Файловый менеджер - Редактировать - /home/jogoso94/public_html/static/img/logo/c3main.js.tar
�азад
home/jogoso94/public_html/jogos/greedy_grub/scripts/c3main.js 0000644 00005323147 15043006231 0020302 0 ustar 00 // Generated by Construct, the game and animation creation tool // Visit: https://www.construct.net var __create=Object.create,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty,__require=(e=>"undefined"!=typeof require?require:"undefined"!=typeof Proxy?new Proxy(e,{get:(e,t)=>("undefined"!=typeof require?require:e)[t]}):e)(function(e){if("undefined"!=typeof require)return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),__commonJS=(e,t)=>function(){return t||(0,e[__getOwnPropNames(e)[0]])((t={exports:{}}).exports,t),t.exports},__copyProps=(t,s,i,n)=>{if(s&&"object"==typeof s||"function"==typeof s)for(let e of __getOwnPropNames(s))__hasOwnProp.call(t,e)||e===i||__defProp(t,e,{get:()=>s[e],enumerable:!(n=__getOwnPropDesc(s,e))||n.enumerable});return t},__toESM=(e,t,s)=>(s=null!=e?__create(__getProtoOf(e)):{},__copyProps(!t&&e&&e.__esModule?s:__defProp(s,"default",{value:e,enumerable:!0}),e)),require_c3runtime=__commonJS({"file-map:scripts/c3runtime.js"(exports,module){{let setMatrixArrayType2=function(e){ARRAY_TYPE=e},toRadian2=function(e){return e*degree},equals$92=function(e,t){return Math.abs(e-t)<=EPSILON*Math.max(1,Math.abs(e),Math.abs(t))},create$82=function(){var e=new ARRAY_TYPE(4);return ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e},clone$82=function(e){var t=new ARRAY_TYPE(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},copy$82=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},identity$52=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e},fromValues$82=function(e,t,s,i){var n=new ARRAY_TYPE(4);return n[0]=e,n[1]=t,n[2]=s,n[3]=i,n},set$82=function(e,t,s,i,n){return e[0]=t,e[1]=s,e[2]=i,e[3]=n,e},transpose$22=function(e,t){var s;return e===t?(s=t[1],e[1]=t[2],e[2]=s):(e[0]=t[0],e[1]=t[2],e[2]=t[1],e[3]=t[3]),e},invert$52=function(e,t){var s=t[0],i=t[1],n=t[2],r=s*(t=t[3])-n*i;return r?(e[0]=t*(r=1/r),e[1]=-i*r,e[2]=-n*r,e[3]=s*r,e):null},adjoint$22=function(e,t){var s=t[0];return e[0]=t[3],e[1]=-t[1],e[2]=-t[2],e[3]=s,e},determinant$32=function(e){return e[0]*e[3]-e[2]*e[1]},multiply$82=function(e,t,s){var i=t[0],n=t[1],r=t[2],t=t[3],a=s[0],o=s[1],l=s[2],s=s[3];return e[0]=i*a+r*o,e[1]=n*a+t*o,e[2]=i*l+r*s,e[3]=n*l+t*s,e},rotate$42=function(e,t,s){var i=t[0],n=t[1],r=t[2],t=t[3],a=Math.sin(s),s=Math.cos(s);return e[0]=i*s+r*a,e[1]=n*s+t*a,e[2]=i*-a+r*s,e[3]=n*-a+t*s,e},scale$82=function(e,t,s){var i=t[0],n=t[1],r=t[2],t=t[3],a=s[0],s=s[1];return e[0]=i*a,e[1]=n*a,e[2]=r*s,e[3]=t*s,e},fromRotation$42=function(e,t){var s=Math.sin(t),t=Math.cos(t);return e[0]=t,e[1]=s,e[2]=-s,e[3]=t,e},fromScaling$32=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=t[1],e},str$82=function(e){return"mat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},frob$32=function(e){return Math.hypot(e[0],e[1],e[2],e[3])},LDU2=function(e,t,s,i){return e[2]=i[2]/i[0],s[0]=i[0],s[1]=i[1],s[3]=i[3]-e[2]*s[1],[e,t,s]},add$82=function(e,t,s){return e[0]=t[0]+s[0],e[1]=t[1]+s[1],e[2]=t[2]+s[2],e[3]=t[3]+s[3],e},subtract$62=function(e,t,s){return e[0]=t[0]-s[0],e[1]=t[1]-s[1],e[2]=t[2]-s[2],e[3]=t[3]-s[3],e},exactEquals$82=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]},equals$82=function(e,t){var s=e[0],i=e[1],n=e[2],e=e[3],r=t[0],a=t[1],o=t[2],t=t[3];return Math.abs(s-r)<=EPSILON*Math.max(1,Math.abs(s),Math.abs(r))&&Math.abs(i-a)<=EPSILON*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(n-o)<=EPSILON*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(e-t)<=EPSILON*Math.max(1,Math.abs(e),Math.abs(t))},multiplyScalar$32=function(e,t,s){return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e[3]=t[3]*s,e},multiplyScalarAndAdd$32=function(e,t,s,i){return e[0]=t[0]+s[0]*i,e[1]=t[1]+s[1]*i,e[2]=t[2]+s[2]*i,e[3]=t[3]+s[3]*i,e},create$72=function(){var e=new ARRAY_TYPE(6);return ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0,e[4]=0,e[5]=0),e[0]=1,e[3]=1,e},clone$72=function(e){var t=new ARRAY_TYPE(6);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t},copy$72=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e},identity$42=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e},fromValues$72=function(e,t,s,i,n,r){var a=new ARRAY_TYPE(6);return a[0]=e,a[1]=t,a[2]=s,a[3]=i,a[4]=n,a[5]=r,a},set$72=function(e,t,s,i,n,r,a){return e[0]=t,e[1]=s,e[2]=i,e[3]=n,e[4]=r,e[5]=a,e},invert$42=function(e,t){var s=t[0],i=t[1],n=t[2],r=t[3],a=t[4],t=t[5],o=s*r-i*n;return o?(e[0]=r*(o=1/o),e[1]=-i*o,e[2]=-n*o,e[3]=s*o,e[4]=(n*t-r*a)*o,e[5]=(i*a-s*t)*o,e):null},determinant$22=function(e){return e[0]*e[3]-e[1]*e[2]},multiply$72=function(e,t,s){var i=t[0],n=t[1],r=t[2],a=t[3],o=t[4],t=t[5],l=s[0],h=s[1],c=s[2],u=s[3],_=s[4],s=s[5];return e[0]=i*l+r*h,e[1]=n*l+a*h,e[2]=i*c+r*u,e[3]=n*c+a*u,e[4]=i*_+r*s+o,e[5]=n*_+a*s+t,e},rotate$32=function(e,t,s){var i=t[0],n=t[1],r=t[2],a=t[3],o=t[4],t=t[5],l=Math.sin(s),s=Math.cos(s);return e[0]=i*s+r*l,e[1]=n*s+a*l,e[2]=i*-l+r*s,e[3]=n*-l+a*s,e[4]=o,e[5]=t,e},scale$72=function(e,t,s){var i=t[0],n=t[1],r=t[2],a=t[3],o=t[4],t=t[5],l=s[0],s=s[1];return e[0]=i*l,e[1]=n*l,e[2]=r*s,e[3]=a*s,e[4]=o,e[5]=t,e},translate$32=function(e,t,s){var i=t[0],n=t[1],r=t[2],a=t[3],o=t[4],t=t[5],l=s[0],s=s[1];return e[0]=i,e[1]=n,e[2]=r,e[3]=a,e[4]=i*l+r*s+o,e[5]=n*l+a*s+t,e},fromRotation$32=function(e,t){var s=Math.sin(t),t=Math.cos(t);return e[0]=t,e[1]=s,e[2]=-s,e[3]=t,e[4]=0,e[5]=0,e},fromScaling$22=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=t[1],e[4]=0,e[5]=0,e},fromTranslation$32=function(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=t[0],e[5]=t[1],e},str$72=function(e){return"mat2d("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+")"},frob$22=function(e){return Math.hypot(e[0],e[1],e[2],e[3],e[4],e[5],1)},add$72=function(e,t,s){return e[0]=t[0]+s[0],e[1]=t[1]+s[1],e[2]=t[2]+s[2],e[3]=t[3]+s[3],e[4]=t[4]+s[4],e[5]=t[5]+s[5],e},subtract$52=function(e,t,s){return e[0]=t[0]-s[0],e[1]=t[1]-s[1],e[2]=t[2]-s[2],e[3]=t[3]-s[3],e[4]=t[4]-s[4],e[5]=t[5]-s[5],e},multiplyScalar$22=function(e,t,s){return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e[3]=t[3]*s,e[4]=t[4]*s,e[5]=t[5]*s,e},multiplyScalarAndAdd$22=function(e,t,s,i){return e[0]=t[0]+s[0]*i,e[1]=t[1]+s[1]*i,e[2]=t[2]+s[2]*i,e[3]=t[3]+s[3]*i,e[4]=t[4]+s[4]*i,e[5]=t[5]+s[5]*i,e},exactEquals$72=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]},equals$72=function(e,t){var s=e[0],i=e[1],n=e[2],r=e[3],a=e[4],e=e[5],o=t[0],l=t[1],h=t[2],c=t[3],u=t[4],t=t[5];return Math.abs(s-o)<=EPSILON*Math.max(1,Math.abs(s),Math.abs(o))&&Math.abs(i-l)<=EPSILON*Math.max(1,Math.abs(i),Math.abs(l))&&Math.abs(n-h)<=EPSILON*Math.max(1,Math.abs(n),Math.abs(h))&&Math.abs(r-c)<=EPSILON*Math.max(1,Math.abs(r),Math.abs(c))&&Math.abs(a-u)<=EPSILON*Math.max(1,Math.abs(a),Math.abs(u))&&Math.abs(e-t)<=EPSILON*Math.max(1,Math.abs(e),Math.abs(t))},create$62=function(){var e=new ARRAY_TYPE(9);return ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e},fromMat4$12=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e},clone$62=function(e){var t=new ARRAY_TYPE(9);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t},copy$62=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e},fromValues$62=function(e,t,s,i,n,r,a,o,l){var h=new ARRAY_TYPE(9);return h[0]=e,h[1]=t,h[2]=s,h[3]=i,h[4]=n,h[5]=r,h[6]=a,h[7]=o,h[8]=l,h},set$62=function(e,t,s,i,n,r,a,o,l,h){return e[0]=t,e[1]=s,e[2]=i,e[3]=n,e[4]=r,e[5]=a,e[6]=o,e[7]=l,e[8]=h,e},identity$32=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},transpose$12=function(e,t){var s,i,n;return e===t?(s=t[1],i=t[2],n=t[5],e[1]=t[3],e[2]=t[6],e[3]=s,e[5]=t[7],e[6]=i,e[7]=n):(e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8]),e},invert$32=function(e,t){var s=t[0],i=t[1],n=t[2],r=t[3],a=t[4],o=t[5],l=t[6],h=t[7],c=(t=t[8])*a-o*h,u=-t*r+o*l,_=h*r-a*l,d=s*c+i*u+n*_;return d?(e[0]=c*(d=1/d),e[1]=(-t*i+n*h)*d,e[2]=(o*i-n*a)*d,e[3]=u*d,e[4]=(t*s-n*l)*d,e[5]=(-o*s+n*r)*d,e[6]=_*d,e[7]=(-h*s+i*l)*d,e[8]=(a*s-i*r)*d,e):null},adjoint$12=function(e,t){var s=t[0],i=t[1],n=t[2],r=t[3],a=t[4],o=t[5],l=t[6],h=t[7],t=t[8];return e[0]=a*t-o*h,e[1]=n*h-i*t,e[2]=i*o-n*a,e[3]=o*l-r*t,e[4]=s*t-n*l,e[5]=n*r-s*o,e[6]=r*h-a*l,e[7]=i*l-s*h,e[8]=s*a-i*r,e},determinant$12=function(e){var t=e[0],s=e[3],i=e[4],n=e[5],r=e[6],a=e[7],o=e[8];return t*(o*i-n*a)+e[1]*(-o*s+n*r)+e[2]*(a*s-i*r)},multiply$62=function(e,t,s){var i=t[0],n=t[1],r=t[2],a=t[3],o=t[4],l=t[5],h=t[6],c=t[7],t=t[8],u=s[0],_=s[1],d=s[2],p=s[3],m=s[4],g=s[5],f=s[6],S=s[7],s=s[8];return e[0]=u*i+_*a+d*h,e[1]=u*n+_*o+d*c,e[2]=u*r+_*l+d*t,e[3]=p*i+m*a+g*h,e[4]=p*n+m*o+g*c,e[5]=p*r+m*l+g*t,e[6]=f*i+S*a+s*h,e[7]=f*n+S*o+s*c,e[8]=f*r+S*l+s*t,e},translate$22=function(e,t,s){var i=t[0],n=t[1],r=t[2],a=t[3],o=t[4],l=t[5],h=t[6],c=t[7],t=t[8],u=s[0],s=s[1];return e[0]=i,e[1]=n,e[2]=r,e[3]=a,e[4]=o,e[5]=l,e[6]=u*i+s*a+h,e[7]=u*n+s*o+c,e[8]=u*r+s*l+t,e},rotate$22=function(e,t,s){var i=t[0],n=t[1],r=t[2],a=t[3],o=t[4],l=t[5],h=t[6],c=t[7],t=t[8],u=Math.sin(s),s=Math.cos(s);return e[0]=s*i+u*a,e[1]=s*n+u*o,e[2]=s*r+u*l,e[3]=s*a-u*i,e[4]=s*o-u*n,e[5]=s*l-u*r,e[6]=h,e[7]=c,e[8]=t,e},scale$62=function(e,t,s){var i=s[0],s=s[1];return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=s*t[3],e[4]=s*t[4],e[5]=s*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e},fromTranslation$22=function(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=t[0],e[7]=t[1],e[8]=1,e},fromRotation$22=function(e,t){var s=Math.sin(t),t=Math.cos(t);return e[0]=t,e[1]=s,e[2]=0,e[3]=-s,e[4]=t,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},fromScaling$12=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=t[1],e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},fromMat2d2=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=0,e[3]=t[2],e[4]=t[3],e[5]=0,e[6]=t[4],e[7]=t[5],e[8]=1,e},fromQuat$12=function(e,t){var s=t[0],i=t[2],n=i+i,s=s*(h=s+s),r=(a=t[1])*h,a=a*(c=a+a),o=i*h,l=i*c,h=(t=t[3])*h,c=t*c,t=t*n;return e[0]=1-a-(i=i*n),e[3]=r-t,e[6]=o+c,e[1]=r+t,e[4]=1-s-i,e[7]=l-h,e[2]=o-c,e[5]=l+h,e[8]=1-s-a,e},normalFromMat42=function(e,t){var s=t[0],i=t[1],n=t[2],r=t[3],a=t[4],o=t[5],l=t[6],h=t[7],c=t[8],u=t[9],_=t[10],d=t[11],p=t[12],m=t[13],g=t[14],f=s*o-i*a,S=s*l-n*a,C=s*h-r*a,y=i*l-n*o,G=i*h-r*o,I=n*h-r*l,T=c*m-u*p,b=c*g-_*p,P=u*g-_*m;return(d=f*(_=_*(t=t[15])-d*g)-S*(u=u*t-d*m)+C*P+y*(c=c*t-d*p)-G*b+I*T)?(e[0]=(o*_-l*u+h*P)*(d=1/d),e[1]=(l*c-a*_-h*b)*d,e[2]=(a*u-o*c+h*T)*d,e[3]=(n*u-i*_-r*P)*d,e[4]=(s*_-n*c+r*b)*d,e[5]=(i*c-s*u-r*T)*d,e[6]=(m*I-g*G+t*y)*d,e[7]=(g*C-p*I-t*S)*d,e[8]=(p*G-m*C+t*f)*d,e):null},projection2=function(e,t,s){return e[0]=2/t,e[1]=0,e[2]=0,e[3]=0,e[4]=-2/s,e[5]=0,e[6]=-1,e[7]=1,e[8]=1,e},str$62=function(e){return"mat3("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+")"},frob$12=function(e){return Math.hypot(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},add$62=function(e,t,s){return e[0]=t[0]+s[0],e[1]=t[1]+s[1],e[2]=t[2]+s[2],e[3]=t[3]+s[3],e[4]=t[4]+s[4],e[5]=t[5]+s[5],e[6]=t[6]+s[6],e[7]=t[7]+s[7],e[8]=t[8]+s[8],e},subtract$42=function(e,t,s){return e[0]=t[0]-s[0],e[1]=t[1]-s[1],e[2]=t[2]-s[2],e[3]=t[3]-s[3],e[4]=t[4]-s[4],e[5]=t[5]-s[5],e[6]=t[6]-s[6],e[7]=t[7]-s[7],e[8]=t[8]-s[8],e},multiplyScalar$12=function(e,t,s){return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e[3]=t[3]*s,e[4]=t[4]*s,e[5]=t[5]*s,e[6]=t[6]*s,e[7]=t[7]*s,e[8]=t[8]*s,e},multiplyScalarAndAdd$12=function(e,t,s,i){return e[0]=t[0]+s[0]*i,e[1]=t[1]+s[1]*i,e[2]=t[2]+s[2]*i,e[3]=t[3]+s[3]*i,e[4]=t[4]+s[4]*i,e[5]=t[5]+s[5]*i,e[6]=t[6]+s[6]*i,e[7]=t[7]+s[7]*i,e[8]=t[8]+s[8]*i,e},exactEquals$62=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]},equals$62=function(e,t){var s=e[0],i=e[1],n=e[2],r=e[3],a=e[4],o=e[5],l=e[6],h=e[7],e=e[8],c=t[0],u=t[1],_=t[2],d=t[3],p=t[4],m=t[5],g=t[6],f=t[7],t=t[8];return Math.abs(s-c)<=EPSILON*Math.max(1,Math.abs(s),Math.abs(c))&&Math.abs(i-u)<=EPSILON*Math.max(1,Math.abs(i),Math.abs(u))&&Math.abs(n-_)<=EPSILON*Math.max(1,Math.abs(n),Math.abs(_))&&Math.abs(r-d)<=EPSILON*Math.max(1,Math.abs(r),Math.abs(d))&&Math.abs(a-p)<=EPSILON*Math.max(1,Math.abs(a),Math.abs(p))&&Math.abs(o-m)<=EPSILON*Math.max(1,Math.abs(o),Math.abs(m))&&Math.abs(l-g)<=EPSILON*Math.max(1,Math.abs(l),Math.abs(g))&&Math.abs(h-f)<=EPSILON*Math.max(1,Math.abs(h),Math.abs(f))&&Math.abs(e-t)<=EPSILON*Math.max(1,Math.abs(e),Math.abs(t))},create$52=function(){var e=new ARRAY_TYPE(16);return ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e},clone$52=function(e){var t=new ARRAY_TYPE(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},copy$52=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},fromValues$52=function(e,t,s,i,n,r,a,o,l,h,c,u,_,d,p,m){var g=new ARRAY_TYPE(16);return g[0]=e,g[1]=t,g[2]=s,g[3]=i,g[4]=n,g[5]=r,g[6]=a,g[7]=o,g[8]=l,g[9]=h,g[10]=c,g[11]=u,g[12]=_,g[13]=d,g[14]=p,g[15]=m,g},set$52=function(e,t,s,i,n,r,a,o,l,h,c,u,_,d,p,m,g){return e[0]=t,e[1]=s,e[2]=i,e[3]=n,e[4]=r,e[5]=a,e[6]=o,e[7]=l,e[8]=h,e[9]=c,e[10]=u,e[11]=_,e[12]=d,e[13]=p,e[14]=m,e[15]=g,e},identity$22=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},transpose2=function(e,t){var s,i,n,r,a,o;return e===t?(s=t[1],i=t[2],n=t[3],r=t[6],a=t[7],o=t[11],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=s,e[6]=t[9],e[7]=t[13],e[8]=i,e[9]=r,e[11]=t[14],e[12]=n,e[13]=a,e[14]=o):(e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15]),e},invert$22=function(e,t){var s=t[0],i=t[1],n=t[2],r=t[3],a=t[4],o=t[5],l=t[6],h=t[7],c=t[8],u=t[9],_=t[10],d=t[11],p=t[12],m=t[13],g=t[14],f=s*o-i*a,S=s*l-n*a,C=s*h-r*a,y=i*l-n*o,G=i*h-r*o,I=n*h-r*l,T=c*m-u*p,b=c*g-_*p,P=c*(t=t[15])-d*p,A=u*g-_*m,R=u*t-d*m,E=_*t-d*g,v=f*E-S*R+C*A+y*P-G*b+I*T;return v?(e[0]=(o*E-l*R+h*A)*(v=1/v),e[1]=(n*R-i*E-r*A)*v,e[2]=(m*I-g*G+t*y)*v,e[3]=(_*G-u*I-d*y)*v,e[4]=(l*P-a*E-h*b)*v,e[5]=(s*E-n*P+r*b)*v,e[6]=(g*C-p*I-t*S)*v,e[7]=(c*I-_*C+d*S)*v,e[8]=(a*R-o*P+h*T)*v,e[9]=(i*P-s*R-r*T)*v,e[10]=(p*G-m*C+t*f)*v,e[11]=(u*C-c*G-d*f)*v,e[12]=(o*b-a*A-l*T)*v,e[13]=(s*A-i*b+n*T)*v,e[14]=(m*S-p*y-g*f)*v,e[15]=(c*y-u*S+_*f)*v,e):null},adjoint2=function(e,t){var s=t[0],i=t[1],n=t[2],r=t[3],a=t[4],o=t[5],l=t[6],h=t[7],c=t[8],u=t[9],_=t[10],d=t[11],p=t[12],m=t[13],g=t[14],f=s*o-i*a,S=s*l-n*a,C=s*h-r*a,y=i*l-n*o,G=i*h-r*o,I=n*h-r*l,T=c*m-u*p,b=c*g-_*p,P=c*(t=t[15])-d*p,A=u*g-_*m,R=u*t-d*m,E=_*t-d*g;return e[0]=o*E-l*R+h*A,e[1]=n*R-i*E-r*A,e[2]=m*I-g*G+t*y,e[3]=_*G-u*I-d*y,e[4]=l*P-a*E-h*b,e[5]=s*E-n*P+r*b,e[6]=g*C-p*I-t*S,e[7]=c*I-_*C+d*S,e[8]=a*R-o*P+h*T,e[9]=i*P-s*R-r*T,e[10]=p*G-m*C+t*f,e[11]=u*C-c*G-d*f,e[12]=o*b-a*A-l*T,e[13]=s*A-i*b+n*T,e[14]=m*S-p*y-g*f,e[15]=c*y-u*S+_*f,e},determinant2=function(e){var t=e[0],s=e[1],i=e[2],n=e[4],r=e[5],a=e[6],o=e[8],l=e[9],h=e[10],c=e[12],u=e[13],_=e[14],d=t*r-s*n,p=t*a-i*n,m=s*a-i*r,g=o*u-l*c,f=o*_-h*c,S=l*_-h*u;return e[7]*(t*S-s*f+i*g)-e[3]*(n*S-r*f+a*g)+e[15]*(o*m-l*p+h*d)-e[11]*(c*m-u*p+_*d)},multiply$52=function(e,t,s){var i=t[0],n=t[1],r=t[2],a=t[3],o=t[4],l=t[5],h=t[6],c=t[7],u=t[8],_=t[9],d=t[10],p=t[11],m=t[12],g=t[13],f=t[14],t=t[15],S=s[0],C=s[1],y=s[2],G=s[3];return e[0]=S*i+C*o+y*u+G*m,e[1]=S*n+C*l+y*_+G*g,e[2]=S*r+C*h+y*d+G*f,e[3]=S*a+C*c+y*p+G*t,e[4]=(S=s[4])*i+(C=s[5])*o+(y=s[6])*u+(G=s[7])*m,e[5]=S*n+C*l+y*_+G*g,e[6]=S*r+C*h+y*d+G*f,e[7]=S*a+C*c+y*p+G*t,e[8]=(S=s[8])*i+(C=s[9])*o+(y=s[10])*u+(G=s[11])*m,e[9]=S*n+C*l+y*_+G*g,e[10]=S*r+C*h+y*d+G*f,e[11]=S*a+C*c+y*p+G*t,e[12]=(S=s[12])*i+(C=s[13])*o+(y=s[14])*u+(G=s[15])*m,e[13]=S*n+C*l+y*_+G*g,e[14]=S*r+C*h+y*d+G*f,e[15]=S*a+C*c+y*p+G*t,e},translate$12=function(e,t,s){var i,n,r,a,o,l,h,c,u,_,d,p,m=s[0],g=s[1],s=s[2];return t===e?(e[12]=t[0]*m+t[4]*g+t[8]*s+t[12],e[13]=t[1]*m+t[5]*g+t[9]*s+t[13],e[14]=t[2]*m+t[6]*g+t[10]*s+t[14],e[15]=t[3]*m+t[7]*g+t[11]*s+t[15]):(i=t[0],n=t[1],r=t[2],a=t[3],o=t[4],l=t[5],h=t[6],c=t[7],u=t[8],_=t[9],d=t[10],p=t[11],e[0]=i,e[1]=n,e[2]=r,e[3]=a,e[4]=o,e[5]=l,e[6]=h,e[7]=c,e[8]=u,e[9]=_,e[10]=d,e[11]=p,e[12]=i*m+o*g+u*s+t[12],e[13]=n*m+l*g+_*s+t[13],e[14]=r*m+h*g+d*s+t[14],e[15]=a*m+c*g+p*s+t[15]),e},scale$52=function(e,t,s){var i=s[0],n=s[1],s=s[2];return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e[4]=t[4]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7]*n,e[8]=t[8]*s,e[9]=t[9]*s,e[10]=t[10]*s,e[11]=t[11]*s,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},rotate$12=function(e,t,s,i){var n,r,a,o,l,h,c,u,_,d,p,m,g,f,S,C,y,G,I,T,b=i[0],P=i[1],i=i[2],A=Math.hypot(b,P,i);return A<EPSILON?null:(b*=A=1/A,P*=A,i*=A,A=Math.sin(s),s=Math.cos(s),r=t[0],a=t[1],o=t[2],l=t[3],c=t[5],u=t[6],_=t[7],p=t[9],m=t[10],g=t[11],S=b*P*(n=1-s)-i*A,C=P*P*n+s,y=i*P*n+b*A,G=b*i*n+P*A,I=P*i*n-b*A,T=i*i*n+s,e[0]=r*(s=b*b*n+s)+(h=t[4])*(f=P*b*n+i*A)+(d=t[8])*(i=i*b*n-P*A),e[1]=a*s+c*f+p*i,e[2]=o*s+u*f+m*i,e[3]=l*s+_*f+g*i,e[4]=r*S+h*C+d*y,e[5]=a*S+c*C+p*y,e[6]=o*S+u*C+m*y,e[7]=l*S+_*C+g*y,e[8]=r*G+h*I+d*T,e[9]=a*G+c*I+p*T,e[10]=o*G+u*I+m*T,e[11]=l*G+_*I+g*T,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)},rotateX$32=function(e,t,s){var i=Math.sin(s),s=Math.cos(s),n=t[4],r=t[5],a=t[6],o=t[7],l=t[8],h=t[9],c=t[10],u=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=n*s+l*i,e[5]=r*s+h*i,e[6]=a*s+c*i,e[7]=o*s+u*i,e[8]=l*s-n*i,e[9]=h*s-r*i,e[10]=c*s-a*i,e[11]=u*s-o*i,e},rotateY$32=function(e,t,s){var i=Math.sin(s),s=Math.cos(s),n=t[0],r=t[1],a=t[2],o=t[3],l=t[8],h=t[9],c=t[10],u=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=n*s-l*i,e[1]=r*s-h*i,e[2]=a*s-c*i,e[3]=o*s-u*i,e[8]=n*i+l*s,e[9]=r*i+h*s,e[10]=a*i+c*s,e[11]=o*i+u*s,e},rotateZ$32=function(e,t,s){var i=Math.sin(s),s=Math.cos(s),n=t[0],r=t[1],a=t[2],o=t[3],l=t[4],h=t[5],c=t[6],u=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=n*s+l*i,e[1]=r*s+h*i,e[2]=a*s+c*i,e[3]=o*s+u*i,e[4]=l*s-n*i,e[5]=h*s-r*i,e[6]=c*s-a*i,e[7]=u*s-o*i,e},fromTranslation$12=function(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e},fromScaling2=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},fromRotation$12=function(e,t,s){var i,n=s[0],r=s[1],s=s[2],a=Math.hypot(n,r,s);return a<EPSILON?null:(n*=a=1/a,r*=a,s*=a,a=Math.sin(t),t=Math.cos(t),e[0]=n*n*(i=1-t)+t,e[1]=r*n*i+s*a,e[2]=s*n*i-r*a,e[3]=0,e[4]=n*r*i-s*a,e[5]=r*r*i+t,e[6]=s*r*i+n*a,e[7]=0,e[8]=n*s*i+r*a,e[9]=r*s*i-n*a,e[10]=s*s*i+t,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)},fromXRotation2=function(e,t){var s=Math.sin(t),t=Math.cos(t);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t,e[6]=s,e[7]=0,e[8]=0,e[9]=-s,e[10]=t,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},fromYRotation2=function(e,t){var s=Math.sin(t),t=Math.cos(t);return e[0]=t,e[1]=0,e[2]=-s,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=s,e[9]=0,e[10]=t,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},fromZRotation2=function(e,t){var s=Math.sin(t),t=Math.cos(t);return e[0]=t,e[1]=s,e[2]=0,e[3]=0,e[4]=-s,e[5]=t,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},fromRotationTranslation$12=function(e,t,s){var i=t[0],n=t[2],r=n+n,a=i*(c=i+i),o=i*(u=(h=t[1])+h),i=i*r,l=h*u,h=h*r,c=(t=t[3])*c,u=t*u,t=t*r;return e[0]=1-(l+(n=n*r)),e[1]=o+t,e[2]=i-u,e[3]=0,e[4]=o-t,e[5]=1-(a+n),e[6]=h+c,e[7]=0,e[8]=i+u,e[9]=h-c,e[10]=1-(a+l),e[11]=0,e[12]=s[0],e[13]=s[1],e[14]=s[2],e[15]=1,e},fromQuat22=function(e,t){var s=new ARRAY_TYPE(3),i=-t[0],n=-t[1],r=-t[2],a=t[3],o=t[4],l=t[5],h=t[6],c=t[7],u=i*i+n*n+r*r+a*a;return 0<u?(s[0]=2*(o*a+c*i+l*r-h*n)/u,s[1]=2*(l*a+c*n+h*i-o*r)/u,s[2]=2*(h*a+c*r+o*n-l*i)/u):(s[0]=2*(o*a+c*i+l*r-h*n),s[1]=2*(l*a+c*n+h*i-o*r),s[2]=2*(h*a+c*r+o*n-l*i)),fromRotationTranslation$12(e,t,s),e},getTranslation$12=function(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e},getScaling2=function(e,t){var s=t[0],i=t[4],n=t[5],r=t[6],a=t[8],o=t[9],l=t[10];return e[0]=Math.hypot(s,t[1],t[2]),e[1]=Math.hypot(i,n,r),e[2]=Math.hypot(a,o,l),e},getRotation2=function(e,t){var s=new ARRAY_TYPE(3),i=(getScaling2(s,t),1/s[0]),n=1/s[1],s=1/s[2],r=t[0]*i,a=t[1]*n,o=t[2]*s,l=t[4]*i,h=t[5]*n,c=t[6]*s,i=t[8]*i,n=t[9]*n,u=0;return 0<(s=r+h+(t=t[10]*s))?(u=2*Math.sqrt(1+s),e[3]=.25*u,e[0]=(c-n)/u,e[1]=(i-o)/u,e[2]=(a-l)/u):h<r&&t<r?(u=2*Math.sqrt(1+r-h-t),e[3]=(c-n)/u,e[0]=.25*u,e[1]=(a+l)/u,e[2]=(i+o)/u):t<h?(u=2*Math.sqrt(1+h-r-t),e[3]=(i-o)/u,e[0]=(a+l)/u,e[1]=.25*u,e[2]=(c+n)/u):(u=2*Math.sqrt(1+t-r-h),e[3]=(a-l)/u,e[0]=(i+o)/u,e[1]=(c+n)/u,e[2]=.25*u),e},decompose2=function(e,t,s,i){t[0]=i[12],t[1]=i[13],t[2]=i[14];var t=i[0],n=i[1],r=i[2],a=i[4],o=i[5],l=i[6],h=i[8],c=i[9],i=i[10],u=(s[0]=Math.hypot(t,n,r),s[1]=Math.hypot(a,o,l),s[2]=Math.hypot(h,c,i),1/s[0]),_=1/s[1],t=t*u,n=n*_,r=r*(s=1/s[2]),a=a*u,l=l*s,h=h*u,u=c*_,c=i*s,i=0;return 0<(_=t+(o=o*_)+c)?(i=2*Math.sqrt(1+_),e[3]=.25*i,e[0]=(l-u)/i,e[1]=(h-r)/i,e[2]=(n-a)/i):o<t&&c<t?(i=2*Math.sqrt(1+t-o-c),e[3]=(l-u)/i,e[0]=.25*i,e[1]=(n+a)/i,e[2]=(h+r)/i):c<o?(i=2*Math.sqrt(1+o-t-c),e[3]=(h-r)/i,e[0]=(n+a)/i,e[1]=.25*i,e[2]=(l+u)/i):(i=2*Math.sqrt(1+c-t-o),e[3]=(n-a)/i,e[0]=(h+r)/i,e[1]=(l+u)/i,e[2]=.25*i),e},fromRotationTranslationScale2=function(e,t,s,i){var n=(a=t[0])*(c=a+a),r=a*(u=(l=t[1])+l),a=a*(_=(h=t[2])+h),o=l*u,l=l*_,h=h*_,c=(t=t[3])*c,u=t*u,t=t*_,_=i[0],d=i[1],i=i[2];return e[0]=(1-(o+h))*_,e[1]=(r+t)*_,e[2]=(a-u)*_,e[3]=0,e[4]=(r-t)*d,e[5]=(1-(n+h))*d,e[6]=(l+c)*d,e[7]=0,e[8]=(a+u)*i,e[9]=(l-c)*i,e[10]=(1-(n+o))*i,e[11]=0,e[12]=s[0],e[13]=s[1],e[14]=s[2],e[15]=1,e},fromRotationTranslationScaleOrigin2=function(e,t,s,i,n){var r=(o=t[0])*(u=o+o),a=o*(_=(h=t[1])+h),o=o*(d=(c=t[2])+c),l=h*_,h=h*d,c=c*d,u=(t=t[3])*u,_=t*_,t=t*d,d=i[0],p=i[1],i=i[2],m=n[0],g=n[1],n=n[2],f=(1-(l+c))*d,S=(a+t)*d,d=(o-_)*d,a=(a-t)*p,t=(1-(r+c))*p,c=(h+u)*p,p=(o+_)*i,o=(h-u)*i,_=(1-(r+l))*i;return e[0]=f,e[1]=S,e[2]=d,e[3]=0,e[4]=a,e[5]=t,e[6]=c,e[7]=0,e[8]=p,e[9]=o,e[10]=_,e[11]=0,e[12]=s[0]+m-(f*m+a*g+p*n),e[13]=s[1]+g-(S*m+t*g+o*n),e[14]=s[2]+n-(d*m+c*g+_*n),e[15]=1,e},fromQuat3=function(e,t){var s=t[0],i=t[2],n=i+i,s=s*(h=s+s),r=(a=t[1])*h,a=a*(c=a+a),o=i*h,l=i*c,h=(t=t[3])*h,c=t*c,t=t*n;return e[0]=1-a-(i=i*n),e[1]=r+t,e[2]=o-c,e[3]=0,e[4]=r-t,e[5]=1-s-i,e[6]=l+h,e[7]=0,e[8]=o+c,e[9]=l-h,e[10]=1-s-a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},frustum2=function(e,t,s,i,n,r,a){var o=1/(s-t),l=1/(n-i),h=1/(r-a);return e[0]=2*r*o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*r*l,e[6]=0,e[7]=0,e[8]=(s+t)*o,e[9]=(n+i)*l,e[10]=(a+r)*h,e[11]=-1,e[12]=0,e[13]=0,e[14]=a*r*2*h,e[15]=0,e},perspectiveNO2=function(e,t,s,i,n){return t=1/Math.tan(t/2),e[0]=t/s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=n&&n!==1/0?(e[10]=(n+i)*(s=1/(i-n)),e[14]=2*n*i*s):(e[10]=-1,e[14]=-2*i),e},perspectiveZO2=function(e,t,s,i,n){return t=1/Math.tan(t/2),e[0]=t/s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=n&&n!==1/0?(e[10]=n*(s=1/(i-n)),e[14]=n*i*s):(e[10]=-1,e[14]=-i),e},perspectiveFromFieldOfView2=function(e,t,s,i){var n=Math.tan(t.upDegrees*Math.PI/180),r=Math.tan(t.downDegrees*Math.PI/180),a=Math.tan(t.leftDegrees*Math.PI/180),o=2/(a+(t=Math.tan(t.rightDegrees*Math.PI/180))),l=2/(n+r);return e[0]=o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=l,e[6]=0,e[7]=0,e[8]=-(a-t)*o*.5,e[9]=(n-r)*l*.5,e[10]=i/(s-i),e[11]=-1,e[12]=0,e[13]=0,e[14]=i*s/(s-i),e[15]=0,e},orthoNO2=function(e,t,s,i,n,r,a){var o=1/(t-s),l=1/(i-n),h=1/(r-a);return e[0]=-2*o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*h,e[11]=0,e[12]=(t+s)*o,e[13]=(n+i)*l,e[14]=(a+r)*h,e[15]=1,e},orthoZO2=function(e,t,s,i,n,r,a){var o=1/(t-s),l=1/(i-n),a=1/(r-a);return e[0]=-2*o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=a,e[11]=0,e[12]=(t+s)*o,e[13]=(n+i)*l,e[14]=r*a,e[15]=1,e},lookAt2=function(e,t,s,i){var n,r,a,o,l=t[0],h=t[1],t=t[2],c=i[0],u=i[1],i=i[2],_=s[0],d=s[1],s=s[2];return Math.abs(l-_)<EPSILON&&Math.abs(h-d)<EPSILON&&Math.abs(t-s)<EPSILON?identity$22(e):(_=l-_,d=h-d,s=t-s,n=u*(s*=o=1/Math.hypot(_,d,s))-i*(d*=o),i=i*(_*=o)-c*s,c=c*d-u*_,(o=Math.hypot(n,i,c))?(n*=o=1/o,i*=o,c*=o):c=i=n=0,u=d*c-s*i,r=s*n-_*c,a=_*i-d*n,(o=Math.hypot(u,r,a))?(u*=o=1/o,r*=o,a*=o):a=r=u=0,e[0]=n,e[1]=u,e[2]=_,e[3]=0,e[4]=i,e[5]=r,e[6]=d,e[7]=0,e[8]=c,e[9]=a,e[10]=s,e[11]=0,e[12]=-(n*l+i*h+c*t),e[13]=-(u*l+r*h+a*t),e[14]=-(_*l+d*h+s*t),e[15]=1,e)},targetTo2=function(e,t,s,i){var n=t[0],r=t[1],t=t[2],a=i[0],o=i[1],i=i[2],l=n-s[0],h=r-s[1],c=l*l+h*h+(s=t-s[2])*s,u=(0<c&&(l*=c=1/Math.sqrt(c),h*=c,s*=c),o*s-i*h);return 0<(c=u*u+(i=i*l-a*s)*i+(a=a*h-o*l)*a)&&(u*=c=1/Math.sqrt(c),i*=c,a*=c),e[0]=u,e[1]=i,e[2]=a,e[3]=0,e[4]=h*a-s*i,e[5]=s*u-l*a,e[6]=l*i-h*u,e[7]=0,e[8]=l,e[9]=h,e[10]=s,e[11]=0,e[12]=n,e[13]=r,e[14]=t,e[15]=1,e},str$52=function(e){return"mat4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+", "+e[9]+", "+e[10]+", "+e[11]+", "+e[12]+", "+e[13]+", "+e[14]+", "+e[15]+")"},frob2=function(e){return Math.hypot(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])},add$52=function(e,t,s){return e[0]=t[0]+s[0],e[1]=t[1]+s[1],e[2]=t[2]+s[2],e[3]=t[3]+s[3],e[4]=t[4]+s[4],e[5]=t[5]+s[5],e[6]=t[6]+s[6],e[7]=t[7]+s[7],e[8]=t[8]+s[8],e[9]=t[9]+s[9],e[10]=t[10]+s[10],e[11]=t[11]+s[11],e[12]=t[12]+s[12],e[13]=t[13]+s[13],e[14]=t[14]+s[14],e[15]=t[15]+s[15],e},subtract$32=function(e,t,s){return e[0]=t[0]-s[0],e[1]=t[1]-s[1],e[2]=t[2]-s[2],e[3]=t[3]-s[3],e[4]=t[4]-s[4],e[5]=t[5]-s[5],e[6]=t[6]-s[6],e[7]=t[7]-s[7],e[8]=t[8]-s[8],e[9]=t[9]-s[9],e[10]=t[10]-s[10],e[11]=t[11]-s[11],e[12]=t[12]-s[12],e[13]=t[13]-s[13],e[14]=t[14]-s[14],e[15]=t[15]-s[15],e},multiplyScalar2=function(e,t,s){return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e[3]=t[3]*s,e[4]=t[4]*s,e[5]=t[5]*s,e[6]=t[6]*s,e[7]=t[7]*s,e[8]=t[8]*s,e[9]=t[9]*s,e[10]=t[10]*s,e[11]=t[11]*s,e[12]=t[12]*s,e[13]=t[13]*s,e[14]=t[14]*s,e[15]=t[15]*s,e},multiplyScalarAndAdd2=function(e,t,s,i){return e[0]=t[0]+s[0]*i,e[1]=t[1]+s[1]*i,e[2]=t[2]+s[2]*i,e[3]=t[3]+s[3]*i,e[4]=t[4]+s[4]*i,e[5]=t[5]+s[5]*i,e[6]=t[6]+s[6]*i,e[7]=t[7]+s[7]*i,e[8]=t[8]+s[8]*i,e[9]=t[9]+s[9]*i,e[10]=t[10]+s[10]*i,e[11]=t[11]+s[11]*i,e[12]=t[12]+s[12]*i,e[13]=t[13]+s[13]*i,e[14]=t[14]+s[14]*i,e[15]=t[15]+s[15]*i,e},exactEquals$52=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]},equals$52=function(e,t){var s=e[0],i=e[1],n=e[2],r=e[3],a=e[4],o=e[5],l=e[6],h=e[7],c=e[8],u=e[9],_=e[10],d=e[11],p=e[12],m=e[13],g=e[14],e=e[15],f=t[0],S=t[1],C=t[2],y=t[3],G=t[4],I=t[5],T=t[6],b=t[7],P=t[8],A=t[9],R=t[10],E=t[11],v=t[12],x=t[13],w=t[14],t=t[15];return Math.abs(s-f)<=EPSILON*Math.max(1,Math.abs(s),Math.abs(f))&&Math.abs(i-S)<=EPSILON*Math.max(1,Math.abs(i),Math.abs(S))&&Math.abs(n-C)<=EPSILON*Math.max(1,Math.abs(n),Math.abs(C))&&Math.abs(r-y)<=EPSILON*Math.max(1,Math.abs(r),Math.abs(y))&&Math.abs(a-G)<=EPSILON*Math.max(1,Math.abs(a),Math.abs(G))&&Math.abs(o-I)<=EPSILON*Math.max(1,Math.abs(o),Math.abs(I))&&Math.abs(l-T)<=EPSILON*Math.max(1,Math.abs(l),Math.abs(T))&&Math.abs(h-b)<=EPSILON*Math.max(1,Math.abs(h),Math.abs(b))&&Math.abs(c-P)<=EPSILON*Math.max(1,Math.abs(c),Math.abs(P))&&Math.abs(u-A)<=EPSILON*Math.max(1,Math.abs(u),Math.abs(A))&&Math.abs(_-R)<=EPSILON*Math.max(1,Math.abs(_),Math.abs(R))&&Math.abs(d-E)<=EPSILON*Math.max(1,Math.abs(d),Math.abs(E))&&Math.abs(p-v)<=EPSILON*Math.max(1,Math.abs(p),Math.abs(v))&&Math.abs(m-x)<=EPSILON*Math.max(1,Math.abs(m),Math.abs(x))&&Math.abs(g-w)<=EPSILON*Math.max(1,Math.abs(g),Math.abs(w))&&Math.abs(e-t)<=EPSILON*Math.max(1,Math.abs(e),Math.abs(t))},create$42=function(){var e=new ARRAY_TYPE(3);return ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e},clone$42=function(e){var t=new ARRAY_TYPE(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},length$42=function(e){var t=e[0];return Math.hypot(t,e[1],e[2])},fromValues$42=function(e,t,s){var i=new ARRAY_TYPE(3);return i[0]=e,i[1]=t,i[2]=s,i},copy$42=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},set$42=function(e,t,s,i){return e[0]=t,e[1]=s,e[2]=i,e},add$42=function(e,t,s){return e[0]=t[0]+s[0],e[1]=t[1]+s[1],e[2]=t[2]+s[2],e},subtract$22=function(e,t,s){return e[0]=t[0]-s[0],e[1]=t[1]-s[1],e[2]=t[2]-s[2],e},multiply$42=function(e,t,s){return e[0]=t[0]*s[0],e[1]=t[1]*s[1],e[2]=t[2]*s[2],e},divide$22=function(e,t,s){return e[0]=t[0]/s[0],e[1]=t[1]/s[1],e[2]=t[2]/s[2],e},ceil$22=function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e},floor$22=function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e},min$22=function(e,t,s){return e[0]=Math.min(t[0],s[0]),e[1]=Math.min(t[1],s[1]),e[2]=Math.min(t[2],s[2]),e},max$22=function(e,t,s){return e[0]=Math.max(t[0],s[0]),e[1]=Math.max(t[1],s[1]),e[2]=Math.max(t[2],s[2]),e},round$22=function(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e[2]=Math.round(t[2]),e},scale$42=function(e,t,s){return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e},scaleAndAdd$22=function(e,t,s,i){return e[0]=t[0]+s[0]*i,e[1]=t[1]+s[1]*i,e[2]=t[2]+s[2]*i,e},distance$22=function(e,t){var s=t[0]-e[0];return Math.hypot(s,t[1]-e[1],t[2]-e[2])},squaredDistance$22=function(e,t){var s=t[0]-e[0],i=t[1]-e[1];return s*s+i*i+(t=t[2]-e[2])*t},squaredLength$42=function(e){var t=e[0],s=e[1];return t*t+s*s+(e=e[2])*e},negate$22=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e},inverse$22=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e},normalize$42=function(e,t){var s=t[0],i=t[1],n=t[2];return 0<(s=s*s+i*i+n*n)&&(s=1/Math.sqrt(s)),e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e},dot$42=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},cross$22=function(e,t,s){var i=t[0],n=t[1],t=t[2],r=s[0],a=s[1],s=s[2];return e[0]=n*s-t*a,e[1]=t*r-i*s,e[2]=i*a-n*r,e},lerp$42=function(e,t,s,i){var n=t[0],r=t[1],t=t[2];return e[0]=n+i*(s[0]-n),e[1]=r+i*(s[1]-r),e[2]=t+i*(s[2]-t),e},slerp$12=function(e,t,s,i){var n=Math.acos(Math.min(Math.max(dot$42(t,s),-1),1)),r=Math.sin(n),a=Math.sin((1-i)*n)/r,i=Math.sin(i*n)/r;return e[0]=a*t[0]+i*s[0],e[1]=a*t[1]+i*s[1],e[2]=a*t[2]+i*s[2],e},hermite2=function(e,t,s,i,n,r){var a=r*r,o=a*(2*r-3)+1,l=a*(r-2)+r,h=a*(r-1);return e[0]=t[0]*o+s[0]*l+i[0]*h+n[0]*(a=a*(3-2*r)),e[1]=t[1]*o+s[1]*l+i[1]*h+n[1]*a,e[2]=t[2]*o+s[2]*l+i[2]*h+n[2]*a,e},bezier2=function(e,t,s,i,n,r){var a=1-r,o=a*a,l=r*r,h=o*a;return e[0]=t[0]*h+s[0]*(o=3*r*o)+i[0]*(a=3*l*a)+n[0]*(l=l*r),e[1]=t[1]*h+s[1]*o+i[1]*a+n[1]*l,e[2]=t[2]*h+s[2]*o+i[2]*a+n[2]*l,e},random$32=function(e,t){t=t||1;var s=2*RANDOM()*Math.PI,i=2*RANDOM()-1,n=Math.sqrt(1-i*i)*t;return e[0]=Math.cos(s)*n,e[1]=Math.sin(s)*n,e[2]=i*t,e},transformMat4$22=function(e,t,s){var i=t[0],n=t[1],t=t[2],r=s[3]*i+s[7]*n+s[11]*t+s[15];return e[0]=(s[0]*i+s[4]*n+s[8]*t+s[12])/(r=r||1),e[1]=(s[1]*i+s[5]*n+s[9]*t+s[13])/r,e[2]=(s[2]*i+s[6]*n+s[10]*t+s[14])/r,e},transformMat3$12=function(e,t,s){var i=t[0],n=t[1],t=t[2];return e[0]=i*s[0]+n*s[3]+t*s[6],e[1]=i*s[1]+n*s[4]+t*s[7],e[2]=i*s[2]+n*s[5]+t*s[8],e},transformQuat$12=function(e,t,s){var i=s[0],n=s[1],r=t[0],a=t[1],o=n*(t=t[2])-(u=s[2])*a,l=u*r-i*t,h=i*a-n*r,c=n*h-u*l,u=u*o-i*h,i=i*l-n*o;return l*=n=2*s[3],h*=n,u*=2,i*=2,e[0]=r+(o*=n)+(c*=2),e[1]=a+l+u,e[2]=t+h+i,e},rotateX$22=function(e,t,s,i){var n=[],r=[];return n[0]=t[0]-s[0],n[1]=t[1]-s[1],n[2]=t[2]-s[2],r[0]=n[0],r[1]=n[1]*Math.cos(i)-n[2]*Math.sin(i),r[2]=n[1]*Math.sin(i)+n[2]*Math.cos(i),e[0]=r[0]+s[0],e[1]=r[1]+s[1],e[2]=r[2]+s[2],e},rotateY$22=function(e,t,s,i){var n=[],r=[];return n[0]=t[0]-s[0],n[1]=t[1]-s[1],n[2]=t[2]-s[2],r[0]=n[2]*Math.sin(i)+n[0]*Math.cos(i),r[1]=n[1],r[2]=n[2]*Math.cos(i)-n[0]*Math.sin(i),e[0]=r[0]+s[0],e[1]=r[1]+s[1],e[2]=r[2]+s[2],e},rotateZ$22=function(e,t,s,i){var n=[],r=[];return n[0]=t[0]-s[0],n[1]=t[1]-s[1],n[2]=t[2]-s[2],r[0]=n[0]*Math.cos(i)-n[1]*Math.sin(i),r[1]=n[0]*Math.sin(i)+n[1]*Math.cos(i),r[2]=n[2],e[0]=r[0]+s[0],e[1]=r[1]+s[1],e[2]=r[2]+s[2],e},angle$12=function(e,t){var s=e[0],i=e[1],n=e[2],r=t[0],a=t[1],o=t[2],i=(s=Math.sqrt((s*s+i*i+n*n)*(r*r+a*a+o*o)))&&dot$42(e,t)/s;return Math.acos(Math.min(Math.max(i,-1),1))},zero$22=function(e){return e[0]=0,e[1]=0,e[2]=0,e},str$42=function(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"},exactEquals$42=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]},equals$42=function(e,t){var s=e[0],i=e[1],e=e[2],n=t[0],r=t[1],t=t[2];return Math.abs(s-n)<=EPSILON*Math.max(1,Math.abs(s),Math.abs(n))&&Math.abs(i-r)<=EPSILON*Math.max(1,Math.abs(i),Math.abs(r))&&Math.abs(e-t)<=EPSILON*Math.max(1,Math.abs(e),Math.abs(t))},create$32=function(){var e=new ARRAY_TYPE(4);return ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e},clone$32=function(e){var t=new ARRAY_TYPE(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},fromValues$32=function(e,t,s,i){var n=new ARRAY_TYPE(4);return n[0]=e,n[1]=t,n[2]=s,n[3]=i,n},copy$32=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},set$32=function(e,t,s,i,n){return e[0]=t,e[1]=s,e[2]=i,e[3]=n,e},add$32=function(e,t,s){return e[0]=t[0]+s[0],e[1]=t[1]+s[1],e[2]=t[2]+s[2],e[3]=t[3]+s[3],e},subtract$12=function(e,t,s){return e[0]=t[0]-s[0],e[1]=t[1]-s[1],e[2]=t[2]-s[2],e[3]=t[3]-s[3],e},multiply$32=function(e,t,s){return e[0]=t[0]*s[0],e[1]=t[1]*s[1],e[2]=t[2]*s[2],e[3]=t[3]*s[3],e},divide$12=function(e,t,s){return e[0]=t[0]/s[0],e[1]=t[1]/s[1],e[2]=t[2]/s[2],e[3]=t[3]/s[3],e},ceil$12=function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e[3]=Math.ceil(t[3]),e},floor$12=function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e[3]=Math.floor(t[3]),e},min$12=function(e,t,s){return e[0]=Math.min(t[0],s[0]),e[1]=Math.min(t[1],s[1]),e[2]=Math.min(t[2],s[2]),e[3]=Math.min(t[3],s[3]),e},max$12=function(e,t,s){return e[0]=Math.max(t[0],s[0]),e[1]=Math.max(t[1],s[1]),e[2]=Math.max(t[2],s[2]),e[3]=Math.max(t[3],s[3]),e},round$12=function(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e[2]=Math.round(t[2]),e[3]=Math.round(t[3]),e},scale$32=function(e,t,s){return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e[3]=t[3]*s,e},scaleAndAdd$12=function(e,t,s,i){return e[0]=t[0]+s[0]*i,e[1]=t[1]+s[1]*i,e[2]=t[2]+s[2]*i,e[3]=t[3]+s[3]*i,e},distance$12=function(e,t){var s=t[0]-e[0];return Math.hypot(s,t[1]-e[1],t[2]-e[2],t[3]-e[3])},squaredDistance$12=function(e,t){var s=t[0]-e[0],i=t[1]-e[1],n=t[2]-e[2];return s*s+i*i+n*n+(t=t[3]-e[3])*t},length$32=function(e){var t=e[0];return Math.hypot(t,e[1],e[2],e[3])},squaredLength$32=function(e){var t=e[0],s=e[1],i=e[2];return t*t+s*s+i*i+(e=e[3])*e},negate$12=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=-t[3],e},inverse$12=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e[3]=1/t[3],e},normalize$32=function(e,t){var s=t[0],i=t[1],n=t[2],r=s*s+i*i+n*n+(t=t[3])*t;return 0<r&&(r=1/Math.sqrt(r)),e[0]=s*r,e[1]=i*r,e[2]=n*r,e[3]=t*r,e},dot$32=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},cross$12=function(e,t,s,i){var n=s[0]*i[1]-s[1]*i[0],r=s[0]*i[2]-s[2]*i[0],a=s[0]*i[3]-s[3]*i[0],o=s[1]*i[2]-s[2]*i[1],l=s[1]*i[3]-s[3]*i[1],s=s[2]*i[3]-s[3]*i[2],i=t[0],h=t[1],c=t[2],t=t[3];return e[0]=h*s-c*l+t*o,e[1]=-i*s+c*a-t*r,e[2]=i*l-h*a+t*n,e[3]=-i*o+h*r-c*n,e},lerp$32=function(e,t,s,i){var n=t[0],r=t[1],a=t[2],t=t[3];return e[0]=n+i*(s[0]-n),e[1]=r+i*(s[1]-r),e[2]=a+i*(s[2]-a),e[3]=t+i*(s[3]-t),e},random$22=function(e,t){var s,i,n,r,a,o;for(t=t||1;1<=(a=(s=2*RANDOM()-1)*s+(i=2*RANDOM()-1)*i););for(;1<=(o=(n=2*RANDOM()-1)*n+(r=2*RANDOM()-1)*r););var l=Math.sqrt((1-a)/o);return e[0]=t*s,e[1]=t*i,e[2]=t*n*l,e[3]=t*r*l,e},transformMat4$12=function(e,t,s){var i=t[0],n=t[1],r=t[2],t=t[3];return e[0]=s[0]*i+s[4]*n+s[8]*r+s[12]*t,e[1]=s[1]*i+s[5]*n+s[9]*r+s[13]*t,e[2]=s[2]*i+s[6]*n+s[10]*r+s[14]*t,e[3]=s[3]*i+s[7]*n+s[11]*r+s[15]*t,e},transformQuat2=function(e,t,s){var i=t[0],n=t[1],r=t[2],a=s[0],o=s[1],l=s[2],h=(s=s[3])*i+o*r-l*n,c=s*n+l*i-a*r,u=s*r+a*n-o*i;return e[0]=h*s+(i=-a*i-o*n-l*r)*-a+c*-l-u*-o,e[1]=c*s+i*-o+u*-a-h*-l,e[2]=u*s+i*-l+h*-o-c*-a,e[3]=t[3],e},zero$12=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e},str$32=function(e){return"vec4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},exactEquals$32=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]},equals$32=function(e,t){var s=e[0],i=e[1],n=e[2],e=e[3],r=t[0],a=t[1],o=t[2],t=t[3];return Math.abs(s-r)<=EPSILON*Math.max(1,Math.abs(s),Math.abs(r))&&Math.abs(i-a)<=EPSILON*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(n-o)<=EPSILON*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(e-t)<=EPSILON*Math.max(1,Math.abs(e),Math.abs(t))},create$22=function(){var e=new ARRAY_TYPE(4);return ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e},identity$12=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},setAxisAngle2=function(e,t,s){s*=.5;var i=Math.sin(s);return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=Math.cos(s),e},getAxisAngle2=function(e,t){var s=2*Math.acos(t[3]),i=Math.sin(s/2);return EPSILON<i?(e[0]=t[0]/i,e[1]=t[1]/i,e[2]=t[2]/i):(e[0]=1,e[1]=0,e[2]=0),s},getAngle2=function(e,t){return e=dot$2(e,t),Math.acos(2*e*e-1)},multiply$22=function(e,t,s){var i=t[0],n=t[1],r=t[2],t=t[3],a=s[0],o=s[1],l=s[2],s=s[3];return e[0]=i*s+t*a+n*l-r*o,e[1]=n*s+t*o+r*a-i*l,e[2]=r*s+t*l+i*o-n*a,e[3]=t*s-i*a-n*o-r*l,e},rotateX$12=function(e,t,s){s*=.5;var i=t[0],n=t[1],r=t[2],t=t[3],a=Math.sin(s),s=Math.cos(s);return e[0]=i*s+t*a,e[1]=n*s+r*a,e[2]=r*s-n*a,e[3]=t*s-i*a,e},rotateY$12=function(e,t,s){s*=.5;var i=t[0],n=t[1],r=t[2],t=t[3],a=Math.sin(s),s=Math.cos(s);return e[0]=i*s-r*a,e[1]=n*s+t*a,e[2]=r*s+i*a,e[3]=t*s-n*a,e},rotateZ$12=function(e,t,s){s*=.5;var i=t[0],n=t[1],r=t[2],t=t[3],a=Math.sin(s),s=Math.cos(s);return e[0]=i*s+n*a,e[1]=n*s-i*a,e[2]=r*s+t*a,e[3]=t*s-r*a,e},calculateW2=function(e,t){var s=t[0],i=t[1],t=t[2];return e[0]=s,e[1]=i,e[2]=t,e[3]=Math.sqrt(Math.abs(1-s*s-i*i-t*t)),e},exp2=function(e,t){var s=t[0],i=t[1],n=t[2],t=t[3],r=Math.sqrt(s*s+i*i+n*n),t=Math.exp(t),a=0<r?t*Math.sin(r)/r:0;return e[0]=s*a,e[1]=i*a,e[2]=n*a,e[3]=t*Math.cos(r),e},ln2=function(e,t){var s=t[0],i=t[1],n=t[2],t=t[3],r=0<(r=Math.sqrt(s*s+i*i+n*n))?Math.atan2(r,t)/r:0;return e[0]=s*r,e[1]=i*r,e[2]=n*r,e[3]=.5*Math.log(s*s+i*i+n*n+t*t),e},pow2=function(e,t,s){return ln2(e,t),scale$2(e,e,s),exp2(e,e),e},slerp2=function(e,t,s,i){var n,r,a=t[0],o=t[1],l=t[2],t=t[3],h=s[0],c=s[1],u=s[2],_=a*h+o*c+l*u+t*(s=s[3]);return _<0&&(_=-_,h=-h,c=-c,u=-u,s=-s),_=EPSILON<1-_?(_=Math.acos(_),n=Math.sin(_),r=Math.sin((1-i)*_)/n,Math.sin(i*_)/n):(r=1-i,i),e[0]=r*a+_*h,e[1]=r*o+_*c,e[2]=r*l+_*u,e[3]=r*t+_*s,e},random$12=function(e){var t=RANDOM(),s=RANDOM(),i=RANDOM(),n=Math.sqrt(1-t),t=Math.sqrt(t);return e[0]=n*Math.sin(2*Math.PI*s),e[1]=n*Math.cos(2*Math.PI*s),e[2]=t*Math.sin(2*Math.PI*i),e[3]=t*Math.cos(2*Math.PI*i),e},invert$12=function(e,t){var s=t[0],i=t[1],n=t[2],r=s*s+i*i+n*n+(t=t[3])*t;return e[0]=-s*(r=r?1/r:0),e[1]=-i*r,e[2]=-n*r,e[3]=t*r,e},conjugate$12=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},fromMat32=function(e,t){var s,i,n,r=t[0]+t[4]+t[8];return 0<r?(n=Math.sqrt(r+1),e[3]=.5*n,e[0]=(t[5]-t[7])*(n=.5/n),e[1]=(t[6]-t[2])*n,e[2]=(t[1]-t[3])*n):(s=(1+(r=t[3*(r=t[4]>t[0]?1:0)+r]<t[8]?2:r))%3,i=(2+r)%3,n=Math.sqrt(t[3*r+r]-t[3*s+s]-t[3*i+i]+1),e[r]=.5*n,e[3]=(t[3*s+i]-t[3*i+s])*(n=.5/n),e[s]=(t[3*s+r]+t[3*r+s])*n,e[i]=(t[3*i+r]+t[3*r+i])*n),e},fromEuler2=function(e,t,s,i){var n=4<arguments.length&&void 0!==arguments[4]?arguments[4]:ANGLE_ORDER,r=Math.PI/360,a=(i*=r,s*=r,Math.sin(t*=r)),o=Math.cos(t),l=Math.sin(s),h=Math.cos(s),c=Math.sin(i),u=Math.cos(i);switch(n){case"xyz":e[0]=a*h*u+o*l*c,e[1]=o*l*u-a*h*c,e[2]=o*h*c+a*l*u,e[3]=o*h*u-a*l*c;break;case"xzy":e[0]=a*h*u-o*l*c,e[1]=o*l*u-a*h*c,e[2]=o*h*c+a*l*u,e[3]=o*h*u+a*l*c;break;case"yxz":e[0]=a*h*u+o*l*c,e[1]=o*l*u-a*h*c,e[2]=o*h*c-a*l*u,e[3]=o*h*u+a*l*c;break;case"yzx":e[0]=a*h*u+o*l*c,e[1]=o*l*u+a*h*c,e[2]=o*h*c-a*l*u,e[3]=o*h*u-a*l*c;break;case"zxy":e[0]=a*h*u-o*l*c,e[1]=o*l*u+a*h*c,e[2]=o*h*c+a*l*u,e[3]=o*h*u-a*l*c;break;case"zyx":e[0]=a*h*u-o*l*c,e[1]=o*l*u+a*h*c,e[2]=o*h*c-a*l*u,e[3]=o*h*u+a*l*c;break;default:throw new Error("Unknown angle order "+n)}return e},str$22=function(e){return"quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},equals$22=function(e,t){return Math.abs(dot$32(e,t))>=1-EPSILON},create$12=function(){var e=new ARRAY_TYPE(8);return ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[4]=0,e[5]=0,e[6]=0,e[7]=0),e[3]=1,e},clone$12=function(e){var t=new ARRAY_TYPE(8);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t},fromValues$12=function(e,t,s,i,n,r,a,o){var l=new ARRAY_TYPE(8);return l[0]=e,l[1]=t,l[2]=s,l[3]=i,l[4]=n,l[5]=r,l[6]=a,l[7]=o,l},fromRotationTranslationValues2=function(e,t,s,i,n,r,a){var o=new ARRAY_TYPE(8),n=(o[0]=e,o[1]=t,o[2]=s,o[3]=i,.5*n),r=.5*r,a=.5*a;return o[4]=n*i+r*s-a*t,o[5]=r*i+a*e-n*s,o[6]=a*i+n*t-r*e,o[7]=-n*e-r*t-a*s,o},fromRotationTranslation2=function(e,t,s){var i=.5*s[0],n=.5*s[1],s=.5*s[2],r=t[0],a=t[1],o=t[2],t=t[3];return e[0]=r,e[1]=a,e[2]=o,e[3]=t,e[4]=i*t+n*o-s*a,e[5]=n*t+s*r-i*o,e[6]=s*t+i*a-n*r,e[7]=-i*r-n*a-s*o,e},fromTranslation2=function(e,t){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e[4]=.5*t[0],e[5]=.5*t[1],e[6]=.5*t[2],e[7]=0,e},fromRotation2=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=0,e[5]=0,e[6]=0,e[7]=0,e},fromMat42=function(e,t){var s=create$22(),i=(getRotation2(s,t),new ARRAY_TYPE(3));return getTranslation$12(i,t),fromRotationTranslation2(e,s,i),e},copy$12=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e},identity2=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e[6]=0,e[7]=0,e},set$12=function(e,t,s,i,n,r,a,o,l){return e[0]=t,e[1]=s,e[2]=i,e[3]=n,e[4]=r,e[5]=a,e[6]=o,e[7]=l,e},getDual2=function(e,t){return e[0]=t[4],e[1]=t[5],e[2]=t[6],e[3]=t[7],e},setDual2=function(e,t){return e[4]=t[0],e[5]=t[1],e[6]=t[2],e[7]=t[3],e},getTranslation2=function(e,t){var s=t[4],i=t[5],n=t[6],r=t[7],a=-t[0],o=-t[1],l=-t[2],t=t[3];return e[0]=2*(s*t+r*a+i*l-n*o),e[1]=2*(i*t+r*o+n*a-s*l),e[2]=2*(n*t+r*l+s*o-i*a),e},translate2=function(e,t,s){var i=t[0],n=t[1],r=t[2],a=t[3],o=.5*s[0],l=.5*s[1],s=.5*s[2],h=t[4],c=t[5],u=t[6],t=t[7];return e[0]=i,e[1]=n,e[2]=r,e[3]=a,e[4]=a*o+n*s-r*l+h,e[5]=a*l+r*o-i*s+c,e[6]=a*s+i*l-n*o+u,e[7]=-i*o-n*l-r*s+t,e},rotateX2=function(e,t,s){var i=-t[0],n=-t[1],r=-t[2],a=t[3],o=t[4],l=t[5],h=t[6],c=o*a+(d=t[7])*i+l*r-h*n,u=l*a+d*n+h*i-o*r,_=h*a+d*r+o*n-l*i,d=d*a-o*i-l*n-h*r;return rotateX$12(e,t,s),i=e[0],e[4]=c*(a=e[3])+d*i+u*(r=e[2])-_*(n=e[1]),e[5]=u*a+d*n+_*i-c*r,e[6]=_*a+d*r+c*n-u*i,e[7]=d*a-c*i-u*n-_*r,e},rotateY2=function(e,t,s){var i=-t[0],n=-t[1],r=-t[2],a=t[3],o=t[4],l=t[5],h=t[6],c=o*a+(d=t[7])*i+l*r-h*n,u=l*a+d*n+h*i-o*r,_=h*a+d*r+o*n-l*i,d=d*a-o*i-l*n-h*r;return rotateY$12(e,t,s),i=e[0],e[4]=c*(a=e[3])+d*i+u*(r=e[2])-_*(n=e[1]),e[5]=u*a+d*n+_*i-c*r,e[6]=_*a+d*r+c*n-u*i,e[7]=d*a-c*i-u*n-_*r,e},rotateZ2=function(e,t,s){var i=-t[0],n=-t[1],r=-t[2],a=t[3],o=t[4],l=t[5],h=t[6],c=o*a+(d=t[7])*i+l*r-h*n,u=l*a+d*n+h*i-o*r,_=h*a+d*r+o*n-l*i,d=d*a-o*i-l*n-h*r;return rotateZ$12(e,t,s),i=e[0],e[4]=c*(a=e[3])+d*i+u*(r=e[2])-_*(n=e[1]),e[5]=u*a+d*n+_*i-c*r,e[6]=_*a+d*r+c*n-u*i,e[7]=d*a-c*i-u*n-_*r,e},rotateByQuatAppend2=function(e,t,s){var i=s[0],n=s[1],r=s[2],s=s[3],a=t[0],o=t[1],l=t[2],h=t[3];return e[0]=a*s+h*i+o*r-l*n,e[1]=o*s+h*n+l*i-a*r,e[2]=l*s+h*r+a*n-o*i,e[3]=h*s-a*i-o*n-l*r,e[4]=(a=t[4])*s+(h=t[7])*i+(o=t[5])*r-(l=t[6])*n,e[5]=o*s+h*n+l*i-a*r,e[6]=l*s+h*r+a*n-o*i,e[7]=h*s-a*i-o*n-l*r,e},rotateByQuatPrepend2=function(e,t,s){var i=t[0],n=t[1],r=t[2],t=t[3],a=s[0],o=s[1],l=s[2],h=s[3];return e[0]=i*h+t*a+n*l-r*o,e[1]=n*h+t*o+r*a-i*l,e[2]=r*h+t*l+i*o-n*a,e[3]=t*h-i*a-n*o-r*l,e[4]=i*(h=s[7])+t*(a=s[4])+n*(l=s[6])-r*(o=s[5]),e[5]=n*h+t*o+r*a-i*l,e[6]=r*h+t*l+i*o-n*a,e[7]=t*h-i*a-n*o-r*l,e},rotateAroundAxis2=function(e,t,s,i){var n,r,a,o,l,h;return Math.abs(i)<EPSILON?copy$12(e,t):(h=Math.hypot(s[0],s[1],s[2]),i*=.5,n=(a=Math.sin(i))*s[0]/h,r=a*s[1]/h,a=a*s[2]/h,s=Math.cos(i),h=t[0],e[0]=h*s+(i=t[3])*n+(o=t[1])*a-(l=t[2])*r,e[1]=o*s+i*r+l*n-h*a,e[2]=l*s+i*a+h*r-o*n,e[3]=i*s-h*n-o*r-l*a,e[4]=(i=t[4])*s+(h=t[7])*n+(o=t[5])*a-(l=t[6])*r,e[5]=o*s+h*r+l*n-i*a,e[6]=l*s+h*a+i*r-o*n,e[7]=h*s-i*n-o*r-l*a,e)},add$12=function(e,t,s){return e[0]=t[0]+s[0],e[1]=t[1]+s[1],e[2]=t[2]+s[2],e[3]=t[3]+s[3],e[4]=t[4]+s[4],e[5]=t[5]+s[5],e[6]=t[6]+s[6],e[7]=t[7]+s[7],e},multiply$12=function(e,t,s){var i=t[0],n=t[1],r=t[2],a=t[3],o=s[4],l=s[5],h=s[6],c=s[7],u=t[4],_=t[5],d=t[6],t=t[7],p=s[0],m=s[1],g=s[2],s=s[3];return e[0]=i*s+a*p+n*g-r*m,e[1]=n*s+a*m+r*p-i*g,e[2]=r*s+a*g+i*m-n*p,e[3]=a*s-i*p-n*m-r*g,e[4]=i*c+a*o+n*h-r*l+u*s+t*p+_*g-d*m,e[5]=n*c+a*l+r*o-i*h+_*s+t*m+d*p-u*g,e[6]=r*c+a*h+i*l-n*o+d*s+t*g+u*m-_*p,e[7]=a*c-i*o-n*l-r*h+t*s-u*p-_*m-d*g,e},scale$12=function(e,t,s){return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e[3]=t[3]*s,e[4]=t[4]*s,e[5]=t[5]*s,e[6]=t[6]*s,e[7]=t[7]*s,e},lerp$12=function(e,t,s,i){var n=1-i;return dot$1(t,s)<0&&(i=-i),e[0]=t[0]*n+s[0]*i,e[1]=t[1]*n+s[1]*i,e[2]=t[2]*n+s[2]*i,e[3]=t[3]*n+s[3]*i,e[4]=t[4]*n+s[4]*i,e[5]=t[5]*n+s[5]*i,e[6]=t[6]*n+s[6]*i,e[7]=t[7]*n+s[7]*i,e},invert2=function(e,t){var s=squaredLength$1(t);return e[0]=-t[0]/s,e[1]=-t[1]/s,e[2]=-t[2]/s,e[3]=t[3]/s,e[4]=-t[4]/s,e[5]=-t[5]/s,e[6]=-t[6]/s,e[7]=t[7]/s,e},conjugate2=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e[4]=-t[4],e[5]=-t[5],e[6]=-t[6],e[7]=t[7],e},normalize$12=function(e,t){var s,i,n,r,a,o,l,h,c=squaredLength$1(t);return 0<c&&(c=Math.sqrt(c),h=(s=t[0]/c)*(a=t[4])+(i=t[1]/c)*(o=t[5])+(n=t[2]/c)*(l=t[6])+(r=t[3]/c)*(t=t[7]),e[0]=s,e[1]=i,e[2]=n,e[3]=r,e[4]=(a-s*h)/c,e[5]=(o-i*h)/c,e[6]=(l-n*h)/c,e[7]=(t-r*h)/c),e},str$12=function(e){return"quat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+")"},exactEquals$12=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]},equals$12=function(e,t){var s=e[0],i=e[1],n=e[2],r=e[3],a=e[4],o=e[5],l=e[6],e=e[7],h=t[0],c=t[1],u=t[2],_=t[3],d=t[4],p=t[5],m=t[6],t=t[7];return Math.abs(s-h)<=EPSILON*Math.max(1,Math.abs(s),Math.abs(h))&&Math.abs(i-c)<=EPSILON*Math.max(1,Math.abs(i),Math.abs(c))&&Math.abs(n-u)<=EPSILON*Math.max(1,Math.abs(n),Math.abs(u))&&Math.abs(r-_)<=EPSILON*Math.max(1,Math.abs(r),Math.abs(_))&&Math.abs(a-d)<=EPSILON*Math.max(1,Math.abs(a),Math.abs(d))&&Math.abs(o-p)<=EPSILON*Math.max(1,Math.abs(o),Math.abs(p))&&Math.abs(l-m)<=EPSILON*Math.max(1,Math.abs(l),Math.abs(m))&&Math.abs(e-t)<=EPSILON*Math.max(1,Math.abs(e),Math.abs(t))},create2=function(){var e=new ARRAY_TYPE(2);return ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0),e},clone2=function(e){var t=new ARRAY_TYPE(2);return t[0]=e[0],t[1]=e[1],t},fromValues2=function(e,t){var s=new ARRAY_TYPE(2);return s[0]=e,s[1]=t,s},copy2=function(e,t){return e[0]=t[0],e[1]=t[1],e},set2=function(e,t,s){return e[0]=t,e[1]=s,e},add2=function(e,t,s){return e[0]=t[0]+s[0],e[1]=t[1]+s[1],e},subtract2=function(e,t,s){return e[0]=t[0]-s[0],e[1]=t[1]-s[1],e},multiply2=function(e,t,s){return e[0]=t[0]*s[0],e[1]=t[1]*s[1],e},divide2=function(e,t,s){return e[0]=t[0]/s[0],e[1]=t[1]/s[1],e},ceil2=function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e},floor2=function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e},min2=function(e,t,s){return e[0]=Math.min(t[0],s[0]),e[1]=Math.min(t[1],s[1]),e},max2=function(e,t,s){return e[0]=Math.max(t[0],s[0]),e[1]=Math.max(t[1],s[1]),e},round2=function(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e},scale2=function(e,t,s){return e[0]=t[0]*s,e[1]=t[1]*s,e},scaleAndAdd2=function(e,t,s,i){return e[0]=t[0]+s[0]*i,e[1]=t[1]+s[1]*i,e},distance2=function(e,t){var s=t[0]-e[0];return Math.hypot(s,t[1]-e[1])},squaredDistance2=function(e,t){var s=t[0]-e[0];return s*s+(t=t[1]-e[1])*t},length2=function(e){var t=e[0];return Math.hypot(t,e[1])},squaredLength2=function(e){var t=e[0];return t*t+(e=e[1])*e},negate2=function(e,t){return e[0]=-t[0],e[1]=-t[1],e},inverse2=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e},normalize2=function(e,t){var s=t[0],i=t[1];return 0<(s=s*s+i*i)&&(s=1/Math.sqrt(s)),e[0]=t[0]*s,e[1]=t[1]*s,e},dot2=function(e,t){return e[0]*t[0]+e[1]*t[1]},cross2=function(e,t,s){return t=t[0]*s[1]-t[1]*s[0],e[0]=e[1]=0,e[2]=t,e},lerp2=function(e,t,s,i){var n=t[0],t=t[1];return e[0]=n+i*(s[0]-n),e[1]=t+i*(s[1]-t),e},random2=function(e,t){t=t||1;var s=2*RANDOM()*Math.PI;return e[0]=Math.cos(s)*t,e[1]=Math.sin(s)*t,e},transformMat22=function(e,t,s){var i=t[0],t=t[1];return e[0]=s[0]*i+s[2]*t,e[1]=s[1]*i+s[3]*t,e},transformMat2d2=function(e,t,s){var i=t[0],t=t[1];return e[0]=s[0]*i+s[2]*t+s[4],e[1]=s[1]*i+s[3]*t+s[5],e},transformMat32=function(e,t,s){var i=t[0],t=t[1];return e[0]=s[0]*i+s[3]*t+s[6],e[1]=s[1]*i+s[4]*t+s[7],e},transformMat42=function(e,t,s){var i=t[0],t=t[1];return e[0]=s[0]*i+s[4]*t+s[12],e[1]=s[1]*i+s[5]*t+s[13],e},rotate2=function(e,t,s,i){var n=t[0]-s[0],t=t[1]-s[1],r=Math.sin(i),i=Math.cos(i);return e[0]=n*i-t*r+s[0],e[1]=n*r+t*i+s[1],e},angle2=function(e,t){var s=e[0],e=e[1],i=t[0],t=t[1],n=Math.sqrt((s*s+e*e)*(i*i+t*t));return Math.acos(Math.min(Math.max(n&&(s*i+e*t)/n,-1),1))},zero2=function(e){return e[0]=0,e[1]=0,e},str2=function(e){return"vec2("+e[0]+", "+e[1]+")"},exactEquals2=function(e,t){return e[0]===t[0]&&e[1]===t[1]},equals2=function(e,t){var s=e[0],e=e[1],i=t[0],t=t[1];return Math.abs(s-i)<=EPSILON*Math.max(1,Math.abs(s),Math.abs(i))&&Math.abs(e-t)<=EPSILON*Math.max(1,Math.abs(e),Math.abs(t))};setMatrixArrayType=setMatrixArrayType2,toRadian=toRadian2,equals$9=equals$92,create$8=create$82,clone$8=clone$82,copy$8=copy$82,identity$5=identity$52,fromValues$8=fromValues$82,set$8=set$82,transpose$2=transpose$22,invert$5=invert$52,adjoint$2=adjoint$22,determinant$3=determinant$32,multiply$8=multiply$82,rotate$4=rotate$42,scale$8=scale$82,fromRotation$4=fromRotation$42,fromScaling$3=fromScaling$32,str$8=str$82,frob$3=frob$32,LDU=LDU2,add$8=add$82,subtract$6=subtract$62,exactEquals$8=exactEquals$82,equals$8=equals$82,multiplyScalar$3=multiplyScalar$32,multiplyScalarAndAdd$3=multiplyScalarAndAdd$32,create$7=create$72,clone$7=clone$72,copy$7=copy$72,identity$4=identity$42,fromValues$7=fromValues$72,set$7=set$72,invert$4=invert$42,determinant$2=determinant$22,multiply$7=multiply$72,rotate$3=rotate$32,scale$7=scale$72,translate$3=translate$32,fromRotation$3=fromRotation$32,fromScaling$2=fromScaling$22,fromTranslation$3=fromTranslation$32,str$7=str$72,frob$2=frob$22,add$7=add$72,subtract$5=subtract$52,multiplyScalar$2=multiplyScalar$22,multiplyScalarAndAdd$2=multiplyScalarAndAdd$22,exactEquals$7=exactEquals$72,equals$7=equals$72,create$6=create$62,fromMat4$1=fromMat4$12,clone$6=clone$62,copy$6=copy$62,fromValues$6=fromValues$62,set$6=set$62,identity$3=identity$32,transpose$1=transpose$12,invert$3=invert$32,adjoint$1=adjoint$12,determinant$1=determinant$12,multiply$6=multiply$62,translate$2=translate$22,rotate$2=rotate$22,scale$6=scale$62,fromTranslation$2=fromTranslation$22,fromRotation$2=fromRotation$22,fromScaling$1=fromScaling$12,fromMat2d=fromMat2d2,fromQuat$1=fromQuat$12,normalFromMat4=normalFromMat42,projection=projection2,str$6=str$62,frob$1=frob$12,add$6=add$62,subtract$4=subtract$42,multiplyScalar$1=multiplyScalar$12,multiplyScalarAndAdd$1=multiplyScalarAndAdd$12,exactEquals$6=exactEquals$62,equals$6=equals$62,create$5=create$52,clone$5=clone$52,copy$5=copy$52,fromValues$5=fromValues$52,set$5=set$52,identity$2=identity$22,transpose=transpose2,invert$2=invert$22,adjoint=adjoint2,determinant=determinant2,multiply$5=multiply$52,translate$1=translate$12,scale$5=scale$52,rotate$1=rotate$12,rotateX$3=rotateX$32,rotateY$3=rotateY$32,rotateZ$3=rotateZ$32,fromTranslation$1=fromTranslation$12,fromScaling=fromScaling2,fromRotation$1=fromRotation$12,fromXRotation=fromXRotation2,fromYRotation=fromYRotation2,fromZRotation=fromZRotation2,fromRotationTranslation$1=fromRotationTranslation$12,fromQuat2=fromQuat22,getTranslation$1=getTranslation$12,getScaling=getScaling2,getRotation=getRotation2,decompose=decompose2,fromRotationTranslationScale=fromRotationTranslationScale2,fromRotationTranslationScaleOrigin=fromRotationTranslationScaleOrigin2,fromQuat=fromQuat3,frustum=frustum2,perspectiveNO=perspectiveNO2,perspectiveZO=perspectiveZO2,perspectiveFromFieldOfView=perspectiveFromFieldOfView2,orthoNO=orthoNO2,orthoZO=orthoZO2,lookAt=lookAt2,targetTo=targetTo2,str$5=str$52,frob=frob2,add$5=add$52,subtract$3=subtract$32,multiplyScalar=multiplyScalar2,multiplyScalarAndAdd=multiplyScalarAndAdd2,exactEquals$5=exactEquals$52,equals$5=equals$52,create$4=create$42,clone$4=clone$42,length$4=length$42,fromValues$4=fromValues$42,copy$4=copy$42,set$4=set$42,add$4=add$42,subtract$2=subtract$22,multiply$4=multiply$42,divide$2=divide$22,ceil$2=ceil$22,floor$2=floor$22,min$2=min$22,max$2=max$22,round$2=round$22,scale$4=scale$42,scaleAndAdd$2=scaleAndAdd$22,distance$2=distance$22,squaredDistance$2=squaredDistance$22,squaredLength$4=squaredLength$42,negate$2=negate$22,inverse$2=inverse$22,normalize$4=normalize$42,dot$4=dot$42,cross$2=cross$22,lerp$4=lerp$42,slerp$1=slerp$12,hermite=hermite2,bezier=bezier2,random$3=random$32,transformMat4$2=transformMat4$22,transformMat3$1=transformMat3$12,transformQuat$1=transformQuat$12,rotateX$2=rotateX$22,rotateY$2=rotateY$22,rotateZ$2=rotateZ$22,angle$1=angle$12,zero$2=zero$22,str$4=str$42,exactEquals$4=exactEquals$42,equals$4=equals$42,create$3=create$32,clone$3=clone$32,fromValues$3=fromValues$32,copy$3=copy$32,set$3=set$32,add$3=add$32,subtract$1=subtract$12,multiply$3=multiply$32,divide$1=divide$12,ceil$1=ceil$12,floor$1=floor$12,min$1=min$12,max$1=max$12,round$1=round$12,scale$3=scale$32,scaleAndAdd$1=scaleAndAdd$12,distance$1=distance$12,squaredDistance$1=squaredDistance$12,length$3=length$32,squaredLength$3=squaredLength$32,negate$1=negate$12,inverse$1=inverse$12,normalize$3=normalize$32,dot$3=dot$32,cross$1=cross$12,lerp$3=lerp$32,random$2=random$22,transformMat4$1=transformMat4$12,transformQuat=transformQuat2,zero$1=zero$12,str$3=str$32,exactEquals$3=exactEquals$32,equals$3=equals$32,create$2=create$22,identity$1=identity$12,setAxisAngle=setAxisAngle2,getAxisAngle=getAxisAngle2,getAngle=getAngle2,multiply$2=multiply$22,rotateX$1=rotateX$12,rotateY$1=rotateY$12,rotateZ$1=rotateZ$12,calculateW=calculateW2,exp=exp2,ln=ln2,pow=pow2,slerp=slerp2,random$1=random$12,invert$1=invert$12,conjugate$1=conjugate$12,fromMat3=fromMat32,fromEuler=fromEuler2,str$2=str$22,equals$2=equals$22,create$1=create$12,clone$1=clone$12,fromValues$1=fromValues$12,fromRotationTranslationValues=fromRotationTranslationValues2,fromRotationTranslation=fromRotationTranslation2,fromTranslation=fromTranslation2,fromRotation=fromRotation2,fromMat4=fromMat42,copy$1=copy$12,identity=identity2,set$1=set$12,getDual=getDual2,setDual=setDual2,getTranslation=getTranslation2,translate=translate2,rotateX=rotateX2,rotateY=rotateY2,rotateZ=rotateZ2,rotateByQuatAppend=rotateByQuatAppend2,rotateByQuatPrepend=rotateByQuatPrepend2,rotateAroundAxis=rotateAroundAxis2,add$1=add$12,multiply$1=multiply$12,scale$1=scale$12,lerp$1=lerp$12,invert=invert2,conjugate=conjugate2,normalize$1=normalize$12,str$1=str$12,exactEquals$1=exactEquals$12,equals$1=equals$12,create=create2,clone=clone2,fromValues=fromValues2,copy=copy2,set=set2,add=add2,subtract=subtract2,multiply=multiply2,divide=divide2,ceil=ceil2,floor=floor2,min=min2,max=max2,round=round2,scale=scale2,scaleAndAdd=scaleAndAdd2,distance=distance2,squaredDistance=squaredDistance2,length=length2,squaredLength=squaredLength2,negate=negate2,inverse=inverse2,normalize=normalize2,dot=dot2,cross=cross2,lerp=lerp2,random=random2,transformMat2=transformMat22,transformMat2d=transformMat2d2,transformMat3=transformMat32,transformMat4=transformMat42,rotate=rotate2,angle=angle2,zero=zero2,str=str2,exactEquals=exactEquals2,equals=equals2,EPSILON=1e-6,ARRAY_TYPE="undefined"!=typeof Float32Array?Float32Array:Array,RANDOM=Math.random,ANGLE_ORDER="zyx",degree=Math.PI/180,Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)}),common={__proto__:null,EPSILON:EPSILON,get ARRAY_TYPE(){return ARRAY_TYPE},RANDOM:RANDOM,ANGLE_ORDER:ANGLE_ORDER,setMatrixArrayType:setMatrixArrayType2,toRadian:toRadian2,equals:equals$92},mul$8=multiply$82,sub$6=subtract$62,mat2=Object.freeze({__proto__:null,create:create$82,clone:clone$82,copy:copy$82,identity:identity$52,fromValues:fromValues$82,set:set$82,transpose:transpose$22,invert:invert$52,adjoint:adjoint$22,determinant:determinant$32,multiply:multiply$82,rotate:rotate$42,scale:scale$82,fromRotation:fromRotation$42,fromScaling:fromScaling$32,str:str$82,frob:frob$32,LDU:LDU2,add:add$82,subtract:subtract$62,exactEquals:exactEquals$82,equals:equals$82,multiplyScalar:multiplyScalar$32,multiplyScalarAndAdd:multiplyScalarAndAdd$32,mul:mul$8,sub:sub$6}),mul$7=multiply$72,sub$5=subtract$52,mat2d=Object.freeze({__proto__:null,create:create$72,clone:clone$72,copy:copy$72,identity:identity$42,fromValues:fromValues$72,set:set$72,invert:invert$42,determinant:determinant$22,multiply:multiply$72,rotate:rotate$32,scale:scale$72,translate:translate$32,fromRotation:fromRotation$32,fromScaling:fromScaling$22,fromTranslation:fromTranslation$32,str:str$72,frob:frob$22,add:add$72,subtract:subtract$52,multiplyScalar:multiplyScalar$22,multiplyScalarAndAdd:multiplyScalarAndAdd$22,exactEquals:exactEquals$72,equals:equals$72,mul:mul$7,sub:sub$5}),mul$6=multiply$62,sub$4=subtract$42,mat3=Object.freeze({__proto__:null,create:create$62,fromMat4:fromMat4$12,clone:clone$62,copy:copy$62,fromValues:fromValues$62,set:set$62,identity:identity$32,transpose:transpose$12,invert:invert$32,adjoint:adjoint$12,determinant:determinant$12,multiply:multiply$62,translate:translate$22,rotate:rotate$22,scale:scale$62,fromTranslation:fromTranslation$22,fromRotation:fromRotation$22,fromScaling:fromScaling$12,fromMat2d:fromMat2d2,fromQuat:fromQuat$12,normalFromMat4:normalFromMat42,projection:projection2,str:str$62,frob:frob$12,add:add$62,subtract:subtract$42,multiplyScalar:multiplyScalar$12,multiplyScalarAndAdd:multiplyScalarAndAdd$12,exactEquals:exactEquals$62,equals:equals$62,mul:mul$6,sub:sub$4}),perspective=perspectiveNO2,ortho=orthoNO2,mul$5=multiply$52,sub$3=subtract$32,mat4=Object.freeze({__proto__:null,create:create$52,clone:clone$52,copy:copy$52,fromValues:fromValues$52,set:set$52,identity:identity$22,transpose:transpose2,invert:invert$22,adjoint:adjoint2,determinant:determinant2,multiply:multiply$52,translate:translate$12,scale:scale$52,rotate:rotate$12,rotateX:rotateX$32,rotateY:rotateY$32,rotateZ:rotateZ$32,fromTranslation:fromTranslation$12,fromScaling:fromScaling2,fromRotation:fromRotation$12,fromXRotation:fromXRotation2,fromYRotation:fromYRotation2,fromZRotation:fromZRotation2,fromRotationTranslation:fromRotationTranslation$12,fromQuat2:fromQuat22,getTranslation:getTranslation$12,getScaling:getScaling2,getRotation:getRotation2,decompose:decompose2,fromRotationTranslationScale:fromRotationTranslationScale2,fromRotationTranslationScaleOrigin:fromRotationTranslationScaleOrigin2,fromQuat:fromQuat3,frustum:frustum2,perspectiveNO:perspectiveNO2,perspective:perspective,perspectiveZO:perspectiveZO2,perspectiveFromFieldOfView:perspectiveFromFieldOfView2,orthoNO:orthoNO2,ortho:ortho,orthoZO:orthoZO2,lookAt:lookAt2,targetTo:targetTo2,str:str$52,frob:frob2,add:add$52,subtract:subtract$32,multiplyScalar:multiplyScalar2,multiplyScalarAndAdd:multiplyScalarAndAdd2,exactEquals:exactEquals$52,equals:equals$52,mul:mul$5,sub:sub$3}),sub$2=subtract$22,mul$4=multiply$42,div$2=divide$22,dist$2=distance$22,sqrDist$2=squaredDistance$22,len$4=length$42,sqrLen$4=squaredLength$42,forEach$2=(()=>{var l=create$42();return function(e,t,s,i,n,r){var a,o;for(t=t||3,s=s||0,o=i?Math.min(i*t+s,e.length):e.length,a=s;a<o;a+=t)l[0]=e[a],l[1]=e[a+1],l[2]=e[a+2],n(l,l,r),e[a]=l[0],e[a+1]=l[1],e[a+2]=l[2];return e}})(),vec3=Object.freeze({__proto__:null,create:create$42,clone:clone$42,length:length$42,fromValues:fromValues$42,copy:copy$42,set:set$42,add:add$42,subtract:subtract$22,multiply:multiply$42,divide:divide$22,ceil:ceil$22,floor:floor$22,min:min$22,max:max$22,round:round$22,scale:scale$42,scaleAndAdd:scaleAndAdd$22,distance:distance$22,squaredDistance:squaredDistance$22,squaredLength:squaredLength$42,negate:negate$22,inverse:inverse$22,normalize:normalize$42,dot:dot$42,cross:cross$22,lerp:lerp$42,slerp:slerp$12,hermite:hermite2,bezier:bezier2,random:random$32,transformMat4:transformMat4$22,transformMat3:transformMat3$12,transformQuat:transformQuat$12,rotateX:rotateX$22,rotateY:rotateY$22,rotateZ:rotateZ$22,angle:angle$12,zero:zero$22,str:str$42,exactEquals:exactEquals$42,equals:equals$42,sub:sub$2,mul:mul$4,div:div$2,dist:dist$2,sqrDist:sqrDist$2,len:len$4,sqrLen:sqrLen$4,forEach:forEach$2}),sub$1=subtract$12,mul$3=multiply$32,div$1=divide$12,dist$1=distance$12,sqrDist$1=squaredDistance$12,len$3=length$32,sqrLen$3=squaredLength$32,forEach$1=(()=>{var l=create$32();return function(e,t,s,i,n,r){var a,o;for(t=t||4,s=s||0,o=i?Math.min(i*t+s,e.length):e.length,a=s;a<o;a+=t)l[0]=e[a],l[1]=e[a+1],l[2]=e[a+2],l[3]=e[a+3],n(l,l,r),e[a]=l[0],e[a+1]=l[1],e[a+2]=l[2],e[a+3]=l[3];return e}})(),vec4=Object.freeze({__proto__:null,create:create$32,clone:clone$32,fromValues:fromValues$32,copy:copy$32,set:set$32,add:add$32,subtract:subtract$12,multiply:multiply$32,divide:divide$12,ceil:ceil$12,floor:floor$12,min:min$12,max:max$12,round:round$12,scale:scale$32,scaleAndAdd:scaleAndAdd$12,distance:distance$12,squaredDistance:squaredDistance$12,length:length$32,squaredLength:squaredLength$32,negate:negate$12,inverse:inverse$12,normalize:normalize$32,dot:dot$32,cross:cross$12,lerp:lerp$32,random:random$22,transformMat4:transformMat4$12,transformQuat:transformQuat2,zero:zero$12,str:str$32,exactEquals:exactEquals$32,equals:equals$32,sub:sub$1,mul:mul$3,div:div$1,dist:dist$1,sqrDist:sqrDist$1,len:len$3,sqrLen:sqrLen$3,forEach:forEach$1}),clone$2=clone$32,fromValues$2=fromValues$32,copy$2=copy$32,set$2=set$32,add$2=add$32,mul$2=multiply$22,scale$2=scale$32,dot$2=dot$32,lerp$2=lerp$32,length$2=length$32,len$2=length$2,squaredLength$2=squaredLength$32,sqrLen$2=squaredLength$2,normalize$2=normalize$32,exactEquals$2=exactEquals$32,rotationTo=(()=>{var n=create$42(),r=fromValues$42(1,0,0),a=fromValues$42(0,1,0);return function(e,t,s){var i=dot$42(t,s);return i<-.999999?(cross$22(n,r,t),len$4(n)<1e-6&&cross$22(n,a,t),normalize$42(n,n),setAxisAngle2(e,n,Math.PI),e):.999999<i?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(cross$22(n,t,s),e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=1+i,normalize$2(e,e))}})(),sqlerp=(()=>{var a=create$22(),o=create$22();return function(e,t,s,i,n,r){return slerp2(a,t,n,r),slerp2(o,s,i,r),slerp2(e,a,o,2*r*(1-r)),e}})(),setAxes=(()=>{var n=create$62();return function(e,t,s,i){return n[0]=s[0],n[3]=s[1],n[6]=s[2],n[1]=i[0],n[4]=i[1],n[7]=i[2],n[2]=-t[0],n[5]=-t[1],n[8]=-t[2],normalize$2(e,fromMat32(e,n))}})(),quat=Object.freeze({__proto__:null,create:create$22,identity:identity$12,setAxisAngle:setAxisAngle2,getAxisAngle:getAxisAngle2,getAngle:getAngle2,multiply:multiply$22,rotateX:rotateX$12,rotateY:rotateY$12,rotateZ:rotateZ$12,calculateW:calculateW2,exp:exp2,ln:ln2,pow:pow2,slerp:slerp2,random:random$12,invert:invert$12,conjugate:conjugate$12,fromMat3:fromMat32,fromEuler:fromEuler2,str:str$22,clone:clone$2,fromValues:fromValues$2,copy:copy$2,set:set$2,add:add$2,mul:mul$2,scale:scale$2,dot:dot$2,lerp:lerp$2,length:length$2,len:len$2,squaredLength:squaredLength$2,sqrLen:sqrLen$2,normalize:normalize$2,exactEquals:exactEquals$2,equals:equals$22,rotationTo:rotationTo,sqlerp:sqlerp,setAxes:setAxes}),getReal=copy$2,setReal=copy$2,mul$1=multiply$12,dot$1=dot$2,length$1=length$2,len$1=length$1,squaredLength$1=squaredLength$2,sqrLen$1=squaredLength$1,quat2=Object.freeze({__proto__:null,create:create$12,clone:clone$12,fromValues:fromValues$12,fromRotationTranslationValues:fromRotationTranslationValues2,fromRotationTranslation:fromRotationTranslation2,fromTranslation:fromTranslation2,fromRotation:fromRotation2,fromMat4:fromMat42,copy:copy$12,identity:identity2,set:set$12,getReal:getReal,getDual:getDual2,setReal:setReal,setDual:setDual2,getTranslation:getTranslation2,translate:translate2,rotateX:rotateX2,rotateY:rotateY2,rotateZ:rotateZ2,rotateByQuatAppend:rotateByQuatAppend2,rotateByQuatPrepend:rotateByQuatPrepend2,rotateAroundAxis:rotateAroundAxis2,add:add$12,multiply:multiply$12,mul:mul$1,scale:scale$12,dot:dot$1,lerp:lerp$12,invert:invert2,conjugate:conjugate2,length:length$1,len:len$1,squaredLength:squaredLength$1,sqrLen:sqrLen$1,normalize:normalize$12,str:str$12,exactEquals:exactEquals$12,equals:equals$12}),len=length2,sub=subtract2,mul=multiply2,div=divide2,dist=distance2,sqrDist=squaredDistance2,sqrLen=squaredLength2,forEach=(()=>{var l=create2();return function(e,t,s,i,n,r){var a,o;for(t=t||2,s=s||0,o=i?Math.min(i*t+s,e.length):e.length,a=s;a<o;a+=t)l[0]=e[a],l[1]=e[a+1],n(l,l,r),e[a]=l[0],e[a+1]=l[1];return e}})(),vec2=Object.freeze({__proto__:null,create:create2,clone:clone2,fromValues:fromValues2,copy:copy2,set:set2,add:add2,subtract:subtract2,multiply:multiply2,divide:divide2,ceil:ceil2,floor:floor2,min:min2,max:max2,round:round2,scale:scale2,scaleAndAdd:scaleAndAdd2,distance:distance2,squaredDistance:squaredDistance2,length:length2,squaredLength:squaredLength2,negate:negate2,inverse:inverse2,normalize:normalize2,dot:dot2,cross:cross2,lerp:lerp2,random:random2,transformMat2:transformMat22,transformMat2d:transformMat2d2,transformMat3:transformMat32,transformMat4:transformMat42,rotate:rotate2,angle:angle2,zero:zero2,str:str2,exactEquals:exactEquals2,equals:equals2,len:len,sub:sub,mul:mul,div:div,dist:dist,sqrDist:sqrDist,sqrLen:sqrLen,forEach:forEach}),globalThis.glMatrix=common,globalThis.glMatrix.mat2=mat2,globalThis.glMatrix.mat2d=mat2d,globalThis.glMatrix.mat3=mat3,globalThis.glMatrix.mat4=mat4,globalThis.glMatrix.quat=quat,globalThis.glMatrix.quat2=quat2,globalThis.glMatrix.vec2=vec2,globalThis.glMatrix.vec3=vec3,globalThis.glMatrix.vec4=vec4}var EPSILON,ARRAY_TYPE,RANDOM,ANGLE_ORDER,degree,common,mul$8,sub$6,mat2,mul$7,sub$5,mat2d,mul$6,sub$4,mat3,perspective,ortho,mul$5,sub$3,mat4,sub$2,mul$4,div$2,dist$2,sqrDist$2,len$4,sqrLen$4,forEach$2,vec3,sub$1,mul$3,div$1,dist$1,sqrDist$1,len$3,sqrLen$3,forEach$1,vec4,clone$2,fromValues$2,copy$2,set$2,add$2,mul$2,scale$2,dot$2,lerp$2,length$2,len$2,squaredLength$2,sqrLen$2,normalize$2,exactEquals$2,rotationTo,sqlerp,setAxes,quat,getReal,setReal,mul$1,dot$1,length$1,len$1,squaredLength$1,sqrLen$1,quat2,len,sub,mul,div,dist,sqrDist,sqrLen,forEach,vec2,setMatrixArrayType,toRadian,equals$9,create$8,clone$8,copy$8,identity$5,fromValues$8,set$8,transpose$2,invert$5,adjoint$2,determinant$3,multiply$8,rotate$4,scale$8,fromRotation$4,fromScaling$3,str$8,frob$3,LDU,add$8,subtract$6,exactEquals$8,equals$8,multiplyScalar$3,multiplyScalarAndAdd$3,create$7,clone$7,copy$7,identity$4,fromValues$7,set$7,invert$4,determinant$2,multiply$7,rotate$3,scale$7,translate$3,fromRotation$3,fromScaling$2,fromTranslation$3,str$7,frob$2,add$7,subtract$5,multiplyScalar$2,multiplyScalarAndAdd$2,exactEquals$7,equals$7,create$6,fromMat4$1,clone$6,copy$6,fromValues$6,set$6,identity$3,transpose$1,invert$3,adjoint$1,determinant$1,multiply$6,translate$2,rotate$2,scale$6,fromTranslation$2,fromRotation$2,fromScaling$1,fromMat2d,fromQuat$1,normalFromMat4,projection,str$6,frob$1,add$6,subtract$4,multiplyScalar$1,multiplyScalarAndAdd$1,exactEquals$6,equals$6,create$5,clone$5,copy$5,fromValues$5,set$5,identity$2,transpose,invert$2,adjoint,determinant,multiply$5,translate$1,scale$5,rotate$1,rotateX$3,rotateY$3,rotateZ$3,fromTranslation$1,fromScaling,fromRotation$1,fromXRotation,fromYRotation,fromZRotation,fromRotationTranslation$1,fromQuat2,getTranslation$1,getScaling,getRotation,decompose,fromRotationTranslationScale,fromRotationTranslationScaleOrigin,fromQuat,frustum,perspectiveNO,perspectiveZO,perspectiveFromFieldOfView,orthoNO,orthoZO,lookAt,targetTo,str$5,frob,add$5,subtract$3,multiplyScalar,multiplyScalarAndAdd,exactEquals$5,equals$5,create$4,clone$4,length$4,fromValues$4,copy$4,set$4,add$4,subtract$2,multiply$4,divide$2,ceil$2,floor$2,min$2,max$2,round$2,scale$4,scaleAndAdd$2,distance$2,squaredDistance$2,squaredLength$4,negate$2,inverse$2,normalize$4,dot$4,cross$2,lerp$4,slerp$1,hermite,bezier,random$3,transformMat4$2,transformMat3$1,transformQuat$1,rotateX$2,rotateY$2,rotateZ$2,angle$1,zero$2,str$4,exactEquals$4,equals$4,create$3,clone$3,fromValues$3,copy$3,set$3,add$3,subtract$1,multiply$3,divide$1,ceil$1,floor$1,min$1,max$1,round$1,scale$3,scaleAndAdd$1,distance$1,squaredDistance$1,length$3,squaredLength$3,negate$1,inverse$1,normalize$3,dot$3,cross$1,lerp$3,random$2,transformMat4$1,transformQuat,zero$1,str$3,exactEquals$3,equals$3,create$2,identity$1,setAxisAngle,getAxisAngle,getAngle,multiply$2,rotateX$1,rotateY$1,rotateZ$1,calculateW,exp,ln,pow,slerp,random$1,invert$1,conjugate$1,fromMat3,fromEuler,str$2,equals$2,create$1,clone$1,fromValues$1,fromRotationTranslationValues,fromRotationTranslation,fromTranslation,fromRotation,fromMat4,copy$1,identity,set$1,getDual,setDual,getTranslation,translate,rotateX,rotateY,rotateZ,rotateByQuatAppend,rotateByQuatPrepend,rotateAroundAxis,add$1,multiply$1,scale$1,lerp$1,invert,conjugate,normalize$1,str$1,exactEquals$1,equals$1,create,clone,fromValues,copy,set,add,subtract,multiply,divide,ceil,floor,min,max,round,scale,scaleAndAdd,distance,squaredDistance,length,squaredLength,negate,inverse,normalize,dot,cross,lerp,random,transformMat2,transformMat2d,transformMat3,transformMat4,rotate,angle,zero,str,exactEquals,equals,tmpPoint1,tmpPoint2,tmpLine1,tmpLine2,lineInt,lineSegmentsIntersect,triangleArea,isLeft,isLeftOn,isRight,isRightOn,collinear,sqdist,polygonAt,polygonClear,polygonAppend,polygonMakeCCW,polygonReverse,polygonIsReflex,polygonCanSee,polygonCanSee2,polygonCopy,polygonGetCutEdges,polygonDecomp,polygonSlice,polygonIsSimple,getIntersectionPoint,polygonQuickDecomp,polygonRemoveCollinearPoints,polygonRemoveDuplicatePoints,scalar_eq,points_eq,ReadBrandList,RunTest,GetWindowsNTVersionName,asyncifyRequest,asyncifyTransaction,openReadOnlyTransaction,openWriteTransaction,lazyOpenDatabase,RequireString,getEntriesFromCursor,NOT_IMPLEMENTED,DISALLOW_CALLBACK,StructuredClone,arrayFlat,assertFail,isValidTypeChange,logDefendedObjectWarning,CheckDefendedObjectsUsedCorrectly,getObjectPropertySet,VerifyObjectPropertiesConsistent,isNegativeZero,padTwoDigits,hueToRGB,RequireStringOrNumber,SetNewCallback,DoAsyncifiedWork,DoNextAsyncifiedJob,ClearTimeCache,CheckActiveIdleTimeouts,lookupHtmlEntity,bbToHtmlReplacerFunc,IsWordBreakWhiteSpace,IsOpeningCJKPunctiationChar,IsContinuingCJKPunctuationChar,WordBreakTrimEnd,IsNewline,PlaneFromPoints,IsInFrontOfPlane,IsPointInFrontOfPlane,interpolateQuad,GetFormatSpecifiers,fillOrStrokeRect,ptToPx,getOffsetParam,CheckPendingPolls,SortZOrderList,GetDispatcher,MakeIWorldInstanceClass,GetDispatcher,GetTimelineState,GetTimelineState,GetTweenState,getActual,GetTypeFromFileExtension,AddScript,SortByInstLastCachedZIndex,SortByInstLastCachedZIndex,SortByInstZElevation,vec3EqualsXYZ,MaybePrepareLayerDraw,SortSolArray,IsSolArrayIdentical,NoActions,WrapIndex,GetExpressionFunc,EvalParams,EvalParams,GetInst,GetWorldInfo,GetInst_SDKv2,GetWorldInfo_SDKv2,GetObjectClass,GetLayer,CollMemory_Add,CollMemory_Remove,CollMemory_RemoveInstance,CollMemory_Get,DoOverlapCondition,FinishCollisionConditionPicking,FinishCollisionCondition,PickByUID_Normal,PickByUID_Inverted,GetNextParamMap,ValidateInternalAPIToken,ForEachOrdered_SortInstances,SortZOrderList,SortInstancesByValue,GetAudioSdkInstance,GetAudioDOMInterface,GetKeyboardSdkInstance,StringFromCharCode,GetTouchSdkInstance,IsExpressionType,GetMouseSdkInstance,GetTCInst,GetTimelineParameter,ValidateTags,MaybeCloseImageBitmap,GetParticleEngine,randomOffset,WrapModeToStr,RunLengthDecode,unaryminus,bothNumbers,add,subtract,multiply,divide,mod,pow,and,or;{let lineInt2=function(e,t,s){var i=[0,0],n=e[1][1]-e[0][1],r=e[0][0]-e[1][0],e=n*e[0][0]+r*e[0][1],a=t[1][1]-t[0][1],o=t[0][0]-t[1][0],t=a*t[0][0]+o*t[0][1],l=n*o-a*r;return scalar_eq2(l,0,s=s||0)||(i[0]=(o*e-r*t)/l,i[1]=(n*t-a*e)/l),i},lineSegmentsIntersect2=function(e,t,s,i){var n,r=t[0]-e[0],t=t[1]-e[1],a=i[0]-s[0];return a*t-(i=i[1]-s[1])*r!=0&&(n=(a*(e[1]-s[1])+i*(s[0]-e[0]))/(i*r-a*t),0<=(e=(r*(s[1]-e[1])+t*(e[0]-s[0]))/(a*t-i*r)))&&e<=1&&0<=n&&n<=1},triangleArea2=function(e,t,s){return(t[0]-e[0])*(s[1]-e[1])-(s[0]-e[0])*(t[1]-e[1])},isLeft2=function(e,t,s){return 0<triangleArea2(e,t,s)},isLeftOn2=function(e,t,s){return 0<=triangleArea2(e,t,s)},isRight2=function(e,t,s){return triangleArea2(e,t,s)<0},isRightOn2=function(e,t,s){return triangleArea2(e,t,s)<=0},collinear2=function(e,t,s,i){var n,r,a;return i?(a=tmpPoint2,(r=tmpPoint1)[0]=t[0]-e[0],r[1]=t[1]-e[1],a[0]=s[0]-t[0],a[1]=s[1]-t[1],n=r[0]*a[0]+r[1]*a[1],r=Math.sqrt(r[0]*r[0]+r[1]*r[1]),a=Math.sqrt(a[0]*a[0]+a[1]*a[1]),Math.acos(n/(r*a))<i):0===triangleArea2(e,t,s)},sqdist2=function(e,t){var s=t[0]-e[0];return s*s+(t=t[1]-e[1])*t},polygonAt2=function(e,t){var s=e.length;return e[t<0?t%s+s:t%s]},polygonClear2=function(e){e.length=0},polygonAppend2=function(e,t,s,i){for(var n=s;n<i;n++)e.push(t[n])},polygonMakeCCW2=function(e){for(var t=0,s=e,i=1;i<e.length;++i)(s[i][1]<s[t][1]||s[i][1]===s[t][1]&&s[i][0]>s[t][0])&&(t=i);return!isLeft2(polygonAt2(e,t-1),polygonAt2(e,t),polygonAt2(e,t+1))&&(polygonReverse2(e),!0)},polygonReverse2=function(e){for(var t=[],s=e.length,i=0;i!==s;i++)t.push(e.pop());for(i=0;i!==s;i++)e[i]=t[i]},polygonIsReflex2=function(e,t){return isRight2(polygonAt2(e,t-1),polygonAt2(e,t),polygonAt2(e,t+1))},polygonCanSee3=function(e,t,s){var i,n=tmpLine1,r=tmpLine2;if(isLeftOn2(polygonAt2(e,t+1),polygonAt2(e,t),polygonAt2(e,s))&&isRightOn2(polygonAt2(e,t-1),polygonAt2(e,t),polygonAt2(e,s)))return!1;for(var a=sqdist2(polygonAt2(e,t),polygonAt2(e,s)),o=0;o!==e.length;++o)if((o+1)%e.length!==t&&o!==t&&isLeftOn2(polygonAt2(e,t),polygonAt2(e,s),polygonAt2(e,o+1))&&isRightOn2(polygonAt2(e,t),polygonAt2(e,s),polygonAt2(e,o))&&(n[0]=polygonAt2(e,t),n[1]=polygonAt2(e,s),r[0]=polygonAt2(e,o),r[1]=polygonAt2(e,o+1),i=lineInt2(n,r),sqdist2(polygonAt2(e,t),i)<a))return!1;return!0},polygonCanSee22=function(e,t,s){for(var i=0;i!==e.length;++i)if(i!==t&&i!==s&&(i+1)%e.length!==t&&(i+1)%e.length!==s&&lineSegmentsIntersect2(polygonAt2(e,t),polygonAt2(e,s),polygonAt2(e,i),polygonAt2(e,i+1)))return!1;return!0},polygonCopy2=function(e,t,s,i){var n=i||[];if(polygonClear2(n),t<s)for(var r=t;r<=s;r++)n.push(e[r]);else{for(r=0;r<=s;r++)n.push(e[r]);for(r=t;r<e.length;r++)n.push(e[r])}return n},polygonGetCutEdges2=function(e){for(var t=[],s=[],i=[],n=Number.MAX_VALUE,r=0;r<e.length;++r)if(polygonIsReflex2(e,r))for(var a=0;a<e.length;++a)if(polygonCanSee3(e,r,a)){for(var s=polygonGetCutEdges2(polygonCopy2(e,r,a,i)),o=polygonGetCutEdges2(polygonCopy2(e,a,r,i)),l=0;l<o.length;l++)s.push(o[l]);s.length<n&&(n=(t=s).length,t.push([polygonAt2(e,r),polygonAt2(e,a)]))}return t},polygonDecomp2=function(e){var t=polygonGetCutEdges2(e);return 0<t.length?polygonSlice2(e,t):[e]},polygonSlice2=function(e,t){if(0===t.length)return[e];if(t instanceof Array&&t.length&&t[0]instanceof Array&&2===t[0].length&&t[0][0]instanceof Array){for(var s=[e],i=0;i<t.length;i++)for(var n=t[i],r=0;r<s.length;r++){var a=polygonSlice2(s[r],n);if(a){s.splice(r,1),s.push(a[0],a[1]);break}}return s}return i=e.indexOf((n=t)[0]),r=e.indexOf(n[1]),-1!==i&&-1!==r&&[polygonCopy2(e,i,r),polygonCopy2(e,r,i)]},polygonIsSimple2=function(e){for(var t=e,s=0;s<t.length-1;s++)for(var i=0;i<s-1;i++)if(lineSegmentsIntersect2(t[s],t[s+1],t[i],t[i+1]))return!1;for(s=1;s<t.length-2;s++)if(lineSegmentsIntersect2(t[0],t[t.length-1],t[s],t[s+1]))return!1;return!0},getIntersectionPoint2=function(e,t,s,i,n){var r=t[1]-e[1],t=e[0]-t[0],e=r*e[0]+t*e[1],a=i[1]-s[1],i=s[0]-i[0],s=a*s[0]+i*s[1],o=r*i-a*t;return scalar_eq2(o,0,n=n||0)?[0,0]:[(i*e-t*s)/o,(r*s-a*e)/o]},polygonQuickDecomp2=function(e,t,s,i,n,r,a){r=r||100,a=a||0,n=n||25,t=void 0!==t?t:[],s=s||[],i=i||[];var o=[0,0],l=[0,0],h=[0,0],c=0,u=0,_=0,d=0,p=0,m=0,g=0,f=[],S=[],C=e,y=e;if(!(y.length<3))if(r<++a)console.warn("quickDecomp: max level ("+r+") reached.");else{for(var G=0;G<e.length;++G)if(polygonIsReflex2(C,G)){s.push(C[G]);for(var c=u=Number.MAX_VALUE,I=0;I<e.length;++I)isLeft2(polygonAt2(C,G-1),polygonAt2(C,G),polygonAt2(C,I))&&isRightOn2(polygonAt2(C,G-1),polygonAt2(C,G),polygonAt2(C,I-1))&&(h=getIntersectionPoint2(polygonAt2(C,G-1),polygonAt2(C,G),polygonAt2(C,I),polygonAt2(C,I-1)),isRight2(polygonAt2(C,G+1),polygonAt2(C,G),h))&&(_=sqdist2(C[G],h))<u&&(u=_,l=h,m=I),isLeft2(polygonAt2(C,G+1),polygonAt2(C,G),polygonAt2(C,I+1))&&isRightOn2(polygonAt2(C,G+1),polygonAt2(C,G),polygonAt2(C,I))&&(h=getIntersectionPoint2(polygonAt2(C,G+1),polygonAt2(C,G),polygonAt2(C,I),polygonAt2(C,I+1)),isLeft2(polygonAt2(C,G-1),polygonAt2(C,G),h))&&(_=sqdist2(C[G],h))<c&&(c=_,o=h,p=I);if(m===(p+1)%e.length)h[0]=(l[0]+o[0])/2,h[1]=(l[1]+o[1])/2,i.push(h),G<p?(polygonAppend2(f,C,G,p+1),f.push(h),S.push(h),0!==m&&polygonAppend2(S,C,m,C.length),polygonAppend2(S,C,0,G+1)):(0!==G&&polygonAppend2(f,C,G,C.length),polygonAppend2(f,C,0,p+1),f.push(h),S.push(h),polygonAppend2(S,C,m,G+1));else{if(p<m&&(p+=e.length),d=Number.MAX_VALUE,p<m)return t;for(I=m;I<=p;++I)isLeftOn2(polygonAt2(C,G-1),polygonAt2(C,G),polygonAt2(C,I))&&isRightOn2(polygonAt2(C,G+1),polygonAt2(C,G),polygonAt2(C,I))&&(_=sqdist2(polygonAt2(C,G),polygonAt2(C,I)))<d&&polygonCanSee22(C,G,I)&&(d=_,g=I%e.length);G<g?(polygonAppend2(f,C,G,g+1),0!==g&&polygonAppend2(S,C,g,y.length),polygonAppend2(S,C,0,G+1)):(0!==G&&polygonAppend2(f,C,G,y.length),polygonAppend2(f,C,0,g+1),polygonAppend2(S,C,g,G+1))}return f.length<S.length?(polygonQuickDecomp2(f,t,s,i,n,r,a),polygonQuickDecomp2(S,t,s,i,n,r,a)):(polygonQuickDecomp2(S,t,s,i,n,r,a),polygonQuickDecomp2(f,t,s,i,n,r,a)),t}t.push(e)}return t},polygonRemoveCollinearPoints2=function(e,t){for(var s=0,i=e.length-1;3<e.length&&0<=i;--i)collinear2(polygonAt2(e,i-1),polygonAt2(e,i),polygonAt2(e,i+1),t)&&(e.splice(i%e.length,1),s++);return s},polygonRemoveDuplicatePoints2=function(e,t){for(var s=e.length-1;1<=s;--s)for(var i=e[s],n=s-1;0<=n;--n)points_eq2(i,e[n],t)&&e.splice(s,1)},scalar_eq2=function(e,t,s){return s=s||0,Math.abs(e-t)<=s},points_eq2=function(e,t,s){return scalar_eq2(e[0],t[0],s)&&scalar_eq2(e[1],t[1],s)};lineInt=lineInt2,lineSegmentsIntersect=lineSegmentsIntersect2,triangleArea=triangleArea2,isLeft=isLeft2,isLeftOn=isLeftOn2,isRight=isRight2,isRightOn=isRightOn2,collinear=collinear2,sqdist=sqdist2,polygonAt=polygonAt2,polygonClear=polygonClear2,polygonAppend=polygonAppend2,polygonMakeCCW=polygonMakeCCW2,polygonReverse=polygonReverse2,polygonIsReflex=polygonIsReflex2,polygonCanSee=polygonCanSee3,polygonCanSee2=polygonCanSee22,polygonCopy=polygonCopy2,polygonGetCutEdges=polygonGetCutEdges2,polygonDecomp=polygonDecomp2,polygonSlice=polygonSlice2,polygonIsSimple=polygonIsSimple2,getIntersectionPoint=getIntersectionPoint2,polygonQuickDecomp=polygonQuickDecomp2,polygonRemoveCollinearPoints=polygonRemoveCollinearPoints2,polygonRemoveDuplicatePoints=polygonRemoveDuplicatePoints2,scalar_eq=scalar_eq2,points_eq=points_eq2,tmpPoint1=[],tmpPoint2=[],tmpLine1=[],tmpLine2=[],self.polyDecomp={decomp:polygonDecomp2,quickDecomp:polygonQuickDecomp2,isSimple:polygonIsSimple2,removeCollinearPoints:polygonRemoveCollinearPoints2,removeDuplicatePoints:polygonRemoveDuplicatePoints2,makeCCW:polygonMakeCCW2}}{let isReady=!1,hasAppStarted=!1,buildMode="dev",internalApiToken=Symbol("Construct internal API token"),internalApiTokenAccessesRemaining=14,C33=self.C3=class{constructor(){throw TypeError("static class can't be instantiated")}static _GetInternalAPIToken(){if(internalApiTokenAccessesRemaining<=0)throw new Error("cannot obtain internal API token");return--internalApiTokenAccessesRemaining,internalApiToken}static SetReady(){isReady=!0}static IsReady(){return isReady}static SetAppStarted(){hasAppStarted=!0}static HasAppStarted(){return hasAppStarted}static SetBuildMode(e){buildMode=e}static GetBuildMode(){return buildMode}static IsReleaseBuild(){return"final"===buildMode}};C33.isDebug=!1,C33.isDebugDefend=!1,C33.hardwareConcurrency=navigator.hardwareConcurrency||2,self.C3X={}}{const C33=self.C3;C33.QueryParser=class{constructor(e){this._queryString=e,this._parameters=new Map,this._Parse()}_Parse(){let e=this._queryString,t=(e=e.startsWith("?")||e.startsWith("#")?e.substr(1):e).split("&");for(const s of t)this._ParseParameter(s)}_ParseParameter(e){if(e)if(e.includes("=")){const t=e.indexOf("="),s=decodeURIComponent(e.substring(0,t)),i=decodeURIComponent(e.substring(t+1));this._parameters.set(s,i)}else this._parameters.set(e,null)}LogAll(){for(const e of this._parameters)console.log("[QueryParser] Parameter '"+e[0]+"' = "+(null===e[1]?"null":"'"+e[1]+"'"))}Has(e){return this._parameters.has(e)}Get(e){const t=this._parameters.get(e);return void 0===t?null:t}ClearHash(){history.replaceState("",document.title,location.pathname+location.search)}Reparse(e){this._queryString=e,this._parameters.clear(),this._Parse()}},C33.QueryString=new C33.QueryParser(location.search),C33.LocationHashString=new C33.QueryParser(location.hash),C33.QueryString.Has("perf")&&(C33.isPerformanceProfiling=!0),"dev"!==C33.QueryString.Get("mode")&&C33.SetBuildMode("final")}{let GetWindowsNTVersionName2=function(e){const t=parseFloat(e),s=windowsNTVerMap.get(t);return s||(13<=t?"11":"NT "+e)};GetWindowsNTVersionName=GetWindowsNTVersionName2;const C33=self.C3,UNKNOWN="(unknown)",windowsNTVerMap=(C33.Platform={OS:UNKNOWN,OSVersion:UNKNOWN,Browser:UNKNOWN,BrowserVersion:UNKNOWN,BrowserVersionNumber:NaN,BrowserEngine:UNKNOWN,Context:"browser",IsDesktop:!0,IsMobile:!1,IsAppleOS:!1,IsIpadOS:!1,GetDetailedInfo:async()=>{}},new Map([[5,"2000"],[5.1,"XP"],[5.2,"XP"],[6,"Vista"],[6.1,"7"],[6.2,"8"],[6.3,"8.1"],[10,"10"]])),uaStr=navigator.userAgent,uaData=navigator.userAgentData;if(uaData&&0<uaData.brands.length){let ReadBrandList2=function(t){let s="",i="",n="",r="";for(const a of t){const o=d.get(a.brand),l=(!s&&o&&(s=o,i=a.version),e.get(a.brand));!n&&l&&(n=l,r=a.version)}s||"Chromium"!==n||(C33.Platform.Browser="Chromium",C33.Platform.BrowserVersion=r),C33.Platform.Browser=s||UNKNOWN,C33.Platform.BrowserVersion=i||UNKNOWN,C33.Platform.BrowserEngine=n||UNKNOWN};ReadBrandList=ReadBrandList2,C33.Platform.OS=uaData.platform,C33.Platform.IsMobile=uaData.mobile,C33.Platform.IsDesktop=!C33.Platform.IsMobile;const d=new Map([["Google Chrome","Chrome"],["Microsoft Edge","Edge"],["Opera","Opera"],["Opera GX","Opera GX"],["Mozilla Firefox","Firefox"],["Apple Safari","Safari"],["NW.js","NW.js"]]),e=new Map([["Chromium","Chromium"],["Gecko","Gecko"],["WebKit","WebKit"]]);ReadBrandList2(uaData.brands);let o=!1;C33.Platform.GetDetailedInfo=async()=>{if(!o)try{const e=await navigator.userAgentData.getHighEntropyValues(["platformVersion","fullVersionList"]);ReadBrandList2(e.fullVersionList),"Windows"===C33.Platform.OS?C33.Platform.OSVersion=GetWindowsNTVersionName2(e.platformVersion):C33.Platform.OSVersion=e.platformVersion,o=!0}catch(e){console.warn("Failed to get detailed user agent information: ",e)}}}else{let RunTest2=function(e,t){const s=Array.isArray(e)?e:[e];for(const i of s){const n=i.exec(uaStr);if(n){t(n);break}}};RunTest=RunTest2,RunTest2(/windows\s+nt\s+([\d\.]+)/i,e=>{C33.Platform.OS="Windows";const t=e[1];C33.Platform.OSVersion=GetWindowsNTVersionName2(t)}),RunTest2(/mac\s+os\s+x\s+([\d\._]+)/i,e=>{C33.Platform.OS="macOS",C33.Platform.OSVersion=e[1].replace(/_/g,".")}),RunTest2(/CrOS/,()=>{C33.Platform.OS="Chrome OS"}),RunTest2(/linux|openbsd|freebsd|netbsd/i,()=>{C33.Platform.OS="Linux"}),RunTest2(/android/i,()=>{C33.Platform.OS="Android"}),RunTest2(/android\s+([\d\.]+)/i,e=>{C33.Platform.OS="Android",C33.Platform.OSVersion=e[1]}),C33.Platform.OS===UNKNOWN&&(RunTest2(/(iphone|ipod|ipad)/i,e=>{C33.Platform.OS="iOS"}),RunTest2([/iphone\s+os\s+([\d\._]+)/i,/ipad[^)]*os\s+([\d\._]+)/i],e=>{C33.Platform.OS="iOS",C33.Platform.OSVersion=e[1].replace(/_/g,".")}));const q=/chrome\//i.test(uaStr),r=/chromium\//i.test(uaStr),s=/edg\//i.test(uaStr),t=/OPR\//.test(uaStr),u=/nwjs/i.test(uaStr),v=/safari\//i.test(uaStr),w=/webkit/i.test(uaStr),x=(s||t||RunTest2(/chrome\/([\d\.]+)/i,e=>{C33.Platform.Browser="Chrome",C33.Platform.BrowserVersion=e[1],C33.Platform.BrowserEngine="Chromium"}),RunTest2(/edg\/([\d\.]+)/i,e=>{C33.Platform.Browser="Edge",C33.Platform.BrowserVersion=e[1],C33.Platform.BrowserEngine="Chromium"}),RunTest2(/OPR\/([\d\.]+)/,e=>{C33.Platform.Browser="Opera",C33.Platform.BrowserVersion=e[1],C33.Platform.BrowserEngine="Chromium"}),RunTest2(/chromium\/([\d\.]+)/i,e=>{C33.Platform.Browser="Chromium",C33.Platform.BrowserVersion=e[1],C33.Platform.BrowserEngine="Chromium"}),RunTest2(/nwjs\/[0-9.]+/i,e=>{C33.Platform.Browser="NW.js",C33.Platform.BrowserVersion=e[1],C33.Platform.BrowserEngine="Chromium",C33.Platform.Context="nwjs"}),RunTest2(/firefox\/([\d\.]+)/i,e=>{C33.Platform.Browser="Firefox",C33.Platform.BrowserVersion=e[1],C33.Platform.BrowserEngine="Gecko"}),!v||q||r||s||t||u||(C33.Platform.Browser="Safari",C33.Platform.BrowserEngine="WebKit",RunTest2(/version\/([\d\.]+)/i,e=>{C33.Platform.BrowserVersion=e[1]}),RunTest2(/crios\/([\d\.]+)/i,e=>{C33.Platform.Browser="Chrome for iOS",C33.Platform.BrowserVersion=e[1]}),RunTest2(/fxios\/([\d\.]+)/i,e=>{C33.Platform.Browser="Firefox for iOS",C33.Platform.BrowserVersion=e[1]}),RunTest2(/edgios\/([\d\.]+)/i,e=>{C33.Platform.Browser="Edge for iOS",C33.Platform.BrowserVersion=e[1]})),C33.Platform.BrowserEngine===UNKNOWN&&w&&(C33.Platform.BrowserEngine="WebKit"),"Android"===C33.Platform.OS&&"Safari"===C33.Platform.Browser&&(C33.Platform.Browser="Stock"),new Set(["Windows","macOS","Linux","Chrome OS"])),y=x.has(C33.Platform.OS)||"nwjs"===C33.Platform.Context;C33.Platform.IsDesktop=y,C33.Platform.IsMobile=!y}"Chrome"===C33.Platform.Browser&&"browser"===C33.Platform.Context&&/wv\)/.test(uaStr)&&(C33.Platform.Context="webview"),"nwjs"!==C33.Platform.Context&&"undefined"!=typeof window&&(window.matchMedia&&window.matchMedia("(display-mode: standalone)").matches||navigator.standalone)&&(C33.Platform.Context="webapp"),C33.Platform.BrowserVersionNumber=parseFloat(C33.Platform.BrowserVersion);const looksLikeIPadOS="macOS"===C33.Platform.OS&&navigator.maxTouchPoints&&2<navigator.maxTouchPoints;looksLikeIPadOS&&(C33.Platform.OS="iOS",C33.Platform.OSVersion=C33.Platform.BrowserVersion,C33.Platform.IsDesktop=!1,C33.Platform.IsMobile=!0,C33.Platform.IsIpadOS=!0),C33.Platform.IsAppleOS="macOS"===C33.Platform.OS||"iOS"===C33.Platform.OS}{let asyncifyRequest2=function(s){return new Promise((e,t)=>{s.onsuccess=()=>e(s.result),s.onerror=()=>t(s.error)})},asyncifyTransaction2=function(s){return new Promise((e,t)=>{s.oncomplete=()=>e(),s.onerror=()=>t(s.error),s.onabort=()=>t(s.error)})},openReadOnlyTransaction2=function(e,t){return openTransaction(e,t)},openWriteTransaction2=function(e,t){return openTransaction(e,t,!0)},lazyOpenDatabase2=function(t){RequireString2(t);let e=c.get(t);return e instanceof Promise||(e=openDatabase(t),c.set(t,e),e.catch(e=>c.delete(t))),e},RequireString2=function(e){if("string"!=typeof e)throw new TypeError("expected string")},getEntriesFromCursor2=function(e,n){const t=e.objectStore(b).openCursor();return new Promise(s=>{const i=[];t.onsuccess=e=>{const t=e.target.result;if(t){switch(n){case"entries":i.push([t.key,t.value]);break;case"keys":i.push(t.key);break;case"values":i.push(t.value)}t.continue()}else s(i)}})};asyncifyRequest=asyncifyRequest2,asyncifyTransaction=asyncifyTransaction2,openReadOnlyTransaction=openReadOnlyTransaction2,openWriteTransaction=openWriteTransaction2,lazyOpenDatabase=lazyOpenDatabase2,RequireString=RequireString2,getEntriesFromCursor=getEntriesFromCursor2;const a=2,b="keyvaluepairs",c=new Map,d="undefined"!=typeof IDBObjectStore&&"function"==typeof IDBObjectStore.prototype.getAll,e="undefined"!=typeof IDBObjectStore&&"function"==typeof IDBObjectStore.prototype.getAllKeys;async function openTransaction(t,s,i=!1,n=!0){const e=await lazyOpenDatabase2(t);try{const r=e.transaction([b],i?"readwrite":"readonly");return s(r)}catch(e){if(n&&"InvalidStateError"===e.name)return c.delete(t),openTransaction(t,s,i,!1);throw e}}async function openDatabase(s){RequireString2(s);const e=indexedDB.open(s,a);return e.addEventListener("upgradeneeded",e=>{try{const t=e.target.result;t.createObjectStore(b)}catch(e){console.error("Failed to create objectstore for database "+s,e)}}),asyncifyRequest2(e)}class f{constructor(e){RequireString2(e),this.name=e}async ready(){await lazyOpenDatabase2(this.name)}set(n,r){return RequireString2(n),openWriteTransaction2(this.name,async e=>{const t=e.objectStore(b).put(r,n),s=asyncifyRequest2(t),i=asyncifyTransaction2(e);await Promise.all([i,s])})}get(r){return RequireString2(r),openReadOnlyTransaction2(this.name,async e=>{const t=e.objectStore(b).get(r),s=asyncifyRequest2(t),i=asyncifyTransaction2(e),[,n]=await Promise.all([i,s]);return n})}delete(n){return RequireString2(n),openWriteTransaction2(this.name,async e=>{const t=e.objectStore(b).delete(n),s=asyncifyRequest2(t),i=asyncifyTransaction2(e);await Promise.all([i,s])})}clear(){return openWriteTransaction2(this.name,async e=>{const t=e.objectStore(b).clear(),s=asyncifyRequest2(t),i=asyncifyTransaction2(e);await Promise.all([i,s])})}keys(){return openReadOnlyTransaction2(this.name,async t=>{let s;if(e){const r=t.objectStore(b).getAllKeys();s=asyncifyRequest2(r)}else s=getEntriesFromCursor2(t,"keys");const i=asyncifyTransaction2(t),[,n]=await Promise.all([i,s]);return n})}values(){return openReadOnlyTransaction2(this.name,async e=>{let t;if(d){const n=e.objectStore(b).getAll();t=asyncifyRequest2(n)}else t=getEntriesFromCursor2(e,"values");const s=asyncifyTransaction2(e),[,i]=await Promise.all([s,t]);return i})}entries(){return openReadOnlyTransaction2(this.name,async e=>{const t=getEntriesFromCursor2(e,"entries"),s=asyncifyTransaction2(e),[,i]=await Promise.all([s,t]);return i})}}self.KVStorageContainer=f}{let NOT_IMPLEMENTED2=function(e){throw new Error(`"${e}" is not implemented`)},DISALLOW_CALLBACK2=function(e){if("function"==typeof e)throw new Error("localforage callback API is not implemented; please use the promise API instead")},StructuredClone2=function(i){return"object"==typeof i?new Promise(t=>{const{port1:e,port2:s}=new MessageChannel;s.onmessage=e=>t(e.data),e.postMessage(i)}):Promise.resolve(i)};NOT_IMPLEMENTED=NOT_IMPLEMENTED2,DISALLOW_CALLBACK=DISALLOW_CALLBACK2,StructuredClone=StructuredClone2;const a=self.KVStorageContainer,b=[/no available storage method found/i,/an attempt was made to break through the security policy of the user agent/i,/the user denied permission to access the database/i,/a mutation operation was attempted on a database that did not allow mutations/i,/idbfactory\.open\(\) called in an invalid security context/i],c=new WeakMap;class d{constructor(e){this._inst=e,this._isInMemory=!this._inst,this._isInMemory||"undefined"!=typeof indexedDB||(this._isInMemory=!0,console.warn("Unable to use local storage because IndexedDB API is not available")),this._memoryStorage=new Map}_MaybeSwitchToMemoryFallback(e){if(!this._isInMemory)for(const t of b)if(e&&t.test(e.message)){console.error("Unable to use local storage, reverting to in-memory store: ",e,e.message),this._isInMemory=!0;break}}async _getItemFallback(e){const t=this._memoryStorage.get(e),s=await StructuredClone2(t);return void 0===s?null:s}async _setItemFallback(e,t){t=await StructuredClone2(t),this._memoryStorage.set(e,t)}_removeItemFallback(e){this._memoryStorage.delete(e)}_clearFallback(){this._memoryStorage.clear()}_keysFallback(){return Array.from(this._memoryStorage.keys())}IsInMemory(){return this._isInMemory}GetMemoryStorage(){return this._memoryStorage}SetMemoryStorage(e){this._memoryStorage=e}async getItem(t,e){if(DISALLOW_CALLBACK2(e),this._isInMemory)return this._getItemFallback(t);let s;try{s=await this._inst.get(t)}catch(e){return this._MaybeSwitchToMemoryFallback(e),this._isInMemory?this._getItemFallback(t):(console.error(`Error reading '${t}' from storage, returning null: `,e),null)}return void 0===s?null:s}async setItem(t,s,e){if(DISALLOW_CALLBACK2(e),void 0===s&&(s=null),this._isInMemory)await this._setItemFallback(t,s);else try{await this._inst.set(t,s)}catch(e){if(this._MaybeSwitchToMemoryFallback(e),!this._isInMemory)throw e;await this._setItemFallback(t,s)}}async removeItem(t,e){if(DISALLOW_CALLBACK2(e),this._isInMemory)this._removeItemFallback(t);else try{await this._inst.delete(t)}catch(e){this._MaybeSwitchToMemoryFallback(e),this._isInMemory?this._removeItemFallback(t):console.error(`Error removing '${t}' from storage: `,e)}}async clear(e){if(DISALLOW_CALLBACK2(e),this._isInMemory)this._clearFallback();else try{await this._inst.clear()}catch(e){this._MaybeSwitchToMemoryFallback(e),this._isInMemory?this._clearFallback():console.error("Error clearing storage: ",e)}}async keys(e){if(DISALLOW_CALLBACK2(e),this._isInMemory)return this._keysFallback();let t=[];try{t=await this._inst.keys()}catch(e){if(this._MaybeSwitchToMemoryFallback(e),this._isInMemory)return this._keysFallback();console.error("Error getting storage keys: ",e)}return t}ready(e){return DISALLOW_CALLBACK2(e),this._isInMemory?Promise.resolve(!0):this._inst.ready()}createInstance(e){if(e.forceInMemoryFallback)return new d(null);{const t=e.name;if("string"!=typeof t)throw new TypeError("invalid store name");const s=new a(t);return new d(s)}}length(e){NOT_IMPLEMENTED2("localforage.length()")}key(e,t){NOT_IMPLEMENTED2("localforage.key()")}iterate(e,t){NOT_IMPLEMENTED2("localforage.iterate()")}setDriver(e){NOT_IMPLEMENTED2("localforage.setDriver()")}config(e){NOT_IMPLEMENTED2("localforage.config()")}defineDriver(e){NOT_IMPLEMENTED2("localforage.defineDriver()")}driver(){NOT_IMPLEMENTED2("localforage.driver()")}supports(e){NOT_IMPLEMENTED2("localforage.supports()")}dropInstance(){NOT_IMPLEMENTED2("localforage.dropInstance()")}}self.localforage=new d(new a("localforage"))}{const C33=self.C3;if(C33.Supports={},C33.Supports.WebAnimations=(()=>{try{if("undefined"==typeof document)return!1;const e=document.createElement("div");if(void 0===e.animate)return!1;const t=e.animate([{opacity:"0"},{opacity:"1"}],1e3);return void 0!==t.reverse}catch(e){return!1}})(),C33.Supports.DialogElement="undefined"!=typeof HTMLDialogElement,C33.Supports.RequestIdleCallback=!!self.requestIdleCallback,C33.Supports.ImageBitmap=!!self.createImageBitmap,C33.Supports.ImageBitmapOptions=!1,C33.Supports.ImageBitmapOptionsResize=!1,C33.Supports.ImageBitmap){try{self.createImageBitmap(new ImageData(32,32),{premultiplyAlpha:"none"}).then(()=>{C33.Supports.ImageBitmapOptions=!0}).catch(()=>{C33.Supports.ImageBitmapOptions=!1})}catch(e){C33.Supports.ImageBitmapOptions=!1}try{self.createImageBitmap(new ImageData(32,32),{resizeWidth:10,resizeHeight:10}).then(e=>{C33.Supports.ImageBitmapOptionsResize=10===e.width&&10===e.height}).catch(()=>{C33.Supports.ImageBitmapOptionsResize=!1})}catch(e){C33.Supports.ImageBitmapOptionsResize=!1}}if(C33.Supports.ClipboardReadText=!(!navigator.clipboard||!navigator.clipboard.readText),C33.Supports.PermissionsQuery=!(!navigator.permissions||!navigator.permissions.query),C33.Supports.ClipboardPermissionsQuery=!1,C33.Supports.PermissionsQuery){const g={name:"clipboard-read"};navigator.permissions.query(g).then(()=>{C33.Supports.ClipboardPermissionsQuery=!0}).catch(()=>{C33.Supports.ClipboardPermissionsQuery=!1})}C33.Supports.AsyncClipboardApi=!!(navigator.permissions&&navigator.clipboard&&self.ClipboardItem),C33.Supports.Proxies="undefined"!=typeof Proxy,C33.Supports.DownloadAttribute=(()=>{if("undefined"==typeof document)return!1;const e=document.createElement("a");return void 0!==e.download})(),C33.Supports.Fetch="function"==typeof fetch,C33.Supports.PersistentStorage=!!(self.isSecureContext&&"Opera"!==C33.Platform.Browser&&navigator.storage&&navigator.storage.persist),C33.Supports.StorageQuotaEstimate=!!(self.isSecureContext&&navigator.storage&&navigator.storage.estimate),C33.Supports.Fullscreen=(()=>{if("undefined"==typeof document)return!1;if("iOS"===C33.Platform.OS)return!1;const e=document.documentElement;return!!(e.requestFullscreen||e.msRequestFullscreen||e.mozRequestFullScreen||e.webkitRequestFullscreen)})(),C33.Supports.ImageDecoder=void 0!==self.ImageDecoder,C33.Supports.WebCodecs=!!self.VideoEncoder,C33.Supports.NativeFileSystemAPI=!!self.showOpenFilePicker,C33.Supports.QueryLocalFonts=!!self.queryLocalFonts,C33.Supports.UserActivation=!!navigator.userActivation,C33.Supports.CanvasToBlobWebP=!1,(async()=>{let t;"undefined"==typeof document?t=new OffscreenCanvas(32,32):((t=document.createElement("canvas")).width=32,t.height=32);const e=t.getContext("2d");e.fillStyle="blue",e.fillRect(0,0,32,32);let s=null;try{t.convertToBlob?s=await t.convertToBlob({type:"image/webp",quality:1}):t.toBlob&&(s=await new Promise(e=>t.toBlob(e,"image/webp",1))),C33.Supports.CanvasToBlobWebP=s&&"image/webp"===s.type}catch(e){C33.Supports.CanvasToBlobWebP=!1}})()}{let arrayFlat2=function(e,s){return e.reduce((e,t)=>(0<s&&Array.isArray(t)?Array.prototype.push.apply(e,arrayFlat2(t,s-1)):e.push(t),e),[])};arrayFlat=arrayFlat2;const C33=self.C3;if(!String.prototype.trimStart){const a=/^[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]*/;String.prototype.trimStart=function(){return this.replace(a,"")}}if(!String.prototype.trimEnd){const c=/[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]*$/;String.prototype.trimEnd=function(){return this.replace(c,"")}}String.prototype.replaceAll||(String.prototype.replaceAll=function(e,t){return this.replace(new RegExp(C33.EscapeRegex(e),"g"),t)}),Array.prototype.values||(Array.prototype.values=function*(){for(const e of this)yield e}),Array.prototype.flat||(Array.prototype.flat=function(e=1){return arrayFlat2(this,e)}),Array.prototype.at||(Array.prototype.at=function(e){if((e=Math.trunc(e)||0)<0&&(e+=this.length),!(e<0||e>=this.length))return this[e]}),String.prototype.at||(String.prototype.at=function(e){if((e=Math.trunc(e)||0)<0&&(e+=this.length),!(e<0||e>=this.length))return this[e]}),RegExp.escape||(RegExp.escape=function(e){return String(e).replace(/[\\^$*+?.()|[\]{}]/g,"\\$&")}),Set.prototype.isSubsetOf||(Set.prototype.isSubsetOf=function(e){if(!(e instanceof Set))throw new TypeError("argument must be a Set");for(const t of this)if(!e.has(t))return!1;return!0}),navigator.storage&&!navigator.storage.estimate&&navigator.webkitTemporaryStorage&&navigator.webkitTemporaryStorage.queryUsageAndQuota&&(navigator.storage.estimate=function(){return new Promise((s,e)=>navigator.webkitTemporaryStorage.queryUsageAndQuota((e,t)=>s({usage:e,quota:t}),e))}),void 0===self.isSecureContext&&(self.isSecureContext="https:"===location.protocol),void 0===self.globalThis&&(self.globalThis=self)}{let assertFail2=function(e){let t=C33.GetCallStack(),s="Assertion failure: "+e+"\n\nStack trace:\n"+t;console.error(s)};assertFail=assertFail2;const C33=self.C3;self.assert=function(e,t){e||assertFail2(t)}}{const C33=self.C3,C3X=self.C3X,TypedArray=(C33.IsNumber=function(e){return"number"==typeof e},C33.IsFiniteNumber=function(e){return C33.IsNumber(e)&&isFinite(e)},C33.RequireNumber=function(e){if(!C33.IsNumber(e))throw new TypeError("expected number")},C33.RequireOptionalNumber=function(e){C33.IsNullOrUndefined(e)},C33.RequireNumberInRange=function(e,t,s){if(!C33.IsNumber(e)||isNaN(e)||e<t||s<e)throw new RangeError("number outside of range")},C33.RequireAllNumber=function(...t){for(let e of t);},C33.RequireFiniteNumber=function(e){if(!C33.IsFiniteNumber(e))throw new TypeError("expected finite number")},C33.RequireOptionalFiniteNumber=function(e){C33.IsNullOrUndefined(e)},C33.RequireAllFiniteNumber=function(...t){for(let e of t);},C33.IsString=function(e){return"string"==typeof e},C33.RequireString=function(e){if(!C33.IsString(e))throw new TypeError("expected string")},C33.RequireOptionalString=function(e){C33.IsNullOrUndefined(e)},C33.RequireAllString=function(...t){for(let e of t);},C33.IsSimpleObject=function(e){if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);return t?t.constructor===Object:null===t},C33.RequireSimpleObject=function(e){if(!C33.IsSimpleObject(e))throw new TypeError("expected simple object")},C33.RequireOptionalSimpleObject=function(e){if(!C33.IsNullOrUndefined(e)&&!C33.IsSimpleObject(e))throw new TypeError("expected simple object")},C33.IsObject=function(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)},C33.RequireObject=function(e){if(!C33.IsObject(e))throw new TypeError("expected object")},C33.RequireOptionalObject=function(e){C33.IsNullOrUndefined(e)},C33.RequireAllObject=function(...t){for(let e of t);},C33.IsFileLike=function(e){return C33.WeakIsInstanceOf(e,Blob)&&"string"==typeof e.name},C33.RequireFileLike=function(e){if(!C33.IsFileLike(e))throw new TypeError("expected file")},C33.RequireOptionalFileLike=function(e){C33.IsNullOrUndefined(e)},C33.IsArray=function(e){return Array.isArray(e)},C33.RequireArray=function(e){if(!C33.IsArray(e))throw new TypeError("expected array")},C33.RequireOptionalArray=function(e){C33.IsNullOrUndefined(e)},C33.RequireAllArray=function(...t){for(let e of t);},C33.Is2DArray=function(e){return!(!C33.IsArray(e)||e.length&&!C33.IsArray(e[0]))},C33.Require2DArray=function(t){if(!C33.Is2DArray(t))throw new TypeError("expected 2d array");for(let e of t)if(!C33.IsArray(e))throw new TypeError("expected 2d array")},C33.RequireOptional2DArray=function(e){C33.IsNullOrUndefined(e)},C33.IsFunction=function(e){return"function"==typeof e},C33.RequireFunction=function(e,t){if(!C33.IsFunction(e))throw new TypeError("expected function");if(!C33.IsNullOrUndefined(t)&&e!==t)throw new TypeError("expected same function reference")},C33.RequireOptionalFunction=function(e){C33.IsNullOrUndefined(e)},C33.RequireAllFunction=function(...t){for(let e of t);},C33.RequireAnyFunction=function(t,...s){if(!C33.IsFunction(t))throw new TypeError("expected function");if(!s.length)throw new Error("missing comparison functions");for(let e of s)if(!C33.IsNullOrUndefined(e)&&t===e)return;throw new TypeError("expected same function reference")},C33.RequireOptionalAllFunction=function(...t){if(!C33.IsNullOrUndefined(t))for(let e of t);},C33.IsInstanceOf=function(e,t){return e instanceof t},C33.IsInstanceOfAny=function(t,...s){for(let e of s)if(C33.IsInstanceOf(t,e))return!0;return!1},C33.RequireInstanceOf=function(e,t){if(!C33.IsInstanceOf(e,t))throw new TypeError("unexpected type")},C33.RequireOptionalInstanceOf=function(e,t){C33.IsNullOrUndefined(e)},C33.RequireAllInstanceOf=function(e,...t){for(let e of t);},C33.RequireAnyInstanceOf=function(e,...t){if(!C33.IsInstanceOfAny(e,...t))throw new TypeError("unexpected type")},C33.RequireAnyOptionalInstanceOf=function(e,...t){if(!C33.IsNullOrUndefined(e)&&!C33.IsInstanceOfAny(e,...t))throw new TypeError("unexpected type")},C33.IsArrayOf=function(t,s){for(let e of t)if(!C33.IsInstanceOf(e,s))return!1;return!0},C33.IsArrayOfFiniteNumbers=function(t){for(let e of t)if(!C33.IsFiniteNumber(e))return!1;return!0},C33.RequireArrayOf=function(t,e){for(let e of t);},C33.RequireOptionalArrayOf=function(t,e){if(!C33.IsNullOrUndefined(t))for(let e of t);},C33.RequireOptionalArrayOfFunctions=function(t,e){if(!C33.IsNullOrUndefined(t))for(let e of t);},C33.RequireArrayOfAny=function(t){for(let e of t);},C33.RequireOptionalArrayOfAny=function(t){if(!C33.IsNullOrUndefined(t))for(let e of t);},C33.IsDOMNode=function(e,t){return!(C33.IsNullOrUndefined(e)||!C33.IsString(e.nodeName))&&(!t||C33.equalsNoCase(e.nodeName,t))},C33.RequireDOMNode=function(e,t){if(C33.IsNullOrUndefined(e)||!C33.IsString(e.nodeName))throw new TypeError("expected DOM node");if(t&&!C33.equalsNoCase(e.nodeName,t))throw new TypeError(`expected DOM '${t}' node`)},C33.RequireOptionalDOMNode=function(e,t){C33.IsNullOrUndefined(e)},C33.IsHTMLElement=function(e,t){return!(C33.IsNullOrUndefined(e)||!C33.IsString(e.tagName))&&(!t||C33.equalsNoCase(e.tagName,t))},C33.RequireHTMLElement=function(e,t){if(C33.IsNullOrUndefined(e)||!C33.IsString(e.tagName))throw new TypeError("expected HTML element");if(t&&!C33.equalsNoCase(e.tagName,t))throw new TypeError(`expected HTML '${t}' element`)},C33.RequireOptionalHTMLElement=function(e,t){C33.IsNullOrUndefined(e)},C33.IsDrawable=function(e){return C33.IsHTMLElement(e,"img")||C33.IsHTMLElement(e,"canvas")||C33.IsHTMLElement(e,"video")||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap},C33.RequireDrawable=function(e){if(!C33.IsDrawable(e))throw new TypeError("expected drawable")},C33.RequireOptionalDrawable=function(e){C33.IsNullOrUndefined(e)},C33.IsDrawableOrImageData=function(e){return e instanceof ImageData||C33.IsDrawable(e)},C33.RequireDrawableOrImageData=function(e){if(!C33.IsDrawableOrImageData(e))throw new TypeError("expected drawable or image data")},C33.RequireOptionalDrawableOrImageData=function(e){if(!C33.IsNullOrUndefined(e)&&!C33.IsDrawableOrImageData(e))throw new TypeError("expected drawable or image data")},C33.IsStringLike=function(e){return"string"==typeof e||C33.HtmlString&&e instanceof C33.HtmlString||e instanceof C33.BBString},C33.RequireStringLike=function(e){if(!C33.IsStringLike(e))throw new TypeError("expected string-like")},C33.RequireOptionalStringLike=function(e){C33.IsNullOrUndefined(e)},C33.RequireAllStringLike=function(...t){for(let e of t);},C33.RequireOverride=function(){throw new Error("must be overridden")},C33.NotYetImplemented=function(){throw new Error("not yet implemented")},C33.IsGeneratorFunction=function(e){return e.constructor===function*(){}.constructor},C33.RequireGeneratorFunction=function(e){if(!C33.IsGeneratorFunction(e))throw new Error("expected generator function")},C33.IsIterable=function(e){return"function"===e[Symbol.iterator]},C33.RequireIterable=function(e){if(!C33.IsIterable(e))throw new Error("expected iterable")},C33.IsDefined=function(e){return!C33.IsNullOrUndefined(e)},C33.IsNullOrUndefined=function(e){return null==e},C33.AreArrayElementsOfSameType=function(t){let s=t[0].constructor;for(let e of t)if(e.constructor!==s)return!1;return s},C33.AreArrayElementsOfType=function(t,s){for(let e of t)if(!(e instanceof s))return!1;return!0},Object.getPrototypeOf(Uint8Array));C33.IsTypedArray=function(e){return C33.IsInstanceOf(e,TypedArray)},C33.RequireTypedArray=function(e){},C33.WeakRequireTypedArray=function(e){C33.WeakRequireInstanceOf(e,TypedArray)},C33.WeakRequireAnyInstanceOf=function(e,...t){if(!C33.WeakIsAnyInstanceOf(e,...t))throw new TypeError("unexpected type")},C33.WeakIsAnyInstanceOf=function(e,...t){for(const s of t)if(C33.WeakIsInstanceOf(e,s))return!0;return!1},C33.WeakRequireInstanceOf=function(e,t){if(!C33.WeakIsInstanceOf(e,t))throw new TypeError("unexpected type")},C33.WeakIsInstanceOf=function(e,t){for(;e=Object.getPrototypeOf(e);)if(e.constructor.name===t.name)return!0;return!1},C3X.RequireNumber=C33.RequireNumber,C3X.RequireOptionalNumber=C33.RequireOptionalNumber,C3X.RequireFiniteNumber=C33.RequireFiniteNumber,C3X.RequireOptionalFiniteNumber=C33.RequireOptionalFiniteNumber,C3X.RequireString=C33.RequireString,C3X.RequireOptionalString=C33.RequireOptionalString,C3X.RequireObject=C33.RequireObject,C3X.RequireOptionalObject=C33.RequireOptionalObject,C3X.RequireArray=C33.RequireArray,C3X.RequireOptionalArray=C33.RequireOptionalArray,C3X.RequireFunction=C33.RequireFunction,C3X.RequireOptionalFunction=C33.RequireOptionalFunction,C3X.RequireInstanceOf=C33.RequireInstanceOf,C3X.RequireOptionalInstanceOf=C33.RequireOptionalInstanceOf,C3X.IsNullOrUndefined=C33.IsNullOrUndefined}{let isValidTypeChange2=function(e,t){let s=C33.getType(e),i=C33.getType(t);return"null"===s||"null"===i||"undefined"!==s&&"undefined"!==i&&s===i},logDefendedObjectWarning2=function(e){console.warn("[Defence] "+e+" @",C33.GetCallStack())},CheckDefendedObjectsUsedCorrectly2=function(){if(checkRafId=-1,0<ctorObjectToProxy.size||0<ctorProxyToObject.size){let e=new Set([...ctorObjectToProxy.keys()].map(e=>C33.getName(e))),t=[...e].join(",");console.warn("An object derived from DefendedBase was not protected with debugDefend(). This will disable some checks. See the coding guidelines! Possible affected class names: "+t),ctorObjectToProxy.clear(),ctorProxyToObject.clear()}},getObjectPropertySet2=function(t){let s=new Set;for(let e in t)s.add(e);return s},VerifyObjectPropertiesConsistent2=function(e,t){let s=getObjectPropertySet2(t),i=typeProperties.get(e);if(i){let t=[];for(let e of i.values())s.has(e)?s.delete(e):t.push(e);C33.appendArray(t,[...s]),t.length&&console.warn(`[Defence] '${C33.getName(e)}' constructor creates inconsistent properties: `+t.join(", "))}else typeProperties.set(e,s)};isValidTypeChange=isValidTypeChange2,logDefendedObjectWarning=logDefendedObjectWarning2,CheckDefendedObjectsUsedCorrectly=CheckDefendedObjectsUsedCorrectly2,getObjectPropertySet=getObjectPropertySet2,VerifyObjectPropertiesConsistent=VerifyObjectPropertiesConsistent2;const C33=self.C3,logRafIds=new Map;C33.ColorLog=function(e,t){console.log("%c"+e,"font-weight: bold; color:"+t)},C33.RafLog=function(e,...t){logRafIds.has(e)||logRafIds.set(e,-1),-1===logRafIds.get(e)&&logRafIds.set(e,requestAnimationFrame(()=>{console.log("%c"+e,"font-weight: bold",...t),logRafIds.set(e,-1)}))};let measures,ctorObjectToProxy=(C33.StartMeasure=function(e){performance.mark(e),(measures=measures||new Map).has(e)||measures.set(e,{current:0,total:0,average:0,calls:1,toString:function(){return`${e} :: current => ${this.current.toPrecision(3)} :: average => ${this.average.toPrecision(3)} :: calls => `+this.calls}})},C33.EndMeasure=function(e){performance.measure("measure-"+e,e);const t=performance.getEntriesByName("measure-"+e)[0],s=measures.get(e);s.current=t.duration,s.total+=s.current,s.average=s.total/s.calls,console.log(s.toString()),s.calls++,performance.clearMarks(e),performance.clearMeasures("measure-"+e)},C33.GetCallStack=function(){return(new Error).stack},C33.Debugger=function(){},C33.cast=function(e,t){return e&&e instanceof t?e:null},C33.getName=function(e){return void 0===e?"undefined":null===e?"null":"boolean"==typeof e?"<boolean>":C33.IsNumber(e)?"<number>":C33.IsString(e)?"<string>":C33.IsArray(e)?"<array>":"symbol"==typeof e?"<"+e.toString()+">":C33.IsFunction(e)?e.name&&"Function"!==e.name?e.name:"<anonymous function>":"object"==typeof e?e.constructor&&e.constructor.name&&"Object"!==e.constructor.name?e.constructor.name:"<anonymous object>":"<unknown>"},C33.getType=function(e){return null===e?"null":Array.isArray(e)?"array":typeof e},C33.range=function*(t,s){if(!isFinite(Math.abs(t-s)))throw new Error("Invalid parameters");if(s<t)for(let e=t-1;e>=s;e--)yield e;else for(let e=t;e<s;e++)yield e},new Map),ctorProxyToObject=new Map,proxyToObject=new WeakMap,releasedObjects=new WeakMap;C33.DefendHandler={};const VALID_GET_MISSING_KEYS=new Set(["then","splice"]);C33.DefendHandler.get=function(e,t){return t in e||"symbol"==typeof t||VALID_GET_MISSING_KEYS.has(t)||logDefendedObjectWarning2(`Accessed missing property '${t}' from defended object '${C33.getName(e)}', returning undefined`),releasedObjects.has(e)&&"symbol"!=typeof t&&!VALID_GET_MISSING_KEYS.has(t)&&logDefendedObjectWarning2(`Accessed property '${t}' on a released object '${C33.getName(e)}' Object was originally released at: ${releasedObjects.get(e)}) Call stack at access: `),e[t]},C33.DefendHandler.set=function(e,t,s){return t in e||ctorObjectToProxy.has(e)||logDefendedObjectWarning2(`Set non-existent property '${t}' to '${s}' on defended object '${C33.getName(e)}'`),isValidTypeChange2(e[t],s)||ctorObjectToProxy.has(e)||logDefendedObjectWarning2(`Set '${C33.getType(e[t])}' property '${t}' to type '${C33.getType(s)}' on defended object '${C33.getName(e)}'`),releasedObjects.has(e)&&logDefendedObjectWarning2(`Set property '${t}' on a released object '${C33.getName(e)}' Object was originally released at: ${releasedObjects.get(e)}) Call stack at access: `),e[t]=s,!0},C33.DefendHandler.deleteProperty=function(e,t){throw new ReferenceError(`Cannot delete property '${t}' from defended object '${C33.getName(e)}'`)},C33.DefendHandler.defineProperty=function(e,t,s){throw new ReferenceError(`Cannot define property '${t}' on defended object '${C33.getName(e)}'`)},C33.DefendHandler.enumerate=function(e){throw new ReferenceError(`Cannot enumerate defended object '${C33.getName(e)}'`)};let checkRafId=-1,typeProperties=(C33.DefendedBase=class{constructor(){if(C33.isDebugDefend&&C33.Supports.Proxies){let e=Object.create(new.target.prototype),t=new Proxy(e,C33.DefendHandler);return ctorObjectToProxy.set(e,t),ctorProxyToObject.set(t,e),proxyToObject.set(t,e),-1===checkRafId&&(checkRafId=requestAnimationFrame(CheckDefendedObjectsUsedCorrectly2)),t}}},C33.debugDefend=function(t){if(C33.isDebugDefend&&C33.Supports.Proxies&&t instanceof C33.DefendedBase){if(ctorProxyToObject.has(t)){let e=ctorProxyToObject.get(t);ctorProxyToObject.delete(t),ctorObjectToProxy.delete(e)}return t}return C33.isDebug?Object.seal(t):t},C33.New=function(e,...t){let s;try{s=new e(...t)}catch(e){throw ctorProxyToObject.clear(),ctorObjectToProxy.clear(),e}return C33.isDebugDefend&&VerifyObjectPropertiesConsistent2(e,s),C33.debugDefend(s)},C33.Release=function(e){let t=proxyToObject.get(e);t&&releasedObjects.set(t,C33.GetCallStack())},C33.WasReleased=function(e){let t=proxyToObject.get(e);return!!t&&!!releasedObjects.get(t)},new Map);C33.PerfMark=class{constructor(e){this._name="",e&&this.start(e)}start(e){C33.isPerformanceProfiling&&(this._name=e,performance.mark(this._name+"-Start"))}end(){C33.isPerformanceProfiling&&(performance.mark(this._name+"-End"),performance.measure(this._name,this._name+"-Start",this._name+"-End"))}next(e){C33.isPerformanceProfiling&&(this.end(),this._name=e,performance.mark(this._name+"-Start"))}}}{let isNegativeZero2=function(e){return 0===e&&1/e<0};isNegativeZero=isNegativeZero2;const C33=self.C3,TWO_PI=2*Math.PI,D_TO_R=Math.PI/180,R_TO_D=180/Math.PI,ALPHAEX_SHIFT=(C33.wrap=function(e,t,s){e=Math.floor(e),t=Math.floor(t);const i=(s=Math.floor(s))-t;if(0==i)return s;if(e<t){const n=s-(t-e)%i;return n===s?0:n}return t+(e-t)%i},C33.mapToRange=function(e,t,s,i,n){const r=s-t;if(0==r&&0===i)return e;const a=n-i;return(e-t)*a/r+i},C33.normalize=function(e,t,s){return t-s==0?1:(e-t)/(s-t)},C33.clamp=function(e,t,s){return e<t?t:s<e?s:e},C33.clampAngle=function(e){return(e%=TWO_PI)<0&&(e+=TWO_PI),e},C33.toRadians=function(e){return e*D_TO_R},C33.toDegrees=function(e){return e*R_TO_D},C33.hypot2DFast=function(e,t){return Math.sqrt(e*e+t*t)},C33.hypot3DFast=function(e,t,s){return Math.sqrt(e*e+t*t+s*s)},C33.distanceTo=function(e,t,s,i){return C33.hypot2DFast(s-e,i-t)},C33.distanceSquared=function(e,t,s,i){const n=s-e,r=i-t;return n*n+r*r},C33.angleTo=function(e,t,s,i){return Math.atan2(i-t,s-e)},C33.angleDiff=function(e,t){if(e===t)return 0;let s=Math.sin(e),i=Math.cos(e),n=Math.sin(t),r=Math.cos(t),a=s*n+i*r;return 1<=a?0:a<=-1?Math.PI:Math.acos(a)},C33.angleRotate=function(e,t,s){let i=Math.sin(e),n=Math.cos(e),r=Math.sin(t),a=Math.cos(t);return Math.acos(i*r+n*a)>s?0<n*r-i*a?C33.clampAngle(e+s):C33.clampAngle(e-s):C33.clampAngle(t)},C33.angleClockwise=function(e,t){let s=Math.sin(e),i=Math.cos(e),n=Math.sin(t),r=Math.cos(t);return i*n-s*r<=0},C33.angleLerp=function(e,t,s,i=0){let n=C33.angleDiff(e,t),r=TWO_PI*i;return C33.angleClockwise(t,e)?C33.clampAngle(e+(n+r)*s):C33.clampAngle(e-(n+r)*s)},C33.angleLerpClockwise=function(e,t,s,i=0){const n=C33.angleDiff(e,t),r=TWO_PI*i;return C33.angleClockwise(t,e)?C33.clampAngle(e+(n+r)*s):C33.clampAngle(e+(TWO_PI-n+r)*s)},C33.angleLerpAntiClockwise=function(e,t,s,i=0){const n=C33.angleDiff(e,t),r=TWO_PI*i;return C33.angleClockwise(t,e)?C33.clampAngle(e-(-TWO_PI+n-r)*s):C33.clampAngle(e-(n+r)*s)},C33.angleReflect=function(e,t){const s=C33.angleDiff(e,t);return C33.angleClockwise(e,t)?C33.clampAngle(t-s):C33.clampAngle(t+s)},C33.lerp=function(e,t,s){return e+s*(t-e)},C33.unlerp=function(e,t,s){return e===t?0:(s-e)/(t-e)},C33.relerp=function(e,t,s,i,n){return C33.lerp(i,n,C33.unlerp(e,t,s))},C33.qarp=function(e,t,s,i){return C33.lerp(C33.lerp(e,t,i),C33.lerp(t,s,i),i)},C33.cubic=function(e,t,s,i,n){return C33.lerp(C33.qarp(e,t,s,n),C33.qarp(t,s,i,n),n)},C33.cosp=function(e,t,s){return(e+t+(e-t)*Math.cos(s*Math.PI))/2},C33.isPOT=function(e){return 0<e&&0==(e-1&e)},C33.nextHighestPowerOfTwo=function(t){--t;for(let e=1;e<32;e<<=1)t|=t>>e;return t+1},C33.roundToNearestFraction=function(e,t){return Math.round(e*t)/t},C33.floorToNearestFraction=function(e,t){return Math.floor(e*t)/t},C33.roundToDp=function(e,t){t=Math.max(Math.floor(t),0);const s=Math.pow(10,t);return Math.round(e*s)/s},C33.countDecimals=function(e){return Math.floor(e)!==e&&e.toString().split(".")[1].length||0},C33.toFixed=function(e,t){let s=e.toFixed(t),i=s.length-1;for(;0<=i&&"0"===s.charAt(i);--i);return 0<=i&&"."===s.charAt(i)&&--i,i<0?s:s.substr(0,i+1)},C33.PackRGB=function(e,t,s){return C33.clamp(e,0,255)|C33.clamp(t,0,255)<<8|C33.clamp(s,0,255)<<16},1024),ALPHAEX_MAX=1023,RGBEX_SHIFT=16384,RGBEX_MAX=8191,RGBEX_MIN=-8192,COMMON_ASPECT_RATIOS=(C33.PackRGBAEx=function(e,t,s,i){return e=C33.clamp(Math.floor(1024*e),RGBEX_MIN,RGBEX_MAX),t=C33.clamp(Math.floor(1024*t),RGBEX_MIN,RGBEX_MAX),s=C33.clamp(Math.floor(1024*s),RGBEX_MIN,RGBEX_MAX),i=C33.clamp(Math.floor(i*ALPHAEX_MAX),0,ALPHAEX_MAX),e<0&&(e+=RGBEX_SHIFT),t<0&&(t+=RGBEX_SHIFT),s<0&&(s+=RGBEX_SHIFT),-(e*RGBEX_SHIFT*RGBEX_SHIFT*ALPHAEX_SHIFT+t*RGBEX_SHIFT*ALPHAEX_SHIFT+s*ALPHAEX_SHIFT+i)},C33.PackRGBEx=function(e,t,s){return C33.PackRGBAEx(e,t,s,1)},C33.GetRValue=function(t){if(0<=t)return(255&t)/255;{let e=Math.floor(-t/(RGBEX_SHIFT*RGBEX_SHIFT*ALPHAEX_SHIFT));return e>RGBEX_MAX&&(e-=RGBEX_SHIFT),e/1024}},C33.GetGValue=function(t){if(0<=t)return((65280&t)>>8)/255;{let e=Math.floor(-t%(RGBEX_SHIFT*RGBEX_SHIFT*ALPHAEX_SHIFT)/(RGBEX_SHIFT*ALPHAEX_SHIFT));return e>RGBEX_MAX&&(e-=RGBEX_SHIFT),e/1024}},C33.GetBValue=function(t){if(0<=t)return((16711680&t)>>16)/255;{let e=Math.floor(-t%(RGBEX_SHIFT*ALPHAEX_SHIFT)/ALPHAEX_SHIFT);return e>RGBEX_MAX&&(e-=RGBEX_SHIFT),e/1024}},C33.GetAValue=function(e){if(isNegativeZero2(e))return 0;if(0<=e)return 1;{const t=Math.floor(-e%ALPHAEX_SHIFT);return t/ALPHAEX_MAX}},C33.greatestCommonDivisor=function(t,s){for(t=Math.floor(t),s=Math.floor(s);0!==s;){let e=s;s=t%s,t=e}return t},[[3,2],[4,3],[5,4],[5,3],[6,5],[14,9],[16,9],[16,10],[21,9]]),NO_HIT=(C33.getAspectRatio=function(s,i){if((s=Math.floor(s))===(i=Math.floor(i)))return[1,1];for(let t of COMMON_ASPECT_RATIOS){let e=s/t[0]*t[1];if(Math.abs(i-e)<1)return t.slice(0);if(e=s/t[1]*t[0],Math.abs(i-e)<1)return[t[1],t[0]]}let e=C33.greatestCommonDivisor(s,i);return[s/e,i/e]},C33.segmentsIntersect=function(e,t,s,i,n,r,a,o){const l=Math.min(e,s),h=Math.max(e,s),c=Math.min(n,a),u=Math.max(n,a);if(h<c||u<l)return!1;const _=Math.min(t,i),d=Math.max(t,i),p=Math.min(r,o),m=Math.max(r,o);if(d<p||m<_)return!1;const g=n-e+a-s,f=r-t+o-i,S=s-e,C=i-t,y=a-n,G=o-r,I=Math.abs(C*y-G*S),T=y*f-G*g;if(Math.abs(T)>I)return!1;const b=S*f-C*g;return Math.abs(b)<=I},C33.segmentsIntersectPreCalc=function(e,t,s,i,n,r,a,o,l,h,c,u){const _=Math.min(l,c),d=Math.max(l,c);if(r<_||d<n)return!1;const p=Math.min(h,u),m=Math.max(h,u);if(o<p||m<a)return!1;const g=l-e+c-s,f=h-t+u-i,S=s-e,C=i-t,y=c-l,G=u-h,I=Math.abs(C*y-G*S),T=y*f-G*g;if(Math.abs(T)>I)return!1;const b=S*f-C*g;return Math.abs(b)<=I},C33.segmentIntersectsQuad=function(e,t,s,i,n){const r=Math.min(e,s),a=Math.max(e,s),o=Math.min(t,i),l=Math.max(t,i),h=n.getTlx(),c=n.getTly(),u=n.getTrx(),_=n.getTry(),d=n.getBrx(),p=n.getBry(),m=n.getBlx(),g=n.getBly();return C33.segmentsIntersectPreCalc(e,t,s,i,r,a,o,l,h,c,u,_)||C33.segmentsIntersectPreCalc(e,t,s,i,r,a,o,l,u,_,d,p)||C33.segmentsIntersectPreCalc(e,t,s,i,r,a,o,l,d,p,m,g)||C33.segmentsIntersectPreCalc(e,t,s,i,r,a,o,l,m,g,h,c)},C33.segmentIntersectsAnyN=function(t,s,i,n,r){let a=Math.min(t,i),o=Math.max(t,i),l=Math.min(s,n),h=Math.max(s,n),c=0;for(let e=r.length-4;c<=e;c+=2)if(C33.segmentsIntersectPreCalc(t,s,i,n,a,o,l,h,r[c],r[c+1],r[c+2],r[c+3]))return!0;return C33.segmentsIntersectPreCalc(t,s,i,n,a,o,l,h,r[c],r[c+1],r[0],r[1])},2),PADDING=1e-6;C33.rayIntersect=function(e,t,s,i,n,r,a,o){const l=s-e,h=i-t,c=a-n,u=o-r,_=l*u-h*c;if(0==_)return NO_HIT;const d=((t-i)*(a-e)+l*(o-t))/_;return 0<d&&d<1+PADDING?(u*(a-e)+(n-a)*(o-t))/_:NO_HIT},C33.rayIntersectExtended=function(e,t,s,i,n,r,a,o,l){const h=(a-n)*l,c=(o-r)*l;return C33.rayIntersect(e,t,s,i,n-h,r-c,a+h,o+c)},C33.isPointInTriangleInclusive=function(e,t,s,i,n,r,a,o){const l=n-s,h=r-i,c=a-s,u=o-i,_=e-s,d=t-i,p=l*l+h*h,m=l*c+h*u,g=l*_+h*d,f=c*c+u*u,S=c*_+u*d,C=1/(p*f-m*m),y=(f*g-m*S)*C,G=(p*S-m*g)*C;return 0<=y&&0<=G&&y+G<=1},C33.triangleCartesianToBarycentric=function(e,t,s,i,n,r,a,o){const l=n-s,h=r-i,c=a-s,u=o-i,_=e-s,d=t-i,p=l*l+h*h,m=l*c+h*u,g=c*c+u*u,f=_*l+d*h,S=_*c+d*u,C=p*g-m*m,y=(g*f-m*S)/C,G=(p*S-m*f)/C,I=1-y-G;return[I,y,G]},C33.triangleBarycentricToCartesian3d=function(e,t,s,i,n,r,a,o,l,h,c,u){return[e*i+t*a+s*h,e*n+t*o+s*c,e*r+t*l+s*u]}}{let C33=self.C3,mainDocument=null,baseHref="";if("undefined"!=typeof document){const a=(mainDocument=document).querySelector("base");(baseHref=a&&a.hasAttribute("href")?a.getAttribute("href"):"")&&!(baseHref=baseHref.startsWith("/")?baseHref.substr(1):baseHref).endsWith("/")&&(baseHref+="/")}C33.GetBaseHref=function(){return baseHref},C33.GetBaseURL=function(){if(!mainDocument)return"";const e=mainDocument.location;return C33.GetPathFromURL(e.origin+e.pathname)+baseHref},C33.GetPathFromURL=function(e){if(!e.length)return e;if(e.endsWith("/")||e.endsWith("\\"))return e;const t=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));return-1===t?"":e.substr(0,t+1)},C33.GetFilenameFromURL=function(e){if(!e.length)return e;if(e.endsWith("/")||e.endsWith("\\"))return"";const t=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));return-1===t?e:e.substr(t+1)},C33.GetFileExtension=function(e){let t=e.lastIndexOf(".");return t<1?"":e.substr(t)},C33.SetFileExtension=function(e,t){const s=e.lastIndexOf(".");return-1===s?e+"."+t:e.substr(0,s+1)+t},C33.GetFileNamePart=function(e){let t=e.lastIndexOf(".");return t<1?e:e.substr(0,t)},C33.NormalizeFileSeparator=function(e){return e.replace(/\\/g,"/")},C33.IsFileExtension=function(e,t){const s=e?C33.GetFileExtension(e).slice(1):"";return t===s},C33.FileNameEquals=function(e,t){let s,i;return C33.IsFileLike(e)&&(s=C33.GetFileNamePart(e.name)),C33.IsString(e)&&(s=C33.GetFileNamePart(e)),C33.IsFileLike(t)&&(i=C33.GetFileNamePart(t.name)),C33.IsString(t)&&(i=C33.GetFileNamePart(t)),s===i},C33.ParseFilePath=function(e){e=C33.NormalizeFileSeparator(e);let t=/^\w\:\//.exec(e),s=(t?(t=t[0],"/"!==(e=e.slice(3))[0]&&(e="/"+e)):t="",(e=1<(e=e.replace(/\/{2,}/g,"/")).length&&"/"===e.slice(-1)?e.slice(0,-1):e).lastIndexOf("/")+1),i="",n=e,r,a="";0<s&&(i=e.slice(0,s),n=e.slice(s));const o=(r=n).lastIndexOf("."),l=(0<o&&(a=n.slice(o),r=n.slice(0,-a.length)),t+i+n);return{dir:i,base:n,name:r,root:t,ext:a,full:l}},C33.Wait=function(s,i){return new Promise((e,t)=>{self.setTimeout(e,s,i)})},C33.swallowException=function(e){try{e()}catch(e){C33.isDebug&&console.warn("Swallowed exception: ",e)}},C33.noop=function(){},C33.equalsNoCase=function(e,t){return"string"==typeof e&&"string"==typeof t&&(e===t||e.normalize().toLowerCase()===t.normalize().toLowerCase())},C33.equalsCase=function(e,t){return"string"==typeof e&&"string"==typeof t&&(e===t||e.normalize()===t.normalize())},C33.typedArraySet16=function(e,t,s){e[s++]=t[0],e[s++]=t[1],e[s++]=t[2],e[s++]=t[3],e[s++]=t[4],e[s++]=t[5],e[s++]=t[6],e[s++]=t[7],e[s++]=t[8],e[s++]=t[9],e[s++]=t[10],e[s++]=t[11],e[s++]=t[12],e[s++]=t[13],e[s++]=t[14],e[s]=t[15]},C33.truncateArray=function(e,t){e.length=t},C33.clearArray=function(e){e&&0!==e.length&&C33.truncateArray(e,0)},C33.clear2DArray=function(s){if(s){for(let t=0;t<s.length;t++){let e=s[t];C33.truncateArray(e,0)}C33.truncateArray(s,0)}},C33.extendArray=function(t,s,i){const n=t.length;if(!((s|=0)<=n))for(let e=n;e<s;++e)t.push(i)},C33.resizeArray=function(e,t,s){const i=e.length;(t|=0)<i?C33.truncateArray(e,t):i<t&&C33.extendArray(e,t,s)},C33.shallowAssignArray=function(e,t){C33.clearArray(e),C33.appendArray(e,t)},C33.appendArray=function(s,i){if(i.length<1e4)s.push(...i);else for(let e=0,t=i.length;e<t;++e)s.push(i[e])},C33.arrayRemove=function(s,i){if(!((i=Math.floor(i))<0||i>=s.length)){let t=s.length-1;for(let e=i;e<t;++e)s[e]=s[e+1];C33.truncateArray(s,t)}},C33.arrayFindRemove=function(e,t){let s=e.indexOf(t);0<=s&&e.splice(s,1)},C33.arraysEqual=function(t,s){let i=t.length;if(s.length!==i)return!1;for(let e=0;e<i;++e)if(t[e]!==s[e])return!1;return!0},C33.arrayFilterOut=function(s,i){let n=[],r=0;for(let t=0,e=s.length;t<e;++t){let e=s[t];i(e)?n.push(e):(s[r]=e,++r)}return C33.truncateArray(s,r),n},C33.arrayRemoveAllInSet=function(s,i){let e=s.length,n=0;for(let t=0,e=s.length;t<e;++t){let e=s[t];i.has(e)||(s[n++]=e)}return C33.truncateArray(s,n),e-n},C33.isArrayIndexInBounds=function(e,t){return e===Math.floor(e)&&0<=e&&e<t.length},C33.validateArrayIndex=function(e,t){if(!C33.isArrayIndexInBounds(e,t))throw new RangeError("array index out of bounds")},C33.cloneArray=function(e){return e.slice()},C33.deepCloneArray=function(e,s){let i=[];for(let t of e)if(C33.IsObject(t)){let e=s(t);if(!e)throw new Error("missing clone");if(e.constructor!==t.constructor)throw new Error("object is not a clone");i.push(e)}else C33.IsArray(t)?i.push(C33.deepCloneArray(t,s)):i.push(t);return i},C33.clone2DArray=function(t){let s=[];for(let e of t)s.push(e.slice());return s},C33.splitStringAndNormalize=function(e,t=" "){return e?e.split(t).map(e=>e.trim()).filter(e=>!!e):[]},C33.filterSet=function(e,t,s){const i=new Set;for(const n of e.values())t(n)&&(s?i.add(s(n)):i.add(n));return i},C33.mergeSets=function(e,t){return e.union?e.union(t):new Set([...e,...t])},C33.mergeSetsInPlace=function(e,t){for(const s of t)e.add(s);return e},C33.first=function(t){for(let e of t)return e;return null},C33.xor=function(e,t){return!e!=!t},C33.compare=function(e,t,s){switch(t){case 0:return e===s;case 1:return e!==s;case 2:return e<s;case 3:return e<=s;case 4:return s<e;case 5:return s<=e;default:return!1}},C33.hasAnyOwnProperty=function(t){for(let e in t)if(t.hasOwnProperty(e))return!0;return!1},C33.PromiseAllWithProgress=function(o,l){return o.length?new Promise((s,i)=>{let n=[],r=0,a=!1;for(let t=0,e=o.length;t<e;++t)n.push(void 0),o[t].then(e=>{a||(n[t]=e,++r===o.length?s(n):l(r,o.length))}).catch(e=>{a=!0,i(e)})}):Promise.resolve([])};let memoryCallbacks=[],nextTaskId=(C33.AddLibraryMemoryCallback=function(e){memoryCallbacks.push(e)},C33.GetEstimatedLibraryMemoryUsage=function(){let s=0;for(let t of memoryCallbacks){let e=t();s+=e}return Math.floor(s)},1),activeTaskIds=new Map,taskMessageChannel=new MessageChannel,activeRPAFids=(taskMessageChannel.port2.onmessage=function(e){const t=e.data,s=activeTaskIds.get(t);activeTaskIds.delete(t),s&&s(performance.now())},C33.RequestUnlimitedAnimationFrame=function(e){const t=nextTaskId++;return activeTaskIds.set(t,e),taskMessageChannel.port1.postMessage(t),t},C33.CancelUnlimitedAnimationFrame=function(e){activeTaskIds.delete(e)},C33.PostTask=C33.RequestUnlimitedAnimationFrame,C33.WaitForNextTask=function(){return new Promise(e=>C33.PostTask(e))},new Set);C33.RequestPostAnimationFrame=function(t){const s=self.requestAnimationFrame(async e=>{await C33.WaitForNextTask(),activeRPAFids.has(s)&&(activeRPAFids.delete(s),t(e))});return activeRPAFids.add(s),s},C33.CancelPostAnimationFrame=function(e){activeRPAFids.has(e)&&(self.cancelAnimationFrame(e),activeRPAFids.delete(e))}}{const C33=self.C3;C33.IsAbsoluteURL=function(e){return/^(?:[a-z\-]+:)?\/\//.test(e)||"data:"===e.substr(0,5)||"blob:"===e.substr(0,5)},C33.IsRelativeURL=function(e){return!C33.IsAbsoluteURL(e)},C33.ThrowIfNotOk=function(e){if(!e.ok)throw new Error(`fetch '${e.url}' response returned ${e.status} `+e.statusText)},C33.FetchOk=function(e,t){return fetch(e,t).then(e=>(C33.ThrowIfNotOk(e),e))},C33.FetchText=function(e){return C33.FetchOk(e).then(e=>e.text())},C33.FetchJson=function(e){return C33.FetchOk(e).then(e=>e.json())},C33.FetchBlob=function(e){return C33.FetchOk(e).then(e=>e.blob())},C33.FetchArrayBuffer=function(e){return C33.FetchOk(e).then(e=>e.arrayBuffer())},C33.FetchImage=function(i){return new Promise((e,t)=>{const s=new Image;s.onload=()=>e(s),s.onerror=e=>t(e),s.src=i})},C33.BlobToArrayBuffer=function(i){return"function"==typeof i.arrayBuffer?i.arrayBuffer():new Promise((e,t)=>{const s=new FileReader;s.onload=()=>e(s.result),s.onerror=()=>t(s.error),s.readAsArrayBuffer(i)})},C33.BlobToString=function(i){return"function"==typeof i.text?i.text():new Promise((e,t)=>{const s=new FileReader;s.onload=()=>e(s.result),s.onerror=()=>t(s.error),s.readAsText(i)})},C33.BlobToJson=function(e){return C33.BlobToString(e).then(e=>JSON.parse(e))},C33.BlobToImage=async function(e,t){let s=URL.createObjectURL(e);try{const i=await C33.FetchImage(s);return URL.revokeObjectURL(s),s="",t&&"function"==typeof i.decode&&await i.decode(),i}finally{s&&URL.revokeObjectURL(s)}},C33.CreateCanvas=function(e,t){if("undefined"==typeof document||"function"!=typeof document.createElement)return new OffscreenCanvas(e,t);{const s=document.createElement("canvas");return s.width=e,s.height=t,s}},C33.CanvasToBlob=function(t,s,i){if("number"!=typeof i&&(i=1),s=s||"image/png",i=C33.clamp(i,0,1),t.convertToBlob)return t.convertToBlob({type:s,quality:i});if(t.toBlob)return new Promise(e=>t.toBlob(e,s,i));throw new Error("could not convert canvas to blob")},C33.DrawableToBlob=function(e,t,s){const i=C33.CreateCanvas(e.width,e.height),n=i.getContext("2d");return n.drawImage(e,0,0),C33.CanvasToBlob(i,t,s)},C33.ImageDataToBlob=function(e,t,s){if(C33.Supports.ImageBitmapOptions)return createImageBitmap(e,{premultiplyAlpha:"none"}).then(e=>C33.DrawableToBlob(e,t,s));if(C33.Supports.ImageBitmap)return createImageBitmap(e).then(e=>C33.DrawableToBlob(e,t,s));{const i=C33.CreateCanvas(e.width,e.height),n=i.getContext("2d");return n.putImageData(e,0,0),C33.CanvasToBlob(i,t,s)}},C33.CopySet=function(e,t){e.clear();for(const s of t)e.add(s)},C33.MapToObject=function(e){const t=Object.create(null);for(const[s,i]of e.entries())t[s]=i;return t},C33.ObjectToMap=function(e,t){t.clear();for(const[s,i]of Object.entries(e))t.set(s,i)},C33.ToSuperJSON=function t(e){if("object"!=typeof e||null===e)return e;if(e instanceof Set)return{_c3type_:"set",data:[...e].map(e=>t(e))};if(e instanceof Map)return{_c3type_:"map",data:[...e].map(e=>[e[0],t(e[1])])};{const s=Object.create(null);for(const[i,n]of Object.entries(e))s[i]=t(n);return s}},C33.FromSuperJSON=function t(e){if("object"==typeof e&null!==e){if("set"===e._c3type_)return new Set(e.data.map(e=>t(e)));if("map"===e._c3type_)return new Map(e.data.map(e=>[e[0],t(e[1])]));{const s=Object.create(null);for(const[i,n]of Object.entries(e))s[i]=t(n);return s}}return e},C33.CSSToCamelCase=function(e){if(e.startsWith("--"))return e;let t="",s=!1,i=0;for(const n of e)"-"===n?0<i&&(s=!0):s?(t+=n.toUpperCase(),s=!1):t+=n,++i;return t},C33.IsIterator=function(e){return"object"==typeof e&&"function"==typeof e.next},C33.MakeFilledArray=function(t,s){const i=[];if("function"==typeof s)for(let e=0;e<t;++e)i.push(s());else for(let e=0;e<t;++e)i.push(s);return i}}{let padTwoDigits2=function(e){return 0===e.length?"00":1===e.length?"0"+e:e},hueToRGB2=function(e,t,s){return s<0&&(s+=1),1<s&&--s,s<1/6?e+6*(t-e)*s:s<.5?t:s<2/3?e+(t-e)*(2/3-s)*6:e};padTwoDigits=padTwoDigits2,hueToRGB=hueToRGB2;const C33=self.C3,HSL_TEST=/([0-9.]+),([0-9.]+)\%?,([0-9.]+)\%?/i,HSLA_TEST=/([0-9.]+),([0-9.]+)\%?,([0-9.]+)\%?,([0-9.])/i;C33.Color=class{constructor(e,t,s,i){this._r=NaN,this._g=NaN,this._b=NaN,this._a=NaN,this._r=0,this._g=0,this._b=0,this._a=0,e instanceof C33.Color?this.set(e):this.setRgba(e||0,t||0,s||0,i||0)}setRgb(e,t,s){return this._r=+e,this._g=+t,this._b=+s,this.clamp(),this}setRgba(e,t,s,i){return this._r=+e,this._g=+t,this._b=+s,this._a=+i,this.clamp(),this}set(e){return this._r=e._r,this._g=e._g,this._b=e._b,this._a=e._a,this}copy(e){return this.set(e)}add(e){this._r+=e._r,this._g+=e._g,this._b+=e._b,this._a+=e._a,this.clamp()}addRgb(e,t,s,i=0){this._r+=+e,this._g+=+t,this._b+=+s,this._a+=+i,this.clamp()}diff(e){this.setR(Math.max(this._r,e._r)-Math.min(this._r,e._r)),this.setG(Math.max(this._g,e._g)-Math.min(this._g,e._g)),this.setB(Math.max(this._b,e._b)-Math.min(this._b,e._b)),this.setA(Math.max(this._a,e._a)-Math.min(this._a,e._a)),this.clamp()}copyRgb(e){this._r=e._r,this._g=e._g,this._b=e._b}setR(e){this._r=C33.clamp(+e,0,1)}getR(){return this._r}setG(e){this._g=C33.clamp(+e,0,1)}getG(){return this._g}setB(e){this._b=C33.clamp(+e,0,1)}getB(){return this._b}setA(e){this._a=C33.clamp(+e,0,1)}getA(){return this._a}clone(){return C33.New(C33.Color,this._r,this._g,this._b,this._a)}toArray(){return[this._r,this._g,this._b,this._a]}toTypedArray(){return new Float64Array(this.toArray())}writeToTypedArray(e,t){e[t++]=this._r,e[t++]=this._g,e[t++]=this._b,e[t]=this._a}writeRGBToTypedArray(e,t){e[t++]=this._r,e[t++]=this._g,e[t]=this._b}equals(e){return this._r===e._r&&this._g===e._g&&this._b===e._b&&this._a===e._a}equalsIgnoringAlpha(e){return this._r===e._r&&this._g===e._g&&this._b===e._b}equalsRgb(e,t,s){return this._r===e&&this._g===t&&this._b===s}equalsRgba(e,t,s,i){return this._r===e&&this._g===t&&this._b===s&&this._a===i}equalsF32Array(e,t){return e[t]===Math.fround(this._r)&&e[t+1]===Math.fround(this._g)&&e[t+2]===Math.fround(this._b)&&e[t+3]===Math.fround(this._a)}equalsRGBF32Array(e,t){return e[t]===Math.fround(this._r)&&e[t+1]===Math.fround(this._g)&&e[t+2]===Math.fround(this._b)}multiply(e){this._r*=e._r,this._g*=e._g,this._b*=e._b,this._a*=e._a}multiplyAlpha(e){this._r*=e,this._g*=e,this._b*=e,this._a*=e}premultiply(){return this._r*=this._a,this._g*=this._a,this._b*=this._a,this}unpremultiply(){return this._r/=this._a,this._g/=this._a,this._b/=this._a,this}clamp(){return this._r=C33.clamp(this._r,0,1),this._g=C33.clamp(this._g,0,1),this._b=C33.clamp(this._b,0,1),this._a=C33.clamp(this._a,0,1),this}setFromRgbValue(e){this._r=C33.GetRValue(e),this._g=C33.GetGValue(e),this._b=C33.GetBValue(e),this._a=C33.GetAValue(e)}getCssRgb(e,t,s){const i=C33.IsFiniteNumber(e)?e:this.getR(),n=C33.IsFiniteNumber(t)?t:this.getG(),r=C33.IsFiniteNumber(s)?s:this.getB();return`rgb(${100*i}%, ${100*n}%, ${100*r}%)`}getCssRgba(e,t,s,i){const n=C33.IsFiniteNumber(e)?e:this.getR(),r=C33.IsFiniteNumber(t)?t:this.getG(),a=C33.IsFiniteNumber(s)?s:this.getB(),o=C33.IsFiniteNumber(i)?i:this.getA();return`rgba(${100*n}%, ${100*r}%, ${100*a}%, ${o})`}toHexString(){const e=Math.round(255*this.getR()),t=Math.round(255*this.getG()),s=Math.round(255*this.getB());return"#"+padTwoDigits2(e.toString(16))+padTwoDigits2(t.toString(16))+padTwoDigits2(s.toString(16))}parseHexString(e){if("string"!=typeof e)return!1;let t,s,i;if(3===(e="#"===(e=e.trim()).charAt(0)?e.substr(1):e).length)t=parseInt(e[0],16)/15,s=parseInt(e[1],16)/15,i=parseInt(e[2],16)/15;else{if(6!==e.length)return!1;t=parseInt(e.substr(0,2),16)/255,s=parseInt(e.substr(2,2),16)/255,i=parseInt(e.substr(4,2),16)/255}return isFinite(t)&&this.setR(t),isFinite(s)&&this.setG(s),isFinite(i)&&this.setB(i),this.setA(1),!0}toCommaSeparatedRgb(){const e=Math.round(255*this.getR()),t=Math.round(255*this.getG()),s=Math.round(255*this.getB());return e+`, ${t}, `+s}toRgbArray(){const e=Math.round(255*this.getR()),t=Math.round(255*this.getG()),s=Math.round(255*this.getB());return[e,t,s]}parseCommaSeparatedRgb(e){if("string"!=typeof e)return!1;const t=(e=e.replace(/^rgb\(|\)|%/,"")).split(",");if(t.length<3)return!1;const s=parseInt(t[0].trim(),10)/255,i=parseInt(t[1].trim(),10)/255,n=parseInt(t[2].trim(),10)/255;return isFinite(s)&&this.setR(s),isFinite(i)&&this.setG(i),isFinite(n)&&this.setB(n),this.setA(1),!0}parseCommaSeparatedPercentageRgb(e){if("string"!=typeof e)return!1;const t=(e=e.replace(/^rgb\(|\)|%/,"")).split(",");if(t.length<3)return!1;const s=parseInt(t[0].trim(),10)/100,i=parseInt(t[1].trim(),10)/100,n=parseInt(t[2].trim(),10)/100;return isFinite(s)&&this.setR(s),isFinite(i)&&this.setG(i),isFinite(n)&&this.setB(n),this.setA(1),!0}parseCommaSeparatedRgba(e){if("string"!=typeof e)return!1;const t=(e=e.replace(/^rgba\(|\)|%/,"")).split(",");if(t.length<4)return!1;const s=parseInt(t[0].trim(),10)/255,i=parseInt(t[1].trim(),10)/255,n=parseInt(t[2].trim(),10)/255,r=parseFloat(t[3].trim());return isFinite(s)&&this.setR(s),isFinite(i)&&this.setG(i),isFinite(n)&&this.setB(n),isFinite(r)&&this.setA(r),!0}parseCommaSeparatedPercentageRgba(e){if("string"!=typeof e)return!1;const t=(e=e.replace(/^rgba\(|\)|%/,"")).split(",");if(t.length<4)return!1;const s=parseInt(t[0].trim(),10)/100,i=parseInt(t[1].trim(),10)/100,n=parseInt(t[2].trim(),10)/100,r=parseFloat(t[3].trim());return isFinite(s)&&this.setR(s),isFinite(i)&&this.setG(i),isFinite(n)&&this.setB(n),isFinite(r)&&this.setA(r),!0}parseString(e){if("string"!=typeof e)return!1;if((e=e.replace(/\s+/,"")).includes(",")){if(e.startsWith("rgb("))return e.includes("%")?this.parseCommaSeparatedPercentageRgb(e):this.parseCommaSeparatedRgb(e);if(e.startsWith("rgba("))return e.includes("%")?this.parseCommaSeparatedPercentageRgba(e):this.parseCommaSeparatedRgba(e);if(e.startsWith("hsl(")||e.startsWith("hsla("))return this.parseHSLString(e);{const t=e.split(",");return e.includes("%")?3===t.length?this.parseCommaSeparatedPercentageRgb(e):4===t.length&&this.parseCommaSeparatedPercentageRgba(e):3===t.length?this.parseCommaSeparatedRgb(e):4===t.length&&this.parseCommaSeparatedRgba(e)}}return this.parseHexString(e)}toJSON(){return[this._r,this._g,this._b,this._a]}setFromHSLA(e,t,s,i){let n,r,a;if(e%=360,t=C33.clamp(t,0,100),s=C33.clamp(s,0,100),i=C33.clamp(i,0,1),e/=360,s/=100,0==(t/=100))n=r=a=s;else{const o=s<.5?s*(1+t):s+t-s*t,l=2*s-o;n=hueToRGB2(l,o,e+1/3),r=hueToRGB2(l,o,e),a=hueToRGB2(l,o,e-1/3)}return this.setR(n),this.setG(r),this.setB(a),this.setA(i),this}parseHSLString(e){const t=e.replace(/ |hsl|hsla|\(|\)|;/gi,""),s=HSL_TEST.exec(t),i=HSLA_TEST.exec(t);return s&&4===s.length?(this.setFromHSLA(+s[1],+s[2],+s[3],1),!0):!(!i||5!==i.length||(this.setFromHSLA(+s[1],+s[2],+s[3],+s[4]),0))}toHSLAString(){const e=this._r,t=this._g,s=this._b,i=this._a,n=C33.Color.GetHue(e,t,s),r=C33.Color.GetSaturation(e,t,s),a=C33.Color.GetLuminosity(e,t,s);return`hsla(${n}, ${r}%, ${a}%, ${i})`}toHSLAArray(){const e=this._r,t=this._g,s=this._b;return[C33.Color.GetHue(e,t,s),C33.Color.GetSaturation(e,t,s),C33.Color.GetLuminosity(e,t,s),this._a]}setFromJSON(e){!Array.isArray(e)||e.length<3||(this._r=e[0],this._g=e[1],this._b=e[2],this._a=4<=e.length?e[3]:1)}set r(e){this.setR(e)}get r(){return this.getR()}set g(e){this.setG(e)}get g(){return this.getG()}set b(e){this.setB(e)}get b(){return this.getB()}set a(e){this.setA(e)}get a(){return this.getA()}setAtIndex(e,t){switch(e){case 0:this.setR(t);break;case 1:this.setG(t);break;case 2:this.setB(t);break;case 3:this.setA(t);break;default:throw new RangeError("invalid color index")}}getAtIndex(e){switch(e){case 0:return this.getR();case 1:return this.getG();case 2:return this.getB();case 3:return this.getA();default:throw new RangeError("invalid color index")}}static Equals(e,t){let s,i;if(Array.isArray(e))(s=new C33.Color).setFromJSON(e);else{if(!(e instanceof C33.Color))throw new Error("unexpected type");s=e}if(Array.isArray(t))(i=new C33.Color).setFromJSON(t);else{if(!(t instanceof C33.Color))throw new Error("unexpected type");i=t}return s.equals(i)}static DiffChannel(e,t){return C33.clamp(Math.max(e,t)-Math.min(e,t),0,1)}static Diff(e,t){const s=new C33.Color;return s.setR(Math.max(e._r,t._r)-Math.min(e._r,t._r)),s.setG(Math.max(e._g,t._g)-Math.min(e._g,t._g)),s.setB(Math.max(e._b,t._b)-Math.min(e._b,t._b)),s.setA(Math.max(e._a,t._a)-Math.min(e._a,t._a)),s}static DiffNoAlpha(e,t){const s=new C33.Color(0,0,0,1);return s.setR(Math.max(e._r,t._r)-Math.min(e._r,t._r)),s.setG(Math.max(e._g,t._g)-Math.min(e._g,t._g)),s.setB(Math.max(e._b,t._b)-Math.min(e._b,t._b)),s}static GetHue(e,t,s){const i=Math.max(e,t,s),n=Math.min(e,t,s);if(i===n)return 0;let r=0;switch(i){case e:r=(t-s)/(i-n)+(t<s?6:0);break;case t:r=(s-e)/(i-n)+2;break;case s:r=(e-t)/(i-n)+4}return Math.round(r/6*360)}static GetSaturation(e,t,s){const i=Math.max(e,t,s),n=Math.min(e,t,s);if(i===n)return 0;const r=(i+n)/2,a=i-n,o=.5<r?a/(2-i-n):a/(i+n);return Math.round(100*o)}static GetLuminosity(e,t,s){const i=Math.max(e,t,s),n=Math.min(e,t,s),r=(i+n)/2;return i?Math.round(100*r):0}},C33.Color.White=Object.freeze(C33.New(C33.Color,1,1,1,1)),C33.Color.Black=Object.freeze(C33.New(C33.Color,0,0,0,1)),C33.Color.TransparentBlack=Object.freeze(C33.New(C33.Color,0,0,0,0))}{const C33=self.C3;C33.Vector2=class{constructor(e,t){this._x=0,this._y=0,e instanceof C33.Vector2?this.copy(e):this.set(e||0,t||0)}set(e,t){this._x=+e,this._y=+t}copy(e){this._x=e._x,this._y=e._y}equals(e){return this._x===e._x&&this._y===e._y}equalsValues(e,t){return this._x===e&&this._y===t}equalsF32Array(e,t){return e[t]===Math.fround(this._x)&&e[t+1]===Math.fround(this._y)}setX(e){this._x=+e}getX(){return this._x}setY(e){this._y=+e}getY(){return this._y}toArray(){return[this._x,this._y]}toTypedArray(){return new Float64Array(this.toArray())}writeToTypedArray(e,t){e[t++]=this._x,e[t]=this._y}offset(e,t){this._x+=+e,this._y+=+t}scale(e,t){this._x*=e,this._y*=t}divide(e,t){this._x/=e,this._y/=t}round(){this._x=Math.round(this._x),this._y=Math.round(this._y)}floor(){this._x=Math.floor(this._x),this._y=Math.floor(this._y)}ceil(){this._x=Math.ceil(this._x),this._y=Math.ceil(this._y)}angle(){return C33.angleTo(0,0,this._x,this._y)}lengthSquared(){return this._x*this._x+this._y*this._y}length(){return C33.hypot2DFast(this._x,this._y)}rotatePrecalc(e,t){const s=this._x*t-this._y*e;this._y=this._y*t+this._x*e,this._x=s}rotate(e){0!==e&&this.rotatePrecalc(Math.sin(e),Math.cos(e))}rotateAbout(e,t,s){0===e||t===this._x&&s===this._y||(this._x-=t,this._y-=s,this.rotatePrecalc(Math.sin(e),Math.cos(e)),this._x+=+t,this._y+=+s)}move(e,t){0!==t&&(this._x+=Math.cos(e)*t,this._y+=Math.sin(e)*t)}normalize(){const e=this.length();0!==e&&1!==e&&(this._x/=e,this._y/=e)}clamp(e,t){this._x=C33.clamp(this._x,e,t),this._y=C33.clamp(this._y,e,t)}dot(e){return this._x*e._x+this._y*e._y}reverse(){this._x=-this._x,this._y=-this._y}perp(){let e=this._x;return this._x=this._y,this._y=-e,this}}}{const C33=self.C3;C33.Rect=class{constructor(e,t,s,i){this._left=NaN,this._top=NaN,this._right=NaN,this._bottom=NaN,this._left=0,this._top=0,this._right=0,this._bottom=0,e instanceof C33.Rect?this.copy(e):this.set(e||0,t||0,s||0,i||0)}set(e,t,s,i){this._left=+e,this._top=+t,this._right=+s,this._bottom=+i}setWH(e,t,s,i){t=+t,this._left=e=+e,this._top=t,this._right=e+ +s,this._bottom=t+ +i}copy(e){this._left=+e._left,this._top=+e._top,this._right=+e._right,this._bottom=+e._bottom}clone(){return new C33.Rect(this._left,this._top,this._right,this._bottom)}static Merge(e,t){const s=new C33.Rect;return s.setLeft(Math.min(e._left,t._left)),s.setTop(Math.min(e._top,t._top)),s.setRight(Math.max(e._right,t._right)),s.setBottom(Math.max(e._bottom,t._bottom)),s}static FromObject(e){return new C33.Rect(e.left,e.top,e.right,e.bottom)}equals(e){return this._left===e._left&&this._top===e._top&&this._right===e._right&&this._bottom===e._bottom}equalsWH(e,t,s,i){return this._left===e&&this._top===t&&this.width()===s&&this.height()===i}equalsF32Array(e,t){return e[t]===Math.fround(this._left)&&e[t+1]===Math.fround(this._top)&&e[t+2]===Math.fround(this._right)&&e[t+3]===Math.fround(this._bottom)}setLeft(e){this._left=+e}getLeft(){return this._left}setTop(e){this._top=+e}getTop(){return this._top}setRight(e){this._right=+e}getRight(){return this._right}setBottom(e){this._bottom=+e}getBottom(){return this._bottom}toArray(){return[this._left,this._top,this._right,this._bottom]}toTypedArray(){return new Float64Array(this.toArray())}toDOMRect(){return new DOMRect(this._left,this._top,this.width(),this.height())}static fromDOMRect(e){return C33.New(C33.Rect,e.left,e.top,e.right,e.bottom)}writeToTypedArray(e,t){e[t++]=this._left,e[t++]=this._top,e[t++]=this._right,e[t]=this._bottom}writeAsQuadToTypedArray(e,t){e[t++]=this._left,e[t++]=this._top,e[t++]=this._right,e[t++]=this._top,e[t++]=this._right,e[t++]=this._bottom,e[t++]=this._left,e[t]=this._bottom}writeAsQuadToTypedArray3D(e,t,s){e[t++]=this._left,e[t++]=this._top,e[t++]=s,e[t++]=this._right,e[t++]=this._top,e[t++]=s,e[t++]=this._right,e[t++]=this._bottom,e[t++]=s,e[t++]=this._left,e[t++]=this._bottom,e[t]=s}width(){return this._right-this._left}height(){return this._bottom-this._top}midX(){return(this._left+this._right)/2}midY(){return(this._top+this._bottom)/2}offset(e,t){t=+t,this._left+=e=+e,this._top+=t,this._right+=e,this._bottom+=t}offsetLeft(e){this._left+=+e}offsetTop(e){this._top+=+e}offsetRight(e){this._right+=+e}offsetBottom(e){this._bottom+=+e}toSquare(e){if("x"!==e)throw new Error("invalid axis, only 'x' supported");this._top<this._bottom?this._left<this._right?this._bottom=this._top+this.width():this._bottom=this._top-this.width():this._left<this._right?this._bottom=this._top-this.width():this._bottom=this._top+this.width()}inflate(e,t){t=+t,this._left-=e=+e,this._top-=t,this._right+=e,this._bottom+=t}deflate(e,t){t=+t,this._left+=e=+e,this._top+=t,this._right-=e,this._bottom-=t}multiply(e,t){this._left*=e,this._top*=t,this._right*=e,this._bottom*=t}divide(e,t){this._left/=e,this._top/=t,this._right/=e,this._bottom/=t}mirrorAround(e){this._left=+e-this._left,this._right=+e-this._right}flipAround(e){this._top=+e-this._top,this._bottom=+e-this._bottom}rotate90DegreesAround(e,t){const s=this.width(),i=this.height(),n=this.getLeft()+s*e,r=this.getTop()+i*t;this.setWH(n-i*t,r-s*e,i,s)}swapLeftRight(){const e=this._left;this._left=this._right,this._right=e}swapTopBottom(){const e=this._top;this._top=this._bottom,this._bottom=e}shuntY(e){const t=this._top;this._top=+e-this._bottom,this._bottom=+e-t}round(){this._left=Math.round(this._left),this._top=Math.round(this._top),this._right=Math.round(this._right),this._bottom=Math.round(this._bottom)}roundInner(){this._left=Math.ceil(this._left),this._top=Math.ceil(this._top),this._right=Math.floor(this._right),this._bottom=Math.floor(this._bottom)}roundOuter(){this._left=Math.floor(this._left),this._top=Math.floor(this._top),this._right=Math.ceil(this._right),this._bottom=Math.ceil(this._bottom)}floor(){this._left=Math.floor(this._left),this._top=Math.floor(this._top),this._right=Math.floor(this._right),this._bottom=Math.floor(this._bottom)}ceil(){this._left=Math.ceil(this._left),this._top=Math.ceil(this._top),this._right=Math.ceil(this._right),this._bottom=Math.ceil(this._bottom)}clamp(e,t,s,i){this._left=Math.max(this._left,+e),this._top=Math.max(this._top,+t),this._right=Math.min(this._right,+s),this._bottom=Math.min(this._bottom,+i)}clampBoth(e,t,s,i){e=+e,t=+t,s=+s,i=+i,this._left=C33.clamp(this._left,e,s),this._top=C33.clamp(this._top,t,i),this._right=C33.clamp(this._right,e,s),this._bottom=C33.clamp(this._bottom,t,i)}normalize(){this._left>this._right&&this.swapLeftRight(),this._top>this._bottom&&this.swapTopBottom()}intersectsRect(e){return!(e._right<this._left||e._bottom<this._top||e._left>this._right||e._top>this._bottom)}intersectsRectOffset(e,t,s){return!(e._right+t<this._left||e._bottom+s<this._top||e._left+t>this._right||e._top+s>this._bottom)}containsPoint(e,t){return e>=this._left&&e<=this._right&&t>=this._top&&t<=this._bottom}containsRect(e){return e._left>=this._left&&e._top>=this._top&&e._right<=this._right&&e._bottom<=this._bottom}expandToContain(e){e._left<this._left&&(this._left=+e._left),e._top<this._top&&(this._top=+e._top),e._right>this._right&&(this._right=+e._right),e._bottom>this._bottom&&(this._bottom=+e._bottom)}lerpInto(e){this._left=C33.lerp(e._left,e._right,this._left),this._top=C33.lerp(e._top,e._bottom,this._top),this._right=C33.lerp(e._left,e._right,this._right),this._bottom=C33.lerp(e._top,e._bottom,this._bottom)}}}{const C33=self.C3;C33.Quad=class{constructor(e,t,s,i,n,r,a,o){this._tlx=NaN,this._tly=NaN,this._trx=NaN,this._try=NaN,this._brx=NaN,this._bry=NaN,this._blx=NaN,this._bly=NaN,this._tlx=0,this._tly=0,this._trx=0,this._try=0,this._brx=0,this._bry=0,this._blx=0,this._bly=0,e instanceof C33.Quad?this.copy(e):this.set(e||0,t||0,s||0,i||0,n||0,r||0,a||0,o||0)}set(e,t,s,i,n,r,a,o){this._tlx=+e,this._tly=+t,this._trx=+s,this._try=+i,this._brx=+n,this._bry=+r,this._blx=+a,this._bly=+o}setRect(e,t,s,i){this.set(e,t,s,t,s,i,e,i)}copy(e){this._tlx=e._tlx,this._tly=e._tly,this._trx=e._trx,this._try=e._try,this._brx=e._brx,this._bry=e._bry,this._blx=e._blx,this._bly=e._bly}equals(e){return this._tlx===e._tlx&&this._tly===e._tly&&this._trx===e._trx&&this._try===e._try&&this._brx===e._brx&&this._bry===e._bry&&this._blx===e._blx&&this._bly===e._bly}setTlx(e){this._tlx=+e}getTlx(){return this._tlx}setTly(e){this._tly=+e}getTly(){return this._tly}setTrx(e){this._trx=+e}getTrx(){return this._trx}setTry(e){this._try=+e}getTry(){return this._try}setBrx(e){this._brx=+e}getBrx(){return this._brx}setBry(e){this._bry=+e}getBry(){return this._bry}setBlx(e){this._blx=+e}getBlx(){return this._blx}setBly(e){this._bly=+e}getBly(){return this._bly}toDOMQuad(){return new DOMQuad(new DOMPoint(this._tlx,this._tly),new DOMPoint(this._trx,this._try),new DOMPoint(this._brx,this._bry),new DOMPoint(this._blx,this._bly))}static fromDOMQuad(e){return C33.New(C33.Quad,e.p1.x,e.p1.y,e.p2.x,e.p2.y,e.p3.x,e.p3.y,e.p4.x,e.p4.y)}toArray(){return[this._tlx,this._tly,this._trx,this._try,this._brx,this._bry,this._blx,this._bly]}toTypedArray(){return new Float64Array(this.toArray())}writeToTypedArray(e,t){e[t++]=this._tlx,e[t++]=this._tly,e[t++]=this._trx,e[t++]=this._try,e[t++]=this._brx,e[t++]=this._bry,e[t++]=this._blx,e[t]=this._bly}writeToTypedArray3D(e,t,s){e[t++]=this._tlx,e[t++]=this._tly,e[t++]=s,e[t++]=this._trx,e[t++]=this._try,e[t++]=s,e[t++]=this._brx,e[t++]=this._bry,e[t++]=s,e[t++]=this._blx,e[t++]=this._bly,e[t]=s}offset(e,t){t=+t,this._tlx+=e=+e,this._tly+=t,this._trx+=e,this._try+=t,this._brx+=e,this._bry+=t,this._blx+=e,this._bly+=t}round(){this._tlx=Math.round(this._tlx),this._tly=Math.round(this._tly),this._trx=Math.round(this._trx),this._try=Math.round(this._try),this._brx=Math.round(this._brx),this._bry=Math.round(this._bry),this._blx=Math.round(this._blx),this._bly=Math.round(this._bly)}floor(){this._tlx=Math.floor(this._tlx),this._tly=Math.floor(this._tly),this._trx=Math.floor(this._trx),this._try=Math.floor(this._try),this._brx=Math.floor(this._brx),this._bry=Math.floor(this._bry),this._blx=Math.floor(this._blx),this._bly=Math.floor(this._bly)}ceil(){this._tlx=Math.ceil(this._tlx),this._tly=Math.ceil(this._tly),this._trx=Math.ceil(this._trx),this._try=Math.ceil(this._try),this._brx=Math.ceil(this._brx),this._bry=Math.ceil(this._bry),this._blx=Math.ceil(this._blx),this._bly=Math.ceil(this._bly)}setFromRect(e){this._tlx=e._left,this._tly=e._top,this._trx=e._right,this._try=e._top,this._brx=e._right,this._bry=e._bottom,this._blx=e._left,this._bly=e._bottom}setFromRotatedRect(e,t){0===t?this.setFromRect(e):this.setFromRotatedRectPrecalc(e,Math.sin(t),Math.cos(t))}setFromRotatedRectPrecalc(e,t,s){const i=e._left*t,n=e._top*t,r=e._right*t,a=e._bottom*t,o=e._left*s,l=e._top*s,h=e._right*s,c=e._bottom*s;this._tlx=o-n,this._tly=l+i,this._trx=h-n,this._try=l+r,this._brx=h-a,this._bry=c+r,this._blx=o-a,this._bly=c+i}getBoundingBox(e){e.set(Math.min(this._tlx,this._trx,this._brx,this._blx),Math.min(this._tly,this._try,this._bry,this._bly),Math.max(this._tlx,this._trx,this._brx,this._blx),Math.max(this._tly,this._try,this._bry,this._bly))}containsPoint(e,t){let s=this._trx-this._tlx,i=this._try-this._tly,n=this._brx-this._tlx,r=this._bry-this._tly,a=e-this._tlx,o=t-this._tly,l=s*s+i*i,h=s*n+i*r,c=s*a+i*o,u=n*n+r*r,_=n*a+r*o,d=1/(l*u-h*h),p=(u*c-h*_)*d,m=(l*_-h*c)*d;return 0<=p&&0<m&&p+m<1||(m=((l=(s=this._blx-this._tlx)*s+(i=this._bly-this._tly)*i)*_-(h=s*n+i*r)*(c=s*a+i*o))*(d=1/(l*u-h*h)),0<=(p=(u*c-h*_)*d)&&0<m&&p+m<1)}midX(){return(this._tlx+this._trx+this._brx+this._blx)/4}midY(){return(this._tly+this._try+this._bry+this._bly)/4}intersectsSegment(e,t,s,i){return!(!this.containsPoint(e,t)&&!this.containsPoint(s,i))||C33.segmentIntersectsQuad(e,t,s,i,this)}intersectsQuad(e){let t=e.midX(),s=e.midY();if(this.containsPoint(t,s))return!0;if(t=this.midX(),s=this.midY(),e.containsPoint(t,s))return!0;const i=this._tlx,n=this._tly,r=this._trx,a=this._try,o=this._brx,l=this._bry,h=this._blx,c=this._bly;return C33.segmentIntersectsQuad(i,n,r,a,e)||C33.segmentIntersectsQuad(r,a,o,l,e)||C33.segmentIntersectsQuad(o,l,h,c,e)||C33.segmentIntersectsQuad(h,c,i,n,e)}rotatePointsAnticlockwise(){const e=this._tlx,t=this._tly;this._tlx=this._trx,this._tly=this._try,this._trx=this._brx,this._try=this._bry,this._brx=this._blx,this._bry=this._bly,this._blx=e,this._bly=t}mirror(){this._swap(0,2),this._swap(1,3),this._swap(6,4),this._swap(7,5)}flip(){this._swap(0,6),this._swap(1,7),this._swap(2,4),this._swap(3,5)}diag(){this._swap(2,6),this._swap(3,7)}_swap(e,t){const s=this._getAtIndex(e);this._setAtIndex(e,this._getAtIndex(t)),this._setAtIndex(t,s)}_getAtIndex(e){switch(e){case 0:return this._tlx;case 1:return this._tly;case 2:return this._trx;case 3:return this._try;case 4:return this._brx;case 5:return this._bry;case 6:return this._blx;case 7:return this._bly;default:throw new RangeError("invalid quad point index")}}_setAtIndex(e,t){switch(t=+t,e){case 0:this._tlx=t;break;case 1:this._tly=t;break;case 2:this._trx=t;break;case 3:this._try=t;break;case 4:this._brx=t;break;case 5:this._bry=t;break;case 6:this._blx=t;break;case 7:this._bly=t;break;default:throw new RangeError("invalid quad point index")}}}}{const C33=self.C3,assert=self.assert,DEFAULT_POLY_POINTS=[0,0,1,0,1,1,0,1],tempQuad=C33.New(C33.Quad);C33.CollisionPoly=class extends C33.DefendedBase{constructor(e,t=!0){super(),e=e||DEFAULT_POLY_POINTS,this._ptsArr=Float64Array.from(e),this._bbox=new C33.Rect,this._isBboxChanged=!0,this._enabled=t}Release(){}pointsArr(){return this._ptsArr}pointCount(){return this._ptsArr.length/2}setPoints(e){this._ptsArr.length===e.length?this._ptsArr.set(e):this._ptsArr=Float64Array.from(e),this._isBboxChanged=!0}setDefaultPoints(){this.setPoints(DEFAULT_POLY_POINTS)}copy(e){this.setPoints(e._ptsArr)}setBboxChanged(){this._isBboxChanged=!0}_updateBbox(){if(this._isBboxChanged){let s=this._ptsArr,i=s[0],n=s[1],r=i,a=n;for(let e=0,t=s.length;e<t;e+=2){const o=s[e],l=s[e+1];o<i&&(i=o),o>r&&(r=o),l<n&&(n=l),l>a&&(a=l)}this._bbox.set(i,n,r,a),this._isBboxChanged=!1}}setFromRect(e,t,s){let i=this._ptsArr;8!==i.length&&(i=new Float64Array(8),this._ptsArr=i),i[0]=e.getLeft()-t,i[1]=e.getTop()-s,i[2]=e.getRight()-t,i[3]=e.getTop()-s,i[4]=e.getRight()-t,i[5]=e.getBottom()-s,i[6]=e.getLeft()-t,i[7]=e.getBottom()-s,this._bbox.copy(e),0===t&&0===s||this._bbox.offset(-t,-s),this._isBboxChanged=!1}setFromQuad(e,t,s){tempQuad.copy(e),tempQuad.offset(t,s),this.setPoints(tempQuad.toArray()),this._isBboxChanged=!0}transform(e,t,s){let i=0,n=1;0!==s&&(i=Math.sin(s),n=Math.cos(s)),this.transformPrecalc(e,t,i,n)}transformPrecalc(s,i,n,r){const a=this._ptsArr;for(let e=0,t=a.length;e<t;e+=2){const o=e+1,l=a[e]*s,h=a[o]*i;a[e]=l*r-h*n,a[o]=h*r+l*n}this._isBboxChanged=!0}offset(s,i){const n=this._ptsArr;for(let e=0,t=n.length;e<t;e+=2)n[e]+=s,n[e+1]+=i}containsPoint(s,i){const n=this._ptsArr;if(s===n[0]&&i===n[1])return!0;this._updateBbox();let e=this._bbox,r=e.getLeft()-110,a=e.getTop()-101,o=e.getRight()+131,l=e.getBottom()+120,h=0,c=0,u,_,d=0,p=0,m,g,f=(u=r<s?(h=r,s):(h=s,r),_=a<i?(c=a,i):(c=i,a),m=o<s?(d=o,s):(d=s,o),g=l<i?(p=l,i):(p=i,l),0),S=0;for(let e=0,t=n.length;e<t;e+=2){const C=(e+2)%t,y=n[e],G=n[e+1],I=n[C],T=n[1+C];C33.segmentsIntersectPreCalc(r,a,s,i,h,u,c,_,y,G,I,T)&&++f,C33.segmentsIntersectPreCalc(o,l,s,i,d,m,p,g,y,G,I,T)&&++S}return f%2==1||S%2==1}intersectsPoly(e,u,_){const d=e._ptsArr,p=this._ptsArr;if(this.containsPoint(d[0]+u,d[1]+_))return!0;if(e.containsPoint(p[0]-u,p[1]-_))return!0;for(let t=0,c=p.length;t<c;t+=2){let e=(t+2)%c,s=p[t],i=p[t+1],n=p[e],r=p[1+e],a=0,o=0,l,h;l=s<n?(a=s,n):(a=n,s),h=i<r?(o=i,r):(o=r,i);for(let e=0,t=d.length;e<t;e+=2){const m=(e+2)%t,g=d[e]+u,f=d[e+1]+_,S=d[m]+u,C=d[1+m]+_;if(C33.segmentsIntersectPreCalc(s,i,n,r,a,l,o,h,g,f,S,C))return!0}}return!1}intersectsSegment(s,i,n,r,a,o){if(this.containsPoint(n-s,r-i))return!0;if(this.containsPoint(a-s,o-i))return!0;let l=0,h=0,c,u;c=n<a?(l=n,a):(l=a,n),u=r<o?(h=r,o):(h=o,r);const _=this._ptsArr;for(let e=0,t=_.length;e<t;e+=2){const d=(e+2)%t,p=_[e]+s,m=_[e+1]+i,g=_[d]+s,f=_[1+d]+i;if(C33.segmentsIntersectPreCalc(n,r,a,o,l,c,h,u,p,m,g,f))return!0}return!1}mirror(s){const i=this._ptsArr;for(let e=0,t=i.length;e<t;e+=2)i[e]=2*s-i[e];this._isBboxChanged=!0}flip(s){const i=this._ptsArr;for(let e=0,t=i.length;e<t;e+=2){const n=e+1;i[n]=2*s-i[n]}this._isBboxChanged=!0}diag(){const s=this._ptsArr;for(let e=0,t=s.length;e<t;e+=2){const i=e+1,n=s[e];s[e]=s[i],s[i]=n}this._isBboxChanged=!0}GetMidX(){let s=this._ptsArr,i=0;for(let e=0,t=s.length;e<t;e+=2)i+=s[e];return i/this.pointCount()}GetMidY(){let s=this._ptsArr,i=0;for(let e=0,t=s.length;e<t;e+=2)i+=s[e+1];return i/this.pointCount()}GetPointsArray(){return this._ptsArr}GetPointCount(){return this.pointCount()}IsEnabled(){return this._enabled}}}{const C33=self.C3;C33.PairMap=class extends C33.DefendedBase{constructor(e){if(super(),this._firstMap=new Map,e)for(const[t,s,i]of e)this.Set(t,s,i)}Release(){this.Clear(),this._firstMap=null}IsEmpty(){return 0===this._firstMap.size}Clear(){const e=this._firstMap;for(const t of e.values())t.clear();e.clear()}Set(e,t,s){let i=this._firstMap,n=i.get(e);n||(n=new Map,i.set(e,n)),n.set(t,s)}Get(e,t){const s=this._firstMap.get(e);return s&&s.get(t)}Has(e,t){const s=this._firstMap.get(e);return!!s&&s.has(t)}Delete(e,t){const s=this._firstMap,i=s.get(e);if(!i)return!1;const n=i.delete(t);return n&&0===i.size&&s.delete(e),n}DeleteEither(e){const t=this._firstMap,s=t.get(e);s&&(s.clear(),t.delete(e));for(const[i,n]of t.entries())n.delete(e)&&0===n.size&&t.delete(i)}GetSize(){let e=0;for(const t of this._firstMap.values())e+=t.size;return e}*values(){for(const e of this._firstMap.values())yield*e.values()}*keyPairs(){for(const[e,t]of this._firstMap.entries())for(const s of t.keys())yield[e,s]}*entries(){for(const[e,t]of this._firstMap.entries())for(const[s,i]of t.entries())yield[e,s,i]}}}{const C33=self.C3;C33.ArraySet=class extends C33.DefendedBase{constructor(){super(),this._set=new Set,this._arr=[],this._needToRebuildArray=!1}Release(){this.Clear()}Clear(){this._set.clear(),C33.clearArray(this._arr),this._needToRebuildArray=!1}Add(e){this._set.has(e)||(this._set.add(e),this._needToRebuildArray)||this._arr.push(e)}Has(e){return this._set.has(e)}Delete(e){this._set.delete(e)&&(this._needToRebuildArray=!0)}GetSize(){return this._set.size}IsEmpty(){return 0===this._set.size}GetArray(){return this._needToRebuildArray&&(this._RebuildArray(),this._needToRebuildArray=!1),this._arr}_RebuildArray(){const e=this._arr;C33.clearArray(e);for(const t of this._set)e.push(t)}}}{const C33=self.C3,EASE_MAP=new Map,PREDEFINED_EASE_MAP=new Map,CUSTOM_EASE_EDITOR_MAP=new Map,CUSTOM_EASE_DATA_EDITOR_MAP=new Map,CUSTOM_EASE_RUNTIME_MAP=new Map,CUSTOM_EASE_DATA_RUNTIME_MAP=new Map,PRIVATE_EASE_MAP=new Map,BUILT_IN_TRANSITION_MAP=new Map,ALIAS_MAP=new Map,EASE_TRANSLATION_KEYS=(ALIAS_MAP.set("linear","noease"),ALIAS_MAP.set("default","noease"),["default","noease","easeinquad","easeoutquad","easeinoutquad","easeincubic","easeoutcubic","easeinoutcubic","easeinquart","easeoutquart","easeinoutquart","easeinquint","easeoutquint","easeinoutquint","easeinsine","easeoutsine","easeinoutsine","easeinexpo","easeoutexpo","easeinoutexpo","easeincirc","easeoutcirc","easeinoutcirc","easeinelastic","easeoutelastic","easeinoutelastic","easeinback","easeoutback","easeinoutback","easeinbounce","easeoutbounce","easeinoutbounce"]),SHORT_EASE_TRANSLATION_KEYS=["default","noease","quad","cubic","quart","quint","sine","expo","circ","elastic","back","bounce"],EASE_API2INTERNAL_NAMES=new Map([["linear","noease"],["in-sine","easeinsine"],["out-sine","easeoutsine"],["in-out-sine","easeinoutsine"],["in-elastic","easeinelastic"],["out-elastic","easeoutelastic"],["in-out-elastic","easeinoutelastic"],["in-back","easeinback"],["out-back","easeoutback"],["in-out-back","easeinoutback"],["in-bounce","easeinbounce"],["out-bounce","easeoutbounce"],["in-out-bounce","easeinoutbounce"],["in-cubic","easeincubic"],["out-cubic","easeoutcubic"],["in-out-cubic","easeinoutcubic"],["in-quadratic","easeinquad"],["out-quadratic","easeoutquad"],["in-out-quadratic","easeinoutquad"],["in-quartic","easeinquart"],["out-quartic","easeoutquart"],["in-out-quartic","easeinoutquart"],["in-quintic","easeinquint"],["out-quintic","easeoutquint"],["in-out-quintic","easeinoutquint"],["in-circular","easeincirc"],["out-circular","easeoutcirc"],["in-out-circular","easeinoutcirc"],["in-exponential","easeinexpo"],["out-exponential","easeoutexpo"],["in-out-exponential","easeinoutexpo"]]),SAMPLE_COUNT=(self.Ease=class d{constructor(){}static InheritEase(){return"default"}static DefaultEase(){return"noease"}static ToInternal(e){return EASE_API2INTERNAL_NAMES.get(e)}static GetEditorEaseNames(t,...s){this._CreateEaseMap();let e,i=(t?(CUSTOM_EASE_EDITOR_MAP.has(t)||CUSTOM_EASE_EDITOR_MAP.set(t,new Map),[...(e=CUSTOM_EASE_EDITOR_MAP.get(t)).keys()].filter(e=>!d.GetEditorEaseData(e,t)||d.GetEditorEaseData(e,t).transition.IsForAnyPurpose())):[...(e=CUSTOM_EASE_RUNTIME_MAP).keys()]).sort();return[...PREDEFINED_EASE_MAP.keys()].concat(i).filter(e=>!s.includes(e))}static GetRuntimeEaseNames(){this._CreateEaseMap();const e=[...CUSTOM_EASE_RUNTIME_MAP.keys()];return e.sort(),[...PREDEFINED_EASE_MAP.keys()].concat(e)}static GetCustomRuntimeEaseNames(){this._CreateEaseMap();const e=[...CUSTOM_EASE_RUNTIME_MAP.keys()];return e.sort(),e}static IsPredefinedTranslatedName(e){for(const t of EASE_TRANSLATION_KEYS){const s=self.lang("ui.bars.timeline.eases."+t);if(s===e)return!0}for(const i of SHORT_EASE_TRANSLATION_KEYS){const n=self.lang("ui.bars.timeline.short-eases."+i);if(n===e)return!0}}static IsNamePredefined(e){return this._CreateEaseMap(),[...PREDEFINED_EASE_MAP.keys()].includes(e)}static _GetEase(e){const t=ALIAS_MAP.get(e);return t?EASE_MAP.get(t):d.IsNamePredefined(e)?EASE_MAP.get(e):PRIVATE_EASE_MAP.has(e)?PRIVATE_EASE_MAP.get(e):void 0}static GetBuiltInTransition(e){return this._CreateEaseMap(),BUILT_IN_TRANSITION_MAP.get(e)}static GetEditorEase(e,t){this._CreateEaseMap();const s=d._GetEase(e);if(s)return s;if(t)return CUSTOM_EASE_EDITOR_MAP.get(t).get(e);throw new Error("missing ease function")}static GetEditorEaseData(e,t){this._CreateEaseMap();const s=CUSTOM_EASE_DATA_EDITOR_MAP.get(t);if(s)return s.get(e)}static HasEditorEase(e,t){this._CreateEaseMap();const s=d._GetEase(e);return!!s||!!CUSTOM_EASE_EDITOR_MAP.get(t).get(e)}static GetRuntimeEase(e){this._CreateEaseMap();const t=d._GetEase(e);return t||CUSTOM_EASE_RUNTIME_MAP.get(e)}static GetRuntimeEaseData(e){return this._CreateEaseMap(),CUSTOM_EASE_DATA_RUNTIME_MAP.get(e)}static GetEaseFromIndex(e){this._CreateEaseMap();const t=this.GetRuntimeEaseNames();return t[e]}static GetIndexForEase(e,t){this._CreateEaseMap();const s=this.GetEditorEaseNames(t);return s.indexOf(e)}static GetIndexForEaseAtRuntime(e){return this.GetIndexForEase(e)}static _CreateEaseMap(){0===EASE_MAP.size&&(this._AddPredifinedEase("default",()=>{}),this._AddPredifinedEase("noease",[{x:0,y:0,sax:.336,say:0,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.336,eay:0,se:!1,ee:!0}],!0),this._AddPredifinedEase("easeinsine",[{x:0,y:0,sax:.485,say:0,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.038,eay:0,se:!1,ee:!0}]),this._AddPredifinedEase("easeoutsine",[{x:0,y:0,sax:.038,say:0,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.485,eay:0,se:!1,ee:!0}]),this._AddPredifinedEase("easeinoutsine",[{x:0,y:0,sax:.336,say:0,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.336,eay:0,se:!1,ee:!0}]),this._AddPredifinedEase("easeinelastic",[{x:0,y:0,sax:.018,say:0,eax:0,eay:0,se:!0,ee:!1},{x:.116,y:.002,sax:.025,say:0,eax:-.025,eay:0,se:!0,ee:!0},{x:.266,y:-.005,sax:.024,say:0,eax:-.021,eay:0,se:!0,ee:!0},{x:.416,y:.016,sax:.024,say:0,eax:-.026,eay:0,se:!0,ee:!0},{x:.566,y:-.045,sax:.061,say:0,eax:-.025,eay:0,se:!0,ee:!0},{x:.716,y:.132,sax:.072,say:-.004,eax:-.045,eay:0,se:!0,ee:!0},{x:.866,y:-.373,sax:.06,say:0,eax:-.049,eay:-.002,se:!0,ee:!0},{x:1,y:1,sax:0,say:0,eax:-.038,eay:-.263,se:!1,ee:!0}]),this._AddPredifinedEase("easeoutelastic",[{x:0,y:0,sax:.038,say:.263,eax:0,eay:0,se:!0,ee:!1},{x:.136,y:1.373,sax:.049,say:.002,eax:-.06,eay:0,se:!0,ee:!0},{x:.286,y:.868,sax:.045,say:0,eax:-.072,eay:.004,se:!0,ee:!0},{x:.436,y:1.045,sax:.025,say:0,eax:-.061,eay:0,se:!0,ee:!0},{x:.586,y:.984,sax:.026,say:0,eax:-.024,eay:0,se:!0,ee:!0},{x:.736,y:1.005,sax:.021,say:0,eax:-.024,eay:0,se:!0,ee:!0},{x:.886,y:.998,sax:.025,say:0,eax:-.025,eay:0,se:!0,ee:!0},{x:1,y:1,sax:0,say:0,eax:-.018,eay:0,se:!1,ee:!0}]),this._AddPredifinedEase("easeinoutelastic",[{x:0,y:0,sax:.025,say:0,eax:0,eay:0,se:!0,ee:!1},{x:.067,y:.001,sax:.025,say:0,eax:-.025,eay:0,se:!0,ee:!0},{x:.18,y:-.005,sax:.025,say:0,eax:-.025,eay:0,se:!0,ee:!0},{x:.292,y:.025,sax:.053,say:0,eax:-.025,eay:0,se:!0,ee:!0},{x:.405,y:-.118,sax:.069,say:0,eax:-.027,eay:0,se:!0,ee:!0},{x:.597,y:1.118,sax:.027,say:0,eax:-.069,eay:0,se:!0,ee:!0},{x:.71,y:.975,sax:.025,say:0,eax:-.053,eay:0,se:!0,ee:!0},{x:.822,y:1.005,sax:.025,say:0,eax:-.025,eay:0,se:!0,ee:!0},{x:.935,y:.999,sax:.025,say:0,eax:-.025,eay:0,se:!0,ee:!0},{x:1,y:1,sax:0,say:0,eax:-.025,eay:0,se:!1,ee:!0}]),this._AddPredifinedEase("easeinback",[{x:0,y:0,sax:.35,say:0,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.34,eay:-1.579,se:!1,ee:!0}]),this._AddPredifinedEase("easeoutback",[{x:0,y:0,sax:.34,say:1.579,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.35,eay:0,se:!1,ee:!0}]),this._AddPredifinedEase("easeinoutback",[{x:0,y:0,sax:.035,say:0,eax:0,eay:0,se:!0,ee:!1},{x:.242,y:-.1,sax:.258,say:0,eax:-.025,eay:0,se:!0,ee:!0},{x:.76,y:1.1,sax:.025,say:0,eax:-.26,eay:0,se:!0,ee:!0},{x:1,y:1,sax:0,say:0,eax:-.035,eay:0,se:!1,ee:!0}]),this._AddPredifinedEase("easeinbounce",[{x:0,y:0,sax:.033,say:.025,eax:0,eay:0,se:!0,ee:!1},{x:.092,y:0,sax:.026,say:.078,eax:-.033,eay:.025,se:!0,ee:!0},{x:.274,y:0,sax:.097,say:.319,eax:-.026,eay:.078,se:!0,ee:!0},{x:.637,y:0,sax:.105,say:.625,eax:-.097,eay:.319,se:!0,ee:!0},{x:1,y:1,sax:0,say:0,eax:-.125,eay:-.004,se:!1,ee:!0}]),this._AddPredifinedEase("easeoutbounce",[{x:0,y:0,sax:.125,say:.004,eax:0,eay:0,se:!0,ee:!1},{x:.365,y:1,sax:.097,say:-.319,eax:-.105,eay:-.625,se:!0,ee:!0},{x:.728,y:1,sax:.026,say:-.078,eax:-.097,eay:-.319,se:!0,ee:!0},{x:.91,y:1,sax:.033,say:-.025,eax:-.026,eay:-.078,se:!0,ee:!0},{x:1,y:1,sax:0,say:0,eax:-.033,eay:-.025,se:!1,ee:!0}]),this._AddPredifinedEase("easeinoutbounce",[{x:0,y:0,sax:.01,say:.006,eax:0,eay:0,se:!0,ee:!1},{x:.046,y:0,sax:.021,say:.038,eax:-.01,eay:.006,se:!0,ee:!0},{x:.137,y:0,sax:.059,say:.158,eax:-.021,eay:.038,se:!0,ee:!0},{x:.319,y:0,sax:.117,say:.744,eax:-.059,eay:.158,se:!0,ee:!0},{x:.683,y:1,sax:.059,say:-.158,eax:-.117,eay:-.744,se:!0,ee:!0},{x:.865,y:1,sax:.021,say:-.038,eax:-.059,eay:-.158,se:!0,ee:!0},{x:.956,y:1,sax:.01,say:-.006,eax:-.021,eay:-.038,se:!0,ee:!0},{x:1,y:1,sax:0,say:0,eax:-.01,eay:-.006,se:!1,ee:!0}]),this._AddPredifinedEase("easeincubic",[{x:0,y:0,sax:.75,say:0,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.138,eay:-.321,se:!1,ee:!0}]),this._AddPredifinedEase("easeoutcubic",[{x:0,y:0,sax:.138,say:.321,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.75,eay:0,se:!1,ee:!0}]),this._AddPredifinedEase("easeinoutcubic",[{x:0,y:0,sax:.285,say:0,eax:0,eay:0,se:!0,ee:!1},{x:.5,y:.5,sax:.081,say:.272,eax:-.081,eay:-.272,se:!0,ee:!0},{x:1,y:1,sax:0,say:0,eax:-.285,eay:0,se:!1,ee:!0}]),this._AddPredifinedEase("easeinquad",[{x:0,y:0,sax:.4,say:0,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.178,eay:-.392,se:!1,ee:!0}]),this._AddPredifinedEase("easeoutquad",[{x:0,y:0,sax:.178,say:.392,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.4,eay:0,se:!1,ee:!0}]),this._AddPredifinedEase("easeinoutquad",[{x:0,y:0,sax:.25,say:0,eax:0,eay:0,se:!0,ee:!1},{x:.5,y:.5,sax:.03,say:.065,eax:-.03,eay:-.065,se:!0,ee:!0},{x:1,y:1,sax:0,say:0,eax:-.25,eay:0,se:!1,ee:!0}]),this._AddPredifinedEase("easeinquart",[{x:0,y:0,sax:.25,say:1,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.5,eay:0,se:!1,ee:!0}]),this._AddPredifinedEase("easeoutquart",[{x:0,y:0,sax:.5,say:0,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.25,eay:-1,se:!1,ee:!0}]),this._AddPredifinedEase("easeinoutquart",[{x:0,y:0,sax:.765,say:.03,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.765,eay:-.03,se:!1,ee:!0}]),this._AddPredifinedEase("easeinquint",[{x:0,y:0,sax:.6,say:0,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.2,eay:-1,se:!1,ee:!0}]),this._AddPredifinedEase("easeoutquint",[{x:0,y:0,sax:.2,say:1,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.6,eay:0,se:!1,ee:!0}]),this._AddPredifinedEase("easeinoutquint",[{eax:0,eay:0,ee:!1,sax:.84,say:0,se:!0,x:0,y:0},{eax:-.84,eay:0,ee:!0,sax:0,say:0,se:!1,x:1,y:1}]),this._AddPredifinedEase("easeincirc",[{x:0,y:0,sax:.25,say:0,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.024,eay:-.808,se:!1,ee:!0}]),this._AddPredifinedEase("easeoutcirc",[{x:0,y:0,sax:.024,say:.808,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.25,eay:0,se:!1,ee:!0}]),this._AddPredifinedEase("easeinoutcirc",[{x:0,y:0,sax:.125,say:0,eax:0,eay:0,se:!0,ee:!1},{x:.5,y:.5,sax:.02,say:.428,eax:-.02,eay:-.428,se:!0,ee:!0},{x:1,y:1,sax:0,say:0,eax:-.125,eay:0,se:!1,ee:!0}]),this._AddPredifinedEase("easeinexpo",[{x:0,y:0,sax:.66,say:0,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.14,eay:-1,se:!1,ee:!0}]),this._AddPredifinedEase("easeoutexpo",[{x:0,y:0,sax:.14,say:1,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.66,eay:0,se:!1,ee:!0}]),this._AddPredifinedEase("easeinoutexpo",[{eax:0,eay:0,ee:!1,sax:.345,say:0,se:!0,x:0,y:0},{eax:-.06,eay:-.5,ee:!0,sax:.06,say:.5,se:!0,x:.5,y:.5},{eax:-.335,eay:0,ee:!0,sax:0,say:0,se:!1,x:1,y:1}]),this._AddPrivateCustomEase("cubicbezier",this.EaseCubicBezier),this._AddPrivateCustomEase("spline",this.EaseSpline))}static _AddPredifinedEase(e,t,s=!1){if("function"==typeof t)d._AddEase(e,t,"predefined");else{if(!C33.IsArray(t))throw new Error("unexpected arguments");if(self.BuiltInTransition){const n=C33.New(self.BuiltInTransition,e,s);n.SetFromJson(t),d._AddEase(e,(e,t,s,i)=>n.Interpolate(e,t,s,i),"predefined"),BUILT_IN_TRANSITION_MAP.set(e,n)}else{const r=C33.New(C33.Transition,[e,t.map(e=>[e.x,e.y,e.sax,e.say,e.eax,e.eay,e.se,e.ee])],!1);r.MakeLinear(s),d._AddEase(e,(e,t,s,i)=>r.Interpolate(e,t,s,i),"predefined")}}}static _AddPrivateCustomEase(e,t){d._AddEase(e,t,"private")}static AddCustomEase(e,t,s,i){this._CreateEaseMap(),d._AddEase(e,t,"custom",s,i)}static RemoveCustomEase(e,t){if(!this.IsNamePredefined(e)&&![...PRIVATE_EASE_MAP.keys()].includes(e)){const s=CUSTOM_EASE_EDITOR_MAP.get(t),i=(s&&s.delete(e),CUSTOM_EASE_DATA_EDITOR_MAP.get(t));i&&i.delete(e)}}static _AddEase(e,t,s,i,n){switch(s){case"predefined":EASE_MAP.set(e,t),PREDEFINED_EASE_MAP.set(e,t);break;case"custom":if(i){CUSTOM_EASE_EDITOR_MAP.has(i)||CUSTOM_EASE_EDITOR_MAP.set(i,new Map),CUSTOM_EASE_DATA_EDITOR_MAP.has(i)||CUSTOM_EASE_DATA_EDITOR_MAP.set(i,new Map);const r=CUSTOM_EASE_EDITOR_MAP.get(i),a=(r.set(e,t),CUSTOM_EASE_DATA_EDITOR_MAP.get(i));a.set(e,n)}else CUSTOM_EASE_RUNTIME_MAP.set(e,t),CUSTOM_EASE_DATA_RUNTIME_MAP.set(e,n);break;case"private":EASE_MAP.set(e,t),PRIVATE_EASE_MAP.set(e,t);break;default:throw new Error("unexpected ease mode")}}static NoEase(e,t,s,i){return 0===i?t:s*e/i+t}static EaseCubicBezier(e,t,s,i,n){const r=t,a=3*e*(s-t),o=3*e**2*(t+i-2*s),l=e**3*(n-t+3*s-3*i);return r+a+o+l}static EaseSpline(e,t,s,i,n,r,o,l,h,u){if(i===n&&r===o)return e;const _=get_t_for_x(e,t,i,r,l,u),d=a(s,n,o,h),p=b(s,n,o,h),m=c(s,n,o,h);return calc_bezier(_,d,p,m)}static GetBezierSamples(e,t,s,i){const n=[],r=a(e,t,s,i),o=b(e,t,s,i),l=c(e,t,s,i);for(let e=0;e<SAMPLE_COUNT;++e){const h=calc_bezier(e*SAMPLE_STEP,r,o,l);n.push(h)}return n}},11),SAMPLE_STEP=1/(SAMPLE_COUNT-1),NEWTON_RAPHSON_ITERATIONS=4,NEWTON_RAPHSON_MIN_SLOPE=.01,SUBDIVISION_PRECISION=1e-7,SUBDIVISION_MAX_ITERATIONS=10,a=(e,t,s,i)=>i-3*s+3*t-e,b=(e,t,s,i)=>3*s-6*t+3*e,c=(e,t,s,i)=>3*(t-e),calc_bezier=(e,t,s,i)=>((t*e+s)*e+i)*e,get_slope=(e,t,s,i)=>3*t*e*e+2*s*e+i,get_t_for_x=(o,e,t,s,i,n)=>{if(1==o)return 1;let l=0,r=1,h=n[r],u=SAMPLE_COUNT-1;for(SAMPLE_COUNT;r!=u&&h<=o;)r++,h=n[r],l+=SAMPLE_STEP;r--;let _=(o-(h=n[r]))/(n[r+1]-h),d=l+_*SAMPLE_STEP,p=a(e,t,s,i),m=b(e,t,s,i),g=c(e,t,s,i),f=get_slope(d,p,m,g);if(0===f)return d;if(f>=NEWTON_RAPHSON_MIN_SLOPE){for(let e=0;e<NEWTON_RAPHSON_ITERATIONS;++e){const S=calc_bezier(d,p,m,g)-o,C=get_slope(d,p,m,g);d-=S/C}return d}{let t=l,s=l+SAMPLE_STEP,i=0,n,r;do{d=t+(s-t)/2;let e=calc_bezier(d,p,m,g)-o;0<e?s=d:t=d,n=Math.abs(e)>SUBDIVISION_PRECISION,r=++i<SUBDIVISION_MAX_ITERATIONS}while(n&&r);return d}}}{let RequireStringOrNumber2=function(e){C33.IsString(e)};RequireStringOrNumber=RequireStringOrNumber2;const C33=self.C3;C33.ProbabilityTable=class{constructor(e){this._items=[],this._name=e||"",this._totalWeight=0}Release(){this.Clear(),this._items=null}GetName(){return this._name}Clear(){C33.clear2DArray(this._items),this._totalWeight=0}GetTotalWeight(){return this._totalWeight}Sample(e=Math.random()*this.GetTotalWeight()){let t=0;for(const[s,i]of this._items)if(e<(t+=s))return i;return 0}AddItem(e,t){RequireStringOrNumber2(t),this._totalWeight+=e,this._items.push([e,t])}RemoveItem(t,s){RequireStringOrNumber2(s);const i=0===t;for(let e=0;e<this._items.length;e++){const n=this._items[e],r=i||n[0]===t,a=n[1]===s;if(r&&a){this._items.splice(e,1),this._totalWeight-=n[0];break}}}asJSON(){return JSON.stringify(this._items)}static fromJSON(e,t){const s=new C33.ProbabilityTable(t),i=JSON.parse(e);for(const n of i){const r=n[0],a=n[1];s.AddItem(r,a)}return s}}}{let C33=self.C3,nextId=0;C33.ScreenReaderText=class{constructor(e,t){this._runtime=e,this._text=t,this._id=nextId++,this._runtime.PostComponentMessageToDOM("runtime","screen-reader-text",{type:"create",id:this._id,text:this._text})}Release(){this._runtime.PostComponentMessageToDOM("runtime","screen-reader-text",{type:"release",id:this._id}),this._runtime=null,this._text="",this._id=-1}SetText(e){this._text!==e&&(this._text=e,this._runtime.PostComponentMessageToDOM("runtime","screen-reader-text",{type:"update",id:this._id,text:this._text}))}}}{const C33=self.C3;C33.Event=class{constructor(e,t){this.type=e,this.cancelable=!!t,this.defaultPrevented=!1,this.propagationStopped=!1,this.isAsync=!1}preventDefault(){if(!this.cancelable)throw new Error(`event '${this.type}' is not cancelable`);this.defaultPrevented=!0}stopPropagation(){if(!this.cancelable)throw new Error(`event '${this.type}' cannot be stopped`);if(this.isAsync)throw new Error(`cannot stop async event '${this.type}' propagation`);this.propagationStopped=!0}}}{const C33=self.C3,assert=self.assert;C33.Event.Handler=class extends C33.DefendedBase{constructor(e){super(),this._type=e,this._captureListeners=[],this._captureListenersSet=new Set,this._listeners=[],this._listenersSet=new Set,this._fireDepth=0,this._queueModifyListeners=[]}Release(){0<this._fireDepth||(C33.clearArray(this._captureListeners),this._captureListenersSet.clear(),C33.clearArray(this._listeners),this._listenersSet.clear(),C33.clearArray(this._queueModifyListeners),C33.Release(this))}_AddListener(e,t){this._IsFiring()?this._queueModifyListeners.push({op:"add",func:e,capture:t}):t?this._captureListenersSet.has(e)||(this._captureListeners.push(e),this._captureListenersSet.add(e)):this._listenersSet.has(e)||(this._listeners.push(e),this._listenersSet.add(e))}_RemoveListener(e,t){this._IsFiring()?this._queueModifyListeners.push({op:"remove",func:e,capture:t}):t?this._captureListenersSet.has(e)&&(this._captureListenersSet.delete(e),C33.arrayFindRemove(this._captureListeners,e)):this._listenersSet.has(e)&&(this._listenersSet.delete(e),C33.arrayFindRemove(this._listeners,e))}_IsEmpty(){return!this._captureListeners.length&&!this._listeners.length}_IsFiring(){return 0<this._fireDepth}_ProcessQueuedListeners(){const e=new Set,t=new Set;for(const s of this._queueModifyListeners)if("add"===s.op)this._AddListener(s.func,s.capture),(s.capture?t:e).delete(s.func);else{if("remove"!==s.op)throw new Error("invalid op");(s.capture?(this._captureListenersSet.delete(s.func),t):(this._listenersSet.delete(s.func),e)).add(s.func)}C33.arrayRemoveAllInSet(this._listeners,e),C33.arrayRemoveAllInSet(this._captureListeners,t),C33.clearArray(this._queueModifyListeners)}_FireCancellable(s){this._IncreaseFireDepth();let i=!1;for(let e=0,t=this._captureListeners.length;e<t;++e)if(this._captureListeners[e](s),s.propagationStopped){i=!0;break}if(!i)for(let e=0,t=this._listeners.length;e<t&&(this._listeners[e](s),!s.propagationStopped);++e);return this._DecreaseFireDepth(),!s.defaultPrevented}_FireNonCancellable(s){this._IncreaseFireDepth();for(let e=0,t=this._captureListeners.length;e<t;++e)this._captureListeners[e](s);for(let e=0,t=this._listeners.length;e<t;++e)this._listeners[e](s);return this._DecreaseFireDepth(),!0}_IncreaseFireDepth(){this._fireDepth++}_DecreaseFireDepth(){this._fireDepth--,0===this._fireDepth&&0<this._queueModifyListeners.length&&this._ProcessQueuedListeners()}SetDelayRemoveEventsEnabled(e){e?this._IncreaseFireDepth():this._DecreaseFireDepth()}_FireAsync(s){let i=[];for(let t=0,e=this._captureListeners.length;t<e;++t){let e=this._captureListeners[t];i.push(C33.Asyncify(()=>e(s)))}for(let t=0,e=this._listeners.length;t<e;++t){let e=this._listeners[t];i.push(C33.Asyncify(()=>e(s)))}return Promise.all(i).then(()=>!s.defaultPrevented)}_FireAndWait_AsyncOptional(s){const i=[];this._IncreaseFireDepth();for(let e=0,t=this._captureListeners.length;e<t;++e){const n=this._captureListeners[e](s);n instanceof Promise&&i.push(n)}for(let e=0,t=this._listeners.length;e<t;++e){const r=this._listeners[e](s);r instanceof Promise&&i.push(r)}return this._DecreaseFireDepth(),i.length?Promise.all(i).then(()=>!s.defaultPrevented):!s.defaultPrevented}async _FireAndWaitAsync(e){return this._FireAndWait_AsyncOptional(e)}async _FireAndWaitAsyncSequential(s){this._IncreaseFireDepth();for(let e=0,t=this._captureListeners.length;e<t;++e){const i=this._captureListeners[e](s);i instanceof Promise&&await i}for(let e=0,t=this._listeners.length;e<t;++e){const n=this._listeners[e](s);n instanceof Promise&&await n}return this._DecreaseFireDepth(),!s.defaultPrevented}*_FireAsGenerator(s){this._IncreaseFireDepth();for(let e=0,t=this._captureListeners.length;e<t;++e){const i=this._captureListeners[e](s);C33.IsIterator(i)&&(yield*i)}for(let e=0,t=this._listeners.length;e<t;++e){const n=this._listeners[e](s);C33.IsIterator(n)&&(yield*n)}this._DecreaseFireDepth()}}}{const C33=self.C3;C33.Event.Dispatcher=class extends C33.DefendedBase{constructor(){super(),this._eventHandlers=new Map,this._dispatcherWasReleased=!1}Release(){if(this._dispatcherWasReleased)throw new Error("already released");this.ClearEvents(),this._dispatcherWasReleased=!0,C33.Release(this)}WasReleased(){return this._dispatcherWasReleased}ClearEvents(){if(this._eventHandlers){for(let e of this._eventHandlers.values())e.Release();this._eventHandlers.clear()}}_GetHandlerByType(e,t){let s=this._eventHandlers.get(e);return s||(t?(s=C33.New(C33.Event.Handler,e),this._eventHandlers.set(e,s),s):null)}HasAnyHandlerFor(e){return this._eventHandlers.has(e)}addEventListener(e,t,s){let i=this._GetHandlerByType(e,!0);i._AddListener(t,!!s)}removeEventListener(e,t,s){let i=this._GetHandlerByType(e,!1);i&&(i._RemoveListener(t,!!s),i._IsEmpty())&&this._eventHandlers.delete(e)}dispatchEvent(e){const t=this._GetHandlerByType(e.type,!1);return!t||(e.cancelable?t._FireCancellable(e):t._FireNonCancellable(e))}dispatchEventAsync(e){const t=this._GetHandlerByType(e.type,!1);return t?(e.isAsync=!0,t._FireAsync(e)):Promise.resolve(!0)}async dispatchEventAndClearAsync(e){const t=this._GetHandlerByType(e.type,!1);if(!t)return!0;this._eventHandlers.delete(e.type),e.isAsync=!0;const s=await t._FireAsync(e);return t.Release(),s}async dispatchEventAndWaitAsync(e){const t=this._GetHandlerByType(e.type,!1);return!t||t._FireAndWaitAsync(e)}dispatchEventAndWait_AsyncOptional(e){const t=this._GetHandlerByType(e.type,!1);return!t||t._FireAndWait_AsyncOptional(e)}async dispatchEventAndWaitAsyncSequential(e){const t=this._GetHandlerByType(e.type,!1);return!t||t._FireAndWaitAsyncSequential(e)}dispatchGeneratorEvent(e){const t=this._GetHandlerByType(e.type,!1);if(!t)return null;if(e.cancelable)throw new Error("not supported");return t._FireAsGenerator(e)}SetDelayRemoveEventsEnabled(e){for(const t of this._eventHandlers.values())t.SetDelayRemoveEventsEnabled(e)}}}{let SetNewCallback2=function(e){callbackId=SUPPORTS_RIC&&0===highThroughputMode?requestIdleCallback(DoAsyncifiedWork2,{timeout:IDLECALLBACK_TIMEOUT}):setTimeout(DoAsyncifiedWork2,0<highThroughputMode?1:e)},DoAsyncifiedWork2=function(n){if(callbackId=-1,workQueue.length){let s=performance.now(),i=s,e=0,t;for(;DoNextAsyncifiedJob2(workQueue.shift()),i=performance.now(),++e,t=(i-s)/e*1.1,workQueue.length&&(SUPPORTS_RIC&&0===highThroughputMode&&void 0!==n?t<n.timeRemaining():i-s+t<SETTIMEOUT_WORK_DURATION););if(-1===callbackId&&workQueue.length){let e=i-s,t=Math.max(SETTIMEOUT_INTERVAL-e,4);SetNewCallback2(t)}}},DoNextAsyncifiedJob2=function(t){let e;try{e=t.func()}catch(e){return void t.reject(e)}t.resolve(e)},C33=(SetNewCallback=SetNewCallback2,DoAsyncifiedWork=DoAsyncifiedWork2,DoNextAsyncifiedJob=DoNextAsyncifiedJob2,self.C3),SETTIMEOUT_WORK_DURATION=12,SETTIMEOUT_INTERVAL=16,IDLECALLBACK_TIMEOUT=35,SUPPORTS_RIC="undefined"!=typeof requestIdleCallback,workQueue=[],callbackId=-1,highThroughputMode=0,asyncifyDisabled=C33.QueryString.Has("disable-asyncify");asyncifyDisabled&&console.warn("[Asyncify] Asyncify has been disabled due to disable-asyncify in the query string. Some work will now be done synchronously."),C33.Asyncify=function(s){let i=null;return C33.isDebug&&(i=C33.GetCallStack()),new Promise((e,t)=>{workQueue.push({func:s,resolve:e,reject:t,stack:i}),asyncifyDisabled?DoNextAsyncifiedJob2(workQueue.pop()):-1===callbackId&&SetNewCallback2(SETTIMEOUT_INTERVAL)})},C33.Asyncify.SetHighThroughputMode=function(e){if(e)++highThroughputMode;else if(--highThroughputMode<0)throw new Error("already turned off high throughput mode")}}{let ClearTimeCache2=function(){cachedNowTime=-1},CheckActiveIdleTimeouts2=function(){timerId=-1,nextDeadline=-1;let s=Date.now();for(let t of activeIdleTimeouts)if(t._CheckTimeout(s)){let e=t._GetDeadline();(-1===nextDeadline||e<nextDeadline)&&(nextDeadline=e)}else activeIdleTimeouts.delete(t);if(-1!==nextDeadline){let e=Math.max(nextDeadline-s+IDLE_CHECK_TIMER_OVERSHOOT,IDLE_CHECK_MIN_INTERVAL);timerId=self.setTimeout(CheckActiveIdleTimeouts2,e)}},C33=(ClearTimeCache=ClearTimeCache2,CheckActiveIdleTimeouts=CheckActiveIdleTimeouts2,self.C3),IDLE_CHECK_MIN_INTERVAL=1e3,IDLE_CHECK_TIMER_OVERSHOOT=100,cachedNowTime=-1,timerId=(C33.FastGetDateNow=function(){return-1===cachedNowTime&&(cachedNowTime=Date.now(),self.setTimeout(ClearTimeCache2,16)),cachedNowTime},-1),nextDeadline=-1,activeIdleTimeouts=new Set;C33.IdleTimeout=class{constructor(e,t){this._callback=e,this._timeout=1e3*t,this._deadline=0,this._isActive=!1}Reset(){let e=C33.FastGetDateNow();this._deadline=e+this._timeout,this._isActive||(activeIdleTimeouts.add(this),this._isActive=!0),-1===timerId?(nextDeadline=this._deadline,timerId=self.setTimeout(CheckActiveIdleTimeouts2,this._timeout+IDLE_CHECK_TIMER_OVERSHOOT)):this._deadline<nextDeadline&&nextDeadline>e+IDLE_CHECK_MIN_INTERVAL&&(self.clearTimeout(timerId),nextDeadline=this._deadline,timerId=self.setTimeout(CheckActiveIdleTimeouts2,this._timeout+IDLE_CHECK_TIMER_OVERSHOOT))}_CheckTimeout(e){return!(e>=this._deadline)||(this._callback()?(this._deadline=e+this._timeout,!0):this._isActive=!1)}_GetDeadline(){return this._deadline}Cancel(){this._isActive&&(activeIdleTimeouts.delete(this),this._isActive=!1,0===activeIdleTimeouts.size)&&-1!==timerId&&(self.clearTimeout(timerId),timerId=-1,nextDeadline=-1)}Release(){this.Cancel(),this._callback=null}}}{const C33=self.C3;C33.Disposable=class a{constructor(e){this._disposed=!1,this._disposeAction=e}Dispose(){this._disposed||(this._disposed=!0,this._disposeAction&&(this._disposeAction(),this._disposeAction=null))}IsDisposed(){return this._disposed}Release(){this.Dispose()}static Release(e){return new a(()=>e.Release())}static From(t,s,i,n,e){if(null==n)n=!1;else if("boolean"!=typeof n&&"object"!=typeof n)throw new TypeError("invalid event listener options");if(e&&(i=i.bind(e)),s.includes(" ")){s=s.split(" ");const r=new C33.CompositeDisposable;for(let e of s)t.addEventListener(e,i,n),r.Add(C33.New(C33.Disposable,()=>t.removeEventListener(e,i,n)));return r}return t.addEventListener(s,i,n),C33.New(C33.Disposable,()=>t.removeEventListener(s,i,n))}},C33.StubDisposable=class extends C33.Disposable{SetAction(e){this._disposeAction=e}},C33.CompositeDisposable=class extends C33.Disposable{constructor(...t){super(),this._disposables=new Set;for(let e of t)this.Add(e)}Add(...t){if(this._disposed)throw new Error("already disposed");for(let e of t)this._disposables.add(e)}Remove(e){if(this._disposed)throw new Error("already disposed");this._disposables.delete(e)}RemoveAll(){if(this._disposed)throw new Error("already disposed");if(this._disposables){for(let e of this._disposables)e.Dispose();this._disposables.clear()}}IsDisposed(){return this._disposed}Dispose(){if(this._disposed)throw new Error("already disposed");this._disposed=!0;for(let e of this._disposables)e.Dispose();this._disposables.clear(),this._disposables=null}Release(){this.Dispose()}}}{const C33=self.C3;C33.KahanSum=class extends C33.DefendedBase{constructor(){super(),this._c=0,this._y=0,this._t=0,this._sum=0}Add(e){this._y=(e=+e)-this._c,this._t=this._sum+this._y,this._c=this._t-this._sum-this._y,this._sum=this._t}Subtract(e){this._sum-=+e}Get(){return this._sum}Reset(){this._c=0,this._y=0,this._t=0,this._sum=0}Set(e){this._c=0,this._y=0,this._t=0,this._sum=+e}Copy(e){this._c=e._c,this._y=e._y,this._t=e._t,this._sum=e._sum}Release(){}}}{const C33=self.C3,js_cols={},RED=!0,BLACK=!1;js_cols.RBnode=function(e){this.tree=e,this.right=this.tree.sentinel,this.left=this.tree.sentinel,this.parent=null,this.color=!1,this.key=null},js_cols.RedBlackSet=function(e){this.size=0,this.sentinel=new js_cols.RBnode(this),this.sentinel.color=BLACK,this.root=this.sentinel,this.root.parent=this.sentinel,this.compare=e||this.default_compare},js_cols.RedBlackSet.prototype.default_compare=function(e,t){return e<t?-1:t<e?1:0},js_cols.RedBlackSet.prototype.clone=function(){var e=new js_cols.RedBlackSet(this.compare);return e.insertAll(this),e},js_cols.RedBlackSet.prototype.clear=function(){this.size=0,this.sentinel=new js_cols.RBnode(this),this.sentinel.color=BLACK,this.root=this.sentinel,this.root.parent=this.sentinel},js_cols.RedBlackSet.prototype.leftRotate=function(e){var t=e.right;e.right=t.left,t.left!=this.sentinel&&(t.left.parent=e),t.parent=e.parent,e.parent==this.sentinel?this.root=t:e==e.parent.left?e.parent.left=t:e.parent.right=t,(t.left=e).parent=t},js_cols.RedBlackSet.prototype.rightRotate=function(e){var t=e.left;e.left=t.right,t.right!=this.sentinel&&(t.right.parent=e),t.parent=e.parent,e.parent==this.sentinel?this.root=t:e==e.parent.right?e.parent.right=t:e.parent.left=t,(t.right=e).parent=t},js_cols.RedBlackSet.prototype.insert=function(e){if(this.contains(e))this.get_(e).key=e;else{for(var t=new js_cols.RBnode(this),s=(t.key=e,this.sentinel),i=this.root;i!=this.sentinel;)s=i,i=this.compare(t.key,i.key)<0?i.left:i.right;(t.parent=s)==this.sentinel?this.root=t:this.compare(t.key,s.key)<0?s.left=t:s.right=t,t.left=this.sentinel,t.right=this.sentinel,t.color=RED,this.insertFixup(t),this.size++}},js_cols.RedBlackSet.prototype.insertFixup=function(e){for(;e!=this.sentinel&&e!=this.root&&e.parent.color==RED;){var t;e.parent==e.parent.parent.left?(t=e.parent.parent.right).color==RED?(e.parent.color=BLACK,t.color=BLACK,e.parent.parent.color=RED,e=e.parent.parent):(e==e.parent.right&&(e=e.parent,this.leftRotate(e)),e.parent.color=BLACK,e.parent.parent.color=RED,e.parent.parent!=this.sentinel&&this.rightRotate(e.parent.parent)):(t=e.parent.parent.left).color==RED?(e.parent.color=BLACK,t.color=BLACK,e.parent.parent.color=RED,e=e.parent.parent):(e==e.parent.left&&(e=e.parent,this.rightRotate(e)),e.parent.color=BLACK,e.parent.parent.color=RED,e.parent.parent!=this.sentinel&&this.leftRotate(e.parent.parent))}this.root.color=BLACK},js_cols.RedBlackSet.prototype.delete_=function(e){var t=e.left==this.sentinel||e.right==this.sentinel?e:this.successor_(e),s=t.left!=this.sentinel?t.left:t.right;s.parent=t.parent,t.parent==this.sentinel?this.root=s:t==t.parent.left?t.parent.left=s:t.parent.right=s,t!=e&&(e.key=t.key),t.color==BLACK&&this.deleteFixup(s),this.size--},js_cols.RedBlackSet.prototype.deleteFixup=function(e){for(;e!=this.root&&e.color==BLACK;){var t;e=e==e.parent.left?((t=e.parent.right).color==RED&&(t.color=BLACK,e.parent.color=RED,this.leftRotate(e.parent),t=e.parent.right),t.left.color==BLACK&&t.right.color==BLACK?(t.color=RED,e.parent):(t.right.color==BLACK&&(t.left.color=BLACK,t.color=RED,this.rightRotate(t),t=e.parent.right),t.color=e.parent.color,e.parent.color=BLACK,t.right.color=BLACK,this.leftRotate(e.parent),this.root)):((t=e.parent.left).color==RED&&(t.color=BLACK,e.parent.color=RED,this.rightRotate(e.parent),t=e.parent.left),t.right.color==BLACK&&t.left.color==BLACK?(t.color=RED,e.parent):(t.left.color==BLACK&&(t.right.color=BLACK,t.color=RED,this.leftRotate(t),t=e.parent.left),t.color=e.parent.color,e.parent.color=BLACK,t.left.color=BLACK,this.rightRotate(e.parent),this.root))}e.color=BLACK},js_cols.RedBlackSet.prototype.remove=function(e){var t;return(e=this.get_(e))!=this.sentinel?(t=e.key,this.delete_(e),t):null},js_cols.RedBlackSet.prototype.removeSwapped=function(e,t){this.remove(t)},js_cols.RedBlackSet.prototype.min=function(e){for(;e.left!=this.sentinel;)e=e.left;return e},js_cols.RedBlackSet.prototype.max=function(e){for(;e.right!=this.sentinel;)e=e.right;return e},js_cols.RedBlackSet.prototype.successor_=function(e){if(e.right!=this.sentinel)return this.min(e.right);for(var t=e.parent;t!=this.sentinel&&e==t.right;)t=(e=t).parent;return t},js_cols.RedBlackSet.prototype.predeccessor_=function(e){if(e.left!=this.sentinel)return this.max(e.left);for(var t=e.parent;t!=this.sentinel&&e==t.left;)t=(e=t).parent;return t},js_cols.RedBlackSet.prototype.successor=function(e){if(0<this.size){var t=this.get_(e);if(t==this.sentinel)return null;if(t.right!=this.sentinel)return this.min(t.right).key;for(var s=t.parent;s!=this.sentinel&&t==s.right;)s=(t=s).parent;return s!=this.sentinel?s.key:null}return null},js_cols.RedBlackSet.prototype.predecessor=function(e){if(0<this.size){var t=this.get_(e);if(t==this.sentinel)return null;if(t.left!=this.sentinel)return this.max(t.left).key;for(var s=t.parent;s!=this.sentinel&&t==s.left;)s=(t=s).parent;return s!=this.sentinel?s.key:null}return null},js_cols.RedBlackSet.prototype.getMin=function(){return this.min(this.root).key},js_cols.RedBlackSet.prototype.getMax=function(){return this.max(this.root).key},js_cols.RedBlackSet.prototype.get_=function(e){for(var t=this.root;t!=this.sentinel&&0!=this.compare(t.key,e);)t=this.compare(e,t.key)<0?t.left:t.right;return t},js_cols.RedBlackSet.prototype.contains=function(e){return null!=this.get_(e).key},js_cols.RedBlackSet.prototype.getValues=function(){var t=[];return this.forEach(function(e){t.push(e)}),t},js_cols.RedBlackSet.prototype.insertAll=function(e){if("array"==js_cols.typeOf(e))for(var t=0;t<e.length;t++)this.insert(e[t]);else if("function"==js_cols.typeOf(e.forEach))e.forEach(this.insert,this);else if("function"==js_cols.typeOf(e.getValues))for(var s=e.getValues(),t=0;t<s.length;t++)this.insert(s[t]);else if("object"==js_cols.typeOf(e))for(var i in e)this.insert(e[i])},js_cols.RedBlackSet.prototype.removeAll=function(e){if("array"==js_cols.typeOf(e))for(var t=0;t<e.length;t++)this.remove(e[t]);else if("function"==js_cols.typeOf(e.forEach))e.forEach(this.removeSwapped,this);else if("function"==js_cols.typeOf(e.getValues))for(var s=e.getValues(),t=0;t<s.length;t++)this.remove(s[t]);else if("object"==js_cols.typeOf(e))for(var i in e)this.remove(e[i])},js_cols.RedBlackSet.prototype.containsAll=function(e){if("array"==js_cols.typeOf(e)){for(var t=0;t<e.length;t++)if(!this.contains(e[t]))return!1;return!0}if("function"==js_cols.typeOf(e.forEach))return e.every(this.contains,this);if("function"==js_cols.typeOf(e.getValues)){for(var s=e.getValues(),t=0;t<s.length;t++)if(!this.contains(s[t]))return!1;return!0}if("object"==js_cols.typeOf(e)){for(var i in e)if(!this.contains(e[i]))return!1;return!0}},js_cols.RedBlackSet.prototype.range=function(e,t){var s=[];return this.traverseFromTo(function(e){s.push(e)},e,t),s},js_cols.RedBlackSet.prototype.traverse=function(e,t){if(!this.isEmpty())for(var s=this.min(this.root);s!=this.sentinel;){if(e.call(t,s.key,this))return;s=this.successor_(s)}},js_cols.RedBlackSet.prototype.traverseFrom=function(e,t,s){if(!this.isEmpty())for(var i=this.get_(t);i!=this.sentinel;){if(e.call(s,i.key,this))return;i=this.successor_(i)}},js_cols.RedBlackSet.prototype.traverseTo=function(e,t,s){if(!this.isEmpty())for(var i=this.min(this.root),n=this.get_(t);i!=n;){if(e.call(s,i.key,this))return;i=this.successor_(i)}},js_cols.RedBlackSet.prototype.traverseFromTo=function(e,t,s,i){if(!this.isEmpty())for(var n=this.get_(t),r=this.get_(s);n!=r;){if(e.call(i,n.key,this))return;n=this.successor_(n)}},js_cols.RedBlackSet.prototype.traverseBackwards=function(e,t){if(!this.isEmpty())for(var s=this.max(this.root);s!=this.sentinel;){if(e.call(t,s.key,this))return;s=this.predeccessor_(s)}},js_cols.RedBlackSet.prototype.forEach=function(e,t){if(!this.isEmpty())for(var s=this.min(this.root);s!=this.sentinel;s=this.successor_(s))e.call(t,s.key,s.key,this)},js_cols.RedBlackSet.prototype.some=function(e,t){if(!this.isEmpty())for(var s=this.min(this.root);s!=this.sentinel;s=this.successor_(s))if(e.call(t,s.key,s.key,this))return!0;return!1},js_cols.RedBlackSet.prototype.every=function(e,t){if(this.isEmpty())return!1;for(var s=this.min(this.root);s!=this.sentinel;s=this.successor_(s))if(!e.call(t,s.key,s.key,this))return!1;return!0},js_cols.RedBlackSet.prototype.map=function(e,t){var s=[];if(!this.isEmpty())for(var i=this.min(this.root);i!=this.sentinel;i=this.successor_(i))s.push(e.call(t,i.key,i.key,this));return s},js_cols.RedBlackSet.prototype.filter=function(e,t){var s=[];if(!this.isEmpty())for(var i=this.min(this.root);i!=this.sentinel;i=this.successor_(i))e.call(t,i.key,i.key,this)&&s.push(i.key);return s},js_cols.RedBlackSet.prototype.getCount=function(){return this.size},js_cols.RedBlackSet.prototype.isEmpty=function(){return 0==this.size},js_cols.RedBlackSet.prototype.isSubsetOf=function(e){var t=js_cols.getCount(e);if(this.getCount()>t)return!1;var s=0;if(this.isEmpty())return!0;for(var i=this.min(this.root);i!=this.sentinel;i=this.successor_(i))js_cols.contains.call(e,e,i.key)&&s++;return s==this.getCount()},js_cols.RedBlackSet.prototype.intersection=function(e){var t=new js_cols.RedBlackSet(this.compare);if(!this.isEmpty())for(var s=this.min(this.root);s!=this.sentinel;s=this.successor_(s))e.contains.call(e,s.key,s.key,this)&&t.insert(s.key);return t},C33.RedBlackSet=class extends C33.DefendedBase{constructor(e){super(),this._rbSet=new js_cols.RedBlackSet(e),this._enableQueue=!1,this._queueInsert=new Set,this._queueRemove=new Set}Add(e){this._enableQueue?this._rbSet.contains(e)?this._queueRemove.delete(e):this._queueInsert.add(e):this._rbSet.insert(e)}Remove(e){this._enableQueue?this._rbSet.contains(e)?this._queueRemove.add(e):this._queueInsert.delete(e):this._rbSet.remove(e)}Has(e){return this._enableQueue?!!this._queueInsert.has(e)||!this._queueRemove.has(e)&&this._rbSet.contains(e):this._rbSet.contains(e)}Clear(){this._rbSet.clear(),this._queueInsert.clear(),this._queueRemove.clear()}toArray(){if(this._enableQueue)throw new Error("cannot be used in queueing mode");return this._rbSet.getValues()}GetSize(){return this._rbSet.getCount()+this._queueInsert.size-this._queueRemove.size}IsEmpty(){return 0===this.GetSize()}Front(){if(this.IsEmpty())throw new Error("empty set");if(this._enableQueue)throw new Error("cannot be used in queueing mode");const e=this._rbSet,t=e.min(e.root);return t.key}Shift(){if(this.IsEmpty())throw new Error("empty set");if(this._enableQueue)throw new Error("cannot be used in queueing mode");const e=this.Front();return this.Remove(e),e}SetQueueingEnabled(e){if(this._enableQueue!==(e=!!e)&&!(this._enableQueue=e)){for(const t of this._queueRemove)this._rbSet.remove(t);this._queueRemove.clear();for(const s of this._queueInsert)this._rbSet.insert(s);this._queueInsert.clear()}}ForEach(e){this._rbSet.forEach(e)}*values(){if(!this.IsEmpty()){const t=this._rbSet;for(let e=t.min(t.root);e!=t.sentinel;e=t.successor_(e))yield e.key}}[Symbol.iterator](){return this.values()}}}{const C33=self.C3;C33.PromiseThrottle=class{constructor(e=C33.hardwareConcurrency){this._maxParallel=e,this._queue=[],this._activeCount=0}Add(s){return new Promise((e,t)=>{this._queue.push({func:s,resolve:e,reject:t}),this._MaybeStartNext()})}_FindInQueue(s){for(let e=0,t=this._queue.length;e<t;++e)if(this._queue[e].func===s)return e;return-1}RemoveAndResolve(e,t){const s=this._FindInQueue(e);if(-1===s)throw new Error("cannot find promise to resolve");this._queue[s].resolve(t),this._queue.splice(s,1)}RemoveAndReject(e,t){const s=this._FindInQueue(e);if(-1===s)throw new Error("cannot find promise to reject");this._queue[s].reject(t),this._queue.splice(s,1)}async _MaybeStartNext(){if(this._queue.length&&!(this._activeCount>=this._maxParallel)){this._activeCount++;const t=this._queue.shift();try{const e=await t.func();t.resolve(e)}catch(e){t.reject(e)}this._activeCount--,this._MaybeStartNext()}}static async Batch(e,t){let s=[],i=!1,n=[];for(;e--;)n.push((async()=>{let e;for(;e=t.pop();){if(i)return;try{s.push(await e())}catch(e){throw i=!0,e}}})());return await Promise.all(n),s}}}{const C33=self.C3;C33.RateLimiter=class{constructor(e,t,s){this._callback=e,this._interval=t,this._intervalOnBattery=s||2*t,this._timerId=-1,this._lastCallTime=-1/0,this._timerCallFunc=()=>this._OnTimer(),this._ignoreReset=!1,this._canRunImmediate=!1,this._callbackArguments=null}SetCanRunImmediate(e){this._canRunImmediate=!!e}_GetInterval(){return void 0!==C33.Battery&&C33.Battery.IsOnBatteryPower()?this._intervalOnBattery:this._interval}Call(...i){if(-1===this._timerId){this._callbackArguments=i;let e=C33.FastGetDateNow(),t=e-this._lastCallTime,s=this._GetInterval();s<=t&&this._canRunImmediate?(this._lastCallTime=e,this._RunCallback()):this._timerId=self.setTimeout(this._timerCallFunc,Math.max(s-t,4))}}_RunCallback(){this._ignoreReset=!0;const e=this._callbackArguments;this._callbackArguments=null,e?this._callback(...e):this._callback(),this._ignoreReset=!1}Reset(){this._ignoreReset||(this._CancelTimer(),this._callbackArguments=null,this._lastCallTime=C33.FastGetDateNow())}_OnTimer(){this._timerId=-1,this._lastCallTime=C33.FastGetDateNow(),this._RunCallback()}_CancelTimer(){-1!==this._timerId&&(self.clearTimeout(this._timerId),this._timerId=-1)}Release(){this._CancelTimer(),this._callback=null,this._callbackArguments=null,this._timerCallFunc=null}}}{const C33=self.C3;C33.SVGRasterManager=class{constructor(){this._images=new Map,this._allowNpotSurfaces=!1,this._getBaseSizeCallback=null,this._rasterAtSizeCallback=null,this._releaseResultCallback=null,this._redrawCallback=null}SetNpotSurfaceAllowed(e){this._allowNpotSurfaces=!!e}IsNpotSurfaceAllowed(){return this._allowNpotSurfaces}SetGetBaseSizeCallback(e){this._getBaseSizeCallback=e}GetBaseSize(e){if(this._getBaseSizeCallback)return this._getBaseSizeCallback(e);throw new Error("no get base size callback set")}SetRasterAtSizeCallback(e){this._rasterAtSizeCallback=e}RasterAtSize(e,t,s,i,n,r){if(this._rasterAtSizeCallback)return this._rasterAtSizeCallback(e,t,s,i,n,r);throw new Error("no raster at size callback set")}SetReleaseResultCallback(e){this._releaseResultCallback=e}ReleaseResult(e){if(!this._releaseResultCallback)throw new Error("no release result callback set");this._releaseResultCallback(e)}SetRedrawCallback(e){this._redrawCallback=e}Redraw(){if(!this._redrawCallback)throw new Error("no redraw callback set");this._redrawCallback()}AddImage(e){let t=this._images.get(e);return t||(t=C33.New(C33.SVGRasterImage,this,e),this._images.set(e,t)),t.IncReference(),t}_RemoveImage(e){this._images.delete(e.GetDataSource())}OnTexturesChanged(){for(const e of this._images.values())e.ReleaseRasterizedResult(),e.ForceRasterAgain()}}}{const C33=self.C3,MAX_SURFACE_SIZE=4096;C33.SVGRasterImage=class{constructor(e,t){this._manager=e,this._dataSource=t,this._refCount=0,this._baseWidth=0,this._baseHeight=0,this._getBaseSizePromise=this._manager.GetBaseSize(t).then(e=>{this._manager&&(this._baseWidth=e[0],this._baseHeight=e[1],this._manager.Redraw())}).catch(e=>{console.error("[SVG] Error loading SVG: ",e),this._hadError=!0,this._manager&&this._manager.Redraw()}),this._rasterSurfaceWidth=0,this._rasterSurfaceHeight=0,this._rasterImageWidth=0,this._rasterImageHeight=0,this._isRasterizing=!1,this._rasterizedResult=null,this._forceRaster=!1,this._hadError=!1}Release(){if(this._refCount<=0)throw new Error("already released");this._refCount--,0===this._refCount&&this._Release()}ReleaseRasterizedResult(){this._rasterizedResult&&(this._manager.ReleaseResult(this._rasterizedResult),this._rasterizedResult=null)}_Release(){this.ReleaseRasterizedResult(),this._manager._RemoveImage(this),this._manager=null}GetDataSource(){return this._dataSource}IncReference(){this._refCount++}HasReferences(){return 0<this._refCount}GetRasterizedResult(){return this._rasterizedResult}ForceRasterAgain(){this._forceRaster=!0}async StartRasterForSize(i,n,r){if(0!==n&&0!==r&&!this._hadError&&!this._isRasterizing){let e=C33.nextHighestPowerOfTwo(Math.ceil(n)),t=C33.nextHighestPowerOfTwo(Math.ceil(r)),s=Math.max(e,t);if(s>MAX_SURFACE_SIZE){const a=MAX_SURFACE_SIZE/s;n*=a,r*=a,e=Math.min(Math.ceil(e*a),MAX_SURFACE_SIZE),t=Math.min(Math.ceil(t*a),MAX_SURFACE_SIZE)}if(n<e&&r<t){const o=n/r,l=e/t;r=o<l?(n=t*o,t):(n=e)/o}if(this._manager.IsNpotSurfaceAllowed()&&(e=Math.ceil(n),t=Math.ceil(r)),!(e<=this._rasterSurfaceWidth&&t<=this._rasterSurfaceHeight)||this._forceRaster){this._isRasterizing=!0,this._rasterSurfaceWidth=e,this._rasterSurfaceHeight=t;const h=await this._manager.RasterAtSize(this._dataSource,i,this._rasterSurfaceWidth,this._rasterSurfaceHeight,n,r);this._manager&&(this.ReleaseRasterizedResult(),this._rasterizedResult=h,this._rasterImageWidth=n,this._rasterImageHeight=r,this._isRasterizing=!1,this._forceRaster=!1,this._manager.Redraw())}}}WhenBaseSizeReady(){return this._getBaseSizePromise}GetBaseWidth(){return this._baseWidth}GetBaseHeight(){return this._baseHeight}GetRasterWidth(){return this._rasterImageWidth}GetRasterHeight(){return this._rasterImageHeight}HadError(){return this._hadError}}}{let lookupHtmlEntity2=function(e){return HTML_ENTITY_MAP.get(e)};lookupHtmlEntity=lookupHtmlEntity2;const C33=self.C3,NUMERIC_CHARS=(C33.UTF8_BOM="\ufeff",new Set("0123456789")),WHITESPACE_CHARS=(C33.IsNumericChar=function(e){return NUMERIC_CHARS.has(e)},new Set(" \t\n\r \u2028\u2029 "));C33.IsWhitespaceChar=function(e){return WHITESPACE_CHARS.has(e)},C33.FilterWhitespace=function(e){return[...e].filter(e=>!C33.IsWhitespaceChar(e)).join("")},C33.IsStringAllWhitespace=function(e){for(const t of e)if(!C33.IsWhitespaceChar(t))return!1;return!0},C33.IsCharArrayAllWhitespace=function(e){for(const t of e)if(!C33.IsWhitespaceChar(t))return!1;return!0},C33.IsUnprintableChar=function(e){return 1===e.length&&e.charCodeAt(0)<32},C33.FilterUnprintableChars=function(e){return[...e].filter(e=>!C33.IsUnprintableChar(e)).join("")};let cjkPunctuationRegex=null;try{cjkPunctuationRegex=new RegExp("\\p{P}(?<=[\\u3000-\\u303F\\uFF00-\\uFFEF])","u")}catch(t){console.warn("Unable to detect CJK punctuation: ",t)}C33.IsCJKPunctuationChar=function(e){return!C33.IsWhitespaceChar(e)&&cjkPunctuationRegex&&cjkPunctuationRegex.test(e)};const NUMERIC_STRING_CHARS=new Set("0123456789.+-e"),HTML_ENTITY_MAP=(C33.IsStringNumber=function(t){if(!(t=t.trim()).length)return!1;let e=t.charAt(0);if("-"!==e&&!NUMERIC_CHARS.has(e))return!1;for(let e of t)if(!NUMERIC_STRING_CHARS.has(e))return!1;return!0},C33.RemoveTrailingDigits=function(t){let s=t.length;for(;0<s;){let e=t.charAt(s-1);if(!C33.IsNumericChar(e))break;--s}return t.substr(0,s)},C33.IncrementNumberAtEndOf=function(e){let t=C33.RemoveTrailingDigits(e),s=e.substr(t.length);return t+(s?(parseInt(s,10)+1).toString():"2")},new Map([["&","&"],["<","<"],[">",">"],['"',"""],["'","'"]])),HTML_ENTITY_REGEX=/[&<>"']/g,ESCAPE_REGEX=(C33.EscapeHTML=function(e){return e.replace(HTML_ENTITY_REGEX,lookupHtmlEntity2)},C33.EscapeJS=function(e){let t=C33.ReplaceAll(e,"\\","\\\\");return t=C33.ReplaceAll(t,'"','\\"'),t=C33.ReplaceAll(t,"\t","\\t"),t=C33.ReplaceAll(t,"\r",""),C33.ReplaceAll(t,"\n","\\n")},C33.EscapeXML=function(e){let t=C33.ReplaceAll(e,"&","&");return t=C33.ReplaceAll(t,"<","<"),t=C33.ReplaceAll(t,">",">"),C33.ReplaceAll(t,'"',""")},/[-[\]{}()*+?.,\\^$|#\s]/g),intlSegmenter=(C33.EscapeRegex=function(e){return e.replace(ESCAPE_REGEX,"\\$&")},C33.CountCharsInString=function(e,t){let s=0;for(const i of e)i===t&&++s;return s},C33.FindAll=function(e,t,s=!1){if(!t)return[];s||(e=e.toLowerCase(),t=t.toLowerCase());let i=t.length,n=0,r,a=[];for(;-1<(r=e.indexOf(t,n));)a.push(r),n=r+i;return a},C33.ReplaceAll=function(e,t,s){return e.replaceAll(t,()=>s)},C33.ReplaceAllCaseInsensitive=function(e,t,s){return e.replace(new RegExp(C33.EscapeRegex(t),"gi"),()=>s)},C33.SetElementContent=function(e,t){"string"==typeof t?e.textContent=t:t.isPlainText()?e.textContent=t.toString():(e.innerHTML=t.toHTML(),t instanceof C33.BBString&&t.attachLinkHandlers(e))},C33.StringLikeEquals=function(e,t){return e instanceof C33.HtmlString||e instanceof C33.BBString?e.equals(t):t instanceof C33.HtmlString||t instanceof C33.BBString?t.equals(e):e===t},C33.StringSubstitute=function(s,...i){let n=s;for(let e=0,t=i.length;e<t;++e){const r=`{${e}}`;if(!s.includes(r))throw new Error(`missing placeholder '${r}' in string substitution`);n=n.replace(r,i[e].toString())}return n},C33.StringSubstituteAllowMissing=function(s,...i){let n=s,r=-1,a=-1;for(let e=0,t=i.length;e<t;++e){const o=`{${e}}`;s.includes(o)?(a=e,n=n.replace(o,i[e].toString())):-1===r&&(r=e)}if(0<=r&&0<=a&&r<a)throw new Error(`missing placeholder '${r}' in string substitution`);return n},C33.StringSubstituteMap=function(e,s){let i=e;for(let[e,t]of Object.entries(s))i=i.replaceAll(e,t.toString());return i},C33.SortAZ=function(e,t){return t<e?1:e<t?-1:0},C33.SortAZCaseInsensitive=function(e,t){let s=e.toLowerCase(),i=t.toLowerCase();return i<s?1:s<i?-1:0},new self.Intl.Segmenter),KILOBYTE=(C33.SplitGraphemes=function(e){const t=[];for(const s of intlSegmenter.segment(e))t.push(s.segment);return t},C33.IterateGraphemes=function*(e){for(const t of intlSegmenter.segment(e))yield t.segment},C33.CountGraphemes=function(e){let t=0;for(const s of intlSegmenter.segment(e))++t;return t},1024),MEGABYTE=1024*KILOBYTE,GIGABYTE=1024*MEGABYTE,TERABYTE=1024*GIGABYTE,DEFAULT_FORMATTIME_OPTS={approximate:(C33.FormatDataSize=function(t,e){let s="common."+(e?"dataRates":"dataSizes")+".",i=self.langSub;if(t<KILOBYTE)return i(s+"bytes",t);if(t<MEGABYTE){let e=t/KILOBYTE;return e=e<10?Math.round(10*e)/10:Math.round(e),i(s+"kilobytes",e)}if(t<GIGABYTE){let e=t/MEGABYTE;return e=e<10?Math.round(10*e)/10:Math.round(e),i(s+"megabytes",e)}if(t<TERABYTE){let e=t/GIGABYTE;return e=e<10?Math.round(10*e)/10:Math.round(e),i(s+"gigabytes",e)}{let e=t/TERABYTE;return e=e<10?Math.round(10*e)/10:Math.round(e),i(s+"terabytes",e)}},!1),days:!0,hours:!0,minutes:!0,seconds:!0};C33.FormatTime=function(e,t){t=Object.assign({},DEFAULT_FORMATTIME_OPTS,t),C33.Lang.PushContext("common.time");const s=[],i=self.lang,n=self.langPluralSub;if(t.days){const a=Math.floor(e/86400);0<a&&(e-=24*a*3600,s.push(n(".days",null,a)))}if(t.hours){const o=Math.floor(e/3600);(0<o||s.length)&&(e-=3600*o,s.push(n(".hours",null,o)))}if(t.minutes){const l=Math.floor(e/60);(0<l||s.length||!t.seconds)&&(e-=60*l,s.push(n(".minutes",null,l)))}if(t.seconds){const h=Math.floor(e%60);s.push(n(".seconds",null,h))}const r=(t.approximate?i(".approx-prefix"):"")+s.join(i(".separator"));return C33.Lang.PopContext(),r},C33.ZeroPad=function(e,t){let s=e<0?"-":"",i=(e=Math.abs(e)).toString(),n=t-i.length;for(let e=0;e<n;++e)s+="0";return s+i},C33.StringToTitleCase=function(e){return e.toLowerCase().replace(/\b\w/g,e=>e.toUpperCase())},C33.CompareVersionStrings=function(e,t){let s=e.split(".").map(e=>e.trim()),i=t.split(".").map(e=>e.trim());C33.resizeArray(s,4,"0"),C33.resizeArray(i,4,"0"),s=s.map(e=>parseInt(e,10)),i=i.map(e=>parseInt(e,10));for(let e=0;e<4;++e){const n=s[e]-i[e];if(0!=n)return n<0?-1:1}return 0},C33.CreateGUID=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.floor(16*Math.random()),s="x"===e?t:3&t|8;return s.toString(16)})},C33.StringHammingDistance=function(s,i){if(s.length!==i.length)throw new Error("strings must be same length");let n=0;for(let e=0,t=s.length;e<t;++e)s.charAt(e)!==i.charAt(e)&&++n;return n},C33.StringLevenshteinDistance=function(e,t){if(0===e.length)return t.length;if(0===t.length)return e.length;let s,i,n,r,a,o;for(t.length<e.length&&(s=e,e=t,t=s),o=Array(e.length+1),i=0;i<=e.length;i++)o[i]=i;for(i=1;i<=t.length;i++){for(r=i,n=1;n<=e.length;n++)a=t[i-1]===e[n-1]?o[n-1]:Math.min(o[n-1]+1,Math.min(r+1,o[n]+1)),o[n-1]=r,r=a;o[e.length]=r}return o[e.length]}}{let bbToHtmlReplacerFunc2=function(e,s,i){const n=BB_CODE_MAP.get(i);if(!n)return"class"===i?s?"</span>":`<span class="bbclass${classIndex++}">`:e;if("string"==typeof n){if("a"===n&&0===linkActions.length||"abbr"===n&&0===tipList.length)return e;if("a"!==n||s){if("abbr"!==n||s)return"<"+s+n+">";{const r=parseInt(i.substring(3),10)-1;if(r<0||r>=tipList.length)throw new Error("invalid bbcode tip substitution");let e=tipList[r],t="";if("string"==typeof e?t=e:"function"==typeof e&&(t=e()),"string"!=typeof t)throw new TypeError("invalid bbcode tip");return`<abbr title="${C33.ReplaceAll(t,'"',""")}">`}}{const t=parseInt(i.substring(1),10)-1;if(t<0||t>=linkActions.length)throw new Error("invalid bbcode link substitution");const a=linkActions[t];if("string"==typeof a)return`<a href="${linkActions[t]}">`;if("function"==typeof a)return`<a class="bblink${t}">`;throw new TypeError("invalid bbcode link action")}}if(Array.isArray(n)){let e=n[0],t=n[1];return s?"</"+e+">":`<${e} class="${t}">`}},C33=(bbToHtmlReplacerFunc=bbToHtmlReplacerFunc2,self.C3),assert=self.assert,BB_CODE_MAP=new Map([["b","strong"],["i","em"],["s","s"],["u","u"],["sub","sub"],["sup","sup"],["small","small"],["mark","mark"],["code","code"],["a1","a"],["a2","a"],["a3","a"],["a4","a"],["a5","a"],["a6","a"],["a7","a"],["a8","a"],["a9","a"],["tip1","abbr"],["tip2","abbr"],["tip3","abbr"],["tip4","abbr"],["tip5","abbr"],["tip6","abbr"],["tip7","abbr"],["tip8","abbr"],["tip9","abbr"],["bad",["span","bbCodeBad"]],["good",["span","bbCodeGood"]],["info",["span","bbCodeInfo"]],["h1",["span","bbCodeH1"]],["h2",["span","bbCodeH2"]],["h3",["span","bbCodeH3"]],["h4",["span","bbCodeH4"]],["item",["span","bbCodeItem"]]]),SELF_CLOSING_TAGS=new Set(["icon"]),BBREGEX=/\[(\/?)([a-zA-Z0-9]+)\]/g,CUSTOM_BBREGEX=/\[(\/?)([^\[\n]*?)\]/g,linkActions=null,tipList=null,classIndex=0,LINEBREAK_REGEX=/\n/g;C33.BBString=class{constructor(e,t){if(this._bbstr=t&&t.noEscape?e:C33.EscapeHTML(e),this._htmlstr="",this._convertLineBreaks=!1,this._linkActions=[],this._tipList=[],t){if(this._convertLineBreaks=!!t.convertLineBreaks,t.links){if(9<t.links.length)throw new Error("too many links");this._linkActions=t.links}if(t.tips){if(9<t.tips.length)throw new Error("too many tips");this._tipList=t.tips}}this._hasAnyBBtags=this._bbstr.includes("["),this._needsLineBreakConversion=this._convertLineBreaks&&this._bbstr.includes("\n"),this._isPlain=!this._hasAnyBBtags&&!this._needsLineBreakConversion&&!this._bbstr.includes("&"),this._hasParsedFragments=!1,this._fragments=[]}toString(){return this._bbstr}valueOf(){return this._bbstr}isPlainText(){return this._isPlain}toPlainText(){return this._hasAnyBBtags?this._bbstr.replace(BBREGEX,""):this._bbstr}toHTML(){if(this._isPlain)return this._bbstr;if(!this._htmlstr&&this._bbstr){let e=this._bbstr;this._hasAnyBBtags&&(classIndex=0,linkActions=this._linkActions,tipList=this._tipList,e=e.replace(BBREGEX,bbToHtmlReplacerFunc2),linkActions=null,tipList=null),this._needsLineBreakConversion&&(e=e.replace(LINEBREAK_REGEX,"<br>")),this._htmlstr=e}return this._htmlstr}attachLinkHandlers(s){if(this._linkActions.length)for(let e=0,t=this._linkActions.length;e<t;++e){const i=this._linkActions[e];if("function"==typeof i){const n=s.querySelector(".bblink"+e);if(!n)throw new Error("unable to attach BBString link handler");n.onclick=i}}}equals(e){return e instanceof C33.HtmlString?this.toHTML()===e.toHTML():e instanceof C33.BBString?this._bbstr===e._bbstr:this._bbstr===e}toFragmentList(){if(!this._hasParsedFragments){let i=[],e=this._bbstr,n=[],t=CUSTOM_BBREGEX.lastIndex=0,s;for(;null!==(s=CUSTOM_BBREGEX.exec(e));){const r=s.index;if(!(0<r&&"\\"===e.charAt(r-1))){const a=s[0],o=s[1],l=s[2],h=e.substring(t,r);if(t=r+a.length,h&&i.push({text:h,styles:n.slice(0)}),l)if(o){const c=l.toLowerCase();for(let e=n.length-1;0<=e;--e)if(n[e].tag===c){n.splice(e,1);break}}else{let e=l,t=null,s=l.indexOf("=");if(-1!==s?(e=l.substring(0,s).toLowerCase(),t=l.substring(s+1)):e=e.toLowerCase(),SELF_CLOSING_TAGS.has(e)){if("icon"!==e)throw new Error("unknown self-closing tag "+e);i.push({icon:t,styles:n.slice(0)})}else n.push({tag:e,param:t})}}}t<e.length&&i.push({text:e.substring(t),styles:n.slice(0)});for(const u of i)u.text&&(u.text=this._ProcessBBCodeEscapeSequences(u.text));this._fragments=i.map(e=>e.icon?C33.New(C33.IconFragment,{icon:e.icon,styles:e.styles}):C33.New(C33.TextFragment,{chArr:C33.SplitGraphemes(e.text),styles:e.styles})),this._hasParsedFragments=!0}return this._fragments}_ProcessBBCodeEscapeSequences(e){return e=C33.ReplaceAll(e,"\\[","["),C33.ReplaceAll(e,"\\\\","\\")}static StripTags(e){return C33.New(C33.BBString,e,{noEscape:!0}).toPlainText()}static StripAnyTags(e){return e.replace(CUSTOM_BBREGEX,"")}}}{let IsWordBreakWhiteSpace2=function(e){return" "!==e&&" "!==e&&C33.IsWhitespaceChar(e)},IsOpeningCJKPunctiationChar2=function(e){return CJK_OPEN_PUNCTUATION.has(e)},IsContinuingCJKPunctuationChar2=function(e){return C33.IsCJKPunctuationChar(e)&&!IsOpeningCJKPunctiationChar2(e)},WordBreakTrimEnd2=function(e){for(;0<e.length&&IsWordBreakWhiteSpace2(e.at(-1));)e.pop()},IsNewline2=function(e){return"\n"===e||"\r\n"===e};IsWordBreakWhiteSpace=IsWordBreakWhiteSpace2,IsOpeningCJKPunctiationChar=IsOpeningCJKPunctiationChar2,IsContinuingCJKPunctuationChar=IsContinuingCJKPunctuationChar2,WordBreakTrimEnd=WordBreakTrimEnd2,IsNewline=IsNewline2;const C33=self.C3,CJK_OPEN_PUNCTUATION=new Set("〈《「『【〔〖〘〚〝");C33.WordWrap=class{constructor(){this._lines=[],this._iconSet=null}GetLines(){return this._lines}GetLineCount(){return this._lines.length}SetIconSet(e){this._iconSet=e}_MeasureLine(e,t){let s=0,i=0,n=0,r=0,a=0;for(const o of e){if(-1===o.GetWidth()){const l=t(o);o.SetHeight(l.height),o.SetFontBoundingBoxAscent(l.fontBoundingBoxAscent||0),o.SetFontBoundingBoxDescent(l.fontBoundingBoxDescent||0),o.SetTopToAlphabeticDistance(l.topToAlphabeticDistance||0),o.IsText()?o.SetWidth(l.width):o.IsIcon()&&o.CalculateWidthFromHeight(this._iconSet)}s+=o.GetWidth(),i=Math.max(i,o.GetHeight()),n=Math.max(n,o.GetFontBoundingBoxAscent()),r=Math.max(r,o.GetFontBoundingBoxDescent()),a=Math.max(a,o.GetTopToAlphabeticDistance())}return{width:s,height:i,fontBoundingBoxAscent:n,fontBoundingBoxDescent:r,topToAlphabeticDistance:a}}_AddLine(e,t,s,i,n,r){this._lines.push(C33.New(C33.WordWrap.Line,{fragments:e,width:t,height:s,fontBoundingBoxAscent:i,fontBoundingBoxDescent:n,topToAlphabeticDistance:r}))}WordWrap(t,r,a,s,o){if("string"==typeof t&&(t=[C33.New(C33.TextFragment,{chArr:C33.SplitGraphemes(t)})]),C33.clearArray(this._lines),!(!t.length||1===t.length&&t[0].IsText()&&t[0].IsEmpty()||a<2)){if(1===t.length){const l=t[0];if(l.IsText()&&l.GetLength()<=100&&!l.HasNewLine()){let{width:e,height:t,fontBoundingBoxAscent:s,fontBoundingBoxDescent:i,topToAlphabeticDistance:n}=r(l);if(e+=o,l.SetWidth(e),l.SetHeight(t),l.SetFontBoundingBoxAscent(s||0),l.SetFontBoundingBoxDescent(i||0),l.SetTopToAlphabeticDistance(n||0),e<=a)return void this._AddLine([l],e,t,s,i,n)}}let e;e="word"===s?this._TokeniseByWord(t):"cjk"===s?this._TokeniseByCJK(t):this._TokeniseByChar(t),this._WrapText(e,r,a,o)}}_TokeniseByWord(e){let t=[],s=[],i=!1;for(const n of e){const r=n.GetStyles();if(n.IsIcon())0<s.length&&t.push(s),t.push([n]),s=[];else for(const a of n.GetCharacterArray())if(IsNewline2(a))0<s.length&&t.push(s),t.push([C33.New(C33.TextFragment,{chArr:["\n"],styles:r})]),s=[];else if(0===s.length)s.push(C33.New(C33.TextFragment,{chArr:[a],styles:r})),i=IsWordBreakWhiteSpace2(a);else{const o=IsWordBreakWhiteSpace2(a);if(o===i){const l=s.at(-1);l.GetStyles()===r?l._AppendChar(a):s.push(C33.New(C33.TextFragment,{chArr:[a],styles:r}))}else t.push(s),s=[C33.New(C33.TextFragment,{chArr:[a],styles:r})],i=o}}return 0<s.length&&t.push(s),t}_TokeniseByCJK(e){let t=[],s=[],i=!1;for(const n of e){const r=n.GetStyles();if(n.IsIcon())0<s.length&&t.push(s),t.push([n]),s=[];else for(const a of n.GetCharacterArray())if(IsNewline2(a))0<s.length&&t.push(s),t.push([C33.New(C33.TextFragment,{chArr:["\n"],styles:r})]),s=[];else{if(0===s.length)s.push(C33.New(C33.TextFragment,{chArr:[a],styles:r}));else if(i||IsContinuingCJKPunctuationChar2(a)){const o=s.at(-1);o.GetStyles()===r?o._AppendChar(a):s.push(C33.New(C33.TextFragment,{chArr:[a],styles:r}))}else t.push(s),s=[C33.New(C33.TextFragment,{chArr:[a],styles:r})];i=IsOpeningCJKPunctiationChar2(a)}}return 0<s.length&&t.push(s),t}_TokeniseByChar(e){const t=[];for(const s of e)if(s.IsText()){const i=s.GetCharacterArray();C33.appendArray(t,i.map(e=>[C33.New(C33.TextFragment,{chArr:[e],styles:s.GetStyles()})]))}else t.push([s]);return t}_CopyLine(e){return e.map(e=>e._Clone())}_AddWordToLine(t,s){let e=t.length?t.at(-1):null,i=0;e&&e.IsText()&&s[0].IsText()&&s[0].GetStyles()===e.GetStyles()&&(e._Append(s[0].GetCharacterArray()),i=1);for(let e=s.length;i<e;++i){const n=s[i];t.push(n._Clone())}}_WrapText(e,t,s,i){let n=[],r=0,a=0,o=0,l=0,h=0;for(const c of e)if(1===c.length&&c[0].IsText()&&1===c[0].GetLength()&&IsNewline2(c[0].GetCharacterArray()[0])){if(0===a){const u=C33.New(C33.TextFragment,{chArr:[" "],styles:c[0].GetStyles()}),_=t(u);a=_.height,o=_.fontBoundingBoxAscent||0,l=_.fontBoundingBoxDescent||0,h=_.topToAlphabeticDistance||0}this._AddLine(n,r,a,o,l,h),n=[],r=0,a=0,o=0,l=0,h=0}else{const d=this._CopyLine(n),p=(this._AddWordToLine(d,c),this._MeasureLine(d,t)),m=p.width;if(s<=m)if(0<n.length&&this._AddLine(n,r,a,o,l,h),n=[],c[0].IsText()&&C33.IsCharArrayAllWhitespace(c[0].GetCharacterArray()))r=0,a=0,o=0,l=0,h=0;else{this._AddWordToLine(n,c);const g=this._MeasureLine(n,t);r=g.width,a=g.height,o=g.fontBoundingBoxAscent,l=g.fontBoundingBoxDescent,h=g.topToAlphabeticDistance}else n=d,r=m,a=p.height,o=p.fontBoundingBoxAscent,l=p.fontBoundingBoxDescent,h=p.topToAlphabeticDistance}0<n.length&&this._AddLine(n,r,a,o,l,h),this._TrimLinesTrailingWhitespace(t,i)}_TrimLinesTrailingWhitespace(t,s){for(const i of this._lines){const n=i._GetFragmentsArray();if(n.length){let e=n.at(-1);if(e.IsText()){const r=e.GetCharacterArray(),a=r.slice(0);if(WordBreakTrimEnd2(a),0===a.length)i.OffsetWidth(-e.GetWidth()),n.pop();else if(a.length<r.length){e.SetCharacterArray(a);const o=t(e).width,l=e.GetWidth()-o;e.SetWidth(o),i.OffsetWidth(-l)}0!==s&&0<n.length&&((e=n.at(-1)).OffsetWidth(s),i.OffsetWidth(s))}}}}Clear(){C33.clearArray(this._lines)}GetMaxLineWidth(){return this._lines.reduce((e,t)=>Math.max(e,t.GetWidth()),0)}GetTotalLineHeight(){return this._lines.reduce((e,t)=>e+t.GetHeight(),0)}}}{const C33=self.C3;C33.WordWrap.Line=class{constructor(e){this._fragments=e.fragments||[],this._width=e.width||-1,this._height=e.height||-1,this._fontBoundingBoxAscent=e.fontBoundingBoxAscent||-1,this._fontBoundingBoxDescent=e.fontBoundingBoxDescent||-1,this._topToAlphabeticDistance=e.topToAlphabeticDistance||-1,this._posX=0,this._posY=0}fragments(){return this._fragments.values()}*fragmentsReverse(){const t=this._fragments;for(let e=t.length-1;0<=e;--e)yield t[e]}_GetFragmentsArray(){return this._fragments}OffsetWidth(e){this._width+=e}GetWidth(){return this._width}GetHeight(){return this._height}GetFoundBoundingBoxAscent(){return this._fontBoundingBoxAscent}GetFontBoundingBoxDescent(){return this._fontBoundingBoxDescent}GetTopToAlphabeticDistance(){return this._topToAlphabeticDistance}SetPosX(e){this._posX=e}GetPosX(){return this._posX}SetPosY(e){this._posY=e}GetPosY(){return this._posY}}}{const C33=self.C3;C33.FragmentBase=class{constructor(e){this._styles=e.styles||[],this._width=e.width||-1,this._height=e.height||-1,this._fontBoundingBoxAscent=e.fontBoundingBoxAscent||-1,this._fontBoundingBoxDescent=e.fontBoundingBoxDescent||-1,this._topToAlphabeticDistance=e.topToAlphabeticDistance||-1,this._posX=0,this._posY=0}IsText(){return!1}IsIcon(){return!1}GetStyles(){return this._styles}GetStyleTag(t){const s=this._styles;for(let e=s.length-1;0<=e;--e){const i=s[e];if(i.tag===t)return i}return null}HasStyleTag(e){return!!this.GetStyleTag(e)}GetStyleMap(){const e=new Map;for(const t of this._styles)e.set(t.tag,t.param);return e}OffsetWidth(e){this._width+=e}SetWidth(e){this._width=e}GetWidth(){return this._width}SetHeight(e){this._height=e}GetHeight(){return this._height}SetFontBoundingBoxAscent(e){this._fontBoundingBoxAscent=e}GetFontBoundingBoxAscent(){return this._fontBoundingBoxAscent}SetFontBoundingBoxDescent(e){this._fontBoundingBoxDescent=e}GetFontBoundingBoxDescent(){return this._fontBoundingBoxDescent}SetTopToAlphabeticDistance(e){this._topToAlphabeticDistance=e}GetTopToAlphabeticDistance(){return this._topToAlphabeticDistance}SetPosX(e){this._posX=e}GetPosX(){return this._posX}SetPosY(e){this._posY=e}GetPosY(){return this._posY}}}{const C33=self.C3;C33.TextFragment=class extends C33.FragmentBase{constructor(e){super(e),this._chArr=e.chArr}IsText(){return!0}_Append(e){C33.appendArray(this._chArr,e),this._width=-1,this._height=-1,this._fontBoundingBoxAscent=-1,this._fontBoundingBoxDescent=-1,this._topToAlphabeticDistance=-1}_AppendChar(e){this._chArr.push(e)}_Clone(){return C33.New(C33.TextFragment,{chArr:this._chArr.slice(0),styles:this._styles,width:this._width,height:this._height,fontBoundingBoxAscent:this._fontBoundingBoxAscent,fontBoundingBoxDescent:this._fontBoundingBoxDescent,topToAlphabeticDistance:this._topToAlphabeticDistance})}GetCharacterArray(){return this._chArr}SetCharacterArray(e){this._chArr=e}GetLength(){return this._chArr.length}IsEmpty(){return 0===this._chArr.length}HasNewLine(){return this._chArr.includes("\n")}}}{const C33=self.C3;C33.IconFragment=class extends C33.FragmentBase{constructor(e){super(e),this._icon=e.icon}IsIcon(){return!0}GetIconParameter(){return this._icon}_Clone(){return C33.New(C33.IconFragment,{icon:this._icon,styles:this._styles,width:this._width,height:this._height,fontBoundingBoxAscent:this._fontBoundingBoxAscent,fontBoundingBoxDescent:this._fontBoundingBoxDescent,topToAlphabeticDistance:this._topToAlphabeticDistance})}GetTextIcon(e){if(!e)return null;let t=Number(this._icon);return String(t)===this._icon?(t=Math.floor(t),e.GetTextIconByIndex(t)):e.GetTextIconByTag(this._icon)}CalculateWidthFromHeight(e){const t=this.GetTextIcon(e);this._width=t?this._height*t.GetWidth()/t.GetHeight():0}GetDrawable(e){const t=this.GetTextIcon(e);return t?t.GetDrawable():null}GetLength(){return 1}}}{const C33=self.C3;C33.TextIconManager=class{constructor(e){this._iconSets=new Map,this._getIconSetMetaCallback=e.getIconSetMeta,this._getIconSetContentCallback=e.getIconSetContent}Release(){for(const e of this._iconSets.values())e.Release();this._iconSets.clear()}GetIconSet(e){let t=this._iconSets.get(e);if(!t){const s=this._getIconSetMetaCallback(e);t=C33.New(C33.TextIconSet,this,{source:e,iconMeta:s}),this._iconSets.set(e,t)}return t}HasIconSet(e){return this._iconSets.has(e)}DeleteIconSet(e){const t=this._iconSets.get(e);t&&t.Release(),this._iconSets.delete(e)}async _GetIconSetContent(e){return this._getIconSetContentCallback(e)}}}{const C33=self.C3;C33.TextIconSet=class{constructor(e,t){this._textIconManager=e,this._source=t.source,this._iconsArray=[],this._iconsByTag=new Map,this._hasStartedLoad=!1,this._isLoading=!1,this._loadPromise=null;const s=t.iconMeta.icons;for(let e=0,t=s.length;e<t;++e){const i=s[e],n=C33.New(C33.TextIcon,this,{index:e,tag:i.tag,source:i.source,width:i.width,height:i.height});this._iconsArray.push(n),i.tag&&this._iconsByTag.set(i.tag.toLowerCase(),n)}}Release(){for(const e of this._iconsArray)e.Release();C33.clearArray(this._iconsArray),this._iconsByTag.clear(),this._textIconManager=null,this._source=null}HasLoaded(){return this._hasStartedLoad}IsLoading(){return this._isLoading}LoadContent(){return this._loadPromise||(this._loadPromise=this._DoLoadContent()),this._loadPromise}async _DoLoadContent(){if(!this._hasStartedLoad){this._hasStartedLoad=!0,this._isLoading=!0;const e=await this._textIconManager._GetIconSetContent(this._source);if(this._textIconManager){const s=e.icons;for(let e=0,t=Math.min(s.length,this._iconsArray.length);e<t;++e){const i=s[e].drawable;this._iconsArray[e]._SetDrawable(i)}this._isLoading=!1}}}GetTextIconByIndex(e){return(e=Math.floor(e))<0||e>=this._iconsArray.length?null:this._iconsArray[e]}GetTextIconByTag(e){return this._iconsByTag.get(e.toLowerCase())||null}}}{const C33=self.C3;C33.TextIcon=class{constructor(e,t){this._textIconSet=e,this._source=t.source||null,this._index=t.index,this._tag=t.tag,this._width=t.width,this._height=t.height,this._drawable=null}Release(){this._width=0,this._height=0,this._textIconSet=null}GetSource(){return this._source}GetWidth(){return this._width}GetHeight(){return this._height}_SetDrawable(e){this._drawable=e}GetDrawable(){return this._drawable}}}{let PlaneFromPoints2=function(e,t,s,i){const n=tempVec3c;vec32.subtract(tempVec3a,s,t),vec32.subtract(tempVec3b,e,t),vec32.cross(n,tempVec3a,tempVec3b),vec32.normalize(n,n),i.set(n[0],n[1],n[2],vec32.dot(e,n))},IsInFrontOfPlane2=function(e,t,s,i,n,r,a){const o=a.x,l=a.y,h=a.z,c=a.w,u=a.xF,_=a.yF,d=a.zF,p=1-u,m=1-_,g=1-d,f=o*e*u+o*i*p+l*t*_+l*n*m+h*s*d+h*r*g;if(c<=f)return!0;const S=o*i*u+o*e*p+l*n*_+l*t*m+h*r*d+h*s*g;return c<S},IsPointInFrontOfPlane2=function(e,t,s,i){const n=i.x,r=i.y,a=i.z,o=i.w,l=n*e+r*t+a*s;return o<=l};PlaneFromPoints=PlaneFromPoints2,IsInFrontOfPlane=IsInFrontOfPlane2,IsPointInFrontOfPlane=IsPointInFrontOfPlane2;const C33=self.C3,glMatrix=self.glMatrix,vec32=glMatrix.vec3,vec42=glMatrix.vec4,mat42=glMatrix.mat4,tempVec3a=vec32.create(),tempVec3b=vec32.create(),tempVec3c=vec32.create(),tempVec4=vec42.create(),tempMat4=mat42.create(),neartl=vec32.create(),neartr=vec32.create(),nearbl=vec32.create(),nearbr=vec32.create(),fartl=vec32.create(),fartr=vec32.create(),farbl=vec32.create(),farbr=vec32.create(),unitViewport=vec42.fromValues(0,0,1,1);C33.Gfx={Project(e,t,s,i,n,r,a){let o=i[0]*e+i[4]*t+i[8]*s+i[12],l=i[1]*e+i[5]*t+i[9]*s+i[13],h=i[2]*e+i[6]*t+i[10]*s+i[14],c=i[3]*e+i[7]*t+i[11]*s+i[15],u=n[0]*o+n[4]*l+n[8]*h+n[12]*c,_=n[1]*o+n[5]*l+n[9]*h+n[13]*c,d=n[2]*o+n[6]*l+n[10]*h+n[14]*c,p=n[3]*o+n[7]*l+n[11]*h+n[15]*c;return 0!=p&&(_*=p=1/p,d*=p,a[0]=(.5*(u*=p)+.5)*r[2]+r[0],a[1]=(.5*_+.5)*r[3]+r[1],a[2]=.5*(1+d),!0)},Unproject(e,t,s,i,n,r,a){const o=tempMat4,l=tempVec4;return mat42.multiply(o,n,i),null!==mat42.invert(o,o)&&(l[0]=(e-r[0])/r[2]*2-1,l[1]=(t-r[1])/r[3]*2-1,l[2]=2*s-1,l[3]=1,vec42.transformMat4(l,l,o),0!==l[3])&&(l[3]=1/l[3],a[0]=l[0]*l[3],a[1]=l[1]*l[3],a[2]=l[2]*l[3],!0)},UnprojectScreenToWorldZ(e,t,s,i,n,r,a){const o=tempVec3a,l=tempVec3b;if(!C33.Gfx.Unproject(e,t,0,i,n,r,o))return!1;if(!C33.Gfx.Unproject(e,t,1,i,n,r,l))return!1;let h=tempVec3b,c=(vec32.subtract(h,l,o),tempVec3c),u=(vec32.set(c,0,0,1),-s),_=vec32.dot(c,h),d=0;if(0===_){const p=vec32.dot(c,o)+u;if(0!==p)return!1}else if((d=-(vec32.dot(o,c)+u)/_)<0)return!1;return vec32.scaleAndAdd(a,o,h,d),!0}};class Plane{constructor(){this.x=NaN,this.y=NaN,this.z=NaN,this.w=NaN,this.xF=NaN,this.yF=NaN,this.zF=NaN}set(e,t,s,i){this.x=e,this.y=t,this.z=s,this.w=i,this.xF=0<e?1:0,this.yF=0<t?1:0,this.zF=0<s?1:0}}C33.Gfx.ViewFrustum=class{constructor(){this._leftP=new Plane,this._topP=new Plane,this._rightP=new Plane,this._bottomP=new Plane,this._nearP=new Plane,this._farP=new Plane}CalculatePlanes(e,t){const s=unitViewport;C33.Gfx.Unproject(0,1,0,e,t,s,neartl),C33.Gfx.Unproject(1,1,0,e,t,s,neartr),C33.Gfx.Unproject(0,0,0,e,t,s,nearbl),C33.Gfx.Unproject(1,0,0,e,t,s,nearbr),C33.Gfx.Unproject(0,1,1,e,t,s,fartl),C33.Gfx.Unproject(1,1,1,e,t,s,fartr),C33.Gfx.Unproject(0,0,1,e,t,s,farbl),C33.Gfx.Unproject(1,0,1,e,t,s,farbr),PlaneFromPoints2(nearbl,neartl,fartl,this._leftP),PlaneFromPoints2(neartl,neartr,fartr,this._topP),PlaneFromPoints2(neartr,nearbr,farbr,this._rightP),PlaneFromPoints2(nearbr,nearbl,farbl,this._bottomP),PlaneFromPoints2(farbl,fartl,fartr,this._farP),PlaneFromPoints2(nearbr,neartr,neartl,this._nearP)}ContainsAABB(e,t,s,i,n,r){return IsInFrontOfPlane2(e,t,s,i,n,r,this._leftP)&&IsInFrontOfPlane2(e,t,s,i,n,r,this._topP)&&IsInFrontOfPlane2(e,t,s,i,n,r,this._rightP)&&IsInFrontOfPlane2(e,t,s,i,n,r,this._bottomP)&&IsInFrontOfPlane2(e,t,s,i,n,r,this._nearP)&&IsInFrontOfPlane2(e,t,s,i,n,r,this._farP)}IsBehindNearPlane(e,t,s){return!IsPointInFrontOfPlane2(e,t,s,this._nearP)}}}{const C33=self.C3,glMatrix=self.glMatrix,vec32=glMatrix.vec3,vec42=glMatrix.vec4,mat42=glMatrix.mat4,tempMat4=mat42.create(),tmpVec3a=vec32.fromValues(0,0,0),tmpVec3b=vec32.fromValues(0,0,0),tmpVec3c=vec32.fromValues(0,0,0),defaultUpVector=vec32.fromValues(0,1,0),tmpVec4=vec42.fromValues(0,0,0,0),tmpQuad=new C33.Quad,tmpRect=new C33.Rect,defaultTexCoordsQuad=new C33.Quad(0,0,1,0,1,1,0,1),DEFAULT_RENDERERBASE_OPTS={nearZ:1,farZ:1e4},matWebGLtoWebGPU=mat42.fromValues(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1);C33.Gfx.RendererBase=class{constructor(e){e=Object.assign({},DEFAULT_RENDERERBASE_OPTS,e),this._width=0,this._height=0,this._fovY=C33.toRadians(45),this._tan_fovY_2=Math.tan(this._fovY/2),this._matP=mat42.create(),this._matMV=mat42.create(),this._zAxisScale=!1,this._nearZ=e.nearZ,this._farZ=e.farZ,this._allShaderPrograms=[],this._shaderProgramsByName=new Map,this._spTextureFill=null,this._spPoints=null,this._spTilemapFill=null,this._spTileRandomization=null,this._spColorFill=null,this._spLinearGradientFill=null,this._spPenumbraFill=null,this._spHardEllipseFill=null,this._spHardEllipseOutline=null,this._spSmoothEllipseFill=null,this._spSmoothEllipseOutline=null,this._spSmoothLineFill=null,this._stateGroups=new Map,this._currentStateGroup=null,this._blendModeTable=[],this._namedBlendModeMap=new Map,this._baseZ=0,this._currentZ=0,this._lineWidth=1,this._lineWidthStack=[this._lineWidth],this._lineCap=1,this._lineCapStack=[this._lineCap],this._lineOffset=.5,this._lineOffsetStack=[this._lineOffset],this._frameNumber=0,this._enableMipmaps=!0,this._hasMajorPerformanceCaveat=!1}FillIndexBufferData(e){let t=0,s=e.length,i=0;for(;t<s;)e[t++]=i,e[t++]=i+1,e[t++]=i+2,e[t++]=i,e[t++]=i+2,e[t++]=i+3,i+=4}_ClearState(){this._baseZ=0,this._currentZ=0,this._spTextureFill=null,this._spPoints=null,this._spTilemapFill=null,this._spTileRandomization=null,this._spColorFill=null,this._spLinearGradientFill=null,this._spPenumbraFill=null,this._spHardEllipseFill=null,this._spHardEllipseOutline=null,this._spSmoothEllipseFill=null,this._spSmoothEllipseOutline=null,this._spSmoothLineFill=null,this._ClearAllShaderPrograms()}InitState(){this._ClearState(),this._currentStateGroup=null}OnDeviceOrContextLost(){for(const e of this._allShaderPrograms)e.Release();this._ClearState()}GetWidth(){return this._width}GetHeight(){return this._height}GetDefaultCameraZ(e){return this.IsZAxisScaleNormalized()?100:e/(2*this._GetTanFovYDiv2())}GetZAxisScaleFactor(e){if(this.IsZAxisScaleNormalized()){const t=e/(2*this._GetTanFovYDiv2());return t/this.GetDefaultCameraZ(e)}return 1}SetNearZ(e){this._nearZ=e}GetNearZ(){return this._nearZ}SetFarZ(e){this._farZ=e}GetFarZ(){return this._farZ}SetFovY(e){this._fovY=e,this._tan_fovY_2=Math.tan(this._fovY/2)}GetFovY(){return this._fovY}_GetTanFovYDiv2(){return this._tan_fovY_2}SetZAxisScaleNormalized(){this._zAxisScale=!1}SetZAxisScaleRegular(){this._zAxisScale=!0}IsZAxisScaleNormalized(){return!this._zAxisScale}IsZAxisScaleRegular(){return this._zAxisScale}CalculatePerspectiveMatrix(e,t,s=.5,i=.5){const n=this.GetNearZ(),r=this.GetFarZ(),a=this.GetFovY();if(.5===s&&.5===i)this.IsWebGPU()?mat42.perspectiveZO(e,a,t,n,r):mat42.perspective(e,a,t,n,r);else{const o=2*(s=1-s)-2,l=2*s,h=2*i-2,c=2*i,u=this._GetTanFovYDiv2()*n,_=u*t;mat42.frustum(e,o*_,l*_,h*u,c*u,n,r),this.IsWebGPU()&&mat42.mul(e,matWebGLtoWebGPU,e)}}CalculateOrthographicMatrix(e,t,s,i=1){const n=self.devicePixelRatio,r=2*this.GetDefaultCameraZ(s)*n*this._GetTanFovYDiv2()/s,a=t*r/(2*n*i),o=s*r/(2*n*i),l=-a,h=a,c=-o,u=o;this.IsWebGPU()?mat42.orthoZO(e,l,h,c,u,this.GetNearZ(),this.GetFarZ()):mat42.ortho(e,l,h,c,u,this.GetNearZ(),this.GetFarZ())}CalculateLookAtModelView(e,t,s,i,n,r=1){let a=1;this.IsZAxisScaleNormalized()&&(a=200*this._GetTanFovYDiv2()/n);const o=tmpVec3c,l=(vec32.set(o,a,-a,1),tmpVec3a),h=tmpVec3b;vec32.multiply(l,t,o),vec32.multiply(h,s,o),mat42.lookAt(e,l,h,i||defaultUpVector),o[2]=r,mat42.scale(e,e,o)}CalculateLookAtModelView2(e,t,s,i,n,r,a,o){return vec32.set(tmpVec3a,e,t,s),vec32.set(tmpVec3b,i,n,r),this.CalculateLookAtModelView(tempMat4,tmpVec3a,tmpVec3b,defaultUpVector,a,o),tempMat4}_AddShaderProgram(e){this._allShaderPrograms.push(e),this._shaderProgramsByName.set(e.GetName(),e)}_RemoveShaderProgram(e){const t=this._allShaderPrograms.indexOf(e);-1!==t&&this._allShaderPrograms.splice(t,1),this._shaderProgramsByName.delete(e.GetName())}_ClearAllShaderPrograms(){C33.clearArray(this._allShaderPrograms),this._shaderProgramsByName.clear()}GetShaderProgramByName(e){return this._shaderProgramsByName.get(e)||null}GetTextureFillShaderProgram(){return this._spTextureFill}SetTextureFillMode(){this.SetProgram(this._spTextureFill)}GetPointsRenderingProgram(){return this._spPoints}SetPointsRenderingProgram(){this.SetProgram(this._spPoints)}SetTilemapFillMode(){this.SetProgram(this._spTilemapFill)}SetTileRandomizationMode(){this.SetProgram(this._spTileRandomization)}SetColorFillMode(){this.SetProgram(this._spColorFill)}SetLinearGradientFillMode(){this.SetProgram(this._spLinearGradientFill)}SetPenumbraFillMode(){this.SetProgram(this._spPenumbraFill)}SetHardEllipseFillMode(){this.SetProgram(this._spHardEllipseFill)}SetHardEllipseOutlineMode(){this.SetProgram(this._spHardEllipseOutline)}SetSmoothEllipseFillMode(){this.SetProgram(this._spSmoothEllipseFill)}SetSmoothEllipseOutlineMode(){this.SetProgram(this._spSmoothEllipseOutline)}SetSmoothLineFillMode(){this.SetProgram(this._spSmoothLineFill)}_SetCurrentStateGroup(e){this._currentStateGroup=e}GetCurrentStateGroup(){return this._currentStateGroup}AcquireStateGroup(e,t,s,i){let n=C33.Gfx.StateGroup.MakeKey(e,t,s,i),r=this._stateGroups.get(n);return r||(r=C33.New(C33.Gfx.StateGroup,this,e,t,s,i),this._stateGroups.set(n,r)),r.AddRef(),r}ReleaseStateGroup(e){e.DecRef(),0===e._GetRefCount()&&(this._currentStateGroup===e&&(this._currentStateGroup=null),this._stateGroups.delete(e.GetKey()),e.Release())}_InitBlendModeData(e){C33.clearArray(this._blendModeTable),this._namedBlendModeMap.clear();let t=0;for(const s of e){const i=s[0],n=s[1],r=s[2];this._blendModeTable.push([n,r]),this._namedBlendModeMap.set(i,{number:t,srcBlend:n,destBlend:r}),t++}}_GetBlendByIndex(e){return this._blendModeTable[e]}GetSrcBlendByIndex(e){return this._GetBlendByIndex(e)[0]}GetDestBlendByIndex(e){return this._GetBlendByIndex(e)[1]}GetNamedBlend(e){const t=this._namedBlendModeMap.get(e);if(void 0===t)throw new Error("invalid blend name");return t}NamedBlendToNumber(e){const t=this._namedBlendModeMap.get(e);if(void 0===t)throw new Error("invalid blend name");return t.number}SetBaseZ(e){this._baseZ=e}GetBaseZ(){return this._baseZ}SetCurrentZ(e){this._currentZ=e,this._currentStateGroup=null}GetCurrentZ(){return this._currentZ}Line(e,t,s,i){const n=C33.angleTo(e,t,s,i),r=Math.sin(n),a=Math.cos(n),o=.5*this._lineWidth,l=r*o,h=a*o,c=this._lineCap;2===c?this.LinePreCalc_LineCap2(e,t,0,s,i,0,l,h):1===c?this.LinePreCalc_LineCap1(e,t,0,s,i,0,l,h):this.LinePreCalc_LineCap0(e,t,0,s,i,0,l,h)}Line3D(e,t,s,i,n,r){const a=C33.angleTo(e,t,i,n),o=Math.sin(a),l=Math.cos(a),h=.5*this._lineWidth,c=o*h,u=l*h,_=this._lineCap;2===_?this.LinePreCalc_LineCap2(e,t,s,i,n,r,c,u):1===_?this.LinePreCalc_LineCap1(e,t,s,i,n,r,c,u):this.LinePreCalc_LineCap0(e,t,s,i,n,r,c,u)}LinePreCalc_LineCap2(e,t,s,i,n,r,a,o){const l=this._lineOffset,h=e+l-o,c=t+l-a,u=i+l+o,_=n+l+a,d=2*o,p=2*a,m=h+a,g=c-o,f=h-a+d,S=c+o+p,C=u+a,y=_-o,G=u-a-d,I=_+o-p;this.Quad3D2(m,g,s,C,y,r,G,I,r,f,S,s,defaultTexCoordsQuad)}LinePreCalc_LineCap1(e,t,s,i,n,r,a,o){const l=this._lineOffset,h=e+l-o,c=t+l-a,u=i+l+o,_=n+l+a,d=h+a,p=c-o,m=h-a,g=c+o,f=u+a,S=_-o,C=u-a,y=_+o;this.Quad3D2(d,p,s,f,S,r,C,y,r,m,g,s,defaultTexCoordsQuad)}LinePreCalc_LineCap0(e,t,s,i,n,r,a,o){const l=this._lineOffset,h=e+l,c=t+l,u=i+l,_=n+l,d=h+a,p=c-o,m=h-a,g=c+o,f=u+a,S=_-o,C=u-a,y=_+o;this.Quad3D2(d,p,s,f,S,r,C,y,r,m,g,s,defaultTexCoordsQuad)}TexturedLine(e,t,s,i,n,r){const a=C33.angleTo(e,t,s,i),o=Math.sin(a),l=Math.cos(a),h=.5*this._lineWidth,c=o*h,u=l*h,_=this._lineCap;2===_?this.TexturedLinePreCalc_LineCap2(e,t,s,i,c,u,n,r):1===_?this.TexturedLinePreCalc_LineCap1(e,t,s,i,c,u,n,r):this.TexturedLinePreCalc_LineCap0(e,t,s,i,c,u,n,r)}TexturedLinePreCalc_LineCap2(e,t,s,i,n,r,a,o){const l=this._lineOffset,h=e+l-r,c=t+l-n,u=s+l+r,_=i+l+n,d=2*r,p=2*n,m=h+n,g=c-r,f=h-n+d,S=c+r+p,C=u+n,y=_-r,G=u-n-d,I=_+r-p;tmpQuad.set(m,g,C,y,G,I,f,S),tmpRect.set(a,0,o,0),this.Quad3(tmpQuad,tmpRect)}TexturedLinePreCalc_LineCap1(e,t,s,i,n,r,a,o){const l=this._lineOffset,h=e+l-r,c=t+l-n,u=s+l+r,_=i+l+n,d=h+n,p=c-r,m=h-n,g=c+r,f=u+n,S=_-r,C=u-n,y=_+r;tmpQuad.set(d,p,f,S,C,y,m,g),tmpRect.set(a,0,o,0),this.Quad3(tmpQuad,tmpRect)}TexturedLinePreCalc_LineCap0(e,t,s,i,n,r,a,o){const l=this._lineOffset,h=e+l,c=t+l,u=s+l,_=i+l,d=h+n,p=c-r,m=h-n,g=c+r,f=u+n,S=_-r,C=u-n,y=_+r;tmpQuad.set(d,p,f,S,C,y,m,g),tmpRect.set(a,0,o,0),this.Quad3(tmpQuad,tmpRect)}LineRect(e,t,s,i){const n=.5*this._lineWidth,r=this._lineCap;2===r?this._LineRectPreCalc_LineCap2(e,t,s,i,n):1===r?this._LineRectPreCalc_LineCap1(e,t,s,i,n):this._LineRectPreCalc_LineCap0(e,t,s,i,n)}_LineRectPreCalc_LineCap2(e,t,s,i,n){this.LinePreCalc_LineCap2(e,t,0,s,t,0,0,n),this.LinePreCalc_LineCap2(s,t,0,s,i,0,n,0),this.LinePreCalc_LineCap2(s,i,0,e,i,0,0,-n),this.LinePreCalc_LineCap2(e,i,0,e,t,0,-n,0)}_LineRectPreCalc_LineCap1(e,t,s,i,n){this.LinePreCalc_LineCap1(e,t,0,s,t,0,0,n),this.LinePreCalc_LineCap1(s,t,0,s,i,0,n,0),this.LinePreCalc_LineCap1(s,i,0,e,i,0,0,-n),this.LinePreCalc_LineCap1(e,i,0,e,t,0,-n,0)}_LineRectPreCalc_LineCap0(e,t,s,i,n){this.LinePreCalc_LineCap0(e,t,0,s,t,0,0,n),this.LinePreCalc_LineCap0(s,t,0,s,i,0,n,0),this.LinePreCalc_LineCap0(s,i,0,e,i,0,0,-n),this.LinePreCalc_LineCap0(e,i,0,e,t,0,-n,0)}LineRect2(e){this.LineRect(e.getLeft(),e.getTop(),e.getRight(),e.getBottom())}LineQuad(e){const t=C33.angleTo(e.getTlx(),e.getTly(),e.getTrx(),e.getTry()),s=Math.sin(t),i=Math.cos(t),n=.5*this._lineWidth,r=s*n,a=i*n,o=this._lineCap;2===o?this._LineQuadPreCalc_LineCap2(e,r,a):1===o?this._LineQuadPreCalc_LineCap1(e,r,a):this._LineQuadPreCalc_LineCap0(e,r,a)}_LineQuadPreCalc_LineCap2(e,t,s){this.LinePreCalc_LineCap2(e.getTlx(),e.getTly(),0,e.getTrx(),e.getTry(),0,t,s),this.LinePreCalc_LineCap2(e.getTrx(),e.getTry(),0,e.getBrx(),e.getBry(),0,s,-t),this.LinePreCalc_LineCap2(e.getBrx(),e.getBry(),0,e.getBlx(),e.getBly(),0,-t,-s),this.LinePreCalc_LineCap2(e.getBlx(),e.getBly(),0,e.getTlx(),e.getTly(),0,-s,t)}_LineQuadPreCalc_LineCap1(e,t,s){this.LinePreCalc_LineCap1(e.getTlx(),e.getTly(),0,e.getTrx(),e.getTry(),0,t,s),this.LinePreCalc_LineCap1(e.getTrx(),e.getTry(),0,e.getBrx(),e.getBry(),0,s,-t),this.LinePreCalc_LineCap1(e.getBrx(),e.getBry(),0,e.getBlx(),e.getBly(),0,-t,-s),this.LinePreCalc_LineCap1(e.getBlx(),e.getBly(),0,e.getTlx(),e.getTly(),0,-s,t)}_LineQuadPreCalc_LineCap0(e,t,s){this.LinePreCalc_LineCap0(e.getTlx(),e.getTly(),0,e.getTrx(),e.getTry(),0,t,s),this.LinePreCalc_LineCap0(e.getTrx(),e.getTry(),0,e.getBrx(),e.getBry(),0,s,-t),this.LinePreCalc_LineCap0(e.getBrx(),e.getBry(),0,e.getBlx(),e.getBly(),0,-t,-s),this.LinePreCalc_LineCap0(e.getBlx(),e.getBly(),0,e.getTlx(),e.getTly(),0,-s,t)}SetLineWidth(e){this._lineWidth=e,this._lineWidthStack[this._lineWidthStack.length-1]=e}GetLineWidth(){return this._lineWidth}PushLineWidth(e){if(100<=this._lineWidthStack.length)throw new Error("pushed too many line widths - check push/pop pairs");this._lineWidthStack.push(e),this._lineWidth=e}PopLineWidth(){if(this._lineWidthStack.length<=1)throw new Error("cannot pop last line width - check push/pop pairs");this._lineWidthStack.pop(),this._lineWidth=this._lineWidthStack.at(-1)}SetLineCapButt(){this._lineCap=0,this._lineCapStack[this._lineCapStack.length-1]=0}SetLineCapSquare(){this._lineCap=1,this._lineCapStack[this._lineCapStack.length-1]=0}SetLineCapZag(){this._lineCap=2,this._lineCapStack[this._lineCapStack.length-1]=0}PushLineCap(e){if("butt"===e)this.PushLineCapButt();else if("square"===e)this.PushLineCapSquare();else{if("zag"!==e)throw new Error("invalid line cap");this.PushLineCapZag()}}PushLineCapButt(){if(100<=this._lineCapStack.length)throw new Error("pushed too many line caps - check push/pop pairs");this._lineCapStack.push(0),this._lineCap=0}PushLineCapSquare(){if(100<=this._lineCapStack.length)throw new Error("pushed too many line caps - check push/pop pairs");this._lineCapStack.push(1),this._lineCap=1}PushLineCapZag(){if(100<=this._lineCapStack.length)throw new Error("pushed too many line caps - check push/pop pairs");this._lineCapStack.push(2),this._lineCap=2}PopLineCap(){if(this._lineCapStack.length<=1)throw new Error("cannot pop last line cap - check push/pop pairs");this._lineCapStack.pop(),this._lineCap=this._lineCapStack.at(-1)}SetLineOffset(e){this._lineOffset=e,this._lineOffsetStack[this._lineOffsetStack.length-1]=e}GetLineOffset(){return this._lineOffset}PushLineOffset(e){if(100<=this._lineOffsetStack.length)throw new Error("pushed too many line offsets - check push/pop pairs");this._lineOffsetStack.push(e),this._lineOffset=e}PopLineOffset(){if(this._lineOffsetStack.length<=1)throw new Error("cannot pop last line offset - check push/pop pairs");this._lineOffsetStack.pop(),this._lineOffset=this._lineOffsetStack.at(-1)}ConvexPoly(t){const e=t.length/2;if(e<3)throw new Error("need at least 3 points");const s=e-2,i=s-1,n=t[0],r=t[1];for(let e=0;e<s;e+=2){const a=2*e,o=t[2+a],l=t[3+a],h=t[4+a],c=t[5+a];if(e===i)this.Quad2(n,r,o,l,h,c,h,c);else{const u=t[6+a],_=t[7+a];this.Quad2(n,r,o,l,h,c,u,_)}}}GetNumVertexComponents(){return 3}Finish(){this.EndBatch(!0),this._frameNumber++}GetFrameNumber(){return this._frameNumber}IncrementFrameNumber(){this._frameNumber++}SetMipmapsEnabled(e){this._enableMipmaps=!!e}AreMipmapsEnabled(){return this._enableMipmaps}SetHasMajorPerformanceCaveat(e){this._hasMajorPerformanceCaveat=!!e}HasMajorPerformanceCaveat(){return this._hasMajorPerformanceCaveat}IsWebGL(){return!1}IsWebGPU(){return!1}GetEstimatedBackBufferMemoryUsage(){}GetEstimatedRenderBufferMemoryUsage(){}GetEstimatedTextureMemoryUsage(){}GetEstimatedTotalMemoryUsage(){return this.GetEstimatedBackBufferMemoryUsage()+this.GetEstimatedRenderBufferMemoryUsage()+this.GetEstimatedTextureMemoryUsage()}CreateRendererText(){return C33.New(C33.Gfx.RendererText,this)}}}{const C33=self.C3;C33.Gfx.ShaderProgramBase=class{constructor(e,t){this._name=t.name,this._renderer=e,this._extendBoxHorizontal=t.extendBoxHorizontal||0,this._extendBoxVertical=t.extendBoxVertical||0,this._crossSampling=!!t.crossSampling,this._mustPreDraw=!!t.mustPreDraw,this._preservesOpaqueness=!!t.preservesOpaqueness,this._supports3dDirectRendering=!!t.supports3dDirectRendering,this._animated=!!t.animated,this._blendsBackground=!!t.blendsBackground,this._usesDepth=!!t.usesDepth,this._usesAnySrcRectOrPixelSize=!1,this._needsPostDrawOrExtendBox=this._crossSampling||this._blendsBackground||0!==this._extendBoxHorizontal||0!==this._extendBoxVertical}Release(){this._renderer=null}GetRenderer(){return this._renderer}GetName(){return this._name}ExtendsBox(){return 0!==this._extendBoxHorizontal||0!==this._extendBoxVertical}GetBoxExtendHorizontal(){return this._extendBoxHorizontal}GetBoxExtendVertical(){return this._extendBoxVertical}UsesCrossSampling(){return this._crossSampling}MustPreDraw(){return this._mustPreDraw}PreservesOpaqueness(){return this._preservesOpaqueness}Supports3DDirectRendering(){return this._supports3dDirectRendering}IsAnimated(){return this._animated}BlendsBackground(){return this._blendsBackground}UsesDepth(){return this._usesDepth}UsesAnySrcRectOrPixelSize(){return this._usesAnySrcRectOrPixelSize}NeedsPostDrawOrExtendsBox(){return this._needsPostDrawOrExtendBox}UsesIsSrcTexRotated(){return!1}}}{const C33=self.C3;C33.Gfx.StateGroup=class{constructor(e,t,s,i,n){this._renderer=e,this._refCount=0,this._shaderProgram=null,this._shaderProgramName="",this._blendMode=s,this._color=C33.New(C33.Color),this._color.set(i),this._zElevation=n,"string"==typeof t?this._shaderProgramName=t:(this._shaderProgram=t,this._shaderProgramName=this._shaderProgram.GetName())}Release(){if(0<this._refCount)throw new Error("releasing state group still in use");this._renderer=null,this._shaderProgram=null,this._shaderProgramName=""}Apply(){const e=this._renderer;e.SetProgram(this._shaderProgram),e.SetBlendMode(this._blendMode),e.SetColor(this._color),e.SetCurrentZ(this._zElevation),e._SetCurrentStateGroup(this)}GetKey(){return C33.Gfx.StateGroup.MakeKey(this._shaderProgramName,this._blendMode,this._color,this._zElevation)}AddRef(){++this._refCount}DecRef(){--this._refCount}_GetRefCount(){return this._refCount}OnContextLost(){this._shaderProgram=null}OnContextRestored(e){if(this._shaderProgram=e.GetShaderProgramByName(this._shaderProgramName),!this._shaderProgram)throw new Error("failed to restore shader program")}static MakeKey(e,t,s,i){const n="string"==typeof e?e:e.GetName();return n+","+t+","+s.getR()+","+s.getG()+","+s.getB()+","+s.getA()+","+i}}}{let interpolateQuad2=function(e,t,s){const i=s.getTlx(),n=s.getTly(),r=s.getTrx()-i,a=s.getTry()-n,o=s.getBlx()-i,l=s.getBly()-n,h=r*e,c=a*e,u=o*t,_=l*t;return[i+h+u,n+c+_]};interpolateQuad=interpolateQuad2;const C33=self.C3,tempQuadTex=C33.New(C33.Quad);C33.Gfx.MeshPoint=class{constructor(e,t,s){this._mesh=e,this._col=t,this._row=s,this._x=NaN,this._y=NaN,this._zElevation=NaN,this._u=NaN,this._v=NaN,this._x=0,this._y=0,this._zElevation=0,this._u=0,this._v=0}_Init(e,t,s,i){this._x=e,this._y=t,this._u=s,this._v=i}GetX(){return this._x}SetX(e){this._x!==e&&(this._x=e,this._mesh._SetPointsChanged())}GetY(){return this._y}SetY(e){this._y!==e&&(this._y=e,this._mesh._SetPointsChanged())}GetZElevation(){return this._zElevation}SetZElevation(e){this._zElevation!==e&&(this._zElevation=Math.max(e,0),this._mesh._SetPointsChanged())}GetU(){return this._u}SetU(e){this._u=e}GetV(){return this._v}SetV(e){this._v=e}_Interpolate_TexRect(e,t,s){[this._x,this._y]=interpolateQuad2(e._x,e._y,t),this._zElevation=e._zElevation,this._u=C33.lerp(s.getLeft(),s.getRight(),e._u),this._v=C33.lerp(s.getTop(),s.getBottom(),e._v)}_Interpolate_TexQuad(e,t,s){[this._x,this._y]=interpolateQuad2(e._x,e._y,t),this._zElevation=e._zElevation,[this._u,this._v]=interpolateQuad2(e._u,e._v,s)}SaveToJson(){return{x:this.GetX(),y:this.GetY(),z:this.GetZElevation(),u:this.GetU(),v:this.GetV()}}LoadFromJson(e){this.SetX(e.x),this.SetY(e.y),e.hasOwnProperty("z")&&this.SetZElevation(e.z),this.SetU(e.u),this.SetV(e.v)}GetMesh(){return this._mesh}GetColumn(){return this._col}GetRow(){return this._row}},C33.Gfx.Mesh=class{constructor(s,e,t){if(s<2||e<2)throw new Error("invalid mesh size");this._hsize=s,this._vsize=e,this._owner=t||null,this._pts=[],this._minX=0,this._minY=0,this._maxX=1,this._maxY=1,this._maxZ=0,this._pointsChanged=!1;const i=s-1,n=e-1;for(let t=0;t<e;++t){const r=[];for(let e=0;e<s;++e){const a=C33.New(C33.Gfx.MeshPoint,this,e,t),o=e/i,l=t/n;a._Init(o,l,o,l),r.push(a)}this._pts.push(r)}}Release(){C33.clearArray(this._pts)}GetHSize(){return this._hsize}GetVSize(){return this._vsize}GetOwner(){return this._owner}_GetPoints(){return this._pts}_SetPointsChanged(){this._pointsChanged=!0}_MaybeComputeBounds(){if(this._pointsChanged){let e=1/0,t=1/0,s=-1/0,i=-1/0,n=0;for(const r of this._pts)for(const a of r){const o=a.GetX(),l=a.GetY();e=Math.min(e,o),t=Math.min(t,l),s=Math.max(s,o),i=Math.max(i,l),n=Math.max(n,a.GetZElevation())}this._minX=e,this._minY=t,this._maxX=s,this._maxY=i,this._maxZ=n,this._pointsChanged=!1}}GetMinX(){return this._MaybeComputeBounds(),this._minX}GetMinY(){return this._MaybeComputeBounds(),this._minY}GetMaxX(){return this._MaybeComputeBounds(),this._maxX}GetMaxY(){return this._MaybeComputeBounds(),this._maxY}GetMaxZ(){return this._MaybeComputeBounds(),this._maxZ}HasAnyZElevation(){return 0<this.GetMaxZ()}GetMeshPointAt(e,t){return e=Math.floor(e),t=Math.floor(t),e<0||e>=this._hsize||t<0||t>=this._vsize?null:this._pts[t][e]}CalculateTransformedMesh(e,s,i){const n=i instanceof C33.Rect;if(e.GetHSize()!==this.GetHSize()||e.GetVSize()!==this.GetVSize())throw new Error("source mesh wrong size");const r=e._pts,a=this._pts;for(let e=0,t=a.length;e<t;++e){const o=r[e],l=a[e];for(let e=0,t=l.length;e<t;++e){const h=o[e],c=l[e];n?c._Interpolate_TexRect(h,s,i):c._Interpolate_TexQuad(h,s,i)}}}Draw(r){let a=this._pts,o=a[0];for(let e=1,t=a.length;e<t;++e){let s=a[e],i=o[0],n=s[0];for(let e=1,t=s.length;e<t;++e){const l=o[e],h=s[e];tempQuadTex.set(i.GetU(),i.GetV(),l.GetU(),l.GetV(),h.GetU(),h.GetV(),n.GetU(),n.GetV()),r.Quad3D2(i.GetX(),i.GetY(),i.GetZElevation(),l.GetX(),l.GetY(),l.GetZElevation(),h.GetX(),h.GetY(),h.GetZElevation(),n.GetX(),n.GetY(),n.GetZElevation(),tempQuadTex),i=l,n=h}o=s}}Outline(o,l){l=l||((e,t,s)=>[e,t,s]);let e=this._pts,h=e[0];for(let r=1,a=e.length;r<a;++r){let s=e[r],i=h[0],n=s[0];for(let e=1,t=s.length;e<t;++e){const c=h[e],u=s[e],[_,d,p]=l(i.GetX(),i.GetY(),i.GetZElevation()),[m,g,f]=l(c.GetX(),c.GetY(),c.GetZElevation()),[S,C,y]=l(u.GetX(),u.GetY(),u.GetZElevation()),[G,I,T]=l(n.GetX(),n.GetY(),n.GetZElevation());o.Line3D(_,d,p,m,g,f),o.Line3D(_,d,p,S,C,y),o.Line3D(_,d,p,G,I,T),e===t-1&&o.Line3D(m,g,f,S,C,y),r===a-1&&o.Line3D(G,I,T,S,C,y),i=c,n=u}h=s}}InsertPolyMeshVertices(e){let s=.99999999,i=e.pointsArr(),n=[],r=this.GetHSize()-1,a=this.GetVSize()-1,o=1/r,l=1/a,h=r-1,c=a-1,u=i[0],_=i[1],d=C33.clamp(Math.floor(u*r),0,h),p=C33.clamp(Math.floor(_*a),0,c),m=!0,g=0,f=0,S=0,C=-1,y=()=>{u=C33.clamp(C33.lerp(u,g,S),0,1),_=C33.clamp(C33.lerp(_,f,S),0,1),n.push(u,_)};for(let e=0,t=i.length;e<t;e+=2){u=i[e],_=i[e+1],n.push(u,_),d=C33.clamp(Math.floor(u*r),0,h),p=C33.clamp(Math.floor(_*a),0,c);const G=(e+2)%t;for(g=i[G],f=i[1+G],C=-1;;){if(1e6<n.length)throw new Error("Too many mesh poly points");const I=d*o,T=p*l,b=(d+1)*o,P=(p+1)*l;if(m=C33.isPointInTriangleInclusive(u,_,I,T,b,T,b,P),0!==C&&0<=(S=C33.rayIntersectExtended(u,_,g,f,I,T,b,P,-.001))&&S<=s)y(),m=!m,C=0;else if(0<p&&2!==C&&0<=(S=C33.rayIntersectExtended(u,_,g,f,I,T,b,T,.001))&&S<=s)y(),p--,m=!1,C=4;else if(d<h&&3!==C&&0<=(S=C33.rayIntersectExtended(u,_,g,f,b,T,b,P,.001))&&S<=s)y(),d++,m=!1,C=1;else if(0<d&&1!==C&&0<=(S=C33.rayIntersectExtended(u,_,g,f,I,T,I,P,.001))&&S<=s)y(),d--,m=!0,C=3;else{if(!(p<c&&4!==C&&0<=(S=C33.rayIntersectExtended(u,_,g,f,I,P,b,P,.001))&&S<=s))break;y(),p++,m=!0,C=2}}}return C33.New(C33.CollisionPoly,n)}TransformCollisionPoly(e,t){const s=this._TransformPolyPoints(e);this._SimplifyPoly(s),t.setPoints(s)}_TransformPolyPoints(e){const s=[],i=e.pointsArr();for(let e=0,t=i.length;e<t;e+=2){const n=i[e],r=i[e+1],[a,o]=this.TransformPoint(n,r);s.push(a,o)}return s}TransformPoint(e,t){const s=this.GetHSize()-1,i=this.GetVSize()-1,n=1/s,r=1/i,a=C33.clamp(Math.floor(e*s),0,s-1),o=C33.clamp(Math.floor(t*i),0,i-1),l=a*n,h=o*r,c=(a+1)*n,u=(o+1)*r,_=this.GetMeshPointAt(a,o),d=this.GetMeshPointAt(a+1,o+1),p=C33.isPointInTriangleInclusive(e,t,l,h,c,h,c,u),m=p?l+n:l,g=p?h:h+r,f=this.GetMeshPointAt(a+(p?1:0),o+(p?0:1)),[S,C,y]=C33.triangleCartesianToBarycentric(e,t,l,h,m,g,c,u);return C33.triangleBarycentricToCartesian3d(S,C,y,_.GetX(),_.GetY(),_.GetZElevation(),f.GetX(),f.GetY(),f.GetZElevation(),d.GetX(),d.GetY(),d.GetZElevation())}_SimplifyPoly(s){let i=[],n=s[0],r=s[1],a=n-s.at(-2),o=r-s.at(-1);for(let e=0,t=s.length;e<t;e+=2){const l=(e+2)%t,h=s[l],c=s[1+l],u=h-n,_=c-r,d=Math.abs(u)<1e-7&&Math.abs(a)<1e-7&&Math.sign(_)===Math.sign(o),p=Math.abs(_)<1e-7&&Math.abs(o)<1e-7&&Math.sign(u)===Math.sign(a);(!d&&!p&&.001<Math.abs(u/a-_/o)||0==u&&0==_)&&i.push(n,r),n=h,r=c,a=u,o=_}6<=i.length&&i.length<s.length&&C33.shallowAssignArray(s,i)}SaveToJson(){return{cols:this.GetHSize(),rows:this.GetVSize(),points:this._pts.map(e=>e.map(e=>e.SaveToJson()))}}LoadFromJson(e){const s=this.GetHSize(),i=this.GetVSize();if(e.cols!==s||e.rows!==i)throw new Error("mesh data wrong size");const n=e.points;for(let t=0;t<i;++t){const r=n[t];for(let e=0;e<s;++e){const a=this.GetMeshPointAt(e,t);a.LoadFromJson(r[e])}}}}}{let GetFormatSpecifiers2=function(e,t){let s,i,n,r;switch(e){case"rgba8":s=t.RGBA8,i=t.RGBA,n=t.RGBA,r=t.UNSIGNED_BYTE;break;case"rgb8":s=t.RGB8,i=t.RGB,n=t.RGB,r=t.UNSIGNED_BYTE;break;case"rgba4":s=t.RGBA4,i=t.RGBA,n=t.RGBA,r=t.UNSIGNED_SHORT_4_4_4_4;break;case"rgb5_a1":s=t.RGB5_A1,i=t.RGBA,n=t.RGBA,r=t.UNSIGNED_SHORT_5_5_5_1;break;case"rgb565":s=t.RGB565,i=t.RGB,n=t.RGB,r=t.UNSIGNED_SHORT_5_6_5;break;default:throw new Error("invalid pixel format")}return{sizedinternalformat:s,internalformat:i,format:n,type:r}};GetFormatSpecifiers=GetFormatSpecifiers2;const C33=self.C3,VALID_PIXEL_FORMATS=new Set(["rgba8","rgb8","rgba4","rgb5_a1","rgb565"]),VALID_SAMPLINGS=new Set(["nearest","bilinear","trilinear"]),VALID_MIPMAP_QUALITIES=new Set(["default","low","high"]),VALID_WRAP_MODES=new Set(["clamp-to-edge","repeat","mirror-repeat"]),CREATEFROM_DEFAULT_OPTIONS={wrapX:"clamp-to-edge",wrapY:"clamp-to-edge",sampling:"trilinear",anisotropy:0,pixelFormat:"rgba8",mipMap:!0,mipMapQuality:"default",premultiplyAlpha:!0,isSvg:!1,width:-1,height:-1},UPDATE_DEFAULT_OPTIONS={premultiplyAlpha:!0,flipY:!1},allTextures=new Set;C33.Gfx.WebGLRendererTexture=class{constructor(e){this._renderer=e,this._texture=null,this._width=0,this._height=0,this._isStatic=!0,this._wrapX="clamp-to-edge",this._wrapY="clamp-to-edge",this._sampling="trilinear",this._anisotropy=0,this._pixelFormat="rgba8",this._isMipMapped=!1,this._mipMapQuality="default",this._refCount=0}_CreateStatic(t,e){if(!("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas||t instanceof ImageData||t instanceof ArrayBuffer||null===t))throw new Error("invalid texture source");if(e=Object.assign({},CREATEFROM_DEFAULT_OPTIONS,e),this._texture)throw new Error("already created texture");if(this._wrapX=e.wrapX,this._wrapY=e.wrapY,this._sampling=e.sampling,this._anisotropy=e.anisotropy,this._pixelFormat=e.pixelFormat,this._isMipMapped=!!e.mipMap&&this._renderer.AreMipmapsEnabled(),this._mipMapQuality=e.mipMapQuality,!VALID_WRAP_MODES.has(this._wrapX)||!VALID_WRAP_MODES.has(this._wrapY))throw new Error("invalid wrap mode");if(!VALID_SAMPLINGS.has(this._sampling))throw new Error("invalid sampling");if(!VALID_PIXEL_FORMATS.has(this._pixelFormat))throw new Error("invalid pixel format");if(!VALID_MIPMAP_QUALITIES.has(this._mipMapQuality))throw new Error("invalid mipmap quality");if(this._isStatic=!0,t instanceof ArrayBuffer||null===t||e.isSvg){if(this._width=e.width,this._height=e.height,t instanceof ArrayBuffer&&t.byteLength!==this._width*this._height*4)throw new Error("ArrayBuffer wrong size")}else this._width=t.width,this._height=t.height;if(this._width<=0||this._height<=0)throw new Error("invalid texture data size");if(e.isSvg){const o=C33.CreateCanvas(this._width,this._height),l=o.getContext("2d");l.drawImage(t,0,0,this._width,this._height),t=o}const s=C33.isPOT(this._width)&&C33.isPOT(this._height),i=this._renderer.GetMaxTextureSize();if(this._width>i||this._height>i)throw new Error("texture data exceeds maximum texture size");const n=this._renderer.GetContext(),r=this._renderer.GetWebGLVersionNumber(),a=(this._texture=n.createTexture(),n.bindTexture(n.TEXTURE_2D,this._texture),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.premultiplyAlpha),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),GetFormatSpecifiers2(this._pixelFormat,n));if(this._renderer.SupportsNPOTTextures()||s||!this._IsTiled())if(2<=r){let e;e=this._isMipMapped?Math.floor(Math.log2(Math.max(this._width,this._height))+1):1,n.texStorage2D(n.TEXTURE_2D,e,a.sizedinternalformat,this._width,this._height),t instanceof ArrayBuffer?n.texSubImage2D(n.TEXTURE_2D,0,0,0,this._width,this._height,a.format,a.type,new Uint8Array(t)):null!==t&&n.texSubImage2D(n.TEXTURE_2D,0,0,0,a.format,a.type,t)}else t instanceof ArrayBuffer?n.texImage2D(n.TEXTURE_2D,0,a.internalformat,this._width,this._height,0,a.format,a.type,new Uint8Array(t)):null===t?n.texImage2D(n.TEXTURE_2D,0,a.internalformat,this._width,this._height,0,a.format,a.type,null):n.texImage2D(n.TEXTURE_2D,0,a.internalformat,a.format,a.type,t);else{if(null===t)throw new Error("cannot pass null data when creating a NPOT tiled texture without NPOT support");if((t=t instanceof ArrayBuffer?new ImageData(new Uint8ClampedArray(t),this._width,this._height):t)instanceof ImageData){const u=C33.CreateCanvas(this._width,this._height),_=u.getContext("2d");_.putImageData(t,0,0),t=u}const h=C33.CreateCanvas(C33.nextHighestPowerOfTwo(this._width),C33.nextHighestPowerOfTwo(this._height)),c=h.getContext("2d");c.imageSmoothingEnabled="nearest"!==this._sampling,c.drawImage(t,0,0,this._width,this._height,0,0,h.width,h.height),n.texImage2D(n.TEXTURE_2D,0,a.internalformat,a.format,a.type,h)}null!==t&&this._SetTextureParameters(n),n.bindTexture(n.TEXTURE_2D,null),this._renderer._ResetLastTexture(),this._refCount=1,allTextures.add(this)}_CreateDynamic(e,t,s){if(s=Object.assign({},CREATEFROM_DEFAULT_OPTIONS,s),this._texture)throw new Error("already created texture");if(this._wrapX=s.wrapX,this._wrapY=s.wrapY,this._sampling=s.sampling,this._pixelFormat=s.pixelFormat,this._isMipMapped=!!s.mipMap&&this._renderer.AreMipmapsEnabled(),this._mipMapQuality=s.mipMapQuality,!VALID_WRAP_MODES.has(this._wrapX)||!VALID_WRAP_MODES.has(this._wrapY))throw new Error("invalid wrap mode");if(!VALID_SAMPLINGS.has(this._sampling))throw new Error("invalid sampling");if(!VALID_PIXEL_FORMATS.has(this._pixelFormat))throw new Error("invalid pixel format");if(!VALID_MIPMAP_QUALITIES.has(this._mipMapQuality))throw new Error("invalid mipmap quality");this._isStatic=!1,this._width=Math.floor(e),this._height=Math.floor(t);const i=C33.isPOT(this._width)&&C33.isPOT(this._height),n=this._renderer.GetMaxTextureSize();if(this._width<=0||this._height<=0)throw new Error("invalid texture size");if(this._width>n||this._height>n)throw new Error("texture exceeds maximum texture size");if(!this._renderer.SupportsNPOTTextures()&&this._IsTiled()&&!i)throw new Error("non-power-of-two tiled textures not supported");const r=this._renderer.GetContext(),a=this._renderer.GetWebGLVersionNumber(),o=(this._texture=r.createTexture(),r.bindTexture(r.TEXTURE_2D,this._texture),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s.premultiplyAlpha),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1),GetFormatSpecifiers2(this._pixelFormat,r)),l=2<=a?o.sizedinternalformat:o.internalformat;r.texImage2D(r.TEXTURE_2D,0,l,this._width,this._height,0,o.format,o.type,null),this._SetTextureParameters(r),r.bindTexture(r.TEXTURE_2D,null),this._renderer._ResetLastTexture(),this._refCount=1,allTextures.add(this)}_GetMipMapHint(e){if("default"===this._mipMapQuality)return this._isStatic?e.NICEST:e.FASTEST;if("low"===this._mipMapQuality)return e.FASTEST;if("high"===this._mipMapQuality)return e.NICEST;throw new Error("invalid mipmap quality")}_IsTiled(){return"clamp-to-edge"!==this._wrapX||"clamp-to-edge"!==this._wrapY}_GetTextureWrapMode(e,t){if("clamp-to-edge"===t)return e.CLAMP_TO_EDGE;if("repeat"===t)return e.REPEAT;if("mirror-repeat"===t)return e.MIRRORED_REPEAT;throw new Error("invalid wrap mode")}_SetTextureParameters(e){const t=C33.isPOT(this._width)&&C33.isPOT(this._height);if(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,this._GetTextureWrapMode(e,this._wrapX)),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,this._GetTextureWrapMode(e,this._wrapY)),"nearest"===this._sampling)e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),this._isMipMapped=!1;else if(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),(t||this._renderer.SupportsNPOTTextures())&&this._isMipMapped){e.hint(e.GENERATE_MIPMAP_HINT,this._GetMipMapHint(e)),e.generateMipmap(e.TEXTURE_2D);const i="trilinear"===this._sampling&&!this._renderer.HasMajorPerformanceCaveat();e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,i?e.LINEAR_MIPMAP_LINEAR:e.LINEAR_MIPMAP_NEAREST)}else e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),this._isMipMapped=!1;const s=this._renderer._GetAnisotropicExtension();s&&0<this._anisotropy&&"nearest"!==this._sampling&&e.texParameterf(e.TEXTURE_2D,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(this._anisotropy,this._renderer._GetMaxAnisotropy()))}_Update(e,t){if(!("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas||e instanceof ImageData))throw new Error("invalid texture source");if(!this._texture||this._refCount<=0)throw new Error("texture not created");if(this._isStatic)throw new Error("cannot update static texture");t=Object.assign({},UPDATE_DEFAULT_OPTIONS,t);const s=e.width||e.videoWidth,i=e.height||e.videoHeight,n=this._renderer.GetWebGLVersionNumber(),r=this._renderer.GetContext(),a=(r.bindTexture(r.TEXTURE_2D,this._texture),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!!t.flipY),GetFormatSpecifiers2(this._pixelFormat,r)),o=2<=n?a.sizedinternalformat:a.internalformat;try{if(this._width===s&&this._height===i){const l=C33.isPOT(this._width)&&C33.isPOT(this._height);r.texSubImage2D(r.TEXTURE_2D,0,0,0,a.format,a.type,e),(l||this._renderer.SupportsNPOTTextures())&&this._isMipMapped&&(r.hint(r.GENERATE_MIPMAP_HINT,this._GetMipMapHint(r)),r.generateMipmap(r.TEXTURE_2D))}else{this._width=s,this._height=i;const h=C33.isPOT(this._width)&&C33.isPOT(this._height);if(!this._renderer.SupportsNPOTTextures()&&this._IsTiled()&&!h)throw new Error("non-power-of-two tiled textures not supported");r.texImage2D(r.TEXTURE_2D,0,o,a.format,a.type,e),(h||this._renderer.SupportsNPOTTextures())&&this._isMipMapped&&(r.hint(r.GENERATE_MIPMAP_HINT,this._GetMipMapHint(r)),r.generateMipmap(r.TEXTURE_2D))}}catch(e){console.error("Error updating WebGL texture: ",e)}r.bindTexture(r.TEXTURE_2D,null),this._renderer._ResetLastTexture()}_Delete(){if(0<this._refCount)throw new Error("texture still has references");if(!this._texture)throw new Error("already deleted texture");allTextures.delete(this);const e=this._renderer.GetContext();e.deleteTexture(this._texture),this._texture=null}IsValid(){return!!this._texture}_GetTexture(){return this._texture}GetRenderer(){return this._renderer}AddReference(){this._refCount++}SubtractReference(){if(this._refCount<=0)throw new Error("no more references");this._refCount--}GetReferenceCount(){return this._refCount}GetWidth(){return this._width}GetHeight(){return this._height}IsStatic(){return this._isStatic}GetEstimatedMemoryUsage(){let e=this._width*this._height;switch(this._pixelFormat){case"rgba8":e*=4;break;case"rgb8":e*=3;break;case"rgba4":case"rgb5_a1":case"rgb565":e*=2}return this._isMipMapped&&(e+=Math.floor(e/3)),e}static OnContextLost(){allTextures.clear()}static allTextures(){return allTextures.values()}}}{const C33=self.C3,assert=self.assert,glMatrix=self.glMatrix,vec32=glMatrix.vec3,mat42=glMatrix.mat4,VALID_SAMPLINGS=new Set(["nearest","bilinear","trilinear"]),DEFAULT_RENDERTARGET_OPTIONS={sampling:"trilinear",alpha:!0,depth:!1,isSampled:!0,isDefaultSize:!0,multisampling:0},allRenderTargets=new Set;C33.Gfx.WebGLRenderTarget=class{constructor(e){this._renderer=e,this._frameBuffer=null,this._frameBufferNoDepth=null,this._texture=null,this._renderBuffer=null,this._width=0,this._height=0,this._isDefaultSize=!0,this._sampling="trilinear",this._alpha=!0,this._depth=!1,this._isSampled=!0,this._multisampling=0,this._projectionMatrix=mat42.create(),this._lastFov=0,this._lastNearZ=0,this._lastFarZ=0}_Create(e,t,s){s=Object.assign({},DEFAULT_RENDERTARGET_OPTIONS,s);const i=this._renderer.GetWebGLVersionNumber();if(this._texture||this._renderBuffer)throw new Error("already created render target");if(this._sampling=s.sampling,this._alpha=!!s.alpha,this._depth=!!s.depth,this._isSampled=!!s.isSampled,this._isDefaultSize=!!s.isDefaultSize,this._multisampling=s.multisampling,!VALID_SAMPLINGS.has(this._sampling))throw new Error("invalid sampling");if(0<this._multisampling&&(i<2||this._isSampled))throw new Error("invalid use of multisampling");if(i<2&&(this._isSampled=!0),this._width=e,this._height=t,this._width<=0||this._height<=0)throw new Error("invalid render target size");this._CalculateProjection();const n=this._renderer.GetContext();if(this._frameBuffer=n.createFramebuffer(),this._depth&&(this._frameBufferNoDepth=n.createFramebuffer()),this._isSampled){this._texture=this._renderer.CreateDynamicTexture(this._width,this._height,{sampling:this._sampling,pixelFormat:this._alpha?"rgba8":"rgb8",mipMap:!1});const a=this._texture._GetTexture();n.bindFramebuffer(n.FRAMEBUFFER,this._frameBuffer),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,a,0),this._depth&&(n.bindFramebuffer(n.FRAMEBUFFER,this._frameBufferNoDepth),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,a,0))}else{this._renderBuffer=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,this._renderBuffer);const o=this._alpha?n.RGBA8:n.RGB8;if(0<this._multisampling){const l=n.getInternalformatParameter(n.RENDERBUFFER,o,n.SAMPLES);if(l&&l[0]){const h=l[0];this._multisampling>h&&(this._multisampling=h)}else this._multisampling=0}0===this._multisampling?n.renderbufferStorage(n.RENDERBUFFER,o,this._width,this._height):n.renderbufferStorageMultisample(n.RENDERBUFFER,this._multisampling,o,this._width,this._height),n.bindFramebuffer(n.FRAMEBUFFER,this._frameBuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,this._renderBuffer),this._depth&&(n.bindFramebuffer(n.FRAMEBUFFER,this._frameBufferNoDepth),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,this._renderBuffer)),n.bindRenderbuffer(n.RENDERBUFFER,null)}const r=this._renderer._GetDepthBuffer();this._depth&&r&&(n.bindFramebuffer(n.FRAMEBUFFER,this._frameBuffer),this._renderer._CanSampleDepth()?n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,r,0):n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,r)),n.bindFramebuffer(n.FRAMEBUFFER,null),allRenderTargets.add(this)}_Resize(e,t){if(this._width!==e||this._height!==t){this._width=e,this._height=t,this._CalculateProjection();const s=this._renderer.GetContext(),i=(s.bindFramebuffer(s.FRAMEBUFFER,this._frameBuffer),this._texture?this._texture._Update(new ImageData(this._width,this._height)):(s.bindRenderbuffer(s.RENDERBUFFER,this._renderBuffer),s.renderbufferStorage(s.RENDERBUFFER,this._alpha?s.RGBA8:s.RGB8,this._width,this._height),s.bindRenderbuffer(s.RENDERBUFFER,null)),this._renderer._GetDepthBuffer());this._depth&&i&&(this._renderer._CanSampleDepth()?s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,i,0):s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,i)),s.bindFramebuffer(s.FRAMEBUFFER,null)}}_Delete(){if(!this._texture&&!this._renderBuffer)throw new Error("already deleted render target");allRenderTargets.delete(this);const e=this._renderer.GetContext(),t=(this._texture?(e.bindFramebuffer(e.FRAMEBUFFER,this._frameBuffer),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,null,0),this._depth&&(e.bindFramebuffer(e.FRAMEBUFFER,this._frameBufferNoDepth),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,null,0)),this._renderer.DeleteTexture(this._texture),this._texture=null):this._renderBuffer&&(e.bindFramebuffer(e.FRAMEBUFFER,this._frameBuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,null),this._depth&&(e.bindFramebuffer(e.FRAMEBUFFER,this._frameBufferNoDepth),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,null)),e.deleteRenderbuffer(this._renderBuffer),this._renderBuffer=null),e.bindFramebuffer(e.FRAMEBUFFER,null),2<=this._renderer.GetWebGLVersionNumber()&&(e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null)),e.deleteFramebuffer(this._frameBuffer),this._depth&&e.deleteFramebuffer(this._frameBufferNoDepth),this._renderer.GetBatchState());t.currentFramebuffer=null,this._frameBuffer=t.currentFramebufferNoDepth=null}_CalculateProjection(){this._renderer.CalculatePerspectiveMatrix(this._projectionMatrix,this._width/this._height),this._lastFov=this._renderer.GetFovY(),this._lastNearZ=this._renderer.GetNearZ(),this._lastFarZ=this._renderer.GetFarZ()}_GetFramebuffer(){return this._frameBuffer}_GetFramebufferNoDepth(){return this._frameBufferNoDepth}GetRenderer(){return this._renderer}GetTexture(){return this._texture}GetProjectionMatrix(){return this._renderer.GetFovY()===this._lastFov&&this._renderer.GetNearZ()===this._lastNearZ&&this._renderer.GetFarZ()===this._lastFarZ||this._CalculateProjection(),this._projectionMatrix}IsLinearSampling(){return"nearest"!==this._sampling}HasAlpha(){return this._alpha}IsSampled(){return this._isSampled}HasDepthBuffer(){return this._depth}GetWidth(){return this._width}GetHeight(){return this._height}IsDefaultSize(){return this._isDefaultSize}GetMultisampling(){return this._multisampling}GetOptions(){const e={sampling:this._sampling,alpha:this._alpha,isSampled:this._isSampled};return this._isDefaultSize||(e.width=this._width,e.height=this._height),e}IsCompatibleWithOptions(e){return"nearest"!==(e=Object.assign({},DEFAULT_RENDERTARGET_OPTIONS,e)).sampling===this.IsLinearSampling()&&!!e.alpha===this.HasAlpha()&&!!e.depth===this.HasDepthBuffer()&&!(2<=this._renderer.GetWebGLVersionNumber()&&!!e.isSampled!==this.IsSampled())&&("number"==typeof e.width||"number"==typeof e.height?!this.IsDefaultSize()&&this.GetWidth()===Math.floor(e.width)&&this.GetHeight()===Math.floor(e.height):this.IsDefaultSize())}_GetWebGLTexture(){return this._texture?this._texture._GetTexture():null}GetEstimatedMemoryUsage(){return this._texture?this._texture.GetEstimatedMemoryUsage():this._width*this._height*(this._alpha?4:3)}static async DebugReadPixelsToBlob(e,t){const s=await e.ReadBackRenderTargetToImageData(t,!0);return C33.ImageDataToBlob(s)}static OnContextLost(){allRenderTargets.clear()}static allRenderTargets(){return allRenderTargets.values()}static ResizeAll(e,t){for(const s of allRenderTargets)s.IsDefaultSize()&&s._Resize(e,t)}}}{const C33=self.C3,glMatrix=self.glMatrix,vec32=glMatrix.vec3,mat42=glMatrix.mat4,RESERVED_UNIFORM_NAMES=new Set(["aPos","aTex","aPoints","matP","matMV","samplerFront","samplerBack","samplerDepth","destStart","destEnd","srcStart","srcEnd","srcOriginStart","srcOriginEnd","pixelSize","seconds","devicePixelRatio","layerScale","layerAngle","layoutStart","layoutEnd","color","color2_","pointTexStart","pointTexEnd","zElevation","tileSize","tileSpacing","outlineThickness","zNear","zFar"]);C33.Gfx.WebGLShaderProgram=class extends C33.Gfx.ShaderProgramBase{static async Compile(e,t){const s=e.GetContext(),i=t.src,n=t.vertexSrc,r=t.name,a=s.createShader(s.FRAGMENT_SHADER),o=(s.shaderSource(a,i),s.compileShader(a),s.createShader(s.VERTEX_SHADER)),l=(s.shaderSource(o,n),s.compileShader(o),s.createProgram()),h=(s.attachShader(l,a),s.attachShader(l,o),s.bindAttribLocation(l,0,"aPos"),s.bindAttribLocation(l,1,"aTex"),s.bindAttribLocation(l,2,"aPoints"),s.linkProgram(l),e._GetParallelShaderCompileExtension());if(h?await e._WaitForObjectReady(()=>s.getProgramParameter(l,h.COMPLETION_STATUS_KHR)):await C33.Wait(5),!s.getShaderParameter(a,s.COMPILE_STATUS)){const u=s.getShaderInfoLog(a);throw s.deleteShader(a),s.deleteShader(o),s.deleteProgram(l),new Error("Error compiling fragment shader: "+u)}if(!s.getShaderParameter(o,s.COMPILE_STATUS)){const _=s.getShaderInfoLog(o);throw s.deleteShader(a),s.deleteShader(o),s.deleteProgram(l),new Error("Error compiling vertex shader: "+_)}if(!s.getProgramParameter(l,s.LINK_STATUS)){const d=s.getProgramInfoLog(l);throw s.deleteShader(a),s.deleteShader(o),s.deleteProgram(l),new Error("Error linking shader program: "+d)}const c=C33.FilterUnprintableChars(s.getProgramInfoLog(l)||"").trim();return c&&!C33.IsStringAllWhitespace(c)&&console.info(`[WebGL] Shader program '${r}' compilation log: `,c),s.deleteShader(a),s.deleteShader(o),l}static async Create(e,t){const s=await C33.Gfx.WebGLShaderProgram.Compile(e,t);return new C33.Gfx.WebGLShaderProgram(e,s,t)}constructor(e,t,s){super(e,s);const i=e.GetContext(),n=e.GetBatchState(),r=(e.EndBatch(),i.useProgram(t),this._gl=i,this._shaderProgram=t,this._isDeviceTransform="<default-device-transform>"===s.name,i.getAttribLocation(t,"aPos")),a=i.getAttribLocation(t,"aTex"),o=(this._locAPoints=i.getAttribLocation(t,"aPoints"),-1!==r&&(i.bindBuffer(i.ARRAY_BUFFER,e._vertexBuffer),i.vertexAttribPointer(r,e.GetNumVertexComponents(),i.FLOAT,!1,0,0),i.enableVertexAttribArray(r)),-1!==a&&(i.bindBuffer(i.ARRAY_BUFFER,e._texcoordBuffer),i.vertexAttribPointer(a,2,i.FLOAT,!1,0,0),i.enableVertexAttribArray(a)),-1!==this._locAPoints&&(i.bindBuffer(i.ARRAY_BUFFER,e._pointBuffer),i.vertexAttribPointer(this._locAPoints,4,i.FLOAT,!1,0,0),i.enableVertexAttribArray(this._locAPoints)),i.bindBuffer(i.ARRAY_BUFFER,null),this._uMatP=new C33.Gfx.WebGLShaderUniform(this,"matP","mat4"),this._uMatMV=new C33.Gfx.WebGLShaderUniform(this,"matMV","mat4"),this._uColor=new C33.Gfx.WebGLShaderUniform(this,"color","vec4"),this._uSamplerFront=new C33.Gfx.WebGLShaderUniform(this,"samplerFront","sampler"),this._uPointTexStart=new C33.Gfx.WebGLShaderUniform(this,"pointTexStart","vec2"),this._uPointTexEnd=new C33.Gfx.WebGLShaderUniform(this,"pointTexEnd","vec2"),this._uZElevation=new C33.Gfx.WebGLShaderUniform(this,"zElevation","float"),this._uTileSize=new C33.Gfx.WebGLShaderUniform(this,"tileSize","vec2"),this._uTileSpacing=new C33.Gfx.WebGLShaderUniform(this,"tileSpacing","vec2"),this._uColor2=new C33.Gfx.WebGLShaderUniform(this,"color2_","vec4"),this._uOutlineThickness=new C33.Gfx.WebGLShaderUniform(this,"outlineThickness","float"),this._uSamplerBack=new C33.Gfx.WebGLShaderUniform(this,"samplerBack","sampler"),this._uSamplerDepth=new C33.Gfx.WebGLShaderUniform(this,"samplerDepth","sampler"),this._uDestStart=new C33.Gfx.WebGLShaderUniform(this,"destStart","vec2"),this._uDestEnd=new C33.Gfx.WebGLShaderUniform(this,"destEnd","vec2"),this._uSrcStart=new C33.Gfx.WebGLShaderUniform(this,"srcStart","vec2"),this._uSrcEnd=new C33.Gfx.WebGLShaderUniform(this,"srcEnd","vec2"),this._uSrcOriginStart=new C33.Gfx.WebGLShaderUniform(this,"srcOriginStart","vec2"),this._uSrcOriginEnd=new C33.Gfx.WebGLShaderUniform(this,"srcOriginEnd","vec2"),this._uPixelSize=new C33.Gfx.WebGLShaderUniform(this,"pixelSize","vec2"),this._uSeconds=new C33.Gfx.WebGLShaderUniform(this,"seconds","float"),this._uDevicePixelRatio=new C33.Gfx.WebGLShaderUniform(this,"devicePixelRatio","float"),this._uLayerScale=new C33.Gfx.WebGLShaderUniform(this,"layerScale","float"),this._uLayerAngle=new C33.Gfx.WebGLShaderUniform(this,"layerAngle","float"),this._uLayoutStart=new C33.Gfx.WebGLShaderUniform(this,"layoutStart","vec2"),this._uLayoutEnd=new C33.Gfx.WebGLShaderUniform(this,"layoutEnd","vec2"),this._uZNear=new C33.Gfx.WebGLShaderUniform(this,"zNear","float"),this._uZFar=new C33.Gfx.WebGLShaderUniform(this,"zFar","float"),this._hasAnyOptionalUniforms=!!(this._uPixelSize.IsUsed()||this._uSeconds.IsUsed()||this._uSamplerBack.IsUsed()||this._uDestStart.IsUsed()||this._uDestEnd.IsUsed()||this._uSrcStart.IsUsed()||this._uSrcEnd.IsUsed()||this._uSrcOriginStart.IsUsed()||this._uSrcOriginEnd.IsUsed()||this._uDevicePixelRatio.IsUsed()||this._uLayerScale.IsUsed()||this._uLayerAngle.IsUsed()||this._uLayoutStart.IsUsed()||this._uLayoutEnd.IsUsed()),s.parameters||[]);this._uCustomParameters=[],this._usesAnySrcRectOrPixelSize=this._uPixelSize.IsUsed()||this._uSrcStart.IsUsed()||this._uSrcEnd.IsUsed()||this._uSrcOriginStart.IsUsed()||this._uSrcOriginEnd.IsUsed(),this._hasCurrentMatP=!1,this._hasCurrentMatMV=!1,this._uColor.Init4f(1,1,1,1),this._uColor2.Init4f(1,1,1,1),this._uSamplerFront.Init1i(0),this._uSamplerBack.Init1i(1),this._uSamplerDepth.Init1i(2),this._uPointTexStart.Init2f(0,0),this._uPointTexEnd.Init2f(1,1),this._uZElevation.Init1f(0),this._uTileSize.Init2f(0,0),this._uTileSpacing.Init2f(0,0),this._uDestStart.Init2f(0,0),this._uDestEnd.Init2f(1,1),this._uSrcStart.Init2f(0,0),this._uSrcEnd.Init2f(0,0),this._uSrcOriginStart.Init2f(0,0),this._uSrcOriginEnd.Init2f(0,0),this._uPixelSize.Init2f(0,0),this._uDevicePixelRatio.Init1f(1),this._uZNear.Init1f(e.GetNearZ()),this._uZFar.Init1f(e.GetFarZ()),this._uLayerScale.Init1f(1),this._uLayerAngle.Init1f(0),this._uSeconds.Init1f(0),this._uLayoutStart.Init2f(0,0),this._uLayoutEnd.Init2f(0,0),this._uOutlineThickness.Init1f(1);for(const h of o){const c=h[0],u=h[2],_=new C33.Gfx.WebGLShaderUniform(this,c,u);"color"===u?_.Init3f(0,0,0):_.Init1f(0),this._uCustomParameters.push(_)}this._isDeviceTransform?this._UpdateDeviceTransformUniforms(n.currentMatP):(this.UpdateMatP(n.currentMatP,!0),this.UpdateMatMV(n.currentMV,!0));const l=n.currentShader;i.useProgram(l?l._shaderProgram:null)}Release(){this._gl.deleteProgram(this._shaderProgram),this._shaderProgram=null,this._renderer._RemoveShaderProgram(this),this._gl=null,super.Release()}GetWebGLContext(){return this._gl}GetShaderProgram(){return this._shaderProgram}GetParameterCount(){return this._uCustomParameters.length}GetParameterType(e){return e<0||e>=this._uCustomParameters.length?null:this._uCustomParameters[e].GetType()}AreCustomParametersAlreadySetInBatch(s){for(let e=0,t=s.length;e<t;++e)if(!this._uCustomParameters[e].IsSetToCustomInBatch(s[e]))return!1;return!0}SetCustomParametersInBatch(s){for(let e=0,t=s.length;e<t;++e)this._uCustomParameters[e].SetBatchValueCustom(s[e])}AreOptionalUniformsAlreadySetInBatch(e,t,s,i,n,r,a,o,l,h){return!this._uSamplerBack.IsUsed()&&!(this._uPixelSize.IsUsed()&&!this._uPixelSize.IsSetTo2InBatch(n,r)||this._uDestStart.IsUsed()&&!this._uDestStart.IsSetTo2InBatch(e.getLeft(),e.getTop())||this._uDestEnd.IsUsed()&&!this._uDestEnd.IsSetTo2InBatch(e.getRight(),e.getBottom())||this._uDevicePixelRatio.IsUsed()&&!this._uDevicePixelRatio.IsSetTo1InBatch(a)||this._uLayerScale.IsUsed()&&!this._uLayerScale.IsSetTo1InBatch(o)||this._uLayerAngle.IsUsed()&&!this._uLayerAngle.IsSetTo1InBatch(l)||this._uSrcStart.IsUsed()&&!this._uSrcStart.IsSetTo2InBatch(t.getLeft(),t.getTop())||this._uSrcEnd.IsUsed()&&!this._uSrcEnd.IsSetTo2InBatch(t.getRight(),t.getBottom())||this._uSrcOriginStart.IsUsed()&&!this._uSrcOriginStart.IsSetTo2InBatch(s.getLeft(),s.getTop())||this._uSrcOriginEnd.IsUsed()&&!this._uSrcOriginEnd.IsSetTo2InBatch(s.getRight(),s.getBottom())||this._uLayoutStart.IsUsed()&&!this._uLayoutStart.IsSetTo2InBatch(i.getLeft(),i.getTop())||this._uLayoutEnd.IsUsed()&&!this._uLayoutEnd.IsSetTo2InBatch(i.getTop(),i.getBottom())||this._uSeconds.IsUsed()&&!this._uSeconds.IsSetTo1InBatch(h))}SetOptionalUniformsInBatch(e,t,s,i,n,r,a,o,l,h){this._uSamplerBack.IsUsed()||(this._uPixelSize.IsUsed()&&this._uPixelSize.SetBatch2(n,r),this._uDestStart.IsUsed()&&this._uDestStart.SetBatch2(e.getLeft(),e.getTop()),this._uDestEnd.IsUsed()&&this._uDestEnd.SetBatch2(e.getRight(),e.getBottom()),this._uDevicePixelRatio.IsUsed()&&this._uDevicePixelRatio.SetBatch1(a),this._uLayerScale.IsUsed()&&this._uLayerScale.SetBatch1(o),this._uLayerAngle.IsUsed()&&this._uLayerAngle.SetBatch1(l),this._uSrcStart.IsUsed()&&this._uSrcStart.SetBatch2(t.getLeft(),t.getTop()),this._uSrcEnd.IsUsed()&&this._uSrcEnd.SetBatch2(t.getRight(),t.getBottom()),this._uSrcOriginStart.IsUsed()&&this._uSrcOriginStart.SetBatch2(s.getLeft(),s.getTop()),this._uSrcOriginEnd.IsUsed()&&this._uSrcOriginEnd.SetBatch2(s.getRight(),s.getBottom()),this._uLayoutStart.IsUsed()&&this._uLayoutStart.SetBatch2(i.getLeft(),i.getTop()),this._uLayoutEnd.IsUsed()&&this._uLayoutEnd.SetBatch2(i.getTop(),i.getBottom()),this._uSeconds.IsUsed()&&this._uSeconds.SetBatch1(h))}UpdateMatP(e,t){this._hasCurrentMatP&&!t||this._isDeviceTransform||(this._uMatP.IsUsed()&&this._uMatP.UpdateMatrix4fv(e),this._hasCurrentMatP=!0)}SetMatPStale(){this._hasCurrentMatP=!1}UpdateMatMV(e,t){this._hasCurrentMatMV&&!t||this._isDeviceTransform||(this._uMatMV.IsUsed()&&this._uMatMV.UpdateMatrix4fv(e),this._hasCurrentMatMV=!0)}SetMatMVStale(){this._hasCurrentMatMV=!1}_UpdateDeviceTransformUniforms(e){if(!this._isDeviceTransform)throw new Error("not device transform shader");this._uMatP.UpdateMatrix4fv(e);const t=this._renderer,s=t.GetWidth()/2,i=t.GetHeight()/2,n=t.CalculateLookAtModelView2(s,i,t.GetDefaultCameraZ(t.GetHeight()),s,i,0,t.GetHeight());this._uMatMV.UpdateMatrix4fv(n)}UpdateColor(e){this._uColor.IsUsed()&&this._uColor.Update4f(e[0],e[1],e[2],e[3])}static GetReservedUniformNames(){return RESERVED_UNIFORM_NAMES}static GetDefaultVertexShaderSource(e){const t=e?"highmedp":"mediump";return["#ifdef GL_FRAGMENT_PRECISION_HIGH","#define highmedp highp","#else","#define highmedp mediump","#endif","attribute highp vec3 aPos;",`attribute ${t} vec2 aTex;`,`varying ${t} vec2 vTex;`,"uniform highp mat4 matP;","uniform highp mat4 matMV;","void main(void) {",` gl_Position = matP * matMV * vec4(aPos, 1.0);`,` vTex = aTex;`,"}"].join("\n")}static GetDefaultVertexShaderSource_WebGL2(e){const t=e?"highp":"mediump";return["#version 300 es","in highp vec3 aPos;",`in ${t} vec2 aTex;`,`out ${t} vec2 vTex;`,"uniform highp mat4 matP;","uniform highp mat4 matMV;","void main(void) {",` gl_Position = matP * matMV * vec4(aPos, 1.0);`,` vTex = aTex;`,"}"].join("\n")}static GetTextureFillFragmentShaderSource_WebGL1_NoFragDepth(){return["varying mediump vec2 vTex;","uniform lowp vec4 color;","uniform lowp sampler2D samplerFront;","void main(void) {","\tgl_FragColor = texture2D(samplerFront, vTex) * color;","}"].join("\n")}static GetTextureFillFragmentShaderSource_WebGL1_FragDepthEXT(){return["#extension GL_EXT_frag_depth : enable","varying mediump vec2 vTex;","uniform lowp vec4 color;","uniform lowp sampler2D samplerFront;","void main(void) {","\tgl_FragColor = texture2D(samplerFront, vTex) * color;","\tgl_FragDepthEXT = (gl_FragColor.a == 0.0 ? 1.0 : gl_FragCoord.z);","}"].join("\n")}static GetTextureFillFragmentShaderSource_WebGL2(){return["#version 300 es","in mediump vec2 vTex;","out lowp vec4 outColor;","uniform lowp vec4 color;","uniform lowp sampler2D samplerFront;","void main(void) {","\toutColor = texture(samplerFront, vTex) * color;","\tgl_FragDepth = (outColor.a == 0.0 ? 1.0 : gl_FragCoord.z);","}"].join("\n")}static GetTilemapFragmentShaderSource_WebGL1_NoFragDepth(){return["#ifdef GL_FRAGMENT_PRECISION_HIGH","#define highmedp highp","#else","#define highmedp mediump","#endif","varying highmedp vec2 vTex;","uniform lowp vec4 color;","uniform lowp sampler2D samplerFront;","uniform highmedp vec2 srcStart;","uniform highmedp vec2 pixelSize;","uniform highmedp vec2 tileSize;","uniform highmedp vec2 tileSpacing;","void main(void) {","\thighmedp vec2 tile = floor(vTex);","\thighmedp vec2 tex = fract(vTex);","\thighmedp vec2 tileOrigin = srcStart + tile * (tileSize + tileSpacing);","\thighmedp vec2 lowerBound = tileOrigin + pixelSize / 2.0;","\thighmedp vec2 upperBound = tileOrigin + tileSize - pixelSize / 2.0;","\tgl_FragColor = texture2D(samplerFront, clamp(tex, lowerBound, upperBound), -16.0) * color;","}"].join("\n")}static GetTilemapFragmentShaderSource_WebGL1_FragDepthEXT(){return["#extension GL_EXT_frag_depth : enable","#ifdef GL_FRAGMENT_PRECISION_HIGH","#define highmedp highp","#else","#define highmedp mediump","#endif","varying highmedp vec2 vTex;","uniform lowp vec4 color;","uniform lowp sampler2D samplerFront;","uniform highmedp vec2 srcStart;","uniform highmedp vec2 pixelSize;","uniform highmedp vec2 tileSize;","uniform highmedp vec2 tileSpacing;","void main(void) {","\thighmedp vec2 tile = floor(vTex);","\thighmedp vec2 tex = fract(vTex);","\thighmedp vec2 tileOrigin = srcStart + tile * (tileSize + tileSpacing);","\thighmedp vec2 lowerBound = tileOrigin + pixelSize / 2.0;","\thighmedp vec2 upperBound = tileOrigin + tileSize - pixelSize / 2.0;","\tgl_FragColor = texture2D(samplerFront, clamp(tex, lowerBound, upperBound), -16.0) * color;","\tgl_FragDepthEXT = (gl_FragColor.a == 0.0 ? 1.0 : gl_FragCoord.z);","}"].join("\n")}static GetTilemapFragmentShaderSource_WebGL2(){return["#version 300 es","in highp vec2 vTex;","out lowp vec4 outColor;","uniform lowp vec4 color;","uniform lowp sampler2D samplerFront;","uniform highp vec2 srcStart;","uniform highp vec2 pixelSize;","uniform highp vec2 tileSize;","uniform highp vec2 tileSpacing;","void main(void) {","\thighp vec2 tile = floor(vTex);","\thighp vec2 tex = fract(vTex);","\thighp vec2 tileOrigin = srcStart + tile * (tileSize + tileSpacing);","\thighp vec2 lowerBound = tileOrigin + pixelSize / 2.0;","\thighp vec2 upperBound = tileOrigin + tileSize - pixelSize / 2.0;","\toutColor = texture(samplerFront, clamp(tex, lowerBound, upperBound), -16.0) * color;","\tgl_FragDepth = (outColor.a == 0.0 ? 1.0 : gl_FragCoord.z);","}"].join("\n")}static GetTileRandomizationFragmentShaderSource(e,t,s){let i="";return 2<=e?i="#version 300 es\n":(t&&(i="#extension GL_EXT_frag_depth : enable\n"),s&&(i+="#extension GL_EXT_shader_texture_lod : enable\n#extension GL_OES_standard_derivatives : enable\n")),i+` #ifdef GL_FRAGMENT_PRECISION_HIGH #define highmedp highp #else #define highmedp mediump #endif precision highmedp float; ${2<=e?"in":"varying"} vec2 vTex; ${2<=e?"out lowp vec4 outColor;":""} uniform lowp vec4 color; uniform lowp sampler2D samplerFront; uniform vec2 pixelSize; uniform vec2 tileSize; uniform vec2 tileSpacing; uniform float outlineThickness; const float PI = 3.1415926; lowp vec4 cospVec4(lowp vec4 a, lowp vec4 b, float x) { return (a + b + (a - b) * cos(x * PI)) / 2.0; } vec3 randVec3(vec2 seed) { return vec3(fract(sin(dot(seed.xy + vec2(0.1, 0.1), vec2(12.9898,78.233))) * 43758.5453), fract(sin(dot(seed.yx + vec2(0.1, 0.1), vec2(12.9898,-78.233))) * 43758.5453), fract(sin(dot(seed.xy + vec2(0.1, 0.1), vec2(-12.9898,-78.233))) * 43758.5453)); } lowp vec4 sampleTile(vec2 tile, vec2 uv, vec2 ddx, vec2 ddy) { vec2 posRandom = tileSize; float angleRandom = outlineThickness; vec3 rand = (randVec3(floor(tile + 0.5)) - 0.5) * 2.0; float angle = angleRandom * rand.z * PI; float sin_a = sin(angle); float cos_a = cos(angle); float aspect = pixelSize.x / pixelSize.y; vec2 mid = tile + vec2(0.5, 0.5); vec2 dp = uv - mid; dp.x /= aspect; vec2 r = vec2(dp.x * cos_a - dp.y * sin_a, dp.y * cos_a + dp.x * sin_a); r.x *= aspect; vec2 p = mid + r + (posRandom * rand.xy / 2.0); ${2<=e?"return textureGrad(samplerFront, p, ddx, ddy);":""} ${e<2&&s?"return texture2DGradEXT(samplerFront, p, ddx, ddy);":""} ${e<2&&!s?"return texture2D(samplerFront, p);":""} } void main(void) { ${e<2?"lowp vec4 outColor;":""} float blendMarginX = tileSpacing.x; float blendMarginY = tileSpacing.y; vec2 tile = floor(vTex); vec2 tex = fract(vTex); vec2 ddx = ${2<=e||s?"dFdx(vTex)":"vec2(0.0, 0.0)"}; vec2 ddy = ${2<=e||s?"dFdy(vTex)":"vec2(0.0, 0.0)"}; vec4 curTile = sampleTile(tile, vTex, ddx, ddy); bool inLeftMargin = (tex.x < blendMarginX); bool inRightMargin = (tex.x > 1.0 - blendMarginX); bool inTopMargin = (tex.y < blendMarginY); bool inBottomMargin = (tex.y > 1.0 - blendMarginY); if (inLeftMargin) { lowp vec4 leftTile = sampleTile(tile + vec2(-1.0, 0.0), vTex, ddx, ddy); float leftMix = (tex.x / (blendMarginX * 2.0)) + 0.5; lowp vec4 leftMixedTile = cospVec4(leftTile, curTile, leftMix); if (inTopMargin) { lowp vec4 topTile = sampleTile(tile + vec2(0.0, -1.0), vTex, ddx, ddy); lowp vec4 topLeftTile = sampleTile(tile + vec2(-1.0, -1.0), vTex, ddx, ddy); lowp vec4 topLeftMixedTile = cospVec4(topLeftTile, topTile, leftMix); outColor = cospVec4(topLeftMixedTile, leftMixedTile, (tex.y / (blendMarginY * 2.0)) + 0.5); } else if (inBottomMargin) { lowp vec4 bottomTile = sampleTile(tile + vec2(0.0, 1.0), vTex, ddx, ddy); lowp vec4 bottomLeftTile = sampleTile(tile + vec2(-1.0, 1.0), vTex, ddx, ddy); lowp vec4 bottomLeftMixedTile = cospVec4(bottomLeftTile, bottomTile, leftMix); outColor = cospVec4(leftMixedTile, bottomLeftMixedTile, (tex.y - (1.0 - blendMarginY)) / (blendMarginY * 2.0)); } else { outColor = leftMixedTile; } } else if (inRightMargin) { lowp vec4 rightTile = sampleTile(tile + vec2(1.0, 0.0), vTex, ddx, ddy); float rightMix = (tex.x - (1.0 - blendMarginX)) / (blendMarginX * 2.0); lowp vec4 rightMixedTile = cospVec4(curTile, rightTile, rightMix); if (inTopMargin) { lowp vec4 topTile = sampleTile(tile + vec2(0.0, -1.0), vTex, ddx, ddy); lowp vec4 topRightTile = sampleTile(tile + vec2(1.0, -1.0), vTex, ddx, ddy); lowp vec4 topRightMixedTile = cospVec4(topTile, topRightTile, rightMix); outColor = cospVec4(topRightMixedTile, rightMixedTile, (tex.y / (blendMarginY * 2.0)) + 0.5); } else if (inBottomMargin) { lowp vec4 bottomTile = sampleTile(tile + vec2(0.0, 1.0), vTex, ddx, ddy); lowp vec4 bottomRightTile = sampleTile(tile + vec2(1.0, 1.0), vTex, ddx, ddy); lowp vec4 bottomRightMixedTile = cospVec4(bottomTile, bottomRightTile, rightMix); outColor = cospVec4(rightMixedTile, bottomRightMixedTile, (tex.y - (1.0 - blendMarginY)) / (blendMarginY * 2.0)); } else { outColor = rightMixedTile; } } else if (inTopMargin) { lowp vec4 topTile = sampleTile(tile + vec2(0.0, -1.0), vTex, ddx, ddy); outColor = cospVec4(topTile, curTile, (tex.y / (blendMarginY * 2.0)) + 0.5); } else if (inBottomMargin) { lowp vec4 bottomTile = sampleTile(tile + vec2(0.0, 1.0), vTex, ddx, ddy); outColor = cospVec4(curTile, bottomTile, (tex.y - (1.0 - blendMarginY)) / (blendMarginY * 2.0)); } else { outColor = curTile; } outColor *= color; ${e<2?"gl_FragColor = outColor;":""} ${2<=e?"gl_FragDepth = (outColor.a == 0.0 ? 1.0 : gl_FragCoord.z);":""} ${e<2&&t?"gl_FragDepthEXT = (outColor.a == 0.0 ? 1.0 : gl_FragCoord.z);":""} } `}static GetPointVertexShaderSource_WebGL1(){return["attribute vec4 aPoints;","varying float pointOpacity;","uniform float zElevation;","uniform mat4 matP;","uniform mat4 matMV;","void main(void) {","\tgl_Position = matP * matMV * vec4(aPoints.xy, zElevation, 1.0);","\tgl_PointSize = aPoints.z;","\tpointOpacity = aPoints.w;","}"].join("\n")}static GetPointVertexShaderSource_WebGL2(){return["#version 300 es","in vec4 aPoints;","out float pointOpacity;","uniform float zElevation;","uniform mat4 matP;","uniform mat4 matMV;","void main(void) {","\tgl_Position = matP * matMV * vec4(aPoints.xy, zElevation, 1.0);","\tgl_PointSize = aPoints.z;","\tpointOpacity = aPoints.w;","}"].join("\n")}static GetPointFragmentShaderSource_WebGL1_NoFragDepth(){return["uniform lowp sampler2D samplerFront;","varying lowp float pointOpacity;","uniform mediump vec2 pointTexStart;","uniform mediump vec2 pointTexEnd;","uniform lowp vec4 color;","void main(void) {","\tmediump vec2 pointTexMin = min(pointTexStart, pointTexEnd);","\tmediump vec2 pointTexMax = max(pointTexStart, pointTexEnd);","\tmediump vec2 pointCoord = (pointTexEnd.x > pointTexStart.x ? gl_PointCoord : vec2(1.0 - gl_PointCoord.y, gl_PointCoord.x));","\tgl_FragColor = texture2D(samplerFront, mix(pointTexMin, pointTexMax, pointCoord)) * color * pointOpacity;","}"].join("\n")}static GetPointFragmentShaderSource_WebGL1_FragDepthEXT(){return["#extension GL_EXT_frag_depth : enable","uniform lowp sampler2D samplerFront;","varying lowp float pointOpacity;","uniform mediump vec2 pointTexStart;","uniform mediump vec2 pointTexEnd;","uniform lowp vec4 color;","void main(void) {","\tmediump vec2 pointTexMin = min(pointTexStart, pointTexEnd);","\tmediump vec2 pointTexMax = max(pointTexStart, pointTexEnd);","\tmediump vec2 pointCoord = (pointTexEnd.x > pointTexStart.x ? gl_PointCoord : vec2(1.0 - gl_PointCoord.y, gl_PointCoord.x));","\tgl_FragColor = texture2D(samplerFront, mix(pointTexMin, pointTexMax, pointCoord)) * color * pointOpacity;","\tgl_FragDepthEXT = (gl_FragColor.a == 0.0 ? 1.0 : gl_FragCoord.z);","}"].join("\n")}static GetPointFragmentShaderSource_WebGL2(){return["#version 300 es","uniform lowp sampler2D samplerFront;","in lowp float pointOpacity;","uniform mediump vec2 pointTexStart;","uniform mediump vec2 pointTexEnd;","uniform lowp vec4 color;","out lowp vec4 outColor;","void main(void) {","\tmediump vec2 pointTexMin = min(pointTexStart, pointTexEnd);","\tmediump vec2 pointTexMax = max(pointTexStart, pointTexEnd);","\tmediump vec2 pointCoord = (pointTexEnd.x > pointTexStart.x ? gl_PointCoord : vec2(1.0 - gl_PointCoord.y, gl_PointCoord.x));","\toutColor = texture(samplerFront, mix(pointTexMin, pointTexMax, pointCoord)) * color * pointOpacity;","\tgl_FragDepth = (outColor.a == 0.0 ? 1.0 : gl_FragCoord.z);","}"].join("\n")}static GetColorFillFragmentShaderSource(){return["uniform lowp vec4 color;","void main(void) {","\tgl_FragColor = color;","}"].join("\n")}static GetLinearGradientFillFragmentShaderSource(){return["precision lowp float;","varying mediump vec2 vTex;","uniform vec4 color;","uniform vec4 color2_;","vec3 fromLinear(vec3 linearRGB)","{","\tbvec3 cutoff = lessThan(linearRGB, vec3(0.0031308));","\tvec3 higher = vec3(1.055) * pow(abs(linearRGB), vec3(1.0/2.4)) - vec3(0.055);","\tvec3 lower = linearRGB * vec3(12.92);","\treturn mix(higher, lower, vec3(cutoff));","}","vec3 toLinear(vec3 sRGB)","{","\tbvec3 cutoff = lessThan(sRGB, vec3(0.04045));","\tvec3 higher = pow(abs((sRGB + vec3(0.055))/vec3(1.055)), vec3(2.4));","\tvec3 lower = sRGB/vec3(12.92);","\treturn mix(higher, lower, vec3(cutoff));","}","void main(void) {","\tvec3 linearGrad = mix(toLinear(color.rgb), toLinear(color2_.rgb), vTex.x);","\tfloat a = mix(color.a, color2_.a, vTex.x);","\tgl_FragColor = vec4(fromLinear(linearGrad) * a, a);","}"].join("\n")}static GetPenumbraFillFragmentShaderSource(){return["#ifdef GL_FRAGMENT_PRECISION_HIGH","#define highmedp highp","#else","#define highmedp mediump","#endif","precision lowp float;","varying highmedp vec2 vTex;","uniform vec4 color;","void main(void) {",` highmedp float grad = vTex.x / (1.0 - vTex.y);`,` gl_FragColor = color * (1.0 - (cos(grad * 3.141592653589793) + 1.0) / 2.0);`,"}"].join("\n")}static GetSmoothLineFillFragmentShaderSource(){return["varying mediump vec2 vTex;","uniform lowp vec4 color;","void main(void) {","\tlowp float f = 1.0 - abs(vTex.y - 0.5) * 2.0;","\tgl_FragColor = color * f;","}"].join("\n")}static GetHardEllipseFillFragmentShaderSource(){return["varying mediump vec2 vTex;","uniform lowp vec4 color;","void main(void) {","\tmediump vec2 diff = vTex - vec2(0.5, 0.5);","\tmediump vec2 diffSq = diff * diff;","\tmediump float f = step(diffSq.x + diffSq.y, 0.25);","\tgl_FragColor = color * f;","}"].join("\n")}static GetHardEllipseOutlineFragmentShaderSource(){return["varying mediump vec2 vTex;","uniform lowp vec4 color;","uniform mediump vec2 pixelSize;","uniform mediump float outlineThickness;","void main(void) {","\tmediump vec2 diff = vTex - vec2(0.5, 0.5);","\tmediump vec2 diffSq = diff * diff;","\tmediump float distSq = diffSq.x + diffSq.y;","\tmediump vec2 norm = normalize(diff);","\tmediump vec2 halfNorm = norm * 0.5;","\tmediump float innerF = step(distSq, 0.25);","\tmediump vec2 innerEdge = halfNorm - pixelSize * norm * outlineThickness;","\tmediump vec2 innerEdgeSq = innerEdge * innerEdge;","\tmediump float outerF = step(innerEdgeSq.x + innerEdgeSq.y, distSq);","\tgl_FragColor = color * innerF * outerF;","}"].join("\n")}static GetSmoothEllipseFillFragmentShaderSource(){return["varying mediump vec2 vTex;","uniform lowp vec4 color;","uniform mediump vec2 pixelSize;","void main(void) {","\tmediump vec2 diff = vTex - vec2(0.5, 0.5);","\tmediump vec2 diffSq = diff * diff;","\tmediump vec2 norm = normalize(diff);","\tmediump vec2 halfNorm = norm * 0.5;","\tmediump vec2 halfNormSq = halfNorm * halfNorm;","\tmediump vec2 innerEdge = halfNorm - pixelSize * norm;","\tmediump vec2 innerEdgeSq = innerEdge * innerEdge;","\tmediump float f = smoothstep(halfNormSq.x + halfNormSq.y, innerEdgeSq.x + innerEdgeSq.y, diffSq.x + diffSq.y);","\tgl_FragColor = color * f;","}"].join("\n")}static GetSmoothEllipseOutlineFragmentShaderSource(){return["varying mediump vec2 vTex;","uniform lowp vec4 color;","uniform mediump vec2 pixelSize;","uniform mediump float outlineThickness;","void main(void) {","\tmediump vec2 diff = vTex - vec2(0.5, 0.5);","\tmediump vec2 diffSq = diff * diff;","\tmediump float distSq = diffSq.x + diffSq.y;","\tmediump vec2 norm = normalize(diff);","\tmediump vec2 halfNorm = norm * 0.5;","\tmediump vec2 halfNormSq = halfNorm * halfNorm;","\tmediump vec2 pxNorm = pixelSize * norm;","\tmediump vec2 innerEdge1 = halfNorm - pxNorm;","\tmediump vec2 innerEdge1Sq = innerEdge1 * innerEdge1;","\tmediump float innerF = smoothstep(halfNormSq.x + halfNormSq.y, innerEdge1Sq.x + innerEdge1Sq.y, distSq);","\tmediump vec2 innerEdge2 = halfNorm - pxNorm * outlineThickness;","\tmediump vec2 innerEdge2Sq = innerEdge2 * innerEdge2;","\tmediump vec2 innerEdge3 = halfNorm - pxNorm * (outlineThickness + 1.0);","\tmediump vec2 innerEdge3Sq = innerEdge3 * innerEdge3;","\tmediump float outerF = smoothstep(innerEdge3Sq.x + innerEdge3Sq.y, innerEdge2Sq.x + innerEdge2Sq.y, distSq);","\tgl_FragColor = color * innerF * outerF;","}"].join("\n")}}}{const C33=self.C3,glMatrix=self.glMatrix,mat42=glMatrix.mat4,TYPE_SIZES=new Map([["float",1],["percent",1],["sampler",1],["vec2",2],["vec3",3],["color",3],["vec4",4],["mat4",16]]);C33.Gfx.WebGLShaderUniform=class{constructor(e,t,s){if(!TYPE_SIZES.has(s))throw new Error("invalid uniform type");this._owner=e,this._gl=this._owner.GetWebGLContext(),this._name=t,this._type=s,this._isColorType="color"===this._type,this._location=this._gl.getUniformLocation(this._owner.GetShaderProgram(),t),this._isUsed=!!this._location;const i=TYPE_SIZES.get(s);this._lastValue=new Float32Array(i),this._lastBatchValue=new Float32Array(i)}Release(){this._owner=null,this._gl=null,this._location=null}IsUsed(){return this._isUsed}GetType(){return this._type}IsColorType(){return this._isColorType}Init1f(e){this.IsUsed()&&(this._lastValue[0]=e,this._lastBatchValue.set(this._lastValue),this._gl.uniform1f(this._location,e))}Init1i(e){this.IsUsed()&&(this._lastValue[0]=e,this._lastBatchValue.set(this._lastValue),this._gl.uniform1i(this._location,e))}Init2f(e,t){this.IsUsed()&&(this._lastValue[0]=e,this._lastValue[1]=t,this._lastBatchValue.set(this._lastValue),this._gl.uniform2f(this._location,e,t))}Init3f(e,t,s){this.IsUsed()&&(this._lastValue[0]=e,this._lastValue[1]=t,this._lastValue[2]=s,this._lastBatchValue.set(this._lastValue),this._gl.uniform3f(this._location,e,t,s))}Init4f(e,t,s,i){this.IsUsed()&&(this._lastValue[0]=e,this._lastValue[1]=t,this._lastValue[2]=s,this._lastValue[3]=i,this._lastBatchValue.set(this._lastValue),this._gl.uniform4f(this._location,e,t,s,i))}Update1f(e){e=Math.fround(e);const t=this._lastValue;t[0]!==e&&(t[0]=e,this._gl.uniform1f(this._location,e))}Update1i(e){const t=this._lastValue;t[0]!==e&&this._gl.uniform1i(this._location,t[0]=e)}Update2f(e,t){e=Math.fround(e),t=Math.fround(t);const s=this._lastValue;s[0]===e&&s[1]===t||(s[0]=e,s[1]=t,this._gl.uniform2f(this._location,e,t))}Update3f(e,t,s){e=Math.fround(e),t=Math.fround(t),s=Math.fround(s);const i=this._lastValue;i[0]===e&&i[1]===t&&i[2]===s||(i[0]=e,i[1]=t,i[2]=s,this._gl.uniform3f(this._location,e,t,s))}Update4f(e,t,s,i){e=Math.fround(e),t=Math.fround(t),s=Math.fround(s),i=Math.fround(i);const n=this._lastValue;n[0]===e&&n[1]===t&&n[2]===s&&n[3]===i||(n[0]=e,n[1]=t,n[2]=s,n[3]=i,this._gl.uniform4f(this._location,e,t,s,i))}UpdateMatrix4fv(e){const t=this._lastValue;mat42.exactEquals(t,e)||(C33.typedArraySet16(t,e,0),this._gl.uniformMatrix4fv(this._location,!1,e))}IsSetToCustomInBatch(e){const t=this._lastBatchValue;return this.IsColorType()?t[0]===Math.fround(e.getR())&&t[1]===Math.fround(e.getG())&&t[2]===Math.fround(e.getB()):t[0]===Math.fround(e)}SetBatchValueCustom(e){const t=this._lastBatchValue;this.IsColorType()?(t[0]=e.getR(),t[1]=e.getG(),t[2]=e.getB()):t[0]=e}IsSetTo1InBatch(e){return this._lastBatchValue[0]===Math.fround(e)}IsSetTo2InBatch(e,t){const s=this._lastBatchValue;return s[0]===Math.fround(e)&&s[1]===Math.fround(t)}SetBatch1(e){this._lastBatchValue[0]=e}SetBatch2(e,t){const s=this._lastBatchValue;s[0]=e,s[1]=t}}}{const C33=self.C3,glMatrix=self.glMatrix,vec42=glMatrix.vec4,mat42=glMatrix.mat4,BATCH_NULL=0,BATCH_QUAD=1,BATCH_SETTEXTURE=2,BATCH_SETCOLOR=3,BATCH_SETBLEND=4,BATCH_SETVIEWPORT=5,BATCH_SETPROJECTION=6,BATCH_SETMODELVIEW=7,BATCH_SETRENDERTARGET=8,BATCH_CLEARSURFACE=9,BATCH_POINTS=10,BATCH_SETPROGRAM=11,BATCH_SETPROGRAMPARAMETERS=12,BATCH_SETPROGRAMCUSTOMPARAMETERS=13,BATCH_INVALIDATEFRAMEBUFFER=14,BATCH_SETPOINTTEXCOORDS=15,BATCH_SETTILEMAPINFO=16,BATCH_BLITFRAMEBUFFER=17,BATCH_STARTQUERY=18,BATCH_ENDQUERY=19,BATCH_SETELLIPSEPARAMS=20,BATCH_SETGRADIENTCOLOR=21,BATCH_CLEARDEPTH=22,BATCH_SETDEPTHENABLED=23,BATCH_SETDEPTHSAMPLINGENABLED=24,BATCH_COPLANAR_STARTSTENCILPASS=25,BATCH_COPLANAR_STARTCOLORPASS=26,BATCH_COPLANAR_RESTORE=27,BATCH_SET_SCISSOR=28,BATCH_SETTILERANDOMIZATIONINFO=29;C33.Gfx.BatchState=class{constructor(e){this.renderer=e,this.currentMV=mat42.create(),this.currentMatP=mat42.create(),this.currentFramebuffer=null,this.currentFramebufferNoDepth=null,this.isDepthSamplingEnabled=!1,this.currentColor=vec42.fromValues(1,1,1,1),this.currentShader=null,this.pointTexCoords=new C33.Rect,this.clearColor=C33.New(C33.Color,0,0,0,0)}},C33.Gfx.WebGLBatchJob=class{constructor(e){const t=new ArrayBuffer(96);this._type=0,this._batchState=e,this._gl=e.renderer.GetContext(),this._startIndex=0,this._indexCount=0,this._texParam=null,this._mat4param=new Float32Array(t,0,16),this._colorParam=new Float32Array(t,64,4),this._srcOriginRect=new Float32Array(t,80,4),this._shaderParams=[]}InitQuad(e,t){this._type=BATCH_QUAD,this._startIndex=e,this._indexCount=t}DoQuad(){const e=this._gl;e.drawElements(e.TRIANGLES,this._indexCount,e.UNSIGNED_SHORT,this._startIndex)}InitSetTexture(e){this._type=BATCH_SETTEXTURE,this._texParam=e}DoSetTexture(){const e=this._gl,t=this._texParam;e.bindTexture(e.TEXTURE_2D,t?t._GetTexture():null)}InitSetColor(e){this._type=BATCH_SETCOLOR,e.writeToTypedArray(this._colorParam,0)}DoSetColor(){const e=this._colorParam,t=this._batchState;vec42.copy(t.currentColor,e),t.currentShader.UpdateColor(e)}InitSetGradientColor(e){this._type=BATCH_SETGRADIENTCOLOR,e.writeToTypedArray(this._colorParam,0)}DoSetGradientColor(){const e=this._colorParam,t=this._batchState.currentShader;t._uColor2.IsUsed()&&t._uColor2.Update4f(e[0],e[1],e[2],e[3])}InitSetBlend(e,t){this._type=BATCH_SETBLEND,this._startIndex=e,this._indexCount=t}DoSetBlend(){this._gl.blendFunc(this._startIndex,this._indexCount)}InitSetViewport(e,t,s,i){this._type=BATCH_SETVIEWPORT;const n=this._colorParam;n[0]=e,n[1]=t,n[2]=s,n[3]=i}DoSetViewport(){const e=this._colorParam;this._gl.viewport(e[0],e[1],e[2],e[3])}InitSetProjection(e){this._type=BATCH_SETPROJECTION,mat42.copy(this._mat4param,e)}DoSetProjection(){const e=this._batchState,s=e.renderer._allShaderPrograms,i=e.currentShader,n=this._mat4param;for(let e=0,t=s.length;e<t;++e){const r=s[e];r===i?r.UpdateMatP(n,!0):r.SetMatPStale()}mat42.copy(e.currentMatP,n)}InitSetModelView(e){this._type=BATCH_SETMODELVIEW,mat42.copy(this._mat4param,e)}DoSetModelView(){const e=this._batchState,s=e.renderer._allShaderPrograms,i=e.currentShader,n=this._mat4param;for(let e=0,t=s.length;e<t;++e){const r=s[e];r===i?r.UpdateMatMV(n,!0):r.SetMatMVStale()}mat42.copy(e.currentMV,n)}InitSetRenderTarget(e){this._type=BATCH_SETRENDERTARGET,this._texParam=e}DoSetRenderTarget(){const e=this._gl,t=this._texParam,s=this._batchState;t?(s.currentFramebuffer=t._GetFramebuffer(),s.currentFramebufferNoDepth=t._GetFramebufferNoDepth(),s.isDepthSamplingEnabled&&s.currentFramebufferNoDepth?e.bindFramebuffer(e.FRAMEBUFFER,s.currentFramebufferNoDepth):e.bindFramebuffer(e.FRAMEBUFFER,s.currentFramebuffer)):(s.currentFramebuffer=null,s.currentFramebufferNoDepth=null,e.bindFramebuffer(e.FRAMEBUFFER,null))}InitClearSurface(e){this._type=BATCH_CLEARSURFACE,e.writeToTypedArray(this._mat4param,0)}InitClearSurface2(e,t,s,i){this._type=BATCH_CLEARSURFACE;const n=this._mat4param;n[0]=e,n[1]=t,n[2]=s,n[3]=i}DoClearSurface(){const e=this._gl,t=this._mat4param,s=this._batchState,i=s.clearColor,n=t[0],r=t[1],a=t[2],o=t[3];i.equalsRgba(n,r,a,o)||(e.clearColor(n,r,a,o),i.setRgba(n,r,a,o)),e.clear(e.COLOR_BUFFER_BIT)}InitSetPointTexCoords(e){this._type=BATCH_SETPOINTTEXCOORDS,e.writeToTypedArray(this._mat4param,0)}DoSetPointTextureCoords(){const e=this._mat4param;this._batchState.pointTexCoords.set(e[0],e[1],e[2],e[3])}InitPoints(e,t){this._type=BATCH_POINTS,this._startIndex=e,this._indexCount=1,this._mat4param[0]=t}DoPoints(){const e=this._gl,t=this._batchState,s=t.renderer,i=s._spPoints,n=(e.useProgram(i._shaderProgram),i.UpdateMatP(t.currentMatP,!1),i.UpdateMatMV(t.currentMV,!1),t.pointTexCoords),r=(i._uPointTexStart.IsUsed()&&i._uPointTexStart.Update2f(n.getLeft(),n.getTop()),i._uPointTexEnd.IsUsed()&&i._uPointTexEnd.Update2f(n.getRight(),n.getBottom()),this._mat4param[0]);if(i._uZElevation.IsUsed()&&i._uZElevation.Update1f(r),i._uColor.IsUsed()){const a=t.currentColor;i._uColor.Update4f(a[0],a[1],a[2],a[3])}e.drawArrays(e.POINTS,this._startIndex/4,this._indexCount),e.useProgram(t.currentShader._shaderProgram)}InitSetProgram(e){this._type=BATCH_SETPROGRAM,this._texParam=e}DoSetProgram(){const e=this._gl,t=this._batchState,s=this._texParam;if(t.currentShader=s,e.useProgram(s._shaderProgram),s.UpdateMatP(t.currentMatP,!1),s.UpdateMatMV(t.currentMV,!1),s._uColor.IsUsed()){const i=t.currentColor;s._uColor.Update4f(i[0],i[1],i[2],i[3])}}InitSetProgramParameters(){this._type=BATCH_SETPROGRAMPARAMETERS}DoSetProgramParameters(){const e=this._batchState.currentShader,t=this._gl,s=this._mat4param,i=this._colorParam,n=this._srcOriginRect;if(e._uSamplerBack.IsUsed()){const r=this._batchState.renderer,a=this._texParam;r._lastTexture1!==a&&(t.activeTexture(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,a?a._GetTexture():null),r._lastTexture1=a,t.activeTexture(t.TEXTURE0))}e._uPixelSize.IsUsed()&&e._uPixelSize.Update2f(s[0],s[1]),e._uDestStart.IsUsed()&&e._uDestStart.Update2f(s[2],s[3]),e._uDestEnd.IsUsed()&&e._uDestEnd.Update2f(s[4],s[5]),e._uDevicePixelRatio.IsUsed()&&e._uDevicePixelRatio.Update1f(this._indexCount),e._uLayerScale.IsUsed()&&e._uLayerScale.Update1f(s[6]),e._uLayerAngle.IsUsed()&&e._uLayerAngle.Update1f(s[7]),e._uSrcStart.IsUsed()&&e._uSrcStart.Update2f(s[12],s[13]),e._uSrcEnd.IsUsed()&&e._uSrcEnd.Update2f(s[14],s[15]),e._uSrcOriginStart.IsUsed()&&e._uSrcOriginStart.Update2f(n[0],n[1]),e._uSrcOriginEnd.IsUsed()&&e._uSrcOriginEnd.Update2f(n[2],n[3]),e._uLayoutStart.IsUsed()&&e._uLayoutStart.Update2f(i[0],i[1]),e._uLayoutEnd.IsUsed()&&e._uLayoutEnd.Update2f(i[2],i[3]),e._uSeconds.IsUsed()&&e._uSeconds.Update1f(this._startIndex)}InitSetProgramCustomParameters(){this._type=BATCH_SETPROGRAMCUSTOMPARAMETERS}DoSetProgramCustomParameters(){const e=this._batchState.currentShader,s=e._uCustomParameters,i=this._shaderParams;for(let e=0,t=s.length;e<t;++e){const n=s[e],r=i[e];n.IsColorType()?n.Update3f(r.getR(),r.getG(),r.getB()):n.Update1f(r)}}InitInvalidateFramebuffer(e){this._type=BATCH_INVALIDATEFRAMEBUFFER,this._texParam=e}DoInvalidateFramebuffer(){const e=this._gl,t=this._texParam,s=this._batchState.currentFramebuffer;t!==s&&e.bindFramebuffer(e.FRAMEBUFFER,t),e.invalidateFramebuffer(e.FRAMEBUFFER,[e.COLOR_ATTACHMENT0]),t!==s&&e.bindFramebuffer(e.FRAMEBUFFER,s)}InitBlitFramebuffer(e,t,s){this._type=BATCH_BLITFRAMEBUFFER;const i=this._mat4param,n=this._batchState.renderer,r=(i[0]=e.GetWidth(),i[1]=e.GetHeight(),i[2]=(t||n).GetWidth(),i[3]=(t||n).GetHeight(),i[4]=e.IsLinearSampling()?1:0,i[5]="stretch"===s,this._shaderParams);C33.clearArray(r),r.push(e._GetFramebuffer()),r.push(t?t._GetFramebuffer():null)}DoBlitFramebuffer(){const e=this._mat4param,t=this._shaderParams,s=this._gl,i=e[0],n=e[1],r=e[2],a=e[3],o=0!==e[4],l=0!==e[5],h=t[0],c=t[1];if(s.bindFramebuffer(s.READ_FRAMEBUFFER,h),s.bindFramebuffer(s.DRAW_FRAMEBUFFER,c),l)s.blitFramebuffer(0,0,i,n,0,0,r,a,s.COLOR_BUFFER_BIT,o?s.LINEAR:s.NEAREST);else{const u=Math.min(i,r),_=Math.min(n,a),d=Math.max(n-a,0),p=Math.max(a-n,0);s.blitFramebuffer(0,d,u,_+d,0,p,u,_+p,s.COLOR_BUFFER_BIT,s.NEAREST)}}InitStartQuery(e){this._type=BATCH_STARTQUERY,this._texParam=e}DoStartQuery(){this._texParam.BeginTimeElapsed(),this._texParam=null}InitEndQuery(e){this._type=BATCH_ENDQUERY,this._texParam=e}DoEndQuery(){this._texParam.EndTimeElapsed(),this._texParam=null}InitSetEllipseParams(e,t,s){this._type=BATCH_SETELLIPSEPARAMS;const i=this._mat4param;i[0]=e,i[1]=t,i[2]=s}DoSetEllipseParams(){const e=this._batchState.currentShader,t=this._mat4param;e._uPixelSize.IsUsed()&&e._uPixelSize.Update2f(t[0],t[1]),e._uOutlineThickness.IsUsed()&&e._uOutlineThickness.Update1f(t[2])}InitSetTilemapInfo(e,t,s,i,n,r,a){this._type=BATCH_SETTILEMAPINFO;const o=this._mat4param;e.writeToTypedArray(o,0),o[4]=1/t,o[5]=1/s,o[6]=i/t,o[7]=n/s,o[8]=r/t,o[9]=a/s}DoSetTilemapInfo(){const e=this._batchState.currentShader,t=this._mat4param;e._uSrcStart.IsUsed()&&e._uSrcStart.Update2f(t[0],t[1]),e._uPixelSize.IsUsed()&&e._uPixelSize.Update2f(t[4],t[5]),e._uTileSize.IsUsed()&&e._uTileSize.Update2f(t[6],t[7]),e._uTileSpacing.IsUsed()&&e._uTileSpacing.Update2f(t[8],t[9])}InitSetTileRandomizationInfo(e,t,s,i,n,r,a){this._type=BATCH_SETTILERANDOMIZATIONINFO;const o=this._mat4param;o[0]=1/e,o[1]=1/t,o[2]=s,o[3]=i,o[4]=n,o[5]=r,o[6]=a}DoSetTileRandomizationInfo(){const e=this._batchState.currentShader,t=this._mat4param;e._uPixelSize.IsUsed()&&e._uPixelSize.Update2f(t[0],t[1]),e._uTileSize.IsUsed()&&e._uTileSize.Update2f(t[2],t[3]),e._uOutlineThickness.IsUsed()&&e._uOutlineThickness.Update1f(t[4]),e._uTileSpacing.IsUsed()&&e._uTileSpacing.Update2f(t[5],t[6])}InitClearDepth(e){this._type=BATCH_CLEARDEPTH,this._startIndex=e?1:0}DoClearDepth(){const e=this._gl,t=0!==this._startIndex;t||e.depthMask(!0),e.clear(e.DEPTH_BUFFER_BIT),t||e.depthMask(!1)}InitSetDepthEnabled(e){this._type=BATCH_SETDEPTHENABLED,this._startIndex=e?1:0}DoSetDepthEnabled(){const e=this._gl;0===this._startIndex?(e.disable(e.DEPTH_TEST),e.depthMask(!1)):(e.enable(e.DEPTH_TEST),e.depthMask(!0))}InitSetDepthSamplingEnabled(e){this._type=BATCH_SETDEPTHSAMPLINGENABLED,this._startIndex=e?1:0}DoSetDepthSamplingEnabled(){const e=this._gl,t=this._batchState,s=t.renderer,i=0!==this._startIndex;t.isDepthSamplingEnabled=i,e.activeTexture(e.TEXTURE2),i?(t.currentFramebufferNoDepth&&e.bindFramebuffer(e.FRAMEBUFFER,t.currentFramebufferNoDepth),e.bindTexture(e.TEXTURE_2D,s._GetDepthBuffer())):(e.bindTexture(e.TEXTURE_2D,null),t.currentFramebufferNoDepth&&e.bindFramebuffer(e.FRAMEBUFFER,t.currentFramebuffer)),e.activeTexture(e.TEXTURE0)}InitCoplanarStartStencilPass(){this._type=BATCH_COPLANAR_STARTSTENCILPASS}DoCoplanarStartStencilPass(){const e=this._gl;e.clear(e.STENCIL_BUFFER_BIT),e.enable(e.STENCIL_TEST),e.stencilFunc(e.ALWAYS,1,1),e.stencilOp(e.KEEP,e.KEEP,e.REPLACE),e.colorMask(!1,!1,!1,!1)}InitCoplanarStartColorPass(){this._type=BATCH_COPLANAR_STARTCOLORPASS}DoCoplanarStartColorPass(){const e=this._gl;e.colorMask(!0,!0,!0,!0),e.stencilFunc(e.EQUAL,1,1),e.stencilOp(e.KEEP,e.KEEP,e.KEEP)}InitCoplanarRestore(){this._type=BATCH_COPLANAR_RESTORE}DoCoplanarRestore(){const e=this._gl;e.disable(e.STENCIL_TEST)}InitSetScissor(e,t,s,i,n){this._type=BATCH_SET_SCISSOR,this._startIndex=e?1:0;const r=this._mat4param;r[0]=t,r[1]=s,r[2]=i,r[3]=n}DoSetScissor(){const e=this._gl,t=this._mat4param;1===this._startIndex?(e.enable(e.SCISSOR_TEST),e.scissor(t[0],t[1],t[2],t[3])):e.disable(e.SCISSOR_TEST)}Run(){switch(this._type){case 1:return void this.DoQuad();case 2:return void this.DoSetTexture();case 3:return void this.DoSetColor();case 4:return void this.DoSetBlend();case 5:return void this.DoSetViewport();case 6:return void this.DoSetProjection();case 7:return void this.DoSetModelView();case 8:return void this.DoSetRenderTarget();case 9:return void this.DoClearSurface();case 10:return void this.DoPoints();case 11:return void this.DoSetProgram();case 12:return void this.DoSetProgramParameters();case 13:return void this.DoSetProgramCustomParameters();case 14:return void this.DoInvalidateFramebuffer();case 15:return void this.DoSetPointTextureCoords();case 16:return void this.DoSetTilemapInfo();case 17:return void this.DoBlitFramebuffer();case 18:return void this.DoStartQuery();case 19:return void this.DoEndQuery();case 20:return void this.DoSetEllipseParams();case 21:return void this.DoSetGradientColor();case 22:return void this.DoClearDepth();case 23:return void this.DoSetDepthEnabled();case 24:return void this.DoSetDepthSamplingEnabled();case 25:return void this.DoCoplanarStartStencilPass();case 26:return void this.DoCoplanarStartColorPass();case 27:return void this.DoCoplanarRestore();case 28:return void this.DoSetScissor();case 29:return void this.DoSetTileRandomizationInfo()}}}}{let fillOrStrokeRect2=function(e,t,s,i,n,r){t?e.strokeRect(s,i,n,r):e.fillRect(s,i,n,r)},ptToPx2=function(e){return e*(4/3)},getOffsetParam2=function(e,t){e=e.trim();const s=parseFloat(e);return isFinite(s)?e.endsWith("%")?t*s/100:s:0};fillOrStrokeRect=fillOrStrokeRect2,ptToPx=ptToPx2,getOffsetParam=getOffsetParam2;const C33=self.C3,MAX_TEXTURE_SIZE=4096,EXTRA_LINE_HEIGHT=4,GENERIC_FONT_FAMILIES=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),DEFAULT_OPTS={timeout:60},tempColor=new C33.Color(0,0,0,1),VALID_HORIZ_ALIGNMENTS=new Set(["left","center","right"]),VALID_VERT_ALIGNMENTS=new Set(["top","center","bottom"]),VALID_WORD_WRAP_MODES=new Set(["word","cjk","character"]),VALID_TEXT_DIRECTIONS=new Set(["ltr","rtl"]),allRendererTexts=new Set;C33.FontManager&&C33.FontManager.addEventListener("fontload",e=>{const t=e.font.GetName();for(const s of allRendererTexts)(s.IsBBCodeEnabled()||C33.equalsNoCase(s.GetFontName(),t))&&s._SetWordWrapChanged()});let didCheckFoundBoundingBoxSupport=!1,supportsFontBoundingBoxMeasurements=!1;C33.Gfx.RendererText=class{constructor(e,t){t=Object.assign({},DEFAULT_OPTS,t),this._renderer=e,this._fontName="Arial",this._fontSize=16,this._fontSizeScale=1,this._lineHeight=0,this._isBold=!1,this._isItalic=!1,this._colorStr="black",this._isBBcodeEnabled=!1,this._iconSet=null,this._iconSmoothing=!0,this.onloadfont=null,this._alreadyLoadedFonts=new Set,this._horizontalAlign="left",this._verticalAlign="top",this._text="",this._bbString=null,this._wrappedText=C33.New(C33.WordWrap),this._wrapMode="word",this._textDirection="ltr",this._wordWrapChanged=!1,this._textLayoutChanged=!1,this._drawChanged=!1,this._drawMaxCharCount=-1,this._drawCharCount=0,this._cssWidth=0,this._cssHeight=0,this._width=0,this._height=0,this._zoom=1,this._textCanvas=null,this._textContext=null,this._measureContext=null,this._measureContextTop=null,this._lastCanvasWidth=-1,this._lastCanvasHeight=-1,this._lastTextCanvasFont="",this._lastMeasureCanvasFont="",this._lastTextCanvasFillStyle="",this._lastTextCanvasOpacity=1,this._lastTextCanvasLineWidth=1,this._measureTextCallback=e=>this._MeasureText(e),this._texture=null,this._rcTex=new C33.Rect,this._scaleFactor=1,this._textureTimeout=new C33.IdleTimeout(()=>{this.ReleaseTexture(),this._SetTextCanvasSize(8,8)},t.timeout),this.ontextureupdate=null,this._wasReleased=!1,allRendererTexts.add(this)}Release(){this.onloadfont=null,this._alreadyLoadedFonts.clear(),this._iconSet=null,this._bbString=null,this._textCanvas=null,this._textContext=null,this._measureContext=null,this._measureContextTop=null,this._measureTextCallback=null,this._textureTimeout.Release(),this.ontextureupdate=null,this.ReleaseTexture(),this._wrappedText.Clear(),this._wrappedText=null,this._renderer=null,this._wasReleased=!0,allRendererTexts.delete(this)}_SetDrawChanged(){this._drawChanged=!0}_SetTextLayoutChanged(){this._SetDrawChanged(),this._textLayoutChanged=!0}_SetWordWrapChanged(){this._SetTextLayoutChanged(),this._wordWrapChanged=!0}SetBBCodeEnabled(e){if(this._isBBcodeEnabled!==(e=!!e)){this._isBBcodeEnabled=e;const t=this._isBBcodeEnabled?"alphabetic":"top";this._textContext&&(this._textContext.textBaseline=t),this._measureContext&&(this._measureContext.textBaseline=t),this._SetWordWrapChanged()}}IsBBCodeEnabled(){return this._isBBcodeEnabled}SetIconSet(e){this._iconSet!==e&&(this._iconSet=e,this._wrappedText.SetIconSet(e),this._iconSet&&this._iconSet.IsLoading()&&this._iconSet.LoadContent().then(()=>this._SetDrawChanged()),this._SetWordWrapChanged())}SetIconSmoothing(e){this._iconSmoothing!==(e=!!e)&&(this._iconSmoothing=e,this._SetDrawChanged())}SetFontName(e){this._fontName!==(e=e||"serif")&&(this._fontName=e,this._SetWordWrapChanged())}GetFontName(){return this._fontName}SetFontSize(e){this._fontSize!==(e=e<.1?.1:e)&&(this._fontSize=e,this._SetWordWrapChanged())}GetFontSize(){return this._fontSize}SetFontSizeScale(e){this._fontSizeScale!==e&&(this._fontSizeScale=e,this._SetWordWrapChanged())}SetLineHeight(e){this._lineHeight!==e&&(this._lineHeight=e,this._SetTextLayoutChanged())}GetLineHeight(){return this._lineHeight}SetBold(e){this._isBold!==(e=!!e)&&(this._isBold=e,this._SetWordWrapChanged())}IsBold(){return this._isBold}SetItalic(e){this._isItalic!==(e=!!e)&&(this._isItalic=e,this._SetWordWrapChanged())}IsItalic(){return this._isItalic}SetDrawMaxCharacterCount(e){e=Math.floor(e),this._drawMaxCharCount!==e&&(this._drawMaxCharCount=e,this._SetDrawChanged())}GetDrawMaxCharacterCount(){return this._drawMaxCharCount}_GetFontString(e,t){let s=[];(this._isBold||t.HasStyleTag("b"))&&s.push("bold"),(this._isItalic||t.HasStyleTag("i"))&&s.push("italic");const i=t.GetStyleTag("size"),n=(i?parseFloat(i.param):this._fontSize)*this._fontSizeScale;s.push(e?n+"pt":n*this.GetDrawScale()+"pt");let r=this._fontName,a=t.GetStyleTag("font");return a&&a.param&&(r=a.param,this.onloadfont)&&!this._alreadyLoadedFonts.has(r)&&(this.onloadfont(r),this._alreadyLoadedFonts.add(r)),r&&(GENERIC_FONT_FAMILIES.has(r)?s.push(r):s.push('"'+r+'"')),s.join(" ")}SetColor(e){e instanceof C33.Color&&(e=e.getCssRgb()),this._colorStr!==e&&(this._colorStr=e,this._SetDrawChanged())}SetColorRgb(e,t,s){tempColor.setRgb(e,t,s),this.SetColor(tempColor)}SetHorizontalAlignment(e){if(!VALID_HORIZ_ALIGNMENTS.has(e))throw new Error("invalid horizontal alignment");this._horizontalAlign!==e&&(this._horizontalAlign=e,this._SetTextLayoutChanged())}GetHorizontalAlignment(){return this._horizontalAlign}SetVerticalAlignment(e){if(!VALID_VERT_ALIGNMENTS.has(e))throw new Error("invalid vertical alignment");this._verticalAlign!==e&&(this._verticalAlign=e,this._SetTextLayoutChanged())}GetVerticalAlignment(){return this._verticalAlign}SetWordWrapMode(e){if(!VALID_WORD_WRAP_MODES.has(e))throw new Error("invalid word wrap mode");this._wrapMode!==e&&(this._wrapMode=e,this._SetWordWrapChanged())}GetWordWrapMode(){return this._wrapMode}SetTextDirection(e){if(!VALID_TEXT_DIRECTIONS.has(e))throw new Error("invalid text direction");this._textDirection!==e&&(this._textDirection=e,this._textContext&&(this._textContext.direction=this._textDirection),this._measureContext&&(this._measureContext.direction=this._textDirection),this._SetWordWrapChanged())}GetTextDirection(){return this._textDirection}SetText(e){this._text!==e&&(this._text=e,this._SetWordWrapChanged())}GetText(){return this._text}GetDrawScale(){return this._scaleFactor*this._zoom*self.devicePixelRatio}SetSize(r,a,o){if(void 0===o&&(o=1),!(r<=0||this._cssWidth===r&&this._cssHeight===a&&this._zoom===o)){let e=this._cssWidth,t=(this._cssWidth=r,this._cssHeight=a,this._zoom=o,self.devicePixelRatio),s=(this._width=this._cssWidth*this._zoom*t,this._height=this._cssHeight*this._zoom*t,Math.max(this._width,this._height)),i=Math.min(this._renderer.GetMaxTextureSize(),MAX_TEXTURE_SIZE),n=1;i<s&&(n=i/s,this._width=Math.min(this._width*n,i),this._height=Math.min(this._height*n,i)),this._scaleFactor=n,this._cssWidth!==e?this._SetWordWrapChanged():this._SetTextLayoutChanged()}}GetWidth(){return this._width}GetHeight(){return this._height}GetZoom(){return this._zoom}GetTextWidth(){return this._UpdateTextMeasurements(),this._wrappedText.GetMaxLineWidth()}GetTextHeight(){return this._UpdateTextMeasurements(),this._wrappedText.GetTotalLineHeight()+this._wrappedText.GetLineCount()*(this._lineHeight+EXTRA_LINE_HEIGHT)-this._lineHeight}GetLengthInGraphemes(){this._UpdateTextMeasurements();let e=0;for(const t of this._wrappedText.GetLines())for(const s of t.fragments())e+=s.GetLength();return e}GetTexture(){return this._textureTimeout.Reset(),this._MaybeUpdate(),this._texture}HitTestFragment(e,t){this._UpdateTextMeasurements();const s=this.GetDrawScale(),i=this._wrappedText.GetLines();for(const n of i){const r=n.GetFontBoundingBoxDescent()*s;if(t>=n.GetPosY()-n.GetHeight()*s+r&&t<n.GetPosY()+r)for(const a of n.fragments())if(e>=a.GetPosX()&&e<a.GetPosX()+a.GetWidth()*s)return a}return null}*fragmentsWithTag(e){this._UpdateTextMeasurements();const t=this._wrappedText.GetLines();for(const s of t)for(const i of s.fragments()){const n=i.GetStyleTag("tag");n&&C33.equalsNoCase(n.param,e)&&(yield i)}}FindFragmentWithTag(e,t){for(const s of this.fragmentsWithTag(e)){if(0===t)return s;--t}return null}CountFragmentsWithTag(e){let t=0;for(const s of this.fragmentsWithTag(e))++t;return t}_MaybeUpdate(){this._texture&&!this._drawChanged&&!this._textLayoutChanged&&!this._wordWrapChanged||this._wasReleased||this._width<=0||this._height<=0||(this._drawChanged=!1,this._DoUpdate())}_DoUpdate(){this._wasReleased||(this._UpdateTextMeasurements(),this._SetTextCanvasSize(Math.max(C33.nextHighestPowerOfTwo(Math.ceil(this._width)),128),Math.max(C33.nextHighestPowerOfTwo(Math.ceil(this._height)),64)),this._DrawTextToCanvas(),this._UpdateTexture(),this._textureTimeout.Reset())}_SetTextCanvasSize(e,t){this._textCanvas||(this._textCanvas=C33.CreateCanvas(16,16));let s=!1;this._lastCanvasWidth===e&&this._lastCanvasHeight===t||(this._lastCanvasWidth=e,this._lastCanvasHeight=t,this._textCanvas.width=e,this._textCanvas.height=t,s=!0),this._textContext||(this._textContext=this._textCanvas.getContext("2d"),s=!0),s?(this._textContext.textBaseline=this._isBBcodeEnabled?"alphabetic":"top",this._textContext.direction=this._textDirection,this._textContext.font=this._lastTextCanvasFont,this._textContext.fillStyle=this._lastTextCanvasFillStyle,this._textContext.strokeStyle=this._lastTextCanvasFillStyle,this._textContext.globalAlpha=this._lastTextCanvasOpacity,this._textContext.lineWidth=this._lastTextCanvasLineWidth):this._textContext.clearRect(0,0,e,t)}_MaybeCreateMeasureContext(){this._measureContext||(this._measureContext=C33.CreateCanvas(16,16).getContext("2d"),this._measureContextTop=C33.CreateCanvas(16,16).getContext("2d"),this._measureContext.textBaseline=this._isBBcodeEnabled?"alphabetic":"top",this._measureContextTop.textBaseline="top",this._measureContext.direction=this._textDirection,this._measureContextTop.direction=this._textDirection)}_SetMeasureFontString(e){this._lastMeasureCanvasFont!==e&&(this._lastMeasureCanvasFont=e,this._measureContext.font=e,this._measureContextTop.font=e)}_SupportsFontBoundingBoxMeasurements(){if(!didCheckFoundBoundingBoxSupport){didCheckFoundBoundingBoxSupport=!0,this._MaybeCreateMeasureContext();const e=this._measureContext.measureText("test");supportsFontBoundingBoxMeasurements="number"==typeof e.fontBoundingBoxAscent&&"number"==typeof e.fontBoundingBoxDescent}return supportsFontBoundingBoxMeasurements}_UpdateTextMeasurements(){this._UpdateWordWrap(),this._UpdateTextLayout()}_UpdateWordWrap(){this._wordWrapChanged&&(this._MaybeCreateMeasureContext(),!this._isBBcodeEnabled||this._bbString&&this._bbString.toString()===this._text||(this._bbString=new C33.BBString(this._text,{noEscape:!0})),this._wrappedText.WordWrap(this._isBBcodeEnabled?this._bbString.toFragmentList():this._text,this._measureTextCallback,this._cssWidth,this._wrapMode,0),this._wordWrapChanged=!1)}_UpdateTextLayout(){this._textLayoutChanged&&(this._LayoutText(),this._textLayoutChanged=!1)}_MeasureText(e){let t=e.IsText()?e.GetCharacterArray().join(""):" ",s=(this._SetMeasureFontString(this._GetFontString(!0,e)),e.GetStyleTag("size")),i=(s?parseFloat(s.param):this._fontSize)*this._fontSizeScale,n=this._measureContext.measureText(t),r=0;if(this._isBBcodeEnabled&&this._SupportsFontBoundingBoxMeasurements()){const a=this._measureContextTop.measureText(t);r=n.fontBoundingBoxAscent-a.fontBoundingBoxAscent}return{width:n.width,height:ptToPx2(i),fontBoundingBoxAscent:n.fontBoundingBoxAscent||0,fontBoundingBoxDescent:n.fontBoundingBoxDescent||0,topToAlphabeticDistance:r}}_SetDrawFontString(e){this._lastTextCanvasFont!==e&&(this._lastTextCanvasFont=e,this._textContext.font=e)}_SetDrawCanvasColor(e){this._lastTextCanvasFillStyle!==e&&(this._lastTextCanvasFillStyle=e,this._textContext.fillStyle=e,this._textContext.strokeStyle=e)}_SetDrawCanvasOpacity(e){this._lastTextCanvasOpacity!==e&&(this._lastTextCanvasOpacity=e,this._textContext.globalAlpha=e)}_SetDrawCanvasLineWith(e){this._lastTextCanvasLineWidth!==e&&(this._lastTextCanvasLineWidth=e,this._textContext.lineWidth=e)}_LayoutText(){let i=this.GetDrawScale(),n=(EXTRA_LINE_HEIGHT+this._lineHeight)*i,r=0,a=this._wrappedText.GetLines();if(0!==a.length){for(const t of a){t.SetPosX(NaN),t.SetPosY(NaN);for(const o of t.fragments())o.SetPosX(NaN),o.SetPosY(NaN)}let e=this._isBBcodeEnabled&&this._SupportsFontBoundingBoxMeasurements(),s=a[0].GetHeight()*i;if("center"===this._verticalAlign){const l=a.reduce((e,t)=>e+t.GetHeight()*i+n,0)-n;r=Math.max(this._height/2-l/2,0),e&&(s=a[0].GetTopToAlphabeticDistance()*i)}else if("bottom"===this._verticalAlign){const h=a.reduce((e,t)=>e+t.GetHeight()*i+n,0)-this._lineHeight*i,c=e?a.at(-1).GetFontBoundingBoxDescent()*i:0;r=this._height-h-c-2}for(let e=0,t=a.length;e<t;++e){const u=a[e],_=u.GetHeight()*i,d=r;if(this._isBBcodeEnabled){if(r+=0===e?s:_,0<e&&r>this._height-EXTRA_LINE_HEIGHT*i)break}else if(0<e&&r>=this._height-_)break;0<=d&&this._LayoutTextLine(u,r,i),this._isBBcodeEnabled||(r+=_),r+=n}}}_LayoutTextLine(e,t,s){let i=0;"center"===this._horizontalAlign?i=Math.floor((this._width-e.GetWidth()*s)/2):"right"===this._horizontalAlign&&(i=this._width-e.GetWidth()*s),e.SetPosX(i),e.SetPosY(t);for(const n of"ltr"===this._textDirection?e.fragments():e.fragmentsReverse())this._LayoutFragment(n,i,t,s),i+=n.GetWidth()*s}_LayoutFragment(e,t,s,i){const n=e.GetStyleTag("offsetx"),r=(t+=n?getOffsetParam2(n.param,e.GetHeight())*i:0,e.GetStyleTag("offsety"));if(s+=r?getOffsetParam2(r.param,e.GetHeight())*i:0,e.IsIcon()){const a=e.GetStyleTag("iconoffsety");s+=a?getOffsetParam2(a.param,e.GetHeight())*i:.2*e.GetHeight()*i}e.SetPosX(t),e.SetPosY(s)}_DrawTextToCanvas(){this._textContext.imageSmoothingEnabled=this._iconSmoothing,this._textContext.imageSmoothingQuality="high",this._drawCharCount=0;const e=this.GetDrawScale(),t=this._wrappedText.GetLines();for(const s of t)this._DrawTextLine(s,e)}_DrawTextLine(e,t){const s=e.GetPosX(),i=e.GetPosY();if(Number.isFinite(s)&&Number.isFinite(i))for(const n of"ltr"===this._textDirection?e.fragments():e.fragmentsReverse())this._DrawFragment(n,t,e.GetHeight())}_DrawFragment(a,o,l){const h=this._textContext,c=a.GetPosX(),u=a.GetPosY();if(Number.isFinite(c)&&Number.isFinite(u)){let e=l/16,t=a.GetWidth()*o,s=a.GetHeight()*o,i=a.GetHeight()/16,n=(EXTRA_LINE_HEIGHT+this._lineHeight)*o,r=a.IsText()?a.GetCharacterArray():null;if(-1!==this._drawMaxCharCount){if(this._drawCharCount>=this._drawMaxCharCount)return;a.IsText()&&this._drawCharCount+r.length>this._drawMaxCharCount&&(r=r.slice(0,this._drawMaxCharCount-this._drawCharCount),t=this._MeasureText(a).width*o),this._drawCharCount+=a.GetLength()}const _=a.GetStyleTag("background"),d=a.HasStyleTag("u"),p=a.HasStyleTag("s");if((!a.IsText()||!C33.IsCharArrayAllWhitespace(r)||_||d||p)&&!a.HasStyleTag("hide")){const m=a.GetStyleTag("color"),g=a.GetStyleTag("opacity"),f=(this._SetDrawCanvasOpacity(g?parseFloat(g.param)/100:1),_&&(this._SetDrawCanvasColor(_.param),h.fillRect(c,u-s,t,s+n)),a.GetStyleTag("linethickness")),S=f?parseFloat(f.param):1,C=a.HasStyleTag("stroke");if(C&&this._SetDrawCanvasLineWith(.5*i*S*this.GetDrawScale()),a.IsText()){const y=r.join("");if(this._SetDrawFontString(this._GetFontString(!1,a)),!C){this._SetDrawCanvasLineWith(.5*i*S*this.GetDrawScale());const G=a.GetStyleTag("outlineback");G&&(this._SetDrawCanvasColor(G.param),this._FillOrStrokeText(!0,y,c,u,t))}if(this._SetDrawCanvasColor(m?m.param:this._colorStr),this._FillOrStrokeText(C,y,c,u,t),!C){this._SetDrawCanvasLineWith(.5*i*S*this.GetDrawScale());const I=a.GetStyleTag("outline");I&&(this._SetDrawCanvasColor(I.param),this._FillOrStrokeText(!0,y,c,u,t))}}else if(a.IsIcon()&&0<a.GetWidth()){const T=a.GetDrawable(this._iconSet);T&&h.drawImage(T,c,u-s,t,s)}if(this._SetDrawCanvasColor(m?m.param:this._colorStr),d&&fillOrStrokeRect2(h,C,c,u+o*e,t,o*e*S),p){const b=u-s/4,P=o*i,A=b+P/2;h.fillRect(c,A-P*S/2,t,P*S)}}}}_FillOrStrokeText(e,t,s,i,n){"rtl"===this._textDirection&&(s+=n),e?"Gecko"===C33.Platform.BrowserEngine?this._textContext.strokeText(t,s,i,n):this._textContext.strokeText(t,s,i):"Gecko"===C33.Platform.BrowserEngine?this._textContext.fillText(t,s,i,n):this._textContext.fillText(t,s,i)}_UpdateTexture(){this._renderer.IsContextLost()||(this._texture||(this._texture=this._renderer.CreateDynamicTexture(this._textCanvas.width,this._textCanvas.height,{mipMap:!0,mipMapQuality:"high"})),this._renderer.UpdateTexture(this._textCanvas,this._texture),this._rcTex.set(0,0,this._width/this._texture.GetWidth(),this._height/this._texture.GetHeight()),this.ontextureupdate&&this.ontextureupdate())}GetTexRect(){return this._rcTex}ReleaseTexture(){this._texture&&(this._renderer.IsContextLost()||this._renderer.DeleteTexture(this._texture),this._texture=null)}static OnContextLost(){for(const e of allRendererTexts)e.ReleaseTexture()}static GetAll(){return allRendererTexts.values()}}}{const C33=self.C3;class WebGLRealTimeElapsedQuery{constructor(e){this._gl=e.GetContext(),this._version=e.GetWebGLVersionNumber(),this._timerExt=e._GetDisjointTimerQueryExtension(),this._query=null,this._isActive=!1,this._hasResult=!1,this._result=0,1===this._version?this._query=this._timerExt.createQueryEXT():this._query=this._gl.createQuery()}Release(){this._DeleteQueryObject(),this._gl=null,this._timerExt=null,this._hasResult=!1}_DeleteQueryObject(){this._query&&(1===this._version?this._timerExt.deleteQueryEXT(this._query):this._gl.deleteQuery(this._query),this._query=null)}BeginTimeElapsed(){if(this._isActive)throw new Error("query already active");1===this._version?this._timerExt.beginQueryEXT(this._timerExt.TIME_ELAPSED_EXT,this._query):this._gl.beginQuery(this._timerExt.TIME_ELAPSED_EXT,this._query),this._isActive=!0}EndTimeElapsed(){if(!this._isActive)throw new Error("query not active");1===this._version?this._timerExt.endQueryEXT(this._timerExt.TIME_ELAPSED_EXT):this._gl.endQuery(this._timerExt.TIME_ELAPSED_EXT),this._isActive=!1}CheckForResult(){if(this._query&&!this._hasResult&&!this._isActive){let e;e=1===this._version?this._timerExt.getQueryObjectEXT(this._query,this._timerExt.QUERY_RESULT_AVAILABLE_EXT):this._gl.getQueryParameter(this._query,this._gl.QUERY_RESULT_AVAILABLE);const t=this._gl.getParameter(this._timerExt.GPU_DISJOINT_EXT);e&&!t&&(1===this._version?this._result=this._timerExt.getQueryObjectEXT(this._query,this._timerExt.QUERY_RESULT_EXT):this._result=this._gl.getQueryParameter(this._query,this._gl.QUERY_RESULT),this._result/=1e9,this._hasResult=!0),(e||t)&&this._DeleteQueryObject()}}HasResult(){return this._hasResult}GetResult(){if(this._hasResult)return this._result;throw new Error("no result available")}}C33.Gfx.WebGLTimeElapsedQuery=class{constructor(e){this._renderer=e,this._frameNumber=e.GetFrameNumber(),this._isActive=!1,this._parentQuery=null,this._isNested=!1,this._realQuery=null,this._queries=[]}Release(){for(const e of this._queries)e instanceof WebGLRealTimeElapsedQuery&&e.Release();C33.clearArray(this._queries),this._parentQuery=null,this._realQuery=null,this._renderer=null}BeginTimeElapsed(){if(this._isActive)throw new Error("query already active");const e=this._renderer._GetTimeQueryStack();0<e.length?(this._isNested=!0,this._parentQuery=e.at(-1),this._parentQuery._EndReal(),this._parentQuery._queries.push(this)):(this._isNested=!1,this._parentQuery=null),this._isActive=!0,e.push(this),this._StartReal()}EndTimeElapsed(){if(!this._isActive)throw new Error("query not active");const e=this._renderer._GetTimeQueryStack().pop();if(e!==this)throw new Error("can only end most nested query");this._isActive=!1,this._EndReal(),this._parentQuery&&(this._parentQuery._StartReal(),this._parentQuery=null)}_StartReal(){this._realQuery=C33.New(WebGLRealTimeElapsedQuery,this._renderer),this._queries.push(this._realQuery),this._realQuery.BeginTimeElapsed()}_EndReal(){this._realQuery.EndTimeElapsed(),this._realQuery=null}CheckForResult(){for(const e of this._queries)e.CheckForResult()}IsNested(){return this._isNested}HasResult(){return this._queries.every(e=>e.HasResult())}GetResult(){return this._queries.reduce((e,t)=>e+t.GetResult(),0)}GetFrameNumber(){return this._frameNumber}}}{const C33=self.C3;C33.Gfx.WebGLQueryResultBuffer=class{constructor(e,t=1e3){this._renderer=e,this._maxQueries=t,this._buffer=[],this._renderer._AddQueryResultBuffer(this)}Release(){this.Clear(),this._renderer._RemoveQueryResultBuffer(this),this._renderer=null}Clear(){for(const e of this._buffer)e.Release();C33.clearArray(this._buffer)}AddTimeElapsedQuery(){const e=new C33.Gfx.WebGLTimeElapsedQuery(this._renderer);if(this._buffer.push(e),this._buffer.length>this._maxQueries){const t=this._buffer.shift();t.Release()}return e}CheckForResults(e){for(const t of this._buffer){if(t.GetFrameNumber()>=e)return;if(t.IsNested())return;t.CheckForResult()}}GetFrameRangeResultSum(e,t){if(t<=e)return NaN;let s=0;for(const i of this._buffer){if(i.GetFrameNumber()>=t)break;if(!(i.GetFrameNumber()<e)){if(!i.HasResult())return NaN;s+=i.GetResult()}}return s}DeleteAllBeforeFrameNumber(s){for(let e=0,t=this._buffer.length;e<t;++e){const i=this._buffer[e];if(!(i.GetFrameNumber()<s))return void(0<e&&this._buffer.splice(0,e));i.Release()}}}}{let CheckPendingPolls2=function(){pollRafId=-1;for(const e of pendingPolls)e.checkFunc()&&(e.resolve(),pendingPolls.delete(e));0<pendingPolls.size&&(pollRafId=self.requestAnimationFrame(CheckPendingPolls2))},C33=(CheckPendingPolls=CheckPendingPolls2,self.C3),assert=self.assert,glMatrix=self.glMatrix,vec32=glMatrix.vec3,vec42=glMatrix.vec4,mat42=glMatrix.mat4,DEFAULT_WEBGLRENDERER_OPTS={powerPreference:"default",enableGpuProfiling:!0,alpha:!1,depth:!1,canSampleDepth:!1,maxWebGLVersion:2,failIfMajorPerformanceCaveat:!1},VALID_POWER_PREFERENCES=new Set(["default","low-power","high-performance"]),MAX_VERTICES=8e3,MAX_INDICES=MAX_VERTICES/2*3,MAX_POINTS=8e3,LAST_POINT=MAX_POINTS-4,PARTIAL_TEXTURE_UPLOAD_CHUNK_SIZE=262144,defaultTexCoordsQuad=new C33.Quad(0,0,1,0,1,1,0,1),tmpProjection=mat42.create(),tmpModelView=mat42.create(),tmpQuad=new C33.Quad,tmpRect=new C33.Rect,loseContextExtension=null,pendingPolls=(C33.isDebug&&(self.debug_lose_webgl_context=function(){loseContextExtension?loseContextExtension.loseContext():console.warn("WEBGL_lose_context not supported")},self.debug_restore_webgl_context=function(){loseContextExtension?loseContextExtension.restoreContext():console.warn("WEBGL_lose_context not supported")}),new Set),pollRafId=-1;C33.Gfx.WebGLRenderer=class extends C33.Gfx.RendererBase{constructor(e,t){if(super(t),t=Object.assign({},DEFAULT_WEBGLRENDERER_OPTS,t),!VALID_POWER_PREFERENCES.has(t.powerPreference))throw new Error("invalid power preference");let s={alpha:!!t.alpha,depth:!1,antialias:!1,powerPreference:t.powerPreference,failIfMajorPerformanceCaveat:!!t.failIfMajorPerformanceCaveat},i=null,n=0;if(2<=t.maxWebGLVersion&&(i=e.getContext("webgl2",s),n=2),i||(i=e.getContext("webgl",s),n=1),!i)throw new Error("renderer-unavailable (could not get WebGL context)");this._gl=i,this._attribs=i.getContextAttributes(),this._versionString=i.getParameter(i.VERSION),this._version=n,this._viewport=vec42.create(),this._didChangeTransform=!1,this._bbProjectionMatrix=mat42.create(),this._usesDepthBuffer=!!t.depth,this._canSampleDepth=!(!t.depth||!t.canSampleDepth),this._isDepthEnabled=this._usesDepthBuffer,this._isDepthSamplingEnabled=!1,this._depthBuffer=null,this._isAutoSizeDepthBuffer=!0,this._depthBufferWidth=0,this._depthBufferHeight=0,this._vertexBuffer=null,this._texcoordBuffer=null,this._indexBuffer=null,this._pointBuffer=null,this._vertexData=new Float32Array(MAX_VERTICES*this.GetNumVertexComponents()),this._indexData=new Uint16Array(MAX_INDICES),this._texcoordData=new Float32Array(2*MAX_VERTICES),this._pointData=new Float32Array(4*MAX_POINTS),this._vertexPtr=0,this._texPtr=0,this._pointPtr=0,this._lastVertexPtr=0,this._lastProgram=null,this._spDeviceTransformTextureFill=null,this._batch=[],this._batchPtr=0,this._topOfBatch=0,this._currentRenderTarget=null,this._lastPointZ=0,this._batchState=C33.New(C33.Gfx.BatchState,this),this._lastColor=C33.New(C33.Color,1,1,1,1),this._lastTexture0=null,this._lastTexture1=null,this._lastSrcBlend=0,this._lastDestBlend=0,this._lastPointTexCoords=new C33.Rect,this._lastScissorRect=C33.New(C33.Rect,0,0,-1,-1),this._coplanarMode=0,this._maxTextureSize=-1,this._minPointSize=0,this._maxPointSize=0,this._highpPrecision=0,this._unmaskedVendor="(unavailable)",this._unmaskedRenderer="(unavailable)",this._extensions=[],this._isInitialisingAfterContextRestored=!1,this._parallelShaderCompileExt=null,this._anisotropicExt=null,this._depthTextureExt=null,this._fragDepthExt=null,this._stdDerivativesExt=null,this._textureLodExt=null,this._maxAnisotropy=0,this._isGpuProfilingEnabled=!!t.enableGpuProfiling,this._timerExt=null,this._allQueryResultBuffers=new Set,this._timeQueryStack=[],this.FillIndexBufferData(this._indexData)}IsWebGL(){return!0}async InitState(){super.InitState();const e=this._gl,t=this.GetNumVertexComponents(),s=(this._lastColor.setRgba(1,1,1,1),this._lastTexture0=null,this._lastTexture1=null,this._vertexPtr=0,this._pointPtr=0,this._lastVertexPtr=MAX_VERTICES*t-4*t,C33.clearArray(this._batch),this._batchPtr=0,this._topOfBatch=0,this._lastProgram=null,this._currentRenderTarget=null,this._lastPointTexCoords.set(0,0,1,1),this._lastPointZ=0,this._batchState),i=(s.currentShader=null,s.currentFramebuffer=null,s.currentFramebufferNoDepth=null,vec42.set(s.currentColor,1,1,1,1),s.clearColor.setRgba(0,0,0,0),s.pointTexCoords.set(0,0,1,1),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.enable(e.BLEND),e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA),this._lastSrcBlend=e.ONE,this._lastDestBlend=e.ONE_MINUS_SRC_ALPHA,this._InitBlendModes(e),e.disable(e.CULL_FACE),e.disable(e.STENCIL_TEST),e.disable(e.DITHER),this._usesDepthBuffer?(e.enable(e.DEPTH_TEST),e.depthMask(!0),e.depthFunc(e.LEQUAL)):(e.disable(e.DEPTH_TEST),e.depthMask(!1)),this._isDepthEnabled=this._usesDepthBuffer,this._isDepthSamplingEnabled=!1,this._pointBuffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this._pointBuffer),e.bufferData(e.ARRAY_BUFFER,this._pointData.byteLength,e.DYNAMIC_DRAW),this._vertexBuffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this._vertexBuffer),e.bufferData(e.ARRAY_BUFFER,this._vertexData.byteLength,e.DYNAMIC_DRAW),this._texcoordBuffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this._texcoordBuffer),e.bufferData(e.ARRAY_BUFFER,this._texcoordData.byteLength,e.DYNAMIC_DRAW),this._indexBuffer=e.createBuffer(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this._indexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this._indexData,e.STATIC_DRAW),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,null),this._maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),e.getParameter(e.ALIASED_POINT_SIZE_RANGE)),n=(this._minPointSize=i[0],this._maxPointSize=i[1],e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT)),r=e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT),a=(this._highpPrecision=n&&r?Math.min(n.precision,r.precision):0,2048<this._maxPointSize&&(this._maxPointSize=2048),this._extensions=e.getSupportedExtensions(),e.getExtension("WEBGL_debug_renderer_info"));if(a&&(this._unmaskedVendor=e.getParameter(a.UNMASKED_VENDOR_WEBGL),this._unmaskedRenderer=e.getParameter(a.UNMASKED_RENDERER_WEBGL)),this._parallelShaderCompileExt=e.getExtension("KHR_parallel_shader_compile"),C33.isDebug&&(loseContextExtension=e.getExtension("WEBGL_lose_context")),this._isGpuProfilingEnabled&&(1===this.GetWebGLVersionNumber()?this._timerExt=e.getExtension("EXT_disjoint_timer_query"):this._timerExt=e.getExtension("EXT_disjoint_timer_query_webgl2")||e.getExtension("EXT_disjoint_timer_query")),this._anisotropicExt=e.getExtension("EXT_texture_filter_anisotropic"),this._anisotropicExt?this._maxAnisotropy=e.getParameter(this._anisotropicExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT):this._maxAnisotropy=0,this.GetWebGLVersionNumber()<2&&this._usesDepthBuffer&&this._canSampleDepth&&(this._depthTextureExt=e.getExtension("WEBGL_depth_texture"),!this._depthTextureExt))throw new Error("no depth texture support");this.GetWebGLVersionNumber()<2&&(this._fragDepthExt=e.getExtension("EXT_frag_depth"),this._stdDerivativesExt=e.getExtension("OES_standard_derivatives"),this._textureLodExt=e.getExtension("EXT_shader_texture_lod"));let o=C33.Gfx.WebGLShaderProgram,l=o.GetDefaultVertexShaderSource(!1),h=o.GetTextureFillFragmentShaderSource_WebGL1_NoFragDepth(),c=l,u=o.GetPointFragmentShaderSource_WebGL1_NoFragDepth(),_=o.GetPointVertexShaderSource_WebGL1(),d=o.GetTilemapFragmentShaderSource_WebGL1_NoFragDepth(),p=o.GetDefaultVertexShaderSource(!0),m=!1;this._usesDepthBuffer&&(this.GetWebGLVersionNumber()<2?this._fragDepthExt&&(h=o.GetTextureFillFragmentShaderSource_WebGL1_FragDepthEXT(),u=o.GetPointFragmentShaderSource_WebGL1_FragDepthEXT(),d=o.GetTilemapFragmentShaderSource_WebGL1_FragDepthEXT(),m=!0):(c=o.GetDefaultVertexShaderSource_WebGL2(),h=o.GetTextureFillFragmentShaderSource_WebGL2(),u=o.GetPointFragmentShaderSource_WebGL2(),_=o.GetPointVertexShaderSource_WebGL2(),d=o.GetTilemapFragmentShaderSource_WebGL2(),p=o.GetDefaultVertexShaderSource_WebGL2(!0)));const g=o.GetTileRandomizationFragmentShaderSource(this.GetWebGLVersionNumber(),m,this._stdDerivativesExt&&this._textureLodExt),f=2<=this.GetWebGLVersionNumber()?o.GetDefaultVertexShaderSource_WebGL2():l,S=[[h,c,"<default>"],[h,c,"<default-device-transform>"],[u,_,"<point>"],[o.GetColorFillFragmentShaderSource(),l,"<fill>"],[o.GetLinearGradientFillFragmentShaderSource(),l,"<lineargradient>"],[o.GetPenumbraFillFragmentShaderSource(),l,"<penumbra>"],[o.GetHardEllipseFillFragmentShaderSource(),l,"<hardellipse>"],[o.GetHardEllipseOutlineFragmentShaderSource(),l,"<hardellipseoutline>"],[o.GetSmoothEllipseFillFragmentShaderSource(),l,"<smoothellipse>"],[o.GetSmoothEllipseOutlineFragmentShaderSource(),l,"<smoothellipseoutline>"],[o.GetSmoothLineFillFragmentShaderSource(),l,"<smoothline>"],[d,p,"<tilemap>"],[g,f,"<tilerandomization>"]],C=await Promise.all(S.map(e=>this.CreateShaderProgram({src:e[0],vertexSrc:e[1],name:e[2]})));this._spTextureFill=C[0],this._spDeviceTransformTextureFill=C[1],this._spPoints=C[2],this._spColorFill=C[3],this._spLinearGradientFill=C[4],this._spPenumbraFill=C[5],this._spHardEllipseFill=C[6],this._spHardEllipseOutline=C[7],this._spSmoothEllipseFill=C[8],this._spSmoothEllipseOutline=C[9],this._spSmoothLineFill=C[10],this._spTilemapFill=C[11],this._spTileRandomization=C[12],this.SetTextureFillMode()}async CreateShaderProgram(e){const t=await C33.Gfx.WebGLShaderProgram.Create(this,e);return this._AddShaderProgram(t),t}ResetLastProgram(){this._lastProgram=null}SetSize(e,t,s){if(this._width!==e||this._height!==t||s){this.EndBatch();const i=this._gl,n=this._batchState;this._width=e,this._height=t,this._SetViewport(0,0,e,t),this.CalculatePerspectiveMatrix(this._bbProjectionMatrix,e/t),this.SetProjectionMatrix(this._bbProjectionMatrix),this._spDeviceTransformTextureFill&&(i.useProgram(this._spDeviceTransformTextureFill.GetShaderProgram()),this._spDeviceTransformTextureFill._UpdateDeviceTransformUniforms(this._matP),this._lastProgram=this._spDeviceTransformTextureFill,this._batchState.currentShader=this._spDeviceTransformTextureFill),i.bindTexture(i.TEXTURE_2D,null),i.activeTexture(i.TEXTURE1),i.bindTexture(i.TEXTURE_2D,null),i.activeTexture(i.TEXTURE0),this._lastTexture0=null,this._lastTexture1=null,this._usesDepthBuffer&&this._isAutoSizeDepthBuffer&&this._SetDepthBufferSize(this._width,this._height),this._currentRenderTarget&&this._currentRenderTarget._Resize(this._width,this._height),i.bindFramebuffer(i.FRAMEBUFFER,null),this._currentRenderTarget=null,n.currentFramebuffer=null,n.currentFramebufferNoDepth=null}}_SetDepthBufferSize(e,t){const s=this._gl;this._depthBuffer&&this._depthBufferWidth===e&&this._depthBufferHeight===t||(this._canSampleDepth?(this._depthBuffer&&s.deleteTexture(this._depthBuffer),this._depthBuffer=s.createTexture(),s.bindTexture(s.TEXTURE_2D,this._depthBuffer),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.NEAREST),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),2<=this.GetWebGLVersionNumber()?s.texImage2D(s.TEXTURE_2D,0,s.DEPTH24_STENCIL8,e,t,0,s.DEPTH_STENCIL,s.UNSIGNED_INT_24_8,null):this._depthTextureExt&&s.texImage2D(s.TEXTURE_2D,0,s.DEPTH_STENCIL,e,t,0,s.DEPTH_STENCIL,this._depthTextureExt.UNSIGNED_INT_24_8_WEBGL,null),s.bindTexture(s.TEXTURE_2D,null)):(this._depthBuffer&&s.deleteRenderbuffer(this._depthBuffer),this._depthBuffer=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,this._depthBuffer),s.renderbufferStorage(s.RENDERBUFFER,2<=this._version?s.DEPTH24_STENCIL8:s.DEPTH_STENCIL,e,t),s.bindRenderbuffer(s.RENDERBUFFER,null)),this._depthBufferWidth=e,this._depthBufferHeight=t)}SetFixedSizeDepthBuffer(e,t){this._usesDepthBuffer&&(this._isAutoSizeDepthBuffer=!1,this._SetDepthBufferSize(e,t))}SetAutoSizeDepthBuffer(){this._usesDepthBuffer&&(this._isAutoSizeDepthBuffer=!0,this._SetDepthBufferSize(this._width,this._height))}_SetViewport(e,t,s,i){const n=this._viewport;if(n[0]!==e||n[1]!==t||n[2]!==s||n[3]!==i){const r=this.PushBatch();r.InitSetViewport(e,t,s,i),vec42.set(n,e,t,s,i),this._topOfBatch=0}}SetFovY(e){super.SetFovY(e),this.CalculatePerspectiveMatrix(this._bbProjectionMatrix,this._width/this._height)}SetNearZ(e){super.SetNearZ(e),this.CalculatePerspectiveMatrix(this._bbProjectionMatrix,this._width/this._height)}SetFarZ(e){super.SetFarZ(e),this.CalculatePerspectiveMatrix(this._bbProjectionMatrix,this._width/this._height)}SetProjectionMatrix(e){if(!mat42.exactEquals(this._matP,e)){const t=this.PushBatch();t.InitSetProjection(e),mat42.copy(this._matP,e),this._topOfBatch=0,this._didChangeTransform=!0}}SetDefaultRenderTargetProjectionState(){let e,t,s,i=this._currentRenderTarget;s=(null===i?(e=this._bbProjectionMatrix,t=this.GetWidth(),this):(e=i.GetProjectionMatrix(),t=i.GetWidth(),i)).GetHeight(),this.SetProjectionMatrix(e),this._SetViewport(0,0,t,s)}SetModelViewMatrix(e){if(!mat42.exactEquals(this._matMV,e)){const t=this.PushBatch();t.InitSetModelView(e),mat42.copy(this._matMV,e),this._topOfBatch=0,this._didChangeTransform=!0}}ResetDidChangeTransformFlag(){this._didChangeTransform=!1}DidChangeTransform(){return this._didChangeTransform}GetBatchState(){return this._batchState}PushBatch(){const e=this._batch;return this._batchPtr===e.length&&e.push(new C33.Gfx.WebGLBatchJob(this._batchState)),e[this._batchPtr++]}EndBatch(){0===this._batchPtr||this.IsContextLost()||(this._WriteBuffers(),this._ExecuteBatch(),this._batchPtr=0,this._vertexPtr=0,this._texPtr=0,this._pointPtr=0,this._topOfBatch=0)}_WriteBuffers(){const e=this._gl;0<this._pointPtr&&(e.bindBuffer(e.ARRAY_BUFFER,this._pointBuffer),e.bufferSubData(e.ARRAY_BUFFER,0,this._pointData.subarray(0,this._pointPtr))),0<this._vertexPtr&&(e.bindBuffer(e.ARRAY_BUFFER,this._vertexBuffer),e.bufferSubData(e.ARRAY_BUFFER,0,this._vertexData.subarray(0,this._vertexPtr)),e.bindBuffer(e.ARRAY_BUFFER,this._texcoordBuffer),e.bufferSubData(e.ARRAY_BUFFER,0,this._texcoordData.subarray(0,this._texPtr)))}_ExecuteBatch(){const s=this._batch;for(let e=0,t=this._batchPtr;e<t;++e)s[e].Run()}GetOpacity(){return this._lastColor.getA()}SetColorRgba(e,t,s,i){const n=this._lastColor;if(!n.equalsRgba(e,t,s,i)){n.setRgba(e,t,s,i);const r=this.PushBatch();r.InitSetColor(n),this._topOfBatch=0,this._currentStateGroup=null}}SetOpacity(e){const t=this._lastColor;if(t.getA()!==e){t.setA(e);const s=this.PushBatch();s.InitSetColor(t),this._topOfBatch=0,this._currentStateGroup=null}}SetColor(e){const t=this._lastColor;if(!t.equals(e)){t.set(e);const s=this.PushBatch();s.InitSetColor(t),this._topOfBatch=0,this._currentStateGroup=null}}ResetColor(){this.SetColorRgba(1,1,1,1)}GetColor(){return this._lastColor}SetTexture(e){if(e!==this._lastTexture0){const t=this.PushBatch();t.InitSetTexture(e),this._lastTexture0=e,this._topOfBatch=0}}_ResetLastTexture(){this._lastTexture0=null}SetBlendMode(e){const t=this._GetBlendByIndex(e);this._SetBlend(t[0],t[1])}SetNamedBlendMode(e){const t=this.GetNamedBlend(e);this._SetBlend(t.srcBlend,t.destBlend)}_SetBlend(e,t){if(e!==this._lastSrcBlend||t!==this._lastDestBlend){const s=this.PushBatch();s.InitSetBlend(e,t),this._lastSrcBlend=e,this._lastDestBlend=t,this._topOfBatch=0,this._currentStateGroup=null}}IsPremultipliedAlphaBlend(){return this._lastSrcBlend===this._gl.ONE&&this._lastDestBlend===this._gl.ONE_MINUS_SRC_ALPHA}SetAlphaBlend(){this._SetBlend(this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA)}SetNoPremultiplyAlphaBlend(){this._SetBlend(this._gl.SRC_ALPHA,this._gl.ONE_MINUS_SRC_ALPHA)}SetCopyBlend(){this._SetBlend(this._gl.ONE,this._gl.ZERO)}Rect(e){this.Rect2(e.getLeft(),e.getTop(),e.getRight(),e.getBottom())}Rect2(e,t,s,i){this.Quad2(e,t,s,t,s,i,e,i)}_ExtendQuadBatch(){let e=this._vertexPtr;if(e>=this._lastVertexPtr&&(this.EndBatch(),e=0),1===this._topOfBatch)this._batch[this._batchPtr-1]._indexCount+=6;else{const t=this.PushBatch();t.InitQuad(e,6),this._topOfBatch=1}}_WriteQuadToVertexBuffer(e){e.writeToTypedArray3D(this._vertexData,this._vertexPtr,this._baseZ+this._currentZ),this._vertexPtr+=12}Quad(e){this._ExtendQuadBatch(),this._WriteQuadToVertexBuffer(e),defaultTexCoordsQuad.writeToTypedArray(this._texcoordData,this._texPtr),this._texPtr+=8}Quad2(e,t,s,i,n,r,a,o){this._ExtendQuadBatch();let l=this._vertexData,h=this._vertexPtr,c=this._baseZ+this._currentZ;l[h++]=e,l[h++]=t,l[h++]=c,l[h++]=s,l[h++]=i,l[h++]=c,l[h++]=n,l[h++]=r,l[h++]=c,l[h++]=a,l[h++]=o,l[h++]=c,this._vertexPtr=h,defaultTexCoordsQuad.writeToTypedArray(this._texcoordData,this._texPtr),this._texPtr+=8}Quad3(e,t){this._ExtendQuadBatch(),this._WriteQuadToVertexBuffer(e),t.writeAsQuadToTypedArray(this._texcoordData,this._texPtr),this._texPtr+=8}Quad4(e,t){this._ExtendQuadBatch(),this._WriteQuadToVertexBuffer(e),t.writeToTypedArray(this._texcoordData,this._texPtr),this._texPtr+=8}Quad3D(e,t,s,i,n,r,a,o,l,h,c,u,_){this._ExtendQuadBatch();let d=this._vertexData,p=this._vertexPtr,m=this._baseZ+this._currentZ;d[p++]=e,d[p++]=t,d[p++]=m+s,d[p++]=i,d[p++]=n,d[p++]=m+r,d[p++]=a,d[p++]=o,d[p++]=m+l,d[p++]=h,d[p++]=c,d[p++]=m+u,this._vertexPtr=p,_.writeAsQuadToTypedArray(this._texcoordData,this._texPtr),this._texPtr+=8}Quad3D2(e,t,s,i,n,r,a,o,l,h,c,u,_){this._ExtendQuadBatch();let d=this._vertexData,p=this._vertexPtr,m=this._baseZ+this._currentZ;d[p++]=e,d[p++]=t,d[p++]=m+s,d[p++]=i,d[p++]=n,d[p++]=m+r,d[p++]=a,d[p++]=o,d[p++]=m+l,d[p++]=h,d[p++]=c,d[p++]=m+u,this._vertexPtr=p,_.writeToTypedArray(this._texcoordData,this._texPtr),this._texPtr+=8}DrawMesh(i,n,r){const a=this._vertexData,o=this._texcoordData;if(r.length%3!=0)throw new Error("invalid index buffer length");for(let s=0,e=r.length;s<e;){const l=r[s++],h=r[s++],c=r[s++],u=3*l,_=3*h,d=3*c,p=2*l,m=2*h,g=2*c;this._ExtendQuadBatch();let e=this._vertexPtr,t=this._texPtr;a[e++]=i[0+u],a[e++]=i[1+u],a[e++]=i[2+u],a[e++]=i[0+_],a[e++]=i[1+_],a[e++]=i[2+_],a[e++]=i[0+d],a[e++]=i[1+d],a[e++]=i[2+d],a[e++]=i[0+d],a[e++]=i[1+d],a[e++]=i[2+d],o[t++]=n[0+p],o[t++]=n[1+p],o[t++]=n[0+m],o[t++]=n[1+m],o[t++]=n[0+g],o[t++]=n[1+g],o[t++]=n[0+g],o[t++]=n[1+g],this._vertexPtr=e,this._texPtr=t}}FullscreenQuad(e,t){this.SetCurrentZ(0),mat42.copy(tmpProjection,this._matP),mat42.copy(tmpModelView,this._matMV),this.SetDefaultRenderTargetProjectionState();const[s,i]=this.GetRenderTargetSize(this._currentRenderTarget),n=this.CalculateLookAtModelView2(0,0,this.GetDefaultCameraZ(i),0,0,0,i);if(this.SetModelViewMatrix(n),"crop"===e&&this._currentRenderTarget&&t){const r=this._width/2,a=this._height/2,o=t.GetWidth(),l=t.GetHeight(),h=this._currentRenderTarget.GetWidth(),c=this._currentRenderTarget.GetHeight(),u=Math.min(h,o),_=Math.min(c,l),d=Math.max(l-c,0),p=Math.max(c-l,0);tmpRect.set(-r,a-p,-r+u,a-_-p),tmpQuad.setFromRect(tmpRect),tmpRect.set(0,d,u,_+d),tmpRect.divide(o,l),this.Quad3(tmpQuad,tmpRect)}else{const m=s/2,g=i/2;this.Rect2(-m,g,m,-g)}this.SetProjectionMatrix(tmpProjection),this.SetModelViewMatrix(tmpModelView)}StartRenderingPoints(e){if(!this._lastPointTexCoords.equals(e)){this._lastPointTexCoords.copy(e);const t=this.PushBatch();t.InitSetPointTexCoords(e),this._topOfBatch=0}}FinishRenderingPoints(){}Point(e,t,s,i){this._pointPtr>=LAST_POINT&&this.EndBatch();let n=this._pointPtr,r=this._baseZ+this._currentZ;if(2===this._topOfBatch&&this._lastPointZ===r)this._batch[this._batchPtr-1]._indexCount++;else{const o=this.PushBatch();o.InitPoints(n,r),this._topOfBatch=2,this._lastPointZ=r}const a=this._pointData;a[n++]=e,a[n++]=t,a[n++]=s,a[n++]=i,this._pointPtr=n}SetProgram(e){if(this._lastProgram!==e){const t=this.PushBatch();t.InitSetProgram(e),this._lastProgram=e,this._topOfBatch=0,this._currentStateGroup=null}}GetProgram(){return this._lastProgram}SetDeviceTransformTextureFillMode(){this.SetProgram(this._spDeviceTransformTextureFill)}SetGradientColor(e){const t=this.PushBatch();t.InitSetGradientColor(e),this._topOfBatch=0}SetEllipseParams(e,t,s=1){const i=this.PushBatch();i.InitSetEllipseParams(e,t,s),this._topOfBatch=0}SetTilemapInfo(e,t,s,i,n,r,a){if(this._lastProgram!==this._spTilemapFill)throw new Error("must set tilemap fill mode first");const o=this.PushBatch();o.InitSetTilemapInfo(e,t,s,i,n,r,a),this._topOfBatch=0}SetTileRandomizationInfo(e,t,s,i,n,r,a){if(this._lastProgram!==this._spTileRandomization)throw new Error("must set tile randomization mode first");const o=this.PushBatch();o.InitSetTileRandomizationInfo(e,t,s,i,n,r,a),this._topOfBatch=0}SetProgramParameters(e,t,s,i,n,r,a,o,l,h,c){const u=this._lastProgram;if(c%=10800,u._hasAnyOptionalUniforms&&!u.AreOptionalUniformsAlreadySetInBatch(t,s,i,n,r,a,o,l,h,c)){const _=this.PushBatch(),d=(_.InitSetProgramParameters(),u.SetOptionalUniformsInBatch(t,s,i,n,r,a,o,l,h,c),_._mat4param),p=(d[0]=r,d[1]=a,t.writeToTypedArray(d,2),d[6]=l,d[7]=h,s.writeToTypedArray(d,12),_._colorParam),m=(n.writeToTypedArray(p,0),p[1]);p[1]=p[3],p[3]=m,i.writeToTypedArray(_._srcOriginRect,0),_._startIndex=c,_._indexCount=o,u._uSamplerBack.IsUsed()?_._texParam=e?e.GetTexture():null:_._texParam=null,this._topOfBatch=0}}SetProgramCustomParameters(e){const t=this._lastProgram;if(0!==e.length&&!t.AreCustomParametersAlreadySetInBatch(e)){const s=this.PushBatch();s.InitSetProgramCustomParameters(),t.SetCustomParametersInBatch(e),C33.shallowAssignArray(s._shaderParams,e),this._topOfBatch=0}}ClearRgba(e,t,s,i){const n=this.PushBatch();n.InitClearSurface2(e,t,s,i),this._topOfBatch=0}Clear(e){const t=this.PushBatch();t.InitClearSurface(e),this._topOfBatch=0}Start(){}Finish(){super.Finish(),this._gl.flush()}ClearDepth(){if(this._usesDepthBuffer&&this._currentRenderTarget&&this._currentRenderTarget.HasDepthBuffer()){const e=this.PushBatch();e.InitClearDepth(this._isDepthEnabled),this._topOfBatch=0}}SetDepthEnabled(e){if(this._isDepthEnabled!==(e=!!e)&&this._usesDepthBuffer){this._isDepthEnabled=e;const t=this.PushBatch();t.InitSetDepthEnabled(e),this._topOfBatch=0}}IsDepthEnabled(){return this._isDepthEnabled}_GetDepthBuffer(){return this._depthBuffer}_CanSampleDepth(){return this._canSampleDepth}SetDepthSamplingEnabled(e){if(e=!!e,this._canSampleDepth&&this._isDepthSamplingEnabled!==e){if(e&&this.IsDepthEnabled())throw new Error("depth still enabled");this._isDepthSamplingEnabled=e;const t=this.PushBatch();t.InitSetDepthSamplingEnabled(e),this._topOfBatch=0}}SetScissorRect(e,t,s,i,n=0){if(e=Math.floor(e),t=Math.floor(t),s=Math.floor(s),i=Math.floor(i),!this._lastScissorRect.equalsWH(e,t,s,i)){this._lastScissorRect.setWH(e,t,s,i);const r=n||this.GetRenderTargetSize(this.GetRenderTarget())[1],a=(t=r-t-i,this.PushBatch());a.InitSetScissor(!0,e,t,s,i),this._topOfBatch=0}}RemoveScissorRect(){if(-1!==this._lastScissorRect.getRight()){this._lastScissorRect.set(0,0,-1,-1);const e=this.PushBatch();e.InitSetScissor(!1,0,0,0,0),this._topOfBatch=0}}CheckForQueryResults(){for(const e of this._allQueryResultBuffers)e.CheckForResults(this._frameNumber)}IsContextLost(){return!this._gl||this._gl.isContextLost()||this._isInitialisingAfterContextRestored}OnContextLost(){super.OnDeviceOrContextLost(),C33.Gfx.WebGLRendererTexture.OnContextLost(),C33.Gfx.WebGLRenderTarget.OnContextLost(),C33.Gfx.RendererText.OnContextLost();for(const e of this._allQueryResultBuffers)e.Clear();this._extensions=[],this._timerExt=null,this._parallelShaderCompileExt=null,this._anisotropicExt=null,this._depthTextureExt=null,this._fragDepthExt=null,this._stdDerivativesExt=null,this._textureLodExt=null,this._maxAnisotropy=0,this._unmaskedVendor="(unavailable)",this._unmaskedRenderer="(unavailable)",this._lastProgram=null,this._spDeviceTransformTextureFill=null,this._depthBuffer=null;for(const t of this._stateGroups.values())t.OnContextLost()}async OnContextRestored(){this._isInitialisingAfterContextRestored=!0,await this.InitState(),this._isInitialisingAfterContextRestored=!1;for(const e of this._stateGroups.values())e.OnContextRestored(this);this.SetSize(this._width,this._height,!0)}CreateStaticTexture(e,t){if(this.IsContextLost())throw new Error("context lost");this.EndBatch();const s=C33.New(C33.Gfx.WebGLRendererTexture,this);return s._CreateStatic(e,t),s}async CreateStaticTextureAsync(i,n){if(this.IsContextLost())throw new Error("context lost");if(n=Object.assign({},n),C33.Supports.ImageBitmapOptions){let e=await createImageBitmap(i,{premultiplyAlpha:"premultiply"}),t=n.wrapX&&"clamp-to-edge"!==n.wrapX||n.wrapY&&"clamp-to-edge"!==n.wrapY,s=C33.isPOT(e.width)&&C33.isPOT(e.height);return this.SupportsNPOTTextures()||s||!t?n.premultiplyAlpha=!1:C33.Supports.ImageBitmapOptionsResize?(e=await createImageBitmap(i,{premultiplyAlpha:"premultiply",resizeWidth:C33.nextHighestPowerOfTwo(e.width),resizeHeight:C33.nextHighestPowerOfTwo(e.height)}),n.premultiplyAlpha=!1):e=await createImageBitmap(i,{premultiplyAlpha:"none"}),C33.Asyncify(()=>this.CreateStaticTexture(e,n))}if(i instanceof Blob){if("undefined"==typeof Image)throw new Error("texture upload variant not supported in worker");const e=await C33.BlobToImage(i);i=e}return C33.Asyncify(()=>this.CreateStaticTexture(i,n))}CreateDynamicTexture(e,t,s){this.EndBatch();const i=C33.New(C33.Gfx.WebGLRendererTexture,this);return i._CreateDynamic(e,t,s),i}UpdateTexture(e,t,s){this.EndBatch(),t._Update(e,s)}DeleteTexture(e){e&&(e.SubtractReference(),0<e.GetReferenceCount()||(this.EndBatch(),e===this._lastTexture0&&(this._gl.bindTexture(this._gl.TEXTURE_2D,null),this._lastTexture0=null),e===this._lastTexture1&&(this._gl.activeTexture(this._gl.TEXTURE1),this._gl.bindTexture(this._gl.TEXTURE_2D,null),this._gl.activeTexture(this._gl.TEXTURE0),this._lastTexture1=null),e._Delete()))}CreateRenderTarget(e){let t=this._width,s=this._height,i=!0;if(e&&("number"==typeof e.width&&(t=Math.floor(e.width),i=!1),"number"==typeof e.height)&&(s=Math.floor(e.height),i=!1),t<=0||s<=0)throw new Error("invalid size");this.EndBatch();const n=C33.New(C33.Gfx.WebGLRenderTarget,this);return n._Create(t,s,Object.assign({isDefaultSize:i},e)),this._currentRenderTarget=null,this._batchState.currentFramebuffer=null,this._batchState.currentFramebufferNoDepth=null,n}SetRenderTarget(e,t=!0){if(e!==this._currentRenderTarget){e&&e.IsDefaultSize()&&e._Resize(this._width,this._height);const s=this.PushBatch();s.InitSetRenderTarget(e),this._currentRenderTarget=e,this._topOfBatch=0,t&&this.SetDefaultRenderTargetProjectionState()}}GetRenderTarget(){return this._currentRenderTarget}GetRenderTargetSize(e){return e?[e.GetWidth(),e.GetHeight()]:[this._width,this._height]}CopyRenderTarget(e,t="stretch"){if(this._version<2||this._currentRenderTarget&&0<this._currentRenderTarget.GetMultisampling())this.SetCopyBlend(),this.ResetColor(),this.DrawRenderTarget(e,t);else{const s=this.PushBatch();s.InitBlitFramebuffer(e,this._currentRenderTarget,t),this._topOfBatch=0}}DrawRenderTarget(e,t="stretch"){const s=e.GetTexture();if(!s)throw new Error("not a texture-backed render target");this.SetTexture(s),this.FullscreenQuad(t,s)}InvalidateRenderTarget(e){if(!(this._version<2)){const t=this.PushBatch();t.InitInvalidateFramebuffer(e._GetFramebuffer()),this._topOfBatch=0}}DeleteRenderTarget(e){this.SetRenderTarget(null),this.EndBatch();const t=e.GetTexture();t===this._lastTexture0&&(this._gl.bindTexture(this._gl.TEXTURE_2D,null),this._lastTexture0=null),t===this._lastTexture1&&(this._gl.activeTexture(this._gl.TEXTURE1),this._gl.bindTexture(this._gl.TEXTURE_2D,null),this._gl.activeTexture(this._gl.TEXTURE0),this._lastTexture1=null),e._Delete()}async ReadBackRenderTargetToImageData(e,t,s){this.EndBatch();let i=this._currentRenderTarget,n,r,a,o=(a=e?(n=e.GetWidth(),r=e.GetHeight(),e._GetFramebuffer()):(n=this.GetWidth(),r=this.GetHeight(),null),0),l=0,h=n,c=r;if(s){o=C33.clamp(Math.floor(s.getLeft()),0,n-1),l=C33.clamp(Math.floor(s.getTop()),0,r-1);let e=s.width(),t=(e=0===e?n-o:C33.clamp(Math.floor(e),0,n-o),s.height());t=0===t?r-l:C33.clamp(Math.floor(t),0,r-l),h=e,c=t,l=r-(l+c)}let u=this._gl,_=(u.bindFramebuffer(u.FRAMEBUFFER,a),()=>{u.bindFramebuffer(u.FRAMEBUFFER,null),this._currentRenderTarget=null,this._batchState.currentFramebuffer=null,this._batchState.currentFramebufferNoDepth=null,this.SetRenderTarget(i)}),d;if(!t&&2<=this.GetWebGLVersionNumber()){u.bindFramebuffer(u.READ_FRAMEBUFFER,a);const p=u.createBuffer(),m=h*c*4,g=u.PIXEL_PACK_BUFFER,f=(u.bindBuffer(g,p),u.bufferData(g,m,u.STREAM_READ),u.readPixels(o,l,h,c,u.RGBA,u.UNSIGNED_BYTE,0),u.bindFramebuffer(u.READ_FRAMEBUFFER,null),u.bindBuffer(g,null),_(),u.fenceSync(u.SYNC_GPU_COMMANDS_COMPLETE,0));await this._WaitForObjectReady(()=>u.getSyncParameter(f,u.SYNC_STATUS)===u.SIGNALED),u.deleteSync(f),d=new ImageData(h,c),u.bindBuffer(g,p),u.getBufferSubData(g,0,new Uint8Array(d.data.buffer),0,m),u.bindBuffer(g,null),u.deleteBuffer(p)}else d=new ImageData(h,c),u.readPixels(o,l,h,c,u.RGBA,u.UNSIGNED_BYTE,new Uint8Array(d.data.buffer)),_();return d}CoplanarStartStencilPass(){this.SetDepthEnabled(!0);const e=this.PushBatch();e.InitCoplanarStartStencilPass(),this._topOfBatch=0,this._coplanarMode=1}CoplanarStartColorPass(){this.SetDepthEnabled(!1);const e=this.PushBatch();e.InitCoplanarStartColorPass(),this._topOfBatch=0,this._coplanarMode=2}IsCoplanarColorPass(){return 2===this._coplanarMode}CoplanarRestoreStandardRendering(){this.SetDepthEnabled(!0);const e=this.PushBatch();e.InitCoplanarRestore(),this._topOfBatch=0,this._coplanarMode=0}StartQuery(e){if(this.SupportsGPUProfiling()){const t=this.PushBatch();t.InitStartQuery(e),this._topOfBatch=0}}EndQuery(e){if(this.SupportsGPUProfiling()){const t=this.PushBatch();t.InitEndQuery(e),this._topOfBatch=0}}_WaitForObjectReady(t){const e=new Promise(e=>pendingPolls.add({resolve:e,checkFunc:t}));return-1===pollRafId&&(pollRafId=self.requestAnimationFrame(CheckPendingPolls2)),e}GetEstimatedBackBufferMemoryUsage(){return this._width*this._height*(this._attribs.alpha?4:3)}GetEstimatedRenderBufferMemoryUsage(){let e=0;for(const t of C33.Gfx.WebGLRenderTarget.allRenderTargets())t.GetTexture()||(e+=t.GetEstimatedMemoryUsage());return e}GetEstimatedTextureMemoryUsage(){let e=0;for(const t of C33.Gfx.WebGLRendererTexture.allTextures())e+=t.GetEstimatedMemoryUsage();return e}GetWebGLVersionString(){return this._versionString}GetWebGLVersionNumber(){return this._version}GetDisplayName(){return"webgl"+this.GetWebGLVersionNumber()}SupportsNPOTTextures(){return 2<=this.GetWebGLVersionNumber()}GetMaxTextureSize(){return this._maxTextureSize}GetMinPointSize(){return this._minPointSize}GetMaxPointSize(){return this._maxPointSize}SupportsHighP(){return 0!==this._highpPrecision}GetHighPPrecision(){return this._highpPrecision}GetUnmaskedVendor(){return this._unmaskedVendor}GetUnmaskedRenderer(){return this._unmaskedRenderer}GetWebGLExtensionsAnalyticsString(){if(2<=this.GetWebGLVersionNumber())return"webgl2";{const e=[];return this._fragDepthExt&&e.push("EXT_frag_depth"),this._stdDerivativesExt&&e.push("OES_standard_derivatives"),this._textureLodExt&&e.push("EXT_shader_texture_lod"),0<e.length?"webgl1:"+e.join(","):"webgl1:none"}}GetExtensions(){return this._extensions}SupportsGPUProfiling(){return!!this._timerExt}_GetDisjointTimerQueryExtension(){return this._timerExt}_GetParallelShaderCompileExtension(){return this._parallelShaderCompileExt}_GetAnisotropicExtension(){return this._anisotropicExt}_GetMaxAnisotropy(){return this._maxAnisotropy}_AddQueryResultBuffer(e){this._allQueryResultBuffers.add(e)}_RemoveQueryResultBuffer(e){this._allQueryResultBuffers.delete(e)}_GetTimeQueryStack(){return this._timeQueryStack}GetContext(){return this._gl}_InitBlendModes(e){this._InitBlendModeData([["normal",e.ONE,e.ONE_MINUS_SRC_ALPHA],["additive",e.ONE,e.ONE],["xor",e.ONE,e.ONE_MINUS_SRC_ALPHA],["copy",e.ONE,e.ZERO],["destination-over",e.ONE_MINUS_DST_ALPHA,e.ONE],["source-in",e.DST_ALPHA,e.ZERO],["destination-in",e.ZERO,e.SRC_ALPHA],["source-out",e.ONE_MINUS_DST_ALPHA,e.ZERO],["destination-out",e.ZERO,e.ONE_MINUS_SRC_ALPHA],["source-atop",e.DST_ALPHA,e.ONE_MINUS_SRC_ALPHA],["destination-atop",e.ONE_MINUS_DST_ALPHA,e.SRC_ALPHA]])}CreateWebGLText(){return this.CreateRendererText()}}}{const C33=self.C3,DEFAULT_CTOR_OPTS={getDrawSize:null,getRenderTarget:null,releaseRenderTarget:null,getTime:null,redraw:null};C33.Gfx.EffectChainManager=class{constructor(e){e=Object.assign({},DEFAULT_CTOR_OPTS,e),this._cbGetDrawSize=e.getDrawSize,this._cbGetRenderTarget=e.getRenderTarget,this._cbReleaseRenderTarget=e.releaseRenderTarget,this._cbGetTime=e.getTime,this._cbRedraw=e.redraw,this._webgpuBackTexture=null,this._allEffectChains=new Set}_AddEffectChain(e){this._allEffectChains.add(e)}_RemoveEffectChain(e){this._allEffectChains.delete(e)}OnContextLost(){this._webgpuBackTexture=null;for(const e of this._allEffectChains)e.OnContextLost()}GetDrawSize(e){return this._cbGetDrawSize?this._cbGetDrawSize(e):[e.GetWidth(),e.GetHeight()]}GetRenderTarget(e){return this._cbGetRenderTarget(e)}ReleaseRenderTarget(e,t){this._cbReleaseRenderTarget(e,t)}GetTime(){return this._cbGetTime()}Redraw(e){this._cbRedraw(e)}_GetWebGPUBackTexture(e,t,s){return t=Math.floor(t),s=Math.floor(s),!this._webgpuBackTexture||this._webgpuBackTexture.GetWidth()===t&&this._webgpuBackTexture.GetHeight()===s||(e.DeleteTexture(this._webgpuBackTexture),this._webgpuBackTexture=null),null===this._webgpuBackTexture&&(this._webgpuBackTexture=e.CreateStaticTexture(null,{width:t,height:s,sampling:"nearest",mipMap:!1})),this._webgpuBackTexture}}}{const C33=self.C3,assert=self.assert,glMatrix=self.glMatrix,mat42=glMatrix.mat4,tempRect=C33.New(C33.Rect),tempRect2=C33.New(C33.Rect),tempRect3=C33.New(C33.Rect),tempRect4=C33.New(C33.Rect),tempMat4a=mat42.create(),tempMat4b=mat42.create(),DEFAULT_CTOR_OPTS={drawContent:null,getSourceTextureInfo:null,getShaderParameters:null,invalidateRenderTargets:!1},DEFAULT_BUILDSTEPS_OPTS={indexMap:null,forcePreDraw:!1,forcePostDraw:!1,is3D:!1,isSourceTextureRotated:!1,isRotatedOrNegativeSizeInstance:!1,useFullSurface:!1};C33.Gfx.EffectChain=class{constructor(e,t){t=Object.assign({},DEFAULT_CTOR_OPTS,t),this._manager=e,this._cbDrawContent=t.drawContent,this._cbGetSourceTextureInfo=t.getSourceTextureInfo,this._cbGetShaderParameters=t.getShaderParameters,this._cbDrawContentHook=null,this._shaderProgramList=[],this._shaderProgramIndices=[],this._steps=[],this._needsRebuild=!1,this._blendMode=0,this._isAnyShaderAnimated=!1,this._isAnyShaderDepthSampling=!1,this._isAnyShaderBackgroundBlending=!1,this._isAnyShaderCrossSampling=!1,this._isAnyIsSrcTexRotated=!1,this._useCopyTextureBackgroundSampling=!1,this._didChangeTransform=!1,this._depthEnabledAtStart=!1,this._coplanarColorPassAtStart=!1,this._canUseFastPath=!1,this._useFullSurface=!1,this._isSourceTextureRotated=!1,this._numTempSurfacesRequired=0,this._renderTargets=[null,null,null],this._invalidateRenderTargets=!!t.invalidateRenderTargets,this._boxExtendHorizontal=0,this._boxExtendVertical=0,this._drawWidth=0,this._drawHeight=0,this._contentObject=null,this._contextObject=null,this._layoutRect=C33.New(C33.Rect),this._drawSurfaceRect=C33.New(C33.Rect),this._rcTexOriginal=C33.New(C33.Rect),this._rcTexBounce=C33.New(C33.Rect),this._rcTexDest=C33.New(C33.Rect),this._devicePixelRatio=1,this._layerScale=1,this._layerAngle=0,this._time=0,this._destRenderTarget=null,this._backTex=null,this._compositOffX=0,this._compositOffY=0,this._updateOwnProjection=!1,this._projectionMatrix=mat42.create(),this._modelViewMatrix=mat42.create(),this._manager._AddEffectChain(this)}Release(){this._manager._RemoveEffectChain(this),C33.clearArray(this._steps),C33.clearArray(this._shaderProgramList),C33.clearArray(this._shaderProgramIndices),this._contentObject=null,this._contextObject=null,this._cbDrawContent=null,this._cbGetSourceTextureInfo=null,this._cbGetShaderParameters=null}OnContextLost(){this._needsRebuild=!0,C33.clearArray(this._steps),C33.clearArray(this._shaderProgramList),C33.clearArray(this._shaderProgramIndices)}NeedsRebuild(){return this._needsRebuild}BuildSteps(n,e){if(e=Object.assign({},DEFAULT_BUILDSTEPS_OPTS,e),C33.clearArray(this._steps),this._boxExtendHorizontal=0,this._boxExtendVertical=0,this._isAnyShaderAnimated=!1,this._isAnyShaderDepthSampling=!1,this._isAnyShaderBackgroundBlending=!1,this._isAnyShaderCrossSampling=!1,this._isAnyIsSrcTexRotated=!1,this._useCopyTextureBackgroundSampling=!1,this._numTempSurfacesRequired=0,this._isSourceTextureRotated=!!e.isSourceTextureRotated,this._useFullSurface=!!e.useFullSurface,this._needsRebuild=!1,C33.shallowAssignArray(this._shaderProgramList,n),0!==n.length){if(e.indexMap){if(e.indexMap.length!==n.length)throw new Error("incorrect indexMap length");C33.shallowAssignArray(this._shaderProgramIndices,e.indexMap)}else{C33.clearArray(this._shaderProgramIndices);for(let e=0,t=n.length;e<t;++e)this._shaderProgramIndices.push(e)}for(const t of n)this._boxExtendHorizontal+=t.GetBoxExtendHorizontal(),this._boxExtendVertical+=t.GetBoxExtendVertical(),t.IsAnimated()&&(this._isAnyShaderAnimated=!0),t.UsesDepth()&&(this._isAnyShaderDepthSampling=!0),t.BlendsBackground()&&(this._isAnyShaderBackgroundBlending=!0),t.UsesCrossSampling()&&(this._isAnyShaderCrossSampling=!0),t.UsesIsSrcTexRotated()&&(this._isAnyIsSrcTexRotated=!0);this._useCopyTextureBackgroundSampling=this._ShouldUseCopyTextureBackgroundSampling(n[0].GetRenderer());const r=this._ShouldPreDraw(n[0],e),a=this._ShouldPostDraw(n.at(-1),e);if(1!==n.length||r||a){this._canUseFastPath=!1;let i=0;r&&(this._numTempSurfacesRequired=1,this._steps.push(C33.New(C33.Gfx.EffectChain.Step.PreDraw,this,-1,1)),i=1);for(let t=0,s=n.length;t<s;++t)if(0!==t||r){let e=1===i?2:1;t!==s-1||a||(e=0),this._numTempSurfacesRequired=Math.max(this._numTempSurfacesRequired,e),this._steps.push(C33.New(C33.Gfx.EffectChain.Step.Bounce,this,i,e,t)),i=e}else this._numTempSurfacesRequired=1,this._steps.push(C33.New(C33.Gfx.EffectChain.Step.FirstBounce,this,-1,1,t)),i=1;a&&this._steps.push(C33.New(C33.Gfx.EffectChain.Step.PostDraw,this,i,0))}else this._canUseFastPath=!0}}_ShouldPreDraw(e,t){return!!(t.forcePreDraw||e.MustPreDraw()||t.is3D&&!e.Supports3DDirectRendering()||e.UsesDepth()&&!this._useFullSurface||0!==this._boxExtendHorizontal||0!==this._boxExtendVertical)||(e.GetRenderer().IsWebGL()?e.BlendsBackground()&&(t.isRotatedOrNegativeSizeInstance||t.isSourceTextureRotated)||e.UsesAnySrcRectOrPixelSize()&&t.isSourceTextureRotated:e.BlendsBackground()&&!this._useCopyTextureBackgroundSampling&&t.isRotatedOrNegativeSizeInstance)}_ShouldPostDraw(e,t){return!!t.forcePostDraw||(e.GetRenderer().IsWebGL()?e.BlendsBackground()||e.UsesCrossSampling():(e.BlendsBackground()||e.UsesCrossSampling())&&this._UseRenderTargetBackgroundSampling())}_ShouldUseCopyTextureBackgroundSampling(e){return e.IsWebGPU()&&this._isAnyShaderBackgroundBlending&&!this._isAnyShaderCrossSampling}Render(e,t,s){e.IsWebGPU()&&null===t&&(t=e.GetBackbufferRenderTarget()),this._destRenderTarget=t,this._contentObject=s.contentObject||null,this._contextObject=s.contextObject||null,this._blendMode=s.blendMode||0,this._devicePixelRatio=s.devicePixelRatio||1,this._layerScale=s.layerScale||1,this._layerAngle=s.layerAngle||0,this._time="number"==typeof s.time?s.time:this._manager.GetTime(),this._didChangeTransform=!1,e.ResetDidChangeTransformFlag(),this._isAnyShaderAnimated&&this._Redraw();let i=!1;if(this._UseCopyTextureBackgroundSampling()&&(this._CalculateDrawSizeAndRectangles(e,s),i=!0,this._backTex=this._manager._GetWebGPUBackTexture(e,this._drawWidth,this._drawHeight),tempRect.copy(this._drawSurfaceRect),tempRect.roundOuter(),e.IsWebGPU()&&e._MaybeDoPendingClearRenderPass(this._destRenderTarget),e.CopyTextureToTexture(this._destRenderTarget.GetTexture(),this._backTex,tempRect.getLeft(),tempRect.getTop(),tempRect.width(),tempRect.height())),this._canUseFastPath)this._Render_FastPath(e,s);else if(i||this._CalculateDrawSizeAndRectangles(e,s),0!==this._rcTexOriginal.width()||0!==this._rcTexOriginal.height()){e.SetAlphaBlend(),e.ResetColor(),e.SetBaseZ(0),e.SetCurrentZ(0),this._cbDrawContentHook=s.drawContentHook||null,this._compositOffX=s.compositOffX||0,this._compositOffY=s.compositOffY||0,this._updateOwnProjection=!!s.updateOwnProjection,this._OnBeforeStartEffectChain(e),this._renderTargets[0]=t,this._renderTargets[1]=1<=this._numTempSurfacesRequired?this._GetRenderTarget():null,this._renderTargets[2]=2===this._numTempSurfacesRequired?this._GetRenderTarget():null;for(const n of this._steps){const r=this._GetRenderTargetForId(n.GetSrcTargetId()),a=this._GetRenderTargetForId(n.GetDestTargetId());e.IsWebGPU()?n.Run_WebGPU(e,r,a):n.Run_WebGL(e,r,a)}e.SetTexture(null),this._renderTargets[1]&&this._ReleaseRenderTarget(this._renderTargets[1]),this._renderTargets[2]&&this._ReleaseRenderTarget(this._renderTargets[2]),this._renderTargets.fill(null),this._OnAfterEndEffectChain(e),this._destRenderTarget=null,this._backTex=null,this._contentObject=null,this._contextObject=null,this._cbDrawContentHook=null}}_CalculateDrawSizeAndRectangles(e,t){const[s,i]=this._manager.GetDrawSize(e);this._SetDrawSize(e,s,i),this._CalculateRectangles(t)}_SetDrawSize(e,t,s){if(t<=0||s<=0)throw new Error("invalid draw size");this._drawWidth===t&&this._drawHeight===s||this._CalculateDeviceTransformMatrices(e,t,s,0,0,this._projectionMatrix,this._modelViewMatrix),this._drawWidth=t,this._drawHeight=s}_CalculateDeviceTransformMatrices(e,t,s,i,n,r,a){const o=t/2+i,l=s/2+n,h=(e.CalculatePerspectiveMatrix(r,t/s),e.CalculateLookAtModelView2(o,l,e.GetDefaultCameraZ(s),o,l,0,s));mat42.copy(a,h)}_CalculateRectangles(e){this._layoutRect.copy(e.layoutRect),e.drawSurfaceRect?this._drawSurfaceRect.copy(e.drawSurfaceRect):this._drawSurfaceRect.set(0,0,this._drawWidth,this._drawHeight),this._rcTexOriginal.copy(this._drawSurfaceRect),this._rcTexOriginal.divide(this._drawWidth,this._drawHeight);const t=this._layerScale*this._devicePixelRatio;this._drawSurfaceRect.inflate(this._boxExtendHorizontal*t,this._boxExtendVertical*t),this._rcTexDest.copy(this._drawSurfaceRect),this._rcTexDest.divide(this._drawWidth,this._drawHeight),this._drawSurfaceRect.clampBoth(0,0,this._drawWidth,this._drawHeight),this._rcTexBounce.copy(this._drawSurfaceRect),this._rcTexBounce.divide(this._drawWidth,this._drawHeight)}_OnBeforeStartEffectChain(e){if(this._depthEnabledAtStart=e.IsDepthEnabled(),this._coplanarColorPassAtStart=e.IsCoplanarColorPass(),this._useFullSurface)e.SetDepthEnabled(!1),this._isAnyShaderDepthSampling&&e.SetDepthSamplingEnabled(!0);else{if(tempRect.copy(this._drawSurfaceRect),e.IsWebGL()){const t=this._layerScale*this._devicePixelRatio;tempRect.inflate(Math.max(this._boxExtendHorizontal,1)*t,Math.max(this._boxExtendVertical,1)*t),tempRect.roundOuter(),tempRect.clamp(0,0,this._drawWidth,this._drawHeight)}else tempRect.roundOuter();e.SetScissorRect(tempRect.getLeft(),tempRect.getTop(),tempRect.width(),tempRect.height(),this._drawHeight)}}_OnAfterEffectChainDrawContent(e){e.ResetColor(),this._useFullSurface||(this._coplanarColorPassAtStart&&e.CoplanarRestoreStandardRendering(),e.SetDepthEnabled(!1),this._isAnyShaderDepthSampling&&e.SetDepthSamplingEnabled(!0)),e.IsWebGPU()&&e.SetNormalizedCoordsProgramVariant(!0)}_OnAfterEndEffectChain(e){e.SetDepthSamplingEnabled(!1),this._coplanarColorPassAtStart&&e.CoplanarStartColorPass(),e.SetDepthEnabled(this._depthEnabledAtStart),this._useFullSurface||e.RemoveScissorRect(),e.IsWebGPU()&&e.SetNormalizedCoordsProgramVariant(!1),this._didChangeTransform=e.DidChangeTransform()}_ClampRcTexDest(){this._rcTexDest.clamp(0,0,1,1)}_GetRenderTargetForId(e){return e<0?null:this._renderTargets[e]}_GetRenderTarget(){return this._manager.GetRenderTarget(this)}_GetDestRenderTarget(){return this._destRenderTarget}_ReleaseRenderTarget(e){this._manager.ReleaseRenderTarget(e,this)}_GetShaderProgramAt(e){return this._shaderProgramList[e]}_DrawContent(e){this._cbDrawContentHook?this._cbDrawContentHook(this,e,()=>this._cbDrawContent(e,this)):this._cbDrawContent(e,this),this._canUseFastPath||this._OnAfterEffectChainDrawContent(e)}_IsRenderTargetSameSizeAndOffset(e){if(this._useFullSurface)return!0;if(0!==this._compositOffX||0!==this._compositOffY)return!1;const[t,s]=e.GetRenderTargetSize(e.GetRenderTarget());return t===this._drawWidth&&s===this._drawHeight}_SetDeviceTransform(e,t){let s=this._projectionMatrix,i=this._modelViewMatrix;if(t&&!this._IsRenderTargetSameSizeAndOffset(e)){s=tempMat4a,i=tempMat4b;const[n,r]=e.GetRenderTargetSize(e.GetRenderTarget());this._CalculateDeviceTransformMatrices(e,n,r,this._compositOffX,this._compositOffY,s,i),this._useFullSurface||e.RemoveScissorRect()}e.SetProjectionMatrix(s),e.SetModelViewMatrix(i)}_Redraw(){this._manager.Redraw(this)}_GetShaderParameters(e,t){return this._cbGetShaderParameters(this._shaderProgramIndices[e],t)}_SetProgramParameters(e,t){let s=this._rcTexDest,i=this._rcTexBounce,n=this._rcTexOriginal;e.IsWebGL()&&(tempRect2.copy(s),tempRect2.flipAround(1),s=tempRect2,tempRect3.copy(i),tempRect3.flipAround(1),i=tempRect3,tempRect4.copy(n),tempRect4.flipAround(1),n=tempRect4),this._DoSetProgramParameters(e,t,i,n,s,1/this._drawWidth,1/this._drawHeight)}_SetFirstBounceProgramParameters(e,t){let i=this._rcTexBounce,n=this._rcTexOriginal,r=1/this._drawWidth,a=1/this._drawHeight;if(this._cbGetSourceTextureInfo){let{srcTexRect:e,srcWidth:t,srcHeight:s}=this._cbGetSourceTextureInfo(this._contentObject);e||(tempRect.set(0,0,0,0),e=tempRect),t=t||this._drawWidth,s=s||this._drawHeight,i=e,n=e,r=1/t,a=1/s}else e.IsWebGL()&&(tempRect3.copy(i),tempRect3.flipAround(1),i=tempRect3,tempRect4.copy(n),tempRect4.flipAround(1),n=tempRect4);let s=this._rcTexDest;e.IsWebGL()&&((s=tempRect2).copy(this._rcTexDest),s.flipAround(1)),this._DoSetProgramParameters(e,t,i,n,s,r,a),e.IsWebGPU()&&this._isAnyIsSrcTexRotated&&e.SetProgramParameter_IsSrcTexRotated(this._isSourceTextureRotated)}_GetBackTex(e){return this._isAnyShaderBackgroundBlending?e.IsWebGPU()?this._UseCopyTextureBackgroundSampling()?this._backTex:this._destRenderTarget.GetTexture():this._destRenderTarget:null}_DoSetProgramParameters(e,t,s,i,n,r,a){e.SetProgramParameters(this._GetBackTex(e),n,s,i,this._layoutRect,r,a,this._devicePixelRatio,this._layerScale,this._layerAngle,this._time),e.SetProgramCustomParameters(this._GetShaderParameters(t,e))}_Render_FastPath(e,t){const s=this._shaderProgramList[0],i=e.IsDepthEnabled(),n=s.UsesDepth();n&&(e.SetDepthEnabled(!1),e.SetDepthSamplingEnabled(!0),this._rcTexDest.set(0,0,1,1),this._rcTexOriginal.set(0,0,1,1)),e.SetProgram(s),e.SetBlendMode(this._blendMode),e.SetRenderTarget(this._destRenderTarget);let r=0,a=1;if(this._rcTexOriginal.set(0,0,1,1),s.UsesAnySrcRectOrPixelSize()&&this._cbGetSourceTextureInfo){const{srcTexRect:o,srcWidth:l,srcHeight:h}=this._cbGetSourceTextureInfo(this._contentObject);o&&this._rcTexOriginal.copy(o),r=Number.isFinite(l)?1/l:0,a=Number.isFinite(h)?1/h:0}else{const[c,u]=this._manager.GetDrawSize(e);r=1/c,a=1/u}t.layoutRect?this._layoutRect.copy(t.layoutRect):this._layoutRect.set(0,0,0,0),e.SetProgramParameters(this._GetBackTex(e),this._rcTexDest,this._rcTexOriginal,this._rcTexOriginal,this._layoutRect,r,a,this._devicePixelRatio,this._layerScale,this._layerAngle,this._time),e.SetProgramCustomParameters(this._GetShaderParameters(0,e)),e.IsWebGPU()&&this._isAnyIsSrcTexRotated&&e.SetProgramParameter_IsSrcTexRotated(this._isSourceTextureRotated),e.SetBaseZ(0),this._DrawContent(e),n&&(e.SetDepthSamplingEnabled(!1),e.SetDepthEnabled(i))}_UseCopyTextureBackgroundSampling(){return this._useCopyTextureBackgroundSampling}_UseRenderTargetBackgroundSampling(){return!this._useCopyTextureBackgroundSampling}IsAnyShaderBackgroundBlending(){return this._isAnyShaderBackgroundBlending}CanSkipCalculatingDrawSurfaceRect(){return!!this._canUseFastPath&&!this._UseCopyTextureBackgroundSampling()}UseFullSurface(){return this._useFullSurface}GetContentObject(){return this._contentObject}GetContextObject(){return this._contextObject}_GetBlendMode(){return this._blendMode}_UpdateOwnProjection(){return this._updateOwnProjection}DidChangeTransform(){return this._didChangeTransform}_GetDrawSurfaceRect(){return this._drawSurfaceRect}_GetRcTexBounce(){return this._rcTexBounce}_ShouldInvalidateRenderTargets(){return this._invalidateRenderTargets}async DebugLogRenderTargetContents(e,t,s){}}}{const C33=self.C3;C33.Gfx.EffectChain.Step=class{constructor(e,t,s,i=-1){this._effectChain=e,this._srcTargetId=t,this._destTargetId=s,this._index=i}GetEffectChain(){return this._effectChain}GetSrcTargetId(){return this._srcTargetId}GetDestTargetId(){return this._destTargetId}GetIndex(){return this._index}GetShaderProgram(){return this.GetEffectChain()._GetShaderProgramAt(this.GetIndex())}Run_WebGL(e,t,s){}Run_WebGPU(e,t,s){}}}{const C33=self.C3;C33.Gfx.EffectChain.Step.PreDraw=class extends C33.Gfx.EffectChain.Step{constructor(e,t,s,i){super(e,t,s,i)}Run_WebGL(e,t,s){const i=this.GetEffectChain();e.SetAlphaBlend(),e.SetTextureFillMode(),e.SetRenderTarget(s,i._UpdateOwnProjection()),e.ClearRgba(0,0,0,0),i._DrawContent(e),i._ClampRcTexDest()}Run_WebGPU(e,t,s){const i=this.GetEffectChain();e.SetAlphaBlend(),e.SetTextureFillMode(),e.SetRenderTarget(s,!1),e.ClearRgba(0,0,0,0),i._DrawContent(e),i._ClampRcTexDest()}}}{const C33=self.C3,tempRect=C33.New(C33.Rect),tempQuad=C33.New(C33.Quad);C33.Gfx.EffectChain.Step.PostDraw=class extends C33.Gfx.EffectChain.Step{constructor(e,t,s,i){super(e,t,s,i)}Run_WebGL(e,t,s){const i=this.GetEffectChain();e.SetTextureFillMode(),e.SetRenderTarget(s),i._SetDeviceTransform(e,!0),e.SetBlendMode(i._GetBlendMode()),e.SetTexture(t.GetTexture()),tempQuad.setFromRect(i._GetDrawSurfaceRect()),tempRect.copy(i._GetRcTexBounce()),tempRect.flipAround(1),e.Quad3(tempQuad,tempRect),i._ShouldInvalidateRenderTargets()&&e.InvalidateRenderTarget(t)}Run_WebGPU(e,t,s){const i=this.GetEffectChain();e.SetTextureFillMode(),e.SetRenderTarget(s,!1),i._IsRenderTargetSameSizeAndOffset(e)?tempQuad.setFromRect(i._GetRcTexBounce()):(e.SetNormalizedCoordsProgramVariant(!1),i._SetDeviceTransform(e,!0),tempQuad.setFromRect(i._GetDrawSurfaceRect())),e.SetBackTexture(null),e.SetBlendMode(i._GetBlendMode()),e.SetTexture(t.GetTexture()),i.UseFullSurface()?e.FullscreenQuad():e.Quad3(tempQuad,i._GetRcTexBounce())}}}{const C33=self.C3;C33.Gfx.EffectChain.Step.FirstBounce=class extends C33.Gfx.EffectChain.Step{constructor(e,t,s,i){super(e,t,s,i)}Run_WebGL(e,t,s){const i=this.GetEffectChain();e.SetRenderTarget(s,i._UpdateOwnProjection()),e.ClearRgba(0,0,0,0),e.SetCopyBlend(),e.SetProgram(this.GetShaderProgram()),i._SetFirstBounceProgramParameters(e,this.GetIndex()),i._DrawContent(e),i._ClampRcTexDest()}Run_WebGPU(e,t,s){const i=this.GetEffectChain();e.SetRenderTarget(s,!1),e.ClearRgba(0,0,0,0),e.SetCopyBlend(),e.SetProgram(this.GetShaderProgram()),i._SetFirstBounceProgramParameters(e,this.GetIndex()),i._DrawContent(e),i._ClampRcTexDest()}}}{const C33=self.C3,tempRect=C33.New(C33.Rect),tempQuad=C33.New(C33.Quad);C33.Gfx.EffectChain.Step.Bounce=class extends C33.Gfx.EffectChain.Step{constructor(e,t,s,i){super(e,t,s,i)}Run_WebGL(e,t,s){const i=this.GetEffectChain(),n=(e.SetRenderTarget(s),0===this.GetDestTargetId());n?e.SetBlendMode(i._GetBlendMode()):(e.ClearRgba(0,0,0,0),e.SetCopyBlend()),e.SetProgram(this.GetShaderProgram()),i._SetProgramParameters(e,this.GetIndex()),e.SetTexture(t.GetTexture()),i._SetDeviceTransform(e,n),tempQuad.setFromRect(i._GetDrawSurfaceRect()),tempRect.copy(i._GetRcTexBounce()),tempRect.flipAround(1),e.Quad3(tempQuad,tempRect),i._ShouldInvalidateRenderTargets()&&e.InvalidateRenderTarget(t)}Run_WebGPU(e,t,s){const i=this.GetEffectChain(),n=(e.SetRenderTarget(s,!1),0===this.GetDestTargetId());n?(e.SetBlendMode(i._GetBlendMode()),e.SetBackTexture(null),i._IsRenderTargetSameSizeAndOffset(e)?tempQuad.setFromRect(i._GetRcTexBounce()):(e.SetNormalizedCoordsProgramVariant(!1),i._SetDeviceTransform(e,!0),tempQuad.setFromRect(i._GetDrawSurfaceRect()))):(e.ClearRgba(0,0,0,0),e.SetCopyBlend(),tempQuad.setFromRect(i._GetRcTexBounce())),e.SetProgram(this.GetShaderProgram()),i._SetProgramParameters(e,this.GetIndex()),e.SetTexture(t.GetTexture()),i.UseFullSurface()?e.FullscreenQuad():e.Quad3(tempQuad,i._GetRcTexBounce())}}}{let SortZOrderList2=function(e,t){const s=e[0],i=t[0],n=s-i;if(0!=n)return n;const r=e[1],a=t[1];return r-a},C33=(SortZOrderList=SortZOrderList2,self.C3),C3X=self.C3X,runtime=null,keysDownByKey=new Set,tempZOrderList=[],tempInstances=[],didWarnInAlertPolyfill=!1,didWarnFpsDeprecated=!1,VALID_FRAMERATE_MODES=new Set(["vsync","unlimited-tick","unlimited-frame"]);self.IRuntime=class{constructor(e){runtime=e,Object.defineProperties(this,{assets:{value:runtime.GetAssetManager().GetIAssetManager(),writable:!1},collisions:{value:runtime.GetCollisionEngine().GetICollisionEngine(),writable:!1},objects:{value:{},writable:!1},globalVars:{value:{},writable:!1},projectName:{value:runtime.GetProjectName(),writable:!1},projectVersion:{value:runtime.GetProjectVersion(),writable:!1},exportDate:{value:new Date(runtime.GetExportTimestamp()),writable:!1},storage:{value:new self.IStorage(runtime),writable:!1},isInWorker:{value:runtime.IsInWorker(),writable:!1},viewportWidth:{value:runtime.GetOriginalViewportWidth(),writable:!1},viewportHeight:{value:runtime.GetOriginalViewportHeight(),writable:!1},sampling:{value:runtime.GetSampling(),writable:!1},isPixelRoundingEnabled:{value:runtime.IsPixelRoundingEnabled(),writable:!1},platformInfo:{value:new self.IPlatformInfo(e),writable:!1},sdk:{value:new self.ISDKUtils(e),writable:!1}}),runtime.UserScriptDispatcher().addEventListener("keydown",e=>{keysDownByKey.has(e.key)?e.stopPropagation():keysDownByKey.add(e.key)}),runtime.UserScriptDispatcher().addEventListener("keyup",e=>keysDownByKey.delete(e.key)),runtime.Dispatcher().addEventListener("window-blur",()=>keysDownByKey.clear()),runtime.IsInWorker()&&(self.alert=e=>(didWarnInAlertPolyfill||(didWarnInAlertPolyfill=!0,console.warn("[Construct] alert() was called from a Web Worker, because the project 'Use worker' setting is enabled. This method is not normally available in a Web Worker. Construct has implemented the alert for you, but note that other features may be missing in worker mode. You may wish to disable 'Use worker', or use a more convenient function like console.log(). For more information please refer to the scripting section of the manual.")),this.alert(e)))}_InitObjects(e){Object.defineProperties(this.objects,e)}_InitGlobalVars(e){Object.defineProperties(this.globalVars,e)}addEventListener(e,t){runtime.UserScriptDispatcher().addEventListener(e,t)}removeEventListener(e,t){runtime.UserScriptDispatcher().removeEventListener(e,t)}callFunction(e,...t){C3X.RequireString(e);const s=runtime.GetEventSheetManager(),i=s.GetFunctionBlockByName(e);if(!i)throw new Error(`cannot find function name '${e}'`);if(!i.IsEnabled())return i.GetDefaultReturnValue();if(t.length<i.GetFunctionParameterCount())throw new Error(`not enough function parameters passed for '${e}' (${t.length} passed, ${i.GetFunctionParameterCount()} expected)`);let n=i.GetEventBlock(),r=n.GetSolModifiersIncludingParents(),a=s.GetCurrentEvent();if(a){r=r.slice(0);const l=new Set(r);for(const h of a.GetSolModifiersIncludingParents())l.has(h)||(r.push(h),l.add(h));for(const c of s.GetDynamicSolModifiersSet())l.has(c)||(r.push(c),l.add(c))}const o=n.RunAsExpressionFunctionCall(r,i.IsCopyPicked(),i.GetReturnType(),i.GetDefaultReturnValue(),...t);return o}setReturnValue(e){const t=runtime.GetEventStack().GetCurrentExpFuncStackFrame();if(!t)throw new Error("not in a function which returns a value");switch(t.GetFunctionReturnType()){case 1:"number"==typeof e&&t.SetFunctionReturnValue(e);break;case 2:"string"==typeof e&&t.SetFunctionReturnValue(e);break;case 3:"number"!=typeof e&&"string"!=typeof e||t.SetFunctionReturnValue(e)}}signal(e){C3X.RequireString(e),runtime.GetEventSheetManager().Signal(e)}waitForSignal(e){return C3X.RequireString(e),runtime.GetEventSheetManager().WaitForSignal(e)}getViewportSize(){return[runtime.GetOriginalViewportWidth(),runtime.GetOriginalViewportHeight()]}get isSuspended(){return runtime.IsSuspended()}get dt(){return runtime.GetDt()}get dtRaw(){return runtime.GetDtRaw()}get gameTime(){return runtime.GetGameTime()}get wallTime(){return runtime.GetWallTime()}get timeScale(){return runtime.GetTimeScale()}set timeScale(e){C3X.RequireFiniteNumber(e),runtime.SetTimeScale(e)}get fps(){return didWarnFpsDeprecated||(console.warn("IRuntime.fps is deprecated. Use IRuntime.framesPerSecond instead."),didWarnFpsDeprecated=!0),runtime.GetFramesPerSecond()}get framesPerSecond(){return runtime.GetFramesPerSecond()}get ticksPerSecond(){return runtime.GetTicksPerSecond()}get cpuUtilisation(){return runtime.GetMainThreadTime()}get gpuUtilisation(){return runtime.GetGPUUtilisation()}get framerateMode(){return runtime.GetFramerateMode()}set framerateMode(e){if(!VALID_FRAMERATE_MODES.has(e))throw new Error("invalid framerate mode");runtime._SetFramerateMode(e)}get minDt(){return runtime.GetMinDt()}set minDt(e){C3X.RequireFiniteNumber(e),runtime.SetMinDt(e)}get maxDt(){return runtime.GetMaxDt()}set maxDt(e){runtime.SetMaxDt(e)}get loadingProgress(){return runtime.GetAssetManager().GetLoadProgress()}get imageLoadingProgress(){return runtime.GetAssetManager().GetImageLoadProgress()}random(){return runtime.Random()}get layout(){const e=runtime.GetMainRunningLayout();if(e)return e.GetILayout();throw new Error("no layout is running - make sure a layout is loaded before accessing")}getLayout(e){let t=runtime.GetLayoutManager(),s=null;if("number"!=typeof e&&"string"!=typeof e)throw new TypeError("expected string or number");if(s=t.GetLayout(e))return s.GetILayout();throw new Error("invalid layout")}getAllLayouts(){return runtime.GetLayoutManager().GetAllLayouts().map(e=>e.GetILayout())}goToLayout(e){let t=runtime.GetLayoutManager(),s;if("number"!=typeof e&&"string"!=typeof e)throw new TypeError("expected string or number");if(!(s=t.GetLayout(e)))throw new Error("invalid layout");t.IsPendingChangeMainLayout()||t.ChangeMainLayout(s)}get keyboard(){const e=runtime._GetCommonScriptInterfaces().keyboard;if(e)return e;throw new Error("runtime.keyboard used but Keyboard object missing - add it to your project first")}get mouse(){const e=runtime._GetCommonScriptInterfaces().mouse;if(e)return e;throw new Error("runtime.mouse used but Mouse object missing - add it to your project first")}get touch(){const e=runtime._GetCommonScriptInterfaces().touch;if(e)return e;throw new Error("runtime.touch used but Touch object missing - add it to your project first")}get timelineController(){const e=runtime._GetCommonScriptInterfaces().timelineController;if(e)return e;throw new Error("runtime.timelineController used but Timeline Controller object missing - add it to your project first")}invokeDownload(e,t){C3X.RequireString(e),C3X.RequireString(t),runtime.InvokeDownload(e,t)}getInstanceByUid(e){C3X.RequireFiniteNumber(e);const t=runtime.GetInstanceByUID(e);return t?t.GetInterfaceClass():null}sortZOrder(e,i){C3X.RequireFunction(i);const n=runtime.GetCurrentLayout();for(const t of e){const s=runtime._UnwrapIWorldInstance(t),r=s.GetWorldInfo();tempZOrderList.push([r.GetLayer().GetIndex(),r.GetZIndex()]),tempInstances.push(s)}if(0!==tempZOrderList.length){tempZOrderList.sort(SortZOrderList2),tempInstances.sort((e,t)=>i(e.GetInterfaceClass(),t.GetInterfaceClass()));let s=!1;for(let e=0,t=tempZOrderList.length;e<t;++e){const a=tempInstances[e],o=n.GetLayerByIndex(tempZOrderList[e][0]),l=tempZOrderList[e][1],h=o._GetInstances();h[l]!==a&&((h[l]=a).GetWorldInfo()._SetLayer(o,!0),o.SetZIndicesChanged(a),s=!0)}s&&runtime.UpdateRender(),C33.clearArray(tempZOrderList),C33.clearArray(tempInstances)}}async createWorker(e,t){const s=new MessageChannel,i=s.port1,n=s.port2;return await runtime.PostComponentMessageToDOMAsync("runtime","script-create-worker",{url:e,opts:t,port2:n},[n]),i}alert(e){return runtime.PostComponentMessageToDOMAsync("runtime","alert",{message:e+(runtime.IsInWorker()?" [via Web Worker]":"")})}getHTMLLayer(e){return C3X.RequireFiniteNumber(e),runtime._GetHTMLLayerWrapElement(e)}addLoadPromise(e){runtime.AddLoadPromise(e)}}}{let C33=self.C3,C3X=self.C3X,assetManager=null;self.IAssetManager=class{constructor(e){assetManager=e,Object.defineProperties(this,{isWebMOpusSupported:{value:!0,writable:!1}})}loadImageAsset(e){const t=self.IImageInfo._Unwrap(e);if(!t)throw new Error("invalid IImageInfo");t.LoadAsset(assetManager.GetRuntime())}fetchText(e){return assetManager.FetchText(e)}fetchJson(e){return assetManager.FetchJson(e)}fetchBlob(e){return assetManager.FetchBlob(e)}fetchArrayBuffer(e){return assetManager.FetchArrayBuffer(e)}getProjectFileUrl(e){return assetManager.GetProjectFileUrl(e)}getMediaFileUrl(e){return"flat"===assetManager.GetFileStructure()&&C33.IsRelativeURL(e)&&(e=e.toLowerCase()),assetManager.GetMediaFileUrl(e)}get mediaFolder(){return assetManager.GetMediaSubfolder()}async decodeWebMOpus(e,t){throw new Error("decodeWebMOpus() is no longer supported - use Web Audio's decodeAudioData() directly as all supported platforms now support WebM Opus")}loadScripts(...e){return assetManager.LoadScripts(...e)}compileWebAssembly(e){return assetManager.CompileWebAssembly(e)}loadStyleSheet(e){return assetManager.LoadStyleSheet(e)}}}{let C33=self.C3,C3X=self.C3X,collisionEngine=null;self.ICollisionEngine=class{constructor(e){collisionEngine=e,Object.defineProperties(this,{runtime:{value:collisionEngine.GetRuntime(),writable:!1}})}testOverlap(e,t){const s=collisionEngine.GetRuntime(),i=s._UnwrapIWorldInstance(e),n=s._UnwrapIWorldInstance(t);return collisionEngine.TestOverlap(i,n)}testOverlapAny(e,t){const s=collisionEngine.GetRuntime(),i=s._UnwrapIWorldInstance(e);for(const n of t){const r=s._UnwrapIWorldInstance(n);if(collisionEngine.TestOverlap(i,r))return n}return null}testOverlapSolid(e){const t=collisionEngine.GetRuntime()._UnwrapIWorldInstance(e),s=collisionEngine.TestOverlapSolid(t);return s?s.GetInterfaceClass():null}setCollisionCellSize(e,t){if(C3X.RequireFiniteNumber(e),C3X.RequireFiniteNumber(t),e=Math.floor(e),t=Math.floor(t),e<=0||t<=0)throw new Error("invalid cell size");collisionEngine.SetCollisionCellSize(e,t)}getCollisionCellSize(){return collisionEngine.GetCollisionCellSize()}getCollisionCandidates(e,t){let s=collisionEngine.GetRuntime(),i;i=Array.isArray(e)?e.map(e=>s._UnwrapIObjectClass(e)):[s._UnwrapIObjectClass(e)];const n=C33.Rect.FromObject(t),r=[];return collisionEngine.GetObjectClassesCollisionCandidates(null,i,n,r),r.map(e=>e.GetInterfaceClass())}}}{let C33=self.C3,C3X=self.C3X,runtime=null,osMap=new Map([["Windows","windows"],["macOS","macos"],["Linux","linux"],["Chrome OS","chrome-os"],["Android","android"],["iOS","ios"]]),browserMap=new Map([["Chrome","chrome"],["Chromium","chromium"],["Edge","edge"],["Opera","opera"],["NW.js","nwjs"],["Firefox","firefox"],["Safari","safari"]]),browserEngineMap=new Map([["Chromium","chromium"],["Gecko","gecko"],["WebKit","webkit"]]);self.IPlatformInfo=class{constructor(e){runtime=e,Object.defineProperties(this,{isMobile:{value:C33.Platform.IsMobile,writable:!1},os:{value:osMap.get(C33.Platform.OS)||"unknown",writable:!1},osVersion:{value:C33.Platform.OSVersion,writable:!1},browser:{value:browserMap.get(C33.Platform.Browser)||"unknown",writable:!1},browserVersion:{value:C33.Platform.BrowserVersion,writable:!1},browserEngine:{value:browserEngineMap.get(C33.Platform.BrowserEngine)||"unknown",writable:!1}})}get exportType(){let e=runtime.GetExportType();return runtime.IsNWjs()?e="nwjs":runtime.IsWindowsWebView2()?e="windows-webview2":"cordova"===e?e="Android"===C33.Platform.OS?"cordova-android":"cordova-ios":"playable-ad-single-file"!==e&&"playable-ad-zip"!==e||(e="playable-ad"),e}get renderer(){return runtime.GetCanvasManager().GetRendererString()}get rendererDetail(){return runtime.GetCanvasManager().GetRendererDetailString()}get canvasCssWidth(){return runtime.GetCanvasManager().GetCssWidth()}get canvasCssHeight(){return runtime.GetCanvasManager().GetCssHeight()}get canvasDeviceWidth(){return runtime.GetCanvasManager().GetDeviceWidth()}get canvasDeviceHeight(){return runtime.GetCanvasManager().GetDeviceHeight()}get devicePixelRatio(){return runtime.GetDevicePixelRatio()}}}{const C33=self.C3,C3X=self.C3X;self.IStorage=class{constructor(e){this._storage=e._GetProjectStorage()}getItem(e){return C3X.RequireString(e),this._storage.getItem(e)}setItem(e,t){return C3X.RequireString(e),this._storage.setItem(e,t)}removeItem(e){return C3X.RequireString(e),this._storage.removeItem(e)}clear(){return this._storage.clear()}keys(){return this._storage.keys()}}}{const C33=self.C3,C3X=self.C3X,internalApiToken=C33._GetInternalAPIToken();self.IPlugin=class{#private;constructor(){const e=C33.AddonManager._GetInitObject2(internalApiToken);this.#private=e,Object.defineProperties(this,{runtime:{value:e.GetRuntime().GetIRuntime(),writable:!1},isSingleGlobal:{value:e.IsSingleGlobal(),writable:!1},isWorldType:{value:e.IsWorldType(),writable:!1},isHTMLElementType:{value:e.IsHTMLElementType(),writable:!1},isRotatable:{value:e.IsRotatable(),writable:!1},hasEffects:{value:e.HasEffects(),writable:!1},is3d:{value:e.Is3D(),writable:!1},supportsHierarchies:{value:e.SupportsSceneGraph(),writable:!1},supportsMesh:{value:e.SupportsMesh(),writable:!1}}),e.GetRuntime()._MapScriptInterface(this,e)}static getByConstructor(e){if(!e)return null;const t=C33.AddonManager.GetPluginByConstructorFunction(e);return t?t.GetIPlugin():null}getSingleGlobalObjectType(){return this.#private.GetSingleGlobalObjectClass().GetIObjectClass()}getSingleGlobalInstance(){return this.#private.GetSingleGlobalInstance().GetInterfaceClass()}}}{const C33=self.C3,C3X=self.C3X,internalApiToken=C33._GetInternalAPIToken();self.IObjectClass=class{#private;constructor(){const e=C33.AddonManager._GetInitObject2(internalApiToken);this.#private=e,Object.defineProperties(this,{name:{value:e.GetName(),writable:!1},runtime:{value:e.GetRuntime().GetIRuntime(),writable:!1},plugin:{value:e.GetPlugin().GetIPlugin(),writable:!1}}),e.GetRuntime()._MapScriptInterface(this,e)}addEventListener(e,t){C3X.RequireString(e),C3X.RequireFunction(t),this.#private.UserScriptDispatcher().addEventListener(e,t)}removeEventListener(e,t){C3X.RequireString(e),C3X.RequireFunction(t),this.#private.UserScriptDispatcher().removeEventListener(e,t)}getAllInstances(){return[...this.instances()]}getFirstInstance(){return C33.first(this.instances())}getPickedInstances(){return[...this.pickedInstances()]}getFirstPickedInstance(){return C33.first(this.pickedInstances())}getPairedInstance(e){const t=this.#private,s=t.GetRuntime()._UnwrapIInstance(e),i=t.GetPairedInstance(s);return i?i.GetInterfaceClass():null}*instances(){for(const e of this.#private.instancesIncludingPendingCreate())yield e.GetInterfaceClass()}*pickedInstances(){for(const e of this.#private.GetCurrentSol().GetInstances())yield e.GetInterfaceClass()}setInstanceClass(e){C3X.RequireFunction(e);const t=this.#private;if(0<t.GetInstanceCount())throw new Error("setInstanceClass() called too late, because instances have already been created - call in runOnStartup");t._SetUserScriptInstanceClass(e)}createInstance(e,t,s,i,n){if(C3X.RequireNumber(t),C3X.RequireNumber(s),"number"!=typeof e&&"string"!=typeof e)throw new TypeError("invalid layer parameter");const r=this.#private,a=r.GetRuntime(),o=a.GetMainRunningLayout().GetLayer(e);if(!o)throw new Error("invalid layer");const l=a.CreateInstance(r,o,t,s,i,n),h=(i&&o.SortAndAddInstancesByZIndex(l),a.GetEventSheetManager());return h.BlockFlushingInstances(!0),l._TriggerOnCreatedOnSelfAndRelated(),h.BlockFlushingInstances(!1),h.IsInEventEngine()||a.GetLayoutManager().IsEndingLayout()||a.FlushPendingInstances(),l.GetInterfaceClass()}}}{const C33=self.C3,C3X=self.C3X,map=new WeakMap,VALID_WHERE_STRINGS=["above","below","top-sublayer","bottom-sublayer"];self.ILayout=class{constructor(e){map.set(this,e);const t=[],s=e.GetEffectList(),i=s.GetAllEffectTypes().length;for(let e=0;e<i;++e)t.push(new self.IEffectInstance(s,e));Object.defineProperties(this,{name:{value:e.GetName(),writable:!1},index:{value:e.GetIndex(),writable:!1},effects:{value:t,writable:!1}})}addEventListener(e,t){C3X.RequireString(e),C3X.RequireFunction(t),map.get(this).UserScriptDispatcher().addEventListener(e,t)}removeEventListener(e,t){C3X.RequireString(e),C3X.RequireFunction(t),map.get(this).UserScriptDispatcher().removeEventListener(e,t)}get width(){return map.get(this).GetWidth()}set width(e){C3X.RequireFiniteNumber(e),map.get(this).SetWidth(e)}get height(){return map.get(this).GetHeight()}set height(e){C3X.RequireFiniteNumber(e),map.get(this).SetHeight(e)}setSize(e,t){C3X.RequireFiniteNumber(e),C3X.RequireFiniteNumber(t);const s=map.get(this);s.SetWidth(e),s.SetHeight(t)}getSize(){const e=map.get(this);return[e.GetWidth(),e.GetHeight()]}set scale(e){C3X.RequireFiniteNumber(e),map.get(this).SetScale(e)}get scale(){return map.get(this).GetScale()}set angle(e){C3X.RequireFiniteNumber(e),map.get(this).SetAngle(e)}get angle(){return map.get(this).GetAngle()}set scrollX(e){C3X.RequireNumber(e),map.get(this).SetScrollX(e)}get scrollX(){return map.get(this).GetScrollX()}set scrollY(e){C3X.RequireNumber(e),map.get(this).SetScrollY(e)}get scrollY(){return map.get(this).GetScrollY()}scrollTo(e,t){C3X.RequireNumber(e),C3X.RequireNumber(t);const s=map.get(this);s.SetScrollX(e),s.SetScrollY(t)}getScrollPosition(){const e=map.get(this);return[e.GetScrollX(),e.GetScrollY()]}getLayer(e){let t=map.get(this),s=null;if("number"!=typeof e&&"string"!=typeof e)throw new TypeError("expected string or number");return(s=t.GetLayer(e))?s.GetILayer():null}getAllLayers(){return map.get(this).GetLayers().map(e=>e.GetILayer())}*allLayers(){for(const e of map.get(this).allLayers())yield e.GetILayer()}addLayer(e,t,s){const i=map.get(this),n=self.ILayer,r=(C3X.RequireString(e),C3X.RequireOptionalInstanceOf(t,n),t?i.GetRuntime()._UnwrapScriptInterface(t):null),a=VALID_WHERE_STRINGS.indexOf(s);if(a<0)throw new Error("invalid location");i.AddLayer(e,r,a)}moveLayer(e,t,s){const i=map.get(this),n=i.GetRuntime(),r=self.ILayer,a=(C3X.RequireInstanceOf(e,r),n._UnwrapScriptInterface(e));if(!a)throw new Error("invalid layer");C3X.RequireOptionalInstanceOf(t,r);const o=t?n._UnwrapScriptInterface(t):null,l=VALID_WHERE_STRINGS.indexOf(s);if(l<0)throw new Error("invalid location");i.MoveLayer(a,o,l)}removeLayer(e){const t=map.get(this),s=self.ILayer,i=(C3X.RequireInstanceOf(e,s),t.GetRuntime()._UnwrapScriptInterface(e));if(!i)throw new Error("invalid layer");const n=i.GetRuntime();t.RemoveLayer(i),n.GetEventSheetManager().IsInEventEngine()||n.FlushPendingInstances()}removeAllDynamicLayers(){const e=map.get(this),t=e.GetRuntime();e.RemoveAllDynamicLayers(),t.GetEventSheetManager().IsInEventEngine()||t.FlushPendingInstances()}setVanishingPoint(e,t){C3X.RequireFiniteNumber(e),C3X.RequireFiniteNumber(t),map.get(this).SetVanishingPointXY(e,t)}getVanishingPoint(){return map.get(this)._GetVanishingPoint()}set projection(e){C3X.RequireString(e);const t=map.get(this);if("perspective"===e)t.SetPerspectiveProjection();else{if("orthographic"!==e)throw new Error("invalid projection");t.SetOrthographicProjection()}}get projection(){return map.get(this).IsOrthographicProjection()?"orthographic":"perspective"}}}{const C33=self.C3,C3X=self.C3X,map=new WeakMap,BLEND_MODE_TO_INDEX=new Map([["normal",0],["additive",1],["copy",3],["destination-over",4],["source-in",5],["destination-in",6],["source-out",7],["destination-out",8],["source-atop",9],["destination-atop",10]]),INDEX_TO_BLEND_MODE=new Map([...BLEND_MODE_TO_INDEX.entries()].map(e=>[e[1],e[0]])),tempColor=C33.New(C33.Color);self.ILayer=class{constructor(e){map.set(this,e);const t=[],s=e.GetEffectList(),i=s.GetAllEffectTypes().length;for(let e=0;e<i;++e)t.push(new self.IEffectInstance(s,e));Object.defineProperties(this,{name:{value:e.GetName(),writable:!1},layout:{value:e.GetLayout().GetILayout(),writable:!1},effects:{value:t,writable:!1}}),e.GetRuntime()._MapScriptInterface(this,e)}get parentLayer(){const e=map.get(this).GetParentLayer();return e?e.GetILayer():null}*parentLayers(){for(const e of map.get(this).parentLayers())yield e.GetILayer()}*subLayers(){for(const e of map.get(this).GetSubLayers())yield e.GetILayer()}*allSubLayers(){for(const e of map.get(this).GetSubLayers())for(const t of e.selfAndAllSubLayers())yield t.GetILayer()}get index(){return map.get(this).GetIndex()}get isVisible(){return map.get(this)._IsVisibleFlagSet()}set isVisible(e){map.get(this).SetVisible(e)}get isSelfAndParentsVisible(){return map.get(this).IsVisible()}get isInteractive(){return map.get(this).IsInteractive()}set isInteractive(e){map.get(this).SetInteractive(e)}get isHTMLElementsLayer(){return map.get(this).IsHTMLElementsLayer()}set isHTMLElementsLayer(e){map.get(this).SetIsHTMLElementsLayer(!!e)}get isSelfAndParentsInteractive(){return map.get(this).IsSelfAndParentsInteractive()}get opacity(){return map.get(this).GetOpacity()}set opacity(e){e=C33.clamp(+e,0,1),isNaN(e)||map.get(this).SetOpacity(e)}set scale(e){C3X.RequireFiniteNumber(e),map.get(this).SetOwnScale(e)}get scale(){return map.get(this).GetOwnScale()}set scaleRate(e){C3X.RequireFiniteNumber(e),map.get(this).SetScaleRate(e)}get scaleRate(){return map.get(this).GetScaleRate()}set angle(e){C3X.RequireFiniteNumber(e),map.get(this).SetAngle(e)}get angle(){return map.get(this).GetOwnAngle()}set parallaxX(e){C3X.RequireFiniteNumber(e),map.get(this).SetParallaxX(e)}get parallaxX(){return map.get(this).GetParallaxX()}set parallaxY(e){C3X.RequireFiniteNumber(e),map.get(this).SetParallaxY(e)}get parallaxY(){return map.get(this).GetParallaxY()}set zElevation(e){C3X.RequireFiniteNumber(e),map.get(this).SetZElevation(e)}get zElevation(){return map.get(this).GetZElevation()}set isTransparent(e){map.get(this).SetTransparent(e)}get isTransparent(){return map.get(this).IsTransparent()}set isForceOwnTexture(e){map.get(this).SetForceOwnTexture(e)}get isForceOwnTexture(){return map.get(this).IsForceOwnTexture()}set blendMode(e){C3X.RequireString(e);const t=BLEND_MODE_TO_INDEX.get(e);if("number"!=typeof t)throw new Error("invalid blend mode");map.get(this).SetBlendMode(t)}get blendMode(){return INDEX_TO_BLEND_MODE.get(map.get(this).GetBlendMode())}set backgroundColor(e){if(C3X.RequireArray(e),e.length<3)throw new Error("expected 3 elements");tempColor.setRgb(e[0],e[1],e[2]);const t=map.get(this),s=t.GetBackgroundColor();s.equalsIgnoringAlpha(tempColor)||(s.copyRgb(tempColor),t.GetRuntime().UpdateRender())}get backgroundColor(){const e=map.get(this).GetBackgroundColor();return[e.getR(),e.getG(),e.getB()]}set scrollX(e){C3X.RequireNumber(e);const t=map.get(this);t.SetOwnScrollPositionEnabled(!0),t.SetScrollX(e)}get scrollX(){return map.get(this).GetScrollX()}set scrollY(e){C3X.RequireNumber(e);const t=map.get(this);t.SetOwnScrollPositionEnabled(!0),t.SetScrollY(e)}get scrollY(){return map.get(this).GetScrollY()}scrollTo(e,t){C3X.RequireNumber(e),C3X.RequireNumber(t);const s=map.get(this);s.SetOwnScrollPositionEnabled(!0),s.SetScrollX(e),s.SetScrollY(t)}getScrollPosition(){const e=map.get(this);return[e.GetScrollX(),e.GetScrollY()]}restoreScrollPosition(){map.get(this).SetOwnScrollPositionEnabled(!1)}getViewport(){return map.get(this).GetViewport().toDOMRect()}cssPxToLayer(e,t,s=0){C3X.RequireNumber(e),C3X.RequireNumber(t),C3X.RequireNumber(s);const i=map.get(this),n=i.GetRuntime();return i.CanvasCssToLayer(e-n.GetCanvasClientX(),t-n.GetCanvasClientY(),s)}layerToCssPx(e,t,s=0){C3X.RequireNumber(e),C3X.RequireNumber(t),C3X.RequireNumber(s);const i=map.get(this),n=i.GetRuntime(),[r,a]=i.LayerToCanvasCss(e,t,s);return[r+n.GetCanvasClientX(),a+n.GetCanvasClientY()]}drawSurfaceToLayer(e,t,s=0){return C3X.RequireNumber(e),C3X.RequireNumber(t),C3X.RequireNumber(s),map.get(this).DrawSurfaceToLayer(e,t,s)}layerToDrawSurface(e,t,s=0){return C3X.RequireNumber(e),C3X.RequireNumber(t),C3X.RequireNumber(s),map.get(this).LayerToDrawSurface(e,t,s)}get renderScale(){return map.get(this).GetRenderScale()}}}{let GetDispatcher2=function(e){let t=dispatchers.get(e);return t||(t=C33.New(C33.Event.Dispatcher),dispatchers.set(e,t)),t};GetDispatcher=GetDispatcher2;const C33=self.C3,C3X=self.C3X,dispatchers=new WeakMap,internalApiToken=C33._GetInternalAPIToken();self.IInstance=class{#private;constructor(){const e=C33.AddonManager._GetInitObject2(internalApiToken),t={runtime:{value:(this.#private=e).GetRuntime().GetIRuntime(),writable:!1},objectType:{value:e.GetObjectClass().GetIObjectClass(),writable:!1},plugin:{value:e.GetPlugin().GetIPlugin(),writable:!1}};e._GetInstVarsScriptDescriptor(t),e._GetBehaviorsScriptDescriptor(t),Object.defineProperties(this,t),e.GetRuntime()._MapScriptInterface(this,e)}static _GetInitInst(){return C33.AddonManager._GetInitObject()}_release(){const e=dispatchers.get(this);e&&(e.Release(),dispatchers.delete(this))}addEventListener(e,t,s){C3X.RequireString(e),C3X.RequireFunction(t),GetDispatcher2(this).addEventListener(e,t,s)}removeEventListener(e,t,s){C3X.RequireString(e),C3X.RequireFunction(t),GetDispatcher2(this).removeEventListener(e,t,s)}dispatchEvent(e){GetDispatcher2(this).dispatchEvent(e)}destroy(){const e=this.#private,t=e.GetRuntime();t.DestroyInstance(e),t.GetEventSheetManager().IsInEventEngine()||t.GetLayoutManager().IsEndingLayout()||t.GetEventSheetManager().IsFlushingBlocked()||t.FlushPendingInstances()}getOtherContainerInstances(){const e=this.#private.GetSiblings();return e?e.map(e=>e.GetInterfaceClass()):[]}*otherContainerInstances(){const e=this.#private;if(e.IsInContainer())for(const t of e.siblings())yield t.GetInterfaceClass()}get uid(){return this.#private.GetUID()}get iid(){return this.#private.GetIID()}get templateName(){return this.#private.GetTemplateName()}set timeScale(e){C3X.RequireFiniteNumber(e),this.#private.SetTimeScale(e)}get timeScale(){return this.#private.GetActiveTimeScale()}restoreTimeScale(){this.#private.RestoreTimeScale()}get dt(){const e=this.#private;return e.GetRuntime().GetDt(e)}hasTags(...e){C3X.RequireArray(e);const t=new Set(e),s=this.#private.GetTagsSet();return t.isSubsetOf(s)}setAllTags(e){C3X.RequireInstanceOf(e,Set),this.#private.SetTagsSet(e)}getAllTags(){return new Set(this.#private.GetTagsSet())}signal(e){C3X.RequireString(e);const t=this.#private;t.GetRuntime().GetEventSheetManager().InstanceSignal(t,e)}waitForSignal(e){C3X.RequireString(e);const t=this.#private;return t.GetRuntime().GetEventSheetManager().WaitForInstanceSignal(t,e)}}}{const C33=self.C3,C3X=self.C3X,internalApiToken=C33._GetInternalAPIToken();self.ISDKInstanceBase=class extends self.IInstance{#private;#isTicking=!1;#tickFunc=null;#isTicking2=!1;#tickFunc2=null;#domComponentId;#wrapperComponentId;constructor(e){super(),this.#private=C33.AddonManager._GetInitObject2(internalApiToken),this.#isTicking=!1,this.#tickFunc=null,this.#isTicking2=!1,this.#tickFunc2=null,this.#domComponentId=e?.domComponentId,this.#wrapperComponentId=e?.wrapperComponentId}_release(){this._setTicking(!1),this._setTicking2(!1),super._release()}_getInitProperties(){return C33.AddonManager._GetInitProperties()}_trigger(e){const t=this.#private;t.GetRuntime().Trigger(e,t)}_triggerAsync(e){const t=this.#private;return t.GetRuntime().TriggerAsync(e,t)}_addDOMMessageHandler(e,t){if(C3X.RequireString(e),C3X.RequireFunction(t),!this.#domComponentId)throw new Error("no DOM component id set");const s=this.#private.GetRuntime();s.AddDOMComponentMessageHandler(this.#domComponentId,e,t)}_addDOMMessageHandlers(e){C3X.RequireArray(e);for(const[t,s]of e)this._addDOMMessageHandler(t,s)}_postToDOM(e,t){if(C3X.RequireString(e),!this.#domComponentId)throw new Error("no DOM component id set");const s=this.#private.GetRuntime();s.PostComponentMessageToDOM(this.#domComponentId,e,t)}_postToDOMAsync(e,t){if(C3X.RequireString(e),!this.#domComponentId)throw new Error("no DOM component id set");const s=this.#private.GetRuntime();return s.PostComponentMessageToDOMAsync(this.#domComponentId,e,t)}_postToDOMMaybeSync(e,t){const s=this.#private.GetRuntime();if(!s.IsInWorker())return window.c3_runtimeInterface._OnMessageFromRuntime({type:"event",component:this.#domComponentId,handler:e,data:t,responseId:null});this._postToDOM(e,t)}_setTicking(e){if(this.#isTicking!==(e=!!e)){this.#isTicking=e;const t=this.#private.GetRuntime();if(e){if(!this.#tickFunc)if(this.#private.GetRuntime().IsDebug()){const s=globalThis.C3Debugger,i=this.plugin;this.#tickFunc=()=>{const e=performance.now();this._tick(),s.AddIndividualPluginTickTime(i,performance.now()-e)}}else this.#tickFunc=()=>this._tick();t.Dispatcher().addEventListener("tick",this.#tickFunc)}else t.Dispatcher().removeEventListener("tick",this.#tickFunc)}}_isTicking(){return this.#isTicking}_tick(){}_setTicking2(e){if(this.#isTicking2!==(e=!!e)){this.#isTicking2=e;const t=this.#private.GetRuntime();if(e){if(!this.#tickFunc2)if(this.#private.GetRuntime().IsDebug()){const s=globalThis.C3Debugger,i=this.plugin;this.#tickFunc2=()=>{const e=performance.now();this._tick2(),s.AddIndividualPluginTickTime(i,performance.now()-e)}}else this.#tickFunc2=()=>this._tick2();t.Dispatcher().addEventListener("tick2",this.#tickFunc2)}else t.Dispatcher().removeEventListener("tick2",this.#tickFunc2)}}_isTicking2(){return this.#isTicking2}_tick2(){}_getDebuggerProperties(){return[]}_saveToJson(){return null}_loadFromJson(e){}_isWrapperExtensionAvailable(){if(!this.#wrapperComponentId)throw new Error("no wrapper component id set");const e=this.#private.GetRuntime();return e.HasWrapperComponentId(this.#wrapperComponentId)}_addWrapperExtensionMessageHandler(e,t){if(C3X.RequireString(e),C3X.RequireFunction(t),!this.#wrapperComponentId)throw new Error("no wrapper component id set");const s=this.#private.GetRuntime();s.AddWrapperExtensionMessageHandler(this.#wrapperComponentId,e,t)}_addWrapperMessageHandlers(e){C3X.RequireArray(e);for(const[t,s]of e)this._addWrapperExtensionMessageHandler(t,s)}_sendWrapperExtensionMessage(e,t){if(!this.#wrapperComponentId)throw new Error("no wrapper component id set");this.runtime.sdk.sendWrapperExtensionMessage(this.#wrapperComponentId,e,t)}_sendWrapperExtensionMessageAsync(e,t){if(this.#wrapperComponentId)return this.runtime.sdk.sendWrapperExtensionMessageAsync(this.#wrapperComponentId,e,t);throw new Error("no wrapper component id set")}}}{let MakeIWorldInstanceClass2=function(e){return class n extends e{#privateInst;#privateWi;constructor(e){super(e);const t=C33.AddonManager._GetInitObject2(internalApiToken),s=t.GetWorldInfo(),i=(this.#privateInst=t,this.#privateWi=s,map.set(this,t),[]),n=s.GetInstanceEffectList();if(n){const a=s.GetObjectClass().GetEffectList().GetAllEffectTypes().length;for(let e=0;e<a;++e)i.push(new self.IEffectInstance(n,e))}const r={effects:{value:i,writable:!1}};Object.defineProperties(this,r)}get layout(){return this.#privateWi.GetLayout().GetILayout()}get layer(){return this.#privateWi.GetLayer().GetILayer()}get x(){return this.#privateWi.GetX()}set x(e){e=+e;const t=this.#privateWi;isNaN(e)||t.GetX()===e||(t.SetX(e),t.SetBboxChanged())}get y(){return this.#privateWi.GetY()}set y(e){e=+e;const t=this.#privateWi;isNaN(e)||t.GetY()===e||(t.SetY(e),t.SetBboxChanged())}setPosition(e,t){e=+e,t=+t;const s=this.#privateWi;isNaN(e)||isNaN(t)||s.GetX()===e&&s.GetY()===t||(s.SetXY(e,t),s.SetBboxChanged())}getPosition(){const e=this.#privateWi;return[e.GetX(),e.GetY()]}offsetPosition(e,t){if(e=+e,t=+t,!(isNaN(e)||isNaN(t)||0===e&&0===t)){const s=this.#privateWi;s.OffsetXY(e,t),s.SetBboxChanged()}}get zElevation(){return this.#privateWi.GetZElevation()}set zElevation(e){e=+e;const t=this.#privateInst,s=this.#privateWi;isNaN(e)||s.GetZElevation()===e||(s.SetZElevation(e),t.GetRuntime().UpdateRender())}get totalZElevation(){return this.#privateWi.GetTotalZElevation()}get width(){return this.#privateWi.GetWidth()}set width(e){e=+e;const t=this.#privateWi;isNaN(e)||t.GetWidth()===e||(t.SetWidth(e),t.SetBboxChanged())}get height(){return this.#privateWi.GetHeight()}set height(e){e=+e;const t=this.#privateWi;isNaN(e)||t.GetHeight()===e||(t.SetHeight(e),t.SetBboxChanged())}setSize(e,t){e=+e,t=+t;const s=this.#privateWi;isNaN(e)||isNaN(t)||s.GetWidth()===e&&s.GetHeight()===t||(s.SetSize(e,t),s.SetBboxChanged())}getSize(){const e=this.#privateWi;return[e.GetWidth(),e.GetHeight()]}get angle(){return this.#privateWi.GetAngle()}set angle(e){e=C33.clampAngle(+e);const t=this.#privateWi;isNaN(e)||t.GetAngle()===e||(t.SetAngle(e),t.SetBboxChanged())}get angleDegrees(){return C33.toDegrees(this.angle)}set angleDegrees(e){this.angle=C33.toRadians(e)}getBoundingBox(){return this.#privateWi.GetBoundingBox().toDOMRect()}getBoundingQuad(){return this.#privateWi.GetBoundingQuad().toDOMQuad()}isOnScreen(){return this.#privateWi.IsInViewport2()}get isVisible(){return this.#privateWi.IsVisible()}set isVisible(e){e=!!e;const t=this.#privateInst,s=this.#privateWi;s.IsVisible()!==e&&(s.SetVisible(e),t.GetRuntime().UpdateRender())}get opacity(){return this.#privateWi.GetOpacity()}set opacity(e){e=C33.clamp(+e,0,1);const t=this.#privateInst,s=this.#privateWi;isNaN(e)||s.GetOpacity()===e||(s.SetOpacity(e),t.GetRuntime().UpdateRender())}set colorRgb(e){if(C3X.RequireArray(e),e.length<3)throw new Error("expected 3 elements");tempColor.setRgb(e[0],e[1],e[2]);const t=this.#privateInst,s=this.#privateWi;s.GetUnpremultipliedColor().equalsIgnoringAlpha(tempColor)||(s.SetUnpremultipliedColor(tempColor),t.GetRuntime().UpdateRender())}get colorRgb(){const e=this.#privateWi.GetUnpremultipliedColor();return[e.getR(),e.getG(),e.getB()]}set blendMode(e){C3X.RequireString(e);const t=BLEND_MODE_TO_INDEX.get(e);if("number"!=typeof t)throw new Error("invalid blend mode");const s=this.#privateInst,i=this.#privateWi;i.SetBlendMode(t),s.GetRuntime().UpdateRender()}get blendMode(){return INDEX_TO_BLEND_MODE.get(this.#privateWi.GetBlendMode())}moveToTop(){this.#privateWi.ZOrderMoveToTop()}moveToBottom(){this.#privateWi.ZOrderMoveToBottom()}moveToLayer(e){C3X.RequireInstanceOf(e,ILayer);const t=this.#privateInst,s=t.GetRuntime()._UnwrapScriptInterface(e);if(!s)throw new Error("invalid layer");t.GetWorldInfo().ZOrderMoveToLayer(s)}moveAdjacentToInstance(e,t){C3X.RequireInstanceOf(e,n),this.#privateWi.ZOrderMoveAdjacentToInstance(map.get(e),t)}get zIndex(){return this.#privateWi.GetZIndex()}get isCollisionEnabled(){return this.#privateWi.IsCollisionEnabled()}set isCollisionEnabled(e){this.#privateWi.SetCollisionEnabled(!!e)}containsPoint(e,t){return C3X.RequireNumber(e),C3X.RequireNumber(t),this.#privateWi.ContainsPoint(+e,+t)}testOverlap(e){C3X.RequireInstanceOf(e,n);const t=this.#privateInst,s=map.get(e);return t.GetRuntime().GetCollisionEngine().TestOverlap(t,s)}testOverlapSolid(){const e=this.#privateInst,t=e.GetRuntime().GetCollisionEngine().TestOverlapSolid(e);return t?t.GetInterfaceClass():null}getParent(){const e=this.#privateInst.GetParent();return e?e.GetInterfaceClass():null}getTopParent(){const e=this.#privateInst.GetTopParent();return e?e.GetInterfaceClass():null}*parents(){for(const e of this.#privateInst.parents())yield e.GetInterfaceClass()}getChildCount(){return this.#privateInst.GetChildCount()}getChildAt(e){const t=this.#privateInst.GetChildAt(e);return t?t.GetInterfaceClass():null}*children(){for(const e of this.#privateInst.children())yield e.GetInterfaceClass()}*allChildren(){for(const e of this.#privateInst.allChildren())yield e.GetInterfaceClass()}addChild(e,t){C3X.RequireInstanceOf(e,n),C3X.RequireOptionalObject(t),t=t||{};const s=this.#privateInst,i=map.get(e);s.AddChild(i,t)}removeChild(e){C3X.RequireInstanceOf(e,n);const t=this.#privateInst,s=map.get(e);t.RemoveChild(s)}removeFromParent(){const e=this.#privateInst;if(e.HasParent()){const t=e.GetParent();t.RemoveChild(e)}}getHierarchyOpts(){const e=this.#privateWi;return{transformX:e.GetTransformWithParentX(),transformY:e.GetTransformWithParentY(),transformWidth:e.GetTransformWithParentWidth(),transformHeight:e.GetTransformWithParentHeight(),transformAngle:e.GetTransformWithParentAngle(),transformZElevation:e.GetTransformWithParentZElevation(),transformOpacity:e.GetTransformWithParentOpacity(),transformVisibility:e.GetTransformWithParentVisibility(),destroyWithParent:e.GetDestroyWithParent()}}createMesh(e,t){C3X.RequireFiniteNumber(e),C3X.RequireFiniteNumber(t),this.#privateWi.CreateMesh(e,t)}releaseMesh(){const e=this.#privateWi;e.ReleaseMesh(),e.SetBboxChanged()}setMeshPoint(e,t,s){C3X.RequireFiniteNumber(e),C3X.RequireFiniteNumber(t),C3X.RequireObject(s);const i=this.#privateWi;i.SetMeshPoint(e,t,s)&&i.SetBboxChanged()}getMeshPoint(e,t){let s=NaN,i=NaN,n=NaN,r=NaN,a=NaN,o=this.#privateWi;if(o.HasMesh()){const l=o.GetSourceMesh(),h=l.GetMeshPointAt(e,t);null!==h&&(s=h.GetX(),i=h.GetY(),n=h.GetZElevation(),r=h.GetU(),a=h.GetV())}return{x:s,y:i,zElevation:n,u:r,v:a}}getMeshSize(){const e=this.#privateWi;if(!e.HasMesh())return[0,0];const t=e.GetSourceMesh();return[t.GetHSize(),t.GetVSize()]}}};MakeIWorldInstanceClass=MakeIWorldInstanceClass2;const C33=self.C3,C3X=self.C3X,IInstance=self.IInstance,ILayer=self.ILayer,map=new WeakMap,internalApiToken=C33._GetInternalAPIToken(),BLEND_MODE_TO_INDEX=new Map([["normal",0],["additive",1],["copy",3],["destination-over",4],["source-in",5],["destination-in",6],["source-out",7],["destination-out",8],["source-atop",9],["destination-atop",10]]),INDEX_TO_BLEND_MODE=new Map([...BLEND_MODE_TO_INDEX.entries()].map(e=>[e[1],e[0]])),tempColor=C33.New(C33.Color);self.IWorldInstance=MakeIWorldInstanceClass2(self.IInstance),self.IWorldInstanceSDKBase=MakeIWorldInstanceClass2(self.ISDKInstanceBase)}{const C33=self.C3,C3X=self.C3X;self.IDOMInstance=class extends self.IWorldInstance{#private;constructor(){super(),this.#private=self.IInstance._GetInitInst()}getElement(){return this.#private.GetSdkInstance()._GetElementInDOMMode()}focus(){this.#private.GetSdkInstance().FocusElement()}blur(){this.#private.GetSdkInstance().BlurElement()}setCssStyle(e,t){C3X.RequireString(e),this.#private.GetSdkInstance().SetElementCSSStyle(e,t)}}}{let GetDispatcher2=function(e){let t=dispatchers.get(e);return t||(t=C33.New(C33.Event.Dispatcher),dispatchers.set(e,t)),t};GetDispatcher=GetDispatcher2;const C33=self.C3,C3X=self.C3X,dispatchers=new WeakMap,internalApiToken=C33._GetInternalAPIToken();self.IBehaviorInstance=class{#private;constructor(){const e=C33.AddonManager._GetInitObject2(internalApiToken),t={runtime:{value:(this.#private=e).GetRuntime().GetIRuntime(),writable:!1},behavior:{value:e.GetBehavior().GetIBehavior(),writable:!1},behaviorType:{value:e.GetBehaviorType().GetIBehaviorType(),writable:!1}};Object.defineProperties(this,t),e.GetRuntime()._MapScriptInterface(this,e)}static _GetInitInst(){return C33.AddonManager._GetInitObject()}get instance(){return this.#private.GetObjectInstance().GetInterfaceClass()}_release(){const e=dispatchers.get(this);e&&(e.Release(),dispatchers.delete(this))}addEventListener(e,t,s){C3X.RequireString(e),C3X.RequireFunction(t),GetDispatcher2(this).addEventListener(e,t,s)}removeEventListener(e,t,s){C3X.RequireString(e),C3X.RequireFunction(t),GetDispatcher2(this).removeEventListener(e,t,s)}dispatchEvent(e){GetDispatcher2(this).dispatchEvent(e)}}}{const C33=self.C3,C3X=self.C3X,internalApiToken=C33._GetInternalAPIToken();self.IBehaviorType=class{constructor(){const e=C33.AddonManager._GetInitObject2(internalApiToken),t={runtime:{value:e.GetRuntime().GetIRuntime(),writable:!1},behavior:{value:e.GetBehavior().GetIBehavior(),writable:!1},name:{value:e.GetName(),writable:!1}};Object.defineProperties(this,t)}}}{const C33=self.C3,C3X=self.C3X,internalApiToken=C33._GetInternalAPIToken();self.IBehavior=class{#private;constructor(){const e=C33.AddonManager._GetInitObject2(internalApiToken),t={runtime:{value:(this.#private=e).GetRuntime().GetIRuntime(),writable:!1}};Object.defineProperties(this,t),e.GetRuntime()._MapScriptInterface(this,e)}getAllInstances(){return this.#private.GetInstances().map(e=>e.GetInterfaceClass())}static getByConstructor(e){if(!e)return null;const t=C33.AddonManager.GetBehaviorByConstructorFunction(e);return t?t.GetIBehavior():null}}}{const C33=self.C3,C3X=self.C3X,tempColor=C33.New(C33.Color);self.IEffectInstance=class{#private;constructor(e,t){this.#private=e;const s={index:{value:t,writable:!1}};Object.defineProperties(this,s)}get name(){const e=this.#private.GetAllEffectTypes();return e[this.index].GetName()}get isActive(){return this.#private.IsEffectIndexActive(this.index)}set isActive(e){e=!!e;const t=this.#private;t.IsEffectIndexActive(this.index)!==e&&(t.SetEffectIndexActive(this.index,e),t.UpdateActiveEffects(),t.GetRuntime().UpdateRender())}setParameter(e,t){C3X.RequireFiniteNumber(e),e=Math.floor(+e);const s=this.#private,i=s.GetEffectParameter(this.index,e);if(null===i)throw new RangeError("invalid index");if(i instanceof C33.Color){if(!Array.isArray(t)||t.length<3)throw new TypeError("expected array with 3 elements");tempColor.setRgb(t[0],t[1],t[2]),t=tempColor}else if("number"!=typeof t)throw new TypeError("expected number");const n=s.SetEffectParameter(this.index,e,t);n&&s.IsEffectIndexActive(this.index)&&s.GetRuntime().UpdateRender()}getParameter(e){C3X.RequireFiniteNumber(e),e=Math.floor(+e);const t=this.#private,s=t.GetEffectParameter(this.index,e);if(null===s)throw new RangeError("invalid index");return s instanceof C33.Color?[s.getR(),s.getG(),s.getB()]:s}}}{const C33=self.C3,C3X=self.C3X;self.IAnimation=class{#private;constructor(e){this.#private=e,Object.defineProperties(this,{name:{value:e.GetName(),writable:!1}})}get speed(){return this.#private.GetSpeed()}get isLooping(){return this.#private.IsLooping()}get repeatCount(){return this.#private.GetRepeatCount()}get repeatTo(){return this.#private.GetRepeatTo()}get isPingPong(){return this.#private.IsPingPong()}get frameCount(){return this.#private.GetFrameCount()}getFrames(){return this.#private.GetFrames().map(e=>e.GetIAnimationFrame())}*frames(){for(const e of this.#private.GetFrames())yield e.GetIAnimationFrame()}}}{const C33=self.C3,C3X=self.C3X;self.IImageInfo=class{#private;constructor(e){this.#private=e}static _Unwrap(e){return e.#private}get width(){return this.#private.GetWidth()}get height(){return this.#private.GetHeight()}getSize(){const e=this.#private;return[e.GetWidth(),e.GetHeight()]}getTexture(e){return e.getTextureForImageInfo(this)}getTexRect(){return this.#private.GetTexRect().toDOMRect()}}}{const C33=self.C3,C3X=self.C3X;self.IAnimationFrame=class extends self.IImageInfo{#private;constructor(e){super(e.GetImageInfo()),this.#private=e,Object.defineProperties(this,{duration:{value:e.GetDuration(),writable:!1},originX:{value:e.GetOriginX(),writable:!1},originY:{value:e.GetOriginY(),writable:!1}})}getOrigin(){const e=this.#private;return[e.GetOriginX(),e.GetOriginY()]}getImagePointCount(){return this.#private.GetImagePointCount()}getImagePointX(e){return this.getImagePoint(e)[0]}getImagePointY(e){return this.getImagePoint(e)[1]}getImagePoint(e){let t=this.#private,s=null;if("number"==typeof e)s=t.GetImagePointByIndex(Math.floor(e));else{if("string"!=typeof e)throw new TypeError("expected string or number");s=t.GetImagePointByName(e)}return s?[s.GetX(),s.GetY()]:this.getOrigin()}getPolyPointCount(){const e=this.#private.GetCollisionPoly();return e?e.pointCount():0}getPolyPointX(e){return this.getPolyPoint(e)[0]}getPolyPointY(e){return this.getPolyPoint(e)[1]}getPolyPoint(e){C3X.RequireFiniteNumber(e),e=Math.floor(e);const t=this.#private.GetCollisionPoly();if(!t||e<0||e>=t.pointCount())return[0,0];const s=t.pointsArr(),i=s[2*e],n=s[2*e+1];return[i,n]}get tag(){return this.#private.GetTag()}}}{let GetTimelineState2=function(e){const t=map.get(e);if(t.IsReleased())throw new Error("timeline/tween was released and is no longer valid");return t};GetTimelineState=GetTimelineState2;const C33=self.C3,C3X=self.C3X,map=new WeakMap;self.ITimelineStateBase=class{constructor(e){map.set(this,e),e.GetRuntime()._MapScriptInterface(this,e)}pause(){GetTimelineState2(this).Stop()}resume(){GetTimelineState2(this).Resume()}stop(){GetTimelineState2(this).Reset()}hasTags(e){return GetTimelineState2(this).HasTags(e)}set time(e){C3X.RequireFiniteNumber(e),GetTimelineState2(this).SetTime(e)}get time(){return GetTimelineState2(this).GetTime()}set totalTime(e){C3X.RequireFiniteNumber(e),GetTimelineState2(this).SetTotalTime(e)}get totalTime(){return GetTimelineState2(this).GetTotalTime()}set isLooping(e){GetTimelineState2(this).SetLoop(!!e)}get isLooping(){return GetTimelineState2(this).GetLoop()}set isPingPong(e){GetTimelineState2(this).SetPingPong(!!e)}get isPingPong(){return GetTimelineState2(this).GetPingPong()}set playbackRate(e){C3X.RequireFiniteNumber(e),GetTimelineState2(this).SetPlaybackRate(e)}get playbackRate(){return GetTimelineState2(this).GetPlaybackRate()}get progress(){const e=GetTimelineState2(this);return e.GetTime()/e.GetTotalTime()}get tags(){return GetTimelineState2(this).GetTags()}get finished(){return GetTimelineState2(this).GetPlayPromise()}get isPlaying(){return GetTimelineState2(this).IsPlaying()}get isPaused(){return GetTimelineState2(this).IsPaused()}get isReleased(){return map.get(this).IsReleased()}}}{let GetTimelineState2=function(e){const t=map.get(e);if(t.IsReleased())throw new Error("timeline was released and is no longer valid");return t},C33=(GetTimelineState=GetTimelineState2,self.C3),C3X=self.C3X,map=new WeakMap,easeToIndexFunc=null;self.ITimelineState=class extends self.ITimelineStateBase{constructor(e){super(e),map.set(this,e);const t={name:{value:e.GetName(),writable:!1}};Object.defineProperties(this,t)}}}{let GetTweenState2=function(e){const t=map.get(e);if(t.IsReleased())throw new Error("tween was released and is no longer valid");return t},C33=(GetTweenState=GetTweenState2,self.C3),C3X=self.C3X,map=new WeakMap,behInstMap=new WeakMap,easeToIndexFunc=null;self.ITweenState=class extends self.ITimelineStateBase{constructor(e,t,s){super(e),easeToIndexFunc=easeToIndexFunc||s.easeToIndexFunc,map.set(this,e),t&&behInstMap.set(this,t)}stop(){const e=GetTweenState2(this),t=behInstMap.get(this);t.ReleaseTween(e)}setEase(e){C3X.RequireString(e);const t=self.Ease.GetEaseFromIndex(easeToIndexFunc(e));GetTweenState2(this).SetEase(t)}get instance(){const e=GetTweenState2(this).GetInstance();return e?e.GetInterfaceClass():null}get isDestroyOnComplete(){return GetTweenState2(this).GetDestroyInstanceOnComplete()}set isDestroyOnComplete(e){GetTweenState2(this).SetDestroyInstanceOnComplete(!!e)}get value(){const e=GetTweenState2(this);if("value"!==e.GetId())throw new Error("not a value tween");return e.GetPropertyTrack("value").GetSourceAdapterValue()}}}{const C33=self.C3,C3X=self.C3X;self.ISDKPluginBase=class extends self.IPlugin{constructor(){super()}}}{const C33=self.C3,C3X=self.C3X,internalApiToken=C33._GetInternalAPIToken();self.ISDKDOMPluginBase=class extends self.ISDKPluginBase{#private;#domComponentId;#nextElementId=0;#instMap=new Map;constructor(e){if(super(),this.#private=C33.AddonManager._GetInitObject2(internalApiToken),!e?.domComponentId)throw new Error("no DOM component ID specified");this.#domComponentId=e.domComponentId,this._addElementMessageHandler("elem-focused",e=>e._onElemFocused()),this._addElementMessageHandler("elem-blurred",e=>{e&&e._onElemBlurred()})}_addElement(e){const t=this.#nextElementId++;return this.#instMap.set(t,e),t}_removeElement(e){this.#instMap.delete(e)}_addElementMessageHandler(e,s){const t=this.#private.GetRuntime();t.AddDOMComponentMessageHandler(this.#domComponentId,e,e=>{const t=this.#instMap.get(e.elementId);s(t,e)})}_addElementMessageHandlers(e){C3X.RequireArray(e);for(const[t,s]of e)this._addElementMessageHandlers(t,s)}}}{const C33=self.C3,C3X=self.C3X,map=new WeakMap,internalApiToken=C33._GetInternalAPIToken();self.ISDKObjectTypeBase=class extends self.IObjectClass{#private;constructor(){super(),this.#private=C33.AddonManager._GetInitObject2(internalApiToken)}_onCreate(){}getImageInfo(){return this.#private.GetImageInfo().GetIImageInfo()}_loadTextures(e){}_releaseTextures(e){}_onDynamicTextureLoadComplete(){}_preloadTexturesWithInstances(e){}}}{const C33=self.C3,C3X=self.C3X,map=new WeakMap,internalApiToken=C33._GetInternalAPIToken();self.ISDKWorldInstanceBase=class extends self.IWorldInstanceSDKBase{#private;#renderercontextlost_handler=null;#renderercontextrestored_handler=null;constructor(e){super(e),this.#private=C33.AddonManager._GetInitObject2(internalApiToken)}_release(){if(super._release(),this.#renderercontextlost_handler){const e=this.#private.GetRuntime().Dispatcher();e.removeEventListener("renderercontextlost",this.#renderercontextlost_handler),e.removeEventListener("renderercontextrestored",this.#renderercontextrestored_handler),this.#renderercontextlost_handler=null,this.#renderercontextrestored_handler=null}}_handleRendererContextLoss(){if(!this.#renderercontextlost_handler){this.#renderercontextlost_handler=()=>this._onRendererContextLost(),this.#renderercontextrestored_handler=()=>this._onRendererContextRestored();const e=this.#private.GetRuntime().Dispatcher();e.addEventListener("renderercontextlost",this.#renderercontextlost_handler),e.addEventListener("renderercontextrestored",this.#renderercontextrestored_handler)}}_onRendererContextLost(){}_onRendererContextRestored(){}_draw(e){}}}{const C33=self.C3,C3X=self.C3X,tempRect=C33.New(C33.Rect),map=new WeakMap,internalApiToken=C33._GetInternalAPIToken();self.ISDKDOMInstanceBase=class extends self.ISDKWorldInstanceBase{#elementId=-1;#isElementShowing=!0;#elemHasFocus=!1;#autoFontSize=!1;#autoFontSizeOffset=-.2;#lastRect=C33.New(C33.Rect,0,0,-1,-1);#lastWindowWidth=0;#lastWindowHeight=0;#lastHTMLIndex=-1;#lastHTMLZIndex=-1;#isPendingUpdateState=!1;constructor(e){if(!e?.domComponentId)throw new Error("no DOM component ID specified");super(e);const t=C33.AddonManager._GetInitObject2(internalApiToken),s=(map.set(this,t),this.#elementId=this.plugin._addElement(this),t.GetRuntime().GetCanvasManager());this.#lastWindowWidth=s.GetLastWidth(),this.#lastWindowHeight=s.GetLastHeight(),this._setTicking(!0)}_release(){super._release(),this.plugin._removeElement(this.#elementId),this._postToDOMElement("destroy"),this.#elementId=-1,map.delete(this)}_getElementInDOMMode(){const e=map.get(this).GetRuntime();if(e.IsInWorker())throw new Error("not valid in worker mode");return this._postToDOMElementMaybeSync("get-element")}_postToDOMElement(e,t){(t=t||{}).elementId=this.#elementId,this._postToDOM(e,t)}_postToDOMElementMaybeSync(e,t){return(t=t||{}).elementId=this.#elementId,this._postToDOMMaybeSync(e,t)}_postToDOMElementAsync(e,t){return(t=t||{}).elementId=this.#elementId,this._postToDOMAsync(e,t)}_createElement(e){e=e||{};const t=map.get(this).GetWorldInfo();e.elementId=this.#elementId,e.isVisible=t.IsVisible(),e.htmlIndex=t.GetLayer().GetHTMLIndex(),e.htmlZIndex=t.GetHTMLZIndex(),Object.assign(e,this._getElementState()),this.#isElementShowing=!!e.isVisible,this._postToDOMMaybeSync("create",e),this._updatePosition(!0)}setElementVisible(e){this.#isElementShowing!==(e=!!e)&&(this.#isElementShowing=e,this._postToDOMElement("set-visible",{isVisible:e}))}_tick(){this._updatePosition(!1)}_shouldPreserveElement(){const e=map.get(this).GetRuntime(),t=e.GetCanvasManager().GetFullscreenMode();return"Android"===C33.Platform.OS&&("scale-inner"===t||"scale-outer"===t||"crop"===t)}_updatePosition(c){const u=map.get(this);if(!u.IsDestroyed()){let e=u.GetWorldInfo(),t=e.GetLayer(),s=e.GetBoundingBox(),[i,n]=t.LayerToCanvasCss(s.getLeft(),s.getTop()),[r,a]=t.LayerToCanvasCss(s.getRight(),s.getBottom()),o=u.GetRuntime().GetCanvasManager(),l=o.GetCssWidth(),h=o.GetCssHeight();if(e.IsVisible()&&t.IsVisible())if(!this._shouldPreserveElement()&&(r<=0||a<=0||l<=i||h<=n))this.setElementVisible(!1);else{tempRect.set(i,n,r,a);const _=o.GetLastWidth(),d=o.GetLastHeight(),p=t.GetHTMLIndex(),m=e.GetHTMLZIndex();if(!c&&tempRect.equals(this.#lastRect)&&this.#lastWindowWidth===_&&this.#lastWindowHeight===d&&this.#lastHTMLIndex===p&&this.#lastHTMLZIndex===m)this.setElementVisible(!0);else{this.#lastRect.copy(tempRect),this.#lastWindowWidth=_,this.#lastWindowHeight=d,this.#lastHTMLIndex=p,this.#lastHTMLZIndex=m,this.setElementVisible(!0);let e=null;this.#autoFontSize&&(e=t.GetDisplayScale()+this.#autoFontSizeOffset),this._postToDOMElement("update-position",{left:Math.round(this.#lastRect.getLeft()),top:Math.round(this.#lastRect.getTop()),width:Math.round(this.#lastRect.width()),height:Math.round(this.#lastRect.height()),htmlIndex:p,htmlZIndex:m,fontSize:e})}}else this.setElementVisible(!1)}}focusElement(){this._postToDOMElementMaybeSync("focus",{focus:!0})}blurElement(){this._postToDOMElementMaybeSync("focus",{focus:!1})}_onElemFocused(){this.#elemHasFocus=!0}_onElemBlurred(){this.#elemHasFocus=!1}isElementFocused(){return this.#elemHasFocus}setElementCSSStyle(e,t){this.postToDOMElement("set-css-style",{prop:C33.CSSToCamelCase(e),val:t})}setElementAttribute(e,t){this.postToDOMElement("set-attribute",{name:e,val:t})}removeElementAttribute(e){this.postToDOMElement("remove-attribute",{name:e})}_updateElementState(){this.#isPendingUpdateState||(this.#isPendingUpdateState=!0,Promise.resolve().then(()=>{this.#isPendingUpdateState=!1,this._postToDOMElement("update-state",this._getElementState())}))}_getElementState(){}_getElementId(){return this.#elementId}}}{const C33=self.C3,C3X=self.C3X;self.ISDKBehaviorBase=class extends self.IBehavior{constructor(){super()}}}{const C33=self.C3,C3X=self.C3X;self.ISDKBehaviorTypeBase=class extends globalThis.IBehaviorType{constructor(){super()}_onCreate(){}}}{const C33=self.C3,C3X=self.C3X,map=new WeakMap,internalApiToken=C33._GetInternalAPIToken();self.ISDKBehaviorInstanceBase=class extends self.IBehaviorInstance{#isTicking=!1;#isTicking2=!1;#isPostTicking=!1;constructor(){super(),map.set(this,C33.AddonManager._GetInitObject2(internalApiToken))}_release(){super._release(),this._setTicking(!1),this._setTicking2(!1),this._setPostTicking(!1),map.delete(this)}_getInitProperties(){return C33.AddonManager._GetInitProperties()}_postCreate(){}_trigger(e){const t=map.get(this);t.GetRuntime().Trigger(e,t.GetObjectInstance(),t.GetBehaviorType())}_triggerAsync(e){const t=map.get(this);return t.GetRuntime().TriggerAsync(e,t.GetObjectInstance(),t.GetBehaviorType())}_setTicking(e){if(this.#isTicking!==(e=!!e)){this.#isTicking=e;const t=map.get(this).GetRuntime();e?t._AddBehInstToTick(this):t._RemoveBehInstToTick(this)}}_isTicking(){return this.#isTicking}_tick(){}_setTicking2(e){if(this.#isTicking2!==(e=!!e)){this.#isTicking2=e;const t=map.get(this).GetRuntime();e?t._AddBehInstToTick2(this):t._RemoveBehInstToTick2(this)}}_isTicking2(){return this.#isTicking2}_tick2(){}_setPostTicking(e){if(this.#isPostTicking!==(e=!!e)){this.#isPostTicking=e;const t=map.get(this).GetRuntime();e?t._AddBehInstToPostTick(this):t._RemoveBehInstToPostTick(this)}}_isPostTicking(){return this.#isPostTicking}_postTick(){}_getDebuggerProperties(){return[]}_saveToJson(){return null}_loadFromJson(e){}}}{let C33=self.C3,C3X=self.C3X,runtime=null;self.ISDKUtils=class{constructor(e){runtime=e}addLoadPromise(e){runtime.AddLoadPromise(e)}sendWrapperExtensionMessage(e,t,s){C3X.RequireString(e),C3X.RequireString(t),C3X.RequireOptionalArray(s),runtime.SendWrapperExtensionMessage(e,t,s)}sendWrapperExtensionMessageAsync(e,t,s){return C3X.RequireString(e),C3X.RequireString(t),C3X.RequireOptionalArray(s),runtime.SendWrapperExtensionMessageAsync(e,t,s)}createLoopingConditionContext(e){return C3X.RequireOptionalString(e),new self.ILoopingConditionContext(runtime,e)}set isAutoSuspendEnabled(e){runtime._SetAutoSuspendEnabled(!!e)}get isAutoSuspendEnabled(){return runtime._IsAutoSuspendEnabled()}setSuspended(e){runtime.SetSuspended(!!e)}getObjectClassBySid(e){C3X.RequireNumber(e);const t=runtime.GetObjectClassBySID(e);return t?t.GetIObjectClass():null}}}{const C33=self.C3,C3X=self.C3X;self.ILoopingConditionContext=class{#runtime;#currentEvent;#solModifiers;#oldFrame;#newFrame;#loop;constructor(e,t){const s=(this.#runtime=e).GetEventSheetManager(),i=e.GetCurrentEvent(),n=(this.#currentEvent=i,this.#solModifiers=i.GetSolModifiers(),e.GetEventStack()),r=(this.#oldFrame=n.GetCurrentStackFrame(),this.#newFrame=n.Push(i),s.GetLoopStack()),a=r.Push();this.#loop=a,t&&a.SetName(t),e.SetDebuggingEnabled(!1)}retrigger(){const e=this.#runtime.GetEventSheetManager(),t=this.#solModifiers,s=this.#loop;e.PushCopySol(t),this.#currentEvent.Retrigger(this.#oldFrame,this.#newFrame),e.PopSol(t),s.SetIndex(s.GetIndex()+1)}get isStopped(){return this.#loop.IsStopped()}release(){const e=this.#runtime,t=e.GetEventStack(),s=e.GetEventSheetManager().GetLoopStack();e.SetDebuggingEnabled(!0),s.Pop(),t.Pop()}}}{let C33=self.C3,C3X=self.C3X,renderer=null,runtime=null;self.IRenderer=class{constructor(e,t){runtime=e,renderer=t}setAlphaBlendMode(){renderer.SetAlphaBlend()}setBlendMode(e){renderer.SetNamedBlendMode(e)}setColorFillMode(){renderer.SetColorFillMode()}setTextureFillMode(){renderer.SetTextureFillMode()}setSmoothLineFillMode(){renderer.SetSmoothLineFillMode()}setColor(e){renderer.SetColorRgba(e[0],e[1],e[2],e[3])}setColorRgba(e,t,s,i){renderer.SetColorRgba(e,t,s,i)}resetColor(){renderer.ResetColor()}setOpacity(e){renderer.SetOpacity(e)}setCurrentZ(e){renderer.SetCurrentZ(e)}getCurrentZ(){renderer.GetCurrentZ()}rect(e){renderer.Rect2(e.left,e.top,e.right,e.bottom)}rect2(e,t,s,i){renderer.Rect2(e,t,s,i)}quad(e){renderer.Quad(C33.Quad.fromDOMQuad(e))}quad2(e,t,s,i,n,r,a,o){renderer.Quad2(e,t,s,i,n,r,a,o)}quad3(e,t){renderer.Quad3(C33.Quad.fromDOMQuad(e),C33.Rect.fromDOMRect(t))}quad4(e,t){renderer.Quad4(C33.Quad.fromDOMQuad(e),C33.Quad.fromDOMQuad(t))}quad3D(e,t,s,i,n,r,a,o,l,h,c,u,_){renderer.Quad3D(e,t,s,i,n,r,a,o,l,h,c,u,C33.Rect.fromDOMRect(_))}quad3D2(e,t,s,i,n,r,a,o,l,h,c,u,_){renderer.Quad3D2(e,t,s,i,n,r,a,o,l,h,c,u,C33.Quad.fromDOMQuad(_))}drawMesh(e,t,s){renderer.DrawMesh(e,t,s)}convexPoly(e){renderer.ConvexPoly(e)}line(e,t,s,i){renderer.Line(e,t,s,i)}texturedLine(e,t,s,i,n,r){renderer.TexturedLine(e,t,s,i,n,r)}lineRect(e,t,s,i){renderer.LineRect(e,t,s,i)}lineRect2(e){renderer.LineRect2(C33.Rect.fromDOMRect(e))}lineQuad(e){renderer.LineQuad(C33.Quad.fromDOMQuad(e))}pushLineWidth(e){renderer.PushLineWidth(e)}popLineWidth(){renderer.PopLineWidth()}pushLineCap(e){renderer.PushLineCap(e)}popLineCap(){renderer.PopLineCap()}setTexture(e){C3X.RequireOptionalInstanceOf(e,self.ITexture);const t=e?runtime._UnwrapScriptInterface(e):null;renderer.SetTexture(t)}loadTextureForImageInfo(e,t){const s=self.IImageInfo._Unwrap(e);if(s)return s.LoadStaticTexture(renderer,{wrapX:t?.wrapX??"clamp-to-edge",wrapY:t?.wrapY??"clamp-to-edge",sampling:t?.sampling??"trilinear",mipMap:t?.mipMap??!0});throw new Error("invalid IImageInfo")}releaseTextureForImageInfo(e){const t=self.IImageInfo._Unwrap(e);if(!t)throw new Error("invalid IImageInfo");t.ReleaseTexture()}getTextureForImageInfo(e){const t=self.IImageInfo._Unwrap(e);if(!t)throw new Error("invalid IImageInfo");const s=t.GetTexture();return self.ITexture.GetInterface(runtime,s)}createDynamicTexture(e,t,s){C3X.RequireFiniteNumber(e),C3X.RequireFiniteNumber(t);const i=renderer.CreateDynamicTexture(e,t,{wrapX:s?.wrapX??"clamp-to-edge",wrapY:s?.wrapY??"clamp-to-edge",sampling:s?.sampling??"trilinear",mipMap:s?.mipMap??!0});return self.ITexture.GetInterface(runtime,i)}updateTexture(e,t,s){C3X.RequireInstanceOf(t,self.ITexture);const i=runtime._UnwrapScriptInterface(t);renderer.UpdateTexture(e,i,{premultiplyAlpha:s?.premultiplyAlpha??!0})}deleteTexture(e){C3X.RequireInstanceOf(e,self.ITexture);const t=runtime._UnwrapScriptInterface(e);renderer.DeleteTexture(t)}createRendererText(){const e=renderer.CreateRendererText();return new self.IRendererText(runtime,e)}setDeviceTransform(){runtime.GetCanvasManager().SetDeviceTransform(renderer)}setLayerTransform(e){C3X.RequireInstanceOf(e,globalThis.ILayer);const t=runtime._UnwrapScriptInterface(e);t._SetTransform(renderer)}}}{const C33=self.C3,C3X=self.C3X,map=new WeakMap,reverseMap=new WeakMap;self.ITexture=class{constructor(e,t){map.set(this,{runtime:e,texture:t}),reverseMap.set(t,this),e._MapScriptInterface(this,t),Object.defineProperties(this,{width:{value:t.GetWidth(),writable:!1},height:{value:t.GetHeight(),writable:!1}})}static GetInterface(e,t){if(!t)return null;const s=reverseMap.get(t);return s||new self.ITexture(e,t)}}}{let getActual2=function(e){return map.get(e).rendererText};getActual=getActual2;const C33=self.C3,C3X=self.C3X,map=new WeakMap;self.IRendererText=class{constructor(e,t){map.set(this,{runtime:e,rendererText:t}),e._MapScriptInterface(this,t)}release(){getActual2(this).Release()}set fontFace(e){C3X.RequireString(e),getActual2(this).SetFontName(e)}get fontFace(){return getActual2(this).GetFontName()}set sizePt(e){C3X.RequireFiniteNumber(e),getActual2(this).SetFontSize(e)}get sizePt(){return getActual2(this).GetFontSize()}set lineHeight(e){C3X.RequireFiniteNumber(e),getActual2(this).SetLineHeight(e)}get lineHeight(){return getActual2(this).GetLineHeight()}set isBold(e){getActual2(this).SetBold(e)}get isBold(){return getActual2(this).IsBold()}set isItalic(e){getActual2(this).SetItalic(e)}get isItalic(){return getActual2(this).IsItalic()}setColor(e){C3X.RequireArray(e),this.setColorRgb(e[0],e[1],e[2])}setColorRgb(e,t,s){getActual2(this).SetColorRgb(e,t,s)}setCssColor(e){C3X.RequireString(e),getActual2(this).SetColor(e)}set horizontalAlign(e){getActual2(this).SetHorizontalAlignment(e)}get horizontalAlign(){return getActual2(this).GetHorizontalAlignment()}set verticalAlign(e){getActual2(this).SetVerticalAlignment(e)}get verticalAlign(){return getActual2(this).GetVerticalAlignment()}set wordWrapMode(e){getActual2(this).SetWordWrapMode(e)}get wordWrapMode(){return getActual2(this).GetWordWrapMode()}set textDirection(e){getActual2(this).SetTextDirection(e)}get textDirection(){return getActual2(this).GetTextDirection()}set text(e){C3X.RequireString(e),getActual2(this).SetText(e)}get text(){return getActual2(this).GetText()}setSize(e,t,s){C3X.RequireFiniteNumber(e),C3X.RequireFiniteNumber(t),C3X.RequireFiniteNumber(s),getActual2(this).SetSize(e,t,s)}getTexture(){const{runtime:e,rendererText:t}=map.get(this),s=t.GetTexture();return self.ITexture.GetInterface(e,s)}getTexRect(){return getActual2(this).GetTexRect().toDOMRect()}setTextureUpdateCallback(e){C3X.RequireFunction(e),getActual2(this).ontextureupdate=e}releaseTexture(){getActual2(this).ReleaseTexture()}get textWidth(){return getActual2(this).GetTextWidth()}get textHeight(){return getActual2(this).GetTextHeight()}}}{let GetTypeFromFileExtension2=function(e){if(!e)return"";const t=e.split(".");if(t.length<2)return"";const s=t.at(-1).toLowerCase();return EXT_TO_TYPE.get(s)||""},AddScript2=function(i){return new Promise((e,t)=>{const s=document.createElement("script");s.onload=e,s.onerror=t,s.async=!1,s.type="module",s.src=i,document.head.appendChild(s)})};GetTypeFromFileExtension=GetTypeFromFileExtension2,AddScript=AddScript2;const C33=self.C3,VALID_LOAD_POLICIES=new Set(["local","remote"]),EXT_TO_TYPE=new Map([["mp4","video/mp4"],["webm","video/webm"],["m4a","audio/mp4"],["mp3","audio/mpeg"],["js","application/javascript"],["wasm","application/wasm"],["svg","image/svg+xml"],["html","text/html"]]);C33.AssetManager=class extends C33.DefendedBase{constructor(e,t){super();const s=t.exportType,i=(this._runtime=e,this._fileStructure="folders",this._cordovaBlobUrlCache=new Map,this._isCordova="cordova"===s,this._isiOSCordova=!!t.isiOSCordova,this._isFileProtocol=!!t.isFileProtocol,this._swClientId=t.swClientId,this._supportedAudioFormats=t.supportedAudioFormats||{},this._audioFiles=new Map,this._preloadSounds=!1,this._scriptSubfolder=t.scriptFolder,this._mediaSubfolder="",this._fontsSubfolder="",this._iconsSubfolder="",this._fileMap=t.fileMap||new Map,this._fileMapBlobUrls=new Map,"html5"===s||"scirra-arcade"===s||"instant-games"===s);this._defaultLoadPolicy=i?"remote":"local",this._assetsByUrl=new Map,this._webFonts=[],this._loadPromises=[],this._hasFinishedInitialLoad=!1,this._totalAssetSizeToLoad=0,this._assetSizeLoaded=0,this._lastLoadProgress=0,this._hasHadErrorLoading=!1,this._loadingRateLimiter=C33.New(C33.RateLimiter,()=>this._FireLoadingProgressEvent(),50),this._localPromiseThrottle=C33.New(C33.PromiseThrottle,Math.max(C33.hardwareConcurrency,8)),this._remotePromiseThrottle=C33.New(C33.PromiseThrottle,20),this._iAssetManager=new self.IAssetManager(this)}Release(){for(const e of this._assetsByUrl.values())e.Release();this._assetsByUrl.clear(),C33.clearArray(this._loadPromises),this._runtime=null}GetRuntime(){return this._runtime}_SetFileStructure(e){this._fileStructure=e}GetFileStructure(){return this._fileStructure}GetScriptSubfolder(){return this._scriptSubfolder}_SetMediaSubfolder(e){this._mediaSubfolder=e}GetMediaSubfolder(){return this._mediaSubfolder}_SetFontsSubfolder(e){this._fontsSubfolder=e}GetFontsSubfolder(){return this._fontsSubfolder}_SetIconsSubfolder(e){this._iconsSubfolder=e}GetIconsSubfolder(){return this._iconsSubfolder}IsFileProtocol(){return this._isFileProtocol}FetchBlob(e,t){return t=t||this._defaultLoadPolicy,C33.IsRelativeURL(e)?("flat"===this._fileStructure&&(e=e.toLowerCase()),this._isCordova&&this._isFileProtocol?this.CordovaFetchLocalFileAsBlob(e):"playable-ad-single-file"===this._runtime.GetExportType()?self.c3_runtimeInterface._PlayableAdFetchBlob(e):("local"===t?this._localPromiseThrottle:this._remotePromiseThrottle).Add(()=>C33.FetchBlob(e))):C33.FetchBlob(e)}FetchArrayBuffer(e){return C33.IsRelativeURL(e)?("flat"===this._fileStructure&&(e=e.toLowerCase()),this._isCordova&&this._isFileProtocol?this.CordovaFetchLocalFileAsArrayBuffer(e):"playable-ad-single-file"===this._runtime.GetExportType()?C33.BlobToArrayBuffer(self.c3_runtimeInterface._PlayableAdFetchBlob(e)):("local"===this._defaultLoadPolicy?this._localPromiseThrottle:this._remotePromiseThrottle).Add(()=>C33.FetchArrayBuffer(e))):C33.FetchArrayBuffer(e)}FetchText(e){return C33.IsRelativeURL(e)?("flat"===this._fileStructure&&(e=e.toLowerCase()),this._isCordova&&this._isFileProtocol?this.CordovaFetchLocalFileAsText(e):"playable-ad-single-file"===this._runtime.GetExportType()?C33.BlobToString(self.c3_runtimeInterface._PlayableAdFetchBlob(e)):("local"===this._defaultLoadPolicy?this._localPromiseThrottle:this._remotePromiseThrottle).Add(()=>C33.FetchText(e))):C33.FetchText(e)}async FetchJson(e){const t=await this.FetchText(e);return JSON.parse(t)}_CordovaFetchLocalFileAs(e,t){return"flat"===this._fileStructure&&(e=e.toLowerCase()),this._runtime.PostComponentMessageToDOMAsync("runtime","cordova-fetch-local-file",{filename:e,as:t})}CordovaFetchLocalFileAsText(e){return this._CordovaFetchLocalFileAs(e,"text")}async CordovaFetchLocalFileAsBlob(e){const t=await this._CordovaFetchLocalFileAs(e,"buffer"),s=GetTypeFromFileExtension2(e);return new Blob([t],{type:s})}async CordovaFetchLocalFileAsBlobURL(e){"flat"===this._fileStructure&&(e=e.toLowerCase());let t=this._cordovaBlobUrlCache.get(e);if(!t){const s=await this.CordovaFetchLocalFileAsBlob(e);t=URL.createObjectURL(s),this._cordovaBlobUrlCache.set(e,t)}return t}CordovaFetchLocalFileAsArrayBuffer(e){return this._CordovaFetchLocalFileAs(e,"buffer")}GetMediaFileUrl(e){"flat"===this._fileStructure&&(e=e.toLowerCase());let t=this._mediaSubfolder+e;return"Gecko"===C33.Platform.BrowserEngine&&"preview"===this._runtime.GetExportType()?this._GetLocalBlobURLFromFileMap(t):t}GetProjectFileUrl(e){return C33.IsAbsoluteURL(e)?Promise.resolve(e):this._isCordova&&this._isFileProtocol?this.CordovaFetchLocalFileAsBlobURL(e):"playable-ad-single-file"===this._runtime.GetExportType()?URL.createObjectURL(self.c3_runtimeInterface._PlayableAdFetchBlob(e)):("flat"===this._fileStructure&&(e=e.toLowerCase()),Promise.resolve(e))}GetProjectFileIframeUrl(t){if(C33.IsAbsoluteURL(t)||"preview"!==this._runtime.GetExportType()||!this._swClientId||!t)return t;try{const e=new URL(t,location.href);return e.searchParams.set("__c3_client_id",this._swClientId),e.toString()}catch(e){return console.warn("Invalid iframe URL: "+t),t}}LoadProjectFileUrl(e){return this.GetProjectFileUrl(e)}LoadImage(e){if(e.loadPolicy&&!VALID_LOAD_POLICIES.has(e.loadPolicy))throw new Error("invalid load policy");let t=this._assetsByUrl.get(e.url);return t||(t=C33.New(C33.ImageAsset,this,{url:e.url,size:e.size||0,loadPolicy:e.loadPolicy||this._defaultLoadPolicy}),this._assetsByUrl.set(t.GetURL(),t),this._hasFinishedInitialLoad)||(this._totalAssetSizeToLoad+=t.GetSize(),this._loadPromises.push(t.Load().then(()=>this._AddLoadedSize(t.GetSize())))),t}_ReleaseAsset(e){this._assetsByUrl.delete(e.GetURL())}async WaitForAllToLoad(){try{await Promise.all(this._loadPromises),this._lastLoadProgress=1}catch(e){console.error("Error loading: ",e),this._hasHadErrorLoading=!0,this._FireLoadingProgressEvent()}}SetInitialLoadFinished(){this._hasFinishedInitialLoad=!0}HasHadErrorLoading(){return this._hasHadErrorLoading}_AddLoadedSize(e){this._assetSizeLoaded+=e,this._loadingRateLimiter.Call()}_FireLoadingProgressEvent(){const e=C33.New(C33.Event,"loadingprogress");this._lastLoadProgress=C33.clamp(this._assetSizeLoaded/this._totalAssetSizeToLoad,0,1),e.progress=this._lastLoadProgress,this._runtime.Dispatcher().dispatchEvent(e)}GetLoadProgress(){return this._lastLoadProgress}GetImageLoadProgress(){return this._runtime.GetSystemPlugin().GetImageLoadingProgress()}_SetWebFonts(e){C33.shallowAssignArray(this._webFonts,e),this._webFonts.length&&this._loadPromises.push(this._LoadWebFonts())}async _LoadWebFonts(){const e=[],t=[];for(const[s,i,n]of this._webFonts)this._totalAssetSizeToLoad+=n,e.push(this._LoadWebFont(s,i,t).then(()=>this._AddLoadedSize(n)));await Promise.all(e),this._runtime.IsInWorker()&&0<t.length&&await this._runtime.PostComponentMessageToDOMAsync("runtime","load-webfonts",{webfonts:t})}async _LoadWebFont(t,s,i){try{let e=await this.GetProjectFileUrl(s);"Gecko"===C33.Platform.BrowserEngine&&(t=`'${t}'`),("Gecko"===C33.Platform.BrowserEngine&&"preview"===this._runtime.GetExportType()||"playable-ad-single-file"===this._runtime.GetExportType())&&(e=this._GetLocalBlobURLFromFileMap(e));const n=new FontFace(t,`url('${e}')`);(this._runtime.IsInWorker()?self:document).fonts.add(n),await n.load(),this._runtime.IsInWorker()&&i.push({name:t,url:e})}catch(e){console.warn(`[C3 runtime] Failed to load web font '${t}': `,e)}}IsAudioFormatSupported(e){return!!this._supportedAudioFormats[e]}_SetAudioFiles(e,t){this._preloadSounds=!!t;for(const[s,i,n]of e)this._audioFiles.set(s,{fileName:s,formats:i.map(e=>({type:e[0],fileExtension:e[1],fullName:s+e[1],fileSize:e[2]})),isMusic:n})}GetPreferredAudioFile(e){"flat"===this._fileStructure&&(e=e.toLowerCase());const t=this._audioFiles.get(e);if(!t)return null;let s=null;for(const i of t.formats)if(s||"audio/webm; codecs=opus"!==i.type||(s=i),this.IsAudioFormatSupported(i.type))return i;return s}GetProjectAudioFileUrl(e){const t=this.GetPreferredAudioFile(e);return t?{url:this.GetMediaFileUrl(t.fullName),type:t.type}:null}GetAudioToPreload(){if(this._preloadSounds){const e=[];for(const t of this._audioFiles.values())if(!t.isMusic){const s=this.GetPreferredAudioFile(t.fileName);s&&e.push({originalUrl:t.fileName,url:this.GetMediaFileUrl(s.fullName),type:s.type,fileSize:s.fileSize})}return e}return[]}_GetLocalBlobFromFileMap(e){return"preview"===this._runtime.GetExportType()&&(e=new URL(e,location.href).toString()),this._fileMap.get(e)||null}_GetLocalBlobURLFromFileMap(e){let t=this._fileMapBlobUrls.get(e);if(!t){const s=this._GetLocalBlobFromFileMap(e);if(!s)return e;t=URL.createObjectURL(s),this._fileMapBlobUrls.set(e,t)}return t}GetIAssetManager(){return this._iAssetManager}async LoadScripts(...e){const t=await Promise.all(e.map(e=>this.GetProjectFileUrl(e)));if(this._runtime.IsInWorker())if(1===e.length){const s=e[0];await import((C33.IsRelativeURL(s)?"./":"")+s)}else{const i=e.map(e=>`import "${C33.IsRelativeURL(e)?"./":""}${e}";`).join("\n"),n=URL.createObjectURL(new Blob([i],{type:"application/javascript"}));await import(n)}else await Promise.all(t.map(e=>AddScript2(e)))}async CompileWebAssembly(e){if(WebAssembly.compileStreaming){const t=await this.GetProjectFileUrl(e);return WebAssembly.compileStreaming(fetch(t))}{const s=await C33.FetchArrayBuffer(e);return WebAssembly.compile(s)}}async LoadStyleSheet(e){const t=await this.GetProjectFileUrl(e);return this._runtime.PostComponentMessageToDOMAsync("runtime","add-stylesheet",{url:t})}}}{const C33=self.C3;C33.Asset=class extends C33.DefendedBase{constructor(e,t){super(),this._assetManager=e,this._runtime=e.GetRuntime(),this._url=t.url||"",this._size=t.size,this._loadPolicy=t.loadPolicy,this._blob=t.blob||null,this._isLoaded=!!this._blob,this._loadPromise=null}Release(){this._loadPromise=null,this._assetManager=null,this._runtime=null,this._blob=null}GetURL(){return this._url}GetSize(){return this._size}Load(){return"local"===this._loadPolicy||this._blob?(this._isLoaded=!0,Promise.resolve()):(this._loadPromise||(this._loadPromise=this._assetManager.FetchBlob(this._url,this._loadPolicy).then(e=>(this._isLoaded=!0,this._loadPromise=null,this._blob=e)).catch(e=>{console.error("Error loading resource: ",e),this._loadPromise=null})),this._loadPromise)}IsLoaded(){return this._isLoaded}GetBlob(){return this._blob?Promise.resolve(this._blob):this._loadPromise||this._assetManager.FetchBlob(this._url,this._loadPolicy)}}}{const C33=self.C3,promiseThrottle=new C33.PromiseThrottle,allImageAssets=new Set;C33.ImageAsset=class extends C33.Asset{constructor(e,t){super(e,t),this._texturePromise=null,this._webglTexture=null,this._refCount=0,this._imageWidth=-1,this._imageHeight=-1,allImageAssets.add(this)}Release(){if(0!==this._refCount)throw new Error("released image asset which still has texture references");this._assetManager._ReleaseAsset(this),this._texturePromise=null,allImageAssets.delete(this),super.Release()}static OnRendererContextLost(){for(const e of allImageAssets)e._texturePromise=null,e._webglTexture=null,e._refCount=0}LoadStaticTexture(e,t){return t=t||{},this._refCount++,this._webglTexture?Promise.resolve(this._webglTexture):(this._texturePromise||(t.anisotropy=this._runtime.GetCanvasManager().GetTextureAnisotropy(),this._texturePromise=this._DoLoadStaticTexture(e,t)),this._texturePromise)}async _DoLoadStaticTexture(t,s){try{const i=await this.GetBlob();return 0===this._refCount?this._texturePromise=null:await promiseThrottle.Add(async()=>{const e=await t.CreateStaticTextureAsync(i,s);return this._texturePromise=null,0===this._refCount?(t.DeleteTexture(e),null):(this._webglTexture=e,this._imageWidth=e.GetWidth(),this._imageHeight=e.GetHeight(),this._webglTexture)})}catch(e){throw console.error("Failed to load texture: ",e),e}}ReleaseTexture(){if(this._refCount<=0)throw new Error("texture released too many times");if(this._refCount--,0===this._refCount&&this._webglTexture){const e=this._webglTexture.GetRenderer();e.DeleteTexture(this._webglTexture),this._webglTexture=null}}GetRefCount(){return this._refCount}GetTexture(){return this._webglTexture}GetWidth(){return this._imageWidth}GetHeight(){return this._imageHeight}async LoadToDrawable(){const e=await this.GetBlob();return C33.Supports.ImageBitmap?createImageBitmap(e):C33.BlobToImage(e)}}}{let SortByInstLastCachedZIndex2=function(e,t){return e.GetWorldInfo()._GetLastCachedZIndex()-t.GetWorldInfo()._GetLastCachedZIndex()};SortByInstLastCachedZIndex=SortByInstLastCachedZIndex2;const C33=self.C3,assert=self.assert;C33.RenderCell=class extends C33.DefendedBase{constructor(e,t,s){super(),this._grid=e,this._x=t,this._y=s,this._instances=[],this._isSorted=!0,this._pendingRemoval=new Set,this._isAnyPendingRemoval=!1}Release(){C33.clearArray(this._instances),this._pendingRemoval.clear(),this._grid=null}Reset(){C33.clearArray(this._instances),this._isSorted=!0,this._pendingRemoval.clear(),this._isAnyPendingRemoval=!1}SetChanged(){this._isSorted=!1}IsEmpty(){if(this._instances.length){if(this._instances.length>this._pendingRemoval.size)return!1;this._FlushPending()}return!0}Insert(e){this._pendingRemoval.has(e)?(this._pendingRemoval.delete(e),0===this._pendingRemoval.size&&(this._isAnyPendingRemoval=!1)):(this._instances.push(e),this._isSorted=1===this._instances.length)}Remove(e){this._pendingRemoval.add(e),this._isAnyPendingRemoval=!0,50<=this._pendingRemoval.size&&this._FlushPending()}_FlushPending(){this._isAnyPendingRemoval&&(this._instances.length===this._pendingRemoval.size?this.Reset():(C33.arrayRemoveAllInSet(this._instances,this._pendingRemoval),this._pendingRemoval.clear(),this._isAnyPendingRemoval=!1))}_EnsureSorted(){this._isSorted||(this._instances.sort(SortByInstLastCachedZIndex2),this._isSorted=!0)}Dump(e){this._FlushPending(),this._EnsureSorted(),this._instances.length&&e.push(this._instances)}}}{const C33=self.C3;C33.RenderGrid=class extends C33.DefendedBase{constructor(e,t){super(),this._cellWidth=e,this._cellHeight=t,this._cells=C33.New(C33.PairMap)}Release(){this._cells.Release(),this._cells=null}GetCell(e,t,s){let i=this._cells.Get(e,t);return i||(s?(i=C33.New(C33.RenderCell,this,e,t),this._cells.Set(e,t,i),i):null)}XToCell(e){return Math.floor(e/this._cellWidth)}YToCell(e){return Math.floor(e/this._cellHeight)}Update(i,n,r){if(n)for(let s=n.getLeft(),e=n.getRight();s<=e;++s)for(let e=n.getTop(),t=n.getBottom();e<=t;++e)if(!r||!r.containsPoint(s,e)){const a=this.GetCell(s,e,!1);a&&(a.Remove(i),a.IsEmpty())&&this._cells.Delete(s,e)}if(r)for(let s=r.getLeft(),e=r.getRight();s<=e;++s)for(let e=r.getTop(),t=r.getBottom();e<=t;++e)n&&n.containsPoint(s,e)||this.GetCell(s,e,!0).Insert(i)}QueryRange(e,t){let s=this.XToCell(e.getLeft()),i=this.YToCell(e.getTop()),n=this.XToCell(e.getRight()),r=this.YToCell(e.getBottom());for(;s<=n;++s)for(let e=i;e<=r;++e){const a=this.GetCell(s,e,!1);a&&a.Dump(t)}}MarkRangeChanged(e){let t=e.getLeft(),s=e.getTop(),i=e.getRight(),n=e.getBottom();for(;t<=i;++t)for(let e=s;e<=n;++e){const r=this.GetCell(t,e,!1);r&&r.SetChanged()}}}}{let SortByInstLastCachedZIndex2=function(e,t){return e.GetWorldInfo()._GetLastCachedZIndex()-t.GetWorldInfo()._GetLastCachedZIndex()},SortByInstZElevation2=function(e,t){return e.GetWorldInfo().GetZElevation()-t.GetWorldInfo().GetZElevation()};SortByInstLastCachedZIndex=SortByInstLastCachedZIndex2,SortByInstZElevation=SortByInstZElevation2;const C33=self.C3,assert=self.assert,tmpRect=new C33.Rect,tmpQuad=new C33.Quad,renderCellArr=[],tmpDestRect=new C33.Rect,tmpSrcRect=new C33.Rect,glMatrix=self.glMatrix,vec32=glMatrix.vec3,vec42=glMatrix.vec4,mat42=glMatrix.mat4,tempMat4=mat42.create(),tempVec3=vec32.create(),tempVec4=vec42.create(),camVector=vec32.create(),lookVector=vec32.create(),upVector=vec32.create(),tempVec2=C33.New(C33.Vector2),tempRect=C33.New(C33.Rect),tempInstanceList1=[],tempInstanceList2=[],tempInstancesByCameraDist=[],DEFAULT_LAYER_OPTIONS={name:"",sid:-1,isDynamic:!1,isVisible:!0,isInteractive:!0,isHTMLElementsLayer:!1,backgroundColor:[1,1,1,1],isTransparent:!0,parallax:[1,1],opacity:1,isForceOwnTexture:!1,renderAs3d:!1,useCameraDistanceDrawOrder:!1,useRenderCells:!1,scaleRate:1,blendMode:0,zElevation:0,initialInstancesData:[],effectListData:[],subLayersData:[]};C33.Layer=class extends C33.DefendedBase{constructor(e,t,s){super(),s=Object.assign({},DEFAULT_LAYER_OPTIONS,s),this._layout=e,this._runtime=e.GetRuntime(),this._parentLayer=t,this._name=s.name,this._index=-1,this._isHTMLElementsLayer=!!s.isHTMLElementsLayer,this._htmlIndex=-1,this._sid=s.sid,this._isDynamic=!!s.isDynamic,this._isVisible=!!s.isVisible,this._isInteractive=!!s.isInteractive,this._backgroundColor=C33.New(C33.Color),this._backgroundColor.setFromJSON(s.backgroundColor),this._isTransparent=!!s.isTransparent,this._parallaxX=s.parallax[0],this._parallaxY=s.parallax[1],this._color=C33.New(C33.Color,1,1,1,s.opacity),this._premultipliedColor=C33.New(C33.Color),this._isForceOwnTexture=!!s.isForceOwnTexture,this._renderAs3d=!!s.renderAs3d,this._useCameraDistanceDrawOrder=!!s.useCameraDistanceDrawOrder,this._useRenderCells=!!s.useRenderCells,this._scaleRate=s.scaleRate,this._blendMode=s.blendMode,this._curRenderTarget=null,this._scale=1,this._zElevation=s.zElevation,this._angle=0,this._scrollX=0,this._scrollY=0,this._hasOwnScrollPosition=!1,this._viewport=C33.New(C33.Rect),this._viewportZ0=C33.New(C33.Rect),this._viewport3D=C33.New(C33.Rect),this._isViewportChanged=!0,this._projectionMatrix=mat42.create(),this._isProjectionMatrixChanged=!0,this._modelViewMatrix=mat42.create(),this._isMVMatrixChanged=!0,this._viewFrustum=C33.New(C33.Gfx.ViewFrustum),this._isViewFrustumChanged=!0,this._startupInitialInstances=[],this._initialInstancesData=s.initialInstancesData,this._initialInstances=[],this._createdGlobalUids=[],this._initialUIDsToInstanceData=new Map,this._instances=[],this._zIndicesUpToDate=!1,this._htmlZIndicesUpToDate=!1,this._anyInstanceZElevated=!1;const n=this._runtime.GetCanvasManager();this._effectList=C33.New(C33.EffectList,this,s.effectListData),this._effectChain=C33.New(C33.Gfx.EffectChain,n.GetEffectChainManager(),{drawContent:(e,t)=>{const s=t.GetContentObject(),i=s.GetRenderTarget();e.SetColor(s.GetPremultipliedColor()),e.DrawRenderTarget(i),e.InvalidateRenderTarget(i),n.ReleaseAdditionalRenderTarget(i)},getShaderParameters:e=>this.GetEffectList()._GetEffectChainShaderParametersForIndex(e)}),this._needsRebuildEffectChainSteps=!0,this._wasDefaultColor=!0,this._renderGrid=null,this._lastRenderList=[],this._isRenderListUpToDate=!1,this._lastRenderCells=C33.New(C33.Rect,0,0,-1,-1),this._curRenderCells=C33.New(C33.Rect,0,0,-1,-1),this._iLayer=new self.ILayer(this),this._UpdatePremultipliedColor(),this.UsesRenderCells()&&(this._renderGrid=C33.New(C33.RenderGrid,this._runtime.GetOriginalViewportWidth(),this._runtime.GetOriginalViewportHeight())),this._subLayers=s.subLayersData.map(e=>C33.Layer.CreateFromExportData(this._layout,this,e))}_InitInitialInstances(){for(const e of this._initialInstancesData){const t=this._runtime.GetObjectClassByIndex(e[1]);this._layout._AddInitialObjectClass(t),t.GetDefaultInstanceData()||(t.SetDefaultInstanceData(e),t._SetDefaultLayerIndex(this._index)),this._initialInstances.push(e),this._initialUIDsToInstanceData.set(e[2],e)}C33.shallowAssignArray(this._startupInitialInstances,this._initialInstances),this._initialInstancesData=null}static CreateFromExportData(e,t,s){return C33.New(C33.Layer,e,t,{name:s[0],sid:s[2],isVisible:s[3],isInteractive:s[13],isHTMLElementsLayer:s[19],backgroundColor:s[4].map(e=>e/255),isTransparent:s[5],parallax:[s[6],s[7]],opacity:s[8],isForceOwnTexture:s[9],renderAs3d:s[17],useCameraDistanceDrawOrder:s[18],useRenderCells:s[10],scaleRate:s[11],blendMode:s[12],zElevation:s[16],initialInstancesData:s[14],effectListData:s[15],subLayersData:s[20]})}Release(){for(const e of this._subLayers)e.Release();C33.clearArray(this._subLayers);for(const t of this._instances)this._runtime.DestroyInstance(t);C33.clearArray(this._instances),this._effectList.Release(),this._effectList=null,this._effectChain.Release(),this._effectChain=null,this._iLayer=null,this._parentLayer=null,this._layout=null,this._runtime=null}GetInitialInstanceData(e){return this._initialUIDsToInstanceData.get(e)}CreateInitialInstances(n){let r=this._layout.IsFirstVisit(),a=0,o=this._initialInstances;for(let i=0,e=o.length;i<e;++i){let e=o[i],t=this._runtime.GetObjectClassByIndex(e[1]),s=!0;if(!t.HasPersistBehavior()||r){const l=this._runtime.CreateInstanceFromData(e,this,!0);n.push(l),t.IsGlobal()&&(s=!1,this._createdGlobalUids.push(l.GetUID()))}s&&(o[a]=o[i],++a)}C33.truncateArray(o,a),this._runtime.FlushPendingInstances(),this.SetZIndicesChanged()}_AddInstance(e,t){if(!e.GetPlugin().IsWorldType())throw new Error("instance is not of world type");const s=e.GetWorldInfo();if(s.GetLayer()!==this)throw new Error("instance added to wrong layer");this._instances.push(e),0!==s.GetZElevation()&&(this._anyInstanceZElevated=!0),t&&this.UsesRenderCells()&&e.GetWorldInfo().SetBboxChanged(),this.SetZIndicesChanged(e)}_MaybeAddInstance(e){this._instances.includes(e)||(this._instances.push(e),0!==e.GetWorldInfo().GetZElevation()&&(this._anyInstanceZElevated=!0),this.SetZIndicesChanged(e))}_PrependInstance(e,t){const s=e.GetWorldInfo();if(s.GetLayer()!==this)throw new Error("instance added to wrong layer");this._instances.unshift(e),0!==s.GetZElevation()&&(this._anyInstanceZElevated=!0),this.SetZIndicesChanged(e),t&&this.UsesRenderCells()&&e.GetWorldInfo().SetBboxChanged()}_RemoveInstance(e,t){const s=this._instances.indexOf(e);s<0||(t&&this.UsesRenderCells()&&e.GetWorldInfo()._RemoveFromRenderCells(),this._instances.splice(s,1),this.SetZIndicesChanged(e),this._MaybeResetAnyInstanceZElevatedFlag())}_SetAnyInstanceZElevated(){this._anyInstanceZElevated=!0}_MaybeResetAnyInstanceZElevatedFlag(){0===this._instances.length&&(this._anyInstanceZElevated=!1)}_SortInstancesByLastCachedZIndex(e){if(e){const t=new Set;for(const s of this._instances){const i=s.GetWorldInfo()._GetLastCachedZIndex();0<=i&&t.add(i)}let e=-1;for(const n of this._instances){const r=n.GetWorldInfo();if(!(0<=r._GetLastCachedZIndex())){for(++e;t.has(e);)++e;r._SetZIndex(e)}}}this._instances.sort(SortByInstLastCachedZIndex2)}_Start(){}_End(){for(const e of this._instances)e.GetObjectClass().IsGlobal()||this._runtime.DestroyInstance(e);this._runtime.FlushPendingInstances(),C33.clearArray(this._instances),this._anyInstanceZElevated=!1,this.SetZIndicesChanged()}RecreateInitialObjects(t,e,s,i,n,r){const a=this._runtime.GetEventSheetManager(),o=this._runtime.GetAllObjectClasses(),l=t.IsFamily(),h=[];for(const c of this._initialInstances){const u=c[0],_=u[0],d=u[1];if(e.containsPoint(_,d)){const p=o[c[1]];if(p!==t){if(!l)continue;if(!t.FamilyHasMember(p))continue}let e=n;if(!e){const f=this._runtime.GetCurrentLayout();e=this.GetLayout()===f?this:(e=f.GetLayerByName(this.GetName()))||f.GetLayerByIndex(this.GetIndex())}const m=this._runtime.CreateInstanceFromData(c,e,!1,void 0,void 0,!1,r),g=(e.SortAndAddInstancesByZIndex(m),m.GetWorldInfo());g.OffsetXY(s,i),g.SetBboxChanged(),a.BlockFlushingInstances(!0),m._TriggerOnCreatedOnSelfAndRelated(),a.BlockFlushingInstances(!1),h.push(m)}}return h}GetInstanceCount(){return this._instances.length}GetLayout(){return this._layout}GetName(){return this._name}_SetIndex(e){this._index=e}GetIndex(){return this._index}_SetHTMLIndex(e){this._htmlIndex=e}GetHTMLIndex(){return this._htmlIndex}IsHTMLElementsLayer(){return this._isHTMLElementsLayer}SetIsHTMLElementsLayer(e){this._isHTMLElementsLayer!==(e=!!e)&&(this._isHTMLElementsLayer=e,this._layout._ReindexAndUpdateAllLayers(),this._runtime.UpdateRender())}_GetSiblingIndex(){let e=this.GetParentLayer();return(e?e.GetSubLayers():this.GetLayout()._GetRootLayers()).indexOf(this)}GetSID(){return this._sid}GetRuntime(){return this._runtime}IsDynamic(){return this._isDynamic}HasAnyDynamicParentLayer(){for(const e of this.parentLayers())if(e.IsDynamic())return!0;return!1}GetDevicePixelRatio(){return this._runtime.GetDevicePixelRatio()}GetEffectList(){return this._effectList}GetEffectChain(){return this._MaybeRebuildEffectChainSteps(),this._effectChain}_MaybeRebuildEffectChainSteps(){const e=this.HasDefaultColor();if(this._needsRebuildEffectChainSteps||e!==this._wasDefaultColor||this._effectChain.NeedsRebuild()){const t=this.GetEffectList().GetActiveEffectTypes();this._effectChain.BuildSteps(t.map(e=>e.GetShaderProgram()),{indexMap:t.map(e=>e.GetIndex()),forcePreDraw:!e,useFullSurface:!0}),this._needsRebuildEffectChainSteps=!1,this._wasDefaultColor=e}}UpdateActiveEffects(){this.GetEffectList().UpdateActiveEffects(),this._needsRebuildEffectChainSteps=!0}UsesRenderCells(){return this._useRenderCells&&!this._useCameraDistanceDrawOrder}GetRenderGrid(){return this._renderGrid}SetRenderListStale(){this._isRenderListUpToDate=!1}IsVisible(){for(const e of this.selfAndParentLayers())if(!e._IsVisibleFlagSet())return!1;return!0}_IsVisibleFlagSet(){return this._isVisible}SetVisible(e){this._isVisible!==(e=!!e)&&(this._isVisible=e,this._runtime.UpdateRender())}SetInteractive(e){this._isInteractive=!!e}IsInteractive(){return this._isInteractive}IsSelfAndParentsInteractive(){for(const e of this.selfAndParentLayers())if(!e.IsInteractive())return!1;return!0}SetOwnScrollPositionEnabled(e){if(this._hasOwnScrollPosition!==(e=!!e)){if(this._hasOwnScrollPosition=e){const t=this.GetLayout();this._scrollX=t.GetScrollX(),this._scrollY=t.GetScrollY()}this._SetMVMatrixChanged(),this._runtime.UpdateRender()}}IsOwnScrollPositionEnabled(){return this._hasOwnScrollPosition}SetScrollX(e){const t=this.GetLayout(),s=t.GetScrollLeftBound(),i=t.GetScrollRightBound();this._scrollX!==(e=(e=i<e?i:e)<s?s:e)&&(this._scrollX=e,this.IsOwnScrollPositionEnabled())&&(this._SetMVMatrixChanged(),this._runtime.UpdateRender())}SetScrollY(e){const t=this.GetLayout(),s=t.GetScrollTopBound(),i=t.GetScrollBottomBound();this._scrollY!==(e=(e=i<e?i:e)<s?s:e)&&(this._scrollY=e,this.IsOwnScrollPositionEnabled())&&(this._SetMVMatrixChanged(),this._runtime.UpdateRender())}GetScrollX(){return this.IsOwnScrollPositionEnabled()?this._scrollX:this.GetLayout().GetScrollX()}GetScrollY(){return this.IsOwnScrollPositionEnabled()?this._scrollY:this.GetLayout().GetScrollY()}GetViewport(){return this._MaybeUpdateViewport(),this._viewport}_GetViewportZ0(){return this._MaybeUpdateViewport(),this._viewportZ0}GetViewport3D(){return this._MaybeUpdateViewport(),this._viewport3D}_GetVanishingPoint(){const e=this.GetLayout();return[e.GetVanishingPointX(),e.GetVanishingPointY()]}GetDefaultCameraZ(e){return this._runtime.GetDefaultCameraZ(e)}GetViewportForZ(u,i){const n=this._GetViewportZ0();if(0===u)i.copy(n);else{let o=n.midX(),l=n.midY(),e=this.Get2DScaleFactorToZ(u),t=n.width()/e,s=n.height()/e,[h,c]=this._GetVanishingPoint();if(.5!==h||.5!==c){let e=this.Get2DCameraZ(),t=this._runtime,s=this.GetDefaultCameraZ()/e,i=(h-.5)*t.GetViewportWidth()/s,n=(c-.5)*t.GetViewportHeight()/s,r=this.GetAngle(),a=(0!==r&&(tempVec2.set(i,n),tempVec2.rotate(r),i=tempVec2.getX(),n=tempVec2.getY()),C33.unlerp(e,0,u));o+=C33.lerp(i,0,a),l+=C33.lerp(n,0,a)}i.set(o-t/2,l-s/2,o+t/2,l+s/2)}}GetOpacity(){return this._color.getA()}SetOpacity(e){e=C33.clamp(e,0,1),this._color.getA()!==e&&(this._color.setA(e),this._UpdatePremultipliedColor(),this._runtime.UpdateRender())}_UpdatePremultipliedColor(){this._premultipliedColor.copy(this._color),this._premultipliedColor.premultiply()}GetPremultipliedColor(){return this._premultipliedColor}HasDefaultColor(){return this._color.equalsRgba(1,1,1,1)}GetScaleRate(){return this._scaleRate}SetScaleRate(e){this._scaleRate!==e&&(this._scaleRate=e,this._SetMVMatrixChanged(),this._runtime.UpdateRender())}GetParallaxX(){return this._parallaxX}GetParallaxY(){return this._parallaxY}SetParallax(e,t){this._parallaxX===e&&this._parallaxY===t||(this._parallaxX=e,this._parallaxY=t,this._SetMVMatrixChanged(),this._runtime.UpdateRender())}SetParallaxX(e){this.SetParallax(e,this.GetParallaxY())}SetParallaxY(e){this.SetParallax(this.GetParallaxX(),e)}SetZElevation(e){this._zElevation!==e&&(this._zElevation=e,this._runtime.UpdateRender())}GetZElevation(){return this._zElevation}SetAngle(e){e=C33.clampAngle(e),this._angle!==e&&(this._angle=e,this._SetMVMatrixChanged(),this._runtime.UpdateRender())}GetAngle(){return C33.clampAngle(this._layout.GetAngle()+this._angle)}GetOwnAngle(){return this._angle}HasInstances(){return 0<this._instances.length}_GetInstances(){return this._instances}_GetInstancesInDrawOrder(){return this.RendersIn3DMode()&&this._useCameraDistanceDrawOrder?(C33.shallowAssignArray(tempInstancesByCameraDist,this._GetInstances()),tempInstancesByCameraDist.sort((e,t)=>this._SortInstancesByCameraDistance(e,t)),tempInstancesByCameraDist):this._GetInstances()}_AppendAllInstancesIncludingSubLayersInDrawOrder(e){C33.appendArray(e,this._GetInstancesInDrawOrder());for(const t of this._subLayers)t.IsVisible()&&0<t.GetOpacity()&&t._AppendAllInstancesIncludingSubLayersInDrawOrder(e)}_SortInstancesByCameraDistance(e,t){const s=this.GetLayout().Get3DCameraPosition(),i=s[0],n=s[1],r=s[2],a=e.GetWorldInfo(),o=t.GetWorldInfo(),l=a.GetX()-i,h=a.GetY()-n,c=a.GetZElevation()-r,u=o.GetX()-i,_=o.GetY()-n,d=o.GetZElevation()-r;return u*u+_*_+d*d-(l*l+h*h+c*c)}GetBackgroundColor(){return this._backgroundColor}IsTransparent(){return this._isTransparent}SetTransparent(e){this._isTransparent!==(e=!!e)&&(this._isTransparent=e,this._runtime.UpdateRender())}IsForceOwnTexture(){return this._isForceOwnTexture}SetForceOwnTexture(e){this._isForceOwnTexture!==(e=!!e)&&(this._isForceOwnTexture=e,this._runtime.UpdateRender())}RendersIn2DMode(){return!this.GetRuntime().Uses3DFeatures()||!this._renderAs3d}RendersIn3DMode(){return!this.RendersIn2DMode()}Has3DCamera(){return this.RendersIn3DMode()&&this.GetLayout().Is3DCameraEnabled()}SelfAndAllSubLayersHave3DCamera(){if(!this.Has3DCamera())return!1;for(const e of this._subLayers)if(!e.SelfAndAllSubLayersHave3DCamera())return!1;return!0}SetBlendMode(e){this._blendMode!==e&&(this._blendMode=e,this._runtime.UpdateRender())}GetBlendMode(){return this._blendMode}IsRootLayer(){return!this._parentLayer}GetParentLayer(){return this._parentLayer}_SetParentLayer(e){this._parentLayer=e}GetSubLayers(){return this._subLayers}HasAnySubLayers(){return 0<this._subLayers.length}_AddSubLayer(e,t=!0){t?this._subLayers.push(e):this._subLayers.unshift(e)}_InsertSubLayer(e,t,s){let i=this._subLayers.indexOf(t);if(-1===i)throw new Error("cannot find layer to insert by");s&&++i,this._subLayers.splice(i,0,e)}_RemoveSubLayer(e){const t=this._subLayers.indexOf(e);if(-1===t)throw new Error("cannot find layer to remove");this._subLayers.splice(t,1)}HasAnyVisibleSubLayer(){for(const e of this._subLayers)if(e.ShouldDraw())return!0;return!1}*selfAndAllSubLayers(){for(const e of this._subLayers)yield*e.selfAndAllSubLayers();yield this}*parentLayers(){let e=this.GetParentLayer();for(;e;)yield e,e=e.GetParentLayer()}*selfAndParentLayers(){yield this,yield*this.parentLayers()}HasParentLayer(e){for(const t of this.parentLayers())if(t===e)return!0;return!1}IsTransformCompatibleWith(e){return this===e||this._parallaxX===e._parallaxX&&this._parallaxY===e._parallaxY&&this._scale===e._scale&&this._scaleRate===e._scaleRate&&this._angle===e._angle&&this.GetScrollX()===e.GetScrollX()&&this.GetScrollY()===e.GetScrollY()}SaveTransform(){return{parallaxX:this.GetParallaxX(),parallaxY:this.GetParallaxY(),scale:this.GetOwnScale(),scaleRate:this.GetScaleRate(),angle:this.GetOwnAngle(),hasOwnScroll:this.IsOwnScrollPositionEnabled(),scrollX:this.GetScrollX(),scrollY:this.GetScrollY()}}RestoreTransform(e){this.SetParallax(e.parallaxX,e.parallaxY),this.SetOwnScale(e.scale),this.SetScaleRate(e.scaleRate),this.SetAngle(e.angle),this.SetOwnScrollPositionEnabled(e.hasOwnScroll),this.SetScrollX(e.scrollX),this.SetScrollY(e.scrollY),this._MaybeUpdateViewport()}_RemoveAllInstancesInSet(e){if(0!==e.size){const t=C33.arrayRemoveAllInSet(this._instances,e);0<t&&(this._MaybeResetAnyInstanceZElevatedFlag(),this.SetZIndicesChanged())}}SetZIndicesChanged(e){this._zIndicesUpToDate=!1,this._isRenderListUpToDate=!1,e&&!e.GetObjectClass().GetPlugin().IsHTMLElementType()||(this._htmlZIndicesUpToDate=!1)}_UpdateZIndices(){if(!this._zIndicesUpToDate){if(this._instances.sort(SortByInstZElevation2),this.UsesRenderCells())for(let e=0,t=this._instances.length;e<t;++e){const s=this._instances[e].GetWorldInfo();s._SetZIndex(e),this._renderGrid.MarkRangeChanged(s.GetRenderCellRange())}else for(let e=0,t=this._instances.length;e<t;++e)this._instances[e].GetWorldInfo()._SetZIndex(e);this._zIndicesUpToDate=!0}}_UpdateHTMLZIndices(){if(!this._htmlZIndicesUpToDate){let e=this._layout.GetRootLayersForHTMLLayer(this.GetHTMLIndex()),t=e.map(e=>[...e.selfAndAllSubLayers()]).flat(),s=0;for(const i of t){for(const n of i._GetInstances())n.GetObjectClass().GetPlugin().IsHTMLElementType()&&n.GetWorldInfo()._SetHTMLZIndex(s++);i._SetHTMLZIndicesUpToDate()}}}_SetHTMLZIndicesUpToDate(){this._htmlZIndicesUpToDate=!0}_GetHTMLLayerDOMState(){return{isVisible:this.IsVisible(),opacity:this.GetOpacity(),isInteractive:this.IsInteractive()}}MoveInstanceAdjacent(e,t,s){const i=e.GetWorldInfo(),n=t.GetWorldInfo();if(i.GetLayer()!==this||n.GetLayer()!==this)throw new Error("can't arrange Z order unless both objects on this layer");let r=i.GetZIndex(),a=n.GetZIndex();return r!==a+(s?1:-1)&&(C33.arrayRemove(this._instances,r),r<a&&a--,s&&a++,a===this._instances.length?this._instances.push(e):this._instances.splice(a,0,e),this.SetZIndicesChanged(e),!0)}_MergeSortedZArrays(e,t){let s=[],i=0,n=0,r=e.length,a=t.length;for(;i<r&&n<a;){const o=e[i],l=t[n];o.GetWorldInfo()._GetLastCachedZIndex()<l.GetWorldInfo()._GetLastCachedZIndex()?(s.push(o),++i):(s.push(l),++n)}for(;i<r;++i)s.push(e[i]);for(;n<a;++n)s.push(t[n]);return s}_MergeAllSortedZArrays_pass(t){const s=[],i=t.length;for(let e=0;e<i-1;e+=2){const n=t[e],r=t[e+1];s.push(this._MergeSortedZArrays(n,r))}return i%2==1&&s.push(t[i-1]),s}_MergeAllSortedZArrays(e){for(;1<e.length;)e=this._MergeAllSortedZArrays_pass(e);return e[0]}_GetRenderCellInstancesToDraw(){return this._UpdateZIndices(),C33.clearArray(renderCellArr),this._renderGrid.QueryRange(this.GetViewport(),renderCellArr),renderCellArr.length?1===renderCellArr.length?renderCellArr[0]:this._MergeAllSortedZArrays(renderCellArr):[]}ShouldDraw(){return this.IsVisible()&&0<this.GetOpacity()&&this._DrawsAnyContentInSelfOrSubLayers()}_DrawsAnyContentInSelfOrSubLayers(){if(this.HasInstances()||!this.IsTransparent())return!0;for(const e of this._subLayers)if(e._DrawsAnyContentInSelfOrSubLayers())return!0;return!1}UsesOwnTexture(){return this.IsForceOwnTexture()||!this.HasDefaultColor()||0!==this.GetBlendMode()||this._effectList.HasAnyActiveEffect()}SelfOrAnySubLayerUsesOwnTexture(){if(this.UsesOwnTexture())return!0;for(const e of this._subLayers)if(e.SelfOrAnySubLayerUsesOwnTexture())return!0;return!1}GetRenderTarget(){return this._curRenderTarget}Get2DScaleFactorToZ(e){if(this._layout.IsOrthographicProjection())return 1;{const t=this.Get3DCameraZ();return t/(t-e)}}GetResolutionScaleFactorToZ(e){const t=this._runtime.GetRenderScale();if(this._layout.IsOrthographicProjection())return t;{const s=this.Get3DCameraZ(),i=this.GetDefaultCameraZ();return i/Math.abs(s-e)*t}}_SetMVMatrixChanged(){this._isMVMatrixChanged=!0,this._isViewFrustumChanged=!0,this._isViewportChanged=!0}_GetModelViewMatrix(e){return this._isMVMatrixChanged&&(this._CalculateModelViewMatrix(e,this._modelViewMatrix,0,0,null),this._isMVMatrixChanged=!1),this._modelViewMatrix}Get2DCameraZ(e){return this.GetDefaultCameraZ(e)/this.GetNormalScale()}Get3DCameraZ(){return this.Has3DCamera()?this.GetLayout().Get3DCameraPosition()[2]:this.Get2DCameraZ()}GetCameraPosition(){if(this.Has3DCamera()){const e=this.GetLayout().Get3DCameraPosition();return[e[0],e[1],e[2]]}return this._Get2DCameraPosition()}_Get2DCameraPosition(e=0,t=0,n=0){let r=this._runtime,s=this.GetLayout(),i=r.GetParallaxXOrigin(),a=r.GetParallaxYOrigin(),o=(this.GetScrollX()-i)*this._parallaxX+i,l=(this.GetScrollY()-a)*this._parallaxY+a,h=(r.IsPixelRoundingEnabled()&&(o=Math.round(o),l=Math.round(l)),o+e),c=l+t,u=s.IsOrthographicProjection()?this.GetDefaultCameraZ(n):this.Get2DCameraZ(n),[_,d]=this._GetVanishingPoint();if(.5!==_||.5!==d){let e=this.GetDefaultCameraZ(n)/u,t=(_-.5)*r.GetViewportWidth()/e,s=(d-.5)*r.GetViewportHeight()/e,i=this.GetAngle();0!==i&&(tempVec2.set(t,s),tempVec2.rotate(i),t=tempVec2.getX(),s=tempVec2.getY()),h+=t,c+=s}return[h,c,u]}_CalculateModelViewMatrix(e,t,s,i,n){const r=this._runtime,a=this.GetLayout();if(this.Has3DCamera()){vec32.copy(camVector,a.Get3DCameraPosition()),vec32.copy(lookVector,a.Get3DCameraLookAt()),vec32.copy(upVector,a.Get3DCameraUpVector());const o=r.GetParallaxXOrigin(),l=r.GetParallaxYOrigin(),h=lookVector[0]-camVector[0],c=lookVector[1]-camVector[1],u=lookVector[2]-camVector[2];camVector[0]=(camVector[0]-o)*this._parallaxX+o,camVector[1]=(camVector[1]-l)*this._parallaxY+l,camVector[2]*=Math.max(this._parallaxX,this._parallaxY),lookVector[0]=camVector[0]+h,lookVector[1]=camVector[1]+c,lookVector[2]=camVector[2]+u}else{const[_,d,p]=this._Get2DCameraPosition(s,i,n),m=(vec32.set(camVector,_,d,p),vec32.set(lookVector,_,d,p-100),this.GetAngle());0===m?vec32.set(upVector,0,1,0):vec32.set(upVector,Math.sin(m),Math.cos(m),0)}e.CalculateLookAtModelView(t,camVector,lookVector,upVector,n||r.GetViewportHeight())}_SetProjectionMatrixChanged(){this._isProjectionMatrixChanged=!0,this._isViewFrustumChanged=!0,this._isViewportChanged=!0}_GetProjectionMatrix(e){return this._isProjectionMatrixChanged&&(this._CalculateProjectionMatrix(e),this._isProjectionMatrixChanged=!1),this._projectionMatrix}_CalculateProjectionMatrix(e){const t=this._runtime.GetCanvasManager(),[s,i]=this._GetVanishingPoint();if(this._layout.IsOrthographicProjection())e.CalculateOrthographicMatrix(this._projectionMatrix,t.GetDrawWidth(),t.GetDrawHeight());else if(.5===s&&.5===i)mat42.copy(this._projectionMatrix,t.GetDefaultProjectionMatrix());else{const n=t.GetDrawWidth(),r=t.GetDrawHeight();e.CalculatePerspectiveMatrix(this._projectionMatrix,n/r,s,i)}}_SetTransform(e,t=!0,s=0,i=0,n=0){t&&e.SetProjectionMatrix(this._GetProjectionMatrix(e));let r;r=0===s&&0===i&&0===n?this._GetModelViewMatrix(e):(this._CalculateModelViewMatrix(e,tempMat4,s,i,n),tempMat4),e.SetModelViewMatrix(r)}PrepareForDraw(e){this._SetTransform(e),e.SetBaseZ(this.GetZElevation())}_MaybeStartWebGLProfiling(e){let t=null;if(e.IsWebGL()&&this._runtime.IsGPUProfiling()){const s=this._runtime.GetCanvasManager().GetLayerTimingsBuffer(this);s&&(t=s.AddTimeElapsedQuery(),e.StartQuery(t))}return t}_MaybeStartWebGPUProfiling(e){if(e.IsWebGPU()&&this._runtime.IsGPUProfiling()){const t=2*(this.GetIndex()+1);e.StartMeasuringRenderPassTime(t,1+t)}}Draw(e,t,s){let i=this._runtime.GetCanvasManager(),n=this.UsesOwnTexture(),r=null,a=this._MaybeStartWebGLProfiling(e);if(this._MaybeStartWebGPUProfiling(e),n){const o={sampling:this._runtime.GetSampling(),isSampled:!0,canReadPixels:!!e.IsWebGPU()&&this._runtime.UsesAnyBackgroundBlending()};"low"===i.GetCurrentFullscreenScalingQuality()&&(o.width=i.GetDrawWidth(),o.height=i.GetDrawHeight()),r=this._runtime.GetAdditionalRenderTarget(o),this._curRenderTarget=r,e.SetRenderTarget(r),this.IsTransparent()&&e.ClearRgba(0,0,0,0)}else this._curRenderTarget=t,e.SetRenderTarget(t);if(this.IsTransparent()||e.Clear(this._backgroundColor),this._layout._DrawLayerList(e,this._curRenderTarget,this._subLayers,n&&this.IsTransparent()),this._MaybeStartWebGPUProfiling(e),this._SetTransform(e),e.SetBaseZ(this.GetZElevation()),e.SetDepthEnabled(this.RendersIn3DMode()),this.GetNormalScale()>Number.EPSILON){this._UpdateZIndices();const l=this.UsesRenderCells()&&0===this.GetZElevation()&&!this._anyInstanceZElevated;this.Has3DCamera()?this._DrawInstances_3DCamera(e):l?this._DrawInstances_RenderCells(e):this._DrawInstances(e,this._GetInstancesInDrawOrder())}e.SetBaseZ(0),e.SetCurrentZ(0),n&&(e.SetDepthEnabled(!1),this._DrawLayerOwnTextureToRenderTarget(e,r,t,s)),a&&e.EndQuery(a),this._curRenderTarget=null}_DrawInstances(s,i){let n=this.GetViewport(),r=this._curRenderTarget,a=this.GetLayout().IsOrthographicProjection(),o=this.GetLayout().HasVanishingPointOutsideViewport(),l=null;for(let e=0,t=i.length;e<t;++e){const h=i[e];if(h!==l){const c=(l=h).GetWorldInfo();c.IsVisible()&&c.IsInViewport(n,o,a)&&this._DrawInstanceMaybeWithEffects(h,c,s,r)}}}_DrawInstances_3DCamera(i){const n=this._curRenderTarget,r=this._GetViewFrustum(),a=tempInstanceList1,o=tempInstanceList2,l=this._GetInstancesInDrawOrder();for(let t=0,s=l.length;t<s;){const h=l[t],c=h.GetWorldInfo();if(c.IsVisible()&&c.IsInViewport3D(r)){(!h.RendersToOwnZPlane()||0<c.GetDepth())&&o.push(h);const u=h.GetWorldInfo().GetTotalZElevation();a.push(h);let e=t+1;for(;e<s;++e){const _=l[e],d=_.GetWorldInfo();if(d.IsVisible()&&d.IsInViewport3D(r)){if(d.GetTotalZElevation()!==u)break;(_.RendersToOwnZPlane()?(0<d.GetDepth()&&o.push(_),a):o).push(_)}}if(1!==a.length||a[0].MustMitigateZFighting()){this._DrawCoplanarInstances_3DCamera(i,a);for(let e=0,t=o.length;e<t;++e){const p=o[e],m=p.GetWorldInfo();m._SetDrawNonBackFacesOnly(!0),this._DrawInstanceMaybeWithEffects(p,m,i,n),m._SetDrawNonBackFacesOnly(!1)}}else{this._DrawInstanceMaybeWithEffects(h,c,i,n);for(let e=0,t=o.length;e<t;++e){const g=o[e];if(g!==h){const f=g.GetWorldInfo(),S=f.GetLayer();S._DrawInstanceMaybeWithEffects(g,f,i,n)}}}t=e,C33.clearArray(a),C33.clearArray(o)}else++t}}_DrawCoplanarInstances_3DCamera(s,i){const n=this._curRenderTarget;s.CoplanarStartStencilPass();for(let e=0,t=i.length;e<t;++e){const r=i[e],a=r.GetWorldInfo();a._SetDrawBackFaceOnly(!0),this._DrawInstance(r,a,s)}s.CoplanarStartColorPass();for(let e=0,t=i.length;e<t;++e){const o=i[e],l=o.GetWorldInfo();this._DrawInstanceMaybeWithEffects(o,l,s,n),l._SetDrawBackFaceOnly(!1)}s.CoplanarRestoreStandardRendering()}_DrawInstances_RenderCells(e){let t=this._renderGrid,s=this._curRenderCells,i=this._lastRenderCells,n=this.GetViewport(),r;s.set(t.XToCell(n.getLeft()),t.YToCell(n.getTop()),t.XToCell(n.getRight()),t.YToCell(n.getBottom())),this._isRenderListUpToDate&&s.equals(i)?r=this._lastRenderList:(r=this._GetRenderCellInstancesToDraw(),this._isRenderListUpToDate=!0,i.copy(s)),this._DrawInstances(e,r),r!==this._lastRenderList&&C33.shallowAssignArray(this._lastRenderList,r)}_DrawInstanceMaybeWithEffects(e,t,s,i){t.HasAnyActiveEffect()?this._DrawInstanceWithEffectsAndRestore(e,t,s,i):this._DrawInstance(e,t,s)}_DrawInstance(e,t,s){const i=t.GetRendererStateGroup();s.GetCurrentStateGroup()!==i&&i.Apply(),e.Draw(s)}_DrawInstanceWithEffectsAndRestore(e,t,s,i){this._DrawInstanceWithEffects(e,t,s,i,null)&&this._SetTransform(s)}_DrawInstanceWithEffects(e,t,s,i,n){const r=t.GetInstanceEffectList().GetEffectChain();return r.Render(s,i,{contentObject:e,blendMode:t.GetBlendMode(),devicePixelRatio:this._runtime.GetEffectDevicePixelRatioParam(),time:e.GetInstanceGameTime(),layerScale:this._runtime.GetEffectLayerScaleParam()*this.GetNormalScale(),layerAngle:this.GetAngle(),layoutRect:t.GetBoundingBox(),drawSurfaceRect:r.CanSkipCalculatingDrawSurfaceRect()?null:this._InstanceBoxToDrawSurface(t),drawContentHook:n&&n.drawContentHook,compositOffX:n&&n.compositOffX,compositOffY:n&&n.compositOffY,updateOwnProjection:n&&n.updateOwnProjection}),s.SetBaseZ(this.GetZElevation()),r.DidChangeTransform()}_DrawLayerOwnTextureToRenderTarget(e,t,s,i){const n=this._effectList.GetActiveEffectTypes(),r=this._runtime;0===n.length?(e.SetRenderTarget(s),e.SetTextureFillMode(),i&&0===this._blendMode&&this.HasDefaultColor()?e.CopyRenderTarget(t):(e.SetBlendMode(this._blendMode),e.SetColor(this._premultipliedColor),e.DrawRenderTarget(t)),e.InvalidateRenderTarget(t),r.ReleaseAdditionalRenderTarget(t)):this.GetEffectChain().Render(e,s,{contentObject:this,blendMode:this.GetBlendMode(),devicePixelRatio:r.GetEffectDevicePixelRatioParam(),layerScale:r.GetEffectLayerScaleParam()*this.GetNormalScale(),layerAngle:this.GetAngle(),layoutRect:this.GetViewport(),drawSurfaceRect:null,invalidateRenderTargets:!0})}GetOwnScale(){return this._scale}SetOwnScale(e){this._scale!==e&&(this._scale=e,this._layout.BoundScrolling(),this._SetMVMatrixChanged(),this._runtime.UpdateRender())}GetRenderScale(){return this.GetNormalScale()*this._runtime.GetRenderScale()}GetDisplayScale(){return this.GetNormalScale()*this._runtime.GetDisplayScale()}GetNormalScale(){return(this._scale*this._layout.GetScale()-1)*this._scaleRate+1}_MaybeUpdateViewport(){if(this._isViewportChanged){this._isViewportChanged=!1;let e=this._runtime.GetParallaxXOrigin(),t=this._runtime.GetParallaxYOrigin(),s=(this.GetScrollX()-e)*this._parallaxX+e,i=(this.GetScrollY()-t)*this._parallaxY+t,n=this.GetNormalScale(),r=this._runtime.GetViewportWidth()/n,a=this._runtime.GetViewportHeight()/n,o=s-r/2,l=i-a/2;this._runtime.IsPixelRoundingEnabled()&&(o=Math.round(o),l=Math.round(l));const h=this._viewportZ0,c=(h.set(o,l,o+r,l+a),this.GetAngle()),u=(0!==c&&(tmpRect.copy(h),tmpRect.offset(-h.midX(),-h.midY()),tmpQuad.setFromRotatedRect(tmpRect,c),tmpQuad.getBoundingBox(tmpRect),tmpRect.offset(h.midX(),h.midY()),h.copy(tmpRect)),this._zElevation);this.GetViewportForZ(u,this._viewport),this.Has3DCamera()?this.CalculateViewport3D(u,this._viewport3D):this._viewport3D.copy(this._viewport)}}CalculateViewport3D(e,t){let s=this._runtime.GetCanvasManager(),i=s.GetCssWidth(),n=s.GetCssHeight(),[r,a]=this.CanvasCssToLayer(0,0,e),[o,l]=this.CanvasCssToLayer(i,0,e),[h,c]=this.CanvasCssToLayer(i,n,e),[u,_]=this.CanvasCssToLayer(0,n,e),d=Math.min(r,o,h,u),p=Math.min(a,l,c,_),m=Math.max(r,o,h,u),g=Math.max(a,l,c,_);isFinite(d)||(d=-1/0),isFinite(p)||(p=-1/0),isFinite(m)||(m=1/0),isFinite(g)||(g=1/0),t.set(d,p,m,g)}CanvasCssToLayer(e,t,s=0){return this._CanvasToLayer(e,t,s,this.GetDisplayScale())}DrawSurfaceToLayer(e,t,s=0){return this._CanvasToLayer(e,t,s,this.GetRenderScale()*this.GetDevicePixelRatio())}_CanvasToLayer(e,t,s,i){const n=this._runtime,r=n.GetRenderer(),a=this.GetNormalScale(),o=n.GetViewportWidth()/a,l=n.GetViewportHeight()/a,h=tempVec4,c=(vec42.set(h,0,0,o,l),e/=i,t=h[3]-t/i,this._GetProjectionMatrix(r)),u=this._GetModelViewMatrix(r),_=tempVec3,d=C33.Gfx.UnprojectScreenToWorldZ(e,t,s,u,c,h,_);return d?[_[0],_[1]]:[NaN,NaN]}CanvasCssToLayer_DefaultTransform(e,t){const s=this._scale,i=this._scaleRate,n=this._parallaxX,r=this._parallaxY,a=this._angle,o=(this._scale=1,this._scaleRate=1,this._parallaxX=1,this._parallaxY=1,this._angle=0,this._SetMVMatrixChanged(),this.CanvasCssToLayer(e,t));return this._scale=s,this._scaleRate=i,this._parallaxX=n,this._parallaxY=r,this._angle=a,this._SetMVMatrixChanged(),o}LayerToCanvasCss(e,t,s=0){return this._LayerToCanvas(e,t,s,this.GetDisplayScale())}LayerToDrawSurface(e,t,s=0){return this._LayerToCanvas(e,t,s,this.GetRenderScale()*this.GetDevicePixelRatio())}_LayerToCanvas(e,t,s,i){const n=this._runtime,r=n.GetRenderer(),a=this.GetNormalScale(),o=n.GetViewportWidth()/a,l=n.GetViewportHeight()/a,h=tempVec4,c=(vec42.set(h,0,0,o,l),this._GetProjectionMatrix(r)),u=this._GetModelViewMatrix(r),_=tempVec3,d=C33.Gfx.Project(e,t,s,u,c,h,_);return d?[_[0]*i,(h[3]-_[1])*i]:[NaN,NaN]}_GetLayerToDrawSurfaceScale(e,t){return e*=this.GetRenderScale()*this.GetDevicePixelRatio(),0!==t&&(e*=this.Get2DScaleFactorToZ(t)),e}_InstanceBoxToDrawSurface(e){const t=e.GetBoundingBox(),s=e.GetTotalZElevation(),i=e.GetDepth(),h=s+i,c=t.getLeft(),u=t.getTop(),_=t.getRight(),d=t.getBottom();if(this.Has3DCamera()){if(this._IsPointBehindNearPlane(c,u,s)||this._IsPointBehindNearPlane(_,u,s)||this._IsPointBehindNearPlane(_,d,s)||this._IsPointBehindNearPlane(c,d,s))return null;if(0<i&&(this._IsPointBehindNearPlane(c,u,h)||this._IsPointBehindNearPlane(_,u,h)||this._IsPointBehindNearPlane(_,d,h)||this._IsPointBehindNearPlane(c,d,h)))return null}else if(h>=this.Get2DCameraZ())return null;let[p,m]=this.LayerToDrawSurface(c,u,s),[g,f]=this.LayerToDrawSurface(_,d,s);if(0!==this.GetAngle()||0<i||this.Has3DCamera()){const[S,C]=this.LayerToDrawSurface(_,u,s),[y,G]=this.LayerToDrawSurface(c,d,s);if(0<i){let[e,t]=this.LayerToDrawSurface(c,u,h),[s,i]=this.LayerToDrawSurface(_,u,h),[n,r]=this.LayerToDrawSurface(_,d,h),[a,o]=this.LayerToDrawSurface(c,d,h),l=Math.min(p,g,S,y,e,s,n,a);g=Math.max(p,g,S,y,e,s,n,a),p=l,l=Math.min(m,f,C,G,t,i,r,o),f=Math.max(m,f,C,G,t,i,r,o),m=l}else{let e=Math.min(p,g,S,y);g=Math.max(p,g,S,y),p=e,e=Math.min(m,f,C,G),f=Math.max(m,f,C,G),m=e}}return tmpRect.set(p,m,g,f),tmpRect}_GetViewFrustum(){return this._isViewFrustumChanged&&(this._UpdateViewFrustum(),this._isViewFrustumChanged=!1),this._viewFrustum}_UpdateViewFrustum(){const e=this._runtime.GetRenderer(),t=this._GetProjectionMatrix(e),s=this._GetModelViewMatrix(e);this._viewFrustum.CalculatePlanes(s,t)}_IsPointBehindNearPlane(e,t,s){return this._GetViewFrustum().IsBehindNearPlane(e,t,s)}_SaveToJson(){const e={d:this.IsDynamic(),s:this.GetOwnScale(),a:this.GetOwnAngle(),v:this._IsVisibleFlagSet(),i:this.IsInteractive(),html:this.IsHTMLElementsLayer(),bc:this._backgroundColor.toJSON(),t:this.IsTransparent(),sx:this._scrollX,sy:this._scrollY,hosp:this._hasOwnScrollPosition,px:this.GetParallaxX(),py:this.GetParallaxY(),c:this._color.toJSON(),sr:this.GetScaleRate(),fx:this._effectList.SaveToJson(),cg:this._createdGlobalUids};return e}_LoadFromJson(e){this._isDynamic=!!e.d,this._scale=e.s,this._angle=e.a,this._isVisible=!!e.v,this._isInteractive=!e.hasOwnProperty("i")||e.i,this._isHTMLElementsLayer=!!e.html,this._backgroundColor.setFromJSON(e.bc),this._isTransparent=!!e.t,e.hasOwnProperty("sx")&&(this._scrollX=e.sx),e.hasOwnProperty("sy")&&(this._scrollY=e.sy),e.hasOwnProperty("hosp")&&(this._hasOwnScrollPosition=!!e.hosp),this._parallaxX=e.px,this._parallaxY=e.py,this._color.setFromJSON(e.c),this._UpdatePremultipliedColor(),this._scaleRate=e.sr,C33.shallowAssignArray(this._createdGlobalUids,e.cg),C33.shallowAssignArray(this._initialInstances,this._startupInitialInstances);let s=new Set(this._createdGlobalUids),i=0;for(let e=0,t=this._initialInstances.length;e<t;++e)s.has(this._initialInstances[e][2])||(this._initialInstances[i]=this._initialInstances[e],++i);C33.truncateArray(this._initialInstances,i),this._effectList.LoadFromJson(e.fx),this._needsRebuildEffectChainSteps=!0}_LoadFromJsonAfterInstances(){this._SortInstancesByLastCachedZIndex(!1),this.SetZIndicesChanged(),this._SetMVMatrixChanged(),this._SetProjectionMatrixChanged()}GetILayer(){return this._iLayer}SortAndAddInstancesByZIndex(e,t=!1){if(this._instances.includes(e))t&&this._instances.sort((e,t)=>{const s=e.GetWorldInfo().GetSceneGraphZIndex(),i=t.GetWorldInfo().GetSceneGraphZIndex();return s-i});else if(e.HasChildren()){const s=[...e.allChildren()];s.push(e),s.sort((e,t)=>{const s=e.GetWorldInfo().GetSceneGraphZIndex(),i=t.GetWorldInfo().GetSceneGraphZIndex();return s-i});for(const i of s)if(i.IsInContainer())for(const n of i.siblings())if(!s.includes(n)){const r=[...n.allChildren()];r.push(n),r.sort((e,t)=>{const s=e.GetWorldInfo().GetSceneGraphZIndex(),i=t.GetWorldInfo().GetSceneGraphZIndex();return s-i}),r&&r.length&&s.splice(s.length,0,...r)}for(const a of s)a.GetPlugin().IsWorldType()&&this._AddInstance(a,!0)}else if(e.GetPlugin().IsWorldType()&&this._AddInstance(e,!0),e.IsInContainer())for(const o of e.siblings()){const l=[...o.allChildren()];if(l.push(o),l.sort((e,t)=>{const s=e.GetWorldInfo().GetSceneGraphZIndex(),i=t.GetWorldInfo().GetSceneGraphZIndex();return s-i}),l&&l.length)for(const h of l)h.GetPlugin().IsWorldType()&&this._AddInstance(h,!0)}}}}{let vec3EqualsXYZ2=function(e,t,s,i){return e[0]===Math.fround(t)&&e[1]===Math.fround(s)&&e[2]===Math.fround(i)},MaybePrepareLayerDraw2=function(e,t){lastLayerPreparedForDrawing!==e&&(e.PrepareForDraw(t),lastLayerPreparedForDrawing=e)},C33=(vec3EqualsXYZ=vec3EqualsXYZ2,MaybePrepareLayerDraw=MaybePrepareLayerDraw2,self.C3),C3Debugger=self.C3Debugger,assert=self.assert,tempDestRect=C33.New(C33.Rect),tempSrcRect=C33.New(C33.Rect),tempLayoutRect=C33.New(C33.Rect),tempColor=C33.New(C33.Color),glMatrix=self.glMatrix,vec32=glMatrix.vec3,tempRender3dList=[],tempInstanceList1=[],tempInstanceList2=[],tempInstanceList3=[],lastLayerPreparedForDrawing=null;C33.Layout=class extends C33.DefendedBase{constructor(e,t,s){super(),this._layoutManager=e,this._runtime=e.GetRuntime(),this._name=s[0],this._originalWidth=s[1],this._originalHeight=s[2],this._width=s[1],this._height=s[2],this._isUnboundedScrolling=!!s[3],this._isOrthographicProjection=!!s[4],this._vanishingPointX=s[5],this._vanishingPointY=s[6],this._eventSheetName=s[7],this._eventSheet=null,this._sid=s[8],this._index=t,this._scrollX=0,this._scrollY=0,this._scale=1,this._angle=0,this._initialObjectClasses=new Set,this._textureLoadedTypes=new Set,this._textureLoadPendingPromises=new Set,this._createdInstances=[],this._createdPersistedInstances=[],this._createdPersistedInstancesToDataMap=new Map,this._createdPersistedIndexToInstanceMap=new Map,this._initialNonWorld=[],this._is3dCameraEnabled=!1,this._cam3dposition=vec32.create(),this._cam3dlook=vec32.create(),this._cam3dup=vec32.create(),this._rootLayers=[],this._allLayersFlat=[],this._layersByName=new Map,this._layersBySid=new Map,this._pendingSetHTMLLayerCount=-1;const n=this._runtime.GetCanvasManager();this._effectList=C33.New(C33.EffectList,this,s[11]),this._effectChain=C33.New(C33.Gfx.EffectChain,n.GetEffectChainManager(),{drawContent:(e,t)=>{const s=t.GetContentObject(),i=s.GetRenderTarget();e.ResetColor(),e.DrawRenderTarget(i),e.InvalidateRenderTarget(i),n.ReleaseAdditionalRenderTarget(i)},getShaderParameters:e=>this.GetEffectList()._GetEffectChainShaderParametersForIndex(e)}),this._needsRebuildEffectChainSteps=!0,this._wasFullScreenQualityLow=!1,this._curRenderTarget=null,this._persistData={},this._persistedIntances=new Map,this._isFirstVisit=!0,this._iLayout=new self.ILayout(this),this._userScriptDispatcher=C33.New(C33.Event.Dispatcher);for(const i of s[9])this._rootLayers.push(C33.Layer.CreateFromExportData(this,null,i));this._ReindexLayers();for(const r of this.allLayers())r._InitInitialInstances();for(const a of s[10]){const o=this._runtime.GetObjectClassByIndex(a[1]);if(!o)throw new Error("missing nonworld object class");o.GetDefaultInstanceData()||o.SetDefaultInstanceData(a),this._initialNonWorld.push(a),this._AddInitialObjectClass(o)}}Release(){for(const e of this._allLayersFlat)e.Release();C33.clearArray(this._allLayersFlat),this._textureLoadPendingPromises.clear(),this._eventSheet=null,this._layoutManager=null,this._runtime=null}GetRuntime(){return this._runtime}GetName(){return this._name}GetSID(){return this._sid}GetIndex(){return this._index}GetEffectList(){return this._effectList}GetEffectChain(){return this._MaybeRebuildEffectChainSteps(),this._effectChain}_MaybeRebuildEffectChainSteps(){const e="low"===this._runtime.GetCanvasManager().GetCurrentFullscreenScalingQuality();if(this._needsRebuildEffectChainSteps||this._wasFullScreenQualityLow!==e||this._effectChain.NeedsRebuild()){const t=this.GetEffectList().GetActiveEffectTypes();this._effectChain.BuildSteps(t.map(e=>e.GetShaderProgram()),{indexMap:t.map(e=>e.GetIndex()),forcePostDraw:e,useFullSurface:!0}),this._needsRebuildEffectChainSteps=!1,this._wasFullScreenQualityLow=e}}UpdateActiveEffects(){this.GetEffectList().UpdateActiveEffects(),this._needsRebuildEffectChainSteps=!0}GetMinLayerScale(){let s=this._allLayersFlat[0].GetNormalScale();for(let e=1,t=this._allLayersFlat.length;e<t;++e){const i=this._allLayersFlat[e];0===i.GetParallaxX()&&0===i.GetParallaxY()||(s=Math.min(s,i.GetNormalScale()))}return s}_GetScrollBoundMarginHorizontal(){return.5*this._runtime.GetViewportWidth()/this.GetMinLayerScale()}_GetScrollBoundMarginVertical(){return.5*this._runtime.GetViewportHeight()/this.GetMinLayerScale()}GetScrollLeftBound(){return this.IsUnboundedScrolling()?-1/0:this._GetScrollBoundMarginHorizontal()}GetScrollRightBound(){return this.IsUnboundedScrolling()?1/0:this.GetWidth()-this._GetScrollBoundMarginHorizontal()}GetScrollTopBound(){return this.IsUnboundedScrolling()?-1/0:this._GetScrollBoundMarginVertical()}GetScrollBottomBound(){return this.IsUnboundedScrolling()?1/0:this.GetHeight()-this._GetScrollBoundMarginVertical()}SetScrollX(e){const t=this.GetScrollLeftBound(),s=this.GetScrollRightBound();this._scrollX!==(e=(e=s<e?s:e)<t?t:e)&&(this._scrollX=e,this._SetAllLayersMVChanged(),this._runtime.UpdateRender())}GetScrollX(){return this._scrollX}SetScrollY(e){const t=this.GetScrollTopBound(),s=this.GetScrollBottomBound();this._scrollY!==(e=(e=s<e?s:e)<t?t:e)&&(this._scrollY=e,this._SetAllLayersMVChanged(),this._runtime.UpdateRender())}GetScrollY(){return this._scrollY}IsUnboundedScrolling(){return this._isUnboundedScrolling}BoundScrolling(){this.SetScrollX(this.GetScrollX()),this.SetScrollY(this.GetScrollY());for(const e of this._allLayersFlat)e.IsOwnScrollPositionEnabled()&&(e.SetScrollX(e.GetScrollX()),e.SetScrollY(e.GetScrollY()))}SetVanishingPointXY(e,t){this._vanishingPointX===e&&this._vanishingPointY===t||(this._vanishingPointX=e,this._vanishingPointY=t,this.IsPerspectiveProjection()&&(this._SetAllLayersProjectionChanged(),this._SetAllLayersMVChanged(),this._runtime.UpdateRender()))}GetVanishingPointX(){return this.IsOrthographicProjection()?.5:this._vanishingPointX}GetVanishingPointY(){return this.IsOrthographicProjection()?.5:this._vanishingPointY}HasVanishingPointOutsideViewport(){const e=this.GetVanishingPointX(),t=this.GetVanishingPointY();return e<0||1<e||t<0||1<t}SetPerspectiveProjection(){this._isOrthographicProjection&&(this._isOrthographicProjection=!1,this._SetAllLayersProjectionChanged(),this._SetAllLayersMVChanged(),this._runtime.UpdateRender())}SetOrthographicProjection(){this._isOrthographicProjection||(this._isOrthographicProjection=!0,this._SetAllLayersProjectionChanged(),this._SetAllLayersMVChanged(),this._runtime.UpdateRender())}IsOrthographicProjection(){return this._isOrthographicProjection}IsPerspectiveProjection(){return!this.IsOrthographicProjection()}Set3DCameraEnabled(e){this._is3dCameraEnabled!==(e=!!e)&&(this._is3dCameraEnabled=e,this._SetAllLayersMVChanged(),this._runtime.UpdateRender())}Is3DCameraEnabled(){return this._is3dCameraEnabled}Set3DCameraOrientation(e,t,s,i,n,r,a,o,l){vec3EqualsXYZ2(this._cam3dposition,e,t,s)&&vec3EqualsXYZ2(this._cam3dlook,i,n,r)&&vec3EqualsXYZ2(this._cam3dup,a,o,l)||(vec32.set(this._cam3dposition,e,t,s),vec32.set(this._cam3dlook,i,n,r),vec32.set(this._cam3dup,a,o,l),this.Set3DCameraChanged())}Set3DCameraChanged(){this._SetAllLayersMVChanged(),this._runtime.UpdateRender()}Get3DCameraPosition(){return this._cam3dposition}Get3DCameraLookAt(){return this._cam3dlook}Get3DCameraUpVector(){return this._cam3dup}GetScale(){return this._scale}SetScale(e){this._scale!==e&&(this._scale=e,this._SetAllLayersMVChanged(),this.BoundScrolling(),this._runtime.UpdateRender())}SetAngle(e){e=C33.clampAngle(e),this._angle!==e&&(this._angle=e,this._SetAllLayersMVChanged(),this._runtime.UpdateRender())}GetAngle(){return this._angle}GetWidth(){return this._width}SetWidth(e){!isFinite(e)||e<1||(this._width=e)}GetHeight(){return this._height}SetHeight(e){!isFinite(e)||e<1||(this._height=e)}GetEventSheet(){return this._eventSheet}_GetRootLayers(){return this._rootLayers}*allLayers(){for(const e of this._rootLayers)yield*e.selfAndAllSubLayers()}GetLayers(){return this._allLayersFlat}GetLayerCount(){return this._allLayersFlat.length}GetLayer(e){return"number"==typeof e?this.GetLayerByIndex(e):this.GetLayerByName(e.toString())}GetLayerByIndex(e){return e=C33.clamp(Math.floor(e),0,this._allLayersFlat.length-1),this._allLayersFlat[e]}GetLayerByName(e){return this._layersByName.get(e.toLowerCase())||null}HasLayerByName(e){return!!this.GetLayerByName(e)}GetLayerBySID(e){return this._layersBySid.get(e)||null}_SetAllLayersProjectionChanged(){for(const e of this._allLayersFlat)e._SetProjectionMatrixChanged()}_SetAllLayersMVChanged(){for(const e of this._allLayersFlat)e._SetMVMatrixChanged()}AddLayer(e,t,s){if(this.HasLayerByName(e))throw new Error(`layer name '${e}' already in use`);if(!t&&s<2)throw new Error("invalid insert position");const i=2<=s?t:t.GetParentLayer(),n=C33.New(C33.Layer,this,i,{name:e,sid:Math.floor(1e15*Math.random()),isDynamic:!0});this._InsertLayer(n,t,s),this.GetRuntime().UpdateRender(),this._ReindexAndUpdateAllLayers()}MoveLayer(e,t,s){if(!t&&s<2)throw new Error("invalid insert position");e===t&&s<2||(this._RemoveLayer(e),this._InsertLayer(e,t,s),this.GetRuntime().UpdateRender(),this._ReindexAndUpdateAllLayers())}RemoveLayer(e){if(this._RemoveLayer(e)){const t=this._runtime.GetEventSheetManager();t.BlockFlushingInstances(!0),e.Release(),t.BlockFlushingInstances(!1),this.GetRuntime().UpdateRender(),this._ReindexAndUpdateAllLayers()}}RemoveAllDynamicLayers(){const e=new Set;for(const t of this.allLayers())t.IsDynamic()&&!t.HasAnyDynamicParentLayer()&&e.add(t);if(0!==e.size){const s=this._runtime.GetEventSheetManager();s.BlockFlushingInstances(!0);for(const i of e)this._RemoveLayer(i),i.Release();s.BlockFlushingInstances(!1),this.GetRuntime().UpdateRender(),this._ReindexAndUpdateAllLayers()}}_InsertLayer(t,s,i){if(2<=i)if(s){if(s===t||s.HasParentLayer(t))throw new Error(`cannot move layer '${t.GetName()}' to sub-layer of itself`);s._AddSubLayer(t,2===i),t._SetParentLayer(s)}else 2===i?this._rootLayers.push(t):this._rootLayers.unshift(t),t._SetParentLayer(null);else{const e=s.GetParentLayer();if(e){if(s.HasParentLayer(t))throw new Error(`cannot move layer '${t.GetName()}' to sub-layer of itself`);e._InsertSubLayer(t,s,0===i),t._SetParentLayer(e)}else{let e=this._rootLayers.indexOf(s);if(-1===e)throw new Error("cannot find layer to insert by");0===i&&++e,this._rootLayers.splice(e,0,t),t._SetParentLayer(null)}}}_RemoveLayer(e){const t=e.GetParentLayer();if(t)return t._RemoveSubLayer(e),!0;if(1<this._rootLayers.length){const s=this._rootLayers.indexOf(e);if(-1===s)throw new Error("cannot find layer to remove");return this._rootLayers.splice(s,1),!0}return!1}_ReindexLayers(){this._allLayersFlat=[...this.allLayers()],this._layersByName.clear(),this._layersBySid.clear();for(let e=0,t=this._allLayersFlat.length;e<t;++e){const s=this._allLayersFlat[e];s._SetIndex(e),this._layersByName.set(s.GetName().toLowerCase(),s),this._layersBySid.set(s.GetSID(),s)}}_ReindexHTMLLayers(){let e=0;for(const t of this._rootLayers){for(const s of t.selfAndAllSubLayers())s._SetHTMLIndex(e);t.IsHTMLElementsLayer()&&e++}}GetHTMLLayerCount(){return this._rootLayers.at(-1).GetHTMLIndex()+1}async _ReindexAndUpdateAllLayers(){this._ReindexLayers(),this._ReindexHTMLLayers(),this._pendingSetHTMLLayerCount=this.GetHTMLLayerCount()}_GetPendingSetHTMLLayerCount(){return this._pendingSetHTMLLayerCount}_ResetPendingHTMLLayerCount(){this._pendingSetHTMLLayerCount=-1}GetRootLayersForHTMLLayer(e){const t=[];for(const s of this._rootLayers){const i=s.GetHTMLIndex();if(i===e)t.push(s);else if(e<i)break}return t}SaveTransform(){return{scrollX:this.GetScrollX(),scrollY:this.GetScrollY(),scale:this.GetScale(),angle:this.GetAngle(),vpX:this.GetVanishingPointX(),vpY:this.GetVanishingPointY()}}RestoreTransform(e){this.SetScrollX(e.scrollX),this.SetScrollY(e.scrollY),this.SetScale(e.scale),this.SetAngle(e.angle),this.SetVanishingPointXY(e.vpX,e.vpY)}GetLayoutBackgroundColor(){let e=this._rootLayers.filter(e=>e.ShouldDraw())[0];for(;e;){if(!e.IsTransparent())return tempColor.copyRgb(e.GetBackgroundColor()),tempColor.setA(1),tempColor;if(e.UsesOwnTexture())return tempColor.setRgba(0,0,0,0),tempColor;e=e.GetSubLayers().filter(e=>e.ShouldDraw())[0]}return tempColor.setRgba(0,0,0,0),tempColor}IsFirstVisit(){return this._isFirstVisit}_GetInitialObjectClasses(){return[...this._initialObjectClasses]}_AddInitialObjectClass(e){if(e.IsInContainer())for(const t of e.GetContainer().GetObjectTypes())this._initialObjectClasses.add(t);else this._initialObjectClasses.add(e)}_GetTextureLoadedObjectTypes(){return[...this._textureLoadedTypes]}_Load(e,t){if(e===this||!t)return Promise.resolve();e&&(C33.CopySet(this._textureLoadedTypes,e._textureLoadedTypes),e._textureLoadedTypes.clear());const s=[];for(const i of this._initialObjectClasses)this._textureLoadedTypes.has(i)||(s.push(i.LoadTextures(t)),this._textureLoadedTypes.add(i));return Promise.all(s)}async MaybeLoadTexturesFor(e){if(e.IsFamily())throw new Error("cannot load textures for family");const t=this._runtime.GetRenderer();if(t&&!t.IsContextLost()&&!this._textureLoadedTypes.has(e)){this._textureLoadedTypes.add(e);const s=e.LoadTextures(t);this._AddPendingTextureLoadPromise(s),await s,e.OnDynamicTextureLoadComplete(),this._runtime.UpdateRender()}}_AddPendingTextureLoadPromise(e){this._textureLoadPendingPromises.add(e),e.then(()=>this._textureLoadPendingPromises.delete(e)).catch(()=>this._textureLoadPendingPromises.delete(e))}WaitForPendingTextureLoadsToComplete(){return Promise.all([...this._textureLoadPendingPromises])}MaybeUnloadTexturesFor(e){if(e.IsFamily()||0<e.GetInstanceCount())throw new Error("cannot unload textures");const t=this._runtime.GetRenderer();t&&this._textureLoadedTypes.has(e)&&(this._textureLoadedTypes.delete(e),e.ReleaseTextures(t))}_Unload(e,t){if(e!==this&&t)for(const s of this._textureLoadedTypes)s.IsGlobal()||e._initialObjectClasses.has(s)||(s.ReleaseTextures(),this._textureLoadedTypes.delete(s))}_OnRendererContextLost(){this._textureLoadedTypes.clear()}async _StartRunning(e){const t=this._runtime,s=this._layoutManager,i=t.GetEventSheetManager(),n=(this._eventSheetName&&(this._eventSheet=i.GetEventSheetByName(this._eventSheetName),this._eventSheet._UpdateDeepIncludes()),s._SetMainRunningLayout(this),this._width=this._originalWidth,this._height=this._originalHeight,this._scrollX=t.GetOriginalViewportWidth()/2,this._scrollY=t.GetOriginalViewportHeight()/2,this.BoundScrolling(),this._SetAllLayersProjectionChanged(),this._SetAllLayersMVChanged(),this._ReindexHTMLLayers(),await this._runtime.GetCanvasManager().SetHTMLLayerCount(this.GetHTMLLayerCount(),!0),this._MoveGlobalObjectsToThisLayout(e),this._runtime.SetUsingCreatePromises(!0),this._CreateInitialInstances(),this._isFirstVisit||this._CreatePersistedInstances(),this._CreateAndLinkContainerInstances(this._createdInstances),this._CreateAndLinkContainerInstances(this._createdPersistedInstances),this._CreateInitialNonWorldInstances(),s.ClearPendingChangeLayout(),t.FlushPendingInstances(),this._runtime.SetUsingCreatePromises(!1),this._runtime.GetCreatePromises());if(await Promise.all(n),C33.clearArray(n),!t.IsLoadingState()){for(const r of this._createdInstances)r.SetupInitialSceneGraphConnections();for(const a of this._createdPersistedInstances)a.SetupPersistedSceneGraphConnections(this._createdPersistedInstancesToDataMap,this._createdPersistedIndexToInstanceMap);for(const[o,l]of Object.entries(this._persistData)){const h=this._runtime.GetObjectClassBySID(parseInt(o,10));h&&!h.IsFamily()&&h.HasPersistBehavior()&&C33.clearArray(l)}for(const c of this._createdInstances)c._TriggerOnCreated();for(const u of this._createdPersistedInstances)u._TriggerOnCreated();for(const _ of this._createdInstances)_.HasParent()||_._OnHierarchyReady();for(const d of this._createdPersistedInstances)d.HasParent()||d._OnHierarchyReady()}C33.clearArray(this._createdInstances),C33.clearArray(this._createdPersistedInstances),this._createdPersistedInstancesToDataMap.clear(),this._createdPersistedIndexToInstanceMap.clear(),await Promise.all([...this._initialObjectClasses].map(e=>e.PreloadTexturesWithInstances(this._runtime.GetRenderer()))),e&&(t.Dispatcher().dispatchEvent(new C33.Event("beforefirstlayoutstart")),await t.DispatchUserScriptEventAsyncWait(new C33.Event("beforeprojectstart"))),await this.DispatchRuntimeUserScriptEventAsyncWait(new C33.Event("beforeanylayoutstart")),t.Dispatcher().dispatchEvent(new C33.Event("beforelayoutstart")),await this.DispatchUserScriptEventAsyncWait(new C33.Event("beforelayoutstart")),t.IsLoadingState()||await t.TriggerAsync(C33.Plugins.System.Cnds.OnLayoutStart,null,null),t.Dispatcher().dispatchEvent(new C33.Event("afterlayoutstart")),await this.DispatchUserScriptEventAsyncWait(new C33.Event("afterlayoutstart")),await this.DispatchRuntimeUserScriptEventAsyncWait(new C33.Event("afteranylayoutstart")),e&&(t.Dispatcher().dispatchEvent(new C33.Event("afterfirstlayoutstart")),await t.DispatchUserScriptEventAsyncWait(new C33.Event("afterprojectstart"))),i._RunQueuedTriggers(s),await this.WaitForPendingTextureLoadsToComplete(),this._isFirstVisit=!1}_MoveGlobalObjectsToThisLayout(e){for(const t of this._runtime.GetAllObjectClasses())if(!t.IsFamily()&&t.IsWorldType())for(const s of t.GetInstances()){const i=s.GetWorldInfo(),n=i.GetLayer(),r=C33.clamp(n.GetIndex(),0,this._allLayersFlat.length-1),a=this._allLayersFlat[r];i._SetLayer(a,!0),a._MaybeAddInstance(s)}if(!e)for(const o of this._allLayersFlat)o._SortInstancesByLastCachedZIndex(!1)}_CreateInitialInstances(){for(const e of this._allLayersFlat)e.CreateInitialInstances(this._createdInstances),e._Start()}_CreatePersistedInstances(){let t=!1;for(const[e,s]of Object.entries(this._persistData)){const i=this._runtime.GetObjectClassBySID(parseInt(e,10));if(i&&!i.IsFamily()&&i.HasPersistBehavior())for(const n of s){let e=null;if(!i.IsWorldType()||(e=n.hasOwnProperty("instJson")?this.GetLayerBySID(n.instJson.w.l):this.GetLayerBySID(n.w.l))){const r=this._runtime.CreateInstanceFromData(i,e,!1,0,0,!0);n.hasOwnProperty("instJson")?r.LoadFromJson(n.instJson):r.LoadFromJson(n),t=!0,this._createdPersistedInstances.push(r),n.hasOwnProperty("instJson")&&(this._createdPersistedInstancesToDataMap.set(r,n),this._createdPersistedIndexToInstanceMap.set(n.index,r))}}}for(const a of this._allLayersFlat)a._SortInstancesByLastCachedZIndex(!0),a.SetZIndicesChanged();t&&(this._runtime.FlushPendingInstances(),this._runtime._RefreshUidMap())}_CreateAndLinkContainerInstances(t){for(const s of t)if(s.IsInContainer()){const i=s.GetWorldInfo(),e=s.GetIID();for(const n of s.GetObjectClass().GetContainer().objectTypes())if(n!==s.GetObjectClass()){const r=n.GetInstances();if(r.length>e)s._AddSibling(r[e]);else{let e;e=i?this._runtime.CreateInstanceFromData(n,i.GetLayer(),!0,i.GetX(),i.GetY(),!0):this._runtime.CreateInstanceFromData(n,null,!0,0,0,!0),this._runtime.FlushPendingInstances(),n._UpdateIIDs(),s._AddSibling(e),t.push(e)}}}}_CreateInitialNonWorldInstances(){for(const e of this._initialNonWorld){const t=this._runtime.GetObjectClassByIndex(e[1]);t.IsInContainer()||this._runtime.CreateInstanceFromData(e,null,!0)}}_CreateGlobalNonWorlds(){let s=[],i=this._initialNonWorld,n=0;for(let e=0,t=i.length;e<t;++e){const r=i[e],a=this._runtime.GetObjectClassByIndex(r[1]);a.IsGlobal()?a.IsInContainer()&&a.GetContainer().HasAnyWorldType()||s.push(this._runtime.CreateInstanceFromData(r,null,!0)):(i[n]=r,++n)}C33.truncateArray(i,n),this._runtime.FlushPendingInstances(),this._CreateAndLinkContainerInstances(s)}RecreateInitialObjects(e,t,s,i,n,r,a){if(s)return s.RecreateInitialObjects(e,t,n,r,i,a);{const o=[];for(const l of this._allLayersFlat)o.push(l.RecreateInitialObjects(e,t,n,r,i,a));return o.flat()}}async _StopRunning(){const e=this._layoutManager;this._runtime.IsLoadingState()||(await this.DispatchRuntimeUserScriptEventAsyncWait(new C33.Event("beforeanylayoutend")),await this.DispatchUserScriptEventAsyncWait(new C33.Event("beforelayoutend")),await this._runtime.TriggerAsync(C33.Plugins.System.Cnds.OnLayoutEnd,null,null),await this.DispatchUserScriptEventAsyncWait(new C33.Event("afterlayoutend")),await this.DispatchRuntimeUserScriptEventAsyncWait(new C33.Event("afteranylayoutend"))),e.SetIsEndingLayout(!0),this._runtime.GetEventSheetManager().ClearAllScheduledWaits(),this._isFirstVisit||this._SavePersistData();for(const t of this._allLayersFlat)t._End();for(const s of this._runtime.GetAllObjectClasses())if(!(s.IsGlobal()||s.IsWorldType()||s.GetPlugin().IsSingleGlobal()||s.IsFamily())){for(const i of s.GetInstances())this._runtime.DestroyInstance(i);this._runtime.FlushPendingInstances()}e.SetIsEndingLayout(!1),e.GetMainRunningLayout()===this&&e._SetMainRunningLayout(null)}_SaveInstanceToPersist(e,t){const s=e.GetObjectClass().GetSID().toString(),i=(this._persistData.hasOwnProperty(s)||(this._persistData[s]=[]),this._persistData[s]),n={index:t,instJson:e.SaveToJson(),sceneGraphJson:{children:[]}};i.push(n),this._persistedIntances.set(e,n)}_SaveSceneGraphInfoToPersist(e){const t=this._persistedIntances.get(e);for(const s of e.GetChildren()){const i=this._persistedIntances.get(s);i&&t.sceneGraphJson.children.push({index:i.index,flags:C33.SceneGraphInfo._GetFlagsNumber(s.GetWorldInfo())})}}_SavePersistData(){this._persistedIntances.clear();let e=0;for(const t of this._allLayersFlat){t._UpdateZIndices();for(const s of t._GetInstances()){const i=s.GetObjectClass();!i.IsGlobal()&&i.HasPersistBehavior()&&(this._SaveInstanceToPersist(s,e),e++)}}for(const n of this._allLayersFlat)for(const r of n._GetInstances()){const a=r.GetObjectClass();!a.IsGlobal()&&a.HasPersistBehavior()&&this._SaveSceneGraphInfoToPersist(r)}this._persistedIntances.clear()}ResetPersistData(){this._persistData={},this._isFirstVisit=!0}GetRenderTarget(){return this._curRenderTarget}UsesOwnTexture(){const e=this._runtime,t=e.GetRenderer().IsWebGL();return"low"===e.GetCanvasManager().GetCurrentFullscreenScalingQuality()||t&&e.UsesAnyBackgroundBlending()||this._effectList.HasAnyActiveEffect()||t&&e.Uses3DFeatures()}_MaybeStartDrawToOwnTexture(e){const t=this._runtime.GetCanvasManager();if(this.UsesOwnTexture()){e.SetRenderTarget(null),e.ClearRgba(0,0,0,0);const s={sampling:this._runtime.GetSampling(),isSampled:e.IsWebGPU()||this._runtime.UsesAnyBackgroundBlending()||this._effectList.HasAnyActiveEffect(),canReadPixels:!!e.IsWebGPU()&&this._runtime.UsesAnyBackgroundBlending()};"low"===t.GetCurrentFullscreenScalingQuality()&&(s.width=t.GetDrawWidth(),s.height=t.GetDrawHeight()),this._curRenderTarget=this._runtime.GetAdditionalRenderTarget(s)}else this._curRenderTarget=null}_MaybeCopyOwnTextureToBackbuffer(e){this._runtime._NeedsHTMLLayerCompositing(e)&&(e.SetDepthEnabled(!1),e.SetRenderTarget(null),e.SetTextureFillMode(),e.CopyRenderTarget(this._curRenderTarget))}_MaybeEndDrawToOwnTexture(e){this.UsesOwnTexture()&&(e.SetDepthEnabled(!1),this._DrawLayoutOwnTextureToRenderTarget(e,this._curRenderTarget))}DrawMain(e){e.SetRenderTarget(this._curRenderTarget),e.Clear(this.GetLayoutBackgroundColor()),this._runtime.Uses3DFeatures()&&e.ClearDepth();const t=this.GetRootLayersForHTMLLayer(0);this._DrawLayerList(e,this._curRenderTarget,t,!0),e.IsWebGPU()&&e.StartMeasuringRenderPassTime(0,1),this._MaybeEndDrawToOwnTexture(e),this._curRenderTarget=null}DrawForHTMLLayerIndex(e,t){let s=null;this._runtime._NeedsHTMLLayerCompositing(e)&&(s=this._curRenderTarget),e.SetRenderTarget(s),e.ClearRgba(0,0,0,0),this._runtime.Uses3DFeatures()&&e.ClearDepth();const i=this.GetRootLayersForHTMLLayer(t);this._DrawLayerList(e,s,i,!0),this._MaybeCopyOwnTextureToBackbuffer(e),e.EndBatch(),this._runtime.GetCanvasManager().BlitMainCanvasToHTMLLayerCanvas(t)}_DrawLayerList(e,i,t,n){const r=t.filter(e=>e.ShouldDraw());for(let t=0,s=r.length;t<s;){const a=r[t];if(a.SelfAndAllSubLayersHave3DCamera()&&!a.SelfOrAnySubLayerUsesOwnTexture()){tempRender3dList.push(a);for(let e=t+1;e<s;++e){const o=r[e];if(!o.SelfAndAllSubLayersHave3DCamera()||o.SelfOrAnySubLayerUsesOwnTexture())break;tempRender3dList.push(r[e])}if(2<=tempRender3dList.length||1===tempRender3dList.length&&tempRender3dList[0].HasAnyVisibleSubLayer()){this._Draw3DLayers(e,i,tempRender3dList),t+=tempRender3dList.length,C33.clearArray(tempRender3dList);continue}C33.clearArray(tempRender3dList)}a.Draw(e,i,n&&0===t),++t}}_DrawLayoutOwnTextureToRenderTarget(e,t){const s=this._effectList.GetActiveEffectTypes(),i=this._runtime;0===s.length?(e.SetRenderTarget(null),e.SetTextureFillMode(),e.CopyRenderTarget(t),e.InvalidateRenderTarget(t),i.ReleaseAdditionalRenderTarget(t)):(tempLayoutRect.set(0,0,i.GetViewportWidth(),i.GetViewportHeight()),this.GetEffectChain().Render(e,null,{contentObject:this,blendMode:3,devicePixelRatio:this._runtime.GetEffectDevicePixelRatioParam(),layerScale:this._runtime.GetEffectLayerScaleParam()*this.GetScale(),layerAngle:this.GetAngle(),layoutRect:tempLayoutRect,drawSurfaceRect:null,invalidateRenderTargets:!0}))}_Draw3DLayers(i,n,e){e[0].IsTransparent()||(tempColor.copyRgb(e[0].GetBackgroundColor()),tempColor.setA(1),i.Clear(tempColor)),this._runtime.GetCanvasManager(),i.SetDepthEnabled(!0);const r=tempInstanceList1,a=tempInstanceList2,o=tempInstanceList3;for(const l of e)l._UpdateZIndices(),l._AppendAllInstancesIncludingSubLayersInDrawOrder(r);const t=e[0],s=t._MaybeStartWebGLProfiling(i);t._MaybeStartWebGPUProfiling(i);for(let t=0,s=r.length;t<s;){const h=r[t],c=h.GetWorldInfo(),u=c.GetLayer();if(c.IsVisible()&&c.IsInViewport3D(u._GetViewFrustum())){(!h.RendersToOwnZPlane()||0<c.GetDepth())&&o.push(h);const _=h.GetWorldInfo().GetTotalZElevation();a.push(h);let e=t+1;for(;e<s;++e){const d=r[e],p=d.GetWorldInfo();if(p.IsVisible()&&p.IsInViewport3D(p.GetLayer()._GetViewFrustum())){if(p.GetTotalZElevation()!==_)break;(d.RendersToOwnZPlane()?(0<p.GetDepth()&&o.push(d),a):o).push(d)}}if(1!==a.length||a[0].MustMitigateZFighting()){this._Draw3DLayersCoplanarInstances(i,n,a);for(let e=0,t=o.length;e<t;++e){const m=o[e],g=m.GetWorldInfo(),f=g.GetLayer();g._SetDrawNonBackFacesOnly(!0),MaybePrepareLayerDraw2(f,i),f._DrawInstanceMaybeWithEffects(m,g,i,n),g._SetDrawNonBackFacesOnly(!1)}}else{MaybePrepareLayerDraw2(u,i),u._DrawInstanceMaybeWithEffects(h,c,i,n);for(let e=0,t=o.length;e<t;++e){const S=o[e];if(S!==h){const C=S.GetWorldInfo(),y=C.GetLayer();MaybePrepareLayerDraw2(y,i),y._DrawInstanceMaybeWithEffects(S,C,i,n)}}}t=e,C33.clearArray(a),C33.clearArray(o)}else++t}s&&i.EndQuery(s),C33.clearArray(r),lastLayerPreparedForDrawing=null}_Draw3DLayersCoplanarInstances(s,i,n){s.CoplanarStartStencilPass();for(let e=0,t=n.length;e<t;++e){const r=n[e],a=r.GetWorldInfo(),o=a.GetLayer();a._SetDrawBackFaceOnly(!0),MaybePrepareLayerDraw2(o,s),o._DrawInstance(r,a,s)}s.CoplanarStartColorPass();for(let e=0,t=n.length;e<t;++e){const l=n[e],h=l.GetWorldInfo(),c=h.GetLayer();MaybePrepareLayerDraw2(c,s),c._DrawInstanceMaybeWithEffects(l,h,s,i),h._SetDrawBackFaceOnly(!1)}s.CoplanarRestoreStandardRendering()}_SaveToJson(){const e={sx:this.GetScrollX(),sy:this.GetScrollY(),s:this.GetScale(),a:this.GetAngle(),w:this.GetWidth(),h:this.GetHeight(),ortho:this.IsOrthographicProjection(),vpX:this.GetVanishingPointX(),vpY:this.GetVanishingPointY(),fv:this._isFirstVisit,persist:this._persistData,fx:this._effectList.SaveToJson(),layers:{},dynamicLayers:[]};for(const t of this._allLayersFlat)if(t.IsDynamic()){const s=t.GetParentLayer();e.dynamicLayers.push({sid:t.GetSID(),name:t.GetName(),parentSid:s?s.GetSID():null,siblingIndex:t._GetSiblingIndex(),data:t._SaveToJson()})}else e.layers[t.GetSID().toString()]=t._SaveToJson();return e}_LoadFromJson(e){this._scrollX=e.sx,this._scrollY=e.sy,this._scale=e.s,this._angle=e.a,this._width=e.w,this._height=e.h,this._isOrthographicProjection=!!e.ortho,e.hasOwnProperty("vpX")&&(this._vanishingPointX=e.vpX),e.hasOwnProperty("vpY")&&(this._vanishingPointY=e.vpY),this._isFirstVisit=!!e.fv,this._persistData=e.persist,this._effectList.LoadFromJson(e.fx),this._needsRebuildEffectChainSteps=!0;for(const[t,s]of Object.entries(e.layers)){const i=parseInt(t,10),n=this.GetLayerBySID(i);n&&n._LoadFromJson(s)}if(e.hasOwnProperty("dynamicLayers")){this.RemoveAllDynamicLayers(),this._runtime.FlushPendingInstances();const r=new Map,a=e.dynamicLayers;for(let e=a.length-1;0<=e;--e){const o=a[e],l=o.sid,h=o.name,c=o.parentSid,u=o.siblingIndex,_=o.data;if(this._ReindexLayers(),!this.HasLayerByName(h)&&!this.GetLayerBySID(l)){let e,t;if(null===c)e=null,t=this._rootLayers;else{if(!(e=this.GetLayerBySID(c)))continue;t=e.GetSubLayers()}const d=C33.New(C33.Layer,this,e,{name:h,sid:l,isDynamic:!0});t.push(d);let s=r.get(t);s||(s=[],r.set(t,s)),s.push({layer:d,siblingIndex:u}),d._LoadFromJson(_)}}for(const[p,m]of r){m.sort((e,t)=>e.siblingIndex-t.siblingIndex);for(const g of m){let e=g.layer,t=g.siblingIndex,s=p.indexOf(e);p.splice(s,1),p.splice(t,0,e)}}}this._ReindexAndUpdateAllLayers(),this._SetAllLayersProjectionChanged(),this._SetAllLayersMVChanged()}GetILayout(){return this._iLayout}UserScriptDispatcher(){return this._userScriptDispatcher}DispatchUserScriptEvent(e){e.layout=this.GetILayout();const t=this._runtime,s=t.IsDebug()&&!t.GetEventSheetManager().IsInEventEngine();s&&C3Debugger.StartMeasuringScriptTime(),this._userScriptDispatcher.dispatchEvent(e),s&&C3Debugger.AddScriptTime()}DispatchUserScriptEventAsyncWait(e){return e.layout=this.GetILayout(),this._userScriptDispatcher.dispatchEventAndWaitAsync(e)}DispatchRuntimeUserScriptEventAsyncWait(e){return e.layout=this.GetILayout(),this._runtime.DispatchUserScriptEventAsyncWait(e)}_LogLayerTree(){this._LogLayerList(this._rootLayers)}_LogLayerList(e,t=0){const s=e.slice(0);s.reverse();for(const i of s)console.log("\t".repeat(t)+"- "+i.GetName()),this._LogLayerList(i.GetSubLayers(),t+1)}}}{const C33=self.C3;C33.LayoutManager=class extends C33.DefendedBase{#runtime;#allLayouts=[];#layoutsByName=new Map;#layoutsBySid=new Map;#mainRunningLayout=null;#runningSubLayouts=[];#firstLayout=null;#isEndingLayout=0;#pendingChangeLayout=null;constructor(e){super(),this.#runtime=e}Release(){this.#runtime=null,this.#mainRunningLayout=null,this.#firstLayout=null,this.#pendingChangeLayout=null,C33.clearArray(this.#allLayouts),this.#layoutsByName.clear(),this.#layoutsBySid.clear(),C33.clearArray(this.#runningSubLayouts)}Create(e){const t=C33.New(C33.Layout,this,this.#allLayouts.length,e);this.#allLayouts.push(t),this.#layoutsByName.set(t.GetName().toLowerCase(),t),this.#layoutsBySid.set(t.GetSID(),t)}GetRuntime(){return this.#runtime}SetFirstLayout(e){this.#firstLayout=e}GetFirstLayout(){if(this.#firstLayout)return this.#firstLayout;if(this.#allLayouts.length)return this.#allLayouts[0];throw new Error("no first layout")}GetLayoutByName(e){return this.#layoutsByName.get(e.toLowerCase())||null}GetLayoutBySID(e){return this.#layoutsBySid.get(e)||null}GetLayoutByIndex(e){return e=C33.clamp(Math.floor(e),0,this.#allLayouts.length-1),this.#allLayouts[e]}GetLayout(e){return"number"==typeof e?this.GetLayoutByIndex(e):this.GetLayoutByName(e.toString())}GetAllLayouts(){return this.#allLayouts}_SetMainRunningLayout(e){this.#mainRunningLayout=e}GetMainRunningLayout(){return this.#mainRunningLayout}_AddRunningSubLayout(e){if(this.#runningSubLayouts.includes(e))throw new Error("layout already running");this.#runningSubLayouts.push(e)}_RemoveRunningSubLayout(e){const t=this.#runningSubLayouts.indexOf(e);if(-1===t)throw new Error("layout not running");this.#runningSubLayouts.splice(t,1)}*runningLayouts(){this.#mainRunningLayout&&(yield this.#mainRunningLayout),this.#runningSubLayouts.length&&(yield*this.#runningSubLayouts)}IsLayoutRunning(e){return this.#mainRunningLayout===e||this.#runningSubLayouts.includes(e)}SetIsEndingLayout(e){if(e)this.#isEndingLayout++;else{if(this.#isEndingLayout<=0)throw new Error("already unset");this.#isEndingLayout--}}IsEndingLayout(){return 0<this.#isEndingLayout}ChangeMainLayout(e){this.#pendingChangeLayout=e}ClearPendingChangeLayout(){this.#pendingChangeLayout=null}IsPendingChangeMainLayout(){return!!this.#pendingChangeLayout}GetPendingChangeMainLayout(){return this.#pendingChangeLayout}SetAllLayerProjectionChanged(){const e=this.GetMainRunningLayout();e&&e._SetAllLayersProjectionChanged()}SetAllLayerMVChanged(){const e=this.GetMainRunningLayout();e&&e._SetAllLayersMVChanged()}}}{const C33=self.C3,NAMES_REGEXP=new RegExp("<(.+?)>","g");C33.TimelineManager=class extends C33.DefendedBase{constructor(e){super(),this._runtime=e,this._timelineDataManager=C33.New(C33.TimelineDataManager),this._pluginInstance=null,this._timelines=[],this._timelinesByName=new Map,this._objectClassToTimelineMap=new Map,this._timelinesCreatedByTemplate=new Map,this._scheduledTimelines=[],this._playingTimelines=[],this._markedForRemovalTimelines=[],this._hasRuntimeListeners=!1,this._changingLayout=!1,this._isTickingTimelines=!1,this._tickFunc=()=>this._OnTick(),this._tick2Func=()=>this._OnTick2(),this._beforeLayoutChange=()=>this._OnBeforeChangeLayout(),this._layoutChange=()=>this._OnAfterChangeLayout(),this._instanceDestroy=e=>this._OnInstanceDestroy(e.instance),this._beforeLoad=e=>this._OnBeforeLoad(),this._afterLoad=e=>this._OnAfterLoad(),this._afterLayoutStart=e=>this._OnAfterLayoutStart(),this._destroyedWhileLoadingState=[],this._renderChange=0}Release(){this.RemoveRuntimeListeners(),this._tickFunc=null,this._tick2Func=null,this._beforeLayoutChange=null,this._layoutChange=null,this._instanceDestroy=null,this._afterLoad=null;for(const e of this._timelines)e.Stop(),e.Release();C33.clearArray(this._timelines),this._timelines=null,this._timelineDataManager.Release(),this._timelineDataManager=null,C33.clearArray(this._scheduledTimelines),this._scheduledTimelines=null,C33.clearArray(this._playingTimelines),this._playingTimelines=null,C33.clearArray(this._markedForRemovalTimelines),this._markedForRemovalTimelines=null,this._timelinesByName.clear(),this._timelinesByName=null,this._objectClassToTimelineMap.clear(),this._objectClassToTimelineMap=null,this._timelinesCreatedByTemplate.clear(),this._timelinesCreatedByTemplate=null,C33.clearArray(this._destroyedWhileLoadingState),this._destroyedWhileLoadingState=null,this._runtime=null}AddRuntimeListeners(){const e=this._runtime.Dispatcher();e.addEventListener("pretick",this._tickFunc),e.addEventListener("tick2",this._tick2Func),e.addEventListener("beforelayoutchange",this._beforeLayoutChange),e.addEventListener("layoutchange",this._layoutChange),e.addEventListener("instancedestroy",this._instanceDestroy),e.addEventListener("beforeload",this._beforeLoad),e.addEventListener("afterload",this._afterLoad),e.addEventListener("afterlayoutstart",this._afterLayoutStart)}RemoveRuntimeListeners(){const e=this._runtime.Dispatcher();e.removeEventListener("pretick",this._tickFunc),e.removeEventListener("tick2",this._tick2Func),e.removeEventListener("beforelayoutchange",this._beforeLayoutChange),e.removeEventListener("layoutchange",this._layoutChange),e.removeEventListener("instancedestroy",this._instanceDestroy),e.removeEventListener("beforeload",this._beforeLoad),e.removeEventListener("afterload",this._afterLoad),e.removeEventListener("afterlayoutstart",this._afterLayoutStart)}Create(e){this._timelineDataManager.Add(e);const t=C33.TimelineState.CreateInitial(e,this);this.Add(t),this.SetTimelineObjectClassesToMap(t),this._timelinesCreatedByTemplate.set(t.GetName(),0)}CreateFromTemplate(e){const t=this.GetTimelineDataManager(),s=e.GetTemplateName(),i=t.Get(s),n=C33.TimelineState.CreateFromTemplate(s+":"+this._timelinesCreatedByTemplate.get(s),i,this);return this._IncreaseTemplateTimelinesCount(s),this.Add(n),n}_IncreaseTemplateTimelinesCount(e){this._timelinesCreatedByTemplate.set(e,this._timelinesCreatedByTemplate.get(e)+1)}_SetCreatedTemplateTimelinesCount(){for(const e of this._timelines)if(!e.IsTemplate()){const t=e.GetTemplateName();this._IncreaseTemplateTimelinesCount(t)}}_ClearCreatedTemplateTimelinesCount(){for(const e of this._timelinesCreatedByTemplate.keys())this._timelinesCreatedByTemplate.set(e,0)}Add(e){this._timelines.push(e),this._timelinesByName.set(e.GetName().toLowerCase(),e)}Remove(e){e.Removed(),e.IsTemplate()||(C33.arrayFindRemove(this._timelines,e),C33.arrayFindRemove(this._scheduledTimelines,e),C33.arrayFindRemove(this._playingTimelines,e),C33.arrayFindRemove(this._markedForRemovalTimelines,e),this._timelinesByName.delete(e.GetName().toLowerCase()),this.RemoveTimelineFromObjectClassMap(e),e.IsReleased())||e.Release()}Trigger(e){this._runtime.Trigger(e,this._pluginInstance,null)}GetRuntime(){return this._runtime}GetTimelineDataManager(){return this._timelineDataManager}SetPluginInstance(e){this._pluginInstance=e}GetPluginInstance(){return this._pluginInstance}*GetTimelines(){for(const e of this._timelines)yield e}*GetPlayingTimelines(){for(const e of this._playingTimelines)yield e}SetTimelineObjectClassToMap(e,t){this._objectClassToTimelineMap.has(e)||this._objectClassToTimelineMap.set(e,new Set),this._objectClassToTimelineMap.get(e).add(t)}SetTimelineObjectClassesToMap(e){for(const t of e.GetObjectClasses())this.SetTimelineObjectClassToMap(t,e)}RemoveTimelineFromObjectClassMap(e){for(const[t,s]of this._objectClassToTimelineMap.entries())s.has(e)&&(s.delete(e),0===s.size)&&this._objectClassToTimelineMap.delete(t)}GetTimelinesForObjectClass(e){if(this._objectClassToTimelineMap.has(e))return this._objectClassToTimelineMap.get(e)}GetTimelineOfTemplateForInstances(e,t){if(t)for(const s of this._timelines){const i=t.every(e=>s.HasTrackInstance(e.instance,e.trackId));if(i&&s.GetName().includes(e.GetName()))return s}}GetTimelineByName(e){return this._timelinesByName.get(e.toLowerCase())||null}GetScheduledOrPlayingTimelineByName(e){for(const t of this._scheduledTimelines)if(t.GetName()===e)return t;for(const s of this._playingTimelines)if(s.GetName()===e)return s;return null}*GetTimelinesByName(s){if(NAMES_REGEXP.test(s)){NAMES_REGEXP.lastIndex=0;let e,t=new Set;do{if(e=NAMES_REGEXP.exec(s)){const i=e[1].split(",");for(const n of i)t.add(n)}}while(e);for(const r of t.values()){const a=this.GetTimelineByName(r);a&&(yield a)}t.clear()}else{const e=this.GetTimelineByName(s);e&&(yield e)}}*GetTimelinesByTags(e){for(const t of this._timelines)t.HasTags(e)&&(yield t)}AddScheduledTimeline(e){this._scheduledTimelines.includes(e)||this._scheduledTimelines.push(e),this._MaybeEnableRuntimeListeners()}RemovePlayingTimeline(e){C33.arrayFindRemove(this._playingTimelines,e),this._MaybeDisableRuntimeListeners()}ScheduleTimeline(e){this._playingTimelines.includes(e)?(e.SetPlaying(!0),e.SetScheduled(!1),e.SetMarkedForRemoval(!1)):(e.SetPlaying(!1),e.SetScheduled(!0),e.SetMarkedForRemoval(!1),this._scheduledTimelines.includes(e)||this._scheduledTimelines.push(e)),this._MaybeEnableRuntimeListeners()}DeScheduleTimeline(e){e.SetPlaying(!1),e.SetScheduled(!1),e.ResolvePlayPromise(),C33.arrayFindRemove(this._scheduledTimelines,e),this._MaybeDisableRuntimeListeners()}CompleteTimeline(e){e.SetPlaying(!1),e.SetScheduled(!1),this._playingTimelines.includes(e)&&(e.SetMarkedForRemoval(!0),this._markedForRemovalTimelines.push(e),C33.arrayFindRemove(this._playingTimelines,e)),this._scheduledTimelines.includes(e)&&e.SetMarkedForRemoval(!0)}CompleteTimelineBeforeChangeOfLayout(e){e.SetPlaying(!1),e.SetScheduled(!1),e.SetMarkedForRemoval(!1),e.SetPlaybackRate(1),C33.arrayFindRemove(this._playingTimelines,e)}CompleteTimelineAndResolve(e){this.CompleteTimeline(e),e.ResolvePlayPromise()}_OnTick(){if(!this.GetRuntime().IsLoadingState()&&this._hasRuntimeListeners&&!this._changingLayout){for(this._isTickingTimelines=!0;this._scheduledTimelines.length;){const e=this._scheduledTimelines.pop();(e.IsMarkedForRemoval()?(e.SetInitialStateForce(),this._markedForRemovalTimelines):(e.SetInitialState(),this._playingTimelines)).push(e),0!==e.GetRenderChange()&&(this._renderChange=1)}const t=this._runtime._GetDtFast(),s=this._runtime.GetDt1(),i=this._runtime.GetTimeScale();for(let e=this._playingTimelines.length-1;0<=e;e--){const n=this._playingTimelines[e];n&&n.Tick(t,i,s)}this._isTickingTimelines=!1,0!==this._renderChange&&this.GetRuntime().UpdateRender()}}_OnTick2(){if(!this.GetRuntime().IsLoadingState()&&this._hasRuntimeListeners&&!this._changingLayout){let s;for(let e=0,t=this._markedForRemovalTimelines.length;e<t;e++){const i=this._markedForRemovalTimelines[e];s=s||new Set,i.Removed(),this._MaybeExecuteTimelineFinishTriggers(i),s.add(i)}if(s){C33.arrayRemoveAllInSet(this._markedForRemovalTimelines,s);for(let e=this._renderChange=0,t=this._playingTimelines.length;e<t;e++)if(0!==this._playingTimelines[e].GetRenderChange()){this._renderChange=1;break}}this._MaybeDisableRuntimeListeners()}}_MaybeExecuteTimelineFinishTriggers(e){e.IsReleased()||e.HasValidTracks()&&e.IsComplete()&&e.InitialStateSet()&&e.FinishTriggers()}_MaybeEnableRuntimeListeners(){this._hasRuntimeListeners||(this._hasRuntimeListeners=!0)}_MaybeDisableRuntimeListeners(){this._markedForRemovalTimelines.length||this._playingTimelines.length||this._scheduledTimelines.length||this._isTickingTimelines||(this._hasRuntimeListeners=!1)}_OnBeforeChangeLayout(){for(this._changingLayout=!0;this._scheduledTimelines.length;)this.DeScheduleTimeline(this._scheduledTimelines.pop());const e=new Set;for(const t of this._playingTimelines){const s=t._OnBeforeChangeLayout();s&&(t.Removed(),e.add(t))}C33.arrayRemoveAllInSet(this._playingTimelines,e),e.clear();for(const i of this._markedForRemovalTimelines){const n=i._OnBeforeChangeLayout();n&&(i.Removed(),e.add(i))}C33.arrayRemoveAllInSet(this._markedForRemovalTimelines,e),this._MaybeDisableRuntimeListeners();for(const r of this._timelines)r.CleanCaches()}_OnAfterChangeLayout(){this._changingLayout=!1}_OnInstanceDestroy(e){const t=e.GetObjectClass(),s=this.GetTimelinesForObjectClass(t);if(s)if(this._runtime.IsLoadingState())this._destroyedWhileLoadingState.push(e);else for(const i of s)i.IsTemplate()||(i.IsReleased()?this.Remove(i):i.HasValidTracks()||(this._MaybeExecuteTimelineFinishTriggers(i),this.Remove(i)))}_OnBeforeLoad(){for(const e of this._scheduledTimelines.map(e=>e))this._MaybeExecuteTimelineFinishTriggers(e),this.Remove(e);for(const t of this._playingTimelines.map(e=>e))this._MaybeExecuteTimelineFinishTriggers(t),this.Remove(t)}_OnAfterLoad(){for(const e of this._destroyedWhileLoadingState)this._OnInstanceDestroy(e);C33.clearArray(this._destroyedWhileLoadingState);for(const t of this._timelines)t._OnAfterLoad()}_OnAfterLayoutStart(){const e=this._runtime.GetLayoutManager(),t=e.GetMainRunningLayout();if(t)for(const s of this._timelines){const i=s.GetStartOnLayout();i&&t.GetName()===i&&this.ScheduleTimeline(s)}}_SaveToJson(){return{timelinesJson:this._SaveTimelinesToJson(),scheduledTimelinesJson:this._SaveScheduledTimelinesToJson(),playingTimelinesJson:this._SavePlayingTimelinesToJson(),markedForRemovalTimelinesJson:this._SaveMarkedForRemovalTimelinesToJson(),hasRuntimeListeners:this._hasRuntimeListeners,changingLayout:this._changingLayout,isTickingTimelines:this._isTickingTimelines}}_LoadFromJson(e){e&&(this._ClearCreatedTemplateTimelinesCount(),this._LoadTimelinesFromJson(e.timelinesJson),this._LoadScheduledTimelinesFromJson(e.scheduledTimelinesJson),this._LoadPlayingTimelinesFromJson(e.playingTimelinesJson),this._LoadMarkedForRemovalTimelinesFromJson(e.markedForRemovalTimelinesJson),this._hasRuntimeListeners=!e.hasRuntimeListeners,this._changingLayout=!!e.changingLayout,this._isTickingTimelines=!!e.isTickingTimelines,this._SetCreatedTemplateTimelinesCount(),this._MaybeEnableRuntimeListeners(),this._MaybeDisableRuntimeListeners())}_SaveTimelinesToJson(){return this._timelines.map(e=>e._SaveToJson())}_LoadTimelinesFromJson(e){for(const t of e){let e=this.GetTimelineByName(t.name);if(e)e._LoadFromJson(t);else{const s=this._GetTemplateNameFromJson(t);if(!s)continue;const i=this.GetTimelineByName(s);(e=this.CreateFromTemplate(i))._LoadFromJson(t)}e.HasTracks()||this.Remove(e)}}_GetTemplateNameFromJson(e){const t=e.name,s=t.split(":");return s&&2===s.length?s[0]:null}_SaveScheduledTimelinesToJson(){return this._SaveTimelines(this._scheduledTimelines)}_LoadScheduledTimelinesFromJson(e){this._LoadTimelines(e,this._scheduledTimelines)}_SavePlayingTimelinesToJson(){return this._SaveTimelines(this._playingTimelines)}_LoadPlayingTimelinesFromJson(e){this._LoadTimelines(e,this._playingTimelines)}_SaveMarkedForRemovalTimelinesToJson(){return this._SaveTimelines(this._markedForRemovalTimelines)}_LoadMarkedForRemovalTimelinesFromJson(e){this._LoadTimelines(e,this._markedForRemovalTimelines)}_IsTimelineInJson(e,t){if(t)for(const s of t)if(s===e.GetName())return!0;return!1}_SaveTimelines(e){return e.map(e=>e.GetName())}_LoadTimelines(e,t){const s=new Set;for(const i of t)this._IsTimelineInJson(i,e)||s.add(i);if(C33.arrayRemoveAllInSet(t,s),e)for(const n of e){const r=this.GetTimelineByName(n);if(r){const a=t.find((t=>e=>e.GetName()===t)(n));a||t.push(r)}}}}}{const C33=self.C3,STEPS=100,LENGTH_STEP_SIZE=.01,BEZIER_STEP_SIZE=25,REFINE_ITERATIONS=20,LOOKUP_STEPS_FROM_LAST=5,TANGENT_RESULT=[0,0],MAP_RESULT=[0,0],SHORT_PROJECTION_RESULT=[0,0],PROJECTION_RESULT=[0,0,0,0,0],REFINE_LUT=new Array(4),REFINE_LUT_OBJECTS=[{x:0,y:0,t:0,distance:0},{x:0,y:0,t:0,distance:0},{x:0,y:0,t:0,distance:0}],REFINE_RESULT={x:0,y:0,t:0,distance:0};C33.TimelineInfo=class{constructor(e,t){this._initialized=!1,this._timeline=e,this._segments=[];let s=null;if(s=t?this._timeline.GetTrackById(t):C33.first(this._timeline.GetTracks())){const i=s.GetPropertyTrack("offsetX"),n=s.GetPropertyTrack("offsetY");if(i&&n){this._xTrack=i,this._yTrack=n;const r=i.GetPropertyKeyframeDataItemArrayIncludingDisabled(),a=n.GetPropertyKeyframeDataItemArrayIncludingDisabled();for(let e=1,t=Math.min(r.length,a.length);e<t;++e){const o=r[e],l=(o.GetNext(),o.GetPrevious()),h=a[e],c=(h.GetNext(),h.GetPrevious());l&&"cubic-bezier"===l.GetPathMode()&&c&&"cubic-bezier"===c.GetPathMode()?this._segments.push(C33.New(C33.TimelineCubicBezierSegmentInfo,l,c,o,h,this._segments.length)):(l&&"line"===l.GetPathMode()&&c&&c.GetPathMode(),this._segments.push(C33.New(C33.TimelineLineSegmentInfo,o,h,this._segments.length)))}this._initialized=!0}}}Release(){for(const e of this._segments)e.Release();C33.clearArray(this._segments),this._segments=null,this._timeline=null,this._xTrack=null,this._yTrack=null}WasInitialized(){return this._initialized}segments(){return this._segments}SetOrigin(e){const t="relative"===this._xTrack.GetResultMode()?e.GetX():0,s="relative"===this._yTrack.GetResultMode()?e.GetY():0;for(const i of this._segments)i.SetOrigin(t,s)}Project(t,s,e){let i=NaN,n=this._segments.length;for(let e=0;e<n;e++){const r=this._segments[e];if("cubic-bezier"===r.GetType()){const a=r.Project(t,s);(isNaN(i)||a[3]<i)&&(i=a[3],SHORT_PROJECTION_RESULT[0]=a[2],SHORT_PROJECTION_RESULT[1]=r.GetIndex())}}return SHORT_PROJECTION_RESULT}ProjectWithOptions(t,s,e){const i=e.tRange;C33.IsFiniteNumber(i[0])||(i[0]=0),C33.IsFiniteNumber(i[1])||(i[1]=1);let n=NaN,r=this._segments.length;for(let e=0;e<r;e++){const a=this._segments[e];if("cubic-bezier"===a.GetType()){const o=a.ProjectWithRange(t,s,i);(isNaN(n)||o[3]<n)&&(n=o[3],SHORT_PROJECTION_RESULT[0]=o[2],SHORT_PROJECTION_RESULT[1]=a.GetIndex())}}return SHORT_PROJECTION_RESULT}Tangent(e,t){return this._segments[t].Tangent(e)}TangentAngle(e,t){return this._segments[t].TangentAngle(e)}},C33.TimelineCubicBezierSegmentInfo=class{constructor(e,t,s,i,n){this._index=n;const r=e.GetAddOn("cubic-bezier"),a=s.GetAddOn("cubic-bezier"),o=t.GetAddOn("cubic-bezier"),l=i.GetAddOn("cubic-bezier");this._aX=e.GetValueWithResultMode(),this._aY=t.GetValueWithResultMode(),this._bX=e.GetValueWithResultMode()+r.GetStartAnchor(),this._bY=t.GetValueWithResultMode()+o.GetStartAnchor(),this._cX=s.GetValueWithResultMode()+a.GetEndAnchor(),this._cY=i.GetValueWithResultMode()+l.GetEndAnchor(),this._dX=s.GetValueWithResultMode(),this._dY=i.GetValueWithResultMode(),this._aXO=0,this._aYO=0,this._bXO=0,this._bYO=0,this._cXO=0,this._cYO=0,this._dXO=0,this._dYO=0,this._d0x=0,this._d0y=0,this._d1x=0,this._d1y=0,this._d2x=0,this._d2y=0,this._x1Factor=0,this._x2Factor=0,this._x3Factor=0,this._y1Factor=0,this._y2Factor=0,this._y3Factor=0,this._lutIndex=NaN,this._initialized=!1,this._len=STEPS,this._arcLengths=new Array(this._len+1),this._arcLengths[0]=0,this._length=0,this._lut=[],this._lutObjects=[];for(let e=0;e<STEPS;e++)this._lutObjects.push({x:0,y:0,t:0,distance:0});this._CalculateLength()}Release(){C33.clearArray(this._arcLengths),this._arcLengths=null,C33.clearArray(this._lut),this._lut=null,C33.clearArray(this._lutObjects),this._lutObjects=null}GetType(){return"cubic-bezier"}GetIndex(){return this._index}GetStepCount(){return Math.floor(this._length/BEZIER_STEP_SIZE)}GetStepIncrement(){return 1/this.GetStepCount()}SetOrigin(e,t){this._originX=e,this._originY=t,this._arcLengths=new Array(this._len+1),this._arcLengths[0]=0,this._CalculateLength(),this._aXO=this._aX+this._originX,this._aYO=this._aY+this._originY,this._bXO=this._bX+this._originX,this._bYO=this._bY+this._originY,this._cXO=this._cX+this._originX,this._cYO=this._cY+this._originY,this._dXO=this._dX+this._originX,this._dYO=this._dY+this._originY,this._d0x=3*(this._bXO-this._aXO),this._d0y=3*(this._bYO-this._aYO),this._d1x=3*(this._cXO-this._bXO),this._d1y=3*(this._cYO-this._bYO),this._d2x=3*(this._dXO-this._cXO),this._d2y=3*(this._dYO-this._cYO),this._x1Factor=3*(this._bXO-this._aXO),this._x2Factor=3*(this._aXO+this._cXO-2*this._bXO),this._x3Factor=this._dXO-this._aXO+3*(this._bXO-this._cXO),this._y1Factor=3*(this._bYO-this._aYO),this._y2Factor=3*(this._aYO+this._cYO-2*this._bYO),this._y3Factor=this._dYO-this._aYO+3*(this._bYO-this._cYO)}Map(e){if(!this._initialized)return NaN;const t=this._Map(e);return MAP_RESULT[0]=this._X(t),MAP_RESULT[1]=this._Y(t),MAP_RESULT}Project(e,t){const s=this._GenerateLUT(STEPS),i=this._FindClosestFromLUT(e,t,s),n=this._RefineProjection(e,t,s,i);return PROJECTION_RESULT[0]=n.x,PROJECTION_RESULT[1]=n.y,PROJECTION_RESULT[2]=n.t,PROJECTION_RESULT[3]=n.distance,PROJECTION_RESULT}ProjectWithRange(e,t,s){const i=this._GenerateLUT(STEPS),n=this._FindClosestFromLUTWithRange(e,t,i,s),r=this._RefineProjection(e,t,i,n);return PROJECTION_RESULT[0]=r.x,PROJECTION_RESULT[1]=r.y,PROJECTION_RESULT[2]=r.t,PROJECTION_RESULT[3]=r.distance,PROJECTION_RESULT}Tangent(e){const t=1-e,s=t*t,i=2*t*e,n=e*e,r=s*this._d0x+i*this._d1x+n*this._d2x,a=s*this._d0y+i*this._d1y+n*this._d2y,o=C33.hypot2DFast(r,a);return TANGENT_RESULT[0]=r/o,TANGENT_RESULT[1]=a/o,TANGENT_RESULT}TangentAngle(e){const t=1-e,s=t*t,i=2*t*e,n=e*e,r=s*this._d0x+i*this._d1x+n*this._d2x,a=s*this._d0y+i*this._d1y+n*this._d2y;return Math.atan2(a,r)}_Map(n){if(this._initialized){let e=n*this._arcLengths[this._len],t=0,s=this._len,i=0;for(;t<s;)i=t+((s-t)/2|0),this._arcLengths[i]<e?t=i+1:s=i;this._arcLengths[i]>e&&i--;const r=this._arcLengths[i];return r===e?i/this._len:(i+(e-r)/(this._arcLengths[i+1]-r))/this._len}}_X(e){return this._initialized?self.Ease.GetRuntimeEase("cubicbezier")(e,this._aX+this._originX,this._bX+this._originX,this._cX+this._originX,this._dX+this._originX):NaN}_Y(e){return this._initialized?self.Ease.GetRuntimeEase("cubicbezier")(e,this._aY+this._originY,this._bY+this._originY,this._cY+this._originY,this._dY+this._originY):NaN}_GenerateLUT(t){if(t=t||STEPS,!(this._lut.length>=t)){this._lut=new Array(t),t++;for(let e=0;e<t-1;e++){const s=e/(t-1),i=s**2,n=s**3,r=this._x1Factor*s,a=this._x2Factor*i,o=this._x3Factor*n,l=this._y1Factor*s,h=this._y2Factor*i,c=this._y3Factor*n,u=this._aXO+r+a+o,_=this._aYO+l+h+c;this._lutObjects[e].x=u,this._lutObjects[e].y=_,this._lutObjects[e].t=s,this._lutObjects[e].distance=0,this._lut[e]=this._lutObjects[e]}}return this._lut}_FindClosestFromLUT(t,s,i,e=0,n=Number.MAX_SAFE_INTEGER){let r=0;if(isNaN(this._lutIndex))for(let e=0;e<STEPS;e++){const a=i[e],o=a.x-t,l=a.y-s;a.distance=o*o+l*l,a.distance<n&&(n=a.distance,r=e)}else{for(let e=this._lutIndex;e<this._lutIndex+LOOKUP_STEPS_FROM_LAST&&!(e>=i.length);e++){const h=i[e],c=h.x-t,u=h.y-s;h.distance=c*c+u*u,h.distance<n&&(n=h.distance,r=e)}for(let e=this._lutIndex;e>this._lutIndex-LOOKUP_STEPS_FROM_LAST&&!(e<0);e--){const _=i[e],d=_.x-t,p=_.y-s;_.distance=d*d+p*p,_.distance<n&&(n=_.distance,r=e)}}return this._lutIndex=r}_FindClosestFromLUTWithRange(t,s,i,n,r=Number.MAX_SAFE_INTEGER){let a=0;if(isNaN(this._lutIndex))for(let e=0;e<STEPS;e++){const o=i[e],l=o.x-t,h=o.y-s;o.distance=l*l+h*h,o.t>=n[0]&&o.t<=n[1]&&o.distance<r&&(r=o.distance,a=e)}else{for(let e=this._lutIndex;e<this._lutIndex+LOOKUP_STEPS_FROM_LAST&&!(e>=i.length);e++){const c=i[e],u=c.x-t,_=c.y-s;c.distance=u*u+_*_,c.t>=n[0]&&c.t<=n[1]&&c.distance<r&&(r=c.distance,a=e)}for(let e=this._lutIndex;e>this._lutIndex-LOOKUP_STEPS_FROM_LAST&&!(e<0);e--){const d=i[e],p=d.x-t,m=d.y-s;d.distance=p*p+m*m,d.t>=n[0]&&d.t<=n[1]&&d.distance<r&&(r=d.distance,a=e)}}return this._lutIndex=a}_RefineProjection(a,o,l,h){let c=l[h],e=1,u=Number.MAX_SAFE_INTEGER;e:do{let e=l.length,t=0===h?0:h-1,s=h===e-1?e-1:h+1,i=l[t].t,n=l[s].t,r=(n-i)/4;if(r<.001)break;REFINE_LUT[0]=l[t];for(let e=1;e<=2;e++){const _=i+e*r,d=_**2,p=_**3,m=this._x1Factor*_,g=this._x2Factor*d,f=this._x3Factor*p,S=this._y1Factor*_,C=this._y2Factor*d,y=this._y3Factor*p,G=this._aXO+m+g+f,I=this._aYO+S+C+y,T=G-a,b=I-o,P=T*T+b*b;if(P<u){u=P,h=e,REFINE_RESULT.x=G,REFINE_RESULT.y=I,REFINE_RESULT.t=_,REFINE_RESULT.distance=P,c=REFINE_RESULT;break e}const A=REFINE_LUT_OBJECTS[e-1];A.x=G,A.y=I,A.t=_,A.distance=P,REFINE_LUT[e]=A}REFINE_LUT[3]=l[s],l=REFINE_LUT}while(e++<REFINE_ITERATIONS);return c}_CalculateLength(){this._initialized=!0;let t=this._X(0),s=this._Y(0),i=0;for(let e=1;e<=this._len;e++){const n=this._X(e*LENGTH_STEP_SIZE),r=this._Y(e*LENGTH_STEP_SIZE),a=t-n,o=s-r;i+=C33.hypot2DFast(a,o),this._arcLengths[e]=i,t=n,s=r}this._length=i}},C33.TimelineLineSegmentInfo=class{constructor(e,t,s){this._index=s,this._targetX=e.GetValueWithResultMode(),this._targetY=t.GetValueWithResultMode(),this._originX=0,this._originY=0}Release(){}GetType(){return"line"}GetIndex(){return this._index}SetOrigin(e,t){this._originX=e,this._originY=t}GetX(){return this._targetX+this._originX}GetY(){return this._targetY+this._originY}}}{const C33=self.C3,PING_PONG_BEGIN=0,PING_PONG_END=1;C33.TimelineState=class extends C33.DefendedBase{constructor(e,t,s){super(),this._runtime=s.GetRuntime(),this._timelineManager=s,this._timelineDataItem=t,this._name=e,this._tracks=[],this._tracksLength=0,this._beforeAndAfterTracks=null,this._beforeAndAfterTracksLength=0,this.CreateTrackStates(),this._playPromise=null,this._playResolve=null,this._playheadTime=0,this._overshoot=0,this._playbackRate=1,this._pingPongState=PING_PONG_BEGIN,this._currentRepeatCount=1,this._isPlaying=!1,this._isScheduled=!1,this._initialStateSet=!1,this._complete=!0,this._released=!1,this._markedForRemoval=!1,this._completedTick=-1,this._implicitPause=!1,this._isTemplate=!1,this._finishedTriggers=!1,this._firstTick=!1,this._lastDelta=NaN,this._tags=[""],this._stringTags="",this._tagsChanged=!1,this._renderChange=0,this._hasNestedContent=0,this._iTimelineState=null}static CreateInitial(e,t){const s=t.GetTimelineDataManager(),i=s.GetNameId(),n=s.Get(e[i]),r=C33.New(C33.TimelineState,e[i],n,t);return r.SetIsTemplate(!0),r}static CreateFromTemplate(e,t,s){return C33.New(C33.TimelineState,e,t,s)}Release(){if(!this.IsReleased()){const e=this._runtime.Dispatcher();this._timelineManager.DeScheduleTimeline(this),this._timelineManager.CompleteTimelineAndResolve(this);for(const t of this._tracks)t.Release();C33.clearArray(this._tracks),this._tracks=null,this._runtime=null,this._timelineManager=null,this._timelineDataItem=null,this._released=!0,this._playPromise=null,this._playResolve=null,this.FireReleaseEvent(e)}}FireReleaseEvent(e){const t=C33.New(C33.Event,"timelinestatereleased");t.timelineState=this,e.dispatchEvent(t)}GetType(){return 0}CreateTrackStates(){for(const e of this._timelineDataItem.GetTrackData().trackDataItems())this._tracksLength=this._tracks.push(C33.TrackState.Create(this,e))}GetTimelineManager(){return this._timelineManager}GetRuntime(){return this._runtime}GetTracks(){return this._tracks}GetSimilarPropertyTracks(i,n,r,a){if(this._hasNestedContent){let s;for(let t=0;t<this._tracks.length;t++){let e=this._tracks[t];if(i===e.GetInstance()){const o=e.GetPropertyTrack(r);o&&n.constructor===o.GetSourceAdapter().constructor&&o.GetResultMode()===a.GetResultMode()&&(s=s||[]).push(o)}}return s}}HasTracks(){return!!this._tracks.length}GetTrackById(e){for(const t of this._tracks)if(C33.equalsNoCase(t.GetId(),e))return t;return null}GetTrackByName(e){for(const t of this._tracks)if(!t.IsInstanceTrack()&&C33.equalsNoCase(t.GetName(),e))return t;return null}SetName(e){this._name=e}GetName(){return this._name}GetTimelineDataItem(){return this._timelineDataItem}GetTemplateName(){return this._timelineDataItem.GetName()}GetTotalTime(){return this._timelineDataItem.GetTotalTime()}SetTotalTime(e){this._timelineDataItem.SetTotalTime(e)}GetStep(){return this._timelineDataItem.GetStep()}SetStep(e){this._timelineDataItem.SetStep(e)}GetInterpolationMode(){return this._timelineDataItem.GetInterpolationMode()}SetInterpolationMode(e){this._timelineDataItem.SetInterpolationMode(e)}GetResultMode(){return this._timelineDataItem.GetResultMode()}SetResultMode(e){this._timelineDataItem.GetResultMode(e)}SetEase(e){for(const t of this.GetTracks())t.SetEase(e)}GetLoop(){return this._timelineDataItem.GetLoop()}SetLoop(e){return this._timelineDataItem.SetLoop(e)}GetPingPong(){return this._timelineDataItem.GetPingPong()}SetPingPong(e){return this._timelineDataItem.SetPingPong(e)}GetRepeatCount(){return this._timelineDataItem.GetRepeatCount()}SetRepeatCount(e){return this._timelineDataItem.SetRepeatCount(e)}SetPlaybackRate(e){return this._playbackRate=e}GetPlaybackRate(){return this._playbackRate}GetStartOnLayout(){return this._timelineDataItem.GetStartOnLayout()}GetTransformWithSceneGraph(){return this._timelineDataItem.GetTransformWithSceneGraph()}GetUseSystemTimescale(){return this._timelineDataItem.GetUseSystemTimescale()}GetPingPongState(){return this._pingPongState}IsForwardPlayBack(){return!this.IsPlaying()||0<this._playbackRate}GetPlayPromise(){return this._playPromise||(this._playPromise=new Promise(e=>{this._playResolve=e})),this._playPromise}ResolvePlayPromise(){this._playPromise&&(this._playResolve(),this._playPromise=null,this._playResolve=null)}SetTags(e){this._tags=C33.TimelineState._GetTagArray(e),this._tagsChanged=!0}GetTags(){return this._tags}GetStringTags(){return this._tagsChanged&&(this._stringTags=this._tags.join(" ")),this._tagsChanged=!1,this._stringTags}HasTags(e){if(!this._tags)return!1;if(!this._tags.length)return!1;const t=C33.TimelineState._GetTagArray(e);return!!t&&!!t.length&&t.every(C33.TimelineState._HasTag,this)}OnStarted(){C33.Plugins.Timeline&&this.constructor===C33.TimelineState&&(C33.Plugins.Timeline.Cnds.PushTriggerTimeline(this),this._timelineManager.Trigger(C33.Plugins.Timeline.Cnds.OnTimelineStarted),this._timelineManager.Trigger(C33.Plugins.Timeline.Cnds.OnTimelineStartedByName),this._timelineManager.Trigger(C33.Plugins.Timeline.Cnds.OnTimelineStartedByTags),this._timelineManager.Trigger(C33.Plugins.Timeline.Cnds.OnAnyTimelineStarted),C33.Plugins.Timeline.Cnds.PopTriggerTimeline())}OnCompleted(){this._completedTick=this._runtime.GetTickCount()}FinishTriggers(){this._finishedTriggers||(this._finishedTriggers=!0,C33.Plugins.Timeline&&this.constructor===C33.TimelineState&&(C33.Plugins.Timeline.Cnds.PushTriggerTimeline(this),this._timelineManager.Trigger(C33.Plugins.Timeline.Cnds.OnTimelineFinished),this._timelineManager.Trigger(C33.Plugins.Timeline.Cnds.OnTimelineFinishedByName),this._timelineManager.Trigger(C33.Plugins.Timeline.Cnds.OnTimelineFinishedByTags),this._timelineManager.Trigger(C33.Plugins.Timeline.Cnds.OnAnyTimelineFinished),C33.Plugins.Timeline.Cnds.PopTriggerTimeline()))}SetPlaying(e){this._isPlaying=e}IsCompletedTick(){return this._completedTick===this._runtime.GetTickCount()}IsPlaying(e=!1){return!!this.IsCompletedTick()||!(!this.IsScheduled()||e)||this._isPlaying}_IsPlaying(){return this.IsPlaying(!0)}IsPaused(){return this._IsPaused()}_IsPaused(){return!(this.IsReleased()||this.IsScheduled()||this._IsPlaying()||this.IsComplete())}SetScheduled(e){this._isScheduled=e}IsScheduled(){return this._isScheduled}SetComplete(e){this._complete=e;const t=this.GetTime();(t<=0||t>=this.GetTotalTime())&&(this._complete=!0)}IsComplete(){return this._complete}IsReleased(){return this._released}SetMarkedForRemoval(e){this._markedForRemoval=e}IsMarkedForRemoval(){return this._markedForRemoval}SetImplicitPause(e){this._implicitPause=e}IsImplicitPause(){return this._implicitPause}SetIsTemplate(e){this._isTemplate=!!e}IsTemplate(){return this._isTemplate}InitialStateSet(){return this._initialStateSet}GetTime(){return this._playheadTime}SetTime(e){const t=this.GetTime();this._SetTime(e),this.SetComplete(!1),this.IsComplete()||this.SetImplicitPause(!0),!this._IsPlaying()&&!this.IsScheduled()&&this._initialStateSet||(this._IsPlaying()||this.IsScheduled()||this._initialStateSet?this._IsPlaying()?this.Stop():this.IsScheduled()&&(this._timelineManager.DeScheduleTimeline(this),this.SetInitialStateFromSetTime()):this.SetInitialStateFromSetTime()),this._SetUpdateStateBefore(),this._Interpolate(this.GetTime(),!1,!0,!0,t),this._SetUpdateStateAfter(),this._renderChange&&this.GetRuntime().UpdateRender(),this._OnSetTime()}_SetTime(e){(e=C33.IsFiniteNumber(e)?e:this.GetTotalTime())<0?this._playheadTime=0:e>=this.GetTotalTime()?this._playheadTime=this.GetTotalTime():this._playheadTime=e}_SetTimeAndReset(e){(e=C33.IsFiniteNumber(e)?e:this.GetTotalTime())<0?this._playheadTime=0:e>=this.GetTotalTime()?this._playheadTime=this.GetTotalTime():this._playheadTime=e;for(const t of this._tracks)t.SetResetState()}_OnSetTime(){C33.Plugins.Timeline&&this.constructor===C33.TimelineState&&(C33.Plugins.Timeline.Cnds.PushTriggerTimeline(this),this._timelineManager.Trigger(C33.Plugins.Timeline.Cnds.OnTimeSet),this._timelineManager.Trigger(C33.Plugins.Timeline.Cnds.OnTimeSetByName),this._timelineManager.Trigger(C33.Plugins.Timeline.Cnds.OnTimeSetByTags),C33.Plugins.Timeline.Cnds.PopTriggerTimeline())}_CanResume(){if(!this.GetLoop())if(this.GetPingPong()&&this._pingPongState===PING_PONG_END){if(this.IsForwardPlayBack()){if(this.GetTime()>=this.GetTotalTime())return!1}else if(this.GetTime()<=0)return!1}else if(!this.GetLoop()&&!this.GetPingPong())if(this.IsForwardPlayBack()){if(this.GetTime()>=this.GetTotalTime())return!1}else if(this.GetTime()<=0)return!1;return!0}Resume(){this.IsReleased()||this._CanResume()&&this.Play(!0)}Play(e=!1){return!this.IsReleased()&&!this.IsScheduled()&&(this._IsPlaying()&&this.IsCompletedTick()?this._SchedulePlayingTimeline():!this._IsPlaying()&&!!(this.IsComplete()||e||this.IsImplicitPause())&&this._ScheduleStoppedTimeline())}_SchedulePlayingTimeline(){return this.SetImplicitPause(!1),this._timelineManager.RemovePlayingTimeline(this),this._timelineManager.ScheduleTimeline(this),this.GetPlayPromise(),!0}_ScheduleStoppedTimeline(){return this.SetImplicitPause(!1),this._timelineManager.ScheduleTimeline(this),this.GetPlayPromise(),!0}Stop(e=!1){this.IsReleased()||(this.SetComplete(e),this._timelineManager.CompleteTimeline(this),this.IsComplete()&&this.ResolvePlayPromise())}Reset(e=!0,t=!1){if(!this.IsReleased()){if(!this._IsPlaying()&&this.IsScheduled())return this._timelineManager.DeScheduleTimeline(this);if(!this.IsComplete()){this.Stop(!0),this.IsForwardPlayBack()?this._SetTime(0):this._SetTime(this.GetTotalTime());const s=this.GetTime();this._SetUpdateStateBefore(),t?this._InterpolateBeforeChangeLayout(s):this._Interpolate(s,!1,!1,!0),e&&this._OnSetTime(),this._SetUpdateStateAfter(),this._renderChange&&e&&this.GetRuntime().UpdateRender()}}}ResetBeforeChangeLayout(){this.Reset(!1,!0)}_InterpolateBeforeChangeLayout(e){this._Interpolate(e,!1,!1,!0,NaN,!1,!0)}_OnBeforeChangeLayout(){if(!this.IsReleased()){if(!this.GetRuntime().IsLoadingState()&&this.HasValidGlobalTracks())return!1;this._timelineManager.CompleteTimelineBeforeChangeOfLayout(this),this.GetRuntime().IsLoadingState()||this.ResetBeforeChangeLayout()}return!0}SetInitialStateFromSetTime(){this.SetInitialState(!0)}SetInitialStateForce(){this.SetInitialState(!1,!0),this.SetPlaying(!1),this.SetScheduled(!1)}SetInitialState(e=!1,t=!1){if(!this.IsMarkedForRemoval()||t){if(e){this._finishedTriggers=!1,this._initialStateSet=!0,this._firstTick=!0,this._SetUpdateStateBefore();for(const s of this._tracks)s.SetInitialState()}else if(this.SetPlaying(!0),this.SetScheduled(!1),this.OnStarted(),this.IsComplete()){this._completedTick=-1,this._pingPongState!==PING_PONG_BEGIN&&(this._playbackRate=Math.abs(this._playbackRate)),this._pingPongState=PING_PONG_BEGIN,this._currentRepeatCount=1,this._complete=!1,this._finishedTriggers=!1,this._initialStateSet=!0,this._firstTick=!0,this.IsForwardPlayBack()?this._SetTime(0):this._SetTime(this.GetTotalTime()),this._SetUpdateStateBefore();for(const i of this._tracks)i.SetInitialState()}else{this._firstTick=!0,this._finishedTriggers=!1,this._SetUpdateStateBefore();for(const n of this._tracks)n.SetResumeState()}this._SetUpdateStateAfter()}}GetRenderChange(){return this._renderChange}_SetUpdateStateBefore(){this._hasNestedContent=0;for(const e of this._tracks)e.IsNested()&&(this._hasNestedContent=1)}_SetUpdateStateAfter(){this._renderChange=0;for(const e of this._tracks)e._SetUpdateState(),0===this._renderChange&&1===e.GetRenderChange()&&(this._renderChange=1),this._beforeAndAfterTracks||1!==e.GetNeedsBeforeAndAfter()||(this._beforeAndAfterTracks||(this._beforeAndAfterTracks=[]),this._beforeAndAfterTracksLength=this._beforeAndAfterTracks.push(e))}Tick(e,t,s){if(this.GetUseSystemTimescale()){if(0===e&&0===this._lastDelta)return;this._lastDelta=e,e=s}else{if(0===s&&0===this._lastDelta)return;e=this._lastDelta=s,t=1}const i=this._playheadTime+this._overshoot,n=e*t*this._playbackRate,r=i+n,a=this._timelineDataItem._totalTime;r<0?(this._playheadTime=0,this._overshoot=-r):a<=r?(this._playheadTime=a,this._overshoot=this._playheadTime-r):(this._playheadTime=r,this._overshoot=0);let o=!1,l=!1,h=this.GetLoop(),c=this.GetPingPong();h||c?h&&!c?0<this._playbackRate?this._playheadTime>=a&&(this._SetTimeAndReset(0),l=!0):this._playheadTime<=0&&(this._SetTimeAndReset(a),l=!0):!h&&c?0<this._playbackRate?this._playheadTime>=a&&(this._SetTime(a),this.SetPlaybackRate(-1*this.GetPlaybackRate()),l=!0,this._pingPongState===PING_PONG_END?this._currentRepeatCount<this.GetRepeatCount()?(this._currentRepeatCount++,this._pingPongState=PING_PONG_BEGIN):o=!0:this._pingPongState===PING_PONG_BEGIN&&(this._pingPongState=PING_PONG_END)):this._playheadTime<=0&&(this._SetTime(0),this.SetPlaybackRate(-1*this.GetPlaybackRate()),l=!0,this._pingPongState===PING_PONG_END?this._currentRepeatCount<this.GetRepeatCount()?(this._currentRepeatCount++,this._pingPongState=PING_PONG_BEGIN):o=!0:this._pingPongState===PING_PONG_BEGIN&&(this._pingPongState=PING_PONG_END)):h&&c&&(0<this._playbackRate?this._playheadTime>=a&&(this._SetTime(a),this.SetPlaybackRate(-1*this.GetPlaybackRate()),l=!0,this._pingPongState++,C33.wrap(this._pingPongState,0,2)):this._playheadTime<=0&&(this._SetTime(0),this.SetPlaybackRate(-1*this.GetPlaybackRate()),l=!0,this._pingPongState++,C33.wrap(this._pingPongState,0,2))):0<this._playbackRate?this._playheadTime>=a&&(this._currentRepeatCount<this.GetRepeatCount()?(this._currentRepeatCount++,this._SetTimeAndReset(0),l=!0):(this._SetTime(a),o=!0)):this._playheadTime<=0&&(this._currentRepeatCount<this.GetRepeatCount()?(this._currentRepeatCount++,this._SetTimeAndReset(a),l=!0):(this._SetTime(0),o=!0));let u,_=this._tracksLength;if(o){for(u=0;u<_;u++)this._tracks[u].SetEndState();this.Stop(!0),this.OnCompleted()}else{const d=this._beforeAndAfterTracksLength;for(u=0;u<d;u++)this._beforeAndAfterTracks[u].BeforeInterpolate();if(1===this._hasNestedContent)for(u=0;u<_;u++){const p=this._tracks[u],m=p.GetStartOffset(),g=this._playheadTime-m,f=i-m;g<0&&0<f?(this._playheadTime=m<0?0:a<=m?a:m,p.Interpolate(m,!0,!1,l,this._firstTick,!1)):p.Interpolate(this._playheadTime,!0,!1,l,this._firstTick,!1)}else for(u=0;u<_;u++)this._tracks[u].Interpolate(this._playheadTime,!0,!1,l,this._firstTick,!1);for(u=0;u<d;u++)this._beforeAndAfterTracks[u].AfterInterpolate();this._firstTick&&(this._firstTick=!1)}}_Interpolate(t,s=!1,i=!1,n=!1,r=NaN,e=!1,a=!1){for(const o of this._tracks)o.BeforeInterpolate();for(const l of this._tracks){let e=t;if("number"==typeof r&&!isNaN(r)){const h=this.GetTime(),c=h-l.GetStartOffset(),u=r-l.GetStartOffset();c<0&&0<u&&(e=l.GetStartOffset(),this._SetTime(e))}l.Interpolate(e,s,i,n,this._firstTick,a)}for(const _ of this._tracks)_.AfterInterpolate();this._firstTick&&e&&(this._firstTick=!1)}AddTrack(){const e=this._timelineDataItem.GetTrackData().AddEmptyTrackDataItem(),t=C33.TrackState.Create(this,e);return this._tracksLength=this._tracks.push(t),t}Removed(){if(!this.IsReleased())for(const e of this._tracks)e.TimelineRemoved()}CleanCaches(){for(const e of this._tracks)e.CleanCaches()}ClearTrackInstances(){for(const e of this._tracks)e.ClearInstance()}SetTrackInstance(e,t,s){if(t){if("number"==typeof s&&0<=s){const i=this._tracks[s];return i?(i.SetInstance(t),void this._timelineManager.SetTimelineObjectClassToMap(t.GetObjectClass(),this)):void 0}for(const n of this._tracks)if(n.IsInstanceTrack())if(e){if(n.GetId()===e){n.SetInstance(t),this._timelineManager.SetTimelineObjectClassToMap(t.GetObjectClass(),this);break}}else if(!n.HasInstance()){n.SetInstance(t),this._timelineManager.SetTimelineObjectClassToMap(t.GetObjectClass(),this);break}}}HasTrackInstance(e,t){for(const s of this._tracks)if(s.IsInstanceTrack())if(t){if(t===s.GetId()&&e===s.GetInstance())return!0}else if(e===s.GetInstance())return!0;return!1}HasValidTracks(){return this._tracks.some(e=>!e.IsInstanceTrack()||e.CanInstanceBeValid())}HasValidGlobalTracks(){return this._tracks.some(e=>{if(e.IsInstanceTrack()){if(!e.CanInstanceBeValid())return!1;const t=e.GetObjectClass();return!!t&&t.IsGlobal()}return!1})}GetPropertyTrack(e){for(const t of this.GetTracks())for(const s of t.GetPropertyTracks())if(s.GetPropertyName()===e)return s}GetTrackFromInstance(e){for(const t of this._tracks)if(e===t.GetInstance())return t;return null}GetKeyframeWithTags(e){let t=e?e.split(" "):[],s=new Set(t.map(e=>e.toLowerCase().trim()));t=[...s.values()];for(const i of this.GetTracks())for(const n of i.GetKeyframeDataItems()){const r=t.every(e=>n.HasTag(e));if(r)return n}}GetObjectClasses(){const e=[];for(const t of this.GetTracks())e.push(t.GetObjectClass());return e.filter(e=>e)}_OnAfterLoad(){for(const e of this.GetTracks())e._OnAfterLoad()}_SaveToJson(){return{tracksJson:this._SaveTracksToJson(),name:this._name,playheadTime:this.GetTime(),playbackRate:this._playbackRate,pingPongState:this._pingPongState,currentRepeatCount:this._currentRepeatCount,isPlaying:this._isPlaying,isScheduled:this._isScheduled,initialStateSet:this._initialStateSet,finishedTriggers:this._finishedTriggers,complete:this._complete,released:this._released,markedForRemoval:this._markedForRemoval,completedTick:this._completedTick,implicitPause:this._implicitPause,isTemplate:this._isTemplate,tags:this._tags.join(" "),stringTags:this._stringTags,tagsChanged:this._tagsChanged,firstTick:this._firstTick}}_LoadFromJson(e){e&&(this._LoadTracksFromJson(e.tracksJson),this._name=e.name,this._playheadTime=e.playheadTime,this._playbackRate=e.playbackRate,this._pingPongState=e.pingPongState,this._currentRepeatCount=e.currentRepeatCount,this._isPlaying=!!e.isPlaying,this._isScheduled=!!e.isScheduled,this._initialStateSet=!!e.initialStateSet,this._finishedTriggers=!!e.hasOwnProperty("finishedTriggers")&&!!e.finishedTriggers,this._complete=!!e.complete,this._released=!!e.released,this._markedForRemoval=!!e.markedForRemoval,this._completedTick=e.completedTick,this._implicitPause=!!e.implicitPause,this._isTemplate=!!e.isTemplate,this._tags=e.tags.split(" "),this._stringTags=e.stringTags,this._tagsChanged=!!e.tagsChanged,this._firstTick=!!e.firstTick)}_SaveTracksToJson(){return this._tracks.map(e=>e._SaveToJson())}_LoadTracksFromJson(e){this.ClearTrackInstances(),e.forEach((e,t)=>{const s=this._tracks[t];s._LoadFromJson(e)}),this._tracks.filter(e=>e.CanInstanceBeValid())}static _HasTag(e){const t=this.GetTags();return""===e?1===t.length&&""===t[0]:t.map(e=>e.toLowerCase()).includes(e.toLowerCase())}static _GetTagArray(e){if(C33.IsArray(e))return e.slice(0);if(C33.IsString(e))return e.split(" ");throw new Error("invalid tags")}GetITimelineState(){return this._iTimelineState||(this._iTimelineState=C33.New(self.ITimelineState,this)),this._iTimelineState}}}{const C33=self.C3,INSTANCE_TRACK=0,VALUE_TRACK=1,AUDIO_TRACK=2;C33.TrackState=class extends C33.DefendedBase{constructor(e,t){super(),this._timeline=e,this._trackDataItem=t,this._trackData=t.GetTrackData(),this._instanceUid=NaN,this._objectClassIndex=NaN,this._instance=null,this._worldInfo=null,this._cleared=!1,this._isNested=0<t.GetStartOffset(),this._initialStateOfNestedSet=!1,this._endStateOfNestedSet=!1,this._instanceUidToLoad=NaN,this._lastKeyframeDataItem=null,this._keyframeDataItems=this._trackDataItem.GetKeyframeData().GetKeyframeDataItemArray(),this._propertyTracks=[],this.CreatePropertyTrackStates(),this._worldInfoChange=0,this._renderChange=0,this._needsBeforeAndAfter=0}static Create(e,t){return C33.New(C33.TrackState,e,t)}Release(){this._keyframeDataItems=null;for(const e of this._propertyTracks)e.Release();C33.clearArray(this._propertyTracks),this._propertyTracks=null,this._timeline=null,this._instance=null,this._worldInfo=null,this._trackDataItem=null,this._lastKeyframeDataItem=null}CreatePropertyTrackStates(){for(const e of this._trackDataItem.GetPropertyTrackData().propertyTrackDataItems())this._propertyTracks.push(C33.PropertyTrackState.Create(this,e))}TimelineRemoved(){for(const e of this._propertyTracks)e.TimelineRemoved()}CleanCaches(){for(const e of this._propertyTracks)e.CleanCaches();this._instance=null,this._worldInfo=null}GetTimeline(){return this._timeline}GetRuntime(){return this._timeline.GetRuntime()}GetKeyframeDataItems(){return this._keyframeDataItems||(this._keyframeDataItems=this._trackDataItem.GetKeyframeData().GetKeyframeDataItemArray()),this._keyframeDataItems}GetPropertyTracks(){return this._propertyTracks}GetPropertyTrack(t){for(let e=0;e<this._propertyTracks.length;e++){const s=this._propertyTracks[e];if(s.GetPropertyName()===t)return s}}MaybeGetInstance(){this._instance||this.GetInstance()}IsInstanceValid(){return!!this._instance&&!this._instance.IsDestroyed()}CanInstanceBeValid(){if(!this.IsInstanceTrack())return!1;const e=this.GetInstanceUID(),t=this.GetRuntime().GetInstanceByUID(e);return!!t&&!t.IsDestroyed()}GetObjectClass(){if(this.IsInstanceTrack()){const e=this.GetObjectClassIndex();if(-1!==e)return this.GetRuntime().GetObjectClassByIndex(e)}}GetTrackIndexInTimeline(){return this._timeline.GetTracks().indexOf(this)}ClearInstance(){this._instance=null,this._instanceUid=NaN,this._worldInfo=null,this._objectClassIndex=NaN,this._cleared=!0}HasInstance(){return!!this._instance}GetInstance(){if(!this._cleared){if(!this._instance||!this.IsInstanceValid()){const e=this.GetInstanceUID();this._instance=this.GetRuntime().GetInstanceByUID(e)}return this._instance}}SetInstance(e){if(this._cleared=!1,this._instance!==e){this.CleanCaches(),this._instance=e,this._objectClassIndex=e.GetObjectClass().GetIndex(),this._instanceUid=e.GetUID(),this._worldInfo=e.GetWorldInfo();for(const t of this.propertyTrackItems()){const s=t.propertyTrack,i=t.sourceAdapter,n=s.GetSourceAdapterId();switch(n){case"instance-variable":{i.GetEditorIndex();const r=e.GetObjectClass(),a=r.GetInstanceVariableIndexByName(t.name),o=r.GetInstanceVariableName(a),l=r.GetInstanceVariableType(a);o===t.name&&l===t.type&&i.UpdateInstanceVariableIndex(a);break}case"behavior":{const h=t.behaviorType,c=this.GetObjectClass(),u=e.GetObjectClass(),_=i.GetBehaviorType(u);if(h&&_){const d=h.GetName();c.GetBehaviorIndexByName(d),u.GetBehaviorIndexByName(d),i.GetEditorIndex(),i.UpdateBehaviorTypeSid(_.GetSID())}break}}}}}*propertyTrackItems(){for(const e of this._propertyTracks){const t=e.GetSourceAdapter(),s=this.GetObjectClass(),i={propertyTrack:e,sourceAdapter:t};switch(e.GetSourceAdapterId()){case"world-instance":i.property=e.GetPropertyName();break;case"instance-variable":{const n=t.GetEditorIndex();i.name=s.GetInstanceVariableName(n),i.type=s.GetInstanceVariableType(n);break}case"effect":{const r=s.GetEffectList(),a=t.GetEffectType(r);i.effectType=a;break}case"behavior":{const o=t.GetBehaviorType(s);i.behaviorType=o;break}case"plugin":i.plugin=s.GetPlugin()}yield i}}GetWorldInfo(){if(!this._worldInfo||!this.IsInstanceValid()){const e=this.GetInstance();e&&(this._worldInfo=e.GetWorldInfo())}return this._worldInfo}GetTrackDataItem(){return this._trackDataItem}GetInstanceUID(){return isNaN(this._instanceUid)?this._trackDataItem.GetInstanceUID():this._instanceUid}SetInstanceUID(e){this._trackDataItem.SetInstanceUID(e)}GetInterpolationMode(){return this._trackDataItem.GetInterpolationMode()}SetInterpolationMode(e){this._trackDataItem.SetInterpolationMode(e)}GetResultMode(){return this._trackDataItem.GetResultMode()}GetId(){return this._trackDataItem.GetId()}GetStartOffset(){return this._trackDataItem.GetStartOffset()}GetLocalTotalTime(){return this._trackDataItem.GetLocalTotalTime()}SetLocalTotalTime(e){this._trackDataItem.SetLocalTotalTime(e)}SetResultMode(e){this._trackDataItem.SetResultMode(e)}SetEase(e){for(const t of this.GetKeyframeDataItems())t.SetEase(e);for(const s of this.GetPropertyTracks())s.SetEase(e)}GetEnable(){return this._trackDataItem.GetEnable()}SetEnable(e){this._trackDataItem.SetEnable(e)}GetObjectClassIndex(){return isNaN(this._objectClassIndex)?this._trackDataItem.GetObjectClassIndex():this._objectClassIndex}SetObjectClassIndex(e){this._trackDataItem.SetObjectClassIndex(e)}SetOriginalWidth(e){this._trackDataItem.SetOriginalWidth(e)}GetOriginalWidth(){const e=this.GetInstance();if(e){const t=e.GetSdkInstance();if(t.IsOriginalSizeKnown())return e.GetSdkInstance().GetOriginalWidth()}return this._trackDataItem.GetOriginalWidth()}SetOriginalHeight(e){this._trackDataItem.SetOriginalHeight(e)}GetOriginalHeight(){const e=this.GetInstance();if(e){const t=e.GetSdkInstance();if(t.IsOriginalSizeKnown())return e.GetSdkInstance().GetOriginalHeight()}return this._trackDataItem.GetOriginalHeight()}GetType(){return this._trackDataItem.GetType()}GetName(){return this._trackDataItem.GetName()}IsInstanceTrack(){return this.GetType()===INSTANCE_TRACK}IsValueTrack(){return this.GetType()===VALUE_TRACK}IsAudioTrack(){return this.GetType()===AUDIO_TRACK}GetWorldInfoChange(){return this._worldInfoChange}GetRenderChange(){return this._renderChange}GetNeedsBeforeAndAfter(){return this._needsBeforeAndAfter}IsNested(){return this._isNested}SetResetState(){for(const e of this._propertyTracks)e.SetResetState()}SetInitialState(){if(this.MaybeGetInstance(),this.IsInstanceValid()||!this.IsInstanceTrack()){const e=this.GetTimeline(),t=e.IsForwardPlayBack(),s=t?0:this.GetLocalTotalTime();for(const n of this._propertyTracks)n.SetInitialState(s),0===this._worldInfoChange&&1===n.GetWorldInfoChange()&&(this._worldInfoChange=1),0===this._renderChange&&1===n.GetRenderChange()&&(this._renderChange=1);this._needsBeforeAndAfter=0;const i=this._propertyTracks.some(e=>e.GetNeedsBeforeAndAfter());i&&(this._needsBeforeAndAfter=1),this._lastKeyframeDataItem=this._GetLastKeyFrameBeforeTime(s),this._initialStateOfNestedSet=!1,this._endStateOfNestedSet=!1,this.Interpolate(s),this.OnKeyframeReached(this._GetLastKeyFrameBeforeTime(s))}}SetResumeState(){if(this.MaybeGetInstance(),this.IsInstanceValid()||!this.IsInstanceTrack()){this._timeline.IsForwardPlayBack();const e=this._timeline.GetTime()-this.GetStartOffset();this._lastKeyframeDataItem=this._GetLastKeyFrameBeforeTime(e);for(const t of this._propertyTracks)t.SetResumeState(e)}}SetEndState(){if(!this.GetTimeline().IsComplete()&&(this.MaybeGetInstance(),this.IsInstanceValid()||!this.IsInstanceTrack())&&!this._isNested){const e=this._timeline.GetTime(),t=this.GetStartOffset()+this.GetLocalTotalTime();t<=e?this.Interpolate(this.GetLocalTotalTime(),!0,!1,!0,!1,!1,!0):e<=0&&this.Interpolate(0,!0,!1,!0,!1,!1,!0)}}_SetUpdateState(){for(let e=0,t=this._propertyTracks.length;e<t;e++){const s=this._propertyTracks[e];s._SetUpdateState(),0===this._worldInfoChange&&1===s.GetWorldInfoChange()&&(this._worldInfoChange=1),0===this._renderChange&&1===s.GetRenderChange()&&(this._renderChange=1)}}BeforeInterpolate(){const t=this._propertyTracks.length;for(let e=0;e<t;e++)this._propertyTracks[e].BeforeInterpolate()}Interpolate(s,e=!1,i=!1,n=!1,t=!1,r=!1,a=!1){this._instance||this.GetInstance();const o=this._instance&&!this._instance.IsDestroyed(),l=this._trackDataItem._type===INSTANCE_TRACK;if((o||!l)&&!(r&&l&&this.GetObjectClass().IsGlobal()||(s-=this.GetStartOffset())<0)){this.MaybeSetInitialStateOfNestedTrack(s,e),this.MaybeTriggerKeyframeReachedConditions(s,e,t);for(let e=0,t=this._propertyTracks.length;e<t;e++)this._propertyTracks[e].Interpolate(s,i,n,a);this.MaybeSetEndStateOfNestedTrack(s,e),0!==this._worldInfoChange&&(this._worldInfo||(this._worldInfo=this._instance.GetWorldInfo()),this._worldInfo)&&this._worldInfo.SetBboxChanged()}}AfterInterpolate(){const t=this._propertyTracks.length;for(let e=0;e<t;e++)this._propertyTracks[e].AfterInterpolate()}MaybeSetInitialStateOfNestedTrack(e,t){if(t&&this._isNested&&!this._initialStateOfNestedSet){const s=this.GetTimeline();if(s.IsForwardPlayBack()){if(e<0)return}else if(e>this.GetLocalTotalTime())return;for(const i of this._propertyTracks)i.SetInitialState();this._initialStateOfNestedSet=!0}}MaybeSetEndStateOfNestedTrack(e,t){if(t&&this._isNested&&!this._endStateOfNestedSet){const s=this.GetTimeline();if(s.IsForwardPlayBack()){if(e>=this.GetLocalTotalTime()){for(const i of this._propertyTracks)i.Interpolate(this.GetLocalTotalTime(),!1,!0);this._endStateOfNestedSet=!0}}else if(e<=0){for(const n of this._propertyTracks)n.Interpolate(0,!1,!0);this._endStateOfNestedSet=!0}}}MaybeTriggerKeyframeReachedConditions(e,t,s){if(!s&&t&&C33.Plugins.Timeline){const i=this.GetTimeline(),n=this._lastKeyframeDataItem.GetNext(),r=this._lastKeyframeDataItem.GetTime(),a=n?n.GetTime():i.GetTotalTime();if(e<=r||a<=e)if(this._lastKeyframeDataItem=this._trackData.GetFirstKeyFrameDataItemLowerOrEqualThan(e,this._trackDataItem),i.IsForwardPlayBack())n&&this.OnKeyframeReached(this._lastKeyframeDataItem);else{const o=this._lastKeyframeDataItem.GetNext();o&&this.OnKeyframeReached(o)}}}_GetLastKeyFrameBeforeTime(e){const t=this._trackData.GetKeyFrameDataItemAtTime(e,this._trackDataItem);return t||this._trackData.GetFirstKeyFrameDataItemLowerOrEqualThan(e,this._trackDataItem)}OnKeyframeReached(e){if(C33.Plugins.Timeline){const t=this.GetTimeline(),s=t.GetTimelineManager();C33.Plugins.Timeline.Cnds.PushTriggerTimeline(t),C33.Plugins.Timeline.Cnds.PushTriggerKeyframe(e),s.Trigger(C33.Plugins.Timeline.Cnds.OnAnyKeyframeReached),s.Trigger(C33.Plugins.Timeline.Cnds.OnKeyframeReached),C33.Plugins.Timeline.Cnds.PopTriggerTimeline(t),C33.Plugins.Timeline.Cnds.PopTriggerKeyframe(e)}}AddKeyframe(){const e=this._trackDataItem.GetKeyframeData(),t=e.AddEmptyKeyframeDataItem();return t}AddPropertyTrack(){const e=this._trackDataItem.GetPropertyTrackData(),t=e.AddEmptyPropertyTrackDataItem(),s=C33.PropertyTrackState.Create(this,t);return this._propertyTracks.push(s),s}DeleteKeyframes(e){const t=this._trackDataItem.GetKeyframeData();t.DeleteKeyframeDataItems(e)}DeletePropertyKeyframes(e){for(const t of this._propertyTracks)t.DeletePropertyKeyframes(e)}SaveState(){for(const e of this._propertyTracks)e.SaveState()}CompareInitialStateWithCurrent(){if(this.MaybeGetInstance(),this.IsInstanceValid()||!this.IsInstanceTrack())for(const e of this._propertyTracks)e.CompareInitialStateWithCurrent()}CompareSaveStateWithCurrent(){if(this.MaybeGetInstance(),this.IsInstanceValid()||!this.IsInstanceTrack()){let e=!1;for(const t of this._propertyTracks){const s=t.CompareSaveStateWithCurrent();!e&&s&&(e=!0)}if(e){const i=this.AddKeyframe();i.SetTime(this.GetTimeline().GetTime()),i.SetEase("noease"),i.SetEnable(!0),i.SetTags("")}}}_OnAfterLoad(){isNaN(this._instanceUidToLoad)||this._LoadInstanceFromJson(this._instanceUidToLoad),this._instanceUidToLoad=NaN}_SaveToJson(){const e=this.GetInstance(),t=e?e.GetUID():this.GetInstanceUID();return{propertyTracksJson:this._SavePropertyTracksToJson(),lastKeyframeDataItemJson:this._SaveLastKeyframeDataItemToJson(),initialStateOfNestedSet:this._initialStateOfNestedSet,endStateOfNestedSet:this._endStateOfNestedSet,instanceUid:t,cleared:this._cleared}}_LoadFromJson(e){if(e){this._LoadPropertyTracksFromJson(e.propertyTracksJson),this._LoadLastKeyframeDataItemFromJson(e.lastKeyframeDataItemJson),this._instanceUidToLoad=e.instanceUid,this._initialStateOfNestedSet=!1,e.hasOwnProperty.initialStateOfNestedSet&&(this._initialStateOfNestedSet=e.initialStateOfNestedSet),this._endStateOfNestedSet=!1,e.hasOwnProperty.endStateOfNestedSet&&(this._endStateOfNestedSet=e.endStateOfNestedSet),this._cleared=!!e.hasOwnProperty("cleared")&&e.cleared;for(const t of this._propertyTracks)0===this._worldInfoChange&&1===t.GetWorldInfoChange()&&(this._worldInfoChange=1),0===this._renderChange&&1===t.GetRenderChange()&&(this._renderChange=1);this._needsBeforeAndAfter=0,this._propertyTracks.some(e=>e.GetNeedsBeforeAndAfter())&&(this._needsBeforeAndAfter=1)}}_SaveLastKeyframeDataItemToJson(){const e=this._trackDataItem.GetKeyframeData();return e.GetKeyframeDataItemIndex(this._lastKeyframeDataItem)}_SavePropertyTracksToJson(){return this._propertyTracks.map(e=>e._SaveToJson())}_LoadPropertyTracksFromJson(e){e.forEach((e,t)=>{const s=this._propertyTracks[t];s._LoadFromJson(e)})}_LoadInstanceFromJson(e){if(C33.IsFiniteNumber(e)){const t=this.GetRuntime().GetInstanceByUID(e);if(t){const s=this.GetTimeline();s.SetTrackInstance(this._trackDataItem.GetId(),t,this.GetTrackIndexInTimeline())}}}_LoadLastKeyframeDataItemFromJson(e){const t=this._trackDataItem.GetKeyframeData();this._lastKeyframeDataItem=t.GetKeyframeDataItemFromIndex(e)}}}{const C33=self.C3;C33.PropertyTrackState=class extends C33.DefendedBase{constructor(e,t){super(),this._track=e,this._propertyTrackDataItem=t,this._propertyTrackData=t.GetPropertyTrackData(),this._worldInfoChange=0,this._renderChange=0,this._needsBeforeAndAfter=0,this._sourceAdapter=this.GetSourceAdapter(),this._propertyKeyframeDataItems=this._propertyTrackDataItem.GetPropertyKeyframeData().GetPropertyKeyframeDataItemArray(),this._lastPropertyKeyframeDataItem=null,this._absoluteValueObject=null}static Create(e,t){return C33.New(C33.PropertyTrackState,e,t)}Release(){this._track=null,this._sourceAdapter&&(this._sourceAdapter.Release(),this._sourceAdapter=null),this._propertyKeyframeDataItems=null,this._propertyTrackDataItem=null,this._propertyTrackData=null}GetWorldInfoChange(){return this._worldInfoChange}GetRenderChange(){return this._renderChange}GetNeedsBeforeAndAfter(){return this._needsBeforeAndAfter}HasAbsoluteValueObject(){return!!this._absoluteValueObject}SetAbsoluteValueObject(e){this._absoluteValueObject=e}GetAbsoluteValueObject(){return this._absoluteValueObject}GetTrack(){return this._track}GetPropertyTrackDataItem(){return this._propertyTrackDataItem}GetPropertyTrackData(){return this._propertyTrackData}GetTimeline(){return this._track.GetTimeline()}GetRuntime(){return this._track.GetRuntime()}GetInstance(){return this._track.GetInstance()}GetSourceAdapter(){if(!this._sourceAdapter){let e=this._propertyTrackDataItem.GetSourceAdapterId(),t;switch(e){case"behavior":t=new C33.PropertyTrackState.BehaviorSourceAdapter(this);break;case"effect":t=new C33.PropertyTrackState.EffectSourceAdapter(this),this._renderChange=1;break;case"instance-variable":t=new C33.PropertyTrackState.InstanceVariableSourceAdapter(this);break;case"plugin":t=new C33.PropertyTrackState.PluginSourceAdapter(this),this._renderChange=1;break;case"world-instance":t=new C33.PropertyTrackState.PropertySourceAdapter(this),this._renderChange=1,this._worldInfoChange=1;break;case"value":t=new C33.PropertyTrackState.ValueSourceAdapter(this);break;case"audio":t=new C33.PropertyTrackState.AudioSourceAdapter(this)}this._sourceAdapter=t}return this._sourceAdapter}GetSourceAdapterId(){return this._propertyTrackDataItem.GetSourceAdapterId()}SetSourceAdapterId(e){this._propertyTrackDataItem.SetSourceAdapterId(e)}GetSourceAdapterArgs(){return this._propertyTrackDataItem.GetSourceAdapterArguments()}SetSourceAdapterArgs(e){this._propertyTrackDataItem.SetSourceAdapterArguments(e)}GetSourceAdapterValue(){return this.GetSourceAdapter().GetValue()}GetPropertyName(){return this._propertyTrackDataItem.GetProperty()}SetPropertyName(e){this._propertyTrackDataItem.SetProperty(e)}GetPropertyType(){return this._propertyTrackDataItem.GetType()}SetPropertyType(e){this._propertyTrackDataItem.SetType(e)}GetPropertyKeyframeType(){return this.GetPropertyTrackData().GetFirstPropertyKeyframeDataItem(this._propertyTrackDataItem).GetType()}GetMin(){return this._propertyTrackDataItem.GetMin()}SetMin(e){this._propertyTrackDataItem.SetMin(e)}GetMax(){return this._propertyTrackDataItem.GetMax()}SetMax(e){this._propertyTrackDataItem.SetMax(e)}GetEnable(){return this._propertyTrackDataItem.GetEnable()}SetEnable(e){this._propertyTrackDataItem.SetEnable(e)}GetInterpolationMode(){return this._propertyTrackDataItem.GetInterpolationMode()}SetInterpolationMode(e){this._propertyTrackDataItem.SetInterpolationMode(e)}GetResultMode(){return this._propertyTrackDataItem.GetResultMode()}SetResultMode(e){this._propertyTrackDataItem.SetResultMode(e)}SetEase(e){for(const t of this.GetPropertyKeyframeDataItems())t.SetEase(e)}CanHavePropertyKeyframes(){return this._propertyTrackDataItem.CanHavePropertyKeyframes()}GetPropertyKeyframeDataItems(){return this._propertyKeyframeDataItems||(this._propertyKeyframeDataItems=this._propertyTrackDataItem.GetPropertyKeyframeData().GetPropertyKeyframeDataItemArray()),this._propertyKeyframeDataItems}GetPropertyKeyframeDataItemArrayIncludingDisabled(){return this._propertyTrackDataItem.GetPropertyKeyframeData().GetPropertyKeyframeDataItemArrayIncludingDisabled()}GetPropertyKeyFrameDataItemAtTime(e){return this._propertyTrackData.GetPropertyKeyFrameDataItemAtTime(e,this._propertyTrackDataItem)}GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e){return this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,this._propertyTrackDataItem)}GetPropertyKeyframeDataItemPairForTime(e){let t=this._propertyTrackData.GetPropertyKeyFrameDataItemAtTime(e,this._propertyTrackDataItem),s;return s=t?this._propertyTrackData.GetFirstPropertyKeyFrameDataItemHigherThan(e,this._propertyTrackDataItem):(t=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,this._propertyTrackDataItem),this._propertyTrackData.GetFirstPropertyKeyFrameDataItemHigherOrEqualThan(e,this._propertyTrackDataItem)),{start:t,end:s}}*GetPropertyKeyframeValues(){for(const e of this.GetPropertyKeyframeDataItems())yield e.GetValueWithResultMode()}*GetPropertyKeyframeTimes(){for(const e of this.GetPropertyKeyframeDataItems())yield e.GetTime()}TimelineRemoved(){this.GetSourceAdapter().TimelineRemoved()}CleanCaches(){this.GetSourceAdapter().CleanCaches()}GetCurrentState(){return this.GetSourceAdapter().GetCurrentState()}SetResetState(){this.GetSourceAdapter().SetResetState()}SetInitialState(e){this.GetSourceAdapter().SetInitialState(),this._lastPropertyKeyframeDataItem=this._GetLastPropertyKeyFrameBeforeTime(e),this._SetUpdateState()}SetResumeState(e){this.GetSourceAdapter().SetResumeState(),this._lastPropertyKeyframeDataItem=this._GetLastPropertyKeyFrameBeforeTime(e)}_SetUpdateState(){const e=this.GetTrack();if(this._needsBeforeAndAfter=0,e.IsInstanceTrack()){const t=this.GetTimeline(),s=e.GetInstance(),i=this.GetSourceAdapter(),n=this.GetPropertyName(),r=i.MayNeedBeforeAndAfterInterpolate();if(r){const a=t.GetSimilarPropertyTracks(s,i,n,this);a&&a.length&&(this._needsBeforeAndAfter=1)}else this._needsBeforeAndAfter=0}}_GetLastPropertyKeyFrameBeforeTime(e){const t=this.GetTimeline(),s=this._propertyTrackData.GetPropertyKeyFrameDataItemAtTime(e,this._propertyTrackDataItem);return s||(t.IsForwardPlayBack()?this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,this._propertyTrackDataItem):this._propertyTrackData.GetFirstPropertyKeyFrameDataItemHigherOrEqualThan(e,this._propertyTrackDataItem))}BeforeInterpolate(){this._sourceAdapter.BeforeInterpolate()}Interpolate(e,t=!1,s=!1,i=!1){let n,r,a=!1;if(t)n=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,this._propertyTrackDataItem);else{if(this._lastPropertyKeyframeDataItem){const o=this.GetTimeline(),l=this._lastPropertyKeyframeDataItem.GetNext(),h=this._lastPropertyKeyframeDataItem.GetTime(),c=l?l.GetTime():o.GetTotalTime();(e<=h||c<=e)&&(this._lastPropertyKeyframeDataItem=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,this._propertyTrackDataItem),a=!0)}else this._lastPropertyKeyframeDataItem=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,this._propertyTrackDataItem),a=!0;n=this._lastPropertyKeyframeDataItem}n&&(r=n.GetNext()),this._sourceAdapter.Interpolate(e,n,r,t,s,i,a)}GetInterpolatedValue(e){if(this._lastPropertyKeyframeDataItem){const i=this.GetTimeline(),n=this._lastPropertyKeyframeDataItem.GetNext(),r=this._lastPropertyKeyframeDataItem.GetTime(),a=n?n.GetTime():i.GetTotalTime();(e<=r||a<=e)&&(this._lastPropertyKeyframeDataItem=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,this._propertyTrackDataItem))}else this._lastPropertyKeyframeDataItem=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,this._propertyTrackDataItem);const t=this._lastPropertyKeyframeDataItem,s=t.GetNext();return this._sourceAdapter.GetInterpolatedValue(e,t,s)}GetInterpolatedValueFast(e,t,s){return this._sourceAdapter.GetInterpolatedValue(e,t,s)}AfterInterpolate(){this._sourceAdapter.AfterInterpolate()}static GetStartPropertyKeyframeForTime(e,t){const s=t.GetPropertyTrackDataItem(),i=t._propertyTrackData;return i.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,s)}static GetEndPropertyKeyframeForTime(e,t){const s=t.GetPropertyTrackDataItem(),i=t._propertyTrackData;return i.GetFirstPropertyKeyFrameDataItemHigherOrEqualThan(e,s)}AddPropertyKeyframe(){const e=this._propertyTrackDataItem.GetPropertyKeyframeData(),t=e.AddEmptyPropertyKeyframeDataItem();return this._lastPropertyKeyframeDataItem=null,t}DeletePropertyKeyframes(e){this._lastPropertyKeyframeDataItem=null;const t=this._propertyTrackDataItem.GetPropertyKeyframeData();t.DeletePropertyKeyframeDataItems(e)}SaveState(){this.GetSourceAdapter().SaveState()}CompareInitialStateWithCurrent(){const e=this.GetSourceAdapter().CompareInitialStateWithCurrent();if(e){const t=this._propertyTrackData.GetFirstPropertyKeyframeDataItem(this._propertyTrackDataItem),s=this.GetSourceAdapter().GetCurrentState();t.SetAbsoluteValue(s)}}CompareSaveStateWithCurrent(){const e=this.GetSourceAdapter().CompareSaveStateWithCurrent();return e&&this.AddPropertyKeyframeAtCurrentTime(),this.GetSourceAdapter().ClearSaveState(),e}AddPropertyKeyframeAtCurrentTime(){const e=this.GetTimeline().GetTime(),t=this.GetSourceAdapter(),s=C33.PropertyTrackState.GetStartPropertyKeyframeForTime(e,this),i=this.AddPropertyKeyframe();i.SetType(s.GetType()),i.SetTime(e),i.SetEase(s.GetEase()),i.SetEnable(!0),i.SetValue(t.GetValueAtTime()),i.SetAbsoluteValue(t.GetCurrentState())}_SaveToJson(){return{sourceAdapterJson:this.GetSourceAdapter()._SaveToJson()}}_LoadFromJson(e){e&&this.GetSourceAdapter()._LoadFromJson(e.sourceAdapterJson)}}}{const C33=self.C3,NS=C33.PropertyTrackState;NS.PropertySourceAdapter=class{constructor(e){this._propertyTrack=e,this._propertyAdapter=null,this.GetPropertyAdapter()}Release(){this._propertyAdapter&&(this._propertyAdapter.Release(),this._propertyAdapter=null),this._propertyTrack=null}MayNeedBeforeAndAfterInterpolate(){return this._propertyAdapter.MayNeedBeforeAndAfterInterpolate()}GetPropertyTrack(){return this._propertyTrack}TimelineRemoved(){this._propertyAdapter&&this._propertyAdapter.TimelineRemoved()}CleanCaches(){this._propertyAdapter&&this._propertyAdapter.CleanCaches()}GetPropertyAdapter(){return this._propertyAdapter||(this._propertyAdapter=this._CreatePropertyAdapter()),this._propertyAdapter}GetEditorIndex(){}GetIndex(){return this.GetEditorIndex()}GetTarget(){}SetResetState(){this.GetPropertyAdapter().SetResetState()}SetInitialState(){this.GetPropertyAdapter().SetInitialState()}SetResumeState(){this.GetPropertyAdapter().SetResumeState()}BeforeInterpolate(){this._propertyAdapter.BeforeChangeProperty()}Interpolate(e,t,s,i,n,r,a){let o=this._propertyTrack.GetPropertyKeyframeType(),l;switch(o){case"numeric":l=NS.NumericTypeAdapter.Interpolate(e,t,s,this._propertyTrack);break;case"angle":l=NS.AngleTypeAdapter.Interpolate(e,t,s,this._propertyTrack);break;case"boolean":l=NS.BooleanTypeAdapter.Interpolate(e,t,s,this._propertyTrack);break;case"color":l=NS.ColorTypeAdapter.Interpolate(e,t,s,this._propertyTrack);break;case"text":l=NS.TextTypeAdapter.Interpolate(e,t,s,this._propertyTrack)}this._propertyAdapter.ChangeProperty(e,l,t,s,i,n,r,a)}GetInterpolatedValue(e,t,s){switch(this._propertyTrack.GetPropertyKeyframeType()){case"numeric":return NS.NumericTypeAdapter.Interpolate(e,t,s,this._propertyTrack);case"angle":return NS.AngleTypeAdapter.Interpolate(e,t,s,this._propertyTrack);case"boolean":return NS.BooleanTypeAdapter.Interpolate(e,t,s,this._propertyTrack);case"color":return NS.ColorTypeAdapter.Interpolate(e,t,s,this._propertyTrack);case"text":return NS.TextTypeAdapter.Interpolate(e,t,s,this._propertyTrack)}}AfterInterpolate(){this._propertyAdapter.AfterChangeProperty()}SaveState(){this.GetPropertyAdapter().SetSaveState()}ClearSaveState(){this.GetPropertyAdapter().ClearSaveState()}GetCurrentState(){return this.GetPropertyAdapter().GetCurrentState()}CompareInitialStateWithCurrent(){return this.GetPropertyAdapter().CompareInitialStateWithCurrent()}CompareSaveStateWithCurrent(){return this.GetPropertyAdapter().CompareSaveStateWithCurrent()}GetValueAtTime(){const e=this._propertyTrack,t=e.GetTrack(),s=t.GetTimeline().GetTime(),i=NS.GetStartPropertyKeyframeForTime(s,e),n=i.GetNext(),r=e.GetPropertyKeyframeType();switch(r){case"numeric":return NS.NumericTypeAdapter.Interpolate(s,i,n,e);case"angle":return NS.AngleTypeAdapter.Interpolate(s,i,n,e);case"boolean":return NS.BooleanTypeAdapter.Interpolate(s,i,n,e);case"color":return NS.ColorTypeAdapter.Interpolate(s,i,n,e);case"text":return NS.TextTypeAdapter.Interpolate(s,i,n,e)}}_CreatePropertyAdapter(){const e=this._propertyTrack,t=e.CanHavePropertyKeyframes()?e.GetPropertyKeyframeType():"";switch(t){case"combo":case"boolean":case"text":case"string":return new NS.PropertyInterpolationAdapter.NoInterpolationAdapter(this);case"numeric":case"number":case"angle":return new("combo"===this._propertyTrack.GetPropertyType()?NS.PropertyInterpolationAdapter.NoInterpolationAdapter:NS.PropertyInterpolationAdapter.NumericInterpolationAdapter)(this);case"color":case"offsetColor":return new NS.PropertyInterpolationAdapter.ColorInterpolationAdapter(this);default:return new NS.PropertyInterpolationAdapter.NumericInterpolationAdapter(this)}}_SaveToJson(){return{propertyAdapterJson:this.GetPropertyAdapter()._SaveToJson()}}_LoadFromJson(e){e&&this.GetPropertyAdapter()._LoadFromJson(e.propertyAdapterJson)}}}{const C33=self.C3,INDEX=0;class InstanceVariableSourceAdapter extends C33.PropertyTrackState.PropertySourceAdapter{constructor(e){super(e),this._updatedIndex=NaN}GetEditorIndex(){return this._propertyTrack.GetPropertyTrackDataItem().GetSourceAdapterArguments()[INDEX]}GetIndex(){return this._updatedIndex||super.GetIndex()}GetTarget(){return this._propertyTrack.GetTrack().GetInstance()}UpdateInstanceVariableIndex(e){const t=this._propertyTrack.GetPropertyTrackDataItem().GetSourceAdapterArguments()[INDEX];t!==e&&(this._updatedIndex=e)}Interpolate(e,t,s,i,n,r,a){this.GetPropertyAdapter().CanChange(t.GetValue())&&super.Interpolate(e,t,s,i,n,r,a)}GetInterpolatedValue(e,t,s){if(this.GetPropertyAdapter().CanChange(t.GetValue()))return super.GetInterpolatedValue(e,t,s)}_SaveToJson(){return Object.assign(super._SaveToJson(),{index:this._updatedIndex})}_LoadFromJson(e){e&&(super._LoadFromJson(e),this._updatedIndex=e.index)}}C33.PropertyTrackState.InstanceVariableSourceAdapter=InstanceVariableSourceAdapter}{const C33=self.C3,SID=0,INDEX=1,NAME=2;class BehaviorSourceAdapter extends C33.PropertyTrackState.PropertySourceAdapter{constructor(e){super(e),this._sid=NaN}GetEditorIndex(){const e=this._propertyTrack.GetPropertyTrackDataItem();return e.GetSourceAdapterArguments()[INDEX]}GetTarget(){const e=this._propertyTrack.GetPropertyTrackDataItem(),t=this._propertyTrack.GetTrack(),s=this._sid||e.GetSourceAdapterArguments()[SID],i=t.GetInstance(),n=i.GetBehaviorIndexBySID(s),r=i.GetBehaviorInstances()[n];return r.GetSdkInstance()}GetBehaviorType(e){const t=this._propertyTrack.GetPropertyTrackDataItem(),s=t.GetSourceAdapterArguments()[NAME];return e.GetBehaviorTypeByName(s)}UpdateBehaviorTypeSid(e){const t=this._propertyTrack.GetPropertyTrackDataItem();t.GetSourceAdapterArguments()[SID]!==e&&(this._sid=e)}Interpolate(e,t,s,i,n,r,a){const o=this._propertyTrack.GetTrack(),l=o.GetInstance();this.GetBehaviorType(l.GetObjectClass())&&super.Interpolate(e,t,s,i,n,r,a)}GetInterpolatedValue(e,t,s){const i=this._propertyTrack.GetTrack(),n=i.GetInstance();if(this.GetBehaviorType(n.GetObjectClass()))return super.GetInterpolatedValue(e,t,s)}_SaveToJson(){return Object.assign(super._SaveToJson(),{sid:this._sid})}_LoadFromJson(e){e&&(super._LoadFromJson(e),this._sid=e.sid)}}C33.PropertyTrackState.BehaviorSourceAdapter=BehaviorSourceAdapter}{const C33=self.C3,NAME=0,INDEX=1;class EffectSourceAdapter extends C33.PropertyTrackState.PropertySourceAdapter{constructor(e){super(e)}GetEditorIndex(){return this._propertyTrack.GetPropertyTrackDataItem().GetSourceAdapterArguments()[INDEX]}GetTarget(){const e=this._propertyTrack,t=e.GetTrack(),s=t.GetWorldInfo(),i=s.GetInstanceEffectList(),n=i.GetEffectList(),r=this.GetEffectType(n),a=r.GetIndex();return i.IsEffectIndexActive(a)?i.GetEffectParametersForIndex(a):null}GetEffectType(e){const t=this._propertyTrack,s=t.GetPropertyTrackDataItem().GetSourceAdapterArguments()[NAME];return e.GetEffectTypeByName(s)}Interpolate(e,t,s,i,n,r,a){this._IsEffectActive()&&super.Interpolate(e,t,s,i,n,r,a)}GetInterpolatedValue(e,t,s){if(this._IsEffectActive())return super.GetInterpolatedValue(e,t,s)}_IsEffectActive(){const e=this._propertyTrack,t=e.GetTrack(),s=t.GetWorldInfo(),i=s.GetInstanceEffectList(),n=i.GetEffectList(),r=this.GetEffectType(n);if(r){const a=r.GetIndex();return i.IsEffectIndexActive(a)}}}C33.PropertyTrackState.EffectSourceAdapter=EffectSourceAdapter}{const C33=self.C3,INDEX=0;class PluginSourceAdapter extends C33.PropertyTrackState.PropertySourceAdapter{constructor(e){super(e)}GetEditorIndex(){return this._propertyTrack.GetPropertyTrackDataItem().GetSourceAdapterArguments()[INDEX]}GetTarget(){return this._propertyTrack.GetTrack().GetInstance().GetSdkInstance()}Interpolate(e,t,s,i,n,r,a){const o=this._propertyTrack.GetTrack(),l=o.GetObjectClass().GetPlugin(),h=o.GetInstance().GetObjectClass().GetPlugin();l===h&&super.Interpolate(e,t,s,i,n,r,a)}GetInterpolatedValue(e,t,s){const i=this._propertyTrack.GetTrack(),n=i.GetObjectClass().GetPlugin(),r=i.GetInstance().GetObjectClass().GetPlugin();if(n===r)return super.GetInterpolatedValue(e,t,s)}GetOptionalCallbacks(){const e=this._propertyTrack.GetTrack(),t=e.GetObjectClass().GetPlugin();if(C33.Plugins.Sprite&&t instanceof C33.Plugins.Sprite&&("initial-frame"===this._propertyTrack.GetPropertyName()||"initial-animation"===this._propertyTrack.GetPropertyName()))switch(this._propertyTrack.GetResultMode()){case"relative":case"absolute":return null}}}C33.PropertyTrackState.PluginSourceAdapter=PluginSourceAdapter}{const C33=self.C3;class ValueSourceAdapter extends C33.PropertyTrackState.PropertySourceAdapter{constructor(e){super(e),this._value=0,this._init=!1}MayNeedBeforeAndAfterInterpolate(){return!1}SetInitialState(){let e=this._propertyTrack.GetPropertyTrackData(),t=this._propertyTrack.GetPropertyTrackDataItem();t=e.GetFirstPropertyKeyframeDataItem(t),this._value=t.GetValueWithResultMode()}SetResumeState(){}GetValue(){return this._init||this._propertyTrack.Interpolate(0),this._value}Interpolate(e,t,s,i,n,r,a){this._value=C33.PropertyTrackState.NumericTypeAdapter.Interpolate(e,t,s,this._propertyTrack),this._init=!0}SaveState(){}ClearSaveState(){}GetCurrentState(){return this._value}CompareInitialStateWithCurrent(){return!1}CompareSaveStateWithCurrent(){return!1}_SaveToJson(){return{value:this._value,init:this._init}}_LoadFromJson(e){e&&(this._value=e.value,this._init=!e.hasOwnProperty("init")||e.init)}}C33.PropertyTrackState.ValueSourceAdapter=ValueSourceAdapter}{const C33=self.C3,PROJECT_FILE=0,PROJECT_FILE_NAME=0,PROJECT_FILE_TYPE=1,START_OFFSET=1,AUDIO_DURATION=2,AUDIO_TAG=3;class AudioSourceAdapter extends C33.PropertyTrackState.PropertySourceAdapter{constructor(e){super(e),this._audioPlaybackStarted=!1,this._sdkInstance=null,this._actions=null,this._expressions=null,this._timeline=this._propertyTrack.GetTimeline(),this._track=this._propertyTrack.GetTrack(),this._sourceAdapterArgs=this._propertyTrack.GetSourceAdapterArgs(),this._fileArgs=this._sourceAdapterArgs[PROJECT_FILE],this._startOffsetTime=this._sourceAdapterArgs[START_OFFSET],this._sourceAdapterArgs[AUDIO_TAG]?this._audioTag=this._sourceAdapterArgs[AUDIO_TAG]:this._audioTag=Math.random().toString(36).slice(2),this._pauseTime=NaN,this._pauseVolume=NaN,this._volume=NaN,this._audioSource=null,this._Initialize()}Release(){super.Release(),this._sdkInstance=null,this._actions=null,this._expressions=null,this._timeline=null,this._track=null,this._sourceAdapterArgs=null,this._fileArgs=null,this._audioSource=null}_Initialize(){if(self.C3.Plugins.Audio){const e=this._propertyTrack.GetRuntime(),t=e.GetSingleGlobalObjectClassByCtor(self.C3.Plugins.Audio);t&&(this._sdkInstance=t.GetSingleGlobalInstance().GetSdkInstance()),this._actions=self.C3.Plugins.Audio.Acts,this._expressions=self.C3.Plugins.Audio.Exps}}_MaybeSetAudioSource(){if(!this._audioSource){const e=this._propertyTrack.GetTrack(),t=e.GetPropertyTrack("audioSource");t&&(this._audioSource=t.GetSourceAdapter())}}_GetPauseVolume(){const e=this._propertyTrack.GetTrack(),t=e.GetPropertyTrack("volume");return(t?t.GetSourceAdapter():this)._pauseVolume}TimelineRemoved(){super.TimelineRemoved(),this._audioPlaybackStarted=!1,this._sdkInstance&&(this._expressions&&(this._pauseTime=this._expressions.PlaybackTime.call(this._sdkInstance,this._audioTag),this._pauseVolume=this._expressions.Volume.call(this._sdkInstance,this._audioTag)),this._actions)&&this._actions.Stop.call(this._sdkInstance,this._audioTag)}GetAudioTag(){return this._audioTag}GetVolume(){return this._volume}SetVolume(e){this._volume=e}SetInitialState(){super.SetInitialState(),this._pauseTime=NaN,this._audioPlaybackStarted=!1}SetResumeState(){super.SetResumeState();const e=this._propertyTrack.GetTimeline(),t=e.GetTime();switch(this._pauseTime=t-this._startOffsetTime,this._propertyTrack.GetPropertyName()){case"audioSource":break;case"volume":this._pauseVolume=this._propertyTrack.GetInterpolatedValue(t)}this._audioPlaybackStarted=!1}Interpolate(e,t,s,i,n,r,a){if(this._sdkInstance)switch(this._propertyTrack.GetPropertyName()){case"audioSource":{if(!this._timeline.IsForwardPlayBack())return;if(i)return void(this._actions&&this._actions.Stop.call(this._sdkInstance,this._audioTag));if(e<this._startOffsetTime)return void(this._audioPlaybackStarted=!1);const o=this._expressions.PlaybackRate.call(this._sdkInstance,this._audioTag),l=this._timeline.GetPlaybackRate();if(l!==o&&this._actions.SetPlaybackRate.call(this._sdkInstance,this._audioTag,l),this._audioPlaybackStarted)return;if(!this._propertyTrack.GetTimeline().IsPlaying())return;if(this._audioPlaybackStarted=!0,isNaN(this._pauseTime)){const h=self.performance.now(),c=e-this._startOffsetTime,u=this._sdkInstance.GetAudioContextState();if("suspended"===u)return void(this._audioPlaybackStarted=!1);const _=self.performance.now(),d=(_-h)/1e3,p=c+d;if(this._actions){let e=this.GetVolume();isNaN(e)?(this.SetVolume(0),e=0):this.SetVolume(e),this._actions.PlayFromTimeline.call(this._sdkInstance,this._fileArgs,e,this._audioTag,p)}}else{const m=this._pauseTime,g=(this._pauseTime=NaN,this._GetPauseVolume()),f=(this._pauseVolume=NaN,this._sdkInstance.GetAudioContextState());if("suspended"===f)return void(this._audioPlaybackStarted=!1);this._actions&&(this.SetVolume(g),this._actions.PlayFromTimeline.call(this._sdkInstance,this._fileArgs,g,this._audioTag,m))}break}case"volume":this._MaybeSetAudioSource(),super.Interpolate(e,t,s,i,n,r,a)}}GetInterpolatedValue(e,t,s){if(this._sdkInstance)switch(this._propertyTrack.GetPropertyName()){case"audioSource":return;case"volume":return this._MaybeSetAudioSource(),super.GetInterpolatedValue(e,t,s)}}Getter(e,t){return this._audioSource?this._audioSource.GetVolume():0}Setter(e,t,s,i){this._audioSource&&this._audioSource.SetVolume(this.Getter()+t),this._actions&&this._audioSource&&this._actions.SetVolume.call(this._sdkInstance,this._audioSource.GetAudioTag(),this._audioSource.GetVolume())}AbsoluteSetter(e,t,s){this._audioSource&&this._audioSource.SetVolume(t),this._actions&&this._audioSource&&this._actions.SetVolume.call(this._sdkInstance,this._audioSource.GetAudioTag(),this._audioSource.GetVolume())}DoesRounding(){return!0}_SaveToJson(){return{audioPlaybackStarted:this._audioPlaybackStarted,audioTag:this._audioTag,pauseTime:this._pauseTime,pauseVolume:this._pauseVolume,volume:this._volume}}_LoadFromJson(e){e&&(this._audioPlaybackStarted=e.audioPlaybackStarted,this._audioTag=e.audioTag,this._pauseTime=e.pauseTime,this._pauseVolume=e.pauseVolume,this._volume=e.volume,this._Initialize())}}C33.PropertyTrackState.AudioSourceAdapter=AudioSourceAdapter}{const C33=self.C3;C33.PropertyTrackState.PropertyInterpolationAdapter=class{constructor(e){this._sourceAdapter=e,this._propertyTrack=e.GetPropertyTrack(),this._worldInfo=this._propertyTrack.GetTrack().GetWorldInfo(),this._property=this._propertyTrack.GetPropertyName(),this._firstAbsoluteUpdate=!1,this._saveState=null,this._target=null}Release(){this._sourceAdapter=null,this._propertyTrack=null,this._worldInfo=null,this._saveState=null,this._target=null}MayNeedBeforeAndAfterInterpolate(){return!1}TimelineRemoved(){}CleanCaches(){this._worldInfo=null,this._saveState=null,this._target=null}GetSourceAdapter(){return this._sourceAdapter}GetPropertyTrack(){return this._propertyTrack}GetWorldInfo(){return this._worldInfo||(this._worldInfo=this._propertyTrack.GetTrack().GetWorldInfo()),this._worldInfo}SetFirstAbsoluteUpdate(e){this._firstAbsoluteUpdate=!!e}GetFirstAbsoluteUpdate(){return this._firstAbsoluteUpdate}SetResetState(){}SetInitialState(){}SetResumeState(){}SetSaveState(){this._saveState=this.GetCurrentState()}ClearSaveState(){this._saveState=null}GetCurrentState(){}CompareInitialStateWithCurrent(){}CompareSaveStateWithCurrent(){}CanChange(e){const t=typeof this._Getter(),s=typeof e;return t==s}BeforeChangeProperty(){}ChangeProperty(e,t,s,i,n,r,a,o){}AfterChangeProperty(){}_FirstKeyframeGetter(){const e=this._PickTimelinePlaybackMode(()=>{const e=this._propertyTrack.GetPropertyTrackDataItem(),t=this._propertyTrack.GetPropertyTrackData();return t.GetFirstPropertyKeyframeDataItem(e)},()=>{const e=this._propertyTrack.GetPropertyTrackDataItem(),t=this._propertyTrack.GetPropertyTrackData();return t.GetLastPropertyKeyframeDataItem(e)});return e.GetAbsoluteValue()}_CurrentKeyframeGetter(){const e=this._propertyTrack.GetTimeline(),i=e.GetTime()-this._propertyTrack.GetTrack().GetStartOffset(),t=this._PickTimelinePlaybackMode(()=>{const e=this._propertyTrack.GetPropertyTrackDataItem(),t=this._propertyTrack.GetPropertyTrackData();return t.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(i,e)},()=>{const e=this._propertyTrack.GetPropertyTrackDataItem(),t=this._propertyTrack.GetPropertyTrackData(),s=t.GetFirstPropertyKeyFrameDataItemHigherOrEqualThan(i,e);return s||t.GetLastPropertyKeyframeDataItem(e)});return t.GetAbsoluteValue()}_PickTimelinePlaybackMode(e,t){const s=this._propertyTrack.GetTimeline();return(s.IsForwardPlayBack()?e:t)()}_PickResultMode(e,t){const s=this._propertyTrack.GetResultMode();return("relative"===s?e:t)()}_PickFirstAbsoluteUpdate(e,t){return(this.GetFirstAbsoluteUpdate()?(this.SetFirstAbsoluteUpdate(!1),e):t)()}_GetAbsoluteInitialValue(e){}_GetIndex(){return this._sourceAdapter.GetIndex()}_GetTarget(){return this._target||(this._target=this._sourceAdapter.GetTarget()),this._target}_PickSource(e,t,s,i,n,r){const a=this._propertyTrack.GetSourceAdapterId();switch(a){case"behavior":return e();case"effect":return t();case"instance-variable":return s();case"plugin":return i();case"world-instance":return n();case"audio":return r()}}_SaveToJson(){return{firstAbsoluteUpdate:this._firstAbsoluteUpdate,saveState:this._saveState}}_LoadFromJson(e){e&&(this._firstAbsoluteUpdate=e.firstAbsoluteUpdate,this._saveState=e.saveState)}_GetPropertyKeyframeStubs(e,t=!1){const s=[];for(const i of e){const n=i.GetTrack().GetStartOffset();for(const r of i.GetPropertyKeyframeDataItems())(t&&0===r.GetTime()||!t)&&s.push({time:n+r.GetTime(),value:r.GetAbsoluteValue()})}return s.sort((e,t)=>e.time-t.time)}_GetLastPropertyKeyframeStub(e,t,s){return this._GetPropertyKeyframeStubLowerThanPlayhead(t,s)}_GetPropertyKeyframeStubLowerThanPlayhead(t,s){for(let e=s.length-1;0<=e;e--){const i=s[e].time;if(i<=t)return s[e]}return null}}}{const C33=self.C3,TMP_COLORS_MAP=new Map,TMP_COLOR=[0,0,0];class ColorInterpolationAdapter extends C33.PropertyTrackState.PropertyInterpolationAdapter{constructor(e){super(e)}SetResetState(){}SetInitialState(){}SetResumeState(){}GetCurrentState(){const e=this._propertyTrack.GetSourceAdapterId(),t=this._GetTarget(),s=this._GetIndex();switch(e){case"behavior":return this._ToColorArray(t.GetPropertyValueByIndex(s));case"effect":return this._ToColorArray(t[s]);case"plugin":return this._ToColorArray(t.GetPropertyValueByIndex(s));case"world-instance":return this._ToColorArray(this._Getter())}}CompareInitialStateWithCurrent(){const e=this._FirstKeyframeGetter();return!this._CompareColors(e,this._Getter())}CompareSaveStateWithCurrent(){return!C33.IsNullOrUndefined(this._saveState)&&!this._CompareColors(this._saveState,this._Getter())}_CompareColors(e,t){return e=this._GetColorFromArray(e),t=this._GetColorFromArray(t),e.equalsIgnoringAlpha(t)}_FirstKeyframeGetter(){const e=super._FirstKeyframeGetter();return this._GetColorFromArray(e)}_CurrentKeyframeGetter(){const e=super._CurrentKeyframeGetter();return this._GetColorFromArray(e)}_GetAbsoluteInitialValue(e){}_ToColorArray(e){return(C33.IsInstanceOf(e,C33.Color)?e.toArray():e).slice(0,3)}_GetColorFromArray(e){return C33.IsInstanceOf(e,C33.Color)?e:new C33.Color(e[0],e[1],e[2],1)}CanChange(e){return!0}MayNeedBeforeAndAfterInterpolate(){return!0}BeforeChangeProperty(){const e=this._propertyTrack.GetTimeline(),t=this._propertyTrack.GetInstance(),s=this._propertyTrack.GetSourceAdapter(),i=e.GetSimilarPropertyTracks(t,s,this._property,this._propertyTrack);if(i&&1<i.length){TMP_COLORS_MAP.has(t)||TMP_COLORS_MAP.set(t,new Map);const n=TMP_COLORS_MAP.get(t),r=this._propertyTrack.GetSourceAdapterId(),a=(n.has(r)||n.set(r,new Map),n.get(r));a.has(this._property)||a.set(this._property,{used:!1,color:new C33.Color(0,0,0,1)})}}_GetTmpColor(e,t,s){const i=TMP_COLORS_MAP.get(e).get(t).get(s);return i.used=!0,i.color}ChangeProperty(e,t,s,i,n,r,a,o){const l=this._propertyTrack.GetTimeline(),h=this._propertyTrack.GetTrack(),c=this._propertyTrack.GetInstance(),u=this._propertyTrack.GetSourceAdapter(),_=this._propertyTrack.GetSourceAdapterId(),d=this._property,p=l.GetSimilarPropertyTracks(c,u,d,this._propertyTrack);if(p&&1<p.length){const m=this._GetPropertyKeyframeStubs(p,!0),g=this._GetLastPropertyKeyframeStub(l,l.GetTime(),m);if(g){const f=h.GetStartOffset(),S=g.time-f;if(0==S)this._GetTmpColor(c,_,this._property).addRgb(t[0],t[1],t[2]);else if(!(S<0)){const C=t[0],y=t[1],G=t[2],I=this._propertyTrack.Interpolate(S,!1,!0),T=C33.Color.DiffChannel(C,I[0]),b=C33.Color.DiffChannel(y,I[1]),P=C33.Color.DiffChannel(G,I[2]);this._GetTmpColor(c,_,this._property).addRgb(T,b,P)}}}else this._Setter(t[0],t[1],t[2])}AfterChangeProperty(){const e=this._propertyTrack.GetInstance();if(TMP_COLORS_MAP.has(e)){const t=TMP_COLORS_MAP.get(e),s=this._propertyTrack.GetSourceAdapterId();if(t.has(s)){const i=t.get(s);if(i.has(this._property)){const n=i.get(this._property),r=n.used,a=n.color;r&&this._Setter(a.getR(),a.getG(),a.getB()),0===i.size&&t.delete(s),0===t.size&&TMP_COLORS_MAP.delete(e)}}}}_Getter(){const e=this._propertyTrack.GetSourceAdapterId(),t=this._GetTarget(),s=this._GetIndex();switch(e){case"behavior":return this._GetColorFromArray(t.GetPropertyValueByIndex(s));case"effect":return t[s].clone();case"plugin":return this._GetColorFromArray(t.GetPropertyValueByIndex(s));case"world-instance":return this.GetWorldInfo().GetUnpremultipliedColor().clone()}}_Setter(e,t,s){const i=this._propertyTrack.GetSourceAdapterId(),n=this._GetTarget(),r=this._GetIndex();switch(i){case"behavior":TMP_COLOR[0]=e,TMP_COLOR[1]=t,TMP_COLOR[2]=s,n.SetPropertyValueByIndex(r,TMP_COLOR);break;case"effect":n[r].setRgb(e,t,s);break;case"plugin":TMP_COLOR[0]=e,TMP_COLOR[1]=t,TMP_COLOR[2]=s,n.SetPropertyValueByIndex(r,TMP_COLOR);break;case"world-instance":this.GetWorldInfo().SetUnpremultipliedColorRGB(e,t,s)}}_SaveToJson(){}_LoadFromJson(e){}}C33.PropertyTrackState.PropertyInterpolationAdapter.ColorInterpolationAdapter=ColorInterpolationAdapter}{const C33=self.C3,NS=C33.PropertyTrackState;class NoInterpolationAdapter extends C33.PropertyTrackState.PropertyInterpolationAdapter{constructor(e){super(e)}SetResetState(){}SetInitialState(){}SetResumeState(){}GetCurrentState(){return this._Getter()}CompareInitialStateWithCurrent(){const e=this._FirstKeyframeGetter();return e!==this.GetCurrentState()}CompareSaveStateWithCurrent(){return!C33.IsNullOrUndefined(this._saveState)&&this._saveState!==this.GetCurrentState()}MayNeedBeforeAndAfterInterpolate(){return!1}ChangeProperty(e,t,s,i,n,r,a,o){const l=this._propertyTrack,h=l.GetTrack(),c=l.GetSourceAdapterId(),u=l.GetTimeline(),_=h.GetInstance(),d=l.GetSourceAdapter(),p=this._property,m=u.GetSimilarPropertyTracks(_,d,p,l);if(m&&1<m.length){const f=this._GetPropertyKeyframeStubs(m),S=e+h.GetStartOffset(),C=this._GetLastPropertyKeyframeStub(u,S,f);C&&(t=C.value)}const g=l.GetPropertyKeyframeType();switch(g){case"numeric":if(NS.NumericTypeAdapter.WillChange(this._GetIndex(),this._GetTarget(),t,c))break;return;case"angle":if(NS.AngleTypeAdapter.WillChange(this._GetIndex(),this._GetTarget(),t,c))break;return;case"boolean":if(NS.BooleanTypeAdapter.WillChange(this._GetIndex(),this._GetTarget(),t,c))break;return;case"color":if(NS.ColorTypeAdapter.WillChange(this._GetIndex(),this._GetTarget(),t,c))break;return;case"text":if(!NS.TextTypeAdapter.WillChange(this._GetIndex(),this._GetTarget(),t,c))return}this._Setter(t)}_Getter(){const e=this._propertyTrack.GetSourceAdapterId(),t=this._GetTarget(),s=this._GetIndex();switch(e){case"behavior":return t.GetPropertyValueByIndex(s);case"effect":return t[s];case"instance-variable":return t.GetInstanceVariableValue(s);case"plugin":return t.GetPropertyValueByIndex(s)}}_Setter(e){const t=this._propertyTrack.GetSourceAdapterId(),s=this._GetTarget(),i=this._GetIndex();switch(t){case"behavior":s.SetPropertyValueByIndex(i,e);break;case"effect":s[i]=e;break;case"instance-variable":s.SetInstanceVariableValue(i,e);break;case"plugin":s.SetPropertyValueByIndex(i,e)}}}C33.PropertyTrackState.PropertyInterpolationAdapter.NoInterpolationAdapter=NoInterpolationAdapter}{const C33=self.C3,NS=C33.PropertyTrackState.PropertyInterpolationAdapter,INSTANCE_FUNC_MAP=new Map,add2=(e,t,s,i,n,r=!1,a=null,o=null)=>{INSTANCE_FUNC_MAP.set(e,{setter:t,absolute_setter:s,getter:i,round:n,fRound:r,init:a,reset:o})};add2("offsetX",(e,t,s,i)=>{"relative"===i._propertyTrack.GetResultMode()?e.OffsetX(t,s.GetTimeline().GetTransformWithSceneGraph()):e.OffsetX(t)},(e,t)=>e.SetX(t),e=>e.GetX(),!0),add2("offsetY",(e,t,s,i)=>{"relative"===i._propertyTrack.GetResultMode()?e.OffsetY(t,s.GetTimeline().GetTransformWithSceneGraph()):e.OffsetY(t)},(e,t)=>e.SetY(t),e=>e.GetY(),!0),add2("offsetWidth",(t,e,o,s,i)=>{if(0!==e){const n="relative"===s._propertyTrack.GetResultMode(),h=1===s._typeAdapter.GetType();if((n||h)&&t.HasParent()&&t.GetTransformWithParentWidth()){if(isNaN(s._absoluteToFactor)){let i=[],e=t.GetParent();for(;e;)i.push(e),e=e.GetParent();i.reverse();let l=(e,t)=>t.GetTimeline().GetTrackFromInstance(e.GetInstance()),n=(e,t)=>{const s=l(e,t);if(s)return s.GetOriginalWidth();const i=e.GetInstance().GetSdkInstance();return i.IsOriginalSizeKnown()?i.GetOriginalWidth():e._GetSceneGraphInfo()._GetStartWidth()},r=(e,t,s,i=0)=>{const n=l(e,t);if(!n)return i;const r=n.GetPropertyTrack(s);if(!r)return i;const a=r.GetPropertyTrackDataItem().GetPropertyKeyframeData();if(!a)return i;const o=a.GetLastPropertyKeyframeDataItem();return o?o.GetValue():i},a;if(h){let e=i[i.length-1];a=e.GetWidth()}else{let t=i[0],e=t._GetSceneGraphInfo()._GetStartWidth(),s=t._GetSceneGraphInfo().GetStartScaleX();a=e*s,a=(a+=r(t,o,"offsetWidth"))+n(t,o)*r(t,o,"offsetScaleX");for(let e=1;e<i.length;e++){const c=(t=i[e])._GetSceneGraphInfo().GetStartScaleX();a=(a=(a*=c)+r(t,o,"offsetWidth"))+n(t,o)*r(t,o,"offsetScaleX")}}s._absoluteToFactor=0===a?Number.EPSILON:a}i||t.OffsetWidth(e/s._absoluteToFactor,!0)}else t.OffsetWidth(e)}},(e,t)=>e.SetWidth(t),e=>e.GetWidth(),!0),add2("offsetHeight",(t,e,o,s,i)=>{if(0!==e){const n="relative"===s._propertyTrack.GetResultMode(),l=1===s._typeAdapter.GetType();if((n||l)&&t.HasParent()&&t.GetTransformWithParentHeight()){if(isNaN(s._absoluteToFactor)){let i=[],e=t.GetParent();for(;e;)i.push(e),e=e.GetParent();i.reverse();let n=(e,t)=>{i=e;const s=t.GetTimeline().GetTrackFromInstance(i.GetInstance());var i;if(s)return s.GetOriginalHeight();const n=e.GetInstance().GetSdkInstance();return n.IsOriginalSizeKnown()?n.GetOriginalHeight():e._GetSceneGraphInfo()._GetStartHeight()},r=(e,t,s,i=0)=>{const n=t.GetTimeline().GetTrackFromInstance(e.GetInstance());if(!n)return i;const r=n.GetPropertyTrack(s);if(!r)return i;const a=r.GetPropertyTrackDataItem().GetPropertyKeyframeData();if(!a)return i;const o=a.GetLastPropertyKeyframeDataItem();return o?o.GetValue():i},a;if(l){let e=i[i.length-1];a=e.GetHeight()}else{let t=i[0],e=t._GetSceneGraphInfo()._GetStartHeight(),s=t._GetSceneGraphInfo().GetStartScaleY();a=e*s,a=(a+=r(t,o,"offsetHeight"))+n(t,o)*r(t,o,"offsetScaleY");for(let e=1;e<i.length;e++){const h=(t=i[e])._GetSceneGraphInfo().GetStartScaleY();a=(a=(a*=h)+r(t,o))+n(t,o)*r(t,o,"offsetScaleY")}}s._absoluteToFactor=0===a?Number.EPSILON:a}i||t.OffsetHeight(e/s._absoluteToFactor,!0)}else t.OffsetHeight(e)}},(e,t)=>e.SetHeight(t),e=>e.GetHeight(),!0),add2("offsetAngle",(e,t,s,i,n)=>{e.OffsetAngle(t)},(e,t)=>e.SetAngle(t),e=>e.GetAngle(),!1,!0),add2("offsetOpacity",(e,t,s,i,n)=>{const r=i._opacityFactor||1,a=(t/=r,e.GetOpacity()),o=a+t;if(0===i._clampAccumulator)1<o?i._clampAccumulator+=o-1:o<0&&(i._clampAccumulator+=o),e.OffsetOpacity(t);else{const l=e.GetOpacity()+t;0<t&&0<i._clampAccumulator?1<l&&(i._clampAccumulator+=l-1):0<t&&i._clampAccumulator<0?(i._clampAccumulator+=t,0<i._clampAccumulator&&(e.OffsetOpacity(i._clampAccumulator),i._clampAccumulator=0)):t<0&&0<i._clampAccumulator?(i._clampAccumulator+=t,i._clampAccumulator<0&&(e.OffsetOpacity(i._clampAccumulator),i._clampAccumulator=0)):t<0&&i._clampAccumulator<0&&l<0&&(i._clampAccumulator+=l)}},(e,t)=>{e.SetOpacity(t)},e=>e.GetOpacity(),!1,!0,(r,n,a)=>{switch(r._clampAccumulator=0,r._propertyTrack.GetResultMode()){case"relative":{r._propertyTrack.GetPropertyTrackData();let e=r._propertyTrack.GetPropertyTrackDataItem(),t=e.GetPropertyKeyframeData(),s=t.GetPropertyKeyframeDataItemArray(),i=r.GetWorldInfo().GetOpacity(),n=i;for(const o of s){const l=o.GetTime(),h=r._propertyTrack.GetInterpolatedValue(l);n=i+h,n=C33.clamp(n,0,1)}r._totalForewardOpacityDelta=i-n,r._totalForewardOpacityDelta=Math.round(100*(r._totalForewardOpacityDelta+Number.EPSILON))/100,n=i;for(let e=s.length-1;0<=e;e--){const c=s[e].GetTime(),u=r._propertyTrack.GetInterpolatedValue(c);n-=u,n=C33.clamp(n,0,1)}r._totalBackwardOpacityDelta=n,r._totalBackwardOpacityDelta=Math.round(100*(r._totalBackwardOpacityDelta+Number.EPSILON))/100;break}}const e="relative"===r._propertyTrack.GetResultMode(),t=1===r._typeAdapter.GetType();if((e||t)&&n.HasParent()&&n.GetTransformWithParentOpacity()){let t=[],e=n.GetParent();for(;e;)t.push(e),e=e.GetParent();t.reverse();let s=(e,t,s)=>{const i=t.GetTimeline().GetTrackFromInstance(e.GetInstance());if(!i)return 0;const n=i.GetPropertyTrack(s);if(!n)return 0;const r=n.GetPropertyTrackDataItem().GetPropertyKeyframeData();if(!r)return 0;const a=r.GetLastPropertyKeyframeDataItem();return a?a.GetValue():0},i=t[0]._GetSceneGraphInfo().GetStartOpacity();i+=s(t[0],a,"offsetOpacity");for(let e=1;e<t.length;e++)i+=s(t[e],a,"offsetOpacity");r._opacityFactor=0===i?1:i}},s=>{switch(s._propertyTrack.GetResultMode()){case"relative":{s._clampAccumulator=0;let e=s.GetWorldInfo(),t=e.GetOpacity();t=Math.round(100*(t+Number.EPSILON))/100,s._propertyTrack.GetTimeline().IsForwardPlayBack()?(e.SetOpacity(t+s._totalForewardOpacityDelta),s._lastValue=0):(e.SetOpacity(t-s._totalBackwardOpacityDelta),s._lastValue=s.GetSourceAdapter().GetValueAtTime());break}}}),add2("offsetOriginX",(e,t)=>e.OffsetOriginX(t),(e,t)=>e.SetOriginX(t),e=>e.GetOriginX(),!1),add2("offsetOriginY",(e,t)=>e.OffsetOriginY(t),(e,t)=>e.SetOriginY(t),e=>e.GetOriginY(),!1),add2("offsetZElevation",(e,t)=>e.OffsetZElevation(t),(e,t)=>e.SetZElevation(t),e=>e.GetZElevation(),!0),add2("offsetScaleX",(e,t,s,i)=>{if(0!==t){const n=e.GetWidth()<0?-1:1;if("relative"===i._propertyTrack.GetResultMode()&&e.HasParent()&&e.GetTransformWithParentWidth()){const r=s.GetOriginalWidth()*n*t;isNaN(i._absoluteToFactor)&&INSTANCE_FUNC_MAP.get("offsetWidth").setter(e,1,s,i,!0),e.OffsetWidth(r/i._absoluteToFactor,!0)}else e.OffsetWidth(s.GetOriginalWidth()*n*t)}},(e,t,s)=>{e.SetWidth(s.GetOriginalWidth()*t)},(i,n)=>{const r=i.GetWidth()<0?-1:1;if(i.GetTransformWithParentWidth()){let e=i.GetParent(),t=n.GetTimeline().GetTrackFromInstance(e.GetInstance()),s=NaN;if(t)s=e.GetWidth()/t.GetOriginalWidth();else{const a=e.GetInstance().GetSdkInstance();s=a.IsOriginalSizeKnown()?e.GetWidth()/a.GetOriginalWidth():1}return i.GetWidth()*r/(n.GetOriginalWidth()*s)}return i.GetWidth()*r/n.GetOriginalWidth()},!1),add2("offsetScaleY",(e,t,s,i)=>{if(0!==t){const n=e.GetHeight()<0?-1:1;if("relative"===i._propertyTrack.GetResultMode()&&e.HasParent()&&e.GetTransformWithParentHeight()){const r=s.GetOriginalHeight()*n*t;isNaN(i._absoluteToFactor)&&INSTANCE_FUNC_MAP.get("offsetHeight").setter(e,1,s,i,!0),e.OffsetHeight(r/i._absoluteToFactor,!0)}else e.OffsetHeight(s.GetOriginalHeight()*n*t)}},(e,t,s)=>{e.SetHeight(s.GetOriginalHeight()*t)},(i,n)=>{const r=i.GetHeight()<0?-1:1;if(i.GetTransformWithParentHeight()){let e=i.GetParent(),t=n.GetTimeline().GetTrackFromInstance(e.GetInstance()),s=NaN;if(t)s=e.GetHeight()/t.GetOriginalHeight();else{const a=e.GetInstance().GetSdkInstance();s=a.IsOriginalSizeKnown()?e.GetHeight()/a.GetOriginalHeight():1}return i.GetHeight()*r/(n.GetOriginalHeight()*s)}return i.GetHeight()*r/n.GetOriginalHeight()},!1);class NumericInterpolationAdapter extends C33.PropertyTrackState.PropertyInterpolationAdapter{constructor(e){super(e),this._lastValue=0,this._clampAccumulator=0,this._totalForewardOpacityDelta=0,this._totalBackwardOpacityDelta=0,this._opacityFactor=NaN,this._absoluteToFactor=NaN,this._angleReflectMirrorOrFlip=void 0,this._angleReflectMirrorAndFlip=void 0,this._instance_getter=null,this._instance_setter=null,this._instance_absolute_setter=null,this._reset_action=null,this._init_action=null,this._source_adapter_getter=null,this._source_adapter_setter=null,this._source_adapter_absolute_setter=null,this._round=!1,this._fRound=!1,C33.IsInstanceOf(this._propertyTrack.GetTimeline(),C33.TweenState)?this._typeAdapter=new C33.PropertyTrackState.PropertyInterpolationAdapter.NumericInterpolationAdapterForTween(this):this._typeAdapter=new C33.PropertyTrackState.PropertyInterpolationAdapter.NumericInterpolationAdapterForTimeline(this);const t=this._propertyTrack.GetPropertyName();switch(this._propertyTrack.GetSourceAdapterId()){case"world-instance":{const s=INSTANCE_FUNC_MAP.get(t);this._instance_getter=s.getter,this._instance_setter=s.setter,this._instance_absolute_setter=s.absolute_setter,this._round=s.round,this._fRound=s.fRound,this._init_action=s.init,this._reset_action=s.reset;break}case"audio":this._source_adapter_getter=e.Getter,this._source_adapter_setter=e.Setter,this._source_adapter_absolute_setter=e.AbsoluteSetter,this._round=!!e.DoesRounding(),this._fRound=!1}}Release(){this._typeAdapter=null,this._instance_getter=null,this._instance_setter=null,this._instance_absolute_setter=null,this._reset_action=null,this._init_action=null,this._source_adapter_getter=null,this._source_adapter_setter=null,this._source_adapter_absolute_setter=null,super.Release()}MayNeedBeforeAndAfterInterpolate(){return this._typeAdapter.MayNeedBeforeAndAfterInterpolate()}GetLastValue(){return this._lastValue}SetLastValue(e){this._lastValue=e}SetResetState(){this._reset_action&&this._reset_action(this)}SetInitialState(){const e=this._typeAdapter.SetInitialState();if("number"==typeof e&&(this._lastValue=e),this._init_action){const t=this.GetWorldInfo(),s=this._propertyTrack.GetTrack();this._init_action(this,t,s)}}SetResumeState(){const e=this._typeAdapter.SetResumeState();"number"==typeof e&&(this._lastValue=e)}GetCurrentState(){return this._Getter()}CompareInitialStateWithCurrent(){const e=this._FirstKeyframeGetter();return e!==this.GetCurrentState()}CompareSaveStateWithCurrent(){return!C33.IsNullOrUndefined(this._saveState)&&this._saveState!==this.GetCurrentState()}BeforeChangeProperty(){this._typeAdapter.BeforeChangeProperty()}ChangeProperty(e,t,s,i,n,r,a,o){return this._typeAdapter.ChangeProperty(e,t,s,i,n,r,a,o)}AfterChangeProperty(){this._typeAdapter.AfterChangeProperty()}_Getter(){const e=this._GetTarget(),t=this._GetIndex(),s=this.GetWorldInfo(),i=this._propertyTrack.GetTrack(),n=this._propertyTrack.GetSourceAdapterId();switch(n){case"behavior":return e.GetPropertyValueByIndex(t);case"effect":return e[t];case"instance-variable":return e.GetInstanceVariableValue(t);case"plugin":return e.GetPropertyValueByIndex(t);case"world-instance":return this._instance_getter(s,i);case"audio":return this._source_adapter_getter.call(this.GetSourceAdapter(),s,i)}}_Setter(e,t,s){const i=this._GetTarget(),n=this._GetIndex(),r=this.GetWorldInfo(),a=this._propertyTrack.GetTrack(),o=this._propertyTrack.GetSourceAdapterId();switch(o){case"behavior":i.OffsetPropertyValueByIndex(n,e);break;case"effect":i[n]+=e;break;case"instance-variable":i.SetInstanceVariableOffset(n,e);break;case"plugin":i.OffsetPropertyValueByIndex(n,e,this.GetSourceAdapter().GetOptionalCallbacks());break;case"world-instance":this._instance_setter(r,e,a,this);break;case"audio":this._source_adapter_setter.call(this.GetSourceAdapter(),r,e,a,this)}}_SetterAbsolute(e,t,s){let i=this._propertyTrack.GetInterpolationMode();if("discrete"!==(i="default"===i?"continuous":i)||t){if("discrete"===i&&s){const h=this._propertyTrack.GetTimeline(),c=h.GetTime(),u=this._propertyTrack.GetPropertyKeyFrameDataItemAtTime(c);if(!u)return}const n=this._GetTarget(),r=this._GetIndex(),a=this.GetWorldInfo(),o=this._propertyTrack.GetTrack(),l=this._propertyTrack.GetSourceAdapterId();switch(l){case"behavior":n.SetPropertyValueByIndex(r,e);break;case"effect":n[r]=e;break;case"instance-variable":n.SetInstanceVariableValue(r,e);break;case"plugin":n.SetPropertyValueByIndex(r,e,this.GetSourceAdapter().GetOptionalCallbacks());break;case"world-instance":this._instance_absolute_setter(a,e,o);break;case"audio":this._source_adapter_absolute_setter.call(this.GetSourceAdapter(),a,e,o)}}}_MaybeEnsureValue(e,t,s,i,n,r,a,o){this._typeAdapter._MaybeEnsureValue(e,t,s,i,n,r,a,o)}_AddDelta(e,t,s,i,n){let r=(e="angle"===this._propertyTrack.GetPropertyType()?C33.toDegrees(e):e).toString(),a=r.split(".")[1]||"",o=a.length,l=this._Getter(),h;switch(h=0===o?this._round?Math.round(l):this._fRound?"angle"===this._propertyTrack.GetPropertyType()?C33.toRadians(Math.round(C33.toDegrees(l))):Number(C33.toFixed(l,2)):l:this._round?Number(C33.toFixed(l,o)):(this._fRound,l),this._Setter(h-l,t,s),this._propertyTrack.GetPropertyName()){case"offsetWidth":case"offsetScaleX":{const c=this.GetWorldInfo(),u=c.GetWidth(),_=Number(C33.toFixed(u,2));c.OffsetWidth(_-u);break}case"offsetHeight":case"offsetScaleY":{const d=this.GetWorldInfo(),p=d.GetHeight(),m=Number(C33.toFixed(p,2));d.OffsetHeight(m-p);break}}}_SaveToJson(){return Object.assign(super._SaveToJson(),{v:this._lastValue,a:this._clampAccumulator,fod:this._totalForewardOpacityDelta,bod:this._totalBackwardOpacityDelta,of:this._opacityFactor,sf:this._absoluteToFactor,armorf:this._angleReflectMirrorOrFlip,armandf:this._angleReflectMirrorAndFlip})}_LoadFromJson(e){e&&(super._LoadFromJson(e),this._lastValue=e.v,this._clampAccumulator=e.a,this._totalForewardOpacityDelta=C33.IsFiniteNumber(e.fod)?e.fod:0,this._totalBackwardOpacityDelta=C33.IsFiniteNumber(e.bod)?e.bod:0,this._opacityFactor=C33.IsFiniteNumber(e.of)?e.of:NaN,this._absoluteToFactor=C33.IsFiniteNumber(e.sf)?e.sf:NaN,this._angleReflectMirrorOrFlip=C33.IsFiniteNumber(e.armorf)?e.armorf:void 0,this._angleReflectMirrorAndFlip=C33.IsFiniteNumber(e.armandf)?e.armandf:void 0)}}C33.PropertyTrackState.PropertyInterpolationAdapter.NumericInterpolationAdapter=NumericInterpolationAdapter}{const C33=self.C3;class AbsoluteValueObject{constructor(e){this._used=!1,this._value=0,this._propertyKeyframeReached=!1,this._endState=!1,this._propertyTracks=e;for(let e=0,t=this._propertyTracks.length;e<t;e++)this._propertyTracks[e].SetAbsoluteValueObject(this)}GetPropertyTracks(){return this._propertyTracks}SetUsed(){this._used=!0}GetUsed(){return this._used}SetValue(e){this._value=e}GetValue(){return this._value}SetPropertyKeyframeReached(e){this._propertyKeyframeReached=e}GetPropertyKeyframeReached(){return this._propertyKeyframeReached}SetEndState(e){this._endState=e}GetEndState(){return this._endState}Reset(){this._used=!1,this._value=0,this._propertyKeyframeReached=!1,this._endState=!1}}class NumericInterpolationAdapterForTimeline{constructor(e){this._numericInterpolationAdapter=e}Release(){this._numericInterpolationAdapter=null}GetType(){return 0}SetInitialState(){const e=this._numericInterpolationAdapter;return this._numericInterpolationAdapter.GetPropertyTrack(),e._PickResultMode(()=>e._PickTimelinePlaybackMode(()=>0,()=>e.GetSourceAdapter().GetValueAtTime()),()=>{})}SetResumeState(){}MayNeedBeforeAndAfterInterpolate(){this._numericInterpolationAdapter;const e=this._numericInterpolationAdapter.GetPropertyTrack();switch(e.GetResultMode()){case"relative":return!1;case"absolute":return!0}}BeforeChangeProperty(){this._numericInterpolationAdapter;const e=this._numericInterpolationAdapter.GetPropertyTrack(),t=e.GetPropertyName();switch(e.GetResultMode()){case"relative":break;case"absolute":if(e.HasAbsoluteValueObject()){const s=e.GetAbsoluteValueObject();s.Reset()}else{const i=e.GetTimeline(),n=e.GetInstance(),r=e.GetSourceAdapter(),a=i.GetSimilarPropertyTracks(n,r,t,e);a&&1<a.length&&new AbsoluteValueObject(a)}}}ChangeProperty(e,t,s,i,n,r,a,o){const l=this._numericInterpolationAdapter,h=this._numericInterpolationAdapter.GetPropertyTrack();switch(h.GetResultMode()){case"relative":{const c=l.GetLastValue();l._Setter(t-c,s,i),r&&this._MaybeEnsureValue(e,s,i,n,c,t),l.SetLastValue(t);break}case"absolute":{const u=h.GetTimeline(),_=h.GetTrack();if(h.GetInstance(),h.GetSourceAdapter(),h.HasAbsoluteValueObject()){const d=h.GetAbsoluteValueObject(),p=d.GetPropertyTracks(),m=l._GetPropertyKeyframeStubs(p,!0),g=l._GetLastPropertyKeyframeStub(u,u.GetTime(),m);if(g){const f=_.GetStartOffset(),S=g.time-f;if(0==S)d.SetEndState(a),d.SetPropertyKeyframeReached(o),d.SetUsed(),d.SetValue(d.GetValue()+t);else{if(S<0)return;const C=h.GetInterpolatedValue(S);d.SetEndState(a),d.SetPropertyKeyframeReached(o),d.SetUsed(),d.SetValue(d.GetValue()+(t-C))}}}else l._SetterAbsolute(t,o,a);break}}}AfterChangeProperty(){const e=this._numericInterpolationAdapter,t=this._numericInterpolationAdapter.GetPropertyTrack();switch(t.GetResultMode()){case"relative":break;case"absolute":if(t.HasAbsoluteValueObject()){const s=t.GetAbsoluteValueObject();s.GetUsed()&&e._SetterAbsolute(s.GetValue(),s.GetPropertyKeyframeReached(),s.GetEndState())}}}_MaybeEnsureValue(e,t,s,i,n,r){const a=this._numericInterpolationAdapter;i||(t&&e===t.GetTime()?a._AddDelta(t.GetValueWithResultMode(),t,s):s&&e===s.GetTime()?a._AddDelta(s.GetValueWithResultMode(),t,s):r-n==0&&a._AddDelta(t.GetValueWithResultMode(),t,s))}}C33.PropertyTrackState.PropertyInterpolationAdapter.NumericInterpolationAdapterForTimeline=NumericInterpolationAdapterForTimeline}{const C33=self.C3;class NumericInterpolationAdapterForTween{constructor(e){this._numericInterpolationAdapter=e}Release(){this._numericInterpolationAdapter=null}GetType(){return 1}SetInitialState(){const e=this._numericInterpolationAdapter;return e.SetFirstAbsoluteUpdate(!0),this._GetAbsoluteInitialValue(e._FirstKeyframeGetter())}SetResumeState(){const e=this._numericInterpolationAdapter;if(e._FirstKeyframeGetter()!==e._CurrentKeyframeGetter())return e.SetFirstAbsoluteUpdate(!0),this._GetAbsoluteInitialValue(e._CurrentKeyframeGetter())}MayNeedBeforeAndAfterInterpolate(){return!1}BeforeChangeProperty(){}ChangeProperty(e,t,s,i,n,r,a,o){const l=this._numericInterpolationAdapter,h=l.GetLastValue();switch(l.GetPropertyTrack().GetResultMode()){case"relative":l._Setter(t-h,s,i),r&&this._MaybeEnsureValue(e,s,i,n,h,t,!1,a);break;case"absolute":l.GetFirstAbsoluteUpdate()?(l.SetFirstAbsoluteUpdate(!1),l._Setter(h,s,i)):0===e&&0===l.GetPropertyTrack().GetTimeline().GetTotalTime()?l._SetterAbsolute(t,!0,!1):(l._Setter(t-h,s,i),r&&this._MaybeEnsureValue(e,s,i,n,h,t,this._ForceEndValue(),a))}l.SetLastValue(t)}AfterChangeProperty(){}_GetAbsoluteInitialValue(e){const t=this._numericInterpolationAdapter;return e-t.GetCurrentState()}_ForceEndValue(){let e=this._numericInterpolationAdapter,t=e.GetWorldInfo().GetInstance(),s=e.GetPropertyTrack().GetRuntime(),i=s.GetTimelineManager(),n=0;for(const r of i.GetPlayingTimelines())0===r.GetType()?r.HasTrackInstance(t)&&n++:1===r.GetType()&&r.GetInstance()===t&&n++;return n<=1}_MaybeEnsureValue(e,t,s,i,n,r,a,o){const l=this._numericInterpolationAdapter;i?t&&e===t.GetTime()?l._AddDelta(t.GetValueWithResultMode(),t,s,a,o):s&&e===s.GetTime()?l._AddDelta(s.GetValueWithResultMode(),t,s,a,o):s||l._AddDelta(t.GetValueWithResultMode(),t,s,a,o):t&&e===t.GetTime()?l._AddDelta(t.GetValueWithResultMode(),t,s,a,o):s&&e===s.GetTime()?l._AddDelta(s.GetValueWithResultMode(),t,s,a,o):r-n==0&&l._AddDelta(t.GetValueWithResultMode(),t,s,a,o)}}C33.PropertyTrackState.PropertyInterpolationAdapter.NumericInterpolationAdapterForTween=NumericInterpolationAdapterForTween}{const C33=self.C3,Ease=self.Ease;C33.PropertyTrackState.NumericTypeAdapter=class{constructor(){}static WillChange(e,t,s,i){let n;switch(i){case"behavior":n=t.GetPropertyValueByIndex(e);break;case"effect":n=t[e];break;case"instance-variable":n=t.GetInstanceVariableValue(e);break;case"plugin":n=t.GetPropertyValueByIndex(e)}return n!==s}static Interpolate(r,a,o,l){if(!o){let e=l.GetPropertyTrackDataItem(),t=l.GetPropertyTrackData();return(e=t.GetLastPropertyKeyframeDataItem(e)).GetValueWithResultMode()}let h=l.GetInterpolationMode();if("default"===h&&(h="continuous"),"discrete"===(h="combo"===l.GetPropertyType()?"discrete":h))return a.GetValueWithResultMode();if("continuous"===h||"step"===h){const c=l.GetTimeline().GetStep();if("step"===h&&0!==c){const g=1/c;r=Math.floor(r*g)/g}const u=a.GetValueWithResultMode(),_=o.GetValueWithResultMode(),d=a.GetAddOn("cubic-bezier"),p=o.GetAddOn("cubic-bezier"),m=d&&d.GetStartEnable()&&p&&p.GetEndEnable();if(!m&&u===_)return u;let e=a.GetTime(),t=o.GetTime(),s=("step"===h&&0!==c&&(r=C33.clamp(r,e,t)),C33.normalize(r,e,t)),i=a.GetEase(),n;if(m){const f=t-e;n=Ease.GetRuntimeEase(i)(f*s,0,1,f),n=Ease.GetRuntimeEase("cubicbezier")(n,u,u+d.GetStartAnchor(),_+p.GetEndAnchor(),_)}else n=Ease.GetRuntimeEase(i)((t-e)*s,u,_-u,t-e);return"integer"===l.GetPropertyType()?Math.floor(n):n}}}}{const C33=self.C3;C33.PropertyTrackState.AngleTypeAdapter=class{constructor(){}static WillChange(e,t,s,i){let n;switch(i){case"behavior":n=t.GetPropertyValueByIndex(e);break;case"effect":n=t[e];break;case"instance-variable":n=t.GetInstanceVariableValue(e);break;case"plugin":n=t.GetPropertyValueByIndex(e)}return n!==s}static Interpolate(e,t,s,i){if(!s){let e=i.GetPropertyTrackDataItem(),t=i.GetPropertyTrackData();return(e=t.GetLastPropertyKeyframeDataItem(e)).GetValueWithResultMode()}let n=i.GetInterpolationMode();if("default"===n&&(n="continuous"),"discrete"===(n="combo"===i.GetPropertyType()?"discrete":n))return t.GetValueWithResultMode();if("continuous"===n||"step"===n){const r=i.GetTimeline().GetStep();if("step"===n&&0!==r){const u=1/r;e=Math.floor(e*u)/u}const a=t.GetTime(),o=s.GetTime(),l=t.GetValueWithResultMode(),h=s.GetValueWithResultMode(),c=("step"===n&&0!==r&&(e=C33.clamp(e,a,o)),t.GetAddOn("angle"));if(!c){if(l===h)return l;const _=C33.normalize(e,a,o),d=self.Ease.GetRuntimeEase(t.GetEase());return C33.angleLerp(l,h,d(_,0,1,1))}{const p=c.GetRevolutions();if(l===h&&0===p)return l;const m=C33.normalize(e,a,o),g=self.Ease.GetRuntimeEase(t.GetEase()),f=g(m,0,1,1);switch(c.GetDirection()){case"closest":return C33.angleLerp(l,h,f,p);case"clockwise":return C33.angleLerpClockwise(l,h,f,p);case"anti-clockwise":return C33.angleLerpAntiClockwise(l,h,f,p)}}}}}}{const C33=self.C3;C33.PropertyTrackState.BooleanTypeAdapter=class{constructor(){}static WillChange(e,t,s,i){let n;switch(i){case"behavior":n=t.GetPropertyValueByIndex(e);break;case"effect":n=t[e];break;case"instance-variable":n=t.GetInstanceVariableValue(e);break;case"plugin":n=t.GetPropertyValueByIndex(e)}return!!n!=!!s}static Interpolate(e,t,s,i){if(s)return t.GetValueWithResultMode()?1:0;{let e=i.GetPropertyTrackDataItem(),t=i.GetPropertyTrackData();return(e=t.GetLastPropertyKeyframeDataItem(e)).GetValueWithResultMode()?1:0}}}}{const C33=self.C3,TEMP_COLOR_ARRAY=[0,0,0],TEMP_COLOR_ARRAY_2=[0,0,0],TEMP_COLOR_ARRAY_3=[0,0,0];C33.PropertyTrackState.ColorTypeAdapter=class{constructor(){}static WillChange(e,t,s,i){let n;switch(i){case"behavior":n=t.GetPropertyValueByIndex(e);break;case"effect":n=t[e];break;case"instance-variable":n=t.GetInstanceVariableValue(e);break;case"plugin":n=t.GetPropertyValueByIndex(e)}return Array.isArray(s)?(TEMP_COLOR_ARRAY[0]=s[0],TEMP_COLOR_ARRAY[1]=s[1],TEMP_COLOR_ARRAY[2]=s[2]):(TEMP_COLOR_ARRAY_3.parseCommaSeparatedRgb(s),TEMP_COLOR_ARRAY[0]=Math.floor(255*TEMP_COLOR_ARRAY_3.getR()),TEMP_COLOR_ARRAY[1]=Math.floor(255*TEMP_COLOR_ARRAY_3.getG()),TEMP_COLOR_ARRAY[2]=Math.floor(255*TEMP_COLOR_ARRAY_3.getB())),Array.isArray(n)?(TEMP_COLOR_ARRAY_2[0]=n[0],TEMP_COLOR_ARRAY_2[1]=n[1],TEMP_COLOR_ARRAY_2[2]=n[2]):(TEMP_COLOR_ARRAY_3.parseCommaSeparatedRgb(n),TEMP_COLOR_ARRAY_2[0]=Math.floor(255*TEMP_COLOR_ARRAY_3.getR()),TEMP_COLOR_ARRAY_2[1]=Math.floor(255*TEMP_COLOR_ARRAY_3.getG()),TEMP_COLOR_ARRAY_2[2]=Math.floor(255*TEMP_COLOR_ARRAY_3.getB())),TEMP_COLOR_ARRAY[0]!==TEMP_COLOR_ARRAY_2[0]||TEMP_COLOR_ARRAY[1]!==TEMP_COLOR_ARRAY_2[1]||TEMP_COLOR_ARRAY[2]!==TEMP_COLOR_ARRAY_2[2]}static Interpolate(e,t,s,i){if(!s){let e=i.GetPropertyTrackDataItem(),t=i.GetPropertyTrackData(),s=(e=t.GetLastPropertyKeyframeDataItem(e)).GetValueWithResultMode();return TEMP_COLOR_ARRAY[0]=s[0],TEMP_COLOR_ARRAY[1]=s[1],TEMP_COLOR_ARRAY[2]=s[2],TEMP_COLOR_ARRAY}let n=i.GetInterpolationMode();if("discrete"===(n="default"===n?"continuous":n)){const r=t.GetValueWithResultMode();return TEMP_COLOR_ARRAY[0]=r[0],TEMP_COLOR_ARRAY[1]=r[1],TEMP_COLOR_ARRAY[2]=r[2],TEMP_COLOR_ARRAY}if("continuous"===n||"step"===n){const a=i.GetTimeline().GetStep();if("step"===n&&0!==a){const I=1/a;e=Math.floor(e*I)/I}const o=t.GetTime(),l=s.GetTime(),h=t.GetValueWithResultMode(),c=s.GetValueWithResultMode(),u=("step"===n&&0!==a&&(e=C33.clamp(e,o,l)),C33.normalize(e,o,l)),_=t.GetEase(),d=h[0],p=h[1],m=h[2],g=c[0],f=c[1],S=c[2],C=self.Ease.GetRuntimeEase(_),y=l-o,G=y*u;return TEMP_COLOR_ARRAY[0]=d===g?d:C(G,d,g-d,y),TEMP_COLOR_ARRAY[1]=p===f?p:C(G,p,f-p,y),TEMP_COLOR_ARRAY[2]=m===S?m:C(G,m,S-m,y),TEMP_COLOR_ARRAY}}}}{const C33=self.C3;C33.PropertyTrackState.TextTypeAdapter=class{constructor(){}static WillChange(e,t,s,i){let n;switch(i){case"behavior":n=t.GetPropertyValueByIndex(e);break;case"effect":n=t[e];break;case"instance-variable":n=t.GetInstanceVariableValue(e);break;case"plugin":n=t.GetPropertyValueByIndex(e)}return n!==s}static Interpolate(e,t,s,i){if(s)return t.GetValueWithResultMode();{let e=i.GetPropertyTrackDataItem(),t=i.GetPropertyTrackData();return(e=t.GetLastPropertyKeyframeDataItem(e)).GetValueWithResultMode()}}}}{const C33=self.C3;C33.TimelineDataManager=class{constructor(){this._timelineDataItems=new Map}Release(){for(const e of this._timelineDataItems.values())e.Release();this._timelineDataItems.clear(),this._timelineDataItems=null}Add(e){const t=new C33.TimelineDataItem(e),s=t.GetName();this._timelineDataItems.set(s,t)}Get(e){return this._timelineDataItems.get(e)}GetNameId(){return 0}static _CreateDataItems(e,t,s,i){if(t)for(const n of t)C33.TimelineDataManager._CreateDataItem("create",n,e,s,i)}static _CreateDataItemsIncludingDisabled(e,t,s,i){if(t)for(const n of t)C33.TimelineDataManager._CreateDataItem("create-including-disabled",n,e,s,i)}static _LoadDataItemsFromJson(s,e,t,i){s.length?e.forEach((e,t)=>{s[t]._LoadFromJson(e)}):e.forEach(e=>{C33.TimelineDataManager._CreateDataItem("load",e,s,t,i)})}static _CreateDataItem(e,t,s,i,n){let r;if("function"==typeof i)switch(e){case"load":r=new i(null,n);break;case"create":case"create-including-disabled":r=new i(t,n)}else if("object"==typeof i){const a=i.prop,o=t[a],l=i.map.get(o);switch(e){case"load":r=new l(null,n);break;case"create":case"create-including-disabled":r=new l(t,n)}}switch(e){case"load":r._LoadFromJson(t),s.push(r);break;case"create":if("function"==typeof r.GetEnable&&!r.GetEnable())return r.Release();s.push(r);break;case"create-including-disabled":s.push(r)}}}}{const C33=self.C3,NAME=0,TOTAL_TIME=1,STEP=2,INTERPOLATION_MODE=3,RESULT_MODE=4,TRACKS=5,LOOP=6,PING_PONG=7,REPEAT_COUNT=8,START_ON_LAYOUT=9,TRANSFORM_WITH_SCENE_GRAPH=10,USE_SYSTEM_TIMESCALE=11;C33.TimelineDataItem=class{constructor(e){this._name="",this._totalTime=NaN,this._step=0,this._interpolationMode="default",this._resultMode="default",this._loop=!1,this._pingPong=!1,this._repeatCount=1,this._trackData=null,this._startOnLayout="",this._transformWithSceneGraph=!1,this._useSystemTimescale=!0,e&&(this._name=e[NAME],this._totalTime=e[TOTAL_TIME],this._step=e[STEP],this._interpolationMode=e[INTERPOLATION_MODE],this._resultMode=e[RESULT_MODE],this._loop=!!e[LOOP],this._pingPong=!!e[PING_PONG],this._repeatCount=e[REPEAT_COUNT],this._startOnLayout=e[START_ON_LAYOUT],this._transformWithSceneGraph=!!e[TRANSFORM_WITH_SCENE_GRAPH],this._useSystemTimescale=!!e[USE_SYSTEM_TIMESCALE],this._trackData=new C33.TrackData(e[TRACKS],this))}Release(){this._trackData.Release(),this._trackData=null}GetTrackData(){return this._trackData||(this._trackData=new C33.TrackData(null,this)),this._trackData}GetName(){return this._name}SetName(e){this._name=e}GetTotalTime(){return this._totalTime}SetTotalTime(e){this._totalTime=e}GetStep(){return this._step}SetStep(e){this._step=e}GetInterpolationMode(){return this._interpolationMode}SetInterpolationMode(e){this._interpolationMode=e}GetResultMode(){return this._resultMode}SetResultMode(e){this._resultMode=e}GetLoop(){return this._loop}SetLoop(e){this._loop=e}GetPingPong(){return this._pingPong}SetPingPong(e){this._pingPong=e}GetRepeatCount(){return this._repeatCount}SetRepeatCount(e){this._repeatCount=e}GetStartOnLayout(){return this._startOnLayout}GetTransformWithSceneGraph(){return this._transformWithSceneGraph}GetUseSystemTimescale(){return this._useSystemTimescale}_SaveToJson(){return{trackDataJson:this._trackData._SaveToJson(),name:this._name,totalTime:this._totalTime,step:this._step,interpolationMode:this._interpolationMode,resultMode:this._resultMode,loop:this._loop,pingPong:this._pingPong,repeatCount:this._repeatCount,startOnLayout:this._startOnLayout,transformWithSceneGraph:!!this._transformWithSceneGraph,useSystemTimescale:this._useSystemTimescale}}_LoadFromJson(e){e&&(this.GetTrackData()._LoadFromJson(e.trackDataJson),this._name=e.name,this._totalTime=e.totalTime,this._step=e.step,this._interpolationMode=e.interpolationMode,this._resultMode=e.resultMode,this._loop=e.loop,this._pingPong=e.pingPong,this._repeatCount=e.repeatCount,this._startOnLayout=e.startOnLayout,this._transformWithSceneGraph=!!e.transformWithSceneGraph,this._useSystemTimescale=!!e.useSystemTimescale)}}}{const C33=self.C3,WI_DATA=0,OC_INDEX=1,WI_UID=2,INTERPOLATION_MODE=1,RESULT_MODE=2,ENABLED=3,KEYFRAMES=4,PROPERTY_TRACKS=5,ID=6,NESTED_DATA=7,START_OFFSET=0,LOCAL_TOTAL_TIME=1,WI_ADDITIONAL_DATA=8,ORIGINAL_WIDTH=0,ORIGINAL_HEIGHT=1,TRACK_TYPE=9,TRACK_NAME=10;class TrackDataItem{constructor(e,t){this._trackData=t,this._instanceData=null,this._additionalInstanceData=null,this._instanceUid=NaN,this._objectClassIndex=NaN,this._interpolationMode="default",this._resultMode="default",this._enabled=!1,this._keyframeData=null,this._propertyTrackData=null,this._id="",this._nestedData=null,this._startOffset=0,this._localTotalTime=this._trackData.GetTimelineDataItem().GetTotalTime(),this._type=0,this._name="",e&&(e[WI_DATA]&&(this._instanceData=e[WI_DATA],this._instanceUid=e[WI_DATA][WI_UID],this._objectClassIndex=e[WI_DATA][OC_INDEX]),this._interpolationMode=e[INTERPOLATION_MODE],this._resultMode=e[RESULT_MODE],this._enabled=!!e[ENABLED],e[ID]&&(this._id=e[ID]),e[NESTED_DATA]&&(this._nestedData=e[NESTED_DATA],this._startOffset=e[NESTED_DATA][START_OFFSET],this._localTotalTime=e[NESTED_DATA][LOCAL_TOTAL_TIME]),e[WI_ADDITIONAL_DATA]&&(this._additionalInstanceData=e[WI_ADDITIONAL_DATA]),e[WI_ADDITIONAL_DATA]&&(this._additionalInstanceData=e[WI_ADDITIONAL_DATA]),e[TRACK_TYPE]&&(this._type=e[TRACK_TYPE]),e[TRACK_NAME]&&(this._name=e[TRACK_NAME]),this._keyframeData=new C33.KeyframeData(e[KEYFRAMES],this),this._propertyTrackData=new C33.PropertyTrackData(e[PROPERTY_TRACKS],this))}Release(){this._instanceData=null,this._trackData=null,this._keyframeData&&(this._keyframeData.Release(),this._keyframeData=null),this._propertyTrackData&&(this._propertyTrackData.Release(),this._propertyTrackData=null),this._nestedData=null}GetTrackData(){return this._trackData}GetKeyframeData(){return this._keyframeData||(this._keyframeData=new C33.KeyframeData(null,this)),this._keyframeData}GetPropertyTrackData(){return this._propertyTrackData||(this._propertyTrackData=new C33.PropertyTrackData(null,this)),this._propertyTrackData}GetInstanceData(){return this._instanceData}GetObjectClassIndex(){return this._objectClassIndex}SetObjectClassIndex(e){this._objectClassIndex=e}GetInstanceUID(){return this._instanceUid}SetInstanceUID(e){this._instanceUid=e}GetInterpolationMode(){return this._interpolationMode}SetInterpolationMode(e){this._interpolationMode=e}GetResultMode(){return this._resultMode}SetResultMode(e){this._resultMode=e}GetEnable(){return this._enabled}SetEnable(e){this._enabled=!!e}GetId(){return this._id}GetStartOffset(){return this._startOffset}GetLocalTotalTime(){return this._localTotalTime}SetLocalTotalTime(e){this._localTotalTime=e}GetOriginalWidth(){return this._additionalInstanceData[ORIGINAL_WIDTH]}SetOriginalWidth(e){this._additionalInstanceData||(this._additionalInstanceData=[]),this._additionalInstanceData[ORIGINAL_WIDTH]=e}GetOriginalHeight(){return this._additionalInstanceData||(this._additionalInstanceData=[]),this._additionalInstanceData[ORIGINAL_HEIGHT]}SetOriginalHeight(e){this._additionalInstanceData||(this._additionalInstanceData=[]),this._additionalInstanceData[ORIGINAL_HEIGHT]=e}GetType(){return this._type}GetName(){return this._name}_SaveToJson(){return{keyframeDataJson:this._keyframeData._SaveToJson(),propertyTrackDataJson:this._propertyTrackData._SaveToJson(),instanceData:this._instanceData,additionalInstanceData:this._additionalInstanceData,instanceUid:this._instanceUid,objectClassIndex:this._objectClassIndex,interpolationMode:this._interpolationMode,resultMode:this._resultMode,enabled:this._enabled,id:this._id,nestedData:this._nestedData,type:this._type,name:this._name}}_LoadFromJson(e){e&&(this._instanceData=e.instanceData,this._instanceUid=e.instanceUid,this._objectClassIndex=e.objectClassIndex,this._interpolationMode=e.interpolationMode,this._resultMode=e.resultMode,this._enabled=e.enabled,this._id=e.id,this._type=e.type||0,this._name=e.name||"",this._localTotalTime=this._trackData.GetTimelineDataItem().GetTotalTime(),e.nestedData&&(this._nestedData=e.nestedData,this._startOffset=this._nestedData[START_OFFSET],this._localTotalTime=this._nestedData[LOCAL_TOTAL_TIME]),e.additionalInstanceData&&(this._additionalInstanceData=e.additionalInstanceData),this.GetKeyframeData()._LoadFromJson(e.keyframeDataJson),this.GetPropertyTrackData()._LoadFromJson(e.propertyTrackDataJson))}}C33.TrackData=class{constructor(e,t){this._timelineDataItem=t,this._trackDataItems=[],C33.TimelineDataManager._CreateDataItems(this._trackDataItems,e,TrackDataItem,this)}Release(){this._timelineDataItem=null;for(const e of this._trackDataItems)e.Release();C33.clearArray(this._trackDataItems),this._trackDataItems=null}GetTimelineDataItem(){return this._timelineDataItem}AddEmptyTrackDataItem(){const e=new TrackDataItem(null,this);return this._trackDataItems.push(e),e}GetFirstKeyframeDataItem(e){return e.GetKeyframeData().GetKeyframeDataItemArray()[0]}GetLastKeyframeDataItem(e){const t=e.GetKeyframeData().GetKeyframeDataItemArray();return t.at(-1)}GetKeyFrameDataItemAtTime(t,e){const s=e.GetKeyframeData().GetKeyframeDataItemArray(),i=s.length;for(let e=0;e<i;e++){const n=s[e];if(n.GetTime()===t)return n}}GetFirstKeyFrameDataItemHigherThan(t,e){const s=e.GetKeyframeData().GetKeyframeDataItemArray(),i=s.length;for(let e=0;e<i;e++){const n=s[e];if(n.GetTime()>t)return n}}GetFirstKeyFrameDataItemHigherOrEqualThan(t,e){const s=e.GetKeyframeData().GetKeyframeDataItemArray(),i=s.length;for(let e=0;e<i;e++){const n=s[e];if(n.GetTime()>=t)return n}}GetFirstKeyFrameDataItemLowerOrEqualThan(t,e){const s=e.GetKeyframeData().GetKeyframeDataItemArray();for(let e=s.length-1;0<=e;e--){const i=s[e];if(i.GetTime()<=t)return i}}*trackDataItems(){for(const e of this._trackDataItems)yield e}_SaveToJson(){return{trackDataItemsJson:this._trackDataItems.map(e=>e._SaveToJson())}}_LoadFromJson(e){e&&C33.TimelineDataManager._LoadDataItemsFromJson(this._trackDataItems,e.trackDataItemsJson,TrackDataItem,this)}}}{const C33=self.C3,SOURCE_DATA=0,SOURCE=0,PROPERTY=1,TYPE=2,MIN=3,MAX=4,INTERPOLATION_MODE=5,RESULT_MODE=6,ENABLED=7,PROPERTY_KEYFRAMES=8,CAN_HAVE_PROPERTY_KEYFRAMES=9;class PropertyTrackDataItem{constructor(e,t){this._propertyTrackData=t,this._sourceAdapterId="",this._sourceAdapterArguments=null,this._property=null,this._type=null,this._min=NaN,this._max=NaN,this._interpolationMode="default",this._resultMode="default",this._enabled=!1,this._propertyKeyframeData=null,this._canHavePropertyKeyframes=!0,e&&(this._sourceAdapterId=e[SOURCE_DATA][SOURCE],this._sourceAdapterArguments=e[SOURCE_DATA].slice(1),this._property=e[PROPERTY],this._type=e[TYPE],this._min=e[MIN],this._max=e[MAX],this._interpolationMode=e[INTERPOLATION_MODE],this._resultMode=e[RESULT_MODE],this._enabled=!!e[ENABLED],this._propertyKeyframeData=new C33.PropertyKeyframeData(e[PROPERTY_KEYFRAMES],this),this._canHavePropertyKeyframes=e[CAN_HAVE_PROPERTY_KEYFRAMES])}Release(){this._propertyKeyframeData.Release(),this._propertyKeyframeData=null,this._propertyTrackData=null,this._sourceAdapterArguments=null}GetPropertyTrackData(){return this._propertyTrackData}GetPropertyKeyframeData(){return this._propertyKeyframeData||(this._propertyKeyframeData=new C33.PropertyKeyframeData(null,this)),this._propertyKeyframeData}GetSourceAdapterId(){return this._sourceAdapterId}SetSourceAdapterId(e){this._sourceAdapterId=e}GetSourceAdapterArguments(){return this._sourceAdapterArguments}SetSourceAdapterArguments(e){this._sourceAdapterArguments=e}GetProperty(){return this._property}SetProperty(e){this._property=e}GetType(){return this._type}SetType(e){this._type=e}GetMin(){return this._min}SetMin(e){this._min=e}GetMax(){return this._max}SetMax(e){this._max=e}GetInterpolationMode(){return this._interpolationMode}SetInterpolationMode(e){this._interpolationMode=e}GetResultMode(){return this._resultMode}SetResultMode(e){this._resultMode=e}GetEnable(){return this._enabled}SetEnable(e){this._enabled=!!e}CanHavePropertyKeyframes(){return!!this._canHavePropertyKeyframes}_SaveToJson(){return{propertyKeyframeDataJson:this._propertyKeyframeData._SaveToJson(),sourceAdapterId:this._sourceAdapterId,sourceAdapterArguments:this._sourceAdapterArguments,property:this._property,type:this._type,min:this._min,max:this._max,interpolationMode:this._interpolationMode,resultMode:this._resultMode,enabled:this._enabled,canHavePropertyKeyframes:this._canHavePropertyKeyframes}}_LoadFromJson(e){e&&(this._sourceAdapterId=e.sourceAdapterId,this._sourceAdapterArguments=e.sourceAdapterArguments,this._property=e.property,this._type=e.type,this._min=e.min,this._max=e.max,this._interpolationMode=e.interpolationMode,this._resultMode=e.resultMode,this._enabled=e.enabled,this._canHavePropertyKeyframes=e.canHavePropertyKeyframes,this.GetPropertyKeyframeData()._LoadFromJson(e.propertyKeyframeDataJson))}}C33.PropertyTrackData=class{constructor(e,t){this._trackDataItem=t,this._propertyTrackDataItems=[],C33.TimelineDataManager._CreateDataItems(this._propertyTrackDataItems,e,PropertyTrackDataItem,this)}Release(){this._trackDataItem=null;for(const e of this._propertyTrackDataItems)e.Release();C33.clearArray(this._propertyTrackDataItems),this._propertyTrackDataItems=null}GetTrackDataItem(){return this._trackDataItem}AddEmptyPropertyTrackDataItem(){const e=new PropertyTrackDataItem(null,this);return this._propertyTrackDataItems.push(e),e}GetFirstPropertyKeyframeDataItem(e){const t=e.GetPropertyKeyframeData();return t.GetPropertyKeyframeDataItemArray()[0]}GetLastPropertyKeyframeDataItem(e){const t=e.GetPropertyKeyframeData(),s=t.GetPropertyKeyframeDataItemArray();return s.at(-1)}GetPropertyKeyFrameDataItemAtTime(t,e){const s=e.GetPropertyKeyframeData(),i=s.GetPropertyKeyframeDataItemArray(),n=i.length;for(let e=0;e<n;e++){const r=i[e];if(r.GetTime()===t)return r}}GetFirstPropertyKeyFrameDataItemHigherThan(t,e){const s=e.GetPropertyKeyframeData(),i=s.GetPropertyKeyframeDataItemArray(),n=i.length;for(let e=0;e<n;e++){const r=i[e];if(r.GetTime()>t)return r}}GetFirstPropertyKeyFrameDataItemHigherOrEqualThan(t,e){const s=e.GetPropertyKeyframeData(),i=s.GetPropertyKeyframeDataItemArray(),n=i.length;for(let e=0;e<n;e++){const r=i[e];if(r.GetTime()>=t)return r}}GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(t,e){const s=e.GetPropertyKeyframeData(),i=s.GetPropertyKeyframeDataItemArray();for(let e=i.length-1;0<=e;e--){const n=i[e];if(n.GetTime()<=t)return n}}*propertyTrackDataItems(){for(const e of this._propertyTrackDataItems)yield e}_SaveToJson(){return{propertyTrackDataItemsJson:this._propertyTrackDataItems.map(e=>e._SaveToJson())}}_LoadFromJson(e){e&&C33.TimelineDataManager._LoadDataItemsFromJson(this._propertyTrackDataItems,e.propertyTrackDataItemsJson,PropertyTrackDataItem,this)}}}{const C33=self.C3,TIME=0,EASE=1,ENABLE=2,TAGS=3;class KeyframeDataItem{constructor(e,t){if(this._keyframeData=t,this._time=-1,this._ease="noease",this._enable=!1,this._tags=null,this._lowerTags=null,e){this._time=e[TIME],this._ease=e[EASE],this._enable=!!e[ENABLE];const s=e[TAGS];this._tags=s?s.split(" "):[],this._lowerTags=new Set(this._tags.map(e=>e.toLowerCase())),this._next=null}}Release(){this._keyframeData=null,C33.clearArray(this._tags),this._tags=null,this._lowerTags.clear(),this._lowerTags=null,this._next=null}GetKeyframeData(){return this._keyframeData}GetNext(){return this._next}SetNext(e){this._next=e}GetTime(){return this._time}SetTime(e){this._time=e,this._keyframeData._LinkKeyframeDataItems()}GetEase(){return this._ease}SetEase(e){this._ease=e}GetEnable(){return this._enable}SetEnable(e){this._enable=!!e}GetTags(){return this._tags}SetTags(e){this._tags=e?e.split(" "):[],this._lowerTags=new Set(this._tags.map(e=>e.toLowerCase()))}GetLowerTags(){return this._lowerTags}HasTag(e){return this._lowerTags.has(e.toLowerCase())}_SaveToJson(){return{time:this._time,ease:this._ease,enable:this._enable,tags:this._tags}}_LoadFromJson(e){e&&(this._time=e.time,this._ease=e.ease,this._enable=e.enable,this._tags=e.tags,this._lowerTags=new Set(this._tags.map(e=>e.toLowerCase())))}}C33.KeyframeData=class{constructor(e,t){this._trackDataItem=t,this._keyframeDataItems=[],C33.TimelineDataManager._CreateDataItems(this._keyframeDataItems,e,KeyframeDataItem,this),this._LinkKeyframeDataItems()}Release(){this._trackDataItem=null;for(const e of this._keyframeDataItems)e.Release();C33.clearArray(this._keyframeDataItems),this._keyframeDataItems=null}_LinkKeyframeDataItems(){this._keyframeDataItems.sort((e,t)=>e.GetTime()-t.GetTime());for(let e=0;e<this._keyframeDataItems.length;e++){const t=this._keyframeDataItems[e];t.SetNext(this._keyframeDataItems[e+1])}}GetTrackDataItem(){return this._trackDataItem}GetKeyframeDataItemCount(){return this._keyframeDataItems.length}GetKeyframeDataItemArray(){return this._keyframeDataItems}AddEmptyKeyframeDataItem(){const e=new KeyframeDataItem(null,this);return this._keyframeDataItems.push(e),this._LinkKeyframeDataItems(),e}DeleteKeyframeDataItems(e){for(const t of this._keyframeDataItems)if(e(t)){const s=this._keyframeDataItems.indexOf(t);-1!==s&&(t.Release(),this._keyframeDataItems.splice(s,1))}this.SortKeyframeDataItems(),this._LinkKeyframeDataItems()}SortKeyframeDataItems(){this._keyframeDataItems.sort((e,t)=>e.GetTime()-t.GetTime())}GetKeyframeDataItemIndex(e){return this._keyframeDataItems.indexOf(e)}GetKeyframeDataItemFromIndex(e){return this._keyframeDataItems[e]}*keyframeDataItems(){for(const e of this._keyframeDataItems)yield e}*keyframeDataItemsReverse(){for(let e=this._keyframeDataItems.length-1;0<=e;e--)yield this._keyframeDataItems[e]}_SaveToJson(){return{keyframeDataItemsJson:this._keyframeDataItems.map(e=>e._SaveToJson())}}_LoadFromJson(e){e&&(C33.TimelineDataManager._LoadDataItemsFromJson(this._keyframeDataItems,e.keyframeDataItemsJson,KeyframeDataItem,this),this._LinkKeyframeDataItems())}}}{const C33=self.C3,VALUE_DATA=0,VALUE_DATA_VALUE=0,VALUE_DATA_ABSOLUTE_VALUE=1,VALUE_DATA_TYPE=2,TIME=1,EASE=2,ENABLE=3,ADDONS=4,PATH_MODE=5;class PropertyKeyframeDataItem{constructor(e,t){this._propertyKeyframeData=t,this._value=null,this._aValue=null,this._type="",this._time=NaN,this._ease="noease",this._enable=!1,this._addonData=null,this._addonInstance=void 0,this._pathMode="line",e&&(this._value=e[VALUE_DATA][VALUE_DATA_VALUE],this._aValue=e[VALUE_DATA][VALUE_DATA_ABSOLUTE_VALUE],this._type=e[VALUE_DATA][VALUE_DATA_TYPE],this._time=e[TIME],this._ease=e[EASE],this._enable=!!e[ENABLE],this._pathMode=e[PATH_MODE],this._addonData=null,e[ADDONS]&&(this._addonData=new C33.AddonData(e[ADDONS],this)),this._next=null,this._prev=null)}Release(){this._propertyKeyframeData=null,this._addonData&&(this._addonData.Release(),this._addonData=null),this._next=null,this._prev=null}GetAddonData(){return this._addonData}SetNext(e){this._next=e}GetNext(){return this._next}SetPrevious(e){this._prev=e}GetPrevious(){return this._prev}GetValue(){return this._value}SetValue(e){"color"===this._type&&C33.IsFiniteNumber(e)?(this._value[0]=C33.GetRValue(e),this._value[1]=C33.GetGValue(e),this._value[2]=C33.GetBValue(e)):this._value=e}GetAbsoluteValue(){return this._aValue}SetAbsoluteValue(e){"color"===this._type&&C33.IsFiniteNumber(e)?(this._aValue[0]=C33.GetRValue(e),this._aValue[1]=C33.GetGValue(e),this._aValue[2]=C33.GetBValue(e)):this._aValue=e}GetValueWithResultMode(){const e=this._propertyKeyframeData.GetPropertyTrackDataItem().GetResultMode();return"relative"===e?this.GetValue():"absolute"===e?this.GetAbsoluteValue():void 0}GetType(){return this._type}SetType(e){this._type=e}GetTime(){return this._time}SetTime(e){this._time=e,this._propertyKeyframeData._LinkPropertyKeyframeDataItems()}GetEase(){return this._ease}SetEase(e){this._ease=e}GetEnable(){return this._enable}SetEnable(e){this._enable=!!e}GetPathMode(){return this._pathMode}GetAddOn(t){if(this._addonData){if(!this._addonInstance&&null!==this._addonInstance){const s=this._addonData.GetAddDataItemArray();if(s){const i=s.length;for(let e=0;e<i;e++){const n=s[e];if(n.GetId()===t)return this._addonInstance=n,this._addonInstance}}this._addonInstance=null}return this._addonInstance}}_SaveToJson(){const e=this._addonData;return{addonDataJson:e&&e._SaveToJson(),value:this._value,aValue:this._aValue,type:this._type,time:this._time,ease:this._ease,enable:this._enable}}_LoadFromJson(e){e&&(e.addonDataJson&&this._addonData._SetFromJson(e.addonDataJson),this._value=e.value,this._aValue=e.aValue,this._type=e.type,this._time=e.time,this._ease=e.ease,this._enable=e.enable)}}C33.PropertyKeyframeData=class{constructor(e,t){this._propertyTrackDataItem=t,this._propertyKeyframeDataItems=[],this._propertyKeyframeDataItemsIncludingDisabled=[],C33.TimelineDataManager._CreateDataItems(this._propertyKeyframeDataItems,e,PropertyKeyframeDataItem,this),C33.TimelineDataManager._CreateDataItemsIncludingDisabled(this._propertyKeyframeDataItemsIncludingDisabled,e,PropertyKeyframeDataItem,this),this._LinkPropertyKeyframeDataItems()}Release(){this._propertyTrackDataItem=null;for(const e of this._propertyKeyframeDataItems)e.Release();C33.clearArray(this._propertyKeyframeDataItems),this._propertyKeyframeDataItems=null;for(const t of this._propertyKeyframeDataItemsIncludingDisabled)t.Release();C33.clearArray(this._propertyKeyframeDataItemsIncludingDisabled),this._propertyKeyframeDataItemsIncludingDisabled=null}_LinkPropertyKeyframeDataItems(){let t=this._propertyKeyframeDataItems;t.sort((e,t)=>e.GetTime()-t.GetTime());for(let e=0;e<t.length;e++){const s=t[e];e+1<t.length&&s.SetNext(t[e+1]),0<=e-1&&s.SetPrevious(t[e-1])}(t=this._propertyKeyframeDataItemsIncludingDisabled).sort((e,t)=>e.GetTime()-t.GetTime());for(let e=0;e<t.length;e++){const i=t[e];e+1<t.length&&i.SetNext(t[e+1]),0<=e-1&&i.SetPrevious(t[e-1])}}AddEmptyPropertyKeyframeDataItem(){const e=new PropertyKeyframeDataItem(null,this);return this._propertyKeyframeDataItems.push(e),this._LinkPropertyKeyframeDataItems(),e}DeletePropertyKeyframeDataItems(e){for(const t of this._propertyKeyframeDataItems)if(e(t)){const s=this._propertyKeyframeDataItems.indexOf(t);-1!==s&&(t.Release(),this._propertyKeyframeDataItems.splice(s,1))}this.SortPropertyKeyFrameDataItems(),this._LinkPropertyKeyframeDataItems()}SortPropertyKeyFrameDataItems(){this._propertyKeyframeDataItems.sort((e,t)=>e.GetTime()-t.GetTime())}GetPropertyTrackDataItem(){return this._propertyTrackDataItem}GetPropertyKeyframeDataItemCount(){return this._propertyKeyframeDataItems.length}GetLastPropertyKeyframeDataItem(){return this._propertyKeyframeDataItems[this._propertyKeyframeDataItems.length-1]}GetPropertyKeyframeDataItemArray(){return this._propertyKeyframeDataItems}GetPropertyKeyframeDataItemArrayIncludingDisabled(){return this._propertyKeyframeDataItemsIncludingDisabled}*propertyKeyframeDataItems(){for(const e of this._propertyKeyframeDataItems)yield e}*propertyKeyframeDataItemsReverse(){for(let e=this._propertyKeyframeDataItems.length-1;0<=e;e--)yield this._propertyKeyframeDataItems[e]}_SaveToJson(){const e=this._propertyKeyframeDataItems,t=this._propertyKeyframeDataItemsIncludingDisabled;return{propertyKeyframeDataItemsJson:e.map(e=>e._SaveToJson()),propertyKeyframeDataItemsIncludingDisabledJson:t.map(e=>e._SaveToJson())}}_LoadFromJson(e){e&&(C33.TimelineDataManager._LoadDataItemsFromJson(this._propertyKeyframeDataItems,e.propertyKeyframeDataItemsJson,PropertyKeyframeDataItem,this),C33.TimelineDataManager._LoadDataItemsFromJson(this._propertyKeyframeDataItemsIncludingDisabled,e.propertyKeyframeDataItemsIncludingDisabledJson,PropertyKeyframeDataItem,this),this._LinkPropertyKeyframeDataItems())}}}{const C33=self.C3,ADDON_ID=0,ADDON_DATA=1;class AddonDataItem{constructor(e,t){this._addonData=t,this._id=e[ADDON_ID],this._data=e[ADDON_DATA]}Release(){this._addonData=null,this._data=null}GetAddonData(){return this._addonData}GetId(){return this._id}_SaveToJson(){return{id:this._id,data:this._data}}_LoadFromJson(e){e&&(this._id=e.id,this._data=e.data)}}const START_ANCHOR=0,START_ENABLE=1,END_ANCHOR=2,END_ENABLE=3;class AddonDataCubicBezierItem extends AddonDataItem{constructor(e,t){super(e,t),this._startAnchor=this._data[START_ANCHOR],this._startEnable=!!this._data[START_ENABLE],this._endAnchor=this._data[END_ANCHOR],this._endEnable=!!this._data[END_ENABLE]}Release(){super.Release()}GetStartAnchor(){return this._startAnchor}GetStartEnable(){return this._startEnable}GetEndAnchor(){return this._endAnchor}GetEndEnable(){return this._endEnable}_SaveToJson(){return Object.assign(super._SaveToJson(),{startAnchor:this._startAnchor,startEnable:!!this._startEnable,endAnchor:this._endAnchor,endEnable:!!this._endEnable})}_LoadFromJson(e){e&&(super._LoadFromJson(e),this._startAnchor=e.startAnchor,this._startEnable=!!e.startEnable,this._endAnchor=e.endAnchor,this._endEnable=!!e.endEnable)}}const DIRECTION=0,REVOLUTIONS=1;class AddonDataAngleItem extends AddonDataItem{constructor(e,t){super(e,t),this._direction=this._data[DIRECTION],this._revolutions=this._data[REVOLUTIONS]}Release(){super.Release()}GetDirection(){return this._direction}GetRevolutions(){return this._revolutions}_SaveToJson(){return Object.assign(super._SaveToJson(),{direction:this._direction,revolutions:this._revolutions})}_LoadFromJson(e){e&&(super._LoadFromJson(e),this._direction=e.direction,this._revolutions=e.revolutions)}}C33.AddonData=class{constructor(e,t){this._propertyKeyframeDataItem=t,this._addonDataItems=[],C33.TimelineDataManager._CreateDataItems(this._addonDataItems,e,{prop:0,map:new Map([["cubic-bezier",AddonDataCubicBezierItem],["angle",AddonDataAngleItem]])},this)}Release(){this._propertyKeyframeDataItem=null;for(const e of this._addonDataItems)e.Release();C33.clearArray(this._addonDataItems),this._addonDataItems=null}GetPropertyKeyframeDataItem(){return this._propertyKeyframeDataItem}GetAddDataItemArray(){return this._addonDataItems}*addonDataItems(){for(const e of this._addonDataItems)yield e}_SaveToJson(){return{addonDataItemsJson:this._addonDataItems.map(e=>e._SaveToJson())}}_LoadFromJson(e){e&&C33.TimelineDataManager._LoadDataItemsFromJson(this._addonDataItems,e.addonDataItemsJson,{prop:"id",map:new Map([["cubic-bezier",AddonDataCubicBezierItem],["angle",AddonDataAngleItem]])},this)}}}{let C33=self.C3,INITIAL_VALUE_MODE_START_VALUE="start-value",INITIAL_VALUE_MODE_CURRENT_STATE="current-state",PING_PONG_BEGIN=0,PING_PONG_END=1,createdTweens=0;C33.TweenState=class extends C33.TimelineState{constructor(e,t){super("tween-"+createdTweens++,e,t),this._id="",this._destroyInstanceOnComplete=!1,this._initialValueMode=INITIAL_VALUE_MODE_START_VALUE,this._instance=null,this._on_completed_callbacks=null,this._on_started_callbacks=null,this._track=null,this._iTweenState=null}FireReleaseEvent(e){const t=C33.New(C33.Event,"tweenstatereleased");t.tweenState=this,e.dispatchEvent(t)}GetType(){return 1}CreateTrackStates(){for(const e of this._timelineDataItem.GetTrackData().trackDataItems())this._tracks.push(C33.TweenTrackState.Create(this,e));this._track=this._tracks[0]}AddTrack(){const e=this._timelineDataItem.GetTrackData().AddEmptyTrackDataItem(),t=C33.TweenTrackState.Create(this,e);return this._tracks.push(t),this._CacheTrack(),t}_CacheTrack(){this._track=this._tracks[0]}GetPropertyTrack(e){return this._track.GetPropertyTracks()[0]}SetPropertyType(e){this._propertyType=e}GetInstance(){const e=this.GetTracks();if(e&&e.length){const t=e[0];if(this._track=t){const s=t.GetInstance();return t.IsInstanceValid()?s:void 0}}}AddStartedCallback(e){this._on_started_callbacks||(this._on_started_callbacks=[]),this._on_started_callbacks.push(e)}AddCompletedCallback(e){this._on_completed_callbacks||(this._on_completed_callbacks=[]),this._on_completed_callbacks.push(e)}RemoveStartedCallback(e){if(this._on_started_callbacks){const t=this._on_started_callbacks.indexOf(e);-1!==t&&this._on_started_callbacks.splice(t,1)}}RemoveCompletedCallback(e){if(this._on_completed_callbacks){const t=this._on_completed_callbacks.indexOf(e);-1!==t&&this._on_completed_callbacks.splice(t,1)}}SetStartValue(e,t){for(const s of this._tracks)for(const i of s._propertyTracks)if(i.GetPropertyName()===t){const n=i.GetPropertyTrackData(),r=i.GetPropertyTrackDataItem(),a=n.GetFirstPropertyKeyframeDataItem(r);a.SetValue(e),a.SetAbsoluteValue(e)}}_GetPropertyTrackState(e){for(const t of this._tracks)for(const s of t._propertyTracks)if(s.GetPropertyName()===e)return s}BeforeSetEndValues(e){for(const t of e){const s=this._GetPropertyTrackState(t);this.SetStartValue(s.GetCurrentState(),t)}if(this.IsForwardPlayBack()){const i=this.GetTotalTime()-this.GetTime();this.SetTotalTime(i);for(const n of this._tracks)n.SetLocalTotalTime(i);this._SetTime(0)}else{const r=this.GetTime();this.SetTotalTime(r);for(const a of this._tracks)a.SetLocalTotalTime(r);this._SetTime(r)}this.SetInitialStateFromSetTime()}SetEndValue(e,t){const s=this._GetPropertyTrackState(t),i=s.GetPropertyTrackData(),n=s.GetPropertyTrackDataItem(),r=i.GetLastPropertyKeyframeDataItem(n);r.SetTime(this.GetTotalTime()),r.SetValue(e),r.SetAbsoluteValue(e)}SetId(e){this._id=e}GetId(){return this._id}SetInitialValueMode(e){this._initialValueMode=e}GetInitialValueMode(){return this._initialValueMode}SetDestroyInstanceOnComplete(e){this._destroyInstanceOnComplete=e}GetDestroyInstanceOnComplete(){return this._destroyInstanceOnComplete}OnStarted(){if(this._on_started_callbacks)for(const e of this._on_started_callbacks)e(this);if(!this.IsComplete())for(const t of this._tracks)t.CompareSaveStateWithCurrent()}OnCompleted(){this._completedTick=this._runtime.GetTickCount()}FinishTriggers(){if(!this._finishedTriggers&&(this._finishedTriggers=!0,this._on_completed_callbacks))for(const e of this._on_completed_callbacks)e(this)}SetTime(e){this._DeleteIntermediateKeyframes(),super.SetTime(e)}_SetTimeAndReset(e){(e=C33.IsFiniteNumber(e)?e:this.GetTotalTime())<0?this._playheadTime=0:e>=this.GetTotalTime()?this._playheadTime=this.GetTotalTime():this._playheadTime=e,this._track.SetResetState()}SetInitialState(e){if(!this.InitialStateSet()&&this.GetInitialValueMode()===INITIAL_VALUE_MODE_CURRENT_STATE)for(const t of this._tracks)t.CompareInitialStateWithCurrent();super.SetInitialState(e)}Stop(e=!1){if(super.Stop(e),!this.IsComplete())for(const t of this._tracks)t.SaveState()}Reset(e=!0,t=!1){this._DeleteIntermediateKeyframes(),super.Reset(e,t)}_DeleteIntermediateKeyframes(){for(const e of this._tracks){const t=e=>{const t=e.GetTime(),s=this.GetTotalTime();return 0!==t&&t!==s};e.DeleteKeyframes(t),e.DeletePropertyKeyframes(t)}}_OnBeforeChangeLayout(){if(!this.IsReleased()){const e=this.GetInstance();if(e&&e.GetObjectClass().IsGlobal())return!1;this._timelineManager.CompleteTimelineBeforeChangeOfLayout(this),this.ResetBeforeChangeLayout()}return!0}Tick(n,e,t){if(this._instance||(this._instance=this.GetInstance()),!this._instance||this._instance.IsDestroyed())this.Stop(!0),this.OnCompleted();else{const s=this._instance.GetTimeScale();if(0!==(n=-1!==s?t*s:n)||0!==this._lastDelta){this._lastDelta=n;const r=this._playheadTime+this._overshoot,a=n*this._playbackRate,o=r+a,l=this._timelineDataItem._totalTime;o<0?(this._playheadTime=0,this._overshoot=-o):l<=o?(this._playheadTime=l,this._overshoot=this._playheadTime-o):(this._playheadTime=o,this._overshoot=0);let e=!1,t=!1,s=this.GetLoop(),i=this.GetPingPong();s||i?s&&!i?0<this._playbackRate?this._playheadTime>=l&&(this._SetTimeAndReset(0),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenLoop),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensLoop),t=!0):this._playheadTime<=0&&(this._SetTimeAndReset(l),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenLoop),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensLoop),t=!0):!s&&i?0<this._playbackRate?this._playheadTime>=l&&(this._SetTime(l),this.SetPlaybackRate(-1*this.GetPlaybackRate()),t=!0,this._pingPongState===PING_PONG_END?this._currentRepeatCount<this.GetRepeatCount()?(this._currentRepeatCount++,this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenLoop),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensLoop),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenPingPong),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensPingPong),this._pingPongState=PING_PONG_BEGIN):(this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenPingPong),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensPingPong),e=!0):this._pingPongState===PING_PONG_BEGIN&&(this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenPingPong),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensPingPong),this._pingPongState=PING_PONG_END)):this._playheadTime<=0&&(this._SetTime(0),this.SetPlaybackRate(-1*this.GetPlaybackRate()),t=!0,this._pingPongState===PING_PONG_END?this._currentRepeatCount<this.GetRepeatCount()?(this._currentRepeatCount++,this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenLoop),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensLoop),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenPingPong),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensPingPong),this._pingPongState=PING_PONG_BEGIN):(e=!0,this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenPingPong),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensPingPong)):this._pingPongState===PING_PONG_BEGIN&&(this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenPingPong),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensPingPong),this._pingPongState=PING_PONG_END)):s&&i&&(0<this._playbackRate?this._playheadTime>=l&&(this._SetTime(l),this.SetPlaybackRate(-1*this.GetPlaybackRate()),t=!0,this._pingPongState===PING_PONG_BEGIN&&(this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenPingPong),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensPingPong)),this._pingPongState===PING_PONG_END&&(this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenLoop),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensLoop),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenPingPong),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensPingPong)),this._pingPongState++,this._pingPongState=C33.wrap(this._pingPongState,0,2)):this._playheadTime<=0&&(this._SetTime(0),this.SetPlaybackRate(-1*this.GetPlaybackRate()),t=!0,this._pingPongState===PING_PONG_BEGIN&&(this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenPingPong),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensPingPong)),this._pingPongState===PING_PONG_END&&(this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenLoop),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensLoop),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenPingPong),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensPingPong)),this._pingPongState++,this._pingPongState=C33.wrap(this._pingPongState,0,2))):0<this._playbackRate?this._playheadTime>=l&&(this._currentRepeatCount<this.GetRepeatCount()?(this._currentRepeatCount++,this._SetTimeAndReset(0),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenLoop),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensLoop),t=!0):(this._SetTime(l),e=!0)):this._playheadTime<=0&&(this._currentRepeatCount<this.GetRepeatCount()?(this._currentRepeatCount++,this._SetTimeAndReset(l),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenLoop),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensLoop),t=!0):(this._SetTime(0),e=!0)),e?(this._track.SetEndState(),this.Stop(!0),this.OnCompleted()):(this._track.Interpolate(this._playheadTime,!0,!1,t,this._firstTick,!1),this._firstTick&&(this._firstTick=!1))}}}_TweenTrigger(e){const t=this.GetInstance(),s=t.GetBehaviorSdkInstanceFromCtor(C33.Behaviors.Tween);s.PushTriggerTween(this),this._runtime.Trigger(e,t,s.GetBehaviorType()),s.PopTriggerTween()}_SaveToJson(){const e=super._SaveToJson(),t=this.GetTimelineDataItem();return Object.assign(e,{tweenDataItemJson:t._SaveToJson(),id:this._id,destroyInstanceOnComplete:this._destroyInstanceOnComplete,initialValueMode:this._initialValueMode})}_LoadFromJson(e){if(e){const t=this.GetTimelineDataItem();t._LoadFromJson(e.tweenDataItemJson),super._LoadFromJson(e),this._id=e.id,this._destroyInstanceOnComplete=e.destroyInstanceOnComplete,this._initialValueMode=e.initialValueMode,this._CacheTrack()}}static IsPlaying(e){return e.IsPlaying()}static IsPaused(e){return e.IsPaused()}static IsPing(e){return!!e.GetPingPong()&&e.GetPingPongState()===PING_PONG_BEGIN}static IsPong(e){return!!e.GetPingPong()&&e.GetPingPongState()===PING_PONG_END}static Build(e){const t=e.runtime.GetTimelineManager(),s=new C33.TimelineDataItem;if(e.json){s._LoadFromJson(e.json.tweenDataItemJson);const i=new C33.TweenState(s,t);return i._LoadFromJson(e.json),i}{const n=new C33.TweenState(s,t),r=(C33.IsArray(e.propertyTracksConfig)||(e.propertyTracksConfig=[e.propertyTracksConfig]),n.SetId(e.id),n.SetTags(e.tags),n.SetInitialValueMode(e.initialValueMode),n.SetDestroyInstanceOnComplete(e.releaseOnComplete),n.SetLoop(e.loop),n.SetPingPong(e.pingPong),n.SetTotalTime(e.time),n.SetStep(0),n.SetInterpolationMode("default"),n.SetResultMode(e.propertyTracksConfig[0].resultMode),n.SetRepeatCount(e.repeatCount),n.AddTrack()),a=(r.SetInstanceUID(e.instance.GetUID()),r.SetInterpolationMode("default"),r.SetResultMode(e.propertyTracksConfig[0].resultMode),r.SetEnable(!0),r.SetObjectClassIndex(e.instance.GetObjectClass().GetIndex()),e.instance.GetSdkInstance()),o=a.IsOriginalSizeKnown()?a.GetOriginalWidth():e.instance.GetWorldInfo().GetWidth(),l=a.IsOriginalSizeKnown()?a.GetOriginalHeight():e.instance.GetWorldInfo().GetHeight(),h=(r.SetOriginalWidth(o),r.SetOriginalHeight(l),r.AddKeyframe()),c=(h.SetTime(0),h.SetEase("noease"),h.SetEnable(!0),h.SetTags(""),r.AddKeyframe());c.SetTime(e.time),c.SetEase("noease"),c.SetEnable(!0),c.SetTags("");for(const u of e.propertyTracksConfig){const _=r.AddPropertyTrack(),d=(_.SetSourceAdapterId(u.sourceId),_.SetSourceAdapterArgs(u.sourceArgs),_.SetPropertyName(u.property),_.SetPropertyType(u.type),_.SetMin(NaN),_.SetMax(NaN),_.SetInterpolationMode("default"),_.SetResultMode(u.resultMode),_.SetEnable(!0),_.AddPropertyKeyframe()),p=(d.SetType(u.valueType),d.SetTime(0),d.SetEase(u.ease),d.SetEnable(!0),d.SetValue(u.startValue),d.SetAbsoluteValue(u.startValue),_.AddPropertyKeyframe());p.SetType(u.valueType),p.SetTime(e.time),p.SetEase(u.ease),p.SetEnable(!0),p.SetValue(u.endValue),p.SetAbsoluteValue(u.endValue),_.GetSourceAdapter()}return n}}static SetInstanceUID(e,t){if(!isNaN(t))for(const s of e.GetTracks())s.SetInstanceUID(t)}GetITweenState(e,t){return this._iTweenState||(this._iTweenState=C33.New(self.ITweenState,this,e,t)),this._iTweenState}}}{const C33=self.C3;C33.TweenTrackState=class extends C33.TrackState{constructor(e,t){super(e,t),this._firstPropertyTrack=null,this._secondPropertyTrack=null}static Create(e,t){return C33.New(C33.TweenTrackState,e,t)}_CachePropertyTracks(){1===this._propertyTracks.length?this._firstPropertyTrack=this._propertyTracks[0]:(this._firstPropertyTrack=this._propertyTracks[0],this._secondPropertyTrack=this._propertyTracks[1])}CreatePropertyTrackStates(){for(const e of this._trackDataItem.GetPropertyTrackData().propertyTrackDataItems())this._propertyTracks.push(C33.TweenPropertyTrackState.Create(this,e));this._CachePropertyTracks()}AddPropertyTrack(){const e=this._trackDataItem.GetPropertyTrackData(),t=e.AddEmptyPropertyTrackDataItem(),s=C33.TweenPropertyTrackState.Create(this,t);return this._propertyTracks.push(s),this._CachePropertyTracks(),s}SetInitialState(){if(this.MaybeGetInstance(),this.IsInstanceValid()||!this.IsInstanceTrack()){const e=this.GetTimeline(),t=e.IsForwardPlayBack(),s=t?0:this.GetLocalTotalTime();for(const n of this._propertyTracks)n.SetInitialState(s),0===this._worldInfoChange&&1===n.GetWorldInfoChange()&&(this._worldInfoChange=1),0===this._renderChange&&1===n.GetRenderChange()&&(this._renderChange=1);this._needsBeforeAndAfter=0;const i=this._propertyTracks.some(e=>e.GetNeedsBeforeAndAfter());i&&(this._needsBeforeAndAfter=1),this._lastKeyframeDataItem=this._GetLastKeyFrameBeforeTime(s),this._initialStateOfNestedSet=!1,this._endStateOfNestedSet=!1,this.Interpolate(s)}}BeforeInterpolate(){}Interpolate(e,t=0,s=!1,i=!1,n,r=!1,a=!1){if(this._instance||this.GetInstance(),this._instance){const o=!this._instance.IsDestroyed();return o&&(!r||!this.GetObjectClass().IsGlobal())&&((this._secondPropertyTrack?(this._firstPropertyTrack.Interpolate(e,s,i,a),this._secondPropertyTrack):this._firstPropertyTrack).Interpolate(e,s,i,a),void(0!==this._firstPropertyTrack.GetWorldInfoChange()&&(this._worldInfo||(this._worldInfo=this._instance.GetWorldInfo()),this._worldInfo)&&this._worldInfo.SetBboxChanged()))}}AfterInterpolate(){}_LoadFromJson(e){super._LoadFromJson(e),this._CachePropertyTracks()}}}{const C33=self.C3;C33.TweenPropertyTrackState=class extends C33.PropertyTrackState{constructor(e,t){super(e,t),this._basic=!1}static Create(e,t){return C33.New(C33.TweenPropertyTrackState,e,t)}Interpolate(e,t=!1,s=!1,i=!1){let n,r;if(this._basic)n=this._propertyKeyframeDataItems[0],r=this._propertyKeyframeDataItems[1];else{if(t)n=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,this._propertyTrackDataItem);else{if(this._lastPropertyKeyframeDataItem){const a=this.GetTimeline(),o=this._lastPropertyKeyframeDataItem.GetNext(),l=this._lastPropertyKeyframeDataItem.GetTime(),h=o?o.GetTime():a.GetTotalTime();(e<=l||h<=e)&&(this._lastPropertyKeyframeDataItem=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,this._propertyTrackDataItem))}else this._lastPropertyKeyframeDataItem=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,this._propertyTrackDataItem);n=this._lastPropertyKeyframeDataItem}r=n.GetNext()}this._sourceAdapter.Interpolate(e,n,r,t,s,i)}AddPropertyKeyframe(){const e=this._propertyTrackDataItem.GetPropertyKeyframeData(),t=e.AddEmptyPropertyKeyframeDataItem();return this._lastPropertyKeyframeDataItem=null,this._basic=this.GetPropertyKeyframeDataItems().length<=2,t}DeletePropertyKeyframes(e){this._lastPropertyKeyframeDataItem=null;const t=this._propertyTrackDataItem.GetPropertyKeyframeData();t.DeletePropertyKeyframeDataItems(e),this._basic=this.GetPropertyKeyframeDataItems().length<=2}_SaveToJson(){return{sourceAdapterJson:this.GetSourceAdapter()._SaveToJson(),basic:this._basic}}_LoadFromJson(e){e&&(this.GetSourceAdapter()._LoadFromJson(e.sourceAdapterJson),this._basic=e.basic)}}}{const C33=self.C3,Ease=self.Ease,NAME=0,TRANSITION_KEYFRAMES=1,LINEAR=2;C33.Transition=class extends C33.DefendedBase{constructor(e,t=!0){super(),this._name=e[NAME],this._linear=e[LINEAR],this._transitionKeyframes=[];for(const s of e[TRANSITION_KEYFRAMES]){const i=C33.TransitionKeyframe.Create(this,s);this._transitionKeyframes.push(i)}for(let e=0;e<this._transitionKeyframes.length;e++){const n=this._transitionKeyframes[e],r=this._transitionKeyframes[e+1],a=this._transitionKeyframes[e-1];n.SetNext(r),n.SetPrevious(a)}this._precalculatedSamples=new Map,this._transitionKeyframeCache=new Map,this._PreCalcSamples(),t&&Ease.AddCustomEase(this._name,(e,t,s,i)=>this.Interpolate(e,t,s,i),null,{transition:this})}static Create(e){return C33.New(C33.Transition,e)}Release(){for(const e of this._transitionKeyframes)e.Release();C33.clearArray(this._transitionKeyframes),this._transitionKeyframes=null,this._precalculatedSamples.clear(),this._precalculatedSamples=null,this._transitionKeyframeCache.clear(),this._transitionKeyframeCache=null}MakeLinear(e){this._linear=!!e}GetTransitionKeyFrameAt(e){const t=this._transitionKeyframeCache.get(e);if(t)return t;for(const s of this._transitionKeyframes)if(s.GetValueX()===e)return this._transitionKeyframeCache.set(e,s),s}GetFirstTransitionKeyFrameLowerOrEqualThan(t){for(let e=this._transitionKeyframes.length-1;0<=e;e--){const s=this._transitionKeyframes[e],i=s.GetValueX();if(i<=t){let e=s;if(i<t)return e;if(i===t){for(;e;){const n=e.GetPrevious();if(!n)break;if(n.GetValueX()!==e.GetValueX())break;e=n}return e}}}}Interpolate(e,t,s,i){let n=e/i;if(this._linear){const S=this.GetTransitionKeyFrameAt(0),C=this.GetTransitionKeyFrameAt(1),y=t+(t+s)*S.GetValueY(),G=(t+s)*C.GetValueY(),I=G-y;return 0===i?y+I:Ease.NoEase(e,y,I,i)}0===i&&(n=1);let r=this.GetFirstTransitionKeyFrameLowerOrEqualThan(n),a=r.GetNext();if(!a){const T=r.GetPrevious(),b=r;r=T,a=b}const o=a.GetValueX()-r.GetValueX(),l=C33.mapToRange(n,r.GetValueX(),a.GetValueX(),0,o);if(r.IsSegmentLinear()||0==o){const P=t+(t+s)*r.GetValueY(),A=(t+s)*a.GetValueY(),R=A-P;return 0==o?1===l?P+R:P:Ease.NoEase(l,P,R,o)}let h=r.GetValueX(),c=r.GetValueY(),u=r.GetValueX()+r.GetStartAnchorX(),_=r.GetValueY()+r.GetStartAnchorY(),d=a.GetValueX()+a.GetEndAnchorX(),p=a.GetValueY()+a.GetEndAnchorY(),m=a.GetValueX(),g=a.GetValueY(),f=Ease.GetRuntimeEase("spline")(l,h,c,u,_,d,p,m,g,this._precalculatedSamples.get(r));return(1-(f+=r.GetValueY()))*t+f*(t+s)}_PreCalcSamples(){this._precalculatedSamples.clear();for(let e=0;e<this._transitionKeyframes.length-1;e++){const t=this._transitionKeyframes[e];if(t.GetStartEnable()){const s=t,i=this._transitionKeyframes[e+1];if(i.GetEndEnable()){const n=s.GetValueX(),r=s.GetValueX()+s.GetStartAnchorX(),a=i.GetValueX()+i.GetEndAnchorX(),o=i.GetValueX();this._precalculatedSamples.set(s,Ease.GetBezierSamples(n,r,a,o))}}}}}}{const C33=self.C3,VALUE_X=0,VALUE_Y=1,START_ANCHOR_X=2,START_ANCHOR_Y=3,END_ANCHOR_X=4,END_ANCHOR_Y=5,START_ENABLE=6,END_ENABLE=7,SEGMENT_MODE=8;C33.TransitionKeyframe=class extends C33.DefendedBase{constructor(e,t){super(),this._transition=e,this._valueX=t[VALUE_X],this._valueY=t[VALUE_Y],this._startAnchorX=t[START_ANCHOR_X],this._startAnchorY=t[START_ANCHOR_Y],this._endAnchorX=t[END_ANCHOR_X],this._endAnchorY=t[END_ANCHOR_Y],this._startEnable=t[START_ENABLE],this._endEnable=t[END_ENABLE],this._segmentMode=t[SEGMENT_MODE],this._next=null,this._prev=null}Release(){this._transition=null}static Create(e,t){return C33.New(C33.TransitionKeyframe,e,t)}SetNext(e){this._next=e}GetNext(){return this._next}SetPrevious(e){this._prev=e}GetPrevious(){return this._prev}GetValueX(){return this._valueX}GetValueY(){return this._valueY}GetStartAnchorX(){return this._startAnchorX}GetStartAnchorY(){return this._startAnchorY}GetEndAnchorX(){return this._endAnchorX}GetEndAnchorY(){return this._endAnchorY}GetStartEnable(){return this._startEnable}GetEndEnable(){return this._endEnable}IsSegmentLinear(){return"linear"===this._segmentMode}IsSegmentCubic(){return"cubic"===this._segmentMode}}}{const C33=self.C3;C33.TransitionManager=class extends C33.DefendedBase{constructor(e){super(),this._runtime=e,this._transitions=[]}Release(){for(const e of this._transitions)e.Release();C33.clearArray(this._transitions),this._transitions=null}Create(e){this._transitions.push(C33.Transition.Create(e))}}}{const C33=self.C3;C33.TemplateManager=class extends C33.DefendedBase{constructor(e){super(),this._runtime=e,this._templateDataMap=null,this._instanceToTemplateNameMap=null,this._instanceDestroy=e=>this._OnInstanceDestroy(e.instance)}Release(){if(this.RemoveRuntimeListeners(),this._templateDataMap){for(const e of this._templateDataMap.values())e.clear();this._templateDataMap.clear()}this._templateDataMap=null,this._runtime=null}Create(e){if(this._templateDataMap||(this._templateDataMap=new Map),e){const t=e[0][16],s=t[0],i=e[1],n=(this._templateDataMap.has(i)||this._templateDataMap.set(i,new Map),this._templateDataMap.get(i));n.set(s,e)}}AddRuntimeListeners(){const e=this._runtime.Dispatcher();e&&e.addEventListener("instancedestroy",this._instanceDestroy)}RemoveRuntimeListeners(){const e=this._runtime.Dispatcher();e&&e.removeEventListener("instancedestroy",this._instanceDestroy)}HasTemplates(){return!!this._templateDataMap&&0!==this._templateDataMap.size}GetTemplateData(e,t){let s;if(s=e instanceof C33.ObjectClass?e.GetIndex():e,this._templateDataMap.has(s)){const i=this._templateDataMap.get(s).get(t);return i?JSON.parse(JSON.stringify(i)):void 0}}MapInstanceToTemplateName(e,t){this._instanceToTemplateNameMap||(this._instanceToTemplateNameMap=new WeakMap),this._instanceToTemplateNameMap.has(e)||this._instanceToTemplateNameMap.set(e,t)}GetInstanceTemplateName(e){if(!this._instanceToTemplateNameMap)return"";const t=this._instanceToTemplateNameMap.get(e);return t||""}_OnInstanceDestroy(e){this._instanceToTemplateNameMap&&this._instanceToTemplateNameMap.has(e)&&this._instanceToTemplateNameMap.delete(e)}}}{const C33=self.C3;C33.FlowchartManager=class{constructor(e){this._runtime=e,this._flowchartDataManager=new C33.FlowchartDataManager}Release(){this._flowchartDataManager.Release(),this._flowchartDataManager=null,this._runtime=null}GetRuntime(){return this._runtime}Create(e){this._flowchartDataManager.Add(e)}GetFlowchartDataItemByName(e){return this._flowchartDataManager.Get(e)}HasFlowcharts(){return this._flowchartDataManager.HasFlowcharts()}}}{const C33=self.C3;C33.FlowchartState=class{constructor(e,t,s,i,n,r,a){this._runtime=n.GetRuntime(),this._flowchartManager=n,this._flowchartName=e,this._startNodeTag=s,this._flowchartDataItem=i,this._tag=t,this._pluginInstance=r,this._pluginUID=a??r.GetInstance().GetUID(),this._SetStartFlowchartNode(),this._currentFlowchartNodeId=this._startFlowchartNode?.GetFlowchartId()??-1,this._previousFlowchartNodeIds=[],this._previousFlowchartState=null,this._previousFlowchartStateStartNodeId=NaN,this._referenceFlowchartStates=null,this._currentReferenceFlowchartState=null,this._rootFlowchartState=null,this._previousFlowchartStateTag="",this._referenceFlowchartStatesJson=null,this._currentReferenceFlowchartStateTag="",this._rootFlowchartStateTag="",this._triggerCount=0,this._markForRelease=!1,this._released=!1}Release(){this._released||(C33.clearArray(this._previousFlowchartNodeIds),this._previousFlowchartNodeIds=null,this._runtime=null,this._flowchartManager=null,this._flowchartDataItem=null,this._pluginInstance=null,this._previousFlowchartState=null,this._previousFlowchartStateStartNodeId=NaN,this._referenceFlowchartStates&&this._referenceFlowchartStates.clear(),this._referenceFlowchartStates=null,this._currentReferenceFlowchartState=null,this._rootFlowchartState=null,this._previousFlowchartStateTag="",this._referenceFlowchartStatesJson=null,this._currentReferenceFlowchartStateTag="",this._rootFlowchartStateTag="",this._released=!0)}WasReleased(){return this._released}GetFlowchartManager(){return this._flowchartManager}GetRuntime(){return this._runtime}GetName(){return this._flowchartName}GetFlowchartDataItem(){return this._flowchartDataItem}GetTag(){return this._tag}GetPluginInstance(){return this._pluginInstance||(this._pluginInstance=this._runtime.GetInstanceByUID(this._pluginUID).GetSdkInstance()),this._pluginInstance}GetCurrentNode(){return this.GetFlowchartElementById(this._currentFlowchartNodeId)}GetCurrentNodeTag(){const e=this.GetCurrentNode();return e?e.GetTag():""}GetCurrentNodeTags(){const e=this.GetCurrentNode();return e?e.GetTags():[]}CurrentNodeHasTags(e){const t=this.GetCurrentNodeTags();if(!t)return!1;if(!t.length)return!1;const s=C33.FlowchartState._GetTagArray(e);return!(!s||!s.length)&&s.every(C33.FlowchartState._HasTag,t)}CurrentNodeCompareTags(e,t){const s=this.GetCurrentNodeTags();if(!s)return!1;if(!s.length)return!1;const i=C33.FlowchartState._GetTagArray(e);return!(!i||!i.length)&&i.every(e=>C33.FlowchartState._CompareTag.call(s,e,t))}static _HasTag(e){return""===e?1===this.length&&""===this[0]:this.map(e=>e.trim().toLowerCase()).includes(e.trim().toLowerCase())}static _GetTagArray(e){return e.trim().split(" ")}static _CompareTag(t,s){return""===t?1===this.length&&""===this[0]:this.some(e=>C33.compare(e.trim(),s,t.trim()))}GetCurrentNodeParent(e){const t=this.GetCurrentNode();if(t){if(C33.IsFiniteNumber(e)){const s=t.GetParentFlowchartIds(),i=s?s[e]:void 0;if(C33.IsFiniteNumber(i))return this.GetFlowchartElementById(i)}if("string"==typeof e)for(const n of t.GetParentFlowchartIds()){const r=this.GetFlowchartElementById(n);if(r.HasTags(e))return this.GetFlowchartElementById(r.GetFlowchartId())}}}GetCurrentNodeParentTag(e){const t=this.GetCurrentNodeParent(e);return t?t.GetTag():""}GetCurrentNodeParentTags(e){const t=this.GetCurrentNodeParent(e);return t?t.GetTags():""}GetCurrentNodeParentIndex(e){const t=this.GetCurrentNode();if(!t)return-1;const s=t.GetParentFlowchartIds();if(!s)return-1;const i=this.GetCurrentNodeParent(e);return i?s.indexOf(i.GetFlowchartId()):-1}GetCurrentNodeParentCount(){const e=this.GetCurrentNode();if(!e)return 0;const t=e.GetParentFlowchartIds();return t?t.length:0}GetFlowchartElementById(e){return this._flowchartDataItem.GetFlowchartElementById(e)}Reset(){const e=this._GetRootFlowchartState();e._Reset(!0)}_Reset(e){if(this._GetReferenceFlowchartStates()){for(const[t,s]of this._GetReferenceFlowchartStates().entries())s._Reset(!1);this._GetReferenceFlowchartStates().clear()}if(this._referenceFlowchartStates=null,this._previousFlowchartState=null,this._previousFlowchartStateStartNode=null,this._currentReferenceFlowchartState=null,this._previousFlowchartStateTag="",this._referenceFlowchartStatesJson=null,this._currentReferenceFlowchartStateTag="",this._rootFlowchartStateTag="",this._previousFlowchartNodeIds=[],e){this._flowchartManager.SetCurrentFlowchartState(this);const i=this._startFlowchartNode.GetFlowchartId();i!==this._currentFlowchartNodeId&&this._GotoFlowchartNode(i)}else this._currentFlowchartNodeId=this._startFlowchartNode.GetFlowchartId()}GetCurrentNodeOutputCount(){const e=this._flowchartDataItem.GetFlowchartElementById(this._currentFlowchartNodeId);return e?e.GetFlowchartNodeOutputData().GetFlowchartNodeOutputDataItemCount():0}GetCurrentNodeOutputNameAt(e){const t=this._GetFlowchartNodeOutputAt(e);return t?t.GetName():""}GetCurrentNodeOutputValueAt(e){let t;return C33.IsFiniteNumber(e)&&(t=this._GetFlowchartNodeOutputAt(e)),"string"==typeof e&&(t=this._GetFlowchartNodeOutputByName(e)),"number"!=typeof e&&"string"!=typeof e&&console.warn("[Flowcharts] unexpected argument type in GetCurrentNodeOutputValueAt expression"),t?t.GetValue():""}GotoNextFlowchartNode(e){let t;if(C33.IsFiniteNumber(e)&&(t=this._GetFlowchartNodeOutputAt(e)),t="string"==typeof e?this._GetFlowchartNodeOutputByName(e):t){const s=t.GetConnectedFlowchartNodeFlowchartId();C33.IsFiniteNumber(s)&&(this._previousFlowchartNodeIds.push(this._currentFlowchartNodeId),this._GotoFlowchartNode(s))}}GotoAnyFlowchartNode(e){const t=this._flowchartDataItem.GetFlowchartNodeByTags(e);if(t){const s=this._flowchartDataItem.GetFlowchartElementById(t.GetFlowchartId());s&&(this._previousFlowchartNodeIds.push(this._currentFlowchartNodeId),this._GotoFlowchartNode(s.GetFlowchartId()))}}GotoPreviousFlowchartNode(){const e=this._previousFlowchartNodeIds.pop();C33.IsFiniteNumber(e)?this._GotoFlowchartNode(e):this._GetPreviousFlowchartState()&&(this._flowchartManager.SetCurrentFlowchartState(this._GetPreviousFlowchartState(),!0,!1,!1),this._GetPreviousFlowchartState()._GotoFlowchartNode(this._GetPreviousFlowchartStateStartNodeId()),this._GetRootFlowchartState()._SetCurrentReferenceFlowchart(this._GetPreviousFlowchartState()))}GotoParentFlowchartNode(e){const t=this.GetCurrentNode();if(t){t.GetFlowchartId();const s=this.GetCurrentNodeParent(e);s&&(this._previousFlowchartNodeIds.push(this._currentFlowchartNodeId),this._GotoFlowchartNode(s.GetFlowchartId()))}}HasOutput(t){if(C33.IsFiniteNumber(t)){const e=this._flowchartDataItem.GetFlowchartElementById(this._currentFlowchartNodeId),s=e.GetFlowchartNodeOutputData().GetFlowchartNodeOutputDataItems();return!!s[t]}if("string"==typeof t){const i=this._flowchartDataItem.GetFlowchartElementById(this._currentFlowchartNodeId),n=i.GetFlowchartNodeOutputData().GetFlowchartNodeOutputDataItems();for(let e=0;e<n.length;e++)if(n[e].GetName()===t)return!0}return!1}MarkForRelease(){this._markForRelease=!0}IsInTriggerState(){return 0<this._triggerCount}PushIsTriggerState(){this._triggerCount++}PopIsTriggerState(){this._triggerCount--,0===this._triggerCount&&this._markForRelease&&this._flowchartManager.RemoveFlowchartState(this)}_GotoFlowchartNode(e){const s=this._currentFlowchartNodeId,t=this.GetPluginInstance().GetInstance();if(this.PushIsTriggerState(),this._flowchartManager.PushFlowchartState(this),this._runtime.Trigger(C33.Plugins.Flowchart.Cnds.OnBeforeAnyNodeChange,t),this._runtime.Trigger(C33.Plugins.Flowchart.Cnds.OnBeforeTaggedNodeChange,t),this._runtime.Trigger(C33.Plugins.Flowchart.Cnds.OnBeforeAnyNodeChangeInFlowchart,t),this._runtime.Trigger(C33.Plugins.Flowchart.Cnds.OnBeforeTaggedNodeChangeInFlowchart,t),this._currentFlowchartNodeId=e,this._runtime.Trigger(C33.Plugins.Flowchart.Cnds.OnAnyNodeChange,t),this._runtime.Trigger(C33.Plugins.Flowchart.Cnds.OnTaggedNodeChange,t),this._runtime.Trigger(C33.Plugins.Flowchart.Cnds.OnAnyNodeChangeInFlowchart,t),this._runtime.Trigger(C33.Plugins.Flowchart.Cnds.OnTaggedNodeChangeInFlowchart,t),this._flowchartManager.PopFlowchartState(),this.PopIsTriggerState(),!this.WasReleased()){const i=this.GetFlowchartElementById(this._currentFlowchartNodeId);if("reference"===i.GetType()){const n=i.GetReferenceFlowchartName();if(this._HasReferenceFlowchartState(i)){this._previousFlowchartNodeIds.pop();const r=this._GetReferenceFlowchartState(i),a=(this._flowchartManager.SetCurrentFlowchartState(r,!0,!0,!1),r._SetPreviousFlowchart(this,s),this._GetRootFlowchartState());a._SetCurrentReferenceFlowchart(r)}else{const o=i.GetReferenceFlowchartStartNodeTag();if(n){this._previousFlowchartNodeIds.pop();let t=i.GetReferenceFlowchartTag();if(t){let e=this._flowchartManager.GetFlowchartState(t);for(;e;)t=C33.IncrementNumberAtEndOf(t),e=this._flowchartManager.GetFlowchartState(t)}else{t=n+"-ref";let e=this._flowchartManager.GetFlowchartState(t);for(;e;)t=C33.IncrementNumberAtEndOf(t),e=this._flowchartManager.GetFlowchartState(t)}const l=this._flowchartManager.AddFlowchartState(n,o,t,this._pluginInstance,!0),h=(l._SetPreviousFlowchart(this,s),this._SetReferenceFlowchartState(i,l),this._GetRootFlowchartState());l._SetRootFlowchartState(h),h._SetCurrentReferenceFlowchart(l)}}}}}_GetFlowchartNodeOutputAt(e){const t=this._flowchartDataItem.GetFlowchartElementById(this._currentFlowchartNodeId);if(!t)return null;const s=t.GetFlowchartNodeOutputData().GetFlowchartNodeOutputDataItems();if(!s)return null;const i=s[e];return i||null}_GetFlowchartNodeOutputByName(e){const t=this._flowchartDataItem.GetFlowchartElementById(this._currentFlowchartNodeId);if(!t)return null;const s=t.GetFlowchartNodeOutputData().GetFlowchartNodeOutputDataItemByName(e);return s||null}_SetStartFlowchartNode(t){if("number"==typeof t){let e=this.GetFlowchartElementById(t);e=e||this._flowchartDataItem.GetFlowchartStartNode(),this._startFlowchartNode=e}else{let e=this._flowchartDataItem.GetFlowchartNodeByTags(this._startNodeTag);e=e||this._flowchartDataItem.GetFlowchartStartNode(),this._startFlowchartNode=e}}_SaveToJson(){return this._markForRelease?null:{flowchartName:this._flowchartName,flowchartTag:this._tag,startNodeTag:this._startNodeTag,currentNodeId:this._currentFlowchartNodeId,previousNodeIds:this._previousFlowchartNodeIds,pluginUID:this._pluginInstance.GetInstance().GetUID(),reference:{previousFlowchartTag:this._GetPreviousFlowchartState()?this._GetPreviousFlowchartState().GetTag():"",previousStartNodeId:C33.IsFiniteNumber(this._GetPreviousFlowchartStateStartNodeId())?this._GetPreviousFlowchartStateStartNodeId():NaN,referencesJson:this._GetFlowchartReferencesJson(),currentReferenceFlowchartTag:this.GetCurrentReferenceFlowchart()?this.GetCurrentReferenceFlowchart().GetTag():"",rootFlowchartTag:this._GetRootFlowchartState()?this._GetRootFlowchartState().GetTag():""}}}_GetFlowchartReferencesJson(){if(!this._HasReferenceFlowchartStates())return null;const e=[];for(const[t,s]of this._GetReferenceFlowchartStates().entries())e.push({flowchartElementId:t.GetFlowchartId(),flowchartStateTag:s.GetTag()});return e.length?e:null}_LoadFromJson(e){if(e){if(this._flowchartName=e.flowchartName,this._tag=e.flowchartTag,this._startNodeTag=e.startNodeTag,this._currentFlowchartNodeId=e.currentNodeId,this._previousFlowchartNodeIds=e.previousNodeIds,this._pluginUID=e.pluginUID,e.hasOwnProperty("reference")){const t=e.reference;this._previousFlowchartStateTag=t.previousFlowchartTag,this._previousFlowchartStateStartNodeId=t.previousStartNodeId,this._referenceFlowchartStatesJson=t.referencesJson,this._currentReferenceFlowchartStateTag=t.currentReferenceFlowchartTag,this._rootFlowchartStateTag=t.rootFlowchartTag}this._SetStartFlowchartNode()}}_GetPreviousFlowchartState(){return"string"==typeof this._previousFlowchartStateTag&&this._previousFlowchartStateTag&&(this._previousFlowchartState=this._flowchartManager.GetFlowchartState(this._previousFlowchartStateTag),this._previousFlowchartStateTag=""),this._previousFlowchartState}_GetPreviousFlowchartStateStartNodeId(){return this._previousFlowchartStateStartNodeId}_SetPreviousFlowchart(e,t){this._previousFlowchartState=e,this._previousFlowchartStateStartNodeId=t}GetCurrentReferenceFlowchart(){return"string"==typeof this._currentReferenceFlowchartStateTag&&this._currentReferenceFlowchartStateTag&&(this._currentReferenceFlowchartState=this._flowchartManager.GetFlowchartState(this._currentReferenceFlowchartStateTag),this._currentReferenceFlowchartStateTag=""),this._currentReferenceFlowchartState}_SetCurrentReferenceFlowchart(e){this._currentReferenceFlowchartState=e,this._currentReferenceFlowchartState===this&&(this._currentReferenceFlowchartState=null)}_GetRootFlowchartState(){return"string"==typeof this._rootFlowchartStateTag&&this._rootFlowchartStateTag&&(this._rootFlowchartState=this._flowchartManager.GetFlowchartState(this._rootFlowchartStateTag),this._rootFlowchartStateTag=""),this._rootFlowchartState||this}_SetRootFlowchartState(e){this._rootFlowchartState=e}_HasReferenceFlowchartStates(){return this._RebuildReferenceFlowchartStates(),!!this._referenceFlowchartStates}_HasReferenceFlowchartState(e){return this._RebuildReferenceFlowchartStates(),this._referenceFlowchartStates&&this._referenceFlowchartStates.has(e)}_RebuildReferenceFlowchartStates(){if(this._referenceFlowchartStatesJson){this._referenceFlowchartStates&&this._referenceFlowchartStates.clear(),this._referenceFlowchartStates||(this._referenceFlowchartStates=new Map);for(const e of this._referenceFlowchartStatesJson){const t=this._flowchartManager.GetFlowchartState(e.flowchartStateTag),s=t.GetFlowchartElementById(e.flowchartElementId);this._referenceFlowchartStates.set(s,t)}this._referenceFlowchartStatesJson=null}}_GetReferenceFlowchartStates(){return this._RebuildReferenceFlowchartStates(),this._referenceFlowchartStates}_GetReferenceFlowchartState(e){return this._RebuildReferenceFlowchartStates(),this._referenceFlowchartStates.get(e)}_SetReferenceFlowchartState(e,t){this._referenceFlowchartStates||(this._referenceFlowchartStates=new Map),this._referenceFlowchartStates.set(e,t)}}}{const C33=self.C3;C33.FlowchartStateManager=class{constructor(e){this._runtime=e,this._flowchartStates=new Map,this._currentFlowchartState=null,this._flowchartStateStack=[],this._on_after_load=()=>this._OnAfterLoad(),this._loadJson=null}Release(){C33.clearArray(this._flowchartStateStack),this._flowchartStateStack=null,this._flowchartStates.clear(),this._flowchartStates=null,this._currentFlowchartState=null,this._runtime=null,this._loadJson=null}GetRuntime(){return this._runtime}AddFlowchartState(e,t,s,i,n,r){const a=this._runtime.GetFlowchartManager().GetFlowchartDataItemByName(e);if(a){if(!this._flowchartStates.has(s)){const o=new C33.FlowchartState(e,s,t,a,this,i,r);return this._flowchartStates.set(s,o),n&&this.SetCurrentFlowchartState(o,!0),o}{const l=this._flowchartStates.get(s);l&&this.RemoveFlowchartState(l)}}else console.warn(`[Flowcharts] no flowchart found with name '${e}'`)}RemoveFlowchartState(e){if(e.MarkForRelease(),!e.IsInTriggerState()){const t=e.GetTag();this._flowchartStates.delete(t),e.Release(),this._currentFlowchartState===e&&(this._currentFlowchartState=null)}}ResetFlowchartState(e){e.Reset()}GetFlowchartState(e){return this._flowchartStates.get(e)}PushFlowchartState(e){this._flowchartStateStack.push(e)}PopFlowchartState(){this._flowchartStateStack.pop()}SetCurrentFlowchartState(e,t=!1,s=!1,i=!0){if(i){const n=e.GetCurrentReferenceFlowchart();e=n||e}e!==this._currentFlowchartState&&(this._TriggerBeforeFlowchartChange(),this._TriggerAfterFlowchartChange(e,t,s))}GetCurrentFlowchartState(e){return"string"==typeof e?this.GetFlowchartState(e):this._flowchartStateStack.length?this._flowchartStateStack[this._flowchartStateStack.length-1]:this._currentFlowchartState}_TriggerBeforeFlowchartChange(){if(this._currentFlowchartState&&!this._currentFlowchartState.WasReleased()){const e=this._currentFlowchartState.GetPluginInstance().GetInstance();this._currentFlowchartState.PushIsTriggerState(),this.PushFlowchartState(this._currentFlowchartState),this._runtime.Trigger(C33.Plugins.Flowchart.Cnds.OnBeforeFlowchartChange,e),this.PopFlowchartState(),this._currentFlowchartState.PopIsTriggerState()}}_TriggerAfterFlowchartChange(e,t=!1,s=!1){if(this._currentFlowchartState=e,this._currentFlowchartState&&!this._currentFlowchartState.WasReleased()){const i=this._currentFlowchartState.GetPluginInstance().GetInstance();this._currentFlowchartState.PushIsTriggerState(),this.PushFlowchartState(this._currentFlowchartState),this._runtime.Trigger(C33.Plugins.Flowchart.Cnds.OnFlowchartChange,i),!0!==s&&"number"!=typeof s||this._currentFlowchartState._SetStartFlowchartNode(s),t&&(this._runtime.Trigger(C33.Plugins.Flowchart.Cnds.OnAnyNodeChange,i),this._runtime.Trigger(C33.Plugins.Flowchart.Cnds.OnTaggedNodeChange,i)),this.PopFlowchartState(),this._currentFlowchartState.PopIsTriggerState()}}_SaveToJson(){return{flowchartJsonObjects:[...this._flowchartStates.values()].map(e=>e._SaveToJson()),currentFlowchartTag:this._currentFlowchartState?this._currentFlowchartState.GetTag():null}}_LoadFromJson(e){if(e){this._loadJson=e;const t=new Map;for(const s of this._loadJson.flowchartJsonObjects){const i=s.flowchartTag;if(this._flowchartStates.has(i)){const n=this._flowchartStates.get(i);n._LoadFromJson(s),t.set(i,n)}else{const r=this.AddFlowchartState(s.flowchartName,s.startNodeTag,s.flowchartTag,null,!1,s.pluginUID);r._LoadFromJson(s),t.set(s.flowchartTag,r)}}for(const[a,o]of this._flowchartStates.entries())t.has(a)||o.Release();this._flowchartStates.clear(),this._flowchartStates=t,this._runtime.IsLoadingState()?this._runtime.Dispatcher().addEventListener("afterload",this._on_after_load):this._OnAfterLoad()}}_OnAfterLoad(){this._runtime.Dispatcher().removeEventListener("afterload",this._on_after_load);const e=this._flowchartStates.get(this._loadJson.currentFlowchartTag);e&&this.SetCurrentFlowchartState(e,!0),this._loadJson=null}}}{const C33=self.C3;C33.FlowchartDataManager=class{constructor(){this._flowchartDataItems=new Map}Release(){for(const e of this._flowchartDataItems.values())e.Release();this._flowchartDataItems.clear(),this._flowchartDataItems=null}Add(e){const t=new C33.FlowchartDataItem(e),s=t.GetName();this._flowchartDataItems.set(s,t)}Get(e){return this._flowchartDataItems.get(e)}HasFlowcharts(){return!!this._flowchartDataItems.size}static CreateDataItems(e,t,s,i){if(t)for(const n of t){const r=new s(n,i);e.push(r)}}}}{const C33=self.C3,NAME=0,NODES=1;C33.FlowchartDataItem=class{constructor(e){this._name=e[NAME],this._flowchartNodeData=new C33.FlowchartNodeData(e[NODES],this)}Release(){this._flowchartNodeData.Release(),this._flowchartNodeData=null}GetFlowchartNodeData(){return this._flowchartNodeData}GetFlowchartElementById(e){return this._flowchartNodeData.GetFlowchartElementById(e)}GetFlowchartNodeByTags(e){return this._flowchartNodeData.GetFlowchartNodeByTags(e)}GetFlowchartStartNode(){return this._flowchartNodeData.GetFlowchartStartNode()}GetName(){return this._name}}}{const C33=self.C3,FLOWCHART_ID=0,TAG=1,PARENT_FLOWCHART_IDS=2,PARENT_OUTPUT_FLOWCHART_IDS=3,CHILDREN_FLOWCHART_IDS=4,OUTPUTS=5,IS_START=6,TYPE=7,REFERENCE_FLOWCHART=8,REFERENCE_FLOWCHART_START_NODE=9,REFERENCE_FLOWCHART_TAG=10;class FlowchartNodeDataItem{constructor(e,t){this._flowchartNodeData=t,this._type=e[TYPE],this._flowchartId=e[FLOWCHART_ID],this._tag=e[TAG],this._tag?this._tags=this._tag.trim().split(" ").map(e=>e.trim()):this._tags=[],this._parentFlowchartIds=e[PARENT_FLOWCHART_IDS],this._parentOutputFlowchartIds=null,this._childrenFlowchartIds=null,"dictionary"===this._type&&(this._parentOutputFlowchartIds=e[PARENT_OUTPUT_FLOWCHART_IDS],this._childrenFlowchartIds=e[CHILDREN_FLOWCHART_IDS]),this._isStart=e[IS_START],this._referenceFlowchartName=null,this._referenceFlowchartStartNodeTag=null,this._referenceFlowchartTag=null,"reference"===this._type&&(this._referenceFlowchartName=e[REFERENCE_FLOWCHART],this._referenceFlowchartStartNodeTag=e[REFERENCE_FLOWCHART_START_NODE],this._referenceFlowchartTag=e[REFERENCE_FLOWCHART_TAG]),this._flowchartNodeOutputData=new C33.FlowchartNodeOutputData(e[OUTPUTS],this)}Release(){this._flowchartNodeData=null}GetFlowchartNodeData(){return this._flowchartNodeData}GetFlowchartNodeOutputData(){return this._flowchartNodeOutputData}GetFlowchartId(){return this._flowchartId}GetTag(){return this._tag}GetTags(){return this._tags}HasTags(e){if(!this._tags)return!1;if(!this._tags.length)return!1;const t=C33.FlowchartState._GetTagArray(e);return!(!t||!t.length)&&t.every(C33.FlowchartState._HasTag,this._tags)}GetIsStart(){return this._isStart}SetIsStart(e){this._isStart=!!e}CanBeStartNode(){if("dictionary"===this._type)return!0;if("reference"===this._type)return!1;throw new Error("unexpected flowchart node type: "+this._type)}GetParentFlowchartIds(){return this._parentFlowchartIds}GetParentOutputFlowchartIds(){return this._parentOutputFlowchartIds}GetChildrenFlowchartIds(){return this._childrenFlowchartIds}GetType(){return this._type}GetReferenceFlowchartName(){return this._referenceFlowchartName}GetReferenceFlowchartStartNodeTag(){return this._referenceFlowchartStartNodeTag}GetReferenceFlowchartTag(){return this._referenceFlowchartTag}}C33.FlowchartNodeData=class{constructor(e,t){this._flowchartDataItem=t,this._flowchartNodeItems=[],this._flowchartNodeItemsIdMap=new Map,this._flowchartNodeItemsTagMap=new Map,this._flowchartNodeStartItem=null,C33.FlowchartDataManager.CreateDataItems(this._flowchartNodeItems,e,FlowchartNodeDataItem,this);for(const s of this._flowchartNodeItems){const i=s.GetFlowchartId(),n=s.GetTag(),r=s.GetTags(),a=s.GetIsStart();if(this._flowchartNodeItemsIdMap.set(i,s),n)for(const l of r)this._flowchartNodeItemsTagMap.has(l)||this._flowchartNodeItemsTagMap.set(l,new Set),this._flowchartNodeItemsTagMap.get(l).add(s);a&&(this._flowchartNodeStartItem=s);const o=s.GetFlowchartNodeOutputData();for(const h of o.flowchartNodeOutputDataItems()){const c=h.GetFlowchartId();this._flowchartNodeItemsIdMap.set(c,h)}}this._flowchartNodeStartItem||this._SetStartNodeIfMissing()}Release(){this._flowchartDataItem=null;for(const e of this._flowchartNodeItems)e.Release();C33.clearArray(this._flowchartNodeItems),this._flowchartNodeItems=null}GetFlowchartDataItem(){return this._flowchartDataItem}GetFlowchartElementById(e){return this._flowchartNodeItemsIdMap.get(e)}GetFlowchartNodeByTags(e){if(!e||!e.length)return null;const s=[];for(const i of e.trim().split(" ")){let e=this._flowchartNodeItemsTagMap.get(i.trim())??new Set;if(0===e.size)return null;s.push(e)}const t=s.reduce((e,t)=>t.size<e.size?t:e);return[...t].filter(t=>s.every(e=>e.has(t)))[0]}GetFlowchartStartNode(){return this._flowchartNodeStartItem}*flowchartNodeDataItems(){for(const e of this._flowchartNodeItems)yield e}_SetStartNodeIfMissing(){let e=0;for(const t of this.flowchartNodeDataItems())t.GetIsStart()&&e++;if(0===e){for(const s of this.flowchartNodeDataItems())if(s.CanBeStartNode()&&!s.GetIsStart())return void s.SetIsStart(!0)}else{if(1===e)return;if(1<e){let e=!0;for(const i of this.flowchartNodeDataItems())i.CanBeStartNode()&&(i.GetIsStart()&&e?e=!1:i.GetIsStart()&&!e&&i.SetIsStart(!1))}}for(const n of this.flowchartNodeDataItems())if(n.CanBeStartNode()&&n.GetIsStart())return void(this._flowchartNodeStartItem=n)}}}{const C33=self.C3,FLOWCHART_ID=0,NAME=1,VALUE=2,CONNECTED_FLOWCHART_NODE_FLOWCHART_ID=3;class FlowchartNodeDataOutputItem{constructor(e,t){this._flowchartNodeOutputData=t,this._flowchartId=e[FLOWCHART_ID],this._name=e[NAME],this._value=e[VALUE],this._connectedFlowchartNodeFlowchartId=e[CONNECTED_FLOWCHART_NODE_FLOWCHART_ID]}Release(){this._flowchartNodeOutputData=null}GetFlowchartNodeOutputData(){return this._flowchartNodeOutputData}GetFlowchartId(){return this._flowchartId}GetName(){return this._name}GetValue(){return this._value}GetConnectedFlowchartNodeFlowchartId(){return this._connectedFlowchartNodeFlowchartId}}C33.FlowchartNodeOutputData=class{constructor(e,t){this._flowchartDataNodeItem=t,this._flowchartNodeOutputItems=[],this._flowchartNodeOutputItemsNameMap=new Map,C33.FlowchartDataManager.CreateDataItems(this._flowchartNodeOutputItems,e,FlowchartNodeDataOutputItem,this);for(const s of this._flowchartNodeOutputItems)this._flowchartNodeOutputItemsNameMap.set(s.GetName(),s)}Release(){this._flowchartDataNodeItem=null;for(const e of this._flowchartNodeOutputItems)e.Release();C33.clearArray(this._flowchartNodeOutputItems),this._flowchartNodeOutputItems=null}GetFlowchartNodeDataItem(){return this._flowchartDataNodeItem}GetFlowchartNodeOutputDataItemCount(){return this._flowchartNodeOutputItems.length}GetFlowchartNodeOutputDataItems(){return this._flowchartNodeOutputItems}GetFlowchartNodeOutputDataItemByName(e){return this._flowchartNodeOutputItemsNameMap.get(e)}*flowchartNodeOutputDataItems(){for(const e of this._flowchartNodeOutputItems)yield e}}}{const C33=self.C3;C33.SolStack=class extends C33.DefendedBase{constructor(e){super(),this._objectClass=e,this._stack=[],this._stack.push(C33.New(C33.Sol,this)),this._index=0,this._current=this._stack[0]}Release(){for(const e of this._stack)e.Release();C33.clearArray(this._stack),this._current=null,this._objectClass=null}GetObjectClass(){return this._objectClass}GetCurrentSol(){return this._current}GetOneBelowCurrentSol(){return this._stack[this._index-1]}Clear(){this.GetCurrentSol().Clear()}PushClean(){const e=this._stack,t=++this._index;if(t===e.length){const s=C33.New(C33.Sol,this);e.push(s),this._current=s}else{const i=e[t];i.Reset(),this._current=i}}PushCopy(){const e=this._stack,t=++this._index,s=(t===e.length&&e.push(C33.New(C33.Sol,this)),e[t]);s.Copy(e[t-1]),this._current=s}Pop(){this._current=this._stack[--this._index]}RemoveInstances(s){const i=this._stack;for(let e=0,t=i.length;e<t;++e)i[e].RemoveInstances(s)}}}{const C33=self.C3;C33.Sol=class extends C33.DefendedBase{constructor(e){super(),this._stack=e,this._objectClass=this._stack.GetObjectClass(),this._eventStack=this._objectClass.GetRuntime().GetEventStack(),this._selectAll=!0,this._instances=[],this._elseInstances=[]}Release(){this.ClearArrays(),this._stack=null,this._objectClass=null,this._eventStack=null}ClearArrays(){C33.clearArray(this._instances),C33.clearArray(this._elseInstances)}GetObjectClass(){return this._objectClass}IsSelectAll(){return this._selectAll}HasAnyInstances(){return this._selectAll?!!this._objectClass.GetInstanceCount():!!this._instances.length}GetInstances(){return this._selectAll?this._objectClass.GetInstances():this._instances}HasAnyElseInstances(){return!!this._elseInstances.length}GetElseInstances(){return this._elseInstances}GetExpressionInstances(){const e=this.GetInstances();return e.length?e:this._elseInstances}Reset(){this._selectAll=!0,C33.clearArray(this._elseInstances)}Clear(){this._selectAll=!0}Copy(e){e.IsSelectAll()?this.Reset():(this._selectAll=!1,C33.shallowAssignArray(this._instances,e._instances),C33.clearArray(this._elseInstances))}_PushInstance(e){this._instances.push(e)}_PushElseInstance(e){this._elseInstances.push(e)}_SetSelectAll(e){this._selectAll=!!e}_GetOwnInstances(){return this._instances}_GetOwnElseInstances(){return this._elseInstances}SetSinglePicked(e){this._selectAll=!1,C33.clearArray(this._instances),this._instances.push(e)}SetArrayPicked(e){this._selectAll=!1,C33.shallowAssignArray(this._instances,e)}SetSetPicked(e){this._selectAll=!1,C33.clearArray(this._instances);for(const t of e)this._instances.push(t)}AddElseInstances(e,t){for(const s of t)e.has(s)||this._elseInstances.push(s)}TransferElseInstancesToOwn(e){for(const t of e)this._instances.push(t);C33.arrayRemoveAllInSet(this._elseInstances,e)}ClearElseInstances(){C33.clearArray(this._elseInstances)}PickOne(e){if(e)if(this._eventStack.GetCurrentStackFrame().GetCurrentEvent().IsOrBlock()){this.IsSelectAll()&&(C33.clearArray(this._instances),C33.shallowAssignArray(this._elseInstances,e.GetObjectClass().GetInstances()),this._selectAll=!1);const t=this._elseInstances.indexOf(e);-1!==t&&(this._instances.push(this._elseInstances[t]),this._elseInstances.splice(t,1))}else this.SetSinglePicked(e)}RemoveInstances(e){C33.arrayRemoveAllInSet(this._instances,e),C33.arrayRemoveAllInSet(this._elseInstances,e)}}}{const C33=self.C3;C33.EventStack=class extends C33.DefendedBase{constructor(e){super(),this._eventSheetManager=e,this._runtime=this._eventSheetManager.GetRuntime(),this._stack=[],this._stack.push(C33.New(C33.EventStackFrame,this,null)),this._index=0,this._expFuncStack=[]}Release(){for(const e of this._stack)e.Release();C33.clearArray(this._stack),C33.clearArray(this._expFuncStack),this._eventSheetManager=null,this._runtime=null}GetEventSheetManager(){return this._eventSheetManager}GetRuntime(){return this._runtime}GetCurrentStackFrame(){return this._stack[this._index]}GetAllStackFrames(){return this._stack}GetCurrentStackFrameIndex(){return this._index}Push(e){const t=this._stack,s=++this._index;if(s===t.length){const i=C33.New(C33.EventStackFrame,this,e);return t.push(i),i}{const n=t[s];return n.Reset(e),n}}Pop(){--this._index}PushExpFunc(e){this._expFuncStack.push(e)}PopExpFunc(){this._expFuncStack.pop()}GetCurrentExpFuncStackFrame(){const e=this._expFuncStack;return 0===e.length?null:e.at(-1)}}}{const C33=self.C3;C33.EventStackFrame=class extends C33.DefendedBase{constructor(e,t){super(),this._stack=e,this._runtime=this._stack.GetRuntime(),this._currentEvent=t,this._cndIndex=0,this._actIndex=0,this._lastEventTrue=!1,this._elseBranchRan=!1,this._expressionObjectClass=null,this._functionReturnType=0,this._functionReturnValue=0,this._dynamicSolModifiers=null}Release(){this.Reset(null),this._stack=null,this._runtime=null}Reset(e){this._currentEvent=e,this._cndIndex=0,this._actIndex=0,this._lastEventTrue=!1,this._elseBranchRan=!1,this._dynamicSolModifiers=null}_Restore(e,t){this._currentEvent=e,this._cndIndex=0,this._actIndex=t}ResetQuick(){this._cndIndex=0,this._actIndex=0}GetCurrentEvent(){return this._currentEvent}SetCurrentEvent(e){this._currentEvent=e}GetConditionIndex(){return this._cndIndex}SetConditionIndex(e){this._cndIndex=e}GetActionIndex(){return this._actIndex}SetActionIndex(e){this._actIndex=e}SetLastEventTrue(e){this._lastEventTrue=!!e}GetLastEventTrue(){return this._lastEventTrue}SetElseBranchRan(e){this._elseBranchRan=!!e}GetElseBranchRan(){return this._elseBranchRan}SetExpressionObjectClass(e){this._expressionObjectClass=e}GetExpressionObjectClass(){return this._expressionObjectClass}InitCallFunctionExpression(e,t){this._functionReturnType=e,this._functionReturnValue=t}GetFunctionReturnType(){return this._functionReturnType}SetFunctionReturnValue(e){this._functionReturnValue=e}GetFunctionReturnValue(){return this._functionReturnValue}IsSolModifierAfterCnds(){const e=this._currentEvent;return!!e.IsSolWriterAfterCnds()||this._cndIndex<e.GetConditionCount()-1&&!!e.GetSolModifiers().length}SetDynamicSolModifiers(e){this._dynamicSolModifiers=e}GetDynamicSolModifiers(){return this._dynamicSolModifiers}}}{const C33=self.C3;C33.LocalVarStack=class extends C33.DefendedBase{constructor(e){super(),this._eventSheetManager=e,this._runtime=this._eventSheetManager.GetRuntime(),this._stack=[],this._index=-1,this._current=null,this._initialValues=[]}Release(){C33.clearArray(this._stack),this._eventSheetManager=null,this._runtime=null}_SetInitialValues(e){this._initialValues=e;const t=this._initialValues.slice(0);this._stack.push(t),this._index=0,this._current=t}GetEventSheetManager(){return this._eventSheetManager}GetRuntime(){return this._runtime}GetCurrent(){return this._current}Push(){const e=++this._index,t=this._stack;e===t.length?t.push(this._initialValues.slice(0)):C33.shallowAssignArray(t[e],this._initialValues),this._current=t[e]}Pop(){this._current=this._stack[--this._index]}}}{const C33=self.C3;C33.LoopStack=class extends C33.DefendedBase{constructor(e){super(),this._eventSheetManager=e,this._runtime=this._eventSheetManager.GetRuntime(),this._stack=[],this._index=-1}Release(){C33.clearArray(this._stack),this._eventSheetManager=null,this._runtime=null}GetEventSheetManager(){return this._eventSheetManager}GetRuntime(){return this._runtime}IsInLoop(){return 0<=this._index}GetCurrent(){return this._stack[this._index]}Push(){if(++this._index,this._index===this._stack.length){const e=C33.New(C33.Loop,this);return this._stack.push(e),e}{const t=this._stack[this._index];return t.Reset(),t}}Pop(){--this._index}FindByName(t){const s=this._stack;for(let e=this._index;0<=e;--e){const i=s[e];if(i.GetName()===t)return i}return null}_GetStack(){return this._stack.slice(0,this._index+1)}}}{const C33=self.C3;C33.Loop=class extends C33.DefendedBase{constructor(e){super(),this._loopStack=e,this._name="",this._index=0,this._isStopped=!1,this._end=NaN}Reset(){this._name="",this._index=0,this._isStopped=!1,this._end=NaN}SetName(e){this._name=e}GetName(){return this._name}SetIndex(e){this._index=e}GetIndex(){return this._index}Stop(){this._isStopped=!0}IsStopped(){return this._isStopped}SetEnd(e){this._end=e}GetEnd(){return this._end}}}{const C33=self.C3;C33.ArrayStack=class extends C33.DefendedBase{constructor(){super(),this._stack=[],this._index=-1}Release(){C33.clearArray(this._stack)}GetCurrent(){return this._stack[this._index]}Push(){if(++this._index,this._index!==this._stack.length)return this._stack[this._index];{const e=[];return this._stack.push(e),e}}Pop(){--this._index}}}{let SortSolArray2=function(e,t){return e.GetIndex()-t.GetIndex()},IsSolArrayIdentical2=function(s,i){for(let e=0,t=s.length;e<t;++e)if(s[e]!==i[e])return!1;return!0};SortSolArray=SortSolArray2,IsSolArrayIdentical=IsSolArrayIdentical2;const C33=self.C3,assert=self.assert;C33.EventSheetManager=class extends C33.DefendedBase{constructor(e){super(),this._runtime=e,this._allSheets=[],this._sheetsByName=new Map,this._allGroups=[],this._groupsByName=new Map,this._blocksBySid=new Map,this._cndsBySid=new Map,this._actsBySid=new Map,this._allUniqueSolModifiers=new Map,this._eventVarsBySid=new Map,this._nextLocalVarIndex=0,this._allGlobalVars=[],this._allLocalVars=[],this._localVarInitialValues=[],this._functionBlocksByName=new Map,this._customActionBlocksMap=new Map,this._eventStack=C33.New(C33.EventStack,this),this._localVarStack=C33.New(C33.LocalVarStack,this),this._loopStack=C33.New(C33.LoopStack,this),this._triggersToPostInit=[],this._queuedTriggers=[],this._queuedDebugTriggers=[],this._runningEventsDepth=0,this._executingTriggerDepth=0,this._blockFlushingDepth=0,this._scheduledWaits=[],this._asyncActionPromises=[],this._signalTags=[],this._signalPromises=new Map,this._instSignals=new Map,self.c3_callFunction=(e,t)=>this._InvokeFunctionFromJS(e,t)}Release(){this.ClearAllScheduledWaits(),this._eventStack.Release(),this._eventStack=null,this._localVarStack.Release(),this._localVarStack=null,C33.clearArray(this._queuedTriggers),C33.clearArray(this._queuedDebugTriggers),this._runtime=null,C33.clearArray(this._allSheets),this._sheetsByName.clear()}Create(e){const t=C33.New(C33.EventSheet,this,e);this._allSheets.push(t),this._sheetsByName.set(t.GetName().toLowerCase(),t)}_AddTriggerToPostInit(e){this._triggersToPostInit.push(e)}_PostInit(){for(const e of this._customActionBlocksMap.values())e._CheckOverrideState();for(const t of this._functionBlocksByName.values())t._PostInit();for(const s of this._customActionBlocksMap.values())s._PostInit();for(const i of this._allSheets)i._PostInit();for(const n of this._allSheets)n._UpdateDeepIncludes();for(const r of this._triggersToPostInit)r._PostInit(!1);C33.clearArray(this._triggersToPostInit),this._localVarStack._SetInitialValues(this._localVarInitialValues)}GetRuntime(){return this._runtime}GetEventSheetByName(e){return this._sheetsByName.get(e.toLowerCase())||null}_RegisterGroup(e){this._allGroups.push(e),this._groupsByName.set(e.GetGroupName(),e)}_RegisterEventBlock(e){this._blocksBySid.set(e.GetSID(),e)}_RegisterCondition(e){this._cndsBySid.set(e.GetSID(),e)}_RegisterAction(e){this._actsBySid.set(e.GetSID(),e)}_RegisterFunctionBlock(e){switch(e.GetFunctionType()){case 0:this._functionBlocksByName.set(e.GetFunctionName().toLowerCase(),e);break;case 1:this._customActionBlocksMap.set(e.GetFunctionName().toLowerCase(),e)}}_RegisterEventVariable(e){this._eventVarsBySid.set(e.GetSID(),e),(e.IsGlobal()?this._allGlobalVars:this._allLocalVars).push(e)}_DeduplicateSolModifierList(s){2<=s.length&&s.sort(SortSolArray2);let i=this._allUniqueSolModifiers.get(s.length);i||(i=[],this._allUniqueSolModifiers.set(s.length,i));for(let e=0,t=i.length;e<t;++e){const n=i[e];if(IsSolArrayIdentical2(s,n))return n}return i.push(s),s}_GetNextLocalVarIndex(e){return this._localVarInitialValues.push(e.GetInitialValue()),this._nextLocalVarIndex++}GetEventStack(){return this._eventStack}GetCurrentEventStackFrame(){return this.GetEventStack().GetCurrentStackFrame()}GetCurrentEvent(){return this.GetCurrentEventStackFrame().GetCurrentEvent()}GetCurrentCondition(){const e=this.GetCurrentEventStackFrame(),t=e.GetCurrentEvent();return t.GetConditionAt(e.GetConditionIndex())}GetCurrentAction(){const e=this.GetCurrentEventStackFrame(),t=e.GetCurrentEvent();return t.GetActionAt(e.GetActionIndex())}GetLocalVarStack(){return this._localVarStack}GetLoopStack(){return this._loopStack}GetAllLocalVariablesInScope(e){const t=[];for(e=e.GetScopeParent();e;)C33.appendArray(t,e._GetAllLocalVariablesInScope()),e=e.GetScopeParent();return t}_GetLocalVariablesScriptInterface(e){const t={};for(const s of this.GetAllLocalVariablesInScope(e))t[s.GetJsPropName()]=s._GetScriptInterfaceDescriptor();return Object.create(Object.prototype,t)}GetEventVariableBySID(e){return this._eventVarsBySid.get(e)||null}GetEventBlockBySID(e){return this._blocksBySid.get(e)||null}GetConditionBySID(e){return this._cndsBySid.get(e)||null}GetActionBySID(e){return this._actsBySid.get(e)||null}GetFunctionBlockByName(e){return this._functionBlocksByName.get(e.toLowerCase())||null}GetCustomActionBlockByName(e,t){let s=this._customActionBlocksMap.get((e.GetName()+"."+t).toLowerCase());if(s)return s;if(!e.IsFamily())for(const i of e.GetFamilies())if(s=this._customActionBlocksMap.get((i.GetName()+"."+t).toLowerCase()))return s;return null}GetAllGlobalVariables(){return this._allGlobalVars}GetAllLocalVariables(){return this._allLocalVars}ResetAllGlobalsToInitialValue(e){for(const t of this._allGlobalVars)t.ResetToInitialValue();if(e)for(const s of this._allLocalVars)s.IsStatic()&&s.ResetToInitialValue()}GetEventGroupByName(e){return this._groupsByName.get(e.toLowerCase())||null}GetEventGroupBySID(e){const t=this._blocksBySid.get(e);return t&&t.IsGroup()?t:null}GetAllGroups(){return this._allGroups}ResetAllGroupsInitialActivation(){for(const e of this._allGroups)e.ResetInitialActivation()}_ResetAllHasRunFlags(){for(const e of this._allSheets)e._ResetHasRunFlag()}RunEvents(e){this._ResetAllHasRunFlags(),this._runningEventsDepth++;for(const t of e.runningLayouts()){const s=t.GetEventSheet();s&&(this._runtime.PushCurrentLayout(t),s.Run(),this._runtime.PopCurrentLayout())}this._runningEventsDepth--}async DebugRunEvents(e){this._ResetAllHasRunFlags(),this._runningEventsDepth++;for(const t of this._DebugRunEventsGen(e))await this._runtime.DebugBreak(t);this._runningEventsDepth--}*_DebugRunEventsGen(e){for(const t of e.runningLayouts()){const s=t.GetEventSheet();s&&(this._runtime.PushCurrentLayout(t),yield*s.DebugRun(),this._runtime.PopCurrentLayout())}}_Trigger(e,t,s,i){let n=!1;if(!e.GetMainRunningLayout())return this.QueueTrigger(t,s,i);this._executingTriggerDepth++;for(const r of e.runningLayouts()){const a=r.GetEventSheet();if(a){this._runtime.PushCurrentLayout(r);for(const l of a.deepIncludes()){const h=l._Trigger(t,s,i);n=n||h}const o=a._Trigger(t,s,i);n=n||o,this._runtime.PopCurrentLayout()}}return this._executingTriggerDepth--,n}*_DebugTrigger(e,t,s,i){let n=!1;if(!e.GetMainRunningLayout())return this.QueueTrigger(t,s,i);this._executingTriggerDepth++;for(const r of e.runningLayouts()){const a=r.GetEventSheet();if(a){this._runtime.PushCurrentLayout(r);for(const l of a.deepIncludes()){const h=yield*l._DebugTrigger(t,s,i);n=n||h}const o=yield*a._DebugTrigger(t,s,i);n=n||o,this._runtime.PopCurrentLayout()}}return this._executingTriggerDepth--,n}QueueTrigger(e,t,s){return this._queuedTriggers.push([e,t,s]),!1}QueueDebugTrigger(e,t,s){let i=null,n=new Promise(e=>i=e);return this._queuedDebugTriggers.push([e,t,s,i]),n}*_RunQueuedDebugTriggersGen(){if(this._runtime.HitBreakpoint())throw new Error("should not be in breakpoint");const e=this._runtime.GetLayoutManager();for(;this._queuedDebugTriggers.length;){const[t,s,i,n]=this._queuedDebugTriggers.shift(),r=yield*this._DebugTrigger(e,t,s,i);n(r)}}async RunQueuedDebugTriggersAsync(){for(const e of this._RunQueuedDebugTriggersGen())await this._runtime.DebugBreak(e)}_FastTrigger(e,s,i,n){let r=!1,t=e.GetMainRunningLayout(),a=t.GetEventSheet();if(a){this._executingTriggerDepth++,this._runtime.PushCurrentLayout(t);const o=a.deepIncludes();for(let e=0,t=o.length;e<t;++e){const h=o[e]._FastTrigger(s,i,n);r=r||h}const l=a._FastTrigger(s,i,n);return r=r||l,this._runtime.PopCurrentLayout(),this._executingTriggerDepth--,r}}*_DebugFastTrigger(e,s,i,n){let r=!1,t=e.GetMainRunningLayout(),a=t.GetEventSheet();if(a){this._executingTriggerDepth++,this._runtime.PushCurrentLayout(t);const o=a.deepIncludes();for(let e=0,t=o.length;e<t;++e){const h=yield*o[e]._DebugFastTrigger(s,i,n);r=r||h}const l=yield*a._DebugFastTrigger(s,i,n);return r=r||l,this._runtime.PopCurrentLayout(),this._executingTriggerDepth--,r}}GetTriggerDepth(){return this._executingTriggerDepth}IsInTrigger(){return 0<this.GetTriggerDepth()}_IncTriggerDepth(){return++this._executingTriggerDepth}_DecTriggerDepth(){--this._executingTriggerDepth}IsRunningEvents(){return 0<this._runningEventsDepth}IsInEventEngine(){return this.IsRunningEvents()||this.IsInTrigger()}_RunQueuedTriggers(e){for(const[t,s,i]of this._queuedTriggers)this._Trigger(e,t,s,i);C33.clearArray(this._queuedTriggers)}BlockFlushingInstances(e){e?this._blockFlushingDepth++:this._blockFlushingDepth--}IsFlushingBlocked(){return 0<this._blockFlushingDepth}ClearSol(s){for(let e=0,t=s.length;e<t;++e)s[e].GetSolStack().Clear()}PushCleanSol(s){for(let e=0,t=s.length;e<t;++e)s[e].GetSolStack().PushClean()}PushCopySol(s){for(let e=0,t=s.length;e<t;++e)s[e].GetSolStack().PushCopy()}PopSol(s){for(let e=0,t=s.length;e<t;++e)s[e].GetSolStack().Pop()}GetDynamicSolModifiersSet(t){const s=new Set,i=this._eventStack.GetAllStackFrames(),n=this._eventStack.GetCurrentStackFrameIndex();for(let e=0;e<=n;++e){const r=i[e].GetDynamicSolModifiers();if(r)for(const a of r)t&&t.has(a)||s.add(a)}return s}PushCleanSolDynamic(e){const t=new Set([...e]),s=this.GetDynamicSolModifiersSet(t);if(0<s.size){for(const i of s)i.GetSolStack().PushClean();return[...s]}return null}AddScheduledWait(){const e=C33.New(C33.ScheduledWait,this);return this._scheduledWaits.push(e),e}scheduledWaits(){return this._scheduledWaits}RunScheduledWaits(){if(this._scheduledWaits.length){let s=this.GetCurrentEventStackFrame(),i=!1;this._runningEventsDepth++;for(let e=0,t=this._scheduledWaits.length;e<t;++e){const n=this._scheduledWaits[e];n._ShouldRun()&&n._Run(s),n.ShouldRelease()&&(i=!0)}i&&(this._FilterScheduledWaitsToRelease(),s.Reset(null)),this._runningEventsDepth--}}async DebugRunScheduledWaits(){if(this._scheduledWaits.length){let s=this.GetCurrentEventStackFrame(),i=!1;this._runningEventsDepth++;for(let e=0,t=this._scheduledWaits.length;e<t;++e){const n=this._scheduledWaits[e];n._ShouldRun()&&await n._DebugRun(s),n.ShouldRelease()&&(i=!0)}i&&(this._FilterScheduledWaitsToRelease(),s.Reset(null)),this._runningEventsDepth--}}_FilterScheduledWaitsToRelease(){const e=C33.arrayFilterOut(this._scheduledWaits,e=>e.ShouldRelease());for(const t of e)t.Release()}ClearAllScheduledWaits(){for(const e of this._scheduledWaits)e.Release();C33.clearArray(this._scheduledWaits)}_OnInstancesReleased(e){for(const t of this._scheduledWaits)t.RemoveInstances(e);for(const s of e){const i=this._instSignals.get(s);if(this._instSignals.delete(s),i)for(const{resolve:n}of i.signalPromises.values())n(!0)}}AddAsyncActionPromise(e){this._asyncActionPromises.push({promise:e,triggerDepth:this.GetTriggerDepth()})}ClearAsyncActionPromises(){C33.clearArray(this._asyncActionPromises)}ClearNestedAsyncActionPromises(){const t=this.GetTriggerDepth();this._asyncActionPromises=this._asyncActionPromises.filter(e=>e.triggerDepth<=t)}GetPromiseForAllAsyncActions(){const e=Promise.all(this._asyncActionPromises.map(e=>e.promise));return this._asyncActionPromises=[],e}Signal(e){const t=e.toLowerCase();this._signalTags.push(t),this._runtime.Trigger(C33.Plugins.System.Cnds.OnSignal,null),this._signalTags.pop();for(const i of this._runtime.GetEventSheetManager().scheduledWaits())i.IsSignal()&&i.GetSignalTag()===t&&i.SetSignalled();const s=this._signalPromises.get(t);s&&(s.resolve(),this._signalPromises.delete(t))}WaitForSignal(e){const s=e.toLowerCase(),t=this._signalPromises.get(s);if(t)return t.promise;{let t=null,e=new Promise(e=>t=e);return this._signalPromises.set(s,{promise:e,resolve:t}),e}}GetCurrentSignalTag(){if(0===this._signalTags.length)throw new Error("not in a signal");return this._signalTags.at(-1)}_GetInstanceSignalState(e){let t=this._instSignals.get(e);return t||(t={signalTags:[],signalPromises:new Map},this._instSignals.set(e,t)),t}InstanceSignal(e,t){const s=this._GetInstanceSignalState(e),i=t.toLowerCase();s.signalTags.push(i),this._runtime.Trigger(e.GetPlugin().GetConstructor().Cnds.OnInstanceSignal,e),s.signalTags.pop();for(const r of this._runtime.GetEventSheetManager().scheduledWaits())r.IsInstanceSignals()&&r.GetSignalTag()===i&&r.SetInstanceSignalled(e);const n=s.signalPromises.get(i);n&&(n.resolve(!1),s.signalPromises.delete(i)),0===s.signalTags.length&&0===s.signalPromises.size&&this._instSignals.delete(e)}WaitForInstanceSignal(e,t){const s=this._GetInstanceSignalState(e),i=t.toLowerCase(),n=s.signalPromises.get(i);if(n)return n.promise;{let t=null,e=new Promise(e=>t=e);return s.signalPromises.set(i,{promise:e,resolve:t}),e}}GetCurrentInstanceSignalTag(e){const t=this._GetInstanceSignalState(e);if(t&&0!==t.signalTags.length)return t.signalTags.at(-1);throw new Error("not in a signal")}_SaveToJson(){return{groups:this._SaveGroupsToJson(),cnds:this._SaveCndsToJson(),acts:this._SaveActsToJson(),vars:this._SaveVarsToJson(),waits:this._SaveScheduledWaitsToJson()}}_LoadFromJson(e){this._LoadGroupsFromJson(e.groups),this._LoadCndsFromJson(e.cnds),this._LoadActsFromJson(e.acts),this._LoadVarsFromJson(e.vars),this._LoadScheduledWaitsFromJson(e.waits)}_SaveGroupsToJson(){const e={};for(const t of this.GetAllGroups())e[t.GetSID().toString()]=t.IsGroupActive();return e}_LoadGroupsFromJson(e){for(const[t,s]of Object.entries(e)){const i=parseInt(t,10),n=this.GetEventGroupBySID(i);n&&n.SetGroupActive(s)}}_SaveCndsToJson(){const e={};for(const[t,s]of this._cndsBySid){const i=s._SaveToJson();i&&(e[t.toString()]=i)}return e}_LoadCndsFromJson(e){const t=new Map;for(const[s,i]of Object.entries(e))t.set(parseInt(s,10),i);for(const[n,r]of this._cndsBySid)r._LoadFromJson(t.get(n)||null)}_SaveActsToJson(){const e={};for(const[t,s]of this._actsBySid){const i=s._SaveToJson();i&&(e[t.toString()]=i)}return e}_LoadActsFromJson(e){const t=new Map;for(const[s,i]of Object.entries(e))t.set(parseInt(s,10),i);for(const[n,r]of this._actsBySid)r._LoadFromJson(t.get(n)||null)}_SaveVarsToJson(){const e={};for(const[t,s]of this._eventVarsBySid)s.IsConstant()||!s.IsGlobal()&&!s.IsStatic()||(e[t.toString()]=s.GetValue());return e}_LoadVarsFromJson(e){for(const[t,s]of Object.entries(e)){const i=parseInt(t,10),n=this.GetEventVariableBySID(i);n&&n.SetValue(s)}}_SaveScheduledWaitsToJson(){return this._scheduledWaits.filter(e=>!e.IsPromise()).map(e=>e._SaveToJson())}_LoadScheduledWaitsFromJson(e){this.ClearAllScheduledWaits();for(const t of e){const s=C33.ScheduledWait._CreateFromJson(this,t);s&&this._scheduledWaits.push(s)}}_GetPerfRecords(){return[...this._runtime.GetLayoutManager().runningLayouts()].map(e=>e.GetEventSheet()).filter(e=>e).map(e=>e._GetPerfRecord())}FindFirstFunctionBlockParent(e){for(;e;){const t=e.GetScopeParent();if(t instanceof C33.FunctionBlock)return t;e=t}return null}_InvokeFunctionFromJS(e,t){Array.isArray(t)||(t=[]);const s=this.GetFunctionBlockByName(e.toLowerCase());if(!s)return null;if(!s.IsEnabled())return s.GetDefaultReturnValue();const i=s.GetFunctionParameters();if(t.length<i.length)for(t=t.slice(0);t.push(i[t.length].GetInitialValue()),t.length<i.length;);const n=s.GetEventBlock();return n.RunAsExpressionFunctionCall(n.GetSolModifiersIncludingParents(),!1,s.GetReturnType(),s.GetDefaultReturnValue(),...t)}}}{const C33=self.C3;C33.EventSheet=class extends C33.DefendedBase{constructor(e,t){super(),this._eventSheetManager=e,this._runtime=e.GetRuntime(),this._name=t[0],this._events=[],this._triggers=new Map,this._fastTriggers=new Map,this._eventsByDisplayNumber=new Map,this._hasRun=!1,this._shallowIncludes=[],this._deepIncludes=[],this._alreadyIncludedSheets=new Set;for(const s of t[1])this._CreateEvent(s,null,this._events);this._perfRecord=this._runtime.IsDebug()?{type:"sheet",name:this._name,totalTimeCounter:0,children:[]}:null}Release(){this._eventSheetManager=null,this._runtime=null}_CreateEvent(e,t,s){switch(e[0]){case 0:case 3:this._CreateEventBlock(e,t,s);break;case 1:this._CreateEventVariable(e,t,s);break;case 2:this._CreateInclude(e,t,s);break;case 4:this._CreateFunctionBlock(e,t);break;case 5:this._CreateScriptBlock(e,t,s);break;case 6:this._CreateCustomACEBlock(e,t);break;default:throw new Error("invalid event type")}}_CreateEventBlock(e,t,s){const i=C33.EventBlock.Create(this,t,e);if(i.IsOrBlock()){s.push(i);const n=i.GetConditions();for(let e=0,t=n.length;e<t;++e)n[e].IsTrigger()&&this._InitTrigger(i,e)}else i.IsTrigger()?this._InitTrigger(i,0):s.push(i)}_CreateFunctionBlock(e,t){const s=C33.FunctionBlock.CreateFunctionBlock(this,t,e);this._eventSheetManager._RegisterFunctionBlock(s)}_CreateCustomACEBlock(e,t){const s=C33.FunctionBlock.CreateCustomACEBlock(this,t,e);this._eventSheetManager._RegisterFunctionBlock(s)}_CreateEventVariable(e,t,s){const i=C33.EventVariable.Create(this,t,e);s.push(i)}_CreateInclude(e,t,s){const i=C33.EventInclude.Create(this,t,e);s.push(i)}_CreateScriptBlock(e,t,s){const i=C33.EventScript.Create(this,t,e);s.push(i)}_InitTrigger(n,r){n.IsOrBlock()||this._eventSheetManager._AddTriggerToPostInit(n);const a=n.GetConditionAt(r),o=a._GetFunc(),l=a.GetObjectClass();if(a.IsFastTrigger()){let e=this._fastTriggers.get(l),t=(e||(e=new Map,this._fastTriggers.set(l,e)),a.GetFastTriggerValue().toLowerCase()),s=e.get(o),i=(s||(s=new Map,e.set(o,s)),s.get(t));i||(i=[],s.set(t,i)),i.push([n,r])}else{let e=this._triggers.get(l),t=(e||(e={methodMap:new Map,behaviors:new Map},this._triggers.set(l,e)),a.GetBehaviorType()),s,i=(t?(s=e.behaviors.get(t))||(s=new Map,e.behaviors.set(t,s)):s=e.methodMap,s.get(o));i||(i=[],s.set(o,i)),i.push([n,r])}}_PostInit(){const s=this._events;for(let e=0,t=s.length;e<t;++e){const i=e<t-1&&s[e+1]instanceof C33.EventBlock&&s[e+1].IsElseBlock();s[e]._PostInit(i)}}_AddShallowInclude(e){this._shallowIncludes.push(e)}_UpdateDeepIncludes(){C33.clearArray(this._deepIncludes),this._AddDeepIncludes(this),this._alreadyIncludedSheets.clear()}_AddDeepIncludes(e){const t=e._deepIncludes,s=e._alreadyIncludedSheets;for(const i of this._shallowIncludes){const n=i.GetIncludeSheet();i.IsActive()&&e!==n&&!s.has(n)&&(s.add(n),n._AddDeepIncludes(e),t.push(n))}}deepIncludes(){return this._deepIncludes}GetEventSheetManager(){return this._eventSheetManager}GetRuntime(){return this._runtime}GetName(){return this._name}_RegisterEventByDisplayNumber(e,t){this._eventsByDisplayNumber.set(t,e)}_GetEventByDisplayNumber(e){return this._eventsByDisplayNumber.get(e)||null}_ResetHasRunFlag(){this._hasRun=!1}Run(){if(!this._hasRun){const e=this._runtime,t=e.IsCPUProfiling(),s=t?performance.now():0,i=(this._hasRun=!0,this.GetEventSheetManager()),n=i.GetCurrentEventStackFrame();for(const r of this._events)r.Run(n),i.ClearSol(r.GetSolModifiers()),i.ClearAsyncActionPromises(),e.FlushPendingInstances();n.Reset(null),t&&(this._perfRecord.totalTimeCounter+=performance.now()-s)}}*DebugRun(){if(!this._hasRun){this._hasRun=!0;const e=this._runtime,t=this.GetEventSheetManager(),s=t.GetCurrentEventStackFrame();for(const i of this._events)yield*i.DebugRun(s),t.ClearSol(i.GetSolModifiers()),t.ClearAsyncActionPromises(),e.FlushPendingInstances();s.Reset(null)}}_Trigger(i,n,r){if(!n)return this._TriggerForClass(i,n,null,null);{let e=n.GetObjectClass(),t=!1,s=this._TriggerForClass(i,n,e,r);t=t||s;for(const a of e.GetFamilies())s=this._TriggerForClass(i,n,a,r),t=t||s}}_TriggerForClass(e,t,s,i){const n=this._triggers.get(s);if(!n)return!1;const r=i?n.behaviors.get(i):n.methodMap;if(!r)return!1;const a=r.get(e);if(!a)return!1;let o=!1;for(const[l,h]of a){const c=this._ExecuteTrigger(t,l,h);o=o||c}return o}*_DebugTrigger(i,n,r){if(!n)return yield*this._DebugTriggerForClass(i,n,null,null);{let e=n.GetObjectClass(),t=!1,s=yield*this._DebugTriggerForClass(i,n,e,r);t=t||s;for(const a of e.GetFamilies())s=yield*this._DebugTriggerForClass(i,n,a,r),t=t||s}}*_DebugTriggerForClass(e,t,s,i){const n=this._triggers.get(s);if(!n)return!1;const r=i?n.behaviors.get(i):n.methodMap;if(!r)return!1;const a=r.get(e);if(!a)return!1;let o=!1;for(const[l,h]of a){let e;e=l.DebugCanRunFast()?this._ExecuteTrigger(t,l,h):yield*this._DebugExecuteTrigger(t,l,h),o=o||e}return o}_FastTrigger(e,t,s){const i=t.GetObjectClass(),n=this._fastTriggers.get(i);if(!n)return!1;const r=n.get(e);if(!r)return!1;const a=r.get(s);if(!a)return!1;let o=!1;for(let e=0,t=a.length;e<t;++e){const l=a[e],h=this._ExecuteTrigger(null,l[0],l[1]);o=o||h}return o}*_DebugFastTrigger(e,t,s){const i=t.GetObjectClass(),n=this._fastTriggers.get(i);if(!n)return!1;const r=n.get(e);if(!r)return!1;const a=r.get(s);if(!a)return!1;let o=!1;for(let n=0,e=a.length;n<e;++n){let e=a[n],t=e[0],s=e[1],i;i=t.DebugCanRunFast()?this._ExecuteTrigger(null,t,s):yield*this._DebugExecuteTrigger(null,t,s),o=o||i}return o}_ExecuteTrigger(e,t,s){let i=this._runtime,n=this._eventSheetManager,r=n.GetCurrentEvent(),a=n.GetEventStack(),o=n.GetTriggerDepth(),l=!1;r&&n.PushCleanSol(r.GetSolModifiersIncludingParents()),n.PushCleanSol(t.GetSolModifiersIncludingParents());const h=1<o,c=(h&&n.GetLocalVarStack().Push(),a.Push(t));if(e){const _=t.GetConditions()[s].GetObjectClass(),d=_.GetCurrentSol();d.SetSinglePicked(e),e.IsInContainer()&&e.SetSiblingsSinglePicked()}let u=!0;if(t.GetParent()){const p=t.GetTriggerParents();for(let e=0,t=p.length;e<t;++e)if(!p[e].RunPreTrigger(c)){u=!1;break}}return u&&(t.IsOrBlock()?t.RunOrBlockTrigger(c,s):t.Run(c),l=c.GetLastEventTrue()),a.Pop(),h&&n.GetLocalVarStack().Pop(),n.PopSol(t.GetSolModifiersIncludingParents()),r&&n.PopSol(r.GetSolModifiersIncludingParents()),r||1!==o||(n.ClearAsyncActionPromises(),n.IsFlushingBlocked())||i.FlushPendingInstances(),l}*_DebugExecuteTrigger(e,t,s){let i=this._runtime,n=this._eventSheetManager,r=n.GetCurrentEvent(),a=n.GetEventStack(),o=n.GetTriggerDepth(),l=!1;r&&n.PushCleanSol(r.GetSolModifiersIncludingParents()),n.PushCleanSol(t.GetSolModifiersIncludingParents());const h=1<o,c=(h&&n.GetLocalVarStack().Push(),a.Push(t));if(e){const _=t.GetConditions()[s].GetObjectClass(),d=_.GetCurrentSol();d.SetSinglePicked(e),e.IsInContainer()&&e.SetSiblingsSinglePicked()}let u=!0;if(t.GetParent()){const p=t.GetTriggerParents();for(let e=0,t=p.length;e<t;++e)if(!(yield*p[e].DebugRunPreTrigger(c))){u=!1;break}}return u&&(t.IsOrBlock()?yield*t.DebugRunOrBlockTrigger(c,s):yield*t.DebugRun(c),l=c.GetLastEventTrue()),a.Pop(),h&&n.GetLocalVarStack().Pop(),n.PopSol(t.GetSolModifiersIncludingParents()),r&&n.PopSol(r.GetSolModifiersIncludingParents()),r||1!==o||(n.ClearAsyncActionPromises(),n.IsFlushingBlocked())||i.FlushPendingInstances(),l}_GetPerfRecord(){return this._perfRecord}}}{let NoActions2=function(e,t){return!0};NoActions=NoActions2;const C33=self.C3,EMPTY_ARRAY=[];function*DebugNoActions(e,t){return!0}C33.EventBlock=class extends C33.DefendedBase{constructor(e,t,s){super(),this._eventSheet=e,this._runtime=e.GetRuntime(),this._parent=t,this._scopeParent=null,this._eventStack=this._runtime.GetEventSheetManager().GetEventStack(),this._solModifiers=[],this._solModifiersIncludingParents=[],this._hasGotSolModifiersIncludingParents=!1,this._isSolWriterAfterCnds=!1,this._isTopLevelGroup=!1,this._hasElseBlock=!1,this._isOrBlock=!!s[2],this._isElseBlock=!1,this._triggerParents=null,this._conditions=[],this._actions=[],this._subEvents=[],this._RunActions=NoActions2,this._DebugRunActions=DebugNoActions,this._isGroup=!1,this._isInitiallyActive=!1,this._groupName="",this._isGroupActive=!1,this._containedIncludes=null,this._perfRecord=null,this._sid=s[4],this._displayNumber=s[5],this._eventSheet._RegisterEventByDisplayNumber(this,this._displayNumber),this._debugData=this._runtime.IsDebug()?{isBreakpoint:s[3][0],isBreakable:s[3][1],canRunAllConditionsFast:!1,canRunAllActionsFast:!1,canRunAllSubEventsFast:!1,canRunSelfFast:!1}:null,this.GetEventSheetManager()._RegisterEventBlock(this),3===s[0]&&this._InitGroup(s[1]);let i=0;for(const n of s[6]){const r=C33.Condition.Create(this,n,i++);this._conditions.push(r),this._AddSolModifier(r.GetObjectClass())}i=0;for(const a of s[7]){const o=C33.Action.Create(this,a,i++);this._actions.push(o)}if(9===s.length){const l=s[8];for(const h of l)this._eventSheet._CreateEvent(h,this,this._subEvents)}this._conditions.length&&(this._isElseBlock=null===this._conditions[0].GetObjectClass()&&this._conditions[0]._GetFunc()===C33.Plugins.System.Cnds.Else),0===this._conditions.length&&(this._conditions=EMPTY_ARRAY),0===this._actions.length&&(this._actions=EMPTY_ARRAY),0===this._subEvents.length&&(this._subEvents=EMPTY_ARRAY)}static Create(e,t,s){return C33.New(C33.EventBlock,e,t,s)}_InitGroup(e){this._isGroup=!0,this._isInitiallyActive=!!e[0],this._isGroupActive=this._isInitiallyActive,this._groupName=e[1].toLowerCase(),this._containedIncludes=[],this.GetEventSheetManager()._RegisterGroup(this),this._runtime.IsDebug()&&(this._perfRecord={type:"group",name:e[1],totalTimeCounter:0,children:[]})}_AddContainedInclude(e){this._containedIncludes.push(e)}_AddContainerSolModifierToList(e,t){for(const s of e.GetContainer().objectTypes())t.includes(s)||t.push(s)}_AddSolModifierToList(e,t){if(e)if(t.includes(e)||t.push(e),e.IsFamily())for(const s of e.GetFamilyMembers())s.IsInContainer()&&this._AddContainerSolModifierToList(s,t);else e.IsInContainer()&&this._AddContainerSolModifierToList(e,t)}_AddSolModifier(e){this._AddSolModifierToList(e,this._solModifiers)}_AddParentSolModifier(e){this._AddSolModifierToList(e,this._solModifiersIncludingParents)}SetAllSolModifiers(){this._solModifiers=this._runtime.GetAllObjectClasses()}_PostInit(e){this._hasElseBlock=!!e,this._IdentifyTopLevelGroup(),this._IdentifyTriggerParents();for(const t of this._conditions)t._PostInit();if(0<this._actions.length){let e=!1;for(const i of this._actions)i._PostInit(),i.HasReturnType()&&(e=!0);e?(this._RunActions=this._RunActions_ReturnValue,this._DebugRunActions=this._DebugRunActions_ReturnValue):(this._RunActions=this._RunActions_Fast,this._DebugRunActions=this._DebugRunActions_Fast)}const s=this._subEvents;for(let e=0,t=s.length;e<t;++e){const n=e<t-1&&s[e+1]instanceof C33.EventBlock&&s[e+1].IsElseBlock();s[e]._PostInit(n)}this._debugData&&this._UpdateCanRunFast(),this._perfRecord&&this._GetPerfRecordParent()._GetPerfRecord().children.push(this._perfRecord)}_GetPerfRecord(){return this._perfRecord}_GetPerfRecordParent(){let e=this.GetParent();for(;e;){if(e.IsGroup())return e;e=e.GetParent()}return this._eventSheet}_UpdateCanRunFast(){const e=this._debugData;e.canRunAllConditionsFast=this._conditions.every(e=>e.DebugCanRunFast()),e.canRunAllActionsFast=this._actions.every(e=>e.DebugCanRunFast()),e.canRunAllSubEventsFast=this._subEvents.every(e=>e.DebugCanRunFast()),e.canRunSelfFast=e.canRunAllConditionsFast&&e.canRunAllActionsFast&&e.canRunAllSubEventsFast}_UpdateCanRunFastRecursive(){let e=this;for(;e._UpdateCanRunFast(),e=e.GetParent(););}_IdentifyTopLevelGroup(){if(this.IsGroup()){let e=this.GetParent();for(this._isTopLevelGroup=!0;e;){if(!e.IsGroup()){this._isTopLevelGroup=!1;break}e=e.GetParent()}}}_IdentifySolModifiersIncludingParents(){const e=this._runtime.GetAllObjectClasses();if(this._solModifiers===e)this._solModifiersIncludingParents=e;else{this._solModifiersIncludingParents=C33.cloneArray(this._solModifiers);let e=this.GetParent();for(;e;){for(const s of e._solModifiers)this._AddParentSolModifier(s);e=e.GetParent()}const t=this.GetEventSheetManager();this._solModifiers=t._DeduplicateSolModifierList(this._solModifiers),this._solModifiersIncludingParents=t._DeduplicateSolModifierList(this._solModifiersIncludingParents)}}_IdentifyTriggerParents(){if(this.HasAnyTriggeredCondition()){this._triggerParents=[];let e=this.GetParent();for(;e;)this._triggerParents.push(e),e=e.GetParent();this._triggerParents.reverse()}}SetSolWriterAfterCnds(){this._isSolWriterAfterCnds=!0,this._parent&&this._parent.SetSolWriterAfterCnds()}IsSolWriterAfterCnds(){return this._isSolWriterAfterCnds}GetSolModifiers(){return this._solModifiers}GetSolModifiersIncludingParents(){return this._hasGotSolModifiersIncludingParents||(this._hasGotSolModifiersIncludingParents=!0,this._IdentifySolModifiersIncludingParents()),this._solModifiersIncludingParents}HasSolModifier(e){return this._solModifiers.includes(e)}GetTriggerParents(){return this._triggerParents}GetEventSheet(){return this._eventSheet}GetEventSheetManager(){return this._eventSheet.GetEventSheetManager()}GetRuntime(){return this._runtime}GetParent(){return this._parent}_SetScopeParent(e){this._scopeParent=e}GetScopeParent(){return this._scopeParent||this._parent}GetDisplayNumber(){return this._displayNumber}IsDebugBreakable(){return this._debugData&&this._debugData.isBreakable}IsDebugBreakpoint(){return this.IsDebugBreakable()&&this._debugData.isBreakpoint}_SetDebugBreakpoint(e){this._debugData.isBreakpoint=!!e,this._UpdateCanRunFastRecursive()}IsGroup(){return this._isGroup}IsTopLevelGroup(){return this._isTopLevelGroup}IsElseBlock(){return this._isElseBlock}HasElseBlock(){return this._hasElseBlock}GetGroupName(){return this._groupName}IsGroupActive(){return this._isGroupActive}ResetInitialActivation(){this.SetGroupActive(this._isInitiallyActive)}SetGroupActive(e){if(e=!!e,!this._isGroup)throw new Error("not a group");if(this._isGroupActive!==e){this._isGroupActive=e;for(const t of this._containedIncludes)t.UpdateActive();if(this._containedIncludes.length){const s=this._runtime.GetCurrentLayout(),i=s.GetEventSheet();i&&i._UpdateDeepIncludes()}}}GetSID(){return this._sid}IsOrBlock(){return this._isOrBlock}IsTrigger(){return this._conditions.length&&this._conditions[0].IsTrigger()}IsForFunctionBlock(){return this._scopeParent&&this._scopeParent instanceof C33.FunctionBlock}HasAnyTriggeredCondition(){return this.IsForFunctionBlock()||this._conditions.some(e=>e.IsTrigger())}GetConditions(){return this._conditions}GetConditionCount(){return this._conditions.length}GetConditionAt(e){if((e=Math.floor(e))<0||e>=this._conditions.length)throw new RangeError("invalid condition index");return this._conditions[e]}GetConditionByDebugIndex(e){return this.GetConditionAt(e)}IsFirstConditionOfType(e){let t=e.GetIndex();if(0!==t){--t;const s=e.IsSystemOrSingleGlobalCondition()?e.GetFirstObjectParameterObjectClass():e.GetObjectClass();for(;0<=t;--t){const i=this._conditions[t];if(s===i.GetObjectClass()||i.IsSystemOrSingleGlobalCondition()&&i.GetFirstObjectParameterObjectClass()===s)return!1}}return!0}GetActions(){return this._actions}GetActionCount(){return this._actions.length}GetActionAt(e){if((e=Math.floor(e))<0||e>=this._actions.length)throw new RangeError("invalid action index");return this._actions[e]}GetActionByDebugIndex(t){t=Math.floor(t);const e=this._actions.find(e=>e.GetDebugIndex()===t);if(e)return e;throw new RangeError("invalid action debug index")}_HasActionIndex(e){return 0<=(e=Math.floor(e))&&e<this._actions.length}GetSubEvents(){return this._subEvents}_GetAllLocalVariablesInScope(){return this._subEvents.filter(e=>e instanceof C33.EventVariable)}RunPreTrigger(s){s.SetCurrentEvent(this);let i=this._conditions,n=0===i.length;for(let e=0,t=i.length;e<t;++e){const r=i[e];if(s.SetConditionIndex(e),r.IsLooping())throw new Error("trigger cannot be used as sub-event to a loop");if(r.Run())n=!0;else if(!this._isOrBlock)return!1}return!this._isOrBlock||n}RunOrBlockTrigger(e,t){e.SetCurrentEvent(this),e.SetConditionIndex(t),this._conditions[t].Run()&&(this._RunActions(e,0)&&this._RunSubEvents(e),e.SetLastEventTrue(!0))}*DebugRunPreTrigger(s){s.SetCurrentEvent(this);let i=this._conditions,n=0===i.length;for(let e=0,t=i.length;e<t;++e){const r=i[e];if(s.SetConditionIndex(e),r.IsLooping())throw new Error("trigger cannot be used as sub-event to a loop");if(r.DebugCanRunFast()?r.Run():yield*r.DebugRun())n=!0;else if(!this._isOrBlock)return!1}return!this._isOrBlock||n}*DebugRunOrBlockTrigger(e,t){e.SetCurrentEvent(this),e.SetConditionIndex(t);let s=this._conditions[t];if(s.DebugCanRunFast()?s.Run():yield*s.DebugRun())(this.DebugCanRunActionsFast()?this._RunActions(e,0):yield*this._DebugRunActions(e,0))&&(this.DebugCanRunSubEventsFast()?this._RunSubEvents():yield*this._DebugRunSubEvents()),e.SetLastEventTrue(!0)}Run(e){e.SetCurrentEvent(this),this._isElseBlock||e.SetElseBranchRan(!1),this._isOrBlock?this._RunOrBlock(e):this._RunAndBlock(e)}*DebugRun(e){(this.IsDebugBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),e.SetCurrentEvent(this),this._isElseBlock||e.SetElseBranchRan(!1),this._isOrBlock?yield*this._DebugRunOrBlock(e):yield*this._DebugRunAndBlock(e)}_RunOrBlock(s){let i=this._conditions,n=0===i.length;for(let e=0,t=i.length;e<t;++e){const r=i[e];if(!r.IsTrigger()){s.SetConditionIndex(e);const a=r.Run();n=n||a}}s.SetLastEventTrue(n),n&&(this._RunActions(s,0)&&this._RunSubEvents(s),this._hasElseBlock)&&s.SetElseBranchRan(!0)}*_DebugRunOrBlock(s){let i=this._conditions,n=0===i.length;for(let t=0,e=i.length;t<e;++t){const r=i[t];if(!r.IsTrigger()){s.SetConditionIndex(t);let e;e=r.DebugCanRunFast()?r.Run():yield*r.DebugRun(),n=n||e}}if(s.SetLastEventTrue(n),n)(this.DebugCanRunActionsFast()?this._RunActions(s,0):yield*this._DebugRunActions(s,0))&&(this.DebugCanRunSubEventsFast()?this._RunSubEvents():yield*this._DebugRunSubEvents()),this._hasElseBlock&&s.SetElseBranchRan(!0)}_RunAndBlock(s){const i=this._conditions;for(let e=0,t=i.length;e<t;++e){const n=i[e],r=(s.SetConditionIndex(e),n.Run());if(!r)return void s.SetLastEventTrue(!1)}s.SetLastEventTrue(!0),this._RunActions(s,0)&&this._RunSubEvents(s),s.GetLastEventTrue()&&this._hasElseBlock&&s.SetElseBranchRan(!0)}*_DebugRunAndBlock(s){const i=this._conditions;for(let e=0,t=i.length;e<t;++e){const n=i[e];s.SetConditionIndex(e);if(!(n.DebugCanRunFast()?n.Run():yield*n.DebugRun()))return void s.SetLastEventTrue(!1)}s.SetLastEventTrue(!0);(this.DebugCanRunActionsFast()?this._RunActions(s,0):yield*this._DebugRunActions(s,0))&&(this.DebugCanRunSubEventsFast()?this._RunSubEvents():yield*this._DebugRunSubEvents()),s.GetLastEventTrue()&&this._hasElseBlock&&s.SetElseBranchRan(!0)}_RunActions_Fast(s,i){const n=this._actions;for(let e=i,t=n.length;e<t;++e){const r=n[e];s.SetActionIndex(e),r.Run()}return!0}*_DebugRunActions_Fast(s,i){const n=this._actions;for(let e=i,t=n.length;e<t;++e){const r=n[e];s.SetActionIndex(e),r.DebugCanRunFast()?r.Run():yield*r.DebugRun()}return!0}_RunActions_ReturnValue(s,i){const n=this.GetEventSheetManager(),r=this._actions;for(let e=i,t=r.length;e<t;++e){const a=r[e],o=(s.SetActionIndex(e),a.Run());if(a.CanBailOut()&&!0===o)return!1;a.IsAsync()&&o instanceof Promise&&n.AddAsyncActionPromise(o)}return!0}*_DebugRunActions_ReturnValue(s,i){const n=this.GetEventSheetManager(),r=this._actions;for(let t=i,e=r.length;t<e;++t){const a=r[t];s.SetActionIndex(t);let e;if(e=a.DebugCanRunFast()?a.Run():yield*a.DebugRun(),a.CanBailOut()&&!0===e)return!1;a.IsAsync()&&e instanceof Promise&&n.AddAsyncActionPromise(e)}return!0}_ResumeActionsAndSubEvents(e){this._RunActions(e,e.GetActionIndex())&&this._RunSubEvents()}*_DebugResumeActionsAndSubEvents(e){(yield*this._DebugRunActions(e,e.GetActionIndex()))&&(yield*this._DebugRunSubEvents())}_RunSubEvents(){if(this._subEvents.length){const e=this.IsGroup()&&this._runtime.IsCPUProfiling(),t=e?performance.now():0,s=this._eventStack,i=s.Push(this);this._isSolWriterAfterCnds?this._RunSubEvents_SolWriterAfterCnds(i):this._RunSubEvents_Fast(i),s.Pop(),e&&(this._perfRecord.totalTimeCounter+=performance.now()-t)}}_RunSubEvents_SolWriterAfterCnds(i){const n=this._isGroup,r=this._isTopLevelGroup,a=this.GetEventSheetManager(),o=this._subEvents;for(let e=0,t=o.length,s=t-1;e<t;++e){const l=o[e],h=l.GetSolModifiers(),c=!r||!n&&e<s;c&&a.PushCopySol(h),l.Run(i),c?a.PopSol(h):a.ClearSol(h)}}_RunSubEvents_Fast(s){const i=this._subEvents;for(let e=0,t=i.length;e<t;++e)i[e].Run(s)}*_DebugRunSubEvents(){if(this._subEvents.length){const e=this._eventStack,t=e.Push(this);this._isSolWriterAfterCnds?yield*this._DebugRunSubEvents_SolWriterAfterCnds(t):yield*this._DebugRunSubEvents_Fast(t),e.Pop()}}*_DebugRunSubEvents_SolWriterAfterCnds(i){const n=this._isGroup,r=this._isTopLevelGroup,a=this.GetEventSheetManager(),o=this._subEvents;for(let e=0,t=o.length,s=t-1;e<t;++e){const l=o[e],h=l.GetSolModifiers(),c=!r||!n&&e<s;c&&a.PushCopySol(h),yield*l.DebugRun(i),c?a.PopSol(h):a.ClearSol(h)}}*_DebugRunSubEvents_Fast(s){const i=this._subEvents;for(let e=0,t=i.length;e<t;++e)yield*i[e].DebugRun(s)}Retrigger(s,i){i.ResetQuick();const n=this._conditions;if(!this.IsOrBlock())for(let e=s.GetConditionIndex()+1,t=n.length;e<t;++e){const r=n[e],a=(i.SetConditionIndex(e),r.Run());if(!a)return!1}return this._RunActions(i,0)&&this._RunSubEvents(i),!0}*DebugRetrigger(s,i){i.ResetQuick();const n=this._conditions;if(!this.IsOrBlock())for(let e=s.GetConditionIndex()+1,t=n.length;e<t;++e){const r=n[e];i.SetConditionIndex(e);if(!(r.DebugCanRunFast()?r.Run():yield*r.DebugRun()))return!1}return(this.DebugCanRunActionsFast()?this._RunActions(i,0):yield*this._DebugRunActions(i,0))&&(this.DebugCanRunSubEventsFast()?this._RunSubEvents():yield*this._DebugRunSubEvents()),!0}DebugCanRunFast(){return!this.IsDebugBreakpoint()&&!this._runtime.DebugBreakNext()&&this._debugData.canRunSelfFast}DebugCanRunActionsFast(){return!this._runtime.DebugBreakNext()&&this._debugData.canRunAllActionsFast}DebugCanRunSubEventsFast(){return!this._runtime.DebugBreakNext()&&this._debugData.canRunAllSubEventsFast}_CheckParentsOKToRun(s){if(this.GetParent()){const i=this.GetTriggerParents();for(let e=0,t=i.length;e<t;++e)if(!i[e].RunPreTrigger(s))return!1}return!0}*_DebugCheckParentsOKToRun(s){if(this.GetParent()){const i=this.GetTriggerParents();for(let e=0,t=i.length;e<t;++e)if(!(yield*i[e].DebugRunPreTrigger(s)))return!1}return!0}_EvaluateFunctionCallParameters(e,t,s){if(0<t.length)if(s){const i=t.map(e=>e.Get(0));e.GetLocalVarStack().Push(),this._scopeParent.SetFunctionParameters(i)}else this._scopeParent.EvaluateFunctionParameters(t);else s&&e.GetLocalVarStack().Push()}RunAsFunctionCall(e,t,s,i){let n,r,a=0<e.length,o=null,l=this._runtime,h=this._eventStack,c=l.GetEventSheetManager(),u=this._scopeParent,_=u.IsAsync(),d=c._IncTriggerDepth(),p=1<d;if(this._EvaluateFunctionCallParameters(c,t,p),a&&(s?c.PushCopySol(e):c.PushCleanSol(e)),null!==i){if(i.copyFromObjectClass){const g=s?i.copyFromObjectClass.GetCurrentSol():i.copyFromObjectClass.GetSolStack().GetOneBelowCurrentSol(),f=i.copyToObjectClass.GetCurrentSol();f.SetArrayPicked(g.GetInstances()),f.ClearElseInstances(),s||i.copyToObjectClass.ApplySolToContainer()}else if(i.pickObjectClass){const S=i.pickObjectClass.GetCurrentSol();S.SetArrayPicked(i.pickInstances),S.ClearElseInstances()}i.pushCleanSolDynamic&&(o=c.PushCleanSolDynamic(e))}const m=h.Push(this);return s&&m.SetDynamicSolModifiers(e),this._CheckParentsOKToRun(m)&&(m.SetCurrentEvent(this),_&&([r,n]=u.StartAsyncFunctionCall()),this._RunAndBlock(m),_)&&u.MaybeFinishAsyncFunctionCall(r),h.Pop(),p&&c.GetLocalVarStack().Pop(),null!==o&&c.PopSol(o),a&&c.PopSol(e),c._DecTriggerDepth(),_||c.ClearNestedAsyncActionPromises(),n}*DebugRunAsFunctionCall(e,t,s,i){let n,r,a=((this.IsDebugBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),0<e.length),o=null,l=this._runtime,h=this._eventStack,c=l.GetEventSheetManager(),u=this._scopeParent,_=u.IsAsync(),d=c._IncTriggerDepth(),p=1<d;if(this._EvaluateFunctionCallParameters(c,t,p),a&&(s?c.PushCopySol(e):c.PushCleanSol(e)),null!==i){if(i.copyFromObjectClass){const g=s?i.copyFromObjectClass.GetCurrentSol():i.copyFromObjectClass.GetSolStack().GetOneBelowCurrentSol(),f=i.copyToObjectClass.GetCurrentSol();f.SetArrayPicked(g.GetInstances()),f.ClearElseInstances(),s||i.copyToObjectClass.ApplySolToContainer()}else if(i.pickObjectClass){const S=i.pickObjectClass.GetCurrentSol();S.SetArrayPicked(i.pickInstances),S.ClearElseInstances()}i.pushCleanSolDynamic&&(o=c.PushCleanSolDynamic(e))}const m=h.Push(this);return s&&m.SetDynamicSolModifiers(e),(yield*this._DebugCheckParentsOKToRun(m))&&(m.SetCurrentEvent(this),_&&([r,n]=u.StartAsyncFunctionCall()),yield*this._DebugRunAndBlock(m),_)&&u.MaybeFinishAsyncFunctionCall(r),h.Pop(),p&&c.GetLocalVarStack().Pop(),null!==o&&c.PopSol(o),a&&c.PopSol(e),c._DecTriggerDepth(),_||c.ClearNestedAsyncActionPromises(),n}RunAsMappedFunctionCall(e,t){const s=this.GetSolModifiersIncludingParents(),i=0<s.length,n=this._runtime,r=this._eventStack,a=n.GetEventSheetManager(),o=a._IncTriggerDepth(),l=1<o,h=(l&&a.GetLocalVarStack().Push(),this._scopeParent.SetFunctionParameters(e),i&&(t?a.PushCopySol(s):a.PushCleanSol(s)),r.Push(this));this._CheckParentsOKToRun(h)&&(h.SetCurrentEvent(this),this._RunAndBlock(h)),r.Pop(),l&&a.GetLocalVarStack().Pop(),i&&a.PopSol(s),a._DecTriggerDepth(),a.ClearNestedAsyncActionPromises()}*DebugRunAsMappedFunctionCall(e,t){(this.IsDebugBreakpoint()||this._runtime.DebugBreakNext())&&(yield this);const s=this.GetSolModifiersIncludingParents(),i=0<s.length,n=this._runtime,r=this._eventStack,a=n.GetEventSheetManager(),o=a._IncTriggerDepth(),l=1<o,h=(l&&a.GetLocalVarStack().Push(),this._scopeParent.SetFunctionParameters(e),i&&(t?a.PushCopySol(s):a.PushCleanSol(s)),r.Push(this));(yield*this._DebugCheckParentsOKToRun(h))&&(h.SetCurrentEvent(this),yield*this._DebugRunAndBlock(h)),r.Pop(),l&&a.GetLocalVarStack().Pop(),i&&a.PopSol(s),a._DecTriggerDepth(),a.ClearNestedAsyncActionPromises()}RunAsExpressionFunctionCall(e,t,s,i,...n){let r,a,o=0<e.length,l=this._runtime,h=this._eventStack,c=l.GetEventSheetManager(),u=this._scopeParent,_=u.IsAsync(),d=c._IncTriggerDepth(),p=1<d,m=(p&&c.GetLocalVarStack().Push(),0<n.length&&this._scopeParent.SetFunctionParameters(n),o&&(t?c.PushCopySol(e):c.PushCleanSol(e)),h.Push(this));return m.InitCallFunctionExpression(s,i),h.PushExpFunc(m),l.SetDebuggingEnabled(!1),this._CheckParentsOKToRun(m)&&(m.SetCurrentEvent(this),_&&([a,r]=u.StartAsyncFunctionCall()),this._RunAndBlock(m),_)&&u.MaybeFinishAsyncFunctionCall(a),l.SetDebuggingEnabled(!0),h.Pop(),h.PopExpFunc(),p&&c.GetLocalVarStack().Pop(),o&&c.PopSol(e),c._DecTriggerDepth(),_||c.ClearNestedAsyncActionPromises(),r||m.GetFunctionReturnValue()}}}{let C33=self.C3,EMPTY_SOL_MODIFIERS=[],hadUserScriptException=!1;C33.EventScript=class extends C33.DefendedBase{constructor(e,t,s){super();const i=e.GetRuntime(),n=e.GetEventSheetManager(),r=(this._eventSheet=e,this._eventSheetManager=n,this._runtime=e.GetRuntime(),this._parent=t,i.GetObjectReference(s[1]));this._func=r,this._displayNumber=s[2],this._eventSheet._RegisterEventByDisplayNumber(this,this._displayNumber),this._debugData=i.IsDebug()?{isBreakpoint:s[3][0],isBreakable:s[3][1]}:null}static Create(e,t,s){return C33.New(C33.EventScript,e,t,s)}_PostInit(){const e=this._func,t=this._runtime.GetEventSheetManager()._GetLocalVariablesScriptInterface(this);this._func=e.bind(null,this._runtime.GetIRuntime(),t)}GetParent(){return this._parent}GetScopeParent(){return this._parent}GetEventSheet(){return this._eventSheet}GetDisplayNumber(){return this._displayNumber}IsDebugBreakable(){return this._debugData&&this._debugData.isBreakable}IsDebugBreakpoint(){return this.IsDebugBreakable()&&this._debugData.isBreakpoint}_SetDebugBreakpoint(e){this._debugData.isBreakpoint=!!e}IsElseBlock(){return!1}GetSolModifiers(){return EMPTY_SOL_MODIFIERS}GetSolModifiersIncludingParents(){return this._parent?this._parent.GetSolModifiersIncludingParents():EMPTY_SOL_MODIFIERS}Run(e){e.SetCurrentEvent(this),this._eventSheetManager.AddAsyncActionPromise(this._RunUserScript())}async _RunUserScript(){try{await this._func()}catch(e){console.error(`Unhandled exception running script %c${this.GetEventSheet().GetName()}, event ${this.GetDisplayNumber()}:`,"font-size: 1.2em; font-weight: bold;",e),self.C3Debugger&&self.C3Debugger._SetLastErrorScript(this),hadUserScriptException||(console.info("%cTip:%c run this to highlight in Construct the last script that had an error: %cgoToLastErrorScript()","font-weight: bold; text-decoration: underline","","font-weight: bold"),hadUserScriptException=!0)}}*DebugRun(e){e.SetCurrentEvent(this),(this.IsDebugBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this.Run(e)}DebugCanRunFast(){return!this.IsDebugBreakpoint()&&!this._runtime.DebugBreakNext()}static HadUserScriptException(){return hadUserScriptException}static SetHadUserScriptException(){hadUserScriptException=!0}}}{const C33=self.C3,assert=self.assert;C33.FunctionBlock=class extends C33.DefendedBase{constructor(e,t,s){super(),this._eventSheet=e,this._runtime=e.GetRuntime(),this._parent=t,this._functionType=0,this._functionName="",this._returnType=0,this._functionParameters=[],this._isEnabled=!0,this._aceName="",this._objectClass=null,this._hasOverrides=!1,this._innerLocalVariables=[],this._isCopyPicked=!1,this._isAsync=!1,this._nextAsyncId=0,this._currentAsyncId=-1,this._asyncMap=new Map,this._eventBlock=C33.EventBlock.Create(e,t,s),this._eventBlock._SetScopeParent(this)}InitFunctionBlock(e){this._functionType=0,this._functionName=e[0],this._returnType=e[1],this._functionParameters=e[2].map(e=>C33.EventVariable.Create(this._eventSheet,this,e)),this._isEnabled=e[3],this._isAsync=e[4],this._isCopyPicked=e[5]}InitCustomACEBlock(e){this._functionType=1,this._aceName=e[1],this._objectClass=this._runtime.GetObjectClassByIndex(e[2]),this._eventBlock._AddSolModifier(this._objectClass),this._functionName=this._objectClass.GetName()+"."+this._aceName,this._returnType=e[3],this._functionParameters=e[4].map(e=>C33.EventVariable.Create(this._eventSheet,this,e)),this._isEnabled=e[5],this._isAsync=e[6],this._isCopyPicked=e[7],this._objectClass.AddCustomAction(this)}static CreateFunctionBlock(e,t,s){const i=C33.New(C33.FunctionBlock,e,t,s),n=s[1];return i.InitFunctionBlock(n),i}static CreateCustomACEBlock(e,t,s){const i=C33.New(C33.FunctionBlock,e,t,s),n=s[1];return i.InitCustomACEBlock(n),i}_CheckOverrideState(){if(this._objectClass&&this._objectClass.IsFamily())for(const e of this._objectClass.GetFamilyMembers())if(e.HasOwnCustomActionByName(this._aceName)){this._hasOverrides=!0;break}}_PostInit(){for(const e of this._functionParameters)e._PostInit();this._eventBlock._PostInit(!1)}GetFunctionType(){return this._functionType}_GetAllLocalVariablesInScope(){return this._functionParameters}GetFunctionParameters(){return this._functionParameters}GetFunctionParameterCount(){return this._functionParameters.length}_RegisterLocalVariable(e){this._innerLocalVariables.push(e)}_GetAllInnerLocalVariables(){return this._innerLocalVariables}EvaluateFunctionParameters(s){const i=this._functionParameters;for(let e=0,t=i.length;e<t;++e)i[e].SetValue(s[e].Get(0))}SetFunctionParameters(s){const i=this._functionParameters;for(let e=0,t=i.length;e<t;++e)i[e].SetValue(s[e])}CaptureFunctionParameters(){return this._functionParameters.map(e=>e.GetValue())}GetParent(){return this._parent}GetScopeParent(){return this._parent}GetFunctionName(){return this._functionName}GetACEName(){return this._aceName}HasCustomACEOverrides(){return this._hasOverrides}GetReturnType(){return this._returnType}GetObjectClass(){return this._objectClass}IsEnabled(){return this._isEnabled}GetDefaultReturnValue(){switch(this._returnType){case 0:return null;case 2:return"";default:return 0}}GetEventBlock(){return this._eventBlock}IsCopyPicked(){return this._isCopyPicked}IsAsync(){return this._isAsync}StartAsyncFunctionCall(){const e=this._nextAsyncId++;this._currentAsyncId=e;let t,s=new Promise(e=>t=e);return this._asyncMap.set(e,{resolve:t,pauseCount:0}),[e,s]}MaybeFinishAsyncFunctionCall(e){const t=this._asyncMap.get(e);0===t.pauseCount&&(t.resolve(),this._asyncMap.delete(e)),this._currentAsyncId=-1}PauseCurrentAsyncFunction(){const e=this._asyncMap.get(this._currentAsyncId);return e.pauseCount++,this._currentAsyncId}ResumeAsyncFunction(e){this._currentAsyncId=e;const t=this._asyncMap.get(e);t.pauseCount--}RunAsFamilyCustomActionWithOverrides(e,t){const s=new Map,i=[];for(const n of this._objectClass.GetCurrentSol().GetInstances()){const r=n.GetObjectClass();if(r.HasOwnCustomActionByName(this._aceName)){const a=s.get(r);Array.isArray(a)?a.push(n):s.set(r,[n])}else i.push(n)}if(0<i.length&&this._eventBlock.RunAsFunctionCall(e,t,this._isCopyPicked,{pickObjectClass:this._objectClass,pickInstances:i}),0<s.size)for(const[o,l]of s){const h=o.GetOwnCustomActionByName(this._aceName).GetEventBlock(),c=[...new Set([...e,...h.GetSolModifiers()])];h.RunAsFunctionCall(c,t,this._isCopyPicked,{pickObjectClass:o,pickInstances:l})}}*DebugRunAsFamilyCustomActionWithOverrides(e,t){const s=new Map,i=[];for(const n of this._objectClass.GetCurrentSol().GetInstances()){const r=n.GetObjectClass();if(r.HasOwnCustomActionByName(this._aceName)){const a=s.get(r);Array.isArray(a)?a.push(n):s.set(r,[n])}else i.push(n)}if(0<i.length&&(yield*this._eventBlock.DebugRunAsFunctionCall(e,t,this._isCopyPicked,{pickObjectClass:this._objectClass,pickInstances:i})),0<s.size)for(const[o,l]of s){const h=o.GetOwnCustomActionByName(this._aceName).GetEventBlock(),c=[...new Set([...e,...h.GetSolModifiers()])];yield*h.DebugRunAsFunctionCall(c,t,this._isCopyPicked,{pickObjectClass:o,pickInstances:l})}}}}{const C33=self.C3,EMPTY_SOL_MODIFIERS=[];C33.EventVariable=class extends C33.DefendedBase{constructor(e,t,s){super();const i=e.GetEventSheetManager();this._eventSheet=e,this._eventSheetManager=i,this._runtime=e.GetRuntime(),this._parent=t,this._localVarStack=i.GetLocalVarStack(),this._name=s[1],this._type=s[2],this._initialValue=s[3],this._isStatic=!!s[4],this._isConstant=!!s[5],this._isFunctionParameter=t instanceof C33.FunctionBlock,this._sid=s[6],this._jsPropName=this._runtime.GetJsPropName(s[8]),this._scriptSetter=e=>this.SetValue(e),this._scriptGetter=()=>this.GetValue(),this._hasSingleValue=!this._parent||this._isStatic||this._isConstant,this._value=this._initialValue,this._localIndex=-1,this.IsBoolean()&&(this._value=this._value?1:0),!this.IsLocal()||this.IsStatic()||this.IsConstant()||(this._localIndex=i._GetNextLocalVarIndex(this)),i._RegisterEventVariable(this)}static Create(e,t,s){return C33.New(C33.EventVariable,e,t,s)}_PostInit(){if(this.IsLocal()&&!this.IsStatic()&&!this.IsConstant()&&!this.IsFunctionParameter()){const e=this._eventSheetManager.FindFirstFunctionBlockParent(this);e&&e._RegisterLocalVariable(this)}}GetName(){return this._name}GetJsPropName(){return this._jsPropName}GetParent(){return this._parent}GetScopeParent(){return this.GetParent()}IsGlobal(){return!this.GetParent()}IsLocal(){return!this.IsGlobal()}IsFunctionParameter(){return this._isFunctionParameter}IsStatic(){return this._isStatic}IsConstant(){return this._isConstant}IsNumber(){return 0===this._type}IsString(){return 1===this._type}IsBoolean(){return 2===this._type}IsElseBlock(){return!1}GetSID(){return this._sid}GetInitialValue(){return this._initialValue}GetSolModifiers(){return EMPTY_SOL_MODIFIERS}Run(e){!this.IsLocal()||this.IsStatic()||this.IsConstant()||this.SetValue(this.GetInitialValue())}DebugCanRunFast(){return!0}*DebugRun(e){this.Run(e)}SetValue(e){this.IsNumber()?"number"!=typeof e&&(e=parseFloat(e)):this.IsString()?"string"!=typeof e&&(e=e.toString()):this.IsBoolean()&&(e=e?1:0),this._hasSingleValue?this._value=e:this._localVarStack.GetCurrent()[this._localIndex]=e}GetValue(){return this._hasSingleValue?this._value:this._localVarStack.GetCurrent()[this._localIndex]}GetTypedValue(){let e=this.GetValue();return this.IsBoolean()?!!e:e}ResetToInitialValue(){this._value=this._initialValue}_GetScriptInterfaceDescriptor(){return{configurable:!1,enumerable:!0,get:this._scriptGetter,set:this._scriptSetter}}}}{const C33=self.C3,assert=self.assert,EMPTY_SOL_MODIFIERS=[];C33.EventInclude=class extends C33.DefendedBase{constructor(e,t,s){super();const i=e.GetEventSheetManager();this._eventSheet=e,this._eventSheetManager=i,this._runtime=e.GetRuntime(),this._parent=t,this._includeSheet=null,this._includeSheetName=s[1],this._isActive=!0}static Create(e,t,s){return C33.New(C33.EventInclude,e,t,s)}_PostInit(){this._includeSheet=this._eventSheetManager.GetEventSheetByName(this._includeSheetName),this._eventSheet._AddShallowInclude(this);let e=this.GetParent();for(;e;)e instanceof C33.EventBlock&&e.IsGroup()&&e._AddContainedInclude(this),e=e.GetParent();this.UpdateActive(),this._runtime.IsDebug()&&this._eventSheet._GetPerfRecord().children.push(this._includeSheet._GetPerfRecord())}GetParent(){return this._parent}GetSolModifiers(){return EMPTY_SOL_MODIFIERS}GetIncludeSheet(){return this._includeSheet}Run(e){const t=!!this.GetParent(),s=this._runtime.GetAllObjectClasses();t&&this._eventSheetManager.PushCleanSol(s),this._includeSheet.Run(),t&&this._eventSheetManager.PopSol(s)}*DebugRun(e){const t=!!this.GetParent(),s=this._runtime.GetAllObjectClasses();t&&this._eventSheetManager.PushCleanSol(s),yield*this._includeSheet.DebugRun(),t&&this._eventSheetManager.PopSol(s)}DebugCanRunFast(){return!1}IsActive(){return this._isActive}UpdateActive(){let e=this.GetParent();for(;e;){if(e instanceof C33.EventBlock&&e.IsGroup()&&!e.IsGroupActive())return void(this._isActive=!1);e=e.GetParent()}this._isActive=!0}}}{let WrapIndex2=function(e,t){return t<=e?e%t:(e<0&&(e<=-t&&(e%=t),e<0)&&(e+=t),e)};WrapIndex=WrapIndex2;const C33=self.C3,assert=self.assert;C33.ExpNode=class extends C33.DefendedBase{constructor(e){super(),this._owner=e,this._runtime=e.GetRuntime()}_PostInit(){}static CreateNode(e,t){const s=t[0],i=[BehaviorExpressionNode,ObjectExpressionNode,InstVarExpressionNode,EventVarExpNode,SystemExpressionExpNode,CallFunctionExpressionExpNode];return C33.New(i[s],e,t)}};class SystemExpressionExpNode extends C33.ExpNode{constructor(e,t){super(e),this._systemPlugin=this._runtime.GetSystemPlugin(),this._func=this._runtime.GetObjectReference(t[1]),this._func!==C33.Plugins.System.Exps.random&&this._func!==C33.Plugins.System.Exps.choose||this._owner.SetVariesPerInstance()}GetBoundMethod(){return this._systemPlugin._GetBoundACEMethod(this._func,this._systemPlugin)}}class CallFunctionExpressionExpNode extends C33.ExpNode{constructor(e,t){super(e),this._functionBlock=null,this._functionName=t[1],this._owner.SetVariesPerInstance()}_PostInit(){const e=this._runtime.GetEventSheetManager(),t=(this._functionBlock=e.GetFunctionBlockByName(this._functionName),this._functionName=null,this._owner.GetEventBlock()),s=this._functionBlock.GetEventBlock();this._combinedSolModifiers=[...new Set([...t.GetSolModifiersIncludingParents(),...s.GetSolModifiersIncludingParents()])],this._combinedSolModifiers=e._DeduplicateSolModifierList(this._combinedSolModifiers)}GetBoundMethod(){const e=this._functionBlock;if(e.IsEnabled()){const t=e.GetEventBlock();return C33.EventBlock.prototype.RunAsExpressionFunctionCall.bind(t,this._combinedSolModifiers,e.IsCopyPicked(),e.GetReturnType(),e.GetDefaultReturnValue())}{const s=e.GetDefaultReturnValue();return()=>s}}}class ObjectExpressionNode extends C33.ExpNode{constructor(e,t){super(e),this._objectClass=this._runtime.GetObjectClassByIndex(t[1]),this._func=this._runtime.GetObjectReference(t[2]),this._returnsString=!!t[3],this._eventStack=this._runtime.GetEventSheetManager().GetEventStack(),this._owner._MaybeVaryFor(this._objectClass)}GetBoundMethod(){return this._objectClass.GetPlugin()._GetBoundACEMethod(this._func,this._objectClass.GetSingleGlobalInstance().GetSdkInstance())}ExpObject(...e){const t=this._objectClass,s=t.GetCurrentSol().GetExpressionInstances(),i=s.length;if(0===i)return this._returnsString?"":0;const n=WrapIndex2(this._owner.GetSolIndex(),i);return this._eventStack.GetCurrentStackFrame().SetExpressionObjectClass(t),this._func.apply(s[n].GetSdkInstance(),e)}ExpObject_InstExpr(e,...t){const s=this._objectClass,i=s.GetInstances(),n=i.length;if(0===n||"number"!=typeof e)return this._returnsString?"":0;const r=WrapIndex2(e,n);return this._eventStack.GetCurrentStackFrame().SetExpressionObjectClass(s),this._func.apply(i[r].GetSdkInstance(),t)}}class InstVarExpressionNode extends C33.ExpNode{constructor(e,t){super(e),this._objectClass=this._runtime.GetObjectClassByIndex(t[1]),this._varIndex=t[3],this._returnsString=!!t[2],this._owner._MaybeVaryFor(this._objectClass)}ExpInstVar(){const e=this._objectClass.GetCurrentSol().GetExpressionInstances(),t=e.length;if(0===t)return this._returnsString?"":0;const s=WrapIndex2(this._owner.GetSolIndex(),t);return e[s]._GetInstanceVariableValueUnchecked(this._varIndex)}ExpInstVar_Family(){const e=this._objectClass,t=e.GetCurrentSol().GetExpressionInstances(),s=t.length;if(0===s)return this._returnsString?"":0;const i=WrapIndex2(this._owner.GetSolIndex(),s),n=t[i],r=n.GetObjectClass().GetFamilyInstanceVariableOffset(e.GetFamilyIndex());return n._GetInstanceVariableValueUnchecked(this._varIndex+r)}ExpInstVar_InstExpr(e){const t=this._objectClass,s=t.GetInstances(),i=s.length;if(0===i||"number"!=typeof e)return this._returnsString?"":0;let n=WrapIndex2(e,i),r=s[n],a=0;return t.IsFamily()&&(a=r.GetObjectClass().GetFamilyInstanceVariableOffset(t.GetFamilyIndex())),r._GetInstanceVariableValueUnchecked(this._varIndex+a)}}class BehaviorExpressionNode extends C33.ExpNode{constructor(e,t){super(e),this._objectClass=this._runtime.GetObjectClassByIndex(t[1]),this._behaviorType=this._objectClass.GetBehaviorTypeByName(t[2]),this._behaviorIndex=this._objectClass.GetBehaviorIndexByName(t[2]),this._func=this._runtime.GetObjectReference(t[3]),this._returnsString=!!t[4],this._eventStack=this._runtime.GetEventSheetManager().GetEventStack(),this._owner._MaybeVaryFor(this._objectClass)}ExpBehavior(...e){const t=this._objectClass,s=t.GetCurrentSol().GetExpressionInstances(),i=s.length;if(0===i)return this._returnsString?"":0;let n=WrapIndex2(this._owner.GetSolIndex(),i),r=(this._eventStack.GetCurrentStackFrame().SetExpressionObjectClass(t),s[n]),a=0;return t.IsFamily()&&(a=r.GetObjectClass().GetFamilyBehaviorOffset(t.GetFamilyIndex())),this._func.apply(r.GetBehaviorInstances()[this._behaviorIndex+a].GetSdkInstance(),e)}ExpBehavior_InstExpr(e,...t){const s=this._objectClass,i=s.GetInstances(),n=i.length;if(0===n||"number"!=typeof e)return this._returnsString?"":0;let r=WrapIndex2(e,n),a=(this._eventStack.GetCurrentStackFrame().SetExpressionObjectClass(s),i[r]),o=0;return s.IsFamily()&&(o=a.GetObjectClass().GetFamilyBehaviorOffset(s.GetFamilyIndex())),this._func.apply(a.GetBehaviorInstances()[this._behaviorIndex+o].GetSdkInstance(),t)}}class EventVarExpNode extends C33.ExpNode{constructor(e,t){super(e),this._eventVar=null,this._eventVarSid=t[1]}_PostInit(){this._eventVar=this._runtime.GetEventSheetManager().GetEventVariableBySID(this._eventVarSid)}GetVar(){return this._eventVar}}}{let GetExpressionFunc2=function(e){const t=self.C3_ExpressionFuncs[e];if(t)return t;throw new Error("invalid expression number")};GetExpressionFunc=GetExpressionFunc2;const C33=self.C3,assert=self.assert;C33.Parameter=class extends C33.DefendedBase{constructor(e,t,s){super(),this._owner=e,this._index=s,this._type=t,this.Get=null,this._variesPerInstance=!1,this._isConstant=!1}static Create(e,t,s){const i=t[0],n=[ExpressionParameter,StringExpressionParameter,FileParameter,ComboParameter,ObjectParameter,LayerExpressionParameter,LayoutParameter,ExpressionParameter,ComboParameter,ComboParameter,InstVarParameter,EventVarParameter,FileParameter,VariadicParameter,StringExpressionParameter,TimelineParameter,BooleanParameter,FunctionParameter,EaseParameter,TilemapBrushParameter,TemplateExpressionParameter,FlowchartParameter];return C33.New(n[i],e,i,s,t)}_PostInit(){}SetVariesPerInstance(){this._variesPerInstance=!0}_MaybeVaryFor(e){this._variesPerInstance||!e||e.GetPlugin().IsSingleGlobal()||(this._variesPerInstance=!0)}VariesPerInstance(){return this._variesPerInstance}GetIndex(){return this._index}GetRuntime(){return this._owner.GetRuntime()}GetEventBlock(){return this._owner.GetEventBlock()}IsConstant(){return this._isConstant}IsObjectParameter(){return 4===this._type}};class ExpressionParameter extends C33.Parameter{constructor(e,t,s,i){super(e,t,s),this._solIndex=0;const n=i[1];this._expressionNumber=n[0],this._numberedNodes=[],this._expressionFunc=null;for(let e=1,t=n.length;e<t;++e)this._numberedNodes.push(C33.ExpNode.CreateNode(this,n[e]));this._numberedNodes.length?this.Get=this.GetExpression:(this.Get=GetExpressionFunc2(this._expressionNumber),this._isConstant=!0)}_GetNode(e){if(e<0||e>=this._numberedNodes.length)throw new RangeError("invalid numbered node");return this._numberedNodes[e]}_PostInit(){for(const t of this._numberedNodes)t._PostInit();const e=GetExpressionFunc2(this._expressionNumber);this._numberedNodes.length?this._expressionFunc=e(this):this._expressionFunc=e}GetSolIndex(){return this._solIndex}GetExpression(e){return this._solIndex=e,this._expressionFunc()}}class StringExpressionParameter extends ExpressionParameter{constructor(e,t,s,i){super(e,t,s,i),this.Get=this.GetStringExpression,14===t&&(this.GetEventBlock().SetAllSolModifiers(),this._owner instanceof C33.Action)&&this.GetEventBlock().SetSolWriterAfterCnds()}GetStringExpression(e){this._solIndex=e;const t=this._expressionFunc();return"string"==typeof t?t:""}_GetFastTriggerValue(){return GetExpressionFunc2(this._expressionNumber)()}}class LayerExpressionParameter extends ExpressionParameter{constructor(e,t,s,i){super(e,t,s,i),2<=e.GetImplementationSdkVersion()?this.Get=this.GetILayer:this.Get=this.GetLayer,this._isConstant=!1}GetLayer(e){this._solIndex=e;const t=this._expressionFunc(),s=this.GetRuntime().GetCurrentLayout();return s.GetLayer(t)}GetILayer(e){const t=this.GetLayer(e);return t?t.GetILayer():null}}class ComboParameter extends C33.Parameter{constructor(e,t,s,i){super(e,t,s),this._combo=i[1],this.Get=this.GetCombo,this._isConstant=!0}GetCombo(){return this._combo}}class BooleanParameter extends C33.Parameter{constructor(e,t,s,i){super(e,t,s),this._bool=i[1],this.Get=this.GetBoolean,this._isConstant=!0}GetBoolean(){return this._bool}}class ObjectParameter extends C33.Parameter{constructor(e,t,s,i){super(e,t,s),this._objectClass=this.GetRuntime().GetObjectClassByIndex(i[1]),2<=e.GetImplementationSdkVersion()?this.Get=this.GetIObjectClass:this.Get=this.GetObjectClass;const n=this.GetEventBlock();n._AddSolModifier(this._objectClass),this._owner instanceof C33.Action?n.SetSolWriterAfterCnds():n.GetParent()&&n.GetParent().SetSolWriterAfterCnds(),this._isConstant=!0}GetObjectClass(){return this._objectClass}GetIObjectClass(){return this._objectClass?this._objectClass.GetIObjectClass():null}}class LayoutParameter extends C33.Parameter{constructor(e,t,s,i){super(e,t,s),this._layout=this.GetRuntime().GetLayoutManager().GetLayoutByName(i[1]),2<=e.GetImplementationSdkVersion()?this.Get=this.GetILayout:this.Get=this.GetLayout,this._isConstant=!0}GetLayout(){return this._layout}GetILayout(){return this._layout?this._layout.GetILayout():null}}class TimelineParameter extends C33.Parameter{constructor(e,t,s,i){super(e,t,s),this._timeline=this.GetRuntime().GetTimelineManager().GetTimelineByName(i[1]),2<=e.GetImplementationSdkVersion()?this.Get=this.GetITimelineState:this.Get=this.GetTimeline,this._isConstant=!0}GetTimeline(){return this._timeline}GetITimelineState(){return this._timeline?this._timeline.GetITimelineState():null}}class FileParameter extends C33.Parameter{constructor(e,t,s,i){super(e,t,s),this._fileInfo=i[1],this.Get=this.GetFile,this._isConstant=!0}GetFile(){return this._fileInfo}}class InstVarParameter extends C33.Parameter{constructor(e,t,s,i){super(e,t,s),this._instVarIndex=i[1];const n=this._owner.GetObjectClass();this._owner instanceof C33.Condition&&this._owner.IsStatic()||!n||!n.IsFamily()?(this.Get=this.GetInstanceVariable,this._isConstant=!0):(this.Get=this.GetFamilyInstanceVariable,this.SetVariesPerInstance())}GetInstanceVariable(){return this._instVarIndex}GetFamilyInstanceVariable(e){e=e||0;let t=this._owner.GetObjectClass(),s=t.GetCurrentSol(),i=s.GetInstances(),n=null;if(i.length)n=i[e%i.length].GetObjectClass();else if(s.HasAnyElseInstances()){const r=s.GetElseInstances();n=r[e%r.length].GetObjectClass()}else{if(!(0<t.GetInstanceCount()))return 0;{const a=t.GetInstances();n=a[e%a.length].GetObjectClass()}}return this._instVarIndex+n.GetFamilyInstanceVariableOffset(t.GetFamilyIndex())}}class EventVarParameter extends C33.Parameter{constructor(e,t,s,i){super(e,t,s),this._eventVarSid=i[1],this._eventVar=null,2<=e.GetImplementationSdkVersion()?this.Get=this.GetIEventVariable:this.Get=this.GetEventVariable,this._isConstant=!0}_PostInit(){this._eventVar=this.GetRuntime().GetEventSheetManager().GetEventVariableBySID(this._eventVarSid)}GetEventVariable(){return this._eventVar}GetIEventVariable(){return null}}class FunctionParameter extends C33.Parameter{constructor(e,t,s,i){super(e,t,s),this._functionBlockName=i[1],this._functionBlock=null,2<=e.GetImplementationSdkVersion()?this.Get=this.GetIFunction:this.Get=this.GetFunction,this._isConstant=!0}_PostInit(){this._functionBlock=this.GetRuntime().GetEventSheetManager().GetFunctionBlockByName(this._functionBlockName),this._functionBlockName=null}GetFunction(){return this._functionBlock}GetIFunction(){return null}}class VariadicParameter extends C33.Parameter{constructor(e,t,s,i){super(e,t,s),this._subParams=[],this._variadicRet=[],this._isConstant=!0;for(let e=1,t=i.length;e<t;++e){const n=C33.Parameter.Create(this._owner,i[e],0);this._subParams.push(n),this._variadicRet.push(0),n.IsConstant()||(this._isConstant=!1)}this.Get=this.GetVariadic}_PostInit(){for(const e of this._subParams)e._PostInit()}GetVariadic(){const s=this._subParams,i=this._variadicRet;for(let e=0,t=s.length;e<t;++e)i[e]=s[e].Get(0);return i}}class EaseParameter extends C33.Parameter{constructor(e,t,s,i){super(e,t,s),this._easeIndex=i[1],this.Get=this.GetEase,this._isConstant=!0}GetEase(){return this._easeIndex}}class TilemapBrushParameter extends C33.Parameter{constructor(e,t,s,i){super(e,t,s),this._brushIndex=i[1],this.Get=this.GetTilemapBrush,this._isConstant=!0}GetTilemapBrush(){return this._brushIndex}}class TemplateExpressionParameter extends ExpressionParameter{constructor(e,t,s,i){super(e,t,s,i),this.Get=this.GetTemplateName,this._isConstant=!1}GetTemplateName(){return this._expressionFunc()}}class FlowchartParameter extends C33.Parameter{constructor(e,t,s,i){super(e,t,s),this._flowchartDataItem=this.GetRuntime().GetFlowchartManager().GetFlowchartDataItemByName(i[1]),this.Get=this.GetFlowchartName,this._isConstant=!0}GetFlowchartName(){return this._flowchartDataItem.GetName()}}}{let EvalParams2=function(s,i){for(let e=0,t=s.length;e<t;++e)i[e]=s[e].Get(0)};EvalParams=EvalParams2;const C33=self.C3,assert=self.assert,EMPTY_PARAMS_ARRAY=[],noop=function(){};C33.Condition=class extends C33.DefendedBase{constructor(e,s,t){if(super(),this._eventBlock=e,this._runtime=e.GetRuntime(),this._index=t,this._func=this._runtime.GetObjectReference(s[1]),this._isTrigger=0<s[3],this._isFastTrigger=2===s[3],this._isLooping=!!s[4],this._isInverted=!!s[5],this._isStatic=!!s[6],this._sid=s[7],this._isInOrBlock=this._eventBlock.IsOrBlock(),this._objectClass=null,this._behaviorType=null,this._behaviorIndex=-1,this._systemPlugin=null,this.Run=noop,this.DebugRun=noop,this._parameters=[],this._results=[],this._anyParamVariesPerInstance=!1,this._savedData=null,this._unsavedData=null,this._debugData=this._runtime.IsDebug()?{isBreakpoint:s[8][0],canDebug:s[8][1]}:null,-1===s[0]?this._systemPlugin=this._runtime.GetSystemPlugin():(this._objectClass=this._runtime.GetObjectClassByIndex(s[0]),s[2]&&(this._behaviorType=this._objectClass.GetBehaviorTypeByName(s[2]),this._behaviorIndex=this._objectClass.GetBehaviorIndexByName(s[2])),this._eventBlock.GetParent()&&this._eventBlock.GetParent().SetSolWriterAfterCnds()),10===s.length){let t=s[9];for(let e of t)this._parameters.push(C33.Parameter.Create(this,e,this._parameters.length)),this._results.push(0)}0===this._parameters.length&&(this._parameters=EMPTY_PARAMS_ARRAY,this._results=EMPTY_PARAMS_ARRAY),this._eventBlock.GetEventSheetManager()._RegisterCondition(this)}static Create(e,t,s){return C33.New(C33.Condition,e,t,s)}_PostInit(){for(const e of this._parameters)e._PostInit(),e.VariesPerInstance()&&(this._anyParamVariesPerInstance=!0);this._isFastTrigger?(this.Run=this._RunFastTrigger,this.DebugRun=this._DebugRunFastTrigger):this._systemPlugin?(this._SetSystemRunMethod(),this.DebugRun=this._DebugRunSystem):this._objectClass.GetPlugin().IsSingleGlobal()?(this._SetSingleGlobalRunMethod(),this.DebugRun=this._DebugRunSingleGlobal):this._isStatic?(this.Run=this._RunStatic,this.DebugRun=this._DebugRunStatic):(this.Run=this._RunObject,this.DebugRun=this._DebugRunObject)}_SetSystemRunMethod(){const e=this._systemPlugin,t=this._systemPlugin;this._SetRunMethodForBoundFunc(e,t,this._RunSystem)}_SetSingleGlobalRunMethod(){const e=this._objectClass.GetPlugin(),t=this._objectClass.GetSingleGlobalInstance().GetSdkInstance();this._SetRunMethodForBoundFunc(e,t,this._RunSingleGlobal)}_SetRunMethodForBoundFunc(e,t,s){const i=this._func,n=this._isInverted,r=this._parameters;if(0===r.length){const a=e._GetBoundACEMethod(i,t);n?this.Run=function(){return C33.xor(a(),n)}:this.Run=a}else if(1===r.length){const o=r[0];if(!n&&o.IsConstant())this.Run=e._GetBoundACEMethod_1param(i,t,o.Get(0));else{const l=e._GetBoundACEMethod(i,t);this.Run=function(){return C33.xor(l(o.Get(0)),n)}}}else if(2===r.length){const h=r[0],c=r[1];if(!n&&h.IsConstant()&&c.IsConstant())this.Run=e._GetBoundACEMethod_2params(i,t,h.Get(0),c.Get(0));else{const u=e._GetBoundACEMethod(i,t);this.Run=function(){return C33.xor(u(h.Get(0),c.Get(0)),n)}}}else if(3===r.length){const _=r[0],d=r[1],p=r[2];if(!n&&_.IsConstant()&&d.IsConstant()&&p.IsConstant())this.Run=e._GetBoundACEMethod_3params(i,t,_.Get(0),d.Get(0),p.Get(0));else{const m=e._GetBoundACEMethod(i,t);this.Run=function(){return C33.xor(m(_.Get(0),d.Get(0),p.Get(0)),n)}}}else this.Run=s}GetSID(){return this._sid}_GetFunc(){return this._func}GetObjectClass(){return this._objectClass}GetBehaviorType(){return this._behaviorType}GetImplementationAddon(){return this._behaviorType?this._behaviorType.GetBehavior():this._objectClass?this._objectClass.GetPlugin():null}GetImplementationSdkVersion(){const e=this.GetImplementationAddon();return e?e.GetSdkVersion():1}GetEventBlock(){return this._eventBlock}GetRuntime(){return this._runtime}GetIndex(){return this._index}GetDebugIndex(){return this.GetIndex()}IsTrigger(){return this._isTrigger}IsFastTrigger(){return this._isFastTrigger}IsInverted(){return this._isInverted}IsLooping(){return this._isLooping}IsStatic(){return this._isStatic}IsBreakpoint(){return this._debugData.isBreakpoint}IsSystemCondition(){return!!this._systemPlugin}IsSystemOrSingleGlobalCondition(){return this.IsSystemCondition()||this._objectClass.GetPlugin().IsSingleGlobal()}GetFirstObjectParameterObjectClass(){for(const e of this._parameters)if(e.IsObjectParameter())return e.GetObjectClass();return null}_SetBreakpoint(e){this._debugData.isBreakpoint=!!e,this._eventBlock._UpdateCanRunFastRecursive()}_DebugReturnsGenerator(){return this._debugData.canDebug}DebugCanRunFast(){return!this.IsBreakpoint()&&!this._runtime.DebugBreakNext()&&!this._DebugReturnsGenerator()}GetSavedDataMap(){return this._savedData||(this._savedData=new Map),this._savedData}GetUnsavedDataMap(){return this._unsavedData||(this._unsavedData=new Map),this._unsavedData}_RunSystem(){const e=this._results;return EvalParams2(this._parameters,e),C33.xor(this._func.apply(this._systemPlugin,e),this._isInverted)}*_DebugRunSystem(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const t=this._results;EvalParams2(this._parameters,t);let e=this._func.apply(this._systemPlugin,t);return C33.IsIterator(e)&&(e=yield*e),C33.xor(e,this._isInverted)}return this.Run()}_RunSingleGlobal(){const e=this._results,t=(EvalParams2(this._parameters,e),this._objectClass.GetSingleGlobalInstance().GetSdkInstance());return C33.xor(this._func.apply(t,e),this._isInverted)}*_DebugRunSingleGlobal(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){let e=this._results,t=(EvalParams2(this._parameters,e),this._objectClass.GetSingleGlobalInstance().GetSdkInstance()),s=this._func.apply(t,e);return C33.IsIterator(s)&&(s=yield*s),C33.xor(s,this._isInverted)}return this.Run()}_RunFastTrigger(){return!0}*_DebugRunFastTrigger(){return(this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),!0}_GetStaticConditionThis(){return this._behaviorType?2<=this._behaviorType.GetBehavior().GetSdkVersion()?this._behaviorType.GetIBehaviorType():this._behaviorType:2<=this._objectClass.GetPlugin().GetSdkVersion()?this._objectClass.GetIObjectClass():this._objectClass}_RunStatic(){const e=this._results,t=(EvalParams2(this._parameters,e),this._func.apply(this._GetStaticConditionThis(),e));return this._objectClass.ApplySolToContainer(),t}*_DebugRunStatic(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const t=this._results;EvalParams2(this._parameters,t);let e=this._func.apply(this._GetStaticConditionThis(),t);return C33.IsIterator(e)&&(e=yield*e),this._objectClass.ApplySolToContainer(),e}return this.Run()}_RunObject(){const s=this._parameters,i=this._results,e=this._objectClass.GetCurrentSol();for(let e=0,t=s.length;e<t;++e){const n=s[e];n.VariesPerInstance()||(i[e]=n.Get(0))}return e.IsSelectAll()?this._RunObject_FirstFilter(e):this._RunObject_NextFilter(e)}*_DebugRunObject(){return(this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._RunObject()}_EvaluateVaryingParameters(s){const i=this._parameters,n=this._results;for(let e=0,t=i.length;e<t;++e){const r=i[e];r.VariesPerInstance()&&(n[e]=r.Get(s))}}_RunObject_FirstFilter(s){const e=this._objectClass,i=e.IsFamily(),n=e.GetFamilyIndex(),r=this._behaviorIndex,a=0<=r,o=e.GetInstances(),l=this._anyParamVariesPerInstance,h=this._results,c=this._func,u=this._isInverted,_=this._isInOrBlock&&!this._isTrigger;s.ClearArrays();for(let t=0,e=o.length;t<e;++t){const d=o[t];l&&this._EvaluateVaryingParameters(t);let e;if(a){const p=i?d.GetObjectClass().GetFamilyBehaviorOffset(n):0;e=c.apply(d.GetBehaviorInstances()[r+p].GetSdkInstance(),h)}else e=c.apply(d.GetSdkInstance(),h);C33.xor(e,u)?s._PushInstance(d):_&&s._PushElseInstance(d)}return e.FinishCondition(!0),s._SetSelectAll(!1),e.ApplySolToContainer(),s.HasAnyInstances()}_RunObject_NextFilter(e){let t=this._objectClass,s=t.IsFamily(),i=t.GetFamilyIndex(),n=t.IsInContainer(),r=this._behaviorIndex,a=0<=r,o=this._anyParamVariesPerInstance,l=this._results,h=this._func,c=this._isInverted,u=this._isInOrBlock&&!this._isTrigger,_=e._GetOwnInstances(),d=e._GetOwnElseInstances(),p=u&&!this._eventBlock.IsFirstConditionOfType(this),m=p?d:_,g=0,f=!1;for(let t=0,e=m.length;t<e;++t){const C=m[t];o&&this._EvaluateVaryingParameters(t);let e;if(a){const y=s?C.GetObjectClass().GetFamilyBehaviorOffset(i):0;e=h.apply(C.GetBehaviorInstances()[r+y].GetSdkInstance(),l)}else e=h.apply(C.GetSdkInstance(),l);C33.xor(e,c)?(f=!0,p?(_.push(C),n&&C._PushSiblingsToSolInstances()):(m[g]=C,n&&C._SetSiblingsToSolInstancesIndex(g),++g)):p?(m[g]=C,n&&C._SetSiblingsToSolElseInstancesIndex(g),++g):u&&(d.push(C),n)&&C._PushSiblingsToSolElseInstances()}C33.truncateArray(m,g),n&&t._TruncateContainerSols(p,g);const S=f;return p&&!f&&(f=this._OrBlockCheckInstances(_)),t.FinishCondition(S||u),u?f:e.HasAnyInstances()}_OrBlockCheckInstances(s){const e=this._objectClass,i=e.IsFamily(),n=e.GetFamilyIndex(),r=this._anyParamVariesPerInstance,a=this._behaviorIndex,o=0<=a,l=this._results,h=this._func,c=this._isInverted;for(let t=0,e=s.length;t<e;++t){const u=s[t];r&&this._EvaluateVaryingParameters(t);let e;if(o){const _=i?u.GetObjectClass().GetFamilyBehaviorOffset(n):0;e=h.apply(u.GetBehaviorInstances()[a+_].GetSdkInstance(),l)}else e=h.apply(u.GetSdkInstance(),l);if(C33.xor(e,c))return!0}return!1}ReevaluateParameter(e,t){return this._parameters[e].Get(t)}GetFastTriggerValue(){const e=this._parameters;if(e.length)return e[0]._GetFastTriggerValue();throw new Error("no parameters")}_SaveToJson(){if(!this._savedData||!this._savedData.size)return null;const t={};for(const[s,i]of this._savedData.entries()){let e=i;"collmemory"===s&&(e=[...i.entries()].map(e=>[e[0].GetUID(),e[1].GetUID(),e[2]])),t[s]=e}return{ex:t}}_LoadFromJson(e){if(this._savedData&&(this._savedData.clear(),this._savedData=null),e){const t=this._runtime,s=e.ex;if(s){const i=this.GetSavedDataMap();i.clear();for(const[n,r]of Object.entries(s)){let e=r;"collmemory"===n&&(e=C33.New(C33.PairMap,r.map(e=>[t.GetInstanceByUID(e[0]),t.GetInstanceByUID(e[1]),e[2]]).filter(e=>e[0]&&e[1]))),i.set(n,e)}}}}}}{let EvalParams2=function(s,i){for(let e=0,t=s.length;e<t;++e)i[e]=s[e].Get(0)};EvalParams=EvalParams2;const C33=self.C3,assert=self.assert,EMPTY_PARAMS_ARRAY=[],noop=function(){},noopGenerator=function*(){},FLAG_CANPICKANYOBJECTCLASS=1,FLAG_COPYPICKED=2,FLAG_CUSTOM_ACE=4,FLAG_IS_ASYNC=8,FLAG_CAN_BAIL_OUT=16;C33.Action=class extends C33.DefendedBase{constructor(e,t,s){super();const i=(this._eventBlock=e).GetRuntime(),n=(this._runtime=i,this._index=s,this._sid=4<=t.length?t[3]:-1,this._actionType=5<=t.length?255&t[4]:0,this._flags=5<=t.length?t[4]>>8:0,this._func=null,this._objectClass=null,this._behaviorType=null,this._behaviorIndex=-1,this._systemPlugin=null,this._callFunctionName="",this._callCustomAceObjectClass=null,this._callEventBlock=null,this.Run=noop,this.DebugRun=noop,this._parameters=[],this._results=[],this._anyParamVariesPerInstance=!1,this._savedData=null,this._unsavedData=null,-3===t[0]),r=n?t[2]:t[5];if(this._debugData=i.IsDebug()||n?{isBreakpoint:r[0],canDebug:r[1],index:r[2]}:null,-1===t[0])this._systemPlugin=i.GetSystemPlugin(),this._func=i.GetObjectReference(t[1]);else if(-2===t[0])this._callFunctionName=t[1];else if(n){const a=i.GetObjectReference(t[1]);this._func=a,this.Run=this.RunUserScript,this.DebugRun=this.DebugRunUserScript,this._flags|=FLAG_IS_ASYNC}else this._objectClass=i.GetObjectClassByIndex(t[0]),this._flags&FLAG_CUSTOM_ACE?(this._callFunctionName=t[1],this._callCustomAceObjectClass=i.GetObjectClassByIndex(t[2])):(t[2]&&(this._behaviorType=this._objectClass.GetBehaviorTypeByName(t[2]),this._behaviorIndex=this._objectClass.GetBehaviorIndexByName(t[2])),this._func=i.GetObjectReference(t[1]));if(7===t.length){const o=t[6];for(const l of o)this._parameters.push(C33.Parameter.Create(this,l,this._parameters.length)),this._results.push(0)}0===this._parameters.length&&(this._parameters=EMPTY_PARAMS_ARRAY,this._results=EMPTY_PARAMS_ARRAY),this.CanPickAnyObjectClass()&&(this._eventBlock.SetAllSolModifiers(),this._eventBlock.SetSolWriterAfterCnds()),this._eventBlock.GetEventSheetManager()._RegisterAction(this)}static Create(e,t,s){return C33.New(C33.Action,e,t,s)}_PostInit(){for(const e of this._parameters)e._PostInit(),e.VariesPerInstance()&&(this._anyParamVariesPerInstance=!0);if(this._systemPlugin)this._SetSystemRunMethod(),this.DebugRun=this._DebugRunSystem;else if(this._callFunctionName)this._flags&FLAG_CUSTOM_ACE?this._SetCallCustomActionRunMethod():this._SetCallFunctionRunMethod(),this._callFunctionName="",this._callCustomAceObjectClass=null;else if(this.Run===this.RunUserScript){const t=this._func,s=this._runtime.GetEventSheetManager()._GetLocalVariablesScriptInterface(this._eventBlock);this._func=t.bind(null,this._runtime.GetIRuntime(),s)}else this._behaviorType?this.IsAsync()?(this.Run=this._RunBehavior_Async,this.DebugRun=this._DebugRunBehavior_Async):(this.Run=this._RunBehavior,this.DebugRun=this._DebugRunBehavior):this._objectClass.GetPlugin().IsSingleGlobal()?(this._SetSingleGlobalRunMethod(),this.DebugRun=this._DebugRunSingleGlobal):this.IsStatic()?(this.Run=this._RunObject_Static,this.DebugRun=this._DebugRunObject_Static):this.IsAsync()?(this.Run=this._RunObject_Async,this.DebugRun=this._DebugRunObject_Async):this.CallBeforeAfterHooks()?(this.Run=this._RunObject_BeforeAfterHooks,this.DebugRun=this._DebugRunObject_BeforeAfterHooks):this._parameters.length?this._parameters.every(e=>e.VariesPerInstance())?(this.Run=this._RunObject_AllParamsVary,this.DebugRun=this._DebugRunObject_AllParamsVary):this._anyParamVariesPerInstance?(this.Run=this._RunObject_SomeParamsVary,this.DebugRun=this._DebugRunObject_SomeParamsVary):this._parameters.every(e=>e.IsConstant())?(EvalParams2(this._parameters,this._results),this.Run=this._RunObject_ParamsConst,this.DebugRun=this._DebugRunObject_ParamsConst):(this.Run=this._RunObject_ParamsDontVary,this.DebugRun=this._DebugRunObject_ParamsDontVary):(this.Run=this._RunObject_ParamsConst,this.DebugRun=this._DebugRunObject_ParamsConst)}_SetSystemRunMethod(){const e=this._systemPlugin,t=this._systemPlugin;this._SetRunMethodForBoundFunc(e,t,this._RunSystem)}_SetSingleGlobalRunMethod(){const e=this._objectClass.GetPlugin(),t=this._objectClass.GetSingleGlobalInstance().GetSdkInstance();this._SetRunMethodForBoundFunc(e,t,this._RunSingleGlobal)}_SetCallFunctionRunMethod(){const e=this._eventBlock.GetEventSheetManager(),s=e.GetFunctionBlockByName(this._callFunctionName);if(s.IsEnabled()){const i=0!=(this._flags&FLAG_COPYPICKED);this._callEventBlock=s.GetEventBlock();let t=[...new Set([...this._eventBlock.GetSolModifiersIncludingParents(),...this._callEventBlock.GetSolModifiersIncludingParents()])];t=e._DeduplicateSolModifierList(t);const n=!s.IsCopyPicked()&&this._HasCopyPickedParent()?{pushCleanSolDynamic:!0}:null;if(this.Run=C33.EventBlock.prototype.RunAsFunctionCall.bind(this._callEventBlock,t,this._parameters,i,n),this._runtime.IsDebug()){const r=this;this.DebugRun=function*(){(r.IsBreakpoint()||r._runtime.DebugBreakNext())&&(yield r);const e=yield*r._callEventBlock.DebugRunAsFunctionCall(t,r._parameters,i,n);return e}}else this.DebugRun=noopGenerator}else this.Run=noop,this.DebugRun=noopGenerator}_SetCallCustomActionRunMethod(){const r=this._eventBlock.GetEventSheetManager(),a=r.GetCustomActionBlockByName(this._callCustomAceObjectClass,this._callFunctionName);if(a.IsEnabled()){const o=0!=(this._flags&FLAG_COPYPICKED);this._callEventBlock=a.GetEventBlock();let t=[...new Set([...this._eventBlock.GetSolModifiersIncludingParents(),...this._callEventBlock.GetSolModifiersIncludingParents(),this._objectClass,a.GetObjectClass()])],e=(t=r._DeduplicateSolModifierList(t),!this._objectClass.IsFamily()&&!a.GetObjectClass().IsFamily()),s=!this._objectClass.IsFamily()&&a.GetObjectClass().IsFamily(),i=this._objectClass.IsFamily(),n=null;if(!a.IsCopyPicked()&&this._HasCopyPickedParent()&&((n=n||{}).pushCleanSolDynamic=!0),!s&&o||((n=n||{}).copyFromObjectClass=this._objectClass,n.copyToObjectClass=a.GetObjectClass()),e||s||i&&!a.HasCustomACEOverrides()?this.Run=C33.EventBlock.prototype.RunAsFunctionCall.bind(this._callEventBlock,t,this._parameters,o,n):i&&(this.Run=C33.FunctionBlock.prototype.RunAsFamilyCustomActionWithOverrides.bind(a,t,this._parameters)),this._runtime.IsDebug()){const l=this;e||s||i&&!a.HasCustomACEOverrides()?this.DebugRun=function*(){(l.IsBreakpoint()||l._runtime.DebugBreakNext())&&(yield l);const e=yield*l._callEventBlock.DebugRunAsFunctionCall(t,l._parameters,o,n);return e}:i&&(this.DebugRun=function*(){(l.IsBreakpoint()||l._runtime.DebugBreakNext())&&(yield l);const e=yield*a.DebugRunAsFamilyCustomActionWithOverrides(t,l._parameters);return e})}else this.DebugRun=noopGenerator}else this.Run=noop,this.DebugRun=noopGenerator}_SetRunMethodForBoundFunc(e,t,s){const i=this._func,n=this._parameters;if(0===n.length)this.Run=e._GetBoundACEMethod(i,t);else if(1===n.length){const r=n[0];if(r.IsConstant())this.Run=e._GetBoundACEMethod_1param(i,t,r.Get(0));else{const a=e._GetBoundACEMethod(i,t);this.Run=function(){return a(r.Get(0))}}}else if(2===n.length){const o=n[0],l=n[1];if(o.IsConstant()&&l.IsConstant())this.Run=e._GetBoundACEMethod_2params(i,t,o.Get(0),l.Get(0));else{const h=e._GetBoundACEMethod(i,t);this.Run=function(){return h(o.Get(0),l.Get(0))}}}else if(3===n.length){const c=n[0],u=n[1],_=n[2];if(c.IsConstant()&&u.IsConstant()&&_.IsConstant())this.Run=e._GetBoundACEMethod_3params(i,t,c.Get(0),u.Get(0),_.Get(0));else{const d=e._GetBoundACEMethod(i,t);this.Run=function(){return d(c.Get(0),u.Get(0),_.Get(0))}}}else this.Run=s}GetSID(){return this._sid}IsAsync(){return 0!=(this._flags&FLAG_IS_ASYNC)}CanBailOut(){return 0!=(this._flags&FLAG_CAN_BAIL_OUT)}CallBeforeAfterHooks(){return 1===this._actionType}IsStatic(){return 2===this._actionType}CanPickAnyObjectClass(){return 0!=(this._flags&FLAG_CANPICKANYOBJECTCLASS)}HasReturnType(){return this.IsAsync()||this.CanBailOut()}GetObjectClass(){return this._objectClass}GetImplementationAddon(){return this._behaviorType?this._behaviorType.GetBehavior():this._objectClass?this._objectClass.GetPlugin():null}GetImplementationSdkVersion(){const e=this.GetImplementationAddon();return e?e.GetSdkVersion():1}GetEventBlock(){return this._eventBlock}_HasCopyPickedParent(){let e=this._eventBlock;do{if(e instanceof C33.FunctionBlock&&e.IsCopyPicked())return!0}while(e=e.GetScopeParent());return!1}GetRuntime(){return this._runtime}GetIndex(){return this._index}GetDebugIndex(){return this._debugData.index}IsBreakpoint(){return this._debugData.isBreakpoint}_SetBreakpoint(e){this._debugData.isBreakpoint=!!e,this._eventBlock._UpdateCanRunFastRecursive()}_DebugReturnsGenerator(){return this._debugData.canDebug}DebugCanRunFast(){return!this.IsBreakpoint()&&!this._runtime.DebugBreakNext()&&!this._DebugReturnsGenerator()}GetSavedDataMap(){return this._savedData||(this._savedData=new Map),this._savedData}GetUnsavedDataMap(){return this._unsavedData||(this._unsavedData=new Map),this._unsavedData}_RunSystem(){const e=this._results;return EvalParams2(this._parameters,e),this._func.apply(this._systemPlugin,e)}*_DebugRunSystem(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const e=this._results,t=(EvalParams2(this._parameters,e),yield*this._func.apply(this._systemPlugin,e));return t}return this.Run()}_RunSingleGlobal(){const e=this._results;return EvalParams2(this._parameters,e),this._func.apply(this._objectClass.GetSingleGlobalInstance().GetSdkInstance(),e)}*_DebugRunSingleGlobal(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const e=this._results,t=(EvalParams2(this._parameters,e),yield*this._func.apply(this._objectClass.GetSingleGlobalInstance().GetSdkInstance(),e));return t}return this.Run()}_RunObject_ParamsConst(){const s=this._results,i=this._objectClass.GetCurrentSol().GetInstances();for(let e=0,t=i.length;e<t;++e)this._func.apply(i[e].GetSdkInstance(),s)}*_DebugRunObject_ParamsConst(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const s=this._results,i=this._objectClass.GetCurrentSol().GetInstances();for(let e=0,t=i.length;e<t;++e)yield*this._func.apply(i[e].GetSdkInstance(),s)}else this._RunObject_ParamsConst()}_RunObject_ParamsDontVary(){const s=this._results,i=(EvalParams2(this._parameters,s),this._objectClass.GetCurrentSol().GetInstances());for(let e=0,t=i.length;e<t;++e)this._func.apply(i[e].GetSdkInstance(),s)}*_DebugRunObject_ParamsDontVary(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const s=this._results,i=(EvalParams2(this._parameters,s),this._objectClass.GetCurrentSol().GetInstances());for(let e=0,t=i.length;e<t;++e)yield*this._func.apply(i[e].GetSdkInstance(),s)}else this._RunObject_ParamsDontVary()}_RunObject_AllParamsVary(){const i=this._parameters,n=this._results,t=this._func,r=this._objectClass.GetCurrentSol().GetInstances();for(let s=0,e=r.length;s<e;++s){const a=r[s];for(let e=0,t=i.length;e<t;++e)n[e]=i[e].Get(s);t.apply(a.GetSdkInstance(),n)}}*_DebugRunObject_AllParamsVary(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const i=this._parameters,n=this._results,t=this._func,r=this._objectClass.GetCurrentSol().GetInstances();for(let s=0,e=r.length;s<e;++s){const a=r[s];for(let e=0,t=i.length;e<t;++e)n[e]=i[e].Get(s);yield*t.apply(a.GetSdkInstance(),n)}}else this._RunObject_AllParamsVary()}_RunObject_SomeParamsVary(){const i=this._parameters,n=this._results,t=this._func,r=this._objectClass.GetCurrentSol().GetInstances();for(let e=0,t=i.length;e<t;++e){const s=i[e];s.VariesPerInstance()||(n[e]=s.Get(0))}for(let s=0,e=r.length;s<e;++s){const a=r[s];for(let e=0,t=i.length;e<t;++e){const o=i[e];o.VariesPerInstance()&&(n[e]=o.Get(s))}t.apply(a.GetSdkInstance(),n)}}*_DebugRunObject_SomeParamsVary(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const i=this._parameters,n=this._results,t=this._func,r=this._objectClass.GetCurrentSol().GetInstances();for(let e=0,t=i.length;e<t;++e){const s=i[e];s.VariesPerInstance()||(n[e]=s.Get(0))}for(let s=0,e=r.length;s<e;++s){const a=r[s];for(let e=0,t=i.length;e<t;++e){const o=i[e];o.VariesPerInstance()&&(n[e]=o.Get(s))}yield*t.apply(a.GetSdkInstance(),n)}}else this._RunObject_SomeParamsVary()}_RunObject_BeforeAfterHooks(){const i=this._parameters,n=this._results,t=this._func,e=this._objectClass,s=e.GetSdkType(),r=e.GetCurrentSol().GetInstances();s.BeforeRunAction(t);for(let s=0,e=r.length;s<e;++s){const a=r[s];for(let e=0,t=i.length;e<t;++e)n[e]=i[e].Get(s);t.apply(a.GetSdkInstance(),n)}s.AfterRunAction(t)}*_DebugRunObject_BeforeAfterHooks(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const i=this._parameters,n=this._results,t=this._func,e=this._objectClass,s=e.GetSdkType(),r=e.GetCurrentSol().GetInstances();s.BeforeRunAction(t);for(let s=0,e=r.length;s<e;++s){const a=r[s];for(let e=0,t=i.length;e<t;++e)n[e]=i[e].Get(s);yield*t.apply(a.GetSdkInstance(),n)}s.AfterRunAction(t)}else this._RunObject_BeforeAfterHooks()}_GetStaticActionThis(){return this._behaviorType?2<=this._behaviorType.GetBehavior().GetSdkVersion()?this._behaviorType.GetIBehaviorType():this._behaviorType:2<=this._objectClass.GetPlugin().GetSdkVersion()?this._objectClass.GetIObjectClass():this._objectClass}_RunObject_Static(){const e=this._results;return EvalParams2(this._parameters,e),this._func.apply(this._GetStaticActionThis(),e)}*_DebugRunObject_Static(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const t=this._results;EvalParams2(this._parameters,t);let e=this._func.apply(this._GetStaticActionThis(),t);return C33.IsIterator(e)?yield*e:e}return this._RunObject_Static()}_RunBehavior(){const e=this._objectClass,t=e.IsFamily(),i=e.GetFamilyIndex(),n=this._parameters,r=this._anyParamVariesPerInstance,a=this._results,o=this._func,l=this._behaviorIndex,h=e.GetCurrentSol().GetInstances();for(let e=0,t=n.length;e<t;++e){const s=n[e];s.VariesPerInstance()||(a[e]=s.Get(0))}for(let s=0,e=h.length;s<e;++s){const c=h[s];if(r)for(let e=0,t=n.length;e<t;++e){const _=n[e];_.VariesPerInstance()&&(a[e]=_.Get(s))}const u=t?c.GetObjectClass().GetFamilyBehaviorOffset(i):0;o.apply(c.GetBehaviorInstances()[l+u].GetSdkInstance(),a)}}*_DebugRunBehavior(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const e=this._objectClass,t=e.IsFamily(),i=e.GetFamilyIndex(),n=this._parameters,r=this._anyParamVariesPerInstance,a=this._results,o=this._func,l=this._behaviorIndex,h=e.GetCurrentSol().GetInstances();for(let e=0,t=n.length;e<t;++e){const s=n[e];s.VariesPerInstance()||(a[e]=s.Get(0))}for(let s=0,e=h.length;s<e;++s){const c=h[s];if(r)for(let e=0,t=n.length;e<t;++e){const _=n[e];_.VariesPerInstance()&&(a[e]=_.Get(s))}const u=t?c.GetObjectClass().GetFamilyBehaviorOffset(i):0;yield*o.apply(c.GetBehaviorInstances()[l+u].GetSdkInstance(),a)}}else this._RunBehavior()}_RunObject_Async(){const i=this._parameters,n=this._results,t=this._func,r=this._objectClass.GetCurrentSol().GetInstances(),a=[];for(let s=0,e=r.length;s<e;++s){const o=r[s];for(let e=0,t=i.length;e<t;++e)n[e]=i[e].Get(s);a.push(t.apply(o.GetSdkInstance(),n))}return Promise.all(a)}*_DebugRunObject_Async(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const i=this._parameters,n=this._results,t=this._func,r=this._objectClass.GetCurrentSol().GetInstances(),a=[];for(let s=0,e=r.length;s<e;++s){const o=r[s];for(let e=0,t=i.length;e<t;++e)n[e]=i[e].Get(s);a.push(yield*t.apply(o.GetSdkInstance(),n))}return Promise.all(a)}return this._RunObject_Async()}_RunBehavior_Async(){const e=this._objectClass,t=e.IsFamily(),i=e.GetFamilyIndex(),n=this._parameters,r=this._results,a=this._func,o=this._behaviorIndex,l=e.GetCurrentSol().GetInstances(),h=[];for(let s=0,e=l.length;s<e;++s){const c=l[s];for(let e=0,t=n.length;e<t;++e)r[e]=n[e].Get(s);const u=t?c.GetObjectClass().GetFamilyBehaviorOffset(i):0;h.push(a.apply(c.GetBehaviorInstances()[o+u].GetSdkInstance(),r))}return Promise.all(h)}*_DebugRunBehavior_Async(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const e=this._objectClass,t=e.IsFamily(),i=e.GetFamilyIndex(),n=this._parameters,r=this._results,a=this._func,o=this._behaviorIndex,l=e.GetCurrentSol().GetInstances(),h=[];for(let s=0,e=l.length;s<e;++s){const c=l[s];for(let e=0,t=n.length;e<t;++e)r[e]=n[e].Get(s);const u=t?c.GetObjectClass().GetFamilyBehaviorOffset(i):0;h.push(yield*a.apply(c.GetBehaviorInstances()[o+u].GetSdkInstance(),r))}return Promise.all(h)}return this._RunBehavior_Async()}async RunUserScript(){try{await this._func()}catch(e){console.error(`Unhandled exception running script %c${this._eventBlock.GetEventSheet().GetName()}, event ${this._eventBlock.GetDisplayNumber()}, action ${this.GetDebugIndex()+1}:`,"font-size: 1.2em; font-weight: bold;",e),self.C3Debugger&&self.C3Debugger._SetLastErrorScript(this),C33.EventScript.HadUserScriptException()||(console.info("%cTip:%c run this to highlight in Construct the last script that had an error: %cgoToLastErrorScript()","font-weight: bold; text-decoration: underline","","font-weight: bold"),C33.EventScript.SetHadUserScriptException())}}*DebugRunUserScript(){return(this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this.RunUserScript()}_SaveToJson(){return this._savedData&&this._savedData.size?{ex:C33.ToSuperJSON(this._savedData)}:null}_LoadFromJson(e){if(this._savedData&&(this._savedData.clear(),this._savedData=null),e){const t=e.ex;t&&(this._savedData=C33.FromSuperJSON(t))}}}}{let GetInst2=function(e){return e instanceof IInstance?runtime._UnwrapScriptInterface(e):e.GetInstance()},GetWorldInfo2=function(e){return GetInst2(e).GetWorldInfo()},GetInst_SDKv22=function(e){return runtime._UnwrapScriptInterface(e)},GetWorldInfo_SDKv22=function(e){return GetInst_SDKv22(e).GetWorldInfo()},GetObjectClass2=function(e){return e instanceof IObjectClass?runtime._UnwrapScriptInterface(e):e},GetLayer2=function(e){return e instanceof ILayer?runtime._UnwrapScriptInterface(e):e},CollMemory_Add2=function(e,t,s,i){const n=t.GetUID(),r=s.GetUID();n<r?e.Set(t,s,i):e.Set(s,t,i)},CollMemory_Remove2=function(e,t,s){const i=t.GetUID(),n=s.GetUID();i<n?e.Delete(t,s):e.Delete(s,t)},CollMemory_RemoveInstance2=function(e,t){e.DeleteEither(t)},CollMemory_Get2=function(e,t,s){const i=t.GetUID(),n=s.GetUID();return i<n?e.Get(t,s):e.Get(s,t)},DoOverlapCondition2=function(e,t,s,i){if(!t)return!1;const n=0!==s||0!==i,r=e.GetWorldInfo(),a=runtime.GetCollisionEngine(),o=runtime.GetCurrentCondition(),l=o.GetEventBlock().IsOrBlock(),h=o.GetObjectClass(),c=o.IsInverted(),u=t.GetCurrentSol(),_=h!==t;rPickType=t,needsCollisionFinish=_&&!c;let d,p=0,m=0,g=rPickFromElseInstances=!1;u.IsSelectAll()?(tempRect.copy(r.GetBoundingBox()),tempRect.offset(s,i),a.GetCollisionCandidates(r.GetLayer(),t,tempRect,tempCandidates2),d=tempCandidates2):!l||runtime.IsCurrentConditionFirst()&&!u._GetOwnElseInstances().length&&u._GetOwnInstances().length?d=u._GetOwnInstances():(d=u._GetOwnElseInstances(),rPickFromElseInstances=!0),n&&(p=r.GetX(),m=r.GetY(),r.OffsetXY(s,i),r.SetBboxChanged());for(const f of d)if(a.TestOverlap(e,f)){if(g=!0,c)break;_&&rToPick.add(f)}return n&&(r.SetXY(p,m),r.SetBboxChanged()),C33.clearArray(tempCandidates2),g},FinishCollisionConditionPicking2=function(e){const t=runtime.GetCurrentEvent().IsOrBlock(),s=rPickType.GetCurrentSol(),i=s._GetOwnInstances(),n=s._GetOwnElseInstances();s.IsSelectAll()?(s.SetSetPicked(rToPick),t&&(C33.clearArray(n),s.AddElseInstances(rToPick,rPickType.GetInstances()))):t?rPickFromElseInstances?s.TransferElseInstancesToOwn(rToPick):(s.AddElseInstances(rToPick,i),s.SetSetPicked(rToPick)):s.SetSetPicked(rToPick),rPickType.ApplySolToContainer()},FinishCollisionCondition2=function(e,t){needsCollisionFinish&&(t&&FinishCollisionConditionPicking2(e),rToPick.clear(),rPickType=null,needsCollisionFinish=!1)},PickByUID_Normal2=function(e,t){const s=runtime.GetInstanceByUID(t);if(s){const i=e.GetCurrentSol();if(i.IsSelectAll()||i._GetOwnInstances().includes(s))if(e.IsFamily()){if(s.GetObjectClass().BelongsToFamily(e))return i.PickOne(s),e.ApplySolToContainer(),!0}else if(s.GetObjectClass()===e)return i.PickOne(s),e.ApplySolToContainer(),!0}return!1},PickByUID_Inverted2=function(e,n){const r=e.GetCurrentSol();if(r.IsSelectAll()){r._SetSelectAll(!1),r.ClearArrays();const s=e.GetInstances();for(let e=0,t=s.length;e<t;++e){const i=s[e];i.GetUID()===n?r._PushElseInstance(i):r._PushInstance(i)}return e.ApplySolToContainer(),!!r._GetOwnInstances().length}{let s=r._GetOwnInstances(),i=0;for(let e=0,t=s.length;e<t;++e){const a=s[e];(s[i]=a).GetUID()===n?r._PushElseInstance(a):++i}return C33.truncateArray(s,i),e.ApplySolToContainer(),!!s.length}},C33=(GetInst=GetInst2,GetWorldInfo=GetWorldInfo2,GetInst_SDKv2=GetInst_SDKv22,GetWorldInfo_SDKv2=GetWorldInfo_SDKv22,GetObjectClass=GetObjectClass2,GetLayer=GetLayer2,CollMemory_Add=CollMemory_Add2,CollMemory_Remove=CollMemory_Remove2,CollMemory_RemoveInstance=CollMemory_RemoveInstance2,CollMemory_Get=CollMemory_Get2,DoOverlapCondition=DoOverlapCondition2,FinishCollisionConditionPicking=FinishCollisionConditionPicking2,FinishCollisionCondition=FinishCollisionCondition2,PickByUID_Normal=PickByUID_Normal2,PickByUID_Inverted=PickByUID_Inverted2,self.C3),tempColor=new C33.Color,AnySDK={},SDKv1={},SDKv2={},runtime=null,IInstance=(C33.CommonACES_SetRuntime=function(e){runtime=e},self.IInstance),IObjectClass=self.IObjectClass,ILayer=self.ILayer,tempRect=(SDKv1.CompareX=function(e,t){return C33.compare(this.GetWorldInfo().GetX(),e,t)},SDKv2.CompareX=function(e,t){return C33.compare(this.x,e,t)},SDKv1.CompareY=function(e,t){return C33.compare(this.GetWorldInfo().GetY(),e,t)},SDKv2.CompareY=function(e,t){return C33.compare(this.y,e,t)},SDKv1.IsOnScreen=function(){return this.GetWorldInfo().IsInViewport2()},SDKv2.IsOnScreen=function(){return this.isOnScreen()},AnySDK.IsOutsideLayout=function(){const e=GetWorldInfo2(this),t=e.GetLayout(),s=e.GetBoundingBox();return s.getRight()<0||s.getBottom()<0||s.getLeft()>t.GetWidth()||s.getTop()>t.GetHeight()},AnySDK.PickDistance=function(s,i,n){const e=GetObjectClass2(this),t=e.GetCurrentSol(),r=t.GetInstances();if(!r.length)return!1;let a=r[0],o=a.GetWorldInfo(),l=a,h=C33.distanceSquared(o.GetX(),o.GetY(),i,n);for(let e=1,t=r.length;e<t;++e){a=r[e],o=a.GetWorldInfo();const c=C33.distanceSquared(o.GetX(),o.GetY(),i,n);(0===s&&c<h||1===s&&c>h)&&(h=c,l=a)}return t.PickOne(l),!0},SDKv1.SetX=function(e){const t=this.GetWorldInfo();t.GetX()!==e&&(t.SetX(e),t.SetBboxChanged())},SDKv2.SetX=function(e){this.x=+e},SDKv1.SetY=function(e){const t=this.GetWorldInfo();t.GetY()!==e&&(t.SetY(e),t.SetBboxChanged())},SDKv2.SetY=function(e){this.y=+e},SDKv1.SetPos=function(e,t){const s=this.GetWorldInfo();s.EqualsXY(e,t)||(s.SetXY(e,t),s.SetBboxChanged())},SDKv2.SetPos=function(e,t){this.setPosition(e,t)},AnySDK.SetPosToObject=function(e,t){if(e=GetObjectClass2(e)){const s=GetInst2(this),i=e.GetPairedInstance(s);if(i){const[n,r]=i.GetImagePoint(t),a=s.GetWorldInfo();a.GetX()===n&&a.GetY()===r||(a.SetXY(n,r),a.SetBboxChanged())}}},AnySDK.MoveForward=function(e){if(0!==e){const t=GetWorldInfo2(this);t.OffsetXY(t.GetCosAngle()*e,t.GetSinAngle()*e),t.SetBboxChanged()}},SDKv1.MoveAtAngle=function(e,t){if(0!==t){const s=this.GetWorldInfo();e=C33.toRadians(e),s.OffsetXY(Math.cos(e)*t,Math.sin(e)*t),s.SetBboxChanged()}},SDKv2.MoveAtAngle=function(e,t){0!==t&&(e=C33.toRadians(e),this.offsetPosition(Math.cos(e)*t,Math.sin(e)*t))},SDKv1.GetX=function(){return this.GetWorldInfo().GetX()},SDKv2.GetX=function(){return this.x},SDKv1.GetY=function(){return this.GetWorldInfo().GetY()},SDKv2.GetY=function(){return this.y},AnySDK.GetDt=function(){return runtime.GetDt(GetInst2(this))},SDKv1.CompareWidth=function(e,t){return C33.compare(this.GetWorldInfo().GetWidth(),e,t)},SDKv2.CompareWidth=function(e,t){return C33.compare(this.width,e,t)},SDKv1.CompareHeight=function(e,t){return C33.compare(this.GetWorldInfo().GetHeight(),e,t)},SDKv2.CompareHeight=function(e,t){return C33.compare(this.height,e,t)},SDKv1.SetWidth=function(e){const t=this.GetWorldInfo();t.GetWidth()!==e&&(t.SetWidth(e),t.SetBboxChanged())},SDKv2.SetWidth=function(e){this.width=e},SDKv1.SetHeight=function(e){const t=this.GetWorldInfo();t.GetHeight()!==e&&(t.SetHeight(e),t.SetBboxChanged())},SDKv2.SetHeight=function(e){this.height=e},SDKv1.SetSize=function(e,t){const s=GetWorldInfo2(this);s.GetWidth()===e&&s.GetHeight()===t||(s.SetSize(e,t),s.SetBboxChanged())},SDKv2.SetSize=function(e,t){this.setSize(e,t)},SDKv1.GetWidth=function(){return this.GetWorldInfo().GetWidth()},SDKv2.GetWidth=function(){return this.width},SDKv1.GetHeight=function(){return this.GetWorldInfo().GetHeight()},SDKv2.GetHeight=function(){return this.height},AnySDK.GetBboxLeft=function(){return GetWorldInfo2(this).GetBoundingBox().getLeft()},AnySDK.GetBboxTop=function(){return GetWorldInfo2(this).GetBoundingBox().getTop()},AnySDK.GetBboxRight=function(){return GetWorldInfo2(this).GetBoundingBox().getRight()},AnySDK.GetBboxBottom=function(){return GetWorldInfo2(this).GetBoundingBox().getBottom()},AnySDK.GetBboxMidX=function(){const e=GetWorldInfo2(this).GetBoundingBox();return(e.getLeft()+e.getRight())/2},AnySDK.GetBboxMidY=function(){const e=GetWorldInfo2(this).GetBoundingBox();return(e.getTop()+e.getBottom())/2},AnySDK.IsAngleWithin=function(e,t){return C33.angleDiff(GetWorldInfo2(this).GetAngle(),C33.toRadians(t))<=C33.toRadians(e)},AnySDK.IsAngleClockwiseFrom=function(e){return C33.angleClockwise(GetWorldInfo2(this).GetAngle(),C33.toRadians(e))},AnySDK.IsBetweenAngles=function(e,t){const s=C33.toRadians(e),i=C33.toRadians(t),n=GetWorldInfo2(this).GetAngle(),r=!C33.angleClockwise(i,s);return r?!(!C33.angleClockwise(n,s)&&C33.angleClockwise(n,i)):C33.angleClockwise(n,s)&&!C33.angleClockwise(n,i)},SDKv1.SetAngle=function(e){const t=this.GetWorldInfo(),s=C33.clampAngle(C33.toRadians(e));isNaN(s)||t.GetAngle()===s||(t.SetAngle(s),t.SetBboxChanged())},SDKv2.SetAngle=function(e){this.angleDegrees=e},AnySDK.RotateClockwise=function(e){if(!isNaN(e)&&0!==e){const t=GetWorldInfo2(this);t.SetAngle(t.GetAngle()+C33.toRadians(e)),t.SetBboxChanged()}},AnySDK.RotateCounterclockwise=function(e){if(!isNaN(e)&&0!==e){const t=GetWorldInfo2(this);t.SetAngle(t.GetAngle()-C33.toRadians(e)),t.SetBboxChanged()}},AnySDK.RotateTowardAngle=function(e,t){const s=GetWorldInfo2(this),i=s.GetAngle(),n=C33.angleRotate(i,C33.toRadians(t),C33.toRadians(e));isNaN(n)||i===n||(s.SetAngle(n),s.SetBboxChanged())},AnySDK.RotateTowardPosition=function(e,t,s){const i=GetWorldInfo2(this),n=i.GetAngle(),r=t-i.GetX(),a=s-i.GetY(),o=Math.atan2(a,r),l=C33.angleRotate(n,o,C33.toRadians(e));isNaN(l)||n===l||(i.SetAngle(l),i.SetBboxChanged())},AnySDK.SetTowardPosition=function(e,t){const s=GetWorldInfo2(this),i=s.GetAngle(),n=e-s.GetX(),r=t-s.GetY(),a=Math.atan2(r,n);isNaN(a)||i===a||(s.SetAngle(a),s.SetBboxChanged())},SDKv1.GetAngle=function(){return C33.toDegrees(this.GetWorldInfo().GetAngle())},SDKv2.GetAngle=function(){return this.angleDegrees},AnySDK.CompareOpacity=function(e,t){return C33.compare(C33.roundToDp(100*GetWorldInfo2(this).GetOpacity(),6),e,t)},SDKv1.IsVisible=function(){return this.GetWorldInfo().IsVisible()},SDKv2.IsVisible=function(){return this.isVisible},AnySDK.SetVisible=function(e){const t=GetWorldInfo2(this);e=2===e?!t.IsVisible():0!==e,t.IsVisible()!==e&&(t.SetVisible(e),runtime.UpdateRender())},AnySDK.SetOpacity=function(e){const t=C33.clamp(e/100,0,1),s=GetWorldInfo2(this);if(s.GetTransformWithParentOpacity()){if(s._GetSceneGraphInfo().GetOwnOpacity()===t)return}else if(s.GetOpacity()===t)return;s.SetOpacity(t),runtime.UpdateRender()},AnySDK.SetDefaultColor=function(e){tempColor.setFromRgbValue(e);const t=GetWorldInfo2(this);t.GetUnpremultipliedColor().equalsIgnoringAlpha(tempColor)||(t.SetUnpremultipliedColor(tempColor),runtime.UpdateRender())},AnySDK.GetColor=function(){const e=GetWorldInfo2(this).GetUnpremultipliedColor();return C33.PackRGBAEx(e.getR(),e.getG(),e.getB(),e.getA())},AnySDK.GetOpacity=function(){return C33.roundToDp(100*GetWorldInfo2(this).GetOpacity(),6)},AnySDK.IsOnLayer=function(e){return!!(e=GetLayer2(e))&&GetWorldInfo2(this).GetLayer()===e},AnySDK.PickTopBottom=function(s){const e=GetObjectClass2(this),t=e.GetCurrentSol(),i=t.GetInstances();if(!i.length)return!1;let n=i[0],r=n;for(let e=1,t=i.length;e<t;++e){const a=i[e],o=a.GetWorldInfo(),l=r.GetWorldInfo(),h=o.GetLayer().GetIndex(),c=l.GetLayer().GetIndex();0===s?(c<h||h===c&&o.GetZIndex()>l.GetZIndex())&&(r=a):(h<c||h===c&&o.GetZIndex()<l.GetZIndex())&&(r=a)}return t.PickOne(r),!0},SDKv1.CompareZElevation=function(e,t,s){const i=this.GetWorldInfo(),n=0===e?i.GetZElevation():i.GetTotalZElevation();return C33.compare(n,t,s)},SDKv2.CompareZElevation=function(e,t,s){const i=0===e?this.zElevation:this.totalZElevation;return C33.compare(i,t,s)},SDKv1.MoveToTop=function(){this.GetWorldInfo().ZOrderMoveToTop()},SDKv2.MoveToTop=function(){this.moveToTop()},SDKv1.MoveToBottom=function(){this.GetWorldInfo().ZOrderMoveToBottom()},SDKv2.MoveToBottom=function(){this.moveToBottom()},AnySDK.MoveToLayer=function(e){(e=GetLayer2(e))&&GetWorldInfo2(this).ZOrderMoveToLayer(e)},AnySDK.ZMoveToObject=function(e,t){const s=0===e;if(t=GetObjectClass2(t)){const i=GetInst2(this),n=t.GetFirstPicked(i);n&&i.GetWorldInfo().ZOrderMoveAdjacentToInstance(n,s)}},SDKv1.SetZElevation=function(e){const t=this.GetWorldInfo();t.GetZElevation()!==e&&(t.SetZElevation(e),runtime.UpdateRender())},SDKv2.SetZElevation=function(e){this.zElevation=e},AnySDK.LayerNumber=function(){return GetWorldInfo2(this).GetLayer().GetIndex()},AnySDK.LayerName=function(){return GetWorldInfo2(this).GetLayer().GetName()},SDKv1.ZIndex=function(){return this.GetWorldInfo().GetZIndex()},SDKv2.ZIndex=function(){return this.zIndex},SDKv1.ZElevation=function(){return this.GetWorldInfo().GetZElevation()},SDKv2.ZElevation=function(){return this.zElevation},SDKv1.TotalZElevation=function(){return this.GetWorldInfo().GetTotalZElevation()},SDKv2.TotalZElevation=function(){return this.totalZElevation},AnySDK.IsEffectEnabled=function(e){const t=GetInst2(this),s=t.GetObjectClass().GetEffectList().GetEffectTypeByName(e);if(s){const i=s.GetIndex(),n=t.GetWorldInfo().GetInstanceEffectList();return n.IsEffectIndexActive(i)}},AnySDK.SetEffectEnabled=function(e,t){const s=GetInst2(this),i=s.GetObjectClass().GetEffectList().GetEffectTypeByName(t);if(i){const n=i.GetIndex(),r=1===e,a=s.GetWorldInfo().GetInstanceEffectList();a.IsEffectIndexActive(n)!==r&&(a.SetEffectIndexActive(n,r),a.UpdateActiveEffects(),runtime.UpdateRender())}},AnySDK.SetEffectParam=function(e,t,s){const i=GetInst2(this),n=i.GetObjectClass().GetEffectList().GetEffectTypeByName(e);if(n){t=Math.floor(t);const r=n.GetShaderProgram().GetParameterType(t);if(r){"color"===r?(tempColor.setFromRgbValue(s),s=tempColor):"percent"===r&&(s/=100);const a=n.GetIndex(),o=i.GetWorldInfo().GetInstanceEffectList(),l=o.SetEffectParameter(a,t,s);l&&o.IsEffectIndexActive(a)&&runtime.UpdateRender()}}},C33.New(C33.Rect)),tempCandidates1=[],tempCandidates2=[],needsCollisionFinish=!1,rPickType=null,rPickFromElseInstances=!1,rToPick=new Set;function*DebugOnCollision(S){if(S){let e=this.GetRuntime(),t=e.GetCollisionEngine(),i=e.GetEventSheetManager(),s=i.GetEventStack(),n=i.GetCurrentCondition(),r=n.GetObjectClass(),a=n.GetSavedDataMap(),o=n.GetUnsavedDataMap(),l=s.GetCurrentStackFrame(),h=e.GetTickCount(),c=h-1,u=l.GetCurrentEvent(),_=s.Push(u),d=a.get("collmemory"),p=(d||(d=C33.New(C33.PairMap),a.set("collmemory",d)),o.get("collisionCreatedDestroyCallback")||(o.set("collisionCreatedDestroyCallback",!0),e.Dispatcher().addEventListener("instancedestroy",e=>CollMemory_RemoveInstance2(d,e.instance))),r.GetCurrentSol()),m=S.GetCurrentSol(),g=p.GetInstances(),f=null;for(let e=0;e<g.length;++e){const C=g[e];m.IsSelectAll()?(t.GetCollisionCandidates(C.GetWorldInfo().GetLayer(),S,C.GetWorldInfo().GetBoundingBox(),tempCandidates1),f=tempCandidates1,t.AddRegisteredCollisionCandidates(C,S,f)):f=m.GetInstances();for(let e=0;e<f.length;++e){const y=f[e];if(t.TestOverlap(C,y)||t.CheckRegisteredCollision(C,y)){let e=CollMemory_Get2(d,C,y),t=!1,s=-2;"number"==typeof e&&(t=!0,s=e);const G=!t||s<c;if(CollMemory_Add2(d,C,y,h),G){const I=u.GetSolModifiers(),T=(i.PushCopySol(I),r.GetCurrentSol()),b=S.GetCurrentSol();if(T._SetSelectAll(!1),b._SetSelectAll(!1),r===S){const P=T._GetOwnInstances();C33.clearArray(P),P.push(C),P.push(y),r.ApplySolToContainer()}else{const A=T._GetOwnInstances(),R=b._GetOwnInstances();C33.clearArray(A),C33.clearArray(R),A.push(C),R.push(y),r.ApplySolToContainer(),S.ApplySolToContainer()}yield*u.DebugRetrigger(l,_),i.PopSol(I)}}else CollMemory_Remove2(d,C,y)}C33.clearArray(tempCandidates1)}s.Pop()}return!1}AnySDK.OnCollision=function(f){const e=GetObjectClass2(this),S=(f=GetObjectClass2(f),e.GetRuntime());if(S.IsDebugging())return DebugOnCollision.call(e,f);if(f){let t=S.GetCollisionEngine(),i=S.GetEventSheetManager(),e=i.GetEventStack(),s=i.GetCurrentCondition(),n=s.GetObjectClass(),r=s.GetSavedDataMap(),a=s.GetUnsavedDataMap(),o=e.GetCurrentStackFrame(),l=S.GetTickCount(),h=l-1,c=o.GetCurrentEvent(),u=e.Push(c),_=r.get("collmemory"),d=(_||(_=C33.New(C33.PairMap),r.set("collmemory",_)),a.get("collisionCreatedDestroyCallback")||(a.set("collisionCreatedDestroyCallback",!0),S.Dispatcher().addEventListener("instancedestroy",e=>CollMemory_RemoveInstance2(_,e.instance))),n.GetCurrentSol()),p=f.GetCurrentSol(),m=d.GetInstances(),g=null;for(let e=0;e<m.length;++e){const C=m[e];p.IsSelectAll()?(t.GetCollisionCandidates(C.GetWorldInfo().GetLayer(),f,C.GetWorldInfo().GetBoundingBox(),tempCandidates1),g=tempCandidates1,t.AddRegisteredCollisionCandidates(C,f,g)):g=p.GetInstances();for(let e=0;e<g.length;++e){const y=g[e];if(t.TestOverlap(C,y)||t.CheckRegisteredCollision(C,y)){let e=CollMemory_Get2(_,C,y),t=!1,s=-2;"number"==typeof e&&(t=!0,s=e);const G=!t||s<h;if(CollMemory_Add2(_,C,y,l),G){const I=c.GetSolModifiers(),T=(i.PushCopySol(I),n.GetCurrentSol()),b=f.GetCurrentSol();if(T._SetSelectAll(!1),b._SetSelectAll(!1),n===f){const P=T._GetOwnInstances();C33.clearArray(P),P.push(C),P.push(y),n.ApplySolToContainer()}else{const A=T._GetOwnInstances(),R=b._GetOwnInstances();C33.clearArray(A),C33.clearArray(R),A.push(C),R.push(y),n.ApplySolToContainer(),f.ApplySolToContainer()}c.Retrigger(o,u),i.PopSol(I)}}else CollMemory_Remove2(_,C,y)}C33.clearArray(tempCandidates1)}e.Pop()}return!1},AnySDK.IsOverlapping=function(e){return e=GetObjectClass2(e),DoOverlapCondition2(GetInst2(this),e,0,0)},AnySDK.IsOverlappingOffset=function(e,t,s){return e=GetObjectClass2(e),DoOverlapCondition2(GetInst2(this),e,t,s)},AnySDK.OnHierarchyReady=function(){return!0},AnySDK.HasParent=function(){return GetWorldInfo2(this).HasParent()},AnySDK.HasChildren=function(){return GetWorldInfo2(this).HasChildren()},AnySDK.PickParent=function(s,i){const e=GetObjectClass2(this),t=(s=GetObjectClass2(s),e.GetRuntime()),n=this.GetCurrentSol(),r=n.GetInstances();if(0===r.length)return!1;let a=s.GetCurrentSol(),o=a.GetInstances();if(a.IsSelectAll()){const c=[...t.instancesPendingCreateForObjectClass(s)];0<c.length&&(o=o.concat(c))}if(0===o.length)return!1;const l=a.IsSelectAll()?null:new Set(o),h=new Set;for(let e=0,t=r.length;e<t;++e){const u=r[e];if(1===i)for(const _ of u.parents())_.BelongsToObjectClass(s)&&(null===l||l.has(_))&&h.add(_);else{let e;if(0===i){if(null===(e=u.GetParent()))continue}else e=u.GetTopParent();e.BelongsToObjectClass(s)&&(null===l||l.has(e))&&h.add(e)}}return 0!==h.size&&(a.SetSetPicked(h),s.ApplySolToContainer(),!0)},AnySDK.PickChildren=function(s,i){const e=GetObjectClass2(this),t=(s=GetObjectClass2(s),e.GetRuntime()),n=e.GetCurrentSol(),r=n.GetInstances();if(0===r.length)return!1;let a=s.GetCurrentSol(),o=a.GetInstances();if(a.IsSelectAll()){const c=[...t.instancesPendingCreateForObjectClass(s)];0<c.length&&(o=o.concat(c))}if(0===o.length)return!1;const l=a.IsSelectAll()?null:new Set(o),h=new Set;for(let e=0,t=r.length;e<t;++e){const u=r[e];2!==i||u.HasChildren()||!u.BelongsToObjectClass(s)||null!==l&&!l.has(u)||h.add(u);for(const _ of 0===i?u.children():u.allChildren())2===i&&_.HasChildren()||_.BelongsToObjectClass(s)&&(null===l||l.has(_))&&h.add(_)}return 0!==h.size&&(a.SetSetPicked(h),s.ApplySolToContainer(),!0)},AnySDK.PickNthChild=function(s,i,n){const e=GetObjectClass2(this),t=(s=GetObjectClass2(s),e.GetRuntime()),r=e.GetCurrentSol(),a=r.GetInstances();if(0===a.length)return!1;let o=s.GetCurrentSol(),l=o.GetInstances();if(o.IsSelectAll()){const u=[...t.instancesPendingCreateForObjectClass(s)];0<u.length&&(l=l.concat(u))}if(0===l.length)return!1;const h=o.IsSelectAll()?null:new Set(l),c=[];for(let e=0,t=a.length;e<t;++e){const _=a[e];if(0===i){const d=_.GetChildAt(n);null!==d&&d.BelongsToObjectClass(s)&&(null===h||h.has(d))&&c.push(d)}else if(1===i)for(const p of _.children())if(p.BelongsToObjectClass(s)){if(0===n){null!==h&&!h.has(p)||c.push(p);break}--n}}return 0!==c.length&&(o.SetArrayPicked(c),s.ApplySolToContainer(),!0)},AnySDK.CompareChildCount=function(e,t,s){const i=GetInst2(this);switch(e){case 0:default:return C33.compare(i.GetChildCount(),t,s);case 1:return C33.compare(i.GetAllChildCount(),t,s)}},AnySDK.AddChild=function(e,t,s,i,n,r,a,o,l,h){e=GetObjectClass2(e);const c=GetInst2(this),u=runtime.GetCurrentAction().GetObjectClass();for(const _ of e.allCorrespondingInstances(c,u)){if(!_.GetPlugin().SupportsSceneGraph())return;c.AddChild(_,{transformX:t,transformY:s,transformWidth:i,transformHeight:n,transformAngle:r,transformOpacity:a,transformZElevation:o,transformVisibility:l,destroyWithParent:h})}},AnySDK.RemoveChild=function(e){e=GetObjectClass2(e);const t=GetInst2(this),s=runtime.GetCurrentAction().GetObjectClass();for(const i of e.allCorrespondingInstances(t,s))t.RemoveChild(i)},AnySDK.RemoveFromParent=function(){const e=GetInst2(this);if(e.HasParent()){const t=e.GetParent();t.RemoveChild(e)}},AnySDK.ParentUID=function(){const e=GetInst2(this).GetParent();return e?e.GetUID():-1},AnySDK.ChildCount=function(){return GetInst2(this).GetChildCount()},AnySDK.AllChildCount=function(){return GetInst2(this).GetAllChildCount()},AnySDK.SetMeshSize=function(e,t){e=Math.floor(e),t=Math.floor(t);const s=GetWorldInfo2(this);e<2||t<2||!isFinite(e)||!isFinite(t)?(s.ReleaseMesh(),s.SetBboxChanged()):s.CreateMesh(e,t)},AnySDK.SetMeshPoint=function(e,t,s,i,n,r,a,o){const l=GetWorldInfo2(this),h=l.SetMeshPoint(e,t,{mode:0===s?"absolute":"relative",x:i,y:n,zElevation:r,u:a,v:o});h&&l.SetBboxChanged()},AnySDK.MeshColumns=function(){const e=GetWorldInfo2(this);return e.HasMesh()?e.GetSourceMesh().GetHSize():0},AnySDK.MeshRows=function(){const e=GetWorldInfo2(this);return e.HasMesh()?e.GetSourceMesh().GetVSize():0},AnySDK.SetElementVisible=function(e){const t=GetWorldInfo2(this);e=2===e?!t.IsVisible():0!==e,t.IsVisible()!==e&&t.SetVisible(e)},AnySDK.SetElementCSSStyle=function(e,t){this instanceof self.IInstance?this.setElementCSSStyle(e,t):this.SetElementCSSStyle(e,t)},AnySDK.SetElementAttribute=function(e,t){this instanceof self.IInstance?this.setElementAttribute(e,""+t):this.SetElementAttribute(e,""+t)},AnySDK.RemoveElementAttribute=function(e){this instanceof self.IInstance?this.removeElementAttribute(e):this.RemoveElementAttribute(e)},AnySDK.SetElementFocus=function(){this instanceof self.IInstance?this.focusElement():this.FocusElement()},AnySDK.SetElementBlur=function(){this instanceof self.IInstance?this.blurElement():this.BlurElement()},AnySDK.IsElementFocused=function(){return this instanceof self.IInstance?this.isElementFocused():this.IsElementFocused()},AnySDK.SetElementEnabled=function(e){this instanceof self.IInstance?this._setEnabled(0!==e):this._SetEnabled(0!==e)},AnySDK.IsElementEnabled=function(){return this instanceof self.IInstance?this._isEnabled():this._IsEnabled()},SDKv1.CompareInstanceVar=function(e,t,s){return C33.compare(this.GetInstance().GetInstanceVariableValue(e),t,s)},SDKv2.CompareInstanceVar=function(e,t,s){return C33.compare(GetInst_SDKv22(this).GetInstanceVariableValue(e),t,s)},SDKv1.IsBoolInstanceVarSet=function(e){return!!this.GetInstance().GetInstanceVariableValue(e)},SDKv2.IsBoolInstanceVarSet=function(e){return!!GetInst_SDKv22(this).GetInstanceVariableValue(e)},AnySDK.PickInstVarHiLow=function(s,i){const n=GetObjectClass2(this),e=n.GetCurrentSol(),r=e.GetInstances();if(!r.length)return!1;let a=n.IsFamily(),o=null,l=0;for(let e=0,t=r.length;e<t;++e){const h=r[e],c=a?h.GetObjectClass().GetFamilyInstanceVariableOffset(n.GetFamilyIndex()):0,u=h.GetInstanceVariableValue(c+i);(null===o||0===s&&u<l||1===s&&u>l)&&(l=u,o=h)}return e.PickOne(o),!0},AnySDK.PickByUID=function(e){const t=GetObjectClass2(this);return(t.GetRuntime().GetCurrentCondition().IsInverted()?PickByUID_Inverted2:PickByUID_Normal2)(t,e)},AnySDK.HasTags=function(e){const t=new Set(C33.splitStringAndNormalize(e)),s=GetInst2(this).GetTagsSet();return t.isSubsetOf(s)},AnySDK.Tags=function(){return GetInst2(this).GetTagsString()},AnySDK.TagsCount=function(){return GetInst2(this).GetTagsSet().size},AnySDK.TagAt=function(e){return GetInst2(this).GetTagAt(e)},AnySDK.ChangeTags=function(e,t){const s=C33.splitStringAndNormalize(t);if(0!==s.length){const i=GetInst2(this),n=new Set(i.GetTagsSet());if(0===e)for(const r of s)n.add(r);else if(1===e)for(const a of s)n.delete(a);i.SetTagsSet(n)}},AnySDK.Destroy=function(){runtime.DestroyInstance(GetInst2(this))},AnySDK.OnCreated=function(){return!0},AnySDK.OnDestroyed=function(){return!0},SDKv1.SetInstanceVar=function(e,t){this.GetInstance().SetInstanceVariableValue(e,t)},SDKv2.SetInstanceVar=function(e,t){GetInst_SDKv22(this).SetInstanceVariableValue(e,t)},SDKv1.AddInstanceVar=function(e,t){const s=this.GetInstance(),i=s.GetInstanceVariableValue(e);"number"==typeof i&&"number"!=typeof t?t=parseFloat(t):"string"==typeof i&&"string"!=typeof t&&(t=t.toString()),s.SetInstanceVariableValue(e,i+t)},SDKv2.AddInstanceVar=function(e,t){const s=GetInst_SDKv22(this),i=s.GetInstanceVariableValue(e);"number"==typeof i&&"number"!=typeof t?t=parseFloat(t):"string"==typeof i&&"string"!=typeof t&&(t=t.toString()),s.SetInstanceVariableValue(e,i+t)},SDKv1.SubInstanceVar=function(e,t){const s=this.GetInstance(),i=s.GetInstanceVariableValue(e);"number"==typeof i&&("number"!=typeof t&&(t=parseFloat(t)),s.SetInstanceVariableValue(e,i-t))},SDKv2.SubInstanceVar=function(e,t){const s=GetInst_SDKv22(this),i=s.GetInstanceVariableValue(e);"number"==typeof i&&("number"!=typeof t&&(t=parseFloat(t)),s.SetInstanceVariableValue(e,i-t))},SDKv1.SetBoolInstanceVar=function(e,t){this.GetInstance().SetInstanceVariableValue(e,t?1:0)},SDKv2.SetBoolInstanceVar=function(e,t){GetInst_SDKv22(this).SetInstanceVariableValue(e,t?1:0)},SDKv1.ToggleBoolInstanceVar=function(e){const t=this.GetInstance();t.SetInstanceVariableValue(e,0===t.GetInstanceVariableValue(e)?1:0)},SDKv2.ToggleBoolInstanceVar=function(e){const t=GetInst_SDKv22(this);t.SetInstanceVariableValue(e,0===t.GetInstanceVariableValue(e)?1:0)},AnySDK.LoadFromJsonString=function(e){let t;try{t=JSON.parse(e)}catch(e){return void console.error("Failed to load from JSON string: ",e)}const s=GetInst2(this);runtime.ClearIntancesNeedingAfterLoad(),s._OnBeforeLoad("state"),s.LoadFromJson(t,"state"),runtime.DoAfterLoad("state",{setFromJson:!0})},AnySDK.AsJSON=function(){return JSON.stringify(GetInst2(this).SaveToJson("state"))},AnySDK.ObjectTypeName=function(){return GetInst2(this).GetObjectClass().GetName()},AnySDK.Count=function(){let e=runtime.GetCurrentEventStackFrame().GetExpressionObjectClass(),t=e.GetInstanceCount();for(const s of runtime.instancesPendingCreateForObjectClass(e))++t;return t},AnySDK.PickedCount=function(){return runtime.GetCurrentEventStackFrame().GetExpressionObjectClass().GetCurrentSol().GetInstances().length},SDKv1.GetIID=function(){return this.GetInstance().GetIID()},SDKv2.GetIID=function(){return GetInst_SDKv22(this).GetIID()},SDKv1.GetUID=function(){return this.GetInstance().GetUID()},SDKv2.GetUID=function(){return GetInst_SDKv22(this).GetUID()},AnySDK.OnInstanceSignal=function(e){const t=GetInst2(this);return e.toLowerCase()===runtime.GetEventSheetManager().GetCurrentInstanceSignalTag(t)},AnySDK.InstanceSignal=function(e){const t=GetInst2(this);runtime.GetEventSheetManager().InstanceSignal(t,e)},AnySDK.InstanceWaitForSignal=function(e){const t=GetObjectClass2(this);return runtime.GetEventSheetManager().AddScheduledWait().InitInstanceSignals(t.GetCurrentSol().GetInstances(),e),!0},AnySDK.TemplateName=function(){return GetInst2(this).GetTemplateName()},C33.AddCommonACEs=function(e,t,s){const i=e[1],n=e[3],r=e[4],a=e[5],o=e[6],l=e[7],h=e[8],c=e[10],u=e[11],_=e[12],d=e[13],p=e[14],m=e[15],g=e[16],f=t.Cnds,S=t.Acts,C=t.Exps,y=Object.assign({},AnySDK,2<=s?SDKv2:SDKv1);n&&(f.CompareX=y.CompareX,f.CompareY=y.CompareY,f.IsOnScreen=y.IsOnScreen,f.IsOutsideLayout=y.IsOutsideLayout,f.PickDistance=y.PickDistance,S.SetX=y.SetX,S.SetY=y.SetY,S.SetPos=y.SetPos,S.SetPosToObject=y.SetPosToObject,S.MoveForward=y.MoveForward,S.MoveAtAngle=y.MoveAtAngle,C.X=y.GetX,C.Y=y.GetY,C.dt=y.GetDt),r&&(f.CompareWidth=y.CompareWidth,f.CompareHeight=y.CompareHeight,S.SetWidth=y.SetWidth,S.SetHeight=y.SetHeight,S.SetSize=y.SetSize,C.Width=y.GetWidth,C.Height=y.GetHeight,C.BBoxLeft=y.GetBboxLeft,C.BBoxTop=y.GetBboxTop,C.BBoxRight=y.GetBboxRight,C.BBoxBottom=y.GetBboxBottom,C.BBoxMidX=y.GetBboxMidX,C.BBoxMidY=y.GetBboxMidY),a&&(f.AngleWithin=y.IsAngleWithin,f.IsClockwiseFrom=y.IsAngleClockwiseFrom,f.IsBetweenAngles=y.IsBetweenAngles,S.SetAngle=y.SetAngle,S.RotateClockwise=y.RotateClockwise,S.RotateCounterclockwise=y.RotateCounterclockwise,S.RotateTowardAngle=y.RotateTowardAngle,S.RotateTowardPosition=y.RotateTowardPosition,S.SetTowardPosition=y.SetTowardPosition,C.Angle=y.GetAngle),o&&(f.IsVisible=y.IsVisible,f.CompareOpacity=y.CompareOpacity,S.SetVisible=y.SetVisible,S.SetOpacity=y.SetOpacity,S.SetDefaultColor=y.SetDefaultColor,C.Opacity=y.GetOpacity,C.ColorValue=y.GetColor),l&&(f.IsOnLayer=y.IsOnLayer,f.PickTopBottom=y.PickTopBottom,f.CompareZElevation=y.CompareZElevation,S.MoveToTop=y.MoveToTop,S.MoveToBottom=y.MoveToBottom,S.MoveToLayer=y.MoveToLayer,S.ZMoveToObject=y.ZMoveToObject,S.SetZElevation=y.SetZElevation,C.LayerNumber=y.LayerNumber,C.LayerName=y.LayerName,C.ZIndex=y.ZIndex,C.ZElevation=y.ZElevation,C.TotalZElevation=y.TotalZElevation),h&&(f.IsEffectEnabled=y.IsEffectEnabled,S.SetEffectEnabled=y.SetEffectEnabled,S.SetEffectParam=y.SetEffectParam),d&&(f.OnHierarchyReady=y.OnHierarchyReady,f.HasParent=y.HasParent,f.HasChildren=y.HasChildren,f.PickParent=y.PickParent,f.PickChildren=y.PickChildren,f.PickNthChild=y.PickNthChild,f.CompareChildCount=y.CompareChildCount,S.AddChild=y.AddChild,S.RemoveChild=y.RemoveChild,S.RemoveFromParent=y.RemoveFromParent,C.ParentUID=y.ParentUID,C.ChildCount=y.ChildCount,C.AllChildCount=y.AllChildCount),p&&(S.SetMeshSize=y.SetMeshSize,S.SetMeshPoint=y.SetMeshPoint,C.MeshColumns=y.MeshColumns,C.MeshRows=y.MeshRows),c&&(f.IsVisible=y.IsVisible,S.SetVisible=y.SetElementVisible,S.SetCSSStyle=y.SetElementCSSStyle,S.SetElemAttribute=y.SetElementAttribute,S.RemoveElemAttribute=y.RemoveElementAttribute),u&&(f.IsFocused=y.IsElementFocused,S.SetFocus=y.SetElementFocus,S.SetBlur=y.SetElementBlur),_&&(f.IsEnabled=y.IsElementEnabled,S.SetEnabled=y.SetElementEnabled),m&&(f.OnCollision=y.OnCollision,f.IsOverlapping=y.IsOverlapping,f.IsOverlappingOffset=y.IsOverlappingOffset,t.FinishCollisionCondition=FinishCollisionCondition2),i||(f.CompareInstanceVar=y.CompareInstanceVar,f.IsBoolInstanceVarSet=y.IsBoolInstanceVarSet,f.PickInstVarHiLow=y.PickInstVarHiLow,f.PickByUID=y.PickByUID,f.HasTags=y.HasTags,S.SetInstanceVar=y.SetInstanceVar,S.AddInstanceVar=y.AddInstanceVar,S.SubInstanceVar=y.SubInstanceVar,S.SetBoolInstanceVar=y.SetBoolInstanceVar,S.ToggleBoolInstanceVar=y.ToggleBoolInstanceVar,S.ChangeTags=y.ChangeTags,f.OnCreated=y.OnCreated,f.OnDestroyed=y.OnDestroyed,S.Destroy=y.Destroy,S.LoadFromJsonString||(S.LoadFromJsonString=y.LoadFromJsonString),C.AsJSON||(C.AsJSON=y.AsJSON),C.Count=y.Count,C.PickedCount=y.PickedCount,C.IID=y.GetIID,C.UID=y.GetUID,C.ObjectTypeName=y.ObjectTypeName,C.Tags=y.Tags,C.TagsCount=y.TagsCount,C.TagAt=y.TagAt,f.OnInstanceSignal=y.OnInstanceSignal,S.InstanceSignal=y.InstanceSignal,S.InstanceWaitForSignal=y.InstanceWaitForSignal),g&&(C.TemplateName=y.TemplateName)}}{const C33=self.C3;C33.ScheduledWait=class extends C33.DefendedBase{constructor(e){super(),this._eventSheetManager=e,this._type="",this._time=-1,this._signalTag="",this._isSignalled=!1,this._event=null,this._actIndex=0,this._solModifiers=[],this._dynamicSolModifiers=null,this._sols=new Map,this._pendingInstances=null,this._callingFunctionBlock=null,this._asyncId=-1,this._functionParameters=null,this._functionInnerLocalVars=null,this._shouldRelease=!1}Release(){this._type="",this._time=-1,this._signalTag="",this._event=null,this._callingFunctionBlock=null,this._functionParameters=null,this._functionInnerLocalVars=null,this._asyncId=-1,C33.clearArray(this._solModifiers),this._dynamicSolModifiers&&(this._dynamicSolModifiers.clear(),this._dynamicSolModifiers=null);for(const e of this._sols.values())e.Release();this._sols.clear(),this._pendingInstances=null}_Init(){const e=this._eventSheetManager,t=e.GetRuntime().GetAllObjectClasses(),s=e.GetCurrentEventStackFrame(),i=(this._event=s.GetCurrentEvent(),this._actIndex=s.GetActionIndex()+1,e.FindFirstFunctionBlockParent(this._event));i&&(this._callingFunctionBlock=i,this._functionParameters=i.CaptureFunctionParameters(),this._functionInnerLocalVars=i._GetAllInnerLocalVariables().map(e=>e.GetValue()),i.IsAsync())&&(this._asyncId=i.PauseCurrentAsyncFunction());for(const r of t){const a=r.GetCurrentSol();a.IsSelectAll()&&!this._event.HasSolModifier(r)||(this._solModifiers.push(r),this._sols.set(r,C33.New(C33.SolState,a)))}const n=e.GetDynamicSolModifiersSet();this._dynamicSolModifiers=0<n.size?n:null}InitTimer(e){this._type="timer",this._Init(),this._time=this._eventSheetManager.GetRuntime().GetGameTime()+e}InitWallTimer(e){this._type="walltimer",this._Init(),this._time=this._eventSheetManager.GetRuntime().GetWallTime()+e}InitSignal(e){this._type="signal",this._Init(),this._signalTag=e.toLowerCase()}InitInstanceSignals(e,t){this._type="instance-signals",this._Init(),this._signalTag=t.toLowerCase(),this._pendingInstances=new Set(e)}InitPromise(e){this._type="promise",this._Init(),e.then(()=>this.SetSignalled()).catch(e=>{console.warn("[C3 runtime] Promise rejected in 'Wait for previous actions to complete': ",e),this.SetSignalled()})}IsTimer(){return"timer"===this._type}IsWallTimer(){return"walltimer"===this._type}IsSignal(){return"signal"===this._type}IsInstanceSignals(){return"instance-signals"===this._type}IsPromise(){return"promise"===this._type}GetSignalTag(){return this._signalTag}IsSignalled(){return this._isSignalled}SetSignalled(){this._isSignalled=!0}SetInstanceSignalled(e){this._pendingInstances.delete(e),0===this._pendingInstances.size&&this.SetSignalled()}_ShouldRun(){return this.IsTimer()?this._time<=this._eventSheetManager.GetRuntime().GetGameTime():this.IsWallTimer()?this._time<=this._eventSheetManager.GetRuntime().GetWallTime():this.IsSignalled()}_RestoreState(e){e._Restore(this._event,this._actIndex);for(const[s,i]of this._sols.entries()){const n=s.GetCurrentSol();i._Restore(n)}this._dynamicSolModifiers&&e.SetDynamicSolModifiers([...this._dynamicSolModifiers]);const t=this._callingFunctionBlock;t&&(t.SetFunctionParameters(this._functionParameters),t._GetAllInnerLocalVariables().map((e,t)=>e.SetValue(this._functionInnerLocalVars[t])),t.IsAsync())&&t.ResumeAsyncFunction(this._asyncId)}_Run(e){this._RestoreState(e),this._event._ResumeActionsAndSubEvents(e),this._callingFunctionBlock&&this._callingFunctionBlock.IsAsync()&&this._callingFunctionBlock.MaybeFinishAsyncFunctionCall(this._asyncId),this._eventSheetManager.ClearSol(this._solModifiers),this._shouldRelease=!0}async _DebugRun(e){this._RestoreState(e);for(const t of this._event._DebugResumeActionsAndSubEvents(e))await this._eventSheetManager.GetRuntime().DebugBreak(t);this._callingFunctionBlock&&this._callingFunctionBlock.IsAsync()&&this._callingFunctionBlock.MaybeFinishAsyncFunctionCall(this._asyncId),this._eventSheetManager.ClearSol(this._solModifiers),this._shouldRelease=!0}ShouldRelease(){return this._shouldRelease}RemoveInstances(e){for(const t of this._sols.values())t.RemoveInstances(e);if("instance-signals"===this._type){for(const s of e)this._pendingInstances.delete(s);0===this._pendingInstances.size&&this.SetSignalled()}}_SaveToJson(){const e={},t={wt:this._type,t:this._time,st:this._signalTag,s:this._isSignalled,ev:this._event.GetSID(),sm:this._solModifiers.map(e=>e.GetSID()),dsm:this._dynamicSolModifiers?[...this._dynamicSolModifiers].map(e=>e.GetSID()):null,sols:e};this._event._HasActionIndex(this._actIndex)&&(t.act=this._event.GetActionAt(this._actIndex).GetSID());for(const[s,i]of this._sols)e[s.GetSID().toString()]=i._SaveToJson();return"instance-signals"===this._type&&(t.pi=[...this._pendingInstances].map(e=>e.GetUID())),t}static _CreateFromJson(e,t){const s=e.GetRuntime(),i=e.GetEventBlockBySID(t.ev);if(!i)return null;let n=0;if(t.hasOwnProperty("act")){const a=e.GetActionBySID(t.act);if(!a)return null;n=a.GetIndex()}const r=C33.New(C33.ScheduledWait,e);r._time=t.t,t.hasOwnProperty("wt")?r._type=t.wt:r._type=-1===r._time?"signal":"timer",r._signalTag=t.st,r._isSignalled=t.s,r._event=i,r._actIndex=n;for(const o of t.sm){const l=s.GetObjectClassBySID(o);l&&r._solModifiers.push(l)}if(Array.isArray(t.dsm))for(const h of t.dsm){const c=s.GetObjectClassBySID(h);c&&(r._dynamicSolModifiers||(r._dynamicSolModifiers=new Set),r._dynamicSolModifiers.add(c))}for(const[u,_]of Object.entries(t.sols)){const d=parseInt(u,10),p=s.GetObjectClassBySID(d);if(p){const m=C33.New(C33.SolState,null);m._LoadFromJson(e,_),r._sols.set(p,m)}}if("instance-signals"===r._type){r._pendingInstances=new Set;for(const g of t.pi){const f=s.GetInstanceByUID(g);f&&r._pendingInstances.add(f)}}return r}}}{const C33=self.C3;C33.SolState=class extends C33.DefendedBase{constructor(e){super(),this._objectClass=null,this._isSelectAll=!0,this._instances=[],e&&(this._objectClass=e.GetObjectClass(),this._isSelectAll=e.IsSelectAll(),C33.shallowAssignArray(this._instances,e._GetOwnInstances()))}Release(){this._objectClass=null,C33.clearArray(this._instances)}_Restore(e){e._SetSelectAll(this._isSelectAll),C33.shallowAssignArray(e._GetOwnInstances(),this._instances)}RemoveInstances(e){C33.arrayRemoveAllInSet(this._instances,e)}_SaveToJson(){return{sa:this._isSelectAll,insts:this._instances.map(e=>e.GetUID())}}_LoadFromJson(e,t){const s=e.GetRuntime();this._isSelectAll=!!t.sa,C33.clearArray(this._instances);for(const i of t.insts){const n=s.GetInstanceByUID(i);n&&this._instances.push(n)}}}}{let GetNextParamMap2=function(e,t){let s=e.get(t);return s||(s=new Map,e.set(t,s)),s};GetNextParamMap=GetNextParamMap2;const C33=self.C3;C33.SDKPluginBase=class extends C33.DefendedBase{constructor(e){super(),this._runtime=e.runtime,this._name=e.name??"",this._isSingleGlobal=!!e.isSingleGlobal,this._isWorldType=!!e.isWorld,this._isRotatable=!!e.isRotatable,this._mustPredraw=!!e.mustPredraw,this._hasEffects=!!e.hasEffects,this._supportsSceneGraph=!!e.supportsSceneGraph,this._supportsMesh=!!e.supportsMesh,this._isHTMLElementType=!!e.isHTMLElementType,this._is3d=!!e.is3d,this._sdkVersion=e.sdkVersion,this._singleGlobalObjectClass=null,this._boundACEMethodCache=new Map,this._boundACEMethodCache_1param=new Map,this._boundACEMethodCache_2params=new Map,this._boundACEMethodCache_3params=new Map,this._scriptInterfaceClass=e.scriptInterfaceClass,this._iPlugin=null}Release(){this._runtime=null}GetRuntime(){return this._runtime}GetName(){return this._name}OnCreate(){}GetConstructor(){return(2<=this.GetSdkVersion()?this._iPlugin:this).constructor}GetSdkVersion(){return this._sdkVersion}GetScriptInterfaceClass(e=!1){let t=this._scriptInterfaceClass;return e&&"function"!=typeof t&&2<=this.GetSdkVersion()?globalThis.ISDKPluginBase:t}IsSingleGlobal(){return this._isSingleGlobal}IsWorldType(){return this._isWorldType}IsHTMLElementType(){return this._isHTMLElementType}Is3D(){return this._is3d}IsRotatable(){return this._isRotatable}MustPreDraw(){return this._mustPredraw}HasEffects(){return this._hasEffects}SupportsSceneGraph(){return this._supportsSceneGraph}SupportsMesh(){return this._supportsMesh}_GetBoundACEMethod(e,t){if(!t)throw new Error("missing 'this' binding");let s=this._boundACEMethodCache.get(e);return s||(s=e.bind(t),this._boundACEMethodCache.set(e,s)),s}_GetBoundACEMethod_1param(e,t,s){if(!t)throw new Error("missing 'this' binding");let i=GetNextParamMap2(this._boundACEMethodCache_1param,e),n=i.get(s);return n||(n=e.bind(t,s),i.set(s,n)),n}_GetBoundACEMethod_2params(e,t,s,i){if(!t)throw new Error("missing 'this' binding");let n=GetNextParamMap2(this._boundACEMethodCache_2params,e),r=GetNextParamMap2(n,s),a=r.get(i);return a||(a=e.bind(t,s,i),r.set(i,a)),a}_GetBoundACEMethod_3params(e,t,s,i,n){if(!t)throw new Error("missing 'this' binding");let r=GetNextParamMap2(this._boundACEMethodCache_3params,e),a=GetNextParamMap2(r,s),o=GetNextParamMap2(a,i),l=o.get(n);return l||(l=e.bind(t,s,i,n),o.set(n,l)),l}_SetSingleGlobalObjectClass(e){if(!this.IsSingleGlobal())throw new Error("must be single-global plugin");this._singleGlobalObjectClass=e}GetSingleGlobalObjectClass(){if(this.IsSingleGlobal())return this._singleGlobalObjectClass;throw new Error("must be single-global plugin")}GetSingleGlobalInstance(){if(this.IsSingleGlobal())return this._singleGlobalObjectClass.GetSingleGlobalInstance();throw new Error("must be single-global plugin")}_InitScriptInterface(){const e=this.GetSdkVersion(),t=(C33.AddonManager._PushInitObject(this,e),this.GetScriptInterfaceClass(!0));if(t){if(this._iPlugin=new t,!(this._iPlugin instanceof self.IPlugin))throw new TypeError("plugin class must derive from IPlugin")}else this._iPlugin=new self.IPlugin;C33.AddonManager._PopInitObject(e)}GetIPlugin(){return this._iPlugin}}}{const C33=self.C3;C33.SDKDOMPluginBase=class extends C33.SDKPluginBase{constructor(e,t){super(e),this._domComponentId=t,this._nextElementId=0,this._instMap=new Map,this.AddElementMessageHandler("elem-focused",e=>e._OnElemFocused()),this.AddElementMessageHandler("elem-blurred",e=>{e&&e._OnElemBlurred()})}Release(){super.Release()}_AddElement(e){const t=this._nextElementId++;return this._instMap.set(t,e),t}_RemoveElement(e){this._instMap.delete(e)}AddElementMessageHandler(e,s){this._runtime.AddDOMComponentMessageHandler(this._domComponentId,e,e=>{const t=this._instMap.get(e.elementId);s(t,e)})}}}{const C33=self.C3;C33.SDKTypeBase=class extends C33.DefendedBase{constructor(e){super(),this._objectClass=e,this._runtime=e.GetRuntime(),this._plugin=e.GetPlugin()}Release(){this._objectClass=null,this._runtime=null,this._plugin=null}GetObjectClass(){return this._objectClass}GetRuntime(){return this._runtime}GetPlugin(){return this._plugin}GetImageInfo(){return this._objectClass.GetImageInfo()}OnCreate(){}FinishCondition(e){}BeforeRunAction(e){}AfterRunAction(e){}LoadTextures(e){}ReleaseTextures(){}OnDynamicTextureLoadComplete(){}PreloadTexturesWithInstances(e){}LoadTilemapData(){}GetScriptInterfaceClass(){return null}DispatchScriptEvent(e,t,s){const i=C33.New(C33.Event,e,t);i.objectClass=this,s&&Object.assign(i,s),this.GetObjectClass().DispatchUserScriptEvent(i)}}}{const C33=self.C3;C33.SDKInstanceBase=class extends C33.DefendedBase{constructor(e,t){super(),this._inst=e,this._domComponentId=t,this._wrapperComponentId=null,this._runtime=e.GetRuntime(),this._objectClass=this._inst.GetObjectClass(),this._sdkType=this._objectClass.GetSdkType(),this._tickFunc=null,this._tick2Func=null,this._isTicking=!1,this._isTicking2=!1,this._disposables=null,this._wasReleased=!1}Release(){this._wasReleased=!0,this._StopTicking(),this._StopTicking2(),this._tickFunc=null,this._tick2Func=null,this._disposables&&(this._disposables.Release(),this._disposables=null),this._inst=null,this._runtime=null,this._objectClass=null,this._sdkType=null}WasReleased(){return this._wasReleased}GetInstance(){return this._inst}GetRuntime(){return this._runtime}GetObjectClass(){return this._objectClass}GetPlugin(){return this._sdkType.GetPlugin()}GetSdkType(){return this._sdkType}GetScriptInterface(){return this._inst.GetInterfaceClass()}Trigger(e){return this._runtime.Trigger(e,this._inst,null)}DebugTrigger(e){return this._runtime.DebugTrigger(e,this._inst,null)}TriggerAsync(e){return this._runtime.TriggerAsync(e,this._inst,null)}FastTrigger(e,t){return this._runtime.FastTrigger(e,this._inst,t)}DebugFastTrigger(e,t){return this._runtime.DebugFastTrigger(e,this._inst,t)}ScheduleTriggers(e){return this._runtime.ScheduleTriggers(e)}AddDOMMessageHandler(e,t){this._runtime.AddDOMComponentMessageHandler(this._domComponentId,e,t)}AddDOMMessageHandlers(e){for(const[t,s]of e)this.AddDOMMessageHandler(t,s)}PostToDOM(e,t){this._runtime.PostComponentMessageToDOM(this._domComponentId,e,t)}PostToDOMAsync(e,t){return this._runtime.PostComponentMessageToDOMAsync(this._domComponentId,e,t)}_PostToDOMMaybeSync(e,t){if(!this._runtime.IsInWorker())return window.c3_runtimeInterface._OnMessageFromRuntime({type:"event",component:this._domComponentId,handler:e,data:t,responseId:null});this.PostToDOM(e,t)}SetWrapperExtensionComponentId(e){if(!e)throw new Error("cannot set empty component id");this._wrapperComponentId=e}IsWrapperExtensionAvailable(){if(this._wrapperComponentId)return this._runtime.HasWrapperComponentId(this._wrapperComponentId);throw new Error("wrapper extension component id not set")}AddWrapperExtensionMessageHandler(e,t){if(!this._wrapperComponentId)throw new Error("wrapper extension component id not set");this._runtime.AddWrapperExtensionMessageHandler(this._wrapperComponentId,e,t)}AddWrapperExtensionMessageHandlers(e){for(const[t,s]of e)this.AddWrapperExtensionMessageHandler(t,s)}SendWrapperExtensionMessage(e,t){if(!this._wrapperComponentId)throw new Error("wrapper extension component id not set");this._runtime.SendWrapperExtensionMessage(this._wrapperComponentId,e,t)}SendWrapperExtensionMessageAsync(e,t){if(this._wrapperComponentId)return this._runtime.SendWrapperExtensionMessageAsync(this._wrapperComponentId,e,t);throw new Error("wrapper extension component id not set")}Tick(){}Tick2(){}_StartTicking(){if(!this._isTicking){if(!this._tickFunc)if(this._runtime.IsDebug()){const t=globalThis.C3Debugger,s=this.GetPlugin();this._tickFunc=()=>{const e=performance.now();this.Tick(),t.AddIndividualPluginTickTime(s,performance.now()-e)}}else this._tickFunc=()=>this.Tick();this._runtime.Dispatcher().addEventListener("tick",this._tickFunc),this._isTicking=!0}}_StopTicking(){this._isTicking&&(this._runtime.Dispatcher().removeEventListener("tick",this._tickFunc),this._isTicking=!1)}IsTicking(){return this._isTicking}_StartTicking2(){if(!this._isTicking2){if(!this._tick2Func)if(this._runtime.IsDebug()){const t=globalThis.C3Debugger,s=this.GetPlugin();this._tick2Func=()=>{const e=performance.now();this.Tick2(),t.AddIndividualPluginTickTime(s,performance.now()-e)}}else this._tick2Func=()=>this.Tick2();this._runtime.Dispatcher().addEventListener("tick2",this._tick2Func),this._isTicking2=!0}}_StopTicking2(){this._isTicking2&&(this._runtime.Dispatcher().removeEventListener("tick2",this._tick2Func),this._isTicking2=!1)}IsTicking2(){return this._isTicking2}GetDebuggerProperties(){return[]}SaveToJson(){return null}LoadFromJson(e){}GetPropertyValueByIndex(e){}SetPropertyValueByIndex(e,t){}OffsetPropertyValueByIndex(e,t,s){if(0!==t){const i=this.GetPropertyValueByIndex(e);if("number"!=typeof i)throw new Error("expected number");this.SetPropertyValueByIndex(e,i+t,s)}}SetPropertyColorOffsetValueByIndex(e,t,s,i){}CallAction(e,...t){e.call(this,...t)}CallExpression(e,...t){return e.call(this,...t)}GetScriptInterfaceClass(){return null}DispatchScriptEvent(e,t,s){if(this._inst.HasScriptInterface()){const i=this.GetScriptInterface(),n=C33.New(C33.Event,e,t);n.instance=i,s&&Object.assign(n,s),i.dispatchEvent(n)}}MustPreDraw(){return!1}}}{const C33=self.C3;C33.SDKWorldInstanceBase=class extends C33.SDKInstanceBase{constructor(e,t){super(e,t),this._worldInfo=e.GetWorldInfo(),this._renderercontextlost_handler=null,this._renderercontextrestored_handler=null}Release(){if(this._renderercontextlost_handler){const e=this._runtime.Dispatcher();e.removeEventListener("renderercontextlost",this._renderercontextlost_handler),e.removeEventListener("renderercontextrestored",this._renderercontextrestored_handler),this._renderercontextlost_handler=null,this._renderercontextrestored_handler=null}this._worldInfo=null,super.Release()}HandleWebGLContextLoss(){this.HandleRendererContextLoss()}OnWebGLContextLost(){}OnWebGLContextRestored(){}HandleRendererContextLoss(){if(!this._renderercontextlost_handler){this._renderercontextlost_handler=()=>this.OnRendererContextLost(),this._renderercontextrestored_handler=()=>this.OnRendererContextRestored();const e=this._runtime.Dispatcher();e.addEventListener("renderercontextlost",this._renderercontextlost_handler),e.addEventListener("renderercontextrestored",this._renderercontextrestored_handler)}}OnRendererContextLost(){this.OnWebGLContextLost()}OnRendererContextRestored(){this.OnWebGLContextRestored()}GetWorldInfo(){return this._worldInfo}IsOriginalSizeKnown(){return!1}GetOriginalWidth(){if(!this.IsOriginalSizeKnown())throw new Error("original size not known");const e=this.GetCurrentImageInfo();if(e)return e.GetWidth()}GetOriginalHeight(){if(!this.IsOriginalSizeKnown())throw new Error("original size not known");const e=this.GetCurrentImageInfo();if(e)return e.GetHeight()}GetCurrentImageInfo(){return null}GetCurrentSurfaceSize(){const e=this.GetCurrentImageInfo();if(e){const t=e.GetTexture();if(t)return[t.GetWidth(),t.GetHeight()]}return[100,100]}GetCurrentTexRect(){const e=this.GetCurrentImageInfo();return e?e.GetTexRect():null}GetCurrentTexQuad(){const e=this.GetCurrentImageInfo();return e?e.GetTexQuad():null}IsCurrentTexRotated(){const e=this.GetCurrentImageInfo();return!!e&&e.IsRotated()}GetImagePoint(e){const t=this._inst.GetWorldInfo();return[t.GetX(),t.GetY(),t.GetTotalZElevation()]}LoadTilemapData(e,t,s){}TestPointOverlapTile(e,t){}RendersToOwnZPlane(){return!0}}}{const C33=self.C3,tempRect=C33.New(C33.Rect);C33.SDKDOMInstanceBase=class extends C33.SDKWorldInstanceBase{constructor(e,t){super(e,t),this._elementId=this.GetPlugin()._AddElement(this),this._isElementShowing=!0,this._elemHasFocus=!1,this._autoFontSize=!1,this._autoFontSizeOffset=-.2,this._lastRect=C33.New(C33.Rect,0,0,-1,-1);const s=this._runtime.GetCanvasManager();this._lastWindowWidth=s.GetLastWidth(),this._lastWindowHeight=s.GetLastHeight(),this._lastHTMLIndex=-1,this._lastHTMLZIndex=-1,this._isPendingUpdateState=!1,this._StartTicking()}Release(){this.GetPlugin()._RemoveElement(this._elementId),this.PostToDOMElement("destroy"),this._elementId=-1,super.Release()}_GetElementInDOMMode(){if(this._runtime.IsInWorker())throw new Error("not valid in worker mode");return this._PostToDOMElementMaybeSync("get-element")}PostToDOMElement(e,t){(t=t||{}).elementId=this._elementId,this.PostToDOM(e,t)}_PostToDOMElementMaybeSync(e,t){return(t=t||{}).elementId=this._elementId,this._PostToDOMMaybeSync(e,t)}PostToDOMElementAsync(e,t){return(t=t||{}).elementId=this._elementId,this.PostToDOMAsync(e,t)}CreateElement(e){e=e||{};const t=this.GetWorldInfo();e.elementId=this._elementId,e.isVisible=t.IsVisible(),e.htmlIndex=t.GetLayer().GetHTMLIndex(),e.htmlZIndex=t.GetHTMLZIndex(),Object.assign(e,this.GetElementState()),this._isElementShowing=!!e.isVisible,this._PostToDOMMaybeSync("create",e),this._UpdatePosition(!0)}SetElementVisible(e){this._isElementShowing!==(e=!!e)&&(this._isElementShowing=e,this.PostToDOMElement("set-visible",{isVisible:e}))}Tick(){this._UpdatePosition(!1)}_ShouldPreserveElement(){const e=this._runtime.GetCanvasManager().GetFullscreenMode();return"Android"===C33.Platform.OS&&("scale-inner"===e||"scale-outer"===e||"crop"===e)}_UpdatePosition(c){if(!this.GetInstance().IsDestroyed()){let e=this.GetWorldInfo(),t=e.GetLayer(),s=e.GetBoundingBox(),[i,n]=t.LayerToCanvasCss(s.getLeft(),s.getTop()),[r,a]=t.LayerToCanvasCss(s.getRight(),s.getBottom()),o=this._runtime.GetCanvasManager(),l=o.GetCssWidth(),h=o.GetCssHeight();if(e.IsVisible()&&t.IsVisible())if(!this._ShouldPreserveElement()&&(r<=0||a<=0||l<=i||h<=n))this.SetElementVisible(!1);else{tempRect.set(i,n,r,a);const u=o.GetLastWidth(),_=o.GetLastHeight(),d=t.GetHTMLIndex(),p=e.GetHTMLZIndex();if(!c&&tempRect.equals(this._lastRect)&&this._lastWindowWidth===u&&this._lastWindowHeight===_&&this._lastHTMLIndex===d&&this._lastHTMLZIndex===p)this.SetElementVisible(!0);else{this._lastRect.copy(tempRect),this._lastWindowWidth=u,this._lastWindowHeight=_,this._lastHTMLIndex=d,this._lastHTMLZIndex=p,this.SetElementVisible(!0);let e=null;this._autoFontSize&&(e=t.GetDisplayScale()+this._autoFontSizeOffset),this.PostToDOMElement("update-position",{left:Math.round(this._lastRect.getLeft()),top:Math.round(this._lastRect.getTop()),width:Math.round(this._lastRect.width()),height:Math.round(this._lastRect.height()),htmlIndex:d,htmlZIndex:p,fontSize:e})}}else this.SetElementVisible(!1)}}FocusElement(){this._PostToDOMElementMaybeSync("focus",{focus:!0})}BlurElement(){this._PostToDOMElementMaybeSync("focus",{focus:!1})}_OnElemFocused(){this._elemHasFocus=!0}_OnElemBlurred(){this._elemHasFocus=!1}IsElementFocused(){return this._elemHasFocus}SetElementCSSStyle(e,t){this.PostToDOMElement("set-css-style",{prop:C33.CSSToCamelCase(e),val:t})}SetElementAttribute(e,t){this.PostToDOMElement("set-attribute",{name:e,val:t})}RemoveElementAttribute(e){this.PostToDOMElement("remove-attribute",{name:e})}UpdateElementState(){this._isPendingUpdateState||(this._isPendingUpdateState=!0,Promise.resolve().then(()=>{this._isPendingUpdateState=!1,this.PostToDOMElement("update-state",this.GetElementState())}))}GetElementState(){}GetElementId(){return this._elementId}}}{const C33=self.C3,IBehavior=self.IBehavior;C33.SDKBehaviorBase=class extends C33.DefendedBase{constructor(e){super(),this._runtime=e.runtime,this._name=e.name??"",this._myObjectClasses=C33.New(C33.ArraySet),this._myInstances=C33.New(C33.ArraySet),this._sdkVersion=e.sdkVersion,this._scriptInterfaceClass=e.scriptInterfaceClass,this._iBehavior=null}Release(){this._myInstances.Release(),this._myObjectClasses.Release(),this._runtime=null}GetRuntime(){return this._runtime}GetName(){return this._name}OnCreate(){}GetSdkVersion(){return this._sdkVersion}GetScriptInterfaceClass(e=!1){let t=this._scriptInterfaceClass;return e&&"function"!=typeof t&&2<=this.GetSdkVersion()?globalThis.ISDKBehaviorBase:t}_AddObjectClass(e){this._myObjectClasses.Add(e)}GetObjectClasses(){return this._myObjectClasses.GetArray()}_AddInstance(e){this._myInstances.Add(e)}_RemoveInstance(e){this._myInstances.Delete(e)}GetInstances(){return this._myInstances.GetArray()}_InitScriptInterface(){const e=this.GetSdkVersion(),t=(C33.AddonManager._PushInitObject(this,e),this.GetScriptInterfaceClass(!0));if(t){if(this._iBehavior=new t,!(this._iBehavior instanceof IBehavior))throw new TypeError("behavior class must derive from IBehavior")}else this._iBehavior=new IBehavior;C33.AddonManager._PopInitObject(e)}GetIBehavior(){return this._iBehavior}}}{const C33=self.C3;C33.SDKBehaviorTypeBase=class extends C33.DefendedBase{constructor(e){super(),this._runtime=e.GetRuntime(),this._behaviorType=e,this._objectClass=e.GetObjectClass(),this._behavior=e.GetBehavior(),this._behavior._AddObjectClass(this._objectClass)}Release(){this._runtime=null,this._behaviorType=null,this._objectClass=null,this._behavior=null}OnCreate(){}GetBehaviorType(){return this._behaviorType}GetObjectClass(){return this._objectClass}GetRuntime(){return this._runtime}GetBehavior(){return this._behavior}}}{const C33=self.C3;C33.SDKBehaviorInstanceBase=class extends C33.DefendedBase{constructor(e,t){super(),this._behInst=e,this._domComponentId=t,this._inst=e.GetObjectInstance(),this._runtime=e.GetRuntime(),this._behaviorType=e.GetBehaviorType(),this._sdkType=this._behaviorType.GetSdkType(),this._isTicking=!1,this._isTicking2=!1,this._isPostTicking=!1,this._disposables=null}Release(){this._StopTicking(),this._StopTicking2(),this._StopPostTicking(),this._disposables&&(this._disposables.Release(),this._disposables=null),this._behInst=null,this._inst=null,this._runtime=null,this._behaviorType=null,this._sdkType=null}GetBehavior(){return this._behaviorType.GetBehavior()}GetBehaviorInstance(){return this._behInst}GetObjectInstance(){return this._inst}GetObjectClass(){return this._inst.GetObjectClass()}GetWorldInfo(){return this._inst.GetWorldInfo()}GetRuntime(){return this._runtime}GetBehaviorType(){return this._behaviorType}GetSdkType(){return this._sdkType}GetScriptInterface(){return this._behInst.GetScriptInterface()}Trigger(e){return this._runtime.Trigger(e,this._inst,this._behaviorType)}DebugTrigger(e){return this._runtime.DebugTrigger(e,this._inst,this._behaviorType)}TriggerAsync(e){return this._runtime.TriggerAsync(e,this._inst,this._behaviorType)}PostCreate(){}Tick(){}Tick2(){}PostTick(){}_StartTicking(){this._isTicking||(this._runtime._AddBehInstToTick(this),this._isTicking=!0)}_StopTicking(){this._isTicking&&(this._runtime._RemoveBehInstToTick(this),this._isTicking=!1)}IsTicking(){return this._isTicking}_StartTicking2(){this._isTicking2||(this._runtime._AddBehInstToTick2(this),this._isTicking2=!0)}_StopTicking2(){this._isTicking2&&(this._runtime._RemoveBehInstToTick2(this),this._isTicking2=!1)}IsTicking2(){return this._isTicking2}_StartPostTicking(){this._isPostTicking||(this._runtime._AddBehInstToPostTick(this),this._isPostTicking=!0)}_StopPostTicking(){this._isPostTicking&&(this._runtime._RemoveBehInstToPostTick(this),this._isPostTicking=!1)}IsPostTicking(){return this._isPostTicking}GetDebuggerProperties(){return[]}AddDOMMessageHandler(e,t){this._runtime.AddDOMComponentMessageHandler(this._domComponentId,e,t)}OnSpriteFrameChanged(e,t){}SaveToJson(){return null}LoadFromJson(e){}GetPropertyValueByIndex(e){}SetPropertyValueByIndex(e,t){}OffsetPropertyValueByIndex(e,t){if(0!==t){const s=this.GetPropertyValueByIndex(e);if("number"!=typeof s)throw new Error("expected number");this.SetPropertyValueByIndex(e,s+t)}}SetPropertyColorOffsetValueByIndex(e,t,s,i){}CallAction(e,...t){e.call(this,...t)}CallExpression(e,...t){return e.call(this,...t)}GetScriptInterfaceClass(){return null}DispatchScriptEvent(e,t,s){if(this._behInst.HasScriptInterface()){const i=this.GetScriptInterface(),n=C33.New(C33.Event,e,t);n.behaviorInstance=i,n.instance=i.instance,s&&Object.assign(n,s),i.dispatchEvent(n)}}}}{let ValidateInternalAPIToken2=function(e){if(e!==internalApiToken)throw new Error("invalid internal API token")},C33=(ValidateInternalAPIToken=ValidateInternalAPIToken2,self.C3),internalApiToken=(C33.Plugins={},C33.Behaviors={},C33._GetInternalAPIToken()),initObjectStack=[],initObjectStack2=[],initPropertiesStack=[],originalPushInitObject=null,originalPopInitObject=null,originalGetInitObject=null,originalGetInitObject2=null,pluginsByCtor=new Map,behaviorsByCtor=new Map;C33.AddonManager=class extends C33.DefendedBase{constructor(e,t){super(),this._runtime=e,this._allPlugins=[],this._systemPlugin=null,this._allBehaviors=[],this._delayCreateBehaviors=new Map,this._solidBehavior=null,this._jumpthruBehavior=null,this._wrapperComponentIds=new Set(t)}CreatePlugin(e){const t=e[19],s=this._runtime.GetObjectReference(e[0]);if(!s)throw new Error("missing plugin");C33.AddCommonACEs(e,s,t);const i=2<=t?C33.SDKPluginBase:s,n=C33.New(i,{runtime:this._runtime,isSingleGlobal:e[1],isWorld:e[2],isRotatable:e[5],hasEffects:e[8],mustPredraw:e[9],supportsSceneGraph:e[13],supportsMesh:e[14],isHTMLElementType:e[17],is3d:e[18],sdkVersion:t,name:e[20],scriptInterfaceClass:2<=t?s:null});n.OnCreate(),this._allPlugins.push(n),pluginsByCtor.set(s,n)}CreateSystemPlugin(){this._systemPlugin=C33.New(C33.Plugins.System,{runtime:this._runtime,isSingleGlobal:!0}),this._systemPlugin.OnCreate()}CreateBehavior(e){const s=e[1],i=e[2],n=this._runtime.GetObjectReference(e[0]);if(!n)throw new Error("missing behavior");this._delayCreateBehaviors.set(n,()=>{const e=2<=s?C33.SDKBehaviorBase:n,t=C33.New(e,{runtime:this._runtime,name:i,sdkVersion:s,scriptInterfaceClass:2<=s?n:null});t.OnCreate(),this._allBehaviors.push(t),behaviorsByCtor.set(n,t),!this._solidBehavior&&C33.Behaviors.solid&&t instanceof C33.Behaviors.solid?this._solidBehavior=t:!this._jumpthruBehavior&&C33.Behaviors.jumpthru&&t instanceof C33.Behaviors.jumpthru&&(this._jumpthruBehavior=t),t._InitScriptInterface()})}_DelayCreateBehavior(e){const t=this._delayCreateBehaviors.get(e);t&&(t(),this._delayCreateBehaviors.delete(e))}static _PushInitObject(e,t=1){if(C33.AddonManager._PushInitObject!==originalPushInitObject)throw new Error("invalid method");1===t&&initObjectStack.push(e),initObjectStack2.push(e)}static _PopInitObject(e=1){if(C33.AddonManager._PopInitObject!==originalPopInitObject)throw new Error("invalid method");1===e&&initObjectStack.pop(),initObjectStack2.pop()}static _GetInitObject(){if(C33.AddonManager._GetInitObject!==originalGetInitObject)throw new Error("invalid method");if(0===initObjectStack.length)throw new Error("no init object set");return initObjectStack.at(-1)}static _GetInitObject2(e){if(C33.AddonManager._GetInitObject2!==originalGetInitObject2)throw new Error("invalid method");if(ValidateInternalAPIToken2(e),0===initObjectStack2.length)throw new Error("no init object set");return initObjectStack2.at(-1)}static _PushInitProperties(e){initPropertiesStack.push(e)}static _PopInitProperties(){initPropertiesStack.pop()}static _GetInitProperties(){if(0===initPropertiesStack.length)throw new Error("no init properties set");return initPropertiesStack.at(-1)}_InitAddonScriptInterfaces(){for(const e of this._allPlugins)e._InitScriptInterface()}static GetPluginByConstructorFunction(e){return pluginsByCtor.get(e)||null}static GetBehaviorByConstructorFunction(e){return behaviorsByCtor.get(e)||null}GetSystemPlugin(){return this._systemPlugin}GetSolidBehavior(){return this._solidBehavior}GetJumpthruBehavior(){return this._jumpthruBehavior}HasWrapperComponentId(e){return this._wrapperComponentIds.has(e)}},originalPushInitObject=C33.AddonManager._PushInitObject,originalPopInitObject=C33.AddonManager._PopInitObject,originalGetInitObject=C33.AddonManager._GetInitObject,originalGetInitObject2=C33.AddonManager._GetInitObject2}{const C33=self.C3,allImageInfos=new Set;C33.ImageInfo=class extends C33.DefendedBase{constructor(){super(),this._generation=0,this._url="",this._size=0,this._offsetX=0,this._offsetY=0,this._width=0,this._height=0,this._isRotated=!1,this._hasMetaData=!1,this._imageAsset=null,this._textureState="",this._rcTex=C33.New(C33.Rect),this._quadTex=C33.New(C33.Quad),this._blobUrl="",this._iImageInfo=new self.IImageInfo(this),allImageInfos.add(this)}Release(){this.ReleaseTexture(),this._imageAsset&&0===this._imageAsset.GetRefCount()&&this._imageAsset.Release(),this._imageAsset=null,allImageInfos.delete(this),this.ReleaseBlobURL()}static OnRendererContextLost(){for(const e of allImageInfos)e._textureState="",e._rcTex.set(0,0,0,0),e._quadTex.setFromRect(e._rcTex)}LoadData(e){this._url=e[0],this._size=e[1],this._offsetX=e[2],this._offsetY=e[3],this._width=e[4],this._height=e[5],this._isRotated=e[6],this._hasMetaData=!0}LoadDynamicAsset(e,t){if(this._imageAsset)throw new Error("already loaded asset");this._url=t;const s={};return C33.IsAbsoluteURL(t)&&(s.loadPolicy="remote"),this.LoadAsset(e,s),this._imageAsset.Load()}LoadDynamicBlobAsset(e,t){if(this._imageAsset)throw new Error("already loaded asset");this._url="",this._size=t.size,this._imageAsset=C33.New(C33.ImageAsset,e.GetAssetManager(),{blob:t,size:this._size,loadPolicy:"local"})}ReplaceWith(e){if(e===this)throw new Error("cannot replace with self");this._generation++,this.ReleaseTexture(),this._url=e._url,this._size=e._size,this._offsetX=e._offsetX,this._offsetY=e._offsetY,this._width=e._width,this._height=e._height,this._isRotated=e._isRotated,this._hasMetaData=e._hasMetaData,this._imageAsset=e._imageAsset,this._textureState=e._textureState,this._rcTex=e._rcTex,this._quadTex=e._quadTex,this.ReleaseBlobURL()}GetURL(){return this._url}GetSize(){return this._size}GetOffsetX(){return this._offsetX}GetOffsetY(){return this._offsetY}IsRotated(){return this._isRotated}GetWidth(){return this._width}GetHeight(){return this._height}GetSheetWidth(){return this._imageAsset.GetWidth()}GetSheetHeight(){return this._imageAsset.GetHeight()}LoadAsset(e,t){if(this._imageAsset)throw new Error("already got asset");t=Object.assign({},t,{url:this.GetURL(),size:this.GetSize()}),this._imageAsset=e.LoadImage(t)}IsLoaded(){return this._imageAsset&&this._imageAsset.IsLoaded()}async LoadStaticTexture(e,t){if(!this._imageAsset)throw new Error("no asset");if(this._textureState)throw new Error("already loaded texture");const s=this._generation,i=(this._textureState="loading",await this._imageAsset.LoadStaticTexture(e,t));if(this._generation!==s)return null;if(!i)return this._textureState="",null;this._textureState="loaded",this._hasMetaData||(this._width=i.GetWidth(),this._height=i.GetHeight(),this._hasMetaData=!0);const n=this._isRotated?this._height:this._width,r=this._isRotated?this._width:this._height;return this._rcTex.set(this._offsetX,this._offsetY,this._offsetX+n,this._offsetY+r),this._rcTex.divide(i.GetWidth(),i.GetHeight()),this._quadTex.setFromRect(this._rcTex),this._isRotated&&this._quadTex.rotatePointsAnticlockwise(),i}ReleaseTexture(){this._textureState&&(this._imageAsset&&this._imageAsset.ReleaseTexture(),this._textureState="",this._rcTex.set(0,0,0,0),this._quadTex.setFromRect(this._rcTex))}GetTexture(){return this._imageAsset&&"loaded"===this._textureState?this._imageAsset.GetTexture():null}GetTexRect(){return this._rcTex}GetTexQuad(){return this._quadTex}GetIImageInfo(){return this._iImageInfo}GetImageAsset(){return this._imageAsset}async ExtractImageToCanvas(e){e=e||await this._imageAsset.LoadToDrawable();const t=C33.CreateCanvas(this._width,this._height),s=t.getContext("2d");return this._isRotated?(s.rotate(Math.PI/-2),s.translate(-this._height,0),s.drawImage(e,this._offsetX,this._offsetY,this._height,this._width,0,0,this._height,this._width)):s.drawImage(e,this._offsetX,this._offsetY,this._width,this._height,0,0,this._width,this._height),t}async ExtractImageToBlobURL(e){if(!this._blobUrl){const t=await this.ExtractImageToCanvas(e),s=await C33.CanvasToBlob(t);this._blobUrl=URL.createObjectURL(s)}return this._blobUrl}ReleaseBlobURL(){this._blobUrl&&(URL.revokeObjectURL(this._blobUrl),this._blobUrl="")}}}{const C33=self.C3;C33.AnimationInfo=class extends C33.DefendedBase{constructor(e){super(),this._name=e[0],this._speed=e[1],this._isLooping=!!e[2],this._repeatCount=e[3],this._repeatTo=e[4],this._isPingPong=!!e[5],this._sid=e[6],this._frames=e[7].map(e=>C33.New(C33.AnimationFrameInfo,e)),this._iAnimation=new self.IAnimation(this)}static CreateDynamic(e,t){const s=C33.New(C33.AnimationInfo,[t,0,!1,0,0,!1,Math.floor(1e15*Math.random()),[]]);return s._frames.push(C33.AnimationFrameInfo.CreateDynamic(e)),s}Release(){for(const e of this._frames)e.Release();C33.clearArray(this._frames)}LoadAllAssets(e){for(const t of this._frames)t.GetImageInfo().LoadAsset(e)}LoadAllTextures(t,s){return Promise.all(this._frames.map(e=>e.GetImageInfo().LoadStaticTexture(t,s)))}ReleaseAllTextures(){for(const e of this._frames)e.GetImageInfo().ReleaseTexture()}GetName(){return this._name}GetSID(){return this._sid}GetFrameCount(){return this._frames.length}GetFrames(){return this._frames}GetFrameAt(e){if((e=Math.floor(e))<0||e>=this._frames.length)throw new RangeError("invalid frame");return this._frames[e]}InsertFrameAt(e,t){(t=Math.floor(t))<0?this._frames.unshift(e):t>=this._frames.length?this._frames.push(e):this._frames.splice(t,0,e)}RemoveFrameAt(e){if((e=Math.floor(e))<0||e>=this._frames.length)throw new RangeError("invalid frame");this._frames[e].Release(),this._frames.splice(e,1)}GetFrameIndexByTag(s){for(let e=0,t=this._frames.length;e<t;++e)if(C33.equalsNoCase(this._frames[e].GetTag(),s))return e;return-1}FrameTagOrIndexToIndex(e){if("string"!=typeof e)return e;{const t=this.GetFrameIndexByTag(e);if(-1===t)throw new Error("cannot find animation frame with tag "+e);return t}}GetSpeed(){return this._speed}IsLooping(){return this._isLooping}GetRepeatCount(){return this._repeatCount}GetRepeatTo(){return this._repeatTo}IsPingPong(){return this._isPingPong}GetIAnimation(){return this._iAnimation}}}{const C33=self.C3,EMPTY_IMAGE_BLOB=(()=>{const s=atob("iVBORw0KGgoAAAANSUhEUgAAAGQAAABkAQMAAABKLAcXAAAAAXNSR0IArs4c6QAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAATSURBVBgZYxgFo2AUjIJRQFcAAAV4AAHcRQIbAAAAAElFTkSuQmCC"),i=new Uint8Array(s.length);for(let e=0,t=s.length;e<t;++e)i[e]=s.charCodeAt(e);return new Blob([i],{type:"image/png"})})();C33.AnimationFrameInfo=class extends C33.DefendedBase{constructor(e){super(),this._imageInfo=C33.New(C33.ImageInfo),this._imageInfo.LoadData(e),this._duration=e[7],this._origin=C33.New(C33.Vector2,e[8],e[9]),this._imagePoints=e[10].map(e=>C33.New(C33.ImagePoint,this,e)),this._imagePointsByName=new Map;for(const s of this._imagePoints)this._imagePointsByName.set(s.GetName().toLowerCase(),s);this._collisionPoly=null;const t=e[11];6<=t.length&&(this._collisionPoly=C33.New(C33.CollisionPoly,t)),this._tag=e[12]||"",this._iAnimationFrame=new self.IAnimationFrame(this)}static CreateDynamic(e){const t=C33.New(C33.AnimationFrameInfo,["",0,0,0,100,100,!1,1,0,0,[],[],""]);return t._imageInfo.LoadDynamicBlobAsset(e,EMPTY_IMAGE_BLOB),t}Release(){this._collisionPoly&&(this._collisionPoly.Release(),this._collisionPoly=null),this._imageInfo.Release(),this._imageInfo=null}GetImageInfo(){return this._imageInfo}GetDuration(){return this._duration}GetOriginX(){return this._origin.getX()}GetOriginY(){return this._origin.getY()}GetCollisionPoly(){return this._collisionPoly}GetImagePointByName(e){return this._imagePointsByName.get(e.toLowerCase())||null}GetImagePointByIndex(e){return(e=Math.floor(e))<0||e>=this._imagePoints.length?null:this._imagePoints[e]}GetImagePointCount(){return this._imagePoints.length}GetTag(){return this._tag}GetIAnimationFrame(){return this._iAnimationFrame}}}{const C33=self.C3;C33.ImagePoint=class extends C33.DefendedBase{constructor(e,t){super(),this._afi=e,this._name=t[0],this._pos=C33.New(C33.Vector2,t[1],t[2])}Release(){}GetName(){return this._name}GetX(){return this._pos.getX()}GetY(){return this._pos.getY()}GetVec2(){return this._pos}}}{const C33=self.C3,C3Debugger=self.C3Debugger,IObjectClass=self.IObjectClass,assert=self.assert;C33.ObjectClass=class extends C33.DefendedBase{constructor(t,e,s){super();const i=t.GetObjectReference(s[1]),[n,r]=(this._runtime=t,this._plugin=C33.AddonManager.GetPluginByConstructorFunction(i),this._sdkType=null,this._instSdkCtor=i.Instance,this._index=e,this._sid=s[11],this._name=s[0],this._jsPropName=this._runtime.GetJsPropName(s[14]),this._isGlobal=!!s[9],this._isFamily=!!s[2],this._isOnLoaderLayout=!!s[10],this._instVars=s[3].map(e=>({sid:e[0],type:e[1],name:e[2],jsPropName:t.GetJsPropName(e[3])})),this._behaviorsCount=s[4],this._effectsCount=s[5],this._isWorldType=this._plugin.IsWorldType(),this._dispatcher=C33.New(C33.Event.Dispatcher),this._effectList=null,t.GetCollisionEngine().GetCollisionCellSize());if(this._collisionGrid=C33.New(C33.SparseGrid,n,r),this._anyCollisionCellChanged=!0,this._familyMembers=null,this._familyMembersSet=null,this._familyIndex=-1,this._families=null,this._familiesSet=null,this._familyInstVarMap=null,this._familyBehaviorMap=null,this._familyEffectMap=null,this._isInContainer=!1,this._container=null,this._behaviorTypes=s[8].map(e=>C33.BehaviorType.Create(this,e)),this._behaviorTypesIncludingInherited=[],this._behaviorsByName=new Map,this._behaviorNameToIndex=new Map,this._usedBehaviorCtors=new Set,this._customActionMap=new Map,this._solStack=C33.New(C33.SolStack,this),this._defaultInstanceData=null,this._defaultLayerIndex=0,this._isContained=!1,this._container=null,this._imageInfo=null,this._animations=null,this._animationsByName=null,this._animationsBySid=null,this._textureRefCount=0,this._savedData=new Map,this._unsavedData=new Map,this._instances=[],this._worldInfosByLayer=new Map,this._iidsStale=!0,this._plugin.HasEffects()&&(this._effectList=C33.New(C33.EffectList,this,s[12])),s[6]&&(this._imageInfo=C33.New(C33.ImageInfo),this._imageInfo.LoadData(s[6])),s[7]){this._animations=s[7].map(e=>C33.New(C33.AnimationInfo,e)),this._animationsByName=new Map,this._animationsBySid=new Map;for(const l of this._animations)this._animationsByName.set(l.GetName().toLowerCase(),l),this._animationsBySid.set(l.GetSID(),l)}this._isFamily?(this._familyMembers=[],this._familyMembersSet=new Set,this._familyIndex=this._runtime._GetNextFamilyIndex()):(this._families=[],this._familiesSet=new Set,this._familyInstVarMap=[],this._familyBehaviorMap=[],this._familyEffectMap=[]);const a=this._plugin.GetSdkVersion();if(a<2&&(this._sdkType=C33.New(i.Type,this,s[15]),!(this._sdkType instanceof C33.SDKTypeBase)))throw new Error("v1 sdk type must derive from SDKTypeBase");this._iObjectClass=null,this._instanceUserScriptClass=null,this._userScriptDispatcher=C33.New(C33.Event.Dispatcher),C33.AddonManager._PushInitObject(this,a);let o;if(o=2<=a?(o=i.Type)||globalThis.ISDKObjectTypeBase:this._sdkType.GetScriptInterfaceClass()){if(this._iObjectClass=new o(a<2?this:null),a<2&&!(this._iObjectClass instanceof IObjectClass))throw new TypeError("script interface class must derive from IObjectClass");if(2<=a&&!(this._iObjectClass instanceof globalThis.ISDKObjectTypeBase))throw new TypeError("script interface class must derive from ISDKObjectTypeBase")}else this._iObjectClass=new IObjectClass;if(C33.AddonManager._PopInitObject(a),s[13]){const h=s[13];if(h){const c=h[0],u=h[1],_=h[2];this._sdkType.LoadTilemapData(c,u,_)}}this._runtime.UsesLoaderLayout()&&!this._isFamily&&!this._isOnLoaderLayout&&this._isWorldType||this.OnCreate(),this._plugin.IsSingleGlobal()&&(this._plugin._SetSingleGlobalObjectClass(this),this._CreateSingleGlobalInstance(s)),this._loadInstancesJson=null}static Create(e,t,s){return C33.New(C33.ObjectClass,e,t,s)}Release(){if(this._dispatcher.Release(),this._dispatcher=null,this._imageInfo&&(this._imageInfo.Release(),this._imageInfo=null),this._animations){for(const e of this._animations)e.Release();C33.clearArray(this._animations),this._animationsByName.clear(),this._animationsBySid.clear()}this._loadInstancesJson=null,this._solStack.Release(),this._solStack=null,this._savedData.clear(),this._unsavedData.clear(),this._container=null,this._runtime=null}_LoadFamily(s){for(let e=1,t=s.length;e<t;++e){const i=this._runtime.GetObjectClassByIndex(s[e]);this._familyMembers.push(i),this._familyMembersSet.add(i),i._families.push(this),i._familiesSet.add(this)}}_SetContainer(e){this._isInContainer=!0,this._container=e}IsInContainer(){return this._isInContainer}GetContainer(){return this._container}_OnAfterCreate(){let e=0;if(!this._isFamily)for(const t of this._families)for(const s of t.GetBehaviorTypes()){const i=s.GetName().toLowerCase();this._behaviorsByName.set(i,s),this._behaviorNameToIndex.set(i,e),this._behaviorTypesIncludingInherited.push(s),++e}for(const n of this.GetBehaviorTypes()){const r=n.GetName().toLowerCase();this._behaviorsByName.set(r,n),this._behaviorNameToIndex.set(r,e),this._behaviorTypesIncludingInherited.push(n),++e}for(const a of this._behaviorTypesIncludingInherited)this._usedBehaviorCtors.add(a.GetBehavior().constructor);if(!this._isFamily&&this._families.length){let e=this._runtime.GetFamilyCount(),t=(C33.extendArray(this._familyInstVarMap,e,0),C33.extendArray(this._familyBehaviorMap,e,0),C33.extendArray(this._familyEffectMap,e,0),[]),s=0,i=0,n=0;for(const o of this._families){const l=o.GetFamilyIndex(),h=(this._familyInstVarMap[l]=s,s+=o.GetInstanceVariablesCount(),this._familyBehaviorMap[l]=i,i+=o.GetBehaviorTypesCount(),this._familyEffectMap[l]=n,n+=o.GetEffectTypesCount(),o.GetEffectList());if(h&&this._effectList)for(const c of h.GetAllEffectTypes())t.push(c.Clone(this._effectList))}this._effectList&&this._effectList.PrependEffectTypes(t)}}_CreateSingleGlobalInstance(e){const t=this._runtime._GetNewUID(),s=C33.New(C33.Instance,{runtime:this._runtime,objectType:this,uid:t});s._CreateSdkInstance(e[16],[]),this._runtime._MapInstanceByUID(t,s),this._instances.push(s)}GetSdkType(){return this._sdkType}IsOnLoaderLayout(){return this._isOnLoaderLayout}Dispatcher(){return this._dispatcher}OnCreate(){this._isFamily||(this._sdkType?this._sdkType.OnCreate():this._iObjectClass._onCreate())}HasLoadedTextures(){return 0<this._textureRefCount}async LoadTextures(e){this._isFamily||(this._textureRefCount++,1===this._textureRefCount&&(this._sdkType?await this._sdkType.LoadTextures(e):await this._iObjectClass._loadTextures(this._runtime.GetCanvasManager().GetIRenderer())))}ReleaseTextures(){if(!this._isFamily){if(this._textureRefCount--,this._textureRefCount<0)throw new Error("released textures too many times");0===this._textureRefCount&&(this._sdkType?this._sdkType.ReleaseTextures():this._iObjectClass._releaseTextures(this._runtime.GetCanvasManager().GetIRenderer()))}}OnDynamicTextureLoadComplete(){if(this._isFamily)throw new Error("not applicable to family");this._sdkType?this._sdkType.OnDynamicTextureLoadComplete():this._iObjectClass._onDynamicTextureLoadComplete()}async PreloadTexturesWithInstances(e){this._isFamily||(this._sdkType?await this._sdkType.PreloadTexturesWithInstances(e):await this._iObjectClass._preloadTexturesWithInstances(this._runtime.GetCanvasManager().GetIRenderer()))}GetRuntime(){return this._runtime}GetPlugin(){return this._plugin}GetInstanceSdkCtor(){return this._instSdkCtor}GetName(){return this._name}GetJsPropName(){return this._jsPropName}GetIndex(){return this._index}GetSID(){return this._sid}IsFamily(){return this._isFamily}IsGlobal(){return this._isGlobal}IsWorldType(){return this._isWorldType}GetFamilyIndex(){return this._familyIndex}GetBehaviorTypes(){return this._behaviorTypes}GetBehaviorTypesCount(){return this._behaviorsCount}UsesBehaviorByCtor(e){return e&&this._usedBehaviorCtors.has(e)}GetInstanceVariablesCount(){return this._instVars.length}GetInstanceVariableSIDs(){return this._instVars.map(e=>e.sid)}GetInstanceVariableIndexBySID(t){return this._instVars.findIndex(e=>e.sid===t)}GetInstanceVariableIndexByName(t){return this._instVars.findIndex(e=>e.name===t)}_GetAllInstanceVariableNames(){return this._instVars.map(e=>e.name)}_GetAllInstanceVariableJsPropNames(){return this._instVars.map(e=>e.jsPropName)}GetInstanceVariableType(e){if((e=Math.floor(e))<0||e>=this._instVars.length)throw new RangeError("invalid instance variable index");return this._instVars[e].type}GetInstanceVariableName(e){if((e=Math.floor(e))<0||e>=this._instVars.length)throw new RangeError("invalid instance variable index");return this._instVars[e].name}GetEffectTypesCount(){return this._effectsCount}GetBehaviorTypesIncludingInherited(){return this._behaviorTypesIncludingInherited}GetBehaviorTypeByName(e){return this._behaviorsByName.get(e.toLowerCase())||null}GetBehaviorIndexByName(e){const t=this._behaviorNameToIndex.get(e.toLowerCase());return void 0===t?-1:t}GetEffectList(){return this._effectList}HasEffects(){return this._plugin.HasEffects()}UsesEffects(){return this._effectList&&this._effectList.HasAnyEffectType()}GetSolStack(){return this._solStack}GetCurrentSol(){return this._solStack.GetCurrentSol()}GetImageInfo(){return this._imageInfo}SetDefaultInstanceData(e){this._defaultInstanceData=e}GetDefaultInstanceData(){return this._defaultInstanceData}_SetDefaultLayerIndex(e){this._defaultLayerIndex=e}GetDefaultLayerIndex(){return this._defaultLayerIndex}GetAnimations(){return this._animations}GetAnimationCount(){return this._animations.length}GetFamilies(){return this._families}BelongsToFamily(e){return this._familiesSet.has(e)}GetFamilyMembers(){return this._familyMembers}FamilyHasMember(e){return this._familyMembersSet.has(e)}GetFamilyBehaviorOffset(e){return this._familyBehaviorMap[e]}GetFamilyInstanceVariableOffset(e){return this._familyInstVarMap[e]}AddCustomAction(e){this._customActionMap.set(e.GetACEName().toLowerCase(),e)}HasOwnCustomActionByName(e){return!!this.GetOwnCustomActionByName(e)}GetOwnCustomActionByName(e){const t=this._customActionMap.get(e.toLowerCase());return t&&t.IsEnabled()?t:null}GetAllAnimations(){return this._animations}GetAnimationByName(e){if(this._animations)return this._animationsByName.get(e.toLowerCase())||null;throw new Error("no animations")}GetAnimationBySID(e){if(this._animations)return this._animationsBySid.get(e)||null;throw new Error("no animations")}AddAnimation(e){if(this.GetAnimationByName(e))throw new Error(`animation name '${e}' already exists`);const t=C33.AnimationInfo.CreateDynamic(this.GetRuntime(),e);return this._animations.push(t),this._animationsByName.set(t.GetName().toLowerCase(),t),this._animationsBySid.set(t.GetSID(),t),t}RemoveAnimation(e){const t=this.GetAnimationByName(e);if(!t)throw new Error(`animation name '${e}' does not exist`);if(1===this._animations.length)throw new Error("cannot remove last animation");const s=this._animations.indexOf(t);this._animations.splice(s,1),this._animationsByName.delete(t.GetName().toLowerCase()),this._animationsBySid.delete(t.GetSID()),t.Release()}GetFirstAnimation(){if(this._animations)return this._animations[0];throw new Error("no animations")}GetFirstAnimationFrame(){return this.GetFirstAnimation().GetFrameAt(0)}GetDefaultInstanceSize(){if(this._animations){const e=this.GetFirstAnimationFrame().GetImageInfo();return[e.GetWidth(),e.GetHeight()]}return this._imageInfo?[this._imageInfo.GetWidth(),this._imageInfo.GetHeight()]:[100,100]}GetSingleGlobalInstance(){if(this._plugin.IsSingleGlobal())return this._instances[0];throw new Error("not a single-global plugin")}GetInstances(){return this._instances}*instances(){yield*this._instances}*instancesIncludingPendingCreate(){yield*this._instances,yield*this._runtime.instancesPendingCreateForObjectClass(this)}GetInstanceCount(){return this._instances.length}_AddInstance(e){this._instances.push(e)}_SetIIDsStale(){this._iidsStale=!0}_UpdateIIDs(){if(this._iidsStale&&!this._isFamily){let t=this._instances,s=0;for(let e=t.length;s<e;++s)t[s]._SetIID(s);const e=this._runtime._GetInstancesPendingCreate();for(const i of e)i.GetObjectClass()===this&&i._SetIID(s++);this._iidsStale=!1}}GetInstanceByIID(e){const t=this._instances;if(e<t.length)return t[e];e-=t.length;const s=this._runtime._GetInstancesPendingCreate();for(const i of s)if(i.GetObjectClass()===this){if(0===e)return i;--e}return null}GetFirstPicked(e){if(e&&e.IsInContainer()&&e.GetObjectClass()!==this)for(const s of e.siblings())if(s.GetObjectClass()===this)return s;const t=this.GetCurrentSol().GetInstances();return t.length?t[0]:null}GetPairedInstance(e){const t=this.GetCurrentSol().GetInstances();return 0<t.length?t[e.GetIID()%t.length]:null}*allCorrespondingInstances(e,t){let s=this.GetCurrentSol().GetInstances(),i=s.length,n=t.GetCurrentSol(),r=t.GetCurrentSol().GetInstances(),a=r.length,o=e.GetIID(),l=(!t.IsFamily()&&n.IsSelectAll()||(o=r.indexOf(e)),Math.ceil(i/a)),h=i%a,c=0,u;u=0==h||o<h?(c=o*l,l):(c=h*l+(o-h)*(l-1),l-1);for(let e=c,t=c+u;e<t;++e)yield s[e]}FinishCondition(e){this._sdkType?.FinishCondition(e)}ApplySolToContainer(){if(this._isInContainer&&!this._isFamily){this._UpdateIIDs();const e=this.GetCurrentSol(),t=e._GetOwnInstances(),s=e.IsSelectAll(),i=this._runtime.GetCurrentEventStackFrame(),n=i&&i.GetCurrentEvent()&&i.GetCurrentEvent().IsOrBlock();for(const r of this._container.objectTypes())if(r!==this){r._UpdateIIDs();const a=r.GetCurrentSol();if(a._SetSelectAll(s),!s){const o=a._GetOwnInstances();C33.clearArray(o);for(const l of t)o.push(r.GetInstanceByIID(l.GetIID()));if(n){const h=e._GetOwnElseInstances(),c=a._GetOwnElseInstances();C33.clearArray(c);for(const u of h)c.push(r.GetInstanceByIID(u.GetIID()))}}}}}_TruncateContainerSols(e,t){for(const s of this.GetContainer().objectTypes()){const i=s.GetCurrentSol();e?C33.truncateArray(i._GetOwnElseInstances(),t):C33.truncateArray(i._GetOwnInstances(),t)}}_GetCollisionCellGrid(){return this._collisionGrid}_SetAnyCollisionCellChanged(e){this._anyCollisionCellChanged=!!e}_UpdateAllCollisionCells(){if(this._anyCollisionCellChanged&&this._isWorldType){for(const e of this._instances)e.GetWorldInfo()._UpdateCollisionCell();for(const t of this._runtime._GetInstancesPendingCreate())t.GetObjectClass()===this&&t.GetWorldInfo()._UpdateCollisionCell();this._anyCollisionCellChanged=!1}}_OnWorldInstanceLayerChanged(t,e,s){if(e){const i=this._worldInfosByLayer.get(e);i&&(i.delete(t),0===i.size)&&this._worldInfosByLayer.delete(e)}if(s){let e=this._worldInfosByLayer.get(s);e||(e=new Set,this._worldInfosByLayer.set(s,e)),e.add(t)}}layersHasInstancesOn(){if(this.IsFamily()){const e=new Set;for(const t of this._familyMembers)for(const s of t.layersHasInstancesOn())e.add(s);return e.values()}return this._worldInfosByLayer.keys()}GetSavedDataMap(){return this._savedData||(this._savedData=new Map),this._savedData}GetUnsavedDataMap(){return this._unsavedData||(this._unsavedData=new Map),this._unsavedData}HasSolidBehavior(){return this.UsesBehaviorByCtor(C33.Behaviors.solid)}HasJumpthruBehavior(){return this.UsesBehaviorByCtor(C33.Behaviors.jumpthru)}HasNoSaveBehavior(){return this.UsesBehaviorByCtor(C33.Behaviors.NoSave)}HasPersistBehavior(){return this.UsesBehaviorByCtor(C33.Behaviors.Persist)}_SaveToJson(){const e={instances:this._instances.map(e=>e.SaveToJson())};return this._savedData&&this._savedData.size&&(e.ex=C33.ToSuperJSON(this._savedData)),e}_LoadFromJson(e,i){this._savedData&&(this._savedData.clear(),this._savedData=null);const t=e.ex,n=(t&&(this._savedData=C33.FromSuperJSON(t)),this._instances),r=e.instances;for(let e=0,t=Math.min(n.length,r.length);e<t;++e)n[e].LoadFromJson(r[e]);for(let e=r.length,t=n.length;e<t;++e)this._runtime.DestroyInstance(n[e]);for(let s=n.length,e=r.length;s<e;++s){let e=r[s],t=null;if(!this.IsWorldType()||(t=this._runtime.GetMainRunningLayout().GetLayerBySID(e.w.l))){const a=this._runtime.CreateInstanceFromData(this._defaultInstanceData||this,t,!1,0,0,!0);a.LoadFromJson(e),i&&i.add(a)}}this._loadInstancesJson=r,this._SetIIDsStale()}_GetLoadInstancesJson(){return this._loadInstancesJson}_ClearLoadInstancesJson(){this._loadInstancesJson=null}_SetupSceneGraphConnectionsOnChangeOfLayout(){for(let e=0,t=this._instances;e<t;++e)this._instances[e]._SetupSceneGraphConnectionsOnChangeOfLayout()}GetIObjectClass(){return this._iObjectClass}UserScriptDispatcher(){return this._userScriptDispatcher}_GetUserScriptInstanceClass(){return this._instanceUserScriptClass}_SetUserScriptInstanceClass(e){this._instanceUserScriptClass=e}DispatchUserScriptEvent(e){const t=this._runtime,s=t.IsDebug()&&!t.GetEventSheetManager().IsInEventEngine();s&&C3Debugger.StartMeasuringScriptTime(),this._userScriptDispatcher.dispatchEvent(e),s&&C3Debugger.AddScriptTime()}}}{const C33=self.C3;C33.Container=class extends C33.DefendedBase{constructor(e,t){super(),this._runtime=e,this._objectTypes=t;for(const s of this._objectTypes)s._SetContainer(this)}Release(){this._runtime=null}GetRuntime(){return this._runtime}GetObjectTypes(){return this._objectTypes}objectTypes(){return this._objectTypes}HasAnyWorldType(){return this._objectTypes.some(e=>e.IsWorldType())}}}{let C33=self.C3,C3Debugger=self.C3Debugger,IInstance=self.IInstance,originalAddonManager=C33.AddonManager,EMPTY_ARRAY=[],nextPuid=0,savedDataMaps=new WeakMap,unsavedDataMaps=new WeakMap,FLAG_DESTROYED=1,FLAG_TILEMAP=2,FLAG_MUST_PREDRAW=4,FLAG_SOLID_ENABLED=8,FLAG_JUMPTHRU_ENABLED=16,FLAG_MUST_MITIGATE_Z_FIGHTING=32,FLAG_IS_DRAWING_WITH_EFFECTS=64;C33.Instance=class extends C33.DefendedBase{constructor(e){if(C33.AddonManager!==originalAddonManager)throw new Error("invalid addon manager");super(),this._runtime=e.runtime,this._objectType=e.objectType,this._worldInfo=null,this._sdkInst=null,this._iScriptInterface=null,this._iid=0,this._uid=e.uid,this._puid=nextPuid++,this._flags=0,this._tagsSet=null;const t=C33.splitStringAndNormalize(e.tags),s=(0<t.length&&(this._tagsSet=new Set(t)),this._instVarValues=EMPTY_ARRAY,this._behaviorInstances=EMPTY_ARRAY,this._objectType.GetBehaviorTypesIncludingInherited()),i=(0<s.length&&(this._behaviorInstances=s.map((e,t)=>C33.New(C33.BehaviorInstance,{runtime:this._runtime,behaviorType:e,instance:this,index:t}))),this._siblings=this._objectType.IsInContainer()?[]:null,this._timeScale=-1,this._dispatcher=null,this.GetPlugin());if(i.MustPreDraw()&&(this._flags|=FLAG_MUST_PREDRAW),i.IsWorldType())if(this._worldInfo=C33.New(C33.WorldInfo,this,e.layer),e.worldData)this._worldInfo.Init(e.worldData);else{this._worldInfo.InitNoData();const[n,r]=this._objectType.GetDefaultInstanceSize();this._worldInfo.SetSize(n,r),this.GetObjectClass().UsesEffects()&&this._worldInfo.GetInstanceEffectList().LoadDefaultEffectParameters()}e.instVarData?this._LoadInstanceVariableData(e.instVarData):this._LoadDefaultInstanceVariables()}Release(){if(this._iScriptInterface&&(this._iScriptInterface._release(),this._iScriptInterface=null),0<this._behaviorInstances.length){for(const s of this._behaviorInstances)s.Release();C33.clearArray(this._behaviorInstances)}this._sdkInst&&(this._sdkInst.Release(),this._sdkInst=null);const e=savedDataMaps.get(this),t=(e&&(e.clear(),savedDataMaps.delete(this)),unsavedDataMaps.get(this));t&&(t.clear(),unsavedDataMaps.delete(this)),this._siblings&&C33.clearArray(this._siblings),this._dispatcher&&(this._dispatcher.Release(),this._dispatcher=null),this._tagsSet&&this._tagsSet.clear(),this._tagsSet=null,this._runtime=null,this._objectType=null,0<this._instVarValues.length&&C33.clearArray(this._instVarValues),this._worldInfo&&(this._worldInfo.Release(),this._worldInfo=null)}_LoadInstanceVariableData(e){0<e.length&&(this._instVarValues=[],C33.shallowAssignArray(this._instVarValues,e))}_LoadDefaultInstanceVariables(){const t=this._objectType.GetInstanceVariablesCount();if(0!==t){this._instVarValues=[];const s=[0,0,""];for(let e=0;e<t;++e)this._instVarValues.push(s[this._objectType.GetInstanceVariableType(e)])}}_CreateSdkInstance(e,s){if(this._sdkInst)throw new Error("already got sdk instance");for(let e=0,t=this._behaviorInstances.length;e<t;++e){const i=this._behaviorInstances[e];i._CreateSdkInstance(s?s[e]:null)}const t=this.GetPlugin().GetSdkVersion();if(t<2){if(this._sdkInst=C33.New(this._objectType.GetInstanceSdkCtor(),this,e),!(this._sdkInst instanceof C33.SDKInstanceBase))throw new Error("sdk type must derive from SDKInstanceBase");!this.GetPlugin().IsWorldType()&&this._objectType._GetUserScriptInstanceClass()&&this.GetInterfaceClass()}else{const n=this.GetPlugin().GetScriptInterfaceClass();this._InitUserScriptInterface(n.Instance,e)}}GetSdkInstance(){return this._sdkInst??this._iScriptInterface}GetWorldInfo(){return this._worldInfo}GetRuntime(){return this._runtime}GetTimeScale(){return this._timeScale}GetActiveTimeScale(){const e=this._timeScale;return-1===e?this.GetRuntime().GetTimeScale():e}SetTimeScale(e){((e=+e)<0||!isFinite(e))&&(e=0),this._timeScale=e,this.GetObjectClass().UsesEffects()&&this._runtime._SetTrackingInstanceTime(this,!0)}RestoreTimeScale(){this._timeScale=-1,this.GetObjectClass().UsesEffects()&&this._runtime._SetTrackingInstanceTime(this,!1)}GetInstanceGameTime(){return this._runtime._GetInstanceGameTime(this)}Dispatcher(){return this._dispatcher||(this._dispatcher=C33.New(C33.Event.Dispatcher)),this._dispatcher}Draw(e){this._sdkInst?this._sdkInst.Draw(e):this._iScriptInterface._draw(this._runtime.GetCanvasManager().GetIRenderer())}OnCreate(e){this._sdkInst.OnCreate(e)}_SetHasTilemap(){this._flags|=FLAG_TILEMAP}HasTilemap(){return 0!=(this._flags&FLAG_TILEMAP)}_MarkDestroyed(){this._flags|=FLAG_DESTROYED}IsDestroyed(){return 0!=(this._flags&FLAG_DESTROYED)}MustPreDraw(){return 0!=(this._flags&FLAG_MUST_PREDRAW)||this._sdkInst.MustPreDraw()}SetMustMitigateZFighting(){this._flags|=FLAG_MUST_MITIGATE_Z_FIGHTING}MustMitigateZFighting(){return 0!=(this._flags&FLAG_MUST_MITIGATE_Z_FIGHTING)}_IsSolidEnabled(){return 0!=(this._flags&FLAG_SOLID_ENABLED)}_SetSolidEnabled(e){e?this._flags|=FLAG_SOLID_ENABLED:this._flags&=~FLAG_SOLID_ENABLED}_IsJumpthruEnabled(){return 0!=(this._flags&FLAG_JUMPTHRU_ENABLED)}_SetJumpthruEnabled(e){e?this._flags|=FLAG_JUMPTHRU_ENABLED:this._flags&=~FLAG_JUMPTHRU_ENABLED}_IsDrawingWithEffects(){return 0!=(this._flags&FLAG_IS_DRAWING_WITH_EFFECTS)}_SetIsDrawingWithEffects(e){e?this._flags|=FLAG_IS_DRAWING_WITH_EFFECTS:this._flags&=~FLAG_IS_DRAWING_WITH_EFFECTS}SetFlag(e,t){e<<=16,t?this._flags|=e:this._flags&=~e}GetFlag(e){return 0!=(this._flags&e<<16)}GetCurrentImageInfo(){return this._sdkInst.GetCurrentImageInfo()}GetCurrentSurfaceSize(){return this._sdkInst.GetCurrentSurfaceSize()}GetCurrentTexRect(){return this._sdkInst.GetCurrentTexRect()}GetCurrentTexQuad(){return this._sdkInst.GetCurrentTexQuad()}IsCurrentTexRotated(){return this._sdkInst.IsCurrentTexRotated()}GetImagePoint(e){return this._sdkInst.GetImagePoint(e)}GetObjectClass(){return this._objectType}RendersToOwnZPlane(){return this._sdkInst.RendersToOwnZPlane()}BelongsToObjectClass(e){return e.IsFamily()?e.FamilyHasMember(this.GetObjectClass()):this.GetObjectClass()===e}CollectInstancesToPick(n,e,t){const s=(e,t)=>{const s=t||e.GetObjectClass(),i=n.get(s);i?i.add(e):n.set(s,new Set([e]))};if(s(this,e),this.IsInContainer())for(const i of this.siblings())s(i);if(t)for(const r of this.allChildren())s(r)}VerifySupportsSceneGraph(){if(!this.GetPlugin().SupportsSceneGraph())throw new Error("object does not support scene graph")}HasParent(){return null!==this.GetParent()}GetParent(){const e=this.GetWorldInfo();if(!e)return null;const t=e.GetParent();return t?t.GetInstance():null}GetTopParent(){const e=this.GetWorldInfo();if(!e)return null;const t=e.GetTopParent();return t?t.GetInstance():null}*parents(){const e=this.GetWorldInfo();if(e)for(const t of e.parents())yield t.GetInstance()}HasChild(e){if(e)for(const t of this.children())if(t===e)return!0;return!1}HasChildren(){const e=this.GetWorldInfo();return!!e&&e.HasChildren()}GetChildrenOfObjectClass(e){const t=this.GetWorldInfo();if(!t)return[];const s=e.GetName();return t.GetChildren().map(e=>e.GetInstance()).filter(e=>e.GetObjectClass().GetName()===s)}GetChildren(){const e=this.GetWorldInfo();return e?e.GetChildren().map(e=>e.GetInstance()):[]}*children(){const e=this.GetWorldInfo();if(e)for(const t of e.children())yield t.GetInstance()}*allChildren(){const e=this.GetWorldInfo();if(e)for(const t of e.allChildren())yield t.GetInstance()}GetChildCount(){const e=this.GetWorldInfo();return e?e.GetChildCount():0}GetParentCount(){return[...this.parents()].length}GetAllChildCount(){const e=this.GetWorldInfo();return e?e.GetAllChildCount():0}GetChildAt(e){const t=this.GetWorldInfo();if(!t)return null;const s=t.GetChildAt(e);return s?s.GetInstance():null}GetIndexInParent(){const e=this.GetWorldInfo();if(!e)return NaN;const t=e.GetParent();return t?t.GetChildIndex(e):NaN}HasChildWithUID(e){for(const t of this.GetWorldInfo().GetChildren())if(t.GetInstance().GetUID()===e)return!0;return!1}AddChild(e,t){this.VerifySupportsSceneGraph(),e.VerifySupportsSceneGraph(),this.GetWorldInfo().AddChild(e.GetWorldInfo(),t||{})}RemoveChild(e){const t=this.GetWorldInfo();t&&t.RemoveChild(e.GetWorldInfo())}GetDestroyWithParent(){const e=this.GetWorldInfo();return!!e&&e.GetDestroyWithParent()}SetupInitialSceneGraphConnections(){const e=this.GetWorldInfo();if(e){const t=e.GetSceneGraphChildrenExportData();if(t)for(const s of t){const i=this._runtime.GetInstanceByUID(s[2]);if(i){const n=s[3];this.AddChild(i,{transformX:!!(n>>0&1),transformY:!!(n>>1&1),transformWidth:!!(n>>2&1),transformHeight:!!(n>>3&1),transformAngle:!!(n>>4&1),destroyWithParent:!!(n>>5&1),transformZElevation:!!(n>>6&1),transformOpacity:!!(n>>7&1),transformVisibility:!!(n>>8&1)})}}}}SetupPersistedSceneGraphConnections(e,t){const s=e.get(this);if(s)for(const i of s.sceneGraphJson.children){const n=t.get(i.index);if(n){const r=i.flags;this.AddChild(n,{transformX:!!(r>>0&1),transformY:!!(r>>1&1),transformWidth:!!(r>>2&1),transformHeight:!!(r>>3&1),transformAngle:!!(r>>4&1),destroyWithParent:!!(r>>5&1),transformZElevation:!!(r>>6&1),transformOpacity:!!(r>>7&1),transformVisibility:!!(r>>8&1)})}}}GetTemplateName(){const e=this._runtime.GetTemplateManager();return e?e.GetInstanceTemplateName(this):""}IsInContainer(){return null!==this._siblings}_AddSibling(e){this._siblings.push(e)}GetSiblings(){return this._siblings}HasSibling(e){return!!this.GetSibling(e)}GetSibling(e){const t=this.siblings();if(null===t||0===t.length)return!1;for(const s of t)if(s.GetObjectClass()===e)return s;return null}siblings(){return this._siblings}SetSiblingsSinglePicked(){for(const e of this.siblings())e.GetObjectClass().GetCurrentSol().SetSinglePicked(e)}_PushSiblingsToSolInstances(){for(const e of this.siblings())e.GetObjectClass().GetCurrentSol()._PushInstance(e)}_SetSiblingsToSolInstancesIndex(e){for(const t of this.siblings())t.GetObjectClass().GetCurrentSol()._GetOwnInstances()[e]=t}_PushSiblingsToSolElseInstances(){for(const e of this.siblings())e.GetObjectClass().GetCurrentSol()._PushElseInstance(e)}_SetSiblingsToSolElseInstancesIndex(e){for(const t of this.siblings())t.GetObjectClass().GetCurrentSol()._GetOwnElseInstances()[e]=t}GetPlugin(){return this._objectType.GetPlugin()}_SetIID(e){this._iid=e}GetIID(){return this._objectType._UpdateIIDs(),this._iid}GetUID(){return this._uid}GetPUID(){return this._puid}_SetTagsSetFromJson(e){e?this.SetTagsSet(new Set(e)):this._tagsSet=null}SetTagsSet(e){if(0===e.size)this._tagsSet=null;else{this._tagsSet?this._tagsSet.clear():this._tagsSet=new Set;for(const t of e)this._tagsSet.add(t)}}GetTagsSet(){return this._tagsSet??new Set}GetTagsString(){return Array.from(this.GetTagsSet()).join(" ")}GetTagAt(e){e=Math.floor(e);for(const t of this.GetTagsSet()){if(0===e)return t;--e}return""}GetBehaviorInstances(){return this._behaviorInstances}GetBehaviorInstanceFromCtor(e){if(e)for(const t of this._behaviorInstances)if(t.GetBehavior()instanceof e)return t;return null}GetBehaviorSdkInstanceFromCtor(e){if(!e)return null;const t=this.GetBehaviorInstanceFromCtor(e);return t?t.GetSdkInstance():null}GetBehaviorIndexBySID(s){const i=this._behaviorInstances;for(let e=0,t=i.length;e<t;++e)if(i[e].GetBehaviorType().GetSID()===s)return e;return-1}GetAllInstanceVariableValues(){return this._instVarValues}_GetAllInstanceVariableNames(){return this._objectType._GetAllInstanceVariableNames()}GetInstanceVariableCount(){return this._instVarValues.length}GetInstanceVariableValue(e){const t=this._instVarValues;if((e|=0)<0||e>=t.length)throw new RangeError("invalid instance variable");return t[e]}_GetInstanceVariableValueUnchecked(e){return this._instVarValues[e]}_GetInstanceVariableTypedValue(e){const t=this._instVarValues[e];return 0===this._objectType.GetInstanceVariableType(e)?!!t:t}SetInstanceVariableValue(e,t){const s=this._instVarValues;if((e|=0)<0||e>=s.length)throw new RangeError("invalid instance variable");const i=this._objectType.GetInstanceVariableType(e);switch(i){case 0:s[e]=t?1:0;break;case 1:s[e]="number"==typeof t?t:parseFloat(t);break;case 2:s[e]="string"==typeof t?t:t.toString();break;default:throw new Error("unknown instance variable type")}}SetInstanceVariableOffset(e,t){if(0!==t){const s=this._instVarValues;if((e|=0)<0||e>=s.length)throw new RangeError("invalid instance variable");const i=s[e];if("number"!=typeof i)throw"boolean"==typeof i?new Error("can not set offset of boolean variable"):"string"==typeof i?new Error("can not set offset of string variable"):new Error("unknown instance variable type");s[e]+="number"==typeof t?t:parseFloat(t)}}GetSavedDataMap(){let e=savedDataMaps.get(this);return e||(e=new Map,savedDataMaps.set(this,e)),e}GetUnsavedDataMap(){let e=unsavedDataMaps.get(this);return e||(e=new Map,unsavedDataMaps.set(this,e)),e}_HasAnyCreateDestroyHandler(e){const t=this.GetObjectClass();if(t.UserScriptDispatcher().HasAnyHandlerFor(e))return!0;for(const s of t.GetFamilies())if(s.UserScriptDispatcher().HasAnyHandlerFor(e))return!0;return!!this._runtime.UserScriptDispatcher().HasAnyHandlerFor(e)}_TriggerOnCreatedOnSelfAndRelated(){const e=new Set,t=(e.add(this),this.GetWorldInfo());if(t&&t.HasChildren())for(const s of this.allChildren())if(e.add(s),s.IsInContainer())for(const i of s.siblings())e.add(i);if(this.IsInContainer())for(const n of this.siblings())e.add(n);for(const r of e.values())r._TriggerOnCreated();this._OnHierarchyReady()}_OnCreatedCommon(){this._objectType._GetUserScriptInstanceClass()&&this.GetInterfaceClass();for(const e of this._behaviorInstances)e.PostCreate()}_OnCreatedForLoadingSavegame(){this._OnCreatedCommon()}_TriggerOnCreated(){if(this._OnCreatedCommon(),this._HasAnyCreateDestroyHandler("instancecreate")){const e=this.GetObjectClass(),t=new C33.Event("instancecreate");t.instance=this.GetInterfaceClass(),e.DispatchUserScriptEvent(t);for(const s of e.GetFamilies())s.DispatchUserScriptEvent(t);this._runtime.DispatchUserScriptEvent(t)}this._runtime.Trigger(this.GetPlugin().GetConstructor().Cnds.OnCreated,this,null)}_OnHierarchyReady(){if(this.GetPlugin().SupportsSceneGraph()){if(this.DispatchUserScriptEvent(new C33.Event("hierarchyready")),this._HasAnyCreateDestroyHandler("hierarchyready")){const e=this.GetObjectClass(),t=new C33.Event("hierarchyready");t.instance=this.GetInterfaceClass(),e.DispatchUserScriptEvent(t);for(const s of e.GetFamilies())s.DispatchUserScriptEvent(t);this._runtime.DispatchUserScriptEvent(t)}this._runtime.Trigger(this.GetPlugin().GetConstructor().Cnds.OnHierarchyReady,this,null)}}_TriggerOnDestroyed(){this._runtime.Trigger(this.GetPlugin().GetConstructor().Cnds.OnDestroyed,this,null)}_FireDestroyedScriptEvents(e){if(this._iScriptInterface){const t=new C33.Event("destroy");t.isEndingLayout=e,this.DispatchUserScriptEvent(t)}if(this._HasAnyCreateDestroyHandler("instancedestroy")){const s=this.GetObjectClass(),i=new C33.Event("instancedestroy");i.instance=this.GetInterfaceClass(),i.isEndingLayout=e,s.DispatchUserScriptEvent(i);for(const n of s.GetFamilies())n.DispatchUserScriptEvent(i);this._runtime.DispatchUserScriptEvent(i)}}_GetDebuggerProperties(){return this._sdkInst?this._sdkInst.GetDebuggerProperties():this._iScriptInterface._getDebuggerProperties()}SaveToJson(e="full",t=null){const s={},i=("full"===e?s.uid=this.GetUID():s.c3=!0,this.GetTagsSet());if(0<i.size&&(s.tags=Array.from(i)),"visual-state"!==e){const r=savedDataMaps.get(this);if(r&&r.size&&(s.ex=C33.ToSuperJSON(r)),-1!==this.GetTimeScale()&&(s.mts=this.GetTimeScale()),0<this._objectType.GetInstanceVariablesCount()){const a={},o=this._objectType.GetInstanceVariableSIDs();for(let e=0,t=this._instVarValues.length;e<t;++e)a[o[e].toString()]=this._instVarValues[e];s.ivs=a}if(this._behaviorInstances.length){const l={};for(const h of this._behaviorInstances){const c=h.SaveToJson(e);c&&(l[h.GetBehaviorType().GetSID().toString()]=c)}s.behs=l}}this._worldInfo&&(s.w=this._worldInfo._SaveToJson(e,t));const n=this._sdkInst?this._sdkInst.SaveToJson():this._iScriptInterface._saveToJson();return n&&(s.data=n),s}_OnBeforeLoad(e="full",t){this._worldInfo&&this._worldInfo._OnBeforeLoad(e)}_OnAfterLoad(e,t="full",s=null){this._worldInfo&&this._worldInfo._OnAfterLoad(e,t,s)}_OnAfterLoad2(e,t="full",s=null){this._worldInfo&&this._worldInfo._OnAfterLoad2(e,t,s)}_SetupSceneGraphConnectionsOnChangeOfLayout(){this.GetPlugin().IsWorldType()&&this._worldInfo._SetupSceneGraphConnectionsOnChangeOfLayout()}LoadFromJson(t,e="full",s){if("full"===e)this._uid=t.uid;else if(!t.c3)return;if(this._SetTagsSetFromJson(t.tags),"visual-state"!==e){let e=savedDataMaps.get(this);e&&(e.clear(),savedDataMaps.delete(this));const n=t.ex,r=(n&&(e=C33.FromSuperJSON(n),savedDataMaps.set(this,e)),this._timeScale=t.hasOwnProperty("mts")?t.mts:-1,t.ivs);if(r)for(const[a,o]of Object.entries(r)){const l=parseInt(a,10),h=this._objectType.GetInstanceVariableIndexBySID(l);if(!(h<0||h>=this._instVarValues.length)){let e=o;null===e&&(e=NaN),this._instVarValues[h]=e}}}if(this.GetPlugin().IsWorldType()){const c=t.w;if(c){const u=c.l;if(this._worldInfo.GetLayer().GetSID()!==u){const _=this._worldInfo.GetLayer(),d=_.GetLayout().GetLayerBySID(u);d?(this._worldInfo._SetLayer(d),_._RemoveInstance(this,!0),d._AddInstance(this,!0),d.SetZIndicesChanged(this),this._worldInfo.SetBboxChanged()):"full"===e&&this._runtime.DestroyInstance(this)}this._worldInfo._LoadFromJson(c,e)}}if("visual-state"!==e){const p=t.behs;if(p)for(const[m,g]of Object.entries(p)){const f=parseInt(m,10),S=this.GetBehaviorIndexBySID(f);S<0||S>=this._behaviorInstances.length||this._behaviorInstances[S].LoadFromJson(g,e)}}const i=t.data;i&&(this._sdkInst?this._sdkInst.LoadFromJson(i,e):this._iScriptInterface._loadFromJson(i))}GetInterfaceClass(){return this._iScriptInterface||this._InitUserScriptInterface()}HasScriptInterface(){return!!this._iScriptInterface}_InitUserScriptInterface(e,t){const s=this._worldInfo?e?self.ISDKWorldInstanceBase:self.IWorldInstance:e?self.ISDKInstanceBase:self.IInstance,i=e||this._sdkInst.GetScriptInterfaceClass(),n=this._objectType._GetUserScriptInstanceClass(),r=n||i||s,a=this.GetPlugin().GetSdkVersion();if(C33.AddonManager._PushInitObject(this,a),C33.AddonManager._PushInitProperties(t),this._iScriptInterface=new r,C33.AddonManager._PopInitProperties(),C33.AddonManager._PopInitObject(a),i&&!(this._iScriptInterface instanceof s))throw new TypeError(`script interface class '${i.name}' does not extend the right base class '${s.name}'`);if(n){const o=i||s;if(!(this._iScriptInterface instanceof o))throw new TypeError(`setInstanceClass(): class '${n.name}' does not extend the right base class - check it extends the right class, e.g. globalThis.InstanceType.MyObjectName`)}return this._iScriptInterface}_GetInstVarsScriptDescriptor(e){if(0!==this._instVarValues.length){const s={},i=this._objectType._GetAllInstanceVariableJsPropNames();for(let e=0,t=i.length;e<t;++e)s[i[e]]={configurable:!1,enumerable:!0,get:C33.Instance.prototype._GetInstanceVariableTypedValue.bind(this,e),set:C33.Instance.prototype.SetInstanceVariableValue.bind(this,e)};const t=Object.create(Object.prototype,s);e.instVars={value:t,writable:!1}}}_GetBehaviorsScriptDescriptor(e){const t=this._behaviorInstances;if(0!==t.length){const s={};for(const n of t)s[n.GetBehaviorType().GetJsPropName()]={value:n.GetScriptInterface(),writable:!1};const i=Object.create(Object.prototype,s);e.behaviors={value:i,writable:!1}}}DispatchUserScriptEvent(e){if(this.HasScriptInterface()){const t=this.GetInterfaceClass(),s=(e.instance=t,this._runtime),i=s.IsDebug()&&!s.GetEventSheetManager().IsInEventEngine();i&&C3Debugger.StartMeasuringScriptTime(),t.dispatchEvent(e),i&&C3Debugger.AddScriptTime()}}}}{const C33=self.C3;C33.SceneGraphInfo=class extends C33.DefendedBase{constructor(i){super(),this._owner=i,this._parent=null,this._children=[],this._startWidth=i.GetWidth(),this._startHeight=i.GetHeight(),this._startScaleX=1,this._startScaleY=1,this._parentStartAngle=0,this._ownOpacity=1,this._startOpacity=i.GetOpacity(),this._tmpSceneGraphChildren=null,this._tmpSceneGraphChildrenIndexes=null,this._indexInParent=NaN,this._originalSizeKnown=!1,this._originalWidth=NaN,this._originalHeight=NaN,this._on_instance_create=e=>{if(e.instance===this._parent.GetInstance()){const t=i.GetRuntime(),s=(t.Dispatcher().removeEventListener("instancecreate",this._on_instance_create),this._parent.GetInstance().GetSdkInstance());this._originalSizeKnown=!!s.IsOriginalSizeKnown(),this._originalWidth=this._originalSizeKnown?s.GetOriginalWidth():NaN,this._originalHeight=this._originalSizeKnown?s.GetOriginalHeight():NaN}}}Release(){this._parent=null,this._tmpSceneGraphChildren=null,this._tmpSceneGraphChildrenIndexes=null,this._indexInParent=NaN,this._originalSizeKnown=!1,this._originalWidth=NaN,this._originalHeight=NaN,C33.clearArray(this._children)}SetParent(e){if(this._ownOpacity=this._owner.GetOpacity(),this._startOpacity=this._ownOpacity,this._parent=e,this._parentStartAngle=e?e.GetAngle():0,this._parent){const t=this._owner,s=t.GetRuntime(),i=this._parent.GetInstance().GetPlugin().GetSdkVersion();if(i<2){const n=this._parent.GetInstance().GetSdkInstance();n?(this._originalSizeKnown=!!n.IsOriginalSizeKnown(),this._originalWidth=this._originalSizeKnown?n.GetOriginalWidth():NaN,this._originalHeight=this._originalSizeKnown?n.GetOriginalHeight():NaN):this._parent.GetInstance().IsDestroyed()||s.Dispatcher().addEventListener("instancecreate",this._on_instance_create)}else this._originalSizeKnown=!1,this._originalWidth=NaN,this._originalHeight=NaN}else this._originalSizeKnown=!1,this._originalWidth=NaN,this._originalHeight=NaN}GetParent(){return this._parent}HasChildren(){return 0<this._children.length}GetChildren(){return this._children}_MaybeSortChildren(){this.HasChildren()&&1!==this._children.length&&(this._tmpSceneGraphChildrenIndexes?this._children.sort((e,t)=>{const s=this._tmpSceneGraphChildrenIndexes.get(e.GetInstance()),i=this._tmpSceneGraphChildrenIndexes.get(t.GetInstance());return C33.IsFiniteNumber(s)&&C33.IsFiniteNumber(i)?s-i:0}):this._children.sort((e,t)=>{const s=e._GetSceneGraphInfo()._GetIndexInParent(),i=t._GetSceneGraphInfo()._GetIndexInParent();return C33.IsFiniteNumber(s)&&C33.IsFiniteNumber(i)?s-i:0}))}_GetIndexInParent(){return this._indexInParent}GetStartScaleX(){return this._startScaleX}SetStartScaleX(e){this._startScaleX=e}GetStartScaleY(){return this._startScaleY}SetStartScaleY(e){this._startScaleY=e}GetStartOpacity(){return this._startOpacity}GetOwnOpacity(){return this._ownOpacity}SetOwnOpacity(e){this._ownOpacity=e}_GetStartWidth(){return 0===this._startWidth?Number.EPSILON:this._startWidth}_GetStartHeight(){return 0===this._startHeight?Number.EPSILON:this._startHeight}GetParentScaleX(){if(this._owner.GetTransformWithParentWidth()){let e=this._parent,t=e.GetWidth(),s=e._GetSceneGraphInfo()._GetStartWidth();return 0===t&&(t=Number.EPSILON),s===Number.EPSILON&&t===Number.EPSILON?1:s===Number.EPSILON&&t!==Number.EPSILON&&this._originalSizeKnown?1+t/this._originalWidth:t/s}return 1}GetParentScaleY(){if(this._owner.GetTransformWithParentHeight()){let e=this._parent,t=e.GetHeight(),s=e._GetSceneGraphInfo()._GetStartHeight();return 0===t&&(t=Number.EPSILON),s===Number.EPSILON&&t===Number.EPSILON?1:s===Number.EPSILON&&t!==Number.EPSILON&&this._originalSizeKnown?1+t/this._originalHeight:t/s}return 1}GetParentStartAngle(){return 0}_SaveToJsonProperties(){return{sw:this._startWidth,sh:this._startHeight,sx:this._startScaleX,sy:this._startScaleY,psa:this._parentStartAngle,oo:this._ownOpacity,so:this._startOpacity,pi:this._owner.GetInstance().GetIndexInParent()}}_SaveToJson(e,t=null){const s=this._SaveToJsonProperties();return t&&t.selfOnly?Object.assign(s,{p:null,c:[]}):Object.assign(s,{p:this._GetParentJson(e),c:this._GetChildrenJson(e)})}_GetFlagsString(e){let t="";return e.GetTransformWithParentX()&&(t+="x"),e.GetTransformWithParentY()&&(t+="y"),e.GetTransformWithParentWidth()&&(t+="w"),e.GetTransformWithParentHeight()&&(t+="h"),e.GetTransformWithParentAngle()&&(t+="a"),e.GetTransformWithParentZElevation()&&(t+="z"),e.GetDestroyWithParent()&&(t+="d"),e.GetTransformWithParentOpacity()&&(t+="o"),e.GetTransformWithParentVisibility()&&(t+="v"),t}_GetParentJson(e){return this._parent&&this._parent.GetInstance()&&!this._parent.GetInstance().IsDestroyed()?this._GetInstanceJson(this._parent,this._owner,e):null}_GetChildrenJson(t){return this._children.map(e=>this._GetInstanceJson(e,e,t)).filter(e=>e)}_GetInstanceJson(e,t,s){const i=e.GetInstance();if(i&&i.IsDestroyed())return null;const n={};return n.uid=i.GetUID(),n.f=this._GetFlagsString(t),n.offsets=t._SaveSceneGraphPropertiesToJson(),n.data=C33.SceneGraphInfo.GetSceneGraphInstanceDataFromInstance(i),n.oci=i.GetObjectClass().GetIndex(),"state"===s?(n.inst=i.SaveToJson("full",{selfOnly:!0}),n.instIndex=NaN):(n.instIndex=i.GetObjectClass().GetInstances().indexOf(i),n.inst=null),n}_LoadFromJson(e){this._startWidth=e.sw,this._startHeight=e.sh,this._startScaleX=e.sx,this._startScaleY=e.sy,this._parentStartAngle=e.psa,this._ownOpacity=e.oo,this._startOpacity=e.so,this._indexInParent=C33.IsFiniteNumber(e.pi)?e.pi:NaN}_SetTmpSceneGraphChildren(e,t){if(!e&&!t&&this._tmpSceneGraphChildren)for(const s of this._tmpSceneGraphChildren)s.IsDestroyed()||s.HasParent()||s.GetRuntime().DestroyInstance(s);this._tmpSceneGraphChildren=e,this._tmpSceneGraphChildrenIndexes=t}_OnAfterLoad(e,t){const s=this._owner,i=s.GetRuntime(),n=new Set;if(e.p&&!this._parent){const o=e.p.uid,l=i.GetInstanceByUID(o);if(t?.setFromJson,l){const h=l.GetWorldInfo();if(l.HasChild(s.GetInstance()))this._parent=h;else{l.HasChildWithUID(s.GetInstance().GetUID())?i.DestroyInstance(s.GetInstance()):l.AddChild(s.GetInstance(),this._GetFlagsObj(e.p.f)),n.has(s)||(s._LoadSceneGraphPropertiesFromJson(e.p.offsets),this._LoadInstancePropertiesFromJson(l,e.p,t)),n.add(s);const c=l.GetWorldInfo();c._GetSceneGraphInfo()._MaybeSortChildren()}}else if(C33.IsFiniteNumber(e.p.oci)){const u=i.GetObjectClassByIndex(e.p.oci),_=(i.GetSystemPlugin(),i.CreateInstance(u,s.GetLayer(),0,0,!0));if(t?.setFromJson,_){const d=this._GetInstanceData(e.p,i),p=(d&&_.LoadFromJson(d),_.GetWorldInfo()),m=(p.GetLayer().SortAndAddInstancesByZIndex(_),_.AddChild(s.GetInstance(),this._GetFlagsObj(e.p.f)),_.GetWorldInfo());m._GetSceneGraphInfo()._MaybeSortChildren()}}}const r=[];for(const g of e.c){const f=g.uid,S=i.GetInstanceByUID(f);S&&r.push(S)}let a=0;for(const C of e.c){const y=C.uid,G=i.GetInstanceByUID(y);if(t?.setFromJson,G){if(this._tmpSceneGraphChildren){if(this._tmpSceneGraphChildren.includes(G)){const P=G;if(P.GetObjectClass()!==G.GetObjectClass()){a++;continue}if(P.IsDestroyed()){a++;continue}const A=e.c[a];if(!t?.setFromJson&&this._HasAllChildrenOfType(P,r,s)){this._UpdateInstance(a,A,s,n,t),a++;continue}if(P.HasParent()&&P.GetParent()!==s.GetInstance()){const R=this._CreateNewChildInstance(A,t);this._AddAndSetChildInstance(R,A,n,t),a++;continue}this._AddAndSetChildInstance(P.GetWorldInfo(),A,n,t,!0),a++;continue}if(this._tmpSceneGraphChildren[a]){const E=this._tmpSceneGraphChildren[a];if(E.GetObjectClass()!==G.GetObjectClass()){a++;continue}if(E.IsDestroyed()){a++;continue}const v=e.c[a];if(!t?.setFromJson&&this._HasAllChildrenOfType(E,r,s)){this._UpdateInstance(a,v,s,n,t),a++;continue}if(E.HasParent()&&E.GetParent()!==s.GetInstance()){const x=this._CreateNewChildInstance(v,t);this._AddAndSetChildInstance(x,v,n,t),a++;continue}this._AddAndSetChildInstance(E.GetWorldInfo(),v,n,t,!0),a++;continue}}const I=G.GetObjectClass(),T=this._GetInstancesOfObjectClassCount(r,I),b=s.GetInstance().GetChildrenOfObjectClass(I).length;if(T===b){const w=s.GetInstance().GetChildAt(a);if(w){const M=w.GetWorldInfo();M&&(n.has(M)||(M._LoadSceneGraphPropertiesFromJson(C.offsets),this._LoadInstancePropertiesFromJson(w,C,t)),n.add(M))}a++;continue}if(G.HasParent()&&G.GetParent()!==s.GetInstance()){const D=this._CreateNewChildInstance(C,t);this._AddAndSetChildInstance(D,C,n,t),a++;continue}this._AddAndSetChildInstance(G.GetWorldInfo(),C,n,t)}else if(this._tmpSceneGraphChildren&&this._tmpSceneGraphChildren[a]){const O=this._tmpSceneGraphChildren[a],F=i.GetObjectClassByIndex(this._GetObjectClassIndex(C));if(O.GetObjectClass()!==F){a++;continue}if(O.IsDestroyed()){a++;continue}const L=e.c[a];if(!t?.setFromJson&&this._HasAllChildrenOfType(O,r,s)){this._UpdateInstance(a,L,s,n,t),a++;continue}if(O.HasParent()&&O.GetParent()!==s.GetInstance()){const B=this._CreateNewChildInstance(L,t);this._AddAndSetChildInstance(B,L,n,t),a++;continue}this._AddAndSetChildInstance(O.GetWorldInfo(),L,n,t)}else{const k=this._CreateNewChildInstance(C,t);this._AddAndSetChildInstance(k,C,n,t)}a++}}_HasAllChildrenOfType(e,t,s){const i=e.GetObjectClass(),n=this._GetInstancesOfObjectClassCount(t,i),r=s.GetInstance().GetChildrenOfObjectClass(i).length;return n===r}_UpdateInstance(e,t,s,i,n){const r=s.GetInstance().GetChildAt(e,t);if(r){const a=r.GetWorldInfo();a&&(i.has(a)||(a._LoadSceneGraphPropertiesFromJson(t.offsets),this._LoadInstancePropertiesFromJson(r,t,n)),i.add(a))}}_GetFlagsObj(e){const t={};return t.transformX=e.includes("x"),t.transformY=e.includes("y"),t.transformWidth=e.includes("w"),t.transformHeight=e.includes("h"),t.transformAngle=e.includes("a"),t.transformZElevation=e.includes("z"),t.destroyWithParent=e.includes("d"),t.transformOpacity=e.includes("o"),t.transformVisibility=e.includes("v"),t}_GetObjectClassIndex(e){return C33.IsFiniteNumber(e.oci)?e.oci:e[1]}_CreateNewChildInstance(i,n){if(C33.IsFiniteNumber(i.oci)){let e=this._owner,t=e.GetRuntime(),s;if(i.data)s=t.CreateInstanceFromData(i.data,e.GetLayer(),!1,0,0,!1,!0);else{const r=t.GetObjectClassByIndex(i.oci);s=t.CreateInstance(r,e.GetLayer(),0,0,!0)}if(n?.setFromJson,s){const a=this._GetInstanceData(i,t),o=(a&&s.LoadFromJson(a),s.GetWorldInfo());return o.GetLayer().SortAndAddInstancesByZIndex(s,!0),o}}}_AddAndSetChildInstance(e,t,s,i,n=!0){const r=this._owner,a=r.AddChild(e,this._GetFlagsObj(t.f));a&&n&&(s.has(e)||(e._LoadSceneGraphPropertiesFromJson(t.offsets),this._LoadInstancePropertiesFromJson(e.GetInstance(),t,i)),s.add(e)),this._MaybeSortChildren()}_LoadInstancePropertiesFromJson(e,t,s){let i=this._GetInstanceData(t,this._owner.GetRuntime());i&&((i=JSON.parse(JSON.stringify(i))).w=null,e.LoadFromJson(i))}_GetInstancesOfObjectClassCount(e,t){return e.filter(e=>e.GetObjectClass().GetName()===t.GetName()).length}_GetInstanceData(e,t){if(C33.IsFiniteNumber(e.instIndex)){const s=t.GetObjectClassByIndex(e.oci),i=s._GetLoadInstancesJson();return i?i[e.instIndex]:null}return C33.IsString(e.inst)?JSON.parse(e.inst):e.inst||void 0}static GetSceneGraphInstanceDataFromInstance(e){let t=e.GetWorldInfo().GetLayer().GetInitialInstanceData(e.GetUID());if(!t)return null;t=JSON.parse(JSON.stringify(t));const s=[];for(const i of[...e.GetChildren()]){const n=i.GetWorldInfo();s.push([n.GetLayout().GetSID(),n.GetLayer().GetIndex(),i.GetUID(),C33.SceneGraphInfo._GetFlagsNumber(n),i.GetObjectClass().IsInContainer()?1:0,n.GetZIndex(),C33.SceneGraphInfo.GetSceneGraphInstanceDataFromInstance(i)])}return C33.IsArray(t[0][14])?t[0][14][1]=s:(t[0][14]=[],t[0][14][0]=C33.SceneGraphInfo._GetDefaultFlagsNumber(),t[0][14][1]=s,t[0][14][2]=e.GetWorldInfo().GetZIndex()),t}static _GetFlagsNumber(e){let t=0;return(t|=Number(e.GetTransformWithParentVisibility())<<8)|Number(e.GetTransformWithParentOpacity())<<7|Number(e.GetTransformWithParentZElevation())<<6|Number(e.GetDestroyWithParent())<<5|Number(e.GetTransformWithParentAngle())<<4|Number(e.GetTransformWithParentHeight())<<3|Number(e.GetTransformWithParentWidth())<<2|Number(e.GetTransformWithParentY())<<1|Number(e.GetTransformWithParentX())<<0}static _GetDefaultFlagsNumber(e){let t=0;return t,511}}}{let C33=self.C3,glMatrix=self.glMatrix,vec32=glMatrix.vec3,vec42=glMatrix.vec4,tempRect=C33.New(C33.Rect),tempQuad=C33.New(C33.Quad),bboxChangeEvent=C33.New(C33.Event,"bboxchange",!1),tempColor=C33.New(C33.Color,0,0,0,0),tempCollisionPoly=C33.New(C33.CollisionPoly),DEFAULT_COLOR=C33.New(C33.Color,1,1,1,1),DEFAULT_RENDER_CELLS=C33.New(C33.Rect,0,0,-1,-1),DEFAULT_COLLISION_CELLS=C33.New(C33.Rect,0,0,-1,-1),VALID_SET_MESH_POINT_MODES=new Set(["absolute","relative"]),EMPTY_ARRAY=[],enableUpdateRendererStateGroup=!0,FLAG_IS_VISIBLE=1,FLAG_BBOX_CHANGED=2,FLAG_ENABLE_BBOX_CHANGED_EVENT=4,FLAG_COLLISION_ENABLED=8,FLAG_COLLISION_CELL_CHANGED=16,FLAG_SOLID_FILTER_INCLUSIVE=32,FLAG_HAS_ANY_ACTIVE_EFFECT=64,FLAG_IS_ROTATABLE=128,FLAG_DESTROYED=256,FLAG_DESTROY_WITH_PARENT=512,FLAG_TRANSFORM_WITH_PARENT_X=1024,FLAG_TRANSFORM_WITH_PARENT_Y=2048,FLAG_TRANSFORM_WITH_PARENT_W=4096,FLAG_TRANSFORM_WITH_PARENT_H=8192,FLAG_TRANSFORM_WITH_PARENT_A=16384,FLAG_TRANSFORM_WITH_PARENT_Z_ELEVATION=32768,FLAG_TRANSFORM_WITH_PARENT_OPACITY=1<<22,FLAG_TRANSFORM_WITH_PARENT_VISIBILITY=1<<23,MASK_ALL_SCENE_GRAPH_FLAGS=FLAG_DESTROY_WITH_PARENT|FLAG_TRANSFORM_WITH_PARENT_X|FLAG_TRANSFORM_WITH_PARENT_Y|FLAG_TRANSFORM_WITH_PARENT_W|FLAG_TRANSFORM_WITH_PARENT_H|FLAG_TRANSFORM_WITH_PARENT_A|FLAG_TRANSFORM_WITH_PARENT_Z_ELEVATION|FLAG_TRANSFORM_WITH_PARENT_OPACITY|FLAG_TRANSFORM_WITH_PARENT_VISIBILITY,FLAG_MESH_CHANGED=65536,FLAG_PHYSICS_BODY_CHANGED=1<<17,FLAG_SIN_COS_ANGLE_CHANGED=1<<18,FLAG_USE_POINTS_SHADER_PROGRAM=1<<19,FLAG_DRAW_BACK_FACE_ONLY=1<<20,FLAG_DRAW_NON_BACK_FACES_ONLY=1<<21,FLAG_BLEND_MODE_BIT_OFFSET=26,FLAG_BLEND_MODE_MASK=31<<FLAG_BLEND_MODE_BIT_OFFSET,sceneGraphExportDataMap=new WeakMap,sceneGraphZIndexMap=new WeakMap;C33.WorldInfo=class extends C33.DefendedBase{constructor(e,t){super(),this._inst=e,this._objectClass=e.GetObjectClass(),this._runtime=e.GetRuntime(),this._layer=t,this._objectClass._OnWorldInstanceLayerChanged(this,null,t),this._zIndex=-1,this._htmlZIndex=-1,this._flags=FLAG_IS_VISIBLE|FLAG_BBOX_CHANGED|FLAG_COLLISION_ENABLED|FLAG_COLLISION_CELL_CHANGED|FLAG_MESH_CHANGED|FLAG_PHYSICS_BODY_CHANGED,this._objectClass.GetPlugin().IsRotatable()&&(this._flags|=FLAG_IS_ROTATABLE),this._x=NaN,this._y=NaN,this._zElevation=NaN,this._w=NaN,this._h=NaN,this._depth=NaN,this._a=NaN,this._sinA=NaN,this._cosA=NaN,this._ox=NaN,this._oy=NaN,this._boundingBox=C33.New(C33.Rect),this._boundingQuad=C33.New(C33.Quad),this._collisionCells=DEFAULT_COLLISION_CELLS,this._renderCells=DEFAULT_RENDER_CELLS,this._sourceCollisionPoly=null,this._transformedPolyInfo=null,this._solidFilterTags=null,this._color=DEFAULT_COLOR,this._colorPremultiplied=DEFAULT_COLOR,this._stateGroup=null,this._instanceEffectList=null,this._inst.GetObjectClass().UsesEffects()&&(this._instanceEffectList=C33.New(C33.InstanceEffectList,this._inst,this)),this._sceneGraphInfo=null,this._tmpSceneGraphChildren=null,this._tmpSceneGraphChildrenIndexes=null,this._tmpHierarchyPosition=-1,this._meshInfo=null}_MarkDestroyed(){this._flags|=FLAG_DESTROYED}Release(){if(this._objectClass._OnWorldInstanceLayerChanged(this,this._layer,null),this._stateGroup&&(this._runtime.GetRenderer().ReleaseStateGroup(this._stateGroup),this._stateGroup=null),this._sourceCollisionPoly=null,this._transformedPolyInfo&&(this._transformedPolyInfo.poly.Release(),this._transformedPolyInfo=null),this._solidFilterTags&&(this._solidFilterTags.clear(),this._solidFilterTags=null),this.ReleaseMesh(),this._instanceEffectList&&this._instanceEffectList.Release(),this.HasParent()&&this.GetParent().RemoveChild(this),this.HasChildren()){const e=[...this.GetChildren()];for(const t of e)this.RemoveChild(t)}this._ReleaseSceneGraphInfo(),this._ReleaseTmpSceneGraphInfo(),sceneGraphExportDataMap.delete(this),sceneGraphZIndexMap.delete(this),this._inst=null,this._objectClass=null,this._runtime=null,this._layer=null}Init(e){if(enableUpdateRendererStateGroup=!1,this.SetXY(e[0],e[1]),this.SetZElevation(e[2]),this.SetSize(e[3],e[4]),this._depth=0,this.IsRotatable()?this.SetAngle(e[6]):this._a=0,tempColor.setFromJSON(e[7]),this._SetColor(tempColor),this.SetOriginX(e[8]),this.SetOriginY(e[9]),this.SetBlendMode(e[10]),this._instanceEffectList&&this._instanceEffectList._LoadEffectParameters(e[12]),e[14]&&sceneGraphExportDataMap.set(this,{childrenData:e[14][1],zIndexData:e[14][2]}),e[15]){const t=e[15],i=(this.CreateMesh(t[0],t[1]),this.GetSourceMesh()),n=t[2];for(let s=0,e=n.length;s<e;++s){const r=n[s];for(let e=0,t=r.length;e<t;++e){const a=r[e],o=i.GetMeshPointAt(e,s);o.SetX(a[0]),o.SetY(a[1]),o.SetZElevation(a[2]),o.SetU(a[3]),o.SetV(a[4])}}}if(e[16]){const s=e[16][0],l=e[16][1],h=!!l,c=!h,u=this._runtime.GetTemplateManager();h&&u&&u.MapInstanceToTemplateName(this.GetInstance(),l),c&&u&&u.MapInstanceToTemplateName(this.GetInstance(),s)}enableUpdateRendererStateGroup=!0,this._UpdateRendererStateGroup()}InitNoData(){this._x=0,this._y=0,this._zElevation=0,this._w=0,this._h=0,this._depth=0,this._a=0,this._sinA=0,this._cosA=1,this._ox=0,this._oy=0,this._UpdateRendererStateGroup()}GetRuntime(){return this._runtime}GetObjectClass(){return this._objectClass}GetInstance(){return this._inst}_GetParentOffsetAngle(){return this.GetTransformWithParentAngle()?this._MaybeReflectAngleForMirrorFlip(this.GetParent()._GetAngleNoReflect()-this._sceneGraphInfo.GetParentStartAngle()):0}SetX(e){if(e=+e,this.GetTransformWithParentX()){const t=this._sceneGraphInfo,s=e-this.GetX(),i=-this._GetParentOffsetAngle();0==i?this._x+=s/t.GetParentScaleX():(this._x+=Math.cos(i)*s/t.GetParentScaleX(),this.GetTransformWithParentY()&&(this._y+=Math.sin(i)*s/t.GetParentScaleY()))}else this._x=e}OffsetX(e,t=!1){e=+e,!t&&this.GetTransformWithParentX()?this.SetX(this.GetX()+e):this._x+=e}GetX(){if(this.GetTransformWithParentX()){let e=this._x,t=this._sceneGraphInfo,s=this.GetParent(),i=this._GetParentOffsetAngle();return 0===i?e*=t.GetParentScaleX():(e=e*t.GetParentScaleX()*Math.cos(i),this.GetTransformWithParentY()&&(e-=this._y*t.GetParentScaleY()*Math.sin(i))),s.GetX()+e}return this._x}SetY(e){if(e=+e,this.GetTransformWithParentY()){const t=this._sceneGraphInfo,s=e-this.GetY(),i=-this._GetParentOffsetAngle();0==i?this._y+=s/t.GetParentScaleY():(this.GetTransformWithParentX()&&(this._x-=Math.sin(i)*s/t.GetParentScaleX()),this._y+=Math.cos(i)*s/t.GetParentScaleY())}else this._y=e}OffsetY(e,t=!1){e=+e,!t&&this.GetTransformWithParentY()?this.SetY(this.GetY()+e):this._y+=e}GetY(){if(this.GetTransformWithParentY()){let e=this._y,t=this._sceneGraphInfo,s=this.GetParent(),i=this._GetParentOffsetAngle();return 0===i?e*=t.GetParentScaleY():(e=e*t.GetParentScaleY()*Math.cos(i),this.GetTransformWithParentX()&&(e+=this._x*t.GetParentScaleX()*Math.sin(i))),s.GetY()+e}return this._y}SetXY(e,t){if(e=+e,t=+t,this.GetTransformWithParentXOrY()){const s=this.GetTransformWithParentX(),i=this.GetTransformWithParentY(),n=this._sceneGraphInfo,r=e-this.GetX(),a=t-this.GetY(),o=-this._GetParentOffsetAngle();if(0==o)s?this._x+=r/n.GetParentScaleX():this._x=e,i?this._y+=a/n.GetParentScaleY():this._y=t;else{const l=Math.sin(o),h=Math.cos(o);s?this._x+=i?(h*r-l*a)/n.GetParentScaleX():h*r/n.GetParentScaleX():this._x=e,i?this._y+=s?(l*r+h*a)/n.GetParentScaleY():h*a/n.GetParentScaleY():this._y=t}}else this._x=e,this._y=t}GetXY(){return[this.GetX(),this.GetY()]}OffsetXY(e,t){e=+e,t=+t,this.GetTransformWithParentXOrY()?this.SetXY(this.GetX()+e,this.GetY()+t):(this._x+=e,this._y+=t)}EqualsXY(e,t){return this.GetX()===e&&this.GetY()===t}SetZElevation(e){if(e=+e,this.GetTransformWithParentZElevation()&&(e-=this.GetParent().GetZElevation()),this._zElevation!==e){this._zElevation=e,this._UpdateZElevation();const t=this.GetLayer();0!==this._zElevation&&t._SetAnyInstanceZElevated(),t.SetZIndicesChanged(this)}}_UpdateZElevation(){if(this._UpdateRendererStateGroup(),this.HasChildren()){const s=this.GetChildren();for(let e=0,t=s.length;e<t;e++){const i=s[e];i.GetTransformWithParentZElevation()&&i._UpdateZElevation()}}}OffsetZElevation(e){this.SetZElevation(this.GetZElevation()+e)}GetZElevation(){return this.GetTransformWithParentZElevation()?this.GetParent().GetZElevation()+this._zElevation:this._zElevation}GetTotalZElevation(){return this.GetLayer().GetZElevation()+this.GetZElevation()}IsOriginalSizeKnown(){const e=this.GetInstance().GetPlugin().GetSdkVersion();return e<2&&this.GetInstance().GetSdkInstance().IsOriginalSizeKnown()}SetWidth(e){if(e=+e,this.GetTransformWithParentWidth()){const t=this.GetWidth();0===t?this._w=Number.EPSILON:this._w*=e/t}else this._w=e;this._MarkSinCosAngleChanged()}OffsetWidth(e,t){e=+e,!t&&this.GetTransformWithParentWidth()?this.SetWidth(this.GetWidth()+e):this._w+=e,this._MarkSinCosAngleChanged()}GetWidth(){if(this.GetTransformWithParentWidth()){const e=this.GetParent(),t=e.GetWidth(),s=e._GetSceneGraphInfo()._GetStartWidth();return s===Number.EPSILON?(this._GetSceneGraphInfo()._GetStartWidth()+t)*this._w:t*this._w}return this._w}SetHeight(e){if(e=+e,this.GetTransformWithParentHeight()){const t=this.GetHeight();0===t?this._h=Number.EPSILON:this._h*=e/t}else this._h=e;this._MarkSinCosAngleChanged()}OffsetHeight(e,t){e=+e,!t&&this.GetTransformWithParentHeight()?this.SetHeight(this.GetHeight()+e):this._h+=e,this._MarkSinCosAngleChanged()}GetHeight(){if(this.GetTransformWithParentHeight()){const e=this.GetParent(),t=e.GetHeight(),s=e._GetSceneGraphInfo()._GetStartHeight();return s===Number.EPSILON?(this._GetSceneGraphInfo()._GetStartHeight()+t)*this._h:t*this._h}return this._h}SetSize(e,t){if(e=+e,t=+t,this.GetTransformWithParentWidth()){const s=this.GetWidth();0===s?this._w=Number.EPSILON:this._w*=e/s}else this._w=e;if(this.GetTransformWithParentHeight()){const i=this.GetHeight();0===i?this._h=Number.EPSILON:this._h*=t/i}else this._h=t;this._MarkSinCosAngleChanged()}GetSize(){return[this.GetWidth(),this.GetHeight()]}GetDepth(){return this._depth}SetDepth(e){if(e<0)throw new RangeError("invalid depth");this._depth=e}GetSceneGraphScale(){if(this.HasParent()){const e=this._sceneGraphInfo;return Math.min(e.GetParentScaleX(),e.GetParentScaleY())}return 1}IsRotatable(){return 0!=(this._flags&FLAG_IS_ROTATABLE)}SetAngle(e){e=+e,this.IsRotatable()&&(this.GetTransformWithParentAngle()&&(e-=this.GetParent().GetAngle()),e=C33.clampAngle(e),this._a!==e)&&(this._a=e,this._MarkSinCosAngleChanged())}OffsetAngle(e){0!=(e=+e)&&this.IsRotatable()&&(this._a=C33.clampAngle(this._a+e),this._MarkSinCosAngleChanged())}_MarkSinCosAngleChanged(){if(this._flags|=FLAG_SIN_COS_ANGLE_CHANGED,this.HasChildren()){const s=this.GetChildren();for(let e=0,t=s.length;e<t;e++)s[e]._MarkSinCosAngleChanged()}}GetAngle(){return this.GetTransformWithParentAngle()&&this.IsRotatable()?this._MaybeReflectAngleForMirrorFlip(C33.clampAngle(this.GetParent()._GetAngleNoReflect()+this._a)):this._a}_GetAngleNoReflect(){return this.GetTransformWithParentAngle()&&this.IsRotatable()?C33.clampAngle(this.GetParent()._GetAngleNoReflect()+this._a):this._a}_MaybeReflectAngleForMirrorFlip(e){return this.GetTransformWithParentWidth()&&this.GetTopParent().GetWidth()<0&&(e=C33.clampAngle(C33.angleReflect(e,this.GetTopParent().GetAngle()+Math.PI))),this.GetTransformWithParentHeight()&&this.GetTopParent().GetHeight()<0?C33.angleReflect(e,this.GetTopParent().GetAngle()):e}_NeedsReflectAngleForMirrorOrFlip(){const e=this.GetParent();return!!(this.GetTransformWithParentWidth()&&e.GetWidth()<0)||!!(this.GetTransformWithParentHeight()&&e.GetHeight()<0)}_NeedsReflectAngleForMirrorAndFlip(){const e=this.GetParent();return!!(this.GetTransformWithParentWidth()&&e.GetWidth()<0&&this.GetTransformWithParentHeight()&&e.GetHeight()<0)}_MaybeUpdateSinCosAngle(){const e=this._flags;if(0!=(e&FLAG_SIN_COS_ANGLE_CHANGED)){const t=this.GetAngle();this._sinA=Math.sin(t),this._cosA=Math.cos(t),this._flags=e&~FLAG_SIN_COS_ANGLE_CHANGED}}GetSinAngle(){return this._MaybeUpdateSinCosAngle(),this._sinA}GetCosAngle(){return this._MaybeUpdateSinCosAngle(),this._cosA}SetOriginX(e){this._ox=+e}OffsetOriginX(e){this._ox+=+e}GetOriginX(){return this._ox}SetOriginY(e){this._oy=+e}OffsetOriginY(e){this._oy+=+e}GetOriginY(){return this._oy}_SetColor(e){this._color.equals(e)||(this._color===DEFAULT_COLOR?(this._color=C33.New(C33.Color,e),this._colorPremultiplied=C33.New(C33.Color,e),this._colorPremultiplied.premultiply()):e.equalsRgba(1,1,1,1)?(this._color=DEFAULT_COLOR,this._colorPremultiplied=DEFAULT_COLOR):(this._color.set(e),this._colorPremultiplied.set(e),this._colorPremultiplied.premultiply()),this._UpdateRendererStateGroup())}SetOpacity(e){if(e=C33.clamp(+e,0,1),this.GetTransformWithParentOpacity()){if(this._GetSceneGraphInfo().GetOwnOpacity()===e)return;this._GetSceneGraphInfo().SetOwnOpacity(e),e=this.GetOpacity()}else if(this._color.a===e)return;this._SetColorWithOpacity(e)}_SetOpacityOfChildren(){if(this.HasChildren()){const s=this.GetChildren();for(let e=0,t=s.length;e<t;e++){const i=s[e];i._SetColorWithOpacity(i.GetOpacity())}}}_SetColorWithOpacity(e){tempColor.copyRgb(this._color),tempColor.a=e,this._SetColor(tempColor),this._SetOpacityOfChildren()}OffsetOpacity(e){this.GetTransformWithParentOpacity()?this.SetOpacity(this._GetSceneGraphInfo().GetOwnOpacity()+e):this.SetOpacity(this.GetOpacity()+e)}GetOpacity(){return this.GetTransformWithParentOpacity()?this.GetParent().GetOpacity()*this._GetSceneGraphInfo().GetOwnOpacity():this._color.a}SetUnpremultipliedColor(e){this._color.equalsIgnoringAlpha(e)||(tempColor.copyRgb(e),tempColor.a=this.GetOpacity(),this._SetColor(tempColor))}SetUnpremultipliedColorRGB(e,t,s){tempColor.setRgb(e,t,s),this.SetUnpremultipliedColor(tempColor)}OffsetUnpremultipliedColorRGB(e,t,s){0===e&&0===t&&0===s||(tempColor.copyRgb(this._color),tempColor.r+=e,tempColor.g+=t,tempColor.b+=s,this.SetUnpremultipliedColor(tempColor))}GetUnpremultipliedColor(){return this._color}GetPremultipliedColor(){return this._colorPremultiplied}GetDestroyWithParent(){return 0!=(this._flags&FLAG_DESTROY_WITH_PARENT)}SetDestroyWithParent(e){this._SetFlag(FLAG_DESTROY_WITH_PARENT,e)}GetTransformWithParentX(){return 0!=(this._flags&FLAG_TRANSFORM_WITH_PARENT_X)}SetTransformWithParentX(e){this._SetFlag(FLAG_TRANSFORM_WITH_PARENT_X,e)}GetTransformWithParentY(){return 0!=(this._flags&FLAG_TRANSFORM_WITH_PARENT_Y)}GetTransformWithParentXOrY(){return 0!=(this._flags&(FLAG_TRANSFORM_WITH_PARENT_X|FLAG_TRANSFORM_WITH_PARENT_Y))}SetTransformWithParentY(e){this._SetFlag(FLAG_TRANSFORM_WITH_PARENT_Y,e)}GetTransformWithParentWidth(){return 0!=(this._flags&FLAG_TRANSFORM_WITH_PARENT_W)}SetTransformWithParentWidth(e){this._SetFlag(FLAG_TRANSFORM_WITH_PARENT_W,e)}GetTransformWithParentHeight(){return 0!=(this._flags&FLAG_TRANSFORM_WITH_PARENT_H)}SetTransformWithParentHeight(e){this._SetFlag(FLAG_TRANSFORM_WITH_PARENT_H,e)}GetTransformWithParentAngle(){return 0!=(this._flags&FLAG_TRANSFORM_WITH_PARENT_A)}SetTransformWithParentAngle(e){this._SetFlag(FLAG_TRANSFORM_WITH_PARENT_A,e)}GetTransformWithParentZElevation(){return 0!=(this._flags&FLAG_TRANSFORM_WITH_PARENT_Z_ELEVATION)}SetTransformWithParentZElevation(e){this._SetFlag(FLAG_TRANSFORM_WITH_PARENT_Z_ELEVATION,e)}GetTransformWithParentOpacity(){return 0!=(this._flags&FLAG_TRANSFORM_WITH_PARENT_OPACITY)}SetTransformWithParentOpacity(e){this._SetFlag(FLAG_TRANSFORM_WITH_PARENT_OPACITY,e)}GetTransformWithParentVisibility(){return 0!=(this._flags&FLAG_TRANSFORM_WITH_PARENT_VISIBILITY)}SetTransformWithParentVisibility(e){this._SetFlag(FLAG_TRANSFORM_WITH_PARENT_VISIBILITY,e)}_ClearAllSceneGraphFlags(){this._flags&=~MASK_ALL_SCENE_GRAPH_FLAGS}AddChild(e,t){if(e===this)return!1;if(e.HasParent())return!1;if(this._HasChildRecursive(e))return!1;if(this._HasAnyParent(e))return!1;const s=e.GetX(),i=e.GetY(),n=e.GetWidth(),r=e.GetHeight(),a=e.GetAngle(),o=e.GetZElevation(),l=e.GetOpacity(),h=(e._SetParent(this),e.SetTransformWithParentX(t.transformX),e.SetTransformWithParentY(t.transformY),e.SetTransformWithParentWidth(t.transformWidth),e.SetTransformWithParentHeight(t.transformHeight),e.SetTransformWithParentAngle(t.transformAngle),e.SetTransformWithParentZElevation(t.transformZElevation),e.SetTransformWithParentOpacity(t.transformOpacity),e.SetTransformWithParentVisibility(t.transformVisibility),e.SetDestroyWithParent(t.destroyWithParent),s-this.GetX()),c=i-this.GetY(),u=-this.GetAngle(),_=Math.cos(u),d=Math.sin(u);if(t.transformX&&(t.transformAngle?e._x=h*_-c*d:e._x=h,t.transformWidth)){const p=this.GetWidth()/this._sceneGraphInfo._GetStartWidth();0!=p&&(e._x/=p)}if(t.transformY&&(t.transformAngle?e._y=h*d+c*_:e._y=c,t.transformHeight)){const m=this.GetHeight()/this._sceneGraphInfo._GetStartHeight();0!=m&&(e._y/=m)}if(t.transformWidth){const g=this.GetWidth();0===g||g===Number.EPSILON?(e._w=1,e._sceneGraphInfo.SetStartScaleX(1)):(e._w=n/this.GetWidth(),e._sceneGraphInfo.SetStartScaleX(e._w))}if(t.transformHeight){const f=this.GetHeight();0===f||f===Number.EPSILON?(e._h=1,e._sceneGraphInfo.SetStartScaleY(1)):(e._h=r/this.GetHeight(),e._sceneGraphInfo.SetStartScaleY(e._h))}return t.transformAngle&&(e._a=a-this.GetAngle()),t.transformZElevation&&(e._zElevation=o-this.GetZElevation()),t.transformOpacity&&e._sceneGraphInfo.SetOwnOpacity(l),t.transformVisibility&&e.SetVisible(this.IsVisible()),this._AddChildToSceneGraphInfo(e),this.SetBboxChanged(),this._SetOpacityOfChildren(),!0}RemoveChild(e){if(e.GetParent()===this){const t=e.GetX(),s=e.GetY(),i=e.GetWidth(),n=e.GetHeight(),r=e.GetAngle(),a=e.GetZElevation(),o=e.GetOpacity();e._SetParent(null),e._ClearAllSceneGraphFlags(),e.SetXY(t,s),e.SetSize(i,n),e.SetAngle(r),e.SetZElevation(a),e.SetOpacity(o),this._RemoveChildFromSceneGraphInfo(e),this.SetBboxChanged()}}GetTmpHierarchyPosition(){return this._tmpHierarchyPosition}_ResetAllSceneGraphState(){this._BuildTmpSceneGraphData();const e=[...this.children()];for(const s of e)this.RemoveChild(s);const t=this.GetParent();t&&t.RemoveChild(this),this._ClearAllSceneGraphFlags()}_BuildTmpSceneGraphData(){if(this._SetTmpHierarchyPosition(),!this._tmpSceneGraphChildren){const t=[...this.children()];t.length&&(this._tmpSceneGraphChildren=[],this._tmpSceneGraphChildrenIndexes=new WeakMap);let e=0;for(const s of t){const i=s.GetInstance();this._tmpSceneGraphChildren.push(i),this._tmpSceneGraphChildrenIndexes.set(i,e),e++}}const e=this.GetParent();e&&e._BuildTmpSceneGraphData()}_SetTmpHierarchyPosition(){if(-1===this._tmpHierarchyPosition){const e=[...this.parents()];this._tmpHierarchyPosition=e.length;for(const s of e)s._SetTmpHierarchyPosition();const t=[...this.children()];for(const i of t)i._SetTmpHierarchyPosition()}}_ReleaseTmpSceneGraphInfo(){this._tmpSceneGraphChildren&&(this._tmpSceneGraphChildren.length=0),this._tmpSceneGraphChildren=null,this._tmpSceneGraphChildrenIndexes=null;const e=this.GetParent();e&&e._ReleaseTmpSceneGraphInfo(),this._tmpHierarchyPosition=-1}HasParent(){return null!==this.GetParent()}GetParent(){const e=this._sceneGraphInfo;return null!==e?e.GetParent():null}GetTopParent(){let e=this;for(;e.HasParent();)e=e.GetParent();return e}*parents(){let e=this.GetParent();for(;e;)yield e,e=e.GetParent()}HasChild(e){return this.GetChildren().includes(e)}HasChildren(){const e=this._sceneGraphInfo;return null!==e&&e.HasChildren()}GetChildren(){const e=this._sceneGraphInfo;return null!==e?e.GetChildren():EMPTY_ARRAY}children(){return this.GetChildren()}*allChildren(){for(const e of this.children())yield e,yield*e.allChildren()}GetChildCount(){return this.GetChildren().length}GetAllChildCount(){return[...this.allChildren()].length}GetChildAt(e){const t=this.GetChildren();return(e=Math.floor(+e))<0||e>=t.length?null:t[e]}GetChildIndex(t){if(t){const s=this.GetChildren();if(s)for(let e=0;e<s.length;e++)if(t===s[e])return e}return NaN}_CreateSceneGraphInfo(e){this._sceneGraphInfo||(this._sceneGraphInfo=C33.New(C33.SceneGraphInfo,this)),e&&this._sceneGraphInfo.SetParent(e)}_GetSceneGraphInfo(){return this._sceneGraphInfo}_ReleaseSceneGraphInfo(){this._sceneGraphInfo&&(this._sceneGraphInfo.Release(),this._sceneGraphInfo=null)}_SetParent(e){e?(e._CreateSceneGraphInfo(null),this._CreateSceneGraphInfo(e)):(this._sceneGraphInfo&&this._sceneGraphInfo.SetParent(null),this.HasChildren()||this._ReleaseSceneGraphInfo())}_HasAnyParent(e){if(!this.HasParent())return!1;const t=this.GetParent();return t===e||t._HasAnyParent(e)}_HasChildRecursive(e){if(this.HasChild(e))return!0;for(const t of this.GetChildren())if(t._HasChildRecursive(e))return!0;return!1}_AddChildToSceneGraphInfo(e){this._sceneGraphInfo.GetChildren().push(e)}_RemoveChildFromSceneGraphInfo(e){const t=this._sceneGraphInfo.GetChildren(),s=t.indexOf(e);-1!==s&&t.splice(s,1),0!==t.length||this.HasParent()||this._ReleaseSceneGraphInfo(),e.HasChildren()||e._ReleaseSceneGraphInfo()}GetSceneGraphChildrenExportData(){const e=sceneGraphExportDataMap.get(this);return e?e.childrenData:null}GetSceneGraphZIndexExportData(){const e=sceneGraphExportDataMap.get(this);return e?e.zIndexData:NaN}GetSceneGraphZIndex(){const e=sceneGraphZIndexMap.get(this);return C33.IsFiniteNumber(e)?e:NaN}SetSceneGraphZIndex(e){sceneGraphZIndexMap.set(this,e)}SetUsePointsShaderProgram(){this._SetFlag(FLAG_USE_POINTS_SHADER_PROGRAM,!0),this._UpdateRendererStateGroup()}_UpdateRendererStateGroup(){if(enableUpdateRendererStateGroup){const t=this._runtime.GetRenderer();this._stateGroup&&t.ReleaseStateGroup(this._stateGroup);let e;e=0!=(this._flags&FLAG_USE_POINTS_SHADER_PROGRAM)?t.GetPointsRenderingProgram()||"<point>":t.GetTextureFillShaderProgram()||"<default>",this._stateGroup=t.AcquireStateGroup(e,this.GetBlendMode(),this._colorPremultiplied,this.GetZElevation())}}GetRendererStateGroup(){return this._stateGroup}HasDefaultColor(){return this._color===DEFAULT_COLOR}SetBlendMode(e){if((e|=0)<0||31<e)throw new RangeError("invalid blend mode");this.GetBlendMode()!==e&&(this._flags=this._flags&~FLAG_BLEND_MODE_MASK|e<<FLAG_BLEND_MODE_BIT_OFFSET,this._UpdateRendererStateGroup())}GetBlendMode(){return(this._flags&FLAG_BLEND_MODE_MASK)>>FLAG_BLEND_MODE_BIT_OFFSET}_SetLayer(e,t){const s=t&&this._layer!==e;s&&this._RemoveFromRenderCells(),this._objectClass._OnWorldInstanceLayerChanged(this,this._layer,e),this._layer=e,s&&this._UpdateRenderCell(),0!==this.GetZElevation()&&this._layer._SetAnyInstanceZElevated()}GetLayer(){return this._layer}GetLayout(){return this.GetLayer().GetLayout()}_SetZIndex(e){this._zIndex=0|e}GetZIndex(){return this._layer._UpdateZIndices(),this._zIndex}_SetHTMLZIndex(e){this._htmlZIndex=0|e}GetHTMLZIndex(){return this._layer._UpdateHTMLZIndices(),this._htmlZIndex}_GetLastCachedZIndex(){return this._zIndex}_SetFlag(e,t){t?this._flags|=e:this._flags&=~e}IsVisible(){return 0!=(this._flags&FLAG_IS_VISIBLE)}SetVisible(e){if(this._SetFlag(FLAG_IS_VISIBLE,e),this.HasChildren())for(const t of this.GetChildren())t.GetTransformWithParentVisibility()&&t.SetVisible(e)}IsCollisionEnabled(){return 0!=(this._flags&FLAG_COLLISION_ENABLED)}SetCollisionEnabled(e){e=!!e,this.IsCollisionEnabled()!==e&&(this._SetFlag(FLAG_COLLISION_ENABLED,e),e?this.SetBboxChanged():this._RemoveFromCollisionCells())}SetSolidCollisionFilter(e,t){if(this._SetFlag(FLAG_SOLID_FILTER_INCLUSIVE,e),this._solidFilterTags&&this._solidFilterTags.clear(),t.trim()){this._solidFilterTags||(this._solidFilterTags=new Set);for(const s of t.split(" "))s&&this._solidFilterTags.add(s.toLowerCase())}else this._solidFilterTags=null}IsSolidCollisionAllowed(e){const t=0!=(this._flags&FLAG_SOLID_FILTER_INCLUSIVE),s=this._solidFilterTags;if(e&&s)for(const i of s)if(e.has(i))return t;return!t}SetBboxChanged(){if(this._flags|=FLAG_BBOX_CHANGED|FLAG_COLLISION_CELL_CHANGED|FLAG_MESH_CHANGED,this._objectClass._SetAnyCollisionCellChanged(!0),this._runtime.UpdateRender(),this._layer.UsesRenderCells()&&(this.CalculateBbox(this._boundingBox,this._boundingQuad,!0),this._flags&=~FLAG_BBOX_CHANGED,this._UpdateRenderCell()),0!=(this._flags&FLAG_ENABLE_BBOX_CHANGED_EVENT)&&this._inst.Dispatcher().dispatchEvent(bboxChangeEvent),null!==this._sceneGraphInfo){const s=this._sceneGraphInfo.GetChildren();for(let e=0,t=s.length;e<t;++e)s[e].SetBboxChanged()}}CalculateBbox(e,t,s){const i=this.GetX(),n=this.GetY(),r=this.GetWidth(),a=this.GetHeight(),o=this.GetAngle();e.setWH(i-this._ox*r,n-this._oy*a,r,a),s&&this.HasMesh()&&this._ExpandBboxForMesh(e),0===o?t.setFromRect(e):(e.offset(-i,-n),t.setFromRotatedRectPrecalc(e,this.GetSinAngle(),this.GetCosAngle()),t.offset(i,n),t.getBoundingBox(e)),e.normalize()}_UpdateBbox(){const e=this._flags;0!=(e&FLAG_BBOX_CHANGED)&&(this.CalculateBbox(this._boundingBox,this._boundingQuad,!0),this._flags=e&~FLAG_BBOX_CHANGED)}GetBoundingBox(){return this._UpdateBbox(),this._boundingBox}GetBoundingQuad(){return this._UpdateBbox(),this._boundingQuad}PixelRoundQuad(e){const t=this.GetX(),s=this.GetY(),i=Math.round(t)-t,n=Math.round(s)-s;return 0==i&&0==n?e:(tempQuad.copy(e),tempQuad.offset(i,n),tempQuad)}OverwriteBoundingBox(e){this._boundingBox.copy(e),this._boundingQuad.setFromRect(this._boundingBox),this._flags&=~FLAG_BBOX_CHANGED,this._UpdateCollisionCell(),this._UpdateRenderCell()}SetBboxChangeEventEnabled(e){this._SetFlag(FLAG_ENABLE_BBOX_CHANGED_EVENT,e)}IsBboxChangeEventEnabled(){return 0!=(this._flags&FLAG_ENABLE_BBOX_CHANGED_EVENT)}IsInViewport(e,t,s){return t&&0!==this.GetDepth()?this.IsInViewport3D(this.GetLayer()._GetViewFrustum()):0===this.GetZElevation()||s?e.intersectsRect(this.GetBoundingBox()):this._IsInViewport_ZElevated()}_IsInViewport_ZElevated(){const e=this.GetLayer(),t=this.GetTotalZElevation();return!(t>=e.Get2DCameraZ())&&(e.GetViewportForZ(t,tempRect),tempRect.intersectsRect(this.GetBoundingBox()))}IsInViewport3D(e){const t=this.GetBoundingBox(),s=t.getLeft(),i=t.getRight(),n=t.getTop(),r=t.getBottom(),a=this.GetTotalZElevation(),o=a+this.GetDepth();return e.ContainsAABB(s,n,a,i,r,o)}IsInViewport2(){const e=this.GetLayer();if(e.Has3DCamera())return this.IsInViewport3D(e._GetViewFrustum());{const t=e.GetLayout();return this.IsInViewport(e.GetViewport(),t.HasVanishingPointOutsideViewport(),t.IsOrthographicProjection())}}_SetDrawBackFaceOnly(e){this._SetFlag(FLAG_DRAW_BACK_FACE_ONLY,e)}_SetDrawNonBackFacesOnly(e){this._SetFlag(FLAG_DRAW_NON_BACK_FACES_ONLY,e)}IsDrawBackFaceOnly(){return 0!=(this._flags&FLAG_DRAW_BACK_FACE_ONLY)}IsDrawNonBackFacesOnly(){return 0!=(this._flags&FLAG_DRAW_NON_BACK_FACES_ONLY)}SetSourceCollisionPoly(e){this._sourceCollisionPoly=e,this._DiscardTransformedCollisionPoly(),this.HasMesh()&&(this._meshInfo.meshPoly=null)}GetSourceCollisionPoly(){return this._sourceCollisionPoly}HasOwnCollisionPoly(){return null!==this._sourceCollisionPoly||this.HasMesh()}GetTransformedCollisionPoly(){return this._GetCustomTransformedCollisionPolyPrecalc(this.GetWidth(),this.GetHeight(),this.GetAngle(),this.GetSinAngle(),this.GetCosAngle())}GetCustomTransformedCollisionPoly(e,t,s){let i=0,n=1;return 0!==s&&(i=Math.sin(s),n=Math.cos(s)),this._GetCustomTransformedCollisionPolyPrecalc(e,t,s,i,n)}_GetCustomTransformedCollisionPolyPrecalc(n,r,e,a,o){let t=this._transformedPolyInfo;null===t&&(t={poly:C33.New(C33.CollisionPoly),width:NaN,height:NaN,angle:NaN},this._transformedPolyInfo=t);const l=t.poly;if(t.width!==n||t.height!==r||t.angle!==e){const h=this._sourceCollisionPoly;if(this.HasMesh()){let e=this.GetOriginX(),t=this.GetOriginY(),s=this.GetSourceMesh(),i=this._meshInfo.meshPoly;i||(h?(tempCollisionPoly.copy(h),tempCollisionPoly.offset(e,t)):tempCollisionPoly.setDefaultPoints(),i=s.InsertPolyMeshVertices(tempCollisionPoly),this._meshInfo.meshPoly=i),s.TransformCollisionPoly(i,l),l.offset(-e,-t),l.transformPrecalc(n,r,a,o)}else h?(l.copy(h),l.transformPrecalc(n,r,a,o)):l.setFromQuad(this.GetBoundingQuad(),-this.GetX(),-this.GetY());t.width=n,t.height=r,t.angle=e}return l}_DiscardTransformedCollisionPoly(){this.SetPhysicsBodyChanged(!0);const e=this._transformedPolyInfo;null!==e&&(e.width=NaN)}CreateMesh(e,t){if(e=Math.floor(e),t=Math.floor(t),!this.GetInstance().GetPlugin().SupportsMesh())throw new Error("object does not support mesh");this.ReleaseMesh(),this._meshInfo={sourceMesh:C33.New(C33.Gfx.Mesh,e,t),transformedMesh:C33.New(C33.Gfx.Mesh,e,t),meshPoly:null}}HasMesh(){return null!==this._meshInfo}GetSourceMesh(){if(this.HasMesh())return this._meshInfo.sourceMesh;throw new Error("no mesh")}GetTransformedMesh(){if(this.HasMesh())return this._meshInfo.transformedMesh;throw new Error("no mesh")}SetMeshChanged(e){this._SetFlag(FLAG_MESH_CHANGED,e)}IsMeshChanged(){return 0!=(this._flags&FLAG_MESH_CHANGED)}SetPhysicsBodyChanged(e){this._SetFlag(FLAG_PHYSICS_BODY_CHANGED,e)}IsPhysicsBodyChanged(){return 0!=(this._flags&FLAG_PHYSICS_BODY_CHANGED)}_ExpandBboxForMesh(e){const t=this._meshInfo.sourceMesh,s=Math.min(t.GetMinX(),0),i=Math.min(t.GetMinY(),0),n=Math.max(t.GetMaxX(),1),r=Math.max(t.GetMaxY(),1),a=e.width(),o=e.height();e.offsetLeft(s*a),e.offsetTop(i*o),e.offsetRight((n-1)*a),e.offsetBottom((r-1)*o),this._depth=t.GetMaxZ()}ReleaseMesh(){this._meshInfo&&(this._meshInfo.sourceMesh.Release(),this._meshInfo.transformedMesh.Release(),this._meshInfo=null,this._DiscardTransformedCollisionPoly())}SetMeshPoint(e,t,s){e=Math.floor(e),t=Math.floor(t);const i=s.mode||"absolute";if(!VALID_SET_MESH_POINT_MODES.has(i))throw new Error("invalid mode");let n="relative"===i,r=s.x,a=s.y,o=s.zElevation,l="number"==typeof s.u?s.u:n?0:-1,h="number"==typeof s.v?s.v:n?0:-1;if(!this.HasMesh())return!1;const c=this.GetSourceMesh(),u=c.GetMeshPointAt(e,t);if(null===u)return!1;let _=!1;return"number"==typeof o&&u.GetZElevation()!==o&&(u.SetZElevation(o),_=!0),n&&(r+=e/(c.GetHSize()-1),a+=t/(c.GetVSize()-1)),l=-1!==l||n?(n&&(l+=e/(c.GetHSize()-1)),C33.clamp(l,0,1)):u.GetU(),h=-1!==h||n?(n&&(h+=t/(c.GetVSize()-1)),C33.clamp(h,0,1)):u.GetV(),u.GetX()===r&&u.GetY()===a&&u.GetU()===l&&u.GetV()===h?_:(u.SetX(r),u.SetY(a),u.SetU(l),u.SetV(h),this._DiscardTransformedCollisionPoly(),!0)}HasTilemap(){return this._inst.HasTilemap()}ContainsPoint(e,t){return!!this.GetBoundingBox().containsPoint(e,t)&&!!this.GetBoundingQuad().containsPoint(e,t)&&(this.HasTilemap()?this._inst.GetSdkInstance().TestPointOverlapTile(e,t):!this.HasOwnCollisionPoly()||this.GetTransformedCollisionPoly().containsPoint(e-this.GetX(),t-this.GetY()))}_IsCollisionCellChanged(){return 0!=(this._flags&FLAG_COLLISION_CELL_CHANGED)}_UpdateCollisionCell(){if(this._IsCollisionCellChanged()&&this.IsCollisionEnabled()&&0==(this._flags&FLAG_DESTROYED)){const e=this.GetBoundingBox(),t=this._objectClass._GetCollisionCellGrid(),s=this._collisionCells;if(tempRect.set(t.XToCell(e.getLeft()),t.YToCell(e.getTop()),t.XToCell(e.getRight()),t.YToCell(e.getBottom())),!s.equals(tempRect)){const i=this._inst;s===DEFAULT_COLLISION_CELLS?(t.Update(i,null,tempRect),this._collisionCells=C33.New(C33.Rect,tempRect)):(t.Update(i,s,tempRect),s.copy(tempRect)),this._flags&=~FLAG_COLLISION_CELL_CHANGED}}}_SetCollisionCellChanged(){this._flags|=FLAG_COLLISION_CELL_CHANGED}_RemoveFromCollisionCells(){const e=this._collisionCells;e!==DEFAULT_COLLISION_CELLS&&(this._objectClass._GetCollisionCellGrid().Update(this._inst,e,null),this._collisionCells=DEFAULT_COLLISION_CELLS)}_UpdateRenderCell(){const e=this.GetLayer();if(e.UsesRenderCells()&&0==(this._flags&FLAG_DESTROYED)){const t=e.GetRenderGrid(),s=this.GetBoundingBox(),i=this._renderCells;if(tempRect.set(t.XToCell(s.getLeft()),t.YToCell(s.getTop()),t.XToCell(s.getRight()),t.YToCell(s.getBottom())),!i.equals(tempRect)){const n=this._inst;i===DEFAULT_RENDER_CELLS?(t.Update(n,null,tempRect),this._renderCells=C33.New(C33.Rect,tempRect)):(t.Update(n,i,tempRect),i.copy(tempRect)),e.SetRenderListStale()}}}_RemoveFromRenderCells(){const e=this._renderCells;e!==DEFAULT_RENDER_CELLS&&(this.GetLayer().GetRenderGrid().Update(this._inst,e,null),this._renderCells=DEFAULT_RENDER_CELLS)}GetRenderCellRange(){return this._renderCells}ZOrderMoveToTop(){const e=this._inst,t=this._layer,s=t._GetInstances();s.length&&s.at(-1)===e||(t._RemoveInstance(e,!1),t._AddInstance(e,!1),this._runtime.UpdateRender())}ZOrderMoveToBottom(){const e=this._inst,t=this._layer,s=t._GetInstances();s.length&&s[0]===e||(t._RemoveInstance(e,!1),t._PrependInstance(e,!1),this._runtime.UpdateRender())}ZOrderMoveToLayer(e){const t=this._inst,s=this._layer;if(s.GetLayout()!==e.GetLayout())throw new Error("layer from different layout");e!==s&&(s._RemoveInstance(t,!0),this._SetLayer(e),e._AddInstance(t,!0),this._runtime.UpdateRender())}ZOrderMoveAdjacentToInstance(e,t){let s=this._inst,i=!1,n=this._layer;if(e.GetUID()!==s.GetUID()){const r=e.GetWorldInfo();if(!r)throw new Error("expected world instance");const a=r.GetLayer(),o=(n.GetIndex()!==a.GetIndex()&&(n._RemoveInstance(s,!0),this._SetLayer(a),a._AddInstance(s,!0),i=!0),a.MoveInstanceAdjacent(s,e,!!t));(i||o)&&this._runtime.UpdateRender()}}GetInstanceEffectList(){return this._instanceEffectList}_SetHasAnyActiveEffect(e){this._SetFlag(FLAG_HAS_ANY_ACTIVE_EFFECT,e)}HasAnyActiveEffect(){return 0!=(this._flags&FLAG_HAS_ANY_ACTIVE_EFFECT)}_SaveToJson(e,t=null){const s={x:this.GetX(),y:this.GetY(),w:this.GetWidth(),h:this.GetHeight(),l:this.GetLayer().GetSID(),zi:this.GetZIndex()},i=(0!==this.GetZElevation()&&(s.ze=this.GetZElevation()),0!==this.GetAngle()&&(s.a=this._GetAngleNoReflect()),this.HasDefaultColor()||(s.c=this._color.toJSON()),.5!==this.GetOriginX()&&(s.oX=this.GetOriginX()),.5!==this.GetOriginY()&&(s.oY=this.GetOriginY()),0!==this.GetBlendMode()&&(s.bm=this.GetBlendMode()),this.IsVisible()||(s.v=this.IsVisible()),this.IsCollisionEnabled()||(s.ce=this.IsCollisionEnabled()),this.IsBboxChangeEventEnabled()&&(s.be=this.IsBboxChangeEventEnabled()),this._instanceEffectList&&(s.fx=this._instanceEffectList._SaveToJson()),0!=(this._flags&FLAG_SOLID_FILTER_INCLUSIVE));return i&&(s.sfi=i),this._solidFilterTags&&(s.sft=[...this._solidFilterTags].join(" ")),this._sceneGraphInfo&&"visual-state"!==e&&(s.sgi=this._sceneGraphInfo._SaveToJson(e,t),sceneGraphExportDataMap.has(this))&&(s.sgcd=sceneGraphExportDataMap.get(this).childrenData,s.sgzid=sceneGraphExportDataMap.get(this).zIndexData),this.HasMesh()&&(s.mesh=this.GetSourceMesh().SaveToJson()),s}_SaveSceneGraphPropertiesToJson(){return{x:this._x,y:this._y,z:this._zElevation,w:this._w,h:this._h,a:this._a,sgi:this._GetSceneGraphInfo()?this._GetSceneGraphInfo()._SaveToJsonProperties():null}}_LoadSceneGraphPropertiesFromJson(e){e&&(this._x=e.x,this._y=e.y,this._zElevation=e.z,this._w=e.w,this._h=e.h,this._a=e.a,e.sgi&&this._GetSceneGraphInfo()&&this._GetSceneGraphInfo()._LoadFromJson(e.sgi),this._MarkSinCosAngleChanged(),this.SetBboxChanged())}_SetupSceneGraphConnectionsOnChangeOfLayout(){this._ReleaseTmpSceneGraphInfo(),this._ResetAllSceneGraphState(),this._CreateSceneGraphInfo(null),this._sceneGraphInfo&&this._sceneGraphInfo._SetTmpSceneGraphChildren(this._tmpSceneGraphChildren,this._tmpSceneGraphChildrenIndexes)}_OnBeforeLoad(e){"visual-state"!==e&&this._ResetAllSceneGraphState()}_OnAfterLoad(e,t="full",s=null){e.hasOwnProperty("sgi")&&"visual-state"!==t&&0==(this._flags&FLAG_DESTROYED)&&this._sceneGraphInfo._OnAfterLoad(e.sgi,s)}_OnAfterLoad2(e,t="full",s){e.hasOwnProperty("sgi")&&"visual-state"!==t&&0==(this._flags&FLAG_DESTROYED)&&(this._sceneGraphInfo._SetTmpSceneGraphChildren(null,null),this._ReleaseTmpSceneGraphInfo(),this.SetBboxChanged())}_LoadFromJson(e,t){if(enableUpdateRendererStateGroup=!1,this.SetX(e.x),this.SetY(e.y),this.SetWidth(e.w),this.SetHeight(e.h),this._SetZIndex(e.zi),this.SetZElevation(e.hasOwnProperty("ze")?e.ze:0),this.SetAngle(e.hasOwnProperty("a")?e.a:0),e.hasOwnProperty("c")?tempColor.setFromJSON(e.c):e.hasOwnProperty("o")?(tempColor.copyRgb(this._color),tempColor.a=e.o):tempColor.setRgba(1,1,1,1),this._SetColor(tempColor),this.SetOriginX(e.hasOwnProperty("oX")?e.oX:.5),this.SetOriginY(e.hasOwnProperty("oY")?e.oY:.5),this.SetBlendMode(e.hasOwnProperty("bm")?e.bm:0),this.SetVisible(!e.hasOwnProperty("v")||e.v),this.SetCollisionEnabled(!e.hasOwnProperty("ce")||e.ce),this.SetBboxChangeEventEnabled(!!e.hasOwnProperty("be")&&e.be),this.SetSolidCollisionFilter(!!e.hasOwnProperty("sfi")&&e.sfi,e.hasOwnProperty("sft")?e.sft:""),this._instanceEffectList&&e.hasOwnProperty("fx")&&this._instanceEffectList._LoadFromJson(e.fx),!e.hasOwnProperty("sgi")&&"visual-state"!==t&&this._tmpSceneGraphChildren)for(const s of this._tmpSceneGraphChildren)s.IsDestroyed()||this._runtime.DestroyInstance(s);if(e.hasOwnProperty("sgi")&&"visual-state"!==t){this._CreateSceneGraphInfo(null);const i=this._sceneGraphInfo,n=e.sgi;i._LoadFromJson(n),i._SetTmpSceneGraphChildren(this._tmpSceneGraphChildren,this._tmpSceneGraphChildrenIndexes),e.sgcd&&C33.IsFiniteNumber(e.sgzid)&&sceneGraphExportDataMap.set(this,{childrenData:e.sgcd,zIndexData:e.sgzid})}if(e.hasOwnProperty("mesh")){const r=e.mesh;this.CreateMesh(r.cols,r.rows),this.GetSourceMesh().LoadFromJson(r)}else this.ReleaseMesh();this.SetBboxChanged(),enableUpdateRendererStateGroup=!0,this._UpdateRendererStateGroup(),"visual-state"!==t&&this._runtime.AddInstanceNeedingAfterLoad(this.GetInstance(),e)}}}{const C33=self.C3;C33.BehaviorType=class extends C33.DefendedBase{constructor(e,t){super();const s=e.GetRuntime(),i=s.GetObjectReference(t[1]),n=(s.GetAddonManager()._DelayCreateBehavior(i),this._runtime=s,this._objectClass=e,this._behavior=C33.AddonManager.GetBehaviorByConstructorFunction(i),this._sdkType=null,this._iBehaviorType=null,this._instSdkCtor=i.Instance,this._sid=t[2],this._name=t[0],this._jsPropName=this._runtime.GetJsPropName(t[3]),this._behavior.GetSdkVersion());if(n<2&&(this._sdkType=C33.New(i.Type,this),!(this._sdkType instanceof C33.SDKBehaviorTypeBase)))throw new Error("v1 sdk type must derive from SDKBehaviorBase");if(C33.AddonManager._PushInitObject(this,n),2<=n){const r=i.Type??globalThis.ISDKBehaviorTypeBase;if(this._iBehaviorType=new r,!(this._iBehaviorType instanceof globalThis.ISDKBehaviorTypeBase))throw new Error("script interface class must derive from ISDKBehaviorTypeBase")}else this._iBehaviorType=new globalThis.IBehaviorType;C33.AddonManager._PopInitObject(n),this.OnCreate()}static Create(e,t){return C33.New(C33.BehaviorType,e,t)}Release(){this._runtime=null,this._behavior=null,this._sdkType&&(this._sdkType.Release(),this._sdkType=null),this._instSdkCtor=null}GetSdkType(){return this._sdkType}OnCreate(){this._sdkType?this._sdkType.OnCreate():this._iBehaviorType&&this._iBehaviorType._onCreate()}GetRuntime(){return this._runtime}GetObjectClass(){return this._objectClass}GetBehavior(){return this._behavior}GetInstanceSdkCtor(){return this._instSdkCtor}GetName(){return this._name}GetSID(){return this._sid}GetIBehaviorType(){return this._iBehaviorType}GetJsPropName(){return this._jsPropName}}}{const C33=self.C3,IBehaviorInstance=self.IBehaviorInstance;C33.BehaviorInstance=class extends C33.DefendedBase{constructor(e){super(),this._runtime=e.runtime,this._behaviorType=e.behaviorType,this._behavior=this._behaviorType.GetBehavior(),this._inst=e.instance,this._index=e.index,this._sdkInst=null,this._iScriptInterface=null,this._behavior._AddInstance(this._inst)}Release(){this._iScriptInterface&&(this._iScriptInterface._release(),this._iScriptInterface=null),this._behavior._RemoveInstance(this._inst),this._sdkInst&&(this._sdkInst.Release(),this._sdkInst=null),this._runtime=null,this._behaviorType=null,this._behavior=null,this._inst=null}_CreateSdkInstance(e){if(this._sdkInst)throw new Error("already got sdk instance");const t=this.GetBehavior().GetSdkVersion();if(t<2){if(this._sdkInst=C33.New(this._behaviorType.GetInstanceSdkCtor(),this,e),!(this._sdkInst instanceof C33.SDKBehaviorInstanceBase))throw new Error("v1 sdk type must derive from SDKBehaviorInstanceBase")}else{const s=this.GetBehavior().GetScriptInterfaceClass();this._InitScriptInterface(s.Instance,e)}}GetSdkInstance(){return this._sdkInst??this._iScriptInterface}GetObjectInstance(){return this._inst}GetRuntime(){return this._runtime}GetBehaviorType(){return this._behaviorType}GetBehavior(){return this._behavior}_GetIndex(){return this._index}PostCreate(){this._sdkInst?this._sdkInst.PostCreate():this._iScriptInterface._postCreate()}OnSpriteFrameChanged(e,t){this._sdkInst&&this._sdkInst.OnSpriteFrameChanged(e,t)}_GetDebuggerProperties(){return this._sdkInst?this._sdkInst.GetDebuggerProperties():this._iScriptInterface._getDebuggerProperties()}SaveToJson(e="full"){return this._sdkInst?this._sdkInst.SaveToJson(e):this._iScriptInterface._saveToJson(e)}LoadFromJson(e,t="full"){if(this._sdkInst)return this._sdkInst.LoadFromJson(e,t);this._iScriptInterface._loadFromJson(e,t)}static SortByTickSequence(e,t,s){let i=globalThis.ISDKBehaviorInstanceBase,n,r;n=t instanceof i?e._UnwrapScriptInterface(t):t.GetBehaviorInstance(),r=s instanceof i?e._UnwrapScriptInterface(s):s.GetBehaviorInstance();const a=n.GetObjectInstance(),o=r.GetObjectInstance(),l=a.GetObjectClass().GetIndex(),h=o.GetObjectClass().GetIndex();if(l!==h)return l-h;const c=a.GetPUID(),u=o.GetPUID();return c!==u?c-u:n._GetIndex()-r._GetIndex()}_InitScriptInterface(e,t){const s=IBehaviorInstance,i=e??this._sdkInst.GetScriptInterfaceClass(),n=i||s,r=this.GetBehavior().GetSdkVersion();if(C33.AddonManager._PushInitObject(this,r),C33.AddonManager._PushInitProperties(t),this._iScriptInterface=new n,C33.AddonManager._PopInitProperties(),C33.AddonManager._PopInitObject(r),!i||this._iScriptInterface instanceof s)return this._iScriptInterface;throw new TypeError(`script interface class '${i.name}' does not extend the right base class '${s.name}'`)}GetScriptInterface(){return this._iScriptInterface||this._InitScriptInterface()}HasScriptInterface(){return!!this._iScriptInterface}}}{const C33=self.C3;C33.EffectList=class extends C33.DefendedBase{constructor(e,t){super(),this._owner=e,this._allEffectTypes=[],this._activeEffectTypes=[],this._effectTypesByName=new Map,this._effectParams=[],this._effectParamBuffers=[],this._allInstanceEffectLists=new Set,this._preservesOpaqueness=!0;for(const s of t){const i=C33.New(C33.EffectType,this,s,this._allEffectTypes.length);this._allEffectTypes.push(i),this._effectTypesByName.set(i.GetName().toLowerCase(),i),3<=s.length&&this._effectParams.push(this._LoadSingleEffectParameters(i,s[2]))}this.GetRuntime()._AddEffectList(this)}Release(){this.GetRuntime()._RemoveEffectList(this);for(const e of this._effectParamBuffers)e.Release();C33.clearArray(this._effectParamBuffers),C33.clearArray(this._allEffectTypes),C33.clearArray(this._activeEffectTypes),this._effectTypesByName.clear(),C33.clearArray(this._effectParams),this._owner=null}_AddInstanceEffectList(e){this._allInstanceEffectLists.add(e)}_RemoveInstanceEffectList(e){this._allInstanceEffectLists.delete(e)}_InitRenderer(e){e.IsWebGPU()&&(this._effectParamBuffers=this._allEffectTypes.map(e=>{const t=e.GetShaderProgram();return 0<t.GetCustomParametersByteSize()?C33.New(C33.Gfx.WebGPUEffectCustomParamsBuffer,t):null}),this._UpdateAllEffectParamBuffers());for(const t of this._allInstanceEffectLists)t._InitRenderer(e)}PrependEffectTypes(e){if(e.length){this._allEffectTypes=e.concat(this._allEffectTypes);for(const t of e)this._effectTypesByName.set(t.GetName().toLowerCase(),t);for(let e=0,t=this._allEffectTypes.length;e<t;++e)this._allEffectTypes[e]._SetIndex(e)}}_LoadSingleEffectParameters(e,t){e.SetActive(t[0]);const s=t.slice(1);for(let e=0,t=s.length;e<t;++e){const i=s[e];if(Array.isArray(i)){const n=C33.New(C33.Color);n.setFromJSON(i),s[e]=n}}return s}GetOwner(){return this._owner}GetRuntime(){return this._owner.GetRuntime()}UpdateActiveEffects(){C33.clearArray(this._activeEffectTypes);let e=!0;for(const t of this._allEffectTypes)t.IsActive()&&(this._activeEffectTypes.push(t),t.GetShaderProgram().PreservesOpaqueness()||(e=!1));this._preservesOpaqueness=e}GetAllEffectTypes(){return this._allEffectTypes}HasAnyEffectType(){return 0<this._allEffectTypes.length}GetEffectTypeByName(e){return this._effectTypesByName.get(e.toLowerCase())||null}GetEffectTypeByIndex(e){if((e=Math.floor(+e))<0||e>=this._allEffectTypes.length)throw new RangeError("invalid effect type index");return this._allEffectTypes[e]}IsEffectIndexActive(e){return this.GetEffectTypeByIndex(e).IsActive()}SetEffectIndexActive(e,t){this.GetEffectTypeByIndex(e).SetActive(t)}GetActiveEffectTypes(){return this._activeEffectTypes}HasAnyActiveEffect(){return 0<this._activeEffectTypes.length}PreservesOpaqueness(){return this._preservesOpaqueness}GetEffectParametersForIndex(e){return this._effectParams[e]}_GetEffectChainShaderParametersForIndex(e){return(e<this._effectParamBuffers.length?this._effectParamBuffers:this._effectParams)[e]}GetEffectParameter(e,t){if(e<0||e>=this._effectParams.length)return null;const s=this._effectParams[e];return t<0||t>=s.length?null:s[t]}SetEffectParameter(e,t,s){if(e<0||e>=this._effectParams.length)return!1;const i=this._effectParams[e];if(t<0||t>=i.length)return!1;const n=i[t];if(n instanceof C33.Color){if(n.equalsIgnoringAlpha(s))return!1;n.copyRgb(s)}else{if(n===s)return!1;i[t]=s}return e<this._effectParamBuffers.length&&this._effectParamBuffers[e].SetParameterValue(t,s),!0}_UpdateAllEffectParamBuffers(){const s=this._effectParams,i=this._effectParamBuffers;for(let e=0,t=Math.min(s.length,i.length);e<t;++e){const n=i[e],r=s[e];for(let e=0,t=r.length;e<t;++e)n.SetParameterValue(e,r[e])}}static SaveFxParamToJson(e){return e&&e instanceof C33.Color?{t:"color",v:e.toJSON()}:e}static LoadFxParamFromJson(e){if(null===e)return NaN;if("object"!=typeof e)return e;{const t=e.t;if("color"!==t)throw new Error("invalid effect parameter type");{const s=C33.New(C33.Color);return s.setFromJSON(e.v),s}}}static SaveFxParamsToJson(e){return e.map(C33.EffectList.SaveFxParamToJson)}static LoadFxParamsFromJson(e){return e.map(C33.EffectList.LoadFxParamFromJson)}SaveToJson(){return this._allEffectTypes.map(e=>({name:e.GetName(),active:e.IsActive(),params:C33.EffectList.SaveFxParamsToJson(this._effectParams[e.GetIndex()])}))}LoadFromJson(e){for(const t of e){const s=this.GetEffectTypeByName(t.name);s&&(s.SetActive(t.active),this._effectParams[s.GetIndex()]=C33.EffectList.LoadFxParamsFromJson(t.params))}this.UpdateActiveEffects(),this._UpdateAllEffectParamBuffers()}}}{const C33=self.C3;C33.EffectType=class extends C33.DefendedBase{constructor(e,t,s){super(),this._effectList=e,this._id=t[0],this._name=t[1],this._index=s,this._shaderProgram=null,this._isActive=!0}Release(){this._effectList=null,this._shaderProgram=null}Clone(e){const t=C33.New(C33.EffectType,e,[this._id,this._name],-1);return t._shaderProgram=this._shaderProgram,t._isActive=this._isActive,t}_InitRenderer(e){const t=e.GetShaderProgramByName(this._id);if(!t)throw new Error("failed to find shader program '"+this._id+"'");this._shaderProgram=t}GetEffectList(){return this._effectList}GetName(){return this._name}_SetIndex(e){this._index=e}GetIndex(){return this._index}GetOwner(){return this._effectList.GetOwner()}GetRuntime(){return this._effectList.GetRuntime()}SetActive(e){this._isActive=!!e}IsActive(){return this._isActive}GetShaderProgram(){return this._shaderProgram}GetDefaultParameterValues(){const s=[];for(let e=0,t=this._shaderProgram.GetParameterCount();e<t;++e){const i=this._shaderProgram.GetParameterType(e);if("float"===i||"percent"===i)s.push(0);else{if("color"!==i)throw new TypeError("unknown effect parameter type");s.push(C33.New(C33.Color,1,1,1,1))}}return s}}}{const C33=self.C3;C33.InstanceEffectList=class extends C33.DefendedBase{constructor(e,t){super(),this._inst=e,this._wi=t,this._effectList=e.GetObjectClass().GetEffectList(),this._needsRebuildSteps=!0,this._wasDefaultColor=!0,this._was3D=!1,this._wasRotatedOrNegativeSize=!1,this._wasTexRotated=!1,this._wasMustPreDraw=!1,this._effectChain=C33.New(C33.Gfx.EffectChain,e.GetRuntime().GetCanvasManager().GetEffectChainManager(),{drawContent:(e,t)=>{const s=t.GetContentObject(),i=s.GetWorldInfo();e.SetColor(i.GetPremultipliedColor()),e.SetCurrentZ(i.GetTotalZElevation()),s.Draw(e),e.SetCurrentZ(0)},getSourceTextureInfo:e=>{const t=e.GetCurrentTexRect(),[s,i]=e.GetCurrentSurfaceSize();return{srcTexRect:t,srcWidth:s,srcHeight:i}},getShaderParameters:e=>this._GetEffectChainShaderParametersForIndex(e)}),this._activeEffectFlags=[],this._activeEffectTypes=[],this._preservesOpaqueness=!0,this._effectParams=[],this._effectParamBuffers=[],this._InitRenderer(e.GetRuntime().GetRenderer());for(let e=0,t=this._effectList.GetAllEffectTypes().length;e<t;++e)this._activeEffectFlags.push(!0);this.UpdateActiveEffects(),this._effectList._AddInstanceEffectList(this)}Release(){this._effectList._RemoveInstanceEffectList(this);for(const e of this._effectParamBuffers)e&&e.Release();C33.clearArray(this._effectParamBuffers),this._effectChain.Release(),this._effectChain=null,C33.clearArray(this._activeEffectFlags),C33.clearArray(this._activeEffectTypes),C33.clearArray(this._effectParams),this._inst=null,this._effectList=null}_InitRenderer(e){e.IsWebGPU()&&(this._effectParamBuffers=this._effectList.GetAllEffectTypes().map(e=>{const t=e.GetShaderProgram();return 0<t.GetCustomParametersByteSize()?C33.New(C33.Gfx.WebGPUEffectCustomParamsBuffer,t):null}))}_LoadEffectParameters(e){let t=0;for(const s of e)this._effectParams.push(this._LoadSingleEffectParameters(t,s)),++t;this._UpdateAllEffectParamBuffers(),this.UpdateActiveEffects()}_LoadSingleEffectParameters(e,t){this._activeEffectFlags[e]=t[0];const s=t.slice(1);for(let e=0,t=s.length;e<t;++e){const i=s[e];if(Array.isArray(i)){const n=C33.New(C33.Color);n.setFromJSON(i),s[e]=n}}return s}LoadDefaultEffectParameters(){for(const e of this._effectList.GetAllEffectTypes())this._effectParams.push(e.GetDefaultParameterValues());this._UpdateAllEffectParamBuffers()}GetOwner(){return this._owner}GetEffectList(){return this._effectList}GetEffectChain(){return this._MaybeRebuildEffectChainSteps(),this._effectChain}GetRuntime(){return this._inst.GetRuntime()}UpdateActiveEffects(){C33.clearArray(this._activeEffectTypes);let e=this._wi,s=this._effectList.GetAllEffectTypes(),i=this._activeEffectTypes,n=this._activeEffectFlags,r=!0;for(let e=0,t=s.length;e<t;++e)if(n[e]){const a=s[e];i.push(a),a.GetShaderProgram().PreservesOpaqueness()||(r=!1)}this._preservesOpaqueness=r,e._SetHasAnyActiveEffect(!!i.length),this._needsRebuildSteps=!0}_MaybeRebuildEffectChainSteps(){const e=this._inst,t=this._wi,s=t.HasDefaultColor(),i=e.GetPlugin().Is3D(),n=0!==t.GetAngle()||0!==t.GetLayer().GetAngle()||t.GetWidth()<0||t.GetHeight()<0,r=e.IsCurrentTexRotated(),a=e.MustPreDraw();(this._needsRebuildSteps||s!==this._wasDefaultColor||i!==this._was3D||n!==this._wasRotatedOrNegativeSize||r!==this._wasTexRotated||a!==this._wasMustPreDraw||this._effectChain.NeedsRebuild())&&(this._effectChain.BuildSteps(this._activeEffectTypes.map(e=>e.GetShaderProgram()),{indexMap:this._activeEffectTypes.map(e=>e.GetIndex()),forcePreDraw:!s||a,is3D:i,isSourceTextureRotated:r,isRotatedOrNegativeSizeInstance:n}),this._needsRebuildSteps=!1,this._wasDefaultColor=s,this._was3D=i,this._wasRotatedOrNegativeSize=n,this._wasTexRotated=r,this._wasMustPreDraw=a)}GetActiveEffectTypes(){return this._activeEffectTypes}GetEffectParametersForIndex(e){return this._effectParams[e]}_GetEffectChainShaderParametersForIndex(e){return(e<this._effectParamBuffers.length?this._effectParamBuffers:this._effectParams)[e]}GetEffectParameter(e,t){if(e<0||e>=this._effectParams.length)return null;const s=this._effectParams[e];return t<0||t>=s.length?null:s[t]}SetEffectParameter(e,t,s){if(e<0||e>=this._effectParams.length)return!1;const i=this._effectParams[e];if(t<0||t>=i.length)return!1;const n=i[t];if(n instanceof C33.Color){if(n.equalsIgnoringAlpha(s))return!1;n.copyRgb(s)}else{if(n===s)return!1;i[t]=s}return e<this._effectParamBuffers.length&&this._effectParamBuffers[e].SetParameterValue(t,s),!0}_UpdateAllEffectParamBuffers(){const s=this._effectParams,i=this._effectParamBuffers;for(let e=0,t=i.length;e<t;++e){const n=i[e],r=s[e];for(let e=0,t=r.length;e<t;++e)n.SetParameterValue(e,r[e])}}PreservesOpaqueness(){return this._preservesOpaqueness}HasAnyActiveBackgroundBlendingEffect(){return this._activeEffectTypes.some(e=>e.GetShaderProgram().BlendsBackground())}IsEffectIndexActive(e){return this._activeEffectFlags[e]}SetEffectIndexActive(e,t){this._activeEffectFlags[e]=!!t}GetAllEffectTypes(){return this._effectList.GetAllEffectTypes()}_SaveToJson(){return this._effectList.GetAllEffectTypes().map(e=>({name:e.GetName(),active:this._activeEffectFlags[e.GetIndex()],params:C33.EffectList.SaveFxParamsToJson(this._effectParams[e.GetIndex()])}))}_LoadFromJson(e){for(const t of e){const s=this._effectList.GetEffectTypeByName(t.name);s&&(this._activeEffectFlags[s.GetIndex()]=t.active,this._effectParams[s.GetIndex()]=C33.EffectList.LoadFxParamsFromJson(t.params))}this.UpdateActiveEffects(),this._UpdateAllEffectParamBuffers()}}}{let C33=self.C3,tempCandidates=[],tileCollRectCandidates=[],tempJumpthruRet=[],tempPolyA=C33.New(C33.CollisionPoly),tempPolyB=C33.New(C33.CollisionPoly),tempQuad=C33.New(C33.Quad),tempRect=C33.New(C33.Rect),tempRect2=C33.New(C33.Rect),tempPolyC=null,tempRect3=null,tempQuadB=null;C33.CollisionEngine=class extends C33.DefendedBase{constructor(e){super(),this._runtime=e,this._collisionCellWidth=0,this._collisionCellHeight=0,this._registeredCollisions=[],this._collisionCheckCount=0,this._collisionCheckSec=0,this._polyCheckCount=0,this._polyCheckSec=0,this._iCollisionEngine=new self.ICollisionEngine(this)}Release(){this._runtime=null}GetRuntime(){return this._runtime}GetICollisionEngine(){return this._iCollisionEngine}_Update1sStats(){this._collisionCheckSec=this._collisionCheckCount,this._collisionCheckCount=0,this._polyCheckSec=this._polyCheckCount,this._polyCheckCount=0}Get1secCollisionChecks(){return this._collisionCheckSec}Get1secPolyChecks(){return this._polyCheckSec}RegisterCollision(e,t){const s=e.GetWorldInfo(),i=t.GetWorldInfo();s&&i&&s.IsCollisionEnabled()&&i.IsCollisionEnabled()&&this._registeredCollisions.push([e,t])}AddRegisteredCollisionCandidates(t,s,i){for(const[n,r]of this._registeredCollisions){let e=null;if(t===n)e=r;else{if(t!==r)continue;e=n}e.BelongsToObjectClass(s)&&!i.includes(e)&&i.push(e)}}CheckRegisteredCollision(e,t){if(this._registeredCollisions.length)for(const[s,i]of this._registeredCollisions)if(e===s&&t===i||e===i&&t===s)return!0;return!1}ClearRegisteredCollisions(){C33.clearArray(this._registeredCollisions)}TestOverlap(e,t){if(!e||!t||e===t)return!1;const s=e.GetWorldInfo(),i=t.GetWorldInfo();if(!s.IsCollisionEnabled()||!i.IsCollisionEnabled())return!1;this._collisionCheckCount++;const n=s.GetLayer(),r=i.GetLayer(),a=n.IsTransformCompatibleWith(r);return a?this._TestOverlap_SameLayers(s,i):this._TestOverlap_DifferentLayers(s,i)}_TestOverlap_SameLayers(e,t){if(!e.GetBoundingBox().intersectsRect(t.GetBoundingBox()))return!1;if(this._polyCheckCount++,!e.GetBoundingQuad().intersectsQuad(t.GetBoundingQuad()))return!1;if(e.HasTilemap()&&t.HasTilemap())return!1;if(e.HasTilemap())return this.TestTilemapOverlap(e,t);if(t.HasTilemap())return this.TestTilemapOverlap(t,e);if(!e.HasOwnCollisionPoly()&&!t.HasOwnCollisionPoly())return!0;const s=e.GetTransformedCollisionPoly(),i=t.GetTransformedCollisionPoly();return s.intersectsPoly(i,t.GetX()-e.GetX(),t.GetY()-e.GetY())}_TestOverlap_DifferentLayers(s,i){const e=s.HasTilemap(),t=i.HasTilemap();if(e&&!t)return this.TestTilemapOverlapDifferentLayers(s,i);if(t&&!e)return this.TestTilemapOverlapDifferentLayers(i,s);if(t||e)return!1;{const n=s.GetLayer(),r=i.GetLayer(),a=(tempPolyA.copy(s.GetTransformedCollisionPoly()),tempPolyB.copy(i.GetTransformedCollisionPoly()),tempPolyA.pointsArr());for(let e=0,t=a.length;e<t;e+=2){const l=e+1,h=a[e],c=a[l],[u,_]=n.LayerToCanvasCss(h+s.GetX(),c+s.GetY());a[e]=u,a[l]=_}const o=tempPolyB.pointsArr();for(let e=0,t=o.length;e<t;e+=2){const d=e+1,p=o[e],m=o[d],[g,f]=r.LayerToCanvasCss(p+i.GetX(),m+i.GetY());o[e]=g,o[d]=f}return tempPolyA.setBboxChanged(),tempPolyB.setBboxChanged(),this._polyCheckCount++,tempPolyA.intersectsPoly(tempPolyB,0,0)}}TestTilemapOverlapDifferentLayers(e,t){const s=e.GetLayer(),i=t.GetLayer(),n=(tempPolyC=tempPolyC||C33.New(C33.CollisionPoly),tempRect3=tempRect3||C33.New(C33.Rect),tempQuadB=tempQuadB||C33.New(C33.Quad),t.GetX()),r=t.GetY(),[a,o]=i.LayerToCanvasCss(n,r),[l,h]=s.CanvasCssToLayer(a,o),c=l-n,u=h-r;if(tempRect3.copy(t.GetBoundingBox()),tempRect3.offset(c,u),!e.GetBoundingBox().intersectsRect(tempRect3))return!1;if(tempQuadB.copy(t.GetBoundingQuad()),tempQuadB.offset(c,u),this._polyCheckCount++,!e.GetBoundingQuad().intersectsQuad(tempQuadB))return!1;tempPolyC.copy(t.GetTransformedCollisionPoly());const _=tempPolyC.pointsArr();for(let e=0,t=_.length;e<t;e+=2){const d=e+1;_[e]+=c,_[d]+=u}return tempPolyC.setBboxChanged(),this.TestTilemapOverlap(e,t,l,h,tempPolyC,tempRect3,tempQuadB)}TestTilemapOverlap(e,i,t,s,n,r,a){const o=void 0!==r?r:i.GetBoundingBox(),l=e.GetX(),h=e.GetY(),c=e.GetInstance().GetSdkInstance(),u=void 0!==t?t:i.GetX(),_=void 0!==s?s:i.GetY(),d=i.HasOwnCollisionPoly(),p=void 0!==a?a:i.GetBoundingQuad(),m=tileCollRectCandidates;c.GetCollisionRectCandidates(o,m);for(let e=0,t=m.length;e<t;++e){const g=m[e],f=g.GetRect();if(this._collisionCheckCount++,o.intersectsRectOffset(f,l,h)&&(tempQuad.setFromRect(f),tempQuad.offset(l,h),tempQuad.intersectsQuad(p)))if(d){let e=void 0!==n?n:i.GetTransformedCollisionPoly(),t=u,s=_;void 0!==n&&(t=i.GetX(),s=i.GetY());const S=g.GetPoly();if(S){if(this._polyCheckCount++,S.intersectsPoly(e,t-(l+f.getLeft()),s-(h+f.getTop())))return C33.clearArray(m),!0}else if(tempPolyA.setFromQuad(tempQuad,0,0),tempPolyA.intersectsPoly(e,t,s))return C33.clearArray(m),!0}else{const C=g.GetPoly();if(!C)return C33.clearArray(m),!0;if(tempPolyA.setFromQuad(p,0,0),C.intersectsPoly(tempPolyA,-(l+f.getLeft()),-(h+f.getTop())))return C33.clearArray(m),!0}}return C33.clearArray(m),!1}TestAndSelectCanvasPointOverlap(e,o,l){const h=e.GetCurrentSol(),t=this._runtime.GetCurrentEvent();if(!t)throw new Error("cannot call outside event");const c=t.IsOrBlock(),s=new Map,u=e=>{let t=s.get(e);return void 0===t&&(t=e.IsSelfAndParentsInteractive(),s.set(e,t)),t};if(h.IsSelectAll()){l||(h._SetSelectAll(!1),C33.clearArray(h._GetOwnInstances())),c&&C33.clearArray(h._GetOwnElseInstances());for(const i of e.GetInstances()){let n=i.GetWorldInfo(),r=n.GetLayer();if(!(!u(r)||!n.IsInViewport2())&&o.some(([e,t])=>{const[s,i]=r.CanvasCssToLayer(e,t,n.GetTotalZElevation());return n.ContainsPoint(s,i)})){if(l)return!1;h._PushInstance(i)}else c&&h._PushElseInstance(i)}}else{let s,i=!1,a=(!c||t.IsFirstConditionOfType(this._runtime.GetCurrentCondition())||this._runtime.IsCurrentConditionFirst()&&!h._GetOwnElseInstances().length&&h._GetOwnInstances().length?s=h._GetOwnInstances():(s=h._GetOwnElseInstances(),i=!0),0);for(let t=0,e=s.length;t<e;++t){let e=s[t],n=e.GetWorldInfo(),r=n.GetLayer();if(!(!u(r)||!n.IsInViewport2())&&o.some(([e,t])=>{const[s,i]=r.CanvasCssToLayer(e,t,n.GetTotalZElevation());return n.ContainsPoint(s,i)})){if(l)return!1;i?h._PushInstance(e):s[a++]=e}else i?s[a++]=e:c&&h._PushElseInstance(e)}l||(s.length=a)}return e.ApplySolToContainer(),s.clear(),!!l||h.HasAnyInstances()}_ObjectClassCanUseCollisionCells(e,t){if(e)for(const s of t.layersHasInstancesOn())if(!e.IsTransformCompatibleWith(s))return!1;return!0}GetCollisionCandidates(e,t,s,i){if(t.IsFamily())for(const n of t.GetFamilyMembers())this._ObjectClassCanUseCollisionCells(e,n)?(n._UpdateAllCollisionCells(),n._GetCollisionCellGrid().QueryRange(s,i)):C33.appendArray(i,n.GetInstances());else this._ObjectClassCanUseCollisionCells(e,t)?(t._UpdateAllCollisionCells(),t._GetCollisionCellGrid().QueryRange(s,i)):C33.appendArray(i,t.GetInstances())}GetObjectClassesCollisionCandidates(e,t,s,i){for(const n of t)this.GetCollisionCandidates(e,n,s,i)}GetSolidCollisionCandidates(e,t,s){const i=this._runtime.GetSolidBehavior();i&&this.GetObjectClassesCollisionCandidates(e,i.GetObjectClasses(),t,s)}GetJumpthruCollisionCandidates(e,t,s){const i=this._runtime.GetJumpthruBehavior();i&&this.GetObjectClassesCollisionCandidates(e,i.GetObjectClasses(),t,s)}IsSolidCollisionAllowed(e,t){return e._IsSolidEnabled()&&(!t||t.GetWorldInfo().IsSolidCollisionAllowed(e.GetSavedDataMap().get("solidTags")))}TestOverlapSolid(e){const t=e.GetWorldInfo();this.GetSolidCollisionCandidates(t.GetLayer(),t.GetBoundingBox(),tempCandidates);for(const s of tempCandidates)if(this.IsSolidCollisionAllowed(s,e)&&this.TestOverlap(e,s))return C33.clearArray(tempCandidates),s;return C33.clearArray(tempCandidates),null}TestRectOverlapSolid(e,t){this.GetSolidCollisionCandidates(null,e,tempCandidates);for(const s of tempCandidates)if(this.IsSolidCollisionAllowed(s,t)&&this.TestRectOverlap(e,s))return C33.clearArray(tempCandidates),s;return C33.clearArray(tempCandidates),null}TestOverlapJumpthru(e,t){let s=null;t&&(s=tempJumpthruRet,C33.clearArray(s));const i=e.GetWorldInfo();this.GetJumpthruCollisionCandidates(i.GetLayer(),i.GetBoundingBox(),tempCandidates);for(const n of tempCandidates)if(n._IsJumpthruEnabled()&&this.TestOverlap(e,n)){if(!t)return C33.clearArray(tempCandidates),n;s.push(n)}return C33.clearArray(tempCandidates),s}PushOut(t,s,i,n,r){n=n||50;const a=t.GetWorldInfo(),o=a.GetX(),l=a.GetY();for(let e=0;e<n;++e)if(a.SetXY(o+s*e,l+i*e),a.SetBboxChanged(),!this.TestOverlap(t,r))return!0;return a.SetXY(o,l),a.SetBboxChanged(),!1}PushOutSolid(t,s,i,n,r,a){n=n||50;let o=t.GetWorldInfo(),l=o.GetX(),h=o.GetY(),c=null,u=null;for(let e=0;e<n;++e)if(o.SetXY(l+s*e,h+i*e),o.SetBboxChanged(),!this.TestOverlap(t,c))if(c=this.TestOverlapSolid(t))u=c;else if(r&&(c=a?this.TestOverlap(t,a)?a:null:this.TestOverlapJumpthru(t))&&(u=c),!c)return u&&this.PushInFractional(t,s,i,u,16,!0),!0;return o.SetXY(l,h),o.SetBboxChanged(),!1}PushOutSolidAxis(s,i,n,e){e=e||50;let r=s.GetWorldInfo(),a=r.GetX(),o=r.GetY(),l=null,h=null;for(let t=0;t<e;++t)for(let e=0;e<2;++e){const c=2*e-1;if(r.SetXY(a+i*t*c,o+n*t*c),r.SetBboxChanged(),!this.TestOverlap(s,l)){if(!(l=this.TestOverlapSolid(s)))return h&&this.PushInFractional(s,i*c,n*c,h,16,!0),!0;h=l}}return r.SetXY(a,o),r.SetBboxChanged(),!1}PushInFractional(e,t,s,i,n,r){let a=2,o=!1,l=!1,h=e.GetWorldInfo(),c=h.GetX(),u=h.GetY();for(;a<=n;){const _=1/a;a*=2,h.OffsetXY(t*_*(o?1:-1),s*_*(o?1:-1)),h.SetBboxChanged(),this.TestOverlap(e,i)||r&&this.TestOverlapSolid(e)?(o=!0,l=!0):(o=!1,l=!1,c=h.GetX(),u=h.GetY())}l&&(h.SetXY(c,u),h.SetBboxChanged())}PushOutSolidNearest(s,e=100){let i=0,n=s.GetWorldInfo(),r=n.GetX(),a=n.GetY(),o=0,l=this.TestOverlapSolid(s);if(!l)return!0;for(;i<=e;){let e=0,t=0;switch(o){case 0:e=0,t=-1,i++;break;case 1:e=1,t=-1;break;case 2:e=1,t=0;break;case 3:e=1,t=1;break;case 4:e=0,t=1;break;case 5:e=-1,t=1;break;case 6:e=-1,t=0;break;case 7:e=-1,t=-1}if(o=(o+1)%8,n.SetXY(Math.floor(r+e*i),Math.floor(a+t*i)),n.SetBboxChanged(),!this.TestOverlap(s,l)&&!(l=this.TestOverlapSolid(s)))return!0}return n.SetXY(r,a),n.SetBboxChanged(),!1}CalculateBounceAngle(e,t,s,i){const n=e.GetWorldInfo(),r=n.GetX(),a=n.GetY(),o=Math.max(10,C33.distanceTo(t,s,r,a)),l=C33.angleTo(t,s,r,a),h=i||this.TestOverlapSolid(e);if(!h)return C33.clampAngle(l+Math.PI);let c=h,u=0,_=0,d=C33.toRadians(5),p;for(p=1;p<36;++p){const b=l-p*d;if(n.SetXY(t+Math.cos(b)*o,s+Math.sin(b)*o),n.SetBboxChanged(),!this.TestOverlap(e,c)&&!(c=i?null:this.TestOverlapSolid(e))){u=b;break}}for(36===p&&(u=C33.clampAngle(l+Math.PI)),c=h,p=1;p<36;++p){const P=l+p*d;if(n.SetXY(t+Math.cos(P)*o,s+Math.sin(P)*o),n.SetBboxChanged(),!this.TestOverlap(e,c)&&!(c=i?null:this.TestOverlapSolid(e))){_=P;break}}if(36===p&&(_=C33.clampAngle(l+Math.PI)),n.SetXY(r,a),n.SetBboxChanged(),_===u)return _;let m=C33.angleDiff(_,u)/2,g;g=C33.angleClockwise(_,u)?C33.clampAngle(u+m+Math.PI):C33.clampAngle(_+m);const f=Math.cos(l),S=Math.sin(l),C=Math.cos(g),y=Math.sin(g),G=f*C+S*y,I=f-2*G*C,T=S-2*G*y;return C33.angleTo(0,0,I,T)}TestSegmentOverlap(e,t,s,i,n){if(!n)return!1;const r=n.GetWorldInfo();if(!r.IsCollisionEnabled())return!1;if(this._collisionCheckCount++,tempRect.set(Math.min(e,s),Math.min(t,i),Math.max(e,s),Math.max(t,i)),!r.GetBoundingBox().intersectsRect(tempRect))return!1;if(n.HasTilemap())return this._TestSegmentOverlapTilemap(e,t,s,i,n,r);if(this._polyCheckCount++,!r.GetBoundingQuad().intersectsSegment(e,t,s,i))return!1;if(!r.HasOwnCollisionPoly())return!0;const a=r.GetTransformedCollisionPoly();return a.intersectsSegment(r.GetX(),r.GetY(),e,t,s,i)}_TestSegmentOverlapTilemap(s,i,n,r,e,t){const a=t.GetX(),o=t.GetY(),l=e.GetSdkInstance(),h=tileCollRectCandidates;tempRect2.set(s,i,n,r),tempRect2.normalize(),l.GetCollisionRectCandidates(tempRect2,h);for(let e=0,t=h.length;e<t;++e){const c=h[e],u=c.GetRect();if(this._collisionCheckCount++,tempRect.intersectsRectOffset(u,a,o)&&(tempQuad.setFromRect(u),tempQuad.offset(a,o),tempQuad.intersectsSegment(s,i,n,r))){const _=c.GetPoly();if(!_)return C33.clearArray(h),!0;if(this._polyCheckCount++,_.intersectsSegment(a+u.getLeft(),o+u.getTop(),s,i,n,r))return C33.clearArray(h),!0}}return C33.clearArray(h),!1}TestRectOverlap(e,t){if(!t)return!1;const s=t.GetWorldInfo();if(!s.IsCollisionEnabled())return!1;if(this._collisionCheckCount++,!s.GetBoundingBox().intersectsRect(e))return!1;if(t.HasTilemap())return this._TestRectOverlapTilemap(e,t,s);if(this._polyCheckCount++,tempQuad.setFromRect(e),!s.GetBoundingQuad().intersectsQuad(tempQuad))return!1;if(!s.HasOwnCollisionPoly())return!0;const i=tempPolyA,n=(i.setFromRect(e,s.GetX(),s.GetY()),s.GetTransformedCollisionPoly());return i.intersectsPoly(n,0,0)}_TestRectOverlapTilemap(s,e,t){const i=t.GetX(),n=t.GetY(),r=e.GetSdkInstance(),a=tileCollRectCandidates;r.GetCollisionRectCandidates(s,a);for(let e=0,t=a.length;e<t;++e){const o=a[e],l=o.GetRect();if(this._collisionCheckCount++,s.intersectsRectOffset(l,i,n)){const h=o.GetPoly();if(!h)return C33.clearArray(a),!0;if(this._polyCheckCount++,tempPolyA.setFromRect(s,0,0),h.intersectsPoly(tempPolyA,-(i+l.getLeft()),-(n+l.getTop())))return C33.clearArray(a),!0}}return C33.clearArray(a),!1}TestRayIntersectsInstance(e,t){if(e){const s=e.GetWorldInfo();s.IsCollisionEnabled()&&(this._collisionCheckCount++,s.GetBoundingBox().intersectsRect(t.rect))&&(e.HasTilemap()?this._TestRayIntersectsTilemap(e,s,t):(this._polyCheckCount++,s.HasOwnCollisionPoly()?t.TestInstancePoly(e,s.GetX(),s.GetY(),s.GetTransformedCollisionPoly()):t.TestInstanceQuad(e,s.GetBoundingQuad())))}}_TestRayIntersectsTilemap(s,i,n){const r=i.GetX(),a=i.GetY(),o=tileCollRectCandidates;s.GetSdkInstance().GetCollisionRectCandidates(n.rect,o);for(let e=0,t=o.length;e<t;e++){const l=o[e],h=l.GetRect();if(this._collisionCheckCount++,n.rect.intersectsRectOffset(h,r,a)){const c=l.GetPoly();this._polyCheckCount++,c?n.TestInstancePoly(s,r+h.getLeft(),a+h.getTop(),c):n.TestInstanceRect(s,i.GetX(),i.GetY(),h)}}C33.clearArray(o)}SetCollisionCellSize(e,t){if(e!==this._collisionCellWidth||t!==this._collisionCellHeight){this._collisionCellWidth=e,this._collisionCellHeight=t;const s=this._runtime.GetAllObjectClasses();for(const i of s)if(i.IsWorldType()){for(const n of i.instancesIncludingPendingCreate())n.GetWorldInfo()._RemoveFromCollisionCells();i._GetCollisionCellGrid().SetCellSize(e,t),i._SetAnyCollisionCellChanged();for(const r of i.instancesIncludingPendingCreate()){const a=r.GetWorldInfo();a._SetCollisionCellChanged(),a._UpdateCollisionCell()}}}}GetCollisionCellSize(){return[this._collisionCellWidth,this._collisionCellHeight]}_InitCollisionCellSize(e,t){this._collisionCellWidth=e,this._collisionCellHeight=t}}}{const C33=self.C3;C33.SparseGrid=class extends C33.DefendedBase{constructor(e,t){super(),this._cellWidth=e,this._cellHeight=t,this._cells=C33.New(C33.PairMap)}Release(){this._cells.Release(),this._cells=null}SetCellSize(e,t){if(!this._cells.IsEmpty())throw new Error("grid not empty");this._cellWidth=e,this._cellHeight=t}GetCell(e,t,s){let i=this._cells.Get(e,t);return i||(s?(i=C33.New(C33.GridCell,this,e,t),this._cells.Set(e,t,i),i):null)}XToCell(e){const t=Math.floor(e/this._cellWidth);return isFinite(t)?t:0}YToCell(e){const t=Math.floor(e/this._cellHeight);return isFinite(t)?t:0}Update(i,n,r){if(n)for(let s=n.getLeft(),e=n.getRight();s<=e;++s)for(let e=n.getTop(),t=n.getBottom();e<=t;++e)if(!r||!r.containsPoint(s,e)){const a=this.GetCell(s,e,!1);a&&(a.Remove(i),a.IsEmpty())&&this._cells.Delete(s,e)}if(r)for(let s=r.getLeft(),e=r.getRight();s<=e;++s)for(let e=r.getTop(),t=r.getBottom();e<=t;++e)n&&n.containsPoint(s,e)||this.GetCell(s,e,!0).Insert(i)}QueryRange(e,t){let s=this.XToCell(e.getLeft()),i=this.YToCell(e.getTop()),n=this.XToCell(e.getRight()),r=this.YToCell(e.getBottom());if(isFinite(n)&&isFinite(r))for(;s<=n;++s)for(let e=i;e<=r;++e){const a=this.GetCell(s,e,!1);a&&a.Dump(t)}}}}{const C33=self.C3;C33.GridCell=class extends C33.DefendedBase{constructor(e,t,s){super(),this._grid=e,this._x=t,this._y=s,this._instances=C33.New(C33.ArraySet)}Release(){this._instances.Release(),this._instances=null,this._grid=null}IsEmpty(){return this._instances.IsEmpty()}Insert(e){this._instances.Add(e)}Remove(e){this._instances.Delete(e)}Dump(e){C33.appendArray(e,this._instances.GetArray())}}}{const C33=self.C3,PADDING=1e-6,NO_HIT=2;C33.Ray=class{constructor(){this.x1=0,this.y1=0,this.x2=0,this.y2=0,this.dx=0,this.dy=0,this.rect=new C33.Rect,this.hitFraction=NO_HIT,this.hitUid=null,this.hitNormal=0,this.hitNormalDx=0,this.hitNormalDy=0,this.hitX=0,this.hitY=0,this.distance=0,this.normalX=1,this.normalY=0,this.reflectionX=1,this.reflectionY=0}DidCollide(){return this.hitFraction<1+PADDING}Reset(){this.hitFraction=NO_HIT}Set(e,t,s,i){return this.x1=e,this.y1=t,this.x2=s,this.y2=i,this.dx=s-e,this.dy=i-t,this.rect.set(e,t,s,i),this.rect.normalize(),this.hitFraction=NO_HIT,this.hitUid=null,this.hitNormal=0,this.hitNormalDx=0,this.hitNormalDy=0,this.hitX=0,this.hitY=0,this.distance=0,this.normalX=1,this.normalY=0,this.reflectionX=1,this.reflectionY=0,this}Complete(){if(!1!==this.DidCollide()){const e=this.dx*this.hitFraction,t=this.dy*this.hitFraction,s=C33.hypot2DFast(e,t),i=e/s,n=t/s,r=(this.distance=s-PADDING,this.hitX=this.x1+i*this.distance,this.hitY=this.y1+n*this.distance,this.hitNormal=Math.atan2(this.hitNormalDy,this.hitNormalDx)+Math.PI/2,this.normalX=Math.cos(this.hitNormal),this.normalY=Math.sin(this.hitNormal),i*this.normalX+n*this.normalY);if(this.reflectionX=i-2*this.normalX*r,this.reflectionY=n-2*this.normalY*r,0<r){const a=Math.PI;this.hitNormal=C33.clampAngle(this.hitNormal+a),this.normalX=-this.normalX,this.normalY=-this.normalY}}}TestInstanceSegment(e,t,s,i,n){const r=C33.rayIntersect(this.x1,this.y1,this.x2,this.y2,t,s,i,n);0<=r&&r<this.hitFraction&&(this.hitFraction=r,this.hitUid=e.GetUID(),this.hitNormalDx=t-i,this.hitNormalDy=s-n)}TestInstanceRect(e,t,s,i){const n=t+i.getLeft(),r=t+i.getRight(),a=s+i.getTop(),o=s+i.getBottom();this.TestInstanceSegment(e,n,a,r,a),this.TestInstanceSegment(e,r,a,r,o),this.TestInstanceSegment(e,r,o,n,o),this.TestInstanceSegment(e,n,o,n,a)}TestInstanceQuad(e,t){const s=t.getTlx(),i=t.getTly(),n=t.getTrx(),r=t.getTry(),a=t.getBrx(),o=t.getBry(),l=t.getBlx(),h=t.getBly();this.TestInstanceSegment(e,s,i,n,r),this.TestInstanceSegment(e,n,r,a,o),this.TestInstanceSegment(e,a,o,l,h),this.TestInstanceSegment(e,l,h,s,i)}TestInstancePoly(s,i,n,e){const r=e.pointsArr();for(let e=0,t=r.length;e<t;e+=2){const a=(e+2)%t,o=r[e]+i,l=r[e+1]+n,h=r[a]+i,c=r[1+a]+n;this.TestInstanceSegment(s,o,l,h,c)}}}}{const C33=self.C3,VALID_FULLSCREEN_MODES=new Set(["off","crop","scale-inner","scale-outer","letterbox-scale","letterbox-integer-scale"]),VALID_FULLSCREEN_SCALING_QUALITIES=new Set(["high","low"]),glMatrix=self.glMatrix,mat42=glMatrix.mat4,vec32=glMatrix.vec3,tempProjection=mat42.create(),PERCENTTEXT_WIDTH=300,PERCENTTEXT_HEIGHT=200,PROGRESSBAR_WIDTH=120,PROGRESSBAR_HEIGHT=8,tempQuad=C33.New(C33.Quad),tempRect=C33.New(C33.Rect),SPLASH_MIN_DISPLAY_TIME=3e3,SPLASH_AFTER_FADEOUT_WAIT_TIME=200,SPLASH_FADE_DURATION=300;C33.CanvasManager=class extends C33.DefendedBase{constructor(e){super(),this._runtime=e,this._canvasLayers=[],this._isWebGPUEnabled=!1,this._webglRenderer=null,this._webgpuRenderer=null,this._iRenderer=null,this._gpuPreference="high-performance",this._isLimitedToWebGL1=!1,this._multitexturingMode="auto",this._windowInnerWidth=0,this._windowInnerHeight=0,this._cssDisplayMode="",this._canvasCssWidth=0,this._canvasCssHeight=0,this._canvasDeviceWidth=0,this._canvasDeviceHeight=0,this._canvasCssOffsetX=0,this._canvasCssOffsetY=0,this._zAxisScale="normalized",this._initFieldOfView=0,this._zNear=1,this._zFar=1e4,this._enableMipmaps=!0,this._textureAnisotropy=0,this._drawWidth=0,this._drawHeight=0,this._fullscreenMode="letterbox-scale",this._documentFullscreenMode="letterbox-scale",this._deviceTransformOffX=0,this._deviceTransformOffY=0,this._defaultProjectionMatrix=mat42.create(),this._wantFullscreenScalingQuality="high",this._fullscreenScalingQuality=this._wantFullscreenScalingQuality,this._isDocumentFullscreen=!1,this._availableAdditionalRenderTargets=[],this._usedAdditionalRenderTargets=new Set,this._shaderData=self.C3_Shaders,this._effectChainManager=C33.New(C33.Gfx.EffectChainManager,{getDrawSize:()=>[this.GetDrawWidth(),this.GetDrawHeight()],getRenderTarget:()=>this.GetEffectCompositorRenderTarget(),releaseRenderTarget:e=>this.ReleaseEffectCompositorRenderTarget(e),getTime:()=>this.GetRuntime().GetGameTime(),redraw:()=>this.GetRuntime().UpdateRender()}),this._gpuTimeStartFrame=0,this._gpuTimeEndFrame=0,this._gpuLastUtilisation=NaN,this._gpuFrameTimingsBuffer=null,this._layersGpuProfile=new Map,this._gpuCurUtilisation=NaN,this._webgpuFrameTimings=new Map,this._snapshotFormat="",this._snapshotQuality=1,this._snapshotArea=C33.New(C33.Rect),this._snapshotUrl="",this._snapshotPromise=null,this._snapshotResolve=null,this._isPastingToDrawingCanvas=0,this._loaderStartTime=0,this._rafId=-1,this._loadingProgress=0,this._loadingprogress_handler=e=>this._loadingProgress=e.progress,this._percentText=null,this._splashTextures={logo:null,powered:null,website:null},this._splashFrameNumber=0,this._splashFadeInFinishTime=0,this._splashFadeOutStartTime=0,this._splashState="fade-in",this._splashDoneResolve=null,this._splashDonePromise=new Promise(e=>this._splashDoneResolve=e)}_SetGPUPowerPreference(e){this._gpuPreference=e}_SetWebGPUEnabled(e){this._isWebGPUEnabled=!!e}_SetZAxisScale(e){this._zAxisScale=e}GetZAxisScale(){return this._zAxisScale}_SetInitFieldOfView(e){this._initFieldOfView=e}_SetZDistances(e,t){this._zNear=e,this._zFar=t}_SetLimitedToWebGL1(e){this._isLimitedToWebGL1=!!e}_SetMultitexturingMode(e){this._multitexturingMode=e}async CreateCanvas(e){let t=e.canvas,s=(this._canvasLayers.push({canvas:t,ctx:null}),this._runtime.AddDOMComponentMessageHandler("runtime","window-resize",e=>this._OnWindowResize(e)),this._runtime.AddDOMComponentMessageHandler("runtime","fullscreenchange",e=>this._OnFullscreenChange(e)),this._runtime.AddDOMComponentMessageHandler("runtime","fullscreenerror",e=>this._OnFullscreenError(e)),t.addEventListener("webglcontextlost",e=>this._OnWebGLContextLost(e)),t.addEventListener("webglcontextrestored",e=>this._OnWebGLContextRestored(e)),this._isDocumentFullscreen=!!e.isFullscreen,this._cssDisplayMode=e.cssDisplayMode,navigator.gpu&&this._isWebGPUEnabled),i=!1;if(s)try{await this._InitWebGPUContext(!0)}catch(e){this._MaybeLogRendererError("WebGPU",e),this._webgpuRenderer=null}if(!this.GetRenderer())try{await this._InitWebGLContext(!0)}catch(e){this._MaybeLogRendererError("WebGL",e),this._webglRenderer=null}if(this.GetRenderer()||(i=!0),!this.GetRenderer()&&s)try{await this._InitWebGPUContext(!1)}catch(e){this._MaybeLogRendererError("WebGPU",e),this._webgpuRenderer=null}if(!this.GetRenderer())try{await this._InitWebGLContext(!1)}catch(e){this._MaybeLogRendererError("WebGL",e),this._webglRenderer=null}const n=this.GetRenderer();if(!n)throw new Error("failed to acquire a renderer - check WebGL or WebGPU is supported");n.SetHasMajorPerformanceCaveat(i),this._webgpuRenderer&&(this._webgpuRenderer.ondevicelost=()=>this._OnWebGPUDeviceLost(),this._webgpuRenderer.ondevicerestored=()=>this._OnWebGPUDeviceRestored()),"normalized"===this._zAxisScale?n.SetZAxisScaleNormalized():(n.SetZAxisScaleRegular(),n.SetFovY(this._initFieldOfView)),this.SetSize(e.windowInnerWidth,e.windowInnerHeight,!0),await this._InitRenderer()}_MaybeLogRendererError(e,t){t&&"string"==typeof t.message&&t.message.startsWith("renderer-unavailable")||console.error(`Error creating ${e} renderer: `,t)}async _InitWebGPUContext(e){let t={nearZ:this._zNear,farZ:this._zFar},s=!0;"no"===this._multitexturingMode?s=!1:"auto"===this._multitexturingMode&&(s=C33.Platform.IsDesktop);const i={powerPreference:this._gpuPreference,depth:this._runtime.Uses3DFeatures(),failIfMajorPerformanceCaveat:e,usesBackgroundBlending:this._runtime.UsesAnyBackgroundBlending(),canSampleBackbuffer:this._runtime.UsesAnyCrossSampling(),canSampleDepth:this._runtime.UsesAnyDepthSampling(),isMultiTexturingAllowed:s};this._webgpuRenderer=C33.New(C33.Gfx.WebGPURenderer,t),await this._webgpuRenderer.Create(this._canvasLayers[0].canvas,i)}async _InitWebGLContext(e){const t={alpha:!0,powerPreference:this._gpuPreference,enableGpuProfiling:"xbox-uwp-webview2"!==this._runtime.GetExportType(),depth:this._runtime.Uses3DFeatures(),canSampleDepth:this._runtime.UsesAnyDepthSampling(),failIfMajorPerformanceCaveat:e,nearZ:this._zNear,farZ:this._zFar};this._isLimitedToWebGL1&&(t.maxWebGLVersion=1),this._webglRenderer=C33.New(C33.Gfx.WebGLRenderer,this._canvasLayers[0].canvas,t),await this._webglRenderer.InitState()}async _InitWebGPU(){if(this._shaderData){const e=[];for(const[t,s]of Object.entries(this._shaderData)){s.src=s.wgsl;const i=C33.Gfx.WebGPUShaderProgram.GetDefaultVertexShaderSource();e.push(this._webgpuRenderer.CreateShaderProgram(Object.assign({vertexSrc:i,name:t},s)))}await Promise.all(e)}}async _InitWebGL(){if(this._shaderData){const t=[];for(const[s,i]of Object.entries(this._shaderData)){let e;if(i.glslWebGL2&&2<=this._webglRenderer.GetWebGLVersionNumber())i.src=i.glslWebGL2,e=C33.Gfx.WebGLShaderProgram.GetDefaultVertexShaderSource_WebGL2();else{if(!i.glsl)throw new Error(`shader '${s}' does not support WebGL 1`);i.src=i.glsl,e=C33.Gfx.WebGLShaderProgram.GetDefaultVertexShaderSource()}t.push(this._webglRenderer.CreateShaderProgram(Object.assign({vertexSrc:e,name:s},i)))}await Promise.all(t),this._webglRenderer.ResetLastProgram(),this._webglRenderer.SetTextureFillMode()}this._webglRenderer.SupportsGPUProfiling()&&(this._gpuFrameTimingsBuffer=C33.New(C33.Gfx.WebGLQueryResultBuffer,this._webglRenderer))}async _InitRenderer(){this._webgpuRenderer?await this._InitWebGPU():this._webglRenderer&&await this._InitWebGL();const e=this.GetRenderer();e.SetMipmapsEnabled(this._enableMipmaps),e.SupportsGPUProfiling()&&(this._gpuLastUtilisation=0);for(const t of this._runtime._GetAllEffectLists()){for(const s of t.GetAllEffectTypes())s._InitRenderer(e);t._InitRenderer(e),t.UpdateActiveEffects()}this._iRenderer=new self.IRenderer(this._runtime,e)}Release(){this._runtime=null,this._webglRenderer=null,this._canvasLayers.length=0}IsInWorker(){return this._runtime.IsInWorker()}_OnWindowResize(e){const t=this._runtime;if(!t.IsExportToVideo()){const s=e.devicePixelRatio,i=(this.IsInWorker()&&(self.devicePixelRatio=s),t._SetDevicePixelRatio(s),this._isDocumentFullscreen=!!e.isFullscreen,this._cssDisplayMode=e.cssDisplayMode,this.SetSize(e.innerWidth,e.innerHeight),t.UpdateRender(),new C33.Event("window-resize")),n=(i.data=e,t.Dispatcher().dispatchEventAndWaitAsyncSequential(i),new C33.Event("resize"));n.cssWidth=this.GetCssWidth(),n.cssHeight=this.GetCssHeight(),n.deviceWidth=this.GetDeviceWidth(),n.deviceHeight=this.GetDeviceHeight(),t.DispatchUserScriptEvent(n),t.IsDebug()&&(t.HitBreakpoint()||self.C3Debugger.IsDebuggerPaused())&&t.Render()}}_OnFullscreenChange(e){this._isDocumentFullscreen=!!e.isFullscreen,this.SetSize(e.innerWidth,e.innerHeight,!0),this._runtime.UpdateRender()}_OnFullscreenError(e){this._isDocumentFullscreen=!!e.isFullscreen,this.SetSize(e.innerWidth,e.innerHeight,!0),this._runtime.UpdateRender()}SetSize(e,t,s=!1){if(e=Math.floor(e),t=Math.floor(t),e<=0||t<=0)throw new Error("invalid size");if(this._windowInnerWidth!==e||this._windowInnerHeight!==t||s){this._windowInnerWidth=e,this._windowInnerHeight=t;const i=this.GetCurrentFullscreenMode();"letterbox-scale"===i?this._CalculateLetterboxScale(e,t):"letterbox-integer-scale"===i?this._CalculateLetterboxIntegerScale(e,t):"off"===i?this._CalculateFixedSizeCanvas(e,t):this._CalculateFullsizeCanvas(e,t),this._UpdateFullscreenScalingQuality(i);for(const{canvas:a}of this._canvasLayers)a.width=this._canvasDeviceWidth,a.height=this._canvasDeviceHeight;this._runtime.PostComponentMessageToDOM("canvas","update-size",{marginLeft:this._canvasCssOffsetX,marginTop:this._canvasCssOffsetY,styleWidth:this._canvasCssWidth,styleHeight:this._canvasCssHeight,displayScale:this.GetDisplayScale()});const n=this.GetRenderer();n.SetSize(this._canvasDeviceWidth,this._canvasDeviceHeight,!0);for(const o of this._availableAdditionalRenderTargets)n.DeleteRenderTarget(o);C33.clearArray(this._availableAdditionalRenderTargets),this.UpdateDefaultProjectionMatrix();const r=this._runtime.GetLayoutManager();r.SetAllLayerProjectionChanged(),r.SetAllLayerMVChanged()}}UpdateDefaultProjectionMatrix(){this.GetRenderer().CalculatePerspectiveMatrix(this._defaultProjectionMatrix,this.GetDrawWidth()/this.GetDrawHeight())}GetDefaultProjectionMatrix(){return this._defaultProjectionMatrix}_CalculateLetterboxScale(e,t){const s=this._runtime.GetDevicePixelRatio(),i=this._runtime.GetOriginalViewportWidth(),n=this._runtime.GetOriginalViewportHeight(),r=i/n,a=e/t;if(r<a){const o=t*r;this._canvasCssWidth=Math.round(o),this._canvasCssHeight=t,this._canvasCssOffsetX=Math.floor((e-this._canvasCssWidth)/2),this._canvasCssOffsetY=0}else{const l=e/r;this._canvasCssWidth=e,this._canvasCssHeight=Math.round(l),this._canvasCssOffsetX=0,this._canvasCssOffsetY=Math.floor((t-this._canvasCssHeight)/2)}this._canvasDeviceWidth=Math.round(this._canvasCssWidth*s),this._canvasDeviceHeight=Math.round(this._canvasCssHeight*s),this._runtime.SetViewportSize(i,n)}_CalculateLetterboxIntegerScale(e,t){let s=this._runtime.GetDevicePixelRatio(),i=(1!==s&&(e+=1,t+=1),this._runtime.GetOriginalViewportWidth()),n=this._runtime.GetOriginalViewportHeight(),r=i/n,a=e/t,o;if(r<a){const l=t*r;o=l*s/i}else{const h=e/r;o=h*s/n}1<o?o=Math.floor(o):o<1&&(o=1/Math.ceil(1/o)),this._canvasDeviceWidth=Math.round(i*o),this._canvasDeviceHeight=Math.round(n*o),this._canvasCssWidth=this._canvasDeviceWidth/s,this._canvasCssHeight=this._canvasDeviceHeight/s,this._canvasCssOffsetX=Math.max(Math.floor((e-this._canvasCssWidth)/2),0),this._canvasCssOffsetY=Math.max(Math.floor((t-this._canvasCssHeight)/2),0),this._runtime.SetViewportSize(i,n)}_CalculateFullsizeCanvas(e,t){const s=this._runtime.GetDevicePixelRatio(),i=(this._canvasCssWidth=e,this._canvasCssHeight=t,this._canvasDeviceWidth=Math.round(this._canvasCssWidth*s),this._canvasDeviceHeight=Math.round(this._canvasCssHeight*s),this._canvasCssOffsetX=0,this._canvasCssOffsetY=0,this.GetDisplayScale());this._runtime.SetViewportSize(this._canvasCssWidth/i,this._canvasCssHeight/i)}_CalculateFixedSizeCanvas(e,t){const s=this._runtime.GetDevicePixelRatio();this._canvasCssWidth=this._runtime.GetViewportWidth(),this._canvasCssHeight=this._runtime.GetViewportHeight(),this._canvasDeviceWidth=Math.round(this._canvasCssWidth*s),this._canvasDeviceHeight=Math.round(this._canvasCssHeight*s),this.IsDocumentFullscreen()?(this._canvasCssOffsetX=Math.floor((e-this._canvasCssWidth)/2),this._canvasCssOffsetY=Math.floor((t-this._canvasCssHeight)/2)):(this._canvasCssOffsetX=0,this._canvasCssOffsetY=0),this._runtime.SetViewportSize(this._runtime.GetViewportWidth(),this._runtime.GetViewportHeight())}_UpdateFullscreenScalingQuality(s){if("high"===this._wantFullscreenScalingQuality)this._drawWidth=this._canvasDeviceWidth,this._drawHeight=this._canvasDeviceHeight,this._fullscreenScalingQuality="high";else{let e,t;if(t="off"===this.GetCurrentFullscreenMode()?(e=this._runtime.GetViewportWidth(),this._runtime.GetViewportHeight()):(e=this._runtime.GetOriginalViewportWidth(),this._runtime.GetOriginalViewportHeight()),this._canvasDeviceWidth<e||this._canvasDeviceHeight<t)this._drawWidth=this._canvasDeviceWidth,this._drawHeight=this._canvasDeviceHeight,this._fullscreenScalingQuality="high";else if(this._drawWidth=e,this._drawHeight=t,this._fullscreenScalingQuality="low","scale-inner"===s){const i=e/t,n=this._windowInnerWidth/this._windowInnerHeight;n<i?this._drawWidth=this._drawHeight*n:i<n&&(this._drawHeight=this._drawWidth/n)}else if("scale-outer"===s){const r=e/t,a=this._windowInnerWidth/this._windowInnerHeight;r<a?this._drawWidth=this._drawHeight*a:a<r&&(this._drawHeight=this._drawWidth/a)}}}GetRuntime(){return this._runtime}GetMainCanvas(){return this._canvasLayers[0].canvas}GetEffectChainManager(){return this._effectChainManager}IsDocumentFullscreen(){return this._isDocumentFullscreen}GetCssDisplayMode(){return this._cssDisplayMode}SetFullscreenMode(e){if(!VALID_FULLSCREEN_MODES.has(e))throw new Error("invalid fullscreen mode");this._fullscreenMode=e;const t=this._runtime.GetLayoutManager();t.SetAllLayerProjectionChanged(),t.SetAllLayerMVChanged()}GetFullscreenMode(){return this._fullscreenMode}SetDocumentFullscreenMode(e){if(!VALID_FULLSCREEN_MODES.has(e))throw new Error("invalid fullscreen mode");this._documentFullscreenMode=e;const t=this._runtime.GetLayoutManager();t.SetAllLayerProjectionChanged(),t.SetAllLayerMVChanged()}GetDocumentFullscreenMode(){return this._documentFullscreenMode}GetCurrentFullscreenMode(){return this.IsDocumentFullscreen()?this.GetDocumentFullscreenMode():this.GetFullscreenMode()}SetFullscreenScalingQuality(e){if(!VALID_FULLSCREEN_SCALING_QUALITIES.has(e))throw new Error("invalid fullscreen scaling quality");this._wantFullscreenScalingQuality=e,this._runtime.GetLayoutManager().SetAllLayerProjectionChanged()}GetSetFullscreenScalingQuality(){return this._wantFullscreenScalingQuality}GetCurrentFullscreenScalingQuality(){return this._fullscreenScalingQuality}static _FullscreenModeNumberToString(e){switch(e){case 0:return"off";case 1:return"crop";case 2:return"scale-inner";case 3:return"scale-outer";case 4:return"letterbox-scale";case 5:return"letterbox-integer-scale";default:throw new Error("invalid fullscreen mode")}}GetLastWidth(){return this._windowInnerWidth}GetLastHeight(){return this._windowInnerHeight}GetDrawWidth(){return this._drawWidth}GetDrawHeight(){return this._drawHeight}SetMipmapsEnabled(e){this._enableMipmaps=!!e}_SetTextureAnisotropy(e){this._textureAnisotropy=e}GetTextureAnisotropy(){return this._textureAnisotropy}IsRendererContextLost(){return this.GetRenderer().IsContextLost()}_OnWebGLContextLost(e){console.log("[Construct] WebGL context lost"),e.preventDefault(),this._availableAdditionalRenderTargets=[],this._usedAdditionalRenderTargets.clear(),this._effectChainManager.OnContextLost(),this._webglRenderer.OnContextLost(),this._runtime._OnRendererContextLost()}_OnWebGPUDeviceLost(){console.log("[Construct] WebGPU device lost"),this._availableAdditionalRenderTargets=[],this._usedAdditionalRenderTargets.clear(),this._effectChainManager.OnContextLost(),this._runtime._OnRendererContextLost()}async _OnWebGLContextRestored(e){await this._webglRenderer.OnContextRestored(),await this._InitRenderer(),await this._runtime._OnRendererContextRestored(),console.log("[Construct] WebGL context restored")}async _OnWebGPUDeviceRestored(){await this._InitRenderer(),await this._runtime._OnRendererContextRestored(),console.log("[Construct] WebGPU device restored")}GetWebGLRenderer(){return this._webglRenderer}GetWebGPURenderer(){return this._webgpuRenderer}GetRenderer(){return this._webgpuRenderer||this._webglRenderer}GetIRenderer(){return this._iRenderer}GetRendererString(){let e="";return e=this._runtime.GetWebGPURenderer()?"webgpu":"webgl"+this._runtime.GetWebGLRenderer().GetWebGLVersionNumber(),this._runtime.GetRenderer().HasMajorPerformanceCaveat()&&(e+="-software"),e}GetRendererDetailString(){return this._runtime.GetWebGPURenderer()?this._runtime.GetWebGPURenderer().GetAdapterInfoString():this._runtime.GetWebGLRenderer().GetUnmaskedRenderer()}GetRenderScale(){return"low"===this._fullscreenScalingQuality?1/this._runtime.GetDevicePixelRatio():this.GetDisplayScale()}GetDisplayScale(){const e=this.GetCurrentFullscreenMode();if("off"===e||"crop"===e)return 1;const t=this._runtime.GetOriginalViewportWidth(),s=this._runtime.GetOriginalViewportHeight(),i=t/s,n=this._canvasDeviceWidth/this._canvasDeviceHeight;return"scale-inner"!==e&&i<n||"scale-inner"===e&&n<i?this._canvasCssHeight/s:this._canvasCssWidth/t}GetEffectLayerScaleParam(){return"low"===this.GetCurrentFullscreenScalingQuality()?1:this.GetDisplayScale()}GetEffectDevicePixelRatioParam(){return"low"===this.GetCurrentFullscreenScalingQuality()?1:this._runtime.GetDevicePixelRatio()}SetDeviceTransformOffset(e,t){this._deviceTransformOffX=e,this._deviceTransformOffY=t}SetDeviceTransform(t,s,i,e=!0){s=s||this._drawWidth,i=i||this._drawHeight;const n=s/2+this._deviceTransformOffX,r=i/2+this._deviceTransformOffY;if(e){let e=this.GetDefaultProjectionMatrix();s===this._drawWidth&&i===this._drawHeight||(t.CalculatePerspectiveMatrix(tempProjection,s/i),e=tempProjection),t.SetProjectionMatrix(e)}const a=t.CalculateLookAtModelView2(n,r,t.GetDefaultCameraZ(i),n,r,0,i);t.SetModelViewMatrix(a)}SetCssTransform(e,t=!0){const s=this.GetCssWidth(),i=this.GetCssHeight(),n=s/2,r=i/2,a=(t&&e.SetProjectionMatrix(this.GetDefaultProjectionMatrix()),e.CalculateLookAtModelView2(n,r,e.GetDefaultCameraZ(i),n,r,0,i));e.SetModelViewMatrix(a)}GetDeviceWidth(){return this._canvasDeviceWidth}GetDeviceHeight(){return this._canvasDeviceHeight}GetCssWidth(){return this._canvasCssWidth}GetCssHeight(){return this._canvasCssHeight}GetCanvasClientX(){return this._canvasCssOffsetX}GetCanvasClientY(){return this._canvasCssOffsetY}GetHTMLLayerCount(){return this._canvasLayers.length}_CanUseImageBitmapRenderingContext(){return"undefined"!=typeof OffscreenCanvas&&this.GetMainCanvas()instanceof OffscreenCanvas&&("Chromium"!==C33.Platform.BrowserEngine||124<=C33.Platform.BrowserVersionNumber)}async SetHTMLLayerCount(i,n=!1){if(i<1)throw new Error("invalid HTML layer count");if(this._canvasLayers.length!==i){let e=this._runtime.GetLayoutManager().GetMainRunningLayout(),t={count:i,layersDomState:e._GetRootLayers().filter(e=>e.IsHTMLElementsLayer()).map(e=>e._GetHTMLLayerDOMState()),immediate:n,marginLeft:this._canvasCssOffsetX,marginTop:this._canvasCssOffsetY,styleWidth:this._canvasCssWidth,styleHeight:this._canvasCssHeight},s;if(s=this.IsInWorker()?await this._runtime.PostComponentMessageToDOMAsync("canvas","set-html-layer-count",t):self.c3_runtimeInterface._OnSetHTMLLayerCount(t),i<this._canvasLayers.length)this._canvasLayers.length=i;else for(const r of s.addedCanvases){r.width=this._canvasDeviceWidth,r.height=this._canvasDeviceHeight;const a=this._CanUseImageBitmapRenderingContext()?"bitmaprenderer":"2d",o=r.getContext(a);if(!o)throw new Error(`failed to acquire '${a}' canvas context`);this._canvasLayers.push({canvas:r,ctx:o})}this._runtime.UpdateRender()}}BlitMainCanvasToHTMLLayerCanvas(e){if(!(e>=this._canvasLayers.length)){const t=this.GetMainCanvas(),s=this._canvasLayers[e].ctx;this._CanUseImageBitmapRenderingContext()?s.transferFromImageBitmap(t.transferToImageBitmap()):(s.globalCompositeOperation="copy",s.drawImage(t,0,0))}}GetAdditionalRenderTarget(t){t.depth=this._runtime.Uses3DFeatures();let e=this._availableAdditionalRenderTargets,s=e.findIndex(e=>e.IsCompatibleWithOptions(t)),i;return-1!==s?(i=e[s],e.splice(s,1)):i=this.GetRenderer().CreateRenderTarget(t),this._usedAdditionalRenderTargets.add(i),i}ReleaseAdditionalRenderTarget(e){if(!this._usedAdditionalRenderTargets.has(e))throw new Error("render target not in use");this._usedAdditionalRenderTargets.delete(e),this._availableAdditionalRenderTargets.push(e)}GetEffectCompositorRenderTarget(){const e={sampling:this._runtime.GetSampling()};return"low"===this.GetCurrentFullscreenScalingQuality()&&(e.width=this.GetDrawWidth(),e.height=this.GetDrawHeight()),this.GetAdditionalRenderTarget(e)}ReleaseEffectCompositorRenderTarget(e){this.ReleaseAdditionalRenderTarget(e)}*activeLayersGpuProfiles(){for(const e of this._runtime.GetLayoutManager().runningLayouts())for(const t of e.GetLayers()){const s=this._layersGpuProfile.get(t);s&&(yield s)}}GetLayerTimingsBuffer(e){if(!this.GetRenderer().SupportsGPUProfiling())return null;let t=this._layersGpuProfile.get(e);return t||(t={layer:e,name:e.GetName(),timingsBuffer:C33.New(C33.Gfx.WebGLQueryResultBuffer,this._webglRenderer),curUtilisation:0,lastTotalUtilisation:0,lastSelfUtilisation:0},this._layersGpuProfile.set(e,t)),t.timingsBuffer}_Update1sFrameRange(){const e=this.GetRenderer();if(e.SupportsGPUProfiling()&&0===this._gpuTimeEndFrame){this._gpuTimeEndFrame=e.GetFrameNumber(),this._gpuCurUtilisation=NaN;for(const t of this.activeLayersGpuProfiles())t.curUtilisation=NaN}}_UpdateTick(){this._webglRenderer&&this._webglRenderer.SupportsGPUProfiling()&&this._UpdateTick_WebGL(),this._webgpuRenderer&&this._webgpuRenderer.SupportsGPUProfiling()&&this._UpdateTick_WebGPU()}_UpdateTick_WebGL(){if(isNaN(this._gpuCurUtilisation)&&(this._gpuCurUtilisation=this._gpuFrameTimingsBuffer.GetFrameRangeResultSum(this._gpuTimeStartFrame,this._gpuTimeEndFrame),!isNaN(this._gpuCurUtilisation))){if(this._runtime.IsDebug())for(const e of this.activeLayersGpuProfiles())if(e.curUtilisation=e.timingsBuffer.GetFrameRangeResultSum(this._gpuTimeStartFrame,this._gpuTimeEndFrame),isNaN(e.curUtilisation))return;if(this._gpuFrameTimingsBuffer.DeleteAllBeforeFrameNumber(this._gpuTimeEndFrame),this._gpuLastUtilisation=Math.min(this._gpuCurUtilisation,1),this._runtime.IsDebug()){const s=new Map;for(const n of this.activeLayersGpuProfiles())n.timingsBuffer.DeleteAllBeforeFrameNumber(this._gpuTimeEndFrame),n.lastTotalUtilisation=Math.min(n.curUtilisation,1),s.set(n.layer,n.lastTotalUtilisation);for(const r of this.activeLayersGpuProfiles()){const a=r.layer,o=s.get(a)||0,l=o-a.GetSubLayers().reduce((e,t)=>e+(s.get(t)||0),0);r.lastSelfUtilisation=C33.clamp(l,0,1)}const t=this._runtime.GetMainRunningLayout(),i=this._gpuLastUtilisation-t._GetRootLayers().reduce((e,t)=>e+(s.get(t)||0),0);self.C3Debugger.UpdateGPUProfile(C33.clamp(i,0,1),this._gpuLastUtilisation,[...this.activeLayersGpuProfiles()])}this._gpuTimeStartFrame=this._gpuTimeEndFrame,this._gpuTimeEndFrame=0}}GetGPUFrameTimingsBuffer(){return this._gpuFrameTimingsBuffer}_UpdateTick_WebGPU(){if(0!==this._gpuTimeEndFrame){for(let e=this._gpuTimeStartFrame;e<this._gpuTimeEndFrame;++e){const s=this._webgpuFrameTimings.get(e);if(s&&!s.HasResult())return}let e=this._runtime.GetMainRunningLayout(),a=C33.MakeFilledArray(e.GetLayerCount()+1,0),t=0;for(let e=this._gpuTimeStartFrame;e<this._gpuTimeEndFrame;++e){const o=this._webgpuFrameTimings.get(e);if(o){let s=o.GetResult(),i=BigInt(0),n=BigInt(0),r=BigInt(0);for(let e=0,t=Math.min(a.length,s.length/2);e<t;++e){const c=s[2*e],u=s[2*e+1],_=(c!==r&&(i===r||c<i)&&(i=c),u>n&&(n=u),u-c),d=Number(_)/1e9;a[e]+=d}const l=n-i,h=Number(l)/1e9;t+=h}}if(this._gpuLastUtilisation=C33.clamp(t,0,1),this._runtime.IsDebug()){const i=e.GetLayers(),n=new Map;for(let e=0,t=Math.min(i.length,a.length-1);e<t;++e){const g=a[e+1];n.set(i[e],g)}const r=[],p=new Map;for(const[f,S]of n){const C=[...f.selfAndAllSubLayers()].reduce((e,t)=>e+(n.get(t)||0),0);p.set(f,C),r.push({name:f.GetName(),lastSelfUtilisation:C33.clamp(S,0,1),lastTotalUtilisation:C33.clamp(C,0,1)})}const m=this._gpuLastUtilisation-e._GetRootLayers().reduce((e,t)=>e+(p.get(t)||0),0);self.C3Debugger.UpdateGPUProfile(C33.clamp(m,0,1),this._gpuLastUtilisation,r)}for(let e=this._gpuTimeStartFrame;e<this._gpuTimeEndFrame;++e)this._webgpuFrameTimings.delete(e);this._gpuTimeStartFrame=this._gpuTimeEndFrame,this._gpuTimeEndFrame=0}}_AddWebGPUFrameTiming(e){this._webgpuFrameTimings.set(this._webgpuRenderer.GetFrameNumber(),e)}GetGPUUtilisation(){return this._gpuLastUtilisation}SnapshotCanvas(e,t,s,i,n,r){return this._snapshotFormat=e,this._snapshotQuality=t,this._snapshotArea.setWH(s,i,n,r),this._snapshotPromise||(this._snapshotPromise=new Promise(e=>{this._snapshotResolve=e})),this._snapshotPromise}_MaybeTakeSnapshot(){if(this._snapshotFormat){let e=this.GetMainCanvas(),t=this._snapshotArea,s=C33.clamp(Math.floor(t.getLeft()),0,e.width),i=C33.clamp(Math.floor(t.getTop()),0,e.height),n=t.width(),r=(n=0===n?e.width-s:C33.clamp(Math.floor(n),0,e.width-s),t.height());if(r=0===r?e.height-i:C33.clamp(Math.floor(r),0,e.height-i),(0!==s||0!==i||n!==e.width||r!==e.height)&&0<n&&0<r){const a=C33.CreateCanvas(n,r),o=a.getContext("2d");o.drawImage(e,s,i,n,r,0,0,n,r),e=a}C33.CanvasToBlob(e,this._snapshotFormat,this._snapshotQuality).then(e=>{this._snapshotUrl&&URL.revokeObjectURL(this._snapshotUrl),this._snapshotUrl=URL.createObjectURL(e),this._snapshotPromise=null,this._snapshotResolve(this._snapshotUrl)}),this._snapshotFormat="",this._snapshotQuality=1}}GetCanvasSnapshotUrl(){return this._snapshotUrl}SetIsPastingToDrawingCanvas(e){e?this._isPastingToDrawingCanvas++:this._isPastingToDrawingCanvas--}IsPastingToDrawingCanvas(){return 0<this._isPastingToDrawingCanvas}InitLoadingScreen(e){const t=this.GetRenderer();if(2===e)this._percentText=C33.New(C33.Gfx.RendererText,this.GetRenderer()),this._percentText.SetFontName("Arial"),this._percentText.SetFontSize(16),this._percentText.SetHorizontalAlignment("center"),this._percentText.SetVerticalAlignment("center"),this._percentText.SetSize(PERCENTTEXT_WIDTH,PERCENTTEXT_HEIGHT);else if(0===e){const s=this._runtime.GetLoadingLogoAsset();s&&s.LoadStaticTexture(t).catch(e=>console.warn("[C3 runtime] Failed to create texture for loading logo: ",e))}else 4===e&&(this._LoadSvgSplashImage("splash-images/splash-logo.svg").then(e=>{"done"===this._splashState?t.DeleteTexture(e):this._splashTextures.logo=e}).catch(e=>console.warn("Failed to load splash image: ",e)),this._LoadBitmapSplashImage("splash-images/splash-poweredby-512.png").then(e=>{"done"===this._splashState?t.DeleteTexture(e):this._splashTextures.powered=e}).catch(e=>console.warn("Failed to load splash image: ",e)),this._LoadBitmapSplashImage("splash-images/splash-website-512.png").then(e=>{"done"===this._splashState?t.DeleteTexture(e):this._splashTextures.website=e}).catch(e=>console.warn("Failed to load splash image: ",e)))}async _LoadSvgSplashImage(e){e=new URL(e,this._runtime.GetRuntimeBaseURL()).toString();const t=await C33.FetchBlob(e),s=await this._runtime.RasterSvgImage(t,2048,2048);return this.GetRenderer().CreateStaticTextureAsync(s,{mipMapQuality:"high"})}async _LoadBitmapSplashImage(e){e=new URL(e,this._runtime.GetRuntimeBaseURL()).toString();const t=await C33.FetchBlob(e);return this.GetRenderer().CreateStaticTextureAsync(t,{mipMapQuality:"high"})}HideCordovaSplashScreen(){this._runtime.PostComponentMessageToDOM("runtime","hide-cordova-splash")}StartLoadingScreen(){this._loaderStartTime=Date.now(),this._runtime.Dispatcher().addEventListener("loadingprogress",this._loadingprogress_handler),this._rafId=requestAnimationFrame(()=>this._DrawLoadingScreen());const e=this._runtime.GetLoaderStyle();3!==e&&this.HideCordovaSplashScreen()}async EndLoadingScreen(){const e=this.GetRenderer(),t=(this._loadingProgress=1,this._runtime.GetLoaderStyle());4===t&&await this._splashDonePromise,this._splashDoneResolve=null,this._splashDonePromise=null,-1!==this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=-1),this._runtime.Dispatcher().removeEventListener("loadingprogress",this._loadingprogress_handler),this._loadingprogress_handler=null,this._percentText&&(this._percentText.Release(),this._percentText=null),this._runtime.ReleaseLoadingLogoAsset(),e.Start(),this._splashTextures.logo&&(e.DeleteTexture(this._splashTextures.logo),this._splashTextures.logo=null),this._splashTextures.powered&&(e.DeleteTexture(this._splashTextures.powered),this._splashTextures.powered=null),this._splashTextures.website&&(e.DeleteTexture(this._splashTextures.website),this._splashTextures.website=null),e.ClearRgba(0,0,0,0),e.Finish(),this._splashState="done",this._gpuTimeStartFrame=e.GetFrameNumber(),3===t&&this.HideCordovaSplashScreen()}_DrawLoadingScreen(){if(-1!==this._rafId){const e=this.GetRenderer(),t=(e.Start(),this._rafId=-1,this._runtime.GetAssetManager().HasHadErrorLoading()),s=this._runtime.GetLoaderStyle();if(3!==s&&(this.SetCssTransform(e),e.ClearRgba(0,0,0,0),e.ResetColor(),e.SetTextureFillMode(),e.SetTexture(null)),0===s)this._DrawProgressBarAndLogoLoadingScreen(t);else if(1===s)this._DrawProgressBarLoadingScreen(t,PROGRESSBAR_WIDTH,0);else if(2===s)this._DrawPercentTextLoadingScreen(t);else if(3===s)C33.noop();else{if(4!==s)throw new Error("invalid loader style");this._DrawSplashLoadingScreen(t)}e.Finish(),this._rafId=requestAnimationFrame(()=>this._DrawLoadingScreen())}}_DrawPercentTextLoadingScreen(e){e?this._percentText.SetColorRgb(1,0,0):this._percentText.SetColorRgb(.6,.6,.6),this._percentText.SetText(Math.round(100*this._loadingProgress)+"%");const t=this._canvasCssWidth/2,s=this._canvasCssHeight/2,i=PERCENTTEXT_WIDTH/2,n=PERCENTTEXT_HEIGHT/2,r=(tempQuad.setRect(t-i,s-n,t+i,s+n),this.GetRenderer());r.SetTexture(this._percentText.GetTexture()),r.Quad3(tempQuad,this._percentText.GetTexRect())}_DrawProgressBarLoadingScreen(e,t,s){const i=this.GetRenderer(),n=PROGRESSBAR_HEIGHT,r=(i.SetColorFillMode(),e?i.SetColorRgba(1,0,0,1):i.SetColorRgba(.118,.565,1,1),this._canvasCssWidth/2),a=this._canvasCssHeight/2,o=t/2,l=n/2;tempRect.setWH(r-o,a-l+s,Math.floor(t*this._loadingProgress),n),i.Rect(tempRect),tempRect.setWH(r-o,a-l+s,t,n),tempRect.offset(-.5,-.5),tempRect.inflate(.5,.5),i.SetColorRgba(0,0,0,1),i.LineRect2(tempRect),tempRect.inflate(1,1),i.SetColorRgba(1,1,1,1),i.LineRect2(tempRect)}_DrawProgressBarAndLogoLoadingScreen(e){const t=this.GetRenderer(),s=this._runtime.GetLoadingLogoAsset();if(s){const i=s.GetTexture();if(i){const n=i.GetWidth(),r=i.GetHeight(),a=this._canvasCssWidth/2,o=this._canvasCssHeight/2,l=n/2,h=r/2;tempQuad.setRect(a-l,o-h,a+l,o+h),t.SetTexture(i),t.Quad(tempQuad),this._DrawProgressBarLoadingScreen(e,n,16+h)}else this._DrawProgressBarLoadingScreen(e,PROGRESSBAR_WIDTH,0)}else this._DrawProgressBarLoadingScreen(e,PROGRESSBAR_WIDTH,0)}_DrawSplashLoadingScreen(e){let t=this.GetRenderer(),s=this._splashTextures.logo,i=this._splashTextures.powered,n=this._splashTextures.website,r=Date.now(),a=(0===this._splashFrameNumber&&(this._loaderStartTime=r),this._runtime.IsPreview()||this._runtime.IsFBInstantAvailable()&&!this._runtime.IsCordova()),o=a?0:SPLASH_AFTER_FADEOUT_WAIT_TIME,l=a?0:SPLASH_MIN_DISPLAY_TIME,h=1,c=("fade-in"===this._splashState?h=Math.min((r-this._loaderStartTime)/SPLASH_FADE_DURATION,1):"fade-out"===this._splashState&&(h=Math.max(1-(r-this._splashFadeOutStartTime)/SPLASH_FADE_DURATION,0)),t.SetColorFillMode(),t.SetColorRgba(.231*h,.251*h,.271*h,h),tempRect.set(0,0,this._canvasCssWidth,this._canvasCssHeight),t.Rect(tempRect),Math.ceil(this._canvasCssWidth)),u=Math.ceil(this._canvasCssHeight),_,d;256<this._canvasCssHeight?(t.SetColorRgba(.302*h,.334*h,.365*h,h),_=c,d=Math.max(.005*u,2),tempRect.setWH(0,.8*u-d/2,_,d),t.Rect(tempRect),e?t.SetColorRgba(h,0,0,h):t.SetColorRgba(.161*h,.953*h,.816*h,h),_=c*this._loadingProgress,tempRect.setWH(.5*c-_/2,.8*u-d/2,_,d),t.Rect(tempRect),t.SetColorRgba(h,h,h,h),t.SetTextureFillMode(),i&&(_=1.5*C33.clamp(.22*u,105,.6*c),d=_/8,tempRect.setWH(.5*c-_/2,.2*u-d/2,_,d),t.SetTexture(i),t.Rect(tempRect)),s&&(_=Math.min(.395*u,.95*c),d=_,tempRect.setWH(.5*c-_/2,.485*u-d/2,_,d),t.SetTexture(s),t.Rect(tempRect)),n&&(_=1.5*C33.clamp(.22*u,105,.6*c),d=_/8,tempRect.setWH(.5*c-_/2,.868*u-d/2,_,d),t.SetTexture(n),t.Rect(tempRect))):(t.SetColorRgba(.302*h,.334*h,.365*h,h),_=c,d=Math.max(.005*u,2),tempRect.setWH(0,.85*u-d/2,_,d),t.Rect(tempRect),e?t.SetColorRgba(h,0,0,h):t.SetColorRgba(.161*h,.953*h,.816*h,h),_=c*this._loadingProgress,tempRect.setWH(.5*c-_/2,.85*u-d/2,_,d),t.Rect(tempRect),t.SetColorRgba(h,h,h,h),t.SetTextureFillMode(),s&&(_=.55*u,d=_,tempRect.setWH(.5*c-_/2,.45*u-d/2,_,d),t.SetTexture(s),t.Rect(tempRect))),this._splashFrameNumber++,"fade-in"===this._splashState&&r-this._loaderStartTime>=SPLASH_FADE_DURATION&&2<=this._splashFrameNumber&&(this._splashState="wait",this._splashFadeInFinishTime=r),"wait"===this._splashState&&r-this._splashFadeInFinishTime>=l&&1<=this._loadingProgress&&(this._splashState="fade-out",this._splashFadeOutStartTime=r),("fade-out"===this._splashState&&r-this._splashFadeOutStartTime>=SPLASH_FADE_DURATION+o||a&&1<=this._loadingProgress&&r-this._loaderStartTime<500)&&this._splashDoneResolve()}}}{let C33=self.C3,C3Debugger=self.C3Debugger,assert=self.assert,ISDKBehaviorInstanceBase=self.ISDKBehaviorInstanceBase,DEFAULT_RUNTIME_OPTS={messagePort:null,runtimeBaseUrl:"",headless:!1,hasDom:!0,isInWorker:!1,useAudio:!0,exportType:""},ife=!0;C33.Runtime=class extends C33.DefendedBase{constructor(e){e=Object.assign({},DEFAULT_RUNTIME_OPTS,e),super(),this._messagePort=e.messagePort,this._runtimeBaseUrl=e.runtimeBaseUrl,this._previewUrl=e.previewUrl,this._isHeadless=!!e.headless,this._hasDom=!!e.hasDom,this._isInWorker=!!e.isInWorker,ife=e.ife,this._useAudio=!!e.useAudio,this._exportType=e.exportType,this._isNWjs=e.isNWjs,this._isiOSCordova=!!e.isiOSCordova,this._isiOSWebView=!!e.isiOSWebView,this._isWindowsWebView2=!!e.isWindowsWebView2,this._isAnyWebView2Wrapper=!!e.isAnyWebView2Wrapper,this._isFBInstantAvailable=!!e.isFBInstantAvailable,this._isDebug=!("preview"!==this._exportType||!e.isDebug),this._breakpointsEnabled=this._isDebug,this._isDebugging=this._isDebug,this._debuggingDisabled=0,this._additionalLoadPromises=[],this._additionalCreatePromises=[],this._isUsingCreatePromises=!1,this._projectName="",this._projectVersion="",this._projectUniqueId="",this._appId="",this._exportTimestamp=0,this._originalViewportWidth=0,this._originalViewportHeight=0,this._devicePixelRatio=self.devicePixelRatio,this._parallaxXorigin=0,this._parallaxYorigin=0,this._viewportWidth=0,this._viewportHeight=0,this._loaderStyle=0,this._usesLoaderLayout=!1,this._isLoading=!0,this._usesAnyBackgroundBlending=!1,this._usesAnyCrossSampling=!1,this._usesAnyDepthSampling=!1,this._loadingLogoAsset=null,this._assetManager=C33.New(C33.AssetManager,this,e),this._layoutManager=C33.New(C33.LayoutManager,this),this._eventSheetManager=C33.New(C33.EventSheetManager,this),this._addonManager=C33.New(C33.AddonManager,this,e.wrapperComponentIds),this._collisionEngine=C33.New(C33.CollisionEngine,this),this._timelineManager=C33.New(C33.TimelineManager,this),this._transitionManager=C33.New(C33.TransitionManager,this),this._templateManager=C33.New(C33.TemplateManager,this),this._flowchartManager=C33.New(C33.FlowchartManager,this),this._textIconManager=C33.New(C33.TextIconManager,{getIconSetMeta:e=>this._GetTextIconSetMeta(e),getIconSetContent:e=>this._GetTextIconSetContent(e)}),this._iconChangeHandlers=new Map,this._allObjectClasses=[],this._objectClassesByName=new Map,this._objectClassesBySid=new Map,this._familyCount=0,this._allContainers=[],this._allEffectLists=new Set,this._currentLayoutStack=[],this._instancesPendingCreate=[],this._instancesPendingDestroy=new Map,this._hasPendingInstances=!1,this._isFlushingPendingInstances=!1,this._objectCount=0,this._nextUid=0,this._instancesByUid=new Map,this._instancesPendingRelease=new Set,this._instancesPendingReleaseAffectedObjectClasses=new Set,this._objectReferenceTable=[],this._jsPropNameTable=[],this._canvasManager=null,this._uses3dFeatures=!1,this._framerateMode="vsync",this._sampling="trilinear",this._isPixelRoundingEnabled=!1,this._needRender=!0,this._pauseOnBlur=!1,this._isPausedOnBlur=!1,this._exportToVideo=null,this._tickCallbacks={normal:e=>{this._rafId=-1,this._ruafId=-1,this.Tick(e)},tickOnly:e=>{this._ruafId=-1,this.Tick(e,!1,"skip-render")},renderOnly:()=>{this._rafId=-1,this.Render()}},this._rafId=-1,this._ruafId=-1,this._tickCount=0,this._tickCountNoSave=0,this._hasStarted=!1,this._isInTick=!1,this._hasStartedTicking=!1,this._isLayoutFirstTick=!0,this._isAutoSuspendEnabled=!0,this._isPageVisibilitySuspended=!1,this._suspendCount=0,this._scheduleTriggersThrottle=new C33.PromiseThrottle(1),this._randomNumberCallback=()=>Math.random(),this._startTime=0,this._lastTickTime=0,this._dtRaw=0,this._dt1=0,this._dt=0,this._timeScale=1,this._maxDt=1/30,this._minDt=0,this._gameTime=C33.New(C33.KahanSum),this._gameTimeRaw=C33.New(C33.KahanSum),this._wallTime=C33.New(C33.KahanSum),this._instanceTimes=new Map,this._fpsFrameCount=-1,this._fpsLastTime=0,this._fps=0,this._tpsTickCount=-1,this._tps=0,this._mainThreadTimeCounter=0,this._mainThreadTime=0,this._isLoadingState=!1,this._saveToSlotName="",this._saveToJsonString=!1,this._loadFromSlotName="",this._loadFromJson=null,this._lastSaveJson="",this._projectStorage=null,this._savegamesStorage=null,this._dispatcher=C33.New(C33.Event.Dispatcher),this._domEventHandlers=new Map,this._pendingResponsePromises=new Map,this._nextDomResponseId=0,this._didRequestDeviceOrientationEvent=!1,this._didRequestDeviceMotionEvent=!1,this._isReadyToHandleEvents=!1,this._waitingToHandleEvents=[],this._eventObjects={pretick:C33.New(C33.Event,"pretick",!1),tick:C33.New(C33.Event,"tick",!1),tick2:C33.New(C33.Event,"tick2",!1),instancecreate:C33.New(C33.Event,"instancecreate",!1),instancedestroy:C33.New(C33.Event,"instancedestroy",!1),beforelayoutchange:C33.New(C33.Event,"beforelayoutchange",!1),layoutchange:C33.New(C33.Event,"layoutchange",!1)},this._eventObjects.instancecreate.instance=null,this._eventObjects.instancedestroy.instance=null,this._userScriptDispatcher=C33.New(C33.Event.Dispatcher),this._userScriptEventObjects=null;const t=(e,t)=>C33.BehaviorInstance.SortByTickSequence(this,e,t);this._behInstsToTick=C33.New(C33.RedBlackSet,t),this._behInstsToPostTick=C33.New(C33.RedBlackSet,t),this._behInstsToTick2=C33.New(C33.RedBlackSet,t),this._jobScheduler=C33.New(C33.JobSchedulerRuntime,this,e.jobScheduler),e.canvas&&(this._canvasManager=C33.New(C33.CanvasManager,this)),this._messagePort.onmessage=e=>this._OnMessageFromDOM(e.data),this.AddDOMComponentMessageHandler("runtime","visibilitychange",e=>this._OnVisibilityChange(e)),this.AddDOMComponentMessageHandler("runtime","wrapper-extension-message",e=>this._OnWrapperExtensionMessage(e)),this.AddDOMComponentMessageHandler("runtime","get-remote-preview-status-info",()=>this._GetRemotePreviewStatusInfo()),this.AddDOMComponentMessageHandler("runtime","js-invoke-function",e=>this._InvokeFunctionFromJS(e)),this.AddDOMComponentMessageHandler("runtime","go-to-last-error-script",self.goToLastErrorScript),this.AddDOMComponentMessageHandler("runtime","offline-audio-render-completed",e=>this._OnOfflineAudioRenderCompleted(e)),this._dispatcher.addEventListener("window-blur",e=>this._OnWindowBlur(e)),this._dispatcher.addEventListener("window-focus",()=>this._OnWindowFocus()),this._timelineManager.AddRuntimeListeners(),this._templateManager.AddRuntimeListeners(),this._iRuntime=null,this._interfaceMap=new WeakMap,this._commonScriptInterfaces={keyboard:null,mouse:null,touch:null,timelineController:null},this._instancesNeedingAfterLoadMap=new WeakMap,this._instancesNeedingAfterLoadArray=[]}static Create(e){return C33.New(C33.Runtime,e)}Release(){C33.clearArray(this._allObjectClasses),this._objectClassesByName.clear(),this._objectClassesBySid.clear(),this._layoutManager.Release(),this._layoutManager=null,this._eventSheetManager.Release(),this._eventSheetManager=null,this._addonManager.Release(),this._addonManager=null,this._assetManager.Release(),this._assetManager=null,this._collisionEngine.Release(),this._collisionEngine=null,this._timelineManager.Release(),this._timelineManager=null,this._transitionManager.Release(),this._transitionManager=null,this._templateManager.Release(),this._templateManager=null,this._flowchartManager.Release(),this._flowchartManager=null,this._textIconManager.Release(),this._textIconManager=null,this._canvasManager&&(this._canvasManager.Release(),this._canvasManager=null),this._dispatcher.Release(),this._dispatcher=null,this._tickEvent=null}["_OnMessageFromDOM"](e){const t=e.type;if("event"===t)this._OnEventFromDOM(e);else{if("result"!==t)throw new Error(`unknown message '${t}'`);this._OnResultFromDOM(e)}}_OnEventFromDOM(e){if(this._isReadyToHandleEvents){const t=e.component,s=e.handler,i=e.data,n=e.dispatchOpts,r=!(!n||!n.dispatchRuntimeEvent),a=!(!n||!n.dispatchUserScriptEvent),o=e.responseId;if("runtime"===t){if(r){const h=new C33.Event(s);h.data=i,this._dispatcher.dispatchEventAndWaitAsyncSequential(h)}if(a){const c=new C33.Event(s,!0);for(const[u,_]of Object.entries(i))c[u]=_;this.DispatchUserScriptEvent(c)}}const l=this._domEventHandlers.get(t);if(l){const d=l.get(s);if(d){let e=null;try{e=d(i)}catch(e){return console.error(`Exception in '${t}' handler '${s}':`,e),void(null!==o&&this._PostResultToDOM(o,!1,""+e))}null!==o&&(e&&e.then?e.then(e=>this._PostResultToDOM(o,!0,e)).catch(e=>{console.error(`Rejection from '${t}' handler '${s}':`,e),this._PostResultToDOM(o,!1,""+e)}):this._PostResultToDOM(o,!0,e))}else r||a||console.warn(`[Runtime] No DOM handler '${s}' for component '${t}'`)}else r||a||console.warn(`[Runtime] No DOM event handlers for component '${t}'`)}else this._waitingToHandleEvents.push(e)}_PostResultToDOM(e,t,s){this._messagePort.postMessage({type:"result",responseId:e,isOk:t,result:s})}_OnResultFromDOM(e){const t=e.responseId,s=e.isOk,i=e.result,n=this._pendingResponsePromises.get(t);s?n.resolve(i):n.reject(i),this._pendingResponsePromises.delete(t)}AddDOMComponentMessageHandler(e,t,s){let i=this._domEventHandlers.get(e);if(i||(i=new Map,this._domEventHandlers.set(e,i)),i.has(t))throw new Error(`[Runtime] Component '${e}' already has handler '${t}'`);i.set(t,s)}PostComponentMessageToDOM(e,t,s,i){this._messagePort.postMessage({type:"event",component:e,handler:t,data:s,responseId:null},i)}PostComponentMessageToDOMAsync(e,t,s,i){const n=this._nextDomResponseId++,r=new Promise((e,t)=>{this._pendingResponsePromises.set(n,{resolve:e,reject:t})});return this._messagePort.postMessage({type:"event",component:e,handler:t,data:s,responseId:n},i),r}SendWrapperExtensionMessage(e,t,s,i=-1){this.PostComponentMessageToDOM("runtime","send-wrapper-extension-message",{componentId:e,messageId:t,params:s,asyncId:i})}SendWrapperExtensionMessageAsync(e,t,s){const i=this._nextDomResponseId++,n=new Promise((e,t)=>{this._pendingResponsePromises.set(i,{resolve:e,reject:t})});return this.SendWrapperExtensionMessage(e,t,s,i),n}_OnWrapperExtensionMessage(e){if(-1!==e.asyncId){const t=e.asyncId,s=this._pendingResponsePromises.get(t);s.resolve(e.params),this._pendingResponsePromises.delete(t)}else this._OnEventFromDOM({component:"wrapper-extension:"+e.componentId,handler:e.messageId,data:e.params,responseId:null})}AddWrapperExtensionMessageHandler(e,t,s){this.AddDOMComponentMessageHandler("wrapper-extension:"+e,t,s)}HasWrapperComponentId(e){return this._addonManager.HasWrapperComponentId(e)}PostToDebugger(e){if(!this.IsDebug())throw new Error("not in debug mode");this.PostComponentMessageToDOM("runtime","post-to-debugger",e)}async Init(e){C33.CommonACES_SetRuntime(this),this.IsDebug()?await C3Debugger.Init(this):self.C3Debugger&&self.C3Debugger.InitPreview(this);const t=await this._assetManager.FetchJson("data.json");if(await this._LoadDataJson(t),await this._InitialiseCanvas(e),this.IsPreview()||console.info("%cMade with Construct, the game and animation creation tool. Visit: https://www.construct.net","font-weight: bold"),this.GetWebGLRenderer()){const s=this.GetWebGLRenderer();console.info(`[C3 runtime] Hosted in ${this.IsInWorker()?"worker":"DOM"}, rendering with WebGL ${s.GetWebGLVersionNumber()} [${s.GetUnmaskedRenderer()}]`)}else this.GetWebGPURenderer()&&console.info(`[C3 runtime] Hosted in ${this.IsInWorker()?"worker":"DOM"}, rendering with WebGPU [${this.GetWebGPURenderer().GetAdapterInfoString()}]`);this.GetRenderer().HasMajorPerformanceCaveat()&&console.warn("[C3 runtime] The renderer indicates a major performance caveat. Software rendering may be in use. This can result in significantly degraded performance."),this._isReadyToHandleEvents=!0;for(const i of this._waitingToHandleEvents)this._OnEventFromDOM(i);C33.clearArray(this._waitingToHandleEvents),this._canvasManager&&this._canvasManager.StartLoadingScreen();for(const n of e.runOnStartupFunctions)this._additionalLoadPromises.push(this._RunOnStartupFunction(n));if(await Promise.all([this._assetManager.WaitForAllToLoad(),...this._additionalLoadPromises]),C33.clearArray(this._additionalLoadPromises),!this._assetManager.HasHadErrorLoading())return this._canvasManager&&await this._canvasManager.EndLoadingScreen(),await this._dispatcher.dispatchEventAndWaitAsync(new C33.Event("beforeruntimestart")),await this.Start(),this._messagePort.postMessage({type:"runtime-ready"}),this;this._canvasManager&&this._canvasManager.HideCordovaSplashScreen()}async _RunOnStartupFunction(e){try{await e(this._iRuntime)}catch(e){console.error("[C3 runtime] Error in runOnStartup function: ",e)}}async _LoadDataJson(e){const t=e.project,s=(this._projectName=t[0],this._projectVersion=t[16],this._projectUniqueId=t[31],this._appId=t[38],this._exportTimestamp=t[36],t[39]||"loading-logo.png"),i=(this._isPixelRoundingEnabled=!!t[9],this._originalViewportWidth=this._viewportWidth=t[10],this._originalViewportHeight=this._viewportHeight=t[11],this._collisionEngine._InitCollisionCellSize(this._originalViewportWidth,this._originalViewportHeight),this._parallaxXorigin=this._originalViewportWidth/2,this._parallaxYorigin=this._originalViewportHeight/2,this._framerateMode=t[37],this._uses3dFeatures=!!t[40],this._sampling=t[14],this._usesAnyBackgroundBlending=t[15],this._usesAnyCrossSampling=t[42],this._usesAnyDepthSampling=t[17],this._usesLoaderLayout=!!t[18],this._loaderStyle=t[19],this._nextUid=t[21],this._pauseOnBlur=t[22],this._assetManager);if(i._SetFileStructure(t[45]),i._SetAudioFiles(t[7],t[25]),i._SetMediaSubfolder(t[8]),i._SetFontsSubfolder(t[32]),i._SetIconsSubfolder(t[28]),i._SetWebFonts(t[29]),0===this._loaderStyle){let e;(e="flat"===i.GetFileStructure()?i.GetIconsSubfolder()+s:s)&&(this._loadingLogoAsset=i.LoadImage({url:e}))}this._canvasManager&&(this._canvasManager.SetFullscreenMode(C33.CanvasManager._FullscreenModeNumberToString(t[12])),this._canvasManager.SetFullscreenScalingQuality(t[23]?"high":"low"),this._canvasManager.SetMipmapsEnabled(0!==t[24]),this._canvasManager._SetGPUPowerPreference(t[34]),this._canvasManager._SetTextureAnisotropy(t[41]),this._canvasManager._SetWebGPUEnabled(t[13]),this._canvasManager._SetZAxisScale(t[30]),this._canvasManager._SetZDistances(t[46],t[47]),this._canvasManager._SetInitFieldOfView(t[26]),this._canvasManager._SetLimitedToWebGL1(t[48]),this._canvasManager._SetMultitexturingMode(t[50]));const n=t[43],r=(n&&await this._LoadExportToVideoData(n),this._InitScriptInterfaces(),this._addonManager.CreateSystemPlugin(),this._objectReferenceTable=self.C3_GetObjectRefTable(),t[2]);for(const h of r[1])this._addonManager.CreateBehavior(h);for(const c of r[0])this._addonManager.CreatePlugin(c);this._objectReferenceTable=self.C3_GetObjectRefTable(),this._LoadJsPropNameTable(),this._addonManager._InitAddonScriptInterfaces();for(const u of t[3]){const _=C33.ObjectClass.Create(this,this._allObjectClasses.length,u);this._allObjectClasses.push(_),this._objectClassesByName.set(_.GetName().toLowerCase(),_),this._objectClassesBySid.set(_.GetSID(),_)}for(const d of t[4]){const p=this._allObjectClasses[d[0]];p._LoadFamily(d)}for(const m of t[27]){const g=m.map(e=>this._allObjectClasses[e]);this._allContainers.push(C33.New(C33.Container,this,g))}this._InitObjectsScriptInterface();for(const f of this._allObjectClasses)f._OnAfterCreate();for(const S of t[5])this._layoutManager.Create(S);const a=t[1];if(a){const C=this._layoutManager.GetLayoutByName(a);C&&this._layoutManager.SetFirstLayout(C)}for(const y of t[35])this._transitionManager.Create(y);for(const G of t[33])this._timelineManager.Create(G);for(const I of t[44])this._templateManager.Create(I);this._templateManager.HasTemplates()||(this._templateManager.Release(),this._templateManager=null);for(const T of t[49])this._flowchartManager.Create(T);this._flowchartManager.HasFlowcharts()||(this._flowchartManager.Release(),this._flowchartManager=null);for(const b of t[6])this._eventSheetManager.Create(b);this._eventSheetManager._PostInit(),this._InitGlobalVariableScriptInterface(),C33.clearArray(this._objectReferenceTable),this.FlushPendingInstances();let o="any",l=t[20];1===l?o="portrait":2===l&&(o="landscape"),this.PostComponentMessageToDOM("runtime","set-target-orientation",{targetOrientation:o})}async _LoadExportToVideoData(e){const t=e.format;"image-sequence"===t?this._exportToVideo=new self.C3ExportToImageSequence(this,e):"image-sequence-gif"===t?this._exportToVideo=new self.C3ExportToGIF(this,e):"webm"===t?this._exportToVideo=new self.C3ExportToWebMVideo(this,e):"mp4"===t&&(this._exportToVideo=new self.C3ExportToMP4Video(this,e)),this._framerateMode="unlimited-frame",this._canvasManager.SetFullscreenMode("off"),this._devicePixelRatio=1,self.devicePixelRatio=1,await this.PostComponentMessageToDOMAsync("runtime","set-exporting-to-video",{message:this._exportToVideo.GetExportingMessageForPercent(0),duration:this._exportToVideo.GetDuration()})}GetLoaderStyle(){return this._loaderStyle}IsExportToVideo(){return null!==this._exportToVideo}GetExportVideoDuration(){return this._exportToVideo.GetDuration()}GetExportVideoFramerate(){return this._exportToVideo.GetFramerate()}_InitExportToVideo(){return this._exportToVideo.Init({width:this._canvasManager.GetDeviceWidth(),height:this._canvasManager.GetDeviceHeight()})}_ExportToVideoAddFrame(){const e=this._tickCount/this.GetExportVideoFramerate();return this._exportToVideo.AddFrame(this._canvasManager.GetMainCanvas(),e)}_ExportToVideoAddKeyframe(){this._exportToVideo&&this._exportToVideo.AddKeyframe()}_OnOfflineAudioRenderCompleted(e){this._exportToVideo.OnOfflineAudioRenderCompleted(e)}_ExportToVideoFinish(){return this._exportToVideo.Finish()}IsFBInstantAvailable(){return this._isFBInstantAvailable}IsLoading(){return this._isLoading}AddLoadPromise(e){this._additionalLoadPromises.push(e)}SetUsingCreatePromises(e){this._isUsingCreatePromises=!!e}AddCreatePromise(e){this._isUsingCreatePromises&&this._additionalCreatePromises.push(e)}GetCreatePromises(){return this._additionalCreatePromises}_GetNextFamilyIndex(){return this._familyCount++}GetFamilyCount(){return this._familyCount}_AddEffectList(e){this._allEffectLists.add(e)}_RemoveEffectList(e){this._allEffectLists.delete(e)}_GetAllEffectLists(){return this._allEffectLists}async _InitialiseCanvas(e){this._canvasManager&&(await this._canvasManager.CreateCanvas(e),this._canvasManager.InitLoadingScreen(this._loaderStyle))}async Start(){this._hasStarted=!0,this._startTime=Date.now();let t=null,e=new Promise(e=>t=e);if(this._usesLoaderLayout){for(const n of this._allObjectClasses)n.IsFamily()||n.IsOnLoaderLayout()||!n.IsWorldType()||n.OnCreate();(async()=>{await this._assetManager.WaitForAllToLoad(),await e,this._isLoading=!1,this._OnLoadFinished()})()}else this._isLoading=!1;this._assetManager.SetInitialLoadFinished(),this.IsDebug()&&C3Debugger.RuntimeInit(ife);for(const r of this._layoutManager.GetAllLayouts())r._CreateGlobalNonWorlds();this.IsExportToVideo()&&await this._InitExportToVideo();const s=this._layoutManager.GetFirstLayout(),i=(await s._Load(null,this.GetRenderer()),await s._StartRunning(!0),this._fpsLastTime=performance.now(),t(),this._usesLoaderLayout||this._OnLoadFinished(),await this.PostComponentMessageToDOMAsync("runtime","before-start-ticking"));i.isSuspended&&!this.IsExportToVideo()?(this._suspendCount++,this._isPageVisibilitySuspended=!0):this.Tick()}_OnLoadFinished(){this.Trigger(C33.Plugins.System.Cnds.OnLoadFinished,null,null),this.PostComponentMessageToDOM("runtime","register-sw")}GetObjectReference(e){e=Math.floor(e);const t=this._objectReferenceTable;if(e<0||e>=t.length)throw new Error("invalid object reference");return t[e]}_LoadJsPropNameTable(){for(const e of self.C3_JsPropNameTable){const t=C33.first(Object.keys(e));this._jsPropNameTable.push(t)}}GetJsPropName(e){e=Math.floor(e);const t=this._jsPropNameTable;if(e<0||e>=t.length)throw new Error("invalid prop reference");return t[e]}HasDOM(){return this._hasDom}IsHeadless(){return this._isHeadless}IsInWorker(){return this._isInWorker}GetRuntimeBaseURL(){return this._runtimeBaseUrl}GetPreviewURL(){return this._previewUrl}GetEventSheetManager(){return this._eventSheetManager}GetEventStack(){return this._eventSheetManager.GetEventStack()}GetCurrentEventStackFrame(){return this._eventSheetManager.GetCurrentEventStackFrame()}GetCurrentEvent(){return this._eventSheetManager.GetCurrentEvent()}GetCurrentCondition(){return this._eventSheetManager.GetCurrentCondition()}IsCurrentConditionFirst(){return 0===this.GetCurrentEventStackFrame().GetConditionIndex()}GetCurrentAction(){return this._eventSheetManager.GetCurrentAction()}GetAddonManager(){return this._addonManager}GetSystemPlugin(){return this._addonManager.GetSystemPlugin()}GetObjectClassByIndex(e){if((e=Math.floor(e))<0||e>=this._allObjectClasses.length)throw new RangeError("invalid index");return this._allObjectClasses[e]}GetObjectClassByName(e){return this._objectClassesByName.get(e.toLowerCase())||null}GetObjectClassBySID(e){return this._objectClassesBySid.get(e)||null}GetSingleGlobalObjectClassByCtor(e){const t=C33.AddonManager.GetPluginByConstructorFunction(e);return t?t.GetSingleGlobalObjectClass():null}GetAllObjectClasses(){return this._allObjectClasses}*allInstances(){for(const e of this._allObjectClasses)e.IsFamily()||(yield*e.instances())}Dispatcher(){return this._dispatcher}UserScriptDispatcher(){return this._userScriptDispatcher}DispatchUserScriptEvent(e){e.runtime=this.GetIRuntime();const t=this.IsDebug()&&!this._eventSheetManager.IsInEventEngine();t&&C3Debugger.StartMeasuringScriptTime(),this._userScriptDispatcher.dispatchEvent(e),t&&C3Debugger.AddScriptTime()}DispatchUserScriptEventAsyncWait(e){return e.runtime=this.GetIRuntime(),this._userScriptDispatcher.dispatchEventAndWaitAsync(e)}GetOriginalViewportWidth(){return this._originalViewportWidth}GetOriginalViewportHeight(){return this._originalViewportHeight}SetOriginalViewportSize(e,t){if(this._originalViewportWidth!==e||this._originalViewportHeight!==t){this._originalViewportWidth=e,this._originalViewportHeight=t;const s=this.GetLayoutManager();s.SetAllLayerProjectionChanged(),s.SetAllLayerMVChanged()}}GetViewportWidth(){return this._viewportWidth}GetViewportHeight(){return this._viewportHeight}SetViewportSize(e,t){if(this._viewportWidth!==e||this._viewportHeight!==t){this._viewportWidth=e,this._viewportHeight=t;const s=this.GetLayoutManager();s.SetAllLayerProjectionChanged(),s.SetAllLayerMVChanged()}}_SetDevicePixelRatio(e){this.IsExportToVideo()||(this._devicePixelRatio=e)}GetDevicePixelRatio(){return this._devicePixelRatio}GetParallaxXOrigin(){return this._parallaxXorigin}GetParallaxYOrigin(){return this._parallaxYorigin}GetCanvasManager(){return this._canvasManager}GetDrawWidth(){return this._canvasManager?this._canvasManager.GetDrawWidth():this._viewportWidth}GetDrawHeight(){return this._canvasManager?this._canvasManager.GetDrawHeight():this._viewportHeight}GetRenderScale(){return this._canvasManager?this._canvasManager.GetRenderScale():1}GetDisplayScale(){return this._canvasManager?this._canvasManager.GetDisplayScale():1}GetEffectLayerScaleParam(){return this._canvasManager?this._canvasManager.GetEffectLayerScaleParam():1}GetEffectDevicePixelRatioParam(){return this._canvasManager?this._canvasManager.GetEffectDevicePixelRatioParam():1}GetCanvasClientX(){return this._canvasManager?this._canvasManager.GetCanvasClientX():0}GetCanvasClientY(){return this._canvasManager?this._canvasManager.GetCanvasClientY():0}GetCanvasCssWidth(){return this._canvasManager?this._canvasManager.GetCssWidth():0}GetCanvasCssHeight(){return this._canvasManager?this._canvasManager.GetCssHeight():0}GetFullscreenMode(){return this._canvasManager?this._canvasManager.GetFullscreenMode():"off"}GetAdditionalRenderTarget(e){return this._canvasManager?this._canvasManager.GetAdditionalRenderTarget(e):null}ReleaseAdditionalRenderTarget(e){this._canvasManager&&this._canvasManager.ReleaseAdditionalRenderTarget(e)}UsesAnyBackgroundBlending(){return this._usesAnyBackgroundBlending}UsesAnyCrossSampling(){return this._usesAnyCrossSampling}UsesAnyDepthSampling(){return this._usesAnyDepthSampling}GetGPUUtilisation(){return this._canvasManager?this._canvasManager.GetGPUUtilisation():NaN}IsLinearSampling(){return"nearest"!==this.GetSampling()}GetFramerateMode(){return this._framerateMode}_SetFramerateMode(e){this._framerateMode!==e&&(this._framerateMode=e,-1!==this._rafId||-1!==this._ruafId)&&(this._CancelAnimationFrame(),this._RequestAnimationFrame())}GetSampling(){return this._sampling}UsesLoaderLayout(){return this._usesLoaderLayout}GetLoadingLogoAsset(){return this._loadingLogoAsset}ReleaseLoadingLogoAsset(){this._loadingLogoAsset&&(this._loadingLogoAsset.ReleaseTexture(),this._loadingLogoAsset.Release(),this._loadingLogoAsset=null)}GetLayoutManager(){return this._layoutManager}GetMainRunningLayout(){return this._layoutManager.GetMainRunningLayout()}GetTimelineManager(){return this._timelineManager}GetTransitionManager(){return this._transitionManager}GetTemplateManager(){return this._templateManager}GetFlowchartManager(){return this._flowchartManager}GetAssetManager(){return this._assetManager}LoadImage(e){return this._assetManager.LoadImage(e)}CreateInstance(e,t,s,i,n,r){if(r&&this._templateManager){if(e instanceof C33.ObjectClass&&e.IsFamily()){const o=e.GetFamilyMembers(),l=Math.floor(this.Random()*o.length);return this.CreateInstance(o[l],t,s,i,n,r)}const a=this._templateManager.GetTemplateData(e,r);if(a){const h=this.CreateInstanceFromData(a,t,!1,s,i,!1,n,void 0,n);return this._templateManager.MapInstanceToTemplateName(h,r),h}}return this.CreateInstanceFromData(e,t,!1,s,i,!1,n,void 0,n)}CreateInstanceFromData(e,t,s,i,n,r,a,o,l){let h=null,c=null;if(e instanceof C33.ObjectClass){if((c=e).IsFamily()){const y=c.GetFamilyMembers(),G=Math.floor(this.Random()*y.length);c=y[G]}h=c.GetDefaultInstanceData()}else h=e,c=this.GetObjectClassByIndex(h[1]);const u=c.GetPlugin().IsWorldType();if(this._isLoading&&u&&!c.IsOnLoaderLayout())return null;const _=t;u||(t=null);let d;d=s&&!r&&h&&!this._instancesByUid.has(h[2])?h[2]:this._nextUid++;const p=h?h[0]:null,m=C33.New(C33.Instance,{runtime:this,objectType:c,layer:t,worldData:p,instVarData:h?h[3]:null,uid:d,tags:h?h[6]:null});this._instancesByUid.set(d,m);let g=null,f=(u&&(g=m.GetWorldInfo(),void 0!==i&&void 0!==n&&(g.SetX(i),g.SetY(n)),c._SetAnyCollisionCellChanged(!0)),t&&(l||t._AddInstance(m,!0),t.GetLayout().MaybeLoadTexturesFor(c)),this._objectCount++,!0);if(o){const I=o.GetObjectClass();if(I.IsInContainer()&&c.IsInContainer()){const T=c.GetContainer(),b=I.GetContainer();T===b&&(f=!1)}}if(c.IsInContainer()&&!s&&!r&&f){const P=new Set;for(const A of c.GetContainer().objectTypes())if(A!==c){const R=this._MaybeGetChildInstanceForObjectTypeData(A,g,P);if(R){const E=this.CreateInstanceFromData(R,_,!1,g?g.GetX():i,g?g.GetY():n,!0,!1,void 0,l);m._AddSibling(E)}else{const k=this.CreateInstanceFromData(A,_,!1,g?g.GetX():i,g?g.GetY():n,!0,!1,void 0,l);m._AddSibling(k)}}for(const v of m.siblings()){v._AddSibling(m);for(const x of m.siblings())v!==x&&v._AddSibling(x)}}if(u&&!s&&a&&this._CreateChildInstancesFromData(m,p,g,t,i,n,l),c.IsInContainer()&&!s&&!r&&a)for(const w of m.siblings()){const M=w.GetWorldInfo();if(M){const N=w.GetPlugin(),D=w.GetObjectClass().GetDefaultInstanceData()[0];N.IsWorldType()?this._CreateChildInstancesFromData(w,D,M,t,M.GetX(),M.GetY(),l):this._CreateChildInstancesFromData(w,D,M,t,void 0,void 0,l)}}if(!r&&a){void 0===i&&(i=p[0]),void 0===n&&(n=p[1]);const O=g.GetTopParent(),W=i-g.GetX()+O.GetX(),U=n-g.GetY()+O.GetY();O.SetXY(W,U)}c._SetIIDsStale();const F=h?C33.cloneArray(h[5]):null,B=h?h[4].map(e=>C33.cloneArray(e)):null,S=u&&p&&p[13];if(S&&m._SetHasTilemap(),m._CreateSdkInstance(F,B),S){const L=p[13];m.GetSdkInstance().LoadTilemapData(L[2],L[0],L[1])}this._instancesPendingCreate.push(m),this._hasPendingInstances=!0,this.IsDebug()&&C3Debugger.InstanceCreated(m);const C=this._eventObjects.instancecreate;return C.instance=m,this._dispatcher.dispatchEvent(C),m}_GetInstanceData(e){const t=e[0],s=e[1],i=e[2],n=e[6];if(n)return n;const r=this._layoutManager.GetLayoutBySID(t),a=r.GetLayer(s);return a.GetInitialInstanceData(i)}_MaybeGetChildInstanceForObjectTypeData(e,t,s){const i=t?.GetSceneGraphChildrenExportData()??[];for(const n of i){const r=this._GetInstanceData(n),a=!!n[4],o=this.GetObjectClassByIndex(r[1]);if(!s.has(r)&&e===o&&a)return s.add(r),r}}_CreateChildInstancesFromData(l,e,t,h,c,u,_){const s=t.GetSceneGraphZIndexExportData(),i=t.GetSceneGraphChildrenExportData();if(l.GetWorldInfo().SetSceneGraphZIndex(s),i){void 0===c&&(c=e[0]),void 0===u&&(u=e[1]);const d=new Set,p=e[0],m=e[1];for(const g of i){let e=g[0],t=g[1],s=g[2],i=g[3],n=!!g[4],r=g[5],a=g[6],o;if(a)o=a;else{const y=this._layoutManager.GetLayoutBySID(e),G=y.GetLayer(t);o=G.GetInitialInstanceData(s)}const f=this.GetObjectClassByIndex(o[1]),S=l.HasSibling(f),C=d.has(f);if(S&&!C&&n){const I=l.GetSibling(f),T=(I.GetWorldInfo().Init(o[0]),c+o[0][0]-p),b=u+o[0][1]-m;I.GetWorldInfo().SetXY(T,b),I.GetWorldInfo().SetSceneGraphZIndex(r),l.AddChild(I,{transformX:!!(i>>0&1),transformY:!!(i>>1&1),transformWidth:!!(i>>2&1),transformHeight:!!(i>>3&1),transformAngle:!!(i>>4&1),destroyWithParent:!!(i>>5&1),transformZElevation:!!(i>>6&1),transformOpacity:!!(i>>7&1),transformVisibility:!!(i>>8&1)}),d.add(f)}else{const P=c+o[0][0]-p,A=u+o[0][1]-m,R=this.CreateInstanceFromData(o,h,!1,P,A,!1,!0,l,_);R.GetWorldInfo().SetSceneGraphZIndex(r),l.AddChild(R,{transformX:!!(i>>0&1),transformY:!!(i>>1&1),transformWidth:!!(i>>2&1),transformHeight:!!(i>>3&1),transformAngle:!!(i>>4&1),destroyWithParent:!!(i>>5&1),transformZElevation:!!(i>>6&1),transformOpacity:!!(i>>7&1),transformVisibility:!!(i>>8&1)})}}}}DestroyInstance(s){if(!this._instancesPendingRelease.has(s)){let e=s.GetObjectClass(),t=this._instancesPendingDestroy.get(e);if(t){if(t.has(s))return;t.add(s)}else(t=new Set).add(s),this._instancesPendingDestroy.set(e,t);if(this.IsDebug()&&C3Debugger.InstanceDestroyed(s),s._MarkDestroyed(),this._hasPendingInstances=!0,s.IsInContainer())for(const i of s.siblings())this.DestroyInstance(i);for(const n of s.children())n.GetDestroyWithParent()&&this.DestroyInstance(n);if(!this._layoutManager.IsEndingLayout()&&!this._isLoadingState){const r=this.GetEventSheetManager();r.BlockFlushingInstances(!0),s._TriggerOnDestroyed(),r.BlockFlushingInstances(!1)}s._FireDestroyedScriptEvents(this._layoutManager.IsEndingLayout())}}FlushPendingInstances(){this._hasPendingInstances&&(this._isFlushingPendingInstances=!0,this._FlushInstancesPendingCreate(),this._FlushInstancesPendingDestroy(),this._isFlushingPendingInstances=!1,this._hasPendingInstances=!1,this.UpdateRender())}_FlushInstancesPendingCreate(){for(const e of this._instancesPendingCreate){const t=e.GetObjectClass();t._AddInstance(e);for(const s of t.GetFamilies())s._AddInstance(e),s._SetIIDsStale()}C33.clearArray(this._instancesPendingCreate)}_FlushInstancesPendingDestroy(){this._dispatcher.SetDelayRemoveEventsEnabled(!0);for(const[e,t]of this._instancesPendingDestroy.entries())this._FlushInstancesPendingDestroyForObjectClass(e,t),t.clear();this._instancesPendingDestroy.clear(),this._dispatcher.SetDelayRemoveEventsEnabled(!1)}_FlushInstancesPendingDestroyForObjectClass(e,t){for(const s of t){const i=this._eventObjects.instancedestroy,n=(i.instance=s,this._dispatcher.dispatchEvent(i),this._instancesByUid.delete(s.GetUID()),this._instanceTimes.delete(s),s.GetWorldInfo());n&&(n._RemoveFromCollisionCells(),n._RemoveFromRenderCells(),n._MarkDestroyed()),this._instancesPendingRelease.add(s),this._objectCount--}C33.arrayRemoveAllInSet(e.GetInstances(),t),e._SetIIDsStale(),this._instancesPendingReleaseAffectedObjectClasses.add(e);for(const r of e.GetFamilies())C33.arrayRemoveAllInSet(r.GetInstances(),t),r._SetIIDsStale(),this._instancesPendingReleaseAffectedObjectClasses.add(r);if(e.GetPlugin().IsWorldType()){const a=new Set([...t].map(e=>e.GetWorldInfo().GetLayer()));for(const o of a)o._RemoveAllInstancesInSet(t)}}_GetInstancesPendingCreate(){return this._instancesPendingCreate}*instancesPendingCreateForObjectClass(e){for(const t of this._GetInstancesPendingCreate())e.IsFamily()?t.GetObjectClass().BelongsToFamily(e)&&(yield t):t.GetObjectClass()===e&&(yield t)}_GetNewUID(){return this._nextUid++}_MapInstanceByUID(e,t){this._instancesByUid.set(e,t)}_SetAutoSuspendEnabled(e){this._isAutoSuspendEnabled!==(e=!!e)&&(this._isAutoSuspendEnabled=!!e,this._isAutoSuspendEnabled)&&this._isPageVisibilitySuspended&&(this.SetSuspended(!1),this._isPageVisibilitySuspended=!1)}_IsAutoSuspendEnabled(){return this._isAutoSuspendEnabled}_OnRendererContextLost(){this._dispatcher.dispatchEvent(C33.New(C33.Event,"renderercontextlost")),this.SetSuspended(!0);for(const t of this._allObjectClasses)!t.IsFamily()&&t.HasLoadedTextures()&&t.ReleaseTextures();const e=this.GetMainRunningLayout();e&&e._OnRendererContextLost(),C33.ImageInfo.OnRendererContextLost(),C33.ImageAsset.OnRendererContextLost()}async _OnRendererContextRestored(){await this.GetMainRunningLayout()._Load(null,this.GetRenderer()),this._dispatcher.dispatchEvent(C33.New(C33.Event,"renderercontextrestored")),this.SetSuspended(!1),this.UpdateRender()}_OnVisibilityChange(e){if(this._isAutoSuspendEnabled){const t=e.hidden;this.SetSuspended(t),(this._isPageVisibilitySuspended=t)||this.UpdateRender()}}_OnWindowBlur(e){this.IsPreview()&&this._pauseOnBlur&&!C33.Platform.IsMobile&&!e.data.parentHasFocus&&(this.SetSuspended(!0),this._isPausedOnBlur=!0)}_OnWindowFocus(){this._isPausedOnBlur&&(this.SetSuspended(!1),this._isPausedOnBlur=!1)}_RequestAnimationFrame(){const e=this._tickCallbacks;"vsync"===this._framerateMode?-1===this._rafId&&(this._rafId=self.requestAnimationFrame(e.normal)):"unlimited-tick"===this._framerateMode?(-1===this._ruafId&&(this._ruafId=C33.RequestUnlimitedAnimationFrame(e.tickOnly)),-1===this._rafId&&(this._rafId=self.requestAnimationFrame(e.renderOnly))):-1===this._ruafId&&(this._ruafId=C33.RequestUnlimitedAnimationFrame(e.normal))}_CancelAnimationFrame(){-1!==this._rafId&&(self.cancelAnimationFrame(this._rafId),this._rafId=-1),-1!==this._ruafId&&(C33.CancelUnlimitedAnimationFrame(this._ruafId),this._ruafId=-1)}IsSuspended(){return 0<this._suspendCount}SetSuspended(e){if(!this.IsExportToVideo()){const t=this.IsSuspended(),s=(this._suspendCount+=e?1:-1,this._suspendCount<0&&(this._suspendCount=0),this.IsSuspended());if(!t&&s)console.log("[Construct] Suspending"),this._CancelAnimationFrame(),this._dispatcher.dispatchEvent(C33.New(C33.Event,"suspend")),this.Trigger(C33.Plugins.System.Cnds.OnSuspend,null,null);else if(t&&!s){console.log("[Construct] Resuming");const i=performance.now();this._lastTickTime=i,this._fpsLastTime=i,this._fpsFrameCount=0,this._fps=0,this._tpsTickCount=0,this._tps=0,this._mainThreadTime=0,this._mainThreadTimeCounter=0,this._dispatcher.dispatchEvent(C33.New(C33.Event,"resume")),this.Trigger(C33.Plugins.System.Cnds.OnResume,null,null),this.HitBreakpoint()||this.Tick(i)}}}_AddBehInstToTick(e){this._behInstsToTick.Add(e)}_AddBehInstToPostTick(e){this._behInstsToPostTick.Add(e)}_AddBehInstToTick2(e){this._behInstsToTick2.Add(e)}_RemoveBehInstToTick(e){this._behInstsToTick.Remove(e)}_RemoveBehInstToPostTick(e){this._behInstsToPostTick.Remove(e)}_RemoveBehInstToTick2(e){this._behInstsToTick2.Remove(e)}_CallBehaviorTickMethod(e,t){let s=t?performance.now():0,i;return e instanceof ISDKBehaviorInstanceBase?(i=e._tick(),t&&C3Debugger.AddIndividualBehaviorTickTime(e.behavior,performance.now()-s)):(i=e.Tick(),t&&C3Debugger.AddIndividualBehaviorTickTime(e.GetBehavior(),performance.now()-s)),i}_BehaviorTick(){const e=this.IsDebug();this._behInstsToTick.SetQueueingEnabled(!0);for(const t of this._behInstsToTick)this._CallBehaviorTickMethod(t,e);this._behInstsToTick.SetQueueingEnabled(!1)}_CallBehaviorPostTickMethod(e,t){let s=t?performance.now():0,i;return e instanceof ISDKBehaviorInstanceBase?(i=e._postTick(),t&&C3Debugger.AddIndividualBehaviorTickTime(e.behavior,performance.now()-s)):(i=e.PostTick(),t&&C3Debugger.AddIndividualBehaviorTickTime(e.GetBehavior(),performance.now()-s)),i}_BehaviorPostTick(){const e=this.IsDebug();this._behInstsToPostTick.SetQueueingEnabled(!0);for(const t of this._behInstsToPostTick)this._CallBehaviorPostTickMethod(t,e);this._behInstsToPostTick.SetQueueingEnabled(!1)}_CallBehaviorTick2Method(e,t){let s=t?performance.now():0,i;return e instanceof ISDKBehaviorInstanceBase?(i=e._tick2(),t&&C3Debugger.AddIndividualBehaviorTickTime(e.behavior,performance.now()-s)):(i=e.Tick2(),t&&C3Debugger.AddIndividualBehaviorTickTime(e.GetBehavior(),performance.now()-s)),i}_BehaviorTick2(){const e=this.IsDebug();this._behInstsToTick2.SetQueueingEnabled(!0);for(const t of this._behInstsToTick2)this._CallBehaviorTick2Method(t,e);this._behInstsToTick2.SetQueueingEnabled(!1)}*_DebugBehaviorTick(){const e=this.IsDebug();this._behInstsToTick.SetQueueingEnabled(!0);for(const t of this._behInstsToTick){const s=this._CallBehaviorTickMethod(t,e);C33.IsIterator(s)&&(yield*s)}this._behInstsToTick.SetQueueingEnabled(!1)}*_DebugBehaviorPostTick(){const e=this.IsDebug();this._behInstsToPostTick.SetQueueingEnabled(!0);for(const t of this._behInstsToPostTick){const s=this._CallBehaviorPostTickMethod(t,e);C33.IsIterator(s)&&(yield*s)}this._behInstsToPostTick.SetQueueingEnabled(!1)}*_DebugBehaviorTick2(){const e=this.IsDebug();this._behInstsToTick2.SetQueueingEnabled(!0);for(const t of this._behInstsToTick2){const s=this._CallBehaviorTick2Method(t,e);C33.IsIterator(s)&&(yield*s)}this._behInstsToTick2.SetQueueingEnabled(!1)}async Tick(l,e,t){this._hasStartedTicking=!0;const h="background-wake"===t,c="background-wake"!==t&&"skip-render"!==t,u=this.GetLayoutManager(),_=this.GetCanvasManager();if(this._hasStarted&&(!this.IsSuspended()||e||h)){let e=performance.now(),t=(this._isInTick=!0,this._MeasureDt(l||0),this._tpsTickCount++,this._ReleasePendingInstances(),this.Step_BeforePreTick()),s=(this.IsDebugging()&&await t,this._dispatcher.dispatchEventAndWait_AsyncOptional(this._eventObjects.pretick)),i=(s instanceof Promise&&await s,this.DispatchUserScriptEvent(this._userScriptEventObjects.pretick),this.Step_AfterPreTick()),n=(this.IsDebugging()&&await i,this._NeedsHandleSaveOrLoad()&&await this._HandleSaveOrLoad(),u.IsPendingChangeMainLayout()&&await this._MaybeChangeLayout(),this.Step_RunEventsEtc()),r=(this.IsDebugging()&&await n,u.GetMainRunningLayout()),a=r._GetPendingSetHTMLLayerCount(),o=!1;if(-1!==a&&(r._ResetPendingHTMLLayerCount(),_.GetHTMLLayerCount()!==a)){const d=this.GetCanvasManager().SetHTMLLayerCount(a);this.IsInWorker()&&(o=!0,await d)}this.PostComponentMessageToDOM("canvas","update-html-layer-dom-state",{layersDomState:r._GetRootLayers().filter(e=>e.IsHTMLElementsLayer()).map(e=>e._GetHTMLLayerDOMState())}),c&&this.Render(),o&&this.PostComponentMessageToDOM("canvas","cleanup-html-layers"),this.IsExportToVideo()&&(await this._ExportToVideoAddFrame(),this.GetGameTime()>=this.GetExportVideoDuration())?this._ExportToVideoFinish():(this.IsSuspended()||h||this._RequestAnimationFrame(),this._tickCount++,this._tickCountNoSave++,this._isInTick=!1,this._mainThreadTimeCounter+=performance.now()-e)}}async Step_BeforePreTick(){const e=this._eventSheetManager,t=this.IsDebug();this.FlushPendingInstances(),e.BlockFlushingInstances(!0),this.PushCurrentLayout(this.GetMainRunningLayout()),t&&C3Debugger.StartMeasuringTime(),this.IsDebugging()?await e.DebugRunScheduledWaits():e.RunScheduledWaits(),t&&C3Debugger.AddEventsTime(),this.PopCurrentLayout(),e.BlockFlushingInstances(!1),this.FlushPendingInstances(),e.BlockFlushingInstances(!0)}async Step_AfterPreTick(){const e=this._eventSheetManager,t=this.IsDebug(),s=this.IsDebugging(),i=this._dispatcher,n=this._eventObjects,r=this._userScriptEventObjects;t&&C3Debugger.StartMeasuringTime(),s?await this.DebugIterateAndBreak(this._DebugBehaviorTick()):this._BehaviorTick(),s?await this.DebugIterateAndBreak(this._DebugBehaviorPostTick()):this._BehaviorPostTick(),t&&C3Debugger.AddBehaviorTotalTickTime(),t&&C3Debugger.StartMeasuringTime(),s?await this.DebugFireGeneratorEventAndBreak(n.tick):i.dispatchEvent(n.tick),t&&C3Debugger.AddPluginTotalTickTime(),e.BlockFlushingInstances(!1),this.DispatchUserScriptEvent(r.tick)}async Step_RunEventsEtc(){const e=this._eventSheetManager,t=this._dispatcher,s=this._eventObjects,i=this._userScriptEventObjects,n=this.IsDebug(),r=this.IsDebugging();n&&C3Debugger.StartMeasuringTime(),r?await e.DebugRunEvents(this._layoutManager):e.RunEvents(this._layoutManager),n&&C3Debugger.AddEventsTime(),this._collisionEngine.ClearRegisteredCollisions(),this._ReleasePendingInstances(),this._isLayoutFirstTick=!1,e.BlockFlushingInstances(!0),n&&C3Debugger.StartMeasuringTime(),r?await this.DebugIterateAndBreak(this._DebugBehaviorTick2()):this._BehaviorTick2(),n&&C3Debugger.AddBehaviorTotalTickTime(),n&&C3Debugger.StartMeasuringTime(),r?await this.DebugFireGeneratorEventAndBreak(s.tick2):t.dispatchEvent(s.tick2),n&&C3Debugger.AddPluginTotalTickTime(),e.BlockFlushingInstances(!1),this.DispatchUserScriptEvent(i.tick2),r&&await e.RunQueuedDebugTriggersAsync()}_ReleasePendingInstances(){if(0!==this._instancesPendingRelease.size){const e=this._dispatcher;e.SetDelayRemoveEventsEnabled(!0);for(const t of this._instancesPendingReleaseAffectedObjectClasses)t.GetSolStack().RemoveInstances(this._instancesPendingRelease);this._instancesPendingReleaseAffectedObjectClasses.clear(),this._eventSheetManager._OnInstancesReleased(this._instancesPendingRelease);for(const s of this._instancesPendingRelease)s.Release();this._instancesPendingRelease.clear(),e.SetDelayRemoveEventsEnabled(!1)}}async _MaybeChangeLayout(){let e=this.GetLayoutManager(),t=0;for(;e.IsPendingChangeMainLayout()&&t++<10;)await this._DoChangeLayout(e.GetPendingChangeMainLayout())}_MeasureDt(e){let t=0;if(this.IsExportToVideo())t=1/this.GetExportVideoFramerate(),this._dtRaw=t,this._dt1=t;else if(0!==this._lastTickTime){const s=Math.max(e-this._lastTickTime,0);.5<(t=s/1e3)&&(t=0),this._dtRaw=t,this._dt1=C33.clamp(t,this._minDt,this._maxDt)}this._lastTickTime=e,this._dt=this._dt1*this._timeScale,this._gameTime.Add(this._dt),this._gameTimeRaw.Add(t*this._timeScale),this._wallTime.Add(this._dt1);for(const[i,n]of this._instanceTimes)n.Add(this._dt1*i.GetTimeScale());this._canvasManager&&this._canvasManager._UpdateTick(),1e3<=e-this._fpsLastTime&&(this._fpsLastTime+=1e3,1e3<=e-this._fpsLastTime&&(this._fpsLastTime=e),this._fps=this._fpsFrameCount,this._fpsFrameCount=0,this._tps=this._tpsTickCount,this._tpsTickCount=0,this._mainThreadTime=Math.min(this._mainThreadTimeCounter/1e3,1),this._mainThreadTimeCounter=0,this._canvasManager&&this._canvasManager._Update1sFrameRange(),this._collisionEngine._Update1sStats(),this.IsDebug())&&C3Debugger.Update1sPerfStats()}_SetTrackingInstanceTime(e,t){if(t){if(!this._instanceTimes.has(e)){const s=C33.New(C33.KahanSum);s.Copy(this._gameTime),this._instanceTimes.set(e,s)}}else this._instanceTimes.delete(e)}_GetInstanceGameTime(e){const t=this._instanceTimes.get(e);return t?t.Get():this.GetGameTime()}async _DoChangeLayout(e){const t=this._dispatcher,s=this.GetLayoutManager(),i=s.GetMainRunningLayout();await i._StopRunning(),i._Unload(e,this.GetRenderer()),i===e&&this._eventSheetManager.ClearAllScheduledWaits(),this._collisionEngine.ClearRegisteredCollisions(),this._ReleasePendingInstances(),t.dispatchEvent(this._eventObjects.beforelayoutchange),C33.Asyncify.SetHighThroughputMode(!0),await e._Load(i,this.GetRenderer()),C33.Asyncify.SetHighThroughputMode(!1),await e._StartRunning(!1),t.dispatchEvent(this._eventObjects.layoutchange),this.UpdateRender(),this._isLayoutFirstTick=!0,this.FlushPendingInstances(),this._ExportToVideoAddKeyframe()}UpdateRender(){this._needRender=!0}GetWebGLRenderer(){return this._canvasManager?this._canvasManager.GetWebGLRenderer():null}GetWebGPURenderer(){return this._canvasManager?this._canvasManager.GetWebGPURenderer():null}GetRenderer(){return this._canvasManager?this._canvasManager.GetRenderer():null}Render(){const s=this._canvasManager;if(s&&!s.IsRendererContextLost()){const i=this.GetRenderer(),e=i.SupportsGPUProfiling(),n=e&&i.IsWebGL(),r=e&&i.IsWebGPU();if(n&&i.CheckForQueryResults(),this._needRender||this.IsExportToVideo()){const a=this._layoutManager.GetMainRunningLayout(),o=(this._fpsFrameCount++,i.Start(),this.IsDebug());o&&C3Debugger.StartMeasuringTime(),this._needRender=!1;let e=null,t=(n&&(e=s.GetGPUFrameTimingsBuffer().AddTimeElapsedQuery(),i.StartQuery(e)),null);r&&(t=i.StartFrameTiming(2*(1+a.GetLayerCount())),i.StartMeasuringRenderPassTime(0,1)),this.Uses3DFeatures()&&"low"===s.GetCurrentFullscreenScalingQuality()?i.SetFixedSizeDepthBuffer(s.GetDrawWidth(),s.GetDrawHeight()):i.SetAutoSizeDepthBuffer(),this._Render(this.GetRenderer(),a),e&&i.EndQuery(e),r&&(i.StopMeasuringRenderPassTime(),this._canvasManager._AddWebGPUFrameTiming(t)),i.Finish(),o&&(C3Debugger.AddDrawCallsTime(),C3Debugger.UpdateInspectHighlight()),s&&s._MaybeTakeSnapshot()}else i.IncrementFrameNumber()}}_NeedsHTMLLayerCompositing(e){return"low"===this.GetCanvasManager().GetCurrentFullscreenScalingQuality()||e.IsWebGL()&&(this.UsesAnyBackgroundBlending()||this.Uses3DFeatures())}_Render(t,s){t.SetTextureFillMode(),t.SetAlphaBlend(),t.SetColorRgba(1,1,1,1),t.SetRenderTarget(null),t.SetTexture(null),t.SetDepthEnabled(this.Uses3DFeatures()),this._NeedsHTMLLayerCompositing(t)&&s._MaybeStartDrawToOwnTexture(t);const i=s.GetHTMLLayerCount();for(let e=1;e<i;++e)s.DrawForHTMLLayerIndex(t,e),t.IsWebGPU()&&t.Restart();this._NeedsHTMLLayerCompositing(t)||s._MaybeStartDrawToOwnTexture(t),s.DrawMain(t)}Trigger(e,t,s){if(!this._hasStarted)return!1;let i=!this._isInTick&&!this._eventSheetManager.IsInTrigger(),n=0;i&&(n=performance.now());const r=this.IsDebug(),a=(r&&this.SetDebuggingEnabled(!1),this._eventSheetManager._Trigger(this._layoutManager,e,t,s));if(i){const o=performance.now()-n;this._mainThreadTimeCounter+=o,r&&C3Debugger.AddTriggersTime(o)}return r&&this.SetDebuggingEnabled(!0),a}DebugTrigger(e,t,s){if(!this.IsDebugging())return this.Trigger(e,t,s);if(this.HitBreakpoint())throw new Error("called DebugTrigger() while stopped on breakpoint");if(this._isInTick||this._eventSheetManager.IsInTrigger())return this._eventSheetManager._DebugTrigger(this._layoutManager,e,t,s);throw new Error("called DebugTrigger() outside of event code - use TriggerAsync() instead")}async TriggerAsync(e,t,s){if(!this.IsDebugging())return this.Trigger(e,t,s);if(!this._hasStarted)return!1;if(this.HitBreakpoint())return this._eventSheetManager.QueueDebugTrigger(e,t,s);if(!this.GetMainRunningLayout())return this._eventSheetManager.QueueTrigger(e,t,s);let i=performance.now(),n=this._eventSheetManager._DebugTrigger(this._layoutManager,e,t,s),r=n.next();for(;!r.done;)await this.DebugBreak(r.value),r=n.next();return this.IsSuspended()||this._eventSheetManager.IsInTrigger()||(await this._eventSheetManager.RunQueuedDebugTriggersAsync(),this._hasStartedTicking&&!this._isInTick&&this._RequestAnimationFrame()),this._mainThreadTimeCounter+=performance.now()-i,r.value}FastTrigger(e,t,s){const i=this.IsDebug(),n=(i&&this.SetDebuggingEnabled(!1),this._eventSheetManager._FastTrigger(this._layoutManager,e,t,s));return i&&this.SetDebuggingEnabled(!0),n}DebugFastTrigger(e,t,s){return this._eventSheetManager._DebugFastTrigger(this._layoutManager,e,t,s)}ScheduleTriggers(e){return this._scheduleTriggersThrottle.Add(e)}PushCurrentLayout(e){this._currentLayoutStack.push(e)}PopCurrentLayout(){if(!this._currentLayoutStack.length)throw new Error("layout stack empty");this._currentLayoutStack.pop()}GetCurrentLayout(){return this._currentLayoutStack.length?this._currentLayoutStack.at(-1):this.GetMainRunningLayout()}GetDt(e){return e&&-1!==e.GetTimeScale()?this._dt1*e.GetTimeScale():this._dt}_GetDtFast(){return this._dt}GetDt1(){return this._dt1}GetDtRaw(){return this._dtRaw}GetTimeScale(){return this._timeScale}SetTimeScale(e){(isNaN(e)||e<0)&&(e=0),this._timeScale=e}SetMinDt(e){this._minDt=Math.max(e,0)}GetMinDt(){return this._minDt}SetMaxDt(e){this._maxDt=Math.max(e,0)}GetMaxDt(){return this._maxDt}GetFramesPerSecond(){return this._fps}GetTicksPerSecond(){return this._tps}GetMainThreadTime(){return this._mainThreadTime}GetStartTime(){return this._startTime}GetGameTime(){return this._gameTime.Get()}GetGameTimeRaw(){return this._gameTimeRaw.Get()}GetWallTime(){return this._wallTime.Get()}GetTickCount(){return this._tickCount}GetTickCountNoSave(){return this._tickCountNoSave}GetObjectCount(){return this._objectCount}GetProjectName(){return this._projectName}GetProjectVersion(){return this._projectVersion}GetProjectUniqueId(){return this._projectUniqueId}GetAppId(){return this._appId}GetExportTimestamp(){return this._exportTimestamp}GetInstanceByUID(e){if(this._isLoadingState)throw new Error("cannot call while loading state - wait until afterload event");return this._instancesByUid.get(e)||null}_RefreshUidMap(){this._instancesByUid.clear();for(const e of this._allObjectClasses)if(!e.IsFamily())for(const t of e.GetInstances())this._instancesByUid.set(t.GetUID(),t)}IsPreview(){return"preview"===this._exportType}IsDebug(){return this._isDebug}GetExportType(){return this._exportType}IsNWjs(){return"nwjs"===this.GetExportType()||this._isNWjs}IsCordova(){return"cordova"===this._exportType}IsAndroidWebView(){return"Android"===C33.Platform.OS&&("cordova"===this._exportType||"playable-ad-single-file"===this._exportType||"playable-ad-zip"===this._exportType||"instant-games"===this._exportType)}IsiOSCordova(){return this._isiOSCordova}IsiOSWebView(){return this._isiOSWebView}IsWindowsWebView2(){return this._isWindowsWebView2}IsAnyWebView2Wrapper(){return this._isAnyWebView2Wrapper}GetCollisionEngine(){return this._collisionEngine}GetSolidBehavior(){return this._addonManager.GetSolidBehavior()}GetJumpthruBehavior(){return this._addonManager.GetJumpthruBehavior()}Uses3DFeatures(){return this._uses3dFeatures}GetZScaleFactor(){return this.GetRenderer().GetZAxisScaleFactor(this.GetViewportHeight())}GetDefaultCameraZ(e){return this.GetRenderer().GetDefaultCameraZ(e||this.GetViewportHeight())}IsLayoutFirstTick(){return this._isLayoutFirstTick}SetPixelRoundingEnabled(e){this._isPixelRoundingEnabled!==(e=!!e)&&(this._isPixelRoundingEnabled=e,this.GetLayoutManager().SetAllLayerMVChanged(),this.UpdateRender())}IsPixelRoundingEnabled(){return this._isPixelRoundingEnabled}GetTextIconSet(e){if(!this._iconChangeHandlers.has(e)){const s=()=>this.DeleteTextIconSet(e);this._iconChangeHandlers.set(e,s),e.Dispatcher().addEventListener("animationframeimagechange",s)}const t=this._textIconManager.GetIconSet(e);return t.HasLoaded()||t.LoadContent().then(()=>this.UpdateRender()),t}DeleteTextIconSet(e){this._textIconManager.DeleteIconSet(e)}_GetTextIconSetMeta(e){const t=[];for(const s of e.GetAnimations())for(const i of s.GetFrames()){const n=i.GetImageInfo();t.push({source:i,width:n.GetWidth(),height:n.GetHeight(),tag:i.GetTag()})}return{icons:t}}async _GetTextIconSetContent(e){const t=C33.New(C33.PromiseThrottle),s=[],n=new Map;for(const a of e.GetAnimations())for(const o of a.GetFrames()){const l=o.GetImageInfo().GetImageAsset();n.has(l)||(n.set(l,null),s.push(t.Add(async()=>{const e=await l.LoadToDrawable();n.set(l,e)})))}await Promise.all(s);const i=[];for(const h of e.GetAnimations())for(const c of h.GetFrames())i.push(t.Add(async()=>{const e=c.GetImageInfo(),t=n.get(e.GetImageAsset()),s=await e.ExtractImageToCanvas(t),i=await createImageBitmap(s);return{drawable:i}}));const r=await Promise.all(i);for(const u of n.values())u instanceof ImageBitmap&&u.close&&u.close();return{icons:r}}SaveToSlot(e){this._saveToSlotName=e,this._saveToJsonString=!1}SaveToJsonString(){this._saveToSlotName="",this._saveToJsonString=!0}LoadFromSlot(e){this._loadFromSlotName=e}LoadFromJsonString(e){this._loadFromJson=e}GetLastSaveJsonString(){return this._lastSaveJson}_NeedsHandleSaveOrLoad(){return!!(this._saveToSlotName||this._saveToJsonString||this._loadFromSlotName||null!==this._loadFromJson)}async _HandleSaveOrLoad(){if(this._saveToSlotName&&(this.FlushPendingInstances(),await this._DoSaveToSlot(this._saveToSlotName),this._ClearSaveOrLoad()),this._loadFromSlotName&&(await this._DoLoadFromSlot(this._loadFromSlotName),this._ClearSaveOrLoad(),this.IsDebug())&&C3Debugger.StepIfPausedInDebugger(),this._saveToJsonString){const e=await this._SaveToJsonString();this._lastSaveJson=e,await this.TriggerAsync(C33.Plugins.System.Cnds.OnSaveComplete,null),this._lastSaveJson="",this._ClearSaveOrLoad()}if(null!==this._loadFromJson){this.FlushPendingInstances();try{await this._DoLoadFromJsonString(this._loadFromJson),this._lastSaveJson=this._loadFromJson,await this.TriggerAsync(C33.Plugins.System.Cnds.OnLoadComplete,null),this._lastSaveJson=""}catch(e){console.error("[Construct] Failed to load state from JSON string: ",e),await this.TriggerAsync(C33.Plugins.System.Cnds.OnLoadFailed,null)}this._ClearSaveOrLoad()}}_ClearSaveOrLoad(){this._saveToSlotName="",this._saveToJsonString=!1,this._loadFromSlotName="",this._loadFromJson=null}_GetProjectStorage(){return this._projectStorage||(this._projectStorage=localforage.createInstance({name:"c3-localstorage-"+this.GetProjectUniqueId(),description:this.GetProjectName()})),this._projectStorage}_GetSavegamesStorage(){return this._savegamesStorage||(this._savegamesStorage=localforage.createInstance({name:"c3-savegames-"+this.GetProjectUniqueId(),description:this.GetProjectName()})),this._savegamesStorage}async _DoSaveToSlot(e){const t=await this._SaveToJsonString();try{await this._GetSavegamesStorage().setItem(e,t),console.log("[Construct] Saved state to storage ("+t.length+" chars)"),this._lastSaveJson=t,await this.TriggerAsync(C33.Plugins.System.Cnds.OnSaveComplete,null),this._lastSaveJson=""}catch(e){console.error("[Construct] Failed to save state to storage: ",e),await this.TriggerAsync(C33.Plugins.System.Cnds.OnSaveFailed,null)}}async _DoLoadFromSlot(e){try{const t=await this._GetSavegamesStorage().getItem(e);if(!t)throw new Error("empty slot");console.log("[Construct] Loaded state from storage ("+t.length+" chars)"),await this._DoLoadFromJsonString(t),this._lastSaveJson=t,await this.TriggerAsync(C33.Plugins.System.Cnds.OnLoadComplete,null),this._lastSaveJson=""}catch(e){console.error("[Construct] Failed to load state from storage: ",e),await this.TriggerAsync(C33.Plugins.System.Cnds.OnLoadFailed,null)}}async _SaveToJsonString(){const e={c3save:!0,version:1,rt:{time:this.GetGameTime(),timeRaw:this.GetGameTimeRaw(),walltime:this.GetWallTime(),timescale:this.GetTimeScale(),tickcount:this.GetTickCount(),next_uid:this._nextUid,running_layout:this.GetMainRunningLayout().GetSID(),start_time_offset:Date.now()-this._startTime},types:{},layouts:{},events:this._eventSheetManager._SaveToJson(),timelines:this._timelineManager._SaveToJson(),user_script_data:null};for(const s of this._allObjectClasses)s.IsFamily()||s.HasNoSaveBehavior()||(e.types[s.GetSID().toString()]=s._SaveToJson());for(const i of this._layoutManager.GetAllLayouts())e.layouts[i.GetSID().toString()]=i._SaveToJson();const t=this._CreateUserScriptEvent("save");return t.saveData=null,await this.DispatchUserScriptEventAsyncWait(t),e.user_script_data=t.saveData,JSON.stringify(e)}IsLoadingState(){return this._isLoadingState}async _DoLoadFromJsonString(e){const t=this.GetLayoutManager(),s=JSON.parse(e);if(s.c2save)throw new Error("C2 saves are incompatible with C3 runtime");if(!s.c3save)throw new Error("not valid C3 save data");if(1<s.version)throw new Error("C3 save data from future version");this.ClearIntancesNeedingAfterLoad(),this._dispatcher.dispatchEvent(C33.New(C33.Event,"beforeload"));for(const l of this.allInstances()){const h=l.GetObjectClass();h.HasNoSaveBehavior()||l._OnBeforeLoad()}let i=s.rt,n=(this._gameTime.Set(i.time),i.hasOwnProperty("timeRaw")&&this._gameTimeRaw.Set(i.timeRaw),this._wallTime.Set(i.walltime),this._timeScale=i.timescale,this._tickCount=i.tickcount,this._startTime=Date.now()-i.start_time_offset,i.running_layout),r=!(this._isLoadingState=!0);if(n!==this.GetMainRunningLayout().GetSID()){const c=t.GetLayoutBySID(n);if(!c)return;await this._DoChangeLayout(c),r=!0}for(const[u,_]of Object.entries(s.layouts)){const d=parseInt(u,10),p=t.GetLayoutBySID(d);p&&p._LoadFromJson(_)}const a=new Set;for(const[m,g]of Object.entries(s.types)){const f=parseInt(m,10),S=this.GetObjectClassBySID(f);!S||S.IsFamily()||S.HasNoSaveBehavior()||S._LoadFromJson(g,a)}for(const C of this._layoutManager.GetAllLayouts())for(const y of C.allLayers())y._LoadFromJsonAfterInstances();if(this.FlushPendingInstances(),this._RefreshUidMap(),this._isLoadingState=!1,r){for(const G of this.allInstances())G.SetupInitialSceneGraphConnections();for(const[I,T]of Object.entries(s.types)){const b=parseInt(I,10),P=this.GetObjectClassBySID(b);!P||P.IsFamily()||P.HasNoSaveBehavior()||P._SetupSceneGraphConnectionsOnChangeOfLayout(T)}}this._nextUid=i.next_uid,this._eventSheetManager._LoadFromJson(s.events);for(const A of this._allObjectClasses)if(!A.IsFamily()&&A.IsInContainer())for(const R of A.GetInstances()){const E=R.GetIID();for(const v of A.GetContainer().objectTypes())if(v!==A){const x=v.GetInstances();if(E<0||E>=x.length)throw new Error("missing sibling instance");R._AddSibling(x[E])}}this._timelineManager._LoadFromJson(s.timelines),t.SetAllLayerProjectionChanged(),t.SetAllLayerMVChanged();for(const w of a)w._OnCreatedForLoadingSavegame();this.DoAfterLoad(),this._dispatcher.dispatchEvent(C33.New(C33.Event,"afterload")),this.DispatchUserScriptEvent(this._CreateUserScriptEvent("afterload"));for(const[M,D]of Object.entries(s.types)){const O=parseInt(M,10),L=this.GetObjectClassBySID(O);L&&L._ClearLoadInstancesJson()}const o=this._CreateUserScriptEvent("load");o.saveData=s.user_script_data,await this.DispatchUserScriptEventAsyncWait(o),this.UpdateRender()}SortOnTmpHierarchyPosition(e,t){return e.GetWorldInfo().GetTmpHierarchyPosition()-t.GetWorldInfo().GetTmpHierarchyPosition()}AddInstanceNeedingAfterLoad(e,t){e.GetWorldInfo()&&!this._instancesNeedingAfterLoadMap.has(e)&&(this._instancesNeedingAfterLoadMap.set(e,t),this._instancesNeedingAfterLoadArray.push(e))}ClearIntancesNeedingAfterLoad(){this._instancesNeedingAfterLoadMap=new WeakMap,C33.clearArray(this._instancesNeedingAfterLoadArray)}DoAfterLoad(e="full",t=null){this._instancesNeedingAfterLoadArray.sort(this.SortOnTmpHierarchyPosition);for(const s of this._instancesNeedingAfterLoadArray)s._OnAfterLoad(this._instancesNeedingAfterLoadMap.get(s),e,t);for(const i of this._instancesNeedingAfterLoadArray)i._OnAfterLoad2(this._instancesNeedingAfterLoadMap.get(i),e,t);this.ClearIntancesNeedingAfterLoad()}async AddJobWorkerScripts(e){const t=await Promise.all(e.map(async e=>{const t=this.IsCordova()&&this._assetManager.IsFileProtocol();if(t||"playable-ad-single-file"===this.GetExportType()){const s=await this._assetManager.FetchBlob(e);return URL.createObjectURL(s)}return new URL(e,location.href).toString()}));this._jobScheduler.ImportScriptsToJobWorkers(t)}AddJobWorkerBlob(e,t){this._jobScheduler.SendBlobToJobWorkers(e,t)}AddJobWorkerBuffer(e,t){this._jobScheduler.SendBufferToJobWorkers(e,t)}AddJob(e,t,s,i){return this._jobScheduler.AddJob(e,t,s,null,null,i)}BroadcastJob(e,t,s,i){return this._jobScheduler.BroadcastJob(e,t,s,i)}GetMaxNumJobWorkers(){return this._jobScheduler.GetMaxNumWorkers()}InvokeDownload(e,t){this.PostComponentMessageToDOM("runtime","invoke-download",{url:e,filename:t})}async RasterSvgImage(e,t,s,i,n,r){if(i=i||t,n=n||s,this.IsInWorker()){const a=await this.PostComponentMessageToDOMAsync("runtime","raster-svg-image",{blob:e,imageWidth:t,imageHeight:s,surfaceWidth:i,surfaceHeight:n,imageBitmapOpts:r});return a.imageBitmap}{const o=await self.C3_RasterSvgImageBlob(e,t,s,i,n);return r?self.createImageBitmap(o,r):o}}async GetSvgImageSize(e){return this.IsInWorker()?this.PostComponentMessageToDOMAsync("runtime","get-svg-image-size",{blob:e}):self.C3_GetSvgImageSize(e)}RequestDeviceOrientationEvent(){this._didRequestDeviceOrientationEvent||(this._didRequestDeviceOrientationEvent=!0,this.PostComponentMessageToDOM("runtime","enable-device-orientation"))}RequestDeviceMotionEvent(){this._didRequestDeviceMotionEvent||(this._didRequestDeviceMotionEvent=!0,this.PostComponentMessageToDOM("runtime","enable-device-motion"))}Random(){return this._randomNumberCallback()}SetRandomNumberGeneratorCallback(e){this._randomNumberCallback=e}_GetRemotePreviewStatusInfo(){const e=this.GetRenderer();return{fps:this.GetFramesPerSecond(),tps:this.GetTicksPerSecond(),cpu:this.GetMainThreadTime(),gpu:this.GetGPUUtilisation(),layout:this.GetMainRunningLayout()?this.GetMainRunningLayout().GetName():"",renderer:e.IsWebGL()?e.GetUnmaskedRenderer():e.GetAdapterInfoString()}}HitBreakpoint(){return!!this.IsDebug()&&C3Debugger.HitBreakpoint()}DebugBreak(e){return this.IsDebugging()?C3Debugger.DebugBreak(e):Promise.resolve()}DebugBreakNext(){return!!this.IsDebugging()&&C3Debugger.BreakNext()}SetDebugBreakpointsEnabled(e){this._breakpointsEnabled=!!e,this._UpdateDebuggingFlag()}AreDebugBreakpointsEnabled(){return this._breakpointsEnabled}IsDebugging(){return this._isDebugging}SetDebuggingEnabled(e){e?this._debuggingDisabled--:this._debuggingDisabled++,this._UpdateDebuggingFlag()}_UpdateDebuggingFlag(){this._isDebugging=this.IsDebug()&&this._breakpointsEnabled&&0===this._debuggingDisabled}IsCPUProfiling(){return this.IsDebug()&&C3Debugger.IsCPUProfiling()}IsGPUProfiling(){return this.IsDebug()&&this.GetRenderer().SupportsGPUProfiling()&&C3Debugger.IsGPUProfiling()}async DebugIterateAndBreak(e){if(e)for(const t of e)await this.DebugBreak(t)}DebugFireGeneratorEventAndBreak(e){return this.DebugIterateAndBreak(this._dispatcher.dispatchGeneratorEvent(e))}_InvokeFunctionFromJS(e){return this._eventSheetManager._InvokeFunctionFromJS(e.name,e.params)}_GetHTMLLayerWrapElement(e){if(this.IsInWorker())throw new Error("not supported in worker mode");return self.c3_runtimeInterface._GetHTMLWrapElement(e)}GetIRuntime(){return this._iRuntime}_CreateUserScriptEvent(e){const t=C33.New(C33.Event,e,!1);return t.runtime=this._iRuntime,t}_InitScriptInterfaces(){this._iRuntime=new self.IRuntime(this),this._userScriptEventObjects={pretick:this._CreateUserScriptEvent("pretick"),tick:this._CreateUserScriptEvent("tick"),tick2:this._CreateUserScriptEvent("tick2")}}_InitObjectsScriptInterface(){const e={};for(const t of this._allObjectClasses)e[t.GetJsPropName()]={value:t.GetIObjectClass(),enumerable:!0,writable:!1};this._iRuntime._InitObjects(e)}_InitGlobalVariableScriptInterface(){const e={};for(const t of this.GetEventSheetManager().GetAllGlobalVariables())e[t.GetJsPropName()]=t._GetScriptInterfaceDescriptor();this._iRuntime._InitGlobalVars(e)}_GetCommonScriptInterfaces(){return this._commonScriptInterfaces}_MapScriptInterface(e,t){this._interfaceMap.set(e,t)}_UnwrapScriptInterface(e){return this._interfaceMap.get(e)}_UnwrapIObjectClass(e){if(!(e instanceof self.IObjectClass))throw new TypeError("expected IObjectClass");const t=this._UnwrapScriptInterface(e);if(t&&t instanceof C33.ObjectClass)return t;throw new Error("invalid IObjectClass")}_UnwrapIInstance(e){if(!(e instanceof self.IInstance))throw new TypeError("expected IInstance");const t=this._UnwrapScriptInterface(e);if(t&&t instanceof C33.Instance)return t;throw new Error("invalid IInstance")}_UnwrapIWorldInstance(e){if(!(e instanceof self.IWorldInstance))throw new TypeError("expected IWorldInstance");const t=this._UnwrapScriptInterface(e);if(t&&t instanceof C33.Instance)return t;throw new Error("invalid IInstance")}},self.C3_CreateRuntime=C33.Runtime.Create,self.C3_InitRuntime=(e,t)=>e.Init(t)}{const C33=self.C3;C33.JobSchedulerRuntime=class extends C33.DefendedBase{constructor(e,t){super(),this._runtime=e,this._jobPromises=new Map,this._nextJobId=0,this._inputPort=t.inputPort,t.outputPort.onmessage=e=>this._OnJobWorkerMessage(e),this._maxNumWorkers=t.maxNumWorkers,this._jobWorkerCount=1,this._isCreatingWorker=!1,this._hadErrorCreatingWorker=!1}GetMaxNumWorkers(){return this._maxNumWorkers}ImportScriptsToJobWorkers(e){this._inputPort.postMessage({type:"_import_scripts",scripts:e})}SendBlobToJobWorkers(e,t){this._inputPort.postMessage({type:"_send_blob",blob:e,id:t})}SendBufferToJobWorkers(e,t){this._inputPort.postMessage({type:"_send_buffer",buffer:e,id:t},[e])}AddJob(e,t,s,i,n,r){if(s=s||[],"number"==typeof r&&(r=Math.floor(r))<=0)throw new Error("invalid maxWorkerNum");const a=this._nextJobId++,o={type:e,isBroadcast:!1,maxWorkerNum:r,jobId:a,params:t,transferables:s},l=new Promise((e,t)=>{this._jobPromises.set(a,{resolve:e,progress:i,reject:t,cancelled:!1,maxWorkerNum:r})});return n&&n.SetAction(()=>this._CancelJob(a)),this._inputPort.postMessage(o,s),this._MaybeCreateExtraWorker(),l}BroadcastJob(e,t,s,i){if(s=s||[],"number"==typeof i&&(i=Math.floor(i))<=0)throw new Error("invalid maxWorkerNum");const n=this._nextJobId++,r={type:e,isBroadcast:!0,maxWorkerNum:i,jobId:n,params:t,transferables:s};this._inputPort.postMessage(r,s)}_CancelJob(e){const t=this._jobPromises.get(e);t&&(t.cancelled=!0,t.resolve=null,t.progress=null,t.reject=null,this._inputPort.postMessage({type:"_cancel",jobId:e}))}_OnJobWorkerMessage(e){const t=e.data,s=t.type,i=t.jobId;switch(s){case"result":this._OnJobResult(i,t.result);break;case"progress":this._OnJobProgress(i,t.progress);break;case"error":this._OnJobError(i,t.error);break;case"ready":this._OnJobWorkerReady();break;default:throw new Error(`unknown message from worker '${s}'`)}}_OnJobResult(e,t){const s=this._jobPromises.get(e);if(!s)throw new Error("invalid job ID");s.cancelled||s.resolve(t),this._jobPromises.delete(e)}_OnJobProgress(e,t){const s=this._jobPromises.get(e);if(!s)throw new Error("invalid job ID");!s.cancelled&&s.progress&&s.progress(t)}_OnJobError(e,t){const s=this._jobPromises.get(e);if(!s)throw new Error("invalid job ID");s.cancelled||s.reject(t),this._jobPromises.delete(e)}_OnJobWorkerReady(){this._isCreatingWorker&&(this._isCreatingWorker=!1,this._jobWorkerCount++,this._jobWorkerCount<this._maxNumWorkers?this._MaybeCreateExtraWorker():this._inputPort.postMessage({type:"_no_more_workers"}))}_GetWorkerCountNeededForPendingJobs(){let e=0,t=[...this._jobPromises.values()].sort((e,t)=>{const s=e.maxWorkerNum||1/0,i=t.maxWorkerNum||1/0;return s-i});for(const s of t){const i=s.maxWorkerNum||1/0;e<i&&e++}return e}async _MaybeCreateExtraWorker(){if(!(this._jobWorkerCount>=this._maxNumWorkers||this._isCreatingWorker||this._hadErrorCreatingWorker||this._GetWorkerCountNeededForPendingJobs()<=this._jobWorkerCount))try{this._isCreatingWorker=!0;const e=await this._runtime.PostComponentMessageToDOMAsync("runtime","create-job-worker");e.outputPort.onmessage=e=>this._OnJobWorkerMessage(e)}catch(e){this._hadErrorCreatingWorker=!0,this._isCreatingWorker=!1,console.error(`[Construct] Failed to create job worker; stopping creating any more (created ${this._jobWorkerCount} so far)`,e)}}}}self.C3_Shaders={},self.C3_Shaders.water={glsl:"#ifdef GL_FRAGMENT_PRECISION_HIGH\n#define highmedp highp\n#else\n#define highmedp mediump\n#endif\nvarying mediump vec2 vTex;\nuniform lowp sampler2D samplerFront;\nuniform mediump vec2 srcStart;\nuniform mediump vec2 srcEnd;\nprecision mediump float;\nuniform highmedp float seconds;\nuniform mediump vec2 pixelSize;\nconst float PI = 3.1415926535897932;\nuniform float speed;\nuniform float speed_x;\nuniform float speed_y;\nuniform float intensity;\nconst float steps = 8.0;\nuniform float frequency;\nuniform float angle; // better when a prime\nuniform float delta;\nuniform float intence;\nuniform float emboss;\nfloat col(vec2 coord)\n{\nfloat delta_theta = 2.0 * PI / angle;\nfloat col = 0.0;\nfloat theta = 0.0;\nfor (float i = 0.0; i < steps; i++)\n{\nvec2 adjc = coord;\ntheta = delta_theta*i;\nadjc.x += cos(theta)*seconds*speed + seconds * speed_x;\nadjc.y -= sin(theta)*seconds*speed - seconds * speed_y;\ncol = col + cos( (adjc.x*cos(theta) - adjc.y*sin(theta))*frequency)*intensity;\n}\nreturn cos(col);\n}\nvoid main(void)\n{\nmediump vec2 tex = (vTex - srcStart) / (srcEnd - srcStart);\nvec2 p = tex, c1 = p, c2 = p;\nfloat cc1 = col(c1);\nc2.x += (1.0 / pixelSize.x) / delta;\nfloat dx = emboss*(cc1-col(c2))/delta;\nc2.x = p.x;\nc2.y += (1.0 / pixelSize.y) / delta;\nfloat dy = emboss*(cc1-col(c2))/delta;\nc1.x += dx;\nc1.y = -(c1.y+dy);\nfloat alpha = 1.+dot(dx,dy)*intence;\nc1.y = -c1.y;\nc1 = clamp(c1, 0.0, 1.0);\ngl_FragColor = texture2D(samplerFront, mix(srcStart, srcEnd, c1)) * alpha;\n}",glslWebGL2:"",wgsl:"%%SAMPLERFRONT_BINDING%% var samplerFront : sampler;\n%%TEXTUREFRONT_BINDING%% var textureFront : texture_2d<f32>;\nstruct ShaderParams {\nspeed : f32,\nspeed_x : f32,\nspeed_y : f32,\nintensity : f32,\nfrequency : f32,\nangle : f32,\ndelta : f32,\nintence : f32,\nemboss : f32\n};\n%%SHADERPARAMS_BINDING%% var<uniform> shaderParams : ShaderParams;\n%%C3PARAMS_STRUCT%%\n%%C3_UTILITY_FUNCTIONS%%\n%%FRAGMENTINPUT_STRUCT%%\n%%FRAGMENTOUTPUT_STRUCT%%\nconst pi : f32 = 3.1415926535897932;\nconst steps = 8.0;\nfn col(coord : vec2<f32>) -> f32\n{\nvar delta_theta : f32 = 2.0 * pi / shaderParams.angle;\nvar col : f32 = 0.0;\nvar theta : f32 = 0.0;\nfor (var i : f32 = 0.0; i < steps; i = i + 1.0)\n{\nvar adjc : vec2<f32> = coord;\ntheta = delta_theta * i;\nadjc.x = adjc.x + cos(theta) * c3Params.seconds * shaderParams.speed + c3Params.seconds * shaderParams.speed_x;\nadjc.y = adjc.y - (sin(theta) * c3Params.seconds * shaderParams.speed - c3Params.seconds * shaderParams.speed_y);\ncol = col + cos((adjc.x * cos(theta) - adjc.y * sin(theta)) * shaderParams.frequency) * shaderParams.intensity;\n}\nreturn cos(col);\n}\n@fragment\nfn main(input : FragmentInput) -> FragmentOutput\n{\nvar texSize : vec2<f32> = vec2<f32>(textureDimensions(textureFront));\nvar tex : vec2<f32> = c3_srcToNorm(input.fragUV);\nvar p : vec2<f32> = tex;\nvar c1 : vec2<f32> = tex;\nvar c2 : vec2<f32> = tex;\nvar cc1 : f32 = col(c1);\nc2.x = c2.x + texSize.x / shaderParams.delta;\nvar dx : f32 = shaderParams.emboss * (cc1 - col(c2)) / shaderParams.delta;\nc2.x = p.x;\nc2.y = c2.y + texSize.y / shaderParams.delta;\nvar dy : f32 = shaderParams.emboss * (cc1 - col(c2)) / shaderParams.delta;\nc1.x = c1.x + dx;\nc1.y = -(c1.y + dy);\nvar alpha : f32 = 1.0 + dx * dy * shaderParams.intence;\nc1.y = -c1.y;\nc1 = c3_clamp2(c1, 0.0, 1.0);\nvar output : FragmentOutput;\noutput.color = textureSample(textureFront, samplerFront, mix(c3Params.srcStart, c3Params.srcEnd, c1)) * alpha;\nreturn output;\n}",blendsBackground:!1,usesDepth:!1,extendBoxHorizontal:40,extendBoxVertical:40,crossSampling:!1,mustPreDraw:!1,preservesOpaqueness:!1,supports3dDirectRendering:!1,animated:!0,parameters:[["speed",0,"percent"],["speed_x",0,"percent"],["speed_y",0,"percent"],["intensity",0,"float"],["frequency",0,"float"],["angle",0,"float"],["delta",0,"float"],["intence",0,"float"],["emboss",0,"percent"]]},self.C3_Shaders.brightness={glsl:"varying mediump vec2 vTex;\nuniform lowp sampler2D samplerFront;\nuniform lowp float brightness;\nvoid main(void)\n{\nlowp vec4 front = texture2D(samplerFront, vTex);\nlowp float a = front.a;\nif (a != 0.0)\nfront.rgb /= front.a;\nfront.rgb += (brightness - 1.0);\nfront.rgb *= a;\ngl_FragColor = front;\n}",glslWebGL2:"",wgsl:"%%SAMPLERFRONT_BINDING%% var samplerFront : sampler;\n%%TEXTUREFRONT_BINDING%% var textureFront : texture_2d<f32>;\nstruct ShaderParams {\nbrightness : f32\n};\n%%SHADERPARAMS_BINDING%% var<uniform> shaderParams : ShaderParams;\n%%C3_UTILITY_FUNCTIONS%%\n%%FRAGMENTINPUT_STRUCT%%\n%%FRAGMENTOUTPUT_STRUCT%%\n@fragment\nfn main(input : FragmentInput) -> FragmentOutput\n{\nvar front : vec4<f32> = c3_unpremultiply(textureSample(textureFront, samplerFront, input.fragUV));\nvar output : FragmentOutput;\noutput.color = vec4<f32>((front.rgb + (shaderParams.brightness - 1.0)) * front.a, front.a);\nreturn output;\n}",blendsBackground:!1,usesDepth:!1,extendBoxHorizontal:0,extendBoxVertical:0,crossSampling:!1,mustPreDraw:!1,preservesOpaqueness:!0,supports3dDirectRendering:!1,animated:!1,parameters:[["brightness",0,"percent"]]};{let ForEachOrdered_SortInstances2=function(e,t){const s=e[1],i=t[1];if("number"==typeof s&&"number"==typeof i)return s-i;{const n=""+s,r=""+i;return n<r?-1:r<n?1:0}},a=(ForEachOrdered_SortInstances=ForEachOrdered_SortInstances2,self.C3),r=null,n="",s="",o=[],u="",l="",c="",i=a.New(a.ArrayStack);a.Plugins.System=class extends a.SDKPluginBase{constructor(e){super(e),this._loopStack=this._runtime.GetEventSheetManager().GetLoopStack(),this._eventStack=this._runtime.GetEventSheetManager().GetEventStack(),this._imagesLoadingTotal=0,this._imagesLoadingComplete=0,this._functionMaps=new Map}Release(){super.Release()}UpdateRender(){this._runtime.UpdateRender()}Trigger(e){this._runtime.Trigger(e,null,null)}GetRegex(e,t){return r&&e===n&&t===s||(r=new RegExp(e,t),n=e,s=t),r.lastIndex=0,r}GetRegexMatches(e,t,s){if(e!==u||t!==l||s!==c){const i=this.GetRegex(t,s);o=e.match(i),u=e,l=t,c=s}return o}async _LoadTexturesForObjectClasses(e,t){if(t.length){this._imagesLoadingTotal+=t.length;const s=[];for(const i of t)s.push(e.MaybeLoadTexturesFor(i));await a.PromiseAllWithProgress(s,()=>{this._imagesLoadingComplete++}),this._imagesLoadingComplete++,this._imagesLoadingComplete===this._imagesLoadingTotal&&(this._imagesLoadingComplete=0,this._imagesLoadingTotal=0,this._runtime.Trigger(a.Plugins.System.Cnds.OnImageLoadingComplete,null,null))}}GetImageLoadingProgress(){return 0===this._imagesLoadingTotal?1:this._imagesLoadingComplete/this._imagesLoadingTotal}_UnloadTexturesForObjectClasses(e,t){for(const s of t)0===s.GetInstanceCount()&&e.MaybeUnloadTexturesFor(s)}_GetForEachStack(){return i}_Repeat(t){const s=this._runtime.GetEventSheetManager(),e=s.GetEventStack(),i=e.GetCurrentStackFrame(),n=i.GetCurrentEvent(),r=n.GetSolModifiers(),a=i.IsSolModifierAfterCnds(),o=e.Push(n),l=s.GetLoopStack(),h=l.Push();if(h.SetEnd(t),a)for(let e=0;e<t&&!h.IsStopped();++e)s.PushCopySol(r),h.SetIndex(e),n.Retrigger(i,o),s.PopSol(r);else for(let e=0;e<t&&!h.IsStopped();++e)h.SetIndex(e),n.Retrigger(i,o);return e.Pop(),l.Pop(),!1}*_DebugRepeat(t){const s=this._runtime.GetEventSheetManager(),e=s.GetEventStack(),i=e.GetCurrentStackFrame(),n=i.GetCurrentEvent(),r=n.GetSolModifiers(),a=i.IsSolModifierAfterCnds(),o=e.Push(n),l=s.GetLoopStack(),h=l.Push();if(h.SetEnd(t),a)for(let e=0;e<t&&!h.IsStopped();++e)s.PushCopySol(r),h.SetIndex(e),yield*n.DebugRetrigger(i,o),s.PopSol(r);else for(let e=0;e<t&&!h.IsStopped();++e)h.SetIndex(e),yield*n.DebugRetrigger(i,o);return e.Pop(),l.Pop(),!1}_While(){const t=this._runtime.GetEventSheetManager(),e=t.GetEventStack(),s=e.GetCurrentStackFrame(),i=s.GetCurrentEvent(),n=i.GetSolModifiers(),r=s.IsSolModifierAfterCnds(),a=e.Push(i),o=t.GetLoopStack(),l=o.Push();if(r)for(let e=0;!l.IsStopped();++e)t.PushCopySol(n),l.SetIndex(e),i.Retrigger(s,a)||l.Stop(),t.PopSol(n);else for(let e=0;!l.IsStopped();++e)l.SetIndex(e),i.Retrigger(s,a)||l.Stop();return e.Pop(),o.Pop(),!1}*_DebugWhile(){const t=this._runtime.GetEventSheetManager(),e=t.GetEventStack(),s=e.GetCurrentStackFrame(),i=s.GetCurrentEvent(),n=i.GetSolModifiers(),r=s.IsSolModifierAfterCnds(),a=e.Push(i),o=t.GetLoopStack(),l=o.Push();if(r)for(let e=0;!l.IsStopped();++e){t.PushCopySol(n),l.SetIndex(e);const h=yield*i.DebugRetrigger(s,a);h||l.Stop(),t.PopSol(n)}else for(let e=0;!l.IsStopped();++e){l.SetIndex(e);const c=yield*i.DebugRetrigger(s,a);c||l.Stop()}return e.Pop(),o.Pop(),!1}_For(e,t,s){const i=this._runtime.GetEventSheetManager(),n=i.GetEventStack(),r=n.GetCurrentStackFrame(),a=r.GetCurrentEvent(),o=a.GetSolModifiers(),l=r.IsSolModifierAfterCnds(),h=n.Push(a),c=i.GetLoopStack(),u=c.Push();if(u.SetName(e),u.SetEnd(s),s<t)if(l)for(let e=t;e>=s&&!u.IsStopped();--e)i.PushCopySol(o),u.SetIndex(e),a.Retrigger(r,h),i.PopSol(o);else for(let e=t;e>=s&&!u.IsStopped();--e)u.SetIndex(e),a.Retrigger(r,h);else if(l)for(let e=t;e<=s&&!u.IsStopped();++e)i.PushCopySol(o),u.SetIndex(e),a.Retrigger(r,h),i.PopSol(o);else for(let e=t;e<=s&&!u.IsStopped();++e)u.SetIndex(e),a.Retrigger(r,h);return n.Pop(),c.Pop(),!1}*_DebugFor(e,t,s){const i=this._runtime.GetEventSheetManager(),n=i.GetEventStack(),r=n.GetCurrentStackFrame(),a=r.GetCurrentEvent(),o=a.GetSolModifiers(),l=r.IsSolModifierAfterCnds(),h=n.Push(a),c=i.GetLoopStack(),u=c.Push();if(u.SetName(e),u.SetEnd(s),s<t)if(l)for(let e=t;e>=s&&!u.IsStopped();--e)i.PushCopySol(o),u.SetIndex(e),yield*a.DebugRetrigger(r,h),i.PopSol(o);else for(let e=t;e>=s&&!u.IsStopped();--e)u.SetIndex(e),yield*a.DebugRetrigger(r,h);else if(l)for(let e=t;e<=s&&!u.IsStopped();++e)i.PushCopySol(o),u.SetIndex(e),yield*a.DebugRetrigger(r,h),i.PopSol(o);else for(let e=t;e<=s&&!u.IsStopped();++e)u.SetIndex(e),yield*a.DebugRetrigger(r,h);return n.Pop(),c.Pop(),!1}_ForEach(s){const e=s.GetCurrentSol(),t=e.GetInstances();if(0!==t.length){const n=this._runtime.GetEventSheetManager(),r=n.GetEventStack(),o=r.GetCurrentStackFrame(),l=o.GetCurrentEvent(),h=l.GetSolModifiers(),c=o.IsSolModifierAfterCnds(),u=r.Push(l),_=n.GetLoopStack(),d=_.Push(),p=s.IsInContainer(),m=i.Push();if(a.shallowAssignArray(m,t),d.SetEnd(m.length),c)for(let e=0,t=m.length;e<t&&!d.IsStopped();++e){n.PushCopySol(h);const g=m[e];s.GetCurrentSol().SetSinglePicked(g),p&&g.SetSiblingsSinglePicked(),d.SetIndex(e),l.Retrigger(o,u),n.PopSol(h)}else{e._SetSelectAll(!1);const f=e._GetOwnInstances();a.clearArray(f),f.push(null);for(let e=0,t=m.length;e<t&&!d.IsStopped();++e){const S=m[e];f[0]=S,p&&S.SetSiblingsSinglePicked(),d.SetIndex(e),l.Retrigger(o,u)}}r.Pop(),_.Pop(),a.clearArray(m),i.Pop()}return!1}*_DebugForEach(s){const e=s.GetCurrentSol(),t=e.GetInstances();if(0!==t.length){const n=this._runtime.GetEventSheetManager(),r=n.GetEventStack(),o=r.GetCurrentStackFrame(),l=o.GetCurrentEvent(),h=l.GetSolModifiers(),c=o.IsSolModifierAfterCnds(),u=r.Push(l),_=n.GetLoopStack(),d=_.Push(),p=s.IsInContainer(),m=i.Push();if(a.shallowAssignArray(m,t),d.SetEnd(m.length),c)for(let e=0,t=m.length;e<t&&!d.IsStopped();++e){n.PushCopySol(h);const g=m[e];s.GetCurrentSol().SetSinglePicked(g),p&&g.SetSiblingsSinglePicked(),d.SetIndex(e),yield*l.DebugRetrigger(o,u),n.PopSol(h)}else{e._SetSelectAll(!1);const f=e._GetOwnInstances();a.clearArray(f),f.push(null);for(let e=0,t=m.length;e<t&&!d.IsStopped();++e){const S=m[e];f[0]=S,p&&S.SetSiblingsSinglePicked(),d.SetIndex(e),yield*l.DebugRetrigger(o,u)}}r.Pop(),_.Pop(),a.clearArray(m),i.Pop()}return!1}_ForEachOrdered(s,e){const t=s.GetCurrentSol(),n=t.GetInstances();if(0!==n.length){const r=this._runtime.GetEventSheetManager(),o=r.GetEventStack(),l=r.GetCurrentCondition(),h=o.GetCurrentStackFrame(),c=h.GetCurrentEvent(),u=c.GetSolModifiers(),_=h.IsSolModifierAfterCnds(),d=o.Push(c),p=r.GetLoopStack(),m=p.Push(),g=s.IsInContainer(),f=i.Push();a.clearArray(f),m.SetEnd(n.length);for(let e=0,t=n.length;e<t;++e)f.push([n[e],l.ReevaluateParameter(1,e)]);if(f.sort(ForEachOrdered_SortInstances2),1===e&&f.reverse(),_)for(let e=0,t=f.length;e<t&&!m.IsStopped();++e){r.PushCopySol(u);const S=f[e][0];s.GetCurrentSol().SetSinglePicked(S),g&&S.SetSiblingsSinglePicked(),m.SetIndex(e),c.Retrigger(h,d),r.PopSol(u)}else{t._SetSelectAll(!1);const C=t._GetOwnInstances();a.clearArray(C),C.push(null);for(let e=0,t=f.length;e<t&&!m.IsStopped();++e){const y=f[e][0];C[0]=y,g&&y.SetSiblingsSinglePicked(),m.SetIndex(e),c.Retrigger(h,d)}}o.Pop(),p.Pop(),a.clearArray(f),i.Pop()}return!1}*_DebugForEachOrdered(s,e){const t=s.GetCurrentSol(),n=t.GetInstances();if(0!==n.length){const r=this._runtime.GetEventSheetManager(),o=r.GetEventStack(),l=r.GetCurrentCondition(),h=o.GetCurrentStackFrame(),c=h.GetCurrentEvent(),u=c.GetSolModifiers(),_=h.IsSolModifierAfterCnds(),d=o.Push(c),p=r.GetLoopStack(),m=p.Push(),g=s.IsInContainer(),f=i.Push();a.clearArray(f),m.SetEnd(n.length);for(let e=0,t=n.length;e<t;++e)f.push([n[e],l.ReevaluateParameter(1,e)]);if(f.sort(ForEachOrdered_SortInstances2),1===e&&f.reverse(),_)for(let e=0,t=f.length;e<t&&!m.IsStopped();++e){r.PushCopySol(u);const S=f[e][0];s.GetCurrentSol().SetSinglePicked(S),g&&S.SetSiblingsSinglePicked(),m.SetIndex(e),yield*c.DebugRetrigger(h,d),r.PopSol(u)}else{t._SetSelectAll(!1);const C=t._GetOwnInstances();a.clearArray(C),C.push(null);for(let e=0,t=f.length;e<t&&!m.IsStopped();++e){const y=f[e][0];C[0]=y,g&&y.SetSiblingsSinglePicked(),m.SetIndex(e),yield*c.DebugRetrigger(h,d)}}o.Pop(),p.Pop(),a.clearArray(f),i.Pop()}return!1}_GetFunctionMap(e,t){let s=this._functionMaps.get(e);if(!s){if(!t)return null;s={defaultFunc:null,strMap:new Map},this._functionMaps.set(e,s)}return s}_DoCallMappedFunction(e,t,s,i,n){t.GetEventBlock().RunAsMappedFunctionCall(s,t.IsCopyPicked()),i&&e.PopSol(n)}*_DebugDoCallMappedFunction(e,t,s,i,n){yield*t.GetEventBlock().DebugRunAsMappedFunctionCall(s,t.IsCopyPicked()),i&&e.PopSol(n)}}}{const a1=self.C3;a1.Plugins.System.Type=class extends a1.DefendedBase{constructor(e){super(),this._objectClass=e,this._runtime=e.GetRuntime(),this._plugin=e.GetPlugin()}OnCreate(){}Release(){this._objectClass=null,this._runtime=null,this._plugin=null}}}{const d1=self.C3;d1.Plugins.System.Instance=class extends d1.DefendedBase{constructor(e,t){super(),this._inst=e,this._objectClass=this._inst.GetObjectClass(),this._sdkType=this._objectClass.GetSdkType(),this._runtime=this._inst.GetRuntime()}Release(){this._inst=null,this._objectClass=null,this._sdkType=null,this._runtime=null}}}{const h1=self.C3,i1=[];h1.Plugins.System.Cnds={EveryTick(){return!0},OnLayoutStart(){return!0},OnLayoutEnd(){return!0},OnSuspend(){return!0},OnResume(){return!0},IsSuspended(){return this._runtime.IsSuspended()},Else(){const e=this._runtime.GetCurrentEventStackFrame();return!e.GetElseBranchRan()&&!e.GetLastEventTrue()},TriggerOnce(){let e=this._runtime.GetCurrentCondition(),t=e.GetSavedDataMap(),s=t.get("TriggerOnce_lastTick");void 0===s&&(s=-1,t.set("TriggerOnce_lastTick",-1));const i=this._runtime.GetTickCount();return t.set("TriggerOnce_lastTick",i),this._runtime.IsLayoutFirstTick()||s!==i-1},Every(e){const t=this._runtime.GetCurrentCondition(),s=t.GetSavedDataMap(),i=s.get("Every_lastTime")||0,n=this._runtime.GetGameTime(),r=(s.has("Every_seconds")||s.set("Every_seconds",e),s.get("Every_seconds"));return i+r<=n?(s.set("Every_lastTime",i+r),n>=s.get("Every_lastTime")+.04&&s.set("Every_lastTime",n),s.set("Every_seconds",e),!0):(n<i-.1&&s.set("Every_lastTime",n),!1)},IsGroupActive(e){const t=this._runtime.GetEventSheetManager().GetEventGroupByName(e);return t&&t.IsGroupActive()},IsPreview(){return this._runtime.IsPreview()},IsMobile(){return h1.Platform.IsMobile},OnLoadFinished(){return!0},OnCanvasSnapshot(){return!0},EffectsSupported(){return!0},OnSaveComplete(){return!0},OnSaveFailed(){return!0},OnLoadComplete(){return!0},OnLoadFailed(){return!0},ObjectUIDExists(e){return!!this._runtime.GetInstanceByUID(e)},IsOnPlatform(e){switch(e){case 0:return"browser"===h1.Platform.Context;case 1:return"iOS"===h1.Platform.OS;case 2:return"Android"===h1.Platform.OS;case 8:return"cordova"===h1.Platform.Context;case 9:return"scirra-arcade"===this._runtime.GetExportType();case 10:return"nwjs"===h1.Platform.Context;case 13:return"windows-uwp"===this._runtime.GetExportType();default:return!1}},RegexTest(e,t,s){const i=this.GetRegex(t,s);return i.test(e)},Compare(e,t,s){return h1.compare(e,t,s)},CompareBetween(e,t,s){return t<=e&&e<=s},CompareVar(e,t,s){return h1.compare(e.GetValue(),t,s)},CompareBoolVar(e){return!!e.GetValue()},CompareTime(e,t){const s=this._runtime.GetGameTime();if(0!==e)return h1.compare(s,e,t);{const i=this._runtime.GetCurrentCondition(),n=i.GetSavedDataMap();return!n.get("CompareTime_executed")&&t<=s&&(n.set("CompareTime_executed",!0),!0)}},IsNaN(e){return isNaN(e)},AngleWithin(e,t,s){return h1.angleDiff(h1.toRadians(e),h1.toRadians(s))<=h1.toRadians(t)},IsClockwiseFrom(e,t){return h1.angleClockwise(h1.toRadians(e),h1.toRadians(t))},IsBetweenAngles(e,t,s){let i=h1.toRadians(e),n=h1.toRadians(t),r=h1.toRadians(s),a=!h1.angleClockwise(r,n);return a?!(!h1.angleClockwise(i,n)&&h1.angleClockwise(i,r)):h1.angleClockwise(i,n)&&!h1.angleClockwise(i,r)},IsValueType(e,t){return"number"==typeof e?0===t:1===t},EvaluateExpression(e){return!!e},OnSignal(e){return e.toLowerCase()===this._runtime.GetEventSheetManager().GetCurrentSignalTag()},PickByComparison(e,s,i,n){if(!e)return!1;let t=this._GetForEachStack(),r=t.Push(),a=e.GetCurrentSol(),o=(h1.shallowAssignArray(r,a.GetInstances()),a.IsSelectAll()&&h1.clearArray(a._GetOwnElseInstances()),this._runtime.GetCurrentCondition()),l=0;for(let e=0,t=r.length;e<t;++e){const c=r[e];r[l]=c,s=o.ReevaluateParameter(1,e),n=o.ReevaluateParameter(3,e),h1.compare(s,i,n)?++l:a._PushElseInstance(c)}h1.truncateArray(r,l),a.SetArrayPicked(r);const h=!!r.length;return h1.clearArray(r),t.Pop(),e.ApplySolToContainer(),h},PickByEvaluate(e,t){if(!e)return!1;let s=this._GetForEachStack(),i=s.Push(),n=e.GetCurrentSol(),r=(h1.shallowAssignArray(i,n.GetInstances()),n.IsSelectAll()&&h1.clearArray(n._GetOwnElseInstances()),this._runtime.GetCurrentCondition()),a=0;for(let e=0,t=i.length;e<t;++e){const l=i[e];i[a]=l,r.ReevaluateParameter(1,e)?++a:n._PushElseInstance(l)}h1.truncateArray(i,a),n.SetArrayPicked(i);const o=!!i.length;return h1.clearArray(i),s.Pop(),e.ApplySolToContainer(),o},PickByHighestLowestValue(e,s,i){if(!e)return!1;const t=e.GetCurrentSol(),n=t.GetInstances();if(0===n.length)return!1;let r=this._runtime.GetCurrentCondition(),a=null,o=0;for(let e=0,t=n.length;e<t;++e){const l=n[e];i=r.ReevaluateParameter(2,e),(null===a||0===s&&i<o||1===s&&i>o)&&(o=i,a=l)}return t.PickOne(a),e.ApplySolToContainer(),!0},PickNth(e,t){if(!e)return!1;const s=e.GetCurrentSol(),i=s.GetInstances();if((t=Math.floor(t))>=i.length)return!1;const n=i[t];return s.PickOne(n),e.ApplySolToContainer(),!0},PickRandom(e){if(!e)return!1;const t=e.GetCurrentSol(),s=t.GetInstances(),i=Math.floor(this._runtime.Random()*s.length);if(i>=s.length)return!1;const n=s[i];return t.PickOne(n),e.ApplySolToContainer(),!0},PickAll(e){if(!e)return!1;if(!e.GetInstanceCount())return!1;const t=e.GetCurrentSol();return t._SetSelectAll(!0),e.ApplySolToContainer(),!0},PickOverlappingPoint(e,s,i){if(!e)return!1;const n=e.GetCurrentSol(),t=n.GetInstances(),r=this._runtime.GetCurrentEvent(),a=r.IsOrBlock(),o=this._runtime.GetCurrentCondition().IsInverted();n.IsSelectAll()?(h1.shallowAssignArray(i1,t),n.ClearArrays(),n._SetSelectAll(!1)):a?(h1.shallowAssignArray(i1,n._GetOwnElseInstances()),h1.clearArray(n._GetOwnElseInstances())):(h1.shallowAssignArray(i1,n._GetOwnInstances()),h1.clearArray(n._GetOwnInstances()));for(let e=0,t=i1.length;e<t;++e){const l=i1[e];h1.xor(l.GetWorldInfo().ContainsPoint(s,i),o)?n._PushInstance(l):n._PushElseInstance(l)}return e.ApplySolToContainer(),h1.xor(!!n._GetOwnInstances().length,o)},PickLastCreated(t){if(!t)return!1;let s=t.IsFamily(),i=null,n=this._runtime._GetInstancesPendingCreate();for(let e=n.length-1;0<=e;--e){const r=n[e];if(s){if(r.GetObjectClass().BelongsToFamily(t)){i=r;break}}else if(r.GetObjectClass()===t){i=r;break}}if(!i){const a=t.GetInstances();a.length&&(i=a.at(-1))}if(!i)return!1;const e=t.GetCurrentSol();return e.PickOne(i),t.ApplySolToContainer(),!0},Repeat(e){return this._runtime.IsDebugging()?this._DebugRepeat(e):this._Repeat(e)},While(){return this._runtime.IsDebugging()?this._DebugWhile():this._While()},For(e,t,s){return this._runtime.IsDebugging()?this._DebugFor(e,t,s):this._For(e,t,s)},ForEach(e){return this._runtime.IsDebugging()?this._DebugForEach(e):this._ForEach(e)},ForEachOrdered(e,t,s){return this._runtime.IsDebugging()?this._DebugForEachOrdered(e,s):this._ForEachOrdered(e,s)},LayerVisible(e){return!!e&&e.IsVisible()},LayerInteractive(e){return!!e&&e.IsSelfAndParentsInteractive()},LayerIsHTML(e){return!!e&&e.IsHTMLElementsLayer()},LayerEmpty(e){return!!e&&!e.GetInstanceCount()},LayerCmpOpacity(e,t,s){return!!e&&h1.compare(100*e.GetOpacity(),t,s)},LayerNameExists(e){const t=this._runtime.GetMainRunningLayout();return!!t&&t.HasLayerByName(e)},OnImageLoadingComplete(){return!0},IsLoadingImages(){return 0<this._imagesLoadingTotal},TemplateExists(e,t){const s=this._runtime.GetTemplateManager();return!!s&&!!t&&!!s.GetTemplateData(e,t)}}}{let SortZOrderList2=function(e,t){const s=e[0],i=t[0],n=s-i;if(0!=n)return n;const r=e[1],a=t[1];return r-a},SortInstancesByValue2=function(e,t){return e[1]-t[1]};SortZOrderList=SortZOrderList2,SortInstancesByValue=SortInstancesByValue2;const M2=self.C3,N2=[],O2=[],P2=M2.New(M2.Rect),Q2=M2.New(M2.Color),R2=[];M2.Plugins.System.Acts={SetVar(e,t){e.SetValue(t)},AddVar(e,t){e.IsNumber()&&"number"!=typeof t&&(t=parseFloat(t)),e.SetValue(e.GetValue()+t)},SubVar(e,t){e.IsNumber()&&e.SetValue(e.GetValue()-t)},SetBoolVar(e,t){e.SetValue(!!t)},ToggleBoolVar(e){e.SetValue(!e.GetValue())},ResetEventVar(e){e.SetValue(e.GetInitialValue())},ResetGlobals(e){this._runtime.GetEventSheetManager().ResetAllGlobalsToInitialValue(e)},CreateObject(e,t,s,i,n,r){if(e&&t){const a=this._runtime.CreateInstance(e,t,s,i,n,r);if(a){n&&t.SortAndAddInstancesByZIndex(a);const o=this._runtime.GetEventSheetManager(),l=(o.BlockFlushingInstances(!0),a._TriggerOnCreatedOnSelfAndRelated(),o.BlockFlushingInstances(!1),new Map);a.CollectInstancesToPick(l,e,n);for(const[h,c]of l)h.GetCurrentSol().SetSetPicked(c)}}},CreateObjectByName(e,t,s,i,n,r){if(e&&t){const a=this._runtime.GetObjectClassByName(e);a&&M2.Plugins.System.Acts.CreateObject.call(this,a,t,s,i,n,r)}},RecreateInitialObjects(n,r,a,o,l,e,h,c,u,_,d){if(n){let t=this._runtime.GetCurrentLayout(),s=t;if(e){const p=this._runtime.GetLayoutManager().GetLayoutByName(e);if(!p)return;s=p}let i=null;if(!("number"!=typeof h||0<=h)||(i=s.GetLayer(h))){let e=null;if(!("number"!=typeof c||0<=c)||(e=t.GetLayer(c))){P2.set(r,a,o,l);const m=s.RecreateInitialObjects(n,P2,i,e,u,_,d);n.GetCurrentSol().SetArrayPicked(m),n.ApplySolToContainer()}}}},StopLoop(){const e=this._loopStack;e.IsInLoop()&&e.GetCurrent().Stop()},SetGroupActive(e,t){const s=this._runtime.GetEventSheetManager().GetEventGroupByName(e);s&&(0===t?s.SetGroupActive(!1):1===t?s.SetGroupActive(!0):s.SetGroupActive(!s.IsGroupActive()))},SetTimescale(e){this._runtime.SetTimeScale(e)},SetObjectTimescale(e,t){if(t<0&&(t=0),e){const s=e.GetCurrentSol(),i=s.GetInstances();for(const n of i)n.SetTimeScale(t)}},RestoreObjectTimescale(e){if(e){const t=e.GetCurrentSol(),s=t.GetInstances();for(const i of s)i.RestoreTimeScale()}},Wait(e,t){if(!(e<0)){const s=this._runtime.GetEventSheetManager().AddScheduledWait();return t?s.InitTimer(e):s.InitWallTimer(e),!0}},WaitForSignal(e){return this._runtime.GetEventSheetManager().AddScheduledWait().InitSignal(e),!0},WaitForPreviousActions(){const e=this._runtime.GetEventSheetManager();return e.AddScheduledWait().InitPromise(e.GetPromiseForAllAsyncActions()),!0},Signal(e){this._runtime.GetEventSheetManager().Signal(e)},async SnapshotCanvas(e,t,s,i,n,r){const a=this._runtime.GetCanvasManager();a&&(this.UpdateRender(),await a.SnapshotCanvas(0===e?"image/png":"image/jpeg",t/100,s,i,n,r),await this._runtime.TriggerAsync(M2.Plugins.System.Cnds.OnCanvasSnapshot,null))},SetCanvasSize(e,t){if(!(e<=0||t<=0)){this._runtime.SetViewportSize(e,t),this._runtime.GetCurrentLayout().BoundScrolling();const s=this._runtime.GetCanvasManager();s&&("off"!==s.GetCurrentFullscreenMode()&&this._runtime.SetOriginalViewportSize(e,t),s.SetSize(s.GetLastWidth(),s.GetLastHeight(),!0),this._runtime.UpdateRender())}},SetFullscreenQuality(e){const t=this._runtime.GetCanvasManager();t&&"off"!==t.GetCurrentFullscreenMode()&&(t.SetFullscreenScalingQuality(0!==e?"high":"low"),t.SetSize(t.GetLastWidth(),t.GetLastHeight(),!0))},SaveState(e){this._runtime.SaveToSlot(e)},SaveStateJSON(){this._runtime.SaveToJsonString()},LoadState(e){this._runtime.LoadFromSlot(e)},LoadStateJSON(e){this._runtime.LoadFromJsonString(e)},SetHalfFramerateMode(e){},ResetPersisted(){for(const e of this._runtime.GetLayoutManager().GetAllLayouts())e.ResetPersistData()},SetPixelRounding(e){this._runtime.SetPixelRoundingEnabled(0!==e)},SetFramerateMinMax(e,t){this._runtime.SetMaxDt(1/e),this._runtime.SetMinDt(1/t)},SetDeltaTimeMinMax(e,t){this._runtime.SetMinDt(e),this._runtime.SetMaxDt(t)},SetFramerateMode(e){this._runtime._SetFramerateMode(["vsync","unlimited-tick","unlimited-frame"][e])},SortZOrderByInstVar(e,s){if(e){const t=e.GetCurrentSol(),i=t.GetInstances(),n=N2,r=O2,a=this._runtime.GetCurrentLayout(),o=e.IsFamily(),l=e.GetFamilyIndex();for(let e=0,t=i.length;e<t;++e){const h=i[e],c=h.GetWorldInfo();if(c){let e;e=o?h.GetInstanceVariableValue(s+h.GetObjectClass().GetFamilyInstanceVariableOffset(l)):h.GetInstanceVariableValue(s),n.push([c.GetLayer().GetIndex(),c.GetZIndex()]),r.push([h,e])}}if(n.length){n.sort(SortZOrderList2),r.sort(SortInstancesByValue2);let s=!1;for(let e=0,t=n.length;e<t;++e){const u=r[e][0],_=a.GetLayerByIndex(n[e][0]),d=n[e][1],p=_._GetInstances();p[d]!==u&&((p[d]=u).GetWorldInfo()._SetLayer(_,!0),_.SetZIndicesChanged(u),s=!0)}s&&this._runtime.UpdateRender(),M2.clearArray(N2),M2.clearArray(O2)}}},SetCollisionCellSize(e,t){e=Math.floor(e),t=Math.floor(t),e<=0||t<=0||!Number.isFinite(e)||!Number.isFinite(t)||this._runtime.GetCollisionEngine().SetCollisionCellSize(e,t)},GoToLayout(e){if(!this._runtime.IsLoading()){const t=this._runtime.GetLayoutManager();t.IsPendingChangeMainLayout()||t.ChangeMainLayout(e)}},GoToLayoutByName(e){if(!this._runtime.IsLoading()){const t=this._runtime.GetLayoutManager();if(!t.IsPendingChangeMainLayout()){const s=t.GetLayoutByName(e);s&&t.ChangeMainLayout(s)}}},NextPrevLayout(e){if(!this._runtime.IsLoading()){const t=this._runtime.GetLayoutManager();if(!t.IsPendingChangeMainLayout()){const s=t.GetAllLayouts(),i=s.indexOf(t.GetMainRunningLayout());if((!e||0!==i)&&(e||i!==s.length-1)){const n=s[i+(e?-1:1)];t.ChangeMainLayout(n)}}}},RestartLayout(){if(!this._runtime.IsLoading()){const e=this._runtime.GetLayoutManager();e.IsPendingChangeMainLayout()||(e.ChangeMainLayout(e.GetMainRunningLayout()),this._runtime.GetEventSheetManager().ResetAllGroupsInitialActivation())}},SetLayerVisible(e,t){e&&e.SetVisible(t)},SetLayerInteractive(e,t){e&&e.SetInteractive(t)},SetLayerHTML(e,t){e&&e.SetIsHTMLElementsLayer(t)},SetLayerOpacity(e,t){e&&e.SetOpacity(t/100)},SetLayerScale(e,t){e&&e.SetOwnScale(t)},SetLayerScaleRate(e,t){e&&e.SetScaleRate(t)},SetLayerAngle(e,t){e&&e.SetAngle(M2.toRadians(+t))},SetLayerScroll(e,t,s){e&&(e.SetOwnScrollPositionEnabled(!0),e.SetScrollX(t),e.SetScrollY(s))},RestoreLayerScroll(e){e&&e.SetOwnScrollPositionEnabled(!1)},SetLayerParallax(e,t,s){e&&e.SetParallax(t/100,s/100)},SetLayerZElevation(e,t){e&&e.SetZElevation(+t)},SetLayerBackground(e,t){if(e){Q2.setFromRgbValue(t),Q2.clamp();const s=e.GetBackgroundColor();s.equalsIgnoringAlpha(Q2)||(s.copyRgb(Q2),this.UpdateRender())}},SetLayerTransparent(e,t){e&&e.SetTransparent(t)},SetLayerBlendMode(e,t){e&&e.SetBlendMode(t)},SetLayerEffectEnabled(e,t,s){if(e){const i=e.GetEffectList(),n=i.GetEffectTypeByName(s);if(n){const r=1===t;n.IsActive()!==r&&(n.SetActive(r),e.UpdateActiveEffects(),this._runtime.UpdateRender())}}},SetLayerEffectParam(e,t,s,i){if(e){const n=e.GetEffectList(),r=n.GetEffectTypeByName(t);if(r){s=Math.floor(s);const a=r.GetShaderProgram().GetParameterType(s);if(a){"color"===a?(Q2.setFromRgbValue(i),i=Q2):"percent"===a&&(i/=100);const o=n.SetEffectParameter(r.GetIndex(),s,i);o&&r.IsActive()&&this._runtime.UpdateRender()}}}},SetLayerForceOwnTexture(e,t){e&&e.SetForceOwnTexture(t)},SetLayoutScale(e){this._runtime.GetCurrentLayout().SetScale(+e)},SetLayoutAngle(e){this._runtime.GetCurrentLayout().SetAngle(M2.toRadians(+e))},SetLayoutEffectEnabled(e,t){const s=this._runtime.GetCurrentLayout(),i=s.GetEffectList(),n=i.GetEffectTypeByName(t);if(n){const r=1===e;n.IsActive()!==r&&(n.SetActive(r),s.UpdateActiveEffects(),this._runtime.UpdateRender())}},SetLayoutEffectParam(e,t,s){const i=this._runtime.GetCurrentLayout(),n=i.GetEffectList(),r=n.GetEffectTypeByName(e);if(r){t=Math.floor(t);const a=r.GetShaderProgram().GetParameterType(t);if(a){"color"===a?(Q2.setFromRgbValue(s),s=Q2):"percent"===a&&(s/=100);const o=n.SetEffectParameter(r.GetIndex(),t,s);o&&r.IsActive()&&this._runtime.UpdateRender()}}},SetLayoutVanishingPoint(e,t){const s=this._runtime.GetCurrentLayout();s.SetVanishingPointXY(e/100,t/100)},SetLayoutProjection(e){const t=this._runtime.GetCurrentLayout();0===e?t.SetPerspectiveProjection():t.SetOrthographicProjection()},ScrollX(e){const t=this._runtime.GetCurrentLayout();t.SetScrollX(e)},ScrollY(e){const t=this._runtime.GetCurrentLayout();t.SetScrollY(e)},Scroll(e,t){const s=this._runtime.GetCurrentLayout();s.SetScrollX(e),s.SetScrollY(t)},ScrollToObject(e){if(e){const t=e.GetFirstPicked();if(t){const s=t.GetWorldInfo();if(s){const i=this._runtime.GetCurrentLayout();i.SetScrollX(s.GetX()),i.SetScrollY(s.GetY())}}}},AddLayer(e,t,s){const i=this._runtime.GetCurrentLayout();try{i.AddLayer(e,t,s)}catch(e){console.warn("[Construct] Cannot add layer: ",e)}},MoveLayer(e,t,s){if(e){const i=this._runtime.GetCurrentLayout();try{i.MoveLayer(e,t,s)}catch(e){console.warn("[Construct] Cannot move layer: ",e)}}},RemoveLayer(e){if(e){const t=this._runtime.GetCurrentLayout();t.RemoveLayer(e)}},RemoveAllDynamicLayers(){this._runtime.GetCurrentLayout().RemoveAllDynamicLayers()},async LoadObjectTextures(e){const t=this._runtime.GetMainRunningLayout();if(t&&e&&!this._runtime.IsLoading()){const s=e.IsFamily()?e.GetFamilyMembers():[e];await this._LoadTexturesForObjectClasses(t,s)}},async LoadObjectTexturesByName(e){await M2.Plugins.System.Acts.LoadObjectTextures.call(this,this._runtime.GetObjectClassByName(e))},UnloadObjectTextures(e){const t=this._runtime.GetMainRunningLayout();if(t&&e){const s=e.IsFamily()?e.GetFamilyMembers():[e];this._UnloadTexturesForObjectClasses(t,s)}},UnloadObjectTexturesByName(e){M2.Plugins.System.Acts.UnloadObjectTextures.call(this,this._runtime.GetObjectClassByName(e))},UnloadUnusedTextures(){const e=this._runtime.GetMainRunningLayout();if(e){const t=e._GetTextureLoadedObjectTypes();this._UnloadTexturesForObjectClasses(e,t)}},async LoadLayoutTextures(e){const t=this._runtime.GetMainRunningLayout();e&&t&&!this._runtime.IsLoading()&&await this._LoadTexturesForObjectClasses(t,e._GetInitialObjectClasses())},async LoadLayoutTexturesByName(e){const t=this._runtime.GetMainRunningLayout(),s=this._runtime.GetLayoutManager().GetLayoutByName(e);s&&t&&!this._runtime.IsLoading()&&await this._LoadTexturesForObjectClasses(t,s._GetInitialObjectClasses())},SetFunctionReturnValue(e){const t=this._eventStack.GetCurrentExpFuncStackFrame();if(t)switch(t.GetFunctionReturnType()){case 1:"number"==typeof e&&t.SetFunctionReturnValue(e);break;case 2:"string"==typeof e&&t.SetFunctionReturnValue(e);break;case 3:t.SetFunctionReturnValue(e)}},MapFunction(e,t,s){const i=this._GetFunctionMap(e.toLowerCase(),!0),n=i.strMap,r=t.toLowerCase(),a=(n.has(r)&&console.warn(`[Construct] Function map '${e}' string '${t}' already in map; overwriting entry`),M2.first(n.values())||i.defaultFunc);if(a){const o=0!==a.GetReturnType(),l=0!==s.GetReturnType();if(o!=l)return void console.error(`[Construct] Function map '${e}' string '${t}' function return type not compatible with other functions in the map; entry ignored`)}n.set(r,s)},MapFunctionDefault(e,t){const s=this._GetFunctionMap(e.toLowerCase(),!0),i=(s.defaultFunc&&console.warn(`[Construct] Function map '${e}' already has a default; overwriting entry`),M2.first(s.strMap.values())||s.defaultFunc);if(i){const n=0!==i.GetReturnType(),r=0!==t.GetReturnType();if(n!=r)return void console.error(`[Construct] Function map '${e}' default: function return type not compatible with other functions in the map; entry ignored`)}s.defaultFunc=t},CallMappedFunction(e,t,s){const i=this._runtime,n=i.IsDebugging()?R2:null,r=(s=Math.floor(s),this._GetFunctionMap(e.toLowerCase(),!1));if(!r)return console.warn(`[Construct] Call mapped function: map name '${e}' not found; call ignored`),n;let a=r.strMap.get(t.toLowerCase());if(!a){if(!r.defaultFunc)return console.warn(`[Construct] Call mapped function: no function associated with map '${e}' string '${t}'; call ignored (consider setting a default)`),n;a=r.defaultFunc,s=0}if(!a.IsEnabled())return n;if(0!==a.GetReturnType())return console.warn(`[Construct] Call mapped function: map '${e}' string '${t}' has a return type so cannot be called`),n;const o=i.GetEventSheetManager(),l=o.GetCurrentEvent(),h=l.GetSolModifiersIncludingParents(),c=0<h.length,u=(c&&(a.IsCopyPicked()?o.PushCopySol(h):o.PushCleanSol(h)),[]),_=o.FindFirstFunctionBlockParent(l);if(_){const p=_.GetFunctionParameters();for(let e=s,t=p.length;e<t;++e)u.push(p[e].GetValue())}const d=a.GetFunctionParameters();for(let e=u.length,t=d.length;e<t;++e)u.push(d[e].GetInitialValue());return i.IsDebugging()?this._DebugDoCallMappedFunction(o,a,u,c,h):this._DoCallMappedFunction(o,a,u,c,h)}}}{const Xf=self.C3;Xf.Plugins.System.Exps={int:function(e){return"string"==typeof e&&(e=parseInt(e,10),isNaN(e))&&(e=0),Math.floor(e)},float:function(e){return"string"==typeof e&&(e=parseFloat(e),isNaN(e))?0:e},str(e){return e.toString()},len(e){return"string"==typeof e?e.length:0},random(e,t){return void 0===t?this._runtime.Random()*e:this._runtime.Random()*(t-e)+e},choose(...e){const t=Math.floor(this._runtime.Random()*e.length);return e[t]},chooseindex(e,...t){return"number"!=typeof e&&(e=0),t[e=Xf.clamp(Math.floor(e),0,t.length-1)]},pi(){return Math.PI},infinity(){return 1/0},sqrt(e){return Math.sqrt(e)},abs(e){return Math.abs(e)},round(e){return Math.round(e)},roundtodp(e,t){t=Math.max(Math.floor(t),0);const s=Math.pow(10,t);return Math.round((e+Number.EPSILON)*s)/s},floor(e){return Math.floor(e)},ceil(e){return Math.ceil(e)},sign(e){return Math.sign(e)},sin(e){return Math.sin(Xf.toRadians(e))},cos(e){return Math.cos(Xf.toRadians(e))},tan(e){return Math.tan(Xf.toRadians(e))},asin(e){return Xf.toDegrees(Math.asin(e))},acos(e){return Xf.toDegrees(Math.acos(e))},atan(e){return Xf.toDegrees(Math.atan(e))},exp(e){return Math.exp(e)},ln(e){return Math.log(e)},log10(e){return Math.log10(e)},max(...s){let i=s[0];"number"!=typeof i&&(i=0);for(let t=1,e=s.length;t<e;++t){let e=s[t];"number"==typeof e&&i<e&&(i=e)}return i},min(...s){let i=s[0];"number"!=typeof i&&(i=0);for(let t=1,e=s.length;t<e;++t){let e=s[t];"number"==typeof e&&i>e&&(i=e)}return i},clamp(e,t,s){return Xf.clamp(e,t,s)},distance(e,t,s,i){return Xf.distanceTo(e,t,s,i)},angle(e,t,s,i){return Xf.toDegrees(Xf.angleTo(e,t,s,i))},lerp(e,t,s){return Xf.lerp(e,t,s)},unlerp(e,t,s){return Xf.unlerp(e,t,s)},qarp(e,t,s,i){return Xf.qarp(e,t,s,i)},cubic(e,t,s,i,n){return Xf.cubic(e,t,s,i,n)},cosp(e,t,s){return Xf.cosp(e,t,s)},anglediff(e,t){return Xf.toDegrees(Xf.angleDiff(Xf.toRadians(e),Xf.toRadians(t)))},anglelerp(e,t,s){return Xf.toDegrees(Xf.angleLerp(Xf.toRadians(e),Xf.toRadians(t),s))},anglerotate(e,t,s){return Xf.toDegrees(Xf.angleRotate(Xf.toRadians(e),Xf.toRadians(t),Xf.toRadians(s)))},setbit(e,t,s){return(e|=0)&~(1<<(t|=0))|(s=0!==s?1:0)<<t},togglebit(e,t){return(e|=0)^1<<(0|t)},getbit(e,t){return(e|=0)&1<<(0|t)?1:0},newline(){return"\n"},uppercase(e){return"string"==typeof e?e.toUpperCase():""},lowercase(e){return"string"==typeof e?e.toLowerCase():""},left(e,t){return"string"==typeof e?e.substr(0,t):""},mid(e,t,s){return"string"!=typeof e?"":s<0?e.substr(t):e.substr(t,s)},right(e,t){return"string"==typeof e?e.substr(Math.max(e.length-t,0)):""},trim(e){return"string"==typeof e?e.trim():""},tokenat(e,t,s){if("string"!=typeof e||"string"!=typeof s)return"";let i=e.split(s);return(t=Math.floor(t))<0||t>=i.length?"":i[t]},tokencount(e,t){return"string"==typeof e&&"string"==typeof t&&e.length?e.split(t).length:0},find(e,t){return"string"==typeof e&&"string"==typeof t?e.search(new RegExp(Xf.EscapeRegex(t),"i")):-1},findcase(e,t){return"string"==typeof e&&"string"==typeof t?e.search(new RegExp(Xf.EscapeRegex(t),"")):-1},replace(e,t,s){return"string"==typeof e&&"string"==typeof t&&"string"==typeof s?e.replace(new RegExp(Xf.EscapeRegex(t),"gi"),s):"string"==typeof e?e:""},stringsub(e,...s){let i=e;for(let e=0,t=s.length;e<t;++e)i=i.replaceAll(`{${e}}`,s[e].toString());return i},regexsearch(e,t,s){const i=this.GetRegex(t,s);return e?e.search(i):-1},regexreplace(e,t,s,i){const n=this.GetRegex(t,s);return e?e.replace(n,i):""},regexmatchcount(e,t,s){const i=this.GetRegexMatches(e.toString(),t,s);return i?i.length:0},regexmatchat(e,t,s,i){i=Math.floor(i);const n=this.GetRegexMatches(e.toString(),t,s);return!n||i<0||i>=n.length?"":n[i]},zeropad(e,t){let s=e<0?"-":"",i=t-(e=e<0?-e:e).toString().length;return(s+="0".repeat(Math.max(i,0)))+e.toString()},urlencode(e){return encodeURIComponent(e)},urldecode(e){return decodeURIComponent(e)},dt(){return this._runtime._GetDtFast()},wallclockdt(){return this._runtime.GetDt1()},timescale(){return this._runtime.GetTimeScale()},wallclocktime(){return(Date.now()-this._runtime.GetStartTime())/1e3},unixtime(){return Date.now()},time(){return this._runtime.GetGameTime()},tickcount(){return this._runtime.GetTickCount()},objectcount(){return this._runtime.GetObjectCount()},fps(){return this._runtime.GetFramesPerSecond()},cpuutilisation(){return this._runtime.GetMainThreadTime()},gpuutilisation(){return this._runtime.GetGPUUtilisation()},windowwidth(){return this._runtime.GetCanvasManager().GetDeviceWidth()},windowheight(){return this._runtime.GetCanvasManager().GetDeviceHeight()},originalwindowwidth(){return this._runtime.GetOriginalViewportWidth()},originalwindowheight(){return this._runtime.GetOriginalViewportHeight()},originalviewportwidth(){return this._runtime.GetOriginalViewportWidth()},originalviewportheight(){return this._runtime.GetOriginalViewportHeight()},scrollx(){return this._runtime.GetCurrentLayout().GetScrollX()},scrolly(){return this._runtime.GetCurrentLayout().GetScrollY()},layoutname(){return this._runtime.GetCurrentLayout().GetName()},layoutscale(){return this._runtime.GetCurrentLayout().GetScale()},layoutangle(){return Xf.toDegrees(this._runtime.GetCurrentLayout().GetAngle())},layoutwidth(){return this._runtime.GetCurrentLayout().GetWidth()},layoutheight(){return this._runtime.GetCurrentLayout().GetHeight()},vanishingpointx(){return 100*this._runtime.GetCurrentLayout().GetVanishingPointX()},vanishingpointy(){return 100*this._runtime.GetCurrentLayout().GetVanishingPointY()},viewportleft(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetViewport3D().getLeft():0},viewporttop(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetViewport3D().getTop():0},viewportright(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetViewport3D().getRight():0},viewportbottom(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetViewport3D().getBottom():0},viewportwidth(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetViewport3D().width():0},viewportheight(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetViewport3D().height():0},viewportmidx(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);if(t){const s=t.GetViewport3D();return(s.getLeft()+s.getRight())/2}return 0},viewportmidy(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);if(t){const s=t.GetViewport3D();return(s.getTop()+s.getBottom())/2}return 0},canvastolayerx(e,t,s){const i=this._runtime.GetCurrentLayout().GetLayer(e);return i?i.CanvasCssToLayer(t,s)[0]:0},canvastolayery(e,t,s){const i=this._runtime.GetCurrentLayout().GetLayer(e);return i?i.CanvasCssToLayer(t,s)[1]:0},layertocanvasx(e,t,s){const i=this._runtime.GetCurrentLayout().GetLayer(e);return i?i.LayerToCanvasCss(t,s)[0]:0},layertocanvasy(e,t,s){const i=this._runtime.GetCurrentLayout().GetLayer(e);return i?i.LayerToCanvasCss(t,s)[1]:0},layertolayerx(e,t,s,i){const n=this._runtime.GetCurrentLayout(),r=n.GetLayer(e),a=n.GetLayer(t);if(!r||!a||r===a)return s;const[o,l]=r.LayerToCanvasCss(s,i);return a.CanvasCssToLayer(o,l)[0]},layertolayery(e,t,s,i){const n=this._runtime.GetCurrentLayout(),r=n.GetLayer(e),a=n.GetLayer(t);if(!r||!a||r===a)return i;const[o,l]=r.LayerToCanvasCss(s,i);return a.CanvasCssToLayer(o,l)[1]},layerscale(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetOwnScale():0},layerangle(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?Xf.toDegrees(t.GetOwnAngle()):0},layeropacity(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?100*t.GetOpacity():0},layerscalerate(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetScaleRate():0},layerscrollx(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetScrollX():0},layerscrolly(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetScrollY():0},layerparallaxx(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?100*t.GetParallaxX():0},layerparallaxy(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?100*t.GetParallaxY():0},layerzelevation(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetZElevation():0},layerindex(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetIndex():-1},canvassnapshot(){const e=this._runtime.GetCanvasManager();return e?e.GetCanvasSnapshotUrl():""},loopindex(e){const t=this._loopStack;if(!t.IsInLoop())return 0;if(e){const s=t.FindByName(e);return s?s.GetIndex():0}return t.GetCurrent().GetIndex()},savestatejson(){return this._runtime.GetLastSaveJsonString()},callmapped(e,t,...s){const i=this._GetFunctionMap(e.toLowerCase(),!1);if(!i)return console.warn(`[Construct] Call mapped function: map name '${e}' not found; returning 0`),0;let n=i.strMap.get(t.toLowerCase());if(!n){if(!i.defaultFunc)return console.warn(`[Construct] Call mapped function: no function associated with map '${e}' string '${t}'; returning 0 (consider setting a default)`),0;n=i.defaultFunc}const r=n.GetReturnType(),a=n.GetDefaultReturnValue();if(0===r)return console.warn(`[Construct] Call mapped function: map '${e}' string '${t}' has no return type so cannot be called from an expression; returning 0`),0;if(!n.IsEnabled())return a;const o=this._runtime,l=o.GetEventSheetManager(),h=l.GetCurrentEvent(),c=h.GetSolModifiersIncludingParents(),u=0<c.length,_=(u&&(n.IsCopyPicked()?l.PushCopySol(c):l.PushCleanSol(c)),n.GetFunctionParameters());for(let e=s.length,t=_.length;e<t;++e)s.push(_[e].GetInitialValue());const d=n.GetEventBlock(),p=d.RunAsExpressionFunctionCall(d.GetSolModifiersIncludingParents(),n.IsCopyPicked(),r,a,...s);return u&&l.PopSol(c),p},loadingprogress(){return this._runtime.GetAssetManager().GetLoadProgress()},imageloadingprogress(){return this.GetImageLoadingProgress()},renderer(){return this._runtime.GetWebGPURenderer()?"webgpu":"webgl"},rendererdetail(){return this._runtime.GetWebGPURenderer()?this._runtime.GetWebGPURenderer().GetAdapterInfoString():this._runtime.GetWebGLRenderer().GetUnmaskedRenderer()},imagememoryusage(){let e=this._runtime.GetRenderer().GetEstimatedTextureMemoryUsage();return Math.round(100*e/1048576)/100},rgb(e,t,s){return Xf.PackRGB(e,t,s)},rgbex(e,t,s){return Xf.PackRGBEx(e/100,t/100,s/100)},rgba(e,t,s,i){return Xf.PackRGBAEx(e/100,t/100,s/100,i/100)},rgbex255(e,t,s){return Xf.PackRGBEx(e/255,t/255,s/255)},rgba255(e,t,s,i){return Xf.PackRGBAEx(e/255,t/255,s/255,i/255)},projectname(){return this._runtime.GetProjectName()},projectversion(){return this._runtime.GetProjectVersion()},currenteventsheetname(){return this._runtime.GetCurrentEvent().GetEventSheet().GetName()},currenteventnumber(){return this._runtime.GetCurrentEvent().GetDisplayNumber()}}}{const a=self.C3;a.Plugins.Sprite=class extends a.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{const d=self.C3,e=self.C3X,f=[],g=(d.Plugins.Sprite.Type=class extends d.SDKTypeBase{constructor(e){super(e),this._animations=e.GetAnimations()}Release(){d.clearArray(this._animations),super.Release()}OnCreate(){for(const e of this._animations)e.LoadAllAssets(this._runtime)}LoadTextures(t){const s={sampling:this._runtime.GetSampling()};return Promise.all(this._animations.map(e=>e.LoadAllTextures(t,s)))}ReleaseTextures(){for(const e of this._animations)e.ReleaseAllTextures()}OnDynamicTextureLoadComplete(){this._UpdateAllCurrentTexture()}_UpdateAllCurrentTexture(){for(const e of this._objectClass.instancesIncludingPendingCreate())e.GetSdkInstance()._UpdateCurrentTexture()}FinishCondition(e){d.Plugins.Sprite.FinishCollisionCondition(this,e)}BeforeRunAction(e){f.push({objectClass:null,createHierarchy:!1,instances:[]})}_SpawnPickInstance(e,t,s){const i=f.at(-1);i.objectClass=e,i.createHierarchy=s,i.instances.push(t)}AfterRunAction(e){const t=f.pop(),s=t.objectClass,i=t.createHierarchy;if(s){const n=new Map;for(const r of t.instances)r.CollectInstancesToPick(n,s,i);for(const[a,o]of n)a.GetCurrentSol().SetSetPicked(o)}}_AddAnimation(e){const t=this.GetObjectClass().AddAnimation(e),s=this.GetRuntime(),i=t.GetFrameAt(0);return i.GetImageInfo().LoadStaticTexture(s.GetRenderer(),{sampling:s.GetSampling()}).then(()=>this._UpdateAllCurrentTexture()),t}_RemoveAnimation(e){for(const t of this._objectClass.instancesIncludingPendingCreate())t.GetSdkInstance()._OnAnimationRemoved(e);this.GetObjectClass().RemoveAnimation(e)}_AddAnimationFrame(e,t){const s=this._objectClass.GetAnimationByName(e);if(!s)throw new Error(`cannot find animation name '${e}'`);let i=s.FrameTagOrIndexToIndex(t);i<0&&(i+=s.GetFrameCount()+1);const n=d.AnimationFrameInfo.CreateDynamic(this.GetRuntime()),r=(s.InsertFrameAt(n,i),this.GetRuntime());n.GetImageInfo().LoadStaticTexture(r.GetRenderer(),{sampling:r.GetSampling()}).then(()=>this._UpdateAllCurrentTexture());for(const a of this._objectClass.instancesIncludingPendingCreate())a.GetSdkInstance()._OnAnimationFramesChanged();return n}_RemoveAnimationFrame(e,t){const s=this._objectClass.GetAnimationByName(e);if(!s)throw new Error(`cannot find animation name '${e}'`);if(1===s.GetFrameCount())throw new Error(`cannot remove last frame from animation '${e}'`);let i=s.FrameTagOrIndexToIndex(t);i<0&&(i+=s.GetFrameCount()),s.RemoveFrameAt(i);for(const n of this._objectClass.instancesIncludingPendingCreate())n.GetSdkInstance()._OnAnimationFramesChanged()}GetScriptInterfaceClass(){return self.ISpriteObjectType}},new WeakMap);self.ISpriteObjectType=class extends self.IObjectClass{constructor(e){super(e),g.set(this,e.GetSdkType())}getAnimation(t){e.RequireString(t);const s=g.get(this).GetObjectClass().GetAnimationByName(t);return s?s.GetIAnimation():null}getAllAnimations(){return g.get(this).GetObjectClass().GetAllAnimations().map(e=>e.GetIAnimation())}addAnimation(t){return e.RequireString(t),g.get(this)._AddAnimation(t).GetIAnimation()}removeAnimation(t){e.RequireString(t),g.get(this)._RemoveAnimation(t)}addAnimationFrame(t,s){if(e.RequireString(t),"number"!=typeof s&&"string"!=typeof s)throw new TypeError("invalid insert location");return g.get(this)._AddAnimationFrame(t,s).GetIAnimationFrame()}removeAnimationFrame(t,s){if(e.RequireString(t),"number"!=typeof s&&"string"!=typeof s)throw new TypeError("invalid insert location");g.get(this)._RemoveAnimationFrame(t,s)}}}{const ea=self.C3,fa=self.C3X,ga=0,ha=1,ia=2,ja=3,ka=ea.New(ea.Rect),la=ea.New(ea.Quad),ma=ea.New(ea.Vector2),na=1,oa=2,pa=4,qa=(ea.Plugins.Sprite.Instance=class extends ea.SDKWorldInstanceBase{constructor(e,t){super(e);let s=!0,i="",n=0,r=!0;t&&(s=!!t[ga],i=t[ha],n=t[ia],r=t[ja]),this._currentAnimation=this._objectClass.GetAnimationByName(i)||this._objectClass.GetAnimations()[0],this._currentFrameIndex=ea.clamp(n,0,this._currentAnimation.GetFrameCount()-1),this._currentAnimationFrame=this._currentAnimation.GetFrameAt(this._currentFrameIndex);const a=this._currentAnimationFrame.GetImageInfo(),o=(this._currentTexture=a.GetTexture(),this._currentRcTex=a.GetTexRect(),this._currentQuadTex=a.GetTexQuad(),this.HandleRendererContextLoss(),e.SetFlag(oa,!0),e.SetFlag(na,0<=this._currentAnimation.GetSpeed()),this._currentAnimationSpeed=Math.abs(this._currentAnimation.GetSpeed()),this._currentAnimationRepeatTo=this._currentAnimation.GetRepeatTo(),this._animationTimer=ea.New(ea.KahanSum),this._frameStartTime=0,this._animationRepeats=0,this._animTriggerName="",this._changeAnimFrameIndex=-1,this._changeAnimationName="",this._changeAnimationFrom=0,this.GetWorldInfo());this._bquadRef=o.GetBoundingQuad(),o.SetVisible(s),o.SetCollisionEnabled(r),o.SetOriginX(this._currentAnimationFrame.GetOriginX()),o.SetOriginY(this._currentAnimationFrame.GetOriginY()),o.SetSourceCollisionPoly(this._currentAnimationFrame.GetCollisionPoly()),o.SetBboxChanged(),1===this._objectClass.GetAnimationCount()&&1===this._objectClass.GetAnimations()[0].GetFrameCount()||0===this._currentAnimationSpeed||this._StartTicking()}Release(){this._currentAnimation=null,this._currentAnimationFrame=null,this._currentTexture=null,this._animationTimer=null,super.Release()}GetCurrentImageInfo(){return this._currentAnimationFrame.GetImageInfo()}IsOriginalSizeKnown(){return!0}OnRendererContextLost(){this._currentTexture=null}OnRendererContextRestored(){this._UpdateCurrentTexture()}Draw(e){const t=this._currentTexture;if(null!==t){e.SetTexture(t);const s=this.GetWorldInfo();s.HasMesh()?this._DrawMesh(s,e):this._DrawStandard(s,e)}}_DrawStandard(e,t){let s=this._bquadRef;this._runtime.IsPixelRoundingEnabled()&&(s=e.PixelRoundQuad(s)),t.Quad4(s,this._currentQuadTex)}_DrawMesh(t,e){const s=t.GetTransformedMesh();if(t.IsMeshChanged()){t.CalculateBbox(ka,la,!1);let e=la;this._runtime.IsPixelRoundingEnabled()&&(e=t.PixelRoundQuad(e)),s.CalculateTransformedMesh(t.GetSourceMesh(),e,this._currentQuadTex),t.SetMeshChanged(!1)}s.Draw(e)}GetAnimationTime(){return this._animationTimer.Get()}IsAnimationPlaying(){return this._inst.GetFlag(oa)}SetAnimationPlaying(e){this._inst.SetFlag(oa,e)}IsPlayingForwards(){return this._inst.GetFlag(na)}SetPlayingForwards(e){this._inst.SetFlag(na,e)}IsInAnimationTrigger(){return this._inst.GetFlag(pa)}SetInAnimationTrigger(e){this._inst.SetFlag(pa,e)}Tick(){this._changeAnimationName&&this._DoChangeAnimation(),0<=this._changeAnimFrameIndex&&this._DoChangeAnimFrame();const e=this._currentAnimationSpeed;if(this.IsAnimationPlaying()&&0!==e){const t=this._runtime.GetDt(this._inst),s=(this._animationTimer.Add(t),this.GetAnimationTime()),i=this._currentAnimationFrame,n=i.GetDuration()/e;if(!(s<this._frameStartTime+n)){const r=this._currentAnimation,a=this._currentAnimationRepeatTo,o=r.GetFrameCount(),l=r.GetRepeatCount(),h=r.IsLooping(),c=r.IsPingPong(),u=(this.IsPlayingForwards()?this._currentFrameIndex++:this._currentFrameIndex--,this._frameStartTime+=n,this._currentFrameIndex>=o&&(c?(this.SetPlayingForwards(!1),this._currentFrameIndex=o-2):!h&&(this._animationRepeats++,this._animationRepeats>=l)?this._FinishAnimation(!1):this._currentFrameIndex=a),this._currentFrameIndex<0&&(c?(this._currentFrameIndex=1,this.SetPlayingForwards(!0),h||(this._animationRepeats++,this._animationRepeats>=l&&this._FinishAnimation(!0))):!h&&(this._animationRepeats++,this._animationRepeats>=l)?this._FinishAnimation(!0):this._currentFrameIndex=a),this._currentFrameIndex=ea.clamp(this._currentFrameIndex,0,o-1),r.GetFrameAt(this._currentFrameIndex));s>this._frameStartTime+u.GetDuration()/e&&(this._frameStartTime=s),this._OnFrameChanged(i,u)}}else this._StopTicking()}_FinishAnimation(e){this._currentFrameIndex=e?0:this._currentAnimation.GetFrameCount()-1,this.SetAnimationPlaying(!1),this._animTriggerName=this._currentAnimation.GetName(),this.SetInAnimationTrigger(!0),this.DispatchScriptEvent("animationend",!1,{animationName:this._animTriggerName}),this.Trigger(ea.Plugins.Sprite.Cnds.OnAnyAnimFinished),this.Trigger(ea.Plugins.Sprite.Cnds.OnAnimFinished),this.SetInAnimationTrigger(!1),this._animationRepeats=0}_OnFrameChanged(s,i,e){if(s!==i){const t=this.GetWorldInfo(),n=s.GetImageInfo(),r=i.GetImageInfo(),a=n.GetWidth(),o=n.GetHeight(),l=r.GetWidth(),h=r.GetHeight(),c=(e&&e.onFrameChange?e.onFrameChange(t,a,o,l,h):(a!==l&&t.SetWidth(t.GetWidth()*(l/a)),o!==h&&t.SetHeight(t.GetHeight()*(h/o))),t.SetOriginX(i.GetOriginX()),t.SetOriginY(i.GetOriginY()),t.SetSourceCollisionPoly(i.GetCollisionPoly()),t.SetBboxChanged(),this._currentAnimationFrame=i,this._currentTexture=r.GetTexture(),this._currentRcTex=r.GetTexRect(),this._currentQuadTex=r.GetTexQuad(),this.GetInstance().GetBehaviorInstances());for(let e=0,t=c.length;e<t;++e)c[e].OnSpriteFrameChanged(s,i);this.DispatchScriptEvent("framechange",!1,{animationName:this._currentAnimation.GetName(),animationFrame:this._currentFrameIndex}),this.Trigger(ea.Plugins.Sprite.Cnds.OnFrameChanged),this._runtime.UpdateRender()}}_StartAnim(e){this.SetAnimationPlaying(!0),this._frameStartTime=this.GetAnimationTime(),1===e&&0!==this._currentFrameIndex&&(this._changeAnimFrameIndex=0,this.IsInAnimationTrigger()||this._DoChangeAnimFrame()),this._StartTicking()}_SetAnim(e,t,s){this._changeAnimationName=e,this._changeAnimationFrom=t,this._StartTicking(),!s&&this.IsInAnimationTrigger()||this._DoChangeAnimation()}_GetCurrentAnimation(){return this._currentAnimation}_GetCurrentAnimationName(){return this._changeAnimationName||this._currentAnimation.GetName()}_OnAnimationRemoved(e){ea.equalsNoCase(e,this._GetCurrentAnimationName())&&this._SetAnim(this._objectClass.GetFirstAnimation().GetName(),1,!0)}_SetAnimFrame(e){if("string"==typeof e)if(String(Number(e))===e)e=Number(e);else{const t=this._objectClass.GetAnimationByName(this._GetCurrentAnimationName());if(!t)return;if(-1===(e=t.GetFrameIndexByTag(e)))return}isFinite(e)&&(this._changeAnimFrameIndex=e,this.IsInAnimationTrigger()||this._DoChangeAnimFrame())}_OnAnimationFramesChanged(){if(!this._changeAnimationName&&-1===this._changeAnimFrameIndex){const e=this._currentAnimationFrame,t=this._currentAnimation.GetFrameAt(ea.clamp(this._currentFrameIndex,0,this._currentAnimation.GetFrameCount()-1));e!==t&&this._OnFrameChanged(e,t),1<this._currentAnimation.GetFrameCount()&&0<this._currentAnimationSpeed&&this._StartTicking()}}_GetAnimFrame(){return this._currentFrameIndex}_GetAnimFrameTag(){return this._currentAnimationFrame.GetTag()}_SetAnimSpeed(e){this._currentAnimationSpeed=Math.abs(e),this.SetPlayingForwards(0<=e),0<this._currentAnimationSpeed&&this._StartTicking()}_GetAnimSpeed(){return this.IsPlayingForwards()?this._currentAnimationSpeed:-this._currentAnimationSpeed}_SetAnimRepeatToFrame(e){"string"==typeof e&&-1===(e=this._currentAnimation.GetFrameIndexByTag(e))||(e=ea.clamp(Math.floor(e),0,this._currentAnimation.GetFrameCount()-1),this._currentAnimationRepeatTo=e)}_GetAnimRepeatToFrame(){return this._currentAnimationRepeatTo}_DoChangeAnimation(e){const t=this._currentAnimationFrame,s=this._objectClass.GetAnimationByName(this._changeAnimationName);if(this._changeAnimationName="",s&&(s!==this._currentAnimation||!this.IsAnimationPlaying())){this._currentAnimation=s,this.SetPlayingForwards(0<=s.GetSpeed()),this._currentAnimationSpeed=Math.abs(s.GetSpeed()),this._currentAnimationRepeatTo=s.GetRepeatTo(),this._currentFrameIndex=ea.clamp(this._currentFrameIndex,0,this._currentAnimation.GetFrameCount()-1),1===this._changeAnimationFrom&&(this._currentFrameIndex=0),this.SetAnimationPlaying(!0),this._frameStartTime=this.GetAnimationTime();const i=this._currentAnimation.GetFrameAt(this._currentFrameIndex);this._OnFrameChanged(t,i,e)}}_DoChangeAnimFrame(e){const t=this._currentAnimationFrame,s=this._currentFrameIndex;if(this._currentFrameIndex=ea.clamp(Math.floor(this._changeAnimFrameIndex),0,this._currentAnimation.GetFrameCount()-1),this._changeAnimFrameIndex=-1,e||s!==this._currentFrameIndex){const i=this._currentAnimation.GetFrameAt(this._currentFrameIndex);this._OnFrameChanged(t,i),this._frameStartTime=this.GetAnimationTime()}}_UpdateCurrentTexture(){const e=this._currentAnimationFrame.GetImageInfo();this._currentTexture=e.GetTexture(),this._currentRcTex=e.GetTexRect(),this._currentQuadTex=e.GetTexQuad(),this.GetWorldInfo().SetMeshChanged(!0)}GetTexture(){return this._currentTexture}GetTexRect(){return this._currentRcTex}GetTexQuad(){return this._currentQuadTex}GetImagePointCount(){return this._currentAnimationFrame.GetImagePointCount()}GetImagePoint(e){let t=this._currentAnimationFrame,s=this.GetWorldInfo(),i=null;if("string"==typeof e)i=t.GetImagePointByName(e);else{if("number"!=typeof e)throw new TypeError("expected string or number");i=t.GetImagePointByIndex(e-1)}let n=s.GetTotalZElevation();if(!i)return[s.GetX(),s.GetY(),n];if(ma.copy(i.GetVec2()),s.HasMesh()){const[r,a,o]=s.GetSourceMesh().TransformPoint(ma.getX(),ma.getY());ma.set(r,a),n+=o}return ma.offset(-t.GetOriginX(),-t.GetOriginY()),ma.scale(s.GetWidth(),s.GetHeight()),ma.rotate(s.GetAngle()),ma.offset(s.GetX(),s.GetY()),[ma.getX(),ma.getY(),n]}GetCollisionPolyPointCount(){return this.GetWorldInfo().GetTransformedCollisionPoly().pointCount()}GetCollisionPolyPoint(e){e=Math.floor(e);const t=this.GetWorldInfo(),s=t.GetTransformedCollisionPoly(),i=s.pointCount();if((e=e===i?0:e)<0||i<=e)return[0,0];const n=s.pointsArr();return[n[2*e+0]+t.GetX(),n[2*e+1]+t.GetY()]}GetDebuggerProperties(){const t=ea.Plugins.Sprite.Acts,e="plugins.sprite.debugger.animation-properties";return[{title:e+".title",properties:[{name:e+".current-animation",value:this._currentAnimation.GetName(),onedit:e=>this.CallAction(t.SetAnim,e,0)},{name:e+".current-frame",value:this._currentFrameIndex,onedit:e=>this.CallAction(t.SetAnimFrame,e)},{name:e+".is-playing",value:this.IsAnimationPlaying(),onedit:e=>e?this.CallAction(t.StartAnim,0):this.CallAction(t.StopAnim)},{name:e+".speed",value:this._currentAnimationSpeed,onedit:e=>this.CallAction(t.SetAnimSpeed,e)},{name:e+".repeats",value:this._animationRepeats,onedit:e=>this._animationRepeats=e}]}]}SaveToJson(){const e={a:this._currentAnimation.GetSID()},t=(0!==this._frameStartTime&&(e.fs=this._frameStartTime),this.GetAnimationTime()),s=(0!==t&&(e.at=t),0!==this._currentFrameIndex&&(e.f=this._currentFrameIndex),0!==this._currentAnimationSpeed&&(e.cas=this._currentAnimationSpeed),1!==this._animationRepeats&&(e.ar=this._animationRepeats),0!==this._currentAnimationRepeatTo&&(e.rt=this._currentAnimationRepeatTo),this.IsAnimationPlaying()||(e.ap=this.IsAnimationPlaying()),this.IsPlayingForwards()||(e.af=this.IsPlayingForwards()),this.GetWorldInfo());return s.IsCollisionEnabled()&&(e.ce=s.IsCollisionEnabled()),e}LoadFromJson(e){const t=this.GetObjectClass().GetAnimationBySID(e.a),s=(t&&(this._currentAnimation=t),this._frameStartTime=e.hasOwnProperty("fs")?e.fs:0,this._animationTimer.Set(e.hasOwnProperty("at")?e.at:0),e.hasOwnProperty("f")?e.f:0),i=(this._currentFrameIndex=ea.clamp(s,0,this._currentAnimation.GetFrameCount()-1),this._currentAnimationSpeed=e.hasOwnProperty("cas")?e.cas:0,this._animationRepeats=e.hasOwnProperty("ar")?e.ar:1,e.hasOwnProperty("rt")?e.rt:0),n=(this._currentAnimationRepeatTo=ea.clamp(i,0,this._currentAnimation.GetFrameCount()-1),this.SetAnimationPlaying(!e.hasOwnProperty("ap")||!!e.ap),this.SetPlayingForwards(!e.hasOwnProperty("af")||!!e.af),this._currentAnimation.GetFrameAt(this._currentFrameIndex)),r=(this._currentAnimationFrame=n,this._UpdateCurrentTexture(),this.GetWorldInfo());r.SetOriginX(n.GetOriginX()),r.SetOriginY(n.GetOriginY()),r.SetSourceCollisionPoly(n.GetCollisionPoly()),r.SetCollisionEnabled(!!e.ce),this.IsAnimationPlaying()&&this._StartTicking()}GetPropertyValueByIndex(e){const t=this.GetWorldInfo();switch(e){case ja:return t.IsCollisionEnabled();case ia:return ea.clamp(this._currentFrameIndex,0,this._currentAnimation.GetFrameCount()-1);case ha:return this._currentAnimation.GetName()}}SetPropertyValueByIndex(e,t,s){const i=this.GetWorldInfo();switch(e){case ja:i.SetCollisionEnabled(!!t);break;case ia:{this.SetAnimationPlaying(!1);const n=this._currentAnimation.GetFrameCount()-1,r=t=ea.clamp(t,0,n),a=this._currentAnimation.GetFrameAt(this._currentFrameIndex),o=this._currentAnimation.GetFrameAt(r);this._OnFrameChanged(a,o,s),this._currentFrameIndex=ea.clamp(r,0,n);break}case ha:{this._changeAnimationName=t,this._DoChangeAnimation(s);const l=this._currentAnimation.GetFrameCount();1<l&&0<this._currentAnimation.GetSpeed()?this._StartTicking():this._StopTicking();break}}}GetScriptInterfaceClass(){return self.ISpriteInstance}},new WeakMap),ra=new Map([["current-frame",0],["beginning",1]]);self.ISpriteInstance=class extends self.IWorldInstance{constructor(){super(),qa.set(this,self.IInstance._GetInitInst().GetSdkInstance())}getImagePointCount(){return qa.get(this).GetImagePointCount()}getImagePointX(e){return this.getImagePoint(e)[0]}getImagePointY(e){return this.getImagePoint(e)[1]}getImagePointZ(e){return this.getImagePoint(e)[2]}getImagePoint(e){if("string"!=typeof e&&"number"!=typeof e)throw new TypeError("expected string or number");return qa.get(this).GetImagePoint(e)}getPolyPointCount(){return qa.get(this).GetCollisionPolyPointCount()}getPolyPointX(e){return fa.RequireFiniteNumber(e),qa.get(this).GetCollisionPolyPoint(e)[0]}getPolyPointY(e){return fa.RequireFiniteNumber(e),qa.get(this).GetCollisionPolyPoint(e)[1]}getPolyPoint(e){return fa.RequireFiniteNumber(e),qa.get(this).GetCollisionPolyPoint(e)}stopAnimation(){qa.get(this).SetAnimationPlaying(!1)}startAnimation(e="current-frame"){fa.RequireString(e);const t=ra.get(e);if(void 0===t)throw new Error("invalid mode");qa.get(this)._StartAnim(t)}setAnimation(e,t="beginning"){fa.RequireString(e),fa.RequireString(t);const s=ra.get(t);if(void 0===s)throw new Error("invalid mode");const i=qa.get(this);if(!i.GetObjectClass().GetAnimationByName(e))throw new Error(`animation name "${e}" does not exist`);i._SetAnim(e,s)}getAnimation(e){fa.RequireString(e);const t=qa.get(this).GetObjectClass().GetAnimationByName(e);return t?t.GetIAnimation():null}get animation(){return qa.get(this)._GetCurrentAnimation().GetIAnimation()}get animationName(){return qa.get(this)._GetCurrentAnimationName()}set animationFrame(e){fa.RequireFiniteNumber(e),qa.get(this)._SetAnimFrame(e)}get animationFrame(){return qa.get(this)._GetAnimFrame()}set animationFrameTag(e){fa.RequireString(e),qa.get(this)._SetAnimFrame(e)}get animationFrameTag(){return qa.get(this)._GetAnimFrameTag()}set animationSpeed(e){fa.RequireFiniteNumber(e),qa.get(this)._SetAnimSpeed(e)}get animationSpeed(){return qa.get(this)._GetAnimSpeed()}set animationRepeatToFrame(e){fa.RequireFiniteNumber(e),qa.get(this)._SetAnimRepeatToFrame(e)}get animationRepeatToFrame(){return qa.get(this)._GetAnimRepeatToFrame()}get imageWidth(){return qa.get(this).GetCurrentImageInfo().GetWidth()}get imageHeight(){return qa.get(this).GetCurrentImageInfo().GetHeight()}getImageSize(){const e=qa.get(this).GetCurrentImageInfo();return[e.GetWidth(),e.GetHeight()]}async replaceCurrentAnimationFrame(e){fa.RequireInstanceOf(e,Blob);const t=qa.get(this),s=t.GetRuntime(),i=t.GetCurrentImageInfo(),n=ea.New(ea.ImageInfo);if(n.LoadDynamicBlobAsset(s,e),await n.LoadStaticTexture(s.GetRenderer(),{sampling:s.GetSampling()}),t.WasReleased())n.Release();else{i.ReplaceWith(n);const r=t.GetSdkType();r._UpdateAllCurrentTexture(),r.GetObjectClass().Dispatcher().dispatchEvent(new ea.Event("animationframeimagechange")),s.UpdateRender()}}setSolidCollisionFilter(e,t){fa.RequireString(t),qa.get(this).GetWorldInfo().SetSolidCollisionFilter(!!e,t)}}}{const Vb=self.C3;Vb.Plugins.Sprite.Cnds={IsAnimPlaying(e){return Vb.equalsNoCase(this._GetCurrentAnimationName(),e)},CompareFrame(e,t){return Vb.compare(this._currentFrameIndex,e,t)},CompareFrameTag(e,t){if("string"!=typeof t)return!1;const s=this._currentAnimationFrame.GetTag();return Vb.compare(s.toLowerCase(),e,t.toLowerCase())},CompareAnimSpeed(e,t){return Vb.compare(this._GetAnimSpeed(),e,t)},OnAnimFinished(e){return Vb.equalsNoCase(this._animTriggerName,e)},OnAnyAnimFinished(){return!0},OnFrameChanged(){return!0},IsMirrored(){return this.GetWorldInfo().GetWidth()<0},IsFlipped(){return this.GetWorldInfo().GetHeight()<0},OnURLLoaded(){return!0},OnURLFailed(){return!0},IsCollisionEnabled(){return this.GetWorldInfo().IsCollisionEnabled()}}}{const d1=self.C3;d1.Plugins.Sprite.Acts={Spawn(e,t,s,i,n){if(e&&t){const[r,a]=this.GetImagePoint(s),o=this._runtime.CreateInstance(e,t,r,a,i,n);if(o){if(i&&t.SortAndAddInstancesByZIndex(o),e.GetPlugin().IsRotatable()){const h=o.GetWorldInfo();h.SetAngle(this.GetWorldInfo().GetAngle()),h.SetBboxChanged()}const l=this._runtime.GetEventSheetManager();l.BlockFlushingInstances(!0),o._TriggerOnCreatedOnSelfAndRelated(),l.BlockFlushingInstances(!1),e!==this._runtime.GetCurrentAction().GetObjectClass()&&this._sdkType._SpawnPickInstance(e,o,i)}}},StopAnim(){this.SetAnimationPlaying(!1)},StartAnim(e){this._StartAnim(e)},SetAnim(e,t){this._SetAnim(e,t)},SetAnimFrame(e){this._SetAnimFrame(e)},SetAnimSpeed(e){this._SetAnimSpeed(e)},SetAnimRepeatToFrame(e){this._SetAnimRepeatToFrame(e)},AddRemoveAnimation(t,e){try{0===t?this.GetSdkType()._AddAnimation(e):this.GetSdkType()._RemoveAnimation(e)}catch(e){console.error(`[Construct] Error ${0===t?"adding":"removing"} animation: `,e)}},AddRemoveAnimationFrame(t,e,s){try{0===t?this.GetSdkType()._AddAnimationFrame(e,s):this.GetSdkType()._RemoveAnimationFrame(e,s)}catch(e){console.error(`[Construct] Error ${0===t?"adding":"removing"} animation frame: `,e)}},SetMirrored(e){const t=this.GetWorldInfo(),s=t.GetWidth(),i=Math.abs(s)*(0===e?-1:1);s!==i&&(t.SetWidth(i),t.SetBboxChanged())},SetFlipped(e){const t=this.GetWorldInfo(),s=t.GetHeight(),i=Math.abs(s)*(0===e?-1:1);s!==i&&(t.SetHeight(i),t.SetBboxChanged())},SetScale(e){const t=this._currentAnimationFrame,s=t.GetImageInfo(),i=this.GetWorldInfo(),n=i.GetWidth()<0?-1:1,r=i.GetHeight()<0?-1:1,a=s.GetWidth()*e*n,o=s.GetHeight()*e*r;i.GetWidth()===a&&i.GetHeight()===o||(i.SetSize(a,o),i.SetBboxChanged())},async LoadURL(e,t,s){const i=this._currentAnimationFrame,n=i.GetImageInfo(),r=this.GetWorldInfo(),a=this._runtime,o=this._sdkType;if(n.GetURL()===e)0===t&&(r.SetSize(n.GetWidth(),n.GetHeight()),r.SetBboxChanged()),this.Trigger(d1.Plugins.Sprite.Cnds.OnURLLoaded);else{const l=d1.New(d1.ImageInfo);try{if(await l.LoadDynamicAsset(a,e),!l.IsLoaded())throw new Error("image failed to load");if(this.WasReleased())return void l.Release();await l.LoadStaticTexture(a.GetRenderer(),{sampling:a.GetSampling()})}catch(e){return console.error("Load image from URL failed: ",e),void(this.WasReleased()||this.Trigger(d1.Plugins.Sprite.Cnds.OnURLFailed))}this.WasReleased()?l.Release():(n.ReplaceWith(l),o._UpdateAllCurrentTexture(),o.GetObjectClass().Dispatcher().dispatchEvent(new d1.Event("animationframeimagechange")),a.UpdateRender(),0===t&&(r.SetSize(n.GetWidth(),n.GetHeight()),r.SetBboxChanged()),await this.TriggerAsync(d1.Plugins.Sprite.Cnds.OnURLLoaded))}},SetCollisions(e){this.GetWorldInfo().SetCollisionEnabled(e)},SetSolidCollisionFilter(e,t){this.GetWorldInfo().SetSolidCollisionFilter(0===e,t)},SetEffect(e){this.GetWorldInfo().SetBlendMode(e),this._runtime.UpdateRender()}}}{const dc=self.C3;dc.Plugins.Sprite.Exps={AnimationFrame(){return this._GetAnimFrame()},AnimationFrameTag(){return this._GetAnimFrameTag()},AnimationFrameCount(){return this._currentAnimation.GetFrameCount()},AnimationName(){return this._currentAnimation.GetName()},AnimationSpeed(){return this._GetAnimSpeed()},OriginalAnimationSpeed(){return this._currentAnimation.GetSpeed()},ImagePointX(e){return this.GetImagePoint(e)[0]},ImagePointY(e){return this.GetImagePoint(e)[1]},ImagePointZ(e){return this.GetImagePoint(e)[2]},ImagePointCount(){return this.GetImagePointCount()},ImageWidth(){return this.GetCurrentImageInfo().GetWidth()},ImageHeight(){return this.GetCurrentImageInfo().GetHeight()},PolyPointXAt(e){return this.GetCollisionPolyPoint(e)[0]},PolyPointYAt(e){return this.GetCollisionPolyPoint(e)[1]},PolyPointCount(){return this.GetCollisionPolyPointCount()}}}{const a=self.C3,b=[];a.Plugins.Audio=class extends a.SDKPluginBase{constructor(e){super(e)}_AddActionPromise(e){b.push(e)}static async WaitForAllActionPromises(){await Promise.all(b),a.clearArray(b)}Release(){super.Release()}}}{let GetAudioSdkInstance2=function(){return e.GetSingleGlobalInstance().GetSdkInstance()},GetAudioDOMInterface2=function(){if(self.C3Audio_DOMInterface)return self.C3Audio_DOMInterface;throw new Error("audio scripting API cannot be used here - make sure the project is using DOM mode, not worker mode")};GetAudioSdkInstance=GetAudioSdkInstance2,GetAudioDOMInterface=GetAudioDOMInterface2;const f=self.C3,g=self.C3X;f.Plugins.Audio.Type=class extends f.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}GetScriptInterfaceClass(){return self.IAudioObjectType}};let e=null;self.IAudioObjectType=class extends self.IObjectClass{constructor(t){super(t),e=t}get audioContext(){return GetAudioDOMInterface2().GetAudioContextExtern()}get destinationNode(){return GetAudioDOMInterface2().GetDestinationNodeExtern()}get isSilent(){return GetAudioSdkInstance2()._IsSilent()}set isSilent(e){GetAudioSdkInstance2()._SetSilent(e)}get masterVolume(){return GetAudioSdkInstance2()._GetMasterVolume()}set masterVolume(e){g.RequireFiniteNumber(e),GetAudioSdkInstance2()._SetMasterVolume(e)}stopAll(){GetAudioSdkInstance2()._StopAll()}}}{const o=self.C3,p="audio",q=["interactive","balanced","playback"];o.Plugins.Audio.Instance=class extends o.SDKInstanceBase{constructor(e,t){super(e,p),this._nextPlayTime=0,this._triggerTags=[],this._enableMultiTags=!0,this._timeScaleMode=0,this._saveLoadMode=0,this._playInBackground=!1,this._panningModel=1,this._distanceModel=1,this._listenerPos=[this._runtime.GetViewportWidth()/2,this._runtime.GetViewportHeight()/2,600],this._listenerForwardVec=[0,0,-1],this._listenerUpVec=[0,1,0],this._referenceDistance=600,this._maxDistance=1e4,this._rolloffFactor=1,this._listenerInst=null,this._loadListenerUid=-1,this._masterVolume=1,this._isSilent=!1,this._sampleRate=0,this._audioContextState="suspended",this._outputLatency=0,this._effectCount=new Map,this._preloadTotal=0,this._preloadCount=0,this._bufferMetadata=new Map,this._remoteUrls=new Map;let s="interactive";t&&(this._timeScaleMode=t[0],this._saveLoadMode=t[1],this._playInBackground=t[2],s=q[t[3]],this._enableMultiTags=t[4],this._panningModel=t[5],this._distanceModel=t[6],this._listenerPos[2]=t[7],this._referenceDistance=t[8],this._maxDistance=t[9],this._rolloffFactor=t[10]),this._lastAIState=[],this._lastFxState=[],this._lastAnalysersData=[],this.AddDOMMessageHandlers([["state",e=>this._OnUpdateState(e)],["audiocontext-state",e=>this._OnAudioContextStateChanged(e)],["fxstate",e=>this._OnUpdateFxState(e)],["trigger",e=>this._OnTrigger(e)],["buffer-metadata",e=>this._OnBufferMetadata(e)]]);const i=this.GetRuntime().Dispatcher(),n=(this._disposables=new o.CompositeDisposable(o.Disposable.From(i,"instancedestroy",e=>this._OnInstanceDestroyed(e.instance)),o.Disposable.From(i,"afterload",()=>this._OnAfterLoad()),o.Disposable.From(i,"suspend",()=>this._OnSuspend()),o.Disposable.From(i,"resume",()=>this._OnResume())),this._runtime.GetExportType()),r="Safari"===o.Platform.Browser,a=this._runtime.IsiOSWebView()||"macos-wkwebview"===n,l=this._runtime.GetAssetManager().IsFileProtocol(),h="playable-ad-single-file"===this._runtime.GetExportType(),c=r||a||l||h;this._runtime.AddLoadPromise(this.PostToDOMAsync("create-audio-context",{preloadList:this._runtime.GetAssetManager().GetAudioToPreload().map(e=>({originalUrl:e.originalUrl,url:e.url,type:e.type,fileSize:e.fileSize})),timeScaleMode:this._timeScaleMode,latencyHint:s,panningModel:this._panningModel,distanceModel:this._distanceModel,refDistance:this._referenceDistance,maxDistance:this._maxDistance,rolloffFactor:this._rolloffFactor,listenerPos:this._listenerPos,usePlayMusicAsSoundWorkaround:c}).then(e=>{this._sampleRate=e.sampleRate,this._audioContextState=e.audioContextState,this._outputLatency=e.outputLatency})),this._StartTicking()}Release(){this._listenerInst=null,super.Release()}_SplitTags(e){return this._enableMultiTags?e.split(" ").filter(e=>!!e):e?[e]:[]}_MatchTagLists(t,e){for(const s of e){let e=!1;for(const i of t)if(o.equalsNoCase(i,s)){e=!0;break}if(!e)return!1}return!0}_MatchTagListToStr(e,t){return this._MatchTagLists(e,this._SplitTags(t))}_AddActionPromise(e){this.GetPlugin()._AddActionPromise(e)}_OnInstanceDestroyed(e){this._listenerInst===e&&(this._listenerInst=null)}DbToLinearNoCap(e){return Math.pow(10,e/20)}DbToLinear(e){const t=this.DbToLinearNoCap(e);return isFinite(t)?Math.max(Math.min(t,1),0):0}LinearToDbNoCap(e){return Math.log(e)/Math.log(10)*20}LinearToDb(e){return this.LinearToDbNoCap(Math.max(Math.min(e,1),0))}_OnSuspend(){this._playInBackground||this.PostToDOM("set-suspended",{isSuspended:!0})}_OnResume(){this._playInBackground||this.PostToDOM("set-suspended",{isSuspended:!1})}_OnUpdateState(e){const t=e.tickCount,s=(this._outputLatency=e.outputLatency,this._lastAIState.filter(e=>e.hasOwnProperty("placeholder")&&(e.placeholder>t||-1===e.placeholder)));this._lastAIState=e.audioInstances,this._lastAnalysersData=e.analysers,0<s.length&&o.appendArray(this._lastAIState,s)}_OnBufferMetadata(e){this._bufferMetadata.set(e.originalUrl,{duration:e.duration})}_OnAudioContextStateChanged(e){this._audioContextState=e.audioContextState}GetAudioContextState(){return this._runtime.IsExportToVideo()?"running":this._audioContextState}_OnUpdateFxState(e){this._lastFxState=e.fxstate}_GetFirstAudioStateByTags(e){const t=this._SplitTags(e);for(const s of this._lastAIState)if(this._MatchTagLists(s.tags,t))return s;return null}_IsTagPlaying(e){const t=this._SplitTags(e);return this._lastAIState.some(e=>this._MatchTagLists(e.tags,t)&&e.isPlaying)}_MaybeMarkAsPlaying(e,t,s,i,n){if(this._IsTagPlaying(t))return null;const r=this._bufferMetadata.get(e),a={tags:this._SplitTags(t),duration:r?r.duration:0,volume:n,isPlaying:!0,playbackTime:0,playbackRate:1,uid:-1,bufferOriginalUrl:e,bufferUrl:"",bufferType:"",isMusic:s,isLooping:i,isMuted:!1,resumePosition:0,pan:null,placeholder:-1};return this._lastAIState.push(a),a}_MaybeMarkAsStopped(e){const t=this._SplitTags(e);for(const s of this._lastAIState)this._MatchTagLists(s.tags,t)&&(s.isPlaying=!1)}async _OnTrigger(e){const t=e.type,s=(this._triggerTags=e.tags,e.aiid);if("ended"===t){for(const i of this._lastAIState)if(i.aiid===s){i.isPlaying=!1;break}await this.TriggerAsync(o.Plugins.Audio.Cnds.OnEnded)}else"fade-ended"===t&&await this.TriggerAsync(o.Plugins.Audio.Cnds.OnFadeEnded)}_MatchTriggerTag(e){return this._MatchTagListToStr(this._triggerTags,e)}Tick(){const e={timeScale:this._runtime.GetTimeScale(),gameTime:this._runtime.GetGameTimeRaw(),instPans:this.GetInstancePans(),tickCount:this._runtime.GetTickCountNoSave()};if(this._listenerInst){const t=this._listenerInst.GetWorldInfo();this._listenerPos[0]=t.GetX(),this._listenerPos[1]=t.GetY(),e.listenerPos=this._listenerPos,e.listenerOrientation=[...this._listenerForwardVec,...this._listenerUpVec]}this.PostToDOM("tick",e)}rotatePtAround(e,t,s,i,n){if(0!==s){const r=Math.sin(s),a=Math.cos(s),o=(e-=i)*r,l=(t-=n)*r,h=e*a,c=t*a;e=h-l,t=c+o,e+=i,t+=n}return[e,t]}GetInstancePans(){return this._lastAIState.filter(e=>-1!==e.uid).map(e=>this._runtime.GetInstanceByUID(e.uid)).filter(e=>e).map(e=>{const t=e.GetWorldInfo(),s=t.GetLayer().GetAngle(),[i,n]=this.rotatePtAround(t.GetX(),t.GetY(),-s,this._listenerPos[0],this._listenerPos[1]);return{uid:e.GetUID(),x:i,y:n,z:t.GetTotalZElevation(),angle:t.GetAngle()-s}})}GetAnalyserData(e,t){for(const s of this._lastAnalysersData)if(s.index===t&&o.equalsNoCase(s.tag,e))return s;return null}_IncrementEffectCount(e){for(const t of this._SplitTags(e)){const s=t.toLowerCase();this._effectCount.set(s,(this._effectCount.get(s)||0)+1)}}_IsSilent(){return this._isSilent}_SetSilent(e){this._isSilent!==(e=!!e)&&(this._isSilent=e,this.PostToDOM("set-silent",{isSilent:e}))}_GetMasterVolume(){return this._masterVolume}_SetMasterVolume(e){this._masterVolume!==e&&(this._masterVolume=e,this.PostToDOM("set-master-volume",{vol:e}))}_StopAll(){this.PostToDOM("stop-all");for(const e of this._lastAIState)e.isPlaying=!1}_ShouldSave(e){return!e.hasOwnProperty("placeholder")&&3!==this._saveLoadMode&&!(e.isMusic&&1===this._saveLoadMode||!e.isMusic&&2===this._saveLoadMode)}SaveToJson(){return{isSilent:this._isSilent,masterVolume:this._masterVolume,listenerZ:this._listenerPos[2],listenerForwardVec:this._listenerForwardVec,listenerUpVec:this._listenerUpVec,listenerUid:this._listenerInst?this._listenerInst.GetUID():-1,remoteUrls:[...this._remoteUrls.entries()],playing:this._lastAIState.filter(e=>this._ShouldSave(e)),effects:this._lastFxState,analysers:this._lastAnalysersData}}LoadFromJson(e){if(this._isSilent=e.isSilent,this._masterVolume=e.masterVolume,this._listenerPos[2]=e.listenerZ,this._listenerInst=null,this._loadListenerUid=e.listenerUid,e.hasOwnProperty("listenerForwardVec")?this._listenerForwardVec=e.listenerForwardVec:this._listenerForwardVec=[0,0,-1],e.hasOwnProperty("listenerUpVec")?this._listenerUpVec=e.listenerUpVec:this._listenerUpVec=[0,1,0],this._remoteUrls.clear(),e.remoteUrls)for(const[t,s]of e.remoteUrls)this._remoteUrls.set(t,s);this._lastAIState=e.playing;for(const i of this._lastAIState)i.hasOwnProperty("tag")&&!i.hasOwnProperty("tags")&&(i.tags=[i.tag].filter(e=>!!e));this._lastFxState=e.effects,this._lastAnalysersData=e.analysers}_OnAfterLoad(){if(-1!==this._loadListenerUid&&(this._listenerInst=this._runtime.GetInstanceByUID(this._loadListenerUid),this._loadListenerUid=-1,this._listenerInst)){const e=this._listenerInst.GetWorldInfo();this._listenerPos[0]=e.GetX(),this._listenerPos[1]=e.GetY()}for(const t of this._lastAIState){const s=this._runtime.GetAssetManager().GetProjectAudioFileUrl(t.bufferOriginalUrl);s?(t.bufferUrl=s.url,t.bufferType=s.type):t.bufferUrl=null}for(const i of Object.values(this._lastFxState))for(const n of i)if(n.hasOwnProperty("bufferOriginalUrl")){const r=this._runtime.GetAssetManager().GetProjectAudioFileUrl(n.bufferOriginalUrl);r&&(n.bufferUrl=r.url,n.bufferType=r.type)}this.PostToDOM("load-state",{saveLoadMode:this._saveLoadMode,timeScale:this._runtime.GetTimeScale(),gameTime:this._runtime.GetGameTimeRaw(),listenerPos:this._listenerPos,listenerOrientation:[...this._listenerForwardVec,...this._listenerUpVec],isSilent:this._isSilent,masterVolume:this._masterVolume,playing:this._lastAIState.filter(e=>null!==e.bufferUrl),effects:this._lastFxState})}GetDebuggerProperties(){const e=[];for(const[s,i]of Object.entries(this._lastFxState))e.push({name:"$"+s,value:i.map(e=>e.type).join(", ")});const t="plugins.audio.debugger";return[{title:t+".tag-effects",properties:e},{title:t+".currently-playing",properties:[{name:t+".currently-playing-count",value:this._lastAIState.length},...this._lastAIState.map((e,t)=>({name:"$#"+t,value:`${e.bufferOriginalUrl} ("${e.tags}") ${Math.round(10*e.playbackTime)/10} / `+Math.round(10*e.duration)/10}))]}]}}}{const x0=self.C3;x0.Plugins.Audio.Cnds={OnEnded(e){return this._MatchTriggerTag(e)},OnFadeEnded(e){return this._MatchTriggerTag(e)},PreloadsComplete(){return this._preloadCount===this._preloadTotal},AdvancedAudioSupported(){return!0},IsSilent(){return this._IsSilent()},IsAnyPlaying(){for(const e of this._lastAIState)if(e.isPlaying)return!0;return!1},IsTagPlaying(e){return this._IsTagPlaying(e)}}}{const C0=self.C3,D0=["lowpass","highpass","bandpass","lowshelf","highshelf","peaking","notch","allpass"];C0.Plugins.Audio.Acts={Play(e,t,s,i,n){const r=C0.Plugins.Audio.Acts._DoPlay.call(this,e,t,s,i,n);return this._AddActionPromise(r),r},PlayFromTimeline(e,t,s,i){C0.Plugins.Audio.Acts._DoPlay.call(this,e,0,t,0,s,i)},async _DoPlay(e,t,s,i,n,r){if(!this._isSilent){const a=e[1],o=this._runtime.GetAssetManager().GetProjectAudioFileUrl(e[0]);if(o){const l=this._nextPlayTime,h=(this._nextPlayTime=0,this._MaybeMarkAsPlaying(e[0],n,a,0!==t,this.DbToLinear(s)));try{await this.PostToDOMAsync("play",{originalUrl:e[0],url:o.url,type:o.type,isMusic:a,tags:this._SplitTags(n),isLooping:0!==t,vol:this.DbToLinear(s),stereoPan:C0.clamp(i/100,-1,1),pos:r||0,off:l,trueClock:!!self.C3_GetAudioContextCurrentTime})}finally{h&&(h.placeholder=this._runtime.GetTickCountNoSave())}}}},async PlayAtPosition(e,t,s,i,n,r,a,o,l,h,c){if(!this._isSilent){const u=e[1],_=this._runtime.GetAssetManager().GetProjectAudioFileUrl(e[0]);if(_){const d=this._nextPlayTime,p=(this._nextPlayTime=0,this._MaybeMarkAsPlaying(e[0],c,u,0!==t,this.DbToLinear(s)));try{await this.PostToDOMAsync("play",{originalUrl:e[0],url:_.url,type:_.type,isMusic:u,tags:this._SplitTags(c),isLooping:0!==t,vol:this.DbToLinear(s),pos:0,off:d,trueClock:!!self.C3_GetAudioContextCurrentTime,panning:{x:i,y:n,z:r,angle:C0.toRadians(a),innerAngle:C0.toRadians(o),outerAngle:C0.toRadians(l),outerGain:this.DbToLinear(h)}})}finally{p&&(p.placeholder=this._runtime.GetTickCountNoSave())}}}},async PlayAtObject(e,t,s,i,n,r,a,o){if(!this._isSilent&&i){const l=i.GetFirstPicked();if(l&&l.GetWorldInfo()){const h=l.GetWorldInfo(),c=h.GetLayer().GetAngle(),[u,_]=this.rotatePtAround(h.GetX(),h.GetY(),-c,this._listenerPos[0],this._listenerPos[1]),d=e[1],p=this._runtime.GetAssetManager().GetProjectAudioFileUrl(e[0]);if(p){const m=this._nextPlayTime,g=(this._nextPlayTime=0,this._MaybeMarkAsPlaying(e[0],o,d,0!==t,this.DbToLinear(s)));try{await this.PostToDOMAsync("play",{originalUrl:e[0],url:p.url,type:p.type,isMusic:d,tags:this._SplitTags(o),isLooping:0!==t,vol:this.DbToLinear(s),pos:0,off:m,trueClock:!!self.C3_GetAudioContextCurrentTime,panning:{x:u,y:_,z:h.GetTotalZElevation(),angle:h.GetAngle()-c,innerAngle:C0.toRadians(n),outerAngle:C0.toRadians(r),outerGain:this.DbToLinear(a),uid:l.GetUID()}})}finally{g&&(g.placeholder=this._runtime.GetTickCountNoSave())}}}}},async PlayByName(e,t,s,i,n,r){if(!this._isSilent){const a=1===e,o=this._runtime.GetAssetManager().GetProjectAudioFileUrl(t)||this._remoteUrls.get(t.toLowerCase());if(o){const l=this._nextPlayTime,h=(this._nextPlayTime=0,this._MaybeMarkAsPlaying(t,r,a,0!==s,this.DbToLinear(i)));try{await this.PostToDOMAsync("play",{originalUrl:t,url:o.url,type:o.type,isMusic:a,tags:this._SplitTags(r),isLooping:0!==s,vol:this.DbToLinear(i),stereoPan:C0.clamp(n/100,-1,1),pos:0,off:l,trueClock:!!self.C3_GetAudioContextCurrentTime})}finally{h&&(h.placeholder=this._runtime.GetTickCountNoSave())}}}},async PlayAtPositionByName(e,t,s,i,n,r,a,o,l,h,c,u){if(!this._isSilent){const _=1===e,d=this._runtime.GetAssetManager().GetProjectAudioFileUrl(t)||this._remoteUrls.get(t.toLowerCase());if(d){const p=this._nextPlayTime,m=(this._nextPlayTime=0,this._MaybeMarkAsPlaying(t,u,_,0!==s,this.DbToLinear(i)));try{await this.PostToDOMAsync("play",{originalUrl:t,url:d.url,type:d.type,isMusic:_,tags:this._SplitTags(u),isLooping:0!==s,vol:this.DbToLinear(i),pos:0,off:p,trueClock:!!self.C3_GetAudioContextCurrentTime,panning:{x:n,y:r,z:a,angle:C0.toRadians(o),innerAngle:C0.toRadians(l),outerAngle:C0.toRadians(h),outerGain:this.DbToLinear(c)}})}finally{m&&(m.placeholder=this._runtime.GetTickCountNoSave())}}}},async PlayAtObjectByName(e,t,s,i,n,r,a,o,l){if(!this._isSilent&&!this._isSilent&&n){const h=n.GetFirstPicked();if(h&&h.GetWorldInfo()){const c=h.GetWorldInfo(),u=c.GetLayer().GetAngle(),[_,d]=this.rotatePtAround(c.GetX(),c.GetY(),-u,this._listenerPos[0],this._listenerPos[1]),p=1===e,m=this._runtime.GetAssetManager().GetProjectAudioFileUrl(t)||this._remoteUrls.get(t.toLowerCase());if(m){const g=this._nextPlayTime,f=(this._nextPlayTime=0,this._MaybeMarkAsPlaying(t,l,p,0!==s,this.DbToLinear(i)));try{await this.PostToDOMAsync("play",{originalUrl:t,url:m.url,type:m.type,isMusic:p,tags:this._SplitTags(l),isLooping:0!==s,vol:this.DbToLinear(i),pos:0,off:g,trueClock:!!self.C3_GetAudioContextCurrentTime,panning:{x:_,y:d,z:c.GetTotalZElevation(),angle:c.GetAngle()-u,innerAngle:C0.toRadians(r),outerAngle:C0.toRadians(a),outerGain:this.DbToLinear(o),uid:h.GetUID()}})}finally{f&&(f.placeholder=this._runtime.GetTickCountNoSave())}}}}},SetLooping(e,t){this.PostToDOM("set-looping",{tags:this._SplitTags(e),isLooping:0===t})},SetMuted(e,t){this.PostToDOM("set-muted",{tags:this._SplitTags(e),isMuted:0===t})},SetVolume(e,t){this.PostToDOM("set-volume",{tags:this._SplitTags(e),vol:this.DbToLinear(t)})},FadeVolume(e,t,s,i){this.PostToDOM("fade-volume",{tags:this._SplitTags(e),vol:this.DbToLinear(t),duration:s,stopOnEnd:0===i})},SetStereoPan(e,t){this.PostToDOM("set-stereo-pan",{tags:this._SplitTags(e),p:C0.clamp(t/100,-1,1)})},async Preload(e){const t=e[1],s=this._runtime.GetAssetManager().GetProjectAudioFileUrl(e[0]);s&&(this._preloadTotal++,await this.PostToDOMAsync("preload",{originalUrl:e[0],url:s.url,type:s.type,isMusic:t}),this._preloadCount++)},async PreloadByName(e,t){const s=1===e,i=this._runtime.GetAssetManager().GetProjectAudioFileUrl(t)||this._remoteUrls.get(t.toLowerCase());i&&(this._preloadTotal++,await this.PostToDOMAsync("preload",{originalUrl:t,url:i.url,type:i.type,isMusic:s}),this._preloadCount++)},SetPlaybackRate(e,t){this.PostToDOM("set-playback-rate",{tags:this._SplitTags(e),rate:Math.max(t,0)})},Stop(e){this._MaybeMarkAsStopped(e),this.PostToDOM("stop",{tags:this._SplitTags(e)})},StopAll(){this._StopAll()},SetPaused(e,t){this.PostToDOM("set-paused",{tags:this._SplitTags(e),paused:0===t})},Seek(e,t){this.PostToDOM("seek",{tags:this._SplitTags(e),pos:t})},SetSilent(e){2===e&&(e=this._IsSilent()?1:0),this._SetSilent(0===e)},SetMasterVolume(e){const t=this.DbToLinear(e);this._SetMasterVolume(t)},AddFilterEffect(e,t,s,i,n,r,a){const o=D0[t];this._IncrementEffectCount(e),this.PostToDOM("add-effect",{type:"filter",tags:this._SplitTags(e),params:[o,s,i,n,r,C0.clamp(a/100,0,1)]})},AddDelayEffect(e,t,s,i){this._IncrementEffectCount(e),this.PostToDOM("add-effect",{type:"delay",tags:this._SplitTags(e),params:[t,this.DbToLinear(s),C0.clamp(i/100,0,1)]})},AddFlangerEffect(e,t,s,i,n,r){this._IncrementEffectCount(e),this.PostToDOM("add-effect",{type:"flanger",tags:this._SplitTags(e),params:[t/1e3,s/1e3,i,n/100,C0.clamp(r/100,0,1)]})},AddPhaserEffect(e,t,s,i,n,r,a){this._IncrementEffectCount(e),this.PostToDOM("add-effect",{type:"phaser",tags:this._SplitTags(e),params:[t,s,i,n,r,C0.clamp(a/100,0,1)]})},AddConvolutionEffect(e,t,s,i){const n=this._runtime.GetAssetManager().GetProjectAudioFileUrl(t[0]);n&&(this._IncrementEffectCount(e),this.PostToDOM("add-effect",{type:"convolution",tags:this._SplitTags(e),bufferOriginalUrl:t[0],bufferUrl:n.url,bufferType:n.type,params:[0===s,C0.clamp(i/100,0,1)]}))},AddGainEffect(e,t){this._IncrementEffectCount(e),this.PostToDOM("add-effect",{type:"gain",tags:this._SplitTags(e),params:[this.DbToLinear(t)]})},AddStereoPanEffect(e,t){this._IncrementEffectCount(e),this.PostToDOM("add-effect",{type:"stereopan",tags:this._SplitTags(e),params:[C0.clamp(t/100,-1,1)]})},AddMuteEffect(e){this._IncrementEffectCount(e),this.PostToDOM("add-effect",{type:"gain",tags:this._SplitTags(e),params:[0]})},AddTremoloEffect(e,t,s){this._IncrementEffectCount(e),this.PostToDOM("add-effect",{type:"tremolo",tags:this._SplitTags(e),params:[t,C0.clamp(s/100,0,1)]})},AddRingModEffect(e,t,s){this._IncrementEffectCount(e),this.PostToDOM("add-effect",{type:"ringmod",tags:this._SplitTags(e),params:[t,C0.clamp(s/100,0,1)]})},AddDistortionEffect(e,t,s,i,n,r){this._IncrementEffectCount(e),this.PostToDOM("add-effect",{type:"distortion",tags:this._SplitTags(e),params:[this.DbToLinearNoCap(t),this.DbToLinearNoCap(s),i,this.DbToLinearNoCap(n),C0.clamp(r/100,0,1)]})},AddCompressorEffect(e,t,s,i,n,r){this._IncrementEffectCount(e),this.PostToDOM("add-effect",{type:"compressor",tags:this._SplitTags(e),params:[t,s,i,n/1e3,r/1e3]})},AddAnalyserEffect(e,t,s){this._IncrementEffectCount(e),this.PostToDOM("add-effect",{type:"analyser",tags:this._SplitTags(e),params:[t,s]})},RemoveEffects(e){const t=this._SplitTags(e);for(const s of t)this._effectCount.set(s.toLowerCase(),0);this.PostToDOM("remove-effects",{tags:t}),this._lastFxState={}},SetEffectParameter(e,t,s,i,n,r){this.PostToDOM("set-effect-param",{tags:this._SplitTags(e),index:Math.floor(t),param:s,value:i,ramp:n,time:r})},SetListenerObject(e){if(e){const t=e.GetFirstPicked();t&&t.GetWorldInfo()&&(this._listenerInst=t)}},SetListenerZ(e){this._listenerPos[2]=e},SetListenerOrientation(e,t,s,i,n,r){this._listenerForwardVec[0]=e,this._listenerForwardVec[1]=t,this._listenerForwardVec[2]=-s,this._listenerUpVec[0]=i,this._listenerUpVec[1]=n,this._listenerUpVec[2]=-r},ScheduleNextPlay(e){this._nextPlayTime=Math.max(e,0)},UnloadAudio(e){const t=e[1],s=this._runtime.GetAssetManager().GetProjectAudioFileUrl(e[0]);s&&this.PostToDOM("unload",{url:s.url,type:s.type,isMusic:t})},UnloadAudioByName(e,t){const s=1===e,i=this._runtime.GetAssetManager().GetProjectAudioFileUrl(t)||this._remoteUrls.get(t.toLowerCase());i&&this.PostToDOM("unload",{url:i.url,type:i.type,isMusic:s})},UnloadAll(){this.PostToDOM("unload-all")},AddRemoteURL(e,t,s){this._remoteUrls.set(s.toLowerCase(),{url:e,type:t})}}}{const y2=self.C3;y2.Plugins.Audio.Exps={Duration(e){const t=this._GetFirstAudioStateByTags(e);return t?t.duration:0},PlaybackTime(e){const t=this._GetFirstAudioStateByTags(e);return t?t.playbackTime:0},PlaybackRate(e){const t=this._GetFirstAudioStateByTags(e);return t?t.playbackRate:0},Volume(e){const t=this._GetFirstAudioStateByTags(e);return t?this.LinearToDb(t.volume):0},MasterVolume(){return this.LinearToDb(this._GetMasterVolume())},EffectCount(e){return this._effectCount.get(e.toLowerCase())||0},AnalyserFreqBinCount(e,t){const s=this.GetAnalyserData(e,Math.floor(t));return s?s.binCount:0},AnalyserFreqBinAt(e,t,s){const i=this.GetAnalyserData(e,Math.floor(t));return!i||(s=Math.floor(s))<0||s>=i.binCount?0:i.freqBins[s]},AnalyserPeakLevel(e,t){const s=this.GetAnalyserData(e,Math.floor(t));return s?s.peak:0},AnalyserRMSLevel(e,t){const s=this.GetAnalyserData(e,Math.floor(t));return s?s.rms:0},SampleRate(){return this._sampleRate},CurrentTime(){return self.C3_GetAudioContextCurrentTime?self.C3_GetAudioContextCurrentTime():performance.now()/1e3},OutputLatency(){return this._outputLatency},NormalizedVolume(e,t){return 0==(e=y2.clamp(+e,0,100)/100)?-1/0:e<.1?this.LinearToDb(y2.lerp(0,this.DbToLinear(t),10*e)):y2.lerp(t,0,(e-.1)/.9)}}}{const a=self.C3;a.Plugins.Keyboard=class extends a.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{let GetKeyboardSdkInstance2=function(){return r.GetSingleGlobalInstance().GetSdkInstance()};GetKeyboardSdkInstance=GetKeyboardSdkInstance2;const d=self.C3,e=self.C3X;d.Plugins.Keyboard.Type=class extends d.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}GetScriptInterfaceClass(){return self.IKeyboardObjectType}};let r=null;self.IKeyboardObjectType=class extends self.IObjectClass{constructor(e){super(e),(r=e).GetRuntime()._GetCommonScriptInterfaces().keyboard=this}isKeyDown(e){const t=GetKeyboardSdkInstance2();if("string"==typeof e)return t.IsKeyDown(e);if("number"==typeof e)return t.IsKeyCodeDown(e);throw new TypeError("expected string or number")}}}{const m=self.C3,n="keyboard";m.Plugins.Keyboard.Instance=class extends m.SDKInstanceBase{constructor(e,t){super(e,n),this._keysDownByString=new Set,this._keysDownByWhich=new Set,this._triggerWhich=0,this._triggerString="",this._triggerTypedKey="",this._isKeyboardLockSupported=!1;const s=this.GetRuntime().Dispatcher();this._disposables=new m.CompositeDisposable(m.Disposable.From(s,"keydown",e=>this._OnKeyDown(e.data)),m.Disposable.From(s,"keyup",e=>this._OnKeyUp(e.data)),m.Disposable.From(s,"window-blur",()=>this._OnWindowOrKeyboardBlur()),m.Disposable.From(s,"keyboard-blur",()=>this._OnWindowOrKeyboardBlur())),this._runtime.AddLoadPromise(this._Init())}Release(){super.Release()}async _Init(){const e=await this.PostToDOMAsync("init");this._isKeyboardLockSupported=e.isKeyboardLockSupported}_OnKeyDown(e){const t=e.which,s=e.code||t.toString(),i=e.key;this._keysDownByString.has(s)||(this._keysDownByString.add(s),this._keysDownByWhich.add(t),this._triggerString=s,this._triggerWhich=t,this._triggerTypedKey=i,this.Trigger(m.Plugins.Keyboard.Cnds.OnAnyKey),this.Trigger(m.Plugins.Keyboard.Cnds.OnKey),this.Trigger(m.Plugins.Keyboard.Cnds.OnLeftRightKeyPressed),this.Trigger(m.Plugins.Keyboard.Cnds.OnKeyCode))}_OnKeyUp(e){const t=e.which,s=e.code||t.toString(),i=e.key;this._keysDownByString.delete(s),this._keysDownByWhich.delete(t),this._triggerString=s,this._triggerWhich=t,this._triggerTypedKey=i,this.Trigger(m.Plugins.Keyboard.Cnds.OnAnyKeyReleased),this.Trigger(m.Plugins.Keyboard.Cnds.OnKeyReleased),this.Trigger(m.Plugins.Keyboard.Cnds.OnLeftRightKeyReleased),this.Trigger(m.Plugins.Keyboard.Cnds.OnKeyCodeReleased)}_OnWindowOrKeyboardBlur(){for(const e of this._keysDownByWhich)this._keysDownByWhich.delete(e),this._triggerWhich=e,this.Trigger(m.Plugins.Keyboard.Cnds.OnAnyKeyReleased),this.Trigger(m.Plugins.Keyboard.Cnds.OnKeyReleased),this.Trigger(m.Plugins.Keyboard.Cnds.OnKeyCodeReleased);this._keysDownByString.clear()}IsKeyDown(e){return this._keysDownByString.has(e)}IsKeyCodeDown(e){return this._keysDownByWhich.has(e)}SaveToJson(){return{tk:this._triggerWhich,tkk:this._triggerTypedKey}}LoadFromJson(e){this._triggerWhich=e.tk,e.hasOwnProperty("tkk")&&(this._triggerTypedKey=e.tkk)}GetDebuggerProperties(){const e="plugins.keyboard";return[{title:e+".name",properties:[{name:e+".debugger.last-key-code",value:this._triggerWhich},{name:e+".debugger.last-key-string",value:m.Plugins.Keyboard.Exps.StringFromKeyCode(this._triggerWhich)},{name:e+".debugger.last-typed-key",value:this._triggerTypedKey}]}]}}}{const I=self.C3,J=["ShiftLeft","ShiftRight","ControlLeft","ControlRight","AltLeft","AltRight","MetaLeft","MetaRight"];I.Plugins.Keyboard.Cnds={IsKeyDown(e){return this._keysDownByWhich.has(e)},OnKey(e){return this._triggerWhich===e},OnAnyKey(){return!0},OnAnyKeyReleased(){return!0},OnKeyReleased(e){return this._triggerWhich===e},IsKeyCodeDown(e){return e=Math.floor(e),this._keysDownByWhich.has(e)},OnKeyCode(e){return this._triggerWhich===e},OnKeyCodeReleased(e){return this._triggerWhich===e},OnLeftRightKeyPressed(e){const t=J[e];return this._triggerString===t},OnLeftRightKeyReleased(e){const t=J[e];return this._triggerString===t},IsLeftRightKeyDown(e){const t=J[e];return this._keysDownByString.has(t)},IsKeyboardLockSupported(){return this._isKeyboardLockSupported},OnKeyboardLocked(){return!0},OnKeyboardLockError(){return!0}}}{const W=self.C3;W.Plugins.Keyboard.Acts={async LockKeyboard(t){if(this._isKeyboardLockSupported){let e=[];t&&(e=t.split(","));const s=await this.PostToDOMAsync("lock-keyboard",{keysArr:e});s.isOk?this.Trigger(W.Plugins.Keyboard.Cnds.OnKeyboardLocked):this.Trigger(W.Plugins.Keyboard.Cnds.OnKeyboardLockError)}},UnlockKeyboard(){this._isKeyboardLockSupported&&this.PostToDOMAsync("unlock-keyboard")}}}{let StringFromCharCode2=function(e){switch(e=Math.floor(e)){case 8:return"backspace";case 9:return"tab";case 13:return"enter";case 16:return"shift";case 17:return"control";case 18:return"alt";case 19:return"pause";case 20:return"capslock";case 27:return"esc";case 33:return"pageup";case 34:return"pagedown";case 35:return"end";case 36:return"home";case 37:return"←";case 38:return"↑";case 39:return"→";case 40:return"↓";case 45:return"insert";case 46:return"del";case 91:return"left window key";case 92:return"right window key";case 93:return"select";case 96:return"numpad 0";case 97:return"numpad 1";case 98:return"numpad 2";case 99:return"numpad 3";case 100:return"numpad 4";case 101:return"numpad 5";case 102:return"numpad 6";case 103:return"numpad 7";case 104:return"numpad 8";case 105:return"numpad 9";case 106:return"numpad *";case 107:return"numpad +";case 109:return"numpad -";case 110:return"numpad .";case 111:return"numpad /";case 112:return"F1";case 113:return"F2";case 114:return"F3";case 115:return"F4";case 116:return"F5";case 117:return"F6";case 118:return"F7";case 119:return"F8";case 120:return"F9";case 121:return"F10";case 122:return"F11";case 123:return"F12";case 144:return"numlock";case 145:return"scroll lock";case 186:return";";case 187:return"=";case 188:return",";case 189:return"-";case 190:return".";case 191:return"/";case 192:return"'";case 219:return"[";case 220:return"\\";case 221:return"]";case 222:return"#";case 223:return"`";default:return String.fromCharCode(e)}};StringFromCharCode=StringFromCharCode2;const $=self.C3;$.Plugins.Keyboard.Exps={LastKeyCode(){return this._triggerWhich},StringFromKeyCode(e){return StringFromCharCode2(e)},TypedKey(){return this._triggerTypedKey}}}{const a=self.C3;a.Plugins.Touch=class extends a.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{let GetTouchSdkInstance2=function(){return s.GetSingleGlobalInstance().GetSdkInstance()};GetTouchSdkInstance=GetTouchSdkInstance2;const d=self.C3,e=self.C3X;d.Plugins.Touch.Type=class extends d.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}GetScriptInterfaceClass(){return self.ITouchObjectType}};let s=null;self.ITouchObjectType=class extends self.IObjectClass{constructor(e){super(e),(s=e).GetRuntime()._GetCommonScriptInterfaces().touch=this}requestPermission(t){e.RequireString(t);const s=GetTouchSdkInstance2();if("orientation"===t)return s._RequestPermission(0);if("motion"===t)return s._RequestPermission(1);throw new Error("invalid type")}}}{const m=self.C3,n="touch";m.Plugins.Touch.Instance=class extends m.SDKInstanceBase{constructor(e,t){super(e,n),this._touches=new Map,this._useMouseInput=!1,this._isMouseDown=!1,this._orientCompassHeading=0,this._orientAlpha=0,this._orientBeta=0,this._orientGamma=0,this._accX=0,this._accY=0,this._accZ=0,this._accWithGX=0,this._accWithGY=0,this._accWithGZ=0,this._triggerIndex=0,this._triggerId=0,this._triggerPermission=0,this._curTouchX=0,this._curTouchY=0,this._getTouchIndex=0,this._triggerType=0,this._permissionPromises=[],t&&(this._useMouseInput=t[0]),this.AddDOMMessageHandler("permission-result",e=>this._OnPermissionResult(e));const s=this.GetRuntime().Dispatcher();this._disposables=new m.CompositeDisposable(m.Disposable.From(s,"pointerdown",e=>this._OnPointerDown(e.data)),m.Disposable.From(s,"pointermove",e=>this._OnPointerMove(e.data)),m.Disposable.From(s,"pointerup",e=>this._OnPointerUp(e.data,!1)),m.Disposable.From(s,"pointercancel",e=>this._OnPointerUp(e.data,!0)),m.Disposable.From(s,"deviceorientation",e=>this._OnDeviceOrientation(e.data)),m.Disposable.From(s,"deviceorientationabsolute",e=>this._OnDeviceOrientationAbsolute(e.data)),m.Disposable.From(s,"devicemotion",e=>this._OnDeviceMotion(e.data)),m.Disposable.From(s,"tick2",e=>this._OnTick2()))}Release(){this._touches.clear(),super.Release()}_OnPointerDown(e){if("mouse"===e.pointerType){if(!this._useMouseInput)return;this._isMouseDown=!0}const t=e.pointerId;if(!this._touches.has(t)){const s=e.pageX-this._runtime.GetCanvasClientX(),i=e.pageY-this._runtime.GetCanvasClientY(),n=performance.now(),r=this._touches.size,a=(this._triggerIndex=r,this._triggerId=t,m.New(m.Plugins.Touch.TouchInfo));a.Init(n,s,i,t,r),this._touches.set(t,a),this.Trigger(m.Plugins.Touch.Cnds.OnNthTouchStart),this.Trigger(m.Plugins.Touch.Cnds.OnTouchStart),this._curTouchX=s,this._curTouchY=i,this._triggerType=0,this.Trigger(m.Plugins.Touch.Cnds.OnTouchObject)}}_OnPointerMove(e){if("mouse"!==e.pointerType||this._isMouseDown){const t=this._touches.get(e.pointerId);if(t){const s=performance.now();if(!(s-t.GetTime()<2)){const i=e.pageX-this._runtime.GetCanvasClientX(),n=e.pageY-this._runtime.GetCanvasClientY();t.Update(s,i,n,e.width,e.height,e.pressure)}}}}_OnPointerUp(e,t){if("mouse"===e.pointerType){if(!this._isMouseDown)return;this._isMouseDown=!1}const s=performance.now(),i=e.pointerId,n=this._touches.get(i);if(n){if(this._triggerIndex=n.GetStartIndex(),this._triggerId=n.GetId(),!t){const r=e.pageX-this._runtime.GetCanvasClientX(),a=e.pageY-this._runtime.GetCanvasClientY();this._curTouchX=r,this._curTouchY=a,this._triggerType=1,this.Trigger(m.Plugins.Touch.Cnds.OnTouchObject)}if(this.Trigger(m.Plugins.Touch.Cnds.OnNthTouchEnd),this.Trigger(m.Plugins.Touch.Cnds.OnTouchEnd),!t){const o=n.ShouldTriggerTap(s);"single-tap"===o?(this.Trigger(m.Plugins.Touch.Cnds.OnTapGesture),this._curTouchX=n.GetX(),this._curTouchY=n.GetY(),this.Trigger(m.Plugins.Touch.Cnds.OnTapGestureObject)):"double-tap"===o&&(this.Trigger(m.Plugins.Touch.Cnds.OnDoubleTapGesture),this._curTouchX=n.GetX(),this._curTouchY=n.GetY(),this.Trigger(m.Plugins.Touch.Cnds.OnDoubleTapGestureObject))}n.Release(),this._touches.delete(i)}}_RequestPermission(s){return this._PostToDOMMaybeSync("request-permission",{type:s}),new Promise((e,t)=>{this._permissionPromises.push({type:s,resolve:e,reject:t})})}_OnPermissionResult(e){const t=e.result,s=e.type,i=(this._triggerPermission=s,this._permissionPromises.filter(e=>e.type===s));for(const n of i)n.resolve(t?"granted":"denied");this._permissionPromises=this._permissionPromises.filter(e=>e.type!==s),t?(this.Trigger(m.Plugins.Touch.Cnds.OnPermissionGranted),0===s?this._runtime.RequestDeviceOrientationEvent():this._runtime.RequestDeviceMotionEvent()):this.Trigger(m.Plugins.Touch.Cnds.OnPermissionDenied)}_OnDeviceOrientation(e){"number"==typeof e.webkitCompassHeading?this._orientCompassHeading=e.webkitCompassHeading:e.absolute&&(this._orientCompassHeading=e.alpha),this._orientAlpha=e.alpha,this._orientBeta=e.beta,this._orientGamma=e.gamma}_OnDeviceOrientationAbsolute(e){this._orientCompassHeading=e.alpha}_OnDeviceMotion(e){const t=e.acceleration,s=(t&&(this._accX=t.x,this._accY=t.y,this._accZ=t.z),e.accelerationIncludingGravity);s&&(this._accWithGX=s.x,this._accWithGY=s.y,this._accWithGZ=s.z)}_OnTick2(){let e=performance.now(),t=0;for(const s of this._touches.values())s.GetTime()<=e-50&&s._SetLastTime(e),s.ShouldTriggerHold(e)&&(this._triggerIndex=s.GetStartIndex(),this._triggerId=s.GetId(),this._getTouchIndex=t,this.Trigger(m.Plugins.Touch.Cnds.OnHoldGesture),this._curTouchX=s.GetX(),this._curTouchY=s.GetY(),this.Trigger(m.Plugins.Touch.Cnds.OnHoldGestureObject),this._getTouchIndex=0),++t}_GetTouchByIndex(e){e=Math.floor(e);for(const t of this._touches.values()){if(0===e)return t;--e}return null}_IsClientPosOnCanvas(e,t){return 0<=e&&0<=t&&e<this._runtime.GetCanvasCssWidth()&&t<this._runtime.GetCanvasCssHeight()}GetDebuggerProperties(){return[{title:"plugins.touch.debugger.touches",properties:[...this._touches.values()].map(e=>({name:"$"+e.GetId(),value:e.GetX()+", "+e.GetY()}))}]}}}{const ra=self.C3,sa=[];ra.Plugins.Touch.Cnds={OnTouchStart(){return!0},OnTouchEnd(){return!0},IsInTouch(){return 0<this._touches.size},OnTouchObject(e,t){return!!e&&t===this._triggerType&&!!this._IsClientPosOnCanvas(this._curTouchX,this._curTouchY)&&this._runtime.GetCollisionEngine().TestAndSelectCanvasPointOverlap(e,[[this._curTouchX,this._curTouchY]],!1)},IsTouchingObject(e){if(!e)return!1;const t=this._runtime.GetCurrentCondition(),s=t.IsInverted(),i=[...this._touches.values()].filter(e=>this._IsClientPosOnCanvas(e.GetX(),e.GetY())).map(e=>[e.GetX(),e.GetY()]);return ra.xor(this._runtime.GetCollisionEngine().TestAndSelectCanvasPointOverlap(e,i,s),s)},CompareTouchSpeed(e,t,s){const i=this._GetTouchByIndex(e);return!!i&&ra.compare(i.GetSpeed(),t,s)},OrientationSupported(){return!0},MotionSupported(){return!0},CompareOrientation(e,t,s){this._runtime.RequestDeviceOrientationEvent();let i;return i=0===e?this._orientAlpha:1===e?this._orientBeta:this._orientGamma,ra.compare(i,t,s)},CompareAcceleration(e,t,s){this._runtime.RequestDeviceMotionEvent();let i;return i=0===e?this._accWithGX:1===e?this._accWithGY:2===e?this._accWithGZ:3===e?this._accX:4===e?this._accY:this._accZ,ra.compare(i,t,s)},OnNthTouchStart(e){return(e=Math.floor(e))===this._triggerIndex},OnNthTouchEnd(e){return(e=Math.floor(e))===this._triggerIndex},HasNthTouch(e){return e=Math.floor(e),this._touches.size>=e+1},OnHoldGesture(){return!0},OnTapGesture(){return!0},OnDoubleTapGesture(){return!0},OnHoldGestureObject(e){return!!e&&!!this._IsClientPosOnCanvas(this._curTouchX,this._curTouchY)&&this._runtime.GetCollisionEngine().TestAndSelectCanvasPointOverlap(e,[[this._curTouchX,this._curTouchY]],!1)},OnTapGestureObject(e){return!!e&&!!this._IsClientPosOnCanvas(this._curTouchX,this._curTouchY)&&this._runtime.GetCollisionEngine().TestAndSelectCanvasPointOverlap(e,[[this._curTouchX,this._curTouchY]],!1)},OnDoubleTapGestureObject(e){return!!e&&!!this._IsClientPosOnCanvas(this._curTouchX,this._curTouchY)&&this._runtime.GetCollisionEngine().TestAndSelectCanvasPointOverlap(e,[[this._curTouchX,this._curTouchY]],!1)},OnPermissionGranted(e){return this._triggerPermission===e},OnPermissionDenied(e){return this._triggerPermission===e}}}{const Va=self.C3;Va.Plugins.Touch.Acts={RequestPermission(e){this._RequestPermission(e)}}}{const Xa=self.C3;Xa.Plugins.Touch.Exps={TouchCount(){return this._touches.size},X(e){const t=this._GetTouchByIndex(this._getTouchIndex);return t?t.GetPositionForLayer(this._runtime.GetCurrentLayout(),e,!0):0},Y(e){const t=this._GetTouchByIndex(this._getTouchIndex);return t?t.GetPositionForLayer(this._runtime.GetCurrentLayout(),e,!1):0},XAt(e,t){const s=this._GetTouchByIndex(e);return s?s.GetPositionForLayer(this._runtime.GetCurrentLayout(),t,!0):0},YAt(e,t){const s=this._GetTouchByIndex(e);return s?s.GetPositionForLayer(this._runtime.GetCurrentLayout(),t,!1):0},XForID(e,t){const s=this._touches.get(e);return s?s.GetPositionForLayer(this._runtime.GetCurrentLayout(),t,!0):0},YForID(e,t){const s=this._touches.get(e);return s?s.GetPositionForLayer(this._runtime.GetCurrentLayout(),t,!1):0},AbsoluteX(){const e=this._GetTouchByIndex(0);return e?e.GetX():0},AbsoluteY(){const e=this._GetTouchByIndex(0);return e?e.GetY():0},AbsoluteXAt(e){const t=this._GetTouchByIndex(e);return t?t.GetX():0},AbsoluteYAt(e){const t=this._GetTouchByIndex(e);return t?t.GetY():0},AbsoluteXForID(e){const t=this._touches.get(e);return t?t.GetX():0},AbsoluteYForID(e){const t=this._touches.get(e);return t?t.GetY():0},SpeedAt(e){const t=this._GetTouchByIndex(e);return t?t.GetSpeed():0},SpeedForID(e){const t=this._touches.get(e);return t?t.GetSpeed():0},AngleAt(e){const t=this._GetTouchByIndex(e);return t?Xa.toDegrees(t.GetAngle()):0},AngleForID(e){const t=this._touches.get(e);return t?Xa.toDegrees(t.GetAngle()):0},CompassHeading(){return this._runtime.RequestDeviceOrientationEvent(),this._orientCompassHeading},Alpha(){return this._runtime.RequestDeviceOrientationEvent(),this._orientAlpha},Beta(){return this._runtime.RequestDeviceOrientationEvent(),this._orientBeta},Gamma(){return this._runtime.RequestDeviceOrientationEvent(),this._orientGamma},AccelerationXWithG(){return this._runtime.RequestDeviceMotionEvent(),this._accWithGX},AccelerationYWithG(){return this._runtime.RequestDeviceMotionEvent(),this._accWithGY},AccelerationZWithG(){return this._runtime.RequestDeviceMotionEvent(),this._accWithGZ},AccelerationX(){return this._runtime.RequestDeviceMotionEvent(),this._accX},AccelerationY(){return this._runtime.RequestDeviceMotionEvent(),this._accY},AccelerationZ(){return this._runtime.RequestDeviceMotionEvent(),this._accZ},TouchIndex(){return this._triggerIndex},TouchID(){return this._triggerId},WidthForID(e){const t=this._touches.get(e);return t?t.GetWidth():0},HeightForID(e){const t=this._touches.get(e);return t?t.GetHeight():0},PressureForID(e){const t=this._touches.get(e);return t?t.GetPressure():0}}}{let C33=self.C3,GESTURE_HOLD_THRESHOLD=15,GESTURE_HOLD_TIMEOUT=500,GESTURE_TAP_TIMEOUT=333,GESTURE_DOUBLETAP_THRESHOLD=25,lastTapX=-1e3,lastTapY=-1e3,lastTapTime=-1e4;C33.Plugins.Touch.TouchInfo=class extends C33.DefendedBase{constructor(){super(),this._pointerId=0,this._startIndex=0,this._startTime=0,this._time=0,this._lastTime=0,this._startX=0,this._startY=0,this._x=0,this._y=0,this._lastX=0,this._lastY=0,this._width=0,this._height=0,this._pressure=0,this._hasTriggeredHold=!1,this._isTooFarForHold=!1}Release(){}Init(e,t,s,i,n){this._pointerId=i,this._startIndex=n,this._time=e,this._lastTime=e,this._startTime=e,this._startX=t,this._startY=s,this._x=t,this._y=s,this._lastX=t,this._lastY=s}Update(e,t,s,i,n,r){this._lastTime=this._time,this._time=e,this._lastX=this._x,this._lastY=this._y,this._x=t,this._y=s,this._width=i,this._height=n,this._pressure=r,!this._isTooFarForHold&&C33.distanceTo(this._startX,this._startY,this._x,this._y)>=GESTURE_HOLD_THRESHOLD&&(this._isTooFarForHold=!0)}GetId(){return this._pointerId}GetStartIndex(){return this._startIndex}GetTime(){return this._time}_SetLastTime(e){this._lastTime=e}GetX(){return this._x}GetY(){return this._y}GetSpeed(){const e=C33.distanceTo(this._x,this._y,this._lastX,this._lastY),t=(this._time-this._lastTime)/1e3;return 0<t?e/t:0}GetAngle(){return C33.angleTo(this._lastX,this._lastY,this._x,this._y)}GetWidth(){return this._width}GetHeight(){return this._height}GetPressure(){return this._pressure}ShouldTriggerHold(e){return!this._hasTriggeredHold&&e-this._startTime>=GESTURE_HOLD_TIMEOUT&&!this._isTooFarForHold&&C33.distanceTo(this._startX,this._startY,this._x,this._y)<GESTURE_HOLD_THRESHOLD&&(this._hasTriggeredHold=!0)}ShouldTriggerTap(e){return!this._hasTriggeredHold&&e-this._startTime<=GESTURE_TAP_TIMEOUT&&!this._isTooFarForHold&&C33.distanceTo(this._startX,this._startY,this._x,this._y)<GESTURE_HOLD_THRESHOLD?e-lastTapTime<=2*GESTURE_TAP_TIMEOUT&&C33.distanceTo(lastTapX,lastTapY,this._x,this._y)<GESTURE_DOUBLETAP_THRESHOLD?(lastTapX=-1e3,lastTapY=-1e3,lastTapTime=-1e4,"double-tap"):(lastTapX=this._x,lastTapY=this._y,lastTapTime=e,"single-tap"):""}GetPositionForLayer(e,t,s){if(void 0===t){const i=e.GetLayerByIndex(0);return i.CanvasCssToLayer_DefaultTransform(this._x,this._y)[s?0:1]}{const n=e.GetLayer(t);return n?n.CanvasCssToLayer(this._x,this._y)[s?0:1]:0}}}}{const C33=self.C3;C33.Plugins.Browser=class BrowserPlugin extends C33.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{const C33=self.C3;C33.Plugins.Browser.Type=class BrowserType extends C33.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const C33=self.C3,DOM_COMPONENT_ID="browser";C33.Plugins.Browser.Instance=class BrowserInstance extends C33.SDKInstanceBase{constructor(e,t){super(e,DOM_COMPONENT_ID),this._initLocationStr="",this._isOnline=!1,this._referrer="",this._docTitle="",this._isCookieEnabled=!1,this._screenWidth=0,this._screenHeight=0,this._windowOuterWidth=0,this._windowOuterHeight=0,this._windowHasFocus=!1,this._isConstructArcade=!1,this._cssStyleMap=new Map,this._isInstallAvailable=!1,this._installResult="",this._isWarnOnCloseEnabled=!1,this.AddDOMMessageHandlers([["online-state",e=>this._OnOnlineStateChanged(e)],["backbutton",()=>this._OnBackButton()],["sw-message",e=>this._OnSWMessage(e)],["hashchange",e=>this._OnHashChange(e)],["install-available",()=>this._OnInstallAvailable()],["app-installed",e=>this._OnAppInstalled(e)]]);const s=this.GetRuntime().Dispatcher();this._disposables=new C33.CompositeDisposable(C33.Disposable.From(s,"afterfirstlayoutstart",()=>this._OnAfterFirstLayoutStart()),C33.Disposable.From(s,"window-resize",()=>this._OnWindowResize()),C33.Disposable.From(s,"window-focus",()=>this._OnWindowFocus()),C33.Disposable.From(s,"window-blur",()=>this._OnWindowBlur()),C33.Disposable.From(s,"suspend",()=>this._OnSuspend()),C33.Disposable.From(s,"resume",()=>this._OnResume())),this._runtime.AddLoadPromise(this.PostToDOMAsync("get-initial-state",{exportType:this._runtime.GetExportType()}).then(e=>{this._initLocationStr=e.location,this._isOnline=e.isOnline,this._referrer=e.referrer,this._docTitle=e.title,this._isCookieEnabled=e.isCookieEnabled,this._screenWidth=e.screenWidth,this._screenHeight=e.screenHeight,this._windowOuterWidth=e.windowOuterWidth,this._windowOuterHeight=e.windowOuterHeight,this._windowHasFocus=e.windowHasFocus,this._isConstructArcade=e.isConstructArcade}))}Release(){super.Release()}_OnAfterFirstLayoutStart(){this.PostToDOM("ready-for-sw-messages")}async _OnOnlineStateChanged(e){const t=!!e.isOnline;this._isOnline!==t&&(this._isOnline=t,this._isOnline?await this.TriggerAsync(C33.Plugins.Browser.Cnds.OnOnline):await this.TriggerAsync(C33.Plugins.Browser.Cnds.OnOffline))}async _OnWindowResize(){await this.TriggerAsync(C33.Plugins.Browser.Cnds.OnResize)}async _OnWindowFocus(){this._windowHasFocus=!0,await this.TriggerAsync(C33.Plugins.Browser.Cnds.OnWindowFocus)}async _OnWindowBlur(){this._windowHasFocus=!1,await this.TriggerAsync(C33.Plugins.Browser.Cnds.OnWindowBlur)}_OnSuspend(){this.Trigger(C33.Plugins.Browser.Cnds.OnPageHidden)}_OnResume(){this.Trigger(C33.Plugins.Browser.Cnds.OnPageVisible)}async _OnBackButton(){await this.TriggerAsync(C33.Plugins.Browser.Cnds.OnBackButton)}_OnSWMessage(e){const t=e.type;"downloading-update"===t?this.Trigger(C33.Plugins.Browser.Cnds.OnUpdateFound):"update-ready"===t||"update-pending"===t?this.Trigger(C33.Plugins.Browser.Cnds.OnUpdateReady):"offline-ready"===t&&this.Trigger(C33.Plugins.Browser.Cnds.OnOfflineReady)}_OnHashChange(e){this._initLocationStr=e.location,this.Trigger(C33.Plugins.Browser.Cnds.OnHashChange)}_OnInstallAvailable(){this._isInstallAvailable=!0,this.Trigger(C33.Plugins.Browser.Cnds.OnInstallAvailable)}_OnAppInstalled(e){this._isInstallAvailable=!1,this.Trigger(C33.Plugins.Browser.Cnds.OnAppInstalled)}_IsWarnOnCloseEnabled(){return this._isWarnOnCloseEnabled}_SetWarnOnCloseEnabled(e){this._isWarnOnCloseEnabled!==(e=!!e)&&(this._isWarnOnCloseEnabled=e,this.PostToDOM("set-warn-on-close",{enabled:e}))}GetDebuggerProperties(){const e="plugins.browser.debugger";return[{title:"plugins.browser.name",properties:[{name:e+".user-agent",value:navigator.userAgent},{name:e+".is-online",value:this._isOnline},{name:e+".is-fullscreen",value:this._runtime.GetCanvasManager().IsDocumentFullscreen()}]}]}}}{const C33=self.C3;C33.Plugins.Browser.Cnds={IsOnline(){return this._isOnline},OnOnline(){return!0},OnOffline(){return!0},OnResize(){return!0},OnWindowFocus(){return!0},OnWindowBlur(){return!0},WindowHasFocus(){return this._windowHasFocus},CookiesEnabled(){return this._isCookieEnabled},IsFullscreen(){return this._runtime.GetCanvasManager().IsDocumentFullscreen()},OnBackButton(){return!0},IsPortraitLandscape(e){const t=this._runtime.GetCanvasManager().GetLastWidth(),s=this._runtime.GetCanvasManager().GetLastHeight(),i=t<=s?0:1;return i===e},OnUpdateFound(){return!0},OnUpdateReady(){return!0},OnOfflineReady(){return!0},OnHashChange(){return!0},OnInstallAvailable(){return!0},IsInstallAvailable(){return this._isInstallAvailable},OnInstallResult(e){switch(e){case 0:return"accepted"===this._installResult;case 1:return"dismissed"===this._installResult;case 2:return"error"===this._installResult;case 3:return!0;default:return!1}},OnAppInstalled(){return!0},CompareDisplayMode(e){const t=this._runtime.GetCanvasManager().GetCssDisplayMode();switch(e){case 0:return"browser"===t;case 1:return"minimal-ui"===t;case 2:return"standalone"===t;case 3:return"fullscreen"===t;default:return!1}},IsWarnOnCloseEnabled(){return this._IsWarnOnCloseEnabled()},PageVisible(){return!this._runtime.IsSuspended()},OnPageHidden(){return!0},OnPageVisible(){return!0},HasJava(){return!1},IsDownloadingUpdate(){return!1},OnMenuButton(){return!1},OnSearchButton(){return!1},IsMetered(){return!1},IsCharging(){return!0},SupportsFullscreen(){return!0}}}{const C3=self.C3,ORIENTATIONS=["portrait","landscape","portrait-primary","portrait-secondary","landscape-primary","landscape-secondary"];C3.Plugins.Browser.Acts={Alert(e){this.PostToDOM("alert",{message:e.toString()})},Close(){this._isConstructArcade||(this._runtime.IsDebug()?self.C3Debugger.CloseWindow():this.PostToDOM("close"))},Focus(){this.PostToDOM("set-focus",{isFocus:!0})},Blur(){this.PostToDOM("set-focus",{isFocus:!1})},GoBack(){this._isConstructArcade||this.PostToDOM("navigate",{type:"back"})},GoForward(){this._isConstructArcade||this.PostToDOM("navigate",{type:"forward"})},GoHome(){},Reload(){this._isConstructArcade||(this._runtime.IsDebug()?this._runtime.PostToDebugger({type:"reload"}):this.PostToDOM("navigate",{type:"reload"}))},GoToURL(e,t){this._PostToDOMMaybeSync("navigate",{type:"url",url:e,target:t,exportType:this._runtime.GetExportType()})},GoToURLWindow(e,t){this._PostToDOMMaybeSync("navigate",{type:"new-window",url:e,tag:t,exportType:this._runtime.GetExportType()})},RequestFullScreen(e,t){2<=e&&(e+=1),1===(e=6===e?2:e)&&(e=0);const s=C3.CanvasManager._FullscreenModeNumberToString(e);this._runtime.GetCanvasManager().SetDocumentFullscreenMode(s),this._PostToDOMMaybeSync("request-fullscreen",{navUI:t})},CancelFullScreen(){this._PostToDOMMaybeSync("exit-fullscreen")},Vibrate(e){const s=e.split(",");for(let e=0,t=s.length;e<t;++e)s[e]=parseInt(s[e],10);this._PostToDOMMaybeSync("vibrate",{pattern:s})},async InvokeDownload(e,t){if(e&&t){const s=await this._runtime.GetAssetManager().GetProjectFileUrl(e);this._runtime.InvokeDownload(s,t)}},InvokeDownloadString(e,t,s){if(s){const i=`data:${t},`+encodeURIComponent(e);this._runtime.InvokeDownload(i,s)}},ConsoleLog(e,t){t=t.toString(),0===e?console.log(t):1===e?console.warn(t):2===e&&console.error(t)},ConsoleGroup(e){console.group(e)},ConsoleGroupEnd(){console.groupEnd()},ExecJs(jsStr){try{eval(jsStr)}catch(err){console.error("Error executing JavaScript: ",err)}},LockOrientation(e){if(!((e=Math.floor(e))<0||e>=ORIENTATIONS.length)){const t=ORIENTATIONS[e];this._PostToDOMMaybeSync("lock-orientation",{orientation:t})}},UnlockOrientation(){this._PostToDOMMaybeSync("unlock-orientation")},LoadStyleSheet(e){this._runtime.GetAssetManager().LoadStyleSheet(e)},async SetDocumentCSSStyle(e,t,s,i){await this.PostToDOMAsync("set-document-css-style",{prop:C3.CSSToCamelCase(e),value:t,selector:s,"is-all":0!==i})},async GetDocumentCSSStyle(e,t,s){const i=await this.PostToDOMAsync("get-document-css-style",{prop:e,selector:t});i.isOk&&this._cssStyleMap.set(s.toLowerCase(),i.result.trim())},SetHash(e){this.PostToDOM("set-hash",{hash:e})},SetWindowSize(e,t){this.PostToDOM("set-window-size",{windowWidth:e,windowHeight:t})},SetWindowPosition(e,t){this.PostToDOM("set-window-position",{windowX:e,windowY:t})},async RequestInstall(){const e=await this.PostToDOMAsync("request-install");this._installResult=e.result,this.Trigger(C3.Plugins.Browser.Cnds.OnInstallResult)},SetWarnOnClose(e){this._SetWarnOnCloseEnabled(e)}}}{const C3=self.C3;C3.Plugins.Browser.Exps={URL(){return this._runtime.IsInWorker()?this._initLocationStr:location.toString()},Protocol(){return(this._runtime.IsInWorker()?new URL(this._initLocationStr):location).protocol},Domain(){return(this._runtime.IsInWorker()?new URL(this._initLocationStr):location).hostname},Port(){return(this._runtime.IsInWorker()?new URL(this._initLocationStr):location).port},PathName(){return(this._runtime.IsInWorker()?new URL(this._initLocationStr):location).pathname},Hash(){return(this._runtime.IsInWorker()?new URL(this._initLocationStr):location).hash},QueryString(){return(this._runtime.IsInWorker()?new URL(this._initLocationStr):location).search},QueryParam(e){const t=(this._runtime.IsInWorker()?new URL(this._initLocationStr):location).search,s=RegExp("[?&]"+e+"=([^&]*)").exec(t);return s?decodeURIComponent(s[1].replace(/\+/g," ")):""},Referrer(){return this._referrer},Title(){return this._docTitle},Language(){return navigator.language},Platform(){return navigator.platform},UserAgent(){return navigator.userAgent},ExecJS(jsStr){let result=0;try{result=eval(jsStr)}catch(err){console.error("Error executing JavaScript: ",err)}return"number"==typeof result||"string"==typeof result?result:"boolean"==typeof result&&result?1:0},CSSStyleValue(e){return this._cssStyleMap.get(e)||""},Name(){return navigator.appName},Version(){return navigator.appVersion},Product(){return navigator.product},Vendor(){return navigator.vendor},BatteryLevel(){return 1},BatteryTimeLeft(){return 1/0},Bandwidth(){const e=navigator.connection;return e&&(e.downlink||e.downlinkMax||e.bandwidth)||1/0},ConnectionType(){const e=navigator.connection;return e&&e.type||"unknown"},DevicePixelRatio(){return self.devicePixelRatio},ScreenWidth(){return this._screenWidth},ScreenHeight(){return this._screenHeight},WindowInnerWidth(){return this._runtime.GetCanvasManager().GetLastWidth()},WindowInnerHeight(){return this._runtime.GetCanvasManager().GetLastHeight()},WindowOuterWidth(){return this._windowOuterWidth},WindowOuterHeight(){return this._windowOuterWidth},DisplayMode(){return this._runtime.GetCanvasManager().GetCssDisplayMode()},InstallResult(){return this._installResult}}}{const a=self.C3;a.Plugins.LocalStorage=class extends a.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{const d=self.C3;d.Plugins.LocalStorage.Type=class extends d.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const g=self.C3,h="localstorage";g.Plugins.LocalStorage.Instance=class extends g.SDKInstanceBase{constructor(e,t){super(e,h),this._currentKey="",this._lastValue="",this._keyNamesList=[],this._errorMessage="",this._isPersistent=!1,this._pendingGets=0,this._pendingSets=0,this._isInMemoryOnly=!1,t&&(this._isInMemoryOnly=t[0]);const s=this._runtime._GetProjectStorage();this._storage=null,this._isInMemoryOnly?this._storage=s.createInstance({forceInMemoryFallback:!0}):this._storage=s,this._debugCache=new Map,this._isLoadingDebugCache=!1,this._runtime.AddLoadPromise(this._Init())}async _Init(){const e=await Promise.race([this.PostToDOMAsync("init"),g.Wait(3e3)]);e&&(this._isPersistent=e.isPersistent)}Release(){super.Release()}async _TriggerStorageError(e){this._errorMessage=this._GetErrorString(e),await this.TriggerAsync(g.Plugins.LocalStorage.Cnds.OnError)}_GetErrorString(e){return e?"string"==typeof e?e:"string"==typeof e.message?e.message:"string"==typeof e.name?e.name:"string"==typeof e.data?e.data:"unknown error":"unknown error"}GetDebuggerProperties(){return this._isLoadingDebugCache||this._DebugCacheStorage(),[{title:"plugins.localstorage.name",properties:[...this._debugCache.entries()].map(t=>({name:"$"+t[0],value:t[1],onedit:e=>this._storage.setItem(t[0],e)}))}]}async _DebugCacheStorage(){this._isLoadingDebugCache=!0;try{const s=await this._storage.keys(),i=(s.sort((e,t)=>{const s=e.toLowerCase(),i=t.toLowerCase();return s<i?-1:i<s?1:0}),await Promise.all(s.map(e=>this._storage.getItem(e))));this._debugCache.clear();for(let e=0,t=s.length;e<t;++e)this._debugCache.set(s[e],i[e])}catch(e){console.warn("[C3 debugger] Error displaying local storage: ",e)}finally{this._isLoadingDebugCache=!1}}}}{const B=self.C3;B.Plugins.LocalStorage.Cnds={OnItemSet(e){return this._currentKey===e},OnAnyItemSet(){return!0},OnItemGet(e){return this._currentKey===e},OnAnyItemGet(){return!0},OnItemRemoved(e){return this._currentKey===e},OnAnyItemRemoved(){return!0},OnCleared(){return!0},OnAllKeyNamesLoaded(){return!0},OnError(){return!0},OnItemExists(e){return this._currentKey===e},OnItemMissing(e){return this._currentKey===e},CompareKey(e,t){return B.compare(this._currentKey,e,t)},CompareValue(e,t){return B.compare(this._lastValue,e,t)},IsProcessingSets(){return 0<this._pendingSets},IsProcessingGets(){return 0<this._pendingGets},OnAllSetsComplete(){return!0},OnAllGetsComplete(){return!0},IsPersistent(){return this._isPersistent}}}{let IsExpressionType2=function(e){return"string"==typeof e||"number"==typeof e};IsExpressionType=IsExpressionType2;const L=self.C3;L.Plugins.LocalStorage.Acts={async SetItem(e,t){this._pendingSets++;try{const s=await this._storage.setItem(e,t);await this.ScheduleTriggers(async()=>{this._currentKey=e,this._lastValue=s,await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnAnyItemSet),await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnItemSet)})}catch(e){await this._TriggerStorageError(e)}finally{this._pendingSets--,0===this._pendingSets&&await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnAllSetsComplete)}},async SetBinaryItem(e,t){if(t){const s=t.GetFirstPicked(this._inst);if(s){const i=s.GetSdkInstance();if(i){const n=i.GetArrayBufferReadOnly();this._pendingSets++;try{await this._storage.setItem(e,n),await this.ScheduleTriggers(async()=>{this._currentKey=e,this._lastValue="",await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnAnyItemSet),await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnItemSet)})}catch(e){await this._TriggerStorageError(e)}finally{this._pendingSets--,0===this._pendingSets&&await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnAllSetsComplete)}}}}},async GetItem(e){this._pendingGets++;try{const t=await this._storage.getItem(e);await this.ScheduleTriggers(async()=>{this._currentKey=e,this._lastValue=IsExpressionType2(t)?t:"",await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnAnyItemGet),await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnItemGet)})}catch(e){await this._TriggerStorageError(e)}finally{this._pendingGets--,0===this._pendingGets&&await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnAllGetsComplete)}},async GetBinaryItem(t,e){if(e){const s=e.GetFirstPicked(this._inst);if(s){const i=s.GetSdkInstance();this._pendingGets++;try{let e=await this._storage.getItem(t);e=e instanceof ArrayBuffer?e:new ArrayBuffer(0),await this.ScheduleTriggers(async()=>{this._lastValue="",this._currentKey=t,i.SetArrayBufferTransfer(e),await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnAnyItemGet),await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnItemGet)})}catch(e){await this._TriggerStorageError(e)}finally{this._pendingGets--,0===this._pendingGets&&await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnAllGetsComplete)}}}},async CheckItemExists(e){try{const t=await this._storage.getItem(e);await this.ScheduleTriggers(async()=>{this._currentKey=e,null==t?(this._lastValue="",await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnItemMissing)):(this._lastValue=IsExpressionType2(t)?t:"",await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnItemExists))})}catch(e){await this._TriggerStorageError(e)}},async RemoveItem(e){try{await this._storage.removeItem(e),await this.ScheduleTriggers(async()=>{this._currentKey=e,this._lastValue="",await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnAnyItemRemoved),await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnItemRemoved)})}catch(e){await this._TriggerStorageError(e)}},async ClearStorage(){try{await this._storage.clear(),await this.ScheduleTriggers(async()=>{this._currentKey="",this._lastValue="",L.clearArray(this._keyNamesList),await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnCleared)})}catch(e){await this._TriggerStorageError(e)}},async GetAllKeyNames(){try{const e=await this._storage.keys();await this.ScheduleTriggers(async()=>{this._keyNamesList=e,await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnAllKeyNamesLoaded)})}catch(e){await this._TriggerStorageError(e)}},async RequestPersistent(){const e=await this.PostToDOMAsync("request-persistent");e.isOk&&(this._isPersistent=e.isPersistent)},LoadMemoryFromJSON(t){if(this._isInMemoryOnly){let e;try{e=JSON.parse(t)}catch(e){return void console.error("[Local Storage] Failed to parse memory storage JSON: ",e)}e&&e["is-c3-storage"]&&Array.isArray(e.items)||console.error("[Local Storage] Failed to load memory storage JSON: invalid data"),this._storage.SetMemoryStorage(new Map(e.items))}}}}{const qa=self.C3;qa.Plugins.LocalStorage.Exps={ItemValue(){return this._lastValue},Key(){return this._currentKey},KeyCount(){return this._keyNamesList.length},KeyAt(e){return(e=Math.floor(e))<0||e>=this._keyNamesList.length?"":this._keyNamesList[e]},ErrorMessage(){return this._errorMessage},MemoryStorageAsJSON(){return this._isInMemoryOnly?JSON.stringify({"is-c3-storage":!0,items:[...this._storage.GetMemoryStorage()]}):""}}}{const a=self.C3;a.Plugins.Mouse=class extends a.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{let GetMouseSdkInstance2=function(){return t.GetSingleGlobalInstance().GetSdkInstance()};GetMouseSdkInstance=GetMouseSdkInstance2;const d=self.C3,e=self.C3X;d.Plugins.Mouse.Type=class extends d.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}GetScriptInterfaceClass(){return self.IMouseObjectType}};let t=null;self.IMouseObjectType=class extends self.IObjectClass{constructor(e){super(e),(t=e).GetRuntime()._GetCommonScriptInterfaces().mouse=this}getMouseX(e){return GetMouseSdkInstance2().GetMousePositionForLayer(e)[0]}getMouseY(e){return GetMouseSdkInstance2().GetMousePositionForLayer(e)[1]}getMousePosition(e){return GetMouseSdkInstance2().GetMousePositionForLayer(e)}isMouseButtonDown(e){return GetMouseSdkInstance2().IsMouseButtonDown(e)}setCursorStyle(t){e.RequireString(t),GetMouseSdkInstance2().SetCursorStyle(t)}setCursorObjectClass(e){const t=GetMouseSdkInstance2(),s=t.GetRuntime(),i=s._UnwrapIObjectClass(e);t.SetCursorObjectClass(i)}}}{let t=self.C3,u="mouse",a=null;t.Plugins.Mouse.Instance=class extends t.SDKInstanceBase{constructor(e,s){super(e,u),this._buttonMap=[!1,!1,!1,!1,!1],this._mouseXcanvas=0,this._mouseYcanvas=0,this._triggerButton=0,this._triggerType=0,this._triggerDir=0,this._wheelDeltaX=0,this._wheelDeltaY=0,this._wheelDeltaZ=0,this._hasPointerLock=!1,this._movementX=0,this._movementY=0,this.AddDOMMessageHandlers([["pointer-lock-change",e=>this._OnPointerLockChange(e)],["pointer-lock-error",e=>this._OnPointerLockError(e)]]);const i=this.GetRuntime().Dispatcher();this._disposables=new t.CompositeDisposable(t.Disposable.From(i,"pointermove",e=>this._OnPointerMove(e.data)),t.Disposable.From(i,"pointerdown",e=>this._OnPointerDown(e.data)),t.Disposable.From(i,"pointerup",e=>this._OnPointerUp(e.data)),t.Disposable.From(i,"dblclick",e=>this._OnDoubleClick(e.data)),t.Disposable.From(i,"wheel",e=>this._OnMouseWheel(e.data)),t.Disposable.From(i,"window-blur",()=>this._OnWindowBlur()))}Release(){super.Release()}_OnPointerDown(e){"mouse"===e.pointerType&&(this._mouseXcanvas=e.pageX-this._runtime.GetCanvasClientX(),this._mouseYcanvas=e.pageY-this._runtime.GetCanvasClientY(),this._CheckButtonChanges(e.lastButtons,e.buttons))}_OnPointerMove(e){this._movementX=e.movementX,this._movementY=e.movementY,this.Trigger(t.Plugins.Mouse.Cnds.OnMovement),this._movementX=0,this._movementY=0,"mouse"===e.pointerType&&(this._mouseXcanvas=e.pageX-this._runtime.GetCanvasClientX(),this._mouseYcanvas=e.pageY-this._runtime.GetCanvasClientY(),this._CheckButtonChanges(e.lastButtons,e.buttons))}_OnPointerUp(e){"mouse"===e.pointerType&&this._CheckButtonChanges(e.lastButtons,e.buttons)}_CheckButtonChanges(e,t){this._CheckButtonChange(e,t,1,0),this._CheckButtonChange(e,t,4,1),this._CheckButtonChange(e,t,2,2),this._CheckButtonChange(e,t,8,3),this._CheckButtonChange(e,t,16,4)}_CheckButtonChange(e,t,s,i){!(e&s)&&t&s?this._OnMouseDown(i):e&s&&!(t&s)&&this._OnMouseUp(i)}_OnMouseDown(e){this._buttonMap[e]=!0,this.Trigger(t.Plugins.Mouse.Cnds.OnAnyClick),this._triggerButton=e,this._triggerType=0,this.Trigger(t.Plugins.Mouse.Cnds.OnClick),this.Trigger(t.Plugins.Mouse.Cnds.OnObjectClicked)}_OnMouseUp(e){this._buttonMap[e]&&(this._buttonMap[e]=!1,this._triggerButton=e,this.Trigger(t.Plugins.Mouse.Cnds.OnRelease))}_OnDoubleClick(e){this._triggerButton=e.button,this._triggerType=1,this.Trigger(t.Plugins.Mouse.Cnds.OnClick),this.Trigger(t.Plugins.Mouse.Cnds.OnObjectClicked)}_OnMouseWheel(e){this._triggerDir=e.deltaY<0?1:0,this._wheelDeltaX=e.deltaX,this._wheelDeltaY=e.deltaY,this._wheelDeltaZ=e.deltaZ,this.Trigger(t.Plugins.Mouse.Cnds.OnWheel)}_OnWindowBlur(){for(let e=0,s=this._buttonMap.length;e<s;++e){if(!this._buttonMap[e])return;this._buttonMap[e]=!1,this._triggerButton=e,this.Trigger(t.Plugins.Mouse.Cnds.OnRelease)}}GetMousePositionForLayer(e){const t=this._runtime.GetMainRunningLayout(),s=this._mouseXcanvas,i=this._mouseYcanvas;if(void 0===e){const n=t.GetLayerByIndex(0);return n.CanvasCssToLayer_DefaultTransform(s,i)}{const r=t.GetLayer(e);return r?r.CanvasCssToLayer(s,i):[0,0]}}IsMouseButtonDown(e){return e=Math.floor(e),!!this._buttonMap[e]}_IsMouseOverCanvas(){return 0<=this._mouseXcanvas&&0<=this._mouseYcanvas&&this._mouseXcanvas<this._runtime.GetCanvasCssWidth()&&this._mouseYcanvas<this._runtime.GetCanvasCssHeight()}SetCursorStyle(e){a!==e&&(a=e,this.PostToDOM("cursor",e))}async SetCursorObjectClass(e){if(!t.Platform.IsMobile&&e){const s=e.GetFirstPicked();if(s){const i=s.GetWorldInfo(),n=s.GetCurrentImageInfo();if(i&&n&&a!==n){const r=await(a=n).ExtractImageToBlobURL(),o=`url(${r}) ${Math.round(i.GetOriginX()*n.GetWidth())} ${Math.round(i.GetOriginY()*n.GetHeight())}, auto`;this.PostToDOM("cursor",o)}}}}_OnPointerLockChange(e){this._UpdatePointerLockState(e["has-pointer-lock"])}_OnPointerLockError(e){this._UpdatePointerLockState(e["has-pointer-lock"]),this.Trigger(t.Plugins.Mouse.Cnds.OnPointerLockError)}_UpdatePointerLockState(e){this._hasPointerLock!==e&&(this._hasPointerLock=e,this._hasPointerLock?this.Trigger(t.Plugins.Mouse.Cnds.OnPointerLocked):this.Trigger(t.Plugins.Mouse.Cnds.OnPointerUnlocked))}GetDebuggerProperties(){const e="plugins.mouse";return[{title:e+".name",properties:[{name:e+".debugger.absolute-position",value:this._mouseXcanvas+","+this._mouseYcanvas},{name:e+".debugger.left-button",value:this._buttonMap[0]},{name:e+".debugger.middle-button",value:this._buttonMap[1]},{name:e+".debugger.right-button",value:this._buttonMap[2]},{name:e+".debugger.button-4",value:this._buttonMap[3]},{name:e+".debugger.button-5",value:this._buttonMap[4]}]},{title:e+".debugger.position-on-each-layer",properties:this._runtime.GetMainRunningLayout().GetLayers().map(e=>({name:"$"+e.GetName(),value:e.CanvasCssToLayer(this._mouseXcanvas,this._mouseYcanvas).join(", ")}))}]}}}{const na=self.C3;na.Plugins.Mouse.Cnds={OnClick(e,t){return this._triggerButton===e&&this._triggerType===t},OnAnyClick(){return!0},IsButtonDown(e){return this._buttonMap[e]},OnRelease(e){return this._triggerButton===e},IsOverObject(e){const t=this._runtime.GetCurrentCondition(),s=t.IsInverted(),i=[];return this._IsMouseOverCanvas()&&i.push([this._mouseXcanvas,this._mouseYcanvas]),na.xor(this._runtime.GetCollisionEngine().TestAndSelectCanvasPointOverlap(e,i,s),s)},OnObjectClicked(e,t,s){if(e!==this._triggerButton||t!==this._triggerType)return!1;if(!this._IsMouseOverCanvas())return!1;const i=this._mouseXcanvas,n=this._mouseYcanvas;return this._runtime.GetCollisionEngine().TestAndSelectCanvasPointOverlap(s,[[i,n]],!1)},OnWheel(e){return 2===e||this._triggerDir===e},OnPointerLocked(){return!0},OnPointerUnlocked(){return!0},OnPointerLockError(){return!0},HasPointerLock(){return this._hasPointerLock},OnMovement(){return!0}}}{const Ca=self.C3,Da=["auto","pointer","text","crosshair","move","help","wait","none"],Ea=["auto","all-scroll","none","help","pointer","progress","wait","cell","crosshair","text","vertical-text","alias","copy","move","not-allowed","grab","grabbing","col-resize","row-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out"];Ca.Plugins.Mouse.Acts={SetCursor(e){this.SetCursorStyle(Da[e])},SetCursor2(e){this.SetCursorStyle(Ea[e])},SetCursorSprite(e){this.SetCursorObjectClass(e)},RequestPointerLock(e){this._PostToDOMMaybeSync("request-pointer-lock",{unadjustedMovement:e})},ReleasePointerLock(){this.PostToDOM("release-pointer-lock")}}}{const Ja=self.C3;Ja.Plugins.Mouse.Exps={X(e){return this.GetMousePositionForLayer(e)[0]},Y(e){return this.GetMousePositionForLayer(e)[1]},AbsoluteX(){return this._mouseXcanvas},AbsoluteY(){return this._mouseYcanvas},MovementX(){return this._movementX},MovementY(){return this._movementY},WheelDeltaX(){return this._wheelDeltaX},WheelDeltaY(){return this._wheelDeltaY},WheelDeltaZ(){return this._wheelDeltaZ}}}{const a=self.C3;a.Plugins.PlatformInfo=class extends a.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{const d=self.C3;d.Plugins.PlatformInfo.Type=class extends d.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const g=self.C3,h="platform-info";g.Plugins.PlatformInfo.Instance=class extends g.SDKInstanceBase{constructor(e,t){super(e,h),this._screenWidth=0,this._screenHeight=0,this._windowOuterWidth=0,this._windowOuterHeight=0,this._safeAreaInset=[0,0,0,0],this._supportsWakeLock=!1,this._isWakeLockActive=!1,this.AddDOMMessageHandlers([["window-resize",e=>this._OnWindowResize(e)],["wake-lock-acquired",e=>this._OnWakeLockAcquired(e)],["wake-lock-error",e=>this._OnWakeLockError(e)],["wake-lock-released",e=>this._OnWakeLockReleased(e)]]),navigator.connection&&navigator.connection.addEventListener("change",()=>this._OnNetworkChange()),this._runtime.AddLoadPromise(this.PostToDOMAsync("get-initial-state").then(e=>{this._screenWidth=e.screenWidth,this._screenHeight=e.screenHeight,this._windowOuterWidth=e.windowOuterWidth,this._windowOuterHeight=e.windowOuterHeight,this._safeAreaInset=e.safeAreaInset,this._supportsWakeLock=e.supportsWakeLock}))}Release(){super.Release()}_OnWindowResize(e){this._windowOuterWidth=e.windowOuterWidth,this._windowOuterHeight=e.windowOuterHeight,this._safeAreaInset=e.safeAreaInset}async _OnNetworkChange(){await this.TriggerAsync(g.Plugins.PlatformInfo.Cnds.OnNetworkChange)}async _OnWakeLockAcquired(){this._isWakeLockActive=!0,await this.TriggerAsync(g.Plugins.PlatformInfo.Cnds.OnWakeLockAcquired)}async _OnWakeLockError(){this._isWakeLockActive=!1,await this.TriggerAsync(g.Plugins.PlatformInfo.Cnds.OnWakeLockError)}async _OnWakeLockReleased(){this._isWakeLockActive=!1,await this.TriggerAsync(g.Plugins.PlatformInfo.Cnds.OnWakeLockReleased)}}}{const r=self.C3;r.Plugins.PlatformInfo.Cnds={IsOnMobile(){return r.Platform.IsMobile},IsOnWindows(){return"Windows"===r.Platform.OS},IsOnMacOS(){return"macOS"===r.Platform.OS},IsOnLinux(){return"Linux"===r.Platform.OS},IsOnChromeOS(){return"Chrome OS"===r.Platform.OS},IsOnAndroid(){return"Android"===r.Platform.OS},IsOniOS(){return"iOS"===r.Platform.OS},IsWebExport(){const e=this._runtime.GetExportType();return"html5"===e||"scirra-arcade"===e||"preview"===e||"instant-games"===e},IsCordovaExport(){return this._runtime.IsCordova()},IsNWjsExport(){return this._runtime.IsNWjs()},IsWindowsUWPExport(){return"windows-uwp"===this._runtime.GetExportType()},IsWindowsWebView2Export(){return this._runtime.IsWindowsWebView2()},IsMacOSWKWebView2Export(){return"macos-wkwebview"===this._runtime.GetExportType()},IsLinuxCEFExport(){return"linux-cef"===this._runtime.GetExportType()},OnNetworkChange(){return!0},OnWakeLockAcquired(){return!0},OnWakeLockError(){return!0},OnWakeLockReleased(){return!0},IsWakeLockActive(){return this._isWakeLockActive},IsWakeLockSupported(){return this._supportsWakeLock}}}{const t=self.C3;t.Plugins.PlatformInfo.Acts={RequestWakeLock(){this._supportsWakeLock&&this._PostToDOMMaybeSync("request-wake-lock")},ReleaseWakeLock(){this._supportsWakeLock&&(this._isWakeLockActive=!1,this.PostToDOM("release-wake-lock"))}}}{const u=self.C3;u.Plugins.PlatformInfo.Exps={Renderer(){return this._runtime.GetCanvasManager().GetRendererString()},RendererDetail(){return this._runtime.GetCanvasManager().GetRendererDetailString()},DevicePixelRatio(){return this._runtime.GetDevicePixelRatio()},ScreenWidth(){return this._screenWidth},ScreenHeight(){return this._screenHeight},WindowInnerWidth(){return this._runtime.GetCanvasManager().GetLastWidth()},WindowInnerHeight(){return this._runtime.GetCanvasManager().GetLastHeight()},WindowOuterWidth(){return this._windowOuterWidth},WindowOuterHeight(){return this._windowOuterHeight},CanvasCssWidth(){return this._runtime.GetCanvasManager().GetCssWidth()},CanvasCssHeight(){return this._runtime.GetCanvasManager().GetCssHeight()},CanvasDeviceWidth(){return this._runtime.GetCanvasManager().GetDeviceWidth()},CanvasDeviceHeight(){return this._runtime.GetCanvasManager().GetDeviceHeight()},Downlink(){return navigator.connection&&navigator.connection.downlink||0},DownlinkMax(){return navigator.connection&&navigator.connection.downlinkMax||0},ConnectionType(){return navigator.connection&&navigator.connection.type||"unknown"},ConnectionEffectiveType(){return navigator.connection&&navigator.connection.effectiveType||"unknown"},ConnectionRTT(){return navigator.connection&&navigator.connection.rtt||0},HardwareConcurrency(){return navigator.hardwareConcurrency||0},DeviceMemory(){return navigator.deviceMemory||0},SafeAreaInsetTop(){return this._safeAreaInset[0]},SafeAreaInsetRight(){return this._safeAreaInset[1]},SafeAreaInsetBottom(){return this._safeAreaInset[2]},SafeAreaInsetLeft(){return this._safeAreaInset[3]},FramesPerSecond(){return this._runtime.GetFramesPerSecond()},TicksPerSecond(){return this._runtime.GetTicksPerSecond()}}}{const a=self.C3;a.Plugins.Timeline=class extends a.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{let GetTCInst2=function(){return l.GetSingleGlobalInstance().GetSdkInstance()},GetTimelineParameter2=function(e){if("string"==typeof e){const t=i.GetTimelineByName(e);if(t)return t;throw new Error(`invalid timeline name '${e}'`)}if(e instanceof self.ITimelineState)return l.GetRuntime()._UnwrapScriptInterface(e);throw new Error("invalid timeline parameter")},ValidateTags2=function(e,t=!1){if(!(t&&null==e||"string"==typeof e||Array.isArray(e)))throw new Error("invalid tags")};GetTCInst=GetTCInst2,GetTimelineParameter=GetTimelineParameter2,ValidateTags=ValidateTags2;const d=self.C3,e=self.C3X;d.Plugins.Timeline.Type=class extends d.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}GetScriptInterfaceClass(){return self.ITimelineControllerObjectType}};let l=null,i=null;self.ITimelineControllerObjectType=class extends self.IObjectClass{constructor(e){super(e),l=e,i=e.GetRuntime().GetTimelineManager(),e.GetRuntime()._GetCommonScriptInterfaces().timelineController=this}setInstances(t,s){let i=l.GetRuntime(),n;if(t instanceof self.IWorldInstance)n=[i._UnwrapIWorldInstance(t)];else{if(!Array.isArray(t))throw new TypeError("invalid instances");n=t.map(e=>i._UnwrapIWorldInstance(e))}if(0!==n.length){e.RequireOptionalString(s);const r=n[0].GetObjectClass();GetTCInst2()._SetInstancesForNextPlay(r,n,s??"")}}play(e,t){const s=GetTimelineParameter2(e);return ValidateTags2(t,!0),GetTCInst2()._PlayTimeline(s,t??[]),s.GetITimelineState()}*allTimelines(){for(const e of i.GetTimelines())yield e.GetITimelineState()}*timelinesByTags(e){ValidateTags2(e);for(const t of i.GetTimelinesByTags(e))yield t.GetITimelineState()}}}{const B=self.C3;B.Plugins.Timeline.Instance=class extends B.SDKInstanceBase{constructor(e,t){super(e),this._nextTimelineObjectClasses=new Map,this.GetRuntime().GetTimelineManager().SetPluginInstance(e)}Release(){super.Release()}_SetTimelineInstanceObjects(e,t){for(const s of e)t.SetTrackInstance(s.trackId,s.instance)}_GetTimelineInstanceObjects(){const e=[],n=(e,t,s)=>{const i=t.pickedInstances[t.startIndex];if(i)return t.startIndex++,e.usedObjectClassInstances.includes(i)||i.IsDestroyed()?n(e,t,s):(e.usedObjectClassInstances.push(i),{trackId:s,instance:i})};for(const t of this._nextTimelineObjectClasses.values())for(const[s,i]of t.trackIdPickedInstances.entries()){const r=n(t,i,s);r&&e.push(r)}return e}_SetInstancesForNextPlay(e,t,s){if(e.IsFamily()&&(e=e.GetFirstPicked().GetObjectClass()),this._nextTimelineObjectClasses.has(e)){const i=this._nextTimelineObjectClasses.get(e).trackIdPickedInstances;if(i.has(s)){const n=new Set([...i.get(s).pickedInstances,...t]);i.set(s,{startIndex:0,pickedInstances:Array.from(n)})}else i.set(s,{startIndex:0,pickedInstances:t})}else this._nextTimelineObjectClasses.set(e,{usedObjectClassInstances:[],trackIdPickedInstances:new Map([[s,{startIndex:0,pickedInstances:t}]])})}_UnsetInstancesForNextPlay(){this._nextTimelineObjectClasses&&this._nextTimelineObjectClasses.clear()}async _PlayTimeline(n,r,e){if(n){let t=this._runtime.GetTimelineManager(),s,i=[];if(this._nextTimelineObjectClasses.size){let e=this._GetTimelineInstanceObjects();for(;e.length&&((s=t.GetTimelineOfTemplateForInstances(n,e))||((s=t.CreateFromTemplate(n)).ClearTrackInstances(),this._SetTimelineInstanceObjects(e,s)),s.SetTags(r),s.Play()&&i.push(s.GetPlayPromise()),e=this._GetTimelineInstanceObjects()),e.length;);}else n.SetTags(r),n.Play()&&i.push(n.GetPlayPromise());e||this._nextTimelineObjectClasses.clear(),await Promise.all(i)}else e||this._nextTimelineObjectClasses.clear()}}}{let ca=self.C3,t=[],i=[];ca.Plugins.Timeline.Cnds={PushTriggerTimeline(e){t.push(e)},PopTriggerTimeline(){t.pop()},GetTriggerTimeline(){return t[t.length-1]},PushTriggerKeyframe(e){i.push(e)},PopTriggerKeyframe(e){i.pop()},GetTriggerKeyframe(){return i[i.length-1]},OnTimelineStarted(e){return ca.Plugins.Timeline.Cnds.GetTriggerTimeline()===e},OnTimelineStartedByName(e){const t=ca.Plugins.Timeline.Cnds.GetTriggerTimeline();if(t){const s=this._runtime.GetTimelineManager();for(const i of s.GetTimelinesByName(e))if(ca.equalsNoCase(t.GetName(),i.GetName()))return!0}return!1},OnTimelineStartedByTags(e){const t=ca.Plugins.Timeline.Cnds.GetTriggerTimeline();if(t){const s=this._runtime.GetTimelineManager();for(const i of s.GetTimelinesByTags(e))if(i.HasTags(t.GetTags()))return!0}return!1},OnAnyTimelineStarted(){return!0},OnTimelineFinished(e){return ca.Plugins.Timeline.Cnds.GetTriggerTimeline()===e},OnTimelineFinishedByName(e){const t=ca.Plugins.Timeline.Cnds.GetTriggerTimeline();if(t){const s=this._runtime.GetTimelineManager();for(const i of s.GetTimelinesByName(e))if(ca.equalsNoCase(t.GetName(),i.GetName()))return!0}return!1},OnTimelineFinishedByTags(e){const t=ca.Plugins.Timeline.Cnds.GetTriggerTimeline();if(t){const s=this._runtime.GetTimelineManager();for(const i of s.GetTimelinesByTags(e))if(i.HasTags(t.GetTags()))return!0}return!1},OnAnyTimelineFinished(){return!0},IsPlaying(e){return e.IsPlaying()},IsPlayingByName(e){const t=this._runtime.GetTimelineManager();for(const s of t.GetTimelinesByName(e))if(s.IsPlaying())return!0;return!1},IsPlayingByTags(e){const t=this._runtime.GetTimelineManager();for(const s of t.GetTimelinesByTags(e))if(s.IsPlaying())return!0;return!1},IsAnyPlaying(){const e=[...this._runtime.GetTimelineManager().GetTimelines()];if(e)return e.some(e=>e.IsPlaying())},IsPaused(e){return e.IsPaused()},IsPausedByName(e){const t=this._runtime.GetTimelineManager();for(const s of t.GetTimelinesByName(e))if(s.IsPaused())return!0;return!1},IsPausedByTags(e){const t=this._runtime.GetTimelineManager();for(const s of t.GetTimelinesByTags(e))if(s.IsPaused())return!0;return!1},IsAnyPaused(){const e=[...this._runtime.GetTimelineManager().GetTimelines()];if(e)return e.some(e=>e.IsPaused())},OnTimeSet(e){return ca.Plugins.Timeline.Cnds.GetTriggerTimeline()===e},OnTimeSetByName(e){const t=ca.Plugins.Timeline.Cnds.GetTriggerTimeline();if(t){const s=this._runtime.GetTimelineManager();for(const i of s.GetTimelinesByName(e))if(t===i)return!0}return!1},OnTimeSetByTags(e){const t=ca.Plugins.Timeline.Cnds.GetTriggerTimeline();if(t){const s=this._runtime.GetTimelineManager();for(const i of s.GetTimelinesByTags(e))if(t===i)return!0}return!1},OnAnyKeyframeReached(){return!!ca.Plugins.Timeline.Cnds.GetTriggerKeyframe()},OnKeyframeReached(e,t){const s=ca.Plugins.Timeline.Cnds.GetTriggerKeyframe();if(!s)return!1;if(0===s.GetTags().length||!e)return!1;const i=e?e.split(" "):[];if(0===t){for(const n of i)if(s.HasTag(n))return!0;return!1}for(const r of i)if(!s.HasTag(r))return!1;return!0}}}{const f0=self.C3;f0.Plugins.Timeline.Acts={PlayTimeline(e,t){return this._PlayTimeline(e,t,!1)},async PlayTimelineByName(e,t){const s=this._runtime.GetTimelineManager(),i=[];for(const n of s.GetTimelinesByName(e))i.push(this._PlayTimeline(n,t,!0));this._nextTimelineObjectClasses.clear(),await Promise.all(i)},async PlayAllTimelines(){const e=this._runtime.GetTimelineManager(),t=[];for(const s of e.GetTimelines())s.Play()&&t.push(s.GetPlayPromise());this._nextTimelineObjectClasses.clear(),await Promise.all(t)},PauseTimeline(e){e&&e.Stop()},PauseTimelineByName(e){const t=this._runtime.GetTimelineManager();for(const s of t.GetTimelinesByName(e))f0.Plugins.Timeline.Acts.PauseTimeline.call(this,s)},PauseTimelineByTags(e){const t=this._runtime.GetTimelineManager();for(const s of t.GetTimelinesByTags(e))f0.Plugins.Timeline.Acts.PauseTimeline.call(this,s)},PauseAllTimelines(){const e=this._runtime.GetTimelineManager();for(const t of e.GetTimelines())t.Stop()},ResumeTimeline(e){e&&e.Resume()},ResumeTimelineByName(e){const t=this._runtime.GetTimelineManager();for(const s of t.GetTimelinesByName(e))f0.Plugins.Timeline.Acts.ResumeTimeline.call(this,s)},ResumeTimelineByTags(e){const t=this._runtime.GetTimelineManager();for(const s of t.GetTimelinesByTags(e))f0.Plugins.Timeline.Acts.ResumeTimeline.call(this,s)},ResumeAllTimelines(){const e=this._runtime.GetTimelineManager();for(const t of e.GetTimelines())t.Resume()},StopTimeline(e){e&&e.Reset()},StopTimelineByName(e){const t=this._runtime.GetTimelineManager();for(const s of t.GetTimelinesByName(e))f0.Plugins.Timeline.Acts.StopTimeline.call(this,s)},StopTimelineByTags(e){const t=this._runtime.GetTimelineManager();for(const s of t.GetTimelinesByTags(e))f0.Plugins.Timeline.Acts.StopTimeline.call(this,s)},StopAllTimelines(){const e=this._runtime.GetTimelineManager();for(const t of e.GetTimelines())t.Reset()},SetTimelineTime(e,t){if(e)if(f0.IsFiniteNumber(t))e.SetTime(t);else if(f0.IsString(t)){const s=e.GetKeyframeWithTags(t);s?e.SetTime(s.GetTime()):f0.Plugins.Timeline.Acts.SetTimelineTime.call(this,e,Number(t))}},SetTimelineTimeByName(e,t){const s=this._runtime.GetTimelineManager();for(const i of s.GetTimelinesByName(e))f0.Plugins.Timeline.Acts.SetTimelineTime.call(this,i,t)},SetTimelineTimeByTags(e,t){const s=this._runtime.GetTimelineManager();for(const i of s.GetTimelinesByTags(e))f0.Plugins.Timeline.Acts.SetTimelineTime.call(this,i,t)},SetTimelinePlaybackRate(e,t){e&&e.SetPlaybackRate(t)},SetTimelinePlaybackRateByName(e,t){const s=this._runtime.GetTimelineManager();for(const i of s.GetTimelinesByName(e))f0.Plugins.Timeline.Acts.SetTimelinePlaybackRate.call(this,i,t)},SetTimelinePlaybackRateByTags(e,t){const s=this._runtime.GetTimelineManager();for(const i of s.GetTimelinesByTags(e))f0.Plugins.Timeline.Acts.SetTimelinePlaybackRate.call(this,i,t)},SetInstance(e,t){const s=[...e.GetCurrentSol().GetInstances()];this._SetInstancesForNextPlay(e,s,t)},UnsetInstances(){this._UnsetInstancesForNextPlay()}}}{const nb=self.C3;nb.Plugins.Timeline.Exps={Time(e){const t=this._runtime.GetTimelineManager();for(const s of t.GetTimelinesByName(e))return s.GetTime();for(const i of t.GetTimelinesByTags(e))return i.GetTime();return 0},TotalTime(e){const t=this._runtime.GetTimelineManager();for(const s of t.GetTimelinesByName(e))return s.GetTotalTime();for(const i of t.GetTimelinesByTags(e))return i.GetTotalTime();return 0},Progress(e){const t=this._runtime.GetTimelineManager();for(const s of t.GetTimelinesByName(e))return s.GetTime()/s.GetTotalTime();for(const i of t.GetTimelinesByTags(e))return i.GetTime()/i.GetTotalTime();return 0},KeyframeTags(){const e=nb.Plugins.Timeline.Cnds.GetTriggerKeyframe();return e?e.GetTags().join(" "):""},TimelineName(){const e=nb.Plugins.Timeline.Cnds.GetTriggerTimeline();return e?e.GetName():""},TimelineTags(){const e=nb.Plugins.Timeline.Cnds.GetTriggerTimeline();return e?e.GetStringTags():""},Value(e,t){const s=this._runtime.GetTimelineManager();for(const i of s.GetTimelinesByName(e)){let e=i.GetTrackByName(t);if(e){const n=e.GetPropertyTrack("value");if(n)return n.GetSourceAdapterValue()}else{let e=i.GetTrackById(t);if(e){const r=e.GetPropertyTrack("value");if(r)return r.GetSourceAdapterValue()}}}for(const a of s.GetTimelinesByTags(e)){let e=a.GetTrackByName(t);if(e){const o=e.GetPropertyTrack("value");if(o)return o.GetSourceAdapterValue()}else{let e=a.GetTrackById(t);if(e){const l=e.GetPropertyTrack("value");if(l)return l.GetSourceAdapterValue()}}}return 0},Ease(e,t){1<=(t=t<0?0:t)&&(t=1);const s=self.Ease.ToInternal(e);if(s)return self.Ease.GetRuntimeEase(s)(t,0,1,1);{const i=self.Ease.GetRuntimeEase(e);if(i)return i(t,0,1,1)}return console.warn("[TimelineController.Ease expression] no matching built-in or custom ease function found, returning 0"),0}}}{let MaybeCloseImageBitmap2=function(e){e&&e.close&&e.close()};MaybeCloseImageBitmap=MaybeCloseImageBitmap2;const a=self.C3,b="video";a.Plugins.video=class extends a.SDKDOMPluginBase{constructor(e){super(e,b),this._postImageBitmaps=!1,this._supportedFormats={},this._lastStateSequenceNumber=-1,this._videoState=new Map,this._runtime.AddLoadPromise(this._runtime.PostComponentMessageToDOMAsync("video","init",{isInWorker:this._runtime.IsInWorker()}).then(e=>{this._postImageBitmaps=e.postImageBitmaps,this._supportedFormats=e.supportedFormats})),this.AddElementMessageHandler("playback-event",(e,t)=>e._OnPlaybackEvent(t)),this._runtime.AddDOMComponentMessageHandler(b,"state",e=>this._OnUpdateState(e))}Release(){super.Release()}IsPostImageBitmapsMode(){return this._postImageBitmaps}IsFormatSupported(e){return!!this._supportedFormats[e]}_OnUpdateState(e){const t=e.sequenceNumber;if(t<=this._lastStateSequenceNumber)for(const s of Object.values(e.videoData))MaybeCloseImageBitmap2(s.imageBitmap);else{this._lastStateSequenceNumber=t;for(const i of this._videoState.values())MaybeCloseImageBitmap2(i.imageBitmap);this._videoState.clear();for(const[n,r]of Object.entries(e.videoData))this._videoState.set(parseInt(n,10),r)}}_DeleteVideoState(e){this._videoState.delete(e)}GetVideoState(e){return this._videoState.get(e)||null}}}{const s=self.C3;s.Plugins.video.Type=class extends s.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const v=self.C3,w=v.New(v.Rect),x=v.New(v.Quad),y="video",z=["webm-vp8","webm-vp9","webm-av1","mp4-h264","mp4-h265","mp4-av1"];v.Plugins.video.Instance=class extends v.SDKDOMInstanceBase{constructor(e,t){super(e,y),this._primarySrc="",this._primaryFormat="mp4-h264",this._secondarySrc="",this._secondaryFormat="webm-vp9",this._autoplay=2,this._playInBackground=!1,this._videoWasPlayingOnSuspend=!1,this._webGLTexture=null,this._currentTrigger=-1,this._isSettingSource=0,this._isPlaying=!1,this._isPaused=!1,this._hasEnded=!1,this._isLooping=!1,this._isMuted=!1,this._volume=0,t&&(this._primarySrc=t[0],this._primaryFormat=z[t[1]],this._secondarySrc=t[2],this._secondaryFormat=z[t[3]],this._autoplay=t[4],this._playInBackground=t[5],this.GetWorldInfo().SetVisible(t[6]));const s=this._runtime.Dispatcher();this._disposables=new v.CompositeDisposable(v.Disposable.From(s,"renderercontextlost",()=>this._OnRendererContextLost()),v.Disposable.From(s,"suspend",()=>this._OnSuspend()),v.Disposable.From(s,"resume",()=>this._OnResume())),this.CreateElement({src:this.GetVideoSource(),autoplay:this._autoplay})}Release(){this.GetPlugin()._DeleteVideoState(this.GetElementId()),this._ReleaseTexture(),super.Release()}_MaybeCreateTexture(e,t,s){if(this._webGLTexture){if(this._webGLTexture.GetWidth()===t||this._webGLTexture.GetHeight()===s)return;this._ReleaseTexture()}this._webGLTexture=e.CreateDynamicTexture(t,s,{sampling:this._runtime.GetSampling(),mipMap:!1})}_ReleaseTexture(){this._webGLTexture&&(this._runtime.GetRenderer().DeleteTexture(this._webGLTexture),this._webGLTexture=null)}GetElementState(){return{}}DbToLinearNoCap(e){return Math.pow(10,e/20)}DbToLinear(e){const t=this.DbToLinearNoCap(e);return isFinite(t)?Math.max(Math.min(t,1),0):0}LinearToDbNoCap(e){return Math.log(e)/Math.log(10)*20}LinearToDb(e){return this.LinearToDbNoCap(Math.max(Math.min(e,1),0))}GetVideoSource(){let e="",t=this.GetPlugin();return t.IsFormatSupported(this._primaryFormat)&&this._primarySrc?e=this._primarySrc:t.IsFormatSupported(this._secondaryFormat)&&this._secondarySrc&&(e=this._secondarySrc),e&&(v.IsRelativeURL(e)?this._runtime.GetAssetManager().GetMediaFileUrl(e):e)}_OnRendererContextLost(){this._webGLTexture=null}async _OnPlaybackEvent(e){const t=e.type;5===t?this._SetIsPlaying(!0):2===t?(this._SetIsPlaying(!1),this._hasEnded=!0,this._isPaused=!1):6===t&&(this._SetIsPlaying(!1),this._isPaused=!0,this._hasEnded=!1),this._currentTrigger=t,await this.TriggerAsync(v.Plugins.video.Cnds.OnPlaybackEvent)}_SetIsPlaying(e){this._isPlaying=!!e,this._isPlaying?(this._StartTicking(),this._isPaused=!1,this._hasEnded=!1):this._StopTicking()}_OnSuspend(){this._playInBackground||this._isPlaying&&(this._videoWasPlayingOnSuspend=!0,this.PostToDOMElement("pause"))}_OnResume(){this._playInBackground||this._videoWasPlayingOnSuspend&&(this.PostToDOMElement("play"),this._videoWasPlayingOnSuspend=!1)}Draw(l){let h=this.GetWorldInfo(),c=0,u=0,_=null,d=this.GetPlugin().IsPostImageBitmapsMode();if(d){const e=this.GetMyState();if(!e)return;_=e.imageBitmap,e.imageBitmap=null,c=e.videoWidth,u=e.videoHeight}else{const t=self.C3Video_GetElement(this.GetElementId());if(!t)return;c=t.videoWidth,u=t.videoHeight,_=t}if(!(c<=0||u<=0)){this._MaybeCreateTexture(l,c,u),_&&(l.UpdateTexture(_,this._webGLTexture),d)&&_.close&&_.close();let e=c/u,t=h.GetWidth(),s=h.GetHeight(),i=t/s,n=0,r=0,a=0,o=0;e<i?(a=s*e,o=s,n=Math.max(Math.floor((t-a)/2),0)):(a=t,o=t/e,r=Math.max(Math.floor((s-o)/2),0)),l.SetTexture(this._webGLTexture),w.setWH(h.GetX()+n,h.GetY()+r,a,o),x.setFromRect(w),l.Quad(x)}}Tick(){this._runtime.UpdateRender()}GetMyState(){return this.GetPlugin().GetVideoState(this.GetElementId())}}}{const fa=self.C3;fa.Plugins.video.Cnds={IsPlaying(){return this._isPlaying},IsPaused(){return this._isPaused},HasEnded(){return this._hasEnded},IsMuted(){return this._isMuted},OnPlaybackEvent(e){return this._currentTrigger===e}}}{const ha=self.C3,ia=["webm-vp8","webm-vp9","webm-av1","mp4-h264","mp4-h265","mp4-av1"];ha.Plugins.video.Acts={SetSource(e,t){this._primarySrc=e,this._primaryFormat="webm-vp8",this._secondarySrc=t,this._secondaryFormat="mp4-h264",this.PostToDOMElement("set-source",{src:this.GetVideoSource()}),this._ReleaseTexture()},SetSource2(e,t,s,i){this._primarySrc=e,this._primaryFormat=ia[t],this._secondarySrc=s,this._secondaryFormat=ia[i],this.PostToDOMElement("set-source",{src:this.GetVideoSource()}),this._ReleaseTexture()},SetPlaybackTime(e){this.PostToDOMElement("set-playback-time",{time:e})},SetPlaybackRate(e){this.PostToDOMElement("set-playback-rate",{rate:e})},SetLooping(e){this._isLooping!==(e=0!==e)&&(this._isLooping=e,this.PostToDOMElement("set-looping",{isLooping:e}))},SetMuted(e){this._isMuted!==(e=0!==e)&&(this._isMuted=e,this.PostToDOMElement("set-muted",{isMuted:e}))},SetVolume(e){this._volume!==e&&(this._volume=e,this.PostToDOMElement("set-volume",{volume:this.DbToLinear(e)}))},Pause(){this.PostToDOMElement("pause")},Play(){this._PostToDOMElementMaybeSync("play")}}}{const ua=self.C3;ua.Plugins.video.Exps={PlaybackTime(){const e=this.GetMyState();return e?e.currentTime:0},PlaybackRate(){const e=this.GetMyState();return e?e.playbackRate:1},Duration(){const e=this.GetMyState();return e?e.duration:0},Volume(){return this._volume},VideoWidth(){const e=this.GetMyState();return e?e.videoWidth:0},VideoHeight(){const e=this.GetMyState();return e?e.videoHeight:0}}}{const a=self.C3;a.Plugins.Particles=class extends a.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{const d=self.C3;d.Plugins.Particles.Type=class extends d.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){this.GetImageInfo().LoadAsset(this._runtime)}LoadTextures(e){return this.GetImageInfo().LoadStaticTexture(e,{sampling:this._runtime.GetSampling()})}ReleaseTextures(){this.GetImageInfo().ReleaseTexture()}}}{let GetParticleEngine2=function(e){return H.get(e).GetParticleEngine()};GetParticleEngine=GetParticleEngine2;const h=self.C3,i=self.C3X,j=0,k=1,l=2,m=3,n=4,o=5,p=6,q=7,r=8,s=9,t=10,u=11,v=12,w=13,x=14,y=15,z=16,A=17,B=18,C=19,D=20,E=0,F=1,G=h.New(h.Rect),H=(h.Plugins.Particles.Instance=class extends h.SDKWorldInstanceBase{constructor(e,i){super(e),this._isFirstTick=!0;const a=h.New(self.ParticleEngine);(this._particleEngine=a).ononeshotfinish=()=>this._OnOneShotFinish(),this._spawnObjectClass=null,this._particleUpdateCallback=(e,t,s,i,n,r)=>this._OnParticleUpdate(e,t,s,i,n,r),this._particleDestroyCallback=e=>this._OnParticleDestroy(e);let c=this._hasAnyDefaultParticle=!0;i&&(a.SetRate(i[j]),a.SetSprayCone(h.toRadians(i[k])),a.SetSprayType(i[l]?"one-shot":"continuous-spray"),this._SetParticleObjectClass(this._runtime.GetObjectClassBySID(i[m])),c=i[n],a.SetInitSpeed(i[o]),a.SetInitSize(i[p]),a.SetInitOpacity(i[q]/100),a.SetGrowRate(i[r]),a.SetInitXRandom(i[s]),a.SetInitYRandom(i[t]),a.SetInitSpeedRandom(i[u]),a.SetInitSizeRandom(i[v]),a.SetGrowRandom(i[w]),a.SetAcceleration(i[x]),a.SetGravity(i[y]),a.SetLifeAngleRandom(i[z]),a.SetLifeSpeedRandom(i[A]),a.SetLifeOpacityRandom(i[B]),a.SetDestroyModeIndex(i[C]),a.SetTimeout(i[D])),this._UpdateEngineParameters(),this._spawnObjectClass&&(this._hasAnyDefaultParticle=!1),"one-shot"===a.GetSprayType()?a.CreateOneShotSpray():a.SetSpraying(!0);const _=this.GetWorldInfo();_.SetVisible(c),_.SetBboxChangeEventEnabled(!0),this._inst.Dispatcher().addEventListener("bboxchange",()=>{_.OverwriteBoundingBox(this._particleEngine.GetBoundingBox())}),this.GetRuntime().GetRenderer().IsWebGPU()&&_.SetUsePointsShaderProgram(),this._afterLoad=e=>this._OnAfterLoad(e),this.GetRuntime().Dispatcher().addEventListener("afterload",this._afterLoad),this._StartTicking()}Release(){this.GetRuntime().Dispatcher().removeEventListener("afterload",this._afterLoad),this._afterLoad=null,this._particleEngine.Release(),this._particleEngine=null,this._particleUpdateCallback=null,this._particleDestroyCallback=null,super.Release()}GetParticleEngine(){return this._particleEngine}_SetRate(e){this._particleEngine.SetRate(e),"one-shot"===this._particleEngine.GetSprayType()&&this._isFirstTick&&this._particleEngine.SetParticleCount(e)}_SetParticleObjectClass(e){(e=e===this.GetObjectClass()?null:e)===this._spawnObjectClass||(this._spawnObjectClass=e,this._particleEngine.onparticlecreate=e?e=>this._OnParticleCreate(e):null,this._spawnObjectClass)||(this._hasAnyDefaultParticle=!0)}_UpdateEngineParameters(){const e=this._particleEngine,t=this.GetWorldInfo();e.SetMasterOpacity(t.GetOpacity()),e.SetPixelRounding(this._runtime.IsPixelRoundingEnabled()),e.SetSpawnX(t.GetX()),e.SetSpawnY(t.GetY()),e.SetSpawnAngle(t.GetAngle()),e.SetInitSizeScale(Math.abs(t.GetSceneGraphScale()))}_OnOneShotFinish(){this._runtime.DestroyInstance(this._inst)}Draw(e){if(this._hasAnyDefaultParticle){const t=this._objectClass.GetImageInfo(),s=t.GetTexture();if(s){const i=this.GetWorldInfo(),n=i.GetLayer(),r=G,a=(this._runtime.GetCanvasManager().IsPastingToDrawingCanvas()?r.set(-1/0,-1/0,1/0,1/0):n.Has3DCamera()?n.CalculateViewport3D(i.GetTotalZElevation(),r):n.GetViewportForZ(i.GetTotalZElevation(),r),e.SetTexture(s),n.Get2DScaleFactorToZ(i.GetTotalZElevation()));this._particleEngine.SetParticleScale(n.GetRenderScale()*a),this._particleEngine.Draw(e,t.GetTexQuad(),r,n.Has3DCamera())}}}SaveToJson(){const e=this._particleEngine;return{r:e.GetRate(),sc:e.GetSprayCone(),st:e.GetSprayType(),isp:e.GetInitSpeed(),isz:e.GetInitSize(),io:e.GetInitOpacity(),gr:e.GetGrowRate(),xr:e.GetInitXRandom(),yr:e.GetInitYRandom(),spr:e.GetInitSpeedRandom(),szr:e.GetInitSizeRandom(),grnd:e.GetGrowRandom(),acc:e.GetAcceleration(),g:e.GetGravity(),lar:e.GetLifeAngleRandom(),lsr:e.GetLifeSpeedRandom(),lor:e.GetLifeOpacityRandom(),dm:e.GetDestroyModeIndex(),to:e.GetTimeout(),s:e.IsSpraying(),pcc:e._GetCreateCounter(),ft:this._isFirstTick,soc:this._spawnObjectClass?this._spawnObjectClass.GetSID():null,p:e.GetParticles().map(e=>e.toJSON())}}LoadFromJson(e,t){const s=this._particleEngine;if(s.SetRate(e.r),s.SetSprayCone(e.sc),s.SetSprayType(e.st),s.SetInitSpeed(e.isp),s.SetInitSize(e.isz),s.SetInitOpacity(e.io),s.SetGrowRate(e.gr),s.SetInitXRandom(e.xr),s.SetInitYRandom(e.yr),s.SetInitSpeedRandom(e.spr),s.SetInitSizeRandom(e.szr),s.SetGrowRandom(e.grnd),s.SetAcceleration(e.acc),s.SetGravity(e.g),s.SetLifeAngleRandom(e.lar),s.SetLifeSpeedRandom(e.lsr),s.SetLifeOpacityRandom(e.lor),s.SetDestroyModeIndex(e.dm),s.SetTimeout(e.to),s.SetSpraying(e.s),s._SetCreateCounter(e.pcc),this._isFirstTick=e.ft,e.hasOwnProperty("soc")){const r=this.GetRuntime().GetObjectClassBySID(e.soc);r&&this._SetParticleObjectClass(r)}const i=e.p,n=(s.SetParticleCount(i.length,!1),s.GetParticles());for(let e=0,t=n.length;e<t;++e)n[e].setFromJSON(i[e]);"state"===t&&this._spawnObjectClass&&(s.UpdateAllParticlesUserData(),s.ApplyParticleDataToUserData(this))}_OnAfterLoad(){const e=this._particleEngine,s=(e.UpdateAllParticlesUserData(),e.ApplyParticleDataToUserData(this),e.GetParticles());for(let e=0,t=s.length;e<t;++e){const i=s[e],n=i.GetUserData();if(n){const r=n.GetWorldInfo();if(r){const a=r.GetInstance();if(a){const o=i.GetUserDataUID(),l=a.GetUID();if(("number"!=typeof o||"number"!=typeof l||o!==l)&&"number"==typeof o){const h=this.GetRuntime(),c=h.GetInstanceByUID(o);c&&h.DestroyInstance(c)}}}}}}Tick(){const e=this._runtime.GetDt(this._inst);this._UpdateEngineParameters(),this._isFirstTick&&"one-shot"===this._particleEngine.GetSprayType()&&this._particleEngine.ReInitAllParticles(),this._particleEngine.Tick(e),this._particleEngine.IsSpraying()&&this._runtime.UpdateRender(),this.GetWorldInfo().SetBboxChanged(),this._isFirstTick=!1}_FastForward(e){for(this._isFirstTick&&"one-shot"===this._particleEngine.GetSprayType()&&this._particleEngine.ReInitAllParticles();0<e;)this._particleEngine.Tick(1/60),e-=1/60;this._particleEngine.IsSpraying()&&this._runtime.UpdateRender(),this.GetWorldInfo().SetBboxChanged(),this._isFirstTick=!1}_OnParticleCreate(e,t){let s,i=(s=(s=(s="number"==typeof t?this._runtime.GetInstanceByUID(t):s)&&s.GetObjectClass()!==this._spawnObjectClass?null:s)||this._runtime.CreateInstance(this._spawnObjectClass,this.GetWorldInfo().GetLayer(),e.GetX(),e.GetY())).GetWorldInfo();return i.SetSize(e.GetSize(),e.GetSize()),i.SetAngle(e.GetAngle()),i.SetOpacity(e.GetOpacity()),i.SetUnpremultipliedColor(this.GetWorldInfo().GetUnpremultipliedColor()),i.SetBboxChanged(),i.ZOrderMoveAdjacentToInstance(this.GetInstance(),!0),s._TriggerOnCreated(),e.SetUpdateCallback(this._particleUpdateCallback),e.SetDestroyCallback(this._particleDestroyCallback),s}_OnParticleUpdate(e,t,s,i,n,r){if(!e.IsDestroyed()){const a=e.GetWorldInfo();a.OffsetXY(t,s),a.SetSize(a.GetWidth()+i,a.GetHeight()+i),a.SetAngle(a.GetAngle()+n),a.SetOpacity(a.GetOpacity()+r),a.SetBboxChanged()}}_OnParticleDestroy(e){e.IsDestroyed()||this._runtime.DestroyInstance(e)}GetPropertyValueByIndex(e){const i=this._particleEngine;switch(e){case j:return i.GetRate();case k:return h.toDegrees(i.GetSprayCone());case l:return"one-shot"===i.GetSprayType()?F:E;case o:return i.GetInitSpeed();case p:return i.GetInitSize();case q:return 100*i.GetInitOpacity();case r:return i.GetGrowRate();case s:return i.GetInitXRandom();case t:return i.GetInitYRandom();case u:return i.GetInitSpeedRandom();case v:return i.GetInitSizeRandom();case w:return i.GetGrowRandom();case x:return i.GetAcceleration();case y:return i.GetGravity();case z:return i.GetLifeAngleRandom();case A:return i.GetLifeSpeedRandom();case B:return i.GetLifeOpacityRandom();case C:return i.GetDestroyModeIndex();case D:return i.GetTimeout()}}SetPropertyValueByIndex(e,i){const n=this._particleEngine;switch(e){case j:n.SetRate(i);break;case k:n.SetSprayCone(h.toRadians(i));break;case l:n.SetSprayType(i?"one-shot":"continuous-spray");break;case o:n.SetInitSpeed(i);break;case p:n.SetInitSize(i);break;case q:n.SetInitOpacity(i/100);break;case r:n.SetGrowRate(i);break;case s:n.SetInitXRandom(i);break;case t:n.SetInitYRandom(i);break;case u:n.SetInitSpeedRandom(i);break;case v:n.SetInitSizeRandom(i);break;case w:n.SetGrowRandom(i);break;case x:n.SetAcceleration(i);break;case y:n.SetGravity(i);break;case z:n.SetLifeAngleRandom(i);break;case A:n.SetLifeSpeedRandom(i);break;case B:n.SetLifeOpacityRandom(i);break;case C:n.SetDestroyModeIndex(i);break;case D:n.SetTimeout(i)}}GetDebuggerProperties(){const e="plugins.particles",t=e+".properties",s=e+".debugger",i=this._particleEngine;return[{title:e+".name",properties:[{name:s+".particle-count",value:i.GetParticleCount()},{name:t+".type.name",value:[t+".type.items."+i.GetSprayType()]},{name:s+".is-spraying",value:i.IsSpraying(),onedit:e=>i.SetSpraying(e)},{name:t+".rate.name",value:i.GetRate(),onedit:e=>i.SetRate(e)},{name:t+".spray-cone.name",value:h.toDegrees(i.GetSprayCone()),onedit:e=>i.SetSprayCone(h.toRadians(e))},{name:t+".speed.name",value:i.GetInitSpeed(),onedit:e=>i.SetInitSpeed(e)},{name:t+".size.name",value:i.GetInitSize(),onedit:e=>i.SetInitSize(e)},{name:t+".opacity.name",value:i.GetInitOpacity(),onedit:e=>i.SetInitOpacity(e)},{name:t+".grow-rate.name",value:i.GetGrowRate(),onedit:e=>i.SetGrowRate(e)},{name:t+".x-randomiser.name",value:i.GetInitXRandom(),onedit:e=>i.SetInitXRandom(e)},{name:t+".y-randomiser.name",value:i.GetInitYRandom(),onedit:e=>i.SetInitYRandom(e)},{name:t+".initial-speed-randomiser.name",value:i.GetInitSpeedRandom(),onedit:e=>i.SetInitSpeedRandom(e)},{name:t+".size-randomiser.name",value:i.GetInitSizeRandom(),onedit:e=>i.SetInitSizeRandom(e)},{name:t+".grow-rate-randomiser.name",value:i.GetGrowRandom(),onedit:e=>i.SetGrowRandom(e)},{name:t+".acceleration.name",value:i.GetAcceleration(),onedit:e=>i.SetAcceleration(e)},{name:t+".gravity.name",value:i.GetGravity(),onedit:e=>i.SetGravity(e)},{name:t+".angle-randomiser.name",value:i.GetLifeAngleRandom(),onedit:e=>i.SetLifeAngleRandom(e)},{name:t+".life-speed-randomiser.name",value:i.GetLifeSpeedRandom(),onedit:e=>i.SetLifeSpeedRandom(e)},{name:t+".opacity-randomiser.name",value:i.GetLifeOpacityRandom(),onedit:e=>i.SetLifeOpacityRandom(e)},{name:t+".timeout.name",value:i.GetTimeout(),onedit:e=>i.SetTimeout(e)}]}]}GetScriptInterfaceClass(){return self.IParticlesInstance}},new WeakMap);self.IParticlesInstance=class extends self.IWorldInstance{constructor(){super(),H.set(this,self.IInstance._GetInitInst().GetSdkInstance())}set isSpraying(e){GetParticleEngine2(this).SetSpraying(!!e)}get isSpraying(){return GetParticleEngine2(this).IsSpraying()}set rate(e){i.RequireFiniteNumber(e),H.get(this)._SetRate(e)}get rate(){return GetParticleEngine2(this).GetRate()}set sprayCone(e){i.RequireFiniteNumber(e),GetParticleEngine2(this).SetSprayCone(e)}get sprayCone(){return GetParticleEngine2(this).GetSprayCone()}set initSpeed(e){i.RequireFiniteNumber(e),GetParticleEngine2(this).SetInitSpeed(e)}get initSpeed(){return GetParticleEngine2(this).GetInitSpeed()}set initSize(e){i.RequireFiniteNumber(e),GetParticleEngine2(this).SetInitSize(e)}get initSize(){return GetParticleEngine2(this).GetInitSize()}set initOpacity(e){i.RequireFiniteNumber(e),GetParticleEngine2(this).SetInitOpacity(e)}get initOpacity(){return GetParticleEngine2(this).GetInitOpacity()}set initXRandom(e){i.RequireFiniteNumber(e),GetParticleEngine2(this).SetInitXRandom(e)}get initXRandom(){return GetParticleEngine2(this).GetInitXRandom()}set initYRandom(e){i.RequireFiniteNumber(e),GetParticleEngine2(this).SetInitYRandom(e)}get initYRandom(){return GetParticleEngine2(this).GetInitYRandom()}set initSpeedRandom(e){i.RequireFiniteNumber(e),GetParticleEngine2(this).SetInitSpeedRandom(e)}get initSpeedRandom(){return GetParticleEngine2(this).GetInitSpeedRandom()}set initSizeRandom(e){i.RequireFiniteNumber(e),GetParticleEngine2(this).SetInitSizeRandom(e)}get initSizeRandom(){return GetParticleEngine2(this).GetInitSizeRandom()}set initGrowRate(e){i.RequireFiniteNumber(e),GetParticleEngine2(this).SetGrowRate(e)}get initGrowRate(){return GetParticleEngine2(this).GetGrowRate()}set initGrowRandom(e){i.RequireFiniteNumber(e),GetParticleEngine2(this).SetGrowRandom(e)}get initGrowRandom(){return GetParticleEngine2(this).GetGrowRandom()}set acceleration(e){i.RequireFiniteNumber(e),GetParticleEngine2(this).SetAcceleration(e)}get acceleration(){return GetParticleEngine2(this).GetAcceleration()}set gravity(e){i.RequireFiniteNumber(e),GetParticleEngine2(this).SetGravity(e)}get gravity(){return GetParticleEngine2(this).GetGravity()}set lifeAngleRandom(e){i.RequireFiniteNumber(e),GetParticleEngine2(this).SetLifeAngleRandom(e)}get lifeAngleRandom(){return GetParticleEngine2(this).GetLifeAngleRandom()}set lifeSpeedRandom(e){i.RequireFiniteNumber(e),GetParticleEngine2(this).SetLifeSpeedRandom(e)}get lifeSpeedRandom(){return GetParticleEngine2(this).GetLifeSpeedRandom()}set lifeOpacityRandom(e){i.RequireFiniteNumber(e),GetParticleEngine2(this).SetLifeOpacityRandom(e)}get lifeOpacityRandom(){return GetParticleEngine2(this).GetLifeOpacityRandom()}set timeout(e){i.RequireFiniteNumber(e),GetParticleEngine2(this).SetTimeout(e)}get timeout(){return GetParticleEngine2(this).GetTimeout()}fastForward(e){i.RequireFiniteNumber(e),H.get(this)._FastForward(e)}setParticleObjectClass(e){const t=H.get(this);e?t._SetParticleObjectClass(t.GetRuntime()._UnwrapIObjectClass(e)):t._SetParticleObjectClass(null)}}}{const N0=self.C3;N0.Plugins.Particles.Cnds={IsSpraying(){return this._particleEngine.IsSpraying()}}}{const O0=self.C3;O0.Plugins.Particles.Acts={SetSpraying(e){this._particleEngine.SetSpraying(0!==e)},SetRate(e){this._SetRate(e)},SetParticleObject(e){this._SetParticleObjectClass(e)},UnsetParticleObject(){this._SetParticleObjectClass(null)},SetSprayCone(e){this._particleEngine.SetSprayCone(O0.toRadians(e))},SetInitSpeed(e){this._particleEngine.SetInitSpeed(e)},SetInitSize(e){this._particleEngine.SetInitSize(e)},SetInitOpacity(e){this._particleEngine.SetInitOpacity(e/100)},SetGrowRate(e){this._particleEngine.SetGrowRate(e)},SetXRandomiser(e){this._particleEngine.SetInitXRandom(e)},SetYRandomiser(e){this._particleEngine.SetInitYRandom(e)},SetSpeedRandomiser(e){this._particleEngine.SetInitSpeedRandom(e)},SetSizeRandomiser(e){this._particleEngine.SetInitSizeRandom(e)},SetGrowRateRandomiser(e){this._particleEngine.SetGrowRandom(e)},SetParticleAcc(e){this._particleEngine.SetAcceleration(e)},SetGravity(e){this._particleEngine.SetGravity(e)},SetAngleRandomiser(e){this._particleEngine.SetLifeAngleRandom(e)},SetLifeSpeedRandomiser(e){this._particleEngine.SetLifeSpeedRandom(e)},SetOpacityRandomiser(e){this._particleEngine.SetLifeOpacityRandom(e)},SetTimeout(e){this._particleEngine.SetTimeout(e)},FastForward(e){this._FastForward(e)},SetEffect(e){this.GetWorldInfo().SetBlendMode(e),this._runtime.UpdateRender()}}}{const ib=self.C3;ib.Plugins.Particles.Exps={ParticleCount(){return this._particleEngine.GetParticleCount()},Rate(){return this._particleEngine.GetRate()},SprayCone(){return ib.toDegrees(this._particleEngine.GetSprayCone())},InitSpeed(){return this._particleEngine.GetInitSpeed()},InitSize(){return this._particleEngine.GetInitSize()},InitOpacity(){return 100*this._particleEngine.GetInitOpacity()},InitGrowRate(){return this._particleEngine.GetGrowRate()},XRandom(){return this._particleEngine.GetInitXRandom()},YRandom(){return this._particleEngine.GetInitYRandom()},InitSizeRandom(){return this._particleEngine.GetInitSizeRandom()},InitSpeedRandom(){return this._particleEngine.GetInitSpeedRandom()},InitGrowRandom(){return this._particleEngine.GetGrowRandom()},ParticleAcceleration(){return this._particleEngine.GetAcceleration()},Gravity(){return this._particleEngine.GetGravity()},ParticleAngleRandom(){return this._particleEngine.GetLifeAngleRandom()},ParticleSpeedRandom(){return this._particleEngine.GetLifeSpeedRandom()},ParticleOpacityRandom(){return this._particleEngine.GetLifeOpacityRandom()},Timeout(){return this._particleEngine.GetTimeout()}}}{const C33=self.C3,inactiveParticles=[],MAX_RECYCLE_PARTICLES=1e3,VALID_SPRAY_TYPES=new Set(["continuous-spray","one-shot"]),DESTROY_MODES=["fade-to-invisible","timeout-expired","particle-stopped"],tempRect=C33.New(C33.Rect);self.ParticleEngine=class{constructor(){this._rate=0,this._sprayCone=0,this._sprayType="continuous-spray",this._isSpraying=!1,this._masterOpacity=0,this._isPixelRounding=!1,this._spawnX=0,this._spawnY=0,this._spawnAngle=0,this._initSpeed=0,this._initSize=0,this._initSizeScale=1,this._initOpacity=0,this._growRate=0,this._xRandom=0,this._yRandom=0,this._initSpeedRandom=0,this._initSizeRandom=0,this._growRandom=0,this._acceleration=0,this._gravity=0,this._lifeAngleRandom=0,this._lifeSpeedRandom=0,this._lifeOpacityRandom=0,this._destroyMode=0,this._timeout=0,this._createCounter=0,this._particleScale=1,this.ononeshotfinish=null,this.onparticlecreate=null,this._particles=[],this._boundingBox=new C33.Rect,this._color=new C33.Color}Release(){this.Cancel(),C33.clearArray(this._particles),this._particles=null,this.ononeshotfinish=null,this.onparticlecreate=null,this._boundingBox=null,this._color=null}Cancel(){const s=this._particles;for(let e=0,t=s.length;e<t;++e)s[e].Destroy();C33.appendArray(inactiveParticles,s),C33.clearArray(s),inactiveParticles.length>MAX_RECYCLE_PARTICLES&&C33.truncateArray(inactiveParticles,MAX_RECYCLE_PARTICLES),this._isSpraying=!1}CreateOneShotSpray(){for(let e=0,t=this._rate;e<t;++e)this._CreateParticle();this._particles.length&&(this._isSpraying=!0)}_CreateParticle(e=!0){let t=null;return inactiveParticles.length?(t=inactiveParticles.pop()).SetEngine(this):t=C33.New(self.Particle,this),this._particles.push(t),e?t.Init(this.onparticlecreate):t.Init(),t}ReInitAllParticles(){const s=this._particles,i=this.onparticlecreate;for(let e=0,t=s.length;e<t;++e)s[e].Init(i)}UpdateAllParticlesUserData(){const s=this._particles,i=this.onparticlecreate;for(let e=0,t=s.length;e<t;++e)s[e].UpdateUserData(i)}ApplyParticleDataToUserData(s){const i=this._particles;for(let e=0,t=i.length;e<t;++e){const n=i[e],r=n.GetUserData();if(r){const a=r.GetWorldInfo();a.SetX(n.GetX()),a.SetY(n.GetY()),a.SetSize(n.GetSize(),n.GetSize()),a.SetOpacity(n.GetOpacity()),a.SetAngle(n.GetAngle()),a.SetUnpremultipliedColor(s.GetWorldInfo().GetUnpremultipliedColor()),a.SetBboxChanged()}}}SetParticleCount(e,t=!0){const s=this._particles;if(e<s.length){const i=s.length-e;for(let e=0;e<i;++e){const n=s.pop();n.Destroy(),inactiveParticles.push(n)}inactiveParticles.length>MAX_RECYCLE_PARTICLES&&C33.truncateArray(inactiveParticles,MAX_RECYCLE_PARTICLES)}else if(e>s.length){const r=e-s.length;for(let e=0;e<r;++e)this._CreateParticle(t)}}GetParticles(){return this._particles}GetParticleCount(){return this._particles.length}Tick(e){this._SpawnContinuous(e),this._TickParticles(e),this._MaybeFinishOneShot()}_SpawnContinuous(e){if("continuous-spray"===this._sprayType&&this._isSpraying){this._createCounter+=e*this._rate;const t=Math.floor(this._createCounter);this._createCounter-=t;for(let e=0;e<t;++e)this._CreateParticle()}}_SetCreateCounter(e){this._createCounter=e}_GetCreateCounter(){return this._createCounter}_TickParticles(s){let i=this._boundingBox,n=(i.set(this._spawnX,this._spawnY,this._spawnX,this._spawnY),this._particles),r=0;for(let e=0,t=n.length;e<t;++e){const a=n[e];(n[r]=a).Tick(s),a.IsActive()?(++r,i.expandToContain(a.GetBoundingBox())):(a.Destroy(),inactiveParticles.push(a))}C33.truncateArray(n,r),inactiveParticles.length>MAX_RECYCLE_PARTICLES&&C33.truncateArray(inactiveParticles,MAX_RECYCLE_PARTICLES)}_MaybeFinishOneShot(){"one-shot"===this._sprayType&&0===this._particles.length&&this._isSpraying&&(this.ononeshotfinish&&this.ononeshotfinish(),this._isSpraying=!1)}Draw(s,i,n,r){tempRect.set(i.getTlx(),i.getTly(),i.getBrx(),i.getBry()),s.StartRenderingPoints(tempRect),this._color.copy(s.GetColor());const a=this._particles;for(let e=0,t=a.length;e<t;++e){const o=a[e];n.intersectsRect(o.GetBoundingBox())&&o.Draw(s,i,r)}s.FinishRenderingPoints()}GetColor(){return this._color}SetRate(e){this._rate=+e}GetRate(){return this._rate}SetSprayCone(e){this._sprayCone=+e}GetSprayCone(){return this._sprayCone}SetSprayType(e){if(!VALID_SPRAY_TYPES.has(e))throw new Error("invalid spray type");this._sprayType=e}GetSprayType(){return this._sprayType}SetSpraying(e){this._isSpraying=!!e}IsSpraying(){return this._isSpraying}SetMasterOpacity(e){this._masterOpacity=+e}GetMasterOpacity(){return this._masterOpacity}SetPixelRounding(e){this._isPixelRounding=!!e}IsPixelRounding(){return this._isPixelRounding}SetSpawnX(e){this._spawnX=+e}GetSpawnX(){return this._spawnX}SetSpawnY(e){this._spawnY=+e}GetSpawnY(){return this._spawnY}SetSpawnAngle(e){this._spawnAngle=+e}GetInitAngle(){return this._spawnAngle}SetInitSpeed(e){this._initSpeed=+e}GetInitSpeed(){return this._initSpeed}SetInitSize(e){this._initSize=+e}GetInitSize(){return this._initSize}SetInitSizeScale(e){this._initSizeScale=+e}GetInitSizeScale(){return this._initSizeScale}SetInitOpacity(e){this._initOpacity=+e}GetInitOpacity(){return this._initOpacity}SetGrowRate(e){this._growRate=+e}GetGrowRate(){return this._growRate}SetInitXRandom(e){this._xRandom=+e}GetInitXRandom(){return this._xRandom}SetInitYRandom(e){this._yRandom=+e}GetInitYRandom(){return this._yRandom}SetInitSpeedRandom(e){this._initSpeedRandom=+e}GetInitSpeedRandom(){return this._initSpeedRandom}SetInitSizeRandom(e){this._initSizeRandom=+e}GetInitSizeRandom(){return this._initSizeRandom}SetGrowRandom(e){this._growRandom=+e}GetGrowRandom(){return this._growRandom}SetAcceleration(e){this._acceleration=+e}GetAcceleration(){return this._acceleration}SetGravity(e){this._gravity=+e}GetGravity(){return this._gravity}SetLifeAngleRandom(e){this._lifeAngleRandom=+e}GetLifeAngleRandom(){return this._lifeAngleRandom}SetLifeSpeedRandom(e){this._lifeSpeedRandom=+e}GetLifeSpeedRandom(){return this._lifeSpeedRandom}SetLifeOpacityRandom(e){this._lifeOpacityRandom=+e}GetLifeOpacityRandom(){return this._lifeOpacityRandom}SetDestroyMode(e){let t=DESTROY_MODES.indexOf(e);if(-1===t)throw new Error("invalid destroy mode");this._destroyMode=t}SetDestroyModeIndex(e){this.SetDestroyMode(DESTROY_MODES[e])}GetDestroyMode(){return DESTROY_MODES[this._destroyMode]}GetDestroyModeIndex(){return this._destroyMode}SetTimeout(e){this._timeout=+e}GetTimeout(){return this._timeout}SetParticleScale(e){this._particleScale=+e}GetParticleScale(){return this._particleScale}GetBoundingBox(){return this._boundingBox}}}{let randomOffset2=function(e){return Math.random()*e-e/2},C33=(randomOffset=randomOffset2,self.C3),ParticleEngine=self.ParticleEngine,tmpQuad=new C33.Quad,tmpColor=new C33.Color,DPR=self.devicePixelRatio||1,didChangeColor=!1;self.Particle=class{constructor(e){this._engine=e,this._isActive=!1,this._x=0,this._y=0,this._speed=0,this._angle=0,this._opacity=1,this._lastOpacity=0,this._grow=0,this._size=0,this._halfSize=0,this._gs=0,this._age=0,this._bbox=new C33.Rect,this._userData=null,this._userDataUid=NaN,this._updateCallback=null,this._destroyCallback=null}SetEngine(e){this._engine=e}Init(e){const t=this._engine;this._isActive=!0,this._x=t.GetSpawnX()+randomOffset2(t.GetInitXRandom()),this._y=t.GetSpawnY()+randomOffset2(t.GetInitYRandom()),this._speed=t.GetInitSpeed()+randomOffset2(t.GetInitSpeedRandom()),this._angle=t.GetInitAngle()+randomOffset2(t.GetSprayCone()),this._opacity=t.GetInitOpacity(),this._lastOpacity=this._opacity,this._size=(t.GetInitSize()+randomOffset2(t.GetInitSizeRandom()))*t.GetInitSizeScale(),this._halfSize=this._size/2,this._grow=t.GetGrowRate()+randomOffset2(t.GetGrowRandom()),this._gs=0,this._age=0,this._UpdateBoundingBox(),e?this._userData||(this._userData=e(this)):(this._userData=null,this._updateCallback=null,this._destroyCallback=null)}UpdateUserData(e){e?this._userData&&!this._userData.IsDestroyed()||(this._userData=e(this,this._userDataUid)):(this._userData=null,this._updateCallback=null,this._destroyCallback=null)}SetUpdateCallback(e){this._updateCallback=e}SetDestroyCallback(e){this._destroyCallback=e}Destroy(){const e=this._destroyCallback;e&&e(this._userData),this._userData=null,this._updateCallback=null,this._destroyCallback=null}toJSON(){let e;return this._userData&&this._userData.GetWorldInfo()&&(e=this._userData.GetWorldInfo().GetInstance().GetUID()),[this._x,this._y,this._speed,this._angle,this._opacity,this._grow,this._size,this._gs,this._age,e]}setFromJSON(e){this._x=e[0],this._y=e[1],this._speed=e[2],this._angle=e[3],this._opacity=e[4],this._lastOpacity=this._opacity,this._grow=e[5],this._size=e[6],this._gs=e[7],this._age=e[8],this._userDataUid=e[9],this._halfSize=this._size/2,this._UpdateBoundingBox()}Tick(e){let t=this._engine,s=this._speed*e,i=this._angle,n=Math.cos(i)*s,r=Math.sin(i)*s+this._gs*e,a=(this._x+=n,this._y+=r,this._grow*e),o=(this._size+=a,this._halfSize=this._size/2,this._speed+=t.GetAcceleration()*e,this._gs+=t.GetGravity()*e,this._age+=e,this._UpdateBoundingBox(),t.GetLifeAngleRandom()),l=t.GetLifeSpeedRandom(),h=t.GetLifeOpacityRandom(),c=0;0!==o&&(c=randomOffset2(o*e),this._angle+=c),0!==l&&(this._speed+=randomOffset2(l*e)),0!==h&&(this._opacity=C33.clamp(this._opacity+randomOffset2(h*e),0,1));const u=1<=this._size&&(2===t.GetDestroyModeIndex()?0<this._speed:this._age<t.GetTimeout()),_=this._updateCallback;if(_&&u){let e=t.GetMasterOpacity()*this._opacity;0===t.GetDestroyModeIndex()&&(e*=1-this._age/t.GetTimeout());const d=e-this._lastOpacity;this._lastOpacity=e,_(this._userData,n,r,a,c,d)}this._isActive=u}IsActive(){return this._isActive}GetBoundingBox(){return this._bbox}_UpdateBoundingBox(){const e=this._x,t=this._y,s=this._halfSize;this._bbox.set(e-s,t-s,e+s,t+s)}Draw(n,r,a){if(!this._userData){let s=this._engine,i=s.GetMasterOpacity()*this._opacity;if(0===s.GetDestroyModeIndex()&&(i*=1-this._age/s.GetTimeout()),!(i<=0)){const o=this._size,l=o*s.GetParticleScale()*DPR;if(!(l<1)){let e=this._x,t=this._y;s.IsPixelRounding()&&(e=e+.5|0,t=t+.5|0),n.IsWebGPU()?n.Point(e,t,o,i):a||l>n.GetMaxPointSize()||l<n.GetMinPointSize()?(tmpColor.copy(s.GetColor()),tmpColor.multiplyAlpha(i),n.SetColor(tmpColor),didChangeColor=!0,tmpQuad.setFromRect(this._bbox),n.Quad4(tmpQuad,r)):(didChangeColor&&(n.SetColor(s.GetColor()),didChangeColor=!1),n.Point(e,t,l,i))}}}}GetUserData(){return this._userData}GetUserDataUID(){return this._userDataUid}GetX(){return this._x}GetY(){return this._y}GetSize(){return this._size}GetAngle(){return this._angle}GetOpacity(){return this._opacity}}}{const a=self.C3;a.Plugins.TiledBg=class extends a.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{let WrapModeToStr2=function(e){switch(e){case 0:return"clamp-to-edge";case 1:return"repeat";case 2:return"mirror-repeat"}return"repeat"};WrapModeToStr=WrapModeToStr2;const d=self.C3;d.Plugins.TiledBg.Type=class extends d.SDKTypeBase{constructor(e,t){super(e),this._wrapX="repeat",this._wrapY="repeat",t&&(this._wrapX=WrapModeToStr2(t[0]),this._wrapY=WrapModeToStr2(t[1]))}Release(){super.Release()}OnCreate(){this.GetImageInfo().LoadAsset(this._runtime)}LoadTextures(e){return this.GetImageInfo().LoadStaticTexture(e,{sampling:this._runtime.GetSampling(),wrapX:this._wrapX,wrapY:this._wrapY})}ReleaseTextures(){this.GetImageInfo().ReleaseTexture()}GetWrapModeX(){return this._wrapX}GetWrapModeY(){return this._wrapY}}}{const j=self.C3,k=self.C3X,l=0,m=1,n=4,o=5,p=6,q=7,r=8,s=9,t=10,u=11,v=12,w=13,x=14,y=j.New(j.Rect),z=j.New(j.Quad),A=j.New(j.Rect),B=j.New(j.Quad),C=(j.Plugins.TiledBg.Instance=class extends j.SDKWorldInstanceBase{constructor(e,i){super(e),this._imageOffsetX=0,this._imageOffsetY=0,this._imageScaleX=1,this._imageScaleY=1,this._imageAngle=0,this._enableTileRandomization=!1,this._tileXRandom=0,this._tileYRandom=0,this._tileAngleRandom=0,this._tileBlendMarginX=0,this._tileBlendMarginY=0,this._ownImageInfo=null,i&&(this.GetWorldInfo().SetVisible(!!i[l]),this._imageOffsetX=i[n],this._imageOffsetY=i[o],this._imageScaleX=i[p],this._imageScaleY=i[q],this._imageAngle=j.toRadians(i[r]),this._enableTileRandomization=!!i[s],this._tileXRandom=i[t],this._tileYRandom=i[u],this._tileAngleRandom=i[v],this._tileBlendMarginX=i[w],this._tileBlendMarginY=i[x])}Release(){this._ReleaseOwnImage(),super.Release()}_ReleaseOwnImage(){this._ownImageInfo&&(this._ownImageInfo.Release(),this._ownImageInfo=null)}CalculateTextureCoordsFor3DFace(e,t,s){const i=this.GetCurrentImageInfo(),n=i.GetWidth(),r=i.GetHeight(),a=this._imageOffsetX/n,o=this._imageOffsetY/r,l=this._imageAngle;A.set(0,0,e/(n*this._imageScaleX),t/(r*this._imageScaleY)),A.offset(-a,-o),0===l?s.setFromRect(A):s.setFromRotatedRect(A,-l)}SetTilingShaderProgram(e,t=!0){if(this._enableTileRandomization){const s=this.GetCurrentImageInfo();e.SetTileRandomizationMode(),e.SetTileRandomizationInfo(s.GetWidth()*this._imageScaleX,s.GetHeight()*this._imageScaleY,this._tileXRandom,this._tileYRandom,this._tileAngleRandom,this._tileBlendMarginX,this._tileBlendMarginY)}else t&&e.SetTextureFillMode()}Draw(e){const t=this.GetCurrentImageInfo(),s=t.GetTexture();if(null!==s){this.SetTilingShaderProgram(e),e.SetTexture(s);const i=t.GetWidth(),n=t.GetHeight(),r=this._imageOffsetX/i,a=this._imageOffsetY/n,o=this.GetWorldInfo();A.set(0,0,o.GetWidth()/(i*this._imageScaleX),o.GetHeight()/(n*this._imageScaleY)),A.offset(-r,-a),o.HasMesh()?this._DrawMesh(o,e):this._DrawStandard(o,e)}}_DrawStandard(e,t){let s=e.GetBoundingQuad();this._runtime.IsPixelRoundingEnabled()&&(s=e.PixelRoundQuad(s)),0===this._imageAngle?t.Quad3(s,A):(B.setFromRotatedRect(A,-this._imageAngle),t.Quad4(s,B))}_DrawMesh(s,e){const i=s.GetTransformedMesh();if(s.IsMeshChanged()){s.CalculateBbox(y,z,!1);let e=z,t=(this._runtime.IsPixelRoundingEnabled()&&(e=s.PixelRoundQuad(e)),A);0!==this._imageAngle&&(B.setFromRotatedRect(A,-this._imageAngle),t=B),i.CalculateTransformedMesh(s.GetSourceMesh(),e,t),s.SetMeshChanged(!1)}i.Draw(e)}GetCurrentImageInfo(){return this._ownImageInfo||this._objectClass.GetImageInfo()}IsOriginalSizeKnown(){return!0}GetTexture(){return this.GetCurrentImageInfo().GetTexture()}_SetMeshChanged(){this.GetWorldInfo().SetMeshChanged(!0)}_SetImageOffsetX(e){this._imageOffsetX!==e&&(this._imageOffsetX=e,this._runtime.UpdateRender(),this._SetMeshChanged())}_GetImageOffsetX(){return this._imageOffsetX}_SetImageOffsetY(e){this._imageOffsetY!==e&&(this._imageOffsetY=e,this._runtime.UpdateRender(),this._SetMeshChanged())}_GetImageOffsetY(){return this._imageOffsetY}_SetImageScaleX(e){this._imageScaleX!==e&&(this._imageScaleX=e,this._runtime.UpdateRender(),this._SetMeshChanged())}_GetImageScaleX(){return this._imageScaleX}_SetImageScaleY(e){this._imageScaleY!==e&&(this._imageScaleY=e,this._runtime.UpdateRender(),this._SetMeshChanged())}_GetImageScaleY(){return this._imageScaleY}_SetImageAngle(e){this._imageAngle!==e&&(this._imageAngle=e,this._runtime.UpdateRender(),this._SetMeshChanged())}_GetImageAngle(){return this._imageAngle}_SetTileRandomizationEnabled(e){this._enableTileRandomization!==(e=!!e)&&(this._enableTileRandomization=e,this._runtime.UpdateRender())}_IsTileRandomizationEnabled(){return this._enableTileRandomization}_SetTileXRandom(e){this._tileXRandom!==e&&(this._tileXRandom=e,this._IsTileRandomizationEnabled())&&this._runtime.UpdateRender()}_GetTileXRandom(){return this._tileXRandom}_SetTileYRandom(e){this._tileYRandom!==e&&(this._tileYRandom=e,this._IsTileRandomizationEnabled())&&this._runtime.UpdateRender()}_GetTileYRandom(){return this._tileYRandom}_SetTileAngleRandom(e){this._tileAngleRandom!==e&&(this._tileAngleRandom=e,this._IsTileRandomizationEnabled())&&this._runtime.UpdateRender()}_GetTileAngleRandom(){return this._tileAngleRandom}_SetTileBlendMarginX(e){this._tileBlendMarginX!==e&&(this._tileBlendMarginX=e,this._IsTileRandomizationEnabled())&&this._runtime.UpdateRender()}_GetTileBlendMarginX(){return this._tileBlendMarginX}_SetTileBlendMarginY(e){this._tileBlendMarginY!==e&&(this._tileBlendMarginY=e,this._IsTileRandomizationEnabled())&&this._runtime.UpdateRender()}_GetTileBlendMarginY(){return this._tileBlendMarginY}SaveToJson(){const e={};return 0!==this._imageOffsetX&&(e.iox=this._imageOffsetX),0!==this._imageOffsetY&&(e.ioy=this._imageOffsetY),1!==this._imageScaleX&&(e.isx=this._imageScaleX),1!==this._imageScaleY&&(e.isy=this._imageScaleY),0!==this._imageAngle&&(e.ia=this._imageAngle),this._enableTileRandomization&&(e.tr=!0),1!==this._tileXRandom&&(e.trx=this._tileXRandom),1!==this._tileYRandom&&(e.try=this._tileYRandom),1!==this._tileAngleRandom&&(e.tra=this._tileAngleRandom),.1!==this._tileBlendMarginX&&(e.trbmx=this._tileBlendMarginX),.1!==this._tileBlendMarginY&&(e.trbmy=this._tileBlendMarginY),e}LoadFromJson(e){this._imageOffsetX=e.iox||0,this._imageOffsetY=e.ioy||0,this._imageScaleX=e.hasOwnProperty("isx")?e.isx:1,this._imageScaleY=e.hasOwnProperty("isy")?e.isy:1,this._imageAngle=e.ia||0,this._enableTileRandomization=!!e.tr,this._tileXRandom=e.hasOwnProperty("trx")?e.trx:1,this._tileYRandom=e.hasOwnProperty("try")?e.try:1,this._tileAngleRandom=e.hasOwnProperty("tra")?e.tra:1,this._tileBlendMarginX=e.hasOwnProperty("trbmx")?e.trbmx:.1,this._tileBlendMarginY=e.hasOwnProperty("trbmy")?e.trbmy:.1}GetDebuggerProperties(){const e="plugins.tiledbg.properties";return[{title:e+".image-transform.name",properties:[{name:e+".image-offset-x.name",value:this._GetImageOffsetX(),onedit:e=>this._SetImageOffsetX(e)},{name:e+".image-offset-y.name",value:this._GetImageOffsetY(),onedit:e=>this._SetImageOffsetY(e)},{name:e+".image-scale-x.name",value:100*this._GetImageScaleX(),onedit:e=>this._SetImageScaleX(e/100)},{name:e+".image-scale-y.name",value:100*this._GetImageScaleY(),onedit:e=>this._SetImageScaleY(e/100)},{name:e+".image-angle.name",value:j.toDegrees(this._GetImageAngle()),onedit:e=>this._SetImageAngle(j.toRadians(e))}]},{title:e+".tile-randomization.name",properties:[{name:e+".enable-tile-randomization.name",value:this._IsTileRandomizationEnabled(),onedit:e=>this._SetTileRandomizationEnabled(e)},{name:e+".x-random.name",value:100*this._GetTileXRandom(),onedit:e=>this._SetTileXRandom(e/100)},{name:e+".y-random.name",value:100*this._GetTileYRandom(),onedit:e=>this._SetTileYRandom(e/100)},{name:e+".angle-random.name",value:100*this._GetTileAngleRandom(),onedit:e=>this._SetTileAngleRandom(e/100)},{name:e+".blend-margin-x.name",value:100*this._GetTileBlendMarginX(),onedit:e=>this._SetTileBlendMarginX(e/100)},{name:e+".blend-margin-y.name",value:100*this._GetTileBlendMarginY(),onedit:e=>this._SetTileBlendMarginY(e/100)}]}]}GetPropertyValueByIndex(e){switch(e){case n:return this._GetImageOffsetX();case o:return this._GetImageOffsetY();case p:return this._GetImageScaleX();case q:return this._GetImageScaleY();case r:return this._GetImageAngle();case s:return this._IsTileRandomizationEnabled();case t:return this._GetTileXRandom();case u:return this._GetTileYRandom();case v:return this._GetTileAngleRandom();case w:return this._GetTileBlendMarginX();case x:return this._GetTileBlendMarginY()}}SetPropertyValueByIndex(e,i){switch(e){case n:this._SetImageOffsetX(i);break;case o:this._SetImageOffsetY(i);break;case p:this._SetImageScaleX(i);break;case q:this._SetImageScaleY(i);break;case r:this._SetImageAngle(i);break;case s:this._SetTileRandomizationEnabled(!!i);break;case t:this._SetTileXRandom(i);break;case u:this._SetTileYRandom(i);break;case v:this._SetTileAngleRandom(i);break;case w:this._SetTileBlendMarginX(i);break;case x:this._SetTileBlendMarginY(i)}}GetScriptInterfaceClass(){return self.ITiledBackgroundInstance}},new WeakMap);self.ITiledBackgroundInstance=class extends self.IWorldInstance{constructor(){super(),C.set(this,self.IInstance._GetInitInst().GetSdkInstance())}set imageOffsetX(e){k.RequireFiniteNumber(e),C.get(this)._SetImageOffsetX(e)}get imageOffsetX(){return C.get(this)._GetImageOffsetX()}set imageOffsetY(e){k.RequireFiniteNumber(e),C.get(this)._SetImageOffsetY(e)}get imageOffsetY(){return C.get(this)._GetImageOffsetY()}setImageOffset(e,t){k.RequireFiniteNumber(e),k.RequireFiniteNumber(t);const s=C.get(this);s._SetImageOffsetX(e),s._SetImageOffsetY(t)}getImageOffset(){const e=C.get(this);return[e._GetImageOffsetX(),e._GetImageOffsetY()]}set imageScaleX(e){k.RequireFiniteNumber(e),C.get(this)._SetImageScaleX(e)}get imageScaleX(){return C.get(this)._GetImageScaleX()}set imageScaleY(e){k.RequireFiniteNumber(e),C.get(this)._SetImageScaleY(e)}get imageScaleY(){return C.get(this)._GetImageScaleY()}setImageScale(e,t){k.RequireFiniteNumber(e),k.RequireFiniteNumber(t);const s=C.get(this);s._SetImageScaleX(e),s._SetImageScaleY(t)}getImageScale(){const e=C.get(this);return[e._GetImageScaleX(),e._GetImageScaleY()]}set imageAngle(e){k.RequireFiniteNumber(e),C.get(this)._SetImageAngle(e)}get imageAngle(){return C.get(this)._GetImageAngle()}set imageAngleDegrees(e){k.RequireFiniteNumber(e),C.get(this)._SetImageAngle(j.toRadians(e))}get imageAngleDegrees(){return j.toDegrees(C.get(this)._GetImageAngle())}get imageWidth(){return C.get(this).GetCurrentImageInfo().GetWidth()}get imageHeight(){return C.get(this).GetCurrentImageInfo().GetHeight()}getImageSize(){const e=C.get(this).GetCurrentImageInfo();return[e.GetWidth(),e.GetHeight()]}set enableTileRandomization(e){C.get(this)._SetTileRandomizationEnabled(!!e)}get enableTileRandomization(){return C.get(this)._IsTileRandomizationEnabled()}set tileXRandom(e){k.RequireFiniteNumber(e),C.get(this)._SetTileXRandom(e)}get tileXRandom(){return C.get(this)._GetTileXRandom()}set tileYRandom(e){k.RequireFiniteNumber(e),C.get(this)._SetTileYRandom(e)}get tileYRandom(){return C.get(this)._GetTileYRandom()}setTileRandom(e,t){k.RequireFiniteNumber(e),k.RequireFiniteNumber(t);const s=C.get(this);s._SetTileXRandom(e),s._SetTileYRandom(t)}getTileRandom(){const e=C.get(this);return[e._GetTileXRandom(),e._GetTileYRandom()]}set tileAngleRandom(e){k.RequireFiniteNumber(e),C.get(this)._SetTileAngleRandom(e)}get tileAngleRandom(){return C.get(this)._GetTileAngleRandom()}set tileBlendMarginX(e){k.RequireFiniteNumber(e),C.get(this)._SetTileBlendMarginX(e)}get tileBlendMarginX(){return C.get(this)._GetTileBlendMarginX()}set tileBlendMarginY(e){k.RequireFiniteNumber(e),C.get(this)._SetTileBlendMarginY(e)}get tileBlendMarginY(){return C.get(this)._GetTileBlendMarginY()}setTileBlendMargin(e,t){k.RequireFiniteNumber(e),k.RequireFiniteNumber(t);const s=C.get(this);s._SetTileBlendMarginX(e),s._SetTileBlendMarginY(t)}getTileBlendMargin(){const e=C.get(this);return[e._GetTileBlendMarginX(),e._GetTileBlendMarginY()]}async replaceImage(e){k.RequireInstanceOf(e,Blob);const t=C.get(this),s=t.GetRuntime(),i=j.New(j.ImageInfo);i.LoadDynamicBlobAsset(s,e),await i.LoadStaticTexture(s.GetRenderer(),{sampling:s.GetSampling(),wrapX:t.GetSdkType().GetWrapModeX(),wrapY:t.GetSdkType().GetWrapModeY()}),t.WasReleased()?i.Release():(t._ReleaseOwnImage(),t._ownImageInfo=i,s.UpdateRender())}}}{const o0=self.C3;o0.Plugins.TiledBg.Cnds={OnURLLoaded(){return!0},OnURLFailed(){return!0},IsTileRandomizationEnabled(){return this._IsTileRandomizationEnabled()}}}{const p0=self.C3;p0.Plugins.TiledBg.Acts={SetImageOffsetX(e){this._SetImageOffsetX(e)},SetImageOffsetY(e){this._SetImageOffsetY(e)},SetImageScaleX(e){this._SetImageScaleX(e/100)},SetImageScaleY(e){this._SetImageScaleY(e/100)},SetImageAngle(e){this._SetImageAngle(p0.toRadians(e))},SetTileRandomizationEnabled(e){this._SetTileRandomizationEnabled(e)},SetTilePosRandom(e,t){this._SetTileXRandom(e/100),this._SetTileYRandom(t/100)},SetTileAngleRandom(e){this._SetTileAngleRandom(e/100)},SetTileBlendMargin(e,t){this._SetTileBlendMarginX(e/100),this._SetTileBlendMarginY(t/100)},SetEffect(e){this.GetWorldInfo().SetBlendMode(e),this._runtime.UpdateRender()},async LoadURL(e,t){if(!this._ownImageInfo||this._ownImageInfo.GetURL()!==e){const s=this._runtime,i=p0.New(p0.ImageInfo);try{if(await i.LoadDynamicAsset(s,e),!i.IsLoaded())throw new Error("image failed to load");if(this.WasReleased())return i.Release(),null;const n=await i.LoadStaticTexture(s.GetRenderer(),{sampling:s.GetSampling(),wrapX:this.GetSdkType().GetWrapModeX(),wrapY:this.GetSdkType().GetWrapModeY()});if(!n)return}catch(e){return console.error("Load image from URL failed: ",e),void(this.WasReleased()||this.Trigger(p0.Plugins.TiledBg.Cnds.OnURLFailed))}this.WasReleased()?i.Release():(this._ReleaseOwnImage(),this._ownImageInfo=i,s.UpdateRender(),await this.TriggerAsync(p0.Plugins.TiledBg.Cnds.OnURLLoaded))}}}}{const I0=self.C3;I0.Plugins.TiledBg.Exps={ImageWidth(){return this.GetCurrentImageInfo().GetWidth()},ImageHeight(){return this.GetCurrentImageInfo().GetHeight()},ImageOffsetX(){return this._imageOffsetX},ImageOffsetY(){return this._imageOffsetY},ImageScaleX(){return 100*this._imageScaleX},ImageScaleY(){return 100*this._imageScaleY},ImageAngle(){return I0.toDegrees(this._imageAngle)},TileXRandom(){return 100*this._GetTileXRandom()},TileYRandom(){return 100*this._GetTileYRandom()},TileAngleRandom(){return 100*this._GetTileAngleRandom()},TileBlendMarginX(){return 100*this._GetTileBlendMarginX()},TileBlendMarginY(){return 100*this._GetTileBlendMarginY()}}}{const a=self.C3;a.Plugins.AJAX=class extends a.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{const d=self.C3;d.Plugins.AJAX.Type=class extends d.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const g=self.C3;g.Plugins.AJAX.Instance=class extends g.SDKInstanceBase{constructor(e,t){if(super(e),this._lastData="",this._lastStatusCode=0,this._curTag="",this._progress=0,this._timeout=-1,this._nextRequestHeaders=new Map,this._nextReponseBinaryData=null,this._nextRequestOverrideMimeType="",this._nextRequestWithCredentials=!1,this._nwjsFs=null,this._nwjsPath=null,this._nwjsAppFolder=null,this._isNWjs=this._runtime.IsNWjs(),this._isNWjs){this._nwjsFs=__require("fs"),this._nwjsPath=__require("path");const s=self.process||nw.process;this._nwjsAppFolder=this._nwjsPath.dirname(s.execPath)+"\\"}}Release(){super.Release()}async _TriggerError(e,t,s){console.error(`[Construct] AJAX request to '${t}' (tag '${e}') failed: `,s),this._curTag=e,await this.TriggerAsync(g.Plugins.AJAX.Cnds.OnAnyError),this._curTag=e,await this.TriggerAsync(g.Plugins.AJAX.Cnds.OnError)}async _TriggerComplete(e){this._curTag=e,await this.TriggerAsync(g.Plugins.AJAX.Cnds.OnAnyComplete),this._curTag=e,await this.TriggerAsync(g.Plugins.AJAX.Cnds.OnComplete)}async _OnProgress(e,t){t.lengthComputable&&(this._progress=t.loaded/t.total,this._curTag=e,await this.TriggerAsync(g.Plugins.AJAX.Cnds.OnProgress))}async _OnUploadProgress(e,t){t.lengthComputable&&(this._progress=t.loaded/t.total,this._curTag=e,await this.TriggerAsync(g.Plugins.AJAX.Cnds.OnUploadProgress))}_OnError(s,i,e){if(this._isNWjs){const t=this._nwjsFs,n=this._nwjsAppFolder+i;t.existsSync(n)?t.readFile(n,{encoding:"utf8"},(e,t)=>{e?this._TriggerError(s,i,e):(this._lastData=t.replace(/\r\n/g,"\n"),this._TriggerComplete(s))}):this._TriggerError(s,i,e)}else this._TriggerError(s,i,e)}async _DoCordovaRequest(t,s){const e=this._runtime.GetAssetManager(),i=this._nextReponseBinaryData;this._nextReponseBinaryData=null;try{if(i){const n=await e.CordovaFetchLocalFileAsArrayBuffer(s);i.SetArrayBufferTransfer(n),this._lastData=""}else{const r=await e.CordovaFetchLocalFileAsText(s);this._lastData=r.replace(/\r\n/g,"\n")}this._lastStatusCode=0,this._TriggerComplete(t)}catch(e){this._TriggerError(t,s,e)}}_DoRequest(o,l,e,h){return new Promise(t=>{const s=e=>{this._OnError(o,l,e),t()},i=this._nextReponseBinaryData;this._nextReponseBinaryData=null;try{const n=new XMLHttpRequest;n.onreadystatechange=()=>{if(4===n.readyState){if(i?this._lastData="":this._lastData=(n.responseText||"").replace(/\r\n/g,"\n"),this._lastStatusCode=n.status,400<=n.status)this._TriggerError(o,l,n.status+n.statusText);else{const e=this._lastData.length||i&&n.response instanceof ArrayBuffer;this._isNWjs&&!e||!this._isNWjs&&0===n.status&&!e||(i&&i.SetArrayBufferTransfer(n.response),this._TriggerComplete(o))}t()}},n.onerror=s,n.ontimeout=s,n.onabort=s,n.onprogress=e=>this._OnProgress(o,e),n.upload.onprogress=e=>this._OnUploadProgress(o,e),n.open(e,l),0<=this._timeout&&void 0!==n.timeout&&(n.timeout=this._timeout),n.responseType=i?"arraybuffer":"text",h&&!this._nextRequestHeaders.has("Content-Type")&&("string"!=typeof h?n.setRequestHeader("Content-Type","application/octet-stream"):n.setRequestHeader("Content-Type","application/x-www-form-urlencoded"));for(const[r,a]of this._nextRequestHeaders)try{n.setRequestHeader(r,a)}catch(e){console.error(`[Construct] AJAX: Failed to set header '${r}: ${a}': `,e)}if(this._nextRequestHeaders.clear(),this._nextRequestOverrideMimeType){try{n.overrideMimeType(this._nextRequestOverrideMimeType)}catch(e){console.error("[Construct] AJAX: failed to override MIME type: ",e)}this._nextRequestOverrideMimeType=""}this._nextRequestWithCredentials&&(n.withCredentials=!0,this._nextRequestWithCredentials=!1),h?n.send(h):n.send()}catch(e){s(e)}})}GetDebuggerProperties(){const e="plugins.ajax.debugger";return[{title:e+".title",properties:[{name:e+".last-status-code",value:this._lastStatusCode},{name:e+".last-data",value:this._lastData}]}]}SaveToJson(){return{lastData:this._lastData,lastStatusCode:this._lastStatusCode}}LoadFromJson(e){this._lastData=e.lastData,this._lastStatusCode=e.hasOwnProperty("lastStatusCode")?e.lastStatusCode:0,this._curTag="",this._progress=0}}}{const $=self.C3;$.Plugins.AJAX.Cnds={OnComplete(e){return $.equalsNoCase(this._curTag,e)},OnAnyComplete(){return!0},OnError(e){return $.equalsNoCase(this._curTag,e)},OnAnyError(){return!0},OnProgress(e){return $.equalsNoCase(this._curTag,e)},OnUploadProgress(e){return $.equalsNoCase(this._curTag,e)}}}{const da=self.C3;da.Plugins.AJAX.Acts={async Request(e,t){this._runtime.IsCordova()&&da.IsRelativeURL(t)&&this._runtime.GetAssetManager().IsFileProtocol()?await this._DoCordovaRequest(e,t):await this._DoRequest(e,t,"GET",null)},async RequestFile(e,t){this._runtime.IsCordova()&&this._runtime.GetAssetManager().IsFileProtocol()?await this._DoCordovaRequest(e,t):await this._DoRequest(e,t,"GET",null)},async Post(e,t,s,i){await this._DoRequest(e,t,i,s)},async PostBinary(e,t,s,i){if(s){const n=s.GetFirstPicked(this._inst);if(n){const r=n.GetSdkInstance(),a=r.GetArrayBufferReadOnly();await this._DoRequest(e,t,i,a)}}},SetTimeout(e){this._timeout=1e3*e},SetHeader(e,t){this._nextRequestHeaders.set(e,t)},SetResponseBinary(e){if(e){const t=e.GetFirstPicked(this._inst);t&&(this._nextReponseBinaryData=t.GetSdkInstance())}},OverrideMIMEType(e){this._nextRequestOverrideMimeType=e},SetWithCredentials(e){this._nextRequestWithCredentials=!!e}}}{const Aa=self.C3;Aa.Plugins.AJAX.Exps={LastData(){return this._lastData},LastStatusCode(){return this._lastStatusCode},Progress(){return this._progress},Tag(){return this._curTag}}}{const a=self.C3;a.Plugins.Json=class extends a.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{const d=self.C3;d.Plugins.Json.Type=class extends d.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const g=self.C3,h=self.C3X,i=self.IInstance,j=(g.Plugins.Json.Instance=class extends g.SDKInstanceBase{constructor(e,t){super(e),this._valueCache=[null,null],this._locationCache=[null,null],this._data={},this._path=[],this._currentKey="",this._currentValue=0}Release(){super.Release()}_InvalidateValueCache(){this._valueCache[0]=null,this._valueCache[1]=null}_HasValueCache(s,e){const i=this._valueCache[0];if(null!==s&&null!==i){if(i===s||g.arraysEqual(i,s))return!0;if(e&&0<i.length){for(let e=0,t=Math.min(s.length,i.length);e<t;++e)if(s[e]!==i[e])return!1;return!0}}return!1}_GetValueCache(){return this._valueCache[1]}_UpdateValueCache(e,t){this._valueCache[0]=e,this._valueCache[1]=t}_InvalidateLocationCache(){this._locationCache[0]=null,this._locationCache[1]=null}_HasLocationCache(e){return this._locationCache[0]===e}_GetLocationCache(){return this._locationCache[1]}_UpdateLocationCache(e,t){this._locationCache[0]=e,this._locationCache[1]=t}_SetData(e){this._data=e,this._InvalidateValueCache(),this._SetPath("")}_GetData(){return this._data}_SetPath(e){this._path=this._ParsePathUnsafe(e),this._InvalidateLocationCache()}_ParsePath(e){return g.cloneArray(this._ParsePathUnsafe(e))}_ParsePathUnsafe(e){let t=[],s=!1,i;if(this._HasLocationCache(e))return this._GetLocationCache();"."===e[0]?(i=g.cloneArray(this._path),e=e.slice(1)):i=[];for(const n of e)s?(t.push(n),s=!1):"\\"===n?s=!0:"."===n?(i.push(t.join("")),g.clearArray(t)):t.push(n);return 0!==t.length&&i.push(t.join("")),this._UpdateLocationCache(e,i),i}_GetValueAtFullPath(e,t){if(this._HasValueCache(e,!1))return this._GetValueCache();let s=this._data;for(const i of e)if(Array.isArray(s)){const n=parseInt(i,10);if(n<0||n>=s.length||!isFinite(n)){s=null;break}s=s[n]}else{if("object"!=typeof s||null===s){s=null;break}if(s.hasOwnProperty(i))s=s[i];else{if(!t){s=null;break}{const r={};s[i]=r,s=r}}}return this._UpdateValueCache(e,s),s}_GetValue(e){const t=this._ParsePath(e);if(!t.length)return this._data;const s=t.pop(),i=this._GetValueAtFullPath(t,!1);if(Array.isArray(i)){const n=parseInt(s,10);return 0<=n&&n<i.length?i[n]:null}return"object"==typeof i&&null!==i&&i.hasOwnProperty(s)?i[s]:null}_JSONTypeOf(e){return null===e?"null":Array.isArray(e)?"array":typeof e}_GetTypeOf(e){const t=this._GetValue(e);return this._JSONTypeOf(t)}_ToSafeValue(e){const t=typeof e;return"number"==t||"string"==t?e:"boolean"==t&&e?1:0}_GetSafeValue(e){return this._ToSafeValue(this._GetValue(e))}_HasKey(e){const t=this._ParsePath(e);if(!t.length)return!1;const s=t.pop(),i=this._GetValueAtFullPath(t,!1);if(Array.isArray(i)){const n=parseInt(s,10);return 0<=n&&n<i.length}return"object"==typeof i&&null!==i&&i.hasOwnProperty(s)}_SetValue(e,t){const s=this._ParsePath(e);if(!s.length)return!1;this._HasValueCache(s,!0)&&this._InvalidateValueCache();const i=s.pop(),n=this._GetValueAtFullPath(s,!0);if(Array.isArray(n)){const r=parseInt(i,10);return!(!isFinite(r)||r<0||r>=n.length||(n[r]=t,0))}return"object"==typeof n&&null!==n&&(n[i]=t,!0)}_DeleteKey(e){const t=this._ParsePath(e);if(!t.length)return!1;this._HasValueCache(t,!0)&&this._InvalidateValueCache();const s=t.pop(),i=this._GetValueAtFullPath(t,!1);return!Array.isArray(i)&&"object"==typeof i&&null!==i&&(delete i[s],!0)}SaveToJson(){return{path:this._path,data:this._data}}LoadFromJson(e){this._InvalidateValueCache(),this._InvalidateLocationCache(),this._path=e.path,this._data=e.data}_SanitizeValue(e){const t=typeof e;return"number"==t?isFinite(e)?e:0:"object"==typeof e?JSON.stringify(e):e+""}GetDebuggerProperties(){let e="plugins.json.debugger",t;try{t=this._SanitizeValue(this._data)}catch(e){t='"invalid"'}return[{title:e+".title",properties:[{name:e+".data",value:t,onedit:e=>{try{const t=JSON.parse(e);this._SetData(t)}catch(e){}}},{name:e+".path",value:this._path.map(e=>e.replace(/\./g,"\\.")).join(".")}]}]}GetScriptInterfaceClass(){return self.IJSONInstance}},new WeakMap);self.IJSONInstance=class extends i{constructor(){super(),j.set(this,i._GetInitInst().GetSdkInstance())}getJsonDataCopy(){const e=j.get(this)._GetData();return JSON.parse(JSON.stringify(e))}setJsonDataCopy(e){try{const t=JSON.parse(JSON.stringify(e));j.get(this)._SetData(t)}catch(e){throw console.error("[JSON plugin] setJsonData: object is not valid JSON: ",e),e}}setJsonString(e){h.RequireString(e);try{const t=JSON.parse(e);j.get(this)._SetData(t)}catch(e){throw console.error("[JSON plugin] setJsonString: string is not valid JSON: ",e),e}}toCompactString(){return JSON.stringify(j.get(this)._GetData())}toBeautifiedString(){return JSON.stringify(j.get(this)._GetData(),null,4)}}}{const Ba=self.C3,Ca=["null","boolean","number","string","object","array"];Ba.Plugins.Json.Cnds={HasKey(e){return this._HasKey(e)},CompareType(e,t){return this._GetTypeOf(e)===Ca[t]},CompareValue(e,t,s){return Ba.compare(this._GetSafeValue(e),t,s)},IsBooleanSet(e){return!0===this._GetValue(e)},ForEach(e){const t=this._GetValue(e);if("object"==typeof t&&null!==t){const s=this._runtime,i=s.GetEventSheetManager(),n=s.GetCurrentEvent(),r=n.GetSolModifiers(),a=s.GetEventStack(),o=a.GetCurrentStackFrame(),l=a.Push(n),h=this._path,c=this._currentKey,u=this._currentValue,_=this._ParsePathUnsafe(e);s.SetDebuggingEnabled(!1);for(const[d,p]of Object.entries(t)){this._path=Ba.cloneArray(_),this._path.push(d),this._currentKey=d,this._currentValue=p,i.PushCopySol(r);const m=this.GetObjectClass().GetCurrentSol();m.PickOne(this.GetInstance()),n.Retrigger(o,l),i.PopSol(r)}s.SetDebuggingEnabled(!0),this._path=h,this._InvalidateLocationCache(),this._currentKey=c,this._currentValue=u,a.Pop()}return!1},OnParseError(){return!0},OnParseSuccess(){return!0}}}{const $a=self.C3;$a.Plugins.Json.Acts={Parse(e){try{this._SetData(JSON.parse(e)),this.Trigger($a.Plugins.Json.Cnds.OnParseSuccess)}catch(e){console.warn("[JSON plugin] Failed to parse JSON data: ",e),this._SetData({}),this.Trigger($a.Plugins.Json.Cnds.OnParseError)}},SetPath(e){this._SetPath(e)},SetValue(e,t){this._SetValue(e,t)},SetArray(e,t){let s=this._GetValue(e);Array.isArray(s)?$a.resizeArray(s,t,0):(s=[],$a.extendArray(s,t,0),this._SetValue(e,s))},SetObject(e){this._SetValue(e,{})},SetJSON(e,t){let s=null;try{s=JSON.parse(t),this.Trigger($a.Plugins.Json.Cnds.OnParseSuccess)}catch(e){console.warn("[JSON plugin] Failed to parse JSON data: ",e),this.Trigger($a.Plugins.Json.Cnds.OnParseError)}this._SetValue(e,s)},SetNull(e){this._SetValue(e,null)},SetBoolean(e,t){this._SetValue(e,0!==t)},ToggleBoolean(e){const t=this._GetValue(e);"boolean"==typeof t&&this._SetValue(e,!t)},AddTo(e,t){const s=this._GetValue(e);"number"==typeof s&&this._SetValue(e,s+t)},SubtractFrom(e,t){const s=this._GetValue(e);"number"==typeof s&&this._SetValue(e,s-t)},DeleteKey(e){this._DeleteKey(e)},PushValue(e,t,s){const i=this._GetValue(t);Array.isArray(i)&&(0===e?i.push(s):i.unshift(s),this._InvalidateValueCache())},PopValue(e,t){const s=this._GetValue(t);Array.isArray(s)&&(0===e?s.pop():s.shift(),this._InvalidateValueCache())},InsertValue(e,t,s){const i=this._GetValue(t);Array.isArray(i)&&(i.splice(s,0,e),this._InvalidateValueCache())},RemoveValues(e,t,s){const i=this._GetValue(t);Array.isArray(i)&&0<e&&(i.splice(s,e),this._InvalidateValueCache())}}}{const N0=self.C3;N0.Plugins.Json.Exps={ToCompactString(){try{return JSON.stringify(this._data)}catch(e){return""}},ToBeautifiedString(){try{return JSON.stringify(this._data,null,4)}catch(e){return""}},Get(e){return this._GetSafeValue(e)},GetAsCompactString(e){const t=this._GetValue(e);return JSON.stringify(t)},GetAsBeautifiedString(e){const t=this._GetValue(e);return JSON.stringify(t,null,4)},Front(e){const t=this._GetValue(e);if(Array.isArray(t)){const s=t[0];return this._ToSafeValue(s)}return-1},Back(e){const t=this._GetValue(e);if(Array.isArray(t)){const s=t.at(-1);return this._ToSafeValue(s)}return-1},Type(e){return this._GetTypeOf(e)},ArraySize(e){const t=this._GetValue(e);return Array.isArray(t)?t.length:-1},Path(){return this._path.map(e=>e.replace(/\./g,"\\.")).join(".")},CurrentKey(){return this._currentKey},CurrentValue(){return this._ToSafeValue(this._currentValue)},CurrentType(){return this._JSONTypeOf(this._currentValue)}}}{const a=self.C3;a.Plugins.Tilemap=class extends a.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}},a.Plugins.Tilemap.TILE_FLIPPED_HORIZONTAL=-2147483648,a.Plugins.Tilemap.TILE_FLIPPED_VERTICAL=1073741824,a.Plugins.Tilemap.TILE_FLIPPED_DIAGONAL=536870912,a.Plugins.Tilemap.TILE_FLAGS_MASK=3758096384,a.Plugins.Tilemap.TILE_ID_MASK=536870911}{const d=self.C3,e=d.Plugins.Tilemap.TILE_FLIPPED_HORIZONTAL,f=d.Plugins.Tilemap.TILE_FLIPPED_VERTICAL,g=d.Plugins.Tilemap.TILE_FLIPPED_DIAGONAL,h=d.Plugins.Tilemap.TILE_ID_MASK;d.Plugins.Tilemap.Type=class extends d.SDKTypeBase{constructor(e){super(e),this._tilePolys=[],this._areTilePolysCached=!1,this._maxTileIndex=0,this._brushesData=[],this._nameToIndexMap=null}Release(){this._nameToIndexMap.clear(),this._nameToIndexMap=null,super.Release()}OnCreate(){this.GetImageInfo().LoadAsset(this._runtime)}LoadTextures(e){return this.GetImageInfo().LoadStaticTexture(e,{sampling:this._runtime.GetSampling()})}ReleaseTextures(){this.GetImageInfo().ReleaseTexture()}OnDynamicTextureLoadComplete(){for(const e of this.GetObjectClass().instancesIncludingPendingCreate())e.GetSdkInstance()._OnDynamicTextureLoadComplete()}LoadTilemapData(e,t,s){this._maxTileIndex=t;for(const i of e)if(i){const n=i[0],r=!!i[1];this._tilePolys.push({poly:n,use:r,flipmap:[[[null,null],[null,null]],[[null,null],[null,null]]]})}else this._tilePolys.push(null);for(const a of s){const o=a[0],l=a[1],h=a[2];this._brushesData.push({name:o,type:l,tileData:h})}}_ForceCacheOfTileCollisionPolys(e,t){this._areTilePolysCached=!1,this._MaybeCacheTileCollisionPolys(e,t)}_MaybeCacheTileCollisionPolys(s,i){if(!this._areTilePolysCached){this._areTilePolysCached=!0;for(let e=0,t=this._tilePolys.length;e<t;++e)this._tilePolys[e]&&(this._CacheTilePoly(e,s,i,!1,!1,!1),this._CacheTilePoly(e,s,i,!1,!1,!0),this._CacheTilePoly(e,s,i,!1,!0,!1),this._CacheTilePoly(e,s,i,!1,!0,!0),this._CacheTilePoly(e,s,i,!0,!1,!1),this._CacheTilePoly(e,s,i,!0,!1,!0),this._CacheTilePoly(e,s,i,!0,!0,!1),this._CacheTilePoly(e,s,i,!0,!0,!0))}}_CacheTilePoly(e,t,s,i,n,r){if(!(e<0||e>=this._tilePolys.length)){const a=this._tilePolys[e];if(a){const o=d.New(d.CollisionPoly,a.poly,a.use);o.transform(t,s,0),r&&o.diag(),i&&o.mirror(t/2),n&&o.flip(s/2),a.flipmap[i?1:0][n?1:0][r?1:0]=null,a.flipmap[i?1:0][n?1:0][r?1:0]=o}}}GetTilePoly(t){if(-1===t)return null;const s=t&h;if(s<0||s>=this._tilePolys.length)return null;const i=this._tilePolys[s];if(!i)return null;const n=t&e?1:0,r=t&f?1:0,a=t&g?1:0;return i.flipmap[n][r][a]}IsTilePolyEnabled(e){return!e||e.IsEnabled()}GetMaxTileIndex(){return this._maxTileIndex}GetBrushData(t){this._nameToIndexMap||(this._nameToIndexMap=new Map);const e=this._nameToIndexMap.get(t);if("number"==typeof e&&0<=e)return this._brushesData[e];for(let e=0;e<this._brushesData.length;e++)if(this._brushesData[e].name===t)return this._nameToIndexMap.set(t,e),this._brushesData[e]}}}{let RunLengthDecode2=function(e){const i=[],s=e.split(",");for(let e=0,t=s.length;e<t;++e){const n=s[e],r=n.indexOf("x");if(-1<r){let e=parseInt(n.substring(0,r),10),t=n.substring(r+1),s=parseInt(t,10);for(t.includes("h")&&(s|=ba),t.includes("v")&&(s|=ca),t.includes("d")&&(s|=da);0<e;--e)i.push(s)}else{let e=parseInt(n,10);n.includes("h")&&(e|=ba),n.includes("v")&&(e|=ca),n.includes("d")&&(e|=da),i.push(e)}}return i};RunLengthDecode=RunLengthDecode2;const U=self.C3,V=self.C3X,W=0,X=1,Y=2,Z=3,$=4,_=5,aa=6,ba=U.Plugins.Tilemap.TILE_FLIPPED_HORIZONTAL,ca=U.Plugins.Tilemap.TILE_FLIPPED_VERTICAL,da=U.Plugins.Tilemap.TILE_FLIPPED_DIAGONAL,ea=U.Plugins.Tilemap.TILE_FLAGS_MASK,fa=U.Plugins.Tilemap.TILE_ID_MASK,ga=U.New(U.Rect),ha=U.New(U.Rect),ia=U.New(U.Rect),ja=(U.Plugins.Tilemap.Instance=class extends U.SDKWorldInstanceBase{constructor(e,t){super(e);const s=this.GetWorldInfo();this._tileWidth=32,this._tileHeight=32,this._tileXoffset=0,this._tileYoffset=0,this._tileXspacing=0,this._tileYspacing=0,this._mapWidth=0,this._mapHeight=0,this._lastWidth=s.GetWidth(),this._lastHeight=s.GetHeight(),this._cellWidth=0,this._cellHeight=0,this._tileCells=[],this._tileTexQuads=new Map,this._isAnyQuadMapChanged=!0,this._ownImageInfo=null,t&&(s.SetVisible(t[W]),this._tileWidth=Math.max(t[X],1),this._tileHeight=Math.max(t[Y],1),this._tileXoffset=t[Z],this._tileYoffset=t[$],this._tileXspacing=t[_],this._tileYspacing=t[aa]),this._cellWidth=Math.ceil(this._runtime.GetOriginalViewportWidth()/this._tileWidth),this._cellHeight=Math.ceil(this._runtime.GetOriginalViewportHeight()/this._tileHeight),this._sdkType._MaybeCacheTileCollisionPolys(this._tileWidth,this._tileHeight),this._autoTiling=null}Release(){this._ReleaseOwnImage(),U.clearArray(this._tileCells),this._tileCells=null,this._tileTexQuads.clear(),this._tileTexQuads=null,super.Release()}_ReleaseOwnImage(){this._ownImageInfo&&(this._ownImageInfo.Release(),this._ownImageInfo=null)}LoadTilemapData(e,t,s){this._mapWidth=t,this._mapHeight=s,this._MaybeResizeTilemap(!0),this.SetTilesFromRLECSV(e),this._MaybeBuildAllQuadMap()}_MaybeResizeTilemap(e){const[t,n]=this.GetMapDisplaySize();if(!(t<=this._mapWidth&&n<=this._mapHeight)||e){let s=0,i=0;e?(s=Math.ceil(this._mapHeight/this._cellHeight),i=Math.ceil(this._mapWidth/this._cellWidth)):(s=this._tileCells.length,i=Math.ceil(this._mapWidth/this._cellWidth),n>this._mapHeight&&(this._mapHeight=n,s=Math.ceil(this._mapHeight/this._cellHeight)),t>this._mapWidth&&(this._mapWidth=t,i=Math.ceil(this._mapWidth/this._cellWidth)),this._SetAllQuadMapChanged(),this._SetPhysicsChanged(),this._runtime.UpdateRender());const r=this._tileCells;if(r.length<s)for(let e=r.length;e<s;++e)r.push([]);for(let t=0;t<s;++t){const a=r[t];for(let e=a.length;e<i;++e)a.push(U.New(U.Plugins.Tilemap.TileCell,this,e,t))}}}SetTilesFromRLECSV(e){let s=RunLengthDecode2(e),i=0,n=this._mapWidth,r=this._cellWidth,a=this._cellHeight;for(let t=0,e=this._mapHeight;t<e;++t)for(let e=0;e<n;++e){const o=s[i++],l=this.GetCellAt(e,t);l&&l.SetTileAt(e%r,t%a,o)}}GetTilesAsRLECSV(){let h="";if(!(this._mapWidth<=0||this._mapHeight<=0)){let s=1,i=this.GetTileAt(0,0),[n,e]=this.GetMapDisplaySize(),r=-1,a=!1,o=!1,l=!1;for(let t=0;t<e;++t)for(let e=0===t?1:0;e<n;++e){const c=this.GetTileAt(e,t);c===i?++s:(l=-1===i?(r=-1,a=!1,o=!1):(r=i&fa,a=0!=(i&ba),o=0!=(i&ca),0!=(i&da)),1===s?h+=""+r:h+=s+"x"+r,a&&(h+="h"),o&&(h+="v"),l&&(h+="d"),h+=",",s=1,i=c)}l=-1===i?(r=-1,a=!1,o=!1):(r=i&fa,a=0!=(i&ba),o=0!=(i&ca),0!=(i&da)),1===s?h+=""+r:h+=s+"x"+r,a&&(h+="h"),o&&(h+="v"),l&&(h+="d")}return h}_SetAllQuadMapChanged(){const s=this._tileCells;for(let e=0,t=s.length;e<t;++e){const i=s[e];for(let e=0,t=i.length;e<t;++e)i[e]._SetQuadMapChanged()}this._isAnyQuadMapChanged=!0}_MaybeBuildAllQuadMap(){if(this._isAnyQuadMapChanged){this._isAnyQuadMapChanged=!1;const s=this._tileCells;for(let e=0,t=s.length;e<t;++e){const i=s[e];for(let e=0,t=i.length;e<t;++e)i[e].MaybeBuildQuadMap()}}}SetTileChanged(){this._isAnyQuadMapChanged=!0,this._SetPhysicsChanged(),this._runtime.UpdateRender()}_SetPhysicsChanged(){this.GetWorldInfo().SetPhysicsBodyChanged(!0)}GetCellAt(e,t){if(e<0||t<0)return null;const s=Math.floor(t/this._cellHeight);if(s>=this._tileCells.length)return null;const i=this._tileCells[s],n=Math.floor(e/this._cellWidth);return n>=i.length?null:i[n]}GetCellAtIndex(e,t){if(e<0||t<0||t>=this._tileCells.length)return null;const s=this._tileCells[t];return e>=s.length?null:s[e]}GetTileAt(e,t){if(e=Math.floor(e),t=Math.floor(t),e<0||t<0||e>=this._mapWidth||t>=this._mapHeight)return-1;const s=this.GetCellAt(e,t);return s?s.GetTilesArr()[t%this._cellHeight][e%this._cellWidth]:-1}SetTileAt(e,t,s){if(e=Math.floor(e),t=Math.floor(t),!(e<0||t<0||e>=this._mapWidth||t>=this._mapHeight||-1!==s&&(s&fa)>this.GetMaxTileIndex())){const i=this.GetCellAt(e,t);i&&i.SetTileAt(e%this._cellWidth,t%this._cellHeight,s)}}GetMaxTileIndex(){return this._sdkType.GetMaxTileIndex()}WorldToCellX(e){return Math.floor((e-this.GetWorldInfo().GetX())/(this._cellWidth*this._tileWidth))}WorldToCellY(e){return Math.floor((e-this.GetWorldInfo().GetY())/(this._cellHeight*this._tileHeight))}WorldToTileX(e){return Math.floor((e-this.GetWorldInfo().GetX())/this._tileWidth)}WorldToTileY(e){return Math.floor((e-this.GetWorldInfo().GetY())/this._tileHeight)}GetMapWidth(){return this._mapWidth}GetMapHeight(){return this._mapHeight}GetMapDisplayWidth(){return Math.floor(this.GetWorldInfo().GetWidth()/this.GetTileWidth())}GetMapDisplayHeight(){return Math.floor(this.GetWorldInfo().GetHeight()/this.GetTileHeight())}GetMapDisplaySize(){const e=this.GetWorldInfo();return[Math.floor(e.GetWidth()/this.GetTileWidth()),Math.floor(e.GetHeight()/this.GetTileHeight())]}GetTileWidth(){return this._tileWidth}GetTileHeight(){return this._tileHeight}GetCellWidth(){return this._cellWidth}GetCellHeight(){return this._cellHeight}GetCollisionRectCandidates(e,s){const i=this.WorldToCellX(e.getLeft()),n=this.WorldToCellY(e.getTop()),r=this.WorldToCellX(e.getRight()),a=this.WorldToCellY(e.getBottom());for(let t=i;t<=r;++t)for(let e=n;e<=a;++e){const o=this.GetCellAtIndex(t,e);o&&(o.MaybeBuildQuadMap(),U.appendArray(s,o.GetCollisionRects()))}}TestPointOverlapTile(e,t){const s=this.WorldToTileX(e),i=this.WorldToTileY(t),n=this.GetTileAt(s,i);if(-1===n)return!1;const r=this._sdkType.GetTilePoly(n);if(!r)return!0;if(!this._sdkType.IsTilePolyEnabled(r))return!1;const a=this.GetWorldInfo(),o=Math.floor((e-a.GetX())/this._tileWidth)*this._tileWidth+a.GetX(),l=Math.floor((t-a.GetY())/this._tileHeight)*this._tileHeight+a.GetY();return e-=o,t-=l,r.containsPoint(e,t)}GetAllCollisionRects(s){const i=this._tileCells;for(let e=0,t=i.length;e<t;++e){const n=i[e];for(let e=0,t=n.length;e<t;++e){const r=n[e];r.MaybeBuildQuadMap(),U.appendArray(s,r.GetCollisionRects())}}}GetCurrentImageInfo(){return this._ownImageInfo||this._objectClass.GetImageInfo()}GetTileUvQuad(e){const t=this._tileTexQuads,s=t.get(e);if(s)return s;const i=e&fa,n=0!=(e&ba),r=0!=(e&ca),a=0!=(e&da),o=this.GetCurrentImageInfo(),l=o.GetWidth(),h=this._tileWidth,c=this._tileXoffset,u=this._tileXspacing,_=Math.floor((l-c)/(h+u)*h)+u,d=Math.floor(_/h),p=i%d,m=Math.floor(i/d),g=o.GetOffsetX()+this._tileXoffset+(this._tileWidth+this._tileXspacing)*p,f=o.GetOffsetY()+this._tileYoffset+(this._tileHeight+this._tileYspacing)*m,S=(ga.setWH(g,f,this._tileWidth,this._tileHeight),ga.divide(o.GetSheetWidth(),o.GetSheetHeight()),U.New(U.Quad));return S.setFromRect(ga),a&&S.diag(),n&&S.mirror(),r&&S.flip(),S.offset(p,m),t.set(e,S),S}_OnDynamicTextureLoadComplete(){this._tileTexQuads.clear(),this._SetAllQuadMapChanged()}Draw(n){const e=this.GetCurrentImageInfo(),t=e.GetTexture();if(t){ga.copy(e.GetTexRect()),ga.offsetLeft(this._tileXoffset/t.GetWidth()),ga.offsetTop(this._tileYoffset/t.GetHeight()),n.SetTilemapFillMode(),n.SetTilemapInfo(ga,t.GetWidth(),t.GetHeight(),this._tileWidth,this._tileHeight,this._tileXspacing,this._tileYspacing),n.SetTexture(t);const r=this.GetWorldInfo(),a=r.GetLayer();r.GetWidth()===this._lastWidth&&r.GetHeight()===this._lastHeight||(this._SetPhysicsChanged(),this._SetAllQuadMapChanged(),this._lastWidth=r.GetWidth(),this._lastHeight=r.GetHeight());let s=r.GetX(),i=r.GetY();this._runtime.IsPixelRoundingEnabled()&&(s=Math.round(s),i=Math.round(i));const o=this._cellWidth*this._tileWidth,l=this._cellHeight*this._tileHeight,h=r.GetTotalZElevation(),c=ha;if(a.Has3DCamera()){c.set(-1/0,-1/0,1/0,1/0);const u=ia,_=a._GetViewFrustum();for(const d of this._tileCells)for(const p of d)p.GetLayoutRect(u),_.ContainsAABB(u.getLeft(),u.getTop(),h,u.getRight(),u.getBottom(),h)&&(p.MaybeBuildQuadMap(),p.Draw(n,c,s,i))}else{a.GetViewportForZ(h,c);const m=Math.floor((c.getLeft()-s)/o),g=Math.floor((c.getRight()-s)/o),f=Math.floor((c.getTop()-i)/l),S=Math.floor((c.getBottom()-i)/l);for(let t=m;t<=g;++t)for(let e=f;e<=S;++e){const C=this.GetCellAtIndex(t,e);C&&(C.MaybeBuildQuadMap(),C.Draw(n,c,s,i))}}}}SaveToJson(){this._MaybeResizeTilemap();const[e,t]=this.GetMapDisplaySize();return{tw:this._tileWidth,th:this._tileHeight,tox:this._tileXoffset,toy:this._tileYoffset,tsx:this._tileXspacing,tsy:this._tileYspacing,w:e,h:t,d:this.GetTilesAsRLECSV()}}LoadFromJson(e){this._tileWidth=e.tw,this._tileHeight=e.th,this._tileXoffset=e.tox,this._tileYoffset=e.toy,this._tileXspacing=e.tsx,this._tileYspacing=e.tsy,this._mapWidth=e.w,this._mapHeight=e.h,this._MaybeResizeTilemap(!0),this.SetTilesFromRLECSV(e.d),this._SetPhysicsChanged(),this._SetAllQuadMapChanged()}GetAsJsonString(){this._MaybeResizeTilemap();const[e,t]=this.GetMapDisplaySize();return JSON.stringify({c2tilemap:!0,width:e,height:t,data:this.GetTilesAsRLECSV()})}StateComboToFlags(e){switch(e){case 0:return 0;case 1:return ba;case 2:return ca;case 3:return ba|da;case 4:return ba|ca;case 5:return ca|da;case 6:return ba|ca|da;case 7:return da;default:return 0}}GetPropertyValueByIndex(e){switch(e){case X:return this._tileWidth;case Y:return this._tileHeight;case Z:return this._tileXoffset;case $:return this._tileYoffset;case _:return this._tileXspacing;case aa:return this._tileYspacing}}SetPropertyValueByIndex(e,t){switch(e){case X:this._tileWidth!==t&&(this._tileWidth=Math.max(t,1),this._cellWidth=Math.ceil(this._runtime.GetOriginalViewportWidth()/this._tileWidth),this._sdkType._ForceCacheOfTileCollisionPolys(),this._UpdateQuadMaps());break;case Y:this._tileHeight!==t&&(this._tileHeight=Math.max(t,1),this._cellHeight=Math.ceil(this._runtime.GetOriginalViewportHeight()/this._tileHeight),this._sdkType._ForceCacheOfTileCollisionPolys(),this._UpdateQuadMaps());break;case Z:this._tileXoffset!==t&&(this._tileXoffset=t,this._UpdateQuadMaps());break;case $:this._tileYoffset!==t&&(this._tileYoffset=t,this._UpdateQuadMaps());break;case _:this._tileXspacing!==t&&(this._tileXspacing=t,this._UpdateQuadMaps());break;case aa:this._tileYspacing!==t&&(this._tileYspacing=t,this._UpdateQuadMaps())}}_UpdateQuadMaps(){this._tileTexQuads.clear(),this._SetAllQuadMapChanged(),this._MaybeBuildAllQuadMap()}GetScriptInterfaceClass(){return ka}},new WeakMap),ka=self.ITilemapInstance=class extends self.IWorldInstance{constructor(){super(),ja.set(this,self.IInstance._GetInitInst().GetSdkInstance())}get mapWidth(){return ja.get(this).GetMapWidth()}get mapHeight(){return ja.get(this).GetMapHeight()}getMapSize(){const e=ja.get(this);return[e.GetMapWidth(),e.GetMapHeight()]}get mapDisplayWidth(){return ja.get(this).GetMapDisplayWidth()}get mapDisplayHeight(){return ja.get(this).GetMapDisplayHeight()}getMapDisplaySize(){const e=ja.get(this);return[e.GetMapDisplayWidth(),e.GetMapDisplayHeight()]}get tileWidth(){return ja.get(this).GetTileWidth()}get tileHeight(){return ja.get(this).GetTileHeight()}getTileSize(){const e=ja.get(this);return[e.GetTileWidth(),e.GetTileHeight()]}getTileAt(e,t){return V.RequireFiniteNumber(e),V.RequireFiniteNumber(t),ja.get(this).GetTileAt(e,t)}setTileAt(e,t,s){V.RequireFiniteNumber(e),V.RequireFiniteNumber(t),V.RequireFiniteNumber(s);const i=ja.get(this);i._MaybeResizeTilemap(),i.SetTileAt(e,t,s)}async replaceImage(e){V.RequireInstanceOf(e,Blob);const t=ja.get(this),s=t.GetRuntime(),i=U.New(U.ImageInfo);i.LoadDynamicBlobAsset(s,e),await i.LoadStaticTexture(s.GetRenderer(),{sampling:s.GetSampling()}),t.WasReleased()?i.Release():(t._ReleaseOwnImage(),t._ownImageInfo=i,t._tileTexQuads.clear(),t._SetAllQuadMapChanged(),s.UpdateRender())}};ka.TILE_FLIPPED_HORIZONTAL=ba,ka.TILE_FLIPPED_VERTICAL=ca,ka.TILE_FLIPPED_DIAGONAL=da,ka.TILE_FLAGS_MASK=ea,ka.TILE_ID_MASK=fa}{const w1=self.C3,x1=w1.Plugins.Tilemap.TILE_FLAGS_MASK,y1=w1.Plugins.Tilemap.TILE_ID_MASK;w1.Plugins.Tilemap.Cnds={CompareTileAt(e,t,s,i){let n=this.GetTileAt(e,t);return-1!==n&&(n&=y1),w1.compare(n,s,i)},CompareTileStateAt(e,t,s){let i=this.GetTileAt(e,t);return(-1!==i?i&x1:0)===this.StateComboToFlags(s)},OnURLLoaded(){return!0},OnURLFailed(){return!0},BrushExists(e){return this._autoTiling||(this._autoTiling=new w1.Plugins.Tilemap.AutoTiling(this,this._sdkType)),this._autoTiling.BrushExists(e)}}}{const K1=self.C3,L1=K1.Plugins.Tilemap.TILE_ID_MASK;K1.Plugins.Tilemap.Acts={EraseTile(e,t){this._MaybeResizeTilemap(),this.SetTileAt(e,t,-1)},SetTile(e,t,s,i){this._MaybeResizeTilemap(),this.SetTileAt(e,t,s&L1|this.StateComboToFlags(i))},SetTileState(e,t,s){const i=this.GetTileAt(e,t);-1!==i&&(this._MaybeResizeTilemap(),this.SetTileAt(e,t,i&L1|this.StateComboToFlags(s)))},EraseTileRange(e,t,s,i){const n=Math.floor(Math.max(e,0)),r=Math.floor(Math.max(t,0)),a=Math.floor(Math.min(e+s,this._mapWidth)),o=Math.floor(Math.min(t+i,this._mapHeight));for(let t=r;t<o;++t)for(let e=n;e<a;++e)this.SetTileAt(e,t,-1)},SetTileRange(e,t,s,i,n,r){this._MaybeResizeTilemap();const a=Math.floor(Math.max(e,0)),o=Math.floor(Math.max(t,0)),l=Math.floor(Math.min(e+s,this._mapWidth)),h=Math.floor(Math.min(t+i,this._mapHeight)),c=n&L1|this.StateComboToFlags(r);for(let t=o;t<h;++t)for(let e=a;e<l;++e)this.SetTileAt(e,t,c)},SetTileStateRange(e,t,s,i,n){this._MaybeResizeTilemap();const r=Math.floor(Math.max(e,0)),a=Math.floor(Math.max(t,0)),o=Math.floor(Math.min(e+s,this._mapWidth)),l=Math.floor(Math.min(t+i,this._mapHeight)),h=this.StateComboToFlags(n);for(let t=a;t<l;++t)for(let e=r;e<o;++e){const c=this.GetTileAt(e,t);-1!==c&&this.SetTileAt(e,t,c&L1|h)}},LoadFromJSON(e){let t=null;try{t=JSON.parse(e)}catch(e){return void console.error("[Construct] Failed to parse tilemap JSON: ",e)}t.c2tilemap?(this._mapWidth=t.width,this._mapHeight=t.height,this._MaybeResizeTilemap(!0),this.SetTilesFromRLECSV(t.data),this._SetAllQuadMapChanged(),this._SetPhysicsChanged()):console.error("[Construct] Unrecognized JSON data format")},JSONDownload(e){const t=URL.createObjectURL(new Blob([this.GetAsJsonString()],{type:"application/json"}));this._runtime.InvokeDownload(t,e)},async LoadURL(e,t){if(!this._ownImageInfo||this._ownImageInfo.GetURL()!==e){const s=this._runtime,i=K1.New(K1.ImageInfo);try{if(await i.LoadDynamicAsset(s,e),!i.IsLoaded())throw new Error("image failed to load");if(this.WasReleased())return i.Release(),null;const n=await i.LoadStaticTexture(s.GetRenderer(),{sampling:s.GetSampling()});if(!n)return}catch(e){return console.error("Load image from URL failed: ",e),void(this.WasReleased()||this.Trigger(K1.Plugins.Tilemap.Cnds.OnURLFailed))}this.WasReleased()?i.Release():(this._ReleaseOwnImage(),this._ownImageInfo=i,s.UpdateRender(),this._tileTexQuads.clear(),this._SetAllQuadMapChanged(),await this.TriggerAsync(K1.Plugins.Tilemap.Cnds.OnURLLoaded))}},SetEffect(e){2<=e&&e++,this.GetWorldInfo().SetBlendMode(e),this._runtime.UpdateRender()},SetTileWithBrush(e,t,s){this._MaybeResizeTilemap(),this._autoTiling||(this._autoTiling=new K1.Plugins.Tilemap.AutoTiling(this,this._sdkType)),this._autoTiling.SetAutoTile(e,t,s)},EraseTileWithBrush(e,t,s){this._MaybeResizeTilemap(),this._autoTiling||(this._autoTiling=new K1.Plugins.Tilemap.AutoTiling(this,this._sdkType)),this._autoTiling.EraseAutoTile(e,t,s)},SetTileWithBrushByName(e,t,s){K1.Plugins.Tilemap.Acts.SetTileWithBrush.call(this,e,t,s)},EraseTileWithBrushByName(e,t,s){K1.Plugins.Tilemap.Acts.EraseTileWithBrush.call(this,e,t,s)}}}{const a2=self.C3,b2=a2.Plugins.Tilemap.TILE_ID_MASK;a2.Plugins.Tilemap.Exps={TileAt(e,t){const s=this.GetTileAt(e,t);return-1===s?-1:s&b2},PositionToTileX(e){return this.WorldToTileX(e)},PositionToTileY(e){return this.WorldToTileY(e)},TileToPositionX(e){return e*this._tileWidth+this.GetWorldInfo().GetX()+this._tileWidth/2},TileToPositionY(e){return e*this._tileHeight+this.GetWorldInfo().GetY()+this._tileHeight/2},SnapX(e){const t=this.GetWorldInfo().GetX();return Math.floor((e-t)/this._tileWidth)*this._tileWidth+t+this._tileWidth/2},SnapY(e){const t=this.GetWorldInfo().GetY();return Math.floor((e-t)/this._tileHeight)*this._tileHeight+t+this._tileHeight/2},TilesJSON(){return this.GetAsJsonString()},TileWidth(){return this.GetTileWidth()},TileHeight(){return this.GetTileHeight()},MapDisplayWidth(){return this.GetMapDisplayWidth()},MapDisplayHeight(){return this.GetMapDisplayHeight()}}}{const C33=self.C3,TILE_FLIPPED_HORIZONTAL=C33.Plugins.Tilemap.TILE_FLIPPED_HORIZONTAL,TILE_FLIPPED_VERTICAL=C33.Plugins.Tilemap.TILE_FLIPPED_VERTICAL,TILE_FLIPPED_DIAGONAL=C33.Plugins.Tilemap.TILE_FLIPPED_DIAGONAL,TILE_ID_MASK=C33.Plugins.Tilemap.TILE_ID_MASK,tempRect=C33.New(C33.Rect),tempQuad=C33.New(C33.Quad);C33.Plugins.Tilemap.TileQuad=class extends C33.DefendedBase{constructor(){super(),this._id=-1,this._tileId=-1,this._isHorizFlip=!1,this._isVertFlip=!1,this._isDiagFlip=!1,this._rc=C33.New(C33.Rect),this._uv=null}Update(e,t,s,i,n,r,a,o){this._id=e,this._tileId=e&TILE_ID_MASK,this._isHorizFlip=0!=(e&TILE_FLIPPED_HORIZONTAL),this._isVertFlip=0!=(e&TILE_FLIPPED_VERTICAL),this._isDiagFlip=0!=(e&TILE_FLIPPED_DIAGONAL),this._rc.setWH(i*t+r,n*s+a,t,s),this._uv=o.GetTileUvQuad(this._id)}Draw(e,t,s,i,n){tempRect.copy(this._rc),tempRect.offset(s,i),tempRect.intersectsRect(t)&&(tempQuad.setFromRect(tempRect),e.Quad4(tempQuad,this._uv))}}}{const C33=self.C3;C33.Plugins.Tilemap.TileCollisionRect=class extends C33.DefendedBase{constructor(){super(),this._id=-1,this._poly=null,this._rc=C33.New(C33.Rect)}Update(e,t,s,i,n,r,a,o){this._id=e,this._poly=t,this._rc.setWH(n*s+a,r*i+o,s,i)}ExtendRight(e){this._rc.setRight(this._rc.getRight()+e)}GetTileId(){return this._id}HasPoly(){return!!this._poly}GetPoly(){return this._poly}GetRect(){return this._rc}}}{const C33=self.C3,TILE_ID_MASK=C33.Plugins.Tilemap.TILE_ID_MASK;C33.Plugins.Tilemap.TileCell=class extends C33.DefendedBase{constructor(e,t,s){super();const i=e.GetCellWidth(),n=e.GetCellHeight();this._sdkInst=e,this._x=t,this._y=s,this._left=this._x*i*e.GetTileWidth(),this._top=this._y*n*e.GetTileHeight(),this._tiles=[],this._quads=[],this._collisionRects=[],this._isQuadMapValid=!1;for(let e=0;e<n;++e){const r=new Int32Array(i);r.fill(-1),this._tiles.push(r)}}Clear(){const s=this._sdkInst.GetCellWidth(),t=this._sdkInst.GetCellHeight(),i=this._tiles;if(i.length<t)for(let e=i.length;e<t;++e)i.push(new Int32Array(s));else i.length>t&&C33.truncateArray(i,t);for(let t=0,e=i.length;t<e;++t){let e=i[t];e.length!==s&&(e=new Int32Array(s),i[t]=e),e.fill(-1)}}GetLayoutRect(e){const t=this._sdkInst,s=t.GetWorldInfo(),i=t.GetCellWidth()*t.GetTileWidth(),n=t.GetCellHeight()*t.GetTileHeight(),r=s.GetX()+this._left,a=s.GetY()+this._top;e.set(r,a,r+i,a+n)}_SetQuadMapChanged(){this._isQuadMapValid=!1}MaybeBuildQuadMap(){if(!this._isQuadMapValid){const c=this._sdkInst,u=c.GetSdkType(),t=c.GetWorldInfo(),_=c.GetTileWidth(),d=c.GetTileHeight(),p=c.GetCellWidth(),m=c.GetCellHeight(),g=this._left,f=this._top;if(!(_<=0||d<=0)){let i=Math.min(c.GetMapWidth(),Math.floor(t.GetWidth()/_)),e=Math.min(c.GetMapHeight(),Math.floor(t.GetHeight()/d)),n=(i-=g/_,e-=f/d,i>p&&(i=p),e>m&&(e=m),this._tiles),r=this._quads,a=0;for(let s=0;s<e;++s){const S=n[s];for(let t=0;t<i;++t){const C=S[t];if(-1!==C){let e=null;a<r.length?e=r[a]:(e=C33.New(C33.Plugins.Tilemap.TileQuad),r.push(e)),e.Update(C,_,d,t,s,g,f,c),++a}}}a<r.length&&C33.truncateArray(r,a);let s=null,o=!1,l=this._collisionRects;C33.clearArray(l);for(let t=0;t<e;++t){const y=n[t];for(let e=0;e<i;++e){const G=y[e],I=(TILE_ID_MASK,u.GetTilePoly(G)),T=u.IsTilePolyEnabled(I);-1!==G&&T?!s||I||o?(s&&l.push(s),(s=C33.New(C33.Plugins.Tilemap.TileCollisionRect)).Update(G,I,_,d,e,t,g,f),o=!!I):s.ExtendRight(_):s&&(l.push(s),s=null,o=!1)}s&&(l.push(s),s=null,o=!1)}let h=l.length;for(let t=0;t<h;++t){const b=l[t];if(!b.HasPoly()){const P=b.GetRect();for(let e=t+1;e<h;++e){const A=l[e],R=A.GetRect();R.getTop()<P.getBottom()||R.getTop()>P.getBottom()||R.getRight()>P.getRight()||R.getLeft()>P.getLeft()||A.HasPoly()||R.getLeft()===P.getLeft()&&R.getRight()===P.getRight()&&(l.splice(e,1),--h,P.setBottom(P.getBottom()+d),--e)}}}this._isQuadMapValid=!0}}}SetTileAt(e,t,s){this._tiles[t][e]!==s&&(this._tiles[t][e]=s,this._isQuadMapValid=!1,this._sdkInst.SetTileChanged())}GetTilesArr(){return this._tiles}GetCollisionRects(){return this._collisionRects}Draw(s,i,n,r){const a=this._sdkInst,o=this._quads;for(let e=0,t=o.length;e<t;++e)o[e].Draw(s,i,n,r,a)}}}{const C33=self.C3,IGNORE_INDEX=-999,FORCE_INDEX=-998,EMPTY_INDEX=-1,PAINT_MODE=0,ERASE_MODE=1,AUTO_TILING_PATCH=Object.freeze([[0,0,0],[0,0,0],[0,0,0]]);C33.Plugins.Tilemap.AutoTiling=class{constructor(e,t){this._sdkInst=e,this._sdkType=t,this._brushAdapterInstances=[null,null],this._brushAdapterConstructors=[C33.Plugins.Tilemap.AutoTiling16,C33.Plugins.Tilemap.AutoTiling47],this._probabilityTable=new C33.ProbabilityTable}get AUTO_TILING_PATCH(){return AUTO_TILING_PATCH}get IGNORE_INDEX(){return IGNORE_INDEX}get FORCE_INDEX(){return FORCE_INDEX}get EMPTY_INDEX(){return EMPTY_INDEX}get PAINT_MODE(){return PAINT_MODE}get ERASE_MODE(){return ERASE_MODE}GetSdkIntance(){return this._sdkInst}GetSdkType(){return this._sdkType}SetAutoTile(e,t,s){this.BrushExists(s)&&(this._SetAutoTileMode(s,PAINT_MODE),this._SetAutoTilePatch(e,t,this._GetAutoTilePatch(e,t,s)))}EraseAutoTile(e,t,s){this.BrushExists(s)&&(this._SetAutoTileMode(s,ERASE_MODE),this._EraseTile(e,t),this._SetAutoTilePatch(e,t,this._GetAutoTilePatch(e,t,s)))}BrushExists(e){return!!this.GetSdkType().GetBrushData(e)}GetTile(e,t){return this.GetSdkIntance().GetTileAt(e,t)}DoesTileExist(e,t,s){const i=this.GetTile(e,t);return!!this.IsTileValid(i,!0,i,s)}IsTileValid(e,t,s,i){return e===EMPTY_INDEX||(!t||e!==FORCE_INDEX)&&t&&i&&!this._IsTileIndexInBrush(s,i)?0:1}GetTileIndex(e,t,s,i){const n=i.tileData[e];if(!n.length)return EMPTY_INDEX;if(1===n.length)return n[0][0];const r=this.GetTile(t,s);if(this.IsTileValid(r)){const a=n.some(e=>r===e[0]);if(a)return r}this._probabilityTable.Clear();for(let[e,t]of n)"number"!=typeof t&&(t=1),this._probabilityTable.AddItem(t,e);return this._probabilityTable.Sample()}_SetTile(e,t,s){e!==EMPTY_INDEX&&this.GetSdkIntance().SetTileAt(e,t,s)}_EraseTile(e,t){this.GetSdkIntance().SetTileAt(e,t,EMPTY_INDEX)}_IsTileIndexInBrush(e,t){for(const s of t.tileData)for(const[i]of s)if(i===e)return!0;return!1}_SetAutoTilePatch(e,t,s){s&&(this._SetTile(e-1,t-1,s[0][0]),this._SetTile(e,t-1,s[1][0]),this._SetTile(e+1,t-1,s[2][0]),this._SetTile(e-1,t,s[0][1]),this._SetTile(e,t,s[1][1]),this._SetTile(e+1,t,s[2][1]),this._SetTile(e-1,t+1,s[0][2]),this._SetTile(e,t+1,s[1][2]),this._SetTile(e+1,t+1,s[2][2]))}_GetBrushType(e){const t=this.GetSdkType().GetBrushData(e);return t.type}_MaybeCreateBrushAdapter(e){const t=this._GetBrushType(e);this._brushAdapterInstances[t]||(this._brushAdapterInstances[t]=new this._brushAdapterConstructors[t](this))}_SetAutoTileMode(e,t){this._MaybeCreateBrushAdapter(e);const s=this._GetBrushType(e);this._brushAdapterInstances[s]&&this._brushAdapterInstances[s].SetMode(t)}_GetAutoTilePatch(e,t,s){this._MaybeCreateBrushAdapter(s);const i=this.GetSdkType().GetBrushData(s);if(this._brushAdapterInstances[i.type])return this._brushAdapterInstances[i.type].BuildPatch(e,t,i)}}}{const C33=self.C3;C33.Plugins.Tilemap.AutoTiling16=class{constructor(e){this._auto=e,this._mode=e.PAINT_MODE}SetMode(e){this._mode=e}BuildPatch(e,t,s){return this._Build4BitAutoTilePatch(e,t,s)}_Build4BitAutoTilePatch(e,t,s){const i=this._mode===this._auto.PAINT_MODE?this._4BitAutoTiling(e,t,void 0,s):this._auto.EMPTY_INDEX,n=this._Get4BitAutoTile(e,t-1,"s",s),r=this._Get4BitAutoTile(e-1,t,"e",s),a=this._Get4BitAutoTile(e+1,t,"w",s),o=this._Get4BitAutoTile(e,t+1,"n",s),l=this._auto.AUTO_TILING_PATCH;return l[0][0]=this._auto.IGNORE_INDEX,l[1][0]=this._Get4BitTileIndex(n,e,t-1,s),l[2][0]=this._auto.IGNORE_INDEX,l[0][1]=this._Get4BitTileIndex(r,e-1,t,s),l[1][1]=this._Get4BitTileIndex(i,e,t,s),l[2][1]=this._Get4BitTileIndex(a,e+1,t,s),l[0][2]=this._auto.IGNORE_INDEX,l[1][2]=this._Get4BitTileIndex(o,e,t+1,s),l[2][2]=this._auto.IGNORE_INDEX,l}_Get4BitAutoTile(e,t,s,i){return this._auto.DoesTileExist(e,t,i)?this._4BitAutoTiling(e,t,s,i):this._auto.IGNORE_INDEX}_4BitAutoTiling(e,t,s,i){this._mode===this._auto.ERASE_MODE&&(s=void 0);const n=this._auto.GetTile(e,t-1),r=this._auto.GetTile(e-1,t),a=this._auto.GetTile(e+1,t),o=this._auto.GetTile(e,t+1),l="n"===s?this._auto.FORCE_INDEX:n,h="w"===s?this._auto.FORCE_INDEX:r,c="e"===s?this._auto.FORCE_INDEX:a,u="s"===s?this._auto.FORCE_INDEX:o,_=this._auto.IsTileValid(l,!0,n,i),d=this._auto.IsTileValid(h,!0,r,i),p=this._auto.IsTileValid(c,!0,a,i),m=this._auto.IsTileValid(u,!0,o,i);return+_+2*d+4*p+8*m}_Get4BitTileIndex(e,t,s,i){return e===this._auto.IGNORE_INDEX||e===this._auto.EMPTY_INDEX?e:this._auto.GetTileIndex(e,t,s,i)}}}{const C33=self.C3,TILE_INDEX_MAP=new Map([[2,1],[8,2],[10,3],[11,4],[16,5],[18,6],[22,7],[24,8],[26,9],[27,10],[30,11],[31,12],[64,13],[66,14],[72,15],[74,16],[75,17],[80,18],[82,19],[86,20],[88,21],[90,22],[91,23],[94,24],[95,25],[104,26],[106,27],[107,28],[120,29],[122,30],[123,31],[126,32],[127,33],[208,34],[210,35],[214,36],[216,37],[218,38],[219,39],[222,40],[223,41],[248,42],[250,43],[251,44],[254,45],[255,46],[0,47]]);C33.Plugins.Tilemap.AutoTiling47=class{constructor(e){this._auto=e,this._mode=e.PAINT_MODE}SetMode(e){this._mode=e}BuildPatch(e,t,s){return this._Build8BitAutoTilePatch(e,t,s)}_Build8BitAutoTilePatch(e,t,s){const i=this._mode===this._auto.PAINT_MODE?this._8BitAutoTiling(e,t,void 0,s):this._auto.EMPTY_INDEX,n=this._Get8BitAutoTile(e-1,t-1,"se",s),r=this._Get8BitAutoTile(e,t-1,"s",s),a=this._Get8BitAutoTile(e+1,t-1,"sw",s),o=this._Get8BitAutoTile(e-1,t,"e",s),l=this._Get8BitAutoTile(e+1,t,"w",s),h=this._Get8BitAutoTile(e-1,t+1,"ne",s),c=this._Get8BitAutoTile(e,t+1,"n",s),u=this._Get8BitAutoTile(e+1,t+1,"nw",s),_=this._auto.AUTO_TILING_PATCH;return _[0][0]=this._Get8BitTileIndex(n,e-1,t-1,s),_[1][0]=this._Get8BitTileIndex(r,e,t-1,s),_[2][0]=this._Get8BitTileIndex(a,e+1,t-1,s),_[0][1]=this._Get8BitTileIndex(o,e-1,t,s),_[1][1]=this._Get8BitTileIndex(i,e,t,s),_[2][1]=this._Get8BitTileIndex(l,e+1,t,s),_[0][2]=this._Get8BitTileIndex(h,e-1,t+1,s),_[1][2]=this._Get8BitTileIndex(c,e,t+1,s),_[2][2]=this._Get8BitTileIndex(u,e+1,t+1,s),_}_Get8BitAutoTile(e,t,s,i){return this._auto.DoesTileExist(e,t,i)?this._8BitAutoTiling(e,t,s,i):this._auto.IGNORE_INDEX}_8BitAutoTiling(e,t,s,i){this._mode===this._auto.ERASE_MODE&&(s=void 0);const n=this._auto.GetTile(e,t-1),r=this._auto.GetTile(e-1,t),a=this._auto.GetTile(e+1,t),o=this._auto.GetTile(e,t+1),l=this._auto.GetTile(e-1,t-1),h=this._auto.GetTile(e+1,t-1),c=this._auto.GetTile(e-1,t+1),u=this._auto.GetTile(e+1,t+1),_="n"===s?this._auto.FORCE_INDEX:n,d="w"===s?this._auto.FORCE_INDEX:r,p="e"===s?this._auto.FORCE_INDEX:a,m="s"===s?this._auto.FORCE_INDEX:o,g="nw"===s?this._auto.FORCE_INDEX:l,f="ne"===s?this._auto.FORCE_INDEX:h,S="sw"===s?this._auto.FORCE_INDEX:c,C="se"===s?this._auto.FORCE_INDEX:u,y=this._auto.IsTileValid(_,!0,n,i),G=this._auto.IsTileValid(d,!0,r,i),I=this._auto.IsTileValid(p,!0,a,i),T=this._auto.IsTileValid(m,!0,o,i),b=y&&G?this._auto.IsTileValid(g,!0,l,i):0,P=y&&I?this._auto.IsTileValid(f,!0,h,i):0,A=T&&G?this._auto.IsTileValid(S,!0,c,i):0,R=T&&I?this._auto.IsTileValid(C,!0,u,i):0;return+b+2*y+4*P+8*G+16*I+32*A+64*T+128*R}_Get8BitTileIndex(e,t,s,i){return e===this._auto.IGNORE_INDEX||e===this._auto.EMPTY_INDEX?e:this._auto.GetTileIndex(TILE_INDEX_MAP.get(e),t,s,i)}}}{const a=self.C3;a.Behaviors.Sin=class extends a.SDKBehaviorBase{constructor(e){super(e)}Release(){super.Release()}}}{const d=self.C3;d.Behaviors.Sin.Type=class extends d.SDKBehaviorTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const g=self.C3,h=self.C3X,i=self.IBehaviorInstance,j=0,k=1,l=2,m=3,n=4,o=5,p=6,q=7,r=8,s=0,t=1,u=2,v=3,w=4,x=5,y=6,z=7,A=8,B=9,C=0,D=1,E=2,F=3,G=4,H=2*Math.PI,I=Math.PI/2,J=3*Math.PI/2,K=[0,1,8,3,4,2,5,6,9,7],L=(g.Behaviors.Sin.Instance=class extends g.SDKBehaviorInstanceBase{constructor(e,t){super(e),this._i=0,this._movement=0,this._wave=0,this._period=0,this._mag=0,this._isEnabled=!0,this._basePeriod=0,this._basePeriodOffset=0,this._baseMag=0,this._periodRandom=0,this._periodOffsetRandom=0,this._magnitudeRandom=0,this._initialValue=0,this._initialValue2=0,this._lastKnownValue=0,this._lastKnownValue2=0,this._ratio=0,t&&(this._movement=K[t[j]],this._wave=t[k],this._periodRandom=this._runtime.Random()*t[m],this._basePeriod=t[l],this._period=t[l],this._period+=this._periodRandom,this._basePeriodOffset=t[n],0!==this._period&&(this._periodOffsetRandom=this._runtime.Random()*t[o],this._i=t[n]/this._period*H,this._i+=this._periodOffsetRandom/this._period*H),this._magnitudeRandom=this._runtime.Random()*t[q],this._baseMag=t[p],this._mag=t[p],this._mag+=this._magnitudeRandom,this._isEnabled=!!t[r]),this._movement===x&&(this._mag=g.toRadians(this._mag)),this.Init(),this._isEnabled&&this._StartTicking()}Release(){super.Release()}SaveToJson(){return{i:this._i,e:this._isEnabled,mv:this._movement,w:this._wave,p:this._period,mag:this._mag,iv:this._initialValue,iv2:this._initialValue2,r:this._ratio,lkv:this._lastKnownValue,lkv2:this._lastKnownValue2}}LoadFromJson(e){this._i=e.i,this._SetEnabled(e.e),this._movement=e.mv,this._wave=e.w,this._period=e.p,this._mag=e.mag,this._initialValue=e.iv,this._initialValue2=e.iv2,this._ratio=e.r,this._lastKnownValue=e.lkv,this._lastKnownValue2=e.lkv2}Init(){const e=this._inst.GetWorldInfo();switch(this._movement){case s:this._initialValue=e.GetX();break;case t:this._initialValue=e.GetY();break;case u:this._initialValue=e.GetWidth(),this._ratio=e.GetHeight()/e.GetWidth();break;case v:this._initialValue=e.GetWidth();break;case w:this._initialValue=e.GetHeight();break;case x:this._initialValue=e.GetAngle();break;case y:this._initialValue=e.GetOpacity();break;case z:this._initialValue=0;break;case A:this._initialValue=e.GetX(),this._initialValue2=e.GetY();break;case B:this._initialValue=e.GetZElevation()}this._lastKnownValue=this._initialValue,this._lastKnownValue2=this._initialValue2}WaveFunc(e){switch(e%=H,this._wave){case C:return Math.sin(e);case D:return e<=I?e/I:e<=J?1-2*(e-I)/Math.PI:(e-J)/I-1;case E:return 2*e/H-1;case F:return-2*e/H+1;case G:return e<Math.PI?-1:1}return 0}Tick(){const e=this._runtime.GetDt(this._inst);this._isEnabled&&0!==e&&(0===this._period?this._i=0:this._i=(this._i+e/this._period*H)%H,this._UpdateFromPhase())}_UpdateFromPhase(){const e=this._inst.GetWorldInfo();switch(this._movement){case s:e.GetX()!==this._lastKnownValue&&(this._initialValue+=e.GetX()-this._lastKnownValue),e.SetX(this._initialValue+this.WaveFunc(this._i)*this._mag),this._lastKnownValue=e.GetX();break;case t:e.GetY()!==this._lastKnownValue&&(this._initialValue+=e.GetY()-this._lastKnownValue),e.SetY(this._initialValue+this.WaveFunc(this._i)*this._mag),this._lastKnownValue=e.GetY();break;case u:e.SetWidth(this._initialValue+this.WaveFunc(this._i)*this._mag),e.SetHeight(e.GetWidth()*this._ratio);break;case v:e.SetWidth(this._initialValue+this.WaveFunc(this._i)*this._mag);break;case w:e.SetHeight(this._initialValue+this.WaveFunc(this._i)*this._mag);break;case x:e.GetAngle()!==this._lastKnownValue&&(this._initialValue=g.clampAngle(this._initialValue+(e.GetAngle()-this._lastKnownValue))),e.SetAngle(this._initialValue+this.WaveFunc(this._i)*this._mag),this._lastKnownValue=e.GetAngle();break;case y:e.SetOpacity(this._initialValue+this.WaveFunc(this._i)*this._mag/100);break;case A:e.GetX()!==this._lastKnownValue&&(this._initialValue+=e.GetX()-this._lastKnownValue),e.GetY()!==this._lastKnownValue2&&(this._initialValue2+=e.GetY()-this._lastKnownValue2),e.SetX(this._initialValue+Math.cos(e.GetAngle())*this.WaveFunc(this._i)*this._mag),e.SetY(this._initialValue2+Math.sin(e.GetAngle())*this.WaveFunc(this._i)*this._mag),this._lastKnownValue=e.GetX(),this._lastKnownValue2=e.GetY();break;case B:e.SetZElevation(this._initialValue+this.WaveFunc(this._i)*this._mag)}e.SetBboxChanged()}_OnSpriteFrameChanged(e,t){}_SetPeriod(e){this._period=e}_GetPeriod(){return this._period}_SetMagnitude(e){this._mag=e}_SetMagnitude_ConvertAngle(e){5===this._movement&&(e=g.toRadians(e)),this._SetMagnitude(e)}_GetMagnitude(){return this._mag}_GetMagnitude_ConvertAngle(){let e=this._GetMagnitude();return 5===this._movement?g.toDegrees(e):e}_SetMovement(e){5===this._movement&&5!==e&&(this._mag=g.toDegrees(this._mag)),this._movement=e,this.Init()}_GetMovement(){return this._movement}_SetWave(e){this._wave=e}_GetWave(){return this._wave}_SetPhase(e){this._i=g.clamp(e,0,2*Math.PI),this._UpdateFromPhase()}_GetPhase(){return this._i}_SetEnabled(e){this._isEnabled=!!e,this._isEnabled?this._StartTicking():this._StopTicking()}_IsEnabled(){return this._isEnabled}GetPropertyValueByIndex(e){switch(e){case j:return this._movement;case k:return this._wave;case l:return this._basePeriod;case p:return this._baseMag;case r:return this._isEnabled}}SetPropertyValueByIndex(e,t){switch(e){case j:this._movement=K[t],this.Init();break;case k:this._wave=t;break;case l:this._basePeriod=t,this._period=this._basePeriod+this._periodRandom,this._isEnabled||(0!==this._period?(this._i=this._basePeriodOffset/this._period*H,this._i+=this._periodOffsetRandom/this._period*H):this._i=0);break;case p:this._baseMag=t,this._mag=this._baseMag+this._magnitudeRandom,this._movement===x&&(this._mag=g.toRadians(this._mag));break;case r:this._isEnabled=!!t}}GetDebuggerProperties(){const e="behaviors.sin";return[{title:"$"+this.GetBehaviorType().GetName(),properties:[{name:e+".properties.enabled.name",value:this._IsEnabled(),onedit:e=>this._SetEnabled(e)},{name:e+".properties.period.name",value:this._GetPeriod(),onedit:e=>this._SetPeriod(e)},{name:e+".properties.magnitude.name",value:this._GetMagnitude_ConvertAngle(),onedit:e=>this._SetMagnitude_ConvertAngle(e)},{name:e+".debugger.value",value:this.WaveFunc(this._GetPhase())*this._GetMagnitude_ConvertAngle()}]}]}GetScriptInterfaceClass(){return self.ISineBehaviorInstance}},new WeakMap),M=["horizontal","vertical","size","width","height","angle","opacity","value-only","forwards-backwards","z-elevation"],N=["sine","triangle","sawtooth","reverse-sawtooth","square"];self.ISineBehaviorInstance=class extends i{constructor(){super(),L.set(this,i._GetInitInst().GetSdkInstance())}set period(e){h.RequireFiniteNumber(e),L.get(this)._SetPeriod(e)}get period(){return L.get(this)._GetPeriod()}set magnitude(e){h.RequireFiniteNumber(e),L.get(this)._SetMagnitude(e)}get magnitude(){return L.get(this)._GetMagnitude()}set phase(e){L.get(this)._SetPhase(e)}get phase(){return L.get(this)._GetPhase()}set movement(e){h.RequireString(e);const t=M.indexOf(e);if(-1===t)throw new Error("invalid movement");L.get(this)._SetMovement(t)}get movement(){return M[L.get(this)._GetMovement()]}set wave(e){h.RequireString(e);const t=N.indexOf(e);if(-1===t)throw new Error("invalid wave");L.get(this)._SetWave(t)}get wave(){return N[L.get(this)._GetWave()]}get value(){const e=L.get(this);return e.WaveFunc(e._GetPhase())*e._GetMagnitude()}updateInitialState(){L.get(this).Init()}set isEnabled(e){L.get(this)._SetEnabled(!!e)}get isEnabled(){return L.get(this)._IsEnabled()}}}{const va=self.C3;va.Behaviors.Sin.Cnds={IsEnabled(){return this._IsEnabled()},CompareMovement(e){return this._GetMovement()===e},ComparePeriod(e,t){return va.compare(this._GetPeriod(),e,t)},CompareMagnitude(e,t){return va.compare(this._GetMagnitude_ConvertAngle(),e,t)},CompareWave(e){return this._GetWave()===e}}}{const Ca=self.C3;Ca.Behaviors.Sin.Acts={SetEnabled(e){this._SetEnabled(0!==e)},SetPeriod(e){this._SetPeriod(e)},SetMagnitude(e){this._SetMagnitude_ConvertAngle(e)},SetMovement(e){this._SetMovement(e)},SetWave(e){this._wave=e},SetPhase(e){const t=2*Math.PI;this._SetPhase(e*t%t)},UpdateInitialState(){this.Init()}}}{const Ka=self.C3;Ka.Behaviors.Sin.Exps={CyclePosition(){return this._GetPhase()/(2*Math.PI)},Period(){return this._GetPeriod()},Magnitude(){return this._GetMagnitude_ConvertAngle()},Value(){return this.WaveFunc(this._GetPhase())*this._GetMagnitude_ConvertAngle()}}}{const a=self.C3;a.Behaviors.NoSave=class extends a.SDKBehaviorBase{constructor(e){super(e)}Release(){super.Release()}}}{const d=self.C3;d.Behaviors.NoSave.Type=class extends d.SDKBehaviorTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const g=self.C3;g.Behaviors.NoSave.Instance=class extends g.SDKBehaviorInstanceBase{constructor(e,t){super(e)}Release(){super.Release()}}}{const k=self.C3;k.Behaviors.NoSave.Cnds={}}{const l=self.C3;l.Behaviors.NoSave.Acts={}}{const m=self.C3;m.Behaviors.NoSave.Exps={}}{const a=self.C3;a.Behaviors.Pin=class extends a.SDKBehaviorBase{constructor(e){super(e)}Release(){super.Release()}}}{const d=self.C3;d.Behaviors.Pin.Type=class extends d.SDKBehaviorTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const g=self.C3;g.Behaviors.Pin.Instance=class extends g.SDKBehaviorInstanceBase{constructor(e,t){super(e),this._pinInst=null,this._pinUid=-1,this._mode="",this._propSet=new Set,this._pinDist=0,this._pinAngle=0,this._pinImagePoint=0,this._dx=0,this._dy=0,this._dWidth=0,this._dHeight=0,this._dAngle=0,this._dz=0,this._lastKnownAngle=0,this._destroy=!1,t&&(this._destroy=t[0]);const s=this._runtime.Dispatcher();this._disposables=new g.CompositeDisposable(g.Disposable.From(s,"instancedestroy",e=>this._OnInstanceDestroyed(e.instance)),g.Disposable.From(s,"afterload",e=>this._OnAfterLoad()))}Release(){this._pinInst=null,super.Release()}_SetPinInst(e){e?(this._pinInst=e,this._StartTicking2()):(this._pinInst=null,this._StopTicking2())}_Pin(e,t,s){if(e){const i=e.GetFirstPicked(this._inst);if(i){this._mode=t,this._SetPinInst(i);const n=this._inst.GetWorldInfo(),r=i.GetWorldInfo();if("properties"===this._mode){const a=this._propSet;a.clear();for(const o of s)a.add(o);this._dx=n.GetX()-r.GetX(),this._dy=n.GetY()-r.GetY(),this._dAngle=n.GetAngle()-r.GetAngle(),this._lastKnownAngle=n.GetAngle(),this._dz=n.GetZElevation()-r.GetZElevation(),a.has("x")&&a.has("y")&&(this._pinAngle=g.angleTo(r.GetX(),r.GetY(),n.GetX(),n.GetY())-r.GetAngle(),this._pinDist=g.distanceTo(r.GetX(),r.GetY(),n.GetX(),n.GetY())),a.has("width-abs")?this._dWidth=n.GetWidth()-r.GetWidth():a.has("width-scale")&&(this._dWidth=n.GetWidth()/r.GetWidth()),a.has("height-abs")?this._dHeight=n.GetHeight()-r.GetHeight():a.has("height-scale")&&(this._dHeight=n.GetHeight()/r.GetHeight())}else this._pinDist=g.distanceTo(r.GetX(),r.GetY(),n.GetX(),n.GetY())}}}SaveToJson(){const e=this._propSet,t=this._mode,s={uid:this._pinInst&&!this._pinInst.IsDestroyed()?this._pinInst.GetUID():-1,m:t,d:this._destroy};return"rope"===t||"bar"===t?s.pd=this._pinDist:"properties"===t&&(s.ps=[...this._propSet],e.has("imagepoint")?s.ip=this._pinImagePoint:e.has("x")&&e.has("y")?(s.pa=this._pinAngle,s.pd=this._pinDist):(e.has("x")&&(s.dx=this._dx),e.has("y")&&(s.dy=this._dy)),e.has("angle")&&(s.da=this._dAngle,s.lka=this._lastKnownAngle),(e.has("width-abs")||e.has("width-scale"))&&(s.dw=this._dWidth),(e.has("height-abs")||e.has("height-scale"))&&(s.dh=this._dHeight),e.has("z"))&&(s.dz=this._dz),s}LoadFromJson(e){const t=e.m,s=this._propSet;if(s.clear(),this._pinUid=e.uid,"number"==typeof t)this._LoadFromJson_Legacy(e);else if(this._mode=t,e.hasOwnProperty("d")&&(this._destroy=!!e.d),"rope"===t||"bar"===t)this._pinDist=e.pd;else if("properties"===t){for(const i of e.ps)s.add(i);s.has("imagepoint")?this._pinImagePoint=e.ip:s.has("x")&&s.has("y")?(this._pinAngle=e.pa,this._pinDist=e.pd):(s.has("x")&&(this._dx=e.dx),s.has("y")&&(this._dy=e.dy)),s.has("angle")&&(this._dAngle=e.da,this._lastKnownAngle=e.lka||0),(s.has("width-abs")||s.has("width-scale"))&&(this._dWidth=e.dw),(s.has("height-abs")||s.has("height-scale"))&&(this._dHeight=e.dh),s.has("z")&&(this._dz=e.dz)}}_LoadFromJson_Legacy(e){const t=this._propSet,s=e.msa,i=e.tsa,n=e.pa,r=e.pd,a=e.m;switch(a){case 0:this._mode="properties",t.add("x").add("y").add("angle"),this._pinAngle=n,this._pinDist=r,this._dAngle=s-i,this._lastKnownAngle=e.lka;break;case 1:this._mode="properties",t.add("x").add("y"),this._pinAngle=n,this._pinDist=r;break;case 2:this._mode="properties",t.add("angle"),this._dAngle=s-i,this._lastKnownAngle=e.lka;break;case 3:this._mode="rope",this._pinDist=e.pd;break;case 4:this._mode="bar",this._pinDist=e.pd}}_OnAfterLoad(){-1===this._pinUid?this._SetPinInst(null):(this._SetPinInst(this._runtime.GetInstanceByUID(this._pinUid)),this._pinUid=-1)}_OnInstanceDestroyed(e){this._pinInst===e&&(this._SetPinInst(null),this._destroy)&&this._runtime.DestroyInstance(this._inst)}Tick2(){const r=this._pinInst;if(r&&!r.IsDestroyed()){let s=r.GetWorldInfo(),e=this._inst,i=e.GetWorldInfo(),t=this._mode,n=!1;if("rope"===t||"bar"===t){const a=g.distanceTo(i.GetX(),i.GetY(),s.GetX(),s.GetY());if(a>this._pinDist||"bar"===t&&a<this._pinDist){const o=g.angleTo(s.GetX(),s.GetY(),i.GetX(),i.GetY());i.SetXY(s.GetX()+Math.cos(o)*this._pinDist,s.GetY()+Math.sin(o)*this._pinDist),n=!0}}else{let e=this._propSet,t=0;if(e.has("imagepoint")){const[l,h]=r.GetImagePoint(this._pinImagePoint);i.EqualsXY(l,h)||(i.SetXY(l,h),n=!0)}else if(e.has("x")&&e.has("y")){const c=s.GetX()+Math.cos(s.GetAngle()+this._pinAngle)*this._pinDist,u=s.GetY()+Math.sin(s.GetAngle()+this._pinAngle)*this._pinDist;i.EqualsXY(c,u)||(i.SetXY(c,u),n=!0)}else t=s.GetX()+this._dx,e.has("x")&&t!==i.GetX()&&(i.SetX(t),n=!0),t=s.GetY()+this._dy,e.has("y")&&t!==i.GetY()&&(i.SetY(t),n=!0);e.has("angle")&&(this._lastKnownAngle!==i.GetAngle()&&(this._dAngle=g.clampAngle(this._dAngle+(i.GetAngle()-this._lastKnownAngle))),(t=g.clampAngle(s.GetAngle()+this._dAngle))!==i.GetAngle()&&(i.SetAngle(t),n=!0),this._lastKnownAngle=i.GetAngle()),e.has("width-abs")&&(t=s.GetWidth()+this._dWidth)!==i.GetWidth()&&(i.SetWidth(t),n=!0),e.has("width-scale")&&(t=s.GetWidth()*this._dWidth)!==i.GetWidth()&&(i.SetWidth(t),n=!0),e.has("height-abs")&&(t=s.GetHeight()+this._dHeight)!==i.GetHeight()&&(i.SetHeight(t),n=!0),e.has("height-scale")&&(t=s.GetHeight()*this._dHeight)!==i.GetHeight()&&(i.SetHeight(t),n=!0),e.has("z")&&(t=s.GetZElevation()+this._dz)!==i.GetZElevation()&&(i.SetZElevation(t),this._runtime.UpdateRender())}n&&i.SetBboxChanged()}}GetDebuggerProperties(){const e="behaviors.pin.debugger";return[{title:"$"+this.GetBehaviorType().GetName(),properties:[{name:e+".is-pinned",value:!!this._pinInst},{name:e+".pinned-uid",value:this._pinInst?this._pinInst.GetUID():0}]}]}}}{const $=self.C3;$.Behaviors.Pin.Cnds={IsPinned(){return!!this._pinInst},WillDestroy(){return this._destroy}}}{const _=self.C3;_.Behaviors.Pin.Acts={PinByDistance(e,t){this._Pin(e,0===t?"rope":"bar")},PinByProperties(e,t,s,i,n,r,a){const o=[];t&&o.push("x"),s&&o.push("y"),i&&o.push("angle"),a&&o.push("z"),1===n?o.push("width-abs"):2===n&&o.push("width-scale"),1===r?o.push("height-abs"):2===r&&o.push("height-scale"),0!==o.length&&this._Pin(e,"properties",o)},PinByImagePoint(e,t,s,i,n,r){const a=["imagepoint"];s&&a.push("angle"),r&&a.push("z"),1===i?a.push("width-abs"):2===i&&a.push("width-scale"),1===n?a.push("height-abs"):2===n&&a.push("height-scale"),this._pinImagePoint=t,this._Pin(e,"properties",a)},SetPinDistance(e){"rope"!==this._mode&&"bar"!==this._mode||(this._pinDist=Math.max(e,0))},SetDestroy(e){this._destroy=e},Unpin(){this._SetPinInst(null),this._mode="",this._propSet.clear(),this._pinImagePoint=""},Pin(e,t){switch(t){case 0:this._Pin(e,"properties",["x","y","angle"]);break;case 1:this._Pin(e,"properties",["x","y"]);break;case 2:this._Pin(e,"properties",["angle"]);break;case 3:this._Pin(e,"rope");break;case 4:this._Pin(e,"bar")}}}}{const va=self.C3;va.Behaviors.Pin.Exps={PinnedUID(){return this._pinInst?this._pinInst.GetUID():-1}}}{const a=self.C3;a.Behaviors.TileMovement=class extends a.SDKBehaviorBase{constructor(e){super(e)}Release(){super.Release()}}}{const d=self.C3;d.Behaviors.TileMovement.Type=class extends d.SDKBehaviorTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const g=self.C3,h=self.C3X,i=self.IBehaviorInstance,j=0,k=1,l=2,m=3,n=4,o=5,p=6,q=7,r=.01,s=10,t=[],u=(g.Behaviors.TileMovement.Instance=class extends g.SDKBehaviorInstanceBase{constructor(e,t){super(e),this._upKey=!1,this._downKey=!1,this._leftKey=!1,this._rightKey=!1,this._ignoreInput=!1,this._simUp=!1,this._simDown=!1,this._simLeft=!1,this._simRight=!1,this._gridWidth=32,this._gridHeight=32,this._gridOffsetX=0,this._gridOffsetY=0,this._speedX=100,this._speedY=100,this._isEnabled=!0,this._defaultControls=!0,this._iso=!1,t&&(this._gridWidth=t[0],this._gridHeight=t[1],this._gridOffsetX=t[2],this._gridOffsetY=t[3],this._speedX=t[4],this._speedY=t[5],this._isEnabled=t[6],this._defaultControls=t[7],this._iso=t[8]),this._targetX=0,this._targetY=0,this._targetGridX=0,this._targetGridY=0,this._lastX=NaN,this._lastY=NaN,this._lastX2=NaN,this._lastY2=NaN,this._collisionRect=g.New(g.Rect),this._disposables=null,this._isEnabled&&this._StartTicking(),this._defaultControls&&this._BindEvents(),this._ResetTarget()}Release(){this._UnBindEvents(),super.Release()}_BindEvents(){if(!this._disposables){const e=this._runtime.Dispatcher();this._disposables=new g.CompositeDisposable(g.Disposable.From(e,"keydown",e=>this._OnKeyDown(e.data)),g.Disposable.From(e,"keyup",e=>this._OnKeyUp(e.data)),g.Disposable.From(e,"window-blur",()=>this._OnWindowOrKeyboardBlur()),g.Disposable.From(e,"keyboard-blur",()=>this._OnWindowOrKeyboardBlur()))}}_UnBindEvents(){this._disposables&&(this._disposables.Release(),this._disposables=null)}_OnKeyDown(e){switch(e.key){case"ArrowLeft":this._leftKey=!0;break;case"ArrowUp":this._upKey=!0;break;case"ArrowRight":this._rightKey=!0;break;case"ArrowDown":this._downKey=!0}}_OnKeyUp(e){switch(e.key){case"ArrowLeft":this._leftKey=!1;break;case"ArrowUp":this._upKey=!1;break;case"ArrowRight":this._rightKey=!1;break;case"ArrowDown":this._downKey=!1}}_OnWindowOrKeyboardBlur(){this._upKey=!1,this._downKey=!1,this._leftKey=!1,this._rightKey=!1}_ResetLastPositions(){this._lastX=NaN,this._lastY=NaN,this._lastX2=NaN,this._lastY2=NaN}SaveToJson(){return{gw:this._gridWidth,gh:this._gridHeight,ox:this._gridOffsetX,oy:this._gridOffsetY,sx:this._speedX,sy:this._speedY,x:this._targetX,y:this._targetY,gx:this._targetGridX,gy:this._targetGridY,e:this._isEnabled,i:this._ignoreInput,c:this._defaultControls}}LoadFromJson(e){this._gridWidth=e.gw,this._gridHeight=e.gh,this._gridOffsetX=e.ox,this._gridOffsetY=e.oy,this._speedX=e.sx,this._speedY=e.sy,this._targetX=e.x,this._targetY=e.y,this._targetGridX=e.gx,this._targetGridY=e.gy,this._isEnabled=!!e.e,this._ignoreInput=!!e.i,this._defaultControls=!!e.c,this._isEnabled?this._StartTicking():(this._simLeft=!1,this._simRight=!1,this._simUp=!1,this._simDown=!1,this._StopTicking()),this._defaultControls?this._BindEvents():this._UnBindEvents(),this._ResetLastPositions()}_GetTargetDelta(){const e=this.GetWorldInfo(),t=this._targetX-e.GetX(),s=this._targetY-e.GetY();return[t,s]}IsMoving(){if(!this.IsEnabled())return!1;const[e,t]=this._GetTargetDelta();return 0<Math.abs(e)&&0!==this._speedX||0<Math.abs(t)&&0!==this._speedY}IsMovingDirection(e){if(!this.IsEnabled())return!1;const[t,s]=this._GetTargetDelta();return e<2&&0!==this._speedX?0===e?0<t:t<0:0!==this._speedY&&(2===e?0<s:s<0)}CanMoveTo(e,t){const s=this.GetWorldInfo(),i=s.GetX(),n=s.GetY(),r=this._WorldPosition(e,t),a=(s.SetX(r[0]),s.SetY(r[1]),s.SetBboxChanged(),this._TestCollision());return s.SetX(i),s.SetY(n),s.SetBboxChanged(),!a}CanMoveDirection(e,t){let s=this.GetWorldInfo(),i=s.GetX(),n=s.GetY(),r=0,a=0;switch(e){case 0:r=1;break;case 1:r=-1;break;case 2:a=1;break;case 3:a=-1}(t=Math.floor(t))<0&&(r=-r,a=-a,t=-t);let o=this._GridX(i,n),l=this._GridY(i,n),h=null;for(let e=0;e<t;e++){o+=r,l+=a;const c=this._WorldPosition(o,l);if(s.SetX(c[0]),s.SetY(c[1]),s.SetBboxChanged(),h=this._TestCollision())break}return s.SetX(i),s.SetY(n),s.SetBboxChanged(),!h}SetIgnoreInput(e){this._ignoreInput=!!e}GetDefaultControls(){return this._defaultControls}SimulateControl(e){if(this.IsEnabled())switch(e){case 0:this._simLeft=!0;break;case 1:this._simRight=!0;break;case 2:this._simUp=!0;break;case 3:this._simDown=!0}}SetSpeed(e,t){this._speedX=e,this._speedY=t}SetGridPosition(e,t,s){s=!!s;const i=!this._UpdateTarget(e,t);i&&s&&this._MoveToTarget()}SetGridDimensions(e,t,s,i){this._gridWidth=e,this._gridHeight=t,this._gridOffsetX=s,this._gridOffsetY=i,this._TargetCurrentPositon()}_GridX(e,t){return this._iso?this._IsoGridX(e,t):(e=(e-=this._gridOffsetX)/this._gridWidth,Math.round(e))}_GridY(e,t){return this._iso?this._IsoGridY(e,t):(t=(t-=this._gridOffsetY)/this._gridHeight,Math.round(t))}_IsoGridX(e,t){e-=this._gridOffsetX,t-=this._gridOffsetY;const s=((e/=this._gridWidth/2)+(t/=this._gridHeight/2))/2;return Math.round(s)}_IsoGridY(e,t){e-=this._gridOffsetX,t-=this._gridOffsetY,e/=this._gridWidth/2;const s=((t/=this._gridHeight/2)-e)/2;return Math.round(s)}_ClampedGridPosition(e,t){const[s,i]=this._GridPosition(e,t);return[Math.round(s),Math.round(i)]}_GridPosition(e,t){return this._iso?this._IsoGridPosition(e,t):(e-=this._gridOffsetX,t-=this._gridOffsetY,[e/=this._gridWidth,t/=this._gridHeight])}_WorldPosition(e,t){return this._iso?this._IsoWorldPosition(e,t):(e*=this._gridWidth,t*=this._gridHeight,[e+=this._gridOffsetX,t+=this._gridOffsetY])}_IsoGridPosition(e,t){e-=this._gridOffsetX,t-=this._gridOffsetY;const s=((e/=this._gridWidth/2)+(t/=this._gridHeight/2))/2,i=(t-e)/2;return[s,i]}_IsoWorldPosition(e,t){let s=e-t,i=e+t;return s*=this._gridWidth/2,i*=this._gridHeight/2,[s+=this._gridOffsetX,i+=this._gridOffsetY]}_UpdateTarget(e,t){const s=this.GetWorldInfo(),i=s.GetX(),n=s.GetY(),r=this._WorldPosition(e,t),a=(s.SetX(r[0]),s.SetY(r[1]),s.SetBboxChanged(),this._TestCollision());return s.SetX(i),s.SetY(n),s.SetBboxChanged(),!!a||(this._targetGridX=e,this._targetGridY=t,this._targetX=r[0],this._targetY=r[1],this._ResetLastPositions(),!1)}_MoveToTarget(){const e=this.GetWorldInfo();e.SetXY(this._targetX,this._targetY),e.SetBboxChanged()}_TargetCurrentPositon(){const e=this.GetWorldInfo(),t=this._ClampedGridPosition(e.GetX(),e.GetY()),s=this._WorldPosition(t[0],t[1]);this._targetGridX=t[0],this._targetGridY=t[1],this._targetX=s[0],this._targetY=s[1],this._ResetLastPositions()}_ResetTarget(){this._TargetCurrentPositon(),this._MoveToTarget()}_UpdateCollisionRect(){const e=this.GetWorldInfo(),t=e.GetBoundingBox();this._collisionRect.copy(t);let s=r,i=r,n=t.width(),a=t.height();if(n<r+r){const o=t.midX();s=0,t.setRight(o),t.setLeft(o)}if(a<r+r){const l=t.midY();i=0,t.setRight(l),t.setLeft(l)}return this._collisionRect.deflate(s,i),this._collisionRect}_TestCollision(){const e=this.GetObjectInstance();if(e.GetWorldInfo().IsCollisionEnabled()){const s=this._runtime.GetCollisionEngine(),i=this._UpdateCollisionRect();s.GetSolidCollisionCandidates(null,i,t);for(const n of t)if(n!==e&&s.IsSolidCollisionAllowed(n,e)&&s.TestRectOverlap(i,n))return g.clearArray(t),n;g.clearArray(t)}return null}_MaybePushOut(){const e=this._runtime.GetCollisionEngine(),t=this._TestCollision();if(!t)return null;let i=this.GetWorldInfo(),n=i.GetX(),r=i.GetY(),a=i.GetBoundingBox(),o=t.GetWorldInfo().GetBoundingBox(),l=Math.max(a.getRight(),o.getRight())-Math.min(a.getLeft(),o.getLeft()),h=Math.max(a.getBottom(),o.getBottom())-Math.min(a.getTop(),o.getTop()),c=a.width()+o.width()-l,u=a.height()+o.height()-h,_=!1;return c<u?(c>s&&(_=!0),c=Math.min(c,s),a.getLeft()<o.getLeft()?i.OffsetX(-c):i.OffsetX(c)):(u>s&&(_=!0),u=Math.min(u,s),a.getTop()<o.getTop()?i.OffsetY(-u):i.OffsetY(u)),i.SetBboxChanged(),this._TestCollision()&&(i.SetX(n),i.SetY(r),i.SetBboxChanged()),_&&e.RegisterCollision(this._inst,t),this._TargetCurrentPositon(),t}Tick(){let _=this._runtime.GetDt(this._inst),d=this.GetWorldInfo(),p=this._leftKey||this._simLeft,m=this._rightKey||this._simRight,f=this._upKey||this._simUp,S=this._downKey||this._simDown;if(this._simLeft=!1,this._simRight=!1,this._simUp=!1,this._simDown=!1,this.IsEnabled()&&(this._ignoreInput&&(p=m=f=S=!1),f&&S&&(f=S=!1),p&&m&&(p=m=!1),!this._MaybePushOut())&&0!==_){let e=d.GetX(),t=d.GetY(),s=_*this._speedX,i=_*this._speedY,n=this._targetGridX,r=this._targetGridY,a=this._targetX-e,o=this._targetY-t,l=Math.abs(a),h=Math.abs(o),c=0,u=0;if(0<l){const C=Math.sign(a),y=C<0&&p,G=0<C&&m;if(y||G)for(;!(!(l<s)||G&&this._UpdateTarget(++n,r)||y&&this._UpdateTarget(--n,r));)a=this._targetX-e,l=Math.abs(a);c=C*g.clamp(l,0,s)}if(0<h){const I=Math.sign(o),T=0<I&&S,b=I<0&&f;if(T||b)for(;!(!(h<i)||T&&this._UpdateTarget(n,++r)||b&&this._UpdateTarget(n,--r));)o=this._targetY-t,h=Math.abs(o);u=I*g.clamp(h,0,i)}if(0!=c||0!=u)if(this._lastX2=this._lastX,this._lastY2=this._lastY,this._lastX=d.GetX(),this._lastY=d.GetY(),this._lastX===this._lastX2&&this._lastY===this._lastY2)this._UpdateTarget(n-Math.sign(c),r-Math.sign(u));else if(Math.abs(this._lastX-this._lastX2)>=this._gridWidth||Math.abs(this._lastY-this._lastY2)>=this._gridHeight){const[P,A]=this._GridPosition(this._lastX,this._lastY);this._UpdateTarget(Math.floor(P)+(0<c?1:0),Math.floor(A)+(0<u?1:0))}else d.OffsetXY(c,u),d.SetBboxChanged(),this._MaybePushOut();else 0!==this._speedX&&(p?this._UpdateTarget(n-1,r):m&&this._UpdateTarget(n+1,r)),0!==this._speedY&&(p||m||!f?S&&this._UpdateTarget(n,r+1):this._UpdateTarget(n,r-1))}}GetPropertyValueByIndex(e){switch(e){case j:return this._gridWidth;case k:return this._gridHeight;case l:return this._gridOffsetX;case m:return this._gridOffsetY;case n:return this._speedX;case o:return this._speedY;case p:return this.IsEnabled();case q:return this._defaultControls}}SetPropertyValueByIndex(e,t){switch(e){case j:this._gridWidth=t,this._TargetCurrentPositon();break;case k:this._gridHeight=t,this._TargetCurrentPositon();break;case l:this._gridOffsetX=t,this._TargetCurrentPositon();break;case m:this._gridOffsetY=t,this._TargetCurrentPositon();break;case n:this._speedX=t;break;case o:this._speedY=t;break;case p:this.SetEnabled(t);break;case q:this._SetDefaultControls(t)}}SetEnabled(e){this._isEnabled!==(e=!!e)&&(this._isEnabled=e,this._isEnabled?this._StartTicking():(this._simLeft=!1,this._simRight=!1,this._simUp=!1,this._simDown=!1,this._StopTicking()),this._ResetLastPositions())}IsEnabled(){return this._isEnabled}_SetDefaultControls(e){this._defaultControls!==(e=!!e)&&(this._defaultControls=e,this._defaultControls?this._BindEvents():(this._UnBindEvents(),this._OnWindowOrKeyboardBlur()))}GetDebuggerProperties(){const e="behaviors.tilemovement",s=this.GetWorldInfo(),i=this._GridPosition(s.GetX(),s.GetY());return[{title:"$"+this.GetBehaviorType().GetName(),properties:[{name:e+".debugger.grid-x",value:i[0],onedit:e=>{const t=this._WorldPosition(e,i[1]);s.SetX(t[0]),s.SetBboxChanged()}},{name:e+".debugger.grid-y",value:i[1],onedit:e=>{const t=this._WorldPosition(i[0],e);s.SetY(t[1]),s.SetBboxChanged()}},{name:e+".properties.grid-width.name",value:this._gridWidth,onedit:e=>{this._gridWidth=e,this._TargetCurrentPositon()}},{name:e+".properties.grid-height.name",value:this._gridHeight,onedit:e=>{this._gridHeight=e,this._TargetCurrentPositon()}},{name:e+".properties.grid-offset-x.name",value:this._gridOffsetX,onedit:e=>{this._gridOffsetX=e,this._TargetCurrentPositon()}},{name:e+".properties.grid-offset-y.name",value:this._gridOffsetY,onedit:e=>{this._gridOffsetY=e,this._TargetCurrentPositon()}},{name:e+".properties.speed-x.name",value:this._speedX,onedit:e=>this._speedX=e},{name:e+".properties.speed-y.name",value:this._speedY,onedit:e=>this._speedY=e},{name:e+".debugger.target-x",value:this._targetX,onedit:e=>{this._targetX=e;const t=this._ClampedGridPosition(this._targetX,this._targetY);this._targetGridX=t[0],this._ResetLastPositions()}},{name:e+".debugger.target-y",value:this._targetY,onedit:e=>{this._targetY=e;const t=this._ClampedGridPosition(this._targetX,this._targetY);this._targetGridY=t[1],this._ResetLastPositions()}},{name:e+".debugger.grid-target-x",value:this._targetGridX,onedit:e=>{this._targetGridX=e;const t=this._WorldPosition(this._targetGridX,this._targetGridY);this._targetX=t[0]}},{name:e+".debugger.grid-target-y",value:this._targetGridY,onedit:e=>{this._targetGridY=e;const t=this._WorldPosition(this._targetGridX,this._targetGridY);this._targetY=t[1]}},{name:e+".properties.enabled.name",value:this.IsEnabled(),onedit:e=>this.SetEnabled(e)},{name:e+".properties.default-controls.name",value:this._defaultControls,onedit:e=>this._SetDefaultControls(e)}]}]}GetScriptInterfaceClass(){return self.ITileMovementBehaviorInstance}},new WeakMap);self.ITileMovementBehaviorInstance=class extends i{constructor(){super(),u.set(this,i._GetInitInst().GetSdkInstance())}set isIgnoringInput(e){u.get(this).SetIgnoreInput(!!e)}get isIgnoringInput(){return u.get(this)._ignoreInput}simulateControl(e){h.RequireString(e);let t=-1;switch(e){case"left":t=0;break;case"right":t=1;break;case"up":t=2;break;case"down":t=3;break;default:throw new Error("Invalid direction "+e)}u.get(this).SimulateControl(t)}set isEnabled(e){u.get(this).SetEnabled(!!e)}get isEnabled(){return u.get(this).IsEnabled()}get isDefaultControls(){return u.get(this).GetDefaultControls()}set isDefaultControls(e){u.get(this)._SetDefaultControls(!!e)}setSpeed(e,t){h.RequireFiniteNumber(e),h.RequireFiniteNumber(t),u.get(this).SetSpeed(e,t)}getSpeed(){const e=u.get(this);return[e._speedX,e._speedY]}setGridPosition(e,t,s){h.RequireFiniteNumber(e),h.RequireFiniteNumber(t),u.get(this).SetGridPosition(e,t,!!s)}getGridPosition(){const e=u.get(this),t=e.GetWorldInfo(),s=t.GetX(),i=t.GetY();return[e._GridX(s,i),e._GridY(s,i)]}modifyGridDimensions(e,t,s,i){h.RequireFiniteNumber(e),h.RequireFiniteNumber(t),h.RequireFiniteNumber(s),h.RequireFiniteNumber(i),u.get(this).SetGridDimensions(e,t,s,i)}isMoving(){return u.get(this).IsMoving()}isMovingDirection(e){h.RequireString(e);let t=-1;switch(e){case"right":t=0;break;case"left":t=1;break;case"down":t=2;break;case"up":t=3;break;default:throw new Error("Invalid direction "+e)}return u.get(this).IsMovingDirection(t)}canMoveTo(e,t){return h.RequireFiniteNumber(e),h.RequireFiniteNumber(t),u.get(this).CanMoveTo(e,t)}canMoveDirection(e,t){h.RequireString(e);let s=-1;switch(e){case"right":s=0;break;case"left":s=1;break;case"down":s=2;break;case"up":s=3;break;default:throw new Error(`invalid direction '${e}'`)}return u.get(this).CanMoveDirection(s,t)}getTargetPosition(){const e=u.get(this);return[e._targetX,e._targetY]}getGridTargetPosition(){const e=u.get(this);return[e._targetGridX,e._targetGridY]}toGridSpace(e,t){return h.RequireFiniteNumber(e),h.RequireFiniteNumber(t),u.get(this)._GridPosition(e,t)}fromGridSpace(e,t){return h.RequireFiniteNumber(e),h.RequireFiniteNumber(t),u.get(this)._WorldPosition(e,t)}}}{const b1=self.C3;b1.Behaviors.TileMovement.Cnds={IsMoving(){return this.IsMoving()},IsMovingDirection(e){return this.IsMovingDirection(e)},IsEnabled(){return this._isEnabled},CanMoveTo(e,t){return this.CanMoveTo(e,t)},CanMoveDirection(e,t){return this.CanMoveDirection(e,t)}}}{const h1=self.C3;h1.Behaviors.TileMovement.Acts={SetIgnoreInput(e){this.SetIgnoreInput(e)},SimulateControl(e){this.SimulateControl(e)},SetEnabled(e){this.SetEnabled(e)},SetSpeed(e,t){this.SetSpeed(e,t)},SetGridPosition(e,t,s){this.SetGridPosition(e,t,s)},SetGridDimensions(e,t,s,i){this.SetGridDimensions(e,t,s,i)},SetDefaultControls(e){this._SetDefaultControls(!!e)}}}{const v1=self.C3;v1.Behaviors.TileMovement.Exps={GridX(){const e=this.GetWorldInfo();return this._GridX(e.GetX(),e.GetY())},GridY(){const e=this.GetWorldInfo();return this._GridY(e.GetX(),e.GetY())},SpeedX(){return this._speedX},SpeedY(){return this._speedY},TargetX(){return this._targetX},TargetY(){return this._targetY},GridTargetX(){return this._targetGridX},GridTargetY(){return this._targetGridY}}}{const a=self.C3;a.Behaviors.Rotate=class extends a.SDKBehaviorBase{constructor(e){super(e)}Release(){super.Release()}}}{const d=self.C3;d.Behaviors.Rotate.Type=class extends d.SDKBehaviorTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const g=self.C3,h=self.C3X,i=self.IBehaviorInstance,j=0,k=1,l=2,m=(g.Behaviors.Rotate.Instance=class extends g.SDKBehaviorInstanceBase{constructor(e,t){super(e),this._speed=0,this._acceleration=0,this._isEnabled=!0,t&&(this._speed=g.toRadians(t[j]),this._acceleration=g.toRadians(t[k]),this._isEnabled=t[l]),this._isEnabled&&this._StartTicking()}Release(){super.Release()}_SetSpeed(e){this._speed=e}_GetSpeed(){return this._speed}_SetAcceleration(e){this._acceleration=e}_GetAcceleration(){return this._acceleration}SaveToJson(){return{s:this._speed,a:this._acceleration,e:this._isEnabled}}LoadFromJson(e){this._speed=e.s,this._acceleration=e.a,this._SetEnabled(e.e)}Tick(){if(this._isEnabled){const e=this._runtime.GetDt(this._inst);if(0!==e&&(0!==this._acceleration&&(this._speed+=this._acceleration*e),0!==this._speed)){const t=this._inst.GetWorldInfo();t.SetAngle(t.GetAngle()+this._speed*e),t.SetBboxChanged()}}}GetPropertyValueByIndex(e){switch(e){case j:return g.toDegrees(this._GetSpeed());case k:return g.toDegrees(this._GetAcceleration());case l:return this._IsEnabled()}}SetPropertyValueByIndex(e,t){switch(e){case j:this._SetSpeed(g.toRadians(t));break;case k:this._SetAcceleration(g.toRadians(t));break;case l:this._SetEnabled(t)}}_SetEnabled(e){this._isEnabled=!!e,this._isEnabled?this._StartTicking():this._StopTicking()}_IsEnabled(){return this._isEnabled}GetDebuggerProperties(){const e="behaviors.rotate";return[{title:"$"+this.GetBehaviorType().GetName(),properties:[{name:e+".properties.speed.name",value:g.toDegrees(this._GetSpeed()),onedit:e=>this._SetSpeed(g.toRadians(e))},{name:e+".properties.acceleration.name",value:g.toDegrees(this._GetAcceleration()),onedit:e=>this._SetAcceleration(g.toRadians(e))},{name:e+".properties.enabled.name",value:this._IsEnabled(),onedit:e=>this._SetEnabled(e)}]}]}GetScriptInterfaceClass(){return self.IRotateBehaviorInstance}},new WeakMap);self.IRotateBehaviorInstance=class extends i{constructor(){super(),m.set(this,i._GetInitInst().GetSdkInstance())}set speed(e){h.RequireFiniteNumber(e),m.get(this)._SetSpeed(e)}get speed(){return m.get(this)._GetSpeed()}set acceleration(e){h.RequireFiniteNumber(e),m.get(this)._SetAcceleration(e)}get acceleration(){return m.get(this)._GetAcceleration()}get isEnabled(){return m.get(this)._IsEnabled()}set isEnabled(e){m.get(this)._SetEnabled(e)}}}{const H=self.C3;H.Behaviors.Rotate.Cnds={IsEnabled(){return this._IsEnabled()}}}{const I=self.C3;I.Behaviors.Rotate.Acts={SetSpeed(e){this._SetSpeed(I.toRadians(e))},SetAcceleration(e){this._SetAcceleration(I.toRadians(e))},SetEnabled(e){this._SetEnabled(e)}}}{const M=self.C3;M.Behaviors.Rotate.Exps={Speed(){return M.toDegrees(this._GetSpeed())},Acceleration(){return M.toDegrees(this._GetAcceleration())}}}{const a=self.C3;a.Behaviors.scrollto=class extends a.SDKBehaviorBase{constructor(e){super(e),this._shakeMag=0,this._shakeStart=0,this._shakeEnd=0,this._shakeMode=0}Release(){super.Release()}SetShakeMagnitude(e){this._shakeMag=e}GetShakeMagnitude(){return this._shakeMag}SetShakeStart(e){this._shakeStart=e}GetShakeStart(){return this._shakeStart}SetShakeEnd(e){this._shakeEnd=e}GetShakeEnd(){return this._shakeEnd}SetShakeMode(e){this._shakeMode=e}GetShakeMode(){return this._shakeMode}}}{const h=self.C3;h.Behaviors.scrollto.Type=class extends h.SDKBehaviorTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const k=self.C3,l=0;k.Behaviors.scrollto.Instance=class extends k.SDKBehaviorInstanceBase{constructor(e,t){super(e),this._isEnabled=!0,t&&(this._isEnabled=t[l]),this._isEnabled&&this._StartTicking2()}Release(){super.Release()}SaveToJson(){const e=this.GetBehavior();return{e:this._isEnabled,smg:e.GetShakeMagnitude(),ss:e.GetShakeStart(),se:e.GetShakeEnd(),smd:e.GetShakeMode()}}LoadFromJson(e){const t=this.GetBehavior();t.SetShakeMagnitude(e.smg),t.SetShakeStart(e.ss),t.SetShakeEnd(e.se),t.SetShakeMode(e.smd),this._isEnabled=e.e,this._isEnabled?this._StartTicking2():this._StopTicking2()}_SetEnabled(e){this._isEnabled=!!e,this._isEnabled?this._StartTicking2():this._StopTicking2()}IsEnabled(){return this._isEnabled}Tick2(){if(this.IsEnabled()){this._runtime.GetDt(this._inst);let t=this.GetBehavior(),e=t.GetInstances(),s=0,i=0,n=0;for(const h of e){const c=h.GetBehaviorInstanceFromCtor(k.Behaviors.scrollto);if(c&&c.GetSdkInstance().IsEnabled()){const u=h.GetWorldInfo();s+=u.GetX(),i+=u.GetY(),++n}}let r=this._inst.GetWorldInfo().GetLayout(),a=this._runtime.GetGameTime(),o=0,l=0;if(a>=t.GetShakeStart()&&a<t.GetShakeEnd()){let e=t.GetShakeMagnitude()*Math.min(this._runtime.GetTimeScale(),1);0===t.GetShakeMode()&&(e*=1-(a-t.GetShakeStart())/(t.GetShakeEnd()-t.GetShakeStart()));const _=this._runtime.Random()*Math.PI*2,d=this._runtime.Random()*e;o=Math.cos(_)*d,l=Math.sin(_)*d}r.SetScrollX(s/n+o),r.SetScrollY(i/n+l)}}GetPropertyValueByIndex(e){if(e===l)return this._isEnabled}SetPropertyValueByIndex(e,t){e===l&&(this._isEnabled=!!t,this._isEnabled?this._StartTicking2():this._StopTicking2())}GetDebuggerProperties(){return[{title:"$"+this.GetBehaviorType().GetName(),properties:[{name:"behaviors.scrollto.properties.enabled.name",value:this.IsEnabled(),onedit:e=>this._SetEnabled(e)}]}]}}}{const O=self.C3;O.Behaviors.scrollto.Cnds={IsEnabled(){return this.IsEnabled()}}}{const P=self.C3;P.Behaviors.scrollto.Acts={Shake(e,t,s){const i=this.GetBehavior();i.SetShakeMagnitude(e),i.SetShakeStart(this._runtime.GetGameTime()),i.SetShakeEnd(this._runtime.GetGameTime()+t),i.SetShakeMode(s)},SetEnabled(e){this._SetEnabled(0!==e)}}}{const V=self.C3;V.Behaviors.scrollto.Exps={}}{const a=self.C3;a.Behaviors.Anchor=class extends a.SDKBehaviorBase{constructor(e){super(e)}Release(){super.Release()}}}{const d=self.C3;d.Behaviors.Anchor.Type=class extends d.SDKBehaviorTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const g=self.C3,h=self.C3X,i=self.IBehaviorInstance,j=0,k=1,l=2,m=3,n=4,o=(g.Behaviors.Anchor.Instance=class extends g.SDKBehaviorInstanceBase{constructor(e,t){super(e),this._anchorLeft=2,this._anchorTop=2,this._anchorRight=0,this._anchorBottom=0,this._isEnabled=!0;const s=this._inst.GetWorldInfo().GetBoundingBox(),i=(this._xLeft=s.getLeft(),this._yTop=s.getTop(),this._xRight=this._runtime.GetOriginalViewportWidth()-s.getLeft(),this._yBottom=this._runtime.GetOriginalViewportHeight()-s.getTop(),this._rDiff=this._runtime.GetOriginalViewportWidth()-s.getRight(),this._bDiff=this._runtime.GetOriginalViewportHeight()-s.getBottom(),t&&(this._anchorLeft=t[j],this._anchorTop=t[k],this._anchorRight=t[l],this._anchorBottom=t[m],this._isEnabled=!!t[n]),this._runtime.Dispatcher());this._disposables=new g.CompositeDisposable(g.Disposable.From(i,"layoutchange",()=>this._OnLayoutChange())),this._isEnabled&&this._StartTicking()}Release(){super.Release()}SaveToJson(){return{xl:this._xLeft,yt:this._yTop,xr:this._xRight,yb:this._yBottom,rd:this._rDiff,bd:this._bDiff,al:this._anchorLeft,at:this._anchorTop,ar:this._anchorRight,ab:this._anchorBottom,e:this._isEnabled}}LoadFromJson(e){this._xLeft=e.xl,this._yTop=e.yt,this._xRight=e.xr,this._yBottom=e.yb,this._rDiff=e.rd,this._bDiff=e.bd,this._anchorLeft=e.al,this._anchorTop=e.at,this._anchorRight=e.ar,this._anchorBottom=e.ab,this._isEnabled=e.e,this._isEnabled?this._StartTicking():this._StopTicking()}_SetEnabled(e){if(this._isEnabled&&!e)this._isEnabled=!1,this._StopTicking();else if(!this._isEnabled&&e){const t=this._inst.GetWorldInfo().GetBoundingBox();this._xLeft=t.getLeft(),this._yTop=t.getTop(),this._xRight=this._runtime.GetOriginalViewportWidth()-t.getLeft(),this._yBottom=this._runtime.GetOriginalViewportHeight()-t.getTop(),this._rDiff=this._runtime.GetOriginalViewportWidth()-t.getRight(),this._bDiff=this._runtime.GetOriginalViewportHeight()-t.getBottom(),this._isEnabled=!0,this._StartTicking()}}_IsEnabled(){return this._isEnabled}_UpdatePosition(){if(this._isEnabled){const e=this._inst.GetWorldInfo(),t=e.GetLayer().GetViewport();if(0===this._anchorLeft){const s=t.getLeft()+this._xLeft-e.GetBoundingBox().getLeft();0!=s&&(e.OffsetX(s),e.SetBboxChanged())}else if(1===this._anchorLeft){const i=t.getRight()-this._xRight-e.GetBoundingBox().getLeft();0!=i&&(e.OffsetX(i),e.SetBboxChanged())}if(0===this._anchorTop){const n=t.getTop()+this._yTop-e.GetBoundingBox().getTop();0!=n&&(e.OffsetY(n),e.SetBboxChanged())}else if(1===this._anchorTop){const r=t.getBottom()-this._yBottom-e.GetBoundingBox().getTop();0!=r&&(e.OffsetY(r),e.SetBboxChanged())}if(1===this._anchorRight){const a=t.getRight()-this._rDiff-e.GetBoundingBox().getRight();0!=a&&(e.OffsetX(e.GetOriginX()*a),e.SetWidth(Math.max(e.GetWidth()+a),0),e.SetBboxChanged(),this._rDiff=t.getRight()-e.GetBoundingBox().getRight())}if(1===this._anchorBottom){const o=t.getBottom()-this._bDiff-e.GetBoundingBox().getBottom();0!=o&&(e.OffsetY(e.GetOriginY()*o),e.SetHeight(Math.max(e.GetHeight()+o,0)),e.SetBboxChanged(),this._bDiff=t.getBottom()-e.GetBoundingBox().getBottom())}}}Tick(){this._UpdatePosition()}_OnLayoutChange(){this._UpdatePosition()}GetPropertyValueByIndex(e){switch(e){case j:return this._anchorLeft;case k:return this._anchorTop;case l:return this._anchorRight;case m:return this._anchorBottom;case n:return this._isEnabled}}SetPropertyValueByIndex(e,t){switch(e){case j:this._anchorLeft=t;break;case k:this._anchorTop=t;break;case l:this._anchorRight=t;break;case m:this._anchorBottom=t;break;case n:this._isEnabled=!!t,this._isEnabled?this._StartTicking():this._StopTicking()}}GetDebuggerProperties(){return[{title:"$"+this.GetBehaviorType().GetName(),properties:[{name:"behaviors.anchor.properties.enabled.name",value:this._IsEnabled(),onedit:e=>this._SetEnabled(e)}]}]}GetScriptInterfaceClass(){return self.IAnchorBehaviorInstance}},new WeakMap);self.IAnchorBehaviorInstance=class extends i{constructor(){super(),o.set(this,i._GetInitInst().GetSdkInstance())}get isEnabled(){return o.get(this)._IsEnabled()}set isEnabled(e){o.get(this)._SetEnabled(e)}}}{const M=self.C3;M.Behaviors.Anchor.Cnds={IsEnabled(){return this._IsEnabled()}}}{const N=self.C3;N.Behaviors.Anchor.Acts={SetEnabled(e){this._SetEnabled(0!==e)}}}{const P=self.C3;P.Behaviors.Anchor.Exps={}}{let unaryminus2=function(e){return"number"==typeof e?-e:e},bothNumbers2=function(e,t){return"number"==typeof e&&"number"==typeof t},add2=function(e,t){return bothNumbers2(e,t)?e+t:e},subtract2=function(e,t){return bothNumbers2(e,t)?e-t:e},multiply2=function(e,t){return bothNumbers2(e,t)?e*t:e},divide2=function(e,t){return bothNumbers2(e,t)?e/t:e},mod2=function(e,t){return bothNumbers2(e,t)?e%t:e},pow2=function(e,t){return bothNumbers2(e,t)?Math.pow(e,t):e},and2=function(s,i){if("string"!=typeof s&&"string"!=typeof i)return s&&i?1:0;{let e,t;return e="number"==typeof s?(Math.round(1e10*s)/1e10).toString():s,t="number"==typeof i?(Math.round(1e10*i)/1e10).toString():i,e+t}},or2=function(e,t){return bothNumbers2(e,t)?e||t?1:0:e};unaryminus=unaryminus2,bothNumbers=bothNumbers2,add=add2,subtract=subtract2,multiply=multiply2,divide=divide2,mod=mod2,pow=pow2,and=and2,or=or2;const C33=self.C3;self.C3_ExpressionFuncs=[()=>"player",e=>{const t=e._GetNode(0).GetBoundMethod();return()=>80*Math.floor(t()/80)},()=>"",e=>{const t=e._GetNode(0).GetBoundMethod();return()=>80*Math.floor(t()/80)+40},()=>"fruit",()=>.2,()=>1,e=>{const t=e._GetNode(0);return()=>t.ExpObject()},e=>{const t=e._GetNode(0).GetVar();return()=>t.GetValue()},()=>200,()=>"game",()=>"Fall",()=>"Movement",()=>"undoMove",()=>0,()=>"bgmm",()=>99,()=>"Brightness",()=>5,()=>"mouthOpen",()=>"mouthEat",()=>"mouthClose",e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t("upEye","idleEye","opclEye","idleEye","downEye","idleEye","idleEye")},()=>2,()=>3,()=>4,()=>6,e=>{const t=e._GetNode(0),s=e._GetNode(1),i=e._GetNode(2),n=e._GetNode(3);return()=>Math.round(C33.toDegrees(C33.angleTo(t.ExpObject(),s.ExpObject(),i.ExpObject(),n.ExpObject())))},()=>90,e=>{const t=e._GetNode(0);return()=>t.ExpObject()-80},()=>180,e=>{const t=e._GetNode(0);return()=>t.ExpObject()+80},()=>270,()=>"controlTouch",()=>"0",e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(0)},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t()},e=>{const t=e._GetNode(0).GetVar(),s=e._GetNode(1).GetVar(),i=e._GetNode(2).GetBoundMethod(),n=e._GetNode(3).GetBoundMethod();return()=>C33.distanceTo(t.GetValue(),s.GetValue(),i(),n())},()=>20,()=>226,()=>314,()=>"up",()=>316,()=>44,()=>"right",()=>46,()=>134,()=>"down",()=>136,()=>224,()=>"left",e=>{const t=e._GetNode(0);return()=>t.ExpObject()-40},e=>{const t=e._GetNode(0);return()=>t.ExpObject()+40},e=>{const t=e._GetNode(0);return()=>t.ExpInstVar()},()=>30,()=>100,()=>50,()=>150,e=>{const t=e._GetNode(0);return()=>t.ExpObject()+5},e=>{const t=e._GetNode(0);return()=>t.ExpObject()+7},e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetBoundMethod();return()=>t(s())},()=>"levels",e=>{const t=e._GetNode(0);return()=>t.ExpObject()-20},e=>{const t=e._GetNode(0);return()=>t.ExpObject()-12},()=>-562949954637823,()=>-678123797899263,()=>-697940423538687,()=>-717747956755455,()=>-100,()=>"GUI",()=>"mobile",e=>{const t=e._GetNode(0);return()=>t.ExpInstVar()+1},()=>"completText",()=>15,e=>{const t=e._GetNode(0);return()=>C33.lerp(t.ExpObject(),480,.07)},()=>"continuText",e=>{const t=e._GetNode(0);return()=>C33.lerp(t.ExpObject(),680,.07)},()=>685,()=>"topstatic",e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(5)+120},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(5)+80},e=>{const t=e._GetNode(0);return()=>t.ExpObject()-10},()=>-10,()=>"sfx",()=>.1,e=>{const t=e._GetNode(0);return()=>t.ExpObject()+10},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(5)+280},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(5)-80},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(5)-260},e=>{const t=e._GetNode(0).GetVar();return()=>t.GetValue().toString()},e=>{const t=e._GetNode(0),s=e._GetNode(1).GetBoundMethod();return()=>t.ExpObject()+30*s()},()=>"Menu",()=>"menu",()=>"bgml",e=>{const t=e._GetNode(0).GetVar();return()=>t.GetValue()-1},e=>{const t=e._GetNode(0);return()=>(t.ExpObject()+1).toString()},()=>"saveload",()=>10]}}}),import_c3runtime=__toESM(require_c3runtime()),C32=self.C3;self.C3_GetObjectRefTable=function(){return[C32.Plugins.Sprite,C32.Behaviors.Sin,C32.Behaviors.NoSave,C32.Plugins.Audio,C32.Plugins.Keyboard,C32.Plugins.Touch,C32.Plugins.Browser,C32.Plugins.LocalStorage,C32.Plugins.Mouse,C32.Plugins.PlatformInfo,C32.Plugins.Timeline,C32.Plugins.video,C32.Behaviors.Pin,C32.Plugins.Particles,C32.Behaviors.TileMovement,C32.Behaviors.Rotate,C32.Plugins.TiledBg,C32.Plugins.AJAX,C32.Plugins.Json,C32.Plugins.Tilemap,C32.Behaviors.scrollto,C32.Behaviors.Anchor,C32.Plugins.System.Cnds.OnLayoutStart,C32.Plugins.System.Cnds.EveryTick,C32.Plugins.Mouse.Cnds.OnClick,C32.Plugins.System.Acts.CreateObject,C32.Plugins.Mouse.Exps.X,C32.Plugins.Mouse.Exps.Y,C32.Plugins.Sprite.Acts.SetVisible,C32.Plugins.Sprite.Acts.SetAnim,C32.Plugins.Sprite.Acts.SetScale,C32.Plugins.Mouse.Cnds.OnObjectClicked,C32.Plugins.Sprite.Acts.Destroy,C32.Plugins.Sprite.Acts.SetPos,C32.Plugins.Touch.Cnds.OnTapGesture,C32.Plugins.System.Acts.Wait,C32.Plugins.System.Acts.GoToLayout,C32.Behaviors.Pin.Acts.PinByProperties,C32.Plugins.Sprite.Acts.SetInstanceVar,C32.Plugins.Sprite.Exps.X,C32.Plugins.Sprite.Exps.Y,C32.Plugins.Sprite.Acts.SetAnimFrame,C32.Plugins.System.Acts.SetVar,C32.Plugins.System.Acts.SetGroupActive,C32.Plugins.Audio.Acts.Stop,C32.Plugins.System.Cnds.CompareVar,C32.Plugins.System.Acts.SetLayoutEffectParam,C32.Plugins.System.Acts.SubVar,C32.Plugins.Sprite.Cnds.IsOverlapping,C32.Plugins.Sprite.Cnds.IsAnimPlaying,C32.Plugins.System.Cnds.TriggerOnce,C32.Plugins.Sprite.Cnds.OnAnyAnimFinished,C32.Plugins.System.Exps.choose,C32.Plugins.System.Cnds.IsGroupActive,C32.Behaviors.TileMovement.Cnds.IsMoving,C32.Plugins.Sprite.Acts.SetBoolInstanceVar,C32.Plugins.Sprite.Acts.AddInstanceVar,C32.Plugins.Audio.Acts.Play,C32.Plugins.Sprite.Acts.SubInstanceVar,C32.Plugins.Sprite.Cnds.CompareInstanceVar,C32.Plugins.Sprite.Acts.SetCollisions,C32.Plugins.Sprite.Cnds.IsCollisionEnabled,C32.Plugins.Sprite.Acts.SetAngle,C32.Plugins.Keyboard.Cnds.OnKey,C32.Plugins.System.Cnds.Compare,C32.Plugins.Sprite.Exps.Angle,C32.Plugins.Sprite.Acts.SetY,C32.Plugins.Sprite.Acts.SetX,C32.Plugins.Touch.Cnds.IsInTouch,C32.Plugins.Touch.Exps.AngleAt,C32.Plugins.Touch.Exps.X,C32.Plugins.Touch.Exps.Y,C32.Plugins.Touch.Cnds.CompareTouchSpeed,C32.Plugins.System.Cnds.IsBetweenAngles,C32.Plugins.Sprite.Acts.SetPosToObject,C32.Plugins.Sprite.Cnds.IsVisible,C32.Plugins.Sprite.Cnds.CompareY,C32.Behaviors.TileMovement.Acts.SimulateControl,C32.Plugins.Sprite.Cnds.CompareX,C32.Plugins.Sprite.Cnds.IsBoolInstanceVarSet,C32.Plugins.System.Cnds.Else,C32.Behaviors.Rotate.Acts.SetSpeed,C32.Plugins.Sprite.Cnds.CompareFrame,C32.Plugins.Sprite.Acts.SetSize,C32.Plugins.Sprite.Acts.SetOpacity,C32.Plugins.Sprite.Cnds.CompareHeight,C32.Plugins.Sprite.Exps.Width,C32.Plugins.Sprite.Exps.Height,C32.Plugins.Sprite.Exps.Opacity,C32.Plugins.System.Exps.int,C32.Plugins.System.Exps.layoutname,C32.Plugins.System.Acts.AddVar,C32.Plugins.LocalStorage.Acts.SetItem,C32.Plugins.Sprite.Cnds.OnDestroyed,C32.Plugins.Particles.Cnds.OnCreated,C32.Plugins.Particles.Acts.SetDefaultColor,C32.Plugins.Sprite.Cnds.CompareOpacity,C32.Plugins.System.Cnds.PickAll,C32.Plugins.Keyboard.Cnds.IsKeyDown,C32.Plugins.Sprite.Exps.Count,C32.Plugins.PlatformInfo.Cnds.IsOnMobile,C32.Behaviors.Sin.Acts.SetEnabled,C32.Plugins.Sprite.Acts.SetAnimSpeed,C32.Plugins.System.Acts.NextPrevLayout,C32.Plugins.System.Acts.RestartLayout,C32.Plugins.System.Exps.viewportleft,C32.Plugins.System.Exps.viewporttop,C32.Plugins.Touch.Cnds.IsTouchingObject,C32.Plugins.System.Exps.viewportright,C32.Plugins.System.Cnds.CompareBoolVar,C32.Plugins.TiledBg.Acts.SetVisible,C32.Plugins.Touch.Cnds.OnTapGestureObject,C32.Plugins.System.Acts.ToggleBoolVar,C32.Plugins.System.Acts.LoadState,C32.Plugins.System.Acts.SaveState,C32.Plugins.TiledBg.Acts.SetImageOffsetX,C32.Plugins.TiledBg.Exps.ImageOffsetX,C32.Plugins.System.Exps.dt,C32.Plugins.System.Acts.SetLayerVisible,C32.Plugins.Audio.Cnds.IsTagPlaying,C32.Plugins.System.Acts.GoToLayoutByName,C32.Plugins.Sprite.Exps.AnimationFrame,C32.Plugins.LocalStorage.Acts.CheckItemExists,C32.Plugins.LocalStorage.Cnds.OnItemExists,C32.Plugins.LocalStorage.Acts.GetItem,C32.Plugins.LocalStorage.Cnds.OnItemGet,C32.Plugins.LocalStorage.Exps.ItemValue,C32.Plugins.LocalStorage.Cnds.OnItemMissing,C32.Plugins.Browser.Acts.RequestFullScreen,C32.Plugins.Audio.Acts.StopAll,C32.Plugins.System.Acts.WaitForPreviousActions]},self.C3_JsPropNameTable=[{Sine:0},{NoSave:0},{buttons:0},{guideControl:0},{Audio:0},{Keyboard:0},{Touch:0},{Browser:0},{LocalStorage:0},{Mouse:0},{PlatformInfo:0},{TimelineController:0},{Video:0},{Pin:0},{checkDown0:0},{checkDown1:0},{checkDown2:0},{checkDown3:0},{checkDown4:0},{checkDown5:0},{checkDown6:0},{checkDown7:0},{checkFruit:0},{particl_1:0},{particl_2:0},{pinHead:0},{lastID:0},{lastX:0},{lastY:0},{currX:0},{currY:0},{moving:0},{TileMovement:0},{PlayerBody1:0},{PlayerBody2:0},{PlayerBody3:0},{PlayerBody4:0},{PlayerBody5:0},{PlayerBody6:0},{PlayerBody7:0},{bodyCount:0},{eating:0},{fruit:0},{keylock:0},{PlayerHead:0},{Rotate:0},{portal:0},{PlayerFace:0},{ovrlay:0},{fog:0},{plt_1:0},{plt_2:0},{plt_3:0},{ThankYouForPlaying_:0},{water:0},{gear:0},{tile:0},{AJAX:0},{JSON:0},{Tilemap:0},{gridmove:0},{TilemapBG:0},{mountains:0},{TiledBackground:0},{TiledBackground5:0},{TiledBackground7:0},{TiledBackground8:0},{mbutton:0},{levelBtns:0},{comingsoon:0},{logo:0},{logoGl:0},{deco_bush:0},{Sprite5:0},{game_tittle:0},{Sprite8:0},{Sprite9:0},{Layer:0},{banana_cinm:0},{caterpillar_dummy:0},{ScrollTo:0},{cinm_camera:0},{cinm_caterpillar:0},{cinm_medium:0},{dummy_stand:0},{fadee:0},{main_tree_leaves:0},{Anchor:0},{skip:0},{spider_cinm:0},{story_bg:0},{tree_cinm:0},{back_btnasset:0},{bg_board_tutorialCopy:0},{bg_ylw:0},{menu_btnasset:0},{next_btnasset:0},{tutorial:0},{tutorial_btn:0},{Tutorial_font:0},{PlayerBody:0},{CheckDown:0},{undoObjs:0},{snakes:0},{fadein:0},{ways:0},{touchXstart:0},{touchYstart:0},{touchAngle:0},{direction:0},{grids:0},{levels:0}],self.InstanceType={buttons:class extends self.ISpriteInstance{},guideControl:class extends self.ISpriteInstance{},Audio:class extends self.IInstance{},Keyboard:class extends self.IInstance{},Touch:class extends self.IInstance{},Browser:class extends self.IInstance{},LocalStorage:class extends self.IInstance{},Mouse:class extends self.IInstance{},PlatformInfo:class extends self.IInstance{},TimelineController:class extends self.IInstance{},Video:class extends self.IWorldInstance{},checkDown0:class extends self.ISpriteInstance{},checkDown1:class extends self.ISpriteInstance{},checkDown2:class extends self.ISpriteInstance{},checkDown3:class extends self.ISpriteInstance{},checkDown4:class extends self.ISpriteInstance{},checkDown5:class extends self.ISpriteInstance{},checkDown6:class extends self.ISpriteInstance{},checkDown7:class extends self.ISpriteInstance{},checkFruit:class extends self.ISpriteInstance{},particl_1:class extends self.IParticlesInstance{},particl_2:class extends self.IParticlesInstance{},pinHead:class extends self.ISpriteInstance{},PlayerBody1:class extends self.ISpriteInstance{},PlayerBody2:class extends self.ISpriteInstance{},PlayerBody3:class extends self.ISpriteInstance{},PlayerBody4:class extends self.ISpriteInstance{},PlayerBody5:class extends self.ISpriteInstance{},PlayerBody6:class extends self.ISpriteInstance{},PlayerBody7:class extends self.ISpriteInstance{},PlayerHead:class extends self.ISpriteInstance{},portal:class extends self.ISpriteInstance{},PlayerFace:class extends self.ISpriteInstance{},ovrlay:class extends self.ISpriteInstance{},fog:class extends self.ITiledBackgroundInstance{},plt_1:class extends self.ITiledBackgroundInstance{},plt_2:class extends self.ITiledBackgroundInstance{},plt_3:class extends self.ITiledBackgroundInstance{},ThankYouForPlaying_:class extends self.ISpriteInstance{},water:class extends self.ITiledBackgroundInstance{},gear:class extends self.ISpriteInstance{},tile:class extends self.ISpriteInstance{},AJAX:class extends self.IInstance{},JSON:class extends self.IJSONInstance{},Tilemap:class extends self.ITilemapInstance{},gridmove:class extends self.ITiledBackgroundInstance{},TilemapBG:class extends self.ITilemapInstance{},mountains:class extends self.ISpriteInstance{},TiledBackground:class extends self.ITiledBackgroundInstance{},TiledBackground5:class extends self.ITiledBackgroundInstance{},TiledBackground7:class extends self.ITiledBackgroundInstance{},TiledBackground8:class extends self.ITiledBackgroundInstance{},mbutton:class extends self.ISpriteInstance{},levelBtns:class extends self.ISpriteInstance{},comingsoon:class extends self.ISpriteInstance{},logo:class extends self.IWorldInstance{},logoGl:class extends self.ISpriteInstance{},deco_bush:class extends self.ISpriteInstance{},Sprite5:class extends self.ISpriteInstance{},game_tittle:class extends self.ISpriteInstance{},Sprite8:class extends self.ISpriteInstance{},Sprite9:class extends self.ISpriteInstance{},Layer:class extends self.ISpriteInstance{},banana_cinm:class extends self.ISpriteInstance{},caterpillar_dummy:class extends self.ISpriteInstance{},cinm_camera:class extends self.ISpriteInstance{},cinm_caterpillar:class extends self.ISpriteInstance{},cinm_medium:class extends self.ISpriteInstance{},dummy_stand:class extends self.ISpriteInstance{},fadee:class extends self.ISpriteInstance{},main_tree_leaves:class extends self.ISpriteInstance{},skip:class extends self.ISpriteInstance{},spider_cinm:class extends self.ISpriteInstance{},story_bg:class extends self.ISpriteInstance{},tree_cinm:class extends self.ISpriteInstance{},back_btnasset:class extends self.ISpriteInstance{},bg_board_tutorialCopy:class extends self.ISpriteInstance{},bg_ylw:class extends self.ISpriteInstance{},menu_btnasset:class extends self.ISpriteInstance{},next_btnasset:class extends self.ISpriteInstance{},tutorial:class extends self.ISpriteInstance{},tutorial_btn:class extends self.ISpriteInstance{},Tutorial_font:class extends self.ISpriteInstance{},PlayerBody:class extends self.ISpriteInstance{},CheckDown:class extends self.ISpriteInstance{},undoObjs:class extends self.ISpriteInstance{}}; home/jogoso94/public_html/jogos/flower_count_master/scripts/c3main.js 0000644 00000000064 15043136120 0022047 0 ustar 00 import "./c3runtime.js"; import "./objRefTable.js"; home/jogoso94/public_html/jogos/castle_protectors/scripts/c3main.js 0000644 00005272526 15043145340 0021554 0 ustar 00 // Generated by Construct, the game and animation creation tool // Visit: https://www.construct.net var __create=Object.create,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty,__require=(e=>"undefined"!=typeof require?require:"undefined"!=typeof Proxy?new Proxy(e,{get:(e,t)=>("undefined"!=typeof require?require:e)[t]}):e)(function(e){if("undefined"!=typeof require)return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),__commonJS=(e,t)=>function(){return t||(0,e[__getOwnPropNames(e)[0]])((t={exports:{}}).exports,t),t.exports},__copyProps=(t,s,i,r)=>{if(s&&"object"==typeof s||"function"==typeof s)for(let e of __getOwnPropNames(s))__hasOwnProp.call(t,e)||e===i||__defProp(t,e,{get:()=>s[e],enumerable:!(r=__getOwnPropDesc(s,e))||r.enumerable});return t},__toESM=(e,t,s)=>(s=null!=e?__create(__getProtoOf(e)):{},__copyProps(!t&&e&&e.__esModule?s:__defProp(s,"default",{value:e,enumerable:!0}),e)),require_c3runtime=__commonJS({"file-map:scripts/c3runtime.js"(exports,module){{let setMatrixArrayType2=function(e){ARRAY_TYPE=e},toRadian2=function(e){return e*degree},equals$92=function(e,t){return Math.abs(e-t)<=EPSILON*Math.max(1,Math.abs(e),Math.abs(t))},create$82=function(){var e=new ARRAY_TYPE(4);return ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e},clone$82=function(e){var t=new ARRAY_TYPE(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},copy$82=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},identity$52=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e},fromValues$82=function(e,t,s,i){var r=new ARRAY_TYPE(4);return r[0]=e,r[1]=t,r[2]=s,r[3]=i,r},set$82=function(e,t,s,i,r){return e[0]=t,e[1]=s,e[2]=i,e[3]=r,e},transpose$22=function(e,t){var s;return e===t?(s=t[1],e[1]=t[2],e[2]=s):(e[0]=t[0],e[1]=t[2],e[2]=t[1],e[3]=t[3]),e},invert$52=function(e,t){var s=t[0],i=t[1],r=t[2],n=s*(t=t[3])-r*i;return n?(e[0]=t*(n=1/n),e[1]=-i*n,e[2]=-r*n,e[3]=s*n,e):null},adjoint$22=function(e,t){var s=t[0];return e[0]=t[3],e[1]=-t[1],e[2]=-t[2],e[3]=s,e},determinant$32=function(e){return e[0]*e[3]-e[2]*e[1]},multiply$82=function(e,t,s){var i=t[0],r=t[1],n=t[2],t=t[3],a=s[0],o=s[1],l=s[2],s=s[3];return e[0]=i*a+n*o,e[1]=r*a+t*o,e[2]=i*l+n*s,e[3]=r*l+t*s,e},rotate$42=function(e,t,s){var i=t[0],r=t[1],n=t[2],t=t[3],a=Math.sin(s),s=Math.cos(s);return e[0]=i*s+n*a,e[1]=r*s+t*a,e[2]=i*-a+n*s,e[3]=r*-a+t*s,e},scale$82=function(e,t,s){var i=t[0],r=t[1],n=t[2],t=t[3],a=s[0],s=s[1];return e[0]=i*a,e[1]=r*a,e[2]=n*s,e[3]=t*s,e},fromRotation$42=function(e,t){var s=Math.sin(t),t=Math.cos(t);return e[0]=t,e[1]=s,e[2]=-s,e[3]=t,e},fromScaling$32=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=t[1],e},str$82=function(e){return"mat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},frob$32=function(e){return Math.hypot(e[0],e[1],e[2],e[3])},LDU2=function(e,t,s,i){return e[2]=i[2]/i[0],s[0]=i[0],s[1]=i[1],s[3]=i[3]-e[2]*s[1],[e,t,s]},add$82=function(e,t,s){return e[0]=t[0]+s[0],e[1]=t[1]+s[1],e[2]=t[2]+s[2],e[3]=t[3]+s[3],e},subtract$62=function(e,t,s){return e[0]=t[0]-s[0],e[1]=t[1]-s[1],e[2]=t[2]-s[2],e[3]=t[3]-s[3],e},exactEquals$82=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]},equals$82=function(e,t){var s=e[0],i=e[1],r=e[2],e=e[3],n=t[0],a=t[1],o=t[2],t=t[3];return Math.abs(s-n)<=EPSILON*Math.max(1,Math.abs(s),Math.abs(n))&&Math.abs(i-a)<=EPSILON*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(r-o)<=EPSILON*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(e-t)<=EPSILON*Math.max(1,Math.abs(e),Math.abs(t))},multiplyScalar$32=function(e,t,s){return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e[3]=t[3]*s,e},multiplyScalarAndAdd$32=function(e,t,s,i){return e[0]=t[0]+s[0]*i,e[1]=t[1]+s[1]*i,e[2]=t[2]+s[2]*i,e[3]=t[3]+s[3]*i,e},create$72=function(){var e=new ARRAY_TYPE(6);return ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0,e[4]=0,e[5]=0),e[0]=1,e[3]=1,e},clone$72=function(e){var t=new ARRAY_TYPE(6);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t},copy$72=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e},identity$42=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e},fromValues$72=function(e,t,s,i,r,n){var a=new ARRAY_TYPE(6);return a[0]=e,a[1]=t,a[2]=s,a[3]=i,a[4]=r,a[5]=n,a},set$72=function(e,t,s,i,r,n,a){return e[0]=t,e[1]=s,e[2]=i,e[3]=r,e[4]=n,e[5]=a,e},invert$42=function(e,t){var s=t[0],i=t[1],r=t[2],n=t[3],a=t[4],t=t[5],o=s*n-i*r;return o?(e[0]=n*(o=1/o),e[1]=-i*o,e[2]=-r*o,e[3]=s*o,e[4]=(r*t-n*a)*o,e[5]=(i*a-s*t)*o,e):null},determinant$22=function(e){return e[0]*e[3]-e[1]*e[2]},multiply$72=function(e,t,s){var i=t[0],r=t[1],n=t[2],a=t[3],o=t[4],t=t[5],l=s[0],h=s[1],c=s[2],u=s[3],_=s[4],s=s[5];return e[0]=i*l+n*h,e[1]=r*l+a*h,e[2]=i*c+n*u,e[3]=r*c+a*u,e[4]=i*_+n*s+o,e[5]=r*_+a*s+t,e},rotate$32=function(e,t,s){var i=t[0],r=t[1],n=t[2],a=t[3],o=t[4],t=t[5],l=Math.sin(s),s=Math.cos(s);return e[0]=i*s+n*l,e[1]=r*s+a*l,e[2]=i*-l+n*s,e[3]=r*-l+a*s,e[4]=o,e[5]=t,e},scale$72=function(e,t,s){var i=t[0],r=t[1],n=t[2],a=t[3],o=t[4],t=t[5],l=s[0],s=s[1];return e[0]=i*l,e[1]=r*l,e[2]=n*s,e[3]=a*s,e[4]=o,e[5]=t,e},translate$32=function(e,t,s){var i=t[0],r=t[1],n=t[2],a=t[3],o=t[4],t=t[5],l=s[0],s=s[1];return e[0]=i,e[1]=r,e[2]=n,e[3]=a,e[4]=i*l+n*s+o,e[5]=r*l+a*s+t,e},fromRotation$32=function(e,t){var s=Math.sin(t),t=Math.cos(t);return e[0]=t,e[1]=s,e[2]=-s,e[3]=t,e[4]=0,e[5]=0,e},fromScaling$22=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=t[1],e[4]=0,e[5]=0,e},fromTranslation$32=function(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=t[0],e[5]=t[1],e},str$72=function(e){return"mat2d("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+")"},frob$22=function(e){return Math.hypot(e[0],e[1],e[2],e[3],e[4],e[5],1)},add$72=function(e,t,s){return e[0]=t[0]+s[0],e[1]=t[1]+s[1],e[2]=t[2]+s[2],e[3]=t[3]+s[3],e[4]=t[4]+s[4],e[5]=t[5]+s[5],e},subtract$52=function(e,t,s){return e[0]=t[0]-s[0],e[1]=t[1]-s[1],e[2]=t[2]-s[2],e[3]=t[3]-s[3],e[4]=t[4]-s[4],e[5]=t[5]-s[5],e},multiplyScalar$22=function(e,t,s){return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e[3]=t[3]*s,e[4]=t[4]*s,e[5]=t[5]*s,e},multiplyScalarAndAdd$22=function(e,t,s,i){return e[0]=t[0]+s[0]*i,e[1]=t[1]+s[1]*i,e[2]=t[2]+s[2]*i,e[3]=t[3]+s[3]*i,e[4]=t[4]+s[4]*i,e[5]=t[5]+s[5]*i,e},exactEquals$72=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]},equals$72=function(e,t){var s=e[0],i=e[1],r=e[2],n=e[3],a=e[4],e=e[5],o=t[0],l=t[1],h=t[2],c=t[3],u=t[4],t=t[5];return Math.abs(s-o)<=EPSILON*Math.max(1,Math.abs(s),Math.abs(o))&&Math.abs(i-l)<=EPSILON*Math.max(1,Math.abs(i),Math.abs(l))&&Math.abs(r-h)<=EPSILON*Math.max(1,Math.abs(r),Math.abs(h))&&Math.abs(n-c)<=EPSILON*Math.max(1,Math.abs(n),Math.abs(c))&&Math.abs(a-u)<=EPSILON*Math.max(1,Math.abs(a),Math.abs(u))&&Math.abs(e-t)<=EPSILON*Math.max(1,Math.abs(e),Math.abs(t))},create$62=function(){var e=new ARRAY_TYPE(9);return ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e},fromMat4$12=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e},clone$62=function(e){var t=new ARRAY_TYPE(9);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t},copy$62=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e},fromValues$62=function(e,t,s,i,r,n,a,o,l){var h=new ARRAY_TYPE(9);return h[0]=e,h[1]=t,h[2]=s,h[3]=i,h[4]=r,h[5]=n,h[6]=a,h[7]=o,h[8]=l,h},set$62=function(e,t,s,i,r,n,a,o,l,h){return e[0]=t,e[1]=s,e[2]=i,e[3]=r,e[4]=n,e[5]=a,e[6]=o,e[7]=l,e[8]=h,e},identity$32=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},transpose$12=function(e,t){var s,i,r;return e===t?(s=t[1],i=t[2],r=t[5],e[1]=t[3],e[2]=t[6],e[3]=s,e[5]=t[7],e[6]=i,e[7]=r):(e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8]),e},invert$32=function(e,t){var s=t[0],i=t[1],r=t[2],n=t[3],a=t[4],o=t[5],l=t[6],h=t[7],c=(t=t[8])*a-o*h,u=-t*n+o*l,_=h*n-a*l,d=s*c+i*u+r*_;return d?(e[0]=c*(d=1/d),e[1]=(-t*i+r*h)*d,e[2]=(o*i-r*a)*d,e[3]=u*d,e[4]=(t*s-r*l)*d,e[5]=(-o*s+r*n)*d,e[6]=_*d,e[7]=(-h*s+i*l)*d,e[8]=(a*s-i*n)*d,e):null},adjoint$12=function(e,t){var s=t[0],i=t[1],r=t[2],n=t[3],a=t[4],o=t[5],l=t[6],h=t[7],t=t[8];return e[0]=a*t-o*h,e[1]=r*h-i*t,e[2]=i*o-r*a,e[3]=o*l-n*t,e[4]=s*t-r*l,e[5]=r*n-s*o,e[6]=n*h-a*l,e[7]=i*l-s*h,e[8]=s*a-i*n,e},determinant$12=function(e){var t=e[0],s=e[3],i=e[4],r=e[5],n=e[6],a=e[7],o=e[8];return t*(o*i-r*a)+e[1]*(-o*s+r*n)+e[2]*(a*s-i*n)},multiply$62=function(e,t,s){var i=t[0],r=t[1],n=t[2],a=t[3],o=t[4],l=t[5],h=t[6],c=t[7],t=t[8],u=s[0],_=s[1],d=s[2],p=s[3],m=s[4],g=s[5],f=s[6],S=s[7],s=s[8];return e[0]=u*i+_*a+d*h,e[1]=u*r+_*o+d*c,e[2]=u*n+_*l+d*t,e[3]=p*i+m*a+g*h,e[4]=p*r+m*o+g*c,e[5]=p*n+m*l+g*t,e[6]=f*i+S*a+s*h,e[7]=f*r+S*o+s*c,e[8]=f*n+S*l+s*t,e},translate$22=function(e,t,s){var i=t[0],r=t[1],n=t[2],a=t[3],o=t[4],l=t[5],h=t[6],c=t[7],t=t[8],u=s[0],s=s[1];return e[0]=i,e[1]=r,e[2]=n,e[3]=a,e[4]=o,e[5]=l,e[6]=u*i+s*a+h,e[7]=u*r+s*o+c,e[8]=u*n+s*l+t,e},rotate$22=function(e,t,s){var i=t[0],r=t[1],n=t[2],a=t[3],o=t[4],l=t[5],h=t[6],c=t[7],t=t[8],u=Math.sin(s),s=Math.cos(s);return e[0]=s*i+u*a,e[1]=s*r+u*o,e[2]=s*n+u*l,e[3]=s*a-u*i,e[4]=s*o-u*r,e[5]=s*l-u*n,e[6]=h,e[7]=c,e[8]=t,e},scale$62=function(e,t,s){var i=s[0],s=s[1];return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=s*t[3],e[4]=s*t[4],e[5]=s*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e},fromTranslation$22=function(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=t[0],e[7]=t[1],e[8]=1,e},fromRotation$22=function(e,t){var s=Math.sin(t),t=Math.cos(t);return e[0]=t,e[1]=s,e[2]=0,e[3]=-s,e[4]=t,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},fromScaling$12=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=t[1],e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},fromMat2d2=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=0,e[3]=t[2],e[4]=t[3],e[5]=0,e[6]=t[4],e[7]=t[5],e[8]=1,e},fromQuat$12=function(e,t){var s=t[0],i=t[2],r=i+i,s=s*(h=s+s),n=(a=t[1])*h,a=a*(c=a+a),o=i*h,l=i*c,h=(t=t[3])*h,c=t*c,t=t*r;return e[0]=1-a-(i=i*r),e[3]=n-t,e[6]=o+c,e[1]=n+t,e[4]=1-s-i,e[7]=l-h,e[2]=o-c,e[5]=l+h,e[8]=1-s-a,e},normalFromMat42=function(e,t){var s=t[0],i=t[1],r=t[2],n=t[3],a=t[4],o=t[5],l=t[6],h=t[7],c=t[8],u=t[9],_=t[10],d=t[11],p=t[12],m=t[13],g=t[14],f=s*o-i*a,S=s*l-r*a,C=s*h-n*a,y=i*l-r*o,G=i*h-n*o,I=r*h-n*l,T=c*m-u*p,b=c*g-_*p,A=u*g-_*m;return(d=f*(_=_*(t=t[15])-d*g)-S*(u=u*t-d*m)+C*A+y*(c=c*t-d*p)-G*b+I*T)?(e[0]=(o*_-l*u+h*A)*(d=1/d),e[1]=(l*c-a*_-h*b)*d,e[2]=(a*u-o*c+h*T)*d,e[3]=(r*u-i*_-n*A)*d,e[4]=(s*_-r*c+n*b)*d,e[5]=(i*c-s*u-n*T)*d,e[6]=(m*I-g*G+t*y)*d,e[7]=(g*C-p*I-t*S)*d,e[8]=(p*G-m*C+t*f)*d,e):null},projection2=function(e,t,s){return e[0]=2/t,e[1]=0,e[2]=0,e[3]=0,e[4]=-2/s,e[5]=0,e[6]=-1,e[7]=1,e[8]=1,e},str$62=function(e){return"mat3("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+")"},frob$12=function(e){return Math.hypot(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},add$62=function(e,t,s){return e[0]=t[0]+s[0],e[1]=t[1]+s[1],e[2]=t[2]+s[2],e[3]=t[3]+s[3],e[4]=t[4]+s[4],e[5]=t[5]+s[5],e[6]=t[6]+s[6],e[7]=t[7]+s[7],e[8]=t[8]+s[8],e},subtract$42=function(e,t,s){return e[0]=t[0]-s[0],e[1]=t[1]-s[1],e[2]=t[2]-s[2],e[3]=t[3]-s[3],e[4]=t[4]-s[4],e[5]=t[5]-s[5],e[6]=t[6]-s[6],e[7]=t[7]-s[7],e[8]=t[8]-s[8],e},multiplyScalar$12=function(e,t,s){return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e[3]=t[3]*s,e[4]=t[4]*s,e[5]=t[5]*s,e[6]=t[6]*s,e[7]=t[7]*s,e[8]=t[8]*s,e},multiplyScalarAndAdd$12=function(e,t,s,i){return e[0]=t[0]+s[0]*i,e[1]=t[1]+s[1]*i,e[2]=t[2]+s[2]*i,e[3]=t[3]+s[3]*i,e[4]=t[4]+s[4]*i,e[5]=t[5]+s[5]*i,e[6]=t[6]+s[6]*i,e[7]=t[7]+s[7]*i,e[8]=t[8]+s[8]*i,e},exactEquals$62=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]},equals$62=function(e,t){var s=e[0],i=e[1],r=e[2],n=e[3],a=e[4],o=e[5],l=e[6],h=e[7],e=e[8],c=t[0],u=t[1],_=t[2],d=t[3],p=t[4],m=t[5],g=t[6],f=t[7],t=t[8];return Math.abs(s-c)<=EPSILON*Math.max(1,Math.abs(s),Math.abs(c))&&Math.abs(i-u)<=EPSILON*Math.max(1,Math.abs(i),Math.abs(u))&&Math.abs(r-_)<=EPSILON*Math.max(1,Math.abs(r),Math.abs(_))&&Math.abs(n-d)<=EPSILON*Math.max(1,Math.abs(n),Math.abs(d))&&Math.abs(a-p)<=EPSILON*Math.max(1,Math.abs(a),Math.abs(p))&&Math.abs(o-m)<=EPSILON*Math.max(1,Math.abs(o),Math.abs(m))&&Math.abs(l-g)<=EPSILON*Math.max(1,Math.abs(l),Math.abs(g))&&Math.abs(h-f)<=EPSILON*Math.max(1,Math.abs(h),Math.abs(f))&&Math.abs(e-t)<=EPSILON*Math.max(1,Math.abs(e),Math.abs(t))},create$52=function(){var e=new ARRAY_TYPE(16);return ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e},clone$52=function(e){var t=new ARRAY_TYPE(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},copy$52=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},fromValues$52=function(e,t,s,i,r,n,a,o,l,h,c,u,_,d,p,m){var g=new ARRAY_TYPE(16);return g[0]=e,g[1]=t,g[2]=s,g[3]=i,g[4]=r,g[5]=n,g[6]=a,g[7]=o,g[8]=l,g[9]=h,g[10]=c,g[11]=u,g[12]=_,g[13]=d,g[14]=p,g[15]=m,g},set$52=function(e,t,s,i,r,n,a,o,l,h,c,u,_,d,p,m,g){return e[0]=t,e[1]=s,e[2]=i,e[3]=r,e[4]=n,e[5]=a,e[6]=o,e[7]=l,e[8]=h,e[9]=c,e[10]=u,e[11]=_,e[12]=d,e[13]=p,e[14]=m,e[15]=g,e},identity$22=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},transpose2=function(e,t){var s,i,r,n,a,o;return e===t?(s=t[1],i=t[2],r=t[3],n=t[6],a=t[7],o=t[11],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=s,e[6]=t[9],e[7]=t[13],e[8]=i,e[9]=n,e[11]=t[14],e[12]=r,e[13]=a,e[14]=o):(e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15]),e},invert$22=function(e,t){var s=t[0],i=t[1],r=t[2],n=t[3],a=t[4],o=t[5],l=t[6],h=t[7],c=t[8],u=t[9],_=t[10],d=t[11],p=t[12],m=t[13],g=t[14],f=s*o-i*a,S=s*l-r*a,C=s*h-n*a,y=i*l-r*o,G=i*h-n*o,I=r*h-n*l,T=c*m-u*p,b=c*g-_*p,A=c*(t=t[15])-d*p,P=u*g-_*m,R=u*t-d*m,x=_*t-d*g,E=f*x-S*R+C*P+y*A-G*b+I*T;return E?(e[0]=(o*x-l*R+h*P)*(E=1/E),e[1]=(r*R-i*x-n*P)*E,e[2]=(m*I-g*G+t*y)*E,e[3]=(_*G-u*I-d*y)*E,e[4]=(l*A-a*x-h*b)*E,e[5]=(s*x-r*A+n*b)*E,e[6]=(g*C-p*I-t*S)*E,e[7]=(c*I-_*C+d*S)*E,e[8]=(a*R-o*A+h*T)*E,e[9]=(i*A-s*R-n*T)*E,e[10]=(p*G-m*C+t*f)*E,e[11]=(u*C-c*G-d*f)*E,e[12]=(o*b-a*P-l*T)*E,e[13]=(s*P-i*b+r*T)*E,e[14]=(m*S-p*y-g*f)*E,e[15]=(c*y-u*S+_*f)*E,e):null},adjoint2=function(e,t){var s=t[0],i=t[1],r=t[2],n=t[3],a=t[4],o=t[5],l=t[6],h=t[7],c=t[8],u=t[9],_=t[10],d=t[11],p=t[12],m=t[13],g=t[14],f=s*o-i*a,S=s*l-r*a,C=s*h-n*a,y=i*l-r*o,G=i*h-n*o,I=r*h-n*l,T=c*m-u*p,b=c*g-_*p,A=c*(t=t[15])-d*p,P=u*g-_*m,R=u*t-d*m,x=_*t-d*g;return e[0]=o*x-l*R+h*P,e[1]=r*R-i*x-n*P,e[2]=m*I-g*G+t*y,e[3]=_*G-u*I-d*y,e[4]=l*A-a*x-h*b,e[5]=s*x-r*A+n*b,e[6]=g*C-p*I-t*S,e[7]=c*I-_*C+d*S,e[8]=a*R-o*A+h*T,e[9]=i*A-s*R-n*T,e[10]=p*G-m*C+t*f,e[11]=u*C-c*G-d*f,e[12]=o*b-a*P-l*T,e[13]=s*P-i*b+r*T,e[14]=m*S-p*y-g*f,e[15]=c*y-u*S+_*f,e},determinant2=function(e){var t=e[0],s=e[1],i=e[2],r=e[4],n=e[5],a=e[6],o=e[8],l=e[9],h=e[10],c=e[12],u=e[13],_=e[14],d=t*n-s*r,p=t*a-i*r,m=s*a-i*n,g=o*u-l*c,f=o*_-h*c,S=l*_-h*u;return e[7]*(t*S-s*f+i*g)-e[3]*(r*S-n*f+a*g)+e[15]*(o*m-l*p+h*d)-e[11]*(c*m-u*p+_*d)},multiply$52=function(e,t,s){var i=t[0],r=t[1],n=t[2],a=t[3],o=t[4],l=t[5],h=t[6],c=t[7],u=t[8],_=t[9],d=t[10],p=t[11],m=t[12],g=t[13],f=t[14],t=t[15],S=s[0],C=s[1],y=s[2],G=s[3];return e[0]=S*i+C*o+y*u+G*m,e[1]=S*r+C*l+y*_+G*g,e[2]=S*n+C*h+y*d+G*f,e[3]=S*a+C*c+y*p+G*t,e[4]=(S=s[4])*i+(C=s[5])*o+(y=s[6])*u+(G=s[7])*m,e[5]=S*r+C*l+y*_+G*g,e[6]=S*n+C*h+y*d+G*f,e[7]=S*a+C*c+y*p+G*t,e[8]=(S=s[8])*i+(C=s[9])*o+(y=s[10])*u+(G=s[11])*m,e[9]=S*r+C*l+y*_+G*g,e[10]=S*n+C*h+y*d+G*f,e[11]=S*a+C*c+y*p+G*t,e[12]=(S=s[12])*i+(C=s[13])*o+(y=s[14])*u+(G=s[15])*m,e[13]=S*r+C*l+y*_+G*g,e[14]=S*n+C*h+y*d+G*f,e[15]=S*a+C*c+y*p+G*t,e},translate$12=function(e,t,s){var i,r,n,a,o,l,h,c,u,_,d,p,m=s[0],g=s[1],s=s[2];return t===e?(e[12]=t[0]*m+t[4]*g+t[8]*s+t[12],e[13]=t[1]*m+t[5]*g+t[9]*s+t[13],e[14]=t[2]*m+t[6]*g+t[10]*s+t[14],e[15]=t[3]*m+t[7]*g+t[11]*s+t[15]):(i=t[0],r=t[1],n=t[2],a=t[3],o=t[4],l=t[5],h=t[6],c=t[7],u=t[8],_=t[9],d=t[10],p=t[11],e[0]=i,e[1]=r,e[2]=n,e[3]=a,e[4]=o,e[5]=l,e[6]=h,e[7]=c,e[8]=u,e[9]=_,e[10]=d,e[11]=p,e[12]=i*m+o*g+u*s+t[12],e[13]=r*m+l*g+_*s+t[13],e[14]=n*m+h*g+d*s+t[14],e[15]=a*m+c*g+p*s+t[15]),e},scale$52=function(e,t,s){var i=s[0],r=s[1],s=s[2];return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*s,e[9]=t[9]*s,e[10]=t[10]*s,e[11]=t[11]*s,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},rotate$12=function(e,t,s,i){var r,n,a,o,l,h,c,u,_,d,p,m,g,f,S,C,y,G,I,T,b=i[0],A=i[1],i=i[2],P=Math.hypot(b,A,i);return P<EPSILON?null:(b*=P=1/P,A*=P,i*=P,P=Math.sin(s),s=Math.cos(s),n=t[0],a=t[1],o=t[2],l=t[3],c=t[5],u=t[6],_=t[7],p=t[9],m=t[10],g=t[11],S=b*A*(r=1-s)-i*P,C=A*A*r+s,y=i*A*r+b*P,G=b*i*r+A*P,I=A*i*r-b*P,T=i*i*r+s,e[0]=n*(s=b*b*r+s)+(h=t[4])*(f=A*b*r+i*P)+(d=t[8])*(i=i*b*r-A*P),e[1]=a*s+c*f+p*i,e[2]=o*s+u*f+m*i,e[3]=l*s+_*f+g*i,e[4]=n*S+h*C+d*y,e[5]=a*S+c*C+p*y,e[6]=o*S+u*C+m*y,e[7]=l*S+_*C+g*y,e[8]=n*G+h*I+d*T,e[9]=a*G+c*I+p*T,e[10]=o*G+u*I+m*T,e[11]=l*G+_*I+g*T,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)},rotateX$32=function(e,t,s){var i=Math.sin(s),s=Math.cos(s),r=t[4],n=t[5],a=t[6],o=t[7],l=t[8],h=t[9],c=t[10],u=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=r*s+l*i,e[5]=n*s+h*i,e[6]=a*s+c*i,e[7]=o*s+u*i,e[8]=l*s-r*i,e[9]=h*s-n*i,e[10]=c*s-a*i,e[11]=u*s-o*i,e},rotateY$32=function(e,t,s){var i=Math.sin(s),s=Math.cos(s),r=t[0],n=t[1],a=t[2],o=t[3],l=t[8],h=t[9],c=t[10],u=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=r*s-l*i,e[1]=n*s-h*i,e[2]=a*s-c*i,e[3]=o*s-u*i,e[8]=r*i+l*s,e[9]=n*i+h*s,e[10]=a*i+c*s,e[11]=o*i+u*s,e},rotateZ$32=function(e,t,s){var i=Math.sin(s),s=Math.cos(s),r=t[0],n=t[1],a=t[2],o=t[3],l=t[4],h=t[5],c=t[6],u=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=r*s+l*i,e[1]=n*s+h*i,e[2]=a*s+c*i,e[3]=o*s+u*i,e[4]=l*s-r*i,e[5]=h*s-n*i,e[6]=c*s-a*i,e[7]=u*s-o*i,e},fromTranslation$12=function(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e},fromScaling2=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},fromRotation$12=function(e,t,s){var i,r=s[0],n=s[1],s=s[2],a=Math.hypot(r,n,s);return a<EPSILON?null:(r*=a=1/a,n*=a,s*=a,a=Math.sin(t),t=Math.cos(t),e[0]=r*r*(i=1-t)+t,e[1]=n*r*i+s*a,e[2]=s*r*i-n*a,e[3]=0,e[4]=r*n*i-s*a,e[5]=n*n*i+t,e[6]=s*n*i+r*a,e[7]=0,e[8]=r*s*i+n*a,e[9]=n*s*i-r*a,e[10]=s*s*i+t,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)},fromXRotation2=function(e,t){var s=Math.sin(t),t=Math.cos(t);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t,e[6]=s,e[7]=0,e[8]=0,e[9]=-s,e[10]=t,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},fromYRotation2=function(e,t){var s=Math.sin(t),t=Math.cos(t);return e[0]=t,e[1]=0,e[2]=-s,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=s,e[9]=0,e[10]=t,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},fromZRotation2=function(e,t){var s=Math.sin(t),t=Math.cos(t);return e[0]=t,e[1]=s,e[2]=0,e[3]=0,e[4]=-s,e[5]=t,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},fromRotationTranslation$12=function(e,t,s){var i=t[0],r=t[2],n=r+r,a=i*(c=i+i),o=i*(u=(h=t[1])+h),i=i*n,l=h*u,h=h*n,c=(t=t[3])*c,u=t*u,t=t*n;return e[0]=1-(l+(r=r*n)),e[1]=o+t,e[2]=i-u,e[3]=0,e[4]=o-t,e[5]=1-(a+r),e[6]=h+c,e[7]=0,e[8]=i+u,e[9]=h-c,e[10]=1-(a+l),e[11]=0,e[12]=s[0],e[13]=s[1],e[14]=s[2],e[15]=1,e},fromQuat22=function(e,t){var s=new ARRAY_TYPE(3),i=-t[0],r=-t[1],n=-t[2],a=t[3],o=t[4],l=t[5],h=t[6],c=t[7],u=i*i+r*r+n*n+a*a;return 0<u?(s[0]=2*(o*a+c*i+l*n-h*r)/u,s[1]=2*(l*a+c*r+h*i-o*n)/u,s[2]=2*(h*a+c*n+o*r-l*i)/u):(s[0]=2*(o*a+c*i+l*n-h*r),s[1]=2*(l*a+c*r+h*i-o*n),s[2]=2*(h*a+c*n+o*r-l*i)),fromRotationTranslation$12(e,t,s),e},getTranslation$12=function(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e},getScaling2=function(e,t){var s=t[0],i=t[4],r=t[5],n=t[6],a=t[8],o=t[9],l=t[10];return e[0]=Math.hypot(s,t[1],t[2]),e[1]=Math.hypot(i,r,n),e[2]=Math.hypot(a,o,l),e},getRotation2=function(e,t){var s=new ARRAY_TYPE(3),i=(getScaling2(s,t),1/s[0]),r=1/s[1],s=1/s[2],n=t[0]*i,a=t[1]*r,o=t[2]*s,l=t[4]*i,h=t[5]*r,c=t[6]*s,i=t[8]*i,r=t[9]*r,u=0;return 0<(s=n+h+(t=t[10]*s))?(u=2*Math.sqrt(1+s),e[3]=.25*u,e[0]=(c-r)/u,e[1]=(i-o)/u,e[2]=(a-l)/u):h<n&&t<n?(u=2*Math.sqrt(1+n-h-t),e[3]=(c-r)/u,e[0]=.25*u,e[1]=(a+l)/u,e[2]=(i+o)/u):t<h?(u=2*Math.sqrt(1+h-n-t),e[3]=(i-o)/u,e[0]=(a+l)/u,e[1]=.25*u,e[2]=(c+r)/u):(u=2*Math.sqrt(1+t-n-h),e[3]=(a-l)/u,e[0]=(i+o)/u,e[1]=(c+r)/u,e[2]=.25*u),e},decompose2=function(e,t,s,i){t[0]=i[12],t[1]=i[13],t[2]=i[14];var t=i[0],r=i[1],n=i[2],a=i[4],o=i[5],l=i[6],h=i[8],c=i[9],i=i[10],u=(s[0]=Math.hypot(t,r,n),s[1]=Math.hypot(a,o,l),s[2]=Math.hypot(h,c,i),1/s[0]),_=1/s[1],t=t*u,r=r*_,n=n*(s=1/s[2]),a=a*u,l=l*s,h=h*u,u=c*_,c=i*s,i=0;return 0<(_=t+(o=o*_)+c)?(i=2*Math.sqrt(1+_),e[3]=.25*i,e[0]=(l-u)/i,e[1]=(h-n)/i,e[2]=(r-a)/i):o<t&&c<t?(i=2*Math.sqrt(1+t-o-c),e[3]=(l-u)/i,e[0]=.25*i,e[1]=(r+a)/i,e[2]=(h+n)/i):c<o?(i=2*Math.sqrt(1+o-t-c),e[3]=(h-n)/i,e[0]=(r+a)/i,e[1]=.25*i,e[2]=(l+u)/i):(i=2*Math.sqrt(1+c-t-o),e[3]=(r-a)/i,e[0]=(h+n)/i,e[1]=(l+u)/i,e[2]=.25*i),e},fromRotationTranslationScale2=function(e,t,s,i){var r=(a=t[0])*(c=a+a),n=a*(u=(l=t[1])+l),a=a*(_=(h=t[2])+h),o=l*u,l=l*_,h=h*_,c=(t=t[3])*c,u=t*u,t=t*_,_=i[0],d=i[1],i=i[2];return e[0]=(1-(o+h))*_,e[1]=(n+t)*_,e[2]=(a-u)*_,e[3]=0,e[4]=(n-t)*d,e[5]=(1-(r+h))*d,e[6]=(l+c)*d,e[7]=0,e[8]=(a+u)*i,e[9]=(l-c)*i,e[10]=(1-(r+o))*i,e[11]=0,e[12]=s[0],e[13]=s[1],e[14]=s[2],e[15]=1,e},fromRotationTranslationScaleOrigin2=function(e,t,s,i,r){var n=(o=t[0])*(u=o+o),a=o*(_=(h=t[1])+h),o=o*(d=(c=t[2])+c),l=h*_,h=h*d,c=c*d,u=(t=t[3])*u,_=t*_,t=t*d,d=i[0],p=i[1],i=i[2],m=r[0],g=r[1],r=r[2],f=(1-(l+c))*d,S=(a+t)*d,d=(o-_)*d,a=(a-t)*p,t=(1-(n+c))*p,c=(h+u)*p,p=(o+_)*i,o=(h-u)*i,_=(1-(n+l))*i;return e[0]=f,e[1]=S,e[2]=d,e[3]=0,e[4]=a,e[5]=t,e[6]=c,e[7]=0,e[8]=p,e[9]=o,e[10]=_,e[11]=0,e[12]=s[0]+m-(f*m+a*g+p*r),e[13]=s[1]+g-(S*m+t*g+o*r),e[14]=s[2]+r-(d*m+c*g+_*r),e[15]=1,e},fromQuat3=function(e,t){var s=t[0],i=t[2],r=i+i,s=s*(h=s+s),n=(a=t[1])*h,a=a*(c=a+a),o=i*h,l=i*c,h=(t=t[3])*h,c=t*c,t=t*r;return e[0]=1-a-(i=i*r),e[1]=n+t,e[2]=o-c,e[3]=0,e[4]=n-t,e[5]=1-s-i,e[6]=l+h,e[7]=0,e[8]=o+c,e[9]=l-h,e[10]=1-s-a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},frustum2=function(e,t,s,i,r,n,a){var o=1/(s-t),l=1/(r-i),h=1/(n-a);return e[0]=2*n*o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*n*l,e[6]=0,e[7]=0,e[8]=(s+t)*o,e[9]=(r+i)*l,e[10]=(a+n)*h,e[11]=-1,e[12]=0,e[13]=0,e[14]=a*n*2*h,e[15]=0,e},perspectiveNO2=function(e,t,s,i,r){return t=1/Math.tan(t/2),e[0]=t/s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=r&&r!==1/0?(e[10]=(r+i)*(s=1/(i-r)),e[14]=2*r*i*s):(e[10]=-1,e[14]=-2*i),e},perspectiveZO2=function(e,t,s,i,r){return t=1/Math.tan(t/2),e[0]=t/s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=r&&r!==1/0?(e[10]=r*(s=1/(i-r)),e[14]=r*i*s):(e[10]=-1,e[14]=-i),e},perspectiveFromFieldOfView2=function(e,t,s,i){var r=Math.tan(t.upDegrees*Math.PI/180),n=Math.tan(t.downDegrees*Math.PI/180),a=Math.tan(t.leftDegrees*Math.PI/180),o=2/(a+(t=Math.tan(t.rightDegrees*Math.PI/180))),l=2/(r+n);return e[0]=o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=l,e[6]=0,e[7]=0,e[8]=-(a-t)*o*.5,e[9]=(r-n)*l*.5,e[10]=i/(s-i),e[11]=-1,e[12]=0,e[13]=0,e[14]=i*s/(s-i),e[15]=0,e},orthoNO2=function(e,t,s,i,r,n,a){var o=1/(t-s),l=1/(i-r),h=1/(n-a);return e[0]=-2*o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*h,e[11]=0,e[12]=(t+s)*o,e[13]=(r+i)*l,e[14]=(a+n)*h,e[15]=1,e},orthoZO2=function(e,t,s,i,r,n,a){var o=1/(t-s),l=1/(i-r),a=1/(n-a);return e[0]=-2*o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=a,e[11]=0,e[12]=(t+s)*o,e[13]=(r+i)*l,e[14]=n*a,e[15]=1,e},lookAt2=function(e,t,s,i){var r,n,a,o,l=t[0],h=t[1],t=t[2],c=i[0],u=i[1],i=i[2],_=s[0],d=s[1],s=s[2];return Math.abs(l-_)<EPSILON&&Math.abs(h-d)<EPSILON&&Math.abs(t-s)<EPSILON?identity$22(e):(_=l-_,d=h-d,s=t-s,r=u*(s*=o=1/Math.hypot(_,d,s))-i*(d*=o),i=i*(_*=o)-c*s,c=c*d-u*_,(o=Math.hypot(r,i,c))?(r*=o=1/o,i*=o,c*=o):c=i=r=0,u=d*c-s*i,n=s*r-_*c,a=_*i-d*r,(o=Math.hypot(u,n,a))?(u*=o=1/o,n*=o,a*=o):a=n=u=0,e[0]=r,e[1]=u,e[2]=_,e[3]=0,e[4]=i,e[5]=n,e[6]=d,e[7]=0,e[8]=c,e[9]=a,e[10]=s,e[11]=0,e[12]=-(r*l+i*h+c*t),e[13]=-(u*l+n*h+a*t),e[14]=-(_*l+d*h+s*t),e[15]=1,e)},targetTo2=function(e,t,s,i){var r=t[0],n=t[1],t=t[2],a=i[0],o=i[1],i=i[2],l=r-s[0],h=n-s[1],c=l*l+h*h+(s=t-s[2])*s,u=(0<c&&(l*=c=1/Math.sqrt(c),h*=c,s*=c),o*s-i*h);return 0<(c=u*u+(i=i*l-a*s)*i+(a=a*h-o*l)*a)&&(u*=c=1/Math.sqrt(c),i*=c,a*=c),e[0]=u,e[1]=i,e[2]=a,e[3]=0,e[4]=h*a-s*i,e[5]=s*u-l*a,e[6]=l*i-h*u,e[7]=0,e[8]=l,e[9]=h,e[10]=s,e[11]=0,e[12]=r,e[13]=n,e[14]=t,e[15]=1,e},str$52=function(e){return"mat4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+", "+e[9]+", "+e[10]+", "+e[11]+", "+e[12]+", "+e[13]+", "+e[14]+", "+e[15]+")"},frob2=function(e){return Math.hypot(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])},add$52=function(e,t,s){return e[0]=t[0]+s[0],e[1]=t[1]+s[1],e[2]=t[2]+s[2],e[3]=t[3]+s[3],e[4]=t[4]+s[4],e[5]=t[5]+s[5],e[6]=t[6]+s[6],e[7]=t[7]+s[7],e[8]=t[8]+s[8],e[9]=t[9]+s[9],e[10]=t[10]+s[10],e[11]=t[11]+s[11],e[12]=t[12]+s[12],e[13]=t[13]+s[13],e[14]=t[14]+s[14],e[15]=t[15]+s[15],e},subtract$32=function(e,t,s){return e[0]=t[0]-s[0],e[1]=t[1]-s[1],e[2]=t[2]-s[2],e[3]=t[3]-s[3],e[4]=t[4]-s[4],e[5]=t[5]-s[5],e[6]=t[6]-s[6],e[7]=t[7]-s[7],e[8]=t[8]-s[8],e[9]=t[9]-s[9],e[10]=t[10]-s[10],e[11]=t[11]-s[11],e[12]=t[12]-s[12],e[13]=t[13]-s[13],e[14]=t[14]-s[14],e[15]=t[15]-s[15],e},multiplyScalar2=function(e,t,s){return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e[3]=t[3]*s,e[4]=t[4]*s,e[5]=t[5]*s,e[6]=t[6]*s,e[7]=t[7]*s,e[8]=t[8]*s,e[9]=t[9]*s,e[10]=t[10]*s,e[11]=t[11]*s,e[12]=t[12]*s,e[13]=t[13]*s,e[14]=t[14]*s,e[15]=t[15]*s,e},multiplyScalarAndAdd2=function(e,t,s,i){return e[0]=t[0]+s[0]*i,e[1]=t[1]+s[1]*i,e[2]=t[2]+s[2]*i,e[3]=t[3]+s[3]*i,e[4]=t[4]+s[4]*i,e[5]=t[5]+s[5]*i,e[6]=t[6]+s[6]*i,e[7]=t[7]+s[7]*i,e[8]=t[8]+s[8]*i,e[9]=t[9]+s[9]*i,e[10]=t[10]+s[10]*i,e[11]=t[11]+s[11]*i,e[12]=t[12]+s[12]*i,e[13]=t[13]+s[13]*i,e[14]=t[14]+s[14]*i,e[15]=t[15]+s[15]*i,e},exactEquals$52=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]},equals$52=function(e,t){var s=e[0],i=e[1],r=e[2],n=e[3],a=e[4],o=e[5],l=e[6],h=e[7],c=e[8],u=e[9],_=e[10],d=e[11],p=e[12],m=e[13],g=e[14],e=e[15],f=t[0],S=t[1],C=t[2],y=t[3],G=t[4],I=t[5],T=t[6],b=t[7],A=t[8],P=t[9],R=t[10],x=t[11],E=t[12],v=t[13],w=t[14],t=t[15];return Math.abs(s-f)<=EPSILON*Math.max(1,Math.abs(s),Math.abs(f))&&Math.abs(i-S)<=EPSILON*Math.max(1,Math.abs(i),Math.abs(S))&&Math.abs(r-C)<=EPSILON*Math.max(1,Math.abs(r),Math.abs(C))&&Math.abs(n-y)<=EPSILON*Math.max(1,Math.abs(n),Math.abs(y))&&Math.abs(a-G)<=EPSILON*Math.max(1,Math.abs(a),Math.abs(G))&&Math.abs(o-I)<=EPSILON*Math.max(1,Math.abs(o),Math.abs(I))&&Math.abs(l-T)<=EPSILON*Math.max(1,Math.abs(l),Math.abs(T))&&Math.abs(h-b)<=EPSILON*Math.max(1,Math.abs(h),Math.abs(b))&&Math.abs(c-A)<=EPSILON*Math.max(1,Math.abs(c),Math.abs(A))&&Math.abs(u-P)<=EPSILON*Math.max(1,Math.abs(u),Math.abs(P))&&Math.abs(_-R)<=EPSILON*Math.max(1,Math.abs(_),Math.abs(R))&&Math.abs(d-x)<=EPSILON*Math.max(1,Math.abs(d),Math.abs(x))&&Math.abs(p-E)<=EPSILON*Math.max(1,Math.abs(p),Math.abs(E))&&Math.abs(m-v)<=EPSILON*Math.max(1,Math.abs(m),Math.abs(v))&&Math.abs(g-w)<=EPSILON*Math.max(1,Math.abs(g),Math.abs(w))&&Math.abs(e-t)<=EPSILON*Math.max(1,Math.abs(e),Math.abs(t))},create$42=function(){var e=new ARRAY_TYPE(3);return ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e},clone$42=function(e){var t=new ARRAY_TYPE(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},length$42=function(e){var t=e[0];return Math.hypot(t,e[1],e[2])},fromValues$42=function(e,t,s){var i=new ARRAY_TYPE(3);return i[0]=e,i[1]=t,i[2]=s,i},copy$42=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},set$42=function(e,t,s,i){return e[0]=t,e[1]=s,e[2]=i,e},add$42=function(e,t,s){return e[0]=t[0]+s[0],e[1]=t[1]+s[1],e[2]=t[2]+s[2],e},subtract$22=function(e,t,s){return e[0]=t[0]-s[0],e[1]=t[1]-s[1],e[2]=t[2]-s[2],e},multiply$42=function(e,t,s){return e[0]=t[0]*s[0],e[1]=t[1]*s[1],e[2]=t[2]*s[2],e},divide$22=function(e,t,s){return e[0]=t[0]/s[0],e[1]=t[1]/s[1],e[2]=t[2]/s[2],e},ceil$22=function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e},floor$22=function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e},min$22=function(e,t,s){return e[0]=Math.min(t[0],s[0]),e[1]=Math.min(t[1],s[1]),e[2]=Math.min(t[2],s[2]),e},max$22=function(e,t,s){return e[0]=Math.max(t[0],s[0]),e[1]=Math.max(t[1],s[1]),e[2]=Math.max(t[2],s[2]),e},round$22=function(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e[2]=Math.round(t[2]),e},scale$42=function(e,t,s){return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e},scaleAndAdd$22=function(e,t,s,i){return e[0]=t[0]+s[0]*i,e[1]=t[1]+s[1]*i,e[2]=t[2]+s[2]*i,e},distance$22=function(e,t){var s=t[0]-e[0];return Math.hypot(s,t[1]-e[1],t[2]-e[2])},squaredDistance$22=function(e,t){var s=t[0]-e[0],i=t[1]-e[1];return s*s+i*i+(t=t[2]-e[2])*t},squaredLength$42=function(e){var t=e[0],s=e[1];return t*t+s*s+(e=e[2])*e},negate$22=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e},inverse$22=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e},normalize$42=function(e,t){var s=t[0],i=t[1],r=t[2];return 0<(s=s*s+i*i+r*r)&&(s=1/Math.sqrt(s)),e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e},dot$42=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},cross$22=function(e,t,s){var i=t[0],r=t[1],t=t[2],n=s[0],a=s[1],s=s[2];return e[0]=r*s-t*a,e[1]=t*n-i*s,e[2]=i*a-r*n,e},lerp$42=function(e,t,s,i){var r=t[0],n=t[1],t=t[2];return e[0]=r+i*(s[0]-r),e[1]=n+i*(s[1]-n),e[2]=t+i*(s[2]-t),e},slerp$12=function(e,t,s,i){var r=Math.acos(Math.min(Math.max(dot$42(t,s),-1),1)),n=Math.sin(r),a=Math.sin((1-i)*r)/n,i=Math.sin(i*r)/n;return e[0]=a*t[0]+i*s[0],e[1]=a*t[1]+i*s[1],e[2]=a*t[2]+i*s[2],e},hermite2=function(e,t,s,i,r,n){var a=n*n,o=a*(2*n-3)+1,l=a*(n-2)+n,h=a*(n-1);return e[0]=t[0]*o+s[0]*l+i[0]*h+r[0]*(a=a*(3-2*n)),e[1]=t[1]*o+s[1]*l+i[1]*h+r[1]*a,e[2]=t[2]*o+s[2]*l+i[2]*h+r[2]*a,e},bezier2=function(e,t,s,i,r,n){var a=1-n,o=a*a,l=n*n,h=o*a;return e[0]=t[0]*h+s[0]*(o=3*n*o)+i[0]*(a=3*l*a)+r[0]*(l=l*n),e[1]=t[1]*h+s[1]*o+i[1]*a+r[1]*l,e[2]=t[2]*h+s[2]*o+i[2]*a+r[2]*l,e},random$32=function(e,t){t=t||1;var s=2*RANDOM()*Math.PI,i=2*RANDOM()-1,r=Math.sqrt(1-i*i)*t;return e[0]=Math.cos(s)*r,e[1]=Math.sin(s)*r,e[2]=i*t,e},transformMat4$22=function(e,t,s){var i=t[0],r=t[1],t=t[2],n=s[3]*i+s[7]*r+s[11]*t+s[15];return e[0]=(s[0]*i+s[4]*r+s[8]*t+s[12])/(n=n||1),e[1]=(s[1]*i+s[5]*r+s[9]*t+s[13])/n,e[2]=(s[2]*i+s[6]*r+s[10]*t+s[14])/n,e},transformMat3$12=function(e,t,s){var i=t[0],r=t[1],t=t[2];return e[0]=i*s[0]+r*s[3]+t*s[6],e[1]=i*s[1]+r*s[4]+t*s[7],e[2]=i*s[2]+r*s[5]+t*s[8],e},transformQuat$12=function(e,t,s){var i=s[0],r=s[1],n=t[0],a=t[1],o=r*(t=t[2])-(u=s[2])*a,l=u*n-i*t,h=i*a-r*n,c=r*h-u*l,u=u*o-i*h,i=i*l-r*o;return l*=r=2*s[3],h*=r,u*=2,i*=2,e[0]=n+(o*=r)+(c*=2),e[1]=a+l+u,e[2]=t+h+i,e},rotateX$22=function(e,t,s,i){var r=[],n=[];return r[0]=t[0]-s[0],r[1]=t[1]-s[1],r[2]=t[2]-s[2],n[0]=r[0],n[1]=r[1]*Math.cos(i)-r[2]*Math.sin(i),n[2]=r[1]*Math.sin(i)+r[2]*Math.cos(i),e[0]=n[0]+s[0],e[1]=n[1]+s[1],e[2]=n[2]+s[2],e},rotateY$22=function(e,t,s,i){var r=[],n=[];return r[0]=t[0]-s[0],r[1]=t[1]-s[1],r[2]=t[2]-s[2],n[0]=r[2]*Math.sin(i)+r[0]*Math.cos(i),n[1]=r[1],n[2]=r[2]*Math.cos(i)-r[0]*Math.sin(i),e[0]=n[0]+s[0],e[1]=n[1]+s[1],e[2]=n[2]+s[2],e},rotateZ$22=function(e,t,s,i){var r=[],n=[];return r[0]=t[0]-s[0],r[1]=t[1]-s[1],r[2]=t[2]-s[2],n[0]=r[0]*Math.cos(i)-r[1]*Math.sin(i),n[1]=r[0]*Math.sin(i)+r[1]*Math.cos(i),n[2]=r[2],e[0]=n[0]+s[0],e[1]=n[1]+s[1],e[2]=n[2]+s[2],e},angle$12=function(e,t){var s=e[0],i=e[1],r=e[2],n=t[0],a=t[1],o=t[2],i=(s=Math.sqrt((s*s+i*i+r*r)*(n*n+a*a+o*o)))&&dot$42(e,t)/s;return Math.acos(Math.min(Math.max(i,-1),1))},zero$22=function(e){return e[0]=0,e[1]=0,e[2]=0,e},str$42=function(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"},exactEquals$42=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]},equals$42=function(e,t){var s=e[0],i=e[1],e=e[2],r=t[0],n=t[1],t=t[2];return Math.abs(s-r)<=EPSILON*Math.max(1,Math.abs(s),Math.abs(r))&&Math.abs(i-n)<=EPSILON*Math.max(1,Math.abs(i),Math.abs(n))&&Math.abs(e-t)<=EPSILON*Math.max(1,Math.abs(e),Math.abs(t))},create$32=function(){var e=new ARRAY_TYPE(4);return ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e},clone$32=function(e){var t=new ARRAY_TYPE(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},fromValues$32=function(e,t,s,i){var r=new ARRAY_TYPE(4);return r[0]=e,r[1]=t,r[2]=s,r[3]=i,r},copy$32=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},set$32=function(e,t,s,i,r){return e[0]=t,e[1]=s,e[2]=i,e[3]=r,e},add$32=function(e,t,s){return e[0]=t[0]+s[0],e[1]=t[1]+s[1],e[2]=t[2]+s[2],e[3]=t[3]+s[3],e},subtract$12=function(e,t,s){return e[0]=t[0]-s[0],e[1]=t[1]-s[1],e[2]=t[2]-s[2],e[3]=t[3]-s[3],e},multiply$32=function(e,t,s){return e[0]=t[0]*s[0],e[1]=t[1]*s[1],e[2]=t[2]*s[2],e[3]=t[3]*s[3],e},divide$12=function(e,t,s){return e[0]=t[0]/s[0],e[1]=t[1]/s[1],e[2]=t[2]/s[2],e[3]=t[3]/s[3],e},ceil$12=function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e[3]=Math.ceil(t[3]),e},floor$12=function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e[3]=Math.floor(t[3]),e},min$12=function(e,t,s){return e[0]=Math.min(t[0],s[0]),e[1]=Math.min(t[1],s[1]),e[2]=Math.min(t[2],s[2]),e[3]=Math.min(t[3],s[3]),e},max$12=function(e,t,s){return e[0]=Math.max(t[0],s[0]),e[1]=Math.max(t[1],s[1]),e[2]=Math.max(t[2],s[2]),e[3]=Math.max(t[3],s[3]),e},round$12=function(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e[2]=Math.round(t[2]),e[3]=Math.round(t[3]),e},scale$32=function(e,t,s){return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e[3]=t[3]*s,e},scaleAndAdd$12=function(e,t,s,i){return e[0]=t[0]+s[0]*i,e[1]=t[1]+s[1]*i,e[2]=t[2]+s[2]*i,e[3]=t[3]+s[3]*i,e},distance$12=function(e,t){var s=t[0]-e[0];return Math.hypot(s,t[1]-e[1],t[2]-e[2],t[3]-e[3])},squaredDistance$12=function(e,t){var s=t[0]-e[0],i=t[1]-e[1],r=t[2]-e[2];return s*s+i*i+r*r+(t=t[3]-e[3])*t},length$32=function(e){var t=e[0];return Math.hypot(t,e[1],e[2],e[3])},squaredLength$32=function(e){var t=e[0],s=e[1],i=e[2];return t*t+s*s+i*i+(e=e[3])*e},negate$12=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=-t[3],e},inverse$12=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e[3]=1/t[3],e},normalize$32=function(e,t){var s=t[0],i=t[1],r=t[2],n=s*s+i*i+r*r+(t=t[3])*t;return 0<n&&(n=1/Math.sqrt(n)),e[0]=s*n,e[1]=i*n,e[2]=r*n,e[3]=t*n,e},dot$32=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},cross$12=function(e,t,s,i){var r=s[0]*i[1]-s[1]*i[0],n=s[0]*i[2]-s[2]*i[0],a=s[0]*i[3]-s[3]*i[0],o=s[1]*i[2]-s[2]*i[1],l=s[1]*i[3]-s[3]*i[1],s=s[2]*i[3]-s[3]*i[2],i=t[0],h=t[1],c=t[2],t=t[3];return e[0]=h*s-c*l+t*o,e[1]=-i*s+c*a-t*n,e[2]=i*l-h*a+t*r,e[3]=-i*o+h*n-c*r,e},lerp$32=function(e,t,s,i){var r=t[0],n=t[1],a=t[2],t=t[3];return e[0]=r+i*(s[0]-r),e[1]=n+i*(s[1]-n),e[2]=a+i*(s[2]-a),e[3]=t+i*(s[3]-t),e},random$22=function(e,t){var s,i,r,n,a,o;for(t=t||1;1<=(a=(s=2*RANDOM()-1)*s+(i=2*RANDOM()-1)*i););for(;1<=(o=(r=2*RANDOM()-1)*r+(n=2*RANDOM()-1)*n););var l=Math.sqrt((1-a)/o);return e[0]=t*s,e[1]=t*i,e[2]=t*r*l,e[3]=t*n*l,e},transformMat4$12=function(e,t,s){var i=t[0],r=t[1],n=t[2],t=t[3];return e[0]=s[0]*i+s[4]*r+s[8]*n+s[12]*t,e[1]=s[1]*i+s[5]*r+s[9]*n+s[13]*t,e[2]=s[2]*i+s[6]*r+s[10]*n+s[14]*t,e[3]=s[3]*i+s[7]*r+s[11]*n+s[15]*t,e},transformQuat2=function(e,t,s){var i=t[0],r=t[1],n=t[2],a=s[0],o=s[1],l=s[2],h=(s=s[3])*i+o*n-l*r,c=s*r+l*i-a*n,u=s*n+a*r-o*i;return e[0]=h*s+(i=-a*i-o*r-l*n)*-a+c*-l-u*-o,e[1]=c*s+i*-o+u*-a-h*-l,e[2]=u*s+i*-l+h*-o-c*-a,e[3]=t[3],e},zero$12=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e},str$32=function(e){return"vec4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},exactEquals$32=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]},equals$32=function(e,t){var s=e[0],i=e[1],r=e[2],e=e[3],n=t[0],a=t[1],o=t[2],t=t[3];return Math.abs(s-n)<=EPSILON*Math.max(1,Math.abs(s),Math.abs(n))&&Math.abs(i-a)<=EPSILON*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(r-o)<=EPSILON*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(e-t)<=EPSILON*Math.max(1,Math.abs(e),Math.abs(t))},create$22=function(){var e=new ARRAY_TYPE(4);return ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e},identity$12=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},setAxisAngle2=function(e,t,s){s*=.5;var i=Math.sin(s);return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=Math.cos(s),e},getAxisAngle2=function(e,t){var s=2*Math.acos(t[3]),i=Math.sin(s/2);return EPSILON<i?(e[0]=t[0]/i,e[1]=t[1]/i,e[2]=t[2]/i):(e[0]=1,e[1]=0,e[2]=0),s},getAngle2=function(e,t){return e=dot$2(e,t),Math.acos(2*e*e-1)},multiply$22=function(e,t,s){var i=t[0],r=t[1],n=t[2],t=t[3],a=s[0],o=s[1],l=s[2],s=s[3];return e[0]=i*s+t*a+r*l-n*o,e[1]=r*s+t*o+n*a-i*l,e[2]=n*s+t*l+i*o-r*a,e[3]=t*s-i*a-r*o-n*l,e},rotateX$12=function(e,t,s){s*=.5;var i=t[0],r=t[1],n=t[2],t=t[3],a=Math.sin(s),s=Math.cos(s);return e[0]=i*s+t*a,e[1]=r*s+n*a,e[2]=n*s-r*a,e[3]=t*s-i*a,e},rotateY$12=function(e,t,s){s*=.5;var i=t[0],r=t[1],n=t[2],t=t[3],a=Math.sin(s),s=Math.cos(s);return e[0]=i*s-n*a,e[1]=r*s+t*a,e[2]=n*s+i*a,e[3]=t*s-r*a,e},rotateZ$12=function(e,t,s){s*=.5;var i=t[0],r=t[1],n=t[2],t=t[3],a=Math.sin(s),s=Math.cos(s);return e[0]=i*s+r*a,e[1]=r*s-i*a,e[2]=n*s+t*a,e[3]=t*s-n*a,e},calculateW2=function(e,t){var s=t[0],i=t[1],t=t[2];return e[0]=s,e[1]=i,e[2]=t,e[3]=Math.sqrt(Math.abs(1-s*s-i*i-t*t)),e},exp2=function(e,t){var s=t[0],i=t[1],r=t[2],t=t[3],n=Math.sqrt(s*s+i*i+r*r),t=Math.exp(t),a=0<n?t*Math.sin(n)/n:0;return e[0]=s*a,e[1]=i*a,e[2]=r*a,e[3]=t*Math.cos(n),e},ln2=function(e,t){var s=t[0],i=t[1],r=t[2],t=t[3],n=0<(n=Math.sqrt(s*s+i*i+r*r))?Math.atan2(n,t)/n:0;return e[0]=s*n,e[1]=i*n,e[2]=r*n,e[3]=.5*Math.log(s*s+i*i+r*r+t*t),e},pow2=function(e,t,s){return ln2(e,t),scale$2(e,e,s),exp2(e,e),e},slerp2=function(e,t,s,i){var r,n,a=t[0],o=t[1],l=t[2],t=t[3],h=s[0],c=s[1],u=s[2],_=a*h+o*c+l*u+t*(s=s[3]);return _<0&&(_=-_,h=-h,c=-c,u=-u,s=-s),_=EPSILON<1-_?(_=Math.acos(_),r=Math.sin(_),n=Math.sin((1-i)*_)/r,Math.sin(i*_)/r):(n=1-i,i),e[0]=n*a+_*h,e[1]=n*o+_*c,e[2]=n*l+_*u,e[3]=n*t+_*s,e},random$12=function(e){var t=RANDOM(),s=RANDOM(),i=RANDOM(),r=Math.sqrt(1-t),t=Math.sqrt(t);return e[0]=r*Math.sin(2*Math.PI*s),e[1]=r*Math.cos(2*Math.PI*s),e[2]=t*Math.sin(2*Math.PI*i),e[3]=t*Math.cos(2*Math.PI*i),e},invert$12=function(e,t){var s=t[0],i=t[1],r=t[2],n=s*s+i*i+r*r+(t=t[3])*t;return e[0]=-s*(n=n?1/n:0),e[1]=-i*n,e[2]=-r*n,e[3]=t*n,e},conjugate$12=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},fromMat32=function(e,t){var s,i,r,n=t[0]+t[4]+t[8];return 0<n?(r=Math.sqrt(n+1),e[3]=.5*r,e[0]=(t[5]-t[7])*(r=.5/r),e[1]=(t[6]-t[2])*r,e[2]=(t[1]-t[3])*r):(s=(1+(n=t[3*(n=t[4]>t[0]?1:0)+n]<t[8]?2:n))%3,i=(2+n)%3,r=Math.sqrt(t[3*n+n]-t[3*s+s]-t[3*i+i]+1),e[n]=.5*r,e[3]=(t[3*s+i]-t[3*i+s])*(r=.5/r),e[s]=(t[3*s+n]+t[3*n+s])*r,e[i]=(t[3*i+n]+t[3*n+i])*r),e},fromEuler2=function(e,t,s,i){var r=4<arguments.length&&void 0!==arguments[4]?arguments[4]:ANGLE_ORDER,n=Math.PI/360,a=(i*=n,s*=n,Math.sin(t*=n)),o=Math.cos(t),l=Math.sin(s),h=Math.cos(s),c=Math.sin(i),u=Math.cos(i);switch(r){case"xyz":e[0]=a*h*u+o*l*c,e[1]=o*l*u-a*h*c,e[2]=o*h*c+a*l*u,e[3]=o*h*u-a*l*c;break;case"xzy":e[0]=a*h*u-o*l*c,e[1]=o*l*u-a*h*c,e[2]=o*h*c+a*l*u,e[3]=o*h*u+a*l*c;break;case"yxz":e[0]=a*h*u+o*l*c,e[1]=o*l*u-a*h*c,e[2]=o*h*c-a*l*u,e[3]=o*h*u+a*l*c;break;case"yzx":e[0]=a*h*u+o*l*c,e[1]=o*l*u+a*h*c,e[2]=o*h*c-a*l*u,e[3]=o*h*u-a*l*c;break;case"zxy":e[0]=a*h*u-o*l*c,e[1]=o*l*u+a*h*c,e[2]=o*h*c+a*l*u,e[3]=o*h*u-a*l*c;break;case"zyx":e[0]=a*h*u-o*l*c,e[1]=o*l*u+a*h*c,e[2]=o*h*c-a*l*u,e[3]=o*h*u+a*l*c;break;default:throw new Error("Unknown angle order "+r)}return e},str$22=function(e){return"quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},equals$22=function(e,t){return Math.abs(dot$32(e,t))>=1-EPSILON},create$12=function(){var e=new ARRAY_TYPE(8);return ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[4]=0,e[5]=0,e[6]=0,e[7]=0),e[3]=1,e},clone$12=function(e){var t=new ARRAY_TYPE(8);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t},fromValues$12=function(e,t,s,i,r,n,a,o){var l=new ARRAY_TYPE(8);return l[0]=e,l[1]=t,l[2]=s,l[3]=i,l[4]=r,l[5]=n,l[6]=a,l[7]=o,l},fromRotationTranslationValues2=function(e,t,s,i,r,n,a){var o=new ARRAY_TYPE(8),r=(o[0]=e,o[1]=t,o[2]=s,o[3]=i,.5*r),n=.5*n,a=.5*a;return o[4]=r*i+n*s-a*t,o[5]=n*i+a*e-r*s,o[6]=a*i+r*t-n*e,o[7]=-r*e-n*t-a*s,o},fromRotationTranslation2=function(e,t,s){var i=.5*s[0],r=.5*s[1],s=.5*s[2],n=t[0],a=t[1],o=t[2],t=t[3];return e[0]=n,e[1]=a,e[2]=o,e[3]=t,e[4]=i*t+r*o-s*a,e[5]=r*t+s*n-i*o,e[6]=s*t+i*a-r*n,e[7]=-i*n-r*a-s*o,e},fromTranslation2=function(e,t){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e[4]=.5*t[0],e[5]=.5*t[1],e[6]=.5*t[2],e[7]=0,e},fromRotation2=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=0,e[5]=0,e[6]=0,e[7]=0,e},fromMat42=function(e,t){var s=create$22(),i=(getRotation2(s,t),new ARRAY_TYPE(3));return getTranslation$12(i,t),fromRotationTranslation2(e,s,i),e},copy$12=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e},identity2=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e[6]=0,e[7]=0,e},set$12=function(e,t,s,i,r,n,a,o,l){return e[0]=t,e[1]=s,e[2]=i,e[3]=r,e[4]=n,e[5]=a,e[6]=o,e[7]=l,e},getDual2=function(e,t){return e[0]=t[4],e[1]=t[5],e[2]=t[6],e[3]=t[7],e},setDual2=function(e,t){return e[4]=t[0],e[5]=t[1],e[6]=t[2],e[7]=t[3],e},getTranslation2=function(e,t){var s=t[4],i=t[5],r=t[6],n=t[7],a=-t[0],o=-t[1],l=-t[2],t=t[3];return e[0]=2*(s*t+n*a+i*l-r*o),e[1]=2*(i*t+n*o+r*a-s*l),e[2]=2*(r*t+n*l+s*o-i*a),e},translate2=function(e,t,s){var i=t[0],r=t[1],n=t[2],a=t[3],o=.5*s[0],l=.5*s[1],s=.5*s[2],h=t[4],c=t[5],u=t[6],t=t[7];return e[0]=i,e[1]=r,e[2]=n,e[3]=a,e[4]=a*o+r*s-n*l+h,e[5]=a*l+n*o-i*s+c,e[6]=a*s+i*l-r*o+u,e[7]=-i*o-r*l-n*s+t,e},rotateX2=function(e,t,s){var i=-t[0],r=-t[1],n=-t[2],a=t[3],o=t[4],l=t[5],h=t[6],c=o*a+(d=t[7])*i+l*n-h*r,u=l*a+d*r+h*i-o*n,_=h*a+d*n+o*r-l*i,d=d*a-o*i-l*r-h*n;return rotateX$12(e,t,s),i=e[0],e[4]=c*(a=e[3])+d*i+u*(n=e[2])-_*(r=e[1]),e[5]=u*a+d*r+_*i-c*n,e[6]=_*a+d*n+c*r-u*i,e[7]=d*a-c*i-u*r-_*n,e},rotateY2=function(e,t,s){var i=-t[0],r=-t[1],n=-t[2],a=t[3],o=t[4],l=t[5],h=t[6],c=o*a+(d=t[7])*i+l*n-h*r,u=l*a+d*r+h*i-o*n,_=h*a+d*n+o*r-l*i,d=d*a-o*i-l*r-h*n;return rotateY$12(e,t,s),i=e[0],e[4]=c*(a=e[3])+d*i+u*(n=e[2])-_*(r=e[1]),e[5]=u*a+d*r+_*i-c*n,e[6]=_*a+d*n+c*r-u*i,e[7]=d*a-c*i-u*r-_*n,e},rotateZ2=function(e,t,s){var i=-t[0],r=-t[1],n=-t[2],a=t[3],o=t[4],l=t[5],h=t[6],c=o*a+(d=t[7])*i+l*n-h*r,u=l*a+d*r+h*i-o*n,_=h*a+d*n+o*r-l*i,d=d*a-o*i-l*r-h*n;return rotateZ$12(e,t,s),i=e[0],e[4]=c*(a=e[3])+d*i+u*(n=e[2])-_*(r=e[1]),e[5]=u*a+d*r+_*i-c*n,e[6]=_*a+d*n+c*r-u*i,e[7]=d*a-c*i-u*r-_*n,e},rotateByQuatAppend2=function(e,t,s){var i=s[0],r=s[1],n=s[2],s=s[3],a=t[0],o=t[1],l=t[2],h=t[3];return e[0]=a*s+h*i+o*n-l*r,e[1]=o*s+h*r+l*i-a*n,e[2]=l*s+h*n+a*r-o*i,e[3]=h*s-a*i-o*r-l*n,e[4]=(a=t[4])*s+(h=t[7])*i+(o=t[5])*n-(l=t[6])*r,e[5]=o*s+h*r+l*i-a*n,e[6]=l*s+h*n+a*r-o*i,e[7]=h*s-a*i-o*r-l*n,e},rotateByQuatPrepend2=function(e,t,s){var i=t[0],r=t[1],n=t[2],t=t[3],a=s[0],o=s[1],l=s[2],h=s[3];return e[0]=i*h+t*a+r*l-n*o,e[1]=r*h+t*o+n*a-i*l,e[2]=n*h+t*l+i*o-r*a,e[3]=t*h-i*a-r*o-n*l,e[4]=i*(h=s[7])+t*(a=s[4])+r*(l=s[6])-n*(o=s[5]),e[5]=r*h+t*o+n*a-i*l,e[6]=n*h+t*l+i*o-r*a,e[7]=t*h-i*a-r*o-n*l,e},rotateAroundAxis2=function(e,t,s,i){var r,n,a,o,l,h;return Math.abs(i)<EPSILON?copy$12(e,t):(h=Math.hypot(s[0],s[1],s[2]),i*=.5,r=(a=Math.sin(i))*s[0]/h,n=a*s[1]/h,a=a*s[2]/h,s=Math.cos(i),h=t[0],e[0]=h*s+(i=t[3])*r+(o=t[1])*a-(l=t[2])*n,e[1]=o*s+i*n+l*r-h*a,e[2]=l*s+i*a+h*n-o*r,e[3]=i*s-h*r-o*n-l*a,e[4]=(i=t[4])*s+(h=t[7])*r+(o=t[5])*a-(l=t[6])*n,e[5]=o*s+h*n+l*r-i*a,e[6]=l*s+h*a+i*n-o*r,e[7]=h*s-i*r-o*n-l*a,e)},add$12=function(e,t,s){return e[0]=t[0]+s[0],e[1]=t[1]+s[1],e[2]=t[2]+s[2],e[3]=t[3]+s[3],e[4]=t[4]+s[4],e[5]=t[5]+s[5],e[6]=t[6]+s[6],e[7]=t[7]+s[7],e},multiply$12=function(e,t,s){var i=t[0],r=t[1],n=t[2],a=t[3],o=s[4],l=s[5],h=s[6],c=s[7],u=t[4],_=t[5],d=t[6],t=t[7],p=s[0],m=s[1],g=s[2],s=s[3];return e[0]=i*s+a*p+r*g-n*m,e[1]=r*s+a*m+n*p-i*g,e[2]=n*s+a*g+i*m-r*p,e[3]=a*s-i*p-r*m-n*g,e[4]=i*c+a*o+r*h-n*l+u*s+t*p+_*g-d*m,e[5]=r*c+a*l+n*o-i*h+_*s+t*m+d*p-u*g,e[6]=n*c+a*h+i*l-r*o+d*s+t*g+u*m-_*p,e[7]=a*c-i*o-r*l-n*h+t*s-u*p-_*m-d*g,e},scale$12=function(e,t,s){return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e[3]=t[3]*s,e[4]=t[4]*s,e[5]=t[5]*s,e[6]=t[6]*s,e[7]=t[7]*s,e},lerp$12=function(e,t,s,i){var r=1-i;return dot$1(t,s)<0&&(i=-i),e[0]=t[0]*r+s[0]*i,e[1]=t[1]*r+s[1]*i,e[2]=t[2]*r+s[2]*i,e[3]=t[3]*r+s[3]*i,e[4]=t[4]*r+s[4]*i,e[5]=t[5]*r+s[5]*i,e[6]=t[6]*r+s[6]*i,e[7]=t[7]*r+s[7]*i,e},invert2=function(e,t){var s=squaredLength$1(t);return e[0]=-t[0]/s,e[1]=-t[1]/s,e[2]=-t[2]/s,e[3]=t[3]/s,e[4]=-t[4]/s,e[5]=-t[5]/s,e[6]=-t[6]/s,e[7]=t[7]/s,e},conjugate2=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e[4]=-t[4],e[5]=-t[5],e[6]=-t[6],e[7]=t[7],e},normalize$12=function(e,t){var s,i,r,n,a,o,l,h,c=squaredLength$1(t);return 0<c&&(c=Math.sqrt(c),h=(s=t[0]/c)*(a=t[4])+(i=t[1]/c)*(o=t[5])+(r=t[2]/c)*(l=t[6])+(n=t[3]/c)*(t=t[7]),e[0]=s,e[1]=i,e[2]=r,e[3]=n,e[4]=(a-s*h)/c,e[5]=(o-i*h)/c,e[6]=(l-r*h)/c,e[7]=(t-n*h)/c),e},str$12=function(e){return"quat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+")"},exactEquals$12=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]},equals$12=function(e,t){var s=e[0],i=e[1],r=e[2],n=e[3],a=e[4],o=e[5],l=e[6],e=e[7],h=t[0],c=t[1],u=t[2],_=t[3],d=t[4],p=t[5],m=t[6],t=t[7];return Math.abs(s-h)<=EPSILON*Math.max(1,Math.abs(s),Math.abs(h))&&Math.abs(i-c)<=EPSILON*Math.max(1,Math.abs(i),Math.abs(c))&&Math.abs(r-u)<=EPSILON*Math.max(1,Math.abs(r),Math.abs(u))&&Math.abs(n-_)<=EPSILON*Math.max(1,Math.abs(n),Math.abs(_))&&Math.abs(a-d)<=EPSILON*Math.max(1,Math.abs(a),Math.abs(d))&&Math.abs(o-p)<=EPSILON*Math.max(1,Math.abs(o),Math.abs(p))&&Math.abs(l-m)<=EPSILON*Math.max(1,Math.abs(l),Math.abs(m))&&Math.abs(e-t)<=EPSILON*Math.max(1,Math.abs(e),Math.abs(t))},create2=function(){var e=new ARRAY_TYPE(2);return ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0),e},clone2=function(e){var t=new ARRAY_TYPE(2);return t[0]=e[0],t[1]=e[1],t},fromValues2=function(e,t){var s=new ARRAY_TYPE(2);return s[0]=e,s[1]=t,s},copy2=function(e,t){return e[0]=t[0],e[1]=t[1],e},set2=function(e,t,s){return e[0]=t,e[1]=s,e},add2=function(e,t,s){return e[0]=t[0]+s[0],e[1]=t[1]+s[1],e},subtract2=function(e,t,s){return e[0]=t[0]-s[0],e[1]=t[1]-s[1],e},multiply2=function(e,t,s){return e[0]=t[0]*s[0],e[1]=t[1]*s[1],e},divide2=function(e,t,s){return e[0]=t[0]/s[0],e[1]=t[1]/s[1],e},ceil2=function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e},floor2=function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e},min2=function(e,t,s){return e[0]=Math.min(t[0],s[0]),e[1]=Math.min(t[1],s[1]),e},max2=function(e,t,s){return e[0]=Math.max(t[0],s[0]),e[1]=Math.max(t[1],s[1]),e},round2=function(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e},scale2=function(e,t,s){return e[0]=t[0]*s,e[1]=t[1]*s,e},scaleAndAdd2=function(e,t,s,i){return e[0]=t[0]+s[0]*i,e[1]=t[1]+s[1]*i,e},distance2=function(e,t){var s=t[0]-e[0];return Math.hypot(s,t[1]-e[1])},squaredDistance2=function(e,t){var s=t[0]-e[0];return s*s+(t=t[1]-e[1])*t},length2=function(e){var t=e[0];return Math.hypot(t,e[1])},squaredLength2=function(e){var t=e[0];return t*t+(e=e[1])*e},negate2=function(e,t){return e[0]=-t[0],e[1]=-t[1],e},inverse2=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e},normalize2=function(e,t){var s=t[0],i=t[1];return 0<(s=s*s+i*i)&&(s=1/Math.sqrt(s)),e[0]=t[0]*s,e[1]=t[1]*s,e},dot2=function(e,t){return e[0]*t[0]+e[1]*t[1]},cross2=function(e,t,s){return t=t[0]*s[1]-t[1]*s[0],e[0]=e[1]=0,e[2]=t,e},lerp2=function(e,t,s,i){var r=t[0],t=t[1];return e[0]=r+i*(s[0]-r),e[1]=t+i*(s[1]-t),e},random2=function(e,t){t=t||1;var s=2*RANDOM()*Math.PI;return e[0]=Math.cos(s)*t,e[1]=Math.sin(s)*t,e},transformMat22=function(e,t,s){var i=t[0],t=t[1];return e[0]=s[0]*i+s[2]*t,e[1]=s[1]*i+s[3]*t,e},transformMat2d2=function(e,t,s){var i=t[0],t=t[1];return e[0]=s[0]*i+s[2]*t+s[4],e[1]=s[1]*i+s[3]*t+s[5],e},transformMat32=function(e,t,s){var i=t[0],t=t[1];return e[0]=s[0]*i+s[3]*t+s[6],e[1]=s[1]*i+s[4]*t+s[7],e},transformMat42=function(e,t,s){var i=t[0],t=t[1];return e[0]=s[0]*i+s[4]*t+s[12],e[1]=s[1]*i+s[5]*t+s[13],e},rotate2=function(e,t,s,i){var r=t[0]-s[0],t=t[1]-s[1],n=Math.sin(i),i=Math.cos(i);return e[0]=r*i-t*n+s[0],e[1]=r*n+t*i+s[1],e},angle2=function(e,t){var s=e[0],e=e[1],i=t[0],t=t[1],r=Math.sqrt((s*s+e*e)*(i*i+t*t));return Math.acos(Math.min(Math.max(r&&(s*i+e*t)/r,-1),1))},zero2=function(e){return e[0]=0,e[1]=0,e},str2=function(e){return"vec2("+e[0]+", "+e[1]+")"},exactEquals2=function(e,t){return e[0]===t[0]&&e[1]===t[1]},equals2=function(e,t){var s=e[0],e=e[1],i=t[0],t=t[1];return Math.abs(s-i)<=EPSILON*Math.max(1,Math.abs(s),Math.abs(i))&&Math.abs(e-t)<=EPSILON*Math.max(1,Math.abs(e),Math.abs(t))};setMatrixArrayType=setMatrixArrayType2,toRadian=toRadian2,equals$9=equals$92,create$8=create$82,clone$8=clone$82,copy$8=copy$82,identity$5=identity$52,fromValues$8=fromValues$82,set$8=set$82,transpose$2=transpose$22,invert$5=invert$52,adjoint$2=adjoint$22,determinant$3=determinant$32,multiply$8=multiply$82,rotate$4=rotate$42,scale$8=scale$82,fromRotation$4=fromRotation$42,fromScaling$3=fromScaling$32,str$8=str$82,frob$3=frob$32,LDU=LDU2,add$8=add$82,subtract$6=subtract$62,exactEquals$8=exactEquals$82,equals$8=equals$82,multiplyScalar$3=multiplyScalar$32,multiplyScalarAndAdd$3=multiplyScalarAndAdd$32,create$7=create$72,clone$7=clone$72,copy$7=copy$72,identity$4=identity$42,fromValues$7=fromValues$72,set$7=set$72,invert$4=invert$42,determinant$2=determinant$22,multiply$7=multiply$72,rotate$3=rotate$32,scale$7=scale$72,translate$3=translate$32,fromRotation$3=fromRotation$32,fromScaling$2=fromScaling$22,fromTranslation$3=fromTranslation$32,str$7=str$72,frob$2=frob$22,add$7=add$72,subtract$5=subtract$52,multiplyScalar$2=multiplyScalar$22,multiplyScalarAndAdd$2=multiplyScalarAndAdd$22,exactEquals$7=exactEquals$72,equals$7=equals$72,create$6=create$62,fromMat4$1=fromMat4$12,clone$6=clone$62,copy$6=copy$62,fromValues$6=fromValues$62,set$6=set$62,identity$3=identity$32,transpose$1=transpose$12,invert$3=invert$32,adjoint$1=adjoint$12,determinant$1=determinant$12,multiply$6=multiply$62,translate$2=translate$22,rotate$2=rotate$22,scale$6=scale$62,fromTranslation$2=fromTranslation$22,fromRotation$2=fromRotation$22,fromScaling$1=fromScaling$12,fromMat2d=fromMat2d2,fromQuat$1=fromQuat$12,normalFromMat4=normalFromMat42,projection=projection2,str$6=str$62,frob$1=frob$12,add$6=add$62,subtract$4=subtract$42,multiplyScalar$1=multiplyScalar$12,multiplyScalarAndAdd$1=multiplyScalarAndAdd$12,exactEquals$6=exactEquals$62,equals$6=equals$62,create$5=create$52,clone$5=clone$52,copy$5=copy$52,fromValues$5=fromValues$52,set$5=set$52,identity$2=identity$22,transpose=transpose2,invert$2=invert$22,adjoint=adjoint2,determinant=determinant2,multiply$5=multiply$52,translate$1=translate$12,scale$5=scale$52,rotate$1=rotate$12,rotateX$3=rotateX$32,rotateY$3=rotateY$32,rotateZ$3=rotateZ$32,fromTranslation$1=fromTranslation$12,fromScaling=fromScaling2,fromRotation$1=fromRotation$12,fromXRotation=fromXRotation2,fromYRotation=fromYRotation2,fromZRotation=fromZRotation2,fromRotationTranslation$1=fromRotationTranslation$12,fromQuat2=fromQuat22,getTranslation$1=getTranslation$12,getScaling=getScaling2,getRotation=getRotation2,decompose=decompose2,fromRotationTranslationScale=fromRotationTranslationScale2,fromRotationTranslationScaleOrigin=fromRotationTranslationScaleOrigin2,fromQuat=fromQuat3,frustum=frustum2,perspectiveNO=perspectiveNO2,perspectiveZO=perspectiveZO2,perspectiveFromFieldOfView=perspectiveFromFieldOfView2,orthoNO=orthoNO2,orthoZO=orthoZO2,lookAt=lookAt2,targetTo=targetTo2,str$5=str$52,frob=frob2,add$5=add$52,subtract$3=subtract$32,multiplyScalar=multiplyScalar2,multiplyScalarAndAdd=multiplyScalarAndAdd2,exactEquals$5=exactEquals$52,equals$5=equals$52,create$4=create$42,clone$4=clone$42,length$4=length$42,fromValues$4=fromValues$42,copy$4=copy$42,set$4=set$42,add$4=add$42,subtract$2=subtract$22,multiply$4=multiply$42,divide$2=divide$22,ceil$2=ceil$22,floor$2=floor$22,min$2=min$22,max$2=max$22,round$2=round$22,scale$4=scale$42,scaleAndAdd$2=scaleAndAdd$22,distance$2=distance$22,squaredDistance$2=squaredDistance$22,squaredLength$4=squaredLength$42,negate$2=negate$22,inverse$2=inverse$22,normalize$4=normalize$42,dot$4=dot$42,cross$2=cross$22,lerp$4=lerp$42,slerp$1=slerp$12,hermite=hermite2,bezier=bezier2,random$3=random$32,transformMat4$2=transformMat4$22,transformMat3$1=transformMat3$12,transformQuat$1=transformQuat$12,rotateX$2=rotateX$22,rotateY$2=rotateY$22,rotateZ$2=rotateZ$22,angle$1=angle$12,zero$2=zero$22,str$4=str$42,exactEquals$4=exactEquals$42,equals$4=equals$42,create$3=create$32,clone$3=clone$32,fromValues$3=fromValues$32,copy$3=copy$32,set$3=set$32,add$3=add$32,subtract$1=subtract$12,multiply$3=multiply$32,divide$1=divide$12,ceil$1=ceil$12,floor$1=floor$12,min$1=min$12,max$1=max$12,round$1=round$12,scale$3=scale$32,scaleAndAdd$1=scaleAndAdd$12,distance$1=distance$12,squaredDistance$1=squaredDistance$12,length$3=length$32,squaredLength$3=squaredLength$32,negate$1=negate$12,inverse$1=inverse$12,normalize$3=normalize$32,dot$3=dot$32,cross$1=cross$12,lerp$3=lerp$32,random$2=random$22,transformMat4$1=transformMat4$12,transformQuat=transformQuat2,zero$1=zero$12,str$3=str$32,exactEquals$3=exactEquals$32,equals$3=equals$32,create$2=create$22,identity$1=identity$12,setAxisAngle=setAxisAngle2,getAxisAngle=getAxisAngle2,getAngle=getAngle2,multiply$2=multiply$22,rotateX$1=rotateX$12,rotateY$1=rotateY$12,rotateZ$1=rotateZ$12,calculateW=calculateW2,exp=exp2,ln=ln2,pow=pow2,slerp=slerp2,random$1=random$12,invert$1=invert$12,conjugate$1=conjugate$12,fromMat3=fromMat32,fromEuler=fromEuler2,str$2=str$22,equals$2=equals$22,create$1=create$12,clone$1=clone$12,fromValues$1=fromValues$12,fromRotationTranslationValues=fromRotationTranslationValues2,fromRotationTranslation=fromRotationTranslation2,fromTranslation=fromTranslation2,fromRotation=fromRotation2,fromMat4=fromMat42,copy$1=copy$12,identity=identity2,set$1=set$12,getDual=getDual2,setDual=setDual2,getTranslation=getTranslation2,translate=translate2,rotateX=rotateX2,rotateY=rotateY2,rotateZ=rotateZ2,rotateByQuatAppend=rotateByQuatAppend2,rotateByQuatPrepend=rotateByQuatPrepend2,rotateAroundAxis=rotateAroundAxis2,add$1=add$12,multiply$1=multiply$12,scale$1=scale$12,lerp$1=lerp$12,invert=invert2,conjugate=conjugate2,normalize$1=normalize$12,str$1=str$12,exactEquals$1=exactEquals$12,equals$1=equals$12,create=create2,clone=clone2,fromValues=fromValues2,copy=copy2,set=set2,add=add2,subtract=subtract2,multiply=multiply2,divide=divide2,ceil=ceil2,floor=floor2,min=min2,max=max2,round=round2,scale=scale2,scaleAndAdd=scaleAndAdd2,distance=distance2,squaredDistance=squaredDistance2,length=length2,squaredLength=squaredLength2,negate=negate2,inverse=inverse2,normalize=normalize2,dot=dot2,cross=cross2,lerp=lerp2,random=random2,transformMat2=transformMat22,transformMat2d=transformMat2d2,transformMat3=transformMat32,transformMat4=transformMat42,rotate=rotate2,angle=angle2,zero=zero2,str=str2,exactEquals=exactEquals2,equals=equals2,EPSILON=1e-6,ARRAY_TYPE="undefined"!=typeof Float32Array?Float32Array:Array,RANDOM=Math.random,ANGLE_ORDER="zyx",degree=Math.PI/180,Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)}),common={__proto__:null,EPSILON:EPSILON,get ARRAY_TYPE(){return ARRAY_TYPE},RANDOM:RANDOM,ANGLE_ORDER:ANGLE_ORDER,setMatrixArrayType:setMatrixArrayType2,toRadian:toRadian2,equals:equals$92},mul$8=multiply$82,sub$6=subtract$62,mat2=Object.freeze({__proto__:null,create:create$82,clone:clone$82,copy:copy$82,identity:identity$52,fromValues:fromValues$82,set:set$82,transpose:transpose$22,invert:invert$52,adjoint:adjoint$22,determinant:determinant$32,multiply:multiply$82,rotate:rotate$42,scale:scale$82,fromRotation:fromRotation$42,fromScaling:fromScaling$32,str:str$82,frob:frob$32,LDU:LDU2,add:add$82,subtract:subtract$62,exactEquals:exactEquals$82,equals:equals$82,multiplyScalar:multiplyScalar$32,multiplyScalarAndAdd:multiplyScalarAndAdd$32,mul:mul$8,sub:sub$6}),mul$7=multiply$72,sub$5=subtract$52,mat2d=Object.freeze({__proto__:null,create:create$72,clone:clone$72,copy:copy$72,identity:identity$42,fromValues:fromValues$72,set:set$72,invert:invert$42,determinant:determinant$22,multiply:multiply$72,rotate:rotate$32,scale:scale$72,translate:translate$32,fromRotation:fromRotation$32,fromScaling:fromScaling$22,fromTranslation:fromTranslation$32,str:str$72,frob:frob$22,add:add$72,subtract:subtract$52,multiplyScalar:multiplyScalar$22,multiplyScalarAndAdd:multiplyScalarAndAdd$22,exactEquals:exactEquals$72,equals:equals$72,mul:mul$7,sub:sub$5}),mul$6=multiply$62,sub$4=subtract$42,mat3=Object.freeze({__proto__:null,create:create$62,fromMat4:fromMat4$12,clone:clone$62,copy:copy$62,fromValues:fromValues$62,set:set$62,identity:identity$32,transpose:transpose$12,invert:invert$32,adjoint:adjoint$12,determinant:determinant$12,multiply:multiply$62,translate:translate$22,rotate:rotate$22,scale:scale$62,fromTranslation:fromTranslation$22,fromRotation:fromRotation$22,fromScaling:fromScaling$12,fromMat2d:fromMat2d2,fromQuat:fromQuat$12,normalFromMat4:normalFromMat42,projection:projection2,str:str$62,frob:frob$12,add:add$62,subtract:subtract$42,multiplyScalar:multiplyScalar$12,multiplyScalarAndAdd:multiplyScalarAndAdd$12,exactEquals:exactEquals$62,equals:equals$62,mul:mul$6,sub:sub$4}),perspective=perspectiveNO2,ortho=orthoNO2,mul$5=multiply$52,sub$3=subtract$32,mat4=Object.freeze({__proto__:null,create:create$52,clone:clone$52,copy:copy$52,fromValues:fromValues$52,set:set$52,identity:identity$22,transpose:transpose2,invert:invert$22,adjoint:adjoint2,determinant:determinant2,multiply:multiply$52,translate:translate$12,scale:scale$52,rotate:rotate$12,rotateX:rotateX$32,rotateY:rotateY$32,rotateZ:rotateZ$32,fromTranslation:fromTranslation$12,fromScaling:fromScaling2,fromRotation:fromRotation$12,fromXRotation:fromXRotation2,fromYRotation:fromYRotation2,fromZRotation:fromZRotation2,fromRotationTranslation:fromRotationTranslation$12,fromQuat2:fromQuat22,getTranslation:getTranslation$12,getScaling:getScaling2,getRotation:getRotation2,decompose:decompose2,fromRotationTranslationScale:fromRotationTranslationScale2,fromRotationTranslationScaleOrigin:fromRotationTranslationScaleOrigin2,fromQuat:fromQuat3,frustum:frustum2,perspectiveNO:perspectiveNO2,perspective:perspective,perspectiveZO:perspectiveZO2,perspectiveFromFieldOfView:perspectiveFromFieldOfView2,orthoNO:orthoNO2,ortho:ortho,orthoZO:orthoZO2,lookAt:lookAt2,targetTo:targetTo2,str:str$52,frob:frob2,add:add$52,subtract:subtract$32,multiplyScalar:multiplyScalar2,multiplyScalarAndAdd:multiplyScalarAndAdd2,exactEquals:exactEquals$52,equals:equals$52,mul:mul$5,sub:sub$3}),sub$2=subtract$22,mul$4=multiply$42,div$2=divide$22,dist$2=distance$22,sqrDist$2=squaredDistance$22,len$4=length$42,sqrLen$4=squaredLength$42,forEach$2=(()=>{var l=create$42();return function(e,t,s,i,r,n){var a,o;for(t=t||3,s=s||0,o=i?Math.min(i*t+s,e.length):e.length,a=s;a<o;a+=t)l[0]=e[a],l[1]=e[a+1],l[2]=e[a+2],r(l,l,n),e[a]=l[0],e[a+1]=l[1],e[a+2]=l[2];return e}})(),vec3=Object.freeze({__proto__:null,create:create$42,clone:clone$42,length:length$42,fromValues:fromValues$42,copy:copy$42,set:set$42,add:add$42,subtract:subtract$22,multiply:multiply$42,divide:divide$22,ceil:ceil$22,floor:floor$22,min:min$22,max:max$22,round:round$22,scale:scale$42,scaleAndAdd:scaleAndAdd$22,distance:distance$22,squaredDistance:squaredDistance$22,squaredLength:squaredLength$42,negate:negate$22,inverse:inverse$22,normalize:normalize$42,dot:dot$42,cross:cross$22,lerp:lerp$42,slerp:slerp$12,hermite:hermite2,bezier:bezier2,random:random$32,transformMat4:transformMat4$22,transformMat3:transformMat3$12,transformQuat:transformQuat$12,rotateX:rotateX$22,rotateY:rotateY$22,rotateZ:rotateZ$22,angle:angle$12,zero:zero$22,str:str$42,exactEquals:exactEquals$42,equals:equals$42,sub:sub$2,mul:mul$4,div:div$2,dist:dist$2,sqrDist:sqrDist$2,len:len$4,sqrLen:sqrLen$4,forEach:forEach$2}),sub$1=subtract$12,mul$3=multiply$32,div$1=divide$12,dist$1=distance$12,sqrDist$1=squaredDistance$12,len$3=length$32,sqrLen$3=squaredLength$32,forEach$1=(()=>{var l=create$32();return function(e,t,s,i,r,n){var a,o;for(t=t||4,s=s||0,o=i?Math.min(i*t+s,e.length):e.length,a=s;a<o;a+=t)l[0]=e[a],l[1]=e[a+1],l[2]=e[a+2],l[3]=e[a+3],r(l,l,n),e[a]=l[0],e[a+1]=l[1],e[a+2]=l[2],e[a+3]=l[3];return e}})(),vec4=Object.freeze({__proto__:null,create:create$32,clone:clone$32,fromValues:fromValues$32,copy:copy$32,set:set$32,add:add$32,subtract:subtract$12,multiply:multiply$32,divide:divide$12,ceil:ceil$12,floor:floor$12,min:min$12,max:max$12,round:round$12,scale:scale$32,scaleAndAdd:scaleAndAdd$12,distance:distance$12,squaredDistance:squaredDistance$12,length:length$32,squaredLength:squaredLength$32,negate:negate$12,inverse:inverse$12,normalize:normalize$32,dot:dot$32,cross:cross$12,lerp:lerp$32,random:random$22,transformMat4:transformMat4$12,transformQuat:transformQuat2,zero:zero$12,str:str$32,exactEquals:exactEquals$32,equals:equals$32,sub:sub$1,mul:mul$3,div:div$1,dist:dist$1,sqrDist:sqrDist$1,len:len$3,sqrLen:sqrLen$3,forEach:forEach$1}),clone$2=clone$32,fromValues$2=fromValues$32,copy$2=copy$32,set$2=set$32,add$2=add$32,mul$2=multiply$22,scale$2=scale$32,dot$2=dot$32,lerp$2=lerp$32,length$2=length$32,len$2=length$2,squaredLength$2=squaredLength$32,sqrLen$2=squaredLength$2,normalize$2=normalize$32,exactEquals$2=exactEquals$32,rotationTo=(()=>{var r=create$42(),n=fromValues$42(1,0,0),a=fromValues$42(0,1,0);return function(e,t,s){var i=dot$42(t,s);return i<-.999999?(cross$22(r,n,t),len$4(r)<1e-6&&cross$22(r,a,t),normalize$42(r,r),setAxisAngle2(e,r,Math.PI),e):.999999<i?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(cross$22(r,t,s),e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=1+i,normalize$2(e,e))}})(),sqlerp=(()=>{var a=create$22(),o=create$22();return function(e,t,s,i,r,n){return slerp2(a,t,r,n),slerp2(o,s,i,n),slerp2(e,a,o,2*n*(1-n)),e}})(),setAxes=(()=>{var r=create$62();return function(e,t,s,i){return r[0]=s[0],r[3]=s[1],r[6]=s[2],r[1]=i[0],r[4]=i[1],r[7]=i[2],r[2]=-t[0],r[5]=-t[1],r[8]=-t[2],normalize$2(e,fromMat32(e,r))}})(),quat=Object.freeze({__proto__:null,create:create$22,identity:identity$12,setAxisAngle:setAxisAngle2,getAxisAngle:getAxisAngle2,getAngle:getAngle2,multiply:multiply$22,rotateX:rotateX$12,rotateY:rotateY$12,rotateZ:rotateZ$12,calculateW:calculateW2,exp:exp2,ln:ln2,pow:pow2,slerp:slerp2,random:random$12,invert:invert$12,conjugate:conjugate$12,fromMat3:fromMat32,fromEuler:fromEuler2,str:str$22,clone:clone$2,fromValues:fromValues$2,copy:copy$2,set:set$2,add:add$2,mul:mul$2,scale:scale$2,dot:dot$2,lerp:lerp$2,length:length$2,len:len$2,squaredLength:squaredLength$2,sqrLen:sqrLen$2,normalize:normalize$2,exactEquals:exactEquals$2,equals:equals$22,rotationTo:rotationTo,sqlerp:sqlerp,setAxes:setAxes}),getReal=copy$2,setReal=copy$2,mul$1=multiply$12,dot$1=dot$2,length$1=length$2,len$1=length$1,squaredLength$1=squaredLength$2,sqrLen$1=squaredLength$1,quat2=Object.freeze({__proto__:null,create:create$12,clone:clone$12,fromValues:fromValues$12,fromRotationTranslationValues:fromRotationTranslationValues2,fromRotationTranslation:fromRotationTranslation2,fromTranslation:fromTranslation2,fromRotation:fromRotation2,fromMat4:fromMat42,copy:copy$12,identity:identity2,set:set$12,getReal:getReal,getDual:getDual2,setReal:setReal,setDual:setDual2,getTranslation:getTranslation2,translate:translate2,rotateX:rotateX2,rotateY:rotateY2,rotateZ:rotateZ2,rotateByQuatAppend:rotateByQuatAppend2,rotateByQuatPrepend:rotateByQuatPrepend2,rotateAroundAxis:rotateAroundAxis2,add:add$12,multiply:multiply$12,mul:mul$1,scale:scale$12,dot:dot$1,lerp:lerp$12,invert:invert2,conjugate:conjugate2,length:length$1,len:len$1,squaredLength:squaredLength$1,sqrLen:sqrLen$1,normalize:normalize$12,str:str$12,exactEquals:exactEquals$12,equals:equals$12}),len=length2,sub=subtract2,mul=multiply2,div=divide2,dist=distance2,sqrDist=squaredDistance2,sqrLen=squaredLength2,forEach=(()=>{var l=create2();return function(e,t,s,i,r,n){var a,o;for(t=t||2,s=s||0,o=i?Math.min(i*t+s,e.length):e.length,a=s;a<o;a+=t)l[0]=e[a],l[1]=e[a+1],r(l,l,n),e[a]=l[0],e[a+1]=l[1];return e}})(),vec2=Object.freeze({__proto__:null,create:create2,clone:clone2,fromValues:fromValues2,copy:copy2,set:set2,add:add2,subtract:subtract2,multiply:multiply2,divide:divide2,ceil:ceil2,floor:floor2,min:min2,max:max2,round:round2,scale:scale2,scaleAndAdd:scaleAndAdd2,distance:distance2,squaredDistance:squaredDistance2,length:length2,squaredLength:squaredLength2,negate:negate2,inverse:inverse2,normalize:normalize2,dot:dot2,cross:cross2,lerp:lerp2,random:random2,transformMat2:transformMat22,transformMat2d:transformMat2d2,transformMat3:transformMat32,transformMat4:transformMat42,rotate:rotate2,angle:angle2,zero:zero2,str:str2,exactEquals:exactEquals2,equals:equals2,len:len,sub:sub,mul:mul,div:div,dist:dist,sqrDist:sqrDist,sqrLen:sqrLen,forEach:forEach}),globalThis.glMatrix=common,globalThis.glMatrix.mat2=mat2,globalThis.glMatrix.mat2d=mat2d,globalThis.glMatrix.mat3=mat3,globalThis.glMatrix.mat4=mat4,globalThis.glMatrix.quat=quat,globalThis.glMatrix.quat2=quat2,globalThis.glMatrix.vec2=vec2,globalThis.glMatrix.vec3=vec3,globalThis.glMatrix.vec4=vec4}var EPSILON,ARRAY_TYPE,RANDOM,ANGLE_ORDER,degree,common,mul$8,sub$6,mat2,mul$7,sub$5,mat2d,mul$6,sub$4,mat3,perspective,ortho,mul$5,sub$3,mat4,sub$2,mul$4,div$2,dist$2,sqrDist$2,len$4,sqrLen$4,forEach$2,vec3,sub$1,mul$3,div$1,dist$1,sqrDist$1,len$3,sqrLen$3,forEach$1,vec4,clone$2,fromValues$2,copy$2,set$2,add$2,mul$2,scale$2,dot$2,lerp$2,length$2,len$2,squaredLength$2,sqrLen$2,normalize$2,exactEquals$2,rotationTo,sqlerp,setAxes,quat,getReal,setReal,mul$1,dot$1,length$1,len$1,squaredLength$1,sqrLen$1,quat2,len,sub,mul,div,dist,sqrDist,sqrLen,forEach,vec2,setMatrixArrayType,toRadian,equals$9,create$8,clone$8,copy$8,identity$5,fromValues$8,set$8,transpose$2,invert$5,adjoint$2,determinant$3,multiply$8,rotate$4,scale$8,fromRotation$4,fromScaling$3,str$8,frob$3,LDU,add$8,subtract$6,exactEquals$8,equals$8,multiplyScalar$3,multiplyScalarAndAdd$3,create$7,clone$7,copy$7,identity$4,fromValues$7,set$7,invert$4,determinant$2,multiply$7,rotate$3,scale$7,translate$3,fromRotation$3,fromScaling$2,fromTranslation$3,str$7,frob$2,add$7,subtract$5,multiplyScalar$2,multiplyScalarAndAdd$2,exactEquals$7,equals$7,create$6,fromMat4$1,clone$6,copy$6,fromValues$6,set$6,identity$3,transpose$1,invert$3,adjoint$1,determinant$1,multiply$6,translate$2,rotate$2,scale$6,fromTranslation$2,fromRotation$2,fromScaling$1,fromMat2d,fromQuat$1,normalFromMat4,projection,str$6,frob$1,add$6,subtract$4,multiplyScalar$1,multiplyScalarAndAdd$1,exactEquals$6,equals$6,create$5,clone$5,copy$5,fromValues$5,set$5,identity$2,transpose,invert$2,adjoint,determinant,multiply$5,translate$1,scale$5,rotate$1,rotateX$3,rotateY$3,rotateZ$3,fromTranslation$1,fromScaling,fromRotation$1,fromXRotation,fromYRotation,fromZRotation,fromRotationTranslation$1,fromQuat2,getTranslation$1,getScaling,getRotation,decompose,fromRotationTranslationScale,fromRotationTranslationScaleOrigin,fromQuat,frustum,perspectiveNO,perspectiveZO,perspectiveFromFieldOfView,orthoNO,orthoZO,lookAt,targetTo,str$5,frob,add$5,subtract$3,multiplyScalar,multiplyScalarAndAdd,exactEquals$5,equals$5,create$4,clone$4,length$4,fromValues$4,copy$4,set$4,add$4,subtract$2,multiply$4,divide$2,ceil$2,floor$2,min$2,max$2,round$2,scale$4,scaleAndAdd$2,distance$2,squaredDistance$2,squaredLength$4,negate$2,inverse$2,normalize$4,dot$4,cross$2,lerp$4,slerp$1,hermite,bezier,random$3,transformMat4$2,transformMat3$1,transformQuat$1,rotateX$2,rotateY$2,rotateZ$2,angle$1,zero$2,str$4,exactEquals$4,equals$4,create$3,clone$3,fromValues$3,copy$3,set$3,add$3,subtract$1,multiply$3,divide$1,ceil$1,floor$1,min$1,max$1,round$1,scale$3,scaleAndAdd$1,distance$1,squaredDistance$1,length$3,squaredLength$3,negate$1,inverse$1,normalize$3,dot$3,cross$1,lerp$3,random$2,transformMat4$1,transformQuat,zero$1,str$3,exactEquals$3,equals$3,create$2,identity$1,setAxisAngle,getAxisAngle,getAngle,multiply$2,rotateX$1,rotateY$1,rotateZ$1,calculateW,exp,ln,pow,slerp,random$1,invert$1,conjugate$1,fromMat3,fromEuler,str$2,equals$2,create$1,clone$1,fromValues$1,fromRotationTranslationValues,fromRotationTranslation,fromTranslation,fromRotation,fromMat4,copy$1,identity,set$1,getDual,setDual,getTranslation,translate,rotateX,rotateY,rotateZ,rotateByQuatAppend,rotateByQuatPrepend,rotateAroundAxis,add$1,multiply$1,scale$1,lerp$1,invert,conjugate,normalize$1,str$1,exactEquals$1,equals$1,create,clone,fromValues,copy,set,add,subtract,multiply,divide,ceil,floor,min,max,round,scale,scaleAndAdd,distance,squaredDistance,length,squaredLength,negate,inverse,normalize,dot,cross,lerp,random,transformMat2,transformMat2d,transformMat3,transformMat4,rotate,angle,zero,str,exactEquals,equals,tmpPoint1,tmpPoint2,tmpLine1,tmpLine2,lineInt,lineSegmentsIntersect,triangleArea,isLeft,isLeftOn,isRight,isRightOn,collinear,sqdist,polygonAt,polygonClear,polygonAppend,polygonMakeCCW,polygonReverse,polygonIsReflex,polygonCanSee,polygonCanSee2,polygonCopy,polygonGetCutEdges,polygonDecomp,polygonSlice,polygonIsSimple,getIntersectionPoint,polygonQuickDecomp,polygonRemoveCollinearPoints,polygonRemoveDuplicatePoints,scalar_eq,points_eq,ReadBrandList,RunTest,GetWindowsNTVersionName,asyncifyRequest,asyncifyTransaction,openReadOnlyTransaction,openWriteTransaction,lazyOpenDatabase,RequireString,getEntriesFromCursor,NOT_IMPLEMENTED,DISALLOW_CALLBACK,StructuredClone,arrayFlat,assertFail,isValidTypeChange,logDefendedObjectWarning,CheckDefendedObjectsUsedCorrectly,getObjectPropertySet,VerifyObjectPropertiesConsistent,isNegativeZero,padTwoDigits,hueToRGB,RequireStringOrNumber,SetNewCallback,DoAsyncifiedWork,DoNextAsyncifiedJob,ClearTimeCache,CheckActiveIdleTimeouts,lookupHtmlEntity,bbToHtmlReplacerFunc,IsWordBreakWhiteSpace,IsOpeningCJKPunctiationChar,IsContinuingCJKPunctuationChar,WordBreakTrimEnd,IsNewline,PlaneFromPoints,IsInFrontOfPlane,IsPointInFrontOfPlane,interpolateQuad,GetFormatSpecifiers,fillOrStrokeRect,ptToPx,getOffsetParam,CheckPendingPolls,SortZOrderList,GetDispatcher,MakeIWorldInstanceClass,GetDispatcher,GetTimelineState,GetTimelineState,GetTweenState,getActual,GetTypeFromFileExtension,AddScript,SortByInstLastCachedZIndex,SortByInstLastCachedZIndex,SortByInstZElevation,vec3EqualsXYZ,MaybePrepareLayerDraw,SortSolArray,IsSolArrayIdentical,NoActions,WrapIndex,GetExpressionFunc,EvalParams,EvalParams,GetInst,GetWorldInfo,GetInst_SDKv2,GetWorldInfo_SDKv2,GetObjectClass,GetLayer,CollMemory_Add,CollMemory_Remove,CollMemory_RemoveInstance,CollMemory_Get,DoOverlapCondition,FinishCollisionConditionPicking,FinishCollisionCondition,PickByUID_Normal,PickByUID_Inverted,GetNextParamMap,ValidateInternalAPIToken,ForEachOrdered_SortInstances,SortZOrderList,SortInstancesByValue,WrapModeToStr,GetAudioSdkInstance,GetAudioDOMInterface,GetKeyboardSdkInstance,StringFromCharCode,GetMouseSdkInstance,GetTouchSdkInstance,IsExpressionType,getOffsetParam,normalizeCssColorString,CloneDrawable,GetParticleEngine,randomOffset,unaryminus,bothNumbers,add,subtract,multiply,divide,mod,pow,and,or;{let lineInt2=function(e,t,s){var i=[0,0],r=e[1][1]-e[0][1],n=e[0][0]-e[1][0],e=r*e[0][0]+n*e[0][1],a=t[1][1]-t[0][1],o=t[0][0]-t[1][0],t=a*t[0][0]+o*t[0][1],l=r*o-a*n;return scalar_eq2(l,0,s=s||0)||(i[0]=(o*e-n*t)/l,i[1]=(r*t-a*e)/l),i},lineSegmentsIntersect2=function(e,t,s,i){var r,n=t[0]-e[0],t=t[1]-e[1],a=i[0]-s[0];return a*t-(i=i[1]-s[1])*n!=0&&(r=(a*(e[1]-s[1])+i*(s[0]-e[0]))/(i*n-a*t),0<=(e=(n*(s[1]-e[1])+t*(e[0]-s[0]))/(a*t-i*n)))&&e<=1&&0<=r&&r<=1},triangleArea2=function(e,t,s){return(t[0]-e[0])*(s[1]-e[1])-(s[0]-e[0])*(t[1]-e[1])},isLeft2=function(e,t,s){return 0<triangleArea2(e,t,s)},isLeftOn2=function(e,t,s){return 0<=triangleArea2(e,t,s)},isRight2=function(e,t,s){return triangleArea2(e,t,s)<0},isRightOn2=function(e,t,s){return triangleArea2(e,t,s)<=0},collinear2=function(e,t,s,i){var r,n,a;return i?(a=tmpPoint2,(n=tmpPoint1)[0]=t[0]-e[0],n[1]=t[1]-e[1],a[0]=s[0]-t[0],a[1]=s[1]-t[1],r=n[0]*a[0]+n[1]*a[1],n=Math.sqrt(n[0]*n[0]+n[1]*n[1]),a=Math.sqrt(a[0]*a[0]+a[1]*a[1]),Math.acos(r/(n*a))<i):0===triangleArea2(e,t,s)},sqdist2=function(e,t){var s=t[0]-e[0];return s*s+(t=t[1]-e[1])*t},polygonAt2=function(e,t){var s=e.length;return e[t<0?t%s+s:t%s]},polygonClear2=function(e){e.length=0},polygonAppend2=function(e,t,s,i){for(var r=s;r<i;r++)e.push(t[r])},polygonMakeCCW2=function(e){for(var t=0,s=e,i=1;i<e.length;++i)(s[i][1]<s[t][1]||s[i][1]===s[t][1]&&s[i][0]>s[t][0])&&(t=i);return!isLeft2(polygonAt2(e,t-1),polygonAt2(e,t),polygonAt2(e,t+1))&&(polygonReverse2(e),!0)},polygonReverse2=function(e){for(var t=[],s=e.length,i=0;i!==s;i++)t.push(e.pop());for(i=0;i!==s;i++)e[i]=t[i]},polygonIsReflex2=function(e,t){return isRight2(polygonAt2(e,t-1),polygonAt2(e,t),polygonAt2(e,t+1))},polygonCanSee3=function(e,t,s){var i,r=tmpLine1,n=tmpLine2;if(isLeftOn2(polygonAt2(e,t+1),polygonAt2(e,t),polygonAt2(e,s))&&isRightOn2(polygonAt2(e,t-1),polygonAt2(e,t),polygonAt2(e,s)))return!1;for(var a=sqdist2(polygonAt2(e,t),polygonAt2(e,s)),o=0;o!==e.length;++o)if((o+1)%e.length!==t&&o!==t&&isLeftOn2(polygonAt2(e,t),polygonAt2(e,s),polygonAt2(e,o+1))&&isRightOn2(polygonAt2(e,t),polygonAt2(e,s),polygonAt2(e,o))&&(r[0]=polygonAt2(e,t),r[1]=polygonAt2(e,s),n[0]=polygonAt2(e,o),n[1]=polygonAt2(e,o+1),i=lineInt2(r,n),sqdist2(polygonAt2(e,t),i)<a))return!1;return!0},polygonCanSee22=function(e,t,s){for(var i=0;i!==e.length;++i)if(i!==t&&i!==s&&(i+1)%e.length!==t&&(i+1)%e.length!==s&&lineSegmentsIntersect2(polygonAt2(e,t),polygonAt2(e,s),polygonAt2(e,i),polygonAt2(e,i+1)))return!1;return!0},polygonCopy2=function(e,t,s,i){var r=i||[];if(polygonClear2(r),t<s)for(var n=t;n<=s;n++)r.push(e[n]);else{for(n=0;n<=s;n++)r.push(e[n]);for(n=t;n<e.length;n++)r.push(e[n])}return r},polygonGetCutEdges2=function(e){for(var t=[],s=[],i=[],r=Number.MAX_VALUE,n=0;n<e.length;++n)if(polygonIsReflex2(e,n))for(var a=0;a<e.length;++a)if(polygonCanSee3(e,n,a)){for(var s=polygonGetCutEdges2(polygonCopy2(e,n,a,i)),o=polygonGetCutEdges2(polygonCopy2(e,a,n,i)),l=0;l<o.length;l++)s.push(o[l]);s.length<r&&(r=(t=s).length,t.push([polygonAt2(e,n),polygonAt2(e,a)]))}return t},polygonDecomp2=function(e){var t=polygonGetCutEdges2(e);return 0<t.length?polygonSlice2(e,t):[e]},polygonSlice2=function(e,t){if(0===t.length)return[e];if(t instanceof Array&&t.length&&t[0]instanceof Array&&2===t[0].length&&t[0][0]instanceof Array){for(var s=[e],i=0;i<t.length;i++)for(var r=t[i],n=0;n<s.length;n++){var a=polygonSlice2(s[n],r);if(a){s.splice(n,1),s.push(a[0],a[1]);break}}return s}return i=e.indexOf((r=t)[0]),n=e.indexOf(r[1]),-1!==i&&-1!==n&&[polygonCopy2(e,i,n),polygonCopy2(e,n,i)]},polygonIsSimple2=function(e){for(var t=e,s=0;s<t.length-1;s++)for(var i=0;i<s-1;i++)if(lineSegmentsIntersect2(t[s],t[s+1],t[i],t[i+1]))return!1;for(s=1;s<t.length-2;s++)if(lineSegmentsIntersect2(t[0],t[t.length-1],t[s],t[s+1]))return!1;return!0},getIntersectionPoint2=function(e,t,s,i,r){var n=t[1]-e[1],t=e[0]-t[0],e=n*e[0]+t*e[1],a=i[1]-s[1],i=s[0]-i[0],s=a*s[0]+i*s[1],o=n*i-a*t;return scalar_eq2(o,0,r=r||0)?[0,0]:[(i*e-t*s)/o,(n*s-a*e)/o]},polygonQuickDecomp2=function(e,t,s,i,r,n,a){n=n||100,a=a||0,r=r||25,t=void 0!==t?t:[],s=s||[],i=i||[];var o=[0,0],l=[0,0],h=[0,0],c=0,u=0,_=0,d=0,p=0,m=0,g=0,f=[],S=[],C=e,y=e;if(!(y.length<3))if(n<++a)console.warn("quickDecomp: max level ("+n+") reached.");else{for(var G=0;G<e.length;++G)if(polygonIsReflex2(C,G)){s.push(C[G]);for(var c=u=Number.MAX_VALUE,I=0;I<e.length;++I)isLeft2(polygonAt2(C,G-1),polygonAt2(C,G),polygonAt2(C,I))&&isRightOn2(polygonAt2(C,G-1),polygonAt2(C,G),polygonAt2(C,I-1))&&(h=getIntersectionPoint2(polygonAt2(C,G-1),polygonAt2(C,G),polygonAt2(C,I),polygonAt2(C,I-1)),isRight2(polygonAt2(C,G+1),polygonAt2(C,G),h))&&(_=sqdist2(C[G],h))<u&&(u=_,l=h,m=I),isLeft2(polygonAt2(C,G+1),polygonAt2(C,G),polygonAt2(C,I+1))&&isRightOn2(polygonAt2(C,G+1),polygonAt2(C,G),polygonAt2(C,I))&&(h=getIntersectionPoint2(polygonAt2(C,G+1),polygonAt2(C,G),polygonAt2(C,I),polygonAt2(C,I+1)),isLeft2(polygonAt2(C,G-1),polygonAt2(C,G),h))&&(_=sqdist2(C[G],h))<c&&(c=_,o=h,p=I);if(m===(p+1)%e.length)h[0]=(l[0]+o[0])/2,h[1]=(l[1]+o[1])/2,i.push(h),G<p?(polygonAppend2(f,C,G,p+1),f.push(h),S.push(h),0!==m&&polygonAppend2(S,C,m,C.length),polygonAppend2(S,C,0,G+1)):(0!==G&&polygonAppend2(f,C,G,C.length),polygonAppend2(f,C,0,p+1),f.push(h),S.push(h),polygonAppend2(S,C,m,G+1));else{if(p<m&&(p+=e.length),d=Number.MAX_VALUE,p<m)return t;for(I=m;I<=p;++I)isLeftOn2(polygonAt2(C,G-1),polygonAt2(C,G),polygonAt2(C,I))&&isRightOn2(polygonAt2(C,G+1),polygonAt2(C,G),polygonAt2(C,I))&&(_=sqdist2(polygonAt2(C,G),polygonAt2(C,I)))<d&&polygonCanSee22(C,G,I)&&(d=_,g=I%e.length);G<g?(polygonAppend2(f,C,G,g+1),0!==g&&polygonAppend2(S,C,g,y.length),polygonAppend2(S,C,0,G+1)):(0!==G&&polygonAppend2(f,C,G,y.length),polygonAppend2(f,C,0,g+1),polygonAppend2(S,C,g,G+1))}return f.length<S.length?(polygonQuickDecomp2(f,t,s,i,r,n,a),polygonQuickDecomp2(S,t,s,i,r,n,a)):(polygonQuickDecomp2(S,t,s,i,r,n,a),polygonQuickDecomp2(f,t,s,i,r,n,a)),t}t.push(e)}return t},polygonRemoveCollinearPoints2=function(e,t){for(var s=0,i=e.length-1;3<e.length&&0<=i;--i)collinear2(polygonAt2(e,i-1),polygonAt2(e,i),polygonAt2(e,i+1),t)&&(e.splice(i%e.length,1),s++);return s},polygonRemoveDuplicatePoints2=function(e,t){for(var s=e.length-1;1<=s;--s)for(var i=e[s],r=s-1;0<=r;--r)points_eq2(i,e[r],t)&&e.splice(s,1)},scalar_eq2=function(e,t,s){return s=s||0,Math.abs(e-t)<=s},points_eq2=function(e,t,s){return scalar_eq2(e[0],t[0],s)&&scalar_eq2(e[1],t[1],s)};lineInt=lineInt2,lineSegmentsIntersect=lineSegmentsIntersect2,triangleArea=triangleArea2,isLeft=isLeft2,isLeftOn=isLeftOn2,isRight=isRight2,isRightOn=isRightOn2,collinear=collinear2,sqdist=sqdist2,polygonAt=polygonAt2,polygonClear=polygonClear2,polygonAppend=polygonAppend2,polygonMakeCCW=polygonMakeCCW2,polygonReverse=polygonReverse2,polygonIsReflex=polygonIsReflex2,polygonCanSee=polygonCanSee3,polygonCanSee2=polygonCanSee22,polygonCopy=polygonCopy2,polygonGetCutEdges=polygonGetCutEdges2,polygonDecomp=polygonDecomp2,polygonSlice=polygonSlice2,polygonIsSimple=polygonIsSimple2,getIntersectionPoint=getIntersectionPoint2,polygonQuickDecomp=polygonQuickDecomp2,polygonRemoveCollinearPoints=polygonRemoveCollinearPoints2,polygonRemoveDuplicatePoints=polygonRemoveDuplicatePoints2,scalar_eq=scalar_eq2,points_eq=points_eq2,tmpPoint1=[],tmpPoint2=[],tmpLine1=[],tmpLine2=[],self.polyDecomp={decomp:polygonDecomp2,quickDecomp:polygonQuickDecomp2,isSimple:polygonIsSimple2,removeCollinearPoints:polygonRemoveCollinearPoints2,removeDuplicatePoints:polygonRemoveDuplicatePoints2,makeCCW:polygonMakeCCW2}}{let isReady=!1,hasAppStarted=!1,buildMode="dev",internalApiToken=Symbol("Construct internal API token"),internalApiTokenAccessesRemaining=14,C33=self.C3=class{constructor(){throw TypeError("static class can't be instantiated")}static _GetInternalAPIToken(){if(internalApiTokenAccessesRemaining<=0)throw new Error("cannot obtain internal API token");return--internalApiTokenAccessesRemaining,internalApiToken}static SetReady(){isReady=!0}static IsReady(){return isReady}static SetAppStarted(){hasAppStarted=!0}static HasAppStarted(){return hasAppStarted}static SetBuildMode(e){buildMode=e}static GetBuildMode(){return buildMode}static IsReleaseBuild(){return"final"===buildMode}};C33.isDebug=!1,C33.isDebugDefend=!1,C33.hardwareConcurrency=navigator.hardwareConcurrency||2,self.C3X={}}{const C33=self.C3;C33.QueryParser=class{constructor(e){this._queryString=e,this._parameters=new Map,this._Parse()}_Parse(){let e=this._queryString,t=(e=e.startsWith("?")||e.startsWith("#")?e.substr(1):e).split("&");for(const s of t)this._ParseParameter(s)}_ParseParameter(e){if(e)if(e.includes("=")){const t=e.indexOf("="),s=decodeURIComponent(e.substring(0,t)),i=decodeURIComponent(e.substring(t+1));this._parameters.set(s,i)}else this._parameters.set(e,null)}LogAll(){for(const e of this._parameters)console.log("[QueryParser] Parameter '"+e[0]+"' = "+(null===e[1]?"null":"'"+e[1]+"'"))}Has(e){return this._parameters.has(e)}Get(e){const t=this._parameters.get(e);return void 0===t?null:t}ClearHash(){history.replaceState("",document.title,location.pathname+location.search)}Reparse(e){this._queryString=e,this._parameters.clear(),this._Parse()}},C33.QueryString=new C33.QueryParser(location.search),C33.LocationHashString=new C33.QueryParser(location.hash),C33.QueryString.Has("perf")&&(C33.isPerformanceProfiling=!0),"dev"!==C33.QueryString.Get("mode")&&C33.SetBuildMode("final")}{let GetWindowsNTVersionName2=function(e){const t=parseFloat(e),s=windowsNTVerMap.get(t);return s||(13<=t?"11":"NT "+e)};GetWindowsNTVersionName=GetWindowsNTVersionName2;const C33=self.C3,UNKNOWN="(unknown)",windowsNTVerMap=(C33.Platform={OS:UNKNOWN,OSVersion:UNKNOWN,Browser:UNKNOWN,BrowserVersion:UNKNOWN,BrowserVersionNumber:NaN,BrowserEngine:UNKNOWN,Context:"browser",IsDesktop:!0,IsMobile:!1,IsAppleOS:!1,IsIpadOS:!1,GetDetailedInfo:async()=>{}},new Map([[5,"2000"],[5.1,"XP"],[5.2,"XP"],[6,"Vista"],[6.1,"7"],[6.2,"8"],[6.3,"8.1"],[10,"10"]])),uaStr=navigator.userAgent,uaData=navigator.userAgentData;if(uaData&&0<uaData.brands.length){let ReadBrandList2=function(t){let s="",i="",r="",n="";for(const a of t){const o=d.get(a.brand),l=(!s&&o&&(s=o,i=a.version),e.get(a.brand));!r&&l&&(r=l,n=a.version)}s||"Chromium"!==r||(C33.Platform.Browser="Chromium",C33.Platform.BrowserVersion=n),C33.Platform.Browser=s||UNKNOWN,C33.Platform.BrowserVersion=i||UNKNOWN,C33.Platform.BrowserEngine=r||UNKNOWN};ReadBrandList=ReadBrandList2,C33.Platform.OS=uaData.platform,C33.Platform.IsMobile=uaData.mobile,C33.Platform.IsDesktop=!C33.Platform.IsMobile;const d=new Map([["Google Chrome","Chrome"],["Microsoft Edge","Edge"],["Opera","Opera"],["Opera GX","Opera GX"],["Mozilla Firefox","Firefox"],["Apple Safari","Safari"],["NW.js","NW.js"]]),e=new Map([["Chromium","Chromium"],["Gecko","Gecko"],["WebKit","WebKit"]]);ReadBrandList2(uaData.brands);let o=!1;C33.Platform.GetDetailedInfo=async()=>{if(!o)try{const e=await navigator.userAgentData.getHighEntropyValues(["platformVersion","fullVersionList"]);ReadBrandList2(e.fullVersionList),"Windows"===C33.Platform.OS?C33.Platform.OSVersion=GetWindowsNTVersionName2(e.platformVersion):C33.Platform.OSVersion=e.platformVersion,o=!0}catch(e){console.warn("Failed to get detailed user agent information: ",e)}}}else{let RunTest2=function(e,t){const s=Array.isArray(e)?e:[e];for(const i of s){const r=i.exec(uaStr);if(r){t(r);break}}};RunTest=RunTest2,RunTest2(/windows\s+nt\s+([\d\.]+)/i,e=>{C33.Platform.OS="Windows";const t=e[1];C33.Platform.OSVersion=GetWindowsNTVersionName2(t)}),RunTest2(/mac\s+os\s+x\s+([\d\._]+)/i,e=>{C33.Platform.OS="macOS",C33.Platform.OSVersion=e[1].replace(/_/g,".")}),RunTest2(/CrOS/,()=>{C33.Platform.OS="Chrome OS"}),RunTest2(/linux|openbsd|freebsd|netbsd/i,()=>{C33.Platform.OS="Linux"}),RunTest2(/android/i,()=>{C33.Platform.OS="Android"}),RunTest2(/android\s+([\d\.]+)/i,e=>{C33.Platform.OS="Android",C33.Platform.OSVersion=e[1]}),C33.Platform.OS===UNKNOWN&&(RunTest2(/(iphone|ipod|ipad)/i,e=>{C33.Platform.OS="iOS"}),RunTest2([/iphone\s+os\s+([\d\._]+)/i,/ipad[^)]*os\s+([\d\._]+)/i],e=>{C33.Platform.OS="iOS",C33.Platform.OSVersion=e[1].replace(/_/g,".")}));const q=/chrome\//i.test(uaStr),r=/chromium\//i.test(uaStr),s=/edg\//i.test(uaStr),t=/OPR\//.test(uaStr),u=/nwjs/i.test(uaStr),v=/safari\//i.test(uaStr),w=/webkit/i.test(uaStr),x=(s||t||RunTest2(/chrome\/([\d\.]+)/i,e=>{C33.Platform.Browser="Chrome",C33.Platform.BrowserVersion=e[1],C33.Platform.BrowserEngine="Chromium"}),RunTest2(/edg\/([\d\.]+)/i,e=>{C33.Platform.Browser="Edge",C33.Platform.BrowserVersion=e[1],C33.Platform.BrowserEngine="Chromium"}),RunTest2(/OPR\/([\d\.]+)/,e=>{C33.Platform.Browser="Opera",C33.Platform.BrowserVersion=e[1],C33.Platform.BrowserEngine="Chromium"}),RunTest2(/chromium\/([\d\.]+)/i,e=>{C33.Platform.Browser="Chromium",C33.Platform.BrowserVersion=e[1],C33.Platform.BrowserEngine="Chromium"}),RunTest2(/nwjs\/[0-9.]+/i,e=>{C33.Platform.Browser="NW.js",C33.Platform.BrowserVersion=e[1],C33.Platform.BrowserEngine="Chromium",C33.Platform.Context="nwjs"}),RunTest2(/firefox\/([\d\.]+)/i,e=>{C33.Platform.Browser="Firefox",C33.Platform.BrowserVersion=e[1],C33.Platform.BrowserEngine="Gecko"}),!v||q||r||s||t||u||(C33.Platform.Browser="Safari",C33.Platform.BrowserEngine="WebKit",RunTest2(/version\/([\d\.]+)/i,e=>{C33.Platform.BrowserVersion=e[1]}),RunTest2(/crios\/([\d\.]+)/i,e=>{C33.Platform.Browser="Chrome for iOS",C33.Platform.BrowserVersion=e[1]}),RunTest2(/fxios\/([\d\.]+)/i,e=>{C33.Platform.Browser="Firefox for iOS",C33.Platform.BrowserVersion=e[1]}),RunTest2(/edgios\/([\d\.]+)/i,e=>{C33.Platform.Browser="Edge for iOS",C33.Platform.BrowserVersion=e[1]})),C33.Platform.BrowserEngine===UNKNOWN&&w&&(C33.Platform.BrowserEngine="WebKit"),"Android"===C33.Platform.OS&&"Safari"===C33.Platform.Browser&&(C33.Platform.Browser="Stock"),new Set(["Windows","macOS","Linux","Chrome OS"])),y=x.has(C33.Platform.OS)||"nwjs"===C33.Platform.Context;C33.Platform.IsDesktop=y,C33.Platform.IsMobile=!y}"Chrome"===C33.Platform.Browser&&"browser"===C33.Platform.Context&&/wv\)/.test(uaStr)&&(C33.Platform.Context="webview"),"nwjs"!==C33.Platform.Context&&"undefined"!=typeof window&&(window.matchMedia&&window.matchMedia("(display-mode: standalone)").matches||navigator.standalone)&&(C33.Platform.Context="webapp"),C33.Platform.BrowserVersionNumber=parseFloat(C33.Platform.BrowserVersion);const looksLikeIPadOS="macOS"===C33.Platform.OS&&navigator.maxTouchPoints&&2<navigator.maxTouchPoints;looksLikeIPadOS&&(C33.Platform.OS="iOS",C33.Platform.OSVersion=C33.Platform.BrowserVersion,C33.Platform.IsDesktop=!1,C33.Platform.IsMobile=!0,C33.Platform.IsIpadOS=!0),C33.Platform.IsAppleOS="macOS"===C33.Platform.OS||"iOS"===C33.Platform.OS}{let asyncifyRequest2=function(s){return new Promise((e,t)=>{s.onsuccess=()=>e(s.result),s.onerror=()=>t(s.error)})},asyncifyTransaction2=function(s){return new Promise((e,t)=>{s.oncomplete=()=>e(),s.onerror=()=>t(s.error),s.onabort=()=>t(s.error)})},openReadOnlyTransaction2=function(e,t){return openTransaction(e,t)},openWriteTransaction2=function(e,t){return openTransaction(e,t,!0)},lazyOpenDatabase2=function(t){RequireString2(t);let e=c.get(t);return e instanceof Promise||(e=openDatabase(t),c.set(t,e),e.catch(e=>c.delete(t))),e},RequireString2=function(e){if("string"!=typeof e)throw new TypeError("expected string")},getEntriesFromCursor2=function(e,r){const t=e.objectStore(b).openCursor();return new Promise(s=>{const i=[];t.onsuccess=e=>{const t=e.target.result;if(t){switch(r){case"entries":i.push([t.key,t.value]);break;case"keys":i.push(t.key);break;case"values":i.push(t.value)}t.continue()}else s(i)}})};asyncifyRequest=asyncifyRequest2,asyncifyTransaction=asyncifyTransaction2,openReadOnlyTransaction=openReadOnlyTransaction2,openWriteTransaction=openWriteTransaction2,lazyOpenDatabase=lazyOpenDatabase2,RequireString=RequireString2,getEntriesFromCursor=getEntriesFromCursor2;const a=2,b="keyvaluepairs",c=new Map,d="undefined"!=typeof IDBObjectStore&&"function"==typeof IDBObjectStore.prototype.getAll,e="undefined"!=typeof IDBObjectStore&&"function"==typeof IDBObjectStore.prototype.getAllKeys;async function openTransaction(t,s,i=!1,r=!0){const e=await lazyOpenDatabase2(t);try{const n=e.transaction([b],i?"readwrite":"readonly");return s(n)}catch(e){if(r&&"InvalidStateError"===e.name)return c.delete(t),openTransaction(t,s,i,!1);throw e}}async function openDatabase(s){RequireString2(s);const e=indexedDB.open(s,a);return e.addEventListener("upgradeneeded",e=>{try{const t=e.target.result;t.createObjectStore(b)}catch(e){console.error("Failed to create objectstore for database "+s,e)}}),asyncifyRequest2(e)}class f{constructor(e){RequireString2(e),this.name=e}async ready(){await lazyOpenDatabase2(this.name)}set(r,n){return RequireString2(r),openWriteTransaction2(this.name,async e=>{const t=e.objectStore(b).put(n,r),s=asyncifyRequest2(t),i=asyncifyTransaction2(e);await Promise.all([i,s])})}get(n){return RequireString2(n),openReadOnlyTransaction2(this.name,async e=>{const t=e.objectStore(b).get(n),s=asyncifyRequest2(t),i=asyncifyTransaction2(e),[,r]=await Promise.all([i,s]);return r})}delete(r){return RequireString2(r),openWriteTransaction2(this.name,async e=>{const t=e.objectStore(b).delete(r),s=asyncifyRequest2(t),i=asyncifyTransaction2(e);await Promise.all([i,s])})}clear(){return openWriteTransaction2(this.name,async e=>{const t=e.objectStore(b).clear(),s=asyncifyRequest2(t),i=asyncifyTransaction2(e);await Promise.all([i,s])})}keys(){return openReadOnlyTransaction2(this.name,async t=>{let s;if(e){const n=t.objectStore(b).getAllKeys();s=asyncifyRequest2(n)}else s=getEntriesFromCursor2(t,"keys");const i=asyncifyTransaction2(t),[,r]=await Promise.all([i,s]);return r})}values(){return openReadOnlyTransaction2(this.name,async e=>{let t;if(d){const r=e.objectStore(b).getAll();t=asyncifyRequest2(r)}else t=getEntriesFromCursor2(e,"values");const s=asyncifyTransaction2(e),[,i]=await Promise.all([s,t]);return i})}entries(){return openReadOnlyTransaction2(this.name,async e=>{const t=getEntriesFromCursor2(e,"entries"),s=asyncifyTransaction2(e),[,i]=await Promise.all([s,t]);return i})}}self.KVStorageContainer=f}{let NOT_IMPLEMENTED2=function(e){throw new Error(`"${e}" is not implemented`)},DISALLOW_CALLBACK2=function(e){if("function"==typeof e)throw new Error("localforage callback API is not implemented; please use the promise API instead")},StructuredClone2=function(i){return"object"==typeof i?new Promise(t=>{const{port1:e,port2:s}=new MessageChannel;s.onmessage=e=>t(e.data),e.postMessage(i)}):Promise.resolve(i)};NOT_IMPLEMENTED=NOT_IMPLEMENTED2,DISALLOW_CALLBACK=DISALLOW_CALLBACK2,StructuredClone=StructuredClone2;const a=self.KVStorageContainer,b=[/no available storage method found/i,/an attempt was made to break through the security policy of the user agent/i,/the user denied permission to access the database/i,/a mutation operation was attempted on a database that did not allow mutations/i,/idbfactory\.open\(\) called in an invalid security context/i],c=new WeakMap;class d{constructor(e){this._inst=e,this._isInMemory=!this._inst,this._isInMemory||"undefined"!=typeof indexedDB||(this._isInMemory=!0,console.warn("Unable to use local storage because IndexedDB API is not available")),this._memoryStorage=new Map}_MaybeSwitchToMemoryFallback(e){if(!this._isInMemory)for(const t of b)if(e&&t.test(e.message)){console.error("Unable to use local storage, reverting to in-memory store: ",e,e.message),this._isInMemory=!0;break}}async _getItemFallback(e){const t=this._memoryStorage.get(e),s=await StructuredClone2(t);return void 0===s?null:s}async _setItemFallback(e,t){t=await StructuredClone2(t),this._memoryStorage.set(e,t)}_removeItemFallback(e){this._memoryStorage.delete(e)}_clearFallback(){this._memoryStorage.clear()}_keysFallback(){return Array.from(this._memoryStorage.keys())}IsInMemory(){return this._isInMemory}GetMemoryStorage(){return this._memoryStorage}SetMemoryStorage(e){this._memoryStorage=e}async getItem(t,e){if(DISALLOW_CALLBACK2(e),this._isInMemory)return this._getItemFallback(t);let s;try{s=await this._inst.get(t)}catch(e){return this._MaybeSwitchToMemoryFallback(e),this._isInMemory?this._getItemFallback(t):(console.error(`Error reading '${t}' from storage, returning null: `,e),null)}return void 0===s?null:s}async setItem(t,s,e){if(DISALLOW_CALLBACK2(e),void 0===s&&(s=null),this._isInMemory)await this._setItemFallback(t,s);else try{await this._inst.set(t,s)}catch(e){if(this._MaybeSwitchToMemoryFallback(e),!this._isInMemory)throw e;await this._setItemFallback(t,s)}}async removeItem(t,e){if(DISALLOW_CALLBACK2(e),this._isInMemory)this._removeItemFallback(t);else try{await this._inst.delete(t)}catch(e){this._MaybeSwitchToMemoryFallback(e),this._isInMemory?this._removeItemFallback(t):console.error(`Error removing '${t}' from storage: `,e)}}async clear(e){if(DISALLOW_CALLBACK2(e),this._isInMemory)this._clearFallback();else try{await this._inst.clear()}catch(e){this._MaybeSwitchToMemoryFallback(e),this._isInMemory?this._clearFallback():console.error("Error clearing storage: ",e)}}async keys(e){if(DISALLOW_CALLBACK2(e),this._isInMemory)return this._keysFallback();let t=[];try{t=await this._inst.keys()}catch(e){if(this._MaybeSwitchToMemoryFallback(e),this._isInMemory)return this._keysFallback();console.error("Error getting storage keys: ",e)}return t}ready(e){return DISALLOW_CALLBACK2(e),this._isInMemory?Promise.resolve(!0):this._inst.ready()}createInstance(e){if(e.forceInMemoryFallback)return new d(null);{const t=e.name;if("string"!=typeof t)throw new TypeError("invalid store name");const s=new a(t);return new d(s)}}length(e){NOT_IMPLEMENTED2("localforage.length()")}key(e,t){NOT_IMPLEMENTED2("localforage.key()")}iterate(e,t){NOT_IMPLEMENTED2("localforage.iterate()")}setDriver(e){NOT_IMPLEMENTED2("localforage.setDriver()")}config(e){NOT_IMPLEMENTED2("localforage.config()")}defineDriver(e){NOT_IMPLEMENTED2("localforage.defineDriver()")}driver(){NOT_IMPLEMENTED2("localforage.driver()")}supports(e){NOT_IMPLEMENTED2("localforage.supports()")}dropInstance(){NOT_IMPLEMENTED2("localforage.dropInstance()")}}self.localforage=new d(new a("localforage"))}{const C33=self.C3;if(C33.Supports={},C33.Supports.WebAnimations=(()=>{try{if("undefined"==typeof document)return!1;const e=document.createElement("div");if(void 0===e.animate)return!1;const t=e.animate([{opacity:"0"},{opacity:"1"}],1e3);return void 0!==t.reverse}catch(e){return!1}})(),C33.Supports.DialogElement="undefined"!=typeof HTMLDialogElement,C33.Supports.RequestIdleCallback=!!self.requestIdleCallback,C33.Supports.ImageBitmap=!!self.createImageBitmap,C33.Supports.ImageBitmapOptions=!1,C33.Supports.ImageBitmapOptionsResize=!1,C33.Supports.ImageBitmap){try{self.createImageBitmap(new ImageData(32,32),{premultiplyAlpha:"none"}).then(()=>{C33.Supports.ImageBitmapOptions=!0}).catch(()=>{C33.Supports.ImageBitmapOptions=!1})}catch(e){C33.Supports.ImageBitmapOptions=!1}try{self.createImageBitmap(new ImageData(32,32),{resizeWidth:10,resizeHeight:10}).then(e=>{C33.Supports.ImageBitmapOptionsResize=10===e.width&&10===e.height}).catch(()=>{C33.Supports.ImageBitmapOptionsResize=!1})}catch(e){C33.Supports.ImageBitmapOptionsResize=!1}}if(C33.Supports.ClipboardReadText=!(!navigator.clipboard||!navigator.clipboard.readText),C33.Supports.PermissionsQuery=!(!navigator.permissions||!navigator.permissions.query),C33.Supports.ClipboardPermissionsQuery=!1,C33.Supports.PermissionsQuery){const g={name:"clipboard-read"};navigator.permissions.query(g).then(()=>{C33.Supports.ClipboardPermissionsQuery=!0}).catch(()=>{C33.Supports.ClipboardPermissionsQuery=!1})}C33.Supports.AsyncClipboardApi=!!(navigator.permissions&&navigator.clipboard&&self.ClipboardItem),C33.Supports.Proxies="undefined"!=typeof Proxy,C33.Supports.DownloadAttribute=(()=>{if("undefined"==typeof document)return!1;const e=document.createElement("a");return void 0!==e.download})(),C33.Supports.Fetch="function"==typeof fetch,C33.Supports.PersistentStorage=!!(self.isSecureContext&&"Opera"!==C33.Platform.Browser&&navigator.storage&&navigator.storage.persist),C33.Supports.StorageQuotaEstimate=!!(self.isSecureContext&&navigator.storage&&navigator.storage.estimate),C33.Supports.Fullscreen=(()=>{if("undefined"==typeof document)return!1;if("iOS"===C33.Platform.OS)return!1;const e=document.documentElement;return!!(e.requestFullscreen||e.msRequestFullscreen||e.mozRequestFullScreen||e.webkitRequestFullscreen)})(),C33.Supports.ImageDecoder=void 0!==self.ImageDecoder,C33.Supports.WebCodecs=!!self.VideoEncoder,C33.Supports.NativeFileSystemAPI=!!self.showOpenFilePicker,C33.Supports.QueryLocalFonts=!!self.queryLocalFonts,C33.Supports.UserActivation=!!navigator.userActivation,C33.Supports.CanvasToBlobWebP=!1,(async()=>{let t;"undefined"==typeof document?t=new OffscreenCanvas(32,32):((t=document.createElement("canvas")).width=32,t.height=32);const e=t.getContext("2d");e.fillStyle="blue",e.fillRect(0,0,32,32);let s=null;try{t.convertToBlob?s=await t.convertToBlob({type:"image/webp",quality:1}):t.toBlob&&(s=await new Promise(e=>t.toBlob(e,"image/webp",1))),C33.Supports.CanvasToBlobWebP=s&&"image/webp"===s.type}catch(e){C33.Supports.CanvasToBlobWebP=!1}})()}{let arrayFlat2=function(e,s){return e.reduce((e,t)=>(0<s&&Array.isArray(t)?Array.prototype.push.apply(e,arrayFlat2(t,s-1)):e.push(t),e),[])};arrayFlat=arrayFlat2;const C33=self.C3;if(!String.prototype.trimStart){const a=/^[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]*/;String.prototype.trimStart=function(){return this.replace(a,"")}}if(!String.prototype.trimEnd){const c=/[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]*$/;String.prototype.trimEnd=function(){return this.replace(c,"")}}String.prototype.replaceAll||(String.prototype.replaceAll=function(e,t){return this.replace(new RegExp(C33.EscapeRegex(e),"g"),t)}),Array.prototype.values||(Array.prototype.values=function*(){for(const e of this)yield e}),Array.prototype.flat||(Array.prototype.flat=function(e=1){return arrayFlat2(this,e)}),Array.prototype.at||(Array.prototype.at=function(e){if((e=Math.trunc(e)||0)<0&&(e+=this.length),!(e<0||e>=this.length))return this[e]}),String.prototype.at||(String.prototype.at=function(e){if((e=Math.trunc(e)||0)<0&&(e+=this.length),!(e<0||e>=this.length))return this[e]}),RegExp.escape||(RegExp.escape=function(e){return String(e).replace(/[\\^$*+?.()|[\]{}]/g,"\\$&")}),Set.prototype.isSubsetOf||(Set.prototype.isSubsetOf=function(e){if(!(e instanceof Set))throw new TypeError("argument must be a Set");for(const t of this)if(!e.has(t))return!1;return!0}),navigator.storage&&!navigator.storage.estimate&&navigator.webkitTemporaryStorage&&navigator.webkitTemporaryStorage.queryUsageAndQuota&&(navigator.storage.estimate=function(){return new Promise((s,e)=>navigator.webkitTemporaryStorage.queryUsageAndQuota((e,t)=>s({usage:e,quota:t}),e))}),void 0===self.isSecureContext&&(self.isSecureContext="https:"===location.protocol),void 0===self.globalThis&&(self.globalThis=self)}{let assertFail2=function(e){let t=C33.GetCallStack(),s="Assertion failure: "+e+"\n\nStack trace:\n"+t;console.error(s)};assertFail=assertFail2;const C33=self.C3;self.assert=function(e,t){e||assertFail2(t)}}{const C33=self.C3,C3X=self.C3X,TypedArray=(C33.IsNumber=function(e){return"number"==typeof e},C33.IsFiniteNumber=function(e){return C33.IsNumber(e)&&isFinite(e)},C33.RequireNumber=function(e){if(!C33.IsNumber(e))throw new TypeError("expected number")},C33.RequireOptionalNumber=function(e){C33.IsNullOrUndefined(e)},C33.RequireNumberInRange=function(e,t,s){if(!C33.IsNumber(e)||isNaN(e)||e<t||s<e)throw new RangeError("number outside of range")},C33.RequireAllNumber=function(...t){for(let e of t);},C33.RequireFiniteNumber=function(e){if(!C33.IsFiniteNumber(e))throw new TypeError("expected finite number")},C33.RequireOptionalFiniteNumber=function(e){C33.IsNullOrUndefined(e)},C33.RequireAllFiniteNumber=function(...t){for(let e of t);},C33.IsString=function(e){return"string"==typeof e},C33.RequireString=function(e){if(!C33.IsString(e))throw new TypeError("expected string")},C33.RequireOptionalString=function(e){C33.IsNullOrUndefined(e)},C33.RequireAllString=function(...t){for(let e of t);},C33.IsSimpleObject=function(e){if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);return t?t.constructor===Object:null===t},C33.RequireSimpleObject=function(e){if(!C33.IsSimpleObject(e))throw new TypeError("expected simple object")},C33.RequireOptionalSimpleObject=function(e){if(!C33.IsNullOrUndefined(e)&&!C33.IsSimpleObject(e))throw new TypeError("expected simple object")},C33.IsObject=function(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)},C33.RequireObject=function(e){if(!C33.IsObject(e))throw new TypeError("expected object")},C33.RequireOptionalObject=function(e){C33.IsNullOrUndefined(e)},C33.RequireAllObject=function(...t){for(let e of t);},C33.IsFileLike=function(e){return C33.WeakIsInstanceOf(e,Blob)&&"string"==typeof e.name},C33.RequireFileLike=function(e){if(!C33.IsFileLike(e))throw new TypeError("expected file")},C33.RequireOptionalFileLike=function(e){C33.IsNullOrUndefined(e)},C33.IsArray=function(e){return Array.isArray(e)},C33.RequireArray=function(e){if(!C33.IsArray(e))throw new TypeError("expected array")},C33.RequireOptionalArray=function(e){C33.IsNullOrUndefined(e)},C33.RequireAllArray=function(...t){for(let e of t);},C33.Is2DArray=function(e){return!(!C33.IsArray(e)||e.length&&!C33.IsArray(e[0]))},C33.Require2DArray=function(t){if(!C33.Is2DArray(t))throw new TypeError("expected 2d array");for(let e of t)if(!C33.IsArray(e))throw new TypeError("expected 2d array")},C33.RequireOptional2DArray=function(e){C33.IsNullOrUndefined(e)},C33.IsFunction=function(e){return"function"==typeof e},C33.RequireFunction=function(e,t){if(!C33.IsFunction(e))throw new TypeError("expected function");if(!C33.IsNullOrUndefined(t)&&e!==t)throw new TypeError("expected same function reference")},C33.RequireOptionalFunction=function(e){C33.IsNullOrUndefined(e)},C33.RequireAllFunction=function(...t){for(let e of t);},C33.RequireAnyFunction=function(t,...s){if(!C33.IsFunction(t))throw new TypeError("expected function");if(!s.length)throw new Error("missing comparison functions");for(let e of s)if(!C33.IsNullOrUndefined(e)&&t===e)return;throw new TypeError("expected same function reference")},C33.RequireOptionalAllFunction=function(...t){if(!C33.IsNullOrUndefined(t))for(let e of t);},C33.IsInstanceOf=function(e,t){return e instanceof t},C33.IsInstanceOfAny=function(t,...s){for(let e of s)if(C33.IsInstanceOf(t,e))return!0;return!1},C33.RequireInstanceOf=function(e,t){if(!C33.IsInstanceOf(e,t))throw new TypeError("unexpected type")},C33.RequireOptionalInstanceOf=function(e,t){C33.IsNullOrUndefined(e)},C33.RequireAllInstanceOf=function(e,...t){for(let e of t);},C33.RequireAnyInstanceOf=function(e,...t){if(!C33.IsInstanceOfAny(e,...t))throw new TypeError("unexpected type")},C33.RequireAnyOptionalInstanceOf=function(e,...t){if(!C33.IsNullOrUndefined(e)&&!C33.IsInstanceOfAny(e,...t))throw new TypeError("unexpected type")},C33.IsArrayOf=function(t,s){for(let e of t)if(!C33.IsInstanceOf(e,s))return!1;return!0},C33.IsArrayOfFiniteNumbers=function(t){for(let e of t)if(!C33.IsFiniteNumber(e))return!1;return!0},C33.RequireArrayOf=function(t,e){for(let e of t);},C33.RequireOptionalArrayOf=function(t,e){if(!C33.IsNullOrUndefined(t))for(let e of t);},C33.RequireOptionalArrayOfFunctions=function(t,e){if(!C33.IsNullOrUndefined(t))for(let e of t);},C33.RequireArrayOfAny=function(t){for(let e of t);},C33.RequireOptionalArrayOfAny=function(t){if(!C33.IsNullOrUndefined(t))for(let e of t);},C33.IsDOMNode=function(e,t){return!(C33.IsNullOrUndefined(e)||!C33.IsString(e.nodeName))&&(!t||C33.equalsNoCase(e.nodeName,t))},C33.RequireDOMNode=function(e,t){if(C33.IsNullOrUndefined(e)||!C33.IsString(e.nodeName))throw new TypeError("expected DOM node");if(t&&!C33.equalsNoCase(e.nodeName,t))throw new TypeError(`expected DOM '${t}' node`)},C33.RequireOptionalDOMNode=function(e,t){C33.IsNullOrUndefined(e)},C33.IsHTMLElement=function(e,t){return!(C33.IsNullOrUndefined(e)||!C33.IsString(e.tagName))&&(!t||C33.equalsNoCase(e.tagName,t))},C33.RequireHTMLElement=function(e,t){if(C33.IsNullOrUndefined(e)||!C33.IsString(e.tagName))throw new TypeError("expected HTML element");if(t&&!C33.equalsNoCase(e.tagName,t))throw new TypeError(`expected HTML '${t}' element`)},C33.RequireOptionalHTMLElement=function(e,t){C33.IsNullOrUndefined(e)},C33.IsDrawable=function(e){return C33.IsHTMLElement(e,"img")||C33.IsHTMLElement(e,"canvas")||C33.IsHTMLElement(e,"video")||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap},C33.RequireDrawable=function(e){if(!C33.IsDrawable(e))throw new TypeError("expected drawable")},C33.RequireOptionalDrawable=function(e){C33.IsNullOrUndefined(e)},C33.IsDrawableOrImageData=function(e){return e instanceof ImageData||C33.IsDrawable(e)},C33.RequireDrawableOrImageData=function(e){if(!C33.IsDrawableOrImageData(e))throw new TypeError("expected drawable or image data")},C33.RequireOptionalDrawableOrImageData=function(e){if(!C33.IsNullOrUndefined(e)&&!C33.IsDrawableOrImageData(e))throw new TypeError("expected drawable or image data")},C33.IsStringLike=function(e){return"string"==typeof e||C33.HtmlString&&e instanceof C33.HtmlString||e instanceof C33.BBString},C33.RequireStringLike=function(e){if(!C33.IsStringLike(e))throw new TypeError("expected string-like")},C33.RequireOptionalStringLike=function(e){C33.IsNullOrUndefined(e)},C33.RequireAllStringLike=function(...t){for(let e of t);},C33.RequireOverride=function(){throw new Error("must be overridden")},C33.NotYetImplemented=function(){throw new Error("not yet implemented")},C33.IsGeneratorFunction=function(e){return e.constructor===function*(){}.constructor},C33.RequireGeneratorFunction=function(e){if(!C33.IsGeneratorFunction(e))throw new Error("expected generator function")},C33.IsIterable=function(e){return"function"===e[Symbol.iterator]},C33.RequireIterable=function(e){if(!C33.IsIterable(e))throw new Error("expected iterable")},C33.IsDefined=function(e){return!C33.IsNullOrUndefined(e)},C33.IsNullOrUndefined=function(e){return null==e},C33.AreArrayElementsOfSameType=function(t){let s=t[0].constructor;for(let e of t)if(e.constructor!==s)return!1;return s},C33.AreArrayElementsOfType=function(t,s){for(let e of t)if(!(e instanceof s))return!1;return!0},Object.getPrototypeOf(Uint8Array));C33.IsTypedArray=function(e){return C33.IsInstanceOf(e,TypedArray)},C33.RequireTypedArray=function(e){},C33.WeakRequireTypedArray=function(e){C33.WeakRequireInstanceOf(e,TypedArray)},C33.WeakRequireAnyInstanceOf=function(e,...t){if(!C33.WeakIsAnyInstanceOf(e,...t))throw new TypeError("unexpected type")},C33.WeakIsAnyInstanceOf=function(e,...t){for(const s of t)if(C33.WeakIsInstanceOf(e,s))return!0;return!1},C33.WeakRequireInstanceOf=function(e,t){if(!C33.WeakIsInstanceOf(e,t))throw new TypeError("unexpected type")},C33.WeakIsInstanceOf=function(e,t){for(;e=Object.getPrototypeOf(e);)if(e.constructor.name===t.name)return!0;return!1},C3X.RequireNumber=C33.RequireNumber,C3X.RequireOptionalNumber=C33.RequireOptionalNumber,C3X.RequireFiniteNumber=C33.RequireFiniteNumber,C3X.RequireOptionalFiniteNumber=C33.RequireOptionalFiniteNumber,C3X.RequireString=C33.RequireString,C3X.RequireOptionalString=C33.RequireOptionalString,C3X.RequireObject=C33.RequireObject,C3X.RequireOptionalObject=C33.RequireOptionalObject,C3X.RequireArray=C33.RequireArray,C3X.RequireOptionalArray=C33.RequireOptionalArray,C3X.RequireFunction=C33.RequireFunction,C3X.RequireOptionalFunction=C33.RequireOptionalFunction,C3X.RequireInstanceOf=C33.RequireInstanceOf,C3X.RequireOptionalInstanceOf=C33.RequireOptionalInstanceOf,C3X.IsNullOrUndefined=C33.IsNullOrUndefined}{let isValidTypeChange2=function(e,t){let s=C33.getType(e),i=C33.getType(t);return"null"===s||"null"===i||"undefined"!==s&&"undefined"!==i&&s===i},logDefendedObjectWarning2=function(e){console.warn("[Defence] "+e+" @",C33.GetCallStack())},CheckDefendedObjectsUsedCorrectly2=function(){if(checkRafId=-1,0<ctorObjectToProxy.size||0<ctorProxyToObject.size){let e=new Set([...ctorObjectToProxy.keys()].map(e=>C33.getName(e))),t=[...e].join(",");console.warn("An object derived from DefendedBase was not protected with debugDefend(). This will disable some checks. See the coding guidelines! Possible affected class names: "+t),ctorObjectToProxy.clear(),ctorProxyToObject.clear()}},getObjectPropertySet2=function(t){let s=new Set;for(let e in t)s.add(e);return s},VerifyObjectPropertiesConsistent2=function(e,t){let s=getObjectPropertySet2(t),i=typeProperties.get(e);if(i){let t=[];for(let e of i.values())s.has(e)?s.delete(e):t.push(e);C33.appendArray(t,[...s]),t.length&&console.warn(`[Defence] '${C33.getName(e)}' constructor creates inconsistent properties: `+t.join(", "))}else typeProperties.set(e,s)};isValidTypeChange=isValidTypeChange2,logDefendedObjectWarning=logDefendedObjectWarning2,CheckDefendedObjectsUsedCorrectly=CheckDefendedObjectsUsedCorrectly2,getObjectPropertySet=getObjectPropertySet2,VerifyObjectPropertiesConsistent=VerifyObjectPropertiesConsistent2;const C33=self.C3,logRafIds=new Map;C33.ColorLog=function(e,t){console.log("%c"+e,"font-weight: bold; color:"+t)},C33.RafLog=function(e,...t){logRafIds.has(e)||logRafIds.set(e,-1),-1===logRafIds.get(e)&&logRafIds.set(e,requestAnimationFrame(()=>{console.log("%c"+e,"font-weight: bold",...t),logRafIds.set(e,-1)}))};let measures,ctorObjectToProxy=(C33.StartMeasure=function(e){performance.mark(e),(measures=measures||new Map).has(e)||measures.set(e,{current:0,total:0,average:0,calls:1,toString:function(){return`${e} :: current => ${this.current.toPrecision(3)} :: average => ${this.average.toPrecision(3)} :: calls => `+this.calls}})},C33.EndMeasure=function(e){performance.measure("measure-"+e,e);const t=performance.getEntriesByName("measure-"+e)[0],s=measures.get(e);s.current=t.duration,s.total+=s.current,s.average=s.total/s.calls,console.log(s.toString()),s.calls++,performance.clearMarks(e),performance.clearMeasures("measure-"+e)},C33.GetCallStack=function(){return(new Error).stack},C33.Debugger=function(){},C33.cast=function(e,t){return e&&e instanceof t?e:null},C33.getName=function(e){return void 0===e?"undefined":null===e?"null":"boolean"==typeof e?"<boolean>":C33.IsNumber(e)?"<number>":C33.IsString(e)?"<string>":C33.IsArray(e)?"<array>":"symbol"==typeof e?"<"+e.toString()+">":C33.IsFunction(e)?e.name&&"Function"!==e.name?e.name:"<anonymous function>":"object"==typeof e?e.constructor&&e.constructor.name&&"Object"!==e.constructor.name?e.constructor.name:"<anonymous object>":"<unknown>"},C33.getType=function(e){return null===e?"null":Array.isArray(e)?"array":typeof e},C33.range=function*(t,s){if(!isFinite(Math.abs(t-s)))throw new Error("Invalid parameters");if(s<t)for(let e=t-1;e>=s;e--)yield e;else for(let e=t;e<s;e++)yield e},new Map),ctorProxyToObject=new Map,proxyToObject=new WeakMap,releasedObjects=new WeakMap;C33.DefendHandler={};const VALID_GET_MISSING_KEYS=new Set(["then","splice"]);C33.DefendHandler.get=function(e,t){return t in e||"symbol"==typeof t||VALID_GET_MISSING_KEYS.has(t)||logDefendedObjectWarning2(`Accessed missing property '${t}' from defended object '${C33.getName(e)}', returning undefined`),releasedObjects.has(e)&&"symbol"!=typeof t&&!VALID_GET_MISSING_KEYS.has(t)&&logDefendedObjectWarning2(`Accessed property '${t}' on a released object '${C33.getName(e)}' Object was originally released at: ${releasedObjects.get(e)}) Call stack at access: `),e[t]},C33.DefendHandler.set=function(e,t,s){return t in e||ctorObjectToProxy.has(e)||logDefendedObjectWarning2(`Set non-existent property '${t}' to '${s}' on defended object '${C33.getName(e)}'`),isValidTypeChange2(e[t],s)||ctorObjectToProxy.has(e)||logDefendedObjectWarning2(`Set '${C33.getType(e[t])}' property '${t}' to type '${C33.getType(s)}' on defended object '${C33.getName(e)}'`),releasedObjects.has(e)&&logDefendedObjectWarning2(`Set property '${t}' on a released object '${C33.getName(e)}' Object was originally released at: ${releasedObjects.get(e)}) Call stack at access: `),e[t]=s,!0},C33.DefendHandler.deleteProperty=function(e,t){throw new ReferenceError(`Cannot delete property '${t}' from defended object '${C33.getName(e)}'`)},C33.DefendHandler.defineProperty=function(e,t,s){throw new ReferenceError(`Cannot define property '${t}' on defended object '${C33.getName(e)}'`)},C33.DefendHandler.enumerate=function(e){throw new ReferenceError(`Cannot enumerate defended object '${C33.getName(e)}'`)};let checkRafId=-1,typeProperties=(C33.DefendedBase=class{constructor(){if(C33.isDebugDefend&&C33.Supports.Proxies){let e=Object.create(new.target.prototype),t=new Proxy(e,C33.DefendHandler);return ctorObjectToProxy.set(e,t),ctorProxyToObject.set(t,e),proxyToObject.set(t,e),-1===checkRafId&&(checkRafId=requestAnimationFrame(CheckDefendedObjectsUsedCorrectly2)),t}}},C33.debugDefend=function(t){if(C33.isDebugDefend&&C33.Supports.Proxies&&t instanceof C33.DefendedBase){if(ctorProxyToObject.has(t)){let e=ctorProxyToObject.get(t);ctorProxyToObject.delete(t),ctorObjectToProxy.delete(e)}return t}return C33.isDebug?Object.seal(t):t},C33.New=function(e,...t){let s;try{s=new e(...t)}catch(e){throw ctorProxyToObject.clear(),ctorObjectToProxy.clear(),e}return C33.isDebugDefend&&VerifyObjectPropertiesConsistent2(e,s),C33.debugDefend(s)},C33.Release=function(e){let t=proxyToObject.get(e);t&&releasedObjects.set(t,C33.GetCallStack())},C33.WasReleased=function(e){let t=proxyToObject.get(e);return!!t&&!!releasedObjects.get(t)},new Map);C33.PerfMark=class{constructor(e){this._name="",e&&this.start(e)}start(e){C33.isPerformanceProfiling&&(this._name=e,performance.mark(this._name+"-Start"))}end(){C33.isPerformanceProfiling&&(performance.mark(this._name+"-End"),performance.measure(this._name,this._name+"-Start",this._name+"-End"))}next(e){C33.isPerformanceProfiling&&(this.end(),this._name=e,performance.mark(this._name+"-Start"))}}}{let isNegativeZero2=function(e){return 0===e&&1/e<0};isNegativeZero=isNegativeZero2;const C33=self.C3,TWO_PI=2*Math.PI,D_TO_R=Math.PI/180,R_TO_D=180/Math.PI,ALPHAEX_SHIFT=(C33.wrap=function(e,t,s){e=Math.floor(e),t=Math.floor(t);const i=(s=Math.floor(s))-t;if(0==i)return s;if(e<t){const r=s-(t-e)%i;return r===s?0:r}return t+(e-t)%i},C33.mapToRange=function(e,t,s,i,r){const n=s-t;if(0==n&&0===i)return e;const a=r-i;return(e-t)*a/n+i},C33.normalize=function(e,t,s){return t-s==0?1:(e-t)/(s-t)},C33.clamp=function(e,t,s){return e<t?t:s<e?s:e},C33.clampAngle=function(e){return(e%=TWO_PI)<0&&(e+=TWO_PI),e},C33.toRadians=function(e){return e*D_TO_R},C33.toDegrees=function(e){return e*R_TO_D},C33.hypot2DFast=function(e,t){return Math.sqrt(e*e+t*t)},C33.hypot3DFast=function(e,t,s){return Math.sqrt(e*e+t*t+s*s)},C33.distanceTo=function(e,t,s,i){return C33.hypot2DFast(s-e,i-t)},C33.distanceSquared=function(e,t,s,i){const r=s-e,n=i-t;return r*r+n*n},C33.angleTo=function(e,t,s,i){return Math.atan2(i-t,s-e)},C33.angleDiff=function(e,t){if(e===t)return 0;let s=Math.sin(e),i=Math.cos(e),r=Math.sin(t),n=Math.cos(t),a=s*r+i*n;return 1<=a?0:a<=-1?Math.PI:Math.acos(a)},C33.angleRotate=function(e,t,s){let i=Math.sin(e),r=Math.cos(e),n=Math.sin(t),a=Math.cos(t);return Math.acos(i*n+r*a)>s?0<r*n-i*a?C33.clampAngle(e+s):C33.clampAngle(e-s):C33.clampAngle(t)},C33.angleClockwise=function(e,t){let s=Math.sin(e),i=Math.cos(e),r=Math.sin(t),n=Math.cos(t);return i*r-s*n<=0},C33.angleLerp=function(e,t,s,i=0){let r=C33.angleDiff(e,t),n=TWO_PI*i;return C33.angleClockwise(t,e)?C33.clampAngle(e+(r+n)*s):C33.clampAngle(e-(r+n)*s)},C33.angleLerpClockwise=function(e,t,s,i=0){const r=C33.angleDiff(e,t),n=TWO_PI*i;return C33.angleClockwise(t,e)?C33.clampAngle(e+(r+n)*s):C33.clampAngle(e+(TWO_PI-r+n)*s)},C33.angleLerpAntiClockwise=function(e,t,s,i=0){const r=C33.angleDiff(e,t),n=TWO_PI*i;return C33.angleClockwise(t,e)?C33.clampAngle(e-(-TWO_PI+r-n)*s):C33.clampAngle(e-(r+n)*s)},C33.angleReflect=function(e,t){const s=C33.angleDiff(e,t);return C33.angleClockwise(e,t)?C33.clampAngle(t-s):C33.clampAngle(t+s)},C33.lerp=function(e,t,s){return e+s*(t-e)},C33.unlerp=function(e,t,s){return e===t?0:(s-e)/(t-e)},C33.relerp=function(e,t,s,i,r){return C33.lerp(i,r,C33.unlerp(e,t,s))},C33.qarp=function(e,t,s,i){return C33.lerp(C33.lerp(e,t,i),C33.lerp(t,s,i),i)},C33.cubic=function(e,t,s,i,r){return C33.lerp(C33.qarp(e,t,s,r),C33.qarp(t,s,i,r),r)},C33.cosp=function(e,t,s){return(e+t+(e-t)*Math.cos(s*Math.PI))/2},C33.isPOT=function(e){return 0<e&&0==(e-1&e)},C33.nextHighestPowerOfTwo=function(t){--t;for(let e=1;e<32;e<<=1)t|=t>>e;return t+1},C33.roundToNearestFraction=function(e,t){return Math.round(e*t)/t},C33.floorToNearestFraction=function(e,t){return Math.floor(e*t)/t},C33.roundToDp=function(e,t){t=Math.max(Math.floor(t),0);const s=Math.pow(10,t);return Math.round(e*s)/s},C33.countDecimals=function(e){return Math.floor(e)!==e&&e.toString().split(".")[1].length||0},C33.toFixed=function(e,t){let s=e.toFixed(t),i=s.length-1;for(;0<=i&&"0"===s.charAt(i);--i);return 0<=i&&"."===s.charAt(i)&&--i,i<0?s:s.substr(0,i+1)},C33.PackRGB=function(e,t,s){return C33.clamp(e,0,255)|C33.clamp(t,0,255)<<8|C33.clamp(s,0,255)<<16},1024),ALPHAEX_MAX=1023,RGBEX_SHIFT=16384,RGBEX_MAX=8191,RGBEX_MIN=-8192,COMMON_ASPECT_RATIOS=(C33.PackRGBAEx=function(e,t,s,i){return e=C33.clamp(Math.floor(1024*e),RGBEX_MIN,RGBEX_MAX),t=C33.clamp(Math.floor(1024*t),RGBEX_MIN,RGBEX_MAX),s=C33.clamp(Math.floor(1024*s),RGBEX_MIN,RGBEX_MAX),i=C33.clamp(Math.floor(i*ALPHAEX_MAX),0,ALPHAEX_MAX),e<0&&(e+=RGBEX_SHIFT),t<0&&(t+=RGBEX_SHIFT),s<0&&(s+=RGBEX_SHIFT),-(e*RGBEX_SHIFT*RGBEX_SHIFT*ALPHAEX_SHIFT+t*RGBEX_SHIFT*ALPHAEX_SHIFT+s*ALPHAEX_SHIFT+i)},C33.PackRGBEx=function(e,t,s){return C33.PackRGBAEx(e,t,s,1)},C33.GetRValue=function(t){if(0<=t)return(255&t)/255;{let e=Math.floor(-t/(RGBEX_SHIFT*RGBEX_SHIFT*ALPHAEX_SHIFT));return e>RGBEX_MAX&&(e-=RGBEX_SHIFT),e/1024}},C33.GetGValue=function(t){if(0<=t)return((65280&t)>>8)/255;{let e=Math.floor(-t%(RGBEX_SHIFT*RGBEX_SHIFT*ALPHAEX_SHIFT)/(RGBEX_SHIFT*ALPHAEX_SHIFT));return e>RGBEX_MAX&&(e-=RGBEX_SHIFT),e/1024}},C33.GetBValue=function(t){if(0<=t)return((16711680&t)>>16)/255;{let e=Math.floor(-t%(RGBEX_SHIFT*ALPHAEX_SHIFT)/ALPHAEX_SHIFT);return e>RGBEX_MAX&&(e-=RGBEX_SHIFT),e/1024}},C33.GetAValue=function(e){if(isNegativeZero2(e))return 0;if(0<=e)return 1;{const t=Math.floor(-e%ALPHAEX_SHIFT);return t/ALPHAEX_MAX}},C33.greatestCommonDivisor=function(t,s){for(t=Math.floor(t),s=Math.floor(s);0!==s;){let e=s;s=t%s,t=e}return t},[[3,2],[4,3],[5,4],[5,3],[6,5],[14,9],[16,9],[16,10],[21,9]]),NO_HIT=(C33.getAspectRatio=function(s,i){if((s=Math.floor(s))===(i=Math.floor(i)))return[1,1];for(let t of COMMON_ASPECT_RATIOS){let e=s/t[0]*t[1];if(Math.abs(i-e)<1)return t.slice(0);if(e=s/t[1]*t[0],Math.abs(i-e)<1)return[t[1],t[0]]}let e=C33.greatestCommonDivisor(s,i);return[s/e,i/e]},C33.segmentsIntersect=function(e,t,s,i,r,n,a,o){const l=Math.min(e,s),h=Math.max(e,s),c=Math.min(r,a),u=Math.max(r,a);if(h<c||u<l)return!1;const _=Math.min(t,i),d=Math.max(t,i),p=Math.min(n,o),m=Math.max(n,o);if(d<p||m<_)return!1;const g=r-e+a-s,f=n-t+o-i,S=s-e,C=i-t,y=a-r,G=o-n,I=Math.abs(C*y-G*S),T=y*f-G*g;if(Math.abs(T)>I)return!1;const b=S*f-C*g;return Math.abs(b)<=I},C33.segmentsIntersectPreCalc=function(e,t,s,i,r,n,a,o,l,h,c,u){const _=Math.min(l,c),d=Math.max(l,c);if(n<_||d<r)return!1;const p=Math.min(h,u),m=Math.max(h,u);if(o<p||m<a)return!1;const g=l-e+c-s,f=h-t+u-i,S=s-e,C=i-t,y=c-l,G=u-h,I=Math.abs(C*y-G*S),T=y*f-G*g;if(Math.abs(T)>I)return!1;const b=S*f-C*g;return Math.abs(b)<=I},C33.segmentIntersectsQuad=function(e,t,s,i,r){const n=Math.min(e,s),a=Math.max(e,s),o=Math.min(t,i),l=Math.max(t,i),h=r.getTlx(),c=r.getTly(),u=r.getTrx(),_=r.getTry(),d=r.getBrx(),p=r.getBry(),m=r.getBlx(),g=r.getBly();return C33.segmentsIntersectPreCalc(e,t,s,i,n,a,o,l,h,c,u,_)||C33.segmentsIntersectPreCalc(e,t,s,i,n,a,o,l,u,_,d,p)||C33.segmentsIntersectPreCalc(e,t,s,i,n,a,o,l,d,p,m,g)||C33.segmentsIntersectPreCalc(e,t,s,i,n,a,o,l,m,g,h,c)},C33.segmentIntersectsAnyN=function(t,s,i,r,n){let a=Math.min(t,i),o=Math.max(t,i),l=Math.min(s,r),h=Math.max(s,r),c=0;for(let e=n.length-4;c<=e;c+=2)if(C33.segmentsIntersectPreCalc(t,s,i,r,a,o,l,h,n[c],n[c+1],n[c+2],n[c+3]))return!0;return C33.segmentsIntersectPreCalc(t,s,i,r,a,o,l,h,n[c],n[c+1],n[0],n[1])},2),PADDING=1e-6;C33.rayIntersect=function(e,t,s,i,r,n,a,o){const l=s-e,h=i-t,c=a-r,u=o-n,_=l*u-h*c;if(0==_)return NO_HIT;const d=((t-i)*(a-e)+l*(o-t))/_;return 0<d&&d<1+PADDING?(u*(a-e)+(r-a)*(o-t))/_:NO_HIT},C33.rayIntersectExtended=function(e,t,s,i,r,n,a,o,l){const h=(a-r)*l,c=(o-n)*l;return C33.rayIntersect(e,t,s,i,r-h,n-c,a+h,o+c)},C33.isPointInTriangleInclusive=function(e,t,s,i,r,n,a,o){const l=r-s,h=n-i,c=a-s,u=o-i,_=e-s,d=t-i,p=l*l+h*h,m=l*c+h*u,g=l*_+h*d,f=c*c+u*u,S=c*_+u*d,C=1/(p*f-m*m),y=(f*g-m*S)*C,G=(p*S-m*g)*C;return 0<=y&&0<=G&&y+G<=1},C33.triangleCartesianToBarycentric=function(e,t,s,i,r,n,a,o){const l=r-s,h=n-i,c=a-s,u=o-i,_=e-s,d=t-i,p=l*l+h*h,m=l*c+h*u,g=c*c+u*u,f=_*l+d*h,S=_*c+d*u,C=p*g-m*m,y=(g*f-m*S)/C,G=(p*S-m*f)/C,I=1-y-G;return[I,y,G]},C33.triangleBarycentricToCartesian3d=function(e,t,s,i,r,n,a,o,l,h,c,u){return[e*i+t*a+s*h,e*r+t*o+s*c,e*n+t*l+s*u]}}{let C33=self.C3,mainDocument=null,baseHref="";if("undefined"!=typeof document){const a=(mainDocument=document).querySelector("base");(baseHref=a&&a.hasAttribute("href")?a.getAttribute("href"):"")&&!(baseHref=baseHref.startsWith("/")?baseHref.substr(1):baseHref).endsWith("/")&&(baseHref+="/")}C33.GetBaseHref=function(){return baseHref},C33.GetBaseURL=function(){if(!mainDocument)return"";const e=mainDocument.location;return C33.GetPathFromURL(e.origin+e.pathname)+baseHref},C33.GetPathFromURL=function(e){if(!e.length)return e;if(e.endsWith("/")||e.endsWith("\\"))return e;const t=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));return-1===t?"":e.substr(0,t+1)},C33.GetFilenameFromURL=function(e){if(!e.length)return e;if(e.endsWith("/")||e.endsWith("\\"))return"";const t=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));return-1===t?e:e.substr(t+1)},C33.GetFileExtension=function(e){let t=e.lastIndexOf(".");return t<1?"":e.substr(t)},C33.SetFileExtension=function(e,t){const s=e.lastIndexOf(".");return-1===s?e+"."+t:e.substr(0,s+1)+t},C33.GetFileNamePart=function(e){let t=e.lastIndexOf(".");return t<1?e:e.substr(0,t)},C33.NormalizeFileSeparator=function(e){return e.replace(/\\/g,"/")},C33.IsFileExtension=function(e,t){const s=e?C33.GetFileExtension(e).slice(1):"";return t===s},C33.FileNameEquals=function(e,t){let s,i;return C33.IsFileLike(e)&&(s=C33.GetFileNamePart(e.name)),C33.IsString(e)&&(s=C33.GetFileNamePart(e)),C33.IsFileLike(t)&&(i=C33.GetFileNamePart(t.name)),C33.IsString(t)&&(i=C33.GetFileNamePart(t)),s===i},C33.ParseFilePath=function(e){e=C33.NormalizeFileSeparator(e);let t=/^\w\:\//.exec(e),s=(t?(t=t[0],"/"!==(e=e.slice(3))[0]&&(e="/"+e)):t="",(e=1<(e=e.replace(/\/{2,}/g,"/")).length&&"/"===e.slice(-1)?e.slice(0,-1):e).lastIndexOf("/")+1),i="",r=e,n,a="";0<s&&(i=e.slice(0,s),r=e.slice(s));const o=(n=r).lastIndexOf("."),l=(0<o&&(a=r.slice(o),n=r.slice(0,-a.length)),t+i+r);return{dir:i,base:r,name:n,root:t,ext:a,full:l}},C33.Wait=function(s,i){return new Promise((e,t)=>{self.setTimeout(e,s,i)})},C33.swallowException=function(e){try{e()}catch(e){C33.isDebug&&console.warn("Swallowed exception: ",e)}},C33.noop=function(){},C33.equalsNoCase=function(e,t){return"string"==typeof e&&"string"==typeof t&&(e===t||e.normalize().toLowerCase()===t.normalize().toLowerCase())},C33.equalsCase=function(e,t){return"string"==typeof e&&"string"==typeof t&&(e===t||e.normalize()===t.normalize())},C33.typedArraySet16=function(e,t,s){e[s++]=t[0],e[s++]=t[1],e[s++]=t[2],e[s++]=t[3],e[s++]=t[4],e[s++]=t[5],e[s++]=t[6],e[s++]=t[7],e[s++]=t[8],e[s++]=t[9],e[s++]=t[10],e[s++]=t[11],e[s++]=t[12],e[s++]=t[13],e[s++]=t[14],e[s]=t[15]},C33.truncateArray=function(e,t){e.length=t},C33.clearArray=function(e){e&&0!==e.length&&C33.truncateArray(e,0)},C33.clear2DArray=function(s){if(s){for(let t=0;t<s.length;t++){let e=s[t];C33.truncateArray(e,0)}C33.truncateArray(s,0)}},C33.extendArray=function(t,s,i){const r=t.length;if(!((s|=0)<=r))for(let e=r;e<s;++e)t.push(i)},C33.resizeArray=function(e,t,s){const i=e.length;(t|=0)<i?C33.truncateArray(e,t):i<t&&C33.extendArray(e,t,s)},C33.shallowAssignArray=function(e,t){C33.clearArray(e),C33.appendArray(e,t)},C33.appendArray=function(s,i){if(i.length<1e4)s.push(...i);else for(let e=0,t=i.length;e<t;++e)s.push(i[e])},C33.arrayRemove=function(s,i){if(!((i=Math.floor(i))<0||i>=s.length)){let t=s.length-1;for(let e=i;e<t;++e)s[e]=s[e+1];C33.truncateArray(s,t)}},C33.arrayFindRemove=function(e,t){let s=e.indexOf(t);0<=s&&e.splice(s,1)},C33.arraysEqual=function(t,s){let i=t.length;if(s.length!==i)return!1;for(let e=0;e<i;++e)if(t[e]!==s[e])return!1;return!0},C33.arrayFilterOut=function(s,i){let r=[],n=0;for(let t=0,e=s.length;t<e;++t){let e=s[t];i(e)?r.push(e):(s[n]=e,++n)}return C33.truncateArray(s,n),r},C33.arrayRemoveAllInSet=function(s,i){let e=s.length,r=0;for(let t=0,e=s.length;t<e;++t){let e=s[t];i.has(e)||(s[r++]=e)}return C33.truncateArray(s,r),e-r},C33.isArrayIndexInBounds=function(e,t){return e===Math.floor(e)&&0<=e&&e<t.length},C33.validateArrayIndex=function(e,t){if(!C33.isArrayIndexInBounds(e,t))throw new RangeError("array index out of bounds")},C33.cloneArray=function(e){return e.slice()},C33.deepCloneArray=function(e,s){let i=[];for(let t of e)if(C33.IsObject(t)){let e=s(t);if(!e)throw new Error("missing clone");if(e.constructor!==t.constructor)throw new Error("object is not a clone");i.push(e)}else C33.IsArray(t)?i.push(C33.deepCloneArray(t,s)):i.push(t);return i},C33.clone2DArray=function(t){let s=[];for(let e of t)s.push(e.slice());return s},C33.splitStringAndNormalize=function(e,t=" "){return e?e.split(t).map(e=>e.trim()).filter(e=>!!e):[]},C33.filterSet=function(e,t,s){const i=new Set;for(const r of e.values())t(r)&&(s?i.add(s(r)):i.add(r));return i},C33.mergeSets=function(e,t){return e.union?e.union(t):new Set([...e,...t])},C33.mergeSetsInPlace=function(e,t){for(const s of t)e.add(s);return e},C33.first=function(t){for(let e of t)return e;return null},C33.xor=function(e,t){return!e!=!t},C33.compare=function(e,t,s){switch(t){case 0:return e===s;case 1:return e!==s;case 2:return e<s;case 3:return e<=s;case 4:return s<e;case 5:return s<=e;default:return!1}},C33.hasAnyOwnProperty=function(t){for(let e in t)if(t.hasOwnProperty(e))return!0;return!1},C33.PromiseAllWithProgress=function(o,l){return o.length?new Promise((s,i)=>{let r=[],n=0,a=!1;for(let t=0,e=o.length;t<e;++t)r.push(void 0),o[t].then(e=>{a||(r[t]=e,++n===o.length?s(r):l(n,o.length))}).catch(e=>{a=!0,i(e)})}):Promise.resolve([])};let memoryCallbacks=[],nextTaskId=(C33.AddLibraryMemoryCallback=function(e){memoryCallbacks.push(e)},C33.GetEstimatedLibraryMemoryUsage=function(){let s=0;for(let t of memoryCallbacks){let e=t();s+=e}return Math.floor(s)},1),activeTaskIds=new Map,taskMessageChannel=new MessageChannel,activeRPAFids=(taskMessageChannel.port2.onmessage=function(e){const t=e.data,s=activeTaskIds.get(t);activeTaskIds.delete(t),s&&s(performance.now())},C33.RequestUnlimitedAnimationFrame=function(e){const t=nextTaskId++;return activeTaskIds.set(t,e),taskMessageChannel.port1.postMessage(t),t},C33.CancelUnlimitedAnimationFrame=function(e){activeTaskIds.delete(e)},C33.PostTask=C33.RequestUnlimitedAnimationFrame,C33.WaitForNextTask=function(){return new Promise(e=>C33.PostTask(e))},new Set);C33.RequestPostAnimationFrame=function(t){const s=self.requestAnimationFrame(async e=>{await C33.WaitForNextTask(),activeRPAFids.has(s)&&(activeRPAFids.delete(s),t(e))});return activeRPAFids.add(s),s},C33.CancelPostAnimationFrame=function(e){activeRPAFids.has(e)&&(self.cancelAnimationFrame(e),activeRPAFids.delete(e))}}{const C33=self.C3;C33.IsAbsoluteURL=function(e){return/^(?:[a-z\-]+:)?\/\//.test(e)||"data:"===e.substr(0,5)||"blob:"===e.substr(0,5)},C33.IsRelativeURL=function(e){return!C33.IsAbsoluteURL(e)},C33.ThrowIfNotOk=function(e){if(!e.ok)throw new Error(`fetch '${e.url}' response returned ${e.status} `+e.statusText)},C33.FetchOk=function(e,t){return fetch(e,t).then(e=>(C33.ThrowIfNotOk(e),e))},C33.FetchText=function(e){return C33.FetchOk(e).then(e=>e.text())},C33.FetchJson=function(e){return C33.FetchOk(e).then(e=>e.json())},C33.FetchBlob=function(e){return C33.FetchOk(e).then(e=>e.blob())},C33.FetchArrayBuffer=function(e){return C33.FetchOk(e).then(e=>e.arrayBuffer())},C33.FetchImage=function(i){return new Promise((e,t)=>{const s=new Image;s.onload=()=>e(s),s.onerror=e=>t(e),s.src=i})},C33.BlobToArrayBuffer=function(i){return"function"==typeof i.arrayBuffer?i.arrayBuffer():new Promise((e,t)=>{const s=new FileReader;s.onload=()=>e(s.result),s.onerror=()=>t(s.error),s.readAsArrayBuffer(i)})},C33.BlobToString=function(i){return"function"==typeof i.text?i.text():new Promise((e,t)=>{const s=new FileReader;s.onload=()=>e(s.result),s.onerror=()=>t(s.error),s.readAsText(i)})},C33.BlobToJson=function(e){return C33.BlobToString(e).then(e=>JSON.parse(e))},C33.BlobToImage=async function(e,t){let s=URL.createObjectURL(e);try{const i=await C33.FetchImage(s);return URL.revokeObjectURL(s),s="",t&&"function"==typeof i.decode&&await i.decode(),i}finally{s&&URL.revokeObjectURL(s)}},C33.CreateCanvas=function(e,t){if("undefined"==typeof document||"function"!=typeof document.createElement)return new OffscreenCanvas(e,t);{const s=document.createElement("canvas");return s.width=e,s.height=t,s}},C33.CanvasToBlob=function(t,s,i){if("number"!=typeof i&&(i=1),s=s||"image/png",i=C33.clamp(i,0,1),t.convertToBlob)return t.convertToBlob({type:s,quality:i});if(t.toBlob)return new Promise(e=>t.toBlob(e,s,i));throw new Error("could not convert canvas to blob")},C33.DrawableToBlob=function(e,t,s){const i=C33.CreateCanvas(e.width,e.height),r=i.getContext("2d");return r.drawImage(e,0,0),C33.CanvasToBlob(i,t,s)},C33.ImageDataToBlob=function(e,t,s){if(C33.Supports.ImageBitmapOptions)return createImageBitmap(e,{premultiplyAlpha:"none"}).then(e=>C33.DrawableToBlob(e,t,s));if(C33.Supports.ImageBitmap)return createImageBitmap(e).then(e=>C33.DrawableToBlob(e,t,s));{const i=C33.CreateCanvas(e.width,e.height),r=i.getContext("2d");return r.putImageData(e,0,0),C33.CanvasToBlob(i,t,s)}},C33.CopySet=function(e,t){e.clear();for(const s of t)e.add(s)},C33.MapToObject=function(e){const t=Object.create(null);for(const[s,i]of e.entries())t[s]=i;return t},C33.ObjectToMap=function(e,t){t.clear();for(const[s,i]of Object.entries(e))t.set(s,i)},C33.ToSuperJSON=function t(e){if("object"!=typeof e||null===e)return e;if(e instanceof Set)return{_c3type_:"set",data:[...e].map(e=>t(e))};if(e instanceof Map)return{_c3type_:"map",data:[...e].map(e=>[e[0],t(e[1])])};{const s=Object.create(null);for(const[i,r]of Object.entries(e))s[i]=t(r);return s}},C33.FromSuperJSON=function t(e){if("object"==typeof e&null!==e){if("set"===e._c3type_)return new Set(e.data.map(e=>t(e)));if("map"===e._c3type_)return new Map(e.data.map(e=>[e[0],t(e[1])]));{const s=Object.create(null);for(const[i,r]of Object.entries(e))s[i]=t(r);return s}}return e},C33.CSSToCamelCase=function(e){if(e.startsWith("--"))return e;let t="",s=!1,i=0;for(const r of e)"-"===r?0<i&&(s=!0):s?(t+=r.toUpperCase(),s=!1):t+=r,++i;return t},C33.IsIterator=function(e){return"object"==typeof e&&"function"==typeof e.next},C33.MakeFilledArray=function(t,s){const i=[];if("function"==typeof s)for(let e=0;e<t;++e)i.push(s());else for(let e=0;e<t;++e)i.push(s);return i}}{let padTwoDigits2=function(e){return 0===e.length?"00":1===e.length?"0"+e:e},hueToRGB2=function(e,t,s){return s<0&&(s+=1),1<s&&--s,s<1/6?e+6*(t-e)*s:s<.5?t:s<2/3?e+(t-e)*(2/3-s)*6:e};padTwoDigits=padTwoDigits2,hueToRGB=hueToRGB2;const C33=self.C3,HSL_TEST=/([0-9.]+),([0-9.]+)\%?,([0-9.]+)\%?/i,HSLA_TEST=/([0-9.]+),([0-9.]+)\%?,([0-9.]+)\%?,([0-9.])/i;C33.Color=class{constructor(e,t,s,i){this._r=NaN,this._g=NaN,this._b=NaN,this._a=NaN,this._r=0,this._g=0,this._b=0,this._a=0,e instanceof C33.Color?this.set(e):this.setRgba(e||0,t||0,s||0,i||0)}setRgb(e,t,s){return this._r=+e,this._g=+t,this._b=+s,this.clamp(),this}setRgba(e,t,s,i){return this._r=+e,this._g=+t,this._b=+s,this._a=+i,this.clamp(),this}set(e){return this._r=e._r,this._g=e._g,this._b=e._b,this._a=e._a,this}copy(e){return this.set(e)}add(e){this._r+=e._r,this._g+=e._g,this._b+=e._b,this._a+=e._a,this.clamp()}addRgb(e,t,s,i=0){this._r+=+e,this._g+=+t,this._b+=+s,this._a+=+i,this.clamp()}diff(e){this.setR(Math.max(this._r,e._r)-Math.min(this._r,e._r)),this.setG(Math.max(this._g,e._g)-Math.min(this._g,e._g)),this.setB(Math.max(this._b,e._b)-Math.min(this._b,e._b)),this.setA(Math.max(this._a,e._a)-Math.min(this._a,e._a)),this.clamp()}copyRgb(e){this._r=e._r,this._g=e._g,this._b=e._b}setR(e){this._r=C33.clamp(+e,0,1)}getR(){return this._r}setG(e){this._g=C33.clamp(+e,0,1)}getG(){return this._g}setB(e){this._b=C33.clamp(+e,0,1)}getB(){return this._b}setA(e){this._a=C33.clamp(+e,0,1)}getA(){return this._a}clone(){return C33.New(C33.Color,this._r,this._g,this._b,this._a)}toArray(){return[this._r,this._g,this._b,this._a]}toTypedArray(){return new Float64Array(this.toArray())}writeToTypedArray(e,t){e[t++]=this._r,e[t++]=this._g,e[t++]=this._b,e[t]=this._a}writeRGBToTypedArray(e,t){e[t++]=this._r,e[t++]=this._g,e[t]=this._b}equals(e){return this._r===e._r&&this._g===e._g&&this._b===e._b&&this._a===e._a}equalsIgnoringAlpha(e){return this._r===e._r&&this._g===e._g&&this._b===e._b}equalsRgb(e,t,s){return this._r===e&&this._g===t&&this._b===s}equalsRgba(e,t,s,i){return this._r===e&&this._g===t&&this._b===s&&this._a===i}equalsF32Array(e,t){return e[t]===Math.fround(this._r)&&e[t+1]===Math.fround(this._g)&&e[t+2]===Math.fround(this._b)&&e[t+3]===Math.fround(this._a)}equalsRGBF32Array(e,t){return e[t]===Math.fround(this._r)&&e[t+1]===Math.fround(this._g)&&e[t+2]===Math.fround(this._b)}multiply(e){this._r*=e._r,this._g*=e._g,this._b*=e._b,this._a*=e._a}multiplyAlpha(e){this._r*=e,this._g*=e,this._b*=e,this._a*=e}premultiply(){return this._r*=this._a,this._g*=this._a,this._b*=this._a,this}unpremultiply(){return this._r/=this._a,this._g/=this._a,this._b/=this._a,this}clamp(){return this._r=C33.clamp(this._r,0,1),this._g=C33.clamp(this._g,0,1),this._b=C33.clamp(this._b,0,1),this._a=C33.clamp(this._a,0,1),this}setFromRgbValue(e){this._r=C33.GetRValue(e),this._g=C33.GetGValue(e),this._b=C33.GetBValue(e),this._a=C33.GetAValue(e)}getCssRgb(e,t,s){const i=C33.IsFiniteNumber(e)?e:this.getR(),r=C33.IsFiniteNumber(t)?t:this.getG(),n=C33.IsFiniteNumber(s)?s:this.getB();return`rgb(${100*i}%, ${100*r}%, ${100*n}%)`}getCssRgba(e,t,s,i){const r=C33.IsFiniteNumber(e)?e:this.getR(),n=C33.IsFiniteNumber(t)?t:this.getG(),a=C33.IsFiniteNumber(s)?s:this.getB(),o=C33.IsFiniteNumber(i)?i:this.getA();return`rgba(${100*r}%, ${100*n}%, ${100*a}%, ${o})`}toHexString(){const e=Math.round(255*this.getR()),t=Math.round(255*this.getG()),s=Math.round(255*this.getB());return"#"+padTwoDigits2(e.toString(16))+padTwoDigits2(t.toString(16))+padTwoDigits2(s.toString(16))}parseHexString(e){if("string"!=typeof e)return!1;let t,s,i;if(3===(e="#"===(e=e.trim()).charAt(0)?e.substr(1):e).length)t=parseInt(e[0],16)/15,s=parseInt(e[1],16)/15,i=parseInt(e[2],16)/15;else{if(6!==e.length)return!1;t=parseInt(e.substr(0,2),16)/255,s=parseInt(e.substr(2,2),16)/255,i=parseInt(e.substr(4,2),16)/255}return isFinite(t)&&this.setR(t),isFinite(s)&&this.setG(s),isFinite(i)&&this.setB(i),this.setA(1),!0}toCommaSeparatedRgb(){const e=Math.round(255*this.getR()),t=Math.round(255*this.getG()),s=Math.round(255*this.getB());return e+`, ${t}, `+s}toRgbArray(){const e=Math.round(255*this.getR()),t=Math.round(255*this.getG()),s=Math.round(255*this.getB());return[e,t,s]}parseCommaSeparatedRgb(e){if("string"!=typeof e)return!1;const t=(e=e.replace(/^rgb\(|\)|%/,"")).split(",");if(t.length<3)return!1;const s=parseInt(t[0].trim(),10)/255,i=parseInt(t[1].trim(),10)/255,r=parseInt(t[2].trim(),10)/255;return isFinite(s)&&this.setR(s),isFinite(i)&&this.setG(i),isFinite(r)&&this.setB(r),this.setA(1),!0}parseCommaSeparatedPercentageRgb(e){if("string"!=typeof e)return!1;const t=(e=e.replace(/^rgb\(|\)|%/,"")).split(",");if(t.length<3)return!1;const s=parseInt(t[0].trim(),10)/100,i=parseInt(t[1].trim(),10)/100,r=parseInt(t[2].trim(),10)/100;return isFinite(s)&&this.setR(s),isFinite(i)&&this.setG(i),isFinite(r)&&this.setB(r),this.setA(1),!0}parseCommaSeparatedRgba(e){if("string"!=typeof e)return!1;const t=(e=e.replace(/^rgba\(|\)|%/,"")).split(",");if(t.length<4)return!1;const s=parseInt(t[0].trim(),10)/255,i=parseInt(t[1].trim(),10)/255,r=parseInt(t[2].trim(),10)/255,n=parseFloat(t[3].trim());return isFinite(s)&&this.setR(s),isFinite(i)&&this.setG(i),isFinite(r)&&this.setB(r),isFinite(n)&&this.setA(n),!0}parseCommaSeparatedPercentageRgba(e){if("string"!=typeof e)return!1;const t=(e=e.replace(/^rgba\(|\)|%/,"")).split(",");if(t.length<4)return!1;const s=parseInt(t[0].trim(),10)/100,i=parseInt(t[1].trim(),10)/100,r=parseInt(t[2].trim(),10)/100,n=parseFloat(t[3].trim());return isFinite(s)&&this.setR(s),isFinite(i)&&this.setG(i),isFinite(r)&&this.setB(r),isFinite(n)&&this.setA(n),!0}parseString(e){if("string"!=typeof e)return!1;if((e=e.replace(/\s+/,"")).includes(",")){if(e.startsWith("rgb("))return e.includes("%")?this.parseCommaSeparatedPercentageRgb(e):this.parseCommaSeparatedRgb(e);if(e.startsWith("rgba("))return e.includes("%")?this.parseCommaSeparatedPercentageRgba(e):this.parseCommaSeparatedRgba(e);if(e.startsWith("hsl(")||e.startsWith("hsla("))return this.parseHSLString(e);{const t=e.split(",");return e.includes("%")?3===t.length?this.parseCommaSeparatedPercentageRgb(e):4===t.length&&this.parseCommaSeparatedPercentageRgba(e):3===t.length?this.parseCommaSeparatedRgb(e):4===t.length&&this.parseCommaSeparatedRgba(e)}}return this.parseHexString(e)}toJSON(){return[this._r,this._g,this._b,this._a]}setFromHSLA(e,t,s,i){let r,n,a;if(e%=360,t=C33.clamp(t,0,100),s=C33.clamp(s,0,100),i=C33.clamp(i,0,1),e/=360,s/=100,0==(t/=100))r=n=a=s;else{const o=s<.5?s*(1+t):s+t-s*t,l=2*s-o;r=hueToRGB2(l,o,e+1/3),n=hueToRGB2(l,o,e),a=hueToRGB2(l,o,e-1/3)}return this.setR(r),this.setG(n),this.setB(a),this.setA(i),this}parseHSLString(e){const t=e.replace(/ |hsl|hsla|\(|\)|;/gi,""),s=HSL_TEST.exec(t),i=HSLA_TEST.exec(t);return s&&4===s.length?(this.setFromHSLA(+s[1],+s[2],+s[3],1),!0):!(!i||5!==i.length||(this.setFromHSLA(+s[1],+s[2],+s[3],+s[4]),0))}toHSLAString(){const e=this._r,t=this._g,s=this._b,i=this._a,r=C33.Color.GetHue(e,t,s),n=C33.Color.GetSaturation(e,t,s),a=C33.Color.GetLuminosity(e,t,s);return`hsla(${r}, ${n}%, ${a}%, ${i})`}toHSLAArray(){const e=this._r,t=this._g,s=this._b;return[C33.Color.GetHue(e,t,s),C33.Color.GetSaturation(e,t,s),C33.Color.GetLuminosity(e,t,s),this._a]}setFromJSON(e){!Array.isArray(e)||e.length<3||(this._r=e[0],this._g=e[1],this._b=e[2],this._a=4<=e.length?e[3]:1)}set r(e){this.setR(e)}get r(){return this.getR()}set g(e){this.setG(e)}get g(){return this.getG()}set b(e){this.setB(e)}get b(){return this.getB()}set a(e){this.setA(e)}get a(){return this.getA()}setAtIndex(e,t){switch(e){case 0:this.setR(t);break;case 1:this.setG(t);break;case 2:this.setB(t);break;case 3:this.setA(t);break;default:throw new RangeError("invalid color index")}}getAtIndex(e){switch(e){case 0:return this.getR();case 1:return this.getG();case 2:return this.getB();case 3:return this.getA();default:throw new RangeError("invalid color index")}}static Equals(e,t){let s,i;if(Array.isArray(e))(s=new C33.Color).setFromJSON(e);else{if(!(e instanceof C33.Color))throw new Error("unexpected type");s=e}if(Array.isArray(t))(i=new C33.Color).setFromJSON(t);else{if(!(t instanceof C33.Color))throw new Error("unexpected type");i=t}return s.equals(i)}static DiffChannel(e,t){return C33.clamp(Math.max(e,t)-Math.min(e,t),0,1)}static Diff(e,t){const s=new C33.Color;return s.setR(Math.max(e._r,t._r)-Math.min(e._r,t._r)),s.setG(Math.max(e._g,t._g)-Math.min(e._g,t._g)),s.setB(Math.max(e._b,t._b)-Math.min(e._b,t._b)),s.setA(Math.max(e._a,t._a)-Math.min(e._a,t._a)),s}static DiffNoAlpha(e,t){const s=new C33.Color(0,0,0,1);return s.setR(Math.max(e._r,t._r)-Math.min(e._r,t._r)),s.setG(Math.max(e._g,t._g)-Math.min(e._g,t._g)),s.setB(Math.max(e._b,t._b)-Math.min(e._b,t._b)),s}static GetHue(e,t,s){const i=Math.max(e,t,s),r=Math.min(e,t,s);if(i===r)return 0;let n=0;switch(i){case e:n=(t-s)/(i-r)+(t<s?6:0);break;case t:n=(s-e)/(i-r)+2;break;case s:n=(e-t)/(i-r)+4}return Math.round(n/6*360)}static GetSaturation(e,t,s){const i=Math.max(e,t,s),r=Math.min(e,t,s);if(i===r)return 0;const n=(i+r)/2,a=i-r,o=.5<n?a/(2-i-r):a/(i+r);return Math.round(100*o)}static GetLuminosity(e,t,s){const i=Math.max(e,t,s),r=Math.min(e,t,s),n=(i+r)/2;return i?Math.round(100*n):0}},C33.Color.White=Object.freeze(C33.New(C33.Color,1,1,1,1)),C33.Color.Black=Object.freeze(C33.New(C33.Color,0,0,0,1)),C33.Color.TransparentBlack=Object.freeze(C33.New(C33.Color,0,0,0,0))}{const C33=self.C3;C33.Vector2=class{constructor(e,t){this._x=0,this._y=0,e instanceof C33.Vector2?this.copy(e):this.set(e||0,t||0)}set(e,t){this._x=+e,this._y=+t}copy(e){this._x=e._x,this._y=e._y}equals(e){return this._x===e._x&&this._y===e._y}equalsValues(e,t){return this._x===e&&this._y===t}equalsF32Array(e,t){return e[t]===Math.fround(this._x)&&e[t+1]===Math.fround(this._y)}setX(e){this._x=+e}getX(){return this._x}setY(e){this._y=+e}getY(){return this._y}toArray(){return[this._x,this._y]}toTypedArray(){return new Float64Array(this.toArray())}writeToTypedArray(e,t){e[t++]=this._x,e[t]=this._y}offset(e,t){this._x+=+e,this._y+=+t}scale(e,t){this._x*=e,this._y*=t}divide(e,t){this._x/=e,this._y/=t}round(){this._x=Math.round(this._x),this._y=Math.round(this._y)}floor(){this._x=Math.floor(this._x),this._y=Math.floor(this._y)}ceil(){this._x=Math.ceil(this._x),this._y=Math.ceil(this._y)}angle(){return C33.angleTo(0,0,this._x,this._y)}lengthSquared(){return this._x*this._x+this._y*this._y}length(){return C33.hypot2DFast(this._x,this._y)}rotatePrecalc(e,t){const s=this._x*t-this._y*e;this._y=this._y*t+this._x*e,this._x=s}rotate(e){0!==e&&this.rotatePrecalc(Math.sin(e),Math.cos(e))}rotateAbout(e,t,s){0===e||t===this._x&&s===this._y||(this._x-=t,this._y-=s,this.rotatePrecalc(Math.sin(e),Math.cos(e)),this._x+=+t,this._y+=+s)}move(e,t){0!==t&&(this._x+=Math.cos(e)*t,this._y+=Math.sin(e)*t)}normalize(){const e=this.length();0!==e&&1!==e&&(this._x/=e,this._y/=e)}clamp(e,t){this._x=C33.clamp(this._x,e,t),this._y=C33.clamp(this._y,e,t)}dot(e){return this._x*e._x+this._y*e._y}reverse(){this._x=-this._x,this._y=-this._y}perp(){let e=this._x;return this._x=this._y,this._y=-e,this}}}{const C33=self.C3;C33.Rect=class{constructor(e,t,s,i){this._left=NaN,this._top=NaN,this._right=NaN,this._bottom=NaN,this._left=0,this._top=0,this._right=0,this._bottom=0,e instanceof C33.Rect?this.copy(e):this.set(e||0,t||0,s||0,i||0)}set(e,t,s,i){this._left=+e,this._top=+t,this._right=+s,this._bottom=+i}setWH(e,t,s,i){t=+t,this._left=e=+e,this._top=t,this._right=e+ +s,this._bottom=t+ +i}copy(e){this._left=+e._left,this._top=+e._top,this._right=+e._right,this._bottom=+e._bottom}clone(){return new C33.Rect(this._left,this._top,this._right,this._bottom)}static Merge(e,t){const s=new C33.Rect;return s.setLeft(Math.min(e._left,t._left)),s.setTop(Math.min(e._top,t._top)),s.setRight(Math.max(e._right,t._right)),s.setBottom(Math.max(e._bottom,t._bottom)),s}static FromObject(e){return new C33.Rect(e.left,e.top,e.right,e.bottom)}equals(e){return this._left===e._left&&this._top===e._top&&this._right===e._right&&this._bottom===e._bottom}equalsWH(e,t,s,i){return this._left===e&&this._top===t&&this.width()===s&&this.height()===i}equalsF32Array(e,t){return e[t]===Math.fround(this._left)&&e[t+1]===Math.fround(this._top)&&e[t+2]===Math.fround(this._right)&&e[t+3]===Math.fround(this._bottom)}setLeft(e){this._left=+e}getLeft(){return this._left}setTop(e){this._top=+e}getTop(){return this._top}setRight(e){this._right=+e}getRight(){return this._right}setBottom(e){this._bottom=+e}getBottom(){return this._bottom}toArray(){return[this._left,this._top,this._right,this._bottom]}toTypedArray(){return new Float64Array(this.toArray())}toDOMRect(){return new DOMRect(this._left,this._top,this.width(),this.height())}static fromDOMRect(e){return C33.New(C33.Rect,e.left,e.top,e.right,e.bottom)}writeToTypedArray(e,t){e[t++]=this._left,e[t++]=this._top,e[t++]=this._right,e[t]=this._bottom}writeAsQuadToTypedArray(e,t){e[t++]=this._left,e[t++]=this._top,e[t++]=this._right,e[t++]=this._top,e[t++]=this._right,e[t++]=this._bottom,e[t++]=this._left,e[t]=this._bottom}writeAsQuadToTypedArray3D(e,t,s){e[t++]=this._left,e[t++]=this._top,e[t++]=s,e[t++]=this._right,e[t++]=this._top,e[t++]=s,e[t++]=this._right,e[t++]=this._bottom,e[t++]=s,e[t++]=this._left,e[t++]=this._bottom,e[t]=s}width(){return this._right-this._left}height(){return this._bottom-this._top}midX(){return(this._left+this._right)/2}midY(){return(this._top+this._bottom)/2}offset(e,t){t=+t,this._left+=e=+e,this._top+=t,this._right+=e,this._bottom+=t}offsetLeft(e){this._left+=+e}offsetTop(e){this._top+=+e}offsetRight(e){this._right+=+e}offsetBottom(e){this._bottom+=+e}toSquare(e){if("x"!==e)throw new Error("invalid axis, only 'x' supported");this._top<this._bottom?this._left<this._right?this._bottom=this._top+this.width():this._bottom=this._top-this.width():this._left<this._right?this._bottom=this._top-this.width():this._bottom=this._top+this.width()}inflate(e,t){t=+t,this._left-=e=+e,this._top-=t,this._right+=e,this._bottom+=t}deflate(e,t){t=+t,this._left+=e=+e,this._top+=t,this._right-=e,this._bottom-=t}multiply(e,t){this._left*=e,this._top*=t,this._right*=e,this._bottom*=t}divide(e,t){this._left/=e,this._top/=t,this._right/=e,this._bottom/=t}mirrorAround(e){this._left=+e-this._left,this._right=+e-this._right}flipAround(e){this._top=+e-this._top,this._bottom=+e-this._bottom}rotate90DegreesAround(e,t){const s=this.width(),i=this.height(),r=this.getLeft()+s*e,n=this.getTop()+i*t;this.setWH(r-i*t,n-s*e,i,s)}swapLeftRight(){const e=this._left;this._left=this._right,this._right=e}swapTopBottom(){const e=this._top;this._top=this._bottom,this._bottom=e}shuntY(e){const t=this._top;this._top=+e-this._bottom,this._bottom=+e-t}round(){this._left=Math.round(this._left),this._top=Math.round(this._top),this._right=Math.round(this._right),this._bottom=Math.round(this._bottom)}roundInner(){this._left=Math.ceil(this._left),this._top=Math.ceil(this._top),this._right=Math.floor(this._right),this._bottom=Math.floor(this._bottom)}roundOuter(){this._left=Math.floor(this._left),this._top=Math.floor(this._top),this._right=Math.ceil(this._right),this._bottom=Math.ceil(this._bottom)}floor(){this._left=Math.floor(this._left),this._top=Math.floor(this._top),this._right=Math.floor(this._right),this._bottom=Math.floor(this._bottom)}ceil(){this._left=Math.ceil(this._left),this._top=Math.ceil(this._top),this._right=Math.ceil(this._right),this._bottom=Math.ceil(this._bottom)}clamp(e,t,s,i){this._left=Math.max(this._left,+e),this._top=Math.max(this._top,+t),this._right=Math.min(this._right,+s),this._bottom=Math.min(this._bottom,+i)}clampBoth(e,t,s,i){e=+e,t=+t,s=+s,i=+i,this._left=C33.clamp(this._left,e,s),this._top=C33.clamp(this._top,t,i),this._right=C33.clamp(this._right,e,s),this._bottom=C33.clamp(this._bottom,t,i)}normalize(){this._left>this._right&&this.swapLeftRight(),this._top>this._bottom&&this.swapTopBottom()}intersectsRect(e){return!(e._right<this._left||e._bottom<this._top||e._left>this._right||e._top>this._bottom)}intersectsRectOffset(e,t,s){return!(e._right+t<this._left||e._bottom+s<this._top||e._left+t>this._right||e._top+s>this._bottom)}containsPoint(e,t){return e>=this._left&&e<=this._right&&t>=this._top&&t<=this._bottom}containsRect(e){return e._left>=this._left&&e._top>=this._top&&e._right<=this._right&&e._bottom<=this._bottom}expandToContain(e){e._left<this._left&&(this._left=+e._left),e._top<this._top&&(this._top=+e._top),e._right>this._right&&(this._right=+e._right),e._bottom>this._bottom&&(this._bottom=+e._bottom)}lerpInto(e){this._left=C33.lerp(e._left,e._right,this._left),this._top=C33.lerp(e._top,e._bottom,this._top),this._right=C33.lerp(e._left,e._right,this._right),this._bottom=C33.lerp(e._top,e._bottom,this._bottom)}}}{const C33=self.C3;C33.Quad=class{constructor(e,t,s,i,r,n,a,o){this._tlx=NaN,this._tly=NaN,this._trx=NaN,this._try=NaN,this._brx=NaN,this._bry=NaN,this._blx=NaN,this._bly=NaN,this._tlx=0,this._tly=0,this._trx=0,this._try=0,this._brx=0,this._bry=0,this._blx=0,this._bly=0,e instanceof C33.Quad?this.copy(e):this.set(e||0,t||0,s||0,i||0,r||0,n||0,a||0,o||0)}set(e,t,s,i,r,n,a,o){this._tlx=+e,this._tly=+t,this._trx=+s,this._try=+i,this._brx=+r,this._bry=+n,this._blx=+a,this._bly=+o}setRect(e,t,s,i){this.set(e,t,s,t,s,i,e,i)}copy(e){this._tlx=e._tlx,this._tly=e._tly,this._trx=e._trx,this._try=e._try,this._brx=e._brx,this._bry=e._bry,this._blx=e._blx,this._bly=e._bly}equals(e){return this._tlx===e._tlx&&this._tly===e._tly&&this._trx===e._trx&&this._try===e._try&&this._brx===e._brx&&this._bry===e._bry&&this._blx===e._blx&&this._bly===e._bly}setTlx(e){this._tlx=+e}getTlx(){return this._tlx}setTly(e){this._tly=+e}getTly(){return this._tly}setTrx(e){this._trx=+e}getTrx(){return this._trx}setTry(e){this._try=+e}getTry(){return this._try}setBrx(e){this._brx=+e}getBrx(){return this._brx}setBry(e){this._bry=+e}getBry(){return this._bry}setBlx(e){this._blx=+e}getBlx(){return this._blx}setBly(e){this._bly=+e}getBly(){return this._bly}toDOMQuad(){return new DOMQuad(new DOMPoint(this._tlx,this._tly),new DOMPoint(this._trx,this._try),new DOMPoint(this._brx,this._bry),new DOMPoint(this._blx,this._bly))}static fromDOMQuad(e){return C33.New(C33.Quad,e.p1.x,e.p1.y,e.p2.x,e.p2.y,e.p3.x,e.p3.y,e.p4.x,e.p4.y)}toArray(){return[this._tlx,this._tly,this._trx,this._try,this._brx,this._bry,this._blx,this._bly]}toTypedArray(){return new Float64Array(this.toArray())}writeToTypedArray(e,t){e[t++]=this._tlx,e[t++]=this._tly,e[t++]=this._trx,e[t++]=this._try,e[t++]=this._brx,e[t++]=this._bry,e[t++]=this._blx,e[t]=this._bly}writeToTypedArray3D(e,t,s){e[t++]=this._tlx,e[t++]=this._tly,e[t++]=s,e[t++]=this._trx,e[t++]=this._try,e[t++]=s,e[t++]=this._brx,e[t++]=this._bry,e[t++]=s,e[t++]=this._blx,e[t++]=this._bly,e[t]=s}offset(e,t){t=+t,this._tlx+=e=+e,this._tly+=t,this._trx+=e,this._try+=t,this._brx+=e,this._bry+=t,this._blx+=e,this._bly+=t}round(){this._tlx=Math.round(this._tlx),this._tly=Math.round(this._tly),this._trx=Math.round(this._trx),this._try=Math.round(this._try),this._brx=Math.round(this._brx),this._bry=Math.round(this._bry),this._blx=Math.round(this._blx),this._bly=Math.round(this._bly)}floor(){this._tlx=Math.floor(this._tlx),this._tly=Math.floor(this._tly),this._trx=Math.floor(this._trx),this._try=Math.floor(this._try),this._brx=Math.floor(this._brx),this._bry=Math.floor(this._bry),this._blx=Math.floor(this._blx),this._bly=Math.floor(this._bly)}ceil(){this._tlx=Math.ceil(this._tlx),this._tly=Math.ceil(this._tly),this._trx=Math.ceil(this._trx),this._try=Math.ceil(this._try),this._brx=Math.ceil(this._brx),this._bry=Math.ceil(this._bry),this._blx=Math.ceil(this._blx),this._bly=Math.ceil(this._bly)}setFromRect(e){this._tlx=e._left,this._tly=e._top,this._trx=e._right,this._try=e._top,this._brx=e._right,this._bry=e._bottom,this._blx=e._left,this._bly=e._bottom}setFromRotatedRect(e,t){0===t?this.setFromRect(e):this.setFromRotatedRectPrecalc(e,Math.sin(t),Math.cos(t))}setFromRotatedRectPrecalc(e,t,s){const i=e._left*t,r=e._top*t,n=e._right*t,a=e._bottom*t,o=e._left*s,l=e._top*s,h=e._right*s,c=e._bottom*s;this._tlx=o-r,this._tly=l+i,this._trx=h-r,this._try=l+n,this._brx=h-a,this._bry=c+n,this._blx=o-a,this._bly=c+i}getBoundingBox(e){e.set(Math.min(this._tlx,this._trx,this._brx,this._blx),Math.min(this._tly,this._try,this._bry,this._bly),Math.max(this._tlx,this._trx,this._brx,this._blx),Math.max(this._tly,this._try,this._bry,this._bly))}containsPoint(e,t){let s=this._trx-this._tlx,i=this._try-this._tly,r=this._brx-this._tlx,n=this._bry-this._tly,a=e-this._tlx,o=t-this._tly,l=s*s+i*i,h=s*r+i*n,c=s*a+i*o,u=r*r+n*n,_=r*a+n*o,d=1/(l*u-h*h),p=(u*c-h*_)*d,m=(l*_-h*c)*d;return 0<=p&&0<m&&p+m<1||(m=((l=(s=this._blx-this._tlx)*s+(i=this._bly-this._tly)*i)*_-(h=s*r+i*n)*(c=s*a+i*o))*(d=1/(l*u-h*h)),0<=(p=(u*c-h*_)*d)&&0<m&&p+m<1)}midX(){return(this._tlx+this._trx+this._brx+this._blx)/4}midY(){return(this._tly+this._try+this._bry+this._bly)/4}intersectsSegment(e,t,s,i){return!(!this.containsPoint(e,t)&&!this.containsPoint(s,i))||C33.segmentIntersectsQuad(e,t,s,i,this)}intersectsQuad(e){let t=e.midX(),s=e.midY();if(this.containsPoint(t,s))return!0;if(t=this.midX(),s=this.midY(),e.containsPoint(t,s))return!0;const i=this._tlx,r=this._tly,n=this._trx,a=this._try,o=this._brx,l=this._bry,h=this._blx,c=this._bly;return C33.segmentIntersectsQuad(i,r,n,a,e)||C33.segmentIntersectsQuad(n,a,o,l,e)||C33.segmentIntersectsQuad(o,l,h,c,e)||C33.segmentIntersectsQuad(h,c,i,r,e)}rotatePointsAnticlockwise(){const e=this._tlx,t=this._tly;this._tlx=this._trx,this._tly=this._try,this._trx=this._brx,this._try=this._bry,this._brx=this._blx,this._bry=this._bly,this._blx=e,this._bly=t}mirror(){this._swap(0,2),this._swap(1,3),this._swap(6,4),this._swap(7,5)}flip(){this._swap(0,6),this._swap(1,7),this._swap(2,4),this._swap(3,5)}diag(){this._swap(2,6),this._swap(3,7)}_swap(e,t){const s=this._getAtIndex(e);this._setAtIndex(e,this._getAtIndex(t)),this._setAtIndex(t,s)}_getAtIndex(e){switch(e){case 0:return this._tlx;case 1:return this._tly;case 2:return this._trx;case 3:return this._try;case 4:return this._brx;case 5:return this._bry;case 6:return this._blx;case 7:return this._bly;default:throw new RangeError("invalid quad point index")}}_setAtIndex(e,t){switch(t=+t,e){case 0:this._tlx=t;break;case 1:this._tly=t;break;case 2:this._trx=t;break;case 3:this._try=t;break;case 4:this._brx=t;break;case 5:this._bry=t;break;case 6:this._blx=t;break;case 7:this._bly=t;break;default:throw new RangeError("invalid quad point index")}}}}{const C33=self.C3,assert=self.assert,DEFAULT_POLY_POINTS=[0,0,1,0,1,1,0,1],tempQuad=C33.New(C33.Quad);C33.CollisionPoly=class extends C33.DefendedBase{constructor(e,t=!0){super(),e=e||DEFAULT_POLY_POINTS,this._ptsArr=Float64Array.from(e),this._bbox=new C33.Rect,this._isBboxChanged=!0,this._enabled=t}Release(){}pointsArr(){return this._ptsArr}pointCount(){return this._ptsArr.length/2}setPoints(e){this._ptsArr.length===e.length?this._ptsArr.set(e):this._ptsArr=Float64Array.from(e),this._isBboxChanged=!0}setDefaultPoints(){this.setPoints(DEFAULT_POLY_POINTS)}copy(e){this.setPoints(e._ptsArr)}setBboxChanged(){this._isBboxChanged=!0}_updateBbox(){if(this._isBboxChanged){let s=this._ptsArr,i=s[0],r=s[1],n=i,a=r;for(let e=0,t=s.length;e<t;e+=2){const o=s[e],l=s[e+1];o<i&&(i=o),o>n&&(n=o),l<r&&(r=l),l>a&&(a=l)}this._bbox.set(i,r,n,a),this._isBboxChanged=!1}}setFromRect(e,t,s){let i=this._ptsArr;8!==i.length&&(i=new Float64Array(8),this._ptsArr=i),i[0]=e.getLeft()-t,i[1]=e.getTop()-s,i[2]=e.getRight()-t,i[3]=e.getTop()-s,i[4]=e.getRight()-t,i[5]=e.getBottom()-s,i[6]=e.getLeft()-t,i[7]=e.getBottom()-s,this._bbox.copy(e),0===t&&0===s||this._bbox.offset(-t,-s),this._isBboxChanged=!1}setFromQuad(e,t,s){tempQuad.copy(e),tempQuad.offset(t,s),this.setPoints(tempQuad.toArray()),this._isBboxChanged=!0}transform(e,t,s){let i=0,r=1;0!==s&&(i=Math.sin(s),r=Math.cos(s)),this.transformPrecalc(e,t,i,r)}transformPrecalc(s,i,r,n){const a=this._ptsArr;for(let e=0,t=a.length;e<t;e+=2){const o=e+1,l=a[e]*s,h=a[o]*i;a[e]=l*n-h*r,a[o]=h*n+l*r}this._isBboxChanged=!0}offset(s,i){const r=this._ptsArr;for(let e=0,t=r.length;e<t;e+=2)r[e]+=s,r[e+1]+=i}containsPoint(s,i){const r=this._ptsArr;if(s===r[0]&&i===r[1])return!0;this._updateBbox();let e=this._bbox,n=e.getLeft()-110,a=e.getTop()-101,o=e.getRight()+131,l=e.getBottom()+120,h=0,c=0,u,_,d=0,p=0,m,g,f=(u=n<s?(h=n,s):(h=s,n),_=a<i?(c=a,i):(c=i,a),m=o<s?(d=o,s):(d=s,o),g=l<i?(p=l,i):(p=i,l),0),S=0;for(let e=0,t=r.length;e<t;e+=2){const C=(e+2)%t,y=r[e],G=r[e+1],I=r[C],T=r[1+C];C33.segmentsIntersectPreCalc(n,a,s,i,h,u,c,_,y,G,I,T)&&++f,C33.segmentsIntersectPreCalc(o,l,s,i,d,m,p,g,y,G,I,T)&&++S}return f%2==1||S%2==1}intersectsPoly(e,u,_){const d=e._ptsArr,p=this._ptsArr;if(this.containsPoint(d[0]+u,d[1]+_))return!0;if(e.containsPoint(p[0]-u,p[1]-_))return!0;for(let t=0,c=p.length;t<c;t+=2){let e=(t+2)%c,s=p[t],i=p[t+1],r=p[e],n=p[1+e],a=0,o=0,l,h;l=s<r?(a=s,r):(a=r,s),h=i<n?(o=i,n):(o=n,i);for(let e=0,t=d.length;e<t;e+=2){const m=(e+2)%t,g=d[e]+u,f=d[e+1]+_,S=d[m]+u,C=d[1+m]+_;if(C33.segmentsIntersectPreCalc(s,i,r,n,a,l,o,h,g,f,S,C))return!0}}return!1}intersectsSegment(s,i,r,n,a,o){if(this.containsPoint(r-s,n-i))return!0;if(this.containsPoint(a-s,o-i))return!0;let l=0,h=0,c,u;c=r<a?(l=r,a):(l=a,r),u=n<o?(h=n,o):(h=o,n);const _=this._ptsArr;for(let e=0,t=_.length;e<t;e+=2){const d=(e+2)%t,p=_[e]+s,m=_[e+1]+i,g=_[d]+s,f=_[1+d]+i;if(C33.segmentsIntersectPreCalc(r,n,a,o,l,c,h,u,p,m,g,f))return!0}return!1}mirror(s){const i=this._ptsArr;for(let e=0,t=i.length;e<t;e+=2)i[e]=2*s-i[e];this._isBboxChanged=!0}flip(s){const i=this._ptsArr;for(let e=0,t=i.length;e<t;e+=2){const r=e+1;i[r]=2*s-i[r]}this._isBboxChanged=!0}diag(){const s=this._ptsArr;for(let e=0,t=s.length;e<t;e+=2){const i=e+1,r=s[e];s[e]=s[i],s[i]=r}this._isBboxChanged=!0}GetMidX(){let s=this._ptsArr,i=0;for(let e=0,t=s.length;e<t;e+=2)i+=s[e];return i/this.pointCount()}GetMidY(){let s=this._ptsArr,i=0;for(let e=0,t=s.length;e<t;e+=2)i+=s[e+1];return i/this.pointCount()}GetPointsArray(){return this._ptsArr}GetPointCount(){return this.pointCount()}IsEnabled(){return this._enabled}}}{const C33=self.C3;C33.PairMap=class extends C33.DefendedBase{constructor(e){if(super(),this._firstMap=new Map,e)for(const[t,s,i]of e)this.Set(t,s,i)}Release(){this.Clear(),this._firstMap=null}IsEmpty(){return 0===this._firstMap.size}Clear(){const e=this._firstMap;for(const t of e.values())t.clear();e.clear()}Set(e,t,s){let i=this._firstMap,r=i.get(e);r||(r=new Map,i.set(e,r)),r.set(t,s)}Get(e,t){const s=this._firstMap.get(e);return s&&s.get(t)}Has(e,t){const s=this._firstMap.get(e);return!!s&&s.has(t)}Delete(e,t){const s=this._firstMap,i=s.get(e);if(!i)return!1;const r=i.delete(t);return r&&0===i.size&&s.delete(e),r}DeleteEither(e){const t=this._firstMap,s=t.get(e);s&&(s.clear(),t.delete(e));for(const[i,r]of t.entries())r.delete(e)&&0===r.size&&t.delete(i)}GetSize(){let e=0;for(const t of this._firstMap.values())e+=t.size;return e}*values(){for(const e of this._firstMap.values())yield*e.values()}*keyPairs(){for(const[e,t]of this._firstMap.entries())for(const s of t.keys())yield[e,s]}*entries(){for(const[e,t]of this._firstMap.entries())for(const[s,i]of t.entries())yield[e,s,i]}}}{const C33=self.C3;C33.ArraySet=class extends C33.DefendedBase{constructor(){super(),this._set=new Set,this._arr=[],this._needToRebuildArray=!1}Release(){this.Clear()}Clear(){this._set.clear(),C33.clearArray(this._arr),this._needToRebuildArray=!1}Add(e){this._set.has(e)||(this._set.add(e),this._needToRebuildArray)||this._arr.push(e)}Has(e){return this._set.has(e)}Delete(e){this._set.delete(e)&&(this._needToRebuildArray=!0)}GetSize(){return this._set.size}IsEmpty(){return 0===this._set.size}GetArray(){return this._needToRebuildArray&&(this._RebuildArray(),this._needToRebuildArray=!1),this._arr}_RebuildArray(){const e=this._arr;C33.clearArray(e);for(const t of this._set)e.push(t)}}}{const C33=self.C3,EASE_MAP=new Map,PREDEFINED_EASE_MAP=new Map,CUSTOM_EASE_EDITOR_MAP=new Map,CUSTOM_EASE_DATA_EDITOR_MAP=new Map,CUSTOM_EASE_RUNTIME_MAP=new Map,CUSTOM_EASE_DATA_RUNTIME_MAP=new Map,PRIVATE_EASE_MAP=new Map,BUILT_IN_TRANSITION_MAP=new Map,ALIAS_MAP=new Map,EASE_TRANSLATION_KEYS=(ALIAS_MAP.set("linear","noease"),ALIAS_MAP.set("default","noease"),["default","noease","easeinquad","easeoutquad","easeinoutquad","easeincubic","easeoutcubic","easeinoutcubic","easeinquart","easeoutquart","easeinoutquart","easeinquint","easeoutquint","easeinoutquint","easeinsine","easeoutsine","easeinoutsine","easeinexpo","easeoutexpo","easeinoutexpo","easeincirc","easeoutcirc","easeinoutcirc","easeinelastic","easeoutelastic","easeinoutelastic","easeinback","easeoutback","easeinoutback","easeinbounce","easeoutbounce","easeinoutbounce"]),SHORT_EASE_TRANSLATION_KEYS=["default","noease","quad","cubic","quart","quint","sine","expo","circ","elastic","back","bounce"],EASE_API2INTERNAL_NAMES=new Map([["linear","noease"],["in-sine","easeinsine"],["out-sine","easeoutsine"],["in-out-sine","easeinoutsine"],["in-elastic","easeinelastic"],["out-elastic","easeoutelastic"],["in-out-elastic","easeinoutelastic"],["in-back","easeinback"],["out-back","easeoutback"],["in-out-back","easeinoutback"],["in-bounce","easeinbounce"],["out-bounce","easeoutbounce"],["in-out-bounce","easeinoutbounce"],["in-cubic","easeincubic"],["out-cubic","easeoutcubic"],["in-out-cubic","easeinoutcubic"],["in-quadratic","easeinquad"],["out-quadratic","easeoutquad"],["in-out-quadratic","easeinoutquad"],["in-quartic","easeinquart"],["out-quartic","easeoutquart"],["in-out-quartic","easeinoutquart"],["in-quintic","easeinquint"],["out-quintic","easeoutquint"],["in-out-quintic","easeinoutquint"],["in-circular","easeincirc"],["out-circular","easeoutcirc"],["in-out-circular","easeinoutcirc"],["in-exponential","easeinexpo"],["out-exponential","easeoutexpo"],["in-out-exponential","easeinoutexpo"]]),SAMPLE_COUNT=(self.Ease=class d{constructor(){}static InheritEase(){return"default"}static DefaultEase(){return"noease"}static ToInternal(e){return EASE_API2INTERNAL_NAMES.get(e)}static GetEditorEaseNames(t,...s){this._CreateEaseMap();let e,i=(t?(CUSTOM_EASE_EDITOR_MAP.has(t)||CUSTOM_EASE_EDITOR_MAP.set(t,new Map),[...(e=CUSTOM_EASE_EDITOR_MAP.get(t)).keys()].filter(e=>!d.GetEditorEaseData(e,t)||d.GetEditorEaseData(e,t).transition.IsForAnyPurpose())):[...(e=CUSTOM_EASE_RUNTIME_MAP).keys()]).sort();return[...PREDEFINED_EASE_MAP.keys()].concat(i).filter(e=>!s.includes(e))}static GetRuntimeEaseNames(){this._CreateEaseMap();const e=[...CUSTOM_EASE_RUNTIME_MAP.keys()];return e.sort(),[...PREDEFINED_EASE_MAP.keys()].concat(e)}static GetCustomRuntimeEaseNames(){this._CreateEaseMap();const e=[...CUSTOM_EASE_RUNTIME_MAP.keys()];return e.sort(),e}static IsPredefinedTranslatedName(e){for(const t of EASE_TRANSLATION_KEYS){const s=self.lang("ui.bars.timeline.eases."+t);if(s===e)return!0}for(const i of SHORT_EASE_TRANSLATION_KEYS){const r=self.lang("ui.bars.timeline.short-eases."+i);if(r===e)return!0}}static IsNamePredefined(e){return this._CreateEaseMap(),[...PREDEFINED_EASE_MAP.keys()].includes(e)}static _GetEase(e){const t=ALIAS_MAP.get(e);return t?EASE_MAP.get(t):d.IsNamePredefined(e)?EASE_MAP.get(e):PRIVATE_EASE_MAP.has(e)?PRIVATE_EASE_MAP.get(e):void 0}static GetBuiltInTransition(e){return this._CreateEaseMap(),BUILT_IN_TRANSITION_MAP.get(e)}static GetEditorEase(e,t){this._CreateEaseMap();const s=d._GetEase(e);if(s)return s;if(t)return CUSTOM_EASE_EDITOR_MAP.get(t).get(e);throw new Error("missing ease function")}static GetEditorEaseData(e,t){this._CreateEaseMap();const s=CUSTOM_EASE_DATA_EDITOR_MAP.get(t);if(s)return s.get(e)}static HasEditorEase(e,t){this._CreateEaseMap();const s=d._GetEase(e);return!!s||!!CUSTOM_EASE_EDITOR_MAP.get(t).get(e)}static GetRuntimeEase(e){this._CreateEaseMap();const t=d._GetEase(e);return t||CUSTOM_EASE_RUNTIME_MAP.get(e)}static GetRuntimeEaseData(e){return this._CreateEaseMap(),CUSTOM_EASE_DATA_RUNTIME_MAP.get(e)}static GetEaseFromIndex(e){this._CreateEaseMap();const t=this.GetRuntimeEaseNames();return t[e]}static GetIndexForEase(e,t){this._CreateEaseMap();const s=this.GetEditorEaseNames(t);return s.indexOf(e)}static GetIndexForEaseAtRuntime(e){return this.GetIndexForEase(e)}static _CreateEaseMap(){0===EASE_MAP.size&&(this._AddPredifinedEase("default",()=>{}),this._AddPredifinedEase("noease",[{x:0,y:0,sax:.336,say:0,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.336,eay:0,se:!1,ee:!0}],!0),this._AddPredifinedEase("easeinsine",[{x:0,y:0,sax:.485,say:0,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.038,eay:0,se:!1,ee:!0}]),this._AddPredifinedEase("easeoutsine",[{x:0,y:0,sax:.038,say:0,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.485,eay:0,se:!1,ee:!0}]),this._AddPredifinedEase("easeinoutsine",[{x:0,y:0,sax:.336,say:0,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.336,eay:0,se:!1,ee:!0}]),this._AddPredifinedEase("easeinelastic",[{x:0,y:0,sax:.018,say:0,eax:0,eay:0,se:!0,ee:!1},{x:.116,y:.002,sax:.025,say:0,eax:-.025,eay:0,se:!0,ee:!0},{x:.266,y:-.005,sax:.024,say:0,eax:-.021,eay:0,se:!0,ee:!0},{x:.416,y:.016,sax:.024,say:0,eax:-.026,eay:0,se:!0,ee:!0},{x:.566,y:-.045,sax:.061,say:0,eax:-.025,eay:0,se:!0,ee:!0},{x:.716,y:.132,sax:.072,say:-.004,eax:-.045,eay:0,se:!0,ee:!0},{x:.866,y:-.373,sax:.06,say:0,eax:-.049,eay:-.002,se:!0,ee:!0},{x:1,y:1,sax:0,say:0,eax:-.038,eay:-.263,se:!1,ee:!0}]),this._AddPredifinedEase("easeoutelastic",[{x:0,y:0,sax:.038,say:.263,eax:0,eay:0,se:!0,ee:!1},{x:.136,y:1.373,sax:.049,say:.002,eax:-.06,eay:0,se:!0,ee:!0},{x:.286,y:.868,sax:.045,say:0,eax:-.072,eay:.004,se:!0,ee:!0},{x:.436,y:1.045,sax:.025,say:0,eax:-.061,eay:0,se:!0,ee:!0},{x:.586,y:.984,sax:.026,say:0,eax:-.024,eay:0,se:!0,ee:!0},{x:.736,y:1.005,sax:.021,say:0,eax:-.024,eay:0,se:!0,ee:!0},{x:.886,y:.998,sax:.025,say:0,eax:-.025,eay:0,se:!0,ee:!0},{x:1,y:1,sax:0,say:0,eax:-.018,eay:0,se:!1,ee:!0}]),this._AddPredifinedEase("easeinoutelastic",[{x:0,y:0,sax:.025,say:0,eax:0,eay:0,se:!0,ee:!1},{x:.067,y:.001,sax:.025,say:0,eax:-.025,eay:0,se:!0,ee:!0},{x:.18,y:-.005,sax:.025,say:0,eax:-.025,eay:0,se:!0,ee:!0},{x:.292,y:.025,sax:.053,say:0,eax:-.025,eay:0,se:!0,ee:!0},{x:.405,y:-.118,sax:.069,say:0,eax:-.027,eay:0,se:!0,ee:!0},{x:.597,y:1.118,sax:.027,say:0,eax:-.069,eay:0,se:!0,ee:!0},{x:.71,y:.975,sax:.025,say:0,eax:-.053,eay:0,se:!0,ee:!0},{x:.822,y:1.005,sax:.025,say:0,eax:-.025,eay:0,se:!0,ee:!0},{x:.935,y:.999,sax:.025,say:0,eax:-.025,eay:0,se:!0,ee:!0},{x:1,y:1,sax:0,say:0,eax:-.025,eay:0,se:!1,ee:!0}]),this._AddPredifinedEase("easeinback",[{x:0,y:0,sax:.35,say:0,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.34,eay:-1.579,se:!1,ee:!0}]),this._AddPredifinedEase("easeoutback",[{x:0,y:0,sax:.34,say:1.579,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.35,eay:0,se:!1,ee:!0}]),this._AddPredifinedEase("easeinoutback",[{x:0,y:0,sax:.035,say:0,eax:0,eay:0,se:!0,ee:!1},{x:.242,y:-.1,sax:.258,say:0,eax:-.025,eay:0,se:!0,ee:!0},{x:.76,y:1.1,sax:.025,say:0,eax:-.26,eay:0,se:!0,ee:!0},{x:1,y:1,sax:0,say:0,eax:-.035,eay:0,se:!1,ee:!0}]),this._AddPredifinedEase("easeinbounce",[{x:0,y:0,sax:.033,say:.025,eax:0,eay:0,se:!0,ee:!1},{x:.092,y:0,sax:.026,say:.078,eax:-.033,eay:.025,se:!0,ee:!0},{x:.274,y:0,sax:.097,say:.319,eax:-.026,eay:.078,se:!0,ee:!0},{x:.637,y:0,sax:.105,say:.625,eax:-.097,eay:.319,se:!0,ee:!0},{x:1,y:1,sax:0,say:0,eax:-.125,eay:-.004,se:!1,ee:!0}]),this._AddPredifinedEase("easeoutbounce",[{x:0,y:0,sax:.125,say:.004,eax:0,eay:0,se:!0,ee:!1},{x:.365,y:1,sax:.097,say:-.319,eax:-.105,eay:-.625,se:!0,ee:!0},{x:.728,y:1,sax:.026,say:-.078,eax:-.097,eay:-.319,se:!0,ee:!0},{x:.91,y:1,sax:.033,say:-.025,eax:-.026,eay:-.078,se:!0,ee:!0},{x:1,y:1,sax:0,say:0,eax:-.033,eay:-.025,se:!1,ee:!0}]),this._AddPredifinedEase("easeinoutbounce",[{x:0,y:0,sax:.01,say:.006,eax:0,eay:0,se:!0,ee:!1},{x:.046,y:0,sax:.021,say:.038,eax:-.01,eay:.006,se:!0,ee:!0},{x:.137,y:0,sax:.059,say:.158,eax:-.021,eay:.038,se:!0,ee:!0},{x:.319,y:0,sax:.117,say:.744,eax:-.059,eay:.158,se:!0,ee:!0},{x:.683,y:1,sax:.059,say:-.158,eax:-.117,eay:-.744,se:!0,ee:!0},{x:.865,y:1,sax:.021,say:-.038,eax:-.059,eay:-.158,se:!0,ee:!0},{x:.956,y:1,sax:.01,say:-.006,eax:-.021,eay:-.038,se:!0,ee:!0},{x:1,y:1,sax:0,say:0,eax:-.01,eay:-.006,se:!1,ee:!0}]),this._AddPredifinedEase("easeincubic",[{x:0,y:0,sax:.75,say:0,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.138,eay:-.321,se:!1,ee:!0}]),this._AddPredifinedEase("easeoutcubic",[{x:0,y:0,sax:.138,say:.321,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.75,eay:0,se:!1,ee:!0}]),this._AddPredifinedEase("easeinoutcubic",[{x:0,y:0,sax:.285,say:0,eax:0,eay:0,se:!0,ee:!1},{x:.5,y:.5,sax:.081,say:.272,eax:-.081,eay:-.272,se:!0,ee:!0},{x:1,y:1,sax:0,say:0,eax:-.285,eay:0,se:!1,ee:!0}]),this._AddPredifinedEase("easeinquad",[{x:0,y:0,sax:.4,say:0,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.178,eay:-.392,se:!1,ee:!0}]),this._AddPredifinedEase("easeoutquad",[{x:0,y:0,sax:.178,say:.392,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.4,eay:0,se:!1,ee:!0}]),this._AddPredifinedEase("easeinoutquad",[{x:0,y:0,sax:.25,say:0,eax:0,eay:0,se:!0,ee:!1},{x:.5,y:.5,sax:.03,say:.065,eax:-.03,eay:-.065,se:!0,ee:!0},{x:1,y:1,sax:0,say:0,eax:-.25,eay:0,se:!1,ee:!0}]),this._AddPredifinedEase("easeinquart",[{x:0,y:0,sax:.25,say:1,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.5,eay:0,se:!1,ee:!0}]),this._AddPredifinedEase("easeoutquart",[{x:0,y:0,sax:.5,say:0,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.25,eay:-1,se:!1,ee:!0}]),this._AddPredifinedEase("easeinoutquart",[{x:0,y:0,sax:.765,say:.03,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.765,eay:-.03,se:!1,ee:!0}]),this._AddPredifinedEase("easeinquint",[{x:0,y:0,sax:.6,say:0,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.2,eay:-1,se:!1,ee:!0}]),this._AddPredifinedEase("easeoutquint",[{x:0,y:0,sax:.2,say:1,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.6,eay:0,se:!1,ee:!0}]),this._AddPredifinedEase("easeinoutquint",[{eax:0,eay:0,ee:!1,sax:.84,say:0,se:!0,x:0,y:0},{eax:-.84,eay:0,ee:!0,sax:0,say:0,se:!1,x:1,y:1}]),this._AddPredifinedEase("easeincirc",[{x:0,y:0,sax:.25,say:0,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.024,eay:-.808,se:!1,ee:!0}]),this._AddPredifinedEase("easeoutcirc",[{x:0,y:0,sax:.024,say:.808,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.25,eay:0,se:!1,ee:!0}]),this._AddPredifinedEase("easeinoutcirc",[{x:0,y:0,sax:.125,say:0,eax:0,eay:0,se:!0,ee:!1},{x:.5,y:.5,sax:.02,say:.428,eax:-.02,eay:-.428,se:!0,ee:!0},{x:1,y:1,sax:0,say:0,eax:-.125,eay:0,se:!1,ee:!0}]),this._AddPredifinedEase("easeinexpo",[{x:0,y:0,sax:.66,say:0,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.14,eay:-1,se:!1,ee:!0}]),this._AddPredifinedEase("easeoutexpo",[{x:0,y:0,sax:.14,say:1,eax:0,eay:0,se:!0,ee:!1},{x:1,y:1,sax:0,say:0,eax:-.66,eay:0,se:!1,ee:!0}]),this._AddPredifinedEase("easeinoutexpo",[{eax:0,eay:0,ee:!1,sax:.345,say:0,se:!0,x:0,y:0},{eax:-.06,eay:-.5,ee:!0,sax:.06,say:.5,se:!0,x:.5,y:.5},{eax:-.335,eay:0,ee:!0,sax:0,say:0,se:!1,x:1,y:1}]),this._AddPrivateCustomEase("cubicbezier",this.EaseCubicBezier),this._AddPrivateCustomEase("spline",this.EaseSpline))}static _AddPredifinedEase(e,t,s=!1){if("function"==typeof t)d._AddEase(e,t,"predefined");else{if(!C33.IsArray(t))throw new Error("unexpected arguments");if(self.BuiltInTransition){const r=C33.New(self.BuiltInTransition,e,s);r.SetFromJson(t),d._AddEase(e,(e,t,s,i)=>r.Interpolate(e,t,s,i),"predefined"),BUILT_IN_TRANSITION_MAP.set(e,r)}else{const n=C33.New(C33.Transition,[e,t.map(e=>[e.x,e.y,e.sax,e.say,e.eax,e.eay,e.se,e.ee])],!1);n.MakeLinear(s),d._AddEase(e,(e,t,s,i)=>n.Interpolate(e,t,s,i),"predefined")}}}static _AddPrivateCustomEase(e,t){d._AddEase(e,t,"private")}static AddCustomEase(e,t,s,i){this._CreateEaseMap(),d._AddEase(e,t,"custom",s,i)}static RemoveCustomEase(e,t){if(!this.IsNamePredefined(e)&&![...PRIVATE_EASE_MAP.keys()].includes(e)){const s=CUSTOM_EASE_EDITOR_MAP.get(t),i=(s&&s.delete(e),CUSTOM_EASE_DATA_EDITOR_MAP.get(t));i&&i.delete(e)}}static _AddEase(e,t,s,i,r){switch(s){case"predefined":EASE_MAP.set(e,t),PREDEFINED_EASE_MAP.set(e,t);break;case"custom":if(i){CUSTOM_EASE_EDITOR_MAP.has(i)||CUSTOM_EASE_EDITOR_MAP.set(i,new Map),CUSTOM_EASE_DATA_EDITOR_MAP.has(i)||CUSTOM_EASE_DATA_EDITOR_MAP.set(i,new Map);const n=CUSTOM_EASE_EDITOR_MAP.get(i),a=(n.set(e,t),CUSTOM_EASE_DATA_EDITOR_MAP.get(i));a.set(e,r)}else CUSTOM_EASE_RUNTIME_MAP.set(e,t),CUSTOM_EASE_DATA_RUNTIME_MAP.set(e,r);break;case"private":EASE_MAP.set(e,t),PRIVATE_EASE_MAP.set(e,t);break;default:throw new Error("unexpected ease mode")}}static NoEase(e,t,s,i){return 0===i?t:s*e/i+t}static EaseCubicBezier(e,t,s,i,r){const n=t,a=3*e*(s-t),o=3*e**2*(t+i-2*s),l=e**3*(r-t+3*s-3*i);return n+a+o+l}static EaseSpline(e,t,s,i,r,n,o,l,h,u){if(i===r&&n===o)return e;const _=get_t_for_x(e,t,i,n,l,u),d=a(s,r,o,h),p=b(s,r,o,h),m=c(s,r,o,h);return calc_bezier(_,d,p,m)}static GetBezierSamples(e,t,s,i){const r=[],n=a(e,t,s,i),o=b(e,t,s,i),l=c(e,t,s,i);for(let e=0;e<SAMPLE_COUNT;++e){const h=calc_bezier(e*SAMPLE_STEP,n,o,l);r.push(h)}return r}},11),SAMPLE_STEP=1/(SAMPLE_COUNT-1),NEWTON_RAPHSON_ITERATIONS=4,NEWTON_RAPHSON_MIN_SLOPE=.01,SUBDIVISION_PRECISION=1e-7,SUBDIVISION_MAX_ITERATIONS=10,a=(e,t,s,i)=>i-3*s+3*t-e,b=(e,t,s,i)=>3*s-6*t+3*e,c=(e,t,s,i)=>3*(t-e),calc_bezier=(e,t,s,i)=>((t*e+s)*e+i)*e,get_slope=(e,t,s,i)=>3*t*e*e+2*s*e+i,get_t_for_x=(o,e,t,s,i,r)=>{if(1==o)return 1;let l=0,n=1,h=r[n],u=SAMPLE_COUNT-1;for(SAMPLE_COUNT;n!=u&&h<=o;)n++,h=r[n],l+=SAMPLE_STEP;n--;let _=(o-(h=r[n]))/(r[n+1]-h),d=l+_*SAMPLE_STEP,p=a(e,t,s,i),m=b(e,t,s,i),g=c(e,t,s,i),f=get_slope(d,p,m,g);if(0===f)return d;if(f>=NEWTON_RAPHSON_MIN_SLOPE){for(let e=0;e<NEWTON_RAPHSON_ITERATIONS;++e){const S=calc_bezier(d,p,m,g)-o,C=get_slope(d,p,m,g);d-=S/C}return d}{let t=l,s=l+SAMPLE_STEP,i=0,r,n;do{d=t+(s-t)/2;let e=calc_bezier(d,p,m,g)-o;0<e?s=d:t=d,r=Math.abs(e)>SUBDIVISION_PRECISION,n=++i<SUBDIVISION_MAX_ITERATIONS}while(r&&n);return d}}}{let RequireStringOrNumber2=function(e){C33.IsString(e)};RequireStringOrNumber=RequireStringOrNumber2;const C33=self.C3;C33.ProbabilityTable=class{constructor(e){this._items=[],this._name=e||"",this._totalWeight=0}Release(){this.Clear(),this._items=null}GetName(){return this._name}Clear(){C33.clear2DArray(this._items),this._totalWeight=0}GetTotalWeight(){return this._totalWeight}Sample(e=Math.random()*this.GetTotalWeight()){let t=0;for(const[s,i]of this._items)if(e<(t+=s))return i;return 0}AddItem(e,t){RequireStringOrNumber2(t),this._totalWeight+=e,this._items.push([e,t])}RemoveItem(t,s){RequireStringOrNumber2(s);const i=0===t;for(let e=0;e<this._items.length;e++){const r=this._items[e],n=i||r[0]===t,a=r[1]===s;if(n&&a){this._items.splice(e,1),this._totalWeight-=r[0];break}}}asJSON(){return JSON.stringify(this._items)}static fromJSON(e,t){const s=new C33.ProbabilityTable(t),i=JSON.parse(e);for(const r of i){const n=r[0],a=r[1];s.AddItem(n,a)}return s}}}{let C33=self.C3,nextId=0;C33.ScreenReaderText=class{constructor(e,t){this._runtime=e,this._text=t,this._id=nextId++,this._runtime.PostComponentMessageToDOM("runtime","screen-reader-text",{type:"create",id:this._id,text:this._text})}Release(){this._runtime.PostComponentMessageToDOM("runtime","screen-reader-text",{type:"release",id:this._id}),this._runtime=null,this._text="",this._id=-1}SetText(e){this._text!==e&&(this._text=e,this._runtime.PostComponentMessageToDOM("runtime","screen-reader-text",{type:"update",id:this._id,text:this._text}))}}}{const C33=self.C3;C33.Event=class{constructor(e,t){this.type=e,this.cancelable=!!t,this.defaultPrevented=!1,this.propagationStopped=!1,this.isAsync=!1}preventDefault(){if(!this.cancelable)throw new Error(`event '${this.type}' is not cancelable`);this.defaultPrevented=!0}stopPropagation(){if(!this.cancelable)throw new Error(`event '${this.type}' cannot be stopped`);if(this.isAsync)throw new Error(`cannot stop async event '${this.type}' propagation`);this.propagationStopped=!0}}}{const C33=self.C3,assert=self.assert;C33.Event.Handler=class extends C33.DefendedBase{constructor(e){super(),this._type=e,this._captureListeners=[],this._captureListenersSet=new Set,this._listeners=[],this._listenersSet=new Set,this._fireDepth=0,this._queueModifyListeners=[]}Release(){0<this._fireDepth||(C33.clearArray(this._captureListeners),this._captureListenersSet.clear(),C33.clearArray(this._listeners),this._listenersSet.clear(),C33.clearArray(this._queueModifyListeners),C33.Release(this))}_AddListener(e,t){this._IsFiring()?this._queueModifyListeners.push({op:"add",func:e,capture:t}):t?this._captureListenersSet.has(e)||(this._captureListeners.push(e),this._captureListenersSet.add(e)):this._listenersSet.has(e)||(this._listeners.push(e),this._listenersSet.add(e))}_RemoveListener(e,t){this._IsFiring()?this._queueModifyListeners.push({op:"remove",func:e,capture:t}):t?this._captureListenersSet.has(e)&&(this._captureListenersSet.delete(e),C33.arrayFindRemove(this._captureListeners,e)):this._listenersSet.has(e)&&(this._listenersSet.delete(e),C33.arrayFindRemove(this._listeners,e))}_IsEmpty(){return!this._captureListeners.length&&!this._listeners.length}_IsFiring(){return 0<this._fireDepth}_ProcessQueuedListeners(){const e=new Set,t=new Set;for(const s of this._queueModifyListeners)if("add"===s.op)this._AddListener(s.func,s.capture),(s.capture?t:e).delete(s.func);else{if("remove"!==s.op)throw new Error("invalid op");(s.capture?(this._captureListenersSet.delete(s.func),t):(this._listenersSet.delete(s.func),e)).add(s.func)}C33.arrayRemoveAllInSet(this._listeners,e),C33.arrayRemoveAllInSet(this._captureListeners,t),C33.clearArray(this._queueModifyListeners)}_FireCancellable(s){this._IncreaseFireDepth();let i=!1;for(let e=0,t=this._captureListeners.length;e<t;++e)if(this._captureListeners[e](s),s.propagationStopped){i=!0;break}if(!i)for(let e=0,t=this._listeners.length;e<t&&(this._listeners[e](s),!s.propagationStopped);++e);return this._DecreaseFireDepth(),!s.defaultPrevented}_FireNonCancellable(s){this._IncreaseFireDepth();for(let e=0,t=this._captureListeners.length;e<t;++e)this._captureListeners[e](s);for(let e=0,t=this._listeners.length;e<t;++e)this._listeners[e](s);return this._DecreaseFireDepth(),!0}_IncreaseFireDepth(){this._fireDepth++}_DecreaseFireDepth(){this._fireDepth--,0===this._fireDepth&&0<this._queueModifyListeners.length&&this._ProcessQueuedListeners()}SetDelayRemoveEventsEnabled(e){e?this._IncreaseFireDepth():this._DecreaseFireDepth()}_FireAsync(s){let i=[];for(let t=0,e=this._captureListeners.length;t<e;++t){let e=this._captureListeners[t];i.push(C33.Asyncify(()=>e(s)))}for(let t=0,e=this._listeners.length;t<e;++t){let e=this._listeners[t];i.push(C33.Asyncify(()=>e(s)))}return Promise.all(i).then(()=>!s.defaultPrevented)}_FireAndWait_AsyncOptional(s){const i=[];this._IncreaseFireDepth();for(let e=0,t=this._captureListeners.length;e<t;++e){const r=this._captureListeners[e](s);r instanceof Promise&&i.push(r)}for(let e=0,t=this._listeners.length;e<t;++e){const n=this._listeners[e](s);n instanceof Promise&&i.push(n)}return this._DecreaseFireDepth(),i.length?Promise.all(i).then(()=>!s.defaultPrevented):!s.defaultPrevented}async _FireAndWaitAsync(e){return this._FireAndWait_AsyncOptional(e)}async _FireAndWaitAsyncSequential(s){this._IncreaseFireDepth();for(let e=0,t=this._captureListeners.length;e<t;++e){const i=this._captureListeners[e](s);i instanceof Promise&&await i}for(let e=0,t=this._listeners.length;e<t;++e){const r=this._listeners[e](s);r instanceof Promise&&await r}return this._DecreaseFireDepth(),!s.defaultPrevented}*_FireAsGenerator(s){this._IncreaseFireDepth();for(let e=0,t=this._captureListeners.length;e<t;++e){const i=this._captureListeners[e](s);C33.IsIterator(i)&&(yield*i)}for(let e=0,t=this._listeners.length;e<t;++e){const r=this._listeners[e](s);C33.IsIterator(r)&&(yield*r)}this._DecreaseFireDepth()}}}{const C33=self.C3;C33.Event.Dispatcher=class extends C33.DefendedBase{constructor(){super(),this._eventHandlers=new Map,this._dispatcherWasReleased=!1}Release(){if(this._dispatcherWasReleased)throw new Error("already released");this.ClearEvents(),this._dispatcherWasReleased=!0,C33.Release(this)}WasReleased(){return this._dispatcherWasReleased}ClearEvents(){if(this._eventHandlers){for(let e of this._eventHandlers.values())e.Release();this._eventHandlers.clear()}}_GetHandlerByType(e,t){let s=this._eventHandlers.get(e);return s||(t?(s=C33.New(C33.Event.Handler,e),this._eventHandlers.set(e,s),s):null)}HasAnyHandlerFor(e){return this._eventHandlers.has(e)}addEventListener(e,t,s){let i=this._GetHandlerByType(e,!0);i._AddListener(t,!!s)}removeEventListener(e,t,s){let i=this._GetHandlerByType(e,!1);i&&(i._RemoveListener(t,!!s),i._IsEmpty())&&this._eventHandlers.delete(e)}dispatchEvent(e){const t=this._GetHandlerByType(e.type,!1);return!t||(e.cancelable?t._FireCancellable(e):t._FireNonCancellable(e))}dispatchEventAsync(e){const t=this._GetHandlerByType(e.type,!1);return t?(e.isAsync=!0,t._FireAsync(e)):Promise.resolve(!0)}async dispatchEventAndClearAsync(e){const t=this._GetHandlerByType(e.type,!1);if(!t)return!0;this._eventHandlers.delete(e.type),e.isAsync=!0;const s=await t._FireAsync(e);return t.Release(),s}async dispatchEventAndWaitAsync(e){const t=this._GetHandlerByType(e.type,!1);return!t||t._FireAndWaitAsync(e)}dispatchEventAndWait_AsyncOptional(e){const t=this._GetHandlerByType(e.type,!1);return!t||t._FireAndWait_AsyncOptional(e)}async dispatchEventAndWaitAsyncSequential(e){const t=this._GetHandlerByType(e.type,!1);return!t||t._FireAndWaitAsyncSequential(e)}dispatchGeneratorEvent(e){const t=this._GetHandlerByType(e.type,!1);if(!t)return null;if(e.cancelable)throw new Error("not supported");return t._FireAsGenerator(e)}SetDelayRemoveEventsEnabled(e){for(const t of this._eventHandlers.values())t.SetDelayRemoveEventsEnabled(e)}}}{let SetNewCallback2=function(e){callbackId=SUPPORTS_RIC&&0===highThroughputMode?requestIdleCallback(DoAsyncifiedWork2,{timeout:IDLECALLBACK_TIMEOUT}):setTimeout(DoAsyncifiedWork2,0<highThroughputMode?1:e)},DoAsyncifiedWork2=function(r){if(callbackId=-1,workQueue.length){let s=performance.now(),i=s,e=0,t;for(;DoNextAsyncifiedJob2(workQueue.shift()),i=performance.now(),++e,t=(i-s)/e*1.1,workQueue.length&&(SUPPORTS_RIC&&0===highThroughputMode&&void 0!==r?t<r.timeRemaining():i-s+t<SETTIMEOUT_WORK_DURATION););if(-1===callbackId&&workQueue.length){let e=i-s,t=Math.max(SETTIMEOUT_INTERVAL-e,4);SetNewCallback2(t)}}},DoNextAsyncifiedJob2=function(t){let e;try{e=t.func()}catch(e){return void t.reject(e)}t.resolve(e)},C33=(SetNewCallback=SetNewCallback2,DoAsyncifiedWork=DoAsyncifiedWork2,DoNextAsyncifiedJob=DoNextAsyncifiedJob2,self.C3),SETTIMEOUT_WORK_DURATION=12,SETTIMEOUT_INTERVAL=16,IDLECALLBACK_TIMEOUT=35,SUPPORTS_RIC="undefined"!=typeof requestIdleCallback,workQueue=[],callbackId=-1,highThroughputMode=0,asyncifyDisabled=C33.QueryString.Has("disable-asyncify");asyncifyDisabled&&console.warn("[Asyncify] Asyncify has been disabled due to disable-asyncify in the query string. Some work will now be done synchronously."),C33.Asyncify=function(s){let i=null;return C33.isDebug&&(i=C33.GetCallStack()),new Promise((e,t)=>{workQueue.push({func:s,resolve:e,reject:t,stack:i}),asyncifyDisabled?DoNextAsyncifiedJob2(workQueue.pop()):-1===callbackId&&SetNewCallback2(SETTIMEOUT_INTERVAL)})},C33.Asyncify.SetHighThroughputMode=function(e){if(e)++highThroughputMode;else if(--highThroughputMode<0)throw new Error("already turned off high throughput mode")}}{let ClearTimeCache2=function(){cachedNowTime=-1},CheckActiveIdleTimeouts2=function(){timerId=-1,nextDeadline=-1;let s=Date.now();for(let t of activeIdleTimeouts)if(t._CheckTimeout(s)){let e=t._GetDeadline();(-1===nextDeadline||e<nextDeadline)&&(nextDeadline=e)}else activeIdleTimeouts.delete(t);if(-1!==nextDeadline){let e=Math.max(nextDeadline-s+IDLE_CHECK_TIMER_OVERSHOOT,IDLE_CHECK_MIN_INTERVAL);timerId=self.setTimeout(CheckActiveIdleTimeouts2,e)}},C33=(ClearTimeCache=ClearTimeCache2,CheckActiveIdleTimeouts=CheckActiveIdleTimeouts2,self.C3),IDLE_CHECK_MIN_INTERVAL=1e3,IDLE_CHECK_TIMER_OVERSHOOT=100,cachedNowTime=-1,timerId=(C33.FastGetDateNow=function(){return-1===cachedNowTime&&(cachedNowTime=Date.now(),self.setTimeout(ClearTimeCache2,16)),cachedNowTime},-1),nextDeadline=-1,activeIdleTimeouts=new Set;C33.IdleTimeout=class{constructor(e,t){this._callback=e,this._timeout=1e3*t,this._deadline=0,this._isActive=!1}Reset(){let e=C33.FastGetDateNow();this._deadline=e+this._timeout,this._isActive||(activeIdleTimeouts.add(this),this._isActive=!0),-1===timerId?(nextDeadline=this._deadline,timerId=self.setTimeout(CheckActiveIdleTimeouts2,this._timeout+IDLE_CHECK_TIMER_OVERSHOOT)):this._deadline<nextDeadline&&nextDeadline>e+IDLE_CHECK_MIN_INTERVAL&&(self.clearTimeout(timerId),nextDeadline=this._deadline,timerId=self.setTimeout(CheckActiveIdleTimeouts2,this._timeout+IDLE_CHECK_TIMER_OVERSHOOT))}_CheckTimeout(e){return!(e>=this._deadline)||(this._callback()?(this._deadline=e+this._timeout,!0):this._isActive=!1)}_GetDeadline(){return this._deadline}Cancel(){this._isActive&&(activeIdleTimeouts.delete(this),this._isActive=!1,0===activeIdleTimeouts.size)&&-1!==timerId&&(self.clearTimeout(timerId),timerId=-1,nextDeadline=-1)}Release(){this.Cancel(),this._callback=null}}}{const C33=self.C3;C33.Disposable=class a{constructor(e){this._disposed=!1,this._disposeAction=e}Dispose(){this._disposed||(this._disposed=!0,this._disposeAction&&(this._disposeAction(),this._disposeAction=null))}IsDisposed(){return this._disposed}Release(){this.Dispose()}static Release(e){return new a(()=>e.Release())}static From(t,s,i,r,e){if(null==r)r=!1;else if("boolean"!=typeof r&&"object"!=typeof r)throw new TypeError("invalid event listener options");if(e&&(i=i.bind(e)),s.includes(" ")){s=s.split(" ");const n=new C33.CompositeDisposable;for(let e of s)t.addEventListener(e,i,r),n.Add(C33.New(C33.Disposable,()=>t.removeEventListener(e,i,r)));return n}return t.addEventListener(s,i,r),C33.New(C33.Disposable,()=>t.removeEventListener(s,i,r))}},C33.StubDisposable=class extends C33.Disposable{SetAction(e){this._disposeAction=e}},C33.CompositeDisposable=class extends C33.Disposable{constructor(...t){super(),this._disposables=new Set;for(let e of t)this.Add(e)}Add(...t){if(this._disposed)throw new Error("already disposed");for(let e of t)this._disposables.add(e)}Remove(e){if(this._disposed)throw new Error("already disposed");this._disposables.delete(e)}RemoveAll(){if(this._disposed)throw new Error("already disposed");if(this._disposables){for(let e of this._disposables)e.Dispose();this._disposables.clear()}}IsDisposed(){return this._disposed}Dispose(){if(this._disposed)throw new Error("already disposed");this._disposed=!0;for(let e of this._disposables)e.Dispose();this._disposables.clear(),this._disposables=null}Release(){this.Dispose()}}}{const C33=self.C3;C33.KahanSum=class extends C33.DefendedBase{constructor(){super(),this._c=0,this._y=0,this._t=0,this._sum=0}Add(e){this._y=(e=+e)-this._c,this._t=this._sum+this._y,this._c=this._t-this._sum-this._y,this._sum=this._t}Subtract(e){this._sum-=+e}Get(){return this._sum}Reset(){this._c=0,this._y=0,this._t=0,this._sum=0}Set(e){this._c=0,this._y=0,this._t=0,this._sum=+e}Copy(e){this._c=e._c,this._y=e._y,this._t=e._t,this._sum=e._sum}Release(){}}}{const C33=self.C3,js_cols={},RED=!0,BLACK=!1;js_cols.RBnode=function(e){this.tree=e,this.right=this.tree.sentinel,this.left=this.tree.sentinel,this.parent=null,this.color=!1,this.key=null},js_cols.RedBlackSet=function(e){this.size=0,this.sentinel=new js_cols.RBnode(this),this.sentinel.color=BLACK,this.root=this.sentinel,this.root.parent=this.sentinel,this.compare=e||this.default_compare},js_cols.RedBlackSet.prototype.default_compare=function(e,t){return e<t?-1:t<e?1:0},js_cols.RedBlackSet.prototype.clone=function(){var e=new js_cols.RedBlackSet(this.compare);return e.insertAll(this),e},js_cols.RedBlackSet.prototype.clear=function(){this.size=0,this.sentinel=new js_cols.RBnode(this),this.sentinel.color=BLACK,this.root=this.sentinel,this.root.parent=this.sentinel},js_cols.RedBlackSet.prototype.leftRotate=function(e){var t=e.right;e.right=t.left,t.left!=this.sentinel&&(t.left.parent=e),t.parent=e.parent,e.parent==this.sentinel?this.root=t:e==e.parent.left?e.parent.left=t:e.parent.right=t,(t.left=e).parent=t},js_cols.RedBlackSet.prototype.rightRotate=function(e){var t=e.left;e.left=t.right,t.right!=this.sentinel&&(t.right.parent=e),t.parent=e.parent,e.parent==this.sentinel?this.root=t:e==e.parent.right?e.parent.right=t:e.parent.left=t,(t.right=e).parent=t},js_cols.RedBlackSet.prototype.insert=function(e){if(this.contains(e))this.get_(e).key=e;else{for(var t=new js_cols.RBnode(this),s=(t.key=e,this.sentinel),i=this.root;i!=this.sentinel;)s=i,i=this.compare(t.key,i.key)<0?i.left:i.right;(t.parent=s)==this.sentinel?this.root=t:this.compare(t.key,s.key)<0?s.left=t:s.right=t,t.left=this.sentinel,t.right=this.sentinel,t.color=RED,this.insertFixup(t),this.size++}},js_cols.RedBlackSet.prototype.insertFixup=function(e){for(;e!=this.sentinel&&e!=this.root&&e.parent.color==RED;){var t;e.parent==e.parent.parent.left?(t=e.parent.parent.right).color==RED?(e.parent.color=BLACK,t.color=BLACK,e.parent.parent.color=RED,e=e.parent.parent):(e==e.parent.right&&(e=e.parent,this.leftRotate(e)),e.parent.color=BLACK,e.parent.parent.color=RED,e.parent.parent!=this.sentinel&&this.rightRotate(e.parent.parent)):(t=e.parent.parent.left).color==RED?(e.parent.color=BLACK,t.color=BLACK,e.parent.parent.color=RED,e=e.parent.parent):(e==e.parent.left&&(e=e.parent,this.rightRotate(e)),e.parent.color=BLACK,e.parent.parent.color=RED,e.parent.parent!=this.sentinel&&this.leftRotate(e.parent.parent))}this.root.color=BLACK},js_cols.RedBlackSet.prototype.delete_=function(e){var t=e.left==this.sentinel||e.right==this.sentinel?e:this.successor_(e),s=t.left!=this.sentinel?t.left:t.right;s.parent=t.parent,t.parent==this.sentinel?this.root=s:t==t.parent.left?t.parent.left=s:t.parent.right=s,t!=e&&(e.key=t.key),t.color==BLACK&&this.deleteFixup(s),this.size--},js_cols.RedBlackSet.prototype.deleteFixup=function(e){for(;e!=this.root&&e.color==BLACK;){var t;e=e==e.parent.left?((t=e.parent.right).color==RED&&(t.color=BLACK,e.parent.color=RED,this.leftRotate(e.parent),t=e.parent.right),t.left.color==BLACK&&t.right.color==BLACK?(t.color=RED,e.parent):(t.right.color==BLACK&&(t.left.color=BLACK,t.color=RED,this.rightRotate(t),t=e.parent.right),t.color=e.parent.color,e.parent.color=BLACK,t.right.color=BLACK,this.leftRotate(e.parent),this.root)):((t=e.parent.left).color==RED&&(t.color=BLACK,e.parent.color=RED,this.rightRotate(e.parent),t=e.parent.left),t.right.color==BLACK&&t.left.color==BLACK?(t.color=RED,e.parent):(t.left.color==BLACK&&(t.right.color=BLACK,t.color=RED,this.leftRotate(t),t=e.parent.left),t.color=e.parent.color,e.parent.color=BLACK,t.left.color=BLACK,this.rightRotate(e.parent),this.root))}e.color=BLACK},js_cols.RedBlackSet.prototype.remove=function(e){var t;return(e=this.get_(e))!=this.sentinel?(t=e.key,this.delete_(e),t):null},js_cols.RedBlackSet.prototype.removeSwapped=function(e,t){this.remove(t)},js_cols.RedBlackSet.prototype.min=function(e){for(;e.left!=this.sentinel;)e=e.left;return e},js_cols.RedBlackSet.prototype.max=function(e){for(;e.right!=this.sentinel;)e=e.right;return e},js_cols.RedBlackSet.prototype.successor_=function(e){if(e.right!=this.sentinel)return this.min(e.right);for(var t=e.parent;t!=this.sentinel&&e==t.right;)t=(e=t).parent;return t},js_cols.RedBlackSet.prototype.predeccessor_=function(e){if(e.left!=this.sentinel)return this.max(e.left);for(var t=e.parent;t!=this.sentinel&&e==t.left;)t=(e=t).parent;return t},js_cols.RedBlackSet.prototype.successor=function(e){if(0<this.size){var t=this.get_(e);if(t==this.sentinel)return null;if(t.right!=this.sentinel)return this.min(t.right).key;for(var s=t.parent;s!=this.sentinel&&t==s.right;)s=(t=s).parent;return s!=this.sentinel?s.key:null}return null},js_cols.RedBlackSet.prototype.predecessor=function(e){if(0<this.size){var t=this.get_(e);if(t==this.sentinel)return null;if(t.left!=this.sentinel)return this.max(t.left).key;for(var s=t.parent;s!=this.sentinel&&t==s.left;)s=(t=s).parent;return s!=this.sentinel?s.key:null}return null},js_cols.RedBlackSet.prototype.getMin=function(){return this.min(this.root).key},js_cols.RedBlackSet.prototype.getMax=function(){return this.max(this.root).key},js_cols.RedBlackSet.prototype.get_=function(e){for(var t=this.root;t!=this.sentinel&&0!=this.compare(t.key,e);)t=this.compare(e,t.key)<0?t.left:t.right;return t},js_cols.RedBlackSet.prototype.contains=function(e){return null!=this.get_(e).key},js_cols.RedBlackSet.prototype.getValues=function(){var t=[];return this.forEach(function(e){t.push(e)}),t},js_cols.RedBlackSet.prototype.insertAll=function(e){if("array"==js_cols.typeOf(e))for(var t=0;t<e.length;t++)this.insert(e[t]);else if("function"==js_cols.typeOf(e.forEach))e.forEach(this.insert,this);else if("function"==js_cols.typeOf(e.getValues))for(var s=e.getValues(),t=0;t<s.length;t++)this.insert(s[t]);else if("object"==js_cols.typeOf(e))for(var i in e)this.insert(e[i])},js_cols.RedBlackSet.prototype.removeAll=function(e){if("array"==js_cols.typeOf(e))for(var t=0;t<e.length;t++)this.remove(e[t]);else if("function"==js_cols.typeOf(e.forEach))e.forEach(this.removeSwapped,this);else if("function"==js_cols.typeOf(e.getValues))for(var s=e.getValues(),t=0;t<s.length;t++)this.remove(s[t]);else if("object"==js_cols.typeOf(e))for(var i in e)this.remove(e[i])},js_cols.RedBlackSet.prototype.containsAll=function(e){if("array"==js_cols.typeOf(e)){for(var t=0;t<e.length;t++)if(!this.contains(e[t]))return!1;return!0}if("function"==js_cols.typeOf(e.forEach))return e.every(this.contains,this);if("function"==js_cols.typeOf(e.getValues)){for(var s=e.getValues(),t=0;t<s.length;t++)if(!this.contains(s[t]))return!1;return!0}if("object"==js_cols.typeOf(e)){for(var i in e)if(!this.contains(e[i]))return!1;return!0}},js_cols.RedBlackSet.prototype.range=function(e,t){var s=[];return this.traverseFromTo(function(e){s.push(e)},e,t),s},js_cols.RedBlackSet.prototype.traverse=function(e,t){if(!this.isEmpty())for(var s=this.min(this.root);s!=this.sentinel;){if(e.call(t,s.key,this))return;s=this.successor_(s)}},js_cols.RedBlackSet.prototype.traverseFrom=function(e,t,s){if(!this.isEmpty())for(var i=this.get_(t);i!=this.sentinel;){if(e.call(s,i.key,this))return;i=this.successor_(i)}},js_cols.RedBlackSet.prototype.traverseTo=function(e,t,s){if(!this.isEmpty())for(var i=this.min(this.root),r=this.get_(t);i!=r;){if(e.call(s,i.key,this))return;i=this.successor_(i)}},js_cols.RedBlackSet.prototype.traverseFromTo=function(e,t,s,i){if(!this.isEmpty())for(var r=this.get_(t),n=this.get_(s);r!=n;){if(e.call(i,r.key,this))return;r=this.successor_(r)}},js_cols.RedBlackSet.prototype.traverseBackwards=function(e,t){if(!this.isEmpty())for(var s=this.max(this.root);s!=this.sentinel;){if(e.call(t,s.key,this))return;s=this.predeccessor_(s)}},js_cols.RedBlackSet.prototype.forEach=function(e,t){if(!this.isEmpty())for(var s=this.min(this.root);s!=this.sentinel;s=this.successor_(s))e.call(t,s.key,s.key,this)},js_cols.RedBlackSet.prototype.some=function(e,t){if(!this.isEmpty())for(var s=this.min(this.root);s!=this.sentinel;s=this.successor_(s))if(e.call(t,s.key,s.key,this))return!0;return!1},js_cols.RedBlackSet.prototype.every=function(e,t){if(this.isEmpty())return!1;for(var s=this.min(this.root);s!=this.sentinel;s=this.successor_(s))if(!e.call(t,s.key,s.key,this))return!1;return!0},js_cols.RedBlackSet.prototype.map=function(e,t){var s=[];if(!this.isEmpty())for(var i=this.min(this.root);i!=this.sentinel;i=this.successor_(i))s.push(e.call(t,i.key,i.key,this));return s},js_cols.RedBlackSet.prototype.filter=function(e,t){var s=[];if(!this.isEmpty())for(var i=this.min(this.root);i!=this.sentinel;i=this.successor_(i))e.call(t,i.key,i.key,this)&&s.push(i.key);return s},js_cols.RedBlackSet.prototype.getCount=function(){return this.size},js_cols.RedBlackSet.prototype.isEmpty=function(){return 0==this.size},js_cols.RedBlackSet.prototype.isSubsetOf=function(e){var t=js_cols.getCount(e);if(this.getCount()>t)return!1;var s=0;if(this.isEmpty())return!0;for(var i=this.min(this.root);i!=this.sentinel;i=this.successor_(i))js_cols.contains.call(e,e,i.key)&&s++;return s==this.getCount()},js_cols.RedBlackSet.prototype.intersection=function(e){var t=new js_cols.RedBlackSet(this.compare);if(!this.isEmpty())for(var s=this.min(this.root);s!=this.sentinel;s=this.successor_(s))e.contains.call(e,s.key,s.key,this)&&t.insert(s.key);return t},C33.RedBlackSet=class extends C33.DefendedBase{constructor(e){super(),this._rbSet=new js_cols.RedBlackSet(e),this._enableQueue=!1,this._queueInsert=new Set,this._queueRemove=new Set}Add(e){this._enableQueue?this._rbSet.contains(e)?this._queueRemove.delete(e):this._queueInsert.add(e):this._rbSet.insert(e)}Remove(e){this._enableQueue?this._rbSet.contains(e)?this._queueRemove.add(e):this._queueInsert.delete(e):this._rbSet.remove(e)}Has(e){return this._enableQueue?!!this._queueInsert.has(e)||!this._queueRemove.has(e)&&this._rbSet.contains(e):this._rbSet.contains(e)}Clear(){this._rbSet.clear(),this._queueInsert.clear(),this._queueRemove.clear()}toArray(){if(this._enableQueue)throw new Error("cannot be used in queueing mode");return this._rbSet.getValues()}GetSize(){return this._rbSet.getCount()+this._queueInsert.size-this._queueRemove.size}IsEmpty(){return 0===this.GetSize()}Front(){if(this.IsEmpty())throw new Error("empty set");if(this._enableQueue)throw new Error("cannot be used in queueing mode");const e=this._rbSet,t=e.min(e.root);return t.key}Shift(){if(this.IsEmpty())throw new Error("empty set");if(this._enableQueue)throw new Error("cannot be used in queueing mode");const e=this.Front();return this.Remove(e),e}SetQueueingEnabled(e){if(this._enableQueue!==(e=!!e)&&!(this._enableQueue=e)){for(const t of this._queueRemove)this._rbSet.remove(t);this._queueRemove.clear();for(const s of this._queueInsert)this._rbSet.insert(s);this._queueInsert.clear()}}ForEach(e){this._rbSet.forEach(e)}*values(){if(!this.IsEmpty()){const t=this._rbSet;for(let e=t.min(t.root);e!=t.sentinel;e=t.successor_(e))yield e.key}}[Symbol.iterator](){return this.values()}}}{const C33=self.C3;C33.PromiseThrottle=class{constructor(e=C33.hardwareConcurrency){this._maxParallel=e,this._queue=[],this._activeCount=0}Add(s){return new Promise((e,t)=>{this._queue.push({func:s,resolve:e,reject:t}),this._MaybeStartNext()})}_FindInQueue(s){for(let e=0,t=this._queue.length;e<t;++e)if(this._queue[e].func===s)return e;return-1}RemoveAndResolve(e,t){const s=this._FindInQueue(e);if(-1===s)throw new Error("cannot find promise to resolve");this._queue[s].resolve(t),this._queue.splice(s,1)}RemoveAndReject(e,t){const s=this._FindInQueue(e);if(-1===s)throw new Error("cannot find promise to reject");this._queue[s].reject(t),this._queue.splice(s,1)}async _MaybeStartNext(){if(this._queue.length&&!(this._activeCount>=this._maxParallel)){this._activeCount++;const t=this._queue.shift();try{const e=await t.func();t.resolve(e)}catch(e){t.reject(e)}this._activeCount--,this._MaybeStartNext()}}static async Batch(e,t){let s=[],i=!1,r=[];for(;e--;)r.push((async()=>{let e;for(;e=t.pop();){if(i)return;try{s.push(await e())}catch(e){throw i=!0,e}}})());return await Promise.all(r),s}}}{const C33=self.C3;C33.RateLimiter=class{constructor(e,t,s){this._callback=e,this._interval=t,this._intervalOnBattery=s||2*t,this._timerId=-1,this._lastCallTime=-1/0,this._timerCallFunc=()=>this._OnTimer(),this._ignoreReset=!1,this._canRunImmediate=!1,this._callbackArguments=null}SetCanRunImmediate(e){this._canRunImmediate=!!e}_GetInterval(){return void 0!==C33.Battery&&C33.Battery.IsOnBatteryPower()?this._intervalOnBattery:this._interval}Call(...i){if(-1===this._timerId){this._callbackArguments=i;let e=C33.FastGetDateNow(),t=e-this._lastCallTime,s=this._GetInterval();s<=t&&this._canRunImmediate?(this._lastCallTime=e,this._RunCallback()):this._timerId=self.setTimeout(this._timerCallFunc,Math.max(s-t,4))}}_RunCallback(){this._ignoreReset=!0;const e=this._callbackArguments;this._callbackArguments=null,e?this._callback(...e):this._callback(),this._ignoreReset=!1}Reset(){this._ignoreReset||(this._CancelTimer(),this._callbackArguments=null,this._lastCallTime=C33.FastGetDateNow())}_OnTimer(){this._timerId=-1,this._lastCallTime=C33.FastGetDateNow(),this._RunCallback()}_CancelTimer(){-1!==this._timerId&&(self.clearTimeout(this._timerId),this._timerId=-1)}Release(){this._CancelTimer(),this._callback=null,this._callbackArguments=null,this._timerCallFunc=null}}}{const C33=self.C3;C33.SVGRasterManager=class{constructor(){this._images=new Map,this._allowNpotSurfaces=!1,this._getBaseSizeCallback=null,this._rasterAtSizeCallback=null,this._releaseResultCallback=null,this._redrawCallback=null}SetNpotSurfaceAllowed(e){this._allowNpotSurfaces=!!e}IsNpotSurfaceAllowed(){return this._allowNpotSurfaces}SetGetBaseSizeCallback(e){this._getBaseSizeCallback=e}GetBaseSize(e){if(this._getBaseSizeCallback)return this._getBaseSizeCallback(e);throw new Error("no get base size callback set")}SetRasterAtSizeCallback(e){this._rasterAtSizeCallback=e}RasterAtSize(e,t,s,i,r,n){if(this._rasterAtSizeCallback)return this._rasterAtSizeCallback(e,t,s,i,r,n);throw new Error("no raster at size callback set")}SetReleaseResultCallback(e){this._releaseResultCallback=e}ReleaseResult(e){if(!this._releaseResultCallback)throw new Error("no release result callback set");this._releaseResultCallback(e)}SetRedrawCallback(e){this._redrawCallback=e}Redraw(){if(!this._redrawCallback)throw new Error("no redraw callback set");this._redrawCallback()}AddImage(e){let t=this._images.get(e);return t||(t=C33.New(C33.SVGRasterImage,this,e),this._images.set(e,t)),t.IncReference(),t}_RemoveImage(e){this._images.delete(e.GetDataSource())}OnTexturesChanged(){for(const e of this._images.values())e.ReleaseRasterizedResult(),e.ForceRasterAgain()}}}{const C33=self.C3,MAX_SURFACE_SIZE=4096;C33.SVGRasterImage=class{constructor(e,t){this._manager=e,this._dataSource=t,this._refCount=0,this._baseWidth=0,this._baseHeight=0,this._getBaseSizePromise=this._manager.GetBaseSize(t).then(e=>{this._manager&&(this._baseWidth=e[0],this._baseHeight=e[1],this._manager.Redraw())}).catch(e=>{console.error("[SVG] Error loading SVG: ",e),this._hadError=!0,this._manager&&this._manager.Redraw()}),this._rasterSurfaceWidth=0,this._rasterSurfaceHeight=0,this._rasterImageWidth=0,this._rasterImageHeight=0,this._isRasterizing=!1,this._rasterizedResult=null,this._forceRaster=!1,this._hadError=!1}Release(){if(this._refCount<=0)throw new Error("already released");this._refCount--,0===this._refCount&&this._Release()}ReleaseRasterizedResult(){this._rasterizedResult&&(this._manager.ReleaseResult(this._rasterizedResult),this._rasterizedResult=null)}_Release(){this.ReleaseRasterizedResult(),this._manager._RemoveImage(this),this._manager=null}GetDataSource(){return this._dataSource}IncReference(){this._refCount++}HasReferences(){return 0<this._refCount}GetRasterizedResult(){return this._rasterizedResult}ForceRasterAgain(){this._forceRaster=!0}async StartRasterForSize(i,r,n){if(0!==r&&0!==n&&!this._hadError&&!this._isRasterizing){let e=C33.nextHighestPowerOfTwo(Math.ceil(r)),t=C33.nextHighestPowerOfTwo(Math.ceil(n)),s=Math.max(e,t);if(s>MAX_SURFACE_SIZE){const a=MAX_SURFACE_SIZE/s;r*=a,n*=a,e=Math.min(Math.ceil(e*a),MAX_SURFACE_SIZE),t=Math.min(Math.ceil(t*a),MAX_SURFACE_SIZE)}if(r<e&&n<t){const o=r/n,l=e/t;n=o<l?(r=t*o,t):(r=e)/o}if(this._manager.IsNpotSurfaceAllowed()&&(e=Math.ceil(r),t=Math.ceil(n)),!(e<=this._rasterSurfaceWidth&&t<=this._rasterSurfaceHeight)||this._forceRaster){this._isRasterizing=!0,this._rasterSurfaceWidth=e,this._rasterSurfaceHeight=t;const h=await this._manager.RasterAtSize(this._dataSource,i,this._rasterSurfaceWidth,this._rasterSurfaceHeight,r,n);this._manager&&(this.ReleaseRasterizedResult(),this._rasterizedResult=h,this._rasterImageWidth=r,this._rasterImageHeight=n,this._isRasterizing=!1,this._forceRaster=!1,this._manager.Redraw())}}}WhenBaseSizeReady(){return this._getBaseSizePromise}GetBaseWidth(){return this._baseWidth}GetBaseHeight(){return this._baseHeight}GetRasterWidth(){return this._rasterImageWidth}GetRasterHeight(){return this._rasterImageHeight}HadError(){return this._hadError}}}{let lookupHtmlEntity2=function(e){return HTML_ENTITY_MAP.get(e)};lookupHtmlEntity=lookupHtmlEntity2;const C33=self.C3,NUMERIC_CHARS=(C33.UTF8_BOM="\ufeff",new Set("0123456789")),WHITESPACE_CHARS=(C33.IsNumericChar=function(e){return NUMERIC_CHARS.has(e)},new Set(" \t\n\r \u2028\u2029 "));C33.IsWhitespaceChar=function(e){return WHITESPACE_CHARS.has(e)},C33.FilterWhitespace=function(e){return[...e].filter(e=>!C33.IsWhitespaceChar(e)).join("")},C33.IsStringAllWhitespace=function(e){for(const t of e)if(!C33.IsWhitespaceChar(t))return!1;return!0},C33.IsCharArrayAllWhitespace=function(e){for(const t of e)if(!C33.IsWhitespaceChar(t))return!1;return!0},C33.IsUnprintableChar=function(e){return 1===e.length&&e.charCodeAt(0)<32},C33.FilterUnprintableChars=function(e){return[...e].filter(e=>!C33.IsUnprintableChar(e)).join("")};let cjkPunctuationRegex=null;try{cjkPunctuationRegex=new RegExp("\\p{P}(?<=[\\u3000-\\u303F\\uFF00-\\uFFEF])","u")}catch(t){console.warn("Unable to detect CJK punctuation: ",t)}C33.IsCJKPunctuationChar=function(e){return!C33.IsWhitespaceChar(e)&&cjkPunctuationRegex&&cjkPunctuationRegex.test(e)};const NUMERIC_STRING_CHARS=new Set("0123456789.+-e"),HTML_ENTITY_MAP=(C33.IsStringNumber=function(t){if(!(t=t.trim()).length)return!1;let e=t.charAt(0);if("-"!==e&&!NUMERIC_CHARS.has(e))return!1;for(let e of t)if(!NUMERIC_STRING_CHARS.has(e))return!1;return!0},C33.RemoveTrailingDigits=function(t){let s=t.length;for(;0<s;){let e=t.charAt(s-1);if(!C33.IsNumericChar(e))break;--s}return t.substr(0,s)},C33.IncrementNumberAtEndOf=function(e){let t=C33.RemoveTrailingDigits(e),s=e.substr(t.length);return t+(s?(parseInt(s,10)+1).toString():"2")},new Map([["&","&"],["<","<"],[">",">"],['"',"""],["'","'"]])),HTML_ENTITY_REGEX=/[&<>"']/g,ESCAPE_REGEX=(C33.EscapeHTML=function(e){return e.replace(HTML_ENTITY_REGEX,lookupHtmlEntity2)},C33.EscapeJS=function(e){let t=C33.ReplaceAll(e,"\\","\\\\");return t=C33.ReplaceAll(t,'"','\\"'),t=C33.ReplaceAll(t,"\t","\\t"),t=C33.ReplaceAll(t,"\r",""),C33.ReplaceAll(t,"\n","\\n")},C33.EscapeXML=function(e){let t=C33.ReplaceAll(e,"&","&");return t=C33.ReplaceAll(t,"<","<"),t=C33.ReplaceAll(t,">",">"),C33.ReplaceAll(t,'"',""")},/[-[\]{}()*+?.,\\^$|#\s]/g),intlSegmenter=(C33.EscapeRegex=function(e){return e.replace(ESCAPE_REGEX,"\\$&")},C33.CountCharsInString=function(e,t){let s=0;for(const i of e)i===t&&++s;return s},C33.FindAll=function(e,t,s=!1){if(!t)return[];s||(e=e.toLowerCase(),t=t.toLowerCase());let i=t.length,r=0,n,a=[];for(;-1<(n=e.indexOf(t,r));)a.push(n),r=n+i;return a},C33.ReplaceAll=function(e,t,s){return e.replaceAll(t,()=>s)},C33.ReplaceAllCaseInsensitive=function(e,t,s){return e.replace(new RegExp(C33.EscapeRegex(t),"gi"),()=>s)},C33.SetElementContent=function(e,t){"string"==typeof t?e.textContent=t:t.isPlainText()?e.textContent=t.toString():(e.innerHTML=t.toHTML(),t instanceof C33.BBString&&t.attachLinkHandlers(e))},C33.StringLikeEquals=function(e,t){return e instanceof C33.HtmlString||e instanceof C33.BBString?e.equals(t):t instanceof C33.HtmlString||t instanceof C33.BBString?t.equals(e):e===t},C33.StringSubstitute=function(s,...i){let r=s;for(let e=0,t=i.length;e<t;++e){const n=`{${e}}`;if(!s.includes(n))throw new Error(`missing placeholder '${n}' in string substitution`);r=r.replace(n,i[e].toString())}return r},C33.StringSubstituteAllowMissing=function(s,...i){let r=s,n=-1,a=-1;for(let e=0,t=i.length;e<t;++e){const o=`{${e}}`;s.includes(o)?(a=e,r=r.replace(o,i[e].toString())):-1===n&&(n=e)}if(0<=n&&0<=a&&n<a)throw new Error(`missing placeholder '${n}' in string substitution`);return r},C33.StringSubstituteMap=function(e,s){let i=e;for(let[e,t]of Object.entries(s))i=i.replaceAll(e,t.toString());return i},C33.SortAZ=function(e,t){return t<e?1:e<t?-1:0},C33.SortAZCaseInsensitive=function(e,t){let s=e.toLowerCase(),i=t.toLowerCase();return i<s?1:s<i?-1:0},new self.Intl.Segmenter),KILOBYTE=(C33.SplitGraphemes=function(e){const t=[];for(const s of intlSegmenter.segment(e))t.push(s.segment);return t},C33.IterateGraphemes=function*(e){for(const t of intlSegmenter.segment(e))yield t.segment},C33.CountGraphemes=function(e){let t=0;for(const s of intlSegmenter.segment(e))++t;return t},1024),MEGABYTE=1024*KILOBYTE,GIGABYTE=1024*MEGABYTE,TERABYTE=1024*GIGABYTE,DEFAULT_FORMATTIME_OPTS={approximate:(C33.FormatDataSize=function(t,e){let s="common."+(e?"dataRates":"dataSizes")+".",i=self.langSub;if(t<KILOBYTE)return i(s+"bytes",t);if(t<MEGABYTE){let e=t/KILOBYTE;return e=e<10?Math.round(10*e)/10:Math.round(e),i(s+"kilobytes",e)}if(t<GIGABYTE){let e=t/MEGABYTE;return e=e<10?Math.round(10*e)/10:Math.round(e),i(s+"megabytes",e)}if(t<TERABYTE){let e=t/GIGABYTE;return e=e<10?Math.round(10*e)/10:Math.round(e),i(s+"gigabytes",e)}{let e=t/TERABYTE;return e=e<10?Math.round(10*e)/10:Math.round(e),i(s+"terabytes",e)}},!1),days:!0,hours:!0,minutes:!0,seconds:!0};C33.FormatTime=function(e,t){t=Object.assign({},DEFAULT_FORMATTIME_OPTS,t),C33.Lang.PushContext("common.time");const s=[],i=self.lang,r=self.langPluralSub;if(t.days){const a=Math.floor(e/86400);0<a&&(e-=24*a*3600,s.push(r(".days",null,a)))}if(t.hours){const o=Math.floor(e/3600);(0<o||s.length)&&(e-=3600*o,s.push(r(".hours",null,o)))}if(t.minutes){const l=Math.floor(e/60);(0<l||s.length||!t.seconds)&&(e-=60*l,s.push(r(".minutes",null,l)))}if(t.seconds){const h=Math.floor(e%60);s.push(r(".seconds",null,h))}const n=(t.approximate?i(".approx-prefix"):"")+s.join(i(".separator"));return C33.Lang.PopContext(),n},C33.ZeroPad=function(e,t){let s=e<0?"-":"",i=(e=Math.abs(e)).toString(),r=t-i.length;for(let e=0;e<r;++e)s+="0";return s+i},C33.StringToTitleCase=function(e){return e.toLowerCase().replace(/\b\w/g,e=>e.toUpperCase())},C33.CompareVersionStrings=function(e,t){let s=e.split(".").map(e=>e.trim()),i=t.split(".").map(e=>e.trim());C33.resizeArray(s,4,"0"),C33.resizeArray(i,4,"0"),s=s.map(e=>parseInt(e,10)),i=i.map(e=>parseInt(e,10));for(let e=0;e<4;++e){const r=s[e]-i[e];if(0!=r)return r<0?-1:1}return 0},C33.CreateGUID=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.floor(16*Math.random()),s="x"===e?t:3&t|8;return s.toString(16)})},C33.StringHammingDistance=function(s,i){if(s.length!==i.length)throw new Error("strings must be same length");let r=0;for(let e=0,t=s.length;e<t;++e)s.charAt(e)!==i.charAt(e)&&++r;return r},C33.StringLevenshteinDistance=function(e,t){if(0===e.length)return t.length;if(0===t.length)return e.length;let s,i,r,n,a,o;for(t.length<e.length&&(s=e,e=t,t=s),o=Array(e.length+1),i=0;i<=e.length;i++)o[i]=i;for(i=1;i<=t.length;i++){for(n=i,r=1;r<=e.length;r++)a=t[i-1]===e[r-1]?o[r-1]:Math.min(o[r-1]+1,Math.min(n+1,o[r]+1)),o[r-1]=n,n=a;o[e.length]=n}return o[e.length]}}{let bbToHtmlReplacerFunc2=function(e,s,i){const r=BB_CODE_MAP.get(i);if(!r)return"class"===i?s?"</span>":`<span class="bbclass${classIndex++}">`:e;if("string"==typeof r){if("a"===r&&0===linkActions.length||"abbr"===r&&0===tipList.length)return e;if("a"!==r||s){if("abbr"!==r||s)return"<"+s+r+">";{const n=parseInt(i.substring(3),10)-1;if(n<0||n>=tipList.length)throw new Error("invalid bbcode tip substitution");let e=tipList[n],t="";if("string"==typeof e?t=e:"function"==typeof e&&(t=e()),"string"!=typeof t)throw new TypeError("invalid bbcode tip");return`<abbr title="${C33.ReplaceAll(t,'"',""")}">`}}{const t=parseInt(i.substring(1),10)-1;if(t<0||t>=linkActions.length)throw new Error("invalid bbcode link substitution");const a=linkActions[t];if("string"==typeof a)return`<a href="${linkActions[t]}">`;if("function"==typeof a)return`<a class="bblink${t}">`;throw new TypeError("invalid bbcode link action")}}if(Array.isArray(r)){let e=r[0],t=r[1];return s?"</"+e+">":`<${e} class="${t}">`}},C33=(bbToHtmlReplacerFunc=bbToHtmlReplacerFunc2,self.C3),assert=self.assert,BB_CODE_MAP=new Map([["b","strong"],["i","em"],["s","s"],["u","u"],["sub","sub"],["sup","sup"],["small","small"],["mark","mark"],["code","code"],["a1","a"],["a2","a"],["a3","a"],["a4","a"],["a5","a"],["a6","a"],["a7","a"],["a8","a"],["a9","a"],["tip1","abbr"],["tip2","abbr"],["tip3","abbr"],["tip4","abbr"],["tip5","abbr"],["tip6","abbr"],["tip7","abbr"],["tip8","abbr"],["tip9","abbr"],["bad",["span","bbCodeBad"]],["good",["span","bbCodeGood"]],["info",["span","bbCodeInfo"]],["h1",["span","bbCodeH1"]],["h2",["span","bbCodeH2"]],["h3",["span","bbCodeH3"]],["h4",["span","bbCodeH4"]],["item",["span","bbCodeItem"]]]),SELF_CLOSING_TAGS=new Set(["icon"]),BBREGEX=/\[(\/?)([a-zA-Z0-9]+)\]/g,CUSTOM_BBREGEX=/\[(\/?)([^\[\n]*?)\]/g,linkActions=null,tipList=null,classIndex=0,LINEBREAK_REGEX=/\n/g;C33.BBString=class{constructor(e,t){if(this._bbstr=t&&t.noEscape?e:C33.EscapeHTML(e),this._htmlstr="",this._convertLineBreaks=!1,this._linkActions=[],this._tipList=[],t){if(this._convertLineBreaks=!!t.convertLineBreaks,t.links){if(9<t.links.length)throw new Error("too many links");this._linkActions=t.links}if(t.tips){if(9<t.tips.length)throw new Error("too many tips");this._tipList=t.tips}}this._hasAnyBBtags=this._bbstr.includes("["),this._needsLineBreakConversion=this._convertLineBreaks&&this._bbstr.includes("\n"),this._isPlain=!this._hasAnyBBtags&&!this._needsLineBreakConversion&&!this._bbstr.includes("&"),this._hasParsedFragments=!1,this._fragments=[]}toString(){return this._bbstr}valueOf(){return this._bbstr}isPlainText(){return this._isPlain}toPlainText(){return this._hasAnyBBtags?this._bbstr.replace(BBREGEX,""):this._bbstr}toHTML(){if(this._isPlain)return this._bbstr;if(!this._htmlstr&&this._bbstr){let e=this._bbstr;this._hasAnyBBtags&&(classIndex=0,linkActions=this._linkActions,tipList=this._tipList,e=e.replace(BBREGEX,bbToHtmlReplacerFunc2),linkActions=null,tipList=null),this._needsLineBreakConversion&&(e=e.replace(LINEBREAK_REGEX,"<br>")),this._htmlstr=e}return this._htmlstr}attachLinkHandlers(s){if(this._linkActions.length)for(let e=0,t=this._linkActions.length;e<t;++e){const i=this._linkActions[e];if("function"==typeof i){const r=s.querySelector(".bblink"+e);if(!r)throw new Error("unable to attach BBString link handler");r.onclick=i}}}equals(e){return e instanceof C33.HtmlString?this.toHTML()===e.toHTML():e instanceof C33.BBString?this._bbstr===e._bbstr:this._bbstr===e}toFragmentList(){if(!this._hasParsedFragments){let i=[],e=this._bbstr,r=[],t=CUSTOM_BBREGEX.lastIndex=0,s;for(;null!==(s=CUSTOM_BBREGEX.exec(e));){const n=s.index;if(!(0<n&&"\\"===e.charAt(n-1))){const a=s[0],o=s[1],l=s[2],h=e.substring(t,n);if(t=n+a.length,h&&i.push({text:h,styles:r.slice(0)}),l)if(o){const c=l.toLowerCase();for(let e=r.length-1;0<=e;--e)if(r[e].tag===c){r.splice(e,1);break}}else{let e=l,t=null,s=l.indexOf("=");if(-1!==s?(e=l.substring(0,s).toLowerCase(),t=l.substring(s+1)):e=e.toLowerCase(),SELF_CLOSING_TAGS.has(e)){if("icon"!==e)throw new Error("unknown self-closing tag "+e);i.push({icon:t,styles:r.slice(0)})}else r.push({tag:e,param:t})}}}t<e.length&&i.push({text:e.substring(t),styles:r.slice(0)});for(const u of i)u.text&&(u.text=this._ProcessBBCodeEscapeSequences(u.text));this._fragments=i.map(e=>e.icon?C33.New(C33.IconFragment,{icon:e.icon,styles:e.styles}):C33.New(C33.TextFragment,{chArr:C33.SplitGraphemes(e.text),styles:e.styles})),this._hasParsedFragments=!0}return this._fragments}_ProcessBBCodeEscapeSequences(e){return e=C33.ReplaceAll(e,"\\[","["),C33.ReplaceAll(e,"\\\\","\\")}static StripTags(e){return C33.New(C33.BBString,e,{noEscape:!0}).toPlainText()}static StripAnyTags(e){return e.replace(CUSTOM_BBREGEX,"")}}}{let IsWordBreakWhiteSpace2=function(e){return" "!==e&&" "!==e&&C33.IsWhitespaceChar(e)},IsOpeningCJKPunctiationChar2=function(e){return CJK_OPEN_PUNCTUATION.has(e)},IsContinuingCJKPunctuationChar2=function(e){return C33.IsCJKPunctuationChar(e)&&!IsOpeningCJKPunctiationChar2(e)},WordBreakTrimEnd2=function(e){for(;0<e.length&&IsWordBreakWhiteSpace2(e.at(-1));)e.pop()},IsNewline2=function(e){return"\n"===e||"\r\n"===e};IsWordBreakWhiteSpace=IsWordBreakWhiteSpace2,IsOpeningCJKPunctiationChar=IsOpeningCJKPunctiationChar2,IsContinuingCJKPunctuationChar=IsContinuingCJKPunctuationChar2,WordBreakTrimEnd=WordBreakTrimEnd2,IsNewline=IsNewline2;const C33=self.C3,CJK_OPEN_PUNCTUATION=new Set("〈《「『【〔〖〘〚〝");C33.WordWrap=class{constructor(){this._lines=[],this._iconSet=null}GetLines(){return this._lines}GetLineCount(){return this._lines.length}SetIconSet(e){this._iconSet=e}_MeasureLine(e,t){let s=0,i=0,r=0,n=0,a=0;for(const o of e){if(-1===o.GetWidth()){const l=t(o);o.SetHeight(l.height),o.SetFontBoundingBoxAscent(l.fontBoundingBoxAscent||0),o.SetFontBoundingBoxDescent(l.fontBoundingBoxDescent||0),o.SetTopToAlphabeticDistance(l.topToAlphabeticDistance||0),o.IsText()?o.SetWidth(l.width):o.IsIcon()&&o.CalculateWidthFromHeight(this._iconSet)}s+=o.GetWidth(),i=Math.max(i,o.GetHeight()),r=Math.max(r,o.GetFontBoundingBoxAscent()),n=Math.max(n,o.GetFontBoundingBoxDescent()),a=Math.max(a,o.GetTopToAlphabeticDistance())}return{width:s,height:i,fontBoundingBoxAscent:r,fontBoundingBoxDescent:n,topToAlphabeticDistance:a}}_AddLine(e,t,s,i,r,n){this._lines.push(C33.New(C33.WordWrap.Line,{fragments:e,width:t,height:s,fontBoundingBoxAscent:i,fontBoundingBoxDescent:r,topToAlphabeticDistance:n}))}WordWrap(t,n,a,s,o){if("string"==typeof t&&(t=[C33.New(C33.TextFragment,{chArr:C33.SplitGraphemes(t)})]),C33.clearArray(this._lines),!(!t.length||1===t.length&&t[0].IsText()&&t[0].IsEmpty()||a<2)){if(1===t.length){const l=t[0];if(l.IsText()&&l.GetLength()<=100&&!l.HasNewLine()){let{width:e,height:t,fontBoundingBoxAscent:s,fontBoundingBoxDescent:i,topToAlphabeticDistance:r}=n(l);if(e+=o,l.SetWidth(e),l.SetHeight(t),l.SetFontBoundingBoxAscent(s||0),l.SetFontBoundingBoxDescent(i||0),l.SetTopToAlphabeticDistance(r||0),e<=a)return void this._AddLine([l],e,t,s,i,r)}}let e;e="word"===s?this._TokeniseByWord(t):"cjk"===s?this._TokeniseByCJK(t):this._TokeniseByChar(t),this._WrapText(e,n,a,o)}}_TokeniseByWord(e){let t=[],s=[],i=!1;for(const r of e){const n=r.GetStyles();if(r.IsIcon())0<s.length&&t.push(s),t.push([r]),s=[];else for(const a of r.GetCharacterArray())if(IsNewline2(a))0<s.length&&t.push(s),t.push([C33.New(C33.TextFragment,{chArr:["\n"],styles:n})]),s=[];else if(0===s.length)s.push(C33.New(C33.TextFragment,{chArr:[a],styles:n})),i=IsWordBreakWhiteSpace2(a);else{const o=IsWordBreakWhiteSpace2(a);if(o===i){const l=s.at(-1);l.GetStyles()===n?l._AppendChar(a):s.push(C33.New(C33.TextFragment,{chArr:[a],styles:n}))}else t.push(s),s=[C33.New(C33.TextFragment,{chArr:[a],styles:n})],i=o}}return 0<s.length&&t.push(s),t}_TokeniseByCJK(e){let t=[],s=[],i=!1;for(const r of e){const n=r.GetStyles();if(r.IsIcon())0<s.length&&t.push(s),t.push([r]),s=[];else for(const a of r.GetCharacterArray())if(IsNewline2(a))0<s.length&&t.push(s),t.push([C33.New(C33.TextFragment,{chArr:["\n"],styles:n})]),s=[];else{if(0===s.length)s.push(C33.New(C33.TextFragment,{chArr:[a],styles:n}));else if(i||IsContinuingCJKPunctuationChar2(a)){const o=s.at(-1);o.GetStyles()===n?o._AppendChar(a):s.push(C33.New(C33.TextFragment,{chArr:[a],styles:n}))}else t.push(s),s=[C33.New(C33.TextFragment,{chArr:[a],styles:n})];i=IsOpeningCJKPunctiationChar2(a)}}return 0<s.length&&t.push(s),t}_TokeniseByChar(e){const t=[];for(const s of e)if(s.IsText()){const i=s.GetCharacterArray();C33.appendArray(t,i.map(e=>[C33.New(C33.TextFragment,{chArr:[e],styles:s.GetStyles()})]))}else t.push([s]);return t}_CopyLine(e){return e.map(e=>e._Clone())}_AddWordToLine(t,s){let e=t.length?t.at(-1):null,i=0;e&&e.IsText()&&s[0].IsText()&&s[0].GetStyles()===e.GetStyles()&&(e._Append(s[0].GetCharacterArray()),i=1);for(let e=s.length;i<e;++i){const r=s[i];t.push(r._Clone())}}_WrapText(e,t,s,i){let r=[],n=0,a=0,o=0,l=0,h=0;for(const c of e)if(1===c.length&&c[0].IsText()&&1===c[0].GetLength()&&IsNewline2(c[0].GetCharacterArray()[0])){if(0===a){const u=C33.New(C33.TextFragment,{chArr:[" "],styles:c[0].GetStyles()}),_=t(u);a=_.height,o=_.fontBoundingBoxAscent||0,l=_.fontBoundingBoxDescent||0,h=_.topToAlphabeticDistance||0}this._AddLine(r,n,a,o,l,h),r=[],n=0,a=0,o=0,l=0,h=0}else{const d=this._CopyLine(r),p=(this._AddWordToLine(d,c),this._MeasureLine(d,t)),m=p.width;if(s<=m)if(0<r.length&&this._AddLine(r,n,a,o,l,h),r=[],c[0].IsText()&&C33.IsCharArrayAllWhitespace(c[0].GetCharacterArray()))n=0,a=0,o=0,l=0,h=0;else{this._AddWordToLine(r,c);const g=this._MeasureLine(r,t);n=g.width,a=g.height,o=g.fontBoundingBoxAscent,l=g.fontBoundingBoxDescent,h=g.topToAlphabeticDistance}else r=d,n=m,a=p.height,o=p.fontBoundingBoxAscent,l=p.fontBoundingBoxDescent,h=p.topToAlphabeticDistance}0<r.length&&this._AddLine(r,n,a,o,l,h),this._TrimLinesTrailingWhitespace(t,i)}_TrimLinesTrailingWhitespace(t,s){for(const i of this._lines){const r=i._GetFragmentsArray();if(r.length){let e=r.at(-1);if(e.IsText()){const n=e.GetCharacterArray(),a=n.slice(0);if(WordBreakTrimEnd2(a),0===a.length)i.OffsetWidth(-e.GetWidth()),r.pop();else if(a.length<n.length){e.SetCharacterArray(a);const o=t(e).width,l=e.GetWidth()-o;e.SetWidth(o),i.OffsetWidth(-l)}0!==s&&0<r.length&&((e=r.at(-1)).OffsetWidth(s),i.OffsetWidth(s))}}}}Clear(){C33.clearArray(this._lines)}GetMaxLineWidth(){return this._lines.reduce((e,t)=>Math.max(e,t.GetWidth()),0)}GetTotalLineHeight(){return this._lines.reduce((e,t)=>e+t.GetHeight(),0)}}}{const C33=self.C3;C33.WordWrap.Line=class{constructor(e){this._fragments=e.fragments||[],this._width=e.width||-1,this._height=e.height||-1,this._fontBoundingBoxAscent=e.fontBoundingBoxAscent||-1,this._fontBoundingBoxDescent=e.fontBoundingBoxDescent||-1,this._topToAlphabeticDistance=e.topToAlphabeticDistance||-1,this._posX=0,this._posY=0}fragments(){return this._fragments.values()}*fragmentsReverse(){const t=this._fragments;for(let e=t.length-1;0<=e;--e)yield t[e]}_GetFragmentsArray(){return this._fragments}OffsetWidth(e){this._width+=e}GetWidth(){return this._width}GetHeight(){return this._height}GetFoundBoundingBoxAscent(){return this._fontBoundingBoxAscent}GetFontBoundingBoxDescent(){return this._fontBoundingBoxDescent}GetTopToAlphabeticDistance(){return this._topToAlphabeticDistance}SetPosX(e){this._posX=e}GetPosX(){return this._posX}SetPosY(e){this._posY=e}GetPosY(){return this._posY}}}{const C33=self.C3;C33.FragmentBase=class{constructor(e){this._styles=e.styles||[],this._width=e.width||-1,this._height=e.height||-1,this._fontBoundingBoxAscent=e.fontBoundingBoxAscent||-1,this._fontBoundingBoxDescent=e.fontBoundingBoxDescent||-1,this._topToAlphabeticDistance=e.topToAlphabeticDistance||-1,this._posX=0,this._posY=0}IsText(){return!1}IsIcon(){return!1}GetStyles(){return this._styles}GetStyleTag(t){const s=this._styles;for(let e=s.length-1;0<=e;--e){const i=s[e];if(i.tag===t)return i}return null}HasStyleTag(e){return!!this.GetStyleTag(e)}GetStyleMap(){const e=new Map;for(const t of this._styles)e.set(t.tag,t.param);return e}OffsetWidth(e){this._width+=e}SetWidth(e){this._width=e}GetWidth(){return this._width}SetHeight(e){this._height=e}GetHeight(){return this._height}SetFontBoundingBoxAscent(e){this._fontBoundingBoxAscent=e}GetFontBoundingBoxAscent(){return this._fontBoundingBoxAscent}SetFontBoundingBoxDescent(e){this._fontBoundingBoxDescent=e}GetFontBoundingBoxDescent(){return this._fontBoundingBoxDescent}SetTopToAlphabeticDistance(e){this._topToAlphabeticDistance=e}GetTopToAlphabeticDistance(){return this._topToAlphabeticDistance}SetPosX(e){this._posX=e}GetPosX(){return this._posX}SetPosY(e){this._posY=e}GetPosY(){return this._posY}}}{const C33=self.C3;C33.TextFragment=class extends C33.FragmentBase{constructor(e){super(e),this._chArr=e.chArr}IsText(){return!0}_Append(e){C33.appendArray(this._chArr,e),this._width=-1,this._height=-1,this._fontBoundingBoxAscent=-1,this._fontBoundingBoxDescent=-1,this._topToAlphabeticDistance=-1}_AppendChar(e){this._chArr.push(e)}_Clone(){return C33.New(C33.TextFragment,{chArr:this._chArr.slice(0),styles:this._styles,width:this._width,height:this._height,fontBoundingBoxAscent:this._fontBoundingBoxAscent,fontBoundingBoxDescent:this._fontBoundingBoxDescent,topToAlphabeticDistance:this._topToAlphabeticDistance})}GetCharacterArray(){return this._chArr}SetCharacterArray(e){this._chArr=e}GetLength(){return this._chArr.length}IsEmpty(){return 0===this._chArr.length}HasNewLine(){return this._chArr.includes("\n")}}}{const C33=self.C3;C33.IconFragment=class extends C33.FragmentBase{constructor(e){super(e),this._icon=e.icon}IsIcon(){return!0}GetIconParameter(){return this._icon}_Clone(){return C33.New(C33.IconFragment,{icon:this._icon,styles:this._styles,width:this._width,height:this._height,fontBoundingBoxAscent:this._fontBoundingBoxAscent,fontBoundingBoxDescent:this._fontBoundingBoxDescent,topToAlphabeticDistance:this._topToAlphabeticDistance})}GetTextIcon(e){if(!e)return null;let t=Number(this._icon);return String(t)===this._icon?(t=Math.floor(t),e.GetTextIconByIndex(t)):e.GetTextIconByTag(this._icon)}CalculateWidthFromHeight(e){const t=this.GetTextIcon(e);this._width=t?this._height*t.GetWidth()/t.GetHeight():0}GetDrawable(e){const t=this.GetTextIcon(e);return t?t.GetDrawable():null}GetLength(){return 1}}}{const C33=self.C3;C33.TextIconManager=class{constructor(e){this._iconSets=new Map,this._getIconSetMetaCallback=e.getIconSetMeta,this._getIconSetContentCallback=e.getIconSetContent}Release(){for(const e of this._iconSets.values())e.Release();this._iconSets.clear()}GetIconSet(e){let t=this._iconSets.get(e);if(!t){const s=this._getIconSetMetaCallback(e);t=C33.New(C33.TextIconSet,this,{source:e,iconMeta:s}),this._iconSets.set(e,t)}return t}HasIconSet(e){return this._iconSets.has(e)}DeleteIconSet(e){const t=this._iconSets.get(e);t&&t.Release(),this._iconSets.delete(e)}async _GetIconSetContent(e){return this._getIconSetContentCallback(e)}}}{const C33=self.C3;C33.TextIconSet=class{constructor(e,t){this._textIconManager=e,this._source=t.source,this._iconsArray=[],this._iconsByTag=new Map,this._hasStartedLoad=!1,this._isLoading=!1,this._loadPromise=null;const s=t.iconMeta.icons;for(let e=0,t=s.length;e<t;++e){const i=s[e],r=C33.New(C33.TextIcon,this,{index:e,tag:i.tag,source:i.source,width:i.width,height:i.height});this._iconsArray.push(r),i.tag&&this._iconsByTag.set(i.tag.toLowerCase(),r)}}Release(){for(const e of this._iconsArray)e.Release();C33.clearArray(this._iconsArray),this._iconsByTag.clear(),this._textIconManager=null,this._source=null}HasLoaded(){return this._hasStartedLoad}IsLoading(){return this._isLoading}LoadContent(){return this._loadPromise||(this._loadPromise=this._DoLoadContent()),this._loadPromise}async _DoLoadContent(){if(!this._hasStartedLoad){this._hasStartedLoad=!0,this._isLoading=!0;const e=await this._textIconManager._GetIconSetContent(this._source);if(this._textIconManager){const s=e.icons;for(let e=0,t=Math.min(s.length,this._iconsArray.length);e<t;++e){const i=s[e].drawable;this._iconsArray[e]._SetDrawable(i)}this._isLoading=!1}}}GetTextIconByIndex(e){return(e=Math.floor(e))<0||e>=this._iconsArray.length?null:this._iconsArray[e]}GetTextIconByTag(e){return this._iconsByTag.get(e.toLowerCase())||null}}}{const C33=self.C3;C33.TextIcon=class{constructor(e,t){this._textIconSet=e,this._source=t.source||null,this._index=t.index,this._tag=t.tag,this._width=t.width,this._height=t.height,this._drawable=null}Release(){this._width=0,this._height=0,this._textIconSet=null}GetSource(){return this._source}GetWidth(){return this._width}GetHeight(){return this._height}_SetDrawable(e){this._drawable=e}GetDrawable(){return this._drawable}}}{let PlaneFromPoints2=function(e,t,s,i){const r=tempVec3c;vec32.subtract(tempVec3a,s,t),vec32.subtract(tempVec3b,e,t),vec32.cross(r,tempVec3a,tempVec3b),vec32.normalize(r,r),i.set(r[0],r[1],r[2],vec32.dot(e,r))},IsInFrontOfPlane2=function(e,t,s,i,r,n,a){const o=a.x,l=a.y,h=a.z,c=a.w,u=a.xF,_=a.yF,d=a.zF,p=1-u,m=1-_,g=1-d,f=o*e*u+o*i*p+l*t*_+l*r*m+h*s*d+h*n*g;if(c<=f)return!0;const S=o*i*u+o*e*p+l*r*_+l*t*m+h*n*d+h*s*g;return c<S},IsPointInFrontOfPlane2=function(e,t,s,i){const r=i.x,n=i.y,a=i.z,o=i.w,l=r*e+n*t+a*s;return o<=l};PlaneFromPoints=PlaneFromPoints2,IsInFrontOfPlane=IsInFrontOfPlane2,IsPointInFrontOfPlane=IsPointInFrontOfPlane2;const C33=self.C3,glMatrix=self.glMatrix,vec32=glMatrix.vec3,vec42=glMatrix.vec4,mat42=glMatrix.mat4,tempVec3a=vec32.create(),tempVec3b=vec32.create(),tempVec3c=vec32.create(),tempVec4=vec42.create(),tempMat4=mat42.create(),neartl=vec32.create(),neartr=vec32.create(),nearbl=vec32.create(),nearbr=vec32.create(),fartl=vec32.create(),fartr=vec32.create(),farbl=vec32.create(),farbr=vec32.create(),unitViewport=vec42.fromValues(0,0,1,1);C33.Gfx={Project(e,t,s,i,r,n,a){let o=i[0]*e+i[4]*t+i[8]*s+i[12],l=i[1]*e+i[5]*t+i[9]*s+i[13],h=i[2]*e+i[6]*t+i[10]*s+i[14],c=i[3]*e+i[7]*t+i[11]*s+i[15],u=r[0]*o+r[4]*l+r[8]*h+r[12]*c,_=r[1]*o+r[5]*l+r[9]*h+r[13]*c,d=r[2]*o+r[6]*l+r[10]*h+r[14]*c,p=r[3]*o+r[7]*l+r[11]*h+r[15]*c;return 0!=p&&(_*=p=1/p,d*=p,a[0]=(.5*(u*=p)+.5)*n[2]+n[0],a[1]=(.5*_+.5)*n[3]+n[1],a[2]=.5*(1+d),!0)},Unproject(e,t,s,i,r,n,a){const o=tempMat4,l=tempVec4;return mat42.multiply(o,r,i),null!==mat42.invert(o,o)&&(l[0]=(e-n[0])/n[2]*2-1,l[1]=(t-n[1])/n[3]*2-1,l[2]=2*s-1,l[3]=1,vec42.transformMat4(l,l,o),0!==l[3])&&(l[3]=1/l[3],a[0]=l[0]*l[3],a[1]=l[1]*l[3],a[2]=l[2]*l[3],!0)},UnprojectScreenToWorldZ(e,t,s,i,r,n,a){const o=tempVec3a,l=tempVec3b;if(!C33.Gfx.Unproject(e,t,0,i,r,n,o))return!1;if(!C33.Gfx.Unproject(e,t,1,i,r,n,l))return!1;let h=tempVec3b,c=(vec32.subtract(h,l,o),tempVec3c),u=(vec32.set(c,0,0,1),-s),_=vec32.dot(c,h),d=0;if(0===_){const p=vec32.dot(c,o)+u;if(0!==p)return!1}else if((d=-(vec32.dot(o,c)+u)/_)<0)return!1;return vec32.scaleAndAdd(a,o,h,d),!0}};class Plane{constructor(){this.x=NaN,this.y=NaN,this.z=NaN,this.w=NaN,this.xF=NaN,this.yF=NaN,this.zF=NaN}set(e,t,s,i){this.x=e,this.y=t,this.z=s,this.w=i,this.xF=0<e?1:0,this.yF=0<t?1:0,this.zF=0<s?1:0}}C33.Gfx.ViewFrustum=class{constructor(){this._leftP=new Plane,this._topP=new Plane,this._rightP=new Plane,this._bottomP=new Plane,this._nearP=new Plane,this._farP=new Plane}CalculatePlanes(e,t){const s=unitViewport;C33.Gfx.Unproject(0,1,0,e,t,s,neartl),C33.Gfx.Unproject(1,1,0,e,t,s,neartr),C33.Gfx.Unproject(0,0,0,e,t,s,nearbl),C33.Gfx.Unproject(1,0,0,e,t,s,nearbr),C33.Gfx.Unproject(0,1,1,e,t,s,fartl),C33.Gfx.Unproject(1,1,1,e,t,s,fartr),C33.Gfx.Unproject(0,0,1,e,t,s,farbl),C33.Gfx.Unproject(1,0,1,e,t,s,farbr),PlaneFromPoints2(nearbl,neartl,fartl,this._leftP),PlaneFromPoints2(neartl,neartr,fartr,this._topP),PlaneFromPoints2(neartr,nearbr,farbr,this._rightP),PlaneFromPoints2(nearbr,nearbl,farbl,this._bottomP),PlaneFromPoints2(farbl,fartl,fartr,this._farP),PlaneFromPoints2(nearbr,neartr,neartl,this._nearP)}ContainsAABB(e,t,s,i,r,n){return IsInFrontOfPlane2(e,t,s,i,r,n,this._leftP)&&IsInFrontOfPlane2(e,t,s,i,r,n,this._topP)&&IsInFrontOfPlane2(e,t,s,i,r,n,this._rightP)&&IsInFrontOfPlane2(e,t,s,i,r,n,this._bottomP)&&IsInFrontOfPlane2(e,t,s,i,r,n,this._nearP)&&IsInFrontOfPlane2(e,t,s,i,r,n,this._farP)}IsBehindNearPlane(e,t,s){return!IsPointInFrontOfPlane2(e,t,s,this._nearP)}}}{const C33=self.C3,glMatrix=self.glMatrix,vec32=glMatrix.vec3,vec42=glMatrix.vec4,mat42=glMatrix.mat4,tempMat4=mat42.create(),tmpVec3a=vec32.fromValues(0,0,0),tmpVec3b=vec32.fromValues(0,0,0),tmpVec3c=vec32.fromValues(0,0,0),defaultUpVector=vec32.fromValues(0,1,0),tmpVec4=vec42.fromValues(0,0,0,0),tmpQuad=new C33.Quad,tmpRect=new C33.Rect,defaultTexCoordsQuad=new C33.Quad(0,0,1,0,1,1,0,1),DEFAULT_RENDERERBASE_OPTS={nearZ:1,farZ:1e4},matWebGLtoWebGPU=mat42.fromValues(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1);C33.Gfx.RendererBase=class{constructor(e){e=Object.assign({},DEFAULT_RENDERERBASE_OPTS,e),this._width=0,this._height=0,this._fovY=C33.toRadians(45),this._tan_fovY_2=Math.tan(this._fovY/2),this._matP=mat42.create(),this._matMV=mat42.create(),this._zAxisScale=!1,this._nearZ=e.nearZ,this._farZ=e.farZ,this._allShaderPrograms=[],this._shaderProgramsByName=new Map,this._spTextureFill=null,this._spPoints=null,this._spTilemapFill=null,this._spTileRandomization=null,this._spColorFill=null,this._spLinearGradientFill=null,this._spPenumbraFill=null,this._spHardEllipseFill=null,this._spHardEllipseOutline=null,this._spSmoothEllipseFill=null,this._spSmoothEllipseOutline=null,this._spSmoothLineFill=null,this._stateGroups=new Map,this._currentStateGroup=null,this._blendModeTable=[],this._namedBlendModeMap=new Map,this._baseZ=0,this._currentZ=0,this._lineWidth=1,this._lineWidthStack=[this._lineWidth],this._lineCap=1,this._lineCapStack=[this._lineCap],this._lineOffset=.5,this._lineOffsetStack=[this._lineOffset],this._frameNumber=0,this._enableMipmaps=!0,this._hasMajorPerformanceCaveat=!1}FillIndexBufferData(e){let t=0,s=e.length,i=0;for(;t<s;)e[t++]=i,e[t++]=i+1,e[t++]=i+2,e[t++]=i,e[t++]=i+2,e[t++]=i+3,i+=4}_ClearState(){this._baseZ=0,this._currentZ=0,this._spTextureFill=null,this._spPoints=null,this._spTilemapFill=null,this._spTileRandomization=null,this._spColorFill=null,this._spLinearGradientFill=null,this._spPenumbraFill=null,this._spHardEllipseFill=null,this._spHardEllipseOutline=null,this._spSmoothEllipseFill=null,this._spSmoothEllipseOutline=null,this._spSmoothLineFill=null,this._ClearAllShaderPrograms()}InitState(){this._ClearState(),this._currentStateGroup=null}OnDeviceOrContextLost(){for(const e of this._allShaderPrograms)e.Release();this._ClearState()}GetWidth(){return this._width}GetHeight(){return this._height}GetDefaultCameraZ(e){return this.IsZAxisScaleNormalized()?100:e/(2*this._GetTanFovYDiv2())}GetZAxisScaleFactor(e){if(this.IsZAxisScaleNormalized()){const t=e/(2*this._GetTanFovYDiv2());return t/this.GetDefaultCameraZ(e)}return 1}SetNearZ(e){this._nearZ=e}GetNearZ(){return this._nearZ}SetFarZ(e){this._farZ=e}GetFarZ(){return this._farZ}SetFovY(e){this._fovY=e,this._tan_fovY_2=Math.tan(this._fovY/2)}GetFovY(){return this._fovY}_GetTanFovYDiv2(){return this._tan_fovY_2}SetZAxisScaleNormalized(){this._zAxisScale=!1}SetZAxisScaleRegular(){this._zAxisScale=!0}IsZAxisScaleNormalized(){return!this._zAxisScale}IsZAxisScaleRegular(){return this._zAxisScale}CalculatePerspectiveMatrix(e,t,s=.5,i=.5){const r=this.GetNearZ(),n=this.GetFarZ(),a=this.GetFovY();if(.5===s&&.5===i)this.IsWebGPU()?mat42.perspectiveZO(e,a,t,r,n):mat42.perspective(e,a,t,r,n);else{const o=2*(s=1-s)-2,l=2*s,h=2*i-2,c=2*i,u=this._GetTanFovYDiv2()*r,_=u*t;mat42.frustum(e,o*_,l*_,h*u,c*u,r,n),this.IsWebGPU()&&mat42.mul(e,matWebGLtoWebGPU,e)}}CalculateOrthographicMatrix(e,t,s,i=1){const r=self.devicePixelRatio,n=2*this.GetDefaultCameraZ(s)*r*this._GetTanFovYDiv2()/s,a=t*n/(2*r*i),o=s*n/(2*r*i),l=-a,h=a,c=-o,u=o;this.IsWebGPU()?mat42.orthoZO(e,l,h,c,u,this.GetNearZ(),this.GetFarZ()):mat42.ortho(e,l,h,c,u,this.GetNearZ(),this.GetFarZ())}CalculateLookAtModelView(e,t,s,i,r,n=1){let a=1;this.IsZAxisScaleNormalized()&&(a=200*this._GetTanFovYDiv2()/r);const o=tmpVec3c,l=(vec32.set(o,a,-a,1),tmpVec3a),h=tmpVec3b;vec32.multiply(l,t,o),vec32.multiply(h,s,o),mat42.lookAt(e,l,h,i||defaultUpVector),o[2]=n,mat42.scale(e,e,o)}CalculateLookAtModelView2(e,t,s,i,r,n,a,o){return vec32.set(tmpVec3a,e,t,s),vec32.set(tmpVec3b,i,r,n),this.CalculateLookAtModelView(tempMat4,tmpVec3a,tmpVec3b,defaultUpVector,a,o),tempMat4}_AddShaderProgram(e){this._allShaderPrograms.push(e),this._shaderProgramsByName.set(e.GetName(),e)}_RemoveShaderProgram(e){const t=this._allShaderPrograms.indexOf(e);-1!==t&&this._allShaderPrograms.splice(t,1),this._shaderProgramsByName.delete(e.GetName())}_ClearAllShaderPrograms(){C33.clearArray(this._allShaderPrograms),this._shaderProgramsByName.clear()}GetShaderProgramByName(e){return this._shaderProgramsByName.get(e)||null}GetTextureFillShaderProgram(){return this._spTextureFill}SetTextureFillMode(){this.SetProgram(this._spTextureFill)}GetPointsRenderingProgram(){return this._spPoints}SetPointsRenderingProgram(){this.SetProgram(this._spPoints)}SetTilemapFillMode(){this.SetProgram(this._spTilemapFill)}SetTileRandomizationMode(){this.SetProgram(this._spTileRandomization)}SetColorFillMode(){this.SetProgram(this._spColorFill)}SetLinearGradientFillMode(){this.SetProgram(this._spLinearGradientFill)}SetPenumbraFillMode(){this.SetProgram(this._spPenumbraFill)}SetHardEllipseFillMode(){this.SetProgram(this._spHardEllipseFill)}SetHardEllipseOutlineMode(){this.SetProgram(this._spHardEllipseOutline)}SetSmoothEllipseFillMode(){this.SetProgram(this._spSmoothEllipseFill)}SetSmoothEllipseOutlineMode(){this.SetProgram(this._spSmoothEllipseOutline)}SetSmoothLineFillMode(){this.SetProgram(this._spSmoothLineFill)}_SetCurrentStateGroup(e){this._currentStateGroup=e}GetCurrentStateGroup(){return this._currentStateGroup}AcquireStateGroup(e,t,s,i){let r=C33.Gfx.StateGroup.MakeKey(e,t,s,i),n=this._stateGroups.get(r);return n||(n=C33.New(C33.Gfx.StateGroup,this,e,t,s,i),this._stateGroups.set(r,n)),n.AddRef(),n}ReleaseStateGroup(e){e.DecRef(),0===e._GetRefCount()&&(this._currentStateGroup===e&&(this._currentStateGroup=null),this._stateGroups.delete(e.GetKey()),e.Release())}_InitBlendModeData(e){C33.clearArray(this._blendModeTable),this._namedBlendModeMap.clear();let t=0;for(const s of e){const i=s[0],r=s[1],n=s[2];this._blendModeTable.push([r,n]),this._namedBlendModeMap.set(i,{number:t,srcBlend:r,destBlend:n}),t++}}_GetBlendByIndex(e){return this._blendModeTable[e]}GetSrcBlendByIndex(e){return this._GetBlendByIndex(e)[0]}GetDestBlendByIndex(e){return this._GetBlendByIndex(e)[1]}GetNamedBlend(e){const t=this._namedBlendModeMap.get(e);if(void 0===t)throw new Error("invalid blend name");return t}NamedBlendToNumber(e){const t=this._namedBlendModeMap.get(e);if(void 0===t)throw new Error("invalid blend name");return t.number}SetBaseZ(e){this._baseZ=e}GetBaseZ(){return this._baseZ}SetCurrentZ(e){this._currentZ=e,this._currentStateGroup=null}GetCurrentZ(){return this._currentZ}Line(e,t,s,i){const r=C33.angleTo(e,t,s,i),n=Math.sin(r),a=Math.cos(r),o=.5*this._lineWidth,l=n*o,h=a*o,c=this._lineCap;2===c?this.LinePreCalc_LineCap2(e,t,0,s,i,0,l,h):1===c?this.LinePreCalc_LineCap1(e,t,0,s,i,0,l,h):this.LinePreCalc_LineCap0(e,t,0,s,i,0,l,h)}Line3D(e,t,s,i,r,n){const a=C33.angleTo(e,t,i,r),o=Math.sin(a),l=Math.cos(a),h=.5*this._lineWidth,c=o*h,u=l*h,_=this._lineCap;2===_?this.LinePreCalc_LineCap2(e,t,s,i,r,n,c,u):1===_?this.LinePreCalc_LineCap1(e,t,s,i,r,n,c,u):this.LinePreCalc_LineCap0(e,t,s,i,r,n,c,u)}LinePreCalc_LineCap2(e,t,s,i,r,n,a,o){const l=this._lineOffset,h=e+l-o,c=t+l-a,u=i+l+o,_=r+l+a,d=2*o,p=2*a,m=h+a,g=c-o,f=h-a+d,S=c+o+p,C=u+a,y=_-o,G=u-a-d,I=_+o-p;this.Quad3D2(m,g,s,C,y,n,G,I,n,f,S,s,defaultTexCoordsQuad)}LinePreCalc_LineCap1(e,t,s,i,r,n,a,o){const l=this._lineOffset,h=e+l-o,c=t+l-a,u=i+l+o,_=r+l+a,d=h+a,p=c-o,m=h-a,g=c+o,f=u+a,S=_-o,C=u-a,y=_+o;this.Quad3D2(d,p,s,f,S,n,C,y,n,m,g,s,defaultTexCoordsQuad)}LinePreCalc_LineCap0(e,t,s,i,r,n,a,o){const l=this._lineOffset,h=e+l,c=t+l,u=i+l,_=r+l,d=h+a,p=c-o,m=h-a,g=c+o,f=u+a,S=_-o,C=u-a,y=_+o;this.Quad3D2(d,p,s,f,S,n,C,y,n,m,g,s,defaultTexCoordsQuad)}TexturedLine(e,t,s,i,r,n){const a=C33.angleTo(e,t,s,i),o=Math.sin(a),l=Math.cos(a),h=.5*this._lineWidth,c=o*h,u=l*h,_=this._lineCap;2===_?this.TexturedLinePreCalc_LineCap2(e,t,s,i,c,u,r,n):1===_?this.TexturedLinePreCalc_LineCap1(e,t,s,i,c,u,r,n):this.TexturedLinePreCalc_LineCap0(e,t,s,i,c,u,r,n)}TexturedLinePreCalc_LineCap2(e,t,s,i,r,n,a,o){const l=this._lineOffset,h=e+l-n,c=t+l-r,u=s+l+n,_=i+l+r,d=2*n,p=2*r,m=h+r,g=c-n,f=h-r+d,S=c+n+p,C=u+r,y=_-n,G=u-r-d,I=_+n-p;tmpQuad.set(m,g,C,y,G,I,f,S),tmpRect.set(a,0,o,0),this.Quad3(tmpQuad,tmpRect)}TexturedLinePreCalc_LineCap1(e,t,s,i,r,n,a,o){const l=this._lineOffset,h=e+l-n,c=t+l-r,u=s+l+n,_=i+l+r,d=h+r,p=c-n,m=h-r,g=c+n,f=u+r,S=_-n,C=u-r,y=_+n;tmpQuad.set(d,p,f,S,C,y,m,g),tmpRect.set(a,0,o,0),this.Quad3(tmpQuad,tmpRect)}TexturedLinePreCalc_LineCap0(e,t,s,i,r,n,a,o){const l=this._lineOffset,h=e+l,c=t+l,u=s+l,_=i+l,d=h+r,p=c-n,m=h-r,g=c+n,f=u+r,S=_-n,C=u-r,y=_+n;tmpQuad.set(d,p,f,S,C,y,m,g),tmpRect.set(a,0,o,0),this.Quad3(tmpQuad,tmpRect)}LineRect(e,t,s,i){const r=.5*this._lineWidth,n=this._lineCap;2===n?this._LineRectPreCalc_LineCap2(e,t,s,i,r):1===n?this._LineRectPreCalc_LineCap1(e,t,s,i,r):this._LineRectPreCalc_LineCap0(e,t,s,i,r)}_LineRectPreCalc_LineCap2(e,t,s,i,r){this.LinePreCalc_LineCap2(e,t,0,s,t,0,0,r),this.LinePreCalc_LineCap2(s,t,0,s,i,0,r,0),this.LinePreCalc_LineCap2(s,i,0,e,i,0,0,-r),this.LinePreCalc_LineCap2(e,i,0,e,t,0,-r,0)}_LineRectPreCalc_LineCap1(e,t,s,i,r){this.LinePreCalc_LineCap1(e,t,0,s,t,0,0,r),this.LinePreCalc_LineCap1(s,t,0,s,i,0,r,0),this.LinePreCalc_LineCap1(s,i,0,e,i,0,0,-r),this.LinePreCalc_LineCap1(e,i,0,e,t,0,-r,0)}_LineRectPreCalc_LineCap0(e,t,s,i,r){this.LinePreCalc_LineCap0(e,t,0,s,t,0,0,r),this.LinePreCalc_LineCap0(s,t,0,s,i,0,r,0),this.LinePreCalc_LineCap0(s,i,0,e,i,0,0,-r),this.LinePreCalc_LineCap0(e,i,0,e,t,0,-r,0)}LineRect2(e){this.LineRect(e.getLeft(),e.getTop(),e.getRight(),e.getBottom())}LineQuad(e){const t=C33.angleTo(e.getTlx(),e.getTly(),e.getTrx(),e.getTry()),s=Math.sin(t),i=Math.cos(t),r=.5*this._lineWidth,n=s*r,a=i*r,o=this._lineCap;2===o?this._LineQuadPreCalc_LineCap2(e,n,a):1===o?this._LineQuadPreCalc_LineCap1(e,n,a):this._LineQuadPreCalc_LineCap0(e,n,a)}_LineQuadPreCalc_LineCap2(e,t,s){this.LinePreCalc_LineCap2(e.getTlx(),e.getTly(),0,e.getTrx(),e.getTry(),0,t,s),this.LinePreCalc_LineCap2(e.getTrx(),e.getTry(),0,e.getBrx(),e.getBry(),0,s,-t),this.LinePreCalc_LineCap2(e.getBrx(),e.getBry(),0,e.getBlx(),e.getBly(),0,-t,-s),this.LinePreCalc_LineCap2(e.getBlx(),e.getBly(),0,e.getTlx(),e.getTly(),0,-s,t)}_LineQuadPreCalc_LineCap1(e,t,s){this.LinePreCalc_LineCap1(e.getTlx(),e.getTly(),0,e.getTrx(),e.getTry(),0,t,s),this.LinePreCalc_LineCap1(e.getTrx(),e.getTry(),0,e.getBrx(),e.getBry(),0,s,-t),this.LinePreCalc_LineCap1(e.getBrx(),e.getBry(),0,e.getBlx(),e.getBly(),0,-t,-s),this.LinePreCalc_LineCap1(e.getBlx(),e.getBly(),0,e.getTlx(),e.getTly(),0,-s,t)}_LineQuadPreCalc_LineCap0(e,t,s){this.LinePreCalc_LineCap0(e.getTlx(),e.getTly(),0,e.getTrx(),e.getTry(),0,t,s),this.LinePreCalc_LineCap0(e.getTrx(),e.getTry(),0,e.getBrx(),e.getBry(),0,s,-t),this.LinePreCalc_LineCap0(e.getBrx(),e.getBry(),0,e.getBlx(),e.getBly(),0,-t,-s),this.LinePreCalc_LineCap0(e.getBlx(),e.getBly(),0,e.getTlx(),e.getTly(),0,-s,t)}SetLineWidth(e){this._lineWidth=e,this._lineWidthStack[this._lineWidthStack.length-1]=e}GetLineWidth(){return this._lineWidth}PushLineWidth(e){if(100<=this._lineWidthStack.length)throw new Error("pushed too many line widths - check push/pop pairs");this._lineWidthStack.push(e),this._lineWidth=e}PopLineWidth(){if(this._lineWidthStack.length<=1)throw new Error("cannot pop last line width - check push/pop pairs");this._lineWidthStack.pop(),this._lineWidth=this._lineWidthStack.at(-1)}SetLineCapButt(){this._lineCap=0,this._lineCapStack[this._lineCapStack.length-1]=0}SetLineCapSquare(){this._lineCap=1,this._lineCapStack[this._lineCapStack.length-1]=0}SetLineCapZag(){this._lineCap=2,this._lineCapStack[this._lineCapStack.length-1]=0}PushLineCap(e){if("butt"===e)this.PushLineCapButt();else if("square"===e)this.PushLineCapSquare();else{if("zag"!==e)throw new Error("invalid line cap");this.PushLineCapZag()}}PushLineCapButt(){if(100<=this._lineCapStack.length)throw new Error("pushed too many line caps - check push/pop pairs");this._lineCapStack.push(0),this._lineCap=0}PushLineCapSquare(){if(100<=this._lineCapStack.length)throw new Error("pushed too many line caps - check push/pop pairs");this._lineCapStack.push(1),this._lineCap=1}PushLineCapZag(){if(100<=this._lineCapStack.length)throw new Error("pushed too many line caps - check push/pop pairs");this._lineCapStack.push(2),this._lineCap=2}PopLineCap(){if(this._lineCapStack.length<=1)throw new Error("cannot pop last line cap - check push/pop pairs");this._lineCapStack.pop(),this._lineCap=this._lineCapStack.at(-1)}SetLineOffset(e){this._lineOffset=e,this._lineOffsetStack[this._lineOffsetStack.length-1]=e}GetLineOffset(){return this._lineOffset}PushLineOffset(e){if(100<=this._lineOffsetStack.length)throw new Error("pushed too many line offsets - check push/pop pairs");this._lineOffsetStack.push(e),this._lineOffset=e}PopLineOffset(){if(this._lineOffsetStack.length<=1)throw new Error("cannot pop last line offset - check push/pop pairs");this._lineOffsetStack.pop(),this._lineOffset=this._lineOffsetStack.at(-1)}ConvexPoly(t){const e=t.length/2;if(e<3)throw new Error("need at least 3 points");const s=e-2,i=s-1,r=t[0],n=t[1];for(let e=0;e<s;e+=2){const a=2*e,o=t[2+a],l=t[3+a],h=t[4+a],c=t[5+a];if(e===i)this.Quad2(r,n,o,l,h,c,h,c);else{const u=t[6+a],_=t[7+a];this.Quad2(r,n,o,l,h,c,u,_)}}}GetNumVertexComponents(){return 3}Finish(){this.EndBatch(!0),this._frameNumber++}GetFrameNumber(){return this._frameNumber}IncrementFrameNumber(){this._frameNumber++}SetMipmapsEnabled(e){this._enableMipmaps=!!e}AreMipmapsEnabled(){return this._enableMipmaps}SetHasMajorPerformanceCaveat(e){this._hasMajorPerformanceCaveat=!!e}HasMajorPerformanceCaveat(){return this._hasMajorPerformanceCaveat}IsWebGL(){return!1}IsWebGPU(){return!1}GetEstimatedBackBufferMemoryUsage(){}GetEstimatedRenderBufferMemoryUsage(){}GetEstimatedTextureMemoryUsage(){}GetEstimatedTotalMemoryUsage(){return this.GetEstimatedBackBufferMemoryUsage()+this.GetEstimatedRenderBufferMemoryUsage()+this.GetEstimatedTextureMemoryUsage()}CreateRendererText(){return C33.New(C33.Gfx.RendererText,this)}}}{const C33=self.C3;C33.Gfx.ShaderProgramBase=class{constructor(e,t){this._name=t.name,this._renderer=e,this._extendBoxHorizontal=t.extendBoxHorizontal||0,this._extendBoxVertical=t.extendBoxVertical||0,this._crossSampling=!!t.crossSampling,this._mustPreDraw=!!t.mustPreDraw,this._preservesOpaqueness=!!t.preservesOpaqueness,this._supports3dDirectRendering=!!t.supports3dDirectRendering,this._animated=!!t.animated,this._blendsBackground=!!t.blendsBackground,this._usesDepth=!!t.usesDepth,this._usesAnySrcRectOrPixelSize=!1,this._needsPostDrawOrExtendBox=this._crossSampling||this._blendsBackground||0!==this._extendBoxHorizontal||0!==this._extendBoxVertical}Release(){this._renderer=null}GetRenderer(){return this._renderer}GetName(){return this._name}ExtendsBox(){return 0!==this._extendBoxHorizontal||0!==this._extendBoxVertical}GetBoxExtendHorizontal(){return this._extendBoxHorizontal}GetBoxExtendVertical(){return this._extendBoxVertical}UsesCrossSampling(){return this._crossSampling}MustPreDraw(){return this._mustPreDraw}PreservesOpaqueness(){return this._preservesOpaqueness}Supports3DDirectRendering(){return this._supports3dDirectRendering}IsAnimated(){return this._animated}BlendsBackground(){return this._blendsBackground}UsesDepth(){return this._usesDepth}UsesAnySrcRectOrPixelSize(){return this._usesAnySrcRectOrPixelSize}NeedsPostDrawOrExtendsBox(){return this._needsPostDrawOrExtendBox}UsesIsSrcTexRotated(){return!1}}}{const C33=self.C3;C33.Gfx.StateGroup=class{constructor(e,t,s,i,r){this._renderer=e,this._refCount=0,this._shaderProgram=null,this._shaderProgramName="",this._blendMode=s,this._color=C33.New(C33.Color),this._color.set(i),this._zElevation=r,"string"==typeof t?this._shaderProgramName=t:(this._shaderProgram=t,this._shaderProgramName=this._shaderProgram.GetName())}Release(){if(0<this._refCount)throw new Error("releasing state group still in use");this._renderer=null,this._shaderProgram=null,this._shaderProgramName=""}Apply(){const e=this._renderer;e.SetProgram(this._shaderProgram),e.SetBlendMode(this._blendMode),e.SetColor(this._color),e.SetCurrentZ(this._zElevation),e._SetCurrentStateGroup(this)}GetKey(){return C33.Gfx.StateGroup.MakeKey(this._shaderProgramName,this._blendMode,this._color,this._zElevation)}AddRef(){++this._refCount}DecRef(){--this._refCount}_GetRefCount(){return this._refCount}OnContextLost(){this._shaderProgram=null}OnContextRestored(e){if(this._shaderProgram=e.GetShaderProgramByName(this._shaderProgramName),!this._shaderProgram)throw new Error("failed to restore shader program")}static MakeKey(e,t,s,i){const r="string"==typeof e?e:e.GetName();return r+","+t+","+s.getR()+","+s.getG()+","+s.getB()+","+s.getA()+","+i}}}{let interpolateQuad2=function(e,t,s){const i=s.getTlx(),r=s.getTly(),n=s.getTrx()-i,a=s.getTry()-r,o=s.getBlx()-i,l=s.getBly()-r,h=n*e,c=a*e,u=o*t,_=l*t;return[i+h+u,r+c+_]};interpolateQuad=interpolateQuad2;const C33=self.C3,tempQuadTex=C33.New(C33.Quad);C33.Gfx.MeshPoint=class{constructor(e,t,s){this._mesh=e,this._col=t,this._row=s,this._x=NaN,this._y=NaN,this._zElevation=NaN,this._u=NaN,this._v=NaN,this._x=0,this._y=0,this._zElevation=0,this._u=0,this._v=0}_Init(e,t,s,i){this._x=e,this._y=t,this._u=s,this._v=i}GetX(){return this._x}SetX(e){this._x!==e&&(this._x=e,this._mesh._SetPointsChanged())}GetY(){return this._y}SetY(e){this._y!==e&&(this._y=e,this._mesh._SetPointsChanged())}GetZElevation(){return this._zElevation}SetZElevation(e){this._zElevation!==e&&(this._zElevation=Math.max(e,0),this._mesh._SetPointsChanged())}GetU(){return this._u}SetU(e){this._u=e}GetV(){return this._v}SetV(e){this._v=e}_Interpolate_TexRect(e,t,s){[this._x,this._y]=interpolateQuad2(e._x,e._y,t),this._zElevation=e._zElevation,this._u=C33.lerp(s.getLeft(),s.getRight(),e._u),this._v=C33.lerp(s.getTop(),s.getBottom(),e._v)}_Interpolate_TexQuad(e,t,s){[this._x,this._y]=interpolateQuad2(e._x,e._y,t),this._zElevation=e._zElevation,[this._u,this._v]=interpolateQuad2(e._u,e._v,s)}SaveToJson(){return{x:this.GetX(),y:this.GetY(),z:this.GetZElevation(),u:this.GetU(),v:this.GetV()}}LoadFromJson(e){this.SetX(e.x),this.SetY(e.y),e.hasOwnProperty("z")&&this.SetZElevation(e.z),this.SetU(e.u),this.SetV(e.v)}GetMesh(){return this._mesh}GetColumn(){return this._col}GetRow(){return this._row}},C33.Gfx.Mesh=class{constructor(s,e,t){if(s<2||e<2)throw new Error("invalid mesh size");this._hsize=s,this._vsize=e,this._owner=t||null,this._pts=[],this._minX=0,this._minY=0,this._maxX=1,this._maxY=1,this._maxZ=0,this._pointsChanged=!1;const i=s-1,r=e-1;for(let t=0;t<e;++t){const n=[];for(let e=0;e<s;++e){const a=C33.New(C33.Gfx.MeshPoint,this,e,t),o=e/i,l=t/r;a._Init(o,l,o,l),n.push(a)}this._pts.push(n)}}Release(){C33.clearArray(this._pts)}GetHSize(){return this._hsize}GetVSize(){return this._vsize}GetOwner(){return this._owner}_GetPoints(){return this._pts}_SetPointsChanged(){this._pointsChanged=!0}_MaybeComputeBounds(){if(this._pointsChanged){let e=1/0,t=1/0,s=-1/0,i=-1/0,r=0;for(const n of this._pts)for(const a of n){const o=a.GetX(),l=a.GetY();e=Math.min(e,o),t=Math.min(t,l),s=Math.max(s,o),i=Math.max(i,l),r=Math.max(r,a.GetZElevation())}this._minX=e,this._minY=t,this._maxX=s,this._maxY=i,this._maxZ=r,this._pointsChanged=!1}}GetMinX(){return this._MaybeComputeBounds(),this._minX}GetMinY(){return this._MaybeComputeBounds(),this._minY}GetMaxX(){return this._MaybeComputeBounds(),this._maxX}GetMaxY(){return this._MaybeComputeBounds(),this._maxY}GetMaxZ(){return this._MaybeComputeBounds(),this._maxZ}HasAnyZElevation(){return 0<this.GetMaxZ()}GetMeshPointAt(e,t){return e=Math.floor(e),t=Math.floor(t),e<0||e>=this._hsize||t<0||t>=this._vsize?null:this._pts[t][e]}CalculateTransformedMesh(e,s,i){const r=i instanceof C33.Rect;if(e.GetHSize()!==this.GetHSize()||e.GetVSize()!==this.GetVSize())throw new Error("source mesh wrong size");const n=e._pts,a=this._pts;for(let e=0,t=a.length;e<t;++e){const o=n[e],l=a[e];for(let e=0,t=l.length;e<t;++e){const h=o[e],c=l[e];r?c._Interpolate_TexRect(h,s,i):c._Interpolate_TexQuad(h,s,i)}}}Draw(n){let a=this._pts,o=a[0];for(let e=1,t=a.length;e<t;++e){let s=a[e],i=o[0],r=s[0];for(let e=1,t=s.length;e<t;++e){const l=o[e],h=s[e];tempQuadTex.set(i.GetU(),i.GetV(),l.GetU(),l.GetV(),h.GetU(),h.GetV(),r.GetU(),r.GetV()),n.Quad3D2(i.GetX(),i.GetY(),i.GetZElevation(),l.GetX(),l.GetY(),l.GetZElevation(),h.GetX(),h.GetY(),h.GetZElevation(),r.GetX(),r.GetY(),r.GetZElevation(),tempQuadTex),i=l,r=h}o=s}}Outline(o,l){l=l||((e,t,s)=>[e,t,s]);let e=this._pts,h=e[0];for(let n=1,a=e.length;n<a;++n){let s=e[n],i=h[0],r=s[0];for(let e=1,t=s.length;e<t;++e){const c=h[e],u=s[e],[_,d,p]=l(i.GetX(),i.GetY(),i.GetZElevation()),[m,g,f]=l(c.GetX(),c.GetY(),c.GetZElevation()),[S,C,y]=l(u.GetX(),u.GetY(),u.GetZElevation()),[G,I,T]=l(r.GetX(),r.GetY(),r.GetZElevation());o.Line3D(_,d,p,m,g,f),o.Line3D(_,d,p,S,C,y),o.Line3D(_,d,p,G,I,T),e===t-1&&o.Line3D(m,g,f,S,C,y),n===a-1&&o.Line3D(G,I,T,S,C,y),i=c,r=u}h=s}}InsertPolyMeshVertices(e){let s=.99999999,i=e.pointsArr(),r=[],n=this.GetHSize()-1,a=this.GetVSize()-1,o=1/n,l=1/a,h=n-1,c=a-1,u=i[0],_=i[1],d=C33.clamp(Math.floor(u*n),0,h),p=C33.clamp(Math.floor(_*a),0,c),m=!0,g=0,f=0,S=0,C=-1,y=()=>{u=C33.clamp(C33.lerp(u,g,S),0,1),_=C33.clamp(C33.lerp(_,f,S),0,1),r.push(u,_)};for(let e=0,t=i.length;e<t;e+=2){u=i[e],_=i[e+1],r.push(u,_),d=C33.clamp(Math.floor(u*n),0,h),p=C33.clamp(Math.floor(_*a),0,c);const G=(e+2)%t;for(g=i[G],f=i[1+G],C=-1;;){if(1e6<r.length)throw new Error("Too many mesh poly points");const I=d*o,T=p*l,b=(d+1)*o,A=(p+1)*l;if(m=C33.isPointInTriangleInclusive(u,_,I,T,b,T,b,A),0!==C&&0<=(S=C33.rayIntersectExtended(u,_,g,f,I,T,b,A,-.001))&&S<=s)y(),m=!m,C=0;else if(0<p&&2!==C&&0<=(S=C33.rayIntersectExtended(u,_,g,f,I,T,b,T,.001))&&S<=s)y(),p--,m=!1,C=4;else if(d<h&&3!==C&&0<=(S=C33.rayIntersectExtended(u,_,g,f,b,T,b,A,.001))&&S<=s)y(),d++,m=!1,C=1;else if(0<d&&1!==C&&0<=(S=C33.rayIntersectExtended(u,_,g,f,I,T,I,A,.001))&&S<=s)y(),d--,m=!0,C=3;else{if(!(p<c&&4!==C&&0<=(S=C33.rayIntersectExtended(u,_,g,f,I,A,b,A,.001))&&S<=s))break;y(),p++,m=!0,C=2}}}return C33.New(C33.CollisionPoly,r)}TransformCollisionPoly(e,t){const s=this._TransformPolyPoints(e);this._SimplifyPoly(s),t.setPoints(s)}_TransformPolyPoints(e){const s=[],i=e.pointsArr();for(let e=0,t=i.length;e<t;e+=2){const r=i[e],n=i[e+1],[a,o]=this.TransformPoint(r,n);s.push(a,o)}return s}TransformPoint(e,t){const s=this.GetHSize()-1,i=this.GetVSize()-1,r=1/s,n=1/i,a=C33.clamp(Math.floor(e*s),0,s-1),o=C33.clamp(Math.floor(t*i),0,i-1),l=a*r,h=o*n,c=(a+1)*r,u=(o+1)*n,_=this.GetMeshPointAt(a,o),d=this.GetMeshPointAt(a+1,o+1),p=C33.isPointInTriangleInclusive(e,t,l,h,c,h,c,u),m=p?l+r:l,g=p?h:h+n,f=this.GetMeshPointAt(a+(p?1:0),o+(p?0:1)),[S,C,y]=C33.triangleCartesianToBarycentric(e,t,l,h,m,g,c,u);return C33.triangleBarycentricToCartesian3d(S,C,y,_.GetX(),_.GetY(),_.GetZElevation(),f.GetX(),f.GetY(),f.GetZElevation(),d.GetX(),d.GetY(),d.GetZElevation())}_SimplifyPoly(s){let i=[],r=s[0],n=s[1],a=r-s.at(-2),o=n-s.at(-1);for(let e=0,t=s.length;e<t;e+=2){const l=(e+2)%t,h=s[l],c=s[1+l],u=h-r,_=c-n,d=Math.abs(u)<1e-7&&Math.abs(a)<1e-7&&Math.sign(_)===Math.sign(o),p=Math.abs(_)<1e-7&&Math.abs(o)<1e-7&&Math.sign(u)===Math.sign(a);(!d&&!p&&.001<Math.abs(u/a-_/o)||0==u&&0==_)&&i.push(r,n),r=h,n=c,a=u,o=_}6<=i.length&&i.length<s.length&&C33.shallowAssignArray(s,i)}SaveToJson(){return{cols:this.GetHSize(),rows:this.GetVSize(),points:this._pts.map(e=>e.map(e=>e.SaveToJson()))}}LoadFromJson(e){const s=this.GetHSize(),i=this.GetVSize();if(e.cols!==s||e.rows!==i)throw new Error("mesh data wrong size");const r=e.points;for(let t=0;t<i;++t){const n=r[t];for(let e=0;e<s;++e){const a=this.GetMeshPointAt(e,t);a.LoadFromJson(n[e])}}}}}{let GetFormatSpecifiers2=function(e,t){let s,i,r,n;switch(e){case"rgba8":s=t.RGBA8,i=t.RGBA,r=t.RGBA,n=t.UNSIGNED_BYTE;break;case"rgb8":s=t.RGB8,i=t.RGB,r=t.RGB,n=t.UNSIGNED_BYTE;break;case"rgba4":s=t.RGBA4,i=t.RGBA,r=t.RGBA,n=t.UNSIGNED_SHORT_4_4_4_4;break;case"rgb5_a1":s=t.RGB5_A1,i=t.RGBA,r=t.RGBA,n=t.UNSIGNED_SHORT_5_5_5_1;break;case"rgb565":s=t.RGB565,i=t.RGB,r=t.RGB,n=t.UNSIGNED_SHORT_5_6_5;break;default:throw new Error("invalid pixel format")}return{sizedinternalformat:s,internalformat:i,format:r,type:n}};GetFormatSpecifiers=GetFormatSpecifiers2;const C33=self.C3,VALID_PIXEL_FORMATS=new Set(["rgba8","rgb8","rgba4","rgb5_a1","rgb565"]),VALID_SAMPLINGS=new Set(["nearest","bilinear","trilinear"]),VALID_MIPMAP_QUALITIES=new Set(["default","low","high"]),VALID_WRAP_MODES=new Set(["clamp-to-edge","repeat","mirror-repeat"]),CREATEFROM_DEFAULT_OPTIONS={wrapX:"clamp-to-edge",wrapY:"clamp-to-edge",sampling:"trilinear",anisotropy:0,pixelFormat:"rgba8",mipMap:!0,mipMapQuality:"default",premultiplyAlpha:!0,isSvg:!1,width:-1,height:-1},UPDATE_DEFAULT_OPTIONS={premultiplyAlpha:!0,flipY:!1},allTextures=new Set;C33.Gfx.WebGLRendererTexture=class{constructor(e){this._renderer=e,this._texture=null,this._width=0,this._height=0,this._isStatic=!0,this._wrapX="clamp-to-edge",this._wrapY="clamp-to-edge",this._sampling="trilinear",this._anisotropy=0,this._pixelFormat="rgba8",this._isMipMapped=!1,this._mipMapQuality="default",this._refCount=0}_CreateStatic(t,e){if(!("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas||t instanceof ImageData||t instanceof ArrayBuffer||null===t))throw new Error("invalid texture source");if(e=Object.assign({},CREATEFROM_DEFAULT_OPTIONS,e),this._texture)throw new Error("already created texture");if(this._wrapX=e.wrapX,this._wrapY=e.wrapY,this._sampling=e.sampling,this._anisotropy=e.anisotropy,this._pixelFormat=e.pixelFormat,this._isMipMapped=!!e.mipMap&&this._renderer.AreMipmapsEnabled(),this._mipMapQuality=e.mipMapQuality,!VALID_WRAP_MODES.has(this._wrapX)||!VALID_WRAP_MODES.has(this._wrapY))throw new Error("invalid wrap mode");if(!VALID_SAMPLINGS.has(this._sampling))throw new Error("invalid sampling");if(!VALID_PIXEL_FORMATS.has(this._pixelFormat))throw new Error("invalid pixel format");if(!VALID_MIPMAP_QUALITIES.has(this._mipMapQuality))throw new Error("invalid mipmap quality");if(this._isStatic=!0,t instanceof ArrayBuffer||null===t||e.isSvg){if(this._width=e.width,this._height=e.height,t instanceof ArrayBuffer&&t.byteLength!==this._width*this._height*4)throw new Error("ArrayBuffer wrong size")}else this._width=t.width,this._height=t.height;if(this._width<=0||this._height<=0)throw new Error("invalid texture data size");if(e.isSvg){const o=C33.CreateCanvas(this._width,this._height),l=o.getContext("2d");l.drawImage(t,0,0,this._width,this._height),t=o}const s=C33.isPOT(this._width)&&C33.isPOT(this._height),i=this._renderer.GetMaxTextureSize();if(this._width>i||this._height>i)throw new Error("texture data exceeds maximum texture size");const r=this._renderer.GetContext(),n=this._renderer.GetWebGLVersionNumber(),a=(this._texture=r.createTexture(),r.bindTexture(r.TEXTURE_2D,this._texture),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.premultiplyAlpha),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1),GetFormatSpecifiers2(this._pixelFormat,r));if(this._renderer.SupportsNPOTTextures()||s||!this._IsTiled())if(2<=n){let e;e=this._isMipMapped?Math.floor(Math.log2(Math.max(this._width,this._height))+1):1,r.texStorage2D(r.TEXTURE_2D,e,a.sizedinternalformat,this._width,this._height),t instanceof ArrayBuffer?r.texSubImage2D(r.TEXTURE_2D,0,0,0,this._width,this._height,a.format,a.type,new Uint8Array(t)):null!==t&&r.texSubImage2D(r.TEXTURE_2D,0,0,0,a.format,a.type,t)}else t instanceof ArrayBuffer?r.texImage2D(r.TEXTURE_2D,0,a.internalformat,this._width,this._height,0,a.format,a.type,new Uint8Array(t)):null===t?r.texImage2D(r.TEXTURE_2D,0,a.internalformat,this._width,this._height,0,a.format,a.type,null):r.texImage2D(r.TEXTURE_2D,0,a.internalformat,a.format,a.type,t);else{if(null===t)throw new Error("cannot pass null data when creating a NPOT tiled texture without NPOT support");if((t=t instanceof ArrayBuffer?new ImageData(new Uint8ClampedArray(t),this._width,this._height):t)instanceof ImageData){const u=C33.CreateCanvas(this._width,this._height),_=u.getContext("2d");_.putImageData(t,0,0),t=u}const h=C33.CreateCanvas(C33.nextHighestPowerOfTwo(this._width),C33.nextHighestPowerOfTwo(this._height)),c=h.getContext("2d");c.imageSmoothingEnabled="nearest"!==this._sampling,c.drawImage(t,0,0,this._width,this._height,0,0,h.width,h.height),r.texImage2D(r.TEXTURE_2D,0,a.internalformat,a.format,a.type,h)}null!==t&&this._SetTextureParameters(r),r.bindTexture(r.TEXTURE_2D,null),this._renderer._ResetLastTexture(),this._refCount=1,allTextures.add(this)}_CreateDynamic(e,t,s){if(s=Object.assign({},CREATEFROM_DEFAULT_OPTIONS,s),this._texture)throw new Error("already created texture");if(this._wrapX=s.wrapX,this._wrapY=s.wrapY,this._sampling=s.sampling,this._pixelFormat=s.pixelFormat,this._isMipMapped=!!s.mipMap&&this._renderer.AreMipmapsEnabled(),this._mipMapQuality=s.mipMapQuality,!VALID_WRAP_MODES.has(this._wrapX)||!VALID_WRAP_MODES.has(this._wrapY))throw new Error("invalid wrap mode");if(!VALID_SAMPLINGS.has(this._sampling))throw new Error("invalid sampling");if(!VALID_PIXEL_FORMATS.has(this._pixelFormat))throw new Error("invalid pixel format");if(!VALID_MIPMAP_QUALITIES.has(this._mipMapQuality))throw new Error("invalid mipmap quality");this._isStatic=!1,this._width=Math.floor(e),this._height=Math.floor(t);const i=C33.isPOT(this._width)&&C33.isPOT(this._height),r=this._renderer.GetMaxTextureSize();if(this._width<=0||this._height<=0)throw new Error("invalid texture size");if(this._width>r||this._height>r)throw new Error("texture exceeds maximum texture size");if(!this._renderer.SupportsNPOTTextures()&&this._IsTiled()&&!i)throw new Error("non-power-of-two tiled textures not supported");const n=this._renderer.GetContext(),a=this._renderer.GetWebGLVersionNumber(),o=(this._texture=n.createTexture(),n.bindTexture(n.TEXTURE_2D,this._texture),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s.premultiplyAlpha),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),GetFormatSpecifiers2(this._pixelFormat,n)),l=2<=a?o.sizedinternalformat:o.internalformat;n.texImage2D(n.TEXTURE_2D,0,l,this._width,this._height,0,o.format,o.type,null),this._SetTextureParameters(n),n.bindTexture(n.TEXTURE_2D,null),this._renderer._ResetLastTexture(),this._refCount=1,allTextures.add(this)}_GetMipMapHint(e){if("default"===this._mipMapQuality)return this._isStatic?e.NICEST:e.FASTEST;if("low"===this._mipMapQuality)return e.FASTEST;if("high"===this._mipMapQuality)return e.NICEST;throw new Error("invalid mipmap quality")}_IsTiled(){return"clamp-to-edge"!==this._wrapX||"clamp-to-edge"!==this._wrapY}_GetTextureWrapMode(e,t){if("clamp-to-edge"===t)return e.CLAMP_TO_EDGE;if("repeat"===t)return e.REPEAT;if("mirror-repeat"===t)return e.MIRRORED_REPEAT;throw new Error("invalid wrap mode")}_SetTextureParameters(e){const t=C33.isPOT(this._width)&&C33.isPOT(this._height);if(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,this._GetTextureWrapMode(e,this._wrapX)),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,this._GetTextureWrapMode(e,this._wrapY)),"nearest"===this._sampling)e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),this._isMipMapped=!1;else if(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),(t||this._renderer.SupportsNPOTTextures())&&this._isMipMapped){e.hint(e.GENERATE_MIPMAP_HINT,this._GetMipMapHint(e)),e.generateMipmap(e.TEXTURE_2D);const i="trilinear"===this._sampling&&!this._renderer.HasMajorPerformanceCaveat();e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,i?e.LINEAR_MIPMAP_LINEAR:e.LINEAR_MIPMAP_NEAREST)}else e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),this._isMipMapped=!1;const s=this._renderer._GetAnisotropicExtension();s&&0<this._anisotropy&&"nearest"!==this._sampling&&e.texParameterf(e.TEXTURE_2D,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(this._anisotropy,this._renderer._GetMaxAnisotropy()))}_Update(e,t){if(!("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas||e instanceof ImageData))throw new Error("invalid texture source");if(!this._texture||this._refCount<=0)throw new Error("texture not created");if(this._isStatic)throw new Error("cannot update static texture");t=Object.assign({},UPDATE_DEFAULT_OPTIONS,t);const s=e.width||e.videoWidth,i=e.height||e.videoHeight,r=this._renderer.GetWebGLVersionNumber(),n=this._renderer.GetContext(),a=(n.bindTexture(n.TEXTURE_2D,this._texture),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!!t.flipY),GetFormatSpecifiers2(this._pixelFormat,n)),o=2<=r?a.sizedinternalformat:a.internalformat;try{if(this._width===s&&this._height===i){const l=C33.isPOT(this._width)&&C33.isPOT(this._height);n.texSubImage2D(n.TEXTURE_2D,0,0,0,a.format,a.type,e),(l||this._renderer.SupportsNPOTTextures())&&this._isMipMapped&&(n.hint(n.GENERATE_MIPMAP_HINT,this._GetMipMapHint(n)),n.generateMipmap(n.TEXTURE_2D))}else{this._width=s,this._height=i;const h=C33.isPOT(this._width)&&C33.isPOT(this._height);if(!this._renderer.SupportsNPOTTextures()&&this._IsTiled()&&!h)throw new Error("non-power-of-two tiled textures not supported");n.texImage2D(n.TEXTURE_2D,0,o,a.format,a.type,e),(h||this._renderer.SupportsNPOTTextures())&&this._isMipMapped&&(n.hint(n.GENERATE_MIPMAP_HINT,this._GetMipMapHint(n)),n.generateMipmap(n.TEXTURE_2D))}}catch(e){console.error("Error updating WebGL texture: ",e)}n.bindTexture(n.TEXTURE_2D,null),this._renderer._ResetLastTexture()}_Delete(){if(0<this._refCount)throw new Error("texture still has references");if(!this._texture)throw new Error("already deleted texture");allTextures.delete(this);const e=this._renderer.GetContext();e.deleteTexture(this._texture),this._texture=null}IsValid(){return!!this._texture}_GetTexture(){return this._texture}GetRenderer(){return this._renderer}AddReference(){this._refCount++}SubtractReference(){if(this._refCount<=0)throw new Error("no more references");this._refCount--}GetReferenceCount(){return this._refCount}GetWidth(){return this._width}GetHeight(){return this._height}IsStatic(){return this._isStatic}GetEstimatedMemoryUsage(){let e=this._width*this._height;switch(this._pixelFormat){case"rgba8":e*=4;break;case"rgb8":e*=3;break;case"rgba4":case"rgb5_a1":case"rgb565":e*=2}return this._isMipMapped&&(e+=Math.floor(e/3)),e}static OnContextLost(){allTextures.clear()}static allTextures(){return allTextures.values()}}}{const C33=self.C3,assert=self.assert,glMatrix=self.glMatrix,vec32=glMatrix.vec3,mat42=glMatrix.mat4,VALID_SAMPLINGS=new Set(["nearest","bilinear","trilinear"]),DEFAULT_RENDERTARGET_OPTIONS={sampling:"trilinear",alpha:!0,depth:!1,isSampled:!0,isDefaultSize:!0,multisampling:0},allRenderTargets=new Set;C33.Gfx.WebGLRenderTarget=class{constructor(e){this._renderer=e,this._frameBuffer=null,this._frameBufferNoDepth=null,this._texture=null,this._renderBuffer=null,this._width=0,this._height=0,this._isDefaultSize=!0,this._sampling="trilinear",this._alpha=!0,this._depth=!1,this._isSampled=!0,this._multisampling=0,this._projectionMatrix=mat42.create(),this._lastFov=0,this._lastNearZ=0,this._lastFarZ=0}_Create(e,t,s){s=Object.assign({},DEFAULT_RENDERTARGET_OPTIONS,s);const i=this._renderer.GetWebGLVersionNumber();if(this._texture||this._renderBuffer)throw new Error("already created render target");if(this._sampling=s.sampling,this._alpha=!!s.alpha,this._depth=!!s.depth,this._isSampled=!!s.isSampled,this._isDefaultSize=!!s.isDefaultSize,this._multisampling=s.multisampling,!VALID_SAMPLINGS.has(this._sampling))throw new Error("invalid sampling");if(0<this._multisampling&&(i<2||this._isSampled))throw new Error("invalid use of multisampling");if(i<2&&(this._isSampled=!0),this._width=e,this._height=t,this._width<=0||this._height<=0)throw new Error("invalid render target size");this._CalculateProjection();const r=this._renderer.GetContext();if(this._frameBuffer=r.createFramebuffer(),this._depth&&(this._frameBufferNoDepth=r.createFramebuffer()),this._isSampled){this._texture=this._renderer.CreateDynamicTexture(this._width,this._height,{sampling:this._sampling,pixelFormat:this._alpha?"rgba8":"rgb8",mipMap:!1});const a=this._texture._GetTexture();r.bindFramebuffer(r.FRAMEBUFFER,this._frameBuffer),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,a,0),this._depth&&(r.bindFramebuffer(r.FRAMEBUFFER,this._frameBufferNoDepth),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,a,0))}else{this._renderBuffer=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,this._renderBuffer);const o=this._alpha?r.RGBA8:r.RGB8;if(0<this._multisampling){const l=r.getInternalformatParameter(r.RENDERBUFFER,o,r.SAMPLES);if(l&&l[0]){const h=l[0];this._multisampling>h&&(this._multisampling=h)}else this._multisampling=0}0===this._multisampling?r.renderbufferStorage(r.RENDERBUFFER,o,this._width,this._height):r.renderbufferStorageMultisample(r.RENDERBUFFER,this._multisampling,o,this._width,this._height),r.bindFramebuffer(r.FRAMEBUFFER,this._frameBuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.RENDERBUFFER,this._renderBuffer),this._depth&&(r.bindFramebuffer(r.FRAMEBUFFER,this._frameBufferNoDepth),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.RENDERBUFFER,this._renderBuffer)),r.bindRenderbuffer(r.RENDERBUFFER,null)}const n=this._renderer._GetDepthBuffer();this._depth&&n&&(r.bindFramebuffer(r.FRAMEBUFFER,this._frameBuffer),this._renderer._CanSampleDepth()?r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.TEXTURE_2D,n,0):r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,n)),r.bindFramebuffer(r.FRAMEBUFFER,null),allRenderTargets.add(this)}_Resize(e,t){if(this._width!==e||this._height!==t){this._width=e,this._height=t,this._CalculateProjection();const s=this._renderer.GetContext(),i=(s.bindFramebuffer(s.FRAMEBUFFER,this._frameBuffer),this._texture?this._texture._Update(new ImageData(this._width,this._height)):(s.bindRenderbuffer(s.RENDERBUFFER,this._renderBuffer),s.renderbufferStorage(s.RENDERBUFFER,this._alpha?s.RGBA8:s.RGB8,this._width,this._height),s.bindRenderbuffer(s.RENDERBUFFER,null)),this._renderer._GetDepthBuffer());this._depth&&i&&(this._renderer._CanSampleDepth()?s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,i,0):s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,i)),s.bindFramebuffer(s.FRAMEBUFFER,null)}}_Delete(){if(!this._texture&&!this._renderBuffer)throw new Error("already deleted render target");allRenderTargets.delete(this);const e=this._renderer.GetContext(),t=(this._texture?(e.bindFramebuffer(e.FRAMEBUFFER,this._frameBuffer),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,null,0),this._depth&&(e.bindFramebuffer(e.FRAMEBUFFER,this._frameBufferNoDepth),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,null,0)),this._renderer.DeleteTexture(this._texture),this._texture=null):this._renderBuffer&&(e.bindFramebuffer(e.FRAMEBUFFER,this._frameBuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,null),this._depth&&(e.bindFramebuffer(e.FRAMEBUFFER,this._frameBufferNoDepth),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,null)),e.deleteRenderbuffer(this._renderBuffer),this._renderBuffer=null),e.bindFramebuffer(e.FRAMEBUFFER,null),2<=this._renderer.GetWebGLVersionNumber()&&(e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null)),e.deleteFramebuffer(this._frameBuffer),this._depth&&e.deleteFramebuffer(this._frameBufferNoDepth),this._renderer.GetBatchState());t.currentFramebuffer=null,this._frameBuffer=t.currentFramebufferNoDepth=null}_CalculateProjection(){this._renderer.CalculatePerspectiveMatrix(this._projectionMatrix,this._width/this._height),this._lastFov=this._renderer.GetFovY(),this._lastNearZ=this._renderer.GetNearZ(),this._lastFarZ=this._renderer.GetFarZ()}_GetFramebuffer(){return this._frameBuffer}_GetFramebufferNoDepth(){return this._frameBufferNoDepth}GetRenderer(){return this._renderer}GetTexture(){return this._texture}GetProjectionMatrix(){return this._renderer.GetFovY()===this._lastFov&&this._renderer.GetNearZ()===this._lastNearZ&&this._renderer.GetFarZ()===this._lastFarZ||this._CalculateProjection(),this._projectionMatrix}IsLinearSampling(){return"nearest"!==this._sampling}HasAlpha(){return this._alpha}IsSampled(){return this._isSampled}HasDepthBuffer(){return this._depth}GetWidth(){return this._width}GetHeight(){return this._height}IsDefaultSize(){return this._isDefaultSize}GetMultisampling(){return this._multisampling}GetOptions(){const e={sampling:this._sampling,alpha:this._alpha,isSampled:this._isSampled};return this._isDefaultSize||(e.width=this._width,e.height=this._height),e}IsCompatibleWithOptions(e){return"nearest"!==(e=Object.assign({},DEFAULT_RENDERTARGET_OPTIONS,e)).sampling===this.IsLinearSampling()&&!!e.alpha===this.HasAlpha()&&!!e.depth===this.HasDepthBuffer()&&!(2<=this._renderer.GetWebGLVersionNumber()&&!!e.isSampled!==this.IsSampled())&&("number"==typeof e.width||"number"==typeof e.height?!this.IsDefaultSize()&&this.GetWidth()===Math.floor(e.width)&&this.GetHeight()===Math.floor(e.height):this.IsDefaultSize())}_GetWebGLTexture(){return this._texture?this._texture._GetTexture():null}GetEstimatedMemoryUsage(){return this._texture?this._texture.GetEstimatedMemoryUsage():this._width*this._height*(this._alpha?4:3)}static async DebugReadPixelsToBlob(e,t){const s=await e.ReadBackRenderTargetToImageData(t,!0);return C33.ImageDataToBlob(s)}static OnContextLost(){allRenderTargets.clear()}static allRenderTargets(){return allRenderTargets.values()}static ResizeAll(e,t){for(const s of allRenderTargets)s.IsDefaultSize()&&s._Resize(e,t)}}}{const C33=self.C3,glMatrix=self.glMatrix,vec32=glMatrix.vec3,mat42=glMatrix.mat4,RESERVED_UNIFORM_NAMES=new Set(["aPos","aTex","aPoints","matP","matMV","samplerFront","samplerBack","samplerDepth","destStart","destEnd","srcStart","srcEnd","srcOriginStart","srcOriginEnd","pixelSize","seconds","devicePixelRatio","layerScale","layerAngle","layoutStart","layoutEnd","color","color2_","pointTexStart","pointTexEnd","zElevation","tileSize","tileSpacing","outlineThickness","zNear","zFar"]);C33.Gfx.WebGLShaderProgram=class extends C33.Gfx.ShaderProgramBase{static async Compile(e,t){const s=e.GetContext(),i=t.src,r=t.vertexSrc,n=t.name,a=s.createShader(s.FRAGMENT_SHADER),o=(s.shaderSource(a,i),s.compileShader(a),s.createShader(s.VERTEX_SHADER)),l=(s.shaderSource(o,r),s.compileShader(o),s.createProgram()),h=(s.attachShader(l,a),s.attachShader(l,o),s.bindAttribLocation(l,0,"aPos"),s.bindAttribLocation(l,1,"aTex"),s.bindAttribLocation(l,2,"aPoints"),s.linkProgram(l),e._GetParallelShaderCompileExtension());if(h?await e._WaitForObjectReady(()=>s.getProgramParameter(l,h.COMPLETION_STATUS_KHR)):await C33.Wait(5),!s.getShaderParameter(a,s.COMPILE_STATUS)){const u=s.getShaderInfoLog(a);throw s.deleteShader(a),s.deleteShader(o),s.deleteProgram(l),new Error("Error compiling fragment shader: "+u)}if(!s.getShaderParameter(o,s.COMPILE_STATUS)){const _=s.getShaderInfoLog(o);throw s.deleteShader(a),s.deleteShader(o),s.deleteProgram(l),new Error("Error compiling vertex shader: "+_)}if(!s.getProgramParameter(l,s.LINK_STATUS)){const d=s.getProgramInfoLog(l);throw s.deleteShader(a),s.deleteShader(o),s.deleteProgram(l),new Error("Error linking shader program: "+d)}const c=C33.FilterUnprintableChars(s.getProgramInfoLog(l)||"").trim();return c&&!C33.IsStringAllWhitespace(c)&&console.info(`[WebGL] Shader program '${n}' compilation log: `,c),s.deleteShader(a),s.deleteShader(o),l}static async Create(e,t){const s=await C33.Gfx.WebGLShaderProgram.Compile(e,t);return new C33.Gfx.WebGLShaderProgram(e,s,t)}constructor(e,t,s){super(e,s);const i=e.GetContext(),r=e.GetBatchState(),n=(e.EndBatch(),i.useProgram(t),this._gl=i,this._shaderProgram=t,this._isDeviceTransform="<default-device-transform>"===s.name,i.getAttribLocation(t,"aPos")),a=i.getAttribLocation(t,"aTex"),o=(this._locAPoints=i.getAttribLocation(t,"aPoints"),-1!==n&&(i.bindBuffer(i.ARRAY_BUFFER,e._vertexBuffer),i.vertexAttribPointer(n,e.GetNumVertexComponents(),i.FLOAT,!1,0,0),i.enableVertexAttribArray(n)),-1!==a&&(i.bindBuffer(i.ARRAY_BUFFER,e._texcoordBuffer),i.vertexAttribPointer(a,2,i.FLOAT,!1,0,0),i.enableVertexAttribArray(a)),-1!==this._locAPoints&&(i.bindBuffer(i.ARRAY_BUFFER,e._pointBuffer),i.vertexAttribPointer(this._locAPoints,4,i.FLOAT,!1,0,0),i.enableVertexAttribArray(this._locAPoints)),i.bindBuffer(i.ARRAY_BUFFER,null),this._uMatP=new C33.Gfx.WebGLShaderUniform(this,"matP","mat4"),this._uMatMV=new C33.Gfx.WebGLShaderUniform(this,"matMV","mat4"),this._uColor=new C33.Gfx.WebGLShaderUniform(this,"color","vec4"),this._uSamplerFront=new C33.Gfx.WebGLShaderUniform(this,"samplerFront","sampler"),this._uPointTexStart=new C33.Gfx.WebGLShaderUniform(this,"pointTexStart","vec2"),this._uPointTexEnd=new C33.Gfx.WebGLShaderUniform(this,"pointTexEnd","vec2"),this._uZElevation=new C33.Gfx.WebGLShaderUniform(this,"zElevation","float"),this._uTileSize=new C33.Gfx.WebGLShaderUniform(this,"tileSize","vec2"),this._uTileSpacing=new C33.Gfx.WebGLShaderUniform(this,"tileSpacing","vec2"),this._uColor2=new C33.Gfx.WebGLShaderUniform(this,"color2_","vec4"),this._uOutlineThickness=new C33.Gfx.WebGLShaderUniform(this,"outlineThickness","float"),this._uSamplerBack=new C33.Gfx.WebGLShaderUniform(this,"samplerBack","sampler"),this._uSamplerDepth=new C33.Gfx.WebGLShaderUniform(this,"samplerDepth","sampler"),this._uDestStart=new C33.Gfx.WebGLShaderUniform(this,"destStart","vec2"),this._uDestEnd=new C33.Gfx.WebGLShaderUniform(this,"destEnd","vec2"),this._uSrcStart=new C33.Gfx.WebGLShaderUniform(this,"srcStart","vec2"),this._uSrcEnd=new C33.Gfx.WebGLShaderUniform(this,"srcEnd","vec2"),this._uSrcOriginStart=new C33.Gfx.WebGLShaderUniform(this,"srcOriginStart","vec2"),this._uSrcOriginEnd=new C33.Gfx.WebGLShaderUniform(this,"srcOriginEnd","vec2"),this._uPixelSize=new C33.Gfx.WebGLShaderUniform(this,"pixelSize","vec2"),this._uSeconds=new C33.Gfx.WebGLShaderUniform(this,"seconds","float"),this._uDevicePixelRatio=new C33.Gfx.WebGLShaderUniform(this,"devicePixelRatio","float"),this._uLayerScale=new C33.Gfx.WebGLShaderUniform(this,"layerScale","float"),this._uLayerAngle=new C33.Gfx.WebGLShaderUniform(this,"layerAngle","float"),this._uLayoutStart=new C33.Gfx.WebGLShaderUniform(this,"layoutStart","vec2"),this._uLayoutEnd=new C33.Gfx.WebGLShaderUniform(this,"layoutEnd","vec2"),this._uZNear=new C33.Gfx.WebGLShaderUniform(this,"zNear","float"),this._uZFar=new C33.Gfx.WebGLShaderUniform(this,"zFar","float"),this._hasAnyOptionalUniforms=!!(this._uPixelSize.IsUsed()||this._uSeconds.IsUsed()||this._uSamplerBack.IsUsed()||this._uDestStart.IsUsed()||this._uDestEnd.IsUsed()||this._uSrcStart.IsUsed()||this._uSrcEnd.IsUsed()||this._uSrcOriginStart.IsUsed()||this._uSrcOriginEnd.IsUsed()||this._uDevicePixelRatio.IsUsed()||this._uLayerScale.IsUsed()||this._uLayerAngle.IsUsed()||this._uLayoutStart.IsUsed()||this._uLayoutEnd.IsUsed()),s.parameters||[]);this._uCustomParameters=[],this._usesAnySrcRectOrPixelSize=this._uPixelSize.IsUsed()||this._uSrcStart.IsUsed()||this._uSrcEnd.IsUsed()||this._uSrcOriginStart.IsUsed()||this._uSrcOriginEnd.IsUsed(),this._hasCurrentMatP=!1,this._hasCurrentMatMV=!1,this._uColor.Init4f(1,1,1,1),this._uColor2.Init4f(1,1,1,1),this._uSamplerFront.Init1i(0),this._uSamplerBack.Init1i(1),this._uSamplerDepth.Init1i(2),this._uPointTexStart.Init2f(0,0),this._uPointTexEnd.Init2f(1,1),this._uZElevation.Init1f(0),this._uTileSize.Init2f(0,0),this._uTileSpacing.Init2f(0,0),this._uDestStart.Init2f(0,0),this._uDestEnd.Init2f(1,1),this._uSrcStart.Init2f(0,0),this._uSrcEnd.Init2f(0,0),this._uSrcOriginStart.Init2f(0,0),this._uSrcOriginEnd.Init2f(0,0),this._uPixelSize.Init2f(0,0),this._uDevicePixelRatio.Init1f(1),this._uZNear.Init1f(e.GetNearZ()),this._uZFar.Init1f(e.GetFarZ()),this._uLayerScale.Init1f(1),this._uLayerAngle.Init1f(0),this._uSeconds.Init1f(0),this._uLayoutStart.Init2f(0,0),this._uLayoutEnd.Init2f(0,0),this._uOutlineThickness.Init1f(1);for(const h of o){const c=h[0],u=h[2],_=new C33.Gfx.WebGLShaderUniform(this,c,u);"color"===u?_.Init3f(0,0,0):_.Init1f(0),this._uCustomParameters.push(_)}this._isDeviceTransform?this._UpdateDeviceTransformUniforms(r.currentMatP):(this.UpdateMatP(r.currentMatP,!0),this.UpdateMatMV(r.currentMV,!0));const l=r.currentShader;i.useProgram(l?l._shaderProgram:null)}Release(){this._gl.deleteProgram(this._shaderProgram),this._shaderProgram=null,this._renderer._RemoveShaderProgram(this),this._gl=null,super.Release()}GetWebGLContext(){return this._gl}GetShaderProgram(){return this._shaderProgram}GetParameterCount(){return this._uCustomParameters.length}GetParameterType(e){return e<0||e>=this._uCustomParameters.length?null:this._uCustomParameters[e].GetType()}AreCustomParametersAlreadySetInBatch(s){for(let e=0,t=s.length;e<t;++e)if(!this._uCustomParameters[e].IsSetToCustomInBatch(s[e]))return!1;return!0}SetCustomParametersInBatch(s){for(let e=0,t=s.length;e<t;++e)this._uCustomParameters[e].SetBatchValueCustom(s[e])}AreOptionalUniformsAlreadySetInBatch(e,t,s,i,r,n,a,o,l,h){return!this._uSamplerBack.IsUsed()&&!(this._uPixelSize.IsUsed()&&!this._uPixelSize.IsSetTo2InBatch(r,n)||this._uDestStart.IsUsed()&&!this._uDestStart.IsSetTo2InBatch(e.getLeft(),e.getTop())||this._uDestEnd.IsUsed()&&!this._uDestEnd.IsSetTo2InBatch(e.getRight(),e.getBottom())||this._uDevicePixelRatio.IsUsed()&&!this._uDevicePixelRatio.IsSetTo1InBatch(a)||this._uLayerScale.IsUsed()&&!this._uLayerScale.IsSetTo1InBatch(o)||this._uLayerAngle.IsUsed()&&!this._uLayerAngle.IsSetTo1InBatch(l)||this._uSrcStart.IsUsed()&&!this._uSrcStart.IsSetTo2InBatch(t.getLeft(),t.getTop())||this._uSrcEnd.IsUsed()&&!this._uSrcEnd.IsSetTo2InBatch(t.getRight(),t.getBottom())||this._uSrcOriginStart.IsUsed()&&!this._uSrcOriginStart.IsSetTo2InBatch(s.getLeft(),s.getTop())||this._uSrcOriginEnd.IsUsed()&&!this._uSrcOriginEnd.IsSetTo2InBatch(s.getRight(),s.getBottom())||this._uLayoutStart.IsUsed()&&!this._uLayoutStart.IsSetTo2InBatch(i.getLeft(),i.getTop())||this._uLayoutEnd.IsUsed()&&!this._uLayoutEnd.IsSetTo2InBatch(i.getTop(),i.getBottom())||this._uSeconds.IsUsed()&&!this._uSeconds.IsSetTo1InBatch(h))}SetOptionalUniformsInBatch(e,t,s,i,r,n,a,o,l,h){this._uSamplerBack.IsUsed()||(this._uPixelSize.IsUsed()&&this._uPixelSize.SetBatch2(r,n),this._uDestStart.IsUsed()&&this._uDestStart.SetBatch2(e.getLeft(),e.getTop()),this._uDestEnd.IsUsed()&&this._uDestEnd.SetBatch2(e.getRight(),e.getBottom()),this._uDevicePixelRatio.IsUsed()&&this._uDevicePixelRatio.SetBatch1(a),this._uLayerScale.IsUsed()&&this._uLayerScale.SetBatch1(o),this._uLayerAngle.IsUsed()&&this._uLayerAngle.SetBatch1(l),this._uSrcStart.IsUsed()&&this._uSrcStart.SetBatch2(t.getLeft(),t.getTop()),this._uSrcEnd.IsUsed()&&this._uSrcEnd.SetBatch2(t.getRight(),t.getBottom()),this._uSrcOriginStart.IsUsed()&&this._uSrcOriginStart.SetBatch2(s.getLeft(),s.getTop()),this._uSrcOriginEnd.IsUsed()&&this._uSrcOriginEnd.SetBatch2(s.getRight(),s.getBottom()),this._uLayoutStart.IsUsed()&&this._uLayoutStart.SetBatch2(i.getLeft(),i.getTop()),this._uLayoutEnd.IsUsed()&&this._uLayoutEnd.SetBatch2(i.getTop(),i.getBottom()),this._uSeconds.IsUsed()&&this._uSeconds.SetBatch1(h))}UpdateMatP(e,t){this._hasCurrentMatP&&!t||this._isDeviceTransform||(this._uMatP.IsUsed()&&this._uMatP.UpdateMatrix4fv(e),this._hasCurrentMatP=!0)}SetMatPStale(){this._hasCurrentMatP=!1}UpdateMatMV(e,t){this._hasCurrentMatMV&&!t||this._isDeviceTransform||(this._uMatMV.IsUsed()&&this._uMatMV.UpdateMatrix4fv(e),this._hasCurrentMatMV=!0)}SetMatMVStale(){this._hasCurrentMatMV=!1}_UpdateDeviceTransformUniforms(e){if(!this._isDeviceTransform)throw new Error("not device transform shader");this._uMatP.UpdateMatrix4fv(e);const t=this._renderer,s=t.GetWidth()/2,i=t.GetHeight()/2,r=t.CalculateLookAtModelView2(s,i,t.GetDefaultCameraZ(t.GetHeight()),s,i,0,t.GetHeight());this._uMatMV.UpdateMatrix4fv(r)}UpdateColor(e){this._uColor.IsUsed()&&this._uColor.Update4f(e[0],e[1],e[2],e[3])}static GetReservedUniformNames(){return RESERVED_UNIFORM_NAMES}static GetDefaultVertexShaderSource(e){const t=e?"highmedp":"mediump";return["#ifdef GL_FRAGMENT_PRECISION_HIGH","#define highmedp highp","#else","#define highmedp mediump","#endif","attribute highp vec3 aPos;",`attribute ${t} vec2 aTex;`,`varying ${t} vec2 vTex;`,"uniform highp mat4 matP;","uniform highp mat4 matMV;","void main(void) {",` gl_Position = matP * matMV * vec4(aPos, 1.0);`,` vTex = aTex;`,"}"].join("\n")}static GetDefaultVertexShaderSource_WebGL2(e){const t=e?"highp":"mediump";return["#version 300 es","in highp vec3 aPos;",`in ${t} vec2 aTex;`,`out ${t} vec2 vTex;`,"uniform highp mat4 matP;","uniform highp mat4 matMV;","void main(void) {",` gl_Position = matP * matMV * vec4(aPos, 1.0);`,` vTex = aTex;`,"}"].join("\n")}static GetTextureFillFragmentShaderSource_WebGL1_NoFragDepth(){return["varying mediump vec2 vTex;","uniform lowp vec4 color;","uniform lowp sampler2D samplerFront;","void main(void) {","\tgl_FragColor = texture2D(samplerFront, vTex) * color;","}"].join("\n")}static GetTextureFillFragmentShaderSource_WebGL1_FragDepthEXT(){return["#extension GL_EXT_frag_depth : enable","varying mediump vec2 vTex;","uniform lowp vec4 color;","uniform lowp sampler2D samplerFront;","void main(void) {","\tgl_FragColor = texture2D(samplerFront, vTex) * color;","\tgl_FragDepthEXT = (gl_FragColor.a == 0.0 ? 1.0 : gl_FragCoord.z);","}"].join("\n")}static GetTextureFillFragmentShaderSource_WebGL2(){return["#version 300 es","in mediump vec2 vTex;","out lowp vec4 outColor;","uniform lowp vec4 color;","uniform lowp sampler2D samplerFront;","void main(void) {","\toutColor = texture(samplerFront, vTex) * color;","\tgl_FragDepth = (outColor.a == 0.0 ? 1.0 : gl_FragCoord.z);","}"].join("\n")}static GetTilemapFragmentShaderSource_WebGL1_NoFragDepth(){return["#ifdef GL_FRAGMENT_PRECISION_HIGH","#define highmedp highp","#else","#define highmedp mediump","#endif","varying highmedp vec2 vTex;","uniform lowp vec4 color;","uniform lowp sampler2D samplerFront;","uniform highmedp vec2 srcStart;","uniform highmedp vec2 pixelSize;","uniform highmedp vec2 tileSize;","uniform highmedp vec2 tileSpacing;","void main(void) {","\thighmedp vec2 tile = floor(vTex);","\thighmedp vec2 tex = fract(vTex);","\thighmedp vec2 tileOrigin = srcStart + tile * (tileSize + tileSpacing);","\thighmedp vec2 lowerBound = tileOrigin + pixelSize / 2.0;","\thighmedp vec2 upperBound = tileOrigin + tileSize - pixelSize / 2.0;","\tgl_FragColor = texture2D(samplerFront, clamp(tex, lowerBound, upperBound), -16.0) * color;","}"].join("\n")}static GetTilemapFragmentShaderSource_WebGL1_FragDepthEXT(){return["#extension GL_EXT_frag_depth : enable","#ifdef GL_FRAGMENT_PRECISION_HIGH","#define highmedp highp","#else","#define highmedp mediump","#endif","varying highmedp vec2 vTex;","uniform lowp vec4 color;","uniform lowp sampler2D samplerFront;","uniform highmedp vec2 srcStart;","uniform highmedp vec2 pixelSize;","uniform highmedp vec2 tileSize;","uniform highmedp vec2 tileSpacing;","void main(void) {","\thighmedp vec2 tile = floor(vTex);","\thighmedp vec2 tex = fract(vTex);","\thighmedp vec2 tileOrigin = srcStart + tile * (tileSize + tileSpacing);","\thighmedp vec2 lowerBound = tileOrigin + pixelSize / 2.0;","\thighmedp vec2 upperBound = tileOrigin + tileSize - pixelSize / 2.0;","\tgl_FragColor = texture2D(samplerFront, clamp(tex, lowerBound, upperBound), -16.0) * color;","\tgl_FragDepthEXT = (gl_FragColor.a == 0.0 ? 1.0 : gl_FragCoord.z);","}"].join("\n")}static GetTilemapFragmentShaderSource_WebGL2(){return["#version 300 es","in highp vec2 vTex;","out lowp vec4 outColor;","uniform lowp vec4 color;","uniform lowp sampler2D samplerFront;","uniform highp vec2 srcStart;","uniform highp vec2 pixelSize;","uniform highp vec2 tileSize;","uniform highp vec2 tileSpacing;","void main(void) {","\thighp vec2 tile = floor(vTex);","\thighp vec2 tex = fract(vTex);","\thighp vec2 tileOrigin = srcStart + tile * (tileSize + tileSpacing);","\thighp vec2 lowerBound = tileOrigin + pixelSize / 2.0;","\thighp vec2 upperBound = tileOrigin + tileSize - pixelSize / 2.0;","\toutColor = texture(samplerFront, clamp(tex, lowerBound, upperBound), -16.0) * color;","\tgl_FragDepth = (outColor.a == 0.0 ? 1.0 : gl_FragCoord.z);","}"].join("\n")}static GetTileRandomizationFragmentShaderSource(e,t,s){let i="";return 2<=e?i="#version 300 es\n":(t&&(i="#extension GL_EXT_frag_depth : enable\n"),s&&(i+="#extension GL_EXT_shader_texture_lod : enable\n#extension GL_OES_standard_derivatives : enable\n")),i+` #ifdef GL_FRAGMENT_PRECISION_HIGH #define highmedp highp #else #define highmedp mediump #endif precision highmedp float; ${2<=e?"in":"varying"} vec2 vTex; ${2<=e?"out lowp vec4 outColor;":""} uniform lowp vec4 color; uniform lowp sampler2D samplerFront; uniform vec2 pixelSize; uniform vec2 tileSize; uniform vec2 tileSpacing; uniform float outlineThickness; const float PI = 3.1415926; lowp vec4 cospVec4(lowp vec4 a, lowp vec4 b, float x) { return (a + b + (a - b) * cos(x * PI)) / 2.0; } vec3 randVec3(vec2 seed) { return vec3(fract(sin(dot(seed.xy + vec2(0.1, 0.1), vec2(12.9898,78.233))) * 43758.5453), fract(sin(dot(seed.yx + vec2(0.1, 0.1), vec2(12.9898,-78.233))) * 43758.5453), fract(sin(dot(seed.xy + vec2(0.1, 0.1), vec2(-12.9898,-78.233))) * 43758.5453)); } lowp vec4 sampleTile(vec2 tile, vec2 uv, vec2 ddx, vec2 ddy) { vec2 posRandom = tileSize; float angleRandom = outlineThickness; vec3 rand = (randVec3(floor(tile + 0.5)) - 0.5) * 2.0; float angle = angleRandom * rand.z * PI; float sin_a = sin(angle); float cos_a = cos(angle); float aspect = pixelSize.x / pixelSize.y; vec2 mid = tile + vec2(0.5, 0.5); vec2 dp = uv - mid; dp.x /= aspect; vec2 r = vec2(dp.x * cos_a - dp.y * sin_a, dp.y * cos_a + dp.x * sin_a); r.x *= aspect; vec2 p = mid + r + (posRandom * rand.xy / 2.0); ${2<=e?"return textureGrad(samplerFront, p, ddx, ddy);":""} ${e<2&&s?"return texture2DGradEXT(samplerFront, p, ddx, ddy);":""} ${e<2&&!s?"return texture2D(samplerFront, p);":""} } void main(void) { ${e<2?"lowp vec4 outColor;":""} float blendMarginX = tileSpacing.x; float blendMarginY = tileSpacing.y; vec2 tile = floor(vTex); vec2 tex = fract(vTex); vec2 ddx = ${2<=e||s?"dFdx(vTex)":"vec2(0.0, 0.0)"}; vec2 ddy = ${2<=e||s?"dFdy(vTex)":"vec2(0.0, 0.0)"}; vec4 curTile = sampleTile(tile, vTex, ddx, ddy); bool inLeftMargin = (tex.x < blendMarginX); bool inRightMargin = (tex.x > 1.0 - blendMarginX); bool inTopMargin = (tex.y < blendMarginY); bool inBottomMargin = (tex.y > 1.0 - blendMarginY); if (inLeftMargin) { lowp vec4 leftTile = sampleTile(tile + vec2(-1.0, 0.0), vTex, ddx, ddy); float leftMix = (tex.x / (blendMarginX * 2.0)) + 0.5; lowp vec4 leftMixedTile = cospVec4(leftTile, curTile, leftMix); if (inTopMargin) { lowp vec4 topTile = sampleTile(tile + vec2(0.0, -1.0), vTex, ddx, ddy); lowp vec4 topLeftTile = sampleTile(tile + vec2(-1.0, -1.0), vTex, ddx, ddy); lowp vec4 topLeftMixedTile = cospVec4(topLeftTile, topTile, leftMix); outColor = cospVec4(topLeftMixedTile, leftMixedTile, (tex.y / (blendMarginY * 2.0)) + 0.5); } else if (inBottomMargin) { lowp vec4 bottomTile = sampleTile(tile + vec2(0.0, 1.0), vTex, ddx, ddy); lowp vec4 bottomLeftTile = sampleTile(tile + vec2(-1.0, 1.0), vTex, ddx, ddy); lowp vec4 bottomLeftMixedTile = cospVec4(bottomLeftTile, bottomTile, leftMix); outColor = cospVec4(leftMixedTile, bottomLeftMixedTile, (tex.y - (1.0 - blendMarginY)) / (blendMarginY * 2.0)); } else { outColor = leftMixedTile; } } else if (inRightMargin) { lowp vec4 rightTile = sampleTile(tile + vec2(1.0, 0.0), vTex, ddx, ddy); float rightMix = (tex.x - (1.0 - blendMarginX)) / (blendMarginX * 2.0); lowp vec4 rightMixedTile = cospVec4(curTile, rightTile, rightMix); if (inTopMargin) { lowp vec4 topTile = sampleTile(tile + vec2(0.0, -1.0), vTex, ddx, ddy); lowp vec4 topRightTile = sampleTile(tile + vec2(1.0, -1.0), vTex, ddx, ddy); lowp vec4 topRightMixedTile = cospVec4(topTile, topRightTile, rightMix); outColor = cospVec4(topRightMixedTile, rightMixedTile, (tex.y / (blendMarginY * 2.0)) + 0.5); } else if (inBottomMargin) { lowp vec4 bottomTile = sampleTile(tile + vec2(0.0, 1.0), vTex, ddx, ddy); lowp vec4 bottomRightTile = sampleTile(tile + vec2(1.0, 1.0), vTex, ddx, ddy); lowp vec4 bottomRightMixedTile = cospVec4(bottomTile, bottomRightTile, rightMix); outColor = cospVec4(rightMixedTile, bottomRightMixedTile, (tex.y - (1.0 - blendMarginY)) / (blendMarginY * 2.0)); } else { outColor = rightMixedTile; } } else if (inTopMargin) { lowp vec4 topTile = sampleTile(tile + vec2(0.0, -1.0), vTex, ddx, ddy); outColor = cospVec4(topTile, curTile, (tex.y / (blendMarginY * 2.0)) + 0.5); } else if (inBottomMargin) { lowp vec4 bottomTile = sampleTile(tile + vec2(0.0, 1.0), vTex, ddx, ddy); outColor = cospVec4(curTile, bottomTile, (tex.y - (1.0 - blendMarginY)) / (blendMarginY * 2.0)); } else { outColor = curTile; } outColor *= color; ${e<2?"gl_FragColor = outColor;":""} ${2<=e?"gl_FragDepth = (outColor.a == 0.0 ? 1.0 : gl_FragCoord.z);":""} ${e<2&&t?"gl_FragDepthEXT = (outColor.a == 0.0 ? 1.0 : gl_FragCoord.z);":""} } `}static GetPointVertexShaderSource_WebGL1(){return["attribute vec4 aPoints;","varying float pointOpacity;","uniform float zElevation;","uniform mat4 matP;","uniform mat4 matMV;","void main(void) {","\tgl_Position = matP * matMV * vec4(aPoints.xy, zElevation, 1.0);","\tgl_PointSize = aPoints.z;","\tpointOpacity = aPoints.w;","}"].join("\n")}static GetPointVertexShaderSource_WebGL2(){return["#version 300 es","in vec4 aPoints;","out float pointOpacity;","uniform float zElevation;","uniform mat4 matP;","uniform mat4 matMV;","void main(void) {","\tgl_Position = matP * matMV * vec4(aPoints.xy, zElevation, 1.0);","\tgl_PointSize = aPoints.z;","\tpointOpacity = aPoints.w;","}"].join("\n")}static GetPointFragmentShaderSource_WebGL1_NoFragDepth(){return["uniform lowp sampler2D samplerFront;","varying lowp float pointOpacity;","uniform mediump vec2 pointTexStart;","uniform mediump vec2 pointTexEnd;","uniform lowp vec4 color;","void main(void) {","\tmediump vec2 pointTexMin = min(pointTexStart, pointTexEnd);","\tmediump vec2 pointTexMax = max(pointTexStart, pointTexEnd);","\tmediump vec2 pointCoord = (pointTexEnd.x > pointTexStart.x ? gl_PointCoord : vec2(1.0 - gl_PointCoord.y, gl_PointCoord.x));","\tgl_FragColor = texture2D(samplerFront, mix(pointTexMin, pointTexMax, pointCoord)) * color * pointOpacity;","}"].join("\n")}static GetPointFragmentShaderSource_WebGL1_FragDepthEXT(){return["#extension GL_EXT_frag_depth : enable","uniform lowp sampler2D samplerFront;","varying lowp float pointOpacity;","uniform mediump vec2 pointTexStart;","uniform mediump vec2 pointTexEnd;","uniform lowp vec4 color;","void main(void) {","\tmediump vec2 pointTexMin = min(pointTexStart, pointTexEnd);","\tmediump vec2 pointTexMax = max(pointTexStart, pointTexEnd);","\tmediump vec2 pointCoord = (pointTexEnd.x > pointTexStart.x ? gl_PointCoord : vec2(1.0 - gl_PointCoord.y, gl_PointCoord.x));","\tgl_FragColor = texture2D(samplerFront, mix(pointTexMin, pointTexMax, pointCoord)) * color * pointOpacity;","\tgl_FragDepthEXT = (gl_FragColor.a == 0.0 ? 1.0 : gl_FragCoord.z);","}"].join("\n")}static GetPointFragmentShaderSource_WebGL2(){return["#version 300 es","uniform lowp sampler2D samplerFront;","in lowp float pointOpacity;","uniform mediump vec2 pointTexStart;","uniform mediump vec2 pointTexEnd;","uniform lowp vec4 color;","out lowp vec4 outColor;","void main(void) {","\tmediump vec2 pointTexMin = min(pointTexStart, pointTexEnd);","\tmediump vec2 pointTexMax = max(pointTexStart, pointTexEnd);","\tmediump vec2 pointCoord = (pointTexEnd.x > pointTexStart.x ? gl_PointCoord : vec2(1.0 - gl_PointCoord.y, gl_PointCoord.x));","\toutColor = texture(samplerFront, mix(pointTexMin, pointTexMax, pointCoord)) * color * pointOpacity;","\tgl_FragDepth = (outColor.a == 0.0 ? 1.0 : gl_FragCoord.z);","}"].join("\n")}static GetColorFillFragmentShaderSource(){return["uniform lowp vec4 color;","void main(void) {","\tgl_FragColor = color;","}"].join("\n")}static GetLinearGradientFillFragmentShaderSource(){return["precision lowp float;","varying mediump vec2 vTex;","uniform vec4 color;","uniform vec4 color2_;","vec3 fromLinear(vec3 linearRGB)","{","\tbvec3 cutoff = lessThan(linearRGB, vec3(0.0031308));","\tvec3 higher = vec3(1.055) * pow(abs(linearRGB), vec3(1.0/2.4)) - vec3(0.055);","\tvec3 lower = linearRGB * vec3(12.92);","\treturn mix(higher, lower, vec3(cutoff));","}","vec3 toLinear(vec3 sRGB)","{","\tbvec3 cutoff = lessThan(sRGB, vec3(0.04045));","\tvec3 higher = pow(abs((sRGB + vec3(0.055))/vec3(1.055)), vec3(2.4));","\tvec3 lower = sRGB/vec3(12.92);","\treturn mix(higher, lower, vec3(cutoff));","}","void main(void) {","\tvec3 linearGrad = mix(toLinear(color.rgb), toLinear(color2_.rgb), vTex.x);","\tfloat a = mix(color.a, color2_.a, vTex.x);","\tgl_FragColor = vec4(fromLinear(linearGrad) * a, a);","}"].join("\n")}static GetPenumbraFillFragmentShaderSource(){return["#ifdef GL_FRAGMENT_PRECISION_HIGH","#define highmedp highp","#else","#define highmedp mediump","#endif","precision lowp float;","varying highmedp vec2 vTex;","uniform vec4 color;","void main(void) {",` highmedp float grad = vTex.x / (1.0 - vTex.y);`,` gl_FragColor = color * (1.0 - (cos(grad * 3.141592653589793) + 1.0) / 2.0);`,"}"].join("\n")}static GetSmoothLineFillFragmentShaderSource(){return["varying mediump vec2 vTex;","uniform lowp vec4 color;","void main(void) {","\tlowp float f = 1.0 - abs(vTex.y - 0.5) * 2.0;","\tgl_FragColor = color * f;","}"].join("\n")}static GetHardEllipseFillFragmentShaderSource(){return["varying mediump vec2 vTex;","uniform lowp vec4 color;","void main(void) {","\tmediump vec2 diff = vTex - vec2(0.5, 0.5);","\tmediump vec2 diffSq = diff * diff;","\tmediump float f = step(diffSq.x + diffSq.y, 0.25);","\tgl_FragColor = color * f;","}"].join("\n")}static GetHardEllipseOutlineFragmentShaderSource(){return["varying mediump vec2 vTex;","uniform lowp vec4 color;","uniform mediump vec2 pixelSize;","uniform mediump float outlineThickness;","void main(void) {","\tmediump vec2 diff = vTex - vec2(0.5, 0.5);","\tmediump vec2 diffSq = diff * diff;","\tmediump float distSq = diffSq.x + diffSq.y;","\tmediump vec2 norm = normalize(diff);","\tmediump vec2 halfNorm = norm * 0.5;","\tmediump float innerF = step(distSq, 0.25);","\tmediump vec2 innerEdge = halfNorm - pixelSize * norm * outlineThickness;","\tmediump vec2 innerEdgeSq = innerEdge * innerEdge;","\tmediump float outerF = step(innerEdgeSq.x + innerEdgeSq.y, distSq);","\tgl_FragColor = color * innerF * outerF;","}"].join("\n")}static GetSmoothEllipseFillFragmentShaderSource(){return["varying mediump vec2 vTex;","uniform lowp vec4 color;","uniform mediump vec2 pixelSize;","void main(void) {","\tmediump vec2 diff = vTex - vec2(0.5, 0.5);","\tmediump vec2 diffSq = diff * diff;","\tmediump vec2 norm = normalize(diff);","\tmediump vec2 halfNorm = norm * 0.5;","\tmediump vec2 halfNormSq = halfNorm * halfNorm;","\tmediump vec2 innerEdge = halfNorm - pixelSize * norm;","\tmediump vec2 innerEdgeSq = innerEdge * innerEdge;","\tmediump float f = smoothstep(halfNormSq.x + halfNormSq.y, innerEdgeSq.x + innerEdgeSq.y, diffSq.x + diffSq.y);","\tgl_FragColor = color * f;","}"].join("\n")}static GetSmoothEllipseOutlineFragmentShaderSource(){return["varying mediump vec2 vTex;","uniform lowp vec4 color;","uniform mediump vec2 pixelSize;","uniform mediump float outlineThickness;","void main(void) {","\tmediump vec2 diff = vTex - vec2(0.5, 0.5);","\tmediump vec2 diffSq = diff * diff;","\tmediump float distSq = diffSq.x + diffSq.y;","\tmediump vec2 norm = normalize(diff);","\tmediump vec2 halfNorm = norm * 0.5;","\tmediump vec2 halfNormSq = halfNorm * halfNorm;","\tmediump vec2 pxNorm = pixelSize * norm;","\tmediump vec2 innerEdge1 = halfNorm - pxNorm;","\tmediump vec2 innerEdge1Sq = innerEdge1 * innerEdge1;","\tmediump float innerF = smoothstep(halfNormSq.x + halfNormSq.y, innerEdge1Sq.x + innerEdge1Sq.y, distSq);","\tmediump vec2 innerEdge2 = halfNorm - pxNorm * outlineThickness;","\tmediump vec2 innerEdge2Sq = innerEdge2 * innerEdge2;","\tmediump vec2 innerEdge3 = halfNorm - pxNorm * (outlineThickness + 1.0);","\tmediump vec2 innerEdge3Sq = innerEdge3 * innerEdge3;","\tmediump float outerF = smoothstep(innerEdge3Sq.x + innerEdge3Sq.y, innerEdge2Sq.x + innerEdge2Sq.y, distSq);","\tgl_FragColor = color * innerF * outerF;","}"].join("\n")}}}{const C33=self.C3,glMatrix=self.glMatrix,mat42=glMatrix.mat4,TYPE_SIZES=new Map([["float",1],["percent",1],["sampler",1],["vec2",2],["vec3",3],["color",3],["vec4",4],["mat4",16]]);C33.Gfx.WebGLShaderUniform=class{constructor(e,t,s){if(!TYPE_SIZES.has(s))throw new Error("invalid uniform type");this._owner=e,this._gl=this._owner.GetWebGLContext(),this._name=t,this._type=s,this._isColorType="color"===this._type,this._location=this._gl.getUniformLocation(this._owner.GetShaderProgram(),t),this._isUsed=!!this._location;const i=TYPE_SIZES.get(s);this._lastValue=new Float32Array(i),this._lastBatchValue=new Float32Array(i)}Release(){this._owner=null,this._gl=null,this._location=null}IsUsed(){return this._isUsed}GetType(){return this._type}IsColorType(){return this._isColorType}Init1f(e){this.IsUsed()&&(this._lastValue[0]=e,this._lastBatchValue.set(this._lastValue),this._gl.uniform1f(this._location,e))}Init1i(e){this.IsUsed()&&(this._lastValue[0]=e,this._lastBatchValue.set(this._lastValue),this._gl.uniform1i(this._location,e))}Init2f(e,t){this.IsUsed()&&(this._lastValue[0]=e,this._lastValue[1]=t,this._lastBatchValue.set(this._lastValue),this._gl.uniform2f(this._location,e,t))}Init3f(e,t,s){this.IsUsed()&&(this._lastValue[0]=e,this._lastValue[1]=t,this._lastValue[2]=s,this._lastBatchValue.set(this._lastValue),this._gl.uniform3f(this._location,e,t,s))}Init4f(e,t,s,i){this.IsUsed()&&(this._lastValue[0]=e,this._lastValue[1]=t,this._lastValue[2]=s,this._lastValue[3]=i,this._lastBatchValue.set(this._lastValue),this._gl.uniform4f(this._location,e,t,s,i))}Update1f(e){e=Math.fround(e);const t=this._lastValue;t[0]!==e&&(t[0]=e,this._gl.uniform1f(this._location,e))}Update1i(e){const t=this._lastValue;t[0]!==e&&this._gl.uniform1i(this._location,t[0]=e)}Update2f(e,t){e=Math.fround(e),t=Math.fround(t);const s=this._lastValue;s[0]===e&&s[1]===t||(s[0]=e,s[1]=t,this._gl.uniform2f(this._location,e,t))}Update3f(e,t,s){e=Math.fround(e),t=Math.fround(t),s=Math.fround(s);const i=this._lastValue;i[0]===e&&i[1]===t&&i[2]===s||(i[0]=e,i[1]=t,i[2]=s,this._gl.uniform3f(this._location,e,t,s))}Update4f(e,t,s,i){e=Math.fround(e),t=Math.fround(t),s=Math.fround(s),i=Math.fround(i);const r=this._lastValue;r[0]===e&&r[1]===t&&r[2]===s&&r[3]===i||(r[0]=e,r[1]=t,r[2]=s,r[3]=i,this._gl.uniform4f(this._location,e,t,s,i))}UpdateMatrix4fv(e){const t=this._lastValue;mat42.exactEquals(t,e)||(C33.typedArraySet16(t,e,0),this._gl.uniformMatrix4fv(this._location,!1,e))}IsSetToCustomInBatch(e){const t=this._lastBatchValue;return this.IsColorType()?t[0]===Math.fround(e.getR())&&t[1]===Math.fround(e.getG())&&t[2]===Math.fround(e.getB()):t[0]===Math.fround(e)}SetBatchValueCustom(e){const t=this._lastBatchValue;this.IsColorType()?(t[0]=e.getR(),t[1]=e.getG(),t[2]=e.getB()):t[0]=e}IsSetTo1InBatch(e){return this._lastBatchValue[0]===Math.fround(e)}IsSetTo2InBatch(e,t){const s=this._lastBatchValue;return s[0]===Math.fround(e)&&s[1]===Math.fround(t)}SetBatch1(e){this._lastBatchValue[0]=e}SetBatch2(e,t){const s=this._lastBatchValue;s[0]=e,s[1]=t}}}{const C33=self.C3,glMatrix=self.glMatrix,vec42=glMatrix.vec4,mat42=glMatrix.mat4,BATCH_NULL=0,BATCH_QUAD=1,BATCH_SETTEXTURE=2,BATCH_SETCOLOR=3,BATCH_SETBLEND=4,BATCH_SETVIEWPORT=5,BATCH_SETPROJECTION=6,BATCH_SETMODELVIEW=7,BATCH_SETRENDERTARGET=8,BATCH_CLEARSURFACE=9,BATCH_POINTS=10,BATCH_SETPROGRAM=11,BATCH_SETPROGRAMPARAMETERS=12,BATCH_SETPROGRAMCUSTOMPARAMETERS=13,BATCH_INVALIDATEFRAMEBUFFER=14,BATCH_SETPOINTTEXCOORDS=15,BATCH_SETTILEMAPINFO=16,BATCH_BLITFRAMEBUFFER=17,BATCH_STARTQUERY=18,BATCH_ENDQUERY=19,BATCH_SETELLIPSEPARAMS=20,BATCH_SETGRADIENTCOLOR=21,BATCH_CLEARDEPTH=22,BATCH_SETDEPTHENABLED=23,BATCH_SETDEPTHSAMPLINGENABLED=24,BATCH_COPLANAR_STARTSTENCILPASS=25,BATCH_COPLANAR_STARTCOLORPASS=26,BATCH_COPLANAR_RESTORE=27,BATCH_SET_SCISSOR=28,BATCH_SETTILERANDOMIZATIONINFO=29;C33.Gfx.BatchState=class{constructor(e){this.renderer=e,this.currentMV=mat42.create(),this.currentMatP=mat42.create(),this.currentFramebuffer=null,this.currentFramebufferNoDepth=null,this.isDepthSamplingEnabled=!1,this.currentColor=vec42.fromValues(1,1,1,1),this.currentShader=null,this.pointTexCoords=new C33.Rect,this.clearColor=C33.New(C33.Color,0,0,0,0)}},C33.Gfx.WebGLBatchJob=class{constructor(e){const t=new ArrayBuffer(96);this._type=0,this._batchState=e,this._gl=e.renderer.GetContext(),this._startIndex=0,this._indexCount=0,this._texParam=null,this._mat4param=new Float32Array(t,0,16),this._colorParam=new Float32Array(t,64,4),this._srcOriginRect=new Float32Array(t,80,4),this._shaderParams=[]}InitQuad(e,t){this._type=BATCH_QUAD,this._startIndex=e,this._indexCount=t}DoQuad(){const e=this._gl;e.drawElements(e.TRIANGLES,this._indexCount,e.UNSIGNED_SHORT,this._startIndex)}InitSetTexture(e){this._type=BATCH_SETTEXTURE,this._texParam=e}DoSetTexture(){const e=this._gl,t=this._texParam;e.bindTexture(e.TEXTURE_2D,t?t._GetTexture():null)}InitSetColor(e){this._type=BATCH_SETCOLOR,e.writeToTypedArray(this._colorParam,0)}DoSetColor(){const e=this._colorParam,t=this._batchState;vec42.copy(t.currentColor,e),t.currentShader.UpdateColor(e)}InitSetGradientColor(e){this._type=BATCH_SETGRADIENTCOLOR,e.writeToTypedArray(this._colorParam,0)}DoSetGradientColor(){const e=this._colorParam,t=this._batchState.currentShader;t._uColor2.IsUsed()&&t._uColor2.Update4f(e[0],e[1],e[2],e[3])}InitSetBlend(e,t){this._type=BATCH_SETBLEND,this._startIndex=e,this._indexCount=t}DoSetBlend(){this._gl.blendFunc(this._startIndex,this._indexCount)}InitSetViewport(e,t,s,i){this._type=BATCH_SETVIEWPORT;const r=this._colorParam;r[0]=e,r[1]=t,r[2]=s,r[3]=i}DoSetViewport(){const e=this._colorParam;this._gl.viewport(e[0],e[1],e[2],e[3])}InitSetProjection(e){this._type=BATCH_SETPROJECTION,mat42.copy(this._mat4param,e)}DoSetProjection(){const e=this._batchState,s=e.renderer._allShaderPrograms,i=e.currentShader,r=this._mat4param;for(let e=0,t=s.length;e<t;++e){const n=s[e];n===i?n.UpdateMatP(r,!0):n.SetMatPStale()}mat42.copy(e.currentMatP,r)}InitSetModelView(e){this._type=BATCH_SETMODELVIEW,mat42.copy(this._mat4param,e)}DoSetModelView(){const e=this._batchState,s=e.renderer._allShaderPrograms,i=e.currentShader,r=this._mat4param;for(let e=0,t=s.length;e<t;++e){const n=s[e];n===i?n.UpdateMatMV(r,!0):n.SetMatMVStale()}mat42.copy(e.currentMV,r)}InitSetRenderTarget(e){this._type=BATCH_SETRENDERTARGET,this._texParam=e}DoSetRenderTarget(){const e=this._gl,t=this._texParam,s=this._batchState;t?(s.currentFramebuffer=t._GetFramebuffer(),s.currentFramebufferNoDepth=t._GetFramebufferNoDepth(),s.isDepthSamplingEnabled&&s.currentFramebufferNoDepth?e.bindFramebuffer(e.FRAMEBUFFER,s.currentFramebufferNoDepth):e.bindFramebuffer(e.FRAMEBUFFER,s.currentFramebuffer)):(s.currentFramebuffer=null,s.currentFramebufferNoDepth=null,e.bindFramebuffer(e.FRAMEBUFFER,null))}InitClearSurface(e){this._type=BATCH_CLEARSURFACE,e.writeToTypedArray(this._mat4param,0)}InitClearSurface2(e,t,s,i){this._type=BATCH_CLEARSURFACE;const r=this._mat4param;r[0]=e,r[1]=t,r[2]=s,r[3]=i}DoClearSurface(){const e=this._gl,t=this._mat4param,s=this._batchState,i=s.clearColor,r=t[0],n=t[1],a=t[2],o=t[3];i.equalsRgba(r,n,a,o)||(e.clearColor(r,n,a,o),i.setRgba(r,n,a,o)),e.clear(e.COLOR_BUFFER_BIT)}InitSetPointTexCoords(e){this._type=BATCH_SETPOINTTEXCOORDS,e.writeToTypedArray(this._mat4param,0)}DoSetPointTextureCoords(){const e=this._mat4param;this._batchState.pointTexCoords.set(e[0],e[1],e[2],e[3])}InitPoints(e,t){this._type=BATCH_POINTS,this._startIndex=e,this._indexCount=1,this._mat4param[0]=t}DoPoints(){const e=this._gl,t=this._batchState,s=t.renderer,i=s._spPoints,r=(e.useProgram(i._shaderProgram),i.UpdateMatP(t.currentMatP,!1),i.UpdateMatMV(t.currentMV,!1),t.pointTexCoords),n=(i._uPointTexStart.IsUsed()&&i._uPointTexStart.Update2f(r.getLeft(),r.getTop()),i._uPointTexEnd.IsUsed()&&i._uPointTexEnd.Update2f(r.getRight(),r.getBottom()),this._mat4param[0]);if(i._uZElevation.IsUsed()&&i._uZElevation.Update1f(n),i._uColor.IsUsed()){const a=t.currentColor;i._uColor.Update4f(a[0],a[1],a[2],a[3])}e.drawArrays(e.POINTS,this._startIndex/4,this._indexCount),e.useProgram(t.currentShader._shaderProgram)}InitSetProgram(e){this._type=BATCH_SETPROGRAM,this._texParam=e}DoSetProgram(){const e=this._gl,t=this._batchState,s=this._texParam;if(t.currentShader=s,e.useProgram(s._shaderProgram),s.UpdateMatP(t.currentMatP,!1),s.UpdateMatMV(t.currentMV,!1),s._uColor.IsUsed()){const i=t.currentColor;s._uColor.Update4f(i[0],i[1],i[2],i[3])}}InitSetProgramParameters(){this._type=BATCH_SETPROGRAMPARAMETERS}DoSetProgramParameters(){const e=this._batchState.currentShader,t=this._gl,s=this._mat4param,i=this._colorParam,r=this._srcOriginRect;if(e._uSamplerBack.IsUsed()){const n=this._batchState.renderer,a=this._texParam;n._lastTexture1!==a&&(t.activeTexture(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,a?a._GetTexture():null),n._lastTexture1=a,t.activeTexture(t.TEXTURE0))}e._uPixelSize.IsUsed()&&e._uPixelSize.Update2f(s[0],s[1]),e._uDestStart.IsUsed()&&e._uDestStart.Update2f(s[2],s[3]),e._uDestEnd.IsUsed()&&e._uDestEnd.Update2f(s[4],s[5]),e._uDevicePixelRatio.IsUsed()&&e._uDevicePixelRatio.Update1f(this._indexCount),e._uLayerScale.IsUsed()&&e._uLayerScale.Update1f(s[6]),e._uLayerAngle.IsUsed()&&e._uLayerAngle.Update1f(s[7]),e._uSrcStart.IsUsed()&&e._uSrcStart.Update2f(s[12],s[13]),e._uSrcEnd.IsUsed()&&e._uSrcEnd.Update2f(s[14],s[15]),e._uSrcOriginStart.IsUsed()&&e._uSrcOriginStart.Update2f(r[0],r[1]),e._uSrcOriginEnd.IsUsed()&&e._uSrcOriginEnd.Update2f(r[2],r[3]),e._uLayoutStart.IsUsed()&&e._uLayoutStart.Update2f(i[0],i[1]),e._uLayoutEnd.IsUsed()&&e._uLayoutEnd.Update2f(i[2],i[3]),e._uSeconds.IsUsed()&&e._uSeconds.Update1f(this._startIndex)}InitSetProgramCustomParameters(){this._type=BATCH_SETPROGRAMCUSTOMPARAMETERS}DoSetProgramCustomParameters(){const e=this._batchState.currentShader,s=e._uCustomParameters,i=this._shaderParams;for(let e=0,t=s.length;e<t;++e){const r=s[e],n=i[e];r.IsColorType()?r.Update3f(n.getR(),n.getG(),n.getB()):r.Update1f(n)}}InitInvalidateFramebuffer(e){this._type=BATCH_INVALIDATEFRAMEBUFFER,this._texParam=e}DoInvalidateFramebuffer(){const e=this._gl,t=this._texParam,s=this._batchState.currentFramebuffer;t!==s&&e.bindFramebuffer(e.FRAMEBUFFER,t),e.invalidateFramebuffer(e.FRAMEBUFFER,[e.COLOR_ATTACHMENT0]),t!==s&&e.bindFramebuffer(e.FRAMEBUFFER,s)}InitBlitFramebuffer(e,t,s){this._type=BATCH_BLITFRAMEBUFFER;const i=this._mat4param,r=this._batchState.renderer,n=(i[0]=e.GetWidth(),i[1]=e.GetHeight(),i[2]=(t||r).GetWidth(),i[3]=(t||r).GetHeight(),i[4]=e.IsLinearSampling()?1:0,i[5]="stretch"===s,this._shaderParams);C33.clearArray(n),n.push(e._GetFramebuffer()),n.push(t?t._GetFramebuffer():null)}DoBlitFramebuffer(){const e=this._mat4param,t=this._shaderParams,s=this._gl,i=e[0],r=e[1],n=e[2],a=e[3],o=0!==e[4],l=0!==e[5],h=t[0],c=t[1];if(s.bindFramebuffer(s.READ_FRAMEBUFFER,h),s.bindFramebuffer(s.DRAW_FRAMEBUFFER,c),l)s.blitFramebuffer(0,0,i,r,0,0,n,a,s.COLOR_BUFFER_BIT,o?s.LINEAR:s.NEAREST);else{const u=Math.min(i,n),_=Math.min(r,a),d=Math.max(r-a,0),p=Math.max(a-r,0);s.blitFramebuffer(0,d,u,_+d,0,p,u,_+p,s.COLOR_BUFFER_BIT,s.NEAREST)}}InitStartQuery(e){this._type=BATCH_STARTQUERY,this._texParam=e}DoStartQuery(){this._texParam.BeginTimeElapsed(),this._texParam=null}InitEndQuery(e){this._type=BATCH_ENDQUERY,this._texParam=e}DoEndQuery(){this._texParam.EndTimeElapsed(),this._texParam=null}InitSetEllipseParams(e,t,s){this._type=BATCH_SETELLIPSEPARAMS;const i=this._mat4param;i[0]=e,i[1]=t,i[2]=s}DoSetEllipseParams(){const e=this._batchState.currentShader,t=this._mat4param;e._uPixelSize.IsUsed()&&e._uPixelSize.Update2f(t[0],t[1]),e._uOutlineThickness.IsUsed()&&e._uOutlineThickness.Update1f(t[2])}InitSetTilemapInfo(e,t,s,i,r,n,a){this._type=BATCH_SETTILEMAPINFO;const o=this._mat4param;e.writeToTypedArray(o,0),o[4]=1/t,o[5]=1/s,o[6]=i/t,o[7]=r/s,o[8]=n/t,o[9]=a/s}DoSetTilemapInfo(){const e=this._batchState.currentShader,t=this._mat4param;e._uSrcStart.IsUsed()&&e._uSrcStart.Update2f(t[0],t[1]),e._uPixelSize.IsUsed()&&e._uPixelSize.Update2f(t[4],t[5]),e._uTileSize.IsUsed()&&e._uTileSize.Update2f(t[6],t[7]),e._uTileSpacing.IsUsed()&&e._uTileSpacing.Update2f(t[8],t[9])}InitSetTileRandomizationInfo(e,t,s,i,r,n,a){this._type=BATCH_SETTILERANDOMIZATIONINFO;const o=this._mat4param;o[0]=1/e,o[1]=1/t,o[2]=s,o[3]=i,o[4]=r,o[5]=n,o[6]=a}DoSetTileRandomizationInfo(){const e=this._batchState.currentShader,t=this._mat4param;e._uPixelSize.IsUsed()&&e._uPixelSize.Update2f(t[0],t[1]),e._uTileSize.IsUsed()&&e._uTileSize.Update2f(t[2],t[3]),e._uOutlineThickness.IsUsed()&&e._uOutlineThickness.Update1f(t[4]),e._uTileSpacing.IsUsed()&&e._uTileSpacing.Update2f(t[5],t[6])}InitClearDepth(e){this._type=BATCH_CLEARDEPTH,this._startIndex=e?1:0}DoClearDepth(){const e=this._gl,t=0!==this._startIndex;t||e.depthMask(!0),e.clear(e.DEPTH_BUFFER_BIT),t||e.depthMask(!1)}InitSetDepthEnabled(e){this._type=BATCH_SETDEPTHENABLED,this._startIndex=e?1:0}DoSetDepthEnabled(){const e=this._gl;0===this._startIndex?(e.disable(e.DEPTH_TEST),e.depthMask(!1)):(e.enable(e.DEPTH_TEST),e.depthMask(!0))}InitSetDepthSamplingEnabled(e){this._type=BATCH_SETDEPTHSAMPLINGENABLED,this._startIndex=e?1:0}DoSetDepthSamplingEnabled(){const e=this._gl,t=this._batchState,s=t.renderer,i=0!==this._startIndex;t.isDepthSamplingEnabled=i,e.activeTexture(e.TEXTURE2),i?(t.currentFramebufferNoDepth&&e.bindFramebuffer(e.FRAMEBUFFER,t.currentFramebufferNoDepth),e.bindTexture(e.TEXTURE_2D,s._GetDepthBuffer())):(e.bindTexture(e.TEXTURE_2D,null),t.currentFramebufferNoDepth&&e.bindFramebuffer(e.FRAMEBUFFER,t.currentFramebuffer)),e.activeTexture(e.TEXTURE0)}InitCoplanarStartStencilPass(){this._type=BATCH_COPLANAR_STARTSTENCILPASS}DoCoplanarStartStencilPass(){const e=this._gl;e.clear(e.STENCIL_BUFFER_BIT),e.enable(e.STENCIL_TEST),e.stencilFunc(e.ALWAYS,1,1),e.stencilOp(e.KEEP,e.KEEP,e.REPLACE),e.colorMask(!1,!1,!1,!1)}InitCoplanarStartColorPass(){this._type=BATCH_COPLANAR_STARTCOLORPASS}DoCoplanarStartColorPass(){const e=this._gl;e.colorMask(!0,!0,!0,!0),e.stencilFunc(e.EQUAL,1,1),e.stencilOp(e.KEEP,e.KEEP,e.KEEP)}InitCoplanarRestore(){this._type=BATCH_COPLANAR_RESTORE}DoCoplanarRestore(){const e=this._gl;e.disable(e.STENCIL_TEST)}InitSetScissor(e,t,s,i,r){this._type=BATCH_SET_SCISSOR,this._startIndex=e?1:0;const n=this._mat4param;n[0]=t,n[1]=s,n[2]=i,n[3]=r}DoSetScissor(){const e=this._gl,t=this._mat4param;1===this._startIndex?(e.enable(e.SCISSOR_TEST),e.scissor(t[0],t[1],t[2],t[3])):e.disable(e.SCISSOR_TEST)}Run(){switch(this._type){case 1:return void this.DoQuad();case 2:return void this.DoSetTexture();case 3:return void this.DoSetColor();case 4:return void this.DoSetBlend();case 5:return void this.DoSetViewport();case 6:return void this.DoSetProjection();case 7:return void this.DoSetModelView();case 8:return void this.DoSetRenderTarget();case 9:return void this.DoClearSurface();case 10:return void this.DoPoints();case 11:return void this.DoSetProgram();case 12:return void this.DoSetProgramParameters();case 13:return void this.DoSetProgramCustomParameters();case 14:return void this.DoInvalidateFramebuffer();case 15:return void this.DoSetPointTextureCoords();case 16:return void this.DoSetTilemapInfo();case 17:return void this.DoBlitFramebuffer();case 18:return void this.DoStartQuery();case 19:return void this.DoEndQuery();case 20:return void this.DoSetEllipseParams();case 21:return void this.DoSetGradientColor();case 22:return void this.DoClearDepth();case 23:return void this.DoSetDepthEnabled();case 24:return void this.DoSetDepthSamplingEnabled();case 25:return void this.DoCoplanarStartStencilPass();case 26:return void this.DoCoplanarStartColorPass();case 27:return void this.DoCoplanarRestore();case 28:return void this.DoSetScissor();case 29:return void this.DoSetTileRandomizationInfo()}}}}{let fillOrStrokeRect2=function(e,t,s,i,r,n){t?e.strokeRect(s,i,r,n):e.fillRect(s,i,r,n)},ptToPx2=function(e){return e*(4/3)},getOffsetParam2=function(e,t){e=e.trim();const s=parseFloat(e);return isFinite(s)?e.endsWith("%")?t*s/100:s:0};fillOrStrokeRect=fillOrStrokeRect2,ptToPx=ptToPx2,getOffsetParam=getOffsetParam2;const C33=self.C3,MAX_TEXTURE_SIZE=4096,EXTRA_LINE_HEIGHT=4,GENERIC_FONT_FAMILIES=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),DEFAULT_OPTS={timeout:60},tempColor=new C33.Color(0,0,0,1),VALID_HORIZ_ALIGNMENTS=new Set(["left","center","right"]),VALID_VERT_ALIGNMENTS=new Set(["top","center","bottom"]),VALID_WORD_WRAP_MODES=new Set(["word","cjk","character"]),VALID_TEXT_DIRECTIONS=new Set(["ltr","rtl"]),allRendererTexts=new Set;C33.FontManager&&C33.FontManager.addEventListener("fontload",e=>{const t=e.font.GetName();for(const s of allRendererTexts)(s.IsBBCodeEnabled()||C33.equalsNoCase(s.GetFontName(),t))&&s._SetWordWrapChanged()});let didCheckFoundBoundingBoxSupport=!1,supportsFontBoundingBoxMeasurements=!1;C33.Gfx.RendererText=class{constructor(e,t){t=Object.assign({},DEFAULT_OPTS,t),this._renderer=e,this._fontName="Arial",this._fontSize=16,this._fontSizeScale=1,this._lineHeight=0,this._isBold=!1,this._isItalic=!1,this._colorStr="black",this._isBBcodeEnabled=!1,this._iconSet=null,this._iconSmoothing=!0,this.onloadfont=null,this._alreadyLoadedFonts=new Set,this._horizontalAlign="left",this._verticalAlign="top",this._text="",this._bbString=null,this._wrappedText=C33.New(C33.WordWrap),this._wrapMode="word",this._textDirection="ltr",this._wordWrapChanged=!1,this._textLayoutChanged=!1,this._drawChanged=!1,this._drawMaxCharCount=-1,this._drawCharCount=0,this._cssWidth=0,this._cssHeight=0,this._width=0,this._height=0,this._zoom=1,this._textCanvas=null,this._textContext=null,this._measureContext=null,this._measureContextTop=null,this._lastCanvasWidth=-1,this._lastCanvasHeight=-1,this._lastTextCanvasFont="",this._lastMeasureCanvasFont="",this._lastTextCanvasFillStyle="",this._lastTextCanvasOpacity=1,this._lastTextCanvasLineWidth=1,this._measureTextCallback=e=>this._MeasureText(e),this._texture=null,this._rcTex=new C33.Rect,this._scaleFactor=1,this._textureTimeout=new C33.IdleTimeout(()=>{this.ReleaseTexture(),this._SetTextCanvasSize(8,8)},t.timeout),this.ontextureupdate=null,this._wasReleased=!1,allRendererTexts.add(this)}Release(){this.onloadfont=null,this._alreadyLoadedFonts.clear(),this._iconSet=null,this._bbString=null,this._textCanvas=null,this._textContext=null,this._measureContext=null,this._measureContextTop=null,this._measureTextCallback=null,this._textureTimeout.Release(),this.ontextureupdate=null,this.ReleaseTexture(),this._wrappedText.Clear(),this._wrappedText=null,this._renderer=null,this._wasReleased=!0,allRendererTexts.delete(this)}_SetDrawChanged(){this._drawChanged=!0}_SetTextLayoutChanged(){this._SetDrawChanged(),this._textLayoutChanged=!0}_SetWordWrapChanged(){this._SetTextLayoutChanged(),this._wordWrapChanged=!0}SetBBCodeEnabled(e){if(this._isBBcodeEnabled!==(e=!!e)){this._isBBcodeEnabled=e;const t=this._isBBcodeEnabled?"alphabetic":"top";this._textContext&&(this._textContext.textBaseline=t),this._measureContext&&(this._measureContext.textBaseline=t),this._SetWordWrapChanged()}}IsBBCodeEnabled(){return this._isBBcodeEnabled}SetIconSet(e){this._iconSet!==e&&(this._iconSet=e,this._wrappedText.SetIconSet(e),this._iconSet&&this._iconSet.IsLoading()&&this._iconSet.LoadContent().then(()=>this._SetDrawChanged()),this._SetWordWrapChanged())}SetIconSmoothing(e){this._iconSmoothing!==(e=!!e)&&(this._iconSmoothing=e,this._SetDrawChanged())}SetFontName(e){this._fontName!==(e=e||"serif")&&(this._fontName=e,this._SetWordWrapChanged())}GetFontName(){return this._fontName}SetFontSize(e){this._fontSize!==(e=e<.1?.1:e)&&(this._fontSize=e,this._SetWordWrapChanged())}GetFontSize(){return this._fontSize}SetFontSizeScale(e){this._fontSizeScale!==e&&(this._fontSizeScale=e,this._SetWordWrapChanged())}SetLineHeight(e){this._lineHeight!==e&&(this._lineHeight=e,this._SetTextLayoutChanged())}GetLineHeight(){return this._lineHeight}SetBold(e){this._isBold!==(e=!!e)&&(this._isBold=e,this._SetWordWrapChanged())}IsBold(){return this._isBold}SetItalic(e){this._isItalic!==(e=!!e)&&(this._isItalic=e,this._SetWordWrapChanged())}IsItalic(){return this._isItalic}SetDrawMaxCharacterCount(e){e=Math.floor(e),this._drawMaxCharCount!==e&&(this._drawMaxCharCount=e,this._SetDrawChanged())}GetDrawMaxCharacterCount(){return this._drawMaxCharCount}_GetFontString(e,t){let s=[];(this._isBold||t.HasStyleTag("b"))&&s.push("bold"),(this._isItalic||t.HasStyleTag("i"))&&s.push("italic");const i=t.GetStyleTag("size"),r=(i?parseFloat(i.param):this._fontSize)*this._fontSizeScale;s.push(e?r+"pt":r*this.GetDrawScale()+"pt");let n=this._fontName,a=t.GetStyleTag("font");return a&&a.param&&(n=a.param,this.onloadfont)&&!this._alreadyLoadedFonts.has(n)&&(this.onloadfont(n),this._alreadyLoadedFonts.add(n)),n&&(GENERIC_FONT_FAMILIES.has(n)?s.push(n):s.push('"'+n+'"')),s.join(" ")}SetColor(e){e instanceof C33.Color&&(e=e.getCssRgb()),this._colorStr!==e&&(this._colorStr=e,this._SetDrawChanged())}SetColorRgb(e,t,s){tempColor.setRgb(e,t,s),this.SetColor(tempColor)}SetHorizontalAlignment(e){if(!VALID_HORIZ_ALIGNMENTS.has(e))throw new Error("invalid horizontal alignment");this._horizontalAlign!==e&&(this._horizontalAlign=e,this._SetTextLayoutChanged())}GetHorizontalAlignment(){return this._horizontalAlign}SetVerticalAlignment(e){if(!VALID_VERT_ALIGNMENTS.has(e))throw new Error("invalid vertical alignment");this._verticalAlign!==e&&(this._verticalAlign=e,this._SetTextLayoutChanged())}GetVerticalAlignment(){return this._verticalAlign}SetWordWrapMode(e){if(!VALID_WORD_WRAP_MODES.has(e))throw new Error("invalid word wrap mode");this._wrapMode!==e&&(this._wrapMode=e,this._SetWordWrapChanged())}GetWordWrapMode(){return this._wrapMode}SetTextDirection(e){if(!VALID_TEXT_DIRECTIONS.has(e))throw new Error("invalid text direction");this._textDirection!==e&&(this._textDirection=e,this._textContext&&(this._textContext.direction=this._textDirection),this._measureContext&&(this._measureContext.direction=this._textDirection),this._SetWordWrapChanged())}GetTextDirection(){return this._textDirection}SetText(e){this._text!==e&&(this._text=e,this._SetWordWrapChanged())}GetText(){return this._text}GetDrawScale(){return this._scaleFactor*this._zoom*self.devicePixelRatio}SetSize(n,a,o){if(void 0===o&&(o=1),!(n<=0||this._cssWidth===n&&this._cssHeight===a&&this._zoom===o)){let e=this._cssWidth,t=(this._cssWidth=n,this._cssHeight=a,this._zoom=o,self.devicePixelRatio),s=(this._width=this._cssWidth*this._zoom*t,this._height=this._cssHeight*this._zoom*t,Math.max(this._width,this._height)),i=Math.min(this._renderer.GetMaxTextureSize(),MAX_TEXTURE_SIZE),r=1;i<s&&(r=i/s,this._width=Math.min(this._width*r,i),this._height=Math.min(this._height*r,i)),this._scaleFactor=r,this._cssWidth!==e?this._SetWordWrapChanged():this._SetTextLayoutChanged()}}GetWidth(){return this._width}GetHeight(){return this._height}GetZoom(){return this._zoom}GetTextWidth(){return this._UpdateTextMeasurements(),this._wrappedText.GetMaxLineWidth()}GetTextHeight(){return this._UpdateTextMeasurements(),this._wrappedText.GetTotalLineHeight()+this._wrappedText.GetLineCount()*(this._lineHeight+EXTRA_LINE_HEIGHT)-this._lineHeight}GetLengthInGraphemes(){this._UpdateTextMeasurements();let e=0;for(const t of this._wrappedText.GetLines())for(const s of t.fragments())e+=s.GetLength();return e}GetTexture(){return this._textureTimeout.Reset(),this._MaybeUpdate(),this._texture}HitTestFragment(e,t){this._UpdateTextMeasurements();const s=this.GetDrawScale(),i=this._wrappedText.GetLines();for(const r of i){const n=r.GetFontBoundingBoxDescent()*s;if(t>=r.GetPosY()-r.GetHeight()*s+n&&t<r.GetPosY()+n)for(const a of r.fragments())if(e>=a.GetPosX()&&e<a.GetPosX()+a.GetWidth()*s)return a}return null}*fragmentsWithTag(e){this._UpdateTextMeasurements();const t=this._wrappedText.GetLines();for(const s of t)for(const i of s.fragments()){const r=i.GetStyleTag("tag");r&&C33.equalsNoCase(r.param,e)&&(yield i)}}FindFragmentWithTag(e,t){for(const s of this.fragmentsWithTag(e)){if(0===t)return s;--t}return null}CountFragmentsWithTag(e){let t=0;for(const s of this.fragmentsWithTag(e))++t;return t}_MaybeUpdate(){this._texture&&!this._drawChanged&&!this._textLayoutChanged&&!this._wordWrapChanged||this._wasReleased||this._width<=0||this._height<=0||(this._drawChanged=!1,this._DoUpdate())}_DoUpdate(){this._wasReleased||(this._UpdateTextMeasurements(),this._SetTextCanvasSize(Math.max(C33.nextHighestPowerOfTwo(Math.ceil(this._width)),128),Math.max(C33.nextHighestPowerOfTwo(Math.ceil(this._height)),64)),this._DrawTextToCanvas(),this._UpdateTexture(),this._textureTimeout.Reset())}_SetTextCanvasSize(e,t){this._textCanvas||(this._textCanvas=C33.CreateCanvas(16,16));let s=!1;this._lastCanvasWidth===e&&this._lastCanvasHeight===t||(this._lastCanvasWidth=e,this._lastCanvasHeight=t,this._textCanvas.width=e,this._textCanvas.height=t,s=!0),this._textContext||(this._textContext=this._textCanvas.getContext("2d"),s=!0),s?(this._textContext.textBaseline=this._isBBcodeEnabled?"alphabetic":"top",this._textContext.direction=this._textDirection,this._textContext.font=this._lastTextCanvasFont,this._textContext.fillStyle=this._lastTextCanvasFillStyle,this._textContext.strokeStyle=this._lastTextCanvasFillStyle,this._textContext.globalAlpha=this._lastTextCanvasOpacity,this._textContext.lineWidth=this._lastTextCanvasLineWidth):this._textContext.clearRect(0,0,e,t)}_MaybeCreateMeasureContext(){this._measureContext||(this._measureContext=C33.CreateCanvas(16,16).getContext("2d"),this._measureContextTop=C33.CreateCanvas(16,16).getContext("2d"),this._measureContext.textBaseline=this._isBBcodeEnabled?"alphabetic":"top",this._measureContextTop.textBaseline="top",this._measureContext.direction=this._textDirection,this._measureContextTop.direction=this._textDirection)}_SetMeasureFontString(e){this._lastMeasureCanvasFont!==e&&(this._lastMeasureCanvasFont=e,this._measureContext.font=e,this._measureContextTop.font=e)}_SupportsFontBoundingBoxMeasurements(){if(!didCheckFoundBoundingBoxSupport){didCheckFoundBoundingBoxSupport=!0,this._MaybeCreateMeasureContext();const e=this._measureContext.measureText("test");supportsFontBoundingBoxMeasurements="number"==typeof e.fontBoundingBoxAscent&&"number"==typeof e.fontBoundingBoxDescent}return supportsFontBoundingBoxMeasurements}_UpdateTextMeasurements(){this._UpdateWordWrap(),this._UpdateTextLayout()}_UpdateWordWrap(){this._wordWrapChanged&&(this._MaybeCreateMeasureContext(),!this._isBBcodeEnabled||this._bbString&&this._bbString.toString()===this._text||(this._bbString=new C33.BBString(this._text,{noEscape:!0})),this._wrappedText.WordWrap(this._isBBcodeEnabled?this._bbString.toFragmentList():this._text,this._measureTextCallback,this._cssWidth,this._wrapMode,0),this._wordWrapChanged=!1)}_UpdateTextLayout(){this._textLayoutChanged&&(this._LayoutText(),this._textLayoutChanged=!1)}_MeasureText(e){let t=e.IsText()?e.GetCharacterArray().join(""):" ",s=(this._SetMeasureFontString(this._GetFontString(!0,e)),e.GetStyleTag("size")),i=(s?parseFloat(s.param):this._fontSize)*this._fontSizeScale,r=this._measureContext.measureText(t),n=0;if(this._isBBcodeEnabled&&this._SupportsFontBoundingBoxMeasurements()){const a=this._measureContextTop.measureText(t);n=r.fontBoundingBoxAscent-a.fontBoundingBoxAscent}return{width:r.width,height:ptToPx2(i),fontBoundingBoxAscent:r.fontBoundingBoxAscent||0,fontBoundingBoxDescent:r.fontBoundingBoxDescent||0,topToAlphabeticDistance:n}}_SetDrawFontString(e){this._lastTextCanvasFont!==e&&(this._lastTextCanvasFont=e,this._textContext.font=e)}_SetDrawCanvasColor(e){this._lastTextCanvasFillStyle!==e&&(this._lastTextCanvasFillStyle=e,this._textContext.fillStyle=e,this._textContext.strokeStyle=e)}_SetDrawCanvasOpacity(e){this._lastTextCanvasOpacity!==e&&(this._lastTextCanvasOpacity=e,this._textContext.globalAlpha=e)}_SetDrawCanvasLineWith(e){this._lastTextCanvasLineWidth!==e&&(this._lastTextCanvasLineWidth=e,this._textContext.lineWidth=e)}_LayoutText(){let i=this.GetDrawScale(),r=(EXTRA_LINE_HEIGHT+this._lineHeight)*i,n=0,a=this._wrappedText.GetLines();if(0!==a.length){for(const t of a){t.SetPosX(NaN),t.SetPosY(NaN);for(const o of t.fragments())o.SetPosX(NaN),o.SetPosY(NaN)}let e=this._isBBcodeEnabled&&this._SupportsFontBoundingBoxMeasurements(),s=a[0].GetHeight()*i;if("center"===this._verticalAlign){const l=a.reduce((e,t)=>e+t.GetHeight()*i+r,0)-r;n=Math.max(this._height/2-l/2,0),e&&(s=a[0].GetTopToAlphabeticDistance()*i)}else if("bottom"===this._verticalAlign){const h=a.reduce((e,t)=>e+t.GetHeight()*i+r,0)-this._lineHeight*i,c=e?a.at(-1).GetFontBoundingBoxDescent()*i:0;n=this._height-h-c-2}for(let e=0,t=a.length;e<t;++e){const u=a[e],_=u.GetHeight()*i,d=n;if(this._isBBcodeEnabled){if(n+=0===e?s:_,0<e&&n>this._height-EXTRA_LINE_HEIGHT*i)break}else if(0<e&&n>=this._height-_)break;0<=d&&this._LayoutTextLine(u,n,i),this._isBBcodeEnabled||(n+=_),n+=r}}}_LayoutTextLine(e,t,s){let i=0;"center"===this._horizontalAlign?i=Math.floor((this._width-e.GetWidth()*s)/2):"right"===this._horizontalAlign&&(i=this._width-e.GetWidth()*s),e.SetPosX(i),e.SetPosY(t);for(const r of"ltr"===this._textDirection?e.fragments():e.fragmentsReverse())this._LayoutFragment(r,i,t,s),i+=r.GetWidth()*s}_LayoutFragment(e,t,s,i){const r=e.GetStyleTag("offsetx"),n=(t+=r?getOffsetParam2(r.param,e.GetHeight())*i:0,e.GetStyleTag("offsety"));if(s+=n?getOffsetParam2(n.param,e.GetHeight())*i:0,e.IsIcon()){const a=e.GetStyleTag("iconoffsety");s+=a?getOffsetParam2(a.param,e.GetHeight())*i:.2*e.GetHeight()*i}e.SetPosX(t),e.SetPosY(s)}_DrawTextToCanvas(){this._textContext.imageSmoothingEnabled=this._iconSmoothing,this._textContext.imageSmoothingQuality="high",this._drawCharCount=0;const e=this.GetDrawScale(),t=this._wrappedText.GetLines();for(const s of t)this._DrawTextLine(s,e)}_DrawTextLine(e,t){const s=e.GetPosX(),i=e.GetPosY();if(Number.isFinite(s)&&Number.isFinite(i))for(const r of"ltr"===this._textDirection?e.fragments():e.fragmentsReverse())this._DrawFragment(r,t,e.GetHeight())}_DrawFragment(a,o,l){const h=this._textContext,c=a.GetPosX(),u=a.GetPosY();if(Number.isFinite(c)&&Number.isFinite(u)){let e=l/16,t=a.GetWidth()*o,s=a.GetHeight()*o,i=a.GetHeight()/16,r=(EXTRA_LINE_HEIGHT+this._lineHeight)*o,n=a.IsText()?a.GetCharacterArray():null;if(-1!==this._drawMaxCharCount){if(this._drawCharCount>=this._drawMaxCharCount)return;a.IsText()&&this._drawCharCount+n.length>this._drawMaxCharCount&&(n=n.slice(0,this._drawMaxCharCount-this._drawCharCount),t=this._MeasureText(a).width*o),this._drawCharCount+=a.GetLength()}const _=a.GetStyleTag("background"),d=a.HasStyleTag("u"),p=a.HasStyleTag("s");if((!a.IsText()||!C33.IsCharArrayAllWhitespace(n)||_||d||p)&&!a.HasStyleTag("hide")){const m=a.GetStyleTag("color"),g=a.GetStyleTag("opacity"),f=(this._SetDrawCanvasOpacity(g?parseFloat(g.param)/100:1),_&&(this._SetDrawCanvasColor(_.param),h.fillRect(c,u-s,t,s+r)),a.GetStyleTag("linethickness")),S=f?parseFloat(f.param):1,C=a.HasStyleTag("stroke");if(C&&this._SetDrawCanvasLineWith(.5*i*S*this.GetDrawScale()),a.IsText()){const y=n.join("");if(this._SetDrawFontString(this._GetFontString(!1,a)),!C){this._SetDrawCanvasLineWith(.5*i*S*this.GetDrawScale());const G=a.GetStyleTag("outlineback");G&&(this._SetDrawCanvasColor(G.param),this._FillOrStrokeText(!0,y,c,u,t))}if(this._SetDrawCanvasColor(m?m.param:this._colorStr),this._FillOrStrokeText(C,y,c,u,t),!C){this._SetDrawCanvasLineWith(.5*i*S*this.GetDrawScale());const I=a.GetStyleTag("outline");I&&(this._SetDrawCanvasColor(I.param),this._FillOrStrokeText(!0,y,c,u,t))}}else if(a.IsIcon()&&0<a.GetWidth()){const T=a.GetDrawable(this._iconSet);T&&h.drawImage(T,c,u-s,t,s)}if(this._SetDrawCanvasColor(m?m.param:this._colorStr),d&&fillOrStrokeRect2(h,C,c,u+o*e,t,o*e*S),p){const b=u-s/4,A=o*i,P=b+A/2;h.fillRect(c,P-A*S/2,t,A*S)}}}}_FillOrStrokeText(e,t,s,i,r){"rtl"===this._textDirection&&(s+=r),e?"Gecko"===C33.Platform.BrowserEngine?this._textContext.strokeText(t,s,i,r):this._textContext.strokeText(t,s,i):"Gecko"===C33.Platform.BrowserEngine?this._textContext.fillText(t,s,i,r):this._textContext.fillText(t,s,i)}_UpdateTexture(){this._renderer.IsContextLost()||(this._texture||(this._texture=this._renderer.CreateDynamicTexture(this._textCanvas.width,this._textCanvas.height,{mipMap:!0,mipMapQuality:"high"})),this._renderer.UpdateTexture(this._textCanvas,this._texture),this._rcTex.set(0,0,this._width/this._texture.GetWidth(),this._height/this._texture.GetHeight()),this.ontextureupdate&&this.ontextureupdate())}GetTexRect(){return this._rcTex}ReleaseTexture(){this._texture&&(this._renderer.IsContextLost()||this._renderer.DeleteTexture(this._texture),this._texture=null)}static OnContextLost(){for(const e of allRendererTexts)e.ReleaseTexture()}static GetAll(){return allRendererTexts.values()}}}{const C33=self.C3;class WebGLRealTimeElapsedQuery{constructor(e){this._gl=e.GetContext(),this._version=e.GetWebGLVersionNumber(),this._timerExt=e._GetDisjointTimerQueryExtension(),this._query=null,this._isActive=!1,this._hasResult=!1,this._result=0,1===this._version?this._query=this._timerExt.createQueryEXT():this._query=this._gl.createQuery()}Release(){this._DeleteQueryObject(),this._gl=null,this._timerExt=null,this._hasResult=!1}_DeleteQueryObject(){this._query&&(1===this._version?this._timerExt.deleteQueryEXT(this._query):this._gl.deleteQuery(this._query),this._query=null)}BeginTimeElapsed(){if(this._isActive)throw new Error("query already active");1===this._version?this._timerExt.beginQueryEXT(this._timerExt.TIME_ELAPSED_EXT,this._query):this._gl.beginQuery(this._timerExt.TIME_ELAPSED_EXT,this._query),this._isActive=!0}EndTimeElapsed(){if(!this._isActive)throw new Error("query not active");1===this._version?this._timerExt.endQueryEXT(this._timerExt.TIME_ELAPSED_EXT):this._gl.endQuery(this._timerExt.TIME_ELAPSED_EXT),this._isActive=!1}CheckForResult(){if(this._query&&!this._hasResult&&!this._isActive){let e;e=1===this._version?this._timerExt.getQueryObjectEXT(this._query,this._timerExt.QUERY_RESULT_AVAILABLE_EXT):this._gl.getQueryParameter(this._query,this._gl.QUERY_RESULT_AVAILABLE);const t=this._gl.getParameter(this._timerExt.GPU_DISJOINT_EXT);e&&!t&&(1===this._version?this._result=this._timerExt.getQueryObjectEXT(this._query,this._timerExt.QUERY_RESULT_EXT):this._result=this._gl.getQueryParameter(this._query,this._gl.QUERY_RESULT),this._result/=1e9,this._hasResult=!0),(e||t)&&this._DeleteQueryObject()}}HasResult(){return this._hasResult}GetResult(){if(this._hasResult)return this._result;throw new Error("no result available")}}C33.Gfx.WebGLTimeElapsedQuery=class{constructor(e){this._renderer=e,this._frameNumber=e.GetFrameNumber(),this._isActive=!1,this._parentQuery=null,this._isNested=!1,this._realQuery=null,this._queries=[]}Release(){for(const e of this._queries)e instanceof WebGLRealTimeElapsedQuery&&e.Release();C33.clearArray(this._queries),this._parentQuery=null,this._realQuery=null,this._renderer=null}BeginTimeElapsed(){if(this._isActive)throw new Error("query already active");const e=this._renderer._GetTimeQueryStack();0<e.length?(this._isNested=!0,this._parentQuery=e.at(-1),this._parentQuery._EndReal(),this._parentQuery._queries.push(this)):(this._isNested=!1,this._parentQuery=null),this._isActive=!0,e.push(this),this._StartReal()}EndTimeElapsed(){if(!this._isActive)throw new Error("query not active");const e=this._renderer._GetTimeQueryStack().pop();if(e!==this)throw new Error("can only end most nested query");this._isActive=!1,this._EndReal(),this._parentQuery&&(this._parentQuery._StartReal(),this._parentQuery=null)}_StartReal(){this._realQuery=C33.New(WebGLRealTimeElapsedQuery,this._renderer),this._queries.push(this._realQuery),this._realQuery.BeginTimeElapsed()}_EndReal(){this._realQuery.EndTimeElapsed(),this._realQuery=null}CheckForResult(){for(const e of this._queries)e.CheckForResult()}IsNested(){return this._isNested}HasResult(){return this._queries.every(e=>e.HasResult())}GetResult(){return this._queries.reduce((e,t)=>e+t.GetResult(),0)}GetFrameNumber(){return this._frameNumber}}}{const C33=self.C3;C33.Gfx.WebGLQueryResultBuffer=class{constructor(e,t=1e3){this._renderer=e,this._maxQueries=t,this._buffer=[],this._renderer._AddQueryResultBuffer(this)}Release(){this.Clear(),this._renderer._RemoveQueryResultBuffer(this),this._renderer=null}Clear(){for(const e of this._buffer)e.Release();C33.clearArray(this._buffer)}AddTimeElapsedQuery(){const e=new C33.Gfx.WebGLTimeElapsedQuery(this._renderer);if(this._buffer.push(e),this._buffer.length>this._maxQueries){const t=this._buffer.shift();t.Release()}return e}CheckForResults(e){for(const t of this._buffer){if(t.GetFrameNumber()>=e)return;if(t.IsNested())return;t.CheckForResult()}}GetFrameRangeResultSum(e,t){if(t<=e)return NaN;let s=0;for(const i of this._buffer){if(i.GetFrameNumber()>=t)break;if(!(i.GetFrameNumber()<e)){if(!i.HasResult())return NaN;s+=i.GetResult()}}return s}DeleteAllBeforeFrameNumber(s){for(let e=0,t=this._buffer.length;e<t;++e){const i=this._buffer[e];if(!(i.GetFrameNumber()<s))return void(0<e&&this._buffer.splice(0,e));i.Release()}}}}{let CheckPendingPolls2=function(){pollRafId=-1;for(const e of pendingPolls)e.checkFunc()&&(e.resolve(),pendingPolls.delete(e));0<pendingPolls.size&&(pollRafId=self.requestAnimationFrame(CheckPendingPolls2))},C33=(CheckPendingPolls=CheckPendingPolls2,self.C3),assert=self.assert,glMatrix=self.glMatrix,vec32=glMatrix.vec3,vec42=glMatrix.vec4,mat42=glMatrix.mat4,DEFAULT_WEBGLRENDERER_OPTS={powerPreference:"default",enableGpuProfiling:!0,alpha:!1,depth:!1,canSampleDepth:!1,maxWebGLVersion:2,failIfMajorPerformanceCaveat:!1},VALID_POWER_PREFERENCES=new Set(["default","low-power","high-performance"]),MAX_VERTICES=8e3,MAX_INDICES=MAX_VERTICES/2*3,MAX_POINTS=8e3,LAST_POINT=MAX_POINTS-4,PARTIAL_TEXTURE_UPLOAD_CHUNK_SIZE=262144,defaultTexCoordsQuad=new C33.Quad(0,0,1,0,1,1,0,1),tmpProjection=mat42.create(),tmpModelView=mat42.create(),tmpQuad=new C33.Quad,tmpRect=new C33.Rect,loseContextExtension=null,pendingPolls=(C33.isDebug&&(self.debug_lose_webgl_context=function(){loseContextExtension?loseContextExtension.loseContext():console.warn("WEBGL_lose_context not supported")},self.debug_restore_webgl_context=function(){loseContextExtension?loseContextExtension.restoreContext():console.warn("WEBGL_lose_context not supported")}),new Set),pollRafId=-1;C33.Gfx.WebGLRenderer=class extends C33.Gfx.RendererBase{constructor(e,t){if(super(t),t=Object.assign({},DEFAULT_WEBGLRENDERER_OPTS,t),!VALID_POWER_PREFERENCES.has(t.powerPreference))throw new Error("invalid power preference");let s={alpha:!!t.alpha,depth:!1,antialias:!1,powerPreference:t.powerPreference,failIfMajorPerformanceCaveat:!!t.failIfMajorPerformanceCaveat},i=null,r=0;if(2<=t.maxWebGLVersion&&(i=e.getContext("webgl2",s),r=2),i||(i=e.getContext("webgl",s),r=1),!i)throw new Error("renderer-unavailable (could not get WebGL context)");this._gl=i,this._attribs=i.getContextAttributes(),this._versionString=i.getParameter(i.VERSION),this._version=r,this._viewport=vec42.create(),this._didChangeTransform=!1,this._bbProjectionMatrix=mat42.create(),this._usesDepthBuffer=!!t.depth,this._canSampleDepth=!(!t.depth||!t.canSampleDepth),this._isDepthEnabled=this._usesDepthBuffer,this._isDepthSamplingEnabled=!1,this._depthBuffer=null,this._isAutoSizeDepthBuffer=!0,this._depthBufferWidth=0,this._depthBufferHeight=0,this._vertexBuffer=null,this._texcoordBuffer=null,this._indexBuffer=null,this._pointBuffer=null,this._vertexData=new Float32Array(MAX_VERTICES*this.GetNumVertexComponents()),this._indexData=new Uint16Array(MAX_INDICES),this._texcoordData=new Float32Array(2*MAX_VERTICES),this._pointData=new Float32Array(4*MAX_POINTS),this._vertexPtr=0,this._texPtr=0,this._pointPtr=0,this._lastVertexPtr=0,this._lastProgram=null,this._spDeviceTransformTextureFill=null,this._batch=[],this._batchPtr=0,this._topOfBatch=0,this._currentRenderTarget=null,this._lastPointZ=0,this._batchState=C33.New(C33.Gfx.BatchState,this),this._lastColor=C33.New(C33.Color,1,1,1,1),this._lastTexture0=null,this._lastTexture1=null,this._lastSrcBlend=0,this._lastDestBlend=0,this._lastPointTexCoords=new C33.Rect,this._lastScissorRect=C33.New(C33.Rect,0,0,-1,-1),this._coplanarMode=0,this._maxTextureSize=-1,this._minPointSize=0,this._maxPointSize=0,this._highpPrecision=0,this._unmaskedVendor="(unavailable)",this._unmaskedRenderer="(unavailable)",this._extensions=[],this._isInitialisingAfterContextRestored=!1,this._parallelShaderCompileExt=null,this._anisotropicExt=null,this._depthTextureExt=null,this._fragDepthExt=null,this._stdDerivativesExt=null,this._textureLodExt=null,this._maxAnisotropy=0,this._isGpuProfilingEnabled=!!t.enableGpuProfiling,this._timerExt=null,this._allQueryResultBuffers=new Set,this._timeQueryStack=[],this.FillIndexBufferData(this._indexData)}IsWebGL(){return!0}async InitState(){super.InitState();const e=this._gl,t=this.GetNumVertexComponents(),s=(this._lastColor.setRgba(1,1,1,1),this._lastTexture0=null,this._lastTexture1=null,this._vertexPtr=0,this._pointPtr=0,this._lastVertexPtr=MAX_VERTICES*t-4*t,C33.clearArray(this._batch),this._batchPtr=0,this._topOfBatch=0,this._lastProgram=null,this._currentRenderTarget=null,this._lastPointTexCoords.set(0,0,1,1),this._lastPointZ=0,this._batchState),i=(s.currentShader=null,s.currentFramebuffer=null,s.currentFramebufferNoDepth=null,vec42.set(s.currentColor,1,1,1,1),s.clearColor.setRgba(0,0,0,0),s.pointTexCoords.set(0,0,1,1),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.enable(e.BLEND),e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA),this._lastSrcBlend=e.ONE,this._lastDestBlend=e.ONE_MINUS_SRC_ALPHA,this._InitBlendModes(e),e.disable(e.CULL_FACE),e.disable(e.STENCIL_TEST),e.disable(e.DITHER),this._usesDepthBuffer?(e.enable(e.DEPTH_TEST),e.depthMask(!0),e.depthFunc(e.LEQUAL)):(e.disable(e.DEPTH_TEST),e.depthMask(!1)),this._isDepthEnabled=this._usesDepthBuffer,this._isDepthSamplingEnabled=!1,this._pointBuffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this._pointBuffer),e.bufferData(e.ARRAY_BUFFER,this._pointData.byteLength,e.DYNAMIC_DRAW),this._vertexBuffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this._vertexBuffer),e.bufferData(e.ARRAY_BUFFER,this._vertexData.byteLength,e.DYNAMIC_DRAW),this._texcoordBuffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this._texcoordBuffer),e.bufferData(e.ARRAY_BUFFER,this._texcoordData.byteLength,e.DYNAMIC_DRAW),this._indexBuffer=e.createBuffer(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this._indexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this._indexData,e.STATIC_DRAW),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,null),this._maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),e.getParameter(e.ALIASED_POINT_SIZE_RANGE)),r=(this._minPointSize=i[0],this._maxPointSize=i[1],e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT)),n=e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT),a=(this._highpPrecision=r&&n?Math.min(r.precision,n.precision):0,2048<this._maxPointSize&&(this._maxPointSize=2048),this._extensions=e.getSupportedExtensions(),e.getExtension("WEBGL_debug_renderer_info"));if(a&&(this._unmaskedVendor=e.getParameter(a.UNMASKED_VENDOR_WEBGL),this._unmaskedRenderer=e.getParameter(a.UNMASKED_RENDERER_WEBGL)),this._parallelShaderCompileExt=e.getExtension("KHR_parallel_shader_compile"),C33.isDebug&&(loseContextExtension=e.getExtension("WEBGL_lose_context")),this._isGpuProfilingEnabled&&(1===this.GetWebGLVersionNumber()?this._timerExt=e.getExtension("EXT_disjoint_timer_query"):this._timerExt=e.getExtension("EXT_disjoint_timer_query_webgl2")||e.getExtension("EXT_disjoint_timer_query")),this._anisotropicExt=e.getExtension("EXT_texture_filter_anisotropic"),this._anisotropicExt?this._maxAnisotropy=e.getParameter(this._anisotropicExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT):this._maxAnisotropy=0,this.GetWebGLVersionNumber()<2&&this._usesDepthBuffer&&this._canSampleDepth&&(this._depthTextureExt=e.getExtension("WEBGL_depth_texture"),!this._depthTextureExt))throw new Error("no depth texture support");this.GetWebGLVersionNumber()<2&&(this._fragDepthExt=e.getExtension("EXT_frag_depth"),this._stdDerivativesExt=e.getExtension("OES_standard_derivatives"),this._textureLodExt=e.getExtension("EXT_shader_texture_lod"));let o=C33.Gfx.WebGLShaderProgram,l=o.GetDefaultVertexShaderSource(!1),h=o.GetTextureFillFragmentShaderSource_WebGL1_NoFragDepth(),c=l,u=o.GetPointFragmentShaderSource_WebGL1_NoFragDepth(),_=o.GetPointVertexShaderSource_WebGL1(),d=o.GetTilemapFragmentShaderSource_WebGL1_NoFragDepth(),p=o.GetDefaultVertexShaderSource(!0),m=!1;this._usesDepthBuffer&&(this.GetWebGLVersionNumber()<2?this._fragDepthExt&&(h=o.GetTextureFillFragmentShaderSource_WebGL1_FragDepthEXT(),u=o.GetPointFragmentShaderSource_WebGL1_FragDepthEXT(),d=o.GetTilemapFragmentShaderSource_WebGL1_FragDepthEXT(),m=!0):(c=o.GetDefaultVertexShaderSource_WebGL2(),h=o.GetTextureFillFragmentShaderSource_WebGL2(),u=o.GetPointFragmentShaderSource_WebGL2(),_=o.GetPointVertexShaderSource_WebGL2(),d=o.GetTilemapFragmentShaderSource_WebGL2(),p=o.GetDefaultVertexShaderSource_WebGL2(!0)));const g=o.GetTileRandomizationFragmentShaderSource(this.GetWebGLVersionNumber(),m,this._stdDerivativesExt&&this._textureLodExt),f=2<=this.GetWebGLVersionNumber()?o.GetDefaultVertexShaderSource_WebGL2():l,S=[[h,c,"<default>"],[h,c,"<default-device-transform>"],[u,_,"<point>"],[o.GetColorFillFragmentShaderSource(),l,"<fill>"],[o.GetLinearGradientFillFragmentShaderSource(),l,"<lineargradient>"],[o.GetPenumbraFillFragmentShaderSource(),l,"<penumbra>"],[o.GetHardEllipseFillFragmentShaderSource(),l,"<hardellipse>"],[o.GetHardEllipseOutlineFragmentShaderSource(),l,"<hardellipseoutline>"],[o.GetSmoothEllipseFillFragmentShaderSource(),l,"<smoothellipse>"],[o.GetSmoothEllipseOutlineFragmentShaderSource(),l,"<smoothellipseoutline>"],[o.GetSmoothLineFillFragmentShaderSource(),l,"<smoothline>"],[d,p,"<tilemap>"],[g,f,"<tilerandomization>"]],C=await Promise.all(S.map(e=>this.CreateShaderProgram({src:e[0],vertexSrc:e[1],name:e[2]})));this._spTextureFill=C[0],this._spDeviceTransformTextureFill=C[1],this._spPoints=C[2],this._spColorFill=C[3],this._spLinearGradientFill=C[4],this._spPenumbraFill=C[5],this._spHardEllipseFill=C[6],this._spHardEllipseOutline=C[7],this._spSmoothEllipseFill=C[8],this._spSmoothEllipseOutline=C[9],this._spSmoothLineFill=C[10],this._spTilemapFill=C[11],this._spTileRandomization=C[12],this.SetTextureFillMode()}async CreateShaderProgram(e){const t=await C33.Gfx.WebGLShaderProgram.Create(this,e);return this._AddShaderProgram(t),t}ResetLastProgram(){this._lastProgram=null}SetSize(e,t,s){if(this._width!==e||this._height!==t||s){this.EndBatch();const i=this._gl,r=this._batchState;this._width=e,this._height=t,this._SetViewport(0,0,e,t),this.CalculatePerspectiveMatrix(this._bbProjectionMatrix,e/t),this.SetProjectionMatrix(this._bbProjectionMatrix),this._spDeviceTransformTextureFill&&(i.useProgram(this._spDeviceTransformTextureFill.GetShaderProgram()),this._spDeviceTransformTextureFill._UpdateDeviceTransformUniforms(this._matP),this._lastProgram=this._spDeviceTransformTextureFill,this._batchState.currentShader=this._spDeviceTransformTextureFill),i.bindTexture(i.TEXTURE_2D,null),i.activeTexture(i.TEXTURE1),i.bindTexture(i.TEXTURE_2D,null),i.activeTexture(i.TEXTURE0),this._lastTexture0=null,this._lastTexture1=null,this._usesDepthBuffer&&this._isAutoSizeDepthBuffer&&this._SetDepthBufferSize(this._width,this._height),this._currentRenderTarget&&this._currentRenderTarget._Resize(this._width,this._height),i.bindFramebuffer(i.FRAMEBUFFER,null),this._currentRenderTarget=null,r.currentFramebuffer=null,r.currentFramebufferNoDepth=null}}_SetDepthBufferSize(e,t){const s=this._gl;this._depthBuffer&&this._depthBufferWidth===e&&this._depthBufferHeight===t||(this._canSampleDepth?(this._depthBuffer&&s.deleteTexture(this._depthBuffer),this._depthBuffer=s.createTexture(),s.bindTexture(s.TEXTURE_2D,this._depthBuffer),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.NEAREST),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),2<=this.GetWebGLVersionNumber()?s.texImage2D(s.TEXTURE_2D,0,s.DEPTH24_STENCIL8,e,t,0,s.DEPTH_STENCIL,s.UNSIGNED_INT_24_8,null):this._depthTextureExt&&s.texImage2D(s.TEXTURE_2D,0,s.DEPTH_STENCIL,e,t,0,s.DEPTH_STENCIL,this._depthTextureExt.UNSIGNED_INT_24_8_WEBGL,null),s.bindTexture(s.TEXTURE_2D,null)):(this._depthBuffer&&s.deleteRenderbuffer(this._depthBuffer),this._depthBuffer=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,this._depthBuffer),s.renderbufferStorage(s.RENDERBUFFER,2<=this._version?s.DEPTH24_STENCIL8:s.DEPTH_STENCIL,e,t),s.bindRenderbuffer(s.RENDERBUFFER,null)),this._depthBufferWidth=e,this._depthBufferHeight=t)}SetFixedSizeDepthBuffer(e,t){this._usesDepthBuffer&&(this._isAutoSizeDepthBuffer=!1,this._SetDepthBufferSize(e,t))}SetAutoSizeDepthBuffer(){this._usesDepthBuffer&&(this._isAutoSizeDepthBuffer=!0,this._SetDepthBufferSize(this._width,this._height))}_SetViewport(e,t,s,i){const r=this._viewport;if(r[0]!==e||r[1]!==t||r[2]!==s||r[3]!==i){const n=this.PushBatch();n.InitSetViewport(e,t,s,i),vec42.set(r,e,t,s,i),this._topOfBatch=0}}SetFovY(e){super.SetFovY(e),this.CalculatePerspectiveMatrix(this._bbProjectionMatrix,this._width/this._height)}SetNearZ(e){super.SetNearZ(e),this.CalculatePerspectiveMatrix(this._bbProjectionMatrix,this._width/this._height)}SetFarZ(e){super.SetFarZ(e),this.CalculatePerspectiveMatrix(this._bbProjectionMatrix,this._width/this._height)}SetProjectionMatrix(e){if(!mat42.exactEquals(this._matP,e)){const t=this.PushBatch();t.InitSetProjection(e),mat42.copy(this._matP,e),this._topOfBatch=0,this._didChangeTransform=!0}}SetDefaultRenderTargetProjectionState(){let e,t,s,i=this._currentRenderTarget;s=(null===i?(e=this._bbProjectionMatrix,t=this.GetWidth(),this):(e=i.GetProjectionMatrix(),t=i.GetWidth(),i)).GetHeight(),this.SetProjectionMatrix(e),this._SetViewport(0,0,t,s)}SetModelViewMatrix(e){if(!mat42.exactEquals(this._matMV,e)){const t=this.PushBatch();t.InitSetModelView(e),mat42.copy(this._matMV,e),this._topOfBatch=0,this._didChangeTransform=!0}}ResetDidChangeTransformFlag(){this._didChangeTransform=!1}DidChangeTransform(){return this._didChangeTransform}GetBatchState(){return this._batchState}PushBatch(){const e=this._batch;return this._batchPtr===e.length&&e.push(new C33.Gfx.WebGLBatchJob(this._batchState)),e[this._batchPtr++]}EndBatch(){0===this._batchPtr||this.IsContextLost()||(this._WriteBuffers(),this._ExecuteBatch(),this._batchPtr=0,this._vertexPtr=0,this._texPtr=0,this._pointPtr=0,this._topOfBatch=0)}_WriteBuffers(){const e=this._gl;0<this._pointPtr&&(e.bindBuffer(e.ARRAY_BUFFER,this._pointBuffer),e.bufferSubData(e.ARRAY_BUFFER,0,this._pointData.subarray(0,this._pointPtr))),0<this._vertexPtr&&(e.bindBuffer(e.ARRAY_BUFFER,this._vertexBuffer),e.bufferSubData(e.ARRAY_BUFFER,0,this._vertexData.subarray(0,this._vertexPtr)),e.bindBuffer(e.ARRAY_BUFFER,this._texcoordBuffer),e.bufferSubData(e.ARRAY_BUFFER,0,this._texcoordData.subarray(0,this._texPtr)))}_ExecuteBatch(){const s=this._batch;for(let e=0,t=this._batchPtr;e<t;++e)s[e].Run()}GetOpacity(){return this._lastColor.getA()}SetColorRgba(e,t,s,i){const r=this._lastColor;if(!r.equalsRgba(e,t,s,i)){r.setRgba(e,t,s,i);const n=this.PushBatch();n.InitSetColor(r),this._topOfBatch=0,this._currentStateGroup=null}}SetOpacity(e){const t=this._lastColor;if(t.getA()!==e){t.setA(e);const s=this.PushBatch();s.InitSetColor(t),this._topOfBatch=0,this._currentStateGroup=null}}SetColor(e){const t=this._lastColor;if(!t.equals(e)){t.set(e);const s=this.PushBatch();s.InitSetColor(t),this._topOfBatch=0,this._currentStateGroup=null}}ResetColor(){this.SetColorRgba(1,1,1,1)}GetColor(){return this._lastColor}SetTexture(e){if(e!==this._lastTexture0){const t=this.PushBatch();t.InitSetTexture(e),this._lastTexture0=e,this._topOfBatch=0}}_ResetLastTexture(){this._lastTexture0=null}SetBlendMode(e){const t=this._GetBlendByIndex(e);this._SetBlend(t[0],t[1])}SetNamedBlendMode(e){const t=this.GetNamedBlend(e);this._SetBlend(t.srcBlend,t.destBlend)}_SetBlend(e,t){if(e!==this._lastSrcBlend||t!==this._lastDestBlend){const s=this.PushBatch();s.InitSetBlend(e,t),this._lastSrcBlend=e,this._lastDestBlend=t,this._topOfBatch=0,this._currentStateGroup=null}}IsPremultipliedAlphaBlend(){return this._lastSrcBlend===this._gl.ONE&&this._lastDestBlend===this._gl.ONE_MINUS_SRC_ALPHA}SetAlphaBlend(){this._SetBlend(this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA)}SetNoPremultiplyAlphaBlend(){this._SetBlend(this._gl.SRC_ALPHA,this._gl.ONE_MINUS_SRC_ALPHA)}SetCopyBlend(){this._SetBlend(this._gl.ONE,this._gl.ZERO)}Rect(e){this.Rect2(e.getLeft(),e.getTop(),e.getRight(),e.getBottom())}Rect2(e,t,s,i){this.Quad2(e,t,s,t,s,i,e,i)}_ExtendQuadBatch(){let e=this._vertexPtr;if(e>=this._lastVertexPtr&&(this.EndBatch(),e=0),1===this._topOfBatch)this._batch[this._batchPtr-1]._indexCount+=6;else{const t=this.PushBatch();t.InitQuad(e,6),this._topOfBatch=1}}_WriteQuadToVertexBuffer(e){e.writeToTypedArray3D(this._vertexData,this._vertexPtr,this._baseZ+this._currentZ),this._vertexPtr+=12}Quad(e){this._ExtendQuadBatch(),this._WriteQuadToVertexBuffer(e),defaultTexCoordsQuad.writeToTypedArray(this._texcoordData,this._texPtr),this._texPtr+=8}Quad2(e,t,s,i,r,n,a,o){this._ExtendQuadBatch();let l=this._vertexData,h=this._vertexPtr,c=this._baseZ+this._currentZ;l[h++]=e,l[h++]=t,l[h++]=c,l[h++]=s,l[h++]=i,l[h++]=c,l[h++]=r,l[h++]=n,l[h++]=c,l[h++]=a,l[h++]=o,l[h++]=c,this._vertexPtr=h,defaultTexCoordsQuad.writeToTypedArray(this._texcoordData,this._texPtr),this._texPtr+=8}Quad3(e,t){this._ExtendQuadBatch(),this._WriteQuadToVertexBuffer(e),t.writeAsQuadToTypedArray(this._texcoordData,this._texPtr),this._texPtr+=8}Quad4(e,t){this._ExtendQuadBatch(),this._WriteQuadToVertexBuffer(e),t.writeToTypedArray(this._texcoordData,this._texPtr),this._texPtr+=8}Quad3D(e,t,s,i,r,n,a,o,l,h,c,u,_){this._ExtendQuadBatch();let d=this._vertexData,p=this._vertexPtr,m=this._baseZ+this._currentZ;d[p++]=e,d[p++]=t,d[p++]=m+s,d[p++]=i,d[p++]=r,d[p++]=m+n,d[p++]=a,d[p++]=o,d[p++]=m+l,d[p++]=h,d[p++]=c,d[p++]=m+u,this._vertexPtr=p,_.writeAsQuadToTypedArray(this._texcoordData,this._texPtr),this._texPtr+=8}Quad3D2(e,t,s,i,r,n,a,o,l,h,c,u,_){this._ExtendQuadBatch();let d=this._vertexData,p=this._vertexPtr,m=this._baseZ+this._currentZ;d[p++]=e,d[p++]=t,d[p++]=m+s,d[p++]=i,d[p++]=r,d[p++]=m+n,d[p++]=a,d[p++]=o,d[p++]=m+l,d[p++]=h,d[p++]=c,d[p++]=m+u,this._vertexPtr=p,_.writeToTypedArray(this._texcoordData,this._texPtr),this._texPtr+=8}DrawMesh(i,r,n){const a=this._vertexData,o=this._texcoordData;if(n.length%3!=0)throw new Error("invalid index buffer length");for(let s=0,e=n.length;s<e;){const l=n[s++],h=n[s++],c=n[s++],u=3*l,_=3*h,d=3*c,p=2*l,m=2*h,g=2*c;this._ExtendQuadBatch();let e=this._vertexPtr,t=this._texPtr;a[e++]=i[0+u],a[e++]=i[1+u],a[e++]=i[2+u],a[e++]=i[0+_],a[e++]=i[1+_],a[e++]=i[2+_],a[e++]=i[0+d],a[e++]=i[1+d],a[e++]=i[2+d],a[e++]=i[0+d],a[e++]=i[1+d],a[e++]=i[2+d],o[t++]=r[0+p],o[t++]=r[1+p],o[t++]=r[0+m],o[t++]=r[1+m],o[t++]=r[0+g],o[t++]=r[1+g],o[t++]=r[0+g],o[t++]=r[1+g],this._vertexPtr=e,this._texPtr=t}}FullscreenQuad(e,t){this.SetCurrentZ(0),mat42.copy(tmpProjection,this._matP),mat42.copy(tmpModelView,this._matMV),this.SetDefaultRenderTargetProjectionState();const[s,i]=this.GetRenderTargetSize(this._currentRenderTarget),r=this.CalculateLookAtModelView2(0,0,this.GetDefaultCameraZ(i),0,0,0,i);if(this.SetModelViewMatrix(r),"crop"===e&&this._currentRenderTarget&&t){const n=this._width/2,a=this._height/2,o=t.GetWidth(),l=t.GetHeight(),h=this._currentRenderTarget.GetWidth(),c=this._currentRenderTarget.GetHeight(),u=Math.min(h,o),_=Math.min(c,l),d=Math.max(l-c,0),p=Math.max(c-l,0);tmpRect.set(-n,a-p,-n+u,a-_-p),tmpQuad.setFromRect(tmpRect),tmpRect.set(0,d,u,_+d),tmpRect.divide(o,l),this.Quad3(tmpQuad,tmpRect)}else{const m=s/2,g=i/2;this.Rect2(-m,g,m,-g)}this.SetProjectionMatrix(tmpProjection),this.SetModelViewMatrix(tmpModelView)}StartRenderingPoints(e){if(!this._lastPointTexCoords.equals(e)){this._lastPointTexCoords.copy(e);const t=this.PushBatch();t.InitSetPointTexCoords(e),this._topOfBatch=0}}FinishRenderingPoints(){}Point(e,t,s,i){this._pointPtr>=LAST_POINT&&this.EndBatch();let r=this._pointPtr,n=this._baseZ+this._currentZ;if(2===this._topOfBatch&&this._lastPointZ===n)this._batch[this._batchPtr-1]._indexCount++;else{const o=this.PushBatch();o.InitPoints(r,n),this._topOfBatch=2,this._lastPointZ=n}const a=this._pointData;a[r++]=e,a[r++]=t,a[r++]=s,a[r++]=i,this._pointPtr=r}SetProgram(e){if(this._lastProgram!==e){const t=this.PushBatch();t.InitSetProgram(e),this._lastProgram=e,this._topOfBatch=0,this._currentStateGroup=null}}GetProgram(){return this._lastProgram}SetDeviceTransformTextureFillMode(){this.SetProgram(this._spDeviceTransformTextureFill)}SetGradientColor(e){const t=this.PushBatch();t.InitSetGradientColor(e),this._topOfBatch=0}SetEllipseParams(e,t,s=1){const i=this.PushBatch();i.InitSetEllipseParams(e,t,s),this._topOfBatch=0}SetTilemapInfo(e,t,s,i,r,n,a){if(this._lastProgram!==this._spTilemapFill)throw new Error("must set tilemap fill mode first");const o=this.PushBatch();o.InitSetTilemapInfo(e,t,s,i,r,n,a),this._topOfBatch=0}SetTileRandomizationInfo(e,t,s,i,r,n,a){if(this._lastProgram!==this._spTileRandomization)throw new Error("must set tile randomization mode first");const o=this.PushBatch();o.InitSetTileRandomizationInfo(e,t,s,i,r,n,a),this._topOfBatch=0}SetProgramParameters(e,t,s,i,r,n,a,o,l,h,c){const u=this._lastProgram;if(c%=10800,u._hasAnyOptionalUniforms&&!u.AreOptionalUniformsAlreadySetInBatch(t,s,i,r,n,a,o,l,h,c)){const _=this.PushBatch(),d=(_.InitSetProgramParameters(),u.SetOptionalUniformsInBatch(t,s,i,r,n,a,o,l,h,c),_._mat4param),p=(d[0]=n,d[1]=a,t.writeToTypedArray(d,2),d[6]=l,d[7]=h,s.writeToTypedArray(d,12),_._colorParam),m=(r.writeToTypedArray(p,0),p[1]);p[1]=p[3],p[3]=m,i.writeToTypedArray(_._srcOriginRect,0),_._startIndex=c,_._indexCount=o,u._uSamplerBack.IsUsed()?_._texParam=e?e.GetTexture():null:_._texParam=null,this._topOfBatch=0}}SetProgramCustomParameters(e){const t=this._lastProgram;if(0!==e.length&&!t.AreCustomParametersAlreadySetInBatch(e)){const s=this.PushBatch();s.InitSetProgramCustomParameters(),t.SetCustomParametersInBatch(e),C33.shallowAssignArray(s._shaderParams,e),this._topOfBatch=0}}ClearRgba(e,t,s,i){const r=this.PushBatch();r.InitClearSurface2(e,t,s,i),this._topOfBatch=0}Clear(e){const t=this.PushBatch();t.InitClearSurface(e),this._topOfBatch=0}Start(){}Finish(){super.Finish(),this._gl.flush()}ClearDepth(){if(this._usesDepthBuffer&&this._currentRenderTarget&&this._currentRenderTarget.HasDepthBuffer()){const e=this.PushBatch();e.InitClearDepth(this._isDepthEnabled),this._topOfBatch=0}}SetDepthEnabled(e){if(this._isDepthEnabled!==(e=!!e)&&this._usesDepthBuffer){this._isDepthEnabled=e;const t=this.PushBatch();t.InitSetDepthEnabled(e),this._topOfBatch=0}}IsDepthEnabled(){return this._isDepthEnabled}_GetDepthBuffer(){return this._depthBuffer}_CanSampleDepth(){return this._canSampleDepth}SetDepthSamplingEnabled(e){if(e=!!e,this._canSampleDepth&&this._isDepthSamplingEnabled!==e){if(e&&this.IsDepthEnabled())throw new Error("depth still enabled");this._isDepthSamplingEnabled=e;const t=this.PushBatch();t.InitSetDepthSamplingEnabled(e),this._topOfBatch=0}}SetScissorRect(e,t,s,i,r=0){if(e=Math.floor(e),t=Math.floor(t),s=Math.floor(s),i=Math.floor(i),!this._lastScissorRect.equalsWH(e,t,s,i)){this._lastScissorRect.setWH(e,t,s,i);const n=r||this.GetRenderTargetSize(this.GetRenderTarget())[1],a=(t=n-t-i,this.PushBatch());a.InitSetScissor(!0,e,t,s,i),this._topOfBatch=0}}RemoveScissorRect(){if(-1!==this._lastScissorRect.getRight()){this._lastScissorRect.set(0,0,-1,-1);const e=this.PushBatch();e.InitSetScissor(!1,0,0,0,0),this._topOfBatch=0}}CheckForQueryResults(){for(const e of this._allQueryResultBuffers)e.CheckForResults(this._frameNumber)}IsContextLost(){return!this._gl||this._gl.isContextLost()||this._isInitialisingAfterContextRestored}OnContextLost(){super.OnDeviceOrContextLost(),C33.Gfx.WebGLRendererTexture.OnContextLost(),C33.Gfx.WebGLRenderTarget.OnContextLost(),C33.Gfx.RendererText.OnContextLost();for(const e of this._allQueryResultBuffers)e.Clear();this._extensions=[],this._timerExt=null,this._parallelShaderCompileExt=null,this._anisotropicExt=null,this._depthTextureExt=null,this._fragDepthExt=null,this._stdDerivativesExt=null,this._textureLodExt=null,this._maxAnisotropy=0,this._unmaskedVendor="(unavailable)",this._unmaskedRenderer="(unavailable)",this._lastProgram=null,this._spDeviceTransformTextureFill=null,this._depthBuffer=null;for(const t of this._stateGroups.values())t.OnContextLost()}async OnContextRestored(){this._isInitialisingAfterContextRestored=!0,await this.InitState(),this._isInitialisingAfterContextRestored=!1;for(const e of this._stateGroups.values())e.OnContextRestored(this);this.SetSize(this._width,this._height,!0)}CreateStaticTexture(e,t){if(this.IsContextLost())throw new Error("context lost");this.EndBatch();const s=C33.New(C33.Gfx.WebGLRendererTexture,this);return s._CreateStatic(e,t),s}async CreateStaticTextureAsync(i,r){if(this.IsContextLost())throw new Error("context lost");if(r=Object.assign({},r),C33.Supports.ImageBitmapOptions){let e=await createImageBitmap(i,{premultiplyAlpha:"premultiply"}),t=r.wrapX&&"clamp-to-edge"!==r.wrapX||r.wrapY&&"clamp-to-edge"!==r.wrapY,s=C33.isPOT(e.width)&&C33.isPOT(e.height);return this.SupportsNPOTTextures()||s||!t?r.premultiplyAlpha=!1:C33.Supports.ImageBitmapOptionsResize?(e=await createImageBitmap(i,{premultiplyAlpha:"premultiply",resizeWidth:C33.nextHighestPowerOfTwo(e.width),resizeHeight:C33.nextHighestPowerOfTwo(e.height)}),r.premultiplyAlpha=!1):e=await createImageBitmap(i,{premultiplyAlpha:"none"}),C33.Asyncify(()=>this.CreateStaticTexture(e,r))}if(i instanceof Blob){if("undefined"==typeof Image)throw new Error("texture upload variant not supported in worker");const e=await C33.BlobToImage(i);i=e}return C33.Asyncify(()=>this.CreateStaticTexture(i,r))}CreateDynamicTexture(e,t,s){this.EndBatch();const i=C33.New(C33.Gfx.WebGLRendererTexture,this);return i._CreateDynamic(e,t,s),i}UpdateTexture(e,t,s){this.EndBatch(),t._Update(e,s)}DeleteTexture(e){e&&(e.SubtractReference(),0<e.GetReferenceCount()||(this.EndBatch(),e===this._lastTexture0&&(this._gl.bindTexture(this._gl.TEXTURE_2D,null),this._lastTexture0=null),e===this._lastTexture1&&(this._gl.activeTexture(this._gl.TEXTURE1),this._gl.bindTexture(this._gl.TEXTURE_2D,null),this._gl.activeTexture(this._gl.TEXTURE0),this._lastTexture1=null),e._Delete()))}CreateRenderTarget(e){let t=this._width,s=this._height,i=!0;if(e&&("number"==typeof e.width&&(t=Math.floor(e.width),i=!1),"number"==typeof e.height)&&(s=Math.floor(e.height),i=!1),t<=0||s<=0)throw new Error("invalid size");this.EndBatch();const r=C33.New(C33.Gfx.WebGLRenderTarget,this);return r._Create(t,s,Object.assign({isDefaultSize:i},e)),this._currentRenderTarget=null,this._batchState.currentFramebuffer=null,this._batchState.currentFramebufferNoDepth=null,r}SetRenderTarget(e,t=!0){if(e!==this._currentRenderTarget){e&&e.IsDefaultSize()&&e._Resize(this._width,this._height);const s=this.PushBatch();s.InitSetRenderTarget(e),this._currentRenderTarget=e,this._topOfBatch=0,t&&this.SetDefaultRenderTargetProjectionState()}}GetRenderTarget(){return this._currentRenderTarget}GetRenderTargetSize(e){return e?[e.GetWidth(),e.GetHeight()]:[this._width,this._height]}CopyRenderTarget(e,t="stretch"){if(this._version<2||this._currentRenderTarget&&0<this._currentRenderTarget.GetMultisampling())this.SetCopyBlend(),this.ResetColor(),this.DrawRenderTarget(e,t);else{const s=this.PushBatch();s.InitBlitFramebuffer(e,this._currentRenderTarget,t),this._topOfBatch=0}}DrawRenderTarget(e,t="stretch"){const s=e.GetTexture();if(!s)throw new Error("not a texture-backed render target");this.SetTexture(s),this.FullscreenQuad(t,s)}InvalidateRenderTarget(e){if(!(this._version<2)){const t=this.PushBatch();t.InitInvalidateFramebuffer(e._GetFramebuffer()),this._topOfBatch=0}}DeleteRenderTarget(e){this.SetRenderTarget(null),this.EndBatch();const t=e.GetTexture();t===this._lastTexture0&&(this._gl.bindTexture(this._gl.TEXTURE_2D,null),this._lastTexture0=null),t===this._lastTexture1&&(this._gl.activeTexture(this._gl.TEXTURE1),this._gl.bindTexture(this._gl.TEXTURE_2D,null),this._gl.activeTexture(this._gl.TEXTURE0),this._lastTexture1=null),e._Delete()}async ReadBackRenderTargetToImageData(e,t,s){this.EndBatch();let i=this._currentRenderTarget,r,n,a,o=(a=e?(r=e.GetWidth(),n=e.GetHeight(),e._GetFramebuffer()):(r=this.GetWidth(),n=this.GetHeight(),null),0),l=0,h=r,c=n;if(s){o=C33.clamp(Math.floor(s.getLeft()),0,r-1),l=C33.clamp(Math.floor(s.getTop()),0,n-1);let e=s.width(),t=(e=0===e?r-o:C33.clamp(Math.floor(e),0,r-o),s.height());t=0===t?n-l:C33.clamp(Math.floor(t),0,n-l),h=e,c=t,l=n-(l+c)}let u=this._gl,_=(u.bindFramebuffer(u.FRAMEBUFFER,a),()=>{u.bindFramebuffer(u.FRAMEBUFFER,null),this._currentRenderTarget=null,this._batchState.currentFramebuffer=null,this._batchState.currentFramebufferNoDepth=null,this.SetRenderTarget(i)}),d;if(!t&&2<=this.GetWebGLVersionNumber()){u.bindFramebuffer(u.READ_FRAMEBUFFER,a);const p=u.createBuffer(),m=h*c*4,g=u.PIXEL_PACK_BUFFER,f=(u.bindBuffer(g,p),u.bufferData(g,m,u.STREAM_READ),u.readPixels(o,l,h,c,u.RGBA,u.UNSIGNED_BYTE,0),u.bindFramebuffer(u.READ_FRAMEBUFFER,null),u.bindBuffer(g,null),_(),u.fenceSync(u.SYNC_GPU_COMMANDS_COMPLETE,0));await this._WaitForObjectReady(()=>u.getSyncParameter(f,u.SYNC_STATUS)===u.SIGNALED),u.deleteSync(f),d=new ImageData(h,c),u.bindBuffer(g,p),u.getBufferSubData(g,0,new Uint8Array(d.data.buffer),0,m),u.bindBuffer(g,null),u.deleteBuffer(p)}else d=new ImageData(h,c),u.readPixels(o,l,h,c,u.RGBA,u.UNSIGNED_BYTE,new Uint8Array(d.data.buffer)),_();return d}CoplanarStartStencilPass(){this.SetDepthEnabled(!0);const e=this.PushBatch();e.InitCoplanarStartStencilPass(),this._topOfBatch=0,this._coplanarMode=1}CoplanarStartColorPass(){this.SetDepthEnabled(!1);const e=this.PushBatch();e.InitCoplanarStartColorPass(),this._topOfBatch=0,this._coplanarMode=2}IsCoplanarColorPass(){return 2===this._coplanarMode}CoplanarRestoreStandardRendering(){this.SetDepthEnabled(!0);const e=this.PushBatch();e.InitCoplanarRestore(),this._topOfBatch=0,this._coplanarMode=0}StartQuery(e){if(this.SupportsGPUProfiling()){const t=this.PushBatch();t.InitStartQuery(e),this._topOfBatch=0}}EndQuery(e){if(this.SupportsGPUProfiling()){const t=this.PushBatch();t.InitEndQuery(e),this._topOfBatch=0}}_WaitForObjectReady(t){const e=new Promise(e=>pendingPolls.add({resolve:e,checkFunc:t}));return-1===pollRafId&&(pollRafId=self.requestAnimationFrame(CheckPendingPolls2)),e}GetEstimatedBackBufferMemoryUsage(){return this._width*this._height*(this._attribs.alpha?4:3)}GetEstimatedRenderBufferMemoryUsage(){let e=0;for(const t of C33.Gfx.WebGLRenderTarget.allRenderTargets())t.GetTexture()||(e+=t.GetEstimatedMemoryUsage());return e}GetEstimatedTextureMemoryUsage(){let e=0;for(const t of C33.Gfx.WebGLRendererTexture.allTextures())e+=t.GetEstimatedMemoryUsage();return e}GetWebGLVersionString(){return this._versionString}GetWebGLVersionNumber(){return this._version}GetDisplayName(){return"webgl"+this.GetWebGLVersionNumber()}SupportsNPOTTextures(){return 2<=this.GetWebGLVersionNumber()}GetMaxTextureSize(){return this._maxTextureSize}GetMinPointSize(){return this._minPointSize}GetMaxPointSize(){return this._maxPointSize}SupportsHighP(){return 0!==this._highpPrecision}GetHighPPrecision(){return this._highpPrecision}GetUnmaskedVendor(){return this._unmaskedVendor}GetUnmaskedRenderer(){return this._unmaskedRenderer}GetWebGLExtensionsAnalyticsString(){if(2<=this.GetWebGLVersionNumber())return"webgl2";{const e=[];return this._fragDepthExt&&e.push("EXT_frag_depth"),this._stdDerivativesExt&&e.push("OES_standard_derivatives"),this._textureLodExt&&e.push("EXT_shader_texture_lod"),0<e.length?"webgl1:"+e.join(","):"webgl1:none"}}GetExtensions(){return this._extensions}SupportsGPUProfiling(){return!!this._timerExt}_GetDisjointTimerQueryExtension(){return this._timerExt}_GetParallelShaderCompileExtension(){return this._parallelShaderCompileExt}_GetAnisotropicExtension(){return this._anisotropicExt}_GetMaxAnisotropy(){return this._maxAnisotropy}_AddQueryResultBuffer(e){this._allQueryResultBuffers.add(e)}_RemoveQueryResultBuffer(e){this._allQueryResultBuffers.delete(e)}_GetTimeQueryStack(){return this._timeQueryStack}GetContext(){return this._gl}_InitBlendModes(e){this._InitBlendModeData([["normal",e.ONE,e.ONE_MINUS_SRC_ALPHA],["additive",e.ONE,e.ONE],["xor",e.ONE,e.ONE_MINUS_SRC_ALPHA],["copy",e.ONE,e.ZERO],["destination-over",e.ONE_MINUS_DST_ALPHA,e.ONE],["source-in",e.DST_ALPHA,e.ZERO],["destination-in",e.ZERO,e.SRC_ALPHA],["source-out",e.ONE_MINUS_DST_ALPHA,e.ZERO],["destination-out",e.ZERO,e.ONE_MINUS_SRC_ALPHA],["source-atop",e.DST_ALPHA,e.ONE_MINUS_SRC_ALPHA],["destination-atop",e.ONE_MINUS_DST_ALPHA,e.SRC_ALPHA]])}CreateWebGLText(){return this.CreateRendererText()}}}{const C33=self.C3,DEFAULT_CTOR_OPTS={getDrawSize:null,getRenderTarget:null,releaseRenderTarget:null,getTime:null,redraw:null};C33.Gfx.EffectChainManager=class{constructor(e){e=Object.assign({},DEFAULT_CTOR_OPTS,e),this._cbGetDrawSize=e.getDrawSize,this._cbGetRenderTarget=e.getRenderTarget,this._cbReleaseRenderTarget=e.releaseRenderTarget,this._cbGetTime=e.getTime,this._cbRedraw=e.redraw,this._webgpuBackTexture=null,this._allEffectChains=new Set}_AddEffectChain(e){this._allEffectChains.add(e)}_RemoveEffectChain(e){this._allEffectChains.delete(e)}OnContextLost(){this._webgpuBackTexture=null;for(const e of this._allEffectChains)e.OnContextLost()}GetDrawSize(e){return this._cbGetDrawSize?this._cbGetDrawSize(e):[e.GetWidth(),e.GetHeight()]}GetRenderTarget(e){return this._cbGetRenderTarget(e)}ReleaseRenderTarget(e,t){this._cbReleaseRenderTarget(e,t)}GetTime(){return this._cbGetTime()}Redraw(e){this._cbRedraw(e)}_GetWebGPUBackTexture(e,t,s){return t=Math.floor(t),s=Math.floor(s),!this._webgpuBackTexture||this._webgpuBackTexture.GetWidth()===t&&this._webgpuBackTexture.GetHeight()===s||(e.DeleteTexture(this._webgpuBackTexture),this._webgpuBackTexture=null),null===this._webgpuBackTexture&&(this._webgpuBackTexture=e.CreateStaticTexture(null,{width:t,height:s,sampling:"nearest",mipMap:!1})),this._webgpuBackTexture}}}{const C33=self.C3,assert=self.assert,glMatrix=self.glMatrix,mat42=glMatrix.mat4,tempRect=C33.New(C33.Rect),tempRect2=C33.New(C33.Rect),tempRect3=C33.New(C33.Rect),tempRect4=C33.New(C33.Rect),tempMat4a=mat42.create(),tempMat4b=mat42.create(),DEFAULT_CTOR_OPTS={drawContent:null,getSourceTextureInfo:null,getShaderParameters:null,invalidateRenderTargets:!1},DEFAULT_BUILDSTEPS_OPTS={indexMap:null,forcePreDraw:!1,forcePostDraw:!1,is3D:!1,isSourceTextureRotated:!1,isRotatedOrNegativeSizeInstance:!1,useFullSurface:!1};C33.Gfx.EffectChain=class{constructor(e,t){t=Object.assign({},DEFAULT_CTOR_OPTS,t),this._manager=e,this._cbDrawContent=t.drawContent,this._cbGetSourceTextureInfo=t.getSourceTextureInfo,this._cbGetShaderParameters=t.getShaderParameters,this._cbDrawContentHook=null,this._shaderProgramList=[],this._shaderProgramIndices=[],this._steps=[],this._needsRebuild=!1,this._blendMode=0,this._isAnyShaderAnimated=!1,this._isAnyShaderDepthSampling=!1,this._isAnyShaderBackgroundBlending=!1,this._isAnyShaderCrossSampling=!1,this._isAnyIsSrcTexRotated=!1,this._useCopyTextureBackgroundSampling=!1,this._didChangeTransform=!1,this._depthEnabledAtStart=!1,this._coplanarColorPassAtStart=!1,this._canUseFastPath=!1,this._useFullSurface=!1,this._isSourceTextureRotated=!1,this._numTempSurfacesRequired=0,this._renderTargets=[null,null,null],this._invalidateRenderTargets=!!t.invalidateRenderTargets,this._boxExtendHorizontal=0,this._boxExtendVertical=0,this._drawWidth=0,this._drawHeight=0,this._contentObject=null,this._contextObject=null,this._layoutRect=C33.New(C33.Rect),this._drawSurfaceRect=C33.New(C33.Rect),this._rcTexOriginal=C33.New(C33.Rect),this._rcTexBounce=C33.New(C33.Rect),this._rcTexDest=C33.New(C33.Rect),this._devicePixelRatio=1,this._layerScale=1,this._layerAngle=0,this._time=0,this._destRenderTarget=null,this._backTex=null,this._compositOffX=0,this._compositOffY=0,this._updateOwnProjection=!1,this._projectionMatrix=mat42.create(),this._modelViewMatrix=mat42.create(),this._manager._AddEffectChain(this)}Release(){this._manager._RemoveEffectChain(this),C33.clearArray(this._steps),C33.clearArray(this._shaderProgramList),C33.clearArray(this._shaderProgramIndices),this._contentObject=null,this._contextObject=null,this._cbDrawContent=null,this._cbGetSourceTextureInfo=null,this._cbGetShaderParameters=null}OnContextLost(){this._needsRebuild=!0,C33.clearArray(this._steps),C33.clearArray(this._shaderProgramList),C33.clearArray(this._shaderProgramIndices)}NeedsRebuild(){return this._needsRebuild}BuildSteps(r,e){if(e=Object.assign({},DEFAULT_BUILDSTEPS_OPTS,e),C33.clearArray(this._steps),this._boxExtendHorizontal=0,this._boxExtendVertical=0,this._isAnyShaderAnimated=!1,this._isAnyShaderDepthSampling=!1,this._isAnyShaderBackgroundBlending=!1,this._isAnyShaderCrossSampling=!1,this._isAnyIsSrcTexRotated=!1,this._useCopyTextureBackgroundSampling=!1,this._numTempSurfacesRequired=0,this._isSourceTextureRotated=!!e.isSourceTextureRotated,this._useFullSurface=!!e.useFullSurface,this._needsRebuild=!1,C33.shallowAssignArray(this._shaderProgramList,r),0!==r.length){if(e.indexMap){if(e.indexMap.length!==r.length)throw new Error("incorrect indexMap length");C33.shallowAssignArray(this._shaderProgramIndices,e.indexMap)}else{C33.clearArray(this._shaderProgramIndices);for(let e=0,t=r.length;e<t;++e)this._shaderProgramIndices.push(e)}for(const t of r)this._boxExtendHorizontal+=t.GetBoxExtendHorizontal(),this._boxExtendVertical+=t.GetBoxExtendVertical(),t.IsAnimated()&&(this._isAnyShaderAnimated=!0),t.UsesDepth()&&(this._isAnyShaderDepthSampling=!0),t.BlendsBackground()&&(this._isAnyShaderBackgroundBlending=!0),t.UsesCrossSampling()&&(this._isAnyShaderCrossSampling=!0),t.UsesIsSrcTexRotated()&&(this._isAnyIsSrcTexRotated=!0);this._useCopyTextureBackgroundSampling=this._ShouldUseCopyTextureBackgroundSampling(r[0].GetRenderer());const n=this._ShouldPreDraw(r[0],e),a=this._ShouldPostDraw(r.at(-1),e);if(1!==r.length||n||a){this._canUseFastPath=!1;let i=0;n&&(this._numTempSurfacesRequired=1,this._steps.push(C33.New(C33.Gfx.EffectChain.Step.PreDraw,this,-1,1)),i=1);for(let t=0,s=r.length;t<s;++t)if(0!==t||n){let e=1===i?2:1;t!==s-1||a||(e=0),this._numTempSurfacesRequired=Math.max(this._numTempSurfacesRequired,e),this._steps.push(C33.New(C33.Gfx.EffectChain.Step.Bounce,this,i,e,t)),i=e}else this._numTempSurfacesRequired=1,this._steps.push(C33.New(C33.Gfx.EffectChain.Step.FirstBounce,this,-1,1,t)),i=1;a&&this._steps.push(C33.New(C33.Gfx.EffectChain.Step.PostDraw,this,i,0))}else this._canUseFastPath=!0}}_ShouldPreDraw(e,t){return!!(t.forcePreDraw||e.MustPreDraw()||t.is3D&&!e.Supports3DDirectRendering()||e.UsesDepth()&&!this._useFullSurface||0!==this._boxExtendHorizontal||0!==this._boxExtendVertical)||(e.GetRenderer().IsWebGL()?e.BlendsBackground()&&(t.isRotatedOrNegativeSizeInstance||t.isSourceTextureRotated)||e.UsesAnySrcRectOrPixelSize()&&t.isSourceTextureRotated:e.BlendsBackground()&&!this._useCopyTextureBackgroundSampling&&t.isRotatedOrNegativeSizeInstance)}_ShouldPostDraw(e,t){return!!t.forcePostDraw||(e.GetRenderer().IsWebGL()?e.BlendsBackground()||e.UsesCrossSampling():(e.BlendsBackground()||e.UsesCrossSampling())&&this._UseRenderTargetBackgroundSampling())}_ShouldUseCopyTextureBackgroundSampling(e){return e.IsWebGPU()&&this._isAnyShaderBackgroundBlending&&!this._isAnyShaderCrossSampling}Render(e,t,s){e.IsWebGPU()&&null===t&&(t=e.GetBackbufferRenderTarget()),this._destRenderTarget=t,this._contentObject=s.contentObject||null,this._contextObject=s.contextObject||null,this._blendMode=s.blendMode||0,this._devicePixelRatio=s.devicePixelRatio||1,this._layerScale=s.layerScale||1,this._layerAngle=s.layerAngle||0,this._time="number"==typeof s.time?s.time:this._manager.GetTime(),this._didChangeTransform=!1,e.ResetDidChangeTransformFlag(),this._isAnyShaderAnimated&&this._Redraw();let i=!1;if(this._UseCopyTextureBackgroundSampling()&&(this._CalculateDrawSizeAndRectangles(e,s),i=!0,this._backTex=this._manager._GetWebGPUBackTexture(e,this._drawWidth,this._drawHeight),tempRect.copy(this._drawSurfaceRect),tempRect.roundOuter(),e.IsWebGPU()&&e._MaybeDoPendingClearRenderPass(this._destRenderTarget),e.CopyTextureToTexture(this._destRenderTarget.GetTexture(),this._backTex,tempRect.getLeft(),tempRect.getTop(),tempRect.width(),tempRect.height())),this._canUseFastPath)this._Render_FastPath(e,s);else if(i||this._CalculateDrawSizeAndRectangles(e,s),0!==this._rcTexOriginal.width()||0!==this._rcTexOriginal.height()){e.SetAlphaBlend(),e.ResetColor(),e.SetBaseZ(0),e.SetCurrentZ(0),this._cbDrawContentHook=s.drawContentHook||null,this._compositOffX=s.compositOffX||0,this._compositOffY=s.compositOffY||0,this._updateOwnProjection=!!s.updateOwnProjection,this._OnBeforeStartEffectChain(e),this._renderTargets[0]=t,this._renderTargets[1]=1<=this._numTempSurfacesRequired?this._GetRenderTarget():null,this._renderTargets[2]=2===this._numTempSurfacesRequired?this._GetRenderTarget():null;for(const r of this._steps){const n=this._GetRenderTargetForId(r.GetSrcTargetId()),a=this._GetRenderTargetForId(r.GetDestTargetId());e.IsWebGPU()?r.Run_WebGPU(e,n,a):r.Run_WebGL(e,n,a)}e.SetTexture(null),this._renderTargets[1]&&this._ReleaseRenderTarget(this._renderTargets[1]),this._renderTargets[2]&&this._ReleaseRenderTarget(this._renderTargets[2]),this._renderTargets.fill(null),this._OnAfterEndEffectChain(e),this._destRenderTarget=null,this._backTex=null,this._contentObject=null,this._contextObject=null,this._cbDrawContentHook=null}}_CalculateDrawSizeAndRectangles(e,t){const[s,i]=this._manager.GetDrawSize(e);this._SetDrawSize(e,s,i),this._CalculateRectangles(t)}_SetDrawSize(e,t,s){if(t<=0||s<=0)throw new Error("invalid draw size");this._drawWidth===t&&this._drawHeight===s||this._CalculateDeviceTransformMatrices(e,t,s,0,0,this._projectionMatrix,this._modelViewMatrix),this._drawWidth=t,this._drawHeight=s}_CalculateDeviceTransformMatrices(e,t,s,i,r,n,a){const o=t/2+i,l=s/2+r,h=(e.CalculatePerspectiveMatrix(n,t/s),e.CalculateLookAtModelView2(o,l,e.GetDefaultCameraZ(s),o,l,0,s));mat42.copy(a,h)}_CalculateRectangles(e){this._layoutRect.copy(e.layoutRect),e.drawSurfaceRect?this._drawSurfaceRect.copy(e.drawSurfaceRect):this._drawSurfaceRect.set(0,0,this._drawWidth,this._drawHeight),this._rcTexOriginal.copy(this._drawSurfaceRect),this._rcTexOriginal.divide(this._drawWidth,this._drawHeight);const t=this._layerScale*this._devicePixelRatio;this._drawSurfaceRect.inflate(this._boxExtendHorizontal*t,this._boxExtendVertical*t),this._rcTexDest.copy(this._drawSurfaceRect),this._rcTexDest.divide(this._drawWidth,this._drawHeight),this._drawSurfaceRect.clampBoth(0,0,this._drawWidth,this._drawHeight),this._rcTexBounce.copy(this._drawSurfaceRect),this._rcTexBounce.divide(this._drawWidth,this._drawHeight)}_OnBeforeStartEffectChain(e){if(this._depthEnabledAtStart=e.IsDepthEnabled(),this._coplanarColorPassAtStart=e.IsCoplanarColorPass(),this._useFullSurface)e.SetDepthEnabled(!1),this._isAnyShaderDepthSampling&&e.SetDepthSamplingEnabled(!0);else{if(tempRect.copy(this._drawSurfaceRect),e.IsWebGL()){const t=this._layerScale*this._devicePixelRatio;tempRect.inflate(Math.max(this._boxExtendHorizontal,1)*t,Math.max(this._boxExtendVertical,1)*t),tempRect.roundOuter(),tempRect.clamp(0,0,this._drawWidth,this._drawHeight)}else tempRect.roundOuter();e.SetScissorRect(tempRect.getLeft(),tempRect.getTop(),tempRect.width(),tempRect.height(),this._drawHeight)}}_OnAfterEffectChainDrawContent(e){e.ResetColor(),this._useFullSurface||(this._coplanarColorPassAtStart&&e.CoplanarRestoreStandardRendering(),e.SetDepthEnabled(!1),this._isAnyShaderDepthSampling&&e.SetDepthSamplingEnabled(!0)),e.IsWebGPU()&&e.SetNormalizedCoordsProgramVariant(!0)}_OnAfterEndEffectChain(e){e.SetDepthSamplingEnabled(!1),this._coplanarColorPassAtStart&&e.CoplanarStartColorPass(),e.SetDepthEnabled(this._depthEnabledAtStart),this._useFullSurface||e.RemoveScissorRect(),e.IsWebGPU()&&e.SetNormalizedCoordsProgramVariant(!1),this._didChangeTransform=e.DidChangeTransform()}_ClampRcTexDest(){this._rcTexDest.clamp(0,0,1,1)}_GetRenderTargetForId(e){return e<0?null:this._renderTargets[e]}_GetRenderTarget(){return this._manager.GetRenderTarget(this)}_GetDestRenderTarget(){return this._destRenderTarget}_ReleaseRenderTarget(e){this._manager.ReleaseRenderTarget(e,this)}_GetShaderProgramAt(e){return this._shaderProgramList[e]}_DrawContent(e){this._cbDrawContentHook?this._cbDrawContentHook(this,e,()=>this._cbDrawContent(e,this)):this._cbDrawContent(e,this),this._canUseFastPath||this._OnAfterEffectChainDrawContent(e)}_IsRenderTargetSameSizeAndOffset(e){if(this._useFullSurface)return!0;if(0!==this._compositOffX||0!==this._compositOffY)return!1;const[t,s]=e.GetRenderTargetSize(e.GetRenderTarget());return t===this._drawWidth&&s===this._drawHeight}_SetDeviceTransform(e,t){let s=this._projectionMatrix,i=this._modelViewMatrix;if(t&&!this._IsRenderTargetSameSizeAndOffset(e)){s=tempMat4a,i=tempMat4b;const[r,n]=e.GetRenderTargetSize(e.GetRenderTarget());this._CalculateDeviceTransformMatrices(e,r,n,this._compositOffX,this._compositOffY,s,i),this._useFullSurface||e.RemoveScissorRect()}e.SetProjectionMatrix(s),e.SetModelViewMatrix(i)}_Redraw(){this._manager.Redraw(this)}_GetShaderParameters(e,t){return this._cbGetShaderParameters(this._shaderProgramIndices[e],t)}_SetProgramParameters(e,t){let s=this._rcTexDest,i=this._rcTexBounce,r=this._rcTexOriginal;e.IsWebGL()&&(tempRect2.copy(s),tempRect2.flipAround(1),s=tempRect2,tempRect3.copy(i),tempRect3.flipAround(1),i=tempRect3,tempRect4.copy(r),tempRect4.flipAround(1),r=tempRect4),this._DoSetProgramParameters(e,t,i,r,s,1/this._drawWidth,1/this._drawHeight)}_SetFirstBounceProgramParameters(e,t){let i=this._rcTexBounce,r=this._rcTexOriginal,n=1/this._drawWidth,a=1/this._drawHeight;if(this._cbGetSourceTextureInfo){let{srcTexRect:e,srcWidth:t,srcHeight:s}=this._cbGetSourceTextureInfo(this._contentObject);e||(tempRect.set(0,0,0,0),e=tempRect),t=t||this._drawWidth,s=s||this._drawHeight,i=e,r=e,n=1/t,a=1/s}else e.IsWebGL()&&(tempRect3.copy(i),tempRect3.flipAround(1),i=tempRect3,tempRect4.copy(r),tempRect4.flipAround(1),r=tempRect4);let s=this._rcTexDest;e.IsWebGL()&&((s=tempRect2).copy(this._rcTexDest),s.flipAround(1)),this._DoSetProgramParameters(e,t,i,r,s,n,a),e.IsWebGPU()&&this._isAnyIsSrcTexRotated&&e.SetProgramParameter_IsSrcTexRotated(this._isSourceTextureRotated)}_GetBackTex(e){return this._isAnyShaderBackgroundBlending?e.IsWebGPU()?this._UseCopyTextureBackgroundSampling()?this._backTex:this._destRenderTarget.GetTexture():this._destRenderTarget:null}_DoSetProgramParameters(e,t,s,i,r,n,a){e.SetProgramParameters(this._GetBackTex(e),r,s,i,this._layoutRect,n,a,this._devicePixelRatio,this._layerScale,this._layerAngle,this._time),e.SetProgramCustomParameters(this._GetShaderParameters(t,e))}_Render_FastPath(e,t){const s=this._shaderProgramList[0],i=e.IsDepthEnabled(),r=s.UsesDepth();r&&(e.SetDepthEnabled(!1),e.SetDepthSamplingEnabled(!0),this._rcTexDest.set(0,0,1,1),this._rcTexOriginal.set(0,0,1,1)),e.SetProgram(s),e.SetBlendMode(this._blendMode),e.SetRenderTarget(this._destRenderTarget);let n=0,a=1;if(this._rcTexOriginal.set(0,0,1,1),s.UsesAnySrcRectOrPixelSize()&&this._cbGetSourceTextureInfo){const{srcTexRect:o,srcWidth:l,srcHeight:h}=this._cbGetSourceTextureInfo(this._contentObject);o&&this._rcTexOriginal.copy(o),n=Number.isFinite(l)?1/l:0,a=Number.isFinite(h)?1/h:0}else{const[c,u]=this._manager.GetDrawSize(e);n=1/c,a=1/u}t.layoutRect?this._layoutRect.copy(t.layoutRect):this._layoutRect.set(0,0,0,0),e.SetProgramParameters(this._GetBackTex(e),this._rcTexDest,this._rcTexOriginal,this._rcTexOriginal,this._layoutRect,n,a,this._devicePixelRatio,this._layerScale,this._layerAngle,this._time),e.SetProgramCustomParameters(this._GetShaderParameters(0,e)),e.IsWebGPU()&&this._isAnyIsSrcTexRotated&&e.SetProgramParameter_IsSrcTexRotated(this._isSourceTextureRotated),e.SetBaseZ(0),this._DrawContent(e),r&&(e.SetDepthSamplingEnabled(!1),e.SetDepthEnabled(i))}_UseCopyTextureBackgroundSampling(){return this._useCopyTextureBackgroundSampling}_UseRenderTargetBackgroundSampling(){return!this._useCopyTextureBackgroundSampling}IsAnyShaderBackgroundBlending(){return this._isAnyShaderBackgroundBlending}CanSkipCalculatingDrawSurfaceRect(){return!!this._canUseFastPath&&!this._UseCopyTextureBackgroundSampling()}UseFullSurface(){return this._useFullSurface}GetContentObject(){return this._contentObject}GetContextObject(){return this._contextObject}_GetBlendMode(){return this._blendMode}_UpdateOwnProjection(){return this._updateOwnProjection}DidChangeTransform(){return this._didChangeTransform}_GetDrawSurfaceRect(){return this._drawSurfaceRect}_GetRcTexBounce(){return this._rcTexBounce}_ShouldInvalidateRenderTargets(){return this._invalidateRenderTargets}async DebugLogRenderTargetContents(e,t,s){}}}{const C33=self.C3;C33.Gfx.EffectChain.Step=class{constructor(e,t,s,i=-1){this._effectChain=e,this._srcTargetId=t,this._destTargetId=s,this._index=i}GetEffectChain(){return this._effectChain}GetSrcTargetId(){return this._srcTargetId}GetDestTargetId(){return this._destTargetId}GetIndex(){return this._index}GetShaderProgram(){return this.GetEffectChain()._GetShaderProgramAt(this.GetIndex())}Run_WebGL(e,t,s){}Run_WebGPU(e,t,s){}}}{const C33=self.C3;C33.Gfx.EffectChain.Step.PreDraw=class extends C33.Gfx.EffectChain.Step{constructor(e,t,s,i){super(e,t,s,i)}Run_WebGL(e,t,s){const i=this.GetEffectChain();e.SetAlphaBlend(),e.SetTextureFillMode(),e.SetRenderTarget(s,i._UpdateOwnProjection()),e.ClearRgba(0,0,0,0),i._DrawContent(e),i._ClampRcTexDest()}Run_WebGPU(e,t,s){const i=this.GetEffectChain();e.SetAlphaBlend(),e.SetTextureFillMode(),e.SetRenderTarget(s,!1),e.ClearRgba(0,0,0,0),i._DrawContent(e),i._ClampRcTexDest()}}}{const C33=self.C3,tempRect=C33.New(C33.Rect),tempQuad=C33.New(C33.Quad);C33.Gfx.EffectChain.Step.PostDraw=class extends C33.Gfx.EffectChain.Step{constructor(e,t,s,i){super(e,t,s,i)}Run_WebGL(e,t,s){const i=this.GetEffectChain();e.SetTextureFillMode(),e.SetRenderTarget(s),i._SetDeviceTransform(e,!0),e.SetBlendMode(i._GetBlendMode()),e.SetTexture(t.GetTexture()),tempQuad.setFromRect(i._GetDrawSurfaceRect()),tempRect.copy(i._GetRcTexBounce()),tempRect.flipAround(1),e.Quad3(tempQuad,tempRect),i._ShouldInvalidateRenderTargets()&&e.InvalidateRenderTarget(t)}Run_WebGPU(e,t,s){const i=this.GetEffectChain();e.SetTextureFillMode(),e.SetRenderTarget(s,!1),i._IsRenderTargetSameSizeAndOffset(e)?tempQuad.setFromRect(i._GetRcTexBounce()):(e.SetNormalizedCoordsProgramVariant(!1),i._SetDeviceTransform(e,!0),tempQuad.setFromRect(i._GetDrawSurfaceRect())),e.SetBackTexture(null),e.SetBlendMode(i._GetBlendMode()),e.SetTexture(t.GetTexture()),i.UseFullSurface()?e.FullscreenQuad():e.Quad3(tempQuad,i._GetRcTexBounce())}}}{const C33=self.C3;C33.Gfx.EffectChain.Step.FirstBounce=class extends C33.Gfx.EffectChain.Step{constructor(e,t,s,i){super(e,t,s,i)}Run_WebGL(e,t,s){const i=this.GetEffectChain();e.SetRenderTarget(s,i._UpdateOwnProjection()),e.ClearRgba(0,0,0,0),e.SetCopyBlend(),e.SetProgram(this.GetShaderProgram()),i._SetFirstBounceProgramParameters(e,this.GetIndex()),i._DrawContent(e),i._ClampRcTexDest()}Run_WebGPU(e,t,s){const i=this.GetEffectChain();e.SetRenderTarget(s,!1),e.ClearRgba(0,0,0,0),e.SetCopyBlend(),e.SetProgram(this.GetShaderProgram()),i._SetFirstBounceProgramParameters(e,this.GetIndex()),i._DrawContent(e),i._ClampRcTexDest()}}}{const C33=self.C3,tempRect=C33.New(C33.Rect),tempQuad=C33.New(C33.Quad);C33.Gfx.EffectChain.Step.Bounce=class extends C33.Gfx.EffectChain.Step{constructor(e,t,s,i){super(e,t,s,i)}Run_WebGL(e,t,s){const i=this.GetEffectChain(),r=(e.SetRenderTarget(s),0===this.GetDestTargetId());r?e.SetBlendMode(i._GetBlendMode()):(e.ClearRgba(0,0,0,0),e.SetCopyBlend()),e.SetProgram(this.GetShaderProgram()),i._SetProgramParameters(e,this.GetIndex()),e.SetTexture(t.GetTexture()),i._SetDeviceTransform(e,r),tempQuad.setFromRect(i._GetDrawSurfaceRect()),tempRect.copy(i._GetRcTexBounce()),tempRect.flipAround(1),e.Quad3(tempQuad,tempRect),i._ShouldInvalidateRenderTargets()&&e.InvalidateRenderTarget(t)}Run_WebGPU(e,t,s){const i=this.GetEffectChain(),r=(e.SetRenderTarget(s,!1),0===this.GetDestTargetId());r?(e.SetBlendMode(i._GetBlendMode()),e.SetBackTexture(null),i._IsRenderTargetSameSizeAndOffset(e)?tempQuad.setFromRect(i._GetRcTexBounce()):(e.SetNormalizedCoordsProgramVariant(!1),i._SetDeviceTransform(e,!0),tempQuad.setFromRect(i._GetDrawSurfaceRect()))):(e.ClearRgba(0,0,0,0),e.SetCopyBlend(),tempQuad.setFromRect(i._GetRcTexBounce())),e.SetProgram(this.GetShaderProgram()),i._SetProgramParameters(e,this.GetIndex()),e.SetTexture(t.GetTexture()),i.UseFullSurface()?e.FullscreenQuad():e.Quad3(tempQuad,i._GetRcTexBounce())}}}{let SortZOrderList2=function(e,t){const s=e[0],i=t[0],r=s-i;if(0!=r)return r;const n=e[1],a=t[1];return n-a},C33=(SortZOrderList=SortZOrderList2,self.C3),C3X=self.C3X,runtime=null,keysDownByKey=new Set,tempZOrderList=[],tempInstances=[],didWarnInAlertPolyfill=!1,didWarnFpsDeprecated=!1,VALID_FRAMERATE_MODES=new Set(["vsync","unlimited-tick","unlimited-frame"]);self.IRuntime=class{constructor(e){runtime=e,Object.defineProperties(this,{assets:{value:runtime.GetAssetManager().GetIAssetManager(),writable:!1},collisions:{value:runtime.GetCollisionEngine().GetICollisionEngine(),writable:!1},objects:{value:{},writable:!1},globalVars:{value:{},writable:!1},projectName:{value:runtime.GetProjectName(),writable:!1},projectVersion:{value:runtime.GetProjectVersion(),writable:!1},exportDate:{value:new Date(runtime.GetExportTimestamp()),writable:!1},storage:{value:new self.IStorage(runtime),writable:!1},isInWorker:{value:runtime.IsInWorker(),writable:!1},viewportWidth:{value:runtime.GetOriginalViewportWidth(),writable:!1},viewportHeight:{value:runtime.GetOriginalViewportHeight(),writable:!1},sampling:{value:runtime.GetSampling(),writable:!1},isPixelRoundingEnabled:{value:runtime.IsPixelRoundingEnabled(),writable:!1},platformInfo:{value:new self.IPlatformInfo(e),writable:!1},sdk:{value:new self.ISDKUtils(e),writable:!1}}),runtime.UserScriptDispatcher().addEventListener("keydown",e=>{keysDownByKey.has(e.key)?e.stopPropagation():keysDownByKey.add(e.key)}),runtime.UserScriptDispatcher().addEventListener("keyup",e=>keysDownByKey.delete(e.key)),runtime.Dispatcher().addEventListener("window-blur",()=>keysDownByKey.clear()),runtime.IsInWorker()&&(self.alert=e=>(didWarnInAlertPolyfill||(didWarnInAlertPolyfill=!0,console.warn("[Construct] alert() was called from a Web Worker, because the project 'Use worker' setting is enabled. This method is not normally available in a Web Worker. Construct has implemented the alert for you, but note that other features may be missing in worker mode. You may wish to disable 'Use worker', or use a more convenient function like console.log(). For more information please refer to the scripting section of the manual.")),this.alert(e)))}_InitObjects(e){Object.defineProperties(this.objects,e)}_InitGlobalVars(e){Object.defineProperties(this.globalVars,e)}addEventListener(e,t){runtime.UserScriptDispatcher().addEventListener(e,t)}removeEventListener(e,t){runtime.UserScriptDispatcher().removeEventListener(e,t)}callFunction(e,...t){C3X.RequireString(e);const s=runtime.GetEventSheetManager(),i=s.GetFunctionBlockByName(e);if(!i)throw new Error(`cannot find function name '${e}'`);if(!i.IsEnabled())return i.GetDefaultReturnValue();if(t.length<i.GetFunctionParameterCount())throw new Error(`not enough function parameters passed for '${e}' (${t.length} passed, ${i.GetFunctionParameterCount()} expected)`);let r=i.GetEventBlock(),n=r.GetSolModifiersIncludingParents(),a=s.GetCurrentEvent();if(a){n=n.slice(0);const l=new Set(n);for(const h of a.GetSolModifiersIncludingParents())l.has(h)||(n.push(h),l.add(h));for(const c of s.GetDynamicSolModifiersSet())l.has(c)||(n.push(c),l.add(c))}const o=r.RunAsExpressionFunctionCall(n,i.IsCopyPicked(),i.GetReturnType(),i.GetDefaultReturnValue(),...t);return o}setReturnValue(e){const t=runtime.GetEventStack().GetCurrentExpFuncStackFrame();if(!t)throw new Error("not in a function which returns a value");switch(t.GetFunctionReturnType()){case 1:"number"==typeof e&&t.SetFunctionReturnValue(e);break;case 2:"string"==typeof e&&t.SetFunctionReturnValue(e);break;case 3:"number"!=typeof e&&"string"!=typeof e||t.SetFunctionReturnValue(e)}}signal(e){C3X.RequireString(e),runtime.GetEventSheetManager().Signal(e)}waitForSignal(e){return C3X.RequireString(e),runtime.GetEventSheetManager().WaitForSignal(e)}getViewportSize(){return[runtime.GetOriginalViewportWidth(),runtime.GetOriginalViewportHeight()]}get isSuspended(){return runtime.IsSuspended()}get dt(){return runtime.GetDt()}get dtRaw(){return runtime.GetDtRaw()}get gameTime(){return runtime.GetGameTime()}get wallTime(){return runtime.GetWallTime()}get timeScale(){return runtime.GetTimeScale()}set timeScale(e){C3X.RequireFiniteNumber(e),runtime.SetTimeScale(e)}get fps(){return didWarnFpsDeprecated||(console.warn("IRuntime.fps is deprecated. Use IRuntime.framesPerSecond instead."),didWarnFpsDeprecated=!0),runtime.GetFramesPerSecond()}get framesPerSecond(){return runtime.GetFramesPerSecond()}get ticksPerSecond(){return runtime.GetTicksPerSecond()}get cpuUtilisation(){return runtime.GetMainThreadTime()}get gpuUtilisation(){return runtime.GetGPUUtilisation()}get framerateMode(){return runtime.GetFramerateMode()}set framerateMode(e){if(!VALID_FRAMERATE_MODES.has(e))throw new Error("invalid framerate mode");runtime._SetFramerateMode(e)}get minDt(){return runtime.GetMinDt()}set minDt(e){C3X.RequireFiniteNumber(e),runtime.SetMinDt(e)}get maxDt(){return runtime.GetMaxDt()}set maxDt(e){runtime.SetMaxDt(e)}get loadingProgress(){return runtime.GetAssetManager().GetLoadProgress()}get imageLoadingProgress(){return runtime.GetAssetManager().GetImageLoadProgress()}random(){return runtime.Random()}get layout(){const e=runtime.GetMainRunningLayout();if(e)return e.GetILayout();throw new Error("no layout is running - make sure a layout is loaded before accessing")}getLayout(e){let t=runtime.GetLayoutManager(),s=null;if("number"!=typeof e&&"string"!=typeof e)throw new TypeError("expected string or number");if(s=t.GetLayout(e))return s.GetILayout();throw new Error("invalid layout")}getAllLayouts(){return runtime.GetLayoutManager().GetAllLayouts().map(e=>e.GetILayout())}goToLayout(e){let t=runtime.GetLayoutManager(),s;if("number"!=typeof e&&"string"!=typeof e)throw new TypeError("expected string or number");if(!(s=t.GetLayout(e)))throw new Error("invalid layout");t.IsPendingChangeMainLayout()||t.ChangeMainLayout(s)}get keyboard(){const e=runtime._GetCommonScriptInterfaces().keyboard;if(e)return e;throw new Error("runtime.keyboard used but Keyboard object missing - add it to your project first")}get mouse(){const e=runtime._GetCommonScriptInterfaces().mouse;if(e)return e;throw new Error("runtime.mouse used but Mouse object missing - add it to your project first")}get touch(){const e=runtime._GetCommonScriptInterfaces().touch;if(e)return e;throw new Error("runtime.touch used but Touch object missing - add it to your project first")}get timelineController(){const e=runtime._GetCommonScriptInterfaces().timelineController;if(e)return e;throw new Error("runtime.timelineController used but Timeline Controller object missing - add it to your project first")}invokeDownload(e,t){C3X.RequireString(e),C3X.RequireString(t),runtime.InvokeDownload(e,t)}getInstanceByUid(e){C3X.RequireFiniteNumber(e);const t=runtime.GetInstanceByUID(e);return t?t.GetInterfaceClass():null}sortZOrder(e,i){C3X.RequireFunction(i);const r=runtime.GetCurrentLayout();for(const t of e){const s=runtime._UnwrapIWorldInstance(t),n=s.GetWorldInfo();tempZOrderList.push([n.GetLayer().GetIndex(),n.GetZIndex()]),tempInstances.push(s)}if(0!==tempZOrderList.length){tempZOrderList.sort(SortZOrderList2),tempInstances.sort((e,t)=>i(e.GetInterfaceClass(),t.GetInterfaceClass()));let s=!1;for(let e=0,t=tempZOrderList.length;e<t;++e){const a=tempInstances[e],o=r.GetLayerByIndex(tempZOrderList[e][0]),l=tempZOrderList[e][1],h=o._GetInstances();h[l]!==a&&((h[l]=a).GetWorldInfo()._SetLayer(o,!0),o.SetZIndicesChanged(a),s=!0)}s&&runtime.UpdateRender(),C33.clearArray(tempZOrderList),C33.clearArray(tempInstances)}}async createWorker(e,t){const s=new MessageChannel,i=s.port1,r=s.port2;return await runtime.PostComponentMessageToDOMAsync("runtime","script-create-worker",{url:e,opts:t,port2:r},[r]),i}alert(e){return runtime.PostComponentMessageToDOMAsync("runtime","alert",{message:e+(runtime.IsInWorker()?" [via Web Worker]":"")})}getHTMLLayer(e){return C3X.RequireFiniteNumber(e),runtime._GetHTMLLayerWrapElement(e)}addLoadPromise(e){runtime.AddLoadPromise(e)}}}{let C33=self.C3,C3X=self.C3X,assetManager=null;self.IAssetManager=class{constructor(e){assetManager=e,Object.defineProperties(this,{isWebMOpusSupported:{value:!0,writable:!1}})}loadImageAsset(e){const t=self.IImageInfo._Unwrap(e);if(!t)throw new Error("invalid IImageInfo");t.LoadAsset(assetManager.GetRuntime())}fetchText(e){return assetManager.FetchText(e)}fetchJson(e){return assetManager.FetchJson(e)}fetchBlob(e){return assetManager.FetchBlob(e)}fetchArrayBuffer(e){return assetManager.FetchArrayBuffer(e)}getProjectFileUrl(e){return assetManager.GetProjectFileUrl(e)}getMediaFileUrl(e){return"flat"===assetManager.GetFileStructure()&&C33.IsRelativeURL(e)&&(e=e.toLowerCase()),assetManager.GetMediaFileUrl(e)}get mediaFolder(){return assetManager.GetMediaSubfolder()}async decodeWebMOpus(e,t){throw new Error("decodeWebMOpus() is no longer supported - use Web Audio's decodeAudioData() directly as all supported platforms now support WebM Opus")}loadScripts(...e){return assetManager.LoadScripts(...e)}compileWebAssembly(e){return assetManager.CompileWebAssembly(e)}loadStyleSheet(e){return assetManager.LoadStyleSheet(e)}}}{let C33=self.C3,C3X=self.C3X,collisionEngine=null;self.ICollisionEngine=class{constructor(e){collisionEngine=e,Object.defineProperties(this,{runtime:{value:collisionEngine.GetRuntime(),writable:!1}})}testOverlap(e,t){const s=collisionEngine.GetRuntime(),i=s._UnwrapIWorldInstance(e),r=s._UnwrapIWorldInstance(t);return collisionEngine.TestOverlap(i,r)}testOverlapAny(e,t){const s=collisionEngine.GetRuntime(),i=s._UnwrapIWorldInstance(e);for(const r of t){const n=s._UnwrapIWorldInstance(r);if(collisionEngine.TestOverlap(i,n))return r}return null}testOverlapSolid(e){const t=collisionEngine.GetRuntime()._UnwrapIWorldInstance(e),s=collisionEngine.TestOverlapSolid(t);return s?s.GetInterfaceClass():null}setCollisionCellSize(e,t){if(C3X.RequireFiniteNumber(e),C3X.RequireFiniteNumber(t),e=Math.floor(e),t=Math.floor(t),e<=0||t<=0)throw new Error("invalid cell size");collisionEngine.SetCollisionCellSize(e,t)}getCollisionCellSize(){return collisionEngine.GetCollisionCellSize()}getCollisionCandidates(e,t){let s=collisionEngine.GetRuntime(),i;i=Array.isArray(e)?e.map(e=>s._UnwrapIObjectClass(e)):[s._UnwrapIObjectClass(e)];const r=C33.Rect.FromObject(t),n=[];return collisionEngine.GetObjectClassesCollisionCandidates(null,i,r,n),n.map(e=>e.GetInterfaceClass())}}}{let C33=self.C3,C3X=self.C3X,runtime=null,osMap=new Map([["Windows","windows"],["macOS","macos"],["Linux","linux"],["Chrome OS","chrome-os"],["Android","android"],["iOS","ios"]]),browserMap=new Map([["Chrome","chrome"],["Chromium","chromium"],["Edge","edge"],["Opera","opera"],["NW.js","nwjs"],["Firefox","firefox"],["Safari","safari"]]),browserEngineMap=new Map([["Chromium","chromium"],["Gecko","gecko"],["WebKit","webkit"]]);self.IPlatformInfo=class{constructor(e){runtime=e,Object.defineProperties(this,{isMobile:{value:C33.Platform.IsMobile,writable:!1},os:{value:osMap.get(C33.Platform.OS)||"unknown",writable:!1},osVersion:{value:C33.Platform.OSVersion,writable:!1},browser:{value:browserMap.get(C33.Platform.Browser)||"unknown",writable:!1},browserVersion:{value:C33.Platform.BrowserVersion,writable:!1},browserEngine:{value:browserEngineMap.get(C33.Platform.BrowserEngine)||"unknown",writable:!1}})}get exportType(){let e=runtime.GetExportType();return runtime.IsNWjs()?e="nwjs":runtime.IsWindowsWebView2()?e="windows-webview2":"cordova"===e?e="Android"===C33.Platform.OS?"cordova-android":"cordova-ios":"playable-ad-single-file"!==e&&"playable-ad-zip"!==e||(e="playable-ad"),e}get renderer(){return runtime.GetCanvasManager().GetRendererString()}get rendererDetail(){return runtime.GetCanvasManager().GetRendererDetailString()}get canvasCssWidth(){return runtime.GetCanvasManager().GetCssWidth()}get canvasCssHeight(){return runtime.GetCanvasManager().GetCssHeight()}get canvasDeviceWidth(){return runtime.GetCanvasManager().GetDeviceWidth()}get canvasDeviceHeight(){return runtime.GetCanvasManager().GetDeviceHeight()}get devicePixelRatio(){return runtime.GetDevicePixelRatio()}}}{const C33=self.C3,C3X=self.C3X;self.IStorage=class{constructor(e){this._storage=e._GetProjectStorage()}getItem(e){return C3X.RequireString(e),this._storage.getItem(e)}setItem(e,t){return C3X.RequireString(e),this._storage.setItem(e,t)}removeItem(e){return C3X.RequireString(e),this._storage.removeItem(e)}clear(){return this._storage.clear()}keys(){return this._storage.keys()}}}{const C33=self.C3,C3X=self.C3X,internalApiToken=C33._GetInternalAPIToken();self.IPlugin=class{#private;constructor(){const e=C33.AddonManager._GetInitObject2(internalApiToken);this.#private=e,Object.defineProperties(this,{runtime:{value:e.GetRuntime().GetIRuntime(),writable:!1},isSingleGlobal:{value:e.IsSingleGlobal(),writable:!1},isWorldType:{value:e.IsWorldType(),writable:!1},isHTMLElementType:{value:e.IsHTMLElementType(),writable:!1},isRotatable:{value:e.IsRotatable(),writable:!1},hasEffects:{value:e.HasEffects(),writable:!1},is3d:{value:e.Is3D(),writable:!1},supportsHierarchies:{value:e.SupportsSceneGraph(),writable:!1},supportsMesh:{value:e.SupportsMesh(),writable:!1}}),e.GetRuntime()._MapScriptInterface(this,e)}static getByConstructor(e){if(!e)return null;const t=C33.AddonManager.GetPluginByConstructorFunction(e);return t?t.GetIPlugin():null}getSingleGlobalObjectType(){return this.#private.GetSingleGlobalObjectClass().GetIObjectClass()}getSingleGlobalInstance(){return this.#private.GetSingleGlobalInstance().GetInterfaceClass()}}}{const C33=self.C3,C3X=self.C3X,internalApiToken=C33._GetInternalAPIToken();self.IObjectClass=class{#private;constructor(){const e=C33.AddonManager._GetInitObject2(internalApiToken);this.#private=e,Object.defineProperties(this,{name:{value:e.GetName(),writable:!1},runtime:{value:e.GetRuntime().GetIRuntime(),writable:!1},plugin:{value:e.GetPlugin().GetIPlugin(),writable:!1}}),e.GetRuntime()._MapScriptInterface(this,e)}addEventListener(e,t){C3X.RequireString(e),C3X.RequireFunction(t),this.#private.UserScriptDispatcher().addEventListener(e,t)}removeEventListener(e,t){C3X.RequireString(e),C3X.RequireFunction(t),this.#private.UserScriptDispatcher().removeEventListener(e,t)}getAllInstances(){return[...this.instances()]}getFirstInstance(){return C33.first(this.instances())}getPickedInstances(){return[...this.pickedInstances()]}getFirstPickedInstance(){return C33.first(this.pickedInstances())}getPairedInstance(e){const t=this.#private,s=t.GetRuntime()._UnwrapIInstance(e),i=t.GetPairedInstance(s);return i?i.GetInterfaceClass():null}*instances(){for(const e of this.#private.instancesIncludingPendingCreate())yield e.GetInterfaceClass()}*pickedInstances(){for(const e of this.#private.GetCurrentSol().GetInstances())yield e.GetInterfaceClass()}setInstanceClass(e){C3X.RequireFunction(e);const t=this.#private;if(0<t.GetInstanceCount())throw new Error("setInstanceClass() called too late, because instances have already been created - call in runOnStartup");t._SetUserScriptInstanceClass(e)}createInstance(e,t,s,i,r){if(C3X.RequireNumber(t),C3X.RequireNumber(s),"number"!=typeof e&&"string"!=typeof e)throw new TypeError("invalid layer parameter");const n=this.#private,a=n.GetRuntime(),o=a.GetMainRunningLayout().GetLayer(e);if(!o)throw new Error("invalid layer");const l=a.CreateInstance(n,o,t,s,i,r),h=(i&&o.SortAndAddInstancesByZIndex(l),a.GetEventSheetManager());return h.BlockFlushingInstances(!0),l._TriggerOnCreatedOnSelfAndRelated(),h.BlockFlushingInstances(!1),h.IsInEventEngine()||a.GetLayoutManager().IsEndingLayout()||a.FlushPendingInstances(),l.GetInterfaceClass()}}}{const C33=self.C3,C3X=self.C3X,map=new WeakMap,VALID_WHERE_STRINGS=["above","below","top-sublayer","bottom-sublayer"];self.ILayout=class{constructor(e){map.set(this,e);const t=[],s=e.GetEffectList(),i=s.GetAllEffectTypes().length;for(let e=0;e<i;++e)t.push(new self.IEffectInstance(s,e));Object.defineProperties(this,{name:{value:e.GetName(),writable:!1},index:{value:e.GetIndex(),writable:!1},effects:{value:t,writable:!1}})}addEventListener(e,t){C3X.RequireString(e),C3X.RequireFunction(t),map.get(this).UserScriptDispatcher().addEventListener(e,t)}removeEventListener(e,t){C3X.RequireString(e),C3X.RequireFunction(t),map.get(this).UserScriptDispatcher().removeEventListener(e,t)}get width(){return map.get(this).GetWidth()}set width(e){C3X.RequireFiniteNumber(e),map.get(this).SetWidth(e)}get height(){return map.get(this).GetHeight()}set height(e){C3X.RequireFiniteNumber(e),map.get(this).SetHeight(e)}setSize(e,t){C3X.RequireFiniteNumber(e),C3X.RequireFiniteNumber(t);const s=map.get(this);s.SetWidth(e),s.SetHeight(t)}getSize(){const e=map.get(this);return[e.GetWidth(),e.GetHeight()]}set scale(e){C3X.RequireFiniteNumber(e),map.get(this).SetScale(e)}get scale(){return map.get(this).GetScale()}set angle(e){C3X.RequireFiniteNumber(e),map.get(this).SetAngle(e)}get angle(){return map.get(this).GetAngle()}set scrollX(e){C3X.RequireNumber(e),map.get(this).SetScrollX(e)}get scrollX(){return map.get(this).GetScrollX()}set scrollY(e){C3X.RequireNumber(e),map.get(this).SetScrollY(e)}get scrollY(){return map.get(this).GetScrollY()}scrollTo(e,t){C3X.RequireNumber(e),C3X.RequireNumber(t);const s=map.get(this);s.SetScrollX(e),s.SetScrollY(t)}getScrollPosition(){const e=map.get(this);return[e.GetScrollX(),e.GetScrollY()]}getLayer(e){let t=map.get(this),s=null;if("number"!=typeof e&&"string"!=typeof e)throw new TypeError("expected string or number");return(s=t.GetLayer(e))?s.GetILayer():null}getAllLayers(){return map.get(this).GetLayers().map(e=>e.GetILayer())}*allLayers(){for(const e of map.get(this).allLayers())yield e.GetILayer()}addLayer(e,t,s){const i=map.get(this),r=self.ILayer,n=(C3X.RequireString(e),C3X.RequireOptionalInstanceOf(t,r),t?i.GetRuntime()._UnwrapScriptInterface(t):null),a=VALID_WHERE_STRINGS.indexOf(s);if(a<0)throw new Error("invalid location");i.AddLayer(e,n,a)}moveLayer(e,t,s){const i=map.get(this),r=i.GetRuntime(),n=self.ILayer,a=(C3X.RequireInstanceOf(e,n),r._UnwrapScriptInterface(e));if(!a)throw new Error("invalid layer");C3X.RequireOptionalInstanceOf(t,n);const o=t?r._UnwrapScriptInterface(t):null,l=VALID_WHERE_STRINGS.indexOf(s);if(l<0)throw new Error("invalid location");i.MoveLayer(a,o,l)}removeLayer(e){const t=map.get(this),s=self.ILayer,i=(C3X.RequireInstanceOf(e,s),t.GetRuntime()._UnwrapScriptInterface(e));if(!i)throw new Error("invalid layer");const r=i.GetRuntime();t.RemoveLayer(i),r.GetEventSheetManager().IsInEventEngine()||r.FlushPendingInstances()}removeAllDynamicLayers(){const e=map.get(this),t=e.GetRuntime();e.RemoveAllDynamicLayers(),t.GetEventSheetManager().IsInEventEngine()||t.FlushPendingInstances()}setVanishingPoint(e,t){C3X.RequireFiniteNumber(e),C3X.RequireFiniteNumber(t),map.get(this).SetVanishingPointXY(e,t)}getVanishingPoint(){return map.get(this)._GetVanishingPoint()}set projection(e){C3X.RequireString(e);const t=map.get(this);if("perspective"===e)t.SetPerspectiveProjection();else{if("orthographic"!==e)throw new Error("invalid projection");t.SetOrthographicProjection()}}get projection(){return map.get(this).IsOrthographicProjection()?"orthographic":"perspective"}}}{const C33=self.C3,C3X=self.C3X,map=new WeakMap,BLEND_MODE_TO_INDEX=new Map([["normal",0],["additive",1],["copy",3],["destination-over",4],["source-in",5],["destination-in",6],["source-out",7],["destination-out",8],["source-atop",9],["destination-atop",10]]),INDEX_TO_BLEND_MODE=new Map([...BLEND_MODE_TO_INDEX.entries()].map(e=>[e[1],e[0]])),tempColor=C33.New(C33.Color);self.ILayer=class{constructor(e){map.set(this,e);const t=[],s=e.GetEffectList(),i=s.GetAllEffectTypes().length;for(let e=0;e<i;++e)t.push(new self.IEffectInstance(s,e));Object.defineProperties(this,{name:{value:e.GetName(),writable:!1},layout:{value:e.GetLayout().GetILayout(),writable:!1},effects:{value:t,writable:!1}}),e.GetRuntime()._MapScriptInterface(this,e)}get parentLayer(){const e=map.get(this).GetParentLayer();return e?e.GetILayer():null}*parentLayers(){for(const e of map.get(this).parentLayers())yield e.GetILayer()}*subLayers(){for(const e of map.get(this).GetSubLayers())yield e.GetILayer()}*allSubLayers(){for(const e of map.get(this).GetSubLayers())for(const t of e.selfAndAllSubLayers())yield t.GetILayer()}get index(){return map.get(this).GetIndex()}get isVisible(){return map.get(this)._IsVisibleFlagSet()}set isVisible(e){map.get(this).SetVisible(e)}get isSelfAndParentsVisible(){return map.get(this).IsVisible()}get isInteractive(){return map.get(this).IsInteractive()}set isInteractive(e){map.get(this).SetInteractive(e)}get isHTMLElementsLayer(){return map.get(this).IsHTMLElementsLayer()}set isHTMLElementsLayer(e){map.get(this).SetIsHTMLElementsLayer(!!e)}get isSelfAndParentsInteractive(){return map.get(this).IsSelfAndParentsInteractive()}get opacity(){return map.get(this).GetOpacity()}set opacity(e){e=C33.clamp(+e,0,1),isNaN(e)||map.get(this).SetOpacity(e)}set scale(e){C3X.RequireFiniteNumber(e),map.get(this).SetOwnScale(e)}get scale(){return map.get(this).GetOwnScale()}set scaleRate(e){C3X.RequireFiniteNumber(e),map.get(this).SetScaleRate(e)}get scaleRate(){return map.get(this).GetScaleRate()}set angle(e){C3X.RequireFiniteNumber(e),map.get(this).SetAngle(e)}get angle(){return map.get(this).GetOwnAngle()}set parallaxX(e){C3X.RequireFiniteNumber(e),map.get(this).SetParallaxX(e)}get parallaxX(){return map.get(this).GetParallaxX()}set parallaxY(e){C3X.RequireFiniteNumber(e),map.get(this).SetParallaxY(e)}get parallaxY(){return map.get(this).GetParallaxY()}set zElevation(e){C3X.RequireFiniteNumber(e),map.get(this).SetZElevation(e)}get zElevation(){return map.get(this).GetZElevation()}set isTransparent(e){map.get(this).SetTransparent(e)}get isTransparent(){return map.get(this).IsTransparent()}set isForceOwnTexture(e){map.get(this).SetForceOwnTexture(e)}get isForceOwnTexture(){return map.get(this).IsForceOwnTexture()}set blendMode(e){C3X.RequireString(e);const t=BLEND_MODE_TO_INDEX.get(e);if("number"!=typeof t)throw new Error("invalid blend mode");map.get(this).SetBlendMode(t)}get blendMode(){return INDEX_TO_BLEND_MODE.get(map.get(this).GetBlendMode())}set backgroundColor(e){if(C3X.RequireArray(e),e.length<3)throw new Error("expected 3 elements");tempColor.setRgb(e[0],e[1],e[2]);const t=map.get(this),s=t.GetBackgroundColor();s.equalsIgnoringAlpha(tempColor)||(s.copyRgb(tempColor),t.GetRuntime().UpdateRender())}get backgroundColor(){const e=map.get(this).GetBackgroundColor();return[e.getR(),e.getG(),e.getB()]}set scrollX(e){C3X.RequireNumber(e);const t=map.get(this);t.SetOwnScrollPositionEnabled(!0),t.SetScrollX(e)}get scrollX(){return map.get(this).GetScrollX()}set scrollY(e){C3X.RequireNumber(e);const t=map.get(this);t.SetOwnScrollPositionEnabled(!0),t.SetScrollY(e)}get scrollY(){return map.get(this).GetScrollY()}scrollTo(e,t){C3X.RequireNumber(e),C3X.RequireNumber(t);const s=map.get(this);s.SetOwnScrollPositionEnabled(!0),s.SetScrollX(e),s.SetScrollY(t)}getScrollPosition(){const e=map.get(this);return[e.GetScrollX(),e.GetScrollY()]}restoreScrollPosition(){map.get(this).SetOwnScrollPositionEnabled(!1)}getViewport(){return map.get(this).GetViewport().toDOMRect()}cssPxToLayer(e,t,s=0){C3X.RequireNumber(e),C3X.RequireNumber(t),C3X.RequireNumber(s);const i=map.get(this),r=i.GetRuntime();return i.CanvasCssToLayer(e-r.GetCanvasClientX(),t-r.GetCanvasClientY(),s)}layerToCssPx(e,t,s=0){C3X.RequireNumber(e),C3X.RequireNumber(t),C3X.RequireNumber(s);const i=map.get(this),r=i.GetRuntime(),[n,a]=i.LayerToCanvasCss(e,t,s);return[n+r.GetCanvasClientX(),a+r.GetCanvasClientY()]}drawSurfaceToLayer(e,t,s=0){return C3X.RequireNumber(e),C3X.RequireNumber(t),C3X.RequireNumber(s),map.get(this).DrawSurfaceToLayer(e,t,s)}layerToDrawSurface(e,t,s=0){return C3X.RequireNumber(e),C3X.RequireNumber(t),C3X.RequireNumber(s),map.get(this).LayerToDrawSurface(e,t,s)}get renderScale(){return map.get(this).GetRenderScale()}}}{let GetDispatcher2=function(e){let t=dispatchers.get(e);return t||(t=C33.New(C33.Event.Dispatcher),dispatchers.set(e,t)),t};GetDispatcher=GetDispatcher2;const C33=self.C3,C3X=self.C3X,dispatchers=new WeakMap,internalApiToken=C33._GetInternalAPIToken();self.IInstance=class{#private;constructor(){const e=C33.AddonManager._GetInitObject2(internalApiToken),t={runtime:{value:(this.#private=e).GetRuntime().GetIRuntime(),writable:!1},objectType:{value:e.GetObjectClass().GetIObjectClass(),writable:!1},plugin:{value:e.GetPlugin().GetIPlugin(),writable:!1}};e._GetInstVarsScriptDescriptor(t),e._GetBehaviorsScriptDescriptor(t),Object.defineProperties(this,t),e.GetRuntime()._MapScriptInterface(this,e)}static _GetInitInst(){return C33.AddonManager._GetInitObject()}_release(){const e=dispatchers.get(this);e&&(e.Release(),dispatchers.delete(this))}addEventListener(e,t,s){C3X.RequireString(e),C3X.RequireFunction(t),GetDispatcher2(this).addEventListener(e,t,s)}removeEventListener(e,t,s){C3X.RequireString(e),C3X.RequireFunction(t),GetDispatcher2(this).removeEventListener(e,t,s)}dispatchEvent(e){GetDispatcher2(this).dispatchEvent(e)}destroy(){const e=this.#private,t=e.GetRuntime();t.DestroyInstance(e),t.GetEventSheetManager().IsInEventEngine()||t.GetLayoutManager().IsEndingLayout()||t.GetEventSheetManager().IsFlushingBlocked()||t.FlushPendingInstances()}getOtherContainerInstances(){const e=this.#private.GetSiblings();return e?e.map(e=>e.GetInterfaceClass()):[]}*otherContainerInstances(){const e=this.#private;if(e.IsInContainer())for(const t of e.siblings())yield t.GetInterfaceClass()}get uid(){return this.#private.GetUID()}get iid(){return this.#private.GetIID()}get templateName(){return this.#private.GetTemplateName()}set timeScale(e){C3X.RequireFiniteNumber(e),this.#private.SetTimeScale(e)}get timeScale(){return this.#private.GetActiveTimeScale()}restoreTimeScale(){this.#private.RestoreTimeScale()}get dt(){const e=this.#private;return e.GetRuntime().GetDt(e)}hasTags(...e){C3X.RequireArray(e);const t=new Set(e),s=this.#private.GetTagsSet();return t.isSubsetOf(s)}setAllTags(e){C3X.RequireInstanceOf(e,Set),this.#private.SetTagsSet(e)}getAllTags(){return new Set(this.#private.GetTagsSet())}signal(e){C3X.RequireString(e);const t=this.#private;t.GetRuntime().GetEventSheetManager().InstanceSignal(t,e)}waitForSignal(e){C3X.RequireString(e);const t=this.#private;return t.GetRuntime().GetEventSheetManager().WaitForInstanceSignal(t,e)}}}{const C33=self.C3,C3X=self.C3X,internalApiToken=C33._GetInternalAPIToken();self.ISDKInstanceBase=class extends self.IInstance{#private;#isTicking=!1;#tickFunc=null;#isTicking2=!1;#tickFunc2=null;#domComponentId;#wrapperComponentId;constructor(e){super(),this.#private=C33.AddonManager._GetInitObject2(internalApiToken),this.#isTicking=!1,this.#tickFunc=null,this.#isTicking2=!1,this.#tickFunc2=null,this.#domComponentId=e?.domComponentId,this.#wrapperComponentId=e?.wrapperComponentId}_release(){this._setTicking(!1),this._setTicking2(!1),super._release()}_getInitProperties(){return C33.AddonManager._GetInitProperties()}_trigger(e){const t=this.#private;t.GetRuntime().Trigger(e,t)}_triggerAsync(e){const t=this.#private;return t.GetRuntime().TriggerAsync(e,t)}_addDOMMessageHandler(e,t){if(C3X.RequireString(e),C3X.RequireFunction(t),!this.#domComponentId)throw new Error("no DOM component id set");const s=this.#private.GetRuntime();s.AddDOMComponentMessageHandler(this.#domComponentId,e,t)}_addDOMMessageHandlers(e){C3X.RequireArray(e);for(const[t,s]of e)this._addDOMMessageHandler(t,s)}_postToDOM(e,t){if(C3X.RequireString(e),!this.#domComponentId)throw new Error("no DOM component id set");const s=this.#private.GetRuntime();s.PostComponentMessageToDOM(this.#domComponentId,e,t)}_postToDOMAsync(e,t){if(C3X.RequireString(e),!this.#domComponentId)throw new Error("no DOM component id set");const s=this.#private.GetRuntime();return s.PostComponentMessageToDOMAsync(this.#domComponentId,e,t)}_postToDOMMaybeSync(e,t){const s=this.#private.GetRuntime();if(!s.IsInWorker())return window.c3_runtimeInterface._OnMessageFromRuntime({type:"event",component:this.#domComponentId,handler:e,data:t,responseId:null});this._postToDOM(e,t)}_setTicking(e){if(this.#isTicking!==(e=!!e)){this.#isTicking=e;const t=this.#private.GetRuntime();if(e){if(!this.#tickFunc)if(this.#private.GetRuntime().IsDebug()){const s=globalThis.C3Debugger,i=this.plugin;this.#tickFunc=()=>{const e=performance.now();this._tick(),s.AddIndividualPluginTickTime(i,performance.now()-e)}}else this.#tickFunc=()=>this._tick();t.Dispatcher().addEventListener("tick",this.#tickFunc)}else t.Dispatcher().removeEventListener("tick",this.#tickFunc)}}_isTicking(){return this.#isTicking}_tick(){}_setTicking2(e){if(this.#isTicking2!==(e=!!e)){this.#isTicking2=e;const t=this.#private.GetRuntime();if(e){if(!this.#tickFunc2)if(this.#private.GetRuntime().IsDebug()){const s=globalThis.C3Debugger,i=this.plugin;this.#tickFunc2=()=>{const e=performance.now();this._tick2(),s.AddIndividualPluginTickTime(i,performance.now()-e)}}else this.#tickFunc2=()=>this._tick2();t.Dispatcher().addEventListener("tick2",this.#tickFunc2)}else t.Dispatcher().removeEventListener("tick2",this.#tickFunc2)}}_isTicking2(){return this.#isTicking2}_tick2(){}_getDebuggerProperties(){return[]}_saveToJson(){return null}_loadFromJson(e){}_isWrapperExtensionAvailable(){if(!this.#wrapperComponentId)throw new Error("no wrapper component id set");const e=this.#private.GetRuntime();return e.HasWrapperComponentId(this.#wrapperComponentId)}_addWrapperExtensionMessageHandler(e,t){if(C3X.RequireString(e),C3X.RequireFunction(t),!this.#wrapperComponentId)throw new Error("no wrapper component id set");const s=this.#private.GetRuntime();s.AddWrapperExtensionMessageHandler(this.#wrapperComponentId,e,t)}_addWrapperMessageHandlers(e){C3X.RequireArray(e);for(const[t,s]of e)this._addWrapperExtensionMessageHandler(t,s)}_sendWrapperExtensionMessage(e,t){if(!this.#wrapperComponentId)throw new Error("no wrapper component id set");this.runtime.sdk.sendWrapperExtensionMessage(this.#wrapperComponentId,e,t)}_sendWrapperExtensionMessageAsync(e,t){if(this.#wrapperComponentId)return this.runtime.sdk.sendWrapperExtensionMessageAsync(this.#wrapperComponentId,e,t);throw new Error("no wrapper component id set")}}}{let MakeIWorldInstanceClass2=function(e){return class r extends e{#privateInst;#privateWi;constructor(e){super(e);const t=C33.AddonManager._GetInitObject2(internalApiToken),s=t.GetWorldInfo(),i=(this.#privateInst=t,this.#privateWi=s,map.set(this,t),[]),r=s.GetInstanceEffectList();if(r){const a=s.GetObjectClass().GetEffectList().GetAllEffectTypes().length;for(let e=0;e<a;++e)i.push(new self.IEffectInstance(r,e))}const n={effects:{value:i,writable:!1}};Object.defineProperties(this,n)}get layout(){return this.#privateWi.GetLayout().GetILayout()}get layer(){return this.#privateWi.GetLayer().GetILayer()}get x(){return this.#privateWi.GetX()}set x(e){e=+e;const t=this.#privateWi;isNaN(e)||t.GetX()===e||(t.SetX(e),t.SetBboxChanged())}get y(){return this.#privateWi.GetY()}set y(e){e=+e;const t=this.#privateWi;isNaN(e)||t.GetY()===e||(t.SetY(e),t.SetBboxChanged())}setPosition(e,t){e=+e,t=+t;const s=this.#privateWi;isNaN(e)||isNaN(t)||s.GetX()===e&&s.GetY()===t||(s.SetXY(e,t),s.SetBboxChanged())}getPosition(){const e=this.#privateWi;return[e.GetX(),e.GetY()]}offsetPosition(e,t){if(e=+e,t=+t,!(isNaN(e)||isNaN(t)||0===e&&0===t)){const s=this.#privateWi;s.OffsetXY(e,t),s.SetBboxChanged()}}get zElevation(){return this.#privateWi.GetZElevation()}set zElevation(e){e=+e;const t=this.#privateInst,s=this.#privateWi;isNaN(e)||s.GetZElevation()===e||(s.SetZElevation(e),t.GetRuntime().UpdateRender())}get totalZElevation(){return this.#privateWi.GetTotalZElevation()}get width(){return this.#privateWi.GetWidth()}set width(e){e=+e;const t=this.#privateWi;isNaN(e)||t.GetWidth()===e||(t.SetWidth(e),t.SetBboxChanged())}get height(){return this.#privateWi.GetHeight()}set height(e){e=+e;const t=this.#privateWi;isNaN(e)||t.GetHeight()===e||(t.SetHeight(e),t.SetBboxChanged())}setSize(e,t){e=+e,t=+t;const s=this.#privateWi;isNaN(e)||isNaN(t)||s.GetWidth()===e&&s.GetHeight()===t||(s.SetSize(e,t),s.SetBboxChanged())}getSize(){const e=this.#privateWi;return[e.GetWidth(),e.GetHeight()]}get angle(){return this.#privateWi.GetAngle()}set angle(e){e=C33.clampAngle(+e);const t=this.#privateWi;isNaN(e)||t.GetAngle()===e||(t.SetAngle(e),t.SetBboxChanged())}get angleDegrees(){return C33.toDegrees(this.angle)}set angleDegrees(e){this.angle=C33.toRadians(e)}getBoundingBox(){return this.#privateWi.GetBoundingBox().toDOMRect()}getBoundingQuad(){return this.#privateWi.GetBoundingQuad().toDOMQuad()}isOnScreen(){return this.#privateWi.IsInViewport2()}get isVisible(){return this.#privateWi.IsVisible()}set isVisible(e){e=!!e;const t=this.#privateInst,s=this.#privateWi;s.IsVisible()!==e&&(s.SetVisible(e),t.GetRuntime().UpdateRender())}get opacity(){return this.#privateWi.GetOpacity()}set opacity(e){e=C33.clamp(+e,0,1);const t=this.#privateInst,s=this.#privateWi;isNaN(e)||s.GetOpacity()===e||(s.SetOpacity(e),t.GetRuntime().UpdateRender())}set colorRgb(e){if(C3X.RequireArray(e),e.length<3)throw new Error("expected 3 elements");tempColor.setRgb(e[0],e[1],e[2]);const t=this.#privateInst,s=this.#privateWi;s.GetUnpremultipliedColor().equalsIgnoringAlpha(tempColor)||(s.SetUnpremultipliedColor(tempColor),t.GetRuntime().UpdateRender())}get colorRgb(){const e=this.#privateWi.GetUnpremultipliedColor();return[e.getR(),e.getG(),e.getB()]}set blendMode(e){C3X.RequireString(e);const t=BLEND_MODE_TO_INDEX.get(e);if("number"!=typeof t)throw new Error("invalid blend mode");const s=this.#privateInst,i=this.#privateWi;i.SetBlendMode(t),s.GetRuntime().UpdateRender()}get blendMode(){return INDEX_TO_BLEND_MODE.get(this.#privateWi.GetBlendMode())}moveToTop(){this.#privateWi.ZOrderMoveToTop()}moveToBottom(){this.#privateWi.ZOrderMoveToBottom()}moveToLayer(e){C3X.RequireInstanceOf(e,ILayer);const t=this.#privateInst,s=t.GetRuntime()._UnwrapScriptInterface(e);if(!s)throw new Error("invalid layer");t.GetWorldInfo().ZOrderMoveToLayer(s)}moveAdjacentToInstance(e,t){C3X.RequireInstanceOf(e,r),this.#privateWi.ZOrderMoveAdjacentToInstance(map.get(e),t)}get zIndex(){return this.#privateWi.GetZIndex()}get isCollisionEnabled(){return this.#privateWi.IsCollisionEnabled()}set isCollisionEnabled(e){this.#privateWi.SetCollisionEnabled(!!e)}containsPoint(e,t){return C3X.RequireNumber(e),C3X.RequireNumber(t),this.#privateWi.ContainsPoint(+e,+t)}testOverlap(e){C3X.RequireInstanceOf(e,r);const t=this.#privateInst,s=map.get(e);return t.GetRuntime().GetCollisionEngine().TestOverlap(t,s)}testOverlapSolid(){const e=this.#privateInst,t=e.GetRuntime().GetCollisionEngine().TestOverlapSolid(e);return t?t.GetInterfaceClass():null}getParent(){const e=this.#privateInst.GetParent();return e?e.GetInterfaceClass():null}getTopParent(){const e=this.#privateInst.GetTopParent();return e?e.GetInterfaceClass():null}*parents(){for(const e of this.#privateInst.parents())yield e.GetInterfaceClass()}getChildCount(){return this.#privateInst.GetChildCount()}getChildAt(e){const t=this.#privateInst.GetChildAt(e);return t?t.GetInterfaceClass():null}*children(){for(const e of this.#privateInst.children())yield e.GetInterfaceClass()}*allChildren(){for(const e of this.#privateInst.allChildren())yield e.GetInterfaceClass()}addChild(e,t){C3X.RequireInstanceOf(e,r),C3X.RequireOptionalObject(t),t=t||{};const s=this.#privateInst,i=map.get(e);s.AddChild(i,t)}removeChild(e){C3X.RequireInstanceOf(e,r);const t=this.#privateInst,s=map.get(e);t.RemoveChild(s)}removeFromParent(){const e=this.#privateInst;if(e.HasParent()){const t=e.GetParent();t.RemoveChild(e)}}getHierarchyOpts(){const e=this.#privateWi;return{transformX:e.GetTransformWithParentX(),transformY:e.GetTransformWithParentY(),transformWidth:e.GetTransformWithParentWidth(),transformHeight:e.GetTransformWithParentHeight(),transformAngle:e.GetTransformWithParentAngle(),transformZElevation:e.GetTransformWithParentZElevation(),transformOpacity:e.GetTransformWithParentOpacity(),transformVisibility:e.GetTransformWithParentVisibility(),destroyWithParent:e.GetDestroyWithParent()}}createMesh(e,t){C3X.RequireFiniteNumber(e),C3X.RequireFiniteNumber(t),this.#privateWi.CreateMesh(e,t)}releaseMesh(){const e=this.#privateWi;e.ReleaseMesh(),e.SetBboxChanged()}setMeshPoint(e,t,s){C3X.RequireFiniteNumber(e),C3X.RequireFiniteNumber(t),C3X.RequireObject(s);const i=this.#privateWi;i.SetMeshPoint(e,t,s)&&i.SetBboxChanged()}getMeshPoint(e,t){let s=NaN,i=NaN,r=NaN,n=NaN,a=NaN,o=this.#privateWi;if(o.HasMesh()){const l=o.GetSourceMesh(),h=l.GetMeshPointAt(e,t);null!==h&&(s=h.GetX(),i=h.GetY(),r=h.GetZElevation(),n=h.GetU(),a=h.GetV())}return{x:s,y:i,zElevation:r,u:n,v:a}}getMeshSize(){const e=this.#privateWi;if(!e.HasMesh())return[0,0];const t=e.GetSourceMesh();return[t.GetHSize(),t.GetVSize()]}}};MakeIWorldInstanceClass=MakeIWorldInstanceClass2;const C33=self.C3,C3X=self.C3X,IInstance=self.IInstance,ILayer=self.ILayer,map=new WeakMap,internalApiToken=C33._GetInternalAPIToken(),BLEND_MODE_TO_INDEX=new Map([["normal",0],["additive",1],["copy",3],["destination-over",4],["source-in",5],["destination-in",6],["source-out",7],["destination-out",8],["source-atop",9],["destination-atop",10]]),INDEX_TO_BLEND_MODE=new Map([...BLEND_MODE_TO_INDEX.entries()].map(e=>[e[1],e[0]])),tempColor=C33.New(C33.Color);self.IWorldInstance=MakeIWorldInstanceClass2(self.IInstance),self.IWorldInstanceSDKBase=MakeIWorldInstanceClass2(self.ISDKInstanceBase)}{const C33=self.C3,C3X=self.C3X;self.IDOMInstance=class extends self.IWorldInstance{#private;constructor(){super(),this.#private=self.IInstance._GetInitInst()}getElement(){return this.#private.GetSdkInstance()._GetElementInDOMMode()}focus(){this.#private.GetSdkInstance().FocusElement()}blur(){this.#private.GetSdkInstance().BlurElement()}setCssStyle(e,t){C3X.RequireString(e),this.#private.GetSdkInstance().SetElementCSSStyle(e,t)}}}{let GetDispatcher2=function(e){let t=dispatchers.get(e);return t||(t=C33.New(C33.Event.Dispatcher),dispatchers.set(e,t)),t};GetDispatcher=GetDispatcher2;const C33=self.C3,C3X=self.C3X,dispatchers=new WeakMap,internalApiToken=C33._GetInternalAPIToken();self.IBehaviorInstance=class{#private;constructor(){const e=C33.AddonManager._GetInitObject2(internalApiToken),t={runtime:{value:(this.#private=e).GetRuntime().GetIRuntime(),writable:!1},behavior:{value:e.GetBehavior().GetIBehavior(),writable:!1},behaviorType:{value:e.GetBehaviorType().GetIBehaviorType(),writable:!1}};Object.defineProperties(this,t),e.GetRuntime()._MapScriptInterface(this,e)}static _GetInitInst(){return C33.AddonManager._GetInitObject()}get instance(){return this.#private.GetObjectInstance().GetInterfaceClass()}_release(){const e=dispatchers.get(this);e&&(e.Release(),dispatchers.delete(this))}addEventListener(e,t,s){C3X.RequireString(e),C3X.RequireFunction(t),GetDispatcher2(this).addEventListener(e,t,s)}removeEventListener(e,t,s){C3X.RequireString(e),C3X.RequireFunction(t),GetDispatcher2(this).removeEventListener(e,t,s)}dispatchEvent(e){GetDispatcher2(this).dispatchEvent(e)}}}{const C33=self.C3,C3X=self.C3X,internalApiToken=C33._GetInternalAPIToken();self.IBehaviorType=class{constructor(){const e=C33.AddonManager._GetInitObject2(internalApiToken),t={runtime:{value:e.GetRuntime().GetIRuntime(),writable:!1},behavior:{value:e.GetBehavior().GetIBehavior(),writable:!1},name:{value:e.GetName(),writable:!1}};Object.defineProperties(this,t)}}}{const C33=self.C3,C3X=self.C3X,internalApiToken=C33._GetInternalAPIToken();self.IBehavior=class{#private;constructor(){const e=C33.AddonManager._GetInitObject2(internalApiToken),t={runtime:{value:(this.#private=e).GetRuntime().GetIRuntime(),writable:!1}};Object.defineProperties(this,t),e.GetRuntime()._MapScriptInterface(this,e)}getAllInstances(){return this.#private.GetInstances().map(e=>e.GetInterfaceClass())}static getByConstructor(e){if(!e)return null;const t=C33.AddonManager.GetBehaviorByConstructorFunction(e);return t?t.GetIBehavior():null}}}{const C33=self.C3,C3X=self.C3X,tempColor=C33.New(C33.Color);self.IEffectInstance=class{#private;constructor(e,t){this.#private=e;const s={index:{value:t,writable:!1}};Object.defineProperties(this,s)}get name(){const e=this.#private.GetAllEffectTypes();return e[this.index].GetName()}get isActive(){return this.#private.IsEffectIndexActive(this.index)}set isActive(e){e=!!e;const t=this.#private;t.IsEffectIndexActive(this.index)!==e&&(t.SetEffectIndexActive(this.index,e),t.UpdateActiveEffects(),t.GetRuntime().UpdateRender())}setParameter(e,t){C3X.RequireFiniteNumber(e),e=Math.floor(+e);const s=this.#private,i=s.GetEffectParameter(this.index,e);if(null===i)throw new RangeError("invalid index");if(i instanceof C33.Color){if(!Array.isArray(t)||t.length<3)throw new TypeError("expected array with 3 elements");tempColor.setRgb(t[0],t[1],t[2]),t=tempColor}else if("number"!=typeof t)throw new TypeError("expected number");const r=s.SetEffectParameter(this.index,e,t);r&&s.IsEffectIndexActive(this.index)&&s.GetRuntime().UpdateRender()}getParameter(e){C3X.RequireFiniteNumber(e),e=Math.floor(+e);const t=this.#private,s=t.GetEffectParameter(this.index,e);if(null===s)throw new RangeError("invalid index");return s instanceof C33.Color?[s.getR(),s.getG(),s.getB()]:s}}}{const C33=self.C3,C3X=self.C3X;self.IAnimation=class{#private;constructor(e){this.#private=e,Object.defineProperties(this,{name:{value:e.GetName(),writable:!1}})}get speed(){return this.#private.GetSpeed()}get isLooping(){return this.#private.IsLooping()}get repeatCount(){return this.#private.GetRepeatCount()}get repeatTo(){return this.#private.GetRepeatTo()}get isPingPong(){return this.#private.IsPingPong()}get frameCount(){return this.#private.GetFrameCount()}getFrames(){return this.#private.GetFrames().map(e=>e.GetIAnimationFrame())}*frames(){for(const e of this.#private.GetFrames())yield e.GetIAnimationFrame()}}}{const C33=self.C3,C3X=self.C3X;self.IImageInfo=class{#private;constructor(e){this.#private=e}static _Unwrap(e){return e.#private}get width(){return this.#private.GetWidth()}get height(){return this.#private.GetHeight()}getSize(){const e=this.#private;return[e.GetWidth(),e.GetHeight()]}getTexture(e){return e.getTextureForImageInfo(this)}getTexRect(){return this.#private.GetTexRect().toDOMRect()}}}{const C33=self.C3,C3X=self.C3X;self.IAnimationFrame=class extends self.IImageInfo{#private;constructor(e){super(e.GetImageInfo()),this.#private=e,Object.defineProperties(this,{duration:{value:e.GetDuration(),writable:!1},originX:{value:e.GetOriginX(),writable:!1},originY:{value:e.GetOriginY(),writable:!1}})}getOrigin(){const e=this.#private;return[e.GetOriginX(),e.GetOriginY()]}getImagePointCount(){return this.#private.GetImagePointCount()}getImagePointX(e){return this.getImagePoint(e)[0]}getImagePointY(e){return this.getImagePoint(e)[1]}getImagePoint(e){let t=this.#private,s=null;if("number"==typeof e)s=t.GetImagePointByIndex(Math.floor(e));else{if("string"!=typeof e)throw new TypeError("expected string or number");s=t.GetImagePointByName(e)}return s?[s.GetX(),s.GetY()]:this.getOrigin()}getPolyPointCount(){const e=this.#private.GetCollisionPoly();return e?e.pointCount():0}getPolyPointX(e){return this.getPolyPoint(e)[0]}getPolyPointY(e){return this.getPolyPoint(e)[1]}getPolyPoint(e){C3X.RequireFiniteNumber(e),e=Math.floor(e);const t=this.#private.GetCollisionPoly();if(!t||e<0||e>=t.pointCount())return[0,0];const s=t.pointsArr(),i=s[2*e],r=s[2*e+1];return[i,r]}get tag(){return this.#private.GetTag()}}}{let GetTimelineState2=function(e){const t=map.get(e);if(t.IsReleased())throw new Error("timeline/tween was released and is no longer valid");return t};GetTimelineState=GetTimelineState2;const C33=self.C3,C3X=self.C3X,map=new WeakMap;self.ITimelineStateBase=class{constructor(e){map.set(this,e),e.GetRuntime()._MapScriptInterface(this,e)}pause(){GetTimelineState2(this).Stop()}resume(){GetTimelineState2(this).Resume()}stop(){GetTimelineState2(this).Reset()}hasTags(e){return GetTimelineState2(this).HasTags(e)}set time(e){C3X.RequireFiniteNumber(e),GetTimelineState2(this).SetTime(e)}get time(){return GetTimelineState2(this).GetTime()}set totalTime(e){C3X.RequireFiniteNumber(e),GetTimelineState2(this).SetTotalTime(e)}get totalTime(){return GetTimelineState2(this).GetTotalTime()}set isLooping(e){GetTimelineState2(this).SetLoop(!!e)}get isLooping(){return GetTimelineState2(this).GetLoop()}set isPingPong(e){GetTimelineState2(this).SetPingPong(!!e)}get isPingPong(){return GetTimelineState2(this).GetPingPong()}set playbackRate(e){C3X.RequireFiniteNumber(e),GetTimelineState2(this).SetPlaybackRate(e)}get playbackRate(){return GetTimelineState2(this).GetPlaybackRate()}get progress(){const e=GetTimelineState2(this);return e.GetTime()/e.GetTotalTime()}get tags(){return GetTimelineState2(this).GetTags()}get finished(){return GetTimelineState2(this).GetPlayPromise()}get isPlaying(){return GetTimelineState2(this).IsPlaying()}get isPaused(){return GetTimelineState2(this).IsPaused()}get isReleased(){return map.get(this).IsReleased()}}}{let GetTimelineState2=function(e){const t=map.get(e);if(t.IsReleased())throw new Error("timeline was released and is no longer valid");return t},C33=(GetTimelineState=GetTimelineState2,self.C3),C3X=self.C3X,map=new WeakMap,easeToIndexFunc=null;self.ITimelineState=class extends self.ITimelineStateBase{constructor(e){super(e),map.set(this,e);const t={name:{value:e.GetName(),writable:!1}};Object.defineProperties(this,t)}}}{let GetTweenState2=function(e){const t=map.get(e);if(t.IsReleased())throw new Error("tween was released and is no longer valid");return t},C33=(GetTweenState=GetTweenState2,self.C3),C3X=self.C3X,map=new WeakMap,behInstMap=new WeakMap,easeToIndexFunc=null;self.ITweenState=class extends self.ITimelineStateBase{constructor(e,t,s){super(e),easeToIndexFunc=easeToIndexFunc||s.easeToIndexFunc,map.set(this,e),t&&behInstMap.set(this,t)}stop(){const e=GetTweenState2(this),t=behInstMap.get(this);t.ReleaseTween(e)}setEase(e){C3X.RequireString(e);const t=self.Ease.GetEaseFromIndex(easeToIndexFunc(e));GetTweenState2(this).SetEase(t)}get instance(){const e=GetTweenState2(this).GetInstance();return e?e.GetInterfaceClass():null}get isDestroyOnComplete(){return GetTweenState2(this).GetDestroyInstanceOnComplete()}set isDestroyOnComplete(e){GetTweenState2(this).SetDestroyInstanceOnComplete(!!e)}get value(){const e=GetTweenState2(this);if("value"!==e.GetId())throw new Error("not a value tween");return e.GetPropertyTrack("value").GetSourceAdapterValue()}}}{const C33=self.C3,C3X=self.C3X;self.ISDKPluginBase=class extends self.IPlugin{constructor(){super()}}}{const C33=self.C3,C3X=self.C3X,internalApiToken=C33._GetInternalAPIToken();self.ISDKDOMPluginBase=class extends self.ISDKPluginBase{#private;#domComponentId;#nextElementId=0;#instMap=new Map;constructor(e){if(super(),this.#private=C33.AddonManager._GetInitObject2(internalApiToken),!e?.domComponentId)throw new Error("no DOM component ID specified");this.#domComponentId=e.domComponentId,this._addElementMessageHandler("elem-focused",e=>e._onElemFocused()),this._addElementMessageHandler("elem-blurred",e=>{e&&e._onElemBlurred()})}_addElement(e){const t=this.#nextElementId++;return this.#instMap.set(t,e),t}_removeElement(e){this.#instMap.delete(e)}_addElementMessageHandler(e,s){const t=this.#private.GetRuntime();t.AddDOMComponentMessageHandler(this.#domComponentId,e,e=>{const t=this.#instMap.get(e.elementId);s(t,e)})}_addElementMessageHandlers(e){C3X.RequireArray(e);for(const[t,s]of e)this._addElementMessageHandlers(t,s)}}}{const C33=self.C3,C3X=self.C3X,map=new WeakMap,internalApiToken=C33._GetInternalAPIToken();self.ISDKObjectTypeBase=class extends self.IObjectClass{#private;constructor(){super(),this.#private=C33.AddonManager._GetInitObject2(internalApiToken)}_onCreate(){}getImageInfo(){return this.#private.GetImageInfo().GetIImageInfo()}_loadTextures(e){}_releaseTextures(e){}_onDynamicTextureLoadComplete(){}_preloadTexturesWithInstances(e){}}}{const C33=self.C3,C3X=self.C3X,map=new WeakMap,internalApiToken=C33._GetInternalAPIToken();self.ISDKWorldInstanceBase=class extends self.IWorldInstanceSDKBase{#private;#renderercontextlost_handler=null;#renderercontextrestored_handler=null;constructor(e){super(e),this.#private=C33.AddonManager._GetInitObject2(internalApiToken)}_release(){if(super._release(),this.#renderercontextlost_handler){const e=this.#private.GetRuntime().Dispatcher();e.removeEventListener("renderercontextlost",this.#renderercontextlost_handler),e.removeEventListener("renderercontextrestored",this.#renderercontextrestored_handler),this.#renderercontextlost_handler=null,this.#renderercontextrestored_handler=null}}_handleRendererContextLoss(){if(!this.#renderercontextlost_handler){this.#renderercontextlost_handler=()=>this._onRendererContextLost(),this.#renderercontextrestored_handler=()=>this._onRendererContextRestored();const e=this.#private.GetRuntime().Dispatcher();e.addEventListener("renderercontextlost",this.#renderercontextlost_handler),e.addEventListener("renderercontextrestored",this.#renderercontextrestored_handler)}}_onRendererContextLost(){}_onRendererContextRestored(){}_draw(e){}}}{const C33=self.C3,C3X=self.C3X,tempRect=C33.New(C33.Rect),map=new WeakMap,internalApiToken=C33._GetInternalAPIToken();self.ISDKDOMInstanceBase=class extends self.ISDKWorldInstanceBase{#elementId=-1;#isElementShowing=!0;#elemHasFocus=!1;#autoFontSize=!1;#autoFontSizeOffset=-.2;#lastRect=C33.New(C33.Rect,0,0,-1,-1);#lastWindowWidth=0;#lastWindowHeight=0;#lastHTMLIndex=-1;#lastHTMLZIndex=-1;#isPendingUpdateState=!1;constructor(e){if(!e?.domComponentId)throw new Error("no DOM component ID specified");super(e);const t=C33.AddonManager._GetInitObject2(internalApiToken),s=(map.set(this,t),this.#elementId=this.plugin._addElement(this),t.GetRuntime().GetCanvasManager());this.#lastWindowWidth=s.GetLastWidth(),this.#lastWindowHeight=s.GetLastHeight(),this._setTicking(!0)}_release(){super._release(),this.plugin._removeElement(this.#elementId),this._postToDOMElement("destroy"),this.#elementId=-1,map.delete(this)}_getElementInDOMMode(){const e=map.get(this).GetRuntime();if(e.IsInWorker())throw new Error("not valid in worker mode");return this._postToDOMElementMaybeSync("get-element")}_postToDOMElement(e,t){(t=t||{}).elementId=this.#elementId,this._postToDOM(e,t)}_postToDOMElementMaybeSync(e,t){return(t=t||{}).elementId=this.#elementId,this._postToDOMMaybeSync(e,t)}_postToDOMElementAsync(e,t){return(t=t||{}).elementId=this.#elementId,this._postToDOMAsync(e,t)}_createElement(e){e=e||{};const t=map.get(this).GetWorldInfo();e.elementId=this.#elementId,e.isVisible=t.IsVisible(),e.htmlIndex=t.GetLayer().GetHTMLIndex(),e.htmlZIndex=t.GetHTMLZIndex(),Object.assign(e,this._getElementState()),this.#isElementShowing=!!e.isVisible,this._postToDOMMaybeSync("create",e),this._updatePosition(!0)}setElementVisible(e){this.#isElementShowing!==(e=!!e)&&(this.#isElementShowing=e,this._postToDOMElement("set-visible",{isVisible:e}))}_tick(){this._updatePosition(!1)}_shouldPreserveElement(){const e=map.get(this).GetRuntime(),t=e.GetCanvasManager().GetFullscreenMode();return"Android"===C33.Platform.OS&&("scale-inner"===t||"scale-outer"===t||"crop"===t)}_updatePosition(c){const u=map.get(this);if(!u.IsDestroyed()){let e=u.GetWorldInfo(),t=e.GetLayer(),s=e.GetBoundingBox(),[i,r]=t.LayerToCanvasCss(s.getLeft(),s.getTop()),[n,a]=t.LayerToCanvasCss(s.getRight(),s.getBottom()),o=u.GetRuntime().GetCanvasManager(),l=o.GetCssWidth(),h=o.GetCssHeight();if(e.IsVisible()&&t.IsVisible())if(!this._shouldPreserveElement()&&(n<=0||a<=0||l<=i||h<=r))this.setElementVisible(!1);else{tempRect.set(i,r,n,a);const _=o.GetLastWidth(),d=o.GetLastHeight(),p=t.GetHTMLIndex(),m=e.GetHTMLZIndex();if(!c&&tempRect.equals(this.#lastRect)&&this.#lastWindowWidth===_&&this.#lastWindowHeight===d&&this.#lastHTMLIndex===p&&this.#lastHTMLZIndex===m)this.setElementVisible(!0);else{this.#lastRect.copy(tempRect),this.#lastWindowWidth=_,this.#lastWindowHeight=d,this.#lastHTMLIndex=p,this.#lastHTMLZIndex=m,this.setElementVisible(!0);let e=null;this.#autoFontSize&&(e=t.GetDisplayScale()+this.#autoFontSizeOffset),this._postToDOMElement("update-position",{left:Math.round(this.#lastRect.getLeft()),top:Math.round(this.#lastRect.getTop()),width:Math.round(this.#lastRect.width()),height:Math.round(this.#lastRect.height()),htmlIndex:p,htmlZIndex:m,fontSize:e})}}else this.setElementVisible(!1)}}focusElement(){this._postToDOMElementMaybeSync("focus",{focus:!0})}blurElement(){this._postToDOMElementMaybeSync("focus",{focus:!1})}_onElemFocused(){this.#elemHasFocus=!0}_onElemBlurred(){this.#elemHasFocus=!1}isElementFocused(){return this.#elemHasFocus}setElementCSSStyle(e,t){this.postToDOMElement("set-css-style",{prop:C33.CSSToCamelCase(e),val:t})}setElementAttribute(e,t){this.postToDOMElement("set-attribute",{name:e,val:t})}removeElementAttribute(e){this.postToDOMElement("remove-attribute",{name:e})}_updateElementState(){this.#isPendingUpdateState||(this.#isPendingUpdateState=!0,Promise.resolve().then(()=>{this.#isPendingUpdateState=!1,this._postToDOMElement("update-state",this._getElementState())}))}_getElementState(){}_getElementId(){return this.#elementId}}}{const C33=self.C3,C3X=self.C3X;self.ISDKBehaviorBase=class extends self.IBehavior{constructor(){super()}}}{const C33=self.C3,C3X=self.C3X;self.ISDKBehaviorTypeBase=class extends globalThis.IBehaviorType{constructor(){super()}_onCreate(){}}}{const C33=self.C3,C3X=self.C3X,map=new WeakMap,internalApiToken=C33._GetInternalAPIToken();self.ISDKBehaviorInstanceBase=class extends self.IBehaviorInstance{#isTicking=!1;#isTicking2=!1;#isPostTicking=!1;constructor(){super(),map.set(this,C33.AddonManager._GetInitObject2(internalApiToken))}_release(){super._release(),this._setTicking(!1),this._setTicking2(!1),this._setPostTicking(!1),map.delete(this)}_getInitProperties(){return C33.AddonManager._GetInitProperties()}_postCreate(){}_trigger(e){const t=map.get(this);t.GetRuntime().Trigger(e,t.GetObjectInstance(),t.GetBehaviorType())}_triggerAsync(e){const t=map.get(this);return t.GetRuntime().TriggerAsync(e,t.GetObjectInstance(),t.GetBehaviorType())}_setTicking(e){if(this.#isTicking!==(e=!!e)){this.#isTicking=e;const t=map.get(this).GetRuntime();e?t._AddBehInstToTick(this):t._RemoveBehInstToTick(this)}}_isTicking(){return this.#isTicking}_tick(){}_setTicking2(e){if(this.#isTicking2!==(e=!!e)){this.#isTicking2=e;const t=map.get(this).GetRuntime();e?t._AddBehInstToTick2(this):t._RemoveBehInstToTick2(this)}}_isTicking2(){return this.#isTicking2}_tick2(){}_setPostTicking(e){if(this.#isPostTicking!==(e=!!e)){this.#isPostTicking=e;const t=map.get(this).GetRuntime();e?t._AddBehInstToPostTick(this):t._RemoveBehInstToPostTick(this)}}_isPostTicking(){return this.#isPostTicking}_postTick(){}_getDebuggerProperties(){return[]}_saveToJson(){return null}_loadFromJson(e){}}}{let C33=self.C3,C3X=self.C3X,runtime=null;self.ISDKUtils=class{constructor(e){runtime=e}addLoadPromise(e){runtime.AddLoadPromise(e)}sendWrapperExtensionMessage(e,t,s){C3X.RequireString(e),C3X.RequireString(t),C3X.RequireOptionalArray(s),runtime.SendWrapperExtensionMessage(e,t,s)}sendWrapperExtensionMessageAsync(e,t,s){return C3X.RequireString(e),C3X.RequireString(t),C3X.RequireOptionalArray(s),runtime.SendWrapperExtensionMessageAsync(e,t,s)}createLoopingConditionContext(e){return C3X.RequireOptionalString(e),new self.ILoopingConditionContext(runtime,e)}set isAutoSuspendEnabled(e){runtime._SetAutoSuspendEnabled(!!e)}get isAutoSuspendEnabled(){return runtime._IsAutoSuspendEnabled()}setSuspended(e){runtime.SetSuspended(!!e)}getObjectClassBySid(e){C3X.RequireNumber(e);const t=runtime.GetObjectClassBySID(e);return t?t.GetIObjectClass():null}}}{const C33=self.C3,C3X=self.C3X;self.ILoopingConditionContext=class{#runtime;#currentEvent;#solModifiers;#oldFrame;#newFrame;#loop;constructor(e,t){const s=(this.#runtime=e).GetEventSheetManager(),i=e.GetCurrentEvent(),r=(this.#currentEvent=i,this.#solModifiers=i.GetSolModifiers(),e.GetEventStack()),n=(this.#oldFrame=r.GetCurrentStackFrame(),this.#newFrame=r.Push(i),s.GetLoopStack()),a=n.Push();this.#loop=a,t&&a.SetName(t),e.SetDebuggingEnabled(!1)}retrigger(){const e=this.#runtime.GetEventSheetManager(),t=this.#solModifiers,s=this.#loop;e.PushCopySol(t),this.#currentEvent.Retrigger(this.#oldFrame,this.#newFrame),e.PopSol(t),s.SetIndex(s.GetIndex()+1)}get isStopped(){return this.#loop.IsStopped()}release(){const e=this.#runtime,t=e.GetEventStack(),s=e.GetEventSheetManager().GetLoopStack();e.SetDebuggingEnabled(!0),s.Pop(),t.Pop()}}}{let C33=self.C3,C3X=self.C3X,renderer=null,runtime=null;self.IRenderer=class{constructor(e,t){runtime=e,renderer=t}setAlphaBlendMode(){renderer.SetAlphaBlend()}setBlendMode(e){renderer.SetNamedBlendMode(e)}setColorFillMode(){renderer.SetColorFillMode()}setTextureFillMode(){renderer.SetTextureFillMode()}setSmoothLineFillMode(){renderer.SetSmoothLineFillMode()}setColor(e){renderer.SetColorRgba(e[0],e[1],e[2],e[3])}setColorRgba(e,t,s,i){renderer.SetColorRgba(e,t,s,i)}resetColor(){renderer.ResetColor()}setOpacity(e){renderer.SetOpacity(e)}setCurrentZ(e){renderer.SetCurrentZ(e)}getCurrentZ(){renderer.GetCurrentZ()}rect(e){renderer.Rect2(e.left,e.top,e.right,e.bottom)}rect2(e,t,s,i){renderer.Rect2(e,t,s,i)}quad(e){renderer.Quad(C33.Quad.fromDOMQuad(e))}quad2(e,t,s,i,r,n,a,o){renderer.Quad2(e,t,s,i,r,n,a,o)}quad3(e,t){renderer.Quad3(C33.Quad.fromDOMQuad(e),C33.Rect.fromDOMRect(t))}quad4(e,t){renderer.Quad4(C33.Quad.fromDOMQuad(e),C33.Quad.fromDOMQuad(t))}quad3D(e,t,s,i,r,n,a,o,l,h,c,u,_){renderer.Quad3D(e,t,s,i,r,n,a,o,l,h,c,u,C33.Rect.fromDOMRect(_))}quad3D2(e,t,s,i,r,n,a,o,l,h,c,u,_){renderer.Quad3D2(e,t,s,i,r,n,a,o,l,h,c,u,C33.Quad.fromDOMQuad(_))}drawMesh(e,t,s){renderer.DrawMesh(e,t,s)}convexPoly(e){renderer.ConvexPoly(e)}line(e,t,s,i){renderer.Line(e,t,s,i)}texturedLine(e,t,s,i,r,n){renderer.TexturedLine(e,t,s,i,r,n)}lineRect(e,t,s,i){renderer.LineRect(e,t,s,i)}lineRect2(e){renderer.LineRect2(C33.Rect.fromDOMRect(e))}lineQuad(e){renderer.LineQuad(C33.Quad.fromDOMQuad(e))}pushLineWidth(e){renderer.PushLineWidth(e)}popLineWidth(){renderer.PopLineWidth()}pushLineCap(e){renderer.PushLineCap(e)}popLineCap(){renderer.PopLineCap()}setTexture(e){C3X.RequireOptionalInstanceOf(e,self.ITexture);const t=e?runtime._UnwrapScriptInterface(e):null;renderer.SetTexture(t)}loadTextureForImageInfo(e,t){const s=self.IImageInfo._Unwrap(e);if(s)return s.LoadStaticTexture(renderer,{wrapX:t?.wrapX??"clamp-to-edge",wrapY:t?.wrapY??"clamp-to-edge",sampling:t?.sampling??"trilinear",mipMap:t?.mipMap??!0});throw new Error("invalid IImageInfo")}releaseTextureForImageInfo(e){const t=self.IImageInfo._Unwrap(e);if(!t)throw new Error("invalid IImageInfo");t.ReleaseTexture()}getTextureForImageInfo(e){const t=self.IImageInfo._Unwrap(e);if(!t)throw new Error("invalid IImageInfo");const s=t.GetTexture();return self.ITexture.GetInterface(runtime,s)}createDynamicTexture(e,t,s){C3X.RequireFiniteNumber(e),C3X.RequireFiniteNumber(t);const i=renderer.CreateDynamicTexture(e,t,{wrapX:s?.wrapX??"clamp-to-edge",wrapY:s?.wrapY??"clamp-to-edge",sampling:s?.sampling??"trilinear",mipMap:s?.mipMap??!0});return self.ITexture.GetInterface(runtime,i)}updateTexture(e,t,s){C3X.RequireInstanceOf(t,self.ITexture);const i=runtime._UnwrapScriptInterface(t);renderer.UpdateTexture(e,i,{premultiplyAlpha:s?.premultiplyAlpha??!0})}deleteTexture(e){C3X.RequireInstanceOf(e,self.ITexture);const t=runtime._UnwrapScriptInterface(e);renderer.DeleteTexture(t)}createRendererText(){const e=renderer.CreateRendererText();return new self.IRendererText(runtime,e)}setDeviceTransform(){runtime.GetCanvasManager().SetDeviceTransform(renderer)}setLayerTransform(e){C3X.RequireInstanceOf(e,globalThis.ILayer);const t=runtime._UnwrapScriptInterface(e);t._SetTransform(renderer)}}}{const C33=self.C3,C3X=self.C3X,map=new WeakMap,reverseMap=new WeakMap;self.ITexture=class{constructor(e,t){map.set(this,{runtime:e,texture:t}),reverseMap.set(t,this),e._MapScriptInterface(this,t),Object.defineProperties(this,{width:{value:t.GetWidth(),writable:!1},height:{value:t.GetHeight(),writable:!1}})}static GetInterface(e,t){if(!t)return null;const s=reverseMap.get(t);return s||new self.ITexture(e,t)}}}{let getActual2=function(e){return map.get(e).rendererText};getActual=getActual2;const C33=self.C3,C3X=self.C3X,map=new WeakMap;self.IRendererText=class{constructor(e,t){map.set(this,{runtime:e,rendererText:t}),e._MapScriptInterface(this,t)}release(){getActual2(this).Release()}set fontFace(e){C3X.RequireString(e),getActual2(this).SetFontName(e)}get fontFace(){return getActual2(this).GetFontName()}set sizePt(e){C3X.RequireFiniteNumber(e),getActual2(this).SetFontSize(e)}get sizePt(){return getActual2(this).GetFontSize()}set lineHeight(e){C3X.RequireFiniteNumber(e),getActual2(this).SetLineHeight(e)}get lineHeight(){return getActual2(this).GetLineHeight()}set isBold(e){getActual2(this).SetBold(e)}get isBold(){return getActual2(this).IsBold()}set isItalic(e){getActual2(this).SetItalic(e)}get isItalic(){return getActual2(this).IsItalic()}setColor(e){C3X.RequireArray(e),this.setColorRgb(e[0],e[1],e[2])}setColorRgb(e,t,s){getActual2(this).SetColorRgb(e,t,s)}setCssColor(e){C3X.RequireString(e),getActual2(this).SetColor(e)}set horizontalAlign(e){getActual2(this).SetHorizontalAlignment(e)}get horizontalAlign(){return getActual2(this).GetHorizontalAlignment()}set verticalAlign(e){getActual2(this).SetVerticalAlignment(e)}get verticalAlign(){return getActual2(this).GetVerticalAlignment()}set wordWrapMode(e){getActual2(this).SetWordWrapMode(e)}get wordWrapMode(){return getActual2(this).GetWordWrapMode()}set textDirection(e){getActual2(this).SetTextDirection(e)}get textDirection(){return getActual2(this).GetTextDirection()}set text(e){C3X.RequireString(e),getActual2(this).SetText(e)}get text(){return getActual2(this).GetText()}setSize(e,t,s){C3X.RequireFiniteNumber(e),C3X.RequireFiniteNumber(t),C3X.RequireFiniteNumber(s),getActual2(this).SetSize(e,t,s)}getTexture(){const{runtime:e,rendererText:t}=map.get(this),s=t.GetTexture();return self.ITexture.GetInterface(e,s)}getTexRect(){return getActual2(this).GetTexRect().toDOMRect()}setTextureUpdateCallback(e){C3X.RequireFunction(e),getActual2(this).ontextureupdate=e}releaseTexture(){getActual2(this).ReleaseTexture()}get textWidth(){return getActual2(this).GetTextWidth()}get textHeight(){return getActual2(this).GetTextHeight()}}}{let GetTypeFromFileExtension2=function(e){if(!e)return"";const t=e.split(".");if(t.length<2)return"";const s=t.at(-1).toLowerCase();return EXT_TO_TYPE.get(s)||""},AddScript2=function(i){return new Promise((e,t)=>{const s=document.createElement("script");s.onload=e,s.onerror=t,s.async=!1,s.type="module",s.src=i,document.head.appendChild(s)})};GetTypeFromFileExtension=GetTypeFromFileExtension2,AddScript=AddScript2;const C33=self.C3,VALID_LOAD_POLICIES=new Set(["local","remote"]),EXT_TO_TYPE=new Map([["mp4","video/mp4"],["webm","video/webm"],["m4a","audio/mp4"],["mp3","audio/mpeg"],["js","application/javascript"],["wasm","application/wasm"],["svg","image/svg+xml"],["html","text/html"]]);C33.AssetManager=class extends C33.DefendedBase{constructor(e,t){super();const s=t.exportType,i=(this._runtime=e,this._fileStructure="folders",this._cordovaBlobUrlCache=new Map,this._isCordova="cordova"===s,this._isiOSCordova=!!t.isiOSCordova,this._isFileProtocol=!!t.isFileProtocol,this._swClientId=t.swClientId,this._supportedAudioFormats=t.supportedAudioFormats||{},this._audioFiles=new Map,this._preloadSounds=!1,this._scriptSubfolder=t.scriptFolder,this._mediaSubfolder="",this._fontsSubfolder="",this._iconsSubfolder="",this._fileMap=t.fileMap||new Map,this._fileMapBlobUrls=new Map,"html5"===s||"scirra-arcade"===s||"instant-games"===s);this._defaultLoadPolicy=i?"remote":"local",this._assetsByUrl=new Map,this._webFonts=[],this._loadPromises=[],this._hasFinishedInitialLoad=!1,this._totalAssetSizeToLoad=0,this._assetSizeLoaded=0,this._lastLoadProgress=0,this._hasHadErrorLoading=!1,this._loadingRateLimiter=C33.New(C33.RateLimiter,()=>this._FireLoadingProgressEvent(),50),this._localPromiseThrottle=C33.New(C33.PromiseThrottle,Math.max(C33.hardwareConcurrency,8)),this._remotePromiseThrottle=C33.New(C33.PromiseThrottle,20),this._iAssetManager=new self.IAssetManager(this)}Release(){for(const e of this._assetsByUrl.values())e.Release();this._assetsByUrl.clear(),C33.clearArray(this._loadPromises),this._runtime=null}GetRuntime(){return this._runtime}_SetFileStructure(e){this._fileStructure=e}GetFileStructure(){return this._fileStructure}GetScriptSubfolder(){return this._scriptSubfolder}_SetMediaSubfolder(e){this._mediaSubfolder=e}GetMediaSubfolder(){return this._mediaSubfolder}_SetFontsSubfolder(e){this._fontsSubfolder=e}GetFontsSubfolder(){return this._fontsSubfolder}_SetIconsSubfolder(e){this._iconsSubfolder=e}GetIconsSubfolder(){return this._iconsSubfolder}IsFileProtocol(){return this._isFileProtocol}FetchBlob(e,t){return t=t||this._defaultLoadPolicy,C33.IsRelativeURL(e)?("flat"===this._fileStructure&&(e=e.toLowerCase()),this._isCordova&&this._isFileProtocol?this.CordovaFetchLocalFileAsBlob(e):"playable-ad-single-file"===this._runtime.GetExportType()?self.c3_runtimeInterface._PlayableAdFetchBlob(e):("local"===t?this._localPromiseThrottle:this._remotePromiseThrottle).Add(()=>C33.FetchBlob(e))):C33.FetchBlob(e)}FetchArrayBuffer(e){return C33.IsRelativeURL(e)?("flat"===this._fileStructure&&(e=e.toLowerCase()),this._isCordova&&this._isFileProtocol?this.CordovaFetchLocalFileAsArrayBuffer(e):"playable-ad-single-file"===this._runtime.GetExportType()?C33.BlobToArrayBuffer(self.c3_runtimeInterface._PlayableAdFetchBlob(e)):("local"===this._defaultLoadPolicy?this._localPromiseThrottle:this._remotePromiseThrottle).Add(()=>C33.FetchArrayBuffer(e))):C33.FetchArrayBuffer(e)}FetchText(e){return C33.IsRelativeURL(e)?("flat"===this._fileStructure&&(e=e.toLowerCase()),this._isCordova&&this._isFileProtocol?this.CordovaFetchLocalFileAsText(e):"playable-ad-single-file"===this._runtime.GetExportType()?C33.BlobToString(self.c3_runtimeInterface._PlayableAdFetchBlob(e)):("local"===this._defaultLoadPolicy?this._localPromiseThrottle:this._remotePromiseThrottle).Add(()=>C33.FetchText(e))):C33.FetchText(e)}async FetchJson(e){const t=await this.FetchText(e);return JSON.parse(t)}_CordovaFetchLocalFileAs(e,t){return"flat"===this._fileStructure&&(e=e.toLowerCase()),this._runtime.PostComponentMessageToDOMAsync("runtime","cordova-fetch-local-file",{filename:e,as:t})}CordovaFetchLocalFileAsText(e){return this._CordovaFetchLocalFileAs(e,"text")}async CordovaFetchLocalFileAsBlob(e){const t=await this._CordovaFetchLocalFileAs(e,"buffer"),s=GetTypeFromFileExtension2(e);return new Blob([t],{type:s})}async CordovaFetchLocalFileAsBlobURL(e){"flat"===this._fileStructure&&(e=e.toLowerCase());let t=this._cordovaBlobUrlCache.get(e);if(!t){const s=await this.CordovaFetchLocalFileAsBlob(e);t=URL.createObjectURL(s),this._cordovaBlobUrlCache.set(e,t)}return t}CordovaFetchLocalFileAsArrayBuffer(e){return this._CordovaFetchLocalFileAs(e,"buffer")}GetMediaFileUrl(e){"flat"===this._fileStructure&&(e=e.toLowerCase());let t=this._mediaSubfolder+e;return"Gecko"===C33.Platform.BrowserEngine&&"preview"===this._runtime.GetExportType()?this._GetLocalBlobURLFromFileMap(t):t}GetProjectFileUrl(e){return C33.IsAbsoluteURL(e)?Promise.resolve(e):this._isCordova&&this._isFileProtocol?this.CordovaFetchLocalFileAsBlobURL(e):"playable-ad-single-file"===this._runtime.GetExportType()?URL.createObjectURL(self.c3_runtimeInterface._PlayableAdFetchBlob(e)):("flat"===this._fileStructure&&(e=e.toLowerCase()),Promise.resolve(e))}GetProjectFileIframeUrl(t){if(C33.IsAbsoluteURL(t)||"preview"!==this._runtime.GetExportType()||!this._swClientId||!t)return t;try{const e=new URL(t,location.href);return e.searchParams.set("__c3_client_id",this._swClientId),e.toString()}catch(e){return console.warn("Invalid iframe URL: "+t),t}}LoadProjectFileUrl(e){return this.GetProjectFileUrl(e)}LoadImage(e){if(e.loadPolicy&&!VALID_LOAD_POLICIES.has(e.loadPolicy))throw new Error("invalid load policy");let t=this._assetsByUrl.get(e.url);return t||(t=C33.New(C33.ImageAsset,this,{url:e.url,size:e.size||0,loadPolicy:e.loadPolicy||this._defaultLoadPolicy}),this._assetsByUrl.set(t.GetURL(),t),this._hasFinishedInitialLoad)||(this._totalAssetSizeToLoad+=t.GetSize(),this._loadPromises.push(t.Load().then(()=>this._AddLoadedSize(t.GetSize())))),t}_ReleaseAsset(e){this._assetsByUrl.delete(e.GetURL())}async WaitForAllToLoad(){try{await Promise.all(this._loadPromises),this._lastLoadProgress=1}catch(e){console.error("Error loading: ",e),this._hasHadErrorLoading=!0,this._FireLoadingProgressEvent()}}SetInitialLoadFinished(){this._hasFinishedInitialLoad=!0}HasHadErrorLoading(){return this._hasHadErrorLoading}_AddLoadedSize(e){this._assetSizeLoaded+=e,this._loadingRateLimiter.Call()}_FireLoadingProgressEvent(){const e=C33.New(C33.Event,"loadingprogress");this._lastLoadProgress=C33.clamp(this._assetSizeLoaded/this._totalAssetSizeToLoad,0,1),e.progress=this._lastLoadProgress,this._runtime.Dispatcher().dispatchEvent(e)}GetLoadProgress(){return this._lastLoadProgress}GetImageLoadProgress(){return this._runtime.GetSystemPlugin().GetImageLoadingProgress()}_SetWebFonts(e){C33.shallowAssignArray(this._webFonts,e),this._webFonts.length&&this._loadPromises.push(this._LoadWebFonts())}async _LoadWebFonts(){const e=[],t=[];for(const[s,i,r]of this._webFonts)this._totalAssetSizeToLoad+=r,e.push(this._LoadWebFont(s,i,t).then(()=>this._AddLoadedSize(r)));await Promise.all(e),this._runtime.IsInWorker()&&0<t.length&&await this._runtime.PostComponentMessageToDOMAsync("runtime","load-webfonts",{webfonts:t})}async _LoadWebFont(t,s,i){try{let e=await this.GetProjectFileUrl(s);"Gecko"===C33.Platform.BrowserEngine&&(t=`'${t}'`),("Gecko"===C33.Platform.BrowserEngine&&"preview"===this._runtime.GetExportType()||"playable-ad-single-file"===this._runtime.GetExportType())&&(e=this._GetLocalBlobURLFromFileMap(e));const r=new FontFace(t,`url('${e}')`);(this._runtime.IsInWorker()?self:document).fonts.add(r),await r.load(),this._runtime.IsInWorker()&&i.push({name:t,url:e})}catch(e){console.warn(`[C3 runtime] Failed to load web font '${t}': `,e)}}IsAudioFormatSupported(e){return!!this._supportedAudioFormats[e]}_SetAudioFiles(e,t){this._preloadSounds=!!t;for(const[s,i,r]of e)this._audioFiles.set(s,{fileName:s,formats:i.map(e=>({type:e[0],fileExtension:e[1],fullName:s+e[1],fileSize:e[2]})),isMusic:r})}GetPreferredAudioFile(e){"flat"===this._fileStructure&&(e=e.toLowerCase());const t=this._audioFiles.get(e);if(!t)return null;let s=null;for(const i of t.formats)if(s||"audio/webm; codecs=opus"!==i.type||(s=i),this.IsAudioFormatSupported(i.type))return i;return s}GetProjectAudioFileUrl(e){const t=this.GetPreferredAudioFile(e);return t?{url:this.GetMediaFileUrl(t.fullName),type:t.type}:null}GetAudioToPreload(){if(this._preloadSounds){const e=[];for(const t of this._audioFiles.values())if(!t.isMusic){const s=this.GetPreferredAudioFile(t.fileName);s&&e.push({originalUrl:t.fileName,url:this.GetMediaFileUrl(s.fullName),type:s.type,fileSize:s.fileSize})}return e}return[]}_GetLocalBlobFromFileMap(e){return"preview"===this._runtime.GetExportType()&&(e=new URL(e,location.href).toString()),this._fileMap.get(e)||null}_GetLocalBlobURLFromFileMap(e){let t=this._fileMapBlobUrls.get(e);if(!t){const s=this._GetLocalBlobFromFileMap(e);if(!s)return e;t=URL.createObjectURL(s),this._fileMapBlobUrls.set(e,t)}return t}GetIAssetManager(){return this._iAssetManager}async LoadScripts(...e){const t=await Promise.all(e.map(e=>this.GetProjectFileUrl(e)));if(this._runtime.IsInWorker())if(1===e.length){const s=e[0];await import((C33.IsRelativeURL(s)?"./":"")+s)}else{const i=e.map(e=>`import "${C33.IsRelativeURL(e)?"./":""}${e}";`).join("\n"),r=URL.createObjectURL(new Blob([i],{type:"application/javascript"}));await import(r)}else await Promise.all(t.map(e=>AddScript2(e)))}async CompileWebAssembly(e){if(WebAssembly.compileStreaming){const t=await this.GetProjectFileUrl(e);return WebAssembly.compileStreaming(fetch(t))}{const s=await C33.FetchArrayBuffer(e);return WebAssembly.compile(s)}}async LoadStyleSheet(e){const t=await this.GetProjectFileUrl(e);return this._runtime.PostComponentMessageToDOMAsync("runtime","add-stylesheet",{url:t})}}}{const C33=self.C3;C33.Asset=class extends C33.DefendedBase{constructor(e,t){super(),this._assetManager=e,this._runtime=e.GetRuntime(),this._url=t.url||"",this._size=t.size,this._loadPolicy=t.loadPolicy,this._blob=t.blob||null,this._isLoaded=!!this._blob,this._loadPromise=null}Release(){this._loadPromise=null,this._assetManager=null,this._runtime=null,this._blob=null}GetURL(){return this._url}GetSize(){return this._size}Load(){return"local"===this._loadPolicy||this._blob?(this._isLoaded=!0,Promise.resolve()):(this._loadPromise||(this._loadPromise=this._assetManager.FetchBlob(this._url,this._loadPolicy).then(e=>(this._isLoaded=!0,this._loadPromise=null,this._blob=e)).catch(e=>{console.error("Error loading resource: ",e),this._loadPromise=null})),this._loadPromise)}IsLoaded(){return this._isLoaded}GetBlob(){return this._blob?Promise.resolve(this._blob):this._loadPromise||this._assetManager.FetchBlob(this._url,this._loadPolicy)}}}{const C33=self.C3,promiseThrottle=new C33.PromiseThrottle,allImageAssets=new Set;C33.ImageAsset=class extends C33.Asset{constructor(e,t){super(e,t),this._texturePromise=null,this._webglTexture=null,this._refCount=0,this._imageWidth=-1,this._imageHeight=-1,allImageAssets.add(this)}Release(){if(0!==this._refCount)throw new Error("released image asset which still has texture references");this._assetManager._ReleaseAsset(this),this._texturePromise=null,allImageAssets.delete(this),super.Release()}static OnRendererContextLost(){for(const e of allImageAssets)e._texturePromise=null,e._webglTexture=null,e._refCount=0}LoadStaticTexture(e,t){return t=t||{},this._refCount++,this._webglTexture?Promise.resolve(this._webglTexture):(this._texturePromise||(t.anisotropy=this._runtime.GetCanvasManager().GetTextureAnisotropy(),this._texturePromise=this._DoLoadStaticTexture(e,t)),this._texturePromise)}async _DoLoadStaticTexture(t,s){try{const i=await this.GetBlob();return 0===this._refCount?this._texturePromise=null:await promiseThrottle.Add(async()=>{const e=await t.CreateStaticTextureAsync(i,s);return this._texturePromise=null,0===this._refCount?(t.DeleteTexture(e),null):(this._webglTexture=e,this._imageWidth=e.GetWidth(),this._imageHeight=e.GetHeight(),this._webglTexture)})}catch(e){throw console.error("Failed to load texture: ",e),e}}ReleaseTexture(){if(this._refCount<=0)throw new Error("texture released too many times");if(this._refCount--,0===this._refCount&&this._webglTexture){const e=this._webglTexture.GetRenderer();e.DeleteTexture(this._webglTexture),this._webglTexture=null}}GetRefCount(){return this._refCount}GetTexture(){return this._webglTexture}GetWidth(){return this._imageWidth}GetHeight(){return this._imageHeight}async LoadToDrawable(){const e=await this.GetBlob();return C33.Supports.ImageBitmap?createImageBitmap(e):C33.BlobToImage(e)}}}{let SortByInstLastCachedZIndex2=function(e,t){return e.GetWorldInfo()._GetLastCachedZIndex()-t.GetWorldInfo()._GetLastCachedZIndex()};SortByInstLastCachedZIndex=SortByInstLastCachedZIndex2;const C33=self.C3,assert=self.assert;C33.RenderCell=class extends C33.DefendedBase{constructor(e,t,s){super(),this._grid=e,this._x=t,this._y=s,this._instances=[],this._isSorted=!0,this._pendingRemoval=new Set,this._isAnyPendingRemoval=!1}Release(){C33.clearArray(this._instances),this._pendingRemoval.clear(),this._grid=null}Reset(){C33.clearArray(this._instances),this._isSorted=!0,this._pendingRemoval.clear(),this._isAnyPendingRemoval=!1}SetChanged(){this._isSorted=!1}IsEmpty(){if(this._instances.length){if(this._instances.length>this._pendingRemoval.size)return!1;this._FlushPending()}return!0}Insert(e){this._pendingRemoval.has(e)?(this._pendingRemoval.delete(e),0===this._pendingRemoval.size&&(this._isAnyPendingRemoval=!1)):(this._instances.push(e),this._isSorted=1===this._instances.length)}Remove(e){this._pendingRemoval.add(e),this._isAnyPendingRemoval=!0,50<=this._pendingRemoval.size&&this._FlushPending()}_FlushPending(){this._isAnyPendingRemoval&&(this._instances.length===this._pendingRemoval.size?this.Reset():(C33.arrayRemoveAllInSet(this._instances,this._pendingRemoval),this._pendingRemoval.clear(),this._isAnyPendingRemoval=!1))}_EnsureSorted(){this._isSorted||(this._instances.sort(SortByInstLastCachedZIndex2),this._isSorted=!0)}Dump(e){this._FlushPending(),this._EnsureSorted(),this._instances.length&&e.push(this._instances)}}}{const C33=self.C3;C33.RenderGrid=class extends C33.DefendedBase{constructor(e,t){super(),this._cellWidth=e,this._cellHeight=t,this._cells=C33.New(C33.PairMap)}Release(){this._cells.Release(),this._cells=null}GetCell(e,t,s){let i=this._cells.Get(e,t);return i||(s?(i=C33.New(C33.RenderCell,this,e,t),this._cells.Set(e,t,i),i):null)}XToCell(e){return Math.floor(e/this._cellWidth)}YToCell(e){return Math.floor(e/this._cellHeight)}Update(i,r,n){if(r)for(let s=r.getLeft(),e=r.getRight();s<=e;++s)for(let e=r.getTop(),t=r.getBottom();e<=t;++e)if(!n||!n.containsPoint(s,e)){const a=this.GetCell(s,e,!1);a&&(a.Remove(i),a.IsEmpty())&&this._cells.Delete(s,e)}if(n)for(let s=n.getLeft(),e=n.getRight();s<=e;++s)for(let e=n.getTop(),t=n.getBottom();e<=t;++e)r&&r.containsPoint(s,e)||this.GetCell(s,e,!0).Insert(i)}QueryRange(e,t){let s=this.XToCell(e.getLeft()),i=this.YToCell(e.getTop()),r=this.XToCell(e.getRight()),n=this.YToCell(e.getBottom());for(;s<=r;++s)for(let e=i;e<=n;++e){const a=this.GetCell(s,e,!1);a&&a.Dump(t)}}MarkRangeChanged(e){let t=e.getLeft(),s=e.getTop(),i=e.getRight(),r=e.getBottom();for(;t<=i;++t)for(let e=s;e<=r;++e){const n=this.GetCell(t,e,!1);n&&n.SetChanged()}}}}{let SortByInstLastCachedZIndex2=function(e,t){return e.GetWorldInfo()._GetLastCachedZIndex()-t.GetWorldInfo()._GetLastCachedZIndex()},SortByInstZElevation2=function(e,t){return e.GetWorldInfo().GetZElevation()-t.GetWorldInfo().GetZElevation()};SortByInstLastCachedZIndex=SortByInstLastCachedZIndex2,SortByInstZElevation=SortByInstZElevation2;const C33=self.C3,assert=self.assert,tmpRect=new C33.Rect,tmpQuad=new C33.Quad,renderCellArr=[],tmpDestRect=new C33.Rect,tmpSrcRect=new C33.Rect,glMatrix=self.glMatrix,vec32=glMatrix.vec3,vec42=glMatrix.vec4,mat42=glMatrix.mat4,tempMat4=mat42.create(),tempVec3=vec32.create(),tempVec4=vec42.create(),camVector=vec32.create(),lookVector=vec32.create(),upVector=vec32.create(),tempVec2=C33.New(C33.Vector2),tempRect=C33.New(C33.Rect),tempInstanceList1=[],tempInstanceList2=[],tempInstancesByCameraDist=[],DEFAULT_LAYER_OPTIONS={name:"",sid:-1,isDynamic:!1,isVisible:!0,isInteractive:!0,isHTMLElementsLayer:!1,backgroundColor:[1,1,1,1],isTransparent:!0,parallax:[1,1],opacity:1,isForceOwnTexture:!1,renderAs3d:!1,useCameraDistanceDrawOrder:!1,useRenderCells:!1,scaleRate:1,blendMode:0,zElevation:0,initialInstancesData:[],effectListData:[],subLayersData:[]};C33.Layer=class extends C33.DefendedBase{constructor(e,t,s){super(),s=Object.assign({},DEFAULT_LAYER_OPTIONS,s),this._layout=e,this._runtime=e.GetRuntime(),this._parentLayer=t,this._name=s.name,this._index=-1,this._isHTMLElementsLayer=!!s.isHTMLElementsLayer,this._htmlIndex=-1,this._sid=s.sid,this._isDynamic=!!s.isDynamic,this._isVisible=!!s.isVisible,this._isInteractive=!!s.isInteractive,this._backgroundColor=C33.New(C33.Color),this._backgroundColor.setFromJSON(s.backgroundColor),this._isTransparent=!!s.isTransparent,this._parallaxX=s.parallax[0],this._parallaxY=s.parallax[1],this._color=C33.New(C33.Color,1,1,1,s.opacity),this._premultipliedColor=C33.New(C33.Color),this._isForceOwnTexture=!!s.isForceOwnTexture,this._renderAs3d=!!s.renderAs3d,this._useCameraDistanceDrawOrder=!!s.useCameraDistanceDrawOrder,this._useRenderCells=!!s.useRenderCells,this._scaleRate=s.scaleRate,this._blendMode=s.blendMode,this._curRenderTarget=null,this._scale=1,this._zElevation=s.zElevation,this._angle=0,this._scrollX=0,this._scrollY=0,this._hasOwnScrollPosition=!1,this._viewport=C33.New(C33.Rect),this._viewportZ0=C33.New(C33.Rect),this._viewport3D=C33.New(C33.Rect),this._isViewportChanged=!0,this._projectionMatrix=mat42.create(),this._isProjectionMatrixChanged=!0,this._modelViewMatrix=mat42.create(),this._isMVMatrixChanged=!0,this._viewFrustum=C33.New(C33.Gfx.ViewFrustum),this._isViewFrustumChanged=!0,this._startupInitialInstances=[],this._initialInstancesData=s.initialInstancesData,this._initialInstances=[],this._createdGlobalUids=[],this._initialUIDsToInstanceData=new Map,this._instances=[],this._zIndicesUpToDate=!1,this._htmlZIndicesUpToDate=!1,this._anyInstanceZElevated=!1;const r=this._runtime.GetCanvasManager();this._effectList=C33.New(C33.EffectList,this,s.effectListData),this._effectChain=C33.New(C33.Gfx.EffectChain,r.GetEffectChainManager(),{drawContent:(e,t)=>{const s=t.GetContentObject(),i=s.GetRenderTarget();e.SetColor(s.GetPremultipliedColor()),e.DrawRenderTarget(i),e.InvalidateRenderTarget(i),r.ReleaseAdditionalRenderTarget(i)},getShaderParameters:e=>this.GetEffectList()._GetEffectChainShaderParametersForIndex(e)}),this._needsRebuildEffectChainSteps=!0,this._wasDefaultColor=!0,this._renderGrid=null,this._lastRenderList=[],this._isRenderListUpToDate=!1,this._lastRenderCells=C33.New(C33.Rect,0,0,-1,-1),this._curRenderCells=C33.New(C33.Rect,0,0,-1,-1),this._iLayer=new self.ILayer(this),this._UpdatePremultipliedColor(),this.UsesRenderCells()&&(this._renderGrid=C33.New(C33.RenderGrid,this._runtime.GetOriginalViewportWidth(),this._runtime.GetOriginalViewportHeight())),this._subLayers=s.subLayersData.map(e=>C33.Layer.CreateFromExportData(this._layout,this,e))}_InitInitialInstances(){for(const e of this._initialInstancesData){const t=this._runtime.GetObjectClassByIndex(e[1]);this._layout._AddInitialObjectClass(t),t.GetDefaultInstanceData()||(t.SetDefaultInstanceData(e),t._SetDefaultLayerIndex(this._index)),this._initialInstances.push(e),this._initialUIDsToInstanceData.set(e[2],e)}C33.shallowAssignArray(this._startupInitialInstances,this._initialInstances),this._initialInstancesData=null}static CreateFromExportData(e,t,s){return C33.New(C33.Layer,e,t,{name:s[0],sid:s[2],isVisible:s[3],isInteractive:s[13],isHTMLElementsLayer:s[19],backgroundColor:s[4].map(e=>e/255),isTransparent:s[5],parallax:[s[6],s[7]],opacity:s[8],isForceOwnTexture:s[9],renderAs3d:s[17],useCameraDistanceDrawOrder:s[18],useRenderCells:s[10],scaleRate:s[11],blendMode:s[12],zElevation:s[16],initialInstancesData:s[14],effectListData:s[15],subLayersData:s[20]})}Release(){for(const e of this._subLayers)e.Release();C33.clearArray(this._subLayers);for(const t of this._instances)this._runtime.DestroyInstance(t);C33.clearArray(this._instances),this._effectList.Release(),this._effectList=null,this._effectChain.Release(),this._effectChain=null,this._iLayer=null,this._parentLayer=null,this._layout=null,this._runtime=null}GetInitialInstanceData(e){return this._initialUIDsToInstanceData.get(e)}CreateInitialInstances(r){let n=this._layout.IsFirstVisit(),a=0,o=this._initialInstances;for(let i=0,e=o.length;i<e;++i){let e=o[i],t=this._runtime.GetObjectClassByIndex(e[1]),s=!0;if(!t.HasPersistBehavior()||n){const l=this._runtime.CreateInstanceFromData(e,this,!0);r.push(l),t.IsGlobal()&&(s=!1,this._createdGlobalUids.push(l.GetUID()))}s&&(o[a]=o[i],++a)}C33.truncateArray(o,a),this._runtime.FlushPendingInstances(),this.SetZIndicesChanged()}_AddInstance(e,t){if(!e.GetPlugin().IsWorldType())throw new Error("instance is not of world type");const s=e.GetWorldInfo();if(s.GetLayer()!==this)throw new Error("instance added to wrong layer");this._instances.push(e),0!==s.GetZElevation()&&(this._anyInstanceZElevated=!0),t&&this.UsesRenderCells()&&e.GetWorldInfo().SetBboxChanged(),this.SetZIndicesChanged(e)}_MaybeAddInstance(e){this._instances.includes(e)||(this._instances.push(e),0!==e.GetWorldInfo().GetZElevation()&&(this._anyInstanceZElevated=!0),this.SetZIndicesChanged(e))}_PrependInstance(e,t){const s=e.GetWorldInfo();if(s.GetLayer()!==this)throw new Error("instance added to wrong layer");this._instances.unshift(e),0!==s.GetZElevation()&&(this._anyInstanceZElevated=!0),this.SetZIndicesChanged(e),t&&this.UsesRenderCells()&&e.GetWorldInfo().SetBboxChanged()}_RemoveInstance(e,t){const s=this._instances.indexOf(e);s<0||(t&&this.UsesRenderCells()&&e.GetWorldInfo()._RemoveFromRenderCells(),this._instances.splice(s,1),this.SetZIndicesChanged(e),this._MaybeResetAnyInstanceZElevatedFlag())}_SetAnyInstanceZElevated(){this._anyInstanceZElevated=!0}_MaybeResetAnyInstanceZElevatedFlag(){0===this._instances.length&&(this._anyInstanceZElevated=!1)}_SortInstancesByLastCachedZIndex(e){if(e){const t=new Set;for(const s of this._instances){const i=s.GetWorldInfo()._GetLastCachedZIndex();0<=i&&t.add(i)}let e=-1;for(const r of this._instances){const n=r.GetWorldInfo();if(!(0<=n._GetLastCachedZIndex())){for(++e;t.has(e);)++e;n._SetZIndex(e)}}}this._instances.sort(SortByInstLastCachedZIndex2)}_Start(){}_End(){for(const e of this._instances)e.GetObjectClass().IsGlobal()||this._runtime.DestroyInstance(e);this._runtime.FlushPendingInstances(),C33.clearArray(this._instances),this._anyInstanceZElevated=!1,this.SetZIndicesChanged()}RecreateInitialObjects(t,e,s,i,r,n){const a=this._runtime.GetEventSheetManager(),o=this._runtime.GetAllObjectClasses(),l=t.IsFamily(),h=[];for(const c of this._initialInstances){const u=c[0],_=u[0],d=u[1];if(e.containsPoint(_,d)){const p=o[c[1]];if(p!==t){if(!l)continue;if(!t.FamilyHasMember(p))continue}let e=r;if(!e){const f=this._runtime.GetCurrentLayout();e=this.GetLayout()===f?this:(e=f.GetLayerByName(this.GetName()))||f.GetLayerByIndex(this.GetIndex())}const m=this._runtime.CreateInstanceFromData(c,e,!1,void 0,void 0,!1,n),g=(e.SortAndAddInstancesByZIndex(m),m.GetWorldInfo());g.OffsetXY(s,i),g.SetBboxChanged(),a.BlockFlushingInstances(!0),m._TriggerOnCreatedOnSelfAndRelated(),a.BlockFlushingInstances(!1),h.push(m)}}return h}GetInstanceCount(){return this._instances.length}GetLayout(){return this._layout}GetName(){return this._name}_SetIndex(e){this._index=e}GetIndex(){return this._index}_SetHTMLIndex(e){this._htmlIndex=e}GetHTMLIndex(){return this._htmlIndex}IsHTMLElementsLayer(){return this._isHTMLElementsLayer}SetIsHTMLElementsLayer(e){this._isHTMLElementsLayer!==(e=!!e)&&(this._isHTMLElementsLayer=e,this._layout._ReindexAndUpdateAllLayers(),this._runtime.UpdateRender())}_GetSiblingIndex(){let e=this.GetParentLayer();return(e?e.GetSubLayers():this.GetLayout()._GetRootLayers()).indexOf(this)}GetSID(){return this._sid}GetRuntime(){return this._runtime}IsDynamic(){return this._isDynamic}HasAnyDynamicParentLayer(){for(const e of this.parentLayers())if(e.IsDynamic())return!0;return!1}GetDevicePixelRatio(){return this._runtime.GetDevicePixelRatio()}GetEffectList(){return this._effectList}GetEffectChain(){return this._MaybeRebuildEffectChainSteps(),this._effectChain}_MaybeRebuildEffectChainSteps(){const e=this.HasDefaultColor();if(this._needsRebuildEffectChainSteps||e!==this._wasDefaultColor||this._effectChain.NeedsRebuild()){const t=this.GetEffectList().GetActiveEffectTypes();this._effectChain.BuildSteps(t.map(e=>e.GetShaderProgram()),{indexMap:t.map(e=>e.GetIndex()),forcePreDraw:!e,useFullSurface:!0}),this._needsRebuildEffectChainSteps=!1,this._wasDefaultColor=e}}UpdateActiveEffects(){this.GetEffectList().UpdateActiveEffects(),this._needsRebuildEffectChainSteps=!0}UsesRenderCells(){return this._useRenderCells&&!this._useCameraDistanceDrawOrder}GetRenderGrid(){return this._renderGrid}SetRenderListStale(){this._isRenderListUpToDate=!1}IsVisible(){for(const e of this.selfAndParentLayers())if(!e._IsVisibleFlagSet())return!1;return!0}_IsVisibleFlagSet(){return this._isVisible}SetVisible(e){this._isVisible!==(e=!!e)&&(this._isVisible=e,this._runtime.UpdateRender())}SetInteractive(e){this._isInteractive=!!e}IsInteractive(){return this._isInteractive}IsSelfAndParentsInteractive(){for(const e of this.selfAndParentLayers())if(!e.IsInteractive())return!1;return!0}SetOwnScrollPositionEnabled(e){if(this._hasOwnScrollPosition!==(e=!!e)){if(this._hasOwnScrollPosition=e){const t=this.GetLayout();this._scrollX=t.GetScrollX(),this._scrollY=t.GetScrollY()}this._SetMVMatrixChanged(),this._runtime.UpdateRender()}}IsOwnScrollPositionEnabled(){return this._hasOwnScrollPosition}SetScrollX(e){const t=this.GetLayout(),s=t.GetScrollLeftBound(),i=t.GetScrollRightBound();this._scrollX!==(e=(e=i<e?i:e)<s?s:e)&&(this._scrollX=e,this.IsOwnScrollPositionEnabled())&&(this._SetMVMatrixChanged(),this._runtime.UpdateRender())}SetScrollY(e){const t=this.GetLayout(),s=t.GetScrollTopBound(),i=t.GetScrollBottomBound();this._scrollY!==(e=(e=i<e?i:e)<s?s:e)&&(this._scrollY=e,this.IsOwnScrollPositionEnabled())&&(this._SetMVMatrixChanged(),this._runtime.UpdateRender())}GetScrollX(){return this.IsOwnScrollPositionEnabled()?this._scrollX:this.GetLayout().GetScrollX()}GetScrollY(){return this.IsOwnScrollPositionEnabled()?this._scrollY:this.GetLayout().GetScrollY()}GetViewport(){return this._MaybeUpdateViewport(),this._viewport}_GetViewportZ0(){return this._MaybeUpdateViewport(),this._viewportZ0}GetViewport3D(){return this._MaybeUpdateViewport(),this._viewport3D}_GetVanishingPoint(){const e=this.GetLayout();return[e.GetVanishingPointX(),e.GetVanishingPointY()]}GetDefaultCameraZ(e){return this._runtime.GetDefaultCameraZ(e)}GetViewportForZ(u,i){const r=this._GetViewportZ0();if(0===u)i.copy(r);else{let o=r.midX(),l=r.midY(),e=this.Get2DScaleFactorToZ(u),t=r.width()/e,s=r.height()/e,[h,c]=this._GetVanishingPoint();if(.5!==h||.5!==c){let e=this.Get2DCameraZ(),t=this._runtime,s=this.GetDefaultCameraZ()/e,i=(h-.5)*t.GetViewportWidth()/s,r=(c-.5)*t.GetViewportHeight()/s,n=this.GetAngle(),a=(0!==n&&(tempVec2.set(i,r),tempVec2.rotate(n),i=tempVec2.getX(),r=tempVec2.getY()),C33.unlerp(e,0,u));o+=C33.lerp(i,0,a),l+=C33.lerp(r,0,a)}i.set(o-t/2,l-s/2,o+t/2,l+s/2)}}GetOpacity(){return this._color.getA()}SetOpacity(e){e=C33.clamp(e,0,1),this._color.getA()!==e&&(this._color.setA(e),this._UpdatePremultipliedColor(),this._runtime.UpdateRender())}_UpdatePremultipliedColor(){this._premultipliedColor.copy(this._color),this._premultipliedColor.premultiply()}GetPremultipliedColor(){return this._premultipliedColor}HasDefaultColor(){return this._color.equalsRgba(1,1,1,1)}GetScaleRate(){return this._scaleRate}SetScaleRate(e){this._scaleRate!==e&&(this._scaleRate=e,this._SetMVMatrixChanged(),this._runtime.UpdateRender())}GetParallaxX(){return this._parallaxX}GetParallaxY(){return this._parallaxY}SetParallax(e,t){this._parallaxX===e&&this._parallaxY===t||(this._parallaxX=e,this._parallaxY=t,this._SetMVMatrixChanged(),this._runtime.UpdateRender())}SetParallaxX(e){this.SetParallax(e,this.GetParallaxY())}SetParallaxY(e){this.SetParallax(this.GetParallaxX(),e)}SetZElevation(e){this._zElevation!==e&&(this._zElevation=e,this._runtime.UpdateRender())}GetZElevation(){return this._zElevation}SetAngle(e){e=C33.clampAngle(e),this._angle!==e&&(this._angle=e,this._SetMVMatrixChanged(),this._runtime.UpdateRender())}GetAngle(){return C33.clampAngle(this._layout.GetAngle()+this._angle)}GetOwnAngle(){return this._angle}HasInstances(){return 0<this._instances.length}_GetInstances(){return this._instances}_GetInstancesInDrawOrder(){return this.RendersIn3DMode()&&this._useCameraDistanceDrawOrder?(C33.shallowAssignArray(tempInstancesByCameraDist,this._GetInstances()),tempInstancesByCameraDist.sort((e,t)=>this._SortInstancesByCameraDistance(e,t)),tempInstancesByCameraDist):this._GetInstances()}_AppendAllInstancesIncludingSubLayersInDrawOrder(e){C33.appendArray(e,this._GetInstancesInDrawOrder());for(const t of this._subLayers)t.IsVisible()&&0<t.GetOpacity()&&t._AppendAllInstancesIncludingSubLayersInDrawOrder(e)}_SortInstancesByCameraDistance(e,t){const s=this.GetLayout().Get3DCameraPosition(),i=s[0],r=s[1],n=s[2],a=e.GetWorldInfo(),o=t.GetWorldInfo(),l=a.GetX()-i,h=a.GetY()-r,c=a.GetZElevation()-n,u=o.GetX()-i,_=o.GetY()-r,d=o.GetZElevation()-n;return u*u+_*_+d*d-(l*l+h*h+c*c)}GetBackgroundColor(){return this._backgroundColor}IsTransparent(){return this._isTransparent}SetTransparent(e){this._isTransparent!==(e=!!e)&&(this._isTransparent=e,this._runtime.UpdateRender())}IsForceOwnTexture(){return this._isForceOwnTexture}SetForceOwnTexture(e){this._isForceOwnTexture!==(e=!!e)&&(this._isForceOwnTexture=e,this._runtime.UpdateRender())}RendersIn2DMode(){return!this.GetRuntime().Uses3DFeatures()||!this._renderAs3d}RendersIn3DMode(){return!this.RendersIn2DMode()}Has3DCamera(){return this.RendersIn3DMode()&&this.GetLayout().Is3DCameraEnabled()}SelfAndAllSubLayersHave3DCamera(){if(!this.Has3DCamera())return!1;for(const e of this._subLayers)if(!e.SelfAndAllSubLayersHave3DCamera())return!1;return!0}SetBlendMode(e){this._blendMode!==e&&(this._blendMode=e,this._runtime.UpdateRender())}GetBlendMode(){return this._blendMode}IsRootLayer(){return!this._parentLayer}GetParentLayer(){return this._parentLayer}_SetParentLayer(e){this._parentLayer=e}GetSubLayers(){return this._subLayers}HasAnySubLayers(){return 0<this._subLayers.length}_AddSubLayer(e,t=!0){t?this._subLayers.push(e):this._subLayers.unshift(e)}_InsertSubLayer(e,t,s){let i=this._subLayers.indexOf(t);if(-1===i)throw new Error("cannot find layer to insert by");s&&++i,this._subLayers.splice(i,0,e)}_RemoveSubLayer(e){const t=this._subLayers.indexOf(e);if(-1===t)throw new Error("cannot find layer to remove");this._subLayers.splice(t,1)}HasAnyVisibleSubLayer(){for(const e of this._subLayers)if(e.ShouldDraw())return!0;return!1}*selfAndAllSubLayers(){for(const e of this._subLayers)yield*e.selfAndAllSubLayers();yield this}*parentLayers(){let e=this.GetParentLayer();for(;e;)yield e,e=e.GetParentLayer()}*selfAndParentLayers(){yield this,yield*this.parentLayers()}HasParentLayer(e){for(const t of this.parentLayers())if(t===e)return!0;return!1}IsTransformCompatibleWith(e){return this===e||this._parallaxX===e._parallaxX&&this._parallaxY===e._parallaxY&&this._scale===e._scale&&this._scaleRate===e._scaleRate&&this._angle===e._angle&&this.GetScrollX()===e.GetScrollX()&&this.GetScrollY()===e.GetScrollY()}SaveTransform(){return{parallaxX:this.GetParallaxX(),parallaxY:this.GetParallaxY(),scale:this.GetOwnScale(),scaleRate:this.GetScaleRate(),angle:this.GetOwnAngle(),hasOwnScroll:this.IsOwnScrollPositionEnabled(),scrollX:this.GetScrollX(),scrollY:this.GetScrollY()}}RestoreTransform(e){this.SetParallax(e.parallaxX,e.parallaxY),this.SetOwnScale(e.scale),this.SetScaleRate(e.scaleRate),this.SetAngle(e.angle),this.SetOwnScrollPositionEnabled(e.hasOwnScroll),this.SetScrollX(e.scrollX),this.SetScrollY(e.scrollY),this._MaybeUpdateViewport()}_RemoveAllInstancesInSet(e){if(0!==e.size){const t=C33.arrayRemoveAllInSet(this._instances,e);0<t&&(this._MaybeResetAnyInstanceZElevatedFlag(),this.SetZIndicesChanged())}}SetZIndicesChanged(e){this._zIndicesUpToDate=!1,this._isRenderListUpToDate=!1,e&&!e.GetObjectClass().GetPlugin().IsHTMLElementType()||(this._htmlZIndicesUpToDate=!1)}_UpdateZIndices(){if(!this._zIndicesUpToDate){if(this._instances.sort(SortByInstZElevation2),this.UsesRenderCells())for(let e=0,t=this._instances.length;e<t;++e){const s=this._instances[e].GetWorldInfo();s._SetZIndex(e),this._renderGrid.MarkRangeChanged(s.GetRenderCellRange())}else for(let e=0,t=this._instances.length;e<t;++e)this._instances[e].GetWorldInfo()._SetZIndex(e);this._zIndicesUpToDate=!0}}_UpdateHTMLZIndices(){if(!this._htmlZIndicesUpToDate){let e=this._layout.GetRootLayersForHTMLLayer(this.GetHTMLIndex()),t=e.map(e=>[...e.selfAndAllSubLayers()]).flat(),s=0;for(const i of t){for(const r of i._GetInstances())r.GetObjectClass().GetPlugin().IsHTMLElementType()&&r.GetWorldInfo()._SetHTMLZIndex(s++);i._SetHTMLZIndicesUpToDate()}}}_SetHTMLZIndicesUpToDate(){this._htmlZIndicesUpToDate=!0}_GetHTMLLayerDOMState(){return{isVisible:this.IsVisible(),opacity:this.GetOpacity(),isInteractive:this.IsInteractive()}}MoveInstanceAdjacent(e,t,s){const i=e.GetWorldInfo(),r=t.GetWorldInfo();if(i.GetLayer()!==this||r.GetLayer()!==this)throw new Error("can't arrange Z order unless both objects on this layer");let n=i.GetZIndex(),a=r.GetZIndex();return n!==a+(s?1:-1)&&(C33.arrayRemove(this._instances,n),n<a&&a--,s&&a++,a===this._instances.length?this._instances.push(e):this._instances.splice(a,0,e),this.SetZIndicesChanged(e),!0)}_MergeSortedZArrays(e,t){let s=[],i=0,r=0,n=e.length,a=t.length;for(;i<n&&r<a;){const o=e[i],l=t[r];o.GetWorldInfo()._GetLastCachedZIndex()<l.GetWorldInfo()._GetLastCachedZIndex()?(s.push(o),++i):(s.push(l),++r)}for(;i<n;++i)s.push(e[i]);for(;r<a;++r)s.push(t[r]);return s}_MergeAllSortedZArrays_pass(t){const s=[],i=t.length;for(let e=0;e<i-1;e+=2){const r=t[e],n=t[e+1];s.push(this._MergeSortedZArrays(r,n))}return i%2==1&&s.push(t[i-1]),s}_MergeAllSortedZArrays(e){for(;1<e.length;)e=this._MergeAllSortedZArrays_pass(e);return e[0]}_GetRenderCellInstancesToDraw(){return this._UpdateZIndices(),C33.clearArray(renderCellArr),this._renderGrid.QueryRange(this.GetViewport(),renderCellArr),renderCellArr.length?1===renderCellArr.length?renderCellArr[0]:this._MergeAllSortedZArrays(renderCellArr):[]}ShouldDraw(){return this.IsVisible()&&0<this.GetOpacity()&&this._DrawsAnyContentInSelfOrSubLayers()}_DrawsAnyContentInSelfOrSubLayers(){if(this.HasInstances()||!this.IsTransparent())return!0;for(const e of this._subLayers)if(e._DrawsAnyContentInSelfOrSubLayers())return!0;return!1}UsesOwnTexture(){return this.IsForceOwnTexture()||!this.HasDefaultColor()||0!==this.GetBlendMode()||this._effectList.HasAnyActiveEffect()}SelfOrAnySubLayerUsesOwnTexture(){if(this.UsesOwnTexture())return!0;for(const e of this._subLayers)if(e.SelfOrAnySubLayerUsesOwnTexture())return!0;return!1}GetRenderTarget(){return this._curRenderTarget}Get2DScaleFactorToZ(e){if(this._layout.IsOrthographicProjection())return 1;{const t=this.Get3DCameraZ();return t/(t-e)}}GetResolutionScaleFactorToZ(e){const t=this._runtime.GetRenderScale();if(this._layout.IsOrthographicProjection())return t;{const s=this.Get3DCameraZ(),i=this.GetDefaultCameraZ();return i/Math.abs(s-e)*t}}_SetMVMatrixChanged(){this._isMVMatrixChanged=!0,this._isViewFrustumChanged=!0,this._isViewportChanged=!0}_GetModelViewMatrix(e){return this._isMVMatrixChanged&&(this._CalculateModelViewMatrix(e,this._modelViewMatrix,0,0,null),this._isMVMatrixChanged=!1),this._modelViewMatrix}Get2DCameraZ(e){return this.GetDefaultCameraZ(e)/this.GetNormalScale()}Get3DCameraZ(){return this.Has3DCamera()?this.GetLayout().Get3DCameraPosition()[2]:this.Get2DCameraZ()}GetCameraPosition(){if(this.Has3DCamera()){const e=this.GetLayout().Get3DCameraPosition();return[e[0],e[1],e[2]]}return this._Get2DCameraPosition()}_Get2DCameraPosition(e=0,t=0,r=0){let n=this._runtime,s=this.GetLayout(),i=n.GetParallaxXOrigin(),a=n.GetParallaxYOrigin(),o=(this.GetScrollX()-i)*this._parallaxX+i,l=(this.GetScrollY()-a)*this._parallaxY+a,h=(n.IsPixelRoundingEnabled()&&(o=Math.round(o),l=Math.round(l)),o+e),c=l+t,u=s.IsOrthographicProjection()?this.GetDefaultCameraZ(r):this.Get2DCameraZ(r),[_,d]=this._GetVanishingPoint();if(.5!==_||.5!==d){let e=this.GetDefaultCameraZ(r)/u,t=(_-.5)*n.GetViewportWidth()/e,s=(d-.5)*n.GetViewportHeight()/e,i=this.GetAngle();0!==i&&(tempVec2.set(t,s),tempVec2.rotate(i),t=tempVec2.getX(),s=tempVec2.getY()),h+=t,c+=s}return[h,c,u]}_CalculateModelViewMatrix(e,t,s,i,r){const n=this._runtime,a=this.GetLayout();if(this.Has3DCamera()){vec32.copy(camVector,a.Get3DCameraPosition()),vec32.copy(lookVector,a.Get3DCameraLookAt()),vec32.copy(upVector,a.Get3DCameraUpVector());const o=n.GetParallaxXOrigin(),l=n.GetParallaxYOrigin(),h=lookVector[0]-camVector[0],c=lookVector[1]-camVector[1],u=lookVector[2]-camVector[2];camVector[0]=(camVector[0]-o)*this._parallaxX+o,camVector[1]=(camVector[1]-l)*this._parallaxY+l,camVector[2]*=Math.max(this._parallaxX,this._parallaxY),lookVector[0]=camVector[0]+h,lookVector[1]=camVector[1]+c,lookVector[2]=camVector[2]+u}else{const[_,d,p]=this._Get2DCameraPosition(s,i,r),m=(vec32.set(camVector,_,d,p),vec32.set(lookVector,_,d,p-100),this.GetAngle());0===m?vec32.set(upVector,0,1,0):vec32.set(upVector,Math.sin(m),Math.cos(m),0)}e.CalculateLookAtModelView(t,camVector,lookVector,upVector,r||n.GetViewportHeight())}_SetProjectionMatrixChanged(){this._isProjectionMatrixChanged=!0,this._isViewFrustumChanged=!0,this._isViewportChanged=!0}_GetProjectionMatrix(e){return this._isProjectionMatrixChanged&&(this._CalculateProjectionMatrix(e),this._isProjectionMatrixChanged=!1),this._projectionMatrix}_CalculateProjectionMatrix(e){const t=this._runtime.GetCanvasManager(),[s,i]=this._GetVanishingPoint();if(this._layout.IsOrthographicProjection())e.CalculateOrthographicMatrix(this._projectionMatrix,t.GetDrawWidth(),t.GetDrawHeight());else if(.5===s&&.5===i)mat42.copy(this._projectionMatrix,t.GetDefaultProjectionMatrix());else{const r=t.GetDrawWidth(),n=t.GetDrawHeight();e.CalculatePerspectiveMatrix(this._projectionMatrix,r/n,s,i)}}_SetTransform(e,t=!0,s=0,i=0,r=0){t&&e.SetProjectionMatrix(this._GetProjectionMatrix(e));let n;n=0===s&&0===i&&0===r?this._GetModelViewMatrix(e):(this._CalculateModelViewMatrix(e,tempMat4,s,i,r),tempMat4),e.SetModelViewMatrix(n)}PrepareForDraw(e){this._SetTransform(e),e.SetBaseZ(this.GetZElevation())}_MaybeStartWebGLProfiling(e){let t=null;if(e.IsWebGL()&&this._runtime.IsGPUProfiling()){const s=this._runtime.GetCanvasManager().GetLayerTimingsBuffer(this);s&&(t=s.AddTimeElapsedQuery(),e.StartQuery(t))}return t}_MaybeStartWebGPUProfiling(e){if(e.IsWebGPU()&&this._runtime.IsGPUProfiling()){const t=2*(this.GetIndex()+1);e.StartMeasuringRenderPassTime(t,1+t)}}Draw(e,t,s){let i=this._runtime.GetCanvasManager(),r=this.UsesOwnTexture(),n=null,a=this._MaybeStartWebGLProfiling(e);if(this._MaybeStartWebGPUProfiling(e),r){const o={sampling:this._runtime.GetSampling(),isSampled:!0,canReadPixels:!!e.IsWebGPU()&&this._runtime.UsesAnyBackgroundBlending()};"low"===i.GetCurrentFullscreenScalingQuality()&&(o.width=i.GetDrawWidth(),o.height=i.GetDrawHeight()),n=this._runtime.GetAdditionalRenderTarget(o),this._curRenderTarget=n,e.SetRenderTarget(n),this.IsTransparent()&&e.ClearRgba(0,0,0,0)}else this._curRenderTarget=t,e.SetRenderTarget(t);if(this.IsTransparent()||e.Clear(this._backgroundColor),this._layout._DrawLayerList(e,this._curRenderTarget,this._subLayers,r&&this.IsTransparent()),this._MaybeStartWebGPUProfiling(e),this._SetTransform(e),e.SetBaseZ(this.GetZElevation()),e.SetDepthEnabled(this.RendersIn3DMode()),this.GetNormalScale()>Number.EPSILON){this._UpdateZIndices();const l=this.UsesRenderCells()&&0===this.GetZElevation()&&!this._anyInstanceZElevated;this.Has3DCamera()?this._DrawInstances_3DCamera(e):l?this._DrawInstances_RenderCells(e):this._DrawInstances(e,this._GetInstancesInDrawOrder())}e.SetBaseZ(0),e.SetCurrentZ(0),r&&(e.SetDepthEnabled(!1),this._DrawLayerOwnTextureToRenderTarget(e,n,t,s)),a&&e.EndQuery(a),this._curRenderTarget=null}_DrawInstances(s,i){let r=this.GetViewport(),n=this._curRenderTarget,a=this.GetLayout().IsOrthographicProjection(),o=this.GetLayout().HasVanishingPointOutsideViewport(),l=null;for(let e=0,t=i.length;e<t;++e){const h=i[e];if(h!==l){const c=(l=h).GetWorldInfo();c.IsVisible()&&c.IsInViewport(r,o,a)&&this._DrawInstanceMaybeWithEffects(h,c,s,n)}}}_DrawInstances_3DCamera(i){const r=this._curRenderTarget,n=this._GetViewFrustum(),a=tempInstanceList1,o=tempInstanceList2,l=this._GetInstancesInDrawOrder();for(let t=0,s=l.length;t<s;){const h=l[t],c=h.GetWorldInfo();if(c.IsVisible()&&c.IsInViewport3D(n)){(!h.RendersToOwnZPlane()||0<c.GetDepth())&&o.push(h);const u=h.GetWorldInfo().GetTotalZElevation();a.push(h);let e=t+1;for(;e<s;++e){const _=l[e],d=_.GetWorldInfo();if(d.IsVisible()&&d.IsInViewport3D(n)){if(d.GetTotalZElevation()!==u)break;(_.RendersToOwnZPlane()?(0<d.GetDepth()&&o.push(_),a):o).push(_)}}if(1!==a.length||a[0].MustMitigateZFighting()){this._DrawCoplanarInstances_3DCamera(i,a);for(let e=0,t=o.length;e<t;++e){const p=o[e],m=p.GetWorldInfo();m._SetDrawNonBackFacesOnly(!0),this._DrawInstanceMaybeWithEffects(p,m,i,r),m._SetDrawNonBackFacesOnly(!1)}}else{this._DrawInstanceMaybeWithEffects(h,c,i,r);for(let e=0,t=o.length;e<t;++e){const g=o[e];if(g!==h){const f=g.GetWorldInfo(),S=f.GetLayer();S._DrawInstanceMaybeWithEffects(g,f,i,r)}}}t=e,C33.clearArray(a),C33.clearArray(o)}else++t}}_DrawCoplanarInstances_3DCamera(s,i){const r=this._curRenderTarget;s.CoplanarStartStencilPass();for(let e=0,t=i.length;e<t;++e){const n=i[e],a=n.GetWorldInfo();a._SetDrawBackFaceOnly(!0),this._DrawInstance(n,a,s)}s.CoplanarStartColorPass();for(let e=0,t=i.length;e<t;++e){const o=i[e],l=o.GetWorldInfo();this._DrawInstanceMaybeWithEffects(o,l,s,r),l._SetDrawBackFaceOnly(!1)}s.CoplanarRestoreStandardRendering()}_DrawInstances_RenderCells(e){let t=this._renderGrid,s=this._curRenderCells,i=this._lastRenderCells,r=this.GetViewport(),n;s.set(t.XToCell(r.getLeft()),t.YToCell(r.getTop()),t.XToCell(r.getRight()),t.YToCell(r.getBottom())),this._isRenderListUpToDate&&s.equals(i)?n=this._lastRenderList:(n=this._GetRenderCellInstancesToDraw(),this._isRenderListUpToDate=!0,i.copy(s)),this._DrawInstances(e,n),n!==this._lastRenderList&&C33.shallowAssignArray(this._lastRenderList,n)}_DrawInstanceMaybeWithEffects(e,t,s,i){t.HasAnyActiveEffect()?this._DrawInstanceWithEffectsAndRestore(e,t,s,i):this._DrawInstance(e,t,s)}_DrawInstance(e,t,s){const i=t.GetRendererStateGroup();s.GetCurrentStateGroup()!==i&&i.Apply(),e.Draw(s)}_DrawInstanceWithEffectsAndRestore(e,t,s,i){this._DrawInstanceWithEffects(e,t,s,i,null)&&this._SetTransform(s)}_DrawInstanceWithEffects(e,t,s,i,r){const n=t.GetInstanceEffectList().GetEffectChain();return n.Render(s,i,{contentObject:e,blendMode:t.GetBlendMode(),devicePixelRatio:this._runtime.GetEffectDevicePixelRatioParam(),time:e.GetInstanceGameTime(),layerScale:this._runtime.GetEffectLayerScaleParam()*this.GetNormalScale(),layerAngle:this.GetAngle(),layoutRect:t.GetBoundingBox(),drawSurfaceRect:n.CanSkipCalculatingDrawSurfaceRect()?null:this._InstanceBoxToDrawSurface(t),drawContentHook:r&&r.drawContentHook,compositOffX:r&&r.compositOffX,compositOffY:r&&r.compositOffY,updateOwnProjection:r&&r.updateOwnProjection}),s.SetBaseZ(this.GetZElevation()),n.DidChangeTransform()}_DrawLayerOwnTextureToRenderTarget(e,t,s,i){const r=this._effectList.GetActiveEffectTypes(),n=this._runtime;0===r.length?(e.SetRenderTarget(s),e.SetTextureFillMode(),i&&0===this._blendMode&&this.HasDefaultColor()?e.CopyRenderTarget(t):(e.SetBlendMode(this._blendMode),e.SetColor(this._premultipliedColor),e.DrawRenderTarget(t)),e.InvalidateRenderTarget(t),n.ReleaseAdditionalRenderTarget(t)):this.GetEffectChain().Render(e,s,{contentObject:this,blendMode:this.GetBlendMode(),devicePixelRatio:n.GetEffectDevicePixelRatioParam(),layerScale:n.GetEffectLayerScaleParam()*this.GetNormalScale(),layerAngle:this.GetAngle(),layoutRect:this.GetViewport(),drawSurfaceRect:null,invalidateRenderTargets:!0})}GetOwnScale(){return this._scale}SetOwnScale(e){this._scale!==e&&(this._scale=e,this._layout.BoundScrolling(),this._SetMVMatrixChanged(),this._runtime.UpdateRender())}GetRenderScale(){return this.GetNormalScale()*this._runtime.GetRenderScale()}GetDisplayScale(){return this.GetNormalScale()*this._runtime.GetDisplayScale()}GetNormalScale(){return(this._scale*this._layout.GetScale()-1)*this._scaleRate+1}_MaybeUpdateViewport(){if(this._isViewportChanged){this._isViewportChanged=!1;let e=this._runtime.GetParallaxXOrigin(),t=this._runtime.GetParallaxYOrigin(),s=(this.GetScrollX()-e)*this._parallaxX+e,i=(this.GetScrollY()-t)*this._parallaxY+t,r=this.GetNormalScale(),n=this._runtime.GetViewportWidth()/r,a=this._runtime.GetViewportHeight()/r,o=s-n/2,l=i-a/2;this._runtime.IsPixelRoundingEnabled()&&(o=Math.round(o),l=Math.round(l));const h=this._viewportZ0,c=(h.set(o,l,o+n,l+a),this.GetAngle()),u=(0!==c&&(tmpRect.copy(h),tmpRect.offset(-h.midX(),-h.midY()),tmpQuad.setFromRotatedRect(tmpRect,c),tmpQuad.getBoundingBox(tmpRect),tmpRect.offset(h.midX(),h.midY()),h.copy(tmpRect)),this._zElevation);this.GetViewportForZ(u,this._viewport),this.Has3DCamera()?this.CalculateViewport3D(u,this._viewport3D):this._viewport3D.copy(this._viewport)}}CalculateViewport3D(e,t){let s=this._runtime.GetCanvasManager(),i=s.GetCssWidth(),r=s.GetCssHeight(),[n,a]=this.CanvasCssToLayer(0,0,e),[o,l]=this.CanvasCssToLayer(i,0,e),[h,c]=this.CanvasCssToLayer(i,r,e),[u,_]=this.CanvasCssToLayer(0,r,e),d=Math.min(n,o,h,u),p=Math.min(a,l,c,_),m=Math.max(n,o,h,u),g=Math.max(a,l,c,_);isFinite(d)||(d=-1/0),isFinite(p)||(p=-1/0),isFinite(m)||(m=1/0),isFinite(g)||(g=1/0),t.set(d,p,m,g)}CanvasCssToLayer(e,t,s=0){return this._CanvasToLayer(e,t,s,this.GetDisplayScale())}DrawSurfaceToLayer(e,t,s=0){return this._CanvasToLayer(e,t,s,this.GetRenderScale()*this.GetDevicePixelRatio())}_CanvasToLayer(e,t,s,i){const r=this._runtime,n=r.GetRenderer(),a=this.GetNormalScale(),o=r.GetViewportWidth()/a,l=r.GetViewportHeight()/a,h=tempVec4,c=(vec42.set(h,0,0,o,l),e/=i,t=h[3]-t/i,this._GetProjectionMatrix(n)),u=this._GetModelViewMatrix(n),_=tempVec3,d=C33.Gfx.UnprojectScreenToWorldZ(e,t,s,u,c,h,_);return d?[_[0],_[1]]:[NaN,NaN]}CanvasCssToLayer_DefaultTransform(e,t){const s=this._scale,i=this._scaleRate,r=this._parallaxX,n=this._parallaxY,a=this._angle,o=(this._scale=1,this._scaleRate=1,this._parallaxX=1,this._parallaxY=1,this._angle=0,this._SetMVMatrixChanged(),this.CanvasCssToLayer(e,t));return this._scale=s,this._scaleRate=i,this._parallaxX=r,this._parallaxY=n,this._angle=a,this._SetMVMatrixChanged(),o}LayerToCanvasCss(e,t,s=0){return this._LayerToCanvas(e,t,s,this.GetDisplayScale())}LayerToDrawSurface(e,t,s=0){return this._LayerToCanvas(e,t,s,this.GetRenderScale()*this.GetDevicePixelRatio())}_LayerToCanvas(e,t,s,i){const r=this._runtime,n=r.GetRenderer(),a=this.GetNormalScale(),o=r.GetViewportWidth()/a,l=r.GetViewportHeight()/a,h=tempVec4,c=(vec42.set(h,0,0,o,l),this._GetProjectionMatrix(n)),u=this._GetModelViewMatrix(n),_=tempVec3,d=C33.Gfx.Project(e,t,s,u,c,h,_);return d?[_[0]*i,(h[3]-_[1])*i]:[NaN,NaN]}_GetLayerToDrawSurfaceScale(e,t){return e*=this.GetRenderScale()*this.GetDevicePixelRatio(),0!==t&&(e*=this.Get2DScaleFactorToZ(t)),e}_InstanceBoxToDrawSurface(e){const t=e.GetBoundingBox(),s=e.GetTotalZElevation(),i=e.GetDepth(),h=s+i,c=t.getLeft(),u=t.getTop(),_=t.getRight(),d=t.getBottom();if(this.Has3DCamera()){if(this._IsPointBehindNearPlane(c,u,s)||this._IsPointBehindNearPlane(_,u,s)||this._IsPointBehindNearPlane(_,d,s)||this._IsPointBehindNearPlane(c,d,s))return null;if(0<i&&(this._IsPointBehindNearPlane(c,u,h)||this._IsPointBehindNearPlane(_,u,h)||this._IsPointBehindNearPlane(_,d,h)||this._IsPointBehindNearPlane(c,d,h)))return null}else if(h>=this.Get2DCameraZ())return null;let[p,m]=this.LayerToDrawSurface(c,u,s),[g,f]=this.LayerToDrawSurface(_,d,s);if(0!==this.GetAngle()||0<i||this.Has3DCamera()){const[S,C]=this.LayerToDrawSurface(_,u,s),[y,G]=this.LayerToDrawSurface(c,d,s);if(0<i){let[e,t]=this.LayerToDrawSurface(c,u,h),[s,i]=this.LayerToDrawSurface(_,u,h),[r,n]=this.LayerToDrawSurface(_,d,h),[a,o]=this.LayerToDrawSurface(c,d,h),l=Math.min(p,g,S,y,e,s,r,a);g=Math.max(p,g,S,y,e,s,r,a),p=l,l=Math.min(m,f,C,G,t,i,n,o),f=Math.max(m,f,C,G,t,i,n,o),m=l}else{let e=Math.min(p,g,S,y);g=Math.max(p,g,S,y),p=e,e=Math.min(m,f,C,G),f=Math.max(m,f,C,G),m=e}}return tmpRect.set(p,m,g,f),tmpRect}_GetViewFrustum(){return this._isViewFrustumChanged&&(this._UpdateViewFrustum(),this._isViewFrustumChanged=!1),this._viewFrustum}_UpdateViewFrustum(){const e=this._runtime.GetRenderer(),t=this._GetProjectionMatrix(e),s=this._GetModelViewMatrix(e);this._viewFrustum.CalculatePlanes(s,t)}_IsPointBehindNearPlane(e,t,s){return this._GetViewFrustum().IsBehindNearPlane(e,t,s)}_SaveToJson(){const e={d:this.IsDynamic(),s:this.GetOwnScale(),a:this.GetOwnAngle(),v:this._IsVisibleFlagSet(),i:this.IsInteractive(),html:this.IsHTMLElementsLayer(),bc:this._backgroundColor.toJSON(),t:this.IsTransparent(),sx:this._scrollX,sy:this._scrollY,hosp:this._hasOwnScrollPosition,px:this.GetParallaxX(),py:this.GetParallaxY(),c:this._color.toJSON(),sr:this.GetScaleRate(),fx:this._effectList.SaveToJson(),cg:this._createdGlobalUids};return e}_LoadFromJson(e){this._isDynamic=!!e.d,this._scale=e.s,this._angle=e.a,this._isVisible=!!e.v,this._isInteractive=!e.hasOwnProperty("i")||e.i,this._isHTMLElementsLayer=!!e.html,this._backgroundColor.setFromJSON(e.bc),this._isTransparent=!!e.t,e.hasOwnProperty("sx")&&(this._scrollX=e.sx),e.hasOwnProperty("sy")&&(this._scrollY=e.sy),e.hasOwnProperty("hosp")&&(this._hasOwnScrollPosition=!!e.hosp),this._parallaxX=e.px,this._parallaxY=e.py,this._color.setFromJSON(e.c),this._UpdatePremultipliedColor(),this._scaleRate=e.sr,C33.shallowAssignArray(this._createdGlobalUids,e.cg),C33.shallowAssignArray(this._initialInstances,this._startupInitialInstances);let s=new Set(this._createdGlobalUids),i=0;for(let e=0,t=this._initialInstances.length;e<t;++e)s.has(this._initialInstances[e][2])||(this._initialInstances[i]=this._initialInstances[e],++i);C33.truncateArray(this._initialInstances,i),this._effectList.LoadFromJson(e.fx),this._needsRebuildEffectChainSteps=!0}_LoadFromJsonAfterInstances(){this._SortInstancesByLastCachedZIndex(!1),this.SetZIndicesChanged(),this._SetMVMatrixChanged(),this._SetProjectionMatrixChanged()}GetILayer(){return this._iLayer}SortAndAddInstancesByZIndex(e,t=!1){if(this._instances.includes(e))t&&this._instances.sort((e,t)=>{const s=e.GetWorldInfo().GetSceneGraphZIndex(),i=t.GetWorldInfo().GetSceneGraphZIndex();return s-i});else if(e.HasChildren()){const s=[...e.allChildren()];s.push(e),s.sort((e,t)=>{const s=e.GetWorldInfo().GetSceneGraphZIndex(),i=t.GetWorldInfo().GetSceneGraphZIndex();return s-i});for(const i of s)if(i.IsInContainer())for(const r of i.siblings())if(!s.includes(r)){const n=[...r.allChildren()];n.push(r),n.sort((e,t)=>{const s=e.GetWorldInfo().GetSceneGraphZIndex(),i=t.GetWorldInfo().GetSceneGraphZIndex();return s-i}),n&&n.length&&s.splice(s.length,0,...n)}for(const a of s)a.GetPlugin().IsWorldType()&&this._AddInstance(a,!0)}else if(e.GetPlugin().IsWorldType()&&this._AddInstance(e,!0),e.IsInContainer())for(const o of e.siblings()){const l=[...o.allChildren()];if(l.push(o),l.sort((e,t)=>{const s=e.GetWorldInfo().GetSceneGraphZIndex(),i=t.GetWorldInfo().GetSceneGraphZIndex();return s-i}),l&&l.length)for(const h of l)h.GetPlugin().IsWorldType()&&this._AddInstance(h,!0)}}}}{let vec3EqualsXYZ2=function(e,t,s,i){return e[0]===Math.fround(t)&&e[1]===Math.fround(s)&&e[2]===Math.fround(i)},MaybePrepareLayerDraw2=function(e,t){lastLayerPreparedForDrawing!==e&&(e.PrepareForDraw(t),lastLayerPreparedForDrawing=e)},C33=(vec3EqualsXYZ=vec3EqualsXYZ2,MaybePrepareLayerDraw=MaybePrepareLayerDraw2,self.C3),C3Debugger=self.C3Debugger,assert=self.assert,tempDestRect=C33.New(C33.Rect),tempSrcRect=C33.New(C33.Rect),tempLayoutRect=C33.New(C33.Rect),tempColor=C33.New(C33.Color),glMatrix=self.glMatrix,vec32=glMatrix.vec3,tempRender3dList=[],tempInstanceList1=[],tempInstanceList2=[],tempInstanceList3=[],lastLayerPreparedForDrawing=null;C33.Layout=class extends C33.DefendedBase{constructor(e,t,s){super(),this._layoutManager=e,this._runtime=e.GetRuntime(),this._name=s[0],this._originalWidth=s[1],this._originalHeight=s[2],this._width=s[1],this._height=s[2],this._isUnboundedScrolling=!!s[3],this._isOrthographicProjection=!!s[4],this._vanishingPointX=s[5],this._vanishingPointY=s[6],this._eventSheetName=s[7],this._eventSheet=null,this._sid=s[8],this._index=t,this._scrollX=0,this._scrollY=0,this._scale=1,this._angle=0,this._initialObjectClasses=new Set,this._textureLoadedTypes=new Set,this._textureLoadPendingPromises=new Set,this._createdInstances=[],this._createdPersistedInstances=[],this._createdPersistedInstancesToDataMap=new Map,this._createdPersistedIndexToInstanceMap=new Map,this._initialNonWorld=[],this._is3dCameraEnabled=!1,this._cam3dposition=vec32.create(),this._cam3dlook=vec32.create(),this._cam3dup=vec32.create(),this._rootLayers=[],this._allLayersFlat=[],this._layersByName=new Map,this._layersBySid=new Map,this._pendingSetHTMLLayerCount=-1;const r=this._runtime.GetCanvasManager();this._effectList=C33.New(C33.EffectList,this,s[11]),this._effectChain=C33.New(C33.Gfx.EffectChain,r.GetEffectChainManager(),{drawContent:(e,t)=>{const s=t.GetContentObject(),i=s.GetRenderTarget();e.ResetColor(),e.DrawRenderTarget(i),e.InvalidateRenderTarget(i),r.ReleaseAdditionalRenderTarget(i)},getShaderParameters:e=>this.GetEffectList()._GetEffectChainShaderParametersForIndex(e)}),this._needsRebuildEffectChainSteps=!0,this._wasFullScreenQualityLow=!1,this._curRenderTarget=null,this._persistData={},this._persistedIntances=new Map,this._isFirstVisit=!0,this._iLayout=new self.ILayout(this),this._userScriptDispatcher=C33.New(C33.Event.Dispatcher);for(const i of s[9])this._rootLayers.push(C33.Layer.CreateFromExportData(this,null,i));this._ReindexLayers();for(const n of this.allLayers())n._InitInitialInstances();for(const a of s[10]){const o=this._runtime.GetObjectClassByIndex(a[1]);if(!o)throw new Error("missing nonworld object class");o.GetDefaultInstanceData()||o.SetDefaultInstanceData(a),this._initialNonWorld.push(a),this._AddInitialObjectClass(o)}}Release(){for(const e of this._allLayersFlat)e.Release();C33.clearArray(this._allLayersFlat),this._textureLoadPendingPromises.clear(),this._eventSheet=null,this._layoutManager=null,this._runtime=null}GetRuntime(){return this._runtime}GetName(){return this._name}GetSID(){return this._sid}GetIndex(){return this._index}GetEffectList(){return this._effectList}GetEffectChain(){return this._MaybeRebuildEffectChainSteps(),this._effectChain}_MaybeRebuildEffectChainSteps(){const e="low"===this._runtime.GetCanvasManager().GetCurrentFullscreenScalingQuality();if(this._needsRebuildEffectChainSteps||this._wasFullScreenQualityLow!==e||this._effectChain.NeedsRebuild()){const t=this.GetEffectList().GetActiveEffectTypes();this._effectChain.BuildSteps(t.map(e=>e.GetShaderProgram()),{indexMap:t.map(e=>e.GetIndex()),forcePostDraw:e,useFullSurface:!0}),this._needsRebuildEffectChainSteps=!1,this._wasFullScreenQualityLow=e}}UpdateActiveEffects(){this.GetEffectList().UpdateActiveEffects(),this._needsRebuildEffectChainSteps=!0}GetMinLayerScale(){let s=this._allLayersFlat[0].GetNormalScale();for(let e=1,t=this._allLayersFlat.length;e<t;++e){const i=this._allLayersFlat[e];0===i.GetParallaxX()&&0===i.GetParallaxY()||(s=Math.min(s,i.GetNormalScale()))}return s}_GetScrollBoundMarginHorizontal(){return.5*this._runtime.GetViewportWidth()/this.GetMinLayerScale()}_GetScrollBoundMarginVertical(){return.5*this._runtime.GetViewportHeight()/this.GetMinLayerScale()}GetScrollLeftBound(){return this.IsUnboundedScrolling()?-1/0:this._GetScrollBoundMarginHorizontal()}GetScrollRightBound(){return this.IsUnboundedScrolling()?1/0:this.GetWidth()-this._GetScrollBoundMarginHorizontal()}GetScrollTopBound(){return this.IsUnboundedScrolling()?-1/0:this._GetScrollBoundMarginVertical()}GetScrollBottomBound(){return this.IsUnboundedScrolling()?1/0:this.GetHeight()-this._GetScrollBoundMarginVertical()}SetScrollX(e){const t=this.GetScrollLeftBound(),s=this.GetScrollRightBound();this._scrollX!==(e=(e=s<e?s:e)<t?t:e)&&(this._scrollX=e,this._SetAllLayersMVChanged(),this._runtime.UpdateRender())}GetScrollX(){return this._scrollX}SetScrollY(e){const t=this.GetScrollTopBound(),s=this.GetScrollBottomBound();this._scrollY!==(e=(e=s<e?s:e)<t?t:e)&&(this._scrollY=e,this._SetAllLayersMVChanged(),this._runtime.UpdateRender())}GetScrollY(){return this._scrollY}IsUnboundedScrolling(){return this._isUnboundedScrolling}BoundScrolling(){this.SetScrollX(this.GetScrollX()),this.SetScrollY(this.GetScrollY());for(const e of this._allLayersFlat)e.IsOwnScrollPositionEnabled()&&(e.SetScrollX(e.GetScrollX()),e.SetScrollY(e.GetScrollY()))}SetVanishingPointXY(e,t){this._vanishingPointX===e&&this._vanishingPointY===t||(this._vanishingPointX=e,this._vanishingPointY=t,this.IsPerspectiveProjection()&&(this._SetAllLayersProjectionChanged(),this._SetAllLayersMVChanged(),this._runtime.UpdateRender()))}GetVanishingPointX(){return this.IsOrthographicProjection()?.5:this._vanishingPointX}GetVanishingPointY(){return this.IsOrthographicProjection()?.5:this._vanishingPointY}HasVanishingPointOutsideViewport(){const e=this.GetVanishingPointX(),t=this.GetVanishingPointY();return e<0||1<e||t<0||1<t}SetPerspectiveProjection(){this._isOrthographicProjection&&(this._isOrthographicProjection=!1,this._SetAllLayersProjectionChanged(),this._SetAllLayersMVChanged(),this._runtime.UpdateRender())}SetOrthographicProjection(){this._isOrthographicProjection||(this._isOrthographicProjection=!0,this._SetAllLayersProjectionChanged(),this._SetAllLayersMVChanged(),this._runtime.UpdateRender())}IsOrthographicProjection(){return this._isOrthographicProjection}IsPerspectiveProjection(){return!this.IsOrthographicProjection()}Set3DCameraEnabled(e){this._is3dCameraEnabled!==(e=!!e)&&(this._is3dCameraEnabled=e,this._SetAllLayersMVChanged(),this._runtime.UpdateRender())}Is3DCameraEnabled(){return this._is3dCameraEnabled}Set3DCameraOrientation(e,t,s,i,r,n,a,o,l){vec3EqualsXYZ2(this._cam3dposition,e,t,s)&&vec3EqualsXYZ2(this._cam3dlook,i,r,n)&&vec3EqualsXYZ2(this._cam3dup,a,o,l)||(vec32.set(this._cam3dposition,e,t,s),vec32.set(this._cam3dlook,i,r,n),vec32.set(this._cam3dup,a,o,l),this.Set3DCameraChanged())}Set3DCameraChanged(){this._SetAllLayersMVChanged(),this._runtime.UpdateRender()}Get3DCameraPosition(){return this._cam3dposition}Get3DCameraLookAt(){return this._cam3dlook}Get3DCameraUpVector(){return this._cam3dup}GetScale(){return this._scale}SetScale(e){this._scale!==e&&(this._scale=e,this._SetAllLayersMVChanged(),this.BoundScrolling(),this._runtime.UpdateRender())}SetAngle(e){e=C33.clampAngle(e),this._angle!==e&&(this._angle=e,this._SetAllLayersMVChanged(),this._runtime.UpdateRender())}GetAngle(){return this._angle}GetWidth(){return this._width}SetWidth(e){!isFinite(e)||e<1||(this._width=e)}GetHeight(){return this._height}SetHeight(e){!isFinite(e)||e<1||(this._height=e)}GetEventSheet(){return this._eventSheet}_GetRootLayers(){return this._rootLayers}*allLayers(){for(const e of this._rootLayers)yield*e.selfAndAllSubLayers()}GetLayers(){return this._allLayersFlat}GetLayerCount(){return this._allLayersFlat.length}GetLayer(e){return"number"==typeof e?this.GetLayerByIndex(e):this.GetLayerByName(e.toString())}GetLayerByIndex(e){return e=C33.clamp(Math.floor(e),0,this._allLayersFlat.length-1),this._allLayersFlat[e]}GetLayerByName(e){return this._layersByName.get(e.toLowerCase())||null}HasLayerByName(e){return!!this.GetLayerByName(e)}GetLayerBySID(e){return this._layersBySid.get(e)||null}_SetAllLayersProjectionChanged(){for(const e of this._allLayersFlat)e._SetProjectionMatrixChanged()}_SetAllLayersMVChanged(){for(const e of this._allLayersFlat)e._SetMVMatrixChanged()}AddLayer(e,t,s){if(this.HasLayerByName(e))throw new Error(`layer name '${e}' already in use`);if(!t&&s<2)throw new Error("invalid insert position");const i=2<=s?t:t.GetParentLayer(),r=C33.New(C33.Layer,this,i,{name:e,sid:Math.floor(1e15*Math.random()),isDynamic:!0});this._InsertLayer(r,t,s),this.GetRuntime().UpdateRender(),this._ReindexAndUpdateAllLayers()}MoveLayer(e,t,s){if(!t&&s<2)throw new Error("invalid insert position");e===t&&s<2||(this._RemoveLayer(e),this._InsertLayer(e,t,s),this.GetRuntime().UpdateRender(),this._ReindexAndUpdateAllLayers())}RemoveLayer(e){if(this._RemoveLayer(e)){const t=this._runtime.GetEventSheetManager();t.BlockFlushingInstances(!0),e.Release(),t.BlockFlushingInstances(!1),this.GetRuntime().UpdateRender(),this._ReindexAndUpdateAllLayers()}}RemoveAllDynamicLayers(){const e=new Set;for(const t of this.allLayers())t.IsDynamic()&&!t.HasAnyDynamicParentLayer()&&e.add(t);if(0!==e.size){const s=this._runtime.GetEventSheetManager();s.BlockFlushingInstances(!0);for(const i of e)this._RemoveLayer(i),i.Release();s.BlockFlushingInstances(!1),this.GetRuntime().UpdateRender(),this._ReindexAndUpdateAllLayers()}}_InsertLayer(t,s,i){if(2<=i)if(s){if(s===t||s.HasParentLayer(t))throw new Error(`cannot move layer '${t.GetName()}' to sub-layer of itself`);s._AddSubLayer(t,2===i),t._SetParentLayer(s)}else 2===i?this._rootLayers.push(t):this._rootLayers.unshift(t),t._SetParentLayer(null);else{const e=s.GetParentLayer();if(e){if(s.HasParentLayer(t))throw new Error(`cannot move layer '${t.GetName()}' to sub-layer of itself`);e._InsertSubLayer(t,s,0===i),t._SetParentLayer(e)}else{let e=this._rootLayers.indexOf(s);if(-1===e)throw new Error("cannot find layer to insert by");0===i&&++e,this._rootLayers.splice(e,0,t),t._SetParentLayer(null)}}}_RemoveLayer(e){const t=e.GetParentLayer();if(t)return t._RemoveSubLayer(e),!0;if(1<this._rootLayers.length){const s=this._rootLayers.indexOf(e);if(-1===s)throw new Error("cannot find layer to remove");return this._rootLayers.splice(s,1),!0}return!1}_ReindexLayers(){this._allLayersFlat=[...this.allLayers()],this._layersByName.clear(),this._layersBySid.clear();for(let e=0,t=this._allLayersFlat.length;e<t;++e){const s=this._allLayersFlat[e];s._SetIndex(e),this._layersByName.set(s.GetName().toLowerCase(),s),this._layersBySid.set(s.GetSID(),s)}}_ReindexHTMLLayers(){let e=0;for(const t of this._rootLayers){for(const s of t.selfAndAllSubLayers())s._SetHTMLIndex(e);t.IsHTMLElementsLayer()&&e++}}GetHTMLLayerCount(){return this._rootLayers.at(-1).GetHTMLIndex()+1}async _ReindexAndUpdateAllLayers(){this._ReindexLayers(),this._ReindexHTMLLayers(),this._pendingSetHTMLLayerCount=this.GetHTMLLayerCount()}_GetPendingSetHTMLLayerCount(){return this._pendingSetHTMLLayerCount}_ResetPendingHTMLLayerCount(){this._pendingSetHTMLLayerCount=-1}GetRootLayersForHTMLLayer(e){const t=[];for(const s of this._rootLayers){const i=s.GetHTMLIndex();if(i===e)t.push(s);else if(e<i)break}return t}SaveTransform(){return{scrollX:this.GetScrollX(),scrollY:this.GetScrollY(),scale:this.GetScale(),angle:this.GetAngle(),vpX:this.GetVanishingPointX(),vpY:this.GetVanishingPointY()}}RestoreTransform(e){this.SetScrollX(e.scrollX),this.SetScrollY(e.scrollY),this.SetScale(e.scale),this.SetAngle(e.angle),this.SetVanishingPointXY(e.vpX,e.vpY)}GetLayoutBackgroundColor(){let e=this._rootLayers.filter(e=>e.ShouldDraw())[0];for(;e;){if(!e.IsTransparent())return tempColor.copyRgb(e.GetBackgroundColor()),tempColor.setA(1),tempColor;if(e.UsesOwnTexture())return tempColor.setRgba(0,0,0,0),tempColor;e=e.GetSubLayers().filter(e=>e.ShouldDraw())[0]}return tempColor.setRgba(0,0,0,0),tempColor}IsFirstVisit(){return this._isFirstVisit}_GetInitialObjectClasses(){return[...this._initialObjectClasses]}_AddInitialObjectClass(e){if(e.IsInContainer())for(const t of e.GetContainer().GetObjectTypes())this._initialObjectClasses.add(t);else this._initialObjectClasses.add(e)}_GetTextureLoadedObjectTypes(){return[...this._textureLoadedTypes]}_Load(e,t){if(e===this||!t)return Promise.resolve();e&&(C33.CopySet(this._textureLoadedTypes,e._textureLoadedTypes),e._textureLoadedTypes.clear());const s=[];for(const i of this._initialObjectClasses)this._textureLoadedTypes.has(i)||(s.push(i.LoadTextures(t)),this._textureLoadedTypes.add(i));return Promise.all(s)}async MaybeLoadTexturesFor(e){if(e.IsFamily())throw new Error("cannot load textures for family");const t=this._runtime.GetRenderer();if(t&&!t.IsContextLost()&&!this._textureLoadedTypes.has(e)){this._textureLoadedTypes.add(e);const s=e.LoadTextures(t);this._AddPendingTextureLoadPromise(s),await s,e.OnDynamicTextureLoadComplete(),this._runtime.UpdateRender()}}_AddPendingTextureLoadPromise(e){this._textureLoadPendingPromises.add(e),e.then(()=>this._textureLoadPendingPromises.delete(e)).catch(()=>this._textureLoadPendingPromises.delete(e))}WaitForPendingTextureLoadsToComplete(){return Promise.all([...this._textureLoadPendingPromises])}MaybeUnloadTexturesFor(e){if(e.IsFamily()||0<e.GetInstanceCount())throw new Error("cannot unload textures");const t=this._runtime.GetRenderer();t&&this._textureLoadedTypes.has(e)&&(this._textureLoadedTypes.delete(e),e.ReleaseTextures(t))}_Unload(e,t){if(e!==this&&t)for(const s of this._textureLoadedTypes)s.IsGlobal()||e._initialObjectClasses.has(s)||(s.ReleaseTextures(),this._textureLoadedTypes.delete(s))}_OnRendererContextLost(){this._textureLoadedTypes.clear()}async _StartRunning(e){const t=this._runtime,s=this._layoutManager,i=t.GetEventSheetManager(),r=(this._eventSheetName&&(this._eventSheet=i.GetEventSheetByName(this._eventSheetName),this._eventSheet._UpdateDeepIncludes()),s._SetMainRunningLayout(this),this._width=this._originalWidth,this._height=this._originalHeight,this._scrollX=t.GetOriginalViewportWidth()/2,this._scrollY=t.GetOriginalViewportHeight()/2,this.BoundScrolling(),this._SetAllLayersProjectionChanged(),this._SetAllLayersMVChanged(),this._ReindexHTMLLayers(),await this._runtime.GetCanvasManager().SetHTMLLayerCount(this.GetHTMLLayerCount(),!0),this._MoveGlobalObjectsToThisLayout(e),this._runtime.SetUsingCreatePromises(!0),this._CreateInitialInstances(),this._isFirstVisit||this._CreatePersistedInstances(),this._CreateAndLinkContainerInstances(this._createdInstances),this._CreateAndLinkContainerInstances(this._createdPersistedInstances),this._CreateInitialNonWorldInstances(),s.ClearPendingChangeLayout(),t.FlushPendingInstances(),this._runtime.SetUsingCreatePromises(!1),this._runtime.GetCreatePromises());if(await Promise.all(r),C33.clearArray(r),!t.IsLoadingState()){for(const n of this._createdInstances)n.SetupInitialSceneGraphConnections();for(const a of this._createdPersistedInstances)a.SetupPersistedSceneGraphConnections(this._createdPersistedInstancesToDataMap,this._createdPersistedIndexToInstanceMap);for(const[o,l]of Object.entries(this._persistData)){const h=this._runtime.GetObjectClassBySID(parseInt(o,10));h&&!h.IsFamily()&&h.HasPersistBehavior()&&C33.clearArray(l)}for(const c of this._createdInstances)c._TriggerOnCreated();for(const u of this._createdPersistedInstances)u._TriggerOnCreated();for(const _ of this._createdInstances)_.HasParent()||_._OnHierarchyReady();for(const d of this._createdPersistedInstances)d.HasParent()||d._OnHierarchyReady()}C33.clearArray(this._createdInstances),C33.clearArray(this._createdPersistedInstances),this._createdPersistedInstancesToDataMap.clear(),this._createdPersistedIndexToInstanceMap.clear(),await Promise.all([...this._initialObjectClasses].map(e=>e.PreloadTexturesWithInstances(this._runtime.GetRenderer()))),e&&(t.Dispatcher().dispatchEvent(new C33.Event("beforefirstlayoutstart")),await t.DispatchUserScriptEventAsyncWait(new C33.Event("beforeprojectstart"))),await this.DispatchRuntimeUserScriptEventAsyncWait(new C33.Event("beforeanylayoutstart")),t.Dispatcher().dispatchEvent(new C33.Event("beforelayoutstart")),await this.DispatchUserScriptEventAsyncWait(new C33.Event("beforelayoutstart")),t.IsLoadingState()||await t.TriggerAsync(C33.Plugins.System.Cnds.OnLayoutStart,null,null),t.Dispatcher().dispatchEvent(new C33.Event("afterlayoutstart")),await this.DispatchUserScriptEventAsyncWait(new C33.Event("afterlayoutstart")),await this.DispatchRuntimeUserScriptEventAsyncWait(new C33.Event("afteranylayoutstart")),e&&(t.Dispatcher().dispatchEvent(new C33.Event("afterfirstlayoutstart")),await t.DispatchUserScriptEventAsyncWait(new C33.Event("afterprojectstart"))),i._RunQueuedTriggers(s),await this.WaitForPendingTextureLoadsToComplete(),this._isFirstVisit=!1}_MoveGlobalObjectsToThisLayout(e){for(const t of this._runtime.GetAllObjectClasses())if(!t.IsFamily()&&t.IsWorldType())for(const s of t.GetInstances()){const i=s.GetWorldInfo(),r=i.GetLayer(),n=C33.clamp(r.GetIndex(),0,this._allLayersFlat.length-1),a=this._allLayersFlat[n];i._SetLayer(a,!0),a._MaybeAddInstance(s)}if(!e)for(const o of this._allLayersFlat)o._SortInstancesByLastCachedZIndex(!1)}_CreateInitialInstances(){for(const e of this._allLayersFlat)e.CreateInitialInstances(this._createdInstances),e._Start()}_CreatePersistedInstances(){let t=!1;for(const[e,s]of Object.entries(this._persistData)){const i=this._runtime.GetObjectClassBySID(parseInt(e,10));if(i&&!i.IsFamily()&&i.HasPersistBehavior())for(const r of s){let e=null;if(!i.IsWorldType()||(e=r.hasOwnProperty("instJson")?this.GetLayerBySID(r.instJson.w.l):this.GetLayerBySID(r.w.l))){const n=this._runtime.CreateInstanceFromData(i,e,!1,0,0,!0);r.hasOwnProperty("instJson")?n.LoadFromJson(r.instJson):n.LoadFromJson(r),t=!0,this._createdPersistedInstances.push(n),r.hasOwnProperty("instJson")&&(this._createdPersistedInstancesToDataMap.set(n,r),this._createdPersistedIndexToInstanceMap.set(r.index,n))}}}for(const a of this._allLayersFlat)a._SortInstancesByLastCachedZIndex(!0),a.SetZIndicesChanged();t&&(this._runtime.FlushPendingInstances(),this._runtime._RefreshUidMap())}_CreateAndLinkContainerInstances(t){for(const s of t)if(s.IsInContainer()){const i=s.GetWorldInfo(),e=s.GetIID();for(const r of s.GetObjectClass().GetContainer().objectTypes())if(r!==s.GetObjectClass()){const n=r.GetInstances();if(n.length>e)s._AddSibling(n[e]);else{let e;e=i?this._runtime.CreateInstanceFromData(r,i.GetLayer(),!0,i.GetX(),i.GetY(),!0):this._runtime.CreateInstanceFromData(r,null,!0,0,0,!0),this._runtime.FlushPendingInstances(),r._UpdateIIDs(),s._AddSibling(e),t.push(e)}}}}_CreateInitialNonWorldInstances(){for(const e of this._initialNonWorld){const t=this._runtime.GetObjectClassByIndex(e[1]);t.IsInContainer()||this._runtime.CreateInstanceFromData(e,null,!0)}}_CreateGlobalNonWorlds(){let s=[],i=this._initialNonWorld,r=0;for(let e=0,t=i.length;e<t;++e){const n=i[e],a=this._runtime.GetObjectClassByIndex(n[1]);a.IsGlobal()?a.IsInContainer()&&a.GetContainer().HasAnyWorldType()||s.push(this._runtime.CreateInstanceFromData(n,null,!0)):(i[r]=n,++r)}C33.truncateArray(i,r),this._runtime.FlushPendingInstances(),this._CreateAndLinkContainerInstances(s)}RecreateInitialObjects(e,t,s,i,r,n,a){if(s)return s.RecreateInitialObjects(e,t,r,n,i,a);{const o=[];for(const l of this._allLayersFlat)o.push(l.RecreateInitialObjects(e,t,r,n,i,a));return o.flat()}}async _StopRunning(){const e=this._layoutManager;this._runtime.IsLoadingState()||(await this.DispatchRuntimeUserScriptEventAsyncWait(new C33.Event("beforeanylayoutend")),await this.DispatchUserScriptEventAsyncWait(new C33.Event("beforelayoutend")),await this._runtime.TriggerAsync(C33.Plugins.System.Cnds.OnLayoutEnd,null,null),await this.DispatchUserScriptEventAsyncWait(new C33.Event("afterlayoutend")),await this.DispatchRuntimeUserScriptEventAsyncWait(new C33.Event("afteranylayoutend"))),e.SetIsEndingLayout(!0),this._runtime.GetEventSheetManager().ClearAllScheduledWaits(),this._isFirstVisit||this._SavePersistData();for(const t of this._allLayersFlat)t._End();for(const s of this._runtime.GetAllObjectClasses())if(!(s.IsGlobal()||s.IsWorldType()||s.GetPlugin().IsSingleGlobal()||s.IsFamily())){for(const i of s.GetInstances())this._runtime.DestroyInstance(i);this._runtime.FlushPendingInstances()}e.SetIsEndingLayout(!1),e.GetMainRunningLayout()===this&&e._SetMainRunningLayout(null)}_SaveInstanceToPersist(e,t){const s=e.GetObjectClass().GetSID().toString(),i=(this._persistData.hasOwnProperty(s)||(this._persistData[s]=[]),this._persistData[s]),r={index:t,instJson:e.SaveToJson(),sceneGraphJson:{children:[]}};i.push(r),this._persistedIntances.set(e,r)}_SaveSceneGraphInfoToPersist(e){const t=this._persistedIntances.get(e);for(const s of e.GetChildren()){const i=this._persistedIntances.get(s);i&&t.sceneGraphJson.children.push({index:i.index,flags:C33.SceneGraphInfo._GetFlagsNumber(s.GetWorldInfo())})}}_SavePersistData(){this._persistedIntances.clear();let e=0;for(const t of this._allLayersFlat){t._UpdateZIndices();for(const s of t._GetInstances()){const i=s.GetObjectClass();!i.IsGlobal()&&i.HasPersistBehavior()&&(this._SaveInstanceToPersist(s,e),e++)}}for(const r of this._allLayersFlat)for(const n of r._GetInstances()){const a=n.GetObjectClass();!a.IsGlobal()&&a.HasPersistBehavior()&&this._SaveSceneGraphInfoToPersist(n)}this._persistedIntances.clear()}ResetPersistData(){this._persistData={},this._isFirstVisit=!0}GetRenderTarget(){return this._curRenderTarget}UsesOwnTexture(){const e=this._runtime,t=e.GetRenderer().IsWebGL();return"low"===e.GetCanvasManager().GetCurrentFullscreenScalingQuality()||t&&e.UsesAnyBackgroundBlending()||this._effectList.HasAnyActiveEffect()||t&&e.Uses3DFeatures()}_MaybeStartDrawToOwnTexture(e){const t=this._runtime.GetCanvasManager();if(this.UsesOwnTexture()){e.SetRenderTarget(null),e.ClearRgba(0,0,0,0);const s={sampling:this._runtime.GetSampling(),isSampled:e.IsWebGPU()||this._runtime.UsesAnyBackgroundBlending()||this._effectList.HasAnyActiveEffect(),canReadPixels:!!e.IsWebGPU()&&this._runtime.UsesAnyBackgroundBlending()};"low"===t.GetCurrentFullscreenScalingQuality()&&(s.width=t.GetDrawWidth(),s.height=t.GetDrawHeight()),this._curRenderTarget=this._runtime.GetAdditionalRenderTarget(s)}else this._curRenderTarget=null}_MaybeCopyOwnTextureToBackbuffer(e){this._runtime._NeedsHTMLLayerCompositing(e)&&(e.SetDepthEnabled(!1),e.SetRenderTarget(null),e.SetTextureFillMode(),e.CopyRenderTarget(this._curRenderTarget))}_MaybeEndDrawToOwnTexture(e){this.UsesOwnTexture()&&(e.SetDepthEnabled(!1),this._DrawLayoutOwnTextureToRenderTarget(e,this._curRenderTarget))}DrawMain(e){e.SetRenderTarget(this._curRenderTarget),e.Clear(this.GetLayoutBackgroundColor()),this._runtime.Uses3DFeatures()&&e.ClearDepth();const t=this.GetRootLayersForHTMLLayer(0);this._DrawLayerList(e,this._curRenderTarget,t,!0),e.IsWebGPU()&&e.StartMeasuringRenderPassTime(0,1),this._MaybeEndDrawToOwnTexture(e),this._curRenderTarget=null}DrawForHTMLLayerIndex(e,t){let s=null;this._runtime._NeedsHTMLLayerCompositing(e)&&(s=this._curRenderTarget),e.SetRenderTarget(s),e.ClearRgba(0,0,0,0),this._runtime.Uses3DFeatures()&&e.ClearDepth();const i=this.GetRootLayersForHTMLLayer(t);this._DrawLayerList(e,s,i,!0),this._MaybeCopyOwnTextureToBackbuffer(e),e.EndBatch(),this._runtime.GetCanvasManager().BlitMainCanvasToHTMLLayerCanvas(t)}_DrawLayerList(e,i,t,r){const n=t.filter(e=>e.ShouldDraw());for(let t=0,s=n.length;t<s;){const a=n[t];if(a.SelfAndAllSubLayersHave3DCamera()&&!a.SelfOrAnySubLayerUsesOwnTexture()){tempRender3dList.push(a);for(let e=t+1;e<s;++e){const o=n[e];if(!o.SelfAndAllSubLayersHave3DCamera()||o.SelfOrAnySubLayerUsesOwnTexture())break;tempRender3dList.push(n[e])}if(2<=tempRender3dList.length||1===tempRender3dList.length&&tempRender3dList[0].HasAnyVisibleSubLayer()){this._Draw3DLayers(e,i,tempRender3dList),t+=tempRender3dList.length,C33.clearArray(tempRender3dList);continue}C33.clearArray(tempRender3dList)}a.Draw(e,i,r&&0===t),++t}}_DrawLayoutOwnTextureToRenderTarget(e,t){const s=this._effectList.GetActiveEffectTypes(),i=this._runtime;0===s.length?(e.SetRenderTarget(null),e.SetTextureFillMode(),e.CopyRenderTarget(t),e.InvalidateRenderTarget(t),i.ReleaseAdditionalRenderTarget(t)):(tempLayoutRect.set(0,0,i.GetViewportWidth(),i.GetViewportHeight()),this.GetEffectChain().Render(e,null,{contentObject:this,blendMode:3,devicePixelRatio:this._runtime.GetEffectDevicePixelRatioParam(),layerScale:this._runtime.GetEffectLayerScaleParam()*this.GetScale(),layerAngle:this.GetAngle(),layoutRect:tempLayoutRect,drawSurfaceRect:null,invalidateRenderTargets:!0}))}_Draw3DLayers(i,r,e){e[0].IsTransparent()||(tempColor.copyRgb(e[0].GetBackgroundColor()),tempColor.setA(1),i.Clear(tempColor)),this._runtime.GetCanvasManager(),i.SetDepthEnabled(!0);const n=tempInstanceList1,a=tempInstanceList2,o=tempInstanceList3;for(const l of e)l._UpdateZIndices(),l._AppendAllInstancesIncludingSubLayersInDrawOrder(n);const t=e[0],s=t._MaybeStartWebGLProfiling(i);t._MaybeStartWebGPUProfiling(i);for(let t=0,s=n.length;t<s;){const h=n[t],c=h.GetWorldInfo(),u=c.GetLayer();if(c.IsVisible()&&c.IsInViewport3D(u._GetViewFrustum())){(!h.RendersToOwnZPlane()||0<c.GetDepth())&&o.push(h);const _=h.GetWorldInfo().GetTotalZElevation();a.push(h);let e=t+1;for(;e<s;++e){const d=n[e],p=d.GetWorldInfo();if(p.IsVisible()&&p.IsInViewport3D(p.GetLayer()._GetViewFrustum())){if(p.GetTotalZElevation()!==_)break;(d.RendersToOwnZPlane()?(0<p.GetDepth()&&o.push(d),a):o).push(d)}}if(1!==a.length||a[0].MustMitigateZFighting()){this._Draw3DLayersCoplanarInstances(i,r,a);for(let e=0,t=o.length;e<t;++e){const m=o[e],g=m.GetWorldInfo(),f=g.GetLayer();g._SetDrawNonBackFacesOnly(!0),MaybePrepareLayerDraw2(f,i),f._DrawInstanceMaybeWithEffects(m,g,i,r),g._SetDrawNonBackFacesOnly(!1)}}else{MaybePrepareLayerDraw2(u,i),u._DrawInstanceMaybeWithEffects(h,c,i,r);for(let e=0,t=o.length;e<t;++e){const S=o[e];if(S!==h){const C=S.GetWorldInfo(),y=C.GetLayer();MaybePrepareLayerDraw2(y,i),y._DrawInstanceMaybeWithEffects(S,C,i,r)}}}t=e,C33.clearArray(a),C33.clearArray(o)}else++t}s&&i.EndQuery(s),C33.clearArray(n),lastLayerPreparedForDrawing=null}_Draw3DLayersCoplanarInstances(s,i,r){s.CoplanarStartStencilPass();for(let e=0,t=r.length;e<t;++e){const n=r[e],a=n.GetWorldInfo(),o=a.GetLayer();a._SetDrawBackFaceOnly(!0),MaybePrepareLayerDraw2(o,s),o._DrawInstance(n,a,s)}s.CoplanarStartColorPass();for(let e=0,t=r.length;e<t;++e){const l=r[e],h=l.GetWorldInfo(),c=h.GetLayer();MaybePrepareLayerDraw2(c,s),c._DrawInstanceMaybeWithEffects(l,h,s,i),h._SetDrawBackFaceOnly(!1)}s.CoplanarRestoreStandardRendering()}_SaveToJson(){const e={sx:this.GetScrollX(),sy:this.GetScrollY(),s:this.GetScale(),a:this.GetAngle(),w:this.GetWidth(),h:this.GetHeight(),ortho:this.IsOrthographicProjection(),vpX:this.GetVanishingPointX(),vpY:this.GetVanishingPointY(),fv:this._isFirstVisit,persist:this._persistData,fx:this._effectList.SaveToJson(),layers:{},dynamicLayers:[]};for(const t of this._allLayersFlat)if(t.IsDynamic()){const s=t.GetParentLayer();e.dynamicLayers.push({sid:t.GetSID(),name:t.GetName(),parentSid:s?s.GetSID():null,siblingIndex:t._GetSiblingIndex(),data:t._SaveToJson()})}else e.layers[t.GetSID().toString()]=t._SaveToJson();return e}_LoadFromJson(e){this._scrollX=e.sx,this._scrollY=e.sy,this._scale=e.s,this._angle=e.a,this._width=e.w,this._height=e.h,this._isOrthographicProjection=!!e.ortho,e.hasOwnProperty("vpX")&&(this._vanishingPointX=e.vpX),e.hasOwnProperty("vpY")&&(this._vanishingPointY=e.vpY),this._isFirstVisit=!!e.fv,this._persistData=e.persist,this._effectList.LoadFromJson(e.fx),this._needsRebuildEffectChainSteps=!0;for(const[t,s]of Object.entries(e.layers)){const i=parseInt(t,10),r=this.GetLayerBySID(i);r&&r._LoadFromJson(s)}if(e.hasOwnProperty("dynamicLayers")){this.RemoveAllDynamicLayers(),this._runtime.FlushPendingInstances();const n=new Map,a=e.dynamicLayers;for(let e=a.length-1;0<=e;--e){const o=a[e],l=o.sid,h=o.name,c=o.parentSid,u=o.siblingIndex,_=o.data;if(this._ReindexLayers(),!this.HasLayerByName(h)&&!this.GetLayerBySID(l)){let e,t;if(null===c)e=null,t=this._rootLayers;else{if(!(e=this.GetLayerBySID(c)))continue;t=e.GetSubLayers()}const d=C33.New(C33.Layer,this,e,{name:h,sid:l,isDynamic:!0});t.push(d);let s=n.get(t);s||(s=[],n.set(t,s)),s.push({layer:d,siblingIndex:u}),d._LoadFromJson(_)}}for(const[p,m]of n){m.sort((e,t)=>e.siblingIndex-t.siblingIndex);for(const g of m){let e=g.layer,t=g.siblingIndex,s=p.indexOf(e);p.splice(s,1),p.splice(t,0,e)}}}this._ReindexAndUpdateAllLayers(),this._SetAllLayersProjectionChanged(),this._SetAllLayersMVChanged()}GetILayout(){return this._iLayout}UserScriptDispatcher(){return this._userScriptDispatcher}DispatchUserScriptEvent(e){e.layout=this.GetILayout();const t=this._runtime,s=t.IsDebug()&&!t.GetEventSheetManager().IsInEventEngine();s&&C3Debugger.StartMeasuringScriptTime(),this._userScriptDispatcher.dispatchEvent(e),s&&C3Debugger.AddScriptTime()}DispatchUserScriptEventAsyncWait(e){return e.layout=this.GetILayout(),this._userScriptDispatcher.dispatchEventAndWaitAsync(e)}DispatchRuntimeUserScriptEventAsyncWait(e){return e.layout=this.GetILayout(),this._runtime.DispatchUserScriptEventAsyncWait(e)}_LogLayerTree(){this._LogLayerList(this._rootLayers)}_LogLayerList(e,t=0){const s=e.slice(0);s.reverse();for(const i of s)console.log("\t".repeat(t)+"- "+i.GetName()),this._LogLayerList(i.GetSubLayers(),t+1)}}}{const C33=self.C3;C33.LayoutManager=class extends C33.DefendedBase{#runtime;#allLayouts=[];#layoutsByName=new Map;#layoutsBySid=new Map;#mainRunningLayout=null;#runningSubLayouts=[];#firstLayout=null;#isEndingLayout=0;#pendingChangeLayout=null;constructor(e){super(),this.#runtime=e}Release(){this.#runtime=null,this.#mainRunningLayout=null,this.#firstLayout=null,this.#pendingChangeLayout=null,C33.clearArray(this.#allLayouts),this.#layoutsByName.clear(),this.#layoutsBySid.clear(),C33.clearArray(this.#runningSubLayouts)}Create(e){const t=C33.New(C33.Layout,this,this.#allLayouts.length,e);this.#allLayouts.push(t),this.#layoutsByName.set(t.GetName().toLowerCase(),t),this.#layoutsBySid.set(t.GetSID(),t)}GetRuntime(){return this.#runtime}SetFirstLayout(e){this.#firstLayout=e}GetFirstLayout(){if(this.#firstLayout)return this.#firstLayout;if(this.#allLayouts.length)return this.#allLayouts[0];throw new Error("no first layout")}GetLayoutByName(e){return this.#layoutsByName.get(e.toLowerCase())||null}GetLayoutBySID(e){return this.#layoutsBySid.get(e)||null}GetLayoutByIndex(e){return e=C33.clamp(Math.floor(e),0,this.#allLayouts.length-1),this.#allLayouts[e]}GetLayout(e){return"number"==typeof e?this.GetLayoutByIndex(e):this.GetLayoutByName(e.toString())}GetAllLayouts(){return this.#allLayouts}_SetMainRunningLayout(e){this.#mainRunningLayout=e}GetMainRunningLayout(){return this.#mainRunningLayout}_AddRunningSubLayout(e){if(this.#runningSubLayouts.includes(e))throw new Error("layout already running");this.#runningSubLayouts.push(e)}_RemoveRunningSubLayout(e){const t=this.#runningSubLayouts.indexOf(e);if(-1===t)throw new Error("layout not running");this.#runningSubLayouts.splice(t,1)}*runningLayouts(){this.#mainRunningLayout&&(yield this.#mainRunningLayout),this.#runningSubLayouts.length&&(yield*this.#runningSubLayouts)}IsLayoutRunning(e){return this.#mainRunningLayout===e||this.#runningSubLayouts.includes(e)}SetIsEndingLayout(e){if(e)this.#isEndingLayout++;else{if(this.#isEndingLayout<=0)throw new Error("already unset");this.#isEndingLayout--}}IsEndingLayout(){return 0<this.#isEndingLayout}ChangeMainLayout(e){this.#pendingChangeLayout=e}ClearPendingChangeLayout(){this.#pendingChangeLayout=null}IsPendingChangeMainLayout(){return!!this.#pendingChangeLayout}GetPendingChangeMainLayout(){return this.#pendingChangeLayout}SetAllLayerProjectionChanged(){const e=this.GetMainRunningLayout();e&&e._SetAllLayersProjectionChanged()}SetAllLayerMVChanged(){const e=this.GetMainRunningLayout();e&&e._SetAllLayersMVChanged()}}}{const C33=self.C3,NAMES_REGEXP=new RegExp("<(.+?)>","g");C33.TimelineManager=class extends C33.DefendedBase{constructor(e){super(),this._runtime=e,this._timelineDataManager=C33.New(C33.TimelineDataManager),this._pluginInstance=null,this._timelines=[],this._timelinesByName=new Map,this._objectClassToTimelineMap=new Map,this._timelinesCreatedByTemplate=new Map,this._scheduledTimelines=[],this._playingTimelines=[],this._markedForRemovalTimelines=[],this._hasRuntimeListeners=!1,this._changingLayout=!1,this._isTickingTimelines=!1,this._tickFunc=()=>this._OnTick(),this._tick2Func=()=>this._OnTick2(),this._beforeLayoutChange=()=>this._OnBeforeChangeLayout(),this._layoutChange=()=>this._OnAfterChangeLayout(),this._instanceDestroy=e=>this._OnInstanceDestroy(e.instance),this._beforeLoad=e=>this._OnBeforeLoad(),this._afterLoad=e=>this._OnAfterLoad(),this._afterLayoutStart=e=>this._OnAfterLayoutStart(),this._destroyedWhileLoadingState=[],this._renderChange=0}Release(){this.RemoveRuntimeListeners(),this._tickFunc=null,this._tick2Func=null,this._beforeLayoutChange=null,this._layoutChange=null,this._instanceDestroy=null,this._afterLoad=null;for(const e of this._timelines)e.Stop(),e.Release();C33.clearArray(this._timelines),this._timelines=null,this._timelineDataManager.Release(),this._timelineDataManager=null,C33.clearArray(this._scheduledTimelines),this._scheduledTimelines=null,C33.clearArray(this._playingTimelines),this._playingTimelines=null,C33.clearArray(this._markedForRemovalTimelines),this._markedForRemovalTimelines=null,this._timelinesByName.clear(),this._timelinesByName=null,this._objectClassToTimelineMap.clear(),this._objectClassToTimelineMap=null,this._timelinesCreatedByTemplate.clear(),this._timelinesCreatedByTemplate=null,C33.clearArray(this._destroyedWhileLoadingState),this._destroyedWhileLoadingState=null,this._runtime=null}AddRuntimeListeners(){const e=this._runtime.Dispatcher();e.addEventListener("pretick",this._tickFunc),e.addEventListener("tick2",this._tick2Func),e.addEventListener("beforelayoutchange",this._beforeLayoutChange),e.addEventListener("layoutchange",this._layoutChange),e.addEventListener("instancedestroy",this._instanceDestroy),e.addEventListener("beforeload",this._beforeLoad),e.addEventListener("afterload",this._afterLoad),e.addEventListener("afterlayoutstart",this._afterLayoutStart)}RemoveRuntimeListeners(){const e=this._runtime.Dispatcher();e.removeEventListener("pretick",this._tickFunc),e.removeEventListener("tick2",this._tick2Func),e.removeEventListener("beforelayoutchange",this._beforeLayoutChange),e.removeEventListener("layoutchange",this._layoutChange),e.removeEventListener("instancedestroy",this._instanceDestroy),e.removeEventListener("beforeload",this._beforeLoad),e.removeEventListener("afterload",this._afterLoad),e.removeEventListener("afterlayoutstart",this._afterLayoutStart)}Create(e){this._timelineDataManager.Add(e);const t=C33.TimelineState.CreateInitial(e,this);this.Add(t),this.SetTimelineObjectClassesToMap(t),this._timelinesCreatedByTemplate.set(t.GetName(),0)}CreateFromTemplate(e){const t=this.GetTimelineDataManager(),s=e.GetTemplateName(),i=t.Get(s),r=C33.TimelineState.CreateFromTemplate(s+":"+this._timelinesCreatedByTemplate.get(s),i,this);return this._IncreaseTemplateTimelinesCount(s),this.Add(r),r}_IncreaseTemplateTimelinesCount(e){this._timelinesCreatedByTemplate.set(e,this._timelinesCreatedByTemplate.get(e)+1)}_SetCreatedTemplateTimelinesCount(){for(const e of this._timelines)if(!e.IsTemplate()){const t=e.GetTemplateName();this._IncreaseTemplateTimelinesCount(t)}}_ClearCreatedTemplateTimelinesCount(){for(const e of this._timelinesCreatedByTemplate.keys())this._timelinesCreatedByTemplate.set(e,0)}Add(e){this._timelines.push(e),this._timelinesByName.set(e.GetName().toLowerCase(),e)}Remove(e){e.Removed(),e.IsTemplate()||(C33.arrayFindRemove(this._timelines,e),C33.arrayFindRemove(this._scheduledTimelines,e),C33.arrayFindRemove(this._playingTimelines,e),C33.arrayFindRemove(this._markedForRemovalTimelines,e),this._timelinesByName.delete(e.GetName().toLowerCase()),this.RemoveTimelineFromObjectClassMap(e),e.IsReleased())||e.Release()}Trigger(e){this._runtime.Trigger(e,this._pluginInstance,null)}GetRuntime(){return this._runtime}GetTimelineDataManager(){return this._timelineDataManager}SetPluginInstance(e){this._pluginInstance=e}GetPluginInstance(){return this._pluginInstance}*GetTimelines(){for(const e of this._timelines)yield e}*GetPlayingTimelines(){for(const e of this._playingTimelines)yield e}SetTimelineObjectClassToMap(e,t){this._objectClassToTimelineMap.has(e)||this._objectClassToTimelineMap.set(e,new Set),this._objectClassToTimelineMap.get(e).add(t)}SetTimelineObjectClassesToMap(e){for(const t of e.GetObjectClasses())this.SetTimelineObjectClassToMap(t,e)}RemoveTimelineFromObjectClassMap(e){for(const[t,s]of this._objectClassToTimelineMap.entries())s.has(e)&&(s.delete(e),0===s.size)&&this._objectClassToTimelineMap.delete(t)}GetTimelinesForObjectClass(e){if(this._objectClassToTimelineMap.has(e))return this._objectClassToTimelineMap.get(e)}GetTimelineOfTemplateForInstances(e,t){if(t)for(const s of this._timelines){const i=t.every(e=>s.HasTrackInstance(e.instance,e.trackId));if(i&&s.GetName().includes(e.GetName()))return s}}GetTimelineByName(e){return this._timelinesByName.get(e.toLowerCase())||null}GetScheduledOrPlayingTimelineByName(e){for(const t of this._scheduledTimelines)if(t.GetName()===e)return t;for(const s of this._playingTimelines)if(s.GetName()===e)return s;return null}*GetTimelinesByName(s){if(NAMES_REGEXP.test(s)){NAMES_REGEXP.lastIndex=0;let e,t=new Set;do{if(e=NAMES_REGEXP.exec(s)){const i=e[1].split(",");for(const r of i)t.add(r)}}while(e);for(const n of t.values()){const a=this.GetTimelineByName(n);a&&(yield a)}t.clear()}else{const e=this.GetTimelineByName(s);e&&(yield e)}}*GetTimelinesByTags(e){for(const t of this._timelines)t.HasTags(e)&&(yield t)}AddScheduledTimeline(e){this._scheduledTimelines.includes(e)||this._scheduledTimelines.push(e),this._MaybeEnableRuntimeListeners()}RemovePlayingTimeline(e){C33.arrayFindRemove(this._playingTimelines,e),this._MaybeDisableRuntimeListeners()}ScheduleTimeline(e){this._playingTimelines.includes(e)?(e.SetPlaying(!0),e.SetScheduled(!1),e.SetMarkedForRemoval(!1)):(e.SetPlaying(!1),e.SetScheduled(!0),e.SetMarkedForRemoval(!1),this._scheduledTimelines.includes(e)||this._scheduledTimelines.push(e)),this._MaybeEnableRuntimeListeners()}DeScheduleTimeline(e){e.SetPlaying(!1),e.SetScheduled(!1),e.ResolvePlayPromise(),C33.arrayFindRemove(this._scheduledTimelines,e),this._MaybeDisableRuntimeListeners()}CompleteTimeline(e){e.SetPlaying(!1),e.SetScheduled(!1),this._playingTimelines.includes(e)&&(e.SetMarkedForRemoval(!0),this._markedForRemovalTimelines.push(e),C33.arrayFindRemove(this._playingTimelines,e)),this._scheduledTimelines.includes(e)&&e.SetMarkedForRemoval(!0)}CompleteTimelineBeforeChangeOfLayout(e){e.SetPlaying(!1),e.SetScheduled(!1),e.SetMarkedForRemoval(!1),e.SetPlaybackRate(1),C33.arrayFindRemove(this._playingTimelines,e)}CompleteTimelineAndResolve(e){this.CompleteTimeline(e),e.ResolvePlayPromise()}_OnTick(){if(!this.GetRuntime().IsLoadingState()&&this._hasRuntimeListeners&&!this._changingLayout){for(this._isTickingTimelines=!0;this._scheduledTimelines.length;){const e=this._scheduledTimelines.pop();(e.IsMarkedForRemoval()?(e.SetInitialStateForce(),this._markedForRemovalTimelines):(e.SetInitialState(),this._playingTimelines)).push(e),0!==e.GetRenderChange()&&(this._renderChange=1)}const t=this._runtime._GetDtFast(),s=this._runtime.GetDt1(),i=this._runtime.GetTimeScale();for(let e=this._playingTimelines.length-1;0<=e;e--){const r=this._playingTimelines[e];r&&r.Tick(t,i,s)}this._isTickingTimelines=!1,0!==this._renderChange&&this.GetRuntime().UpdateRender()}}_OnTick2(){if(!this.GetRuntime().IsLoadingState()&&this._hasRuntimeListeners&&!this._changingLayout){let s;for(let e=0,t=this._markedForRemovalTimelines.length;e<t;e++){const i=this._markedForRemovalTimelines[e];s=s||new Set,i.Removed(),this._MaybeExecuteTimelineFinishTriggers(i),s.add(i)}if(s){C33.arrayRemoveAllInSet(this._markedForRemovalTimelines,s);for(let e=this._renderChange=0,t=this._playingTimelines.length;e<t;e++)if(0!==this._playingTimelines[e].GetRenderChange()){this._renderChange=1;break}}this._MaybeDisableRuntimeListeners()}}_MaybeExecuteTimelineFinishTriggers(e){e.IsReleased()||e.HasValidTracks()&&e.IsComplete()&&e.InitialStateSet()&&e.FinishTriggers()}_MaybeEnableRuntimeListeners(){this._hasRuntimeListeners||(this._hasRuntimeListeners=!0)}_MaybeDisableRuntimeListeners(){this._markedForRemovalTimelines.length||this._playingTimelines.length||this._scheduledTimelines.length||this._isTickingTimelines||(this._hasRuntimeListeners=!1)}_OnBeforeChangeLayout(){for(this._changingLayout=!0;this._scheduledTimelines.length;)this.DeScheduleTimeline(this._scheduledTimelines.pop());const e=new Set;for(const t of this._playingTimelines){const s=t._OnBeforeChangeLayout();s&&(t.Removed(),e.add(t))}C33.arrayRemoveAllInSet(this._playingTimelines,e),e.clear();for(const i of this._markedForRemovalTimelines){const r=i._OnBeforeChangeLayout();r&&(i.Removed(),e.add(i))}C33.arrayRemoveAllInSet(this._markedForRemovalTimelines,e),this._MaybeDisableRuntimeListeners();for(const n of this._timelines)n.CleanCaches()}_OnAfterChangeLayout(){this._changingLayout=!1}_OnInstanceDestroy(e){const t=e.GetObjectClass(),s=this.GetTimelinesForObjectClass(t);if(s)if(this._runtime.IsLoadingState())this._destroyedWhileLoadingState.push(e);else for(const i of s)i.IsTemplate()||(i.IsReleased()?this.Remove(i):i.HasValidTracks()||(this._MaybeExecuteTimelineFinishTriggers(i),this.Remove(i)))}_OnBeforeLoad(){for(const e of this._scheduledTimelines.map(e=>e))this._MaybeExecuteTimelineFinishTriggers(e),this.Remove(e);for(const t of this._playingTimelines.map(e=>e))this._MaybeExecuteTimelineFinishTriggers(t),this.Remove(t)}_OnAfterLoad(){for(const e of this._destroyedWhileLoadingState)this._OnInstanceDestroy(e);C33.clearArray(this._destroyedWhileLoadingState);for(const t of this._timelines)t._OnAfterLoad()}_OnAfterLayoutStart(){const e=this._runtime.GetLayoutManager(),t=e.GetMainRunningLayout();if(t)for(const s of this._timelines){const i=s.GetStartOnLayout();i&&t.GetName()===i&&this.ScheduleTimeline(s)}}_SaveToJson(){return{timelinesJson:this._SaveTimelinesToJson(),scheduledTimelinesJson:this._SaveScheduledTimelinesToJson(),playingTimelinesJson:this._SavePlayingTimelinesToJson(),markedForRemovalTimelinesJson:this._SaveMarkedForRemovalTimelinesToJson(),hasRuntimeListeners:this._hasRuntimeListeners,changingLayout:this._changingLayout,isTickingTimelines:this._isTickingTimelines}}_LoadFromJson(e){e&&(this._ClearCreatedTemplateTimelinesCount(),this._LoadTimelinesFromJson(e.timelinesJson),this._LoadScheduledTimelinesFromJson(e.scheduledTimelinesJson),this._LoadPlayingTimelinesFromJson(e.playingTimelinesJson),this._LoadMarkedForRemovalTimelinesFromJson(e.markedForRemovalTimelinesJson),this._hasRuntimeListeners=!e.hasRuntimeListeners,this._changingLayout=!!e.changingLayout,this._isTickingTimelines=!!e.isTickingTimelines,this._SetCreatedTemplateTimelinesCount(),this._MaybeEnableRuntimeListeners(),this._MaybeDisableRuntimeListeners())}_SaveTimelinesToJson(){return this._timelines.map(e=>e._SaveToJson())}_LoadTimelinesFromJson(e){for(const t of e){let e=this.GetTimelineByName(t.name);if(e)e._LoadFromJson(t);else{const s=this._GetTemplateNameFromJson(t);if(!s)continue;const i=this.GetTimelineByName(s);(e=this.CreateFromTemplate(i))._LoadFromJson(t)}e.HasTracks()||this.Remove(e)}}_GetTemplateNameFromJson(e){const t=e.name,s=t.split(":");return s&&2===s.length?s[0]:null}_SaveScheduledTimelinesToJson(){return this._SaveTimelines(this._scheduledTimelines)}_LoadScheduledTimelinesFromJson(e){this._LoadTimelines(e,this._scheduledTimelines)}_SavePlayingTimelinesToJson(){return this._SaveTimelines(this._playingTimelines)}_LoadPlayingTimelinesFromJson(e){this._LoadTimelines(e,this._playingTimelines)}_SaveMarkedForRemovalTimelinesToJson(){return this._SaveTimelines(this._markedForRemovalTimelines)}_LoadMarkedForRemovalTimelinesFromJson(e){this._LoadTimelines(e,this._markedForRemovalTimelines)}_IsTimelineInJson(e,t){if(t)for(const s of t)if(s===e.GetName())return!0;return!1}_SaveTimelines(e){return e.map(e=>e.GetName())}_LoadTimelines(e,t){const s=new Set;for(const i of t)this._IsTimelineInJson(i,e)||s.add(i);if(C33.arrayRemoveAllInSet(t,s),e)for(const r of e){const n=this.GetTimelineByName(r);if(n){const a=t.find((t=>e=>e.GetName()===t)(r));a||t.push(n)}}}}}{const C33=self.C3,STEPS=100,LENGTH_STEP_SIZE=.01,BEZIER_STEP_SIZE=25,REFINE_ITERATIONS=20,LOOKUP_STEPS_FROM_LAST=5,TANGENT_RESULT=[0,0],MAP_RESULT=[0,0],SHORT_PROJECTION_RESULT=[0,0],PROJECTION_RESULT=[0,0,0,0,0],REFINE_LUT=new Array(4),REFINE_LUT_OBJECTS=[{x:0,y:0,t:0,distance:0},{x:0,y:0,t:0,distance:0},{x:0,y:0,t:0,distance:0}],REFINE_RESULT={x:0,y:0,t:0,distance:0};C33.TimelineInfo=class{constructor(e,t){this._initialized=!1,this._timeline=e,this._segments=[];let s=null;if(s=t?this._timeline.GetTrackById(t):C33.first(this._timeline.GetTracks())){const i=s.GetPropertyTrack("offsetX"),r=s.GetPropertyTrack("offsetY");if(i&&r){this._xTrack=i,this._yTrack=r;const n=i.GetPropertyKeyframeDataItemArrayIncludingDisabled(),a=r.GetPropertyKeyframeDataItemArrayIncludingDisabled();for(let e=1,t=Math.min(n.length,a.length);e<t;++e){const o=n[e],l=(o.GetNext(),o.GetPrevious()),h=a[e],c=(h.GetNext(),h.GetPrevious());l&&"cubic-bezier"===l.GetPathMode()&&c&&"cubic-bezier"===c.GetPathMode()?this._segments.push(C33.New(C33.TimelineCubicBezierSegmentInfo,l,c,o,h,this._segments.length)):(l&&"line"===l.GetPathMode()&&c&&c.GetPathMode(),this._segments.push(C33.New(C33.TimelineLineSegmentInfo,o,h,this._segments.length)))}this._initialized=!0}}}Release(){for(const e of this._segments)e.Release();C33.clearArray(this._segments),this._segments=null,this._timeline=null,this._xTrack=null,this._yTrack=null}WasInitialized(){return this._initialized}segments(){return this._segments}SetOrigin(e){const t="relative"===this._xTrack.GetResultMode()?e.GetX():0,s="relative"===this._yTrack.GetResultMode()?e.GetY():0;for(const i of this._segments)i.SetOrigin(t,s)}Project(t,s,e){let i=NaN,r=this._segments.length;for(let e=0;e<r;e++){const n=this._segments[e];if("cubic-bezier"===n.GetType()){const a=n.Project(t,s);(isNaN(i)||a[3]<i)&&(i=a[3],SHORT_PROJECTION_RESULT[0]=a[2],SHORT_PROJECTION_RESULT[1]=n.GetIndex())}}return SHORT_PROJECTION_RESULT}ProjectWithOptions(t,s,e){const i=e.tRange;C33.IsFiniteNumber(i[0])||(i[0]=0),C33.IsFiniteNumber(i[1])||(i[1]=1);let r=NaN,n=this._segments.length;for(let e=0;e<n;e++){const a=this._segments[e];if("cubic-bezier"===a.GetType()){const o=a.ProjectWithRange(t,s,i);(isNaN(r)||o[3]<r)&&(r=o[3],SHORT_PROJECTION_RESULT[0]=o[2],SHORT_PROJECTION_RESULT[1]=a.GetIndex())}}return SHORT_PROJECTION_RESULT}Tangent(e,t){return this._segments[t].Tangent(e)}TangentAngle(e,t){return this._segments[t].TangentAngle(e)}},C33.TimelineCubicBezierSegmentInfo=class{constructor(e,t,s,i,r){this._index=r;const n=e.GetAddOn("cubic-bezier"),a=s.GetAddOn("cubic-bezier"),o=t.GetAddOn("cubic-bezier"),l=i.GetAddOn("cubic-bezier");this._aX=e.GetValueWithResultMode(),this._aY=t.GetValueWithResultMode(),this._bX=e.GetValueWithResultMode()+n.GetStartAnchor(),this._bY=t.GetValueWithResultMode()+o.GetStartAnchor(),this._cX=s.GetValueWithResultMode()+a.GetEndAnchor(),this._cY=i.GetValueWithResultMode()+l.GetEndAnchor(),this._dX=s.GetValueWithResultMode(),this._dY=i.GetValueWithResultMode(),this._aXO=0,this._aYO=0,this._bXO=0,this._bYO=0,this._cXO=0,this._cYO=0,this._dXO=0,this._dYO=0,this._d0x=0,this._d0y=0,this._d1x=0,this._d1y=0,this._d2x=0,this._d2y=0,this._x1Factor=0,this._x2Factor=0,this._x3Factor=0,this._y1Factor=0,this._y2Factor=0,this._y3Factor=0,this._lutIndex=NaN,this._initialized=!1,this._len=STEPS,this._arcLengths=new Array(this._len+1),this._arcLengths[0]=0,this._length=0,this._lut=[],this._lutObjects=[];for(let e=0;e<STEPS;e++)this._lutObjects.push({x:0,y:0,t:0,distance:0});this._CalculateLength()}Release(){C33.clearArray(this._arcLengths),this._arcLengths=null,C33.clearArray(this._lut),this._lut=null,C33.clearArray(this._lutObjects),this._lutObjects=null}GetType(){return"cubic-bezier"}GetIndex(){return this._index}GetStepCount(){return Math.floor(this._length/BEZIER_STEP_SIZE)}GetStepIncrement(){return 1/this.GetStepCount()}SetOrigin(e,t){this._originX=e,this._originY=t,this._arcLengths=new Array(this._len+1),this._arcLengths[0]=0,this._CalculateLength(),this._aXO=this._aX+this._originX,this._aYO=this._aY+this._originY,this._bXO=this._bX+this._originX,this._bYO=this._bY+this._originY,this._cXO=this._cX+this._originX,this._cYO=this._cY+this._originY,this._dXO=this._dX+this._originX,this._dYO=this._dY+this._originY,this._d0x=3*(this._bXO-this._aXO),this._d0y=3*(this._bYO-this._aYO),this._d1x=3*(this._cXO-this._bXO),this._d1y=3*(this._cYO-this._bYO),this._d2x=3*(this._dXO-this._cXO),this._d2y=3*(this._dYO-this._cYO),this._x1Factor=3*(this._bXO-this._aXO),this._x2Factor=3*(this._aXO+this._cXO-2*this._bXO),this._x3Factor=this._dXO-this._aXO+3*(this._bXO-this._cXO),this._y1Factor=3*(this._bYO-this._aYO),this._y2Factor=3*(this._aYO+this._cYO-2*this._bYO),this._y3Factor=this._dYO-this._aYO+3*(this._bYO-this._cYO)}Map(e){if(!this._initialized)return NaN;const t=this._Map(e);return MAP_RESULT[0]=this._X(t),MAP_RESULT[1]=this._Y(t),MAP_RESULT}Project(e,t){const s=this._GenerateLUT(STEPS),i=this._FindClosestFromLUT(e,t,s),r=this._RefineProjection(e,t,s,i);return PROJECTION_RESULT[0]=r.x,PROJECTION_RESULT[1]=r.y,PROJECTION_RESULT[2]=r.t,PROJECTION_RESULT[3]=r.distance,PROJECTION_RESULT}ProjectWithRange(e,t,s){const i=this._GenerateLUT(STEPS),r=this._FindClosestFromLUTWithRange(e,t,i,s),n=this._RefineProjection(e,t,i,r);return PROJECTION_RESULT[0]=n.x,PROJECTION_RESULT[1]=n.y,PROJECTION_RESULT[2]=n.t,PROJECTION_RESULT[3]=n.distance,PROJECTION_RESULT}Tangent(e){const t=1-e,s=t*t,i=2*t*e,r=e*e,n=s*this._d0x+i*this._d1x+r*this._d2x,a=s*this._d0y+i*this._d1y+r*this._d2y,o=C33.hypot2DFast(n,a);return TANGENT_RESULT[0]=n/o,TANGENT_RESULT[1]=a/o,TANGENT_RESULT}TangentAngle(e){const t=1-e,s=t*t,i=2*t*e,r=e*e,n=s*this._d0x+i*this._d1x+r*this._d2x,a=s*this._d0y+i*this._d1y+r*this._d2y;return Math.atan2(a,n)}_Map(r){if(this._initialized){let e=r*this._arcLengths[this._len],t=0,s=this._len,i=0;for(;t<s;)i=t+((s-t)/2|0),this._arcLengths[i]<e?t=i+1:s=i;this._arcLengths[i]>e&&i--;const n=this._arcLengths[i];return n===e?i/this._len:(i+(e-n)/(this._arcLengths[i+1]-n))/this._len}}_X(e){return this._initialized?self.Ease.GetRuntimeEase("cubicbezier")(e,this._aX+this._originX,this._bX+this._originX,this._cX+this._originX,this._dX+this._originX):NaN}_Y(e){return this._initialized?self.Ease.GetRuntimeEase("cubicbezier")(e,this._aY+this._originY,this._bY+this._originY,this._cY+this._originY,this._dY+this._originY):NaN}_GenerateLUT(t){if(t=t||STEPS,!(this._lut.length>=t)){this._lut=new Array(t),t++;for(let e=0;e<t-1;e++){const s=e/(t-1),i=s**2,r=s**3,n=this._x1Factor*s,a=this._x2Factor*i,o=this._x3Factor*r,l=this._y1Factor*s,h=this._y2Factor*i,c=this._y3Factor*r,u=this._aXO+n+a+o,_=this._aYO+l+h+c;this._lutObjects[e].x=u,this._lutObjects[e].y=_,this._lutObjects[e].t=s,this._lutObjects[e].distance=0,this._lut[e]=this._lutObjects[e]}}return this._lut}_FindClosestFromLUT(t,s,i,e=0,r=Number.MAX_SAFE_INTEGER){let n=0;if(isNaN(this._lutIndex))for(let e=0;e<STEPS;e++){const a=i[e],o=a.x-t,l=a.y-s;a.distance=o*o+l*l,a.distance<r&&(r=a.distance,n=e)}else{for(let e=this._lutIndex;e<this._lutIndex+LOOKUP_STEPS_FROM_LAST&&!(e>=i.length);e++){const h=i[e],c=h.x-t,u=h.y-s;h.distance=c*c+u*u,h.distance<r&&(r=h.distance,n=e)}for(let e=this._lutIndex;e>this._lutIndex-LOOKUP_STEPS_FROM_LAST&&!(e<0);e--){const _=i[e],d=_.x-t,p=_.y-s;_.distance=d*d+p*p,_.distance<r&&(r=_.distance,n=e)}}return this._lutIndex=n}_FindClosestFromLUTWithRange(t,s,i,r,n=Number.MAX_SAFE_INTEGER){let a=0;if(isNaN(this._lutIndex))for(let e=0;e<STEPS;e++){const o=i[e],l=o.x-t,h=o.y-s;o.distance=l*l+h*h,o.t>=r[0]&&o.t<=r[1]&&o.distance<n&&(n=o.distance,a=e)}else{for(let e=this._lutIndex;e<this._lutIndex+LOOKUP_STEPS_FROM_LAST&&!(e>=i.length);e++){const c=i[e],u=c.x-t,_=c.y-s;c.distance=u*u+_*_,c.t>=r[0]&&c.t<=r[1]&&c.distance<n&&(n=c.distance,a=e)}for(let e=this._lutIndex;e>this._lutIndex-LOOKUP_STEPS_FROM_LAST&&!(e<0);e--){const d=i[e],p=d.x-t,m=d.y-s;d.distance=p*p+m*m,d.t>=r[0]&&d.t<=r[1]&&d.distance<n&&(n=d.distance,a=e)}}return this._lutIndex=a}_RefineProjection(a,o,l,h){let c=l[h],e=1,u=Number.MAX_SAFE_INTEGER;e:do{let e=l.length,t=0===h?0:h-1,s=h===e-1?e-1:h+1,i=l[t].t,r=l[s].t,n=(r-i)/4;if(n<.001)break;REFINE_LUT[0]=l[t];for(let e=1;e<=2;e++){const _=i+e*n,d=_**2,p=_**3,m=this._x1Factor*_,g=this._x2Factor*d,f=this._x3Factor*p,S=this._y1Factor*_,C=this._y2Factor*d,y=this._y3Factor*p,G=this._aXO+m+g+f,I=this._aYO+S+C+y,T=G-a,b=I-o,A=T*T+b*b;if(A<u){u=A,h=e,REFINE_RESULT.x=G,REFINE_RESULT.y=I,REFINE_RESULT.t=_,REFINE_RESULT.distance=A,c=REFINE_RESULT;break e}const P=REFINE_LUT_OBJECTS[e-1];P.x=G,P.y=I,P.t=_,P.distance=A,REFINE_LUT[e]=P}REFINE_LUT[3]=l[s],l=REFINE_LUT}while(e++<REFINE_ITERATIONS);return c}_CalculateLength(){this._initialized=!0;let t=this._X(0),s=this._Y(0),i=0;for(let e=1;e<=this._len;e++){const r=this._X(e*LENGTH_STEP_SIZE),n=this._Y(e*LENGTH_STEP_SIZE),a=t-r,o=s-n;i+=C33.hypot2DFast(a,o),this._arcLengths[e]=i,t=r,s=n}this._length=i}},C33.TimelineLineSegmentInfo=class{constructor(e,t,s){this._index=s,this._targetX=e.GetValueWithResultMode(),this._targetY=t.GetValueWithResultMode(),this._originX=0,this._originY=0}Release(){}GetType(){return"line"}GetIndex(){return this._index}SetOrigin(e,t){this._originX=e,this._originY=t}GetX(){return this._targetX+this._originX}GetY(){return this._targetY+this._originY}}}{const C33=self.C3,PING_PONG_BEGIN=0,PING_PONG_END=1;C33.TimelineState=class extends C33.DefendedBase{constructor(e,t,s){super(),this._runtime=s.GetRuntime(),this._timelineManager=s,this._timelineDataItem=t,this._name=e,this._tracks=[],this._tracksLength=0,this._beforeAndAfterTracks=null,this._beforeAndAfterTracksLength=0,this.CreateTrackStates(),this._playPromise=null,this._playResolve=null,this._playheadTime=0,this._overshoot=0,this._playbackRate=1,this._pingPongState=PING_PONG_BEGIN,this._currentRepeatCount=1,this._isPlaying=!1,this._isScheduled=!1,this._initialStateSet=!1,this._complete=!0,this._released=!1,this._markedForRemoval=!1,this._completedTick=-1,this._implicitPause=!1,this._isTemplate=!1,this._finishedTriggers=!1,this._firstTick=!1,this._lastDelta=NaN,this._tags=[""],this._stringTags="",this._tagsChanged=!1,this._renderChange=0,this._hasNestedContent=0,this._iTimelineState=null}static CreateInitial(e,t){const s=t.GetTimelineDataManager(),i=s.GetNameId(),r=s.Get(e[i]),n=C33.New(C33.TimelineState,e[i],r,t);return n.SetIsTemplate(!0),n}static CreateFromTemplate(e,t,s){return C33.New(C33.TimelineState,e,t,s)}Release(){if(!this.IsReleased()){const e=this._runtime.Dispatcher();this._timelineManager.DeScheduleTimeline(this),this._timelineManager.CompleteTimelineAndResolve(this);for(const t of this._tracks)t.Release();C33.clearArray(this._tracks),this._tracks=null,this._runtime=null,this._timelineManager=null,this._timelineDataItem=null,this._released=!0,this._playPromise=null,this._playResolve=null,this.FireReleaseEvent(e)}}FireReleaseEvent(e){const t=C33.New(C33.Event,"timelinestatereleased");t.timelineState=this,e.dispatchEvent(t)}GetType(){return 0}CreateTrackStates(){for(const e of this._timelineDataItem.GetTrackData().trackDataItems())this._tracksLength=this._tracks.push(C33.TrackState.Create(this,e))}GetTimelineManager(){return this._timelineManager}GetRuntime(){return this._runtime}GetTracks(){return this._tracks}GetSimilarPropertyTracks(i,r,n,a){if(this._hasNestedContent){let s;for(let t=0;t<this._tracks.length;t++){let e=this._tracks[t];if(i===e.GetInstance()){const o=e.GetPropertyTrack(n);o&&r.constructor===o.GetSourceAdapter().constructor&&o.GetResultMode()===a.GetResultMode()&&(s=s||[]).push(o)}}return s}}HasTracks(){return!!this._tracks.length}GetTrackById(e){for(const t of this._tracks)if(C33.equalsNoCase(t.GetId(),e))return t;return null}GetTrackByName(e){for(const t of this._tracks)if(!t.IsInstanceTrack()&&C33.equalsNoCase(t.GetName(),e))return t;return null}SetName(e){this._name=e}GetName(){return this._name}GetTimelineDataItem(){return this._timelineDataItem}GetTemplateName(){return this._timelineDataItem.GetName()}GetTotalTime(){return this._timelineDataItem.GetTotalTime()}SetTotalTime(e){this._timelineDataItem.SetTotalTime(e)}GetStep(){return this._timelineDataItem.GetStep()}SetStep(e){this._timelineDataItem.SetStep(e)}GetInterpolationMode(){return this._timelineDataItem.GetInterpolationMode()}SetInterpolationMode(e){this._timelineDataItem.SetInterpolationMode(e)}GetResultMode(){return this._timelineDataItem.GetResultMode()}SetResultMode(e){this._timelineDataItem.GetResultMode(e)}SetEase(e){for(const t of this.GetTracks())t.SetEase(e)}GetLoop(){return this._timelineDataItem.GetLoop()}SetLoop(e){return this._timelineDataItem.SetLoop(e)}GetPingPong(){return this._timelineDataItem.GetPingPong()}SetPingPong(e){return this._timelineDataItem.SetPingPong(e)}GetRepeatCount(){return this._timelineDataItem.GetRepeatCount()}SetRepeatCount(e){return this._timelineDataItem.SetRepeatCount(e)}SetPlaybackRate(e){return this._playbackRate=e}GetPlaybackRate(){return this._playbackRate}GetStartOnLayout(){return this._timelineDataItem.GetStartOnLayout()}GetTransformWithSceneGraph(){return this._timelineDataItem.GetTransformWithSceneGraph()}GetUseSystemTimescale(){return this._timelineDataItem.GetUseSystemTimescale()}GetPingPongState(){return this._pingPongState}IsForwardPlayBack(){return!this.IsPlaying()||0<this._playbackRate}GetPlayPromise(){return this._playPromise||(this._playPromise=new Promise(e=>{this._playResolve=e})),this._playPromise}ResolvePlayPromise(){this._playPromise&&(this._playResolve(),this._playPromise=null,this._playResolve=null)}SetTags(e){this._tags=C33.TimelineState._GetTagArray(e),this._tagsChanged=!0}GetTags(){return this._tags}GetStringTags(){return this._tagsChanged&&(this._stringTags=this._tags.join(" ")),this._tagsChanged=!1,this._stringTags}HasTags(e){if(!this._tags)return!1;if(!this._tags.length)return!1;const t=C33.TimelineState._GetTagArray(e);return!!t&&!!t.length&&t.every(C33.TimelineState._HasTag,this)}OnStarted(){C33.Plugins.Timeline&&this.constructor===C33.TimelineState&&(C33.Plugins.Timeline.Cnds.PushTriggerTimeline(this),this._timelineManager.Trigger(C33.Plugins.Timeline.Cnds.OnTimelineStarted),this._timelineManager.Trigger(C33.Plugins.Timeline.Cnds.OnTimelineStartedByName),this._timelineManager.Trigger(C33.Plugins.Timeline.Cnds.OnTimelineStartedByTags),this._timelineManager.Trigger(C33.Plugins.Timeline.Cnds.OnAnyTimelineStarted),C33.Plugins.Timeline.Cnds.PopTriggerTimeline())}OnCompleted(){this._completedTick=this._runtime.GetTickCount()}FinishTriggers(){this._finishedTriggers||(this._finishedTriggers=!0,C33.Plugins.Timeline&&this.constructor===C33.TimelineState&&(C33.Plugins.Timeline.Cnds.PushTriggerTimeline(this),this._timelineManager.Trigger(C33.Plugins.Timeline.Cnds.OnTimelineFinished),this._timelineManager.Trigger(C33.Plugins.Timeline.Cnds.OnTimelineFinishedByName),this._timelineManager.Trigger(C33.Plugins.Timeline.Cnds.OnTimelineFinishedByTags),this._timelineManager.Trigger(C33.Plugins.Timeline.Cnds.OnAnyTimelineFinished),C33.Plugins.Timeline.Cnds.PopTriggerTimeline()))}SetPlaying(e){this._isPlaying=e}IsCompletedTick(){return this._completedTick===this._runtime.GetTickCount()}IsPlaying(e=!1){return!!this.IsCompletedTick()||!(!this.IsScheduled()||e)||this._isPlaying}_IsPlaying(){return this.IsPlaying(!0)}IsPaused(){return this._IsPaused()}_IsPaused(){return!(this.IsReleased()||this.IsScheduled()||this._IsPlaying()||this.IsComplete())}SetScheduled(e){this._isScheduled=e}IsScheduled(){return this._isScheduled}SetComplete(e){this._complete=e;const t=this.GetTime();(t<=0||t>=this.GetTotalTime())&&(this._complete=!0)}IsComplete(){return this._complete}IsReleased(){return this._released}SetMarkedForRemoval(e){this._markedForRemoval=e}IsMarkedForRemoval(){return this._markedForRemoval}SetImplicitPause(e){this._implicitPause=e}IsImplicitPause(){return this._implicitPause}SetIsTemplate(e){this._isTemplate=!!e}IsTemplate(){return this._isTemplate}InitialStateSet(){return this._initialStateSet}GetTime(){return this._playheadTime}SetTime(e){const t=this.GetTime();this._SetTime(e),this.SetComplete(!1),this.IsComplete()||this.SetImplicitPause(!0),!this._IsPlaying()&&!this.IsScheduled()&&this._initialStateSet||(this._IsPlaying()||this.IsScheduled()||this._initialStateSet?this._IsPlaying()?this.Stop():this.IsScheduled()&&(this._timelineManager.DeScheduleTimeline(this),this.SetInitialStateFromSetTime()):this.SetInitialStateFromSetTime()),this._SetUpdateStateBefore(),this._Interpolate(this.GetTime(),!1,!0,!0,t),this._SetUpdateStateAfter(),this._renderChange&&this.GetRuntime().UpdateRender(),this._OnSetTime()}_SetTime(e){(e=C33.IsFiniteNumber(e)?e:this.GetTotalTime())<0?this._playheadTime=0:e>=this.GetTotalTime()?this._playheadTime=this.GetTotalTime():this._playheadTime=e}_SetTimeAndReset(e){(e=C33.IsFiniteNumber(e)?e:this.GetTotalTime())<0?this._playheadTime=0:e>=this.GetTotalTime()?this._playheadTime=this.GetTotalTime():this._playheadTime=e;for(const t of this._tracks)t.SetResetState()}_OnSetTime(){C33.Plugins.Timeline&&this.constructor===C33.TimelineState&&(C33.Plugins.Timeline.Cnds.PushTriggerTimeline(this),this._timelineManager.Trigger(C33.Plugins.Timeline.Cnds.OnTimeSet),this._timelineManager.Trigger(C33.Plugins.Timeline.Cnds.OnTimeSetByName),this._timelineManager.Trigger(C33.Plugins.Timeline.Cnds.OnTimeSetByTags),C33.Plugins.Timeline.Cnds.PopTriggerTimeline())}_CanResume(){if(!this.GetLoop())if(this.GetPingPong()&&this._pingPongState===PING_PONG_END){if(this.IsForwardPlayBack()){if(this.GetTime()>=this.GetTotalTime())return!1}else if(this.GetTime()<=0)return!1}else if(!this.GetLoop()&&!this.GetPingPong())if(this.IsForwardPlayBack()){if(this.GetTime()>=this.GetTotalTime())return!1}else if(this.GetTime()<=0)return!1;return!0}Resume(){this.IsReleased()||this._CanResume()&&this.Play(!0)}Play(e=!1){return!this.IsReleased()&&!this.IsScheduled()&&(this._IsPlaying()&&this.IsCompletedTick()?this._SchedulePlayingTimeline():!this._IsPlaying()&&!!(this.IsComplete()||e||this.IsImplicitPause())&&this._ScheduleStoppedTimeline())}_SchedulePlayingTimeline(){return this.SetImplicitPause(!1),this._timelineManager.RemovePlayingTimeline(this),this._timelineManager.ScheduleTimeline(this),this.GetPlayPromise(),!0}_ScheduleStoppedTimeline(){return this.SetImplicitPause(!1),this._timelineManager.ScheduleTimeline(this),this.GetPlayPromise(),!0}Stop(e=!1){this.IsReleased()||(this.SetComplete(e),this._timelineManager.CompleteTimeline(this),this.IsComplete()&&this.ResolvePlayPromise())}Reset(e=!0,t=!1){if(!this.IsReleased()){if(!this._IsPlaying()&&this.IsScheduled())return this._timelineManager.DeScheduleTimeline(this);if(!this.IsComplete()){this.Stop(!0),this.IsForwardPlayBack()?this._SetTime(0):this._SetTime(this.GetTotalTime());const s=this.GetTime();this._SetUpdateStateBefore(),t?this._InterpolateBeforeChangeLayout(s):this._Interpolate(s,!1,!1,!0),e&&this._OnSetTime(),this._SetUpdateStateAfter(),this._renderChange&&e&&this.GetRuntime().UpdateRender()}}}ResetBeforeChangeLayout(){this.Reset(!1,!0)}_InterpolateBeforeChangeLayout(e){this._Interpolate(e,!1,!1,!0,NaN,!1,!0)}_OnBeforeChangeLayout(){if(!this.IsReleased()){if(!this.GetRuntime().IsLoadingState()&&this.HasValidGlobalTracks())return!1;this._timelineManager.CompleteTimelineBeforeChangeOfLayout(this),this.GetRuntime().IsLoadingState()||this.ResetBeforeChangeLayout()}return!0}SetInitialStateFromSetTime(){this.SetInitialState(!0)}SetInitialStateForce(){this.SetInitialState(!1,!0),this.SetPlaying(!1),this.SetScheduled(!1)}SetInitialState(e=!1,t=!1){if(!this.IsMarkedForRemoval()||t){if(e){this._finishedTriggers=!1,this._initialStateSet=!0,this._firstTick=!0,this._SetUpdateStateBefore();for(const s of this._tracks)s.SetInitialState()}else if(this.SetPlaying(!0),this.SetScheduled(!1),this.OnStarted(),this.IsComplete()){this._completedTick=-1,this._pingPongState!==PING_PONG_BEGIN&&(this._playbackRate=Math.abs(this._playbackRate)),this._pingPongState=PING_PONG_BEGIN,this._currentRepeatCount=1,this._complete=!1,this._finishedTriggers=!1,this._initialStateSet=!0,this._firstTick=!0,this.IsForwardPlayBack()?this._SetTime(0):this._SetTime(this.GetTotalTime()),this._SetUpdateStateBefore();for(const i of this._tracks)i.SetInitialState()}else{this._firstTick=!0,this._finishedTriggers=!1,this._SetUpdateStateBefore();for(const r of this._tracks)r.SetResumeState()}this._SetUpdateStateAfter()}}GetRenderChange(){return this._renderChange}_SetUpdateStateBefore(){this._hasNestedContent=0;for(const e of this._tracks)e.IsNested()&&(this._hasNestedContent=1)}_SetUpdateStateAfter(){this._renderChange=0;for(const e of this._tracks)e._SetUpdateState(),0===this._renderChange&&1===e.GetRenderChange()&&(this._renderChange=1),this._beforeAndAfterTracks||1!==e.GetNeedsBeforeAndAfter()||(this._beforeAndAfterTracks||(this._beforeAndAfterTracks=[]),this._beforeAndAfterTracksLength=this._beforeAndAfterTracks.push(e))}Tick(e,t,s){if(this.GetUseSystemTimescale()){if(0===e&&0===this._lastDelta)return;this._lastDelta=e,e=s}else{if(0===s&&0===this._lastDelta)return;e=this._lastDelta=s,t=1}const i=this._playheadTime+this._overshoot,r=e*t*this._playbackRate,n=i+r,a=this._timelineDataItem._totalTime;n<0?(this._playheadTime=0,this._overshoot=-n):a<=n?(this._playheadTime=a,this._overshoot=this._playheadTime-n):(this._playheadTime=n,this._overshoot=0);let o=!1,l=!1,h=this.GetLoop(),c=this.GetPingPong();h||c?h&&!c?0<this._playbackRate?this._playheadTime>=a&&(this._SetTimeAndReset(0),l=!0):this._playheadTime<=0&&(this._SetTimeAndReset(a),l=!0):!h&&c?0<this._playbackRate?this._playheadTime>=a&&(this._SetTime(a),this.SetPlaybackRate(-1*this.GetPlaybackRate()),l=!0,this._pingPongState===PING_PONG_END?this._currentRepeatCount<this.GetRepeatCount()?(this._currentRepeatCount++,this._pingPongState=PING_PONG_BEGIN):o=!0:this._pingPongState===PING_PONG_BEGIN&&(this._pingPongState=PING_PONG_END)):this._playheadTime<=0&&(this._SetTime(0),this.SetPlaybackRate(-1*this.GetPlaybackRate()),l=!0,this._pingPongState===PING_PONG_END?this._currentRepeatCount<this.GetRepeatCount()?(this._currentRepeatCount++,this._pingPongState=PING_PONG_BEGIN):o=!0:this._pingPongState===PING_PONG_BEGIN&&(this._pingPongState=PING_PONG_END)):h&&c&&(0<this._playbackRate?this._playheadTime>=a&&(this._SetTime(a),this.SetPlaybackRate(-1*this.GetPlaybackRate()),l=!0,this._pingPongState++,C33.wrap(this._pingPongState,0,2)):this._playheadTime<=0&&(this._SetTime(0),this.SetPlaybackRate(-1*this.GetPlaybackRate()),l=!0,this._pingPongState++,C33.wrap(this._pingPongState,0,2))):0<this._playbackRate?this._playheadTime>=a&&(this._currentRepeatCount<this.GetRepeatCount()?(this._currentRepeatCount++,this._SetTimeAndReset(0),l=!0):(this._SetTime(a),o=!0)):this._playheadTime<=0&&(this._currentRepeatCount<this.GetRepeatCount()?(this._currentRepeatCount++,this._SetTimeAndReset(a),l=!0):(this._SetTime(0),o=!0));let u,_=this._tracksLength;if(o){for(u=0;u<_;u++)this._tracks[u].SetEndState();this.Stop(!0),this.OnCompleted()}else{const d=this._beforeAndAfterTracksLength;for(u=0;u<d;u++)this._beforeAndAfterTracks[u].BeforeInterpolate();if(1===this._hasNestedContent)for(u=0;u<_;u++){const p=this._tracks[u],m=p.GetStartOffset(),g=this._playheadTime-m,f=i-m;g<0&&0<f?(this._playheadTime=m<0?0:a<=m?a:m,p.Interpolate(m,!0,!1,l,this._firstTick,!1)):p.Interpolate(this._playheadTime,!0,!1,l,this._firstTick,!1)}else for(u=0;u<_;u++)this._tracks[u].Interpolate(this._playheadTime,!0,!1,l,this._firstTick,!1);for(u=0;u<d;u++)this._beforeAndAfterTracks[u].AfterInterpolate();this._firstTick&&(this._firstTick=!1)}}_Interpolate(t,s=!1,i=!1,r=!1,n=NaN,e=!1,a=!1){for(const o of this._tracks)o.BeforeInterpolate();for(const l of this._tracks){let e=t;if("number"==typeof n&&!isNaN(n)){const h=this.GetTime(),c=h-l.GetStartOffset(),u=n-l.GetStartOffset();c<0&&0<u&&(e=l.GetStartOffset(),this._SetTime(e))}l.Interpolate(e,s,i,r,this._firstTick,a)}for(const _ of this._tracks)_.AfterInterpolate();this._firstTick&&e&&(this._firstTick=!1)}AddTrack(){const e=this._timelineDataItem.GetTrackData().AddEmptyTrackDataItem(),t=C33.TrackState.Create(this,e);return this._tracksLength=this._tracks.push(t),t}Removed(){if(!this.IsReleased())for(const e of this._tracks)e.TimelineRemoved()}CleanCaches(){for(const e of this._tracks)e.CleanCaches()}ClearTrackInstances(){for(const e of this._tracks)e.ClearInstance()}SetTrackInstance(e,t,s){if(t){if("number"==typeof s&&0<=s){const i=this._tracks[s];return i?(i.SetInstance(t),void this._timelineManager.SetTimelineObjectClassToMap(t.GetObjectClass(),this)):void 0}for(const r of this._tracks)if(r.IsInstanceTrack())if(e){if(r.GetId()===e){r.SetInstance(t),this._timelineManager.SetTimelineObjectClassToMap(t.GetObjectClass(),this);break}}else if(!r.HasInstance()){r.SetInstance(t),this._timelineManager.SetTimelineObjectClassToMap(t.GetObjectClass(),this);break}}}HasTrackInstance(e,t){for(const s of this._tracks)if(s.IsInstanceTrack())if(t){if(t===s.GetId()&&e===s.GetInstance())return!0}else if(e===s.GetInstance())return!0;return!1}HasValidTracks(){return this._tracks.some(e=>!e.IsInstanceTrack()||e.CanInstanceBeValid())}HasValidGlobalTracks(){return this._tracks.some(e=>{if(e.IsInstanceTrack()){if(!e.CanInstanceBeValid())return!1;const t=e.GetObjectClass();return!!t&&t.IsGlobal()}return!1})}GetPropertyTrack(e){for(const t of this.GetTracks())for(const s of t.GetPropertyTracks())if(s.GetPropertyName()===e)return s}GetTrackFromInstance(e){for(const t of this._tracks)if(e===t.GetInstance())return t;return null}GetKeyframeWithTags(e){let t=e?e.split(" "):[],s=new Set(t.map(e=>e.toLowerCase().trim()));t=[...s.values()];for(const i of this.GetTracks())for(const r of i.GetKeyframeDataItems()){const n=t.every(e=>r.HasTag(e));if(n)return r}}GetObjectClasses(){const e=[];for(const t of this.GetTracks())e.push(t.GetObjectClass());return e.filter(e=>e)}_OnAfterLoad(){for(const e of this.GetTracks())e._OnAfterLoad()}_SaveToJson(){return{tracksJson:this._SaveTracksToJson(),name:this._name,playheadTime:this.GetTime(),playbackRate:this._playbackRate,pingPongState:this._pingPongState,currentRepeatCount:this._currentRepeatCount,isPlaying:this._isPlaying,isScheduled:this._isScheduled,initialStateSet:this._initialStateSet,finishedTriggers:this._finishedTriggers,complete:this._complete,released:this._released,markedForRemoval:this._markedForRemoval,completedTick:this._completedTick,implicitPause:this._implicitPause,isTemplate:this._isTemplate,tags:this._tags.join(" "),stringTags:this._stringTags,tagsChanged:this._tagsChanged,firstTick:this._firstTick}}_LoadFromJson(e){e&&(this._LoadTracksFromJson(e.tracksJson),this._name=e.name,this._playheadTime=e.playheadTime,this._playbackRate=e.playbackRate,this._pingPongState=e.pingPongState,this._currentRepeatCount=e.currentRepeatCount,this._isPlaying=!!e.isPlaying,this._isScheduled=!!e.isScheduled,this._initialStateSet=!!e.initialStateSet,this._finishedTriggers=!!e.hasOwnProperty("finishedTriggers")&&!!e.finishedTriggers,this._complete=!!e.complete,this._released=!!e.released,this._markedForRemoval=!!e.markedForRemoval,this._completedTick=e.completedTick,this._implicitPause=!!e.implicitPause,this._isTemplate=!!e.isTemplate,this._tags=e.tags.split(" "),this._stringTags=e.stringTags,this._tagsChanged=!!e.tagsChanged,this._firstTick=!!e.firstTick)}_SaveTracksToJson(){return this._tracks.map(e=>e._SaveToJson())}_LoadTracksFromJson(e){this.ClearTrackInstances(),e.forEach((e,t)=>{const s=this._tracks[t];s._LoadFromJson(e)}),this._tracks.filter(e=>e.CanInstanceBeValid())}static _HasTag(e){const t=this.GetTags();return""===e?1===t.length&&""===t[0]:t.map(e=>e.toLowerCase()).includes(e.toLowerCase())}static _GetTagArray(e){if(C33.IsArray(e))return e.slice(0);if(C33.IsString(e))return e.split(" ");throw new Error("invalid tags")}GetITimelineState(){return this._iTimelineState||(this._iTimelineState=C33.New(self.ITimelineState,this)),this._iTimelineState}}}{const C33=self.C3,INSTANCE_TRACK=0,VALUE_TRACK=1,AUDIO_TRACK=2;C33.TrackState=class extends C33.DefendedBase{constructor(e,t){super(),this._timeline=e,this._trackDataItem=t,this._trackData=t.GetTrackData(),this._instanceUid=NaN,this._objectClassIndex=NaN,this._instance=null,this._worldInfo=null,this._cleared=!1,this._isNested=0<t.GetStartOffset(),this._initialStateOfNestedSet=!1,this._endStateOfNestedSet=!1,this._instanceUidToLoad=NaN,this._lastKeyframeDataItem=null,this._keyframeDataItems=this._trackDataItem.GetKeyframeData().GetKeyframeDataItemArray(),this._propertyTracks=[],this.CreatePropertyTrackStates(),this._worldInfoChange=0,this._renderChange=0,this._needsBeforeAndAfter=0}static Create(e,t){return C33.New(C33.TrackState,e,t)}Release(){this._keyframeDataItems=null;for(const e of this._propertyTracks)e.Release();C33.clearArray(this._propertyTracks),this._propertyTracks=null,this._timeline=null,this._instance=null,this._worldInfo=null,this._trackDataItem=null,this._lastKeyframeDataItem=null}CreatePropertyTrackStates(){for(const e of this._trackDataItem.GetPropertyTrackData().propertyTrackDataItems())this._propertyTracks.push(C33.PropertyTrackState.Create(this,e))}TimelineRemoved(){for(const e of this._propertyTracks)e.TimelineRemoved()}CleanCaches(){for(const e of this._propertyTracks)e.CleanCaches();this._instance=null,this._worldInfo=null}GetTimeline(){return this._timeline}GetRuntime(){return this._timeline.GetRuntime()}GetKeyframeDataItems(){return this._keyframeDataItems||(this._keyframeDataItems=this._trackDataItem.GetKeyframeData().GetKeyframeDataItemArray()),this._keyframeDataItems}GetPropertyTracks(){return this._propertyTracks}GetPropertyTrack(t){for(let e=0;e<this._propertyTracks.length;e++){const s=this._propertyTracks[e];if(s.GetPropertyName()===t)return s}}MaybeGetInstance(){this._instance||this.GetInstance()}IsInstanceValid(){return!!this._instance&&!this._instance.IsDestroyed()}CanInstanceBeValid(){if(!this.IsInstanceTrack())return!1;const e=this.GetInstanceUID(),t=this.GetRuntime().GetInstanceByUID(e);return!!t&&!t.IsDestroyed()}GetObjectClass(){if(this.IsInstanceTrack()){const e=this.GetObjectClassIndex();if(-1!==e)return this.GetRuntime().GetObjectClassByIndex(e)}}GetTrackIndexInTimeline(){return this._timeline.GetTracks().indexOf(this)}ClearInstance(){this._instance=null,this._instanceUid=NaN,this._worldInfo=null,this._objectClassIndex=NaN,this._cleared=!0}HasInstance(){return!!this._instance}GetInstance(){if(!this._cleared){if(!this._instance||!this.IsInstanceValid()){const e=this.GetInstanceUID();this._instance=this.GetRuntime().GetInstanceByUID(e)}return this._instance}}SetInstance(e){if(this._cleared=!1,this._instance!==e){this.CleanCaches(),this._instance=e,this._objectClassIndex=e.GetObjectClass().GetIndex(),this._instanceUid=e.GetUID(),this._worldInfo=e.GetWorldInfo();for(const t of this.propertyTrackItems()){const s=t.propertyTrack,i=t.sourceAdapter,r=s.GetSourceAdapterId();switch(r){case"instance-variable":{i.GetEditorIndex();const n=e.GetObjectClass(),a=n.GetInstanceVariableIndexByName(t.name),o=n.GetInstanceVariableName(a),l=n.GetInstanceVariableType(a);o===t.name&&l===t.type&&i.UpdateInstanceVariableIndex(a);break}case"behavior":{const h=t.behaviorType,c=this.GetObjectClass(),u=e.GetObjectClass(),_=i.GetBehaviorType(u);if(h&&_){const d=h.GetName();c.GetBehaviorIndexByName(d),u.GetBehaviorIndexByName(d),i.GetEditorIndex(),i.UpdateBehaviorTypeSid(_.GetSID())}break}}}}}*propertyTrackItems(){for(const e of this._propertyTracks){const t=e.GetSourceAdapter(),s=this.GetObjectClass(),i={propertyTrack:e,sourceAdapter:t};switch(e.GetSourceAdapterId()){case"world-instance":i.property=e.GetPropertyName();break;case"instance-variable":{const r=t.GetEditorIndex();i.name=s.GetInstanceVariableName(r),i.type=s.GetInstanceVariableType(r);break}case"effect":{const n=s.GetEffectList(),a=t.GetEffectType(n);i.effectType=a;break}case"behavior":{const o=t.GetBehaviorType(s);i.behaviorType=o;break}case"plugin":i.plugin=s.GetPlugin()}yield i}}GetWorldInfo(){if(!this._worldInfo||!this.IsInstanceValid()){const e=this.GetInstance();e&&(this._worldInfo=e.GetWorldInfo())}return this._worldInfo}GetTrackDataItem(){return this._trackDataItem}GetInstanceUID(){return isNaN(this._instanceUid)?this._trackDataItem.GetInstanceUID():this._instanceUid}SetInstanceUID(e){this._trackDataItem.SetInstanceUID(e)}GetInterpolationMode(){return this._trackDataItem.GetInterpolationMode()}SetInterpolationMode(e){this._trackDataItem.SetInterpolationMode(e)}GetResultMode(){return this._trackDataItem.GetResultMode()}GetId(){return this._trackDataItem.GetId()}GetStartOffset(){return this._trackDataItem.GetStartOffset()}GetLocalTotalTime(){return this._trackDataItem.GetLocalTotalTime()}SetLocalTotalTime(e){this._trackDataItem.SetLocalTotalTime(e)}SetResultMode(e){this._trackDataItem.SetResultMode(e)}SetEase(e){for(const t of this.GetKeyframeDataItems())t.SetEase(e);for(const s of this.GetPropertyTracks())s.SetEase(e)}GetEnable(){return this._trackDataItem.GetEnable()}SetEnable(e){this._trackDataItem.SetEnable(e)}GetObjectClassIndex(){return isNaN(this._objectClassIndex)?this._trackDataItem.GetObjectClassIndex():this._objectClassIndex}SetObjectClassIndex(e){this._trackDataItem.SetObjectClassIndex(e)}SetOriginalWidth(e){this._trackDataItem.SetOriginalWidth(e)}GetOriginalWidth(){const e=this.GetInstance();if(e){const t=e.GetSdkInstance();if(t.IsOriginalSizeKnown())return e.GetSdkInstance().GetOriginalWidth()}return this._trackDataItem.GetOriginalWidth()}SetOriginalHeight(e){this._trackDataItem.SetOriginalHeight(e)}GetOriginalHeight(){const e=this.GetInstance();if(e){const t=e.GetSdkInstance();if(t.IsOriginalSizeKnown())return e.GetSdkInstance().GetOriginalHeight()}return this._trackDataItem.GetOriginalHeight()}GetType(){return this._trackDataItem.GetType()}GetName(){return this._trackDataItem.GetName()}IsInstanceTrack(){return this.GetType()===INSTANCE_TRACK}IsValueTrack(){return this.GetType()===VALUE_TRACK}IsAudioTrack(){return this.GetType()===AUDIO_TRACK}GetWorldInfoChange(){return this._worldInfoChange}GetRenderChange(){return this._renderChange}GetNeedsBeforeAndAfter(){return this._needsBeforeAndAfter}IsNested(){return this._isNested}SetResetState(){for(const e of this._propertyTracks)e.SetResetState()}SetInitialState(){if(this.MaybeGetInstance(),this.IsInstanceValid()||!this.IsInstanceTrack()){const e=this.GetTimeline(),t=e.IsForwardPlayBack(),s=t?0:this.GetLocalTotalTime();for(const r of this._propertyTracks)r.SetInitialState(s),0===this._worldInfoChange&&1===r.GetWorldInfoChange()&&(this._worldInfoChange=1),0===this._renderChange&&1===r.GetRenderChange()&&(this._renderChange=1);this._needsBeforeAndAfter=0;const i=this._propertyTracks.some(e=>e.GetNeedsBeforeAndAfter());i&&(this._needsBeforeAndAfter=1),this._lastKeyframeDataItem=this._GetLastKeyFrameBeforeTime(s),this._initialStateOfNestedSet=!1,this._endStateOfNestedSet=!1,this.Interpolate(s),this.OnKeyframeReached(this._GetLastKeyFrameBeforeTime(s))}}SetResumeState(){if(this.MaybeGetInstance(),this.IsInstanceValid()||!this.IsInstanceTrack()){this._timeline.IsForwardPlayBack();const e=this._timeline.GetTime()-this.GetStartOffset();this._lastKeyframeDataItem=this._GetLastKeyFrameBeforeTime(e);for(const t of this._propertyTracks)t.SetResumeState(e)}}SetEndState(){if(!this.GetTimeline().IsComplete()&&(this.MaybeGetInstance(),this.IsInstanceValid()||!this.IsInstanceTrack())&&!this._isNested){const e=this._timeline.GetTime(),t=this.GetStartOffset()+this.GetLocalTotalTime();t<=e?this.Interpolate(this.GetLocalTotalTime(),!0,!1,!0,!1,!1,!0):e<=0&&this.Interpolate(0,!0,!1,!0,!1,!1,!0)}}_SetUpdateState(){for(let e=0,t=this._propertyTracks.length;e<t;e++){const s=this._propertyTracks[e];s._SetUpdateState(),0===this._worldInfoChange&&1===s.GetWorldInfoChange()&&(this._worldInfoChange=1),0===this._renderChange&&1===s.GetRenderChange()&&(this._renderChange=1)}}BeforeInterpolate(){const t=this._propertyTracks.length;for(let e=0;e<t;e++)this._propertyTracks[e].BeforeInterpolate()}Interpolate(s,e=!1,i=!1,r=!1,t=!1,n=!1,a=!1){this._instance||this.GetInstance();const o=this._instance&&!this._instance.IsDestroyed(),l=this._trackDataItem._type===INSTANCE_TRACK;if((o||!l)&&!(n&&l&&this.GetObjectClass().IsGlobal()||(s-=this.GetStartOffset())<0)){this.MaybeSetInitialStateOfNestedTrack(s,e),this.MaybeTriggerKeyframeReachedConditions(s,e,t);for(let e=0,t=this._propertyTracks.length;e<t;e++)this._propertyTracks[e].Interpolate(s,i,r,a);this.MaybeSetEndStateOfNestedTrack(s,e),0!==this._worldInfoChange&&(this._worldInfo||(this._worldInfo=this._instance.GetWorldInfo()),this._worldInfo)&&this._worldInfo.SetBboxChanged()}}AfterInterpolate(){const t=this._propertyTracks.length;for(let e=0;e<t;e++)this._propertyTracks[e].AfterInterpolate()}MaybeSetInitialStateOfNestedTrack(e,t){if(t&&this._isNested&&!this._initialStateOfNestedSet){const s=this.GetTimeline();if(s.IsForwardPlayBack()){if(e<0)return}else if(e>this.GetLocalTotalTime())return;for(const i of this._propertyTracks)i.SetInitialState();this._initialStateOfNestedSet=!0}}MaybeSetEndStateOfNestedTrack(e,t){if(t&&this._isNested&&!this._endStateOfNestedSet){const s=this.GetTimeline();if(s.IsForwardPlayBack()){if(e>=this.GetLocalTotalTime()){for(const i of this._propertyTracks)i.Interpolate(this.GetLocalTotalTime(),!1,!0);this._endStateOfNestedSet=!0}}else if(e<=0){for(const r of this._propertyTracks)r.Interpolate(0,!1,!0);this._endStateOfNestedSet=!0}}}MaybeTriggerKeyframeReachedConditions(e,t,s){if(!s&&t&&C33.Plugins.Timeline){const i=this.GetTimeline(),r=this._lastKeyframeDataItem.GetNext(),n=this._lastKeyframeDataItem.GetTime(),a=r?r.GetTime():i.GetTotalTime();if(e<=n||a<=e)if(this._lastKeyframeDataItem=this._trackData.GetFirstKeyFrameDataItemLowerOrEqualThan(e,this._trackDataItem),i.IsForwardPlayBack())r&&this.OnKeyframeReached(this._lastKeyframeDataItem);else{const o=this._lastKeyframeDataItem.GetNext();o&&this.OnKeyframeReached(o)}}}_GetLastKeyFrameBeforeTime(e){const t=this._trackData.GetKeyFrameDataItemAtTime(e,this._trackDataItem);return t||this._trackData.GetFirstKeyFrameDataItemLowerOrEqualThan(e,this._trackDataItem)}OnKeyframeReached(e){if(C33.Plugins.Timeline){const t=this.GetTimeline(),s=t.GetTimelineManager();C33.Plugins.Timeline.Cnds.PushTriggerTimeline(t),C33.Plugins.Timeline.Cnds.PushTriggerKeyframe(e),s.Trigger(C33.Plugins.Timeline.Cnds.OnAnyKeyframeReached),s.Trigger(C33.Plugins.Timeline.Cnds.OnKeyframeReached),C33.Plugins.Timeline.Cnds.PopTriggerTimeline(t),C33.Plugins.Timeline.Cnds.PopTriggerKeyframe(e)}}AddKeyframe(){const e=this._trackDataItem.GetKeyframeData(),t=e.AddEmptyKeyframeDataItem();return t}AddPropertyTrack(){const e=this._trackDataItem.GetPropertyTrackData(),t=e.AddEmptyPropertyTrackDataItem(),s=C33.PropertyTrackState.Create(this,t);return this._propertyTracks.push(s),s}DeleteKeyframes(e){const t=this._trackDataItem.GetKeyframeData();t.DeleteKeyframeDataItems(e)}DeletePropertyKeyframes(e){for(const t of this._propertyTracks)t.DeletePropertyKeyframes(e)}SaveState(){for(const e of this._propertyTracks)e.SaveState()}CompareInitialStateWithCurrent(){if(this.MaybeGetInstance(),this.IsInstanceValid()||!this.IsInstanceTrack())for(const e of this._propertyTracks)e.CompareInitialStateWithCurrent()}CompareSaveStateWithCurrent(){if(this.MaybeGetInstance(),this.IsInstanceValid()||!this.IsInstanceTrack()){let e=!1;for(const t of this._propertyTracks){const s=t.CompareSaveStateWithCurrent();!e&&s&&(e=!0)}if(e){const i=this.AddKeyframe();i.SetTime(this.GetTimeline().GetTime()),i.SetEase("noease"),i.SetEnable(!0),i.SetTags("")}}}_OnAfterLoad(){isNaN(this._instanceUidToLoad)||this._LoadInstanceFromJson(this._instanceUidToLoad),this._instanceUidToLoad=NaN}_SaveToJson(){const e=this.GetInstance(),t=e?e.GetUID():this.GetInstanceUID();return{propertyTracksJson:this._SavePropertyTracksToJson(),lastKeyframeDataItemJson:this._SaveLastKeyframeDataItemToJson(),initialStateOfNestedSet:this._initialStateOfNestedSet,endStateOfNestedSet:this._endStateOfNestedSet,instanceUid:t,cleared:this._cleared}}_LoadFromJson(e){if(e){this._LoadPropertyTracksFromJson(e.propertyTracksJson),this._LoadLastKeyframeDataItemFromJson(e.lastKeyframeDataItemJson),this._instanceUidToLoad=e.instanceUid,this._initialStateOfNestedSet=!1,e.hasOwnProperty.initialStateOfNestedSet&&(this._initialStateOfNestedSet=e.initialStateOfNestedSet),this._endStateOfNestedSet=!1,e.hasOwnProperty.endStateOfNestedSet&&(this._endStateOfNestedSet=e.endStateOfNestedSet),this._cleared=!!e.hasOwnProperty("cleared")&&e.cleared;for(const t of this._propertyTracks)0===this._worldInfoChange&&1===t.GetWorldInfoChange()&&(this._worldInfoChange=1),0===this._renderChange&&1===t.GetRenderChange()&&(this._renderChange=1);this._needsBeforeAndAfter=0,this._propertyTracks.some(e=>e.GetNeedsBeforeAndAfter())&&(this._needsBeforeAndAfter=1)}}_SaveLastKeyframeDataItemToJson(){const e=this._trackDataItem.GetKeyframeData();return e.GetKeyframeDataItemIndex(this._lastKeyframeDataItem)}_SavePropertyTracksToJson(){return this._propertyTracks.map(e=>e._SaveToJson())}_LoadPropertyTracksFromJson(e){e.forEach((e,t)=>{const s=this._propertyTracks[t];s._LoadFromJson(e)})}_LoadInstanceFromJson(e){if(C33.IsFiniteNumber(e)){const t=this.GetRuntime().GetInstanceByUID(e);if(t){const s=this.GetTimeline();s.SetTrackInstance(this._trackDataItem.GetId(),t,this.GetTrackIndexInTimeline())}}}_LoadLastKeyframeDataItemFromJson(e){const t=this._trackDataItem.GetKeyframeData();this._lastKeyframeDataItem=t.GetKeyframeDataItemFromIndex(e)}}}{const C33=self.C3;C33.PropertyTrackState=class extends C33.DefendedBase{constructor(e,t){super(),this._track=e,this._propertyTrackDataItem=t,this._propertyTrackData=t.GetPropertyTrackData(),this._worldInfoChange=0,this._renderChange=0,this._needsBeforeAndAfter=0,this._sourceAdapter=this.GetSourceAdapter(),this._propertyKeyframeDataItems=this._propertyTrackDataItem.GetPropertyKeyframeData().GetPropertyKeyframeDataItemArray(),this._lastPropertyKeyframeDataItem=null,this._absoluteValueObject=null}static Create(e,t){return C33.New(C33.PropertyTrackState,e,t)}Release(){this._track=null,this._sourceAdapter&&(this._sourceAdapter.Release(),this._sourceAdapter=null),this._propertyKeyframeDataItems=null,this._propertyTrackDataItem=null,this._propertyTrackData=null}GetWorldInfoChange(){return this._worldInfoChange}GetRenderChange(){return this._renderChange}GetNeedsBeforeAndAfter(){return this._needsBeforeAndAfter}HasAbsoluteValueObject(){return!!this._absoluteValueObject}SetAbsoluteValueObject(e){this._absoluteValueObject=e}GetAbsoluteValueObject(){return this._absoluteValueObject}GetTrack(){return this._track}GetPropertyTrackDataItem(){return this._propertyTrackDataItem}GetPropertyTrackData(){return this._propertyTrackData}GetTimeline(){return this._track.GetTimeline()}GetRuntime(){return this._track.GetRuntime()}GetInstance(){return this._track.GetInstance()}GetSourceAdapter(){if(!this._sourceAdapter){let e=this._propertyTrackDataItem.GetSourceAdapterId(),t;switch(e){case"behavior":t=new C33.PropertyTrackState.BehaviorSourceAdapter(this);break;case"effect":t=new C33.PropertyTrackState.EffectSourceAdapter(this),this._renderChange=1;break;case"instance-variable":t=new C33.PropertyTrackState.InstanceVariableSourceAdapter(this);break;case"plugin":t=new C33.PropertyTrackState.PluginSourceAdapter(this),this._renderChange=1;break;case"world-instance":t=new C33.PropertyTrackState.PropertySourceAdapter(this),this._renderChange=1,this._worldInfoChange=1;break;case"value":t=new C33.PropertyTrackState.ValueSourceAdapter(this);break;case"audio":t=new C33.PropertyTrackState.AudioSourceAdapter(this)}this._sourceAdapter=t}return this._sourceAdapter}GetSourceAdapterId(){return this._propertyTrackDataItem.GetSourceAdapterId()}SetSourceAdapterId(e){this._propertyTrackDataItem.SetSourceAdapterId(e)}GetSourceAdapterArgs(){return this._propertyTrackDataItem.GetSourceAdapterArguments()}SetSourceAdapterArgs(e){this._propertyTrackDataItem.SetSourceAdapterArguments(e)}GetSourceAdapterValue(){return this.GetSourceAdapter().GetValue()}GetPropertyName(){return this._propertyTrackDataItem.GetProperty()}SetPropertyName(e){this._propertyTrackDataItem.SetProperty(e)}GetPropertyType(){return this._propertyTrackDataItem.GetType()}SetPropertyType(e){this._propertyTrackDataItem.SetType(e)}GetPropertyKeyframeType(){return this.GetPropertyTrackData().GetFirstPropertyKeyframeDataItem(this._propertyTrackDataItem).GetType()}GetMin(){return this._propertyTrackDataItem.GetMin()}SetMin(e){this._propertyTrackDataItem.SetMin(e)}GetMax(){return this._propertyTrackDataItem.GetMax()}SetMax(e){this._propertyTrackDataItem.SetMax(e)}GetEnable(){return this._propertyTrackDataItem.GetEnable()}SetEnable(e){this._propertyTrackDataItem.SetEnable(e)}GetInterpolationMode(){return this._propertyTrackDataItem.GetInterpolationMode()}SetInterpolationMode(e){this._propertyTrackDataItem.SetInterpolationMode(e)}GetResultMode(){return this._propertyTrackDataItem.GetResultMode()}SetResultMode(e){this._propertyTrackDataItem.SetResultMode(e)}SetEase(e){for(const t of this.GetPropertyKeyframeDataItems())t.SetEase(e)}CanHavePropertyKeyframes(){return this._propertyTrackDataItem.CanHavePropertyKeyframes()}GetPropertyKeyframeDataItems(){return this._propertyKeyframeDataItems||(this._propertyKeyframeDataItems=this._propertyTrackDataItem.GetPropertyKeyframeData().GetPropertyKeyframeDataItemArray()),this._propertyKeyframeDataItems}GetPropertyKeyframeDataItemArrayIncludingDisabled(){return this._propertyTrackDataItem.GetPropertyKeyframeData().GetPropertyKeyframeDataItemArrayIncludingDisabled()}GetPropertyKeyFrameDataItemAtTime(e){return this._propertyTrackData.GetPropertyKeyFrameDataItemAtTime(e,this._propertyTrackDataItem)}GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e){return this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,this._propertyTrackDataItem)}GetPropertyKeyframeDataItemPairForTime(e){let t=this._propertyTrackData.GetPropertyKeyFrameDataItemAtTime(e,this._propertyTrackDataItem),s;return s=t?this._propertyTrackData.GetFirstPropertyKeyFrameDataItemHigherThan(e,this._propertyTrackDataItem):(t=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,this._propertyTrackDataItem),this._propertyTrackData.GetFirstPropertyKeyFrameDataItemHigherOrEqualThan(e,this._propertyTrackDataItem)),{start:t,end:s}}*GetPropertyKeyframeValues(){for(const e of this.GetPropertyKeyframeDataItems())yield e.GetValueWithResultMode()}*GetPropertyKeyframeTimes(){for(const e of this.GetPropertyKeyframeDataItems())yield e.GetTime()}TimelineRemoved(){this.GetSourceAdapter().TimelineRemoved()}CleanCaches(){this.GetSourceAdapter().CleanCaches()}GetCurrentState(){return this.GetSourceAdapter().GetCurrentState()}SetResetState(){this.GetSourceAdapter().SetResetState()}SetInitialState(e){this.GetSourceAdapter().SetInitialState(),this._lastPropertyKeyframeDataItem=this._GetLastPropertyKeyFrameBeforeTime(e),this._SetUpdateState()}SetResumeState(e){this.GetSourceAdapter().SetResumeState(),this._lastPropertyKeyframeDataItem=this._GetLastPropertyKeyFrameBeforeTime(e)}_SetUpdateState(){const e=this.GetTrack();if(this._needsBeforeAndAfter=0,e.IsInstanceTrack()){const t=this.GetTimeline(),s=e.GetInstance(),i=this.GetSourceAdapter(),r=this.GetPropertyName(),n=i.MayNeedBeforeAndAfterInterpolate();if(n){const a=t.GetSimilarPropertyTracks(s,i,r,this);a&&a.length&&(this._needsBeforeAndAfter=1)}else this._needsBeforeAndAfter=0}}_GetLastPropertyKeyFrameBeforeTime(e){const t=this.GetTimeline(),s=this._propertyTrackData.GetPropertyKeyFrameDataItemAtTime(e,this._propertyTrackDataItem);return s||(t.IsForwardPlayBack()?this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,this._propertyTrackDataItem):this._propertyTrackData.GetFirstPropertyKeyFrameDataItemHigherOrEqualThan(e,this._propertyTrackDataItem))}BeforeInterpolate(){this._sourceAdapter.BeforeInterpolate()}Interpolate(e,t=!1,s=!1,i=!1){let r,n,a=!1;if(t)r=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,this._propertyTrackDataItem);else{if(this._lastPropertyKeyframeDataItem){const o=this.GetTimeline(),l=this._lastPropertyKeyframeDataItem.GetNext(),h=this._lastPropertyKeyframeDataItem.GetTime(),c=l?l.GetTime():o.GetTotalTime();(e<=h||c<=e)&&(this._lastPropertyKeyframeDataItem=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,this._propertyTrackDataItem),a=!0)}else this._lastPropertyKeyframeDataItem=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,this._propertyTrackDataItem),a=!0;r=this._lastPropertyKeyframeDataItem}r&&(n=r.GetNext()),this._sourceAdapter.Interpolate(e,r,n,t,s,i,a)}GetInterpolatedValue(e){if(this._lastPropertyKeyframeDataItem){const i=this.GetTimeline(),r=this._lastPropertyKeyframeDataItem.GetNext(),n=this._lastPropertyKeyframeDataItem.GetTime(),a=r?r.GetTime():i.GetTotalTime();(e<=n||a<=e)&&(this._lastPropertyKeyframeDataItem=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,this._propertyTrackDataItem))}else this._lastPropertyKeyframeDataItem=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,this._propertyTrackDataItem);const t=this._lastPropertyKeyframeDataItem,s=t.GetNext();return this._sourceAdapter.GetInterpolatedValue(e,t,s)}GetInterpolatedValueFast(e,t,s){return this._sourceAdapter.GetInterpolatedValue(e,t,s)}AfterInterpolate(){this._sourceAdapter.AfterInterpolate()}static GetStartPropertyKeyframeForTime(e,t){const s=t.GetPropertyTrackDataItem(),i=t._propertyTrackData;return i.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,s)}static GetEndPropertyKeyframeForTime(e,t){const s=t.GetPropertyTrackDataItem(),i=t._propertyTrackData;return i.GetFirstPropertyKeyFrameDataItemHigherOrEqualThan(e,s)}AddPropertyKeyframe(){const e=this._propertyTrackDataItem.GetPropertyKeyframeData(),t=e.AddEmptyPropertyKeyframeDataItem();return this._lastPropertyKeyframeDataItem=null,t}DeletePropertyKeyframes(e){this._lastPropertyKeyframeDataItem=null;const t=this._propertyTrackDataItem.GetPropertyKeyframeData();t.DeletePropertyKeyframeDataItems(e)}SaveState(){this.GetSourceAdapter().SaveState()}CompareInitialStateWithCurrent(){const e=this.GetSourceAdapter().CompareInitialStateWithCurrent();if(e){const t=this._propertyTrackData.GetFirstPropertyKeyframeDataItem(this._propertyTrackDataItem),s=this.GetSourceAdapter().GetCurrentState();t.SetAbsoluteValue(s)}}CompareSaveStateWithCurrent(){const e=this.GetSourceAdapter().CompareSaveStateWithCurrent();return e&&this.AddPropertyKeyframeAtCurrentTime(),this.GetSourceAdapter().ClearSaveState(),e}AddPropertyKeyframeAtCurrentTime(){const e=this.GetTimeline().GetTime(),t=this.GetSourceAdapter(),s=C33.PropertyTrackState.GetStartPropertyKeyframeForTime(e,this),i=this.AddPropertyKeyframe();i.SetType(s.GetType()),i.SetTime(e),i.SetEase(s.GetEase()),i.SetEnable(!0),i.SetValue(t.GetValueAtTime()),i.SetAbsoluteValue(t.GetCurrentState())}_SaveToJson(){return{sourceAdapterJson:this.GetSourceAdapter()._SaveToJson()}}_LoadFromJson(e){e&&this.GetSourceAdapter()._LoadFromJson(e.sourceAdapterJson)}}}{const C33=self.C3,NS=C33.PropertyTrackState;NS.PropertySourceAdapter=class{constructor(e){this._propertyTrack=e,this._propertyAdapter=null,this.GetPropertyAdapter()}Release(){this._propertyAdapter&&(this._propertyAdapter.Release(),this._propertyAdapter=null),this._propertyTrack=null}MayNeedBeforeAndAfterInterpolate(){return this._propertyAdapter.MayNeedBeforeAndAfterInterpolate()}GetPropertyTrack(){return this._propertyTrack}TimelineRemoved(){this._propertyAdapter&&this._propertyAdapter.TimelineRemoved()}CleanCaches(){this._propertyAdapter&&this._propertyAdapter.CleanCaches()}GetPropertyAdapter(){return this._propertyAdapter||(this._propertyAdapter=this._CreatePropertyAdapter()),this._propertyAdapter}GetEditorIndex(){}GetIndex(){return this.GetEditorIndex()}GetTarget(){}SetResetState(){this.GetPropertyAdapter().SetResetState()}SetInitialState(){this.GetPropertyAdapter().SetInitialState()}SetResumeState(){this.GetPropertyAdapter().SetResumeState()}BeforeInterpolate(){this._propertyAdapter.BeforeChangeProperty()}Interpolate(e,t,s,i,r,n,a){let o=this._propertyTrack.GetPropertyKeyframeType(),l;switch(o){case"numeric":l=NS.NumericTypeAdapter.Interpolate(e,t,s,this._propertyTrack);break;case"angle":l=NS.AngleTypeAdapter.Interpolate(e,t,s,this._propertyTrack);break;case"boolean":l=NS.BooleanTypeAdapter.Interpolate(e,t,s,this._propertyTrack);break;case"color":l=NS.ColorTypeAdapter.Interpolate(e,t,s,this._propertyTrack);break;case"text":l=NS.TextTypeAdapter.Interpolate(e,t,s,this._propertyTrack)}this._propertyAdapter.ChangeProperty(e,l,t,s,i,r,n,a)}GetInterpolatedValue(e,t,s){switch(this._propertyTrack.GetPropertyKeyframeType()){case"numeric":return NS.NumericTypeAdapter.Interpolate(e,t,s,this._propertyTrack);case"angle":return NS.AngleTypeAdapter.Interpolate(e,t,s,this._propertyTrack);case"boolean":return NS.BooleanTypeAdapter.Interpolate(e,t,s,this._propertyTrack);case"color":return NS.ColorTypeAdapter.Interpolate(e,t,s,this._propertyTrack);case"text":return NS.TextTypeAdapter.Interpolate(e,t,s,this._propertyTrack)}}AfterInterpolate(){this._propertyAdapter.AfterChangeProperty()}SaveState(){this.GetPropertyAdapter().SetSaveState()}ClearSaveState(){this.GetPropertyAdapter().ClearSaveState()}GetCurrentState(){return this.GetPropertyAdapter().GetCurrentState()}CompareInitialStateWithCurrent(){return this.GetPropertyAdapter().CompareInitialStateWithCurrent()}CompareSaveStateWithCurrent(){return this.GetPropertyAdapter().CompareSaveStateWithCurrent()}GetValueAtTime(){const e=this._propertyTrack,t=e.GetTrack(),s=t.GetTimeline().GetTime(),i=NS.GetStartPropertyKeyframeForTime(s,e),r=i.GetNext(),n=e.GetPropertyKeyframeType();switch(n){case"numeric":return NS.NumericTypeAdapter.Interpolate(s,i,r,e);case"angle":return NS.AngleTypeAdapter.Interpolate(s,i,r,e);case"boolean":return NS.BooleanTypeAdapter.Interpolate(s,i,r,e);case"color":return NS.ColorTypeAdapter.Interpolate(s,i,r,e);case"text":return NS.TextTypeAdapter.Interpolate(s,i,r,e)}}_CreatePropertyAdapter(){const e=this._propertyTrack,t=e.CanHavePropertyKeyframes()?e.GetPropertyKeyframeType():"";switch(t){case"combo":case"boolean":case"text":case"string":return new NS.PropertyInterpolationAdapter.NoInterpolationAdapter(this);case"numeric":case"number":case"angle":return new("combo"===this._propertyTrack.GetPropertyType()?NS.PropertyInterpolationAdapter.NoInterpolationAdapter:NS.PropertyInterpolationAdapter.NumericInterpolationAdapter)(this);case"color":case"offsetColor":return new NS.PropertyInterpolationAdapter.ColorInterpolationAdapter(this);default:return new NS.PropertyInterpolationAdapter.NumericInterpolationAdapter(this)}}_SaveToJson(){return{propertyAdapterJson:this.GetPropertyAdapter()._SaveToJson()}}_LoadFromJson(e){e&&this.GetPropertyAdapter()._LoadFromJson(e.propertyAdapterJson)}}}{const C33=self.C3,INDEX=0;class InstanceVariableSourceAdapter extends C33.PropertyTrackState.PropertySourceAdapter{constructor(e){super(e),this._updatedIndex=NaN}GetEditorIndex(){return this._propertyTrack.GetPropertyTrackDataItem().GetSourceAdapterArguments()[INDEX]}GetIndex(){return this._updatedIndex||super.GetIndex()}GetTarget(){return this._propertyTrack.GetTrack().GetInstance()}UpdateInstanceVariableIndex(e){const t=this._propertyTrack.GetPropertyTrackDataItem().GetSourceAdapterArguments()[INDEX];t!==e&&(this._updatedIndex=e)}Interpolate(e,t,s,i,r,n,a){this.GetPropertyAdapter().CanChange(t.GetValue())&&super.Interpolate(e,t,s,i,r,n,a)}GetInterpolatedValue(e,t,s){if(this.GetPropertyAdapter().CanChange(t.GetValue()))return super.GetInterpolatedValue(e,t,s)}_SaveToJson(){return Object.assign(super._SaveToJson(),{index:this._updatedIndex})}_LoadFromJson(e){e&&(super._LoadFromJson(e),this._updatedIndex=e.index)}}C33.PropertyTrackState.InstanceVariableSourceAdapter=InstanceVariableSourceAdapter}{const C33=self.C3,SID=0,INDEX=1,NAME=2;class BehaviorSourceAdapter extends C33.PropertyTrackState.PropertySourceAdapter{constructor(e){super(e),this._sid=NaN}GetEditorIndex(){const e=this._propertyTrack.GetPropertyTrackDataItem();return e.GetSourceAdapterArguments()[INDEX]}GetTarget(){const e=this._propertyTrack.GetPropertyTrackDataItem(),t=this._propertyTrack.GetTrack(),s=this._sid||e.GetSourceAdapterArguments()[SID],i=t.GetInstance(),r=i.GetBehaviorIndexBySID(s),n=i.GetBehaviorInstances()[r];return n.GetSdkInstance()}GetBehaviorType(e){const t=this._propertyTrack.GetPropertyTrackDataItem(),s=t.GetSourceAdapterArguments()[NAME];return e.GetBehaviorTypeByName(s)}UpdateBehaviorTypeSid(e){const t=this._propertyTrack.GetPropertyTrackDataItem();t.GetSourceAdapterArguments()[SID]!==e&&(this._sid=e)}Interpolate(e,t,s,i,r,n,a){const o=this._propertyTrack.GetTrack(),l=o.GetInstance();this.GetBehaviorType(l.GetObjectClass())&&super.Interpolate(e,t,s,i,r,n,a)}GetInterpolatedValue(e,t,s){const i=this._propertyTrack.GetTrack(),r=i.GetInstance();if(this.GetBehaviorType(r.GetObjectClass()))return super.GetInterpolatedValue(e,t,s)}_SaveToJson(){return Object.assign(super._SaveToJson(),{sid:this._sid})}_LoadFromJson(e){e&&(super._LoadFromJson(e),this._sid=e.sid)}}C33.PropertyTrackState.BehaviorSourceAdapter=BehaviorSourceAdapter}{const C33=self.C3,NAME=0,INDEX=1;class EffectSourceAdapter extends C33.PropertyTrackState.PropertySourceAdapter{constructor(e){super(e)}GetEditorIndex(){return this._propertyTrack.GetPropertyTrackDataItem().GetSourceAdapterArguments()[INDEX]}GetTarget(){const e=this._propertyTrack,t=e.GetTrack(),s=t.GetWorldInfo(),i=s.GetInstanceEffectList(),r=i.GetEffectList(),n=this.GetEffectType(r),a=n.GetIndex();return i.IsEffectIndexActive(a)?i.GetEffectParametersForIndex(a):null}GetEffectType(e){const t=this._propertyTrack,s=t.GetPropertyTrackDataItem().GetSourceAdapterArguments()[NAME];return e.GetEffectTypeByName(s)}Interpolate(e,t,s,i,r,n,a){this._IsEffectActive()&&super.Interpolate(e,t,s,i,r,n,a)}GetInterpolatedValue(e,t,s){if(this._IsEffectActive())return super.GetInterpolatedValue(e,t,s)}_IsEffectActive(){const e=this._propertyTrack,t=e.GetTrack(),s=t.GetWorldInfo(),i=s.GetInstanceEffectList(),r=i.GetEffectList(),n=this.GetEffectType(r);if(n){const a=n.GetIndex();return i.IsEffectIndexActive(a)}}}C33.PropertyTrackState.EffectSourceAdapter=EffectSourceAdapter}{const C33=self.C3,INDEX=0;class PluginSourceAdapter extends C33.PropertyTrackState.PropertySourceAdapter{constructor(e){super(e)}GetEditorIndex(){return this._propertyTrack.GetPropertyTrackDataItem().GetSourceAdapterArguments()[INDEX]}GetTarget(){return this._propertyTrack.GetTrack().GetInstance().GetSdkInstance()}Interpolate(e,t,s,i,r,n,a){const o=this._propertyTrack.GetTrack(),l=o.GetObjectClass().GetPlugin(),h=o.GetInstance().GetObjectClass().GetPlugin();l===h&&super.Interpolate(e,t,s,i,r,n,a)}GetInterpolatedValue(e,t,s){const i=this._propertyTrack.GetTrack(),r=i.GetObjectClass().GetPlugin(),n=i.GetInstance().GetObjectClass().GetPlugin();if(r===n)return super.GetInterpolatedValue(e,t,s)}GetOptionalCallbacks(){const e=this._propertyTrack.GetTrack(),t=e.GetObjectClass().GetPlugin();if(C33.Plugins.Sprite&&t instanceof C33.Plugins.Sprite&&("initial-frame"===this._propertyTrack.GetPropertyName()||"initial-animation"===this._propertyTrack.GetPropertyName()))switch(this._propertyTrack.GetResultMode()){case"relative":case"absolute":return null}}}C33.PropertyTrackState.PluginSourceAdapter=PluginSourceAdapter}{const C33=self.C3;class ValueSourceAdapter extends C33.PropertyTrackState.PropertySourceAdapter{constructor(e){super(e),this._value=0,this._init=!1}MayNeedBeforeAndAfterInterpolate(){return!1}SetInitialState(){let e=this._propertyTrack.GetPropertyTrackData(),t=this._propertyTrack.GetPropertyTrackDataItem();t=e.GetFirstPropertyKeyframeDataItem(t),this._value=t.GetValueWithResultMode()}SetResumeState(){}GetValue(){return this._init||this._propertyTrack.Interpolate(0),this._value}Interpolate(e,t,s,i,r,n,a){this._value=C33.PropertyTrackState.NumericTypeAdapter.Interpolate(e,t,s,this._propertyTrack),this._init=!0}SaveState(){}ClearSaveState(){}GetCurrentState(){return this._value}CompareInitialStateWithCurrent(){return!1}CompareSaveStateWithCurrent(){return!1}_SaveToJson(){return{value:this._value,init:this._init}}_LoadFromJson(e){e&&(this._value=e.value,this._init=!e.hasOwnProperty("init")||e.init)}}C33.PropertyTrackState.ValueSourceAdapter=ValueSourceAdapter}{const C33=self.C3,PROJECT_FILE=0,PROJECT_FILE_NAME=0,PROJECT_FILE_TYPE=1,START_OFFSET=1,AUDIO_DURATION=2,AUDIO_TAG=3;class AudioSourceAdapter extends C33.PropertyTrackState.PropertySourceAdapter{constructor(e){super(e),this._audioPlaybackStarted=!1,this._sdkInstance=null,this._actions=null,this._expressions=null,this._timeline=this._propertyTrack.GetTimeline(),this._track=this._propertyTrack.GetTrack(),this._sourceAdapterArgs=this._propertyTrack.GetSourceAdapterArgs(),this._fileArgs=this._sourceAdapterArgs[PROJECT_FILE],this._startOffsetTime=this._sourceAdapterArgs[START_OFFSET],this._sourceAdapterArgs[AUDIO_TAG]?this._audioTag=this._sourceAdapterArgs[AUDIO_TAG]:this._audioTag=Math.random().toString(36).slice(2),this._pauseTime=NaN,this._pauseVolume=NaN,this._volume=NaN,this._audioSource=null,this._Initialize()}Release(){super.Release(),this._sdkInstance=null,this._actions=null,this._expressions=null,this._timeline=null,this._track=null,this._sourceAdapterArgs=null,this._fileArgs=null,this._audioSource=null}_Initialize(){if(self.C3.Plugins.Audio){const e=this._propertyTrack.GetRuntime(),t=e.GetSingleGlobalObjectClassByCtor(self.C3.Plugins.Audio);t&&(this._sdkInstance=t.GetSingleGlobalInstance().GetSdkInstance()),this._actions=self.C3.Plugins.Audio.Acts,this._expressions=self.C3.Plugins.Audio.Exps}}_MaybeSetAudioSource(){if(!this._audioSource){const e=this._propertyTrack.GetTrack(),t=e.GetPropertyTrack("audioSource");t&&(this._audioSource=t.GetSourceAdapter())}}_GetPauseVolume(){const e=this._propertyTrack.GetTrack(),t=e.GetPropertyTrack("volume");return(t?t.GetSourceAdapter():this)._pauseVolume}TimelineRemoved(){super.TimelineRemoved(),this._audioPlaybackStarted=!1,this._sdkInstance&&(this._expressions&&(this._pauseTime=this._expressions.PlaybackTime.call(this._sdkInstance,this._audioTag),this._pauseVolume=this._expressions.Volume.call(this._sdkInstance,this._audioTag)),this._actions)&&this._actions.Stop.call(this._sdkInstance,this._audioTag)}GetAudioTag(){return this._audioTag}GetVolume(){return this._volume}SetVolume(e){this._volume=e}SetInitialState(){super.SetInitialState(),this._pauseTime=NaN,this._audioPlaybackStarted=!1}SetResumeState(){super.SetResumeState();const e=this._propertyTrack.GetTimeline(),t=e.GetTime();switch(this._pauseTime=t-this._startOffsetTime,this._propertyTrack.GetPropertyName()){case"audioSource":break;case"volume":this._pauseVolume=this._propertyTrack.GetInterpolatedValue(t)}this._audioPlaybackStarted=!1}Interpolate(e,t,s,i,r,n,a){if(this._sdkInstance)switch(this._propertyTrack.GetPropertyName()){case"audioSource":{if(!this._timeline.IsForwardPlayBack())return;if(i)return void(this._actions&&this._actions.Stop.call(this._sdkInstance,this._audioTag));if(e<this._startOffsetTime)return void(this._audioPlaybackStarted=!1);const o=this._expressions.PlaybackRate.call(this._sdkInstance,this._audioTag),l=this._timeline.GetPlaybackRate();if(l!==o&&this._actions.SetPlaybackRate.call(this._sdkInstance,this._audioTag,l),this._audioPlaybackStarted)return;if(!this._propertyTrack.GetTimeline().IsPlaying())return;if(this._audioPlaybackStarted=!0,isNaN(this._pauseTime)){const h=self.performance.now(),c=e-this._startOffsetTime,u=this._sdkInstance.GetAudioContextState();if("suspended"===u)return void(this._audioPlaybackStarted=!1);const _=self.performance.now(),d=(_-h)/1e3,p=c+d;if(this._actions){let e=this.GetVolume();isNaN(e)?(this.SetVolume(0),e=0):this.SetVolume(e),this._actions.PlayFromTimeline.call(this._sdkInstance,this._fileArgs,e,this._audioTag,p)}}else{const m=this._pauseTime,g=(this._pauseTime=NaN,this._GetPauseVolume()),f=(this._pauseVolume=NaN,this._sdkInstance.GetAudioContextState());if("suspended"===f)return void(this._audioPlaybackStarted=!1);this._actions&&(this.SetVolume(g),this._actions.PlayFromTimeline.call(this._sdkInstance,this._fileArgs,g,this._audioTag,m))}break}case"volume":this._MaybeSetAudioSource(),super.Interpolate(e,t,s,i,r,n,a)}}GetInterpolatedValue(e,t,s){if(this._sdkInstance)switch(this._propertyTrack.GetPropertyName()){case"audioSource":return;case"volume":return this._MaybeSetAudioSource(),super.GetInterpolatedValue(e,t,s)}}Getter(e,t){return this._audioSource?this._audioSource.GetVolume():0}Setter(e,t,s,i){this._audioSource&&this._audioSource.SetVolume(this.Getter()+t),this._actions&&this._audioSource&&this._actions.SetVolume.call(this._sdkInstance,this._audioSource.GetAudioTag(),this._audioSource.GetVolume())}AbsoluteSetter(e,t,s){this._audioSource&&this._audioSource.SetVolume(t),this._actions&&this._audioSource&&this._actions.SetVolume.call(this._sdkInstance,this._audioSource.GetAudioTag(),this._audioSource.GetVolume())}DoesRounding(){return!0}_SaveToJson(){return{audioPlaybackStarted:this._audioPlaybackStarted,audioTag:this._audioTag,pauseTime:this._pauseTime,pauseVolume:this._pauseVolume,volume:this._volume}}_LoadFromJson(e){e&&(this._audioPlaybackStarted=e.audioPlaybackStarted,this._audioTag=e.audioTag,this._pauseTime=e.pauseTime,this._pauseVolume=e.pauseVolume,this._volume=e.volume,this._Initialize())}}C33.PropertyTrackState.AudioSourceAdapter=AudioSourceAdapter}{const C33=self.C3;C33.PropertyTrackState.PropertyInterpolationAdapter=class{constructor(e){this._sourceAdapter=e,this._propertyTrack=e.GetPropertyTrack(),this._worldInfo=this._propertyTrack.GetTrack().GetWorldInfo(),this._property=this._propertyTrack.GetPropertyName(),this._firstAbsoluteUpdate=!1,this._saveState=null,this._target=null}Release(){this._sourceAdapter=null,this._propertyTrack=null,this._worldInfo=null,this._saveState=null,this._target=null}MayNeedBeforeAndAfterInterpolate(){return!1}TimelineRemoved(){}CleanCaches(){this._worldInfo=null,this._saveState=null,this._target=null}GetSourceAdapter(){return this._sourceAdapter}GetPropertyTrack(){return this._propertyTrack}GetWorldInfo(){return this._worldInfo||(this._worldInfo=this._propertyTrack.GetTrack().GetWorldInfo()),this._worldInfo}SetFirstAbsoluteUpdate(e){this._firstAbsoluteUpdate=!!e}GetFirstAbsoluteUpdate(){return this._firstAbsoluteUpdate}SetResetState(){}SetInitialState(){}SetResumeState(){}SetSaveState(){this._saveState=this.GetCurrentState()}ClearSaveState(){this._saveState=null}GetCurrentState(){}CompareInitialStateWithCurrent(){}CompareSaveStateWithCurrent(){}CanChange(e){const t=typeof this._Getter(),s=typeof e;return t==s}BeforeChangeProperty(){}ChangeProperty(e,t,s,i,r,n,a,o){}AfterChangeProperty(){}_FirstKeyframeGetter(){const e=this._PickTimelinePlaybackMode(()=>{const e=this._propertyTrack.GetPropertyTrackDataItem(),t=this._propertyTrack.GetPropertyTrackData();return t.GetFirstPropertyKeyframeDataItem(e)},()=>{const e=this._propertyTrack.GetPropertyTrackDataItem(),t=this._propertyTrack.GetPropertyTrackData();return t.GetLastPropertyKeyframeDataItem(e)});return e.GetAbsoluteValue()}_CurrentKeyframeGetter(){const e=this._propertyTrack.GetTimeline(),i=e.GetTime()-this._propertyTrack.GetTrack().GetStartOffset(),t=this._PickTimelinePlaybackMode(()=>{const e=this._propertyTrack.GetPropertyTrackDataItem(),t=this._propertyTrack.GetPropertyTrackData();return t.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(i,e)},()=>{const e=this._propertyTrack.GetPropertyTrackDataItem(),t=this._propertyTrack.GetPropertyTrackData(),s=t.GetFirstPropertyKeyFrameDataItemHigherOrEqualThan(i,e);return s||t.GetLastPropertyKeyframeDataItem(e)});return t.GetAbsoluteValue()}_PickTimelinePlaybackMode(e,t){const s=this._propertyTrack.GetTimeline();return(s.IsForwardPlayBack()?e:t)()}_PickResultMode(e,t){const s=this._propertyTrack.GetResultMode();return("relative"===s?e:t)()}_PickFirstAbsoluteUpdate(e,t){return(this.GetFirstAbsoluteUpdate()?(this.SetFirstAbsoluteUpdate(!1),e):t)()}_GetAbsoluteInitialValue(e){}_GetIndex(){return this._sourceAdapter.GetIndex()}_GetTarget(){return this._target||(this._target=this._sourceAdapter.GetTarget()),this._target}_PickSource(e,t,s,i,r,n){const a=this._propertyTrack.GetSourceAdapterId();switch(a){case"behavior":return e();case"effect":return t();case"instance-variable":return s();case"plugin":return i();case"world-instance":return r();case"audio":return n()}}_SaveToJson(){return{firstAbsoluteUpdate:this._firstAbsoluteUpdate,saveState:this._saveState}}_LoadFromJson(e){e&&(this._firstAbsoluteUpdate=e.firstAbsoluteUpdate,this._saveState=e.saveState)}_GetPropertyKeyframeStubs(e,t=!1){const s=[];for(const i of e){const r=i.GetTrack().GetStartOffset();for(const n of i.GetPropertyKeyframeDataItems())(t&&0===n.GetTime()||!t)&&s.push({time:r+n.GetTime(),value:n.GetAbsoluteValue()})}return s.sort((e,t)=>e.time-t.time)}_GetLastPropertyKeyframeStub(e,t,s){return this._GetPropertyKeyframeStubLowerThanPlayhead(t,s)}_GetPropertyKeyframeStubLowerThanPlayhead(t,s){for(let e=s.length-1;0<=e;e--){const i=s[e].time;if(i<=t)return s[e]}return null}}}{const C33=self.C3,TMP_COLORS_MAP=new Map,TMP_COLOR=[0,0,0];class ColorInterpolationAdapter extends C33.PropertyTrackState.PropertyInterpolationAdapter{constructor(e){super(e)}SetResetState(){}SetInitialState(){}SetResumeState(){}GetCurrentState(){const e=this._propertyTrack.GetSourceAdapterId(),t=this._GetTarget(),s=this._GetIndex();switch(e){case"behavior":return this._ToColorArray(t.GetPropertyValueByIndex(s));case"effect":return this._ToColorArray(t[s]);case"plugin":return this._ToColorArray(t.GetPropertyValueByIndex(s));case"world-instance":return this._ToColorArray(this._Getter())}}CompareInitialStateWithCurrent(){const e=this._FirstKeyframeGetter();return!this._CompareColors(e,this._Getter())}CompareSaveStateWithCurrent(){return!C33.IsNullOrUndefined(this._saveState)&&!this._CompareColors(this._saveState,this._Getter())}_CompareColors(e,t){return e=this._GetColorFromArray(e),t=this._GetColorFromArray(t),e.equalsIgnoringAlpha(t)}_FirstKeyframeGetter(){const e=super._FirstKeyframeGetter();return this._GetColorFromArray(e)}_CurrentKeyframeGetter(){const e=super._CurrentKeyframeGetter();return this._GetColorFromArray(e)}_GetAbsoluteInitialValue(e){}_ToColorArray(e){return(C33.IsInstanceOf(e,C33.Color)?e.toArray():e).slice(0,3)}_GetColorFromArray(e){return C33.IsInstanceOf(e,C33.Color)?e:new C33.Color(e[0],e[1],e[2],1)}CanChange(e){return!0}MayNeedBeforeAndAfterInterpolate(){return!0}BeforeChangeProperty(){const e=this._propertyTrack.GetTimeline(),t=this._propertyTrack.GetInstance(),s=this._propertyTrack.GetSourceAdapter(),i=e.GetSimilarPropertyTracks(t,s,this._property,this._propertyTrack);if(i&&1<i.length){TMP_COLORS_MAP.has(t)||TMP_COLORS_MAP.set(t,new Map);const r=TMP_COLORS_MAP.get(t),n=this._propertyTrack.GetSourceAdapterId(),a=(r.has(n)||r.set(n,new Map),r.get(n));a.has(this._property)||a.set(this._property,{used:!1,color:new C33.Color(0,0,0,1)})}}_GetTmpColor(e,t,s){const i=TMP_COLORS_MAP.get(e).get(t).get(s);return i.used=!0,i.color}ChangeProperty(e,t,s,i,r,n,a,o){const l=this._propertyTrack.GetTimeline(),h=this._propertyTrack.GetTrack(),c=this._propertyTrack.GetInstance(),u=this._propertyTrack.GetSourceAdapter(),_=this._propertyTrack.GetSourceAdapterId(),d=this._property,p=l.GetSimilarPropertyTracks(c,u,d,this._propertyTrack);if(p&&1<p.length){const m=this._GetPropertyKeyframeStubs(p,!0),g=this._GetLastPropertyKeyframeStub(l,l.GetTime(),m);if(g){const f=h.GetStartOffset(),S=g.time-f;if(0==S)this._GetTmpColor(c,_,this._property).addRgb(t[0],t[1],t[2]);else if(!(S<0)){const C=t[0],y=t[1],G=t[2],I=this._propertyTrack.Interpolate(S,!1,!0),T=C33.Color.DiffChannel(C,I[0]),b=C33.Color.DiffChannel(y,I[1]),A=C33.Color.DiffChannel(G,I[2]);this._GetTmpColor(c,_,this._property).addRgb(T,b,A)}}}else this._Setter(t[0],t[1],t[2])}AfterChangeProperty(){const e=this._propertyTrack.GetInstance();if(TMP_COLORS_MAP.has(e)){const t=TMP_COLORS_MAP.get(e),s=this._propertyTrack.GetSourceAdapterId();if(t.has(s)){const i=t.get(s);if(i.has(this._property)){const r=i.get(this._property),n=r.used,a=r.color;n&&this._Setter(a.getR(),a.getG(),a.getB()),0===i.size&&t.delete(s),0===t.size&&TMP_COLORS_MAP.delete(e)}}}}_Getter(){const e=this._propertyTrack.GetSourceAdapterId(),t=this._GetTarget(),s=this._GetIndex();switch(e){case"behavior":return this._GetColorFromArray(t.GetPropertyValueByIndex(s));case"effect":return t[s].clone();case"plugin":return this._GetColorFromArray(t.GetPropertyValueByIndex(s));case"world-instance":return this.GetWorldInfo().GetUnpremultipliedColor().clone()}}_Setter(e,t,s){const i=this._propertyTrack.GetSourceAdapterId(),r=this._GetTarget(),n=this._GetIndex();switch(i){case"behavior":TMP_COLOR[0]=e,TMP_COLOR[1]=t,TMP_COLOR[2]=s,r.SetPropertyValueByIndex(n,TMP_COLOR);break;case"effect":r[n].setRgb(e,t,s);break;case"plugin":TMP_COLOR[0]=e,TMP_COLOR[1]=t,TMP_COLOR[2]=s,r.SetPropertyValueByIndex(n,TMP_COLOR);break;case"world-instance":this.GetWorldInfo().SetUnpremultipliedColorRGB(e,t,s)}}_SaveToJson(){}_LoadFromJson(e){}}C33.PropertyTrackState.PropertyInterpolationAdapter.ColorInterpolationAdapter=ColorInterpolationAdapter}{const C33=self.C3,NS=C33.PropertyTrackState;class NoInterpolationAdapter extends C33.PropertyTrackState.PropertyInterpolationAdapter{constructor(e){super(e)}SetResetState(){}SetInitialState(){}SetResumeState(){}GetCurrentState(){return this._Getter()}CompareInitialStateWithCurrent(){const e=this._FirstKeyframeGetter();return e!==this.GetCurrentState()}CompareSaveStateWithCurrent(){return!C33.IsNullOrUndefined(this._saveState)&&this._saveState!==this.GetCurrentState()}MayNeedBeforeAndAfterInterpolate(){return!1}ChangeProperty(e,t,s,i,r,n,a,o){const l=this._propertyTrack,h=l.GetTrack(),c=l.GetSourceAdapterId(),u=l.GetTimeline(),_=h.GetInstance(),d=l.GetSourceAdapter(),p=this._property,m=u.GetSimilarPropertyTracks(_,d,p,l);if(m&&1<m.length){const f=this._GetPropertyKeyframeStubs(m),S=e+h.GetStartOffset(),C=this._GetLastPropertyKeyframeStub(u,S,f);C&&(t=C.value)}const g=l.GetPropertyKeyframeType();switch(g){case"numeric":if(NS.NumericTypeAdapter.WillChange(this._GetIndex(),this._GetTarget(),t,c))break;return;case"angle":if(NS.AngleTypeAdapter.WillChange(this._GetIndex(),this._GetTarget(),t,c))break;return;case"boolean":if(NS.BooleanTypeAdapter.WillChange(this._GetIndex(),this._GetTarget(),t,c))break;return;case"color":if(NS.ColorTypeAdapter.WillChange(this._GetIndex(),this._GetTarget(),t,c))break;return;case"text":if(!NS.TextTypeAdapter.WillChange(this._GetIndex(),this._GetTarget(),t,c))return}this._Setter(t)}_Getter(){const e=this._propertyTrack.GetSourceAdapterId(),t=this._GetTarget(),s=this._GetIndex();switch(e){case"behavior":return t.GetPropertyValueByIndex(s);case"effect":return t[s];case"instance-variable":return t.GetInstanceVariableValue(s);case"plugin":return t.GetPropertyValueByIndex(s)}}_Setter(e){const t=this._propertyTrack.GetSourceAdapterId(),s=this._GetTarget(),i=this._GetIndex();switch(t){case"behavior":s.SetPropertyValueByIndex(i,e);break;case"effect":s[i]=e;break;case"instance-variable":s.SetInstanceVariableValue(i,e);break;case"plugin":s.SetPropertyValueByIndex(i,e)}}}C33.PropertyTrackState.PropertyInterpolationAdapter.NoInterpolationAdapter=NoInterpolationAdapter}{const C33=self.C3,NS=C33.PropertyTrackState.PropertyInterpolationAdapter,INSTANCE_FUNC_MAP=new Map,add2=(e,t,s,i,r,n=!1,a=null,o=null)=>{INSTANCE_FUNC_MAP.set(e,{setter:t,absolute_setter:s,getter:i,round:r,fRound:n,init:a,reset:o})};add2("offsetX",(e,t,s,i)=>{"relative"===i._propertyTrack.GetResultMode()?e.OffsetX(t,s.GetTimeline().GetTransformWithSceneGraph()):e.OffsetX(t)},(e,t)=>e.SetX(t),e=>e.GetX(),!0),add2("offsetY",(e,t,s,i)=>{"relative"===i._propertyTrack.GetResultMode()?e.OffsetY(t,s.GetTimeline().GetTransformWithSceneGraph()):e.OffsetY(t)},(e,t)=>e.SetY(t),e=>e.GetY(),!0),add2("offsetWidth",(t,e,o,s,i)=>{if(0!==e){const r="relative"===s._propertyTrack.GetResultMode(),h=1===s._typeAdapter.GetType();if((r||h)&&t.HasParent()&&t.GetTransformWithParentWidth()){if(isNaN(s._absoluteToFactor)){let i=[],e=t.GetParent();for(;e;)i.push(e),e=e.GetParent();i.reverse();let l=(e,t)=>t.GetTimeline().GetTrackFromInstance(e.GetInstance()),r=(e,t)=>{const s=l(e,t);if(s)return s.GetOriginalWidth();const i=e.GetInstance().GetSdkInstance();return i.IsOriginalSizeKnown()?i.GetOriginalWidth():e._GetSceneGraphInfo()._GetStartWidth()},n=(e,t,s,i=0)=>{const r=l(e,t);if(!r)return i;const n=r.GetPropertyTrack(s);if(!n)return i;const a=n.GetPropertyTrackDataItem().GetPropertyKeyframeData();if(!a)return i;const o=a.GetLastPropertyKeyframeDataItem();return o?o.GetValue():i},a;if(h){let e=i[i.length-1];a=e.GetWidth()}else{let t=i[0],e=t._GetSceneGraphInfo()._GetStartWidth(),s=t._GetSceneGraphInfo().GetStartScaleX();a=e*s,a=(a+=n(t,o,"offsetWidth"))+r(t,o)*n(t,o,"offsetScaleX");for(let e=1;e<i.length;e++){const c=(t=i[e])._GetSceneGraphInfo().GetStartScaleX();a=(a=(a*=c)+n(t,o,"offsetWidth"))+r(t,o)*n(t,o,"offsetScaleX")}}s._absoluteToFactor=0===a?Number.EPSILON:a}i||t.OffsetWidth(e/s._absoluteToFactor,!0)}else t.OffsetWidth(e)}},(e,t)=>e.SetWidth(t),e=>e.GetWidth(),!0),add2("offsetHeight",(t,e,o,s,i)=>{if(0!==e){const r="relative"===s._propertyTrack.GetResultMode(),l=1===s._typeAdapter.GetType();if((r||l)&&t.HasParent()&&t.GetTransformWithParentHeight()){if(isNaN(s._absoluteToFactor)){let i=[],e=t.GetParent();for(;e;)i.push(e),e=e.GetParent();i.reverse();let r=(e,t)=>{i=e;const s=t.GetTimeline().GetTrackFromInstance(i.GetInstance());var i;if(s)return s.GetOriginalHeight();const r=e.GetInstance().GetSdkInstance();return r.IsOriginalSizeKnown()?r.GetOriginalHeight():e._GetSceneGraphInfo()._GetStartHeight()},n=(e,t,s,i=0)=>{const r=t.GetTimeline().GetTrackFromInstance(e.GetInstance());if(!r)return i;const n=r.GetPropertyTrack(s);if(!n)return i;const a=n.GetPropertyTrackDataItem().GetPropertyKeyframeData();if(!a)return i;const o=a.GetLastPropertyKeyframeDataItem();return o?o.GetValue():i},a;if(l){let e=i[i.length-1];a=e.GetHeight()}else{let t=i[0],e=t._GetSceneGraphInfo()._GetStartHeight(),s=t._GetSceneGraphInfo().GetStartScaleY();a=e*s,a=(a+=n(t,o,"offsetHeight"))+r(t,o)*n(t,o,"offsetScaleY");for(let e=1;e<i.length;e++){const h=(t=i[e])._GetSceneGraphInfo().GetStartScaleY();a=(a=(a*=h)+n(t,o))+r(t,o)*n(t,o,"offsetScaleY")}}s._absoluteToFactor=0===a?Number.EPSILON:a}i||t.OffsetHeight(e/s._absoluteToFactor,!0)}else t.OffsetHeight(e)}},(e,t)=>e.SetHeight(t),e=>e.GetHeight(),!0),add2("offsetAngle",(e,t,s,i,r)=>{e.OffsetAngle(t)},(e,t)=>e.SetAngle(t),e=>e.GetAngle(),!1,!0),add2("offsetOpacity",(e,t,s,i,r)=>{const n=i._opacityFactor||1,a=(t/=n,e.GetOpacity()),o=a+t;if(0===i._clampAccumulator)1<o?i._clampAccumulator+=o-1:o<0&&(i._clampAccumulator+=o),e.OffsetOpacity(t);else{const l=e.GetOpacity()+t;0<t&&0<i._clampAccumulator?1<l&&(i._clampAccumulator+=l-1):0<t&&i._clampAccumulator<0?(i._clampAccumulator+=t,0<i._clampAccumulator&&(e.OffsetOpacity(i._clampAccumulator),i._clampAccumulator=0)):t<0&&0<i._clampAccumulator?(i._clampAccumulator+=t,i._clampAccumulator<0&&(e.OffsetOpacity(i._clampAccumulator),i._clampAccumulator=0)):t<0&&i._clampAccumulator<0&&l<0&&(i._clampAccumulator+=l)}},(e,t)=>{e.SetOpacity(t)},e=>e.GetOpacity(),!1,!0,(n,r,a)=>{switch(n._clampAccumulator=0,n._propertyTrack.GetResultMode()){case"relative":{n._propertyTrack.GetPropertyTrackData();let e=n._propertyTrack.GetPropertyTrackDataItem(),t=e.GetPropertyKeyframeData(),s=t.GetPropertyKeyframeDataItemArray(),i=n.GetWorldInfo().GetOpacity(),r=i;for(const o of s){const l=o.GetTime(),h=n._propertyTrack.GetInterpolatedValue(l);r=i+h,r=C33.clamp(r,0,1)}n._totalForewardOpacityDelta=i-r,n._totalForewardOpacityDelta=Math.round(100*(n._totalForewardOpacityDelta+Number.EPSILON))/100,r=i;for(let e=s.length-1;0<=e;e--){const c=s[e].GetTime(),u=n._propertyTrack.GetInterpolatedValue(c);r-=u,r=C33.clamp(r,0,1)}n._totalBackwardOpacityDelta=r,n._totalBackwardOpacityDelta=Math.round(100*(n._totalBackwardOpacityDelta+Number.EPSILON))/100;break}}const e="relative"===n._propertyTrack.GetResultMode(),t=1===n._typeAdapter.GetType();if((e||t)&&r.HasParent()&&r.GetTransformWithParentOpacity()){let t=[],e=r.GetParent();for(;e;)t.push(e),e=e.GetParent();t.reverse();let s=(e,t,s)=>{const i=t.GetTimeline().GetTrackFromInstance(e.GetInstance());if(!i)return 0;const r=i.GetPropertyTrack(s);if(!r)return 0;const n=r.GetPropertyTrackDataItem().GetPropertyKeyframeData();if(!n)return 0;const a=n.GetLastPropertyKeyframeDataItem();return a?a.GetValue():0},i=t[0]._GetSceneGraphInfo().GetStartOpacity();i+=s(t[0],a,"offsetOpacity");for(let e=1;e<t.length;e++)i+=s(t[e],a,"offsetOpacity");n._opacityFactor=0===i?1:i}},s=>{switch(s._propertyTrack.GetResultMode()){case"relative":{s._clampAccumulator=0;let e=s.GetWorldInfo(),t=e.GetOpacity();t=Math.round(100*(t+Number.EPSILON))/100,s._propertyTrack.GetTimeline().IsForwardPlayBack()?(e.SetOpacity(t+s._totalForewardOpacityDelta),s._lastValue=0):(e.SetOpacity(t-s._totalBackwardOpacityDelta),s._lastValue=s.GetSourceAdapter().GetValueAtTime());break}}}),add2("offsetOriginX",(e,t)=>e.OffsetOriginX(t),(e,t)=>e.SetOriginX(t),e=>e.GetOriginX(),!1),add2("offsetOriginY",(e,t)=>e.OffsetOriginY(t),(e,t)=>e.SetOriginY(t),e=>e.GetOriginY(),!1),add2("offsetZElevation",(e,t)=>e.OffsetZElevation(t),(e,t)=>e.SetZElevation(t),e=>e.GetZElevation(),!0),add2("offsetScaleX",(e,t,s,i)=>{if(0!==t){const r=e.GetWidth()<0?-1:1;if("relative"===i._propertyTrack.GetResultMode()&&e.HasParent()&&e.GetTransformWithParentWidth()){const n=s.GetOriginalWidth()*r*t;isNaN(i._absoluteToFactor)&&INSTANCE_FUNC_MAP.get("offsetWidth").setter(e,1,s,i,!0),e.OffsetWidth(n/i._absoluteToFactor,!0)}else e.OffsetWidth(s.GetOriginalWidth()*r*t)}},(e,t,s)=>{e.SetWidth(s.GetOriginalWidth()*t)},(i,r)=>{const n=i.GetWidth()<0?-1:1;if(i.GetTransformWithParentWidth()){let e=i.GetParent(),t=r.GetTimeline().GetTrackFromInstance(e.GetInstance()),s=NaN;if(t)s=e.GetWidth()/t.GetOriginalWidth();else{const a=e.GetInstance().GetSdkInstance();s=a.IsOriginalSizeKnown()?e.GetWidth()/a.GetOriginalWidth():1}return i.GetWidth()*n/(r.GetOriginalWidth()*s)}return i.GetWidth()*n/r.GetOriginalWidth()},!1),add2("offsetScaleY",(e,t,s,i)=>{if(0!==t){const r=e.GetHeight()<0?-1:1;if("relative"===i._propertyTrack.GetResultMode()&&e.HasParent()&&e.GetTransformWithParentHeight()){const n=s.GetOriginalHeight()*r*t;isNaN(i._absoluteToFactor)&&INSTANCE_FUNC_MAP.get("offsetHeight").setter(e,1,s,i,!0),e.OffsetHeight(n/i._absoluteToFactor,!0)}else e.OffsetHeight(s.GetOriginalHeight()*r*t)}},(e,t,s)=>{e.SetHeight(s.GetOriginalHeight()*t)},(i,r)=>{const n=i.GetHeight()<0?-1:1;if(i.GetTransformWithParentHeight()){let e=i.GetParent(),t=r.GetTimeline().GetTrackFromInstance(e.GetInstance()),s=NaN;if(t)s=e.GetHeight()/t.GetOriginalHeight();else{const a=e.GetInstance().GetSdkInstance();s=a.IsOriginalSizeKnown()?e.GetHeight()/a.GetOriginalHeight():1}return i.GetHeight()*n/(r.GetOriginalHeight()*s)}return i.GetHeight()*n/r.GetOriginalHeight()},!1);class NumericInterpolationAdapter extends C33.PropertyTrackState.PropertyInterpolationAdapter{constructor(e){super(e),this._lastValue=0,this._clampAccumulator=0,this._totalForewardOpacityDelta=0,this._totalBackwardOpacityDelta=0,this._opacityFactor=NaN,this._absoluteToFactor=NaN,this._angleReflectMirrorOrFlip=void 0,this._angleReflectMirrorAndFlip=void 0,this._instance_getter=null,this._instance_setter=null,this._instance_absolute_setter=null,this._reset_action=null,this._init_action=null,this._source_adapter_getter=null,this._source_adapter_setter=null,this._source_adapter_absolute_setter=null,this._round=!1,this._fRound=!1,C33.IsInstanceOf(this._propertyTrack.GetTimeline(),C33.TweenState)?this._typeAdapter=new C33.PropertyTrackState.PropertyInterpolationAdapter.NumericInterpolationAdapterForTween(this):this._typeAdapter=new C33.PropertyTrackState.PropertyInterpolationAdapter.NumericInterpolationAdapterForTimeline(this);const t=this._propertyTrack.GetPropertyName();switch(this._propertyTrack.GetSourceAdapterId()){case"world-instance":{const s=INSTANCE_FUNC_MAP.get(t);this._instance_getter=s.getter,this._instance_setter=s.setter,this._instance_absolute_setter=s.absolute_setter,this._round=s.round,this._fRound=s.fRound,this._init_action=s.init,this._reset_action=s.reset;break}case"audio":this._source_adapter_getter=e.Getter,this._source_adapter_setter=e.Setter,this._source_adapter_absolute_setter=e.AbsoluteSetter,this._round=!!e.DoesRounding(),this._fRound=!1}}Release(){this._typeAdapter=null,this._instance_getter=null,this._instance_setter=null,this._instance_absolute_setter=null,this._reset_action=null,this._init_action=null,this._source_adapter_getter=null,this._source_adapter_setter=null,this._source_adapter_absolute_setter=null,super.Release()}MayNeedBeforeAndAfterInterpolate(){return this._typeAdapter.MayNeedBeforeAndAfterInterpolate()}GetLastValue(){return this._lastValue}SetLastValue(e){this._lastValue=e}SetResetState(){this._reset_action&&this._reset_action(this)}SetInitialState(){const e=this._typeAdapter.SetInitialState();if("number"==typeof e&&(this._lastValue=e),this._init_action){const t=this.GetWorldInfo(),s=this._propertyTrack.GetTrack();this._init_action(this,t,s)}}SetResumeState(){const e=this._typeAdapter.SetResumeState();"number"==typeof e&&(this._lastValue=e)}GetCurrentState(){return this._Getter()}CompareInitialStateWithCurrent(){const e=this._FirstKeyframeGetter();return e!==this.GetCurrentState()}CompareSaveStateWithCurrent(){return!C33.IsNullOrUndefined(this._saveState)&&this._saveState!==this.GetCurrentState()}BeforeChangeProperty(){this._typeAdapter.BeforeChangeProperty()}ChangeProperty(e,t,s,i,r,n,a,o){return this._typeAdapter.ChangeProperty(e,t,s,i,r,n,a,o)}AfterChangeProperty(){this._typeAdapter.AfterChangeProperty()}_Getter(){const e=this._GetTarget(),t=this._GetIndex(),s=this.GetWorldInfo(),i=this._propertyTrack.GetTrack(),r=this._propertyTrack.GetSourceAdapterId();switch(r){case"behavior":return e.GetPropertyValueByIndex(t);case"effect":return e[t];case"instance-variable":return e.GetInstanceVariableValue(t);case"plugin":return e.GetPropertyValueByIndex(t);case"world-instance":return this._instance_getter(s,i);case"audio":return this._source_adapter_getter.call(this.GetSourceAdapter(),s,i)}}_Setter(e,t,s){const i=this._GetTarget(),r=this._GetIndex(),n=this.GetWorldInfo(),a=this._propertyTrack.GetTrack(),o=this._propertyTrack.GetSourceAdapterId();switch(o){case"behavior":i.OffsetPropertyValueByIndex(r,e);break;case"effect":i[r]+=e;break;case"instance-variable":i.SetInstanceVariableOffset(r,e);break;case"plugin":i.OffsetPropertyValueByIndex(r,e,this.GetSourceAdapter().GetOptionalCallbacks());break;case"world-instance":this._instance_setter(n,e,a,this);break;case"audio":this._source_adapter_setter.call(this.GetSourceAdapter(),n,e,a,this)}}_SetterAbsolute(e,t,s){let i=this._propertyTrack.GetInterpolationMode();if("discrete"!==(i="default"===i?"continuous":i)||t){if("discrete"===i&&s){const h=this._propertyTrack.GetTimeline(),c=h.GetTime(),u=this._propertyTrack.GetPropertyKeyFrameDataItemAtTime(c);if(!u)return}const r=this._GetTarget(),n=this._GetIndex(),a=this.GetWorldInfo(),o=this._propertyTrack.GetTrack(),l=this._propertyTrack.GetSourceAdapterId();switch(l){case"behavior":r.SetPropertyValueByIndex(n,e);break;case"effect":r[n]=e;break;case"instance-variable":r.SetInstanceVariableValue(n,e);break;case"plugin":r.SetPropertyValueByIndex(n,e,this.GetSourceAdapter().GetOptionalCallbacks());break;case"world-instance":this._instance_absolute_setter(a,e,o);break;case"audio":this._source_adapter_absolute_setter.call(this.GetSourceAdapter(),a,e,o)}}}_MaybeEnsureValue(e,t,s,i,r,n,a,o){this._typeAdapter._MaybeEnsureValue(e,t,s,i,r,n,a,o)}_AddDelta(e,t,s,i,r){let n=(e="angle"===this._propertyTrack.GetPropertyType()?C33.toDegrees(e):e).toString(),a=n.split(".")[1]||"",o=a.length,l=this._Getter(),h;switch(h=0===o?this._round?Math.round(l):this._fRound?"angle"===this._propertyTrack.GetPropertyType()?C33.toRadians(Math.round(C33.toDegrees(l))):Number(C33.toFixed(l,2)):l:this._round?Number(C33.toFixed(l,o)):(this._fRound,l),this._Setter(h-l,t,s),this._propertyTrack.GetPropertyName()){case"offsetWidth":case"offsetScaleX":{const c=this.GetWorldInfo(),u=c.GetWidth(),_=Number(C33.toFixed(u,2));c.OffsetWidth(_-u);break}case"offsetHeight":case"offsetScaleY":{const d=this.GetWorldInfo(),p=d.GetHeight(),m=Number(C33.toFixed(p,2));d.OffsetHeight(m-p);break}}}_SaveToJson(){return Object.assign(super._SaveToJson(),{v:this._lastValue,a:this._clampAccumulator,fod:this._totalForewardOpacityDelta,bod:this._totalBackwardOpacityDelta,of:this._opacityFactor,sf:this._absoluteToFactor,armorf:this._angleReflectMirrorOrFlip,armandf:this._angleReflectMirrorAndFlip})}_LoadFromJson(e){e&&(super._LoadFromJson(e),this._lastValue=e.v,this._clampAccumulator=e.a,this._totalForewardOpacityDelta=C33.IsFiniteNumber(e.fod)?e.fod:0,this._totalBackwardOpacityDelta=C33.IsFiniteNumber(e.bod)?e.bod:0,this._opacityFactor=C33.IsFiniteNumber(e.of)?e.of:NaN,this._absoluteToFactor=C33.IsFiniteNumber(e.sf)?e.sf:NaN,this._angleReflectMirrorOrFlip=C33.IsFiniteNumber(e.armorf)?e.armorf:void 0,this._angleReflectMirrorAndFlip=C33.IsFiniteNumber(e.armandf)?e.armandf:void 0)}}C33.PropertyTrackState.PropertyInterpolationAdapter.NumericInterpolationAdapter=NumericInterpolationAdapter}{const C33=self.C3;class AbsoluteValueObject{constructor(e){this._used=!1,this._value=0,this._propertyKeyframeReached=!1,this._endState=!1,this._propertyTracks=e;for(let e=0,t=this._propertyTracks.length;e<t;e++)this._propertyTracks[e].SetAbsoluteValueObject(this)}GetPropertyTracks(){return this._propertyTracks}SetUsed(){this._used=!0}GetUsed(){return this._used}SetValue(e){this._value=e}GetValue(){return this._value}SetPropertyKeyframeReached(e){this._propertyKeyframeReached=e}GetPropertyKeyframeReached(){return this._propertyKeyframeReached}SetEndState(e){this._endState=e}GetEndState(){return this._endState}Reset(){this._used=!1,this._value=0,this._propertyKeyframeReached=!1,this._endState=!1}}class NumericInterpolationAdapterForTimeline{constructor(e){this._numericInterpolationAdapter=e}Release(){this._numericInterpolationAdapter=null}GetType(){return 0}SetInitialState(){const e=this._numericInterpolationAdapter;return this._numericInterpolationAdapter.GetPropertyTrack(),e._PickResultMode(()=>e._PickTimelinePlaybackMode(()=>0,()=>e.GetSourceAdapter().GetValueAtTime()),()=>{})}SetResumeState(){}MayNeedBeforeAndAfterInterpolate(){this._numericInterpolationAdapter;const e=this._numericInterpolationAdapter.GetPropertyTrack();switch(e.GetResultMode()){case"relative":return!1;case"absolute":return!0}}BeforeChangeProperty(){this._numericInterpolationAdapter;const e=this._numericInterpolationAdapter.GetPropertyTrack(),t=e.GetPropertyName();switch(e.GetResultMode()){case"relative":break;case"absolute":if(e.HasAbsoluteValueObject()){const s=e.GetAbsoluteValueObject();s.Reset()}else{const i=e.GetTimeline(),r=e.GetInstance(),n=e.GetSourceAdapter(),a=i.GetSimilarPropertyTracks(r,n,t,e);a&&1<a.length&&new AbsoluteValueObject(a)}}}ChangeProperty(e,t,s,i,r,n,a,o){const l=this._numericInterpolationAdapter,h=this._numericInterpolationAdapter.GetPropertyTrack();switch(h.GetResultMode()){case"relative":{const c=l.GetLastValue();l._Setter(t-c,s,i),n&&this._MaybeEnsureValue(e,s,i,r,c,t),l.SetLastValue(t);break}case"absolute":{const u=h.GetTimeline(),_=h.GetTrack();if(h.GetInstance(),h.GetSourceAdapter(),h.HasAbsoluteValueObject()){const d=h.GetAbsoluteValueObject(),p=d.GetPropertyTracks(),m=l._GetPropertyKeyframeStubs(p,!0),g=l._GetLastPropertyKeyframeStub(u,u.GetTime(),m);if(g){const f=_.GetStartOffset(),S=g.time-f;if(0==S)d.SetEndState(a),d.SetPropertyKeyframeReached(o),d.SetUsed(),d.SetValue(d.GetValue()+t);else{if(S<0)return;const C=h.GetInterpolatedValue(S);d.SetEndState(a),d.SetPropertyKeyframeReached(o),d.SetUsed(),d.SetValue(d.GetValue()+(t-C))}}}else l._SetterAbsolute(t,o,a);break}}}AfterChangeProperty(){const e=this._numericInterpolationAdapter,t=this._numericInterpolationAdapter.GetPropertyTrack();switch(t.GetResultMode()){case"relative":break;case"absolute":if(t.HasAbsoluteValueObject()){const s=t.GetAbsoluteValueObject();s.GetUsed()&&e._SetterAbsolute(s.GetValue(),s.GetPropertyKeyframeReached(),s.GetEndState())}}}_MaybeEnsureValue(e,t,s,i,r,n){const a=this._numericInterpolationAdapter;i||(t&&e===t.GetTime()?a._AddDelta(t.GetValueWithResultMode(),t,s):s&&e===s.GetTime()?a._AddDelta(s.GetValueWithResultMode(),t,s):n-r==0&&a._AddDelta(t.GetValueWithResultMode(),t,s))}}C33.PropertyTrackState.PropertyInterpolationAdapter.NumericInterpolationAdapterForTimeline=NumericInterpolationAdapterForTimeline}{const C33=self.C3;class NumericInterpolationAdapterForTween{constructor(e){this._numericInterpolationAdapter=e}Release(){this._numericInterpolationAdapter=null}GetType(){return 1}SetInitialState(){const e=this._numericInterpolationAdapter;return e.SetFirstAbsoluteUpdate(!0),this._GetAbsoluteInitialValue(e._FirstKeyframeGetter())}SetResumeState(){const e=this._numericInterpolationAdapter;if(e._FirstKeyframeGetter()!==e._CurrentKeyframeGetter())return e.SetFirstAbsoluteUpdate(!0),this._GetAbsoluteInitialValue(e._CurrentKeyframeGetter())}MayNeedBeforeAndAfterInterpolate(){return!1}BeforeChangeProperty(){}ChangeProperty(e,t,s,i,r,n,a,o){const l=this._numericInterpolationAdapter,h=l.GetLastValue();switch(l.GetPropertyTrack().GetResultMode()){case"relative":l._Setter(t-h,s,i),n&&this._MaybeEnsureValue(e,s,i,r,h,t,!1,a);break;case"absolute":l.GetFirstAbsoluteUpdate()?(l.SetFirstAbsoluteUpdate(!1),l._Setter(h,s,i)):0===e&&0===l.GetPropertyTrack().GetTimeline().GetTotalTime()?l._SetterAbsolute(t,!0,!1):(l._Setter(t-h,s,i),n&&this._MaybeEnsureValue(e,s,i,r,h,t,this._ForceEndValue(),a))}l.SetLastValue(t)}AfterChangeProperty(){}_GetAbsoluteInitialValue(e){const t=this._numericInterpolationAdapter;return e-t.GetCurrentState()}_ForceEndValue(){let e=this._numericInterpolationAdapter,t=e.GetWorldInfo().GetInstance(),s=e.GetPropertyTrack().GetRuntime(),i=s.GetTimelineManager(),r=0;for(const n of i.GetPlayingTimelines())0===n.GetType()?n.HasTrackInstance(t)&&r++:1===n.GetType()&&n.GetInstance()===t&&r++;return r<=1}_MaybeEnsureValue(e,t,s,i,r,n,a,o){const l=this._numericInterpolationAdapter;i?t&&e===t.GetTime()?l._AddDelta(t.GetValueWithResultMode(),t,s,a,o):s&&e===s.GetTime()?l._AddDelta(s.GetValueWithResultMode(),t,s,a,o):s||l._AddDelta(t.GetValueWithResultMode(),t,s,a,o):t&&e===t.GetTime()?l._AddDelta(t.GetValueWithResultMode(),t,s,a,o):s&&e===s.GetTime()?l._AddDelta(s.GetValueWithResultMode(),t,s,a,o):n-r==0&&l._AddDelta(t.GetValueWithResultMode(),t,s,a,o)}}C33.PropertyTrackState.PropertyInterpolationAdapter.NumericInterpolationAdapterForTween=NumericInterpolationAdapterForTween}{const C33=self.C3,Ease=self.Ease;C33.PropertyTrackState.NumericTypeAdapter=class{constructor(){}static WillChange(e,t,s,i){let r;switch(i){case"behavior":r=t.GetPropertyValueByIndex(e);break;case"effect":r=t[e];break;case"instance-variable":r=t.GetInstanceVariableValue(e);break;case"plugin":r=t.GetPropertyValueByIndex(e)}return r!==s}static Interpolate(n,a,o,l){if(!o){let e=l.GetPropertyTrackDataItem(),t=l.GetPropertyTrackData();return(e=t.GetLastPropertyKeyframeDataItem(e)).GetValueWithResultMode()}let h=l.GetInterpolationMode();if("default"===h&&(h="continuous"),"discrete"===(h="combo"===l.GetPropertyType()?"discrete":h))return a.GetValueWithResultMode();if("continuous"===h||"step"===h){const c=l.GetTimeline().GetStep();if("step"===h&&0!==c){const g=1/c;n=Math.floor(n*g)/g}const u=a.GetValueWithResultMode(),_=o.GetValueWithResultMode(),d=a.GetAddOn("cubic-bezier"),p=o.GetAddOn("cubic-bezier"),m=d&&d.GetStartEnable()&&p&&p.GetEndEnable();if(!m&&u===_)return u;let e=a.GetTime(),t=o.GetTime(),s=("step"===h&&0!==c&&(n=C33.clamp(n,e,t)),C33.normalize(n,e,t)),i=a.GetEase(),r;if(m){const f=t-e;r=Ease.GetRuntimeEase(i)(f*s,0,1,f),r=Ease.GetRuntimeEase("cubicbezier")(r,u,u+d.GetStartAnchor(),_+p.GetEndAnchor(),_)}else r=Ease.GetRuntimeEase(i)((t-e)*s,u,_-u,t-e);return"integer"===l.GetPropertyType()?Math.floor(r):r}}}}{const C33=self.C3;C33.PropertyTrackState.AngleTypeAdapter=class{constructor(){}static WillChange(e,t,s,i){let r;switch(i){case"behavior":r=t.GetPropertyValueByIndex(e);break;case"effect":r=t[e];break;case"instance-variable":r=t.GetInstanceVariableValue(e);break;case"plugin":r=t.GetPropertyValueByIndex(e)}return r!==s}static Interpolate(e,t,s,i){if(!s){let e=i.GetPropertyTrackDataItem(),t=i.GetPropertyTrackData();return(e=t.GetLastPropertyKeyframeDataItem(e)).GetValueWithResultMode()}let r=i.GetInterpolationMode();if("default"===r&&(r="continuous"),"discrete"===(r="combo"===i.GetPropertyType()?"discrete":r))return t.GetValueWithResultMode();if("continuous"===r||"step"===r){const n=i.GetTimeline().GetStep();if("step"===r&&0!==n){const u=1/n;e=Math.floor(e*u)/u}const a=t.GetTime(),o=s.GetTime(),l=t.GetValueWithResultMode(),h=s.GetValueWithResultMode(),c=("step"===r&&0!==n&&(e=C33.clamp(e,a,o)),t.GetAddOn("angle"));if(!c){if(l===h)return l;const _=C33.normalize(e,a,o),d=self.Ease.GetRuntimeEase(t.GetEase());return C33.angleLerp(l,h,d(_,0,1,1))}{const p=c.GetRevolutions();if(l===h&&0===p)return l;const m=C33.normalize(e,a,o),g=self.Ease.GetRuntimeEase(t.GetEase()),f=g(m,0,1,1);switch(c.GetDirection()){case"closest":return C33.angleLerp(l,h,f,p);case"clockwise":return C33.angleLerpClockwise(l,h,f,p);case"anti-clockwise":return C33.angleLerpAntiClockwise(l,h,f,p)}}}}}}{const C33=self.C3;C33.PropertyTrackState.BooleanTypeAdapter=class{constructor(){}static WillChange(e,t,s,i){let r;switch(i){case"behavior":r=t.GetPropertyValueByIndex(e);break;case"effect":r=t[e];break;case"instance-variable":r=t.GetInstanceVariableValue(e);break;case"plugin":r=t.GetPropertyValueByIndex(e)}return!!r!=!!s}static Interpolate(e,t,s,i){if(s)return t.GetValueWithResultMode()?1:0;{let e=i.GetPropertyTrackDataItem(),t=i.GetPropertyTrackData();return(e=t.GetLastPropertyKeyframeDataItem(e)).GetValueWithResultMode()?1:0}}}}{const C33=self.C3,TEMP_COLOR_ARRAY=[0,0,0],TEMP_COLOR_ARRAY_2=[0,0,0],TEMP_COLOR_ARRAY_3=[0,0,0];C33.PropertyTrackState.ColorTypeAdapter=class{constructor(){}static WillChange(e,t,s,i){let r;switch(i){case"behavior":r=t.GetPropertyValueByIndex(e);break;case"effect":r=t[e];break;case"instance-variable":r=t.GetInstanceVariableValue(e);break;case"plugin":r=t.GetPropertyValueByIndex(e)}return Array.isArray(s)?(TEMP_COLOR_ARRAY[0]=s[0],TEMP_COLOR_ARRAY[1]=s[1],TEMP_COLOR_ARRAY[2]=s[2]):(TEMP_COLOR_ARRAY_3.parseCommaSeparatedRgb(s),TEMP_COLOR_ARRAY[0]=Math.floor(255*TEMP_COLOR_ARRAY_3.getR()),TEMP_COLOR_ARRAY[1]=Math.floor(255*TEMP_COLOR_ARRAY_3.getG()),TEMP_COLOR_ARRAY[2]=Math.floor(255*TEMP_COLOR_ARRAY_3.getB())),Array.isArray(r)?(TEMP_COLOR_ARRAY_2[0]=r[0],TEMP_COLOR_ARRAY_2[1]=r[1],TEMP_COLOR_ARRAY_2[2]=r[2]):(TEMP_COLOR_ARRAY_3.parseCommaSeparatedRgb(r),TEMP_COLOR_ARRAY_2[0]=Math.floor(255*TEMP_COLOR_ARRAY_3.getR()),TEMP_COLOR_ARRAY_2[1]=Math.floor(255*TEMP_COLOR_ARRAY_3.getG()),TEMP_COLOR_ARRAY_2[2]=Math.floor(255*TEMP_COLOR_ARRAY_3.getB())),TEMP_COLOR_ARRAY[0]!==TEMP_COLOR_ARRAY_2[0]||TEMP_COLOR_ARRAY[1]!==TEMP_COLOR_ARRAY_2[1]||TEMP_COLOR_ARRAY[2]!==TEMP_COLOR_ARRAY_2[2]}static Interpolate(e,t,s,i){if(!s){let e=i.GetPropertyTrackDataItem(),t=i.GetPropertyTrackData(),s=(e=t.GetLastPropertyKeyframeDataItem(e)).GetValueWithResultMode();return TEMP_COLOR_ARRAY[0]=s[0],TEMP_COLOR_ARRAY[1]=s[1],TEMP_COLOR_ARRAY[2]=s[2],TEMP_COLOR_ARRAY}let r=i.GetInterpolationMode();if("discrete"===(r="default"===r?"continuous":r)){const n=t.GetValueWithResultMode();return TEMP_COLOR_ARRAY[0]=n[0],TEMP_COLOR_ARRAY[1]=n[1],TEMP_COLOR_ARRAY[2]=n[2],TEMP_COLOR_ARRAY}if("continuous"===r||"step"===r){const a=i.GetTimeline().GetStep();if("step"===r&&0!==a){const I=1/a;e=Math.floor(e*I)/I}const o=t.GetTime(),l=s.GetTime(),h=t.GetValueWithResultMode(),c=s.GetValueWithResultMode(),u=("step"===r&&0!==a&&(e=C33.clamp(e,o,l)),C33.normalize(e,o,l)),_=t.GetEase(),d=h[0],p=h[1],m=h[2],g=c[0],f=c[1],S=c[2],C=self.Ease.GetRuntimeEase(_),y=l-o,G=y*u;return TEMP_COLOR_ARRAY[0]=d===g?d:C(G,d,g-d,y),TEMP_COLOR_ARRAY[1]=p===f?p:C(G,p,f-p,y),TEMP_COLOR_ARRAY[2]=m===S?m:C(G,m,S-m,y),TEMP_COLOR_ARRAY}}}}{const C33=self.C3;C33.PropertyTrackState.TextTypeAdapter=class{constructor(){}static WillChange(e,t,s,i){let r;switch(i){case"behavior":r=t.GetPropertyValueByIndex(e);break;case"effect":r=t[e];break;case"instance-variable":r=t.GetInstanceVariableValue(e);break;case"plugin":r=t.GetPropertyValueByIndex(e)}return r!==s}static Interpolate(e,t,s,i){if(s)return t.GetValueWithResultMode();{let e=i.GetPropertyTrackDataItem(),t=i.GetPropertyTrackData();return(e=t.GetLastPropertyKeyframeDataItem(e)).GetValueWithResultMode()}}}}{const C33=self.C3;C33.TimelineDataManager=class{constructor(){this._timelineDataItems=new Map}Release(){for(const e of this._timelineDataItems.values())e.Release();this._timelineDataItems.clear(),this._timelineDataItems=null}Add(e){const t=new C33.TimelineDataItem(e),s=t.GetName();this._timelineDataItems.set(s,t)}Get(e){return this._timelineDataItems.get(e)}GetNameId(){return 0}static _CreateDataItems(e,t,s,i){if(t)for(const r of t)C33.TimelineDataManager._CreateDataItem("create",r,e,s,i)}static _CreateDataItemsIncludingDisabled(e,t,s,i){if(t)for(const r of t)C33.TimelineDataManager._CreateDataItem("create-including-disabled",r,e,s,i)}static _LoadDataItemsFromJson(s,e,t,i){s.length?e.forEach((e,t)=>{s[t]._LoadFromJson(e)}):e.forEach(e=>{C33.TimelineDataManager._CreateDataItem("load",e,s,t,i)})}static _CreateDataItem(e,t,s,i,r){let n;if("function"==typeof i)switch(e){case"load":n=new i(null,r);break;case"create":case"create-including-disabled":n=new i(t,r)}else if("object"==typeof i){const a=i.prop,o=t[a],l=i.map.get(o);switch(e){case"load":n=new l(null,r);break;case"create":case"create-including-disabled":n=new l(t,r)}}switch(e){case"load":n._LoadFromJson(t),s.push(n);break;case"create":if("function"==typeof n.GetEnable&&!n.GetEnable())return n.Release();s.push(n);break;case"create-including-disabled":s.push(n)}}}}{const C33=self.C3,NAME=0,TOTAL_TIME=1,STEP=2,INTERPOLATION_MODE=3,RESULT_MODE=4,TRACKS=5,LOOP=6,PING_PONG=7,REPEAT_COUNT=8,START_ON_LAYOUT=9,TRANSFORM_WITH_SCENE_GRAPH=10,USE_SYSTEM_TIMESCALE=11;C33.TimelineDataItem=class{constructor(e){this._name="",this._totalTime=NaN,this._step=0,this._interpolationMode="default",this._resultMode="default",this._loop=!1,this._pingPong=!1,this._repeatCount=1,this._trackData=null,this._startOnLayout="",this._transformWithSceneGraph=!1,this._useSystemTimescale=!0,e&&(this._name=e[NAME],this._totalTime=e[TOTAL_TIME],this._step=e[STEP],this._interpolationMode=e[INTERPOLATION_MODE],this._resultMode=e[RESULT_MODE],this._loop=!!e[LOOP],this._pingPong=!!e[PING_PONG],this._repeatCount=e[REPEAT_COUNT],this._startOnLayout=e[START_ON_LAYOUT],this._transformWithSceneGraph=!!e[TRANSFORM_WITH_SCENE_GRAPH],this._useSystemTimescale=!!e[USE_SYSTEM_TIMESCALE],this._trackData=new C33.TrackData(e[TRACKS],this))}Release(){this._trackData.Release(),this._trackData=null}GetTrackData(){return this._trackData||(this._trackData=new C33.TrackData(null,this)),this._trackData}GetName(){return this._name}SetName(e){this._name=e}GetTotalTime(){return this._totalTime}SetTotalTime(e){this._totalTime=e}GetStep(){return this._step}SetStep(e){this._step=e}GetInterpolationMode(){return this._interpolationMode}SetInterpolationMode(e){this._interpolationMode=e}GetResultMode(){return this._resultMode}SetResultMode(e){this._resultMode=e}GetLoop(){return this._loop}SetLoop(e){this._loop=e}GetPingPong(){return this._pingPong}SetPingPong(e){this._pingPong=e}GetRepeatCount(){return this._repeatCount}SetRepeatCount(e){this._repeatCount=e}GetStartOnLayout(){return this._startOnLayout}GetTransformWithSceneGraph(){return this._transformWithSceneGraph}GetUseSystemTimescale(){return this._useSystemTimescale}_SaveToJson(){return{trackDataJson:this._trackData._SaveToJson(),name:this._name,totalTime:this._totalTime,step:this._step,interpolationMode:this._interpolationMode,resultMode:this._resultMode,loop:this._loop,pingPong:this._pingPong,repeatCount:this._repeatCount,startOnLayout:this._startOnLayout,transformWithSceneGraph:!!this._transformWithSceneGraph,useSystemTimescale:this._useSystemTimescale}}_LoadFromJson(e){e&&(this.GetTrackData()._LoadFromJson(e.trackDataJson),this._name=e.name,this._totalTime=e.totalTime,this._step=e.step,this._interpolationMode=e.interpolationMode,this._resultMode=e.resultMode,this._loop=e.loop,this._pingPong=e.pingPong,this._repeatCount=e.repeatCount,this._startOnLayout=e.startOnLayout,this._transformWithSceneGraph=!!e.transformWithSceneGraph,this._useSystemTimescale=!!e.useSystemTimescale)}}}{const C33=self.C3,WI_DATA=0,OC_INDEX=1,WI_UID=2,INTERPOLATION_MODE=1,RESULT_MODE=2,ENABLED=3,KEYFRAMES=4,PROPERTY_TRACKS=5,ID=6,NESTED_DATA=7,START_OFFSET=0,LOCAL_TOTAL_TIME=1,WI_ADDITIONAL_DATA=8,ORIGINAL_WIDTH=0,ORIGINAL_HEIGHT=1,TRACK_TYPE=9,TRACK_NAME=10;class TrackDataItem{constructor(e,t){this._trackData=t,this._instanceData=null,this._additionalInstanceData=null,this._instanceUid=NaN,this._objectClassIndex=NaN,this._interpolationMode="default",this._resultMode="default",this._enabled=!1,this._keyframeData=null,this._propertyTrackData=null,this._id="",this._nestedData=null,this._startOffset=0,this._localTotalTime=this._trackData.GetTimelineDataItem().GetTotalTime(),this._type=0,this._name="",e&&(e[WI_DATA]&&(this._instanceData=e[WI_DATA],this._instanceUid=e[WI_DATA][WI_UID],this._objectClassIndex=e[WI_DATA][OC_INDEX]),this._interpolationMode=e[INTERPOLATION_MODE],this._resultMode=e[RESULT_MODE],this._enabled=!!e[ENABLED],e[ID]&&(this._id=e[ID]),e[NESTED_DATA]&&(this._nestedData=e[NESTED_DATA],this._startOffset=e[NESTED_DATA][START_OFFSET],this._localTotalTime=e[NESTED_DATA][LOCAL_TOTAL_TIME]),e[WI_ADDITIONAL_DATA]&&(this._additionalInstanceData=e[WI_ADDITIONAL_DATA]),e[WI_ADDITIONAL_DATA]&&(this._additionalInstanceData=e[WI_ADDITIONAL_DATA]),e[TRACK_TYPE]&&(this._type=e[TRACK_TYPE]),e[TRACK_NAME]&&(this._name=e[TRACK_NAME]),this._keyframeData=new C33.KeyframeData(e[KEYFRAMES],this),this._propertyTrackData=new C33.PropertyTrackData(e[PROPERTY_TRACKS],this))}Release(){this._instanceData=null,this._trackData=null,this._keyframeData&&(this._keyframeData.Release(),this._keyframeData=null),this._propertyTrackData&&(this._propertyTrackData.Release(),this._propertyTrackData=null),this._nestedData=null}GetTrackData(){return this._trackData}GetKeyframeData(){return this._keyframeData||(this._keyframeData=new C33.KeyframeData(null,this)),this._keyframeData}GetPropertyTrackData(){return this._propertyTrackData||(this._propertyTrackData=new C33.PropertyTrackData(null,this)),this._propertyTrackData}GetInstanceData(){return this._instanceData}GetObjectClassIndex(){return this._objectClassIndex}SetObjectClassIndex(e){this._objectClassIndex=e}GetInstanceUID(){return this._instanceUid}SetInstanceUID(e){this._instanceUid=e}GetInterpolationMode(){return this._interpolationMode}SetInterpolationMode(e){this._interpolationMode=e}GetResultMode(){return this._resultMode}SetResultMode(e){this._resultMode=e}GetEnable(){return this._enabled}SetEnable(e){this._enabled=!!e}GetId(){return this._id}GetStartOffset(){return this._startOffset}GetLocalTotalTime(){return this._localTotalTime}SetLocalTotalTime(e){this._localTotalTime=e}GetOriginalWidth(){return this._additionalInstanceData[ORIGINAL_WIDTH]}SetOriginalWidth(e){this._additionalInstanceData||(this._additionalInstanceData=[]),this._additionalInstanceData[ORIGINAL_WIDTH]=e}GetOriginalHeight(){return this._additionalInstanceData||(this._additionalInstanceData=[]),this._additionalInstanceData[ORIGINAL_HEIGHT]}SetOriginalHeight(e){this._additionalInstanceData||(this._additionalInstanceData=[]),this._additionalInstanceData[ORIGINAL_HEIGHT]=e}GetType(){return this._type}GetName(){return this._name}_SaveToJson(){return{keyframeDataJson:this._keyframeData._SaveToJson(),propertyTrackDataJson:this._propertyTrackData._SaveToJson(),instanceData:this._instanceData,additionalInstanceData:this._additionalInstanceData,instanceUid:this._instanceUid,objectClassIndex:this._objectClassIndex,interpolationMode:this._interpolationMode,resultMode:this._resultMode,enabled:this._enabled,id:this._id,nestedData:this._nestedData,type:this._type,name:this._name}}_LoadFromJson(e){e&&(this._instanceData=e.instanceData,this._instanceUid=e.instanceUid,this._objectClassIndex=e.objectClassIndex,this._interpolationMode=e.interpolationMode,this._resultMode=e.resultMode,this._enabled=e.enabled,this._id=e.id,this._type=e.type||0,this._name=e.name||"",this._localTotalTime=this._trackData.GetTimelineDataItem().GetTotalTime(),e.nestedData&&(this._nestedData=e.nestedData,this._startOffset=this._nestedData[START_OFFSET],this._localTotalTime=this._nestedData[LOCAL_TOTAL_TIME]),e.additionalInstanceData&&(this._additionalInstanceData=e.additionalInstanceData),this.GetKeyframeData()._LoadFromJson(e.keyframeDataJson),this.GetPropertyTrackData()._LoadFromJson(e.propertyTrackDataJson))}}C33.TrackData=class{constructor(e,t){this._timelineDataItem=t,this._trackDataItems=[],C33.TimelineDataManager._CreateDataItems(this._trackDataItems,e,TrackDataItem,this)}Release(){this._timelineDataItem=null;for(const e of this._trackDataItems)e.Release();C33.clearArray(this._trackDataItems),this._trackDataItems=null}GetTimelineDataItem(){return this._timelineDataItem}AddEmptyTrackDataItem(){const e=new TrackDataItem(null,this);return this._trackDataItems.push(e),e}GetFirstKeyframeDataItem(e){return e.GetKeyframeData().GetKeyframeDataItemArray()[0]}GetLastKeyframeDataItem(e){const t=e.GetKeyframeData().GetKeyframeDataItemArray();return t.at(-1)}GetKeyFrameDataItemAtTime(t,e){const s=e.GetKeyframeData().GetKeyframeDataItemArray(),i=s.length;for(let e=0;e<i;e++){const r=s[e];if(r.GetTime()===t)return r}}GetFirstKeyFrameDataItemHigherThan(t,e){const s=e.GetKeyframeData().GetKeyframeDataItemArray(),i=s.length;for(let e=0;e<i;e++){const r=s[e];if(r.GetTime()>t)return r}}GetFirstKeyFrameDataItemHigherOrEqualThan(t,e){const s=e.GetKeyframeData().GetKeyframeDataItemArray(),i=s.length;for(let e=0;e<i;e++){const r=s[e];if(r.GetTime()>=t)return r}}GetFirstKeyFrameDataItemLowerOrEqualThan(t,e){const s=e.GetKeyframeData().GetKeyframeDataItemArray();for(let e=s.length-1;0<=e;e--){const i=s[e];if(i.GetTime()<=t)return i}}*trackDataItems(){for(const e of this._trackDataItems)yield e}_SaveToJson(){return{trackDataItemsJson:this._trackDataItems.map(e=>e._SaveToJson())}}_LoadFromJson(e){e&&C33.TimelineDataManager._LoadDataItemsFromJson(this._trackDataItems,e.trackDataItemsJson,TrackDataItem,this)}}}{const C33=self.C3,SOURCE_DATA=0,SOURCE=0,PROPERTY=1,TYPE=2,MIN=3,MAX=4,INTERPOLATION_MODE=5,RESULT_MODE=6,ENABLED=7,PROPERTY_KEYFRAMES=8,CAN_HAVE_PROPERTY_KEYFRAMES=9;class PropertyTrackDataItem{constructor(e,t){this._propertyTrackData=t,this._sourceAdapterId="",this._sourceAdapterArguments=null,this._property=null,this._type=null,this._min=NaN,this._max=NaN,this._interpolationMode="default",this._resultMode="default",this._enabled=!1,this._propertyKeyframeData=null,this._canHavePropertyKeyframes=!0,e&&(this._sourceAdapterId=e[SOURCE_DATA][SOURCE],this._sourceAdapterArguments=e[SOURCE_DATA].slice(1),this._property=e[PROPERTY],this._type=e[TYPE],this._min=e[MIN],this._max=e[MAX],this._interpolationMode=e[INTERPOLATION_MODE],this._resultMode=e[RESULT_MODE],this._enabled=!!e[ENABLED],this._propertyKeyframeData=new C33.PropertyKeyframeData(e[PROPERTY_KEYFRAMES],this),this._canHavePropertyKeyframes=e[CAN_HAVE_PROPERTY_KEYFRAMES])}Release(){this._propertyKeyframeData.Release(),this._propertyKeyframeData=null,this._propertyTrackData=null,this._sourceAdapterArguments=null}GetPropertyTrackData(){return this._propertyTrackData}GetPropertyKeyframeData(){return this._propertyKeyframeData||(this._propertyKeyframeData=new C33.PropertyKeyframeData(null,this)),this._propertyKeyframeData}GetSourceAdapterId(){return this._sourceAdapterId}SetSourceAdapterId(e){this._sourceAdapterId=e}GetSourceAdapterArguments(){return this._sourceAdapterArguments}SetSourceAdapterArguments(e){this._sourceAdapterArguments=e}GetProperty(){return this._property}SetProperty(e){this._property=e}GetType(){return this._type}SetType(e){this._type=e}GetMin(){return this._min}SetMin(e){this._min=e}GetMax(){return this._max}SetMax(e){this._max=e}GetInterpolationMode(){return this._interpolationMode}SetInterpolationMode(e){this._interpolationMode=e}GetResultMode(){return this._resultMode}SetResultMode(e){this._resultMode=e}GetEnable(){return this._enabled}SetEnable(e){this._enabled=!!e}CanHavePropertyKeyframes(){return!!this._canHavePropertyKeyframes}_SaveToJson(){return{propertyKeyframeDataJson:this._propertyKeyframeData._SaveToJson(),sourceAdapterId:this._sourceAdapterId,sourceAdapterArguments:this._sourceAdapterArguments,property:this._property,type:this._type,min:this._min,max:this._max,interpolationMode:this._interpolationMode,resultMode:this._resultMode,enabled:this._enabled,canHavePropertyKeyframes:this._canHavePropertyKeyframes}}_LoadFromJson(e){e&&(this._sourceAdapterId=e.sourceAdapterId,this._sourceAdapterArguments=e.sourceAdapterArguments,this._property=e.property,this._type=e.type,this._min=e.min,this._max=e.max,this._interpolationMode=e.interpolationMode,this._resultMode=e.resultMode,this._enabled=e.enabled,this._canHavePropertyKeyframes=e.canHavePropertyKeyframes,this.GetPropertyKeyframeData()._LoadFromJson(e.propertyKeyframeDataJson))}}C33.PropertyTrackData=class{constructor(e,t){this._trackDataItem=t,this._propertyTrackDataItems=[],C33.TimelineDataManager._CreateDataItems(this._propertyTrackDataItems,e,PropertyTrackDataItem,this)}Release(){this._trackDataItem=null;for(const e of this._propertyTrackDataItems)e.Release();C33.clearArray(this._propertyTrackDataItems),this._propertyTrackDataItems=null}GetTrackDataItem(){return this._trackDataItem}AddEmptyPropertyTrackDataItem(){const e=new PropertyTrackDataItem(null,this);return this._propertyTrackDataItems.push(e),e}GetFirstPropertyKeyframeDataItem(e){const t=e.GetPropertyKeyframeData();return t.GetPropertyKeyframeDataItemArray()[0]}GetLastPropertyKeyframeDataItem(e){const t=e.GetPropertyKeyframeData(),s=t.GetPropertyKeyframeDataItemArray();return s.at(-1)}GetPropertyKeyFrameDataItemAtTime(t,e){const s=e.GetPropertyKeyframeData(),i=s.GetPropertyKeyframeDataItemArray(),r=i.length;for(let e=0;e<r;e++){const n=i[e];if(n.GetTime()===t)return n}}GetFirstPropertyKeyFrameDataItemHigherThan(t,e){const s=e.GetPropertyKeyframeData(),i=s.GetPropertyKeyframeDataItemArray(),r=i.length;for(let e=0;e<r;e++){const n=i[e];if(n.GetTime()>t)return n}}GetFirstPropertyKeyFrameDataItemHigherOrEqualThan(t,e){const s=e.GetPropertyKeyframeData(),i=s.GetPropertyKeyframeDataItemArray(),r=i.length;for(let e=0;e<r;e++){const n=i[e];if(n.GetTime()>=t)return n}}GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(t,e){const s=e.GetPropertyKeyframeData(),i=s.GetPropertyKeyframeDataItemArray();for(let e=i.length-1;0<=e;e--){const r=i[e];if(r.GetTime()<=t)return r}}*propertyTrackDataItems(){for(const e of this._propertyTrackDataItems)yield e}_SaveToJson(){return{propertyTrackDataItemsJson:this._propertyTrackDataItems.map(e=>e._SaveToJson())}}_LoadFromJson(e){e&&C33.TimelineDataManager._LoadDataItemsFromJson(this._propertyTrackDataItems,e.propertyTrackDataItemsJson,PropertyTrackDataItem,this)}}}{const C33=self.C3,TIME=0,EASE=1,ENABLE=2,TAGS=3;class KeyframeDataItem{constructor(e,t){if(this._keyframeData=t,this._time=-1,this._ease="noease",this._enable=!1,this._tags=null,this._lowerTags=null,e){this._time=e[TIME],this._ease=e[EASE],this._enable=!!e[ENABLE];const s=e[TAGS];this._tags=s?s.split(" "):[],this._lowerTags=new Set(this._tags.map(e=>e.toLowerCase())),this._next=null}}Release(){this._keyframeData=null,C33.clearArray(this._tags),this._tags=null,this._lowerTags.clear(),this._lowerTags=null,this._next=null}GetKeyframeData(){return this._keyframeData}GetNext(){return this._next}SetNext(e){this._next=e}GetTime(){return this._time}SetTime(e){this._time=e,this._keyframeData._LinkKeyframeDataItems()}GetEase(){return this._ease}SetEase(e){this._ease=e}GetEnable(){return this._enable}SetEnable(e){this._enable=!!e}GetTags(){return this._tags}SetTags(e){this._tags=e?e.split(" "):[],this._lowerTags=new Set(this._tags.map(e=>e.toLowerCase()))}GetLowerTags(){return this._lowerTags}HasTag(e){return this._lowerTags.has(e.toLowerCase())}_SaveToJson(){return{time:this._time,ease:this._ease,enable:this._enable,tags:this._tags}}_LoadFromJson(e){e&&(this._time=e.time,this._ease=e.ease,this._enable=e.enable,this._tags=e.tags,this._lowerTags=new Set(this._tags.map(e=>e.toLowerCase())))}}C33.KeyframeData=class{constructor(e,t){this._trackDataItem=t,this._keyframeDataItems=[],C33.TimelineDataManager._CreateDataItems(this._keyframeDataItems,e,KeyframeDataItem,this),this._LinkKeyframeDataItems()}Release(){this._trackDataItem=null;for(const e of this._keyframeDataItems)e.Release();C33.clearArray(this._keyframeDataItems),this._keyframeDataItems=null}_LinkKeyframeDataItems(){this._keyframeDataItems.sort((e,t)=>e.GetTime()-t.GetTime());for(let e=0;e<this._keyframeDataItems.length;e++){const t=this._keyframeDataItems[e];t.SetNext(this._keyframeDataItems[e+1])}}GetTrackDataItem(){return this._trackDataItem}GetKeyframeDataItemCount(){return this._keyframeDataItems.length}GetKeyframeDataItemArray(){return this._keyframeDataItems}AddEmptyKeyframeDataItem(){const e=new KeyframeDataItem(null,this);return this._keyframeDataItems.push(e),this._LinkKeyframeDataItems(),e}DeleteKeyframeDataItems(e){for(const t of this._keyframeDataItems)if(e(t)){const s=this._keyframeDataItems.indexOf(t);-1!==s&&(t.Release(),this._keyframeDataItems.splice(s,1))}this.SortKeyframeDataItems(),this._LinkKeyframeDataItems()}SortKeyframeDataItems(){this._keyframeDataItems.sort((e,t)=>e.GetTime()-t.GetTime())}GetKeyframeDataItemIndex(e){return this._keyframeDataItems.indexOf(e)}GetKeyframeDataItemFromIndex(e){return this._keyframeDataItems[e]}*keyframeDataItems(){for(const e of this._keyframeDataItems)yield e}*keyframeDataItemsReverse(){for(let e=this._keyframeDataItems.length-1;0<=e;e--)yield this._keyframeDataItems[e]}_SaveToJson(){return{keyframeDataItemsJson:this._keyframeDataItems.map(e=>e._SaveToJson())}}_LoadFromJson(e){e&&(C33.TimelineDataManager._LoadDataItemsFromJson(this._keyframeDataItems,e.keyframeDataItemsJson,KeyframeDataItem,this),this._LinkKeyframeDataItems())}}}{const C33=self.C3,VALUE_DATA=0,VALUE_DATA_VALUE=0,VALUE_DATA_ABSOLUTE_VALUE=1,VALUE_DATA_TYPE=2,TIME=1,EASE=2,ENABLE=3,ADDONS=4,PATH_MODE=5;class PropertyKeyframeDataItem{constructor(e,t){this._propertyKeyframeData=t,this._value=null,this._aValue=null,this._type="",this._time=NaN,this._ease="noease",this._enable=!1,this._addonData=null,this._addonInstance=void 0,this._pathMode="line",e&&(this._value=e[VALUE_DATA][VALUE_DATA_VALUE],this._aValue=e[VALUE_DATA][VALUE_DATA_ABSOLUTE_VALUE],this._type=e[VALUE_DATA][VALUE_DATA_TYPE],this._time=e[TIME],this._ease=e[EASE],this._enable=!!e[ENABLE],this._pathMode=e[PATH_MODE],this._addonData=null,e[ADDONS]&&(this._addonData=new C33.AddonData(e[ADDONS],this)),this._next=null,this._prev=null)}Release(){this._propertyKeyframeData=null,this._addonData&&(this._addonData.Release(),this._addonData=null),this._next=null,this._prev=null}GetAddonData(){return this._addonData}SetNext(e){this._next=e}GetNext(){return this._next}SetPrevious(e){this._prev=e}GetPrevious(){return this._prev}GetValue(){return this._value}SetValue(e){"color"===this._type&&C33.IsFiniteNumber(e)?(this._value[0]=C33.GetRValue(e),this._value[1]=C33.GetGValue(e),this._value[2]=C33.GetBValue(e)):this._value=e}GetAbsoluteValue(){return this._aValue}SetAbsoluteValue(e){"color"===this._type&&C33.IsFiniteNumber(e)?(this._aValue[0]=C33.GetRValue(e),this._aValue[1]=C33.GetGValue(e),this._aValue[2]=C33.GetBValue(e)):this._aValue=e}GetValueWithResultMode(){const e=this._propertyKeyframeData.GetPropertyTrackDataItem().GetResultMode();return"relative"===e?this.GetValue():"absolute"===e?this.GetAbsoluteValue():void 0}GetType(){return this._type}SetType(e){this._type=e}GetTime(){return this._time}SetTime(e){this._time=e,this._propertyKeyframeData._LinkPropertyKeyframeDataItems()}GetEase(){return this._ease}SetEase(e){this._ease=e}GetEnable(){return this._enable}SetEnable(e){this._enable=!!e}GetPathMode(){return this._pathMode}GetAddOn(t){if(this._addonData){if(!this._addonInstance&&null!==this._addonInstance){const s=this._addonData.GetAddDataItemArray();if(s){const i=s.length;for(let e=0;e<i;e++){const r=s[e];if(r.GetId()===t)return this._addonInstance=r,this._addonInstance}}this._addonInstance=null}return this._addonInstance}}_SaveToJson(){const e=this._addonData;return{addonDataJson:e&&e._SaveToJson(),value:this._value,aValue:this._aValue,type:this._type,time:this._time,ease:this._ease,enable:this._enable}}_LoadFromJson(e){e&&(e.addonDataJson&&this._addonData._SetFromJson(e.addonDataJson),this._value=e.value,this._aValue=e.aValue,this._type=e.type,this._time=e.time,this._ease=e.ease,this._enable=e.enable)}}C33.PropertyKeyframeData=class{constructor(e,t){this._propertyTrackDataItem=t,this._propertyKeyframeDataItems=[],this._propertyKeyframeDataItemsIncludingDisabled=[],C33.TimelineDataManager._CreateDataItems(this._propertyKeyframeDataItems,e,PropertyKeyframeDataItem,this),C33.TimelineDataManager._CreateDataItemsIncludingDisabled(this._propertyKeyframeDataItemsIncludingDisabled,e,PropertyKeyframeDataItem,this),this._LinkPropertyKeyframeDataItems()}Release(){this._propertyTrackDataItem=null;for(const e of this._propertyKeyframeDataItems)e.Release();C33.clearArray(this._propertyKeyframeDataItems),this._propertyKeyframeDataItems=null;for(const t of this._propertyKeyframeDataItemsIncludingDisabled)t.Release();C33.clearArray(this._propertyKeyframeDataItemsIncludingDisabled),this._propertyKeyframeDataItemsIncludingDisabled=null}_LinkPropertyKeyframeDataItems(){let t=this._propertyKeyframeDataItems;t.sort((e,t)=>e.GetTime()-t.GetTime());for(let e=0;e<t.length;e++){const s=t[e];e+1<t.length&&s.SetNext(t[e+1]),0<=e-1&&s.SetPrevious(t[e-1])}(t=this._propertyKeyframeDataItemsIncludingDisabled).sort((e,t)=>e.GetTime()-t.GetTime());for(let e=0;e<t.length;e++){const i=t[e];e+1<t.length&&i.SetNext(t[e+1]),0<=e-1&&i.SetPrevious(t[e-1])}}AddEmptyPropertyKeyframeDataItem(){const e=new PropertyKeyframeDataItem(null,this);return this._propertyKeyframeDataItems.push(e),this._LinkPropertyKeyframeDataItems(),e}DeletePropertyKeyframeDataItems(e){for(const t of this._propertyKeyframeDataItems)if(e(t)){const s=this._propertyKeyframeDataItems.indexOf(t);-1!==s&&(t.Release(),this._propertyKeyframeDataItems.splice(s,1))}this.SortPropertyKeyFrameDataItems(),this._LinkPropertyKeyframeDataItems()}SortPropertyKeyFrameDataItems(){this._propertyKeyframeDataItems.sort((e,t)=>e.GetTime()-t.GetTime())}GetPropertyTrackDataItem(){return this._propertyTrackDataItem}GetPropertyKeyframeDataItemCount(){return this._propertyKeyframeDataItems.length}GetLastPropertyKeyframeDataItem(){return this._propertyKeyframeDataItems[this._propertyKeyframeDataItems.length-1]}GetPropertyKeyframeDataItemArray(){return this._propertyKeyframeDataItems}GetPropertyKeyframeDataItemArrayIncludingDisabled(){return this._propertyKeyframeDataItemsIncludingDisabled}*propertyKeyframeDataItems(){for(const e of this._propertyKeyframeDataItems)yield e}*propertyKeyframeDataItemsReverse(){for(let e=this._propertyKeyframeDataItems.length-1;0<=e;e--)yield this._propertyKeyframeDataItems[e]}_SaveToJson(){const e=this._propertyKeyframeDataItems,t=this._propertyKeyframeDataItemsIncludingDisabled;return{propertyKeyframeDataItemsJson:e.map(e=>e._SaveToJson()),propertyKeyframeDataItemsIncludingDisabledJson:t.map(e=>e._SaveToJson())}}_LoadFromJson(e){e&&(C33.TimelineDataManager._LoadDataItemsFromJson(this._propertyKeyframeDataItems,e.propertyKeyframeDataItemsJson,PropertyKeyframeDataItem,this),C33.TimelineDataManager._LoadDataItemsFromJson(this._propertyKeyframeDataItemsIncludingDisabled,e.propertyKeyframeDataItemsIncludingDisabledJson,PropertyKeyframeDataItem,this),this._LinkPropertyKeyframeDataItems())}}}{const C33=self.C3,ADDON_ID=0,ADDON_DATA=1;class AddonDataItem{constructor(e,t){this._addonData=t,this._id=e[ADDON_ID],this._data=e[ADDON_DATA]}Release(){this._addonData=null,this._data=null}GetAddonData(){return this._addonData}GetId(){return this._id}_SaveToJson(){return{id:this._id,data:this._data}}_LoadFromJson(e){e&&(this._id=e.id,this._data=e.data)}}const START_ANCHOR=0,START_ENABLE=1,END_ANCHOR=2,END_ENABLE=3;class AddonDataCubicBezierItem extends AddonDataItem{constructor(e,t){super(e,t),this._startAnchor=this._data[START_ANCHOR],this._startEnable=!!this._data[START_ENABLE],this._endAnchor=this._data[END_ANCHOR],this._endEnable=!!this._data[END_ENABLE]}Release(){super.Release()}GetStartAnchor(){return this._startAnchor}GetStartEnable(){return this._startEnable}GetEndAnchor(){return this._endAnchor}GetEndEnable(){return this._endEnable}_SaveToJson(){return Object.assign(super._SaveToJson(),{startAnchor:this._startAnchor,startEnable:!!this._startEnable,endAnchor:this._endAnchor,endEnable:!!this._endEnable})}_LoadFromJson(e){e&&(super._LoadFromJson(e),this._startAnchor=e.startAnchor,this._startEnable=!!e.startEnable,this._endAnchor=e.endAnchor,this._endEnable=!!e.endEnable)}}const DIRECTION=0,REVOLUTIONS=1;class AddonDataAngleItem extends AddonDataItem{constructor(e,t){super(e,t),this._direction=this._data[DIRECTION],this._revolutions=this._data[REVOLUTIONS]}Release(){super.Release()}GetDirection(){return this._direction}GetRevolutions(){return this._revolutions}_SaveToJson(){return Object.assign(super._SaveToJson(),{direction:this._direction,revolutions:this._revolutions})}_LoadFromJson(e){e&&(super._LoadFromJson(e),this._direction=e.direction,this._revolutions=e.revolutions)}}C33.AddonData=class{constructor(e,t){this._propertyKeyframeDataItem=t,this._addonDataItems=[],C33.TimelineDataManager._CreateDataItems(this._addonDataItems,e,{prop:0,map:new Map([["cubic-bezier",AddonDataCubicBezierItem],["angle",AddonDataAngleItem]])},this)}Release(){this._propertyKeyframeDataItem=null;for(const e of this._addonDataItems)e.Release();C33.clearArray(this._addonDataItems),this._addonDataItems=null}GetPropertyKeyframeDataItem(){return this._propertyKeyframeDataItem}GetAddDataItemArray(){return this._addonDataItems}*addonDataItems(){for(const e of this._addonDataItems)yield e}_SaveToJson(){return{addonDataItemsJson:this._addonDataItems.map(e=>e._SaveToJson())}}_LoadFromJson(e){e&&C33.TimelineDataManager._LoadDataItemsFromJson(this._addonDataItems,e.addonDataItemsJson,{prop:"id",map:new Map([["cubic-bezier",AddonDataCubicBezierItem],["angle",AddonDataAngleItem]])},this)}}}{let C33=self.C3,INITIAL_VALUE_MODE_START_VALUE="start-value",INITIAL_VALUE_MODE_CURRENT_STATE="current-state",PING_PONG_BEGIN=0,PING_PONG_END=1,createdTweens=0;C33.TweenState=class extends C33.TimelineState{constructor(e,t){super("tween-"+createdTweens++,e,t),this._id="",this._destroyInstanceOnComplete=!1,this._initialValueMode=INITIAL_VALUE_MODE_START_VALUE,this._instance=null,this._on_completed_callbacks=null,this._on_started_callbacks=null,this._track=null,this._iTweenState=null}FireReleaseEvent(e){const t=C33.New(C33.Event,"tweenstatereleased");t.tweenState=this,e.dispatchEvent(t)}GetType(){return 1}CreateTrackStates(){for(const e of this._timelineDataItem.GetTrackData().trackDataItems())this._tracks.push(C33.TweenTrackState.Create(this,e));this._track=this._tracks[0]}AddTrack(){const e=this._timelineDataItem.GetTrackData().AddEmptyTrackDataItem(),t=C33.TweenTrackState.Create(this,e);return this._tracks.push(t),this._CacheTrack(),t}_CacheTrack(){this._track=this._tracks[0]}GetPropertyTrack(e){return this._track.GetPropertyTracks()[0]}SetPropertyType(e){this._propertyType=e}GetInstance(){const e=this.GetTracks();if(e&&e.length){const t=e[0];if(this._track=t){const s=t.GetInstance();return t.IsInstanceValid()?s:void 0}}}AddStartedCallback(e){this._on_started_callbacks||(this._on_started_callbacks=[]),this._on_started_callbacks.push(e)}AddCompletedCallback(e){this._on_completed_callbacks||(this._on_completed_callbacks=[]),this._on_completed_callbacks.push(e)}RemoveStartedCallback(e){if(this._on_started_callbacks){const t=this._on_started_callbacks.indexOf(e);-1!==t&&this._on_started_callbacks.splice(t,1)}}RemoveCompletedCallback(e){if(this._on_completed_callbacks){const t=this._on_completed_callbacks.indexOf(e);-1!==t&&this._on_completed_callbacks.splice(t,1)}}SetStartValue(e,t){for(const s of this._tracks)for(const i of s._propertyTracks)if(i.GetPropertyName()===t){const r=i.GetPropertyTrackData(),n=i.GetPropertyTrackDataItem(),a=r.GetFirstPropertyKeyframeDataItem(n);a.SetValue(e),a.SetAbsoluteValue(e)}}_GetPropertyTrackState(e){for(const t of this._tracks)for(const s of t._propertyTracks)if(s.GetPropertyName()===e)return s}BeforeSetEndValues(e){for(const t of e){const s=this._GetPropertyTrackState(t);this.SetStartValue(s.GetCurrentState(),t)}if(this.IsForwardPlayBack()){const i=this.GetTotalTime()-this.GetTime();this.SetTotalTime(i);for(const r of this._tracks)r.SetLocalTotalTime(i);this._SetTime(0)}else{const n=this.GetTime();this.SetTotalTime(n);for(const a of this._tracks)a.SetLocalTotalTime(n);this._SetTime(n)}this.SetInitialStateFromSetTime()}SetEndValue(e,t){const s=this._GetPropertyTrackState(t),i=s.GetPropertyTrackData(),r=s.GetPropertyTrackDataItem(),n=i.GetLastPropertyKeyframeDataItem(r);n.SetTime(this.GetTotalTime()),n.SetValue(e),n.SetAbsoluteValue(e)}SetId(e){this._id=e}GetId(){return this._id}SetInitialValueMode(e){this._initialValueMode=e}GetInitialValueMode(){return this._initialValueMode}SetDestroyInstanceOnComplete(e){this._destroyInstanceOnComplete=e}GetDestroyInstanceOnComplete(){return this._destroyInstanceOnComplete}OnStarted(){if(this._on_started_callbacks)for(const e of this._on_started_callbacks)e(this);if(!this.IsComplete())for(const t of this._tracks)t.CompareSaveStateWithCurrent()}OnCompleted(){this._completedTick=this._runtime.GetTickCount()}FinishTriggers(){if(!this._finishedTriggers&&(this._finishedTriggers=!0,this._on_completed_callbacks))for(const e of this._on_completed_callbacks)e(this)}SetTime(e){this._DeleteIntermediateKeyframes(),super.SetTime(e)}_SetTimeAndReset(e){(e=C33.IsFiniteNumber(e)?e:this.GetTotalTime())<0?this._playheadTime=0:e>=this.GetTotalTime()?this._playheadTime=this.GetTotalTime():this._playheadTime=e,this._track.SetResetState()}SetInitialState(e){if(!this.InitialStateSet()&&this.GetInitialValueMode()===INITIAL_VALUE_MODE_CURRENT_STATE)for(const t of this._tracks)t.CompareInitialStateWithCurrent();super.SetInitialState(e)}Stop(e=!1){if(super.Stop(e),!this.IsComplete())for(const t of this._tracks)t.SaveState()}Reset(e=!0,t=!1){this._DeleteIntermediateKeyframes(),super.Reset(e,t)}_DeleteIntermediateKeyframes(){for(const e of this._tracks){const t=e=>{const t=e.GetTime(),s=this.GetTotalTime();return 0!==t&&t!==s};e.DeleteKeyframes(t),e.DeletePropertyKeyframes(t)}}_OnBeforeChangeLayout(){if(!this.IsReleased()){const e=this.GetInstance();if(e&&e.GetObjectClass().IsGlobal())return!1;this._timelineManager.CompleteTimelineBeforeChangeOfLayout(this),this.ResetBeforeChangeLayout()}return!0}Tick(r,e,t){if(this._instance||(this._instance=this.GetInstance()),!this._instance||this._instance.IsDestroyed())this.Stop(!0),this.OnCompleted();else{const s=this._instance.GetTimeScale();if(0!==(r=-1!==s?t*s:r)||0!==this._lastDelta){this._lastDelta=r;const n=this._playheadTime+this._overshoot,a=r*this._playbackRate,o=n+a,l=this._timelineDataItem._totalTime;o<0?(this._playheadTime=0,this._overshoot=-o):l<=o?(this._playheadTime=l,this._overshoot=this._playheadTime-o):(this._playheadTime=o,this._overshoot=0);let e=!1,t=!1,s=this.GetLoop(),i=this.GetPingPong();s||i?s&&!i?0<this._playbackRate?this._playheadTime>=l&&(this._SetTimeAndReset(0),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenLoop),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensLoop),t=!0):this._playheadTime<=0&&(this._SetTimeAndReset(l),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenLoop),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensLoop),t=!0):!s&&i?0<this._playbackRate?this._playheadTime>=l&&(this._SetTime(l),this.SetPlaybackRate(-1*this.GetPlaybackRate()),t=!0,this._pingPongState===PING_PONG_END?this._currentRepeatCount<this.GetRepeatCount()?(this._currentRepeatCount++,this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenLoop),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensLoop),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenPingPong),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensPingPong),this._pingPongState=PING_PONG_BEGIN):(this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenPingPong),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensPingPong),e=!0):this._pingPongState===PING_PONG_BEGIN&&(this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenPingPong),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensPingPong),this._pingPongState=PING_PONG_END)):this._playheadTime<=0&&(this._SetTime(0),this.SetPlaybackRate(-1*this.GetPlaybackRate()),t=!0,this._pingPongState===PING_PONG_END?this._currentRepeatCount<this.GetRepeatCount()?(this._currentRepeatCount++,this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenLoop),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensLoop),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenPingPong),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensPingPong),this._pingPongState=PING_PONG_BEGIN):(e=!0,this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenPingPong),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensPingPong)):this._pingPongState===PING_PONG_BEGIN&&(this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenPingPong),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensPingPong),this._pingPongState=PING_PONG_END)):s&&i&&(0<this._playbackRate?this._playheadTime>=l&&(this._SetTime(l),this.SetPlaybackRate(-1*this.GetPlaybackRate()),t=!0,this._pingPongState===PING_PONG_BEGIN&&(this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenPingPong),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensPingPong)),this._pingPongState===PING_PONG_END&&(this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenLoop),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensLoop),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenPingPong),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensPingPong)),this._pingPongState++,this._pingPongState=C33.wrap(this._pingPongState,0,2)):this._playheadTime<=0&&(this._SetTime(0),this.SetPlaybackRate(-1*this.GetPlaybackRate()),t=!0,this._pingPongState===PING_PONG_BEGIN&&(this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenPingPong),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensPingPong)),this._pingPongState===PING_PONG_END&&(this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenLoop),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensLoop),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenPingPong),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensPingPong)),this._pingPongState++,this._pingPongState=C33.wrap(this._pingPongState,0,2))):0<this._playbackRate?this._playheadTime>=l&&(this._currentRepeatCount<this.GetRepeatCount()?(this._currentRepeatCount++,this._SetTimeAndReset(0),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenLoop),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensLoop),t=!0):(this._SetTime(l),e=!0)):this._playheadTime<=0&&(this._currentRepeatCount<this.GetRepeatCount()?(this._currentRepeatCount++,this._SetTimeAndReset(l),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnAnyTweenLoop),this._TweenTrigger(C33.Behaviors.Tween.Cnds.OnTweensLoop),t=!0):(this._SetTime(0),e=!0)),e?(this._track.SetEndState(),this.Stop(!0),this.OnCompleted()):(this._track.Interpolate(this._playheadTime,!0,!1,t,this._firstTick,!1),this._firstTick&&(this._firstTick=!1))}}}_TweenTrigger(e){const t=this.GetInstance(),s=t.GetBehaviorSdkInstanceFromCtor(C33.Behaviors.Tween);s.PushTriggerTween(this),this._runtime.Trigger(e,t,s.GetBehaviorType()),s.PopTriggerTween()}_SaveToJson(){const e=super._SaveToJson(),t=this.GetTimelineDataItem();return Object.assign(e,{tweenDataItemJson:t._SaveToJson(),id:this._id,destroyInstanceOnComplete:this._destroyInstanceOnComplete,initialValueMode:this._initialValueMode})}_LoadFromJson(e){if(e){const t=this.GetTimelineDataItem();t._LoadFromJson(e.tweenDataItemJson),super._LoadFromJson(e),this._id=e.id,this._destroyInstanceOnComplete=e.destroyInstanceOnComplete,this._initialValueMode=e.initialValueMode,this._CacheTrack()}}static IsPlaying(e){return e.IsPlaying()}static IsPaused(e){return e.IsPaused()}static IsPing(e){return!!e.GetPingPong()&&e.GetPingPongState()===PING_PONG_BEGIN}static IsPong(e){return!!e.GetPingPong()&&e.GetPingPongState()===PING_PONG_END}static Build(e){const t=e.runtime.GetTimelineManager(),s=new C33.TimelineDataItem;if(e.json){s._LoadFromJson(e.json.tweenDataItemJson);const i=new C33.TweenState(s,t);return i._LoadFromJson(e.json),i}{const r=new C33.TweenState(s,t),n=(C33.IsArray(e.propertyTracksConfig)||(e.propertyTracksConfig=[e.propertyTracksConfig]),r.SetId(e.id),r.SetTags(e.tags),r.SetInitialValueMode(e.initialValueMode),r.SetDestroyInstanceOnComplete(e.releaseOnComplete),r.SetLoop(e.loop),r.SetPingPong(e.pingPong),r.SetTotalTime(e.time),r.SetStep(0),r.SetInterpolationMode("default"),r.SetResultMode(e.propertyTracksConfig[0].resultMode),r.SetRepeatCount(e.repeatCount),r.AddTrack()),a=(n.SetInstanceUID(e.instance.GetUID()),n.SetInterpolationMode("default"),n.SetResultMode(e.propertyTracksConfig[0].resultMode),n.SetEnable(!0),n.SetObjectClassIndex(e.instance.GetObjectClass().GetIndex()),e.instance.GetSdkInstance()),o=a.IsOriginalSizeKnown()?a.GetOriginalWidth():e.instance.GetWorldInfo().GetWidth(),l=a.IsOriginalSizeKnown()?a.GetOriginalHeight():e.instance.GetWorldInfo().GetHeight(),h=(n.SetOriginalWidth(o),n.SetOriginalHeight(l),n.AddKeyframe()),c=(h.SetTime(0),h.SetEase("noease"),h.SetEnable(!0),h.SetTags(""),n.AddKeyframe());c.SetTime(e.time),c.SetEase("noease"),c.SetEnable(!0),c.SetTags("");for(const u of e.propertyTracksConfig){const _=n.AddPropertyTrack(),d=(_.SetSourceAdapterId(u.sourceId),_.SetSourceAdapterArgs(u.sourceArgs),_.SetPropertyName(u.property),_.SetPropertyType(u.type),_.SetMin(NaN),_.SetMax(NaN),_.SetInterpolationMode("default"),_.SetResultMode(u.resultMode),_.SetEnable(!0),_.AddPropertyKeyframe()),p=(d.SetType(u.valueType),d.SetTime(0),d.SetEase(u.ease),d.SetEnable(!0),d.SetValue(u.startValue),d.SetAbsoluteValue(u.startValue),_.AddPropertyKeyframe());p.SetType(u.valueType),p.SetTime(e.time),p.SetEase(u.ease),p.SetEnable(!0),p.SetValue(u.endValue),p.SetAbsoluteValue(u.endValue),_.GetSourceAdapter()}return r}}static SetInstanceUID(e,t){if(!isNaN(t))for(const s of e.GetTracks())s.SetInstanceUID(t)}GetITweenState(e,t){return this._iTweenState||(this._iTweenState=C33.New(self.ITweenState,this,e,t)),this._iTweenState}}}{const C33=self.C3;C33.TweenTrackState=class extends C33.TrackState{constructor(e,t){super(e,t),this._firstPropertyTrack=null,this._secondPropertyTrack=null}static Create(e,t){return C33.New(C33.TweenTrackState,e,t)}_CachePropertyTracks(){1===this._propertyTracks.length?this._firstPropertyTrack=this._propertyTracks[0]:(this._firstPropertyTrack=this._propertyTracks[0],this._secondPropertyTrack=this._propertyTracks[1])}CreatePropertyTrackStates(){for(const e of this._trackDataItem.GetPropertyTrackData().propertyTrackDataItems())this._propertyTracks.push(C33.TweenPropertyTrackState.Create(this,e));this._CachePropertyTracks()}AddPropertyTrack(){const e=this._trackDataItem.GetPropertyTrackData(),t=e.AddEmptyPropertyTrackDataItem(),s=C33.TweenPropertyTrackState.Create(this,t);return this._propertyTracks.push(s),this._CachePropertyTracks(),s}SetInitialState(){if(this.MaybeGetInstance(),this.IsInstanceValid()||!this.IsInstanceTrack()){const e=this.GetTimeline(),t=e.IsForwardPlayBack(),s=t?0:this.GetLocalTotalTime();for(const r of this._propertyTracks)r.SetInitialState(s),0===this._worldInfoChange&&1===r.GetWorldInfoChange()&&(this._worldInfoChange=1),0===this._renderChange&&1===r.GetRenderChange()&&(this._renderChange=1);this._needsBeforeAndAfter=0;const i=this._propertyTracks.some(e=>e.GetNeedsBeforeAndAfter());i&&(this._needsBeforeAndAfter=1),this._lastKeyframeDataItem=this._GetLastKeyFrameBeforeTime(s),this._initialStateOfNestedSet=!1,this._endStateOfNestedSet=!1,this.Interpolate(s)}}BeforeInterpolate(){}Interpolate(e,t=0,s=!1,i=!1,r,n=!1,a=!1){if(this._instance||this.GetInstance(),this._instance){const o=!this._instance.IsDestroyed();return o&&(!n||!this.GetObjectClass().IsGlobal())&&((this._secondPropertyTrack?(this._firstPropertyTrack.Interpolate(e,s,i,a),this._secondPropertyTrack):this._firstPropertyTrack).Interpolate(e,s,i,a),void(0!==this._firstPropertyTrack.GetWorldInfoChange()&&(this._worldInfo||(this._worldInfo=this._instance.GetWorldInfo()),this._worldInfo)&&this._worldInfo.SetBboxChanged()))}}AfterInterpolate(){}_LoadFromJson(e){super._LoadFromJson(e),this._CachePropertyTracks()}}}{const C33=self.C3;C33.TweenPropertyTrackState=class extends C33.PropertyTrackState{constructor(e,t){super(e,t),this._basic=!1}static Create(e,t){return C33.New(C33.TweenPropertyTrackState,e,t)}Interpolate(e,t=!1,s=!1,i=!1){let r,n;if(this._basic)r=this._propertyKeyframeDataItems[0],n=this._propertyKeyframeDataItems[1];else{if(t)r=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,this._propertyTrackDataItem);else{if(this._lastPropertyKeyframeDataItem){const a=this.GetTimeline(),o=this._lastPropertyKeyframeDataItem.GetNext(),l=this._lastPropertyKeyframeDataItem.GetTime(),h=o?o.GetTime():a.GetTotalTime();(e<=l||h<=e)&&(this._lastPropertyKeyframeDataItem=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,this._propertyTrackDataItem))}else this._lastPropertyKeyframeDataItem=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,this._propertyTrackDataItem);r=this._lastPropertyKeyframeDataItem}n=r.GetNext()}this._sourceAdapter.Interpolate(e,r,n,t,s,i)}AddPropertyKeyframe(){const e=this._propertyTrackDataItem.GetPropertyKeyframeData(),t=e.AddEmptyPropertyKeyframeDataItem();return this._lastPropertyKeyframeDataItem=null,this._basic=this.GetPropertyKeyframeDataItems().length<=2,t}DeletePropertyKeyframes(e){this._lastPropertyKeyframeDataItem=null;const t=this._propertyTrackDataItem.GetPropertyKeyframeData();t.DeletePropertyKeyframeDataItems(e),this._basic=this.GetPropertyKeyframeDataItems().length<=2}_SaveToJson(){return{sourceAdapterJson:this.GetSourceAdapter()._SaveToJson(),basic:this._basic}}_LoadFromJson(e){e&&(this.GetSourceAdapter()._LoadFromJson(e.sourceAdapterJson),this._basic=e.basic)}}}{const C33=self.C3,Ease=self.Ease,NAME=0,TRANSITION_KEYFRAMES=1,LINEAR=2;C33.Transition=class extends C33.DefendedBase{constructor(e,t=!0){super(),this._name=e[NAME],this._linear=e[LINEAR],this._transitionKeyframes=[];for(const s of e[TRANSITION_KEYFRAMES]){const i=C33.TransitionKeyframe.Create(this,s);this._transitionKeyframes.push(i)}for(let e=0;e<this._transitionKeyframes.length;e++){const r=this._transitionKeyframes[e],n=this._transitionKeyframes[e+1],a=this._transitionKeyframes[e-1];r.SetNext(n),r.SetPrevious(a)}this._precalculatedSamples=new Map,this._transitionKeyframeCache=new Map,this._PreCalcSamples(),t&&Ease.AddCustomEase(this._name,(e,t,s,i)=>this.Interpolate(e,t,s,i),null,{transition:this})}static Create(e){return C33.New(C33.Transition,e)}Release(){for(const e of this._transitionKeyframes)e.Release();C33.clearArray(this._transitionKeyframes),this._transitionKeyframes=null,this._precalculatedSamples.clear(),this._precalculatedSamples=null,this._transitionKeyframeCache.clear(),this._transitionKeyframeCache=null}MakeLinear(e){this._linear=!!e}GetTransitionKeyFrameAt(e){const t=this._transitionKeyframeCache.get(e);if(t)return t;for(const s of this._transitionKeyframes)if(s.GetValueX()===e)return this._transitionKeyframeCache.set(e,s),s}GetFirstTransitionKeyFrameLowerOrEqualThan(t){for(let e=this._transitionKeyframes.length-1;0<=e;e--){const s=this._transitionKeyframes[e],i=s.GetValueX();if(i<=t){let e=s;if(i<t)return e;if(i===t){for(;e;){const r=e.GetPrevious();if(!r)break;if(r.GetValueX()!==e.GetValueX())break;e=r}return e}}}}Interpolate(e,t,s,i){let r=e/i;if(this._linear){const S=this.GetTransitionKeyFrameAt(0),C=this.GetTransitionKeyFrameAt(1),y=t+(t+s)*S.GetValueY(),G=(t+s)*C.GetValueY(),I=G-y;return 0===i?y+I:Ease.NoEase(e,y,I,i)}0===i&&(r=1);let n=this.GetFirstTransitionKeyFrameLowerOrEqualThan(r),a=n.GetNext();if(!a){const T=n.GetPrevious(),b=n;n=T,a=b}const o=a.GetValueX()-n.GetValueX(),l=C33.mapToRange(r,n.GetValueX(),a.GetValueX(),0,o);if(n.IsSegmentLinear()||0==o){const A=t+(t+s)*n.GetValueY(),P=(t+s)*a.GetValueY(),R=P-A;return 0==o?1===l?A+R:A:Ease.NoEase(l,A,R,o)}let h=n.GetValueX(),c=n.GetValueY(),u=n.GetValueX()+n.GetStartAnchorX(),_=n.GetValueY()+n.GetStartAnchorY(),d=a.GetValueX()+a.GetEndAnchorX(),p=a.GetValueY()+a.GetEndAnchorY(),m=a.GetValueX(),g=a.GetValueY(),f=Ease.GetRuntimeEase("spline")(l,h,c,u,_,d,p,m,g,this._precalculatedSamples.get(n));return(1-(f+=n.GetValueY()))*t+f*(t+s)}_PreCalcSamples(){this._precalculatedSamples.clear();for(let e=0;e<this._transitionKeyframes.length-1;e++){const t=this._transitionKeyframes[e];if(t.GetStartEnable()){const s=t,i=this._transitionKeyframes[e+1];if(i.GetEndEnable()){const r=s.GetValueX(),n=s.GetValueX()+s.GetStartAnchorX(),a=i.GetValueX()+i.GetEndAnchorX(),o=i.GetValueX();this._precalculatedSamples.set(s,Ease.GetBezierSamples(r,n,a,o))}}}}}}{const C33=self.C3,VALUE_X=0,VALUE_Y=1,START_ANCHOR_X=2,START_ANCHOR_Y=3,END_ANCHOR_X=4,END_ANCHOR_Y=5,START_ENABLE=6,END_ENABLE=7,SEGMENT_MODE=8;C33.TransitionKeyframe=class extends C33.DefendedBase{constructor(e,t){super(),this._transition=e,this._valueX=t[VALUE_X],this._valueY=t[VALUE_Y],this._startAnchorX=t[START_ANCHOR_X],this._startAnchorY=t[START_ANCHOR_Y],this._endAnchorX=t[END_ANCHOR_X],this._endAnchorY=t[END_ANCHOR_Y],this._startEnable=t[START_ENABLE],this._endEnable=t[END_ENABLE],this._segmentMode=t[SEGMENT_MODE],this._next=null,this._prev=null}Release(){this._transition=null}static Create(e,t){return C33.New(C33.TransitionKeyframe,e,t)}SetNext(e){this._next=e}GetNext(){return this._next}SetPrevious(e){this._prev=e}GetPrevious(){return this._prev}GetValueX(){return this._valueX}GetValueY(){return this._valueY}GetStartAnchorX(){return this._startAnchorX}GetStartAnchorY(){return this._startAnchorY}GetEndAnchorX(){return this._endAnchorX}GetEndAnchorY(){return this._endAnchorY}GetStartEnable(){return this._startEnable}GetEndEnable(){return this._endEnable}IsSegmentLinear(){return"linear"===this._segmentMode}IsSegmentCubic(){return"cubic"===this._segmentMode}}}{const C33=self.C3;C33.TransitionManager=class extends C33.DefendedBase{constructor(e){super(),this._runtime=e,this._transitions=[]}Release(){for(const e of this._transitions)e.Release();C33.clearArray(this._transitions),this._transitions=null}Create(e){this._transitions.push(C33.Transition.Create(e))}}}{const C33=self.C3;C33.TemplateManager=class extends C33.DefendedBase{constructor(e){super(),this._runtime=e,this._templateDataMap=null,this._instanceToTemplateNameMap=null,this._instanceDestroy=e=>this._OnInstanceDestroy(e.instance)}Release(){if(this.RemoveRuntimeListeners(),this._templateDataMap){for(const e of this._templateDataMap.values())e.clear();this._templateDataMap.clear()}this._templateDataMap=null,this._runtime=null}Create(e){if(this._templateDataMap||(this._templateDataMap=new Map),e){const t=e[0][16],s=t[0],i=e[1],r=(this._templateDataMap.has(i)||this._templateDataMap.set(i,new Map),this._templateDataMap.get(i));r.set(s,e)}}AddRuntimeListeners(){const e=this._runtime.Dispatcher();e&&e.addEventListener("instancedestroy",this._instanceDestroy)}RemoveRuntimeListeners(){const e=this._runtime.Dispatcher();e&&e.removeEventListener("instancedestroy",this._instanceDestroy)}HasTemplates(){return!!this._templateDataMap&&0!==this._templateDataMap.size}GetTemplateData(e,t){let s;if(s=e instanceof C33.ObjectClass?e.GetIndex():e,this._templateDataMap.has(s)){const i=this._templateDataMap.get(s).get(t);return i?JSON.parse(JSON.stringify(i)):void 0}}MapInstanceToTemplateName(e,t){this._instanceToTemplateNameMap||(this._instanceToTemplateNameMap=new WeakMap),this._instanceToTemplateNameMap.has(e)||this._instanceToTemplateNameMap.set(e,t)}GetInstanceTemplateName(e){if(!this._instanceToTemplateNameMap)return"";const t=this._instanceToTemplateNameMap.get(e);return t||""}_OnInstanceDestroy(e){this._instanceToTemplateNameMap&&this._instanceToTemplateNameMap.has(e)&&this._instanceToTemplateNameMap.delete(e)}}}{const C33=self.C3;C33.FlowchartManager=class{constructor(e){this._runtime=e,this._flowchartDataManager=new C33.FlowchartDataManager}Release(){this._flowchartDataManager.Release(),this._flowchartDataManager=null,this._runtime=null}GetRuntime(){return this._runtime}Create(e){this._flowchartDataManager.Add(e)}GetFlowchartDataItemByName(e){return this._flowchartDataManager.Get(e)}HasFlowcharts(){return this._flowchartDataManager.HasFlowcharts()}}}{const C33=self.C3;C33.FlowchartState=class{constructor(e,t,s,i,r,n,a){this._runtime=r.GetRuntime(),this._flowchartManager=r,this._flowchartName=e,this._startNodeTag=s,this._flowchartDataItem=i,this._tag=t,this._pluginInstance=n,this._pluginUID=a??n.GetInstance().GetUID(),this._SetStartFlowchartNode(),this._currentFlowchartNodeId=this._startFlowchartNode?.GetFlowchartId()??-1,this._previousFlowchartNodeIds=[],this._previousFlowchartState=null,this._previousFlowchartStateStartNodeId=NaN,this._referenceFlowchartStates=null,this._currentReferenceFlowchartState=null,this._rootFlowchartState=null,this._previousFlowchartStateTag="",this._referenceFlowchartStatesJson=null,this._currentReferenceFlowchartStateTag="",this._rootFlowchartStateTag="",this._triggerCount=0,this._markForRelease=!1,this._released=!1}Release(){this._released||(C33.clearArray(this._previousFlowchartNodeIds),this._previousFlowchartNodeIds=null,this._runtime=null,this._flowchartManager=null,this._flowchartDataItem=null,this._pluginInstance=null,this._previousFlowchartState=null,this._previousFlowchartStateStartNodeId=NaN,this._referenceFlowchartStates&&this._referenceFlowchartStates.clear(),this._referenceFlowchartStates=null,this._currentReferenceFlowchartState=null,this._rootFlowchartState=null,this._previousFlowchartStateTag="",this._referenceFlowchartStatesJson=null,this._currentReferenceFlowchartStateTag="",this._rootFlowchartStateTag="",this._released=!0)}WasReleased(){return this._released}GetFlowchartManager(){return this._flowchartManager}GetRuntime(){return this._runtime}GetName(){return this._flowchartName}GetFlowchartDataItem(){return this._flowchartDataItem}GetTag(){return this._tag}GetPluginInstance(){return this._pluginInstance||(this._pluginInstance=this._runtime.GetInstanceByUID(this._pluginUID).GetSdkInstance()),this._pluginInstance}GetCurrentNode(){return this.GetFlowchartElementById(this._currentFlowchartNodeId)}GetCurrentNodeTag(){const e=this.GetCurrentNode();return e?e.GetTag():""}GetCurrentNodeTags(){const e=this.GetCurrentNode();return e?e.GetTags():[]}CurrentNodeHasTags(e){const t=this.GetCurrentNodeTags();if(!t)return!1;if(!t.length)return!1;const s=C33.FlowchartState._GetTagArray(e);return!(!s||!s.length)&&s.every(C33.FlowchartState._HasTag,t)}CurrentNodeCompareTags(e,t){const s=this.GetCurrentNodeTags();if(!s)return!1;if(!s.length)return!1;const i=C33.FlowchartState._GetTagArray(e);return!(!i||!i.length)&&i.every(e=>C33.FlowchartState._CompareTag.call(s,e,t))}static _HasTag(e){return""===e?1===this.length&&""===this[0]:this.map(e=>e.trim().toLowerCase()).includes(e.trim().toLowerCase())}static _GetTagArray(e){return e.trim().split(" ")}static _CompareTag(t,s){return""===t?1===this.length&&""===this[0]:this.some(e=>C33.compare(e.trim(),s,t.trim()))}GetCurrentNodeParent(e){const t=this.GetCurrentNode();if(t){if(C33.IsFiniteNumber(e)){const s=t.GetParentFlowchartIds(),i=s?s[e]:void 0;if(C33.IsFiniteNumber(i))return this.GetFlowchartElementById(i)}if("string"==typeof e)for(const r of t.GetParentFlowchartIds()){const n=this.GetFlowchartElementById(r);if(n.HasTags(e))return this.GetFlowchartElementById(n.GetFlowchartId())}}}GetCurrentNodeParentTag(e){const t=this.GetCurrentNodeParent(e);return t?t.GetTag():""}GetCurrentNodeParentTags(e){const t=this.GetCurrentNodeParent(e);return t?t.GetTags():""}GetCurrentNodeParentIndex(e){const t=this.GetCurrentNode();if(!t)return-1;const s=t.GetParentFlowchartIds();if(!s)return-1;const i=this.GetCurrentNodeParent(e);return i?s.indexOf(i.GetFlowchartId()):-1}GetCurrentNodeParentCount(){const e=this.GetCurrentNode();if(!e)return 0;const t=e.GetParentFlowchartIds();return t?t.length:0}GetFlowchartElementById(e){return this._flowchartDataItem.GetFlowchartElementById(e)}Reset(){const e=this._GetRootFlowchartState();e._Reset(!0)}_Reset(e){if(this._GetReferenceFlowchartStates()){for(const[t,s]of this._GetReferenceFlowchartStates().entries())s._Reset(!1);this._GetReferenceFlowchartStates().clear()}if(this._referenceFlowchartStates=null,this._previousFlowchartState=null,this._previousFlowchartStateStartNode=null,this._currentReferenceFlowchartState=null,this._previousFlowchartStateTag="",this._referenceFlowchartStatesJson=null,this._currentReferenceFlowchartStateTag="",this._rootFlowchartStateTag="",this._previousFlowchartNodeIds=[],e){this._flowchartManager.SetCurrentFlowchartState(this);const i=this._startFlowchartNode.GetFlowchartId();i!==this._currentFlowchartNodeId&&this._GotoFlowchartNode(i)}else this._currentFlowchartNodeId=this._startFlowchartNode.GetFlowchartId()}GetCurrentNodeOutputCount(){const e=this._flowchartDataItem.GetFlowchartElementById(this._currentFlowchartNodeId);return e?e.GetFlowchartNodeOutputData().GetFlowchartNodeOutputDataItemCount():0}GetCurrentNodeOutputNameAt(e){const t=this._GetFlowchartNodeOutputAt(e);return t?t.GetName():""}GetCurrentNodeOutputValueAt(e){let t;return C33.IsFiniteNumber(e)&&(t=this._GetFlowchartNodeOutputAt(e)),"string"==typeof e&&(t=this._GetFlowchartNodeOutputByName(e)),"number"!=typeof e&&"string"!=typeof e&&console.warn("[Flowcharts] unexpected argument type in GetCurrentNodeOutputValueAt expression"),t?t.GetValue():""}GotoNextFlowchartNode(e){let t;if(C33.IsFiniteNumber(e)&&(t=this._GetFlowchartNodeOutputAt(e)),t="string"==typeof e?this._GetFlowchartNodeOutputByName(e):t){const s=t.GetConnectedFlowchartNodeFlowchartId();C33.IsFiniteNumber(s)&&(this._previousFlowchartNodeIds.push(this._currentFlowchartNodeId),this._GotoFlowchartNode(s))}}GotoAnyFlowchartNode(e){const t=this._flowchartDataItem.GetFlowchartNodeByTags(e);if(t){const s=this._flowchartDataItem.GetFlowchartElementById(t.GetFlowchartId());s&&(this._previousFlowchartNodeIds.push(this._currentFlowchartNodeId),this._GotoFlowchartNode(s.GetFlowchartId()))}}GotoPreviousFlowchartNode(){const e=this._previousFlowchartNodeIds.pop();C33.IsFiniteNumber(e)?this._GotoFlowchartNode(e):this._GetPreviousFlowchartState()&&(this._flowchartManager.SetCurrentFlowchartState(this._GetPreviousFlowchartState(),!0,!1,!1),this._GetPreviousFlowchartState()._GotoFlowchartNode(this._GetPreviousFlowchartStateStartNodeId()),this._GetRootFlowchartState()._SetCurrentReferenceFlowchart(this._GetPreviousFlowchartState()))}GotoParentFlowchartNode(e){const t=this.GetCurrentNode();if(t){t.GetFlowchartId();const s=this.GetCurrentNodeParent(e);s&&(this._previousFlowchartNodeIds.push(this._currentFlowchartNodeId),this._GotoFlowchartNode(s.GetFlowchartId()))}}HasOutput(t){if(C33.IsFiniteNumber(t)){const e=this._flowchartDataItem.GetFlowchartElementById(this._currentFlowchartNodeId),s=e.GetFlowchartNodeOutputData().GetFlowchartNodeOutputDataItems();return!!s[t]}if("string"==typeof t){const i=this._flowchartDataItem.GetFlowchartElementById(this._currentFlowchartNodeId),r=i.GetFlowchartNodeOutputData().GetFlowchartNodeOutputDataItems();for(let e=0;e<r.length;e++)if(r[e].GetName()===t)return!0}return!1}MarkForRelease(){this._markForRelease=!0}IsInTriggerState(){return 0<this._triggerCount}PushIsTriggerState(){this._triggerCount++}PopIsTriggerState(){this._triggerCount--,0===this._triggerCount&&this._markForRelease&&this._flowchartManager.RemoveFlowchartState(this)}_GotoFlowchartNode(e){const s=this._currentFlowchartNodeId,t=this.GetPluginInstance().GetInstance();if(this.PushIsTriggerState(),this._flowchartManager.PushFlowchartState(this),this._runtime.Trigger(C33.Plugins.Flowchart.Cnds.OnBeforeAnyNodeChange,t),this._runtime.Trigger(C33.Plugins.Flowchart.Cnds.OnBeforeTaggedNodeChange,t),this._runtime.Trigger(C33.Plugins.Flowchart.Cnds.OnBeforeAnyNodeChangeInFlowchart,t),this._runtime.Trigger(C33.Plugins.Flowchart.Cnds.OnBeforeTaggedNodeChangeInFlowchart,t),this._currentFlowchartNodeId=e,this._runtime.Trigger(C33.Plugins.Flowchart.Cnds.OnAnyNodeChange,t),this._runtime.Trigger(C33.Plugins.Flowchart.Cnds.OnTaggedNodeChange,t),this._runtime.Trigger(C33.Plugins.Flowchart.Cnds.OnAnyNodeChangeInFlowchart,t),this._runtime.Trigger(C33.Plugins.Flowchart.Cnds.OnTaggedNodeChangeInFlowchart,t),this._flowchartManager.PopFlowchartState(),this.PopIsTriggerState(),!this.WasReleased()){const i=this.GetFlowchartElementById(this._currentFlowchartNodeId);if("reference"===i.GetType()){const r=i.GetReferenceFlowchartName();if(this._HasReferenceFlowchartState(i)){this._previousFlowchartNodeIds.pop();const n=this._GetReferenceFlowchartState(i),a=(this._flowchartManager.SetCurrentFlowchartState(n,!0,!0,!1),n._SetPreviousFlowchart(this,s),this._GetRootFlowchartState());a._SetCurrentReferenceFlowchart(n)}else{const o=i.GetReferenceFlowchartStartNodeTag();if(r){this._previousFlowchartNodeIds.pop();let t=i.GetReferenceFlowchartTag();if(t){let e=this._flowchartManager.GetFlowchartState(t);for(;e;)t=C33.IncrementNumberAtEndOf(t),e=this._flowchartManager.GetFlowchartState(t)}else{t=r+"-ref";let e=this._flowchartManager.GetFlowchartState(t);for(;e;)t=C33.IncrementNumberAtEndOf(t),e=this._flowchartManager.GetFlowchartState(t)}const l=this._flowchartManager.AddFlowchartState(r,o,t,this._pluginInstance,!0),h=(l._SetPreviousFlowchart(this,s),this._SetReferenceFlowchartState(i,l),this._GetRootFlowchartState());l._SetRootFlowchartState(h),h._SetCurrentReferenceFlowchart(l)}}}}}_GetFlowchartNodeOutputAt(e){const t=this._flowchartDataItem.GetFlowchartElementById(this._currentFlowchartNodeId);if(!t)return null;const s=t.GetFlowchartNodeOutputData().GetFlowchartNodeOutputDataItems();if(!s)return null;const i=s[e];return i||null}_GetFlowchartNodeOutputByName(e){const t=this._flowchartDataItem.GetFlowchartElementById(this._currentFlowchartNodeId);if(!t)return null;const s=t.GetFlowchartNodeOutputData().GetFlowchartNodeOutputDataItemByName(e);return s||null}_SetStartFlowchartNode(t){if("number"==typeof t){let e=this.GetFlowchartElementById(t);e=e||this._flowchartDataItem.GetFlowchartStartNode(),this._startFlowchartNode=e}else{let e=this._flowchartDataItem.GetFlowchartNodeByTags(this._startNodeTag);e=e||this._flowchartDataItem.GetFlowchartStartNode(),this._startFlowchartNode=e}}_SaveToJson(){return this._markForRelease?null:{flowchartName:this._flowchartName,flowchartTag:this._tag,startNodeTag:this._startNodeTag,currentNodeId:this._currentFlowchartNodeId,previousNodeIds:this._previousFlowchartNodeIds,pluginUID:this._pluginInstance.GetInstance().GetUID(),reference:{previousFlowchartTag:this._GetPreviousFlowchartState()?this._GetPreviousFlowchartState().GetTag():"",previousStartNodeId:C33.IsFiniteNumber(this._GetPreviousFlowchartStateStartNodeId())?this._GetPreviousFlowchartStateStartNodeId():NaN,referencesJson:this._GetFlowchartReferencesJson(),currentReferenceFlowchartTag:this.GetCurrentReferenceFlowchart()?this.GetCurrentReferenceFlowchart().GetTag():"",rootFlowchartTag:this._GetRootFlowchartState()?this._GetRootFlowchartState().GetTag():""}}}_GetFlowchartReferencesJson(){if(!this._HasReferenceFlowchartStates())return null;const e=[];for(const[t,s]of this._GetReferenceFlowchartStates().entries())e.push({flowchartElementId:t.GetFlowchartId(),flowchartStateTag:s.GetTag()});return e.length?e:null}_LoadFromJson(e){if(e){if(this._flowchartName=e.flowchartName,this._tag=e.flowchartTag,this._startNodeTag=e.startNodeTag,this._currentFlowchartNodeId=e.currentNodeId,this._previousFlowchartNodeIds=e.previousNodeIds,this._pluginUID=e.pluginUID,e.hasOwnProperty("reference")){const t=e.reference;this._previousFlowchartStateTag=t.previousFlowchartTag,this._previousFlowchartStateStartNodeId=t.previousStartNodeId,this._referenceFlowchartStatesJson=t.referencesJson,this._currentReferenceFlowchartStateTag=t.currentReferenceFlowchartTag,this._rootFlowchartStateTag=t.rootFlowchartTag}this._SetStartFlowchartNode()}}_GetPreviousFlowchartState(){return"string"==typeof this._previousFlowchartStateTag&&this._previousFlowchartStateTag&&(this._previousFlowchartState=this._flowchartManager.GetFlowchartState(this._previousFlowchartStateTag),this._previousFlowchartStateTag=""),this._previousFlowchartState}_GetPreviousFlowchartStateStartNodeId(){return this._previousFlowchartStateStartNodeId}_SetPreviousFlowchart(e,t){this._previousFlowchartState=e,this._previousFlowchartStateStartNodeId=t}GetCurrentReferenceFlowchart(){return"string"==typeof this._currentReferenceFlowchartStateTag&&this._currentReferenceFlowchartStateTag&&(this._currentReferenceFlowchartState=this._flowchartManager.GetFlowchartState(this._currentReferenceFlowchartStateTag),this._currentReferenceFlowchartStateTag=""),this._currentReferenceFlowchartState}_SetCurrentReferenceFlowchart(e){this._currentReferenceFlowchartState=e,this._currentReferenceFlowchartState===this&&(this._currentReferenceFlowchartState=null)}_GetRootFlowchartState(){return"string"==typeof this._rootFlowchartStateTag&&this._rootFlowchartStateTag&&(this._rootFlowchartState=this._flowchartManager.GetFlowchartState(this._rootFlowchartStateTag),this._rootFlowchartStateTag=""),this._rootFlowchartState||this}_SetRootFlowchartState(e){this._rootFlowchartState=e}_HasReferenceFlowchartStates(){return this._RebuildReferenceFlowchartStates(),!!this._referenceFlowchartStates}_HasReferenceFlowchartState(e){return this._RebuildReferenceFlowchartStates(),this._referenceFlowchartStates&&this._referenceFlowchartStates.has(e)}_RebuildReferenceFlowchartStates(){if(this._referenceFlowchartStatesJson){this._referenceFlowchartStates&&this._referenceFlowchartStates.clear(),this._referenceFlowchartStates||(this._referenceFlowchartStates=new Map);for(const e of this._referenceFlowchartStatesJson){const t=this._flowchartManager.GetFlowchartState(e.flowchartStateTag),s=t.GetFlowchartElementById(e.flowchartElementId);this._referenceFlowchartStates.set(s,t)}this._referenceFlowchartStatesJson=null}}_GetReferenceFlowchartStates(){return this._RebuildReferenceFlowchartStates(),this._referenceFlowchartStates}_GetReferenceFlowchartState(e){return this._RebuildReferenceFlowchartStates(),this._referenceFlowchartStates.get(e)}_SetReferenceFlowchartState(e,t){this._referenceFlowchartStates||(this._referenceFlowchartStates=new Map),this._referenceFlowchartStates.set(e,t)}}}{const C33=self.C3;C33.FlowchartStateManager=class{constructor(e){this._runtime=e,this._flowchartStates=new Map,this._currentFlowchartState=null,this._flowchartStateStack=[],this._on_after_load=()=>this._OnAfterLoad(),this._loadJson=null}Release(){C33.clearArray(this._flowchartStateStack),this._flowchartStateStack=null,this._flowchartStates.clear(),this._flowchartStates=null,this._currentFlowchartState=null,this._runtime=null,this._loadJson=null}GetRuntime(){return this._runtime}AddFlowchartState(e,t,s,i,r,n){const a=this._runtime.GetFlowchartManager().GetFlowchartDataItemByName(e);if(a){if(!this._flowchartStates.has(s)){const o=new C33.FlowchartState(e,s,t,a,this,i,n);return this._flowchartStates.set(s,o),r&&this.SetCurrentFlowchartState(o,!0),o}{const l=this._flowchartStates.get(s);l&&this.RemoveFlowchartState(l)}}else console.warn(`[Flowcharts] no flowchart found with name '${e}'`)}RemoveFlowchartState(e){if(e.MarkForRelease(),!e.IsInTriggerState()){const t=e.GetTag();this._flowchartStates.delete(t),e.Release(),this._currentFlowchartState===e&&(this._currentFlowchartState=null)}}ResetFlowchartState(e){e.Reset()}GetFlowchartState(e){return this._flowchartStates.get(e)}PushFlowchartState(e){this._flowchartStateStack.push(e)}PopFlowchartState(){this._flowchartStateStack.pop()}SetCurrentFlowchartState(e,t=!1,s=!1,i=!0){if(i){const r=e.GetCurrentReferenceFlowchart();e=r||e}e!==this._currentFlowchartState&&(this._TriggerBeforeFlowchartChange(),this._TriggerAfterFlowchartChange(e,t,s))}GetCurrentFlowchartState(e){return"string"==typeof e?this.GetFlowchartState(e):this._flowchartStateStack.length?this._flowchartStateStack[this._flowchartStateStack.length-1]:this._currentFlowchartState}_TriggerBeforeFlowchartChange(){if(this._currentFlowchartState&&!this._currentFlowchartState.WasReleased()){const e=this._currentFlowchartState.GetPluginInstance().GetInstance();this._currentFlowchartState.PushIsTriggerState(),this.PushFlowchartState(this._currentFlowchartState),this._runtime.Trigger(C33.Plugins.Flowchart.Cnds.OnBeforeFlowchartChange,e),this.PopFlowchartState(),this._currentFlowchartState.PopIsTriggerState()}}_TriggerAfterFlowchartChange(e,t=!1,s=!1){if(this._currentFlowchartState=e,this._currentFlowchartState&&!this._currentFlowchartState.WasReleased()){const i=this._currentFlowchartState.GetPluginInstance().GetInstance();this._currentFlowchartState.PushIsTriggerState(),this.PushFlowchartState(this._currentFlowchartState),this._runtime.Trigger(C33.Plugins.Flowchart.Cnds.OnFlowchartChange,i),!0!==s&&"number"!=typeof s||this._currentFlowchartState._SetStartFlowchartNode(s),t&&(this._runtime.Trigger(C33.Plugins.Flowchart.Cnds.OnAnyNodeChange,i),this._runtime.Trigger(C33.Plugins.Flowchart.Cnds.OnTaggedNodeChange,i)),this.PopFlowchartState(),this._currentFlowchartState.PopIsTriggerState()}}_SaveToJson(){return{flowchartJsonObjects:[...this._flowchartStates.values()].map(e=>e._SaveToJson()),currentFlowchartTag:this._currentFlowchartState?this._currentFlowchartState.GetTag():null}}_LoadFromJson(e){if(e){this._loadJson=e;const t=new Map;for(const s of this._loadJson.flowchartJsonObjects){const i=s.flowchartTag;if(this._flowchartStates.has(i)){const r=this._flowchartStates.get(i);r._LoadFromJson(s),t.set(i,r)}else{const n=this.AddFlowchartState(s.flowchartName,s.startNodeTag,s.flowchartTag,null,!1,s.pluginUID);n._LoadFromJson(s),t.set(s.flowchartTag,n)}}for(const[a,o]of this._flowchartStates.entries())t.has(a)||o.Release();this._flowchartStates.clear(),this._flowchartStates=t,this._runtime.IsLoadingState()?this._runtime.Dispatcher().addEventListener("afterload",this._on_after_load):this._OnAfterLoad()}}_OnAfterLoad(){this._runtime.Dispatcher().removeEventListener("afterload",this._on_after_load);const e=this._flowchartStates.get(this._loadJson.currentFlowchartTag);e&&this.SetCurrentFlowchartState(e,!0),this._loadJson=null}}}{const C33=self.C3;C33.FlowchartDataManager=class{constructor(){this._flowchartDataItems=new Map}Release(){for(const e of this._flowchartDataItems.values())e.Release();this._flowchartDataItems.clear(),this._flowchartDataItems=null}Add(e){const t=new C33.FlowchartDataItem(e),s=t.GetName();this._flowchartDataItems.set(s,t)}Get(e){return this._flowchartDataItems.get(e)}HasFlowcharts(){return!!this._flowchartDataItems.size}static CreateDataItems(e,t,s,i){if(t)for(const r of t){const n=new s(r,i);e.push(n)}}}}{const C33=self.C3,NAME=0,NODES=1;C33.FlowchartDataItem=class{constructor(e){this._name=e[NAME],this._flowchartNodeData=new C33.FlowchartNodeData(e[NODES],this)}Release(){this._flowchartNodeData.Release(),this._flowchartNodeData=null}GetFlowchartNodeData(){return this._flowchartNodeData}GetFlowchartElementById(e){return this._flowchartNodeData.GetFlowchartElementById(e)}GetFlowchartNodeByTags(e){return this._flowchartNodeData.GetFlowchartNodeByTags(e)}GetFlowchartStartNode(){return this._flowchartNodeData.GetFlowchartStartNode()}GetName(){return this._name}}}{const C33=self.C3,FLOWCHART_ID=0,TAG=1,PARENT_FLOWCHART_IDS=2,PARENT_OUTPUT_FLOWCHART_IDS=3,CHILDREN_FLOWCHART_IDS=4,OUTPUTS=5,IS_START=6,TYPE=7,REFERENCE_FLOWCHART=8,REFERENCE_FLOWCHART_START_NODE=9,REFERENCE_FLOWCHART_TAG=10;class FlowchartNodeDataItem{constructor(e,t){this._flowchartNodeData=t,this._type=e[TYPE],this._flowchartId=e[FLOWCHART_ID],this._tag=e[TAG],this._tag?this._tags=this._tag.trim().split(" ").map(e=>e.trim()):this._tags=[],this._parentFlowchartIds=e[PARENT_FLOWCHART_IDS],this._parentOutputFlowchartIds=null,this._childrenFlowchartIds=null,"dictionary"===this._type&&(this._parentOutputFlowchartIds=e[PARENT_OUTPUT_FLOWCHART_IDS],this._childrenFlowchartIds=e[CHILDREN_FLOWCHART_IDS]),this._isStart=e[IS_START],this._referenceFlowchartName=null,this._referenceFlowchartStartNodeTag=null,this._referenceFlowchartTag=null,"reference"===this._type&&(this._referenceFlowchartName=e[REFERENCE_FLOWCHART],this._referenceFlowchartStartNodeTag=e[REFERENCE_FLOWCHART_START_NODE],this._referenceFlowchartTag=e[REFERENCE_FLOWCHART_TAG]),this._flowchartNodeOutputData=new C33.FlowchartNodeOutputData(e[OUTPUTS],this)}Release(){this._flowchartNodeData=null}GetFlowchartNodeData(){return this._flowchartNodeData}GetFlowchartNodeOutputData(){return this._flowchartNodeOutputData}GetFlowchartId(){return this._flowchartId}GetTag(){return this._tag}GetTags(){return this._tags}HasTags(e){if(!this._tags)return!1;if(!this._tags.length)return!1;const t=C33.FlowchartState._GetTagArray(e);return!(!t||!t.length)&&t.every(C33.FlowchartState._HasTag,this._tags)}GetIsStart(){return this._isStart}SetIsStart(e){this._isStart=!!e}CanBeStartNode(){if("dictionary"===this._type)return!0;if("reference"===this._type)return!1;throw new Error("unexpected flowchart node type: "+this._type)}GetParentFlowchartIds(){return this._parentFlowchartIds}GetParentOutputFlowchartIds(){return this._parentOutputFlowchartIds}GetChildrenFlowchartIds(){return this._childrenFlowchartIds}GetType(){return this._type}GetReferenceFlowchartName(){return this._referenceFlowchartName}GetReferenceFlowchartStartNodeTag(){return this._referenceFlowchartStartNodeTag}GetReferenceFlowchartTag(){return this._referenceFlowchartTag}}C33.FlowchartNodeData=class{constructor(e,t){this._flowchartDataItem=t,this._flowchartNodeItems=[],this._flowchartNodeItemsIdMap=new Map,this._flowchartNodeItemsTagMap=new Map,this._flowchartNodeStartItem=null,C33.FlowchartDataManager.CreateDataItems(this._flowchartNodeItems,e,FlowchartNodeDataItem,this);for(const s of this._flowchartNodeItems){const i=s.GetFlowchartId(),r=s.GetTag(),n=s.GetTags(),a=s.GetIsStart();if(this._flowchartNodeItemsIdMap.set(i,s),r)for(const l of n)this._flowchartNodeItemsTagMap.has(l)||this._flowchartNodeItemsTagMap.set(l,new Set),this._flowchartNodeItemsTagMap.get(l).add(s);a&&(this._flowchartNodeStartItem=s);const o=s.GetFlowchartNodeOutputData();for(const h of o.flowchartNodeOutputDataItems()){const c=h.GetFlowchartId();this._flowchartNodeItemsIdMap.set(c,h)}}this._flowchartNodeStartItem||this._SetStartNodeIfMissing()}Release(){this._flowchartDataItem=null;for(const e of this._flowchartNodeItems)e.Release();C33.clearArray(this._flowchartNodeItems),this._flowchartNodeItems=null}GetFlowchartDataItem(){return this._flowchartDataItem}GetFlowchartElementById(e){return this._flowchartNodeItemsIdMap.get(e)}GetFlowchartNodeByTags(e){if(!e||!e.length)return null;const s=[];for(const i of e.trim().split(" ")){let e=this._flowchartNodeItemsTagMap.get(i.trim())??new Set;if(0===e.size)return null;s.push(e)}const t=s.reduce((e,t)=>t.size<e.size?t:e);return[...t].filter(t=>s.every(e=>e.has(t)))[0]}GetFlowchartStartNode(){return this._flowchartNodeStartItem}*flowchartNodeDataItems(){for(const e of this._flowchartNodeItems)yield e}_SetStartNodeIfMissing(){let e=0;for(const t of this.flowchartNodeDataItems())t.GetIsStart()&&e++;if(0===e){for(const s of this.flowchartNodeDataItems())if(s.CanBeStartNode()&&!s.GetIsStart())return void s.SetIsStart(!0)}else{if(1===e)return;if(1<e){let e=!0;for(const i of this.flowchartNodeDataItems())i.CanBeStartNode()&&(i.GetIsStart()&&e?e=!1:i.GetIsStart()&&!e&&i.SetIsStart(!1))}}for(const r of this.flowchartNodeDataItems())if(r.CanBeStartNode()&&r.GetIsStart())return void(this._flowchartNodeStartItem=r)}}}{const C33=self.C3,FLOWCHART_ID=0,NAME=1,VALUE=2,CONNECTED_FLOWCHART_NODE_FLOWCHART_ID=3;class FlowchartNodeDataOutputItem{constructor(e,t){this._flowchartNodeOutputData=t,this._flowchartId=e[FLOWCHART_ID],this._name=e[NAME],this._value=e[VALUE],this._connectedFlowchartNodeFlowchartId=e[CONNECTED_FLOWCHART_NODE_FLOWCHART_ID]}Release(){this._flowchartNodeOutputData=null}GetFlowchartNodeOutputData(){return this._flowchartNodeOutputData}GetFlowchartId(){return this._flowchartId}GetName(){return this._name}GetValue(){return this._value}GetConnectedFlowchartNodeFlowchartId(){return this._connectedFlowchartNodeFlowchartId}}C33.FlowchartNodeOutputData=class{constructor(e,t){this._flowchartDataNodeItem=t,this._flowchartNodeOutputItems=[],this._flowchartNodeOutputItemsNameMap=new Map,C33.FlowchartDataManager.CreateDataItems(this._flowchartNodeOutputItems,e,FlowchartNodeDataOutputItem,this);for(const s of this._flowchartNodeOutputItems)this._flowchartNodeOutputItemsNameMap.set(s.GetName(),s)}Release(){this._flowchartDataNodeItem=null;for(const e of this._flowchartNodeOutputItems)e.Release();C33.clearArray(this._flowchartNodeOutputItems),this._flowchartNodeOutputItems=null}GetFlowchartNodeDataItem(){return this._flowchartDataNodeItem}GetFlowchartNodeOutputDataItemCount(){return this._flowchartNodeOutputItems.length}GetFlowchartNodeOutputDataItems(){return this._flowchartNodeOutputItems}GetFlowchartNodeOutputDataItemByName(e){return this._flowchartNodeOutputItemsNameMap.get(e)}*flowchartNodeOutputDataItems(){for(const e of this._flowchartNodeOutputItems)yield e}}}{const C33=self.C3;C33.SolStack=class extends C33.DefendedBase{constructor(e){super(),this._objectClass=e,this._stack=[],this._stack.push(C33.New(C33.Sol,this)),this._index=0,this._current=this._stack[0]}Release(){for(const e of this._stack)e.Release();C33.clearArray(this._stack),this._current=null,this._objectClass=null}GetObjectClass(){return this._objectClass}GetCurrentSol(){return this._current}GetOneBelowCurrentSol(){return this._stack[this._index-1]}Clear(){this.GetCurrentSol().Clear()}PushClean(){const e=this._stack,t=++this._index;if(t===e.length){const s=C33.New(C33.Sol,this);e.push(s),this._current=s}else{const i=e[t];i.Reset(),this._current=i}}PushCopy(){const e=this._stack,t=++this._index,s=(t===e.length&&e.push(C33.New(C33.Sol,this)),e[t]);s.Copy(e[t-1]),this._current=s}Pop(){this._current=this._stack[--this._index]}RemoveInstances(s){const i=this._stack;for(let e=0,t=i.length;e<t;++e)i[e].RemoveInstances(s)}}}{const C33=self.C3;C33.Sol=class extends C33.DefendedBase{constructor(e){super(),this._stack=e,this._objectClass=this._stack.GetObjectClass(),this._eventStack=this._objectClass.GetRuntime().GetEventStack(),this._selectAll=!0,this._instances=[],this._elseInstances=[]}Release(){this.ClearArrays(),this._stack=null,this._objectClass=null,this._eventStack=null}ClearArrays(){C33.clearArray(this._instances),C33.clearArray(this._elseInstances)}GetObjectClass(){return this._objectClass}IsSelectAll(){return this._selectAll}HasAnyInstances(){return this._selectAll?!!this._objectClass.GetInstanceCount():!!this._instances.length}GetInstances(){return this._selectAll?this._objectClass.GetInstances():this._instances}HasAnyElseInstances(){return!!this._elseInstances.length}GetElseInstances(){return this._elseInstances}GetExpressionInstances(){const e=this.GetInstances();return e.length?e:this._elseInstances}Reset(){this._selectAll=!0,C33.clearArray(this._elseInstances)}Clear(){this._selectAll=!0}Copy(e){e.IsSelectAll()?this.Reset():(this._selectAll=!1,C33.shallowAssignArray(this._instances,e._instances),C33.clearArray(this._elseInstances))}_PushInstance(e){this._instances.push(e)}_PushElseInstance(e){this._elseInstances.push(e)}_SetSelectAll(e){this._selectAll=!!e}_GetOwnInstances(){return this._instances}_GetOwnElseInstances(){return this._elseInstances}SetSinglePicked(e){this._selectAll=!1,C33.clearArray(this._instances),this._instances.push(e)}SetArrayPicked(e){this._selectAll=!1,C33.shallowAssignArray(this._instances,e)}SetSetPicked(e){this._selectAll=!1,C33.clearArray(this._instances);for(const t of e)this._instances.push(t)}AddElseInstances(e,t){for(const s of t)e.has(s)||this._elseInstances.push(s)}TransferElseInstancesToOwn(e){for(const t of e)this._instances.push(t);C33.arrayRemoveAllInSet(this._elseInstances,e)}ClearElseInstances(){C33.clearArray(this._elseInstances)}PickOne(e){if(e)if(this._eventStack.GetCurrentStackFrame().GetCurrentEvent().IsOrBlock()){this.IsSelectAll()&&(C33.clearArray(this._instances),C33.shallowAssignArray(this._elseInstances,e.GetObjectClass().GetInstances()),this._selectAll=!1);const t=this._elseInstances.indexOf(e);-1!==t&&(this._instances.push(this._elseInstances[t]),this._elseInstances.splice(t,1))}else this.SetSinglePicked(e)}RemoveInstances(e){C33.arrayRemoveAllInSet(this._instances,e),C33.arrayRemoveAllInSet(this._elseInstances,e)}}}{const C33=self.C3;C33.EventStack=class extends C33.DefendedBase{constructor(e){super(),this._eventSheetManager=e,this._runtime=this._eventSheetManager.GetRuntime(),this._stack=[],this._stack.push(C33.New(C33.EventStackFrame,this,null)),this._index=0,this._expFuncStack=[]}Release(){for(const e of this._stack)e.Release();C33.clearArray(this._stack),C33.clearArray(this._expFuncStack),this._eventSheetManager=null,this._runtime=null}GetEventSheetManager(){return this._eventSheetManager}GetRuntime(){return this._runtime}GetCurrentStackFrame(){return this._stack[this._index]}GetAllStackFrames(){return this._stack}GetCurrentStackFrameIndex(){return this._index}Push(e){const t=this._stack,s=++this._index;if(s===t.length){const i=C33.New(C33.EventStackFrame,this,e);return t.push(i),i}{const r=t[s];return r.Reset(e),r}}Pop(){--this._index}PushExpFunc(e){this._expFuncStack.push(e)}PopExpFunc(){this._expFuncStack.pop()}GetCurrentExpFuncStackFrame(){const e=this._expFuncStack;return 0===e.length?null:e.at(-1)}}}{const C33=self.C3;C33.EventStackFrame=class extends C33.DefendedBase{constructor(e,t){super(),this._stack=e,this._runtime=this._stack.GetRuntime(),this._currentEvent=t,this._cndIndex=0,this._actIndex=0,this._lastEventTrue=!1,this._elseBranchRan=!1,this._expressionObjectClass=null,this._functionReturnType=0,this._functionReturnValue=0,this._dynamicSolModifiers=null}Release(){this.Reset(null),this._stack=null,this._runtime=null}Reset(e){this._currentEvent=e,this._cndIndex=0,this._actIndex=0,this._lastEventTrue=!1,this._elseBranchRan=!1,this._dynamicSolModifiers=null}_Restore(e,t){this._currentEvent=e,this._cndIndex=0,this._actIndex=t}ResetQuick(){this._cndIndex=0,this._actIndex=0}GetCurrentEvent(){return this._currentEvent}SetCurrentEvent(e){this._currentEvent=e}GetConditionIndex(){return this._cndIndex}SetConditionIndex(e){this._cndIndex=e}GetActionIndex(){return this._actIndex}SetActionIndex(e){this._actIndex=e}SetLastEventTrue(e){this._lastEventTrue=!!e}GetLastEventTrue(){return this._lastEventTrue}SetElseBranchRan(e){this._elseBranchRan=!!e}GetElseBranchRan(){return this._elseBranchRan}SetExpressionObjectClass(e){this._expressionObjectClass=e}GetExpressionObjectClass(){return this._expressionObjectClass}InitCallFunctionExpression(e,t){this._functionReturnType=e,this._functionReturnValue=t}GetFunctionReturnType(){return this._functionReturnType}SetFunctionReturnValue(e){this._functionReturnValue=e}GetFunctionReturnValue(){return this._functionReturnValue}IsSolModifierAfterCnds(){const e=this._currentEvent;return!!e.IsSolWriterAfterCnds()||this._cndIndex<e.GetConditionCount()-1&&!!e.GetSolModifiers().length}SetDynamicSolModifiers(e){this._dynamicSolModifiers=e}GetDynamicSolModifiers(){return this._dynamicSolModifiers}}}{const C33=self.C3;C33.LocalVarStack=class extends C33.DefendedBase{constructor(e){super(),this._eventSheetManager=e,this._runtime=this._eventSheetManager.GetRuntime(),this._stack=[],this._index=-1,this._current=null,this._initialValues=[]}Release(){C33.clearArray(this._stack),this._eventSheetManager=null,this._runtime=null}_SetInitialValues(e){this._initialValues=e;const t=this._initialValues.slice(0);this._stack.push(t),this._index=0,this._current=t}GetEventSheetManager(){return this._eventSheetManager}GetRuntime(){return this._runtime}GetCurrent(){return this._current}Push(){const e=++this._index,t=this._stack;e===t.length?t.push(this._initialValues.slice(0)):C33.shallowAssignArray(t[e],this._initialValues),this._current=t[e]}Pop(){this._current=this._stack[--this._index]}}}{const C33=self.C3;C33.LoopStack=class extends C33.DefendedBase{constructor(e){super(),this._eventSheetManager=e,this._runtime=this._eventSheetManager.GetRuntime(),this._stack=[],this._index=-1}Release(){C33.clearArray(this._stack),this._eventSheetManager=null,this._runtime=null}GetEventSheetManager(){return this._eventSheetManager}GetRuntime(){return this._runtime}IsInLoop(){return 0<=this._index}GetCurrent(){return this._stack[this._index]}Push(){if(++this._index,this._index===this._stack.length){const e=C33.New(C33.Loop,this);return this._stack.push(e),e}{const t=this._stack[this._index];return t.Reset(),t}}Pop(){--this._index}FindByName(t){const s=this._stack;for(let e=this._index;0<=e;--e){const i=s[e];if(i.GetName()===t)return i}return null}_GetStack(){return this._stack.slice(0,this._index+1)}}}{const C33=self.C3;C33.Loop=class extends C33.DefendedBase{constructor(e){super(),this._loopStack=e,this._name="",this._index=0,this._isStopped=!1,this._end=NaN}Reset(){this._name="",this._index=0,this._isStopped=!1,this._end=NaN}SetName(e){this._name=e}GetName(){return this._name}SetIndex(e){this._index=e}GetIndex(){return this._index}Stop(){this._isStopped=!0}IsStopped(){return this._isStopped}SetEnd(e){this._end=e}GetEnd(){return this._end}}}{const C33=self.C3;C33.ArrayStack=class extends C33.DefendedBase{constructor(){super(),this._stack=[],this._index=-1}Release(){C33.clearArray(this._stack)}GetCurrent(){return this._stack[this._index]}Push(){if(++this._index,this._index!==this._stack.length)return this._stack[this._index];{const e=[];return this._stack.push(e),e}}Pop(){--this._index}}}{let SortSolArray2=function(e,t){return e.GetIndex()-t.GetIndex()},IsSolArrayIdentical2=function(s,i){for(let e=0,t=s.length;e<t;++e)if(s[e]!==i[e])return!1;return!0};SortSolArray=SortSolArray2,IsSolArrayIdentical=IsSolArrayIdentical2;const C33=self.C3,assert=self.assert;C33.EventSheetManager=class extends C33.DefendedBase{constructor(e){super(),this._runtime=e,this._allSheets=[],this._sheetsByName=new Map,this._allGroups=[],this._groupsByName=new Map,this._blocksBySid=new Map,this._cndsBySid=new Map,this._actsBySid=new Map,this._allUniqueSolModifiers=new Map,this._eventVarsBySid=new Map,this._nextLocalVarIndex=0,this._allGlobalVars=[],this._allLocalVars=[],this._localVarInitialValues=[],this._functionBlocksByName=new Map,this._customActionBlocksMap=new Map,this._eventStack=C33.New(C33.EventStack,this),this._localVarStack=C33.New(C33.LocalVarStack,this),this._loopStack=C33.New(C33.LoopStack,this),this._triggersToPostInit=[],this._queuedTriggers=[],this._queuedDebugTriggers=[],this._runningEventsDepth=0,this._executingTriggerDepth=0,this._blockFlushingDepth=0,this._scheduledWaits=[],this._asyncActionPromises=[],this._signalTags=[],this._signalPromises=new Map,this._instSignals=new Map,self.c3_callFunction=(e,t)=>this._InvokeFunctionFromJS(e,t)}Release(){this.ClearAllScheduledWaits(),this._eventStack.Release(),this._eventStack=null,this._localVarStack.Release(),this._localVarStack=null,C33.clearArray(this._queuedTriggers),C33.clearArray(this._queuedDebugTriggers),this._runtime=null,C33.clearArray(this._allSheets),this._sheetsByName.clear()}Create(e){const t=C33.New(C33.EventSheet,this,e);this._allSheets.push(t),this._sheetsByName.set(t.GetName().toLowerCase(),t)}_AddTriggerToPostInit(e){this._triggersToPostInit.push(e)}_PostInit(){for(const e of this._customActionBlocksMap.values())e._CheckOverrideState();for(const t of this._functionBlocksByName.values())t._PostInit();for(const s of this._customActionBlocksMap.values())s._PostInit();for(const i of this._allSheets)i._PostInit();for(const r of this._allSheets)r._UpdateDeepIncludes();for(const n of this._triggersToPostInit)n._PostInit(!1);C33.clearArray(this._triggersToPostInit),this._localVarStack._SetInitialValues(this._localVarInitialValues)}GetRuntime(){return this._runtime}GetEventSheetByName(e){return this._sheetsByName.get(e.toLowerCase())||null}_RegisterGroup(e){this._allGroups.push(e),this._groupsByName.set(e.GetGroupName(),e)}_RegisterEventBlock(e){this._blocksBySid.set(e.GetSID(),e)}_RegisterCondition(e){this._cndsBySid.set(e.GetSID(),e)}_RegisterAction(e){this._actsBySid.set(e.GetSID(),e)}_RegisterFunctionBlock(e){switch(e.GetFunctionType()){case 0:this._functionBlocksByName.set(e.GetFunctionName().toLowerCase(),e);break;case 1:this._customActionBlocksMap.set(e.GetFunctionName().toLowerCase(),e)}}_RegisterEventVariable(e){this._eventVarsBySid.set(e.GetSID(),e),(e.IsGlobal()?this._allGlobalVars:this._allLocalVars).push(e)}_DeduplicateSolModifierList(s){2<=s.length&&s.sort(SortSolArray2);let i=this._allUniqueSolModifiers.get(s.length);i||(i=[],this._allUniqueSolModifiers.set(s.length,i));for(let e=0,t=i.length;e<t;++e){const r=i[e];if(IsSolArrayIdentical2(s,r))return r}return i.push(s),s}_GetNextLocalVarIndex(e){return this._localVarInitialValues.push(e.GetInitialValue()),this._nextLocalVarIndex++}GetEventStack(){return this._eventStack}GetCurrentEventStackFrame(){return this.GetEventStack().GetCurrentStackFrame()}GetCurrentEvent(){return this.GetCurrentEventStackFrame().GetCurrentEvent()}GetCurrentCondition(){const e=this.GetCurrentEventStackFrame(),t=e.GetCurrentEvent();return t.GetConditionAt(e.GetConditionIndex())}GetCurrentAction(){const e=this.GetCurrentEventStackFrame(),t=e.GetCurrentEvent();return t.GetActionAt(e.GetActionIndex())}GetLocalVarStack(){return this._localVarStack}GetLoopStack(){return this._loopStack}GetAllLocalVariablesInScope(e){const t=[];for(e=e.GetScopeParent();e;)C33.appendArray(t,e._GetAllLocalVariablesInScope()),e=e.GetScopeParent();return t}_GetLocalVariablesScriptInterface(e){const t={};for(const s of this.GetAllLocalVariablesInScope(e))t[s.GetJsPropName()]=s._GetScriptInterfaceDescriptor();return Object.create(Object.prototype,t)}GetEventVariableBySID(e){return this._eventVarsBySid.get(e)||null}GetEventBlockBySID(e){return this._blocksBySid.get(e)||null}GetConditionBySID(e){return this._cndsBySid.get(e)||null}GetActionBySID(e){return this._actsBySid.get(e)||null}GetFunctionBlockByName(e){return this._functionBlocksByName.get(e.toLowerCase())||null}GetCustomActionBlockByName(e,t){let s=this._customActionBlocksMap.get((e.GetName()+"."+t).toLowerCase());if(s)return s;if(!e.IsFamily())for(const i of e.GetFamilies())if(s=this._customActionBlocksMap.get((i.GetName()+"."+t).toLowerCase()))return s;return null}GetAllGlobalVariables(){return this._allGlobalVars}GetAllLocalVariables(){return this._allLocalVars}ResetAllGlobalsToInitialValue(e){for(const t of this._allGlobalVars)t.ResetToInitialValue();if(e)for(const s of this._allLocalVars)s.IsStatic()&&s.ResetToInitialValue()}GetEventGroupByName(e){return this._groupsByName.get(e.toLowerCase())||null}GetEventGroupBySID(e){const t=this._blocksBySid.get(e);return t&&t.IsGroup()?t:null}GetAllGroups(){return this._allGroups}ResetAllGroupsInitialActivation(){for(const e of this._allGroups)e.ResetInitialActivation()}_ResetAllHasRunFlags(){for(const e of this._allSheets)e._ResetHasRunFlag()}RunEvents(e){this._ResetAllHasRunFlags(),this._runningEventsDepth++;for(const t of e.runningLayouts()){const s=t.GetEventSheet();s&&(this._runtime.PushCurrentLayout(t),s.Run(),this._runtime.PopCurrentLayout())}this._runningEventsDepth--}async DebugRunEvents(e){this._ResetAllHasRunFlags(),this._runningEventsDepth++;for(const t of this._DebugRunEventsGen(e))await this._runtime.DebugBreak(t);this._runningEventsDepth--}*_DebugRunEventsGen(e){for(const t of e.runningLayouts()){const s=t.GetEventSheet();s&&(this._runtime.PushCurrentLayout(t),yield*s.DebugRun(),this._runtime.PopCurrentLayout())}}_Trigger(e,t,s,i){let r=!1;if(!e.GetMainRunningLayout())return this.QueueTrigger(t,s,i);this._executingTriggerDepth++;for(const n of e.runningLayouts()){const a=n.GetEventSheet();if(a){this._runtime.PushCurrentLayout(n);for(const l of a.deepIncludes()){const h=l._Trigger(t,s,i);r=r||h}const o=a._Trigger(t,s,i);r=r||o,this._runtime.PopCurrentLayout()}}return this._executingTriggerDepth--,r}*_DebugTrigger(e,t,s,i){let r=!1;if(!e.GetMainRunningLayout())return this.QueueTrigger(t,s,i);this._executingTriggerDepth++;for(const n of e.runningLayouts()){const a=n.GetEventSheet();if(a){this._runtime.PushCurrentLayout(n);for(const l of a.deepIncludes()){const h=yield*l._DebugTrigger(t,s,i);r=r||h}const o=yield*a._DebugTrigger(t,s,i);r=r||o,this._runtime.PopCurrentLayout()}}return this._executingTriggerDepth--,r}QueueTrigger(e,t,s){return this._queuedTriggers.push([e,t,s]),!1}QueueDebugTrigger(e,t,s){let i=null,r=new Promise(e=>i=e);return this._queuedDebugTriggers.push([e,t,s,i]),r}*_RunQueuedDebugTriggersGen(){if(this._runtime.HitBreakpoint())throw new Error("should not be in breakpoint");const e=this._runtime.GetLayoutManager();for(;this._queuedDebugTriggers.length;){const[t,s,i,r]=this._queuedDebugTriggers.shift(),n=yield*this._DebugTrigger(e,t,s,i);r(n)}}async RunQueuedDebugTriggersAsync(){for(const e of this._RunQueuedDebugTriggersGen())await this._runtime.DebugBreak(e)}_FastTrigger(e,s,i,r){let n=!1,t=e.GetMainRunningLayout(),a=t.GetEventSheet();if(a){this._executingTriggerDepth++,this._runtime.PushCurrentLayout(t);const o=a.deepIncludes();for(let e=0,t=o.length;e<t;++e){const h=o[e]._FastTrigger(s,i,r);n=n||h}const l=a._FastTrigger(s,i,r);return n=n||l,this._runtime.PopCurrentLayout(),this._executingTriggerDepth--,n}}*_DebugFastTrigger(e,s,i,r){let n=!1,t=e.GetMainRunningLayout(),a=t.GetEventSheet();if(a){this._executingTriggerDepth++,this._runtime.PushCurrentLayout(t);const o=a.deepIncludes();for(let e=0,t=o.length;e<t;++e){const h=yield*o[e]._DebugFastTrigger(s,i,r);n=n||h}const l=yield*a._DebugFastTrigger(s,i,r);return n=n||l,this._runtime.PopCurrentLayout(),this._executingTriggerDepth--,n}}GetTriggerDepth(){return this._executingTriggerDepth}IsInTrigger(){return 0<this.GetTriggerDepth()}_IncTriggerDepth(){return++this._executingTriggerDepth}_DecTriggerDepth(){--this._executingTriggerDepth}IsRunningEvents(){return 0<this._runningEventsDepth}IsInEventEngine(){return this.IsRunningEvents()||this.IsInTrigger()}_RunQueuedTriggers(e){for(const[t,s,i]of this._queuedTriggers)this._Trigger(e,t,s,i);C33.clearArray(this._queuedTriggers)}BlockFlushingInstances(e){e?this._blockFlushingDepth++:this._blockFlushingDepth--}IsFlushingBlocked(){return 0<this._blockFlushingDepth}ClearSol(s){for(let e=0,t=s.length;e<t;++e)s[e].GetSolStack().Clear()}PushCleanSol(s){for(let e=0,t=s.length;e<t;++e)s[e].GetSolStack().PushClean()}PushCopySol(s){for(let e=0,t=s.length;e<t;++e)s[e].GetSolStack().PushCopy()}PopSol(s){for(let e=0,t=s.length;e<t;++e)s[e].GetSolStack().Pop()}GetDynamicSolModifiersSet(t){const s=new Set,i=this._eventStack.GetAllStackFrames(),r=this._eventStack.GetCurrentStackFrameIndex();for(let e=0;e<=r;++e){const n=i[e].GetDynamicSolModifiers();if(n)for(const a of n)t&&t.has(a)||s.add(a)}return s}PushCleanSolDynamic(e){const t=new Set([...e]),s=this.GetDynamicSolModifiersSet(t);if(0<s.size){for(const i of s)i.GetSolStack().PushClean();return[...s]}return null}AddScheduledWait(){const e=C33.New(C33.ScheduledWait,this);return this._scheduledWaits.push(e),e}scheduledWaits(){return this._scheduledWaits}RunScheduledWaits(){if(this._scheduledWaits.length){let s=this.GetCurrentEventStackFrame(),i=!1;this._runningEventsDepth++;for(let e=0,t=this._scheduledWaits.length;e<t;++e){const r=this._scheduledWaits[e];r._ShouldRun()&&r._Run(s),r.ShouldRelease()&&(i=!0)}i&&(this._FilterScheduledWaitsToRelease(),s.Reset(null)),this._runningEventsDepth--}}async DebugRunScheduledWaits(){if(this._scheduledWaits.length){let s=this.GetCurrentEventStackFrame(),i=!1;this._runningEventsDepth++;for(let e=0,t=this._scheduledWaits.length;e<t;++e){const r=this._scheduledWaits[e];r._ShouldRun()&&await r._DebugRun(s),r.ShouldRelease()&&(i=!0)}i&&(this._FilterScheduledWaitsToRelease(),s.Reset(null)),this._runningEventsDepth--}}_FilterScheduledWaitsToRelease(){const e=C33.arrayFilterOut(this._scheduledWaits,e=>e.ShouldRelease());for(const t of e)t.Release()}ClearAllScheduledWaits(){for(const e of this._scheduledWaits)e.Release();C33.clearArray(this._scheduledWaits)}_OnInstancesReleased(e){for(const t of this._scheduledWaits)t.RemoveInstances(e);for(const s of e){const i=this._instSignals.get(s);if(this._instSignals.delete(s),i)for(const{resolve:r}of i.signalPromises.values())r(!0)}}AddAsyncActionPromise(e){this._asyncActionPromises.push({promise:e,triggerDepth:this.GetTriggerDepth()})}ClearAsyncActionPromises(){C33.clearArray(this._asyncActionPromises)}ClearNestedAsyncActionPromises(){const t=this.GetTriggerDepth();this._asyncActionPromises=this._asyncActionPromises.filter(e=>e.triggerDepth<=t)}GetPromiseForAllAsyncActions(){const e=Promise.all(this._asyncActionPromises.map(e=>e.promise));return this._asyncActionPromises=[],e}Signal(e){const t=e.toLowerCase();this._signalTags.push(t),this._runtime.Trigger(C33.Plugins.System.Cnds.OnSignal,null),this._signalTags.pop();for(const i of this._runtime.GetEventSheetManager().scheduledWaits())i.IsSignal()&&i.GetSignalTag()===t&&i.SetSignalled();const s=this._signalPromises.get(t);s&&(s.resolve(),this._signalPromises.delete(t))}WaitForSignal(e){const s=e.toLowerCase(),t=this._signalPromises.get(s);if(t)return t.promise;{let t=null,e=new Promise(e=>t=e);return this._signalPromises.set(s,{promise:e,resolve:t}),e}}GetCurrentSignalTag(){if(0===this._signalTags.length)throw new Error("not in a signal");return this._signalTags.at(-1)}_GetInstanceSignalState(e){let t=this._instSignals.get(e);return t||(t={signalTags:[],signalPromises:new Map},this._instSignals.set(e,t)),t}InstanceSignal(e,t){const s=this._GetInstanceSignalState(e),i=t.toLowerCase();s.signalTags.push(i),this._runtime.Trigger(e.GetPlugin().GetConstructor().Cnds.OnInstanceSignal,e),s.signalTags.pop();for(const n of this._runtime.GetEventSheetManager().scheduledWaits())n.IsInstanceSignals()&&n.GetSignalTag()===i&&n.SetInstanceSignalled(e);const r=s.signalPromises.get(i);r&&(r.resolve(!1),s.signalPromises.delete(i)),0===s.signalTags.length&&0===s.signalPromises.size&&this._instSignals.delete(e)}WaitForInstanceSignal(e,t){const s=this._GetInstanceSignalState(e),i=t.toLowerCase(),r=s.signalPromises.get(i);if(r)return r.promise;{let t=null,e=new Promise(e=>t=e);return s.signalPromises.set(i,{promise:e,resolve:t}),e}}GetCurrentInstanceSignalTag(e){const t=this._GetInstanceSignalState(e);if(t&&0!==t.signalTags.length)return t.signalTags.at(-1);throw new Error("not in a signal")}_SaveToJson(){return{groups:this._SaveGroupsToJson(),cnds:this._SaveCndsToJson(),acts:this._SaveActsToJson(),vars:this._SaveVarsToJson(),waits:this._SaveScheduledWaitsToJson()}}_LoadFromJson(e){this._LoadGroupsFromJson(e.groups),this._LoadCndsFromJson(e.cnds),this._LoadActsFromJson(e.acts),this._LoadVarsFromJson(e.vars),this._LoadScheduledWaitsFromJson(e.waits)}_SaveGroupsToJson(){const e={};for(const t of this.GetAllGroups())e[t.GetSID().toString()]=t.IsGroupActive();return e}_LoadGroupsFromJson(e){for(const[t,s]of Object.entries(e)){const i=parseInt(t,10),r=this.GetEventGroupBySID(i);r&&r.SetGroupActive(s)}}_SaveCndsToJson(){const e={};for(const[t,s]of this._cndsBySid){const i=s._SaveToJson();i&&(e[t.toString()]=i)}return e}_LoadCndsFromJson(e){const t=new Map;for(const[s,i]of Object.entries(e))t.set(parseInt(s,10),i);for(const[r,n]of this._cndsBySid)n._LoadFromJson(t.get(r)||null)}_SaveActsToJson(){const e={};for(const[t,s]of this._actsBySid){const i=s._SaveToJson();i&&(e[t.toString()]=i)}return e}_LoadActsFromJson(e){const t=new Map;for(const[s,i]of Object.entries(e))t.set(parseInt(s,10),i);for(const[r,n]of this._actsBySid)n._LoadFromJson(t.get(r)||null)}_SaveVarsToJson(){const e={};for(const[t,s]of this._eventVarsBySid)s.IsConstant()||!s.IsGlobal()&&!s.IsStatic()||(e[t.toString()]=s.GetValue());return e}_LoadVarsFromJson(e){for(const[t,s]of Object.entries(e)){const i=parseInt(t,10),r=this.GetEventVariableBySID(i);r&&r.SetValue(s)}}_SaveScheduledWaitsToJson(){return this._scheduledWaits.filter(e=>!e.IsPromise()).map(e=>e._SaveToJson())}_LoadScheduledWaitsFromJson(e){this.ClearAllScheduledWaits();for(const t of e){const s=C33.ScheduledWait._CreateFromJson(this,t);s&&this._scheduledWaits.push(s)}}_GetPerfRecords(){return[...this._runtime.GetLayoutManager().runningLayouts()].map(e=>e.GetEventSheet()).filter(e=>e).map(e=>e._GetPerfRecord())}FindFirstFunctionBlockParent(e){for(;e;){const t=e.GetScopeParent();if(t instanceof C33.FunctionBlock)return t;e=t}return null}_InvokeFunctionFromJS(e,t){Array.isArray(t)||(t=[]);const s=this.GetFunctionBlockByName(e.toLowerCase());if(!s)return null;if(!s.IsEnabled())return s.GetDefaultReturnValue();const i=s.GetFunctionParameters();if(t.length<i.length)for(t=t.slice(0);t.push(i[t.length].GetInitialValue()),t.length<i.length;);const r=s.GetEventBlock();return r.RunAsExpressionFunctionCall(r.GetSolModifiersIncludingParents(),!1,s.GetReturnType(),s.GetDefaultReturnValue(),...t)}}}{const C33=self.C3;C33.EventSheet=class extends C33.DefendedBase{constructor(e,t){super(),this._eventSheetManager=e,this._runtime=e.GetRuntime(),this._name=t[0],this._events=[],this._triggers=new Map,this._fastTriggers=new Map,this._eventsByDisplayNumber=new Map,this._hasRun=!1,this._shallowIncludes=[],this._deepIncludes=[],this._alreadyIncludedSheets=new Set;for(const s of t[1])this._CreateEvent(s,null,this._events);this._perfRecord=this._runtime.IsDebug()?{type:"sheet",name:this._name,totalTimeCounter:0,children:[]}:null}Release(){this._eventSheetManager=null,this._runtime=null}_CreateEvent(e,t,s){switch(e[0]){case 0:case 3:this._CreateEventBlock(e,t,s);break;case 1:this._CreateEventVariable(e,t,s);break;case 2:this._CreateInclude(e,t,s);break;case 4:this._CreateFunctionBlock(e,t);break;case 5:this._CreateScriptBlock(e,t,s);break;case 6:this._CreateCustomACEBlock(e,t);break;default:throw new Error("invalid event type")}}_CreateEventBlock(e,t,s){const i=C33.EventBlock.Create(this,t,e);if(i.IsOrBlock()){s.push(i);const r=i.GetConditions();for(let e=0,t=r.length;e<t;++e)r[e].IsTrigger()&&this._InitTrigger(i,e)}else i.IsTrigger()?this._InitTrigger(i,0):s.push(i)}_CreateFunctionBlock(e,t){const s=C33.FunctionBlock.CreateFunctionBlock(this,t,e);this._eventSheetManager._RegisterFunctionBlock(s)}_CreateCustomACEBlock(e,t){const s=C33.FunctionBlock.CreateCustomACEBlock(this,t,e);this._eventSheetManager._RegisterFunctionBlock(s)}_CreateEventVariable(e,t,s){const i=C33.EventVariable.Create(this,t,e);s.push(i)}_CreateInclude(e,t,s){const i=C33.EventInclude.Create(this,t,e);s.push(i)}_CreateScriptBlock(e,t,s){const i=C33.EventScript.Create(this,t,e);s.push(i)}_InitTrigger(r,n){r.IsOrBlock()||this._eventSheetManager._AddTriggerToPostInit(r);const a=r.GetConditionAt(n),o=a._GetFunc(),l=a.GetObjectClass();if(a.IsFastTrigger()){let e=this._fastTriggers.get(l),t=(e||(e=new Map,this._fastTriggers.set(l,e)),a.GetFastTriggerValue().toLowerCase()),s=e.get(o),i=(s||(s=new Map,e.set(o,s)),s.get(t));i||(i=[],s.set(t,i)),i.push([r,n])}else{let e=this._triggers.get(l),t=(e||(e={methodMap:new Map,behaviors:new Map},this._triggers.set(l,e)),a.GetBehaviorType()),s,i=(t?(s=e.behaviors.get(t))||(s=new Map,e.behaviors.set(t,s)):s=e.methodMap,s.get(o));i||(i=[],s.set(o,i)),i.push([r,n])}}_PostInit(){const s=this._events;for(let e=0,t=s.length;e<t;++e){const i=e<t-1&&s[e+1]instanceof C33.EventBlock&&s[e+1].IsElseBlock();s[e]._PostInit(i)}}_AddShallowInclude(e){this._shallowIncludes.push(e)}_UpdateDeepIncludes(){C33.clearArray(this._deepIncludes),this._AddDeepIncludes(this),this._alreadyIncludedSheets.clear()}_AddDeepIncludes(e){const t=e._deepIncludes,s=e._alreadyIncludedSheets;for(const i of this._shallowIncludes){const r=i.GetIncludeSheet();i.IsActive()&&e!==r&&!s.has(r)&&(s.add(r),r._AddDeepIncludes(e),t.push(r))}}deepIncludes(){return this._deepIncludes}GetEventSheetManager(){return this._eventSheetManager}GetRuntime(){return this._runtime}GetName(){return this._name}_RegisterEventByDisplayNumber(e,t){this._eventsByDisplayNumber.set(t,e)}_GetEventByDisplayNumber(e){return this._eventsByDisplayNumber.get(e)||null}_ResetHasRunFlag(){this._hasRun=!1}Run(){if(!this._hasRun){const e=this._runtime,t=e.IsCPUProfiling(),s=t?performance.now():0,i=(this._hasRun=!0,this.GetEventSheetManager()),r=i.GetCurrentEventStackFrame();for(const n of this._events)n.Run(r),i.ClearSol(n.GetSolModifiers()),i.ClearAsyncActionPromises(),e.FlushPendingInstances();r.Reset(null),t&&(this._perfRecord.totalTimeCounter+=performance.now()-s)}}*DebugRun(){if(!this._hasRun){this._hasRun=!0;const e=this._runtime,t=this.GetEventSheetManager(),s=t.GetCurrentEventStackFrame();for(const i of this._events)yield*i.DebugRun(s),t.ClearSol(i.GetSolModifiers()),t.ClearAsyncActionPromises(),e.FlushPendingInstances();s.Reset(null)}}_Trigger(i,r,n){if(!r)return this._TriggerForClass(i,r,null,null);{let e=r.GetObjectClass(),t=!1,s=this._TriggerForClass(i,r,e,n);t=t||s;for(const a of e.GetFamilies())s=this._TriggerForClass(i,r,a,n),t=t||s}}_TriggerForClass(e,t,s,i){const r=this._triggers.get(s);if(!r)return!1;const n=i?r.behaviors.get(i):r.methodMap;if(!n)return!1;const a=n.get(e);if(!a)return!1;let o=!1;for(const[l,h]of a){const c=this._ExecuteTrigger(t,l,h);o=o||c}return o}*_DebugTrigger(i,r,n){if(!r)return yield*this._DebugTriggerForClass(i,r,null,null);{let e=r.GetObjectClass(),t=!1,s=yield*this._DebugTriggerForClass(i,r,e,n);t=t||s;for(const a of e.GetFamilies())s=yield*this._DebugTriggerForClass(i,r,a,n),t=t||s}}*_DebugTriggerForClass(e,t,s,i){const r=this._triggers.get(s);if(!r)return!1;const n=i?r.behaviors.get(i):r.methodMap;if(!n)return!1;const a=n.get(e);if(!a)return!1;let o=!1;for(const[l,h]of a){let e;e=l.DebugCanRunFast()?this._ExecuteTrigger(t,l,h):yield*this._DebugExecuteTrigger(t,l,h),o=o||e}return o}_FastTrigger(e,t,s){const i=t.GetObjectClass(),r=this._fastTriggers.get(i);if(!r)return!1;const n=r.get(e);if(!n)return!1;const a=n.get(s);if(!a)return!1;let o=!1;for(let e=0,t=a.length;e<t;++e){const l=a[e],h=this._ExecuteTrigger(null,l[0],l[1]);o=o||h}return o}*_DebugFastTrigger(e,t,s){const i=t.GetObjectClass(),r=this._fastTriggers.get(i);if(!r)return!1;const n=r.get(e);if(!n)return!1;const a=n.get(s);if(!a)return!1;let o=!1;for(let r=0,e=a.length;r<e;++r){let e=a[r],t=e[0],s=e[1],i;i=t.DebugCanRunFast()?this._ExecuteTrigger(null,t,s):yield*this._DebugExecuteTrigger(null,t,s),o=o||i}return o}_ExecuteTrigger(e,t,s){let i=this._runtime,r=this._eventSheetManager,n=r.GetCurrentEvent(),a=r.GetEventStack(),o=r.GetTriggerDepth(),l=!1;n&&r.PushCleanSol(n.GetSolModifiersIncludingParents()),r.PushCleanSol(t.GetSolModifiersIncludingParents());const h=1<o,c=(h&&r.GetLocalVarStack().Push(),a.Push(t));if(e){const _=t.GetConditions()[s].GetObjectClass(),d=_.GetCurrentSol();d.SetSinglePicked(e),e.IsInContainer()&&e.SetSiblingsSinglePicked()}let u=!0;if(t.GetParent()){const p=t.GetTriggerParents();for(let e=0,t=p.length;e<t;++e)if(!p[e].RunPreTrigger(c)){u=!1;break}}return u&&(t.IsOrBlock()?t.RunOrBlockTrigger(c,s):t.Run(c),l=c.GetLastEventTrue()),a.Pop(),h&&r.GetLocalVarStack().Pop(),r.PopSol(t.GetSolModifiersIncludingParents()),n&&r.PopSol(n.GetSolModifiersIncludingParents()),n||1!==o||(r.ClearAsyncActionPromises(),r.IsFlushingBlocked())||i.FlushPendingInstances(),l}*_DebugExecuteTrigger(e,t,s){let i=this._runtime,r=this._eventSheetManager,n=r.GetCurrentEvent(),a=r.GetEventStack(),o=r.GetTriggerDepth(),l=!1;n&&r.PushCleanSol(n.GetSolModifiersIncludingParents()),r.PushCleanSol(t.GetSolModifiersIncludingParents());const h=1<o,c=(h&&r.GetLocalVarStack().Push(),a.Push(t));if(e){const _=t.GetConditions()[s].GetObjectClass(),d=_.GetCurrentSol();d.SetSinglePicked(e),e.IsInContainer()&&e.SetSiblingsSinglePicked()}let u=!0;if(t.GetParent()){const p=t.GetTriggerParents();for(let e=0,t=p.length;e<t;++e)if(!(yield*p[e].DebugRunPreTrigger(c))){u=!1;break}}return u&&(t.IsOrBlock()?yield*t.DebugRunOrBlockTrigger(c,s):yield*t.DebugRun(c),l=c.GetLastEventTrue()),a.Pop(),h&&r.GetLocalVarStack().Pop(),r.PopSol(t.GetSolModifiersIncludingParents()),n&&r.PopSol(n.GetSolModifiersIncludingParents()),n||1!==o||(r.ClearAsyncActionPromises(),r.IsFlushingBlocked())||i.FlushPendingInstances(),l}_GetPerfRecord(){return this._perfRecord}}}{let NoActions2=function(e,t){return!0};NoActions=NoActions2;const C33=self.C3,EMPTY_ARRAY=[];function*DebugNoActions(e,t){return!0}C33.EventBlock=class extends C33.DefendedBase{constructor(e,t,s){super(),this._eventSheet=e,this._runtime=e.GetRuntime(),this._parent=t,this._scopeParent=null,this._eventStack=this._runtime.GetEventSheetManager().GetEventStack(),this._solModifiers=[],this._solModifiersIncludingParents=[],this._hasGotSolModifiersIncludingParents=!1,this._isSolWriterAfterCnds=!1,this._isTopLevelGroup=!1,this._hasElseBlock=!1,this._isOrBlock=!!s[2],this._isElseBlock=!1,this._triggerParents=null,this._conditions=[],this._actions=[],this._subEvents=[],this._RunActions=NoActions2,this._DebugRunActions=DebugNoActions,this._isGroup=!1,this._isInitiallyActive=!1,this._groupName="",this._isGroupActive=!1,this._containedIncludes=null,this._perfRecord=null,this._sid=s[4],this._displayNumber=s[5],this._eventSheet._RegisterEventByDisplayNumber(this,this._displayNumber),this._debugData=this._runtime.IsDebug()?{isBreakpoint:s[3][0],isBreakable:s[3][1],canRunAllConditionsFast:!1,canRunAllActionsFast:!1,canRunAllSubEventsFast:!1,canRunSelfFast:!1}:null,this.GetEventSheetManager()._RegisterEventBlock(this),3===s[0]&&this._InitGroup(s[1]);let i=0;for(const r of s[6]){const n=C33.Condition.Create(this,r,i++);this._conditions.push(n),this._AddSolModifier(n.GetObjectClass())}i=0;for(const a of s[7]){const o=C33.Action.Create(this,a,i++);this._actions.push(o)}if(9===s.length){const l=s[8];for(const h of l)this._eventSheet._CreateEvent(h,this,this._subEvents)}this._conditions.length&&(this._isElseBlock=null===this._conditions[0].GetObjectClass()&&this._conditions[0]._GetFunc()===C33.Plugins.System.Cnds.Else),0===this._conditions.length&&(this._conditions=EMPTY_ARRAY),0===this._actions.length&&(this._actions=EMPTY_ARRAY),0===this._subEvents.length&&(this._subEvents=EMPTY_ARRAY)}static Create(e,t,s){return C33.New(C33.EventBlock,e,t,s)}_InitGroup(e){this._isGroup=!0,this._isInitiallyActive=!!e[0],this._isGroupActive=this._isInitiallyActive,this._groupName=e[1].toLowerCase(),this._containedIncludes=[],this.GetEventSheetManager()._RegisterGroup(this),this._runtime.IsDebug()&&(this._perfRecord={type:"group",name:e[1],totalTimeCounter:0,children:[]})}_AddContainedInclude(e){this._containedIncludes.push(e)}_AddContainerSolModifierToList(e,t){for(const s of e.GetContainer().objectTypes())t.includes(s)||t.push(s)}_AddSolModifierToList(e,t){if(e)if(t.includes(e)||t.push(e),e.IsFamily())for(const s of e.GetFamilyMembers())s.IsInContainer()&&this._AddContainerSolModifierToList(s,t);else e.IsInContainer()&&this._AddContainerSolModifierToList(e,t)}_AddSolModifier(e){this._AddSolModifierToList(e,this._solModifiers)}_AddParentSolModifier(e){this._AddSolModifierToList(e,this._solModifiersIncludingParents)}SetAllSolModifiers(){this._solModifiers=this._runtime.GetAllObjectClasses()}_PostInit(e){this._hasElseBlock=!!e,this._IdentifyTopLevelGroup(),this._IdentifyTriggerParents();for(const t of this._conditions)t._PostInit();if(0<this._actions.length){let e=!1;for(const i of this._actions)i._PostInit(),i.HasReturnType()&&(e=!0);e?(this._RunActions=this._RunActions_ReturnValue,this._DebugRunActions=this._DebugRunActions_ReturnValue):(this._RunActions=this._RunActions_Fast,this._DebugRunActions=this._DebugRunActions_Fast)}const s=this._subEvents;for(let e=0,t=s.length;e<t;++e){const r=e<t-1&&s[e+1]instanceof C33.EventBlock&&s[e+1].IsElseBlock();s[e]._PostInit(r)}this._debugData&&this._UpdateCanRunFast(),this._perfRecord&&this._GetPerfRecordParent()._GetPerfRecord().children.push(this._perfRecord)}_GetPerfRecord(){return this._perfRecord}_GetPerfRecordParent(){let e=this.GetParent();for(;e;){if(e.IsGroup())return e;e=e.GetParent()}return this._eventSheet}_UpdateCanRunFast(){const e=this._debugData;e.canRunAllConditionsFast=this._conditions.every(e=>e.DebugCanRunFast()),e.canRunAllActionsFast=this._actions.every(e=>e.DebugCanRunFast()),e.canRunAllSubEventsFast=this._subEvents.every(e=>e.DebugCanRunFast()),e.canRunSelfFast=e.canRunAllConditionsFast&&e.canRunAllActionsFast&&e.canRunAllSubEventsFast}_UpdateCanRunFastRecursive(){let e=this;for(;e._UpdateCanRunFast(),e=e.GetParent(););}_IdentifyTopLevelGroup(){if(this.IsGroup()){let e=this.GetParent();for(this._isTopLevelGroup=!0;e;){if(!e.IsGroup()){this._isTopLevelGroup=!1;break}e=e.GetParent()}}}_IdentifySolModifiersIncludingParents(){const e=this._runtime.GetAllObjectClasses();if(this._solModifiers===e)this._solModifiersIncludingParents=e;else{this._solModifiersIncludingParents=C33.cloneArray(this._solModifiers);let e=this.GetParent();for(;e;){for(const s of e._solModifiers)this._AddParentSolModifier(s);e=e.GetParent()}const t=this.GetEventSheetManager();this._solModifiers=t._DeduplicateSolModifierList(this._solModifiers),this._solModifiersIncludingParents=t._DeduplicateSolModifierList(this._solModifiersIncludingParents)}}_IdentifyTriggerParents(){if(this.HasAnyTriggeredCondition()){this._triggerParents=[];let e=this.GetParent();for(;e;)this._triggerParents.push(e),e=e.GetParent();this._triggerParents.reverse()}}SetSolWriterAfterCnds(){this._isSolWriterAfterCnds=!0,this._parent&&this._parent.SetSolWriterAfterCnds()}IsSolWriterAfterCnds(){return this._isSolWriterAfterCnds}GetSolModifiers(){return this._solModifiers}GetSolModifiersIncludingParents(){return this._hasGotSolModifiersIncludingParents||(this._hasGotSolModifiersIncludingParents=!0,this._IdentifySolModifiersIncludingParents()),this._solModifiersIncludingParents}HasSolModifier(e){return this._solModifiers.includes(e)}GetTriggerParents(){return this._triggerParents}GetEventSheet(){return this._eventSheet}GetEventSheetManager(){return this._eventSheet.GetEventSheetManager()}GetRuntime(){return this._runtime}GetParent(){return this._parent}_SetScopeParent(e){this._scopeParent=e}GetScopeParent(){return this._scopeParent||this._parent}GetDisplayNumber(){return this._displayNumber}IsDebugBreakable(){return this._debugData&&this._debugData.isBreakable}IsDebugBreakpoint(){return this.IsDebugBreakable()&&this._debugData.isBreakpoint}_SetDebugBreakpoint(e){this._debugData.isBreakpoint=!!e,this._UpdateCanRunFastRecursive()}IsGroup(){return this._isGroup}IsTopLevelGroup(){return this._isTopLevelGroup}IsElseBlock(){return this._isElseBlock}HasElseBlock(){return this._hasElseBlock}GetGroupName(){return this._groupName}IsGroupActive(){return this._isGroupActive}ResetInitialActivation(){this.SetGroupActive(this._isInitiallyActive)}SetGroupActive(e){if(e=!!e,!this._isGroup)throw new Error("not a group");if(this._isGroupActive!==e){this._isGroupActive=e;for(const t of this._containedIncludes)t.UpdateActive();if(this._containedIncludes.length){const s=this._runtime.GetCurrentLayout(),i=s.GetEventSheet();i&&i._UpdateDeepIncludes()}}}GetSID(){return this._sid}IsOrBlock(){return this._isOrBlock}IsTrigger(){return this._conditions.length&&this._conditions[0].IsTrigger()}IsForFunctionBlock(){return this._scopeParent&&this._scopeParent instanceof C33.FunctionBlock}HasAnyTriggeredCondition(){return this.IsForFunctionBlock()||this._conditions.some(e=>e.IsTrigger())}GetConditions(){return this._conditions}GetConditionCount(){return this._conditions.length}GetConditionAt(e){if((e=Math.floor(e))<0||e>=this._conditions.length)throw new RangeError("invalid condition index");return this._conditions[e]}GetConditionByDebugIndex(e){return this.GetConditionAt(e)}IsFirstConditionOfType(e){let t=e.GetIndex();if(0!==t){--t;const s=e.IsSystemOrSingleGlobalCondition()?e.GetFirstObjectParameterObjectClass():e.GetObjectClass();for(;0<=t;--t){const i=this._conditions[t];if(s===i.GetObjectClass()||i.IsSystemOrSingleGlobalCondition()&&i.GetFirstObjectParameterObjectClass()===s)return!1}}return!0}GetActions(){return this._actions}GetActionCount(){return this._actions.length}GetActionAt(e){if((e=Math.floor(e))<0||e>=this._actions.length)throw new RangeError("invalid action index");return this._actions[e]}GetActionByDebugIndex(t){t=Math.floor(t);const e=this._actions.find(e=>e.GetDebugIndex()===t);if(e)return e;throw new RangeError("invalid action debug index")}_HasActionIndex(e){return 0<=(e=Math.floor(e))&&e<this._actions.length}GetSubEvents(){return this._subEvents}_GetAllLocalVariablesInScope(){return this._subEvents.filter(e=>e instanceof C33.EventVariable)}RunPreTrigger(s){s.SetCurrentEvent(this);let i=this._conditions,r=0===i.length;for(let e=0,t=i.length;e<t;++e){const n=i[e];if(s.SetConditionIndex(e),n.IsLooping())throw new Error("trigger cannot be used as sub-event to a loop");if(n.Run())r=!0;else if(!this._isOrBlock)return!1}return!this._isOrBlock||r}RunOrBlockTrigger(e,t){e.SetCurrentEvent(this),e.SetConditionIndex(t),this._conditions[t].Run()&&(this._RunActions(e,0)&&this._RunSubEvents(e),e.SetLastEventTrue(!0))}*DebugRunPreTrigger(s){s.SetCurrentEvent(this);let i=this._conditions,r=0===i.length;for(let e=0,t=i.length;e<t;++e){const n=i[e];if(s.SetConditionIndex(e),n.IsLooping())throw new Error("trigger cannot be used as sub-event to a loop");if(n.DebugCanRunFast()?n.Run():yield*n.DebugRun())r=!0;else if(!this._isOrBlock)return!1}return!this._isOrBlock||r}*DebugRunOrBlockTrigger(e,t){e.SetCurrentEvent(this),e.SetConditionIndex(t);let s=this._conditions[t];if(s.DebugCanRunFast()?s.Run():yield*s.DebugRun())(this.DebugCanRunActionsFast()?this._RunActions(e,0):yield*this._DebugRunActions(e,0))&&(this.DebugCanRunSubEventsFast()?this._RunSubEvents():yield*this._DebugRunSubEvents()),e.SetLastEventTrue(!0)}Run(e){e.SetCurrentEvent(this),this._isElseBlock||e.SetElseBranchRan(!1),this._isOrBlock?this._RunOrBlock(e):this._RunAndBlock(e)}*DebugRun(e){(this.IsDebugBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),e.SetCurrentEvent(this),this._isElseBlock||e.SetElseBranchRan(!1),this._isOrBlock?yield*this._DebugRunOrBlock(e):yield*this._DebugRunAndBlock(e)}_RunOrBlock(s){let i=this._conditions,r=0===i.length;for(let e=0,t=i.length;e<t;++e){const n=i[e];if(!n.IsTrigger()){s.SetConditionIndex(e);const a=n.Run();r=r||a}}s.SetLastEventTrue(r),r&&(this._RunActions(s,0)&&this._RunSubEvents(s),this._hasElseBlock)&&s.SetElseBranchRan(!0)}*_DebugRunOrBlock(s){let i=this._conditions,r=0===i.length;for(let t=0,e=i.length;t<e;++t){const n=i[t];if(!n.IsTrigger()){s.SetConditionIndex(t);let e;e=n.DebugCanRunFast()?n.Run():yield*n.DebugRun(),r=r||e}}if(s.SetLastEventTrue(r),r)(this.DebugCanRunActionsFast()?this._RunActions(s,0):yield*this._DebugRunActions(s,0))&&(this.DebugCanRunSubEventsFast()?this._RunSubEvents():yield*this._DebugRunSubEvents()),this._hasElseBlock&&s.SetElseBranchRan(!0)}_RunAndBlock(s){const i=this._conditions;for(let e=0,t=i.length;e<t;++e){const r=i[e],n=(s.SetConditionIndex(e),r.Run());if(!n)return void s.SetLastEventTrue(!1)}s.SetLastEventTrue(!0),this._RunActions(s,0)&&this._RunSubEvents(s),s.GetLastEventTrue()&&this._hasElseBlock&&s.SetElseBranchRan(!0)}*_DebugRunAndBlock(s){const i=this._conditions;for(let e=0,t=i.length;e<t;++e){const r=i[e];s.SetConditionIndex(e);if(!(r.DebugCanRunFast()?r.Run():yield*r.DebugRun()))return void s.SetLastEventTrue(!1)}s.SetLastEventTrue(!0);(this.DebugCanRunActionsFast()?this._RunActions(s,0):yield*this._DebugRunActions(s,0))&&(this.DebugCanRunSubEventsFast()?this._RunSubEvents():yield*this._DebugRunSubEvents()),s.GetLastEventTrue()&&this._hasElseBlock&&s.SetElseBranchRan(!0)}_RunActions_Fast(s,i){const r=this._actions;for(let e=i,t=r.length;e<t;++e){const n=r[e];s.SetActionIndex(e),n.Run()}return!0}*_DebugRunActions_Fast(s,i){const r=this._actions;for(let e=i,t=r.length;e<t;++e){const n=r[e];s.SetActionIndex(e),n.DebugCanRunFast()?n.Run():yield*n.DebugRun()}return!0}_RunActions_ReturnValue(s,i){const r=this.GetEventSheetManager(),n=this._actions;for(let e=i,t=n.length;e<t;++e){const a=n[e],o=(s.SetActionIndex(e),a.Run());if(a.CanBailOut()&&!0===o)return!1;a.IsAsync()&&o instanceof Promise&&r.AddAsyncActionPromise(o)}return!0}*_DebugRunActions_ReturnValue(s,i){const r=this.GetEventSheetManager(),n=this._actions;for(let t=i,e=n.length;t<e;++t){const a=n[t];s.SetActionIndex(t);let e;if(e=a.DebugCanRunFast()?a.Run():yield*a.DebugRun(),a.CanBailOut()&&!0===e)return!1;a.IsAsync()&&e instanceof Promise&&r.AddAsyncActionPromise(e)}return!0}_ResumeActionsAndSubEvents(e){this._RunActions(e,e.GetActionIndex())&&this._RunSubEvents()}*_DebugResumeActionsAndSubEvents(e){(yield*this._DebugRunActions(e,e.GetActionIndex()))&&(yield*this._DebugRunSubEvents())}_RunSubEvents(){if(this._subEvents.length){const e=this.IsGroup()&&this._runtime.IsCPUProfiling(),t=e?performance.now():0,s=this._eventStack,i=s.Push(this);this._isSolWriterAfterCnds?this._RunSubEvents_SolWriterAfterCnds(i):this._RunSubEvents_Fast(i),s.Pop(),e&&(this._perfRecord.totalTimeCounter+=performance.now()-t)}}_RunSubEvents_SolWriterAfterCnds(i){const r=this._isGroup,n=this._isTopLevelGroup,a=this.GetEventSheetManager(),o=this._subEvents;for(let e=0,t=o.length,s=t-1;e<t;++e){const l=o[e],h=l.GetSolModifiers(),c=!n||!r&&e<s;c&&a.PushCopySol(h),l.Run(i),c?a.PopSol(h):a.ClearSol(h)}}_RunSubEvents_Fast(s){const i=this._subEvents;for(let e=0,t=i.length;e<t;++e)i[e].Run(s)}*_DebugRunSubEvents(){if(this._subEvents.length){const e=this._eventStack,t=e.Push(this);this._isSolWriterAfterCnds?yield*this._DebugRunSubEvents_SolWriterAfterCnds(t):yield*this._DebugRunSubEvents_Fast(t),e.Pop()}}*_DebugRunSubEvents_SolWriterAfterCnds(i){const r=this._isGroup,n=this._isTopLevelGroup,a=this.GetEventSheetManager(),o=this._subEvents;for(let e=0,t=o.length,s=t-1;e<t;++e){const l=o[e],h=l.GetSolModifiers(),c=!n||!r&&e<s;c&&a.PushCopySol(h),yield*l.DebugRun(i),c?a.PopSol(h):a.ClearSol(h)}}*_DebugRunSubEvents_Fast(s){const i=this._subEvents;for(let e=0,t=i.length;e<t;++e)yield*i[e].DebugRun(s)}Retrigger(s,i){i.ResetQuick();const r=this._conditions;if(!this.IsOrBlock())for(let e=s.GetConditionIndex()+1,t=r.length;e<t;++e){const n=r[e],a=(i.SetConditionIndex(e),n.Run());if(!a)return!1}return this._RunActions(i,0)&&this._RunSubEvents(i),!0}*DebugRetrigger(s,i){i.ResetQuick();const r=this._conditions;if(!this.IsOrBlock())for(let e=s.GetConditionIndex()+1,t=r.length;e<t;++e){const n=r[e];i.SetConditionIndex(e);if(!(n.DebugCanRunFast()?n.Run():yield*n.DebugRun()))return!1}return(this.DebugCanRunActionsFast()?this._RunActions(i,0):yield*this._DebugRunActions(i,0))&&(this.DebugCanRunSubEventsFast()?this._RunSubEvents():yield*this._DebugRunSubEvents()),!0}DebugCanRunFast(){return!this.IsDebugBreakpoint()&&!this._runtime.DebugBreakNext()&&this._debugData.canRunSelfFast}DebugCanRunActionsFast(){return!this._runtime.DebugBreakNext()&&this._debugData.canRunAllActionsFast}DebugCanRunSubEventsFast(){return!this._runtime.DebugBreakNext()&&this._debugData.canRunAllSubEventsFast}_CheckParentsOKToRun(s){if(this.GetParent()){const i=this.GetTriggerParents();for(let e=0,t=i.length;e<t;++e)if(!i[e].RunPreTrigger(s))return!1}return!0}*_DebugCheckParentsOKToRun(s){if(this.GetParent()){const i=this.GetTriggerParents();for(let e=0,t=i.length;e<t;++e)if(!(yield*i[e].DebugRunPreTrigger(s)))return!1}return!0}_EvaluateFunctionCallParameters(e,t,s){if(0<t.length)if(s){const i=t.map(e=>e.Get(0));e.GetLocalVarStack().Push(),this._scopeParent.SetFunctionParameters(i)}else this._scopeParent.EvaluateFunctionParameters(t);else s&&e.GetLocalVarStack().Push()}RunAsFunctionCall(e,t,s,i){let r,n,a=0<e.length,o=null,l=this._runtime,h=this._eventStack,c=l.GetEventSheetManager(),u=this._scopeParent,_=u.IsAsync(),d=c._IncTriggerDepth(),p=1<d;if(this._EvaluateFunctionCallParameters(c,t,p),a&&(s?c.PushCopySol(e):c.PushCleanSol(e)),null!==i){if(i.copyFromObjectClass){const g=s?i.copyFromObjectClass.GetCurrentSol():i.copyFromObjectClass.GetSolStack().GetOneBelowCurrentSol(),f=i.copyToObjectClass.GetCurrentSol();f.SetArrayPicked(g.GetInstances()),f.ClearElseInstances(),s||i.copyToObjectClass.ApplySolToContainer()}else if(i.pickObjectClass){const S=i.pickObjectClass.GetCurrentSol();S.SetArrayPicked(i.pickInstances),S.ClearElseInstances()}i.pushCleanSolDynamic&&(o=c.PushCleanSolDynamic(e))}const m=h.Push(this);return s&&m.SetDynamicSolModifiers(e),this._CheckParentsOKToRun(m)&&(m.SetCurrentEvent(this),_&&([n,r]=u.StartAsyncFunctionCall()),this._RunAndBlock(m),_)&&u.MaybeFinishAsyncFunctionCall(n),h.Pop(),p&&c.GetLocalVarStack().Pop(),null!==o&&c.PopSol(o),a&&c.PopSol(e),c._DecTriggerDepth(),_||c.ClearNestedAsyncActionPromises(),r}*DebugRunAsFunctionCall(e,t,s,i){let r,n,a=((this.IsDebugBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),0<e.length),o=null,l=this._runtime,h=this._eventStack,c=l.GetEventSheetManager(),u=this._scopeParent,_=u.IsAsync(),d=c._IncTriggerDepth(),p=1<d;if(this._EvaluateFunctionCallParameters(c,t,p),a&&(s?c.PushCopySol(e):c.PushCleanSol(e)),null!==i){if(i.copyFromObjectClass){const g=s?i.copyFromObjectClass.GetCurrentSol():i.copyFromObjectClass.GetSolStack().GetOneBelowCurrentSol(),f=i.copyToObjectClass.GetCurrentSol();f.SetArrayPicked(g.GetInstances()),f.ClearElseInstances(),s||i.copyToObjectClass.ApplySolToContainer()}else if(i.pickObjectClass){const S=i.pickObjectClass.GetCurrentSol();S.SetArrayPicked(i.pickInstances),S.ClearElseInstances()}i.pushCleanSolDynamic&&(o=c.PushCleanSolDynamic(e))}const m=h.Push(this);return s&&m.SetDynamicSolModifiers(e),(yield*this._DebugCheckParentsOKToRun(m))&&(m.SetCurrentEvent(this),_&&([n,r]=u.StartAsyncFunctionCall()),yield*this._DebugRunAndBlock(m),_)&&u.MaybeFinishAsyncFunctionCall(n),h.Pop(),p&&c.GetLocalVarStack().Pop(),null!==o&&c.PopSol(o),a&&c.PopSol(e),c._DecTriggerDepth(),_||c.ClearNestedAsyncActionPromises(),r}RunAsMappedFunctionCall(e,t){const s=this.GetSolModifiersIncludingParents(),i=0<s.length,r=this._runtime,n=this._eventStack,a=r.GetEventSheetManager(),o=a._IncTriggerDepth(),l=1<o,h=(l&&a.GetLocalVarStack().Push(),this._scopeParent.SetFunctionParameters(e),i&&(t?a.PushCopySol(s):a.PushCleanSol(s)),n.Push(this));this._CheckParentsOKToRun(h)&&(h.SetCurrentEvent(this),this._RunAndBlock(h)),n.Pop(),l&&a.GetLocalVarStack().Pop(),i&&a.PopSol(s),a._DecTriggerDepth(),a.ClearNestedAsyncActionPromises()}*DebugRunAsMappedFunctionCall(e,t){(this.IsDebugBreakpoint()||this._runtime.DebugBreakNext())&&(yield this);const s=this.GetSolModifiersIncludingParents(),i=0<s.length,r=this._runtime,n=this._eventStack,a=r.GetEventSheetManager(),o=a._IncTriggerDepth(),l=1<o,h=(l&&a.GetLocalVarStack().Push(),this._scopeParent.SetFunctionParameters(e),i&&(t?a.PushCopySol(s):a.PushCleanSol(s)),n.Push(this));(yield*this._DebugCheckParentsOKToRun(h))&&(h.SetCurrentEvent(this),yield*this._DebugRunAndBlock(h)),n.Pop(),l&&a.GetLocalVarStack().Pop(),i&&a.PopSol(s),a._DecTriggerDepth(),a.ClearNestedAsyncActionPromises()}RunAsExpressionFunctionCall(e,t,s,i,...r){let n,a,o=0<e.length,l=this._runtime,h=this._eventStack,c=l.GetEventSheetManager(),u=this._scopeParent,_=u.IsAsync(),d=c._IncTriggerDepth(),p=1<d,m=(p&&c.GetLocalVarStack().Push(),0<r.length&&this._scopeParent.SetFunctionParameters(r),o&&(t?c.PushCopySol(e):c.PushCleanSol(e)),h.Push(this));return m.InitCallFunctionExpression(s,i),h.PushExpFunc(m),l.SetDebuggingEnabled(!1),this._CheckParentsOKToRun(m)&&(m.SetCurrentEvent(this),_&&([a,n]=u.StartAsyncFunctionCall()),this._RunAndBlock(m),_)&&u.MaybeFinishAsyncFunctionCall(a),l.SetDebuggingEnabled(!0),h.Pop(),h.PopExpFunc(),p&&c.GetLocalVarStack().Pop(),o&&c.PopSol(e),c._DecTriggerDepth(),_||c.ClearNestedAsyncActionPromises(),n||m.GetFunctionReturnValue()}}}{let C33=self.C3,EMPTY_SOL_MODIFIERS=[],hadUserScriptException=!1;C33.EventScript=class extends C33.DefendedBase{constructor(e,t,s){super();const i=e.GetRuntime(),r=e.GetEventSheetManager(),n=(this._eventSheet=e,this._eventSheetManager=r,this._runtime=e.GetRuntime(),this._parent=t,i.GetObjectReference(s[1]));this._func=n,this._displayNumber=s[2],this._eventSheet._RegisterEventByDisplayNumber(this,this._displayNumber),this._debugData=i.IsDebug()?{isBreakpoint:s[3][0],isBreakable:s[3][1]}:null}static Create(e,t,s){return C33.New(C33.EventScript,e,t,s)}_PostInit(){const e=this._func,t=this._runtime.GetEventSheetManager()._GetLocalVariablesScriptInterface(this);this._func=e.bind(null,this._runtime.GetIRuntime(),t)}GetParent(){return this._parent}GetScopeParent(){return this._parent}GetEventSheet(){return this._eventSheet}GetDisplayNumber(){return this._displayNumber}IsDebugBreakable(){return this._debugData&&this._debugData.isBreakable}IsDebugBreakpoint(){return this.IsDebugBreakable()&&this._debugData.isBreakpoint}_SetDebugBreakpoint(e){this._debugData.isBreakpoint=!!e}IsElseBlock(){return!1}GetSolModifiers(){return EMPTY_SOL_MODIFIERS}GetSolModifiersIncludingParents(){return this._parent?this._parent.GetSolModifiersIncludingParents():EMPTY_SOL_MODIFIERS}Run(e){e.SetCurrentEvent(this),this._eventSheetManager.AddAsyncActionPromise(this._RunUserScript())}async _RunUserScript(){try{await this._func()}catch(e){console.error(`Unhandled exception running script %c${this.GetEventSheet().GetName()}, event ${this.GetDisplayNumber()}:`,"font-size: 1.2em; font-weight: bold;",e),self.C3Debugger&&self.C3Debugger._SetLastErrorScript(this),hadUserScriptException||(console.info("%cTip:%c run this to highlight in Construct the last script that had an error: %cgoToLastErrorScript()","font-weight: bold; text-decoration: underline","","font-weight: bold"),hadUserScriptException=!0)}}*DebugRun(e){e.SetCurrentEvent(this),(this.IsDebugBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this.Run(e)}DebugCanRunFast(){return!this.IsDebugBreakpoint()&&!this._runtime.DebugBreakNext()}static HadUserScriptException(){return hadUserScriptException}static SetHadUserScriptException(){hadUserScriptException=!0}}}{const C33=self.C3,assert=self.assert;C33.FunctionBlock=class extends C33.DefendedBase{constructor(e,t,s){super(),this._eventSheet=e,this._runtime=e.GetRuntime(),this._parent=t,this._functionType=0,this._functionName="",this._returnType=0,this._functionParameters=[],this._isEnabled=!0,this._aceName="",this._objectClass=null,this._hasOverrides=!1,this._innerLocalVariables=[],this._isCopyPicked=!1,this._isAsync=!1,this._nextAsyncId=0,this._currentAsyncId=-1,this._asyncMap=new Map,this._eventBlock=C33.EventBlock.Create(e,t,s),this._eventBlock._SetScopeParent(this)}InitFunctionBlock(e){this._functionType=0,this._functionName=e[0],this._returnType=e[1],this._functionParameters=e[2].map(e=>C33.EventVariable.Create(this._eventSheet,this,e)),this._isEnabled=e[3],this._isAsync=e[4],this._isCopyPicked=e[5]}InitCustomACEBlock(e){this._functionType=1,this._aceName=e[1],this._objectClass=this._runtime.GetObjectClassByIndex(e[2]),this._eventBlock._AddSolModifier(this._objectClass),this._functionName=this._objectClass.GetName()+"."+this._aceName,this._returnType=e[3],this._functionParameters=e[4].map(e=>C33.EventVariable.Create(this._eventSheet,this,e)),this._isEnabled=e[5],this._isAsync=e[6],this._isCopyPicked=e[7],this._objectClass.AddCustomAction(this)}static CreateFunctionBlock(e,t,s){const i=C33.New(C33.FunctionBlock,e,t,s),r=s[1];return i.InitFunctionBlock(r),i}static CreateCustomACEBlock(e,t,s){const i=C33.New(C33.FunctionBlock,e,t,s),r=s[1];return i.InitCustomACEBlock(r),i}_CheckOverrideState(){if(this._objectClass&&this._objectClass.IsFamily())for(const e of this._objectClass.GetFamilyMembers())if(e.HasOwnCustomActionByName(this._aceName)){this._hasOverrides=!0;break}}_PostInit(){for(const e of this._functionParameters)e._PostInit();this._eventBlock._PostInit(!1)}GetFunctionType(){return this._functionType}_GetAllLocalVariablesInScope(){return this._functionParameters}GetFunctionParameters(){return this._functionParameters}GetFunctionParameterCount(){return this._functionParameters.length}_RegisterLocalVariable(e){this._innerLocalVariables.push(e)}_GetAllInnerLocalVariables(){return this._innerLocalVariables}EvaluateFunctionParameters(s){const i=this._functionParameters;for(let e=0,t=i.length;e<t;++e)i[e].SetValue(s[e].Get(0))}SetFunctionParameters(s){const i=this._functionParameters;for(let e=0,t=i.length;e<t;++e)i[e].SetValue(s[e])}CaptureFunctionParameters(){return this._functionParameters.map(e=>e.GetValue())}GetParent(){return this._parent}GetScopeParent(){return this._parent}GetFunctionName(){return this._functionName}GetACEName(){return this._aceName}HasCustomACEOverrides(){return this._hasOverrides}GetReturnType(){return this._returnType}GetObjectClass(){return this._objectClass}IsEnabled(){return this._isEnabled}GetDefaultReturnValue(){switch(this._returnType){case 0:return null;case 2:return"";default:return 0}}GetEventBlock(){return this._eventBlock}IsCopyPicked(){return this._isCopyPicked}IsAsync(){return this._isAsync}StartAsyncFunctionCall(){const e=this._nextAsyncId++;this._currentAsyncId=e;let t,s=new Promise(e=>t=e);return this._asyncMap.set(e,{resolve:t,pauseCount:0}),[e,s]}MaybeFinishAsyncFunctionCall(e){const t=this._asyncMap.get(e);0===t.pauseCount&&(t.resolve(),this._asyncMap.delete(e)),this._currentAsyncId=-1}PauseCurrentAsyncFunction(){const e=this._asyncMap.get(this._currentAsyncId);return e.pauseCount++,this._currentAsyncId}ResumeAsyncFunction(e){this._currentAsyncId=e;const t=this._asyncMap.get(e);t.pauseCount--}RunAsFamilyCustomActionWithOverrides(e,t){const s=new Map,i=[];for(const r of this._objectClass.GetCurrentSol().GetInstances()){const n=r.GetObjectClass();if(n.HasOwnCustomActionByName(this._aceName)){const a=s.get(n);Array.isArray(a)?a.push(r):s.set(n,[r])}else i.push(r)}if(0<i.length&&this._eventBlock.RunAsFunctionCall(e,t,this._isCopyPicked,{pickObjectClass:this._objectClass,pickInstances:i}),0<s.size)for(const[o,l]of s){const h=o.GetOwnCustomActionByName(this._aceName).GetEventBlock(),c=[...new Set([...e,...h.GetSolModifiers()])];h.RunAsFunctionCall(c,t,this._isCopyPicked,{pickObjectClass:o,pickInstances:l})}}*DebugRunAsFamilyCustomActionWithOverrides(e,t){const s=new Map,i=[];for(const r of this._objectClass.GetCurrentSol().GetInstances()){const n=r.GetObjectClass();if(n.HasOwnCustomActionByName(this._aceName)){const a=s.get(n);Array.isArray(a)?a.push(r):s.set(n,[r])}else i.push(r)}if(0<i.length&&(yield*this._eventBlock.DebugRunAsFunctionCall(e,t,this._isCopyPicked,{pickObjectClass:this._objectClass,pickInstances:i})),0<s.size)for(const[o,l]of s){const h=o.GetOwnCustomActionByName(this._aceName).GetEventBlock(),c=[...new Set([...e,...h.GetSolModifiers()])];yield*h.DebugRunAsFunctionCall(c,t,this._isCopyPicked,{pickObjectClass:o,pickInstances:l})}}}}{const C33=self.C3,EMPTY_SOL_MODIFIERS=[];C33.EventVariable=class extends C33.DefendedBase{constructor(e,t,s){super();const i=e.GetEventSheetManager();this._eventSheet=e,this._eventSheetManager=i,this._runtime=e.GetRuntime(),this._parent=t,this._localVarStack=i.GetLocalVarStack(),this._name=s[1],this._type=s[2],this._initialValue=s[3],this._isStatic=!!s[4],this._isConstant=!!s[5],this._isFunctionParameter=t instanceof C33.FunctionBlock,this._sid=s[6],this._jsPropName=this._runtime.GetJsPropName(s[8]),this._scriptSetter=e=>this.SetValue(e),this._scriptGetter=()=>this.GetValue(),this._hasSingleValue=!this._parent||this._isStatic||this._isConstant,this._value=this._initialValue,this._localIndex=-1,this.IsBoolean()&&(this._value=this._value?1:0),!this.IsLocal()||this.IsStatic()||this.IsConstant()||(this._localIndex=i._GetNextLocalVarIndex(this)),i._RegisterEventVariable(this)}static Create(e,t,s){return C33.New(C33.EventVariable,e,t,s)}_PostInit(){if(this.IsLocal()&&!this.IsStatic()&&!this.IsConstant()&&!this.IsFunctionParameter()){const e=this._eventSheetManager.FindFirstFunctionBlockParent(this);e&&e._RegisterLocalVariable(this)}}GetName(){return this._name}GetJsPropName(){return this._jsPropName}GetParent(){return this._parent}GetScopeParent(){return this.GetParent()}IsGlobal(){return!this.GetParent()}IsLocal(){return!this.IsGlobal()}IsFunctionParameter(){return this._isFunctionParameter}IsStatic(){return this._isStatic}IsConstant(){return this._isConstant}IsNumber(){return 0===this._type}IsString(){return 1===this._type}IsBoolean(){return 2===this._type}IsElseBlock(){return!1}GetSID(){return this._sid}GetInitialValue(){return this._initialValue}GetSolModifiers(){return EMPTY_SOL_MODIFIERS}Run(e){!this.IsLocal()||this.IsStatic()||this.IsConstant()||this.SetValue(this.GetInitialValue())}DebugCanRunFast(){return!0}*DebugRun(e){this.Run(e)}SetValue(e){this.IsNumber()?"number"!=typeof e&&(e=parseFloat(e)):this.IsString()?"string"!=typeof e&&(e=e.toString()):this.IsBoolean()&&(e=e?1:0),this._hasSingleValue?this._value=e:this._localVarStack.GetCurrent()[this._localIndex]=e}GetValue(){return this._hasSingleValue?this._value:this._localVarStack.GetCurrent()[this._localIndex]}GetTypedValue(){let e=this.GetValue();return this.IsBoolean()?!!e:e}ResetToInitialValue(){this._value=this._initialValue}_GetScriptInterfaceDescriptor(){return{configurable:!1,enumerable:!0,get:this._scriptGetter,set:this._scriptSetter}}}}{const C33=self.C3,assert=self.assert,EMPTY_SOL_MODIFIERS=[];C33.EventInclude=class extends C33.DefendedBase{constructor(e,t,s){super();const i=e.GetEventSheetManager();this._eventSheet=e,this._eventSheetManager=i,this._runtime=e.GetRuntime(),this._parent=t,this._includeSheet=null,this._includeSheetName=s[1],this._isActive=!0}static Create(e,t,s){return C33.New(C33.EventInclude,e,t,s)}_PostInit(){this._includeSheet=this._eventSheetManager.GetEventSheetByName(this._includeSheetName),this._eventSheet._AddShallowInclude(this);let e=this.GetParent();for(;e;)e instanceof C33.EventBlock&&e.IsGroup()&&e._AddContainedInclude(this),e=e.GetParent();this.UpdateActive(),this._runtime.IsDebug()&&this._eventSheet._GetPerfRecord().children.push(this._includeSheet._GetPerfRecord())}GetParent(){return this._parent}GetSolModifiers(){return EMPTY_SOL_MODIFIERS}GetIncludeSheet(){return this._includeSheet}Run(e){const t=!!this.GetParent(),s=this._runtime.GetAllObjectClasses();t&&this._eventSheetManager.PushCleanSol(s),this._includeSheet.Run(),t&&this._eventSheetManager.PopSol(s)}*DebugRun(e){const t=!!this.GetParent(),s=this._runtime.GetAllObjectClasses();t&&this._eventSheetManager.PushCleanSol(s),yield*this._includeSheet.DebugRun(),t&&this._eventSheetManager.PopSol(s)}DebugCanRunFast(){return!1}IsActive(){return this._isActive}UpdateActive(){let e=this.GetParent();for(;e;){if(e instanceof C33.EventBlock&&e.IsGroup()&&!e.IsGroupActive())return void(this._isActive=!1);e=e.GetParent()}this._isActive=!0}}}{let WrapIndex2=function(e,t){return t<=e?e%t:(e<0&&(e<=-t&&(e%=t),e<0)&&(e+=t),e)};WrapIndex=WrapIndex2;const C33=self.C3,assert=self.assert;C33.ExpNode=class extends C33.DefendedBase{constructor(e){super(),this._owner=e,this._runtime=e.GetRuntime()}_PostInit(){}static CreateNode(e,t){const s=t[0],i=[BehaviorExpressionNode,ObjectExpressionNode,InstVarExpressionNode,EventVarExpNode,SystemExpressionExpNode,CallFunctionExpressionExpNode];return C33.New(i[s],e,t)}};class SystemExpressionExpNode extends C33.ExpNode{constructor(e,t){super(e),this._systemPlugin=this._runtime.GetSystemPlugin(),this._func=this._runtime.GetObjectReference(t[1]),this._func!==C33.Plugins.System.Exps.random&&this._func!==C33.Plugins.System.Exps.choose||this._owner.SetVariesPerInstance()}GetBoundMethod(){return this._systemPlugin._GetBoundACEMethod(this._func,this._systemPlugin)}}class CallFunctionExpressionExpNode extends C33.ExpNode{constructor(e,t){super(e),this._functionBlock=null,this._functionName=t[1],this._owner.SetVariesPerInstance()}_PostInit(){const e=this._runtime.GetEventSheetManager(),t=(this._functionBlock=e.GetFunctionBlockByName(this._functionName),this._functionName=null,this._owner.GetEventBlock()),s=this._functionBlock.GetEventBlock();this._combinedSolModifiers=[...new Set([...t.GetSolModifiersIncludingParents(),...s.GetSolModifiersIncludingParents()])],this._combinedSolModifiers=e._DeduplicateSolModifierList(this._combinedSolModifiers)}GetBoundMethod(){const e=this._functionBlock;if(e.IsEnabled()){const t=e.GetEventBlock();return C33.EventBlock.prototype.RunAsExpressionFunctionCall.bind(t,this._combinedSolModifiers,e.IsCopyPicked(),e.GetReturnType(),e.GetDefaultReturnValue())}{const s=e.GetDefaultReturnValue();return()=>s}}}class ObjectExpressionNode extends C33.ExpNode{constructor(e,t){super(e),this._objectClass=this._runtime.GetObjectClassByIndex(t[1]),this._func=this._runtime.GetObjectReference(t[2]),this._returnsString=!!t[3],this._eventStack=this._runtime.GetEventSheetManager().GetEventStack(),this._owner._MaybeVaryFor(this._objectClass)}GetBoundMethod(){return this._objectClass.GetPlugin()._GetBoundACEMethod(this._func,this._objectClass.GetSingleGlobalInstance().GetSdkInstance())}ExpObject(...e){const t=this._objectClass,s=t.GetCurrentSol().GetExpressionInstances(),i=s.length;if(0===i)return this._returnsString?"":0;const r=WrapIndex2(this._owner.GetSolIndex(),i);return this._eventStack.GetCurrentStackFrame().SetExpressionObjectClass(t),this._func.apply(s[r].GetSdkInstance(),e)}ExpObject_InstExpr(e,...t){const s=this._objectClass,i=s.GetInstances(),r=i.length;if(0===r||"number"!=typeof e)return this._returnsString?"":0;const n=WrapIndex2(e,r);return this._eventStack.GetCurrentStackFrame().SetExpressionObjectClass(s),this._func.apply(i[n].GetSdkInstance(),t)}}class InstVarExpressionNode extends C33.ExpNode{constructor(e,t){super(e),this._objectClass=this._runtime.GetObjectClassByIndex(t[1]),this._varIndex=t[3],this._returnsString=!!t[2],this._owner._MaybeVaryFor(this._objectClass)}ExpInstVar(){const e=this._objectClass.GetCurrentSol().GetExpressionInstances(),t=e.length;if(0===t)return this._returnsString?"":0;const s=WrapIndex2(this._owner.GetSolIndex(),t);return e[s]._GetInstanceVariableValueUnchecked(this._varIndex)}ExpInstVar_Family(){const e=this._objectClass,t=e.GetCurrentSol().GetExpressionInstances(),s=t.length;if(0===s)return this._returnsString?"":0;const i=WrapIndex2(this._owner.GetSolIndex(),s),r=t[i],n=r.GetObjectClass().GetFamilyInstanceVariableOffset(e.GetFamilyIndex());return r._GetInstanceVariableValueUnchecked(this._varIndex+n)}ExpInstVar_InstExpr(e){const t=this._objectClass,s=t.GetInstances(),i=s.length;if(0===i||"number"!=typeof e)return this._returnsString?"":0;let r=WrapIndex2(e,i),n=s[r],a=0;return t.IsFamily()&&(a=n.GetObjectClass().GetFamilyInstanceVariableOffset(t.GetFamilyIndex())),n._GetInstanceVariableValueUnchecked(this._varIndex+a)}}class BehaviorExpressionNode extends C33.ExpNode{constructor(e,t){super(e),this._objectClass=this._runtime.GetObjectClassByIndex(t[1]),this._behaviorType=this._objectClass.GetBehaviorTypeByName(t[2]),this._behaviorIndex=this._objectClass.GetBehaviorIndexByName(t[2]),this._func=this._runtime.GetObjectReference(t[3]),this._returnsString=!!t[4],this._eventStack=this._runtime.GetEventSheetManager().GetEventStack(),this._owner._MaybeVaryFor(this._objectClass)}ExpBehavior(...e){const t=this._objectClass,s=t.GetCurrentSol().GetExpressionInstances(),i=s.length;if(0===i)return this._returnsString?"":0;let r=WrapIndex2(this._owner.GetSolIndex(),i),n=(this._eventStack.GetCurrentStackFrame().SetExpressionObjectClass(t),s[r]),a=0;return t.IsFamily()&&(a=n.GetObjectClass().GetFamilyBehaviorOffset(t.GetFamilyIndex())),this._func.apply(n.GetBehaviorInstances()[this._behaviorIndex+a].GetSdkInstance(),e)}ExpBehavior_InstExpr(e,...t){const s=this._objectClass,i=s.GetInstances(),r=i.length;if(0===r||"number"!=typeof e)return this._returnsString?"":0;let n=WrapIndex2(e,r),a=(this._eventStack.GetCurrentStackFrame().SetExpressionObjectClass(s),i[n]),o=0;return s.IsFamily()&&(o=a.GetObjectClass().GetFamilyBehaviorOffset(s.GetFamilyIndex())),this._func.apply(a.GetBehaviorInstances()[this._behaviorIndex+o].GetSdkInstance(),t)}}class EventVarExpNode extends C33.ExpNode{constructor(e,t){super(e),this._eventVar=null,this._eventVarSid=t[1]}_PostInit(){this._eventVar=this._runtime.GetEventSheetManager().GetEventVariableBySID(this._eventVarSid)}GetVar(){return this._eventVar}}}{let GetExpressionFunc2=function(e){const t=self.C3_ExpressionFuncs[e];if(t)return t;throw new Error("invalid expression number")};GetExpressionFunc=GetExpressionFunc2;const C33=self.C3,assert=self.assert;C33.Parameter=class extends C33.DefendedBase{constructor(e,t,s){super(),this._owner=e,this._index=s,this._type=t,this.Get=null,this._variesPerInstance=!1,this._isConstant=!1}static Create(e,t,s){const i=t[0],r=[ExpressionParameter,StringExpressionParameter,FileParameter,ComboParameter,ObjectParameter,LayerExpressionParameter,LayoutParameter,ExpressionParameter,ComboParameter,ComboParameter,InstVarParameter,EventVarParameter,FileParameter,VariadicParameter,StringExpressionParameter,TimelineParameter,BooleanParameter,FunctionParameter,EaseParameter,TilemapBrushParameter,TemplateExpressionParameter,FlowchartParameter];return C33.New(r[i],e,i,s,t)}_PostInit(){}SetVariesPerInstance(){this._variesPerInstance=!0}_MaybeVaryFor(e){this._variesPerInstance||!e||e.GetPlugin().IsSingleGlobal()||(this._variesPerInstance=!0)}VariesPerInstance(){return this._variesPerInstance}GetIndex(){return this._index}GetRuntime(){return this._owner.GetRuntime()}GetEventBlock(){return this._owner.GetEventBlock()}IsConstant(){return this._isConstant}IsObjectParameter(){return 4===this._type}};class ExpressionParameter extends C33.Parameter{constructor(e,t,s,i){super(e,t,s),this._solIndex=0;const r=i[1];this._expressionNumber=r[0],this._numberedNodes=[],this._expressionFunc=null;for(let e=1,t=r.length;e<t;++e)this._numberedNodes.push(C33.ExpNode.CreateNode(this,r[e]));this._numberedNodes.length?this.Get=this.GetExpression:(this.Get=GetExpressionFunc2(this._expressionNumber),this._isConstant=!0)}_GetNode(e){if(e<0||e>=this._numberedNodes.length)throw new RangeError("invalid numbered node");return this._numberedNodes[e]}_PostInit(){for(const t of this._numberedNodes)t._PostInit();const e=GetExpressionFunc2(this._expressionNumber);this._numberedNodes.length?this._expressionFunc=e(this):this._expressionFunc=e}GetSolIndex(){return this._solIndex}GetExpression(e){return this._solIndex=e,this._expressionFunc()}}class StringExpressionParameter extends ExpressionParameter{constructor(e,t,s,i){super(e,t,s,i),this.Get=this.GetStringExpression,14===t&&(this.GetEventBlock().SetAllSolModifiers(),this._owner instanceof C33.Action)&&this.GetEventBlock().SetSolWriterAfterCnds()}GetStringExpression(e){this._solIndex=e;const t=this._expressionFunc();return"string"==typeof t?t:""}_GetFastTriggerValue(){return GetExpressionFunc2(this._expressionNumber)()}}class LayerExpressionParameter extends ExpressionParameter{constructor(e,t,s,i){super(e,t,s,i),2<=e.GetImplementationSdkVersion()?this.Get=this.GetILayer:this.Get=this.GetLayer,this._isConstant=!1}GetLayer(e){this._solIndex=e;const t=this._expressionFunc(),s=this.GetRuntime().GetCurrentLayout();return s.GetLayer(t)}GetILayer(e){const t=this.GetLayer(e);return t?t.GetILayer():null}}class ComboParameter extends C33.Parameter{constructor(e,t,s,i){super(e,t,s),this._combo=i[1],this.Get=this.GetCombo,this._isConstant=!0}GetCombo(){return this._combo}}class BooleanParameter extends C33.Parameter{constructor(e,t,s,i){super(e,t,s),this._bool=i[1],this.Get=this.GetBoolean,this._isConstant=!0}GetBoolean(){return this._bool}}class ObjectParameter extends C33.Parameter{constructor(e,t,s,i){super(e,t,s),this._objectClass=this.GetRuntime().GetObjectClassByIndex(i[1]),2<=e.GetImplementationSdkVersion()?this.Get=this.GetIObjectClass:this.Get=this.GetObjectClass;const r=this.GetEventBlock();r._AddSolModifier(this._objectClass),this._owner instanceof C33.Action?r.SetSolWriterAfterCnds():r.GetParent()&&r.GetParent().SetSolWriterAfterCnds(),this._isConstant=!0}GetObjectClass(){return this._objectClass}GetIObjectClass(){return this._objectClass?this._objectClass.GetIObjectClass():null}}class LayoutParameter extends C33.Parameter{constructor(e,t,s,i){super(e,t,s),this._layout=this.GetRuntime().GetLayoutManager().GetLayoutByName(i[1]),2<=e.GetImplementationSdkVersion()?this.Get=this.GetILayout:this.Get=this.GetLayout,this._isConstant=!0}GetLayout(){return this._layout}GetILayout(){return this._layout?this._layout.GetILayout():null}}class TimelineParameter extends C33.Parameter{constructor(e,t,s,i){super(e,t,s),this._timeline=this.GetRuntime().GetTimelineManager().GetTimelineByName(i[1]),2<=e.GetImplementationSdkVersion()?this.Get=this.GetITimelineState:this.Get=this.GetTimeline,this._isConstant=!0}GetTimeline(){return this._timeline}GetITimelineState(){return this._timeline?this._timeline.GetITimelineState():null}}class FileParameter extends C33.Parameter{constructor(e,t,s,i){super(e,t,s),this._fileInfo=i[1],this.Get=this.GetFile,this._isConstant=!0}GetFile(){return this._fileInfo}}class InstVarParameter extends C33.Parameter{constructor(e,t,s,i){super(e,t,s),this._instVarIndex=i[1];const r=this._owner.GetObjectClass();this._owner instanceof C33.Condition&&this._owner.IsStatic()||!r||!r.IsFamily()?(this.Get=this.GetInstanceVariable,this._isConstant=!0):(this.Get=this.GetFamilyInstanceVariable,this.SetVariesPerInstance())}GetInstanceVariable(){return this._instVarIndex}GetFamilyInstanceVariable(e){e=e||0;let t=this._owner.GetObjectClass(),s=t.GetCurrentSol(),i=s.GetInstances(),r=null;if(i.length)r=i[e%i.length].GetObjectClass();else if(s.HasAnyElseInstances()){const n=s.GetElseInstances();r=n[e%n.length].GetObjectClass()}else{if(!(0<t.GetInstanceCount()))return 0;{const a=t.GetInstances();r=a[e%a.length].GetObjectClass()}}return this._instVarIndex+r.GetFamilyInstanceVariableOffset(t.GetFamilyIndex())}}class EventVarParameter extends C33.Parameter{constructor(e,t,s,i){super(e,t,s),this._eventVarSid=i[1],this._eventVar=null,2<=e.GetImplementationSdkVersion()?this.Get=this.GetIEventVariable:this.Get=this.GetEventVariable,this._isConstant=!0}_PostInit(){this._eventVar=this.GetRuntime().GetEventSheetManager().GetEventVariableBySID(this._eventVarSid)}GetEventVariable(){return this._eventVar}GetIEventVariable(){return null}}class FunctionParameter extends C33.Parameter{constructor(e,t,s,i){super(e,t,s),this._functionBlockName=i[1],this._functionBlock=null,2<=e.GetImplementationSdkVersion()?this.Get=this.GetIFunction:this.Get=this.GetFunction,this._isConstant=!0}_PostInit(){this._functionBlock=this.GetRuntime().GetEventSheetManager().GetFunctionBlockByName(this._functionBlockName),this._functionBlockName=null}GetFunction(){return this._functionBlock}GetIFunction(){return null}}class VariadicParameter extends C33.Parameter{constructor(e,t,s,i){super(e,t,s),this._subParams=[],this._variadicRet=[],this._isConstant=!0;for(let e=1,t=i.length;e<t;++e){const r=C33.Parameter.Create(this._owner,i[e],0);this._subParams.push(r),this._variadicRet.push(0),r.IsConstant()||(this._isConstant=!1)}this.Get=this.GetVariadic}_PostInit(){for(const e of this._subParams)e._PostInit()}GetVariadic(){const s=this._subParams,i=this._variadicRet;for(let e=0,t=s.length;e<t;++e)i[e]=s[e].Get(0);return i}}class EaseParameter extends C33.Parameter{constructor(e,t,s,i){super(e,t,s),this._easeIndex=i[1],this.Get=this.GetEase,this._isConstant=!0}GetEase(){return this._easeIndex}}class TilemapBrushParameter extends C33.Parameter{constructor(e,t,s,i){super(e,t,s),this._brushIndex=i[1],this.Get=this.GetTilemapBrush,this._isConstant=!0}GetTilemapBrush(){return this._brushIndex}}class TemplateExpressionParameter extends ExpressionParameter{constructor(e,t,s,i){super(e,t,s,i),this.Get=this.GetTemplateName,this._isConstant=!1}GetTemplateName(){return this._expressionFunc()}}class FlowchartParameter extends C33.Parameter{constructor(e,t,s,i){super(e,t,s),this._flowchartDataItem=this.GetRuntime().GetFlowchartManager().GetFlowchartDataItemByName(i[1]),this.Get=this.GetFlowchartName,this._isConstant=!0}GetFlowchartName(){return this._flowchartDataItem.GetName()}}}{let EvalParams2=function(s,i){for(let e=0,t=s.length;e<t;++e)i[e]=s[e].Get(0)};EvalParams=EvalParams2;const C33=self.C3,assert=self.assert,EMPTY_PARAMS_ARRAY=[],noop=function(){};C33.Condition=class extends C33.DefendedBase{constructor(e,s,t){if(super(),this._eventBlock=e,this._runtime=e.GetRuntime(),this._index=t,this._func=this._runtime.GetObjectReference(s[1]),this._isTrigger=0<s[3],this._isFastTrigger=2===s[3],this._isLooping=!!s[4],this._isInverted=!!s[5],this._isStatic=!!s[6],this._sid=s[7],this._isInOrBlock=this._eventBlock.IsOrBlock(),this._objectClass=null,this._behaviorType=null,this._behaviorIndex=-1,this._systemPlugin=null,this.Run=noop,this.DebugRun=noop,this._parameters=[],this._results=[],this._anyParamVariesPerInstance=!1,this._savedData=null,this._unsavedData=null,this._debugData=this._runtime.IsDebug()?{isBreakpoint:s[8][0],canDebug:s[8][1]}:null,-1===s[0]?this._systemPlugin=this._runtime.GetSystemPlugin():(this._objectClass=this._runtime.GetObjectClassByIndex(s[0]),s[2]&&(this._behaviorType=this._objectClass.GetBehaviorTypeByName(s[2]),this._behaviorIndex=this._objectClass.GetBehaviorIndexByName(s[2])),this._eventBlock.GetParent()&&this._eventBlock.GetParent().SetSolWriterAfterCnds()),10===s.length){let t=s[9];for(let e of t)this._parameters.push(C33.Parameter.Create(this,e,this._parameters.length)),this._results.push(0)}0===this._parameters.length&&(this._parameters=EMPTY_PARAMS_ARRAY,this._results=EMPTY_PARAMS_ARRAY),this._eventBlock.GetEventSheetManager()._RegisterCondition(this)}static Create(e,t,s){return C33.New(C33.Condition,e,t,s)}_PostInit(){for(const e of this._parameters)e._PostInit(),e.VariesPerInstance()&&(this._anyParamVariesPerInstance=!0);this._isFastTrigger?(this.Run=this._RunFastTrigger,this.DebugRun=this._DebugRunFastTrigger):this._systemPlugin?(this._SetSystemRunMethod(),this.DebugRun=this._DebugRunSystem):this._objectClass.GetPlugin().IsSingleGlobal()?(this._SetSingleGlobalRunMethod(),this.DebugRun=this._DebugRunSingleGlobal):this._isStatic?(this.Run=this._RunStatic,this.DebugRun=this._DebugRunStatic):(this.Run=this._RunObject,this.DebugRun=this._DebugRunObject)}_SetSystemRunMethod(){const e=this._systemPlugin,t=this._systemPlugin;this._SetRunMethodForBoundFunc(e,t,this._RunSystem)}_SetSingleGlobalRunMethod(){const e=this._objectClass.GetPlugin(),t=this._objectClass.GetSingleGlobalInstance().GetSdkInstance();this._SetRunMethodForBoundFunc(e,t,this._RunSingleGlobal)}_SetRunMethodForBoundFunc(e,t,s){const i=this._func,r=this._isInverted,n=this._parameters;if(0===n.length){const a=e._GetBoundACEMethod(i,t);r?this.Run=function(){return C33.xor(a(),r)}:this.Run=a}else if(1===n.length){const o=n[0];if(!r&&o.IsConstant())this.Run=e._GetBoundACEMethod_1param(i,t,o.Get(0));else{const l=e._GetBoundACEMethod(i,t);this.Run=function(){return C33.xor(l(o.Get(0)),r)}}}else if(2===n.length){const h=n[0],c=n[1];if(!r&&h.IsConstant()&&c.IsConstant())this.Run=e._GetBoundACEMethod_2params(i,t,h.Get(0),c.Get(0));else{const u=e._GetBoundACEMethod(i,t);this.Run=function(){return C33.xor(u(h.Get(0),c.Get(0)),r)}}}else if(3===n.length){const _=n[0],d=n[1],p=n[2];if(!r&&_.IsConstant()&&d.IsConstant()&&p.IsConstant())this.Run=e._GetBoundACEMethod_3params(i,t,_.Get(0),d.Get(0),p.Get(0));else{const m=e._GetBoundACEMethod(i,t);this.Run=function(){return C33.xor(m(_.Get(0),d.Get(0),p.Get(0)),r)}}}else this.Run=s}GetSID(){return this._sid}_GetFunc(){return this._func}GetObjectClass(){return this._objectClass}GetBehaviorType(){return this._behaviorType}GetImplementationAddon(){return this._behaviorType?this._behaviorType.GetBehavior():this._objectClass?this._objectClass.GetPlugin():null}GetImplementationSdkVersion(){const e=this.GetImplementationAddon();return e?e.GetSdkVersion():1}GetEventBlock(){return this._eventBlock}GetRuntime(){return this._runtime}GetIndex(){return this._index}GetDebugIndex(){return this.GetIndex()}IsTrigger(){return this._isTrigger}IsFastTrigger(){return this._isFastTrigger}IsInverted(){return this._isInverted}IsLooping(){return this._isLooping}IsStatic(){return this._isStatic}IsBreakpoint(){return this._debugData.isBreakpoint}IsSystemCondition(){return!!this._systemPlugin}IsSystemOrSingleGlobalCondition(){return this.IsSystemCondition()||this._objectClass.GetPlugin().IsSingleGlobal()}GetFirstObjectParameterObjectClass(){for(const e of this._parameters)if(e.IsObjectParameter())return e.GetObjectClass();return null}_SetBreakpoint(e){this._debugData.isBreakpoint=!!e,this._eventBlock._UpdateCanRunFastRecursive()}_DebugReturnsGenerator(){return this._debugData.canDebug}DebugCanRunFast(){return!this.IsBreakpoint()&&!this._runtime.DebugBreakNext()&&!this._DebugReturnsGenerator()}GetSavedDataMap(){return this._savedData||(this._savedData=new Map),this._savedData}GetUnsavedDataMap(){return this._unsavedData||(this._unsavedData=new Map),this._unsavedData}_RunSystem(){const e=this._results;return EvalParams2(this._parameters,e),C33.xor(this._func.apply(this._systemPlugin,e),this._isInverted)}*_DebugRunSystem(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const t=this._results;EvalParams2(this._parameters,t);let e=this._func.apply(this._systemPlugin,t);return C33.IsIterator(e)&&(e=yield*e),C33.xor(e,this._isInverted)}return this.Run()}_RunSingleGlobal(){const e=this._results,t=(EvalParams2(this._parameters,e),this._objectClass.GetSingleGlobalInstance().GetSdkInstance());return C33.xor(this._func.apply(t,e),this._isInverted)}*_DebugRunSingleGlobal(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){let e=this._results,t=(EvalParams2(this._parameters,e),this._objectClass.GetSingleGlobalInstance().GetSdkInstance()),s=this._func.apply(t,e);return C33.IsIterator(s)&&(s=yield*s),C33.xor(s,this._isInverted)}return this.Run()}_RunFastTrigger(){return!0}*_DebugRunFastTrigger(){return(this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),!0}_GetStaticConditionThis(){return this._behaviorType?2<=this._behaviorType.GetBehavior().GetSdkVersion()?this._behaviorType.GetIBehaviorType():this._behaviorType:2<=this._objectClass.GetPlugin().GetSdkVersion()?this._objectClass.GetIObjectClass():this._objectClass}_RunStatic(){const e=this._results,t=(EvalParams2(this._parameters,e),this._func.apply(this._GetStaticConditionThis(),e));return this._objectClass.ApplySolToContainer(),t}*_DebugRunStatic(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const t=this._results;EvalParams2(this._parameters,t);let e=this._func.apply(this._GetStaticConditionThis(),t);return C33.IsIterator(e)&&(e=yield*e),this._objectClass.ApplySolToContainer(),e}return this.Run()}_RunObject(){const s=this._parameters,i=this._results,e=this._objectClass.GetCurrentSol();for(let e=0,t=s.length;e<t;++e){const r=s[e];r.VariesPerInstance()||(i[e]=r.Get(0))}return e.IsSelectAll()?this._RunObject_FirstFilter(e):this._RunObject_NextFilter(e)}*_DebugRunObject(){return(this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._RunObject()}_EvaluateVaryingParameters(s){const i=this._parameters,r=this._results;for(let e=0,t=i.length;e<t;++e){const n=i[e];n.VariesPerInstance()&&(r[e]=n.Get(s))}}_RunObject_FirstFilter(s){const e=this._objectClass,i=e.IsFamily(),r=e.GetFamilyIndex(),n=this._behaviorIndex,a=0<=n,o=e.GetInstances(),l=this._anyParamVariesPerInstance,h=this._results,c=this._func,u=this._isInverted,_=this._isInOrBlock&&!this._isTrigger;s.ClearArrays();for(let t=0,e=o.length;t<e;++t){const d=o[t];l&&this._EvaluateVaryingParameters(t);let e;if(a){const p=i?d.GetObjectClass().GetFamilyBehaviorOffset(r):0;e=c.apply(d.GetBehaviorInstances()[n+p].GetSdkInstance(),h)}else e=c.apply(d.GetSdkInstance(),h);C33.xor(e,u)?s._PushInstance(d):_&&s._PushElseInstance(d)}return e.FinishCondition(!0),s._SetSelectAll(!1),e.ApplySolToContainer(),s.HasAnyInstances()}_RunObject_NextFilter(e){let t=this._objectClass,s=t.IsFamily(),i=t.GetFamilyIndex(),r=t.IsInContainer(),n=this._behaviorIndex,a=0<=n,o=this._anyParamVariesPerInstance,l=this._results,h=this._func,c=this._isInverted,u=this._isInOrBlock&&!this._isTrigger,_=e._GetOwnInstances(),d=e._GetOwnElseInstances(),p=u&&!this._eventBlock.IsFirstConditionOfType(this),m=p?d:_,g=0,f=!1;for(let t=0,e=m.length;t<e;++t){const C=m[t];o&&this._EvaluateVaryingParameters(t);let e;if(a){const y=s?C.GetObjectClass().GetFamilyBehaviorOffset(i):0;e=h.apply(C.GetBehaviorInstances()[n+y].GetSdkInstance(),l)}else e=h.apply(C.GetSdkInstance(),l);C33.xor(e,c)?(f=!0,p?(_.push(C),r&&C._PushSiblingsToSolInstances()):(m[g]=C,r&&C._SetSiblingsToSolInstancesIndex(g),++g)):p?(m[g]=C,r&&C._SetSiblingsToSolElseInstancesIndex(g),++g):u&&(d.push(C),r)&&C._PushSiblingsToSolElseInstances()}C33.truncateArray(m,g),r&&t._TruncateContainerSols(p,g);const S=f;return p&&!f&&(f=this._OrBlockCheckInstances(_)),t.FinishCondition(S||u),u?f:e.HasAnyInstances()}_OrBlockCheckInstances(s){const e=this._objectClass,i=e.IsFamily(),r=e.GetFamilyIndex(),n=this._anyParamVariesPerInstance,a=this._behaviorIndex,o=0<=a,l=this._results,h=this._func,c=this._isInverted;for(let t=0,e=s.length;t<e;++t){const u=s[t];n&&this._EvaluateVaryingParameters(t);let e;if(o){const _=i?u.GetObjectClass().GetFamilyBehaviorOffset(r):0;e=h.apply(u.GetBehaviorInstances()[a+_].GetSdkInstance(),l)}else e=h.apply(u.GetSdkInstance(),l);if(C33.xor(e,c))return!0}return!1}ReevaluateParameter(e,t){return this._parameters[e].Get(t)}GetFastTriggerValue(){const e=this._parameters;if(e.length)return e[0]._GetFastTriggerValue();throw new Error("no parameters")}_SaveToJson(){if(!this._savedData||!this._savedData.size)return null;const t={};for(const[s,i]of this._savedData.entries()){let e=i;"collmemory"===s&&(e=[...i.entries()].map(e=>[e[0].GetUID(),e[1].GetUID(),e[2]])),t[s]=e}return{ex:t}}_LoadFromJson(e){if(this._savedData&&(this._savedData.clear(),this._savedData=null),e){const t=this._runtime,s=e.ex;if(s){const i=this.GetSavedDataMap();i.clear();for(const[r,n]of Object.entries(s)){let e=n;"collmemory"===r&&(e=C33.New(C33.PairMap,n.map(e=>[t.GetInstanceByUID(e[0]),t.GetInstanceByUID(e[1]),e[2]]).filter(e=>e[0]&&e[1]))),i.set(r,e)}}}}}}{let EvalParams2=function(s,i){for(let e=0,t=s.length;e<t;++e)i[e]=s[e].Get(0)};EvalParams=EvalParams2;const C33=self.C3,assert=self.assert,EMPTY_PARAMS_ARRAY=[],noop=function(){},noopGenerator=function*(){},FLAG_CANPICKANYOBJECTCLASS=1,FLAG_COPYPICKED=2,FLAG_CUSTOM_ACE=4,FLAG_IS_ASYNC=8,FLAG_CAN_BAIL_OUT=16;C33.Action=class extends C33.DefendedBase{constructor(e,t,s){super();const i=(this._eventBlock=e).GetRuntime(),r=(this._runtime=i,this._index=s,this._sid=4<=t.length?t[3]:-1,this._actionType=5<=t.length?255&t[4]:0,this._flags=5<=t.length?t[4]>>8:0,this._func=null,this._objectClass=null,this._behaviorType=null,this._behaviorIndex=-1,this._systemPlugin=null,this._callFunctionName="",this._callCustomAceObjectClass=null,this._callEventBlock=null,this.Run=noop,this.DebugRun=noop,this._parameters=[],this._results=[],this._anyParamVariesPerInstance=!1,this._savedData=null,this._unsavedData=null,-3===t[0]),n=r?t[2]:t[5];if(this._debugData=i.IsDebug()||r?{isBreakpoint:n[0],canDebug:n[1],index:n[2]}:null,-1===t[0])this._systemPlugin=i.GetSystemPlugin(),this._func=i.GetObjectReference(t[1]);else if(-2===t[0])this._callFunctionName=t[1];else if(r){const a=i.GetObjectReference(t[1]);this._func=a,this.Run=this.RunUserScript,this.DebugRun=this.DebugRunUserScript,this._flags|=FLAG_IS_ASYNC}else this._objectClass=i.GetObjectClassByIndex(t[0]),this._flags&FLAG_CUSTOM_ACE?(this._callFunctionName=t[1],this._callCustomAceObjectClass=i.GetObjectClassByIndex(t[2])):(t[2]&&(this._behaviorType=this._objectClass.GetBehaviorTypeByName(t[2]),this._behaviorIndex=this._objectClass.GetBehaviorIndexByName(t[2])),this._func=i.GetObjectReference(t[1]));if(7===t.length){const o=t[6];for(const l of o)this._parameters.push(C33.Parameter.Create(this,l,this._parameters.length)),this._results.push(0)}0===this._parameters.length&&(this._parameters=EMPTY_PARAMS_ARRAY,this._results=EMPTY_PARAMS_ARRAY),this.CanPickAnyObjectClass()&&(this._eventBlock.SetAllSolModifiers(),this._eventBlock.SetSolWriterAfterCnds()),this._eventBlock.GetEventSheetManager()._RegisterAction(this)}static Create(e,t,s){return C33.New(C33.Action,e,t,s)}_PostInit(){for(const e of this._parameters)e._PostInit(),e.VariesPerInstance()&&(this._anyParamVariesPerInstance=!0);if(this._systemPlugin)this._SetSystemRunMethod(),this.DebugRun=this._DebugRunSystem;else if(this._callFunctionName)this._flags&FLAG_CUSTOM_ACE?this._SetCallCustomActionRunMethod():this._SetCallFunctionRunMethod(),this._callFunctionName="",this._callCustomAceObjectClass=null;else if(this.Run===this.RunUserScript){const t=this._func,s=this._runtime.GetEventSheetManager()._GetLocalVariablesScriptInterface(this._eventBlock);this._func=t.bind(null,this._runtime.GetIRuntime(),s)}else this._behaviorType?this.IsAsync()?(this.Run=this._RunBehavior_Async,this.DebugRun=this._DebugRunBehavior_Async):(this.Run=this._RunBehavior,this.DebugRun=this._DebugRunBehavior):this._objectClass.GetPlugin().IsSingleGlobal()?(this._SetSingleGlobalRunMethod(),this.DebugRun=this._DebugRunSingleGlobal):this.IsStatic()?(this.Run=this._RunObject_Static,this.DebugRun=this._DebugRunObject_Static):this.IsAsync()?(this.Run=this._RunObject_Async,this.DebugRun=this._DebugRunObject_Async):this.CallBeforeAfterHooks()?(this.Run=this._RunObject_BeforeAfterHooks,this.DebugRun=this._DebugRunObject_BeforeAfterHooks):this._parameters.length?this._parameters.every(e=>e.VariesPerInstance())?(this.Run=this._RunObject_AllParamsVary,this.DebugRun=this._DebugRunObject_AllParamsVary):this._anyParamVariesPerInstance?(this.Run=this._RunObject_SomeParamsVary,this.DebugRun=this._DebugRunObject_SomeParamsVary):this._parameters.every(e=>e.IsConstant())?(EvalParams2(this._parameters,this._results),this.Run=this._RunObject_ParamsConst,this.DebugRun=this._DebugRunObject_ParamsConst):(this.Run=this._RunObject_ParamsDontVary,this.DebugRun=this._DebugRunObject_ParamsDontVary):(this.Run=this._RunObject_ParamsConst,this.DebugRun=this._DebugRunObject_ParamsConst)}_SetSystemRunMethod(){const e=this._systemPlugin,t=this._systemPlugin;this._SetRunMethodForBoundFunc(e,t,this._RunSystem)}_SetSingleGlobalRunMethod(){const e=this._objectClass.GetPlugin(),t=this._objectClass.GetSingleGlobalInstance().GetSdkInstance();this._SetRunMethodForBoundFunc(e,t,this._RunSingleGlobal)}_SetCallFunctionRunMethod(){const e=this._eventBlock.GetEventSheetManager(),s=e.GetFunctionBlockByName(this._callFunctionName);if(s.IsEnabled()){const i=0!=(this._flags&FLAG_COPYPICKED);this._callEventBlock=s.GetEventBlock();let t=[...new Set([...this._eventBlock.GetSolModifiersIncludingParents(),...this._callEventBlock.GetSolModifiersIncludingParents()])];t=e._DeduplicateSolModifierList(t);const r=!s.IsCopyPicked()&&this._HasCopyPickedParent()?{pushCleanSolDynamic:!0}:null;if(this.Run=C33.EventBlock.prototype.RunAsFunctionCall.bind(this._callEventBlock,t,this._parameters,i,r),this._runtime.IsDebug()){const n=this;this.DebugRun=function*(){(n.IsBreakpoint()||n._runtime.DebugBreakNext())&&(yield n);const e=yield*n._callEventBlock.DebugRunAsFunctionCall(t,n._parameters,i,r);return e}}else this.DebugRun=noopGenerator}else this.Run=noop,this.DebugRun=noopGenerator}_SetCallCustomActionRunMethod(){const n=this._eventBlock.GetEventSheetManager(),a=n.GetCustomActionBlockByName(this._callCustomAceObjectClass,this._callFunctionName);if(a.IsEnabled()){const o=0!=(this._flags&FLAG_COPYPICKED);this._callEventBlock=a.GetEventBlock();let t=[...new Set([...this._eventBlock.GetSolModifiersIncludingParents(),...this._callEventBlock.GetSolModifiersIncludingParents(),this._objectClass,a.GetObjectClass()])],e=(t=n._DeduplicateSolModifierList(t),!this._objectClass.IsFamily()&&!a.GetObjectClass().IsFamily()),s=!this._objectClass.IsFamily()&&a.GetObjectClass().IsFamily(),i=this._objectClass.IsFamily(),r=null;if(!a.IsCopyPicked()&&this._HasCopyPickedParent()&&((r=r||{}).pushCleanSolDynamic=!0),!s&&o||((r=r||{}).copyFromObjectClass=this._objectClass,r.copyToObjectClass=a.GetObjectClass()),e||s||i&&!a.HasCustomACEOverrides()?this.Run=C33.EventBlock.prototype.RunAsFunctionCall.bind(this._callEventBlock,t,this._parameters,o,r):i&&(this.Run=C33.FunctionBlock.prototype.RunAsFamilyCustomActionWithOverrides.bind(a,t,this._parameters)),this._runtime.IsDebug()){const l=this;e||s||i&&!a.HasCustomACEOverrides()?this.DebugRun=function*(){(l.IsBreakpoint()||l._runtime.DebugBreakNext())&&(yield l);const e=yield*l._callEventBlock.DebugRunAsFunctionCall(t,l._parameters,o,r);return e}:i&&(this.DebugRun=function*(){(l.IsBreakpoint()||l._runtime.DebugBreakNext())&&(yield l);const e=yield*a.DebugRunAsFamilyCustomActionWithOverrides(t,l._parameters);return e})}else this.DebugRun=noopGenerator}else this.Run=noop,this.DebugRun=noopGenerator}_SetRunMethodForBoundFunc(e,t,s){const i=this._func,r=this._parameters;if(0===r.length)this.Run=e._GetBoundACEMethod(i,t);else if(1===r.length){const n=r[0];if(n.IsConstant())this.Run=e._GetBoundACEMethod_1param(i,t,n.Get(0));else{const a=e._GetBoundACEMethod(i,t);this.Run=function(){return a(n.Get(0))}}}else if(2===r.length){const o=r[0],l=r[1];if(o.IsConstant()&&l.IsConstant())this.Run=e._GetBoundACEMethod_2params(i,t,o.Get(0),l.Get(0));else{const h=e._GetBoundACEMethod(i,t);this.Run=function(){return h(o.Get(0),l.Get(0))}}}else if(3===r.length){const c=r[0],u=r[1],_=r[2];if(c.IsConstant()&&u.IsConstant()&&_.IsConstant())this.Run=e._GetBoundACEMethod_3params(i,t,c.Get(0),u.Get(0),_.Get(0));else{const d=e._GetBoundACEMethod(i,t);this.Run=function(){return d(c.Get(0),u.Get(0),_.Get(0))}}}else this.Run=s}GetSID(){return this._sid}IsAsync(){return 0!=(this._flags&FLAG_IS_ASYNC)}CanBailOut(){return 0!=(this._flags&FLAG_CAN_BAIL_OUT)}CallBeforeAfterHooks(){return 1===this._actionType}IsStatic(){return 2===this._actionType}CanPickAnyObjectClass(){return 0!=(this._flags&FLAG_CANPICKANYOBJECTCLASS)}HasReturnType(){return this.IsAsync()||this.CanBailOut()}GetObjectClass(){return this._objectClass}GetImplementationAddon(){return this._behaviorType?this._behaviorType.GetBehavior():this._objectClass?this._objectClass.GetPlugin():null}GetImplementationSdkVersion(){const e=this.GetImplementationAddon();return e?e.GetSdkVersion():1}GetEventBlock(){return this._eventBlock}_HasCopyPickedParent(){let e=this._eventBlock;do{if(e instanceof C33.FunctionBlock&&e.IsCopyPicked())return!0}while(e=e.GetScopeParent());return!1}GetRuntime(){return this._runtime}GetIndex(){return this._index}GetDebugIndex(){return this._debugData.index}IsBreakpoint(){return this._debugData.isBreakpoint}_SetBreakpoint(e){this._debugData.isBreakpoint=!!e,this._eventBlock._UpdateCanRunFastRecursive()}_DebugReturnsGenerator(){return this._debugData.canDebug}DebugCanRunFast(){return!this.IsBreakpoint()&&!this._runtime.DebugBreakNext()&&!this._DebugReturnsGenerator()}GetSavedDataMap(){return this._savedData||(this._savedData=new Map),this._savedData}GetUnsavedDataMap(){return this._unsavedData||(this._unsavedData=new Map),this._unsavedData}_RunSystem(){const e=this._results;return EvalParams2(this._parameters,e),this._func.apply(this._systemPlugin,e)}*_DebugRunSystem(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const e=this._results,t=(EvalParams2(this._parameters,e),yield*this._func.apply(this._systemPlugin,e));return t}return this.Run()}_RunSingleGlobal(){const e=this._results;return EvalParams2(this._parameters,e),this._func.apply(this._objectClass.GetSingleGlobalInstance().GetSdkInstance(),e)}*_DebugRunSingleGlobal(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const e=this._results,t=(EvalParams2(this._parameters,e),yield*this._func.apply(this._objectClass.GetSingleGlobalInstance().GetSdkInstance(),e));return t}return this.Run()}_RunObject_ParamsConst(){const s=this._results,i=this._objectClass.GetCurrentSol().GetInstances();for(let e=0,t=i.length;e<t;++e)this._func.apply(i[e].GetSdkInstance(),s)}*_DebugRunObject_ParamsConst(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const s=this._results,i=this._objectClass.GetCurrentSol().GetInstances();for(let e=0,t=i.length;e<t;++e)yield*this._func.apply(i[e].GetSdkInstance(),s)}else this._RunObject_ParamsConst()}_RunObject_ParamsDontVary(){const s=this._results,i=(EvalParams2(this._parameters,s),this._objectClass.GetCurrentSol().GetInstances());for(let e=0,t=i.length;e<t;++e)this._func.apply(i[e].GetSdkInstance(),s)}*_DebugRunObject_ParamsDontVary(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const s=this._results,i=(EvalParams2(this._parameters,s),this._objectClass.GetCurrentSol().GetInstances());for(let e=0,t=i.length;e<t;++e)yield*this._func.apply(i[e].GetSdkInstance(),s)}else this._RunObject_ParamsDontVary()}_RunObject_AllParamsVary(){const i=this._parameters,r=this._results,t=this._func,n=this._objectClass.GetCurrentSol().GetInstances();for(let s=0,e=n.length;s<e;++s){const a=n[s];for(let e=0,t=i.length;e<t;++e)r[e]=i[e].Get(s);t.apply(a.GetSdkInstance(),r)}}*_DebugRunObject_AllParamsVary(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const i=this._parameters,r=this._results,t=this._func,n=this._objectClass.GetCurrentSol().GetInstances();for(let s=0,e=n.length;s<e;++s){const a=n[s];for(let e=0,t=i.length;e<t;++e)r[e]=i[e].Get(s);yield*t.apply(a.GetSdkInstance(),r)}}else this._RunObject_AllParamsVary()}_RunObject_SomeParamsVary(){const i=this._parameters,r=this._results,t=this._func,n=this._objectClass.GetCurrentSol().GetInstances();for(let e=0,t=i.length;e<t;++e){const s=i[e];s.VariesPerInstance()||(r[e]=s.Get(0))}for(let s=0,e=n.length;s<e;++s){const a=n[s];for(let e=0,t=i.length;e<t;++e){const o=i[e];o.VariesPerInstance()&&(r[e]=o.Get(s))}t.apply(a.GetSdkInstance(),r)}}*_DebugRunObject_SomeParamsVary(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const i=this._parameters,r=this._results,t=this._func,n=this._objectClass.GetCurrentSol().GetInstances();for(let e=0,t=i.length;e<t;++e){const s=i[e];s.VariesPerInstance()||(r[e]=s.Get(0))}for(let s=0,e=n.length;s<e;++s){const a=n[s];for(let e=0,t=i.length;e<t;++e){const o=i[e];o.VariesPerInstance()&&(r[e]=o.Get(s))}yield*t.apply(a.GetSdkInstance(),r)}}else this._RunObject_SomeParamsVary()}_RunObject_BeforeAfterHooks(){const i=this._parameters,r=this._results,t=this._func,e=this._objectClass,s=e.GetSdkType(),n=e.GetCurrentSol().GetInstances();s.BeforeRunAction(t);for(let s=0,e=n.length;s<e;++s){const a=n[s];for(let e=0,t=i.length;e<t;++e)r[e]=i[e].Get(s);t.apply(a.GetSdkInstance(),r)}s.AfterRunAction(t)}*_DebugRunObject_BeforeAfterHooks(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const i=this._parameters,r=this._results,t=this._func,e=this._objectClass,s=e.GetSdkType(),n=e.GetCurrentSol().GetInstances();s.BeforeRunAction(t);for(let s=0,e=n.length;s<e;++s){const a=n[s];for(let e=0,t=i.length;e<t;++e)r[e]=i[e].Get(s);yield*t.apply(a.GetSdkInstance(),r)}s.AfterRunAction(t)}else this._RunObject_BeforeAfterHooks()}_GetStaticActionThis(){return this._behaviorType?2<=this._behaviorType.GetBehavior().GetSdkVersion()?this._behaviorType.GetIBehaviorType():this._behaviorType:2<=this._objectClass.GetPlugin().GetSdkVersion()?this._objectClass.GetIObjectClass():this._objectClass}_RunObject_Static(){const e=this._results;return EvalParams2(this._parameters,e),this._func.apply(this._GetStaticActionThis(),e)}*_DebugRunObject_Static(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const t=this._results;EvalParams2(this._parameters,t);let e=this._func.apply(this._GetStaticActionThis(),t);return C33.IsIterator(e)?yield*e:e}return this._RunObject_Static()}_RunBehavior(){const e=this._objectClass,t=e.IsFamily(),i=e.GetFamilyIndex(),r=this._parameters,n=this._anyParamVariesPerInstance,a=this._results,o=this._func,l=this._behaviorIndex,h=e.GetCurrentSol().GetInstances();for(let e=0,t=r.length;e<t;++e){const s=r[e];s.VariesPerInstance()||(a[e]=s.Get(0))}for(let s=0,e=h.length;s<e;++s){const c=h[s];if(n)for(let e=0,t=r.length;e<t;++e){const _=r[e];_.VariesPerInstance()&&(a[e]=_.Get(s))}const u=t?c.GetObjectClass().GetFamilyBehaviorOffset(i):0;o.apply(c.GetBehaviorInstances()[l+u].GetSdkInstance(),a)}}*_DebugRunBehavior(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const e=this._objectClass,t=e.IsFamily(),i=e.GetFamilyIndex(),r=this._parameters,n=this._anyParamVariesPerInstance,a=this._results,o=this._func,l=this._behaviorIndex,h=e.GetCurrentSol().GetInstances();for(let e=0,t=r.length;e<t;++e){const s=r[e];s.VariesPerInstance()||(a[e]=s.Get(0))}for(let s=0,e=h.length;s<e;++s){const c=h[s];if(n)for(let e=0,t=r.length;e<t;++e){const _=r[e];_.VariesPerInstance()&&(a[e]=_.Get(s))}const u=t?c.GetObjectClass().GetFamilyBehaviorOffset(i):0;yield*o.apply(c.GetBehaviorInstances()[l+u].GetSdkInstance(),a)}}else this._RunBehavior()}_RunObject_Async(){const i=this._parameters,r=this._results,t=this._func,n=this._objectClass.GetCurrentSol().GetInstances(),a=[];for(let s=0,e=n.length;s<e;++s){const o=n[s];for(let e=0,t=i.length;e<t;++e)r[e]=i[e].Get(s);a.push(t.apply(o.GetSdkInstance(),r))}return Promise.all(a)}*_DebugRunObject_Async(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const i=this._parameters,r=this._results,t=this._func,n=this._objectClass.GetCurrentSol().GetInstances(),a=[];for(let s=0,e=n.length;s<e;++s){const o=n[s];for(let e=0,t=i.length;e<t;++e)r[e]=i[e].Get(s);a.push(yield*t.apply(o.GetSdkInstance(),r))}return Promise.all(a)}return this._RunObject_Async()}_RunBehavior_Async(){const e=this._objectClass,t=e.IsFamily(),i=e.GetFamilyIndex(),r=this._parameters,n=this._results,a=this._func,o=this._behaviorIndex,l=e.GetCurrentSol().GetInstances(),h=[];for(let s=0,e=l.length;s<e;++s){const c=l[s];for(let e=0,t=r.length;e<t;++e)n[e]=r[e].Get(s);const u=t?c.GetObjectClass().GetFamilyBehaviorOffset(i):0;h.push(a.apply(c.GetBehaviorInstances()[o+u].GetSdkInstance(),n))}return Promise.all(h)}*_DebugRunBehavior_Async(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const e=this._objectClass,t=e.IsFamily(),i=e.GetFamilyIndex(),r=this._parameters,n=this._results,a=this._func,o=this._behaviorIndex,l=e.GetCurrentSol().GetInstances(),h=[];for(let s=0,e=l.length;s<e;++s){const c=l[s];for(let e=0,t=r.length;e<t;++e)n[e]=r[e].Get(s);const u=t?c.GetObjectClass().GetFamilyBehaviorOffset(i):0;h.push(yield*a.apply(c.GetBehaviorInstances()[o+u].GetSdkInstance(),n))}return Promise.all(h)}return this._RunBehavior_Async()}async RunUserScript(){try{await this._func()}catch(e){console.error(`Unhandled exception running script %c${this._eventBlock.GetEventSheet().GetName()}, event ${this._eventBlock.GetDisplayNumber()}, action ${this.GetDebugIndex()+1}:`,"font-size: 1.2em; font-weight: bold;",e),self.C3Debugger&&self.C3Debugger._SetLastErrorScript(this),C33.EventScript.HadUserScriptException()||(console.info("%cTip:%c run this to highlight in Construct the last script that had an error: %cgoToLastErrorScript()","font-weight: bold; text-decoration: underline","","font-weight: bold"),C33.EventScript.SetHadUserScriptException())}}*DebugRunUserScript(){return(this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this.RunUserScript()}_SaveToJson(){return this._savedData&&this._savedData.size?{ex:C33.ToSuperJSON(this._savedData)}:null}_LoadFromJson(e){if(this._savedData&&(this._savedData.clear(),this._savedData=null),e){const t=e.ex;t&&(this._savedData=C33.FromSuperJSON(t))}}}}{let GetInst2=function(e){return e instanceof IInstance?runtime._UnwrapScriptInterface(e):e.GetInstance()},GetWorldInfo2=function(e){return GetInst2(e).GetWorldInfo()},GetInst_SDKv22=function(e){return runtime._UnwrapScriptInterface(e)},GetWorldInfo_SDKv22=function(e){return GetInst_SDKv22(e).GetWorldInfo()},GetObjectClass2=function(e){return e instanceof IObjectClass?runtime._UnwrapScriptInterface(e):e},GetLayer2=function(e){return e instanceof ILayer?runtime._UnwrapScriptInterface(e):e},CollMemory_Add2=function(e,t,s,i){const r=t.GetUID(),n=s.GetUID();r<n?e.Set(t,s,i):e.Set(s,t,i)},CollMemory_Remove2=function(e,t,s){const i=t.GetUID(),r=s.GetUID();i<r?e.Delete(t,s):e.Delete(s,t)},CollMemory_RemoveInstance2=function(e,t){e.DeleteEither(t)},CollMemory_Get2=function(e,t,s){const i=t.GetUID(),r=s.GetUID();return i<r?e.Get(t,s):e.Get(s,t)},DoOverlapCondition2=function(e,t,s,i){if(!t)return!1;const r=0!==s||0!==i,n=e.GetWorldInfo(),a=runtime.GetCollisionEngine(),o=runtime.GetCurrentCondition(),l=o.GetEventBlock().IsOrBlock(),h=o.GetObjectClass(),c=o.IsInverted(),u=t.GetCurrentSol(),_=h!==t;rPickType=t,needsCollisionFinish=_&&!c;let d,p=0,m=0,g=rPickFromElseInstances=!1;u.IsSelectAll()?(tempRect.copy(n.GetBoundingBox()),tempRect.offset(s,i),a.GetCollisionCandidates(n.GetLayer(),t,tempRect,tempCandidates2),d=tempCandidates2):!l||runtime.IsCurrentConditionFirst()&&!u._GetOwnElseInstances().length&&u._GetOwnInstances().length?d=u._GetOwnInstances():(d=u._GetOwnElseInstances(),rPickFromElseInstances=!0),r&&(p=n.GetX(),m=n.GetY(),n.OffsetXY(s,i),n.SetBboxChanged());for(const f of d)if(a.TestOverlap(e,f)){if(g=!0,c)break;_&&rToPick.add(f)}return r&&(n.SetXY(p,m),n.SetBboxChanged()),C33.clearArray(tempCandidates2),g},FinishCollisionConditionPicking2=function(e){const t=runtime.GetCurrentEvent().IsOrBlock(),s=rPickType.GetCurrentSol(),i=s._GetOwnInstances(),r=s._GetOwnElseInstances();s.IsSelectAll()?(s.SetSetPicked(rToPick),t&&(C33.clearArray(r),s.AddElseInstances(rToPick,rPickType.GetInstances()))):t?rPickFromElseInstances?s.TransferElseInstancesToOwn(rToPick):(s.AddElseInstances(rToPick,i),s.SetSetPicked(rToPick)):s.SetSetPicked(rToPick),rPickType.ApplySolToContainer()},FinishCollisionCondition2=function(e,t){needsCollisionFinish&&(t&&FinishCollisionConditionPicking2(e),rToPick.clear(),rPickType=null,needsCollisionFinish=!1)},PickByUID_Normal2=function(e,t){const s=runtime.GetInstanceByUID(t);if(s){const i=e.GetCurrentSol();if(i.IsSelectAll()||i._GetOwnInstances().includes(s))if(e.IsFamily()){if(s.GetObjectClass().BelongsToFamily(e))return i.PickOne(s),e.ApplySolToContainer(),!0}else if(s.GetObjectClass()===e)return i.PickOne(s),e.ApplySolToContainer(),!0}return!1},PickByUID_Inverted2=function(e,r){const n=e.GetCurrentSol();if(n.IsSelectAll()){n._SetSelectAll(!1),n.ClearArrays();const s=e.GetInstances();for(let e=0,t=s.length;e<t;++e){const i=s[e];i.GetUID()===r?n._PushElseInstance(i):n._PushInstance(i)}return e.ApplySolToContainer(),!!n._GetOwnInstances().length}{let s=n._GetOwnInstances(),i=0;for(let e=0,t=s.length;e<t;++e){const a=s[e];(s[i]=a).GetUID()===r?n._PushElseInstance(a):++i}return C33.truncateArray(s,i),e.ApplySolToContainer(),!!s.length}},C33=(GetInst=GetInst2,GetWorldInfo=GetWorldInfo2,GetInst_SDKv2=GetInst_SDKv22,GetWorldInfo_SDKv2=GetWorldInfo_SDKv22,GetObjectClass=GetObjectClass2,GetLayer=GetLayer2,CollMemory_Add=CollMemory_Add2,CollMemory_Remove=CollMemory_Remove2,CollMemory_RemoveInstance=CollMemory_RemoveInstance2,CollMemory_Get=CollMemory_Get2,DoOverlapCondition=DoOverlapCondition2,FinishCollisionConditionPicking=FinishCollisionConditionPicking2,FinishCollisionCondition=FinishCollisionCondition2,PickByUID_Normal=PickByUID_Normal2,PickByUID_Inverted=PickByUID_Inverted2,self.C3),tempColor=new C33.Color,AnySDK={},SDKv1={},SDKv2={},runtime=null,IInstance=(C33.CommonACES_SetRuntime=function(e){runtime=e},self.IInstance),IObjectClass=self.IObjectClass,ILayer=self.ILayer,tempRect=(SDKv1.CompareX=function(e,t){return C33.compare(this.GetWorldInfo().GetX(),e,t)},SDKv2.CompareX=function(e,t){return C33.compare(this.x,e,t)},SDKv1.CompareY=function(e,t){return C33.compare(this.GetWorldInfo().GetY(),e,t)},SDKv2.CompareY=function(e,t){return C33.compare(this.y,e,t)},SDKv1.IsOnScreen=function(){return this.GetWorldInfo().IsInViewport2()},SDKv2.IsOnScreen=function(){return this.isOnScreen()},AnySDK.IsOutsideLayout=function(){const e=GetWorldInfo2(this),t=e.GetLayout(),s=e.GetBoundingBox();return s.getRight()<0||s.getBottom()<0||s.getLeft()>t.GetWidth()||s.getTop()>t.GetHeight()},AnySDK.PickDistance=function(s,i,r){const e=GetObjectClass2(this),t=e.GetCurrentSol(),n=t.GetInstances();if(!n.length)return!1;let a=n[0],o=a.GetWorldInfo(),l=a,h=C33.distanceSquared(o.GetX(),o.GetY(),i,r);for(let e=1,t=n.length;e<t;++e){a=n[e],o=a.GetWorldInfo();const c=C33.distanceSquared(o.GetX(),o.GetY(),i,r);(0===s&&c<h||1===s&&c>h)&&(h=c,l=a)}return t.PickOne(l),!0},SDKv1.SetX=function(e){const t=this.GetWorldInfo();t.GetX()!==e&&(t.SetX(e),t.SetBboxChanged())},SDKv2.SetX=function(e){this.x=+e},SDKv1.SetY=function(e){const t=this.GetWorldInfo();t.GetY()!==e&&(t.SetY(e),t.SetBboxChanged())},SDKv2.SetY=function(e){this.y=+e},SDKv1.SetPos=function(e,t){const s=this.GetWorldInfo();s.EqualsXY(e,t)||(s.SetXY(e,t),s.SetBboxChanged())},SDKv2.SetPos=function(e,t){this.setPosition(e,t)},AnySDK.SetPosToObject=function(e,t){if(e=GetObjectClass2(e)){const s=GetInst2(this),i=e.GetPairedInstance(s);if(i){const[r,n]=i.GetImagePoint(t),a=s.GetWorldInfo();a.GetX()===r&&a.GetY()===n||(a.SetXY(r,n),a.SetBboxChanged())}}},AnySDK.MoveForward=function(e){if(0!==e){const t=GetWorldInfo2(this);t.OffsetXY(t.GetCosAngle()*e,t.GetSinAngle()*e),t.SetBboxChanged()}},SDKv1.MoveAtAngle=function(e,t){if(0!==t){const s=this.GetWorldInfo();e=C33.toRadians(e),s.OffsetXY(Math.cos(e)*t,Math.sin(e)*t),s.SetBboxChanged()}},SDKv2.MoveAtAngle=function(e,t){0!==t&&(e=C33.toRadians(e),this.offsetPosition(Math.cos(e)*t,Math.sin(e)*t))},SDKv1.GetX=function(){return this.GetWorldInfo().GetX()},SDKv2.GetX=function(){return this.x},SDKv1.GetY=function(){return this.GetWorldInfo().GetY()},SDKv2.GetY=function(){return this.y},AnySDK.GetDt=function(){return runtime.GetDt(GetInst2(this))},SDKv1.CompareWidth=function(e,t){return C33.compare(this.GetWorldInfo().GetWidth(),e,t)},SDKv2.CompareWidth=function(e,t){return C33.compare(this.width,e,t)},SDKv1.CompareHeight=function(e,t){return C33.compare(this.GetWorldInfo().GetHeight(),e,t)},SDKv2.CompareHeight=function(e,t){return C33.compare(this.height,e,t)},SDKv1.SetWidth=function(e){const t=this.GetWorldInfo();t.GetWidth()!==e&&(t.SetWidth(e),t.SetBboxChanged())},SDKv2.SetWidth=function(e){this.width=e},SDKv1.SetHeight=function(e){const t=this.GetWorldInfo();t.GetHeight()!==e&&(t.SetHeight(e),t.SetBboxChanged())},SDKv2.SetHeight=function(e){this.height=e},SDKv1.SetSize=function(e,t){const s=GetWorldInfo2(this);s.GetWidth()===e&&s.GetHeight()===t||(s.SetSize(e,t),s.SetBboxChanged())},SDKv2.SetSize=function(e,t){this.setSize(e,t)},SDKv1.GetWidth=function(){return this.GetWorldInfo().GetWidth()},SDKv2.GetWidth=function(){return this.width},SDKv1.GetHeight=function(){return this.GetWorldInfo().GetHeight()},SDKv2.GetHeight=function(){return this.height},AnySDK.GetBboxLeft=function(){return GetWorldInfo2(this).GetBoundingBox().getLeft()},AnySDK.GetBboxTop=function(){return GetWorldInfo2(this).GetBoundingBox().getTop()},AnySDK.GetBboxRight=function(){return GetWorldInfo2(this).GetBoundingBox().getRight()},AnySDK.GetBboxBottom=function(){return GetWorldInfo2(this).GetBoundingBox().getBottom()},AnySDK.GetBboxMidX=function(){const e=GetWorldInfo2(this).GetBoundingBox();return(e.getLeft()+e.getRight())/2},AnySDK.GetBboxMidY=function(){const e=GetWorldInfo2(this).GetBoundingBox();return(e.getTop()+e.getBottom())/2},AnySDK.IsAngleWithin=function(e,t){return C33.angleDiff(GetWorldInfo2(this).GetAngle(),C33.toRadians(t))<=C33.toRadians(e)},AnySDK.IsAngleClockwiseFrom=function(e){return C33.angleClockwise(GetWorldInfo2(this).GetAngle(),C33.toRadians(e))},AnySDK.IsBetweenAngles=function(e,t){const s=C33.toRadians(e),i=C33.toRadians(t),r=GetWorldInfo2(this).GetAngle(),n=!C33.angleClockwise(i,s);return n?!(!C33.angleClockwise(r,s)&&C33.angleClockwise(r,i)):C33.angleClockwise(r,s)&&!C33.angleClockwise(r,i)},SDKv1.SetAngle=function(e){const t=this.GetWorldInfo(),s=C33.clampAngle(C33.toRadians(e));isNaN(s)||t.GetAngle()===s||(t.SetAngle(s),t.SetBboxChanged())},SDKv2.SetAngle=function(e){this.angleDegrees=e},AnySDK.RotateClockwise=function(e){if(!isNaN(e)&&0!==e){const t=GetWorldInfo2(this);t.SetAngle(t.GetAngle()+C33.toRadians(e)),t.SetBboxChanged()}},AnySDK.RotateCounterclockwise=function(e){if(!isNaN(e)&&0!==e){const t=GetWorldInfo2(this);t.SetAngle(t.GetAngle()-C33.toRadians(e)),t.SetBboxChanged()}},AnySDK.RotateTowardAngle=function(e,t){const s=GetWorldInfo2(this),i=s.GetAngle(),r=C33.angleRotate(i,C33.toRadians(t),C33.toRadians(e));isNaN(r)||i===r||(s.SetAngle(r),s.SetBboxChanged())},AnySDK.RotateTowardPosition=function(e,t,s){const i=GetWorldInfo2(this),r=i.GetAngle(),n=t-i.GetX(),a=s-i.GetY(),o=Math.atan2(a,n),l=C33.angleRotate(r,o,C33.toRadians(e));isNaN(l)||r===l||(i.SetAngle(l),i.SetBboxChanged())},AnySDK.SetTowardPosition=function(e,t){const s=GetWorldInfo2(this),i=s.GetAngle(),r=e-s.GetX(),n=t-s.GetY(),a=Math.atan2(n,r);isNaN(a)||i===a||(s.SetAngle(a),s.SetBboxChanged())},SDKv1.GetAngle=function(){return C33.toDegrees(this.GetWorldInfo().GetAngle())},SDKv2.GetAngle=function(){return this.angleDegrees},AnySDK.CompareOpacity=function(e,t){return C33.compare(C33.roundToDp(100*GetWorldInfo2(this).GetOpacity(),6),e,t)},SDKv1.IsVisible=function(){return this.GetWorldInfo().IsVisible()},SDKv2.IsVisible=function(){return this.isVisible},AnySDK.SetVisible=function(e){const t=GetWorldInfo2(this);e=2===e?!t.IsVisible():0!==e,t.IsVisible()!==e&&(t.SetVisible(e),runtime.UpdateRender())},AnySDK.SetOpacity=function(e){const t=C33.clamp(e/100,0,1),s=GetWorldInfo2(this);if(s.GetTransformWithParentOpacity()){if(s._GetSceneGraphInfo().GetOwnOpacity()===t)return}else if(s.GetOpacity()===t)return;s.SetOpacity(t),runtime.UpdateRender()},AnySDK.SetDefaultColor=function(e){tempColor.setFromRgbValue(e);const t=GetWorldInfo2(this);t.GetUnpremultipliedColor().equalsIgnoringAlpha(tempColor)||(t.SetUnpremultipliedColor(tempColor),runtime.UpdateRender())},AnySDK.GetColor=function(){const e=GetWorldInfo2(this).GetUnpremultipliedColor();return C33.PackRGBAEx(e.getR(),e.getG(),e.getB(),e.getA())},AnySDK.GetOpacity=function(){return C33.roundToDp(100*GetWorldInfo2(this).GetOpacity(),6)},AnySDK.IsOnLayer=function(e){return!!(e=GetLayer2(e))&&GetWorldInfo2(this).GetLayer()===e},AnySDK.PickTopBottom=function(s){const e=GetObjectClass2(this),t=e.GetCurrentSol(),i=t.GetInstances();if(!i.length)return!1;let r=i[0],n=r;for(let e=1,t=i.length;e<t;++e){const a=i[e],o=a.GetWorldInfo(),l=n.GetWorldInfo(),h=o.GetLayer().GetIndex(),c=l.GetLayer().GetIndex();0===s?(c<h||h===c&&o.GetZIndex()>l.GetZIndex())&&(n=a):(h<c||h===c&&o.GetZIndex()<l.GetZIndex())&&(n=a)}return t.PickOne(n),!0},SDKv1.CompareZElevation=function(e,t,s){const i=this.GetWorldInfo(),r=0===e?i.GetZElevation():i.GetTotalZElevation();return C33.compare(r,t,s)},SDKv2.CompareZElevation=function(e,t,s){const i=0===e?this.zElevation:this.totalZElevation;return C33.compare(i,t,s)},SDKv1.MoveToTop=function(){this.GetWorldInfo().ZOrderMoveToTop()},SDKv2.MoveToTop=function(){this.moveToTop()},SDKv1.MoveToBottom=function(){this.GetWorldInfo().ZOrderMoveToBottom()},SDKv2.MoveToBottom=function(){this.moveToBottom()},AnySDK.MoveToLayer=function(e){(e=GetLayer2(e))&&GetWorldInfo2(this).ZOrderMoveToLayer(e)},AnySDK.ZMoveToObject=function(e,t){const s=0===e;if(t=GetObjectClass2(t)){const i=GetInst2(this),r=t.GetFirstPicked(i);r&&i.GetWorldInfo().ZOrderMoveAdjacentToInstance(r,s)}},SDKv1.SetZElevation=function(e){const t=this.GetWorldInfo();t.GetZElevation()!==e&&(t.SetZElevation(e),runtime.UpdateRender())},SDKv2.SetZElevation=function(e){this.zElevation=e},AnySDK.LayerNumber=function(){return GetWorldInfo2(this).GetLayer().GetIndex()},AnySDK.LayerName=function(){return GetWorldInfo2(this).GetLayer().GetName()},SDKv1.ZIndex=function(){return this.GetWorldInfo().GetZIndex()},SDKv2.ZIndex=function(){return this.zIndex},SDKv1.ZElevation=function(){return this.GetWorldInfo().GetZElevation()},SDKv2.ZElevation=function(){return this.zElevation},SDKv1.TotalZElevation=function(){return this.GetWorldInfo().GetTotalZElevation()},SDKv2.TotalZElevation=function(){return this.totalZElevation},AnySDK.IsEffectEnabled=function(e){const t=GetInst2(this),s=t.GetObjectClass().GetEffectList().GetEffectTypeByName(e);if(s){const i=s.GetIndex(),r=t.GetWorldInfo().GetInstanceEffectList();return r.IsEffectIndexActive(i)}},AnySDK.SetEffectEnabled=function(e,t){const s=GetInst2(this),i=s.GetObjectClass().GetEffectList().GetEffectTypeByName(t);if(i){const r=i.GetIndex(),n=1===e,a=s.GetWorldInfo().GetInstanceEffectList();a.IsEffectIndexActive(r)!==n&&(a.SetEffectIndexActive(r,n),a.UpdateActiveEffects(),runtime.UpdateRender())}},AnySDK.SetEffectParam=function(e,t,s){const i=GetInst2(this),r=i.GetObjectClass().GetEffectList().GetEffectTypeByName(e);if(r){t=Math.floor(t);const n=r.GetShaderProgram().GetParameterType(t);if(n){"color"===n?(tempColor.setFromRgbValue(s),s=tempColor):"percent"===n&&(s/=100);const a=r.GetIndex(),o=i.GetWorldInfo().GetInstanceEffectList(),l=o.SetEffectParameter(a,t,s);l&&o.IsEffectIndexActive(a)&&runtime.UpdateRender()}}},C33.New(C33.Rect)),tempCandidates1=[],tempCandidates2=[],needsCollisionFinish=!1,rPickType=null,rPickFromElseInstances=!1,rToPick=new Set;function*DebugOnCollision(S){if(S){let e=this.GetRuntime(),t=e.GetCollisionEngine(),i=e.GetEventSheetManager(),s=i.GetEventStack(),r=i.GetCurrentCondition(),n=r.GetObjectClass(),a=r.GetSavedDataMap(),o=r.GetUnsavedDataMap(),l=s.GetCurrentStackFrame(),h=e.GetTickCount(),c=h-1,u=l.GetCurrentEvent(),_=s.Push(u),d=a.get("collmemory"),p=(d||(d=C33.New(C33.PairMap),a.set("collmemory",d)),o.get("collisionCreatedDestroyCallback")||(o.set("collisionCreatedDestroyCallback",!0),e.Dispatcher().addEventListener("instancedestroy",e=>CollMemory_RemoveInstance2(d,e.instance))),n.GetCurrentSol()),m=S.GetCurrentSol(),g=p.GetInstances(),f=null;for(let e=0;e<g.length;++e){const C=g[e];m.IsSelectAll()?(t.GetCollisionCandidates(C.GetWorldInfo().GetLayer(),S,C.GetWorldInfo().GetBoundingBox(),tempCandidates1),f=tempCandidates1,t.AddRegisteredCollisionCandidates(C,S,f)):f=m.GetInstances();for(let e=0;e<f.length;++e){const y=f[e];if(t.TestOverlap(C,y)||t.CheckRegisteredCollision(C,y)){let e=CollMemory_Get2(d,C,y),t=!1,s=-2;"number"==typeof e&&(t=!0,s=e);const G=!t||s<c;if(CollMemory_Add2(d,C,y,h),G){const I=u.GetSolModifiers(),T=(i.PushCopySol(I),n.GetCurrentSol()),b=S.GetCurrentSol();if(T._SetSelectAll(!1),b._SetSelectAll(!1),n===S){const A=T._GetOwnInstances();C33.clearArray(A),A.push(C),A.push(y),n.ApplySolToContainer()}else{const P=T._GetOwnInstances(),R=b._GetOwnInstances();C33.clearArray(P),C33.clearArray(R),P.push(C),R.push(y),n.ApplySolToContainer(),S.ApplySolToContainer()}yield*u.DebugRetrigger(l,_),i.PopSol(I)}}else CollMemory_Remove2(d,C,y)}C33.clearArray(tempCandidates1)}s.Pop()}return!1}AnySDK.OnCollision=function(f){const e=GetObjectClass2(this),S=(f=GetObjectClass2(f),e.GetRuntime());if(S.IsDebugging())return DebugOnCollision.call(e,f);if(f){let t=S.GetCollisionEngine(),i=S.GetEventSheetManager(),e=i.GetEventStack(),s=i.GetCurrentCondition(),r=s.GetObjectClass(),n=s.GetSavedDataMap(),a=s.GetUnsavedDataMap(),o=e.GetCurrentStackFrame(),l=S.GetTickCount(),h=l-1,c=o.GetCurrentEvent(),u=e.Push(c),_=n.get("collmemory"),d=(_||(_=C33.New(C33.PairMap),n.set("collmemory",_)),a.get("collisionCreatedDestroyCallback")||(a.set("collisionCreatedDestroyCallback",!0),S.Dispatcher().addEventListener("instancedestroy",e=>CollMemory_RemoveInstance2(_,e.instance))),r.GetCurrentSol()),p=f.GetCurrentSol(),m=d.GetInstances(),g=null;for(let e=0;e<m.length;++e){const C=m[e];p.IsSelectAll()?(t.GetCollisionCandidates(C.GetWorldInfo().GetLayer(),f,C.GetWorldInfo().GetBoundingBox(),tempCandidates1),g=tempCandidates1,t.AddRegisteredCollisionCandidates(C,f,g)):g=p.GetInstances();for(let e=0;e<g.length;++e){const y=g[e];if(t.TestOverlap(C,y)||t.CheckRegisteredCollision(C,y)){let e=CollMemory_Get2(_,C,y),t=!1,s=-2;"number"==typeof e&&(t=!0,s=e);const G=!t||s<h;if(CollMemory_Add2(_,C,y,l),G){const I=c.GetSolModifiers(),T=(i.PushCopySol(I),r.GetCurrentSol()),b=f.GetCurrentSol();if(T._SetSelectAll(!1),b._SetSelectAll(!1),r===f){const A=T._GetOwnInstances();C33.clearArray(A),A.push(C),A.push(y),r.ApplySolToContainer()}else{const P=T._GetOwnInstances(),R=b._GetOwnInstances();C33.clearArray(P),C33.clearArray(R),P.push(C),R.push(y),r.ApplySolToContainer(),f.ApplySolToContainer()}c.Retrigger(o,u),i.PopSol(I)}}else CollMemory_Remove2(_,C,y)}C33.clearArray(tempCandidates1)}e.Pop()}return!1},AnySDK.IsOverlapping=function(e){return e=GetObjectClass2(e),DoOverlapCondition2(GetInst2(this),e,0,0)},AnySDK.IsOverlappingOffset=function(e,t,s){return e=GetObjectClass2(e),DoOverlapCondition2(GetInst2(this),e,t,s)},AnySDK.OnHierarchyReady=function(){return!0},AnySDK.HasParent=function(){return GetWorldInfo2(this).HasParent()},AnySDK.HasChildren=function(){return GetWorldInfo2(this).HasChildren()},AnySDK.PickParent=function(s,i){const e=GetObjectClass2(this),t=(s=GetObjectClass2(s),e.GetRuntime()),r=this.GetCurrentSol(),n=r.GetInstances();if(0===n.length)return!1;let a=s.GetCurrentSol(),o=a.GetInstances();if(a.IsSelectAll()){const c=[...t.instancesPendingCreateForObjectClass(s)];0<c.length&&(o=o.concat(c))}if(0===o.length)return!1;const l=a.IsSelectAll()?null:new Set(o),h=new Set;for(let e=0,t=n.length;e<t;++e){const u=n[e];if(1===i)for(const _ of u.parents())_.BelongsToObjectClass(s)&&(null===l||l.has(_))&&h.add(_);else{let e;if(0===i){if(null===(e=u.GetParent()))continue}else e=u.GetTopParent();e.BelongsToObjectClass(s)&&(null===l||l.has(e))&&h.add(e)}}return 0!==h.size&&(a.SetSetPicked(h),s.ApplySolToContainer(),!0)},AnySDK.PickChildren=function(s,i){const e=GetObjectClass2(this),t=(s=GetObjectClass2(s),e.GetRuntime()),r=e.GetCurrentSol(),n=r.GetInstances();if(0===n.length)return!1;let a=s.GetCurrentSol(),o=a.GetInstances();if(a.IsSelectAll()){const c=[...t.instancesPendingCreateForObjectClass(s)];0<c.length&&(o=o.concat(c))}if(0===o.length)return!1;const l=a.IsSelectAll()?null:new Set(o),h=new Set;for(let e=0,t=n.length;e<t;++e){const u=n[e];2!==i||u.HasChildren()||!u.BelongsToObjectClass(s)||null!==l&&!l.has(u)||h.add(u);for(const _ of 0===i?u.children():u.allChildren())2===i&&_.HasChildren()||_.BelongsToObjectClass(s)&&(null===l||l.has(_))&&h.add(_)}return 0!==h.size&&(a.SetSetPicked(h),s.ApplySolToContainer(),!0)},AnySDK.PickNthChild=function(s,i,r){const e=GetObjectClass2(this),t=(s=GetObjectClass2(s),e.GetRuntime()),n=e.GetCurrentSol(),a=n.GetInstances();if(0===a.length)return!1;let o=s.GetCurrentSol(),l=o.GetInstances();if(o.IsSelectAll()){const u=[...t.instancesPendingCreateForObjectClass(s)];0<u.length&&(l=l.concat(u))}if(0===l.length)return!1;const h=o.IsSelectAll()?null:new Set(l),c=[];for(let e=0,t=a.length;e<t;++e){const _=a[e];if(0===i){const d=_.GetChildAt(r);null!==d&&d.BelongsToObjectClass(s)&&(null===h||h.has(d))&&c.push(d)}else if(1===i)for(const p of _.children())if(p.BelongsToObjectClass(s)){if(0===r){null!==h&&!h.has(p)||c.push(p);break}--r}}return 0!==c.length&&(o.SetArrayPicked(c),s.ApplySolToContainer(),!0)},AnySDK.CompareChildCount=function(e,t,s){const i=GetInst2(this);switch(e){case 0:default:return C33.compare(i.GetChildCount(),t,s);case 1:return C33.compare(i.GetAllChildCount(),t,s)}},AnySDK.AddChild=function(e,t,s,i,r,n,a,o,l,h){e=GetObjectClass2(e);const c=GetInst2(this),u=runtime.GetCurrentAction().GetObjectClass();for(const _ of e.allCorrespondingInstances(c,u)){if(!_.GetPlugin().SupportsSceneGraph())return;c.AddChild(_,{transformX:t,transformY:s,transformWidth:i,transformHeight:r,transformAngle:n,transformOpacity:a,transformZElevation:o,transformVisibility:l,destroyWithParent:h})}},AnySDK.RemoveChild=function(e){e=GetObjectClass2(e);const t=GetInst2(this),s=runtime.GetCurrentAction().GetObjectClass();for(const i of e.allCorrespondingInstances(t,s))t.RemoveChild(i)},AnySDK.RemoveFromParent=function(){const e=GetInst2(this);if(e.HasParent()){const t=e.GetParent();t.RemoveChild(e)}},AnySDK.ParentUID=function(){const e=GetInst2(this).GetParent();return e?e.GetUID():-1},AnySDK.ChildCount=function(){return GetInst2(this).GetChildCount()},AnySDK.AllChildCount=function(){return GetInst2(this).GetAllChildCount()},AnySDK.SetMeshSize=function(e,t){e=Math.floor(e),t=Math.floor(t);const s=GetWorldInfo2(this);e<2||t<2||!isFinite(e)||!isFinite(t)?(s.ReleaseMesh(),s.SetBboxChanged()):s.CreateMesh(e,t)},AnySDK.SetMeshPoint=function(e,t,s,i,r,n,a,o){const l=GetWorldInfo2(this),h=l.SetMeshPoint(e,t,{mode:0===s?"absolute":"relative",x:i,y:r,zElevation:n,u:a,v:o});h&&l.SetBboxChanged()},AnySDK.MeshColumns=function(){const e=GetWorldInfo2(this);return e.HasMesh()?e.GetSourceMesh().GetHSize():0},AnySDK.MeshRows=function(){const e=GetWorldInfo2(this);return e.HasMesh()?e.GetSourceMesh().GetVSize():0},AnySDK.SetElementVisible=function(e){const t=GetWorldInfo2(this);e=2===e?!t.IsVisible():0!==e,t.IsVisible()!==e&&t.SetVisible(e)},AnySDK.SetElementCSSStyle=function(e,t){this instanceof self.IInstance?this.setElementCSSStyle(e,t):this.SetElementCSSStyle(e,t)},AnySDK.SetElementAttribute=function(e,t){this instanceof self.IInstance?this.setElementAttribute(e,""+t):this.SetElementAttribute(e,""+t)},AnySDK.RemoveElementAttribute=function(e){this instanceof self.IInstance?this.removeElementAttribute(e):this.RemoveElementAttribute(e)},AnySDK.SetElementFocus=function(){this instanceof self.IInstance?this.focusElement():this.FocusElement()},AnySDK.SetElementBlur=function(){this instanceof self.IInstance?this.blurElement():this.BlurElement()},AnySDK.IsElementFocused=function(){return this instanceof self.IInstance?this.isElementFocused():this.IsElementFocused()},AnySDK.SetElementEnabled=function(e){this instanceof self.IInstance?this._setEnabled(0!==e):this._SetEnabled(0!==e)},AnySDK.IsElementEnabled=function(){return this instanceof self.IInstance?this._isEnabled():this._IsEnabled()},SDKv1.CompareInstanceVar=function(e,t,s){return C33.compare(this.GetInstance().GetInstanceVariableValue(e),t,s)},SDKv2.CompareInstanceVar=function(e,t,s){return C33.compare(GetInst_SDKv22(this).GetInstanceVariableValue(e),t,s)},SDKv1.IsBoolInstanceVarSet=function(e){return!!this.GetInstance().GetInstanceVariableValue(e)},SDKv2.IsBoolInstanceVarSet=function(e){return!!GetInst_SDKv22(this).GetInstanceVariableValue(e)},AnySDK.PickInstVarHiLow=function(s,i){const r=GetObjectClass2(this),e=r.GetCurrentSol(),n=e.GetInstances();if(!n.length)return!1;let a=r.IsFamily(),o=null,l=0;for(let e=0,t=n.length;e<t;++e){const h=n[e],c=a?h.GetObjectClass().GetFamilyInstanceVariableOffset(r.GetFamilyIndex()):0,u=h.GetInstanceVariableValue(c+i);(null===o||0===s&&u<l||1===s&&u>l)&&(l=u,o=h)}return e.PickOne(o),!0},AnySDK.PickByUID=function(e){const t=GetObjectClass2(this);return(t.GetRuntime().GetCurrentCondition().IsInverted()?PickByUID_Inverted2:PickByUID_Normal2)(t,e)},AnySDK.HasTags=function(e){const t=new Set(C33.splitStringAndNormalize(e)),s=GetInst2(this).GetTagsSet();return t.isSubsetOf(s)},AnySDK.Tags=function(){return GetInst2(this).GetTagsString()},AnySDK.TagsCount=function(){return GetInst2(this).GetTagsSet().size},AnySDK.TagAt=function(e){return GetInst2(this).GetTagAt(e)},AnySDK.ChangeTags=function(e,t){const s=C33.splitStringAndNormalize(t);if(0!==s.length){const i=GetInst2(this),r=new Set(i.GetTagsSet());if(0===e)for(const n of s)r.add(n);else if(1===e)for(const a of s)r.delete(a);i.SetTagsSet(r)}},AnySDK.Destroy=function(){runtime.DestroyInstance(GetInst2(this))},AnySDK.OnCreated=function(){return!0},AnySDK.OnDestroyed=function(){return!0},SDKv1.SetInstanceVar=function(e,t){this.GetInstance().SetInstanceVariableValue(e,t)},SDKv2.SetInstanceVar=function(e,t){GetInst_SDKv22(this).SetInstanceVariableValue(e,t)},SDKv1.AddInstanceVar=function(e,t){const s=this.GetInstance(),i=s.GetInstanceVariableValue(e);"number"==typeof i&&"number"!=typeof t?t=parseFloat(t):"string"==typeof i&&"string"!=typeof t&&(t=t.toString()),s.SetInstanceVariableValue(e,i+t)},SDKv2.AddInstanceVar=function(e,t){const s=GetInst_SDKv22(this),i=s.GetInstanceVariableValue(e);"number"==typeof i&&"number"!=typeof t?t=parseFloat(t):"string"==typeof i&&"string"!=typeof t&&(t=t.toString()),s.SetInstanceVariableValue(e,i+t)},SDKv1.SubInstanceVar=function(e,t){const s=this.GetInstance(),i=s.GetInstanceVariableValue(e);"number"==typeof i&&("number"!=typeof t&&(t=parseFloat(t)),s.SetInstanceVariableValue(e,i-t))},SDKv2.SubInstanceVar=function(e,t){const s=GetInst_SDKv22(this),i=s.GetInstanceVariableValue(e);"number"==typeof i&&("number"!=typeof t&&(t=parseFloat(t)),s.SetInstanceVariableValue(e,i-t))},SDKv1.SetBoolInstanceVar=function(e,t){this.GetInstance().SetInstanceVariableValue(e,t?1:0)},SDKv2.SetBoolInstanceVar=function(e,t){GetInst_SDKv22(this).SetInstanceVariableValue(e,t?1:0)},SDKv1.ToggleBoolInstanceVar=function(e){const t=this.GetInstance();t.SetInstanceVariableValue(e,0===t.GetInstanceVariableValue(e)?1:0)},SDKv2.ToggleBoolInstanceVar=function(e){const t=GetInst_SDKv22(this);t.SetInstanceVariableValue(e,0===t.GetInstanceVariableValue(e)?1:0)},AnySDK.LoadFromJsonString=function(e){let t;try{t=JSON.parse(e)}catch(e){return void console.error("Failed to load from JSON string: ",e)}const s=GetInst2(this);runtime.ClearIntancesNeedingAfterLoad(),s._OnBeforeLoad("state"),s.LoadFromJson(t,"state"),runtime.DoAfterLoad("state",{setFromJson:!0})},AnySDK.AsJSON=function(){return JSON.stringify(GetInst2(this).SaveToJson("state"))},AnySDK.ObjectTypeName=function(){return GetInst2(this).GetObjectClass().GetName()},AnySDK.Count=function(){let e=runtime.GetCurrentEventStackFrame().GetExpressionObjectClass(),t=e.GetInstanceCount();for(const s of runtime.instancesPendingCreateForObjectClass(e))++t;return t},AnySDK.PickedCount=function(){return runtime.GetCurrentEventStackFrame().GetExpressionObjectClass().GetCurrentSol().GetInstances().length},SDKv1.GetIID=function(){return this.GetInstance().GetIID()},SDKv2.GetIID=function(){return GetInst_SDKv22(this).GetIID()},SDKv1.GetUID=function(){return this.GetInstance().GetUID()},SDKv2.GetUID=function(){return GetInst_SDKv22(this).GetUID()},AnySDK.OnInstanceSignal=function(e){const t=GetInst2(this);return e.toLowerCase()===runtime.GetEventSheetManager().GetCurrentInstanceSignalTag(t)},AnySDK.InstanceSignal=function(e){const t=GetInst2(this);runtime.GetEventSheetManager().InstanceSignal(t,e)},AnySDK.InstanceWaitForSignal=function(e){const t=GetObjectClass2(this);return runtime.GetEventSheetManager().AddScheduledWait().InitInstanceSignals(t.GetCurrentSol().GetInstances(),e),!0},AnySDK.TemplateName=function(){return GetInst2(this).GetTemplateName()},C33.AddCommonACEs=function(e,t,s){const i=e[1],r=e[3],n=e[4],a=e[5],o=e[6],l=e[7],h=e[8],c=e[10],u=e[11],_=e[12],d=e[13],p=e[14],m=e[15],g=e[16],f=t.Cnds,S=t.Acts,C=t.Exps,y=Object.assign({},AnySDK,2<=s?SDKv2:SDKv1);r&&(f.CompareX=y.CompareX,f.CompareY=y.CompareY,f.IsOnScreen=y.IsOnScreen,f.IsOutsideLayout=y.IsOutsideLayout,f.PickDistance=y.PickDistance,S.SetX=y.SetX,S.SetY=y.SetY,S.SetPos=y.SetPos,S.SetPosToObject=y.SetPosToObject,S.MoveForward=y.MoveForward,S.MoveAtAngle=y.MoveAtAngle,C.X=y.GetX,C.Y=y.GetY,C.dt=y.GetDt),n&&(f.CompareWidth=y.CompareWidth,f.CompareHeight=y.CompareHeight,S.SetWidth=y.SetWidth,S.SetHeight=y.SetHeight,S.SetSize=y.SetSize,C.Width=y.GetWidth,C.Height=y.GetHeight,C.BBoxLeft=y.GetBboxLeft,C.BBoxTop=y.GetBboxTop,C.BBoxRight=y.GetBboxRight,C.BBoxBottom=y.GetBboxBottom,C.BBoxMidX=y.GetBboxMidX,C.BBoxMidY=y.GetBboxMidY),a&&(f.AngleWithin=y.IsAngleWithin,f.IsClockwiseFrom=y.IsAngleClockwiseFrom,f.IsBetweenAngles=y.IsBetweenAngles,S.SetAngle=y.SetAngle,S.RotateClockwise=y.RotateClockwise,S.RotateCounterclockwise=y.RotateCounterclockwise,S.RotateTowardAngle=y.RotateTowardAngle,S.RotateTowardPosition=y.RotateTowardPosition,S.SetTowardPosition=y.SetTowardPosition,C.Angle=y.GetAngle),o&&(f.IsVisible=y.IsVisible,f.CompareOpacity=y.CompareOpacity,S.SetVisible=y.SetVisible,S.SetOpacity=y.SetOpacity,S.SetDefaultColor=y.SetDefaultColor,C.Opacity=y.GetOpacity,C.ColorValue=y.GetColor),l&&(f.IsOnLayer=y.IsOnLayer,f.PickTopBottom=y.PickTopBottom,f.CompareZElevation=y.CompareZElevation,S.MoveToTop=y.MoveToTop,S.MoveToBottom=y.MoveToBottom,S.MoveToLayer=y.MoveToLayer,S.ZMoveToObject=y.ZMoveToObject,S.SetZElevation=y.SetZElevation,C.LayerNumber=y.LayerNumber,C.LayerName=y.LayerName,C.ZIndex=y.ZIndex,C.ZElevation=y.ZElevation,C.TotalZElevation=y.TotalZElevation),h&&(f.IsEffectEnabled=y.IsEffectEnabled,S.SetEffectEnabled=y.SetEffectEnabled,S.SetEffectParam=y.SetEffectParam),d&&(f.OnHierarchyReady=y.OnHierarchyReady,f.HasParent=y.HasParent,f.HasChildren=y.HasChildren,f.PickParent=y.PickParent,f.PickChildren=y.PickChildren,f.PickNthChild=y.PickNthChild,f.CompareChildCount=y.CompareChildCount,S.AddChild=y.AddChild,S.RemoveChild=y.RemoveChild,S.RemoveFromParent=y.RemoveFromParent,C.ParentUID=y.ParentUID,C.ChildCount=y.ChildCount,C.AllChildCount=y.AllChildCount),p&&(S.SetMeshSize=y.SetMeshSize,S.SetMeshPoint=y.SetMeshPoint,C.MeshColumns=y.MeshColumns,C.MeshRows=y.MeshRows),c&&(f.IsVisible=y.IsVisible,S.SetVisible=y.SetElementVisible,S.SetCSSStyle=y.SetElementCSSStyle,S.SetElemAttribute=y.SetElementAttribute,S.RemoveElemAttribute=y.RemoveElementAttribute),u&&(f.IsFocused=y.IsElementFocused,S.SetFocus=y.SetElementFocus,S.SetBlur=y.SetElementBlur),_&&(f.IsEnabled=y.IsElementEnabled,S.SetEnabled=y.SetElementEnabled),m&&(f.OnCollision=y.OnCollision,f.IsOverlapping=y.IsOverlapping,f.IsOverlappingOffset=y.IsOverlappingOffset,t.FinishCollisionCondition=FinishCollisionCondition2),i||(f.CompareInstanceVar=y.CompareInstanceVar,f.IsBoolInstanceVarSet=y.IsBoolInstanceVarSet,f.PickInstVarHiLow=y.PickInstVarHiLow,f.PickByUID=y.PickByUID,f.HasTags=y.HasTags,S.SetInstanceVar=y.SetInstanceVar,S.AddInstanceVar=y.AddInstanceVar,S.SubInstanceVar=y.SubInstanceVar,S.SetBoolInstanceVar=y.SetBoolInstanceVar,S.ToggleBoolInstanceVar=y.ToggleBoolInstanceVar,S.ChangeTags=y.ChangeTags,f.OnCreated=y.OnCreated,f.OnDestroyed=y.OnDestroyed,S.Destroy=y.Destroy,S.LoadFromJsonString||(S.LoadFromJsonString=y.LoadFromJsonString),C.AsJSON||(C.AsJSON=y.AsJSON),C.Count=y.Count,C.PickedCount=y.PickedCount,C.IID=y.GetIID,C.UID=y.GetUID,C.ObjectTypeName=y.ObjectTypeName,C.Tags=y.Tags,C.TagsCount=y.TagsCount,C.TagAt=y.TagAt,f.OnInstanceSignal=y.OnInstanceSignal,S.InstanceSignal=y.InstanceSignal,S.InstanceWaitForSignal=y.InstanceWaitForSignal),g&&(C.TemplateName=y.TemplateName)}}{const C33=self.C3;C33.ScheduledWait=class extends C33.DefendedBase{constructor(e){super(),this._eventSheetManager=e,this._type="",this._time=-1,this._signalTag="",this._isSignalled=!1,this._event=null,this._actIndex=0,this._solModifiers=[],this._dynamicSolModifiers=null,this._sols=new Map,this._pendingInstances=null,this._callingFunctionBlock=null,this._asyncId=-1,this._functionParameters=null,this._functionInnerLocalVars=null,this._shouldRelease=!1}Release(){this._type="",this._time=-1,this._signalTag="",this._event=null,this._callingFunctionBlock=null,this._functionParameters=null,this._functionInnerLocalVars=null,this._asyncId=-1,C33.clearArray(this._solModifiers),this._dynamicSolModifiers&&(this._dynamicSolModifiers.clear(),this._dynamicSolModifiers=null);for(const e of this._sols.values())e.Release();this._sols.clear(),this._pendingInstances=null}_Init(){const e=this._eventSheetManager,t=e.GetRuntime().GetAllObjectClasses(),s=e.GetCurrentEventStackFrame(),i=(this._event=s.GetCurrentEvent(),this._actIndex=s.GetActionIndex()+1,e.FindFirstFunctionBlockParent(this._event));i&&(this._callingFunctionBlock=i,this._functionParameters=i.CaptureFunctionParameters(),this._functionInnerLocalVars=i._GetAllInnerLocalVariables().map(e=>e.GetValue()),i.IsAsync())&&(this._asyncId=i.PauseCurrentAsyncFunction());for(const n of t){const a=n.GetCurrentSol();a.IsSelectAll()&&!this._event.HasSolModifier(n)||(this._solModifiers.push(n),this._sols.set(n,C33.New(C33.SolState,a)))}const r=e.GetDynamicSolModifiersSet();this._dynamicSolModifiers=0<r.size?r:null}InitTimer(e){this._type="timer",this._Init(),this._time=this._eventSheetManager.GetRuntime().GetGameTime()+e}InitWallTimer(e){this._type="walltimer",this._Init(),this._time=this._eventSheetManager.GetRuntime().GetWallTime()+e}InitSignal(e){this._type="signal",this._Init(),this._signalTag=e.toLowerCase()}InitInstanceSignals(e,t){this._type="instance-signals",this._Init(),this._signalTag=t.toLowerCase(),this._pendingInstances=new Set(e)}InitPromise(e){this._type="promise",this._Init(),e.then(()=>this.SetSignalled()).catch(e=>{console.warn("[C3 runtime] Promise rejected in 'Wait for previous actions to complete': ",e),this.SetSignalled()})}IsTimer(){return"timer"===this._type}IsWallTimer(){return"walltimer"===this._type}IsSignal(){return"signal"===this._type}IsInstanceSignals(){return"instance-signals"===this._type}IsPromise(){return"promise"===this._type}GetSignalTag(){return this._signalTag}IsSignalled(){return this._isSignalled}SetSignalled(){this._isSignalled=!0}SetInstanceSignalled(e){this._pendingInstances.delete(e),0===this._pendingInstances.size&&this.SetSignalled()}_ShouldRun(){return this.IsTimer()?this._time<=this._eventSheetManager.GetRuntime().GetGameTime():this.IsWallTimer()?this._time<=this._eventSheetManager.GetRuntime().GetWallTime():this.IsSignalled()}_RestoreState(e){e._Restore(this._event,this._actIndex);for(const[s,i]of this._sols.entries()){const r=s.GetCurrentSol();i._Restore(r)}this._dynamicSolModifiers&&e.SetDynamicSolModifiers([...this._dynamicSolModifiers]);const t=this._callingFunctionBlock;t&&(t.SetFunctionParameters(this._functionParameters),t._GetAllInnerLocalVariables().map((e,t)=>e.SetValue(this._functionInnerLocalVars[t])),t.IsAsync())&&t.ResumeAsyncFunction(this._asyncId)}_Run(e){this._RestoreState(e),this._event._ResumeActionsAndSubEvents(e),this._callingFunctionBlock&&this._callingFunctionBlock.IsAsync()&&this._callingFunctionBlock.MaybeFinishAsyncFunctionCall(this._asyncId),this._eventSheetManager.ClearSol(this._solModifiers),this._shouldRelease=!0}async _DebugRun(e){this._RestoreState(e);for(const t of this._event._DebugResumeActionsAndSubEvents(e))await this._eventSheetManager.GetRuntime().DebugBreak(t);this._callingFunctionBlock&&this._callingFunctionBlock.IsAsync()&&this._callingFunctionBlock.MaybeFinishAsyncFunctionCall(this._asyncId),this._eventSheetManager.ClearSol(this._solModifiers),this._shouldRelease=!0}ShouldRelease(){return this._shouldRelease}RemoveInstances(e){for(const t of this._sols.values())t.RemoveInstances(e);if("instance-signals"===this._type){for(const s of e)this._pendingInstances.delete(s);0===this._pendingInstances.size&&this.SetSignalled()}}_SaveToJson(){const e={},t={wt:this._type,t:this._time,st:this._signalTag,s:this._isSignalled,ev:this._event.GetSID(),sm:this._solModifiers.map(e=>e.GetSID()),dsm:this._dynamicSolModifiers?[...this._dynamicSolModifiers].map(e=>e.GetSID()):null,sols:e};this._event._HasActionIndex(this._actIndex)&&(t.act=this._event.GetActionAt(this._actIndex).GetSID());for(const[s,i]of this._sols)e[s.GetSID().toString()]=i._SaveToJson();return"instance-signals"===this._type&&(t.pi=[...this._pendingInstances].map(e=>e.GetUID())),t}static _CreateFromJson(e,t){const s=e.GetRuntime(),i=e.GetEventBlockBySID(t.ev);if(!i)return null;let r=0;if(t.hasOwnProperty("act")){const a=e.GetActionBySID(t.act);if(!a)return null;r=a.GetIndex()}const n=C33.New(C33.ScheduledWait,e);n._time=t.t,t.hasOwnProperty("wt")?n._type=t.wt:n._type=-1===n._time?"signal":"timer",n._signalTag=t.st,n._isSignalled=t.s,n._event=i,n._actIndex=r;for(const o of t.sm){const l=s.GetObjectClassBySID(o);l&&n._solModifiers.push(l)}if(Array.isArray(t.dsm))for(const h of t.dsm){const c=s.GetObjectClassBySID(h);c&&(n._dynamicSolModifiers||(n._dynamicSolModifiers=new Set),n._dynamicSolModifiers.add(c))}for(const[u,_]of Object.entries(t.sols)){const d=parseInt(u,10),p=s.GetObjectClassBySID(d);if(p){const m=C33.New(C33.SolState,null);m._LoadFromJson(e,_),n._sols.set(p,m)}}if("instance-signals"===n._type){n._pendingInstances=new Set;for(const g of t.pi){const f=s.GetInstanceByUID(g);f&&n._pendingInstances.add(f)}}return n}}}{const C33=self.C3;C33.SolState=class extends C33.DefendedBase{constructor(e){super(),this._objectClass=null,this._isSelectAll=!0,this._instances=[],e&&(this._objectClass=e.GetObjectClass(),this._isSelectAll=e.IsSelectAll(),C33.shallowAssignArray(this._instances,e._GetOwnInstances()))}Release(){this._objectClass=null,C33.clearArray(this._instances)}_Restore(e){e._SetSelectAll(this._isSelectAll),C33.shallowAssignArray(e._GetOwnInstances(),this._instances)}RemoveInstances(e){C33.arrayRemoveAllInSet(this._instances,e)}_SaveToJson(){return{sa:this._isSelectAll,insts:this._instances.map(e=>e.GetUID())}}_LoadFromJson(e,t){const s=e.GetRuntime();this._isSelectAll=!!t.sa,C33.clearArray(this._instances);for(const i of t.insts){const r=s.GetInstanceByUID(i);r&&this._instances.push(r)}}}}{let GetNextParamMap2=function(e,t){let s=e.get(t);return s||(s=new Map,e.set(t,s)),s};GetNextParamMap=GetNextParamMap2;const C33=self.C3;C33.SDKPluginBase=class extends C33.DefendedBase{constructor(e){super(),this._runtime=e.runtime,this._name=e.name??"",this._isSingleGlobal=!!e.isSingleGlobal,this._isWorldType=!!e.isWorld,this._isRotatable=!!e.isRotatable,this._mustPredraw=!!e.mustPredraw,this._hasEffects=!!e.hasEffects,this._supportsSceneGraph=!!e.supportsSceneGraph,this._supportsMesh=!!e.supportsMesh,this._isHTMLElementType=!!e.isHTMLElementType,this._is3d=!!e.is3d,this._sdkVersion=e.sdkVersion,this._singleGlobalObjectClass=null,this._boundACEMethodCache=new Map,this._boundACEMethodCache_1param=new Map,this._boundACEMethodCache_2params=new Map,this._boundACEMethodCache_3params=new Map,this._scriptInterfaceClass=e.scriptInterfaceClass,this._iPlugin=null}Release(){this._runtime=null}GetRuntime(){return this._runtime}GetName(){return this._name}OnCreate(){}GetConstructor(){return(2<=this.GetSdkVersion()?this._iPlugin:this).constructor}GetSdkVersion(){return this._sdkVersion}GetScriptInterfaceClass(e=!1){let t=this._scriptInterfaceClass;return e&&"function"!=typeof t&&2<=this.GetSdkVersion()?globalThis.ISDKPluginBase:t}IsSingleGlobal(){return this._isSingleGlobal}IsWorldType(){return this._isWorldType}IsHTMLElementType(){return this._isHTMLElementType}Is3D(){return this._is3d}IsRotatable(){return this._isRotatable}MustPreDraw(){return this._mustPredraw}HasEffects(){return this._hasEffects}SupportsSceneGraph(){return this._supportsSceneGraph}SupportsMesh(){return this._supportsMesh}_GetBoundACEMethod(e,t){if(!t)throw new Error("missing 'this' binding");let s=this._boundACEMethodCache.get(e);return s||(s=e.bind(t),this._boundACEMethodCache.set(e,s)),s}_GetBoundACEMethod_1param(e,t,s){if(!t)throw new Error("missing 'this' binding");let i=GetNextParamMap2(this._boundACEMethodCache_1param,e),r=i.get(s);return r||(r=e.bind(t,s),i.set(s,r)),r}_GetBoundACEMethod_2params(e,t,s,i){if(!t)throw new Error("missing 'this' binding");let r=GetNextParamMap2(this._boundACEMethodCache_2params,e),n=GetNextParamMap2(r,s),a=n.get(i);return a||(a=e.bind(t,s,i),n.set(i,a)),a}_GetBoundACEMethod_3params(e,t,s,i,r){if(!t)throw new Error("missing 'this' binding");let n=GetNextParamMap2(this._boundACEMethodCache_3params,e),a=GetNextParamMap2(n,s),o=GetNextParamMap2(a,i),l=o.get(r);return l||(l=e.bind(t,s,i,r),o.set(r,l)),l}_SetSingleGlobalObjectClass(e){if(!this.IsSingleGlobal())throw new Error("must be single-global plugin");this._singleGlobalObjectClass=e}GetSingleGlobalObjectClass(){if(this.IsSingleGlobal())return this._singleGlobalObjectClass;throw new Error("must be single-global plugin")}GetSingleGlobalInstance(){if(this.IsSingleGlobal())return this._singleGlobalObjectClass.GetSingleGlobalInstance();throw new Error("must be single-global plugin")}_InitScriptInterface(){const e=this.GetSdkVersion(),t=(C33.AddonManager._PushInitObject(this,e),this.GetScriptInterfaceClass(!0));if(t){if(this._iPlugin=new t,!(this._iPlugin instanceof self.IPlugin))throw new TypeError("plugin class must derive from IPlugin")}else this._iPlugin=new self.IPlugin;C33.AddonManager._PopInitObject(e)}GetIPlugin(){return this._iPlugin}}}{const C33=self.C3;C33.SDKDOMPluginBase=class extends C33.SDKPluginBase{constructor(e,t){super(e),this._domComponentId=t,this._nextElementId=0,this._instMap=new Map,this.AddElementMessageHandler("elem-focused",e=>e._OnElemFocused()),this.AddElementMessageHandler("elem-blurred",e=>{e&&e._OnElemBlurred()})}Release(){super.Release()}_AddElement(e){const t=this._nextElementId++;return this._instMap.set(t,e),t}_RemoveElement(e){this._instMap.delete(e)}AddElementMessageHandler(e,s){this._runtime.AddDOMComponentMessageHandler(this._domComponentId,e,e=>{const t=this._instMap.get(e.elementId);s(t,e)})}}}{const C33=self.C3;C33.SDKTypeBase=class extends C33.DefendedBase{constructor(e){super(),this._objectClass=e,this._runtime=e.GetRuntime(),this._plugin=e.GetPlugin()}Release(){this._objectClass=null,this._runtime=null,this._plugin=null}GetObjectClass(){return this._objectClass}GetRuntime(){return this._runtime}GetPlugin(){return this._plugin}GetImageInfo(){return this._objectClass.GetImageInfo()}OnCreate(){}FinishCondition(e){}BeforeRunAction(e){}AfterRunAction(e){}LoadTextures(e){}ReleaseTextures(){}OnDynamicTextureLoadComplete(){}PreloadTexturesWithInstances(e){}LoadTilemapData(){}GetScriptInterfaceClass(){return null}DispatchScriptEvent(e,t,s){const i=C33.New(C33.Event,e,t);i.objectClass=this,s&&Object.assign(i,s),this.GetObjectClass().DispatchUserScriptEvent(i)}}}{const C33=self.C3;C33.SDKInstanceBase=class extends C33.DefendedBase{constructor(e,t){super(),this._inst=e,this._domComponentId=t,this._wrapperComponentId=null,this._runtime=e.GetRuntime(),this._objectClass=this._inst.GetObjectClass(),this._sdkType=this._objectClass.GetSdkType(),this._tickFunc=null,this._tick2Func=null,this._isTicking=!1,this._isTicking2=!1,this._disposables=null,this._wasReleased=!1}Release(){this._wasReleased=!0,this._StopTicking(),this._StopTicking2(),this._tickFunc=null,this._tick2Func=null,this._disposables&&(this._disposables.Release(),this._disposables=null),this._inst=null,this._runtime=null,this._objectClass=null,this._sdkType=null}WasReleased(){return this._wasReleased}GetInstance(){return this._inst}GetRuntime(){return this._runtime}GetObjectClass(){return this._objectClass}GetPlugin(){return this._sdkType.GetPlugin()}GetSdkType(){return this._sdkType}GetScriptInterface(){return this._inst.GetInterfaceClass()}Trigger(e){return this._runtime.Trigger(e,this._inst,null)}DebugTrigger(e){return this._runtime.DebugTrigger(e,this._inst,null)}TriggerAsync(e){return this._runtime.TriggerAsync(e,this._inst,null)}FastTrigger(e,t){return this._runtime.FastTrigger(e,this._inst,t)}DebugFastTrigger(e,t){return this._runtime.DebugFastTrigger(e,this._inst,t)}ScheduleTriggers(e){return this._runtime.ScheduleTriggers(e)}AddDOMMessageHandler(e,t){this._runtime.AddDOMComponentMessageHandler(this._domComponentId,e,t)}AddDOMMessageHandlers(e){for(const[t,s]of e)this.AddDOMMessageHandler(t,s)}PostToDOM(e,t){this._runtime.PostComponentMessageToDOM(this._domComponentId,e,t)}PostToDOMAsync(e,t){return this._runtime.PostComponentMessageToDOMAsync(this._domComponentId,e,t)}_PostToDOMMaybeSync(e,t){if(!this._runtime.IsInWorker())return window.c3_runtimeInterface._OnMessageFromRuntime({type:"event",component:this._domComponentId,handler:e,data:t,responseId:null});this.PostToDOM(e,t)}SetWrapperExtensionComponentId(e){if(!e)throw new Error("cannot set empty component id");this._wrapperComponentId=e}IsWrapperExtensionAvailable(){if(this._wrapperComponentId)return this._runtime.HasWrapperComponentId(this._wrapperComponentId);throw new Error("wrapper extension component id not set")}AddWrapperExtensionMessageHandler(e,t){if(!this._wrapperComponentId)throw new Error("wrapper extension component id not set");this._runtime.AddWrapperExtensionMessageHandler(this._wrapperComponentId,e,t)}AddWrapperExtensionMessageHandlers(e){for(const[t,s]of e)this.AddWrapperExtensionMessageHandler(t,s)}SendWrapperExtensionMessage(e,t){if(!this._wrapperComponentId)throw new Error("wrapper extension component id not set");this._runtime.SendWrapperExtensionMessage(this._wrapperComponentId,e,t)}SendWrapperExtensionMessageAsync(e,t){if(this._wrapperComponentId)return this._runtime.SendWrapperExtensionMessageAsync(this._wrapperComponentId,e,t);throw new Error("wrapper extension component id not set")}Tick(){}Tick2(){}_StartTicking(){if(!this._isTicking){if(!this._tickFunc)if(this._runtime.IsDebug()){const t=globalThis.C3Debugger,s=this.GetPlugin();this._tickFunc=()=>{const e=performance.now();this.Tick(),t.AddIndividualPluginTickTime(s,performance.now()-e)}}else this._tickFunc=()=>this.Tick();this._runtime.Dispatcher().addEventListener("tick",this._tickFunc),this._isTicking=!0}}_StopTicking(){this._isTicking&&(this._runtime.Dispatcher().removeEventListener("tick",this._tickFunc),this._isTicking=!1)}IsTicking(){return this._isTicking}_StartTicking2(){if(!this._isTicking2){if(!this._tick2Func)if(this._runtime.IsDebug()){const t=globalThis.C3Debugger,s=this.GetPlugin();this._tick2Func=()=>{const e=performance.now();this.Tick2(),t.AddIndividualPluginTickTime(s,performance.now()-e)}}else this._tick2Func=()=>this.Tick2();this._runtime.Dispatcher().addEventListener("tick2",this._tick2Func),this._isTicking2=!0}}_StopTicking2(){this._isTicking2&&(this._runtime.Dispatcher().removeEventListener("tick2",this._tick2Func),this._isTicking2=!1)}IsTicking2(){return this._isTicking2}GetDebuggerProperties(){return[]}SaveToJson(){return null}LoadFromJson(e){}GetPropertyValueByIndex(e){}SetPropertyValueByIndex(e,t){}OffsetPropertyValueByIndex(e,t,s){if(0!==t){const i=this.GetPropertyValueByIndex(e);if("number"!=typeof i)throw new Error("expected number");this.SetPropertyValueByIndex(e,i+t,s)}}SetPropertyColorOffsetValueByIndex(e,t,s,i){}CallAction(e,...t){e.call(this,...t)}CallExpression(e,...t){return e.call(this,...t)}GetScriptInterfaceClass(){return null}DispatchScriptEvent(e,t,s){if(this._inst.HasScriptInterface()){const i=this.GetScriptInterface(),r=C33.New(C33.Event,e,t);r.instance=i,s&&Object.assign(r,s),i.dispatchEvent(r)}}MustPreDraw(){return!1}}}{const C33=self.C3;C33.SDKWorldInstanceBase=class extends C33.SDKInstanceBase{constructor(e,t){super(e,t),this._worldInfo=e.GetWorldInfo(),this._renderercontextlost_handler=null,this._renderercontextrestored_handler=null}Release(){if(this._renderercontextlost_handler){const e=this._runtime.Dispatcher();e.removeEventListener("renderercontextlost",this._renderercontextlost_handler),e.removeEventListener("renderercontextrestored",this._renderercontextrestored_handler),this._renderercontextlost_handler=null,this._renderercontextrestored_handler=null}this._worldInfo=null,super.Release()}HandleWebGLContextLoss(){this.HandleRendererContextLoss()}OnWebGLContextLost(){}OnWebGLContextRestored(){}HandleRendererContextLoss(){if(!this._renderercontextlost_handler){this._renderercontextlost_handler=()=>this.OnRendererContextLost(),this._renderercontextrestored_handler=()=>this.OnRendererContextRestored();const e=this._runtime.Dispatcher();e.addEventListener("renderercontextlost",this._renderercontextlost_handler),e.addEventListener("renderercontextrestored",this._renderercontextrestored_handler)}}OnRendererContextLost(){this.OnWebGLContextLost()}OnRendererContextRestored(){this.OnWebGLContextRestored()}GetWorldInfo(){return this._worldInfo}IsOriginalSizeKnown(){return!1}GetOriginalWidth(){if(!this.IsOriginalSizeKnown())throw new Error("original size not known");const e=this.GetCurrentImageInfo();if(e)return e.GetWidth()}GetOriginalHeight(){if(!this.IsOriginalSizeKnown())throw new Error("original size not known");const e=this.GetCurrentImageInfo();if(e)return e.GetHeight()}GetCurrentImageInfo(){return null}GetCurrentSurfaceSize(){const e=this.GetCurrentImageInfo();if(e){const t=e.GetTexture();if(t)return[t.GetWidth(),t.GetHeight()]}return[100,100]}GetCurrentTexRect(){const e=this.GetCurrentImageInfo();return e?e.GetTexRect():null}GetCurrentTexQuad(){const e=this.GetCurrentImageInfo();return e?e.GetTexQuad():null}IsCurrentTexRotated(){const e=this.GetCurrentImageInfo();return!!e&&e.IsRotated()}GetImagePoint(e){const t=this._inst.GetWorldInfo();return[t.GetX(),t.GetY(),t.GetTotalZElevation()]}LoadTilemapData(e,t,s){}TestPointOverlapTile(e,t){}RendersToOwnZPlane(){return!0}}}{const C33=self.C3,tempRect=C33.New(C33.Rect);C33.SDKDOMInstanceBase=class extends C33.SDKWorldInstanceBase{constructor(e,t){super(e,t),this._elementId=this.GetPlugin()._AddElement(this),this._isElementShowing=!0,this._elemHasFocus=!1,this._autoFontSize=!1,this._autoFontSizeOffset=-.2,this._lastRect=C33.New(C33.Rect,0,0,-1,-1);const s=this._runtime.GetCanvasManager();this._lastWindowWidth=s.GetLastWidth(),this._lastWindowHeight=s.GetLastHeight(),this._lastHTMLIndex=-1,this._lastHTMLZIndex=-1,this._isPendingUpdateState=!1,this._StartTicking()}Release(){this.GetPlugin()._RemoveElement(this._elementId),this.PostToDOMElement("destroy"),this._elementId=-1,super.Release()}_GetElementInDOMMode(){if(this._runtime.IsInWorker())throw new Error("not valid in worker mode");return this._PostToDOMElementMaybeSync("get-element")}PostToDOMElement(e,t){(t=t||{}).elementId=this._elementId,this.PostToDOM(e,t)}_PostToDOMElementMaybeSync(e,t){return(t=t||{}).elementId=this._elementId,this._PostToDOMMaybeSync(e,t)}PostToDOMElementAsync(e,t){return(t=t||{}).elementId=this._elementId,this.PostToDOMAsync(e,t)}CreateElement(e){e=e||{};const t=this.GetWorldInfo();e.elementId=this._elementId,e.isVisible=t.IsVisible(),e.htmlIndex=t.GetLayer().GetHTMLIndex(),e.htmlZIndex=t.GetHTMLZIndex(),Object.assign(e,this.GetElementState()),this._isElementShowing=!!e.isVisible,this._PostToDOMMaybeSync("create",e),this._UpdatePosition(!0)}SetElementVisible(e){this._isElementShowing!==(e=!!e)&&(this._isElementShowing=e,this.PostToDOMElement("set-visible",{isVisible:e}))}Tick(){this._UpdatePosition(!1)}_ShouldPreserveElement(){const e=this._runtime.GetCanvasManager().GetFullscreenMode();return"Android"===C33.Platform.OS&&("scale-inner"===e||"scale-outer"===e||"crop"===e)}_UpdatePosition(c){if(!this.GetInstance().IsDestroyed()){let e=this.GetWorldInfo(),t=e.GetLayer(),s=e.GetBoundingBox(),[i,r]=t.LayerToCanvasCss(s.getLeft(),s.getTop()),[n,a]=t.LayerToCanvasCss(s.getRight(),s.getBottom()),o=this._runtime.GetCanvasManager(),l=o.GetCssWidth(),h=o.GetCssHeight();if(e.IsVisible()&&t.IsVisible())if(!this._ShouldPreserveElement()&&(n<=0||a<=0||l<=i||h<=r))this.SetElementVisible(!1);else{tempRect.set(i,r,n,a);const u=o.GetLastWidth(),_=o.GetLastHeight(),d=t.GetHTMLIndex(),p=e.GetHTMLZIndex();if(!c&&tempRect.equals(this._lastRect)&&this._lastWindowWidth===u&&this._lastWindowHeight===_&&this._lastHTMLIndex===d&&this._lastHTMLZIndex===p)this.SetElementVisible(!0);else{this._lastRect.copy(tempRect),this._lastWindowWidth=u,this._lastWindowHeight=_,this._lastHTMLIndex=d,this._lastHTMLZIndex=p,this.SetElementVisible(!0);let e=null;this._autoFontSize&&(e=t.GetDisplayScale()+this._autoFontSizeOffset),this.PostToDOMElement("update-position",{left:Math.round(this._lastRect.getLeft()),top:Math.round(this._lastRect.getTop()),width:Math.round(this._lastRect.width()),height:Math.round(this._lastRect.height()),htmlIndex:d,htmlZIndex:p,fontSize:e})}}else this.SetElementVisible(!1)}}FocusElement(){this._PostToDOMElementMaybeSync("focus",{focus:!0})}BlurElement(){this._PostToDOMElementMaybeSync("focus",{focus:!1})}_OnElemFocused(){this._elemHasFocus=!0}_OnElemBlurred(){this._elemHasFocus=!1}IsElementFocused(){return this._elemHasFocus}SetElementCSSStyle(e,t){this.PostToDOMElement("set-css-style",{prop:C33.CSSToCamelCase(e),val:t})}SetElementAttribute(e,t){this.PostToDOMElement("set-attribute",{name:e,val:t})}RemoveElementAttribute(e){this.PostToDOMElement("remove-attribute",{name:e})}UpdateElementState(){this._isPendingUpdateState||(this._isPendingUpdateState=!0,Promise.resolve().then(()=>{this._isPendingUpdateState=!1,this.PostToDOMElement("update-state",this.GetElementState())}))}GetElementState(){}GetElementId(){return this._elementId}}}{const C33=self.C3,IBehavior=self.IBehavior;C33.SDKBehaviorBase=class extends C33.DefendedBase{constructor(e){super(),this._runtime=e.runtime,this._name=e.name??"",this._myObjectClasses=C33.New(C33.ArraySet),this._myInstances=C33.New(C33.ArraySet),this._sdkVersion=e.sdkVersion,this._scriptInterfaceClass=e.scriptInterfaceClass,this._iBehavior=null}Release(){this._myInstances.Release(),this._myObjectClasses.Release(),this._runtime=null}GetRuntime(){return this._runtime}GetName(){return this._name}OnCreate(){}GetSdkVersion(){return this._sdkVersion}GetScriptInterfaceClass(e=!1){let t=this._scriptInterfaceClass;return e&&"function"!=typeof t&&2<=this.GetSdkVersion()?globalThis.ISDKBehaviorBase:t}_AddObjectClass(e){this._myObjectClasses.Add(e)}GetObjectClasses(){return this._myObjectClasses.GetArray()}_AddInstance(e){this._myInstances.Add(e)}_RemoveInstance(e){this._myInstances.Delete(e)}GetInstances(){return this._myInstances.GetArray()}_InitScriptInterface(){const e=this.GetSdkVersion(),t=(C33.AddonManager._PushInitObject(this,e),this.GetScriptInterfaceClass(!0));if(t){if(this._iBehavior=new t,!(this._iBehavior instanceof IBehavior))throw new TypeError("behavior class must derive from IBehavior")}else this._iBehavior=new IBehavior;C33.AddonManager._PopInitObject(e)}GetIBehavior(){return this._iBehavior}}}{const C33=self.C3;C33.SDKBehaviorTypeBase=class extends C33.DefendedBase{constructor(e){super(),this._runtime=e.GetRuntime(),this._behaviorType=e,this._objectClass=e.GetObjectClass(),this._behavior=e.GetBehavior(),this._behavior._AddObjectClass(this._objectClass)}Release(){this._runtime=null,this._behaviorType=null,this._objectClass=null,this._behavior=null}OnCreate(){}GetBehaviorType(){return this._behaviorType}GetObjectClass(){return this._objectClass}GetRuntime(){return this._runtime}GetBehavior(){return this._behavior}}}{const C33=self.C3;C33.SDKBehaviorInstanceBase=class extends C33.DefendedBase{constructor(e,t){super(),this._behInst=e,this._domComponentId=t,this._inst=e.GetObjectInstance(),this._runtime=e.GetRuntime(),this._behaviorType=e.GetBehaviorType(),this._sdkType=this._behaviorType.GetSdkType(),this._isTicking=!1,this._isTicking2=!1,this._isPostTicking=!1,this._disposables=null}Release(){this._StopTicking(),this._StopTicking2(),this._StopPostTicking(),this._disposables&&(this._disposables.Release(),this._disposables=null),this._behInst=null,this._inst=null,this._runtime=null,this._behaviorType=null,this._sdkType=null}GetBehavior(){return this._behaviorType.GetBehavior()}GetBehaviorInstance(){return this._behInst}GetObjectInstance(){return this._inst}GetObjectClass(){return this._inst.GetObjectClass()}GetWorldInfo(){return this._inst.GetWorldInfo()}GetRuntime(){return this._runtime}GetBehaviorType(){return this._behaviorType}GetSdkType(){return this._sdkType}GetScriptInterface(){return this._behInst.GetScriptInterface()}Trigger(e){return this._runtime.Trigger(e,this._inst,this._behaviorType)}DebugTrigger(e){return this._runtime.DebugTrigger(e,this._inst,this._behaviorType)}TriggerAsync(e){return this._runtime.TriggerAsync(e,this._inst,this._behaviorType)}PostCreate(){}Tick(){}Tick2(){}PostTick(){}_StartTicking(){this._isTicking||(this._runtime._AddBehInstToTick(this),this._isTicking=!0)}_StopTicking(){this._isTicking&&(this._runtime._RemoveBehInstToTick(this),this._isTicking=!1)}IsTicking(){return this._isTicking}_StartTicking2(){this._isTicking2||(this._runtime._AddBehInstToTick2(this),this._isTicking2=!0)}_StopTicking2(){this._isTicking2&&(this._runtime._RemoveBehInstToTick2(this),this._isTicking2=!1)}IsTicking2(){return this._isTicking2}_StartPostTicking(){this._isPostTicking||(this._runtime._AddBehInstToPostTick(this),this._isPostTicking=!0)}_StopPostTicking(){this._isPostTicking&&(this._runtime._RemoveBehInstToPostTick(this),this._isPostTicking=!1)}IsPostTicking(){return this._isPostTicking}GetDebuggerProperties(){return[]}AddDOMMessageHandler(e,t){this._runtime.AddDOMComponentMessageHandler(this._domComponentId,e,t)}OnSpriteFrameChanged(e,t){}SaveToJson(){return null}LoadFromJson(e){}GetPropertyValueByIndex(e){}SetPropertyValueByIndex(e,t){}OffsetPropertyValueByIndex(e,t){if(0!==t){const s=this.GetPropertyValueByIndex(e);if("number"!=typeof s)throw new Error("expected number");this.SetPropertyValueByIndex(e,s+t)}}SetPropertyColorOffsetValueByIndex(e,t,s,i){}CallAction(e,...t){e.call(this,...t)}CallExpression(e,...t){return e.call(this,...t)}GetScriptInterfaceClass(){return null}DispatchScriptEvent(e,t,s){if(this._behInst.HasScriptInterface()){const i=this.GetScriptInterface(),r=C33.New(C33.Event,e,t);r.behaviorInstance=i,r.instance=i.instance,s&&Object.assign(r,s),i.dispatchEvent(r)}}}}{let ValidateInternalAPIToken2=function(e){if(e!==internalApiToken)throw new Error("invalid internal API token")},C33=(ValidateInternalAPIToken=ValidateInternalAPIToken2,self.C3),internalApiToken=(C33.Plugins={},C33.Behaviors={},C33._GetInternalAPIToken()),initObjectStack=[],initObjectStack2=[],initPropertiesStack=[],originalPushInitObject=null,originalPopInitObject=null,originalGetInitObject=null,originalGetInitObject2=null,pluginsByCtor=new Map,behaviorsByCtor=new Map;C33.AddonManager=class extends C33.DefendedBase{constructor(e,t){super(),this._runtime=e,this._allPlugins=[],this._systemPlugin=null,this._allBehaviors=[],this._delayCreateBehaviors=new Map,this._solidBehavior=null,this._jumpthruBehavior=null,this._wrapperComponentIds=new Set(t)}CreatePlugin(e){const t=e[19],s=this._runtime.GetObjectReference(e[0]);if(!s)throw new Error("missing plugin");C33.AddCommonACEs(e,s,t);const i=2<=t?C33.SDKPluginBase:s,r=C33.New(i,{runtime:this._runtime,isSingleGlobal:e[1],isWorld:e[2],isRotatable:e[5],hasEffects:e[8],mustPredraw:e[9],supportsSceneGraph:e[13],supportsMesh:e[14],isHTMLElementType:e[17],is3d:e[18],sdkVersion:t,name:e[20],scriptInterfaceClass:2<=t?s:null});r.OnCreate(),this._allPlugins.push(r),pluginsByCtor.set(s,r)}CreateSystemPlugin(){this._systemPlugin=C33.New(C33.Plugins.System,{runtime:this._runtime,isSingleGlobal:!0}),this._systemPlugin.OnCreate()}CreateBehavior(e){const s=e[1],i=e[2],r=this._runtime.GetObjectReference(e[0]);if(!r)throw new Error("missing behavior");this._delayCreateBehaviors.set(r,()=>{const e=2<=s?C33.SDKBehaviorBase:r,t=C33.New(e,{runtime:this._runtime,name:i,sdkVersion:s,scriptInterfaceClass:2<=s?r:null});t.OnCreate(),this._allBehaviors.push(t),behaviorsByCtor.set(r,t),!this._solidBehavior&&C33.Behaviors.solid&&t instanceof C33.Behaviors.solid?this._solidBehavior=t:!this._jumpthruBehavior&&C33.Behaviors.jumpthru&&t instanceof C33.Behaviors.jumpthru&&(this._jumpthruBehavior=t),t._InitScriptInterface()})}_DelayCreateBehavior(e){const t=this._delayCreateBehaviors.get(e);t&&(t(),this._delayCreateBehaviors.delete(e))}static _PushInitObject(e,t=1){if(C33.AddonManager._PushInitObject!==originalPushInitObject)throw new Error("invalid method");1===t&&initObjectStack.push(e),initObjectStack2.push(e)}static _PopInitObject(e=1){if(C33.AddonManager._PopInitObject!==originalPopInitObject)throw new Error("invalid method");1===e&&initObjectStack.pop(),initObjectStack2.pop()}static _GetInitObject(){if(C33.AddonManager._GetInitObject!==originalGetInitObject)throw new Error("invalid method");if(0===initObjectStack.length)throw new Error("no init object set");return initObjectStack.at(-1)}static _GetInitObject2(e){if(C33.AddonManager._GetInitObject2!==originalGetInitObject2)throw new Error("invalid method");if(ValidateInternalAPIToken2(e),0===initObjectStack2.length)throw new Error("no init object set");return initObjectStack2.at(-1)}static _PushInitProperties(e){initPropertiesStack.push(e)}static _PopInitProperties(){initPropertiesStack.pop()}static _GetInitProperties(){if(0===initPropertiesStack.length)throw new Error("no init properties set");return initPropertiesStack.at(-1)}_InitAddonScriptInterfaces(){for(const e of this._allPlugins)e._InitScriptInterface()}static GetPluginByConstructorFunction(e){return pluginsByCtor.get(e)||null}static GetBehaviorByConstructorFunction(e){return behaviorsByCtor.get(e)||null}GetSystemPlugin(){return this._systemPlugin}GetSolidBehavior(){return this._solidBehavior}GetJumpthruBehavior(){return this._jumpthruBehavior}HasWrapperComponentId(e){return this._wrapperComponentIds.has(e)}},originalPushInitObject=C33.AddonManager._PushInitObject,originalPopInitObject=C33.AddonManager._PopInitObject,originalGetInitObject=C33.AddonManager._GetInitObject,originalGetInitObject2=C33.AddonManager._GetInitObject2}{const C33=self.C3,allImageInfos=new Set;C33.ImageInfo=class extends C33.DefendedBase{constructor(){super(),this._generation=0,this._url="",this._size=0,this._offsetX=0,this._offsetY=0,this._width=0,this._height=0,this._isRotated=!1,this._hasMetaData=!1,this._imageAsset=null,this._textureState="",this._rcTex=C33.New(C33.Rect),this._quadTex=C33.New(C33.Quad),this._blobUrl="",this._iImageInfo=new self.IImageInfo(this),allImageInfos.add(this)}Release(){this.ReleaseTexture(),this._imageAsset&&0===this._imageAsset.GetRefCount()&&this._imageAsset.Release(),this._imageAsset=null,allImageInfos.delete(this),this.ReleaseBlobURL()}static OnRendererContextLost(){for(const e of allImageInfos)e._textureState="",e._rcTex.set(0,0,0,0),e._quadTex.setFromRect(e._rcTex)}LoadData(e){this._url=e[0],this._size=e[1],this._offsetX=e[2],this._offsetY=e[3],this._width=e[4],this._height=e[5],this._isRotated=e[6],this._hasMetaData=!0}LoadDynamicAsset(e,t){if(this._imageAsset)throw new Error("already loaded asset");this._url=t;const s={};return C33.IsAbsoluteURL(t)&&(s.loadPolicy="remote"),this.LoadAsset(e,s),this._imageAsset.Load()}LoadDynamicBlobAsset(e,t){if(this._imageAsset)throw new Error("already loaded asset");this._url="",this._size=t.size,this._imageAsset=C33.New(C33.ImageAsset,e.GetAssetManager(),{blob:t,size:this._size,loadPolicy:"local"})}ReplaceWith(e){if(e===this)throw new Error("cannot replace with self");this._generation++,this.ReleaseTexture(),this._url=e._url,this._size=e._size,this._offsetX=e._offsetX,this._offsetY=e._offsetY,this._width=e._width,this._height=e._height,this._isRotated=e._isRotated,this._hasMetaData=e._hasMetaData,this._imageAsset=e._imageAsset,this._textureState=e._textureState,this._rcTex=e._rcTex,this._quadTex=e._quadTex,this.ReleaseBlobURL()}GetURL(){return this._url}GetSize(){return this._size}GetOffsetX(){return this._offsetX}GetOffsetY(){return this._offsetY}IsRotated(){return this._isRotated}GetWidth(){return this._width}GetHeight(){return this._height}GetSheetWidth(){return this._imageAsset.GetWidth()}GetSheetHeight(){return this._imageAsset.GetHeight()}LoadAsset(e,t){if(this._imageAsset)throw new Error("already got asset");t=Object.assign({},t,{url:this.GetURL(),size:this.GetSize()}),this._imageAsset=e.LoadImage(t)}IsLoaded(){return this._imageAsset&&this._imageAsset.IsLoaded()}async LoadStaticTexture(e,t){if(!this._imageAsset)throw new Error("no asset");if(this._textureState)throw new Error("already loaded texture");const s=this._generation,i=(this._textureState="loading",await this._imageAsset.LoadStaticTexture(e,t));if(this._generation!==s)return null;if(!i)return this._textureState="",null;this._textureState="loaded",this._hasMetaData||(this._width=i.GetWidth(),this._height=i.GetHeight(),this._hasMetaData=!0);const r=this._isRotated?this._height:this._width,n=this._isRotated?this._width:this._height;return this._rcTex.set(this._offsetX,this._offsetY,this._offsetX+r,this._offsetY+n),this._rcTex.divide(i.GetWidth(),i.GetHeight()),this._quadTex.setFromRect(this._rcTex),this._isRotated&&this._quadTex.rotatePointsAnticlockwise(),i}ReleaseTexture(){this._textureState&&(this._imageAsset&&this._imageAsset.ReleaseTexture(),this._textureState="",this._rcTex.set(0,0,0,0),this._quadTex.setFromRect(this._rcTex))}GetTexture(){return this._imageAsset&&"loaded"===this._textureState?this._imageAsset.GetTexture():null}GetTexRect(){return this._rcTex}GetTexQuad(){return this._quadTex}GetIImageInfo(){return this._iImageInfo}GetImageAsset(){return this._imageAsset}async ExtractImageToCanvas(e){e=e||await this._imageAsset.LoadToDrawable();const t=C33.CreateCanvas(this._width,this._height),s=t.getContext("2d");return this._isRotated?(s.rotate(Math.PI/-2),s.translate(-this._height,0),s.drawImage(e,this._offsetX,this._offsetY,this._height,this._width,0,0,this._height,this._width)):s.drawImage(e,this._offsetX,this._offsetY,this._width,this._height,0,0,this._width,this._height),t}async ExtractImageToBlobURL(e){if(!this._blobUrl){const t=await this.ExtractImageToCanvas(e),s=await C33.CanvasToBlob(t);this._blobUrl=URL.createObjectURL(s)}return this._blobUrl}ReleaseBlobURL(){this._blobUrl&&(URL.revokeObjectURL(this._blobUrl),this._blobUrl="")}}}{const C33=self.C3;C33.AnimationInfo=class extends C33.DefendedBase{constructor(e){super(),this._name=e[0],this._speed=e[1],this._isLooping=!!e[2],this._repeatCount=e[3],this._repeatTo=e[4],this._isPingPong=!!e[5],this._sid=e[6],this._frames=e[7].map(e=>C33.New(C33.AnimationFrameInfo,e)),this._iAnimation=new self.IAnimation(this)}static CreateDynamic(e,t){const s=C33.New(C33.AnimationInfo,[t,0,!1,0,0,!1,Math.floor(1e15*Math.random()),[]]);return s._frames.push(C33.AnimationFrameInfo.CreateDynamic(e)),s}Release(){for(const e of this._frames)e.Release();C33.clearArray(this._frames)}LoadAllAssets(e){for(const t of this._frames)t.GetImageInfo().LoadAsset(e)}LoadAllTextures(t,s){return Promise.all(this._frames.map(e=>e.GetImageInfo().LoadStaticTexture(t,s)))}ReleaseAllTextures(){for(const e of this._frames)e.GetImageInfo().ReleaseTexture()}GetName(){return this._name}GetSID(){return this._sid}GetFrameCount(){return this._frames.length}GetFrames(){return this._frames}GetFrameAt(e){if((e=Math.floor(e))<0||e>=this._frames.length)throw new RangeError("invalid frame");return this._frames[e]}InsertFrameAt(e,t){(t=Math.floor(t))<0?this._frames.unshift(e):t>=this._frames.length?this._frames.push(e):this._frames.splice(t,0,e)}RemoveFrameAt(e){if((e=Math.floor(e))<0||e>=this._frames.length)throw new RangeError("invalid frame");this._frames[e].Release(),this._frames.splice(e,1)}GetFrameIndexByTag(s){for(let e=0,t=this._frames.length;e<t;++e)if(C33.equalsNoCase(this._frames[e].GetTag(),s))return e;return-1}FrameTagOrIndexToIndex(e){if("string"!=typeof e)return e;{const t=this.GetFrameIndexByTag(e);if(-1===t)throw new Error("cannot find animation frame with tag "+e);return t}}GetSpeed(){return this._speed}IsLooping(){return this._isLooping}GetRepeatCount(){return this._repeatCount}GetRepeatTo(){return this._repeatTo}IsPingPong(){return this._isPingPong}GetIAnimation(){return this._iAnimation}}}{const C33=self.C3,EMPTY_IMAGE_BLOB=(()=>{const s=atob("iVBORw0KGgoAAAANSUhEUgAAAGQAAABkAQMAAABKLAcXAAAAAXNSR0IArs4c6QAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAATSURBVBgZYxgFo2AUjIJRQFcAAAV4AAHcRQIbAAAAAElFTkSuQmCC"),i=new Uint8Array(s.length);for(let e=0,t=s.length;e<t;++e)i[e]=s.charCodeAt(e);return new Blob([i],{type:"image/png"})})();C33.AnimationFrameInfo=class extends C33.DefendedBase{constructor(e){super(),this._imageInfo=C33.New(C33.ImageInfo),this._imageInfo.LoadData(e),this._duration=e[7],this._origin=C33.New(C33.Vector2,e[8],e[9]),this._imagePoints=e[10].map(e=>C33.New(C33.ImagePoint,this,e)),this._imagePointsByName=new Map;for(const s of this._imagePoints)this._imagePointsByName.set(s.GetName().toLowerCase(),s);this._collisionPoly=null;const t=e[11];6<=t.length&&(this._collisionPoly=C33.New(C33.CollisionPoly,t)),this._tag=e[12]||"",this._iAnimationFrame=new self.IAnimationFrame(this)}static CreateDynamic(e){const t=C33.New(C33.AnimationFrameInfo,["",0,0,0,100,100,!1,1,0,0,[],[],""]);return t._imageInfo.LoadDynamicBlobAsset(e,EMPTY_IMAGE_BLOB),t}Release(){this._collisionPoly&&(this._collisionPoly.Release(),this._collisionPoly=null),this._imageInfo.Release(),this._imageInfo=null}GetImageInfo(){return this._imageInfo}GetDuration(){return this._duration}GetOriginX(){return this._origin.getX()}GetOriginY(){return this._origin.getY()}GetCollisionPoly(){return this._collisionPoly}GetImagePointByName(e){return this._imagePointsByName.get(e.toLowerCase())||null}GetImagePointByIndex(e){return(e=Math.floor(e))<0||e>=this._imagePoints.length?null:this._imagePoints[e]}GetImagePointCount(){return this._imagePoints.length}GetTag(){return this._tag}GetIAnimationFrame(){return this._iAnimationFrame}}}{const C33=self.C3;C33.ImagePoint=class extends C33.DefendedBase{constructor(e,t){super(),this._afi=e,this._name=t[0],this._pos=C33.New(C33.Vector2,t[1],t[2])}Release(){}GetName(){return this._name}GetX(){return this._pos.getX()}GetY(){return this._pos.getY()}GetVec2(){return this._pos}}}{const C33=self.C3,C3Debugger=self.C3Debugger,IObjectClass=self.IObjectClass,assert=self.assert;C33.ObjectClass=class extends C33.DefendedBase{constructor(t,e,s){super();const i=t.GetObjectReference(s[1]),[r,n]=(this._runtime=t,this._plugin=C33.AddonManager.GetPluginByConstructorFunction(i),this._sdkType=null,this._instSdkCtor=i.Instance,this._index=e,this._sid=s[11],this._name=s[0],this._jsPropName=this._runtime.GetJsPropName(s[14]),this._isGlobal=!!s[9],this._isFamily=!!s[2],this._isOnLoaderLayout=!!s[10],this._instVars=s[3].map(e=>({sid:e[0],type:e[1],name:e[2],jsPropName:t.GetJsPropName(e[3])})),this._behaviorsCount=s[4],this._effectsCount=s[5],this._isWorldType=this._plugin.IsWorldType(),this._dispatcher=C33.New(C33.Event.Dispatcher),this._effectList=null,t.GetCollisionEngine().GetCollisionCellSize());if(this._collisionGrid=C33.New(C33.SparseGrid,r,n),this._anyCollisionCellChanged=!0,this._familyMembers=null,this._familyMembersSet=null,this._familyIndex=-1,this._families=null,this._familiesSet=null,this._familyInstVarMap=null,this._familyBehaviorMap=null,this._familyEffectMap=null,this._isInContainer=!1,this._container=null,this._behaviorTypes=s[8].map(e=>C33.BehaviorType.Create(this,e)),this._behaviorTypesIncludingInherited=[],this._behaviorsByName=new Map,this._behaviorNameToIndex=new Map,this._usedBehaviorCtors=new Set,this._customActionMap=new Map,this._solStack=C33.New(C33.SolStack,this),this._defaultInstanceData=null,this._defaultLayerIndex=0,this._isContained=!1,this._container=null,this._imageInfo=null,this._animations=null,this._animationsByName=null,this._animationsBySid=null,this._textureRefCount=0,this._savedData=new Map,this._unsavedData=new Map,this._instances=[],this._worldInfosByLayer=new Map,this._iidsStale=!0,this._plugin.HasEffects()&&(this._effectList=C33.New(C33.EffectList,this,s[12])),s[6]&&(this._imageInfo=C33.New(C33.ImageInfo),this._imageInfo.LoadData(s[6])),s[7]){this._animations=s[7].map(e=>C33.New(C33.AnimationInfo,e)),this._animationsByName=new Map,this._animationsBySid=new Map;for(const l of this._animations)this._animationsByName.set(l.GetName().toLowerCase(),l),this._animationsBySid.set(l.GetSID(),l)}this._isFamily?(this._familyMembers=[],this._familyMembersSet=new Set,this._familyIndex=this._runtime._GetNextFamilyIndex()):(this._families=[],this._familiesSet=new Set,this._familyInstVarMap=[],this._familyBehaviorMap=[],this._familyEffectMap=[]);const a=this._plugin.GetSdkVersion();if(a<2&&(this._sdkType=C33.New(i.Type,this,s[15]),!(this._sdkType instanceof C33.SDKTypeBase)))throw new Error("v1 sdk type must derive from SDKTypeBase");this._iObjectClass=null,this._instanceUserScriptClass=null,this._userScriptDispatcher=C33.New(C33.Event.Dispatcher),C33.AddonManager._PushInitObject(this,a);let o;if(o=2<=a?(o=i.Type)||globalThis.ISDKObjectTypeBase:this._sdkType.GetScriptInterfaceClass()){if(this._iObjectClass=new o(a<2?this:null),a<2&&!(this._iObjectClass instanceof IObjectClass))throw new TypeError("script interface class must derive from IObjectClass");if(2<=a&&!(this._iObjectClass instanceof globalThis.ISDKObjectTypeBase))throw new TypeError("script interface class must derive from ISDKObjectTypeBase")}else this._iObjectClass=new IObjectClass;if(C33.AddonManager._PopInitObject(a),s[13]){const h=s[13];if(h){const c=h[0],u=h[1],_=h[2];this._sdkType.LoadTilemapData(c,u,_)}}this._runtime.UsesLoaderLayout()&&!this._isFamily&&!this._isOnLoaderLayout&&this._isWorldType||this.OnCreate(),this._plugin.IsSingleGlobal()&&(this._plugin._SetSingleGlobalObjectClass(this),this._CreateSingleGlobalInstance(s)),this._loadInstancesJson=null}static Create(e,t,s){return C33.New(C33.ObjectClass,e,t,s)}Release(){if(this._dispatcher.Release(),this._dispatcher=null,this._imageInfo&&(this._imageInfo.Release(),this._imageInfo=null),this._animations){for(const e of this._animations)e.Release();C33.clearArray(this._animations),this._animationsByName.clear(),this._animationsBySid.clear()}this._loadInstancesJson=null,this._solStack.Release(),this._solStack=null,this._savedData.clear(),this._unsavedData.clear(),this._container=null,this._runtime=null}_LoadFamily(s){for(let e=1,t=s.length;e<t;++e){const i=this._runtime.GetObjectClassByIndex(s[e]);this._familyMembers.push(i),this._familyMembersSet.add(i),i._families.push(this),i._familiesSet.add(this)}}_SetContainer(e){this._isInContainer=!0,this._container=e}IsInContainer(){return this._isInContainer}GetContainer(){return this._container}_OnAfterCreate(){let e=0;if(!this._isFamily)for(const t of this._families)for(const s of t.GetBehaviorTypes()){const i=s.GetName().toLowerCase();this._behaviorsByName.set(i,s),this._behaviorNameToIndex.set(i,e),this._behaviorTypesIncludingInherited.push(s),++e}for(const r of this.GetBehaviorTypes()){const n=r.GetName().toLowerCase();this._behaviorsByName.set(n,r),this._behaviorNameToIndex.set(n,e),this._behaviorTypesIncludingInherited.push(r),++e}for(const a of this._behaviorTypesIncludingInherited)this._usedBehaviorCtors.add(a.GetBehavior().constructor);if(!this._isFamily&&this._families.length){let e=this._runtime.GetFamilyCount(),t=(C33.extendArray(this._familyInstVarMap,e,0),C33.extendArray(this._familyBehaviorMap,e,0),C33.extendArray(this._familyEffectMap,e,0),[]),s=0,i=0,r=0;for(const o of this._families){const l=o.GetFamilyIndex(),h=(this._familyInstVarMap[l]=s,s+=o.GetInstanceVariablesCount(),this._familyBehaviorMap[l]=i,i+=o.GetBehaviorTypesCount(),this._familyEffectMap[l]=r,r+=o.GetEffectTypesCount(),o.GetEffectList());if(h&&this._effectList)for(const c of h.GetAllEffectTypes())t.push(c.Clone(this._effectList))}this._effectList&&this._effectList.PrependEffectTypes(t)}}_CreateSingleGlobalInstance(e){const t=this._runtime._GetNewUID(),s=C33.New(C33.Instance,{runtime:this._runtime,objectType:this,uid:t});s._CreateSdkInstance(e[16],[]),this._runtime._MapInstanceByUID(t,s),this._instances.push(s)}GetSdkType(){return this._sdkType}IsOnLoaderLayout(){return this._isOnLoaderLayout}Dispatcher(){return this._dispatcher}OnCreate(){this._isFamily||(this._sdkType?this._sdkType.OnCreate():this._iObjectClass._onCreate())}HasLoadedTextures(){return 0<this._textureRefCount}async LoadTextures(e){this._isFamily||(this._textureRefCount++,1===this._textureRefCount&&(this._sdkType?await this._sdkType.LoadTextures(e):await this._iObjectClass._loadTextures(this._runtime.GetCanvasManager().GetIRenderer())))}ReleaseTextures(){if(!this._isFamily){if(this._textureRefCount--,this._textureRefCount<0)throw new Error("released textures too many times");0===this._textureRefCount&&(this._sdkType?this._sdkType.ReleaseTextures():this._iObjectClass._releaseTextures(this._runtime.GetCanvasManager().GetIRenderer()))}}OnDynamicTextureLoadComplete(){if(this._isFamily)throw new Error("not applicable to family");this._sdkType?this._sdkType.OnDynamicTextureLoadComplete():this._iObjectClass._onDynamicTextureLoadComplete()}async PreloadTexturesWithInstances(e){this._isFamily||(this._sdkType?await this._sdkType.PreloadTexturesWithInstances(e):await this._iObjectClass._preloadTexturesWithInstances(this._runtime.GetCanvasManager().GetIRenderer()))}GetRuntime(){return this._runtime}GetPlugin(){return this._plugin}GetInstanceSdkCtor(){return this._instSdkCtor}GetName(){return this._name}GetJsPropName(){return this._jsPropName}GetIndex(){return this._index}GetSID(){return this._sid}IsFamily(){return this._isFamily}IsGlobal(){return this._isGlobal}IsWorldType(){return this._isWorldType}GetFamilyIndex(){return this._familyIndex}GetBehaviorTypes(){return this._behaviorTypes}GetBehaviorTypesCount(){return this._behaviorsCount}UsesBehaviorByCtor(e){return e&&this._usedBehaviorCtors.has(e)}GetInstanceVariablesCount(){return this._instVars.length}GetInstanceVariableSIDs(){return this._instVars.map(e=>e.sid)}GetInstanceVariableIndexBySID(t){return this._instVars.findIndex(e=>e.sid===t)}GetInstanceVariableIndexByName(t){return this._instVars.findIndex(e=>e.name===t)}_GetAllInstanceVariableNames(){return this._instVars.map(e=>e.name)}_GetAllInstanceVariableJsPropNames(){return this._instVars.map(e=>e.jsPropName)}GetInstanceVariableType(e){if((e=Math.floor(e))<0||e>=this._instVars.length)throw new RangeError("invalid instance variable index");return this._instVars[e].type}GetInstanceVariableName(e){if((e=Math.floor(e))<0||e>=this._instVars.length)throw new RangeError("invalid instance variable index");return this._instVars[e].name}GetEffectTypesCount(){return this._effectsCount}GetBehaviorTypesIncludingInherited(){return this._behaviorTypesIncludingInherited}GetBehaviorTypeByName(e){return this._behaviorsByName.get(e.toLowerCase())||null}GetBehaviorIndexByName(e){const t=this._behaviorNameToIndex.get(e.toLowerCase());return void 0===t?-1:t}GetEffectList(){return this._effectList}HasEffects(){return this._plugin.HasEffects()}UsesEffects(){return this._effectList&&this._effectList.HasAnyEffectType()}GetSolStack(){return this._solStack}GetCurrentSol(){return this._solStack.GetCurrentSol()}GetImageInfo(){return this._imageInfo}SetDefaultInstanceData(e){this._defaultInstanceData=e}GetDefaultInstanceData(){return this._defaultInstanceData}_SetDefaultLayerIndex(e){this._defaultLayerIndex=e}GetDefaultLayerIndex(){return this._defaultLayerIndex}GetAnimations(){return this._animations}GetAnimationCount(){return this._animations.length}GetFamilies(){return this._families}BelongsToFamily(e){return this._familiesSet.has(e)}GetFamilyMembers(){return this._familyMembers}FamilyHasMember(e){return this._familyMembersSet.has(e)}GetFamilyBehaviorOffset(e){return this._familyBehaviorMap[e]}GetFamilyInstanceVariableOffset(e){return this._familyInstVarMap[e]}AddCustomAction(e){this._customActionMap.set(e.GetACEName().toLowerCase(),e)}HasOwnCustomActionByName(e){return!!this.GetOwnCustomActionByName(e)}GetOwnCustomActionByName(e){const t=this._customActionMap.get(e.toLowerCase());return t&&t.IsEnabled()?t:null}GetAllAnimations(){return this._animations}GetAnimationByName(e){if(this._animations)return this._animationsByName.get(e.toLowerCase())||null;throw new Error("no animations")}GetAnimationBySID(e){if(this._animations)return this._animationsBySid.get(e)||null;throw new Error("no animations")}AddAnimation(e){if(this.GetAnimationByName(e))throw new Error(`animation name '${e}' already exists`);const t=C33.AnimationInfo.CreateDynamic(this.GetRuntime(),e);return this._animations.push(t),this._animationsByName.set(t.GetName().toLowerCase(),t),this._animationsBySid.set(t.GetSID(),t),t}RemoveAnimation(e){const t=this.GetAnimationByName(e);if(!t)throw new Error(`animation name '${e}' does not exist`);if(1===this._animations.length)throw new Error("cannot remove last animation");const s=this._animations.indexOf(t);this._animations.splice(s,1),this._animationsByName.delete(t.GetName().toLowerCase()),this._animationsBySid.delete(t.GetSID()),t.Release()}GetFirstAnimation(){if(this._animations)return this._animations[0];throw new Error("no animations")}GetFirstAnimationFrame(){return this.GetFirstAnimation().GetFrameAt(0)}GetDefaultInstanceSize(){if(this._animations){const e=this.GetFirstAnimationFrame().GetImageInfo();return[e.GetWidth(),e.GetHeight()]}return this._imageInfo?[this._imageInfo.GetWidth(),this._imageInfo.GetHeight()]:[100,100]}GetSingleGlobalInstance(){if(this._plugin.IsSingleGlobal())return this._instances[0];throw new Error("not a single-global plugin")}GetInstances(){return this._instances}*instances(){yield*this._instances}*instancesIncludingPendingCreate(){yield*this._instances,yield*this._runtime.instancesPendingCreateForObjectClass(this)}GetInstanceCount(){return this._instances.length}_AddInstance(e){this._instances.push(e)}_SetIIDsStale(){this._iidsStale=!0}_UpdateIIDs(){if(this._iidsStale&&!this._isFamily){let t=this._instances,s=0;for(let e=t.length;s<e;++s)t[s]._SetIID(s);const e=this._runtime._GetInstancesPendingCreate();for(const i of e)i.GetObjectClass()===this&&i._SetIID(s++);this._iidsStale=!1}}GetInstanceByIID(e){const t=this._instances;if(e<t.length)return t[e];e-=t.length;const s=this._runtime._GetInstancesPendingCreate();for(const i of s)if(i.GetObjectClass()===this){if(0===e)return i;--e}return null}GetFirstPicked(e){if(e&&e.IsInContainer()&&e.GetObjectClass()!==this)for(const s of e.siblings())if(s.GetObjectClass()===this)return s;const t=this.GetCurrentSol().GetInstances();return t.length?t[0]:null}GetPairedInstance(e){const t=this.GetCurrentSol().GetInstances();return 0<t.length?t[e.GetIID()%t.length]:null}*allCorrespondingInstances(e,t){let s=this.GetCurrentSol().GetInstances(),i=s.length,r=t.GetCurrentSol(),n=t.GetCurrentSol().GetInstances(),a=n.length,o=e.GetIID(),l=(!t.IsFamily()&&r.IsSelectAll()||(o=n.indexOf(e)),Math.ceil(i/a)),h=i%a,c=0,u;u=0==h||o<h?(c=o*l,l):(c=h*l+(o-h)*(l-1),l-1);for(let e=c,t=c+u;e<t;++e)yield s[e]}FinishCondition(e){this._sdkType?.FinishCondition(e)}ApplySolToContainer(){if(this._isInContainer&&!this._isFamily){this._UpdateIIDs();const e=this.GetCurrentSol(),t=e._GetOwnInstances(),s=e.IsSelectAll(),i=this._runtime.GetCurrentEventStackFrame(),r=i&&i.GetCurrentEvent()&&i.GetCurrentEvent().IsOrBlock();for(const n of this._container.objectTypes())if(n!==this){n._UpdateIIDs();const a=n.GetCurrentSol();if(a._SetSelectAll(s),!s){const o=a._GetOwnInstances();C33.clearArray(o);for(const l of t)o.push(n.GetInstanceByIID(l.GetIID()));if(r){const h=e._GetOwnElseInstances(),c=a._GetOwnElseInstances();C33.clearArray(c);for(const u of h)c.push(n.GetInstanceByIID(u.GetIID()))}}}}}_TruncateContainerSols(e,t){for(const s of this.GetContainer().objectTypes()){const i=s.GetCurrentSol();e?C33.truncateArray(i._GetOwnElseInstances(),t):C33.truncateArray(i._GetOwnInstances(),t)}}_GetCollisionCellGrid(){return this._collisionGrid}_SetAnyCollisionCellChanged(e){this._anyCollisionCellChanged=!!e}_UpdateAllCollisionCells(){if(this._anyCollisionCellChanged&&this._isWorldType){for(const e of this._instances)e.GetWorldInfo()._UpdateCollisionCell();for(const t of this._runtime._GetInstancesPendingCreate())t.GetObjectClass()===this&&t.GetWorldInfo()._UpdateCollisionCell();this._anyCollisionCellChanged=!1}}_OnWorldInstanceLayerChanged(t,e,s){if(e){const i=this._worldInfosByLayer.get(e);i&&(i.delete(t),0===i.size)&&this._worldInfosByLayer.delete(e)}if(s){let e=this._worldInfosByLayer.get(s);e||(e=new Set,this._worldInfosByLayer.set(s,e)),e.add(t)}}layersHasInstancesOn(){if(this.IsFamily()){const e=new Set;for(const t of this._familyMembers)for(const s of t.layersHasInstancesOn())e.add(s);return e.values()}return this._worldInfosByLayer.keys()}GetSavedDataMap(){return this._savedData||(this._savedData=new Map),this._savedData}GetUnsavedDataMap(){return this._unsavedData||(this._unsavedData=new Map),this._unsavedData}HasSolidBehavior(){return this.UsesBehaviorByCtor(C33.Behaviors.solid)}HasJumpthruBehavior(){return this.UsesBehaviorByCtor(C33.Behaviors.jumpthru)}HasNoSaveBehavior(){return this.UsesBehaviorByCtor(C33.Behaviors.NoSave)}HasPersistBehavior(){return this.UsesBehaviorByCtor(C33.Behaviors.Persist)}_SaveToJson(){const e={instances:this._instances.map(e=>e.SaveToJson())};return this._savedData&&this._savedData.size&&(e.ex=C33.ToSuperJSON(this._savedData)),e}_LoadFromJson(e,i){this._savedData&&(this._savedData.clear(),this._savedData=null);const t=e.ex,r=(t&&(this._savedData=C33.FromSuperJSON(t)),this._instances),n=e.instances;for(let e=0,t=Math.min(r.length,n.length);e<t;++e)r[e].LoadFromJson(n[e]);for(let e=n.length,t=r.length;e<t;++e)this._runtime.DestroyInstance(r[e]);for(let s=r.length,e=n.length;s<e;++s){let e=n[s],t=null;if(!this.IsWorldType()||(t=this._runtime.GetMainRunningLayout().GetLayerBySID(e.w.l))){const a=this._runtime.CreateInstanceFromData(this._defaultInstanceData||this,t,!1,0,0,!0);a.LoadFromJson(e),i&&i.add(a)}}this._loadInstancesJson=n,this._SetIIDsStale()}_GetLoadInstancesJson(){return this._loadInstancesJson}_ClearLoadInstancesJson(){this._loadInstancesJson=null}_SetupSceneGraphConnectionsOnChangeOfLayout(){for(let e=0,t=this._instances;e<t;++e)this._instances[e]._SetupSceneGraphConnectionsOnChangeOfLayout()}GetIObjectClass(){return this._iObjectClass}UserScriptDispatcher(){return this._userScriptDispatcher}_GetUserScriptInstanceClass(){return this._instanceUserScriptClass}_SetUserScriptInstanceClass(e){this._instanceUserScriptClass=e}DispatchUserScriptEvent(e){const t=this._runtime,s=t.IsDebug()&&!t.GetEventSheetManager().IsInEventEngine();s&&C3Debugger.StartMeasuringScriptTime(),this._userScriptDispatcher.dispatchEvent(e),s&&C3Debugger.AddScriptTime()}}}{const C33=self.C3;C33.Container=class extends C33.DefendedBase{constructor(e,t){super(),this._runtime=e,this._objectTypes=t;for(const s of this._objectTypes)s._SetContainer(this)}Release(){this._runtime=null}GetRuntime(){return this._runtime}GetObjectTypes(){return this._objectTypes}objectTypes(){return this._objectTypes}HasAnyWorldType(){return this._objectTypes.some(e=>e.IsWorldType())}}}{let C33=self.C3,C3Debugger=self.C3Debugger,IInstance=self.IInstance,originalAddonManager=C33.AddonManager,EMPTY_ARRAY=[],nextPuid=0,savedDataMaps=new WeakMap,unsavedDataMaps=new WeakMap,FLAG_DESTROYED=1,FLAG_TILEMAP=2,FLAG_MUST_PREDRAW=4,FLAG_SOLID_ENABLED=8,FLAG_JUMPTHRU_ENABLED=16,FLAG_MUST_MITIGATE_Z_FIGHTING=32,FLAG_IS_DRAWING_WITH_EFFECTS=64;C33.Instance=class extends C33.DefendedBase{constructor(e){if(C33.AddonManager!==originalAddonManager)throw new Error("invalid addon manager");super(),this._runtime=e.runtime,this._objectType=e.objectType,this._worldInfo=null,this._sdkInst=null,this._iScriptInterface=null,this._iid=0,this._uid=e.uid,this._puid=nextPuid++,this._flags=0,this._tagsSet=null;const t=C33.splitStringAndNormalize(e.tags),s=(0<t.length&&(this._tagsSet=new Set(t)),this._instVarValues=EMPTY_ARRAY,this._behaviorInstances=EMPTY_ARRAY,this._objectType.GetBehaviorTypesIncludingInherited()),i=(0<s.length&&(this._behaviorInstances=s.map((e,t)=>C33.New(C33.BehaviorInstance,{runtime:this._runtime,behaviorType:e,instance:this,index:t}))),this._siblings=this._objectType.IsInContainer()?[]:null,this._timeScale=-1,this._dispatcher=null,this.GetPlugin());if(i.MustPreDraw()&&(this._flags|=FLAG_MUST_PREDRAW),i.IsWorldType())if(this._worldInfo=C33.New(C33.WorldInfo,this,e.layer),e.worldData)this._worldInfo.Init(e.worldData);else{this._worldInfo.InitNoData();const[r,n]=this._objectType.GetDefaultInstanceSize();this._worldInfo.SetSize(r,n),this.GetObjectClass().UsesEffects()&&this._worldInfo.GetInstanceEffectList().LoadDefaultEffectParameters()}e.instVarData?this._LoadInstanceVariableData(e.instVarData):this._LoadDefaultInstanceVariables()}Release(){if(this._iScriptInterface&&(this._iScriptInterface._release(),this._iScriptInterface=null),0<this._behaviorInstances.length){for(const s of this._behaviorInstances)s.Release();C33.clearArray(this._behaviorInstances)}this._sdkInst&&(this._sdkInst.Release(),this._sdkInst=null);const e=savedDataMaps.get(this),t=(e&&(e.clear(),savedDataMaps.delete(this)),unsavedDataMaps.get(this));t&&(t.clear(),unsavedDataMaps.delete(this)),this._siblings&&C33.clearArray(this._siblings),this._dispatcher&&(this._dispatcher.Release(),this._dispatcher=null),this._tagsSet&&this._tagsSet.clear(),this._tagsSet=null,this._runtime=null,this._objectType=null,0<this._instVarValues.length&&C33.clearArray(this._instVarValues),this._worldInfo&&(this._worldInfo.Release(),this._worldInfo=null)}_LoadInstanceVariableData(e){0<e.length&&(this._instVarValues=[],C33.shallowAssignArray(this._instVarValues,e))}_LoadDefaultInstanceVariables(){const t=this._objectType.GetInstanceVariablesCount();if(0!==t){this._instVarValues=[];const s=[0,0,""];for(let e=0;e<t;++e)this._instVarValues.push(s[this._objectType.GetInstanceVariableType(e)])}}_CreateSdkInstance(e,s){if(this._sdkInst)throw new Error("already got sdk instance");for(let e=0,t=this._behaviorInstances.length;e<t;++e){const i=this._behaviorInstances[e];i._CreateSdkInstance(s?s[e]:null)}const t=this.GetPlugin().GetSdkVersion();if(t<2){if(this._sdkInst=C33.New(this._objectType.GetInstanceSdkCtor(),this,e),!(this._sdkInst instanceof C33.SDKInstanceBase))throw new Error("sdk type must derive from SDKInstanceBase");!this.GetPlugin().IsWorldType()&&this._objectType._GetUserScriptInstanceClass()&&this.GetInterfaceClass()}else{const r=this.GetPlugin().GetScriptInterfaceClass();this._InitUserScriptInterface(r.Instance,e)}}GetSdkInstance(){return this._sdkInst??this._iScriptInterface}GetWorldInfo(){return this._worldInfo}GetRuntime(){return this._runtime}GetTimeScale(){return this._timeScale}GetActiveTimeScale(){const e=this._timeScale;return-1===e?this.GetRuntime().GetTimeScale():e}SetTimeScale(e){((e=+e)<0||!isFinite(e))&&(e=0),this._timeScale=e,this.GetObjectClass().UsesEffects()&&this._runtime._SetTrackingInstanceTime(this,!0)}RestoreTimeScale(){this._timeScale=-1,this.GetObjectClass().UsesEffects()&&this._runtime._SetTrackingInstanceTime(this,!1)}GetInstanceGameTime(){return this._runtime._GetInstanceGameTime(this)}Dispatcher(){return this._dispatcher||(this._dispatcher=C33.New(C33.Event.Dispatcher)),this._dispatcher}Draw(e){this._sdkInst?this._sdkInst.Draw(e):this._iScriptInterface._draw(this._runtime.GetCanvasManager().GetIRenderer())}OnCreate(e){this._sdkInst.OnCreate(e)}_SetHasTilemap(){this._flags|=FLAG_TILEMAP}HasTilemap(){return 0!=(this._flags&FLAG_TILEMAP)}_MarkDestroyed(){this._flags|=FLAG_DESTROYED}IsDestroyed(){return 0!=(this._flags&FLAG_DESTROYED)}MustPreDraw(){return 0!=(this._flags&FLAG_MUST_PREDRAW)||this._sdkInst.MustPreDraw()}SetMustMitigateZFighting(){this._flags|=FLAG_MUST_MITIGATE_Z_FIGHTING}MustMitigateZFighting(){return 0!=(this._flags&FLAG_MUST_MITIGATE_Z_FIGHTING)}_IsSolidEnabled(){return 0!=(this._flags&FLAG_SOLID_ENABLED)}_SetSolidEnabled(e){e?this._flags|=FLAG_SOLID_ENABLED:this._flags&=~FLAG_SOLID_ENABLED}_IsJumpthruEnabled(){return 0!=(this._flags&FLAG_JUMPTHRU_ENABLED)}_SetJumpthruEnabled(e){e?this._flags|=FLAG_JUMPTHRU_ENABLED:this._flags&=~FLAG_JUMPTHRU_ENABLED}_IsDrawingWithEffects(){return 0!=(this._flags&FLAG_IS_DRAWING_WITH_EFFECTS)}_SetIsDrawingWithEffects(e){e?this._flags|=FLAG_IS_DRAWING_WITH_EFFECTS:this._flags&=~FLAG_IS_DRAWING_WITH_EFFECTS}SetFlag(e,t){e<<=16,t?this._flags|=e:this._flags&=~e}GetFlag(e){return 0!=(this._flags&e<<16)}GetCurrentImageInfo(){return this._sdkInst.GetCurrentImageInfo()}GetCurrentSurfaceSize(){return this._sdkInst.GetCurrentSurfaceSize()}GetCurrentTexRect(){return this._sdkInst.GetCurrentTexRect()}GetCurrentTexQuad(){return this._sdkInst.GetCurrentTexQuad()}IsCurrentTexRotated(){return this._sdkInst.IsCurrentTexRotated()}GetImagePoint(e){return this._sdkInst.GetImagePoint(e)}GetObjectClass(){return this._objectType}RendersToOwnZPlane(){return this._sdkInst.RendersToOwnZPlane()}BelongsToObjectClass(e){return e.IsFamily()?e.FamilyHasMember(this.GetObjectClass()):this.GetObjectClass()===e}CollectInstancesToPick(r,e,t){const s=(e,t)=>{const s=t||e.GetObjectClass(),i=r.get(s);i?i.add(e):r.set(s,new Set([e]))};if(s(this,e),this.IsInContainer())for(const i of this.siblings())s(i);if(t)for(const n of this.allChildren())s(n)}VerifySupportsSceneGraph(){if(!this.GetPlugin().SupportsSceneGraph())throw new Error("object does not support scene graph")}HasParent(){return null!==this.GetParent()}GetParent(){const e=this.GetWorldInfo();if(!e)return null;const t=e.GetParent();return t?t.GetInstance():null}GetTopParent(){const e=this.GetWorldInfo();if(!e)return null;const t=e.GetTopParent();return t?t.GetInstance():null}*parents(){const e=this.GetWorldInfo();if(e)for(const t of e.parents())yield t.GetInstance()}HasChild(e){if(e)for(const t of this.children())if(t===e)return!0;return!1}HasChildren(){const e=this.GetWorldInfo();return!!e&&e.HasChildren()}GetChildrenOfObjectClass(e){const t=this.GetWorldInfo();if(!t)return[];const s=e.GetName();return t.GetChildren().map(e=>e.GetInstance()).filter(e=>e.GetObjectClass().GetName()===s)}GetChildren(){const e=this.GetWorldInfo();return e?e.GetChildren().map(e=>e.GetInstance()):[]}*children(){const e=this.GetWorldInfo();if(e)for(const t of e.children())yield t.GetInstance()}*allChildren(){const e=this.GetWorldInfo();if(e)for(const t of e.allChildren())yield t.GetInstance()}GetChildCount(){const e=this.GetWorldInfo();return e?e.GetChildCount():0}GetParentCount(){return[...this.parents()].length}GetAllChildCount(){const e=this.GetWorldInfo();return e?e.GetAllChildCount():0}GetChildAt(e){const t=this.GetWorldInfo();if(!t)return null;const s=t.GetChildAt(e);return s?s.GetInstance():null}GetIndexInParent(){const e=this.GetWorldInfo();if(!e)return NaN;const t=e.GetParent();return t?t.GetChildIndex(e):NaN}HasChildWithUID(e){for(const t of this.GetWorldInfo().GetChildren())if(t.GetInstance().GetUID()===e)return!0;return!1}AddChild(e,t){this.VerifySupportsSceneGraph(),e.VerifySupportsSceneGraph(),this.GetWorldInfo().AddChild(e.GetWorldInfo(),t||{})}RemoveChild(e){const t=this.GetWorldInfo();t&&t.RemoveChild(e.GetWorldInfo())}GetDestroyWithParent(){const e=this.GetWorldInfo();return!!e&&e.GetDestroyWithParent()}SetupInitialSceneGraphConnections(){const e=this.GetWorldInfo();if(e){const t=e.GetSceneGraphChildrenExportData();if(t)for(const s of t){const i=this._runtime.GetInstanceByUID(s[2]);if(i){const r=s[3];this.AddChild(i,{transformX:!!(r>>0&1),transformY:!!(r>>1&1),transformWidth:!!(r>>2&1),transformHeight:!!(r>>3&1),transformAngle:!!(r>>4&1),destroyWithParent:!!(r>>5&1),transformZElevation:!!(r>>6&1),transformOpacity:!!(r>>7&1),transformVisibility:!!(r>>8&1)})}}}}SetupPersistedSceneGraphConnections(e,t){const s=e.get(this);if(s)for(const i of s.sceneGraphJson.children){const r=t.get(i.index);if(r){const n=i.flags;this.AddChild(r,{transformX:!!(n>>0&1),transformY:!!(n>>1&1),transformWidth:!!(n>>2&1),transformHeight:!!(n>>3&1),transformAngle:!!(n>>4&1),destroyWithParent:!!(n>>5&1),transformZElevation:!!(n>>6&1),transformOpacity:!!(n>>7&1),transformVisibility:!!(n>>8&1)})}}}GetTemplateName(){const e=this._runtime.GetTemplateManager();return e?e.GetInstanceTemplateName(this):""}IsInContainer(){return null!==this._siblings}_AddSibling(e){this._siblings.push(e)}GetSiblings(){return this._siblings}HasSibling(e){return!!this.GetSibling(e)}GetSibling(e){const t=this.siblings();if(null===t||0===t.length)return!1;for(const s of t)if(s.GetObjectClass()===e)return s;return null}siblings(){return this._siblings}SetSiblingsSinglePicked(){for(const e of this.siblings())e.GetObjectClass().GetCurrentSol().SetSinglePicked(e)}_PushSiblingsToSolInstances(){for(const e of this.siblings())e.GetObjectClass().GetCurrentSol()._PushInstance(e)}_SetSiblingsToSolInstancesIndex(e){for(const t of this.siblings())t.GetObjectClass().GetCurrentSol()._GetOwnInstances()[e]=t}_PushSiblingsToSolElseInstances(){for(const e of this.siblings())e.GetObjectClass().GetCurrentSol()._PushElseInstance(e)}_SetSiblingsToSolElseInstancesIndex(e){for(const t of this.siblings())t.GetObjectClass().GetCurrentSol()._GetOwnElseInstances()[e]=t}GetPlugin(){return this._objectType.GetPlugin()}_SetIID(e){this._iid=e}GetIID(){return this._objectType._UpdateIIDs(),this._iid}GetUID(){return this._uid}GetPUID(){return this._puid}_SetTagsSetFromJson(e){e?this.SetTagsSet(new Set(e)):this._tagsSet=null}SetTagsSet(e){if(0===e.size)this._tagsSet=null;else{this._tagsSet?this._tagsSet.clear():this._tagsSet=new Set;for(const t of e)this._tagsSet.add(t)}}GetTagsSet(){return this._tagsSet??new Set}GetTagsString(){return Array.from(this.GetTagsSet()).join(" ")}GetTagAt(e){e=Math.floor(e);for(const t of this.GetTagsSet()){if(0===e)return t;--e}return""}GetBehaviorInstances(){return this._behaviorInstances}GetBehaviorInstanceFromCtor(e){if(e)for(const t of this._behaviorInstances)if(t.GetBehavior()instanceof e)return t;return null}GetBehaviorSdkInstanceFromCtor(e){if(!e)return null;const t=this.GetBehaviorInstanceFromCtor(e);return t?t.GetSdkInstance():null}GetBehaviorIndexBySID(s){const i=this._behaviorInstances;for(let e=0,t=i.length;e<t;++e)if(i[e].GetBehaviorType().GetSID()===s)return e;return-1}GetAllInstanceVariableValues(){return this._instVarValues}_GetAllInstanceVariableNames(){return this._objectType._GetAllInstanceVariableNames()}GetInstanceVariableCount(){return this._instVarValues.length}GetInstanceVariableValue(e){const t=this._instVarValues;if((e|=0)<0||e>=t.length)throw new RangeError("invalid instance variable");return t[e]}_GetInstanceVariableValueUnchecked(e){return this._instVarValues[e]}_GetInstanceVariableTypedValue(e){const t=this._instVarValues[e];return 0===this._objectType.GetInstanceVariableType(e)?!!t:t}SetInstanceVariableValue(e,t){const s=this._instVarValues;if((e|=0)<0||e>=s.length)throw new RangeError("invalid instance variable");const i=this._objectType.GetInstanceVariableType(e);switch(i){case 0:s[e]=t?1:0;break;case 1:s[e]="number"==typeof t?t:parseFloat(t);break;case 2:s[e]="string"==typeof t?t:t.toString();break;default:throw new Error("unknown instance variable type")}}SetInstanceVariableOffset(e,t){if(0!==t){const s=this._instVarValues;if((e|=0)<0||e>=s.length)throw new RangeError("invalid instance variable");const i=s[e];if("number"!=typeof i)throw"boolean"==typeof i?new Error("can not set offset of boolean variable"):"string"==typeof i?new Error("can not set offset of string variable"):new Error("unknown instance variable type");s[e]+="number"==typeof t?t:parseFloat(t)}}GetSavedDataMap(){let e=savedDataMaps.get(this);return e||(e=new Map,savedDataMaps.set(this,e)),e}GetUnsavedDataMap(){let e=unsavedDataMaps.get(this);return e||(e=new Map,unsavedDataMaps.set(this,e)),e}_HasAnyCreateDestroyHandler(e){const t=this.GetObjectClass();if(t.UserScriptDispatcher().HasAnyHandlerFor(e))return!0;for(const s of t.GetFamilies())if(s.UserScriptDispatcher().HasAnyHandlerFor(e))return!0;return!!this._runtime.UserScriptDispatcher().HasAnyHandlerFor(e)}_TriggerOnCreatedOnSelfAndRelated(){const e=new Set,t=(e.add(this),this.GetWorldInfo());if(t&&t.HasChildren())for(const s of this.allChildren())if(e.add(s),s.IsInContainer())for(const i of s.siblings())e.add(i);if(this.IsInContainer())for(const r of this.siblings())e.add(r);for(const n of e.values())n._TriggerOnCreated();this._OnHierarchyReady()}_OnCreatedCommon(){this._objectType._GetUserScriptInstanceClass()&&this.GetInterfaceClass();for(const e of this._behaviorInstances)e.PostCreate()}_OnCreatedForLoadingSavegame(){this._OnCreatedCommon()}_TriggerOnCreated(){if(this._OnCreatedCommon(),this._HasAnyCreateDestroyHandler("instancecreate")){const e=this.GetObjectClass(),t=new C33.Event("instancecreate");t.instance=this.GetInterfaceClass(),e.DispatchUserScriptEvent(t);for(const s of e.GetFamilies())s.DispatchUserScriptEvent(t);this._runtime.DispatchUserScriptEvent(t)}this._runtime.Trigger(this.GetPlugin().GetConstructor().Cnds.OnCreated,this,null)}_OnHierarchyReady(){if(this.GetPlugin().SupportsSceneGraph()){if(this.DispatchUserScriptEvent(new C33.Event("hierarchyready")),this._HasAnyCreateDestroyHandler("hierarchyready")){const e=this.GetObjectClass(),t=new C33.Event("hierarchyready");t.instance=this.GetInterfaceClass(),e.DispatchUserScriptEvent(t);for(const s of e.GetFamilies())s.DispatchUserScriptEvent(t);this._runtime.DispatchUserScriptEvent(t)}this._runtime.Trigger(this.GetPlugin().GetConstructor().Cnds.OnHierarchyReady,this,null)}}_TriggerOnDestroyed(){this._runtime.Trigger(this.GetPlugin().GetConstructor().Cnds.OnDestroyed,this,null)}_FireDestroyedScriptEvents(e){if(this._iScriptInterface){const t=new C33.Event("destroy");t.isEndingLayout=e,this.DispatchUserScriptEvent(t)}if(this._HasAnyCreateDestroyHandler("instancedestroy")){const s=this.GetObjectClass(),i=new C33.Event("instancedestroy");i.instance=this.GetInterfaceClass(),i.isEndingLayout=e,s.DispatchUserScriptEvent(i);for(const r of s.GetFamilies())r.DispatchUserScriptEvent(i);this._runtime.DispatchUserScriptEvent(i)}}_GetDebuggerProperties(){return this._sdkInst?this._sdkInst.GetDebuggerProperties():this._iScriptInterface._getDebuggerProperties()}SaveToJson(e="full",t=null){const s={},i=("full"===e?s.uid=this.GetUID():s.c3=!0,this.GetTagsSet());if(0<i.size&&(s.tags=Array.from(i)),"visual-state"!==e){const n=savedDataMaps.get(this);if(n&&n.size&&(s.ex=C33.ToSuperJSON(n)),-1!==this.GetTimeScale()&&(s.mts=this.GetTimeScale()),0<this._objectType.GetInstanceVariablesCount()){const a={},o=this._objectType.GetInstanceVariableSIDs();for(let e=0,t=this._instVarValues.length;e<t;++e)a[o[e].toString()]=this._instVarValues[e];s.ivs=a}if(this._behaviorInstances.length){const l={};for(const h of this._behaviorInstances){const c=h.SaveToJson(e);c&&(l[h.GetBehaviorType().GetSID().toString()]=c)}s.behs=l}}this._worldInfo&&(s.w=this._worldInfo._SaveToJson(e,t));const r=this._sdkInst?this._sdkInst.SaveToJson():this._iScriptInterface._saveToJson();return r&&(s.data=r),s}_OnBeforeLoad(e="full",t){this._worldInfo&&this._worldInfo._OnBeforeLoad(e)}_OnAfterLoad(e,t="full",s=null){this._worldInfo&&this._worldInfo._OnAfterLoad(e,t,s)}_OnAfterLoad2(e,t="full",s=null){this._worldInfo&&this._worldInfo._OnAfterLoad2(e,t,s)}_SetupSceneGraphConnectionsOnChangeOfLayout(){this.GetPlugin().IsWorldType()&&this._worldInfo._SetupSceneGraphConnectionsOnChangeOfLayout()}LoadFromJson(t,e="full",s){if("full"===e)this._uid=t.uid;else if(!t.c3)return;if(this._SetTagsSetFromJson(t.tags),"visual-state"!==e){let e=savedDataMaps.get(this);e&&(e.clear(),savedDataMaps.delete(this));const r=t.ex,n=(r&&(e=C33.FromSuperJSON(r),savedDataMaps.set(this,e)),this._timeScale=t.hasOwnProperty("mts")?t.mts:-1,t.ivs);if(n)for(const[a,o]of Object.entries(n)){const l=parseInt(a,10),h=this._objectType.GetInstanceVariableIndexBySID(l);if(!(h<0||h>=this._instVarValues.length)){let e=o;null===e&&(e=NaN),this._instVarValues[h]=e}}}if(this.GetPlugin().IsWorldType()){const c=t.w;if(c){const u=c.l;if(this._worldInfo.GetLayer().GetSID()!==u){const _=this._worldInfo.GetLayer(),d=_.GetLayout().GetLayerBySID(u);d?(this._worldInfo._SetLayer(d),_._RemoveInstance(this,!0),d._AddInstance(this,!0),d.SetZIndicesChanged(this),this._worldInfo.SetBboxChanged()):"full"===e&&this._runtime.DestroyInstance(this)}this._worldInfo._LoadFromJson(c,e)}}if("visual-state"!==e){const p=t.behs;if(p)for(const[m,g]of Object.entries(p)){const f=parseInt(m,10),S=this.GetBehaviorIndexBySID(f);S<0||S>=this._behaviorInstances.length||this._behaviorInstances[S].LoadFromJson(g,e)}}const i=t.data;i&&(this._sdkInst?this._sdkInst.LoadFromJson(i,e):this._iScriptInterface._loadFromJson(i))}GetInterfaceClass(){return this._iScriptInterface||this._InitUserScriptInterface()}HasScriptInterface(){return!!this._iScriptInterface}_InitUserScriptInterface(e,t){const s=this._worldInfo?e?self.ISDKWorldInstanceBase:self.IWorldInstance:e?self.ISDKInstanceBase:self.IInstance,i=e||this._sdkInst.GetScriptInterfaceClass(),r=this._objectType._GetUserScriptInstanceClass(),n=r||i||s,a=this.GetPlugin().GetSdkVersion();if(C33.AddonManager._PushInitObject(this,a),C33.AddonManager._PushInitProperties(t),this._iScriptInterface=new n,C33.AddonManager._PopInitProperties(),C33.AddonManager._PopInitObject(a),i&&!(this._iScriptInterface instanceof s))throw new TypeError(`script interface class '${i.name}' does not extend the right base class '${s.name}'`);if(r){const o=i||s;if(!(this._iScriptInterface instanceof o))throw new TypeError(`setInstanceClass(): class '${r.name}' does not extend the right base class - check it extends the right class, e.g. globalThis.InstanceType.MyObjectName`)}return this._iScriptInterface}_GetInstVarsScriptDescriptor(e){if(0!==this._instVarValues.length){const s={},i=this._objectType._GetAllInstanceVariableJsPropNames();for(let e=0,t=i.length;e<t;++e)s[i[e]]={configurable:!1,enumerable:!0,get:C33.Instance.prototype._GetInstanceVariableTypedValue.bind(this,e),set:C33.Instance.prototype.SetInstanceVariableValue.bind(this,e)};const t=Object.create(Object.prototype,s);e.instVars={value:t,writable:!1}}}_GetBehaviorsScriptDescriptor(e){const t=this._behaviorInstances;if(0!==t.length){const s={};for(const r of t)s[r.GetBehaviorType().GetJsPropName()]={value:r.GetScriptInterface(),writable:!1};const i=Object.create(Object.prototype,s);e.behaviors={value:i,writable:!1}}}DispatchUserScriptEvent(e){if(this.HasScriptInterface()){const t=this.GetInterfaceClass(),s=(e.instance=t,this._runtime),i=s.IsDebug()&&!s.GetEventSheetManager().IsInEventEngine();i&&C3Debugger.StartMeasuringScriptTime(),t.dispatchEvent(e),i&&C3Debugger.AddScriptTime()}}}}{const C33=self.C3;C33.SceneGraphInfo=class extends C33.DefendedBase{constructor(i){super(),this._owner=i,this._parent=null,this._children=[],this._startWidth=i.GetWidth(),this._startHeight=i.GetHeight(),this._startScaleX=1,this._startScaleY=1,this._parentStartAngle=0,this._ownOpacity=1,this._startOpacity=i.GetOpacity(),this._tmpSceneGraphChildren=null,this._tmpSceneGraphChildrenIndexes=null,this._indexInParent=NaN,this._originalSizeKnown=!1,this._originalWidth=NaN,this._originalHeight=NaN,this._on_instance_create=e=>{if(e.instance===this._parent.GetInstance()){const t=i.GetRuntime(),s=(t.Dispatcher().removeEventListener("instancecreate",this._on_instance_create),this._parent.GetInstance().GetSdkInstance());this._originalSizeKnown=!!s.IsOriginalSizeKnown(),this._originalWidth=this._originalSizeKnown?s.GetOriginalWidth():NaN,this._originalHeight=this._originalSizeKnown?s.GetOriginalHeight():NaN}}}Release(){this._parent=null,this._tmpSceneGraphChildren=null,this._tmpSceneGraphChildrenIndexes=null,this._indexInParent=NaN,this._originalSizeKnown=!1,this._originalWidth=NaN,this._originalHeight=NaN,C33.clearArray(this._children)}SetParent(e){if(this._ownOpacity=this._owner.GetOpacity(),this._startOpacity=this._ownOpacity,this._parent=e,this._parentStartAngle=e?e.GetAngle():0,this._parent){const t=this._owner,s=t.GetRuntime(),i=this._parent.GetInstance().GetPlugin().GetSdkVersion();if(i<2){const r=this._parent.GetInstance().GetSdkInstance();r?(this._originalSizeKnown=!!r.IsOriginalSizeKnown(),this._originalWidth=this._originalSizeKnown?r.GetOriginalWidth():NaN,this._originalHeight=this._originalSizeKnown?r.GetOriginalHeight():NaN):this._parent.GetInstance().IsDestroyed()||s.Dispatcher().addEventListener("instancecreate",this._on_instance_create)}else this._originalSizeKnown=!1,this._originalWidth=NaN,this._originalHeight=NaN}else this._originalSizeKnown=!1,this._originalWidth=NaN,this._originalHeight=NaN}GetParent(){return this._parent}HasChildren(){return 0<this._children.length}GetChildren(){return this._children}_MaybeSortChildren(){this.HasChildren()&&1!==this._children.length&&(this._tmpSceneGraphChildrenIndexes?this._children.sort((e,t)=>{const s=this._tmpSceneGraphChildrenIndexes.get(e.GetInstance()),i=this._tmpSceneGraphChildrenIndexes.get(t.GetInstance());return C33.IsFiniteNumber(s)&&C33.IsFiniteNumber(i)?s-i:0}):this._children.sort((e,t)=>{const s=e._GetSceneGraphInfo()._GetIndexInParent(),i=t._GetSceneGraphInfo()._GetIndexInParent();return C33.IsFiniteNumber(s)&&C33.IsFiniteNumber(i)?s-i:0}))}_GetIndexInParent(){return this._indexInParent}GetStartScaleX(){return this._startScaleX}SetStartScaleX(e){this._startScaleX=e}GetStartScaleY(){return this._startScaleY}SetStartScaleY(e){this._startScaleY=e}GetStartOpacity(){return this._startOpacity}GetOwnOpacity(){return this._ownOpacity}SetOwnOpacity(e){this._ownOpacity=e}_GetStartWidth(){return 0===this._startWidth?Number.EPSILON:this._startWidth}_GetStartHeight(){return 0===this._startHeight?Number.EPSILON:this._startHeight}GetParentScaleX(){if(this._owner.GetTransformWithParentWidth()){let e=this._parent,t=e.GetWidth(),s=e._GetSceneGraphInfo()._GetStartWidth();return 0===t&&(t=Number.EPSILON),s===Number.EPSILON&&t===Number.EPSILON?1:s===Number.EPSILON&&t!==Number.EPSILON&&this._originalSizeKnown?1+t/this._originalWidth:t/s}return 1}GetParentScaleY(){if(this._owner.GetTransformWithParentHeight()){let e=this._parent,t=e.GetHeight(),s=e._GetSceneGraphInfo()._GetStartHeight();return 0===t&&(t=Number.EPSILON),s===Number.EPSILON&&t===Number.EPSILON?1:s===Number.EPSILON&&t!==Number.EPSILON&&this._originalSizeKnown?1+t/this._originalHeight:t/s}return 1}GetParentStartAngle(){return 0}_SaveToJsonProperties(){return{sw:this._startWidth,sh:this._startHeight,sx:this._startScaleX,sy:this._startScaleY,psa:this._parentStartAngle,oo:this._ownOpacity,so:this._startOpacity,pi:this._owner.GetInstance().GetIndexInParent()}}_SaveToJson(e,t=null){const s=this._SaveToJsonProperties();return t&&t.selfOnly?Object.assign(s,{p:null,c:[]}):Object.assign(s,{p:this._GetParentJson(e),c:this._GetChildrenJson(e)})}_GetFlagsString(e){let t="";return e.GetTransformWithParentX()&&(t+="x"),e.GetTransformWithParentY()&&(t+="y"),e.GetTransformWithParentWidth()&&(t+="w"),e.GetTransformWithParentHeight()&&(t+="h"),e.GetTransformWithParentAngle()&&(t+="a"),e.GetTransformWithParentZElevation()&&(t+="z"),e.GetDestroyWithParent()&&(t+="d"),e.GetTransformWithParentOpacity()&&(t+="o"),e.GetTransformWithParentVisibility()&&(t+="v"),t}_GetParentJson(e){return this._parent&&this._parent.GetInstance()&&!this._parent.GetInstance().IsDestroyed()?this._GetInstanceJson(this._parent,this._owner,e):null}_GetChildrenJson(t){return this._children.map(e=>this._GetInstanceJson(e,e,t)).filter(e=>e)}_GetInstanceJson(e,t,s){const i=e.GetInstance();if(i&&i.IsDestroyed())return null;const r={};return r.uid=i.GetUID(),r.f=this._GetFlagsString(t),r.offsets=t._SaveSceneGraphPropertiesToJson(),r.data=C33.SceneGraphInfo.GetSceneGraphInstanceDataFromInstance(i),r.oci=i.GetObjectClass().GetIndex(),"state"===s?(r.inst=i.SaveToJson("full",{selfOnly:!0}),r.instIndex=NaN):(r.instIndex=i.GetObjectClass().GetInstances().indexOf(i),r.inst=null),r}_LoadFromJson(e){this._startWidth=e.sw,this._startHeight=e.sh,this._startScaleX=e.sx,this._startScaleY=e.sy,this._parentStartAngle=e.psa,this._ownOpacity=e.oo,this._startOpacity=e.so,this._indexInParent=C33.IsFiniteNumber(e.pi)?e.pi:NaN}_SetTmpSceneGraphChildren(e,t){if(!e&&!t&&this._tmpSceneGraphChildren)for(const s of this._tmpSceneGraphChildren)s.IsDestroyed()||s.HasParent()||s.GetRuntime().DestroyInstance(s);this._tmpSceneGraphChildren=e,this._tmpSceneGraphChildrenIndexes=t}_OnAfterLoad(e,t){const s=this._owner,i=s.GetRuntime(),r=new Set;if(e.p&&!this._parent){const o=e.p.uid,l=i.GetInstanceByUID(o);if(t?.setFromJson,l){const h=l.GetWorldInfo();if(l.HasChild(s.GetInstance()))this._parent=h;else{l.HasChildWithUID(s.GetInstance().GetUID())?i.DestroyInstance(s.GetInstance()):l.AddChild(s.GetInstance(),this._GetFlagsObj(e.p.f)),r.has(s)||(s._LoadSceneGraphPropertiesFromJson(e.p.offsets),this._LoadInstancePropertiesFromJson(l,e.p,t)),r.add(s);const c=l.GetWorldInfo();c._GetSceneGraphInfo()._MaybeSortChildren()}}else if(C33.IsFiniteNumber(e.p.oci)){const u=i.GetObjectClassByIndex(e.p.oci),_=(i.GetSystemPlugin(),i.CreateInstance(u,s.GetLayer(),0,0,!0));if(t?.setFromJson,_){const d=this._GetInstanceData(e.p,i),p=(d&&_.LoadFromJson(d),_.GetWorldInfo()),m=(p.GetLayer().SortAndAddInstancesByZIndex(_),_.AddChild(s.GetInstance(),this._GetFlagsObj(e.p.f)),_.GetWorldInfo());m._GetSceneGraphInfo()._MaybeSortChildren()}}}const n=[];for(const g of e.c){const f=g.uid,S=i.GetInstanceByUID(f);S&&n.push(S)}let a=0;for(const C of e.c){const y=C.uid,G=i.GetInstanceByUID(y);if(t?.setFromJson,G){if(this._tmpSceneGraphChildren){if(this._tmpSceneGraphChildren.includes(G)){const A=G;if(A.GetObjectClass()!==G.GetObjectClass()){a++;continue}if(A.IsDestroyed()){a++;continue}const P=e.c[a];if(!t?.setFromJson&&this._HasAllChildrenOfType(A,n,s)){this._UpdateInstance(a,P,s,r,t),a++;continue}if(A.HasParent()&&A.GetParent()!==s.GetInstance()){const R=this._CreateNewChildInstance(P,t);this._AddAndSetChildInstance(R,P,r,t),a++;continue}this._AddAndSetChildInstance(A.GetWorldInfo(),P,r,t,!0),a++;continue}if(this._tmpSceneGraphChildren[a]){const x=this._tmpSceneGraphChildren[a];if(x.GetObjectClass()!==G.GetObjectClass()){a++;continue}if(x.IsDestroyed()){a++;continue}const E=e.c[a];if(!t?.setFromJson&&this._HasAllChildrenOfType(x,n,s)){this._UpdateInstance(a,E,s,r,t),a++;continue}if(x.HasParent()&&x.GetParent()!==s.GetInstance()){const v=this._CreateNewChildInstance(E,t);this._AddAndSetChildInstance(v,E,r,t),a++;continue}this._AddAndSetChildInstance(x.GetWorldInfo(),E,r,t,!0),a++;continue}}const I=G.GetObjectClass(),T=this._GetInstancesOfObjectClassCount(n,I),b=s.GetInstance().GetChildrenOfObjectClass(I).length;if(T===b){const w=s.GetInstance().GetChildAt(a);if(w){const M=w.GetWorldInfo();M&&(r.has(M)||(M._LoadSceneGraphPropertiesFromJson(C.offsets),this._LoadInstancePropertiesFromJson(w,C,t)),r.add(M))}a++;continue}if(G.HasParent()&&G.GetParent()!==s.GetInstance()){const D=this._CreateNewChildInstance(C,t);this._AddAndSetChildInstance(D,C,r,t),a++;continue}this._AddAndSetChildInstance(G.GetWorldInfo(),C,r,t)}else if(this._tmpSceneGraphChildren&&this._tmpSceneGraphChildren[a]){const O=this._tmpSceneGraphChildren[a],F=i.GetObjectClassByIndex(this._GetObjectClassIndex(C));if(O.GetObjectClass()!==F){a++;continue}if(O.IsDestroyed()){a++;continue}const L=e.c[a];if(!t?.setFromJson&&this._HasAllChildrenOfType(O,n,s)){this._UpdateInstance(a,L,s,r,t),a++;continue}if(O.HasParent()&&O.GetParent()!==s.GetInstance()){const B=this._CreateNewChildInstance(L,t);this._AddAndSetChildInstance(B,L,r,t),a++;continue}this._AddAndSetChildInstance(O.GetWorldInfo(),L,r,t)}else{const k=this._CreateNewChildInstance(C,t);this._AddAndSetChildInstance(k,C,r,t)}a++}}_HasAllChildrenOfType(e,t,s){const i=e.GetObjectClass(),r=this._GetInstancesOfObjectClassCount(t,i),n=s.GetInstance().GetChildrenOfObjectClass(i).length;return r===n}_UpdateInstance(e,t,s,i,r){const n=s.GetInstance().GetChildAt(e,t);if(n){const a=n.GetWorldInfo();a&&(i.has(a)||(a._LoadSceneGraphPropertiesFromJson(t.offsets),this._LoadInstancePropertiesFromJson(n,t,r)),i.add(a))}}_GetFlagsObj(e){const t={};return t.transformX=e.includes("x"),t.transformY=e.includes("y"),t.transformWidth=e.includes("w"),t.transformHeight=e.includes("h"),t.transformAngle=e.includes("a"),t.transformZElevation=e.includes("z"),t.destroyWithParent=e.includes("d"),t.transformOpacity=e.includes("o"),t.transformVisibility=e.includes("v"),t}_GetObjectClassIndex(e){return C33.IsFiniteNumber(e.oci)?e.oci:e[1]}_CreateNewChildInstance(i,r){if(C33.IsFiniteNumber(i.oci)){let e=this._owner,t=e.GetRuntime(),s;if(i.data)s=t.CreateInstanceFromData(i.data,e.GetLayer(),!1,0,0,!1,!0);else{const n=t.GetObjectClassByIndex(i.oci);s=t.CreateInstance(n,e.GetLayer(),0,0,!0)}if(r?.setFromJson,s){const a=this._GetInstanceData(i,t),o=(a&&s.LoadFromJson(a),s.GetWorldInfo());return o.GetLayer().SortAndAddInstancesByZIndex(s,!0),o}}}_AddAndSetChildInstance(e,t,s,i,r=!0){const n=this._owner,a=n.AddChild(e,this._GetFlagsObj(t.f));a&&r&&(s.has(e)||(e._LoadSceneGraphPropertiesFromJson(t.offsets),this._LoadInstancePropertiesFromJson(e.GetInstance(),t,i)),s.add(e)),this._MaybeSortChildren()}_LoadInstancePropertiesFromJson(e,t,s){let i=this._GetInstanceData(t,this._owner.GetRuntime());i&&((i=JSON.parse(JSON.stringify(i))).w=null,e.LoadFromJson(i))}_GetInstancesOfObjectClassCount(e,t){return e.filter(e=>e.GetObjectClass().GetName()===t.GetName()).length}_GetInstanceData(e,t){if(C33.IsFiniteNumber(e.instIndex)){const s=t.GetObjectClassByIndex(e.oci),i=s._GetLoadInstancesJson();return i?i[e.instIndex]:null}return C33.IsString(e.inst)?JSON.parse(e.inst):e.inst||void 0}static GetSceneGraphInstanceDataFromInstance(e){let t=e.GetWorldInfo().GetLayer().GetInitialInstanceData(e.GetUID());if(!t)return null;t=JSON.parse(JSON.stringify(t));const s=[];for(const i of[...e.GetChildren()]){const r=i.GetWorldInfo();s.push([r.GetLayout().GetSID(),r.GetLayer().GetIndex(),i.GetUID(),C33.SceneGraphInfo._GetFlagsNumber(r),i.GetObjectClass().IsInContainer()?1:0,r.GetZIndex(),C33.SceneGraphInfo.GetSceneGraphInstanceDataFromInstance(i)])}return C33.IsArray(t[0][14])?t[0][14][1]=s:(t[0][14]=[],t[0][14][0]=C33.SceneGraphInfo._GetDefaultFlagsNumber(),t[0][14][1]=s,t[0][14][2]=e.GetWorldInfo().GetZIndex()),t}static _GetFlagsNumber(e){let t=0;return(t|=Number(e.GetTransformWithParentVisibility())<<8)|Number(e.GetTransformWithParentOpacity())<<7|Number(e.GetTransformWithParentZElevation())<<6|Number(e.GetDestroyWithParent())<<5|Number(e.GetTransformWithParentAngle())<<4|Number(e.GetTransformWithParentHeight())<<3|Number(e.GetTransformWithParentWidth())<<2|Number(e.GetTransformWithParentY())<<1|Number(e.GetTransformWithParentX())<<0}static _GetDefaultFlagsNumber(e){let t=0;return t,511}}}{let C33=self.C3,glMatrix=self.glMatrix,vec32=glMatrix.vec3,vec42=glMatrix.vec4,tempRect=C33.New(C33.Rect),tempQuad=C33.New(C33.Quad),bboxChangeEvent=C33.New(C33.Event,"bboxchange",!1),tempColor=C33.New(C33.Color,0,0,0,0),tempCollisionPoly=C33.New(C33.CollisionPoly),DEFAULT_COLOR=C33.New(C33.Color,1,1,1,1),DEFAULT_RENDER_CELLS=C33.New(C33.Rect,0,0,-1,-1),DEFAULT_COLLISION_CELLS=C33.New(C33.Rect,0,0,-1,-1),VALID_SET_MESH_POINT_MODES=new Set(["absolute","relative"]),EMPTY_ARRAY=[],enableUpdateRendererStateGroup=!0,FLAG_IS_VISIBLE=1,FLAG_BBOX_CHANGED=2,FLAG_ENABLE_BBOX_CHANGED_EVENT=4,FLAG_COLLISION_ENABLED=8,FLAG_COLLISION_CELL_CHANGED=16,FLAG_SOLID_FILTER_INCLUSIVE=32,FLAG_HAS_ANY_ACTIVE_EFFECT=64,FLAG_IS_ROTATABLE=128,FLAG_DESTROYED=256,FLAG_DESTROY_WITH_PARENT=512,FLAG_TRANSFORM_WITH_PARENT_X=1024,FLAG_TRANSFORM_WITH_PARENT_Y=2048,FLAG_TRANSFORM_WITH_PARENT_W=4096,FLAG_TRANSFORM_WITH_PARENT_H=8192,FLAG_TRANSFORM_WITH_PARENT_A=16384,FLAG_TRANSFORM_WITH_PARENT_Z_ELEVATION=32768,FLAG_TRANSFORM_WITH_PARENT_OPACITY=1<<22,FLAG_TRANSFORM_WITH_PARENT_VISIBILITY=1<<23,MASK_ALL_SCENE_GRAPH_FLAGS=FLAG_DESTROY_WITH_PARENT|FLAG_TRANSFORM_WITH_PARENT_X|FLAG_TRANSFORM_WITH_PARENT_Y|FLAG_TRANSFORM_WITH_PARENT_W|FLAG_TRANSFORM_WITH_PARENT_H|FLAG_TRANSFORM_WITH_PARENT_A|FLAG_TRANSFORM_WITH_PARENT_Z_ELEVATION|FLAG_TRANSFORM_WITH_PARENT_OPACITY|FLAG_TRANSFORM_WITH_PARENT_VISIBILITY,FLAG_MESH_CHANGED=65536,FLAG_PHYSICS_BODY_CHANGED=1<<17,FLAG_SIN_COS_ANGLE_CHANGED=1<<18,FLAG_USE_POINTS_SHADER_PROGRAM=1<<19,FLAG_DRAW_BACK_FACE_ONLY=1<<20,FLAG_DRAW_NON_BACK_FACES_ONLY=1<<21,FLAG_BLEND_MODE_BIT_OFFSET=26,FLAG_BLEND_MODE_MASK=31<<FLAG_BLEND_MODE_BIT_OFFSET,sceneGraphExportDataMap=new WeakMap,sceneGraphZIndexMap=new WeakMap;C33.WorldInfo=class extends C33.DefendedBase{constructor(e,t){super(),this._inst=e,this._objectClass=e.GetObjectClass(),this._runtime=e.GetRuntime(),this._layer=t,this._objectClass._OnWorldInstanceLayerChanged(this,null,t),this._zIndex=-1,this._htmlZIndex=-1,this._flags=FLAG_IS_VISIBLE|FLAG_BBOX_CHANGED|FLAG_COLLISION_ENABLED|FLAG_COLLISION_CELL_CHANGED|FLAG_MESH_CHANGED|FLAG_PHYSICS_BODY_CHANGED,this._objectClass.GetPlugin().IsRotatable()&&(this._flags|=FLAG_IS_ROTATABLE),this._x=NaN,this._y=NaN,this._zElevation=NaN,this._w=NaN,this._h=NaN,this._depth=NaN,this._a=NaN,this._sinA=NaN,this._cosA=NaN,this._ox=NaN,this._oy=NaN,this._boundingBox=C33.New(C33.Rect),this._boundingQuad=C33.New(C33.Quad),this._collisionCells=DEFAULT_COLLISION_CELLS,this._renderCells=DEFAULT_RENDER_CELLS,this._sourceCollisionPoly=null,this._transformedPolyInfo=null,this._solidFilterTags=null,this._color=DEFAULT_COLOR,this._colorPremultiplied=DEFAULT_COLOR,this._stateGroup=null,this._instanceEffectList=null,this._inst.GetObjectClass().UsesEffects()&&(this._instanceEffectList=C33.New(C33.InstanceEffectList,this._inst,this)),this._sceneGraphInfo=null,this._tmpSceneGraphChildren=null,this._tmpSceneGraphChildrenIndexes=null,this._tmpHierarchyPosition=-1,this._meshInfo=null}_MarkDestroyed(){this._flags|=FLAG_DESTROYED}Release(){if(this._objectClass._OnWorldInstanceLayerChanged(this,this._layer,null),this._stateGroup&&(this._runtime.GetRenderer().ReleaseStateGroup(this._stateGroup),this._stateGroup=null),this._sourceCollisionPoly=null,this._transformedPolyInfo&&(this._transformedPolyInfo.poly.Release(),this._transformedPolyInfo=null),this._solidFilterTags&&(this._solidFilterTags.clear(),this._solidFilterTags=null),this.ReleaseMesh(),this._instanceEffectList&&this._instanceEffectList.Release(),this.HasParent()&&this.GetParent().RemoveChild(this),this.HasChildren()){const e=[...this.GetChildren()];for(const t of e)this.RemoveChild(t)}this._ReleaseSceneGraphInfo(),this._ReleaseTmpSceneGraphInfo(),sceneGraphExportDataMap.delete(this),sceneGraphZIndexMap.delete(this),this._inst=null,this._objectClass=null,this._runtime=null,this._layer=null}Init(e){if(enableUpdateRendererStateGroup=!1,this.SetXY(e[0],e[1]),this.SetZElevation(e[2]),this.SetSize(e[3],e[4]),this._depth=0,this.IsRotatable()?this.SetAngle(e[6]):this._a=0,tempColor.setFromJSON(e[7]),this._SetColor(tempColor),this.SetOriginX(e[8]),this.SetOriginY(e[9]),this.SetBlendMode(e[10]),this._instanceEffectList&&this._instanceEffectList._LoadEffectParameters(e[12]),e[14]&&sceneGraphExportDataMap.set(this,{childrenData:e[14][1],zIndexData:e[14][2]}),e[15]){const t=e[15],i=(this.CreateMesh(t[0],t[1]),this.GetSourceMesh()),r=t[2];for(let s=0,e=r.length;s<e;++s){const n=r[s];for(let e=0,t=n.length;e<t;++e){const a=n[e],o=i.GetMeshPointAt(e,s);o.SetX(a[0]),o.SetY(a[1]),o.SetZElevation(a[2]),o.SetU(a[3]),o.SetV(a[4])}}}if(e[16]){const s=e[16][0],l=e[16][1],h=!!l,c=!h,u=this._runtime.GetTemplateManager();h&&u&&u.MapInstanceToTemplateName(this.GetInstance(),l),c&&u&&u.MapInstanceToTemplateName(this.GetInstance(),s)}enableUpdateRendererStateGroup=!0,this._UpdateRendererStateGroup()}InitNoData(){this._x=0,this._y=0,this._zElevation=0,this._w=0,this._h=0,this._depth=0,this._a=0,this._sinA=0,this._cosA=1,this._ox=0,this._oy=0,this._UpdateRendererStateGroup()}GetRuntime(){return this._runtime}GetObjectClass(){return this._objectClass}GetInstance(){return this._inst}_GetParentOffsetAngle(){return this.GetTransformWithParentAngle()?this._MaybeReflectAngleForMirrorFlip(this.GetParent()._GetAngleNoReflect()-this._sceneGraphInfo.GetParentStartAngle()):0}SetX(e){if(e=+e,this.GetTransformWithParentX()){const t=this._sceneGraphInfo,s=e-this.GetX(),i=-this._GetParentOffsetAngle();0==i?this._x+=s/t.GetParentScaleX():(this._x+=Math.cos(i)*s/t.GetParentScaleX(),this.GetTransformWithParentY()&&(this._y+=Math.sin(i)*s/t.GetParentScaleY()))}else this._x=e}OffsetX(e,t=!1){e=+e,!t&&this.GetTransformWithParentX()?this.SetX(this.GetX()+e):this._x+=e}GetX(){if(this.GetTransformWithParentX()){let e=this._x,t=this._sceneGraphInfo,s=this.GetParent(),i=this._GetParentOffsetAngle();return 0===i?e*=t.GetParentScaleX():(e=e*t.GetParentScaleX()*Math.cos(i),this.GetTransformWithParentY()&&(e-=this._y*t.GetParentScaleY()*Math.sin(i))),s.GetX()+e}return this._x}SetY(e){if(e=+e,this.GetTransformWithParentY()){const t=this._sceneGraphInfo,s=e-this.GetY(),i=-this._GetParentOffsetAngle();0==i?this._y+=s/t.GetParentScaleY():(this.GetTransformWithParentX()&&(this._x-=Math.sin(i)*s/t.GetParentScaleX()),this._y+=Math.cos(i)*s/t.GetParentScaleY())}else this._y=e}OffsetY(e,t=!1){e=+e,!t&&this.GetTransformWithParentY()?this.SetY(this.GetY()+e):this._y+=e}GetY(){if(this.GetTransformWithParentY()){let e=this._y,t=this._sceneGraphInfo,s=this.GetParent(),i=this._GetParentOffsetAngle();return 0===i?e*=t.GetParentScaleY():(e=e*t.GetParentScaleY()*Math.cos(i),this.GetTransformWithParentX()&&(e+=this._x*t.GetParentScaleX()*Math.sin(i))),s.GetY()+e}return this._y}SetXY(e,t){if(e=+e,t=+t,this.GetTransformWithParentXOrY()){const s=this.GetTransformWithParentX(),i=this.GetTransformWithParentY(),r=this._sceneGraphInfo,n=e-this.GetX(),a=t-this.GetY(),o=-this._GetParentOffsetAngle();if(0==o)s?this._x+=n/r.GetParentScaleX():this._x=e,i?this._y+=a/r.GetParentScaleY():this._y=t;else{const l=Math.sin(o),h=Math.cos(o);s?this._x+=i?(h*n-l*a)/r.GetParentScaleX():h*n/r.GetParentScaleX():this._x=e,i?this._y+=s?(l*n+h*a)/r.GetParentScaleY():h*a/r.GetParentScaleY():this._y=t}}else this._x=e,this._y=t}GetXY(){return[this.GetX(),this.GetY()]}OffsetXY(e,t){e=+e,t=+t,this.GetTransformWithParentXOrY()?this.SetXY(this.GetX()+e,this.GetY()+t):(this._x+=e,this._y+=t)}EqualsXY(e,t){return this.GetX()===e&&this.GetY()===t}SetZElevation(e){if(e=+e,this.GetTransformWithParentZElevation()&&(e-=this.GetParent().GetZElevation()),this._zElevation!==e){this._zElevation=e,this._UpdateZElevation();const t=this.GetLayer();0!==this._zElevation&&t._SetAnyInstanceZElevated(),t.SetZIndicesChanged(this)}}_UpdateZElevation(){if(this._UpdateRendererStateGroup(),this.HasChildren()){const s=this.GetChildren();for(let e=0,t=s.length;e<t;e++){const i=s[e];i.GetTransformWithParentZElevation()&&i._UpdateZElevation()}}}OffsetZElevation(e){this.SetZElevation(this.GetZElevation()+e)}GetZElevation(){return this.GetTransformWithParentZElevation()?this.GetParent().GetZElevation()+this._zElevation:this._zElevation}GetTotalZElevation(){return this.GetLayer().GetZElevation()+this.GetZElevation()}IsOriginalSizeKnown(){const e=this.GetInstance().GetPlugin().GetSdkVersion();return e<2&&this.GetInstance().GetSdkInstance().IsOriginalSizeKnown()}SetWidth(e){if(e=+e,this.GetTransformWithParentWidth()){const t=this.GetWidth();0===t?this._w=Number.EPSILON:this._w*=e/t}else this._w=e;this._MarkSinCosAngleChanged()}OffsetWidth(e,t){e=+e,!t&&this.GetTransformWithParentWidth()?this.SetWidth(this.GetWidth()+e):this._w+=e,this._MarkSinCosAngleChanged()}GetWidth(){if(this.GetTransformWithParentWidth()){const e=this.GetParent(),t=e.GetWidth(),s=e._GetSceneGraphInfo()._GetStartWidth();return s===Number.EPSILON?(this._GetSceneGraphInfo()._GetStartWidth()+t)*this._w:t*this._w}return this._w}SetHeight(e){if(e=+e,this.GetTransformWithParentHeight()){const t=this.GetHeight();0===t?this._h=Number.EPSILON:this._h*=e/t}else this._h=e;this._MarkSinCosAngleChanged()}OffsetHeight(e,t){e=+e,!t&&this.GetTransformWithParentHeight()?this.SetHeight(this.GetHeight()+e):this._h+=e,this._MarkSinCosAngleChanged()}GetHeight(){if(this.GetTransformWithParentHeight()){const e=this.GetParent(),t=e.GetHeight(),s=e._GetSceneGraphInfo()._GetStartHeight();return s===Number.EPSILON?(this._GetSceneGraphInfo()._GetStartHeight()+t)*this._h:t*this._h}return this._h}SetSize(e,t){if(e=+e,t=+t,this.GetTransformWithParentWidth()){const s=this.GetWidth();0===s?this._w=Number.EPSILON:this._w*=e/s}else this._w=e;if(this.GetTransformWithParentHeight()){const i=this.GetHeight();0===i?this._h=Number.EPSILON:this._h*=t/i}else this._h=t;this._MarkSinCosAngleChanged()}GetSize(){return[this.GetWidth(),this.GetHeight()]}GetDepth(){return this._depth}SetDepth(e){if(e<0)throw new RangeError("invalid depth");this._depth=e}GetSceneGraphScale(){if(this.HasParent()){const e=this._sceneGraphInfo;return Math.min(e.GetParentScaleX(),e.GetParentScaleY())}return 1}IsRotatable(){return 0!=(this._flags&FLAG_IS_ROTATABLE)}SetAngle(e){e=+e,this.IsRotatable()&&(this.GetTransformWithParentAngle()&&(e-=this.GetParent().GetAngle()),e=C33.clampAngle(e),this._a!==e)&&(this._a=e,this._MarkSinCosAngleChanged())}OffsetAngle(e){0!=(e=+e)&&this.IsRotatable()&&(this._a=C33.clampAngle(this._a+e),this._MarkSinCosAngleChanged())}_MarkSinCosAngleChanged(){if(this._flags|=FLAG_SIN_COS_ANGLE_CHANGED,this.HasChildren()){const s=this.GetChildren();for(let e=0,t=s.length;e<t;e++)s[e]._MarkSinCosAngleChanged()}}GetAngle(){return this.GetTransformWithParentAngle()&&this.IsRotatable()?this._MaybeReflectAngleForMirrorFlip(C33.clampAngle(this.GetParent()._GetAngleNoReflect()+this._a)):this._a}_GetAngleNoReflect(){return this.GetTransformWithParentAngle()&&this.IsRotatable()?C33.clampAngle(this.GetParent()._GetAngleNoReflect()+this._a):this._a}_MaybeReflectAngleForMirrorFlip(e){return this.GetTransformWithParentWidth()&&this.GetTopParent().GetWidth()<0&&(e=C33.clampAngle(C33.angleReflect(e,this.GetTopParent().GetAngle()+Math.PI))),this.GetTransformWithParentHeight()&&this.GetTopParent().GetHeight()<0?C33.angleReflect(e,this.GetTopParent().GetAngle()):e}_NeedsReflectAngleForMirrorOrFlip(){const e=this.GetParent();return!!(this.GetTransformWithParentWidth()&&e.GetWidth()<0)||!!(this.GetTransformWithParentHeight()&&e.GetHeight()<0)}_NeedsReflectAngleForMirrorAndFlip(){const e=this.GetParent();return!!(this.GetTransformWithParentWidth()&&e.GetWidth()<0&&this.GetTransformWithParentHeight()&&e.GetHeight()<0)}_MaybeUpdateSinCosAngle(){const e=this._flags;if(0!=(e&FLAG_SIN_COS_ANGLE_CHANGED)){const t=this.GetAngle();this._sinA=Math.sin(t),this._cosA=Math.cos(t),this._flags=e&~FLAG_SIN_COS_ANGLE_CHANGED}}GetSinAngle(){return this._MaybeUpdateSinCosAngle(),this._sinA}GetCosAngle(){return this._MaybeUpdateSinCosAngle(),this._cosA}SetOriginX(e){this._ox=+e}OffsetOriginX(e){this._ox+=+e}GetOriginX(){return this._ox}SetOriginY(e){this._oy=+e}OffsetOriginY(e){this._oy+=+e}GetOriginY(){return this._oy}_SetColor(e){this._color.equals(e)||(this._color===DEFAULT_COLOR?(this._color=C33.New(C33.Color,e),this._colorPremultiplied=C33.New(C33.Color,e),this._colorPremultiplied.premultiply()):e.equalsRgba(1,1,1,1)?(this._color=DEFAULT_COLOR,this._colorPremultiplied=DEFAULT_COLOR):(this._color.set(e),this._colorPremultiplied.set(e),this._colorPremultiplied.premultiply()),this._UpdateRendererStateGroup())}SetOpacity(e){if(e=C33.clamp(+e,0,1),this.GetTransformWithParentOpacity()){if(this._GetSceneGraphInfo().GetOwnOpacity()===e)return;this._GetSceneGraphInfo().SetOwnOpacity(e),e=this.GetOpacity()}else if(this._color.a===e)return;this._SetColorWithOpacity(e)}_SetOpacityOfChildren(){if(this.HasChildren()){const s=this.GetChildren();for(let e=0,t=s.length;e<t;e++){const i=s[e];i._SetColorWithOpacity(i.GetOpacity())}}}_SetColorWithOpacity(e){tempColor.copyRgb(this._color),tempColor.a=e,this._SetColor(tempColor),this._SetOpacityOfChildren()}OffsetOpacity(e){this.GetTransformWithParentOpacity()?this.SetOpacity(this._GetSceneGraphInfo().GetOwnOpacity()+e):this.SetOpacity(this.GetOpacity()+e)}GetOpacity(){return this.GetTransformWithParentOpacity()?this.GetParent().GetOpacity()*this._GetSceneGraphInfo().GetOwnOpacity():this._color.a}SetUnpremultipliedColor(e){this._color.equalsIgnoringAlpha(e)||(tempColor.copyRgb(e),tempColor.a=this.GetOpacity(),this._SetColor(tempColor))}SetUnpremultipliedColorRGB(e,t,s){tempColor.setRgb(e,t,s),this.SetUnpremultipliedColor(tempColor)}OffsetUnpremultipliedColorRGB(e,t,s){0===e&&0===t&&0===s||(tempColor.copyRgb(this._color),tempColor.r+=e,tempColor.g+=t,tempColor.b+=s,this.SetUnpremultipliedColor(tempColor))}GetUnpremultipliedColor(){return this._color}GetPremultipliedColor(){return this._colorPremultiplied}GetDestroyWithParent(){return 0!=(this._flags&FLAG_DESTROY_WITH_PARENT)}SetDestroyWithParent(e){this._SetFlag(FLAG_DESTROY_WITH_PARENT,e)}GetTransformWithParentX(){return 0!=(this._flags&FLAG_TRANSFORM_WITH_PARENT_X)}SetTransformWithParentX(e){this._SetFlag(FLAG_TRANSFORM_WITH_PARENT_X,e)}GetTransformWithParentY(){return 0!=(this._flags&FLAG_TRANSFORM_WITH_PARENT_Y)}GetTransformWithParentXOrY(){return 0!=(this._flags&(FLAG_TRANSFORM_WITH_PARENT_X|FLAG_TRANSFORM_WITH_PARENT_Y))}SetTransformWithParentY(e){this._SetFlag(FLAG_TRANSFORM_WITH_PARENT_Y,e)}GetTransformWithParentWidth(){return 0!=(this._flags&FLAG_TRANSFORM_WITH_PARENT_W)}SetTransformWithParentWidth(e){this._SetFlag(FLAG_TRANSFORM_WITH_PARENT_W,e)}GetTransformWithParentHeight(){return 0!=(this._flags&FLAG_TRANSFORM_WITH_PARENT_H)}SetTransformWithParentHeight(e){this._SetFlag(FLAG_TRANSFORM_WITH_PARENT_H,e)}GetTransformWithParentAngle(){return 0!=(this._flags&FLAG_TRANSFORM_WITH_PARENT_A)}SetTransformWithParentAngle(e){this._SetFlag(FLAG_TRANSFORM_WITH_PARENT_A,e)}GetTransformWithParentZElevation(){return 0!=(this._flags&FLAG_TRANSFORM_WITH_PARENT_Z_ELEVATION)}SetTransformWithParentZElevation(e){this._SetFlag(FLAG_TRANSFORM_WITH_PARENT_Z_ELEVATION,e)}GetTransformWithParentOpacity(){return 0!=(this._flags&FLAG_TRANSFORM_WITH_PARENT_OPACITY)}SetTransformWithParentOpacity(e){this._SetFlag(FLAG_TRANSFORM_WITH_PARENT_OPACITY,e)}GetTransformWithParentVisibility(){return 0!=(this._flags&FLAG_TRANSFORM_WITH_PARENT_VISIBILITY)}SetTransformWithParentVisibility(e){this._SetFlag(FLAG_TRANSFORM_WITH_PARENT_VISIBILITY,e)}_ClearAllSceneGraphFlags(){this._flags&=~MASK_ALL_SCENE_GRAPH_FLAGS}AddChild(e,t){if(e===this)return!1;if(e.HasParent())return!1;if(this._HasChildRecursive(e))return!1;if(this._HasAnyParent(e))return!1;const s=e.GetX(),i=e.GetY(),r=e.GetWidth(),n=e.GetHeight(),a=e.GetAngle(),o=e.GetZElevation(),l=e.GetOpacity(),h=(e._SetParent(this),e.SetTransformWithParentX(t.transformX),e.SetTransformWithParentY(t.transformY),e.SetTransformWithParentWidth(t.transformWidth),e.SetTransformWithParentHeight(t.transformHeight),e.SetTransformWithParentAngle(t.transformAngle),e.SetTransformWithParentZElevation(t.transformZElevation),e.SetTransformWithParentOpacity(t.transformOpacity),e.SetTransformWithParentVisibility(t.transformVisibility),e.SetDestroyWithParent(t.destroyWithParent),s-this.GetX()),c=i-this.GetY(),u=-this.GetAngle(),_=Math.cos(u),d=Math.sin(u);if(t.transformX&&(t.transformAngle?e._x=h*_-c*d:e._x=h,t.transformWidth)){const p=this.GetWidth()/this._sceneGraphInfo._GetStartWidth();0!=p&&(e._x/=p)}if(t.transformY&&(t.transformAngle?e._y=h*d+c*_:e._y=c,t.transformHeight)){const m=this.GetHeight()/this._sceneGraphInfo._GetStartHeight();0!=m&&(e._y/=m)}if(t.transformWidth){const g=this.GetWidth();0===g||g===Number.EPSILON?(e._w=1,e._sceneGraphInfo.SetStartScaleX(1)):(e._w=r/this.GetWidth(),e._sceneGraphInfo.SetStartScaleX(e._w))}if(t.transformHeight){const f=this.GetHeight();0===f||f===Number.EPSILON?(e._h=1,e._sceneGraphInfo.SetStartScaleY(1)):(e._h=n/this.GetHeight(),e._sceneGraphInfo.SetStartScaleY(e._h))}return t.transformAngle&&(e._a=a-this.GetAngle()),t.transformZElevation&&(e._zElevation=o-this.GetZElevation()),t.transformOpacity&&e._sceneGraphInfo.SetOwnOpacity(l),t.transformVisibility&&e.SetVisible(this.IsVisible()),this._AddChildToSceneGraphInfo(e),this.SetBboxChanged(),this._SetOpacityOfChildren(),!0}RemoveChild(e){if(e.GetParent()===this){const t=e.GetX(),s=e.GetY(),i=e.GetWidth(),r=e.GetHeight(),n=e.GetAngle(),a=e.GetZElevation(),o=e.GetOpacity();e._SetParent(null),e._ClearAllSceneGraphFlags(),e.SetXY(t,s),e.SetSize(i,r),e.SetAngle(n),e.SetZElevation(a),e.SetOpacity(o),this._RemoveChildFromSceneGraphInfo(e),this.SetBboxChanged()}}GetTmpHierarchyPosition(){return this._tmpHierarchyPosition}_ResetAllSceneGraphState(){this._BuildTmpSceneGraphData();const e=[...this.children()];for(const s of e)this.RemoveChild(s);const t=this.GetParent();t&&t.RemoveChild(this),this._ClearAllSceneGraphFlags()}_BuildTmpSceneGraphData(){if(this._SetTmpHierarchyPosition(),!this._tmpSceneGraphChildren){const t=[...this.children()];t.length&&(this._tmpSceneGraphChildren=[],this._tmpSceneGraphChildrenIndexes=new WeakMap);let e=0;for(const s of t){const i=s.GetInstance();this._tmpSceneGraphChildren.push(i),this._tmpSceneGraphChildrenIndexes.set(i,e),e++}}const e=this.GetParent();e&&e._BuildTmpSceneGraphData()}_SetTmpHierarchyPosition(){if(-1===this._tmpHierarchyPosition){const e=[...this.parents()];this._tmpHierarchyPosition=e.length;for(const s of e)s._SetTmpHierarchyPosition();const t=[...this.children()];for(const i of t)i._SetTmpHierarchyPosition()}}_ReleaseTmpSceneGraphInfo(){this._tmpSceneGraphChildren&&(this._tmpSceneGraphChildren.length=0),this._tmpSceneGraphChildren=null,this._tmpSceneGraphChildrenIndexes=null;const e=this.GetParent();e&&e._ReleaseTmpSceneGraphInfo(),this._tmpHierarchyPosition=-1}HasParent(){return null!==this.GetParent()}GetParent(){const e=this._sceneGraphInfo;return null!==e?e.GetParent():null}GetTopParent(){let e=this;for(;e.HasParent();)e=e.GetParent();return e}*parents(){let e=this.GetParent();for(;e;)yield e,e=e.GetParent()}HasChild(e){return this.GetChildren().includes(e)}HasChildren(){const e=this._sceneGraphInfo;return null!==e&&e.HasChildren()}GetChildren(){const e=this._sceneGraphInfo;return null!==e?e.GetChildren():EMPTY_ARRAY}children(){return this.GetChildren()}*allChildren(){for(const e of this.children())yield e,yield*e.allChildren()}GetChildCount(){return this.GetChildren().length}GetAllChildCount(){return[...this.allChildren()].length}GetChildAt(e){const t=this.GetChildren();return(e=Math.floor(+e))<0||e>=t.length?null:t[e]}GetChildIndex(t){if(t){const s=this.GetChildren();if(s)for(let e=0;e<s.length;e++)if(t===s[e])return e}return NaN}_CreateSceneGraphInfo(e){this._sceneGraphInfo||(this._sceneGraphInfo=C33.New(C33.SceneGraphInfo,this)),e&&this._sceneGraphInfo.SetParent(e)}_GetSceneGraphInfo(){return this._sceneGraphInfo}_ReleaseSceneGraphInfo(){this._sceneGraphInfo&&(this._sceneGraphInfo.Release(),this._sceneGraphInfo=null)}_SetParent(e){e?(e._CreateSceneGraphInfo(null),this._CreateSceneGraphInfo(e)):(this._sceneGraphInfo&&this._sceneGraphInfo.SetParent(null),this.HasChildren()||this._ReleaseSceneGraphInfo())}_HasAnyParent(e){if(!this.HasParent())return!1;const t=this.GetParent();return t===e||t._HasAnyParent(e)}_HasChildRecursive(e){if(this.HasChild(e))return!0;for(const t of this.GetChildren())if(t._HasChildRecursive(e))return!0;return!1}_AddChildToSceneGraphInfo(e){this._sceneGraphInfo.GetChildren().push(e)}_RemoveChildFromSceneGraphInfo(e){const t=this._sceneGraphInfo.GetChildren(),s=t.indexOf(e);-1!==s&&t.splice(s,1),0!==t.length||this.HasParent()||this._ReleaseSceneGraphInfo(),e.HasChildren()||e._ReleaseSceneGraphInfo()}GetSceneGraphChildrenExportData(){const e=sceneGraphExportDataMap.get(this);return e?e.childrenData:null}GetSceneGraphZIndexExportData(){const e=sceneGraphExportDataMap.get(this);return e?e.zIndexData:NaN}GetSceneGraphZIndex(){const e=sceneGraphZIndexMap.get(this);return C33.IsFiniteNumber(e)?e:NaN}SetSceneGraphZIndex(e){sceneGraphZIndexMap.set(this,e)}SetUsePointsShaderProgram(){this._SetFlag(FLAG_USE_POINTS_SHADER_PROGRAM,!0),this._UpdateRendererStateGroup()}_UpdateRendererStateGroup(){if(enableUpdateRendererStateGroup){const t=this._runtime.GetRenderer();this._stateGroup&&t.ReleaseStateGroup(this._stateGroup);let e;e=0!=(this._flags&FLAG_USE_POINTS_SHADER_PROGRAM)?t.GetPointsRenderingProgram()||"<point>":t.GetTextureFillShaderProgram()||"<default>",this._stateGroup=t.AcquireStateGroup(e,this.GetBlendMode(),this._colorPremultiplied,this.GetZElevation())}}GetRendererStateGroup(){return this._stateGroup}HasDefaultColor(){return this._color===DEFAULT_COLOR}SetBlendMode(e){if((e|=0)<0||31<e)throw new RangeError("invalid blend mode");this.GetBlendMode()!==e&&(this._flags=this._flags&~FLAG_BLEND_MODE_MASK|e<<FLAG_BLEND_MODE_BIT_OFFSET,this._UpdateRendererStateGroup())}GetBlendMode(){return(this._flags&FLAG_BLEND_MODE_MASK)>>FLAG_BLEND_MODE_BIT_OFFSET}_SetLayer(e,t){const s=t&&this._layer!==e;s&&this._RemoveFromRenderCells(),this._objectClass._OnWorldInstanceLayerChanged(this,this._layer,e),this._layer=e,s&&this._UpdateRenderCell(),0!==this.GetZElevation()&&this._layer._SetAnyInstanceZElevated()}GetLayer(){return this._layer}GetLayout(){return this.GetLayer().GetLayout()}_SetZIndex(e){this._zIndex=0|e}GetZIndex(){return this._layer._UpdateZIndices(),this._zIndex}_SetHTMLZIndex(e){this._htmlZIndex=0|e}GetHTMLZIndex(){return this._layer._UpdateHTMLZIndices(),this._htmlZIndex}_GetLastCachedZIndex(){return this._zIndex}_SetFlag(e,t){t?this._flags|=e:this._flags&=~e}IsVisible(){return 0!=(this._flags&FLAG_IS_VISIBLE)}SetVisible(e){if(this._SetFlag(FLAG_IS_VISIBLE,e),this.HasChildren())for(const t of this.GetChildren())t.GetTransformWithParentVisibility()&&t.SetVisible(e)}IsCollisionEnabled(){return 0!=(this._flags&FLAG_COLLISION_ENABLED)}SetCollisionEnabled(e){e=!!e,this.IsCollisionEnabled()!==e&&(this._SetFlag(FLAG_COLLISION_ENABLED,e),e?this.SetBboxChanged():this._RemoveFromCollisionCells())}SetSolidCollisionFilter(e,t){if(this._SetFlag(FLAG_SOLID_FILTER_INCLUSIVE,e),this._solidFilterTags&&this._solidFilterTags.clear(),t.trim()){this._solidFilterTags||(this._solidFilterTags=new Set);for(const s of t.split(" "))s&&this._solidFilterTags.add(s.toLowerCase())}else this._solidFilterTags=null}IsSolidCollisionAllowed(e){const t=0!=(this._flags&FLAG_SOLID_FILTER_INCLUSIVE),s=this._solidFilterTags;if(e&&s)for(const i of s)if(e.has(i))return t;return!t}SetBboxChanged(){if(this._flags|=FLAG_BBOX_CHANGED|FLAG_COLLISION_CELL_CHANGED|FLAG_MESH_CHANGED,this._objectClass._SetAnyCollisionCellChanged(!0),this._runtime.UpdateRender(),this._layer.UsesRenderCells()&&(this.CalculateBbox(this._boundingBox,this._boundingQuad,!0),this._flags&=~FLAG_BBOX_CHANGED,this._UpdateRenderCell()),0!=(this._flags&FLAG_ENABLE_BBOX_CHANGED_EVENT)&&this._inst.Dispatcher().dispatchEvent(bboxChangeEvent),null!==this._sceneGraphInfo){const s=this._sceneGraphInfo.GetChildren();for(let e=0,t=s.length;e<t;++e)s[e].SetBboxChanged()}}CalculateBbox(e,t,s){const i=this.GetX(),r=this.GetY(),n=this.GetWidth(),a=this.GetHeight(),o=this.GetAngle();e.setWH(i-this._ox*n,r-this._oy*a,n,a),s&&this.HasMesh()&&this._ExpandBboxForMesh(e),0===o?t.setFromRect(e):(e.offset(-i,-r),t.setFromRotatedRectPrecalc(e,this.GetSinAngle(),this.GetCosAngle()),t.offset(i,r),t.getBoundingBox(e)),e.normalize()}_UpdateBbox(){const e=this._flags;0!=(e&FLAG_BBOX_CHANGED)&&(this.CalculateBbox(this._boundingBox,this._boundingQuad,!0),this._flags=e&~FLAG_BBOX_CHANGED)}GetBoundingBox(){return this._UpdateBbox(),this._boundingBox}GetBoundingQuad(){return this._UpdateBbox(),this._boundingQuad}PixelRoundQuad(e){const t=this.GetX(),s=this.GetY(),i=Math.round(t)-t,r=Math.round(s)-s;return 0==i&&0==r?e:(tempQuad.copy(e),tempQuad.offset(i,r),tempQuad)}OverwriteBoundingBox(e){this._boundingBox.copy(e),this._boundingQuad.setFromRect(this._boundingBox),this._flags&=~FLAG_BBOX_CHANGED,this._UpdateCollisionCell(),this._UpdateRenderCell()}SetBboxChangeEventEnabled(e){this._SetFlag(FLAG_ENABLE_BBOX_CHANGED_EVENT,e)}IsBboxChangeEventEnabled(){return 0!=(this._flags&FLAG_ENABLE_BBOX_CHANGED_EVENT)}IsInViewport(e,t,s){return t&&0!==this.GetDepth()?this.IsInViewport3D(this.GetLayer()._GetViewFrustum()):0===this.GetZElevation()||s?e.intersectsRect(this.GetBoundingBox()):this._IsInViewport_ZElevated()}_IsInViewport_ZElevated(){const e=this.GetLayer(),t=this.GetTotalZElevation();return!(t>=e.Get2DCameraZ())&&(e.GetViewportForZ(t,tempRect),tempRect.intersectsRect(this.GetBoundingBox()))}IsInViewport3D(e){const t=this.GetBoundingBox(),s=t.getLeft(),i=t.getRight(),r=t.getTop(),n=t.getBottom(),a=this.GetTotalZElevation(),o=a+this.GetDepth();return e.ContainsAABB(s,r,a,i,n,o)}IsInViewport2(){const e=this.GetLayer();if(e.Has3DCamera())return this.IsInViewport3D(e._GetViewFrustum());{const t=e.GetLayout();return this.IsInViewport(e.GetViewport(),t.HasVanishingPointOutsideViewport(),t.IsOrthographicProjection())}}_SetDrawBackFaceOnly(e){this._SetFlag(FLAG_DRAW_BACK_FACE_ONLY,e)}_SetDrawNonBackFacesOnly(e){this._SetFlag(FLAG_DRAW_NON_BACK_FACES_ONLY,e)}IsDrawBackFaceOnly(){return 0!=(this._flags&FLAG_DRAW_BACK_FACE_ONLY)}IsDrawNonBackFacesOnly(){return 0!=(this._flags&FLAG_DRAW_NON_BACK_FACES_ONLY)}SetSourceCollisionPoly(e){this._sourceCollisionPoly=e,this._DiscardTransformedCollisionPoly(),this.HasMesh()&&(this._meshInfo.meshPoly=null)}GetSourceCollisionPoly(){return this._sourceCollisionPoly}HasOwnCollisionPoly(){return null!==this._sourceCollisionPoly||this.HasMesh()}GetTransformedCollisionPoly(){return this._GetCustomTransformedCollisionPolyPrecalc(this.GetWidth(),this.GetHeight(),this.GetAngle(),this.GetSinAngle(),this.GetCosAngle())}GetCustomTransformedCollisionPoly(e,t,s){let i=0,r=1;return 0!==s&&(i=Math.sin(s),r=Math.cos(s)),this._GetCustomTransformedCollisionPolyPrecalc(e,t,s,i,r)}_GetCustomTransformedCollisionPolyPrecalc(r,n,e,a,o){let t=this._transformedPolyInfo;null===t&&(t={poly:C33.New(C33.CollisionPoly),width:NaN,height:NaN,angle:NaN},this._transformedPolyInfo=t);const l=t.poly;if(t.width!==r||t.height!==n||t.angle!==e){const h=this._sourceCollisionPoly;if(this.HasMesh()){let e=this.GetOriginX(),t=this.GetOriginY(),s=this.GetSourceMesh(),i=this._meshInfo.meshPoly;i||(h?(tempCollisionPoly.copy(h),tempCollisionPoly.offset(e,t)):tempCollisionPoly.setDefaultPoints(),i=s.InsertPolyMeshVertices(tempCollisionPoly),this._meshInfo.meshPoly=i),s.TransformCollisionPoly(i,l),l.offset(-e,-t),l.transformPrecalc(r,n,a,o)}else h?(l.copy(h),l.transformPrecalc(r,n,a,o)):l.setFromQuad(this.GetBoundingQuad(),-this.GetX(),-this.GetY());t.width=r,t.height=n,t.angle=e}return l}_DiscardTransformedCollisionPoly(){this.SetPhysicsBodyChanged(!0);const e=this._transformedPolyInfo;null!==e&&(e.width=NaN)}CreateMesh(e,t){if(e=Math.floor(e),t=Math.floor(t),!this.GetInstance().GetPlugin().SupportsMesh())throw new Error("object does not support mesh");this.ReleaseMesh(),this._meshInfo={sourceMesh:C33.New(C33.Gfx.Mesh,e,t),transformedMesh:C33.New(C33.Gfx.Mesh,e,t),meshPoly:null}}HasMesh(){return null!==this._meshInfo}GetSourceMesh(){if(this.HasMesh())return this._meshInfo.sourceMesh;throw new Error("no mesh")}GetTransformedMesh(){if(this.HasMesh())return this._meshInfo.transformedMesh;throw new Error("no mesh")}SetMeshChanged(e){this._SetFlag(FLAG_MESH_CHANGED,e)}IsMeshChanged(){return 0!=(this._flags&FLAG_MESH_CHANGED)}SetPhysicsBodyChanged(e){this._SetFlag(FLAG_PHYSICS_BODY_CHANGED,e)}IsPhysicsBodyChanged(){return 0!=(this._flags&FLAG_PHYSICS_BODY_CHANGED)}_ExpandBboxForMesh(e){const t=this._meshInfo.sourceMesh,s=Math.min(t.GetMinX(),0),i=Math.min(t.GetMinY(),0),r=Math.max(t.GetMaxX(),1),n=Math.max(t.GetMaxY(),1),a=e.width(),o=e.height();e.offsetLeft(s*a),e.offsetTop(i*o),e.offsetRight((r-1)*a),e.offsetBottom((n-1)*o),this._depth=t.GetMaxZ()}ReleaseMesh(){this._meshInfo&&(this._meshInfo.sourceMesh.Release(),this._meshInfo.transformedMesh.Release(),this._meshInfo=null,this._DiscardTransformedCollisionPoly())}SetMeshPoint(e,t,s){e=Math.floor(e),t=Math.floor(t);const i=s.mode||"absolute";if(!VALID_SET_MESH_POINT_MODES.has(i))throw new Error("invalid mode");let r="relative"===i,n=s.x,a=s.y,o=s.zElevation,l="number"==typeof s.u?s.u:r?0:-1,h="number"==typeof s.v?s.v:r?0:-1;if(!this.HasMesh())return!1;const c=this.GetSourceMesh(),u=c.GetMeshPointAt(e,t);if(null===u)return!1;let _=!1;return"number"==typeof o&&u.GetZElevation()!==o&&(u.SetZElevation(o),_=!0),r&&(n+=e/(c.GetHSize()-1),a+=t/(c.GetVSize()-1)),l=-1!==l||r?(r&&(l+=e/(c.GetHSize()-1)),C33.clamp(l,0,1)):u.GetU(),h=-1!==h||r?(r&&(h+=t/(c.GetVSize()-1)),C33.clamp(h,0,1)):u.GetV(),u.GetX()===n&&u.GetY()===a&&u.GetU()===l&&u.GetV()===h?_:(u.SetX(n),u.SetY(a),u.SetU(l),u.SetV(h),this._DiscardTransformedCollisionPoly(),!0)}HasTilemap(){return this._inst.HasTilemap()}ContainsPoint(e,t){return!!this.GetBoundingBox().containsPoint(e,t)&&!!this.GetBoundingQuad().containsPoint(e,t)&&(this.HasTilemap()?this._inst.GetSdkInstance().TestPointOverlapTile(e,t):!this.HasOwnCollisionPoly()||this.GetTransformedCollisionPoly().containsPoint(e-this.GetX(),t-this.GetY()))}_IsCollisionCellChanged(){return 0!=(this._flags&FLAG_COLLISION_CELL_CHANGED)}_UpdateCollisionCell(){if(this._IsCollisionCellChanged()&&this.IsCollisionEnabled()&&0==(this._flags&FLAG_DESTROYED)){const e=this.GetBoundingBox(),t=this._objectClass._GetCollisionCellGrid(),s=this._collisionCells;if(tempRect.set(t.XToCell(e.getLeft()),t.YToCell(e.getTop()),t.XToCell(e.getRight()),t.YToCell(e.getBottom())),!s.equals(tempRect)){const i=this._inst;s===DEFAULT_COLLISION_CELLS?(t.Update(i,null,tempRect),this._collisionCells=C33.New(C33.Rect,tempRect)):(t.Update(i,s,tempRect),s.copy(tempRect)),this._flags&=~FLAG_COLLISION_CELL_CHANGED}}}_SetCollisionCellChanged(){this._flags|=FLAG_COLLISION_CELL_CHANGED}_RemoveFromCollisionCells(){const e=this._collisionCells;e!==DEFAULT_COLLISION_CELLS&&(this._objectClass._GetCollisionCellGrid().Update(this._inst,e,null),this._collisionCells=DEFAULT_COLLISION_CELLS)}_UpdateRenderCell(){const e=this.GetLayer();if(e.UsesRenderCells()&&0==(this._flags&FLAG_DESTROYED)){const t=e.GetRenderGrid(),s=this.GetBoundingBox(),i=this._renderCells;if(tempRect.set(t.XToCell(s.getLeft()),t.YToCell(s.getTop()),t.XToCell(s.getRight()),t.YToCell(s.getBottom())),!i.equals(tempRect)){const r=this._inst;i===DEFAULT_RENDER_CELLS?(t.Update(r,null,tempRect),this._renderCells=C33.New(C33.Rect,tempRect)):(t.Update(r,i,tempRect),i.copy(tempRect)),e.SetRenderListStale()}}}_RemoveFromRenderCells(){const e=this._renderCells;e!==DEFAULT_RENDER_CELLS&&(this.GetLayer().GetRenderGrid().Update(this._inst,e,null),this._renderCells=DEFAULT_RENDER_CELLS)}GetRenderCellRange(){return this._renderCells}ZOrderMoveToTop(){const e=this._inst,t=this._layer,s=t._GetInstances();s.length&&s.at(-1)===e||(t._RemoveInstance(e,!1),t._AddInstance(e,!1),this._runtime.UpdateRender())}ZOrderMoveToBottom(){const e=this._inst,t=this._layer,s=t._GetInstances();s.length&&s[0]===e||(t._RemoveInstance(e,!1),t._PrependInstance(e,!1),this._runtime.UpdateRender())}ZOrderMoveToLayer(e){const t=this._inst,s=this._layer;if(s.GetLayout()!==e.GetLayout())throw new Error("layer from different layout");e!==s&&(s._RemoveInstance(t,!0),this._SetLayer(e),e._AddInstance(t,!0),this._runtime.UpdateRender())}ZOrderMoveAdjacentToInstance(e,t){let s=this._inst,i=!1,r=this._layer;if(e.GetUID()!==s.GetUID()){const n=e.GetWorldInfo();if(!n)throw new Error("expected world instance");const a=n.GetLayer(),o=(r.GetIndex()!==a.GetIndex()&&(r._RemoveInstance(s,!0),this._SetLayer(a),a._AddInstance(s,!0),i=!0),a.MoveInstanceAdjacent(s,e,!!t));(i||o)&&this._runtime.UpdateRender()}}GetInstanceEffectList(){return this._instanceEffectList}_SetHasAnyActiveEffect(e){this._SetFlag(FLAG_HAS_ANY_ACTIVE_EFFECT,e)}HasAnyActiveEffect(){return 0!=(this._flags&FLAG_HAS_ANY_ACTIVE_EFFECT)}_SaveToJson(e,t=null){const s={x:this.GetX(),y:this.GetY(),w:this.GetWidth(),h:this.GetHeight(),l:this.GetLayer().GetSID(),zi:this.GetZIndex()},i=(0!==this.GetZElevation()&&(s.ze=this.GetZElevation()),0!==this.GetAngle()&&(s.a=this._GetAngleNoReflect()),this.HasDefaultColor()||(s.c=this._color.toJSON()),.5!==this.GetOriginX()&&(s.oX=this.GetOriginX()),.5!==this.GetOriginY()&&(s.oY=this.GetOriginY()),0!==this.GetBlendMode()&&(s.bm=this.GetBlendMode()),this.IsVisible()||(s.v=this.IsVisible()),this.IsCollisionEnabled()||(s.ce=this.IsCollisionEnabled()),this.IsBboxChangeEventEnabled()&&(s.be=this.IsBboxChangeEventEnabled()),this._instanceEffectList&&(s.fx=this._instanceEffectList._SaveToJson()),0!=(this._flags&FLAG_SOLID_FILTER_INCLUSIVE));return i&&(s.sfi=i),this._solidFilterTags&&(s.sft=[...this._solidFilterTags].join(" ")),this._sceneGraphInfo&&"visual-state"!==e&&(s.sgi=this._sceneGraphInfo._SaveToJson(e,t),sceneGraphExportDataMap.has(this))&&(s.sgcd=sceneGraphExportDataMap.get(this).childrenData,s.sgzid=sceneGraphExportDataMap.get(this).zIndexData),this.HasMesh()&&(s.mesh=this.GetSourceMesh().SaveToJson()),s}_SaveSceneGraphPropertiesToJson(){return{x:this._x,y:this._y,z:this._zElevation,w:this._w,h:this._h,a:this._a,sgi:this._GetSceneGraphInfo()?this._GetSceneGraphInfo()._SaveToJsonProperties():null}}_LoadSceneGraphPropertiesFromJson(e){e&&(this._x=e.x,this._y=e.y,this._zElevation=e.z,this._w=e.w,this._h=e.h,this._a=e.a,e.sgi&&this._GetSceneGraphInfo()&&this._GetSceneGraphInfo()._LoadFromJson(e.sgi),this._MarkSinCosAngleChanged(),this.SetBboxChanged())}_SetupSceneGraphConnectionsOnChangeOfLayout(){this._ReleaseTmpSceneGraphInfo(),this._ResetAllSceneGraphState(),this._CreateSceneGraphInfo(null),this._sceneGraphInfo&&this._sceneGraphInfo._SetTmpSceneGraphChildren(this._tmpSceneGraphChildren,this._tmpSceneGraphChildrenIndexes)}_OnBeforeLoad(e){"visual-state"!==e&&this._ResetAllSceneGraphState()}_OnAfterLoad(e,t="full",s=null){e.hasOwnProperty("sgi")&&"visual-state"!==t&&0==(this._flags&FLAG_DESTROYED)&&this._sceneGraphInfo._OnAfterLoad(e.sgi,s)}_OnAfterLoad2(e,t="full",s){e.hasOwnProperty("sgi")&&"visual-state"!==t&&0==(this._flags&FLAG_DESTROYED)&&(this._sceneGraphInfo._SetTmpSceneGraphChildren(null,null),this._ReleaseTmpSceneGraphInfo(),this.SetBboxChanged())}_LoadFromJson(e,t){if(enableUpdateRendererStateGroup=!1,this.SetX(e.x),this.SetY(e.y),this.SetWidth(e.w),this.SetHeight(e.h),this._SetZIndex(e.zi),this.SetZElevation(e.hasOwnProperty("ze")?e.ze:0),this.SetAngle(e.hasOwnProperty("a")?e.a:0),e.hasOwnProperty("c")?tempColor.setFromJSON(e.c):e.hasOwnProperty("o")?(tempColor.copyRgb(this._color),tempColor.a=e.o):tempColor.setRgba(1,1,1,1),this._SetColor(tempColor),this.SetOriginX(e.hasOwnProperty("oX")?e.oX:.5),this.SetOriginY(e.hasOwnProperty("oY")?e.oY:.5),this.SetBlendMode(e.hasOwnProperty("bm")?e.bm:0),this.SetVisible(!e.hasOwnProperty("v")||e.v),this.SetCollisionEnabled(!e.hasOwnProperty("ce")||e.ce),this.SetBboxChangeEventEnabled(!!e.hasOwnProperty("be")&&e.be),this.SetSolidCollisionFilter(!!e.hasOwnProperty("sfi")&&e.sfi,e.hasOwnProperty("sft")?e.sft:""),this._instanceEffectList&&e.hasOwnProperty("fx")&&this._instanceEffectList._LoadFromJson(e.fx),!e.hasOwnProperty("sgi")&&"visual-state"!==t&&this._tmpSceneGraphChildren)for(const s of this._tmpSceneGraphChildren)s.IsDestroyed()||this._runtime.DestroyInstance(s);if(e.hasOwnProperty("sgi")&&"visual-state"!==t){this._CreateSceneGraphInfo(null);const i=this._sceneGraphInfo,r=e.sgi;i._LoadFromJson(r),i._SetTmpSceneGraphChildren(this._tmpSceneGraphChildren,this._tmpSceneGraphChildrenIndexes),e.sgcd&&C33.IsFiniteNumber(e.sgzid)&&sceneGraphExportDataMap.set(this,{childrenData:e.sgcd,zIndexData:e.sgzid})}if(e.hasOwnProperty("mesh")){const n=e.mesh;this.CreateMesh(n.cols,n.rows),this.GetSourceMesh().LoadFromJson(n)}else this.ReleaseMesh();this.SetBboxChanged(),enableUpdateRendererStateGroup=!0,this._UpdateRendererStateGroup(),"visual-state"!==t&&this._runtime.AddInstanceNeedingAfterLoad(this.GetInstance(),e)}}}{const C33=self.C3;C33.BehaviorType=class extends C33.DefendedBase{constructor(e,t){super();const s=e.GetRuntime(),i=s.GetObjectReference(t[1]),r=(s.GetAddonManager()._DelayCreateBehavior(i),this._runtime=s,this._objectClass=e,this._behavior=C33.AddonManager.GetBehaviorByConstructorFunction(i),this._sdkType=null,this._iBehaviorType=null,this._instSdkCtor=i.Instance,this._sid=t[2],this._name=t[0],this._jsPropName=this._runtime.GetJsPropName(t[3]),this._behavior.GetSdkVersion());if(r<2&&(this._sdkType=C33.New(i.Type,this),!(this._sdkType instanceof C33.SDKBehaviorTypeBase)))throw new Error("v1 sdk type must derive from SDKBehaviorBase");if(C33.AddonManager._PushInitObject(this,r),2<=r){const n=i.Type??globalThis.ISDKBehaviorTypeBase;if(this._iBehaviorType=new n,!(this._iBehaviorType instanceof globalThis.ISDKBehaviorTypeBase))throw new Error("script interface class must derive from ISDKBehaviorTypeBase")}else this._iBehaviorType=new globalThis.IBehaviorType;C33.AddonManager._PopInitObject(r),this.OnCreate()}static Create(e,t){return C33.New(C33.BehaviorType,e,t)}Release(){this._runtime=null,this._behavior=null,this._sdkType&&(this._sdkType.Release(),this._sdkType=null),this._instSdkCtor=null}GetSdkType(){return this._sdkType}OnCreate(){this._sdkType?this._sdkType.OnCreate():this._iBehaviorType&&this._iBehaviorType._onCreate()}GetRuntime(){return this._runtime}GetObjectClass(){return this._objectClass}GetBehavior(){return this._behavior}GetInstanceSdkCtor(){return this._instSdkCtor}GetName(){return this._name}GetSID(){return this._sid}GetIBehaviorType(){return this._iBehaviorType}GetJsPropName(){return this._jsPropName}}}{const C33=self.C3,IBehaviorInstance=self.IBehaviorInstance;C33.BehaviorInstance=class extends C33.DefendedBase{constructor(e){super(),this._runtime=e.runtime,this._behaviorType=e.behaviorType,this._behavior=this._behaviorType.GetBehavior(),this._inst=e.instance,this._index=e.index,this._sdkInst=null,this._iScriptInterface=null,this._behavior._AddInstance(this._inst)}Release(){this._iScriptInterface&&(this._iScriptInterface._release(),this._iScriptInterface=null),this._behavior._RemoveInstance(this._inst),this._sdkInst&&(this._sdkInst.Release(),this._sdkInst=null),this._runtime=null,this._behaviorType=null,this._behavior=null,this._inst=null}_CreateSdkInstance(e){if(this._sdkInst)throw new Error("already got sdk instance");const t=this.GetBehavior().GetSdkVersion();if(t<2){if(this._sdkInst=C33.New(this._behaviorType.GetInstanceSdkCtor(),this,e),!(this._sdkInst instanceof C33.SDKBehaviorInstanceBase))throw new Error("v1 sdk type must derive from SDKBehaviorInstanceBase")}else{const s=this.GetBehavior().GetScriptInterfaceClass();this._InitScriptInterface(s.Instance,e)}}GetSdkInstance(){return this._sdkInst??this._iScriptInterface}GetObjectInstance(){return this._inst}GetRuntime(){return this._runtime}GetBehaviorType(){return this._behaviorType}GetBehavior(){return this._behavior}_GetIndex(){return this._index}PostCreate(){this._sdkInst?this._sdkInst.PostCreate():this._iScriptInterface._postCreate()}OnSpriteFrameChanged(e,t){this._sdkInst&&this._sdkInst.OnSpriteFrameChanged(e,t)}_GetDebuggerProperties(){return this._sdkInst?this._sdkInst.GetDebuggerProperties():this._iScriptInterface._getDebuggerProperties()}SaveToJson(e="full"){return this._sdkInst?this._sdkInst.SaveToJson(e):this._iScriptInterface._saveToJson(e)}LoadFromJson(e,t="full"){if(this._sdkInst)return this._sdkInst.LoadFromJson(e,t);this._iScriptInterface._loadFromJson(e,t)}static SortByTickSequence(e,t,s){let i=globalThis.ISDKBehaviorInstanceBase,r,n;r=t instanceof i?e._UnwrapScriptInterface(t):t.GetBehaviorInstance(),n=s instanceof i?e._UnwrapScriptInterface(s):s.GetBehaviorInstance();const a=r.GetObjectInstance(),o=n.GetObjectInstance(),l=a.GetObjectClass().GetIndex(),h=o.GetObjectClass().GetIndex();if(l!==h)return l-h;const c=a.GetPUID(),u=o.GetPUID();return c!==u?c-u:r._GetIndex()-n._GetIndex()}_InitScriptInterface(e,t){const s=IBehaviorInstance,i=e??this._sdkInst.GetScriptInterfaceClass(),r=i||s,n=this.GetBehavior().GetSdkVersion();if(C33.AddonManager._PushInitObject(this,n),C33.AddonManager._PushInitProperties(t),this._iScriptInterface=new r,C33.AddonManager._PopInitProperties(),C33.AddonManager._PopInitObject(n),!i||this._iScriptInterface instanceof s)return this._iScriptInterface;throw new TypeError(`script interface class '${i.name}' does not extend the right base class '${s.name}'`)}GetScriptInterface(){return this._iScriptInterface||this._InitScriptInterface()}HasScriptInterface(){return!!this._iScriptInterface}}}{const C33=self.C3;C33.EffectList=class extends C33.DefendedBase{constructor(e,t){super(),this._owner=e,this._allEffectTypes=[],this._activeEffectTypes=[],this._effectTypesByName=new Map,this._effectParams=[],this._effectParamBuffers=[],this._allInstanceEffectLists=new Set,this._preservesOpaqueness=!0;for(const s of t){const i=C33.New(C33.EffectType,this,s,this._allEffectTypes.length);this._allEffectTypes.push(i),this._effectTypesByName.set(i.GetName().toLowerCase(),i),3<=s.length&&this._effectParams.push(this._LoadSingleEffectParameters(i,s[2]))}this.GetRuntime()._AddEffectList(this)}Release(){this.GetRuntime()._RemoveEffectList(this);for(const e of this._effectParamBuffers)e.Release();C33.clearArray(this._effectParamBuffers),C33.clearArray(this._allEffectTypes),C33.clearArray(this._activeEffectTypes),this._effectTypesByName.clear(),C33.clearArray(this._effectParams),this._owner=null}_AddInstanceEffectList(e){this._allInstanceEffectLists.add(e)}_RemoveInstanceEffectList(e){this._allInstanceEffectLists.delete(e)}_InitRenderer(e){e.IsWebGPU()&&(this._effectParamBuffers=this._allEffectTypes.map(e=>{const t=e.GetShaderProgram();return 0<t.GetCustomParametersByteSize()?C33.New(C33.Gfx.WebGPUEffectCustomParamsBuffer,t):null}),this._UpdateAllEffectParamBuffers());for(const t of this._allInstanceEffectLists)t._InitRenderer(e)}PrependEffectTypes(e){if(e.length){this._allEffectTypes=e.concat(this._allEffectTypes);for(const t of e)this._effectTypesByName.set(t.GetName().toLowerCase(),t);for(let e=0,t=this._allEffectTypes.length;e<t;++e)this._allEffectTypes[e]._SetIndex(e)}}_LoadSingleEffectParameters(e,t){e.SetActive(t[0]);const s=t.slice(1);for(let e=0,t=s.length;e<t;++e){const i=s[e];if(Array.isArray(i)){const r=C33.New(C33.Color);r.setFromJSON(i),s[e]=r}}return s}GetOwner(){return this._owner}GetRuntime(){return this._owner.GetRuntime()}UpdateActiveEffects(){C33.clearArray(this._activeEffectTypes);let e=!0;for(const t of this._allEffectTypes)t.IsActive()&&(this._activeEffectTypes.push(t),t.GetShaderProgram().PreservesOpaqueness()||(e=!1));this._preservesOpaqueness=e}GetAllEffectTypes(){return this._allEffectTypes}HasAnyEffectType(){return 0<this._allEffectTypes.length}GetEffectTypeByName(e){return this._effectTypesByName.get(e.toLowerCase())||null}GetEffectTypeByIndex(e){if((e=Math.floor(+e))<0||e>=this._allEffectTypes.length)throw new RangeError("invalid effect type index");return this._allEffectTypes[e]}IsEffectIndexActive(e){return this.GetEffectTypeByIndex(e).IsActive()}SetEffectIndexActive(e,t){this.GetEffectTypeByIndex(e).SetActive(t)}GetActiveEffectTypes(){return this._activeEffectTypes}HasAnyActiveEffect(){return 0<this._activeEffectTypes.length}PreservesOpaqueness(){return this._preservesOpaqueness}GetEffectParametersForIndex(e){return this._effectParams[e]}_GetEffectChainShaderParametersForIndex(e){return(e<this._effectParamBuffers.length?this._effectParamBuffers:this._effectParams)[e]}GetEffectParameter(e,t){if(e<0||e>=this._effectParams.length)return null;const s=this._effectParams[e];return t<0||t>=s.length?null:s[t]}SetEffectParameter(e,t,s){if(e<0||e>=this._effectParams.length)return!1;const i=this._effectParams[e];if(t<0||t>=i.length)return!1;const r=i[t];if(r instanceof C33.Color){if(r.equalsIgnoringAlpha(s))return!1;r.copyRgb(s)}else{if(r===s)return!1;i[t]=s}return e<this._effectParamBuffers.length&&this._effectParamBuffers[e].SetParameterValue(t,s),!0}_UpdateAllEffectParamBuffers(){const s=this._effectParams,i=this._effectParamBuffers;for(let e=0,t=Math.min(s.length,i.length);e<t;++e){const r=i[e],n=s[e];for(let e=0,t=n.length;e<t;++e)r.SetParameterValue(e,n[e])}}static SaveFxParamToJson(e){return e&&e instanceof C33.Color?{t:"color",v:e.toJSON()}:e}static LoadFxParamFromJson(e){if(null===e)return NaN;if("object"!=typeof e)return e;{const t=e.t;if("color"!==t)throw new Error("invalid effect parameter type");{const s=C33.New(C33.Color);return s.setFromJSON(e.v),s}}}static SaveFxParamsToJson(e){return e.map(C33.EffectList.SaveFxParamToJson)}static LoadFxParamsFromJson(e){return e.map(C33.EffectList.LoadFxParamFromJson)}SaveToJson(){return this._allEffectTypes.map(e=>({name:e.GetName(),active:e.IsActive(),params:C33.EffectList.SaveFxParamsToJson(this._effectParams[e.GetIndex()])}))}LoadFromJson(e){for(const t of e){const s=this.GetEffectTypeByName(t.name);s&&(s.SetActive(t.active),this._effectParams[s.GetIndex()]=C33.EffectList.LoadFxParamsFromJson(t.params))}this.UpdateActiveEffects(),this._UpdateAllEffectParamBuffers()}}}{const C33=self.C3;C33.EffectType=class extends C33.DefendedBase{constructor(e,t,s){super(),this._effectList=e,this._id=t[0],this._name=t[1],this._index=s,this._shaderProgram=null,this._isActive=!0}Release(){this._effectList=null,this._shaderProgram=null}Clone(e){const t=C33.New(C33.EffectType,e,[this._id,this._name],-1);return t._shaderProgram=this._shaderProgram,t._isActive=this._isActive,t}_InitRenderer(e){const t=e.GetShaderProgramByName(this._id);if(!t)throw new Error("failed to find shader program '"+this._id+"'");this._shaderProgram=t}GetEffectList(){return this._effectList}GetName(){return this._name}_SetIndex(e){this._index=e}GetIndex(){return this._index}GetOwner(){return this._effectList.GetOwner()}GetRuntime(){return this._effectList.GetRuntime()}SetActive(e){this._isActive=!!e}IsActive(){return this._isActive}GetShaderProgram(){return this._shaderProgram}GetDefaultParameterValues(){const s=[];for(let e=0,t=this._shaderProgram.GetParameterCount();e<t;++e){const i=this._shaderProgram.GetParameterType(e);if("float"===i||"percent"===i)s.push(0);else{if("color"!==i)throw new TypeError("unknown effect parameter type");s.push(C33.New(C33.Color,1,1,1,1))}}return s}}}{const C33=self.C3;C33.InstanceEffectList=class extends C33.DefendedBase{constructor(e,t){super(),this._inst=e,this._wi=t,this._effectList=e.GetObjectClass().GetEffectList(),this._needsRebuildSteps=!0,this._wasDefaultColor=!0,this._was3D=!1,this._wasRotatedOrNegativeSize=!1,this._wasTexRotated=!1,this._wasMustPreDraw=!1,this._effectChain=C33.New(C33.Gfx.EffectChain,e.GetRuntime().GetCanvasManager().GetEffectChainManager(),{drawContent:(e,t)=>{const s=t.GetContentObject(),i=s.GetWorldInfo();e.SetColor(i.GetPremultipliedColor()),e.SetCurrentZ(i.GetTotalZElevation()),s.Draw(e),e.SetCurrentZ(0)},getSourceTextureInfo:e=>{const t=e.GetCurrentTexRect(),[s,i]=e.GetCurrentSurfaceSize();return{srcTexRect:t,srcWidth:s,srcHeight:i}},getShaderParameters:e=>this._GetEffectChainShaderParametersForIndex(e)}),this._activeEffectFlags=[],this._activeEffectTypes=[],this._preservesOpaqueness=!0,this._effectParams=[],this._effectParamBuffers=[],this._InitRenderer(e.GetRuntime().GetRenderer());for(let e=0,t=this._effectList.GetAllEffectTypes().length;e<t;++e)this._activeEffectFlags.push(!0);this.UpdateActiveEffects(),this._effectList._AddInstanceEffectList(this)}Release(){this._effectList._RemoveInstanceEffectList(this);for(const e of this._effectParamBuffers)e&&e.Release();C33.clearArray(this._effectParamBuffers),this._effectChain.Release(),this._effectChain=null,C33.clearArray(this._activeEffectFlags),C33.clearArray(this._activeEffectTypes),C33.clearArray(this._effectParams),this._inst=null,this._effectList=null}_InitRenderer(e){e.IsWebGPU()&&(this._effectParamBuffers=this._effectList.GetAllEffectTypes().map(e=>{const t=e.GetShaderProgram();return 0<t.GetCustomParametersByteSize()?C33.New(C33.Gfx.WebGPUEffectCustomParamsBuffer,t):null}))}_LoadEffectParameters(e){let t=0;for(const s of e)this._effectParams.push(this._LoadSingleEffectParameters(t,s)),++t;this._UpdateAllEffectParamBuffers(),this.UpdateActiveEffects()}_LoadSingleEffectParameters(e,t){this._activeEffectFlags[e]=t[0];const s=t.slice(1);for(let e=0,t=s.length;e<t;++e){const i=s[e];if(Array.isArray(i)){const r=C33.New(C33.Color);r.setFromJSON(i),s[e]=r}}return s}LoadDefaultEffectParameters(){for(const e of this._effectList.GetAllEffectTypes())this._effectParams.push(e.GetDefaultParameterValues());this._UpdateAllEffectParamBuffers()}GetOwner(){return this._owner}GetEffectList(){return this._effectList}GetEffectChain(){return this._MaybeRebuildEffectChainSteps(),this._effectChain}GetRuntime(){return this._inst.GetRuntime()}UpdateActiveEffects(){C33.clearArray(this._activeEffectTypes);let e=this._wi,s=this._effectList.GetAllEffectTypes(),i=this._activeEffectTypes,r=this._activeEffectFlags,n=!0;for(let e=0,t=s.length;e<t;++e)if(r[e]){const a=s[e];i.push(a),a.GetShaderProgram().PreservesOpaqueness()||(n=!1)}this._preservesOpaqueness=n,e._SetHasAnyActiveEffect(!!i.length),this._needsRebuildSteps=!0}_MaybeRebuildEffectChainSteps(){const e=this._inst,t=this._wi,s=t.HasDefaultColor(),i=e.GetPlugin().Is3D(),r=0!==t.GetAngle()||0!==t.GetLayer().GetAngle()||t.GetWidth()<0||t.GetHeight()<0,n=e.IsCurrentTexRotated(),a=e.MustPreDraw();(this._needsRebuildSteps||s!==this._wasDefaultColor||i!==this._was3D||r!==this._wasRotatedOrNegativeSize||n!==this._wasTexRotated||a!==this._wasMustPreDraw||this._effectChain.NeedsRebuild())&&(this._effectChain.BuildSteps(this._activeEffectTypes.map(e=>e.GetShaderProgram()),{indexMap:this._activeEffectTypes.map(e=>e.GetIndex()),forcePreDraw:!s||a,is3D:i,isSourceTextureRotated:n,isRotatedOrNegativeSizeInstance:r}),this._needsRebuildSteps=!1,this._wasDefaultColor=s,this._was3D=i,this._wasRotatedOrNegativeSize=r,this._wasTexRotated=n,this._wasMustPreDraw=a)}GetActiveEffectTypes(){return this._activeEffectTypes}GetEffectParametersForIndex(e){return this._effectParams[e]}_GetEffectChainShaderParametersForIndex(e){return(e<this._effectParamBuffers.length?this._effectParamBuffers:this._effectParams)[e]}GetEffectParameter(e,t){if(e<0||e>=this._effectParams.length)return null;const s=this._effectParams[e];return t<0||t>=s.length?null:s[t]}SetEffectParameter(e,t,s){if(e<0||e>=this._effectParams.length)return!1;const i=this._effectParams[e];if(t<0||t>=i.length)return!1;const r=i[t];if(r instanceof C33.Color){if(r.equalsIgnoringAlpha(s))return!1;r.copyRgb(s)}else{if(r===s)return!1;i[t]=s}return e<this._effectParamBuffers.length&&this._effectParamBuffers[e].SetParameterValue(t,s),!0}_UpdateAllEffectParamBuffers(){const s=this._effectParams,i=this._effectParamBuffers;for(let e=0,t=i.length;e<t;++e){const r=i[e],n=s[e];for(let e=0,t=n.length;e<t;++e)r.SetParameterValue(e,n[e])}}PreservesOpaqueness(){return this._preservesOpaqueness}HasAnyActiveBackgroundBlendingEffect(){return this._activeEffectTypes.some(e=>e.GetShaderProgram().BlendsBackground())}IsEffectIndexActive(e){return this._activeEffectFlags[e]}SetEffectIndexActive(e,t){this._activeEffectFlags[e]=!!t}GetAllEffectTypes(){return this._effectList.GetAllEffectTypes()}_SaveToJson(){return this._effectList.GetAllEffectTypes().map(e=>({name:e.GetName(),active:this._activeEffectFlags[e.GetIndex()],params:C33.EffectList.SaveFxParamsToJson(this._effectParams[e.GetIndex()])}))}_LoadFromJson(e){for(const t of e){const s=this._effectList.GetEffectTypeByName(t.name);s&&(this._activeEffectFlags[s.GetIndex()]=t.active,this._effectParams[s.GetIndex()]=C33.EffectList.LoadFxParamsFromJson(t.params))}this.UpdateActiveEffects(),this._UpdateAllEffectParamBuffers()}}}{let C33=self.C3,tempCandidates=[],tileCollRectCandidates=[],tempJumpthruRet=[],tempPolyA=C33.New(C33.CollisionPoly),tempPolyB=C33.New(C33.CollisionPoly),tempQuad=C33.New(C33.Quad),tempRect=C33.New(C33.Rect),tempRect2=C33.New(C33.Rect),tempPolyC=null,tempRect3=null,tempQuadB=null;C33.CollisionEngine=class extends C33.DefendedBase{constructor(e){super(),this._runtime=e,this._collisionCellWidth=0,this._collisionCellHeight=0,this._registeredCollisions=[],this._collisionCheckCount=0,this._collisionCheckSec=0,this._polyCheckCount=0,this._polyCheckSec=0,this._iCollisionEngine=new self.ICollisionEngine(this)}Release(){this._runtime=null}GetRuntime(){return this._runtime}GetICollisionEngine(){return this._iCollisionEngine}_Update1sStats(){this._collisionCheckSec=this._collisionCheckCount,this._collisionCheckCount=0,this._polyCheckSec=this._polyCheckCount,this._polyCheckCount=0}Get1secCollisionChecks(){return this._collisionCheckSec}Get1secPolyChecks(){return this._polyCheckSec}RegisterCollision(e,t){const s=e.GetWorldInfo(),i=t.GetWorldInfo();s&&i&&s.IsCollisionEnabled()&&i.IsCollisionEnabled()&&this._registeredCollisions.push([e,t])}AddRegisteredCollisionCandidates(t,s,i){for(const[r,n]of this._registeredCollisions){let e=null;if(t===r)e=n;else{if(t!==n)continue;e=r}e.BelongsToObjectClass(s)&&!i.includes(e)&&i.push(e)}}CheckRegisteredCollision(e,t){if(this._registeredCollisions.length)for(const[s,i]of this._registeredCollisions)if(e===s&&t===i||e===i&&t===s)return!0;return!1}ClearRegisteredCollisions(){C33.clearArray(this._registeredCollisions)}TestOverlap(e,t){if(!e||!t||e===t)return!1;const s=e.GetWorldInfo(),i=t.GetWorldInfo();if(!s.IsCollisionEnabled()||!i.IsCollisionEnabled())return!1;this._collisionCheckCount++;const r=s.GetLayer(),n=i.GetLayer(),a=r.IsTransformCompatibleWith(n);return a?this._TestOverlap_SameLayers(s,i):this._TestOverlap_DifferentLayers(s,i)}_TestOverlap_SameLayers(e,t){if(!e.GetBoundingBox().intersectsRect(t.GetBoundingBox()))return!1;if(this._polyCheckCount++,!e.GetBoundingQuad().intersectsQuad(t.GetBoundingQuad()))return!1;if(e.HasTilemap()&&t.HasTilemap())return!1;if(e.HasTilemap())return this.TestTilemapOverlap(e,t);if(t.HasTilemap())return this.TestTilemapOverlap(t,e);if(!e.HasOwnCollisionPoly()&&!t.HasOwnCollisionPoly())return!0;const s=e.GetTransformedCollisionPoly(),i=t.GetTransformedCollisionPoly();return s.intersectsPoly(i,t.GetX()-e.GetX(),t.GetY()-e.GetY())}_TestOverlap_DifferentLayers(s,i){const e=s.HasTilemap(),t=i.HasTilemap();if(e&&!t)return this.TestTilemapOverlapDifferentLayers(s,i);if(t&&!e)return this.TestTilemapOverlapDifferentLayers(i,s);if(t||e)return!1;{const r=s.GetLayer(),n=i.GetLayer(),a=(tempPolyA.copy(s.GetTransformedCollisionPoly()),tempPolyB.copy(i.GetTransformedCollisionPoly()),tempPolyA.pointsArr());for(let e=0,t=a.length;e<t;e+=2){const l=e+1,h=a[e],c=a[l],[u,_]=r.LayerToCanvasCss(h+s.GetX(),c+s.GetY());a[e]=u,a[l]=_}const o=tempPolyB.pointsArr();for(let e=0,t=o.length;e<t;e+=2){const d=e+1,p=o[e],m=o[d],[g,f]=n.LayerToCanvasCss(p+i.GetX(),m+i.GetY());o[e]=g,o[d]=f}return tempPolyA.setBboxChanged(),tempPolyB.setBboxChanged(),this._polyCheckCount++,tempPolyA.intersectsPoly(tempPolyB,0,0)}}TestTilemapOverlapDifferentLayers(e,t){const s=e.GetLayer(),i=t.GetLayer(),r=(tempPolyC=tempPolyC||C33.New(C33.CollisionPoly),tempRect3=tempRect3||C33.New(C33.Rect),tempQuadB=tempQuadB||C33.New(C33.Quad),t.GetX()),n=t.GetY(),[a,o]=i.LayerToCanvasCss(r,n),[l,h]=s.CanvasCssToLayer(a,o),c=l-r,u=h-n;if(tempRect3.copy(t.GetBoundingBox()),tempRect3.offset(c,u),!e.GetBoundingBox().intersectsRect(tempRect3))return!1;if(tempQuadB.copy(t.GetBoundingQuad()),tempQuadB.offset(c,u),this._polyCheckCount++,!e.GetBoundingQuad().intersectsQuad(tempQuadB))return!1;tempPolyC.copy(t.GetTransformedCollisionPoly());const _=tempPolyC.pointsArr();for(let e=0,t=_.length;e<t;e+=2){const d=e+1;_[e]+=c,_[d]+=u}return tempPolyC.setBboxChanged(),this.TestTilemapOverlap(e,t,l,h,tempPolyC,tempRect3,tempQuadB)}TestTilemapOverlap(e,i,t,s,r,n,a){const o=void 0!==n?n:i.GetBoundingBox(),l=e.GetX(),h=e.GetY(),c=e.GetInstance().GetSdkInstance(),u=void 0!==t?t:i.GetX(),_=void 0!==s?s:i.GetY(),d=i.HasOwnCollisionPoly(),p=void 0!==a?a:i.GetBoundingQuad(),m=tileCollRectCandidates;c.GetCollisionRectCandidates(o,m);for(let e=0,t=m.length;e<t;++e){const g=m[e],f=g.GetRect();if(this._collisionCheckCount++,o.intersectsRectOffset(f,l,h)&&(tempQuad.setFromRect(f),tempQuad.offset(l,h),tempQuad.intersectsQuad(p)))if(d){let e=void 0!==r?r:i.GetTransformedCollisionPoly(),t=u,s=_;void 0!==r&&(t=i.GetX(),s=i.GetY());const S=g.GetPoly();if(S){if(this._polyCheckCount++,S.intersectsPoly(e,t-(l+f.getLeft()),s-(h+f.getTop())))return C33.clearArray(m),!0}else if(tempPolyA.setFromQuad(tempQuad,0,0),tempPolyA.intersectsPoly(e,t,s))return C33.clearArray(m),!0}else{const C=g.GetPoly();if(!C)return C33.clearArray(m),!0;if(tempPolyA.setFromQuad(p,0,0),C.intersectsPoly(tempPolyA,-(l+f.getLeft()),-(h+f.getTop())))return C33.clearArray(m),!0}}return C33.clearArray(m),!1}TestAndSelectCanvasPointOverlap(e,o,l){const h=e.GetCurrentSol(),t=this._runtime.GetCurrentEvent();if(!t)throw new Error("cannot call outside event");const c=t.IsOrBlock(),s=new Map,u=e=>{let t=s.get(e);return void 0===t&&(t=e.IsSelfAndParentsInteractive(),s.set(e,t)),t};if(h.IsSelectAll()){l||(h._SetSelectAll(!1),C33.clearArray(h._GetOwnInstances())),c&&C33.clearArray(h._GetOwnElseInstances());for(const i of e.GetInstances()){let r=i.GetWorldInfo(),n=r.GetLayer();if(!(!u(n)||!r.IsInViewport2())&&o.some(([e,t])=>{const[s,i]=n.CanvasCssToLayer(e,t,r.GetTotalZElevation());return r.ContainsPoint(s,i)})){if(l)return!1;h._PushInstance(i)}else c&&h._PushElseInstance(i)}}else{let s,i=!1,a=(!c||t.IsFirstConditionOfType(this._runtime.GetCurrentCondition())||this._runtime.IsCurrentConditionFirst()&&!h._GetOwnElseInstances().length&&h._GetOwnInstances().length?s=h._GetOwnInstances():(s=h._GetOwnElseInstances(),i=!0),0);for(let t=0,e=s.length;t<e;++t){let e=s[t],r=e.GetWorldInfo(),n=r.GetLayer();if(!(!u(n)||!r.IsInViewport2())&&o.some(([e,t])=>{const[s,i]=n.CanvasCssToLayer(e,t,r.GetTotalZElevation());return r.ContainsPoint(s,i)})){if(l)return!1;i?h._PushInstance(e):s[a++]=e}else i?s[a++]=e:c&&h._PushElseInstance(e)}l||(s.length=a)}return e.ApplySolToContainer(),s.clear(),!!l||h.HasAnyInstances()}_ObjectClassCanUseCollisionCells(e,t){if(e)for(const s of t.layersHasInstancesOn())if(!e.IsTransformCompatibleWith(s))return!1;return!0}GetCollisionCandidates(e,t,s,i){if(t.IsFamily())for(const r of t.GetFamilyMembers())this._ObjectClassCanUseCollisionCells(e,r)?(r._UpdateAllCollisionCells(),r._GetCollisionCellGrid().QueryRange(s,i)):C33.appendArray(i,r.GetInstances());else this._ObjectClassCanUseCollisionCells(e,t)?(t._UpdateAllCollisionCells(),t._GetCollisionCellGrid().QueryRange(s,i)):C33.appendArray(i,t.GetInstances())}GetObjectClassesCollisionCandidates(e,t,s,i){for(const r of t)this.GetCollisionCandidates(e,r,s,i)}GetSolidCollisionCandidates(e,t,s){const i=this._runtime.GetSolidBehavior();i&&this.GetObjectClassesCollisionCandidates(e,i.GetObjectClasses(),t,s)}GetJumpthruCollisionCandidates(e,t,s){const i=this._runtime.GetJumpthruBehavior();i&&this.GetObjectClassesCollisionCandidates(e,i.GetObjectClasses(),t,s)}IsSolidCollisionAllowed(e,t){return e._IsSolidEnabled()&&(!t||t.GetWorldInfo().IsSolidCollisionAllowed(e.GetSavedDataMap().get("solidTags")))}TestOverlapSolid(e){const t=e.GetWorldInfo();this.GetSolidCollisionCandidates(t.GetLayer(),t.GetBoundingBox(),tempCandidates);for(const s of tempCandidates)if(this.IsSolidCollisionAllowed(s,e)&&this.TestOverlap(e,s))return C33.clearArray(tempCandidates),s;return C33.clearArray(tempCandidates),null}TestRectOverlapSolid(e,t){this.GetSolidCollisionCandidates(null,e,tempCandidates);for(const s of tempCandidates)if(this.IsSolidCollisionAllowed(s,t)&&this.TestRectOverlap(e,s))return C33.clearArray(tempCandidates),s;return C33.clearArray(tempCandidates),null}TestOverlapJumpthru(e,t){let s=null;t&&(s=tempJumpthruRet,C33.clearArray(s));const i=e.GetWorldInfo();this.GetJumpthruCollisionCandidates(i.GetLayer(),i.GetBoundingBox(),tempCandidates);for(const r of tempCandidates)if(r._IsJumpthruEnabled()&&this.TestOverlap(e,r)){if(!t)return C33.clearArray(tempCandidates),r;s.push(r)}return C33.clearArray(tempCandidates),s}PushOut(t,s,i,r,n){r=r||50;const a=t.GetWorldInfo(),o=a.GetX(),l=a.GetY();for(let e=0;e<r;++e)if(a.SetXY(o+s*e,l+i*e),a.SetBboxChanged(),!this.TestOverlap(t,n))return!0;return a.SetXY(o,l),a.SetBboxChanged(),!1}PushOutSolid(t,s,i,r,n,a){r=r||50;let o=t.GetWorldInfo(),l=o.GetX(),h=o.GetY(),c=null,u=null;for(let e=0;e<r;++e)if(o.SetXY(l+s*e,h+i*e),o.SetBboxChanged(),!this.TestOverlap(t,c))if(c=this.TestOverlapSolid(t))u=c;else if(n&&(c=a?this.TestOverlap(t,a)?a:null:this.TestOverlapJumpthru(t))&&(u=c),!c)return u&&this.PushInFractional(t,s,i,u,16,!0),!0;return o.SetXY(l,h),o.SetBboxChanged(),!1}PushOutSolidAxis(s,i,r,e){e=e||50;let n=s.GetWorldInfo(),a=n.GetX(),o=n.GetY(),l=null,h=null;for(let t=0;t<e;++t)for(let e=0;e<2;++e){const c=2*e-1;if(n.SetXY(a+i*t*c,o+r*t*c),n.SetBboxChanged(),!this.TestOverlap(s,l)){if(!(l=this.TestOverlapSolid(s)))return h&&this.PushInFractional(s,i*c,r*c,h,16,!0),!0;h=l}}return n.SetXY(a,o),n.SetBboxChanged(),!1}PushInFractional(e,t,s,i,r,n){let a=2,o=!1,l=!1,h=e.GetWorldInfo(),c=h.GetX(),u=h.GetY();for(;a<=r;){const _=1/a;a*=2,h.OffsetXY(t*_*(o?1:-1),s*_*(o?1:-1)),h.SetBboxChanged(),this.TestOverlap(e,i)||n&&this.TestOverlapSolid(e)?(o=!0,l=!0):(o=!1,l=!1,c=h.GetX(),u=h.GetY())}l&&(h.SetXY(c,u),h.SetBboxChanged())}PushOutSolidNearest(s,e=100){let i=0,r=s.GetWorldInfo(),n=r.GetX(),a=r.GetY(),o=0,l=this.TestOverlapSolid(s);if(!l)return!0;for(;i<=e;){let e=0,t=0;switch(o){case 0:e=0,t=-1,i++;break;case 1:e=1,t=-1;break;case 2:e=1,t=0;break;case 3:e=1,t=1;break;case 4:e=0,t=1;break;case 5:e=-1,t=1;break;case 6:e=-1,t=0;break;case 7:e=-1,t=-1}if(o=(o+1)%8,r.SetXY(Math.floor(n+e*i),Math.floor(a+t*i)),r.SetBboxChanged(),!this.TestOverlap(s,l)&&!(l=this.TestOverlapSolid(s)))return!0}return r.SetXY(n,a),r.SetBboxChanged(),!1}CalculateBounceAngle(e,t,s,i){const r=e.GetWorldInfo(),n=r.GetX(),a=r.GetY(),o=Math.max(10,C33.distanceTo(t,s,n,a)),l=C33.angleTo(t,s,n,a),h=i||this.TestOverlapSolid(e);if(!h)return C33.clampAngle(l+Math.PI);let c=h,u=0,_=0,d=C33.toRadians(5),p;for(p=1;p<36;++p){const b=l-p*d;if(r.SetXY(t+Math.cos(b)*o,s+Math.sin(b)*o),r.SetBboxChanged(),!this.TestOverlap(e,c)&&!(c=i?null:this.TestOverlapSolid(e))){u=b;break}}for(36===p&&(u=C33.clampAngle(l+Math.PI)),c=h,p=1;p<36;++p){const A=l+p*d;if(r.SetXY(t+Math.cos(A)*o,s+Math.sin(A)*o),r.SetBboxChanged(),!this.TestOverlap(e,c)&&!(c=i?null:this.TestOverlapSolid(e))){_=A;break}}if(36===p&&(_=C33.clampAngle(l+Math.PI)),r.SetXY(n,a),r.SetBboxChanged(),_===u)return _;let m=C33.angleDiff(_,u)/2,g;g=C33.angleClockwise(_,u)?C33.clampAngle(u+m+Math.PI):C33.clampAngle(_+m);const f=Math.cos(l),S=Math.sin(l),C=Math.cos(g),y=Math.sin(g),G=f*C+S*y,I=f-2*G*C,T=S-2*G*y;return C33.angleTo(0,0,I,T)}TestSegmentOverlap(e,t,s,i,r){if(!r)return!1;const n=r.GetWorldInfo();if(!n.IsCollisionEnabled())return!1;if(this._collisionCheckCount++,tempRect.set(Math.min(e,s),Math.min(t,i),Math.max(e,s),Math.max(t,i)),!n.GetBoundingBox().intersectsRect(tempRect))return!1;if(r.HasTilemap())return this._TestSegmentOverlapTilemap(e,t,s,i,r,n);if(this._polyCheckCount++,!n.GetBoundingQuad().intersectsSegment(e,t,s,i))return!1;if(!n.HasOwnCollisionPoly())return!0;const a=n.GetTransformedCollisionPoly();return a.intersectsSegment(n.GetX(),n.GetY(),e,t,s,i)}_TestSegmentOverlapTilemap(s,i,r,n,e,t){const a=t.GetX(),o=t.GetY(),l=e.GetSdkInstance(),h=tileCollRectCandidates;tempRect2.set(s,i,r,n),tempRect2.normalize(),l.GetCollisionRectCandidates(tempRect2,h);for(let e=0,t=h.length;e<t;++e){const c=h[e],u=c.GetRect();if(this._collisionCheckCount++,tempRect.intersectsRectOffset(u,a,o)&&(tempQuad.setFromRect(u),tempQuad.offset(a,o),tempQuad.intersectsSegment(s,i,r,n))){const _=c.GetPoly();if(!_)return C33.clearArray(h),!0;if(this._polyCheckCount++,_.intersectsSegment(a+u.getLeft(),o+u.getTop(),s,i,r,n))return C33.clearArray(h),!0}}return C33.clearArray(h),!1}TestRectOverlap(e,t){if(!t)return!1;const s=t.GetWorldInfo();if(!s.IsCollisionEnabled())return!1;if(this._collisionCheckCount++,!s.GetBoundingBox().intersectsRect(e))return!1;if(t.HasTilemap())return this._TestRectOverlapTilemap(e,t,s);if(this._polyCheckCount++,tempQuad.setFromRect(e),!s.GetBoundingQuad().intersectsQuad(tempQuad))return!1;if(!s.HasOwnCollisionPoly())return!0;const i=tempPolyA,r=(i.setFromRect(e,s.GetX(),s.GetY()),s.GetTransformedCollisionPoly());return i.intersectsPoly(r,0,0)}_TestRectOverlapTilemap(s,e,t){const i=t.GetX(),r=t.GetY(),n=e.GetSdkInstance(),a=tileCollRectCandidates;n.GetCollisionRectCandidates(s,a);for(let e=0,t=a.length;e<t;++e){const o=a[e],l=o.GetRect();if(this._collisionCheckCount++,s.intersectsRectOffset(l,i,r)){const h=o.GetPoly();if(!h)return C33.clearArray(a),!0;if(this._polyCheckCount++,tempPolyA.setFromRect(s,0,0),h.intersectsPoly(tempPolyA,-(i+l.getLeft()),-(r+l.getTop())))return C33.clearArray(a),!0}}return C33.clearArray(a),!1}TestRayIntersectsInstance(e,t){if(e){const s=e.GetWorldInfo();s.IsCollisionEnabled()&&(this._collisionCheckCount++,s.GetBoundingBox().intersectsRect(t.rect))&&(e.HasTilemap()?this._TestRayIntersectsTilemap(e,s,t):(this._polyCheckCount++,s.HasOwnCollisionPoly()?t.TestInstancePoly(e,s.GetX(),s.GetY(),s.GetTransformedCollisionPoly()):t.TestInstanceQuad(e,s.GetBoundingQuad())))}}_TestRayIntersectsTilemap(s,i,r){const n=i.GetX(),a=i.GetY(),o=tileCollRectCandidates;s.GetSdkInstance().GetCollisionRectCandidates(r.rect,o);for(let e=0,t=o.length;e<t;e++){const l=o[e],h=l.GetRect();if(this._collisionCheckCount++,r.rect.intersectsRectOffset(h,n,a)){const c=l.GetPoly();this._polyCheckCount++,c?r.TestInstancePoly(s,n+h.getLeft(),a+h.getTop(),c):r.TestInstanceRect(s,i.GetX(),i.GetY(),h)}}C33.clearArray(o)}SetCollisionCellSize(e,t){if(e!==this._collisionCellWidth||t!==this._collisionCellHeight){this._collisionCellWidth=e,this._collisionCellHeight=t;const s=this._runtime.GetAllObjectClasses();for(const i of s)if(i.IsWorldType()){for(const r of i.instancesIncludingPendingCreate())r.GetWorldInfo()._RemoveFromCollisionCells();i._GetCollisionCellGrid().SetCellSize(e,t),i._SetAnyCollisionCellChanged();for(const n of i.instancesIncludingPendingCreate()){const a=n.GetWorldInfo();a._SetCollisionCellChanged(),a._UpdateCollisionCell()}}}}GetCollisionCellSize(){return[this._collisionCellWidth,this._collisionCellHeight]}_InitCollisionCellSize(e,t){this._collisionCellWidth=e,this._collisionCellHeight=t}}}{const C33=self.C3;C33.SparseGrid=class extends C33.DefendedBase{constructor(e,t){super(),this._cellWidth=e,this._cellHeight=t,this._cells=C33.New(C33.PairMap)}Release(){this._cells.Release(),this._cells=null}SetCellSize(e,t){if(!this._cells.IsEmpty())throw new Error("grid not empty");this._cellWidth=e,this._cellHeight=t}GetCell(e,t,s){let i=this._cells.Get(e,t);return i||(s?(i=C33.New(C33.GridCell,this,e,t),this._cells.Set(e,t,i),i):null)}XToCell(e){const t=Math.floor(e/this._cellWidth);return isFinite(t)?t:0}YToCell(e){const t=Math.floor(e/this._cellHeight);return isFinite(t)?t:0}Update(i,r,n){if(r)for(let s=r.getLeft(),e=r.getRight();s<=e;++s)for(let e=r.getTop(),t=r.getBottom();e<=t;++e)if(!n||!n.containsPoint(s,e)){const a=this.GetCell(s,e,!1);a&&(a.Remove(i),a.IsEmpty())&&this._cells.Delete(s,e)}if(n)for(let s=n.getLeft(),e=n.getRight();s<=e;++s)for(let e=n.getTop(),t=n.getBottom();e<=t;++e)r&&r.containsPoint(s,e)||this.GetCell(s,e,!0).Insert(i)}QueryRange(e,t){let s=this.XToCell(e.getLeft()),i=this.YToCell(e.getTop()),r=this.XToCell(e.getRight()),n=this.YToCell(e.getBottom());if(isFinite(r)&&isFinite(n))for(;s<=r;++s)for(let e=i;e<=n;++e){const a=this.GetCell(s,e,!1);a&&a.Dump(t)}}}}{const C33=self.C3;C33.GridCell=class extends C33.DefendedBase{constructor(e,t,s){super(),this._grid=e,this._x=t,this._y=s,this._instances=C33.New(C33.ArraySet)}Release(){this._instances.Release(),this._instances=null,this._grid=null}IsEmpty(){return this._instances.IsEmpty()}Insert(e){this._instances.Add(e)}Remove(e){this._instances.Delete(e)}Dump(e){C33.appendArray(e,this._instances.GetArray())}}}{const C33=self.C3,PADDING=1e-6,NO_HIT=2;C33.Ray=class{constructor(){this.x1=0,this.y1=0,this.x2=0,this.y2=0,this.dx=0,this.dy=0,this.rect=new C33.Rect,this.hitFraction=NO_HIT,this.hitUid=null,this.hitNormal=0,this.hitNormalDx=0,this.hitNormalDy=0,this.hitX=0,this.hitY=0,this.distance=0,this.normalX=1,this.normalY=0,this.reflectionX=1,this.reflectionY=0}DidCollide(){return this.hitFraction<1+PADDING}Reset(){this.hitFraction=NO_HIT}Set(e,t,s,i){return this.x1=e,this.y1=t,this.x2=s,this.y2=i,this.dx=s-e,this.dy=i-t,this.rect.set(e,t,s,i),this.rect.normalize(),this.hitFraction=NO_HIT,this.hitUid=null,this.hitNormal=0,this.hitNormalDx=0,this.hitNormalDy=0,this.hitX=0,this.hitY=0,this.distance=0,this.normalX=1,this.normalY=0,this.reflectionX=1,this.reflectionY=0,this}Complete(){if(!1!==this.DidCollide()){const e=this.dx*this.hitFraction,t=this.dy*this.hitFraction,s=C33.hypot2DFast(e,t),i=e/s,r=t/s,n=(this.distance=s-PADDING,this.hitX=this.x1+i*this.distance,this.hitY=this.y1+r*this.distance,this.hitNormal=Math.atan2(this.hitNormalDy,this.hitNormalDx)+Math.PI/2,this.normalX=Math.cos(this.hitNormal),this.normalY=Math.sin(this.hitNormal),i*this.normalX+r*this.normalY);if(this.reflectionX=i-2*this.normalX*n,this.reflectionY=r-2*this.normalY*n,0<n){const a=Math.PI;this.hitNormal=C33.clampAngle(this.hitNormal+a),this.normalX=-this.normalX,this.normalY=-this.normalY}}}TestInstanceSegment(e,t,s,i,r){const n=C33.rayIntersect(this.x1,this.y1,this.x2,this.y2,t,s,i,r);0<=n&&n<this.hitFraction&&(this.hitFraction=n,this.hitUid=e.GetUID(),this.hitNormalDx=t-i,this.hitNormalDy=s-r)}TestInstanceRect(e,t,s,i){const r=t+i.getLeft(),n=t+i.getRight(),a=s+i.getTop(),o=s+i.getBottom();this.TestInstanceSegment(e,r,a,n,a),this.TestInstanceSegment(e,n,a,n,o),this.TestInstanceSegment(e,n,o,r,o),this.TestInstanceSegment(e,r,o,r,a)}TestInstanceQuad(e,t){const s=t.getTlx(),i=t.getTly(),r=t.getTrx(),n=t.getTry(),a=t.getBrx(),o=t.getBry(),l=t.getBlx(),h=t.getBly();this.TestInstanceSegment(e,s,i,r,n),this.TestInstanceSegment(e,r,n,a,o),this.TestInstanceSegment(e,a,o,l,h),this.TestInstanceSegment(e,l,h,s,i)}TestInstancePoly(s,i,r,e){const n=e.pointsArr();for(let e=0,t=n.length;e<t;e+=2){const a=(e+2)%t,o=n[e]+i,l=n[e+1]+r,h=n[a]+i,c=n[1+a]+r;this.TestInstanceSegment(s,o,l,h,c)}}}}{const C33=self.C3,VALID_FULLSCREEN_MODES=new Set(["off","crop","scale-inner","scale-outer","letterbox-scale","letterbox-integer-scale"]),VALID_FULLSCREEN_SCALING_QUALITIES=new Set(["high","low"]),glMatrix=self.glMatrix,mat42=glMatrix.mat4,vec32=glMatrix.vec3,tempProjection=mat42.create(),PERCENTTEXT_WIDTH=300,PERCENTTEXT_HEIGHT=200,PROGRESSBAR_WIDTH=120,PROGRESSBAR_HEIGHT=8,tempQuad=C33.New(C33.Quad),tempRect=C33.New(C33.Rect),SPLASH_MIN_DISPLAY_TIME=3e3,SPLASH_AFTER_FADEOUT_WAIT_TIME=200,SPLASH_FADE_DURATION=300;C33.CanvasManager=class extends C33.DefendedBase{constructor(e){super(),this._runtime=e,this._canvasLayers=[],this._isWebGPUEnabled=!1,this._webglRenderer=null,this._webgpuRenderer=null,this._iRenderer=null,this._gpuPreference="high-performance",this._isLimitedToWebGL1=!1,this._multitexturingMode="auto",this._windowInnerWidth=0,this._windowInnerHeight=0,this._cssDisplayMode="",this._canvasCssWidth=0,this._canvasCssHeight=0,this._canvasDeviceWidth=0,this._canvasDeviceHeight=0,this._canvasCssOffsetX=0,this._canvasCssOffsetY=0,this._zAxisScale="normalized",this._initFieldOfView=0,this._zNear=1,this._zFar=1e4,this._enableMipmaps=!0,this._textureAnisotropy=0,this._drawWidth=0,this._drawHeight=0,this._fullscreenMode="letterbox-scale",this._documentFullscreenMode="letterbox-scale",this._deviceTransformOffX=0,this._deviceTransformOffY=0,this._defaultProjectionMatrix=mat42.create(),this._wantFullscreenScalingQuality="high",this._fullscreenScalingQuality=this._wantFullscreenScalingQuality,this._isDocumentFullscreen=!1,this._availableAdditionalRenderTargets=[],this._usedAdditionalRenderTargets=new Set,this._shaderData=self.C3_Shaders,this._effectChainManager=C33.New(C33.Gfx.EffectChainManager,{getDrawSize:()=>[this.GetDrawWidth(),this.GetDrawHeight()],getRenderTarget:()=>this.GetEffectCompositorRenderTarget(),releaseRenderTarget:e=>this.ReleaseEffectCompositorRenderTarget(e),getTime:()=>this.GetRuntime().GetGameTime(),redraw:()=>this.GetRuntime().UpdateRender()}),this._gpuTimeStartFrame=0,this._gpuTimeEndFrame=0,this._gpuLastUtilisation=NaN,this._gpuFrameTimingsBuffer=null,this._layersGpuProfile=new Map,this._gpuCurUtilisation=NaN,this._webgpuFrameTimings=new Map,this._snapshotFormat="",this._snapshotQuality=1,this._snapshotArea=C33.New(C33.Rect),this._snapshotUrl="",this._snapshotPromise=null,this._snapshotResolve=null,this._isPastingToDrawingCanvas=0,this._loaderStartTime=0,this._rafId=-1,this._loadingProgress=0,this._loadingprogress_handler=e=>this._loadingProgress=e.progress,this._percentText=null,this._splashTextures={logo:null,powered:null,website:null},this._splashFrameNumber=0,this._splashFadeInFinishTime=0,this._splashFadeOutStartTime=0,this._splashState="fade-in",this._splashDoneResolve=null,this._splashDonePromise=new Promise(e=>this._splashDoneResolve=e)}_SetGPUPowerPreference(e){this._gpuPreference=e}_SetWebGPUEnabled(e){this._isWebGPUEnabled=!!e}_SetZAxisScale(e){this._zAxisScale=e}GetZAxisScale(){return this._zAxisScale}_SetInitFieldOfView(e){this._initFieldOfView=e}_SetZDistances(e,t){this._zNear=e,this._zFar=t}_SetLimitedToWebGL1(e){this._isLimitedToWebGL1=!!e}_SetMultitexturingMode(e){this._multitexturingMode=e}async CreateCanvas(e){let t=e.canvas,s=(this._canvasLayers.push({canvas:t,ctx:null}),this._runtime.AddDOMComponentMessageHandler("runtime","window-resize",e=>this._OnWindowResize(e)),this._runtime.AddDOMComponentMessageHandler("runtime","fullscreenchange",e=>this._OnFullscreenChange(e)),this._runtime.AddDOMComponentMessageHandler("runtime","fullscreenerror",e=>this._OnFullscreenError(e)),t.addEventListener("webglcontextlost",e=>this._OnWebGLContextLost(e)),t.addEventListener("webglcontextrestored",e=>this._OnWebGLContextRestored(e)),this._isDocumentFullscreen=!!e.isFullscreen,this._cssDisplayMode=e.cssDisplayMode,navigator.gpu&&this._isWebGPUEnabled),i=!1;if(s)try{await this._InitWebGPUContext(!0)}catch(e){this._MaybeLogRendererError("WebGPU",e),this._webgpuRenderer=null}if(!this.GetRenderer())try{await this._InitWebGLContext(!0)}catch(e){this._MaybeLogRendererError("WebGL",e),this._webglRenderer=null}if(this.GetRenderer()||(i=!0),!this.GetRenderer()&&s)try{await this._InitWebGPUContext(!1)}catch(e){this._MaybeLogRendererError("WebGPU",e),this._webgpuRenderer=null}if(!this.GetRenderer())try{await this._InitWebGLContext(!1)}catch(e){this._MaybeLogRendererError("WebGL",e),this._webglRenderer=null}const r=this.GetRenderer();if(!r)throw new Error("failed to acquire a renderer - check WebGL or WebGPU is supported");r.SetHasMajorPerformanceCaveat(i),this._webgpuRenderer&&(this._webgpuRenderer.ondevicelost=()=>this._OnWebGPUDeviceLost(),this._webgpuRenderer.ondevicerestored=()=>this._OnWebGPUDeviceRestored()),"normalized"===this._zAxisScale?r.SetZAxisScaleNormalized():(r.SetZAxisScaleRegular(),r.SetFovY(this._initFieldOfView)),this.SetSize(e.windowInnerWidth,e.windowInnerHeight,!0),await this._InitRenderer()}_MaybeLogRendererError(e,t){t&&"string"==typeof t.message&&t.message.startsWith("renderer-unavailable")||console.error(`Error creating ${e} renderer: `,t)}async _InitWebGPUContext(e){let t={nearZ:this._zNear,farZ:this._zFar},s=!0;"no"===this._multitexturingMode?s=!1:"auto"===this._multitexturingMode&&(s=C33.Platform.IsDesktop);const i={powerPreference:this._gpuPreference,depth:this._runtime.Uses3DFeatures(),failIfMajorPerformanceCaveat:e,usesBackgroundBlending:this._runtime.UsesAnyBackgroundBlending(),canSampleBackbuffer:this._runtime.UsesAnyCrossSampling(),canSampleDepth:this._runtime.UsesAnyDepthSampling(),isMultiTexturingAllowed:s};this._webgpuRenderer=C33.New(C33.Gfx.WebGPURenderer,t),await this._webgpuRenderer.Create(this._canvasLayers[0].canvas,i)}async _InitWebGLContext(e){const t={alpha:!0,powerPreference:this._gpuPreference,enableGpuProfiling:"xbox-uwp-webview2"!==this._runtime.GetExportType(),depth:this._runtime.Uses3DFeatures(),canSampleDepth:this._runtime.UsesAnyDepthSampling(),failIfMajorPerformanceCaveat:e,nearZ:this._zNear,farZ:this._zFar};this._isLimitedToWebGL1&&(t.maxWebGLVersion=1),this._webglRenderer=C33.New(C33.Gfx.WebGLRenderer,this._canvasLayers[0].canvas,t),await this._webglRenderer.InitState()}async _InitWebGPU(){if(this._shaderData){const e=[];for(const[t,s]of Object.entries(this._shaderData)){s.src=s.wgsl;const i=C33.Gfx.WebGPUShaderProgram.GetDefaultVertexShaderSource();e.push(this._webgpuRenderer.CreateShaderProgram(Object.assign({vertexSrc:i,name:t},s)))}await Promise.all(e)}}async _InitWebGL(){if(this._shaderData){const t=[];for(const[s,i]of Object.entries(this._shaderData)){let e;if(i.glslWebGL2&&2<=this._webglRenderer.GetWebGLVersionNumber())i.src=i.glslWebGL2,e=C33.Gfx.WebGLShaderProgram.GetDefaultVertexShaderSource_WebGL2();else{if(!i.glsl)throw new Error(`shader '${s}' does not support WebGL 1`);i.src=i.glsl,e=C33.Gfx.WebGLShaderProgram.GetDefaultVertexShaderSource()}t.push(this._webglRenderer.CreateShaderProgram(Object.assign({vertexSrc:e,name:s},i)))}await Promise.all(t),this._webglRenderer.ResetLastProgram(),this._webglRenderer.SetTextureFillMode()}this._webglRenderer.SupportsGPUProfiling()&&(this._gpuFrameTimingsBuffer=C33.New(C33.Gfx.WebGLQueryResultBuffer,this._webglRenderer))}async _InitRenderer(){this._webgpuRenderer?await this._InitWebGPU():this._webglRenderer&&await this._InitWebGL();const e=this.GetRenderer();e.SetMipmapsEnabled(this._enableMipmaps),e.SupportsGPUProfiling()&&(this._gpuLastUtilisation=0);for(const t of this._runtime._GetAllEffectLists()){for(const s of t.GetAllEffectTypes())s._InitRenderer(e);t._InitRenderer(e),t.UpdateActiveEffects()}this._iRenderer=new self.IRenderer(this._runtime,e)}Release(){this._runtime=null,this._webglRenderer=null,this._canvasLayers.length=0}IsInWorker(){return this._runtime.IsInWorker()}_OnWindowResize(e){const t=this._runtime;if(!t.IsExportToVideo()){const s=e.devicePixelRatio,i=(this.IsInWorker()&&(self.devicePixelRatio=s),t._SetDevicePixelRatio(s),this._isDocumentFullscreen=!!e.isFullscreen,this._cssDisplayMode=e.cssDisplayMode,this.SetSize(e.innerWidth,e.innerHeight),t.UpdateRender(),new C33.Event("window-resize")),r=(i.data=e,t.Dispatcher().dispatchEventAndWaitAsyncSequential(i),new C33.Event("resize"));r.cssWidth=this.GetCssWidth(),r.cssHeight=this.GetCssHeight(),r.deviceWidth=this.GetDeviceWidth(),r.deviceHeight=this.GetDeviceHeight(),t.DispatchUserScriptEvent(r),t.IsDebug()&&(t.HitBreakpoint()||self.C3Debugger.IsDebuggerPaused())&&t.Render()}}_OnFullscreenChange(e){this._isDocumentFullscreen=!!e.isFullscreen,this.SetSize(e.innerWidth,e.innerHeight,!0),this._runtime.UpdateRender()}_OnFullscreenError(e){this._isDocumentFullscreen=!!e.isFullscreen,this.SetSize(e.innerWidth,e.innerHeight,!0),this._runtime.UpdateRender()}SetSize(e,t,s=!1){if(e=Math.floor(e),t=Math.floor(t),e<=0||t<=0)throw new Error("invalid size");if(this._windowInnerWidth!==e||this._windowInnerHeight!==t||s){this._windowInnerWidth=e,this._windowInnerHeight=t;const i=this.GetCurrentFullscreenMode();"letterbox-scale"===i?this._CalculateLetterboxScale(e,t):"letterbox-integer-scale"===i?this._CalculateLetterboxIntegerScale(e,t):"off"===i?this._CalculateFixedSizeCanvas(e,t):this._CalculateFullsizeCanvas(e,t),this._UpdateFullscreenScalingQuality(i);for(const{canvas:a}of this._canvasLayers)a.width=this._canvasDeviceWidth,a.height=this._canvasDeviceHeight;this._runtime.PostComponentMessageToDOM("canvas","update-size",{marginLeft:this._canvasCssOffsetX,marginTop:this._canvasCssOffsetY,styleWidth:this._canvasCssWidth,styleHeight:this._canvasCssHeight,displayScale:this.GetDisplayScale()});const r=this.GetRenderer();r.SetSize(this._canvasDeviceWidth,this._canvasDeviceHeight,!0);for(const o of this._availableAdditionalRenderTargets)r.DeleteRenderTarget(o);C33.clearArray(this._availableAdditionalRenderTargets),this.UpdateDefaultProjectionMatrix();const n=this._runtime.GetLayoutManager();n.SetAllLayerProjectionChanged(),n.SetAllLayerMVChanged()}}UpdateDefaultProjectionMatrix(){this.GetRenderer().CalculatePerspectiveMatrix(this._defaultProjectionMatrix,this.GetDrawWidth()/this.GetDrawHeight())}GetDefaultProjectionMatrix(){return this._defaultProjectionMatrix}_CalculateLetterboxScale(e,t){const s=this._runtime.GetDevicePixelRatio(),i=this._runtime.GetOriginalViewportWidth(),r=this._runtime.GetOriginalViewportHeight(),n=i/r,a=e/t;if(n<a){const o=t*n;this._canvasCssWidth=Math.round(o),this._canvasCssHeight=t,this._canvasCssOffsetX=Math.floor((e-this._canvasCssWidth)/2),this._canvasCssOffsetY=0}else{const l=e/n;this._canvasCssWidth=e,this._canvasCssHeight=Math.round(l),this._canvasCssOffsetX=0,this._canvasCssOffsetY=Math.floor((t-this._canvasCssHeight)/2)}this._canvasDeviceWidth=Math.round(this._canvasCssWidth*s),this._canvasDeviceHeight=Math.round(this._canvasCssHeight*s),this._runtime.SetViewportSize(i,r)}_CalculateLetterboxIntegerScale(e,t){let s=this._runtime.GetDevicePixelRatio(),i=(1!==s&&(e+=1,t+=1),this._runtime.GetOriginalViewportWidth()),r=this._runtime.GetOriginalViewportHeight(),n=i/r,a=e/t,o;if(n<a){const l=t*n;o=l*s/i}else{const h=e/n;o=h*s/r}1<o?o=Math.floor(o):o<1&&(o=1/Math.ceil(1/o)),this._canvasDeviceWidth=Math.round(i*o),this._canvasDeviceHeight=Math.round(r*o),this._canvasCssWidth=this._canvasDeviceWidth/s,this._canvasCssHeight=this._canvasDeviceHeight/s,this._canvasCssOffsetX=Math.max(Math.floor((e-this._canvasCssWidth)/2),0),this._canvasCssOffsetY=Math.max(Math.floor((t-this._canvasCssHeight)/2),0),this._runtime.SetViewportSize(i,r)}_CalculateFullsizeCanvas(e,t){const s=this._runtime.GetDevicePixelRatio(),i=(this._canvasCssWidth=e,this._canvasCssHeight=t,this._canvasDeviceWidth=Math.round(this._canvasCssWidth*s),this._canvasDeviceHeight=Math.round(this._canvasCssHeight*s),this._canvasCssOffsetX=0,this._canvasCssOffsetY=0,this.GetDisplayScale());this._runtime.SetViewportSize(this._canvasCssWidth/i,this._canvasCssHeight/i)}_CalculateFixedSizeCanvas(e,t){const s=this._runtime.GetDevicePixelRatio();this._canvasCssWidth=this._runtime.GetViewportWidth(),this._canvasCssHeight=this._runtime.GetViewportHeight(),this._canvasDeviceWidth=Math.round(this._canvasCssWidth*s),this._canvasDeviceHeight=Math.round(this._canvasCssHeight*s),this.IsDocumentFullscreen()?(this._canvasCssOffsetX=Math.floor((e-this._canvasCssWidth)/2),this._canvasCssOffsetY=Math.floor((t-this._canvasCssHeight)/2)):(this._canvasCssOffsetX=0,this._canvasCssOffsetY=0),this._runtime.SetViewportSize(this._runtime.GetViewportWidth(),this._runtime.GetViewportHeight())}_UpdateFullscreenScalingQuality(s){if("high"===this._wantFullscreenScalingQuality)this._drawWidth=this._canvasDeviceWidth,this._drawHeight=this._canvasDeviceHeight,this._fullscreenScalingQuality="high";else{let e,t;if(t="off"===this.GetCurrentFullscreenMode()?(e=this._runtime.GetViewportWidth(),this._runtime.GetViewportHeight()):(e=this._runtime.GetOriginalViewportWidth(),this._runtime.GetOriginalViewportHeight()),this._canvasDeviceWidth<e||this._canvasDeviceHeight<t)this._drawWidth=this._canvasDeviceWidth,this._drawHeight=this._canvasDeviceHeight,this._fullscreenScalingQuality="high";else if(this._drawWidth=e,this._drawHeight=t,this._fullscreenScalingQuality="low","scale-inner"===s){const i=e/t,r=this._windowInnerWidth/this._windowInnerHeight;r<i?this._drawWidth=this._drawHeight*r:i<r&&(this._drawHeight=this._drawWidth/r)}else if("scale-outer"===s){const n=e/t,a=this._windowInnerWidth/this._windowInnerHeight;n<a?this._drawWidth=this._drawHeight*a:a<n&&(this._drawHeight=this._drawWidth/a)}}}GetRuntime(){return this._runtime}GetMainCanvas(){return this._canvasLayers[0].canvas}GetEffectChainManager(){return this._effectChainManager}IsDocumentFullscreen(){return this._isDocumentFullscreen}GetCssDisplayMode(){return this._cssDisplayMode}SetFullscreenMode(e){if(!VALID_FULLSCREEN_MODES.has(e))throw new Error("invalid fullscreen mode");this._fullscreenMode=e;const t=this._runtime.GetLayoutManager();t.SetAllLayerProjectionChanged(),t.SetAllLayerMVChanged()}GetFullscreenMode(){return this._fullscreenMode}SetDocumentFullscreenMode(e){if(!VALID_FULLSCREEN_MODES.has(e))throw new Error("invalid fullscreen mode");this._documentFullscreenMode=e;const t=this._runtime.GetLayoutManager();t.SetAllLayerProjectionChanged(),t.SetAllLayerMVChanged()}GetDocumentFullscreenMode(){return this._documentFullscreenMode}GetCurrentFullscreenMode(){return this.IsDocumentFullscreen()?this.GetDocumentFullscreenMode():this.GetFullscreenMode()}SetFullscreenScalingQuality(e){if(!VALID_FULLSCREEN_SCALING_QUALITIES.has(e))throw new Error("invalid fullscreen scaling quality");this._wantFullscreenScalingQuality=e,this._runtime.GetLayoutManager().SetAllLayerProjectionChanged()}GetSetFullscreenScalingQuality(){return this._wantFullscreenScalingQuality}GetCurrentFullscreenScalingQuality(){return this._fullscreenScalingQuality}static _FullscreenModeNumberToString(e){switch(e){case 0:return"off";case 1:return"crop";case 2:return"scale-inner";case 3:return"scale-outer";case 4:return"letterbox-scale";case 5:return"letterbox-integer-scale";default:throw new Error("invalid fullscreen mode")}}GetLastWidth(){return this._windowInnerWidth}GetLastHeight(){return this._windowInnerHeight}GetDrawWidth(){return this._drawWidth}GetDrawHeight(){return this._drawHeight}SetMipmapsEnabled(e){this._enableMipmaps=!!e}_SetTextureAnisotropy(e){this._textureAnisotropy=e}GetTextureAnisotropy(){return this._textureAnisotropy}IsRendererContextLost(){return this.GetRenderer().IsContextLost()}_OnWebGLContextLost(e){console.log("[Construct] WebGL context lost"),e.preventDefault(),this._availableAdditionalRenderTargets=[],this._usedAdditionalRenderTargets.clear(),this._effectChainManager.OnContextLost(),this._webglRenderer.OnContextLost(),this._runtime._OnRendererContextLost()}_OnWebGPUDeviceLost(){console.log("[Construct] WebGPU device lost"),this._availableAdditionalRenderTargets=[],this._usedAdditionalRenderTargets.clear(),this._effectChainManager.OnContextLost(),this._runtime._OnRendererContextLost()}async _OnWebGLContextRestored(e){await this._webglRenderer.OnContextRestored(),await this._InitRenderer(),await this._runtime._OnRendererContextRestored(),console.log("[Construct] WebGL context restored")}async _OnWebGPUDeviceRestored(){await this._InitRenderer(),await this._runtime._OnRendererContextRestored(),console.log("[Construct] WebGPU device restored")}GetWebGLRenderer(){return this._webglRenderer}GetWebGPURenderer(){return this._webgpuRenderer}GetRenderer(){return this._webgpuRenderer||this._webglRenderer}GetIRenderer(){return this._iRenderer}GetRendererString(){let e="";return e=this._runtime.GetWebGPURenderer()?"webgpu":"webgl"+this._runtime.GetWebGLRenderer().GetWebGLVersionNumber(),this._runtime.GetRenderer().HasMajorPerformanceCaveat()&&(e+="-software"),e}GetRendererDetailString(){return this._runtime.GetWebGPURenderer()?this._runtime.GetWebGPURenderer().GetAdapterInfoString():this._runtime.GetWebGLRenderer().GetUnmaskedRenderer()}GetRenderScale(){return"low"===this._fullscreenScalingQuality?1/this._runtime.GetDevicePixelRatio():this.GetDisplayScale()}GetDisplayScale(){const e=this.GetCurrentFullscreenMode();if("off"===e||"crop"===e)return 1;const t=this._runtime.GetOriginalViewportWidth(),s=this._runtime.GetOriginalViewportHeight(),i=t/s,r=this._canvasDeviceWidth/this._canvasDeviceHeight;return"scale-inner"!==e&&i<r||"scale-inner"===e&&r<i?this._canvasCssHeight/s:this._canvasCssWidth/t}GetEffectLayerScaleParam(){return"low"===this.GetCurrentFullscreenScalingQuality()?1:this.GetDisplayScale()}GetEffectDevicePixelRatioParam(){return"low"===this.GetCurrentFullscreenScalingQuality()?1:this._runtime.GetDevicePixelRatio()}SetDeviceTransformOffset(e,t){this._deviceTransformOffX=e,this._deviceTransformOffY=t}SetDeviceTransform(t,s,i,e=!0){s=s||this._drawWidth,i=i||this._drawHeight;const r=s/2+this._deviceTransformOffX,n=i/2+this._deviceTransformOffY;if(e){let e=this.GetDefaultProjectionMatrix();s===this._drawWidth&&i===this._drawHeight||(t.CalculatePerspectiveMatrix(tempProjection,s/i),e=tempProjection),t.SetProjectionMatrix(e)}const a=t.CalculateLookAtModelView2(r,n,t.GetDefaultCameraZ(i),r,n,0,i);t.SetModelViewMatrix(a)}SetCssTransform(e,t=!0){const s=this.GetCssWidth(),i=this.GetCssHeight(),r=s/2,n=i/2,a=(t&&e.SetProjectionMatrix(this.GetDefaultProjectionMatrix()),e.CalculateLookAtModelView2(r,n,e.GetDefaultCameraZ(i),r,n,0,i));e.SetModelViewMatrix(a)}GetDeviceWidth(){return this._canvasDeviceWidth}GetDeviceHeight(){return this._canvasDeviceHeight}GetCssWidth(){return this._canvasCssWidth}GetCssHeight(){return this._canvasCssHeight}GetCanvasClientX(){return this._canvasCssOffsetX}GetCanvasClientY(){return this._canvasCssOffsetY}GetHTMLLayerCount(){return this._canvasLayers.length}_CanUseImageBitmapRenderingContext(){return"undefined"!=typeof OffscreenCanvas&&this.GetMainCanvas()instanceof OffscreenCanvas&&("Chromium"!==C33.Platform.BrowserEngine||124<=C33.Platform.BrowserVersionNumber)}async SetHTMLLayerCount(i,r=!1){if(i<1)throw new Error("invalid HTML layer count");if(this._canvasLayers.length!==i){let e=this._runtime.GetLayoutManager().GetMainRunningLayout(),t={count:i,layersDomState:e._GetRootLayers().filter(e=>e.IsHTMLElementsLayer()).map(e=>e._GetHTMLLayerDOMState()),immediate:r,marginLeft:this._canvasCssOffsetX,marginTop:this._canvasCssOffsetY,styleWidth:this._canvasCssWidth,styleHeight:this._canvasCssHeight},s;if(s=this.IsInWorker()?await this._runtime.PostComponentMessageToDOMAsync("canvas","set-html-layer-count",t):self.c3_runtimeInterface._OnSetHTMLLayerCount(t),i<this._canvasLayers.length)this._canvasLayers.length=i;else for(const n of s.addedCanvases){n.width=this._canvasDeviceWidth,n.height=this._canvasDeviceHeight;const a=this._CanUseImageBitmapRenderingContext()?"bitmaprenderer":"2d",o=n.getContext(a);if(!o)throw new Error(`failed to acquire '${a}' canvas context`);this._canvasLayers.push({canvas:n,ctx:o})}this._runtime.UpdateRender()}}BlitMainCanvasToHTMLLayerCanvas(e){if(!(e>=this._canvasLayers.length)){const t=this.GetMainCanvas(),s=this._canvasLayers[e].ctx;this._CanUseImageBitmapRenderingContext()?s.transferFromImageBitmap(t.transferToImageBitmap()):(s.globalCompositeOperation="copy",s.drawImage(t,0,0))}}GetAdditionalRenderTarget(t){t.depth=this._runtime.Uses3DFeatures();let e=this._availableAdditionalRenderTargets,s=e.findIndex(e=>e.IsCompatibleWithOptions(t)),i;return-1!==s?(i=e[s],e.splice(s,1)):i=this.GetRenderer().CreateRenderTarget(t),this._usedAdditionalRenderTargets.add(i),i}ReleaseAdditionalRenderTarget(e){if(!this._usedAdditionalRenderTargets.has(e))throw new Error("render target not in use");this._usedAdditionalRenderTargets.delete(e),this._availableAdditionalRenderTargets.push(e)}GetEffectCompositorRenderTarget(){const e={sampling:this._runtime.GetSampling()};return"low"===this.GetCurrentFullscreenScalingQuality()&&(e.width=this.GetDrawWidth(),e.height=this.GetDrawHeight()),this.GetAdditionalRenderTarget(e)}ReleaseEffectCompositorRenderTarget(e){this.ReleaseAdditionalRenderTarget(e)}*activeLayersGpuProfiles(){for(const e of this._runtime.GetLayoutManager().runningLayouts())for(const t of e.GetLayers()){const s=this._layersGpuProfile.get(t);s&&(yield s)}}GetLayerTimingsBuffer(e){if(!this.GetRenderer().SupportsGPUProfiling())return null;let t=this._layersGpuProfile.get(e);return t||(t={layer:e,name:e.GetName(),timingsBuffer:C33.New(C33.Gfx.WebGLQueryResultBuffer,this._webglRenderer),curUtilisation:0,lastTotalUtilisation:0,lastSelfUtilisation:0},this._layersGpuProfile.set(e,t)),t.timingsBuffer}_Update1sFrameRange(){const e=this.GetRenderer();if(e.SupportsGPUProfiling()&&0===this._gpuTimeEndFrame){this._gpuTimeEndFrame=e.GetFrameNumber(),this._gpuCurUtilisation=NaN;for(const t of this.activeLayersGpuProfiles())t.curUtilisation=NaN}}_UpdateTick(){this._webglRenderer&&this._webglRenderer.SupportsGPUProfiling()&&this._UpdateTick_WebGL(),this._webgpuRenderer&&this._webgpuRenderer.SupportsGPUProfiling()&&this._UpdateTick_WebGPU()}_UpdateTick_WebGL(){if(isNaN(this._gpuCurUtilisation)&&(this._gpuCurUtilisation=this._gpuFrameTimingsBuffer.GetFrameRangeResultSum(this._gpuTimeStartFrame,this._gpuTimeEndFrame),!isNaN(this._gpuCurUtilisation))){if(this._runtime.IsDebug())for(const e of this.activeLayersGpuProfiles())if(e.curUtilisation=e.timingsBuffer.GetFrameRangeResultSum(this._gpuTimeStartFrame,this._gpuTimeEndFrame),isNaN(e.curUtilisation))return;if(this._gpuFrameTimingsBuffer.DeleteAllBeforeFrameNumber(this._gpuTimeEndFrame),this._gpuLastUtilisation=Math.min(this._gpuCurUtilisation,1),this._runtime.IsDebug()){const s=new Map;for(const r of this.activeLayersGpuProfiles())r.timingsBuffer.DeleteAllBeforeFrameNumber(this._gpuTimeEndFrame),r.lastTotalUtilisation=Math.min(r.curUtilisation,1),s.set(r.layer,r.lastTotalUtilisation);for(const n of this.activeLayersGpuProfiles()){const a=n.layer,o=s.get(a)||0,l=o-a.GetSubLayers().reduce((e,t)=>e+(s.get(t)||0),0);n.lastSelfUtilisation=C33.clamp(l,0,1)}const t=this._runtime.GetMainRunningLayout(),i=this._gpuLastUtilisation-t._GetRootLayers().reduce((e,t)=>e+(s.get(t)||0),0);self.C3Debugger.UpdateGPUProfile(C33.clamp(i,0,1),this._gpuLastUtilisation,[...this.activeLayersGpuProfiles()])}this._gpuTimeStartFrame=this._gpuTimeEndFrame,this._gpuTimeEndFrame=0}}GetGPUFrameTimingsBuffer(){return this._gpuFrameTimingsBuffer}_UpdateTick_WebGPU(){if(0!==this._gpuTimeEndFrame){for(let e=this._gpuTimeStartFrame;e<this._gpuTimeEndFrame;++e){const s=this._webgpuFrameTimings.get(e);if(s&&!s.HasResult())return}let e=this._runtime.GetMainRunningLayout(),a=C33.MakeFilledArray(e.GetLayerCount()+1,0),t=0;for(let e=this._gpuTimeStartFrame;e<this._gpuTimeEndFrame;++e){const o=this._webgpuFrameTimings.get(e);if(o){let s=o.GetResult(),i=BigInt(0),r=BigInt(0),n=BigInt(0);for(let e=0,t=Math.min(a.length,s.length/2);e<t;++e){const c=s[2*e],u=s[2*e+1],_=(c!==n&&(i===n||c<i)&&(i=c),u>r&&(r=u),u-c),d=Number(_)/1e9;a[e]+=d}const l=r-i,h=Number(l)/1e9;t+=h}}if(this._gpuLastUtilisation=C33.clamp(t,0,1),this._runtime.IsDebug()){const i=e.GetLayers(),r=new Map;for(let e=0,t=Math.min(i.length,a.length-1);e<t;++e){const g=a[e+1];r.set(i[e],g)}const n=[],p=new Map;for(const[f,S]of r){const C=[...f.selfAndAllSubLayers()].reduce((e,t)=>e+(r.get(t)||0),0);p.set(f,C),n.push({name:f.GetName(),lastSelfUtilisation:C33.clamp(S,0,1),lastTotalUtilisation:C33.clamp(C,0,1)})}const m=this._gpuLastUtilisation-e._GetRootLayers().reduce((e,t)=>e+(p.get(t)||0),0);self.C3Debugger.UpdateGPUProfile(C33.clamp(m,0,1),this._gpuLastUtilisation,n)}for(let e=this._gpuTimeStartFrame;e<this._gpuTimeEndFrame;++e)this._webgpuFrameTimings.delete(e);this._gpuTimeStartFrame=this._gpuTimeEndFrame,this._gpuTimeEndFrame=0}}_AddWebGPUFrameTiming(e){this._webgpuFrameTimings.set(this._webgpuRenderer.GetFrameNumber(),e)}GetGPUUtilisation(){return this._gpuLastUtilisation}SnapshotCanvas(e,t,s,i,r,n){return this._snapshotFormat=e,this._snapshotQuality=t,this._snapshotArea.setWH(s,i,r,n),this._snapshotPromise||(this._snapshotPromise=new Promise(e=>{this._snapshotResolve=e})),this._snapshotPromise}_MaybeTakeSnapshot(){if(this._snapshotFormat){let e=this.GetMainCanvas(),t=this._snapshotArea,s=C33.clamp(Math.floor(t.getLeft()),0,e.width),i=C33.clamp(Math.floor(t.getTop()),0,e.height),r=t.width(),n=(r=0===r?e.width-s:C33.clamp(Math.floor(r),0,e.width-s),t.height());if(n=0===n?e.height-i:C33.clamp(Math.floor(n),0,e.height-i),(0!==s||0!==i||r!==e.width||n!==e.height)&&0<r&&0<n){const a=C33.CreateCanvas(r,n),o=a.getContext("2d");o.drawImage(e,s,i,r,n,0,0,r,n),e=a}C33.CanvasToBlob(e,this._snapshotFormat,this._snapshotQuality).then(e=>{this._snapshotUrl&&URL.revokeObjectURL(this._snapshotUrl),this._snapshotUrl=URL.createObjectURL(e),this._snapshotPromise=null,this._snapshotResolve(this._snapshotUrl)}),this._snapshotFormat="",this._snapshotQuality=1}}GetCanvasSnapshotUrl(){return this._snapshotUrl}SetIsPastingToDrawingCanvas(e){e?this._isPastingToDrawingCanvas++:this._isPastingToDrawingCanvas--}IsPastingToDrawingCanvas(){return 0<this._isPastingToDrawingCanvas}InitLoadingScreen(e){const t=this.GetRenderer();if(2===e)this._percentText=C33.New(C33.Gfx.RendererText,this.GetRenderer()),this._percentText.SetFontName("Arial"),this._percentText.SetFontSize(16),this._percentText.SetHorizontalAlignment("center"),this._percentText.SetVerticalAlignment("center"),this._percentText.SetSize(PERCENTTEXT_WIDTH,PERCENTTEXT_HEIGHT);else if(0===e){const s=this._runtime.GetLoadingLogoAsset();s&&s.LoadStaticTexture(t).catch(e=>console.warn("[C3 runtime] Failed to create texture for loading logo: ",e))}else 4===e&&(this._LoadSvgSplashImage("splash-images/splash-logo.svg").then(e=>{"done"===this._splashState?t.DeleteTexture(e):this._splashTextures.logo=e}).catch(e=>console.warn("Failed to load splash image: ",e)),this._LoadBitmapSplashImage("splash-images/splash-poweredby-512.png").then(e=>{"done"===this._splashState?t.DeleteTexture(e):this._splashTextures.powered=e}).catch(e=>console.warn("Failed to load splash image: ",e)),this._LoadBitmapSplashImage("splash-images/splash-website-512.png").then(e=>{"done"===this._splashState?t.DeleteTexture(e):this._splashTextures.website=e}).catch(e=>console.warn("Failed to load splash image: ",e)))}async _LoadSvgSplashImage(e){e=new URL(e,this._runtime.GetRuntimeBaseURL()).toString();const t=await C33.FetchBlob(e),s=await this._runtime.RasterSvgImage(t,2048,2048);return this.GetRenderer().CreateStaticTextureAsync(s,{mipMapQuality:"high"})}async _LoadBitmapSplashImage(e){e=new URL(e,this._runtime.GetRuntimeBaseURL()).toString();const t=await C33.FetchBlob(e);return this.GetRenderer().CreateStaticTextureAsync(t,{mipMapQuality:"high"})}HideCordovaSplashScreen(){this._runtime.PostComponentMessageToDOM("runtime","hide-cordova-splash")}StartLoadingScreen(){this._loaderStartTime=Date.now(),this._runtime.Dispatcher().addEventListener("loadingprogress",this._loadingprogress_handler),this._rafId=requestAnimationFrame(()=>this._DrawLoadingScreen());const e=this._runtime.GetLoaderStyle();3!==e&&this.HideCordovaSplashScreen()}async EndLoadingScreen(){const e=this.GetRenderer(),t=(this._loadingProgress=1,this._runtime.GetLoaderStyle());4===t&&await this._splashDonePromise,this._splashDoneResolve=null,this._splashDonePromise=null,-1!==this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=-1),this._runtime.Dispatcher().removeEventListener("loadingprogress",this._loadingprogress_handler),this._loadingprogress_handler=null,this._percentText&&(this._percentText.Release(),this._percentText=null),this._runtime.ReleaseLoadingLogoAsset(),e.Start(),this._splashTextures.logo&&(e.DeleteTexture(this._splashTextures.logo),this._splashTextures.logo=null),this._splashTextures.powered&&(e.DeleteTexture(this._splashTextures.powered),this._splashTextures.powered=null),this._splashTextures.website&&(e.DeleteTexture(this._splashTextures.website),this._splashTextures.website=null),e.ClearRgba(0,0,0,0),e.Finish(),this._splashState="done",this._gpuTimeStartFrame=e.GetFrameNumber(),3===t&&this.HideCordovaSplashScreen()}_DrawLoadingScreen(){if(-1!==this._rafId){const e=this.GetRenderer(),t=(e.Start(),this._rafId=-1,this._runtime.GetAssetManager().HasHadErrorLoading()),s=this._runtime.GetLoaderStyle();if(3!==s&&(this.SetCssTransform(e),e.ClearRgba(0,0,0,0),e.ResetColor(),e.SetTextureFillMode(),e.SetTexture(null)),0===s)this._DrawProgressBarAndLogoLoadingScreen(t);else if(1===s)this._DrawProgressBarLoadingScreen(t,PROGRESSBAR_WIDTH,0);else if(2===s)this._DrawPercentTextLoadingScreen(t);else if(3===s)C33.noop();else{if(4!==s)throw new Error("invalid loader style");this._DrawSplashLoadingScreen(t)}e.Finish(),this._rafId=requestAnimationFrame(()=>this._DrawLoadingScreen())}}_DrawPercentTextLoadingScreen(e){e?this._percentText.SetColorRgb(1,0,0):this._percentText.SetColorRgb(.6,.6,.6),this._percentText.SetText(Math.round(100*this._loadingProgress)+"%");const t=this._canvasCssWidth/2,s=this._canvasCssHeight/2,i=PERCENTTEXT_WIDTH/2,r=PERCENTTEXT_HEIGHT/2,n=(tempQuad.setRect(t-i,s-r,t+i,s+r),this.GetRenderer());n.SetTexture(this._percentText.GetTexture()),n.Quad3(tempQuad,this._percentText.GetTexRect())}_DrawProgressBarLoadingScreen(e,t,s){const i=this.GetRenderer(),r=PROGRESSBAR_HEIGHT,n=(i.SetColorFillMode(),e?i.SetColorRgba(1,0,0,1):i.SetColorRgba(.118,.565,1,1),this._canvasCssWidth/2),a=this._canvasCssHeight/2,o=t/2,l=r/2;tempRect.setWH(n-o,a-l+s,Math.floor(t*this._loadingProgress),r),i.Rect(tempRect),tempRect.setWH(n-o,a-l+s,t,r),tempRect.offset(-.5,-.5),tempRect.inflate(.5,.5),i.SetColorRgba(0,0,0,1),i.LineRect2(tempRect),tempRect.inflate(1,1),i.SetColorRgba(1,1,1,1),i.LineRect2(tempRect)}_DrawProgressBarAndLogoLoadingScreen(e){const t=this.GetRenderer(),s=this._runtime.GetLoadingLogoAsset();if(s){const i=s.GetTexture();if(i){const r=i.GetWidth(),n=i.GetHeight(),a=this._canvasCssWidth/2,o=this._canvasCssHeight/2,l=r/2,h=n/2;tempQuad.setRect(a-l,o-h,a+l,o+h),t.SetTexture(i),t.Quad(tempQuad),this._DrawProgressBarLoadingScreen(e,r,16+h)}else this._DrawProgressBarLoadingScreen(e,PROGRESSBAR_WIDTH,0)}else this._DrawProgressBarLoadingScreen(e,PROGRESSBAR_WIDTH,0)}_DrawSplashLoadingScreen(e){let t=this.GetRenderer(),s=this._splashTextures.logo,i=this._splashTextures.powered,r=this._splashTextures.website,n=Date.now(),a=(0===this._splashFrameNumber&&(this._loaderStartTime=n),this._runtime.IsPreview()||this._runtime.IsFBInstantAvailable()&&!this._runtime.IsCordova()),o=a?0:SPLASH_AFTER_FADEOUT_WAIT_TIME,l=a?0:SPLASH_MIN_DISPLAY_TIME,h=1,c=("fade-in"===this._splashState?h=Math.min((n-this._loaderStartTime)/SPLASH_FADE_DURATION,1):"fade-out"===this._splashState&&(h=Math.max(1-(n-this._splashFadeOutStartTime)/SPLASH_FADE_DURATION,0)),t.SetColorFillMode(),t.SetColorRgba(.231*h,.251*h,.271*h,h),tempRect.set(0,0,this._canvasCssWidth,this._canvasCssHeight),t.Rect(tempRect),Math.ceil(this._canvasCssWidth)),u=Math.ceil(this._canvasCssHeight),_,d;256<this._canvasCssHeight?(t.SetColorRgba(.302*h,.334*h,.365*h,h),_=c,d=Math.max(.005*u,2),tempRect.setWH(0,.8*u-d/2,_,d),t.Rect(tempRect),e?t.SetColorRgba(h,0,0,h):t.SetColorRgba(.161*h,.953*h,.816*h,h),_=c*this._loadingProgress,tempRect.setWH(.5*c-_/2,.8*u-d/2,_,d),t.Rect(tempRect),t.SetColorRgba(h,h,h,h),t.SetTextureFillMode(),i&&(_=1.5*C33.clamp(.22*u,105,.6*c),d=_/8,tempRect.setWH(.5*c-_/2,.2*u-d/2,_,d),t.SetTexture(i),t.Rect(tempRect)),s&&(_=Math.min(.395*u,.95*c),d=_,tempRect.setWH(.5*c-_/2,.485*u-d/2,_,d),t.SetTexture(s),t.Rect(tempRect)),r&&(_=1.5*C33.clamp(.22*u,105,.6*c),d=_/8,tempRect.setWH(.5*c-_/2,.868*u-d/2,_,d),t.SetTexture(r),t.Rect(tempRect))):(t.SetColorRgba(.302*h,.334*h,.365*h,h),_=c,d=Math.max(.005*u,2),tempRect.setWH(0,.85*u-d/2,_,d),t.Rect(tempRect),e?t.SetColorRgba(h,0,0,h):t.SetColorRgba(.161*h,.953*h,.816*h,h),_=c*this._loadingProgress,tempRect.setWH(.5*c-_/2,.85*u-d/2,_,d),t.Rect(tempRect),t.SetColorRgba(h,h,h,h),t.SetTextureFillMode(),s&&(_=.55*u,d=_,tempRect.setWH(.5*c-_/2,.45*u-d/2,_,d),t.SetTexture(s),t.Rect(tempRect))),this._splashFrameNumber++,"fade-in"===this._splashState&&n-this._loaderStartTime>=SPLASH_FADE_DURATION&&2<=this._splashFrameNumber&&(this._splashState="wait",this._splashFadeInFinishTime=n),"wait"===this._splashState&&n-this._splashFadeInFinishTime>=l&&1<=this._loadingProgress&&(this._splashState="fade-out",this._splashFadeOutStartTime=n),("fade-out"===this._splashState&&n-this._splashFadeOutStartTime>=SPLASH_FADE_DURATION+o||a&&1<=this._loadingProgress&&n-this._loaderStartTime<500)&&this._splashDoneResolve()}}}{let C33=self.C3,C3Debugger=self.C3Debugger,assert=self.assert,ISDKBehaviorInstanceBase=self.ISDKBehaviorInstanceBase,DEFAULT_RUNTIME_OPTS={messagePort:null,runtimeBaseUrl:"",headless:!1,hasDom:!0,isInWorker:!1,useAudio:!0,exportType:""},ife=!0;C33.Runtime=class extends C33.DefendedBase{constructor(e){e=Object.assign({},DEFAULT_RUNTIME_OPTS,e),super(),this._messagePort=e.messagePort,this._runtimeBaseUrl=e.runtimeBaseUrl,this._previewUrl=e.previewUrl,this._isHeadless=!!e.headless,this._hasDom=!!e.hasDom,this._isInWorker=!!e.isInWorker,ife=e.ife,this._useAudio=!!e.useAudio,this._exportType=e.exportType,this._isNWjs=e.isNWjs,this._isiOSCordova=!!e.isiOSCordova,this._isiOSWebView=!!e.isiOSWebView,this._isWindowsWebView2=!!e.isWindowsWebView2,this._isAnyWebView2Wrapper=!!e.isAnyWebView2Wrapper,this._isFBInstantAvailable=!!e.isFBInstantAvailable,this._isDebug=!("preview"!==this._exportType||!e.isDebug),this._breakpointsEnabled=this._isDebug,this._isDebugging=this._isDebug,this._debuggingDisabled=0,this._additionalLoadPromises=[],this._additionalCreatePromises=[],this._isUsingCreatePromises=!1,this._projectName="",this._projectVersion="",this._projectUniqueId="",this._appId="",this._exportTimestamp=0,this._originalViewportWidth=0,this._originalViewportHeight=0,this._devicePixelRatio=self.devicePixelRatio,this._parallaxXorigin=0,this._parallaxYorigin=0,this._viewportWidth=0,this._viewportHeight=0,this._loaderStyle=0,this._usesLoaderLayout=!1,this._isLoading=!0,this._usesAnyBackgroundBlending=!1,this._usesAnyCrossSampling=!1,this._usesAnyDepthSampling=!1,this._loadingLogoAsset=null,this._assetManager=C33.New(C33.AssetManager,this,e),this._layoutManager=C33.New(C33.LayoutManager,this),this._eventSheetManager=C33.New(C33.EventSheetManager,this),this._addonManager=C33.New(C33.AddonManager,this,e.wrapperComponentIds),this._collisionEngine=C33.New(C33.CollisionEngine,this),this._timelineManager=C33.New(C33.TimelineManager,this),this._transitionManager=C33.New(C33.TransitionManager,this),this._templateManager=C33.New(C33.TemplateManager,this),this._flowchartManager=C33.New(C33.FlowchartManager,this),this._textIconManager=C33.New(C33.TextIconManager,{getIconSetMeta:e=>this._GetTextIconSetMeta(e),getIconSetContent:e=>this._GetTextIconSetContent(e)}),this._iconChangeHandlers=new Map,this._allObjectClasses=[],this._objectClassesByName=new Map,this._objectClassesBySid=new Map,this._familyCount=0,this._allContainers=[],this._allEffectLists=new Set,this._currentLayoutStack=[],this._instancesPendingCreate=[],this._instancesPendingDestroy=new Map,this._hasPendingInstances=!1,this._isFlushingPendingInstances=!1,this._objectCount=0,this._nextUid=0,this._instancesByUid=new Map,this._instancesPendingRelease=new Set,this._instancesPendingReleaseAffectedObjectClasses=new Set,this._objectReferenceTable=[],this._jsPropNameTable=[],this._canvasManager=null,this._uses3dFeatures=!1,this._framerateMode="vsync",this._sampling="trilinear",this._isPixelRoundingEnabled=!1,this._needRender=!0,this._pauseOnBlur=!1,this._isPausedOnBlur=!1,this._exportToVideo=null,this._tickCallbacks={normal:e=>{this._rafId=-1,this._ruafId=-1,this.Tick(e)},tickOnly:e=>{this._ruafId=-1,this.Tick(e,!1,"skip-render")},renderOnly:()=>{this._rafId=-1,this.Render()}},this._rafId=-1,this._ruafId=-1,this._tickCount=0,this._tickCountNoSave=0,this._hasStarted=!1,this._isInTick=!1,this._hasStartedTicking=!1,this._isLayoutFirstTick=!0,this._isAutoSuspendEnabled=!0,this._isPageVisibilitySuspended=!1,this._suspendCount=0,this._scheduleTriggersThrottle=new C33.PromiseThrottle(1),this._randomNumberCallback=()=>Math.random(),this._startTime=0,this._lastTickTime=0,this._dtRaw=0,this._dt1=0,this._dt=0,this._timeScale=1,this._maxDt=1/30,this._minDt=0,this._gameTime=C33.New(C33.KahanSum),this._gameTimeRaw=C33.New(C33.KahanSum),this._wallTime=C33.New(C33.KahanSum),this._instanceTimes=new Map,this._fpsFrameCount=-1,this._fpsLastTime=0,this._fps=0,this._tpsTickCount=-1,this._tps=0,this._mainThreadTimeCounter=0,this._mainThreadTime=0,this._isLoadingState=!1,this._saveToSlotName="",this._saveToJsonString=!1,this._loadFromSlotName="",this._loadFromJson=null,this._lastSaveJson="",this._projectStorage=null,this._savegamesStorage=null,this._dispatcher=C33.New(C33.Event.Dispatcher),this._domEventHandlers=new Map,this._pendingResponsePromises=new Map,this._nextDomResponseId=0,this._didRequestDeviceOrientationEvent=!1,this._didRequestDeviceMotionEvent=!1,this._isReadyToHandleEvents=!1,this._waitingToHandleEvents=[],this._eventObjects={pretick:C33.New(C33.Event,"pretick",!1),tick:C33.New(C33.Event,"tick",!1),tick2:C33.New(C33.Event,"tick2",!1),instancecreate:C33.New(C33.Event,"instancecreate",!1),instancedestroy:C33.New(C33.Event,"instancedestroy",!1),beforelayoutchange:C33.New(C33.Event,"beforelayoutchange",!1),layoutchange:C33.New(C33.Event,"layoutchange",!1)},this._eventObjects.instancecreate.instance=null,this._eventObjects.instancedestroy.instance=null,this._userScriptDispatcher=C33.New(C33.Event.Dispatcher),this._userScriptEventObjects=null;const t=(e,t)=>C33.BehaviorInstance.SortByTickSequence(this,e,t);this._behInstsToTick=C33.New(C33.RedBlackSet,t),this._behInstsToPostTick=C33.New(C33.RedBlackSet,t),this._behInstsToTick2=C33.New(C33.RedBlackSet,t),this._jobScheduler=C33.New(C33.JobSchedulerRuntime,this,e.jobScheduler),e.canvas&&(this._canvasManager=C33.New(C33.CanvasManager,this)),this._messagePort.onmessage=e=>this._OnMessageFromDOM(e.data),this.AddDOMComponentMessageHandler("runtime","visibilitychange",e=>this._OnVisibilityChange(e)),this.AddDOMComponentMessageHandler("runtime","wrapper-extension-message",e=>this._OnWrapperExtensionMessage(e)),this.AddDOMComponentMessageHandler("runtime","get-remote-preview-status-info",()=>this._GetRemotePreviewStatusInfo()),this.AddDOMComponentMessageHandler("runtime","js-invoke-function",e=>this._InvokeFunctionFromJS(e)),this.AddDOMComponentMessageHandler("runtime","go-to-last-error-script",self.goToLastErrorScript),this.AddDOMComponentMessageHandler("runtime","offline-audio-render-completed",e=>this._OnOfflineAudioRenderCompleted(e)),this._dispatcher.addEventListener("window-blur",e=>this._OnWindowBlur(e)),this._dispatcher.addEventListener("window-focus",()=>this._OnWindowFocus()),this._timelineManager.AddRuntimeListeners(),this._templateManager.AddRuntimeListeners(),this._iRuntime=null,this._interfaceMap=new WeakMap,this._commonScriptInterfaces={keyboard:null,mouse:null,touch:null,timelineController:null},this._instancesNeedingAfterLoadMap=new WeakMap,this._instancesNeedingAfterLoadArray=[]}static Create(e){return C33.New(C33.Runtime,e)}Release(){C33.clearArray(this._allObjectClasses),this._objectClassesByName.clear(),this._objectClassesBySid.clear(),this._layoutManager.Release(),this._layoutManager=null,this._eventSheetManager.Release(),this._eventSheetManager=null,this._addonManager.Release(),this._addonManager=null,this._assetManager.Release(),this._assetManager=null,this._collisionEngine.Release(),this._collisionEngine=null,this._timelineManager.Release(),this._timelineManager=null,this._transitionManager.Release(),this._transitionManager=null,this._templateManager.Release(),this._templateManager=null,this._flowchartManager.Release(),this._flowchartManager=null,this._textIconManager.Release(),this._textIconManager=null,this._canvasManager&&(this._canvasManager.Release(),this._canvasManager=null),this._dispatcher.Release(),this._dispatcher=null,this._tickEvent=null}["_OnMessageFromDOM"](e){const t=e.type;if("event"===t)this._OnEventFromDOM(e);else{if("result"!==t)throw new Error(`unknown message '${t}'`);this._OnResultFromDOM(e)}}_OnEventFromDOM(e){if(this._isReadyToHandleEvents){const t=e.component,s=e.handler,i=e.data,r=e.dispatchOpts,n=!(!r||!r.dispatchRuntimeEvent),a=!(!r||!r.dispatchUserScriptEvent),o=e.responseId;if("runtime"===t){if(n){const h=new C33.Event(s);h.data=i,this._dispatcher.dispatchEventAndWaitAsyncSequential(h)}if(a){const c=new C33.Event(s,!0);for(const[u,_]of Object.entries(i))c[u]=_;this.DispatchUserScriptEvent(c)}}const l=this._domEventHandlers.get(t);if(l){const d=l.get(s);if(d){let e=null;try{e=d(i)}catch(e){return console.error(`Exception in '${t}' handler '${s}':`,e),void(null!==o&&this._PostResultToDOM(o,!1,""+e))}null!==o&&(e&&e.then?e.then(e=>this._PostResultToDOM(o,!0,e)).catch(e=>{console.error(`Rejection from '${t}' handler '${s}':`,e),this._PostResultToDOM(o,!1,""+e)}):this._PostResultToDOM(o,!0,e))}else n||a||console.warn(`[Runtime] No DOM handler '${s}' for component '${t}'`)}else n||a||console.warn(`[Runtime] No DOM event handlers for component '${t}'`)}else this._waitingToHandleEvents.push(e)}_PostResultToDOM(e,t,s){this._messagePort.postMessage({type:"result",responseId:e,isOk:t,result:s})}_OnResultFromDOM(e){const t=e.responseId,s=e.isOk,i=e.result,r=this._pendingResponsePromises.get(t);s?r.resolve(i):r.reject(i),this._pendingResponsePromises.delete(t)}AddDOMComponentMessageHandler(e,t,s){let i=this._domEventHandlers.get(e);if(i||(i=new Map,this._domEventHandlers.set(e,i)),i.has(t))throw new Error(`[Runtime] Component '${e}' already has handler '${t}'`);i.set(t,s)}PostComponentMessageToDOM(e,t,s,i){this._messagePort.postMessage({type:"event",component:e,handler:t,data:s,responseId:null},i)}PostComponentMessageToDOMAsync(e,t,s,i){const r=this._nextDomResponseId++,n=new Promise((e,t)=>{this._pendingResponsePromises.set(r,{resolve:e,reject:t})});return this._messagePort.postMessage({type:"event",component:e,handler:t,data:s,responseId:r},i),n}SendWrapperExtensionMessage(e,t,s,i=-1){this.PostComponentMessageToDOM("runtime","send-wrapper-extension-message",{componentId:e,messageId:t,params:s,asyncId:i})}SendWrapperExtensionMessageAsync(e,t,s){const i=this._nextDomResponseId++,r=new Promise((e,t)=>{this._pendingResponsePromises.set(i,{resolve:e,reject:t})});return this.SendWrapperExtensionMessage(e,t,s,i),r}_OnWrapperExtensionMessage(e){if(-1!==e.asyncId){const t=e.asyncId,s=this._pendingResponsePromises.get(t);s.resolve(e.params),this._pendingResponsePromises.delete(t)}else this._OnEventFromDOM({component:"wrapper-extension:"+e.componentId,handler:e.messageId,data:e.params,responseId:null})}AddWrapperExtensionMessageHandler(e,t,s){this.AddDOMComponentMessageHandler("wrapper-extension:"+e,t,s)}HasWrapperComponentId(e){return this._addonManager.HasWrapperComponentId(e)}PostToDebugger(e){if(!this.IsDebug())throw new Error("not in debug mode");this.PostComponentMessageToDOM("runtime","post-to-debugger",e)}async Init(e){C33.CommonACES_SetRuntime(this),this.IsDebug()?await C3Debugger.Init(this):self.C3Debugger&&self.C3Debugger.InitPreview(this);const t=await this._assetManager.FetchJson("data.json");if(await this._LoadDataJson(t),await this._InitialiseCanvas(e),this.IsPreview()||console.info("%cMade with Construct, the game and animation creation tool. Visit: https://www.construct.net","font-weight: bold"),this.GetWebGLRenderer()){const s=this.GetWebGLRenderer();console.info(`[C3 runtime] Hosted in ${this.IsInWorker()?"worker":"DOM"}, rendering with WebGL ${s.GetWebGLVersionNumber()} [${s.GetUnmaskedRenderer()}]`)}else this.GetWebGPURenderer()&&console.info(`[C3 runtime] Hosted in ${this.IsInWorker()?"worker":"DOM"}, rendering with WebGPU [${this.GetWebGPURenderer().GetAdapterInfoString()}]`);this.GetRenderer().HasMajorPerformanceCaveat()&&console.warn("[C3 runtime] The renderer indicates a major performance caveat. Software rendering may be in use. This can result in significantly degraded performance."),this._isReadyToHandleEvents=!0;for(const i of this._waitingToHandleEvents)this._OnEventFromDOM(i);C33.clearArray(this._waitingToHandleEvents),this._canvasManager&&this._canvasManager.StartLoadingScreen();for(const r of e.runOnStartupFunctions)this._additionalLoadPromises.push(this._RunOnStartupFunction(r));if(await Promise.all([this._assetManager.WaitForAllToLoad(),...this._additionalLoadPromises]),C33.clearArray(this._additionalLoadPromises),!this._assetManager.HasHadErrorLoading())return this._canvasManager&&await this._canvasManager.EndLoadingScreen(),await this._dispatcher.dispatchEventAndWaitAsync(new C33.Event("beforeruntimestart")),await this.Start(),this._messagePort.postMessage({type:"runtime-ready"}),this;this._canvasManager&&this._canvasManager.HideCordovaSplashScreen()}async _RunOnStartupFunction(e){try{await e(this._iRuntime)}catch(e){console.error("[C3 runtime] Error in runOnStartup function: ",e)}}async _LoadDataJson(e){const t=e.project,s=(this._projectName=t[0],this._projectVersion=t[16],this._projectUniqueId=t[31],this._appId=t[38],this._exportTimestamp=t[36],t[39]||"loading-logo.png"),i=(this._isPixelRoundingEnabled=!!t[9],this._originalViewportWidth=this._viewportWidth=t[10],this._originalViewportHeight=this._viewportHeight=t[11],this._collisionEngine._InitCollisionCellSize(this._originalViewportWidth,this._originalViewportHeight),this._parallaxXorigin=this._originalViewportWidth/2,this._parallaxYorigin=this._originalViewportHeight/2,this._framerateMode=t[37],this._uses3dFeatures=!!t[40],this._sampling=t[14],this._usesAnyBackgroundBlending=t[15],this._usesAnyCrossSampling=t[42],this._usesAnyDepthSampling=t[17],this._usesLoaderLayout=!!t[18],this._loaderStyle=t[19],this._nextUid=t[21],this._pauseOnBlur=t[22],this._assetManager);if(i._SetFileStructure(t[45]),i._SetAudioFiles(t[7],t[25]),i._SetMediaSubfolder(t[8]),i._SetFontsSubfolder(t[32]),i._SetIconsSubfolder(t[28]),i._SetWebFonts(t[29]),0===this._loaderStyle){let e;(e="flat"===i.GetFileStructure()?i.GetIconsSubfolder()+s:s)&&(this._loadingLogoAsset=i.LoadImage({url:e}))}this._canvasManager&&(this._canvasManager.SetFullscreenMode(C33.CanvasManager._FullscreenModeNumberToString(t[12])),this._canvasManager.SetFullscreenScalingQuality(t[23]?"high":"low"),this._canvasManager.SetMipmapsEnabled(0!==t[24]),this._canvasManager._SetGPUPowerPreference(t[34]),this._canvasManager._SetTextureAnisotropy(t[41]),this._canvasManager._SetWebGPUEnabled(t[13]),this._canvasManager._SetZAxisScale(t[30]),this._canvasManager._SetZDistances(t[46],t[47]),this._canvasManager._SetInitFieldOfView(t[26]),this._canvasManager._SetLimitedToWebGL1(t[48]),this._canvasManager._SetMultitexturingMode(t[50]));const r=t[43],n=(r&&await this._LoadExportToVideoData(r),this._InitScriptInterfaces(),this._addonManager.CreateSystemPlugin(),this._objectReferenceTable=self.C3_GetObjectRefTable(),t[2]);for(const h of n[1])this._addonManager.CreateBehavior(h);for(const c of n[0])this._addonManager.CreatePlugin(c);this._objectReferenceTable=self.C3_GetObjectRefTable(),this._LoadJsPropNameTable(),this._addonManager._InitAddonScriptInterfaces();for(const u of t[3]){const _=C33.ObjectClass.Create(this,this._allObjectClasses.length,u);this._allObjectClasses.push(_),this._objectClassesByName.set(_.GetName().toLowerCase(),_),this._objectClassesBySid.set(_.GetSID(),_)}for(const d of t[4]){const p=this._allObjectClasses[d[0]];p._LoadFamily(d)}for(const m of t[27]){const g=m.map(e=>this._allObjectClasses[e]);this._allContainers.push(C33.New(C33.Container,this,g))}this._InitObjectsScriptInterface();for(const f of this._allObjectClasses)f._OnAfterCreate();for(const S of t[5])this._layoutManager.Create(S);const a=t[1];if(a){const C=this._layoutManager.GetLayoutByName(a);C&&this._layoutManager.SetFirstLayout(C)}for(const y of t[35])this._transitionManager.Create(y);for(const G of t[33])this._timelineManager.Create(G);for(const I of t[44])this._templateManager.Create(I);this._templateManager.HasTemplates()||(this._templateManager.Release(),this._templateManager=null);for(const T of t[49])this._flowchartManager.Create(T);this._flowchartManager.HasFlowcharts()||(this._flowchartManager.Release(),this._flowchartManager=null);for(const b of t[6])this._eventSheetManager.Create(b);this._eventSheetManager._PostInit(),this._InitGlobalVariableScriptInterface(),C33.clearArray(this._objectReferenceTable),this.FlushPendingInstances();let o="any",l=t[20];1===l?o="portrait":2===l&&(o="landscape"),this.PostComponentMessageToDOM("runtime","set-target-orientation",{targetOrientation:o})}async _LoadExportToVideoData(e){const t=e.format;"image-sequence"===t?this._exportToVideo=new self.C3ExportToImageSequence(this,e):"image-sequence-gif"===t?this._exportToVideo=new self.C3ExportToGIF(this,e):"webm"===t?this._exportToVideo=new self.C3ExportToWebMVideo(this,e):"mp4"===t&&(this._exportToVideo=new self.C3ExportToMP4Video(this,e)),this._framerateMode="unlimited-frame",this._canvasManager.SetFullscreenMode("off"),this._devicePixelRatio=1,self.devicePixelRatio=1,await this.PostComponentMessageToDOMAsync("runtime","set-exporting-to-video",{message:this._exportToVideo.GetExportingMessageForPercent(0),duration:this._exportToVideo.GetDuration()})}GetLoaderStyle(){return this._loaderStyle}IsExportToVideo(){return null!==this._exportToVideo}GetExportVideoDuration(){return this._exportToVideo.GetDuration()}GetExportVideoFramerate(){return this._exportToVideo.GetFramerate()}_InitExportToVideo(){return this._exportToVideo.Init({width:this._canvasManager.GetDeviceWidth(),height:this._canvasManager.GetDeviceHeight()})}_ExportToVideoAddFrame(){const e=this._tickCount/this.GetExportVideoFramerate();return this._exportToVideo.AddFrame(this._canvasManager.GetMainCanvas(),e)}_ExportToVideoAddKeyframe(){this._exportToVideo&&this._exportToVideo.AddKeyframe()}_OnOfflineAudioRenderCompleted(e){this._exportToVideo.OnOfflineAudioRenderCompleted(e)}_ExportToVideoFinish(){return this._exportToVideo.Finish()}IsFBInstantAvailable(){return this._isFBInstantAvailable}IsLoading(){return this._isLoading}AddLoadPromise(e){this._additionalLoadPromises.push(e)}SetUsingCreatePromises(e){this._isUsingCreatePromises=!!e}AddCreatePromise(e){this._isUsingCreatePromises&&this._additionalCreatePromises.push(e)}GetCreatePromises(){return this._additionalCreatePromises}_GetNextFamilyIndex(){return this._familyCount++}GetFamilyCount(){return this._familyCount}_AddEffectList(e){this._allEffectLists.add(e)}_RemoveEffectList(e){this._allEffectLists.delete(e)}_GetAllEffectLists(){return this._allEffectLists}async _InitialiseCanvas(e){this._canvasManager&&(await this._canvasManager.CreateCanvas(e),this._canvasManager.InitLoadingScreen(this._loaderStyle))}async Start(){this._hasStarted=!0,this._startTime=Date.now();let t=null,e=new Promise(e=>t=e);if(this._usesLoaderLayout){for(const r of this._allObjectClasses)r.IsFamily()||r.IsOnLoaderLayout()||!r.IsWorldType()||r.OnCreate();(async()=>{await this._assetManager.WaitForAllToLoad(),await e,this._isLoading=!1,this._OnLoadFinished()})()}else this._isLoading=!1;this._assetManager.SetInitialLoadFinished(),this.IsDebug()&&C3Debugger.RuntimeInit(ife);for(const n of this._layoutManager.GetAllLayouts())n._CreateGlobalNonWorlds();this.IsExportToVideo()&&await this._InitExportToVideo();const s=this._layoutManager.GetFirstLayout(),i=(await s._Load(null,this.GetRenderer()),await s._StartRunning(!0),this._fpsLastTime=performance.now(),t(),this._usesLoaderLayout||this._OnLoadFinished(),await this.PostComponentMessageToDOMAsync("runtime","before-start-ticking"));i.isSuspended&&!this.IsExportToVideo()?(this._suspendCount++,this._isPageVisibilitySuspended=!0):this.Tick()}_OnLoadFinished(){this.Trigger(C33.Plugins.System.Cnds.OnLoadFinished,null,null),this.PostComponentMessageToDOM("runtime","register-sw")}GetObjectReference(e){e=Math.floor(e);const t=this._objectReferenceTable;if(e<0||e>=t.length)throw new Error("invalid object reference");return t[e]}_LoadJsPropNameTable(){for(const e of self.C3_JsPropNameTable){const t=C33.first(Object.keys(e));this._jsPropNameTable.push(t)}}GetJsPropName(e){e=Math.floor(e);const t=this._jsPropNameTable;if(e<0||e>=t.length)throw new Error("invalid prop reference");return t[e]}HasDOM(){return this._hasDom}IsHeadless(){return this._isHeadless}IsInWorker(){return this._isInWorker}GetRuntimeBaseURL(){return this._runtimeBaseUrl}GetPreviewURL(){return this._previewUrl}GetEventSheetManager(){return this._eventSheetManager}GetEventStack(){return this._eventSheetManager.GetEventStack()}GetCurrentEventStackFrame(){return this._eventSheetManager.GetCurrentEventStackFrame()}GetCurrentEvent(){return this._eventSheetManager.GetCurrentEvent()}GetCurrentCondition(){return this._eventSheetManager.GetCurrentCondition()}IsCurrentConditionFirst(){return 0===this.GetCurrentEventStackFrame().GetConditionIndex()}GetCurrentAction(){return this._eventSheetManager.GetCurrentAction()}GetAddonManager(){return this._addonManager}GetSystemPlugin(){return this._addonManager.GetSystemPlugin()}GetObjectClassByIndex(e){if((e=Math.floor(e))<0||e>=this._allObjectClasses.length)throw new RangeError("invalid index");return this._allObjectClasses[e]}GetObjectClassByName(e){return this._objectClassesByName.get(e.toLowerCase())||null}GetObjectClassBySID(e){return this._objectClassesBySid.get(e)||null}GetSingleGlobalObjectClassByCtor(e){const t=C33.AddonManager.GetPluginByConstructorFunction(e);return t?t.GetSingleGlobalObjectClass():null}GetAllObjectClasses(){return this._allObjectClasses}*allInstances(){for(const e of this._allObjectClasses)e.IsFamily()||(yield*e.instances())}Dispatcher(){return this._dispatcher}UserScriptDispatcher(){return this._userScriptDispatcher}DispatchUserScriptEvent(e){e.runtime=this.GetIRuntime();const t=this.IsDebug()&&!this._eventSheetManager.IsInEventEngine();t&&C3Debugger.StartMeasuringScriptTime(),this._userScriptDispatcher.dispatchEvent(e),t&&C3Debugger.AddScriptTime()}DispatchUserScriptEventAsyncWait(e){return e.runtime=this.GetIRuntime(),this._userScriptDispatcher.dispatchEventAndWaitAsync(e)}GetOriginalViewportWidth(){return this._originalViewportWidth}GetOriginalViewportHeight(){return this._originalViewportHeight}SetOriginalViewportSize(e,t){if(this._originalViewportWidth!==e||this._originalViewportHeight!==t){this._originalViewportWidth=e,this._originalViewportHeight=t;const s=this.GetLayoutManager();s.SetAllLayerProjectionChanged(),s.SetAllLayerMVChanged()}}GetViewportWidth(){return this._viewportWidth}GetViewportHeight(){return this._viewportHeight}SetViewportSize(e,t){if(this._viewportWidth!==e||this._viewportHeight!==t){this._viewportWidth=e,this._viewportHeight=t;const s=this.GetLayoutManager();s.SetAllLayerProjectionChanged(),s.SetAllLayerMVChanged()}}_SetDevicePixelRatio(e){this.IsExportToVideo()||(this._devicePixelRatio=e)}GetDevicePixelRatio(){return this._devicePixelRatio}GetParallaxXOrigin(){return this._parallaxXorigin}GetParallaxYOrigin(){return this._parallaxYorigin}GetCanvasManager(){return this._canvasManager}GetDrawWidth(){return this._canvasManager?this._canvasManager.GetDrawWidth():this._viewportWidth}GetDrawHeight(){return this._canvasManager?this._canvasManager.GetDrawHeight():this._viewportHeight}GetRenderScale(){return this._canvasManager?this._canvasManager.GetRenderScale():1}GetDisplayScale(){return this._canvasManager?this._canvasManager.GetDisplayScale():1}GetEffectLayerScaleParam(){return this._canvasManager?this._canvasManager.GetEffectLayerScaleParam():1}GetEffectDevicePixelRatioParam(){return this._canvasManager?this._canvasManager.GetEffectDevicePixelRatioParam():1}GetCanvasClientX(){return this._canvasManager?this._canvasManager.GetCanvasClientX():0}GetCanvasClientY(){return this._canvasManager?this._canvasManager.GetCanvasClientY():0}GetCanvasCssWidth(){return this._canvasManager?this._canvasManager.GetCssWidth():0}GetCanvasCssHeight(){return this._canvasManager?this._canvasManager.GetCssHeight():0}GetFullscreenMode(){return this._canvasManager?this._canvasManager.GetFullscreenMode():"off"}GetAdditionalRenderTarget(e){return this._canvasManager?this._canvasManager.GetAdditionalRenderTarget(e):null}ReleaseAdditionalRenderTarget(e){this._canvasManager&&this._canvasManager.ReleaseAdditionalRenderTarget(e)}UsesAnyBackgroundBlending(){return this._usesAnyBackgroundBlending}UsesAnyCrossSampling(){return this._usesAnyCrossSampling}UsesAnyDepthSampling(){return this._usesAnyDepthSampling}GetGPUUtilisation(){return this._canvasManager?this._canvasManager.GetGPUUtilisation():NaN}IsLinearSampling(){return"nearest"!==this.GetSampling()}GetFramerateMode(){return this._framerateMode}_SetFramerateMode(e){this._framerateMode!==e&&(this._framerateMode=e,-1!==this._rafId||-1!==this._ruafId)&&(this._CancelAnimationFrame(),this._RequestAnimationFrame())}GetSampling(){return this._sampling}UsesLoaderLayout(){return this._usesLoaderLayout}GetLoadingLogoAsset(){return this._loadingLogoAsset}ReleaseLoadingLogoAsset(){this._loadingLogoAsset&&(this._loadingLogoAsset.ReleaseTexture(),this._loadingLogoAsset.Release(),this._loadingLogoAsset=null)}GetLayoutManager(){return this._layoutManager}GetMainRunningLayout(){return this._layoutManager.GetMainRunningLayout()}GetTimelineManager(){return this._timelineManager}GetTransitionManager(){return this._transitionManager}GetTemplateManager(){return this._templateManager}GetFlowchartManager(){return this._flowchartManager}GetAssetManager(){return this._assetManager}LoadImage(e){return this._assetManager.LoadImage(e)}CreateInstance(e,t,s,i,r,n){if(n&&this._templateManager){if(e instanceof C33.ObjectClass&&e.IsFamily()){const o=e.GetFamilyMembers(),l=Math.floor(this.Random()*o.length);return this.CreateInstance(o[l],t,s,i,r,n)}const a=this._templateManager.GetTemplateData(e,n);if(a){const h=this.CreateInstanceFromData(a,t,!1,s,i,!1,r,void 0,r);return this._templateManager.MapInstanceToTemplateName(h,n),h}}return this.CreateInstanceFromData(e,t,!1,s,i,!1,r,void 0,r)}CreateInstanceFromData(e,t,s,i,r,n,a,o,l){let h=null,c=null;if(e instanceof C33.ObjectClass){if((c=e).IsFamily()){const y=c.GetFamilyMembers(),G=Math.floor(this.Random()*y.length);c=y[G]}h=c.GetDefaultInstanceData()}else h=e,c=this.GetObjectClassByIndex(h[1]);const u=c.GetPlugin().IsWorldType();if(this._isLoading&&u&&!c.IsOnLoaderLayout())return null;const _=t;u||(t=null);let d;d=s&&!n&&h&&!this._instancesByUid.has(h[2])?h[2]:this._nextUid++;const p=h?h[0]:null,m=C33.New(C33.Instance,{runtime:this,objectType:c,layer:t,worldData:p,instVarData:h?h[3]:null,uid:d,tags:h?h[6]:null});this._instancesByUid.set(d,m);let g=null,f=(u&&(g=m.GetWorldInfo(),void 0!==i&&void 0!==r&&(g.SetX(i),g.SetY(r)),c._SetAnyCollisionCellChanged(!0)),t&&(l||t._AddInstance(m,!0),t.GetLayout().MaybeLoadTexturesFor(c)),this._objectCount++,!0);if(o){const I=o.GetObjectClass();if(I.IsInContainer()&&c.IsInContainer()){const T=c.GetContainer(),b=I.GetContainer();T===b&&(f=!1)}}if(c.IsInContainer()&&!s&&!n&&f){const A=new Set;for(const P of c.GetContainer().objectTypes())if(P!==c){const R=this._MaybeGetChildInstanceForObjectTypeData(P,g,A);if(R){const x=this.CreateInstanceFromData(R,_,!1,g?g.GetX():i,g?g.GetY():r,!0,!1,void 0,l);m._AddSibling(x)}else{const k=this.CreateInstanceFromData(P,_,!1,g?g.GetX():i,g?g.GetY():r,!0,!1,void 0,l);m._AddSibling(k)}}for(const E of m.siblings()){E._AddSibling(m);for(const v of m.siblings())E!==v&&E._AddSibling(v)}}if(u&&!s&&a&&this._CreateChildInstancesFromData(m,p,g,t,i,r,l),c.IsInContainer()&&!s&&!n&&a)for(const w of m.siblings()){const M=w.GetWorldInfo();if(M){const N=w.GetPlugin(),D=w.GetObjectClass().GetDefaultInstanceData()[0];N.IsWorldType()?this._CreateChildInstancesFromData(w,D,M,t,M.GetX(),M.GetY(),l):this._CreateChildInstancesFromData(w,D,M,t,void 0,void 0,l)}}if(!n&&a){void 0===i&&(i=p[0]),void 0===r&&(r=p[1]);const O=g.GetTopParent(),W=i-g.GetX()+O.GetX(),V=r-g.GetY()+O.GetY();O.SetXY(W,V)}c._SetIIDsStale();const F=h?C33.cloneArray(h[5]):null,B=h?h[4].map(e=>C33.cloneArray(e)):null,S=u&&p&&p[13];if(S&&m._SetHasTilemap(),m._CreateSdkInstance(F,B),S){const L=p[13];m.GetSdkInstance().LoadTilemapData(L[2],L[0],L[1])}this._instancesPendingCreate.push(m),this._hasPendingInstances=!0,this.IsDebug()&&C3Debugger.InstanceCreated(m);const C=this._eventObjects.instancecreate;return C.instance=m,this._dispatcher.dispatchEvent(C),m}_GetInstanceData(e){const t=e[0],s=e[1],i=e[2],r=e[6];if(r)return r;const n=this._layoutManager.GetLayoutBySID(t),a=n.GetLayer(s);return a.GetInitialInstanceData(i)}_MaybeGetChildInstanceForObjectTypeData(e,t,s){const i=t?.GetSceneGraphChildrenExportData()??[];for(const r of i){const n=this._GetInstanceData(r),a=!!r[4],o=this.GetObjectClassByIndex(n[1]);if(!s.has(n)&&e===o&&a)return s.add(n),n}}_CreateChildInstancesFromData(l,e,t,h,c,u,_){const s=t.GetSceneGraphZIndexExportData(),i=t.GetSceneGraphChildrenExportData();if(l.GetWorldInfo().SetSceneGraphZIndex(s),i){void 0===c&&(c=e[0]),void 0===u&&(u=e[1]);const d=new Set,p=e[0],m=e[1];for(const g of i){let e=g[0],t=g[1],s=g[2],i=g[3],r=!!g[4],n=g[5],a=g[6],o;if(a)o=a;else{const y=this._layoutManager.GetLayoutBySID(e),G=y.GetLayer(t);o=G.GetInitialInstanceData(s)}const f=this.GetObjectClassByIndex(o[1]),S=l.HasSibling(f),C=d.has(f);if(S&&!C&&r){const I=l.GetSibling(f),T=(I.GetWorldInfo().Init(o[0]),c+o[0][0]-p),b=u+o[0][1]-m;I.GetWorldInfo().SetXY(T,b),I.GetWorldInfo().SetSceneGraphZIndex(n),l.AddChild(I,{transformX:!!(i>>0&1),transformY:!!(i>>1&1),transformWidth:!!(i>>2&1),transformHeight:!!(i>>3&1),transformAngle:!!(i>>4&1),destroyWithParent:!!(i>>5&1),transformZElevation:!!(i>>6&1),transformOpacity:!!(i>>7&1),transformVisibility:!!(i>>8&1)}),d.add(f)}else{const A=c+o[0][0]-p,P=u+o[0][1]-m,R=this.CreateInstanceFromData(o,h,!1,A,P,!1,!0,l,_);R.GetWorldInfo().SetSceneGraphZIndex(n),l.AddChild(R,{transformX:!!(i>>0&1),transformY:!!(i>>1&1),transformWidth:!!(i>>2&1),transformHeight:!!(i>>3&1),transformAngle:!!(i>>4&1),destroyWithParent:!!(i>>5&1),transformZElevation:!!(i>>6&1),transformOpacity:!!(i>>7&1),transformVisibility:!!(i>>8&1)})}}}}DestroyInstance(s){if(!this._instancesPendingRelease.has(s)){let e=s.GetObjectClass(),t=this._instancesPendingDestroy.get(e);if(t){if(t.has(s))return;t.add(s)}else(t=new Set).add(s),this._instancesPendingDestroy.set(e,t);if(this.IsDebug()&&C3Debugger.InstanceDestroyed(s),s._MarkDestroyed(),this._hasPendingInstances=!0,s.IsInContainer())for(const i of s.siblings())this.DestroyInstance(i);for(const r of s.children())r.GetDestroyWithParent()&&this.DestroyInstance(r);if(!this._layoutManager.IsEndingLayout()&&!this._isLoadingState){const n=this.GetEventSheetManager();n.BlockFlushingInstances(!0),s._TriggerOnDestroyed(),n.BlockFlushingInstances(!1)}s._FireDestroyedScriptEvents(this._layoutManager.IsEndingLayout())}}FlushPendingInstances(){this._hasPendingInstances&&(this._isFlushingPendingInstances=!0,this._FlushInstancesPendingCreate(),this._FlushInstancesPendingDestroy(),this._isFlushingPendingInstances=!1,this._hasPendingInstances=!1,this.UpdateRender())}_FlushInstancesPendingCreate(){for(const e of this._instancesPendingCreate){const t=e.GetObjectClass();t._AddInstance(e);for(const s of t.GetFamilies())s._AddInstance(e),s._SetIIDsStale()}C33.clearArray(this._instancesPendingCreate)}_FlushInstancesPendingDestroy(){this._dispatcher.SetDelayRemoveEventsEnabled(!0);for(const[e,t]of this._instancesPendingDestroy.entries())this._FlushInstancesPendingDestroyForObjectClass(e,t),t.clear();this._instancesPendingDestroy.clear(),this._dispatcher.SetDelayRemoveEventsEnabled(!1)}_FlushInstancesPendingDestroyForObjectClass(e,t){for(const s of t){const i=this._eventObjects.instancedestroy,r=(i.instance=s,this._dispatcher.dispatchEvent(i),this._instancesByUid.delete(s.GetUID()),this._instanceTimes.delete(s),s.GetWorldInfo());r&&(r._RemoveFromCollisionCells(),r._RemoveFromRenderCells(),r._MarkDestroyed()),this._instancesPendingRelease.add(s),this._objectCount--}C33.arrayRemoveAllInSet(e.GetInstances(),t),e._SetIIDsStale(),this._instancesPendingReleaseAffectedObjectClasses.add(e);for(const n of e.GetFamilies())C33.arrayRemoveAllInSet(n.GetInstances(),t),n._SetIIDsStale(),this._instancesPendingReleaseAffectedObjectClasses.add(n);if(e.GetPlugin().IsWorldType()){const a=new Set([...t].map(e=>e.GetWorldInfo().GetLayer()));for(const o of a)o._RemoveAllInstancesInSet(t)}}_GetInstancesPendingCreate(){return this._instancesPendingCreate}*instancesPendingCreateForObjectClass(e){for(const t of this._GetInstancesPendingCreate())e.IsFamily()?t.GetObjectClass().BelongsToFamily(e)&&(yield t):t.GetObjectClass()===e&&(yield t)}_GetNewUID(){return this._nextUid++}_MapInstanceByUID(e,t){this._instancesByUid.set(e,t)}_SetAutoSuspendEnabled(e){this._isAutoSuspendEnabled!==(e=!!e)&&(this._isAutoSuspendEnabled=!!e,this._isAutoSuspendEnabled)&&this._isPageVisibilitySuspended&&(this.SetSuspended(!1),this._isPageVisibilitySuspended=!1)}_IsAutoSuspendEnabled(){return this._isAutoSuspendEnabled}_OnRendererContextLost(){this._dispatcher.dispatchEvent(C33.New(C33.Event,"renderercontextlost")),this.SetSuspended(!0);for(const t of this._allObjectClasses)!t.IsFamily()&&t.HasLoadedTextures()&&t.ReleaseTextures();const e=this.GetMainRunningLayout();e&&e._OnRendererContextLost(),C33.ImageInfo.OnRendererContextLost(),C33.ImageAsset.OnRendererContextLost()}async _OnRendererContextRestored(){await this.GetMainRunningLayout()._Load(null,this.GetRenderer()),this._dispatcher.dispatchEvent(C33.New(C33.Event,"renderercontextrestored")),this.SetSuspended(!1),this.UpdateRender()}_OnVisibilityChange(e){if(this._isAutoSuspendEnabled){const t=e.hidden;this.SetSuspended(t),(this._isPageVisibilitySuspended=t)||this.UpdateRender()}}_OnWindowBlur(e){this.IsPreview()&&this._pauseOnBlur&&!C33.Platform.IsMobile&&!e.data.parentHasFocus&&(this.SetSuspended(!0),this._isPausedOnBlur=!0)}_OnWindowFocus(){this._isPausedOnBlur&&(this.SetSuspended(!1),this._isPausedOnBlur=!1)}_RequestAnimationFrame(){const e=this._tickCallbacks;"vsync"===this._framerateMode?-1===this._rafId&&(this._rafId=self.requestAnimationFrame(e.normal)):"unlimited-tick"===this._framerateMode?(-1===this._ruafId&&(this._ruafId=C33.RequestUnlimitedAnimationFrame(e.tickOnly)),-1===this._rafId&&(this._rafId=self.requestAnimationFrame(e.renderOnly))):-1===this._ruafId&&(this._ruafId=C33.RequestUnlimitedAnimationFrame(e.normal))}_CancelAnimationFrame(){-1!==this._rafId&&(self.cancelAnimationFrame(this._rafId),this._rafId=-1),-1!==this._ruafId&&(C33.CancelUnlimitedAnimationFrame(this._ruafId),this._ruafId=-1)}IsSuspended(){return 0<this._suspendCount}SetSuspended(e){if(!this.IsExportToVideo()){const t=this.IsSuspended(),s=(this._suspendCount+=e?1:-1,this._suspendCount<0&&(this._suspendCount=0),this.IsSuspended());if(!t&&s)console.log("[Construct] Suspending"),this._CancelAnimationFrame(),this._dispatcher.dispatchEvent(C33.New(C33.Event,"suspend")),this.Trigger(C33.Plugins.System.Cnds.OnSuspend,null,null);else if(t&&!s){console.log("[Construct] Resuming");const i=performance.now();this._lastTickTime=i,this._fpsLastTime=i,this._fpsFrameCount=0,this._fps=0,this._tpsTickCount=0,this._tps=0,this._mainThreadTime=0,this._mainThreadTimeCounter=0,this._dispatcher.dispatchEvent(C33.New(C33.Event,"resume")),this.Trigger(C33.Plugins.System.Cnds.OnResume,null,null),this.HitBreakpoint()||this.Tick(i)}}}_AddBehInstToTick(e){this._behInstsToTick.Add(e)}_AddBehInstToPostTick(e){this._behInstsToPostTick.Add(e)}_AddBehInstToTick2(e){this._behInstsToTick2.Add(e)}_RemoveBehInstToTick(e){this._behInstsToTick.Remove(e)}_RemoveBehInstToPostTick(e){this._behInstsToPostTick.Remove(e)}_RemoveBehInstToTick2(e){this._behInstsToTick2.Remove(e)}_CallBehaviorTickMethod(e,t){let s=t?performance.now():0,i;return e instanceof ISDKBehaviorInstanceBase?(i=e._tick(),t&&C3Debugger.AddIndividualBehaviorTickTime(e.behavior,performance.now()-s)):(i=e.Tick(),t&&C3Debugger.AddIndividualBehaviorTickTime(e.GetBehavior(),performance.now()-s)),i}_BehaviorTick(){const e=this.IsDebug();this._behInstsToTick.SetQueueingEnabled(!0);for(const t of this._behInstsToTick)this._CallBehaviorTickMethod(t,e);this._behInstsToTick.SetQueueingEnabled(!1)}_CallBehaviorPostTickMethod(e,t){let s=t?performance.now():0,i;return e instanceof ISDKBehaviorInstanceBase?(i=e._postTick(),t&&C3Debugger.AddIndividualBehaviorTickTime(e.behavior,performance.now()-s)):(i=e.PostTick(),t&&C3Debugger.AddIndividualBehaviorTickTime(e.GetBehavior(),performance.now()-s)),i}_BehaviorPostTick(){const e=this.IsDebug();this._behInstsToPostTick.SetQueueingEnabled(!0);for(const t of this._behInstsToPostTick)this._CallBehaviorPostTickMethod(t,e);this._behInstsToPostTick.SetQueueingEnabled(!1)}_CallBehaviorTick2Method(e,t){let s=t?performance.now():0,i;return e instanceof ISDKBehaviorInstanceBase?(i=e._tick2(),t&&C3Debugger.AddIndividualBehaviorTickTime(e.behavior,performance.now()-s)):(i=e.Tick2(),t&&C3Debugger.AddIndividualBehaviorTickTime(e.GetBehavior(),performance.now()-s)),i}_BehaviorTick2(){const e=this.IsDebug();this._behInstsToTick2.SetQueueingEnabled(!0);for(const t of this._behInstsToTick2)this._CallBehaviorTick2Method(t,e);this._behInstsToTick2.SetQueueingEnabled(!1)}*_DebugBehaviorTick(){const e=this.IsDebug();this._behInstsToTick.SetQueueingEnabled(!0);for(const t of this._behInstsToTick){const s=this._CallBehaviorTickMethod(t,e);C33.IsIterator(s)&&(yield*s)}this._behInstsToTick.SetQueueingEnabled(!1)}*_DebugBehaviorPostTick(){const e=this.IsDebug();this._behInstsToPostTick.SetQueueingEnabled(!0);for(const t of this._behInstsToPostTick){const s=this._CallBehaviorPostTickMethod(t,e);C33.IsIterator(s)&&(yield*s)}this._behInstsToPostTick.SetQueueingEnabled(!1)}*_DebugBehaviorTick2(){const e=this.IsDebug();this._behInstsToTick2.SetQueueingEnabled(!0);for(const t of this._behInstsToTick2){const s=this._CallBehaviorTick2Method(t,e);C33.IsIterator(s)&&(yield*s)}this._behInstsToTick2.SetQueueingEnabled(!1)}async Tick(l,e,t){this._hasStartedTicking=!0;const h="background-wake"===t,c="background-wake"!==t&&"skip-render"!==t,u=this.GetLayoutManager(),_=this.GetCanvasManager();if(this._hasStarted&&(!this.IsSuspended()||e||h)){let e=performance.now(),t=(this._isInTick=!0,this._MeasureDt(l||0),this._tpsTickCount++,this._ReleasePendingInstances(),this.Step_BeforePreTick()),s=(this.IsDebugging()&&await t,this._dispatcher.dispatchEventAndWait_AsyncOptional(this._eventObjects.pretick)),i=(s instanceof Promise&&await s,this.DispatchUserScriptEvent(this._userScriptEventObjects.pretick),this.Step_AfterPreTick()),r=(this.IsDebugging()&&await i,this._NeedsHandleSaveOrLoad()&&await this._HandleSaveOrLoad(),u.IsPendingChangeMainLayout()&&await this._MaybeChangeLayout(),this.Step_RunEventsEtc()),n=(this.IsDebugging()&&await r,u.GetMainRunningLayout()),a=n._GetPendingSetHTMLLayerCount(),o=!1;if(-1!==a&&(n._ResetPendingHTMLLayerCount(),_.GetHTMLLayerCount()!==a)){const d=this.GetCanvasManager().SetHTMLLayerCount(a);this.IsInWorker()&&(o=!0,await d)}this.PostComponentMessageToDOM("canvas","update-html-layer-dom-state",{layersDomState:n._GetRootLayers().filter(e=>e.IsHTMLElementsLayer()).map(e=>e._GetHTMLLayerDOMState())}),c&&this.Render(),o&&this.PostComponentMessageToDOM("canvas","cleanup-html-layers"),this.IsExportToVideo()&&(await this._ExportToVideoAddFrame(),this.GetGameTime()>=this.GetExportVideoDuration())?this._ExportToVideoFinish():(this.IsSuspended()||h||this._RequestAnimationFrame(),this._tickCount++,this._tickCountNoSave++,this._isInTick=!1,this._mainThreadTimeCounter+=performance.now()-e)}}async Step_BeforePreTick(){const e=this._eventSheetManager,t=this.IsDebug();this.FlushPendingInstances(),e.BlockFlushingInstances(!0),this.PushCurrentLayout(this.GetMainRunningLayout()),t&&C3Debugger.StartMeasuringTime(),this.IsDebugging()?await e.DebugRunScheduledWaits():e.RunScheduledWaits(),t&&C3Debugger.AddEventsTime(),this.PopCurrentLayout(),e.BlockFlushingInstances(!1),this.FlushPendingInstances(),e.BlockFlushingInstances(!0)}async Step_AfterPreTick(){const e=this._eventSheetManager,t=this.IsDebug(),s=this.IsDebugging(),i=this._dispatcher,r=this._eventObjects,n=this._userScriptEventObjects;t&&C3Debugger.StartMeasuringTime(),s?await this.DebugIterateAndBreak(this._DebugBehaviorTick()):this._BehaviorTick(),s?await this.DebugIterateAndBreak(this._DebugBehaviorPostTick()):this._BehaviorPostTick(),t&&C3Debugger.AddBehaviorTotalTickTime(),t&&C3Debugger.StartMeasuringTime(),s?await this.DebugFireGeneratorEventAndBreak(r.tick):i.dispatchEvent(r.tick),t&&C3Debugger.AddPluginTotalTickTime(),e.BlockFlushingInstances(!1),this.DispatchUserScriptEvent(n.tick)}async Step_RunEventsEtc(){const e=this._eventSheetManager,t=this._dispatcher,s=this._eventObjects,i=this._userScriptEventObjects,r=this.IsDebug(),n=this.IsDebugging();r&&C3Debugger.StartMeasuringTime(),n?await e.DebugRunEvents(this._layoutManager):e.RunEvents(this._layoutManager),r&&C3Debugger.AddEventsTime(),this._collisionEngine.ClearRegisteredCollisions(),this._ReleasePendingInstances(),this._isLayoutFirstTick=!1,e.BlockFlushingInstances(!0),r&&C3Debugger.StartMeasuringTime(),n?await this.DebugIterateAndBreak(this._DebugBehaviorTick2()):this._BehaviorTick2(),r&&C3Debugger.AddBehaviorTotalTickTime(),r&&C3Debugger.StartMeasuringTime(),n?await this.DebugFireGeneratorEventAndBreak(s.tick2):t.dispatchEvent(s.tick2),r&&C3Debugger.AddPluginTotalTickTime(),e.BlockFlushingInstances(!1),this.DispatchUserScriptEvent(i.tick2),n&&await e.RunQueuedDebugTriggersAsync()}_ReleasePendingInstances(){if(0!==this._instancesPendingRelease.size){const e=this._dispatcher;e.SetDelayRemoveEventsEnabled(!0);for(const t of this._instancesPendingReleaseAffectedObjectClasses)t.GetSolStack().RemoveInstances(this._instancesPendingRelease);this._instancesPendingReleaseAffectedObjectClasses.clear(),this._eventSheetManager._OnInstancesReleased(this._instancesPendingRelease);for(const s of this._instancesPendingRelease)s.Release();this._instancesPendingRelease.clear(),e.SetDelayRemoveEventsEnabled(!1)}}async _MaybeChangeLayout(){let e=this.GetLayoutManager(),t=0;for(;e.IsPendingChangeMainLayout()&&t++<10;)await this._DoChangeLayout(e.GetPendingChangeMainLayout())}_MeasureDt(e){let t=0;if(this.IsExportToVideo())t=1/this.GetExportVideoFramerate(),this._dtRaw=t,this._dt1=t;else if(0!==this._lastTickTime){const s=Math.max(e-this._lastTickTime,0);.5<(t=s/1e3)&&(t=0),this._dtRaw=t,this._dt1=C33.clamp(t,this._minDt,this._maxDt)}this._lastTickTime=e,this._dt=this._dt1*this._timeScale,this._gameTime.Add(this._dt),this._gameTimeRaw.Add(t*this._timeScale),this._wallTime.Add(this._dt1);for(const[i,r]of this._instanceTimes)r.Add(this._dt1*i.GetTimeScale());this._canvasManager&&this._canvasManager._UpdateTick(),1e3<=e-this._fpsLastTime&&(this._fpsLastTime+=1e3,1e3<=e-this._fpsLastTime&&(this._fpsLastTime=e),this._fps=this._fpsFrameCount,this._fpsFrameCount=0,this._tps=this._tpsTickCount,this._tpsTickCount=0,this._mainThreadTime=Math.min(this._mainThreadTimeCounter/1e3,1),this._mainThreadTimeCounter=0,this._canvasManager&&this._canvasManager._Update1sFrameRange(),this._collisionEngine._Update1sStats(),this.IsDebug())&&C3Debugger.Update1sPerfStats()}_SetTrackingInstanceTime(e,t){if(t){if(!this._instanceTimes.has(e)){const s=C33.New(C33.KahanSum);s.Copy(this._gameTime),this._instanceTimes.set(e,s)}}else this._instanceTimes.delete(e)}_GetInstanceGameTime(e){const t=this._instanceTimes.get(e);return t?t.Get():this.GetGameTime()}async _DoChangeLayout(e){const t=this._dispatcher,s=this.GetLayoutManager(),i=s.GetMainRunningLayout();await i._StopRunning(),i._Unload(e,this.GetRenderer()),i===e&&this._eventSheetManager.ClearAllScheduledWaits(),this._collisionEngine.ClearRegisteredCollisions(),this._ReleasePendingInstances(),t.dispatchEvent(this._eventObjects.beforelayoutchange),C33.Asyncify.SetHighThroughputMode(!0),await e._Load(i,this.GetRenderer()),C33.Asyncify.SetHighThroughputMode(!1),await e._StartRunning(!1),t.dispatchEvent(this._eventObjects.layoutchange),this.UpdateRender(),this._isLayoutFirstTick=!0,this.FlushPendingInstances(),this._ExportToVideoAddKeyframe()}UpdateRender(){this._needRender=!0}GetWebGLRenderer(){return this._canvasManager?this._canvasManager.GetWebGLRenderer():null}GetWebGPURenderer(){return this._canvasManager?this._canvasManager.GetWebGPURenderer():null}GetRenderer(){return this._canvasManager?this._canvasManager.GetRenderer():null}Render(){const s=this._canvasManager;if(s&&!s.IsRendererContextLost()){const i=this.GetRenderer(),e=i.SupportsGPUProfiling(),r=e&&i.IsWebGL(),n=e&&i.IsWebGPU();if(r&&i.CheckForQueryResults(),this._needRender||this.IsExportToVideo()){const a=this._layoutManager.GetMainRunningLayout(),o=(this._fpsFrameCount++,i.Start(),this.IsDebug());o&&C3Debugger.StartMeasuringTime(),this._needRender=!1;let e=null,t=(r&&(e=s.GetGPUFrameTimingsBuffer().AddTimeElapsedQuery(),i.StartQuery(e)),null);n&&(t=i.StartFrameTiming(2*(1+a.GetLayerCount())),i.StartMeasuringRenderPassTime(0,1)),this.Uses3DFeatures()&&"low"===s.GetCurrentFullscreenScalingQuality()?i.SetFixedSizeDepthBuffer(s.GetDrawWidth(),s.GetDrawHeight()):i.SetAutoSizeDepthBuffer(),this._Render(this.GetRenderer(),a),e&&i.EndQuery(e),n&&(i.StopMeasuringRenderPassTime(),this._canvasManager._AddWebGPUFrameTiming(t)),i.Finish(),o&&(C3Debugger.AddDrawCallsTime(),C3Debugger.UpdateInspectHighlight()),s&&s._MaybeTakeSnapshot()}else i.IncrementFrameNumber()}}_NeedsHTMLLayerCompositing(e){return"low"===this.GetCanvasManager().GetCurrentFullscreenScalingQuality()||e.IsWebGL()&&(this.UsesAnyBackgroundBlending()||this.Uses3DFeatures())}_Render(t,s){t.SetTextureFillMode(),t.SetAlphaBlend(),t.SetColorRgba(1,1,1,1),t.SetRenderTarget(null),t.SetTexture(null),t.SetDepthEnabled(this.Uses3DFeatures()),this._NeedsHTMLLayerCompositing(t)&&s._MaybeStartDrawToOwnTexture(t);const i=s.GetHTMLLayerCount();for(let e=1;e<i;++e)s.DrawForHTMLLayerIndex(t,e),t.IsWebGPU()&&t.Restart();this._NeedsHTMLLayerCompositing(t)||s._MaybeStartDrawToOwnTexture(t),s.DrawMain(t)}Trigger(e,t,s){if(!this._hasStarted)return!1;let i=!this._isInTick&&!this._eventSheetManager.IsInTrigger(),r=0;i&&(r=performance.now());const n=this.IsDebug(),a=(n&&this.SetDebuggingEnabled(!1),this._eventSheetManager._Trigger(this._layoutManager,e,t,s));if(i){const o=performance.now()-r;this._mainThreadTimeCounter+=o,n&&C3Debugger.AddTriggersTime(o)}return n&&this.SetDebuggingEnabled(!0),a}DebugTrigger(e,t,s){if(!this.IsDebugging())return this.Trigger(e,t,s);if(this.HitBreakpoint())throw new Error("called DebugTrigger() while stopped on breakpoint");if(this._isInTick||this._eventSheetManager.IsInTrigger())return this._eventSheetManager._DebugTrigger(this._layoutManager,e,t,s);throw new Error("called DebugTrigger() outside of event code - use TriggerAsync() instead")}async TriggerAsync(e,t,s){if(!this.IsDebugging())return this.Trigger(e,t,s);if(!this._hasStarted)return!1;if(this.HitBreakpoint())return this._eventSheetManager.QueueDebugTrigger(e,t,s);if(!this.GetMainRunningLayout())return this._eventSheetManager.QueueTrigger(e,t,s);let i=performance.now(),r=this._eventSheetManager._DebugTrigger(this._layoutManager,e,t,s),n=r.next();for(;!n.done;)await this.DebugBreak(n.value),n=r.next();return this.IsSuspended()||this._eventSheetManager.IsInTrigger()||(await this._eventSheetManager.RunQueuedDebugTriggersAsync(),this._hasStartedTicking&&!this._isInTick&&this._RequestAnimationFrame()),this._mainThreadTimeCounter+=performance.now()-i,n.value}FastTrigger(e,t,s){const i=this.IsDebug(),r=(i&&this.SetDebuggingEnabled(!1),this._eventSheetManager._FastTrigger(this._layoutManager,e,t,s));return i&&this.SetDebuggingEnabled(!0),r}DebugFastTrigger(e,t,s){return this._eventSheetManager._DebugFastTrigger(this._layoutManager,e,t,s)}ScheduleTriggers(e){return this._scheduleTriggersThrottle.Add(e)}PushCurrentLayout(e){this._currentLayoutStack.push(e)}PopCurrentLayout(){if(!this._currentLayoutStack.length)throw new Error("layout stack empty");this._currentLayoutStack.pop()}GetCurrentLayout(){return this._currentLayoutStack.length?this._currentLayoutStack.at(-1):this.GetMainRunningLayout()}GetDt(e){return e&&-1!==e.GetTimeScale()?this._dt1*e.GetTimeScale():this._dt}_GetDtFast(){return this._dt}GetDt1(){return this._dt1}GetDtRaw(){return this._dtRaw}GetTimeScale(){return this._timeScale}SetTimeScale(e){(isNaN(e)||e<0)&&(e=0),this._timeScale=e}SetMinDt(e){this._minDt=Math.max(e,0)}GetMinDt(){return this._minDt}SetMaxDt(e){this._maxDt=Math.max(e,0)}GetMaxDt(){return this._maxDt}GetFramesPerSecond(){return this._fps}GetTicksPerSecond(){return this._tps}GetMainThreadTime(){return this._mainThreadTime}GetStartTime(){return this._startTime}GetGameTime(){return this._gameTime.Get()}GetGameTimeRaw(){return this._gameTimeRaw.Get()}GetWallTime(){return this._wallTime.Get()}GetTickCount(){return this._tickCount}GetTickCountNoSave(){return this._tickCountNoSave}GetObjectCount(){return this._objectCount}GetProjectName(){return this._projectName}GetProjectVersion(){return this._projectVersion}GetProjectUniqueId(){return this._projectUniqueId}GetAppId(){return this._appId}GetExportTimestamp(){return this._exportTimestamp}GetInstanceByUID(e){if(this._isLoadingState)throw new Error("cannot call while loading state - wait until afterload event");return this._instancesByUid.get(e)||null}_RefreshUidMap(){this._instancesByUid.clear();for(const e of this._allObjectClasses)if(!e.IsFamily())for(const t of e.GetInstances())this._instancesByUid.set(t.GetUID(),t)}IsPreview(){return"preview"===this._exportType}IsDebug(){return this._isDebug}GetExportType(){return this._exportType}IsNWjs(){return"nwjs"===this.GetExportType()||this._isNWjs}IsCordova(){return"cordova"===this._exportType}IsAndroidWebView(){return"Android"===C33.Platform.OS&&("cordova"===this._exportType||"playable-ad-single-file"===this._exportType||"playable-ad-zip"===this._exportType||"instant-games"===this._exportType)}IsiOSCordova(){return this._isiOSCordova}IsiOSWebView(){return this._isiOSWebView}IsWindowsWebView2(){return this._isWindowsWebView2}IsAnyWebView2Wrapper(){return this._isAnyWebView2Wrapper}GetCollisionEngine(){return this._collisionEngine}GetSolidBehavior(){return this._addonManager.GetSolidBehavior()}GetJumpthruBehavior(){return this._addonManager.GetJumpthruBehavior()}Uses3DFeatures(){return this._uses3dFeatures}GetZScaleFactor(){return this.GetRenderer().GetZAxisScaleFactor(this.GetViewportHeight())}GetDefaultCameraZ(e){return this.GetRenderer().GetDefaultCameraZ(e||this.GetViewportHeight())}IsLayoutFirstTick(){return this._isLayoutFirstTick}SetPixelRoundingEnabled(e){this._isPixelRoundingEnabled!==(e=!!e)&&(this._isPixelRoundingEnabled=e,this.GetLayoutManager().SetAllLayerMVChanged(),this.UpdateRender())}IsPixelRoundingEnabled(){return this._isPixelRoundingEnabled}GetTextIconSet(e){if(!this._iconChangeHandlers.has(e)){const s=()=>this.DeleteTextIconSet(e);this._iconChangeHandlers.set(e,s),e.Dispatcher().addEventListener("animationframeimagechange",s)}const t=this._textIconManager.GetIconSet(e);return t.HasLoaded()||t.LoadContent().then(()=>this.UpdateRender()),t}DeleteTextIconSet(e){this._textIconManager.DeleteIconSet(e)}_GetTextIconSetMeta(e){const t=[];for(const s of e.GetAnimations())for(const i of s.GetFrames()){const r=i.GetImageInfo();t.push({source:i,width:r.GetWidth(),height:r.GetHeight(),tag:i.GetTag()})}return{icons:t}}async _GetTextIconSetContent(e){const t=C33.New(C33.PromiseThrottle),s=[],r=new Map;for(const a of e.GetAnimations())for(const o of a.GetFrames()){const l=o.GetImageInfo().GetImageAsset();r.has(l)||(r.set(l,null),s.push(t.Add(async()=>{const e=await l.LoadToDrawable();r.set(l,e)})))}await Promise.all(s);const i=[];for(const h of e.GetAnimations())for(const c of h.GetFrames())i.push(t.Add(async()=>{const e=c.GetImageInfo(),t=r.get(e.GetImageAsset()),s=await e.ExtractImageToCanvas(t),i=await createImageBitmap(s);return{drawable:i}}));const n=await Promise.all(i);for(const u of r.values())u instanceof ImageBitmap&&u.close&&u.close();return{icons:n}}SaveToSlot(e){this._saveToSlotName=e,this._saveToJsonString=!1}SaveToJsonString(){this._saveToSlotName="",this._saveToJsonString=!0}LoadFromSlot(e){this._loadFromSlotName=e}LoadFromJsonString(e){this._loadFromJson=e}GetLastSaveJsonString(){return this._lastSaveJson}_NeedsHandleSaveOrLoad(){return!!(this._saveToSlotName||this._saveToJsonString||this._loadFromSlotName||null!==this._loadFromJson)}async _HandleSaveOrLoad(){if(this._saveToSlotName&&(this.FlushPendingInstances(),await this._DoSaveToSlot(this._saveToSlotName),this._ClearSaveOrLoad()),this._loadFromSlotName&&(await this._DoLoadFromSlot(this._loadFromSlotName),this._ClearSaveOrLoad(),this.IsDebug())&&C3Debugger.StepIfPausedInDebugger(),this._saveToJsonString){const e=await this._SaveToJsonString();this._lastSaveJson=e,await this.TriggerAsync(C33.Plugins.System.Cnds.OnSaveComplete,null),this._lastSaveJson="",this._ClearSaveOrLoad()}if(null!==this._loadFromJson){this.FlushPendingInstances();try{await this._DoLoadFromJsonString(this._loadFromJson),this._lastSaveJson=this._loadFromJson,await this.TriggerAsync(C33.Plugins.System.Cnds.OnLoadComplete,null),this._lastSaveJson=""}catch(e){console.error("[Construct] Failed to load state from JSON string: ",e),await this.TriggerAsync(C33.Plugins.System.Cnds.OnLoadFailed,null)}this._ClearSaveOrLoad()}}_ClearSaveOrLoad(){this._saveToSlotName="",this._saveToJsonString=!1,this._loadFromSlotName="",this._loadFromJson=null}_GetProjectStorage(){return this._projectStorage||(this._projectStorage=localforage.createInstance({name:"c3-localstorage-"+this.GetProjectUniqueId(),description:this.GetProjectName()})),this._projectStorage}_GetSavegamesStorage(){return this._savegamesStorage||(this._savegamesStorage=localforage.createInstance({name:"c3-savegames-"+this.GetProjectUniqueId(),description:this.GetProjectName()})),this._savegamesStorage}async _DoSaveToSlot(e){const t=await this._SaveToJsonString();try{await this._GetSavegamesStorage().setItem(e,t),console.log("[Construct] Saved state to storage ("+t.length+" chars)"),this._lastSaveJson=t,await this.TriggerAsync(C33.Plugins.System.Cnds.OnSaveComplete,null),this._lastSaveJson=""}catch(e){console.error("[Construct] Failed to save state to storage: ",e),await this.TriggerAsync(C33.Plugins.System.Cnds.OnSaveFailed,null)}}async _DoLoadFromSlot(e){try{const t=await this._GetSavegamesStorage().getItem(e);if(!t)throw new Error("empty slot");console.log("[Construct] Loaded state from storage ("+t.length+" chars)"),await this._DoLoadFromJsonString(t),this._lastSaveJson=t,await this.TriggerAsync(C33.Plugins.System.Cnds.OnLoadComplete,null),this._lastSaveJson=""}catch(e){console.error("[Construct] Failed to load state from storage: ",e),await this.TriggerAsync(C33.Plugins.System.Cnds.OnLoadFailed,null)}}async _SaveToJsonString(){const e={c3save:!0,version:1,rt:{time:this.GetGameTime(),timeRaw:this.GetGameTimeRaw(),walltime:this.GetWallTime(),timescale:this.GetTimeScale(),tickcount:this.GetTickCount(),next_uid:this._nextUid,running_layout:this.GetMainRunningLayout().GetSID(),start_time_offset:Date.now()-this._startTime},types:{},layouts:{},events:this._eventSheetManager._SaveToJson(),timelines:this._timelineManager._SaveToJson(),user_script_data:null};for(const s of this._allObjectClasses)s.IsFamily()||s.HasNoSaveBehavior()||(e.types[s.GetSID().toString()]=s._SaveToJson());for(const i of this._layoutManager.GetAllLayouts())e.layouts[i.GetSID().toString()]=i._SaveToJson();const t=this._CreateUserScriptEvent("save");return t.saveData=null,await this.DispatchUserScriptEventAsyncWait(t),e.user_script_data=t.saveData,JSON.stringify(e)}IsLoadingState(){return this._isLoadingState}async _DoLoadFromJsonString(e){const t=this.GetLayoutManager(),s=JSON.parse(e);if(s.c2save)throw new Error("C2 saves are incompatible with C3 runtime");if(!s.c3save)throw new Error("not valid C3 save data");if(1<s.version)throw new Error("C3 save data from future version");this.ClearIntancesNeedingAfterLoad(),this._dispatcher.dispatchEvent(C33.New(C33.Event,"beforeload"));for(const l of this.allInstances()){const h=l.GetObjectClass();h.HasNoSaveBehavior()||l._OnBeforeLoad()}let i=s.rt,r=(this._gameTime.Set(i.time),i.hasOwnProperty("timeRaw")&&this._gameTimeRaw.Set(i.timeRaw),this._wallTime.Set(i.walltime),this._timeScale=i.timescale,this._tickCount=i.tickcount,this._startTime=Date.now()-i.start_time_offset,i.running_layout),n=!(this._isLoadingState=!0);if(r!==this.GetMainRunningLayout().GetSID()){const c=t.GetLayoutBySID(r);if(!c)return;await this._DoChangeLayout(c),n=!0}for(const[u,_]of Object.entries(s.layouts)){const d=parseInt(u,10),p=t.GetLayoutBySID(d);p&&p._LoadFromJson(_)}const a=new Set;for(const[m,g]of Object.entries(s.types)){const f=parseInt(m,10),S=this.GetObjectClassBySID(f);!S||S.IsFamily()||S.HasNoSaveBehavior()||S._LoadFromJson(g,a)}for(const C of this._layoutManager.GetAllLayouts())for(const y of C.allLayers())y._LoadFromJsonAfterInstances();if(this.FlushPendingInstances(),this._RefreshUidMap(),this._isLoadingState=!1,n){for(const G of this.allInstances())G.SetupInitialSceneGraphConnections();for(const[I,T]of Object.entries(s.types)){const b=parseInt(I,10),A=this.GetObjectClassBySID(b);!A||A.IsFamily()||A.HasNoSaveBehavior()||A._SetupSceneGraphConnectionsOnChangeOfLayout(T)}}this._nextUid=i.next_uid,this._eventSheetManager._LoadFromJson(s.events);for(const P of this._allObjectClasses)if(!P.IsFamily()&&P.IsInContainer())for(const R of P.GetInstances()){const x=R.GetIID();for(const E of P.GetContainer().objectTypes())if(E!==P){const v=E.GetInstances();if(x<0||x>=v.length)throw new Error("missing sibling instance");R._AddSibling(v[x])}}this._timelineManager._LoadFromJson(s.timelines),t.SetAllLayerProjectionChanged(),t.SetAllLayerMVChanged();for(const w of a)w._OnCreatedForLoadingSavegame();this.DoAfterLoad(),this._dispatcher.dispatchEvent(C33.New(C33.Event,"afterload")),this.DispatchUserScriptEvent(this._CreateUserScriptEvent("afterload"));for(const[M,D]of Object.entries(s.types)){const O=parseInt(M,10),L=this.GetObjectClassBySID(O);L&&L._ClearLoadInstancesJson()}const o=this._CreateUserScriptEvent("load");o.saveData=s.user_script_data,await this.DispatchUserScriptEventAsyncWait(o),this.UpdateRender()}SortOnTmpHierarchyPosition(e,t){return e.GetWorldInfo().GetTmpHierarchyPosition()-t.GetWorldInfo().GetTmpHierarchyPosition()}AddInstanceNeedingAfterLoad(e,t){e.GetWorldInfo()&&!this._instancesNeedingAfterLoadMap.has(e)&&(this._instancesNeedingAfterLoadMap.set(e,t),this._instancesNeedingAfterLoadArray.push(e))}ClearIntancesNeedingAfterLoad(){this._instancesNeedingAfterLoadMap=new WeakMap,C33.clearArray(this._instancesNeedingAfterLoadArray)}DoAfterLoad(e="full",t=null){this._instancesNeedingAfterLoadArray.sort(this.SortOnTmpHierarchyPosition);for(const s of this._instancesNeedingAfterLoadArray)s._OnAfterLoad(this._instancesNeedingAfterLoadMap.get(s),e,t);for(const i of this._instancesNeedingAfterLoadArray)i._OnAfterLoad2(this._instancesNeedingAfterLoadMap.get(i),e,t);this.ClearIntancesNeedingAfterLoad()}async AddJobWorkerScripts(e){const t=await Promise.all(e.map(async e=>{const t=this.IsCordova()&&this._assetManager.IsFileProtocol();if(t||"playable-ad-single-file"===this.GetExportType()){const s=await this._assetManager.FetchBlob(e);return URL.createObjectURL(s)}return new URL(e,location.href).toString()}));this._jobScheduler.ImportScriptsToJobWorkers(t)}AddJobWorkerBlob(e,t){this._jobScheduler.SendBlobToJobWorkers(e,t)}AddJobWorkerBuffer(e,t){this._jobScheduler.SendBufferToJobWorkers(e,t)}AddJob(e,t,s,i){return this._jobScheduler.AddJob(e,t,s,null,null,i)}BroadcastJob(e,t,s,i){return this._jobScheduler.BroadcastJob(e,t,s,i)}GetMaxNumJobWorkers(){return this._jobScheduler.GetMaxNumWorkers()}InvokeDownload(e,t){this.PostComponentMessageToDOM("runtime","invoke-download",{url:e,filename:t})}async RasterSvgImage(e,t,s,i,r,n){if(i=i||t,r=r||s,this.IsInWorker()){const a=await this.PostComponentMessageToDOMAsync("runtime","raster-svg-image",{blob:e,imageWidth:t,imageHeight:s,surfaceWidth:i,surfaceHeight:r,imageBitmapOpts:n});return a.imageBitmap}{const o=await self.C3_RasterSvgImageBlob(e,t,s,i,r);return n?self.createImageBitmap(o,n):o}}async GetSvgImageSize(e){return this.IsInWorker()?this.PostComponentMessageToDOMAsync("runtime","get-svg-image-size",{blob:e}):self.C3_GetSvgImageSize(e)}RequestDeviceOrientationEvent(){this._didRequestDeviceOrientationEvent||(this._didRequestDeviceOrientationEvent=!0,this.PostComponentMessageToDOM("runtime","enable-device-orientation"))}RequestDeviceMotionEvent(){this._didRequestDeviceMotionEvent||(this._didRequestDeviceMotionEvent=!0,this.PostComponentMessageToDOM("runtime","enable-device-motion"))}Random(){return this._randomNumberCallback()}SetRandomNumberGeneratorCallback(e){this._randomNumberCallback=e}_GetRemotePreviewStatusInfo(){const e=this.GetRenderer();return{fps:this.GetFramesPerSecond(),tps:this.GetTicksPerSecond(),cpu:this.GetMainThreadTime(),gpu:this.GetGPUUtilisation(),layout:this.GetMainRunningLayout()?this.GetMainRunningLayout().GetName():"",renderer:e.IsWebGL()?e.GetUnmaskedRenderer():e.GetAdapterInfoString()}}HitBreakpoint(){return!!this.IsDebug()&&C3Debugger.HitBreakpoint()}DebugBreak(e){return this.IsDebugging()?C3Debugger.DebugBreak(e):Promise.resolve()}DebugBreakNext(){return!!this.IsDebugging()&&C3Debugger.BreakNext()}SetDebugBreakpointsEnabled(e){this._breakpointsEnabled=!!e,this._UpdateDebuggingFlag()}AreDebugBreakpointsEnabled(){return this._breakpointsEnabled}IsDebugging(){return this._isDebugging}SetDebuggingEnabled(e){e?this._debuggingDisabled--:this._debuggingDisabled++,this._UpdateDebuggingFlag()}_UpdateDebuggingFlag(){this._isDebugging=this.IsDebug()&&this._breakpointsEnabled&&0===this._debuggingDisabled}IsCPUProfiling(){return this.IsDebug()&&C3Debugger.IsCPUProfiling()}IsGPUProfiling(){return this.IsDebug()&&this.GetRenderer().SupportsGPUProfiling()&&C3Debugger.IsGPUProfiling()}async DebugIterateAndBreak(e){if(e)for(const t of e)await this.DebugBreak(t)}DebugFireGeneratorEventAndBreak(e){return this.DebugIterateAndBreak(this._dispatcher.dispatchGeneratorEvent(e))}_InvokeFunctionFromJS(e){return this._eventSheetManager._InvokeFunctionFromJS(e.name,e.params)}_GetHTMLLayerWrapElement(e){if(this.IsInWorker())throw new Error("not supported in worker mode");return self.c3_runtimeInterface._GetHTMLWrapElement(e)}GetIRuntime(){return this._iRuntime}_CreateUserScriptEvent(e){const t=C33.New(C33.Event,e,!1);return t.runtime=this._iRuntime,t}_InitScriptInterfaces(){this._iRuntime=new self.IRuntime(this),this._userScriptEventObjects={pretick:this._CreateUserScriptEvent("pretick"),tick:this._CreateUserScriptEvent("tick"),tick2:this._CreateUserScriptEvent("tick2")}}_InitObjectsScriptInterface(){const e={};for(const t of this._allObjectClasses)e[t.GetJsPropName()]={value:t.GetIObjectClass(),enumerable:!0,writable:!1};this._iRuntime._InitObjects(e)}_InitGlobalVariableScriptInterface(){const e={};for(const t of this.GetEventSheetManager().GetAllGlobalVariables())e[t.GetJsPropName()]=t._GetScriptInterfaceDescriptor();this._iRuntime._InitGlobalVars(e)}_GetCommonScriptInterfaces(){return this._commonScriptInterfaces}_MapScriptInterface(e,t){this._interfaceMap.set(e,t)}_UnwrapScriptInterface(e){return this._interfaceMap.get(e)}_UnwrapIObjectClass(e){if(!(e instanceof self.IObjectClass))throw new TypeError("expected IObjectClass");const t=this._UnwrapScriptInterface(e);if(t&&t instanceof C33.ObjectClass)return t;throw new Error("invalid IObjectClass")}_UnwrapIInstance(e){if(!(e instanceof self.IInstance))throw new TypeError("expected IInstance");const t=this._UnwrapScriptInterface(e);if(t&&t instanceof C33.Instance)return t;throw new Error("invalid IInstance")}_UnwrapIWorldInstance(e){if(!(e instanceof self.IWorldInstance))throw new TypeError("expected IWorldInstance");const t=this._UnwrapScriptInterface(e);if(t&&t instanceof C33.Instance)return t;throw new Error("invalid IInstance")}},self.C3_CreateRuntime=C33.Runtime.Create,self.C3_InitRuntime=(e,t)=>e.Init(t)}{const C33=self.C3;C33.JobSchedulerRuntime=class extends C33.DefendedBase{constructor(e,t){super(),this._runtime=e,this._jobPromises=new Map,this._nextJobId=0,this._inputPort=t.inputPort,t.outputPort.onmessage=e=>this._OnJobWorkerMessage(e),this._maxNumWorkers=t.maxNumWorkers,this._jobWorkerCount=1,this._isCreatingWorker=!1,this._hadErrorCreatingWorker=!1}GetMaxNumWorkers(){return this._maxNumWorkers}ImportScriptsToJobWorkers(e){this._inputPort.postMessage({type:"_import_scripts",scripts:e})}SendBlobToJobWorkers(e,t){this._inputPort.postMessage({type:"_send_blob",blob:e,id:t})}SendBufferToJobWorkers(e,t){this._inputPort.postMessage({type:"_send_buffer",buffer:e,id:t},[e])}AddJob(e,t,s,i,r,n){if(s=s||[],"number"==typeof n&&(n=Math.floor(n))<=0)throw new Error("invalid maxWorkerNum");const a=this._nextJobId++,o={type:e,isBroadcast:!1,maxWorkerNum:n,jobId:a,params:t,transferables:s},l=new Promise((e,t)=>{this._jobPromises.set(a,{resolve:e,progress:i,reject:t,cancelled:!1,maxWorkerNum:n})});return r&&r.SetAction(()=>this._CancelJob(a)),this._inputPort.postMessage(o,s),this._MaybeCreateExtraWorker(),l}BroadcastJob(e,t,s,i){if(s=s||[],"number"==typeof i&&(i=Math.floor(i))<=0)throw new Error("invalid maxWorkerNum");const r=this._nextJobId++,n={type:e,isBroadcast:!0,maxWorkerNum:i,jobId:r,params:t,transferables:s};this._inputPort.postMessage(n,s)}_CancelJob(e){const t=this._jobPromises.get(e);t&&(t.cancelled=!0,t.resolve=null,t.progress=null,t.reject=null,this._inputPort.postMessage({type:"_cancel",jobId:e}))}_OnJobWorkerMessage(e){const t=e.data,s=t.type,i=t.jobId;switch(s){case"result":this._OnJobResult(i,t.result);break;case"progress":this._OnJobProgress(i,t.progress);break;case"error":this._OnJobError(i,t.error);break;case"ready":this._OnJobWorkerReady();break;default:throw new Error(`unknown message from worker '${s}'`)}}_OnJobResult(e,t){const s=this._jobPromises.get(e);if(!s)throw new Error("invalid job ID");s.cancelled||s.resolve(t),this._jobPromises.delete(e)}_OnJobProgress(e,t){const s=this._jobPromises.get(e);if(!s)throw new Error("invalid job ID");!s.cancelled&&s.progress&&s.progress(t)}_OnJobError(e,t){const s=this._jobPromises.get(e);if(!s)throw new Error("invalid job ID");s.cancelled||s.reject(t),this._jobPromises.delete(e)}_OnJobWorkerReady(){this._isCreatingWorker&&(this._isCreatingWorker=!1,this._jobWorkerCount++,this._jobWorkerCount<this._maxNumWorkers?this._MaybeCreateExtraWorker():this._inputPort.postMessage({type:"_no_more_workers"}))}_GetWorkerCountNeededForPendingJobs(){let e=0,t=[...this._jobPromises.values()].sort((e,t)=>{const s=e.maxWorkerNum||1/0,i=t.maxWorkerNum||1/0;return s-i});for(const s of t){const i=s.maxWorkerNum||1/0;e<i&&e++}return e}async _MaybeCreateExtraWorker(){if(!(this._jobWorkerCount>=this._maxNumWorkers||this._isCreatingWorker||this._hadErrorCreatingWorker||this._GetWorkerCountNeededForPendingJobs()<=this._jobWorkerCount))try{this._isCreatingWorker=!0;const e=await this._runtime.PostComponentMessageToDOMAsync("runtime","create-job-worker");e.outputPort.onmessage=e=>this._OnJobWorkerMessage(e)}catch(e){this._hadErrorCreatingWorker=!0,this._isCreatingWorker=!1,console.error(`[Construct] Failed to create job worker; stopping creating any more (created ${this._jobWorkerCount} so far)`,e)}}}}self.C3_Shaders={},self.C3_Shaders.hsladjust={glsl:"varying mediump vec2 vTex;\nuniform lowp sampler2D samplerFront;\nprecision mediump float;\nuniform float huerotate;\nuniform float satadjust;\nuniform float lumadjust;\nvec3 rgb_to_hsl(vec3 color)\n{\nvec3 hsl = vec3(0.0, 0.0, 0.0);\nfloat fmin = min(min(color.r, color.g), color.b);\nfloat fmax = max(max(color.r, color.g), color.b);\nfloat delta = fmax - fmin;\nhsl.z = (fmax + fmin) / 2.0;\nif (delta == 0.0)\n{\nhsl.x = 0.0;\nhsl.y = 0.0;\n}\nelse\n{\nif (hsl.z < 0.5)\nhsl.y = delta / (fmax + fmin);\nelse\nhsl.y = delta / (2.0 - fmax - fmin);\nfloat dR = (((fmax - color.r) / 6.0) + (delta / 2.0)) / delta;\nfloat dG = (((fmax - color.g) / 6.0) + (delta / 2.0)) / delta;\nfloat dB = (((fmax - color.b) / 6.0) + (delta / 2.0)) / delta;\nif (color.r == fmax)\nhsl.x = dB - dG;\nelse if (color.g == fmax)\nhsl.x = (1.0 / 3.0) + dR - dB;\nelse if (color.b == fmax)\nhsl.x = (2.0 / 3.0) + dG - dR;\nif (hsl.x < 0.0)\nhsl.x += 1.0;\nelse if (hsl.x > 1.0)\nhsl.x -= 1.0;\n}\nreturn hsl;\n}\nfloat hue_to_rgb(float f1, float f2, float hue)\n{\nif (hue < 0.0)\nhue += 1.0;\nelse if (hue > 1.0)\nhue -= 1.0;\nfloat ret;\nif ((6.0 * hue) < 1.0)\nret = f1 + (f2 - f1) * 6.0 * hue;\nelse if ((2.0 * hue) < 1.0)\nret = f2;\nelse if ((3.0 * hue) < 2.0)\nret = f1 + (f2 - f1) * ((2.0 / 3.0) - hue) * 6.0;\nelse\nret = f1;\nreturn ret;\n}\nvec3 hsl_to_rgb(vec3 hsl)\n{\nvec3 rgb = vec3(hsl.z);\nif (hsl.y != 0.0)\n{\nfloat f2;\nif (hsl.z < 0.5)\nf2 = hsl.z * (1.0 + hsl.y);\nelse\nf2 = (hsl.z + hsl.y) - (hsl.y * hsl.z);\nfloat f1 = 2.0 * hsl.z - f2;\nrgb.r = hue_to_rgb(f1, f2, hsl.x + (1.0 / 3.0));\nrgb.g = hue_to_rgb(f1, f2, hsl.x);\nrgb.b = hue_to_rgb(f1, f2, hsl.x - (1.0 / 3.0));\n}\nreturn rgb;\n}\nvoid main(void)\n{\nvec4 front = texture2D(samplerFront, vTex);\nvec3 rgb = rgb_to_hsl(front.rgb) + vec3((huerotate > 0.5 ? huerotate - 1.0 : huerotate), 0, (lumadjust - 1.0) * front.a);\nrgb.y *= satadjust;\nrgb = hsl_to_rgb(rgb);\ngl_FragColor = vec4(rgb, front.a);\n}",glslWebGL2:"",wgsl:"%%SAMPLERFRONT_BINDING%% var samplerFront : sampler;\n%%TEXTUREFRONT_BINDING%% var textureFront : texture_2d<f32>;\nstruct ShaderParams {\nhuerotate : f32,\nsatadjust : f32,\nlumadjust : f32\n};\n%%SHADERPARAMS_BINDING%% var<uniform> shaderParams : ShaderParams;\n%%C3_UTILITY_FUNCTIONS%%\n%%FRAGMENTINPUT_STRUCT%%\n%%FRAGMENTOUTPUT_STRUCT%%\n@fragment\nfn main(input : FragmentInput) -> FragmentOutput\n{\nvar front : vec4<f32> = textureSample(textureFront, samplerFront, input.fragUV);\nvar huerotate : f32 = shaderParams.huerotate;\nif (huerotate > 0.5)\n{\nhuerotate = huerotate - 1.0;\n}\nvar rgb : vec3<f32> = c3_RGBtoHSL(front.rgb) + vec3<f32>(huerotate, 0.0, (shaderParams.lumadjust - 1.0) * front.a);\nrgb.y = rgb.y * shaderParams.satadjust;\nrgb = c3_HSLtoRGB(rgb);\nvar output : FragmentOutput;\noutput.color = vec4<f32>(rgb, front.a);\nreturn output;\n}",blendsBackground:!1,usesDepth:!1,extendBoxHorizontal:0,extendBoxVertical:0,crossSampling:!1,mustPreDraw:!1,preservesOpaqueness:!0,supports3dDirectRendering:!1,animated:!1,parameters:[["huerotate",0,"percent"],["satadjust",0,"percent"],["lumadjust",0,"percent"]]},self.C3_Shaders.water={glsl:"#ifdef GL_FRAGMENT_PRECISION_HIGH\n#define highmedp highp\n#else\n#define highmedp mediump\n#endif\nvarying mediump vec2 vTex;\nuniform lowp sampler2D samplerFront;\nuniform mediump vec2 srcStart;\nuniform mediump vec2 srcEnd;\nprecision mediump float;\nuniform highmedp float seconds;\nuniform mediump vec2 pixelSize;\nconst float PI = 3.1415926535897932;\nuniform float speed;\nuniform float speed_x;\nuniform float speed_y;\nuniform float intensity;\nconst float steps = 8.0;\nuniform float frequency;\nuniform float angle; // better when a prime\nuniform float delta;\nuniform float intence;\nuniform float emboss;\nfloat col(vec2 coord)\n{\nfloat delta_theta = 2.0 * PI / angle;\nfloat col = 0.0;\nfloat theta = 0.0;\nfor (float i = 0.0; i < steps; i++)\n{\nvec2 adjc = coord;\ntheta = delta_theta*i;\nadjc.x += cos(theta)*seconds*speed + seconds * speed_x;\nadjc.y -= sin(theta)*seconds*speed - seconds * speed_y;\ncol = col + cos( (adjc.x*cos(theta) - adjc.y*sin(theta))*frequency)*intensity;\n}\nreturn cos(col);\n}\nvoid main(void)\n{\nmediump vec2 tex = (vTex - srcStart) / (srcEnd - srcStart);\nvec2 p = tex, c1 = p, c2 = p;\nfloat cc1 = col(c1);\nc2.x += (1.0 / pixelSize.x) / delta;\nfloat dx = emboss*(cc1-col(c2))/delta;\nc2.x = p.x;\nc2.y += (1.0 / pixelSize.y) / delta;\nfloat dy = emboss*(cc1-col(c2))/delta;\nc1.x += dx;\nc1.y = -(c1.y+dy);\nfloat alpha = 1.+dot(dx,dy)*intence;\nc1.y = -c1.y;\nc1 = clamp(c1, 0.0, 1.0);\ngl_FragColor = texture2D(samplerFront, mix(srcStart, srcEnd, c1)) * alpha;\n}",glslWebGL2:"",wgsl:"%%SAMPLERFRONT_BINDING%% var samplerFront : sampler;\n%%TEXTUREFRONT_BINDING%% var textureFront : texture_2d<f32>;\nstruct ShaderParams {\nspeed : f32,\nspeed_x : f32,\nspeed_y : f32,\nintensity : f32,\nfrequency : f32,\nangle : f32,\ndelta : f32,\nintence : f32,\nemboss : f32\n};\n%%SHADERPARAMS_BINDING%% var<uniform> shaderParams : ShaderParams;\n%%C3PARAMS_STRUCT%%\n%%C3_UTILITY_FUNCTIONS%%\n%%FRAGMENTINPUT_STRUCT%%\n%%FRAGMENTOUTPUT_STRUCT%%\nconst pi : f32 = 3.1415926535897932;\nconst steps = 8.0;\nfn col(coord : vec2<f32>) -> f32\n{\nvar delta_theta : f32 = 2.0 * pi / shaderParams.angle;\nvar col : f32 = 0.0;\nvar theta : f32 = 0.0;\nfor (var i : f32 = 0.0; i < steps; i = i + 1.0)\n{\nvar adjc : vec2<f32> = coord;\ntheta = delta_theta * i;\nadjc.x = adjc.x + cos(theta) * c3Params.seconds * shaderParams.speed + c3Params.seconds * shaderParams.speed_x;\nadjc.y = adjc.y - (sin(theta) * c3Params.seconds * shaderParams.speed - c3Params.seconds * shaderParams.speed_y);\ncol = col + cos((adjc.x * cos(theta) - adjc.y * sin(theta)) * shaderParams.frequency) * shaderParams.intensity;\n}\nreturn cos(col);\n}\n@fragment\nfn main(input : FragmentInput) -> FragmentOutput\n{\nvar texSize : vec2<f32> = vec2<f32>(textureDimensions(textureFront));\nvar tex : vec2<f32> = c3_srcToNorm(input.fragUV);\nvar p : vec2<f32> = tex;\nvar c1 : vec2<f32> = tex;\nvar c2 : vec2<f32> = tex;\nvar cc1 : f32 = col(c1);\nc2.x = c2.x + texSize.x / shaderParams.delta;\nvar dx : f32 = shaderParams.emboss * (cc1 - col(c2)) / shaderParams.delta;\nc2.x = p.x;\nc2.y = c2.y + texSize.y / shaderParams.delta;\nvar dy : f32 = shaderParams.emboss * (cc1 - col(c2)) / shaderParams.delta;\nc1.x = c1.x + dx;\nc1.y = -(c1.y + dy);\nvar alpha : f32 = 1.0 + dx * dy * shaderParams.intence;\nc1.y = -c1.y;\nc1 = c3_clamp2(c1, 0.0, 1.0);\nvar output : FragmentOutput;\noutput.color = textureSample(textureFront, samplerFront, mix(c3Params.srcStart, c3Params.srcEnd, c1)) * alpha;\nreturn output;\n}",blendsBackground:!1,usesDepth:!1,extendBoxHorizontal:40,extendBoxVertical:40,crossSampling:!1,mustPreDraw:!1,preservesOpaqueness:!1,supports3dDirectRendering:!1,animated:!0,parameters:[["speed",0,"percent"],["speed_x",0,"percent"],["speed_y",0,"percent"],["intensity",0,"float"],["frequency",0,"float"],["angle",0,"float"],["delta",0,"float"],["intence",0,"float"],["emboss",0,"percent"]]};{let ForEachOrdered_SortInstances2=function(e,t){const s=e[1],i=t[1];if("number"==typeof s&&"number"==typeof i)return s-i;{const r=""+s,n=""+i;return r<n?-1:n<r?1:0}},a=(ForEachOrdered_SortInstances=ForEachOrdered_SortInstances2,self.C3),r=null,n="",s="",o=[],u="",l="",c="",i=a.New(a.ArrayStack);a.Plugins.System=class extends a.SDKPluginBase{constructor(e){super(e),this._loopStack=this._runtime.GetEventSheetManager().GetLoopStack(),this._eventStack=this._runtime.GetEventSheetManager().GetEventStack(),this._imagesLoadingTotal=0,this._imagesLoadingComplete=0,this._functionMaps=new Map}Release(){super.Release()}UpdateRender(){this._runtime.UpdateRender()}Trigger(e){this._runtime.Trigger(e,null,null)}GetRegex(e,t){return r&&e===n&&t===s||(r=new RegExp(e,t),n=e,s=t),r.lastIndex=0,r}GetRegexMatches(e,t,s){if(e!==u||t!==l||s!==c){const i=this.GetRegex(t,s);o=e.match(i),u=e,l=t,c=s}return o}async _LoadTexturesForObjectClasses(e,t){if(t.length){this._imagesLoadingTotal+=t.length;const s=[];for(const i of t)s.push(e.MaybeLoadTexturesFor(i));await a.PromiseAllWithProgress(s,()=>{this._imagesLoadingComplete++}),this._imagesLoadingComplete++,this._imagesLoadingComplete===this._imagesLoadingTotal&&(this._imagesLoadingComplete=0,this._imagesLoadingTotal=0,this._runtime.Trigger(a.Plugins.System.Cnds.OnImageLoadingComplete,null,null))}}GetImageLoadingProgress(){return 0===this._imagesLoadingTotal?1:this._imagesLoadingComplete/this._imagesLoadingTotal}_UnloadTexturesForObjectClasses(e,t){for(const s of t)0===s.GetInstanceCount()&&e.MaybeUnloadTexturesFor(s)}_GetForEachStack(){return i}_Repeat(t){const s=this._runtime.GetEventSheetManager(),e=s.GetEventStack(),i=e.GetCurrentStackFrame(),r=i.GetCurrentEvent(),n=r.GetSolModifiers(),a=i.IsSolModifierAfterCnds(),o=e.Push(r),l=s.GetLoopStack(),h=l.Push();if(h.SetEnd(t),a)for(let e=0;e<t&&!h.IsStopped();++e)s.PushCopySol(n),h.SetIndex(e),r.Retrigger(i,o),s.PopSol(n);else for(let e=0;e<t&&!h.IsStopped();++e)h.SetIndex(e),r.Retrigger(i,o);return e.Pop(),l.Pop(),!1}*_DebugRepeat(t){const s=this._runtime.GetEventSheetManager(),e=s.GetEventStack(),i=e.GetCurrentStackFrame(),r=i.GetCurrentEvent(),n=r.GetSolModifiers(),a=i.IsSolModifierAfterCnds(),o=e.Push(r),l=s.GetLoopStack(),h=l.Push();if(h.SetEnd(t),a)for(let e=0;e<t&&!h.IsStopped();++e)s.PushCopySol(n),h.SetIndex(e),yield*r.DebugRetrigger(i,o),s.PopSol(n);else for(let e=0;e<t&&!h.IsStopped();++e)h.SetIndex(e),yield*r.DebugRetrigger(i,o);return e.Pop(),l.Pop(),!1}_While(){const t=this._runtime.GetEventSheetManager(),e=t.GetEventStack(),s=e.GetCurrentStackFrame(),i=s.GetCurrentEvent(),r=i.GetSolModifiers(),n=s.IsSolModifierAfterCnds(),a=e.Push(i),o=t.GetLoopStack(),l=o.Push();if(n)for(let e=0;!l.IsStopped();++e)t.PushCopySol(r),l.SetIndex(e),i.Retrigger(s,a)||l.Stop(),t.PopSol(r);else for(let e=0;!l.IsStopped();++e)l.SetIndex(e),i.Retrigger(s,a)||l.Stop();return e.Pop(),o.Pop(),!1}*_DebugWhile(){const t=this._runtime.GetEventSheetManager(),e=t.GetEventStack(),s=e.GetCurrentStackFrame(),i=s.GetCurrentEvent(),r=i.GetSolModifiers(),n=s.IsSolModifierAfterCnds(),a=e.Push(i),o=t.GetLoopStack(),l=o.Push();if(n)for(let e=0;!l.IsStopped();++e){t.PushCopySol(r),l.SetIndex(e);const h=yield*i.DebugRetrigger(s,a);h||l.Stop(),t.PopSol(r)}else for(let e=0;!l.IsStopped();++e){l.SetIndex(e);const c=yield*i.DebugRetrigger(s,a);c||l.Stop()}return e.Pop(),o.Pop(),!1}_For(e,t,s){const i=this._runtime.GetEventSheetManager(),r=i.GetEventStack(),n=r.GetCurrentStackFrame(),a=n.GetCurrentEvent(),o=a.GetSolModifiers(),l=n.IsSolModifierAfterCnds(),h=r.Push(a),c=i.GetLoopStack(),u=c.Push();if(u.SetName(e),u.SetEnd(s),s<t)if(l)for(let e=t;e>=s&&!u.IsStopped();--e)i.PushCopySol(o),u.SetIndex(e),a.Retrigger(n,h),i.PopSol(o);else for(let e=t;e>=s&&!u.IsStopped();--e)u.SetIndex(e),a.Retrigger(n,h);else if(l)for(let e=t;e<=s&&!u.IsStopped();++e)i.PushCopySol(o),u.SetIndex(e),a.Retrigger(n,h),i.PopSol(o);else for(let e=t;e<=s&&!u.IsStopped();++e)u.SetIndex(e),a.Retrigger(n,h);return r.Pop(),c.Pop(),!1}*_DebugFor(e,t,s){const i=this._runtime.GetEventSheetManager(),r=i.GetEventStack(),n=r.GetCurrentStackFrame(),a=n.GetCurrentEvent(),o=a.GetSolModifiers(),l=n.IsSolModifierAfterCnds(),h=r.Push(a),c=i.GetLoopStack(),u=c.Push();if(u.SetName(e),u.SetEnd(s),s<t)if(l)for(let e=t;e>=s&&!u.IsStopped();--e)i.PushCopySol(o),u.SetIndex(e),yield*a.DebugRetrigger(n,h),i.PopSol(o);else for(let e=t;e>=s&&!u.IsStopped();--e)u.SetIndex(e),yield*a.DebugRetrigger(n,h);else if(l)for(let e=t;e<=s&&!u.IsStopped();++e)i.PushCopySol(o),u.SetIndex(e),yield*a.DebugRetrigger(n,h),i.PopSol(o);else for(let e=t;e<=s&&!u.IsStopped();++e)u.SetIndex(e),yield*a.DebugRetrigger(n,h);return r.Pop(),c.Pop(),!1}_ForEach(s){const e=s.GetCurrentSol(),t=e.GetInstances();if(0!==t.length){const r=this._runtime.GetEventSheetManager(),n=r.GetEventStack(),o=n.GetCurrentStackFrame(),l=o.GetCurrentEvent(),h=l.GetSolModifiers(),c=o.IsSolModifierAfterCnds(),u=n.Push(l),_=r.GetLoopStack(),d=_.Push(),p=s.IsInContainer(),m=i.Push();if(a.shallowAssignArray(m,t),d.SetEnd(m.length),c)for(let e=0,t=m.length;e<t&&!d.IsStopped();++e){r.PushCopySol(h);const g=m[e];s.GetCurrentSol().SetSinglePicked(g),p&&g.SetSiblingsSinglePicked(),d.SetIndex(e),l.Retrigger(o,u),r.PopSol(h)}else{e._SetSelectAll(!1);const f=e._GetOwnInstances();a.clearArray(f),f.push(null);for(let e=0,t=m.length;e<t&&!d.IsStopped();++e){const S=m[e];f[0]=S,p&&S.SetSiblingsSinglePicked(),d.SetIndex(e),l.Retrigger(o,u)}}n.Pop(),_.Pop(),a.clearArray(m),i.Pop()}return!1}*_DebugForEach(s){const e=s.GetCurrentSol(),t=e.GetInstances();if(0!==t.length){const r=this._runtime.GetEventSheetManager(),n=r.GetEventStack(),o=n.GetCurrentStackFrame(),l=o.GetCurrentEvent(),h=l.GetSolModifiers(),c=o.IsSolModifierAfterCnds(),u=n.Push(l),_=r.GetLoopStack(),d=_.Push(),p=s.IsInContainer(),m=i.Push();if(a.shallowAssignArray(m,t),d.SetEnd(m.length),c)for(let e=0,t=m.length;e<t&&!d.IsStopped();++e){r.PushCopySol(h);const g=m[e];s.GetCurrentSol().SetSinglePicked(g),p&&g.SetSiblingsSinglePicked(),d.SetIndex(e),yield*l.DebugRetrigger(o,u),r.PopSol(h)}else{e._SetSelectAll(!1);const f=e._GetOwnInstances();a.clearArray(f),f.push(null);for(let e=0,t=m.length;e<t&&!d.IsStopped();++e){const S=m[e];f[0]=S,p&&S.SetSiblingsSinglePicked(),d.SetIndex(e),yield*l.DebugRetrigger(o,u)}}n.Pop(),_.Pop(),a.clearArray(m),i.Pop()}return!1}_ForEachOrdered(s,e){const t=s.GetCurrentSol(),r=t.GetInstances();if(0!==r.length){const n=this._runtime.GetEventSheetManager(),o=n.GetEventStack(),l=n.GetCurrentCondition(),h=o.GetCurrentStackFrame(),c=h.GetCurrentEvent(),u=c.GetSolModifiers(),_=h.IsSolModifierAfterCnds(),d=o.Push(c),p=n.GetLoopStack(),m=p.Push(),g=s.IsInContainer(),f=i.Push();a.clearArray(f),m.SetEnd(r.length);for(let e=0,t=r.length;e<t;++e)f.push([r[e],l.ReevaluateParameter(1,e)]);if(f.sort(ForEachOrdered_SortInstances2),1===e&&f.reverse(),_)for(let e=0,t=f.length;e<t&&!m.IsStopped();++e){n.PushCopySol(u);const S=f[e][0];s.GetCurrentSol().SetSinglePicked(S),g&&S.SetSiblingsSinglePicked(),m.SetIndex(e),c.Retrigger(h,d),n.PopSol(u)}else{t._SetSelectAll(!1);const C=t._GetOwnInstances();a.clearArray(C),C.push(null);for(let e=0,t=f.length;e<t&&!m.IsStopped();++e){const y=f[e][0];C[0]=y,g&&y.SetSiblingsSinglePicked(),m.SetIndex(e),c.Retrigger(h,d)}}o.Pop(),p.Pop(),a.clearArray(f),i.Pop()}return!1}*_DebugForEachOrdered(s,e){const t=s.GetCurrentSol(),r=t.GetInstances();if(0!==r.length){const n=this._runtime.GetEventSheetManager(),o=n.GetEventStack(),l=n.GetCurrentCondition(),h=o.GetCurrentStackFrame(),c=h.GetCurrentEvent(),u=c.GetSolModifiers(),_=h.IsSolModifierAfterCnds(),d=o.Push(c),p=n.GetLoopStack(),m=p.Push(),g=s.IsInContainer(),f=i.Push();a.clearArray(f),m.SetEnd(r.length);for(let e=0,t=r.length;e<t;++e)f.push([r[e],l.ReevaluateParameter(1,e)]);if(f.sort(ForEachOrdered_SortInstances2),1===e&&f.reverse(),_)for(let e=0,t=f.length;e<t&&!m.IsStopped();++e){n.PushCopySol(u);const S=f[e][0];s.GetCurrentSol().SetSinglePicked(S),g&&S.SetSiblingsSinglePicked(),m.SetIndex(e),yield*c.DebugRetrigger(h,d),n.PopSol(u)}else{t._SetSelectAll(!1);const C=t._GetOwnInstances();a.clearArray(C),C.push(null);for(let e=0,t=f.length;e<t&&!m.IsStopped();++e){const y=f[e][0];C[0]=y,g&&y.SetSiblingsSinglePicked(),m.SetIndex(e),yield*c.DebugRetrigger(h,d)}}o.Pop(),p.Pop(),a.clearArray(f),i.Pop()}return!1}_GetFunctionMap(e,t){let s=this._functionMaps.get(e);if(!s){if(!t)return null;s={defaultFunc:null,strMap:new Map},this._functionMaps.set(e,s)}return s}_DoCallMappedFunction(e,t,s,i,r){t.GetEventBlock().RunAsMappedFunctionCall(s,t.IsCopyPicked()),i&&e.PopSol(r)}*_DebugDoCallMappedFunction(e,t,s,i,r){yield*t.GetEventBlock().DebugRunAsMappedFunctionCall(s,t.IsCopyPicked()),i&&e.PopSol(r)}}}{const a1=self.C3;a1.Plugins.System.Type=class extends a1.DefendedBase{constructor(e){super(),this._objectClass=e,this._runtime=e.GetRuntime(),this._plugin=e.GetPlugin()}OnCreate(){}Release(){this._objectClass=null,this._runtime=null,this._plugin=null}}}{const d1=self.C3;d1.Plugins.System.Instance=class extends d1.DefendedBase{constructor(e,t){super(),this._inst=e,this._objectClass=this._inst.GetObjectClass(),this._sdkType=this._objectClass.GetSdkType(),this._runtime=this._inst.GetRuntime()}Release(){this._inst=null,this._objectClass=null,this._sdkType=null,this._runtime=null}}}{const h1=self.C3,i1=[];h1.Plugins.System.Cnds={EveryTick(){return!0},OnLayoutStart(){return!0},OnLayoutEnd(){return!0},OnSuspend(){return!0},OnResume(){return!0},IsSuspended(){return this._runtime.IsSuspended()},Else(){const e=this._runtime.GetCurrentEventStackFrame();return!e.GetElseBranchRan()&&!e.GetLastEventTrue()},TriggerOnce(){let e=this._runtime.GetCurrentCondition(),t=e.GetSavedDataMap(),s=t.get("TriggerOnce_lastTick");void 0===s&&(s=-1,t.set("TriggerOnce_lastTick",-1));const i=this._runtime.GetTickCount();return t.set("TriggerOnce_lastTick",i),this._runtime.IsLayoutFirstTick()||s!==i-1},Every(e){const t=this._runtime.GetCurrentCondition(),s=t.GetSavedDataMap(),i=s.get("Every_lastTime")||0,r=this._runtime.GetGameTime(),n=(s.has("Every_seconds")||s.set("Every_seconds",e),s.get("Every_seconds"));return i+n<=r?(s.set("Every_lastTime",i+n),r>=s.get("Every_lastTime")+.04&&s.set("Every_lastTime",r),s.set("Every_seconds",e),!0):(r<i-.1&&s.set("Every_lastTime",r),!1)},IsGroupActive(e){const t=this._runtime.GetEventSheetManager().GetEventGroupByName(e);return t&&t.IsGroupActive()},IsPreview(){return this._runtime.IsPreview()},IsMobile(){return h1.Platform.IsMobile},OnLoadFinished(){return!0},OnCanvasSnapshot(){return!0},EffectsSupported(){return!0},OnSaveComplete(){return!0},OnSaveFailed(){return!0},OnLoadComplete(){return!0},OnLoadFailed(){return!0},ObjectUIDExists(e){return!!this._runtime.GetInstanceByUID(e)},IsOnPlatform(e){switch(e){case 0:return"browser"===h1.Platform.Context;case 1:return"iOS"===h1.Platform.OS;case 2:return"Android"===h1.Platform.OS;case 8:return"cordova"===h1.Platform.Context;case 9:return"scirra-arcade"===this._runtime.GetExportType();case 10:return"nwjs"===h1.Platform.Context;case 13:return"windows-uwp"===this._runtime.GetExportType();default:return!1}},RegexTest(e,t,s){const i=this.GetRegex(t,s);return i.test(e)},Compare(e,t,s){return h1.compare(e,t,s)},CompareBetween(e,t,s){return t<=e&&e<=s},CompareVar(e,t,s){return h1.compare(e.GetValue(),t,s)},CompareBoolVar(e){return!!e.GetValue()},CompareTime(e,t){const s=this._runtime.GetGameTime();if(0!==e)return h1.compare(s,e,t);{const i=this._runtime.GetCurrentCondition(),r=i.GetSavedDataMap();return!r.get("CompareTime_executed")&&t<=s&&(r.set("CompareTime_executed",!0),!0)}},IsNaN(e){return isNaN(e)},AngleWithin(e,t,s){return h1.angleDiff(h1.toRadians(e),h1.toRadians(s))<=h1.toRadians(t)},IsClockwiseFrom(e,t){return h1.angleClockwise(h1.toRadians(e),h1.toRadians(t))},IsBetweenAngles(e,t,s){let i=h1.toRadians(e),r=h1.toRadians(t),n=h1.toRadians(s),a=!h1.angleClockwise(n,r);return a?!(!h1.angleClockwise(i,r)&&h1.angleClockwise(i,n)):h1.angleClockwise(i,r)&&!h1.angleClockwise(i,n)},IsValueType(e,t){return"number"==typeof e?0===t:1===t},EvaluateExpression(e){return!!e},OnSignal(e){return e.toLowerCase()===this._runtime.GetEventSheetManager().GetCurrentSignalTag()},PickByComparison(e,s,i,r){if(!e)return!1;let t=this._GetForEachStack(),n=t.Push(),a=e.GetCurrentSol(),o=(h1.shallowAssignArray(n,a.GetInstances()),a.IsSelectAll()&&h1.clearArray(a._GetOwnElseInstances()),this._runtime.GetCurrentCondition()),l=0;for(let e=0,t=n.length;e<t;++e){const c=n[e];n[l]=c,s=o.ReevaluateParameter(1,e),r=o.ReevaluateParameter(3,e),h1.compare(s,i,r)?++l:a._PushElseInstance(c)}h1.truncateArray(n,l),a.SetArrayPicked(n);const h=!!n.length;return h1.clearArray(n),t.Pop(),e.ApplySolToContainer(),h},PickByEvaluate(e,t){if(!e)return!1;let s=this._GetForEachStack(),i=s.Push(),r=e.GetCurrentSol(),n=(h1.shallowAssignArray(i,r.GetInstances()),r.IsSelectAll()&&h1.clearArray(r._GetOwnElseInstances()),this._runtime.GetCurrentCondition()),a=0;for(let e=0,t=i.length;e<t;++e){const l=i[e];i[a]=l,n.ReevaluateParameter(1,e)?++a:r._PushElseInstance(l)}h1.truncateArray(i,a),r.SetArrayPicked(i);const o=!!i.length;return h1.clearArray(i),s.Pop(),e.ApplySolToContainer(),o},PickByHighestLowestValue(e,s,i){if(!e)return!1;const t=e.GetCurrentSol(),r=t.GetInstances();if(0===r.length)return!1;let n=this._runtime.GetCurrentCondition(),a=null,o=0;for(let e=0,t=r.length;e<t;++e){const l=r[e];i=n.ReevaluateParameter(2,e),(null===a||0===s&&i<o||1===s&&i>o)&&(o=i,a=l)}return t.PickOne(a),e.ApplySolToContainer(),!0},PickNth(e,t){if(!e)return!1;const s=e.GetCurrentSol(),i=s.GetInstances();if((t=Math.floor(t))>=i.length)return!1;const r=i[t];return s.PickOne(r),e.ApplySolToContainer(),!0},PickRandom(e){if(!e)return!1;const t=e.GetCurrentSol(),s=t.GetInstances(),i=Math.floor(this._runtime.Random()*s.length);if(i>=s.length)return!1;const r=s[i];return t.PickOne(r),e.ApplySolToContainer(),!0},PickAll(e){if(!e)return!1;if(!e.GetInstanceCount())return!1;const t=e.GetCurrentSol();return t._SetSelectAll(!0),e.ApplySolToContainer(),!0},PickOverlappingPoint(e,s,i){if(!e)return!1;const r=e.GetCurrentSol(),t=r.GetInstances(),n=this._runtime.GetCurrentEvent(),a=n.IsOrBlock(),o=this._runtime.GetCurrentCondition().IsInverted();r.IsSelectAll()?(h1.shallowAssignArray(i1,t),r.ClearArrays(),r._SetSelectAll(!1)):a?(h1.shallowAssignArray(i1,r._GetOwnElseInstances()),h1.clearArray(r._GetOwnElseInstances())):(h1.shallowAssignArray(i1,r._GetOwnInstances()),h1.clearArray(r._GetOwnInstances()));for(let e=0,t=i1.length;e<t;++e){const l=i1[e];h1.xor(l.GetWorldInfo().ContainsPoint(s,i),o)?r._PushInstance(l):r._PushElseInstance(l)}return e.ApplySolToContainer(),h1.xor(!!r._GetOwnInstances().length,o)},PickLastCreated(t){if(!t)return!1;let s=t.IsFamily(),i=null,r=this._runtime._GetInstancesPendingCreate();for(let e=r.length-1;0<=e;--e){const n=r[e];if(s){if(n.GetObjectClass().BelongsToFamily(t)){i=n;break}}else if(n.GetObjectClass()===t){i=n;break}}if(!i){const a=t.GetInstances();a.length&&(i=a.at(-1))}if(!i)return!1;const e=t.GetCurrentSol();return e.PickOne(i),t.ApplySolToContainer(),!0},Repeat(e){return this._runtime.IsDebugging()?this._DebugRepeat(e):this._Repeat(e)},While(){return this._runtime.IsDebugging()?this._DebugWhile():this._While()},For(e,t,s){return this._runtime.IsDebugging()?this._DebugFor(e,t,s):this._For(e,t,s)},ForEach(e){return this._runtime.IsDebugging()?this._DebugForEach(e):this._ForEach(e)},ForEachOrdered(e,t,s){return this._runtime.IsDebugging()?this._DebugForEachOrdered(e,s):this._ForEachOrdered(e,s)},LayerVisible(e){return!!e&&e.IsVisible()},LayerInteractive(e){return!!e&&e.IsSelfAndParentsInteractive()},LayerIsHTML(e){return!!e&&e.IsHTMLElementsLayer()},LayerEmpty(e){return!!e&&!e.GetInstanceCount()},LayerCmpOpacity(e,t,s){return!!e&&h1.compare(100*e.GetOpacity(),t,s)},LayerNameExists(e){const t=this._runtime.GetMainRunningLayout();return!!t&&t.HasLayerByName(e)},OnImageLoadingComplete(){return!0},IsLoadingImages(){return 0<this._imagesLoadingTotal},TemplateExists(e,t){const s=this._runtime.GetTemplateManager();return!!s&&!!t&&!!s.GetTemplateData(e,t)}}}{let SortZOrderList2=function(e,t){const s=e[0],i=t[0],r=s-i;if(0!=r)return r;const n=e[1],a=t[1];return n-a},SortInstancesByValue2=function(e,t){return e[1]-t[1]};SortZOrderList=SortZOrderList2,SortInstancesByValue=SortInstancesByValue2;const M2=self.C3,N2=[],O2=[],P2=M2.New(M2.Rect),Q2=M2.New(M2.Color),R2=[];M2.Plugins.System.Acts={SetVar(e,t){e.SetValue(t)},AddVar(e,t){e.IsNumber()&&"number"!=typeof t&&(t=parseFloat(t)),e.SetValue(e.GetValue()+t)},SubVar(e,t){e.IsNumber()&&e.SetValue(e.GetValue()-t)},SetBoolVar(e,t){e.SetValue(!!t)},ToggleBoolVar(e){e.SetValue(!e.GetValue())},ResetEventVar(e){e.SetValue(e.GetInitialValue())},ResetGlobals(e){this._runtime.GetEventSheetManager().ResetAllGlobalsToInitialValue(e)},CreateObject(e,t,s,i,r,n){if(e&&t){const a=this._runtime.CreateInstance(e,t,s,i,r,n);if(a){r&&t.SortAndAddInstancesByZIndex(a);const o=this._runtime.GetEventSheetManager(),l=(o.BlockFlushingInstances(!0),a._TriggerOnCreatedOnSelfAndRelated(),o.BlockFlushingInstances(!1),new Map);a.CollectInstancesToPick(l,e,r);for(const[h,c]of l)h.GetCurrentSol().SetSetPicked(c)}}},CreateObjectByName(e,t,s,i,r,n){if(e&&t){const a=this._runtime.GetObjectClassByName(e);a&&M2.Plugins.System.Acts.CreateObject.call(this,a,t,s,i,r,n)}},RecreateInitialObjects(r,n,a,o,l,e,h,c,u,_,d){if(r){let t=this._runtime.GetCurrentLayout(),s=t;if(e){const p=this._runtime.GetLayoutManager().GetLayoutByName(e);if(!p)return;s=p}let i=null;if(!("number"!=typeof h||0<=h)||(i=s.GetLayer(h))){let e=null;if(!("number"!=typeof c||0<=c)||(e=t.GetLayer(c))){P2.set(n,a,o,l);const m=s.RecreateInitialObjects(r,P2,i,e,u,_,d);r.GetCurrentSol().SetArrayPicked(m),r.ApplySolToContainer()}}}},StopLoop(){const e=this._loopStack;e.IsInLoop()&&e.GetCurrent().Stop()},SetGroupActive(e,t){const s=this._runtime.GetEventSheetManager().GetEventGroupByName(e);s&&(0===t?s.SetGroupActive(!1):1===t?s.SetGroupActive(!0):s.SetGroupActive(!s.IsGroupActive()))},SetTimescale(e){this._runtime.SetTimeScale(e)},SetObjectTimescale(e,t){if(t<0&&(t=0),e){const s=e.GetCurrentSol(),i=s.GetInstances();for(const r of i)r.SetTimeScale(t)}},RestoreObjectTimescale(e){if(e){const t=e.GetCurrentSol(),s=t.GetInstances();for(const i of s)i.RestoreTimeScale()}},Wait(e,t){if(!(e<0)){const s=this._runtime.GetEventSheetManager().AddScheduledWait();return t?s.InitTimer(e):s.InitWallTimer(e),!0}},WaitForSignal(e){return this._runtime.GetEventSheetManager().AddScheduledWait().InitSignal(e),!0},WaitForPreviousActions(){const e=this._runtime.GetEventSheetManager();return e.AddScheduledWait().InitPromise(e.GetPromiseForAllAsyncActions()),!0},Signal(e){this._runtime.GetEventSheetManager().Signal(e)},async SnapshotCanvas(e,t,s,i,r,n){const a=this._runtime.GetCanvasManager();a&&(this.UpdateRender(),await a.SnapshotCanvas(0===e?"image/png":"image/jpeg",t/100,s,i,r,n),await this._runtime.TriggerAsync(M2.Plugins.System.Cnds.OnCanvasSnapshot,null))},SetCanvasSize(e,t){if(!(e<=0||t<=0)){this._runtime.SetViewportSize(e,t),this._runtime.GetCurrentLayout().BoundScrolling();const s=this._runtime.GetCanvasManager();s&&("off"!==s.GetCurrentFullscreenMode()&&this._runtime.SetOriginalViewportSize(e,t),s.SetSize(s.GetLastWidth(),s.GetLastHeight(),!0),this._runtime.UpdateRender())}},SetFullscreenQuality(e){const t=this._runtime.GetCanvasManager();t&&"off"!==t.GetCurrentFullscreenMode()&&(t.SetFullscreenScalingQuality(0!==e?"high":"low"),t.SetSize(t.GetLastWidth(),t.GetLastHeight(),!0))},SaveState(e){this._runtime.SaveToSlot(e)},SaveStateJSON(){this._runtime.SaveToJsonString()},LoadState(e){this._runtime.LoadFromSlot(e)},LoadStateJSON(e){this._runtime.LoadFromJsonString(e)},SetHalfFramerateMode(e){},ResetPersisted(){for(const e of this._runtime.GetLayoutManager().GetAllLayouts())e.ResetPersistData()},SetPixelRounding(e){this._runtime.SetPixelRoundingEnabled(0!==e)},SetFramerateMinMax(e,t){this._runtime.SetMaxDt(1/e),this._runtime.SetMinDt(1/t)},SetDeltaTimeMinMax(e,t){this._runtime.SetMinDt(e),this._runtime.SetMaxDt(t)},SetFramerateMode(e){this._runtime._SetFramerateMode(["vsync","unlimited-tick","unlimited-frame"][e])},SortZOrderByInstVar(e,s){if(e){const t=e.GetCurrentSol(),i=t.GetInstances(),r=N2,n=O2,a=this._runtime.GetCurrentLayout(),o=e.IsFamily(),l=e.GetFamilyIndex();for(let e=0,t=i.length;e<t;++e){const h=i[e],c=h.GetWorldInfo();if(c){let e;e=o?h.GetInstanceVariableValue(s+h.GetObjectClass().GetFamilyInstanceVariableOffset(l)):h.GetInstanceVariableValue(s),r.push([c.GetLayer().GetIndex(),c.GetZIndex()]),n.push([h,e])}}if(r.length){r.sort(SortZOrderList2),n.sort(SortInstancesByValue2);let s=!1;for(let e=0,t=r.length;e<t;++e){const u=n[e][0],_=a.GetLayerByIndex(r[e][0]),d=r[e][1],p=_._GetInstances();p[d]!==u&&((p[d]=u).GetWorldInfo()._SetLayer(_,!0),_.SetZIndicesChanged(u),s=!0)}s&&this._runtime.UpdateRender(),M2.clearArray(N2),M2.clearArray(O2)}}},SetCollisionCellSize(e,t){e=Math.floor(e),t=Math.floor(t),e<=0||t<=0||!Number.isFinite(e)||!Number.isFinite(t)||this._runtime.GetCollisionEngine().SetCollisionCellSize(e,t)},GoToLayout(e){if(!this._runtime.IsLoading()){const t=this._runtime.GetLayoutManager();t.IsPendingChangeMainLayout()||t.ChangeMainLayout(e)}},GoToLayoutByName(e){if(!this._runtime.IsLoading()){const t=this._runtime.GetLayoutManager();if(!t.IsPendingChangeMainLayout()){const s=t.GetLayoutByName(e);s&&t.ChangeMainLayout(s)}}},NextPrevLayout(e){if(!this._runtime.IsLoading()){const t=this._runtime.GetLayoutManager();if(!t.IsPendingChangeMainLayout()){const s=t.GetAllLayouts(),i=s.indexOf(t.GetMainRunningLayout());if((!e||0!==i)&&(e||i!==s.length-1)){const r=s[i+(e?-1:1)];t.ChangeMainLayout(r)}}}},RestartLayout(){if(!this._runtime.IsLoading()){const e=this._runtime.GetLayoutManager();e.IsPendingChangeMainLayout()||(e.ChangeMainLayout(e.GetMainRunningLayout()),this._runtime.GetEventSheetManager().ResetAllGroupsInitialActivation())}},SetLayerVisible(e,t){e&&e.SetVisible(t)},SetLayerInteractive(e,t){e&&e.SetInteractive(t)},SetLayerHTML(e,t){e&&e.SetIsHTMLElementsLayer(t)},SetLayerOpacity(e,t){e&&e.SetOpacity(t/100)},SetLayerScale(e,t){e&&e.SetOwnScale(t)},SetLayerScaleRate(e,t){e&&e.SetScaleRate(t)},SetLayerAngle(e,t){e&&e.SetAngle(M2.toRadians(+t))},SetLayerScroll(e,t,s){e&&(e.SetOwnScrollPositionEnabled(!0),e.SetScrollX(t),e.SetScrollY(s))},RestoreLayerScroll(e){e&&e.SetOwnScrollPositionEnabled(!1)},SetLayerParallax(e,t,s){e&&e.SetParallax(t/100,s/100)},SetLayerZElevation(e,t){e&&e.SetZElevation(+t)},SetLayerBackground(e,t){if(e){Q2.setFromRgbValue(t),Q2.clamp();const s=e.GetBackgroundColor();s.equalsIgnoringAlpha(Q2)||(s.copyRgb(Q2),this.UpdateRender())}},SetLayerTransparent(e,t){e&&e.SetTransparent(t)},SetLayerBlendMode(e,t){e&&e.SetBlendMode(t)},SetLayerEffectEnabled(e,t,s){if(e){const i=e.GetEffectList(),r=i.GetEffectTypeByName(s);if(r){const n=1===t;r.IsActive()!==n&&(r.SetActive(n),e.UpdateActiveEffects(),this._runtime.UpdateRender())}}},SetLayerEffectParam(e,t,s,i){if(e){const r=e.GetEffectList(),n=r.GetEffectTypeByName(t);if(n){s=Math.floor(s);const a=n.GetShaderProgram().GetParameterType(s);if(a){"color"===a?(Q2.setFromRgbValue(i),i=Q2):"percent"===a&&(i/=100);const o=r.SetEffectParameter(n.GetIndex(),s,i);o&&n.IsActive()&&this._runtime.UpdateRender()}}}},SetLayerForceOwnTexture(e,t){e&&e.SetForceOwnTexture(t)},SetLayoutScale(e){this._runtime.GetCurrentLayout().SetScale(+e)},SetLayoutAngle(e){this._runtime.GetCurrentLayout().SetAngle(M2.toRadians(+e))},SetLayoutEffectEnabled(e,t){const s=this._runtime.GetCurrentLayout(),i=s.GetEffectList(),r=i.GetEffectTypeByName(t);if(r){const n=1===e;r.IsActive()!==n&&(r.SetActive(n),s.UpdateActiveEffects(),this._runtime.UpdateRender())}},SetLayoutEffectParam(e,t,s){const i=this._runtime.GetCurrentLayout(),r=i.GetEffectList(),n=r.GetEffectTypeByName(e);if(n){t=Math.floor(t);const a=n.GetShaderProgram().GetParameterType(t);if(a){"color"===a?(Q2.setFromRgbValue(s),s=Q2):"percent"===a&&(s/=100);const o=r.SetEffectParameter(n.GetIndex(),t,s);o&&n.IsActive()&&this._runtime.UpdateRender()}}},SetLayoutVanishingPoint(e,t){const s=this._runtime.GetCurrentLayout();s.SetVanishingPointXY(e/100,t/100)},SetLayoutProjection(e){const t=this._runtime.GetCurrentLayout();0===e?t.SetPerspectiveProjection():t.SetOrthographicProjection()},ScrollX(e){const t=this._runtime.GetCurrentLayout();t.SetScrollX(e)},ScrollY(e){const t=this._runtime.GetCurrentLayout();t.SetScrollY(e)},Scroll(e,t){const s=this._runtime.GetCurrentLayout();s.SetScrollX(e),s.SetScrollY(t)},ScrollToObject(e){if(e){const t=e.GetFirstPicked();if(t){const s=t.GetWorldInfo();if(s){const i=this._runtime.GetCurrentLayout();i.SetScrollX(s.GetX()),i.SetScrollY(s.GetY())}}}},AddLayer(e,t,s){const i=this._runtime.GetCurrentLayout();try{i.AddLayer(e,t,s)}catch(e){console.warn("[Construct] Cannot add layer: ",e)}},MoveLayer(e,t,s){if(e){const i=this._runtime.GetCurrentLayout();try{i.MoveLayer(e,t,s)}catch(e){console.warn("[Construct] Cannot move layer: ",e)}}},RemoveLayer(e){if(e){const t=this._runtime.GetCurrentLayout();t.RemoveLayer(e)}},RemoveAllDynamicLayers(){this._runtime.GetCurrentLayout().RemoveAllDynamicLayers()},async LoadObjectTextures(e){const t=this._runtime.GetMainRunningLayout();if(t&&e&&!this._runtime.IsLoading()){const s=e.IsFamily()?e.GetFamilyMembers():[e];await this._LoadTexturesForObjectClasses(t,s)}},async LoadObjectTexturesByName(e){await M2.Plugins.System.Acts.LoadObjectTextures.call(this,this._runtime.GetObjectClassByName(e))},UnloadObjectTextures(e){const t=this._runtime.GetMainRunningLayout();if(t&&e){const s=e.IsFamily()?e.GetFamilyMembers():[e];this._UnloadTexturesForObjectClasses(t,s)}},UnloadObjectTexturesByName(e){M2.Plugins.System.Acts.UnloadObjectTextures.call(this,this._runtime.GetObjectClassByName(e))},UnloadUnusedTextures(){const e=this._runtime.GetMainRunningLayout();if(e){const t=e._GetTextureLoadedObjectTypes();this._UnloadTexturesForObjectClasses(e,t)}},async LoadLayoutTextures(e){const t=this._runtime.GetMainRunningLayout();e&&t&&!this._runtime.IsLoading()&&await this._LoadTexturesForObjectClasses(t,e._GetInitialObjectClasses())},async LoadLayoutTexturesByName(e){const t=this._runtime.GetMainRunningLayout(),s=this._runtime.GetLayoutManager().GetLayoutByName(e);s&&t&&!this._runtime.IsLoading()&&await this._LoadTexturesForObjectClasses(t,s._GetInitialObjectClasses())},SetFunctionReturnValue(e){const t=this._eventStack.GetCurrentExpFuncStackFrame();if(t)switch(t.GetFunctionReturnType()){case 1:"number"==typeof e&&t.SetFunctionReturnValue(e);break;case 2:"string"==typeof e&&t.SetFunctionReturnValue(e);break;case 3:t.SetFunctionReturnValue(e)}},MapFunction(e,t,s){const i=this._GetFunctionMap(e.toLowerCase(),!0),r=i.strMap,n=t.toLowerCase(),a=(r.has(n)&&console.warn(`[Construct] Function map '${e}' string '${t}' already in map; overwriting entry`),M2.first(r.values())||i.defaultFunc);if(a){const o=0!==a.GetReturnType(),l=0!==s.GetReturnType();if(o!=l)return void console.error(`[Construct] Function map '${e}' string '${t}' function return type not compatible with other functions in the map; entry ignored`)}r.set(n,s)},MapFunctionDefault(e,t){const s=this._GetFunctionMap(e.toLowerCase(),!0),i=(s.defaultFunc&&console.warn(`[Construct] Function map '${e}' already has a default; overwriting entry`),M2.first(s.strMap.values())||s.defaultFunc);if(i){const r=0!==i.GetReturnType(),n=0!==t.GetReturnType();if(r!=n)return void console.error(`[Construct] Function map '${e}' default: function return type not compatible with other functions in the map; entry ignored`)}s.defaultFunc=t},CallMappedFunction(e,t,s){const i=this._runtime,r=i.IsDebugging()?R2:null,n=(s=Math.floor(s),this._GetFunctionMap(e.toLowerCase(),!1));if(!n)return console.warn(`[Construct] Call mapped function: map name '${e}' not found; call ignored`),r;let a=n.strMap.get(t.toLowerCase());if(!a){if(!n.defaultFunc)return console.warn(`[Construct] Call mapped function: no function associated with map '${e}' string '${t}'; call ignored (consider setting a default)`),r;a=n.defaultFunc,s=0}if(!a.IsEnabled())return r;if(0!==a.GetReturnType())return console.warn(`[Construct] Call mapped function: map '${e}' string '${t}' has a return type so cannot be called`),r;const o=i.GetEventSheetManager(),l=o.GetCurrentEvent(),h=l.GetSolModifiersIncludingParents(),c=0<h.length,u=(c&&(a.IsCopyPicked()?o.PushCopySol(h):o.PushCleanSol(h)),[]),_=o.FindFirstFunctionBlockParent(l);if(_){const p=_.GetFunctionParameters();for(let e=s,t=p.length;e<t;++e)u.push(p[e].GetValue())}const d=a.GetFunctionParameters();for(let e=u.length,t=d.length;e<t;++e)u.push(d[e].GetInitialValue());return i.IsDebugging()?this._DebugDoCallMappedFunction(o,a,u,c,h):this._DoCallMappedFunction(o,a,u,c,h)}}}{const Xf=self.C3;Xf.Plugins.System.Exps={int:function(e){return"string"==typeof e&&(e=parseInt(e,10),isNaN(e))&&(e=0),Math.floor(e)},float:function(e){return"string"==typeof e&&(e=parseFloat(e),isNaN(e))?0:e},str(e){return e.toString()},len(e){return"string"==typeof e?e.length:0},random(e,t){return void 0===t?this._runtime.Random()*e:this._runtime.Random()*(t-e)+e},choose(...e){const t=Math.floor(this._runtime.Random()*e.length);return e[t]},chooseindex(e,...t){return"number"!=typeof e&&(e=0),t[e=Xf.clamp(Math.floor(e),0,t.length-1)]},pi(){return Math.PI},infinity(){return 1/0},sqrt(e){return Math.sqrt(e)},abs(e){return Math.abs(e)},round(e){return Math.round(e)},roundtodp(e,t){t=Math.max(Math.floor(t),0);const s=Math.pow(10,t);return Math.round((e+Number.EPSILON)*s)/s},floor(e){return Math.floor(e)},ceil(e){return Math.ceil(e)},sign(e){return Math.sign(e)},sin(e){return Math.sin(Xf.toRadians(e))},cos(e){return Math.cos(Xf.toRadians(e))},tan(e){return Math.tan(Xf.toRadians(e))},asin(e){return Xf.toDegrees(Math.asin(e))},acos(e){return Xf.toDegrees(Math.acos(e))},atan(e){return Xf.toDegrees(Math.atan(e))},exp(e){return Math.exp(e)},ln(e){return Math.log(e)},log10(e){return Math.log10(e)},max(...s){let i=s[0];"number"!=typeof i&&(i=0);for(let t=1,e=s.length;t<e;++t){let e=s[t];"number"==typeof e&&i<e&&(i=e)}return i},min(...s){let i=s[0];"number"!=typeof i&&(i=0);for(let t=1,e=s.length;t<e;++t){let e=s[t];"number"==typeof e&&i>e&&(i=e)}return i},clamp(e,t,s){return Xf.clamp(e,t,s)},distance(e,t,s,i){return Xf.distanceTo(e,t,s,i)},angle(e,t,s,i){return Xf.toDegrees(Xf.angleTo(e,t,s,i))},lerp(e,t,s){return Xf.lerp(e,t,s)},unlerp(e,t,s){return Xf.unlerp(e,t,s)},qarp(e,t,s,i){return Xf.qarp(e,t,s,i)},cubic(e,t,s,i,r){return Xf.cubic(e,t,s,i,r)},cosp(e,t,s){return Xf.cosp(e,t,s)},anglediff(e,t){return Xf.toDegrees(Xf.angleDiff(Xf.toRadians(e),Xf.toRadians(t)))},anglelerp(e,t,s){return Xf.toDegrees(Xf.angleLerp(Xf.toRadians(e),Xf.toRadians(t),s))},anglerotate(e,t,s){return Xf.toDegrees(Xf.angleRotate(Xf.toRadians(e),Xf.toRadians(t),Xf.toRadians(s)))},setbit(e,t,s){return(e|=0)&~(1<<(t|=0))|(s=0!==s?1:0)<<t},togglebit(e,t){return(e|=0)^1<<(0|t)},getbit(e,t){return(e|=0)&1<<(0|t)?1:0},newline(){return"\n"},uppercase(e){return"string"==typeof e?e.toUpperCase():""},lowercase(e){return"string"==typeof e?e.toLowerCase():""},left(e,t){return"string"==typeof e?e.substr(0,t):""},mid(e,t,s){return"string"!=typeof e?"":s<0?e.substr(t):e.substr(t,s)},right(e,t){return"string"==typeof e?e.substr(Math.max(e.length-t,0)):""},trim(e){return"string"==typeof e?e.trim():""},tokenat(e,t,s){if("string"!=typeof e||"string"!=typeof s)return"";let i=e.split(s);return(t=Math.floor(t))<0||t>=i.length?"":i[t]},tokencount(e,t){return"string"==typeof e&&"string"==typeof t&&e.length?e.split(t).length:0},find(e,t){return"string"==typeof e&&"string"==typeof t?e.search(new RegExp(Xf.EscapeRegex(t),"i")):-1},findcase(e,t){return"string"==typeof e&&"string"==typeof t?e.search(new RegExp(Xf.EscapeRegex(t),"")):-1},replace(e,t,s){return"string"==typeof e&&"string"==typeof t&&"string"==typeof s?e.replace(new RegExp(Xf.EscapeRegex(t),"gi"),s):"string"==typeof e?e:""},stringsub(e,...s){let i=e;for(let e=0,t=s.length;e<t;++e)i=i.replaceAll(`{${e}}`,s[e].toString());return i},regexsearch(e,t,s){const i=this.GetRegex(t,s);return e?e.search(i):-1},regexreplace(e,t,s,i){const r=this.GetRegex(t,s);return e?e.replace(r,i):""},regexmatchcount(e,t,s){const i=this.GetRegexMatches(e.toString(),t,s);return i?i.length:0},regexmatchat(e,t,s,i){i=Math.floor(i);const r=this.GetRegexMatches(e.toString(),t,s);return!r||i<0||i>=r.length?"":r[i]},zeropad(e,t){let s=e<0?"-":"",i=t-(e=e<0?-e:e).toString().length;return(s+="0".repeat(Math.max(i,0)))+e.toString()},urlencode(e){return encodeURIComponent(e)},urldecode(e){return decodeURIComponent(e)},dt(){return this._runtime._GetDtFast()},wallclockdt(){return this._runtime.GetDt1()},timescale(){return this._runtime.GetTimeScale()},wallclocktime(){return(Date.now()-this._runtime.GetStartTime())/1e3},unixtime(){return Date.now()},time(){return this._runtime.GetGameTime()},tickcount(){return this._runtime.GetTickCount()},objectcount(){return this._runtime.GetObjectCount()},fps(){return this._runtime.GetFramesPerSecond()},cpuutilisation(){return this._runtime.GetMainThreadTime()},gpuutilisation(){return this._runtime.GetGPUUtilisation()},windowwidth(){return this._runtime.GetCanvasManager().GetDeviceWidth()},windowheight(){return this._runtime.GetCanvasManager().GetDeviceHeight()},originalwindowwidth(){return this._runtime.GetOriginalViewportWidth()},originalwindowheight(){return this._runtime.GetOriginalViewportHeight()},originalviewportwidth(){return this._runtime.GetOriginalViewportWidth()},originalviewportheight(){return this._runtime.GetOriginalViewportHeight()},scrollx(){return this._runtime.GetCurrentLayout().GetScrollX()},scrolly(){return this._runtime.GetCurrentLayout().GetScrollY()},layoutname(){return this._runtime.GetCurrentLayout().GetName()},layoutscale(){return this._runtime.GetCurrentLayout().GetScale()},layoutangle(){return Xf.toDegrees(this._runtime.GetCurrentLayout().GetAngle())},layoutwidth(){return this._runtime.GetCurrentLayout().GetWidth()},layoutheight(){return this._runtime.GetCurrentLayout().GetHeight()},vanishingpointx(){return 100*this._runtime.GetCurrentLayout().GetVanishingPointX()},vanishingpointy(){return 100*this._runtime.GetCurrentLayout().GetVanishingPointY()},viewportleft(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetViewport3D().getLeft():0},viewporttop(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetViewport3D().getTop():0},viewportright(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetViewport3D().getRight():0},viewportbottom(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetViewport3D().getBottom():0},viewportwidth(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetViewport3D().width():0},viewportheight(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetViewport3D().height():0},viewportmidx(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);if(t){const s=t.GetViewport3D();return(s.getLeft()+s.getRight())/2}return 0},viewportmidy(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);if(t){const s=t.GetViewport3D();return(s.getTop()+s.getBottom())/2}return 0},canvastolayerx(e,t,s){const i=this._runtime.GetCurrentLayout().GetLayer(e);return i?i.CanvasCssToLayer(t,s)[0]:0},canvastolayery(e,t,s){const i=this._runtime.GetCurrentLayout().GetLayer(e);return i?i.CanvasCssToLayer(t,s)[1]:0},layertocanvasx(e,t,s){const i=this._runtime.GetCurrentLayout().GetLayer(e);return i?i.LayerToCanvasCss(t,s)[0]:0},layertocanvasy(e,t,s){const i=this._runtime.GetCurrentLayout().GetLayer(e);return i?i.LayerToCanvasCss(t,s)[1]:0},layertolayerx(e,t,s,i){const r=this._runtime.GetCurrentLayout(),n=r.GetLayer(e),a=r.GetLayer(t);if(!n||!a||n===a)return s;const[o,l]=n.LayerToCanvasCss(s,i);return a.CanvasCssToLayer(o,l)[0]},layertolayery(e,t,s,i){const r=this._runtime.GetCurrentLayout(),n=r.GetLayer(e),a=r.GetLayer(t);if(!n||!a||n===a)return i;const[o,l]=n.LayerToCanvasCss(s,i);return a.CanvasCssToLayer(o,l)[1]},layerscale(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetOwnScale():0},layerangle(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?Xf.toDegrees(t.GetOwnAngle()):0},layeropacity(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?100*t.GetOpacity():0},layerscalerate(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetScaleRate():0},layerscrollx(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetScrollX():0},layerscrolly(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetScrollY():0},layerparallaxx(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?100*t.GetParallaxX():0},layerparallaxy(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?100*t.GetParallaxY():0},layerzelevation(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetZElevation():0},layerindex(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetIndex():-1},canvassnapshot(){const e=this._runtime.GetCanvasManager();return e?e.GetCanvasSnapshotUrl():""},loopindex(e){const t=this._loopStack;if(!t.IsInLoop())return 0;if(e){const s=t.FindByName(e);return s?s.GetIndex():0}return t.GetCurrent().GetIndex()},savestatejson(){return this._runtime.GetLastSaveJsonString()},callmapped(e,t,...s){const i=this._GetFunctionMap(e.toLowerCase(),!1);if(!i)return console.warn(`[Construct] Call mapped function: map name '${e}' not found; returning 0`),0;let r=i.strMap.get(t.toLowerCase());if(!r){if(!i.defaultFunc)return console.warn(`[Construct] Call mapped function: no function associated with map '${e}' string '${t}'; returning 0 (consider setting a default)`),0;r=i.defaultFunc}const n=r.GetReturnType(),a=r.GetDefaultReturnValue();if(0===n)return console.warn(`[Construct] Call mapped function: map '${e}' string '${t}' has no return type so cannot be called from an expression; returning 0`),0;if(!r.IsEnabled())return a;const o=this._runtime,l=o.GetEventSheetManager(),h=l.GetCurrentEvent(),c=h.GetSolModifiersIncludingParents(),u=0<c.length,_=(u&&(r.IsCopyPicked()?l.PushCopySol(c):l.PushCleanSol(c)),r.GetFunctionParameters());for(let e=s.length,t=_.length;e<t;++e)s.push(_[e].GetInitialValue());const d=r.GetEventBlock(),p=d.RunAsExpressionFunctionCall(d.GetSolModifiersIncludingParents(),r.IsCopyPicked(),n,a,...s);return u&&l.PopSol(c),p},loadingprogress(){return this._runtime.GetAssetManager().GetLoadProgress()},imageloadingprogress(){return this.GetImageLoadingProgress()},renderer(){return this._runtime.GetWebGPURenderer()?"webgpu":"webgl"},rendererdetail(){return this._runtime.GetWebGPURenderer()?this._runtime.GetWebGPURenderer().GetAdapterInfoString():this._runtime.GetWebGLRenderer().GetUnmaskedRenderer()},imagememoryusage(){let e=this._runtime.GetRenderer().GetEstimatedTextureMemoryUsage();return Math.round(100*e/1048576)/100},rgb(e,t,s){return Xf.PackRGB(e,t,s)},rgbex(e,t,s){return Xf.PackRGBEx(e/100,t/100,s/100)},rgba(e,t,s,i){return Xf.PackRGBAEx(e/100,t/100,s/100,i/100)},rgbex255(e,t,s){return Xf.PackRGBEx(e/255,t/255,s/255)},rgba255(e,t,s,i){return Xf.PackRGBAEx(e/255,t/255,s/255,i/255)},projectname(){return this._runtime.GetProjectName()},projectversion(){return this._runtime.GetProjectVersion()},currenteventsheetname(){return this._runtime.GetCurrentEvent().GetEventSheet().GetName()},currenteventnumber(){return this._runtime.GetCurrentEvent().GetDisplayNumber()}}}{const a=self.C3;a.Plugins.Sprite=class extends a.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{const d=self.C3,e=self.C3X,f=[],g=(d.Plugins.Sprite.Type=class extends d.SDKTypeBase{constructor(e){super(e),this._animations=e.GetAnimations()}Release(){d.clearArray(this._animations),super.Release()}OnCreate(){for(const e of this._animations)e.LoadAllAssets(this._runtime)}LoadTextures(t){const s={sampling:this._runtime.GetSampling()};return Promise.all(this._animations.map(e=>e.LoadAllTextures(t,s)))}ReleaseTextures(){for(const e of this._animations)e.ReleaseAllTextures()}OnDynamicTextureLoadComplete(){this._UpdateAllCurrentTexture()}_UpdateAllCurrentTexture(){for(const e of this._objectClass.instancesIncludingPendingCreate())e.GetSdkInstance()._UpdateCurrentTexture()}FinishCondition(e){d.Plugins.Sprite.FinishCollisionCondition(this,e)}BeforeRunAction(e){f.push({objectClass:null,createHierarchy:!1,instances:[]})}_SpawnPickInstance(e,t,s){const i=f.at(-1);i.objectClass=e,i.createHierarchy=s,i.instances.push(t)}AfterRunAction(e){const t=f.pop(),s=t.objectClass,i=t.createHierarchy;if(s){const r=new Map;for(const n of t.instances)n.CollectInstancesToPick(r,s,i);for(const[a,o]of r)a.GetCurrentSol().SetSetPicked(o)}}_AddAnimation(e){const t=this.GetObjectClass().AddAnimation(e),s=this.GetRuntime(),i=t.GetFrameAt(0);return i.GetImageInfo().LoadStaticTexture(s.GetRenderer(),{sampling:s.GetSampling()}).then(()=>this._UpdateAllCurrentTexture()),t}_RemoveAnimation(e){for(const t of this._objectClass.instancesIncludingPendingCreate())t.GetSdkInstance()._OnAnimationRemoved(e);this.GetObjectClass().RemoveAnimation(e)}_AddAnimationFrame(e,t){const s=this._objectClass.GetAnimationByName(e);if(!s)throw new Error(`cannot find animation name '${e}'`);let i=s.FrameTagOrIndexToIndex(t);i<0&&(i+=s.GetFrameCount()+1);const r=d.AnimationFrameInfo.CreateDynamic(this.GetRuntime()),n=(s.InsertFrameAt(r,i),this.GetRuntime());r.GetImageInfo().LoadStaticTexture(n.GetRenderer(),{sampling:n.GetSampling()}).then(()=>this._UpdateAllCurrentTexture());for(const a of this._objectClass.instancesIncludingPendingCreate())a.GetSdkInstance()._OnAnimationFramesChanged();return r}_RemoveAnimationFrame(e,t){const s=this._objectClass.GetAnimationByName(e);if(!s)throw new Error(`cannot find animation name '${e}'`);if(1===s.GetFrameCount())throw new Error(`cannot remove last frame from animation '${e}'`);let i=s.FrameTagOrIndexToIndex(t);i<0&&(i+=s.GetFrameCount()),s.RemoveFrameAt(i);for(const r of this._objectClass.instancesIncludingPendingCreate())r.GetSdkInstance()._OnAnimationFramesChanged()}GetScriptInterfaceClass(){return self.ISpriteObjectType}},new WeakMap);self.ISpriteObjectType=class extends self.IObjectClass{constructor(e){super(e),g.set(this,e.GetSdkType())}getAnimation(t){e.RequireString(t);const s=g.get(this).GetObjectClass().GetAnimationByName(t);return s?s.GetIAnimation():null}getAllAnimations(){return g.get(this).GetObjectClass().GetAllAnimations().map(e=>e.GetIAnimation())}addAnimation(t){return e.RequireString(t),g.get(this)._AddAnimation(t).GetIAnimation()}removeAnimation(t){e.RequireString(t),g.get(this)._RemoveAnimation(t)}addAnimationFrame(t,s){if(e.RequireString(t),"number"!=typeof s&&"string"!=typeof s)throw new TypeError("invalid insert location");return g.get(this)._AddAnimationFrame(t,s).GetIAnimationFrame()}removeAnimationFrame(t,s){if(e.RequireString(t),"number"!=typeof s&&"string"!=typeof s)throw new TypeError("invalid insert location");g.get(this)._RemoveAnimationFrame(t,s)}}}{const ea=self.C3,fa=self.C3X,ga=0,ha=1,ia=2,ja=3,ka=ea.New(ea.Rect),la=ea.New(ea.Quad),ma=ea.New(ea.Vector2),na=1,oa=2,pa=4,qa=(ea.Plugins.Sprite.Instance=class extends ea.SDKWorldInstanceBase{constructor(e,t){super(e);let s=!0,i="",r=0,n=!0;t&&(s=!!t[ga],i=t[ha],r=t[ia],n=t[ja]),this._currentAnimation=this._objectClass.GetAnimationByName(i)||this._objectClass.GetAnimations()[0],this._currentFrameIndex=ea.clamp(r,0,this._currentAnimation.GetFrameCount()-1),this._currentAnimationFrame=this._currentAnimation.GetFrameAt(this._currentFrameIndex);const a=this._currentAnimationFrame.GetImageInfo(),o=(this._currentTexture=a.GetTexture(),this._currentRcTex=a.GetTexRect(),this._currentQuadTex=a.GetTexQuad(),this.HandleRendererContextLoss(),e.SetFlag(oa,!0),e.SetFlag(na,0<=this._currentAnimation.GetSpeed()),this._currentAnimationSpeed=Math.abs(this._currentAnimation.GetSpeed()),this._currentAnimationRepeatTo=this._currentAnimation.GetRepeatTo(),this._animationTimer=ea.New(ea.KahanSum),this._frameStartTime=0,this._animationRepeats=0,this._animTriggerName="",this._changeAnimFrameIndex=-1,this._changeAnimationName="",this._changeAnimationFrom=0,this.GetWorldInfo());this._bquadRef=o.GetBoundingQuad(),o.SetVisible(s),o.SetCollisionEnabled(n),o.SetOriginX(this._currentAnimationFrame.GetOriginX()),o.SetOriginY(this._currentAnimationFrame.GetOriginY()),o.SetSourceCollisionPoly(this._currentAnimationFrame.GetCollisionPoly()),o.SetBboxChanged(),1===this._objectClass.GetAnimationCount()&&1===this._objectClass.GetAnimations()[0].GetFrameCount()||0===this._currentAnimationSpeed||this._StartTicking()}Release(){this._currentAnimation=null,this._currentAnimationFrame=null,this._currentTexture=null,this._animationTimer=null,super.Release()}GetCurrentImageInfo(){return this._currentAnimationFrame.GetImageInfo()}IsOriginalSizeKnown(){return!0}OnRendererContextLost(){this._currentTexture=null}OnRendererContextRestored(){this._UpdateCurrentTexture()}Draw(e){const t=this._currentTexture;if(null!==t){e.SetTexture(t);const s=this.GetWorldInfo();s.HasMesh()?this._DrawMesh(s,e):this._DrawStandard(s,e)}}_DrawStandard(e,t){let s=this._bquadRef;this._runtime.IsPixelRoundingEnabled()&&(s=e.PixelRoundQuad(s)),t.Quad4(s,this._currentQuadTex)}_DrawMesh(t,e){const s=t.GetTransformedMesh();if(t.IsMeshChanged()){t.CalculateBbox(ka,la,!1);let e=la;this._runtime.IsPixelRoundingEnabled()&&(e=t.PixelRoundQuad(e)),s.CalculateTransformedMesh(t.GetSourceMesh(),e,this._currentQuadTex),t.SetMeshChanged(!1)}s.Draw(e)}GetAnimationTime(){return this._animationTimer.Get()}IsAnimationPlaying(){return this._inst.GetFlag(oa)}SetAnimationPlaying(e){this._inst.SetFlag(oa,e)}IsPlayingForwards(){return this._inst.GetFlag(na)}SetPlayingForwards(e){this._inst.SetFlag(na,e)}IsInAnimationTrigger(){return this._inst.GetFlag(pa)}SetInAnimationTrigger(e){this._inst.SetFlag(pa,e)}Tick(){this._changeAnimationName&&this._DoChangeAnimation(),0<=this._changeAnimFrameIndex&&this._DoChangeAnimFrame();const e=this._currentAnimationSpeed;if(this.IsAnimationPlaying()&&0!==e){const t=this._runtime.GetDt(this._inst),s=(this._animationTimer.Add(t),this.GetAnimationTime()),i=this._currentAnimationFrame,r=i.GetDuration()/e;if(!(s<this._frameStartTime+r)){const n=this._currentAnimation,a=this._currentAnimationRepeatTo,o=n.GetFrameCount(),l=n.GetRepeatCount(),h=n.IsLooping(),c=n.IsPingPong(),u=(this.IsPlayingForwards()?this._currentFrameIndex++:this._currentFrameIndex--,this._frameStartTime+=r,this._currentFrameIndex>=o&&(c?(this.SetPlayingForwards(!1),this._currentFrameIndex=o-2):!h&&(this._animationRepeats++,this._animationRepeats>=l)?this._FinishAnimation(!1):this._currentFrameIndex=a),this._currentFrameIndex<0&&(c?(this._currentFrameIndex=1,this.SetPlayingForwards(!0),h||(this._animationRepeats++,this._animationRepeats>=l&&this._FinishAnimation(!0))):!h&&(this._animationRepeats++,this._animationRepeats>=l)?this._FinishAnimation(!0):this._currentFrameIndex=a),this._currentFrameIndex=ea.clamp(this._currentFrameIndex,0,o-1),n.GetFrameAt(this._currentFrameIndex));s>this._frameStartTime+u.GetDuration()/e&&(this._frameStartTime=s),this._OnFrameChanged(i,u)}}else this._StopTicking()}_FinishAnimation(e){this._currentFrameIndex=e?0:this._currentAnimation.GetFrameCount()-1,this.SetAnimationPlaying(!1),this._animTriggerName=this._currentAnimation.GetName(),this.SetInAnimationTrigger(!0),this.DispatchScriptEvent("animationend",!1,{animationName:this._animTriggerName}),this.Trigger(ea.Plugins.Sprite.Cnds.OnAnyAnimFinished),this.Trigger(ea.Plugins.Sprite.Cnds.OnAnimFinished),this.SetInAnimationTrigger(!1),this._animationRepeats=0}_OnFrameChanged(s,i,e){if(s!==i){const t=this.GetWorldInfo(),r=s.GetImageInfo(),n=i.GetImageInfo(),a=r.GetWidth(),o=r.GetHeight(),l=n.GetWidth(),h=n.GetHeight(),c=(e&&e.onFrameChange?e.onFrameChange(t,a,o,l,h):(a!==l&&t.SetWidth(t.GetWidth()*(l/a)),o!==h&&t.SetHeight(t.GetHeight()*(h/o))),t.SetOriginX(i.GetOriginX()),t.SetOriginY(i.GetOriginY()),t.SetSourceCollisionPoly(i.GetCollisionPoly()),t.SetBboxChanged(),this._currentAnimationFrame=i,this._currentTexture=n.GetTexture(),this._currentRcTex=n.GetTexRect(),this._currentQuadTex=n.GetTexQuad(),this.GetInstance().GetBehaviorInstances());for(let e=0,t=c.length;e<t;++e)c[e].OnSpriteFrameChanged(s,i);this.DispatchScriptEvent("framechange",!1,{animationName:this._currentAnimation.GetName(),animationFrame:this._currentFrameIndex}),this.Trigger(ea.Plugins.Sprite.Cnds.OnFrameChanged),this._runtime.UpdateRender()}}_StartAnim(e){this.SetAnimationPlaying(!0),this._frameStartTime=this.GetAnimationTime(),1===e&&0!==this._currentFrameIndex&&(this._changeAnimFrameIndex=0,this.IsInAnimationTrigger()||this._DoChangeAnimFrame()),this._StartTicking()}_SetAnim(e,t,s){this._changeAnimationName=e,this._changeAnimationFrom=t,this._StartTicking(),!s&&this.IsInAnimationTrigger()||this._DoChangeAnimation()}_GetCurrentAnimation(){return this._currentAnimation}_GetCurrentAnimationName(){return this._changeAnimationName||this._currentAnimation.GetName()}_OnAnimationRemoved(e){ea.equalsNoCase(e,this._GetCurrentAnimationName())&&this._SetAnim(this._objectClass.GetFirstAnimation().GetName(),1,!0)}_SetAnimFrame(e){if("string"==typeof e)if(String(Number(e))===e)e=Number(e);else{const t=this._objectClass.GetAnimationByName(this._GetCurrentAnimationName());if(!t)return;if(-1===(e=t.GetFrameIndexByTag(e)))return}isFinite(e)&&(this._changeAnimFrameIndex=e,this.IsInAnimationTrigger()||this._DoChangeAnimFrame())}_OnAnimationFramesChanged(){if(!this._changeAnimationName&&-1===this._changeAnimFrameIndex){const e=this._currentAnimationFrame,t=this._currentAnimation.GetFrameAt(ea.clamp(this._currentFrameIndex,0,this._currentAnimation.GetFrameCount()-1));e!==t&&this._OnFrameChanged(e,t),1<this._currentAnimation.GetFrameCount()&&0<this._currentAnimationSpeed&&this._StartTicking()}}_GetAnimFrame(){return this._currentFrameIndex}_GetAnimFrameTag(){return this._currentAnimationFrame.GetTag()}_SetAnimSpeed(e){this._currentAnimationSpeed=Math.abs(e),this.SetPlayingForwards(0<=e),0<this._currentAnimationSpeed&&this._StartTicking()}_GetAnimSpeed(){return this.IsPlayingForwards()?this._currentAnimationSpeed:-this._currentAnimationSpeed}_SetAnimRepeatToFrame(e){"string"==typeof e&&-1===(e=this._currentAnimation.GetFrameIndexByTag(e))||(e=ea.clamp(Math.floor(e),0,this._currentAnimation.GetFrameCount()-1),this._currentAnimationRepeatTo=e)}_GetAnimRepeatToFrame(){return this._currentAnimationRepeatTo}_DoChangeAnimation(e){const t=this._currentAnimationFrame,s=this._objectClass.GetAnimationByName(this._changeAnimationName);if(this._changeAnimationName="",s&&(s!==this._currentAnimation||!this.IsAnimationPlaying())){this._currentAnimation=s,this.SetPlayingForwards(0<=s.GetSpeed()),this._currentAnimationSpeed=Math.abs(s.GetSpeed()),this._currentAnimationRepeatTo=s.GetRepeatTo(),this._currentFrameIndex=ea.clamp(this._currentFrameIndex,0,this._currentAnimation.GetFrameCount()-1),1===this._changeAnimationFrom&&(this._currentFrameIndex=0),this.SetAnimationPlaying(!0),this._frameStartTime=this.GetAnimationTime();const i=this._currentAnimation.GetFrameAt(this._currentFrameIndex);this._OnFrameChanged(t,i,e)}}_DoChangeAnimFrame(e){const t=this._currentAnimationFrame,s=this._currentFrameIndex;if(this._currentFrameIndex=ea.clamp(Math.floor(this._changeAnimFrameIndex),0,this._currentAnimation.GetFrameCount()-1),this._changeAnimFrameIndex=-1,e||s!==this._currentFrameIndex){const i=this._currentAnimation.GetFrameAt(this._currentFrameIndex);this._OnFrameChanged(t,i),this._frameStartTime=this.GetAnimationTime()}}_UpdateCurrentTexture(){const e=this._currentAnimationFrame.GetImageInfo();this._currentTexture=e.GetTexture(),this._currentRcTex=e.GetTexRect(),this._currentQuadTex=e.GetTexQuad(),this.GetWorldInfo().SetMeshChanged(!0)}GetTexture(){return this._currentTexture}GetTexRect(){return this._currentRcTex}GetTexQuad(){return this._currentQuadTex}GetImagePointCount(){return this._currentAnimationFrame.GetImagePointCount()}GetImagePoint(e){let t=this._currentAnimationFrame,s=this.GetWorldInfo(),i=null;if("string"==typeof e)i=t.GetImagePointByName(e);else{if("number"!=typeof e)throw new TypeError("expected string or number");i=t.GetImagePointByIndex(e-1)}let r=s.GetTotalZElevation();if(!i)return[s.GetX(),s.GetY(),r];if(ma.copy(i.GetVec2()),s.HasMesh()){const[n,a,o]=s.GetSourceMesh().TransformPoint(ma.getX(),ma.getY());ma.set(n,a),r+=o}return ma.offset(-t.GetOriginX(),-t.GetOriginY()),ma.scale(s.GetWidth(),s.GetHeight()),ma.rotate(s.GetAngle()),ma.offset(s.GetX(),s.GetY()),[ma.getX(),ma.getY(),r]}GetCollisionPolyPointCount(){return this.GetWorldInfo().GetTransformedCollisionPoly().pointCount()}GetCollisionPolyPoint(e){e=Math.floor(e);const t=this.GetWorldInfo(),s=t.GetTransformedCollisionPoly(),i=s.pointCount();if((e=e===i?0:e)<0||i<=e)return[0,0];const r=s.pointsArr();return[r[2*e+0]+t.GetX(),r[2*e+1]+t.GetY()]}GetDebuggerProperties(){const t=ea.Plugins.Sprite.Acts,e="plugins.sprite.debugger.animation-properties";return[{title:e+".title",properties:[{name:e+".current-animation",value:this._currentAnimation.GetName(),onedit:e=>this.CallAction(t.SetAnim,e,0)},{name:e+".current-frame",value:this._currentFrameIndex,onedit:e=>this.CallAction(t.SetAnimFrame,e)},{name:e+".is-playing",value:this.IsAnimationPlaying(),onedit:e=>e?this.CallAction(t.StartAnim,0):this.CallAction(t.StopAnim)},{name:e+".speed",value:this._currentAnimationSpeed,onedit:e=>this.CallAction(t.SetAnimSpeed,e)},{name:e+".repeats",value:this._animationRepeats,onedit:e=>this._animationRepeats=e}]}]}SaveToJson(){const e={a:this._currentAnimation.GetSID()},t=(0!==this._frameStartTime&&(e.fs=this._frameStartTime),this.GetAnimationTime()),s=(0!==t&&(e.at=t),0!==this._currentFrameIndex&&(e.f=this._currentFrameIndex),0!==this._currentAnimationSpeed&&(e.cas=this._currentAnimationSpeed),1!==this._animationRepeats&&(e.ar=this._animationRepeats),0!==this._currentAnimationRepeatTo&&(e.rt=this._currentAnimationRepeatTo),this.IsAnimationPlaying()||(e.ap=this.IsAnimationPlaying()),this.IsPlayingForwards()||(e.af=this.IsPlayingForwards()),this.GetWorldInfo());return s.IsCollisionEnabled()&&(e.ce=s.IsCollisionEnabled()),e}LoadFromJson(e){const t=this.GetObjectClass().GetAnimationBySID(e.a),s=(t&&(this._currentAnimation=t),this._frameStartTime=e.hasOwnProperty("fs")?e.fs:0,this._animationTimer.Set(e.hasOwnProperty("at")?e.at:0),e.hasOwnProperty("f")?e.f:0),i=(this._currentFrameIndex=ea.clamp(s,0,this._currentAnimation.GetFrameCount()-1),this._currentAnimationSpeed=e.hasOwnProperty("cas")?e.cas:0,this._animationRepeats=e.hasOwnProperty("ar")?e.ar:1,e.hasOwnProperty("rt")?e.rt:0),r=(this._currentAnimationRepeatTo=ea.clamp(i,0,this._currentAnimation.GetFrameCount()-1),this.SetAnimationPlaying(!e.hasOwnProperty("ap")||!!e.ap),this.SetPlayingForwards(!e.hasOwnProperty("af")||!!e.af),this._currentAnimation.GetFrameAt(this._currentFrameIndex)),n=(this._currentAnimationFrame=r,this._UpdateCurrentTexture(),this.GetWorldInfo());n.SetOriginX(r.GetOriginX()),n.SetOriginY(r.GetOriginY()),n.SetSourceCollisionPoly(r.GetCollisionPoly()),n.SetCollisionEnabled(!!e.ce),this.IsAnimationPlaying()&&this._StartTicking()}GetPropertyValueByIndex(e){const t=this.GetWorldInfo();switch(e){case ja:return t.IsCollisionEnabled();case ia:return ea.clamp(this._currentFrameIndex,0,this._currentAnimation.GetFrameCount()-1);case ha:return this._currentAnimation.GetName()}}SetPropertyValueByIndex(e,t,s){const i=this.GetWorldInfo();switch(e){case ja:i.SetCollisionEnabled(!!t);break;case ia:{this.SetAnimationPlaying(!1);const r=this._currentAnimation.GetFrameCount()-1,n=t=ea.clamp(t,0,r),a=this._currentAnimation.GetFrameAt(this._currentFrameIndex),o=this._currentAnimation.GetFrameAt(n);this._OnFrameChanged(a,o,s),this._currentFrameIndex=ea.clamp(n,0,r);break}case ha:{this._changeAnimationName=t,this._DoChangeAnimation(s);const l=this._currentAnimation.GetFrameCount();1<l&&0<this._currentAnimation.GetSpeed()?this._StartTicking():this._StopTicking();break}}}GetScriptInterfaceClass(){return self.ISpriteInstance}},new WeakMap),ra=new Map([["current-frame",0],["beginning",1]]);self.ISpriteInstance=class extends self.IWorldInstance{constructor(){super(),qa.set(this,self.IInstance._GetInitInst().GetSdkInstance())}getImagePointCount(){return qa.get(this).GetImagePointCount()}getImagePointX(e){return this.getImagePoint(e)[0]}getImagePointY(e){return this.getImagePoint(e)[1]}getImagePointZ(e){return this.getImagePoint(e)[2]}getImagePoint(e){if("string"!=typeof e&&"number"!=typeof e)throw new TypeError("expected string or number");return qa.get(this).GetImagePoint(e)}getPolyPointCount(){return qa.get(this).GetCollisionPolyPointCount()}getPolyPointX(e){return fa.RequireFiniteNumber(e),qa.get(this).GetCollisionPolyPoint(e)[0]}getPolyPointY(e){return fa.RequireFiniteNumber(e),qa.get(this).GetCollisionPolyPoint(e)[1]}getPolyPoint(e){return fa.RequireFiniteNumber(e),qa.get(this).GetCollisionPolyPoint(e)}stopAnimation(){qa.get(this).SetAnimationPlaying(!1)}startAnimation(e="current-frame"){fa.RequireString(e);const t=ra.get(e);if(void 0===t)throw new Error("invalid mode");qa.get(this)._StartAnim(t)}setAnimation(e,t="beginning"){fa.RequireString(e),fa.RequireString(t);const s=ra.get(t);if(void 0===s)throw new Error("invalid mode");const i=qa.get(this);if(!i.GetObjectClass().GetAnimationByName(e))throw new Error(`animation name "${e}" does not exist`);i._SetAnim(e,s)}getAnimation(e){fa.RequireString(e);const t=qa.get(this).GetObjectClass().GetAnimationByName(e);return t?t.GetIAnimation():null}get animation(){return qa.get(this)._GetCurrentAnimation().GetIAnimation()}get animationName(){return qa.get(this)._GetCurrentAnimationName()}set animationFrame(e){fa.RequireFiniteNumber(e),qa.get(this)._SetAnimFrame(e)}get animationFrame(){return qa.get(this)._GetAnimFrame()}set animationFrameTag(e){fa.RequireString(e),qa.get(this)._SetAnimFrame(e)}get animationFrameTag(){return qa.get(this)._GetAnimFrameTag()}set animationSpeed(e){fa.RequireFiniteNumber(e),qa.get(this)._SetAnimSpeed(e)}get animationSpeed(){return qa.get(this)._GetAnimSpeed()}set animationRepeatToFrame(e){fa.RequireFiniteNumber(e),qa.get(this)._SetAnimRepeatToFrame(e)}get animationRepeatToFrame(){return qa.get(this)._GetAnimRepeatToFrame()}get imageWidth(){return qa.get(this).GetCurrentImageInfo().GetWidth()}get imageHeight(){return qa.get(this).GetCurrentImageInfo().GetHeight()}getImageSize(){const e=qa.get(this).GetCurrentImageInfo();return[e.GetWidth(),e.GetHeight()]}async replaceCurrentAnimationFrame(e){fa.RequireInstanceOf(e,Blob);const t=qa.get(this),s=t.GetRuntime(),i=t.GetCurrentImageInfo(),r=ea.New(ea.ImageInfo);if(r.LoadDynamicBlobAsset(s,e),await r.LoadStaticTexture(s.GetRenderer(),{sampling:s.GetSampling()}),t.WasReleased())r.Release();else{i.ReplaceWith(r);const n=t.GetSdkType();n._UpdateAllCurrentTexture(),n.GetObjectClass().Dispatcher().dispatchEvent(new ea.Event("animationframeimagechange")),s.UpdateRender()}}setSolidCollisionFilter(e,t){fa.RequireString(t),qa.get(this).GetWorldInfo().SetSolidCollisionFilter(!!e,t)}}}{const Vb=self.C3;Vb.Plugins.Sprite.Cnds={IsAnimPlaying(e){return Vb.equalsNoCase(this._GetCurrentAnimationName(),e)},CompareFrame(e,t){return Vb.compare(this._currentFrameIndex,e,t)},CompareFrameTag(e,t){if("string"!=typeof t)return!1;const s=this._currentAnimationFrame.GetTag();return Vb.compare(s.toLowerCase(),e,t.toLowerCase())},CompareAnimSpeed(e,t){return Vb.compare(this._GetAnimSpeed(),e,t)},OnAnimFinished(e){return Vb.equalsNoCase(this._animTriggerName,e)},OnAnyAnimFinished(){return!0},OnFrameChanged(){return!0},IsMirrored(){return this.GetWorldInfo().GetWidth()<0},IsFlipped(){return this.GetWorldInfo().GetHeight()<0},OnURLLoaded(){return!0},OnURLFailed(){return!0},IsCollisionEnabled(){return this.GetWorldInfo().IsCollisionEnabled()}}}{const d1=self.C3;d1.Plugins.Sprite.Acts={Spawn(e,t,s,i,r){if(e&&t){const[n,a]=this.GetImagePoint(s),o=this._runtime.CreateInstance(e,t,n,a,i,r);if(o){if(i&&t.SortAndAddInstancesByZIndex(o),e.GetPlugin().IsRotatable()){const h=o.GetWorldInfo();h.SetAngle(this.GetWorldInfo().GetAngle()),h.SetBboxChanged()}const l=this._runtime.GetEventSheetManager();l.BlockFlushingInstances(!0),o._TriggerOnCreatedOnSelfAndRelated(),l.BlockFlushingInstances(!1),e!==this._runtime.GetCurrentAction().GetObjectClass()&&this._sdkType._SpawnPickInstance(e,o,i)}}},StopAnim(){this.SetAnimationPlaying(!1)},StartAnim(e){this._StartAnim(e)},SetAnim(e,t){this._SetAnim(e,t)},SetAnimFrame(e){this._SetAnimFrame(e)},SetAnimSpeed(e){this._SetAnimSpeed(e)},SetAnimRepeatToFrame(e){this._SetAnimRepeatToFrame(e)},AddRemoveAnimation(t,e){try{0===t?this.GetSdkType()._AddAnimation(e):this.GetSdkType()._RemoveAnimation(e)}catch(e){console.error(`[Construct] Error ${0===t?"adding":"removing"} animation: `,e)}},AddRemoveAnimationFrame(t,e,s){try{0===t?this.GetSdkType()._AddAnimationFrame(e,s):this.GetSdkType()._RemoveAnimationFrame(e,s)}catch(e){console.error(`[Construct] Error ${0===t?"adding":"removing"} animation frame: `,e)}},SetMirrored(e){const t=this.GetWorldInfo(),s=t.GetWidth(),i=Math.abs(s)*(0===e?-1:1);s!==i&&(t.SetWidth(i),t.SetBboxChanged())},SetFlipped(e){const t=this.GetWorldInfo(),s=t.GetHeight(),i=Math.abs(s)*(0===e?-1:1);s!==i&&(t.SetHeight(i),t.SetBboxChanged())},SetScale(e){const t=this._currentAnimationFrame,s=t.GetImageInfo(),i=this.GetWorldInfo(),r=i.GetWidth()<0?-1:1,n=i.GetHeight()<0?-1:1,a=s.GetWidth()*e*r,o=s.GetHeight()*e*n;i.GetWidth()===a&&i.GetHeight()===o||(i.SetSize(a,o),i.SetBboxChanged())},async LoadURL(e,t,s){const i=this._currentAnimationFrame,r=i.GetImageInfo(),n=this.GetWorldInfo(),a=this._runtime,o=this._sdkType;if(r.GetURL()===e)0===t&&(n.SetSize(r.GetWidth(),r.GetHeight()),n.SetBboxChanged()),this.Trigger(d1.Plugins.Sprite.Cnds.OnURLLoaded);else{const l=d1.New(d1.ImageInfo);try{if(await l.LoadDynamicAsset(a,e),!l.IsLoaded())throw new Error("image failed to load");if(this.WasReleased())return void l.Release();await l.LoadStaticTexture(a.GetRenderer(),{sampling:a.GetSampling()})}catch(e){return console.error("Load image from URL failed: ",e),void(this.WasReleased()||this.Trigger(d1.Plugins.Sprite.Cnds.OnURLFailed))}this.WasReleased()?l.Release():(r.ReplaceWith(l),o._UpdateAllCurrentTexture(),o.GetObjectClass().Dispatcher().dispatchEvent(new d1.Event("animationframeimagechange")),a.UpdateRender(),0===t&&(n.SetSize(r.GetWidth(),r.GetHeight()),n.SetBboxChanged()),await this.TriggerAsync(d1.Plugins.Sprite.Cnds.OnURLLoaded))}},SetCollisions(e){this.GetWorldInfo().SetCollisionEnabled(e)},SetSolidCollisionFilter(e,t){this.GetWorldInfo().SetSolidCollisionFilter(0===e,t)},SetEffect(e){this.GetWorldInfo().SetBlendMode(e),this._runtime.UpdateRender()}}}{const dc=self.C3;dc.Plugins.Sprite.Exps={AnimationFrame(){return this._GetAnimFrame()},AnimationFrameTag(){return this._GetAnimFrameTag()},AnimationFrameCount(){return this._currentAnimation.GetFrameCount()},AnimationName(){return this._currentAnimation.GetName()},AnimationSpeed(){return this._GetAnimSpeed()},OriginalAnimationSpeed(){return this._currentAnimation.GetSpeed()},ImagePointX(e){return this.GetImagePoint(e)[0]},ImagePointY(e){return this.GetImagePoint(e)[1]},ImagePointZ(e){return this.GetImagePoint(e)[2]},ImagePointCount(){return this.GetImagePointCount()},ImageWidth(){return this.GetCurrentImageInfo().GetWidth()},ImageHeight(){return this.GetCurrentImageInfo().GetHeight()},PolyPointXAt(e){return this.GetCollisionPolyPoint(e)[0]},PolyPointYAt(e){return this.GetCollisionPolyPoint(e)[1]},PolyPointCount(){return this.GetCollisionPolyPointCount()}}}{const a=self.C3;a.Plugins.TiledBg=class extends a.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{let WrapModeToStr2=function(e){switch(e){case 0:return"clamp-to-edge";case 1:return"repeat";case 2:return"mirror-repeat"}return"repeat"};WrapModeToStr=WrapModeToStr2;const d=self.C3;d.Plugins.TiledBg.Type=class extends d.SDKTypeBase{constructor(e,t){super(e),this._wrapX="repeat",this._wrapY="repeat",t&&(this._wrapX=WrapModeToStr2(t[0]),this._wrapY=WrapModeToStr2(t[1]))}Release(){super.Release()}OnCreate(){this.GetImageInfo().LoadAsset(this._runtime)}LoadTextures(e){return this.GetImageInfo().LoadStaticTexture(e,{sampling:this._runtime.GetSampling(),wrapX:this._wrapX,wrapY:this._wrapY})}ReleaseTextures(){this.GetImageInfo().ReleaseTexture()}GetWrapModeX(){return this._wrapX}GetWrapModeY(){return this._wrapY}}}{const j=self.C3,k=self.C3X,l=0,m=1,n=4,o=5,p=6,q=7,r=8,s=9,t=10,u=11,v=12,w=13,x=14,y=j.New(j.Rect),z=j.New(j.Quad),A=j.New(j.Rect),B=j.New(j.Quad),C=(j.Plugins.TiledBg.Instance=class extends j.SDKWorldInstanceBase{constructor(e,i){super(e),this._imageOffsetX=0,this._imageOffsetY=0,this._imageScaleX=1,this._imageScaleY=1,this._imageAngle=0,this._enableTileRandomization=!1,this._tileXRandom=0,this._tileYRandom=0,this._tileAngleRandom=0,this._tileBlendMarginX=0,this._tileBlendMarginY=0,this._ownImageInfo=null,i&&(this.GetWorldInfo().SetVisible(!!i[l]),this._imageOffsetX=i[n],this._imageOffsetY=i[o],this._imageScaleX=i[p],this._imageScaleY=i[q],this._imageAngle=j.toRadians(i[r]),this._enableTileRandomization=!!i[s],this._tileXRandom=i[t],this._tileYRandom=i[u],this._tileAngleRandom=i[v],this._tileBlendMarginX=i[w],this._tileBlendMarginY=i[x])}Release(){this._ReleaseOwnImage(),super.Release()}_ReleaseOwnImage(){this._ownImageInfo&&(this._ownImageInfo.Release(),this._ownImageInfo=null)}CalculateTextureCoordsFor3DFace(e,t,s){const i=this.GetCurrentImageInfo(),r=i.GetWidth(),n=i.GetHeight(),a=this._imageOffsetX/r,o=this._imageOffsetY/n,l=this._imageAngle;A.set(0,0,e/(r*this._imageScaleX),t/(n*this._imageScaleY)),A.offset(-a,-o),0===l?s.setFromRect(A):s.setFromRotatedRect(A,-l)}SetTilingShaderProgram(e,t=!0){if(this._enableTileRandomization){const s=this.GetCurrentImageInfo();e.SetTileRandomizationMode(),e.SetTileRandomizationInfo(s.GetWidth()*this._imageScaleX,s.GetHeight()*this._imageScaleY,this._tileXRandom,this._tileYRandom,this._tileAngleRandom,this._tileBlendMarginX,this._tileBlendMarginY)}else t&&e.SetTextureFillMode()}Draw(e){const t=this.GetCurrentImageInfo(),s=t.GetTexture();if(null!==s){this.SetTilingShaderProgram(e),e.SetTexture(s);const i=t.GetWidth(),r=t.GetHeight(),n=this._imageOffsetX/i,a=this._imageOffsetY/r,o=this.GetWorldInfo();A.set(0,0,o.GetWidth()/(i*this._imageScaleX),o.GetHeight()/(r*this._imageScaleY)),A.offset(-n,-a),o.HasMesh()?this._DrawMesh(o,e):this._DrawStandard(o,e)}}_DrawStandard(e,t){let s=e.GetBoundingQuad();this._runtime.IsPixelRoundingEnabled()&&(s=e.PixelRoundQuad(s)),0===this._imageAngle?t.Quad3(s,A):(B.setFromRotatedRect(A,-this._imageAngle),t.Quad4(s,B))}_DrawMesh(s,e){const i=s.GetTransformedMesh();if(s.IsMeshChanged()){s.CalculateBbox(y,z,!1);let e=z,t=(this._runtime.IsPixelRoundingEnabled()&&(e=s.PixelRoundQuad(e)),A);0!==this._imageAngle&&(B.setFromRotatedRect(A,-this._imageAngle),t=B),i.CalculateTransformedMesh(s.GetSourceMesh(),e,t),s.SetMeshChanged(!1)}i.Draw(e)}GetCurrentImageInfo(){return this._ownImageInfo||this._objectClass.GetImageInfo()}IsOriginalSizeKnown(){return!0}GetTexture(){return this.GetCurrentImageInfo().GetTexture()}_SetMeshChanged(){this.GetWorldInfo().SetMeshChanged(!0)}_SetImageOffsetX(e){this._imageOffsetX!==e&&(this._imageOffsetX=e,this._runtime.UpdateRender(),this._SetMeshChanged())}_GetImageOffsetX(){return this._imageOffsetX}_SetImageOffsetY(e){this._imageOffsetY!==e&&(this._imageOffsetY=e,this._runtime.UpdateRender(),this._SetMeshChanged())}_GetImageOffsetY(){return this._imageOffsetY}_SetImageScaleX(e){this._imageScaleX!==e&&(this._imageScaleX=e,this._runtime.UpdateRender(),this._SetMeshChanged())}_GetImageScaleX(){return this._imageScaleX}_SetImageScaleY(e){this._imageScaleY!==e&&(this._imageScaleY=e,this._runtime.UpdateRender(),this._SetMeshChanged())}_GetImageScaleY(){return this._imageScaleY}_SetImageAngle(e){this._imageAngle!==e&&(this._imageAngle=e,this._runtime.UpdateRender(),this._SetMeshChanged())}_GetImageAngle(){return this._imageAngle}_SetTileRandomizationEnabled(e){this._enableTileRandomization!==(e=!!e)&&(this._enableTileRandomization=e,this._runtime.UpdateRender())}_IsTileRandomizationEnabled(){return this._enableTileRandomization}_SetTileXRandom(e){this._tileXRandom!==e&&(this._tileXRandom=e,this._IsTileRandomizationEnabled())&&this._runtime.UpdateRender()}_GetTileXRandom(){return this._tileXRandom}_SetTileYRandom(e){this._tileYRandom!==e&&(this._tileYRandom=e,this._IsTileRandomizationEnabled())&&this._runtime.UpdateRender()}_GetTileYRandom(){return this._tileYRandom}_SetTileAngleRandom(e){this._tileAngleRandom!==e&&(this._tileAngleRandom=e,this._IsTileRandomizationEnabled())&&this._runtime.UpdateRender()}_GetTileAngleRandom(){return this._tileAngleRandom}_SetTileBlendMarginX(e){this._tileBlendMarginX!==e&&(this._tileBlendMarginX=e,this._IsTileRandomizationEnabled())&&this._runtime.UpdateRender()}_GetTileBlendMarginX(){return this._tileBlendMarginX}_SetTileBlendMarginY(e){this._tileBlendMarginY!==e&&(this._tileBlendMarginY=e,this._IsTileRandomizationEnabled())&&this._runtime.UpdateRender()}_GetTileBlendMarginY(){return this._tileBlendMarginY}SaveToJson(){const e={};return 0!==this._imageOffsetX&&(e.iox=this._imageOffsetX),0!==this._imageOffsetY&&(e.ioy=this._imageOffsetY),1!==this._imageScaleX&&(e.isx=this._imageScaleX),1!==this._imageScaleY&&(e.isy=this._imageScaleY),0!==this._imageAngle&&(e.ia=this._imageAngle),this._enableTileRandomization&&(e.tr=!0),1!==this._tileXRandom&&(e.trx=this._tileXRandom),1!==this._tileYRandom&&(e.try=this._tileYRandom),1!==this._tileAngleRandom&&(e.tra=this._tileAngleRandom),.1!==this._tileBlendMarginX&&(e.trbmx=this._tileBlendMarginX),.1!==this._tileBlendMarginY&&(e.trbmy=this._tileBlendMarginY),e}LoadFromJson(e){this._imageOffsetX=e.iox||0,this._imageOffsetY=e.ioy||0,this._imageScaleX=e.hasOwnProperty("isx")?e.isx:1,this._imageScaleY=e.hasOwnProperty("isy")?e.isy:1,this._imageAngle=e.ia||0,this._enableTileRandomization=!!e.tr,this._tileXRandom=e.hasOwnProperty("trx")?e.trx:1,this._tileYRandom=e.hasOwnProperty("try")?e.try:1,this._tileAngleRandom=e.hasOwnProperty("tra")?e.tra:1,this._tileBlendMarginX=e.hasOwnProperty("trbmx")?e.trbmx:.1,this._tileBlendMarginY=e.hasOwnProperty("trbmy")?e.trbmy:.1}GetDebuggerProperties(){const e="plugins.tiledbg.properties";return[{title:e+".image-transform.name",properties:[{name:e+".image-offset-x.name",value:this._GetImageOffsetX(),onedit:e=>this._SetImageOffsetX(e)},{name:e+".image-offset-y.name",value:this._GetImageOffsetY(),onedit:e=>this._SetImageOffsetY(e)},{name:e+".image-scale-x.name",value:100*this._GetImageScaleX(),onedit:e=>this._SetImageScaleX(e/100)},{name:e+".image-scale-y.name",value:100*this._GetImageScaleY(),onedit:e=>this._SetImageScaleY(e/100)},{name:e+".image-angle.name",value:j.toDegrees(this._GetImageAngle()),onedit:e=>this._SetImageAngle(j.toRadians(e))}]},{title:e+".tile-randomization.name",properties:[{name:e+".enable-tile-randomization.name",value:this._IsTileRandomizationEnabled(),onedit:e=>this._SetTileRandomizationEnabled(e)},{name:e+".x-random.name",value:100*this._GetTileXRandom(),onedit:e=>this._SetTileXRandom(e/100)},{name:e+".y-random.name",value:100*this._GetTileYRandom(),onedit:e=>this._SetTileYRandom(e/100)},{name:e+".angle-random.name",value:100*this._GetTileAngleRandom(),onedit:e=>this._SetTileAngleRandom(e/100)},{name:e+".blend-margin-x.name",value:100*this._GetTileBlendMarginX(),onedit:e=>this._SetTileBlendMarginX(e/100)},{name:e+".blend-margin-y.name",value:100*this._GetTileBlendMarginY(),onedit:e=>this._SetTileBlendMarginY(e/100)}]}]}GetPropertyValueByIndex(e){switch(e){case n:return this._GetImageOffsetX();case o:return this._GetImageOffsetY();case p:return this._GetImageScaleX();case q:return this._GetImageScaleY();case r:return this._GetImageAngle();case s:return this._IsTileRandomizationEnabled();case t:return this._GetTileXRandom();case u:return this._GetTileYRandom();case v:return this._GetTileAngleRandom();case w:return this._GetTileBlendMarginX();case x:return this._GetTileBlendMarginY()}}SetPropertyValueByIndex(e,i){switch(e){case n:this._SetImageOffsetX(i);break;case o:this._SetImageOffsetY(i);break;case p:this._SetImageScaleX(i);break;case q:this._SetImageScaleY(i);break;case r:this._SetImageAngle(i);break;case s:this._SetTileRandomizationEnabled(!!i);break;case t:this._SetTileXRandom(i);break;case u:this._SetTileYRandom(i);break;case v:this._SetTileAngleRandom(i);break;case w:this._SetTileBlendMarginX(i);break;case x:this._SetTileBlendMarginY(i)}}GetScriptInterfaceClass(){return self.ITiledBackgroundInstance}},new WeakMap);self.ITiledBackgroundInstance=class extends self.IWorldInstance{constructor(){super(),C.set(this,self.IInstance._GetInitInst().GetSdkInstance())}set imageOffsetX(e){k.RequireFiniteNumber(e),C.get(this)._SetImageOffsetX(e)}get imageOffsetX(){return C.get(this)._GetImageOffsetX()}set imageOffsetY(e){k.RequireFiniteNumber(e),C.get(this)._SetImageOffsetY(e)}get imageOffsetY(){return C.get(this)._GetImageOffsetY()}setImageOffset(e,t){k.RequireFiniteNumber(e),k.RequireFiniteNumber(t);const s=C.get(this);s._SetImageOffsetX(e),s._SetImageOffsetY(t)}getImageOffset(){const e=C.get(this);return[e._GetImageOffsetX(),e._GetImageOffsetY()]}set imageScaleX(e){k.RequireFiniteNumber(e),C.get(this)._SetImageScaleX(e)}get imageScaleX(){return C.get(this)._GetImageScaleX()}set imageScaleY(e){k.RequireFiniteNumber(e),C.get(this)._SetImageScaleY(e)}get imageScaleY(){return C.get(this)._GetImageScaleY()}setImageScale(e,t){k.RequireFiniteNumber(e),k.RequireFiniteNumber(t);const s=C.get(this);s._SetImageScaleX(e),s._SetImageScaleY(t)}getImageScale(){const e=C.get(this);return[e._GetImageScaleX(),e._GetImageScaleY()]}set imageAngle(e){k.RequireFiniteNumber(e),C.get(this)._SetImageAngle(e)}get imageAngle(){return C.get(this)._GetImageAngle()}set imageAngleDegrees(e){k.RequireFiniteNumber(e),C.get(this)._SetImageAngle(j.toRadians(e))}get imageAngleDegrees(){return j.toDegrees(C.get(this)._GetImageAngle())}get imageWidth(){return C.get(this).GetCurrentImageInfo().GetWidth()}get imageHeight(){return C.get(this).GetCurrentImageInfo().GetHeight()}getImageSize(){const e=C.get(this).GetCurrentImageInfo();return[e.GetWidth(),e.GetHeight()]}set enableTileRandomization(e){C.get(this)._SetTileRandomizationEnabled(!!e)}get enableTileRandomization(){return C.get(this)._IsTileRandomizationEnabled()}set tileXRandom(e){k.RequireFiniteNumber(e),C.get(this)._SetTileXRandom(e)}get tileXRandom(){return C.get(this)._GetTileXRandom()}set tileYRandom(e){k.RequireFiniteNumber(e),C.get(this)._SetTileYRandom(e)}get tileYRandom(){return C.get(this)._GetTileYRandom()}setTileRandom(e,t){k.RequireFiniteNumber(e),k.RequireFiniteNumber(t);const s=C.get(this);s._SetTileXRandom(e),s._SetTileYRandom(t)}getTileRandom(){const e=C.get(this);return[e._GetTileXRandom(),e._GetTileYRandom()]}set tileAngleRandom(e){k.RequireFiniteNumber(e),C.get(this)._SetTileAngleRandom(e)}get tileAngleRandom(){return C.get(this)._GetTileAngleRandom()}set tileBlendMarginX(e){k.RequireFiniteNumber(e),C.get(this)._SetTileBlendMarginX(e)}get tileBlendMarginX(){return C.get(this)._GetTileBlendMarginX()}set tileBlendMarginY(e){k.RequireFiniteNumber(e),C.get(this)._SetTileBlendMarginY(e)}get tileBlendMarginY(){return C.get(this)._GetTileBlendMarginY()}setTileBlendMargin(e,t){k.RequireFiniteNumber(e),k.RequireFiniteNumber(t);const s=C.get(this);s._SetTileBlendMarginX(e),s._SetTileBlendMarginY(t)}getTileBlendMargin(){const e=C.get(this);return[e._GetTileBlendMarginX(),e._GetTileBlendMarginY()]}async replaceImage(e){k.RequireInstanceOf(e,Blob);const t=C.get(this),s=t.GetRuntime(),i=j.New(j.ImageInfo);i.LoadDynamicBlobAsset(s,e),await i.LoadStaticTexture(s.GetRenderer(),{sampling:s.GetSampling(),wrapX:t.GetSdkType().GetWrapModeX(),wrapY:t.GetSdkType().GetWrapModeY()}),t.WasReleased()?i.Release():(t._ReleaseOwnImage(),t._ownImageInfo=i,s.UpdateRender())}}}{const o0=self.C3;o0.Plugins.TiledBg.Cnds={OnURLLoaded(){return!0},OnURLFailed(){return!0},IsTileRandomizationEnabled(){return this._IsTileRandomizationEnabled()}}}{const p0=self.C3;p0.Plugins.TiledBg.Acts={SetImageOffsetX(e){this._SetImageOffsetX(e)},SetImageOffsetY(e){this._SetImageOffsetY(e)},SetImageScaleX(e){this._SetImageScaleX(e/100)},SetImageScaleY(e){this._SetImageScaleY(e/100)},SetImageAngle(e){this._SetImageAngle(p0.toRadians(e))},SetTileRandomizationEnabled(e){this._SetTileRandomizationEnabled(e)},SetTilePosRandom(e,t){this._SetTileXRandom(e/100),this._SetTileYRandom(t/100)},SetTileAngleRandom(e){this._SetTileAngleRandom(e/100)},SetTileBlendMargin(e,t){this._SetTileBlendMarginX(e/100),this._SetTileBlendMarginY(t/100)},SetEffect(e){this.GetWorldInfo().SetBlendMode(e),this._runtime.UpdateRender()},async LoadURL(e,t){if(!this._ownImageInfo||this._ownImageInfo.GetURL()!==e){const s=this._runtime,i=p0.New(p0.ImageInfo);try{if(await i.LoadDynamicAsset(s,e),!i.IsLoaded())throw new Error("image failed to load");if(this.WasReleased())return i.Release(),null;const r=await i.LoadStaticTexture(s.GetRenderer(),{sampling:s.GetSampling(),wrapX:this.GetSdkType().GetWrapModeX(),wrapY:this.GetSdkType().GetWrapModeY()});if(!r)return}catch(e){return console.error("Load image from URL failed: ",e),void(this.WasReleased()||this.Trigger(p0.Plugins.TiledBg.Cnds.OnURLFailed))}this.WasReleased()?i.Release():(this._ReleaseOwnImage(),this._ownImageInfo=i,s.UpdateRender(),await this.TriggerAsync(p0.Plugins.TiledBg.Cnds.OnURLLoaded))}}}}{const I0=self.C3;I0.Plugins.TiledBg.Exps={ImageWidth(){return this.GetCurrentImageInfo().GetWidth()},ImageHeight(){return this.GetCurrentImageInfo().GetHeight()},ImageOffsetX(){return this._imageOffsetX},ImageOffsetY(){return this._imageOffsetY},ImageScaleX(){return 100*this._imageScaleX},ImageScaleY(){return 100*this._imageScaleY},ImageAngle(){return I0.toDegrees(this._imageAngle)},TileXRandom(){return 100*this._GetTileXRandom()},TileYRandom(){return 100*this._GetTileYRandom()},TileAngleRandom(){return 100*this._GetTileAngleRandom()},TileBlendMarginX(){return 100*this._GetTileBlendMarginX()},TileBlendMarginY(){return 100*this._GetTileBlendMarginY()}}}{const a=self.C3,b=[];a.Plugins.Audio=class extends a.SDKPluginBase{constructor(e){super(e)}_AddActionPromise(e){b.push(e)}static async WaitForAllActionPromises(){await Promise.all(b),a.clearArray(b)}Release(){super.Release()}}}{let GetAudioSdkInstance2=function(){return e.GetSingleGlobalInstance().GetSdkInstance()},GetAudioDOMInterface2=function(){if(self.C3Audio_DOMInterface)return self.C3Audio_DOMInterface;throw new Error("audio scripting API cannot be used here - make sure the project is using DOM mode, not worker mode")};GetAudioSdkInstance=GetAudioSdkInstance2,GetAudioDOMInterface=GetAudioDOMInterface2;const f=self.C3,g=self.C3X;f.Plugins.Audio.Type=class extends f.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}GetScriptInterfaceClass(){return self.IAudioObjectType}};let e=null;self.IAudioObjectType=class extends self.IObjectClass{constructor(t){super(t),e=t}get audioContext(){return GetAudioDOMInterface2().GetAudioContextExtern()}get destinationNode(){return GetAudioDOMInterface2().GetDestinationNodeExtern()}get isSilent(){return GetAudioSdkInstance2()._IsSilent()}set isSilent(e){GetAudioSdkInstance2()._SetSilent(e)}get masterVolume(){return GetAudioSdkInstance2()._GetMasterVolume()}set masterVolume(e){g.RequireFiniteNumber(e),GetAudioSdkInstance2()._SetMasterVolume(e)}stopAll(){GetAudioSdkInstance2()._StopAll()}}}{const o=self.C3,p="audio",q=["interactive","balanced","playback"];o.Plugins.Audio.Instance=class extends o.SDKInstanceBase{constructor(e,t){super(e,p),this._nextPlayTime=0,this._triggerTags=[],this._enableMultiTags=!0,this._timeScaleMode=0,this._saveLoadMode=0,this._playInBackground=!1,this._panningModel=1,this._distanceModel=1,this._listenerPos=[this._runtime.GetViewportWidth()/2,this._runtime.GetViewportHeight()/2,600],this._listenerForwardVec=[0,0,-1],this._listenerUpVec=[0,1,0],this._referenceDistance=600,this._maxDistance=1e4,this._rolloffFactor=1,this._listenerInst=null,this._loadListenerUid=-1,this._masterVolume=1,this._isSilent=!1,this._sampleRate=0,this._audioContextState="suspended",this._outputLatency=0,this._effectCount=new Map,this._preloadTotal=0,this._preloadCount=0,this._bufferMetadata=new Map,this._remoteUrls=new Map;let s="interactive";t&&(this._timeScaleMode=t[0],this._saveLoadMode=t[1],this._playInBackground=t[2],s=q[t[3]],this._enableMultiTags=t[4],this._panningModel=t[5],this._distanceModel=t[6],this._listenerPos[2]=t[7],this._referenceDistance=t[8],this._maxDistance=t[9],this._rolloffFactor=t[10]),this._lastAIState=[],this._lastFxState=[],this._lastAnalysersData=[],this.AddDOMMessageHandlers([["state",e=>this._OnUpdateState(e)],["audiocontext-state",e=>this._OnAudioContextStateChanged(e)],["fxstate",e=>this._OnUpdateFxState(e)],["trigger",e=>this._OnTrigger(e)],["buffer-metadata",e=>this._OnBufferMetadata(e)]]);const i=this.GetRuntime().Dispatcher(),r=(this._disposables=new o.CompositeDisposable(o.Disposable.From(i,"instancedestroy",e=>this._OnInstanceDestroyed(e.instance)),o.Disposable.From(i,"afterload",()=>this._OnAfterLoad()),o.Disposable.From(i,"suspend",()=>this._OnSuspend()),o.Disposable.From(i,"resume",()=>this._OnResume())),this._runtime.GetExportType()),n="Safari"===o.Platform.Browser,a=this._runtime.IsiOSWebView()||"macos-wkwebview"===r,l=this._runtime.GetAssetManager().IsFileProtocol(),h="playable-ad-single-file"===this._runtime.GetExportType(),c=n||a||l||h;this._runtime.AddLoadPromise(this.PostToDOMAsync("create-audio-context",{preloadList:this._runtime.GetAssetManager().GetAudioToPreload().map(e=>({originalUrl:e.originalUrl,url:e.url,type:e.type,fileSize:e.fileSize})),timeScaleMode:this._timeScaleMode,latencyHint:s,panningModel:this._panningModel,distanceModel:this._distanceModel,refDistance:this._referenceDistance,maxDistance:this._maxDistance,rolloffFactor:this._rolloffFactor,listenerPos:this._listenerPos,usePlayMusicAsSoundWorkaround:c}).then(e=>{this._sampleRate=e.sampleRate,this._audioContextState=e.audioContextState,this._outputLatency=e.outputLatency})),this._StartTicking()}Release(){this._listenerInst=null,super.Release()}_SplitTags(e){return this._enableMultiTags?e.split(" ").filter(e=>!!e):e?[e]:[]}_MatchTagLists(t,e){for(const s of e){let e=!1;for(const i of t)if(o.equalsNoCase(i,s)){e=!0;break}if(!e)return!1}return!0}_MatchTagListToStr(e,t){return this._MatchTagLists(e,this._SplitTags(t))}_AddActionPromise(e){this.GetPlugin()._AddActionPromise(e)}_OnInstanceDestroyed(e){this._listenerInst===e&&(this._listenerInst=null)}DbToLinearNoCap(e){return Math.pow(10,e/20)}DbToLinear(e){const t=this.DbToLinearNoCap(e);return isFinite(t)?Math.max(Math.min(t,1),0):0}LinearToDbNoCap(e){return Math.log(e)/Math.log(10)*20}LinearToDb(e){return this.LinearToDbNoCap(Math.max(Math.min(e,1),0))}_OnSuspend(){this._playInBackground||this.PostToDOM("set-suspended",{isSuspended:!0})}_OnResume(){this._playInBackground||this.PostToDOM("set-suspended",{isSuspended:!1})}_OnUpdateState(e){const t=e.tickCount,s=(this._outputLatency=e.outputLatency,this._lastAIState.filter(e=>e.hasOwnProperty("placeholder")&&(e.placeholder>t||-1===e.placeholder)));this._lastAIState=e.audioInstances,this._lastAnalysersData=e.analysers,0<s.length&&o.appendArray(this._lastAIState,s)}_OnBufferMetadata(e){this._bufferMetadata.set(e.originalUrl,{duration:e.duration})}_OnAudioContextStateChanged(e){this._audioContextState=e.audioContextState}GetAudioContextState(){return this._runtime.IsExportToVideo()?"running":this._audioContextState}_OnUpdateFxState(e){this._lastFxState=e.fxstate}_GetFirstAudioStateByTags(e){const t=this._SplitTags(e);for(const s of this._lastAIState)if(this._MatchTagLists(s.tags,t))return s;return null}_IsTagPlaying(e){const t=this._SplitTags(e);return this._lastAIState.some(e=>this._MatchTagLists(e.tags,t)&&e.isPlaying)}_MaybeMarkAsPlaying(e,t,s,i,r){if(this._IsTagPlaying(t))return null;const n=this._bufferMetadata.get(e),a={tags:this._SplitTags(t),duration:n?n.duration:0,volume:r,isPlaying:!0,playbackTime:0,playbackRate:1,uid:-1,bufferOriginalUrl:e,bufferUrl:"",bufferType:"",isMusic:s,isLooping:i,isMuted:!1,resumePosition:0,pan:null,placeholder:-1};return this._lastAIState.push(a),a}_MaybeMarkAsStopped(e){const t=this._SplitTags(e);for(const s of this._lastAIState)this._MatchTagLists(s.tags,t)&&(s.isPlaying=!1)}async _OnTrigger(e){const t=e.type,s=(this._triggerTags=e.tags,e.aiid);if("ended"===t){for(const i of this._lastAIState)if(i.aiid===s){i.isPlaying=!1;break}await this.TriggerAsync(o.Plugins.Audio.Cnds.OnEnded)}else"fade-ended"===t&&await this.TriggerAsync(o.Plugins.Audio.Cnds.OnFadeEnded)}_MatchTriggerTag(e){return this._MatchTagListToStr(this._triggerTags,e)}Tick(){const e={timeScale:this._runtime.GetTimeScale(),gameTime:this._runtime.GetGameTimeRaw(),instPans:this.GetInstancePans(),tickCount:this._runtime.GetTickCountNoSave()};if(this._listenerInst){const t=this._listenerInst.GetWorldInfo();this._listenerPos[0]=t.GetX(),this._listenerPos[1]=t.GetY(),e.listenerPos=this._listenerPos,e.listenerOrientation=[...this._listenerForwardVec,...this._listenerUpVec]}this.PostToDOM("tick",e)}rotatePtAround(e,t,s,i,r){if(0!==s){const n=Math.sin(s),a=Math.cos(s),o=(e-=i)*n,l=(t-=r)*n,h=e*a,c=t*a;e=h-l,t=c+o,e+=i,t+=r}return[e,t]}GetInstancePans(){return this._lastAIState.filter(e=>-1!==e.uid).map(e=>this._runtime.GetInstanceByUID(e.uid)).filter(e=>e).map(e=>{const t=e.GetWorldInfo(),s=t.GetLayer().GetAngle(),[i,r]=this.rotatePtAround(t.GetX(),t.GetY(),-s,this._listenerPos[0],this._listenerPos[1]);return{uid:e.GetUID(),x:i,y:r,z:t.GetTotalZElevation(),angle:t.GetAngle()-s}})}GetAnalyserData(e,t){for(const s of this._lastAnalysersData)if(s.index===t&&o.equalsNoCase(s.tag,e))return s;return null}_IncrementEffectCount(e){for(const t of this._SplitTags(e)){const s=t.toLowerCase();this._effectCount.set(s,(this._effectCount.get(s)||0)+1)}}_IsSilent(){return this._isSilent}_SetSilent(e){this._isSilent!==(e=!!e)&&(this._isSilent=e,this.PostToDOM("set-silent",{isSilent:e}))}_GetMasterVolume(){return this._masterVolume}_SetMasterVolume(e){this._masterVolume!==e&&(this._masterVolume=e,this.PostToDOM("set-master-volume",{vol:e}))}_StopAll(){this.PostToDOM("stop-all");for(const e of this._lastAIState)e.isPlaying=!1}_ShouldSave(e){return!e.hasOwnProperty("placeholder")&&3!==this._saveLoadMode&&!(e.isMusic&&1===this._saveLoadMode||!e.isMusic&&2===this._saveLoadMode)}SaveToJson(){return{isSilent:this._isSilent,masterVolume:this._masterVolume,listenerZ:this._listenerPos[2],listenerForwardVec:this._listenerForwardVec,listenerUpVec:this._listenerUpVec,listenerUid:this._listenerInst?this._listenerInst.GetUID():-1,remoteUrls:[...this._remoteUrls.entries()],playing:this._lastAIState.filter(e=>this._ShouldSave(e)),effects:this._lastFxState,analysers:this._lastAnalysersData}}LoadFromJson(e){if(this._isSilent=e.isSilent,this._masterVolume=e.masterVolume,this._listenerPos[2]=e.listenerZ,this._listenerInst=null,this._loadListenerUid=e.listenerUid,e.hasOwnProperty("listenerForwardVec")?this._listenerForwardVec=e.listenerForwardVec:this._listenerForwardVec=[0,0,-1],e.hasOwnProperty("listenerUpVec")?this._listenerUpVec=e.listenerUpVec:this._listenerUpVec=[0,1,0],this._remoteUrls.clear(),e.remoteUrls)for(const[t,s]of e.remoteUrls)this._remoteUrls.set(t,s);this._lastAIState=e.playing;for(const i of this._lastAIState)i.hasOwnProperty("tag")&&!i.hasOwnProperty("tags")&&(i.tags=[i.tag].filter(e=>!!e));this._lastFxState=e.effects,this._lastAnalysersData=e.analysers}_OnAfterLoad(){if(-1!==this._loadListenerUid&&(this._listenerInst=this._runtime.GetInstanceByUID(this._loadListenerUid),this._loadListenerUid=-1,this._listenerInst)){const e=this._listenerInst.GetWorldInfo();this._listenerPos[0]=e.GetX(),this._listenerPos[1]=e.GetY()}for(const t of this._lastAIState){const s=this._runtime.GetAssetManager().GetProjectAudioFileUrl(t.bufferOriginalUrl);s?(t.bufferUrl=s.url,t.bufferType=s.type):t.bufferUrl=null}for(const i of Object.values(this._lastFxState))for(const r of i)if(r.hasOwnProperty("bufferOriginalUrl")){const n=this._runtime.GetAssetManager().GetProjectAudioFileUrl(r.bufferOriginalUrl);n&&(r.bufferUrl=n.url,r.bufferType=n.type)}this.PostToDOM("load-state",{saveLoadMode:this._saveLoadMode,timeScale:this._runtime.GetTimeScale(),gameTime:this._runtime.GetGameTimeRaw(),listenerPos:this._listenerPos,listenerOrientation:[...this._listenerForwardVec,...this._listenerUpVec],isSilent:this._isSilent,masterVolume:this._masterVolume,playing:this._lastAIState.filter(e=>null!==e.bufferUrl),effects:this._lastFxState})}GetDebuggerProperties(){const e=[];for(const[s,i]of Object.entries(this._lastFxState))e.push({name:"$"+s,value:i.map(e=>e.type).join(", ")});const t="plugins.audio.debugger";return[{title:t+".tag-effects",properties:e},{title:t+".currently-playing",properties:[{name:t+".currently-playing-count",value:this._lastAIState.length},...this._lastAIState.map((e,t)=>({name:"$#"+t,value:`${e.bufferOriginalUrl} ("${e.tags}") ${Math.round(10*e.playbackTime)/10} / `+Math.round(10*e.duration)/10}))]}]}}}{const x0=self.C3;x0.Plugins.Audio.Cnds={OnEnded(e){return this._MatchTriggerTag(e)},OnFadeEnded(e){return this._MatchTriggerTag(e)},PreloadsComplete(){return this._preloadCount===this._preloadTotal},AdvancedAudioSupported(){return!0},IsSilent(){return this._IsSilent()},IsAnyPlaying(){for(const e of this._lastAIState)if(e.isPlaying)return!0;return!1},IsTagPlaying(e){return this._IsTagPlaying(e)}}}{const C0=self.C3,D0=["lowpass","highpass","bandpass","lowshelf","highshelf","peaking","notch","allpass"];C0.Plugins.Audio.Acts={Play(e,t,s,i,r){const n=C0.Plugins.Audio.Acts._DoPlay.call(this,e,t,s,i,r);return this._AddActionPromise(n),n},PlayFromTimeline(e,t,s,i){C0.Plugins.Audio.Acts._DoPlay.call(this,e,0,t,0,s,i)},async _DoPlay(e,t,s,i,r,n){if(!this._isSilent){const a=e[1],o=this._runtime.GetAssetManager().GetProjectAudioFileUrl(e[0]);if(o){const l=this._nextPlayTime,h=(this._nextPlayTime=0,this._MaybeMarkAsPlaying(e[0],r,a,0!==t,this.DbToLinear(s)));try{await this.PostToDOMAsync("play",{originalUrl:e[0],url:o.url,type:o.type,isMusic:a,tags:this._SplitTags(r),isLooping:0!==t,vol:this.DbToLinear(s),stereoPan:C0.clamp(i/100,-1,1),pos:n||0,off:l,trueClock:!!self.C3_GetAudioContextCurrentTime})}finally{h&&(h.placeholder=this._runtime.GetTickCountNoSave())}}}},async PlayAtPosition(e,t,s,i,r,n,a,o,l,h,c){if(!this._isSilent){const u=e[1],_=this._runtime.GetAssetManager().GetProjectAudioFileUrl(e[0]);if(_){const d=this._nextPlayTime,p=(this._nextPlayTime=0,this._MaybeMarkAsPlaying(e[0],c,u,0!==t,this.DbToLinear(s)));try{await this.PostToDOMAsync("play",{originalUrl:e[0],url:_.url,type:_.type,isMusic:u,tags:this._SplitTags(c),isLooping:0!==t,vol:this.DbToLinear(s),pos:0,off:d,trueClock:!!self.C3_GetAudioContextCurrentTime,panning:{x:i,y:r,z:n,angle:C0.toRadians(a),innerAngle:C0.toRadians(o),outerAngle:C0.toRadians(l),outerGain:this.DbToLinear(h)}})}finally{p&&(p.placeholder=this._runtime.GetTickCountNoSave())}}}},async PlayAtObject(e,t,s,i,r,n,a,o){if(!this._isSilent&&i){const l=i.GetFirstPicked();if(l&&l.GetWorldInfo()){const h=l.GetWorldInfo(),c=h.GetLayer().GetAngle(),[u,_]=this.rotatePtAround(h.GetX(),h.GetY(),-c,this._listenerPos[0],this._listenerPos[1]),d=e[1],p=this._runtime.GetAssetManager().GetProjectAudioFileUrl(e[0]);if(p){const m=this._nextPlayTime,g=(this._nextPlayTime=0,this._MaybeMarkAsPlaying(e[0],o,d,0!==t,this.DbToLinear(s)));try{await this.PostToDOMAsync("play",{originalUrl:e[0],url:p.url,type:p.type,isMusic:d,tags:this._SplitTags(o),isLooping:0!==t,vol:this.DbToLinear(s),pos:0,off:m,trueClock:!!self.C3_GetAudioContextCurrentTime,panning:{x:u,y:_,z:h.GetTotalZElevation(),angle:h.GetAngle()-c,innerAngle:C0.toRadians(r),outerAngle:C0.toRadians(n),outerGain:this.DbToLinear(a),uid:l.GetUID()}})}finally{g&&(g.placeholder=this._runtime.GetTickCountNoSave())}}}}},async PlayByName(e,t,s,i,r,n){if(!this._isSilent){const a=1===e,o=this._runtime.GetAssetManager().GetProjectAudioFileUrl(t)||this._remoteUrls.get(t.toLowerCase());if(o){const l=this._nextPlayTime,h=(this._nextPlayTime=0,this._MaybeMarkAsPlaying(t,n,a,0!==s,this.DbToLinear(i)));try{await this.PostToDOMAsync("play",{originalUrl:t,url:o.url,type:o.type,isMusic:a,tags:this._SplitTags(n),isLooping:0!==s,vol:this.DbToLinear(i),stereoPan:C0.clamp(r/100,-1,1),pos:0,off:l,trueClock:!!self.C3_GetAudioContextCurrentTime})}finally{h&&(h.placeholder=this._runtime.GetTickCountNoSave())}}}},async PlayAtPositionByName(e,t,s,i,r,n,a,o,l,h,c,u){if(!this._isSilent){const _=1===e,d=this._runtime.GetAssetManager().GetProjectAudioFileUrl(t)||this._remoteUrls.get(t.toLowerCase());if(d){const p=this._nextPlayTime,m=(this._nextPlayTime=0,this._MaybeMarkAsPlaying(t,u,_,0!==s,this.DbToLinear(i)));try{await this.PostToDOMAsync("play",{originalUrl:t,url:d.url,type:d.type,isMusic:_,tags:this._SplitTags(u),isLooping:0!==s,vol:this.DbToLinear(i),pos:0,off:p,trueClock:!!self.C3_GetAudioContextCurrentTime,panning:{x:r,y:n,z:a,angle:C0.toRadians(o),innerAngle:C0.toRadians(l),outerAngle:C0.toRadians(h),outerGain:this.DbToLinear(c)}})}finally{m&&(m.placeholder=this._runtime.GetTickCountNoSave())}}}},async PlayAtObjectByName(e,t,s,i,r,n,a,o,l){if(!this._isSilent&&!this._isSilent&&r){const h=r.GetFirstPicked();if(h&&h.GetWorldInfo()){const c=h.GetWorldInfo(),u=c.GetLayer().GetAngle(),[_,d]=this.rotatePtAround(c.GetX(),c.GetY(),-u,this._listenerPos[0],this._listenerPos[1]),p=1===e,m=this._runtime.GetAssetManager().GetProjectAudioFileUrl(t)||this._remoteUrls.get(t.toLowerCase());if(m){const g=this._nextPlayTime,f=(this._nextPlayTime=0,this._MaybeMarkAsPlaying(t,l,p,0!==s,this.DbToLinear(i)));try{await this.PostToDOMAsync("play",{originalUrl:t,url:m.url,type:m.type,isMusic:p,tags:this._SplitTags(l),isLooping:0!==s,vol:this.DbToLinear(i),pos:0,off:g,trueClock:!!self.C3_GetAudioContextCurrentTime,panning:{x:_,y:d,z:c.GetTotalZElevation(),angle:c.GetAngle()-u,innerAngle:C0.toRadians(n),outerAngle:C0.toRadians(a),outerGain:this.DbToLinear(o),uid:h.GetUID()}})}finally{f&&(f.placeholder=this._runtime.GetTickCountNoSave())}}}}},SetLooping(e,t){this.PostToDOM("set-looping",{tags:this._SplitTags(e),isLooping:0===t})},SetMuted(e,t){this.PostToDOM("set-muted",{tags:this._SplitTags(e),isMuted:0===t})},SetVolume(e,t){this.PostToDOM("set-volume",{tags:this._SplitTags(e),vol:this.DbToLinear(t)})},FadeVolume(e,t,s,i){this.PostToDOM("fade-volume",{tags:this._SplitTags(e),vol:this.DbToLinear(t),duration:s,stopOnEnd:0===i})},SetStereoPan(e,t){this.PostToDOM("set-stereo-pan",{tags:this._SplitTags(e),p:C0.clamp(t/100,-1,1)})},async Preload(e){const t=e[1],s=this._runtime.GetAssetManager().GetProjectAudioFileUrl(e[0]);s&&(this._preloadTotal++,await this.PostToDOMAsync("preload",{originalUrl:e[0],url:s.url,type:s.type,isMusic:t}),this._preloadCount++)},async PreloadByName(e,t){const s=1===e,i=this._runtime.GetAssetManager().GetProjectAudioFileUrl(t)||this._remoteUrls.get(t.toLowerCase());i&&(this._preloadTotal++,await this.PostToDOMAsync("preload",{originalUrl:t,url:i.url,type:i.type,isMusic:s}),this._preloadCount++)},SetPlaybackRate(e,t){this.PostToDOM("set-playback-rate",{tags:this._SplitTags(e),rate:Math.max(t,0)})},Stop(e){this._MaybeMarkAsStopped(e),this.PostToDOM("stop",{tags:this._SplitTags(e)})},StopAll(){this._StopAll()},SetPaused(e,t){this.PostToDOM("set-paused",{tags:this._SplitTags(e),paused:0===t})},Seek(e,t){this.PostToDOM("seek",{tags:this._SplitTags(e),pos:t})},SetSilent(e){2===e&&(e=this._IsSilent()?1:0),this._SetSilent(0===e)},SetMasterVolume(e){const t=this.DbToLinear(e);this._SetMasterVolume(t)},AddFilterEffect(e,t,s,i,r,n,a){const o=D0[t];this._IncrementEffectCount(e),this.PostToDOM("add-effect",{type:"filter",tags:this._SplitTags(e),params:[o,s,i,r,n,C0.clamp(a/100,0,1)]})},AddDelayEffect(e,t,s,i){this._IncrementEffectCount(e),this.PostToDOM("add-effect",{type:"delay",tags:this._SplitTags(e),params:[t,this.DbToLinear(s),C0.clamp(i/100,0,1)]})},AddFlangerEffect(e,t,s,i,r,n){this._IncrementEffectCount(e),this.PostToDOM("add-effect",{type:"flanger",tags:this._SplitTags(e),params:[t/1e3,s/1e3,i,r/100,C0.clamp(n/100,0,1)]})},AddPhaserEffect(e,t,s,i,r,n,a){this._IncrementEffectCount(e),this.PostToDOM("add-effect",{type:"phaser",tags:this._SplitTags(e),params:[t,s,i,r,n,C0.clamp(a/100,0,1)]})},AddConvolutionEffect(e,t,s,i){const r=this._runtime.GetAssetManager().GetProjectAudioFileUrl(t[0]);r&&(this._IncrementEffectCount(e),this.PostToDOM("add-effect",{type:"convolution",tags:this._SplitTags(e),bufferOriginalUrl:t[0],bufferUrl:r.url,bufferType:r.type,params:[0===s,C0.clamp(i/100,0,1)]}))},AddGainEffect(e,t){this._IncrementEffectCount(e),this.PostToDOM("add-effect",{type:"gain",tags:this._SplitTags(e),params:[this.DbToLinear(t)]})},AddStereoPanEffect(e,t){this._IncrementEffectCount(e),this.PostToDOM("add-effect",{type:"stereopan",tags:this._SplitTags(e),params:[C0.clamp(t/100,-1,1)]})},AddMuteEffect(e){this._IncrementEffectCount(e),this.PostToDOM("add-effect",{type:"gain",tags:this._SplitTags(e),params:[0]})},AddTremoloEffect(e,t,s){this._IncrementEffectCount(e),this.PostToDOM("add-effect",{type:"tremolo",tags:this._SplitTags(e),params:[t,C0.clamp(s/100,0,1)]})},AddRingModEffect(e,t,s){this._IncrementEffectCount(e),this.PostToDOM("add-effect",{type:"ringmod",tags:this._SplitTags(e),params:[t,C0.clamp(s/100,0,1)]})},AddDistortionEffect(e,t,s,i,r,n){this._IncrementEffectCount(e),this.PostToDOM("add-effect",{type:"distortion",tags:this._SplitTags(e),params:[this.DbToLinearNoCap(t),this.DbToLinearNoCap(s),i,this.DbToLinearNoCap(r),C0.clamp(n/100,0,1)]})},AddCompressorEffect(e,t,s,i,r,n){this._IncrementEffectCount(e),this.PostToDOM("add-effect",{type:"compressor",tags:this._SplitTags(e),params:[t,s,i,r/1e3,n/1e3]})},AddAnalyserEffect(e,t,s){this._IncrementEffectCount(e),this.PostToDOM("add-effect",{type:"analyser",tags:this._SplitTags(e),params:[t,s]})},RemoveEffects(e){const t=this._SplitTags(e);for(const s of t)this._effectCount.set(s.toLowerCase(),0);this.PostToDOM("remove-effects",{tags:t}),this._lastFxState={}},SetEffectParameter(e,t,s,i,r,n){this.PostToDOM("set-effect-param",{tags:this._SplitTags(e),index:Math.floor(t),param:s,value:i,ramp:r,time:n})},SetListenerObject(e){if(e){const t=e.GetFirstPicked();t&&t.GetWorldInfo()&&(this._listenerInst=t)}},SetListenerZ(e){this._listenerPos[2]=e},SetListenerOrientation(e,t,s,i,r,n){this._listenerForwardVec[0]=e,this._listenerForwardVec[1]=t,this._listenerForwardVec[2]=-s,this._listenerUpVec[0]=i,this._listenerUpVec[1]=r,this._listenerUpVec[2]=-n},ScheduleNextPlay(e){this._nextPlayTime=Math.max(e,0)},UnloadAudio(e){const t=e[1],s=this._runtime.GetAssetManager().GetProjectAudioFileUrl(e[0]);s&&this.PostToDOM("unload",{url:s.url,type:s.type,isMusic:t})},UnloadAudioByName(e,t){const s=1===e,i=this._runtime.GetAssetManager().GetProjectAudioFileUrl(t)||this._remoteUrls.get(t.toLowerCase());i&&this.PostToDOM("unload",{url:i.url,type:i.type,isMusic:s})},UnloadAll(){this.PostToDOM("unload-all")},AddRemoteURL(e,t,s){this._remoteUrls.set(s.toLowerCase(),{url:e,type:t})}}}{const y2=self.C3;y2.Plugins.Audio.Exps={Duration(e){const t=this._GetFirstAudioStateByTags(e);return t?t.duration:0},PlaybackTime(e){const t=this._GetFirstAudioStateByTags(e);return t?t.playbackTime:0},PlaybackRate(e){const t=this._GetFirstAudioStateByTags(e);return t?t.playbackRate:0},Volume(e){const t=this._GetFirstAudioStateByTags(e);return t?this.LinearToDb(t.volume):0},MasterVolume(){return this.LinearToDb(this._GetMasterVolume())},EffectCount(e){return this._effectCount.get(e.toLowerCase())||0},AnalyserFreqBinCount(e,t){const s=this.GetAnalyserData(e,Math.floor(t));return s?s.binCount:0},AnalyserFreqBinAt(e,t,s){const i=this.GetAnalyserData(e,Math.floor(t));return!i||(s=Math.floor(s))<0||s>=i.binCount?0:i.freqBins[s]},AnalyserPeakLevel(e,t){const s=this.GetAnalyserData(e,Math.floor(t));return s?s.peak:0},AnalyserRMSLevel(e,t){const s=this.GetAnalyserData(e,Math.floor(t));return s?s.rms:0},SampleRate(){return this._sampleRate},CurrentTime(){return self.C3_GetAudioContextCurrentTime?self.C3_GetAudioContextCurrentTime():performance.now()/1e3},OutputLatency(){return this._outputLatency},NormalizedVolume(e,t){return 0==(e=y2.clamp(+e,0,100)/100)?-1/0:e<.1?this.LinearToDb(y2.lerp(0,this.DbToLinear(t),10*e)):y2.lerp(t,0,(e-.1)/.9)}}}{const C33=self.C3;C33.Plugins.Browser=class BrowserPlugin extends C33.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{const C33=self.C3;C33.Plugins.Browser.Type=class BrowserType extends C33.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const C33=self.C3,DOM_COMPONENT_ID="browser";C33.Plugins.Browser.Instance=class BrowserInstance extends C33.SDKInstanceBase{constructor(e,t){super(e,DOM_COMPONENT_ID),this._initLocationStr="",this._isOnline=!1,this._referrer="",this._docTitle="",this._isCookieEnabled=!1,this._screenWidth=0,this._screenHeight=0,this._windowOuterWidth=0,this._windowOuterHeight=0,this._windowHasFocus=!1,this._isConstructArcade=!1,this._cssStyleMap=new Map,this._isInstallAvailable=!1,this._installResult="",this._isWarnOnCloseEnabled=!1,this.AddDOMMessageHandlers([["online-state",e=>this._OnOnlineStateChanged(e)],["backbutton",()=>this._OnBackButton()],["sw-message",e=>this._OnSWMessage(e)],["hashchange",e=>this._OnHashChange(e)],["install-available",()=>this._OnInstallAvailable()],["app-installed",e=>this._OnAppInstalled(e)]]);const s=this.GetRuntime().Dispatcher();this._disposables=new C33.CompositeDisposable(C33.Disposable.From(s,"afterfirstlayoutstart",()=>this._OnAfterFirstLayoutStart()),C33.Disposable.From(s,"window-resize",()=>this._OnWindowResize()),C33.Disposable.From(s,"window-focus",()=>this._OnWindowFocus()),C33.Disposable.From(s,"window-blur",()=>this._OnWindowBlur()),C33.Disposable.From(s,"suspend",()=>this._OnSuspend()),C33.Disposable.From(s,"resume",()=>this._OnResume())),this._runtime.AddLoadPromise(this.PostToDOMAsync("get-initial-state",{exportType:this._runtime.GetExportType()}).then(e=>{this._initLocationStr=e.location,this._isOnline=e.isOnline,this._referrer=e.referrer,this._docTitle=e.title,this._isCookieEnabled=e.isCookieEnabled,this._screenWidth=e.screenWidth,this._screenHeight=e.screenHeight,this._windowOuterWidth=e.windowOuterWidth,this._windowOuterHeight=e.windowOuterHeight,this._windowHasFocus=e.windowHasFocus,this._isConstructArcade=e.isConstructArcade}))}Release(){super.Release()}_OnAfterFirstLayoutStart(){this.PostToDOM("ready-for-sw-messages")}async _OnOnlineStateChanged(e){const t=!!e.isOnline;this._isOnline!==t&&(this._isOnline=t,this._isOnline?await this.TriggerAsync(C33.Plugins.Browser.Cnds.OnOnline):await this.TriggerAsync(C33.Plugins.Browser.Cnds.OnOffline))}async _OnWindowResize(){await this.TriggerAsync(C33.Plugins.Browser.Cnds.OnResize)}async _OnWindowFocus(){this._windowHasFocus=!0,await this.TriggerAsync(C33.Plugins.Browser.Cnds.OnWindowFocus)}async _OnWindowBlur(){this._windowHasFocus=!1,await this.TriggerAsync(C33.Plugins.Browser.Cnds.OnWindowBlur)}_OnSuspend(){this.Trigger(C33.Plugins.Browser.Cnds.OnPageHidden)}_OnResume(){this.Trigger(C33.Plugins.Browser.Cnds.OnPageVisible)}async _OnBackButton(){await this.TriggerAsync(C33.Plugins.Browser.Cnds.OnBackButton)}_OnSWMessage(e){const t=e.type;"downloading-update"===t?this.Trigger(C33.Plugins.Browser.Cnds.OnUpdateFound):"update-ready"===t||"update-pending"===t?this.Trigger(C33.Plugins.Browser.Cnds.OnUpdateReady):"offline-ready"===t&&this.Trigger(C33.Plugins.Browser.Cnds.OnOfflineReady)}_OnHashChange(e){this._initLocationStr=e.location,this.Trigger(C33.Plugins.Browser.Cnds.OnHashChange)}_OnInstallAvailable(){this._isInstallAvailable=!0,this.Trigger(C33.Plugins.Browser.Cnds.OnInstallAvailable)}_OnAppInstalled(e){this._isInstallAvailable=!1,this.Trigger(C33.Plugins.Browser.Cnds.OnAppInstalled)}_IsWarnOnCloseEnabled(){return this._isWarnOnCloseEnabled}_SetWarnOnCloseEnabled(e){this._isWarnOnCloseEnabled!==(e=!!e)&&(this._isWarnOnCloseEnabled=e,this.PostToDOM("set-warn-on-close",{enabled:e}))}GetDebuggerProperties(){const e="plugins.browser.debugger";return[{title:"plugins.browser.name",properties:[{name:e+".user-agent",value:navigator.userAgent},{name:e+".is-online",value:this._isOnline},{name:e+".is-fullscreen",value:this._runtime.GetCanvasManager().IsDocumentFullscreen()}]}]}}}{const C33=self.C3;C33.Plugins.Browser.Cnds={IsOnline(){return this._isOnline},OnOnline(){return!0},OnOffline(){return!0},OnResize(){return!0},OnWindowFocus(){return!0},OnWindowBlur(){return!0},WindowHasFocus(){return this._windowHasFocus},CookiesEnabled(){return this._isCookieEnabled},IsFullscreen(){return this._runtime.GetCanvasManager().IsDocumentFullscreen()},OnBackButton(){return!0},IsPortraitLandscape(e){const t=this._runtime.GetCanvasManager().GetLastWidth(),s=this._runtime.GetCanvasManager().GetLastHeight(),i=t<=s?0:1;return i===e},OnUpdateFound(){return!0},OnUpdateReady(){return!0},OnOfflineReady(){return!0},OnHashChange(){return!0},OnInstallAvailable(){return!0},IsInstallAvailable(){return this._isInstallAvailable},OnInstallResult(e){switch(e){case 0:return"accepted"===this._installResult;case 1:return"dismissed"===this._installResult;case 2:return"error"===this._installResult;case 3:return!0;default:return!1}},OnAppInstalled(){return!0},CompareDisplayMode(e){const t=this._runtime.GetCanvasManager().GetCssDisplayMode();switch(e){case 0:return"browser"===t;case 1:return"minimal-ui"===t;case 2:return"standalone"===t;case 3:return"fullscreen"===t;default:return!1}},IsWarnOnCloseEnabled(){return this._IsWarnOnCloseEnabled()},PageVisible(){return!this._runtime.IsSuspended()},OnPageHidden(){return!0},OnPageVisible(){return!0},HasJava(){return!1},IsDownloadingUpdate(){return!1},OnMenuButton(){return!1},OnSearchButton(){return!1},IsMetered(){return!1},IsCharging(){return!0},SupportsFullscreen(){return!0}}}{const C3=self.C3,ORIENTATIONS=["portrait","landscape","portrait-primary","portrait-secondary","landscape-primary","landscape-secondary"];C3.Plugins.Browser.Acts={Alert(e){this.PostToDOM("alert",{message:e.toString()})},Close(){this._isConstructArcade||(this._runtime.IsDebug()?self.C3Debugger.CloseWindow():this.PostToDOM("close"))},Focus(){this.PostToDOM("set-focus",{isFocus:!0})},Blur(){this.PostToDOM("set-focus",{isFocus:!1})},GoBack(){this._isConstructArcade||this.PostToDOM("navigate",{type:"back"})},GoForward(){this._isConstructArcade||this.PostToDOM("navigate",{type:"forward"})},GoHome(){},Reload(){this._isConstructArcade||(this._runtime.IsDebug()?this._runtime.PostToDebugger({type:"reload"}):this.PostToDOM("navigate",{type:"reload"}))},GoToURL(e,t){this._PostToDOMMaybeSync("navigate",{type:"url",url:e,target:t,exportType:this._runtime.GetExportType()})},GoToURLWindow(e,t){this._PostToDOMMaybeSync("navigate",{type:"new-window",url:e,tag:t,exportType:this._runtime.GetExportType()})},RequestFullScreen(e,t){2<=e&&(e+=1),1===(e=6===e?2:e)&&(e=0);const s=C3.CanvasManager._FullscreenModeNumberToString(e);this._runtime.GetCanvasManager().SetDocumentFullscreenMode(s),this._PostToDOMMaybeSync("request-fullscreen",{navUI:t})},CancelFullScreen(){this._PostToDOMMaybeSync("exit-fullscreen")},Vibrate(e){const s=e.split(",");for(let e=0,t=s.length;e<t;++e)s[e]=parseInt(s[e],10);this._PostToDOMMaybeSync("vibrate",{pattern:s})},async InvokeDownload(e,t){if(e&&t){const s=await this._runtime.GetAssetManager().GetProjectFileUrl(e);this._runtime.InvokeDownload(s,t)}},InvokeDownloadString(e,t,s){if(s){const i=`data:${t},`+encodeURIComponent(e);this._runtime.InvokeDownload(i,s)}},ConsoleLog(e,t){t=t.toString(),0===e?console.log(t):1===e?console.warn(t):2===e&&console.error(t)},ConsoleGroup(e){console.group(e)},ConsoleGroupEnd(){console.groupEnd()},ExecJs(jsStr){try{eval(jsStr)}catch(err){console.error("Error executing JavaScript: ",err)}},LockOrientation(e){if(!((e=Math.floor(e))<0||e>=ORIENTATIONS.length)){const t=ORIENTATIONS[e];this._PostToDOMMaybeSync("lock-orientation",{orientation:t})}},UnlockOrientation(){this._PostToDOMMaybeSync("unlock-orientation")},LoadStyleSheet(e){this._runtime.GetAssetManager().LoadStyleSheet(e)},async SetDocumentCSSStyle(e,t,s,i){await this.PostToDOMAsync("set-document-css-style",{prop:C3.CSSToCamelCase(e),value:t,selector:s,"is-all":0!==i})},async GetDocumentCSSStyle(e,t,s){const i=await this.PostToDOMAsync("get-document-css-style",{prop:e,selector:t});i.isOk&&this._cssStyleMap.set(s.toLowerCase(),i.result.trim())},SetHash(e){this.PostToDOM("set-hash",{hash:e})},SetWindowSize(e,t){this.PostToDOM("set-window-size",{windowWidth:e,windowHeight:t})},SetWindowPosition(e,t){this.PostToDOM("set-window-position",{windowX:e,windowY:t})},async RequestInstall(){const e=await this.PostToDOMAsync("request-install");this._installResult=e.result,this.Trigger(C3.Plugins.Browser.Cnds.OnInstallResult)},SetWarnOnClose(e){this._SetWarnOnCloseEnabled(e)}}}{const C3=self.C3;C3.Plugins.Browser.Exps={URL(){return this._runtime.IsInWorker()?this._initLocationStr:location.toString()},Protocol(){return(this._runtime.IsInWorker()?new URL(this._initLocationStr):location).protocol},Domain(){return(this._runtime.IsInWorker()?new URL(this._initLocationStr):location).hostname},Port(){return(this._runtime.IsInWorker()?new URL(this._initLocationStr):location).port},PathName(){return(this._runtime.IsInWorker()?new URL(this._initLocationStr):location).pathname},Hash(){return(this._runtime.IsInWorker()?new URL(this._initLocationStr):location).hash},QueryString(){return(this._runtime.IsInWorker()?new URL(this._initLocationStr):location).search},QueryParam(e){const t=(this._runtime.IsInWorker()?new URL(this._initLocationStr):location).search,s=RegExp("[?&]"+e+"=([^&]*)").exec(t);return s?decodeURIComponent(s[1].replace(/\+/g," ")):""},Referrer(){return this._referrer},Title(){return this._docTitle},Language(){return navigator.language},Platform(){return navigator.platform},UserAgent(){return navigator.userAgent},ExecJS(jsStr){let result=0;try{result=eval(jsStr)}catch(err){console.error("Error executing JavaScript: ",err)}return"number"==typeof result||"string"==typeof result?result:"boolean"==typeof result&&result?1:0},CSSStyleValue(e){return this._cssStyleMap.get(e)||""},Name(){return navigator.appName},Version(){return navigator.appVersion},Product(){return navigator.product},Vendor(){return navigator.vendor},BatteryLevel(){return 1},BatteryTimeLeft(){return 1/0},Bandwidth(){const e=navigator.connection;return e&&(e.downlink||e.downlinkMax||e.bandwidth)||1/0},ConnectionType(){const e=navigator.connection;return e&&e.type||"unknown"},DevicePixelRatio(){return self.devicePixelRatio},ScreenWidth(){return this._screenWidth},ScreenHeight(){return this._screenHeight},WindowInnerWidth(){return this._runtime.GetCanvasManager().GetLastWidth()},WindowInnerHeight(){return this._runtime.GetCanvasManager().GetLastHeight()},WindowOuterWidth(){return this._windowOuterWidth},WindowOuterHeight(){return this._windowOuterWidth},DisplayMode(){return this._runtime.GetCanvasManager().GetCssDisplayMode()},InstallResult(){return this._installResult}}}{const a=self.C3;a.Plugins.Keyboard=class extends a.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{let GetKeyboardSdkInstance2=function(){return r.GetSingleGlobalInstance().GetSdkInstance()};GetKeyboardSdkInstance=GetKeyboardSdkInstance2;const d=self.C3,e=self.C3X;d.Plugins.Keyboard.Type=class extends d.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}GetScriptInterfaceClass(){return self.IKeyboardObjectType}};let r=null;self.IKeyboardObjectType=class extends self.IObjectClass{constructor(e){super(e),(r=e).GetRuntime()._GetCommonScriptInterfaces().keyboard=this}isKeyDown(e){const t=GetKeyboardSdkInstance2();if("string"==typeof e)return t.IsKeyDown(e);if("number"==typeof e)return t.IsKeyCodeDown(e);throw new TypeError("expected string or number")}}}{const m=self.C3,n="keyboard";m.Plugins.Keyboard.Instance=class extends m.SDKInstanceBase{constructor(e,t){super(e,n),this._keysDownByString=new Set,this._keysDownByWhich=new Set,this._triggerWhich=0,this._triggerString="",this._triggerTypedKey="",this._isKeyboardLockSupported=!1;const s=this.GetRuntime().Dispatcher();this._disposables=new m.CompositeDisposable(m.Disposable.From(s,"keydown",e=>this._OnKeyDown(e.data)),m.Disposable.From(s,"keyup",e=>this._OnKeyUp(e.data)),m.Disposable.From(s,"window-blur",()=>this._OnWindowOrKeyboardBlur()),m.Disposable.From(s,"keyboard-blur",()=>this._OnWindowOrKeyboardBlur())),this._runtime.AddLoadPromise(this._Init())}Release(){super.Release()}async _Init(){const e=await this.PostToDOMAsync("init");this._isKeyboardLockSupported=e.isKeyboardLockSupported}_OnKeyDown(e){const t=e.which,s=e.code||t.toString(),i=e.key;this._keysDownByString.has(s)||(this._keysDownByString.add(s),this._keysDownByWhich.add(t),this._triggerString=s,this._triggerWhich=t,this._triggerTypedKey=i,this.Trigger(m.Plugins.Keyboard.Cnds.OnAnyKey),this.Trigger(m.Plugins.Keyboard.Cnds.OnKey),this.Trigger(m.Plugins.Keyboard.Cnds.OnLeftRightKeyPressed),this.Trigger(m.Plugins.Keyboard.Cnds.OnKeyCode))}_OnKeyUp(e){const t=e.which,s=e.code||t.toString(),i=e.key;this._keysDownByString.delete(s),this._keysDownByWhich.delete(t),this._triggerString=s,this._triggerWhich=t,this._triggerTypedKey=i,this.Trigger(m.Plugins.Keyboard.Cnds.OnAnyKeyReleased),this.Trigger(m.Plugins.Keyboard.Cnds.OnKeyReleased),this.Trigger(m.Plugins.Keyboard.Cnds.OnLeftRightKeyReleased),this.Trigger(m.Plugins.Keyboard.Cnds.OnKeyCodeReleased)}_OnWindowOrKeyboardBlur(){for(const e of this._keysDownByWhich)this._keysDownByWhich.delete(e),this._triggerWhich=e,this.Trigger(m.Plugins.Keyboard.Cnds.OnAnyKeyReleased),this.Trigger(m.Plugins.Keyboard.Cnds.OnKeyReleased),this.Trigger(m.Plugins.Keyboard.Cnds.OnKeyCodeReleased);this._keysDownByString.clear()}IsKeyDown(e){return this._keysDownByString.has(e)}IsKeyCodeDown(e){return this._keysDownByWhich.has(e)}SaveToJson(){return{tk:this._triggerWhich,tkk:this._triggerTypedKey}}LoadFromJson(e){this._triggerWhich=e.tk,e.hasOwnProperty("tkk")&&(this._triggerTypedKey=e.tkk)}GetDebuggerProperties(){const e="plugins.keyboard";return[{title:e+".name",properties:[{name:e+".debugger.last-key-code",value:this._triggerWhich},{name:e+".debugger.last-key-string",value:m.Plugins.Keyboard.Exps.StringFromKeyCode(this._triggerWhich)},{name:e+".debugger.last-typed-key",value:this._triggerTypedKey}]}]}}}{const I=self.C3,J=["ShiftLeft","ShiftRight","ControlLeft","ControlRight","AltLeft","AltRight","MetaLeft","MetaRight"];I.Plugins.Keyboard.Cnds={IsKeyDown(e){return this._keysDownByWhich.has(e)},OnKey(e){return this._triggerWhich===e},OnAnyKey(){return!0},OnAnyKeyReleased(){return!0},OnKeyReleased(e){return this._triggerWhich===e},IsKeyCodeDown(e){return e=Math.floor(e),this._keysDownByWhich.has(e)},OnKeyCode(e){return this._triggerWhich===e},OnKeyCodeReleased(e){return this._triggerWhich===e},OnLeftRightKeyPressed(e){const t=J[e];return this._triggerString===t},OnLeftRightKeyReleased(e){const t=J[e];return this._triggerString===t},IsLeftRightKeyDown(e){const t=J[e];return this._keysDownByString.has(t)},IsKeyboardLockSupported(){return this._isKeyboardLockSupported},OnKeyboardLocked(){return!0},OnKeyboardLockError(){return!0}}}{const W=self.C3;W.Plugins.Keyboard.Acts={async LockKeyboard(t){if(this._isKeyboardLockSupported){let e=[];t&&(e=t.split(","));const s=await this.PostToDOMAsync("lock-keyboard",{keysArr:e});s.isOk?this.Trigger(W.Plugins.Keyboard.Cnds.OnKeyboardLocked):this.Trigger(W.Plugins.Keyboard.Cnds.OnKeyboardLockError)}},UnlockKeyboard(){this._isKeyboardLockSupported&&this.PostToDOMAsync("unlock-keyboard")}}}{let StringFromCharCode2=function(e){switch(e=Math.floor(e)){case 8:return"backspace";case 9:return"tab";case 13:return"enter";case 16:return"shift";case 17:return"control";case 18:return"alt";case 19:return"pause";case 20:return"capslock";case 27:return"esc";case 33:return"pageup";case 34:return"pagedown";case 35:return"end";case 36:return"home";case 37:return"←";case 38:return"↑";case 39:return"→";case 40:return"↓";case 45:return"insert";case 46:return"del";case 91:return"left window key";case 92:return"right window key";case 93:return"select";case 96:return"numpad 0";case 97:return"numpad 1";case 98:return"numpad 2";case 99:return"numpad 3";case 100:return"numpad 4";case 101:return"numpad 5";case 102:return"numpad 6";case 103:return"numpad 7";case 104:return"numpad 8";case 105:return"numpad 9";case 106:return"numpad *";case 107:return"numpad +";case 109:return"numpad -";case 110:return"numpad .";case 111:return"numpad /";case 112:return"F1";case 113:return"F2";case 114:return"F3";case 115:return"F4";case 116:return"F5";case 117:return"F6";case 118:return"F7";case 119:return"F8";case 120:return"F9";case 121:return"F10";case 122:return"F11";case 123:return"F12";case 144:return"numlock";case 145:return"scroll lock";case 186:return";";case 187:return"=";case 188:return",";case 189:return"-";case 190:return".";case 191:return"/";case 192:return"'";case 219:return"[";case 220:return"\\";case 221:return"]";case 222:return"#";case 223:return"`";default:return String.fromCharCode(e)}};StringFromCharCode=StringFromCharCode2;const $=self.C3;$.Plugins.Keyboard.Exps={LastKeyCode(){return this._triggerWhich},StringFromKeyCode(e){return StringFromCharCode2(e)},TypedKey(){return this._triggerTypedKey}}}{const a=self.C3;a.Plugins.Mouse=class extends a.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{let GetMouseSdkInstance2=function(){return t.GetSingleGlobalInstance().GetSdkInstance()};GetMouseSdkInstance=GetMouseSdkInstance2;const d=self.C3,e=self.C3X;d.Plugins.Mouse.Type=class extends d.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}GetScriptInterfaceClass(){return self.IMouseObjectType}};let t=null;self.IMouseObjectType=class extends self.IObjectClass{constructor(e){super(e),(t=e).GetRuntime()._GetCommonScriptInterfaces().mouse=this}getMouseX(e){return GetMouseSdkInstance2().GetMousePositionForLayer(e)[0]}getMouseY(e){return GetMouseSdkInstance2().GetMousePositionForLayer(e)[1]}getMousePosition(e){return GetMouseSdkInstance2().GetMousePositionForLayer(e)}isMouseButtonDown(e){return GetMouseSdkInstance2().IsMouseButtonDown(e)}setCursorStyle(t){e.RequireString(t),GetMouseSdkInstance2().SetCursorStyle(t)}setCursorObjectClass(e){const t=GetMouseSdkInstance2(),s=t.GetRuntime(),i=s._UnwrapIObjectClass(e);t.SetCursorObjectClass(i)}}}{let t=self.C3,u="mouse",a=null;t.Plugins.Mouse.Instance=class extends t.SDKInstanceBase{constructor(e,s){super(e,u),this._buttonMap=[!1,!1,!1,!1,!1],this._mouseXcanvas=0,this._mouseYcanvas=0,this._triggerButton=0,this._triggerType=0,this._triggerDir=0,this._wheelDeltaX=0,this._wheelDeltaY=0,this._wheelDeltaZ=0,this._hasPointerLock=!1,this._movementX=0,this._movementY=0,this.AddDOMMessageHandlers([["pointer-lock-change",e=>this._OnPointerLockChange(e)],["pointer-lock-error",e=>this._OnPointerLockError(e)]]);const i=this.GetRuntime().Dispatcher();this._disposables=new t.CompositeDisposable(t.Disposable.From(i,"pointermove",e=>this._OnPointerMove(e.data)),t.Disposable.From(i,"pointerdown",e=>this._OnPointerDown(e.data)),t.Disposable.From(i,"pointerup",e=>this._OnPointerUp(e.data)),t.Disposable.From(i,"dblclick",e=>this._OnDoubleClick(e.data)),t.Disposable.From(i,"wheel",e=>this._OnMouseWheel(e.data)),t.Disposable.From(i,"window-blur",()=>this._OnWindowBlur()))}Release(){super.Release()}_OnPointerDown(e){"mouse"===e.pointerType&&(this._mouseXcanvas=e.pageX-this._runtime.GetCanvasClientX(),this._mouseYcanvas=e.pageY-this._runtime.GetCanvasClientY(),this._CheckButtonChanges(e.lastButtons,e.buttons))}_OnPointerMove(e){this._movementX=e.movementX,this._movementY=e.movementY,this.Trigger(t.Plugins.Mouse.Cnds.OnMovement),this._movementX=0,this._movementY=0,"mouse"===e.pointerType&&(this._mouseXcanvas=e.pageX-this._runtime.GetCanvasClientX(),this._mouseYcanvas=e.pageY-this._runtime.GetCanvasClientY(),this._CheckButtonChanges(e.lastButtons,e.buttons))}_OnPointerUp(e){"mouse"===e.pointerType&&this._CheckButtonChanges(e.lastButtons,e.buttons)}_CheckButtonChanges(e,t){this._CheckButtonChange(e,t,1,0),this._CheckButtonChange(e,t,4,1),this._CheckButtonChange(e,t,2,2),this._CheckButtonChange(e,t,8,3),this._CheckButtonChange(e,t,16,4)}_CheckButtonChange(e,t,s,i){!(e&s)&&t&s?this._OnMouseDown(i):e&s&&!(t&s)&&this._OnMouseUp(i)}_OnMouseDown(e){this._buttonMap[e]=!0,this.Trigger(t.Plugins.Mouse.Cnds.OnAnyClick),this._triggerButton=e,this._triggerType=0,this.Trigger(t.Plugins.Mouse.Cnds.OnClick),this.Trigger(t.Plugins.Mouse.Cnds.OnObjectClicked)}_OnMouseUp(e){this._buttonMap[e]&&(this._buttonMap[e]=!1,this._triggerButton=e,this.Trigger(t.Plugins.Mouse.Cnds.OnRelease))}_OnDoubleClick(e){this._triggerButton=e.button,this._triggerType=1,this.Trigger(t.Plugins.Mouse.Cnds.OnClick),this.Trigger(t.Plugins.Mouse.Cnds.OnObjectClicked)}_OnMouseWheel(e){this._triggerDir=e.deltaY<0?1:0,this._wheelDeltaX=e.deltaX,this._wheelDeltaY=e.deltaY,this._wheelDeltaZ=e.deltaZ,this.Trigger(t.Plugins.Mouse.Cnds.OnWheel)}_OnWindowBlur(){for(let e=0,s=this._buttonMap.length;e<s;++e){if(!this._buttonMap[e])return;this._buttonMap[e]=!1,this._triggerButton=e,this.Trigger(t.Plugins.Mouse.Cnds.OnRelease)}}GetMousePositionForLayer(e){const t=this._runtime.GetMainRunningLayout(),s=this._mouseXcanvas,i=this._mouseYcanvas;if(void 0===e){const r=t.GetLayerByIndex(0);return r.CanvasCssToLayer_DefaultTransform(s,i)}{const n=t.GetLayer(e);return n?n.CanvasCssToLayer(s,i):[0,0]}}IsMouseButtonDown(e){return e=Math.floor(e),!!this._buttonMap[e]}_IsMouseOverCanvas(){return 0<=this._mouseXcanvas&&0<=this._mouseYcanvas&&this._mouseXcanvas<this._runtime.GetCanvasCssWidth()&&this._mouseYcanvas<this._runtime.GetCanvasCssHeight()}SetCursorStyle(e){a!==e&&(a=e,this.PostToDOM("cursor",e))}async SetCursorObjectClass(e){if(!t.Platform.IsMobile&&e){const s=e.GetFirstPicked();if(s){const i=s.GetWorldInfo(),r=s.GetCurrentImageInfo();if(i&&r&&a!==r){const n=await(a=r).ExtractImageToBlobURL(),o=`url(${n}) ${Math.round(i.GetOriginX()*r.GetWidth())} ${Math.round(i.GetOriginY()*r.GetHeight())}, auto`;this.PostToDOM("cursor",o)}}}}_OnPointerLockChange(e){this._UpdatePointerLockState(e["has-pointer-lock"])}_OnPointerLockError(e){this._UpdatePointerLockState(e["has-pointer-lock"]),this.Trigger(t.Plugins.Mouse.Cnds.OnPointerLockError)}_UpdatePointerLockState(e){this._hasPointerLock!==e&&(this._hasPointerLock=e,this._hasPointerLock?this.Trigger(t.Plugins.Mouse.Cnds.OnPointerLocked):this.Trigger(t.Plugins.Mouse.Cnds.OnPointerUnlocked))}GetDebuggerProperties(){const e="plugins.mouse";return[{title:e+".name",properties:[{name:e+".debugger.absolute-position",value:this._mouseXcanvas+","+this._mouseYcanvas},{name:e+".debugger.left-button",value:this._buttonMap[0]},{name:e+".debugger.middle-button",value:this._buttonMap[1]},{name:e+".debugger.right-button",value:this._buttonMap[2]},{name:e+".debugger.button-4",value:this._buttonMap[3]},{name:e+".debugger.button-5",value:this._buttonMap[4]}]},{title:e+".debugger.position-on-each-layer",properties:this._runtime.GetMainRunningLayout().GetLayers().map(e=>({name:"$"+e.GetName(),value:e.CanvasCssToLayer(this._mouseXcanvas,this._mouseYcanvas).join(", ")}))}]}}}{const na=self.C3;na.Plugins.Mouse.Cnds={OnClick(e,t){return this._triggerButton===e&&this._triggerType===t},OnAnyClick(){return!0},IsButtonDown(e){return this._buttonMap[e]},OnRelease(e){return this._triggerButton===e},IsOverObject(e){const t=this._runtime.GetCurrentCondition(),s=t.IsInverted(),i=[];return this._IsMouseOverCanvas()&&i.push([this._mouseXcanvas,this._mouseYcanvas]),na.xor(this._runtime.GetCollisionEngine().TestAndSelectCanvasPointOverlap(e,i,s),s)},OnObjectClicked(e,t,s){if(e!==this._triggerButton||t!==this._triggerType)return!1;if(!this._IsMouseOverCanvas())return!1;const i=this._mouseXcanvas,r=this._mouseYcanvas;return this._runtime.GetCollisionEngine().TestAndSelectCanvasPointOverlap(s,[[i,r]],!1)},OnWheel(e){return 2===e||this._triggerDir===e},OnPointerLocked(){return!0},OnPointerUnlocked(){return!0},OnPointerLockError(){return!0},HasPointerLock(){return this._hasPointerLock},OnMovement(){return!0}}}{const Ca=self.C3,Da=["auto","pointer","text","crosshair","move","help","wait","none"],Ea=["auto","all-scroll","none","help","pointer","progress","wait","cell","crosshair","text","vertical-text","alias","copy","move","not-allowed","grab","grabbing","col-resize","row-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out"];Ca.Plugins.Mouse.Acts={SetCursor(e){this.SetCursorStyle(Da[e])},SetCursor2(e){this.SetCursorStyle(Ea[e])},SetCursorSprite(e){this.SetCursorObjectClass(e)},RequestPointerLock(e){this._PostToDOMMaybeSync("request-pointer-lock",{unadjustedMovement:e})},ReleasePointerLock(){this.PostToDOM("release-pointer-lock")}}}{const Ja=self.C3;Ja.Plugins.Mouse.Exps={X(e){return this.GetMousePositionForLayer(e)[0]},Y(e){return this.GetMousePositionForLayer(e)[1]},AbsoluteX(){return this._mouseXcanvas},AbsoluteY(){return this._mouseYcanvas},MovementX(){return this._movementX},MovementY(){return this._movementY},WheelDeltaX(){return this._wheelDeltaX},WheelDeltaY(){return this._wheelDeltaY},WheelDeltaZ(){return this._wheelDeltaZ}}}{const a=self.C3;a.Plugins.Touch=class extends a.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{let GetTouchSdkInstance2=function(){return s.GetSingleGlobalInstance().GetSdkInstance()};GetTouchSdkInstance=GetTouchSdkInstance2;const d=self.C3,e=self.C3X;d.Plugins.Touch.Type=class extends d.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}GetScriptInterfaceClass(){return self.ITouchObjectType}};let s=null;self.ITouchObjectType=class extends self.IObjectClass{constructor(e){super(e),(s=e).GetRuntime()._GetCommonScriptInterfaces().touch=this}requestPermission(t){e.RequireString(t);const s=GetTouchSdkInstance2();if("orientation"===t)return s._RequestPermission(0);if("motion"===t)return s._RequestPermission(1);throw new Error("invalid type")}}}{const m=self.C3,n="touch";m.Plugins.Touch.Instance=class extends m.SDKInstanceBase{constructor(e,t){super(e,n),this._touches=new Map,this._useMouseInput=!1,this._isMouseDown=!1,this._orientCompassHeading=0,this._orientAlpha=0,this._orientBeta=0,this._orientGamma=0,this._accX=0,this._accY=0,this._accZ=0,this._accWithGX=0,this._accWithGY=0,this._accWithGZ=0,this._triggerIndex=0,this._triggerId=0,this._triggerPermission=0,this._curTouchX=0,this._curTouchY=0,this._getTouchIndex=0,this._triggerType=0,this._permissionPromises=[],t&&(this._useMouseInput=t[0]),this.AddDOMMessageHandler("permission-result",e=>this._OnPermissionResult(e));const s=this.GetRuntime().Dispatcher();this._disposables=new m.CompositeDisposable(m.Disposable.From(s,"pointerdown",e=>this._OnPointerDown(e.data)),m.Disposable.From(s,"pointermove",e=>this._OnPointerMove(e.data)),m.Disposable.From(s,"pointerup",e=>this._OnPointerUp(e.data,!1)),m.Disposable.From(s,"pointercancel",e=>this._OnPointerUp(e.data,!0)),m.Disposable.From(s,"deviceorientation",e=>this._OnDeviceOrientation(e.data)),m.Disposable.From(s,"deviceorientationabsolute",e=>this._OnDeviceOrientationAbsolute(e.data)),m.Disposable.From(s,"devicemotion",e=>this._OnDeviceMotion(e.data)),m.Disposable.From(s,"tick2",e=>this._OnTick2()))}Release(){this._touches.clear(),super.Release()}_OnPointerDown(e){if("mouse"===e.pointerType){if(!this._useMouseInput)return;this._isMouseDown=!0}const t=e.pointerId;if(!this._touches.has(t)){const s=e.pageX-this._runtime.GetCanvasClientX(),i=e.pageY-this._runtime.GetCanvasClientY(),r=performance.now(),n=this._touches.size,a=(this._triggerIndex=n,this._triggerId=t,m.New(m.Plugins.Touch.TouchInfo));a.Init(r,s,i,t,n),this._touches.set(t,a),this.Trigger(m.Plugins.Touch.Cnds.OnNthTouchStart),this.Trigger(m.Plugins.Touch.Cnds.OnTouchStart),this._curTouchX=s,this._curTouchY=i,this._triggerType=0,this.Trigger(m.Plugins.Touch.Cnds.OnTouchObject)}}_OnPointerMove(e){if("mouse"!==e.pointerType||this._isMouseDown){const t=this._touches.get(e.pointerId);if(t){const s=performance.now();if(!(s-t.GetTime()<2)){const i=e.pageX-this._runtime.GetCanvasClientX(),r=e.pageY-this._runtime.GetCanvasClientY();t.Update(s,i,r,e.width,e.height,e.pressure)}}}}_OnPointerUp(e,t){if("mouse"===e.pointerType){if(!this._isMouseDown)return;this._isMouseDown=!1}const s=performance.now(),i=e.pointerId,r=this._touches.get(i);if(r){if(this._triggerIndex=r.GetStartIndex(),this._triggerId=r.GetId(),!t){const n=e.pageX-this._runtime.GetCanvasClientX(),a=e.pageY-this._runtime.GetCanvasClientY();this._curTouchX=n,this._curTouchY=a,this._triggerType=1,this.Trigger(m.Plugins.Touch.Cnds.OnTouchObject)}if(this.Trigger(m.Plugins.Touch.Cnds.OnNthTouchEnd),this.Trigger(m.Plugins.Touch.Cnds.OnTouchEnd),!t){const o=r.ShouldTriggerTap(s);"single-tap"===o?(this.Trigger(m.Plugins.Touch.Cnds.OnTapGesture),this._curTouchX=r.GetX(),this._curTouchY=r.GetY(),this.Trigger(m.Plugins.Touch.Cnds.OnTapGestureObject)):"double-tap"===o&&(this.Trigger(m.Plugins.Touch.Cnds.OnDoubleTapGesture),this._curTouchX=r.GetX(),this._curTouchY=r.GetY(),this.Trigger(m.Plugins.Touch.Cnds.OnDoubleTapGestureObject))}r.Release(),this._touches.delete(i)}}_RequestPermission(s){return this._PostToDOMMaybeSync("request-permission",{type:s}),new Promise((e,t)=>{this._permissionPromises.push({type:s,resolve:e,reject:t})})}_OnPermissionResult(e){const t=e.result,s=e.type,i=(this._triggerPermission=s,this._permissionPromises.filter(e=>e.type===s));for(const r of i)r.resolve(t?"granted":"denied");this._permissionPromises=this._permissionPromises.filter(e=>e.type!==s),t?(this.Trigger(m.Plugins.Touch.Cnds.OnPermissionGranted),0===s?this._runtime.RequestDeviceOrientationEvent():this._runtime.RequestDeviceMotionEvent()):this.Trigger(m.Plugins.Touch.Cnds.OnPermissionDenied)}_OnDeviceOrientation(e){"number"==typeof e.webkitCompassHeading?this._orientCompassHeading=e.webkitCompassHeading:e.absolute&&(this._orientCompassHeading=e.alpha),this._orientAlpha=e.alpha,this._orientBeta=e.beta,this._orientGamma=e.gamma}_OnDeviceOrientationAbsolute(e){this._orientCompassHeading=e.alpha}_OnDeviceMotion(e){const t=e.acceleration,s=(t&&(this._accX=t.x,this._accY=t.y,this._accZ=t.z),e.accelerationIncludingGravity);s&&(this._accWithGX=s.x,this._accWithGY=s.y,this._accWithGZ=s.z)}_OnTick2(){let e=performance.now(),t=0;for(const s of this._touches.values())s.GetTime()<=e-50&&s._SetLastTime(e),s.ShouldTriggerHold(e)&&(this._triggerIndex=s.GetStartIndex(),this._triggerId=s.GetId(),this._getTouchIndex=t,this.Trigger(m.Plugins.Touch.Cnds.OnHoldGesture),this._curTouchX=s.GetX(),this._curTouchY=s.GetY(),this.Trigger(m.Plugins.Touch.Cnds.OnHoldGestureObject),this._getTouchIndex=0),++t}_GetTouchByIndex(e){e=Math.floor(e);for(const t of this._touches.values()){if(0===e)return t;--e}return null}_IsClientPosOnCanvas(e,t){return 0<=e&&0<=t&&e<this._runtime.GetCanvasCssWidth()&&t<this._runtime.GetCanvasCssHeight()}GetDebuggerProperties(){return[{title:"plugins.touch.debugger.touches",properties:[...this._touches.values()].map(e=>({name:"$"+e.GetId(),value:e.GetX()+", "+e.GetY()}))}]}}}{const ra=self.C3,sa=[];ra.Plugins.Touch.Cnds={OnTouchStart(){return!0},OnTouchEnd(){return!0},IsInTouch(){return 0<this._touches.size},OnTouchObject(e,t){return!!e&&t===this._triggerType&&!!this._IsClientPosOnCanvas(this._curTouchX,this._curTouchY)&&this._runtime.GetCollisionEngine().TestAndSelectCanvasPointOverlap(e,[[this._curTouchX,this._curTouchY]],!1)},IsTouchingObject(e){if(!e)return!1;const t=this._runtime.GetCurrentCondition(),s=t.IsInverted(),i=[...this._touches.values()].filter(e=>this._IsClientPosOnCanvas(e.GetX(),e.GetY())).map(e=>[e.GetX(),e.GetY()]);return ra.xor(this._runtime.GetCollisionEngine().TestAndSelectCanvasPointOverlap(e,i,s),s)},CompareTouchSpeed(e,t,s){const i=this._GetTouchByIndex(e);return!!i&&ra.compare(i.GetSpeed(),t,s)},OrientationSupported(){return!0},MotionSupported(){return!0},CompareOrientation(e,t,s){this._runtime.RequestDeviceOrientationEvent();let i;return i=0===e?this._orientAlpha:1===e?this._orientBeta:this._orientGamma,ra.compare(i,t,s)},CompareAcceleration(e,t,s){this._runtime.RequestDeviceMotionEvent();let i;return i=0===e?this._accWithGX:1===e?this._accWithGY:2===e?this._accWithGZ:3===e?this._accX:4===e?this._accY:this._accZ,ra.compare(i,t,s)},OnNthTouchStart(e){return(e=Math.floor(e))===this._triggerIndex},OnNthTouchEnd(e){return(e=Math.floor(e))===this._triggerIndex},HasNthTouch(e){return e=Math.floor(e),this._touches.size>=e+1},OnHoldGesture(){return!0},OnTapGesture(){return!0},OnDoubleTapGesture(){return!0},OnHoldGestureObject(e){return!!e&&!!this._IsClientPosOnCanvas(this._curTouchX,this._curTouchY)&&this._runtime.GetCollisionEngine().TestAndSelectCanvasPointOverlap(e,[[this._curTouchX,this._curTouchY]],!1)},OnTapGestureObject(e){return!!e&&!!this._IsClientPosOnCanvas(this._curTouchX,this._curTouchY)&&this._runtime.GetCollisionEngine().TestAndSelectCanvasPointOverlap(e,[[this._curTouchX,this._curTouchY]],!1)},OnDoubleTapGestureObject(e){return!!e&&!!this._IsClientPosOnCanvas(this._curTouchX,this._curTouchY)&&this._runtime.GetCollisionEngine().TestAndSelectCanvasPointOverlap(e,[[this._curTouchX,this._curTouchY]],!1)},OnPermissionGranted(e){return this._triggerPermission===e},OnPermissionDenied(e){return this._triggerPermission===e}}}{const Va=self.C3;Va.Plugins.Touch.Acts={RequestPermission(e){this._RequestPermission(e)}}}{const Xa=self.C3;Xa.Plugins.Touch.Exps={TouchCount(){return this._touches.size},X(e){const t=this._GetTouchByIndex(this._getTouchIndex);return t?t.GetPositionForLayer(this._runtime.GetCurrentLayout(),e,!0):0},Y(e){const t=this._GetTouchByIndex(this._getTouchIndex);return t?t.GetPositionForLayer(this._runtime.GetCurrentLayout(),e,!1):0},XAt(e,t){const s=this._GetTouchByIndex(e);return s?s.GetPositionForLayer(this._runtime.GetCurrentLayout(),t,!0):0},YAt(e,t){const s=this._GetTouchByIndex(e);return s?s.GetPositionForLayer(this._runtime.GetCurrentLayout(),t,!1):0},XForID(e,t){const s=this._touches.get(e);return s?s.GetPositionForLayer(this._runtime.GetCurrentLayout(),t,!0):0},YForID(e,t){const s=this._touches.get(e);return s?s.GetPositionForLayer(this._runtime.GetCurrentLayout(),t,!1):0},AbsoluteX(){const e=this._GetTouchByIndex(0);return e?e.GetX():0},AbsoluteY(){const e=this._GetTouchByIndex(0);return e?e.GetY():0},AbsoluteXAt(e){const t=this._GetTouchByIndex(e);return t?t.GetX():0},AbsoluteYAt(e){const t=this._GetTouchByIndex(e);return t?t.GetY():0},AbsoluteXForID(e){const t=this._touches.get(e);return t?t.GetX():0},AbsoluteYForID(e){const t=this._touches.get(e);return t?t.GetY():0},SpeedAt(e){const t=this._GetTouchByIndex(e);return t?t.GetSpeed():0},SpeedForID(e){const t=this._touches.get(e);return t?t.GetSpeed():0},AngleAt(e){const t=this._GetTouchByIndex(e);return t?Xa.toDegrees(t.GetAngle()):0},AngleForID(e){const t=this._touches.get(e);return t?Xa.toDegrees(t.GetAngle()):0},CompassHeading(){return this._runtime.RequestDeviceOrientationEvent(),this._orientCompassHeading},Alpha(){return this._runtime.RequestDeviceOrientationEvent(),this._orientAlpha},Beta(){return this._runtime.RequestDeviceOrientationEvent(),this._orientBeta},Gamma(){return this._runtime.RequestDeviceOrientationEvent(),this._orientGamma},AccelerationXWithG(){return this._runtime.RequestDeviceMotionEvent(),this._accWithGX},AccelerationYWithG(){return this._runtime.RequestDeviceMotionEvent(),this._accWithGY},AccelerationZWithG(){return this._runtime.RequestDeviceMotionEvent(),this._accWithGZ},AccelerationX(){return this._runtime.RequestDeviceMotionEvent(),this._accX},AccelerationY(){return this._runtime.RequestDeviceMotionEvent(),this._accY},AccelerationZ(){return this._runtime.RequestDeviceMotionEvent(),this._accZ},TouchIndex(){return this._triggerIndex},TouchID(){return this._triggerId},WidthForID(e){const t=this._touches.get(e);return t?t.GetWidth():0},HeightForID(e){const t=this._touches.get(e);return t?t.GetHeight():0},PressureForID(e){const t=this._touches.get(e);return t?t.GetPressure():0}}}{let C33=self.C3,GESTURE_HOLD_THRESHOLD=15,GESTURE_HOLD_TIMEOUT=500,GESTURE_TAP_TIMEOUT=333,GESTURE_DOUBLETAP_THRESHOLD=25,lastTapX=-1e3,lastTapY=-1e3,lastTapTime=-1e4;C33.Plugins.Touch.TouchInfo=class extends C33.DefendedBase{constructor(){super(),this._pointerId=0,this._startIndex=0,this._startTime=0,this._time=0,this._lastTime=0,this._startX=0,this._startY=0,this._x=0,this._y=0,this._lastX=0,this._lastY=0,this._width=0,this._height=0,this._pressure=0,this._hasTriggeredHold=!1,this._isTooFarForHold=!1}Release(){}Init(e,t,s,i,r){this._pointerId=i,this._startIndex=r,this._time=e,this._lastTime=e,this._startTime=e,this._startX=t,this._startY=s,this._x=t,this._y=s,this._lastX=t,this._lastY=s}Update(e,t,s,i,r,n){this._lastTime=this._time,this._time=e,this._lastX=this._x,this._lastY=this._y,this._x=t,this._y=s,this._width=i,this._height=r,this._pressure=n,!this._isTooFarForHold&&C33.distanceTo(this._startX,this._startY,this._x,this._y)>=GESTURE_HOLD_THRESHOLD&&(this._isTooFarForHold=!0)}GetId(){return this._pointerId}GetStartIndex(){return this._startIndex}GetTime(){return this._time}_SetLastTime(e){this._lastTime=e}GetX(){return this._x}GetY(){return this._y}GetSpeed(){const e=C33.distanceTo(this._x,this._y,this._lastX,this._lastY),t=(this._time-this._lastTime)/1e3;return 0<t?e/t:0}GetAngle(){return C33.angleTo(this._lastX,this._lastY,this._x,this._y)}GetWidth(){return this._width}GetHeight(){return this._height}GetPressure(){return this._pressure}ShouldTriggerHold(e){return!this._hasTriggeredHold&&e-this._startTime>=GESTURE_HOLD_TIMEOUT&&!this._isTooFarForHold&&C33.distanceTo(this._startX,this._startY,this._x,this._y)<GESTURE_HOLD_THRESHOLD&&(this._hasTriggeredHold=!0)}ShouldTriggerTap(e){return!this._hasTriggeredHold&&e-this._startTime<=GESTURE_TAP_TIMEOUT&&!this._isTooFarForHold&&C33.distanceTo(this._startX,this._startY,this._x,this._y)<GESTURE_HOLD_THRESHOLD?e-lastTapTime<=2*GESTURE_TAP_TIMEOUT&&C33.distanceTo(lastTapX,lastTapY,this._x,this._y)<GESTURE_DOUBLETAP_THRESHOLD?(lastTapX=-1e3,lastTapY=-1e3,lastTapTime=-1e4,"double-tap"):(lastTapX=this._x,lastTapY=this._y,lastTapTime=e,"single-tap"):""}GetPositionForLayer(e,t,s){if(void 0===t){const i=e.GetLayerByIndex(0);return i.CanvasCssToLayer_DefaultTransform(this._x,this._y)[s?0:1]}{const r=e.GetLayer(t);return r?r.CanvasCssToLayer(this._x,this._y)[s?0:1]:0}}}}{const a=self.C3;a.Plugins.LocalStorage=class extends a.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{const d=self.C3;d.Plugins.LocalStorage.Type=class extends d.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const g=self.C3,h="localstorage";g.Plugins.LocalStorage.Instance=class extends g.SDKInstanceBase{constructor(e,t){super(e,h),this._currentKey="",this._lastValue="",this._keyNamesList=[],this._errorMessage="",this._isPersistent=!1,this._pendingGets=0,this._pendingSets=0,this._isInMemoryOnly=!1,t&&(this._isInMemoryOnly=t[0]);const s=this._runtime._GetProjectStorage();this._storage=null,this._isInMemoryOnly?this._storage=s.createInstance({forceInMemoryFallback:!0}):this._storage=s,this._debugCache=new Map,this._isLoadingDebugCache=!1,this._runtime.AddLoadPromise(this._Init())}async _Init(){const e=await Promise.race([this.PostToDOMAsync("init"),g.Wait(3e3)]);e&&(this._isPersistent=e.isPersistent)}Release(){super.Release()}async _TriggerStorageError(e){this._errorMessage=this._GetErrorString(e),await this.TriggerAsync(g.Plugins.LocalStorage.Cnds.OnError)}_GetErrorString(e){return e?"string"==typeof e?e:"string"==typeof e.message?e.message:"string"==typeof e.name?e.name:"string"==typeof e.data?e.data:"unknown error":"unknown error"}GetDebuggerProperties(){return this._isLoadingDebugCache||this._DebugCacheStorage(),[{title:"plugins.localstorage.name",properties:[...this._debugCache.entries()].map(t=>({name:"$"+t[0],value:t[1],onedit:e=>this._storage.setItem(t[0],e)}))}]}async _DebugCacheStorage(){this._isLoadingDebugCache=!0;try{const s=await this._storage.keys(),i=(s.sort((e,t)=>{const s=e.toLowerCase(),i=t.toLowerCase();return s<i?-1:i<s?1:0}),await Promise.all(s.map(e=>this._storage.getItem(e))));this._debugCache.clear();for(let e=0,t=s.length;e<t;++e)this._debugCache.set(s[e],i[e])}catch(e){console.warn("[C3 debugger] Error displaying local storage: ",e)}finally{this._isLoadingDebugCache=!1}}}}{const B=self.C3;B.Plugins.LocalStorage.Cnds={OnItemSet(e){return this._currentKey===e},OnAnyItemSet(){return!0},OnItemGet(e){return this._currentKey===e},OnAnyItemGet(){return!0},OnItemRemoved(e){return this._currentKey===e},OnAnyItemRemoved(){return!0},OnCleared(){return!0},OnAllKeyNamesLoaded(){return!0},OnError(){return!0},OnItemExists(e){return this._currentKey===e},OnItemMissing(e){return this._currentKey===e},CompareKey(e,t){return B.compare(this._currentKey,e,t)},CompareValue(e,t){return B.compare(this._lastValue,e,t)},IsProcessingSets(){return 0<this._pendingSets},IsProcessingGets(){return 0<this._pendingGets},OnAllSetsComplete(){return!0},OnAllGetsComplete(){return!0},IsPersistent(){return this._isPersistent}}}{let IsExpressionType2=function(e){return"string"==typeof e||"number"==typeof e};IsExpressionType=IsExpressionType2;const L=self.C3;L.Plugins.LocalStorage.Acts={async SetItem(e,t){this._pendingSets++;try{const s=await this._storage.setItem(e,t);await this.ScheduleTriggers(async()=>{this._currentKey=e,this._lastValue=s,await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnAnyItemSet),await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnItemSet)})}catch(e){await this._TriggerStorageError(e)}finally{this._pendingSets--,0===this._pendingSets&&await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnAllSetsComplete)}},async SetBinaryItem(e,t){if(t){const s=t.GetFirstPicked(this._inst);if(s){const i=s.GetSdkInstance();if(i){const r=i.GetArrayBufferReadOnly();this._pendingSets++;try{await this._storage.setItem(e,r),await this.ScheduleTriggers(async()=>{this._currentKey=e,this._lastValue="",await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnAnyItemSet),await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnItemSet)})}catch(e){await this._TriggerStorageError(e)}finally{this._pendingSets--,0===this._pendingSets&&await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnAllSetsComplete)}}}}},async GetItem(e){this._pendingGets++;try{const t=await this._storage.getItem(e);await this.ScheduleTriggers(async()=>{this._currentKey=e,this._lastValue=IsExpressionType2(t)?t:"",await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnAnyItemGet),await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnItemGet)})}catch(e){await this._TriggerStorageError(e)}finally{this._pendingGets--,0===this._pendingGets&&await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnAllGetsComplete)}},async GetBinaryItem(t,e){if(e){const s=e.GetFirstPicked(this._inst);if(s){const i=s.GetSdkInstance();this._pendingGets++;try{let e=await this._storage.getItem(t);e=e instanceof ArrayBuffer?e:new ArrayBuffer(0),await this.ScheduleTriggers(async()=>{this._lastValue="",this._currentKey=t,i.SetArrayBufferTransfer(e),await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnAnyItemGet),await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnItemGet)})}catch(e){await this._TriggerStorageError(e)}finally{this._pendingGets--,0===this._pendingGets&&await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnAllGetsComplete)}}}},async CheckItemExists(e){try{const t=await this._storage.getItem(e);await this.ScheduleTriggers(async()=>{this._currentKey=e,null==t?(this._lastValue="",await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnItemMissing)):(this._lastValue=IsExpressionType2(t)?t:"",await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnItemExists))})}catch(e){await this._TriggerStorageError(e)}},async RemoveItem(e){try{await this._storage.removeItem(e),await this.ScheduleTriggers(async()=>{this._currentKey=e,this._lastValue="",await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnAnyItemRemoved),await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnItemRemoved)})}catch(e){await this._TriggerStorageError(e)}},async ClearStorage(){try{await this._storage.clear(),await this.ScheduleTriggers(async()=>{this._currentKey="",this._lastValue="",L.clearArray(this._keyNamesList),await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnCleared)})}catch(e){await this._TriggerStorageError(e)}},async GetAllKeyNames(){try{const e=await this._storage.keys();await this.ScheduleTriggers(async()=>{this._keyNamesList=e,await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnAllKeyNamesLoaded)})}catch(e){await this._TriggerStorageError(e)}},async RequestPersistent(){const e=await this.PostToDOMAsync("request-persistent");e.isOk&&(this._isPersistent=e.isPersistent)},LoadMemoryFromJSON(t){if(this._isInMemoryOnly){let e;try{e=JSON.parse(t)}catch(e){return void console.error("[Local Storage] Failed to parse memory storage JSON: ",e)}e&&e["is-c3-storage"]&&Array.isArray(e.items)||console.error("[Local Storage] Failed to load memory storage JSON: invalid data"),this._storage.SetMemoryStorage(new Map(e.items))}}}}{const qa=self.C3;qa.Plugins.LocalStorage.Exps={ItemValue(){return this._lastValue},Key(){return this._currentKey},KeyCount(){return this._keyNamesList.length},KeyAt(e){return(e=Math.floor(e))<0||e>=this._keyNamesList.length?"":this._keyNamesList[e]},ErrorMessage(){return this._errorMessage},MemoryStorageAsJSON(){return this._isInMemoryOnly?JSON.stringify({"is-c3-storage":!0,items:[...this._storage.GetMemoryStorage()]}):""}}}{const a=self.C3;a.Plugins.Spritefont2=class extends a.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{const d=self.C3;d.Plugins.Spritefont2.Type=class extends d.SDKTypeBase{constructor(e){super(e),this._spriteFont=d.New(self.SpriteFont)}Release(){super.Release()}OnCreate(){this.GetImageInfo().LoadAsset(this._runtime)}LoadTextures(e){return this.GetImageInfo().LoadStaticTexture(e,{sampling:this._runtime.GetSampling()})}ReleaseTextures(){this.GetImageInfo().ReleaseTexture()}GetSpriteFont(){return this._spriteFont}UpdateSettings(e,t,s,i){const r=this.GetImageInfo(),n=this._spriteFont;n.SetWidth(r.GetWidth()),n.SetHeight(r.GetHeight()),n.SetCharacterWidth(e),n.SetCharacterHeight(t),n.SetCharacterSet(s),n.SetSpacingData(i),n.UpdateCharacterMap()}}}{const n=self.C3,o=self.C3X,p=n.New(n.Vector2),q=0,r=1,s=2,t=3,u=4,v=5,w=6,x=7,y=8,z=9,A=10,B=11,C=12,D=13,E=14,F=["left","center","right"],G=["top","center","bottom"],H=["word","cjk","character"],I=(n.Plugins.Spritefont2.Instance=class extends n.SDKWorldInstanceBase{constructor(e,t){super(e),this._text="",this._enableBBcode=!0,this._characterWidth=16,this._characterHeight=16,this._characterSet="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,;:?!-_~#\"'&()[]|`\\/@°+=*$£€<>";let s="";if(this._characterScale=1,this._characterSpacing=0,this._lineHeight=0,this._horizontalAlign=0,this._verticalAlign=0,this._wrapMode="word",this._needsTextLayout=!0,this._readAloud=!1,this._screenReaderText=null,this._spriteFontText=null,this._typewriterStartTime=-1,this._typewriterEndTime=-1,this._typewriterLength=0,t){this._text=t[0],this._enableBBcode=t[1],this._characterWidth=t[2],this._characterHeight=t[3],this._characterSet=t[4],s=t[5],this._characterScale=t[6],this._characterSpacing=t[7],this._lineHeight=t[8],this._horizontalAlign=t[9],this._verticalAlign=t[10],this._wrapMode=H[t[11]];const r=this.GetWorldInfo();r.SetVisible(t[12]),this._readAloud=!!t[E]}this._sdkType.UpdateSettings(this._characterWidth,this._characterHeight,this._characterSet,s),this._spriteFontText=n.New(self.SpriteFontText,this._sdkType.GetSpriteFont());const i=this.GetWorldInfo();this._spriteFontText.SetSize(i.GetWidth(),i.GetHeight()),this._UpdateSettings(),this._UpdateScreenReaderText(),this._inst.SetMustMitigateZFighting()}Release(){this._CancelTypewriter(),this._screenReaderText&&(this._screenReaderText.Release(),this._screenReaderText=null),this._spriteFontText.Release(),this._spriteFontText=null,super.Release()}_UpdateSettings(){const e=this._spriteFontText;e&&(e.SetBBCodeEnabled(this._enableBBcode),e.SetText(this._text),e.SetWordWrapMode(this._wrapMode),e.SetHorizontalAlign(F[this._horizontalAlign]),e.SetVerticalAlign(G[this._verticalAlign]),e.SetSpacing(this._characterSpacing),e.SetLineHeight(this._lineHeight))}_UpdateTextSize(){const e=this.GetWorldInfo();this._spriteFontText.SetSize(e.GetWidth(),e.GetHeight()),this._spriteFontText.SetScale(this._characterScale)}_UpdateScreenReaderText(){if(this._readAloud){let e=this._text;this._enableBBcode&&(e=n.BBString.StripAnyTags(e)),this._screenReaderText?this._screenReaderText.SetText(e):this._screenReaderText=n.New(n.ScreenReaderText,this._runtime,e)}else this._screenReaderText&&(this._screenReaderText.Release(),this._screenReaderText=null)}Draw(i){const r=this._objectClass.GetImageInfo(),n=r.GetTexture();if(n){i.SetTexture(n);let e=this.GetWorldInfo(),t=e.GetBoundingQuad(),s=this._spriteFontText;s.SetScale(this._characterScale),s.SetSceneGraphScale(e.GetSceneGraphScale()),this._runtime.IsPixelRoundingEnabled()&&(t=e.PixelRoundQuad(t)),s.SetSize(e.GetWidth(),e.GetHeight()),s.GetSpriteFont().SetTexRect(r.GetTexRect()),s.SetColor(e.GetUnpremultipliedColor()),s.Draw(i,t.getTlx(),t.getTly(),e.GetAngle()),this._needsTextLayout=!1}}SaveToJson(){const e={t:this._text,ebbc:this._enableBBcode,csc:this._characterScale,csp:this._characterSpacing,lh:this._lineHeight,ha:this._horizontalAlign,va:this._verticalAlign,w:this._wrapMode,cw:this._sdkType.GetSpriteFont().GetCharacterWidth(),ch:this._sdkType.GetSpriteFont().GetCharacterHeight(),cs:this._sdkType.GetSpriteFont().GetCharacterSet(),sd:this._sdkType.GetSpriteFont().GetSpacingData()};return-1!==this._typewriterEndTime&&(e.tw={st:this._typewriterStartTime,en:this._typewriterEndTime,l:this._typewriterLength}),e}LoadFromJson(e){if(this._CancelTypewriter(),this._text=e.t,this._enableBBcode=e.ebbc,this._characterScale=e.csc,this._characterSpacing=e.csp,this._lineHeight=e.lh,this._horizontalAlign=e.ha,this._verticalAlign=e.va,e.hasOwnProperty("w")){const s=e.w;this._wrapMode="boolean"==typeof s?s?"word":"character":s}else this._wrapMode="word";if(e.hasOwnProperty("tw")){const i=e.tw;this._typewriterStartTime=i.st,this._typewriterEndTime=i.en,this._typewriterLength=e.l}const t=this._sdkType.GetSpriteFont();t.SetCharacterWidth(e.cw),t.SetCharacterHeight(e.ch),t.SetCharacterSet(e.cs),t.SetSpacingData(e.sd),this._UpdateSettings(),this._UpdateScreenReaderText(),-1!==this._typewriterEndTime&&this._StartTicking()}GetPropertyValueByIndex(e){switch(e){case q:return this.GetText();case r:return this._enableBBcode;case s:return this._sdkType.GetSpriteFont().GetCharacterWidth();case t:return this._sdkType.GetSpriteFont().GetCharacterHeight();case u:return this._sdkType.GetSpriteFont().GetCharacterSet();case v:return this._sdkType.GetSpriteFont().GetSpacingData();case w:return this._GetScale();case x:return this._GetCharacterSpacing();case y:return this._GetLineHeight();case z:return this._GetHAlign();case A:return this._GetVAlign();case B:return this._GetWrapMode()}}SetPropertyValueByIndex(e,i){switch(e){case q:this._SetText(i);break;case r:this._enableBBcode!==!!i&&(this._enableBBcode=!!i,this._UpdateSettings());break;case s:this._sdkType.GetSpriteFont().SetCharacterWidth(i);break;case t:this._sdkType.GetSpriteFont().SetCharacterHeight(i);break;case u:this._sdkType.GetSpriteFont().SetCharacterSet(i);break;case v:this._sdkType.GetSpriteFont().SetSpacingData(i);break;case w:this._SetScale(i);break;case x:this._SetCharacterSpacing(i);break;case y:this._SetLineHeight(i);break;case z:this._SetHAlign(i);break;case A:this._SetVAlign(i);break;case B:this._SetWrapMode(i)}}_SetText(e){this._text!==e&&(this._text=e,this._spriteFontText.SetText(e),this._UpdateScreenReaderText(),this._runtime.UpdateRender())}GetText(){return this._text}_StartTypewriter(e,t){this._SetText(e),this._typewriterStartTime=this._runtime.GetWallTime(),this._typewriterEndTime=this._typewriterStartTime+t/this.GetInstance().GetActiveTimeScale(),this._typewriterLength=n.CountGraphemes(n.BBString.StripAnyTags(e)),this._spriteFontText.SetDrawMaxCharacterCount(0),this._StartTicking()}_CancelTypewriter(){this._typewriterStartTime=-1,this._typewriterEndTime=-1,this._typewriterLength=0,this._spriteFontText.SetDrawMaxCharacterCount(-1),this._StopTicking()}_FinishTypewriter(){-1!==this._typewriterEndTime&&(this._CancelTypewriter(),this.Trigger(n.Plugins.Spritefont2.Cnds.OnTypewriterTextFinished),this._runtime.UpdateRender())}_SetScale(e){this._characterScale!==e&&(this._characterScale=e,this._spriteFontText.SetScale(this._characterScale),this._runtime.UpdateRender())}_GetScale(){return this._characterScale}_SetCharacterSpacing(e){this._characterSpacing!==e&&(this._characterSpacing=e,this._spriteFontText.SetSpacing(this._characterSpacing),this._runtime.UpdateRender())}_GetCharacterSpacing(){return this._characterSpacing}_SetLineHeight(e){this._lineHeight!==e&&(this._lineHeight=e,this._spriteFontText.SetLineHeight(this._lineHeight),this._runtime.UpdateRender())}_GetLineHeight(){return this._lineHeight}_SetHAlign(e){this._horizontalAlign!==e&&(this._horizontalAlign=e,this._UpdateSettings(),this._runtime.UpdateRender())}_GetHAlign(){return this._horizontalAlign}_SetVAlign(e){this._verticalAlign!==e&&(this._verticalAlign=e,this._UpdateSettings(),this._runtime.UpdateRender())}_GetVAlign(){return this._verticalAlign}_SetWrapModeByIndex(e){this._SetWrapMode(H[e])}_SetWrapMode(e){this._wrapMode!==e&&(this._wrapMode=e,this._UpdateSettings(),this._runtime.UpdateRender())}_GetWrapMode(){return this._wrapMode}_SetReadAloud(e){this._readAloud=!!e,this._UpdateScreenReaderText()}_IsReadAloud(){return this._readAloud}_GetTextWidth(){return this._UpdateTextSize(),this._spriteFontText.GetTextWidth()}_GetTextHeight(){return this._UpdateTextSize(),this._spriteFontText.GetTextHeight()}_GetTagAtPosition(e,t){this._UpdateTextSize();const s=this.GetWorldInfo(),i=(p.set(e-s.GetX(),t-s.GetY()),p.rotate(-s.GetAngle()),p.offset(s.GetWidth()*s.GetOriginX(),s.GetHeight()*s.GetOriginY()),this._spriteFontText.HitTestFragment(p.getX(),p.getY()));if(i){const r=i.GetStyleTag("tag");if(r)return r.param}return""}_HasTagAtPosition(e,t,s){const i=this._GetTagAtPosition(t,s);return i&&n.equalsNoCase(e,i)}_GetTagPosition(e,t){this._UpdateTextSize(),t=Math.floor(t);const s=this._spriteFontText.FindFragmentWithTag(e,t);if(!s)return null;const i=this.GetWorldInfo();return p.set(s.GetPosX(),s.GetPosY()),p.offset(-i.GetWidth()*i.GetOriginX(),-i.GetHeight()*i.GetOriginY()),p.rotate(i.GetAngle()),p.offset(i.GetX(),i.GetY()),{x:p.getX(),y:p.getY(),width:s.GetWidth(),height:s.GetHeight()}}_GetTagCount(e){return this._UpdateTextSize(),this._spriteFontText.CountFragmentsWithTag(e)}Tick(){const t=this._runtime.GetWallTime();if(t>=this._typewriterEndTime)this._CancelTypewriter(),this.Trigger(n.Plugins.Spritefont2.Cnds.OnTypewriterTextFinished),this._runtime.UpdateRender();else{let e=n.relerp(this._typewriterStartTime,this._typewriterEndTime,t,0,this._typewriterLength);(e=Math.floor(e))!==this._spriteFontText.GetDrawMaxCharacterCount()&&(this._spriteFontText.SetDrawMaxCharacterCount(e),this._runtime.UpdateRender())}}GetDebuggerProperties(){const e="plugins.spritefont2";return[{title:e+".name",properties:[{name:e+".properties.text.name",value:this.GetText(),onedit:e=>this._SetText(e)},{name:e+".properties.scale.name",value:this._GetScale(),onedit:e=>this._SetScale(e)},{name:e+".properties.character-spacing.name",value:this._GetCharacterSpacing(),onedit:e=>this._SetCharacterSpacing(e)},{name:e+".properties.line-height.name",value:this._GetLineHeight(),onedit:e=>this._SetLineHeight(e)}]}]}GetScriptInterfaceClass(){return self.ISpriteFontInstance}},new WeakMap),J=new Map([["left",0],["center",1],["right",2]]),K=new Map([["top",0],["center",1],["bottom",2]]);self.ISpriteFontInstance=class extends self.IWorldInstance{constructor(){super(),I.set(this,self.IInstance._GetInitInst().GetSdkInstance())}get text(){return I.get(this).GetText()}set text(e){o.RequireString(e);const t=I.get(this);t._CancelTypewriter(),t._SetText(e)}typewriterText(e,t){o.RequireString(e),o.RequireFiniteNumber(t);const s=I.get(this);s._CancelTypewriter(),s._StartTypewriter(e,t)}typewriterFinish(){I.get(this)._FinishTypewriter()}set characterScale(e){o.RequireFiniteNumber(e),I.get(this)._SetScale(e)}get characterScale(){return I.get(this)._GetScale()}set characterSpacing(e){o.RequireFiniteNumber(e),I.get(this)._SetCharacterSpacing(e)}get characterSpacing(){return I.get(this)._GetCharacterSpacing()}set lineHeight(e){o.RequireFiniteNumber(e),I.get(this)._SetLineHeight(e)}get lineHeight(){return I.get(this)._GetLineHeight()}set horizontalAlign(e){o.RequireString(e);const t=J.get(e);if(void 0===t)throw new Error("invalid mode");I.get(this)._SetHAlign(t)}get horizontalAlign(){return F[I.get(this)._GetHAlign()]}set verticalAlign(e){o.RequireString(e);const t=K.get(e);if(void 0===t)throw new Error("invalid mode");I.get(this)._SetVAlign(t)}get verticalAlign(){return G[I.get(this)._GetVAlign()]}set wordWrapMode(e){if(!H.includes(e))throw new Error("invalid mode");I.get(this)._SetWrapMode(e)}get wordWrapMode(){return I.get(this)._GetWrapMode()}set readAloud(e){I.get(this)._SetReadAloud(!!e)}get readAloud(){return I.get(this)._IsReadAloud()}get textWidth(){return I.get(this)._GetTextWidth()}get textHeight(){return I.get(this)._GetTextHeight()}getTextSize(){const e=I.get(this);return[e._GetTextWidth(),e._GetTextHeight()]}hasTagAtPosition(e,t,s){return o.RequireString(e),o.RequireFiniteNumber(t),o.RequireFiniteNumber(s),I.get(this)._HasTagAtPosition(e,t,s)}getTagAtPosition(e,t){return o.RequireFiniteNumber(e),o.RequireFiniteNumber(t),I.get(this)._GetTagAtPosition(e,t)}getTagPositionAndSize(e,t=0){return o.RequireString(e),o.RequireFiniteNumber(t),I.get(this)._GetTagPosition(e,t)}getTagCount(e){return o.RequireString(e),I.get(this)._GetTagCount(e)}}}{const h0=self.C3;h0.Plugins.Spritefont2.Cnds={CompareText(e,t){return t?this._text===e:h0.equalsNoCase(this._text,e)},IsRunningTypewriterText(){return-1!==this._typewriterEndTime},OnTypewriterTextFinished(){return!0},HasTagAtPosition(e,t,s){return this._HasTagAtPosition(e,t,s)}}}{const n0=self.C3;n0.Plugins.Spritefont2.Acts={SetText(e){this._CancelTypewriter(),"number"==typeof e&&e<1e9&&(e=Math.round(1e10*e)/1e10),this._SetText(e.toString())},AppendText(e){this._CancelTypewriter(),(e=(e="number"==typeof e&&e<1e9?Math.round(1e10*e)/1e10:e).toString())&&this._SetText(this._text+e)},TypewriterText(e,t){this._CancelTypewriter(),"number"==typeof e&&e<1e9&&(e=Math.round(1e10*e)/1e10),this._StartTypewriter(e.toString(),t)},TypewriterFinish(){this._FinishTypewriter()},SetScale(e){this._SetScale(e)},SetCharacterSpacing(e){this._SetCharacterSpacing(e)},SetLineHeight(e){this._SetLineHeight(e)},SetCharacterWidth(e,t){let s=!1,i=this._sdkType.GetSpriteFont();for(const r of e)if(" "===r)i.SetSpaceWidth(t),s=!0;else{const n=i.GetCharacter(r);n&&(n.SetDisplayWidth(t),s=!0)}s&&i.SetCharacterWidthsChanged(),this._runtime.UpdateRender()},SetEffect(e){this.GetWorldInfo().SetBlendMode(e),this._runtime.UpdateRender()},SetHAlign(e){this._SetHAlign(e)},SetVAlign(e){this._SetVAlign(e)},SetWrapping(e){this._SetWrapModeByIndex(e)},SetReadAloud(e){this._SetReadAloud(e)}}}{const G0=self.C3;G0.Plugins.Spritefont2.Exps={CharacterWidth(e){const t=this._sdkType.GetSpriteFont().GetCharacter(e);return t?t.GetDisplayWidth():this._sdkType.GetSpriteFont().GetCharacterWidth()},CharacterHeight(){return this._characterHeight},CharacterScale(){return this._characterScale},CharacterSpacing(){return this._characterSpacing},LineHeight(){return this._lineHeight},Text(){return this._text},PlainText(){return this._enableBBcode?G0.BBString.StripAnyTags(this._text):this._text},TextWidth(){return this._GetTextWidth()},TextHeight(){return this._GetTextHeight()},TagAtPosition(e,t){return this._GetTagAtPosition(e,t)},TagCount(e){return this._GetTagCount(e)},TagX(e,t){const s=this._GetTagPosition(e,t);return s?s.x:0},TagY(e,t){const s=this._GetTagPosition(e,t);return s?s.y:0},TagWidth(e,t){const s=this._GetTagPosition(e,t);return s?s.width:0},TagHeight(e,t){const s=this._GetTagPosition(e,t);return s?s.height:0}}}{const C33=self.C3;self.SpriteFontCharacter=class{constructor(e,t,s,i){let r=e.GetCharacterWidth(),n=e.GetCharacterHeight();this._spriteFont=e,this._char=t,this._pxRect=new C33.Rect(s,i,s+r,i+n),this._texRect=new C33.Rect,this._displayWidth=-1,this._UpdateTexRect()}Release(){this._spriteFont=null,this._pxRect=null,this._texRect=null}_UpdateTexRect(){let e=this._spriteFont.GetWidth(),t=this._spriteFont.GetHeight();this._texRect.copy(this._pxRect),this._texRect.divide(e,t),this._texRect.lerpInto(this._spriteFont.GetTexRect())}GetSpriteFont(){return this._spriteFont}GetChar(){return this._char}GetTexRect(){return this._texRect}SetDisplayWidth(e){this._displayWidth=e}GetDisplayWidth(){return this._displayWidth<0?this._spriteFont.GetCharacterWidth():this._displayWidth}}}{let getOffsetParam2=function(e,t){e=e.trim();const s=parseFloat(e);return isFinite(s)?e.endsWith("%")?t*s/100:s:0},normalizeCssColorString2=function(e){return(canvasColorCtx=canvasColorCtx||C33.CreateCanvas(32,32).getContext("2d")).fillStyle="#FFFFFF",canvasColorCtx.fillStyle=e,canvasColorCtx.fillStyle},C33=(getOffsetParam=getOffsetParam2,normalizeCssColorString=normalizeCssColorString2,self.C3),tmpRect=new C33.Rect,tmpQuad=new C33.Quad,tmpColor=new C33.Color,VALID_HORIZ_ALIGNMENTS=new Set(["left","center","right"]),VALID_VERT_ALIGNMENTS=new Set(["top","center","bottom"]),VALID_WORD_WRAP_MODES=new Set(["word","cjk","character"]),canvasColorCtx=null;self.SpriteFontText=class{constructor(e){this._spriteFont=e,this._cssWidth=0,this._cssHeight=0,this._text="",this._isBBcodeEnabled=!1,this._bbString=null,this._wrappedText=C33.New(C33.WordWrap),this._wrapMode="word",this._wordWrapChanged=!1,this._textLayoutChanged=!1,this._horizontalAlign="left",this._verticalAlign="top",this._scale=1,this._sceneGraphScale=1,this._spacing=0,this._lineHeight=0,this._color=C33.New(C33.Color),this._drawMaxCharCount=-1,this._drawCharCount=0,this._measureTextCallback=e=>this._MeasureText(e),this._spriteFont._AddSpriteFontText(this)}Release(){this._spriteFont._RemoveSpriteFontText(this),this._color=null,this._measureTextCallback=null,this._wrappedText.Clear(),this._wrappedText=null,this._spriteFont=null,this._bbString=null}_MeasureText(e){if(e.IsIcon())return{width:0,height:0};const t=e.GetCharacterArray(),s=e.GetStyleTag("scale"),i=(s?parseFloat(s.param):this._scale)*this._sceneGraphScale,r=e.GetStyleTag("scalex"),n=(r?parseFloat(r.param):1)*i,a=e.GetStyleTag("scaley"),o=(a?parseFloat(a.param):1)*i,l=this._spriteFont.GetCharacterHeight()*o+this._lineHeight,h=this.GetSpriteFont(),c=h.GetCharacterWidth()*n,u=this.GetSpacing();if(h.HasAnyCustomWidths()){let s=0,i=0;for(const _ of t){let e=c,t=h.GetCharacter(_);t?e=t.GetDisplayWidth()*n:" "===_&&(e=h.GetSpaceWidth()*n),i+=e,++s}return{width:i+s*u,height:l}}{const d=t.length,p=Math.max(d,0);return{width:c*d+p*u,height:l}}}_SetTextLayoutChanged(){this._textLayoutChanged=!0}_SetWordWrapChanged(){this._SetTextLayoutChanged(),this._wordWrapChanged=!0,this._wrappedText.Clear()}SetSize(e,t){e<=0||t<=0||this._cssWidth===e&&this._cssHeight===t||(this._cssWidth!==e?this._SetWordWrapChanged():this._SetTextLayoutChanged(),this._cssWidth=e,this._cssHeight=t)}SetDrawMaxCharacterCount(e){this._drawMaxCharCount=Math.floor(e)}GetDrawMaxCharacterCount(){return this._drawMaxCharCount}HitTestFragment(e,t){this._UpdateTextMeasurements();const s=this._wrappedText.GetLines();for(const i of s)if(t>i.GetPosY()&&t<i.GetPosY()+i.GetHeight())for(const r of i.fragments())if(e>=r.GetPosX()&&e<r.GetPosX()+r.GetWidth())return r;return null}*fragmentsWithTag(e){this._UpdateTextMeasurements();const t=this._wrappedText.GetLines();for(const s of t)for(const i of s.fragments()){const r=i.GetStyleTag("tag");r&&C33.equalsNoCase(r.param,e)&&(yield i)}}FindFragmentWithTag(e,t){for(const s of this.fragmentsWithTag(e)){if(0===t)return s;--t}return null}CountFragmentsWithTag(e){let t=0;for(const s of this.fragmentsWithTag(e))++t;return t}_UpdateTextMeasurements(){this._UpdateWordWrap(),this._UpdateTextLayout()}_UpdateWordWrap(){if(this._wordWrapChanged){!this._isBBcodeEnabled||this._bbString&&this._bbString.toString()===this._text||(this._bbString=new C33.BBString(this._text,{noEscape:!0}));const e=-this.GetSpacing();this._wrappedText.WordWrap(this._isBBcodeEnabled?this._bbString.toFragmentList():this._text,this._measureTextCallback,this._cssWidth,this._wrapMode,e),this._wordWrapChanged=!1}}_UpdateTextLayout(){this._textLayoutChanged&&(this._LayoutText(),this._textLayoutChanged=!1)}_LayoutText(){let s=0,i=this._lineHeight,r=C33.cloneArray(this._wrappedText.GetLines());for(const t of r){t.SetPosX(NaN),t.SetPosY(NaN);for(const n of t.fragments())n.SetPosX(NaN),n.SetPosY(NaN)}const e=r.reduce((e,t)=>e+t.GetHeight(),0)-i;"center"===this._verticalAlign?s=Math.max(Math.floor(this._cssHeight/2-e/2),0):"bottom"===this._verticalAlign&&(s=Math.floor(this._cssHeight-e));for(let e=0,t=r.length;e<t;++e){const a=r[e],o=a.GetHeight();if(0<e&&s>this._cssHeight-(o-i))break;0<=s&&this._LayoutTextLine(a,s),s+=o}}_LayoutTextLine(e,t){let s=0;"center"===this._horizontalAlign?s=Math.max(Math.floor((this._cssWidth-e.GetWidth())/2),0):"right"===this._horizontalAlign&&(s=Math.max(Math.floor(this._cssWidth-e.GetWidth()),0)),e.SetPosX(s),e.SetPosY(t);for(const i of e.fragments())i.IsIcon()||(this._LayoutTextFragment(i,s,t),s+=i.GetWidth())}_LayoutTextFragment(e,t,s){const i=e.GetStyleTag("offsetx"),r=(t+=i?getOffsetParam2(i.param,e.GetHeight()):0,e.GetStyleTag("offsety"));s+=r?getOffsetParam2(r.param,e.GetHeight()):0,e.SetPosX(t),e.SetPosY(s)}Draw(e,t,s,i){this._UpdateTextMeasurements(),this._drawCharCount=0;const r=C33.cloneArray(this._wrappedText.GetLines()),n=Math.sin(i),a=Math.cos(i);for(const o of r)this._DrawLine(e,o,t,s,n,a)}_DrawLine(e,t,s,i,r,n){const a=t.GetPosX(),o=t.GetPosY();if(Number.isFinite(a)&&Number.isFinite(o)){const l=t.GetHeight();for(const h of t.fragments())this._DrawFragment(e,h,s,i,r,n,l)}}_DrawFragment(o,l,h,c,u,_,d){let p=l.GetPosX(),m=l.GetPosY();if(Number.isFinite(p)&&Number.isFinite(m)){let n=l.GetCharacterArray(),a=l.GetWidth();if(-1!==this._drawMaxCharCount){if(this._drawCharCount>=this._drawMaxCharCount)return;this._drawCharCount+n.length>this._drawMaxCharCount&&(n=n.slice(0,this._drawMaxCharCount-this._drawCharCount),a=this._MeasureText(l).width),this._drawCharCount+=n.length}const g=l.GetStyleTag("background");if(!(C33.IsCharArrayAllWhitespace(n)&&!g||l.HasStyleTag("hide"))){const f=l.GetStyleTag("scale"),S=(f?parseFloat(f.param):this._scale)*this._sceneGraphScale,C=l.GetStyleTag("scalex"),y=(C?parseFloat(C.param):1)*S,G=l.GetStyleTag("scaley"),I=(G?parseFloat(G.param):1)*S,T=this._spriteFont.GetCharacterHeight()*I,b=this._lineHeight;m+=d-b-T;let e=1,t=l.GetStyleTag("opacity"),s=(t&&(e=parseFloat(t.param)/100),g&&(o.SetColorFillMode(),tmpColor.parseString(normalizeCssColorString2(g.param)),tmpColor.setA(tmpColor.getA()*e*this._color.getA()),tmpColor.premultiply(),o.SetColor(tmpColor),tmpRect.set(p,m,p+a,m+T),tmpRect.getRight()>this._cssWidth&&tmpRect.setRight(this._cssWidth),tmpQuad.setFromRotatedRectPrecalc(tmpRect,u,_),tmpQuad.offset(h,c),o.Quad(tmpQuad),o.SetTextureFillMode()),l.GetStyleTag("color")),i=(s?(tmpColor.parseString(normalizeCssColorString2(s.param)),tmpColor.setA(this._color.getA())):tmpColor.copy(this._color),tmpColor.setA(tmpColor.getA()*e),tmpColor.premultiply(),o.SetColor(tmpColor),this._spriteFont.GetCharacterWidth()*y),r=Math.abs(this.GetSpacing());for(const A of n){const P=this._spriteFont.GetCharacter(A);if(P){const R=P.GetDisplayWidth()*y;if(p+R>this._cssWidth+r+1e-5)return;tmpRect.set(p,m,p+i,m+T),tmpQuad.setFromRotatedRectPrecalc(tmpRect,u,_),tmpQuad.offset(h,c),o.Quad3(tmpQuad,P.GetTexRect()),p+=R+this._spacing}else p+=this._spriteFont.GetSpaceWidth()*y+this._spacing}}}}GetSpriteFont(){return this._spriteFont}SetBBCodeEnabled(e){this._isBBcodeEnabled!==(e=!!e)&&(this._isBBcodeEnabled=e,this._SetWordWrapChanged())}IsBBCodeEnabled(){return this._isBBcodeEnabled}SetText(e){this._text!==e&&(this._text=e,this._SetWordWrapChanged())}SetWordWrapMode(e){if(!VALID_WORD_WRAP_MODES.has(e))throw new Error("invalid word wrap mode");this._wrapMode!==e&&(this._wrapMode=e,this._SetWordWrapChanged())}SetHorizontalAlign(e){if(!VALID_HORIZ_ALIGNMENTS.has(e))throw new Error("invalid alignment");this._horizontalAlign!==e&&(this._horizontalAlign=e,this._SetTextLayoutChanged())}SetVerticalAlign(e){if(!VALID_VERT_ALIGNMENTS.has(e))throw new Error("invalid alignment");this._verticalAlign!==e&&(this._verticalAlign=e,this._SetTextLayoutChanged())}SetScale(e){this._scale!==e&&(this._scale=e,this._SetWordWrapChanged())}GetScale(){return this._scale}SetSceneGraphScale(e){this._sceneGraphScale!==e&&(this._sceneGraphScale=e,this._SetWordWrapChanged())}GetSceneGraphScale(){return this._sceneGraphScale}SetSpacing(e){this._spacing!==e&&(this._spacing=e,this._SetWordWrapChanged())}GetSpacing(){return this._spacing}SetLineHeight(e){this._lineHeight=e,this._SetWordWrapChanged()}GetLineHeight(){return this._lineHeight}SetOpacity(e){e=C33.clamp(e,0,1),this._color.a=e}SetColor(e){this._color.equals(e)||this._color.copy(e)}GetColor(){return this._color}GetTextWidth(){return this._UpdateTextMeasurements(),this._wrappedText.GetMaxLineWidth()}GetTextHeight(){this._UpdateTextMeasurements();const e=this._spriteFont.GetCharacterHeight()*this._scale,t=this._lineHeight,s=e+t;return this._wrappedText.GetLineCount()*s-t}}}{const C33=self.C3,SpriteFontText=self.SpriteFontText,DEFAULT_SPRITEFONT_OPTS={width:256,height:256,characterWidth:16,characterHeight:16,characterSet:""};self.SpriteFont=class{constructor(e){if((e=Object.assign({},DEFAULT_SPRITEFONT_OPTS,e)).width<=0||e.height<=0||e.characterWidth<=0||e.characterHeight<=0)throw new Error("invalid size");this._width=e.width,this._height=e.height,this._characterWidth=e.characterWidth,this._characterHeight=e.characterHeight,this._characterSet=e.characterSet,this._spacingData="",this._spacingParsed=null,this._hasAnyCustomWidths=!1,this._spaceWidth=-1,this._texRect=new C33.Rect(0,0,1,1),this._characterMap=new Map,this._mapChanged=!0,this._allTexts=new Set}Release(){this._texRect=null,this._ReleaseCharacters(),this._characterMap=null,this._allTexts&&this._allTexts.clear(),this._allTexts=null}_ReleaseCharacters(){for(let e of this._characterMap.values())e.Release();this._characterMap.clear()}_AddSpriteFontText(e){this._allTexts.add(e)}_RemoveSpriteFontText(e){this._allTexts.delete(e)}UpdateCharacterMap(){if(this._mapChanged){this._ReleaseCharacters();let t=C33.SplitGraphemes(this._characterSet),r=Math.floor(this._width/this._characterWidth),e=Math.floor(this._height/this._characterHeight),s=r*e;for(let i=0,e=t.length;i<e&&!(i>=s);++i){let s=t[i];if(!this._characterMap.has(s)){let e=i%r,t=Math.floor(i/r);this._characterMap.set(s,C33.New(self.SpriteFontCharacter,this,s,e*this._characterWidth,t*this._characterHeight))}}if(this._hasAnyCustomWidths=!1,this._spaceWidth=-1,Array.isArray(this._spacingParsed))for(let t of this._spacingParsed)if(Array.isArray(t)&&2===t.length){let s=t[0],e=t[1];if("number"==typeof s&&isFinite(s)&&"string"==typeof e&&s!==this._characterWidth)for(let t of e){let e=this._characterMap.get(t);e?(e.SetDisplayWidth(s),this._hasAnyCustomWidths=!0):" "===t&&(this._spaceWidth=s,this._hasAnyCustomWidths=!0)}}this._mapChanged=!1;for(let e of this._allTexts)e._SetWordWrapChanged()}}SetCharacterWidthsChanged(){this._hasAnyCustomWidths=!0;for(const e of this._allTexts)e._SetWordWrapChanged()}GetCharacter(e){return this.UpdateCharacterMap(),this._characterMap.get(e)||null}HasAnyCustomWidths(){return this._hasAnyCustomWidths}SetWidth(e){if((e=Math.floor(e))<=0)throw new Error("invalid size");this._width!==e&&(this._width=e,this._mapChanged=!0)}GetWidth(){return this._width}SetHeight(e){if((e=Math.floor(e))<=0)throw new Error("invalid size");this._height!==e&&(this._height=e,this._mapChanged=!0)}GetHeight(){return this._height}SetTexRect(e){if(!this._texRect.equals(e)){this._texRect.copy(e);for(const t of this._characterMap.values())t._UpdateTexRect()}}GetTexRect(){return this._texRect}SetCharacterWidth(e){if((e=Math.floor(e))<=0)throw new Error("invalid size");this._characterWidth!==e&&(this._characterWidth=e,this._mapChanged=!0)}GetCharacterWidth(){return this._characterWidth}SetCharacterHeight(e){if((e=Math.floor(e))<=0)throw new Error("invalid size");this._characterHeight!==e&&(this._characterHeight=e,this._mapChanged=!0)}GetCharacterHeight(){return this._characterHeight}SetCharacterSet(e){this._characterSet!==e&&(this._characterSet=e,this._mapChanged=!0)}GetCharacterSet(){return this._characterSet}SetSpacingData(e){if(this._spacingData!==e&&(this._spacingData=e,this._mapChanged=!0,this._spacingParsed=null,this._spacingData.length))try{this._spacingParsed=JSON.parse(this._spacingData)}catch(e){this._spacingParsed=null}}GetSpacingData(){return this._spacingData}SetSpaceWidth(e){this._spaceWidth!==(e=e<0?-1:e)&&(this._spaceWidth=e,0<=this._spaceWidth)&&(this._hasAnyCustomWidths=!0)}GetSpaceWidth(){return this._spaceWidth<0?this._characterWidth:this._spaceWidth}}}{const a=self.C3;a.Plugins.NinePatch=class extends a.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{const d=self.C3;d.Plugins.NinePatch.Type=class extends d.SDKTypeBase{constructor(e){super(e),this._textureSet=null,this._drawable=null}Release(){this.ReleaseTextures(),super.Release()}OnCreate(){this.GetImageInfo().LoadAsset(this._runtime)}async LoadTextures(e){const t=this.GetImageInfo();this._drawable=await t.ExtractImageToCanvas()}CreatePatch(e,t,s,i){!this._textureSet&&this._drawable&&(this._textureSet=new self.NinePatchTextureSet(this),this._textureSet.CreateTextures(this._drawable,e,t,s,i))}ReleaseTextures(){this._textureSet&&(this._textureSet.Release(),this._textureSet=null)}GetTextureSet(){return this._textureSet}}}{const m=self.C3,n=0,o=1,p=2,q=3,r=4,s=5,t=6,u=7,v=8,w=m.New(m.Rect),x=m.New(m.Rect),y=m.New(m.Quad);m.Plugins.NinePatch.Instance=class extends m.SDKWorldInstanceBase{constructor(e,i){super(e),this._leftMargin=16,this._rightMargin=16,this._topMargin=16,this._bottomMargin=16,this._edges=1,this._fill=1,this._isSeamless=!0,this._callback3d=null,i&&(this._leftMargin=i[n],this._rightMargin=i[o],this._topMargin=i[p],this._bottomMargin=i[q],this._edges=i[r],this._fill=i[s],this._isSeamless=!!i[v],this.GetWorldInfo().SetVisible(!!i[t])),this._sdkType.CreatePatch(this._leftMargin,this._rightMargin,this._topMargin,this._bottomMargin)}Release(){super.Release()}_Set3DCallback(e){this._callback3d=e}Draw(e){const t=this.GetWorldInfo(),s=t.GetBoundingQuad();this._Draw(e,s.getTlx(),s.getTly(),t.GetWidth(),t.GetHeight())}_Draw(e,t,s,i,r){let n=this._sdkType.GetTextureSet();if(n||(this._sdkType.CreatePatch(this._leftMargin,this._rightMargin,this._topMargin,this._bottomMargin),n=this._sdkType.GetTextureSet())){const a=n.GetImageWidth(),o=n.GetImageHeight(),l=Math.min(this._leftMargin,a),h=Math.min(this._rightMargin,a),c=Math.min(this._topMargin,o),u=Math.min(this._bottomMargin,o),_=a-h,d=o-u,p=this._isSeamless?1:0,m=this._edges,g=this._fill;if(0<l&&0<c&&this._DrawPatch(e,n.GetTexture(),0,0,l+p,c+p,t,s,l+p,c+p),0<h&&0<c&&this._DrawPatch(e,n.GetTexture(),_-p,0,h+p,c+p,t+i-h-p,s,h+p,c+p),0<h&&0<u&&this._DrawPatch(e,n.GetTexture(),_-p,d-p,h+p,u+p,t+i-h-p,s+r-u-p,h+p,u+p),0<l&&0<u&&this._DrawPatch(e,n.GetTexture(),0,d-p,l+p,u+p,t,s+r-u-p,l+p,u+p),0===m){const f=2===g?0:p;0<l&&c<d&&this._TilePatch(e,n.GetLeftTexture(),t,s+c,l+f,r-c-u,0,0),0<h&&c<d&&this._TilePatch(e,n.GetRightTexture(),t+i-h-f,s+c,h+f,r-c-u,f,0),0<c&&l<_&&this._TilePatch(e,n.GetTopTexture(),t+l,s,i-l-h,c+f,0,0),0<u&&l<_&&this._TilePatch(e,n.GetBottomTexture(),t+l,s+r-u-f,i-l-h,u+f,0,f)}else 1===m&&(0<l&&c<d&&this._DrawPatch(e,n.GetTexture(),0,c,l,d-c,t,s+c,l,r-c-u),0<h&&c<d&&this._DrawPatch(e,n.GetTexture(),_,c,h,d-c,t+i-h,s+c,h,r-c-u),0<c&&l<_&&this._DrawPatch(e,n.GetTexture(),l,0,_-l,c,t+l,s,i-l-h,c),0<u)&&l<_&&this._DrawPatch(e,n.GetTexture(),l,d,_-l,u,t+l,s+r-u,i-l-h,u);c<d&&l<_&&(0===g?this._TilePatch(e,n.GetFillTexture(),t+l,s+c,i-l-h,r-c-u,0,0):1===g&&this._DrawPatch(e,n.GetTexture(),l,c,_-l,d-c,t+l,s+c,i-l-h,r-c-u))}}_DrawPatch(e,t,s,i,r,n,a,o,l,h){const c=t.GetWidth(),u=t.GetHeight();if(e.SetTexture(t),w.set(a,o,a+l,o+h),x.set(s/c,i/u,(s+r)/c,(i+n)/u),null===this._callback3d){const _=this.GetWorldInfo(),d=_.GetBoundingQuad(),p=d.getTlx(),m=d.getTly();w.offset(-p,-m),y.setFromRotatedRect(w,_.GetAngle()),y.offset(p,m),e.Quad3(y,x)}else this._callback3d(w,x)}_TilePatch(e,t,s,i,r,n,a,o){const l=t.GetWidth(),h=t.GetHeight();if(e.SetTexture(t),w.set(s,i,s+r,i+n),x.set(-a/l,-o/h,(r-a)/l,(n-o)/h),null===this._callback3d){const c=this.GetWorldInfo(),u=c.GetBoundingQuad(),_=u.getTlx(),d=u.getTly();w.offset(-_,-d),y.setFromRotatedRect(w,c.GetAngle()),y.offset(_,d),e.Quad3(y,x)}else this._callback3d(w,x)}GetCurrentImageInfo(){this._objectClass.GetImageInfo()}GetPropertyValueByIndex(e){}SetPropertyValueByIndex(e,t){}}}{const Da=self.C3;Da.Plugins.NinePatch.Cnds={}}{const Ea=self.C3;Ea.Plugins.NinePatch.Acts={SetEffect(e){this.GetWorldInfo().SetBlendMode(e),this._runtime.UpdateRender()}}}{const Ga=self.C3;Ga.Plugins.NinePatch.Exps={}}{let CloneDrawable2=function(e){const t=C33.CreateCanvas(e.width,e.height),s=t.getContext("2d");return s.drawImage(e,0,0),t};CloneDrawable=CloneDrawable2;const C33=self.C3;self.NinePatchTextureSet=class{constructor(e){this._sdkType=e,this._runtime=this._sdkType.GetRuntime(),this._texture=null,this._fillTexture=null,this._leftTexture=null,this._rightTexture=null,this._topTexture=null,this._bottomTexture=null,this._imageWidth=0,this._imageHeight=0,this._renderer=this._runtime.GetRenderer(),this._isLoading=!1,this._wasReleased=!1}Release(){this._renderer.IsContextLost()||(this._renderer.DeleteTexture(this._texture),this._renderer.DeleteTexture(this._fillTexture),this._renderer.DeleteTexture(this._leftTexture),this._renderer.DeleteTexture(this._rightTexture),this._renderer.DeleteTexture(this._topTexture),this._renderer.DeleteTexture(this._bottomTexture)),this._texture=null,this._fillTexture=null,this._leftTexture=null,this._rightTexture=null,this._topTexture=null,this._bottomTexture=null,this._sdkType=null,this._renderer=null,this._wasReleased=!0}WasReleased(){return this._wasReleased}CreateTextures(e,t,s,i,r){this._SliceImage(e,t,s,i,r)}HasCreatedTextures(){return!!this._texture}_SliceImage(e,t,s,i,r){if(!this._wasReleased){const n=e.width,a=e.height,o=(this._imageWidth=n,this._imageHeight=a,t=Math.min(Math.floor(t),n),s=Math.min(Math.floor(s),n),i=Math.min(Math.floor(i),a),n-s),l=a-(r=Math.min(Math.floor(r),a)),h=this._runtime.GetSampling(),c=this._runtime.GetCanvasManager().GetTextureAnisotropy();this._texture=this._renderer.CreateStaticTexture(CloneDrawable2(e),{sampling:h,anisotropy:c}),t<o&&i<l&&(this._fillTexture=this._renderer.CreateStaticTexture(this._SliceSubImage(CloneDrawable2(e),t,i,o,l),{wrapX:"repeat",wrapY:"repeat",sampling:h,anisotropy:c})),0<t&&i<l&&(this._leftTexture=this._renderer.CreateStaticTexture(this._SliceSubImage(CloneDrawable2(e),0,i,t,l),{wrapY:"repeat",sampling:h,anisotropy:c})),0<s&&i<l&&(this._rightTexture=this._renderer.CreateStaticTexture(this._SliceSubImage(CloneDrawable2(e),o,i,n,l),{wrapY:"repeat",sampling:h,anisotropy:c})),0<i&&t<o&&(this._topTexture=this._renderer.CreateStaticTexture(this._SliceSubImage(CloneDrawable2(e),t,0,o,i),{wrapX:"repeat",sampling:h,anisotropy:c})),0<r&&t<o&&(this._bottomTexture=this._renderer.CreateStaticTexture(this._SliceSubImage(CloneDrawable2(e),t,l,o,a),{wrapX:"repeat",sampling:h,anisotropy:c}))}}_SliceSubImage(e,t,s,i,r){const n=i-t,a=r-s,o=C33.CreateCanvas(n,a),l=o.getContext("2d");return l.drawImage(e,t,s,n,a,0,0,n,a),o}GetImageWidth(){return this._imageWidth}GetImageHeight(){return this._imageHeight}GetTexture(){return this._texture}GetFillTexture(){return this._fillTexture}GetLeftTexture(){return this._leftTexture}GetRightTexture(){return this._rightTexture}GetTopTexture(){return this._topTexture}GetBottomTexture(){return this._bottomTexture}}}{const a=self.C3;a.Plugins.AJAX=class extends a.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{const d=self.C3;d.Plugins.AJAX.Type=class extends d.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const g=self.C3;g.Plugins.AJAX.Instance=class extends g.SDKInstanceBase{constructor(e,t){if(super(e),this._lastData="",this._lastStatusCode=0,this._curTag="",this._progress=0,this._timeout=-1,this._nextRequestHeaders=new Map,this._nextReponseBinaryData=null,this._nextRequestOverrideMimeType="",this._nextRequestWithCredentials=!1,this._nwjsFs=null,this._nwjsPath=null,this._nwjsAppFolder=null,this._isNWjs=this._runtime.IsNWjs(),this._isNWjs){this._nwjsFs=__require("fs"),this._nwjsPath=__require("path");const s=self.process||nw.process;this._nwjsAppFolder=this._nwjsPath.dirname(s.execPath)+"\\"}}Release(){super.Release()}async _TriggerError(e,t,s){console.error(`[Construct] AJAX request to '${t}' (tag '${e}') failed: `,s),this._curTag=e,await this.TriggerAsync(g.Plugins.AJAX.Cnds.OnAnyError),this._curTag=e,await this.TriggerAsync(g.Plugins.AJAX.Cnds.OnError)}async _TriggerComplete(e){this._curTag=e,await this.TriggerAsync(g.Plugins.AJAX.Cnds.OnAnyComplete),this._curTag=e,await this.TriggerAsync(g.Plugins.AJAX.Cnds.OnComplete)}async _OnProgress(e,t){t.lengthComputable&&(this._progress=t.loaded/t.total,this._curTag=e,await this.TriggerAsync(g.Plugins.AJAX.Cnds.OnProgress))}async _OnUploadProgress(e,t){t.lengthComputable&&(this._progress=t.loaded/t.total,this._curTag=e,await this.TriggerAsync(g.Plugins.AJAX.Cnds.OnUploadProgress))}_OnError(s,i,e){if(this._isNWjs){const t=this._nwjsFs,r=this._nwjsAppFolder+i;t.existsSync(r)?t.readFile(r,{encoding:"utf8"},(e,t)=>{e?this._TriggerError(s,i,e):(this._lastData=t.replace(/\r\n/g,"\n"),this._TriggerComplete(s))}):this._TriggerError(s,i,e)}else this._TriggerError(s,i,e)}async _DoCordovaRequest(t,s){const e=this._runtime.GetAssetManager(),i=this._nextReponseBinaryData;this._nextReponseBinaryData=null;try{if(i){const r=await e.CordovaFetchLocalFileAsArrayBuffer(s);i.SetArrayBufferTransfer(r),this._lastData=""}else{const n=await e.CordovaFetchLocalFileAsText(s);this._lastData=n.replace(/\r\n/g,"\n")}this._lastStatusCode=0,this._TriggerComplete(t)}catch(e){this._TriggerError(t,s,e)}}_DoRequest(o,l,e,h){return new Promise(t=>{const s=e=>{this._OnError(o,l,e),t()},i=this._nextReponseBinaryData;this._nextReponseBinaryData=null;try{const r=new XMLHttpRequest;r.onreadystatechange=()=>{if(4===r.readyState){if(i?this._lastData="":this._lastData=(r.responseText||"").replace(/\r\n/g,"\n"),this._lastStatusCode=r.status,400<=r.status)this._TriggerError(o,l,r.status+r.statusText);else{const e=this._lastData.length||i&&r.response instanceof ArrayBuffer;this._isNWjs&&!e||!this._isNWjs&&0===r.status&&!e||(i&&i.SetArrayBufferTransfer(r.response),this._TriggerComplete(o))}t()}},r.onerror=s,r.ontimeout=s,r.onabort=s,r.onprogress=e=>this._OnProgress(o,e),r.upload.onprogress=e=>this._OnUploadProgress(o,e),r.open(e,l),0<=this._timeout&&void 0!==r.timeout&&(r.timeout=this._timeout),r.responseType=i?"arraybuffer":"text",h&&!this._nextRequestHeaders.has("Content-Type")&&("string"!=typeof h?r.setRequestHeader("Content-Type","application/octet-stream"):r.setRequestHeader("Content-Type","application/x-www-form-urlencoded"));for(const[n,a]of this._nextRequestHeaders)try{r.setRequestHeader(n,a)}catch(e){console.error(`[Construct] AJAX: Failed to set header '${n}: ${a}': `,e)}if(this._nextRequestHeaders.clear(),this._nextRequestOverrideMimeType){try{r.overrideMimeType(this._nextRequestOverrideMimeType)}catch(e){console.error("[Construct] AJAX: failed to override MIME type: ",e)}this._nextRequestOverrideMimeType=""}this._nextRequestWithCredentials&&(r.withCredentials=!0,this._nextRequestWithCredentials=!1),h?r.send(h):r.send()}catch(e){s(e)}})}GetDebuggerProperties(){const e="plugins.ajax.debugger";return[{title:e+".title",properties:[{name:e+".last-status-code",value:this._lastStatusCode},{name:e+".last-data",value:this._lastData}]}]}SaveToJson(){return{lastData:this._lastData,lastStatusCode:this._lastStatusCode}}LoadFromJson(e){this._lastData=e.lastData,this._lastStatusCode=e.hasOwnProperty("lastStatusCode")?e.lastStatusCode:0,this._curTag="",this._progress=0}}}{const $=self.C3;$.Plugins.AJAX.Cnds={OnComplete(e){return $.equalsNoCase(this._curTag,e)},OnAnyComplete(){return!0},OnError(e){return $.equalsNoCase(this._curTag,e)},OnAnyError(){return!0},OnProgress(e){return $.equalsNoCase(this._curTag,e)},OnUploadProgress(e){return $.equalsNoCase(this._curTag,e)}}}{const da=self.C3;da.Plugins.AJAX.Acts={async Request(e,t){this._runtime.IsCordova()&&da.IsRelativeURL(t)&&this._runtime.GetAssetManager().IsFileProtocol()?await this._DoCordovaRequest(e,t):await this._DoRequest(e,t,"GET",null)},async RequestFile(e,t){this._runtime.IsCordova()&&this._runtime.GetAssetManager().IsFileProtocol()?await this._DoCordovaRequest(e,t):await this._DoRequest(e,t,"GET",null)},async Post(e,t,s,i){await this._DoRequest(e,t,i,s)},async PostBinary(e,t,s,i){if(s){const r=s.GetFirstPicked(this._inst);if(r){const n=r.GetSdkInstance(),a=n.GetArrayBufferReadOnly();await this._DoRequest(e,t,i,a)}}},SetTimeout(e){this._timeout=1e3*e},SetHeader(e,t){this._nextRequestHeaders.set(e,t)},SetResponseBinary(e){if(e){const t=e.GetFirstPicked(this._inst);t&&(this._nextReponseBinaryData=t.GetSdkInstance())}},OverrideMIMEType(e){this._nextRequestOverrideMimeType=e},SetWithCredentials(e){this._nextRequestWithCredentials=!!e}}}{const Aa=self.C3;Aa.Plugins.AJAX.Exps={LastData(){return this._lastData},LastStatusCode(){return this._lastStatusCode},Progress(){return this._progress},Tag(){return this._curTag}}}{const a=self.C3;a.Plugins.Json=class extends a.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{const d=self.C3;d.Plugins.Json.Type=class extends d.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const g=self.C3,h=self.C3X,i=self.IInstance,j=(g.Plugins.Json.Instance=class extends g.SDKInstanceBase{constructor(e,t){super(e),this._valueCache=[null,null],this._locationCache=[null,null],this._data={},this._path=[],this._currentKey="",this._currentValue=0}Release(){super.Release()}_InvalidateValueCache(){this._valueCache[0]=null,this._valueCache[1]=null}_HasValueCache(s,e){const i=this._valueCache[0];if(null!==s&&null!==i){if(i===s||g.arraysEqual(i,s))return!0;if(e&&0<i.length){for(let e=0,t=Math.min(s.length,i.length);e<t;++e)if(s[e]!==i[e])return!1;return!0}}return!1}_GetValueCache(){return this._valueCache[1]}_UpdateValueCache(e,t){this._valueCache[0]=e,this._valueCache[1]=t}_InvalidateLocationCache(){this._locationCache[0]=null,this._locationCache[1]=null}_HasLocationCache(e){return this._locationCache[0]===e}_GetLocationCache(){return this._locationCache[1]}_UpdateLocationCache(e,t){this._locationCache[0]=e,this._locationCache[1]=t}_SetData(e){this._data=e,this._InvalidateValueCache(),this._SetPath("")}_GetData(){return this._data}_SetPath(e){this._path=this._ParsePathUnsafe(e),this._InvalidateLocationCache()}_ParsePath(e){return g.cloneArray(this._ParsePathUnsafe(e))}_ParsePathUnsafe(e){let t=[],s=!1,i;if(this._HasLocationCache(e))return this._GetLocationCache();"."===e[0]?(i=g.cloneArray(this._path),e=e.slice(1)):i=[];for(const r of e)s?(t.push(r),s=!1):"\\"===r?s=!0:"."===r?(i.push(t.join("")),g.clearArray(t)):t.push(r);return 0!==t.length&&i.push(t.join("")),this._UpdateLocationCache(e,i),i}_GetValueAtFullPath(e,t){if(this._HasValueCache(e,!1))return this._GetValueCache();let s=this._data;for(const i of e)if(Array.isArray(s)){const r=parseInt(i,10);if(r<0||r>=s.length||!isFinite(r)){s=null;break}s=s[r]}else{if("object"!=typeof s||null===s){s=null;break}if(s.hasOwnProperty(i))s=s[i];else{if(!t){s=null;break}{const n={};s[i]=n,s=n}}}return this._UpdateValueCache(e,s),s}_GetValue(e){const t=this._ParsePath(e);if(!t.length)return this._data;const s=t.pop(),i=this._GetValueAtFullPath(t,!1);if(Array.isArray(i)){const r=parseInt(s,10);return 0<=r&&r<i.length?i[r]:null}return"object"==typeof i&&null!==i&&i.hasOwnProperty(s)?i[s]:null}_JSONTypeOf(e){return null===e?"null":Array.isArray(e)?"array":typeof e}_GetTypeOf(e){const t=this._GetValue(e);return this._JSONTypeOf(t)}_ToSafeValue(e){const t=typeof e;return"number"==t||"string"==t?e:"boolean"==t&&e?1:0}_GetSafeValue(e){return this._ToSafeValue(this._GetValue(e))}_HasKey(e){const t=this._ParsePath(e);if(!t.length)return!1;const s=t.pop(),i=this._GetValueAtFullPath(t,!1);if(Array.isArray(i)){const r=parseInt(s,10);return 0<=r&&r<i.length}return"object"==typeof i&&null!==i&&i.hasOwnProperty(s)}_SetValue(e,t){const s=this._ParsePath(e);if(!s.length)return!1;this._HasValueCache(s,!0)&&this._InvalidateValueCache();const i=s.pop(),r=this._GetValueAtFullPath(s,!0);if(Array.isArray(r)){const n=parseInt(i,10);return!(!isFinite(n)||n<0||n>=r.length||(r[n]=t,0))}return"object"==typeof r&&null!==r&&(r[i]=t,!0)}_DeleteKey(e){const t=this._ParsePath(e);if(!t.length)return!1;this._HasValueCache(t,!0)&&this._InvalidateValueCache();const s=t.pop(),i=this._GetValueAtFullPath(t,!1);return!Array.isArray(i)&&"object"==typeof i&&null!==i&&(delete i[s],!0)}SaveToJson(){return{path:this._path,data:this._data}}LoadFromJson(e){this._InvalidateValueCache(),this._InvalidateLocationCache(),this._path=e.path,this._data=e.data}_SanitizeValue(e){const t=typeof e;return"number"==t?isFinite(e)?e:0:"object"==typeof e?JSON.stringify(e):e+""}GetDebuggerProperties(){let e="plugins.json.debugger",t;try{t=this._SanitizeValue(this._data)}catch(e){t='"invalid"'}return[{title:e+".title",properties:[{name:e+".data",value:t,onedit:e=>{try{const t=JSON.parse(e);this._SetData(t)}catch(e){}}},{name:e+".path",value:this._path.map(e=>e.replace(/\./g,"\\.")).join(".")}]}]}GetScriptInterfaceClass(){return self.IJSONInstance}},new WeakMap);self.IJSONInstance=class extends i{constructor(){super(),j.set(this,i._GetInitInst().GetSdkInstance())}getJsonDataCopy(){const e=j.get(this)._GetData();return JSON.parse(JSON.stringify(e))}setJsonDataCopy(e){try{const t=JSON.parse(JSON.stringify(e));j.get(this)._SetData(t)}catch(e){throw console.error("[JSON plugin] setJsonData: object is not valid JSON: ",e),e}}setJsonString(e){h.RequireString(e);try{const t=JSON.parse(e);j.get(this)._SetData(t)}catch(e){throw console.error("[JSON plugin] setJsonString: string is not valid JSON: ",e),e}}toCompactString(){return JSON.stringify(j.get(this)._GetData())}toBeautifiedString(){return JSON.stringify(j.get(this)._GetData(),null,4)}}}{const Ba=self.C3,Ca=["null","boolean","number","string","object","array"];Ba.Plugins.Json.Cnds={HasKey(e){return this._HasKey(e)},CompareType(e,t){return this._GetTypeOf(e)===Ca[t]},CompareValue(e,t,s){return Ba.compare(this._GetSafeValue(e),t,s)},IsBooleanSet(e){return!0===this._GetValue(e)},ForEach(e){const t=this._GetValue(e);if("object"==typeof t&&null!==t){const s=this._runtime,i=s.GetEventSheetManager(),r=s.GetCurrentEvent(),n=r.GetSolModifiers(),a=s.GetEventStack(),o=a.GetCurrentStackFrame(),l=a.Push(r),h=this._path,c=this._currentKey,u=this._currentValue,_=this._ParsePathUnsafe(e);s.SetDebuggingEnabled(!1);for(const[d,p]of Object.entries(t)){this._path=Ba.cloneArray(_),this._path.push(d),this._currentKey=d,this._currentValue=p,i.PushCopySol(n);const m=this.GetObjectClass().GetCurrentSol();m.PickOne(this.GetInstance()),r.Retrigger(o,l),i.PopSol(n)}s.SetDebuggingEnabled(!0),this._path=h,this._InvalidateLocationCache(),this._currentKey=c,this._currentValue=u,a.Pop()}return!1},OnParseError(){return!0},OnParseSuccess(){return!0}}}{const $a=self.C3;$a.Plugins.Json.Acts={Parse(e){try{this._SetData(JSON.parse(e)),this.Trigger($a.Plugins.Json.Cnds.OnParseSuccess)}catch(e){console.warn("[JSON plugin] Failed to parse JSON data: ",e),this._SetData({}),this.Trigger($a.Plugins.Json.Cnds.OnParseError)}},SetPath(e){this._SetPath(e)},SetValue(e,t){this._SetValue(e,t)},SetArray(e,t){let s=this._GetValue(e);Array.isArray(s)?$a.resizeArray(s,t,0):(s=[],$a.extendArray(s,t,0),this._SetValue(e,s))},SetObject(e){this._SetValue(e,{})},SetJSON(e,t){let s=null;try{s=JSON.parse(t),this.Trigger($a.Plugins.Json.Cnds.OnParseSuccess)}catch(e){console.warn("[JSON plugin] Failed to parse JSON data: ",e),this.Trigger($a.Plugins.Json.Cnds.OnParseError)}this._SetValue(e,s)},SetNull(e){this._SetValue(e,null)},SetBoolean(e,t){this._SetValue(e,0!==t)},ToggleBoolean(e){const t=this._GetValue(e);"boolean"==typeof t&&this._SetValue(e,!t)},AddTo(e,t){const s=this._GetValue(e);"number"==typeof s&&this._SetValue(e,s+t)},SubtractFrom(e,t){const s=this._GetValue(e);"number"==typeof s&&this._SetValue(e,s-t)},DeleteKey(e){this._DeleteKey(e)},PushValue(e,t,s){const i=this._GetValue(t);Array.isArray(i)&&(0===e?i.push(s):i.unshift(s),this._InvalidateValueCache())},PopValue(e,t){const s=this._GetValue(t);Array.isArray(s)&&(0===e?s.pop():s.shift(),this._InvalidateValueCache())},InsertValue(e,t,s){const i=this._GetValue(t);Array.isArray(i)&&(i.splice(s,0,e),this._InvalidateValueCache())},RemoveValues(e,t,s){const i=this._GetValue(t);Array.isArray(i)&&0<e&&(i.splice(s,e),this._InvalidateValueCache())}}}{const N0=self.C3;N0.Plugins.Json.Exps={ToCompactString(){try{return JSON.stringify(this._data)}catch(e){return""}},ToBeautifiedString(){try{return JSON.stringify(this._data,null,4)}catch(e){return""}},Get(e){return this._GetSafeValue(e)},GetAsCompactString(e){const t=this._GetValue(e);return JSON.stringify(t)},GetAsBeautifiedString(e){const t=this._GetValue(e);return JSON.stringify(t,null,4)},Front(e){const t=this._GetValue(e);if(Array.isArray(t)){const s=t[0];return this._ToSafeValue(s)}return-1},Back(e){const t=this._GetValue(e);if(Array.isArray(t)){const s=t.at(-1);return this._ToSafeValue(s)}return-1},Type(e){return this._GetTypeOf(e)},ArraySize(e){const t=this._GetValue(e);return Array.isArray(t)?t.length:-1},Path(){return this._path.map(e=>e.replace(/\./g,"\\.")).join(".")},CurrentKey(){return this._currentKey},CurrentValue(){return this._ToSafeValue(this._currentValue)},CurrentType(){return this._JSONTypeOf(this._currentValue)}}}{const a=self.C3;a.Plugins.Particles=class extends a.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{const d=self.C3;d.Plugins.Particles.Type=class extends d.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){this.GetImageInfo().LoadAsset(this._runtime)}LoadTextures(e){return this.GetImageInfo().LoadStaticTexture(e,{sampling:this._runtime.GetSampling()})}ReleaseTextures(){this.GetImageInfo().ReleaseTexture()}}}{let GetParticleEngine2=function(e){return H.get(e).GetParticleEngine()};GetParticleEngine=GetParticleEngine2;const h=self.C3,i=self.C3X,j=0,k=1,l=2,m=3,n=4,o=5,p=6,q=7,r=8,s=9,t=10,u=11,v=12,w=13,x=14,y=15,z=16,A=17,B=18,C=19,D=20,E=0,F=1,G=h.New(h.Rect),H=(h.Plugins.Particles.Instance=class extends h.SDKWorldInstanceBase{constructor(e,i){super(e),this._isFirstTick=!0;const a=h.New(self.ParticleEngine);(this._particleEngine=a).ononeshotfinish=()=>this._OnOneShotFinish(),this._spawnObjectClass=null,this._particleUpdateCallback=(e,t,s,i,r,n)=>this._OnParticleUpdate(e,t,s,i,r,n),this._particleDestroyCallback=e=>this._OnParticleDestroy(e);let c=this._hasAnyDefaultParticle=!0;i&&(a.SetRate(i[j]),a.SetSprayCone(h.toRadians(i[k])),a.SetSprayType(i[l]?"one-shot":"continuous-spray"),this._SetParticleObjectClass(this._runtime.GetObjectClassBySID(i[m])),c=i[n],a.SetInitSpeed(i[o]),a.SetInitSize(i[p]),a.SetInitOpacity(i[q]/100),a.SetGrowRate(i[r]),a.SetInitXRandom(i[s]),a.SetInitYRandom(i[t]),a.SetInitSpeedRandom(i[u]),a.SetInitSizeRandom(i[v]),a.SetGrowRandom(i[w]),a.SetAcceleration(i[x]),a.SetGravity(i[y]),a.SetLifeAngleRandom(i[z]),a.SetLifeSpeedRandom(i[A]),a.SetLifeOpacityRandom(i[B]),a.SetDestroyModeIndex(i[C]),a.SetTimeout(i[D])),this._UpdateEngineParameters(),this._spawnObjectClass&&(this._hasAnyDefaultParticle=!1),"one-shot"===a.GetSprayType()?a.CreateOneShotSpray():a.SetSpraying(!0);const _=this.GetWorldInfo();_.SetVisible(c),_.SetBboxChangeEventEnabled(!0),this._inst.Dispatcher().addEventListener("bboxchange",()=>{_.OverwriteBoundingBox(this._particleEngine.GetBoundingBox())}),this.GetRuntime().GetRenderer().IsWebGPU()&&_.SetUsePointsShaderProgram(),this._afterLoad=e=>this._OnAfterLoad(e),this.GetRuntime().Dispatcher().addEventListener("afterload",this._afterLoad),this._StartTicking()}Release(){this.GetRuntime().Dispatcher().removeEventListener("afterload",this._afterLoad),this._afterLoad=null,this._particleEngine.Release(),this._particleEngine=null,this._particleUpdateCallback=null,this._particleDestroyCallback=null,super.Release()}GetParticleEngine(){return this._particleEngine}_SetRate(e){this._particleEngine.SetRate(e),"one-shot"===this._particleEngine.GetSprayType()&&this._isFirstTick&&this._particleEngine.SetParticleCount(e)}_SetParticleObjectClass(e){(e=e===this.GetObjectClass()?null:e)===this._spawnObjectClass||(this._spawnObjectClass=e,this._particleEngine.onparticlecreate=e?e=>this._OnParticleCreate(e):null,this._spawnObjectClass)||(this._hasAnyDefaultParticle=!0)}_UpdateEngineParameters(){const e=this._particleEngine,t=this.GetWorldInfo();e.SetMasterOpacity(t.GetOpacity()),e.SetPixelRounding(this._runtime.IsPixelRoundingEnabled()),e.SetSpawnX(t.GetX()),e.SetSpawnY(t.GetY()),e.SetSpawnAngle(t.GetAngle()),e.SetInitSizeScale(Math.abs(t.GetSceneGraphScale()))}_OnOneShotFinish(){this._runtime.DestroyInstance(this._inst)}Draw(e){if(this._hasAnyDefaultParticle){const t=this._objectClass.GetImageInfo(),s=t.GetTexture();if(s){const i=this.GetWorldInfo(),r=i.GetLayer(),n=G,a=(this._runtime.GetCanvasManager().IsPastingToDrawingCanvas()?n.set(-1/0,-1/0,1/0,1/0):r.Has3DCamera()?r.CalculateViewport3D(i.GetTotalZElevation(),n):r.GetViewportForZ(i.GetTotalZElevation(),n),e.SetTexture(s),r.Get2DScaleFactorToZ(i.GetTotalZElevation()));this._particleEngine.SetParticleScale(r.GetRenderScale()*a),this._particleEngine.Draw(e,t.GetTexQuad(),n,r.Has3DCamera())}}}SaveToJson(){const e=this._particleEngine;return{r:e.GetRate(),sc:e.GetSprayCone(),st:e.GetSprayType(),isp:e.GetInitSpeed(),isz:e.GetInitSize(),io:e.GetInitOpacity(),gr:e.GetGrowRate(),xr:e.GetInitXRandom(),yr:e.GetInitYRandom(),spr:e.GetInitSpeedRandom(),szr:e.GetInitSizeRandom(),grnd:e.GetGrowRandom(),acc:e.GetAcceleration(),g:e.GetGravity(),lar:e.GetLifeAngleRandom(),lsr:e.GetLifeSpeedRandom(),lor:e.GetLifeOpacityRandom(),dm:e.GetDestroyModeIndex(),to:e.GetTimeout(),s:e.IsSpraying(),pcc:e._GetCreateCounter(),ft:this._isFirstTick,soc:this._spawnObjectClass?this._spawnObjectClass.GetSID():null,p:e.GetParticles().map(e=>e.toJSON())}}LoadFromJson(e,t){const s=this._particleEngine;if(s.SetRate(e.r),s.SetSprayCone(e.sc),s.SetSprayType(e.st),s.SetInitSpeed(e.isp),s.SetInitSize(e.isz),s.SetInitOpacity(e.io),s.SetGrowRate(e.gr),s.SetInitXRandom(e.xr),s.SetInitYRandom(e.yr),s.SetInitSpeedRandom(e.spr),s.SetInitSizeRandom(e.szr),s.SetGrowRandom(e.grnd),s.SetAcceleration(e.acc),s.SetGravity(e.g),s.SetLifeAngleRandom(e.lar),s.SetLifeSpeedRandom(e.lsr),s.SetLifeOpacityRandom(e.lor),s.SetDestroyModeIndex(e.dm),s.SetTimeout(e.to),s.SetSpraying(e.s),s._SetCreateCounter(e.pcc),this._isFirstTick=e.ft,e.hasOwnProperty("soc")){const n=this.GetRuntime().GetObjectClassBySID(e.soc);n&&this._SetParticleObjectClass(n)}const i=e.p,r=(s.SetParticleCount(i.length,!1),s.GetParticles());for(let e=0,t=r.length;e<t;++e)r[e].setFromJSON(i[e]);"state"===t&&this._spawnObjectClass&&(s.UpdateAllParticlesUserData(),s.ApplyParticleDataToUserData(this))}_OnAfterLoad(){const e=this._particleEngine,s=(e.UpdateAllParticlesUserData(),e.ApplyParticleDataToUserData(this),e.GetParticles());for(let e=0,t=s.length;e<t;++e){const i=s[e],r=i.GetUserData();if(r){const n=r.GetWorldInfo();if(n){const a=n.GetInstance();if(a){const o=i.GetUserDataUID(),l=a.GetUID();if(("number"!=typeof o||"number"!=typeof l||o!==l)&&"number"==typeof o){const h=this.GetRuntime(),c=h.GetInstanceByUID(o);c&&h.DestroyInstance(c)}}}}}}Tick(){const e=this._runtime.GetDt(this._inst);this._UpdateEngineParameters(),this._isFirstTick&&"one-shot"===this._particleEngine.GetSprayType()&&this._particleEngine.ReInitAllParticles(),this._particleEngine.Tick(e),this._particleEngine.IsSpraying()&&this._runtime.UpdateRender(),this.GetWorldInfo().SetBboxChanged(),this._isFirstTick=!1}_FastForward(e){for(this._isFirstTick&&"one-shot"===this._particleEngine.GetSprayType()&&this._particleEngine.ReInitAllParticles();0<e;)this._particleEngine.Tick(1/60),e-=1/60;this._particleEngine.IsSpraying()&&this._runtime.UpdateRender(),this.GetWorldInfo().SetBboxChanged(),this._isFirstTick=!1}_OnParticleCreate(e,t){let s,i=(s=(s=(s="number"==typeof t?this._runtime.GetInstanceByUID(t):s)&&s.GetObjectClass()!==this._spawnObjectClass?null:s)||this._runtime.CreateInstance(this._spawnObjectClass,this.GetWorldInfo().GetLayer(),e.GetX(),e.GetY())).GetWorldInfo();return i.SetSize(e.GetSize(),e.GetSize()),i.SetAngle(e.GetAngle()),i.SetOpacity(e.GetOpacity()),i.SetUnpremultipliedColor(this.GetWorldInfo().GetUnpremultipliedColor()),i.SetBboxChanged(),i.ZOrderMoveAdjacentToInstance(this.GetInstance(),!0),s._TriggerOnCreated(),e.SetUpdateCallback(this._particleUpdateCallback),e.SetDestroyCallback(this._particleDestroyCallback),s}_OnParticleUpdate(e,t,s,i,r,n){if(!e.IsDestroyed()){const a=e.GetWorldInfo();a.OffsetXY(t,s),a.SetSize(a.GetWidth()+i,a.GetHeight()+i),a.SetAngle(a.GetAngle()+r),a.SetOpacity(a.GetOpacity()+n),a.SetBboxChanged()}}_OnParticleDestroy(e){e.IsDestroyed()||this._runtime.DestroyInstance(e)}GetPropertyValueByIndex(e){const i=this._particleEngine;switch(e){case j:return i.GetRate();case k:return h.toDegrees(i.GetSprayCone());case l:return"one-shot"===i.GetSprayType()?F:E;case o:return i.GetInitSpeed();case p:return i.GetInitSize();case q:return 100*i.GetInitOpacity();case r:return i.GetGrowRate();case s:return i.GetInitXRandom();case t:return i.GetInitYRandom();case u:return i.GetInitSpeedRandom();case v:return i.GetInitSizeRandom();case w:return i.GetGrowRandom();case x:return i.GetAcceleration();case y:return i.GetGravity();case z:return i.GetLifeAngleRandom();case A:return i.GetLifeSpeedRandom();case B:return i.GetLifeOpacityRandom();case C:return i.GetDestroyModeIndex();case D:return i.GetTimeout()}}SetPropertyValueByIndex(e,i){const n=this._particleEngine;switch(e){case j:n.SetRate(i);break;case k:n.SetSprayCone(h.toRadians(i));break;case l:n.SetSprayType(i?"one-shot":"continuous-spray");break;case o:n.SetInitSpeed(i);break;case p:n.SetInitSize(i);break;case q:n.SetInitOpacity(i/100);break;case r:n.SetGrowRate(i);break;case s:n.SetInitXRandom(i);break;case t:n.SetInitYRandom(i);break;case u:n.SetInitSpeedRandom(i);break;case v:n.SetInitSizeRandom(i);break;case w:n.SetGrowRandom(i);break;case x:n.SetAcceleration(i);break;case y:n.SetGravity(i);break;case z:n.SetLifeAngleRandom(i);break;case A:n.SetLifeSpeedRandom(i);break;case B:n.SetLifeOpacityRandom(i);break;case C:n.SetDestroyModeIndex(i);break;case D:n.SetTimeout(i)}}GetDebuggerProperties(){const e="plugins.particles",t=e+".properties",s=e+".debugger",i=this._particleEngine;return[{title:e+".name",properties:[{name:s+".particle-count",value:i.GetParticleCount()},{name:t+".type.name",value:[t+".type.items."+i.GetSprayType()]},{name:s+".is-spraying",value:i.IsSpraying(),onedit:e=>i.SetSpraying(e)},{name:t+".rate.name",value:i.GetRate(),onedit:e=>i.SetRate(e)},{name:t+".spray-cone.name",value:h.toDegrees(i.GetSprayCone()),onedit:e=>i.SetSprayCone(h.toRadians(e))},{name:t+".speed.name",value:i.GetInitSpeed(),onedit:e=>i.SetInitSpeed(e)},{name:t+".size.name",value:i.GetInitSize(),onedit:e=>i.SetInitSize(e)},{name:t+".opacity.name",value:i.GetInitOpacity(),onedit:e=>i.SetInitOpacity(e)},{name:t+".grow-rate.name",value:i.GetGrowRate(),onedit:e=>i.SetGrowRate(e)},{name:t+".x-randomiser.name",value:i.GetInitXRandom(),onedit:e=>i.SetInitXRandom(e)},{name:t+".y-randomiser.name",value:i.GetInitYRandom(),onedit:e=>i.SetInitYRandom(e)},{name:t+".initial-speed-randomiser.name",value:i.GetInitSpeedRandom(),onedit:e=>i.SetInitSpeedRandom(e)},{name:t+".size-randomiser.name",value:i.GetInitSizeRandom(),onedit:e=>i.SetInitSizeRandom(e)},{name:t+".grow-rate-randomiser.name",value:i.GetGrowRandom(),onedit:e=>i.SetGrowRandom(e)},{name:t+".acceleration.name",value:i.GetAcceleration(),onedit:e=>i.SetAcceleration(e)},{name:t+".gravity.name",value:i.GetGravity(),onedit:e=>i.SetGravity(e)},{name:t+".angle-randomiser.name",value:i.GetLifeAngleRandom(),onedit:e=>i.SetLifeAngleRandom(e)},{name:t+".life-speed-randomiser.name",value:i.GetLifeSpeedRandom(),onedit:e=>i.SetLifeSpeedRandom(e)},{name:t+".opacity-randomiser.name",value:i.GetLifeOpacityRandom(),onedit:e=>i.SetLifeOpacityRandom(e)},{name:t+".timeout.name",value:i.GetTimeout(),onedit:e=>i.SetTimeout(e)}]}]}GetScriptInterfaceClass(){return self.IParticlesInstance}},new WeakMap);self.IParticlesInstance=class extends self.IWorldInstance{constructor(){super(),H.set(this,self.IInstance._GetInitInst().GetSdkInstance())}set isSpraying(e){GetParticleEngine2(this).SetSpraying(!!e)}get isSpraying(){return GetParticleEngine2(this).IsSpraying()}set rate(e){i.RequireFiniteNumber(e),H.get(this)._SetRate(e)}get rate(){return GetParticleEngine2(this).GetRate()}set sprayCone(e){i.RequireFiniteNumber(e),GetParticleEngine2(this).SetSprayCone(e)}get sprayCone(){return GetParticleEngine2(this).GetSprayCone()}set initSpeed(e){i.RequireFiniteNumber(e),GetParticleEngine2(this).SetInitSpeed(e)}get initSpeed(){return GetParticleEngine2(this).GetInitSpeed()}set initSize(e){i.RequireFiniteNumber(e),GetParticleEngine2(this).SetInitSize(e)}get initSize(){return GetParticleEngine2(this).GetInitSize()}set initOpacity(e){i.RequireFiniteNumber(e),GetParticleEngine2(this).SetInitOpacity(e)}get initOpacity(){return GetParticleEngine2(this).GetInitOpacity()}set initXRandom(e){i.RequireFiniteNumber(e),GetParticleEngine2(this).SetInitXRandom(e)}get initXRandom(){return GetParticleEngine2(this).GetInitXRandom()}set initYRandom(e){i.RequireFiniteNumber(e),GetParticleEngine2(this).SetInitYRandom(e)}get initYRandom(){return GetParticleEngine2(this).GetInitYRandom()}set initSpeedRandom(e){i.RequireFiniteNumber(e),GetParticleEngine2(this).SetInitSpeedRandom(e)}get initSpeedRandom(){return GetParticleEngine2(this).GetInitSpeedRandom()}set initSizeRandom(e){i.RequireFiniteNumber(e),GetParticleEngine2(this).SetInitSizeRandom(e)}get initSizeRandom(){return GetParticleEngine2(this).GetInitSizeRandom()}set initGrowRate(e){i.RequireFiniteNumber(e),GetParticleEngine2(this).SetGrowRate(e)}get initGrowRate(){return GetParticleEngine2(this).GetGrowRate()}set initGrowRandom(e){i.RequireFiniteNumber(e),GetParticleEngine2(this).SetGrowRandom(e)}get initGrowRandom(){return GetParticleEngine2(this).GetGrowRandom()}set acceleration(e){i.RequireFiniteNumber(e),GetParticleEngine2(this).SetAcceleration(e)}get acceleration(){return GetParticleEngine2(this).GetAcceleration()}set gravity(e){i.RequireFiniteNumber(e),GetParticleEngine2(this).SetGravity(e)}get gravity(){return GetParticleEngine2(this).GetGravity()}set lifeAngleRandom(e){i.RequireFiniteNumber(e),GetParticleEngine2(this).SetLifeAngleRandom(e)}get lifeAngleRandom(){return GetParticleEngine2(this).GetLifeAngleRandom()}set lifeSpeedRandom(e){i.RequireFiniteNumber(e),GetParticleEngine2(this).SetLifeSpeedRandom(e)}get lifeSpeedRandom(){return GetParticleEngine2(this).GetLifeSpeedRandom()}set lifeOpacityRandom(e){i.RequireFiniteNumber(e),GetParticleEngine2(this).SetLifeOpacityRandom(e)}get lifeOpacityRandom(){return GetParticleEngine2(this).GetLifeOpacityRandom()}set timeout(e){i.RequireFiniteNumber(e),GetParticleEngine2(this).SetTimeout(e)}get timeout(){return GetParticleEngine2(this).GetTimeout()}fastForward(e){i.RequireFiniteNumber(e),H.get(this)._FastForward(e)}setParticleObjectClass(e){const t=H.get(this);e?t._SetParticleObjectClass(t.GetRuntime()._UnwrapIObjectClass(e)):t._SetParticleObjectClass(null)}}}{const N0=self.C3;N0.Plugins.Particles.Cnds={IsSpraying(){return this._particleEngine.IsSpraying()}}}{const O0=self.C3;O0.Plugins.Particles.Acts={SetSpraying(e){this._particleEngine.SetSpraying(0!==e)},SetRate(e){this._SetRate(e)},SetParticleObject(e){this._SetParticleObjectClass(e)},UnsetParticleObject(){this._SetParticleObjectClass(null)},SetSprayCone(e){this._particleEngine.SetSprayCone(O0.toRadians(e))},SetInitSpeed(e){this._particleEngine.SetInitSpeed(e)},SetInitSize(e){this._particleEngine.SetInitSize(e)},SetInitOpacity(e){this._particleEngine.SetInitOpacity(e/100)},SetGrowRate(e){this._particleEngine.SetGrowRate(e)},SetXRandomiser(e){this._particleEngine.SetInitXRandom(e)},SetYRandomiser(e){this._particleEngine.SetInitYRandom(e)},SetSpeedRandomiser(e){this._particleEngine.SetInitSpeedRandom(e)},SetSizeRandomiser(e){this._particleEngine.SetInitSizeRandom(e)},SetGrowRateRandomiser(e){this._particleEngine.SetGrowRandom(e)},SetParticleAcc(e){this._particleEngine.SetAcceleration(e)},SetGravity(e){this._particleEngine.SetGravity(e)},SetAngleRandomiser(e){this._particleEngine.SetLifeAngleRandom(e)},SetLifeSpeedRandomiser(e){this._particleEngine.SetLifeSpeedRandom(e)},SetOpacityRandomiser(e){this._particleEngine.SetLifeOpacityRandom(e)},SetTimeout(e){this._particleEngine.SetTimeout(e)},FastForward(e){this._FastForward(e)},SetEffect(e){this.GetWorldInfo().SetBlendMode(e),this._runtime.UpdateRender()}}}{const ib=self.C3;ib.Plugins.Particles.Exps={ParticleCount(){return this._particleEngine.GetParticleCount()},Rate(){return this._particleEngine.GetRate()},SprayCone(){return ib.toDegrees(this._particleEngine.GetSprayCone())},InitSpeed(){return this._particleEngine.GetInitSpeed()},InitSize(){return this._particleEngine.GetInitSize()},InitOpacity(){return 100*this._particleEngine.GetInitOpacity()},InitGrowRate(){return this._particleEngine.GetGrowRate()},XRandom(){return this._particleEngine.GetInitXRandom()},YRandom(){return this._particleEngine.GetInitYRandom()},InitSizeRandom(){return this._particleEngine.GetInitSizeRandom()},InitSpeedRandom(){return this._particleEngine.GetInitSpeedRandom()},InitGrowRandom(){return this._particleEngine.GetGrowRandom()},ParticleAcceleration(){return this._particleEngine.GetAcceleration()},Gravity(){return this._particleEngine.GetGravity()},ParticleAngleRandom(){return this._particleEngine.GetLifeAngleRandom()},ParticleSpeedRandom(){return this._particleEngine.GetLifeSpeedRandom()},ParticleOpacityRandom(){return this._particleEngine.GetLifeOpacityRandom()},Timeout(){return this._particleEngine.GetTimeout()}}}{const C33=self.C3,inactiveParticles=[],MAX_RECYCLE_PARTICLES=1e3,VALID_SPRAY_TYPES=new Set(["continuous-spray","one-shot"]),DESTROY_MODES=["fade-to-invisible","timeout-expired","particle-stopped"],tempRect=C33.New(C33.Rect);self.ParticleEngine=class{constructor(){this._rate=0,this._sprayCone=0,this._sprayType="continuous-spray",this._isSpraying=!1,this._masterOpacity=0,this._isPixelRounding=!1,this._spawnX=0,this._spawnY=0,this._spawnAngle=0,this._initSpeed=0,this._initSize=0,this._initSizeScale=1,this._initOpacity=0,this._growRate=0,this._xRandom=0,this._yRandom=0,this._initSpeedRandom=0,this._initSizeRandom=0,this._growRandom=0,this._acceleration=0,this._gravity=0,this._lifeAngleRandom=0,this._lifeSpeedRandom=0,this._lifeOpacityRandom=0,this._destroyMode=0,this._timeout=0,this._createCounter=0,this._particleScale=1,this.ononeshotfinish=null,this.onparticlecreate=null,this._particles=[],this._boundingBox=new C33.Rect,this._color=new C33.Color}Release(){this.Cancel(),C33.clearArray(this._particles),this._particles=null,this.ononeshotfinish=null,this.onparticlecreate=null,this._boundingBox=null,this._color=null}Cancel(){const s=this._particles;for(let e=0,t=s.length;e<t;++e)s[e].Destroy();C33.appendArray(inactiveParticles,s),C33.clearArray(s),inactiveParticles.length>MAX_RECYCLE_PARTICLES&&C33.truncateArray(inactiveParticles,MAX_RECYCLE_PARTICLES),this._isSpraying=!1}CreateOneShotSpray(){for(let e=0,t=this._rate;e<t;++e)this._CreateParticle();this._particles.length&&(this._isSpraying=!0)}_CreateParticle(e=!0){let t=null;return inactiveParticles.length?(t=inactiveParticles.pop()).SetEngine(this):t=C33.New(self.Particle,this),this._particles.push(t),e?t.Init(this.onparticlecreate):t.Init(),t}ReInitAllParticles(){const s=this._particles,i=this.onparticlecreate;for(let e=0,t=s.length;e<t;++e)s[e].Init(i)}UpdateAllParticlesUserData(){const s=this._particles,i=this.onparticlecreate;for(let e=0,t=s.length;e<t;++e)s[e].UpdateUserData(i)}ApplyParticleDataToUserData(s){const i=this._particles;for(let e=0,t=i.length;e<t;++e){const r=i[e],n=r.GetUserData();if(n){const a=n.GetWorldInfo();a.SetX(r.GetX()),a.SetY(r.GetY()),a.SetSize(r.GetSize(),r.GetSize()),a.SetOpacity(r.GetOpacity()),a.SetAngle(r.GetAngle()),a.SetUnpremultipliedColor(s.GetWorldInfo().GetUnpremultipliedColor()),a.SetBboxChanged()}}}SetParticleCount(e,t=!0){const s=this._particles;if(e<s.length){const i=s.length-e;for(let e=0;e<i;++e){const r=s.pop();r.Destroy(),inactiveParticles.push(r)}inactiveParticles.length>MAX_RECYCLE_PARTICLES&&C33.truncateArray(inactiveParticles,MAX_RECYCLE_PARTICLES)}else if(e>s.length){const n=e-s.length;for(let e=0;e<n;++e)this._CreateParticle(t)}}GetParticles(){return this._particles}GetParticleCount(){return this._particles.length}Tick(e){this._SpawnContinuous(e),this._TickParticles(e),this._MaybeFinishOneShot()}_SpawnContinuous(e){if("continuous-spray"===this._sprayType&&this._isSpraying){this._createCounter+=e*this._rate;const t=Math.floor(this._createCounter);this._createCounter-=t;for(let e=0;e<t;++e)this._CreateParticle()}}_SetCreateCounter(e){this._createCounter=e}_GetCreateCounter(){return this._createCounter}_TickParticles(s){let i=this._boundingBox,r=(i.set(this._spawnX,this._spawnY,this._spawnX,this._spawnY),this._particles),n=0;for(let e=0,t=r.length;e<t;++e){const a=r[e];(r[n]=a).Tick(s),a.IsActive()?(++n,i.expandToContain(a.GetBoundingBox())):(a.Destroy(),inactiveParticles.push(a))}C33.truncateArray(r,n),inactiveParticles.length>MAX_RECYCLE_PARTICLES&&C33.truncateArray(inactiveParticles,MAX_RECYCLE_PARTICLES)}_MaybeFinishOneShot(){"one-shot"===this._sprayType&&0===this._particles.length&&this._isSpraying&&(this.ononeshotfinish&&this.ononeshotfinish(),this._isSpraying=!1)}Draw(s,i,r,n){tempRect.set(i.getTlx(),i.getTly(),i.getBrx(),i.getBry()),s.StartRenderingPoints(tempRect),this._color.copy(s.GetColor());const a=this._particles;for(let e=0,t=a.length;e<t;++e){const o=a[e];r.intersectsRect(o.GetBoundingBox())&&o.Draw(s,i,n)}s.FinishRenderingPoints()}GetColor(){return this._color}SetRate(e){this._rate=+e}GetRate(){return this._rate}SetSprayCone(e){this._sprayCone=+e}GetSprayCone(){return this._sprayCone}SetSprayType(e){if(!VALID_SPRAY_TYPES.has(e))throw new Error("invalid spray type");this._sprayType=e}GetSprayType(){return this._sprayType}SetSpraying(e){this._isSpraying=!!e}IsSpraying(){return this._isSpraying}SetMasterOpacity(e){this._masterOpacity=+e}GetMasterOpacity(){return this._masterOpacity}SetPixelRounding(e){this._isPixelRounding=!!e}IsPixelRounding(){return this._isPixelRounding}SetSpawnX(e){this._spawnX=+e}GetSpawnX(){return this._spawnX}SetSpawnY(e){this._spawnY=+e}GetSpawnY(){return this._spawnY}SetSpawnAngle(e){this._spawnAngle=+e}GetInitAngle(){return this._spawnAngle}SetInitSpeed(e){this._initSpeed=+e}GetInitSpeed(){return this._initSpeed}SetInitSize(e){this._initSize=+e}GetInitSize(){return this._initSize}SetInitSizeScale(e){this._initSizeScale=+e}GetInitSizeScale(){return this._initSizeScale}SetInitOpacity(e){this._initOpacity=+e}GetInitOpacity(){return this._initOpacity}SetGrowRate(e){this._growRate=+e}GetGrowRate(){return this._growRate}SetInitXRandom(e){this._xRandom=+e}GetInitXRandom(){return this._xRandom}SetInitYRandom(e){this._yRandom=+e}GetInitYRandom(){return this._yRandom}SetInitSpeedRandom(e){this._initSpeedRandom=+e}GetInitSpeedRandom(){return this._initSpeedRandom}SetInitSizeRandom(e){this._initSizeRandom=+e}GetInitSizeRandom(){return this._initSizeRandom}SetGrowRandom(e){this._growRandom=+e}GetGrowRandom(){return this._growRandom}SetAcceleration(e){this._acceleration=+e}GetAcceleration(){return this._acceleration}SetGravity(e){this._gravity=+e}GetGravity(){return this._gravity}SetLifeAngleRandom(e){this._lifeAngleRandom=+e}GetLifeAngleRandom(){return this._lifeAngleRandom}SetLifeSpeedRandom(e){this._lifeSpeedRandom=+e}GetLifeSpeedRandom(){return this._lifeSpeedRandom}SetLifeOpacityRandom(e){this._lifeOpacityRandom=+e}GetLifeOpacityRandom(){return this._lifeOpacityRandom}SetDestroyMode(e){let t=DESTROY_MODES.indexOf(e);if(-1===t)throw new Error("invalid destroy mode");this._destroyMode=t}SetDestroyModeIndex(e){this.SetDestroyMode(DESTROY_MODES[e])}GetDestroyMode(){return DESTROY_MODES[this._destroyMode]}GetDestroyModeIndex(){return this._destroyMode}SetTimeout(e){this._timeout=+e}GetTimeout(){return this._timeout}SetParticleScale(e){this._particleScale=+e}GetParticleScale(){return this._particleScale}GetBoundingBox(){return this._boundingBox}}}{let randomOffset2=function(e){return Math.random()*e-e/2},C33=(randomOffset=randomOffset2,self.C3),ParticleEngine=self.ParticleEngine,tmpQuad=new C33.Quad,tmpColor=new C33.Color,DPR=self.devicePixelRatio||1,didChangeColor=!1;self.Particle=class{constructor(e){this._engine=e,this._isActive=!1,this._x=0,this._y=0,this._speed=0,this._angle=0,this._opacity=1,this._lastOpacity=0,this._grow=0,this._size=0,this._halfSize=0,this._gs=0,this._age=0,this._bbox=new C33.Rect,this._userData=null,this._userDataUid=NaN,this._updateCallback=null,this._destroyCallback=null}SetEngine(e){this._engine=e}Init(e){const t=this._engine;this._isActive=!0,this._x=t.GetSpawnX()+randomOffset2(t.GetInitXRandom()),this._y=t.GetSpawnY()+randomOffset2(t.GetInitYRandom()),this._speed=t.GetInitSpeed()+randomOffset2(t.GetInitSpeedRandom()),this._angle=t.GetInitAngle()+randomOffset2(t.GetSprayCone()),this._opacity=t.GetInitOpacity(),this._lastOpacity=this._opacity,this._size=(t.GetInitSize()+randomOffset2(t.GetInitSizeRandom()))*t.GetInitSizeScale(),this._halfSize=this._size/2,this._grow=t.GetGrowRate()+randomOffset2(t.GetGrowRandom()),this._gs=0,this._age=0,this._UpdateBoundingBox(),e?this._userData||(this._userData=e(this)):(this._userData=null,this._updateCallback=null,this._destroyCallback=null)}UpdateUserData(e){e?this._userData&&!this._userData.IsDestroyed()||(this._userData=e(this,this._userDataUid)):(this._userData=null,this._updateCallback=null,this._destroyCallback=null)}SetUpdateCallback(e){this._updateCallback=e}SetDestroyCallback(e){this._destroyCallback=e}Destroy(){const e=this._destroyCallback;e&&e(this._userData),this._userData=null,this._updateCallback=null,this._destroyCallback=null}toJSON(){let e;return this._userData&&this._userData.GetWorldInfo()&&(e=this._userData.GetWorldInfo().GetInstance().GetUID()),[this._x,this._y,this._speed,this._angle,this._opacity,this._grow,this._size,this._gs,this._age,e]}setFromJSON(e){this._x=e[0],this._y=e[1],this._speed=e[2],this._angle=e[3],this._opacity=e[4],this._lastOpacity=this._opacity,this._grow=e[5],this._size=e[6],this._gs=e[7],this._age=e[8],this._userDataUid=e[9],this._halfSize=this._size/2,this._UpdateBoundingBox()}Tick(e){let t=this._engine,s=this._speed*e,i=this._angle,r=Math.cos(i)*s,n=Math.sin(i)*s+this._gs*e,a=(this._x+=r,this._y+=n,this._grow*e),o=(this._size+=a,this._halfSize=this._size/2,this._speed+=t.GetAcceleration()*e,this._gs+=t.GetGravity()*e,this._age+=e,this._UpdateBoundingBox(),t.GetLifeAngleRandom()),l=t.GetLifeSpeedRandom(),h=t.GetLifeOpacityRandom(),c=0;0!==o&&(c=randomOffset2(o*e),this._angle+=c),0!==l&&(this._speed+=randomOffset2(l*e)),0!==h&&(this._opacity=C33.clamp(this._opacity+randomOffset2(h*e),0,1));const u=1<=this._size&&(2===t.GetDestroyModeIndex()?0<this._speed:this._age<t.GetTimeout()),_=this._updateCallback;if(_&&u){let e=t.GetMasterOpacity()*this._opacity;0===t.GetDestroyModeIndex()&&(e*=1-this._age/t.GetTimeout());const d=e-this._lastOpacity;this._lastOpacity=e,_(this._userData,r,n,a,c,d)}this._isActive=u}IsActive(){return this._isActive}GetBoundingBox(){return this._bbox}_UpdateBoundingBox(){const e=this._x,t=this._y,s=this._halfSize;this._bbox.set(e-s,t-s,e+s,t+s)}Draw(r,n,a){if(!this._userData){let s=this._engine,i=s.GetMasterOpacity()*this._opacity;if(0===s.GetDestroyModeIndex()&&(i*=1-this._age/s.GetTimeout()),!(i<=0)){const o=this._size,l=o*s.GetParticleScale()*DPR;if(!(l<1)){let e=this._x,t=this._y;s.IsPixelRounding()&&(e=e+.5|0,t=t+.5|0),r.IsWebGPU()?r.Point(e,t,o,i):a||l>r.GetMaxPointSize()||l<r.GetMinPointSize()?(tmpColor.copy(s.GetColor()),tmpColor.multiplyAlpha(i),r.SetColor(tmpColor),didChangeColor=!0,tmpQuad.setFromRect(this._bbox),r.Quad4(tmpQuad,n)):(didChangeColor&&(r.SetColor(s.GetColor()),didChangeColor=!1),r.Point(e,t,l,i))}}}}GetUserData(){return this._userData}GetUserDataUID(){return this._userDataUid}GetX(){return this._x}GetY(){return this._y}GetSize(){return this._size}GetAngle(){return this._angle}GetOpacity(){return this._opacity}}}{const a=self.C3;a.Behaviors.Fade=class extends a.SDKBehaviorBase{constructor(e){super(e)}Release(){super.Release()}}}{const d=self.C3;d.Behaviors.Fade.Type=class extends d.SDKBehaviorTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const g=self.C3,h=self.C3X,i=self.IBehaviorInstance,j=0,k=1,l=2,m=3,n=4,o=(g.Behaviors.Fade.Instance=class extends g.SDKBehaviorInstanceBase{constructor(e,t){super(e),this._fadeInTime=0,this._waitTime=0,this._fadeOutTime=0,this._destroy=!0,this._activeAtStart=!0,this._setMaxOpacity=!1,this._stage=0,this._stageTime=g.New(g.KahanSum),this._maxOpacity=this._inst.GetWorldInfo().GetOpacity()||1,t&&(this._fadeInTime=t[j],this._waitTime=t[k],this._fadeOutTime=t[l],this._destroy=!!t[m],this._activeAtStart=!!t[n],this._stage=this._activeAtStart?0:3),this._activeAtStart&&(0===this._fadeInTime?(this._stage=1,0===this._waitTime&&(this._stage=2)):(this._inst.GetWorldInfo().SetOpacity(0),this._runtime.UpdateRender())),this._StartTicking()}Release(){super.Release()}SaveToJson(){return{fit:this._fadeInTime,wt:this._waitTime,fot:this._fadeOutTime,d:this._destroy,s:this._stage,st:this._stageTime.Get(),mo:this._maxOpacity}}LoadFromJson(e){this._fadeInTime=e.fit,this._waitTime=e.wt,this._fadeOutTime=e.fot,this._destroy=e.d,this._stage=e.s,this._stageTime.Set(e.st),this._maxOpacity=e.mo,3===this._stage?this._StopTicking():this._StartTicking()}Tick(){const e=this._runtime.GetDt(this._inst),t=(this._stageTime.Add(e),this._inst.GetWorldInfo());0===this._stage&&(t.SetOpacity(this._stageTime.Get()/this._fadeInTime*this._maxOpacity),this._runtime.UpdateRender(),t.GetOpacity()>=this._maxOpacity)&&(t.SetOpacity(this._maxOpacity),this._stage=1,this._stageTime.Reset(),this.DispatchScriptEvent("fadeinend"),this.Trigger(g.Behaviors.Fade.Cnds.OnFadeInEnd)),1===this._stage&&this._stageTime.Get()>=this._waitTime&&(this._stage=2,this._stageTime.Reset(),this.DispatchScriptEvent("waitend"),this.Trigger(g.Behaviors.Fade.Cnds.OnWaitEnd)),2===this._stage&&(0!==this._fadeOutTime?(t.SetOpacity(this._maxOpacity-this._stageTime.Get()/this._fadeOutTime*this._maxOpacity),this._runtime.UpdateRender(),t.GetOpacity()<=0&&(this._stage=3,this._stageTime.Reset(),this.DispatchScriptEvent("fadeoutend"),this.Trigger(g.Behaviors.Fade.Cnds.OnFadeOutEnd),this._destroy)&&this._runtime.DestroyInstance(this._inst)):(this._stage=3,this._stageTime.Reset())),3===this._stage&&this._StopTicking()}_StartFade(){this._activeAtStart||this._setMaxOpacity||(this._maxOpacity=this._inst.GetWorldInfo().GetOpacity()||1,this._setMaxOpacity=!0),3===this._stage&&this.Start()}_RestartFade(){this.Start()}Start(){this._stage=0,this._stageTime.Reset(),0===this._fadeInTime?(this._stage=1,0===this._waitTime&&(this._stage=2)):(this._inst.GetWorldInfo().SetOpacity(0),this._runtime.UpdateRender()),this._StartTicking()}_SetFadeInTime(e){this._fadeInTime=Math.max(e,0)}_GetFadeInTime(){return this._fadeInTime}_SetWaitTime(e){this._waitTime=Math.max(e,0)}_GetWaitTime(){return this._waitTime}_SetFadeOutTime(e){this._fadeOutTime=Math.max(e,0)}_GetFadeOutTime(){return this._fadeOutTime}GetPropertyValueByIndex(e){switch(e){case j:return this._GetFadeInTime();case k:return this._GetWaitTime();case l:return this._GetFadeOutTime();case m:return this._destroy}}SetPropertyValueByIndex(e,t){switch(e){case j:this._SetFadeInTime(t);break;case k:this._SetWaitTime(t);break;case l:this._SetFadeOutTime(t);break;case m:this._destroy=!!t}}GetDebuggerProperties(){const e="behaviors.fade";return[{title:"$"+this.GetBehaviorType().GetName(),properties:[{name:e+".properties.fade-in-time.name",value:this._GetFadeInTime(),onedit:e=>this._SetFadeInTime(e)},{name:e+".properties.wait-time.name",value:this._GetWaitTime(),onedit:e=>this._SetWaitTime(e)},{name:e+".properties.fade-out-time.name",value:this._GetFadeOutTime(),onedit:e=>this._SetFadeOutTime(e)},{name:e+".debugger.stage",value:[e+".debugger."+["fade-in","wait","fade-out","done"][this._stage]]}]}]}GetScriptInterfaceClass(){return self.IFadeBehaviorInstance}},new WeakMap);self.IFadeBehaviorInstance=class extends i{constructor(){super(),o.set(this,i._GetInitInst().GetSdkInstance())}startFade(){o.get(this)._StartFade()}restartFade(){o.get(this)._RestartFade()}set fadeInTime(e){h.RequireFiniteNumber(e),o.get(this)._SetFadeInTime(e)}get fadeInTime(){return o.get(this)._GetFadeInTime()}set waitTime(e){h.RequireFiniteNumber(e),o.get(this)._SetWaitTime(e)}get waitTime(){return o.get(this)._GetWaitTime()}set fadeOutTime(e){h.RequireFiniteNumber(e),o.get(this)._SetFadeOutTime(e)}get fadeOutTime(){return o.get(this)._GetFadeOutTime()}}}{const J=self.C3;J.Behaviors.Fade.Cnds={OnFadeOutEnd(){return!0},OnFadeInEnd(){return!0},OnWaitEnd(){return!0}}}{const K=self.C3;K.Behaviors.Fade.Acts={StartFade(){this._StartFade()},RestartFade(){this._RestartFade()},SetFadeInTime(e){this._SetFadeInTime(e)},SetWaitTime(e){this._SetWaitTime(e)},SetFadeOutTime(e){this._SetFadeOutTime(e)}}}{const O=self.C3;O.Behaviors.Fade.Exps={FadeInTime(){return this._GetFadeInTime()},WaitTime(){return this._GetWaitTime()},FadeOutTime(){return this._GetFadeOutTime()}}}{const a=self.C3;a.Behaviors.Sin=class extends a.SDKBehaviorBase{constructor(e){super(e)}Release(){super.Release()}}}{const d=self.C3;d.Behaviors.Sin.Type=class extends d.SDKBehaviorTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const g=self.C3,h=self.C3X,i=self.IBehaviorInstance,j=0,k=1,l=2,m=3,n=4,o=5,p=6,q=7,r=8,s=0,t=1,u=2,v=3,w=4,x=5,y=6,z=7,A=8,B=9,C=0,D=1,E=2,F=3,G=4,H=2*Math.PI,I=Math.PI/2,J=3*Math.PI/2,K=[0,1,8,3,4,2,5,6,9,7],L=(g.Behaviors.Sin.Instance=class extends g.SDKBehaviorInstanceBase{constructor(e,t){super(e),this._i=0,this._movement=0,this._wave=0,this._period=0,this._mag=0,this._isEnabled=!0,this._basePeriod=0,this._basePeriodOffset=0,this._baseMag=0,this._periodRandom=0,this._periodOffsetRandom=0,this._magnitudeRandom=0,this._initialValue=0,this._initialValue2=0,this._lastKnownValue=0,this._lastKnownValue2=0,this._ratio=0,t&&(this._movement=K[t[j]],this._wave=t[k],this._periodRandom=this._runtime.Random()*t[m],this._basePeriod=t[l],this._period=t[l],this._period+=this._periodRandom,this._basePeriodOffset=t[n],0!==this._period&&(this._periodOffsetRandom=this._runtime.Random()*t[o],this._i=t[n]/this._period*H,this._i+=this._periodOffsetRandom/this._period*H),this._magnitudeRandom=this._runtime.Random()*t[q],this._baseMag=t[p],this._mag=t[p],this._mag+=this._magnitudeRandom,this._isEnabled=!!t[r]),this._movement===x&&(this._mag=g.toRadians(this._mag)),this.Init(),this._isEnabled&&this._StartTicking()}Release(){super.Release()}SaveToJson(){return{i:this._i,e:this._isEnabled,mv:this._movement,w:this._wave,p:this._period,mag:this._mag,iv:this._initialValue,iv2:this._initialValue2,r:this._ratio,lkv:this._lastKnownValue,lkv2:this._lastKnownValue2}}LoadFromJson(e){this._i=e.i,this._SetEnabled(e.e),this._movement=e.mv,this._wave=e.w,this._period=e.p,this._mag=e.mag,this._initialValue=e.iv,this._initialValue2=e.iv2,this._ratio=e.r,this._lastKnownValue=e.lkv,this._lastKnownValue2=e.lkv2}Init(){const e=this._inst.GetWorldInfo();switch(this._movement){case s:this._initialValue=e.GetX();break;case t:this._initialValue=e.GetY();break;case u:this._initialValue=e.GetWidth(),this._ratio=e.GetHeight()/e.GetWidth();break;case v:this._initialValue=e.GetWidth();break;case w:this._initialValue=e.GetHeight();break;case x:this._initialValue=e.GetAngle();break;case y:this._initialValue=e.GetOpacity();break;case z:this._initialValue=0;break;case A:this._initialValue=e.GetX(),this._initialValue2=e.GetY();break;case B:this._initialValue=e.GetZElevation()}this._lastKnownValue=this._initialValue,this._lastKnownValue2=this._initialValue2}WaveFunc(e){switch(e%=H,this._wave){case C:return Math.sin(e);case D:return e<=I?e/I:e<=J?1-2*(e-I)/Math.PI:(e-J)/I-1;case E:return 2*e/H-1;case F:return-2*e/H+1;case G:return e<Math.PI?-1:1}return 0}Tick(){const e=this._runtime.GetDt(this._inst);this._isEnabled&&0!==e&&(0===this._period?this._i=0:this._i=(this._i+e/this._period*H)%H,this._UpdateFromPhase())}_UpdateFromPhase(){const e=this._inst.GetWorldInfo();switch(this._movement){case s:e.GetX()!==this._lastKnownValue&&(this._initialValue+=e.GetX()-this._lastKnownValue),e.SetX(this._initialValue+this.WaveFunc(this._i)*this._mag),this._lastKnownValue=e.GetX();break;case t:e.GetY()!==this._lastKnownValue&&(this._initialValue+=e.GetY()-this._lastKnownValue),e.SetY(this._initialValue+this.WaveFunc(this._i)*this._mag),this._lastKnownValue=e.GetY();break;case u:e.SetWidth(this._initialValue+this.WaveFunc(this._i)*this._mag),e.SetHeight(e.GetWidth()*this._ratio);break;case v:e.SetWidth(this._initialValue+this.WaveFunc(this._i)*this._mag);break;case w:e.SetHeight(this._initialValue+this.WaveFunc(this._i)*this._mag);break;case x:e.GetAngle()!==this._lastKnownValue&&(this._initialValue=g.clampAngle(this._initialValue+(e.GetAngle()-this._lastKnownValue))),e.SetAngle(this._initialValue+this.WaveFunc(this._i)*this._mag),this._lastKnownValue=e.GetAngle();break;case y:e.SetOpacity(this._initialValue+this.WaveFunc(this._i)*this._mag/100);break;case A:e.GetX()!==this._lastKnownValue&&(this._initialValue+=e.GetX()-this._lastKnownValue),e.GetY()!==this._lastKnownValue2&&(this._initialValue2+=e.GetY()-this._lastKnownValue2),e.SetX(this._initialValue+Math.cos(e.GetAngle())*this.WaveFunc(this._i)*this._mag),e.SetY(this._initialValue2+Math.sin(e.GetAngle())*this.WaveFunc(this._i)*this._mag),this._lastKnownValue=e.GetX(),this._lastKnownValue2=e.GetY();break;case B:e.SetZElevation(this._initialValue+this.WaveFunc(this._i)*this._mag)}e.SetBboxChanged()}_OnSpriteFrameChanged(e,t){}_SetPeriod(e){this._period=e}_GetPeriod(){return this._period}_SetMagnitude(e){this._mag=e}_SetMagnitude_ConvertAngle(e){5===this._movement&&(e=g.toRadians(e)),this._SetMagnitude(e)}_GetMagnitude(){return this._mag}_GetMagnitude_ConvertAngle(){let e=this._GetMagnitude();return 5===this._movement?g.toDegrees(e):e}_SetMovement(e){5===this._movement&&5!==e&&(this._mag=g.toDegrees(this._mag)),this._movement=e,this.Init()}_GetMovement(){return this._movement}_SetWave(e){this._wave=e}_GetWave(){return this._wave}_SetPhase(e){this._i=g.clamp(e,0,2*Math.PI),this._UpdateFromPhase()}_GetPhase(){return this._i}_SetEnabled(e){this._isEnabled=!!e,this._isEnabled?this._StartTicking():this._StopTicking()}_IsEnabled(){return this._isEnabled}GetPropertyValueByIndex(e){switch(e){case j:return this._movement;case k:return this._wave;case l:return this._basePeriod;case p:return this._baseMag;case r:return this._isEnabled}}SetPropertyValueByIndex(e,t){switch(e){case j:this._movement=K[t],this.Init();break;case k:this._wave=t;break;case l:this._basePeriod=t,this._period=this._basePeriod+this._periodRandom,this._isEnabled||(0!==this._period?(this._i=this._basePeriodOffset/this._period*H,this._i+=this._periodOffsetRandom/this._period*H):this._i=0);break;case p:this._baseMag=t,this._mag=this._baseMag+this._magnitudeRandom,this._movement===x&&(this._mag=g.toRadians(this._mag));break;case r:this._isEnabled=!!t}}GetDebuggerProperties(){const e="behaviors.sin";return[{title:"$"+this.GetBehaviorType().GetName(),properties:[{name:e+".properties.enabled.name",value:this._IsEnabled(),onedit:e=>this._SetEnabled(e)},{name:e+".properties.period.name",value:this._GetPeriod(),onedit:e=>this._SetPeriod(e)},{name:e+".properties.magnitude.name",value:this._GetMagnitude_ConvertAngle(),onedit:e=>this._SetMagnitude_ConvertAngle(e)},{name:e+".debugger.value",value:this.WaveFunc(this._GetPhase())*this._GetMagnitude_ConvertAngle()}]}]}GetScriptInterfaceClass(){return self.ISineBehaviorInstance}},new WeakMap),M=["horizontal","vertical","size","width","height","angle","opacity","value-only","forwards-backwards","z-elevation"],N=["sine","triangle","sawtooth","reverse-sawtooth","square"];self.ISineBehaviorInstance=class extends i{constructor(){super(),L.set(this,i._GetInitInst().GetSdkInstance())}set period(e){h.RequireFiniteNumber(e),L.get(this)._SetPeriod(e)}get period(){return L.get(this)._GetPeriod()}set magnitude(e){h.RequireFiniteNumber(e),L.get(this)._SetMagnitude(e)}get magnitude(){return L.get(this)._GetMagnitude()}set phase(e){L.get(this)._SetPhase(e)}get phase(){return L.get(this)._GetPhase()}set movement(e){h.RequireString(e);const t=M.indexOf(e);if(-1===t)throw new Error("invalid movement");L.get(this)._SetMovement(t)}get movement(){return M[L.get(this)._GetMovement()]}set wave(e){h.RequireString(e);const t=N.indexOf(e);if(-1===t)throw new Error("invalid wave");L.get(this)._SetWave(t)}get wave(){return N[L.get(this)._GetWave()]}get value(){const e=L.get(this);return e.WaveFunc(e._GetPhase())*e._GetMagnitude()}updateInitialState(){L.get(this).Init()}set isEnabled(e){L.get(this)._SetEnabled(!!e)}get isEnabled(){return L.get(this)._IsEnabled()}}}{const va=self.C3;va.Behaviors.Sin.Cnds={IsEnabled(){return this._IsEnabled()},CompareMovement(e){return this._GetMovement()===e},ComparePeriod(e,t){return va.compare(this._GetPeriod(),e,t)},CompareMagnitude(e,t){return va.compare(this._GetMagnitude_ConvertAngle(),e,t)},CompareWave(e){return this._GetWave()===e}}}{const Ca=self.C3;Ca.Behaviors.Sin.Acts={SetEnabled(e){this._SetEnabled(0!==e)},SetPeriod(e){this._SetPeriod(e)},SetMagnitude(e){this._SetMagnitude_ConvertAngle(e)},SetMovement(e){this._SetMovement(e)},SetWave(e){this._wave=e},SetPhase(e){const t=2*Math.PI;this._SetPhase(e*t%t)},UpdateInitialState(){this.Init()}}}{const Ka=self.C3;Ka.Behaviors.Sin.Exps={CyclePosition(){return this._GetPhase()/(2*Math.PI)},Period(){return this._GetPeriod()},Magnitude(){return this._GetMagnitude_ConvertAngle()},Value(){return this.WaveFunc(this._GetPhase())*this._GetMagnitude_ConvertAngle()}}}{const a=self.C3;a.Behaviors.Pin=class extends a.SDKBehaviorBase{constructor(e){super(e)}Release(){super.Release()}}}{const d=self.C3;d.Behaviors.Pin.Type=class extends d.SDKBehaviorTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const g=self.C3;g.Behaviors.Pin.Instance=class extends g.SDKBehaviorInstanceBase{constructor(e,t){super(e),this._pinInst=null,this._pinUid=-1,this._mode="",this._propSet=new Set,this._pinDist=0,this._pinAngle=0,this._pinImagePoint=0,this._dx=0,this._dy=0,this._dWidth=0,this._dHeight=0,this._dAngle=0,this._dz=0,this._lastKnownAngle=0,this._destroy=!1,t&&(this._destroy=t[0]);const s=this._runtime.Dispatcher();this._disposables=new g.CompositeDisposable(g.Disposable.From(s,"instancedestroy",e=>this._OnInstanceDestroyed(e.instance)),g.Disposable.From(s,"afterload",e=>this._OnAfterLoad()))}Release(){this._pinInst=null,super.Release()}_SetPinInst(e){e?(this._pinInst=e,this._StartTicking2()):(this._pinInst=null,this._StopTicking2())}_Pin(e,t,s){if(e){const i=e.GetFirstPicked(this._inst);if(i){this._mode=t,this._SetPinInst(i);const r=this._inst.GetWorldInfo(),n=i.GetWorldInfo();if("properties"===this._mode){const a=this._propSet;a.clear();for(const o of s)a.add(o);this._dx=r.GetX()-n.GetX(),this._dy=r.GetY()-n.GetY(),this._dAngle=r.GetAngle()-n.GetAngle(),this._lastKnownAngle=r.GetAngle(),this._dz=r.GetZElevation()-n.GetZElevation(),a.has("x")&&a.has("y")&&(this._pinAngle=g.angleTo(n.GetX(),n.GetY(),r.GetX(),r.GetY())-n.GetAngle(),this._pinDist=g.distanceTo(n.GetX(),n.GetY(),r.GetX(),r.GetY())),a.has("width-abs")?this._dWidth=r.GetWidth()-n.GetWidth():a.has("width-scale")&&(this._dWidth=r.GetWidth()/n.GetWidth()),a.has("height-abs")?this._dHeight=r.GetHeight()-n.GetHeight():a.has("height-scale")&&(this._dHeight=r.GetHeight()/n.GetHeight())}else this._pinDist=g.distanceTo(n.GetX(),n.GetY(),r.GetX(),r.GetY())}}}SaveToJson(){const e=this._propSet,t=this._mode,s={uid:this._pinInst&&!this._pinInst.IsDestroyed()?this._pinInst.GetUID():-1,m:t,d:this._destroy};return"rope"===t||"bar"===t?s.pd=this._pinDist:"properties"===t&&(s.ps=[...this._propSet],e.has("imagepoint")?s.ip=this._pinImagePoint:e.has("x")&&e.has("y")?(s.pa=this._pinAngle,s.pd=this._pinDist):(e.has("x")&&(s.dx=this._dx),e.has("y")&&(s.dy=this._dy)),e.has("angle")&&(s.da=this._dAngle,s.lka=this._lastKnownAngle),(e.has("width-abs")||e.has("width-scale"))&&(s.dw=this._dWidth),(e.has("height-abs")||e.has("height-scale"))&&(s.dh=this._dHeight),e.has("z"))&&(s.dz=this._dz),s}LoadFromJson(e){const t=e.m,s=this._propSet;if(s.clear(),this._pinUid=e.uid,"number"==typeof t)this._LoadFromJson_Legacy(e);else if(this._mode=t,e.hasOwnProperty("d")&&(this._destroy=!!e.d),"rope"===t||"bar"===t)this._pinDist=e.pd;else if("properties"===t){for(const i of e.ps)s.add(i);s.has("imagepoint")?this._pinImagePoint=e.ip:s.has("x")&&s.has("y")?(this._pinAngle=e.pa,this._pinDist=e.pd):(s.has("x")&&(this._dx=e.dx),s.has("y")&&(this._dy=e.dy)),s.has("angle")&&(this._dAngle=e.da,this._lastKnownAngle=e.lka||0),(s.has("width-abs")||s.has("width-scale"))&&(this._dWidth=e.dw),(s.has("height-abs")||s.has("height-scale"))&&(this._dHeight=e.dh),s.has("z")&&(this._dz=e.dz)}}_LoadFromJson_Legacy(e){const t=this._propSet,s=e.msa,i=e.tsa,r=e.pa,n=e.pd,a=e.m;switch(a){case 0:this._mode="properties",t.add("x").add("y").add("angle"),this._pinAngle=r,this._pinDist=n,this._dAngle=s-i,this._lastKnownAngle=e.lka;break;case 1:this._mode="properties",t.add("x").add("y"),this._pinAngle=r,this._pinDist=n;break;case 2:this._mode="properties",t.add("angle"),this._dAngle=s-i,this._lastKnownAngle=e.lka;break;case 3:this._mode="rope",this._pinDist=e.pd;break;case 4:this._mode="bar",this._pinDist=e.pd}}_OnAfterLoad(){-1===this._pinUid?this._SetPinInst(null):(this._SetPinInst(this._runtime.GetInstanceByUID(this._pinUid)),this._pinUid=-1)}_OnInstanceDestroyed(e){this._pinInst===e&&(this._SetPinInst(null),this._destroy)&&this._runtime.DestroyInstance(this._inst)}Tick2(){const n=this._pinInst;if(n&&!n.IsDestroyed()){let s=n.GetWorldInfo(),e=this._inst,i=e.GetWorldInfo(),t=this._mode,r=!1;if("rope"===t||"bar"===t){const a=g.distanceTo(i.GetX(),i.GetY(),s.GetX(),s.GetY());if(a>this._pinDist||"bar"===t&&a<this._pinDist){const o=g.angleTo(s.GetX(),s.GetY(),i.GetX(),i.GetY());i.SetXY(s.GetX()+Math.cos(o)*this._pinDist,s.GetY()+Math.sin(o)*this._pinDist),r=!0}}else{let e=this._propSet,t=0;if(e.has("imagepoint")){const[l,h]=n.GetImagePoint(this._pinImagePoint);i.EqualsXY(l,h)||(i.SetXY(l,h),r=!0)}else if(e.has("x")&&e.has("y")){const c=s.GetX()+Math.cos(s.GetAngle()+this._pinAngle)*this._pinDist,u=s.GetY()+Math.sin(s.GetAngle()+this._pinAngle)*this._pinDist;i.EqualsXY(c,u)||(i.SetXY(c,u),r=!0)}else t=s.GetX()+this._dx,e.has("x")&&t!==i.GetX()&&(i.SetX(t),r=!0),t=s.GetY()+this._dy,e.has("y")&&t!==i.GetY()&&(i.SetY(t),r=!0);e.has("angle")&&(this._lastKnownAngle!==i.GetAngle()&&(this._dAngle=g.clampAngle(this._dAngle+(i.GetAngle()-this._lastKnownAngle))),(t=g.clampAngle(s.GetAngle()+this._dAngle))!==i.GetAngle()&&(i.SetAngle(t),r=!0),this._lastKnownAngle=i.GetAngle()),e.has("width-abs")&&(t=s.GetWidth()+this._dWidth)!==i.GetWidth()&&(i.SetWidth(t),r=!0),e.has("width-scale")&&(t=s.GetWidth()*this._dWidth)!==i.GetWidth()&&(i.SetWidth(t),r=!0),e.has("height-abs")&&(t=s.GetHeight()+this._dHeight)!==i.GetHeight()&&(i.SetHeight(t),r=!0),e.has("height-scale")&&(t=s.GetHeight()*this._dHeight)!==i.GetHeight()&&(i.SetHeight(t),r=!0),e.has("z")&&(t=s.GetZElevation()+this._dz)!==i.GetZElevation()&&(i.SetZElevation(t),this._runtime.UpdateRender())}r&&i.SetBboxChanged()}}GetDebuggerProperties(){const e="behaviors.pin.debugger";return[{title:"$"+this.GetBehaviorType().GetName(),properties:[{name:e+".is-pinned",value:!!this._pinInst},{name:e+".pinned-uid",value:this._pinInst?this._pinInst.GetUID():0}]}]}}}{const $=self.C3;$.Behaviors.Pin.Cnds={IsPinned(){return!!this._pinInst},WillDestroy(){return this._destroy}}}{const _=self.C3;_.Behaviors.Pin.Acts={PinByDistance(e,t){this._Pin(e,0===t?"rope":"bar")},PinByProperties(e,t,s,i,r,n,a){const o=[];t&&o.push("x"),s&&o.push("y"),i&&o.push("angle"),a&&o.push("z"),1===r?o.push("width-abs"):2===r&&o.push("width-scale"),1===n?o.push("height-abs"):2===n&&o.push("height-scale"),0!==o.length&&this._Pin(e,"properties",o)},PinByImagePoint(e,t,s,i,r,n){const a=["imagepoint"];s&&a.push("angle"),n&&a.push("z"),1===i?a.push("width-abs"):2===i&&a.push("width-scale"),1===r?a.push("height-abs"):2===r&&a.push("height-scale"),this._pinImagePoint=t,this._Pin(e,"properties",a)},SetPinDistance(e){"rope"!==this._mode&&"bar"!==this._mode||(this._pinDist=Math.max(e,0))},SetDestroy(e){this._destroy=e},Unpin(){this._SetPinInst(null),this._mode="",this._propSet.clear(),this._pinImagePoint=""},Pin(e,t){switch(t){case 0:this._Pin(e,"properties",["x","y","angle"]);break;case 1:this._Pin(e,"properties",["x","y"]);break;case 2:this._Pin(e,"properties",["angle"]);break;case 3:this._Pin(e,"rope");break;case 4:this._Pin(e,"bar")}}}}{const va=self.C3;va.Behaviors.Pin.Exps={PinnedUID(){return this._pinInst?this._pinInst.GetUID():-1}}}{const a=self.C3;a.Behaviors.Bullet=class extends a.SDKBehaviorBase{constructor(e){super(e)}Release(){super.Release()}}}{const d=self.C3;d.Behaviors.Bullet.Type=class extends d.SDKBehaviorTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const g=self.C3,h=self.C3X,i=self.IBehaviorInstance,j=0,k=1,l=2,m=3,n=4,o=5,p=6,q=(g.Behaviors.Bullet.Instance=class extends g.SDKBehaviorInstanceBase{constructor(e,t){super(e);const s=this.GetWorldInfo(),i=(this._speed=0,this._acc=0,this._g=0,this._bounceOffSolid=!1,this._setAngle=!1,this._isStepping=!1,this._isEnabled=!0,this._dx=0,this._dy=0,this._lastX=s.GetX(),this._lastY=s.GetY(),this._lastKnownAngle=s.GetAngle(),this._travelled=0,this._stepSize=Math.min(Math.abs(s.GetWidth()),Math.abs(s.GetHeight())/2),this._stopStepping=!1,t&&(this._speed=t[j],this._acc=t[k],this._g=t[l],this._bounceOffSolid=!!t[m],this._setAngle=!!t[n],this._isStepping=!!t[o],this._isEnabled=!!t[p]),s.GetAngle());this._dx=Math.cos(i)*this._speed,this._dy=Math.sin(i)*this._speed,this._isEnabled&&(this._StartTicking(),this._bounceOffSolid)&&this._StartPostTicking()}Release(){super.Release()}SaveToJson(){const e={dx:this._dx,dy:this._dy,lx:this._lastX,ly:this._lastY,lka:this._lastKnownAngle,t:this._travelled};return 0!==this._acc&&(e.acc=this._acc),0!==this._g&&(e.g=this._g),this._isStepping&&(e.st=this._isStepping),this._isEnabled||(e.e=this._isEnabled),this._bounceOffSolid&&(e.bos=this._bounceOffSolid),this._setAngle&&(e.sa=this._setAngle),e}LoadFromJson(e){this._dx=e.dx,this._dy=e.dy,this._lastX=e.lx,this._lastY=e.ly,this._lastKnownAngle=e.lka,this._travelled=e.t,this._acc=e.hasOwnProperty("acc")?e.acc:0,this._g=e.hasOwnProperty("g")?e.g:0,this._isStepping=!!e.hasOwnProperty("st")&&e.st,this._bounceOffSolid=!!e.hasOwnProperty("bos")&&e.bos,this._setAngle=!!e.hasOwnProperty("sa")&&e.sa,this._SetEnabled(!e.hasOwnProperty("e")||e.e)}Tick(){if(this._isEnabled){const r=this._runtime.GetDt(this._inst),n=this._inst.GetWorldInfo();if(n.GetAngle()!==this._lastKnownAngle){const e=n.GetAngle();if(this._setAngle){const t=g.distanceTo(0,0,this._dx,this._dy);this._dx=Math.cos(e)*t,this._dy=Math.sin(e)*t}this._lastKnownAngle=e}let s=0,i=0;if(0!==this._acc){let e=g.distanceTo(0,0,this._dx,this._dy),t;t=0===this._dx&&0===this._dy?n.GetAngle():g.angleTo(0,0,this._dx,this._dy),e+=this._acc*r,s=Math.cos(t)*this._acc,i=Math.sin(t)*this._acc,e<0&&(e=0,s=0,i=0),this._dx=Math.cos(t)*e,this._dy=Math.sin(t)*e}if(0!==this._g&&(this._dy+=this._g*r,i+=this._g),this._lastX=n.GetX(),this._lastY=n.GetY(),0!==this._dx||0!==this._dy){const a=this._dx*r+.5*s*r*r,o=this._dy*r+.5*i*r*r,l=g.distanceTo(0,0,a,o);if(this._MoveBy(a,o,l),this._travelled+=l,this._setAngle&&(0!=a||0!=o)){const h=g.angleTo(0,0,a,o);n.SetAngle(h),this._lastKnownAngle=n.GetAngle()}n.SetBboxChanged()}}}_MoveBy(e,t,s){const i=this.GetWorldInfo();if(!this._isStepping||s<=this._stepSize)i.OffsetXY(e,t),i.SetBboxChanged(),this._isStepping&&this.Trigger(g.Behaviors.Bullet.Cnds.OnStep);else{this._stopStepping=!1;const r=i.GetX(),n=i.GetY(),a=r+e,o=n+t,l=g.angleTo(0,0,e,t),h=Math.cos(l)*this._stepSize,c=Math.sin(l)*this._stepSize,u=Math.floor(s/this._stepSize);for(let e=1;e<=u;++e)if(i.SetXY(r+h*e,n+c*e),i.SetBboxChanged(),this.Trigger(g.Behaviors.Bullet.Cnds.OnStep),this._inst.IsDestroyed()||this._stopStepping)return;i.SetXY(a,o),i.SetBboxChanged(),this.Trigger(g.Behaviors.Bullet.Cnds.OnStep)}}PostTick(){if(this._isEnabled&&this._bounceOffSolid&&(0!==this._dx||0!==this._dy)){const e=this._runtime.GetDt(this._inst),t=this._inst.GetWorldInfo(),s=this._runtime.GetCollisionEngine(),i=s.TestOverlapSolid(this._inst);if(i){s.RegisterCollision(this._inst,i);const r=g.distanceTo(0,0,this._dx,this._dy),n=s.CalculateBounceAngle(this._inst,this._lastX,this._lastY);this._dx=Math.cos(n)*r,this._dy=Math.sin(n)*r,t.OffsetXY(this._dx*e,this._dy*e),t.SetBboxChanged(),this._setAngle&&(t.SetAngle(n),this._lastKnownAngle=t.GetAngle(),t.SetBboxChanged()),s.PushOutSolid(this._inst,this._dx/r,this._dy/r,Math.max(2.5*r*e,30))||s.PushOutSolidNearest(this._inst,100)}}}GetPropertyValueByIndex(e){switch(e){case j:return this._GetSpeed();case k:return this._GetAcceleration();case l:return this._GetGravity();case n:return this._setAngle;case o:return this._isStepping;case p:return this._IsEnabled()}}SetPropertyValueByIndex(e,t){switch(e){case j:this._SetSpeed(t);break;case k:this._acc=t;break;case l:this._g=t;break;case n:this._setAngle=!!t;break;case o:this._isStepping=!!t;break;case p:this._SetEnabled(!!t)}}_SetSpeed(e){const t=g.angleTo(0,0,this._dx,this._dy);this._dx=Math.cos(t)*e,this._dy=Math.sin(t)*e}_GetSpeed(){return g.roundToDp(g.distanceTo(0,0,this._dx,this._dy),6)}_SetAcceleration(e){this._acc=e}_GetAcceleration(){return this._acc}_SetGravity(e){this._g=e}_GetGravity(){return this._g}_SetAngleOfMotion(e){const t=g.distanceTo(0,0,this._dx,this._dy);this._dx=Math.cos(e)*t,this._dy=Math.sin(e)*t}_GetAngleOfMotion(){return g.angleTo(0,0,this._dx,this._dy)}_SetBounceOffSolids(e){this._bounceOffSolid!==(e=!!e)&&(this._bounceOffSolid=e,this._isEnabled)&&(this._bounceOffSolid?this._StartPostTicking():this._StopPostTicking())}_IsBounceOffSolids(){return this._bounceOffSolid}_SetDistanceTravelled(e){this._travelled=e}_GetDistanceTravelled(){return this._travelled}_SetEnabled(e){this._isEnabled=!!e,this._isEnabled?(this._StartTicking(),this._bounceOffSolid&&this._StartPostTicking()):(this._StopTicking(),this._StopPostTicking())}_IsEnabled(){return this._isEnabled}GetDebuggerProperties(){const e="behaviors.bullet";return[{title:"$"+this.GetBehaviorType().GetName(),properties:[{name:e+".debugger.vector-x",value:this._dx,onedit:e=>this._dx=e},{name:e+".debugger.vector-y",value:this._dy,onedit:e=>this._dy=e},{name:e+".properties.speed.name",value:this._GetSpeed(),onedit:e=>this._SetSpeed(e)},{name:e+".debugger.angle-of-motion",value:g.toDegrees(this._GetAngleOfMotion())},{name:e+".properties.gravity.name",value:this._GetGravity(),onedit:e=>this._SetGravity(e)},{name:e+".properties.acceleration.name",value:this._GetAcceleration(),onedit:e=>this._SetAcceleration(e)},{name:e+".debugger.distance-travelled",value:this._GetDistanceTravelled()},{name:e+".properties.enabled.name",value:this._IsEnabled(),onedit:e=>this._SetEnabled(e)}]}]}GetScriptInterfaceClass(){return self.IBulletBehaviorInstance}},new WeakMap);self.IBulletBehaviorInstance=class extends i{constructor(){super(),q.set(this,i._GetInitInst().GetSdkInstance())}get speed(){return q.get(this)._GetSpeed()}set speed(e){h.RequireFiniteNumber(e),q.get(this)._SetSpeed(e)}get acceleration(){return q.get(this)._GetAcceleration()}set acceleration(e){h.RequireFiniteNumber(e),q.get(this)._SetAcceleration(e)}get gravity(){return q.get(this)._GetGravity()}set gravity(e){h.RequireFiniteNumber(e),q.get(this)._SetGravity(e)}get angleOfMotion(){return q.get(this)._GetAngleOfMotion()}set angleOfMotion(e){h.RequireFiniteNumber(e),q.get(this)._SetAngleOfMotion(e)}get bounceOffSolids(){return q.get(this)._IsBounceOffSolids()}set bounceOffSolids(e){q.get(this)._SetBounceOffSolids(!!e)}get distanceTravelled(){return q.get(this)._GetDistanceTravelled()}set distanceTravelled(e){h.RequireFiniteNumber(e),q.get(this)._SetDistanceTravelled(e)}get isEnabled(){return q.get(this)._IsEnabled()}set isEnabled(e){q.get(this)._SetEnabled(e)}}}{const Ca=self.C3;Ca.Behaviors.Bullet.Cnds={CompareSpeed(e,t){const s=Math.hypot(this._dx,this._dy);return Ca.compare(s,e,t)},CompareTravelled(e,t){return Ca.compare(this._GetDistanceTravelled(),e,t)},OnStep(){return!0},IsEnabled(){return this._IsEnabled()}}}{const Ia=self.C3;Ia.Behaviors.Bullet.Acts={SetSpeed(e){this._SetSpeed(e)},SetAcceleration(e){this._SetAcceleration(e)},SetGravity(e){this._SetGravity(e)},SetAngleOfMotion(e){this._SetAngleOfMotion(Ia.toRadians(e))},Bounce(e){if(e){const t=e.GetFirstPicked(this._inst);if(t){const s=this._inst.GetWorldInfo(),i=this._runtime.GetCollisionEngine(),r=this._runtime.GetDt(this._inst),n=Ia.distanceTo(0,0,this._dx,this._dy),a=i.CalculateBounceAngle(this._inst,this._lastX,this._lastY,t);this._dx=Math.cos(a)*n,this._dy=Math.sin(a)*n,s.OffsetXY(this._dx*r,this._dy*r),s.SetBboxChanged(),this._setAngle&&(s.SetAngle(a),this._lastKnownAngle=s.GetAngle(),s.SetBboxChanged()),0!==n&&(this._bounceOffSolid?i.PushOutSolid(this._inst,this._dx/n,this._dy/n,Math.max(2.5*n*r,30))||i.PushOutSolidNearest(this._inst,100):i.PushOut(this._inst,this._dx/n,this._dy/n,Math.max(2.5*n*r,30),t))}}},SetBounceOffSolids(e){this._SetBounceOffSolids(e)},SetDistanceTravelled(e){this._SetDistanceTravelled(e)},SetEnabled(e){this._SetEnabled(e)},StopStepping(){this._stopStepping=!0}}}{const Xa=self.C3;Xa.Behaviors.Bullet.Exps={Speed(){return this._GetSpeed()},Acceleration(){return this._GetAcceleration()},AngleOfMotion(){return Xa.toDegrees(this._GetAngleOfMotion())},DistanceTravelled(){return this._GetDistanceTravelled()},Gravity(){return this._GetGravity()}}}{let unaryminus2=function(e){return"number"==typeof e?-e:e},bothNumbers2=function(e,t){return"number"==typeof e&&"number"==typeof t},add2=function(e,t){return bothNumbers2(e,t)?e+t:e},subtract2=function(e,t){return bothNumbers2(e,t)?e-t:e},multiply2=function(e,t){return bothNumbers2(e,t)?e*t:e},divide2=function(e,t){return bothNumbers2(e,t)?e/t:e},mod2=function(e,t){return bothNumbers2(e,t)?e%t:e},pow2=function(e,t){return bothNumbers2(e,t)?Math.pow(e,t):e},and2=function(s,i){if("string"!=typeof s&&"string"!=typeof i)return s&&i?1:0;{let e,t;return e="number"==typeof s?(Math.round(1e10*s)/1e10).toString():s,t="number"==typeof i?(Math.round(1e10*i)/1e10).toString():i,e+t}},or2=function(e,t){return bothNumbers2(e,t)?e||t?1:0:e};unaryminus=unaryminus2,bothNumbers=bothNumbers2,add=add2,subtract=subtract2,multiply=multiply2,divide=divide2,mod=mod2,pow=pow2,and=and2,or=or2;const C33=self.C3;self.C3_ExpressionFuncs=[()=>1,()=>0,()=>560,()=>12,e=>{const t=e._GetNode(0).GetVar();return()=>25+5*t.GetValue()},e=>{const t=e._GetNode(0).GetVar();return()=>t.GetValue()},e=>{const t=e._GetNode(0).GetVar();return()=>t.GetValue()/5},e=>{const t=e._GetNode(0).GetVar();return()=>and2("Type_",t.GetValue())},e=>{const t=e._GetNode(0).GetVar();return()=>and2("LEVEL-",t.GetValue())},()=>960,()=>2e3,()=>880,()=>1030,()=>1230,()=>750,()=>890,()=>1170,e=>{const t=e._GetNode(0).GetVar(),s=e._GetNode(1).GetVar();return()=>and2(and2("LIFE:",t.GetValue())+"/",s.GetValue())},e=>{const t=e._GetNode(0).GetVar();return()=>and2("LEVEL ",t.GetValue())+"/30"},e=>{const t=e._GetNode(0).GetVar(),s=e._GetNode(1).GetVar();return()=>t.GetValue()*(600/s.GetValue())},e=>{const t=e._GetNode(0);return()=>t.ExpObject()+14},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t()},e=>{const t=e._GetNode(0);return()=>t.ExpObject()},()=>"StartGame_Settings",()=>"Sound",()=>"Levels_Settings",()=>"Level-1",()=>"Player",()=>"",()=>5,()=>15,()=>.5,()=>25,()=>35,()=>45,()=>50,()=>55,()=>70,()=>80,()=>90,()=>100,()=>120,()=>140,()=>"Level-2",()=>2,()=>7,()=>10,()=>20,()=>33,()=>160,()=>"Level-3",()=>3,()=>30,()=>60,()=>65,()=>75,()=>85,()=>110,()=>130,()=>155,()=>"Level-4",()=>4,()=>32,()=>40,()=>44,()=>48,()=>52,()=>56,()=>165,()=>170,()=>180,()=>"Level-5",()=>115,()=>125,()=>135,()=>145,()=>"Level-6",()=>6,()=>24,()=>28,()=>36,()=>83,()=>86,()=>89,()=>92,()=>105,()=>132,()=>134,()=>136,()=>138,()=>142,()=>144,()=>146,()=>"Level-7",()=>150,()=>175,()=>"Level-8",()=>8,()=>"Level-9",()=>9,()=>95,()=>"Level-10",()=>"Level-11",()=>11,()=>16,()=>34,()=>42,()=>54,()=>64,()=>68,()=>72,()=>74,()=>78,()=>87,()=>"Level-12",()=>14,()=>18,()=>23,()=>76,()=>94,()=>96,()=>106,()=>"Level-13",()=>13,()=>38,()=>47,()=>57,()=>62,()=>"Level-14",()=>26,()=>46,()=>67,()=>73,()=>82,()=>104,()=>108,()=>112,()=>118,()=>122,()=>"Level-15",()=>"Level-16",()=>66,()=>84,()=>88,()=>98,()=>102,()=>"Level-17",()=>17,()=>58,()=>91,()=>97,()=>"Level-18",()=>21,()=>27,()=>59,()=>63,()=>71,()=>79,()=>133,()=>168,()=>171,()=>174,()=>177,()=>184,()=>190,()=>195,()=>200,()=>"Level-19",()=>19,()=>53,()=>141,()=>148,()=>151,()=>154,()=>157,()=>"Level-20",()=>77,()=>173,()=>176,()=>"Level-21",()=>81,()=>93,()=>99,()=>185,()=>191,()=>192,()=>193,()=>194,()=>196,()=>197,()=>205,()=>"Level-22",()=>22,()=>121,()=>124,()=>127,()=>158,()=>161,()=>164,()=>169,()=>"Level-23",()=>167,()=>182,()=>210,()=>215,()=>"Level-24",()=>159,()=>204,()=>208,()=>212,()=>216,()=>220,()=>224,()=>229,()=>235,()=>245,()=>250,()=>"Level-25",()=>"Level-26",()=>188,()=>"Level-27",()=>103,()=>111,()=>116,()=>162,()=>166,()=>178,()=>186,()=>198,()=>202,()=>206,()=>"Level-28",()=>109,()=>113,()=>123,()=>128,()=>137,()=>153,()=>203,()=>230,()=>"Level-29",()=>29,()=>39,()=>117,()=>143,()=>149,()=>199,()=>201,()=>228,()=>232,()=>236,()=>240,()=>"Level-30",()=>152,()=>156,()=>172,()=>244,()=>252,()=>256,()=>260,()=>264,()=>268,()=>272,()=>276,()=>280,()=>284,()=>288,()=>292,()=>304,()=>308,()=>312,()=>316,()=>320,()=>324,()=>328,()=>332,()=>336,()=>340,()=>344,()=>348,()=>352,()=>356,()=>360,()=>362,()=>"Fortress_Settings",e=>{const t=e._GetNode(0).GetVar();return()=>t.GetValue()/2},e=>{const t=e._GetNode(0).GetVar();return()=>t.GetValue()/4},e=>{const t=e._GetNode(0).GetVar();return()=>and2("LIFE:0/",t.GetValue())},()=>"FinalDefense_Coins",()=>"FinalDefense_Level",()=>"Shadow_In_Settings",()=>"Shadow_In",()=>"Score_Settings",()=>.02,()=>-5,()=>"Explosion_Settings",()=>"Enemy_Settings",e=>{const t=e._GetNode(0).GetBoundMethod();return()=>Math.round(t(0,1e13))},()=>"Back",e=>{const t=e._GetNode(0);return()=>t.ExpInstVar_Family()},e=>{const t=e._GetNode(0),s=e._GetNode(1).GetBoundMethod(),i=e._GetNode(2);return()=>t.ExpInstVar_Family()+s(i.ExpInstVar_Family()/10)},()=>"Top",e=>{const t=e._GetNode(0),s=e._GetNode(1);return()=>t.ExpInstVar_Family()+2*s.ExpInstVar()},e=>{const t=e._GetNode(0),s=e._GetNode(1);return()=>t.ExpObject()+2*s.ExpInstVar()},e=>{const t=e._GetNode(0),s=e._GetNode(1),i=e._GetNode(2);return()=>t.ExpObject()-(s.ExpObject()/2+i.ExpInstVar())},e=>{const t=e._GetNode(0),s=e._GetNode(1),i=e._GetNode(2);return()=>t.ExpObject()-(s.ExpObject()+i.ExpObject()/5)},e=>{const t=e._GetNode(0),s=e._GetNode(1);return()=>t.ExpObject()-s.ExpObject()/2},e=>{const t=e._GetNode(0);return()=>t.ExpInstVar()},()=>"Death",e=>{const t=e._GetNode(0),s=e._GetNode(1);return()=>t.ExpInstVar_Family()*s.ExpInstVar_Family()},e=>{const t=e._GetNode(0).GetVar();return()=>600/t.GetValue()},e=>{const t=e._GetNode(0);return()=>t.ExpInstVar_Family()/2},()=>"Walk",()=>"Run",()=>"Fly",()=>"Attack",e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(360)},()=>"Archers_Settings",()=>"AttackSpeed_Settings",e=>{const t=e._GetNode(0),s=e._GetNode(1);return()=>t.ExpObject()+s.ExpInstVar_Family()},e=>{const t=e._GetNode(0),s=e._GetNode(1);return()=>t.ExpObject()+2*s.ExpInstVar_Family()},()=>"ArchersSpeed_Settings",e=>{const t=e._GetNode(0).GetVar();return()=>2*t.GetValue()},()=>.25,e=>{const t=e._GetNode(0).GetVar();return()=>and2("EXP:",Math.round(t.GetValue()/5.6))+"%"},()=>"Magic_Settings",()=>"Freeze_Settings",()=>.3,()=>"Freeze",e=>{const t=e._GetNode(0),s=e._GetNode(1),i=e._GetNode(2).GetVar();return()=>t.ExpObject()-s.ExpInstVar()/i.GetValue()},()=>"Fire_Settings",()=>"Fire",e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetBoundMethod();return()=>t()+s(-200,200)},e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetBoundMethod(),i=e._GetNode(2).GetBoundMethod();return()=>t()-s()+i(-200,200)},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(.2,.6)},()=>"Lightining_Settings",()=>"Lightning",()=>500,e=>{const t=e._GetNode(0),s=e._GetNode(1).GetBoundMethod();return()=>t.ExpObject()+30*s()},e=>{const t=e._GetNode(0),s=e._GetNode(1).GetBoundMethod();return()=>t.ExpObject()+35*s()},()=>"ShowLayer_Settings",()=>"HideLayer_Settings",()=>"Gui",()=>"FinalDefense_Score",()=>"FinalDefense_Arrows",()=>"FinalDefense_Archers",()=>"FinalDefense_Archer_1",()=>"FinalDefense_Archer_2",()=>"FinalDefense_Archer_3",()=>"FinalDefense_FortressType",()=>"FinalDefense_FreezeMagicType",()=>"FinalDefense_FireMagicType",()=>"FinalDefense_LightningMagicType",()=>"Audio_Settings",e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t()+"Sound_Status"},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t()+"Music_Status"},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t()+"Sound_Volume"},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t()+"Music_Volume"},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t()+"Sound"},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t()+"Music"},e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1),i=e._GetNode(2).GetBoundMethod(),r=e._GetNode(3),n=e._GetNode(4).GetVar(),a=e._GetNode(5).GetVar(),o=e._GetNode(6).GetVar();return()=>(t(s.ExpObject())+i(r.ExpObject()))/2-(n.GetValue()*a.GetValue()-o.GetValue()/2)},e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1),i=e._GetNode(2).GetBoundMethod(),r=e._GetNode(3),n=e._GetNode(4).GetVar();return()=>(t(s.ExpObject())+i(r.ExpObject()))/2-n.GetValue()/2},e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetBoundMethod(),i=e._GetNode(2),r=e._GetNode(3).GetVar(),n=e._GetNode(4).GetVar(),a=e._GetNode(5).GetVar();return()=>t()/2+s(i.ExpObject())-(r.GetValue()*n.GetValue()-a.GetValue()/2)},e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetBoundMethod(),i=e._GetNode(2),r=e._GetNode(3).GetVar();return()=>t()/2+s(i.ExpObject())-r.GetValue()/2},()=>-100,()=>"Shadow_Out_Settings",e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetBoundMethod(),i=e._GetNode(2),r=e._GetNode(3).GetVar(),n=e._GetNode(4).GetVar(),a=e._GetNode(5).GetBoundMethod(),o=e._GetNode(6),l=e._GetNode(7).GetBoundMethod(),h=e._GetNode(8),c=e._GetNode(9).GetVar(),u=e._GetNode(10).GetBoundMethod(),_=e._GetNode(11),d=e._GetNode(12).GetBoundMethod(),p=e._GetNode(13),m=e._GetNode(14).GetVar();return()=>C33.clamp(Math.round((t()+s(i.ExpObject()))/(r.GetValue()/100))*(n.GetValue()/100),(a(o.ExpObject())+l(h.ExpObject()))/2-c.GetValue()/2,(u(_.ExpObject())+d(p.ExpObject()))/2+m.GetValue()/2)},e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1),i=e._GetNode(2).GetBoundMethod(),r=e._GetNode(3),n=e._GetNode(4).GetBoundMethod(),a=e._GetNode(5),o=e._GetNode(6),l=e._GetNode(7).GetVar();return()=>((t(s.ExpObject())+i(r.ExpObject()))/2+n(a.ExpObject())-o.ExpObject())/l.GetValue()+.5},e=>{const t=e._GetNode(0).GetVar();return()=>Math.ceil(t.GetValue())},e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetVar(),i=e._GetNode(2).GetBoundMethod();return()=>t(s.GetValue())/i(2)*10},()=>"Music",e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetVar(),i=e._GetNode(2).GetVar(),r=e._GetNode(3).GetBoundMethod(),n=e._GetNode(4).GetBoundMethod(),a=e._GetNode(5),o=e._GetNode(6).GetVar(),l=e._GetNode(7).GetBoundMethod(),h=e._GetNode(8).GetBoundMethod(),c=e._GetNode(9),u=e._GetNode(10).GetVar();return()=>C33.clamp(Math.round(t()/(s.GetValue()/100))*(i.GetValue()/100),r()/2+n(a.ExpObject())-o.GetValue()/2,l()/2+h(c.ExpObject())+u.GetValue()/2)},e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetBoundMethod(),i=e._GetNode(2),r=e._GetNode(3),n=e._GetNode(4).GetVar();return()=>(t()/2+s(i.ExpObject())-r.ExpObject())/n.GetValue()+.5},e=>{const t=e._GetNode(0),s=e._GetNode(1),i=e._GetNode(2),r=e._GetNode(3);return()=>C33.distanceTo(t.ExpObject(),s.ExpObject(),i.ExpObject(),r.ExpObject())},()=>"Buttons_Settings",()=>"Exit_Settings",()=>"Fullscreen_Settings",()=>"FulLscreenON",()=>"FulLscreenOFF",()=>"Mouse_Settings",()=>358.397892,()=>153.798996,()=>249.142983,()=>118.767085,()=>"Pause_Settings",()=>961.5,()=>567,()=>390,()=>464,()=>470,()=>580,()=>770,()=>683,()=>690,()=>820,()=>861,()=>1100,()=>"Settings",()=>1.5,()=>.03,e=>{const t=e._GetNode(0).GetBoundMethod();return()=>C33.lerp(t("Settings"),100,.25)},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>C33.lerp(t("Settings"),1,.25)},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>C33.lerp(t("Gui"),0,.25)},()=>.01,e=>{const t=e._GetNode(0).GetBoundMethod();return()=>C33.lerp(t("Settings"),0,.25)},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>C33.lerp(t("Settings"),1.5,.25)},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>C33.lerp(t("Gui"),100,.25)},()=>"GameOver_Settings",()=>1e6,()=>"LevelsMenu_Settings",()=>"UpgradesMenu_Settings",()=>"Arrows",()=>800,()=>1400,()=>2500,()=>3800,()=>6200,()=>1200,()=>"Archer_1",()=>5e3,()=>"Archer_2",()=>6e3,()=>7500,()=>9e3,()=>"Archer_3",()=>8e3,()=>9500,()=>"Fortress",()=>300,()=>400,()=>350,()=>700,()=>2800,()=>1600,()=>3200,()=>"800",()=>"1400",()=>"2500",()=>"3800",()=>"6200",()=>"MAX",()=>"5000",()=>"6000",()=>"7500",()=>"9000",()=>"8000",()=>"9500",()=>"350",()=>"700",()=>"2800",()=>"200",()=>"300",()=>"400",()=>"500",()=>"1600",()=>"3200",()=>"InfoMenu_Settings",()=>"Name",()=>"GOBLIN WARRIOR",()=>"Life",()=>"Speed",()=>"MEDIUM",()=>"Damage",()=>"1%",()=>"Armour",()=>"NONE",()=>"Reward",()=>"Number",()=>"1/39",()=>"GOBLIN FLYING BOMBER",()=>"FAST",()=>"3%",()=>"2/39",()=>"GOBLIN HOG RIDER",()=>"2%",()=>"3/39",()=>"GOBLIN ARCHER",()=>"4/39",()=>"GOBLIN SHAMAN",()=>"5/39",()=>"GOBLIN CYCLOPS - BOSS",()=>"SLOW",()=>"10%",()=>"HARD",()=>1e3,()=>"6/39",()=>"ZOMBIE",()=>"LOW",()=>"7/39",()=>"8/39",()=>"9/39",()=>"BIG ZOMBIE",()=>"10/39",()=>"11/39",()=>"BIG ZOMBIE - BOSS",()=>"15%",()=>1500,()=>"12/39",()=>"FLY ENEMY",()=>"13/39",()=>"14/39",()=>"15/39",()=>"16/39",()=>"17/39",()=>"18/39",()=>"19/39",()=>"20/39",()=>"21/39",()=>"22/39",()=>"SKELETON WARRIORS",()=>"23/39",()=>"SKELETON WARRIOR",()=>"24/39",()=>"SKELETON BAT SWORD",()=>"25/39",()=>"SKELETON ONAGER",()=>"5%",()=>"26/39",()=>"SKELETON SHIELD MAN",()=>"4%",()=>"27/39",()=>"SKELETON BOMBER",()=>"28/39",()=>"SKELETON HOG RIDER",()=>"29/39",()=>"SKELETON SPEAR MAN",()=>"30/39",()=>"SKELETON WITCH",()=>"31/39",()=>31,()=>"SKELETON GIANT",()=>"32/39",()=>"SKELETON ARCHER",()=>"33/39",()=>"SKELETON BAT BOMB",()=>"34/39",()=>"SKELETON DEAD WITCH",()=>"35/39",()=>"SKELETON YETI - BOSS",()=>"8%",()=>"36/39",()=>"SKELETON STONE - BOSS",()=>600,()=>"20%",()=>3e3,()=>"37/39",()=>37,()=>"SKELETON DRAGON - BOSS",()=>"25%",()=>"38/39",()=>"SKELETON BIG - BOSS",()=>"30%",()=>3500,()=>"39/39",()=>"Shadow",()=>"Shadow_Settings",e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t("Shadow")+6},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t("Shadow")-6},()=>"Shadow_Out"]}}}),import_c3runtime=__toESM(require_c3runtime()),C32=self.C3;self.C3_GetObjectRefTable=function(){return[C32.Plugins.Sprite,C32.Plugins.TiledBg,C32.Behaviors.Fade,C32.Behaviors.Sin,C32.Plugins.Audio,C32.Plugins.Browser,C32.Plugins.Keyboard,C32.Plugins.Mouse,C32.Plugins.Touch,C32.Plugins.LocalStorage,C32.Plugins.Spritefont2,C32.Behaviors.Pin,C32.Plugins.NinePatch,C32.Plugins.AJAX,C32.Plugins.Json,C32.Plugins.Particles,C32.Behaviors.Bullet,C32.Plugins.System.Cnds.OnLayoutStart,C32.Plugins.System.Acts.SetVar,C32.Plugins.Sprite.Acts.SetAnimFrame,C32.Plugins.Sprite.Acts.SetAnim,C32.Plugins.Spritefont2.Acts.SetText,C32.Plugins.Sprite.Acts.SetPos,C32.Plugins.Spritefont2.Acts.SetPos,C32.Plugins.Sprite.Acts.SetY,C32.Plugins.Sprite.Cnds.CompareInstanceVar,C32.Plugins.Sprite.Acts.SetBoolInstanceVar,C32.Plugins.Sprite.Acts.SetVisible,C32.Plugins.System.Cnds.EveryTick,C32.Plugins.System.Cnds.CompareVar,C32.Plugins.TiledBg.Acts.SetWidth,C32.Plugins.Sprite.Exps.Y,C32.Plugins.Sprite.Acts.SetInstanceVar,C32.Plugins.Mouse.Cnds.IsOverObject,C32.Plugins.Sprite.Cnds.IsBoolInstanceVarSet,C32.Plugins.Sprite.Acts.SetTowardPosition,C32.Plugins.Mouse.Exps.X,C32.Plugins.Mouse.Exps.Y,C32.Plugins.Sprite.Exps.X,C32.Plugins.System.Cnds.IsGroupActive,C32.Plugins.Touch.Cnds.OnTouchObject,C32.Behaviors.Sin.Cnds.IsEnabled,C32.Plugins.Audio.Acts.Play,C32.Behaviors.Fade.Acts.StartFade,C32.Behaviors.Sin.Acts.SetEnabled,C32.Plugins.Sprite.Cnds.OnDestroyed,C32.Plugins.Sprite.Acts.SetAnimSpeed,C32.Plugins.System.Cnds.Every,C32.Plugins.System.Acts.AddVar,C32.Plugins.Sprite.Acts.Spawn,C32.Plugins.System.Acts.Wait,C32.Plugins.Sprite.Acts.StopAnim,C32.Plugins.Sprite.Acts.Destroy,C32.Plugins.LocalStorage.Acts.SetItem,C32.Plugins.System.Acts.SetGroupActive,C32.Plugins.System.Acts.WaitForSignal,C32.Plugins.System.Acts.GoToLayout,C32.Plugins.Sprite.Cnds.OnAnyAnimFinished,C32.Plugins.Sprite.Cnds.OnCreated,C32.Plugins.System.Exps.random,C32.Behaviors.Pin.Acts.Pin,C32.Plugins.Sprite.Acts.SetSize,C32.Plugins.NinePatch.Acts.SetWidth,C32.Plugins.NinePatch.Acts.SetHeight,C32.Plugins.NinePatch.Exps.Height,C32.Plugins.NinePatch.Acts.SetX,C32.Plugins.NinePatch.Exps.Width,C32.Plugins.NinePatch.Acts.SetY,C32.Plugins.Sprite.Exps.Height,C32.Plugins.NinePatch.Acts.SetInstanceVar,C32.Plugins.Sprite.Cnds.OnCollision,C32.Plugins.Sprite.Cnds.IsAnimPlaying,C32.Plugins.Sprite.Cnds.CompareX,C32.Plugins.Sprite.Acts.SubInstanceVar,C32.Plugins.NinePatch.Cnds.CompareInstanceVar,C32.Plugins.NinePatch.Acts.Destroy,C32.Plugins.Sprite.Cnds.OnAnimFinished,C32.Plugins.System.Acts.SubVar,C32.Plugins.Sprite.Cnds.CompareFrame,C32.Plugins.Sprite.Acts.SetAngle,C32.Plugins.Touch.Cnds.IsTouchingObject,C32.Plugins.Touch.Exps.X,C32.Plugins.Touch.Exps.Y,C32.Plugins.Sprite.Acts.StartAnim,C32.Plugins.Sprite.Cnds.IsOutsideLayout,C32.Plugins.System.Acts.SetTimescale,C32.Plugins.Sprite.Acts.SetX,C32.Plugins.TiledBg.Cnds.CompareInstanceVar,C32.Plugins.Spritefont2.Cnds.CompareInstanceVar,C32.Plugins.System.Acts.CreateObject,C32.Plugins.TiledBg.Acts.SetVisible,C32.Plugins.Spritefont2.Acts.SetVisible,C32.Plugins.Sprite.Cnds.IsOverlapping,C32.Plugins.TiledBg.Acts.SetHeight,C32.Plugins.TiledBg.Exps.Height,C32.Plugins.System.Exps.windowheight,C32.Plugins.TiledBg.Acts.SetImageOffsetX,C32.Plugins.TiledBg.Exps.ImageOffsetX,C32.Plugins.System.Exps.dt,C32.Plugins.System.Acts.SetLayerOpacity,C32.Plugins.LocalStorage.Acts.CheckItemExists,C32.Plugins.LocalStorage.Cnds.OnItemExists,C32.Plugins.LocalStorage.Exps.ItemValue,C32.Plugins.System.Exps.projectname,C32.Plugins.LocalStorage.Cnds.OnItemMissing,C32.Plugins.System.Exps.viewportleft,C32.Plugins.Sprite.Exps.LayerName,C32.Plugins.System.Exps.viewportright,C32.Plugins.System.Exps.originalwindowwidth,C32.Plugins.LocalStorage.Cnds.IsProcessingGets,C32.Plugins.System.Exps.log10,C32.Plugins.Audio.Acts.SetVolume,C32.Plugins.Sprite.Acts.SetWidth,C32.Plugins.System.Cnds.Else,C32.Plugins.System.Acts.RestartLayout,C32.Plugins.Browser.Acts.Close,C32.Plugins.Browser.Acts.RequestFullScreen,C32.Plugins.Browser.Acts.CancelFullScreen,C32.Plugins.Mouse.Cnds.IsButtonDown,C32.Plugins.Mouse.Acts.SetCursorSprite,C32.Plugins.Sprite.Cnds.CompareAnimSpeed,C32.Plugins.System.Cnds.TriggerOnce,C32.Plugins.System.Acts.SetLayerScale,C32.Plugins.System.Exps.layeropacity,C32.Plugins.System.Exps.layerscale,C32.Plugins.Sprite.Acts.SetPosToObject,C32.Plugins.Audio.Acts.StopAll,C32.Plugins.System.Cnds.LayerCmpOpacity,C32.Plugins.System.Acts.Signal,C32.Plugins.Mouse.Cnds.OnRelease,C32.Plugins.Touch.Cnds.OnTapGestureObject]},self.C3_JsPropNameTable=[{Cursor:0},{CursorHover:0},{Name:0},{AudioLine:0},{FramePaused:0},{FrameAudio:0},{SliderMusic:0},{FrameSound:0},{SliderSound:0},{FrameMusic:0},{BarGui:0},{EnemyGui:0},{ClosedBarGui:0},{EnemyLineGui:0},{ExpGui:0},{ExpLineGui:0},{LifeBarGui:0},{LifeGui:0},{BarLine:0},{CoinsGui:0},{MagicName:0},{Size:0},{MagicShadow:0},{CoinsLine:0},{Fade:0},{LevelFrame:0},{ArmourGui:0},{SpeedGui:0},{NumberGui:0},{Sine:0},{Selector:0},{LevelBackgrounds:0},{GameLogo:0},{Fortress:0},{Backgrounds:0},{Audio:0},{Browser:0},{Keyboard:0},{Mouse:0},{Touch:0},{LocalStorage:0},{Explosion_1:0},{Explosion_2:0},{Explosion_3:0},{Explosion_4:0},{Explosion_5:0},{Explosion_6:0},{Fire:0},{DragonFire:0},{Blood:0},{EnemiesCollFX_1:0},{EnemiesCollFX_2:0},{FireBall:0},{fire_wall:0},{LightningSpell:0},{Active:0},{Move:0},{ID:0},{ArchersBow:0},{ArchersAim:0},{ArchersHand:0},{Archer_1Head:0},{Archer_1Body:0},{Shadow:0},{Archer_2Body:0},{Archer_3Body:0},{Archer_2Head:0},{Archer_3Head:0},{Archer_1Head2:0},{Archer_2Head2:0},{ExpFont:0},{LifeFont:0},{MagicTimeFont:0},{CoinsFont:0},{LevelFont:0},{MusicFont:0},{SoundFont:0},{LoadingFont:0},{InfoFont:0},{GameOverFont:0},{ItemName:0},{UpgradesFont:0},{BuyFont:0},{EnemiesNumberFont:0},{TextLevelFont:0},{notenough:0},{BtnExit:0},{BtnFullscreen:0},{BtnPlay:0},{BtnMenu:0},{BtnMusic:0},{BtnPause:0},{BtnReload:0},{BtnReturn:0},{BtnSound:0},{BtnStart:0},{BtnGo:0},{BtnRestart:0},{BtnUpgrades:0},{BtnArcherSpeed:0},{BtnAttackSpeed:0},{Touched:0},{Level:0},{ButtonLevels:0},{BtnFireMagic:0},{BtnFreezeMagic:0},{BtnLightingMagic:0},{BtnHome:0},{BtnLeft:0},{BtnRight:0},{Life:0},{LifeRate:0},{Speed:0},{Damage:0},{Reward:0},{CollWidth:0},{CollHeight:0},{FlyEnemy_01:0},{FlyEnemy_02:0},{FlyEnemy_03:0},{FlyEnemy_04:0},{FlyEnemy_05:0},{FlyEnemy_06:0},{FlyEnemy_07:0},{FlyEnemy_08:0},{FlyEnemy_09:0},{FlyEnemy_10:0},{SkeletonDeadWitch:0},{SkeletonDragon:0},{GoblinArcher:0},{GoblinCyclops:0},{GoblinFlyingBomber:0},{GoblinHogRider:0},{GoblinShaman:0},{GoblinWarior:0},{SkeletonHogRider:0},{SkeletonArcher:0},{SkeletonWariors:0},{SkeletonYeti:0},{Zombie_1:0},{Zombie_2:0},{Zombie_3:0},{Zombie_4:0},{Zombie_5:0},{Zombie_6:0},{SkeletonBatBomb:0},{SkeletonBatSword:0},{SkeletonBigBoss:0},{SkeletonBomber:0},{SkeletonGiant:0},{SkeletonOnager:0},{SkeletonShieldMan:0},{SkeletonSpearMan:0},{SkeletonStone:0},{SkeletonWarrior:0},{SkeletonWitch:0},{EnemySpawn_1:0},{EnemySpawn_2:0},{EnemySpawn_3:0},{EnemySpawn_4:0},{EnemySpawn_5:0},{TouchArea:0},{EnemySpawn_6:0},{EnemySpawn_7:0},{EnemySpawn_8:0},{FortressCollision:0},{AimArea:0},{Pin:0},{EnemiesColl:0},{EnemiesLife:0},{EnemiesLifeBack:0},{FrameWidthPixels:0},{EnemiesLifeFrame:0},{MagicArea:0},{ArrowDark:0},{ArrowFire:0},{ArrowIce:0},{ArrowIron:0},{ArrowLight:0},{ArrowPoison:0},{TextTapToPlay:0},{TextPaused:0},{TextGameInfo:0},{TextDefeat:0},{TextGameResults:0},{TextUpgrades:0},{TextLevels:0},{TextYouWon:0},{BoxShopping:0},{BuyArcher_1:0},{BuyArcher_2:0},{BuyArcher_3:0},{BuyArrows:0},{OptionBox:0},{BtnBuy:0},{BuyFortress:0},{BuyFireBallMagic:0},{BuyFreezeMagic:0},{BuyLightingMagic:0},{UpgradesLineArchers:0},{UpgradesLineArrows:0},{UpgradesLineFortress:0},{UpgradesLineMagic:0},{AJAX:0},{JSON:0},{back:0},{HTP:0},{Frame_change:0},{NEXT:0},{Tutorial_bg:0},{cloud:0},{Fireflies:0},{fog:0},{long_grass_tuft_2_bright_green:0},{menu_enemy:0},{rewter:0},{rxtytrfyd:0},{water:0},{bush_2_bright_green:0},{Buttons:0},{TextFonts:0},{Enemies:0},{Archers:0},{Bullet:0},{Arrows:0},{EnemiesFrame:0},{Score:0},{EnemiesNumber:0},{EnemiesNumberCurrent:0},{FireMagicType:0},{FireMagicTime:0},{FireMagicTimeCurrent:0},{FreezeMagicType:0},{FreezeMagicTime:0},{FreezeMagicTimeCurrent:0},{LightningMagicType:0},{LightningMagicTime:0},{LightningMagicTimeCurrent:0},{LevelStars:0},{AttackSpeed:0},{EnemiesID:0},{EnemiesWave:0},{Archer_1:0},{Archer_2:0},{Archer_3:0},{ArchersExp:0},{ArchersSpeed:0},{FortressLife:0},{FortressType:0},{FortressLifeCurrent:0},{Timer:0},{Coins:0},{BestScore:0},{CountCoins:0},{EnemiesType:0},{Pause:0},{Fullscreen:0},{Sound:0},{Sound_Status:0},{Sound_Volume:0},{Music:0},{Music_Status:0},{Music_Volume:0},{Audio_Line_Width:0}],self.InstanceType={Cursor:class extends self.ISpriteInstance{},CursorHover:class extends self.ISpriteInstance{},AudioLine:class extends self.ISpriteInstance{},FramePaused:class extends self.ISpriteInstance{},FrameAudio:class extends self.ISpriteInstance{},SliderMusic:class extends self.ISpriteInstance{},FrameSound:class extends self.ISpriteInstance{},SliderSound:class extends self.ISpriteInstance{},FrameMusic:class extends self.ISpriteInstance{},BarGui:class extends self.ITiledBackgroundInstance{},EnemyGui:class extends self.ISpriteInstance{},ClosedBarGui:class extends self.ISpriteInstance{},EnemyLineGui:class extends self.ITiledBackgroundInstance{},ExpGui:class extends self.ISpriteInstance{},ExpLineGui:class extends self.ITiledBackgroundInstance{},LifeBarGui:class extends self.ITiledBackgroundInstance{},LifeGui:class extends self.ISpriteInstance{},BarLine:class extends self.ISpriteInstance{},CoinsGui:class extends self.ISpriteInstance{},MagicShadow:class extends self.ITiledBackgroundInstance{},CoinsLine:class extends self.ITiledBackgroundInstance{},LevelFrame:class extends self.ISpriteInstance{},ArmourGui:class extends self.ISpriteInstance{},SpeedGui:class extends self.ISpriteInstance{},NumberGui:class extends self.ISpriteInstance{},Selector:class extends self.ISpriteInstance{},LevelBackgrounds:class extends self.ISpriteInstance{},GameLogo:class extends self.ISpriteInstance{},Fortress:class extends self.ISpriteInstance{},Backgrounds:class extends self.ISpriteInstance{},Audio:class extends self.IInstance{},Browser:class extends self.IInstance{},Keyboard:class extends self.IInstance{},Mouse:class extends self.IInstance{},Touch:class extends self.IInstance{},LocalStorage:class extends self.IInstance{},Explosion_1:class extends self.ISpriteInstance{},Explosion_2:class extends self.ISpriteInstance{},Explosion_3:class extends self.ISpriteInstance{},Explosion_4:class extends self.ISpriteInstance{},Explosion_5:class extends self.ISpriteInstance{},Explosion_6:class extends self.ISpriteInstance{},Fire:class extends self.ISpriteInstance{},DragonFire:class extends self.ISpriteInstance{},Blood:class extends self.ISpriteInstance{},EnemiesCollFX_1:class extends self.ISpriteInstance{},EnemiesCollFX_2:class extends self.ISpriteInstance{},FireBall:class extends self.ISpriteInstance{},fire_wall:class extends self.ISpriteInstance{},LightningSpell:class extends self.ISpriteInstance{},ArchersBow:class extends self.ISpriteInstance{},ArchersAim:class extends self.ISpriteInstance{},ArchersHand:class extends self.ISpriteInstance{},Archer_1Head:class extends self.ISpriteInstance{},Archer_1Body:class extends self.ISpriteInstance{},Shadow:class extends self.ISpriteInstance{},Archer_2Body:class extends self.ISpriteInstance{},Archer_3Body:class extends self.ISpriteInstance{},Archer_2Head:class extends self.ISpriteInstance{},Archer_3Head:class extends self.ISpriteInstance{},Archer_1Head2:class extends self.ISpriteInstance{},Archer_2Head2:class extends self.ISpriteInstance{},ExpFont:class extends self.ISpriteFontInstance{},LifeFont:class extends self.ISpriteFontInstance{},MagicTimeFont:class extends self.ISpriteFontInstance{},CoinsFont:class extends self.ISpriteFontInstance{},LevelFont:class extends self.ISpriteFontInstance{},MusicFont:class extends self.ISpriteFontInstance{},SoundFont:class extends self.ISpriteFontInstance{},LoadingFont:class extends self.ISpriteFontInstance{},InfoFont:class extends self.ISpriteFontInstance{},GameOverFont:class extends self.ISpriteFontInstance{},UpgradesFont:class extends self.ISpriteFontInstance{},BuyFont:class extends self.ISpriteFontInstance{},EnemiesNumberFont:class extends self.ISpriteFontInstance{},TextLevelFont:class extends self.ISpriteFontInstance{},notenough:class extends self.ISpriteFontInstance{},BtnExit:class extends self.ISpriteInstance{},BtnFullscreen:class extends self.ISpriteInstance{},BtnPlay:class extends self.ISpriteInstance{},BtnMenu:class extends self.ISpriteInstance{},BtnMusic:class extends self.ISpriteInstance{},BtnPause:class extends self.ISpriteInstance{},BtnReload:class extends self.ISpriteInstance{},BtnReturn:class extends self.ISpriteInstance{},BtnSound:class extends self.ISpriteInstance{},BtnStart:class extends self.ISpriteInstance{},BtnGo:class extends self.ISpriteInstance{},BtnRestart:class extends self.ISpriteInstance{},BtnUpgrades:class extends self.ISpriteInstance{},BtnArcherSpeed:class extends self.ISpriteInstance{},BtnAttackSpeed:class extends self.ISpriteInstance{},ButtonLevels:class extends self.ISpriteInstance{},BtnFireMagic:class extends self.ISpriteInstance{},BtnFreezeMagic:class extends self.ISpriteInstance{},BtnLightingMagic:class extends self.ISpriteInstance{},BtnHome:class extends self.ISpriteInstance{},BtnLeft:class extends self.ISpriteInstance{},BtnRight:class extends self.ISpriteInstance{},FlyEnemy_01:class extends self.ISpriteInstance{},FlyEnemy_02:class extends self.ISpriteInstance{},FlyEnemy_03:class extends self.ISpriteInstance{},FlyEnemy_04:class extends self.ISpriteInstance{},FlyEnemy_05:class extends self.ISpriteInstance{},FlyEnemy_06:class extends self.ISpriteInstance{},FlyEnemy_07:class extends self.ISpriteInstance{},FlyEnemy_08:class extends self.ISpriteInstance{},FlyEnemy_09:class extends self.ISpriteInstance{},FlyEnemy_10:class extends self.ISpriteInstance{},SkeletonDeadWitch:class extends self.ISpriteInstance{},SkeletonDragon:class extends self.ISpriteInstance{},GoblinArcher:class extends self.ISpriteInstance{},GoblinCyclops:class extends self.ISpriteInstance{},GoblinFlyingBomber:class extends self.ISpriteInstance{},GoblinHogRider:class extends self.ISpriteInstance{},GoblinShaman:class extends self.ISpriteInstance{},GoblinWarior:class extends self.ISpriteInstance{},SkeletonHogRider:class extends self.ISpriteInstance{},SkeletonArcher:class extends self.ISpriteInstance{},SkeletonWariors:class extends self.ISpriteInstance{},SkeletonYeti:class extends self.ISpriteInstance{},Zombie_1:class extends self.ISpriteInstance{},Zombie_2:class extends self.ISpriteInstance{},Zombie_3:class extends self.ISpriteInstance{},Zombie_4:class extends self.ISpriteInstance{},Zombie_5:class extends self.ISpriteInstance{},Zombie_6:class extends self.ISpriteInstance{},SkeletonBatBomb:class extends self.ISpriteInstance{},SkeletonBatSword:class extends self.ISpriteInstance{},SkeletonBigBoss:class extends self.ISpriteInstance{},SkeletonBomber:class extends self.ISpriteInstance{},SkeletonGiant:class extends self.ISpriteInstance{},SkeletonOnager:class extends self.ISpriteInstance{},SkeletonShieldMan:class extends self.ISpriteInstance{},SkeletonSpearMan:class extends self.ISpriteInstance{},SkeletonStone:class extends self.ISpriteInstance{},SkeletonWarrior:class extends self.ISpriteInstance{},SkeletonWitch:class extends self.ISpriteInstance{},EnemySpawn_1:class extends self.ISpriteInstance{},EnemySpawn_2:class extends self.ISpriteInstance{},EnemySpawn_3:class extends self.ISpriteInstance{},EnemySpawn_4:class extends self.ISpriteInstance{},EnemySpawn_5:class extends self.ISpriteInstance{},TouchArea:class extends self.ISpriteInstance{},EnemySpawn_6:class extends self.ISpriteInstance{},EnemySpawn_7:class extends self.ISpriteInstance{},EnemySpawn_8:class extends self.ISpriteInstance{},FortressCollision:class extends self.ISpriteInstance{},AimArea:class extends self.ISpriteInstance{},EnemiesColl:class extends self.ISpriteInstance{},EnemiesLife:class extends self.IWorldInstance{},EnemiesLifeBack:class extends self.IWorldInstance{},EnemiesLifeFrame:class extends self.IWorldInstance{},MagicArea:class extends self.ISpriteInstance{},ArrowDark:class extends self.ISpriteInstance{},ArrowFire:class extends self.ISpriteInstance{},ArrowIce:class extends self.ISpriteInstance{},ArrowIron:class extends self.ISpriteInstance{},ArrowLight:class extends self.ISpriteInstance{},ArrowPoison:class extends self.ISpriteInstance{},TextTapToPlay:class extends self.ISpriteInstance{},TextPaused:class extends self.ISpriteInstance{},TextGameInfo:class extends self.ISpriteInstance{},TextDefeat:class extends self.ISpriteInstance{},TextGameResults:class extends self.ISpriteInstance{},TextUpgrades:class extends self.ISpriteInstance{},TextLevels:class extends self.ISpriteInstance{},TextYouWon:class extends self.ISpriteInstance{},BoxShopping:class extends self.ISpriteInstance{},BuyArcher_1:class extends self.ISpriteInstance{},BuyArcher_2:class extends self.ISpriteInstance{},BuyArcher_3:class extends self.ISpriteInstance{},BuyArrows:class extends self.ISpriteInstance{},OptionBox:class extends self.ISpriteInstance{},BtnBuy:class extends self.ISpriteInstance{},BuyFortress:class extends self.ISpriteInstance{},BuyFireBallMagic:class extends self.ISpriteInstance{},BuyFreezeMagic:class extends self.ISpriteInstance{},BuyLightingMagic:class extends self.ISpriteInstance{},UpgradesLineArchers:class extends self.ISpriteInstance{},UpgradesLineArrows:class extends self.ISpriteInstance{},UpgradesLineFortress:class extends self.ISpriteInstance{},UpgradesLineMagic:class extends self.ISpriteInstance{},AJAX:class extends self.IInstance{},JSON:class extends self.IJSONInstance{},back:class extends self.ISpriteInstance{},HTP:class extends self.ISpriteInstance{},NEXT:class extends self.ISpriteInstance{},Tutorial_bg:class extends self.ISpriteInstance{},cloud:class extends self.ITiledBackgroundInstance{},Fireflies:class extends self.IParticlesInstance{},fog:class extends self.ITiledBackgroundInstance{},long_grass_tuft_2_bright_green:class extends self.ISpriteInstance{},menu_enemy:class extends self.ISpriteInstance{},rewter:class extends self.ISpriteInstance{},rxtytrfyd:class extends self.ISpriteInstance{},water:class extends self.ISpriteInstance{},bush_2_bright_green:class extends self.ISpriteInstance{},Buttons:class extends self.ISpriteInstance{},TextFonts:class extends self.ISpriteInstance{},Enemies:class extends self.ISpriteInstance{},Archers:class extends self.ISpriteInstance{},Arrows:class extends self.ISpriteInstance{},EnemiesFrame:class extends self.IWorldInstance{}}; home/jogoso94/public_html/jogos/join_food_chain/scripts/c3main.js 0000644 00000000064 15043151026 0021100 0 ustar 00 import "./c3runtime.js"; import "./objRefTable.js";
| ver. 1.4 |
Github
|
.
| PHP 8.2.29 | Генераци� �траницы: 0.26 |
proxy
|
phpinfo
|
�а�тройка