import "./../gamezop.js"; // 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,__commonJS=(e,t)=>function(){return t||(0,e[__getOwnPropNames(e)[0]])((t={exports:{}}).exports,t),t.exports},__copyProps=(e,t,s,i)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let n of __getOwnPropNames(t))__hasOwnProp.call(e,n)||n===s||__defProp(e,n,{get:()=>t[n],enumerable:!(i=__getOwnPropDesc(t,n))||i.enumerable});return e},__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 e=function(e){ARRAY_TYPE=e},n=function(e){return e*degree},h=function(e,t){return Math.abs(e-t)<=EPSILON*Math.max(1,Math.abs(e),Math.abs(t))},u=function(){var e=new ARRAY_TYPE(4);return ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e},_=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},p=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},g=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e},m=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},S=function(e,t,s,i,n){return e[0]=t,e[1]=s,e[2]=i,e[3]=n,e},G=function(e,t){if(e===t){var s=t[1];e[1]=t[2],e[2]=s}else e[0]=t[0],e[1]=t[2],e[2]=t[1],e[3]=t[3];return e},y=function(e,t){var s=t[0],i=t[1],n=t[2],r=t[3],a=s*r-n*i;return a?(a=1/a,e[0]=r*a,e[1]=-i*a,e[2]=-n*a,e[3]=s*a,e):null},I=function(e,t){var s=t[0];return e[0]=t[3],e[1]=-t[1],e[2]=-t[2],e[3]=s,e},T=function(e){return e[0]*e[3]-e[2]*e[1]},C=function(e,t,s){var i=t[0],n=t[1],r=t[2],a=t[3],o=s[0],h=s[1],l=s[2],c=s[3];return e[0]=i*o+r*h,e[1]=n*o+a*h,e[2]=i*l+r*c,e[3]=n*l+a*c,e},b=function(e,t,s){var i=t[0],n=t[1],r=t[2],a=t[3],o=Math.sin(s),h=Math.cos(s);return e[0]=i*h+r*o,e[1]=n*h+a*o,e[2]=i*-o+r*h,e[3]=n*-o+a*h,e},w=function(e,t,s){var i=t[0],n=t[1],r=t[2],a=t[3],o=s[0],h=s[1];return e[0]=i*o,e[1]=n*o,e[2]=r*h,e[3]=a*h,e},P=function(e,t){var s=Math.sin(t),i=Math.cos(t);return e[0]=i,e[1]=s,e[2]=-s,e[3]=i,e},x=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=t[1],e},v=function(e){return"mat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},A=function(e){return Math.hypot(e[0],e[1],e[2],e[3])},R=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]},M=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},D=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},E=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]},F=function(e,t){var s=e[0],i=e[1],n=e[2],r=e[3],a=t[0],o=t[1],h=t[2],l=t[3];return Math.abs(s-a)<=EPSILON*Math.max(1,Math.abs(s),Math.abs(a))&&Math.abs(i-o)<=EPSILON*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(n-h)<=EPSILON*Math.max(1,Math.abs(n),Math.abs(h))&&Math.abs(r-l)<=EPSILON*Math.max(1,Math.abs(r),Math.abs(l))},O=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},B=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},L=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},k=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},N=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},W=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e},V=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},U=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},j=function(e,t){var s=t[0],i=t[1],n=t[2],r=t[3],a=t[4],o=t[5],h=s*r-i*n;return h?(h=1/h,e[0]=r*h,e[1]=-i*h,e[2]=-n*h,e[3]=s*h,e[4]=(n*o-r*a)*h,e[5]=(i*a-s*o)*h,e):null},H=function(e){return e[0]*e[3]-e[1]*e[2]},z=function(e,t,s){var i=t[0],n=t[1],r=t[2],a=t[3],o=t[4],h=t[5],l=s[0],c=s[1],u=s[2],d=s[3],_=s[4],p=s[5];return e[0]=i*l+r*c,e[1]=n*l+a*c,e[2]=i*u+r*d,e[3]=n*u+a*d,e[4]=i*_+r*p+o,e[5]=n*_+a*p+h,e},X=function(e,t,s){var i=t[0],n=t[1],r=t[2],a=t[3],o=t[4],h=t[5],l=Math.sin(s),c=Math.cos(s);return e[0]=i*c+r*l,e[1]=n*c+a*l,e[2]=i*-l+r*c,e[3]=n*-l+a*c,e[4]=o,e[5]=h,e},Y=function(e,t,s){var i=t[0],n=t[1],r=t[2],a=t[3],o=t[4],h=t[5],l=s[0],c=s[1];return e[0]=i*l,e[1]=n*l,e[2]=r*c,e[3]=a*c,e[4]=o,e[5]=h,e},q=function(e,t,s){var i=t[0],n=t[1],r=t[2],a=t[3],o=t[4],h=t[5],l=s[0],c=s[1];return e[0]=i,e[1]=n,e[2]=r,e[3]=a,e[4]=i*l+r*c+o,e[5]=n*l+a*c+h,e},K=function(e,t){var s=Math.sin(t),i=Math.cos(t);return e[0]=i,e[1]=s,e[2]=-s,e[3]=i,e[4]=0,e[5]=0,e},$=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},J=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},Z=function(e){return"mat2d("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+")"},Q=function(e){return Math.hypot(e[0],e[1],e[2],e[3],e[4],e[5],1)},ee=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},te=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},se=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},ie=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},ne=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]},re=function(e,t){var s=e[0],i=e[1],n=e[2],r=e[3],a=e[4],o=e[5],h=t[0],l=t[1],c=t[2],u=t[3],d=t[4],_=t[5];return Math.abs(s-h)<=EPSILON*Math.max(1,Math.abs(s),Math.abs(h))&&Math.abs(i-l)<=EPSILON*Math.max(1,Math.abs(i),Math.abs(l))&&Math.abs(n-c)<=EPSILON*Math.max(1,Math.abs(n),Math.abs(c))&&Math.abs(r-u)<=EPSILON*Math.max(1,Math.abs(r),Math.abs(u))&&Math.abs(a-d)<=EPSILON*Math.max(1,Math.abs(a),Math.abs(d))&&Math.abs(o-_)<=EPSILON*Math.max(1,Math.abs(o),Math.abs(_))},ae=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},oe=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},he=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},le=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},ce=function(e,t,s,i,n,r,a,o,h){var l=new ARRAY_TYPE(9);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[8]=h,l},ue=function(e,t,s,i,n,r,a,o,h,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]=h,e[8]=l,e},de=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},_e=function(e,t){if(e===t){var 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}else 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];return e},pe=function(e,t){var s=t[0],i=t[1],n=t[2],r=t[3],a=t[4],o=t[5],h=t[6],l=t[7],c=t[8],u=c*a-o*l,d=-c*r+o*h,_=l*r-a*h,p=s*u+i*d+n*_;return p?(p=1/p,e[0]=u*p,e[1]=(-c*i+n*l)*p,e[2]=(o*i-n*a)*p,e[3]=d*p,e[4]=(c*s-n*h)*p,e[5]=(-o*s+n*r)*p,e[6]=_*p,e[7]=(-l*s+i*h)*p,e[8]=(a*s-i*r)*p,e):null},ge=function(e,t){var s=t[0],i=t[1],n=t[2],r=t[3],a=t[4],o=t[5],h=t[6],l=t[7],c=t[8];return e[0]=a*c-o*l,e[1]=n*l-i*c,e[2]=i*o-n*a,e[3]=o*h-r*c,e[4]=s*c-n*h,e[5]=n*r-s*o,e[6]=r*l-a*h,e[7]=i*h-s*l,e[8]=s*a-i*r,e},me=function(e){var t=e[0],s=e[1],i=e[2],n=e[3],r=e[4],a=e[5],o=e[6],h=e[7],l=e[8];return t*(l*r-a*h)+s*(-l*n+a*o)+i*(h*n-r*o)},fe=function(e,t,s){var i=t[0],n=t[1],r=t[2],a=t[3],o=t[4],h=t[5],l=t[6],c=t[7],u=t[8],d=s[0],_=s[1],p=s[2],g=s[3],m=s[4],f=s[5],S=s[6],G=s[7],y=s[8];return e[0]=d*i+_*a+p*l,e[1]=d*n+_*o+p*c,e[2]=d*r+_*h+p*u,e[3]=g*i+m*a+f*l,e[4]=g*n+m*o+f*c,e[5]=g*r+m*h+f*u,e[6]=S*i+G*a+y*l,e[7]=S*n+G*o+y*c,e[8]=S*r+G*h+y*u,e},Se=function(e,t,s){var i=t[0],n=t[1],r=t[2],a=t[3],o=t[4],h=t[5],l=t[6],c=t[7],u=t[8],d=s[0],_=s[1];return e[0]=i,e[1]=n,e[2]=r,e[3]=a,e[4]=o,e[5]=h,e[6]=d*i+_*a+l,e[7]=d*n+_*o+c,e[8]=d*r+_*h+u,e},Ge=function(e,t,s){var i=t[0],n=t[1],r=t[2],a=t[3],o=t[4],h=t[5],l=t[6],c=t[7],u=t[8],d=Math.sin(s),_=Math.cos(s);return e[0]=_*i+d*a,e[1]=_*n+d*o,e[2]=_*r+d*h,e[3]=_*a-d*i,e[4]=_*o-d*n,e[5]=_*h-d*r,e[6]=l,e[7]=c,e[8]=u,e},ye=function(e,t,s){var i=s[0],n=s[1];return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=n*t[3],e[4]=n*t[4],e[5]=n*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e},Ie=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},Te=function(e,t){var s=Math.sin(t),i=Math.cos(t);return e[0]=i,e[1]=s,e[2]=0,e[3]=-s,e[4]=i,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},Ce=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},be=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},we=function(e,t){var s=t[0],i=t[1],n=t[2],r=t[3],a=s+s,o=i+i,h=n+n,l=s*a,c=i*a,u=i*o,d=n*a,_=n*o,p=n*h,g=r*a,m=r*o,f=r*h;return e[0]=1-u-p,e[3]=c-f,e[6]=d+m,e[1]=c+f,e[4]=1-l-p,e[7]=_-g,e[2]=d-m,e[5]=_+g,e[8]=1-l-u,e},Pe=function(e,t){var s=t[0],i=t[1],n=t[2],r=t[3],a=t[4],o=t[5],h=t[6],l=t[7],c=t[8],u=t[9],d=t[10],_=t[11],p=t[12],g=t[13],m=t[14],f=t[15],S=s*o-i*a,G=s*h-n*a,y=s*l-r*a,I=i*h-n*o,T=i*l-r*o,C=n*l-r*h,b=c*g-u*p,w=c*m-d*p,P=c*f-_*p,x=u*m-d*g,v=u*f-_*g,A=d*f-_*m,R=S*A-G*v+y*x+I*P-T*w+C*b;return R?(R=1/R,e[0]=(o*A-h*v+l*x)*R,e[1]=(h*P-a*A-l*w)*R,e[2]=(a*v-o*P+l*b)*R,e[3]=(n*v-i*A-r*x)*R,e[4]=(s*A-n*P+r*w)*R,e[5]=(i*P-s*v-r*b)*R,e[6]=(g*C-m*T+f*I)*R,e[7]=(m*y-p*C-f*G)*R,e[8]=(p*T-g*y+f*S)*R,e):null},xe=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},ve=function(e){return"mat3("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+")"},Ae=function(e){return Math.hypot(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},Re=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},Me=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},De=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},Ee=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},Fe=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]},Oe=function(e,t){var s=e[0],i=e[1],n=e[2],r=e[3],a=e[4],o=e[5],h=e[6],l=e[7],c=e[8],u=t[0],d=t[1],_=t[2],p=t[3],g=t[4],m=t[5],f=t[6],S=t[7],G=t[8];return Math.abs(s-u)<=EPSILON*Math.max(1,Math.abs(s),Math.abs(u))&&Math.abs(i-d)<=EPSILON*Math.max(1,Math.abs(i),Math.abs(d))&&Math.abs(n-_)<=EPSILON*Math.max(1,Math.abs(n),Math.abs(_))&&Math.abs(r-p)<=EPSILON*Math.max(1,Math.abs(r),Math.abs(p))&&Math.abs(a-g)<=EPSILON*Math.max(1,Math.abs(a),Math.abs(g))&&Math.abs(o-m)<=EPSILON*Math.max(1,Math.abs(o),Math.abs(m))&&Math.abs(h-f)<=EPSILON*Math.max(1,Math.abs(h),Math.abs(f))&&Math.abs(l-S)<=EPSILON*Math.max(1,Math.abs(l),Math.abs(S))&&Math.abs(c-G)<=EPSILON*Math.max(1,Math.abs(c),Math.abs(G))},Be=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},Le=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},ke=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},Ne=function(e,t,s,i,n,r,a,o,h,l,c,u,d,_,p,g){var m=new ARRAY_TYPE(16);return m[0]=e,m[1]=t,m[2]=s,m[3]=i,m[4]=n,m[5]=r,m[6]=a,m[7]=o,m[8]=h,m[9]=l,m[10]=c,m[11]=u,m[12]=d,m[13]=_,m[14]=p,m[15]=g,m},We=function(e,t,s,i,n,r,a,o,h,l,c,u,d,_,p,g,m){return e[0]=t,e[1]=s,e[2]=i,e[3]=n,e[4]=r,e[5]=a,e[6]=o,e[7]=h,e[8]=l,e[9]=c,e[10]=u,e[11]=d,e[12]=_,e[13]=p,e[14]=g,e[15]=m,e},Ve=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},Ue=function(e,t){if(e===t){var 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}else 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];return e},je=function(e,t){var s=t[0],i=t[1],n=t[2],r=t[3],a=t[4],o=t[5],h=t[6],l=t[7],c=t[8],u=t[9],d=t[10],_=t[11],p=t[12],g=t[13],m=t[14],f=t[15],S=s*o-i*a,G=s*h-n*a,y=s*l-r*a,I=i*h-n*o,T=i*l-r*o,C=n*l-r*h,b=c*g-u*p,w=c*m-d*p,P=c*f-_*p,x=u*m-d*g,v=u*f-_*g,A=d*f-_*m,R=S*A-G*v+y*x+I*P-T*w+C*b;return R?(R=1/R,e[0]=(o*A-h*v+l*x)*R,e[1]=(n*v-i*A-r*x)*R,e[2]=(g*C-m*T+f*I)*R,e[3]=(d*T-u*C-_*I)*R,e[4]=(h*P-a*A-l*w)*R,e[5]=(s*A-n*P+r*w)*R,e[6]=(m*y-p*C-f*G)*R,e[7]=(c*C-d*y+_*G)*R,e[8]=(a*v-o*P+l*b)*R,e[9]=(i*P-s*v-r*b)*R,e[10]=(p*T-g*y+f*S)*R,e[11]=(u*y-c*T-_*S)*R,e[12]=(o*w-a*x-h*b)*R,e[13]=(s*x-i*w+n*b)*R,e[14]=(g*G-p*I-m*S)*R,e[15]=(c*I-u*G+d*S)*R,e):null},He=function(e,t){var s=t[0],i=t[1],n=t[2],r=t[3],a=t[4],o=t[5],h=t[6],l=t[7],c=t[8],u=t[9],d=t[10],_=t[11],p=t[12],g=t[13],m=t[14],f=t[15],S=s*o-i*a,G=s*h-n*a,y=s*l-r*a,I=i*h-n*o,T=i*l-r*o,C=n*l-r*h,b=c*g-u*p,w=c*m-d*p,P=c*f-_*p,x=u*m-d*g,v=u*f-_*g,A=d*f-_*m;return e[0]=o*A-h*v+l*x,e[1]=n*v-i*A-r*x,e[2]=g*C-m*T+f*I,e[3]=d*T-u*C-_*I,e[4]=h*P-a*A-l*w,e[5]=s*A-n*P+r*w,e[6]=m*y-p*C-f*G,e[7]=c*C-d*y+_*G,e[8]=a*v-o*P+l*b,e[9]=i*P-s*v-r*b,e[10]=p*T-g*y+f*S,e[11]=u*y-c*T-_*S,e[12]=o*w-a*x-h*b,e[13]=s*x-i*w+n*b,e[14]=g*G-p*I-m*S,e[15]=c*I-u*G+d*S,e},ze=function(e){var t=e[0],s=e[1],i=e[2],n=e[3],r=e[4],a=e[5],o=e[6],h=e[7],l=e[8],c=e[9],u=e[10],d=e[11],_=e[12],p=e[13],g=e[14],m=t*a-s*r,f=t*o-i*r,S=s*o-i*a,G=l*p-c*_,y=l*g-u*_,I=c*g-u*p;return h*(t*I-s*y+i*G)-n*(r*I-a*y+o*G)+e[15]*(l*S-c*f+u*m)-d*(_*S-p*f+g*m)},Xe=function(e,t,s){var i=t[0],n=t[1],r=t[2],a=t[3],o=t[4],h=t[5],l=t[6],c=t[7],u=t[8],d=t[9],_=t[10],p=t[11],g=t[12],m=t[13],f=t[14],S=t[15],G=s[0],y=s[1],I=s[2],T=s[3];return e[0]=G*i+y*o+I*u+T*g,e[1]=G*n+y*h+I*d+T*m,e[2]=G*r+y*l+I*_+T*f,e[3]=G*a+y*c+I*p+T*S,G=s[4],y=s[5],I=s[6],T=s[7],e[4]=G*i+y*o+I*u+T*g,e[5]=G*n+y*h+I*d+T*m,e[6]=G*r+y*l+I*_+T*f,e[7]=G*a+y*c+I*p+T*S,G=s[8],y=s[9],I=s[10],T=s[11],e[8]=G*i+y*o+I*u+T*g,e[9]=G*n+y*h+I*d+T*m,e[10]=G*r+y*l+I*_+T*f,e[11]=G*a+y*c+I*p+T*S,G=s[12],y=s[13],I=s[14],T=s[15],e[12]=G*i+y*o+I*u+T*g,e[13]=G*n+y*h+I*d+T*m,e[14]=G*r+y*l+I*_+T*f,e[15]=G*a+y*c+I*p+T*S,e},Ye=function(e,t,s){var i,n,r,a,o,h,l,c,u,d,_,p,g=s[0],m=s[1],f=s[2];return t===e?(e[12]=t[0]*g+t[4]*m+t[8]*f+t[12],e[13]=t[1]*g+t[5]*m+t[9]*f+t[13],e[14]=t[2]*g+t[6]*m+t[10]*f+t[14],e[15]=t[3]*g+t[7]*m+t[11]*f+t[15]):(i=t[0],n=t[1],r=t[2],a=t[3],o=t[4],h=t[5],l=t[6],c=t[7],u=t[8],d=t[9],_=t[10],p=t[11],e[0]=i,e[1]=n,e[2]=r,e[3]=a,e[4]=o,e[5]=h,e[6]=l,e[7]=c,e[8]=u,e[9]=d,e[10]=_,e[11]=p,e[12]=i*g+o*m+u*f+t[12],e[13]=n*g+h*m+d*f+t[13],e[14]=r*g+l*m+_*f+t[14],e[15]=a*g+c*m+p*f+t[15]),e},qe=function(e,t,s){var i=s[0],n=s[1],r=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]*r,e[9]=t[9]*r,e[10]=t[10]*r,e[11]=t[11]*r,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},Ke=function(e,t,s,i){var n,r,a,o,h,l,c,u,d,_,p,g,m,f,S,G,y,I,T,C,b,w,P,x,v=i[0],A=i[1],R=i[2],M=Math.hypot(v,A,R);return M0?(s[0]=2*(o*a+c*i+h*r-l*n)/u,s[1]=2*(h*a+c*n+l*i-o*r)/u,s[2]=2*(l*a+c*r+o*n-h*i)/u):(s[0]=2*(o*a+c*i+h*r-l*n),s[1]=2*(h*a+c*n+l*i-o*r),s[2]=2*(l*a+c*r+o*n-h*i)),rt(e,t,s),e},ot=function(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e},ht=function(e,t){var s=t[0],i=t[1],n=t[2],r=t[4],a=t[5],o=t[6],h=t[8],l=t[9],c=t[10];return e[0]=Math.hypot(s,i,n),e[1]=Math.hypot(r,a,o),e[2]=Math.hypot(h,l,c),e},lt=function(e,t){var s=new ARRAY_TYPE(3);ht(s,t);var i=1/s[0],n=1/s[1],r=1/s[2],a=t[0]*i,o=t[1]*n,h=t[2]*r,l=t[4]*i,c=t[5]*n,u=t[6]*r,d=t[8]*i,_=t[9]*n,p=t[10]*r,g=a+c+p,m=0;return g>0?(m=2*Math.sqrt(g+1),e[3]=.25*m,e[0]=(u-_)/m,e[1]=(d-h)/m,e[2]=(o-l)/m):a>c&&a>p?(m=2*Math.sqrt(1+a-c-p),e[3]=(u-_)/m,e[0]=.25*m,e[1]=(o+l)/m,e[2]=(d+h)/m):c>p?(m=2*Math.sqrt(1+c-a-p),e[3]=(d-h)/m,e[0]=(o+l)/m,e[1]=.25*m,e[2]=(u+_)/m):(m=2*Math.sqrt(1+p-a-c),e[3]=(o-l)/m,e[0]=(d+h)/m,e[1]=(u+_)/m,e[2]=.25*m),e},ct=function(e,t,s,i){t[0]=i[12],t[1]=i[13],t[2]=i[14];var n=i[0],r=i[1],a=i[2],o=i[4],h=i[5],l=i[6],c=i[8],u=i[9],d=i[10];s[0]=Math.hypot(n,r,a),s[1]=Math.hypot(o,h,l),s[2]=Math.hypot(c,u,d);var _=1/s[0],p=1/s[1],g=1/s[2],m=n*_,f=r*p,S=a*g,G=o*_,y=h*p,I=l*g,T=c*_,C=u*p,b=d*g,w=m+y+b,P=0;return w>0?(P=2*Math.sqrt(w+1),e[3]=.25*P,e[0]=(I-C)/P,e[1]=(T-S)/P,e[2]=(f-G)/P):m>y&&m>b?(P=2*Math.sqrt(1+m-y-b),e[3]=(I-C)/P,e[0]=.25*P,e[1]=(f+G)/P,e[2]=(T+S)/P):y>b?(P=2*Math.sqrt(1+y-m-b),e[3]=(T-S)/P,e[0]=(f+G)/P,e[1]=.25*P,e[2]=(I+C)/P):(P=2*Math.sqrt(1+b-m-y),e[3]=(f-G)/P,e[0]=(T+S)/P,e[1]=(I+C)/P,e[2]=.25*P),e},ut=function(e,t,s,i){var n=t[0],r=t[1],a=t[2],o=t[3],h=n+n,l=r+r,c=a+a,u=n*h,d=n*l,_=n*c,p=r*l,g=r*c,m=a*c,f=o*h,S=o*l,G=o*c,y=i[0],I=i[1],T=i[2];return e[0]=(1-(p+m))*y,e[1]=(d+G)*y,e[2]=(_-S)*y,e[3]=0,e[4]=(d-G)*I,e[5]=(1-(u+m))*I,e[6]=(g+f)*I,e[7]=0,e[8]=(_+S)*T,e[9]=(g-f)*T,e[10]=(1-(u+p))*T,e[11]=0,e[12]=s[0],e[13]=s[1],e[14]=s[2],e[15]=1,e},dt=function(e,t,s,i,n){var r=t[0],a=t[1],o=t[2],h=t[3],l=r+r,c=a+a,u=o+o,d=r*l,_=r*c,p=r*u,g=a*c,m=a*u,f=o*u,S=h*l,G=h*c,y=h*u,I=i[0],T=i[1],C=i[2],b=n[0],w=n[1],P=n[2],x=(1-(g+f))*I,v=(_+y)*I,A=(p-G)*I,R=(_-y)*T,M=(1-(d+f))*T,D=(m+S)*T,E=(p+G)*C,F=(m-S)*C,O=(1-(d+g))*C;return e[0]=x,e[1]=v,e[2]=A,e[3]=0,e[4]=R,e[5]=M,e[6]=D,e[7]=0,e[8]=E,e[9]=F,e[10]=O,e[11]=0,e[12]=s[0]+b-(x*b+R*w+E*P),e[13]=s[1]+w-(v*b+M*w+F*P),e[14]=s[2]+P-(A*b+D*w+O*P),e[15]=1,e},_t=function(e,t){var s=t[0],i=t[1],n=t[2],r=t[3],a=s+s,o=i+i,h=n+n,l=s*a,c=i*a,u=i*o,d=n*a,_=n*o,p=n*h,g=r*a,m=r*o,f=r*h;return e[0]=1-u-p,e[1]=c+f,e[2]=d-m,e[3]=0,e[4]=c-f,e[5]=1-l-p,e[6]=_+g,e[7]=0,e[8]=d+m,e[9]=_-g,e[10]=1-l-u,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},pt=function(e,t,s,i,n,r,a){var o=1/(s-t),h=1/(n-i),l=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*h,e[6]=0,e[7]=0,e[8]=(s+t)*o,e[9]=(n+i)*h,e[10]=(a+r)*l,e[11]=-1,e[12]=0,e[13]=0,e[14]=a*r*2*l,e[15]=0,e},gt=function(e,t,s,i,n){var r=1/Math.tan(t/2);if(e[0]=r/s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=r,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){var a=1/(i-n);e[10]=(n+i)*a,e[14]=2*n*i*a}else e[10]=-1,e[14]=-2*i;return e},mt=function(e,t,s,i,n){var r=1/Math.tan(t/2);if(e[0]=r/s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=r,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){var a=1/(i-n);e[10]=n*a,e[14]=n*i*a}else e[10]=-1,e[14]=-i;return e},ft=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=Math.tan(t.rightDegrees*Math.PI/180),h=2/(a+o),l=2/(n+r);return e[0]=h,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=l,e[6]=0,e[7]=0,e[8]=-(a-o)*h*.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},St=function(e,t,s,i,n,r,a){var o=1/(t-s),h=1/(i-n),l=1/(r-a);return e[0]=-2*o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*h,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+s)*o,e[13]=(n+i)*h,e[14]=(a+r)*l,e[15]=1,e},Gt=function(e,t,s,i,n,r,a){var o=1/(t-s),h=1/(i-n),l=1/(r-a);return e[0]=-2*o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*h,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=l,e[11]=0,e[12]=(t+s)*o,e[13]=(n+i)*h,e[14]=r*l,e[15]=1,e},yt=function(e,t,s,i){var n,r,a,o,h,l,c,u,d,_,p=t[0],g=t[1],m=t[2],f=i[0],S=i[1],G=i[2],y=s[0],I=s[1],T=s[2];return Math.abs(p-y)0&&(c*=_=1/Math.sqrt(_),u*=_,d*=_);var p=h*d-l*u,g=l*c-o*d,m=o*u-h*c;return(_=p*p+g*g+m*m)>0&&(p*=_=1/Math.sqrt(_),g*=_,m*=_),e[0]=p,e[1]=g,e[2]=m,e[3]=0,e[4]=u*m-d*g,e[5]=d*p-c*m,e[6]=c*g-u*p,e[7]=0,e[8]=c,e[9]=u,e[10]=d,e[11]=0,e[12]=n,e[13]=r,e[14]=a,e[15]=1,e},Tt=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]+")"},Ct=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])},bt=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},wt=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},Pt=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},xt=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},vt=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]},At=function(e,t){var s=e[0],i=e[1],n=e[2],r=e[3],a=e[4],o=e[5],h=e[6],l=e[7],c=e[8],u=e[9],d=e[10],_=e[11],p=e[12],g=e[13],m=e[14],f=e[15],S=t[0],G=t[1],y=t[2],I=t[3],T=t[4],C=t[5],b=t[6],w=t[7],P=t[8],x=t[9],v=t[10],A=t[11],R=t[12],M=t[13],D=t[14],E=t[15];return Math.abs(s-S)<=EPSILON*Math.max(1,Math.abs(s),Math.abs(S))&&Math.abs(i-G)<=EPSILON*Math.max(1,Math.abs(i),Math.abs(G))&&Math.abs(n-y)<=EPSILON*Math.max(1,Math.abs(n),Math.abs(y))&&Math.abs(r-I)<=EPSILON*Math.max(1,Math.abs(r),Math.abs(I))&&Math.abs(a-T)<=EPSILON*Math.max(1,Math.abs(a),Math.abs(T))&&Math.abs(o-C)<=EPSILON*Math.max(1,Math.abs(o),Math.abs(C))&&Math.abs(h-b)<=EPSILON*Math.max(1,Math.abs(h),Math.abs(b))&&Math.abs(l-w)<=EPSILON*Math.max(1,Math.abs(l),Math.abs(w))&&Math.abs(c-P)<=EPSILON*Math.max(1,Math.abs(c),Math.abs(P))&&Math.abs(u-x)<=EPSILON*Math.max(1,Math.abs(u),Math.abs(x))&&Math.abs(d-v)<=EPSILON*Math.max(1,Math.abs(d),Math.abs(v))&&Math.abs(_-A)<=EPSILON*Math.max(1,Math.abs(_),Math.abs(A))&&Math.abs(p-R)<=EPSILON*Math.max(1,Math.abs(p),Math.abs(R))&&Math.abs(g-M)<=EPSILON*Math.max(1,Math.abs(g),Math.abs(M))&&Math.abs(m-D)<=EPSILON*Math.max(1,Math.abs(m),Math.abs(D))&&Math.abs(f-E)<=EPSILON*Math.max(1,Math.abs(f),Math.abs(E))},Rt=function(){var e=new ARRAY_TYPE(3);return ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e},Mt=function(e){var t=new ARRAY_TYPE(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},Dt=function(e){var t=e[0],s=e[1],i=e[2];return Math.hypot(t,s,i)},Et=function(e,t,s){var i=new ARRAY_TYPE(3);return i[0]=e,i[1]=t,i[2]=s,i},Ft=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},Ot=function(e,t,s,i){return e[0]=t,e[1]=s,e[2]=i,e},Bt=function(e,t,s){return e[0]=t[0]+s[0],e[1]=t[1]+s[1],e[2]=t[2]+s[2],e},Lt=function(e,t,s){return e[0]=t[0]-s[0],e[1]=t[1]-s[1],e[2]=t[2]-s[2],e},kt=function(e,t,s){return e[0]=t[0]*s[0],e[1]=t[1]*s[1],e[2]=t[2]*s[2],e},Nt=function(e,t,s){return e[0]=t[0]/s[0],e[1]=t[1]/s[1],e[2]=t[2]/s[2],e},Wt=function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e},Vt=function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e},Ut=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},jt=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},Ht=function(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e[2]=Math.round(t[2]),e},zt=function(e,t,s){return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e},Xt=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},Yt=function(e,t){var s=t[0]-e[0],i=t[1]-e[1],n=t[2]-e[2];return Math.hypot(s,i,n)},qt=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},Kt=function(e){var t=e[0],s=e[1],i=e[2];return t*t+s*s+i*i},$t=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e},Jt=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e},Zt=function(e,t){var s=t[0],i=t[1],n=t[2],r=s*s+i*i+n*n;return r>0&&(r=1/Math.sqrt(r)),e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e},Qt=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},es=function(e,t,s){var i=t[0],n=t[1],r=t[2],a=s[0],o=s[1],h=s[2];return e[0]=n*h-r*o,e[1]=r*a-i*h,e[2]=i*o-n*a,e},ts=function(e,t,s,i){var n=t[0],r=t[1],a=t[2];return e[0]=n+i*(s[0]-n),e[1]=r+i*(s[1]-r),e[2]=a+i*(s[2]-a),e},ss=function(e,t,s,i){var n=Math.acos(Math.min(Math.max(Qt(t,s),-1),1)),r=Math.sin(n),a=Math.sin((1-i)*n)/r,o=Math.sin(i*n)/r;return e[0]=a*t[0]+o*s[0],e[1]=a*t[1]+o*s[1],e[2]=a*t[2]+o*s[2],e},is=function(e,t,s,i,n,r){var a=r*r,o=a*(2*r-3)+1,h=a*(r-2)+r,l=a*(r-1),c=a*(3-2*r);return e[0]=t[0]*o+s[0]*h+i[0]*l+n[0]*c,e[1]=t[1]*o+s[1]*h+i[1]*l+n[1]*c,e[2]=t[2]*o+s[2]*h+i[2]*l+n[2]*c,e},ns=function(e,t,s,i,n,r){var a=1-r,o=a*a,h=r*r,l=o*a,c=3*r*o,u=3*h*a,d=h*r;return e[0]=t[0]*l+s[0]*c+i[0]*u+n[0]*d,e[1]=t[1]*l+s[1]*c+i[1]*u+n[1]*d,e[2]=t[2]*l+s[2]*c+i[2]*u+n[2]*d,e},rs=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},as=function(e,t,s){var i=t[0],n=t[1],r=t[2],a=s[3]*i+s[7]*n+s[11]*r+s[15];return a=a||1,e[0]=(s[0]*i+s[4]*n+s[8]*r+s[12])/a,e[1]=(s[1]*i+s[5]*n+s[9]*r+s[13])/a,e[2]=(s[2]*i+s[6]*n+s[10]*r+s[14])/a,e},os=function(e,t,s){var i=t[0],n=t[1],r=t[2];return e[0]=i*s[0]+n*s[3]+r*s[6],e[1]=i*s[1]+n*s[4]+r*s[7],e[2]=i*s[2]+n*s[5]+r*s[8],e},hs=function(e,t,s){var i=s[0],n=s[1],r=s[2],a=s[3],o=t[0],h=t[1],l=t[2],c=n*l-r*h,u=r*o-i*l,d=i*h-n*o,_=n*d-r*u,p=r*c-i*d,g=i*u-n*c,m=2*a;return c*=m,u*=m,d*=m,_*=2,p*=2,g*=2,e[0]=o+c+_,e[1]=h+u+p,e[2]=l+d+g,e},ls=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},cs=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},us=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},ds=function(e,t){var s=e[0],i=e[1],n=e[2],r=t[0],a=t[1],o=t[2],h=Math.sqrt((s*s+i*i+n*n)*(r*r+a*a+o*o)),l=h&&Qt(e,t)/h;return Math.acos(Math.min(Math.max(l,-1),1))},_s=function(e){return e[0]=0,e[1]=0,e[2]=0,e},ps=function(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"},gs=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]},ms=function(e,t){var s=e[0],i=e[1],n=e[2],r=t[0],a=t[1],o=t[2];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))},fs=function(){var e=new ARRAY_TYPE(4);return ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e},Ss=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},Gs=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},ys=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},Is=function(e,t,s,i,n){return e[0]=t,e[1]=s,e[2]=i,e[3]=n,e},Ts=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},Cs=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},bs=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},ws=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},Ps=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},xs=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},vs=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},As=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},Rs=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},Ms=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},Ds=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},Es=function(e,t){var s=t[0]-e[0],i=t[1]-e[1],n=t[2]-e[2],r=t[3]-e[3];return Math.hypot(s,i,n,r)},Fs=function(e,t){var s=t[0]-e[0],i=t[1]-e[1],n=t[2]-e[2],r=t[3]-e[3];return s*s+i*i+n*n+r*r},Os=function(e){var t=e[0],s=e[1],i=e[2],n=e[3];return Math.hypot(t,s,i,n)},Bs=function(e){var t=e[0],s=e[1],i=e[2],n=e[3];return t*t+s*s+i*i+n*n},Ls=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=-t[3],e},ks=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},Ns=function(e,t){var s=t[0],i=t[1],n=t[2],r=t[3],a=s*s+i*i+n*n+r*r;return a>0&&(a=1/Math.sqrt(a)),e[0]=s*a,e[1]=i*a,e[2]=n*a,e[3]=r*a,e},Ws=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},Vs=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],h=s[1]*i[3]-s[3]*i[1],l=s[2]*i[3]-s[3]*i[2],c=t[0],u=t[1],d=t[2],_=t[3];return e[0]=u*l-d*h+_*o,e[1]=-c*l+d*a-_*r,e[2]=c*h-u*a+_*n,e[3]=-c*o+u*r-d*n,e},Us=function(e,t,s,i){var n=t[0],r=t[1],a=t[2],o=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]=o+i*(s[3]-o),e},js=function(e,t){var s,i,n,r,a,o;t=t||1;do{a=(s=2*RANDOM()-1)*s+(i=2*RANDOM()-1)*i}while(a>=1);do{o=(n=2*RANDOM()-1)*n+(r=2*RANDOM()-1)*r}while(o>=1);var h=Math.sqrt((1-a)/o);return e[0]=t*s,e[1]=t*i,e[2]=t*n*h,e[3]=t*r*h,e},Hs=function(e,t,s){var i=t[0],n=t[1],r=t[2],a=t[3];return e[0]=s[0]*i+s[4]*n+s[8]*r+s[12]*a,e[1]=s[1]*i+s[5]*n+s[9]*r+s[13]*a,e[2]=s[2]*i+s[6]*n+s[10]*r+s[14]*a,e[3]=s[3]*i+s[7]*n+s[11]*r+s[15]*a,e},zs=function(e,t,s){var i=t[0],n=t[1],r=t[2],a=s[0],o=s[1],h=s[2],l=s[3],c=l*i+o*r-h*n,u=l*n+h*i-a*r,d=l*r+a*n-o*i,_=-a*i-o*n-h*r;return e[0]=c*l+_*-a+u*-h-d*-o,e[1]=u*l+_*-o+d*-a-c*-h,e[2]=d*l+_*-h+c*-o-u*-a,e[3]=t[3],e},Xs=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e},Ys=function(e){return"vec4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},qs=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]},Ks=function(e,t){var s=e[0],i=e[1],n=e[2],r=e[3],a=t[0],o=t[1],h=t[2],l=t[3];return Math.abs(s-a)<=EPSILON*Math.max(1,Math.abs(s),Math.abs(a))&&Math.abs(i-o)<=EPSILON*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(n-h)<=EPSILON*Math.max(1,Math.abs(n),Math.abs(h))&&Math.abs(r-l)<=EPSILON*Math.max(1,Math.abs(r),Math.abs(l))},$s=function(){var e=new ARRAY_TYPE(4);return ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e},Js=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},Zs=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},Qs=function(e,t){var s=2*Math.acos(t[3]),i=Math.sin(s/2);return i>EPSILON?(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},ei=function(e,t){var s=dot$2(e,t);return Math.acos(2*s*s-1)},ti=function(e,t,s){var i=t[0],n=t[1],r=t[2],a=t[3],o=s[0],h=s[1],l=s[2],c=s[3];return e[0]=i*c+a*o+n*l-r*h,e[1]=n*c+a*h+r*o-i*l,e[2]=r*c+a*l+i*h-n*o,e[3]=a*c-i*o-n*h-r*l,e},si=function(e,t,s){s*=.5;var i=t[0],n=t[1],r=t[2],a=t[3],o=Math.sin(s),h=Math.cos(s);return e[0]=i*h+a*o,e[1]=n*h+r*o,e[2]=r*h-n*o,e[3]=a*h-i*o,e},ii=function(e,t,s){s*=.5;var i=t[0],n=t[1],r=t[2],a=t[3],o=Math.sin(s),h=Math.cos(s);return e[0]=i*h-r*o,e[1]=n*h+a*o,e[2]=r*h+i*o,e[3]=a*h-n*o,e},ni=function(e,t,s){s*=.5;var i=t[0],n=t[1],r=t[2],a=t[3],o=Math.sin(s),h=Math.cos(s);return e[0]=i*h+n*o,e[1]=n*h-i*o,e[2]=r*h+a*o,e[3]=a*h-r*o,e},ri=function(e,t){var s=t[0],i=t[1],n=t[2];return e[0]=s,e[1]=i,e[2]=n,e[3]=Math.sqrt(Math.abs(1-s*s-i*i-n*n)),e},ai=function(e,t){var s=t[0],i=t[1],n=t[2],r=t[3],a=Math.sqrt(s*s+i*i+n*n),o=Math.exp(r),h=a>0?o*Math.sin(a)/a:0;return e[0]=s*h,e[1]=i*h,e[2]=n*h,e[3]=o*Math.cos(a),e},oi=function(e,t){var s=t[0],i=t[1],n=t[2],r=t[3],a=Math.sqrt(s*s+i*i+n*n),o=a>0?Math.atan2(a,r)/a:0;return e[0]=s*o,e[1]=i*o,e[2]=n*o,e[3]=.5*Math.log(s*s+i*i+n*n+r*r),e},hi=function(e,t,s){return oi(e,t),scale$2(e,e,s),ai(e,e),e},li=function(e,t,s,i){var n,r,a,o,h,l=t[0],c=t[1],u=t[2],d=t[3],_=s[0],p=s[1],g=s[2],m=s[3];return(r=l*_+c*p+u*g+d*m)<0&&(r=-r,_=-_,p=-p,g=-g,m=-m),1-r>EPSILON?(n=Math.acos(r),a=Math.sin(n),o=Math.sin((1-i)*n)/a,h=Math.sin(i*n)/a):(o=1-i,h=i),e[0]=o*l+h*_,e[1]=o*c+h*p,e[2]=o*u+h*g,e[3]=o*d+h*m,e},ci=function(e){var t=RANDOM(),s=RANDOM(),i=RANDOM(),n=Math.sqrt(1-t),r=Math.sqrt(t);return e[0]=n*Math.sin(2*Math.PI*s),e[1]=n*Math.cos(2*Math.PI*s),e[2]=r*Math.sin(2*Math.PI*i),e[3]=r*Math.cos(2*Math.PI*i),e},ui=function(e,t){var s=t[0],i=t[1],n=t[2],r=t[3],a=s*s+i*i+n*n+r*r,o=a?1/a:0;return e[0]=-s*o,e[1]=-i*o,e[2]=-n*o,e[3]=r*o,e},di=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},_i=function(e,t){var s,i=t[0]+t[4]+t[8];if(i>0)s=Math.sqrt(i+1),e[3]=.5*s,s=.5/s,e[0]=(t[5]-t[7])*s,e[1]=(t[6]-t[2])*s,e[2]=(t[1]-t[3])*s;else{var n=0;t[4]>t[0]&&(n=1),t[8]>t[3*n+n]&&(n=2);var r=(n+1)%3,a=(n+2)%3;s=Math.sqrt(t[3*n+n]-t[3*r+r]-t[3*a+a]+1),e[n]=.5*s,s=.5/s,e[3]=(t[3*r+a]-t[3*a+r])*s,e[r]=(t[3*r+n]+t[3*n+r])*s,e[a]=(t[3*a+n]+t[3*n+a])*s}return e},pi=function(e,t,s,i){var n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:ANGLE_ORDER,r=Math.PI/360;t*=r,i*=r,s*=r;var a=Math.sin(t),o=Math.cos(t),h=Math.sin(s),l=Math.cos(s),c=Math.sin(i),u=Math.cos(i);switch(n){case"xyz":e[0]=a*l*u+o*h*c,e[1]=o*h*u-a*l*c,e[2]=o*l*c+a*h*u,e[3]=o*l*u-a*h*c;break;case"xzy":e[0]=a*l*u-o*h*c,e[1]=o*h*u-a*l*c,e[2]=o*l*c+a*h*u,e[3]=o*l*u+a*h*c;break;case"yxz":e[0]=a*l*u+o*h*c,e[1]=o*h*u-a*l*c,e[2]=o*l*c-a*h*u,e[3]=o*l*u+a*h*c;break;case"yzx":e[0]=a*l*u+o*h*c,e[1]=o*h*u+a*l*c,e[2]=o*l*c-a*h*u,e[3]=o*l*u-a*h*c;break;case"zxy":e[0]=a*l*u-o*h*c,e[1]=o*h*u+a*l*c,e[2]=o*l*c+a*h*u,e[3]=o*l*u-a*h*c;break;case"zyx":e[0]=a*l*u-o*h*c,e[1]=o*h*u+a*l*c,e[2]=o*l*c-a*h*u,e[3]=o*l*u+a*h*c;break;default:throw new Error("Unknown angle order "+n)}return e},gi=function(e){return"quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},mi=function(e,t){return Math.abs(Ws(e,t))>=1-EPSILON},fi=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},Si=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},Gi=function(e,t,s,i,n,r,a,o){var h=new ARRAY_TYPE(8);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},yi=function(e,t,s,i,n,r,a){var o=new ARRAY_TYPE(8);o[0]=e,o[1]=t,o[2]=s,o[3]=i;var h=.5*n,l=.5*r,c=.5*a;return o[4]=h*i+l*s-c*t,o[5]=l*i+c*e-h*s,o[6]=c*i+h*t-l*e,o[7]=-h*e-l*t-c*s,o},Ii=function(e,t,s){var i=.5*s[0],n=.5*s[1],r=.5*s[2],a=t[0],o=t[1],h=t[2],l=t[3];return e[0]=a,e[1]=o,e[2]=h,e[3]=l,e[4]=i*l+n*h-r*o,e[5]=n*l+r*a-i*h,e[6]=r*l+i*o-n*a,e[7]=-i*a-n*o-r*h,e},Ti=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},Ci=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},bi=function(e,t){var s=$s();lt(s,t);var i=new ARRAY_TYPE(3);return ot(i,t),Ii(e,s,i),e},wi=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},Pi=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},xi=function(e,t,s,i,n,r,a,o,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]=h,e},vi=function(e,t){return e[0]=t[4],e[1]=t[5],e[2]=t[6],e[3]=t[7],e},Ai=function(e,t){return e[4]=t[0],e[5]=t[1],e[6]=t[2],e[7]=t[3],e},Ri=function(e,t){var s=t[4],i=t[5],n=t[6],r=t[7],a=-t[0],o=-t[1],h=-t[2],l=t[3];return e[0]=2*(s*l+r*a+i*h-n*o),e[1]=2*(i*l+r*o+n*a-s*h),e[2]=2*(n*l+r*h+s*o-i*a),e},Mi=function(e,t,s){var i=t[0],n=t[1],r=t[2],a=t[3],o=.5*s[0],h=.5*s[1],l=.5*s[2],c=t[4],u=t[5],d=t[6],_=t[7];return e[0]=i,e[1]=n,e[2]=r,e[3]=a,e[4]=a*o+n*l-r*h+c,e[5]=a*h+r*o-i*l+u,e[6]=a*l+i*h-n*o+d,e[7]=-i*o-n*h-r*l+_,e},Di=function(e,t,s){var i=-t[0],n=-t[1],r=-t[2],a=t[3],o=t[4],h=t[5],l=t[6],c=t[7],u=o*a+c*i+h*r-l*n,d=h*a+c*n+l*i-o*r,_=l*a+c*r+o*n-h*i,p=c*a-o*i-h*n-l*r;return si(e,t,s),i=e[0],n=e[1],r=e[2],a=e[3],e[4]=u*a+p*i+d*r-_*n,e[5]=d*a+p*n+_*i-u*r,e[6]=_*a+p*r+u*n-d*i,e[7]=p*a-u*i-d*n-_*r,e},Ei=function(e,t,s){var i=-t[0],n=-t[1],r=-t[2],a=t[3],o=t[4],h=t[5],l=t[6],c=t[7],u=o*a+c*i+h*r-l*n,d=h*a+c*n+l*i-o*r,_=l*a+c*r+o*n-h*i,p=c*a-o*i-h*n-l*r;return ii(e,t,s),i=e[0],n=e[1],r=e[2],a=e[3],e[4]=u*a+p*i+d*r-_*n,e[5]=d*a+p*n+_*i-u*r,e[6]=_*a+p*r+u*n-d*i,e[7]=p*a-u*i-d*n-_*r,e},Fi=function(e,t,s){var i=-t[0],n=-t[1],r=-t[2],a=t[3],o=t[4],h=t[5],l=t[6],c=t[7],u=o*a+c*i+h*r-l*n,d=h*a+c*n+l*i-o*r,_=l*a+c*r+o*n-h*i,p=c*a-o*i-h*n-l*r;return ni(e,t,s),i=e[0],n=e[1],r=e[2],a=e[3],e[4]=u*a+p*i+d*r-_*n,e[5]=d*a+p*n+_*i-u*r,e[6]=_*a+p*r+u*n-d*i,e[7]=p*a-u*i-d*n-_*r,e},Oi=function(e,t,s){var i=s[0],n=s[1],r=s[2],a=s[3],o=t[0],h=t[1],l=t[2],c=t[3];return e[0]=o*a+c*i+h*r-l*n,e[1]=h*a+c*n+l*i-o*r,e[2]=l*a+c*r+o*n-h*i,e[3]=c*a-o*i-h*n-l*r,o=t[4],h=t[5],l=t[6],c=t[7],e[4]=o*a+c*i+h*r-l*n,e[5]=h*a+c*n+l*i-o*r,e[6]=l*a+c*r+o*n-h*i,e[7]=c*a-o*i-h*n-l*r,e},Bi=function(e,t,s){var i=t[0],n=t[1],r=t[2],a=t[3],o=s[0],h=s[1],l=s[2],c=s[3];return e[0]=i*c+a*o+n*l-r*h,e[1]=n*c+a*h+r*o-i*l,e[2]=r*c+a*l+i*h-n*o,e[3]=a*c-i*o-n*h-r*l,o=s[4],h=s[5],l=s[6],c=s[7],e[4]=i*c+a*o+n*l-r*h,e[5]=n*c+a*h+r*o-i*l,e[6]=r*c+a*l+i*h-n*o,e[7]=a*c-i*o-n*h-r*l,e},Li=function(e,t,s,i){if(Math.abs(i)0){s=Math.sqrt(s);var i=t[0]/s,n=t[1]/s,r=t[2]/s,a=t[3]/s,o=t[4],h=t[5],l=t[6],c=t[7],u=i*o+n*h+r*l+a*c;e[0]=i,e[1]=n,e[2]=r,e[3]=a,e[4]=(o-i*u)/s,e[5]=(h-n*u)/s,e[6]=(l-r*u)/s,e[7]=(c-a*u)/s}return e},zi=function(e){return"quat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+")"},Xi=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]},Yi=function(e,t){var s=e[0],i=e[1],n=e[2],r=e[3],a=e[4],o=e[5],h=e[6],l=e[7],c=t[0],u=t[1],d=t[2],_=t[3],p=t[4],g=t[5],m=t[6],f=t[7];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-d)<=EPSILON*Math.max(1,Math.abs(n),Math.abs(d))&&Math.abs(r-_)<=EPSILON*Math.max(1,Math.abs(r),Math.abs(_))&&Math.abs(a-p)<=EPSILON*Math.max(1,Math.abs(a),Math.abs(p))&&Math.abs(o-g)<=EPSILON*Math.max(1,Math.abs(o),Math.abs(g))&&Math.abs(h-m)<=EPSILON*Math.max(1,Math.abs(h),Math.abs(m))&&Math.abs(l-f)<=EPSILON*Math.max(1,Math.abs(l),Math.abs(f))},qi=function(){var e=new ARRAY_TYPE(2);return ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0),e},Ki=function(e){var t=new ARRAY_TYPE(2);return t[0]=e[0],t[1]=e[1],t},$i=function(e,t){var s=new ARRAY_TYPE(2);return s[0]=e,s[1]=t,s},Ji=function(e,t){return e[0]=t[0],e[1]=t[1],e},Zi=function(e,t,s){return e[0]=t,e[1]=s,e},Qi=function(e,t,s){return e[0]=t[0]+s[0],e[1]=t[1]+s[1],e},en=function(e,t,s){return e[0]=t[0]-s[0],e[1]=t[1]-s[1],e},tn=function(e,t,s){return e[0]=t[0]*s[0],e[1]=t[1]*s[1],e},sn=function(e,t,s){return e[0]=t[0]/s[0],e[1]=t[1]/s[1],e},nn=function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e},rn=function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e},an=function(e,t,s){return e[0]=Math.min(t[0],s[0]),e[1]=Math.min(t[1],s[1]),e},on=function(e,t,s){return e[0]=Math.max(t[0],s[0]),e[1]=Math.max(t[1],s[1]),e},hn=function(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e},cn=function(e,t,s){return e[0]=t[0]*s,e[1]=t[1]*s,e},un=function(e,t,s,i){return e[0]=t[0]+s[0]*i,e[1]=t[1]+s[1]*i,e},dn=function(e,t){var s=t[0]-e[0],i=t[1]-e[1];return Math.hypot(s,i)},_n=function(e,t){var s=t[0]-e[0],i=t[1]-e[1];return s*s+i*i},pn=function(e){var t=e[0],s=e[1];return Math.hypot(t,s)},gn=function(e){var t=e[0],s=e[1];return t*t+s*s},mn=function(e,t){return e[0]=-t[0],e[1]=-t[1],e},fn=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e},Sn=function(e,t){var s=t[0],i=t[1],n=s*s+i*i;return n>0&&(n=1/Math.sqrt(n)),e[0]=t[0]*n,e[1]=t[1]*n,e},Gn=function(e,t){return e[0]*t[0]+e[1]*t[1]},yn=function(e,t,s){var i=t[0]*s[1]-t[1]*s[0];return e[0]=e[1]=0,e[2]=i,e},In=function(e,t,s,i){var n=t[0],r=t[1];return e[0]=n+i*(s[0]-n),e[1]=r+i*(s[1]-r),e},Tn=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},Cn=function(e,t,s){var i=t[0],n=t[1];return e[0]=s[0]*i+s[2]*n,e[1]=s[1]*i+s[3]*n,e},bn=function(e,t,s){var i=t[0],n=t[1];return e[0]=s[0]*i+s[2]*n+s[4],e[1]=s[1]*i+s[3]*n+s[5],e},wn=function(e,t,s){var i=t[0],n=t[1];return e[0]=s[0]*i+s[3]*n+s[6],e[1]=s[1]*i+s[4]*n+s[7],e},Pn=function(e,t,s){var i=t[0],n=t[1];return e[0]=s[0]*i+s[4]*n+s[12],e[1]=s[1]*i+s[5]*n+s[13],e},xn=function(e,t,s,i){var n=t[0]-s[0],r=t[1]-s[1],a=Math.sin(i),o=Math.cos(i);return e[0]=n*o-r*a+s[0],e[1]=n*a+r*o+s[1],e},vn=function(e,t){var s=e[0],i=e[1],n=t[0],r=t[1],a=Math.sqrt((s*s+i*i)*(n*n+r*r)),o=a&&(s*n+i*r)/a;return Math.acos(Math.min(Math.max(o,-1),1))},An=function(e){return e[0]=0,e[1]=0,e},Rn=function(e){return"vec2("+e[0]+", "+e[1]+")"},Mn=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Dn=function(e,t){var s=e[0],i=e[1],n=t[0],r=t[1];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))};setMatrixArrayType=e,toRadian=n,equals$9=h,create$8=u,clone$8=_,copy$8=p,identity$5=g,fromValues$8=m,set$8=S,transpose$2=G,invert$5=y,adjoint$2=I,determinant$3=T,multiply$8=C,rotate$4=b,scale$8=w,fromRotation$4=P,fromScaling$3=x,str$8=v,frob$3=A,LDU=R,add$8=M,subtract$6=D,exactEquals$8=E,equals$8=F,multiplyScalar$3=O,multiplyScalarAndAdd$3=B,create$7=L,clone$7=k,copy$7=N,identity$4=W,fromValues$7=V,set$7=U,invert$4=j,determinant$2=H,multiply$7=z,rotate$3=X,scale$7=Y,translate$3=q,fromRotation$3=K,fromScaling$2=$,fromTranslation$3=J,str$7=Z,frob$2=Q,add$7=ee,subtract$5=te,multiplyScalar$2=se,multiplyScalarAndAdd$2=ie,exactEquals$7=ne,equals$7=re,create$6=ae,fromMat4$1=oe,clone$6=he,copy$6=le,fromValues$6=ce,set$6=ue,identity$3=de,transpose$1=_e,invert$3=pe,adjoint$1=ge,determinant$1=me,multiply$6=fe,translate$2=Se,rotate$2=Ge,scale$6=ye,fromTranslation$2=Ie,fromRotation$2=Te,fromScaling$1=Ce,fromMat2d=be,fromQuat$1=we,normalFromMat4=Pe,projection=xe,str$6=ve,frob$1=Ae,add$6=Re,subtract$4=Me,multiplyScalar$1=De,multiplyScalarAndAdd$1=Ee,exactEquals$6=Fe,equals$6=Oe,create$5=Be,clone$5=Le,copy$5=ke,fromValues$5=Ne,set$5=We,identity$2=Ve,transpose=Ue,invert$2=je,adjoint=He,determinant=ze,multiply$5=Xe,translate$1=Ye,scale$5=qe,rotate$1=Ke,rotateX$3=$e,rotateY$3=Je,rotateZ$3=Ze,fromTranslation$1=Qe,fromScaling=et,fromRotation$1=tt,fromXRotation=st,fromYRotation=it,fromZRotation=nt,fromRotationTranslation$1=rt,fromQuat2=at,getTranslation$1=ot,getScaling=ht,getRotation=lt,decompose=ct,fromRotationTranslationScale=ut,fromRotationTranslationScaleOrigin=dt,fromQuat=_t,frustum=pt,perspectiveNO=gt,perspectiveZO=mt,perspectiveFromFieldOfView=ft,orthoNO=St,orthoZO=Gt,lookAt=yt,targetTo=It,str$5=Tt,frob=Ct,add$5=bt,subtract$3=wt,multiplyScalar=Pt,multiplyScalarAndAdd=xt,exactEquals$5=vt,equals$5=At,create$4=Rt,clone$4=Mt,length$4=Dt,fromValues$4=Et,copy$4=Ft,set$4=Ot,add$4=Bt,subtract$2=Lt,multiply$4=kt,divide$2=Nt,ceil$2=Wt,floor$2=Vt,min$2=Ut,max$2=jt,round$2=Ht,scale$4=zt,scaleAndAdd$2=Xt,distance$2=Yt,squaredDistance$2=qt,squaredLength$4=Kt,negate$2=$t,inverse$2=Jt,normalize$4=Zt,dot$4=Qt,cross$2=es,lerp$4=ts,slerp$1=ss,hermite=is,bezier=ns,random$3=rs,transformMat4$2=as,transformMat3$1=os,transformQuat$1=hs,rotateX$2=ls,rotateY$2=cs,rotateZ$2=us,angle$1=ds,zero$2=_s,str$4=ps,exactEquals$4=gs,equals$4=ms,create$3=fs,clone$3=Ss,fromValues$3=Gs,copy$3=ys,set$3=Is,add$3=Ts,subtract$1=Cs,multiply$3=bs,divide$1=ws,ceil$1=Ps,floor$1=xs,min$1=vs,max$1=As,round$1=Rs,scale$3=Ms,scaleAndAdd$1=Ds,distance$1=Es,squaredDistance$1=Fs,length$3=Os,squaredLength$3=Bs,negate$1=Ls,inverse$1=ks,normalize$3=Ns,dot$3=Ws,cross$1=Vs,lerp$3=Us,random$2=js,transformMat4$1=Hs,transformQuat=zs,zero$1=Xs,str$3=Ys,exactEquals$3=qs,equals$3=Ks,create$2=$s,identity$1=Js,setAxisAngle=Zs,getAxisAngle=Qs,getAngle=ei,multiply$2=ti,rotateX$1=si,rotateY$1=ii,rotateZ$1=ni,calculateW=ri,exp=ai,ln=oi,pow=hi,slerp=li,random$1=ci,invert$1=ui,conjugate$1=di,fromMat3=_i,fromEuler=pi,str$2=gi,equals$2=mi,create$1=fi,clone$1=Si,fromValues$1=Gi,fromRotationTranslationValues=yi,fromRotationTranslation=Ii,fromTranslation=Ti,fromRotation=Ci,fromMat4=bi,copy$1=wi,identity=Pi,set$1=xi,getDual=vi,setDual=Ai,getTranslation=Ri,translate=Mi,rotateX=Di,rotateY=Ei,rotateZ=Fi,rotateByQuatAppend=Oi,rotateByQuatPrepend=Bi,rotateAroundAxis=Li,add$1=ki,multiply$1=Ni,scale$1=Wi,lerp$1=Vi,invert=Ui,conjugate=ji,normalize$1=Hi,str$1=zi,exactEquals$1=Xi,equals$1=Yi,create=qi,clone=Ki,fromValues=$i,copy=Ji,set=Zi,add=Qi,subtract=en,multiply=tn,divide=sn,ceil=nn,floor=rn,min=an,max=on,round=hn,scale=cn,scaleAndAdd=un,distance=dn,squaredDistance=_n,length=pn,squaredLength=gn,negate=mn,inverse=fn,normalize=Sn,dot=Gn,cross=yn,lerp=In,random=Tn,transformMat2=Cn,transformMat2d=bn,transformMat3=wn,transformMat4=Pn,rotate=xn,angle=vn,zero=An,str=Rn,exactEquals=Mn,equals=Dn,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:e,toRadian:n,equals:h},mul$8=C,sub$6=D,mat2=Object.freeze({__proto__:null,create:u,clone:_,copy:p,identity:g,fromValues:m,set:S,transpose:G,invert:y,adjoint:I,determinant:T,multiply:C,rotate:b,scale:w,fromRotation:P,fromScaling:x,str:v,frob:A,LDU:R,add:M,subtract:D,exactEquals:E,equals:F,multiplyScalar:O,multiplyScalarAndAdd:B,mul:mul$8,sub:sub$6}),mul$7=z,sub$5=te,mat2d=Object.freeze({__proto__:null,create:L,clone:k,copy:N,identity:W,fromValues:V,set:U,invert:j,determinant:H,multiply:z,rotate:X,scale:Y,translate:q,fromRotation:K,fromScaling:$,fromTranslation:J,str:Z,frob:Q,add:ee,subtract:te,multiplyScalar:se,multiplyScalarAndAdd:ie,exactEquals:ne,equals:re,mul:mul$7,sub:sub$5}),mul$6=fe,sub$4=Me,mat3=Object.freeze({__proto__:null,create:ae,fromMat4:oe,clone:he,copy:le,fromValues:ce,set:ue,identity:de,transpose:_e,invert:pe,adjoint:ge,determinant:me,multiply:fe,translate:Se,rotate:Ge,scale:ye,fromTranslation:Ie,fromRotation:Te,fromScaling:Ce,fromMat2d:be,fromQuat:we,normalFromMat4:Pe,projection:xe,str:ve,frob:Ae,add:Re,subtract:Me,multiplyScalar:De,multiplyScalarAndAdd:Ee,exactEquals:Fe,equals:Oe,mul:mul$6,sub:sub$4}),perspective=gt,ortho=St,mul$5=Xe,sub$3=wt,mat4=Object.freeze({__proto__:null,create:Be,clone:Le,copy:ke,fromValues:Ne,set:We,identity:Ve,transpose:Ue,invert:je,adjoint:He,determinant:ze,multiply:Xe,translate:Ye,scale:qe,rotate:Ke,rotateX:$e,rotateY:Je,rotateZ:Ze,fromTranslation:Qe,fromScaling:et,fromRotation:tt,fromXRotation:st,fromYRotation:it,fromZRotation:nt,fromRotationTranslation:rt,fromQuat2:at,getTranslation:ot,getScaling:ht,getRotation:lt,decompose:ct,fromRotationTranslationScale:ut,fromRotationTranslationScaleOrigin:dt,fromQuat:_t,frustum:pt,perspectiveNO:gt,perspective:perspective,perspectiveZO:mt,perspectiveFromFieldOfView:ft,orthoNO:St,ortho:ortho,orthoZO:Gt,lookAt:yt,targetTo:It,str:Tt,frob:Ct,add:bt,subtract:wt,multiplyScalar:Pt,multiplyScalarAndAdd:xt,exactEquals:vt,equals:At,mul:mul$5,sub:sub$3}),sub$2=Lt,mul$4=kt,div$2=Nt,dist$2=Yt,sqrDist$2=qt,len$4=Dt,sqrLen$4=Kt,t=Rt(),forEach$2=function(e,s,i,n,r,a){var o,h;for(s||(s=3),i||(i=0),h=n?Math.min(n*s+i,e.length):e.length,o=i;o.999999?(i[0]=0,i[1]=0,i[2]=0,i[3]=1,i):(es(e,n,r),i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=1+a,normalize$2(i,i))}}(),sqlerp=function(){var e=$s(),t=$s();return function(s,i,n,r,a,o){return li(e,i,a,o),li(t,n,r,o),li(s,e,t,2*o*(1-o)),s}}(),setAxes=function(){var e=ae();return function(t,s,i,n){return e[0]=i[0],e[3]=i[1],e[6]=i[2],e[1]=n[0],e[4]=n[1],e[7]=n[2],e[2]=-s[0],e[5]=-s[1],e[8]=-s[2],normalize$2(t,_i(t,e))}}(),quat=Object.freeze({__proto__:null,create:$s,identity:Js,setAxisAngle:Zs,getAxisAngle:Qs,getAngle:ei,multiply:ti,rotateX:si,rotateY:ii,rotateZ:ni,calculateW:ri,exp:ai,ln:oi,pow:hi,slerp:li,random:ci,invert:ui,conjugate:di,fromMat3:_i,fromEuler:pi,str:gi,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:mi,rotationTo:rotationTo,sqlerp:sqlerp,setAxes:setAxes}),getReal=copy$2,setReal=copy$2,mul$1=Ni,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:fi,clone:Si,fromValues:Gi,fromRotationTranslationValues:yi,fromRotationTranslation:Ii,fromTranslation:Ti,fromRotation:Ci,fromMat4:bi,copy:wi,identity:Pi,set:xi,getReal:getReal,getDual:vi,setReal:setReal,setDual:Ai,getTranslation:Ri,translate:Mi,rotateX:Di,rotateY:Ei,rotateZ:Fi,rotateByQuatAppend:Oi,rotateByQuatPrepend:Bi,rotateAroundAxis:Li,add:ki,multiply:Ni,mul:mul$1,scale:Wi,dot:dot$1,lerp:Vi,invert:Ui,conjugate:ji,length:length$1,len:len$1,squaredLength:squaredLength$1,sqrLen:sqrLen$1,normalize:Hi,str:zi,exactEquals:Xi,equals:Yi}),len=pn,sub=en,mul=tn,div=sn,dist=dn,sqrDist=_n,sqrLen=gn,forEach=function(){var e=qi();return function(t,s,i,n,r,a){var o,h;for(s||(s=2),i||(i=0),h=n?Math.min(n*s+i,t.length):t.length,o=i;o=0&&h<=1&&l>=0&&l<=1},On=function(e,t,s){return(t[0]-e[0])*(s[1]-e[1])-(s[0]-e[0])*(t[1]-e[1])},Bn=function(e,t,s){return On(e,t,s)>0},Ln=function(e,t,s){return On(e,t,s)>=0},kn=function(e,t,s){return On(e,t,s)<0},Nn=function(e,t,s){return On(e,t,s)<=0},Wn=function(e,t,s,i){if(i){var n=tmpPoint1,r=tmpPoint2;n[0]=t[0]-e[0],n[1]=t[1]-e[1],r[0]=s[0]-t[0],r[1]=s[1]-t[1];var a=n[0]*r[0]+n[1]*r[1],o=Math.sqrt(n[0]*n[0]+n[1]*n[1]),h=Math.sqrt(r[0]*r[0]+r[1]*r[1]);return Math.acos(a/(o*h))s[t][0])&&(t=i);return!Bn(Un(e,t-1),Un(e,t),Un(e,t+1))&&(Xn(e),!0)},Xn=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]},Yn=function(e,t){return kn(Un(e,t-1),Un(e,t),Un(e,t+1))},qn=function(e,t,s){var i,n,r=tmpLine1,a=tmpLine2;if(Ln(Un(e,t+1),Un(e,t),Un(e,s))&&Nn(Un(e,t-1),Un(e,t),Un(e,s)))return!1;n=Vn(Un(e,t),Un(e,s));for(var o=0;o!==e.length;++o)if((o+1)%e.length!==t&&o!==t&&Ln(Un(e,t),Un(e,s),Un(e,o+1))&&Nn(Un(e,t),Un(e,s),Un(e,o))&&(r[0]=Un(e,t),r[1]=Un(e,s),a[0]=Un(e,o),a[1]=Un(e,o+1),i=En(r,a),Vn(Un(e,t),i)0?Qn(e,t):[e]},Qn=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;ir)return console.warn("quickDecomp: max level ("+r+") reached."),t;for(var I=0;Ip&&(p+=e.length),_=Number.MAX_VALUE,p3&&i>=0;--i)Wn(Un(e,i-1),Un(e,i),Un(e,i+1),t)&&(e.splice(i%e.length,1),s++);return s},nr=function(e,t){for(var s=e.length-1;s>=1;--s)for(var i=e[s],n=s-1;n>=0;--n)ar(i,e[n],t)&&e.splice(s,1)},rr=function(e,t,s){return s=s||0,Math.abs(e-t)<=s},ar=function(e,t,s){return rr(e[0],t[0],s)&&rr(e[1],t[1],s)};lineInt=En,lineSegmentsIntersect=Fn,triangleArea=On,isLeft=Bn,isLeftOn=Ln,isRight=kn,isRightOn=Nn,collinear=Wn,sqdist=Vn,polygonAt=Un,polygonClear=jn,polygonAppend=Hn,polygonMakeCCW=zn,polygonReverse=Xn,polygonIsReflex=Yn,polygonCanSee=qn,polygonCanSee2=Kn,polygonCopy=$n,polygonGetCutEdges=Jn,polygonDecomp=Zn,polygonSlice=Qn,polygonIsSimple=er,getIntersectionPoint=tr,polygonQuickDecomp=sr,polygonRemoveCollinearPoints=ir,polygonRemoveDuplicatePoints=nr,scalar_eq=rr,points_eq=ar,tmpPoint1=[],tmpPoint2=[],tmpLine1=[],tmpLine2=[],self.polyDecomp={decomp:Zn,quickDecomp:sr,isSimple:er,removeCollinearPoints:ir,removeDuplicatePoints:nr,makeCCW:zn}}{let hr=!1,lr=!1,cr="dev";const ur=Symbol("Construct internal API token");let dr=16;const _r=self.C3=class{constructor(){throw TypeError("static class can't be instantiated")}static _GetInternalAPIToken(){if(dr<=0)throw new Error("cannot obtain internal API token");return--dr,ur}static SetReady(){hr=!0}static IsReady(){return hr}static SetAppStarted(){lr=!0}static HasAppStarted(){return lr}static SetBuildMode(e){cr=e}static GetBuildMode(){return cr}static IsReleaseBuild(){return"final"===cr}};_r.isDebug=!1,_r.isDebugDefend=!1,_r.hardwareConcurrency=navigator.hardwareConcurrency||2,self.C3X={}}{const pr=self.C3;pr.QueryParser=class{constructor(e){this._queryString=e,this._parameters=new Map,this._Parse()}_Parse(){let e=this._queryString;(e.startsWith("?")||e.startsWith("#"))&&(e=e.substr(1));const t=e.split("&");for(const e of t)this._ParseParameter(e)}_ParseParameter(e){if(!e)return;if(!e.includes("="))return void this._parameters.set(e,null);const t=e.indexOf("="),s=decodeURIComponent(e.substring(0,t)),i=decodeURIComponent(e.substring(t+1));this._parameters.set(s,i)}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()}},pr.QueryString=new pr.QueryParser(location.search),pr.LocationHashString=new pr.QueryParser(location.hash),pr.QueryString.Has("perf")&&(pr.isPerformanceProfiling=!0),"dev"!==pr.QueryString.Get("mode")&&pr.SetBuildMode("final")}{let gr=function(e){const t=parseFloat(e);return Sr.get(t)||(t>=13?"11":"NT "+e)};GetWindowsNTVersionName=gr;const mr=self.C3,fr="(unknown)";mr.Platform={OS:fr,OSVersion:fr,Browser:fr,BrowserVersion:fr,BrowserVersionNumber:NaN,BrowserEngine:fr,Context:"browser",IsDesktop:!0,IsMobile:!1,IsAppleOS:!1,IsIpadOS:!1,GetDetailedInfo:async()=>{}};const Sr=new Map([[5,"2000"],[5.1,"XP"],[5.2,"XP"],[6,"Vista"],[6.1,"7"],[6.2,"8"],[6.3,"8.1"],[10,"10"]]),Gr=navigator.userAgent,yr=navigator.userAgentData;if(yr&&yr.brands.length>0){let Tr=function(e){let t="",s="",i="",n="";for(const r of e){const e=Cr.get(r.brand);!t&&e&&(t=e,s=r.version);const a=br.get(r.brand);!i&&a&&(i=a,n=r.version)}t||"Chromium"!==i||(mr.Platform.Browser="Chromium",mr.Platform.BrowserVersion=n),mr.Platform.Browser=t||fr,mr.Platform.BrowserVersion=s||fr,mr.Platform.BrowserEngine=i||fr};ReadBrandList=Tr,mr.Platform.OS=yr.platform,mr.Platform.IsMobile=yr.mobile,mr.Platform.IsDesktop=!mr.Platform.IsMobile;const Cr=new Map([["Google Chrome","Chrome"],["Microsoft Edge","Edge"],["Opera","Opera"],["Opera GX","Opera GX"],["Mozilla Firefox","Firefox"],["Apple Safari","Safari"],["NW.js","NW.js"]]),br=new Map([["Chromium","Chromium"],["Gecko","Gecko"],["WebKit","WebKit"]]);Tr(yr.brands);let wr=!1;mr.Platform.GetDetailedInfo=async()=>{if(!wr)try{const e=await navigator.userAgentData.getHighEntropyValues(["platformVersion","fullVersionList"]);Tr(e.fullVersionList),"Windows"===mr.Platform.OS?mr.Platform.OSVersion=gr(e.platformVersion):mr.Platform.OSVersion=e.platformVersion,wr=!0}catch(e){console.warn("Failed to get detailed user agent information: ",e)}}}else{let Pr=function(e,t){const s=Array.isArray(e)?e:[e];for(const e of s){const s=e.exec(Gr);if(s){t(s);break}}};RunTest=Pr,Pr(/windows\s+nt\s+([\d\.]+)/i,e=>{mr.Platform.OS="Windows";const t=e[1];mr.Platform.OSVersion=gr(t)}),Pr(/mac\s+os\s+x\s+([\d\._]+)/i,e=>{mr.Platform.OS="macOS",mr.Platform.OSVersion=e[1].replace(/_/g,".")}),Pr(/CrOS/,()=>{mr.Platform.OS="Chrome OS"}),Pr(/linux|openbsd|freebsd|netbsd/i,()=>{mr.Platform.OS="Linux"}),Pr(/android/i,()=>{mr.Platform.OS="Android"}),Pr(/android\s+([\d\.]+)/i,e=>{mr.Platform.OS="Android",mr.Platform.OSVersion=e[1]}),mr.Platform.OS===fr&&(Pr(/(iphone|ipod|ipad)/i,e=>{mr.Platform.OS="iOS"}),Pr([/iphone\s+os\s+([\d\._]+)/i,/ipad[^)]*os\s+([\d\._]+)/i],e=>{mr.Platform.OS="iOS",mr.Platform.OSVersion=e[1].replace(/_/g,".")}));const xr=/chrome\//i.test(Gr),vr=/chromium\//i.test(Gr),Ar=/edg\//i.test(Gr),Rr=/OPR\//.test(Gr),Mr=/nwjs/i.test(Gr),Dr=/safari\//i.test(Gr),Er=/webkit/i.test(Gr);Ar||Rr||Pr(/chrome\/([\d\.]+)/i,e=>{mr.Platform.Browser="Chrome",mr.Platform.BrowserVersion=e[1],mr.Platform.BrowserEngine="Chromium"}),Pr(/edg\/([\d\.]+)/i,e=>{mr.Platform.Browser="Edge",mr.Platform.BrowserVersion=e[1],mr.Platform.BrowserEngine="Chromium"}),Pr(/OPR\/([\d\.]+)/,e=>{mr.Platform.Browser="Opera",mr.Platform.BrowserVersion=e[1],mr.Platform.BrowserEngine="Chromium"}),Pr(/chromium\/([\d\.]+)/i,e=>{mr.Platform.Browser="Chromium",mr.Platform.BrowserVersion=e[1],mr.Platform.BrowserEngine="Chromium"}),Pr(/nwjs\/[0-9.]+/i,e=>{mr.Platform.Browser="NW.js",mr.Platform.BrowserVersion=e[1],mr.Platform.BrowserEngine="Chromium",mr.Platform.Context="nwjs"}),Pr(/firefox\/([\d\.]+)/i,e=>{mr.Platform.Browser="Firefox",mr.Platform.BrowserVersion=e[1],mr.Platform.BrowserEngine="Gecko"}),!Dr||xr||vr||Ar||Rr||Mr||(mr.Platform.Browser="Safari",mr.Platform.BrowserEngine="WebKit",Pr(/version\/([\d\.]+)/i,e=>{mr.Platform.BrowserVersion=e[1]}),Pr(/crios\/([\d\.]+)/i,e=>{mr.Platform.Browser="Chrome for iOS",mr.Platform.BrowserVersion=e[1]}),Pr(/fxios\/([\d\.]+)/i,e=>{mr.Platform.Browser="Firefox for iOS",mr.Platform.BrowserVersion=e[1]}),Pr(/edgios\/([\d\.]+)/i,e=>{mr.Platform.Browser="Edge for iOS",mr.Platform.BrowserVersion=e[1]})),mr.Platform.BrowserEngine===fr&&Er&&(mr.Platform.BrowserEngine="WebKit"),"Android"===mr.Platform.OS&&"Safari"===mr.Platform.Browser&&(mr.Platform.Browser="Stock");const Fr=new Set(["Windows","macOS","Linux","Chrome OS"]).has(mr.Platform.OS)||"nwjs"===mr.Platform.Context;mr.Platform.IsDesktop=Fr,mr.Platform.IsMobile=!Fr}"Chrome"===mr.Platform.Browser&&"browser"===mr.Platform.Context&&/wv\)/.test(Gr)&&(mr.Platform.Context="webview"),"nwjs"!==mr.Platform.Context&&"undefined"!=typeof window&&(window.matchMedia&&window.matchMedia("(display-mode: standalone)").matches||navigator.standalone)&&(mr.Platform.Context="webapp"),mr.Platform.BrowserVersionNumber=parseFloat(mr.Platform.BrowserVersion);const Ir="macOS"===mr.Platform.OS&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2;Ir&&(mr.Platform.OS="iOS",mr.Platform.OSVersion=mr.Platform.BrowserVersion,mr.Platform.IsDesktop=!1,mr.Platform.IsMobile=!0,mr.Platform.IsIpadOS=!0),mr.Platform.IsAppleOS="macOS"===mr.Platform.OS||"iOS"===mr.Platform.OS}{let Or=function(e){return new Promise((t,s)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>s(e.error)})},Br=function(e){return new Promise((t,s)=>{e.oncomplete=()=>t(),e.onerror=()=>s(e.error),e.onabort=()=>s(e.error)})},Lr=function(e,t){return Yr(e,t)},kr=function(e,t){return Yr(e,t,!0)},Nr=function(e){Wr(e);let t=Hr.get(e);return t instanceof Promise||(t=qr(e),Hr.set(e,t),t.catch(t=>Hr.delete(e))),t},Wr=function(e){if("string"!=typeof e)throw new TypeError("expected string")},Vr=function(e,t){const s=e.objectStore(jr).openCursor();return new Promise(e=>{const i=[];s.onsuccess=s=>{const n=s.target.result;if(n){switch(t){case"entries":i.push([n.key,n.value]);break;case"keys":i.push(n.key);break;case"values":i.push(n.value)}n.continue()}else e(i)}})};s=Or,a=Br,c=Lr,i=kr,l=Nr,f=Wr,d=Vr;const Ur=2,jr="keyvaluepairs",Hr=new Map,zr="undefined"!=typeof IDBObjectStore&&"function"==typeof IDBObjectStore.prototype.getAll,Xr="undefined"!=typeof IDBObjectStore&&"function"==typeof IDBObjectStore.prototype.getAllKeys;async function Yr(e,t,s=!1,i=!0){const n=await Nr(e);try{return t(n.transaction([jr],s?"readwrite":"readonly"))}catch(n){if(i&&"InvalidStateError"===n.name)return Hr.delete(e),Yr(e,t,s,!1);throw n}}async function qr(e){Wr(e);const t=indexedDB.open(e,Ur);return t.addEventListener("upgradeneeded",t=>{try{t.target.result.createObjectStore(jr)}catch(t){console.error(`Failed to create objectstore for database ${e}`,t)}}),Or(t)}class Kr{constructor(e){Wr(e),this.name=e}async ready(){await Nr(this.name)}set(e,t){return Wr(e),kr(this.name,async s=>{const i=Or(s.objectStore(jr).put(t,e)),n=Br(s);await Promise.all([n,i])})}get(e){return Wr(e),Lr(this.name,async t=>{const s=Or(t.objectStore(jr).get(e)),i=Br(t),[n,r]=await Promise.all([i,s]);return r})}delete(e){return Wr(e),kr(this.name,async t=>{const s=Or(t.objectStore(jr).delete(e)),i=Br(t);await Promise.all([i,s])})}clear(){return kr(this.name,async e=>{const t=Or(e.objectStore(jr).clear()),s=Br(e);await Promise.all([s,t])})}keys(){return Lr(this.name,async e=>{let t;t=Xr?Or(e.objectStore(jr).getAllKeys()):Vr(e,"keys");const s=Br(e),[i,n]=await Promise.all([s,t]);return n})}values(){return Lr(this.name,async e=>{let t;t=zr?Or(e.objectStore(jr).getAll()):Vr(e,"values");const s=Br(e),[i,n]=await Promise.all([s,t]);return n})}entries(){return Lr(this.name,async e=>{const t=Vr(e,"entries"),s=Br(e),[i,n]=await Promise.all([s,t]);return n})}}self.KVStorageContainer=Kr}{let $r=function(e){throw new Error(`"${e}" is not implemented`)},Jr=function(e){if("function"==typeof e)throw new Error("localforage callback API is not implemented; please use the promise API instead")},Zr=function(e){return"object"==typeof e?new Promise(t=>{const{port1:s,port2:i}=new MessageChannel;i.onmessage=e=>t(e.data),s.postMessage(e)}):Promise.resolve(e)};r=$r,a=Jr,o=Zr;const Qr=self.KVStorageContainer,ea=[/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];class ta{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 ea)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 Zr(t);return void 0===s?null:s}async _setItemFallback(e,t){t=await Zr(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(e,t){if(Jr(t),this._isInMemory)return await this._getItemFallback(e);let s;try{s=await this._inst.get(e)}catch(t){return this._MaybeSwitchToMemoryFallback(t),this._isInMemory?await this._getItemFallback(e):(console.error(`Error reading '${e}' from storage, returning null: `,t),null)}return void 0===s?null:s}async setItem(e,t,s){if(Jr(s),void 0===t&&(t=null),this._isInMemory)await this._setItemFallback(e,t);else try{await this._inst.set(e,t)}catch(s){if(this._MaybeSwitchToMemoryFallback(s),!this._isInMemory)throw s;await this._setItemFallback(e,t)}}async removeItem(e,t){if(Jr(t),this._isInMemory)this._removeItemFallback(e);else try{await this._inst.delete(e)}catch(t){this._MaybeSwitchToMemoryFallback(t),this._isInMemory?this._removeItemFallback(e):console.error(`Error removing '${e}' from storage: `,t)}}async clear(e){if(Jr(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(Jr(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 Jr(e),this._isInMemory?Promise.resolve(!0):this._inst.ready()}createInstance(e){if(e.forceInMemoryFallback)return new ta(null);{const t=e.name;if("string"!=typeof t)throw new TypeError("invalid store name");const s=new Qr(t);return new ta(s)}}length(e){$r("localforage.length()")}key(e,t){$r("localforage.key()")}iterate(e,t){$r("localforage.iterate()")}setDriver(e){$r("localforage.setDriver()")}config(e){$r("localforage.config()")}defineDriver(e){$r("localforage.defineDriver()")}driver(){$r("localforage.driver()")}supports(e){$r("localforage.supports()")}dropInstance(){$r("localforage.dropInstance()")}}self.localforage=new ta(new Qr("localforage"))}{const sa=self.C3;if(sa.Supports={},sa.Supports.WebAnimations=(()=>{try{if("undefined"==typeof document)return!1;const e=document.createElement("div");return void 0!==e.animate&&void 0!==e.animate([{opacity:"0"},{opacity:"1"}],1e3).reverse}catch(e){return!1}})(),sa.Supports.DialogElement="undefined"!=typeof HTMLDialogElement,sa.Supports.RequestIdleCallback=!!self.requestIdleCallback,sa.Supports.ImageBitmap=!!self.createImageBitmap,sa.Supports.ImageBitmapOptions=!1,sa.Supports.ImageBitmapOptionsResize=!1,sa.Supports.ImageBitmap){try{self.createImageBitmap(new ImageData(32,32),{premultiplyAlpha:"none"}).then(()=>{sa.Supports.ImageBitmapOptions=!0}).catch(()=>{sa.Supports.ImageBitmapOptions=!1})}catch(ia){sa.Supports.ImageBitmapOptions=!1}try{self.createImageBitmap(new ImageData(32,32),{resizeWidth:10,resizeHeight:10}).then(e=>{sa.Supports.ImageBitmapOptionsResize=10===e.width&&10===e.height}).catch(()=>{sa.Supports.ImageBitmapOptionsResize=!1})}catch(na){sa.Supports.ImageBitmapOptionsResize=!1}}if(sa.Supports.ClipboardReadText=!(!navigator.clipboard||!navigator.clipboard.readText),sa.Supports.PermissionsQuery=!(!navigator.permissions||!navigator.permissions.query),sa.Supports.ClipboardPermissionsQuery=!1,sa.Supports.PermissionsQuery){const ra={name:"clipboard-read"};navigator.permissions.query(ra).then(()=>{sa.Supports.ClipboardPermissionsQuery=!0}).catch(()=>{sa.Supports.ClipboardPermissionsQuery=!1})}sa.Supports.AsyncClipboardApi=!!(navigator.permissions&&navigator.clipboard&&self.ClipboardItem),sa.Supports.Proxies="undefined"!=typeof Proxy,sa.Supports.DownloadAttribute="undefined"!=typeof document&&void 0!==document.createElement("a").download,sa.Supports.Fetch="function"==typeof fetch,sa.Supports.PersistentStorage=!!(self.isSecureContext&&"Opera"!==sa.Platform.Browser&&navigator.storage&&navigator.storage.persist),sa.Supports.StorageQuotaEstimate=!!(self.isSecureContext&&navigator.storage&&navigator.storage.estimate),sa.Supports.Fullscreen=(()=>{if("undefined"==typeof document)return!1;if("iOS"===sa.Platform.OS)return!1;const e=document.documentElement;return!!(e.requestFullscreen||e.msRequestFullscreen||e.mozRequestFullScreen||e.webkitRequestFullscreen)})(),sa.Supports.ImageDecoder=void 0!==self.ImageDecoder,sa.Supports.WebCodecs=!!self.VideoEncoder,sa.Supports.NativeFileSystemAPI=!!self.showOpenFilePicker,sa.Supports.QueryLocalFonts=!!self.queryLocalFonts,sa.Supports.UserActivation=!!navigator.userActivation,sa.Supports.CanvasToBlobWebP=!1,(async()=>{let e;"undefined"==typeof document?e=new OffscreenCanvas(32,32):(e=document.createElement("canvas"),e.width=32,e.height=32);const t=e.getContext("2d");t.fillStyle="blue",t.fillRect(0,0,32,32);let s=null;try{e.convertToBlob?s=await e.convertToBlob({type:"image/webp",quality:1}):e.toBlob&&(s=await new Promise(t=>e.toBlob(t,"image/webp",1))),sa.Supports.CanvasToBlobWebP=s&&"image/webp"===s.type}catch(e){sa.Supports.CanvasToBlobWebP=!1}})()}{const aa=self.C3;if(!String.prototype.trimStart){const oa=/^[\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(oa,"")}}if(!String.prototype.trimEnd){const ha=/[\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(ha,"")}}if(String.prototype.replaceAll||(String.prototype.replaceAll=function(e,t){return this.replace(new RegExp(aa.EscapeRegex(e),"g"),t)}),Array.prototype.values||(Array.prototype.values=function*(){for(const e of this)yield e}),!Array.prototype.flat){let la=function(e,t){return e.reduce((e,s)=>t>0&&Array.isArray(s)?(Array.prototype.push.apply(e,la(s,t-1)),e):(e.push(s),e),[])};arrayFlat=la,Array.prototype.flat=function(e=1){return la(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((e,t)=>navigator.webkitTemporaryStorage.queryUsageAndQuota((t,s)=>e({usage:t,quota:s}),t))}),void 0===self.isSecureContext&&(self.isSecureContext="https:"===location.protocol),void 0===self.globalThis&&(self.globalThis=self)}{let ca=function(e){let t="Assertion failure: "+e+"\n\nStack trace:\n"+ua.GetCallStack();console.error(t)};assertFail=ca;const ua=self.C3;self.assert=function(e,t){e||ca(t)}}{const da=self.C3,_a=self.C3X;da.IsNumber=function(e){return"number"==typeof e},da.IsFiniteNumber=function(e){return da.IsNumber(e)&&isFinite(e)},da.RequireNumber=function(e){if(!da.IsNumber(e))throw new TypeError("expected number")},da.RequireOptionalNumber=function(e){da.IsNullOrUndefined(e)},da.RequireNumberInRange=function(e,t,s){if(!da.IsNumber(e)||isNaN(e)||t>e||s0||ba.size>0){let e=[...new Set([...Ca.keys()].map(e=>ya.getName(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: ${e}`),Ca.clear(),ba.clear()}},Sa=function(e){let t=new Set;for(let s in e)t.add(s);return t},Ga=function(e,t){let s=Sa(t),i=Aa.get(e);if(i){let t=[];for(let e of i.values())s.has(e)?s.delete(e):t.push(e);ya.appendArray(t,[...s]),t.length&&console.warn(`[Defence] '${ya.getName(e)}' constructor creates inconsistent properties: ${t.join(", ")}`)}else Aa.set(e,s)};isValidTypeChange=ga,logDefendedObjectWarning=ma,CheckDefendedObjectsUsedCorrectly=fa,getObjectPropertySet=Sa,VerifyObjectPropertiesConsistent=Ga;const ya=self.C3,Ia=new Map;let Ta;ya.ColorLog=function(e,t){console.log(`%c${e}`,`font-weight: bold; color:${t}`)},ya.RafLog=function(e,...t){Ia.has(e)||Ia.set(e,-1),-1===Ia.get(e)&&Ia.set(e,requestAnimationFrame(()=>{console.log(`%c${e}`,"font-weight: bold",...t),Ia.set(e,-1)}))},ya.StartMeasure=function(e){performance.mark(e),Ta||(Ta=new Map),Ta.has(e)||Ta.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}`}})},ya.EndMeasure=function(e){performance.measure(`measure-${e}`,e);const t=performance.getEntriesByName(`measure-${e}`)[0],s=Ta.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}`)},ya.GetCallStack=function(){return(new Error).stack},ya.Debugger=function(){},ya.cast=function(e,t){return e&&e instanceof t?e:null},ya.getName=function(e){return void 0===e?"undefined":null===e?"null":"boolean"==typeof e?"":ya.IsNumber(e)?"":ya.IsString(e)?"":ya.IsArray(e)?"":"symbol"==typeof e?"<"+e.toString()+">":ya.IsFunction(e)?e.name&&"Function"!==e.name?e.name:"":"object"==typeof e?e.constructor&&e.constructor.name&&"Object"!==e.constructor.name?e.constructor.name:"":""},ya.getType=function(e){return null===e?"null":Array.isArray(e)?"array":typeof e},ya.range=function*(e,t){if(!isFinite(Math.abs(e-t)))throw new Error("Invalid parameters");if(e>t)for(let s=e-1;s>=t;s--)yield s;else for(let s=e;ss?s:e},Ma.clampAngle=function(e){return(e%=Da)<0&&(e+=Da),e},Ma.toRadians=function(e){return e*Ea},Ma.toDegrees=function(e){return e*Fa},Ma.hypot2DFast=function(e,t){return Math.sqrt(e*e+t*t)},Ma.hypot3DFast=function(e,t,s){return Math.sqrt(e*e+t*t+s*s)},Ma.distanceTo=function(e,t,s,i){return Ma.hypot2DFast(s-e,i-t)},Ma.distanceSquared=function(e,t,s,i){const n=s-e,r=i-t;return n*n+r*r},Ma.angleTo=function(e,t,s,i){return Math.atan2(i-t,s-e)},Ma.angleDiff=function(e,t){if(e===t)return 0;let s=Math.sin(e),i=Math.cos(e),n=s*Math.sin(t)+i*Math.cos(t);return n>=1?0:n<=-1?Math.PI:Math.acos(n)},Ma.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?n*r-i*a>0?Ma.clampAngle(e+s):Ma.clampAngle(e-s):Ma.clampAngle(t)},Ma.angleClockwise=function(e,t){let s=Math.sin(e);return Math.cos(e)*Math.sin(t)-s*Math.cos(t)<=0},Ma.angleLerp=function(e,t,s,i=0){let n=Ma.angleDiff(e,t);const r=Da*i;return Ma.angleClockwise(t,e)?Ma.clampAngle(e+(n+r)*s):Ma.clampAngle(e-(n+r)*s)},Ma.angleLerpClockwise=function(e,t,s,i=0){const n=Ma.angleDiff(e,t),r=Da*i;return Ma.angleClockwise(t,e)?Ma.clampAngle(e+(n+r)*s):Ma.clampAngle(e+(Da-n+r)*s)},Ma.angleLerpAntiClockwise=function(e,t,s,i=0){const n=Ma.angleDiff(e,t),r=Da*i;return Ma.angleClockwise(t,e)?Ma.clampAngle(e-(-Da+n-r)*s):Ma.clampAngle(e-(n+r)*s)},Ma.angleReflect=function(e,t){const s=Ma.angleDiff(e,t);return Ma.angleClockwise(e,t)?Ma.clampAngle(t-s):Ma.clampAngle(t+s)},Ma.lerp=function(e,t,s){return e+s*(t-e)},Ma.unlerp=function(e,t,s){return e===t?0:(s-e)/(t-e)},Ma.relerp=function(e,t,s,i,n){return Ma.lerp(i,n,Ma.unlerp(e,t,s))},Ma.qarp=function(e,t,s,i){return Ma.lerp(Ma.lerp(e,t,i),Ma.lerp(t,s,i),i)},Ma.cubic=function(e,t,s,i,n){return Ma.lerp(Ma.qarp(e,t,s,n),Ma.qarp(t,s,i,n),n)},Ma.cosp=function(e,t,s){return(e+t+(e-t)*Math.cos(s*Math.PI))/2},Ma.isPOT=function(e){return e>0&&!(e-1&e)},Ma.nextHighestPowerOfTwo=function(e){--e;for(let t=1;t<32;t<<=1)e|=e>>t;return e+1},Ma.roundToNearestFraction=function(e,t){return Math.round(e*t)/t},Ma.floorToNearestFraction=function(e,t){return Math.floor(e*t)/t},Ma.roundToDp=function(e,t){t=Math.max(Math.floor(t),0);const s=Math.pow(10,t);return Math.round(e*s)/s},Ma.countDecimals=function(e){return Math.floor(e)!==e&&e.toString().split(".")[1].length||0},Ma.toFixed=function(e,t){let s=e.toFixed(t),i=s.length-1;for(;i>=0&&"0"===s.charAt(i);--i);return i>=0&&"."===s.charAt(i)&&--i,i<0?s:s.substr(0,i+1)},Ma.PackRGB=function(e,t,s){return Ma.clamp(e,0,255)|Ma.clamp(t,0,255)<<8|Ma.clamp(s,0,255)<<16};const Oa=1024,Ba=1023,La=16384,ka=8191,Na=-8192;Ma.PackRGBAEx=function(e,t,s,i){return(e=Ma.clamp(Math.floor(1024*e),-8192,8191))<0&&(e+=16384),(t=Ma.clamp(Math.floor(1024*t),-8192,8191))<0&&(t+=16384),(s=Ma.clamp(Math.floor(1024*s),-8192,8191))<0&&(s+=16384),-(16384*e*16384*1024+16384*t*1024+1024*s+(i=Ma.clamp(Math.floor(1023*i),0,1023)))},Ma.PackRGBEx=function(e,t,s){return Ma.PackRGBAEx(e,t,s,1)},Ma.GetRValue=function(e){if(e>=0)return(255&e)/255;{let t=Math.floor(-e/274877906944);return t>8191&&(t-=16384),t/1024}},Ma.GetGValue=function(e){if(e>=0)return((65280&e)>>8)/255;{let t=Math.floor(-e%274877906944/16777216);return t>8191&&(t-=16384),t/1024}},Ma.GetBValue=function(e){if(e>=0)return((16711680&e)>>16)/255;{let t=Math.floor(-e%16777216/1024);return t>8191&&(t-=16384),t/1024}},Ma.GetAValue=function(e){return Ra(e)?0:e>=0?1:Math.floor(-e%1024)/1023},Ma.greatestCommonDivisor=function(e,t){for(e=Math.floor(e),t=Math.floor(t);0!==t;){let s=t;t=e%t,e=s}return e};const Wa=[[3,2],[4,3],[5,4],[5,3],[6,5],[14,9],[16,9],[16,10],[21,9]];Ma.getAspectRatio=function(e,t){if((e=Math.floor(e))===(t=Math.floor(t)))return[1,1];for(let s of Wa){let i=e/s[0]*s[1];if(Math.abs(t-i)<1)return s.slice(0);if(i=e/s[1]*s[0],Math.abs(t-i)<1)return[s[1],s[0]]}let s=Ma.greatestCommonDivisor(e,t);return[e/s,t/s]},Ma.segmentsIntersect=function(e,t,s,i,n,r,a,o){const h=Math.min(e,s),l=Math.max(e,s),c=Math.min(n,a),u=Math.max(n,a);if(lu)return!1;const d=Math.min(t,i),_=Math.max(t,i),p=Math.min(r,o),g=Math.max(r,o);if(_g)return!1;const m=n-e+a-s,f=r-t+o-i,S=s-e,G=i-t,y=a-n,I=o-r,T=Math.abs(G*y-I*S),C=y*f-I*m;if(Math.abs(C)>T)return!1;const b=S*f-G*m;return Math.abs(b)<=T},Ma.segmentsIntersectPreCalc=function(e,t,s,i,n,r,a,o,h,l,c,u){const d=Math.min(h,c),_=Math.max(h,c);if(r_)return!1;const p=Math.min(l,u),g=Math.max(l,u);if(og)return!1;const m=h-e+c-s,f=l-t+u-i,S=s-e,G=i-t,y=c-h,I=u-l,T=Math.abs(G*y-I*S),C=y*f-I*m;if(Math.abs(C)>T)return!1;const b=S*f-G*m;return Math.abs(b)<=T},Ma.segmentIntersectsQuad=function(e,t,s,i,n){const r=Math.min(e,s),a=Math.max(e,s),o=Math.min(t,i),h=Math.max(t,i),l=n.getTlx(),c=n.getTly(),u=n.getTrx(),d=n.getTry(),_=n.getBrx(),p=n.getBry(),g=n.getBlx(),m=n.getBly();return Ma.segmentsIntersectPreCalc(e,t,s,i,r,a,o,h,l,c,u,d)||Ma.segmentsIntersectPreCalc(e,t,s,i,r,a,o,h,u,d,_,p)||Ma.segmentsIntersectPreCalc(e,t,s,i,r,a,o,h,_,p,g,m)||Ma.segmentsIntersectPreCalc(e,t,s,i,r,a,o,h,g,m,l,c)},Ma.segmentIntersectsAnyN=function(e,t,s,i,n){const r=Math.min(e,s),a=Math.max(e,s),o=Math.min(t,i),h=Math.max(t,i);let l=0;for(let c=n.length-4;l<=c;l+=2)if(Ma.segmentsIntersectPreCalc(e,t,s,i,r,a,o,h,n[l],n[l+1],n[l+2],n[l+3]))return!0;return Ma.segmentsIntersectPreCalc(e,t,s,i,r,a,o,h,n[l],n[l+1],n[0],n[1])};const Va=2,Ua=1e-6;Ma.rayIntersect=function(e,t,s,i,n,r,a,o){const h=s-e,l=o-r,c=h*l-(i-t)*(a-n);if(0===c)return 2;const u=((t-i)*(a-e)+h*(o-t))/c;return 0=0&&I>=0&&y+I<=1},Ma.triangleCartesianToBarycentric=function(e,t,s,i,n,r,a,o){const h=n-s,l=r-i,c=a-s,u=o-i,d=e-s,_=t-i,p=h*h+l*l,g=h*c+l*u,m=c*c+u*u,f=d*h+_*l,S=d*c+_*u,G=p*m-g*g,y=(m*f-g*S)/G,I=(p*S-g*f)/G;return[1-y-I,y,I]},Ma.triangleBarycentricToCartesian3d=function(e,t,s,i,n,r,a,o,h,l,c,u){return[e*i+t*a+s*l,e*n+t*o+s*c,e*r+t*h+s*u]}}{const ja=self.C3;let Ha=null,za="";if("undefined"!=typeof document){Ha=document;const Ja=document.querySelector("base");za=Ja&&Ja.hasAttribute("href")?Ja.getAttribute("href"):"",za&&(za.startsWith("/")&&(za=za.substr(1)),za.endsWith("/")||(za+="/"))}ja.GetBaseHref=function(){return za},ja.GetBaseURL=function(){if(!Ha)return"";const e=Ha.location;return ja.GetPathFromURL(e.origin+e.pathname)+za},ja.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)},ja.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)},ja.GetFileExtension=function(e){let t=e.lastIndexOf(".");return t<1?"":e.substr(t)},ja.SetFileExtension=function(e,t){const s=e.lastIndexOf(".");return-1===s?e+"."+t:e.substr(0,s+1)+t},ja.GetFileNamePart=function(e){let t=e.lastIndexOf(".");return t<1?e:e.substr(0,t)},ja.NormalizeFileSeparator=function(e){return e.replace(/\\/g,"/")},ja.IsFileExtension=function(e,t){return t===(e?ja.GetFileExtension(e).slice(1):"")},ja.FileNameEquals=function(e,t){let s,i;return ja.IsFileLike(e)&&(s=ja.GetFileNamePart(e.name)),ja.IsString(e)&&(s=ja.GetFileNamePart(e)),ja.IsFileLike(t)&&(i=ja.GetFileNamePart(t.name)),ja.IsString(t)&&(i=ja.GetFileNamePart(t)),s===i},ja.ParseFilePath=function(e){e=ja.NormalizeFileSeparator(e);let t=/^\w\:\//.exec(e);t?(t=t[0],"/"!==(e=e.slice(3))[0]&&(e="/"+e)):t="",(e=e.replace(/\/{2,}/g,"/")).length>1&&"/"===e.slice(-1)&&(e=e.slice(0,-1));const s=e.lastIndexOf("/")+1;let i,n="",r=e,a="";s>0&&(n=e.slice(0,s),r=e.slice(s)),i=r;const o=r.lastIndexOf(".");return o>0&&(a=r.slice(o),i=r.slice(0,-a.length)),{dir:n,base:r,name:i,root:t,ext:a,full:t+n+r}},ja.Wait=function(e,t){return new Promise((s,i)=>{self.setTimeout(s,e,t)})},ja.swallowException=function(e){try{e()}catch(e){ja.isDebug&&console.warn("Swallowed exception: ",e)}},ja.noop=function(){},ja.equalsNoCase=function(e,t){return"string"==typeof e&&"string"==typeof t&&(e===t||e.normalize().toLowerCase()===t.normalize().toLowerCase())},ja.equalsCase=function(e,t){return"string"==typeof e&&"string"==typeof t&&(e===t||e.normalize()===t.normalize())},ja.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]},ja.truncateArray=function(e,t){e.length=t},ja.clearArray=function(e){e&&0!==e.length&&ja.truncateArray(e,0)},ja.clear2DArray=function(e){if(e){for(let t=0;ti&&ja.extendArray(e,t,s)},ja.shallowAssignArray=function(e,t){ja.clearArray(e),ja.appendArray(e,t)},ja.appendArray=function(e,t){if(t.length<1e4)e.push(...t);else for(let s=0,i=t.length;s=e.length)return;let s=e.length-1;for(let i=t;i=0&&e.splice(s,1)},ja.arraysEqual=function(e,t){let s=e.length;if(t.length!==s)return!1;for(let i=0;i=0&&ee.trim()).filter(e=>!!e):[]},ja.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},ja.mergeSets=function(e,t){return e.union?e.union(t):new Set([...e,...t])},ja.mergeSetsInPlace=function(e,t){for(const s of t)e.add(s);return e},ja.first=function(e){for(let t of e)return t;return null},ja.xor=function(e,t){return!e!=!t},ja.compare=function(e,t,s){switch(t){case 0:return e===s;case 1:return e!==s;case 2:return es;case 5:return e>=s;default:return!1}},ja.hasAnyOwnProperty=function(e){for(let t in e)if(e.hasOwnProperty(t))return!0;return!1},ja.PromiseAllWithProgress=function(e,t){return e.length?new Promise((s,i)=>{const n=[];let r=0,a=!1;for(let o=0,h=e.length;o{a||(n[o]=i,++r,r===e.length?s(n):t(r,e.length))}).catch(e=>{a=!0,i(e)})}):Promise.resolve([])};let Xa=[];ja.AddLibraryMemoryCallback=function(e){Xa.push(e)},ja.GetEstimatedLibraryMemoryUsage=function(){let e=0;for(let t of Xa)e+=t();return Math.floor(e)};let Ya=1;const qa=new Map,Ka=new MessageChannel;Ka.port2.onmessage=function(e){const t=e.data,s=qa.get(t);qa.delete(t),s&&s(performance.now())},ja.RequestUnlimitedAnimationFrame=function(e){const t=Ya++;return qa.set(t,e),Ka.port1.postMessage(t),t},ja.CancelUnlimitedAnimationFrame=function(e){qa.delete(e)},ja.PostTask=ja.RequestUnlimitedAnimationFrame,ja.WaitForNextTask=function(){return new Promise(e=>ja.PostTask(e))};const $a=new Set;ja.RequestPostAnimationFrame=function(e){const t=self.requestAnimationFrame(async s=>{await ja.WaitForNextTask(),$a.has(t)&&($a.delete(t),e(s))});return $a.add(t),t},ja.CancelPostAnimationFrame=function(e){$a.has(e)&&(self.cancelAnimationFrame(e),$a.delete(e))}}{const Za=self.C3;Za.IsAbsoluteURL=function(e){return/^(?:[a-z\-]+:)?\/\//.test(e)||"data:"===e.substr(0,5)||"blob:"===e.substr(0,5)},Za.IsRelativeURL=function(e){return!Za.IsAbsoluteURL(e)},Za.ThrowIfNotOk=function(e){if(!e.ok)throw new Error(`fetch '${e.url}' response returned ${e.status} ${e.statusText}`)},Za.FetchOk=function(e,t){return fetch(e,t).then(e=>(Za.ThrowIfNotOk(e),e))},Za.FetchText=function(e){return Za.FetchOk(e).then(e=>e.text())},Za.FetchJson=function(e){return Za.FetchOk(e).then(e=>e.json())},Za.FetchBlob=function(e){return Za.FetchOk(e).then(e=>e.blob())},Za.FetchArrayBuffer=function(e){return Za.FetchOk(e).then(e=>e.arrayBuffer())},Za.FetchImage=function(e){return new Promise((t,s)=>{const i=new Image;i.onload=()=>t(i),i.onerror=e=>s(e),i.src=e})},Za.BlobToArrayBuffer=function(e){return"function"==typeof e.arrayBuffer?e.arrayBuffer():new Promise((t,s)=>{const i=new FileReader;i.onload=()=>t(i.result),i.onerror=()=>s(i.error),i.readAsArrayBuffer(e)})},Za.BlobToString=function(e){return"function"==typeof e.text?e.text():new Promise((t,s)=>{const i=new FileReader;i.onload=()=>t(i.result),i.onerror=()=>s(i.error),i.readAsText(e)})},Za.BlobToJson=function(e){return Za.BlobToString(e).then(e=>JSON.parse(e))},Za.BlobToImage=async function(e,t){let s=URL.createObjectURL(e);try{const e=await Za.FetchImage(s);return URL.revokeObjectURL(s),s="",t&&"function"==typeof e.decode&&await e.decode(),e}finally{s&&URL.revokeObjectURL(s)}},Za.CreateCanvas=function(e,t){if("undefined"!=typeof document&&"function"==typeof document.createElement){const s=document.createElement("canvas");return s.width=e,s.height=t,s}return new OffscreenCanvas(e,t)},Za.CanvasToBlob=function(e,t,s){if("number"!=typeof s&&(s=1),t=t||"image/png",s=Za.clamp(s,0,1),e.convertToBlob)return e.convertToBlob({type:t,quality:s});if(e.toBlob)return new Promise(i=>e.toBlob(i,t,s));throw new Error("could not convert canvas to blob")},Za.DrawableToBlob=function(e,t,s){const i=Za.CreateCanvas(e.width,e.height);return i.getContext("2d").drawImage(e,0,0),Za.CanvasToBlob(i,t,s)},Za.ImageDataToBlob=function(e,t,s){if(Za.Supports.ImageBitmapOptions)return createImageBitmap(e,{premultiplyAlpha:"none"}).then(e=>Za.DrawableToBlob(e,t,s));if(Za.Supports.ImageBitmap)return createImageBitmap(e).then(e=>Za.DrawableToBlob(e,t,s));{const i=Za.CreateCanvas(e.width,e.height);return i.getContext("2d").putImageData(e,0,0),Za.CanvasToBlob(i,t,s)}},Za.CopySet=function(e,t){e.clear();for(const s of t)e.add(s)},Za.MapToObject=function(e){const t=Object.create(null);for(const[s,i]of e.entries())t[s]=i;return t},Za.ObjectToMap=function(e,t){t.clear();for(const[s,i]of Object.entries(e))t.set(s,i)},Za.ToSuperJSON=function e(t){if("object"==typeof t&&null!==t){if(t instanceof Set)return{_c3type_:"set",data:[...t].map(t=>e(t))};if(t instanceof Map)return{_c3type_:"map",data:[...t].map(t=>[t[0],e(t[1])])};{const s=Object.create(null);for(const[i,n]of Object.entries(t))s[i]=e(n);return s}}return t},Za.FromSuperJSON=function e(t){if("object"==typeof t&null!==t){if("set"===t._c3type_)return new Set(t.data.map(t=>e(t)));if("map"===t._c3type_)return new Map(t.data.map(t=>[t[0],e(t[1])]));{const s=Object.create(null);for(const[i,n]of Object.entries(t))s[i]=e(n);return s}}return t},Za.CSSToCamelCase=function(e){if(e.startsWith("--"))return e;let t="",s=!1,i=0;for(const n of e)"-"===n?i>0&&(s=!0):s?(t+=n.toUpperCase(),s=!1):t+=n,++i;return t},Za.IsIterator=function(e){return"object"==typeof e&&"function"==typeof e.next},Za.MakeFilledArray=function(e,t){const s=[];if("function"==typeof t)for(let i=0;i1&&(s-=1),s<1/6?e+6*(t-e)*s:s<.5?t:s<2/3?e+(t-e)*(2/3-s)*6:e};padTwoDigits=Qa,hueToRGB=eo;const to=self.C3,so=/([0-9.]+),([0-9.]+)\%?,([0-9.]+)\%?/i,io=/([0-9.]+),([0-9.]+)\%?,([0-9.]+)\%?,([0-9.])/i;to.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 to.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=to.clamp(+e,0,1)}getR(){return this._r}setG(e){this._g=to.clamp(+e,0,1)}getG(){return this._g}setB(e){this._b=to.clamp(+e,0,1)}getB(){return this._b}setA(e){this._a=to.clamp(+e,0,1)}getA(){return this._a}clone(){return to.New(to.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}writeToTypedArrayx4(e,t){const s=this._r,i=this._g,n=this._b,r=this._a;for(let a=0;a<4;++a)e[t++]=s,e[t++]=i,e[t++]=n,e[t++]=r}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=to.clamp(this._r,0,1),this._g=to.clamp(this._g,0,1),this._b=to.clamp(this._b,0,1),this._a=to.clamp(this._a,0,1),this}setFromRgbValue(e){this._r=to.GetRValue(e),this._g=to.GetGValue(e),this._b=to.GetBValue(e),this._a=to.GetAValue(e)}getCssRgb(e,t,s){return`rgb(${100*(to.IsFiniteNumber(e)?e:this.getR())}%, ${100*(to.IsFiniteNumber(t)?t:this.getG())}%, ${100*(to.IsFiniteNumber(s)?s:this.getB())}%)`}getCssRgba(e,t,s,i){return`rgba(${100*(to.IsFiniteNumber(e)?e:this.getR())}%, ${100*(to.IsFiniteNumber(t)?t:this.getG())}%, ${100*(to.IsFiniteNumber(s)?s:this.getB())}%, ${to.IsFiniteNumber(i)?i:this.getA()})`}toHexString(){const e=Math.round(255*this.getR()),t=Math.round(255*this.getG()),s=Math.round(255*this.getB());return"#"+Qa(e.toString(16))+Qa(t.toString(16))+Qa(s.toString(16))}parseHexString(e){if("string"!=typeof e)return!1;let t,s,i;if("#"===(e=e.trim()).charAt(0)&&(e=e.substr(1)),3===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(){return`${Math.round(255*this.getR())}, ${Math.round(255*this.getG())}, ${Math.round(255*this.getB())}`}toRgbArray(){return[Math.round(255*this.getR()),Math.round(255*this.getG()),Math.round(255*this.getB())]}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=to.clamp(t,0,100),s=to.clamp(s,0,100),i=to.clamp(i,0,1),e/=360,s/=100,0==(t/=100))n=r=a=s;else{const i=s<.5?s*(1+t):s+t-s*t,o=2*s-i;n=eo(o,i,e+1/3),r=eo(o,i,e),a=eo(o,i,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=so.exec(t),i=io.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;return`hsla(${to.Color.GetHue(e,t,s)}, ${to.Color.GetSaturation(e,t,s)}%, ${to.Color.GetLuminosity(e,t,s)}%, ${i})`}toHSLAArray(){const e=this._r,t=this._g,s=this._b;return[to.Color.GetHue(e,t,s),to.Color.GetSaturation(e,t,s),to.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],e.length>=4?this._a=e[3]:this._a=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 to.Color,s.setFromJSON(e);else{if(!(e instanceof to.Color))throw new Error("unexpected type");s=e}if(Array.isArray(t))i=new to.Color,i.setFromJSON(t);else{if(!(t instanceof to.Color))throw new Error("unexpected type");i=t}return s.equals(i)}static DiffChannel(e,t){return to.clamp(Math.max(e,t)-Math.min(e,t),0,1)}static Diff(e,t){const s=new to.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 to.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.5?r/(2-i-n):r/(i+n);return Math.round(100*a)}static GetLuminosity(e,t,s){const i=Math.max(e,t,s),n=(i+Math.min(e,t,s))/2;return i?Math.round(100*n):0}},to.Color.White=Object.freeze(to.New(to.Color,1,1,1,1)),to.Color.Black=Object.freeze(to.New(to.Color,0,0,0,1)),to.Color.TransparentBlack=Object.freeze(to.New(to.Color,0,0,0,0))}{const no=self.C3;no.Vector2=class{constructor(e,t){this._x=0,this._y=0,e instanceof no.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 no.angleTo(0,0,this._x,this._y)}lengthSquared(){return this._x*this._x+this._y*this._y}length(){return no.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=no.clamp(this._x,e,t),this._y=no.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 ro=self.C3;ro.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 ro.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){e=+e,t=+t,this._left=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 ro.Rect(this._left,this._top,this._right,this._bottom)}static Merge(e,t){const s=new ro.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 ro.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 ro.New(ro.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){e=+e,t=+t,this._left+=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._topthis._right&&this.swapLeftRight(),this._top>this._bottom&&this.swapTopBottom()}intersectsRect(e){return!(e._rightthis._right||e._top>this._bottom)}intersectsRectOffset(e,t,s){return!(e._right+tthis._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._leftthis._right&&(this._right=+e._right),e._bottom>this._bottom&&(this._bottom=+e._bottom)}lerpInto(e){this._left=ro.lerp(e._left,e._right,this._left),this._top=ro.lerp(e._top,e._bottom,this._top),this._right=ro.lerp(e._left,e._right,this._right),this._bottom=ro.lerp(e._top,e._bottom,this._bottom)}}}{const ao=self.C3;ao.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 ao.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 ao.New(ao.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){e=+e,t=+t,this._tlx+=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,h=e._top*s,l=e._right*s,c=e._bottom*s;this._tlx=o-n,this._tly=h+i,this._trx=l-n,this._try=h+r,this._brx=l-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;const n=this._brx-this._tlx,r=this._bry-this._tly,a=e-this._tlx,o=t-this._tly;let h=s*s+i*i,l=s*n+i*r,c=s*a+i*o;const u=n*n+r*r,d=n*a+r*o;let _=1/(h*u-l*l),p=(u*c-l*d)*_,g=(h*d-l*c)*_;return p>=0&&g>0&&p+g<1||(s=this._blx-this._tlx,i=this._bly-this._tly,h=s*s+i*i,l=s*n+i*r,c=s*a+i*o,_=1/(h*u-l*l),p=(u*c-l*d)*_,g=(h*d-l*c)*_,p>=0&&g>0&&p+g<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))||ao.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,h=this._bry,l=this._blx,c=this._bly;return ao.segmentIntersectsQuad(i,n,r,a,e)||ao.segmentIntersectsQuad(r,a,o,h,e)||ao.segmentIntersectsQuad(o,h,l,c,e)||ao.segmentIntersectsQuad(l,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")}}divide(e,t){this._tlx/=e,this._tly/=t,this._trx/=e,this._try/=t,this._brx/=e,this._bry/=t,this._blx/=e,this._bly/=t}}}{const oo=self.C3,ho=self.assert,lo=[0,0,1,0,1,1,0,1],co=oo.New(oo.Quad);oo.CollisionPoly=class extends oo.DefendedBase{constructor(e,t=!0){super(),e||(e=lo),this._ptsArr=Float64Array.from(e),this._bbox=new oo.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(lo)}copy(e){this.setPoints(e._ptsArr)}setBboxChanged(){this._isBboxChanged=!0}_updateBbox(){if(!this._isBboxChanged)return;const e=this._ptsArr;let t=e[0],s=e[1],i=t,n=s;for(let r=0,a=e.length;ri&&(i=a),on&&(n=o)}this._bbox.set(t,s,i,n),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){co.copy(e),co.offset(t,s),this.setPoints(co.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(e,t,s,i){const n=this._ptsArr;for(let r=0,a=n.length;r!e.GetEditorEaseData(s,t)||e.GetEditorEaseData(s,t).transition.IsForAnyPurpose())):(i=Go,n=[...i.keys()]);const r=n.sort();return[...mo.keys()].concat(r).filter(e=>!s.includes(e))}static GetRuntimeEaseNames(){this._CreateEaseMap();const e=[...Go.keys()];return e.sort(),[...mo.keys()].concat(e)}static GetCustomRuntimeEaseNames(){this._CreateEaseMap();const e=[...Go.keys()];return e.sort(),e}static IsPredefinedTranslatedName(e){for(const t of bo)if(self.lang(`ui.bars.timeline.eases.${t}`)===e)return!0;for(const t of wo)if(self.lang(`ui.bars.timeline.short-eases.${t}`)===e)return!0}static IsNamePredefined(e){return this._CreateEaseMap(),[...mo.keys()].includes(e)}static _GetEase(t){const s=Co.get(t);return s?go.get(s):e.IsNamePredefined(t)?go.get(t):Io.has(t)?Io.get(t):void 0}static GetBuiltInTransition(e){return this._CreateEaseMap(),To.get(e)}static GetEditorEase(t,s){this._CreateEaseMap();const i=e._GetEase(t);if(i)return i;if(!s)throw new Error("missing ease function");return fo.get(s).get(t)}static GetEditorEaseData(e,t){this._CreateEaseMap();const s=So.get(t);if(s)return s.get(e)}static HasEditorEase(t,s){return this._CreateEaseMap(),!!e._GetEase(t)||!!fo.get(s).get(t)}static GetRuntimeEase(t){this._CreateEaseMap();return e._GetEase(t)||Go.get(t)}static GetRuntimeEaseData(e){return this._CreateEaseMap(),yo.get(e)}static GetEaseFromIndex(e){return this._CreateEaseMap(),this.GetRuntimeEaseNames()[e]}static GetIndexForEase(e,t){return this._CreateEaseMap(),this.GetEditorEaseNames(t).indexOf(e)}static GetIndexForEaseAtRuntime(e){return this.GetIndexForEase(e)}static _CreateEaseMap(){0===go.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:.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("easeoutquart",[{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("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(t,s,i=!1){if("function"==typeof s)e._AddEase(t,s,"predefined");else{if(!po.IsArray(s))throw new Error("unexpected arguments");if(self.BuiltInTransition){const n=po.New(self.BuiltInTransition,t,i);n.SetFromJson(s),e._AddEase(t,(e,t,s,i)=>n.Interpolate(e,t,s,i),"predefined"),To.set(t,n)}else{const n=po.New(po.Transition,[t,s.map(e=>[e.x,e.y,e.sax,e.say,e.eax,e.eay,e.se,e.ee])],!1);n.MakeLinear(i),e._AddEase(t,(e,t,s,i)=>n.Interpolate(e,t,s,i),"predefined")}}}static _AddPrivateCustomEase(t,s){e._AddEase(t,s,"private")}static AddCustomEase(t,s,i,n){this._CreateEaseMap(),e._AddEase(t,s,"custom",i,n)}static RemoveCustomEase(e,t){if(this.IsNamePredefined(e))return;if([...Io.keys()].includes(e))return;const s=fo.get(t);s&&s.delete(e);const i=So.get(t);i&&i.delete(e)}static _AddEase(e,t,s,i,n){switch(s){case"predefined":go.set(e,t),mo.set(e,t);break;case"custom":i?(fo.has(i)||fo.set(i,new Map),So.has(i)||So.set(i,new Map),fo.get(i).set(e,t),So.get(i).set(e,n)):(Go.set(e,t),yo.set(e,n));break;case"private":go.set(e,t),Io.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){return t+3*e*(s-t)+3*e**2*(t+i-2*s)+e**3*(n-t+3*s-3*i)}static EaseSpline(e,t,s,i,n,r,a,o,h,l){if(i===n&&r===a)return e;const c=ko(e,t,i,r,o,l),u=Eo(s,n,a,h),d=Fo(s,n,a,h),_=Oo(s,n,a,h);return Bo(c,u,d,_)}static GetBezierSamples(e,t,s,i){const n=[],r=Eo(e,t,s,i),a=Fo(e,t,s,i),o=Oo(e,t,s,i);for(let e=0;ei-3*s+3*t-e,Fo=(e,t,s,i)=>3*s-6*t+3*e,Oo=(e,t,s,i)=>3*(t-e),Bo=(e,t,s,i)=>((t*e+s)*e+i)*e,Lo=(e,t,s,i)=>3*t*e*e+2*s*e+i,ko=(e,t,s,i,n,r)=>{if(1==e)return 1;let a=0,o=1,h=r[o],l=xo-1;for(r[xo-1];o!=l&&h<=e;)o++,h=r[o],a+=vo;o--,h=r[o];let c=a+(e-h)/(r[o+1]-h)*vo;const u=Eo(t,s,i,n),d=Fo(t,s,i,n),_=Oo(t,s,i,n),p=Lo(c,u,d,_);if(0===p)return c;if(p>=.01){for(let t=0;t<4;++t)c-=(Bo(c,u,d,_)-e)/Lo(c,u,d,_);return c}{let t,s,i=a,n=a+vo,r=0;do{c=i+(n-i)/2;let a=Bo(c,u,d,_)-e;a>0?n=c:i=c,t=Math.abs(a)>1e-7,s=++r<10}while(t&&s);return c}}}{let No=function(e){Wo.IsString(e)};RequireStringOrNumber=No;const Wo=self.C3;Wo.ProbabilityTable=class{constructor(e){this._items=[],this._name=e||"",this._totalWeight=0}Release(){this.Clear(),this._items=null}GetName(){return this._name}Clear(){Wo.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(t+=s,e0||(Ho.clearArray(this._captureListeners),this._captureListenersSet.clear(),Ho.clearArray(this._listeners),this._listenersSet.clear(),Ho.clearArray(this._queueModifyListeners),Ho.Release(this))}_AddListener(e,t){if(this._IsFiring())this._queueModifyListeners.push({op:"add",func:e,capture:t});else if(t){if(this._captureListenersSet.has(e))return;this._captureListeners.push(e),this._captureListenersSet.add(e)}else{if(this._listenersSet.has(e))return;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),Ho.arrayFindRemove(this._captureListeners,e)):this._listenersSet.has(e)&&(this._listenersSet.delete(e),Ho.arrayFindRemove(this._listeners,e))}_IsEmpty(){return!this._captureListeners.length&&!this._listeners.length}_IsFiring(){return this._fireDepth>0}_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.delete(s.func):e.delete(s.func);else{if("remove"!==s.op)throw new Error("invalid op");s.capture?(this._captureListenersSet.delete(s.func),t.add(s.func)):(this._listenersSet.delete(s.func),e.add(s.func))}Ho.arrayRemoveAllInSet(this._listeners,e),Ho.arrayRemoveAllInSet(this._captureListeners,t),Ho.clearArray(this._queueModifyListeners)}_FireCancellable(e){this._IncreaseFireDepth();let t=!1;for(let s=0,i=this._captureListeners.length;s0&&this._ProcessQueuedListeners()}SetDelayRemoveEventsEnabled(e){e?this._IncreaseFireDepth():this._DecreaseFireDepth()}_FireAsync(e){let t=[];for(let s=0,i=this._captureListeners.length;si(e)))}for(let s=0,i=this._listeners.length;si(e)))}return Promise.all(t).then(()=>!e.defaultPrevented)}_FireAndWait_AsyncOptional(e){const t=[];this._IncreaseFireDepth();for(let s=0,i=this._captureListeners.length;s!e.defaultPrevented):!e.defaultPrevented}async _FireAndWaitAsync(e){return await this._FireAndWait_AsyncOptional(e)}async _FireAndWaitAsyncSequential(e){this._IncreaseFireDepth();for(let t=0,s=this._captureListeners.length;t0?1:e)},qo=function(e){if(sh=-1,!th.length)return;let t=performance.now(),s=t,i=0,n=0;do{Ko(th.shift()),s=performance.now(),++i,n=(s-t)/i*1.1}while(th.length&&(eh&&0===ih&&void 0!==e?n{th.push({func:e,resolve:s,reject:i,stack:t}),nh?Ko(th.pop()):-1===sh&&Yo(16)})},$o.Asyncify.SetHighThroughputMode=function(e){if(e)++ih;else if(--ih,ih<0)throw new Error("already turned off high throughput mode")}}{let rh=function(){ch=-1},ah=function(){uh=-1,dh=-1;let e=Date.now();for(let t of _h)if(t._CheckTimeout(e)){let e=t._GetDeadline();(-1===dh||ee+1e3&&(self.clearTimeout(uh),dh=this._deadline,uh=self.setTimeout(ah,this._timeout+100))}_CheckTimeout(e){return!(e>=this._deadline&&(this._callback()?(this._deadline=e+this._timeout,0):(this._isActive=!1,1)))}_GetDeadline(){return this._deadline}Cancel(){this._isActive&&(_h.delete(this),this._isActive=!1,0===_h.size&&-1!==uh&&(self.clearTimeout(uh),uh=-1,dh=-1))}Release(){this.Cancel(),this._callback=null}}}{const ph=self.C3;ph.Disposable=class e{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(t){return new e(()=>t.Release())}static From(e,t,s,i,n){if("string"!=typeof t&&!Array.isArray(t))throw new TypeError("expected string or array");if(null==i)i=!1;else if("boolean"!=typeof i&&"object"!=typeof i)throw new TypeError("invalid event listener options");if(n&&(s=s.bind(n)),Array.isArray(t)||t.includes(" ")){"string"==typeof t&&(t=t.split(" "));const n=new ph.CompositeDisposable;for(const r of t)e.addEventListener(r,s,i),n.Add(ph.New(ph.Disposable,()=>e.removeEventListener(r,s,i)));return n}return e.addEventListener(t,s,i),ph.New(ph.Disposable,()=>e.removeEventListener(t,s,i))}},ph.StubDisposable=class extends ph.Disposable{SetAction(e){this._disposeAction=e}},ph.CompositeDisposable=class extends ph.Disposable{constructor(...e){super(),this._disposables=new Set;for(let t of e)this.Add(t)}Add(...e){if(this._disposed)throw new Error("already disposed");for(let t of e)this._disposables.add(t)}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 gh=self.C3;gh.KahanSum=class extends gh.DefendedBase{constructor(){super(),this._c=0,this._y=0,this._t=0,this._sum=0}Add(e){e=+e,this._y=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 mh=self.C3,fh={},Sh=!0,Gh=!1;fh.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},fh.RedBlackSet=function(e){this.size=0,this.sentinel=new fh.RBnode(this),this.sentinel.color=!1,this.root=this.sentinel,this.root.parent=this.sentinel,this.compare=e||this.default_compare},fh.RedBlackSet.prototype.default_compare=function(e,t){return e0){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;)t=s,s=s.parent;return s!=this.sentinel?s.key:null}return null},fh.RedBlackSet.prototype.predecessor=function(e){if(this.size>0){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;)t=s,s=s.parent;return s!=this.sentinel?s.key:null}return null},fh.RedBlackSet.prototype.getMin=function(){return this.min(this.root).key},fh.RedBlackSet.prototype.getMax=function(){return this.max(this.root).key},fh.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},fh.RedBlackSet.prototype.contains=function(e){return null!=this.get_(e).key},fh.RedBlackSet.prototype.getValues=function(){var e=[];return this.forEach(function(t){e.push(t)}),e},fh.RedBlackSet.prototype.insertAll=function(e){if("array"==fh.typeOf(e))for(var t=0;tt)return!1;var s=0;if(this.isEmpty())return!0;for(var i=this.min(this.root);i!=this.sentinel;i=this.successor_(i))fh.contains.call(e,e,i.key)&&s++;return s==this.getCount()},fh.RedBlackSet.prototype.intersection=function(e){var t=new fh.RedBlackSet(this.compare);if(this.isEmpty())return t;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},mh.RedBlackSet=class extends mh.DefendedBase{constructor(e){super(),this._rbSet=new fh.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;return e.min(e.root).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(e=!!e,this._enableQueue!==e&&(this._enableQueue=e,!e)){for(const e of this._queueRemove)this._rbSet.remove(e);this._queueRemove.clear();for(const e of this._queueInsert)this._rbSet.insert(e);this._queueInsert.clear()}}ForEach(e){this._rbSet.forEach(e)}*values(){if(this.IsEmpty())return;const e=this._rbSet;for(let t=e.min(e.root);t!=e.sentinel;t=e.successor_(t))yield t.key}[Symbol.iterator](){return this.values()}}}{const yh=self.C3;yh.PromiseThrottle=class{constructor(e=yh.hardwareConcurrency){this._maxParallel=e,this._queue=[],this._activeCount=0}Add(e,t){return new Promise((s,i)=>{const n={func:e,resolve:s,reject:i,opts:t};t?.signal&&t.signal.aborted?i(new Error("abort")):(t?.signal&&(n.onabort=()=>{const e=this._queue.indexOf(n);-1!==e&&(this._queue.splice(e,1),i(new Error("abort")))},t.signal.addEventListener("abort",n.onabort)),this._queue.push(n),this._MaybeStartNext())})}_FindInQueue(e){for(let t=0,s=this._queue.length;t=this._maxParallel)return;this._activeCount++;const e=this._queue.shift();e.opts?.signal&&e.onabort&&e.opts.signal.removeEventListener("abort",e.onabort);try{const t=await e.func();e.resolve(t)}catch(t){e.reject(t)}this._activeCount--,this._MaybeStartNext()}}}{const Ih=self.C3;Ih.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!==Ih.Battery&&Ih.Battery.IsOnBatteryPower()?this._intervalOnBattery:this._interval}Call(...e){if(-1!==this._timerId)return;this._callbackArguments=e;let t=Ih.FastGetDateNow(),s=t-this._lastCallTime,i=this._GetInterval();s>=i&&this._canRunImmediate?(this._lastCallTime=t,this._RunCallback()):this._timerId=self.setTimeout(this._timerCallFunc,Math.max(i-s,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=Ih.FastGetDateNow())}_OnTimer(){this._timerId=-1,this._lastCallTime=Ih.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 Th=self.C3;Th.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)throw new Error("no get base size callback set");return this._getBaseSizeCallback(e)}SetRasterAtSizeCallback(e){this._rasterAtSizeCallback=e}RasterAtSize(e,t,s,i,n,r){if(!this._rasterAtSizeCallback)throw new Error("no raster at size callback set");return this._rasterAtSizeCallback(e,t,s,i,n,r)}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=Th.New(Th.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 Ch=self.C3,bh=4096;Ch.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 this._refCount>0}GetRasterizedResult(){return this._rasterizedResult}ForceRasterAgain(){this._forceRaster=!0}async StartRasterForSize(e,t,s){if(0===t||0===s||this._hadError)return;if(this._isRasterizing)return;let i=Ch.nextHighestPowerOfTwo(Math.ceil(t)),n=Ch.nextHighestPowerOfTwo(Math.ceil(s));const r=Math.max(i,n);if(r>4096){const e=4096/r;t*=e,s*=e,i=Math.min(Math.ceil(i*e),4096),n=Math.min(Math.ceil(n*e),4096)}if(te?(t=n*e,s=n):(t=i,s=i/e)}if(this._manager.IsNpotSurfaceAllowed()&&(i=Math.ceil(t),n=Math.ceil(s)),i<=this._rasterSurfaceWidth&&n<=this._rasterSurfaceHeight&&!this._forceRaster)return;this._isRasterizing=!0,this._rasterSurfaceWidth=i,this._rasterSurfaceHeight=n;const a=await this._manager.RasterAtSize(this._dataSource,e,this._rasterSurfaceWidth,this._rasterSurfaceHeight,t,s);this._manager&&(this.ReleaseRasterizedResult(),this._rasterizedResult=a,this._rasterImageWidth=t,this._rasterImageHeight=s,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 wh=function(e){return Mh.get(e)};lookupHtmlEntity=wh;const Ph=self.C3;Ph.UTF8_BOM="\ufeff";const xh=new Set("0123456789");Ph.IsNumericChar=function(e){return xh.has(e)};const vh=new Set(" \t\n\r …           ​\u2028\u2029   ");Ph.IsWhitespaceChar=function(e){return vh.has(e)},Ph.FilterWhitespace=function(e){return[...e].filter(e=>!Ph.IsWhitespaceChar(e)).join("")},Ph.IsStringAllWhitespace=function(e){for(const t of e)if(!Ph.IsWhitespaceChar(t))return!1;return!0},Ph.IsCharArrayAllWhitespace=function(e){for(const t of e)if(!Ph.IsWhitespaceChar(t))return!1;return!0},Ph.IsUnprintableChar=function(e){return 1===e.length&&e.charCodeAt(0)<32},Ph.FilterUnprintableChars=function(e){return[...e].filter(e=>!Ph.IsUnprintableChar(e)).join("")};let Ah=null;try{Ah=new RegExp("\\p{P}(?<=[\\u3000-\\u303F\\uFF00-\\uFFEF])","u")}catch(t){console.warn("Unable to detect CJK punctuation: ",t)}Ph.IsCJKPunctuationChar=function(e){return!Ph.IsWhitespaceChar(e)&&Ah&&Ah.test(e)};const Rh=new Set("0123456789.+-e");Ph.IsStringNumber=function(e){if(!(e=e.trim()).length)return!1;let t=e.charAt(0);if("-"!==t&&!xh.has(t))return!1;for(let t of e)if(!Rh.has(t))return!1;return!0},Ph.RemoveTrailingDigits=function(e){let t=e.length;for(;t>0;){let s=e.charAt(t-1);if(!Ph.IsNumericChar(s))break;--t}return e.substr(0,t)},Ph.IncrementNumberAtEndOf=function(e){let t=Ph.RemoveTrailingDigits(e),s=e.substr(t.length);return s=s?(parseInt(s,10)+1).toString():"2",t+s};const Mh=new Map([["&","&"],["<","<"],[">",">"],['"',"""],["'","'"]]),Dh=/[&<>"']/g;Ph.EscapeHTML=function(e){return e.replace(Dh,wh)},Ph.EscapeJS=function(e){let t=Ph.ReplaceAll(e,"\\","\\\\");return t=Ph.ReplaceAll(t,'"','\\"'),t=Ph.ReplaceAll(t,"\t","\\t"),t=Ph.ReplaceAll(t,"\r",""),Ph.ReplaceAll(t,"\n","\\n")},Ph.EscapeXML=function(e){let t=Ph.ReplaceAll(e,"&","&");return t=Ph.ReplaceAll(t,"<","<"),t=Ph.ReplaceAll(t,">",">"),Ph.ReplaceAll(t,'"',""")};const Eh=/[-[\]{}()*+?.,\\^$|#\s]/g;Ph.EscapeRegex=function(e){return e.replace(Eh,"\\$&")},Ph.CountCharsInString=function(e,t){let s=0;for(const i of e)i===t&&++s;return s},Ph.StringPosToLineNumber=function(e,t){let s=0,i=0;for(;s-1;)a.push(r),n=r+i;return a},Ph.ReplaceAll=function(e,t,s){return e.replaceAll(t,()=>s)},Ph.ReplaceAllCaseInsensitive=function(e,t,s){return e.replace(new RegExp(Ph.EscapeRegex(t),"gi"),()=>s)},Ph.SetElementContent=function(e,t){"string"==typeof t?e.textContent=t:t.isPlainText()?e.textContent=t.toString():(e.innerHTML=t.toHTML(),t instanceof Ph.BBString&&t.attachLinkHandlers(e))},Ph.StringLikeEquals=function(e,t){return e instanceof Ph.HtmlString||e instanceof Ph.BBString?e.equals(t):t instanceof Ph.HtmlString||t instanceof Ph.BBString?t.equals(e):e===t},Ph.StringSubstitute=function(e,...t){let s=e;for(let i=0,n=t.length;i=0&&n>=0&&it?1:ei?1:s0&&(e-=24*t*3600,s.push(n(".days",null,t)))}if(t.hours){const t=Math.floor(e/3600);(t>0||s.length)&&(e-=3600*t,s.push(n(".hours",null,t)))}if(t.minutes){const i=Math.floor(e/60);(i>0||s.length||!t.seconds)&&(e-=60*i,s.push(n(".minutes",null,i)))}if(t.seconds){const t=Math.floor(e%60);s.push(n(".seconds",null,t))}const r=(t.approximate?i(".approx-prefix"):"")+s.join(i(".separator"));return Ph.Lang.PopContext(),r},Ph.ZeroPad=function(e,t){let s=e<0?"-":"",i=(e=Math.abs(e)).toString(),n=t-i.length;for(let e=0;ee.toUpperCase())},Ph.CompareVersionStrings=function(e,t){let s=e.split(".").map(e=>e.trim()),i=t.split(".").map(e=>e.trim());Ph.resizeArray(s,4,"0"),Ph.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 t=s[e]-i[e];if(0!==t)return t<0?-1:1}return 0},Ph.CreateGUID=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.floor(16*Math.random());return("x"===e?t:3&t|8).toString(16)})},Ph.StringHammingDistance=function(e,t){if(e.length!==t.length)throw new Error("strings must be same length");let s=0;for(let i=0,n=e.length;it.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 Wh=function(e,t,s){const i=jh.get(s);if(!i)return"class"===s?t?"":``:e;if("string"==typeof i){if("a"===i&&0===Yh.length||"abbr"===i&&0===qh.length)return e;if("a"!==i||t){if("abbr"!==i||t)return"<"+t+i+">";{const e=parseInt(s.substring(3),10)-1;if(e<0||e>=qh.length)throw new Error("invalid bbcode tip substitution");const t=qh[e];let i="";if("string"==typeof t?i=t:"function"==typeof t&&(i=t()),"string"!=typeof i)throw new TypeError("invalid bbcode tip");return``}}{const e=parseInt(s.substring(1),10)-1;if(e<0||e>=Yh.length)throw new Error("invalid bbcode link substitution");const t=Yh[e];if("string"==typeof t)return``;if("function"==typeof t)return``;throw new TypeError("invalid bbcode link action")}}if(Array.isArray(i)){let e=i[0],s=i[1];return t?"":`<${e} class="${s}">`}};bbToHtmlReplacerFunc=Wh;const Vh=self.C3,Uh=self.assert,jh=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"]]]),Hh=new Set(["icon"]),zh=/\[(\/?)([a-zA-Z0-9]+)\]/g,Xh=/\[(\/?)([^\[\n]*?)\]/g;let Yh=null,qh=null,Kh=0;const $h=/\n/g;Vh.BBString=class{constructor(e,t){if(this._bbstr=t&&t.noEscape?e:Vh.EscapeHTML(e),this._htmlstr="",this._convertLineBreaks=!1,this._linkActions=[],this._tipList=[],t){if(this._convertLineBreaks=!!t.convertLineBreaks,t.links){if(t.links.length>9)throw new Error("too many links");this._linkActions=t.links}if(t.tips){if(t.tips.length>9)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(zh,""):this._bbstr}toHTML(){if(this._isPlain)return this._bbstr;if(!this._htmlstr&&this._bbstr){let e=this._bbstr;this._hasAnyBBtags&&(Kh=0,Yh=this._linkActions,qh=this._tipList,e=e.replace(zh,Wh),Yh=null,qh=null),this._needsLineBreakConversion&&(e=e.replace($h,"
")),this._htmlstr=e}return this._htmlstr}attachLinkHandlers(e){if(this._linkActions.length)for(let t=0,s=this._linkActions.length;t0&&"\\"===t.charAt(r-1))continue;const a=n[0],o=n[1],h=n[2],l=t.substring(i,r);if(i=r+a.length,l&&e.push({text:l,styles:s.slice(0)}),h)if(o){const e=h.toLowerCase();for(let t=s.length-1;t>=0;--t)if(s[t].tag===e){s.splice(t,1);break}}else{let t=h,i=null;const n=h.indexOf("=");if(-1!==n?(t=h.substring(0,n).toLowerCase(),i=h.substring(n+1)):t=t.toLowerCase(),Hh.has(t)){if("icon"!==t)throw new Error(`unknown self-closing tag ${t}`);e.push({icon:i,styles:s.slice(0)})}else s.push({tag:t,param:i})}}ie.icon?Vh.New(Vh.IconFragment,{icon:e.icon,styles:e.styles}):Vh.New(Vh.TextFragment,{chArr:Vh.SplitGraphemes(e.text),styles:e.styles})),this._hasParsedFragments=!0,this._fragments}_ProcessBBCodeEscapeSequences(e){return e=Vh.ReplaceAll(e,"\\[","["),Vh.ReplaceAll(e,"\\\\","\\")}static StripTags(e){return Vh.New(Vh.BBString,e,{noEscape:!0}).toPlainText()}static StripAnyTags(e){return e.replace(Xh,"")}}}{let Jh=function(e){return" "!==e&&" "!==e&&sl.IsWhitespaceChar(e)},Zh=function(e){return il.has(e)},Qh=function(e){return sl.IsCJKPunctuationChar(e)&&!Zh(e)},el=function(e){for(;e.length>0&&Jh(e.at(-1));)e.pop()},tl=function(e){return"\n"===e||"\r\n"===e};IsWordBreakWhiteSpace=Jh,IsOpeningCJKPunctiationChar=Zh,IsContinuingCJKPunctuationChar=Qh,WordBreakTrimEnd=el,IsNewline=tl;const sl=self.C3,il=new Set("〈《「『【〔〖〘〚〝");sl.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 e=t(o);o.SetHeight(e.height),o.SetFontBoundingBoxAscent(e.fontBoundingBoxAscent||0),o.SetFontBoundingBoxDescent(e.fontBoundingBoxDescent||0),o.SetTopToAlphabeticDistance(e.topToAlphabeticDistance||0),o.IsText()?o.SetWidth(e.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(sl.New(sl.WordWrap.Line,{fragments:e,width:t,height:s,fontBoundingBoxAscent:i,fontBoundingBoxDescent:n,topToAlphabeticDistance:r}))}WordWrap(e,t,s,i,n){if("string"==typeof e&&(e=[sl.New(sl.TextFragment,{chArr:sl.SplitGraphemes(e)})]),sl.clearArray(this._lines),!e.length||1===e.length&&e[0].IsText()&&e[0].IsEmpty()||s<2)return;if(1===e.length){const i=e[0];if(i.IsText()&&i.GetLength()<=100&&!i.HasNewLine()){let{width:e,height:r,fontBoundingBoxAscent:a,fontBoundingBoxDescent:o,topToAlphabeticDistance:h}=t(i);if(e+=n,i.SetWidth(e),i.SetHeight(r),i.SetFontBoundingBoxAscent(a||0),i.SetFontBoundingBoxDescent(o||0),i.SetTopToAlphabeticDistance(h||0),e<=s)return void this._AddLine([i],e,r,a,o,h)}}let r;r="word"===i?this._TokeniseByWord(e):"cjk"===i?this._TokeniseByCJK(e):this._TokeniseByChar(e),this._WrapText(r,t,s,n)}_TokeniseByWord(e){const t=[];let s=[],i=!1;for(const n of e){const e=n.GetStyles();if(n.IsIcon())s.length>0&&t.push(s),t.push([n]),s=[];else for(const r of n.GetCharacterArray())if(tl(r))s.length>0&&t.push(s),t.push([sl.New(sl.TextFragment,{chArr:["\n"],styles:e})]),s=[];else if(0===s.length)s.push(sl.New(sl.TextFragment,{chArr:[r],styles:e})),i=Jh(r);else{const n=Jh(r);if(n===i){const t=s.at(-1);t.GetStyles()===e?t._AppendChar(r):s.push(sl.New(sl.TextFragment,{chArr:[r],styles:e}))}else t.push(s),s=[sl.New(sl.TextFragment,{chArr:[r],styles:e})],i=n}}return s.length>0&&t.push(s),t}_TokeniseByCJK(e){const t=[];let s=[],i=!1;for(const n of e){const e=n.GetStyles();if(n.IsIcon())s.length>0&&t.push(s),t.push([n]),s=[];else for(const r of n.GetCharacterArray())if(tl(r))s.length>0&&t.push(s),t.push([sl.New(sl.TextFragment,{chArr:["\n"],styles:e})]),s=[];else if(0===s.length)s.push(sl.New(sl.TextFragment,{chArr:[r],styles:e})),i=Zh(r);else if(i||Qh(r)){const t=s.at(-1);t.GetStyles()===e?t._AppendChar(r):s.push(sl.New(sl.TextFragment,{chArr:[r],styles:e})),i=Zh(r)}else t.push(s),s=[sl.New(sl.TextFragment,{chArr:[r],styles:e})],i=Zh(r)}return s.length>0&&t.push(s),t}_TokeniseByChar(e){const t=[];for(const s of e)if(s.IsText()){const e=s.GetCharacterArray();sl.appendArray(t,e.map(e=>[sl.New(sl.TextFragment,{chArr:[e],styles:s.GetStyles()})]))}else t.push([s]);return t}_CopyLine(e){return e.map(e=>e._Clone())}_AddWordToLine(e,t){const s=e.length?e.at(-1):null;let i=0;s&&s.IsText()&&t[0].IsText()&&t[0].GetStyles()===s.GetStyles()&&(s._Append(t[0].GetCharacterArray()),i=1);for(let s=t.length;i=s)if(n.length>0&&this._AddLine(n,r,a,o,h,l),n=[],i[0].IsText()&&sl.IsCharArrayAllWhitespace(i[0].GetCharacterArray()))r=0,a=0,o=0,h=0,l=0;else{this._AddWordToLine(n,i);const e=this._MeasureLine(n,t);r=e.width,a=e.height,o=e.fontBoundingBoxAscent,h=e.fontBoundingBoxDescent,l=e.topToAlphabeticDistance}else n=e,r=u,a=c.height,o=c.fontBoundingBoxAscent,h=c.fontBoundingBoxDescent,l=c.topToAlphabeticDistance}n.length>0&&this._AddLine(n,r,a,o,h,l),this._TrimLinesTrailingWhitespace(t,i)}_TrimLinesTrailingWhitespace(e,t){for(const s of this._lines){const i=s._GetFragmentsArray();if(!i.length)continue;let n=i.at(-1);if(n.IsText()){const r=n.GetCharacterArray(),a=r.slice(0);if(el(a),0===a.length)s.OffsetWidth(-n.GetWidth()),i.pop();else if(a.length0&&(n=i.at(-1),n.OffsetWidth(t),s.OffsetWidth(t))}}}Clear(){sl.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 nl=self.C3;nl.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 e=this._fragments;for(let t=e.length-1;t>=0;--t)yield e[t]}_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 rl=self.C3;rl.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(e){const t=this._styles;for(let s=t.length-1;s>=0;--s){const i=t[s];if(i.tag===e)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 al=self.C3;al.TextFragment=class extends al.FragmentBase{constructor(e){super(e),this._chArr=e.chArr}IsText(){return!0}_Append(e){al.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 al.New(al.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 ol=self.C3;ol.IconFragment=class extends ol.FragmentBase{constructor(e){super(e),this._icon=e.icon}IsIcon(){return!0}GetIconParameter(){return this._icon}_Clone(){return ol.New(ol.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 hl=self.C3;hl.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)return t;const s=this._getIconSetMetaCallback(e);return t=hl.New(hl.TextIconSet,this,{source:e,iconMeta:s}),this._iconSets.set(e,t),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 await this._getIconSetContentCallback(e)}}}{const ll=self.C3;ll.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=this._iconsArray.length?null:this._iconsArray[e]}GetTextIconByTag(e){return this._iconsByTag.get(e.toLowerCase())||null}}}{const cl=self.C3;cl.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 ul=function(e,t,s,i){const n=Il;ml.subtract(Gl,s,t),ml.subtract(yl,e,t),ml.cross(n,Gl,yl),ml.normalize(n,n),i.set(n[0],n[1],n[2],ml.dot(e,n))},dl=function(e,t,s,i,n,r,a){const o=a.x,h=a.y,l=a.z,c=a.w,u=a.xF,d=a.yF,_=a.zF,p=1-u,g=1-d,m=1-_;return o*e*u+o*i*p+h*t*d+h*n*g+l*s*_+l*r*m>=c||o*i*u+o*e*p+h*n*d+h*t*g+l*r*_+l*s*m>c},_l=function(e,t,s,i){return i.x*e+i.y*t+i.z*s>=i.w};PlaneFromPoints=ul,IsInFrontOfPlane=dl,IsPointInFrontOfPlane=_l;const pl=self.C3,gl=self.glMatrix,ml=gl.vec3,fl=gl.vec4,Sl=gl.mat4,Gl=ml.create(),yl=ml.create(),Il=ml.create(),Tl=fl.create(),Cl=Sl.create(),bl=ml.create(),wl=ml.create(),Pl=ml.create(),xl=ml.create(),vl=ml.create(),Al=ml.create(),Rl=ml.create(),Ml=ml.create(),Dl=fl.fromValues(0,0,1,1);pl.Gfx={Project(e,t,s,i,n,r,a){const o=i[0]*e+i[4]*t+i[8]*s+i[12],h=i[1]*e+i[5]*t+i[9]*s+i[13],l=i[2]*e+i[6]*t+i[10]*s+i[14],c=i[3]*e+i[7]*t+i[11]*s+i[15];let u=n[0]*o+n[4]*h+n[8]*l+n[12]*c,d=n[1]*o+n[5]*h+n[9]*l+n[13]*c,_=n[2]*o+n[6]*h+n[10]*l+n[14]*c,p=n[3]*o+n[7]*h+n[11]*l+n[15]*c;return 0!==p&&(p=1/p,u*=p,d*=p,_*=p,a[0]=(.5*u+.5)*r[2]+r[0],a[1]=(.5*d+.5)*r[3]+r[1],a[2]=.5*(1+_),!0)},Unproject(e,t,s,i,n,r,a){const o=Cl,h=Tl;return Sl.multiply(o,n,i),null!==Sl.invert(o,o)&&(h[0]=(e-r[0])/r[2]*2-1,h[1]=(t-r[1])/r[3]*2-1,h[2]=2*s-1,h[3]=1,fl.transformMat4(h,h,o),0!==h[3]&&(h[3]=1/h[3],a[0]=h[0]*h[3],a[1]=h[1]*h[3],a[2]=h[2]*h[3],!0))},UnprojectScreenToWorldZ(e,t,s,i,n,r,a){const o=Gl,h=yl;if(!pl.Gfx.Unproject(e,t,0,i,n,r,o))return!1;if(!pl.Gfx.Unproject(e,t,1,i,n,r,h))return!1;const l=yl;ml.subtract(l,h,o);const c=Il;ml.set(c,0,0,1);const u=-s,d=ml.dot(c,l);let _=0;if(0===d){if(0!==ml.dot(c,o)+u)return!1}else if(_=-(ml.dot(o,c)+u)/d,_<0)return!1;return ml.scaleAndAdd(a,o,l,_),!0}};class El{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=e>0?1:0,this.yF=t>0?1:0,this.zF=s>0?1:0}}pl.Gfx.ViewFrustum=class{constructor(){this._leftP=new El,this._topP=new El,this._rightP=new El,this._bottomP=new El,this._nearP=new El,this._farP=new El}CalculatePlanes(e,t){const s=Dl;pl.Gfx.Unproject(0,1,0,e,t,s,bl),pl.Gfx.Unproject(1,1,0,e,t,s,wl),pl.Gfx.Unproject(0,0,0,e,t,s,Pl),pl.Gfx.Unproject(1,0,0,e,t,s,xl),pl.Gfx.Unproject(0,1,1,e,t,s,vl),pl.Gfx.Unproject(1,1,1,e,t,s,Al),pl.Gfx.Unproject(0,0,1,e,t,s,Rl),pl.Gfx.Unproject(1,0,1,e,t,s,Ml),ul(Pl,bl,vl,this._leftP),ul(bl,wl,Al,this._topP),ul(wl,xl,Ml,this._rightP),ul(xl,Pl,Rl,this._bottomP),ul(Rl,vl,Al,this._farP),ul(xl,wl,bl,this._nearP)}ContainsAABB(e,t,s,i,n,r){return dl(e,t,s,i,n,r,this._leftP)&&dl(e,t,s,i,n,r,this._topP)&&dl(e,t,s,i,n,r,this._rightP)&&dl(e,t,s,i,n,r,this._bottomP)&&dl(e,t,s,i,n,r,this._nearP)&&dl(e,t,s,i,n,r,this._farP)}IsBehindNearPlane(e,t,s){return!_l(e,t,s,this._nearP)}}}{const Fl=self.C3,Ol=self.glMatrix,Bl=Ol.vec3,Ll=Ol.vec4,kl=Ol.mat4,Nl=kl.create(),Wl=Bl.fromValues(0,0,0),Vl=Bl.fromValues(0,0,0),Ul=Bl.fromValues(0,0,0),jl=Bl.fromValues(0,1,0),Hl=Ll.fromValues(0,0,0,0),zl=new Fl.Quad,Xl=new Fl.Rect,Yl=new Fl.Quad(0,0,1,0,1,1,0,1),ql={nearZ:1,farZ:1e4},Kl=kl.fromValues(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1);Fl.Gfx.RendererBase=class{constructor(e){e=Object.assign({},ql,e),this._width=0,this._height=0,this._fovY=Fl.toRadians(45),this._tan_fovY_2=Math.tan(this._fovY/2),this._matP=kl.create(),this._matMV=kl.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}_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){return this.IsZAxisScaleNormalized()?e/(2*this._GetTanFovYDiv2())/this.GetDefaultCameraZ(e):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()?kl.perspectiveZO(e,a,t,n,r):kl.perspective(e,a,t,n,r);else{const a=2*(s=1-s)-2,o=2*s,h=2*i-2,l=2*i,c=this._GetTanFovYDiv2()*n,u=c*t;kl.frustum(e,a*u,o*u,h*c,l*c,n,r),this.IsWebGPU()&&kl.mul(e,Kl,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),h=-a,l=a,c=-o,u=o;this.IsWebGPU()?kl.orthoZO(e,h,l,c,u,this.GetNearZ(),this.GetFarZ()):kl.ortho(e,h,l,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=Ul;Bl.set(o,a,-a,1);const h=Wl,l=Vl;Bl.multiply(h,t,o),Bl.multiply(l,s,o),kl.lookAt(e,h,l,i||jl),o[2]=r,kl.scale(e,e,o)}CalculateLookAtModelView2(e,t,s,i,n,r,a,o){return Bl.set(Wl,e,t,s),Bl.set(Vl,i,n,r),this.CalculateLookAtModelView(Nl,Wl,Vl,jl,a,o),Nl}_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(){Fl.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,n,r){const a=Fl.Gfx.StateGroup.MakeKey(e,t,s,i,n,r);let o=this._stateGroups.get(a);return o||(o=Fl.New(Fl.Gfx.StateGroup,this,e,t,s,i,n,r),this._stateGroups.set(a,o)),o.AddRef(),o}ReleaseStateGroup(e){e.DecRef(),0===e._GetRefCount()&&(this._currentStateGroup===e&&(this._currentStateGroup=null),this._stateGroups.delete(e.GetKey()),e.Release())}_InitBlendModeData(e){Fl.clearArray(this._blendModeTable),this._namedBlendModeMap.clear();let t=0;for(const s of e){const e=s[0],i=s[1],n=s[2];this._blendModeTable.push([i,n]),this._namedBlendModeMap.set(e,{number:t,srcBlend:i,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 n=Fl.angleTo(e,t,s,i),r=Math.sin(n),a=Math.cos(n),o=.5*this._lineWidth,h=r*o,l=a*o,c=this._lineCap;2===c?this.LinePreCalc_LineCap2(e,t,0,s,i,0,h,l):1===c?this.LinePreCalc_LineCap1(e,t,0,s,i,0,h,l):this.LinePreCalc_LineCap0(e,t,0,s,i,0,h,l)}Line3D(e,t,s,i,n,r){const a=Fl.angleTo(e,t,i,n),o=Math.sin(a),h=Math.cos(a),l=.5*this._lineWidth,c=o*l,u=h*l,d=this._lineCap;2===d?this.LinePreCalc_LineCap2(e,t,s,i,n,r,c,u):1===d?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 h=this._lineOffset,l=e+h-o,c=t+h-a,u=i+h+o,d=n+h+a,_=2*o,p=2*a,g=l+a,m=c-o,f=l-a+_,S=c+o+p,G=u+a,y=d-o,I=u-a-_,T=d+o-p;this.Quad3D2(g,m,s,G,y,r,I,T,r,f,S,s,Yl)}LinePreCalc_LineCap1(e,t,s,i,n,r,a,o){const h=this._lineOffset,l=e+h-o,c=t+h-a,u=i+h+o,d=n+h+a,_=l+a,p=c-o,g=l-a,m=c+o,f=u+a,S=d-o,G=u-a,y=d+o;this.Quad3D2(_,p,s,f,S,r,G,y,r,g,m,s,Yl)}LinePreCalc_LineCap0(e,t,s,i,n,r,a,o){const h=this._lineOffset,l=e+h,c=t+h,u=i+h,d=n+h,_=l+a,p=c-o,g=l-a,m=c+o,f=u+a,S=d-o,G=u-a,y=d+o;this.Quad3D2(_,p,s,f,S,r,G,y,r,g,m,s,Yl)}TexturedLine(e,t,s,i,n,r){const a=Fl.angleTo(e,t,s,i),o=Math.sin(a),h=Math.cos(a),l=.5*this._lineWidth,c=o*l,u=h*l,d=this._lineCap;2===d?this.TexturedLinePreCalc_LineCap2(e,t,s,i,c,u,n,r):1===d?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 h=this._lineOffset,l=e+h-r,c=t+h-n,u=s+h+r,d=i+h+n,_=2*r,p=2*n,g=l+n,m=c-r,f=l-n+_,S=c+r+p,G=u+n,y=d-r,I=u-n-_,T=d+r-p;zl.set(g,m,G,y,I,T,f,S),Xl.set(a,0,o,0),this.Quad3(zl,Xl)}TexturedLinePreCalc_LineCap1(e,t,s,i,n,r,a,o){const h=this._lineOffset,l=e+h-r,c=t+h-n,u=s+h+r,d=i+h+n,_=l+n,p=c-r,g=l-n,m=c+r,f=u+n,S=d-r,G=u-n,y=d+r;zl.set(_,p,f,S,G,y,g,m),Xl.set(a,0,o,0),this.Quad3(zl,Xl)}TexturedLinePreCalc_LineCap0(e,t,s,i,n,r,a,o){const h=this._lineOffset,l=e+h,c=t+h,u=s+h,d=i+h,_=l+n,p=c-r,g=l-n,m=c+r,f=u+n,S=d-r,G=u-n,y=d+r;zl.set(_,p,f,S,G,y,g,m),Xl.set(a,0,o,0),this.Quad3(zl,Xl)}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=Fl.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(this._lineWidthStack.length>=100)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(this._lineCapStack.length>=100)throw new Error("pushed too many line caps - check push/pop pairs");this._lineCapStack.push(0),this._lineCap=0}PushLineCapSquare(){if(this._lineCapStack.length>=100)throw new Error("pushed too many line caps - check push/pop pairs");this._lineCapStack.push(1),this._lineCap=1}PushLineCapZag(){if(this._lineCapStack.length>=100)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(this._lineOffsetStack.length>=100)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)}ResetCullState(){this.SetCullFaceMode(0),this.SetFrontFaceWinding(0)}ConvexPoly(e){const t=e.length/2;if(t<3)throw new Error("need at least 3 points");const s=t-2,i=s-1,n=e[0],r=e[1];for(let t=0;t0)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.SetCullFaceMode(this._cullFaceMode),e.SetFrontFaceWinding(this._frontFaceWinding),e._SetCurrentStateGroup(this)}GetKey(){return Jl.Gfx.StateGroup.MakeKey(this._shaderProgramName,this._blendMode,this._color,this._zElevation,this._cullFaceMode,this._frontFaceWinding)}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,n,r){return("string"==typeof e?e:e.GetName())+","+t+","+s.getR()+","+s.getG()+","+s.getB()+","+s.getA()+","+i+","+n+","+r}}}{let Zl=function(e,t,s){const i=s.getTlx(),n=s.getTly(),r=s.getTrx()-i,a=s.getTry()-n;return[i+r*e+(s.getBlx()-i)*t,n+a*e+(s.getBly()-n)*t]};interpolateQuad=Zl;const Ql=globalThis.C3,ec=globalThis.assert,tc=65535;Ql.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]=Zl(e._x,e._y,t),this._zElevation=e._zElevation,this._u=Ql.lerp(s.getLeft(),s.getRight(),e._u),this._v=Ql.lerp(s.getTop(),s.getBottom(),e._v)}_Interpolate_TexQuad(e,t,s){[this._x,this._y]=Zl(e._x,e._y,t),this._zElevation=e._zElevation,[this._u,this._v]=Zl(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}},Ql.Gfx.Mesh=class{constructor(e,t,s){if(e<2||t<2)throw new Error("invalid mesh size");this._hsize=e,this._vsize=t,this._owner=s||null,this._pts=[],this._minX=0,this._minY=0,this._maxX=1,this._maxY=1,this._maxZ=0,this._bboxChanged=!1,this._meshChunks=[],this._lastZOffset=0,this._dataArrsChanged=!0;const i=e-1,n=t-1;for(let s=0;s0}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,t,s){const i=s instanceof Ql.Rect;if(e.GetHSize()!==this.GetHSize()||e.GetVSize()!==this.GetVSize())throw new Error("source mesh wrong size");const n=e._pts,r=this._pts;for(let e=0,a=r.length;e[e,t,s]);const s=this._pts;let i=s[0];for(let n=1,r=s.length;n{u=Ql.clamp(Ql.lerp(u,m,S),0,1),d=Ql.clamp(Ql.lerp(d,f,S),0,1),n.push(u,d)};for(let e=0,I=i.length;e1e6)throw new Error("Too many mesh poly points");const e=_*o,i=p*h,r=(_+1)*o,a=(p+1)*h;if(g=Ql.isPointInTriangleInclusive(u,d,e,i,r,i,r,a),0!==G&&(S=Ql.rayIntersectExtended(u,d,m,f,e,i,r,a,-.001),S>=0&&S<=s))y(),g=!g,G=0;else if(p>0&&2!==G&&(S=Ql.rayIntersectExtended(u,d,m,f,e,i,r,i,t),S>=0&&S<=s))y(),p--,g=!1,G=4;else if(_=0&&S<=s))y(),_++,g=!1,G=1;else if(_>0&&1!==G&&(S=Ql.rayIntersectExtended(u,d,m,f,e,i,e,a,t),S>=0&&S<=s))y(),_--,g=!0,G=3;else{if(!(p=0&&S<=s)))break;y(),p++,g=!0,G=2}}}return Ql.New(Ql.CollisionPoly,n)}TransformCollisionPoly(e,t){const s=this._TransformPolyPoints(e);this._SimplifyPoly(s),t.setPoints(s)}_TransformPolyPoints(e){const t=[],s=e.pointsArr();for(let e=0,i=s.length;e.001||0==d&&0===_)&&t.push(i,n),i=c,n=u,r=d,a=_}t.length>=6&&t.lengthe.map(e=>e.SaveToJson()))}}LoadFromJson(e){const t=this.GetHSize(),s=this.GetVSize();if(e.cols!==t||e.rows!==s)throw new Error("mesh data wrong size");const i=e.points;for(let e=0;ei||this._height>i)throw new Error("texture data exceeds maximum texture size");const n=this._renderer.GetContext(),r=this._renderer.GetWebGLVersionNumber();this._texture=n.createTexture(),n.bindTexture(n.TEXTURE_2D,this._texture),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1);const a=sc(this._pixelFormat,n);if(this._renderer.SupportsNPOTTextures()||s||!this._IsTiled())if(r>=2){let t;t=this._isMipMapped?Math.floor(Math.log2(Math.max(this._width,this._height))+1):1,n.texStorage2D(n.TEXTURE_2D,t,a.sizedinternalformat,this._width,this._height),e instanceof ArrayBuffer?n.texSubImage2D(n.TEXTURE_2D,0,0,0,this._width,this._height,a.format,a.type,new Uint8Array(e)):null!==e&&n.texSubImage2D(n.TEXTURE_2D,0,0,0,a.format,a.type,e)}else e instanceof ArrayBuffer?n.texImage2D(n.TEXTURE_2D,0,a.internalformat,this._width,this._height,0,a.format,a.type,new Uint8Array(e)):null===e?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,e);else{if(null===e)throw new Error("cannot pass null data when creating a NPOT tiled texture without NPOT support");if(e instanceof ArrayBuffer&&(e=new ImageData(new Uint8ClampedArray(e),this._width,this._height)),e instanceof ImageData){const t=ic.CreateCanvas(this._width,this._height);t.getContext("2d").putImageData(e,0,0),e=t}const t=ic.CreateCanvas(ic.nextHighestPowerOfTwo(this._width),ic.nextHighestPowerOfTwo(this._height)),s=t.getContext("2d");s.imageSmoothingEnabled="nearest"!==this._sampling,s.drawImage(e,0,0,this._width,this._height,0,0,t.width,t.height),n.texImage2D(n.TEXTURE_2D,0,a.internalformat,a.format,a.type,t)}null!==e&&this._SetTextureParameters(n),n.bindTexture(n.TEXTURE_2D,null),this._renderer._ResetLastTexture(),this._refCount=1,cc.add(this)}_CreateDynamic(e,t,s){if(s=Object.assign({},hc,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,!oc.has(this._wrapX)||!oc.has(this._wrapY))throw new Error("invalid wrap mode");if(!rc.has(this._sampling))throw new Error("invalid sampling");if(!nc.has(this._pixelFormat))throw new Error("invalid pixel format");if(!ac.has(this._mipMapQuality))throw new Error("invalid mipmap quality");this._isStatic=!1,this._width=Math.floor(e),this._height=Math.floor(t);const i=ic.isPOT(this._width)&&ic.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();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);const o=sc(this._pixelFormat,r),h=a>=2?o.sizedinternalformat:o.internalformat;r.texImage2D(r.TEXTURE_2D,0,h,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,cc.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=ic.isPOT(this._width)&&ic.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 t="trilinear"===this._sampling&&!this._renderer.HasMajorPerformanceCaveat();e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t?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&&this._anisotropy>0&&"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({},lc,t);const s=e.width||e.videoWidth,i=e.height||e.videoHeight,n=this._renderer.GetWebGLVersionNumber(),r=this._renderer.GetContext();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);const a=sc(this._pixelFormat,r),o=n>=2?a.sizedinternalformat:a.internalformat;try{if(this._width===s&&this._height===i){const t=ic.isPOT(this._width)&&ic.isPOT(this._height);r.texSubImage2D(r.TEXTURE_2D,0,0,0,a.format,a.type,e),(t||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 t=ic.isPOT(this._width)&&ic.isPOT(this._height);if(!this._renderer.SupportsNPOTTextures()&&this._IsTiled()&&!t)throw new Error("non-power-of-two tiled textures not supported");r.texImage2D(r.TEXTURE_2D,0,o,a.format,a.type,e),(t||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(this._refCount>0)throw new Error("texture still has references");if(!this._texture)throw new Error("already deleted texture");cc.delete(this),this._renderer.GetContext().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(){cc.clear()}static allTextures(){return cc.values()}}}{const uc=self.C3,dc=self.assert,_c=self.glMatrix,pc=_c.vec3,gc=_c.mat4,mc=new Set(["nearest","bilinear","trilinear"]),fc={sampling:"trilinear",alpha:!0,depth:!1,isSampled:!0,isDefaultSize:!0,multisampling:0},Sc=new Set;uc.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=gc.create(),this._lastFov=0,this._lastNearZ=0,this._lastFarZ=0}_Create(e,t,s){s=Object.assign({},fc,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,!mc.has(this._sampling))throw new Error("invalid sampling");if(this._multisampling>0&&(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 e=this._texture._GetTexture();n.bindFramebuffer(n.FRAMEBUFFER,this._frameBuffer),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,e,0),this._depth&&(n.bindFramebuffer(n.FRAMEBUFFER,this._frameBufferNoDepth),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,e,0))}else{this._renderBuffer=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,this._renderBuffer);const e=this._alpha?n.RGBA8:n.RGB8;if(this._multisampling>0){const t=n.getInternalformatParameter(n.RENDERBUFFER,e,n.SAMPLES);if(t&&t[0]){const e=t[0];this._multisampling>e&&(this._multisampling=e)}else this._multisampling=0}0===this._multisampling?n.renderbufferStorage(n.RENDERBUFFER,e,this._width,this._height):n.renderbufferStorageMultisample(n.RENDERBUFFER,this._multisampling,e,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),Sc.add(this)}_Resize(e,t){if(this._width===e&&this._height===t)return;this._width=e,this._height=t,this._CalculateProjection();const s=this._renderer.GetContext();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));const i=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");Sc.delete(this);const e=this._renderer.GetContext();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),this._renderer.GetWebGLVersionNumber()>=2&&(e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null)),e.deleteFramebuffer(this._frameBuffer),this._depth&&e.deleteFramebuffer(this._frameBufferNoDepth);const t=this._renderer.GetBatchState();t.currentFramebuffer=null,t.currentFramebufferNoDepth=null,this._frameBuffer=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({},fc,e)).sampling===this.IsLinearSampling()&&!!e.alpha===this.HasAlpha()&&!!e.depth===this.HasDepthBuffer()&&!(this._renderer.GetWebGLVersionNumber()>=2&&!!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 await uc.ImageDataToBlob(s)}static OnContextLost(){Sc.clear()}static allRenderTargets(){return Sc.values()}static ResizeAll(e,t){for(const s of Sc)s.IsDefaultSize()&&s._Resize(e,t)}}}{const Gc=self.C3,yc=self.glMatrix,Ic=yc.vec3,Tc=yc.mat4,Cc=new Set(["aPos","aTex","aColor","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"]);Gc.Gfx.WebGLShaderProgram=class extends Gc.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);s.shaderSource(a,i),s.compileShader(a);const o=s.createShader(s.VERTEX_SHADER);s.shaderSource(o,n),s.compileShader(o);const h=s.createProgram();s.attachShader(h,a),s.attachShader(h,o),s.bindAttribLocation(h,0,"aPos"),s.bindAttribLocation(h,1,"aTex"),s.bindAttribLocation(h,2,"aColor"),s.bindAttribLocation(h,3,"aPoints"),s.linkProgram(h);const l=e._GetParallelShaderCompileExtension();if(l?await e._WaitForObjectReady(()=>s.getProgramParameter(h,l.COMPLETION_STATUS_KHR)):await Gc.Wait(5),!s.getShaderParameter(a,s.COMPILE_STATUS)){const e=s.getShaderInfoLog(a);throw s.deleteShader(a),s.deleteShader(o),s.deleteProgram(h),new Error("Error compiling fragment shader: "+e)}if(!s.getShaderParameter(o,s.COMPILE_STATUS)){const e=s.getShaderInfoLog(o);throw s.deleteShader(a),s.deleteShader(o),s.deleteProgram(h),new Error("Error compiling vertex shader: "+e)}if(!s.getProgramParameter(h,s.LINK_STATUS)){const e=s.getProgramInfoLog(h);throw s.deleteShader(a),s.deleteShader(o),s.deleteProgram(h),new Error("Error linking shader program: "+e)}const c=Gc.FilterUnprintableChars(s.getProgramInfoLog(h)||"").trim();return c&&!Gc.IsStringAllWhitespace(c)&&console.info(`[WebGL] Shader program '${r}' compilation log: `,c),s.deleteShader(a),s.deleteShader(o),h}static async Create(e,t){const s=await Gc.Gfx.WebGLShaderProgram.Compile(e,t);return new Gc.Gfx.WebGLShaderProgram(e,s,t)}constructor(e,t,s){super(e,s);const i=e.GetContext(),n=e.GetBatchState();e.EndBatch(),i.useProgram(t),this._gl=i,this._shaderProgram=t,this._isDeviceTransform=""===s.name;const r=i.getAttribLocation(t,"aPos"),a=i.getAttribLocation(t,"aTex"),o=i.getAttribLocation(t,"aColor");this._locAPoints=i.getAttribLocation(t,"aPoints"),-1!==r&&(i.bindBuffer(i.ARRAY_BUFFER,e._vertexBuffer),i.vertexAttribPointer(r,3,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!==o&&(i.bindBuffer(i.ARRAY_BUFFER,e._colorBuffer),i.vertexAttribPointer(o,4,e.IsColorDataF16()?i.HALF_FLOAT:i.FLOAT,!1,0,0),i.enableVertexAttribArray(o)),-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 Gc.Gfx.WebGLShaderUniform(this,"matP","mat4"),this._uMatMV=new Gc.Gfx.WebGLShaderUniform(this,"matMV","mat4"),this._uColor=new Gc.Gfx.WebGLShaderUniform(this,"color","vec4"),this._uSamplerFront=new Gc.Gfx.WebGLShaderUniform(this,"samplerFront","sampler"),this._uPointTexStart=new Gc.Gfx.WebGLShaderUniform(this,"pointTexStart","vec2"),this._uPointTexEnd=new Gc.Gfx.WebGLShaderUniform(this,"pointTexEnd","vec2"),this._uZElevation=new Gc.Gfx.WebGLShaderUniform(this,"zElevation","float"),this._uTileSize=new Gc.Gfx.WebGLShaderUniform(this,"tileSize","vec2"),this._uTileSpacing=new Gc.Gfx.WebGLShaderUniform(this,"tileSpacing","vec2"),this._uColor2=new Gc.Gfx.WebGLShaderUniform(this,"color2_","vec4"),this._uOutlineThickness=new Gc.Gfx.WebGLShaderUniform(this,"outlineThickness","float"),this._uSamplerBack=new Gc.Gfx.WebGLShaderUniform(this,"samplerBack","sampler"),this._uSamplerDepth=new Gc.Gfx.WebGLShaderUniform(this,"samplerDepth","sampler"),this._uDestStart=new Gc.Gfx.WebGLShaderUniform(this,"destStart","vec2"),this._uDestEnd=new Gc.Gfx.WebGLShaderUniform(this,"destEnd","vec2"),this._uSrcStart=new Gc.Gfx.WebGLShaderUniform(this,"srcStart","vec2"),this._uSrcEnd=new Gc.Gfx.WebGLShaderUniform(this,"srcEnd","vec2"),this._uSrcOriginStart=new Gc.Gfx.WebGLShaderUniform(this,"srcOriginStart","vec2"),this._uSrcOriginEnd=new Gc.Gfx.WebGLShaderUniform(this,"srcOriginEnd","vec2"),this._uPixelSize=new Gc.Gfx.WebGLShaderUniform(this,"pixelSize","vec2"),this._uSeconds=new Gc.Gfx.WebGLShaderUniform(this,"seconds","float"),this._uDevicePixelRatio=new Gc.Gfx.WebGLShaderUniform(this,"devicePixelRatio","float"),this._uLayerScale=new Gc.Gfx.WebGLShaderUniform(this,"layerScale","float"),this._uLayerAngle=new Gc.Gfx.WebGLShaderUniform(this,"layerAngle","float"),this._uLayoutStart=new Gc.Gfx.WebGLShaderUniform(this,"layoutStart","vec2"),this._uLayoutEnd=new Gc.Gfx.WebGLShaderUniform(this,"layoutEnd","vec2"),this._uZNear=new Gc.Gfx.WebGLShaderUniform(this,"zNear","float"),this._uZFar=new Gc.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());const h=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 e of h){const t=e[0],s=e[2],i=new Gc.Gfx.WebGLShaderUniform(this,t,s);"color"===s?i.Init3f(0,0,0):i.Init1f(0),this._uCustomParameters.push(i)}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(e){for(let t=0,s=e.length;t=2?n="#version 300 es\n"+Gc.Gfx.WebGLShaderProgram._GetConservativeDepthShaderPrefix(i):(t&&(n="#extension GL_EXT_frag_depth : enable\n"),s&&(n+="#extension GL_EXT_shader_texture_lod : enable\n",n+="#extension GL_OES_standard_derivatives : enable\n")),n+`\nprecision highp float;\n${e>=2?"in":"varying"} vec2 vTex;\n${e>=2?"out lowp vec4 outColor;":""}\n${e>=2?"in":"varying"} lowp vec4 vColor;\nuniform lowp sampler2D samplerFront;\nuniform vec2 pixelSize;\n\nuniform vec2 tileSize;\nuniform vec2 tileSpacing;\nuniform float outlineThickness;\n\nconst float PI = 3.1415926;\n\nlowp vec4 cospVec4(lowp vec4 a, lowp vec4 b, float x)\n{\n\treturn (a + b + (a - b) * cos(x * PI)) / 2.0;\n}\n\nvec3 randVec3(vec2 seed)\n{\n\treturn vec3(fract(sin(dot(seed.xy + vec2(0.1, 0.1), vec2(12.9898,78.233))) * 43758.5453),\n\t\t\t\tfract(sin(dot(seed.yx + vec2(0.1, 0.1), vec2(12.9898,-78.233))) * 43758.5453),\n\t\t\t\tfract(sin(dot(seed.xy + vec2(0.1, 0.1), vec2(-12.9898,-78.233))) * 43758.5453));\n}\n\nlowp vec4 sampleTile(vec2 tile, vec2 uv, vec2 ddx, vec2 ddy)\n{\n\tvec2 posRandom = tileSize;\n\tfloat angleRandom = outlineThickness;\n\t\n\tvec3 rand = (randVec3(floor(tile + 0.5)) - 0.5) * 2.0;\n\t\n\tfloat angle = angleRandom * rand.z * PI;\n\tfloat sin_a = sin(angle);\n\tfloat cos_a = cos(angle);\n\tfloat aspect = pixelSize.x / pixelSize.y;\n\n\tvec2 mid = tile + vec2(0.5, 0.5);\n\tvec2 dp = uv - mid;\n\tdp.x /= aspect;\n\tvec2 r = vec2(dp.x * cos_a - dp.y * sin_a,\n\t\t\t\t dp.y * cos_a + dp.x * sin_a);\n\tr.x *= aspect;\n\n\tvec2 p = mid + r + (posRandom * rand.xy / 2.0);\n\t\n\t${e>=2?"return textureGrad(samplerFront, p, ddx, ddy);":""}\n\t${e<2&&s?"return texture2DGradEXT(samplerFront, p, ddx, ddy);":""}\n\t${e<2&&!s?"return texture2D(samplerFront, p);":""}\n}\n\nvoid main(void) {\n\t\n\t${e<2?"lowp vec4 outColor;":""}\n\t\n\tfloat blendMarginX = tileSpacing.x;\n\tfloat blendMarginY = tileSpacing.y;\n\t\n\tvec2 tile = floor(vTex);\n\tvec2 tex = fract(vTex);\n\tvec2 ddx = ${e>=2||s?"dFdx(vTex)":"vec2(0.0, 0.0)"};\n\tvec2 ddy = ${e>=2||s?"dFdy(vTex)":"vec2(0.0, 0.0)"};\n\t\n\tvec4 curTile = sampleTile(tile, vTex, ddx, ddy);\n\t\n\tbool inLeftMargin = (tex.x < blendMarginX);\n\tbool inRightMargin = (tex.x > 1.0 - blendMarginX);\n\tbool inTopMargin = (tex.y < blendMarginY);\n\tbool inBottomMargin = (tex.y > 1.0 - blendMarginY);\n\t\n\tif (inLeftMargin)\n\t{\n\t\tlowp vec4 leftTile = sampleTile(tile + vec2(-1.0, 0.0), vTex, ddx, ddy);\n\t\tfloat leftMix = (tex.x / (blendMarginX * 2.0)) + 0.5;\n\t\tlowp vec4 leftMixedTile = cospVec4(leftTile, curTile, leftMix);\n\t\t\n\t\tif (inTopMargin)\n\t\t{\n\t\t\tlowp vec4 topTile = sampleTile(tile + vec2(0.0, -1.0), vTex, ddx, ddy);\n\t\t\tlowp vec4 topLeftTile = sampleTile(tile + vec2(-1.0, -1.0), vTex, ddx, ddy);\n\t\t\tlowp vec4 topLeftMixedTile = cospVec4(topLeftTile, topTile, leftMix);\n\t\t\t\n\t\t\toutColor = cospVec4(topLeftMixedTile, leftMixedTile, (tex.y / (blendMarginY * 2.0)) + 0.5);\n\t\t}\n\t\telse if (inBottomMargin)\n\t\t{\n\t\t\tlowp vec4 bottomTile = sampleTile(tile + vec2(0.0, 1.0), vTex, ddx, ddy);\n\t\t\tlowp vec4 bottomLeftTile = sampleTile(tile + vec2(-1.0, 1.0), vTex, ddx, ddy);\n\t\t\tlowp vec4 bottomLeftMixedTile = cospVec4(bottomLeftTile, bottomTile, leftMix);\n\t\t\t\n\t\t\toutColor = cospVec4(leftMixedTile, bottomLeftMixedTile, (tex.y - (1.0 - blendMarginY)) / (blendMarginY * 2.0));\n\t\t}\n\t\telse\n\t\t{\n\t\t\toutColor = leftMixedTile;\n\t\t}\n\t}\n\telse if (inRightMargin)\n\t{\n\t\tlowp vec4 rightTile = sampleTile(tile + vec2(1.0, 0.0), vTex, ddx, ddy);\n\t\tfloat rightMix = (tex.x - (1.0 - blendMarginX)) / (blendMarginX * 2.0);\n\t\tlowp vec4 rightMixedTile = cospVec4(curTile, rightTile, rightMix);\n\t\t\n\t\tif (inTopMargin)\n\t\t{\n\t\t\tlowp vec4 topTile = sampleTile(tile + vec2(0.0, -1.0), vTex, ddx, ddy);\n\t\t\tlowp vec4 topRightTile = sampleTile(tile + vec2(1.0, -1.0), vTex, ddx, ddy);\n\t\t\tlowp vec4 topRightMixedTile = cospVec4(topTile, topRightTile, rightMix);\n\t\t\t\n\t\t\toutColor = cospVec4(topRightMixedTile, rightMixedTile, (tex.y / (blendMarginY * 2.0)) + 0.5);\n\t\t}\n\t\telse if (inBottomMargin)\n\t\t{\n\t\t\tlowp vec4 bottomTile = sampleTile(tile + vec2(0.0, 1.0), vTex, ddx, ddy);\n\t\t\tlowp vec4 bottomRightTile = sampleTile(tile + vec2(1.0, 1.0), vTex, ddx, ddy);\n\t\t\tlowp vec4 bottomRightMixedTile = cospVec4(bottomTile, bottomRightTile, rightMix);\n\t\t\t\n\t\t\toutColor = cospVec4(rightMixedTile, bottomRightMixedTile, (tex.y - (1.0 - blendMarginY)) / (blendMarginY * 2.0));\n\t\t}\n\t\telse\n\t\t{\n\t\t\toutColor = rightMixedTile;\n\t\t}\n\t}\n\telse if (inTopMargin)\n\t{\n\t\tlowp vec4 topTile = sampleTile(tile + vec2(0.0, -1.0), vTex, ddx, ddy);\n\t\toutColor = cospVec4(topTile, curTile, (tex.y / (blendMarginY * 2.0)) + 0.5);\n\t}\n\telse if (inBottomMargin)\n\t{\n\t\tlowp vec4 bottomTile = sampleTile(tile + vec2(0.0, 1.0), vTex, ddx, ddy);\n\t\toutColor = cospVec4(curTile, bottomTile, (tex.y - (1.0 - blendMarginY)) / (blendMarginY * 2.0));\n\t}\n\telse\n\t{\n\t\toutColor = curTile;\n\t}\n\t\n\toutColor *= vColor;\n\t${e<2?"gl_FragColor = outColor;":""}\n\t${e>=2?"gl_FragDepth = (outColor.a == 0.0 ? 1.0 : gl_FragCoord.z);":""}\n\t${e<2&&t?"gl_FragDepthEXT = (outColor.a == 0.0 ? 1.0 : gl_FragCoord.z);":""}\n}\n`}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(e){return["#version 300 es",Gc.Gfx.WebGLShaderProgram._GetConservativeDepthShaderPrefix(e),"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["varying lowp vec4 vColor;","void main(void) {","\tgl_FragColor = vColor;","}"].join("\n")}static GetLinearGradientFillFragmentShaderSource(){return["precision lowp float;","varying mediump vec2 vTex;","varying vec4 vColor;","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(vColor.rgb), toLinear(color2_.rgb), vTex.x);","\tfloat a = mix(vColor.a, color2_.a, vTex.x);","\tgl_FragColor = vec4(fromLinear(linearGrad) * a, a);","}"].join("\n")}static GetPenumbraFillFragmentShaderSource(){return["precision lowp float;","varying highp vec2 vTex;","varying vec4 vColor;","void main(void) {","\thighp float grad = vTex.x / (1.0 - vTex.y);","\tgl_FragColor = vColor * (1.0 - (cos(grad * 3.141592653589793) + 1.0) / 2.0);","}"].join("\n")}static GetSmoothLineFillFragmentShaderSource(){return["varying mediump vec2 vTex;","varying lowp vec4 vColor;","void main(void) {","\tlowp float f = 1.0 - abs(vTex.y - 0.5) * 2.0;","\tgl_FragColor = vColor * f;","}"].join("\n")}static GetHardEllipseFillFragmentShaderSource(){return["varying highp vec2 vTex;","varying lowp vec4 vColor;","void main(void) {","\thighp vec2 diff = vTex - vec2(0.5, 0.5);","\thighp vec2 diffSq = diff * diff;","\thighp float f = step(diffSq.x + diffSq.y, 0.25);","\tgl_FragColor = vColor * f;","}"].join("\n")}static GetHardEllipseOutlineFragmentShaderSource(){return["varying highp vec2 vTex;","varying lowp vec4 vColor;","uniform highp vec2 pixelSize;","uniform highp float outlineThickness;","void main(void) {","\thighp vec2 diff = vTex - vec2(0.5, 0.5);","\thighp vec2 diffSq = diff * diff;","\thighp float distSq = diffSq.x + diffSq.y;","\thighp vec2 norm = normalize(diff);","\thighp vec2 halfNorm = norm * 0.5;","\thighp float innerF = step(distSq, 0.25);","\thighp vec2 innerEdge = halfNorm - pixelSize * norm * outlineThickness;","\thighp vec2 innerEdgeSq = innerEdge * innerEdge;","\thighp float outerF = step(innerEdgeSq.x + innerEdgeSq.y, distSq);","\tgl_FragColor = vColor * innerF * outerF;","}"].join("\n")}static GetSmoothEllipseFillFragmentShaderSource(){return["varying highp vec2 vTex;","varying lowp vec4 vColor;","uniform highp vec2 pixelSize;","void main(void) {","\thighp vec2 diff = vTex - vec2(0.5, 0.5);","\thighp vec2 diffSq = diff * diff;","\thighp vec2 norm = normalize(diff);","\thighp vec2 halfNorm = norm * 0.5;","\thighp vec2 halfNormSq = halfNorm * halfNorm;","\thighp vec2 innerEdge = halfNorm - pixelSize * norm;","\thighp vec2 innerEdgeSq = innerEdge * innerEdge;","\thighp float f = smoothstep(halfNormSq.x + halfNormSq.y, innerEdgeSq.x + innerEdgeSq.y, diffSq.x + diffSq.y);","\tgl_FragColor = vColor * f;","}"].join("\n")}static GetSmoothEllipseOutlineFragmentShaderSource(){return["varying highp vec2 vTex;","varying lowp vec4 vColor;","uniform highp vec2 pixelSize;","uniform highp float outlineThickness;","void main(void) {","\thighp vec2 diff = vTex - vec2(0.5, 0.5);","\thighp vec2 diffSq = diff * diff;","\thighp float distSq = diffSq.x + diffSq.y;","\thighp vec2 norm = normalize(diff);","\thighp vec2 halfNorm = norm * 0.5;","\thighp vec2 halfNormSq = halfNorm * halfNorm;","\thighp vec2 pxNorm = pixelSize * norm;","\thighp vec2 innerEdge1 = halfNorm - pxNorm;","\thighp vec2 innerEdge1Sq = innerEdge1 * innerEdge1;","\thighp float innerF = smoothstep(halfNormSq.x + halfNormSq.y, innerEdge1Sq.x + innerEdge1Sq.y, distSq);","\thighp vec2 innerEdge2 = halfNorm - pxNorm * outlineThickness;","\thighp vec2 innerEdge2Sq = innerEdge2 * innerEdge2;","\thighp vec2 innerEdge3 = halfNorm - pxNorm * (outlineThickness + 1.0);","\thighp vec2 innerEdge3Sq = innerEdge3 * innerEdge3;","\thighp float outerF = smoothstep(innerEdge3Sq.x + innerEdge3Sq.y, innerEdge2Sq.x + innerEdge2Sq.y, distSq);","\tgl_FragColor = vColor * innerF * outerF;","}"].join("\n")}}}{const bc=self.C3,wc=self.glMatrix,Pc=wc.mat4,xc=new Map([["float",1],["percent",1],["sampler",1],["vec2",2],["vec3",3],["color",3],["vec4",4],["mat4",16]]);bc.Gfx.WebGLShaderUniform=class{constructor(e,t,s){if(!xc.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=xc.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&&(t[0]=e,this._gl.uniform1i(this._location,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;Pc.exactEquals(t,e)||(bc.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 vc=self.C3,Ac=self.glMatrix,Rc=Ac.vec4,Mc=Ac.mat4,Dc=0,Ec=1,Fc=2,Oc=3,Bc=4,Lc=5,kc=6,Nc=7,Wc=8,Vc=9,Uc=10,jc=11,Hc=12,zc=13,Xc=14,Yc=15,qc=16,Kc=17,$c=18,Jc=19,Zc=20,Qc=21,eu=22,tu=23,su=24,iu=25,nu=26,ru=27,au=28,ou=29,hu=30;vc.Gfx.BatchState=class{constructor(e){this.renderer=e,this.currentMV=Mc.create(),this.currentMatP=Mc.create(),this.currentFramebuffer=null,this.currentFramebufferNoDepth=null,this.isDepthSamplingEnabled=!1,this.currentShader=null,this.pointTexCoords=new vc.Rect,this.clearColor=vc.New(vc.Color,0,0,0,0)}},vc.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=[]}InitDraw(e,t){this._type=1,this._startIndex=e,this._indexCount=t}DoDraw(){const e=this._gl;e.drawElements(e.TRIANGLES,this._indexCount,e.UNSIGNED_SHORT,this._startIndex)}InitSetTexture(e){this._type=2,this._texParam=e}DoSetTexture(){const e=this._gl,t=this._texParam;e.bindTexture(e.TEXTURE_2D,t?t._GetTexture():null)}InitSetGradientColor(e){this._type=20,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=3,this._startIndex=e,this._indexCount=t}DoSetBlend(){this._gl.blendFunc(this._startIndex,this._indexCount)}InitSetViewport(e,t,s,i){this._type=4;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=5,Mc.copy(this._mat4param,e)}DoSetProjection(){const e=this._batchState,t=e.renderer._allShaderPrograms,s=e.currentShader,i=this._mat4param;for(let e=0,n=t.length;e{const t=e.font.GetName();for(const e of Tu)(e.IsBBCodeEnabled()||du.equalsNoCase(e.GetFontName(),t))&&e._SetWordWrapChanged()});let Cu=!1,bu=!1;du.Gfx.RendererText=class{constructor(e,t){t=Object.assign({},mu,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=du.New(du.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 du.Rect,this._scaleFactor=1,this._textureTimeout=new du.IdleTimeout(()=>{this.ReleaseTexture(),this._SetTextCanvasSize(8,8)},t.timeout),this.ontextureupdate=null,this._wasReleased=!1,Tu.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,Tu.delete(this)}_SetDrawChanged(){this._drawChanged=!0}_SetTextLayoutChanged(){this._SetDrawChanged(),this._textLayoutChanged=!0}_SetWordWrapChanged(){this._SetTextLayoutChanged(),this._wordWrapChanged=!0}SetBBCodeEnabled(e){if(e=!!e,this._isBBcodeEnabled===e)return;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){e=!!e,this._iconSmoothing!==e&&(this._iconSmoothing=e,this._SetDrawChanged())}SetFontName(e){e||(e="serif"),this._fontName!==e&&(this._fontName=e,this._SetWordWrapChanged())}GetFontName(){return this._fontName}SetFontSize(e){e<.1&&(e=.1),this._fontSize!==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){e=!!e,this._isBold!==e&&(this._isBold=e,this._SetWordWrapChanged())}IsBold(){return this._isBold}SetItalic(e){e=!!e,this._isItalic!==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;e?s.push(n+"pt"):s.push(n*this.GetDrawScale()+"pt");let r=this._fontName;const 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&&(gu.has(r)?s.push(r):s.push('"'+r+'"')),s.join(" ")}SetColor(e){e instanceof du.Color&&(e=e.getCssRgb()),this._colorStr!==e&&(this._colorStr=e,this._SetDrawChanged())}SetColorRgb(e,t,s){fu.setRgb(e,t,s),this.SetColor(fu)}SetHorizontalAlignment(e){if(!Su.has(e))throw new Error("invalid horizontal alignment");this._horizontalAlign!==e&&(this._horizontalAlign=e,this._SetTextLayoutChanged())}GetHorizontalAlignment(){return this._horizontalAlign}SetVerticalAlignment(e){if(!Gu.has(e))throw new Error("invalid vertical alignment");this._verticalAlign!==e&&(this._verticalAlign=e,this._SetTextLayoutChanged())}GetVerticalAlignment(){return this._verticalAlign}SetWordWrapMode(e){if(!yu.has(e))throw new Error("invalid word wrap mode");this._wrapMode!==e&&(this._wrapMode=e,this._SetWordWrapChanged())}GetWordWrapMode(){return this._wrapMode}SetTextDirection(e){if(!Iu.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(e,t,s){if(void 0===s&&(s=1),e<=0||e<=0)return;if(this._cssWidth===e&&this._cssHeight===t&&this._zoom===s)return;const i=this._cssWidth;this._cssWidth=e,this._cssHeight=t,this._zoom=s;const n=self.devicePixelRatio;this._width=this._cssWidth*this._zoom*n,this._height=this._cssHeight*this._zoom*n;const r=Math.max(this._width,this._height),a=Math.min(this._renderer.GetMaxTextureSize(),4096);let o=1;r>a&&(o=a/r,this._width=Math.min(this._width*o,a),this._height=Math.min(this._height*o,a)),this._scaleFactor=o,this._cssWidth!==i?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+4)-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 i=n.GetFontBoundingBoxDescent()*s;if(t>=n.GetPosY()-n.GetHeight()*s+i&&t=t.GetPosX()&&es+i.GetHeight()*e+t,0)-t;s=Math.max(this._height/2-a/2,0),n&&(r=i[0].GetTopToAlphabeticDistance()*e)}else if("bottom"===this._verticalAlign){const r=i.reduce((s,i)=>s+i.GetHeight()*e+t,0)-this._lineHeight*e,a=n?i.at(-1).GetFontBoundingBoxDescent()*e:0;s=this._height-r-a-2}for(let n=0,a=i.length;n0&&s>this._height-4*e)break}else if(n>0&&s>=this._height-o)break;h>=0&&this._LayoutTextLine(a,s,e),this._isBBcodeEnabled||(s+=o),s+=t}}_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");t+=n?uu(n.param,e.GetHeight())*i:0;const r=e.GetStyleTag("offsety");if(s+=r?uu(r.param,e.GetHeight())*i:0,e.IsIcon()){const t=e.GetStyleTag("iconoffsety");s+=t?uu(t.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 s of"ltr"===this._textDirection?e.fragments():e.fragmentsReverse())this._DrawFragment(s,t,e.GetHeight())}_DrawFragment(e,t,s){const i=this._textContext,n=e.GetPosX(),r=e.GetPosY();if(!Number.isFinite(n)||!Number.isFinite(r))return;const a=s/16;let o=e.GetWidth()*t;const h=e.GetHeight()*t,l=e.GetHeight()/16,c=(4+this._lineHeight)*t;let u=e.IsText()?e.GetCharacterArray():null;if(-1!==this._drawMaxCharCount){if(this._drawCharCount>=this._drawMaxCharCount)return;e.IsText()&&this._drawCharCount+u.length>this._drawMaxCharCount&&(u=u.slice(0,this._drawMaxCharCount-this._drawCharCount),o=this._MeasureText(e).width*t),this._drawCharCount+=e.GetLength()}const d=e.GetStyleTag("background"),_=e.HasStyleTag("u"),p=e.HasStyleTag("s");if(e.IsText()&&du.IsCharArrayAllWhitespace(u)&&!d&&!_&&!p||e.HasStyleTag("hide"))return;const g=e.GetStyleTag("color"),m=e.GetStyleTag("opacity");this._SetDrawCanvasOpacity(m?parseFloat(m.param)/100:1),d&&(this._SetDrawCanvasColor(d.param),i.fillRect(n,r-h,o,h+c));const f=e.GetStyleTag("linethickness"),S=f?parseFloat(f.param):1,G=e.HasStyleTag("stroke");if(G&&this._SetDrawCanvasLineWith(.5*l*S*this.GetDrawScale()),e.IsText()){const t=u.join("");if(this._SetDrawFontString(this._GetFontString(!1,e)),!G){this._SetDrawCanvasLineWith(.5*l*S*this.GetDrawScale());const s=e.GetStyleTag("outlineback");s&&(this._SetDrawCanvasColor(s.param),this._FillOrStrokeText(!0,t,n,r,o))}if(this._SetDrawCanvasColor(g?g.param:this._colorStr),this._FillOrStrokeText(G,t,n,r,o),!G){this._SetDrawCanvasLineWith(.5*l*S*this.GetDrawScale());const s=e.GetStyleTag("outline");s&&(this._SetDrawCanvasColor(s.param),this._FillOrStrokeText(!0,t,n,r,o))}}else if(e.IsIcon()&&e.GetWidth()>0){const t=e.GetDrawable(this._iconSet);t&&i.drawImage(t,n,r-h,o,h)}if(this._SetDrawCanvasColor(g?g.param:this._colorStr),_&&lu(i,G,n,r+t*a,o,t*a*S),p){const e=t*l,s=r-h/4+e/2;i.fillRect(n,s-e*S/2,o,e*S)}}_FillOrStrokeText(e,t,s,i,n){"rtl"===this._textDirection&&(s+=n),e?"Gecko"===du.Platform.BrowserEngine?this._textContext.strokeText(t,s,i,n):this._textContext.strokeText(t,s,i):"Gecko"===du.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 Tu)e.ReleaseTexture()}static GetAll(){return Tu.values()}}}{const wu=self.C3;class Pu{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)return;let e=!1;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)throw new Error("no result available");return this._result}}wu.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 Pu&&e.Release();wu.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();e.length>0?(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");if(this._renderer._GetTimeQueryStack().pop()!==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=wu.New(Pu,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 xu=self.C3;xu.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();xu.clearArray(this._buffer)}AddTimeElapsedQuery(){const e=new xu.Gfx.WebGLTimeElapsedQuery(this._renderer);return this._buffer.push(e),this._buffer.length>this._maxQueries&&this._buffer.shift().Release(),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()0&&this._buffer.splice(0,t));s.Release()}}}}{let vu=function(){qu=-1;for(const e of Yu)e.checkFunc()&&(e.resolve(),Yu.delete(e));Yu.size>0&&(qu=self.requestAnimationFrame(vu))};CheckPendingPolls=vu;const Au=self.C3,Ru=self.assert,Mu=self.glMatrix,Du=Mu.vec3,Eu=Mu.vec4,Fu=Mu.mat4,Ou={powerPreference:"default",enableGpuProfiling:!0,alpha:!1,depth:!1,canSampleDepth:!1,maxWebGLVersion:2,failIfMajorPerformanceCaveat:!1},Bu=new Set(["default","low-power","high-performance"]),Lu=65535,ku=393210,Nu=8e3,Wu=7996,Vu=new Au.Quad(0,0,1,0,1,1,0,1),Uu=Fu.create(),ju=Fu.create(),Hu=new Au.Quad,zu=new Au.Rect;let Xu=null;Au.isDebug&&(self.debug_lose_webgl_context=function(){Xu?Xu.loseContext():console.warn("WEBGL_lose_context not supported")},self.debug_restore_webgl_context=function(){Xu?Xu.restoreContext():console.warn("WEBGL_lose_context not supported")});const Yu=new Set;let qu=-1;Au.Gfx.WebGLRenderer=class extends Au.Gfx.RendererBase{constructor(e,t){if(super(t),t=Object.assign({},Ou,t),!Bu.has(t.powerPreference))throw new Error("invalid power preference");const s={alpha:!!t.alpha,depth:!1,antialias:!1,powerPreference:t.powerPreference,failIfMajorPerformanceCaveat:!!t.failIfMajorPerformanceCaveat};let i=null,n=0;if(t.maxWebGLVersion>=2&&(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=Eu.create(),this._didChangeTransform=!1,this._bbProjectionMatrix=Fu.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._colorBuffer=null,this._indexBuffer=null,this._pointBuffer=null,this._isColorDataF16=this._version>=2&&void 0!==globalThis.Float16Array,this._vertexData=new Float32Array(196605),this._indexData=new Uint16Array(393210),this._texcoordData=new Float32Array(131070),this._colorData=this._isColorDataF16?new globalThis.Float16Array(262140):new Float32Array(262140),this._pointData=new Float32Array(32e3),this._vertexPtr=0,this._indexPtr=0,this._pointPtr=0,this._lastProgram=null,this._spDeviceTransformTextureFill=null,this._batch=[],this._batchPtr=0,this._topOfBatch=0,this._currentRenderTarget=null,this._lastPointZ=0,this._batchState=Au.New(Au.Gfx.BatchState,this),this._lastColor=Au.New(Au.Color,1,1,1,1),this._lastTexture0=null,this._lastTexture1=null,this._lastSrcBlend=0,this._lastDestBlend=0,this._lastPointTexCoords=new Au.Rect,this._lastScissorRect=Au.New(Au.Rect,0,0,-1,-1),this._coplanarMode=0,this._lastCullFace=0,this._lastFrontFaceWinding=0,this._maxTextureSize=-1,this._minPointSize=0,this._maxPointSize=0,this._unmaskedVendor="(unavailable)",this._unmaskedRenderer="(unavailable)",this._extensions=[],this._isInitialisingAfterContextRestored=!1,this._parallelShaderCompileExt=null,this._anisotropicExt=null,this._conservativeDepthExt=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=[]}IsWebGL(){return!0}async InitState(){super.InitState();const e=this._gl;this._lastColor.setRgba(1,1,1,1),this._lastTexture0=null,this._lastTexture1=null,this._vertexPtr=0,this._indexPtr=0,this._pointPtr=0,Au.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;const t=this._batchState;t.currentShader=null,t.currentFramebuffer=null,t.currentFramebufferNoDepth=null,t.clearColor.setRgba(0,0,0,0),t.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.cullFace(e.BACK),e.disable(e.CULL_FACE),this._lastCullFace=0,e.frontFace(e.CW),this._lastFrontFaceWinding=0,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._colorBuffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this._colorBuffer),e.bufferData(e.ARRAY_BUFFER,this._colorData.byteLength,e.DYNAMIC_DRAW),this._indexBuffer=e.createBuffer(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this._indexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this._indexData.byteLength,e.DYNAMIC_DRAW),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,null),this._maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE);const s=e.getParameter(e.ALIASED_POINT_SIZE_RANGE);this._minPointSize=s[0],this._maxPointSize=s[1],this._maxPointSize>2048&&(this._maxPointSize=2048),this._extensions=e.getSupportedExtensions();const i=e.getExtension("WEBGL_debug_renderer_info");if(i&&(this._unmaskedVendor=e.getParameter(i.UNMASKED_VENDOR_WEBGL),this._unmaskedRenderer=e.getParameter(i.UNMASKED_RENDERER_WEBGL)),this._parallelShaderCompileExt=e.getExtension("KHR_parallel_shader_compile"),this._version>=2&&("Chromium"!==Au.Platform.BrowserEngine||Au.Platform.BrowserVersionNumber>=135)&&(this._conservativeDepthExt=e.getExtension("EXT_conservative_depth")),Au.isDebug&&(Xu=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"));const n=Au.Gfx.WebGLShaderProgram,r=n.GetDefaultVertexShaderSource(!1);let a=n.GetTextureFillFragmentShaderSource_WebGL1_NoFragDepth(),o=r,h=n.GetPointFragmentShaderSource_WebGL1_NoFragDepth(),l=n.GetPointVertexShaderSource_WebGL1(),c=n.GetTilemapFragmentShaderSource_WebGL1_NoFragDepth(),u=n.GetDefaultVertexShaderSource(!0),d=!1;this._usesDepthBuffer&&(this.GetWebGLVersionNumber()<2?this._fragDepthExt&&(a=n.GetTextureFillFragmentShaderSource_WebGL1_FragDepthEXT(),h=n.GetPointFragmentShaderSource_WebGL1_FragDepthEXT(),c=n.GetTilemapFragmentShaderSource_WebGL1_FragDepthEXT(),d=!0):(o=n.GetDefaultVertexShaderSource_WebGL2(),a=n.GetTextureFillFragmentShaderSource_WebGL2(this._SupportsConservativeDepth()),h=n.GetPointFragmentShaderSource_WebGL2(this._SupportsConservativeDepth()),l=n.GetPointVertexShaderSource_WebGL2(),c=n.GetTilemapFragmentShaderSource_WebGL2(this._SupportsConservativeDepth()),u=n.GetDefaultVertexShaderSource_WebGL2(!0)));const _=n.GetTileRandomizationFragmentShaderSource(this.GetWebGLVersionNumber(),d,this._stdDerivativesExt&&this._textureLodExt,this._SupportsConservativeDepth()),p=this.GetWebGLVersionNumber()>=2?n.GetDefaultVertexShaderSource_WebGL2():r,g=[[a,o,""],[a,o,""],[h,l,""],[n.GetColorFillFragmentShaderSource(),r,""],[n.GetLinearGradientFillFragmentShaderSource(),r,""],[n.GetPenumbraFillFragmentShaderSource(),r,""],[n.GetHardEllipseFillFragmentShaderSource(),r,""],[n.GetHardEllipseOutlineFragmentShaderSource(),r,""],[n.GetSmoothEllipseFillFragmentShaderSource(),r,""],[n.GetSmoothEllipseOutlineFragmentShaderSource(),r,""],[n.GetSmoothLineFillFragmentShaderSource(),r,""],[c,u,""],[_,p,""]],m=await Promise.all(g.map(e=>this.CreateShaderProgram({src:e[0],vertexSrc:e[1],name:e[2]})));this._spTextureFill=m[0],this._spDeviceTransformTextureFill=m[1],this._spPoints=m[2],this._spColorFill=m[3],this._spLinearGradientFill=m[4],this._spPenumbraFill=m[5],this._spHardEllipseFill=m[6],this._spHardEllipseOutline=m[7],this._spSmoothEllipseFill=m[8],this._spSmoothEllipseOutline=m[9],this._spSmoothLineFill=m[10],this._spTilemapFill=m[11],this._spTileRandomization=m[12],this.SetTextureFillMode()}async CreateShaderProgram(e){const t=await Au.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)return;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),this.GetWebGLVersionNumber()>=2?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,this._version>=2?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;n[0]===e&&n[1]===t&&n[2]===s&&n[3]===i||(this.PushBatch().InitSetViewport(e,t,s,i),Eu.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){Fu.exactEquals(this._matP,e)||(this.PushBatch().InitSetProjection(e),Fu.copy(this._matP,e),this._topOfBatch=0,this._didChangeTransform=!0)}SetDefaultRenderTargetProjectionState(){let e,t,s;const i=this._currentRenderTarget;null===i?(e=this._bbProjectionMatrix,t=this.GetWidth(),s=this.GetHeight()):(e=i.GetProjectionMatrix(),t=i.GetWidth(),s=i.GetHeight()),this.SetProjectionMatrix(e),this._SetViewport(0,0,t,s)}SetModelViewMatrix(e){Fu.exactEquals(this._matMV,e)||(this.PushBatch().InitSetModelView(e),Fu.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 Au.Gfx.WebGLBatchJob(this._batchState)),e[this._batchPtr++]}EndBatch(){0!==this._batchPtr&&(this.IsContextLost()||(this._WriteBuffers(),this._ExecuteBatch(),this._batchPtr=0,this._vertexPtr=0,this._indexPtr=0,this._pointPtr=0,this._topOfBatch=0))}_WriteBuffers(){const e=this._gl;this._vertexPtr>0&&(e.bindBuffer(e.ARRAY_BUFFER,this._vertexBuffer),e.bufferSubData(e.ARRAY_BUFFER,0,this._vertexData.subarray(0,3*this._vertexPtr)),e.bindBuffer(e.ARRAY_BUFFER,this._texcoordBuffer),e.bufferSubData(e.ARRAY_BUFFER,0,this._texcoordData.subarray(0,2*this._vertexPtr)),e.bindBuffer(e.ARRAY_BUFFER,this._colorBuffer),e.bufferSubData(e.ARRAY_BUFFER,0,this._colorData.subarray(0,4*this._vertexPtr))),this._indexPtr>0&&(e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this._indexBuffer),e.bufferSubData(e.ELEMENT_ARRAY_BUFFER,0,this._indexData.subarray(0,this._indexPtr))),this._pointPtr>0&&(e.bindBuffer(e.ARRAY_BUFFER,this._pointBuffer),e.bufferSubData(e.ARRAY_BUFFER,0,this._pointData.subarray(0,this._pointPtr)))}_ExecuteBatch(){const e=this._batch;for(let t=0,s=this._batchPtr;t65535||this._indexPtr+t>393210)&&this.EndBatch(),1===this._topOfBatch?this._batch[this._batchPtr-1]._indexCount+=t:(this.PushBatch().InitDraw(2*this._indexPtr,t),this._topOfBatch=1)}_AddIndicesForQuad(){const e=this._vertexPtr;let t=this._indexPtr;this._indexPtr+=6;const s=this._indexData;s[t++]=e,s[t++]=e+1,s[t++]=e+2,s[t++]=e,s[t++]=e+2,s[t]=e+3}Quad(e){this.Quad4(e,Vu)}Quad2(e,t,s,i,n,r,a,o){this._AddToDrawBatch(4,6),this._AddIndicesForQuad();const h=this._vertexData,l=this._vertexPtr;this._vertexPtr+=4;let c=3*l;const u=this._baseZ+this._currentZ;h[c++]=e,h[c++]=t,h[c++]=u,h[c++]=s,h[c++]=i,h[c++]=u,h[c++]=n,h[c++]=r,h[c++]=u,h[c++]=a,h[c++]=o,h[c]=u,Vu.writeToTypedArray(this._texcoordData,2*l),this._lastColor.writeToTypedArrayx4(this._colorData,4*l)}Quad3(e,t){this._AddToDrawBatch(4,6),this._AddIndicesForQuad();const s=this._vertexPtr;this._vertexPtr+=4,e.writeToTypedArray3D(this._vertexData,3*s,this._baseZ+this._currentZ),t.writeAsQuadToTypedArray(this._texcoordData,2*s),this._lastColor.writeToTypedArrayx4(this._colorData,4*s)}Quad4(e,t){this._AddToDrawBatch(4,6),this._AddIndicesForQuad();const s=this._vertexPtr;this._vertexPtr+=4,e.writeToTypedArray3D(this._vertexData,3*s,this._baseZ+this._currentZ),t.writeToTypedArray(this._texcoordData,2*s),this._lastColor.writeToTypedArrayx4(this._colorData,4*s)}Quad5(e,t,s){this._AddToDrawBatch(4,6),this._AddIndicesForQuad();const i=this._vertexPtr;this._vertexPtr+=4,e.writeToTypedArray3D(this._vertexData,3*i,this._baseZ+this._currentZ),t.writeToTypedArray(this._texcoordData,2*i),this._colorData.set(s,4*i)}Quad3D(e,t,s,i,n,r,a,o,h,l,c,u,d){this._AddToDrawBatch(4,6),this._AddIndicesForQuad();const _=this._vertexData,p=this._vertexPtr;this._vertexPtr+=4;let g=3*p;const m=this._baseZ+this._currentZ;_[g++]=e,_[g++]=t,_[g++]=m+s,_[g++]=i,_[g++]=n,_[g++]=m+r,_[g++]=a,_[g++]=o,_[g++]=m+h,_[g++]=l,_[g++]=c,_[g]=m+u,d.writeAsQuadToTypedArray(this._texcoordData,2*p),this._lastColor.writeToTypedArrayx4(this._colorData,4*p)}Quad3D2(e,t,s,i,n,r,a,o,h,l,c,u,d){this._AddToDrawBatch(4,6),this._AddIndicesForQuad();const _=this._vertexData,p=this._vertexPtr;this._vertexPtr+=4;let g=3*p;const m=this._baseZ+this._currentZ;_[g++]=e,_[g++]=t,_[g++]=m+s,_[g++]=i,_[g++]=n,_[g++]=m+r,_[g++]=a,_[g++]=o,_[g++]=m+h,_[g++]=l,_[g++]=c,_[g]=m+u,d.writeToTypedArray(this._texcoordData,2*p),this._lastColor.writeToTypedArrayx4(this._colorData,4*p)}Quad3D3(e,t,s,i,n,r,a,o,h,l,c,u,d,_){this._AddToDrawBatch(4,6),this._AddIndicesForQuad();const p=this._vertexData,g=this._vertexPtr;this._vertexPtr+=4;let m=3*g;const f=this._baseZ+this._currentZ;p[m++]=e,p[m++]=t,p[m++]=f+s,p[m++]=i,p[m++]=n,p[m++]=f+r,p[m++]=a,p[m++]=o,p[m++]=f+h,p[m++]=l,p[m++]=c,p[m]=f+u,d.writeToTypedArray(this._texcoordData,2*g),this._colorData.set(_,4*g)}DrawMesh(e,t,s,i){if(e.length%3!=0)throw new Error("vertex buffer length not multiple of 3");if(e.length>196605)throw new Error(`too many vertices (${e.length/3}, limit 65535)`);if(s.length%3!=0)throw new Error("index buffer length not multiple of 3");if(s.length>393210)throw new Error(`too many indices (${s.length}, limit 393210)`);this._AddToDrawBatch(e.length,s.length);const n=this._vertexPtr;this._vertexData.set(e,3*n),this._texcoordData.set(t,2*n);const r=this._indexData;if(0===n)r.set(s,this._indexPtr);else{let e=this._indexPtr;for(let t=0,i=s.length;t=7996&&this.EndBatch();let n=this._pointPtr;const r=this._baseZ+this._currentZ;2===this._topOfBatch&&this._lastPointZ===r?this._batch[this._batchPtr-1]._indexCount++:(this.PushBatch().InitPoints(n,r,this._lastColor),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){this._lastProgram!==e&&(this.PushBatch().InitSetProgram(e),this._lastProgram=e,this._topOfBatch=0,this._currentStateGroup=null)}GetProgram(){return this._lastProgram}SetDeviceTransformTextureFillMode(){this.SetProgram(this._spDeviceTransformTextureFill)}SetGradientColor(e){this.PushBatch().InitSetGradientColor(e),this._topOfBatch=0}SetEllipseParams(e,t,s=1){this.PushBatch().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");this.PushBatch().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");this.PushBatch().InitSetTileRandomizationInfo(e,t,s,i,n,r,a),this._topOfBatch=0}SetProgramParameters(e,t,s,i,n,r,a,o,h,l,c){const u=this._lastProgram;if(c%=10800,!u._hasAnyOptionalUniforms||u.AreOptionalUniformsAlreadySetInBatch(t,s,i,n,r,a,o,h,l,c))return;const d=this.PushBatch();d.InitSetProgramParameters(),u.SetOptionalUniformsInBatch(t,s,i,n,r,a,o,h,l,c);const _=d._mat4param;_[0]=r,_[1]=a,t.writeToTypedArray(_,2),_[6]=h,_[7]=l,s.writeToTypedArray(_,12);const p=d._colorParam;n.writeToTypedArray(p,0);const g=p[1];p[1]=p[3],p[3]=g,i.writeToTypedArray(d._srcOriginRect,0),d._startIndex=c,d._indexCount=o,u._uSamplerBack.IsUsed()?d._texParam=e?e.GetTexture():null:d._texParam=null,this._topOfBatch=0}SetProgramCustomParameters(e){const t=this._lastProgram;if(0===e.length||t.AreCustomParametersAlreadySetInBatch(e))return;const s=this.PushBatch();s.InitSetProgramCustomParameters(),t.SetCustomParametersInBatch(e),Au.shallowAssignArray(s._shaderParams,e),this._topOfBatch=0}ClearRgba(e,t,s,i){this.PushBatch().InitClearSurface2(e,t,s,i),this._topOfBatch=0}Clear(e){this.PushBatch().InitClearSurface(e),this._topOfBatch=0}Start(){}Finish(){super.Finish(),this._gl.flush()}ClearDepth(){this._usesDepthBuffer&&this._currentRenderTarget&&this._currentRenderTarget.HasDepthBuffer()&&(this.PushBatch().InitClearDepth(this._isDepthEnabled),this._topOfBatch=0)}SetDepthEnabled(e){e=!!e,this._isDepthEnabled!==e&&this._usesDepthBuffer&&(this._isDepthEnabled=e,this.PushBatch().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,this.PushBatch().InitSetDepthSamplingEnabled(e),this._topOfBatch=0}}SetScissorRect(e,t,s,i,n=0){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),t=(n||this.GetRenderTargetSize(this.GetRenderTarget())[1])-t-i,this.PushBatch().InitSetScissor(!0,e,t,s,i),this._topOfBatch=0)}RemoveScissorRect(){-1!==this._lastScissorRect.getRight()&&(this._lastScissorRect.set(0,0,-1,-1),this.PushBatch().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(),Au.Gfx.WebGLRendererTexture.OnContextLost(),Au.Gfx.WebGLRenderTarget.OnContextLost(),Au.Gfx.RendererText.OnContextLost();for(const e of this._allQueryResultBuffers)e.Clear();this._extensions=[],this._timerExt=null,this._parallelShaderCompileExt=null,this._conservativeDepthExt=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 e of this._stateGroups.values())e.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=Au.New(Au.Gfx.WebGLRendererTexture,this);return s._CreateStatic(e,t),s}async CreateStaticTextureAsync(e,t){if(this.IsContextLost())throw new Error("context lost");if(t=Object.assign({},t),Au.Supports.ImageBitmapOptions){let s=await createImageBitmap(e,{premultiplyAlpha:"premultiply"});const i=t.wrapX&&"clamp-to-edge"!==t.wrapX||t.wrapY&&"clamp-to-edge"!==t.wrapY,n=Au.isPOT(s.width)&&Au.isPOT(s.height);return this.SupportsNPOTTextures()||n||!i?t.premultiplyAlpha=!1:Au.Supports.ImageBitmapOptionsResize?(s=await createImageBitmap(e,{premultiplyAlpha:"premultiply",resizeWidth:Au.nextHighestPowerOfTwo(s.width),resizeHeight:Au.nextHighestPowerOfTwo(s.height)}),t.premultiplyAlpha=!1):s=await createImageBitmap(e,{premultiplyAlpha:"none"}),await Au.Asyncify(()=>this.CreateStaticTexture(s,t))}if(e instanceof Blob){if("undefined"==typeof Image)throw new Error("texture upload variant not supported in worker");const t=await Au.BlobToImage(e);e=t}return await Au.Asyncify(()=>this.CreateStaticTexture(e,t))}CreateDynamicTexture(e,t,s){this.EndBatch();const i=Au.New(Au.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(),e.GetReferenceCount()>0||(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=Au.New(Au.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){e!==this._currentRenderTarget&&(e&&e.IsDefaultSize()&&e._Resize(this._width,this._height),this.PushBatch().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"){this._version<2||this._currentRenderTarget&&this._currentRenderTarget.GetMultisampling()>0?(this.SetCopyBlend(),this.ResetColor(),this.DrawRenderTarget(e,t)):(this.PushBatch().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){this._version<2||(this.PushBatch().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();const i=this._currentRenderTarget;let n,r,a;e?(n=e.GetWidth(),r=e.GetHeight(),a=e._GetFramebuffer()):(n=this.GetWidth(),r=this.GetHeight(),a=null);let o=0,h=0,l=n,c=r;if(s){o=Au.clamp(Math.floor(s.getLeft()),0,n-1),h=Au.clamp(Math.floor(s.getTop()),0,r-1);let e=s.width();e=0===e?n-o:Au.clamp(Math.floor(e),0,n-o);let t=s.height();t=0===t?r-h:Au.clamp(Math.floor(t),0,r-h),l=e,c=t,h=r-(h+c)}const u=this._gl;u.bindFramebuffer(u.FRAMEBUFFER,a);const d=()=>{u.bindFramebuffer(u.FRAMEBUFFER,null),this._currentRenderTarget=null,this._batchState.currentFramebuffer=null,this._batchState.currentFramebufferNoDepth=null,this.SetRenderTarget(i)};let _;if(!t&&this.GetWebGLVersionNumber()>=2){u.bindFramebuffer(u.READ_FRAMEBUFFER,a);const e=u.createBuffer(),t=l*c*4,s=u.PIXEL_PACK_BUFFER;u.bindBuffer(s,e),u.bufferData(s,t,u.STREAM_READ),u.readPixels(o,h,l,c,u.RGBA,u.UNSIGNED_BYTE,0),u.bindFramebuffer(u.READ_FRAMEBUFFER,null),u.bindBuffer(s,null),d();const i=u.fenceSync(u.SYNC_GPU_COMMANDS_COMPLETE,0);await this._WaitForObjectReady(()=>u.getSyncParameter(i,u.SYNC_STATUS)===u.SIGNALED),u.deleteSync(i),_=new ImageData(l,c),u.bindBuffer(s,e),u.getBufferSubData(s,0,new Uint8Array(_.data.buffer),0,t),u.bindBuffer(s,null),u.deleteBuffer(e)}else _=new ImageData(l,c),u.readPixels(o,h,l,c,u.RGBA,u.UNSIGNED_BYTE,new Uint8Array(_.data.buffer)),d();return _}CoplanarStartStencilPass(){this.SetDepthEnabled(!0),this.PushBatch().InitCoplanarStartStencilPass(),this._topOfBatch=0,this._coplanarMode=1}CoplanarStartColorPass(){this.SetDepthEnabled(!1),this.PushBatch().InitCoplanarStartColorPass(),this._topOfBatch=0,this._coplanarMode=2}IsCoplanarColorPass(){return 2===this._coplanarMode}CoplanarRestoreStandardRendering(){this.SetDepthEnabled(!0),this.PushBatch().InitCoplanarRestore(),this._topOfBatch=0,this._coplanarMode=0}StartQuery(e){this.SupportsGPUProfiling()&&(this.PushBatch().InitStartQuery(e),this._topOfBatch=0)}EndQuery(e){this.SupportsGPUProfiling()&&(this.PushBatch().InitEndQuery(e),this._topOfBatch=0)}_WaitForObjectReady(e){const t=new Promise(t=>Yu.add({resolve:t,checkFunc:e}));return-1===qu&&(qu=self.requestAnimationFrame(vu)),t}GetEstimatedBackBufferMemoryUsage(){return this._width*this._height*(this._attribs.alpha?4:3)}GetEstimatedRenderBufferMemoryUsage(){let e=0;for(const t of Au.Gfx.WebGLRenderTarget.allRenderTargets())t.GetTexture()||(e+=t.GetEstimatedMemoryUsage());return e}GetEstimatedTextureMemoryUsage(){let e=0;for(const t of Au.Gfx.WebGLRendererTexture.allTextures())e+=t.GetEstimatedMemoryUsage();return e}GetWebGLVersionString(){return this._versionString}GetWebGLVersionNumber(){return this._version}IsColorDataF16(){return this._isColorDataF16}GetDisplayName(){return"webgl"+this.GetWebGLVersionNumber()}SupportsNPOTTextures(){return this.GetWebGLVersionNumber()>=2}GetMaxTextureSize(){return this._maxTextureSize}GetMinPointSize(){return this._minPointSize}GetMaxPointSize(){return this._maxPointSize}GetUnmaskedVendor(){return this._unmaskedVendor}GetUnmaskedRenderer(){return this._unmaskedRenderer}GetWebGLExtensionsAnalyticsString(){if(this.GetWebGLVersionNumber()>=2)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"),e.length>0?"webgl1:"+e.join(","):"webgl1:none"}}GetExtensions(){return this._extensions}SupportsGPUProfiling(){return!!this._timerExt}_GetDisjointTimerQueryExtension(){return this._timerExt}_GetParallelShaderCompileExtension(){return this._parallelShaderCompileExt}_SupportsConservativeDepth(){return!!this._conservativeDepthExt}_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 Ku=self.C3,$u={getDrawSize:null,getRenderTarget:null,releaseRenderTarget:null,getTime:null,redraw:null};Ku.Gfx.EffectChainManager=class{constructor(e){e=Object.assign({},$u,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 Ju=self.C3,Zu=self.assert,Qu=self.glMatrix,ed=Qu.mat4,td=Ju.New(Ju.Rect),sd=Ju.New(Ju.Rect),id=Ju.New(Ju.Rect),nd=Ju.New(Ju.Rect),rd=ed.create(),ad=ed.create(),od={drawContent:null,getSourceTextureInfo:null,getShaderParameters:null,invalidateRenderTargets:!1},hd={indexMap:null,forcePreDraw:!1,forcePostDraw:!1,is3D:!1,isSourceTextureRotated:!1,isRotatedOrNegativeSizeInstance:!1,useFullSurface:!1};Ju.Gfx.EffectChain=class{constructor(e,t){t=Object.assign({},od,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=Ju.New(Ju.Rect),this._drawSurfaceRect=Ju.New(Ju.Rect),this._rcTexOriginal=Ju.New(Ju.Rect),this._rcTexBounce=Ju.New(Ju.Rect),this._rcTexDest=Ju.New(Ju.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._compositRtWidth=0,this._compositRtHeight=0,this._updateOwnProjection=!1,this._projectionMatrix=ed.create(),this._modelViewMatrix=ed.create(),this._manager._AddEffectChain(this)}Release(){this._manager._RemoveEffectChain(this),Ju.clearArray(this._steps),Ju.clearArray(this._shaderProgramList),Ju.clearArray(this._shaderProgramIndices),this._contentObject=null,this._contextObject=null,this._cbDrawContent=null,this._cbGetSourceTextureInfo=null,this._cbGetShaderParameters=null}OnContextLost(){this._needsRebuild=!0,Ju.clearArray(this._steps),Ju.clearArray(this._shaderProgramList),Ju.clearArray(this._shaderProgramIndices)}NeedsRebuild(){return this._needsRebuild}BuildSteps(e,t){if(t=Object.assign({},hd,t),Ju.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=!!t.isSourceTextureRotated,this._useFullSurface=!!t.useFullSurface,this._needsRebuild=!1,Ju.shallowAssignArray(this._shaderProgramList,e),0===e.length)return;if(t.indexMap){if(t.indexMap.length!==e.length)throw new Error("incorrect indexMap length");Ju.shallowAssignArray(this._shaderProgramIndices,t.indexMap)}else{Ju.clearArray(this._shaderProgramIndices);for(let t=0,s=e.length;t=1?this._GetRenderTarget():null,this._renderTargets[2]=2===this._numTempSurfacesRequired?this._GetRenderTarget():null;for(const t of this._steps){const s=this._GetRenderTargetForId(t.GetSrcTargetId()),i=this._GetRenderTargetForId(t.GetDestTargetId());e.IsWebGPU()?t.Run_WebGPU(e,s,i):t.Run_WebGL(e,s,i)}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,h=s/2+n;e.CalculatePerspectiveMatrix(r,t/s);const l=e.CalculateLookAtModelView2(o,h,e.GetDefaultCameraZ(s),o,h,0,s);ed.copy(a,l)}_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(td.copy(this._drawSurfaceRect),e.IsWebGL()){const e=this._layerScale*this._devicePixelRatio;td.inflate(Math.max(this._boxExtendHorizontal,1)*e,Math.max(this._boxExtendVertical,1)*e),td.roundOuter(),td.clamp(0,0,this._drawWidth,this._drawHeight)}else td.roundOuter();e.SetScissorRect(td.getLeft(),td.getTop(),td.width(),td.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||0!==this._compositRtWidth||0!==this._compositRtHeight)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)){let t,n;s=rd,i=ad,0!==this._compositRtWidth&&0!==this._compositRtHeight?[t,n]=[this._compositRtWidth,this._compositRtHeight]:[t,n]=e.GetRenderTargetSize(e.GetRenderTarget()),this._CalculateDeviceTransformMatrices(e,t,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,n=this._rcTexOriginal;e.IsWebGL()&&(sd.copy(s),sd.flipAround(1),s=sd,id.copy(i),id.flipAround(1),i=id,nd.copy(n),nd.flipAround(1),n=nd),this._DoSetProgramParameters(e,t,i,n,s,1/this._drawWidth,1/this._drawHeight)}_SetFirstBounceProgramParameters(e,t){let s=this._rcTexBounce,i=this._rcTexOriginal,n=1/this._drawWidth,r=1/this._drawHeight;if(this._cbGetSourceTextureInfo){let{srcTexRect:e,srcWidth:t,srcHeight:a}=this._cbGetSourceTextureInfo(this._contentObject);e||(td.set(0,0,0,0),e=td),t||(t=this._drawWidth),a||(a=this._drawHeight),s=e,i=e,n=1/t,r=1/a}else e.IsWebGL()&&(id.copy(s),id.flipAround(1),s=id,nd.copy(i),nd.flipAround(1),i=nd);let a=this._rcTexDest;e.IsWebGL()&&(a=sd,a.copy(this._rcTexDest),a.flipAround(1)),this._DoSetProgramParameters(e,t,s,i,a,n,r),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),e.ResetCullState();let r=0,a=1;if(this._rcTexOriginal.set(0,0,1,1),s.UsesAnySrcRectOrPixelSize()&&this._cbGetSourceTextureInfo){const{srcTexRect:e,srcWidth:t,srcHeight:s}=this._cbGetSourceTextureInfo(this._contentObject);e&&this._rcTexOriginal.copy(e),r=Number.isFinite(t)?1/t:0,a=Number.isFinite(s)?1/s:0}else{const[t,s]=this._manager.GetDrawSize(e);r=1/t,a=1/s}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 ld=self.C3;ld.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 cd=self.C3;cd.Gfx.EffectChain.Step.PreDraw=class extends cd.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.ResetCullState(),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.ResetCullState(),e.SetTextureFillMode(),e.SetRenderTarget(s,!1),e.ClearRgba(0,0,0,0),i._DrawContent(e),i._ClampRcTexDest()}}}{const ud=self.C3,dd=ud.New(ud.Rect),_d=ud.New(ud.Quad);ud.Gfx.EffectChain.Step.PostDraw=class extends ud.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()),_d.setFromRect(i._GetDrawSurfaceRect()),dd.copy(i._GetRcTexBounce()),dd.flipAround(1),e.Quad3(_d,dd),i._ShouldInvalidateRenderTargets()&&e.InvalidateRenderTarget(t)}Run_WebGPU(e,t,s){const i=this.GetEffectChain();e.SetTextureFillMode(),e.SetRenderTarget(s,!1),i._IsRenderTargetSameSizeAndOffset(e)?_d.setFromRect(i._GetRcTexBounce()):(e.SetNormalizedCoordsProgramVariant(!1),i._SetDeviceTransform(e,!0),_d.setFromRect(i._GetDrawSurfaceRect())),e.SetBackTexture(null),e.SetBlendMode(i._GetBlendMode()),e.SetTexture(t.GetTexture()),i.UseFullSurface()?e.FullscreenQuad():e.Quad3(_d,i._GetRcTexBounce())}}}{const pd=self.C3;pd.Gfx.EffectChain.Step.FirstBounce=class extends pd.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 gd=self.C3,md=gd.New(gd.Rect),fd=gd.New(gd.Quad);gd.Gfx.EffectChain.Step.Bounce=class extends gd.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);const n=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),fd.setFromRect(i._GetDrawSurfaceRect()),md.copy(i._GetRcTexBounce()),md.flipAround(1),e.Quad3(fd,md),i._ShouldInvalidateRenderTargets()&&e.InvalidateRenderTarget(t)}Run_WebGPU(e,t,s){const i=this.GetEffectChain();e.SetRenderTarget(s,!1),0===this.GetDestTargetId()?(e.SetBlendMode(i._GetBlendMode()),e.SetBackTexture(null),i._IsRenderTargetSameSizeAndOffset(e)?fd.setFromRect(i._GetRcTexBounce()):(e.SetNormalizedCoordsProgramVariant(!1),i._SetDeviceTransform(e,!0),fd.setFromRect(i._GetDrawSurfaceRect()))):(e.ClearRgba(0,0,0,0),e.SetCopyBlend(),fd.setFromRect(i._GetRcTexBounce())),e.SetProgram(this.GetShaderProgram()),i._SetProgramParameters(e,this.GetIndex()),e.SetTexture(t.GetTexture()),i.UseFullSurface()?e.FullscreenQuad():e.Quad3(fd,i._GetRcTexBounce())}}}{let Sd=function(e,t){const s=e[0]-t[0];return 0!==s?s:e[1]-t[1]};SortZOrderList=Sd;const Gd=self.C3,yd=self.C3X;let Id=null;const Td=new Set,Cd=[],bd=[];let wd=!1,Pd=!1,xd=!1;const vd=new Set(["vsync","unlimited-tick","unlimited-frame"]);self.IRuntime=class{constructor(e){Id=e,Object.defineProperties(this,{assets:{value:Id.GetAssetManager().GetIAssetManager(),writable:!1},collisions:{value:Id.GetCollisionEngine().GetICollisionEngine(),writable:!1},objects:{value:{},writable:!1},globalVars:{value:{},writable:!1},projectName:{value:Id.GetProjectName(),writable:!1},projectVersion:{value:Id.GetProjectVersion(),writable:!1},projectId:{value:Id.GetAppId(),writable:!1},projectUniqueId:{value:Id.GetProjectUniqueId(),writable:!1},exportDate:{value:new Date(Id.GetExportTimestamp()),writable:!1},storage:{value:new self.IStorage(Id),writable:!1},isInWorker:{value:Id.IsInWorker(),writable:!1},viewportWidth:{value:Id.GetOriginalViewportWidth(),writable:!1},viewportHeight:{value:Id.GetOriginalViewportHeight(),writable:!1},sampling:{value:Id.GetSampling(),writable:!1},isPixelRoundingEnabled:{value:Id.IsPixelRoundingEnabled(),writable:!1},platformInfo:{value:new self.IPlatformInfo(e),writable:!1},sdk:{value:new self.ISDKUtils(e),writable:!1}}),Id.UserScriptDispatcher().addEventListener("keydown",e=>{Td.has(e.key)?e.stopPropagation():Td.add(e.key)}),Id.UserScriptDispatcher().addEventListener("keyup",e=>Td.delete(e.key)),Id.Dispatcher().addEventListener("window-blur",()=>Td.clear()),Id.IsInWorker()&&(self.alert=e=>(wd||(wd=!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){Id.UserScriptDispatcher().addEventListener(e,t)}removeEventListener(e,t){Id.UserScriptDispatcher().removeEventListener(e,t)}callFunction(e,...t){yd.RequireString(e);const s=Id.GetEventSheetManager(),i=s.GetFunctionBlockByName(e);if(!i)throw new Error(`cannot find function name '${e}'`);if(!i.IsEnabled())return i.GetDefaultReturnValue();if(t.lengthe.GetILayout())}goToLayout(e){const t=Id.GetLayoutManager();let s=null;if("number"!=typeof e&&"string"!=typeof e)throw new TypeError("expected string or number");if(s=t.GetLayout(e),!s)throw new Error("invalid layout");t.IsPendingChangeMainLayout()||t.ChangeMainLayout(s)}get keyboard(){const e=Id._GetCommonScriptInterfaces().keyboard;if(!e)throw new Error("runtime.keyboard used but Keyboard object missing - add it to your project first");return e}get mouse(){const e=Id._GetCommonScriptInterfaces().mouse;if(!e)throw new Error("runtime.mouse used but Mouse object missing - add it to your project first");return e}get touch(){const e=Id._GetCommonScriptInterfaces().touch;if(!e)throw new Error("runtime.touch used but Touch object missing - add it to your project first");return e}get timelineController(){const e=Id._GetCommonScriptInterfaces().timelineController;if(!e)throw new Error("runtime.timelineController used but Timeline Controller object missing - add it to your project first");return e}get renderer(){return Id.GetCanvasManager().GetIRenderer()}invokeDownload(e,t){yd.RequireString(e),yd.RequireString(t),Id.InvokeDownload(e,t)}getInstanceByUid(e){yd.RequireFiniteNumber(e);const t=Id.GetInstanceByUID(e);return t?t.GetInterfaceClass():null}sortZOrder(e,t){yd.RequireFunction(t);const s=Id.GetCurrentLayout();for(const t of e){const e=Id._UnwrapIWorldInstance(t),s=e.GetWorldInfo();Cd.push([s.GetLayer().GetIndex(),s.GetZIndex()]),bd.push(e)}if(0===Cd.length)return;Cd.sort(Sd),bd.sort((e,s)=>t(e.GetInterfaceClass(),s.GetInterfaceClass()));let i=!1;for(let e=0,t=Cd.length;es._UnwrapIObjectClass(e)):[s._UnwrapIObjectClass(e)];const n=Dd.Rect.FromObject(t),r=[];return Fd.GetObjectClassesCollisionCandidates(null,i,n,r),r.map(e=>e.GetInterfaceClass())}}}{const Od=self.C3,Bd=self.C3X;let Ld=null;const kd=new Map([["Windows","windows"],["macOS","macos"],["Linux","linux"],["Chrome OS","chrome-os"],["Android","android"],["iOS","ios"]]),Nd=new Map([["Chrome","chrome"],["Chromium","chromium"],["Edge","edge"],["Opera","opera"],["NW.js","nwjs"],["Firefox","firefox"],["Safari","safari"]]),Wd=new Map([["Chromium","chromium"],["Gecko","gecko"],["WebKit","webkit"]]);self.IPlatformInfo=class{constructor(e){Ld=e,Object.defineProperties(this,{isMobile:{value:Od.Platform.IsMobile,writable:!1},os:{value:kd.get(Od.Platform.OS)||"unknown",writable:!1},osVersion:{value:Od.Platform.OSVersion,writable:!1},browser:{value:Nd.get(Od.Platform.Browser)||"unknown",writable:!1},browserVersion:{value:Od.Platform.BrowserVersion,writable:!1},browserEngine:{value:Wd.get(Od.Platform.BrowserEngine)||"unknown",writable:!1}})}get exportType(){let e=Ld.GetExportType();return Ld.IsNWjs()?e="nwjs":Ld.IsWindowsWebView2()?e="windows-webview2":"cordova"===e?e="Android"===Od.Platform.OS?"cordova-android":"cordova-ios":"playable-ad-single-file"!==e&&"playable-ad-zip"!==e||(e="playable-ad"),e}get renderer(){return Ld.GetCanvasManager().GetRendererString()}get rendererDetail(){return Ld.GetCanvasManager().GetRendererDetailString()}get canvasClientX(){return Ld.GetCanvasManager().GetCanvasClientX()}get canvasClientY(){return Ld.GetCanvasManager().GetCanvasClientY()}get canvasCssWidth(){return Ld.GetCanvasManager().GetCssWidth()}get canvasCssHeight(){return Ld.GetCanvasManager().GetCssHeight()}get canvasDeviceWidth(){return Ld.GetCanvasManager().GetDeviceWidth()}get canvasDeviceHeight(){return Ld.GetCanvasManager().GetDeviceHeight()}get devicePixelRatio(){return Ld.GetDevicePixelRatio()}}}{const Vd=self.C3,Ud=self.C3X;self.IStorage=class{constructor(e){this._storage=e._GetProjectStorage()}getItem(e){return Ud.RequireString(e),this._storage.getItem(e)}setItem(e,t){return Ud.RequireString(e),this._storage.setItem(e,t)}removeItem(e){return Ud.RequireString(e),this._storage.removeItem(e)}clear(){return this._storage.clear()}keys(){return this._storage.keys()}}}{const jd=self.C3,Hd=self.C3X,zd=jd._GetInternalAPIToken();self.IPlugin=class{#e;constructor(){const e=jd.AddonManager._GetInitObject2(zd);this.#e=e,Object.defineProperties(this,{runtime:{value:e.GetRuntime().GetIRuntime(),writable:!1},id:{value:e.GetID(),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=jd.AddonManager.GetPluginByConstructorFunction(e);return t?t.GetIPlugin():null}getSingleGlobalObjectType(){return this.#e.GetSingleGlobalObjectClass().GetIObjectClass()}getSingleGlobalInstance(){return this.#e.GetSingleGlobalInstance().GetInterfaceClass()}}}{const Xd=globalThis.C3,Yd=globalThis.C3X,qd=Xd._GetInternalAPIToken();globalThis.IObjectClass=class{#e;constructor(){const e=Xd.AddonManager._GetInitObject2(qd);this.#e=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){Yd.RequireString(e),Yd.RequireFunction(t),this.#e.UserScriptDispatcher().addEventListener(e,t)}removeEventListener(e,t){Yd.RequireString(e),Yd.RequireFunction(t),this.#e.UserScriptDispatcher().removeEventListener(e,t)}getAllInstances(){return[...this.instances()]}getFirstInstance(){return Xd.first(this.instances())}getPickedInstances(){return[...this.pickedInstances()]}getFirstPickedInstance(){return Xd.first(this.pickedInstances())}getPairedInstance(e){const t=this.#e,s=t.GetRuntime()._UnwrapIInstance(e),i=t.GetPairedInstance(s);return i?i.GetInterfaceClass():null}*instances(){for(const e of this.#e.instancesIncludingPendingCreate())yield e.GetInterfaceClass()}*pickedInstances(){for(const e of this.#e.GetCurrentSol().GetInstances())yield e.GetInterfaceClass()}}}{const Kd=globalThis.C3,$d=globalThis.C3X,Jd=Kd._GetInternalAPIToken();globalThis.IObjectType=class extends globalThis.IObjectClass{#e;constructor(){super();const e=Kd.AddonManager._GetInitObject2(Jd);this.#e=e}setInstanceClass(e){$d.RequireFunction(e);const t=this.#e;if(t.GetInstanceCount()>0)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($d.RequireNumber(t),$d.RequireNumber(s),"number"!=typeof e&&"string"!=typeof e)throw new TypeError("invalid layer parameter");const r=this.#e,a=r.GetRuntime(),o=a.GetMainRunningLayout().GetLayer(e);if(!o)throw new Error("invalid layer");const h=a.CreateInstance(r,o,t,s,i,n);i&&o.SortAndAddInstancesByZIndex(h);const l=a.GetEventSheetManager();return l.BlockFlushingInstances(!0),h._TriggerOnCreatedOnSelfAndRelated(),l.BlockFlushingInstances(!1),l.IsInEventEngine()||a.GetLayoutManager().IsEndingLayout()||a.FlushPendingInstances(),h.GetInterfaceClass()}getAllFamilies(){return this.#e.GetFamilies().map(e=>e.GetIObjectClass())}*families(){for(const e of this.#e.GetFamilies())yield e.GetIObjectClass()}isInFamily(e){return $d.RequireInstanceOf(e,globalThis.IFamily),e.hasObjectType(this)}}}{const Zd=globalThis.C3,Qd=globalThis.C3X,e_=globalThis.IObjectType,t_=Zd._GetInternalAPIToken();globalThis.IFamily=class extends globalThis.IObjectClass{#e;constructor(){super();const e=Zd.AddonManager._GetInitObject2(t_);this.#e=e}getAllObjectTypes(){return this.#e.GetFamilyMembers().map(e=>e.GetIObjectClass())}*objectTypes(){for(const e of this.#e.GetFamilyMembers())yield e.GetIObjectClass()}hasObjectType(e){Qd.RequireInstanceOf(e,e_);const t=this.#e,s=t.GetRuntime()._UnwrapIObjectClass(e);return t.FamilyHasMember(s)}}}{const s_=self.C3,i_=self.C3X,n_=["above","below","top-sublayer","bottom-sublayer"];self.ILayout=class{#e;constructor(e){this.#e=e;const t=[],s=e.GetEffectList(),i=s.GetAllEffectTypes().length;for(let e=0;ee.GetILayer())}*allLayers(){for(const e of this.#e.allLayers())yield e.GetILayer()}addLayer(e,t,s){const i=this.#e,n=self.ILayer;i_.RequireString(e),i_.RequireOptionalInstanceOf(t,n);const r=t?i.GetRuntime()._UnwrapScriptInterface(t):null,a=n_.indexOf(s);if(a<0)throw new Error("invalid location");i.AddLayer(e,r,a)}moveLayer(e,t,s){const i=this.#e,n=i.GetRuntime(),r=self.ILayer;i_.RequireInstanceOf(e,r);const a=n._UnwrapScriptInterface(e);if(!a)throw new Error("invalid layer");i_.RequireOptionalInstanceOf(t,r);const o=t?n._UnwrapScriptInterface(t):null,h=n_.indexOf(s);if(h<0)throw new Error("invalid location");i.MoveLayer(a,o,h)}removeLayer(e){const t=this.#e,s=self.ILayer;i_.RequireInstanceOf(e,s);const i=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=this.#e,t=e.GetRuntime();e.RemoveAllDynamicLayers(),t.GetEventSheetManager().IsInEventEngine()||t.FlushPendingInstances()}setVanishingPoint(e,t){i_.RequireFiniteNumber(e),i_.RequireFiniteNumber(t),this.#e.SetVanishingPointXY(e,t)}getVanishingPoint(){return this.#e.GetVanishingPoint()}set projection(e){i_.RequireString(e);const t=this.#e;if("perspective"===e)t.SetPerspectiveProjection();else{if("orthographic"!==e)throw new Error("invalid projection");t.SetOrthographicProjection()}}get projection(){return this.#e.IsOrthographicProjection()?"orthographic":"perspective"}}}{const r_=self.C3,a_=self.C3X,o_=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]]),h_=new Map([...o_.entries()].map(e=>[e[1],e[0]])),l_=new Set(["2d","3d"]),c_=r_.New(r_.Color);self.ILayer=class{#e;constructor(e){this.#e=e;const t=[],s=e.GetEffectList(),i=s.GetAllEffectTypes().length;for(let e=0;ee.GetInterfaceClass()):[]}*otherContainerInstances(){const e=this.#e;if(e.IsInContainer())for(const t of e.siblings())yield t.GetInterfaceClass()}get uid(){return this.#e.GetUID()}get iid(){return this.#e.GetIID()}get templateName(){return this.#e.GetTemplateName()}set timeScale(e){__.RequireFiniteNumber(e),this.#e.SetTimeScale(e)}get timeScale(){return this.#e.GetActiveTimeScale()}restoreTimeScale(){this.#e.RestoreTimeScale()}get dt(){const e=this.#e;return e.GetRuntime().GetDt(e)}hasTags(...e){__.RequireArray(e);const t=new Set(e),s=this.#e.GetTagsSet();return t.isSubsetOf(s)}setAllTags(e){__.RequireInstanceOf(e,Set),this.#e.SetTagsSet(e)}getAllTags(){return new Set(this.#e.GetTagsSet())}signal(e){__.RequireString(e);const t=this.#e;t.GetRuntime().GetEventSheetManager().InstanceSignal(t,e)}waitForSignal(e){__.RequireString(e);const t=this.#e;return t.GetRuntime().GetEventSheetManager().WaitForInstanceSignal(t,e)}}}{const m_=self.C3,f_=self.C3X,S_=m_._GetInternalAPIToken();self.ISDKInstanceBase=class extends self.IInstance{#e;#t=!1;#s=null;#i=!1;#n=null;#r;#a;constructor(e){super(),this.#e=m_.AddonManager._GetInitObject2(S_),this.#t=!1,this.#s=null,this.#i=!1,this.#n=null,this.#r=e?.domComponentId,this.#a=e?.wrapperComponentId}_release(){this._setTicking(!1),this._setTicking2(!1),super._release()}_getInitProperties(){return m_.AddonManager._GetInitProperties()}_trigger(e){const t=this.#e;t.GetRuntime().Trigger(e,t)}_triggerAsync(e){const t=this.#e;return t.GetRuntime().TriggerAsync(e,t)}_addDOMMessageHandler(e,t){if(f_.RequireString(e),f_.RequireFunction(t),!this.#r)throw new Error("no DOM component id set");this.#e.GetRuntime().AddDOMComponentMessageHandler(this.#r,e,t)}_addDOMMessageHandlers(e){f_.RequireArray(e);for(const[t,s]of e)this._addDOMMessageHandler(t,s)}_postToDOM(e,t){if(f_.RequireString(e),!this.#r)throw new Error("no DOM component id set");this.#e.GetRuntime().PostComponentMessageToDOM(this.#r,e,t)}_postToDOMAsync(e,t){if(f_.RequireString(e),!this.#r)throw new Error("no DOM component id set");return this.#e.GetRuntime().PostComponentMessageToDOMAsync(this.#r,e,t)}_postToDOMMaybeSync(e,t){if(!this.#e.GetRuntime().IsInWorker())return window.c3_runtimeInterface._OnMessageFromRuntime({type:"event",component:this.#r,handler:e,data:t,responseId:null});this._postToDOM(e,t)}_setTicking(e){if(e=!!e,this.#t===e)return;this.#t=e;const t=this.#e.GetRuntime();if(e){if(!this.#s)if(this.#e.GetRuntime().IsDebug()){const e=globalThis.C3Debugger,t=this.plugin;this.#s=()=>{const s=performance.now();this._tick(),e.AddIndividualPluginTickTime(t,performance.now()-s)}}else this.#s=()=>this._tick();t.Dispatcher().addEventListener("tick",this.#s)}else t.Dispatcher().removeEventListener("tick",this.#s)}_isTicking(){return this.#t}_tick(){}_setTicking2(e){if(e=!!e,this.#i===e)return;this.#i=e;const t=this.#e.GetRuntime();if(e){if(!this.#n)if(this.#e.GetRuntime().IsDebug()){const e=globalThis.C3Debugger,t=this.plugin;this.#n=()=>{const s=performance.now();this._tick2(),e.AddIndividualPluginTickTime(t,performance.now()-s)}}else this.#n=()=>this._tick2();t.Dispatcher().addEventListener("tick2",this.#n)}else t.Dispatcher().removeEventListener("tick2",this.#n)}_isTicking2(){return this.#i}_tick2(){}_getDebuggerProperties(){return[]}_saveToJson(){return null}_loadFromJson(e){}_isWrapperExtensionAvailable(){if(!this.#a)throw new Error("no wrapper component id set");return this.#e.GetRuntime().HasWrapperComponentId(this.#a)}_addWrapperExtensionMessageHandler(e,t){if(f_.RequireString(e),f_.RequireFunction(t),!this.#a)throw new Error("no wrapper component id set");this.#e.GetRuntime().AddWrapperExtensionMessageHandler(this.#a,e,t)}_addWrapperMessageHandlers(e){f_.RequireArray(e);for(const[t,s]of e)this._addWrapperExtensionMessageHandler(t,s)}_sendWrapperExtensionMessage(e,t){if(!this.#a)throw new Error("no wrapper component id set");this.runtime.sdk.sendWrapperExtensionMessage(this.#a,e,t)}_sendWrapperExtensionMessageAsync(e,t){if(!this.#a)throw new Error("no wrapper component id set");return this.runtime.sdk.sendWrapperExtensionMessageAsync(this.#a,e,t)}}}{let G_=function(e){return class t extends e{#e;#t;constructor(e){super(e);const t=y_.AddonManager._GetInitObject2(x_),s=t.GetWorldInfo();this.#e=t,this.#t=s,P_.set(this,t);const i=[],n=s.GetInstanceEffectList();if(n){const e=s.GetObjectClass().GetEffectList().GetAllEffectTypes().length;for(let t=0;t[e[1],e[0]])),R_=y_.New(y_.Color);self.IWorldInstance=G_(self.IInstance),self.IWorldInstanceSDKBase=G_(self.ISDKInstanceBase)}{const M_=self.C3,D_=self.C3X;self.IDOMInstance=class extends self.IWorldInstance{#e;constructor(){super(),this.#e=self.IInstance._GetInitInst()}getElement(){return this.#e.GetSdkInstance()._GetElementInDOMMode()}focus(){this.#e.GetSdkInstance().FocusElement()}blur(){this.#e.GetSdkInstance().BlurElement()}setCssStyle(e,t){D_.RequireString(e),this.#e.GetSdkInstance().SetElementCSSStyle(e,t)}}}{let E_=function(e){let t=B_.get(e);return t||(t=F_.New(F_.Event.Dispatcher),B_.set(e,t),t)};GetDispatcher=E_;const F_=self.C3,O_=self.C3X,B_=new WeakMap,L_=F_._GetInternalAPIToken();self.IBehaviorInstance=class{#e;constructor(){const e=F_.AddonManager._GetInitObject2(L_);this.#e=e;const t={runtime:{value: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 F_.AddonManager._GetInitObject()}get instance(){return this.#e.GetObjectInstance().GetInterfaceClass()}_release(){const e=B_.get(this);e&&(e.Release(),B_.delete(this))}addEventListener(e,t,s){O_.RequireString(e),O_.RequireFunction(t),E_(this).addEventListener(e,t,s)}removeEventListener(e,t,s){O_.RequireString(e),O_.RequireFunction(t),E_(this).removeEventListener(e,t,s)}dispatchEvent(e){E_(this).dispatchEvent(e)}}}{const k_=self.C3,N_=self.C3X,W_=k_._GetInternalAPIToken();self.IBehaviorType=class{constructor(){const e=k_.AddonManager._GetInitObject2(W_),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 V_=self.C3,U_=self.C3X,j_=V_._GetInternalAPIToken();self.IBehavior=class{#t;constructor(){const e=V_.AddonManager._GetInitObject2(j_);this.#t=e;const t={runtime:{value:e.GetRuntime().GetIRuntime(),writable:!1},id:{value:e.GetID(),writable:!1}};Object.defineProperties(this,t),e.GetRuntime()._MapScriptInterface(this,e)}getAllInstances(){return this.#t.GetInstances().map(e=>e.GetInterfaceClass())}static getByConstructor(e){if(!e)return null;const t=V_.AddonManager.GetBehaviorByConstructorFunction(e);return t?t.GetIBehavior():null}}}{const H_=self.C3,z_=self.C3X,X_=H_.New(H_.Color);self.IEffectInstance=class{#e;constructor(e,t){this.#e=e;const s={index:{value:t,writable:!1}};Object.defineProperties(this,s)}get name(){return this.#e.GetAllEffectTypes()[this.index].GetName()}get isActive(){return this.#e.IsEffectIndexActive(this.index)}set isActive(e){e=!!e;const t=this.#e;t.IsEffectIndexActive(this.index)!==e&&(t.SetEffectIndexActive(this.index,e),t.UpdateActiveEffects(),t.GetRuntime().UpdateRender())}setParameter(e,t){z_.RequireFiniteNumber(e),e=Math.floor(+e);const s=this.#e,i=s.GetEffectParameter(this.index,e);if(null===i)throw new RangeError("invalid index");if(i instanceof H_.Color){if(!Array.isArray(t)||t.length<3)throw new TypeError("expected array with 3 elements");X_.setRgb(t[0],t[1],t[2]),t=X_}else if("number"!=typeof t)throw new TypeError("expected number");s.SetEffectParameter(this.index,e,t)&&s.IsEffectIndexActive(this.index)&&s.GetRuntime().UpdateRender()}getParameter(e){z_.RequireFiniteNumber(e),e=Math.floor(+e);const t=this.#e.GetEffectParameter(this.index,e);if(null===t)throw new RangeError("invalid index");return t instanceof H_.Color?[t.getR(),t.getG(),t.getB()]:t}}}{const Y_=self.C3,q_=self.C3X;self.IAnimation=class{#e;constructor(e){this.#e=e,Object.defineProperties(this,{name:{value:e.GetName(),writable:!1}})}get speed(){return this.#e.GetSpeed()}get isLooping(){return this.#e.IsLooping()}get repeatCount(){return this.#e.GetRepeatCount()}get repeatTo(){return this.#e.GetRepeatTo()}get isPingPong(){return this.#e.IsPingPong()}get frameCount(){return this.#e.GetFrameCount()}getFrames(){return this.#e.GetFrames().map(e=>e.GetIAnimationFrame())}*frames(){for(const e of this.#e.GetFrames())yield e.GetIAnimationFrame()}}}{const K_=self.C3,$_=self.C3X;self.IImageInfo=class{#t;constructor(e){this.#t=e}static _Unwrap(e){return e.#t}get width(){return this.#t.GetWidth()}get height(){return this.#t.GetHeight()}getSize(){const e=this.#t;return[e.GetWidth(),e.GetHeight()]}getTexture(e){return e.getTextureForImageInfo(this)}getTexRect(){return this.#t.GetTexRect().toDOMRect()}}}{const J_=self.C3,Z_=self.C3X;self.IAnimationFrame=class extends self.IImageInfo{#t;constructor(e){super(e.GetImageInfo()),this.#t=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.#t;return[e.GetOriginX(),e.GetOriginY()]}getImagePointCount(){return this.#t.GetImagePointCount()}getImagePointX(e){return this.getImagePoint(e)[0]}getImagePointY(e){return this.getImagePoint(e)[1]}getImagePoint(e){const t=this.#t;let 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.#t.GetCollisionPoly();return e?e.pointCount():0}getPolyPointX(e){return this.getPolyPoint(e)[0]}getPolyPointY(e){return this.getPolyPoint(e)[1]}getPolyPoint(e){Z_.RequireFiniteNumber(e),e=Math.floor(e);const t=this.#t.GetCollisionPoly();if(!t||e<0||e>=t.pointCount())return[0,0];const s=t.pointsArr();return[s[2*e],s[2*e+1]]}get tag(){return this.#t.GetTag()}}}{let Q_=function(e){const t=sp.get(e);if(t.IsReleased())throw new Error("timeline/tween was released and is no longer valid");return t};GetTimelineState=Q_;const ep=self.C3,tp=self.C3X,sp=new WeakMap;self.ITimelineStateBase=class{constructor(e){sp.set(this,e),e.GetRuntime()._MapScriptInterface(this,e)}pause(){Q_(this).Stop()}resume(){Q_(this).Resume()}stop(){Q_(this).Reset()}hasTags(e){return Q_(this).HasTags(e)}set time(e){tp.RequireFiniteNumber(e),Q_(this).SetTime(e)}get time(){return Q_(this).GetTime()}set totalTime(e){tp.RequireFiniteNumber(e),Q_(this).SetTotalTime(e)}get totalTime(){return Q_(this).GetTotalTime()}set isLooping(e){Q_(this).SetLoop(!!e)}get isLooping(){return Q_(this).GetLoop()}set isPingPong(e){Q_(this).SetPingPong(!!e)}get isPingPong(){return Q_(this).GetPingPong()}set playbackRate(e){tp.RequireFiniteNumber(e),Q_(this).SetPlaybackRate(e)}get playbackRate(){return Q_(this).GetPlaybackRate()}get progress(){const e=Q_(this);return e.GetTime()/e.GetTotalTime()}get tags(){return Q_(this).GetTags()}get finished(){return Q_(this).GetPlayPromise()}get isPlaying(){return Q_(this).IsPlaying()}get isPaused(){return Q_(this).IsPaused()}get isReleased(){return sp.get(this).IsReleased()}}}{let ip=function(e){const t=ap.get(e);if(t.IsReleased())throw new Error("timeline was released and is no longer valid");return t};GetTimelineState=ip;const np=self.C3,rp=self.C3X,ap=new WeakMap;let op=null;self.ITimelineState=class extends self.ITimelineStateBase{constructor(e){super(e),ap.set(this,e);const t={name:{value:e.GetName(),writable:!1}};Object.defineProperties(this,t)}}}{let hp=function(e){const t=up.get(e);if(t.IsReleased())throw new Error("tween was released and is no longer valid");return t};GetTweenState=hp;const lp=self.C3,cp=self.C3X,up=new WeakMap,dp=new WeakMap;let _p=null;self.ITweenState=class extends self.ITimelineStateBase{constructor(e,t,s){super(e),_p||(_p=s.easeToIndexFunc),up.set(this,e),t&&dp.set(this,t)}stop(){const e=hp(this);dp.get(this).ReleaseTween(e)}setEase(e){cp.RequireString(e);const t=self.Ease.GetEaseFromIndex(_p(e));hp(this).SetEase(t)}get instance(){const e=hp(this).GetInstance();return e?e.GetInterfaceClass():null}get isDestroyOnComplete(){return hp(this).GetDestroyInstanceOnComplete()}set isDestroyOnComplete(e){hp(this).SetDestroyInstanceOnComplete(!!e)}get value(){const e=hp(this);if("value"!==e.GetId())throw new Error("not a value tween");return e.GetPropertyTrack("value").GetSourceAdapterValue()}}}{const pp=self.C3,gp=self.C3X;self.ISDKPluginBase=class extends self.IPlugin{constructor(){super()}}}{const mp=self.C3,fp=self.C3X,Sp=mp._GetInternalAPIToken();self.ISDKDOMPluginBase=class extends self.ISDKPluginBase{#e;#s;#t=0;#r=new Map;constructor(e){if(super(),this.#e=mp.AddonManager._GetInitObject2(Sp),!e?.domComponentId)throw new Error("no DOM component ID specified");this.#s=e.domComponentId,this._addElementMessageHandler("elem-focused",e=>e._onElemFocused()),this._addElementMessageHandler("elem-blurred",e=>{e&&e._onElemBlurred()})}_addElement(e){const t=this.#t++;return this.#r.set(t,e),t}_removeElement(e){this.#r.delete(e)}_addElementMessageHandler(e,t){this.#e.GetRuntime().AddDOMComponentMessageHandler(this.#s,e,e=>{const s=this.#r.get(e.elementId);t(s,e)})}_addElementMessageHandlers(e){fp.RequireArray(e);for(const[t,s]of e)this._addElementMessageHandlers(t,s)}}}{const Gp=self.C3,yp=self.C3X,Ip=new WeakMap,Tp=Gp._GetInternalAPIToken();self.ISDKObjectTypeBase=class extends self.IObjectType{#e;constructor(){super(),this.#e=Gp.AddonManager._GetInitObject2(Tp)}_onCreate(){}getImageInfo(){return this.#e.GetImageInfo().GetIImageInfo()}_loadTextures(e){}_releaseTextures(e){}_onDynamicTextureLoadComplete(){}_preloadTexturesWithInstances(e){}}}{const Cp=self.C3,bp=self.C3X,wp=new WeakMap,Pp=Cp._GetInternalAPIToken();self.ISDKWorldInstanceBase=class extends self.IWorldInstanceSDKBase{#e;#n=null;#t=null;constructor(e){super(e),this.#e=Cp.AddonManager._GetInitObject2(Pp)}_release(){if(super._release(),this.#n){const e=this.#e.GetRuntime().Dispatcher();e.removeEventListener("renderercontextlost",this.#n),e.removeEventListener("renderercontextrestored",this.#t),this.#n=null,this.#t=null}}_handleRendererContextLoss(){if(this.#n)return;this.#n=()=>this._onRendererContextLost(),this.#t=()=>this._onRendererContextRestored();const e=this.#e.GetRuntime().Dispatcher();e.addEventListener("renderercontextlost",this.#n),e.addEventListener("renderercontextrestored",this.#t)}_onRendererContextLost(){}_onRendererContextRestored(){}_draw(e){}_rendersToOwnZPlane(){return!0}_mustPreDraw(){return!1}}}{const xp=self.C3,vp=self.C3X,Ap=xp.New(xp.Rect),Rp=new WeakMap,Mp=xp._GetInternalAPIToken();self.ISDKDOMInstanceBase=class extends self.ISDKWorldInstanceBase{#e=-1;#t=!0;#r=!1;#i=!1;#s=-.2;#a=xp.New(xp.Rect,0,0,-1,-1);#o=0;#h=0;#l=-1;#c=-1;#u=!1;constructor(e){if(!e?.domComponentId)throw new Error("no DOM component ID specified");super(e);const t=xp.AddonManager._GetInitObject2(Mp);Rp.set(this,t),this.#e=this.plugin._addElement(this);const s=t.GetRuntime().GetCanvasManager();this.#o=s.GetLastWidth(),this.#h=s.GetLastHeight(),this._setTicking(!0)}_release(){super._release(),this.plugin._removeElement(this.#e),this._postToDOMElement("destroy"),this.#e=-1,Rp.delete(this)}_getElementInDOMMode(){if(Rp.get(this).GetRuntime().IsInWorker())throw new Error("not valid in worker mode");return this._postToDOMElementMaybeSync("get-element")}_postToDOMElement(e,t){t||(t={}),t.elementId=this.#e,this._postToDOM(e,t)}_postToDOMElementMaybeSync(e,t){return t||(t={}),t.elementId=this.#e,this._postToDOMMaybeSync(e,t)}_postToDOMElementAsync(e,t){return t||(t={}),t.elementId=this.#e,this._postToDOMAsync(e,t)}_createElement(e){e||(e={});const t=Rp.get(this).GetWorldInfo();e.elementId=this.#e,e.isVisible=t.IsVisible(),e.htmlIndex=t.GetLayer().GetHTMLIndex(),e.htmlZIndex=t.GetHTMLZIndex(),Object.assign(e,this._getElementState()),this.#t=!!e.isVisible,this._postToDOMMaybeSync("create",e),this._updatePosition(!0)}setElementVisible(e){e=!!e,this.#t!==e&&(this.#t=e,this._postToDOMElement("set-visible",{isVisible:e}))}_tick(){this._updatePosition(!1)}_shouldPreserveElement(){const e=Rp.get(this).GetRuntime().GetCanvasManager().GetFullscreenMode();return"Android"===xp.Platform.OS&&("scale-inner"===e||"scale-outer"===e||"crop"===e)}_updatePosition(e){const t=Rp.get(this);if(t.IsDestroyed())return;const s=t.GetWorldInfo(),i=s.GetLayer(),n=s.GetBoundingBox();let[r,a]=i.LayerToCanvasCss(n.getLeft(),n.getTop()),[o,h]=i.LayerToCanvasCss(n.getRight(),n.getBottom());const l=t.GetRuntime().GetCanvasManager(),c=l.GetCssWidth(),u=l.GetCssHeight();if(!s.IsVisible()||!i.IsVisible())return void this.setElementVisible(!1);if(!this._shouldPreserveElement()&&(o<=0||h<=0||r>=c||a>=u))return void this.setElementVisible(!1);Ap.set(r,a,o,h);const d=l.GetLastWidth(),_=l.GetLastHeight(),p=i.GetHTMLIndex(),g=s.GetHTMLZIndex();if(!e&&Ap.equals(this.#a)&&this.#o===d&&this.#h===_&&this.#l===p&&this.#c===g)return void this.setElementVisible(!0);this.#a.copy(Ap),this.#o=d,this.#h=_,this.#l=p,this.#c=g,this.setElementVisible(!0);let m=null;this.#i&&(m=i.GetDisplayScale()+this.#s),this._postToDOMElement("update-position",{left:Math.round(this.#a.getLeft()),top:Math.round(this.#a.getTop()),width:Math.round(this.#a.width()),height:Math.round(this.#a.height()),htmlIndex:p,htmlZIndex:g,fontSize:m})}focusElement(){this._postToDOMElementMaybeSync("focus",{focus:!0})}blurElement(){this._postToDOMElementMaybeSync("focus",{focus:!1})}_onElemFocused(){this.#r=!0}_onElemBlurred(){this.#r=!1}isElementFocused(){return this.#r}setElementCSSStyle(e,t){this.postToDOMElement("set-css-style",{prop:xp.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.#u||(this.#u=!0,Promise.resolve().then(()=>{this.#u=!1,this._postToDOMElement("update-state",this._getElementState())}))}_getElementState(){}_getElementId(){return this.#e}}}{const Dp=self.C3,Ep=self.C3X;self.ISDKBehaviorBase=class extends self.IBehavior{constructor(){super()}}}{const Fp=self.C3,Op=self.C3X;self.ISDKBehaviorTypeBase=class extends globalThis.IBehaviorType{constructor(){super()}_onCreate(){}}}{const Bp=self.C3,Lp=self.C3X,kp=new WeakMap,Np=Bp._GetInternalAPIToken();self.ISDKBehaviorInstanceBase=class extends self.IBehaviorInstance{#i=!1;#t=!1;#e=!1;constructor(){super(),kp.set(this,Bp.AddonManager._GetInitObject2(Np))}_release(){super._release(),this._setTicking(!1),this._setTicking2(!1),this._setPostTicking(!1),kp.delete(this)}_getInitProperties(){return Bp.AddonManager._GetInitProperties()}_postCreate(){}_trigger(e){const t=kp.get(this);t.GetRuntime().Trigger(e,t.GetObjectInstance(),t.GetBehaviorType())}_triggerAsync(e){const t=kp.get(this);return t.GetRuntime().TriggerAsync(e,t.GetObjectInstance(),t.GetBehaviorType())}_setTicking(e){if(e=!!e,this.#i===e)return;this.#i=e;const t=kp.get(this).GetRuntime();e?t._AddBehInstToTick(this):t._RemoveBehInstToTick(this)}_isTicking(){return this.#i}_tick(){}_setTicking2(e){if(e=!!e,this.#t===e)return;this.#t=e;const t=kp.get(this).GetRuntime();e?t._AddBehInstToTick2(this):t._RemoveBehInstToTick2(this)}_isTicking2(){return this.#t}_tick2(){}_setPostTicking(e){if(e=!!e,this.#e===e)return;this.#e=e;const t=kp.get(this).GetRuntime();e?t._AddBehInstToPostTick(this):t._RemoveBehInstToPostTick(this)}_isPostTicking(){return this.#e}_postTick(){}_getDebuggerProperties(){return[]}_saveToJson(){return null}_loadFromJson(e){}}}{const Wp=self.C3,Vp=self.C3X;let Up=null;self.ISDKUtils=class{constructor(e){Up=e}addLoadPromise(e){Up.AddLoadPromise(e)}sendWrapperExtensionMessage(e,t,s){Vp.RequireString(e),Vp.RequireString(t),Vp.RequireOptionalArray(s),Up.SendWrapperExtensionMessage(e,t,s)}sendWrapperExtensionMessageAsync(e,t,s){return Vp.RequireString(e),Vp.RequireString(t),Vp.RequireOptionalArray(s),Up.SendWrapperExtensionMessageAsync(e,t,s)}createLoopingConditionContext(e){return Vp.RequireOptionalString(e),new self.ILoopingConditionContext(Up,e)}set isAutoSuspendEnabled(e){Up._SetAutoSuspendEnabled(!!e)}get isAutoSuspendEnabled(){return Up._IsAutoSuspendEnabled()}setSuspended(e){Up.SetSuspended(!!e)}getObjectClassBySid(e){Vp.RequireNumber(e);const t=Up.GetObjectClassBySID(e);return t?t.GetIObjectClass():null}}}{const jp=self.C3,Hp=self.C3X;self.ILoopingConditionContext=class{#e;#t;#a;#s;#r;#n;constructor(e,t){this.#e=e;const s=e.GetEventSheetManager(),i=e.GetCurrentEvent();this.#t=i,this.#a=i.GetSolModifiers();const n=e.GetEventStack();this.#s=n.GetCurrentStackFrame(),this.#r=n.Push(i);const r=s.GetLoopStack().Push();this.#n=r,t&&r.SetName(t),e.SetDebuggingEnabled(!1)}retrigger(){const e=this.#e.GetEventSheetManager(),t=this.#a,s=this.#n;e.PushCopySol(t),this.#t.Retrigger(this.#s,this.#r),e.PopSol(t),s.SetIndex(s.GetIndex()+1)}get isStopped(){return this.#n.IsStopped()}release(){const e=this.#e,t=e.GetEventStack(),s=e.GetEventSheetManager().GetLoopStack();e.SetDebuggingEnabled(!0),s.Pop(),t.Pop()}}}{let zp=function(e){return e instanceof ImageBitmap||"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas};IsStaticTextureDataType=zp;const Xp=self.C3,Yp=self.C3X;let qp=null,Kp=null;const $p=["none","back","front"],Jp=["cw","ccw"];self.IRenderer=class{constructor(e,t){Kp=e,qp=t}setAlphaBlendMode(){qp.SetAlphaBlend()}setBlendMode(e){qp.SetNamedBlendMode(e)}setColorFillMode(){qp.SetColorFillMode()}setTextureFillMode(){qp.SetTextureFillMode()}setSmoothLineFillMode(){qp.SetSmoothLineFillMode()}setColor(e){qp.SetColorRgba(e[0],e[1],e[2],e[3])}setColorRgba(e,t,s,i){qp.SetColorRgba(e,t,s,i)}resetColor(){qp.ResetColor()}setOpacity(e){qp.SetOpacity(e)}setCurrentZ(e){qp.SetCurrentZ(e)}getCurrentZ(){return qp.GetCurrentZ()}setCullFaceMode(e){const t=$p.indexOf(e);if(-1===t)throw new Error("invalid cull mode");qp.SetCullFaceMode(t)}getCullFaceMode(){return $p[qp.GetCullFaceMode()]}setFrontFaceWinding(e){const t=Jp.indexOf(e);if(-1===t)throw new Error("invalid front face winding");qp.SetFrontFaceWinding(t)}getFrontFaceWinding(){return qp.GetFrontFaceWinding()}rect(e){qp.Rect2(e.left,e.top,e.right,e.bottom)}rect2(e,t,s,i){qp.Rect2(e,t,s,i)}quad(e){qp.Quad(Xp.Quad.fromDOMQuad(e))}quad2(e,t,s,i,n,r,a,o){qp.Quad2(e,t,s,i,n,r,a,o)}quad3(e,t){qp.Quad3(Xp.Quad.fromDOMQuad(e),Xp.Rect.fromDOMRect(t))}quad4(e,t){qp.Quad4(Xp.Quad.fromDOMQuad(e),Xp.Quad.fromDOMQuad(t))}quad5(e,t,s){qp.Quad5(Xp.Quad.fromDOMQuad(e),Xp.Quad.fromDOMQuad(t),s)}quad3D(e,t,s,i,n,r,a,o,h,l,c,u,d){qp.Quad3D(e,t,s,i,n,r,a,o,h,l,c,u,Xp.Rect.fromDOMRect(d))}quad3D2(e,t,s,i,n,r,a,o,h,l,c,u,d){qp.Quad3D2(e,t,s,i,n,r,a,o,h,l,c,u,Xp.Quad.fromDOMQuad(d))}quad3D3(e,t,s,i,n,r,a,o,h,l,c,u,d,_){qp.Quad3D3(e,t,s,i,n,r,a,o,h,l,c,u,Xp.Quad.fromDOMQuad(d),_)}drawMesh(e,t,s,i){qp.DrawMesh(e,t,s,i)}convexPoly(e){qp.ConvexPoly(e)}line(e,t,s,i){qp.Line(e,t,s,i)}texturedLine(e,t,s,i,n,r){qp.TexturedLine(e,t,s,i,n,r)}lineRect(e,t,s,i){qp.LineRect(e,t,s,i)}lineRect2(e){qp.LineRect2(Xp.Rect.fromDOMRect(e))}lineQuad(e){qp.LineQuad(Xp.Quad.fromDOMQuad(e))}pushLineWidth(e){qp.PushLineWidth(e)}popLineWidth(){qp.PopLineWidth()}pushLineCap(e){qp.PushLineCap(e)}popLineCap(){qp.PopLineCap()}setTexture(e){Yp.RequireOptionalInstanceOf(e,self.ITexture);const t=e?Kp._UnwrapScriptInterface(e):null;qp.SetTexture(t)}loadTextureForImageInfo(e,t){const s=self.IImageInfo._Unwrap(e);if(!s)throw new Error("invalid IImageInfo");return s.LoadStaticTexture(qp,{wrapX:t?.wrapX??"clamp-to-edge",wrapY:t?.wrapY??"clamp-to-edge",sampling:t?.sampling??"trilinear",mipMap:t?.mipMap??!0})}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(Kp,s)}createStaticTexture(e,t){if(!zp(e))throw new TypeError("invalid texture data");const s=qp.CreateStaticTexture(e,{wrapX:t?.wrapX??"clamp-to-edge",wrapY:t?.wrapY??"clamp-to-edge",sampling:t?.sampling??"trilinear",mipMap:t?.mipMap??!0});return self.ITexture.GetInterface(Kp,s)}createDynamicTexture(e,t,s){Yp.RequireFiniteNumber(e),Yp.RequireFiniteNumber(t);const i=qp.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(Kp,i)}updateTexture(e,t,s){Yp.RequireInstanceOf(t,self.ITexture);const i=Kp._UnwrapScriptInterface(t);qp.UpdateTexture(e,i,{premultiplyAlpha:s?.premultiplyAlpha??!0})}deleteTexture(e){Yp.RequireInstanceOf(e,self.ITexture);const t=Kp._UnwrapScriptInterface(e);qp.DeleteTexture(t)}createRendererText(){const e=qp.CreateRendererText();return new self.IRendererText(Kp,e)}setDeviceTransform(){Kp.GetCanvasManager().SetDeviceTransform(qp)}setLayerTransform(e){Yp.RequireInstanceOf(e,globalThis.ILayer),Kp._UnwrapScriptInterface(e)._SetTransform(qp)}}}{const Zp=self.C3,Qp=self.C3X,eg=new WeakMap,tg=new WeakMap;self.ITexture=class{constructor(e,t){eg.set(this,{runtime:e,texture:t}),tg.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;return tg.get(t)||new self.ITexture(e,t)}}}{let sg=function(e){return rg.get(e).rendererText};getActual=sg;const ig=self.C3,ng=self.C3X,rg=new WeakMap;self.IRendererText=class{constructor(e,t){rg.set(this,{runtime:e,rendererText:t}),e._MapScriptInterface(this,t)}release(){sg(this).Release()}set fontFace(e){ng.RequireString(e),sg(this).SetFontName(e)}get fontFace(){return sg(this).GetFontName()}set sizePt(e){ng.RequireFiniteNumber(e),sg(this).SetFontSize(e)}get sizePt(){return sg(this).GetFontSize()}set lineHeight(e){ng.RequireFiniteNumber(e),sg(this).SetLineHeight(e)}get lineHeight(){return sg(this).GetLineHeight()}set isBold(e){sg(this).SetBold(e)}get isBold(){return sg(this).IsBold()}set isItalic(e){sg(this).SetItalic(e)}get isItalic(){return sg(this).IsItalic()}setColor(e){ng.RequireArray(e),this.setColorRgb(e[0],e[1],e[2])}setColorRgb(e,t,s){sg(this).SetColorRgb(e,t,s)}setCssColor(e){ng.RequireString(e),sg(this).SetColor(e)}set horizontalAlign(e){sg(this).SetHorizontalAlignment(e)}get horizontalAlign(){return sg(this).GetHorizontalAlignment()}set verticalAlign(e){sg(this).SetVerticalAlignment(e)}get verticalAlign(){return sg(this).GetVerticalAlignment()}set wordWrapMode(e){sg(this).SetWordWrapMode(e)}get wordWrapMode(){return sg(this).GetWordWrapMode()}set textDirection(e){sg(this).SetTextDirection(e)}get textDirection(){return sg(this).GetTextDirection()}set text(e){ng.RequireString(e),sg(this).SetText(e)}get text(){return sg(this).GetText()}setSize(e,t,s){ng.RequireFiniteNumber(e),ng.RequireFiniteNumber(t),ng.RequireFiniteNumber(s),sg(this).SetSize(e,t,s)}getTexture(){const{runtime:e,rendererText:t}=rg.get(this),s=t.GetTexture();return self.ITexture.GetInterface(e,s)}getTexRect(){return sg(this).GetTexRect().toDOMRect()}setTextureUpdateCallback(e){ng.RequireFunction(e),sg(this).ontextureupdate=e}releaseTexture(){sg(this).ReleaseTexture()}get textWidth(){return sg(this).GetTextWidth()}get textHeight(){return sg(this).GetTextHeight()}}}{let ag=function(e){if(!e)return"";const t=e.split(".");if(t.length<2)return"";const s=t.at(-1).toLowerCase();return cg.get(s)||""},og=function(e){return new Promise((t,s)=>{const i=document.createElement("script");i.onload=t,i.onerror=s,i.async=!1,i.type="module",i.src=e,document.head.appendChild(i)})};GetTypeFromFileExtension=ag,AddScript=og;const hg=self.C3,lg=new Set(["local","remote"]),cg=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"]]);hg.AssetManager=class extends hg.DefendedBase{constructor(e,t){super();const s=t.exportType;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;const i="html5"===s||"scirra-arcade"===s||"instant-games"===s;this._defaultLoadPolicy=i?"remote":"local",this._imageAssetsMap=new Map,this._webFonts=[],this._loadPromises=[],this._hasFinishedInitialLoad=!1,this._totalAssetSizeToLoad=0,this._assetSizeLoaded=0,this._lastLoadProgress=0,this._hasHadErrorLoading=!1,this._loadingRateLimiter=hg.New(hg.RateLimiter,()=>this._FireLoadingProgressEvent(),50),this._localPromiseThrottle=hg.New(hg.PromiseThrottle,Math.max(hg.hardwareConcurrency,8)),this._remotePromiseThrottle=hg.New(hg.PromiseThrottle,20),this._iAssetManager=new self.IAssetManager(this)}Release(){for(const e of this._imageAssetsMap.values())e.Release();this._imageAssetsMap.clear(),hg.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,hg.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.Add(()=>hg.FetchBlob(e)):this._remotePromiseThrottle.Add(()=>hg.FetchBlob(e))):hg.FetchBlob(e)}FetchArrayBuffer(e){return hg.IsRelativeURL(e)?("flat"===this._fileStructure&&(e=e.toLowerCase()),this._isCordova&&this._isFileProtocol?this.CordovaFetchLocalFileAsArrayBuffer(e):"playable-ad-single-file"===this._runtime.GetExportType()?hg.BlobToArrayBuffer(self.c3_runtimeInterface._PlayableAdFetchBlob(e)):"local"===this._defaultLoadPolicy?this._localPromiseThrottle.Add(()=>hg.FetchArrayBuffer(e)):this._remotePromiseThrottle.Add(()=>hg.FetchArrayBuffer(e))):hg.FetchArrayBuffer(e)}FetchText(e){return hg.IsRelativeURL(e)?("flat"===this._fileStructure&&(e=e.toLowerCase()),this._isCordova&&this._isFileProtocol?this.CordovaFetchLocalFileAsText(e):"playable-ad-single-file"===this._runtime.GetExportType()?hg.BlobToString(self.c3_runtimeInterface._PlayableAdFetchBlob(e)):"local"===this._defaultLoadPolicy?this._localPromiseThrottle.Add(()=>hg.FetchText(e)):this._remotePromiseThrottle.Add(()=>hg.FetchText(e))):hg.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=ag(e);return new Blob([t],{type:s})}async CordovaFetchLocalFileAsBlobURL(e){"flat"===this._fileStructure&&(e=e.toLowerCase());let t=this._cordovaBlobUrlCache.get(e);if(t)return t;const s=await this.CordovaFetchLocalFileAsBlob(e);return t=URL.createObjectURL(s),this._cordovaBlobUrlCache.set(e,t),t}CordovaFetchLocalFileAsArrayBuffer(e){return this._CordovaFetchLocalFileAs(e,"buffer")}GetMediaFileUrl(e){"flat"===this._fileStructure&&(e=e.toLowerCase());let t=this._mediaSubfolder+e;return"Gecko"===hg.Platform.BrowserEngine&&"preview"===this._runtime.GetExportType()&&(t=this._GetLocalBlobURLFromFileMap(t)),t}GetProjectFileUrl(e){return hg.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(e){if(hg.IsAbsoluteURL(e)||"preview"!==this._runtime.GetExportType()||!this._swClientId||!e)return e;try{const t=new URL(e,location.href);return t.searchParams.set("__c3_client_id",this._swClientId),t.toString()}catch(t){return console.warn("Invalid iframe URL: "+e),e}}LoadProjectFileUrl(e){return this.GetProjectFileUrl(e)}_GetImageAssetKey(e,t){return(t?"true":"false")+"|"+e}LoadImage(e){const t=!!e.isTiled;if(e.loadPolicy&&!lg.has(e.loadPolicy))throw new Error("invalid load policy");const s=this._GetImageAssetKey(e.url,t);let i=this._imageAssetsMap.get(s);return i||(i=hg.New(hg.ImageAsset,this,{url:e.url,size:e.size||0,loadPolicy:e.loadPolicy||this._defaultLoadPolicy,isTiled:t}),this._imageAssetsMap.set(s,i),this._hasFinishedInitialLoad||(this._totalAssetSizeToLoad+=i.GetSize(),this._loadPromises.push(i.Load().then(()=>this._AddLoadedSize(i.GetSize())))),i)}_ReleaseImageAsset(e){const t=this._GetImageAssetKey(e.GetURL(),e.IsTiled());this._imageAssetsMap.delete(t)}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=hg.New(hg.Event,"loadingprogress");this._lastLoadProgress=hg.clamp(this._assetSizeLoaded/this._totalAssetSizeToLoad,0,1),e.progress=this._lastLoadProgress,this._runtime.Dispatcher().dispatchEvent(e),this._runtime.DispatchUserScriptEvent(hg.New(hg.Event,"loadingprogress"))}GetLoadProgress(){return this._lastLoadProgress}GetImageLoadProgress(){return this._runtime.GetSystemPlugin().GetImageLoadingProgress()}_SetWebFonts(e){hg.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()&&t.length>0&&await this._runtime.PostComponentMessageToDOMAsync("runtime","load-webfonts",{webfonts:t})}async _LoadWebFont(e,t,s){try{let i=await this.GetProjectFileUrl(t);"Gecko"===hg.Platform.BrowserEngine&&(e=`'${e}'`),("Gecko"===hg.Platform.BrowserEngine&&"preview"===this._runtime.GetExportType()||"playable-ad-single-file"===this._runtime.GetExportType())&&(i=this._GetLocalBlobURLFromFileMap(i));const n=new FontFace(e,`url('${i}')`);this._runtime.IsInWorker()?self.fonts.add(n):document.fonts.add(n),await n.load(),this._runtime.IsInWorker()&&s.push({name:e,url:i})}catch(t){console.warn(`[C3 runtime] Failed to load web font '${e}': `,t)}}IsAudioFormatSupported(e){return!!this._supportedAudioFormats[e]}_SetAudioFiles(e,t){this._preloadSounds=!!t;for(const[t,s,i]of e)this._audioFiles.set(t,{fileName:t,formats:s.map(e=>({type:e[0],fileExtension:e[1],fullName:t+e[1],fileSize:e[2]})),isMusic:i})}GetPreferredAudioFile(e){"flat"===this._fileStructure&&(e=e.toLowerCase());const t=this._audioFiles.get(e);if(!t)return null;let s=null;for(const e of t.formats)if(s||"audio/webm; codecs=opus"!==e.type||(s=e),this.IsAudioFormatSupported(e.type))return e;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)continue;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)return t;const s=this._GetLocalBlobFromFileMap(e);return s?(t=URL.createObjectURL(s),this._fileMapBlobUrls.set(e,t),t):e}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 t=e[0];await import((hg.IsRelativeURL(t)?"./":"")+t)}else{const t=e.map(e=>`import "${hg.IsRelativeURL(e)?"./":""}${e}";`).join("\n"),s=URL.createObjectURL(new Blob([t],{type:"application/javascript"}));await import(s)}else await Promise.all(t.map(e=>og(e)))}async CompileWebAssembly(e){if(WebAssembly.compileStreaming){const t=await this.GetProjectFileUrl(e);return await WebAssembly.compileStreaming(fetch(t))}{const t=await hg.FetchArrayBuffer(e);return await WebAssembly.compile(t)}}async LoadStyleSheet(e){const t=await this.GetProjectFileUrl(e);return await this._runtime.PostComponentMessageToDOMAsync("runtime","add-stylesheet",{url:t})}}}{const ug=self.C3;ug.Asset=class extends ug.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,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._loadPromise:this._assetManager.FetchBlob(this._url,this._loadPolicy)}}}{const dg=self.C3,_g=new dg.PromiseThrottle,pg=new Set;dg.ImageAsset=class extends dg.Asset{constructor(e,t){super(e,t),this._texturePromise=null,this._webglTexture=null,this._refCount=0,this._imageWidth=-1,this._imageHeight=-1,this._isTiled=!!t.isTiled,pg.add(this)}Release(){if(0!==this._refCount)throw new Error("released image asset which still has texture references");this._assetManager._ReleaseImageAsset(this),this._texturePromise=null,pg.delete(this),super.Release()}static OnRendererContextLost(){for(const e of pg)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(e,t){try{const s=await this.GetBlob();return 0===this._refCount?(this._texturePromise=null,null):await _g.Add(async()=>{const i=await e.CreateStaticTextureAsync(s,t);return this._texturePromise=null,0===this._refCount?(e.DeleteTexture(i),null):(this._webglTexture=i,this._imageWidth=i.GetWidth(),this._imageHeight=i.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");this._refCount--,0===this._refCount&&this._webglTexture&&(this._webglTexture.GetRenderer().DeleteTexture(this._webglTexture),this._webglTexture=null)}GetRefCount(){return this._refCount}GetTexture(){return this._webglTexture}GetWidth(){return this._imageWidth}GetHeight(){return this._imageHeight}IsTiled(){return this._isTiled}async LoadToDrawable(){const e=await this.GetBlob();return dg.Supports.ImageBitmap?await createImageBitmap(e):await dg.BlobToImage(e)}}}{let gg=function(e,t){return e.GetWorldInfo()._GetLastCachedZIndex()-t.GetWorldInfo()._GetLastCachedZIndex()};SortByInstLastCachedZIndex=gg;const mg=self.C3,fg=self.assert;mg.RenderCell=class extends mg.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(){mg.clearArray(this._instances),this._pendingRemoval.clear(),this._grid=null}Reset(){mg.clearArray(this._instances),this._isSorted=!0,this._pendingRemoval.clear(),this._isAnyPendingRemoval=!1}SetChanged(){this._isSorted=!1}IsEmpty(){return!this._instances.length||!(this._instances.length>this._pendingRemoval.size)&&(this._FlushPending(),!0)}Insert(e){if(this._pendingRemoval.has(e))return this._pendingRemoval.delete(e),void(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,this._pendingRemoval.size>=50&&this._FlushPending()}_FlushPending(){this._isAnyPendingRemoval&&(this._instances.length!==this._pendingRemoval.size?(mg.arrayRemoveAllInSet(this._instances,this._pendingRemoval),this._pendingRemoval.clear(),this._isAnyPendingRemoval=!1):this.Reset())}_EnsureSorted(){this._isSorted||(this._instances.sort(gg),this._isSorted=!0)}Dump(e){this._FlushPending(),this._EnsureSorted(),this._instances.length&&e.push(this._instances)}}}{const Sg=self.C3;Sg.RenderGrid=class extends Sg.DefendedBase{constructor(e,t){super(),this._cellWidth=e,this._cellHeight=t,this._cells=Sg.New(Sg.PairMap)}Release(){this._cells.Release(),this._cells=null}GetCell(e,t,s){let i=this._cells.Get(e,t);return i||(s?(i=Sg.New(Sg.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(e,t,s){if(t)for(let i=t.getLeft(),n=t.getRight();i<=n;++i)for(let n=t.getTop(),r=t.getBottom();n<=r;++n){if(s&&s.containsPoint(i,n))continue;const t=this.GetCell(i,n,!1);t&&(t.Remove(e),t.IsEmpty()&&this._cells.Delete(i,n))}if(s)for(let i=s.getLeft(),n=s.getRight();i<=n;++i)for(let n=s.getTop(),r=s.getBottom();n<=r;++n)t&&t.containsPoint(i,n)||this.GetCell(i,n,!0).Insert(e)}QueryRange(e,t){let s=this.XToCell(e.getLeft());const 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 i=this.GetCell(s,e,!1);i&&i.Dump(t)}}MarkRangeChanged(e){let t=e.getLeft();const s=e.getTop(),i=e.getRight(),n=e.getBottom();for(;t<=i;++t)for(let e=s;e<=n;++e){const s=this.GetCell(t,e,!1);s&&s.SetChanged()}}}}{let Gg=function(e,t){return e.GetWorldInfo()._GetLastCachedZIndex()-t.GetWorldInfo()._GetLastCachedZIndex()},yg=function(e,t){return e.GetWorldInfo().GetZElevation()-t.GetWorldInfo().GetZElevation()};SortByInstLastCachedZIndex=Gg,SortByInstZElevation=yg;const Ig=self.C3,Tg=self.assert,Cg=new Ig.Rect,bg=new Ig.Quad,wg=[],Pg=new Ig.Rect,xg=new Ig.Rect,vg=self.glMatrix,Ag=vg.vec3,Rg=vg.vec4,Mg=vg.mat4,Dg=Mg.create(),Eg=Ag.create(),Fg=Rg.create(),Og=Ag.create(),Bg=Ag.create(),Lg=Ag.create(),kg=Ig.New(Ig.Vector2),Ng=Ig.New(Ig.Rect),Wg=[],Vg=[],Ug=[],jg={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:[]},Hg=new Map,zg=e=>{if(!e.instance.GetObjectClass().IsGlobal())return;const t=e.instance.GetUID();Hg.has(t)&&(Hg.delete(t),Hg.size||e.instance.GetRuntime().Dispatcher().removeEventListener("instancedestroy",zg))};Ig.Layer=class extends Ig.DefendedBase{constructor(e,t,s){super(),s=Object.assign({},jg,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=Ig.New(Ig.Color),this._backgroundColor.setFromJSON(s.backgroundColor),this._isTransparent=!!s.isTransparent,this._parallaxX=s.parallax[0],this._parallaxY=s.parallax[1],this._color=Ig.New(Ig.Color,1,1,1,s.opacity),this._premultipliedColor=Ig.New(Ig.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=Ig.New(Ig.Rect),this._viewportZ0=Ig.New(Ig.Rect),this._viewport3D=Ig.New(Ig.Rect),this._isViewportChanged=!0,this._projectionMatrix=Mg.create(),this._isProjectionMatrixChanged=!0,this._modelViewMatrix=Mg.create(),this._isMVMatrixChanged=!0,this._viewFrustum=Ig.New(Ig.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 i=this._runtime.GetCanvasManager();this._effectList=Ig.New(Ig.EffectList,this,s.effectListData),this._effectChain=Ig.New(Ig.Gfx.EffectChain,i.GetEffectChainManager(),{drawContent:(e,t)=>{const s=t.GetContentObject(),n=s.GetRenderTarget();e.SetColor(s.GetPremultipliedColor()),e.DrawRenderTarget(n),e.InvalidateRenderTarget(n),i.ReleaseAdditionalRenderTarget(n)},getShaderParameters:e=>this.GetEffectList()._GetEffectChainShaderParametersForIndex(e)}),this._needsRebuildEffectChainSteps=!0,this._wasDefaultColor=!0,this._renderGrid=null,this._lastRenderList=[],this._isRenderListUpToDate=!1,this._lastRenderCells=Ig.New(Ig.Rect,0,0,-1,-1),this._curRenderCells=Ig.New(Ig.Rect,0,0,-1,-1),this._iLayer=new self.ILayer(this),this._userScriptDispatcher=Ig.New(Ig.Event.Dispatcher),this._UpdatePremultipliedColor(),this.UsesRenderCells()&&(this._renderGrid=Ig.New(Ig.RenderGrid,this._runtime.GetOriginalViewportWidth(),this._runtime.GetOriginalViewportHeight())),this._subLayers=s.subLayersData.map(e=>Ig.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)}Ig.shallowAssignArray(this._startupInitialInstances,this._initialInstances),this._initialInstancesData=null}static CreateFromExportData(e,t,s){return Ig.New(Ig.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();Ig.clearArray(this._subLayers);for(const e of this._instances)this._runtime.DestroyInstance(e);Ig.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}WasReleased(){return!this._layout}GetInitialInstanceData(e){return this._initialUIDsToInstanceData.get(e)}CreateInitialInstances(e){const t=this._layout.IsFirstVisit(),s=this._initialInstances;let i=0;for(let n=0,r=s.length;n=0&&e.add(s)}let t=-1;for(const s of this._instances){const i=s.GetWorldInfo();if(!(i._GetLastCachedZIndex()>=0)){for(++t;e.has(t);)++t;i._SetZIndex(t)}}}this._instances.sort(Gg)}_Start(){}_End(){for(const e of this._instances)e.GetObjectClass().IsGlobal()||this._runtime.DestroyInstance(e);this._runtime.FlushPendingInstances(),Ig.clearArray(this._instances),this._anyInstanceZElevated=!1,this.SetZIndicesChanged()}RecreateInitialObjects(e,t,s,i,n,r){const a=this._runtime.GetEventSheetManager(),o=this._runtime.GetAllObjectClasses(),h=e.IsFamily(),l=[];for(const c of this._initialInstances){const u=c[0],d=u[0],_=u[1];if(!t.containsPoint(d,_))continue;const p=o[c[1]];if(p!==e){if(!h)continue;if(!e.FamilyHasMember(p))continue}let g=n;if(!g){const e=this._runtime.GetCurrentLayout();this.GetLayout()===e?g=this:(g=e.GetLayerByName(this.GetName()),g||(g=e.GetLayerByIndex(this.GetIndex())))}const m=this._runtime.CreateInstanceFromData(c,g,!1,void 0,void 0,!1,r,void 0,r);r&&g.SortAndAddInstancesByZIndex(m);const f=m.GetWorldInfo();f.OffsetXY(s,i),f.SetBboxChanged(),a.BlockFlushingInstances(!0),m._TriggerOnCreatedOnSelfAndRelated(),a.BlockFlushingInstances(!1),l.push(m)}return l}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){e=!!e,this._isHTMLElementsLayer!==e&&(this._isHTMLElementsLayer=e,this._layout._ReindexAndUpdateAllLayers(),this._runtime.UpdateRender())}_GetSiblingIndex(){let e=-1;const t=this.GetParentLayer();return e=t?t.GetSubLayers().indexOf(this):this.GetLayout()._GetRootLayers().indexOf(this),e}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())return;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){e=!!e,this._isVisible!==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(e=!!e,this._hasOwnScrollPosition!==e){if(this._hasOwnScrollPosition=e,e){const e=this.GetLayout();this._scrollX=e.GetScrollX(),this._scrollY=e.GetScrollY()}this._SetMVMatrixChanged(),this._runtime.UpdateRender()}}IsOwnScrollPositionEnabled(){return this._hasOwnScrollPosition}SetScrollX(e){const t=this.GetLayout(),s=t.GetScrollLeftBound(),i=t.GetScrollRightBound();e>i&&(e=i),ei&&(e=i),e0}_GetInstances(){return this._instances}_GetInstancesInDrawOrder(){return this.RendersIn3DMode()&&this._useCameraDistanceDrawOrder?(Ig.shallowAssignArray(Ug,this._GetInstances()),Ug.sort((e,t)=>this._SortInstancesByCameraDistance(e,t)),Ug):this._GetInstances()}_AppendAllInstancesIncludingSubLayersInDrawOrder(e){Ig.appendArray(e,this._GetInstancesInDrawOrder());for(const t of this._subLayers)t.IsVisible()&&t.GetOpacity()>0&&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(),h=a.GetX()-i,l=a.GetY()-n,c=a.GetZElevation()-r,u=o.GetX()-i,d=o.GetY()-n,_=o.GetZElevation()-r;return u*u+d*d+_*_-(h*h+l*l+c*c)}GetBackgroundColor(){return this._backgroundColor}IsTransparent(){return this._isTransparent}SetTransparent(e){e=!!e,this._isTransparent!==e&&(this._isTransparent=e,this._runtime.UpdateRender())}IsForceOwnTexture(){return this._isForceOwnTexture}SetForceOwnTexture(e){e=!!e,this._isForceOwnTexture!==e&&(this._isForceOwnTexture=e,this._runtime.UpdateRender())}SetRenderAs3D(e){e=!!e,this._renderAs3d!==e&&(this._renderAs3d=e,this._SetMVMatrixChanged(),this._runtime.UpdateRender())}IsRenderAs3D(){return this._renderAs3d}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 this._subLayers.length>0}_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){0!==e.size&&Ig.arrayRemoveAllInSet(this._instances,e)>0&&(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(yg),this.UsesRenderCells())for(let e=0,t=this._instances.length;e[...e.selfAndAllSubLayers()]).flat();let t=0;for(const s of e){for(const e of s._GetInstances())e.GetObjectClass().GetPlugin().IsHTMLElementType()&&e.GetWorldInfo()._SetHTMLZIndex(t++);s._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");const r=i.GetZIndex();let a=n.GetZIndex();return r!==a+(s?1:-1)&&(Ig.arrayRemove(this._instances,r),r1;)e=this._MergeAllSortedZArrays_pass(e);return e[0]}_GetRenderCellInstancesToDraw(){return this._UpdateZIndices(),Ig.clearArray(wg),this._renderGrid.QueryRange(this.GetViewport(),wg),wg.length?1===wg.length?wg[0]:this._MergeAllSortedZArrays(wg):[]}ShouldDraw(){return this.IsVisible()&&this.GetOpacity()>0&&this._DrawsAnyContentInSelfOrSubLayers()}_DrawsAnyContentInSelfOrSubLayers(){if(this.HasInstances()||!this.IsTransparent()||this._userScriptDispatcher.HasAnyHandlerFor("beforedraw")||this._userScriptDispatcher.HasAnyHandlerFor("afterdraw"))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();return this.GetDefaultCameraZ()/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,s=0){const i=this._runtime,n=this.GetLayout(),r=i.GetParallaxXOrigin(),a=i.GetParallaxYOrigin();let o=(this.GetScrollX()-r)*this._parallaxX+r,h=(this.GetScrollY()-a)*this._parallaxY+a;i.IsPixelRoundingEnabled()&&(o=Math.round(o),h=Math.round(h));let l=o+e,c=h+t;const u=n.IsOrthographicProjection()?this.GetDefaultCameraZ(s):this.Get2DCameraZ(s),[d,_]=this._GetVanishingPoint();if(.5!==d||.5!==_){const e=this.GetDefaultCameraZ(s)/u;let t=(d-.5)*i.GetViewportWidth()/e,n=(_-.5)*i.GetViewportHeight()/e;const r=this.GetAngle();0!==r&&(kg.set(t,n),kg.rotate(r),t=kg.getX(),n=kg.getY()),l+=t,c+=n}return[l,c,u]}_CalculateModelViewMatrix(e,t,s,i,n){const r=this._runtime,a=this.GetLayout();if(this.Has3DCamera()){Ag.copy(Og,a.Get3DCameraPosition()),Ag.copy(Bg,a.Get3DCameraLookAt()),Ag.copy(Lg,a.Get3DCameraUpVector());const e=r.GetParallaxXOrigin(),t=r.GetParallaxYOrigin(),s=Bg[0]-Og[0],i=Bg[1]-Og[1],n=Bg[2]-Og[2];Og[0]=(Og[0]-e)*this._parallaxX+e,Og[1]=(Og[1]-t)*this._parallaxY+t,Og[2]*=Math.max(this._parallaxX,this._parallaxY),Bg[0]=Og[0]+s,Bg[1]=Og[1]+i,Bg[2]=Og[2]+n}else{const[e,t,r]=this._Get2DCameraPosition(s,i,n);Ag.set(Og,e,t,r),Ag.set(Bg,e,t,r-100);const a=this.GetAngle();0===a?Ag.set(Lg,0,1,0):Ag.set(Lg,Math.sin(a),Math.cos(a),0)}e.CalculateLookAtModelView(t,Og,Bg,Lg,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)Mg.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=null;0===s&&0===i&&0===n?r=this._GetModelViewMatrix(e):(this._CalculateModelViewMatrix(e,Dg,s,i,n),r=Dg),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,t+1)}}_FireDrawEvent(e,t){if(this._userScriptDispatcher.HasAnyHandlerFor(t)){e.SetTextureFillMode(),e.SetTexture(null),e.SetAlphaBlend(),e.ResetCullState(),e.SetColorRgba(1,1,1,1),e.SetBaseZ(this.GetZElevation()),e.SetCurrentZ(0);const s=new Ig.Event(t);s.renderer=this._runtime.GetCanvasManager().GetIRenderer(),this.DispatchUserScriptEvent(s)}}Draw(e,t,s){const i=this._runtime.GetCanvasManager(),n=this.UsesOwnTexture();let r=null;const a=this._MaybeStartWebGLProfiling(e);if(this._MaybeStartWebGPUProfiling(e),n){const t={sampling:this._runtime.GetSampling(),isSampled:!0,canReadPixels:!!e.IsWebGPU()&&this._runtime.UsesAnyBackgroundBlending()};"low"===i.GetCurrentFullscreenScalingQuality()&&(t.width=i.GetDrawWidth(),t.height=i.GetDrawHeight()),r=this._runtime.GetAdditionalRenderTarget(t),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._FireDrawEvent(e,"beforedraw"),this.GetNormalScale()>Number.EPSILON){this._UpdateZIndices();const t=this.UsesRenderCells()&&0===this.GetZElevation()&&!this._anyInstanceZElevated;this.Has3DCamera()?this._DrawInstances_3DCamera(e):t?this._DrawInstances_RenderCells(e):this._DrawInstances(e,this._GetInstancesInDrawOrder())}this._FireDrawEvent(e,"afterdraw"),e.SetBaseZ(0),e.SetCurrentZ(0),n&&(e.SetDepthEnabled(!1),this._DrawLayerOwnTextureToRenderTarget(e,r,t,s)),a&&e.EndQuery(a),this._curRenderTarget=null}_DrawInstances(e,t){const s=this.GetViewport(),i=this._curRenderTarget,n=this.GetLayout().IsOrthographicProjection(),r=this.GetLayout().HasVanishingPointOutsideViewport();let a=null;for(let o=0,h=t.length;o0)&&n.push(h);const c=h.GetWorldInfo().GetTotalZElevation();i.push(h);let u=a+1;for(;u0&&n.push(e),i.push(e)):n.push(e)}}if(1!==i.length||i[0].MustMitigateZFighting()){this._DrawCoplanarInstances_3DCamera(e,i);for(let s=0,i=n.length;s0&&(this._IsPointBehindNearPlane(r,a,n)||this._IsPointBehindNearPlane(o,a,n)||this._IsPointBehindNearPlane(o,h,n)||this._IsPointBehindNearPlane(r,h,n)))return null}else if(n>=this.Get2DCameraZ())return null;let[l,c]=this.LayerToDrawSurface(r,a,s),[u,d]=this.LayerToDrawSurface(o,h,s);if(0!==this.GetAngle()||i>0||this.Has3DCamera()){const[e,t]=this.LayerToDrawSurface(o,a,s),[_,p]=this.LayerToDrawSurface(r,h,s);if(i>0){const[s,i]=this.LayerToDrawSurface(r,a,n),[g,m]=this.LayerToDrawSurface(o,a,n),[f,S]=this.LayerToDrawSurface(o,h,n),[G,y]=this.LayerToDrawSurface(r,h,n);let I=Math.min(l,u,e,_,s,g,f,G);u=Math.max(l,u,e,_,s,g,f,G),l=I,I=Math.min(c,d,t,p,i,m,S,y),d=Math.max(c,d,t,p,i,m,S,y),c=I}else{let s=Math.min(l,u,e,_);u=Math.max(l,u,e,_),l=s,s=Math.min(c,d,t,p),d=Math.max(c,d,t,p),c=s}}return Cg.set(l,c,u,d),Cg}_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(){return{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}}_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,Ig.shallowAssignArray(this._createdGlobalUids,e.cg),Ig.shallowAssignArray(this._initialInstances,this._startupInitialInstances);const t=new Set(this._createdGlobalUids);let s=0;for(let e=0,i=this._initialInstances.length;e(e.GetWorldInfo().GetSceneGraphZIndex()??0)-(t.GetWorldInfo().GetSceneGraphZIndex()??0)),void(s&&this._instances.forEach((e,t)=>e.GetWorldInfo()._SetZIndex(t)));if(e.HasChildren()){const t=[...e.allChildren()];t.push(e),t.sort((e,t)=>(e.GetWorldInfo().GetSceneGraphZIndex()??0)-(t.GetWorldInfo().GetSceneGraphZIndex()??0));for(const e of t)if(e.IsInContainer())for(const s of e.siblings()){if(t.includes(s))continue;const e=[...s.allChildren()];e.push(s),e.sort((e,t)=>(e.GetWorldInfo().GetSceneGraphZIndex()??0)-(t.GetWorldInfo().GetSceneGraphZIndex()??0)),e&&e.length&&t.splice(t.length,0,...e)}for(const e of t)e.GetPlugin().IsWorldType()&&this._AddInstance(e,!0);s&&this._instances.forEach((e,t)=>e.GetWorldInfo()._SetZIndex(t))}else{if(e.GetPlugin().IsWorldType()&&this._AddInstance(e,!0),!e.IsInContainer())return void(s&&this._instances.forEach((e,t)=>e.GetWorldInfo()._SetZIndex(t)));for(const t of e.siblings()){const e=[...t.allChildren()];if(e.push(t),e.sort((e,t)=>(e.GetWorldInfo().GetSceneGraphZIndex()??0)-(t.GetWorldInfo().GetSceneGraphZIndex()??0)),e&&e.length)for(const t of e)t.GetPlugin().IsWorldType()&&this._AddInstance(t,!0)}s&&this._instances.forEach((e,t)=>e.GetWorldInfo()._SetZIndex(t))}}}}{let Xg=function(e,t,s,i){return e[0]===Math.fround(t)&&e[1]===Math.fround(s)&&e[2]===Math.fround(i)},Yg=function(e,t){om!==e&&(e.PrepareForDraw(t),om=e)};vec3EqualsXYZ=Xg,MaybePrepareLayerDraw=Yg;const qg=self.C3,Kg=self.C3Debugger,$g=self.assert,Jg=qg.New(qg.Rect),Zg=qg.New(qg.Rect),Qg=qg.New(qg.Rect),em=qg.New(qg.Color),tm=self.glMatrix,sm=tm.vec3,im=[],nm=[],rm=[],am=[];let om=null;qg.Layout=class extends qg.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=sm.create(),this._cam3dlook=sm.create(),this._cam3dup=sm.create(),this._rootLayers=[],this._allLayersFlat=[],this._layersByName=new Map,this._layersBySid=new Map,this._pendingSetHTMLLayerCount=-1;const i=this._runtime.GetCanvasManager();this._effectList=qg.New(qg.EffectList,this,s[11]),this._effectChain=qg.New(qg.Gfx.EffectChain,i.GetEffectChainManager(),{drawContent:(e,t)=>{const s=t.GetContentObject().GetRenderTarget();e.ResetColor(),e.DrawRenderTarget(s),e.InvalidateRenderTarget(s),i.ReleaseAdditionalRenderTarget(s)},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=qg.New(qg.Event.Dispatcher);for(const e of s[9])this._rootLayers.push(qg.Layer.CreateFromExportData(this,null,e));this._ReindexLayers();for(const e of this.allLayers())e._InitInitialInstances();for(const e of s[10]){const t=this._runtime.GetObjectClassByIndex(e[1]);if(!t)throw new Error("missing nonworld object class");t.GetDefaultInstanceData()||t.SetDefaultInstanceData(e),this._initialNonWorld.push(e),this._AddInitialObjectClass(t)}}Release(){for(const e of this._allLayersFlat)e.Release();qg.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())return;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 e=this._allLayersFlat[0].GetNormalScale();for(let t=1,s=this._allLayersFlat.length;ts&&(e=s),es&&(e=s),e1||t<0||t>1}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){e=!!e,this._is3dCameraEnabled!==e&&(this._is3dCameraEnabled=e,this._SetAllLayersMVChanged(),this._runtime.UpdateRender())}Is3DCameraEnabled(){return this._is3dCameraEnabled}Set3DCameraOrientation(e,t,s,i,n,r,a,o,h){Xg(this._cam3dposition,e,t,s)&&Xg(this._cam3dlook,i,n,r)&&Xg(this._cam3dup,a,o,h)||(sm.set(this._cam3dposition,e,t,s),sm.set(this._cam3dlook,i,n,r),sm.set(this._cam3dup,a,o,h),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=qg.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=qg.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=s>=2?t:t.GetParentLayer(),n=qg.New(qg.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)return;const t=this._runtime.GetEventSheetManager();t.BlockFlushingInstances(!0);for(const t of e)this._RemoveLayer(t),t.Release();t.BlockFlushingInstances(!1),this.GetRuntime().UpdateRender(),this._ReindexAndUpdateAllLayers()}_InsertLayer(e,t,s){if(s>=2)if(t){if(t===e||t.HasParentLayer(e))throw new Error(`cannot move layer '${e.GetName()}' to sub-layer of itself`);t._AddSubLayer(e,2===s),e._SetParentLayer(t)}else 2===s?this._rootLayers.push(e):this._rootLayers.unshift(e),e._SetParentLayer(null);else{const i=t.GetParentLayer();if(i){if(t.HasParentLayer(e))throw new Error(`cannot move layer '${e.GetName()}' to sub-layer of itself`);i._InsertSubLayer(e,t,0===s),e._SetParentLayer(i)}else{let i=this._rootLayers.indexOf(t);if(-1===i)throw new Error("cannot find layer to insert by");0===s&&++i,this._rootLayers.splice(i,0,e),e._SetParentLayer(null)}}}_RemoveLayer(e){const t=e.GetParentLayer();if(t)return t._RemoveSubLayer(e),!0;if(this._rootLayers.length>1){const t=this._rootLayers.indexOf(e);if(-1===t)throw new Error("cannot find layer to remove");return this._rootLayers.splice(t,1),!0}return!1}_ReindexLayers(){this._allLayersFlat=[...this.allLayers()],this._layersByName.clear(),this._layersBySid.clear();for(let e=0,t=this._allLayersFlat.length;ee)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 em.copyRgb(e.GetBackgroundColor()),em.setA(1),em;if(e.UsesOwnTexture())return em.setRgba(0,0,0,0),em;e=e.GetSubLayers().filter(e=>e.ShouldDraw())[0]}return em.setRgba(0,0,0,0),em}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&&(qg.CopySet(this._textureLoadedTypes,e._textureLoadedTypes),e._textureLoadedTypes.clear());const s=[];for(const e of this._initialObjectClasses)this._textureLoadedTypes.has(e)||(s.push(e.LoadTextures(t)),this._textureLoadedTypes.add(e));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))return;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()||e.GetInstanceCount()>0)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 t of this._textureLoadedTypes)t.IsGlobal()||e._initialObjectClasses.has(t)||(t.ReleaseTextures(),this._textureLoadedTypes.delete(t))}_OnRendererContextLost(){this._textureLoadedTypes.clear()}async _StartRunning(e){const t=this._runtime,s=this._layoutManager,i=t.GetEventSheetManager();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);const n=this._runtime.GetCreatePromises();if(await Promise.all(n),qg.clearArray(n),!t.IsLoadingState()){for(const e of this._createdInstances)e.SetupInitialSceneGraphConnections();for(const e of this._createdPersistedInstances)e.SetupPersistedSceneGraphConnections(this._createdPersistedInstancesToDataMap,this._createdPersistedIndexToInstanceMap);for(const[e,t]of Object.entries(this._persistData)){const s=this._runtime.GetObjectClassBySID(parseInt(e,10));s&&!s.IsFamily()&&s.HasPersistBehavior()&&qg.clearArray(t)}for(const e of this._createdInstances)e._TriggerOnCreated();for(const e of this._createdPersistedInstances)e._TriggerOnCreated();for(const e of this._createdInstances)e.HasParent()||e._OnHierarchyReady();for(const e of this._createdPersistedInstances)e.HasParent()||e._OnHierarchyReady()}qg.clearArray(this._createdInstances),qg.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 qg.Event("beforefirstlayoutstart")),await t.DispatchUserScriptEventAsyncWait(new qg.Event("beforeprojectstart"))),await this.DispatchRuntimeUserScriptEventAsyncWait(new qg.Event("beforeanylayoutstart")),t.Dispatcher().dispatchEvent(new qg.Event("beforelayoutstart")),await this.DispatchUserScriptEventAsyncWait(new qg.Event("beforelayoutstart")),t.IsLoadingState()||await t.TriggerAsync(qg.Plugins.System.Cnds.OnLayoutStart,null,null),t.Dispatcher().dispatchEvent(new qg.Event("afterlayoutstart")),await this.DispatchUserScriptEventAsyncWait(new qg.Event("afterlayoutstart")),await this.DispatchRuntimeUserScriptEventAsyncWait(new qg.Event("afteranylayoutstart")),e&&(t.Dispatcher().dispatchEvent(new qg.Event("afterfirstlayoutstart")),await t.DispatchUserScriptEventAsyncWait(new qg.Event("afterprojectstart"))),i._RunQueuedTriggers(s),await this.WaitForPendingTextureLoadsToComplete(),this._isFirstVisit=!1}_MoveGlobalObjectsToThisLayout(e){for(const e of this._runtime.GetAllObjectClasses())if(!e.IsFamily()&&e.IsWorldType())for(const t of e.GetInstances()){const e=t.GetWorldInfo(),s=e.GetLayer(),i=qg.clamp(s.GetIndex(),0,this._allLayersFlat.length-1),n=this._allLayersFlat[i];e._SetLayer(n,!0),n._MaybeAddInstance(t)}if(!e)for(const e of this._allLayersFlat)e._SortInstancesByLastCachedZIndex(!1)}_CreateInitialInstances(){for(const e of this._allLayersFlat)e.CreateInitialInstances(this._createdInstances),e._Start()}_CreatePersistedInstances(){let e=!1;for(const[t,s]of Object.entries(this._persistData)){const i=this._runtime.GetObjectClassBySID(parseInt(t,10));if(i&&!i.IsFamily()&&i.HasPersistBehavior())for(const t of s){let s=null;if(i.IsWorldType()&&(s=t.hasOwnProperty("instJson")?this.GetLayerBySID(t.instJson.w.l):this.GetLayerBySID(t.w.l),!s))continue;const n=this._runtime.CreateInstanceFromData(i,s,!1,0,0,!0);t.hasOwnProperty("instJson")?n.LoadFromJson(t.instJson):n.LoadFromJson(t),e=!0,this._createdPersistedInstances.push(n),t.hasOwnProperty("instJson")&&(this._createdPersistedInstancesToDataMap.set(n,t),this._createdPersistedIndexToInstanceMap.set(t.index,n))}}for(const e of this._allLayersFlat)e._SortInstancesByLastCachedZIndex(!0),e.SetZIndicesChanged();e&&(this._runtime.FlushPendingInstances(),this._runtime._RefreshUidMap())}_CreateAndLinkContainerInstances(e){for(const t of e){if(!t.IsInContainer())continue;const s=t.GetWorldInfo(),i=t.GetIID();for(const n of t.GetObjectClass().GetContainer().objectTypes()){if(n===t.GetObjectClass())continue;const r=n.GetInstances();if(r.length>i)t._AddSibling(r[i]);else{let i;i=s?this._runtime.CreateInstanceFromData(n,s.GetLayer(),!0,s.GetX(),s.GetY(),!0):this._runtime.CreateInstanceFromData(n,null,!0,0,0,!0),this._runtime.FlushPendingInstances(),n._UpdateIIDs(),t._AddSibling(i),e.push(i)}}}}_CreateInitialNonWorldInstances(){for(const e of this._initialNonWorld)this._runtime.GetObjectClassByIndex(e[1]).IsInContainer()||this._runtime.CreateInstanceFromData(e,null,!0)}_CreateGlobalNonWorlds(){const e=[],t=this._initialNonWorld;let s=0;for(let i=0,n=t.length;ie.ShouldDraw());for(let s=0,r=n.length;s=2||1===im.length&&im[0].HasAnyVisibleSubLayer()){this._Draw3DLayers(e,t,im),s+=im.length,qg.clearArray(im);continue}qg.clearArray(im)}a.Draw(e,t,i&&0===s),++s}}_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)):(Qg.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:Qg,drawSurfaceRect:null,invalidateRenderTargets:!0}))}_Draw3DLayers(e,t,s){const i=s[0],n=i._MaybeStartWebGLProfiling(e);i._MaybeStartWebGPUProfiling(e),s[0].IsTransparent()||(em.copyRgb(s[0].GetBackgroundColor()),em.setA(1),e.Clear(em)),e.SetDepthEnabled(!0);const r=nm,a=rm,o=am;for(const t of s)t._UpdateZIndices(),t._AppendAllInstancesIncludingSubLayersInDrawOrder(r),t._FireDrawEvent(e,"beforedraw");for(let s=0,i=r.length;s0)&&o.push(n);const c=n.GetWorldInfo().GetTotalZElevation();a.push(n);let u=s+1;for(;u0&&o.push(e),a.push(e)):o.push(e)}}if(1!==a.length||a[0].MustMitigateZFighting()){this._Draw3DLayersCoplanarInstances(e,t,a);for(let s=0,i=o.length;s=0;--e){const i=s[e],n=i.sid,r=i.name,a=i.parentSid,o=i.siblingIndex,h=i.data;if(this._ReindexLayers(),this.HasLayerByName(r)||this.GetLayerBySID(n))continue;let l,c;if(null===a)l=null,c=this._rootLayers;else{if(l=this.GetLayerBySID(a),!l)continue;c=l.GetSubLayers()}const u=qg.New(qg.Layer,this,l,{name:r,sid:n,isDynamic:!0});c.push(u);let d=t.get(c);d||(d=[],t.set(c,d)),d.push({layer:u,siblingIndex:o}),u._LoadFromJson(h)}for(const[e,s]of t){s.sort((e,t)=>e.siblingIndex-t.siblingIndex);for(const t of s){const s=t.layer,i=t.siblingIndex;let n=e.indexOf(s);e.splice(n,1),e.splice(i,0,s)}}}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&&Kg.StartMeasuringScriptTime(),this._userScriptDispatcher.dispatchEvent(e),s&&Kg.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 e of s)console.log(`${"\t".repeat(t)}- ${e.GetName()}`),this._LogLayerList(e.GetSubLayers(),t+1)}}}{const hm=self.C3;hm.LayoutManager=class extends hm.DefendedBase{#t;#s=[];#d=new Map;#h=new Map;#i=null;#e=[];#r=null;#a=0;#_=null;constructor(e){super(),this.#t=e}Release(){this.#t=null,this.#i=null,this.#r=null,this.#_=null,hm.clearArray(this.#s),this.#d.clear(),this.#h.clear(),hm.clearArray(this.#e)}Create(e){const t=hm.New(hm.Layout,this,this.#s.length,e);this.#s.push(t),this.#d.set(t.GetName().toLowerCase(),t),this.#h.set(t.GetSID(),t)}GetRuntime(){return this.#t}SetFirstLayout(e){this.#r=e}GetFirstLayout(){if(this.#r)return this.#r;if(this.#s.length)return this.#s[0];throw new Error("no first layout")}GetLayoutByName(e){return this.#d.get(e.toLowerCase())||null}GetLayoutBySID(e){return this.#h.get(e)||null}GetLayoutByIndex(e){return e=hm.clamp(Math.floor(e),0,this.#s.length-1),this.#s[e]}GetLayout(e){return"number"==typeof e?this.GetLayoutByIndex(e):this.GetLayoutByName(e.toString())}GetAllLayouts(){return this.#s}_SetMainRunningLayout(e){this.#i=e}GetMainRunningLayout(){return this.#i}_AddRunningSubLayout(e){if(this.#e.includes(e))throw new Error("layout already running");this.#e.push(e)}_RemoveRunningSubLayout(e){const t=this.#e.indexOf(e);if(-1===t)throw new Error("layout not running");this.#e.splice(t,1)}*runningLayouts(){this.#i&&(yield this.#i),this.#e.length&&(yield*this.#e)}IsLayoutRunning(e){return this.#i===e||this.#e.includes(e)}SetIsEndingLayout(e){if(e)this.#a++;else{if(this.#a<=0)throw new Error("already unset");this.#a--}}IsEndingLayout(){return this.#a>0}ChangeMainLayout(e){this.#_=e}ClearPendingChangeLayout(){this.#_=null}IsPendingChangeMainLayout(){return!!this.#_}GetPendingChangeMainLayout(){return this.#_}SetAllLayerProjectionChanged(){const e=this.GetMainRunningLayout();e&&e._SetAllLayersProjectionChanged()}SetAllLayerMVChanged(){const e=this.GetMainRunningLayout();e&&e._SetAllLayersMVChanged()}}}{const lm=self.C3,cm=new RegExp("<(.+?)>","g");lm.TimelineManager=class extends lm.DefendedBase{constructor(e){super(),this._runtime=e,this._timelineDataManager=lm.New(lm.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();lm.clearArray(this._timelines),this._timelines=null,this._timelineDataManager.Release(),this._timelineDataManager=null,lm.clearArray(this._scheduledTimelines),this._scheduledTimelines=null,lm.clearArray(this._playingTimelines),this._playingTimelines=null,lm.clearArray(this._markedForRemovalTimelines),this._markedForRemovalTimelines=null,this._timelinesByName.clear(),this._timelinesByName=null,this._objectClassToTimelineMap.clear(),this._objectClassToTimelineMap=null,this._timelinesCreatedByTemplate.clear(),this._timelinesCreatedByTemplate=null,lm.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=lm.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=lm.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())continue;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()||(lm.arrayFindRemove(this._timelines,e),lm.arrayFindRemove(this._scheduledTimelines,e),lm.arrayFindRemove(this._playingTimelines,e),lm.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)if(t.every(e=>s.HasTrackInstance(e.instance,e.trackId))&&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 t of this._playingTimelines)if(t.GetName()===e)return t;return null}*GetTimelinesByName(e){if(cm.test(e)){let t;cm.lastIndex=0;const s=new Set;do{if(t=cm.exec(e),t){const e=t[1].split(",");for(const t of e)s.add(t)}}while(t);for(const e of s.values()){const t=this.GetTimelineByName(e);t&&(yield t)}s.clear()}else{const t=this.GetTimelineByName(e);t&&(yield t)}}*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){lm.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(),lm.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),lm.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),lm.arrayFindRemove(this._playingTimelines,e)}CompleteTimelineAndResolve(e){this.CompleteTimeline(e),e.ResolvePlayPromise()}_OnTick(){const e=this.GetRuntime();if(e.IsLoadingState())return;if(!this._hasRuntimeListeners)return;if(this._changingLayout)return;let t=0;for(e.IsDebug()&&(t=performance.now()),this._isTickingTimelines=!0;this._scheduledTimelines.length;){const e=this._scheduledTimelines.pop();e.IsMarkedForRemoval()?(e.SetInitialStateForce(),this._markedForRemovalTimelines.push(e)):(e.SetInitialState(),this._playingTimelines.push(e)),0!==e.GetRenderChange()&&(this._renderChange=1)}const s=this._runtime._GetDtFast(),i=this._runtime.GetDt1(),n=this._runtime.GetTimeScale();for(let e=this._playingTimelines.length-1;e>=0;e--){const t=this._playingTimelines[e];t&&t.Tick(s,n,i)}this._isTickingTimelines=!1,e.IsDebug()&&globalThis.C3Debugger.AddTweensAndTimelinesTime(performance.now()-t),0!==this._renderChange&&e.UpdateRender()}_OnTick2(){const e=this.GetRuntime();if(e.IsLoadingState())return;if(!this._hasRuntimeListeners)return;if(this._changingLayout)return;let t,s=0;e.IsDebug()&&(s=performance.now());for(let e=0,s=this._markedForRemovalTimelines.length;ee))this._MaybeExecuteTimelineFinishTriggers(e),this.Remove(e);for(const e of this._playingTimelines.map(e=>e))this._MaybeExecuteTimelineFinishTriggers(e),this.Remove(e)}_OnAfterLoad(){for(const e of this._destroyedWhileLoadingState)this._OnInstanceDestroy(e);lm.clearArray(this._destroyedWhileLoadingState);for(const e of this._timelines)e._OnAfterLoad()}_OnAfterLayoutStart(){const e=this._runtime.GetLayoutManager().GetMainRunningLayout();if(e)for(const t of this._timelines){const s=t.GetStartOnLayout();s&&e.GetName()===s&&this.ScheduleTimeline(t)}}_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),e._LoadFromJson(t)}e.HasTracks()||this.Remove(e)}}_GetTemplateNameFromJson(e){const t=e.name.split(":");return t&&2===t.length?t[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)return!1;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(lm.arrayRemoveAllInSet(t,s),e){const s=e=>t=>t.GetName()===e;for(const i of e){const e=this.GetTimelineByName(i);e&&(t.find(s(i))||t.push(e))}}}}}{const um=self.C3,dm=100,_m=.01,pm=25,gm=20,mm=5,fm=[0,0],Sm=[0,0],Gm=[0,0],ym=[0,0,0,0,0],Im=new Array(4),Tm=[{x:0,y:0,t:0,distance:0},{x:0,y:0,t:0,distance:0},{x:0,y:0,t:0,distance:0}],Cm={x:0,y:0,t:0,distance:0};um.TimelineInfo=class{constructor(e,t){this._initialized=!1,this._timeline=e,this._segments=[];let s=null;if(s=t?this._timeline.GetTrackById(t):um.first(this._timeline.GetTracks()),!s)return;const i=s.GetPropertyTrack("offsetX"),n=s.GetPropertyTrack("offsetY");if(!i||!n)return;this._xTrack=i,this._yTrack=n;const r=i.GetPropertyKeyframeDataItemArrayIncludingDisabled(),a=n.GetPropertyKeyframeDataItemArrayIncludingDisabled();for(let e=1,t=Math.min(r.length,a.length);et&&n--;const r=this._arcLengths[n];return r===t?n/this._len:(n+(t-r)/(this._arcLengths[n+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(e){if(e=e||100,this._lut.length>=e)return this._lut;this._lut=new Array(e),e++;for(let t=0;t=s.length);i++){const a=s[i],o=a.x-e,h=a.y-t;a.distance=o*o+h*h,a.distancethis._lutIndex-5&&!(i<0);i--){const a=s[i],o=a.x-e,h=a.y-t;a.distance=o*o+h*h,a.distance=i[0]&&o.t<=i[1]&&o.distance=s.length);a++){const o=s[a],h=o.x-e,l=o.y-t;o.distance=h*h+l*l,o.t>=i[0]&&o.t<=i[1]&&o.distancethis._lutIndex-5&&!(a<0);a--){const o=s[a],h=o.x-e,l=o.y-t;o.distance=h*h+l*l,o.t>=i[0]&&o.t<=i[1]&&o.distance0}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=bm.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=bm.TimelineState._GetTagArray(e);return!!t&&!!t.length&&t.every(bm.TimelineState._HasTag,this)}OnStarted(){bm.Plugins.Timeline&&this.constructor===bm.TimelineState&&(bm.Plugins.Timeline.Cnds.PushTriggerTimeline(this),this._timelineManager.Trigger(bm.Plugins.Timeline.Cnds.OnTimelineStarted),this._timelineManager.Trigger(bm.Plugins.Timeline.Cnds.OnTimelineStartedByName),this._timelineManager.Trigger(bm.Plugins.Timeline.Cnds.OnTimelineStartedByTags),this._timelineManager.Trigger(bm.Plugins.Timeline.Cnds.OnAnyTimelineStarted),bm.Plugins.Timeline.Cnds.PopTriggerTimeline())}OnCompleted(){this._completedTick=this._runtime.GetTickCount()}FinishTriggers(){this._finishedTriggers||(this._finishedTriggers=!0,bm.Plugins.Timeline&&this.constructor===bm.TimelineState&&(bm.Plugins.Timeline.Cnds.PushTriggerTimeline(this),this._timelineManager.Trigger(bm.Plugins.Timeline.Cnds.OnTimelineFinished),this._timelineManager.Trigger(bm.Plugins.Timeline.Cnds.OnTimelineFinishedByName),this._timelineManager.Trigger(bm.Plugins.Timeline.Cnds.OnTimelineFinishedByTags),this._timelineManager.Trigger(bm.Plugins.Timeline.Cnds.OnAnyTimelineFinished),bm.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.GetLoop(),s=this.GetPingPong();if(t||s){if(t&&!s);else if(!t&&s){const e=this.GetTime();1===this._pingPongState&&(e<=0||e>=this.GetTotalTime())&&(this._complete=!0)}}else{const e=this.GetTime();(e<=0||e>=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){bm.IsFiniteNumber(e)||(e=this.GetTotalTime()),e<0?this._playheadTime=0:e>=this.GetTotalTime()?this._playheadTime=this.GetTotalTime():this._playheadTime=e}_SetTimeAndReset(e){bm.IsFiniteNumber(e)||(e=this.GetTotalTime()),e<0?this._playheadTime=0:e>=this.GetTotalTime()?this._playheadTime=this.GetTotalTime():this._playheadTime=e;for(const e of this._tracks)e.SetResetState()}_OnSetTime(){bm.Plugins.Timeline&&this.constructor===bm.TimelineState&&(bm.Plugins.Timeline.Cnds.PushTriggerTimeline(this),this._timelineManager.Trigger(bm.Plugins.Timeline.Cnds.OnTimeSet),this._timelineManager.Trigger(bm.Plugins.Timeline.Cnds.OnTimeSetByName),this._timelineManager.Trigger(bm.Plugins.Timeline.Cnds.OnTimeSetByTags),bm.Plugins.Timeline.Cnds.PopTriggerTimeline())}_CanResume(){if(this.GetLoop())return!0;if(this.GetPingPong()&&1===this._pingPongState){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())return;if(!this._IsPlaying()&&this.IsScheduled())return this._timelineManager.DeScheduleTimeline(this);if(this.IsComplete())return;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(){return!!this.IsReleased()||!(!this.GetRuntime().IsLoadingState()&&this.HasValidGlobalTracks())&&(this._timelineManager.CompleteTimelineBeforeChangeOfLayout(this),this.GetRuntime().IsLoadingState()||this.ResetBeforeChangeLayout(),!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 e of this._tracks)e.SetInitialState();this._SetUpdateStateAfter()}else if(this.SetPlaying(!0),this.SetScheduled(!1),this.OnStarted(),this.IsComplete()){this._completedTick=-1,0!==this._pingPongState&&(this._playbackRate=Math.abs(this._playbackRate)),this._pingPongState=0,this._resumePingPongState=-1,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 e of this._tracks)e.SetInitialState();this._SetUpdateStateAfter()}else{-1!==this._resumePingPongState&&(this._pingPongState=this._resumePingPongState),this._firstTick=!0,this._finishedTriggers=!1,this._SetUpdateStateBefore();for(const e of this._tracks)e.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;this._lastDelta=s,e=s,t=1}const i=this._playheadTime+this._overshoot,n=i+e*t*this._playbackRate,r=this._timelineDataItem._totalTime;n<0?(this._playheadTime=0,this._overshoot=-n):n>=r?(this._playheadTime=r,this._overshoot=this._playheadTime-n):(this._playheadTime=n,this._overshoot=0);let a=!1,o=!1;const h=this.GetLoop(),l=this.GetPingPong();let c;h||l?h&&!l?this._playbackRate>0?this._playheadTime>=r&&(this._SetTimeAndReset(0),o=!0):this._playheadTime<=0&&(this._SetTimeAndReset(r),o=!0):!h&&l?this._playbackRate>0?this._playheadTime>=r&&(this._SetTime(r),this.SetPlaybackRate(-1*this.GetPlaybackRate()),o=!0,1===this._pingPongState?this._currentRepeatCount0?this._playheadTime>=r&&(this._SetTime(r),this.SetPlaybackRate(-1*this.GetPlaybackRate()),o=!0,this._pingPongState++,bm.wrap(this._pingPongState,0,2)):this._playheadTime<=0&&(this._SetTime(0),this.SetPlaybackRate(-1*this.GetPlaybackRate()),o=!0,this._pingPongState++,bm.wrap(this._pingPongState,0,2))):this._playbackRate>0?this._playheadTime>=r&&(this._currentRepeatCount0?(this._playheadTime=t<0?0:t>=r?r:t,e.Interpolate(t,!0,!1,o,this._firstTick,!1)):e.Interpolate(this._playheadTime,!0,!1,o,this._firstTick,!1)}else for(c=0;c0&&(o=r.GetStartOffset(),this._SetTime(o))}r.Interpolate(o,t,s,i,this._firstTick,a)}for(const e of this._tracks)e.AfterInterpolate();this._firstTick&&r&&(this._firstTick=!1)}AddTrack(){const e=this._timelineDataItem.GetTrackData().AddEmptyTrackDataItem(),t=bm.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&&s>=0){const e=this._tracks[s];if(!e)return;return e.SetInstance(t),void this._timelineManager.SetTimelineObjectClassToMap(t.GetObjectClass(),this)}for(const s of this._tracks)if(s.IsInstanceTrack()){if(e){if(s.GetId()!==e)continue;s.SetInstance(t),this._timelineManager.SetTimelineObjectClassToMap(t.GetObjectClass(),this);break}if(!s.HasInstance()){s.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(" "):[];const s=new Set(t.map(e=>e.toLowerCase().trim()));t=[...s.values()];for(const e of this.GetTracks())for(const s of e.GetKeyframeDataItems())if(t.every(e=>s.HasTag(e)))return s}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,resumePingPongState:this._resumePingPongState,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._resumePingPongState=e.hasOwnProperty("resumePingPongState")?e.resumePingPongState:-1,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)=>{this._tracks[t]._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(bm.IsArray(e))return e.slice(0);if(bm.IsString(e))return e.split(" ");throw new Error("invalid tags")}GetITimelineState(){return this._iTimelineState||(this._iTimelineState=bm.New(self.ITimelineState,this)),this._iTimelineState}}}{const xm=self.C3,vm=0,Am=1,Rm=2;xm.TrackState=class extends xm.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=t.GetStartOffset()>0,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 xm.New(xm.TrackState,e,t)}Release(){this._keyframeDataItems=null;for(const e of this._propertyTracks)e.Release();xm.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(xm.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(e){for(let t=0;te.GetNeedsBeforeAndAfter())&&(this._needsBeforeAndAfter=1),this._lastKeyframeDataItem=e?this._GetLastKeyFrameBeforeTime(t):this._GetFirstKeyFrameAfterTime(t),this._initialStateOfNestedSet=!1,this._endStateOfNestedSet=!1,this.Interpolate(t),this.OnInitialKeyframeReached(this._lastKeyframeDataItem)}SetResumeState(){if(this.MaybeGetInstance(),!this.IsInstanceValid()&&this.IsInstanceTrack())return;const e=this._timeline.IsForwardPlayBack(),t=this._timeline.GetTime()-this.GetStartOffset();this._lastKeyframeDataItem=e?this._GetLastKeyFrameBeforeTime(t):this._GetFirstKeyFrameAfterTime(t);for(const e of this._propertyTracks)e.SetResumeState(t)}SetEndState(){if(!this.GetTimeline().IsComplete()&&(this.MaybeGetInstance(),(this.IsInstanceValid()||!this.IsInstanceTrack())&&!this._isNested)){const e=this._timeline.GetTime();e>=this.GetStartOffset()+this.GetLocalTotalTime()?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;ethis.GetLocalTotalTime())return;for(const e of this._propertyTracks)e.SetInitialState();this._initialStateOfNestedSet=!0}}MaybeSetEndStateOfNestedTrack(e,t){if(t&&this._isNested&&!this._endStateOfNestedSet)if(this.GetTimeline().IsForwardPlayBack()){if(e>=this.GetLocalTotalTime()){for(const e of this._propertyTracks)e.Interpolate(this.GetLocalTotalTime(),!1,!0);this._endStateOfNestedSet=!0}}else if(e<=0){for(const e of this._propertyTracks)e.Interpolate(0,!1,!0);this._endStateOfNestedSet=!0}}MaybeTriggerKeyframeReachedConditions(e,t,s){if(s)return;if(!t)return;if(!xm.Plugins.Timeline)return;const i=this.GetTimeline();if(i.IsForwardPlayBack()){const t=this._lastKeyframeDataItem.GetNext(),s=this._lastKeyframeDataItem.GetTime(),n=t?t.GetTime():i.GetTotalTime();(e<=s||e>=n)&&(this._lastKeyframeDataItem=this._trackData.GetFirstKeyFrameDataItemLowerOrEqualThan(e,this._trackDataItem),t&&this.OnKeyframeReached(this._lastKeyframeDataItem))}else{if(!this._trackData.GetFirstKeyFrameDataItemHigherOrEqualThan(e,this._trackDataItem))return;this._lastKeyframeDataItem||(this._lastKeyframeDataItem=this._trackData.GetFirstKeyFrameDataItemHigherOrEqualThan(e,this._trackDataItem));const t=this._lastKeyframeDataItem.GetLast(),s=this._lastKeyframeDataItem.GetTime(),i=t?t.GetTime():0;(e>=s||e<=i)&&(this._lastKeyframeDataItem=this._trackData.GetFirstKeyFrameDataItemHigherOrEqualThan(e,this._trackDataItem),this._lastKeyframeDataItem&&this.OnKeyframeReached(this._lastKeyframeDataItem))}}_GetLastKeyFrameBeforeTime(e){return this._trackData.GetKeyFrameDataItemAtTime(e,this._trackDataItem)||this._trackData.GetFirstKeyFrameDataItemLowerOrEqualThan(e,this._trackDataItem)}_GetFirstKeyFrameAfterTime(e){return this._trackData.GetKeyFrameDataItemAtTime(e,this._trackDataItem)||this._trackData.GetFirstKeyFrameDataItemHigherOrEqualThan(e,this._trackDataItem)}OnKeyframeReached(e,t=!1){if(!xm.Plugins.Timeline)return;const s=this.GetTimeline(),i=s.GetTimelineManager();xm.Plugins.Timeline.Cnds.PushTriggerTimeline(s),xm.Plugins.Timeline.Cnds.PushTriggerKeyframe(e),i.Trigger(xm.Plugins.Timeline.Cnds.OnAnyKeyframeReached),i.Trigger(xm.Plugins.Timeline.Cnds.OnKeyframeReached),s.IsPlaying()||t||s.SetStoppedOnKeyframe(e),xm.Plugins.Timeline.Cnds.PopTriggerTimeline(s),xm.Plugins.Timeline.Cnds.PopTriggerKeyframe(e)}OnInitialKeyframeReached(e){this.OnKeyframeReached(e,!0)}AddKeyframe(){return this._trackDataItem.GetKeyframeData().AddEmptyKeyframeDataItem()}AddPropertyTrack(){const e=this._trackDataItem.GetPropertyTrackData().AddEmptyPropertyTrackDataItem(),t=xm.PropertyTrackState.Create(this,e);return this._propertyTracks.push(t),t}DeleteKeyframes(e){this._trackDataItem.GetKeyframeData().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())return;let e=!1;for(const t of this._propertyTracks){const s=t.CompareSaveStateWithCurrent();!e&&s&&(e=!0)}if(e){const e=this.AddKeyframe();e.SetTime(this.GetTimeline().GetTime()),e.SetEase("noease"),e.SetEnable(!0),e.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 e of this._propertyTracks)0===this._worldInfoChange&&1===e.GetWorldInfoChange()&&(this._worldInfoChange=1),0===this._renderChange&&1===e.GetRenderChange()&&(this._renderChange=1);this._needsBeforeAndAfter=0,this._propertyTracks.some(e=>e.GetNeedsBeforeAndAfter())&&(this._needsBeforeAndAfter=1)}}_SaveLastKeyframeDataItemToJson(){return this._trackDataItem.GetKeyframeData().GetKeyframeDataItemIndex(this._lastKeyframeDataItem)}_SavePropertyTracksToJson(){return this._propertyTracks.map(e=>e._SaveToJson())}_LoadPropertyTracksFromJson(e){e.forEach((e,t)=>{this._propertyTracks[t]._LoadFromJson(e)})}_LoadInstanceFromJson(e){if(!xm.IsFiniteNumber(e))return;const t=this.GetRuntime().GetInstanceByUID(e);t&&this.GetTimeline().SetTrackInstance(this._trackDataItem.GetId(),t,this.GetTrackIndexInTimeline())}_LoadLastKeyframeDataItemFromJson(e){const t=this._trackDataItem.GetKeyframeData();this._lastKeyframeDataItem=t.GetKeyframeDataItemFromIndex(e)}}}{const Mm=self.C3;Mm.PropertyTrackState=class extends Mm.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 Mm.New(Mm.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)return this._sourceAdapter;let e;switch(this._propertyTrackDataItem.GetSourceAdapterId()){case"behavior":e=new Mm.PropertyTrackState.BehaviorSourceAdapter(this);break;case"effect":e=new Mm.PropertyTrackState.EffectSourceAdapter(this),this._renderChange=1;break;case"instance-variable":e=new Mm.PropertyTrackState.InstanceVariableSourceAdapter(this);break;case"plugin":e=new Mm.PropertyTrackState.PluginSourceAdapter(this),this._renderChange=1;break;case"world-instance":e=new Mm.PropertyTrackState.PropertySourceAdapter(this),this._renderChange=1,this._worldInfoChange=1;break;case"value":e=new Mm.PropertyTrackState.ValueSourceAdapter(this);break;case"audio":e=new Mm.PropertyTrackState.AudioSourceAdapter(this)}return this._sourceAdapter=e,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,s=this._propertyTrackData.GetPropertyKeyFrameDataItemAtTime(e,this._propertyTrackDataItem);return s?t=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemHigherThan(e,this._propertyTrackDataItem):(s=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,this._propertyTrackDataItem),t=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemHigherOrEqualThan(e,this._propertyTrackDataItem)),{start:s,end:t}}*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();if(i.MayNeedBeforeAndAfterInterpolate()){const e=t.GetSimilarPropertyTracks(s,i,n,this);e&&e.length&&(this._needsBeforeAndAfter=1)}else this._needsBeforeAndAfter=0}}_GetLastPropertyKeyFrameBeforeTime(e){const t=this.GetTimeline();return this._propertyTrackData.GetPropertyKeyFrameDataItemAtTime(e,this._propertyTrackDataItem)||(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 t=this.GetTimeline(),s=this._lastPropertyKeyframeDataItem.GetNext(),i=this._lastPropertyKeyframeDataItem.GetTime(),n=s?s.GetTime():t.GetTotalTime();(e<=i||e>=n)&&(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 t=this.GetTimeline(),s=this._lastPropertyKeyframeDataItem.GetNext(),i=this._lastPropertyKeyframeDataItem.GetTime(),n=s?s.GetTime():t.GetTotalTime();(e<=i||e>=n)&&(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();return t._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,s)}static GetEndPropertyKeyframeForTime(e,t){const s=t.GetPropertyTrackDataItem();return t._propertyTrackData.GetFirstPropertyKeyFrameDataItemHigherOrEqualThan(e,s)}AddPropertyKeyframe(){const e=this._propertyTrackDataItem.GetPropertyKeyframeData().AddEmptyPropertyKeyframeDataItem();return this._lastPropertyKeyframeDataItem=null,e}DeletePropertyKeyframes(e){this._lastPropertyKeyframeDataItem=null,this._propertyTrackDataItem.GetPropertyKeyframeData().DeletePropertyKeyframeDataItems(e)}SaveState(){this.GetSourceAdapter().SaveState()}CompareInitialStateWithCurrent(){if(this.GetSourceAdapter().CompareInitialStateWithCurrent()){const e=this._propertyTrackData.GetFirstPropertyKeyframeDataItem(this._propertyTrackDataItem),t=this.GetSourceAdapter().GetCurrentState();e.SetAbsoluteValue(t)}}CompareSaveStateWithCurrent(){const e=this.GetSourceAdapter().CompareSaveStateWithCurrent();return e&&this.AddPropertyKeyframeAtCurrentTime(),this.GetSourceAdapter().ClearSaveState(),e}AddPropertyKeyframeAtCurrentTime(){const e=this.GetTimeline().GetTime(),t=this.GetSourceAdapter(),s=Mm.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 Dm=self.C3,Em=Dm.PropertyTrackState;Em.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;switch(this._propertyTrack.GetPropertyKeyframeType()){case"numeric":o=Em.NumericTypeAdapter.Interpolate(e,t,s,this._propertyTrack);break;case"angle":o=Em.AngleTypeAdapter.Interpolate(e,t,s,this._propertyTrack);break;case"boolean":o=Em.BooleanTypeAdapter.Interpolate(e,t,s,this._propertyTrack);break;case"color":o=Em.ColorTypeAdapter.Interpolate(e,t,s,this._propertyTrack);break;case"text":o=Em.TextTypeAdapter.Interpolate(e,t,s,this._propertyTrack)}this._propertyAdapter.ChangeProperty(e,o,t,s,i,n,r,a)}GetInterpolatedValue(e,t,s){switch(this._propertyTrack.GetPropertyKeyframeType()){case"numeric":return Em.NumericTypeAdapter.Interpolate(e,t,s,this._propertyTrack);case"angle":return Em.AngleTypeAdapter.Interpolate(e,t,s,this._propertyTrack);case"boolean":return Em.BooleanTypeAdapter.Interpolate(e,t,s,this._propertyTrack);case"color":return Em.ColorTypeAdapter.Interpolate(e,t,s,this._propertyTrack);case"text":return Em.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().GetTimeline().GetTime(),s=Em.GetStartPropertyKeyframeForTime(t,e),i=s.GetNext();switch(e.GetPropertyKeyframeType()){case"numeric":return Em.NumericTypeAdapter.Interpolate(t,s,i,e);case"angle":return Em.AngleTypeAdapter.Interpolate(t,s,i,e);case"boolean":return Em.BooleanTypeAdapter.Interpolate(t,s,i,e);case"color":return Em.ColorTypeAdapter.Interpolate(t,s,i,e);case"text":return Em.TextTypeAdapter.Interpolate(t,s,i,e)}}_CreatePropertyAdapter(){const e=this._propertyTrack;switch(e.CanHavePropertyKeyframes()?e.GetPropertyKeyframeType():""){case"combo":case"boolean":case"text":case"string":return new Em.PropertyInterpolationAdapter.NoInterpolationAdapter(this);case"numeric":case"number":case"angle":return"combo"===this._propertyTrack.GetPropertyType()?new Em.PropertyInterpolationAdapter.NoInterpolationAdapter(this):new Em.PropertyInterpolationAdapter.NumericInterpolationAdapter(this);case"color":case"offsetColor":return new Em.PropertyInterpolationAdapter.ColorInterpolationAdapter(this);default:return new Em.PropertyInterpolationAdapter.NumericInterpolationAdapter(this)}}_SaveToJson(){return{propertyAdapterJson:this.GetPropertyAdapter()._SaveToJson()}}_LoadFromJson(e){e&&this.GetPropertyAdapter()._LoadFromJson(e.propertyAdapterJson)}}}{const Fm=self.C3,Om=0;class Bm extends Fm.PropertyTrackState.PropertySourceAdapter{constructor(e){super(e),this._updatedIndex=NaN}GetEditorIndex(){return this._propertyTrack.GetPropertyTrackDataItem().GetSourceAdapterArguments()[0]}GetIndex(){return this._updatedIndex?this._updatedIndex:super.GetIndex()}GetTarget(){return this._propertyTrack.GetTrack().GetInstance()}UpdateInstanceVariableIndex(e){this._propertyTrack.GetPropertyTrackDataItem().GetSourceAdapterArguments()[0]!==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)}}Fm.PropertyTrackState.InstanceVariableSourceAdapter=Bm}{const Lm=self.C3,km=0,Nm=1,Wm=2;class Vm extends Lm.PropertyTrackState.PropertySourceAdapter{constructor(e){super(e),this._sid=NaN}GetEditorIndex(){return this._propertyTrack.GetPropertyTrackDataItem().GetSourceAdapterArguments()[1]}GetTarget(){const e=this._propertyTrack.GetPropertyTrackDataItem(),t=this._propertyTrack.GetTrack(),s=this._sid?this._sid:e.GetSourceAdapterArguments()[0],i=t.GetInstance(),n=i.GetBehaviorIndexBySID(s);return i.GetBehaviorInstances()[n].GetSdkInstance()}GetBehaviorType(e){const t=this._propertyTrack.GetPropertyTrackDataItem().GetSourceAdapterArguments()[2];return e.GetBehaviorTypeByName(t)}UpdateBehaviorTypeSid(e){this._propertyTrack.GetPropertyTrackDataItem().GetSourceAdapterArguments()[0]!==e&&(this._sid=e)}Interpolate(e,t,s,i,n,r,a){const o=this._propertyTrack.GetTrack().GetInstance();this.GetBehaviorType(o.GetObjectClass())&&super.Interpolate(e,t,s,i,n,r,a)}GetInterpolatedValue(e,t,s){const i=this._propertyTrack.GetTrack().GetInstance();if(this.GetBehaviorType(i.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)}}Lm.PropertyTrackState.BehaviorSourceAdapter=Vm}{const Um=self.C3,jm=0,Hm=1;class zm extends Um.PropertyTrackState.PropertySourceAdapter{constructor(e){super(e)}GetEditorIndex(){return this._propertyTrack.GetPropertyTrackDataItem().GetSourceAdapterArguments()[1]}GetTarget(){const e=this._propertyTrack.GetTrack().GetWorldInfo().GetInstanceEffectList(),t=e.GetEffectList(),s=this.GetEffectType(t).GetIndex();return e.IsEffectIndexActive(s)?e.GetEffectParametersForIndex(s):null}GetEffectType(e){const t=this._propertyTrack.GetPropertyTrackDataItem().GetSourceAdapterArguments()[0];return e.GetEffectTypeByName(t)}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.GetTrack().GetWorldInfo().GetInstanceEffectList(),t=e.GetEffectList(),s=this.GetEffectType(t);if(!s)return;const i=s.GetIndex();return e.IsEffectIndexActive(i)}}Um.PropertyTrackState.EffectSourceAdapter=zm}{const Xm=self.C3,Ym=0;class qm extends Xm.PropertyTrackState.PropertySourceAdapter{constructor(e){super(e)}GetEditorIndex(){return this._propertyTrack.GetPropertyTrackDataItem().GetSourceAdapterArguments()[0]}GetTarget(){return this._propertyTrack.GetTrack().GetInstance().GetSdkInstance()}Interpolate(e,t,s,i,n,r,a){const o=this._propertyTrack.GetTrack();o.GetObjectClass().GetPlugin()===o.GetInstance().GetObjectClass().GetPlugin()&&super.Interpolate(e,t,s,i,n,r,a)}GetInterpolatedValue(e,t,s){const i=this._propertyTrack.GetTrack();if(i.GetObjectClass().GetPlugin()===i.GetInstance().GetObjectClass().GetPlugin())return super.GetInterpolatedValue(e,t,s)}GetOptionalCallbacks(){const e=this._propertyTrack.GetTrack(),t=e.GetObjectClass().GetPlugin();if(Xm.Plugins.Sprite&&t instanceof Xm.Plugins.Sprite&&("initial-frame"===this._propertyTrack.GetPropertyName()||"initial-animation"===this._propertyTrack.GetPropertyName()))switch(this._propertyTrack.GetResultMode()){case"relative":return{onFrameChange:(t,s,i,n,r)=>{if(s!==n){const i=n/s,r=e.GetPropertyTrack("offsetWidth"),a=e.GetPropertyTrack("offsetScaleX");if(r||a){const o=r?.GetSourceAdapter()?.GetPropertyAdapter(),h=a?.GetSourceAdapter()?.GetPropertyAdapter();if(t.HasParent()&&t.GetTransformWithParentWidth())h&&h.SetOriginalSizeProperty(n),t.SetWidth(this.GetNewWidth(n,s,t,e,o,h));else{const s=n*((t._GetSceneGraphInfo()?._GetStartWidth()??this.GetInstanceOriginalWidth(t,e))/this.GetInstanceOriginalWidth(t,e));h&&h.SetOriginalSizeProperty(n);const r=o?.GetChangeAccumulatorProperty()??0,a=h?.GetChangeAccumulatorProperty()??0;t.SetWidth(s+(r+a*i))}}else t.SetWidth(t.GetWidth()*i)}if(i!==r){const s=r/i,n=e.GetPropertyTrack("offsetHeight"),a=e.GetPropertyTrack("offsetScaleY");if(n||a){const o=n?.GetSourceAdapter()?.GetPropertyAdapter(),h=a?.GetSourceAdapter()?.GetPropertyAdapter();if(t.HasParent()&&t.GetTransformWithParentHeight())h&&h.SetOriginalSizeProperty(r),t.SetHeight(this.GetNewHeight(r,i,t,e,o,h));else{const i=r*((t._GetSceneGraphInfo()?._GetStartHeight()??this.GetInstanceOriginalHeight(t,e))/this.GetInstanceOriginalHeight(t,e));h&&h.SetOriginalSizeProperty(r);const n=o?.GetChangeAccumulatorProperty()??0,a=h?.GetChangeAccumulatorProperty()??0;t.SetHeight(i+(n+a*s))}}else t.SetHeight(t.GetHeight()*s)}}};case"absolute":return null}}GetLastPropertyKeyframeValue(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}GetInstanceOriginalWidth(e,t){const s=t.GetTimeline().GetTrackFromInstance(e.GetInstance());if(s)return s.GetOriginalWidth();const i=e.GetInstance().GetSdkInstance();return i.IsOriginalSizeKnown()?i.GetOriginalWidth():e._GetSceneGraphInfo()._GetStartWidth()}GetInstanceOriginalHeight(e,t){const s=t.GetTimeline().GetTrackFromInstance(e.GetInstance());if(s)return s.GetOriginalHeight();const i=e.GetInstance().GetSdkInstance();return i.IsOriginalSizeKnown()?i.GetOriginalHeight():e._GetSceneGraphInfo()._GetStartHeight()}GetNewWidth(e,t,s,i,n,r){const a=s._GetSceneGraphInfo()._GetStartWidth(),o=a/s.GetParent()._GetSceneGraphInfo()._GetStartWidth();let h=1;const l=r?.GetAbsoluteScaleXOffsetProperty()??0;if(0!==l){const e=a/this.GetInstanceOriginalWidth(s,i);h=(e+l)/(0===e?Number.EPSILON:e)}const c=a*(e/t);let u=n?.GetAbsoluteWidthOffsetProperty()??0;u+=c-a;const d=(a+u)/(0===a?Number.EPSILON:a);return s.GetParent().GetWidth()*o*h*d}GetNewHeight(e,t,s,i,n,r){const a=s._GetSceneGraphInfo()._GetStartHeight(),o=a/s.GetParent()._GetSceneGraphInfo()._GetStartHeight();let h=1;const l=r?.GetAbsoluteScaleYOffsetProperty()??0;if(0!==l){const e=a/this.GetInstanceOriginalHeight(s,i);h=(e+l)/(0===e?Number.EPSILON:e)}const c=a*(e/t);let u=n?.GetAbsoluteHeightOffsetProperty()??0;u+=c-a;const d=(a+u)/(0===a?Number.EPSILON:a);return s.GetParent().GetHeight()*o*h*d}}Xm.PropertyTrackState.PluginSourceAdapter=qm}{const Km=self.C3;class $m extends Km.PropertyTrackState.PropertySourceAdapter{constructor(e){super(e),this._value=0,this._init=!1}MayNeedBeforeAndAfterInterpolate(){return!1}SetInitialState(){const e=this._propertyTrack.GetPropertyTrackData();let 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=Km.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)}}Km.PropertyTrackState.ValueSourceAdapter=$m}{const Jm=self.C3,Zm=0,Qm=0,ef=1,tf=1,sf=2,nf=3;class rf extends Jm.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[0],this._startOffsetTime=this._sourceAdapterArgs[1],this._sourceAdapterArgs[3]?this._audioTag=this._sourceAdapterArgs[3]: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)return;const e=this._propertyTrack.GetRuntime().GetSingleGlobalObjectClassByCtor(self.C3.Plugins.Audio);e&&(this._sdkInstance=e.GetSingleGlobalInstance().GetSdkInstance()),this._actions=self.C3.Plugins.Audio.Acts,this._expressions=self.C3.Plugins.Audio.Exps}_MaybeSetAudioSource(){if(this._audioSource)return;const e=this._propertyTrack.GetTrack().GetPropertyTrack("audioSource");e&&(this._audioSource=e.GetSourceAdapter())}_GetPauseVolume(){const e=this._propertyTrack.GetTrack().GetPropertyTrack("volume");return e?e.GetSourceAdapter()._pauseVolume: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().GetTime();switch(this._pauseTime=e-this._startOffsetTime,this._propertyTrack.GetPropertyName()){case"audioSource":break;case"volume":this._pauseVolume=this._propertyTrack.GetInterpolatedValue(e)}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{const e=this._propertyTrack.GetPropertyTrackDataItem();return this._propertyTrack.GetPropertyTrackData().GetFirstPropertyKeyframeDataItem(e)},()=>{const e=this._propertyTrack.GetPropertyTrackDataItem();return this._propertyTrack.GetPropertyTrackData().GetLastPropertyKeyframeDataItem(e)}).GetAbsoluteValue()}_CurrentKeyframeGetter(){const e=this._propertyTrack.GetTimeline().GetTime()-this._propertyTrack.GetTrack().GetStartOffset();return this._PickTimelinePlaybackMode(()=>{const t=this._propertyTrack.GetPropertyTrackDataItem();return this._propertyTrack.GetPropertyTrackData().GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,t)},()=>{const t=this._propertyTrack.GetPropertyTrackDataItem(),s=this._propertyTrack.GetPropertyTrackData();return s.GetFirstPropertyKeyFrameDataItemHigherOrEqualThan(e,t)||s.GetLastPropertyKeyframeDataItem(t)}).GetAbsoluteValue()}_PickTimelinePlaybackMode(e,t){return this._propertyTrack.GetTimeline().IsForwardPlayBack()?e():t()}_PickResultMode(e,t){return"relative"===this._propertyTrack.GetResultMode()?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){switch(this._propertyTrack.GetSourceAdapterId()){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 e=i.GetTrack().GetStartOffset();for(const n of i.GetPropertyKeyframeDataItems())t&&0===n.GetTime()?s.push({time:e+n.GetTime(),value:n.GetAbsoluteValue()}):t||s.push({time:e+n.GetTime(),value:n.GetAbsoluteValue()})}return s.sort((e,t)=>e.time-t.time)}_GetLastPropertyKeyframeStub(e,t,s){return this._GetPropertyKeyframeStubLowerThanPlayhead(t,s)}_GetPropertyKeyframeStubLowerThanPlayhead(e,t){for(let s=t.length-1;s>=0;s--)if(t[s].time<=e)return t[s];return null}}}{const of=self.C3,hf=new Map,lf=[0,0,0];class cf extends of.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":case"plugin":return this._ToColorArray(t.GetPropertyValueByIndex(s));case"effect":return this._ToColorArray(t[s]);case"world-instance":return this._ToColorArray(this._Getter())}}CompareInitialStateWithCurrent(){const e=this._FirstKeyframeGetter();return!this._CompareColors(e,this._Getter())}CompareSaveStateWithCurrent(){return!of.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 of.IsInstanceOf(e,of.Color)?e.toArray().slice(0,3):e.slice(0,3)}_GetColorFromArray(e){return of.IsInstanceOf(e,of.Color)?e:new of.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&&i.length>1){hf.has(t)||hf.set(t,new Map);const e=hf.get(t),s=this._propertyTrack.GetSourceAdapterId();e.has(s)||e.set(s,new Map);const i=e.get(s);i.has(this._property)||i.set(this._property,{used:!1,color:new of.Color(0,0,0,1)})}}_GetTmpColor(e,t,s){const i=hf.get(e).get(t).get(s);return i.used=!0,i.color}ChangeProperty(e,t,s,i,n,r,a,o){const h=this._propertyTrack.GetTimeline(),l=this._propertyTrack.GetTrack(),c=this._propertyTrack.GetInstance(),u=this._propertyTrack.GetSourceAdapter(),d=this._propertyTrack.GetSourceAdapterId(),_=this._property,p=h.GetSimilarPropertyTracks(c,u,_,this._propertyTrack);if(p&&p.length>1){const e=this._GetPropertyKeyframeStubs(p,!0),s=this._GetLastPropertyKeyframeStub(h,h.GetTime(),e);if(s){const e=l.GetStartOffset(),i=s.time-e;if(0===i)this._GetTmpColor(c,d,this._property).addRgb(t[0],t[1],t[2]);else{if(i<0)return;const e=t[0],s=t[1],n=t[2],r=this._propertyTrack.Interpolate(i,!1,!0),a=of.Color.DiffChannel(e,r[0]),o=of.Color.DiffChannel(s,r[1]),h=of.Color.DiffChannel(n,r[2]);this._GetTmpColor(c,d,this._property).addRgb(a,o,h)}}}else this._Setter(t[0],t[1],t[2])}AfterChangeProperty(){const e=this._propertyTrack.GetInstance();if(!hf.has(e))return;const t=hf.get(e),s=this._propertyTrack.GetSourceAdapterId();if(!t.has(s))return;const i=t.get(s);if(!i.has(this._property))return;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&&hf.delete(e)}_Getter(){const e=this._propertyTrack.GetSourceAdapterId(),t=this._GetTarget(),s=this._GetIndex();switch(e){case"behavior":case"plugin":return this._GetColorFromArray(t.GetPropertyValueByIndex(s));case"effect":return t[s].clone();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":case"plugin":lf[0]=e,lf[1]=t,lf[2]=s,n.SetPropertyValueByIndex(r,lf);break;case"effect":n[r].setRgb(e,t,s);break;case"world-instance":this.GetWorldInfo().SetUnpremultipliedColorRGB(e,t,s)}}_SaveToJson(){}_LoadFromJson(e){}}of.PropertyTrackState.PropertyInterpolationAdapter.ColorInterpolationAdapter=cf}{const uf=self.C3,df=uf.PropertyTrackState;class _f extends uf.PropertyTrackState.PropertyInterpolationAdapter{constructor(e){super(e)}SetResetState(){}SetInitialState(){}SetResumeState(){}GetCurrentState(){return this._Getter()}CompareInitialStateWithCurrent(){return this._FirstKeyframeGetter()!==this.GetCurrentState()}CompareSaveStateWithCurrent(){return!uf.IsNullOrUndefined(this._saveState)&&this._saveState!==this.GetCurrentState()}MayNeedBeforeAndAfterInterpolate(){return!1}ChangeProperty(e,t,s,i,n,r,a,o){const h=this._propertyTrack,l=h.GetTrack(),c=h.GetSourceAdapterId(),u=h.GetTimeline(),d=l.GetInstance(),_=h.GetSourceAdapter(),p=this._property,g=u.GetSimilarPropertyTracks(d,_,p,h);if(g&&g.length>1){const s=this._GetPropertyKeyframeStubs(g),i=e+l.GetStartOffset(),n=this._GetLastPropertyKeyframeStub(u,i,s);n&&(t=n.value)}switch(h.GetPropertyKeyframeType()){case"numeric":if(!df.NumericTypeAdapter.WillChange(this._GetIndex(),this._GetTarget(),t,c))return;break;case"angle":if(!df.AngleTypeAdapter.WillChange(this._GetIndex(),this._GetTarget(),t,c))return;break;case"boolean":if(!df.BooleanTypeAdapter.WillChange(this._GetIndex(),this._GetTarget(),t,c))return;break;case"color":if(!df.ColorTypeAdapter.WillChange(this._GetIndex(),this._GetTarget(),t,c))return;break;case"text":if(!df.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":case"plugin":return t.GetPropertyValueByIndex(s);case"effect":return t[s];case"instance-variable":return t.GetInstanceVariableValue(s)}}_Setter(e){const t=this._propertyTrack.GetSourceAdapterId(),s=this._GetTarget(),i=this._GetIndex();switch(t){case"behavior":case"plugin":s.SetPropertyValueByIndex(i,e);break;case"effect":s[i]=e;break;case"instance-variable":s.SetInstanceVariableValue(i,e)}}}uf.PropertyTrackState.PropertyInterpolationAdapter.NoInterpolationAdapter=_f}{const pf=self.C3,gf=pf.PropertyTrackState.PropertyInterpolationAdapter,mf=new Map,ff=(e,t,s,i,n,r=!1,a=null,o=null)=>{mf.set(e,{setter:t,absolute_setter:s,getter:i,round:n,fRound:r,init:a,reset:o})},Sf=(e,t)=>{const s=t.GetTimeline().GetTrackFromInstance(e.GetInstance());if(s)return s.GetOriginalWidth();const i=e.GetInstance().GetSdkInstance();return i.IsOriginalSizeKnown()?i.GetOriginalWidth():e._GetSceneGraphInfo()._GetStartWidth()},Gf=(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},yf=e=>{const t=[];let s=e.GetParent();for(;s;)t.push(s),s=s.GetParent();return t.reverse(),t};ff("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),ff("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),ff("offsetWidth",(e,t,s,i,n=!1,r=!0)=>{if(0===t)return;const a="relative"===i._propertyTrack.GetResultMode(),o=1===i._typeAdapter.GetType();if((a||o)&&e.HasParent()&&e.GetTransformWithParentWidth()){if(isNaN(i._absoluteToFactor)){const t=yf(e);let s;s=o?t[t.length-1].GetWidth():t[t.length-1]._GetSceneGraphInfo()._GetStartWidth(),i._absoluteToFactor=0===s?Number.EPSILON:s}if(n)return;i._absoluteWidthOffset+=t;const s=t/i._absoluteToFactor;e.OffsetWidth(s,r),i._changeAccumulator+=s}else e.OffsetWidth(t),i._changeAccumulator+=t},(e,t)=>e.SetWidth(t),e=>e.GetWidth(),!0,!1,null,e=>{e._changeAccumulator=0,e._absoluteWidthOffset=0}),ff("offsetHeight",(e,t,s,i,n=!1,r=!0)=>{if(0===t)return;const a="relative"===i._propertyTrack.GetResultMode(),o=1===i._typeAdapter.GetType();if((a||o)&&e.HasParent()&&e.GetTransformWithParentHeight()){if(isNaN(i._absoluteToFactor)){const t=yf(e);let s;s=o?t[t.length-1].GetHeight():t[t.length-1]._GetSceneGraphInfo()._GetStartHeight(),i._absoluteToFactor=0===s?Number.EPSILON:s}if(n)return;i._absoluteHeightOffset+=t;const s=t/i._absoluteToFactor;e.OffsetHeight(s,r),i._changeAccumulator+=s}else e.OffsetHeight(t),i._changeAccumulator+=t},(e,t)=>e.SetHeight(t),e=>e.GetHeight(),!0,!1,null,e=>{e._changeAccumulator=0,e._absoluteHeightOffset=0}),ff("offsetAngle",(e,t,s,i,n)=>{e.OffsetAngle(t)},(e,t)=>e.SetAngle(t),e=>e.GetAngle(),!1,!0),ff("offsetOpacity",(e,t,s,i,n)=>{t/=i._opacityFactor?i._opacityFactor:1;const r=e.GetOpacity()+t;if(0===i._clampAccumulator)r>1?i._clampAccumulator+=r-1:r<0&&(i._clampAccumulator+=r),e.OffsetOpacity(t);else{const s=e.GetOpacity()+t;t>0&&i._clampAccumulator>0?s>1&&(i._clampAccumulator+=s-1):t>0&&i._clampAccumulator<0?(i._clampAccumulator+=t,i._clampAccumulator>0&&(e.OffsetOpacity(i._clampAccumulator),i._clampAccumulator=0)):t<0&&i._clampAccumulator>0?(i._clampAccumulator+=t,i._clampAccumulator<0&&(e.OffsetOpacity(i._clampAccumulator),i._clampAccumulator=0)):t<0&&i._clampAccumulator<0&&s<0&&(i._clampAccumulator+=s)}},(e,t)=>{e.SetOpacity(t)},e=>e.GetOpacity(),!1,!0,(e,t,s)=>{switch(e._clampAccumulator=0,e._propertyTrack.GetResultMode()){case"relative":{e._propertyTrack.GetPropertyTrackData();const t=e._propertyTrack.GetPropertyTrackDataItem().GetPropertyKeyframeData().GetPropertyKeyframeDataItemArray();let s=e.GetWorldInfo().GetOpacity(),i=s;for(const n of t){const t=n.GetTime();i=s+e._propertyTrack.GetInterpolatedValue(t),i=pf.clamp(i,0,1)}e._totalForewardOpacityDelta=s-i,e._totalForewardOpacityDelta=Math.round(100*(e._totalForewardOpacityDelta+Number.EPSILON))/100,i=s;for(let s=t.length-1;s>=0;s--){const n=t[s].GetTime();i-=e._propertyTrack.GetInterpolatedValue(n),i=pf.clamp(i,0,1)}e._totalBackwardOpacityDelta=i,e._totalBackwardOpacityDelta=Math.round(100*(e._totalBackwardOpacityDelta+Number.EPSILON))/100;break}}const i="relative"===e._propertyTrack.GetResultMode(),n=1===e._typeAdapter.GetType();if((i||n)&&t.HasParent()&&t.GetTransformWithParentOpacity()){const i=yf(t);let n=i[0]._GetSceneGraphInfo().GetStartOpacity();n+=Gf(i[0],s,"offsetOpacity");for(let e=1;e{switch(e._propertyTrack.GetResultMode()){case"relative":{e._clampAccumulator=0;const t=e.GetWorldInfo();let s=t.GetOpacity();s=Math.round(100*(s+Number.EPSILON))/100,e._propertyTrack.GetTimeline().IsForwardPlayBack()?(t.SetOpacity(s+e._totalForewardOpacityDelta),e._lastValue=0):(t.SetOpacity(s-e._totalBackwardOpacityDelta),e._lastValue=e.GetSourceAdapter().GetValueAtTime());break}}}),ff("offsetOriginX",(e,t)=>e.OffsetOriginX(t),(e,t)=>e.SetOriginX(t),e=>e.GetOriginX(),!1),ff("offsetOriginY",(e,t)=>e.OffsetOriginY(t),(e,t)=>e.SetOriginY(t),e=>e.GetOriginY(),!1),ff("offsetZElevation",(e,t)=>e.OffsetZElevation(t),(e,t)=>e.SetZElevation(t),e=>e.GetZElevation(),!0),ff("offsetScaleX",(e,t,s,i)=>{if(0===t)return;const n=e.GetWidth()<0?-1:1;if(i._absoluteScaleXOffset+=t,"relative"===i._propertyTrack.GetResultMode()&&e.HasParent()&&e.GetTransformWithParentWidth()){const r=Gf(e,s,"offsetWidth"),a=isNaN(i._originalSize)?s.GetOriginalWidth():i._originalSize,o=(a+r/(e._GetSceneGraphInfo()._GetStartWidth()/a))*n*t;isNaN(i._absoluteToFactor)&&mf.get("offsetWidth").setter(e,1,s,i,!0);const h=o/i._absoluteToFactor;e.OffsetWidth(h,!0),i._changeAccumulator+=h}else{const r=(isNaN(i._originalSize)?s.GetOriginalWidth():i._originalSize)*n*t;e.OffsetWidth(r),i._changeAccumulator+=r}},(e,t,s)=>{e.SetWidth(s.GetOriginalWidth()*t)},(e,t)=>{const s=e.GetWidth()<0?-1:1;if(e.GetTransformWithParentWidth()){const i=e.GetParent(),n=t.GetTimeline().GetTrackFromInstance(i.GetInstance());let r=NaN;if(n)r=i.GetWidth()/n.GetOriginalWidth();else{const e=i.GetInstance().GetSdkInstance();r=e.IsOriginalSizeKnown()?i.GetWidth()/e.GetOriginalWidth():1}return e.GetWidth()*s/(t.GetOriginalWidth()*r)}return e.GetWidth()*s/t.GetOriginalWidth()},!1,!1,null,e=>{e._changeAccumulator=0,e._originalSize=NaN,e._absoluteScaleXOffset=0}),ff("offsetScaleY",(e,t,s,i)=>{if(0===t)return;const n=e.GetHeight()<0?-1:1;if(i._absoluteScaleYOffset+=t,"relative"===i._propertyTrack.GetResultMode()&&e.HasParent()&&e.GetTransformWithParentHeight()){const r=Gf(e,s,"offsetHeight"),a=isNaN(i._originalSize)?s.GetOriginalHeight():i._originalSize,o=(a+r/(e._GetSceneGraphInfo()._GetStartHeight()/a))*n*t;isNaN(i._absoluteToFactor)&&mf.get("offsetHeight").setter(e,1,s,i,!0);const h=o/i._absoluteToFactor;e.OffsetHeight(h,!0),i._changeAccumulator+=h}else{const r=(isNaN(i._originalSize)?s.GetOriginalHeight():i._originalSize)*n*t;e.OffsetHeight(r),i._changeAccumulator+=r}},(e,t,s)=>{e.SetHeight(s.GetOriginalHeight()*t)},(e,t)=>{const s=e.GetHeight()<0?-1:1;if(e.GetTransformWithParentHeight()){const i=e.GetParent(),n=t.GetTimeline().GetTrackFromInstance(i.GetInstance());let r=NaN;if(n)r=i.GetHeight()/n.GetOriginalHeight();else{const e=i.GetInstance().GetSdkInstance();r=e.IsOriginalSizeKnown()?i.GetHeight()/e.GetOriginalHeight():1}return e.GetHeight()*s/(t.GetOriginalHeight()*r)}return e.GetHeight()*s/t.GetOriginalHeight()},!1,!1,null,e=>{e._changeAccumulator=0,e._originalSize=NaN,e._absoluteScaleYOffset=0});class If extends pf.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._changeAccumulator=0,this._originalSize=NaN,this._absoluteWidthOffset=0,this._absoluteScaleXOffset=0,this._absoluteHeightOffset=0,this._absoluteScaleYOffset=0,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,pf.IsInstanceOf(this._propertyTrack.GetTimeline(),pf.TweenState)?this._typeAdapter=new pf.PropertyTrackState.PropertyInterpolationAdapter.NumericInterpolationAdapterForTween(this):this._typeAdapter=new pf.PropertyTrackState.PropertyInterpolationAdapter.NumericInterpolationAdapterForTimeline(this);const t=this._propertyTrack.GetPropertyName();switch(this._propertyTrack.GetSourceAdapterId()){case"world-instance":{const e=mf.get(t);this._instance_getter=e.getter,this._instance_setter=e.setter,this._instance_absolute_setter=e.absolute_setter,this._round=e.round,this._fRound=e.fRound,this._init_action=e.init,this._reset_action=e.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 e=this.GetWorldInfo(),t=this._propertyTrack.GetTrack();this._init_action(this,e,t)}}SetResumeState(){const e=this._typeAdapter.SetResumeState();"number"==typeof e&&(this._lastValue=e)}GetCurrentState(){return this._Getter()}CompareInitialStateWithCurrent(){return this._FirstKeyframeGetter()!==this.GetCurrentState()}CompareSaveStateWithCurrent(){return!pf.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();switch(this._propertyTrack.GetSourceAdapterId()){case"behavior":case"plugin":return e.GetPropertyValueByIndex(t);case"effect":return e[t];case"instance-variable":return e.GetInstanceVariableValue(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,i=!0){const n=this._GetTarget(),r=this._GetIndex(),a=this.GetWorldInfo(),o=this._propertyTrack.GetTrack();switch(this._propertyTrack.GetSourceAdapterId()){case"behavior":n.OffsetPropertyValueByIndex(r,e);break;case"effect":n[r]+=e;break;case"instance-variable":n.SetInstanceVariableOffset(r,e);break;case"plugin":n.OffsetPropertyValueByIndex(r,e,this.GetSourceAdapter().GetOptionalCallbacks());break;case"world-instance":this._instance_setter(a,e,o,this,!1,i);break;case"audio":this._source_adapter_setter.call(this.GetSourceAdapter(),a,e,o,this)}}_SetterAbsolute(e,t,s){let i=this._propertyTrack.GetInterpolationMode();if(i="default"===i?"continuous":i,"discrete"===i&&!t)return;if("discrete"===i&&s){const e=this._propertyTrack.GetTimeline().GetTime();if(!this._propertyTrack.GetPropertyKeyFrameDataItemAtTime(e))return}const n=this._GetTarget(),r=this._GetIndex(),a=this.GetWorldInfo(),o=this._propertyTrack.GetTrack();switch(this._propertyTrack.GetSourceAdapterId()){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){"angle"===this._propertyTrack.GetPropertyType()&&(e=pf.toDegrees(e));const r=(e.toString().split(".")[1]||"").length,a=this._Getter();let o;switch(o=0===r?this._round?Math.round(a):this._fRound?"angle"===this._propertyTrack.GetPropertyType()?pf.toRadians(Math.round(pf.toDegrees(a))):Number(pf.toFixed(a,2)):a:this._round?Number(pf.toFixed(a,r)):(this._fRound,a),this._Setter(o-a,t,s,!1),this._propertyTrack.GetPropertyName()){case"offsetWidth":case"offsetScaleX":{const e=this.GetWorldInfo(),t=e.GetWidth(),s=Number(pf.toFixed(t,2));e.OffsetWidth(s-t);break}case"offsetHeight":case"offsetScaleY":{const e=this.GetWorldInfo(),t=e.GetHeight(),s=Number(pf.toFixed(t,2));e.OffsetHeight(s-t);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,ca:this._changeAccumulator,os:this._originalSize,awo:this._absoluteWidthOffset,aho:this._absoluteHeightOffset,asxo:this._absoluteScaleXOffset,asyo:this._absoluteScaleYOffset})}_LoadFromJson(e){e&&(super._LoadFromJson(e),this._lastValue=e.v,this._clampAccumulator=e.a,this._totalForewardOpacityDelta=pf.IsFiniteNumber(e.fod)?e.fod:0,this._totalBackwardOpacityDelta=pf.IsFiniteNumber(e.bod)?e.bod:0,this._opacityFactor=pf.IsFiniteNumber(e.of)?e.of:NaN,this._absoluteToFactor=pf.IsFiniteNumber(e.sf)?e.sf:NaN,this._angleReflectMirrorOrFlip=pf.IsFiniteNumber(e.armorf)?e.armorf:void 0,this._angleReflectMirrorAndFlip=pf.IsFiniteNumber(e.armandf)?e.armandf:void 0,this._changeAccumulator=pf.IsFiniteNumber(e.ca)?e.ca:0,this._originalSize=pf.IsFiniteNumber(e.os)?e.os:NaN,this._absoluteWidthOffset=pf.IsFiniteNumber(e.awo)?e.awo:0,this._absoluteHeightOffset=pf.IsFiniteNumber(e.aho)?e.aho:0,this._absoluteScaleXOffset=pf.IsFiniteNumber(e.asxo)?e.asxo:0,this._absoluteScaleYOffset=pf.IsFiniteNumber(e.asyo)?e.asyo:0)}SetOriginalSizeProperty(e){this._originalSize=e}GetChangeAccumulatorProperty(){return this._changeAccumulator}GetAbsoluteWidthOffsetProperty(){return this._absoluteWidthOffset}GetAbsoluteHeightOffsetProperty(){return this._absoluteHeightOffset}GetAbsoluteScaleXOffsetProperty(){return this._absoluteScaleXOffset}GetAbsoluteScaleYOffsetProperty(){return this._absoluteScaleYOffset}}pf.PropertyTrackState.PropertyInterpolationAdapter.NumericInterpolationAdapter=If}{const Tf=self.C3;class Cf{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;ee._PickTimelinePlaybackMode(()=>0,()=>e.GetSourceAdapter().GetValueAtTime()),()=>{})}SetResumeState(){}MayNeedBeforeAndAfterInterpolate(){switch(this._numericInterpolationAdapter,this._numericInterpolationAdapter.GetPropertyTrack().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())e.GetAbsoluteValueObject().Reset();else{const s=e.GetTimeline(),i=e.GetInstance(),n=e.GetSourceAdapter(),r=s.GetSimilarPropertyTracks(i,n,t,e);r&&r.length>1&&new Cf(r)}}}ChangeProperty(e,t,s,i,n,r,a,o){const h=this._numericInterpolationAdapter,l=this._numericInterpolationAdapter.GetPropertyTrack();switch(l.GetResultMode()){case"relative":{const a=h.GetLastValue();h._Setter(t-a,s,i),r&&this._MaybeEnsureValue(e,s,i,n,a,t),h.SetLastValue(t);break}case"absolute":{const e=l.GetTimeline(),s=l.GetTrack();if(l.GetInstance(),l.GetSourceAdapter(),l.HasAbsoluteValueObject()){const i=l.GetAbsoluteValueObject(),n=i.GetPropertyTracks(),r=h._GetPropertyKeyframeStubs(n,!0),c=h._GetLastPropertyKeyframeStub(e,e.GetTime(),r);if(c){const e=s.GetStartOffset(),n=c.time-e;if(0===n)i.SetEndState(a),i.SetPropertyKeyframeReached(o),i.SetUsed(),i.SetValue(i.GetValue()+t);else{if(n<0)return;const e=l.GetInterpolatedValue(n);i.SetEndState(a),i.SetPropertyKeyframeReached(o),i.SetUsed(),i.SetValue(i.GetValue()+(t-e))}}}else h._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))}}Tf.PropertyTrackState.PropertyInterpolationAdapter.NumericInterpolationAdapterForTimeline=bf}{const wf=self.C3;class Pf{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 h=this._numericInterpolationAdapter,l=h.GetLastValue();switch(h.GetPropertyTrack().GetResultMode()){case"relative":h._Setter(t-l,s,i),r&&this._MaybeEnsureValue(e,s,i,n,l,t,!1,a);break;case"absolute":h.GetFirstAbsoluteUpdate()?(h.SetFirstAbsoluteUpdate(!1),h._Setter(l,s,i)):0===e&&0===h.GetPropertyTrack().GetTimeline().GetTotalTime()?h._SetterAbsolute(t,!0,!1):(h._Setter(t-l,s,i),r&&this._MaybeEnsureValue(e,s,i,n,l,t,this._ForceEndValue(),a))}h.SetLastValue(t)}AfterChangeProperty(){}_GetAbsoluteInitialValue(e){return e-this._numericInterpolationAdapter.GetCurrentState()}_ForceEndValue(){const e=this._numericInterpolationAdapter,t=e.GetWorldInfo().GetInstance(),s=e.GetPropertyTrack().GetRuntime().GetTimelineManager();let i=0;for(const e of s.GetPlayingTimelines())0===e.GetType()?e.HasTrackInstance(t)&&i++:1===e.GetType()&&e.GetInstance()===t&&i++;return i<=1}_MaybeEnsureValue(e,t,s,i,n,r,a,o){const h=this._numericInterpolationAdapter;i?t&&e===t.GetTime()?h._AddDelta(t.GetValueWithResultMode(),t,s,a,o):s&&e===s.GetTime()?h._AddDelta(s.GetValueWithResultMode(),t,s,a,o):s||h._AddDelta(t.GetValueWithResultMode(),t,s,a,o):t&&e===t.GetTime()?h._AddDelta(t.GetValueWithResultMode(),t,s,a,o):s&&e===s.GetTime()?h._AddDelta(s.GetValueWithResultMode(),t,s,a,o):r-n===0&&h._AddDelta(t.GetValueWithResultMode(),t,s,a,o)}}wf.PropertyTrackState.PropertyInterpolationAdapter.NumericInterpolationAdapterForTween=Pf}{const xf=self.C3,vf=self.Ease;xf.PropertyTrackState.NumericTypeAdapter=class{constructor(){}static WillChange(e,t,s,i){let n;switch(i){case"behavior":case"plugin":n=t.GetPropertyValueByIndex(e);break;case"effect":n=t[e];break;case"instance-variable":n=t.GetInstanceVariableValue(e)}return n!==s}static Interpolate(e,t,s,i){if(!s){let e=i.GetPropertyTrackDataItem();return e=i.GetPropertyTrackData().GetLastPropertyKeyframeDataItem(e),e.GetValueWithResultMode()}let n=i.GetInterpolationMode();if("default"===n&&(n="continuous"),"combo"===i.GetPropertyType()&&(n="discrete"),"discrete"===n)return t.GetValueWithResultMode();if("continuous"===n||"step"===n){const r=i.GetTimeline().GetStep();if("step"===n&&0!==r){const t=1/r;e=Math.floor(e*t)/t}const a=t.GetValueWithResultMode(),o=s.GetValueWithResultMode(),h=t.GetAddOn("cubic-bezier"),l=s.GetAddOn("cubic-bezier"),c=h&&h.GetStartEnable()&&l&&l.GetEndEnable();if(!c&&a===o)return a;const u=t.GetTime(),d=s.GetTime();"step"===n&&0!==r&&(e=xf.clamp(e,u,d));const _=xf.normalize(e,u,d),p=t.GetEase();let g;if(c){const e=d-u;g=vf.GetRuntimeEase(p)(e*_,0,1,e),g=vf.GetRuntimeEase("cubicbezier")(g,a,a+h.GetStartAnchor(),o+l.GetEndAnchor(),o)}else g=vf.GetRuntimeEase(p)((d-u)*_,a,o-a,d-u);return"integer"===i.GetPropertyType()?Math.floor(g):g}}}}{const Af=self.C3;Af.PropertyTrackState.AngleTypeAdapter=class{constructor(){}static WillChange(e,t,s,i){let n;switch(i){case"behavior":case"plugin":n=t.GetPropertyValueByIndex(e);break;case"effect":n=t[e];break;case"instance-variable":n=t.GetInstanceVariableValue(e)}return n!==s}static Interpolate(e,t,s,i){if(!s){let e=i.GetPropertyTrackDataItem();return e=i.GetPropertyTrackData().GetLastPropertyKeyframeDataItem(e),e.GetValueWithResultMode()}let n=i.GetInterpolationMode();if("default"===n&&(n="continuous"),"combo"===i.GetPropertyType()&&(n="discrete"),"discrete"===n)return t.GetValueWithResultMode();if("continuous"===n||"step"===n){const r=i.GetTimeline().GetStep();if("step"===n&&0!==r){const t=1/r;e=Math.floor(e*t)/t}const a=t.GetTime(),o=s.GetTime(),h=t.GetValueWithResultMode(),l=s.GetValueWithResultMode();"step"===n&&0!==r&&(e=Af.clamp(e,a,o));const c=t.GetAddOn("angle");if(!c){if(h===l)return h;const s=Af.normalize(e,a,o),i=self.Ease.GetRuntimeEase(t.GetEase());return Af.angleLerp(h,l,i(s,0,1,1))}{const s=c.GetRevolutions();if(h===l&&0===s)return h;const i=Af.normalize(e,a,o),n=self.Ease.GetRuntimeEase(t.GetEase())(i,0,1,1);switch(c.GetDirection()){case"closest":return Af.angleLerp(h,l,n,s);case"clockwise":return Af.angleLerpClockwise(h,l,n,s);case"anti-clockwise":return Af.angleLerpAntiClockwise(h,l,n,s)}}}}}}{const Rf=self.C3;Rf.PropertyTrackState.BooleanTypeAdapter=class{constructor(){}static WillChange(e,t,s,i){let n;switch(i){case"behavior":case"plugin":n=t.GetPropertyValueByIndex(e);break;case"effect":n=t[e];break;case"instance-variable":n=t.GetInstanceVariableValue(e)}return!!n!=!!s}static Interpolate(e,t,s,i){if(!s){let e=i.GetPropertyTrackDataItem();return e=i.GetPropertyTrackData().GetLastPropertyKeyframeDataItem(e),e.GetValueWithResultMode()?1:0}return t.GetValueWithResultMode()?1:0}}}{const Mf=self.C3,Df=[0,0,0],Ef=[0,0,0],Ff=[0,0,0];Mf.PropertyTrackState.ColorTypeAdapter=class{constructor(){}static WillChange(e,t,s,i){let n;switch(i){case"behavior":case"plugin":n=t.GetPropertyValueByIndex(e);break;case"effect":n=t[e];break;case"instance-variable":n=t.GetInstanceVariableValue(e)}return Array.isArray(s)?(Df[0]=s[0],Df[1]=s[1],Df[2]=s[2]):(Ff.parseCommaSeparatedRgb(s),Df[0]=Math.floor(255*Ff.getR()),Df[1]=Math.floor(255*Ff.getG()),Df[2]=Math.floor(255*Ff.getB())),Array.isArray(n)?(Ef[0]=n[0],Ef[1]=n[1],Ef[2]=n[2]):(Ff.parseCommaSeparatedRgb(n),Ef[0]=Math.floor(255*Ff.getR()),Ef[1]=Math.floor(255*Ff.getG()),Ef[2]=Math.floor(255*Ff.getB())),Df[0]!==Ef[0]||Df[1]!==Ef[1]||Df[2]!==Ef[2]}static Interpolate(e,t,s,i){if(!s){let e=i.GetPropertyTrackDataItem();e=i.GetPropertyTrackData().GetLastPropertyKeyframeDataItem(e);const t=e.GetValueWithResultMode();return Df[0]=t[0],Df[1]=t[1],Df[2]=t[2],Df}let n=i.GetInterpolationMode();if("default"===n&&(n="continuous"),"discrete"===n){const e=t.GetValueWithResultMode();return Df[0]=e[0],Df[1]=e[1],Df[2]=e[2],Df}if("continuous"===n||"step"===n){const r=i.GetTimeline().GetStep();if("step"===n&&0!==r){const t=1/r;e=Math.floor(e*t)/t}const a=t.GetTime(),o=s.GetTime(),h=t.GetValueWithResultMode(),l=s.GetValueWithResultMode();"step"===n&&0!==r&&(e=Mf.clamp(e,a,o));const c=Mf.normalize(e,a,o),u=t.GetEase(),d=h[0],_=h[1],p=h[2],g=l[0],m=l[1],f=l[2],S=self.Ease.GetRuntimeEase(u),G=o-a,y=G*c;return Df[0]=d===g?d:S(y,d,g-d,G),Df[1]=_===m?_:S(y,_,m-_,G),Df[2]=p===f?p:S(y,p,f-p,G),Df}}}}{const Of=self.C3;Of.PropertyTrackState.TextTypeAdapter=class{constructor(){}static WillChange(e,t,s,i){let n;switch(i){case"behavior":case"plugin":n=t.GetPropertyValueByIndex(e);break;case"effect":n=t[e];break;case"instance-variable":n=t.GetInstanceVariableValue(e)}return n!==s}static Interpolate(e,t,s,i){if(!s){let e=i.GetPropertyTrackDataItem();return e=i.GetPropertyTrackData().GetLastPropertyKeyframeDataItem(e),e.GetValueWithResultMode()}return t.GetValueWithResultMode()}}}{const Bf=self.C3;Bf.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 Bf.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)Bf.TimelineDataManager._CreateDataItem("create",n,e,s,i)}static _CreateDataItemsIncludingDisabled(e,t,s,i){if(t)for(const n of t)Bf.TimelineDataManager._CreateDataItem("create-including-disabled",n,e,s,i)}static _LoadDataItemsFromJson(e,t,s,i){e.length?t.forEach((t,s)=>{e[s]._LoadFromJson(t)}):t.forEach(t=>{Bf.TimelineDataManager._CreateDataItem("load",t,e,s,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 s=t[i.prop],a=i.map.get(s);switch(e){case"load":r=new a(null,n);break;case"create":case"create-including-disabled":r=new a(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 Lf=self.C3,kf=0,Nf=1,Wf=2,Vf=3,Uf=4,jf=5,Hf=6,zf=7,Xf=8,Yf=9,qf=10,Kf=11;Lf.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[0],this._totalTime=e[1],this._step=e[2],this._interpolationMode=e[3],this._resultMode=e[4],this._loop=!!e[6],this._pingPong=!!e[7],this._repeatCount=e[8],this._startOnLayout=e[9],this._transformWithSceneGraph=!!e[10],this._useSystemTimescale=!!e[11],this._trackData=new Lf.TrackData(e[5],this))}Release(){this._trackData.Release(),this._trackData=null}GetTrackData(){return this._trackData||(this._trackData=new Lf.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 $f=self.C3,Jf=0,Zf=1,Qf=2,eS=1,tS=2,sS=3,iS=4,nS=5,rS=6,aS=7,oS=0,hS=1,lS=8,cS=0,uS=1,dS=9,_S=10;class pS{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[0]&&(this._instanceData=e[0],this._instanceUid=e[0][2],this._objectClassIndex=e[0][1]),this._interpolationMode=e[1],this._resultMode=e[2],this._enabled=!!e[3],e[6]&&(this._id=e[6]),e[7]&&(this._nestedData=e[7],this._startOffset=e[7][0],this._localTotalTime=e[7][1]),e[8]&&(this._additionalInstanceData=e[8]),e[8]&&(this._additionalInstanceData=e[8]),e[9]&&(this._type=e[9]),e[10]&&(this._name=e[10]),this._keyframeData=new $f.KeyframeData(e[4],this),this._propertyTrackData=new $f.PropertyTrackData(e[5],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 $f.KeyframeData(null,this)),this._keyframeData}GetPropertyTrackData(){return this._propertyTrackData||(this._propertyTrackData=new $f.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[0]}SetOriginalWidth(e){this._additionalInstanceData||(this._additionalInstanceData=[]),this._additionalInstanceData[0]=e}GetOriginalHeight(){return this._additionalInstanceData||(this._additionalInstanceData=[]),this._additionalInstanceData[1]}SetOriginalHeight(e){this._additionalInstanceData||(this._additionalInstanceData=[]),this._additionalInstanceData[1]=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?e.type:0,this._name=e.name?e.name:"",this._localTotalTime=this._trackData.GetTimelineDataItem().GetTotalTime(),e.nestedData&&(this._nestedData=e.nestedData,this._startOffset=this._nestedData[0],this._localTotalTime=this._nestedData[1]),e.additionalInstanceData&&(this._additionalInstanceData=e.additionalInstanceData),this.GetKeyframeData()._LoadFromJson(e.keyframeDataJson),this.GetPropertyTrackData()._LoadFromJson(e.propertyTrackDataJson))}}$f.TrackData=class{constructor(e,t){this._timelineDataItem=t,this._trackDataItems=[],$f.TimelineDataManager._CreateDataItems(this._trackDataItems,e,pS,this)}Release(){this._timelineDataItem=null;for(const e of this._trackDataItems)e.Release();$f.clearArray(this._trackDataItems),this._trackDataItems=null}GetTimelineDataItem(){return this._timelineDataItem}AddEmptyTrackDataItem(){const e=new pS(null,this);return this._trackDataItems.push(e),e}GetFirstKeyframeDataItem(e){return e.GetKeyframeData().GetKeyframeDataItemArray()[0]}GetLastKeyframeDataItem(e){return e.GetKeyframeData().GetKeyframeDataItemArray().at(-1)}GetKeyFrameDataItemAtTime(e,t){const s=t.GetKeyframeData().GetKeyframeDataItemArray(),i=s.length;for(let t=0;te)return i}}GetFirstKeyFrameDataItemHigherOrEqualThan(e,t){const s=t.GetKeyframeData().GetKeyframeDataItemArray(),i=s.length;for(let t=0;t=e)return i}}GetFirstKeyFrameDataItemLowerOrEqualThan(e,t){const s=t.GetKeyframeData().GetKeyframeDataItemArray();for(let t=s.length-1;t>=0;t--){const i=s[t];if(i.GetTime()<=e)return i}}*trackDataItems(){for(const e of this._trackDataItems)yield e}_SaveToJson(){return{trackDataItemsJson:this._trackDataItems.map(e=>e._SaveToJson())}}_LoadFromJson(e){e&&$f.TimelineDataManager._LoadDataItemsFromJson(this._trackDataItems,e.trackDataItemsJson,pS,this)}}}{const gS=self.C3,mS=0,fS=0,SS=1,GS=2,yS=3,IS=4,TS=5,CS=6,bS=7,wS=8,PS=9;class xS{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[0][0],this._sourceAdapterArguments=e[0].slice(1),this._property=e[1],this._type=e[2],this._min=e[3],this._max=e[4],this._interpolationMode=e[5],this._resultMode=e[6],this._enabled=!!e[7],this._propertyKeyframeData=new gS.PropertyKeyframeData(e[8],this),this._canHavePropertyKeyframes=e[9])}Release(){this._propertyKeyframeData.Release(),this._propertyKeyframeData=null,this._propertyTrackData=null,this._sourceAdapterArguments=null}GetPropertyTrackData(){return this._propertyTrackData}GetPropertyKeyframeData(){return this._propertyKeyframeData||(this._propertyKeyframeData=new gS.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))}}gS.PropertyTrackData=class{constructor(e,t){this._trackDataItem=t,this._propertyTrackDataItems=[],gS.TimelineDataManager._CreateDataItems(this._propertyTrackDataItems,e,xS,this)}Release(){this._trackDataItem=null;for(const e of this._propertyTrackDataItems)e.Release();gS.clearArray(this._propertyTrackDataItems),this._propertyTrackDataItems=null}GetTrackDataItem(){return this._trackDataItem}AddEmptyPropertyTrackDataItem(){const e=new xS(null,this);return this._propertyTrackDataItems.push(e),e}GetFirstPropertyKeyframeDataItem(e){return e.GetPropertyKeyframeData().GetPropertyKeyframeDataItemArray()[0]}GetLastPropertyKeyframeDataItem(e){return e.GetPropertyKeyframeData().GetPropertyKeyframeDataItemArray().at(-1)}GetPropertyKeyFrameDataItemAtTime(e,t){const s=t.GetPropertyKeyframeData().GetPropertyKeyframeDataItemArray(),i=s.length;for(let t=0;te)return i}}GetFirstPropertyKeyFrameDataItemHigherOrEqualThan(e,t){const s=t.GetPropertyKeyframeData().GetPropertyKeyframeDataItemArray(),i=s.length;for(let t=0;t=e)return i}}GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,t){const s=t.GetPropertyKeyframeData().GetPropertyKeyframeDataItemArray();for(let t=s.length-1;t>=0;t--){const i=s[t];if(i.GetTime()<=e)return i}}*propertyTrackDataItems(){for(const e of this._propertyTrackDataItems)yield e}_SaveToJson(){return{propertyTrackDataItemsJson:this._propertyTrackDataItems.map(e=>e._SaveToJson())}}_LoadFromJson(e){e&&gS.TimelineDataManager._LoadDataItemsFromJson(this._propertyTrackDataItems,e.propertyTrackDataItemsJson,xS,this)}}}{const vS=self.C3,AS=0,RS=1,MS=2,DS=3;class ES{constructor(e,t){if(this._keyframeData=t,this._time=-1,this._ease="noease",this._enable=!1,this._tags=null,this._lowerTags=null,!e)return;this._time=e[0],this._ease=e[1],this._enable=!!e[2];const s=e[3];this._tags=s?s.split(" "):[],this._lowerTags=new Set(this._tags.map(e=>e.toLowerCase())),this._next=null,this._last=null}Release(){this._keyframeData=null,vS.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}GetLast(){return this._last}SetLast(e){this._last=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())))}}vS.KeyframeData=class{constructor(e,t){this._trackDataItem=t,this._keyframeDataItems=[],vS.TimelineDataManager._CreateDataItems(this._keyframeDataItems,e,ES,this),this._LinkKeyframeDataItems()}Release(){this._trackDataItem=null;for(const e of this._keyframeDataItems)e.Release();vS.clearArray(this._keyframeDataItems),this._keyframeDataItems=null}_LinkKeyframeDataItems(){this._keyframeDataItems.sort((e,t)=>e.GetTime()-t.GetTime());for(let e=0;ee.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;e>=0;e--)yield this._keyframeDataItems[e]}_SaveToJson(){return{keyframeDataItemsJson:this._keyframeDataItems.map(e=>e._SaveToJson())}}_LoadFromJson(e){e&&(vS.TimelineDataManager._LoadDataItemsFromJson(this._keyframeDataItems,e.keyframeDataItemsJson,ES,this),this._LinkKeyframeDataItems())}}}{const FS=self.C3,OS=0,BS=0,LS=1,kS=2,NS=1,WS=2,VS=3,US=4,jS=5;class HS{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[0][0],this._aValue=e[0][1],this._type=e[0][2],this._time=e[1],this._ease=e[2],this._enable=!!e[3],this._pathMode=e[5],this._addonData=null,e[4]&&(this._addonData=new FS.AddonData(e[4],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&&FS.IsFiniteNumber(e)?(this._value[0]=FS.GetRValue(e),this._value[1]=FS.GetGValue(e),this._value[2]=FS.GetBValue(e)):this._value=e}GetAbsoluteValue(){return this._aValue}SetAbsoluteValue(e){"color"===this._type&&FS.IsFiniteNumber(e)?(this._aValue[0]=FS.GetRValue(e),this._aValue[1]=FS.GetGValue(e),this._aValue[2]=FS.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(e){if(!this._addonData)return;if(this._addonInstance||null===this._addonInstance)return this._addonInstance;const t=this._addonData.GetAddDataItemArray();if(!t)return this._addonInstance=null,this._addonInstance;const s=t.length;for(let i=0;ie.GetTime()-t.GetTime());for(let t=0;t=0&&s.SetPrevious(e[t-1])}e=this._propertyKeyframeDataItemsIncludingDisabled,e.sort((e,t)=>e.GetTime()-t.GetTime());for(let t=0;t=0&&s.SetPrevious(e[t-1])}}AddEmptyPropertyKeyframeDataItem(){const e=new HS(null,this);return this._propertyKeyframeDataItems.push(e),this._LinkPropertyKeyframeDataItems(),e}DeletePropertyKeyframeDataItems(e){for(const t of this._propertyKeyframeDataItems){if(!e(t))continue;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;e>=0;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&&(FS.TimelineDataManager._LoadDataItemsFromJson(this._propertyKeyframeDataItems,e.propertyKeyframeDataItemsJson,HS,this),FS.TimelineDataManager._LoadDataItemsFromJson(this._propertyKeyframeDataItemsIncludingDisabled,e.propertyKeyframeDataItemsIncludingDisabledJson,HS,this),this._LinkPropertyKeyframeDataItems())}}}{const zS=self.C3,XS=0,YS=1;class qS{constructor(e,t){this._addonData=t,this._id=e[0],this._data=e[1]}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 KS=0,$S=1,JS=2,ZS=3;class QS extends qS{constructor(e,t){super(e,t),this._startAnchor=this._data[0],this._startEnable=!!this._data[1],this._endAnchor=this._data[2],this._endEnable=!!this._data[3]}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 eG=0,tG=1;class sG extends qS{constructor(e,t){super(e,t),this._direction=this._data[0],this._revolutions=this._data[1]}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)}}zS.AddonData=class{constructor(e,t){this._propertyKeyframeDataItem=t,this._addonDataItems=[],zS.TimelineDataManager._CreateDataItems(this._addonDataItems,e,{prop:0,map:new Map([["cubic-bezier",QS],["angle",sG]])},this)}Release(){this._propertyKeyframeDataItem=null;for(const e of this._addonDataItems)e.Release();zS.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&&zS.TimelineDataManager._LoadDataItemsFromJson(this._addonDataItems,e.addonDataItemsJson,{prop:"id",map:new Map([["cubic-bezier",QS],["angle",sG]])},this)}}}{const iG=self.C3,nG="start-value",rG="current-state",aG=0,oG=1;let hG=0;iG.TweenState=class extends iG.TimelineState{constructor(e,t){super("tween-"+hG++,e,t),this._id="",this._destroyInstanceOnComplete=!1,this._initialValueMode="start-value",this._instance=null,this._on_completed_callbacks=null,this._on_started_callbacks=null,this._behInst=null,this._track=null,this._iTweenState=null}FireReleaseEvent(e){const t=iG.New(iG.Event,"tweenstatereleased");t.tweenState=this,e.dispatchEvent(t)}GetType(){return 1}CreateTrackStates(){for(const e of this._timelineDataItem.GetTrackData().trackDataItems())this._tracks.push(iG.TweenTrackState.Create(this,e));this._track=this._tracks[0]}AddTrack(){const e=this._timelineDataItem.GetTrackData().AddEmptyTrackDataItem(),t=iG.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)return;const t=e[0];if(this._track=t,!t)return;const s=t.GetInstance();return t.IsInstanceValid()?s:void 0}SetBehaviorInstance(e){this._behInst=e}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)return;const t=this._on_started_callbacks.indexOf(e);-1!==t&&this._on_started_callbacks.splice(t,1)}RemoveCompletedCallback(e){if(!this._on_completed_callbacks)return;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)continue;const s=i.GetPropertyTrackData(),n=i.GetPropertyTrackDataItem(),r=s.GetFirstPropertyKeyframeDataItem(n);r.SetValue(e),r.SetAbsoluteValue(e)}}_GetPropertyTrackState(e){for(const t of this._tracks)for(const s of t._propertyTracks)if(s.GetPropertyName()===e)return s}BeforeSetEndValues(e){let t=!1;for(const s of e){const e=this._GetPropertyTrackState(s);e&&(this.SetStartValue(e.GetCurrentState(),s),t=!0)}if(t){if(this.IsForwardPlayBack()){const e=this.GetTotalTime()-this.GetTime();this.SetTotalTime(e);for(const t of this._tracks)t.SetLocalTotalTime(e);this._SetTime(0)}else{const e=this.GetTime();this.SetTotalTime(e);for(const t of this._tracks)t.SetLocalTotalTime(e);this._SetTime(e)}this.SetInitialStateFromSetTime()}}SetEndValue(e,t){const s=this._GetPropertyTrackState(t);if(!s)return;const 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 e of this._tracks)e.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){iG.IsFiniteNumber(e)||(e=this.GetTotalTime()),e<0?this._playheadTime=0:e>=this.GetTotalTime()?this._playheadTime=this.GetTotalTime():this._playheadTime=e,this._track.SetResetState()}SetInitialState(e){if(!this.InitialStateSet()&&"current-state"===this.GetInitialValueMode())for(const e of this._tracks)e.CompareInitialStateWithCurrent();super.SetInitialState(e)}Stop(e=!1){if(super.Stop(e),!this.IsComplete())for(const e of this._tracks)e.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())return!0;const e=this.GetInstance();return!(e&&e.GetObjectClass().IsGlobal()||(this._timelineManager.CompleteTimelineBeforeChangeOfLayout(this),this.ResetBeforeChangeLayout(),0))}Tick(e,t,s){if(this._instance||(this._instance=this.GetInstance()),!this._instance||this._instance.IsDestroyed())return this.Stop(!0),void this.OnCompleted();const i=this._instance.GetTimeScale();if(-1!==i&&(e=s*i),0===e&&0===this._lastDelta)return;this._lastDelta=e;const n=this._playheadTime+this._overshoot+e*this._playbackRate,r=this._timelineDataItem._totalTime;n<0?(this._playheadTime=0,this._overshoot=-n):n>=r?(this._playheadTime=r,this._overshoot=this._playheadTime-n):(this._playheadTime=n,this._overshoot=0);let a=!1,o=!1;const h=this.GetLoop(),l=this.GetPingPong();if(h||l?h&&!l?this._playbackRate>0?this._playheadTime>=r&&(this._SetTimeAndReset(0),this._TweenTrigger(iG.Behaviors.Tween.Cnds.OnAnyTweenLoop),this._TweenTrigger(iG.Behaviors.Tween.Cnds.OnTweensLoop),o=!0):this._playheadTime<=0&&(this._SetTimeAndReset(r),this._TweenTrigger(iG.Behaviors.Tween.Cnds.OnAnyTweenLoop),this._TweenTrigger(iG.Behaviors.Tween.Cnds.OnTweensLoop),o=!0):!h&&l?this._playbackRate>0?this._playheadTime>=r&&(this._SetTime(r),this.SetPlaybackRate(-1*this.GetPlaybackRate()),o=!0,1===this._pingPongState?this._currentRepeatCount0?this._playheadTime>=r&&(this._SetTime(r),this.SetPlaybackRate(-1*this.GetPlaybackRate()),o=!0,0===this._pingPongState&&(this._TweenTrigger(iG.Behaviors.Tween.Cnds.OnAnyTweenPingPong),this._TweenTrigger(iG.Behaviors.Tween.Cnds.OnTweensPingPong)),1===this._pingPongState&&(this._TweenTrigger(iG.Behaviors.Tween.Cnds.OnAnyTweenLoop),this._TweenTrigger(iG.Behaviors.Tween.Cnds.OnTweensLoop),this._TweenTrigger(iG.Behaviors.Tween.Cnds.OnAnyTweenPingPong),this._TweenTrigger(iG.Behaviors.Tween.Cnds.OnTweensPingPong)),this.IsPlaying()?(this._pingPongState++,this._pingPongState=iG.wrap(this._pingPongState,0,2)):(this._resumePingPongState=this._pingPongState+1,this._resumePingPongState=iG.wrap(this._resumePingPongState,0,2))):this._playheadTime<=0&&(this._SetTime(0),this.SetPlaybackRate(-1*this.GetPlaybackRate()),o=!0,0===this._pingPongState&&(this._TweenTrigger(iG.Behaviors.Tween.Cnds.OnAnyTweenPingPong),this._TweenTrigger(iG.Behaviors.Tween.Cnds.OnTweensPingPong)),1===this._pingPongState&&(this._TweenTrigger(iG.Behaviors.Tween.Cnds.OnAnyTweenLoop),this._TweenTrigger(iG.Behaviors.Tween.Cnds.OnTweensLoop),this._TweenTrigger(iG.Behaviors.Tween.Cnds.OnAnyTweenPingPong),this._TweenTrigger(iG.Behaviors.Tween.Cnds.OnTweensPingPong)),this.IsPlaying()?(this._pingPongState++,this._pingPongState=iG.wrap(this._pingPongState,0,2)):(this._resumePingPongState=this._pingPongState+1,this._resumePingPongState=iG.wrap(this._resumePingPongState,0,2)))):this._playbackRate>0?this._playheadTime>=r&&(this._currentRepeatCounte.GetNeedsBeforeAndAfter())&&(this._needsBeforeAndAfter=1),this._lastKeyframeDataItem=this._GetLastKeyFrameBeforeTime(e),this._initialStateOfNestedSet=!1,this._endStateOfNestedSet=!1,this.Interpolate(e)}BeforeInterpolate(){}Interpolate(e,t=!1,s=!1,i=!1,n=!1,r=!1,a=!1){if(this._instance||this.GetInstance(),this._instance)return!this._instance.IsDestroyed()&&(!r||!this.GetObjectClass().IsGlobal())&&(this._secondPropertyTrack?(this._firstPropertyTrack.Interpolate(e,s,i,a),this._secondPropertyTrack.Interpolate(e,s,i,a)):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 cG=self.C3;cG.TweenPropertyTrackState=class extends cG.PropertyTrackState{constructor(e,t){super(e,t),this._basic=!1}static Create(e,t){return cG.New(cG.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),r=n.GetNext();else{if(this._lastPropertyKeyframeDataItem){const t=this.GetTimeline(),s=this._lastPropertyKeyframeDataItem.GetNext(),i=this._lastPropertyKeyframeDataItem.GetTime(),n=s?s.GetTime():t.GetTotalTime();(e<=i||e>=n)&&(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().AddEmptyPropertyKeyframeDataItem();return this._lastPropertyKeyframeDataItem=null,this._basic=this.GetPropertyKeyframeDataItems().length<=2,e}DeletePropertyKeyframes(e){this._lastPropertyKeyframeDataItem=null,this._propertyTrackDataItem.GetPropertyKeyframeData().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 uG=self.C3,dG=self.Ease,_G=0,pG=1,gG=2;uG.Transition=class extends uG.DefendedBase{constructor(e,t=!0){super(),this._name=e[0],this._linear=e[2],this._transitionKeyframes=[];for(const t of e[1]){const e=uG.TransitionKeyframe.Create(this,t);this._transitionKeyframes.push(e)}for(let e=0;ethis.Interpolate(e,t,s,i),null,{transition:this})}static Create(e){return uG.New(uG.Transition,e)}Release(){for(const e of this._transitionKeyframes)e.Release();uG.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 t of this._transitionKeyframes)if(t.GetValueX()===e)return this._transitionKeyframeCache.set(e,t),t}GetFirstTransitionKeyFrameLowerOrEqualThan(e){for(let t=this._transitionKeyframes.length-1;t>=0;t--){const s=this._transitionKeyframes[t],i=s.GetValueX();if(i<=e){let t=s;if(ithis._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)return;const t=e[0][16][0],s=e[1];this._templateDataMap.has(s)||this._templateDataMap.set(s,new Map),this._templateDataMap.get(s).set(t,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=0;if(s=e instanceof xG.ObjectClass?e.GetIndex():e,!this._templateDataMap.has(s))return;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"";return this._instanceToTemplateNameMap.get(e)||""}_OnInstanceDestroy(e){this._instanceToTemplateNameMap&&this._instanceToTemplateNameMap.has(e)&&this._instanceToTemplateNameMap.delete(e)}}}{const vG=self.C3;vG.FlowchartManager=class{constructor(e){this._runtime=e,this._flowchartDataManager=new vG.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 AG=self.C3;AG.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||(AG.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=AG.FlowchartState._GetTagArray(e);return!(!s||!s.length)&&s.every(AG.FlowchartState._HasTag,t)}CurrentNodeCompareTags(e,t){const s=this.GetCurrentNodeTags();if(!s)return!1;if(!s.length)return!1;const i=AG.FlowchartState._GetTagArray(e);return!(!i||!i.length)&&i.every(e=>AG.FlowchartState._CompareTag.call(s,e,t))}static _HasTag(e){const t=this;return""===e?1===t.length&&""===t[0]:t.map(e=>e.trim().toLowerCase()).includes(e.trim().toLowerCase())}static _GetTagArray(e){return e.trim().split(" ")}static _CompareTag(e,t){const s=this;return""===e?1===s.length&&""===s[0]:s.some(s=>AG.compare(s.trim(),t,e.trim()))}GetCurrentNodeParent(e){const t=this.GetCurrentNode();if(t){if(AG.IsFiniteNumber(e)){const s=t.GetParentFlowchartIds(),i=s?s[e]:void 0;if(AG.IsFiniteNumber(i))return this.GetFlowchartElementById(i)}if("string"==typeof e)for(const s of t.GetParentFlowchartIds()){const t=this.GetFlowchartElementById(s);if(t.HasTags(e))return this.GetFlowchartElementById(t.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(){this._GetRootFlowchartState()._Reset(!0)}_Reset(e){if(this._GetReferenceFlowchartStates()){for(const[e,t]of this._GetReferenceFlowchartStates().entries())t._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 e=this._startFlowchartNode.GetFlowchartId();e!==this._currentFlowchartNodeId&&this._GotoFlowchartNode(e)}else this._currentFlowchartNodeId=this._startFlowchartNode.GetFlowchartId()}GetCurrentNodeOutputCount(){const e=this._flowchartDataItem.GetFlowchartElementById(this._currentFlowchartNodeId);return e?e.GetFlowchartNodeOutputData().GetFlowchartNodeOutputDataItemCount():0}IsIndexOfDefaultOutput(e){return!(e<0)&&e===this.GetDefaultOutputIndex()}GetDefaultOutputIndex(){const e=this._flowchartDataItem.GetFlowchartElementById(this._currentFlowchartNodeId);if(!e)return-1;let t=e.GetFlowchartNodeOutputData().GetFlowchartNodeOutputDefault();return t?e.GetFlowchartNodeOutputData().GetFlowchartNodeOutputDataItems().indexOf(t):-1}GetCurrentNodeOutputNameAt(e){const t=this._GetFlowchartNodeOutputAt(e);return t?t.GetName():""}GetCurrentNodeOutputValueAt(e){let t;return AG.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():""}_MaybeByPassNodes(e,t){if(e.GetEnable())return e.GetFlowchartId();{const s=e.GetFlowchartNodeOutputData().GetFlowchartNodeOutputDefault();if(!s)return t.GetFlowchartId();const i=s.GetConnectedFlowchartNodeFlowchartId();if(!AG.IsFiniteNumber(i))return t.GetFlowchartId();const n=this.GetFlowchartElementById(i);return n?this._MaybeByPassNodes(n,t):t.GetFlowchartId()}}_MaybeByPassNodesInReferenceFlowchart(e,t){if(e.GetEnable()){if("reference"===e.GetType()){const t=e.GetReferenceFlowchartName(),s=e.GetReferenceFlowchartStartNodeTag(),i=this._flowchartManager.GetFlowchartDataItemByName(t);if(!i)return[-1,null];const n=i.GetFlowchartNodeByTags(s);return n?this._MaybeByPassNodesInReferenceFlowchart(n,i):this._MaybeByPassNodesInReferenceFlowchart(i.GetFlowchartStartNode(),i)}return[e.GetFlowchartId(),t]}{const s=e.GetFlowchartNodeOutputData().GetFlowchartNodeOutputDefault();if(!s)return[-1,null];const i=s.GetConnectedFlowchartNodeFlowchartId();if(!AG.IsFiniteNumber(i))return[-1,null];const n=t.GetFlowchartElementById(i);return n?this._MaybeByPassNodesInReferenceFlowchart(n,t):[-1,null]}}_ProcessAllByPasses(e,t){let s=this.GetFlowchartElementById(e);if(s){if(!s.GetEnable()){const t=this.GetFlowchartElementById(this._currentFlowchartNodeId);e=this._MaybeByPassNodes(s,t)}if(AG.IsFiniteNumber(e)&&e!==this._currentFlowchartNodeId)if(s=this.GetFlowchartElementById(e),"reference"===s.GetType()){const i=s.GetReferenceFlowchartName(),n=s.GetReferenceFlowchartStartNodeTag(),r=this._flowchartManager.GetFlowchartDataItemByName(i);let a=r.GetFlowchartNodeByTags(n);if(a){const s=this._MaybeByPassNodesInReferenceFlowchart(a,r);if(-1===s[0])return;t(this._currentFlowchartNodeId,e,s[1],s[0])}else t(this._currentFlowchartNodeId,e)}else t(this._currentFlowchartNodeId,e)}}GotoNextFlowchartNode(e){let t;if(AG.IsFiniteNumber(e)&&(t=this._GetFlowchartNodeOutputAt(e)),"string"==typeof e&&(t=this._GetFlowchartNodeOutputByName(e)),!t)return;let s=t.GetConnectedFlowchartNodeFlowchartId();AG.IsFiniteNumber(s)&&this._ProcessAllByPasses(s,(e,t,s,i)=>{this._previousFlowchartNodeIds.push(e),this._GotoFlowchartNode(t,s,i)})}GotoNextFlowchartNodeDefault(){const e=this._GetFlowchartNodeOutputDefault();if(!e)return;const t=e.GetConnectedFlowchartNodeFlowchartId();AG.IsFiniteNumber(t)&&this._ProcessAllByPasses(t,(e,t,s,i)=>{this._previousFlowchartNodeIds.push(e),this._GotoFlowchartNode(t,s,i)})}GotoAnyFlowchartNode(e){const t=this._flowchartDataItem.GetFlowchartNodeByTags(e);if(!t)return;const s=t.GetFlowchartId();AG.IsFiniteNumber(s)&&this._ProcessAllByPasses(s,(e,t,s,i)=>{this._previousFlowchartNodeIds.push(e),this._GotoFlowchartNode(t,s,i)})}GotoPreviousFlowchartNode(){const e=this._previousFlowchartNodeIds.pop();AG.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){if(!this.GetCurrentNode())return;const t=this.GetCurrentNodeParent(e);if(t){if(!t.GetEnable())return;const e=t.GetFlowchartId();if(!AG.IsFiniteNumber(e))return;this._previousFlowchartNodeIds.push(this._currentFlowchartNodeId),this._GotoFlowchartNode(t.GetFlowchartId())}}HasOutput(e){if(AG.IsFiniteNumber(e))return!!this._flowchartDataItem.GetFlowchartElementById(this._currentFlowchartNodeId).GetFlowchartNodeOutputData().GetFlowchartNodeOutputDataItems()[e];if("string"==typeof e){const t=this._flowchartDataItem.GetFlowchartElementById(this._currentFlowchartNodeId).GetFlowchartNodeOutputData().GetFlowchartNodeOutputDataItems();for(let s=0;s0}PushIsTriggerState(){this._triggerCount++}PopIsTriggerState(){this._triggerCount--,0===this._triggerCount&&this._markForRelease&&this._flowchartManager.RemoveFlowchartState(this)}_GotoFlowchartNode(e,t,s){const i=this._currentFlowchartNodeId,n=this.GetPluginInstance().GetInstance();this.PushIsTriggerState(),this._flowchartManager.PushFlowchartState(this),this._runtime.Trigger(AG.Plugins.Flowchart.Cnds.OnBeforeAnyNodeChange,n),this._runtime.Trigger(AG.Plugins.Flowchart.Cnds.OnBeforeTaggedNodeChange,n),this._runtime.Trigger(AG.Plugins.Flowchart.Cnds.OnBeforeAnyNodeChangeInFlowchart,n),this._runtime.Trigger(AG.Plugins.Flowchart.Cnds.OnBeforeTaggedNodeChangeInFlowchart,n),this._currentFlowchartNodeId=e;let r=this.GetFlowchartElementById(this._currentFlowchartNodeId);if("dictionary"===r.GetType()&&(this._runtime.Trigger(AG.Plugins.Flowchart.Cnds.OnAnyNodeChange,n),this._runtime.Trigger(AG.Plugins.Flowchart.Cnds.OnTaggedNodeChange,n),this._runtime.Trigger(AG.Plugins.Flowchart.Cnds.OnAnyNodeChangeInFlowchart,n),this._runtime.Trigger(AG.Plugins.Flowchart.Cnds.OnTaggedNodeChangeInFlowchart,n)),this._flowchartManager.PopFlowchartState(),this.PopIsTriggerState(),!this.WasReleased()&&(r=this.GetFlowchartElementById(this._currentFlowchartNodeId),"reference"===r.GetType())){const e=t?t.GetName():r.GetReferenceFlowchartName();if(this._HasReferenceFlowchartState(r)){this._previousFlowchartNodeIds.pop();const e=this._GetReferenceFlowchartState(r);this._flowchartManager.SetCurrentFlowchartState(e,!0,!0,!1),e._SetPreviousFlowchart(this,i),this._GetRootFlowchartState()._SetCurrentReferenceFlowchart(e)}else{const t="number"==typeof s?s:r.GetReferenceFlowchartStartNodeTag();if(e){this._previousFlowchartNodeIds.pop();let s=r.GetReferenceFlowchartTag();if(s){let e=this._flowchartManager.GetFlowchartState(s);for(;e;)s=AG.IncrementNumberAtEndOf(s),e=this._flowchartManager.GetFlowchartState(s)}else{s=`${e}-ref`;let t=this._flowchartManager.GetFlowchartState(s);for(;t;)s=AG.IncrementNumberAtEndOf(s),t=this._flowchartManager.GetFlowchartState(s)}const n=this._flowchartManager.AddFlowchartState(e,t,s,this._pluginInstance,!0);n._SetPreviousFlowchart(this,i),this._SetReferenceFlowchartState(r,n);const a=this._GetRootFlowchartState();n._SetRootFlowchartState(a),a._SetCurrentReferenceFlowchart(n)}}}}_GetFlowchartNodeOutputDefault(){const e=this._flowchartDataItem.GetFlowchartElementById(this._currentFlowchartNodeId);return e?e.GetFlowchartNodeOutputData().GetFlowchartNodeOutputDefault():null}_GetFlowchartNodeOutputAt(e){const t=this._flowchartDataItem.GetFlowchartElementById(this._currentFlowchartNodeId);if(!t)return null;const s=t.GetFlowchartNodeOutputData().GetFlowchartNodeOutputDataItems();if(!s)return null;return s[e]||null}_GetFlowchartNodeOutputByName(e){const t=this._flowchartDataItem.GetFlowchartElementById(this._currentFlowchartNodeId);if(!t)return null;return t.GetFlowchartNodeOutputData().GetFlowchartNodeOutputDataItemByName(e)||null}_SetStartFlowchartNode(e){if("number"==typeof e){let t=this.GetFlowchartElementById(e);t||(t=this._flowchartDataItem.GetFlowchartStartNode()),this._startFlowchartNode=t}else if("number"==typeof this._startNodeTag){let e=this.GetFlowchartElementById(this._startNodeTag);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:AG.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._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 RG=self.C3;RG.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(){RG.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}GetFlowchartDataItemByName(e){return this._runtime.GetFlowchartManager().GetFlowchartDataItemByName(e)}AddFlowchartState(e,t,s,i,n,r){const a=this._runtime.GetFlowchartManager().GetFlowchartDataItemByName(e);if(!a)return void console.warn(`[Flowcharts] no flowchart found with name '${e}'`);if(this._flowchartStates.has(s)){const e=this._flowchartStates.get(s);e&&this.RemoveFlowchartState(e)}const o=new RG.FlowchartState(e,s,t,a,this,i,r);return this._flowchartStates.set(s,o),n&&this.SetCurrentFlowchartState(o,!0),o}RemoveFlowchartState(e){if(e.MarkForRelease(),e.IsInTriggerState())return;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 t=e.GetCurrentReferenceFlowchart();e=t||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)return;if(this._currentFlowchartState.WasReleased())return;const e=this._currentFlowchartState.GetPluginInstance().GetInstance();this._currentFlowchartState.PushIsTriggerState(),this.PushFlowchartState(this._currentFlowchartState),this._runtime.Trigger(RG.Plugins.Flowchart.Cnds.OnBeforeFlowchartChange,e),this.PopFlowchartState(),this._currentFlowchartState.PopIsTriggerState()}_TriggerAfterFlowchartChange(e,t=!1,s=!1){if(this._currentFlowchartState=e,!this._currentFlowchartState)return;if(this._currentFlowchartState.WasReleased())return;const i=this._currentFlowchartState.GetPluginInstance().GetInstance();this._currentFlowchartState.PushIsTriggerState(),this.PushFlowchartState(this._currentFlowchartState),this._runtime.Trigger(RG.Plugins.Flowchart.Cnds.OnFlowchartChange,i),!0!==s&&"number"!=typeof s||this._currentFlowchartState._SetStartFlowchartNode(s),t&&(this._runtime.Trigger(RG.Plugins.Flowchart.Cnds.OnAnyNodeChange,i),this._runtime.Trigger(RG.Plugins.Flowchart.Cnds.OnTaggedNodeChange,i),this._runtime.Trigger(RG.Plugins.Flowchart.Cnds.OnAnyNodeChangeInFlowchart,i),this._runtime.Trigger(RG.Plugins.Flowchart.Cnds.OnTaggedNodeChangeInFlowchart,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)return;this._loadJson=e;const t=new Map;for(const e of this._loadJson.flowchartJsonObjects){const s=e.flowchartTag;if(this._flowchartStates.has(s)){const i=this._flowchartStates.get(s);i._LoadFromJson(e),t.set(s,i)}else{const s=this.AddFlowchartState(e.flowchartName,e.startNodeTag,e.flowchartTag,null,!1,e.pluginUID);s._LoadFromJson(e),t.set(e.flowchartTag,s)}}for(const[e,s]of this._flowchartStates.entries())t.has(e)||s.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 MG=self.C3;MG.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 MG.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 t=new s(n,i);e.push(t)}}}}{const DG=self.C3,EG=0,FG=1;DG.FlowchartDataItem=class{constructor(e){this._name=e[0],this._flowchartNodeData=new DG.FlowchartNodeData(e[1],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 OG=self.C3,BG=0,LG=1,kG=2,NG=3,WG=4,VG=5,UG=6,jG=7,HG=8,zG=8,XG=9,YG=10,qG=11;class KG{constructor(e,t){this._flowchartNodeData=t,this._type=e[7],this._flowchartId=e[0],this._tag=e[1],this._tag?this._tags=this._tag.trim().split(" ").map(e=>e.trim()):this._tags=[],this._parentFlowchartIds=e[2],this._parentOutputFlowchartIds=null,this._childrenFlowchartIds=null,this._enable=!1,"dictionary"===this._type&&(this._parentOutputFlowchartIds=e[3],this._childrenFlowchartIds=e[4],this._enable=e[8]),this._isStart=e[6],this._referenceFlowchartName=null,this._referenceFlowchartStartNodeTag=null,this._referenceFlowchartTag=null,"reference"===this._type&&(this._referenceFlowchartName=e[8],this._referenceFlowchartStartNodeTag=e[9],this._referenceFlowchartTag=e[10],this._enable=e[11]),this._flowchartNodeOutputData=new OG.FlowchartNodeOutputData(e[5],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=OG.FlowchartState._GetTagArray(e);return!(!t||!t.length)&&t.every(OG.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}GetEnable(){return this._enable}GetReferenceFlowchartName(){return this._referenceFlowchartName}GetReferenceFlowchartStartNodeTag(){return this._referenceFlowchartStartNodeTag}GetReferenceFlowchartTag(){return this._referenceFlowchartTag}}OG.FlowchartNodeData=class{constructor(e,t){this._flowchartDataItem=t,this._flowchartNodeItems=[],this._flowchartNodeItemsIdMap=new Map,this._flowchartNodeItemsTagMap=new Map,this._flowchartNodeStartItem=null,OG.FlowchartDataManager.CreateDataItems(this._flowchartNodeItems,e,KG,this);for(const e of this._flowchartNodeItems){const t=e.GetFlowchartId(),s=e.GetTag(),i=e.GetTags(),n=e.GetIsStart();if(this._flowchartNodeItemsIdMap.set(t,e),s)for(const t of i)this._flowchartNodeItemsTagMap.has(t)||this._flowchartNodeItemsTagMap.set(t,new Set),this._flowchartNodeItemsTagMap.get(t).add(e);n&&(this._flowchartNodeStartItem=e);const r=e.GetFlowchartNodeOutputData();for(const e of r.flowchartNodeOutputDataItems()){const t=e.GetFlowchartId();this._flowchartNodeItemsIdMap.set(t,e)}}this._flowchartNodeStartItem||this._SetStartNodeIfMissing()}Release(){this._flowchartDataItem=null;for(const e of this._flowchartNodeItems)e.Release();OG.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 t=[];for(const s of e.trim().split(" ")){let e=this._flowchartNodeItemsTagMap.get(s.trim())??new Set;if(0===e.size)return null;t.push(e)}return[...t.reduce((e,t)=>t.sizet.every(t=>t.has(e)))[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 e of this.flowchartNodeDataItems())if(e.CanBeStartNode()&&!e.GetIsStart())return void e.SetIsStart(!0)}else{if(1===e)return;if(e>1){let e=!0;for(const t of this.flowchartNodeDataItems())t.CanBeStartNode()&&(t.GetIsStart()&&e?e=!1:t.GetIsStart()&&!e&&t.SetIsStart(!1))}}for(const e of this.flowchartNodeDataItems())if(e.CanBeStartNode()&&e.GetIsStart())return void(this._flowchartNodeStartItem=e)}}}{const $G=self.C3,JG=0,ZG=1,QG=2,ey=3,ty=4,sy=5;class iy{constructor(e,t){this._flowchartNodeOutputData=t,this._flowchartId=e[0],this._name=e[1],this._value=e[2],this._connectedFlowchartNodeFlowchartId=e[3],this._enable=e[4],this._default=e[5]}Release(){this._flowchartNodeOutputData=null}GetFlowchartNodeOutputData(){return this._flowchartNodeOutputData}GetFlowchartId(){return this._flowchartId}GetName(){return this._name}GetValue(){return this._value}GetConnectedFlowchartNodeFlowchartId(){return this._connectedFlowchartNodeFlowchartId}GetEnable(){return this._enable}GetDefault(){return this._default}}$G.FlowchartNodeOutputData=class{constructor(e,t){this._flowchartDataNodeItem=t,this._flowchartNodeOutputItems=[],this._flowchartNodeOutputItemsNameMap=new Map,$G.FlowchartDataManager.CreateDataItems(this._flowchartNodeOutputItems,e,iy,this),this._enabledFlowchartNodeOutputItems=this._flowchartNodeOutputItems.filter(e=>e.GetEnable());for(const e of this._enabledFlowchartNodeOutputItems)this._flowchartNodeOutputItemsNameMap.set(e.GetName(),e)}Release(){this._flowchartDataNodeItem=null;for(const e of this._flowchartNodeOutputItems)e.Release();$G.clearArray(this._flowchartNodeOutputItems),this._flowchartNodeOutputItems=null,$G.clearArray(this._enabledFlowchartNodeOutputItems),this._enabledFlowchartNodeOutputItems=null}GetFlowchartNodeDataItem(){return this._flowchartDataNodeItem}GetFlowchartNodeOutputDataItemCount(){return this._enabledFlowchartNodeOutputItems.length}GetFlowchartNodeOutputDataItems(){return this._enabledFlowchartNodeOutputItems}GetFlowchartNodeOutputDataItemByName(e){return this._flowchartNodeOutputItemsNameMap.get(e)}GetFlowchartNodeOutputDefault(){for(const e of this._enabledFlowchartNodeOutputItems)if(e.GetDefault())return e}*flowchartNodeOutputDataItems(){for(const e of this._enabledFlowchartNodeOutputItems)yield e}}}{const ny=self.C3;ny.SolStack=class extends ny.DefendedBase{constructor(e){super(),this._objectClass=e,this._stack=[],this._stack.push(ny.New(ny.Sol,this)),this._index=0,this._current=this._stack[0]}Release(){for(const e of this._stack)e.Release();ny.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 t=ny.New(ny.Sol,this);e.push(t),this._current=t}else{const s=e[t];s.Reset(),this._current=s}}PushCopy(){const e=this._stack,t=++this._index;t===e.length&&e.push(ny.New(ny.Sol,this));const s=e[t];s.Copy(e[t-1]),this._current=s}Pop(){this._current=this._stack[--this._index]}RemoveInstances(e){const t=this._stack;for(let s=0,i=t.length;s=0}GetCurrent(){return this._stack[this._index]}Push(){if(++this._index,this._index===this._stack.length){const e=ly.New(ly.Loop,this);return this._stack.push(e),e}{const e=this._stack[this._index];return e.Reset(),e}}Pop(){--this._index}FindByName(e){const t=this._stack;for(let s=this._index;s>=0;--s){const i=t[s];if(i.GetName()===e)return i}return null}_GetStack(){return this._stack.slice(0,this._index+1)}}}{const cy=self.C3;cy.Loop=class extends cy.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 uy=self.C3;uy.ArrayStack=class extends uy.DefendedBase{constructor(){super(),this._stack=[],this._index=-1}Release(){uy.clearArray(this._stack)}GetCurrent(){return this._stack[this._index]}Push(){if(++this._index,this._index===this._stack.length){const e=[];return this._stack.push(e),e}return this._stack[this._index]}Pop(){--this._index}}}{let dy=function(e,t){return e.GetIndex()-t.GetIndex()},_y=function(e,t){for(let s=0,i=e.length;sthis._InvokeFunctionFromJS(e,t)}Release(){this.ClearAllScheduledWaits(),this._eventStack.Release(),this._eventStack=null,this._localVarStack.Release(),this._localVarStack=null,py.clearArray(this._queuedTriggers),py.clearArray(this._queuedDebugTriggers),this._runtime=null,py.clearArray(this._allSheets),this._sheetsByName.clear()}Create(e){const t=py.New(py.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 e of this._functionBlocksByName.values())e._PostInit();for(const e of this._customActionBlocksMap.values())e._PostInit();for(const e of this._allSheets)e._PostInit();for(const e of this._allSheets)e._UpdateDeepIncludes();for(const e of this._triggersToPostInit)e._PostInit(!1);py.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.push(e):this._allLocalVars.push(e)}_DeduplicateSolModifierList(e){e.length>=2&&e.sort(dy);let t=this._allUniqueSolModifiers.get(e.length);t||(t=[],this._allUniqueSolModifiers.set(e.length,t));for(let s=0,i=t.length;si=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();n(yield*this._DebugTrigger(e,t,s,i))}}async RunQueuedDebugTriggersAsync(){for(const e of this._RunQueuedDebugTriggersGen())await this._runtime.DebugBreak(e)}_FastTrigger(e,t,s,i){let n=!1;const r=e.GetMainRunningLayout(),a=r.GetEventSheet();if(!a)return;this._executingTriggerDepth++,this._runtime.PushCurrentLayout(r);const o=a.deepIncludes();for(let e=0,r=o.length;e0}_IncTriggerDepth(){return++this._executingTriggerDepth}_DecTriggerDepth(){--this._executingTriggerDepth}IsRunningEvents(){return this._runningEventsDepth>0}IsInEventEngine(){return this.IsRunningEvents()||this.IsInTrigger()}_RunQueuedTriggers(e){for(const[t,s,i]of this._queuedTriggers)this._Trigger(e,t,s,i);py.clearArray(this._queuedTriggers)}BlockFlushingInstances(e){e?this._blockFlushingDepth++:this._blockFlushingDepth--}IsFlushingBlocked(){return this._blockFlushingDepth>0}ClearSol(e){for(let t=0,s=e.length;t0){for(const e of s)e.GetSolStack().PushClean();return[...s]}return null}AddScheduledWait(){const e=py.New(py.ScheduledWait,this);return this._scheduledWaits.push(e),e}scheduledWaits(){return this._scheduledWaits}RunScheduledWaits(){if(!this._scheduledWaits.length)return;const e=this.GetCurrentEventStackFrame();let t=!1;this._runningEventsDepth++;for(let s=0,i=this._scheduledWaits.length;se.ShouldRelease());for(const t of e)t.Release()}ClearAllScheduledWaits(){for(const e of this._scheduledWaits)e.Release();py.clearArray(this._scheduledWaits)}_OnInstancesReleased(e){for(const t of this._scheduledWaits)t.RemoveInstances(e);for(const t of e){const e=this._instSignals.get(t);if(this._instSignals.delete(t),e)for(const{resolve:t}of e.signalPromises.values())t(!0)}}AddAsyncActionPromise(e){this._asyncActionPromises.push({promise:e,triggerDepth:this.GetTriggerDepth()})}ClearAsyncActionPromises(){py.clearArray(this._asyncActionPromises)}GetPromiseForAllAsyncActions(){const e=this.GetTriggerDepth(),t=Promise.all(this._asyncActionPromises.filter(t=>t.triggerDepth===e).map(e=>e.promise));return this._asyncActionPromises=this._asyncActionPromises.filter(t=>t.triggerDepthe=t);return this._signalPromises.set(t,{promise:s,resolve:e}),s}}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 t of this._runtime.GetEventSheetManager().scheduledWaits())t.IsInstanceSignals()&&t.GetSignalTag()===i&&t.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 e=null;const t=new Promise(t=>e=t);return s.signalPromises.set(i,{promise:t,resolve:e}),t}}GetCurrentInstanceSignalTag(e){const t=this._GetInstanceSignalState(e);if(!t||0===t.signalTags.length)throw new Error("not in a signal");return t.signalTags.at(-1)}_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 e=parseInt(t,10),i=this.GetEventGroupBySID(e);i&&i.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[e,s]of this._cndsBySid)s._LoadFromJson(t.get(e)||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[e,s]of this._actsBySid)s._LoadFromJson(t.get(e)||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 e=parseInt(t,10),i=this.GetEventVariableBySID(e);i&&i.SetValue(s)}}_SaveScheduledWaitsToJson(){return this._scheduledWaits.filter(e=>!e.IsPromise()).map(e=>e._SaveToJson())}_LoadScheduledWaitsFromJson(e){this.ClearAllScheduledWaits();for(const t of e){const e=py.ScheduledWait._CreateFromJson(this,t);e&&this._scheduledWaits.push(e)}}_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 py.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.length1;l&&n.GetLocalVarStack().Push();const c=a.Push(t);e&&(t.GetConditions()[s].GetObjectClass().GetCurrentSol().SetSinglePicked(e),e.IsInContainer()&&e.SetSiblingsSinglePicked());let u=!0;if(t.GetParent()){const e=t.GetTriggerParents();for(let t=0,s=e.length;t1;l&&n.GetLocalVarStack().Push();const c=a.Push(t);e&&(t.GetConditions()[s].GetObjectClass().GetCurrentSol().SetSinglePicked(e),e.IsInContainer()&&e.SetSiblingsSinglePicked());let u=!0;if(t.GetParent()){const e=t.GetTriggerParents();for(let t=0,s=e.length;t0){let e=!1;for(const t of this._actions)t._PostInit(),t.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 t=this._subEvents;for(let e=0,s=t.length;ee.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;do{e._UpdateCanRunFast(),e=e.GetParent()}while(e)}_IdentifyTopLevelGroup(){if(!this.IsGroup())return;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=Sy.cloneArray(this._solModifiers);let e=this.GetParent();for(;e;){for(const t of e._solModifiers)this._AddParentSolModifier(t);e=e.GetParent()}const t=this.GetEventSheetManager();this._solModifiers=t._DeduplicateSolModifierList(this._solModifiers),this._solModifiersIncludingParents=t._DeduplicateSolModifierList(this._solModifiersIncludingParents)}}_IdentifyTriggerParents(){if(!this.HasAnyTriggeredCondition())return;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 e of this._containedIncludes)e.UpdateActive();if(this._containedIncludes.length){const e=this._runtime.GetCurrentLayout().GetEventSheet();e&&e._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 Sy.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)return!0;--t;const s=e.IsSystemOrSingleGlobalCondition()?e.GetFirstObjectParameterObjectClass():e.GetObjectClass();for(;t>=0;--t){const e=this._conditions[t];if(s===e.GetObjectClass()||e.IsSystemOrSingleGlobalCondition()&&e.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(e){e=Math.floor(e);const t=this._actions.find(t=>t.GetDebugIndex()===e);if(!t)throw new RangeError("invalid action debug index");return t}_HasActionIndex(e){return(e=Math.floor(e))>=0&&ee instanceof Sy.EventVariable)}RunPreTrigger(e){e.SetCurrentEvent(this);const t=this._conditions;let s=0===t.length;for(let i=0,n=t.length;i0)if(s){const s=t.map(e=>e.Get(0));e.GetLocalVarStack().Push(),this._scopeParent.SetFunctionParameters(s)}else this._scopeParent.EvaluateFunctionParameters(t);else s&&e.GetLocalVarStack().Push()}RunAsFunctionCall(e,t,s,i){let n,r;const a=e.length>0;let o=null;const h=this._runtime,l=this._eventStack,c=h.GetEventSheetManager(),u=this._scopeParent,d=u.IsAsync(),_=c._IncTriggerDepth()>1;if(this._EvaluateFunctionCallParameters(c,t,_),a&&(s?c.PushCopySol(e):c.PushCleanSol(e)),null!==i){if(i.copyFromObjectClass){const e=s?i.copyFromObjectClass.GetCurrentSol():i.copyFromObjectClass.GetSolStack().GetOneBelowCurrentSol(),t=i.copyToObjectClass.GetCurrentSol();t.SetArrayPicked(e.GetInstances()),t.ClearElseInstances(),s||i.copyToObjectClass.ApplySolToContainer()}else if(i.pickObjectClass){const e=i.pickObjectClass.GetCurrentSol();e.SetArrayPicked(i.pickInstances),e.ClearElseInstances()}i.pushCleanSolDynamic&&(o=c.PushCleanSolDynamic(e))}const p=l.Push(this);return s&&p.SetDynamicSolModifiers(e),this._CheckParentsOKToRun(p)&&(p.SetCurrentEvent(this),d&&([r,n]=u.StartAsyncFunctionCall()),this._RunAndBlock(p),d&&u.MaybeFinishAsyncFunctionCall(r)),l.Pop(),_&&c.GetLocalVarStack().Pop(),null!==o&&c.PopSol(o),a&&c.PopSol(e),c._DecTriggerDepth(),n}*DebugRunAsFunctionCall(e,t,s,i){let n,r;(this.IsDebugBreakpoint()||this._runtime.DebugBreakNext())&&(yield this);const a=e.length>0;let o=null;const h=this._runtime,l=this._eventStack,c=h.GetEventSheetManager(),u=this._scopeParent,d=u.IsAsync(),_=c._IncTriggerDepth()>1;if(this._EvaluateFunctionCallParameters(c,t,_),a&&(s?c.PushCopySol(e):c.PushCleanSol(e)),null!==i){if(i.copyFromObjectClass){const e=s?i.copyFromObjectClass.GetCurrentSol():i.copyFromObjectClass.GetSolStack().GetOneBelowCurrentSol(),t=i.copyToObjectClass.GetCurrentSol();t.SetArrayPicked(e.GetInstances()),t.ClearElseInstances(),s||i.copyToObjectClass.ApplySolToContainer()}else if(i.pickObjectClass){const e=i.pickObjectClass.GetCurrentSol();e.SetArrayPicked(i.pickInstances),e.ClearElseInstances()}i.pushCleanSolDynamic&&(o=c.PushCleanSolDynamic(e))}const p=l.Push(this);return s&&p.SetDynamicSolModifiers(e),(yield*this._DebugCheckParentsOKToRun(p))&&(p.SetCurrentEvent(this),d&&([r,n]=u.StartAsyncFunctionCall()),yield*this._DebugRunAndBlock(p),d&&u.MaybeFinishAsyncFunctionCall(r)),l.Pop(),_&&c.GetLocalVarStack().Pop(),null!==o&&c.PopSol(o),a&&c.PopSol(e),c._DecTriggerDepth(),n}RunAsMappedFunctionCall(e,t){const s=this.GetSolModifiersIncludingParents(),i=s.length>0,n=this._runtime,r=this._eventStack,a=n.GetEventSheetManager(),o=a._IncTriggerDepth()>1;o&&a.GetLocalVarStack().Push(),this._scopeParent.SetFunctionParameters(e),i&&(t?a.PushCopySol(s):a.PushCleanSol(s));const h=r.Push(this);this._CheckParentsOKToRun(h)&&(h.SetCurrentEvent(this),this._RunAndBlock(h)),r.Pop(),o&&a.GetLocalVarStack().Pop(),i&&a.PopSol(s),a._DecTriggerDepth()}*DebugRunAsMappedFunctionCall(e,t){(this.IsDebugBreakpoint()||this._runtime.DebugBreakNext())&&(yield this);const s=this.GetSolModifiersIncludingParents(),i=s.length>0,n=this._runtime,r=this._eventStack,a=n.GetEventSheetManager(),o=a._IncTriggerDepth()>1;o&&a.GetLocalVarStack().Push(),this._scopeParent.SetFunctionParameters(e),i&&(t?a.PushCopySol(s):a.PushCleanSol(s));const h=r.Push(this);(yield*this._DebugCheckParentsOKToRun(h))&&(h.SetCurrentEvent(this),yield*this._DebugRunAndBlock(h)),r.Pop(),o&&a.GetLocalVarStack().Pop(),i&&a.PopSol(s),a._DecTriggerDepth()}RunAsExpressionFunctionCall(e,t,s,i,...n){let r,a;const o=e.length>0,h=this._runtime,l=this._eventStack,c=h.GetEventSheetManager(),u=this._scopeParent,d=u.IsAsync(),_=c._IncTriggerDepth()>1;_&&c.GetLocalVarStack().Push(),n.length>0&&this._scopeParent.SetFunctionParameters(n),o&&(t?c.PushCopySol(e):c.PushCleanSol(e));const p=l.Push(this);return p.InitCallFunctionExpression(s,i),l.PushExpFunc(p),h.SetDebuggingEnabled(!1),this._CheckParentsOKToRun(p)&&(p.SetCurrentEvent(this),d&&([a,r]=u.StartAsyncFunctionCall()),this._RunAndBlock(p),d&&u.MaybeFinishAsyncFunctionCall(a)),h.SetDebuggingEnabled(!0),l.Pop(),l.PopExpFunc(),_&&c.GetLocalVarStack().Pop(),o&&c.PopSol(e),c._DecTriggerDepth(),r||p.GetFunctionReturnValue()}}}{const Iy=self.C3,Ty=[];let Cy=!1;Iy.EventScript=class extends Iy.DefendedBase{constructor(e,t,s){super();const i=e.GetRuntime(),n=e.GetEventSheetManager();this._eventSheet=e,this._eventSheetManager=n,this._runtime=e.GetRuntime(),this._parent=t;const r=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 Iy.New(Iy.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 Ty}GetSolModifiersIncludingParents(){return this._parent?this._parent.GetSolModifiersIncludingParents():Ty}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),Cy||(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"),Cy=!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 Cy}static SetHadUserScriptException(){Cy=!0}}}{const by=self.C3,wy=self.assert;by.FunctionBlock=class extends by.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=by.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=>by.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=>by.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=by.New(by.FunctionBlock,e,t,s),n=s[1];return i.InitFunctionBlock(n),i}static CreateCustomACEBlock(e,t,s){const i=by.New(by.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(e){const t=this._functionParameters;for(let s=0,i=t.length;se.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++;let t;this._currentAsyncId=e;const 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(){return this._asyncMap.get(this._currentAsyncId).pauseCount++,this._currentAsyncId}ResumeAsyncFunction(e){this._currentAsyncId=e,this._asyncMap.get(e).pauseCount--}RunAsFamilyCustomActionWithOverrides(e,t){const s=new Map,i=[];for(const e of this._objectClass.GetCurrentSol().GetInstances()){const t=e.GetObjectClass();if(t.HasOwnCustomActionByName(this._aceName)){const i=s.get(t);Array.isArray(i)?i.push(e):s.set(t,[e])}else i.push(e)}if(i.length>0&&this._eventBlock.RunAsFunctionCall(e,t,this._isCopyPicked,{pickObjectClass:this._objectClass,pickInstances:i}),s.size>0)for(const[i,n]of s){const s=i.GetOwnCustomActionByName(this._aceName).GetEventBlock(),r=[...new Set([...e,...s.GetSolModifiers()])];s.RunAsFunctionCall(r,t,this._isCopyPicked,{pickObjectClass:i,pickInstances:n})}}*DebugRunAsFamilyCustomActionWithOverrides(e,t){const s=new Map,i=[];for(const e of this._objectClass.GetCurrentSol().GetInstances()){const t=e.GetObjectClass();if(t.HasOwnCustomActionByName(this._aceName)){const i=s.get(t);Array.isArray(i)?i.push(e):s.set(t,[e])}else i.push(e)}if(i.length>0&&(yield*this._eventBlock.DebugRunAsFunctionCall(e,t,this._isCopyPicked,{pickObjectClass:this._objectClass,pickInstances:i})),s.size>0)for(const[i,n]of s){const s=i.GetOwnCustomActionByName(this._aceName).GetEventBlock(),r=[...new Set([...e,...s.GetSolModifiers()])];yield*s.DebugRunAsFunctionCall(r,t,this._isCopyPicked,{pickObjectClass:i,pickInstances:n})}}}}{const Py=self.C3,xy=[];Py.EventVariable=class extends Py.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 Py.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 Py.New(Py.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 xy}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),e}ResetToInitialValue(){this._value=this._initialValue}_GetScriptInterfaceDescriptor(){return{configurable:!1,enumerable:!0,get:this._scriptGetter,set:this._scriptSetter}}}}{const vy=self.C3,Ay=self.assert,Ry=[];vy.EventInclude=class extends vy.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 vy.New(vy.EventInclude,e,t,s)}_PostInit(){this._includeSheet=this._eventSheetManager.GetEventSheetByName(this._includeSheetName),this._eventSheet._AddShallowInclude(this);let e=this.GetParent();for(;e;)e instanceof vy.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 Ry}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 vy.EventBlock&&e.IsGroup()&&!e.IsGroupActive())return void(this._isActive=!1);e=e.GetParent()}this._isActive=!0}}}{let My=function(e,t){return e>=t?e%t:e<0?(e<=-t&&(e%=t),e<0&&(e+=t),e):e};WrapIndex=My;const Dy=self.C3,Ey=self.assert;Dy.ExpNode=class extends Dy.DefendedBase{constructor(e){super(),this._owner=e,this._runtime=e.GetRuntime()}_PostInit(){}static CreateNode(e,t){const s=t[0],i=[ky,By,Ly,Ny,Fy,Oy];return Dy.New(i[s],e,t)}};class Fy extends Dy.ExpNode{constructor(e,t){super(e),this._systemPlugin=this._runtime.GetSystemPlugin(),this._func=this._runtime.GetObjectReference(t[1]),this._func!==Dy.Plugins.System.Exps.random&&this._func!==Dy.Plugins.System.Exps.choose||this._owner.SetVariesPerInstance()}GetBoundMethod(){return this._systemPlugin._GetBoundACEMethod(this._func,this._systemPlugin)}}class Oy extends Dy.ExpNode{constructor(e,t){super(e),this._functionBlock=null,this._functionName=t[1],this._owner.SetVariesPerInstance()}_PostInit(){const e=this._runtime.GetEventSheetManager();this._functionBlock=e.GetFunctionBlockByName(this._functionName),this._functionName=null;const t=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 Dy.EventBlock.prototype.RunAsExpressionFunctionCall.bind(t,this._combinedSolModifiers,e.IsCopyPicked(),e.GetReturnType(),e.GetDefaultReturnValue())}{const t=e.GetDefaultReturnValue();return()=>t}}}class By extends Dy.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=My(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=My(e,n);return this._eventStack.GetCurrentStackFrame().SetExpressionObjectClass(s),this._func.apply(i[r].GetSdkInstance(),t)}}class Ly extends Dy.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;return 0===t?this._returnsString?"":0:e[My(this._owner.GetSolIndex(),t)]._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=t[My(this._owner.GetSolIndex(),s)],n=i.GetObjectClass().GetFamilyInstanceVariableOffset(e.GetFamilyIndex());return i._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;const n=s[My(e,i)];let r=0;return t.IsFamily()&&(r=n.GetObjectClass().GetFamilyInstanceVariableOffset(t.GetFamilyIndex())),n._GetInstanceVariableValueUnchecked(this._varIndex+r)}}class ky extends Dy.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;const n=My(this._owner.GetSolIndex(),i);this._eventStack.GetCurrentStackFrame().SetExpressionObjectClass(t);const r=s[n];let 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;const r=My(e,n);this._eventStack.GetCurrentStackFrame().SetExpressionObjectClass(s);const a=i[r];let o=0;return s.IsFamily()&&(o=a.GetObjectClass().GetFamilyBehaviorOffset(s.GetFamilyIndex())),this._func.apply(a.GetBehaviorInstances()[this._behaviorIndex+o].GetSdkInstance(),t)}}class Ny extends Dy.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 Wy=function(e){const t=self.C3_ExpressionFuncs[e];if(!t)throw new Error("invalid expression number");return t};GetExpressionFunc=Wy;const Vy=self.C3,Uy=self.assert;Vy.Parameter=class extends Vy.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=[jy,Hy,Jy,Xy,qy,zy,Ky,jy,Xy,Xy,Zy,Qy,Jy,tI,Hy,$y,Yy,eI,sI,iI,nI,rI];return Vy.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 jy extends Vy.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=this._numberedNodes.length)throw new RangeError("invalid numbered node");return this._numberedNodes[e]}_PostInit(){for(const e of this._numberedNodes)e._PostInit();const e=Wy(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 Hy extends jy{constructor(e,t,s,i){super(e,t,s,i),this.Get=this.GetStringExpression,14===t&&(this.GetEventBlock().SetAllSolModifiers(),this._owner instanceof Vy.Action&&this.GetEventBlock().SetSolWriterAfterCnds())}GetStringExpression(e){this._solIndex=e;const t=this._expressionFunc();return"string"==typeof t?t:""}_GetFastTriggerValue(){return Wy(this._expressionNumber)()}}class zy extends jy{constructor(e,t,s,i){super(e,t,s,i),e.GetImplementationSdkVersion()>=2?this.Get=this.GetILayer:this.Get=this.GetLayer,this._isConstant=!1}GetLayer(e){this._solIndex=e;const t=this._expressionFunc();return this.GetRuntime().GetCurrentLayout().GetLayer(t)}GetILayer(e){const t=this.GetLayer(e);return t?t.GetILayer():null}}class Xy extends Vy.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 Yy extends Vy.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 qy extends Vy.Parameter{constructor(e,t,s,i){super(e,t,s),this._objectClass=this.GetRuntime().GetObjectClassByIndex(i[1]),e.GetImplementationSdkVersion()>=2?this.Get=this.GetIObjectClass:this.Get=this.GetObjectClass;const n=this.GetEventBlock();n._AddSolModifier(this._objectClass),this._owner instanceof Vy.Action?n.SetSolWriterAfterCnds():n.GetParent()&&n.GetParent().SetSolWriterAfterCnds(),this._isConstant=!0}GetObjectClass(){return this._objectClass}GetIObjectClass(){return this._objectClass?this._objectClass.GetIObjectClass():null}}class Ky extends Vy.Parameter{constructor(e,t,s,i){super(e,t,s),this._layout=this.GetRuntime().GetLayoutManager().GetLayoutByName(i[1]),e.GetImplementationSdkVersion()>=2?this.Get=this.GetILayout:this.Get=this.GetLayout,this._isConstant=!0}GetLayout(){return this._layout}GetILayout(){return this._layout?this._layout.GetILayout():null}}class $y extends Vy.Parameter{constructor(e,t,s,i){super(e,t,s),this._timeline=this.GetRuntime().GetTimelineManager().GetTimelineByName(i[1]),e.GetImplementationSdkVersion()>=2?this.Get=this.GetITimelineState:this.Get=this.GetTimeline,this._isConstant=!0}GetTimeline(){return this._timeline}GetITimelineState(){return this._timeline?this._timeline.GetITimelineState():null}}class Jy extends Vy.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 Zy extends Vy.Parameter{constructor(e,t,s,i){super(e,t,s),this._instVarIndex=i[1];const n=this._owner.GetObjectClass();this._owner instanceof Vy.Condition&&this._owner.IsStatic()?(this.Get=this.GetInstanceVariable,this._isConstant=!0):n&&n.IsFamily()?(this.Get=this.GetFamilyInstanceVariable,this.SetVariesPerInstance()):(this.Get=this.GetInstanceVariable,this._isConstant=!0)}GetInstanceVariable(){return this._instVarIndex}GetFamilyInstanceVariable(e){e=e||0;const t=this._owner.GetObjectClass(),s=t.GetCurrentSol(),i=s.GetInstances();let n=null;if(i.length)n=i[e%i.length].GetObjectClass();else if(s.HasAnyElseInstances()){const t=s.GetElseInstances();n=t[e%t.length].GetObjectClass()}else{if(!(t.GetInstanceCount()>0))return 0;{const s=t.GetInstances();n=s[e%s.length].GetObjectClass()}}return this._instVarIndex+n.GetFamilyInstanceVariableOffset(t.GetFamilyIndex())}}class Qy extends Vy.Parameter{constructor(e,t,s,i){super(e,t,s),this._eventVarSid=i[1],this._eventVar=null,e.GetImplementationSdkVersion()>=2?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 eI extends Vy.Parameter{constructor(e,t,s,i){super(e,t,s),this._functionBlockName=i[1],this._functionBlock=null,e.GetImplementationSdkVersion()>=2?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 tI extends Vy.Parameter{constructor(e,t,s,i){super(e,t,s),this._subParams=[],this._variadicRet=[],this._isConstant=!0;for(let e=1,t=i.length;e0,this._isFastTrigger=2===t[3],this._isLooping=!!t[4],this._isInverted=!!t[5],this._isStatic=!!t[6],this._sid=t[7],this._isInOrBlock=this._eventBlock.IsOrBlock(),this._objectClass=null,this._behaviorType=null,this._behaviorIndex=-1,this._systemPlugin=null,this.Run=cI,this.DebugRun=cI,this._parameters=[],this._results=[],this._anyParamVariesPerInstance=!1,this._savedData=null,this._unsavedData=null,this._debugData=this._runtime.IsDebug()?{isBreakpoint:t[8][0],canDebug:t[8][1]}:null,-1===t[0]?this._systemPlugin=this._runtime.GetSystemPlugin():(this._objectClass=this._runtime.GetObjectClassByIndex(t[0]),t[2]&&(this._behaviorType=this._objectClass.GetBehaviorTypeByName(t[2]),this._behaviorIndex=this._objectClass.GetBehaviorIndexByName(t[2])),this._eventBlock.GetParent()&&this._eventBlock.GetParent().SetSolWriterAfterCnds()),10===t.length){let e=t[9];for(let t of e)this._parameters.push(oI.Parameter.Create(this,t,this._parameters.length)),this._results.push(0)}0===this._parameters.length&&(this._parameters=lI,this._results=lI),this._eventBlock.GetEventSheetManager()._RegisterCondition(this)}static Create(e,t,s){return oI.New(oI.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 s=e._GetBoundACEMethod(i,t);this.Run=n?function(){return oI.xor(s(),n)}:s}else if(1===r.length){const s=r[0];if(!n&&s.IsConstant())this.Run=e._GetBoundACEMethod_1param(i,t,s.Get(0));else{const r=e._GetBoundACEMethod(i,t);this.Run=function(){return oI.xor(r(s.Get(0)),n)}}}else if(2===r.length){const s=r[0],a=r[1];if(!n&&s.IsConstant()&&a.IsConstant())this.Run=e._GetBoundACEMethod_2params(i,t,s.Get(0),a.Get(0));else{const r=e._GetBoundACEMethod(i,t);this.Run=function(){return oI.xor(r(s.Get(0),a.Get(0)),n)}}}else if(3===r.length){const s=r[0],a=r[1],o=r[2];if(!n&&s.IsConstant()&&a.IsConstant()&&o.IsConstant())this.Run=e._GetBoundACEMethod_3params(i,t,s.Get(0),a.Get(0),o.Get(0));else{const r=e._GetBoundACEMethod(i,t);this.Run=function(){return oI.xor(r(s.Get(0),a.Get(0),o.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 aI(this._parameters,e),oI.xor(this._func.apply(this._systemPlugin,e),this._isInverted)}*_DebugRunSystem(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const e=this._results;aI(this._parameters,e);let t=this._func.apply(this._systemPlugin,e);return oI.IsIterator(t)&&(t=yield*t),oI.xor(t,this._isInverted)}return this.Run()}_RunSingleGlobal(){const e=this._results;aI(this._parameters,e);const t=this._objectClass.GetSingleGlobalInstance().GetSdkInstance();return oI.xor(this._func.apply(t,e),this._isInverted)}*_DebugRunSingleGlobal(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const e=this._results;aI(this._parameters,e);const t=this._objectClass.GetSingleGlobalInstance().GetSdkInstance();let s=this._func.apply(t,e);return oI.IsIterator(s)&&(s=yield*s),oI.xor(s,this._isInverted)}return this.Run()}_RunFastTrigger(){return!0}*_DebugRunFastTrigger(){return(this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),!0}_GetStaticConditionThis(){return this._behaviorType?this._behaviorType.GetBehavior().GetSdkVersion()>=2?this._behaviorType.GetIBehaviorType():this._behaviorType:this._objectClass.GetPlugin().GetSdkVersion()>=2?this._objectClass.GetIObjectClass():this._objectClass}_RunStatic(){const e=this._results;aI(this._parameters,e);const t=this._func.apply(this._GetStaticConditionThis(),e);return this._objectClass.ApplySolToContainer(),t}*_DebugRunStatic(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const e=this._results;aI(this._parameters,e);let t=this._func.apply(this._GetStaticConditionThis(),e);return oI.IsIterator(t)&&(t=yield*t),this._objectClass.ApplySolToContainer(),t}return this.Run()}_RunObject(){const e=this._parameters,t=this._results,s=this._objectClass.GetCurrentSol();for(let s=0,i=e.length;s=0,a=t.GetInstances(),o=this._anyParamVariesPerInstance,h=this._results,l=this._func,c=this._isInverted,u=this._isInOrBlock&&!this._isTrigger;e.ClearArrays();for(let t=0,d=a.length;t=0,o=this._anyParamVariesPerInstance,h=this._results,l=this._func,c=this._isInverted,u=this._isInOrBlock&&!this._isTrigger,d=e._GetOwnInstances(),_=e._GetOwnElseInstances(),p=u&&!this._eventBlock.IsFirstConditionOfType(this),g=p?_:d;let m=0,f=!1;for(let e=0,t=g.length;e=0,o=this._results,h=this._func,l=this._isInverted;for(let t=0,c=e.length;t[e[0].GetUID(),e[1].GetUID(),e[2]])),e[t]=i}return{ex:e}}_LoadFromJson(e){if(this._savedData&&(this._savedData.clear(),this._savedData=null),!e)return;const t=this._runtime,s=e.ex;if(s){const e=this.GetSavedDataMap();e.clear();for(const[i,n]of Object.entries(s)){let s=n;"collmemory"===i&&(s=oI.New(oI.PairMap,n.map(e=>[t.GetInstanceByUID(e[0]),t.GetInstanceByUID(e[1]),e[2]]).filter(e=>e[0]&&e[1]))),e.set(i,s)}}}}}{let uI=function(e,t){for(let s=0,i=e.length;s=4?t[3]:-1,this._actionType=t.length>=5?255&t[4]:0,this._flags=t.length>=5?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=gI,this.DebugRun=gI,this._parameters=[],this._results=[],this._anyParamVariesPerInstance=!1,this._savedData=null,this._unsavedData=null;const n=-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 e=i.GetObjectReference(t[1]);this._func=e,this.Run=this.RunUserScript,this.DebugRun=this.DebugRunUserScript,this._flags|=8}else this._objectClass=i.GetObjectClassByIndex(t[0]),4&this._flags?(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 e=t[6];for(const t of e)this._parameters.push(dI.Parameter.Create(this,t,this._parameters.length)),this._results.push(0)}0===this._parameters.length&&(this._parameters=pI,this._results=pI),this.CanPickAnyObjectClass()&&(this._eventBlock.SetAllSolModifiers(),this._eventBlock.SetSolWriterAfterCnds()),this._eventBlock.GetEventSheetManager()._RegisterAction(this)}static Create(e,t,s){return dI.New(dI.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)4&this._flags?this._SetCallCustomActionRunMethod():this._SetCallFunctionRunMethod(),this._callFunctionName="",this._callCustomAceObjectClass=null;else if(this.Run===this.RunUserScript){const e=this._func,t=this._runtime.GetEventSheetManager()._GetLocalVariablesScriptInterface(this._eventBlock);this._func=e.bind(null,this._runtime.GetIRuntime(),t)}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())?(uI(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(),t=e.GetFunctionBlockByName(this._callFunctionName);if(t.IsEnabled()){const s=!!(2&this._flags);this._callEventBlock=t.GetEventBlock();let i=[...new Set([...this._eventBlock.GetSolModifiersIncludingParents(),...this._callEventBlock.GetSolModifiersIncludingParents()])];i=e._DeduplicateSolModifierList(i);const n=!t.IsCopyPicked()&&this._HasCopyPickedParent()?{pushCleanSolDynamic:!0}:null;if(this.Run=dI.EventBlock.prototype.RunAsFunctionCall.bind(this._callEventBlock,i,this._parameters,s,n),this._runtime.IsDebug()){const e=this;this.DebugRun=function*(){return(e.IsBreakpoint()||e._runtime.DebugBreakNext())&&(yield e),yield*e._callEventBlock.DebugRunAsFunctionCall(i,e._parameters,s,n)}}else this.DebugRun=mI}else this.Run=gI,this.DebugRun=mI}_SetCallCustomActionRunMethod(){const e=this._eventBlock.GetEventSheetManager(),t=e.GetCustomActionBlockByName(this._callCustomAceObjectClass,this._callFunctionName);if(t.IsEnabled()){const s=!!(2&this._flags);this._callEventBlock=t.GetEventBlock();let i=[...new Set([...this._eventBlock.GetSolModifiersIncludingParents(),...this._callEventBlock.GetSolModifiersIncludingParents(),this._objectClass,t.GetObjectClass()])];i=e._DeduplicateSolModifierList(i);const n=!this._objectClass.IsFamily()&&!t.GetObjectClass().IsFamily(),r=!this._objectClass.IsFamily()&&t.GetObjectClass().IsFamily(),a=this._objectClass.IsFamily();let o=null;if(!t.IsCopyPicked()&&this._HasCopyPickedParent()&&(o=o||{},o.pushCleanSolDynamic=!0),!r&&s||(o=o||{},o.copyFromObjectClass=this._objectClass,o.copyToObjectClass=t.GetObjectClass()),n||r||a&&!t.HasCustomACEOverrides()?this.Run=dI.EventBlock.prototype.RunAsFunctionCall.bind(this._callEventBlock,i,this._parameters,s,o):a&&(this.Run=dI.FunctionBlock.prototype.RunAsFamilyCustomActionWithOverrides.bind(t,i,this._parameters)),this._runtime.IsDebug()){const e=this;n||r||a&&!t.HasCustomACEOverrides()?this.DebugRun=function*(){return(e.IsBreakpoint()||e._runtime.DebugBreakNext())&&(yield e),yield*e._callEventBlock.DebugRunAsFunctionCall(i,e._parameters,s,o)}:a&&(this.DebugRun=function*(){return(e.IsBreakpoint()||e._runtime.DebugBreakNext())&&(yield e),yield*t.DebugRunAsFamilyCustomActionWithOverrides(i,e._parameters)})}else this.DebugRun=mI}else this.Run=gI,this.DebugRun=mI}_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 s=n[0];if(s.IsConstant())this.Run=e._GetBoundACEMethod_1param(i,t,s.Get(0));else{const n=e._GetBoundACEMethod(i,t);this.Run=function(){return n(s.Get(0))}}}else if(2===n.length){const s=n[0],r=n[1];if(s.IsConstant()&&r.IsConstant())this.Run=e._GetBoundACEMethod_2params(i,t,s.Get(0),r.Get(0));else{const n=e._GetBoundACEMethod(i,t);this.Run=function(){return n(s.Get(0),r.Get(0))}}}else if(3===n.length){const s=n[0],r=n[1],a=n[2];if(s.IsConstant()&&r.IsConstant()&&a.IsConstant())this.Run=e._GetBoundACEMethod_3params(i,t,s.Get(0),r.Get(0),a.Get(0));else{const n=e._GetBoundACEMethod(i,t);this.Run=function(){return n(s.Get(0),r.Get(0),a.Get(0))}}}else this.Run=s}GetSID(){return this._sid}IsAsync(){return!!(8&this._flags)}CanBailOut(){return!!(16&this._flags)}CallBeforeAfterHooks(){return 1===this._actionType}IsStatic(){return 2===this._actionType}CanPickAnyObjectClass(){return!!(1&this._flags)}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 dI.FunctionBlock&&e.IsCopyPicked())return!0;e=e.GetScopeParent()}while(e);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 uI(this._parameters,e),this._func.apply(this._systemPlugin,e)}*_DebugRunSystem(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const e=this._results;return uI(this._parameters,e),yield*this._func.apply(this._systemPlugin,e)}return this.Run()}_RunSingleGlobal(){const e=this._results;return uI(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;return uI(this._parameters,e),yield*this._func.apply(this._objectClass.GetSingleGlobalInstance().GetSdkInstance(),e)}return this.Run()}_RunObject_ParamsConst(){const e=this._results,t=this._objectClass.GetCurrentSol().GetInstances();for(let s=0,i=t.length;s=2?this._behaviorType.GetIBehaviorType():this._behaviorType:this._objectClass.GetPlugin().GetSdkVersion()>=2?this._objectClass.GetIObjectClass():this._objectClass}_RunObject_Static(){const e=this._results;return uI(this._parameters,e),this._func.apply(this._GetStaticActionThis(),e)}*_DebugRunObject_Static(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const e=this._results;uI(this._parameters,e);let t=this._func.apply(this._GetStaticActionThis(),e);return dI.IsIterator(t)&&(t=yield*t),t}return this._RunObject_Static()}_RunBehavior(){const e=this._objectClass,t=e.IsFamily(),s=e.GetFamilyIndex(),i=this._parameters,n=this._anyParamVariesPerInstance,r=this._results,a=this._func,o=this._behaviorIndex,h=e.GetCurrentSol().GetInstances();for(let e=0,t=i.length;et.GetWidth()||s.getTop()>t.GetHeight()},NI.PickDistance=function(e,t,s){const i=PI(this).GetCurrentSol(),n=i.GetInstances();if(!n.length)return!1;let r=n[0],a=r.GetWorldInfo(),o=r,h=LI.distanceSquared(a.GetX(),a.GetY(),t,s);for(let i=1,l=n.length;ih)&&(h=l,o=r)}return i.PickOne(o),!0},WI.SetX=function(e){const t=this.GetWorldInfo();t.GetX()!==e&&(t.SetX(e),t.SetBboxChanged())},VI.SetX=function(e){this.x=+e},WI.SetY=function(e){const t=this.GetWorldInfo();t.GetY()!==e&&(t.SetY(e),t.SetBboxChanged())},VI.SetY=function(e){this.y=+e},WI.SetPos=function(e,t){const s=this.GetWorldInfo();s.EqualsXY(e,t)||(s.SetXY(e,t),s.SetBboxChanged())},VI.SetPos=function(e,t){this.setPosition(e,t)},NI.SetPosToObject=function(e,t){if(!(e=PI(e)))return;const s=TI(this),i=e.GetPairedInstance(s);if(!i)return;const[n,r]=i.GetImagePoint(t),a=s.GetWorldInfo();a.GetX()===n&&a.GetY()===r||(a.SetXY(n,r),a.SetBboxChanged())},NI.MoveForward=function(e){if(0===e)return;const t=CI(this);t.OffsetXY(t.GetCosAngle()*e,t.GetSinAngle()*e),t.SetBboxChanged()},WI.MoveAtAngle=function(e,t){if(0===t)return;const s=this.GetWorldInfo();e=LI.toRadians(e),s.OffsetXY(Math.cos(e)*t,Math.sin(e)*t),s.SetBboxChanged()},VI.MoveAtAngle=function(e,t){0!==t&&(e=LI.toRadians(e),this.offsetPosition(Math.cos(e)*t,Math.sin(e)*t))},WI.GetX=function(){return this.GetWorldInfo().GetX()},VI.GetX=function(){return this.x},WI.GetY=function(){return this.GetWorldInfo().GetY()},VI.GetY=function(){return this.y},NI.GetDt=function(){return UI.GetDt(TI(this))},WI.CompareWidth=function(e,t){return LI.compare(this.GetWorldInfo().GetWidth(),e,t)},VI.CompareWidth=function(e,t){return LI.compare(this.width,e,t)},WI.CompareHeight=function(e,t){return LI.compare(this.GetWorldInfo().GetHeight(),e,t)},VI.CompareHeight=function(e,t){return LI.compare(this.height,e,t)},WI.SetWidth=function(e){const t=this.GetWorldInfo();t.GetWidth()!==e&&(t.SetWidth(e),t.SetBboxChanged())},VI.SetWidth=function(e){this.width=e},WI.SetHeight=function(e){const t=this.GetWorldInfo();t.GetHeight()!==e&&(t.SetHeight(e),t.SetBboxChanged())},VI.SetHeight=function(e){this.height=e},WI.SetSize=function(e,t){const s=CI(this);s.GetWidth()===e&&s.GetHeight()===t||(s.SetSize(e,t),s.SetBboxChanged())},VI.SetSize=function(e,t){this.setSize(e,t)},WI.GetWidth=function(){return this.GetWorldInfo().GetWidth()},VI.GetWidth=function(){return this.width},WI.GetHeight=function(){return this.GetWorldInfo().GetHeight()},VI.GetHeight=function(){return this.height},NI.GetBboxLeft=function(){return CI(this).GetBoundingBox().getLeft()},NI.GetBboxTop=function(){return CI(this).GetBoundingBox().getTop()},NI.GetBboxRight=function(){return CI(this).GetBoundingBox().getRight()},NI.GetBboxBottom=function(){return CI(this).GetBoundingBox().getBottom()},NI.GetBboxMidX=function(){const e=CI(this).GetBoundingBox();return(e.getLeft()+e.getRight())/2},NI.GetBboxMidY=function(){const e=CI(this).GetBoundingBox();return(e.getTop()+e.getBottom())/2},NI.IsAngleWithin=function(e,t){return LI.angleDiff(CI(this).GetAngle(),LI.toRadians(t))<=LI.toRadians(e)},NI.IsAngleClockwiseFrom=function(e){return LI.angleClockwise(CI(this).GetAngle(),LI.toRadians(e))},NI.IsBetweenAngles=function(e,t){const s=LI.toRadians(e),i=LI.toRadians(t),n=CI(this).GetAngle();return LI.angleClockwise(i,s)?LI.angleClockwise(n,s)&&!LI.angleClockwise(n,i):!(!LI.angleClockwise(n,s)&&LI.angleClockwise(n,i))},WI.SetAngle=function(e){const t=this.GetWorldInfo(),s=LI.clampAngle(LI.toRadians(e));isNaN(s)||t.GetAngle()===s||(t.SetAngle(s),t.SetBboxChanged())},VI.SetAngle=function(e){this.angleDegrees=e},NI.RotateClockwise=function(e){if(isNaN(e)||0===e)return;const t=CI(this);t.SetAngle(t.GetAngle()+LI.toRadians(e)),t.SetBboxChanged()},NI.RotateCounterclockwise=function(e){if(isNaN(e)||0===e)return;const t=CI(this);t.SetAngle(t.GetAngle()-LI.toRadians(e)),t.SetBboxChanged()},NI.RotateTowardAngle=function(e,t){const s=CI(this),i=s.GetAngle(),n=LI.angleRotate(i,LI.toRadians(t),LI.toRadians(e));isNaN(n)||i===n||(s.SetAngle(n),s.SetBboxChanged())},NI.RotateTowardPosition=function(e,t,s){const i=CI(this),n=i.GetAngle(),r=t-i.GetX(),a=s-i.GetY(),o=Math.atan2(a,r),h=LI.angleRotate(n,o,LI.toRadians(e));isNaN(h)||n===h||(i.SetAngle(h),i.SetBboxChanged())},NI.SetTowardPosition=function(e,t){const s=CI(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())},WI.GetAngle=function(){return LI.toDegrees(this.GetWorldInfo().GetAngle())},VI.GetAngle=function(){return this.angleDegrees},NI.CompareOpacity=function(e,t){return LI.compare(LI.roundToDp(100*CI(this).GetOpacity(),6),e,t)},WI.IsVisible=function(){return this.GetWorldInfo().IsVisible()},VI.IsVisible=function(){return this.isVisible},NI.SetVisible=function(e){const t=CI(this);e=2===e?!t.IsVisible():0!==e,t.IsVisible()!==e&&(t.SetVisible(e),UI.UpdateRender())},NI.SetOpacity=function(e){const t=LI.clamp(e/100,0,1),s=CI(this);if(s.GetTransformWithParentOpacity()){if(s._GetSceneGraphInfo().GetOwnOpacity()===t)return}else if(s.GetOpacity()===t)return;s.SetOpacity(t),UI.UpdateRender()},NI.SetDefaultColor=function(e){kI.setFromRgbValue(e);const t=CI(this);t.GetUnpremultipliedColor().equalsIgnoringAlpha(kI)||(t.SetUnpremultipliedColor(kI),UI.UpdateRender())},NI.GetColor=function(){const e=CI(this).GetUnpremultipliedColor();return LI.PackRGBAEx(e.getR(),e.getG(),e.getB(),e.getA())},NI.GetOpacity=function(){return LI.roundToDp(100*CI(this).GetOpacity(),6)},NI.IsOnLayer=function(e){return!!(e=xI(e))&&CI(this).GetLayer()===e},NI.PickTopBottom=function(e){const t=PI(this).GetCurrentSol(),s=t.GetInstances();if(!s.length)return!1;let i=s[0];for(let t=1,n=s.length;th||o===h&&r.GetZIndex()>a.GetZIndex())&&(i=n):(oRI(p,e.instance)));const g=a.GetCurrentSol(),m=e.GetCurrentSol(),f=g.GetInstances();let S=null;for(let t=0;tRI(g,e.instance)));const m=o.GetCurrentSol(),f=e.GetCurrentSol(),S=m.GetInstances();let G=null;for(let t=0;t0&&(a=a.concat(t))}if(0===a.length)return!1;const o=r.IsSelectAll()?null:new Set(a),h=new Set;for(let s=0,i=n.length;s0&&(a=a.concat(t))}if(0===a.length)return!1;const o=r.IsSelectAll()?null:new Set(a),h=new Set;for(let s=0,i=n.length;s0&&(o=o.concat(t))}if(0===o.length)return!1;const h=a.IsSelectAll()?null:new Set(o),l=[];for(let i=0,n=r.length;io)&&(o=c,a=h)}return i.PickOne(a),!0},NI.PickByUID=function(e){const t=PI(this);return t.GetRuntime().GetCurrentCondition().IsInverted()?BI(t,e):OI(t,e)},NI.HasTags=function(e){const t=new Set(LI.splitStringAndNormalize(e)),s=TI(this).GetTagsSet();return t.isSubsetOf(s)},NI.Tags=function(){return TI(this).GetTagsString()},NI.TagsCount=function(){return TI(this).GetTagsSet().size},NI.TagAt=function(e){return TI(this).GetTagAt(e)},NI.ChangeTags=function(e,t){const s=LI.splitStringAndNormalize(t);if(0===s.length)return;const i=TI(this),n=new Set(i.GetTagsSet());if(0===e)for(const e of s)n.add(e);else if(1===e)for(const e of s)n.delete(e);i.SetTagsSet(n)},NI.Destroy=function(){UI.DestroyInstance(TI(this))},NI.OnCreated=function(){return!0},NI.OnDestroyed=function(){return!0},WI.SetInstanceVar=function(e,t){this.GetInstance().SetInstanceVariableValue(e,t)},VI.SetInstanceVar=function(e,t){bI(this).SetInstanceVariableValue(e,t)},WI.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)},VI.AddInstanceVar=function(e,t){const s=bI(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)},WI.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))},VI.SubInstanceVar=function(e,t){const s=bI(this),i=s.GetInstanceVariableValue(e);"number"==typeof i&&("number"!=typeof t&&(t=parseFloat(t)),s.SetInstanceVariableValue(e,i-t))},WI.SetBoolInstanceVar=function(e,t){this.GetInstance().SetInstanceVariableValue(e,t?1:0)},VI.SetBoolInstanceVar=function(e,t){bI(this).SetInstanceVariableValue(e,t?1:0)},WI.ToggleBoolInstanceVar=function(e){const t=this.GetInstance();t.SetInstanceVariableValue(e,0===t.GetInstanceVariableValue(e)?1:0)},VI.ToggleBoolInstanceVar=function(e){const t=bI(this);t.SetInstanceVariableValue(e,0===t.GetInstanceVariableValue(e)?1:0)},NI.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=TI(this),i="state";UI.ClearIntancesNeedingAfterLoad(),s._OnBeforeLoad(i),s.LoadFromJson(t,i),UI.DoAfterLoad(i,{setFromJson:!0})},NI.AsJSON=function(){return JSON.stringify(TI(this).SaveToJson("state"))},NI.ObjectTypeName=function(){return TI(this).GetObjectClass().GetName()},NI.Count=function(){const e=UI.GetCurrentEventStackFrame().GetExpressionObjectClass();let t=e.GetInstanceCount();for(const s of UI.instancesPendingCreateForObjectClass(e))++t;return t},NI.PickedCount=function(){return UI.GetCurrentEventStackFrame().GetExpressionObjectClass().GetCurrentSol().GetInstances().length},WI.GetIID=function(){return this.GetInstance().GetIID()},VI.GetIID=function(){return bI(this).GetIID()},WI.GetUID=function(){return this.GetInstance().GetUID()},VI.GetUID=function(){return bI(this).GetUID()},NI.OnInstanceSignal=function(e){const t=TI(this);return e.toLowerCase()===UI.GetEventSheetManager().GetCurrentInstanceSignalTag(t)},NI.InstanceSignal=function(e){const t=TI(this);UI.GetEventSheetManager().InstanceSignal(t,e)},NI.InstanceWaitForSignal=function(e){const t=PI(this);return UI.GetEventSheetManager().AddScheduledWait().InitInstanceSignals(t.GetCurrentSol().GetInstances(),e),!0},NI.TemplateName=function(){return TI(this).GetTemplateName()},LI.AddCommonACEs=function(e,t,s){const i=e[1],n=e[3],r=e[4],a=e[5],o=e[6],h=e[7],l=e[8],c=e[10],u=e[11],d=e[12],_=e[13],p=e[14],g=e[15],m=e[16],f=t.Cnds,S=t.Acts,G=t.Exps,y=Object.assign({},NI,s>=2?VI:WI);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,G.X=y.GetX,G.Y=y.GetY,G.dt=y.GetDt),r&&(f.CompareWidth=y.CompareWidth,f.CompareHeight=y.CompareHeight,S.SetWidth=y.SetWidth,S.SetHeight=y.SetHeight,S.SetSize=y.SetSize,G.Width=y.GetWidth,G.Height=y.GetHeight,G.BBoxLeft=y.GetBboxLeft,G.BBoxTop=y.GetBboxTop,G.BBoxRight=y.GetBboxRight,G.BBoxBottom=y.GetBboxBottom,G.BBoxMidX=y.GetBboxMidX,G.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,G.Angle=y.GetAngle),o&&(f.IsVisible=y.IsVisible,f.CompareOpacity=y.CompareOpacity,S.SetVisible=y.SetVisible,S.SetOpacity=y.SetOpacity,S.SetDefaultColor=y.SetDefaultColor,G.Opacity=y.GetOpacity,G.ColorValue=y.GetColor),h&&(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,G.LayerNumber=y.LayerNumber,G.LayerName=y.LayerName,G.ZIndex=y.ZIndex,G.ZElevation=y.ZElevation,G.TotalZElevation=y.TotalZElevation),l&&(f.IsEffectEnabled=y.IsEffectEnabled,S.SetEffectEnabled=y.SetEffectEnabled,S.SetEffectParam=y.SetEffectParam),_&&(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,G.ParentUID=y.ParentUID,G.ChildCount=y.ChildCount,G.AllChildCount=y.AllChildCount),p&&(S.SetMeshSize=y.SetMeshSize,S.SetMeshPoint=y.SetMeshPoint,G.MeshColumns=y.MeshColumns,G.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),d&&(f.IsEnabled=y.IsElementEnabled,S.SetEnabled=y.SetElementEnabled),g&&(f.OnCollision=y.OnCollision,f.IsOverlapping=y.IsOverlapping,f.IsOverlappingOffset=y.IsOverlappingOffset,t.FinishCollisionCondition=FI),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),G.AsJSON||(G.AsJSON=y.AsJSON),G.Count=y.Count,G.PickedCount=y.PickedCount,G.IID=y.GetIID,G.UID=y.GetUID,G.ObjectTypeName=y.ObjectTypeName,G.Tags=y.Tags,G.TagsCount=y.TagsCount,G.TagAt=y.TagAt,f.OnInstanceSignal=y.OnInstanceSignal,S.InstanceSignal=y.InstanceSignal,S.InstanceWaitForSignal=y.InstanceWaitForSignal),m&&(G.TemplateName=y.TemplateName)}}{const eT=self.C3;eT.ScheduledWait=class extends eT.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,eT.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();this._event=s.GetCurrentEvent(),this._actIndex=s.GetActionIndex()+1;const i=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 e of t){const t=e.GetCurrentSol();t.IsSelectAll()&&!this._event.HasSolModifier(e)||(this._solModifiers.push(e),this._sols.set(e,eT.New(eT.SolState,t)))}const n=e.GetDynamicSolModifiersSet();this._dynamicSolModifiers=n.size>0?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[e,t]of this._sols.entries()){const s=e.GetCurrentSol();t._Restore(s)}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 t of e)this._pendingInstances.delete(t);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[t,s]of this._sols)e[t.GetSID().toString()]=s._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 s=e.GetActionBySID(t.act);if(!s)return null;n=s.GetIndex()}const r=eT.New(eT.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 e of t.sm){const t=s.GetObjectClassBySID(e);t&&r._solModifiers.push(t)}if(Array.isArray(t.dsm))for(const e of t.dsm){const t=s.GetObjectClassBySID(e);t&&(r._dynamicSolModifiers||(r._dynamicSolModifiers=new Set),r._dynamicSolModifiers.add(t))}for(const[i,n]of Object.entries(t.sols)){const t=parseInt(i,10),a=s.GetObjectClassBySID(t);if(!a)continue;const o=eT.New(eT.SolState,null);o._LoadFromJson(e,n),r._sols.set(a,o)}if("instance-signals"===r._type){r._pendingInstances=new Set;for(const e of t.pi){const t=s.GetInstanceByUID(e);t&&r._pendingInstances.add(t)}}return r}}}{const tT=self.C3;tT.SolState=class extends tT.DefendedBase{constructor(e){super(),this._objectClass=null,this._isSelectAll=!0,this._instances=[],e&&(this._objectClass=e.GetObjectClass(),this._isSelectAll=e.IsSelectAll(),tT.shallowAssignArray(this._instances,e._GetOwnInstances()))}Release(){this._objectClass=null,tT.clearArray(this._instances)}_Restore(e){e._SetSelectAll(this._isSelectAll),tT.shallowAssignArray(e._GetOwnInstances(),this._instances)}RemoveInstances(e){tT.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,tT.clearArray(this._instances);for(const e of t.insts){const t=s.GetInstanceByUID(e);t&&this._instances.push(t)}}}}{let sT=function(e,t){let s=e.get(t);return s||(s=new Map,e.set(t,s)),s};GetNextParamMap=sT;const iT=self.C3;iT.SDKPluginBase=class extends iT.DefendedBase{constructor(e){super(),this._runtime=e.runtime,this._id=e.id,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}GetID(){return this._id}GetName(){return this._name}OnCreate(){}GetConstructor(){return this.GetSdkVersion()>=2?this._iPlugin.constructor:this.constructor}GetSdkVersion(){return this._sdkVersion}GetScriptInterfaceClass(e=!1){let t=this._scriptInterfaceClass;return e&&"function"!=typeof t&&this.GetSdkVersion()>=2&&(t=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");const i=sT(this._boundACEMethodCache_1param,e);let 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");const n=sT(this._boundACEMethodCache_2params,e),r=sT(n,s);let 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");const r=sT(this._boundACEMethodCache_3params,e),a=sT(r,s),o=sT(a,i);let h=o.get(n);return h||(h=e.bind(t,s,i,n),o.set(n,h),h)}_SetSingleGlobalObjectClass(e){if(!this.IsSingleGlobal())throw new Error("must be single-global plugin");this._singleGlobalObjectClass=e}GetSingleGlobalObjectClass(){if(!this.IsSingleGlobal())throw new Error("must be single-global plugin");return this._singleGlobalObjectClass}GetSingleGlobalInstance(){if(!this.IsSingleGlobal())throw new Error("must be single-global plugin");return this._singleGlobalObjectClass.GetSingleGlobalInstance()}_InitScriptInterface(){const e=this.GetSdkVersion();iT.AddonManager._PushInitObject(this,e);const t=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;iT.AddonManager._PopInitObject(e)}GetIPlugin(){return this._iPlugin}}}{const nT=self.C3;nT.SDKDOMPluginBase=class extends nT.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,t){this._runtime.AddDOMComponentMessageHandler(this._domComponentId,e,e=>{const s=this._instMap.get(e.elementId);t(s,e)})}}}{const rT=self.C3;rT.SDKTypeBase=class extends rT.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=rT.New(rT.Event,e,t);i.objectClass=this,s&&Object.assign(i,s),this.GetObjectClass().DispatchUserScriptEvent(i)}}}{const aT=self.C3;aT.SDKInstanceBase=class extends aT.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)throw new Error("wrapper extension component id not set");return this._runtime.HasWrapperComponentId(this._wrapperComponentId)}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)throw new Error("wrapper extension component id not set");return this._runtime.SendWrapperExtensionMessageAsync(this._wrapperComponentId,e,t)}Tick(){}Tick2(){}_StartTicking(){if(!this._isTicking){if(!this._tickFunc)if(this._runtime.IsDebug()){const e=globalThis.C3Debugger,t=this.GetPlugin();this._tickFunc=()=>{const s=performance.now();this.Tick(),e.AddIndividualPluginTickTime(t,performance.now()-s)}}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 e=globalThis.C3Debugger,t=this.GetPlugin();this._tick2Func=()=>{const s=performance.now();this.Tick2(),e.AddIndividualPluginTickTime(t,performance.now()-s)}}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)return;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())return;const i=this.GetScriptInterface(),n=aT.New(aT.Event,e,t);n.instance=i,s&&Object.assign(n,s),i.dispatchEvent(n)}MustPreDraw(){return!1}}}{const oT=self.C3;oT.SDKWorldInstanceBase=class extends oT.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)return;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 hT=self.C3,lT=hT.New(hT.Rect);hT.SDKDOMInstanceBase=class extends hT.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=hT.New(hT.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={}),t.elementId=this._elementId,this.PostToDOM(e,t)}_PostToDOMElementMaybeSync(e,t){return t||(t={}),t.elementId=this._elementId,this._PostToDOMMaybeSync(e,t)}PostToDOMElementAsync(e,t){return t||(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){e=!!e,this._isElementShowing!==e&&(this._isElementShowing=e,this.PostToDOMElement("set-visible",{isVisible:e}))}Tick(){this._UpdatePosition(!1)}_ShouldPreserveElement(){const e=this._runtime.GetCanvasManager().GetFullscreenMode();return"Android"===hT.Platform.OS&&("scale-inner"===e||"scale-outer"===e||"crop"===e)}_UpdatePosition(e){if(this.GetInstance().IsDestroyed())return;const t=this.GetWorldInfo(),s=t.GetLayer(),i=t.GetBoundingBox();let[n,r]=s.LayerToCanvasCss(i.getLeft(),i.getTop()),[a,o]=s.LayerToCanvasCss(i.getRight(),i.getBottom());const h=this._runtime.GetCanvasManager(),l=h.GetCssWidth(),c=h.GetCssHeight();if(!t.IsVisible()||!s.IsVisible())return void this.SetElementVisible(!1);if(!this._ShouldPreserveElement()&&(a<=0||o<=0||n>=l||r>=c))return void this.SetElementVisible(!1);lT.set(n,r,a,o);const u=h.GetLastWidth(),d=h.GetLastHeight(),_=s.GetHTMLIndex(),p=t.GetHTMLZIndex();if(!e&&lT.equals(this._lastRect)&&this._lastWindowWidth===u&&this._lastWindowHeight===d&&this._lastHTMLIndex===_&&this._lastHTMLZIndex===p)return void this.SetElementVisible(!0);this._lastRect.copy(lT),this._lastWindowWidth=u,this._lastWindowHeight=d,this._lastHTMLIndex=_,this._lastHTMLZIndex=p,this.SetElementVisible(!0);let g=null;this._autoFontSize&&(g=s.GetDisplayScale()+this._autoFontSizeOffset),this._PostToDOMElementMaybeSync("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:_,htmlZIndex:p,fontSize:g})}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:hT.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 cT=self.C3,uT=self.IBehavior;cT.SDKBehaviorBase=class extends cT.DefendedBase{constructor(e){super(),this._runtime=e.runtime,this._id=e.id,this._name=e.name??"",this._myObjectClasses=cT.New(cT.ArraySet),this._myInstances=cT.New(cT.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}GetID(){return this._id}GetName(){return this._name}OnCreate(){}GetSdkVersion(){return this._sdkVersion}GetScriptInterfaceClass(e=!1){let t=this._scriptInterfaceClass;return e&&"function"!=typeof t&&this.GetSdkVersion()>=2&&(t=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();cT.AddonManager._PushInitObject(this,e);const t=this.GetScriptInterfaceClass(!0);if(t){if(this._iBehavior=new t,!(this._iBehavior instanceof uT))throw new TypeError("behavior class must derive from IBehavior")}else this._iBehavior=new uT;cT.AddonManager._PopInitObject(e)}GetIBehavior(){return this._iBehavior}}}{const dT=self.C3;dT.SDKBehaviorTypeBase=class extends dT.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 _T=self.C3;_T.SDKBehaviorInstanceBase=class extends _T.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)return;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())return;const i=this.GetScriptInterface(),n=_T.New(_T.Event,e,t);n.behaviorInstance=i,n.instance=i.instance,s&&Object.assign(n,s),i.dispatchEvent(n)}}}{let pT=function(e){if(e!==mT)throw new Error("invalid internal API token")};ValidateInternalAPIToken=pT;const gT=self.C3;gT.Plugins={},gT.Behaviors={};const mT=gT._GetInternalAPIToken();let fT=[],ST=[],GT=[],yT=null,IT=null,TT=null,CT=null;const bT=new Map,wT=new Map;gT.AddonManager=class extends gT.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");gT.AddCommonACEs(e,s,t);const i=t>=2?gT.SDKPluginBase:s,n=gT.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,id:e[20],name:e[21],scriptInterfaceClass:t>=2?s:null});n.OnCreate(),this._allPlugins.push(n),bT.set(s,n)}CreateSystemPlugin(){this._systemPlugin=gT.New(gT.Plugins.System,{runtime:this._runtime,isSingleGlobal:!0}),this._systemPlugin.OnCreate()}CreateBehavior(e){const t=e[1],s=e[2],i=e[3],n=this._runtime.GetObjectReference(e[0]);if(!n)throw new Error("missing behavior");this._delayCreateBehaviors.set(n,()=>{const e=t>=2?gT.SDKBehaviorBase:n,r=gT.New(e,{runtime:this._runtime,id:s,name:i,sdkVersion:t,scriptInterfaceClass:t>=2?n:null});r.OnCreate(),this._allBehaviors.push(r),wT.set(n,r),!this._solidBehavior&&gT.Behaviors.solid&&r instanceof gT.Behaviors.solid?this._solidBehavior=r:!this._jumpthruBehavior&&gT.Behaviors.jumpthru&&r instanceof gT.Behaviors.jumpthru&&(this._jumpthruBehavior=r),r._InitScriptInterface()})}_DelayCreateBehavior(e){const t=this._delayCreateBehaviors.get(e);t&&(t(),this._delayCreateBehaviors.delete(e))}static _PushInitObject(e,t=1){if(gT.AddonManager._PushInitObject!==yT)throw new Error("invalid method");1===t&&fT.push(e),ST.push(e)}static _PopInitObject(e=1){if(gT.AddonManager._PopInitObject!==IT)throw new Error("invalid method");1===e&&fT.pop(),ST.pop()}static _GetInitObject(){if(gT.AddonManager._GetInitObject!==TT)throw new Error("invalid method");if(0===fT.length)throw new Error("no init object set");return fT.at(-1)}static _GetInitObject2(e){if(gT.AddonManager._GetInitObject2!==CT)throw new Error("invalid method");if(pT(e),0===ST.length)throw new Error("no init object set");return ST.at(-1)}static _PushInitProperties(e){GT.push(e)}static _PopInitProperties(){GT.pop()}static _GetInitProperties(){if(0===GT.length)throw new Error("no init properties set");return GT.at(-1)}_InitAddonScriptInterfaces(){for(const e of this._allPlugins)e._InitScriptInterface()}static GetPluginByConstructorFunction(e){return bT.get(e)||null}static GetBehaviorByConstructorFunction(e){return wT.get(e)||null}GetSystemPlugin(){return this._systemPlugin}GetSolidBehavior(){return this._solidBehavior}GetJumpthruBehavior(){return this._jumpthruBehavior}HasWrapperComponentId(e){return this._wrapperComponentIds.has(e)}},yT=gT.AddonManager._PushInitObject,IT=gT.AddonManager._PopInitObject,TT=gT.AddonManager._GetInitObject,CT=gT.AddonManager._GetInitObject2}{const PT=self.C3,xT=new Set;PT.ImageInfo=class extends PT.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=PT.New(PT.Rect),this._quadTex=PT.New(PT.Quad),this._blobUrl="",this._iImageInfo=new self.IImageInfo(this),xT.add(this)}Release(){this.ReleaseTexture(),this._imageAsset&&0===this._imageAsset.GetRefCount()&&this._imageAsset.Release(),this._imageAsset=null,xT.delete(this),this.ReleaseBlobURL()}static OnRendererContextLost(){for(const e of xT)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,s){if(s=!!s,this._imageAsset)throw new Error("already loaded asset");this._url=t;const i={isTiled:s};return PT.IsAbsoluteURL(t)&&(i.loadPolicy="remote"),this.LoadAsset(e,i),this._imageAsset.Load()}LoadDynamicBlobAsset(e,t){if(this._imageAsset)throw new Error("already loaded asset");this._url="",this._size=t.size,this._imageAsset=PT.New(PT.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;this._textureState="loading";const i=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=PT.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)return this._blobUrl;const t=await this.ExtractImageToCanvas(e),s=await PT.CanvasToBlob(t);return this._blobUrl=URL.createObjectURL(s),this._blobUrl}ReleaseBlobURL(){this._blobUrl&&(URL.revokeObjectURL(this._blobUrl),this._blobUrl="")}}}{const vT=self.C3;vT.AnimationInfo=class extends vT.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=>vT.New(vT.AnimationFrameInfo,e)),this._iAnimation=new self.IAnimation(this)}static CreateDynamic(e,t){const s=vT.New(vT.AnimationInfo,[t,0,!1,0,0,!1,Math.floor(1e15*Math.random()),[]]);return s._frames.push(vT.AnimationFrameInfo.CreateDynamic(e)),s}Release(){for(const e of this._frames)e.Release();vT.clearArray(this._frames)}LoadAllAssets(e){for(const t of this._frames)t.GetImageInfo().LoadAsset(e)}LoadAllTextures(e,t){return Promise.all(this._frames.map(s=>s.GetImageInfo().LoadStaticTexture(e,t)))}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(e){for(let t=0,s=this._frames.length;t{const e=atob("iVBORw0KGgoAAAANSUhEUgAAAGQAAABkAQMAAABKLAcXAAAAAXNSR0IArs4c6QAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAATSURBVBgZYxgFo2AUjIJRQFcAAAV4AAHcRQIbAAAAAElFTkSuQmCC"),t=new Uint8Array(e.length);for(let s=0,i=e.length;sAT.New(AT.ImagePoint,this,e)),this._imagePointsByName=new Map;for(const e of this._imagePoints)this._imagePointsByName.set(e.GetName().toLowerCase(),e);this._collisionPoly=null;const t=e[11];t.length>=6&&(this._collisionPoly=AT.New(AT.CollisionPoly,t)),this._tag=e[12]?e[12]:"",this._iAnimationFrame=new self.IAnimationFrame(this)}static CreateDynamic(e){const t=AT.New(AT.AnimationFrameInfo,["",0,0,0,100,100,!1,1,0,0,[],[],""]);return t._imageInfo.LoadDynamicBlobAsset(e,RT),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 MT=self.C3;MT.ImagePoint=class extends MT.DefendedBase{constructor(e,t){super(),this._afi=e,this._name=t[0],this._pos=MT.New(MT.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 DT=globalThis.C3,ET=globalThis.C3Debugger,FT=globalThis.IObjectClass,OT=globalThis.IObjectType,BT=globalThis.IFamily,LT=globalThis.assert;DT.ObjectClass=class extends DT.DefendedBase{constructor(e,t,s){super();const i=e.GetObjectReference(s[1]);this._runtime=e,this._plugin=DT.AddonManager.GetPluginByConstructorFunction(i),this._sdkType=null,this._instSdkCtor=i.Instance,this._index=t,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(t=>({sid:t[0],type:t[1],name:t[2],jsPropName:e.GetJsPropName(t[3])})),this._behaviorsCount=s[4],this._effectsCount=s[5],this._isWorldType=this._plugin.IsWorldType(),this._dispatcher=DT.New(DT.Event.Dispatcher),this._effectList=null;const[n,r]=e.GetCollisionEngine().GetCollisionCellSize();if(this._collisionGrid=DT.New(DT.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=>DT.BehaviorType.Create(this,e)),this._behaviorTypesIncludingInherited=[],this._behaviorsByName=new Map,this._behaviorNameToIndex=new Map,this._usedBehaviorCtors=new Set,this._customActionMap=new Map,this._solStack=DT.New(DT.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=DT.New(DT.EffectList,this,s[12])),s[6]&&(this._imageInfo=DT.New(DT.ImageInfo),this._imageInfo.LoadData(s[6])),s[7]){this._animations=s[7].map(e=>DT.New(DT.AnimationInfo,e)),this._animationsByName=new Map,this._animationsBySid=new Map;for(const e of this._animations)this._animationsByName.set(e.GetName().toLowerCase(),e),this._animationsBySid.set(e.GetSID(),e)}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=DT.New(i.Type,this,s[15]),!(this._sdkType instanceof DT.SDKTypeBase)))throw new Error("v1 sdk type must derive from SDKTypeBase");let o;if(this._iObjectClass=null,this._instanceUserScriptClass=null,this._userScriptDispatcher=DT.New(DT.Event.Dispatcher),DT.AddonManager._PushInitObject(this,a),a>=2?(o=i.Type,o||(o=globalThis.ISDKObjectTypeBase)):o=this._sdkType.GetScriptInterfaceClass(),o&&!this._isFamily){if(this._iObjectClass=new o(a<2?this:null),a<2&&!(this._iObjectClass instanceof OT))throw new TypeError("script interface class must derive from IObjectType");if(a>=2&&!(this._iObjectClass instanceof globalThis.ISDKObjectTypeBase))throw new TypeError("script interface class must derive from ISDKObjectTypeBase")}else{const e=this._isFamily?BT:OT;this._iObjectClass=new e}if(DT.AddonManager._PopInitObject(a),s[13]){const e=s[13];if(e){const t=e[0],s=e[1],i=e[2];this._sdkType.LoadTilemapData(t,s,i)}}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 DT.New(DT.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();DT.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(e){for(let t=1,s=e.length;t0}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(e){return this._instVars.findIndex(t=>t.sid===e)}GetInstanceVariableIndexByName(e){return this._instVars.findIndex(t=>t.name===e)}_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)throw new Error("no animations");return this._animationsByName.get(e.toLowerCase())||null}GetAnimationBySID(e){if(!this._animations)throw new Error("no animations");return this._animationsBySid.get(e)||null}AddAnimation(e){if(this.GetAnimationByName(e))throw new Error(`animation name '${e}' already exists`);const t=DT.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)throw new Error("no animations");return this._animations[0]}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())throw new Error("not a single-global plugin");return this._instances[0]}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)return;const e=this._instances;let t=0;for(let s=e.length;t0?t[e.GetIID()%t.length]:null}*allCorrespondingInstances(e,t){const s=this.GetCurrentSol().GetInstances(),i=s.length,n=t.GetCurrentSol(),r=t.GetCurrentSol().GetInstances(),a=r.length;let o=e.GetIID();!t.IsFamily()&&n.IsSelectAll()||(o=r.indexOf(e));const h=Math.ceil(i/a),l=i%a;let c=0,u=0;0===l||oe.SaveToJson())};return this._savedData&&this._savedData.size&&(e.ex=DT.ToSuperJSON(this._savedData)),e}_LoadFromJson(e,t){this._savedData&&(this._savedData.clear(),this._savedData=null);const s=e.ex;s&&(this._savedData=DT.FromSuperJSON(s));const i=this._instances,n=e.instances;for(let e=0,t=Math.min(i.length,n.length);ee.IsWorldType())}}}{const NT=self.C3,WT=self.C3Debugger,VT=self.IInstance,UT=NT.AddonManager,jT=[];let HT=0;const zT=new WeakMap,XT=new WeakMap,YT=1,qT=2,KT=4,$T=8,JT=16,ZT=32,QT=64;NT.Instance=class extends NT.DefendedBase{constructor(e){if(NT.AddonManager!==UT)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=HT++,this._flags=0,this._tagsSet=null;const t=NT.splitStringAndNormalize(e.tags);t.length>0&&(this._tagsSet=new Set(t)),this._instVarValues=jT,this._behaviorInstances=jT;const s=this._objectType.GetBehaviorTypesIncludingInherited();s.length>0&&(this._behaviorInstances=s.map((e,t)=>NT.New(NT.BehaviorInstance,{runtime:this._runtime,behaviorType:e,instance:this,index:t}))),this._siblings=this._objectType.IsInContainer()?[]:null,this._timeScale=-1,this._dispatcher=null;const i=this.GetPlugin();if(i.MustPreDraw()&&(this._flags|=4),i.IsWorldType())if(this._worldInfo=NT.New(NT.WorldInfo,this,e.layer),e.worldData)this._worldInfo.Init(e.worldData);else{this._worldInfo.InitNoData();const[e,t]=this._objectType.GetDefaultInstanceSize();this._worldInfo.SetSize(e,t),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),this._behaviorInstances.length>0){for(const e of this._behaviorInstances)e.Release();NT.clearArray(this._behaviorInstances)}this._sdkInst&&(this._sdkInst.Release(),this._sdkInst=null);const e=zT.get(this);e&&(e.clear(),zT.delete(this));const t=XT.get(this);t&&(t.clear(),XT.delete(this)),this._siblings&&NT.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,this._instVarValues.length>0&&NT.clearArray(this._instVarValues),this._worldInfo&&(this._worldInfo.Release(),this._worldInfo=null)}_LoadInstanceVariableData(e){e.length>0&&(this._instVarValues=[],NT.shallowAssignArray(this._instVarValues,e))}_LoadDefaultInstanceVariables(){const e=this._objectType.GetInstanceVariablesCount();if(0===e)return;this._instVarValues=[];const t=[0,0,""];for(let s=0;s{const i=s||t.GetObjectClass(),n=e.get(i);n?n.add(t):e.set(i,new Set([t]))};if(i(this,t),this.IsInContainer())for(const e of this.siblings())i(e);if(s)for(const e of this.allChildren())i(e)}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)return!1;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)return;const t=e.GetSceneGraphChildrenExportData();if(t)for(const e of t){const t=this._runtime.GetInstanceByUID(e[2]);if(t){const s=e[3];this.AddChild(t,{transformX:!!(1&s),transformY:!!(s>>1&1),transformWidth:!!(s>>2&1),transformHeight:!!(s>>3&1),transformAngle:!!(s>>4&1),destroyWithParent:!!(s>>5&1),transformZElevation:!!(s>>6&1),transformOpacity:!!(s>>7&1),transformVisibility:!!(s>>8&1)})}}}SetupPersistedSceneGraphConnections(e,t){const s=e.get(this);if(s)for(const e of s.sceneGraphJson.children){const s=t.get(e.index);if(!s)continue;const i=e.flags;this.AddChild(s,{transformX:!!(1&i),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)})}}GetTemplateName(){const e=this._runtime.GetTemplateManager();return e?e.GetInstanceTemplateName(this):""}IsInContainer(){return null!==this._siblings}_ClearSiblings(){NT.clearArray(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}SetUID(e){this._uid=e}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)return null;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(e){const t=this._behaviorInstances;for(let s=0,i=t.length;s=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){e|=0;const s=this._instVarValues;if(e<0||e>=s.length)throw new RangeError("invalid instance variable");switch(this._objectType.GetInstanceVariableType(e)){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)return;e|=0;const s=this._instVarValues;if(e<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=zT.get(this);return e||(e=new Map,zT.set(this,e),e)}GetUnsavedDataMap(){let e=XT.get(this);return e||(e=new Map,XT.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(e=void 0){const t=e??new Set;if(t.has(this))return;t.add(this);const s=this.GetWorldInfo();if(s&&s.HasChildren())for(const e of this.allChildren())if(t.add(e),e.IsInContainer())for(const s of e.siblings())t.add(s);if(this.IsInContainer())for(const e of this.siblings())e._TriggerOnCreatedOnSelfAndRelated(t);if(!e){for(const e of t.values())e._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 NT.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 NT.Event("hierarchyready")),this._HasAnyCreateDestroyHandler("hierarchyready")){const e=this.GetObjectClass(),t=new NT.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 NT.Event("destroy");t.isEndingLayout=e,this.DispatchUserScriptEvent(t)}if(!this._HasAnyCreateDestroyHandler("instancedestroy"))return;const t=this.GetObjectClass(),s=new NT.Event("instancedestroy");s.instance=this.GetInterfaceClass(),s.isEndingLayout=e,t.DispatchUserScriptEvent(s);for(const e of t.GetFamilies())e.DispatchUserScriptEvent(s);this._runtime.DispatchUserScriptEvent(s)}_GetDebuggerProperties(){return this._sdkInst?this._sdkInst.GetDebuggerProperties():this._iScriptInterface._getDebuggerProperties()}SaveToJson(e="full",t=null){const s={};"full"===e?s.uid=this.GetUID():s.c3=!0;const i=this.GetTagsSet();if(i.size>0&&(s.tags=Array.from(i)),"visual-state"!==e){const t=zT.get(this);if(t&&t.size&&(s.ex=NT.ToSuperJSON(t)),-1!==this.GetTimeScale()&&(s.mts=this.GetTimeScale()),this._objectType.GetInstanceVariablesCount()>0){const e={},t=this._objectType.GetInstanceVariableSIDs();for(let s=0,i=this._instVarValues.length;s=this._instVarValues.length)continue;let n=t;null===n&&(n=NaN),this._instVarValues[i]=n}}if(this.GetPlugin().IsWorldType()){const i=e.w;if(i){const e=i.l;if(this._worldInfo.GetLayer().GetSID()!==e){const s=this._worldInfo.GetLayer(),i=s.GetLayout().GetLayerBySID(e);i?(this._worldInfo._SetLayer(i),s._RemoveInstance(this,!0),i._AddInstance(this,!0),i.SetZIndicesChanged(this),this._worldInfo.SetBboxChanged()):"full"===t&&this._runtime.DestroyInstance(this)}this._worldInfo._LoadFromJson(i,t,s)}}if("visual-state"!==t){const s=e.behs;if(s)for(const[e,i]of Object.entries(s)){const s=parseInt(e,10),n=this.GetBehaviorIndexBySID(s);n<0||n>=this._behaviorInstances.length||this._behaviorInstances[n].LoadFromJson(i,t)}}const i=e.data;i&&(this._sdkInst?this._sdkInst.LoadFromJson(i,t):this._iScriptInterface._loadFromJson(i))}MoveToLayerWithSID(e){if(this._worldInfo.GetLayer().GetSID()===e)return;const t=this._worldInfo.GetLayer(),s=t.GetLayout().GetLayerBySID(e);s&&(this._worldInfo._SetLayer(s),t._RemoveInstance(this,!0),s._AddInstance(this,!0),s.SetZIndicesChanged(this),this._worldInfo.SetBboxChanged())}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(NT.AddonManager._PushInitObject(this,a),NT.AddonManager._PushInitProperties(t),this._iScriptInterface=new r,NT.AddonManager._PopInitProperties(),NT.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 e=i||s;if(!(this._iScriptInterface instanceof e))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)return;const t={},s=this._objectType._GetAllInstanceVariableJsPropNames();for(let e=0,i=s.length;e{if(t.instance!==this._parent.GetInstance())return;e.GetRuntime().Dispatcher().removeEventListener("instancecreate",this._on_instance_create);const s=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,eC.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 e=this._owner.GetRuntime();if(this._parent.GetInstance().GetPlugin().GetSdkVersion()<2){const t=this._parent.GetInstance().GetSdkInstance();t?(this._originalSizeKnown=!!t.IsOriginalSizeKnown(),this._originalWidth=this._originalSizeKnown?t.GetOriginalWidth():NaN,this._originalHeight=this._originalSizeKnown?t.GetOriginalHeight():NaN):this._parent.GetInstance().IsDestroyed()||e.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 this._children.length>0}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 eC.IsFiniteNumber(s)&&eC.IsFiniteNumber(i)?s-i:0}):this._children.sort((e,t)=>{const s=e._GetSceneGraphInfo()._GetIndexInParent(),i=t._GetSceneGraphInfo()._GetIndexInParent();return eC.IsFiniteNumber(s)&&eC.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()){const e=this._parent;let 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()){const e=this._parent;let 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()?null:this._GetInstanceJson(this._parent,this._owner,e):null}_GetChildrenJson(e){return this._children.map(t=>this._GetInstanceJson(t,t,e)).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=eC.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=eC.IsFiniteNumber(e.pi)?e.pi:NaN}_SetTmpSceneGraphChildren(e,t,s,i){if(!e&&!t)if(i?.setFromJson){if(this._tmpSceneGraphChildren)for(const e of this._tmpSceneGraphChildren)e.IsDestroyed()||e.HasParent()||e.GetRuntime().DestroyInstance(e)}else if(this._tmpSceneGraphChildren)for(const e of this._tmpSceneGraphChildren)if(s.c&&s.c.length){if(!s.c.some(t=>t.uid===e.GetUID()))continue;e.IsDestroyed()||e.HasParent()||e.GetRuntime().DestroyInstance(e)}this._tmpSceneGraphChildren=e,this._tmpSceneGraphChildrenIndexes=t}_GetInstanceByUID(e){const t=this._owner.GetRuntime();return tC.has(e)?tC.get(e):t.GetInstanceByUID(e)}_OnAfterLoad(e,t){const s=this._owner,i=s.GetRuntime(),n=t?.processedWorldInfo??new Set;if(e.p&&!this._parent){const r=e.p.uid,a=this._GetInstanceByUID(r);if(a){const r=a.GetWorldInfo();a.HasChild(s.GetInstance())?this._parent=r:(a.HasChildWithUID(s.GetInstance().GetUID())?(i.DestroyInstance(s.GetInstance()),i._RemoveInstanceFromUIDMap(s.GetInstance().GetUID()),tC.delete(s.GetInstance().GetUID())):a.AddChild(s.GetInstance(),this._GetFlagsObj(e.p.f)),n.has(s)||(s._LoadSceneGraphPropertiesFromJson(e.p.offsets),this._LoadInstancePropertiesFromJson(a,e.p,t),this._UpdateUIDInstanceMap(a,a.GetUID(),s.GetRuntime(),t)),n.add(s),a.GetWorldInfo()._GetSceneGraphInfo()._MaybeSortChildren())}else if(eC.IsFiniteNumber(e.p.oci)){const n=i.CreateInstance(i.GetObjectClassByIndex(e.p.oci),s.GetLayer(),0,0,!0);if(n){const r=this._GetInstanceData(e.p,i);r&&n.LoadFromJson(r);const a=n.GetWorldInfo(),o=!!t?.setFromJson;a.GetLayer().SortAndAddInstancesByZIndex(n,!1,o),n.AddChild(s.GetInstance(),this._GetFlagsObj(e.p.f)),tC.set(n.GetUID(),n),this._UpdateUIDInstanceMap(n,n.GetUID(),i,t),n.GetWorldInfo()._GetSceneGraphInfo()._MaybeSortChildren()}}}const r=[];for(const t of e.c){const e=t.uid,s=this._GetInstanceByUID(e);s&&r.push(s)}let a=0;for(const o of e.c){const h=o.uid,l=this._GetInstanceByUID(h);if(l){if(this._tmpSceneGraphChildren){if(this._tmpSceneGraphChildren.includes(l)){const i=l;if(i.GetObjectClass()!==l.GetObjectClass()){a++;continue}if(i.IsDestroyed()){a++;continue}const o=e.c[a];if(!t?.setFromJson&&this._HasAllChildrenOfType(i,r,s)){if(s.GetInstance().GetChildAt(a)){const r=i.GetObjectClass().GetIndex(),h=o.oci,l=s.GetInstance().GetChildAt(a).GetObjectClass().GetIndex();if(r!==h||h!==l){this._RefreshAllChildren(e.c,s,n,t);break}this._UpdateInstance(a,o,s,n,t)}else this._UpdateInstance(a,o,s,n,t);a++;continue}if(i.HasParent()&&i.GetParent()!==s.GetInstance()){const e=this._CreateNewChildInstance(o,t);this._AddAndSetChildInstance(e,o,n,t),a++;continue}this._AddAndSetChildInstance(i.GetWorldInfo(),o,n,t,!0),a++;continue}if(this._tmpSceneGraphChildren[a]){const i=this._tmpSceneGraphChildren[a];if(i.GetObjectClass()!==l.GetObjectClass()){a++;continue}if(i.IsDestroyed()){a++;continue}const o=e.c[a];if(!t?.setFromJson&&this._HasAllChildrenOfType(i,r,s)){if(s.GetInstance().GetChildAt(a)){const r=i.GetObjectClass().GetIndex(),h=o.oci,l=s.GetInstance().GetChildAt(a).GetObjectClass().GetIndex();if(r!==h||h!==l){this._RefreshAllChildren(e.c,s,n,t);break}this._UpdateInstance(a,o,s,n,t)}else this._UpdateInstance(a,o,s,n,t);a++;continue}if(i.HasParent()&&i.GetParent()!==s.GetInstance()){const e=this._CreateNewChildInstance(o,t);this._AddAndSetChildInstance(e,o,n,t),a++;continue}this._AddAndSetChildInstance(i.GetWorldInfo(),o,n,t,!0),a++;continue}}const i=l.GetObjectClass();if(this._GetInstancesOfObjectClassCount(r,i)===s.GetInstance().GetChildrenOfObjectClass(i).length){for(const e of s.GetInstance().GetChildren()){if(e.GetObjectClass()!==i)continue;const s=e.GetWorldInfo();if(s&&!n.has(s)){n.add(s),s._LoadSceneGraphPropertiesFromJson(o.offsets),this._LoadInstancePropertiesFromJson(e,o,t);break}}a++;continue}if(l.HasParent()&&l.GetParent()!==s.GetInstance()){const e=this._CreateNewChildInstance(o,t);this._AddAndSetChildInstance(e,o,n,t),a++;continue}this._AddAndSetChildInstance(l.GetWorldInfo(),o,n,t)}else if(this._tmpSceneGraphChildren&&this._tmpSceneGraphChildren[a]){const h=this._tmpSceneGraphChildren[a],l=i.GetObjectClassByIndex(this._GetObjectClassIndex(o));if(h.GetObjectClass()!==l){a++;continue}if(h.IsDestroyed()){a++;continue}const c=e.c[a];if(!t?.setFromJson&&this._HasAllChildrenOfType(h,r,s)){if(s.GetInstance().GetChildAt(a)){const i=h.GetObjectClass().GetIndex(),r=c.oci,o=s.GetInstance().GetChildAt(a).GetObjectClass().GetIndex();if(i!==r||r!==o){this._RefreshAllChildren(e.c,s,n,t);break}this._UpdateInstance(a,c,s,n,t)}else this._UpdateInstance(a,c,s,n,t);a++;continue}if(h.HasParent()&&h.GetParent()!==s.GetInstance()){const e=this._CreateNewChildInstance(c,t);this._AddAndSetChildInstance(e,c,n,t),a++;continue}this._AddAndSetChildInstance(h.GetWorldInfo(),c,n,t)}else{const e=this._CreateNewChildInstance(o,t);this._AddAndSetChildInstance(e,o,n,t)}a++}}_RefreshAllChildren(e,t,s,i){const n=t.GetRuntime();for(const e of t.GetInstance().children())e&&!e.IsDestroyed()&&(n.DestroyInstance(e),n._RemoveInstanceFromUIDMap(e.GetUID()),tC.delete(e.GetUID()));this._tmpSceneGraphChildren&&(this._tmpSceneGraphChildren=[]),this._tmpSceneGraphChildrenIndexes&&(this._tmpSceneGraphChildrenIndexes=new WeakMap),Object.assign({},i,{assignZIndex:!1});for(const t of e){const e=this._CreateNewChildInstance(t,i);this._AddAndSetChildInstance(e,t,s,i),this._tmpSceneGraphChildren.push(e.GetInstance()),this._tmpSceneGraphChildrenIndexes.set(e.GetInstance(),this._tmpSceneGraphChildren.length-1)}t._GetSceneGraphInfo()._MaybeSortChildren()}_HasAllChildrenOfType(e,t,s){const i=e.GetObjectClass();return this._GetInstancesOfObjectClassCount(t,i)===s.GetInstance().GetChildrenOfObjectClass(i).length}_UpdateInstance(e,t,s,i,n){const r=s.GetInstance().GetChildAt(e);if(!r)return;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 eC.IsFiniteNumber(e.oci)?e.oci:e[1]}_CreateNewChildInstance(e,t){if(!eC.IsFiniteNumber(e.oci))return;const s=this._owner,i=s.GetRuntime();let n;const r=!t.hasOwnProperty("createHierarchy")||t.createHierarchy;if(n=e.data?i.CreateInstanceFromData(e.data,s.GetLayer(),!1,0,0,!1,r):i.CreateInstance(i.GetObjectClassByIndex(e.oci),s.GetLayer(),0,0,r),!n)return;const a=this._GetInstanceData(e,i);a&&n.LoadFromJson(a);const o=n.GetWorldInfo(),h=!!t?.setFromJson;return o.GetLayer().SortAndAddInstancesByZIndex(n,!0,h),o}_UpdateUIDInstanceMap(e,t,s,i){if(this._GetInstanceByUID(t)&&!i?.setFromJson){const i=this._GetInstanceByUID(t);i!==e&&s.DestroyInstance(i)}s._RemoveInstanceFromUIDMap(t),s._MapInstanceByUID(t,e)}_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)):a&&(tC.set(e.GetInstance().GetUID(),e.GetInstance()),this._UpdateUIDInstanceMap(e.GetInstance(),t.uid,r.GetRuntime(),i)),this._MaybeSortChildren()}_LoadInstancePropertiesFromJson(e,t,s){let i=this._GetInstanceData(t,this._owner.GetRuntime());if(!i)return;const n=!s.hasOwnProperty("clearChildren")||s.clearChildren,r=!s.hasOwnProperty("assignZIndex")||s.assignZIndex,a=e.GetRuntime();if(tC.set(e.GetUID(),e),i=JSON.parse(JSON.stringify(i)),n&&e.GetUID()!==i.uid){for(const t of e.children())t&&!t.IsDestroyed()&&(a.DestroyInstance(t),a._RemoveInstanceFromUIDMap(t.GetUID()),tC.delete(t.GetUID()));if(i.w?.sgi&&i.w.sgi.c?.length)for(const t of i.w.sgi.c){const i=Object.assign({},s,{clearChildren:!1,createHierarchy:!1}),n=this._CreateNewChildInstance(t,i);tC.set(n.GetInstance().GetUID(),n.GetInstance()),e.AddChild(n.GetInstance(),this._GetFlagsObj(t.f)),n._LoadSceneGraphPropertiesFromJson(t.offsets),this._LoadInstancePropertiesFromJson(n.GetInstance(),t,i)}}const o=i.w?.zi,h=i.w?.l;i.w=null,e.LoadFromJson(i),s?.setFromJson||(eC.IsFiniteNumber(o)&&r&&e.GetWorldInfo()._SetZIndex(o),eC.IsFiniteNumber(h)&&e.MoveToLayerWithSID(h)),this._UpdateUIDInstanceMap(e,i.uid,a,s)}_GetInstancesOfObjectClassCount(e,t){return e.filter(e=>e.GetObjectClass().GetName()===t.GetName()).length}_GetInstanceData(e,t){if(eC.IsFiniteNumber(e.instIndex)){const s=t.GetObjectClassByIndex(e.oci)._GetLoadInstancesJson();return s?s[e.instIndex]:null}return eC.IsString(e.inst)?JSON.parse(e.inst):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 t of[...e.GetChildren()]){const e=t.GetWorldInfo();s.push([e.GetLayout().GetSID(),e.GetLayer().GetIndex(),t.GetUID(),eC.SceneGraphInfo._GetFlagsNumber(e),t.GetObjectClass().IsInContainer()?1:0,e.GetZIndex(),eC.SceneGraphInfo.GetSceneGraphInstanceDataFromInstance(t)])}return eC.IsArray(t[0][14])?t[0][14][1]=s:(t[0][14]=[],t[0][14][0]=eC.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,t|=Number(e.GetTransformWithParentOpacity())<<7,t|=Number(e.GetTransformWithParentZElevation())<<6,t|=Number(e.GetDestroyWithParent())<<5,t|=Number(e.GetTransformWithParentAngle())<<4,t|=Number(e.GetTransformWithParentHeight())<<3,t|=Number(e.GetTransformWithParentWidth())<<2,t|=Number(e.GetTransformWithParentY())<<1,t|=0|Number(e.GetTransformWithParentX()),t}static _GetDefaultFlagsNumber(e){let t=0;return t|=256,t|=128,t|=64,t|=32,t|=16,t|=8,t|=4,t|=2,t|=1,511}static ClearUpdatedInstances(){tC.clear()}}}{const sC=self.C3,iC=self.glMatrix,nC=iC.vec3,rC=iC.vec4,aC=sC.New(sC.Rect),oC=sC.New(sC.Quad),hC=sC.New(sC.Event,"bboxchange",!1),lC=sC.New(sC.Color,0,0,0,0),cC=sC.New(sC.CollisionPoly),uC=sC.New(sC.Color,1,1,1,1),dC=sC.New(sC.Rect,0,0,-1,-1),_C=sC.New(sC.Rect,0,0,-1,-1),pC=new Set(["absolute","relative"]),gC=[];let mC=!0;const fC=1,SC=2,GC=4,yC=8,IC=16,TC=32,CC=64,bC=128,wC=256,PC=512,xC=1024,vC=2048,AC=4096,RC=8192,MC=16384,DC=32768,EC=1<<22,FC=1<<23,OC=12647936,BC=65536,LC=1<<17,kC=1<<18,NC=1<<19,WC=1<<20,VC=1<<21,UC=1<<24,jC=26,HC=31<<26,zC=new WeakMap,XC=new WeakMap;sC.WorldInfo=class extends sC.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=196635,this._objectClass.GetPlugin().IsRotatable()&&(this._flags|=128),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=sC.New(sC.Rect),this._boundingQuad=sC.New(sC.Quad),this._collisionCells=_C,this._renderCells=dC,this._sourceCollisionPoly=null,this._transformedPolyInfo=null,this._solidFilterTags=null,this._color=uC,this._colorPremultiplied=uC,this._stateGroup=null,this._instanceEffectList=null,this._inst.GetObjectClass().UsesEffects()&&(this._instanceEffectList=sC.New(sC.InstanceEffectList,this._inst,this)),this._sceneGraphInfo=null,this._tmpSceneGraphChildren=null,this._tmpSceneGraphChildrenIndexes=null,this._tmpHierarchyPosition=-1,this._meshInfo=null}_MarkDestroyed(){this._flags|=256}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(),zC.delete(this),XC.delete(this),this._inst=null,this._objectClass=null,this._runtime=null,this._layer=null}Init(e){if(mC=!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,lC.setFromJSON(e[7]),this._SetColor(lC),this.SetOriginX(e[8]),this.SetOriginY(e[9]),this.SetBlendMode(e[10]),this._instanceEffectList&&this._instanceEffectList._LoadEffectParameters(e[12]),e[14]&&zC.set(this,{childrenData:e[14][1],zIndexData:e[14][2]}),e[15]){const t=e[15];this.CreateMesh(t[0],t[1]);const s=this.GetSourceMesh(),i=t[2];for(let e=0,t=i.length;e=t.length?null:t[e]}GetChildIndex(e){if(!e)return NaN;const t=this.GetChildren();if(!t)return NaN;for(let s=0;s":e.GetTextureFillShaderProgram()||"",this._stateGroup=e.AcquireStateGroup(t,this.GetBlendMode(),this._colorPremultiplied,this.GetZElevation(),this.IsBackFaceCulling()?1:0,0)}GetRendererStateGroup(){return this._stateGroup}HasDefaultColor(){return this._color===uC}SetBlendMode(e){if((e|=0)<0||e>31)throw new RangeError("invalid blend mode");this.GetBlendMode()!==e&&(this._flags=-2080374785&this._flags|e<<26,this._UpdateRendererStateGroup())}GetBlendMode(){return(2080374784&this._flags)>>26}_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!!(1&this._flags)}SetVisible(e){if(this._SetFlag(1,e),this.HasChildren())for(const t of this.GetChildren())t.GetTransformWithParentVisibility()&&t.SetVisible(e)}IsCollisionEnabled(){return!!(8&this._flags)}SetCollisionEnabled(e){e=!!e,this.IsCollisionEnabled()!==e&&(this._SetFlag(8,e),e?this.SetBboxChanged():this._RemoveFromCollisionCells())}SetSolidCollisionFilter(e,t){if(this._SetFlag(32,e),this._solidFilterTags&&this._solidFilterTags.clear(),t.trim()){this._solidFilterTags||(this._solidFilterTags=new Set);for(const e of t.split(" "))e&&this._solidFilterTags.add(e.toLowerCase())}else this._solidFilterTags=null}IsSolidCollisionAllowed(e){const t=!!(32&this._flags),s=this._solidFilterTags;if(!e||!s)return!t;for(const i of s)if(e.has(i))return t;return!t}SetBboxChanged(){if(this._flags|=65554,this._objectClass._SetAnyCollisionCellChanged(!0),this._runtime.UpdateRender(),this._layer.UsesRenderCells()&&(this.CalculateBbox(this._boundingBox,this._boundingQuad,!0),this._flags&=-3,this._UpdateRenderCell()),4&this._flags&&this._inst.Dispatcher().dispatchEvent(hC),null!==this._sceneGraphInfo){const e=this._sceneGraphInfo.GetChildren();for(let t=0,s=e.length;t=e.Get2DCameraZ())&&(e.GetViewportForZ(t,aC),aC.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(1048576,e)}_SetDrawNonBackFacesOnly(e){this._SetFlag(2097152,e)}IsDrawBackFaceOnly(){return!!(1048576&this._flags)}IsDrawNonBackFacesOnly(){return!!(2097152&this._flags)}SetBackFaceCulling(e){(e=!!e)!==this.IsBackFaceCulling()&&(this._SetFlag(16777216,e),this._UpdateRendererStateGroup())}IsBackFaceCulling(){return!!(16777216&this._flags)}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(e,t,s,i,n){let r=this._transformedPolyInfo;null===r&&(r={poly:sC.New(sC.CollisionPoly),width:NaN,height:NaN,angle:NaN},this._transformedPolyInfo=r);const a=r.poly;if(r.width===e&&r.height===t&&r.angle===s)return a;const o=this._sourceCollisionPoly;if(this.HasMesh()){const s=this.GetOriginX(),r=this.GetOriginY(),h=this.GetSourceMesh();let l=this._meshInfo.meshPoly;l||(o?(cC.copy(o),cC.offset(s,r)):cC.setDefaultPoints(),l=h.InsertPolyMeshVertices(cC),this._meshInfo.meshPoly=l),h.TransformCollisionPoly(l,a),a.offset(-s,-r),a.transformPrecalc(e,t,i,n)}else o?(a.copy(o),a.transformPrecalc(e,t,i,n)):a.setFromQuad(this.GetBoundingQuad(),-this.GetX(),-this.GetY());return r.width=e,r.height=t,r.angle=s,a}_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:sC.New(sC.Gfx.Mesh,e,t),transformedMesh:sC.New(sC.Gfx.Mesh,e,t),meshPoly:null}}HasMesh(){return null!==this._meshInfo}GetSourceMesh(){if(!this.HasMesh())throw new Error("no mesh");return this._meshInfo.sourceMesh}GetTransformedMesh(){if(!this.HasMesh())throw new Error("no mesh");return this._meshInfo.transformedMesh}SetMeshChanged(e){this._SetFlag(65536,e)}IsMeshChanged(){return!!(65536&this._flags)}SetPhysicsBodyChanged(e){this._SetFlag(131072,e)}IsPhysicsBodyChanged(){return!!(131072&this._flags)}_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(!pC.has(i))throw new Error("invalid mode");const n="relative"===i;let r=s.x,a=s.y;const o=s.zElevation;let h="number"==typeof s.u?s.u:n?0:-1,l="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 d=!1;return"number"==typeof o&&u.GetZElevation()!==o&&(u.SetZElevation(o),d=!0),n&&(r+=e/(c.GetHSize()-1),a+=t/(c.GetVSize()-1)),-1!==h||n?(n&&(h+=e/(c.GetHSize()-1)),h=sC.clamp(h,0,1)):h=u.GetU(),-1!==l||n?(n&&(l+=t/(c.GetVSize()-1)),l=sC.clamp(l,0,1)):l=u.GetV(),u.GetX()===r&&u.GetY()===a&&u.GetU()===h&&u.GetV()===l?d:(u.SetX(r),u.SetY(a),u.SetU(h),u.SetV(l),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!!(16&this._flags)}_UpdateCollisionCell(){if(!this._IsCollisionCellChanged()||!this.IsCollisionEnabled()||256&this._flags)return;const e=this.GetBoundingBox(),t=this._objectClass._GetCollisionCellGrid(),s=this._collisionCells;if(aC.set(t.XToCell(e.getLeft()),t.YToCell(e.getTop()),t.XToCell(e.getRight()),t.YToCell(e.getBottom())),s.equals(aC))return;const i=this._inst;s===_C?(t.Update(i,null,aC),this._collisionCells=sC.New(sC.Rect,aC)):(t.Update(i,s,aC),s.copy(aC)),this._flags&=-17}_SetCollisionCellChanged(){this._flags|=16}_RemoveFromCollisionCells(){const e=this._collisionCells;e!==_C&&(this._objectClass._GetCollisionCellGrid().Update(this._inst,e,null),this._collisionCells=_C)}_UpdateRenderCell(){const e=this.GetLayer();if(!e.UsesRenderCells()||256&this._flags)return;const t=e.GetRenderGrid(),s=this.GetBoundingBox(),i=this._renderCells;if(aC.set(t.XToCell(s.getLeft()),t.YToCell(s.getTop()),t.XToCell(s.getRight()),t.YToCell(s.getBottom())),i.equals(aC))return;const n=this._inst;i===dC?(t.Update(n,null,aC),this._renderCells=sC.New(sC.Rect,aC)):(t.Update(n,i,aC),i.copy(aC)),e.SetRenderListStale()}_RemoveFromRenderCells(){const e=this._renderCells;e!==dC&&(this.GetLayer().GetRenderGrid().Update(this._inst,e,null),this._renderCells=dC)}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){const s=this._inst;let i=!1;const n=this._layer;if(e.GetUID()===s.GetUID())return;const r=e.GetWorldInfo();if(!r)throw new Error("expected world instance");const a=r.GetLayer();n.GetIndex()!==a.GetIndex()&&(n._RemoveInstance(s,!0),this._SetLayer(a),a._AddInstance(s,!0),i=!0);const o=a.MoveInstanceAdjacent(s,e,!!t);(i||o)&&this._runtime.UpdateRender()}GetInstanceEffectList(){return this._instanceEffectList}_SetHasAnyActiveEffect(e){this._SetFlag(64,e)}HasAnyActiveEffect(){return!!(64&this._flags)}_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()};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());const i=!!(32&this._flags);return i&&(s.sfi=i),this._solidFilterTags&&(s.sft=[...this._solidFilterTags].join(" ")),this._sceneGraphInfo&&"visual-state"!==e&&(s.sgi=this._sceneGraphInfo._SaveToJson(e,t),zC.has(this)&&(s.sgcd=zC.get(this).childrenData,s.sgzid=zC.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){if(e.hasOwnProperty("sgi")&&"visual-state"!==t){if(256&this._flags)return;this._sceneGraphInfo._OnAfterLoad(e.sgi,s)}}_OnAfterLoad2(e,t="full",s=null){if("visual-state"!==t)if(256&this._flags)this._ReleaseTmpSceneGraphInfo();else{if(e.hasOwnProperty("sgi"))this._sceneGraphInfo._SetTmpSceneGraphChildren(null,null,e.sgi,s);else if(s?.setFromJson&&this._tmpSceneGraphChildren)for(const e of this._tmpSceneGraphChildren)e.IsDestroyed()||this._runtime.DestroyInstance(e);this._ReleaseTmpSceneGraphInfo(),this.SetBboxChanged()}}_LoadFromJson(e,t,s=null){if(mC=!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")?lC.setFromJSON(e.c):e.hasOwnProperty("o")?(lC.copyRgb(this._color),lC.a=e.o):lC.setRgba(1,1,1,1),this._SetColor(lC),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._CreateSceneGraphInfo(null);const t=this._sceneGraphInfo,s=e.sgi;t._LoadFromJson(s),t._SetTmpSceneGraphChildren(this._tmpSceneGraphChildren,this._tmpSceneGraphChildrenIndexes),this._SetSceneGraphExportData(e.sgcd,e.sgzid)}if(e.hasOwnProperty("mesh")){const t=e.mesh;this.CreateMesh(t.cols,t.rows),this.GetSourceMesh().LoadFromJson(t)}else this.ReleaseMesh();this.SetBboxChanged(),mC=!0,this._UpdateRendererStateGroup(),"visual-state"!==t&&this._runtime.AddInstanceNeedingAfterLoad(this.GetInstance(),e)}_SetSceneGraphExportData(e,t){e&&sC.IsFiniteNumber(t)&&zC.set(this,{childrenData:e,zIndexData:t})}}}{const YC=self.C3;YC.BehaviorType=class extends YC.DefendedBase{constructor(e,t){super();const s=e.GetRuntime(),i=s.GetObjectReference(t[1]);s.GetAddonManager()._DelayCreateBehavior(i),this._runtime=s,this._objectClass=e,this._behavior=YC.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]);const n=this._behavior.GetSdkVersion();if(n<2&&(this._sdkType=YC.New(i.Type,this),!(this._sdkType instanceof YC.SDKBehaviorTypeBase)))throw new Error("v1 sdk type must derive from SDKBehaviorBase");if(YC.AddonManager._PushInitObject(this,n),n>=2){const e=i.Type??globalThis.ISDKBehaviorTypeBase;if(this._iBehaviorType=new e,!(this._iBehaviorType instanceof globalThis.ISDKBehaviorTypeBase))throw new Error("script interface class must derive from ISDKBehaviorTypeBase")}else this._iBehaviorType=new globalThis.IBehaviorType;YC.AddonManager._PopInitObject(n),this.OnCreate()}static Create(e,t){return YC.New(YC.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 qC=self.C3,KC=self.IBehaviorInstance;qC.BehaviorInstance=class extends qC.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");if(this.GetBehavior().GetSdkVersion()<2){if(this._sdkInst=qC.New(this._behaviorType.GetInstanceSdkCtor(),this,e),!(this._sdkInst instanceof qC.SDKBehaviorInstanceBase))throw new Error("v1 sdk type must derive from SDKBehaviorInstanceBase")}else{const t=this.GetBehavior().GetScriptInterfaceClass();this._InitScriptInterface(t.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){const i=globalThis.ISDKBehaviorInstanceBase;let 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(),h=a.GetObjectClass().GetIndex(),l=o.GetObjectClass().GetIndex();if(h!==l)return h-l;const c=a.GetPUID(),u=o.GetPUID();return c!==u?c-u:n._GetIndex()-r._GetIndex()}_InitScriptInterface(e,t){const s=KC,i=e??this._sdkInst.GetScriptInterfaceClass(),n=i||s,r=this.GetBehavior().GetSdkVersion();if(qC.AddonManager._PushInitObject(this,r),qC.AddonManager._PushInitProperties(t),this._iScriptInterface=new n,qC.AddonManager._PopInitProperties(),qC.AddonManager._PopInitObject(r),i&&!(this._iScriptInterface instanceof s))throw new TypeError(`script interface class '${i.name}' does not extend the right base class '${s.name}'`);return this._iScriptInterface}GetScriptInterface(){return this._iScriptInterface||this._InitScriptInterface()}HasScriptInterface(){return!!this._iScriptInterface}}}{const $C=self.C3;$C.EffectList=class extends $C.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 e of t){const t=$C.New($C.EffectType,this,e,this._allEffectTypes.length);this._allEffectTypes.push(t),this._effectTypesByName.set(t.GetName().toLowerCase(),t),e.length>=3&&this._effectParams.push(this._LoadSingleEffectParameters(t,e[2]))}this.GetRuntime()._AddEffectList(this)}Release(){this.GetRuntime()._RemoveEffectList(this);for(const e of this._effectParamBuffers)e.Release();$C.clearArray(this._effectParamBuffers),$C.clearArray(this._allEffectTypes),$C.clearArray(this._activeEffectTypes),this._effectTypesByName.clear(),$C.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 t.GetCustomParametersByteSize()>0?$C.New($C.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;e0}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 this._activeEffectTypes.length>0}PreservesOpaqueness(){return this._preservesOpaqueness}GetEffectParametersForIndex(e){return this._effectParams[e]}_GetEffectChainShaderParametersForIndex(e){return 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 $C.Color){if(n.equalsIgnoringAlpha(s))return!1;n.copyRgb(s)}else{if(n===s)return!1;i[t]=s}return e({name:e.GetName(),active:e.IsActive(),params:$C.EffectList.SaveFxParamsToJson(this._effectParams[e.GetIndex()])}))}LoadFromJson(e){for(const t of e){const e=this.GetEffectTypeByName(t.name);e&&(e.SetActive(t.active),this._effectParams[e.GetIndex()]=$C.EffectList.LoadFxParamsFromJson(t.params))}this.UpdateActiveEffects(),this._UpdateAllEffectParamBuffers()}}}{const JC=self.C3;JC.EffectType=class extends JC.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=JC.New(JC.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 e=[];for(let t=0,s=this._shaderProgram.GetParameterCount();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{const t=e.GetShaderProgram();return t.GetCustomParametersByteSize()>0?ZC.New(ZC.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;ee.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._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 ZC.Color){if(n.equalsIgnoringAlpha(s))return!1;n.copyRgb(s)}else{if(n===s)return!1;i[t]=s}return ee.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:ZC.EffectList.SaveFxParamsToJson(this._effectParams[e.GetIndex()])}))}_LoadFromJson(e){for(const t of e){const e=this._effectList.GetEffectTypeByName(t.name);e&&(this._activeEffectFlags[e.GetIndex()]=t.active,this._effectParams[e.GetIndex()]=ZC.EffectList.LoadFxParamsFromJson(t.params))}this.UpdateActiveEffects(),this._UpdateAllEffectParamBuffers()}}}{const QC=self.C3,eb=[],tb=[],sb=[],ib=QC.New(QC.CollisionPoly),nb=QC.New(QC.CollisionPoly),rb=QC.New(QC.Quad),ab=QC.New(QC.Rect),ob=QC.New(QC.Rect);let hb=null,lb=null,cb=null;QC.CollisionEngine=class extends QC.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(e,t,s){for(const[i,n]of this._registeredCollisions){let r=null;if(e===i)r=n;else{if(e!==n)continue;r=i}r.BelongsToObjectClass(t)&&(s.includes(r)||s.push(r))}}CheckRegisteredCollision(e,t){if(!this._registeredCollisions.length)return!1;for(const[s,i]of this._registeredCollisions)if(e===s&&t===i||e===i&&t===s)return!0;return!1}ClearRegisteredCollisions(){QC.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();return n.IsTransformCompatibleWith(r)?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(e,t){const s=e.HasTilemap(),i=t.HasTilemap();if(s&&!i)return this.TestTilemapOverlapDifferentLayers(e,t);if(i&&!s)return this.TestTilemapOverlapDifferentLayers(t,e);if(i||s)return!1;{const s=e.GetLayer(),i=t.GetLayer();ib.copy(e.GetTransformedCollisionPoly()),nb.copy(t.GetTransformedCollisionPoly());const n=ib.pointsArr();for(let t=0,i=n.length;t{const[i,n]=a.CanvasCssToLayer(o,t,s,e.GetTotalZElevation());return e.ContainsPoint(i,n)})),h){if(s)return!1;i._PushInstance(n)}else r&&i._PushElseInstance(n)}}else{let e,o=!1;r&&!n.IsFirstConditionOfType(this._runtime.GetCurrentCondition())?this._runtime.IsCurrentConditionFirst()&&!i._GetOwnElseInstances().length&&i._GetOwnInstances().length?e=i._GetOwnInstances():(e=i._GetOwnElseInstances(),o=!0):e=i._GetOwnInstances();let h=0;for(let n=0,l=e.length;n{const[s,i]=a.CanvasCssToLayer(u,e,t,c.GetTotalZElevation());return c.ContainsPoint(s,i)})),d){if(s)return!1;o?i._PushInstance(l):e[h++]=l}else o?e[h++]=l:r&&i._PushElseInstance(l)}s||(e.length=h)}return e.ApplySolToContainer(),a.Release(),!!s||i.HasAnyInstances()}_ObjectClassCanUseCollisionCells(e,t){if(!e)return!0;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)):QC.appendArray(i,n.GetInstances());else this._ObjectClassCanUseCollisionCells(e,t)?(t._UpdateAllCollisionCells(),t._GetCollisionCellGrid().QueryRange(s,i)):QC.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(),eb);for(const t of eb)if(this.IsSolidCollisionAllowed(t,e)&&this.TestOverlap(e,t))return QC.clearArray(eb),t;return QC.clearArray(eb),null}TestRectOverlapSolid(e,t){this.GetSolidCollisionCandidates(null,e,eb);for(const s of eb)if(this.IsSolidCollisionAllowed(s,t)&&this.TestRectOverlap(e,s))return QC.clearArray(eb),s;return QC.clearArray(eb),null}TestOverlapJumpthru(e,t){let s=null;t&&(s=sb,QC.clearArray(s));const i=e.GetWorldInfo();this.GetJumpthruCollisionCandidates(i.GetLayer(),i.GetBoundingBox(),eb);for(const i of eb)if(i._IsJumpthruEnabled()&&this.TestOverlap(e,i)){if(!t)return QC.clearArray(eb),i;s.push(i)}return QC.clearArray(eb),s}PushOut(e,t,s,i,n){i=i||50;const r=e.GetWorldInfo(),a=r.GetX(),o=r.GetY();for(let h=0;h0){const e=Math.PI;this.hitNormal=_b.clampAngle(this.hitNormal+e),this.normalX=-this.normalX,this.normalY=-this.normalY}}TestInstanceSegment(e,t,s,i,n){const r=_b.rayIntersect(this.x1,this.y1,this.x2,this.y2,t,s,i,n);r>=0&&r[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=fb.New(fb.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;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;const s=navigator.gpu&&this._isWebGPUEnabled;let 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){const t={nearZ:this._zNear,farZ:this._zFar};let s=!0;"no"===this._multitexturingMode?s=!1:"auto"===this._multitexturingMode&&(s=fb.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=fb.New(fb.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=fb.New(fb.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=fb.Gfx.WebGPUShaderProgram.GetDefaultVertexShaderSource(this._webgpuRenderer.IsColorDataF16());e.push(this._webgpuRenderer.CreateShaderProgram(Object.assign({vertexSrc:i,name:t},s)))}await Promise.all(e)}}async _InitWebGL(){if(this._shaderData){const e=[];for(const[t,s]of Object.entries(this._shaderData)){let i;if(s.glslWebGL2&&this._webglRenderer.GetWebGLVersionNumber()>=2)s.src=s.glslWebGL2,i=fb.Gfx.WebGLShaderProgram.GetDefaultVertexShaderSource_WebGL2();else{if(!s.glsl)throw new Error(`shader '${t}' does not support WebGL 1`);s.src=s.glsl,i=fb.Gfx.WebGLShaderProgram.GetDefaultVertexShaderSource()}e.push(this._webglRenderer.CreateShaderProgram(Object.assign({vertexSrc:i,name:t},s)))}await Promise.all(e),this._webglRenderer.ResetLastProgram(),this._webglRenderer.SetTextureFillMode()}this._webglRenderer.SupportsGPUProfiling()&&(this._gpuFrameTimingsBuffer=fb.New(fb.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())return;const s=e.devicePixelRatio;this.IsInWorker()&&(self.devicePixelRatio=s),t._SetDevicePixelRatio(s),this._isDocumentFullscreen=!!e.isFullscreen,this._cssDisplayMode=e.cssDisplayMode,this.SetSize(e.innerWidth,e.innerHeight),t.UpdateRender();const i=new fb.Event("window-resize");i.data=e,t.Dispatcher().dispatchEventAndWaitAsyncSequential(i);const n=new fb.Event("resize");n.cssWidth=this.GetCssWidth(),n.cssHeight=this.GetCssHeight(),n.deviceWidth=this.GetDeviceWidth(),n.deviceHeight=this.GetDeviceHeight(),t.DispatchUserScriptEvent(n),this._runtime.GetCurrentLayout()?.BoundScrolling(),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)return;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:e}of this._canvasLayers)e.width=this._canvasDeviceWidth,e.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 e of this._availableAdditionalRenderTargets)n.DeleteRenderTarget(e);fb.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;if(e/t>r){const s=t*r;this._canvasCssWidth=Math.round(s),this._canvasCssHeight=t,this._canvasCssOffsetX=Math.floor((e-this._canvasCssWidth)/2),this._canvasCssOffsetY=0}else{const s=e/r;this._canvasCssWidth=e,this._canvasCssHeight=Math.round(s),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){const s=this._runtime.GetDevicePixelRatio();1!==s&&(e+=1,t+=1);const i=this._runtime.GetOriginalViewportWidth(),n=this._runtime.GetOriginalViewportHeight(),r=i/n;let a;a=e/t>r?t*r*s/i:e/r*s/n,a>1?a=Math.floor(a):a<1&&(a=1/Math.ceil(1/a)),this._canvasDeviceWidth=Math.round(i*a),this._canvasDeviceHeight=Math.round(n*a),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();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;const i=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(e){if("high"===this._wantFullscreenScalingQuality)this._drawWidth=this._canvasDeviceWidth,this._drawHeight=this._canvasDeviceHeight,this._fullscreenScalingQuality="high";else{let t,s;if("off"===this.GetCurrentFullscreenMode()?(t=this._runtime.GetViewportWidth(),s=this._runtime.GetViewportHeight()):(t=this._runtime.GetOriginalViewportWidth(),s=this._runtime.GetOriginalViewportHeight()),this._canvasDeviceWidthe&&(this._drawHeight=this._drawWidth/i)}else if("scale-outer"===e){const e=t/s,i=this._windowInnerWidth/this._windowInnerHeight;i>e?this._drawWidth=this._drawHeight*i:ii||"scale-inner"===e&&n=124)}async SetHTMLLayerCount(e,t=!1){if(e<1)throw new Error("invalid HTML layer count");if(this._canvasLayers.length===e)return;const s={count:e,layersDomState:this._runtime.GetLayoutManager().GetMainRunningLayout()._GetRootLayers().filter(e=>e.IsHTMLElementsLayer()).map(e=>e._GetHTMLLayerDOMState()),immediate:t,marginLeft:this._canvasCssOffsetX,marginTop:this._canvasCssOffsetY,styleWidth:this._canvasCssWidth,styleHeight:this._canvasCssHeight};let i;if(i=this.IsInWorker()?await this._runtime.PostComponentMessageToDOMAsync("canvas","set-html-layer-count",s):self.c3_runtimeInterface._OnSetHTMLLayerCount(s),e=this._canvasLayers.length)return;const t=this.GetMainCanvas(),s=this._canvasLayers[e].ctx;this._CanUseImageBitmapRenderingContext()?s.transferFromImageBitmap(t.transferToImageBitmap()):(s.globalCompositeOperation="copy",s.drawImage(t,0,0))}GetAdditionalRenderTarget(e){e.depth=this._runtime.Uses3DFeatures();const t=this._availableAdditionalRenderTargets,s=t.findIndex(t=>t.IsCompatibleWithOptions(e));let i;return-1!==s?(i=t[s],t.splice(s,1)):i=this.GetRenderer().CreateRenderTarget(e),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 e=this._layersGpuProfile.get(t);e&&(yield e)}}GetLayerTimingsBuffer(e){if(!this.GetRenderer().SupportsGPUProfiling())return null;let t=this._layersGpuProfile.get(e);return t||(t={layer:e,name:e.GetName(),timingsBuffer:fb.New(fb.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 e of this.activeLayersGpuProfiles())e.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 e=new Map;for(const t of this.activeLayersGpuProfiles())t.timingsBuffer.DeleteAllBeforeFrameNumber(this._gpuTimeEndFrame),t.lastTotalUtilisation=Math.min(t.curUtilisation,1),e.set(t.layer,t.lastTotalUtilisation);for(const t of this.activeLayersGpuProfiles()){const s=t.layer,i=(e.get(s)||0)-s.GetSubLayers().reduce((t,s)=>t+(e.get(s)||0),0);t.lastSelfUtilisation=fb.clamp(i,0,1)}const t=this._runtime.GetMainRunningLayout(),s=this._gpuLastUtilisation-t._GetRootLayers().reduce((t,s)=>t+(e.get(s)||0),0);self.C3Debugger.UpdateGPUProfile(fb.clamp(s,0,1),this._gpuLastUtilisation,[...this.activeLayersGpuProfiles()])}this._gpuTimeStartFrame=this._gpuTimeEndFrame,this._gpuTimeEndFrame=0}}GetGPUFrameTimingsBuffer(){return this._gpuFrameTimingsBuffer}_UpdateTick_WebGPU(){if(0===this._gpuTimeEndFrame)return;for(let e=this._gpuTimeStartFrame;ea&&(a=i);const h=Number(i-s)/1e9;t[e]+=h}s+=Number(a-r)/1e9}if(this._gpuLastUtilisation=fb.clamp(s,0,1),this._runtime.IsDebug()){const s=e.GetLayers(),i=new Map;for(let e=0,n=Math.min(s.length,t.length-1);ee+(i.get(t)||0),0);r.set(e,s),n.push({name:e.GetName(),lastSelfUtilisation:fb.clamp(t,0,1),lastTotalUtilisation:fb.clamp(s,0,1)})}const a=this._gpuLastUtilisation-e._GetRootLayers().reduce((e,t)=>e+(r.get(t)||0),0);self.C3Debugger.UpdateGPUProfile(fb.clamp(a,0,1),this._gpuLastUtilisation,n)}for(let e=this._gpuTimeStartFrame;e{this._snapshotResolve=e})),this._snapshotPromise}_MaybeTakeSnapshot(){if(!this._snapshotFormat)return;let e=this.GetMainCanvas();const t=this._snapshotArea,s=fb.clamp(Math.floor(t.getLeft()),0,e.width),i=fb.clamp(Math.floor(t.getTop()),0,e.height);let n=t.width();n=0===n?e.width-s:fb.clamp(Math.floor(n),0,e.width-s);let r=t.height();if(r=0===r?e.height-i:fb.clamp(Math.floor(r),0,e.height-i),(0!==s||0!==i||n!==e.width||r!==e.height)&&n>0&&r>0){const t=fb.CreateCanvas(n,r);t.getContext("2d").drawImage(e,s,i,n,r,0,0,n,r),e=t}fb.CanvasToBlob(e,this._snapshotFormat,this._snapshotQuality).then(e=>{this._snapshotUrl&&URL.revokeObjectURL(this._snapshotUrl),this._snapshotUrl=URL.createObjectURL(e),this._snapshotPromise=null,this._snapshotResolve(e)}),this._snapshotFormat="",this._snapshotQuality=1}GetCanvasSnapshotUrl(){return this._snapshotUrl}SetIsPastingToDrawingCanvas(e){e?this._isPastingToDrawingCanvas++:this._isPastingToDrawingCanvas--}IsPastingToDrawingCanvas(){return this._isPastingToDrawingCanvas>0}InitLoadingScreen(e){const t=this.GetRenderer();if(2===e)this._percentText=fb.New(fb.Gfx.RendererText,this.GetRenderer()),this._percentText.SetFontName("Arial"),this._percentText.SetFontSize(16),this._percentText.SetHorizontalAlignment("center"),this._percentText.SetVerticalAlignment("center"),this._percentText.SetSize(300,200);else if(0===e){const e=this._runtime.GetLoadingLogoAsset();e&&e.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 fb.FetchBlob(e),s=await this._runtime.RasterSvgImage(t,2048,2048);return await this.GetRenderer().CreateStaticTextureAsync(s,{mipMapQuality:"high"})}async _LoadBitmapSplashImage(e){e=new URL(e,this._runtime.GetRuntimeBaseURL()).toString();const t=await fb.FetchBlob(e);return await 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()),3!==this._runtime.GetLoaderStyle()&&this.HideCordovaSplashScreen()}async EndLoadingScreen(){const e=this.GetRenderer();this._loadingProgress=1;const t=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)return;const e=this.GetRenderer();e.Start(),this._rafId=-1;const t=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,120,0);else if(2===s)this._DrawPercentTextLoadingScreen(t);else if(3===s)fb.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;vb.setRect(t-150,s-100,t+150,s+100);const i=this.GetRenderer();i.SetTexture(this._percentText.GetTexture()),i.Quad3(vb,this._percentText.GetTexRect())}_DrawProgressBarLoadingScreen(e,t,s){const i=this.GetRenderer();i.SetColorFillMode(),e?i.SetColorRgba(1,0,0,1):i.SetColorRgba(.118,.565,1,1);const n=this._canvasCssWidth/2,r=this._canvasCssHeight/2,a=t/2;Ab.setWH(n-a,r-4+s,Math.floor(t*this._loadingProgress),8),i.Rect(Ab),Ab.setWH(n-a,r-4+s,t,8),Ab.offset(-.5,-.5),Ab.inflate(.5,.5),i.SetColorRgba(0,0,0,1),i.LineRect2(Ab),Ab.inflate(1,1),i.SetColorRgba(1,1,1,1),i.LineRect2(Ab)}_DrawProgressBarAndLogoLoadingScreen(e){const t=this.GetRenderer(),s=this._runtime.GetLoadingLogoAsset();if(!s)return void this._DrawProgressBarLoadingScreen(e,120,0);const i=s.GetTexture();if(!i)return void this._DrawProgressBarLoadingScreen(e,120,0);const n=i.GetWidth(),r=i.GetHeight(),a=this._canvasCssWidth/2,o=this._canvasCssHeight/2,h=n/2,l=r/2;vb.setRect(a-h,o-l,a+h,o+l),t.SetTexture(i),t.Quad(vb),this._DrawProgressBarLoadingScreen(e,n,l+16)}_DrawSplashLoadingScreen(e){const t=this.GetRenderer(),s=this._splashTextures.logo,i=this._splashTextures.powered,n=this._splashTextures.website,r=Date.now();0===this._splashFrameNumber&&(this._loaderStartTime=r);const a=this._runtime.IsPreview()||this._runtime.IsFBInstantAvailable()&&!this._runtime.IsCordova(),o=a?0:200,h=a?0:3e3;let l=1;"fade-in"===this._splashState?l=Math.min((r-this._loaderStartTime)/300,1):"fade-out"===this._splashState&&(l=Math.max(1-(r-this._splashFadeOutStartTime)/300,0)),t.SetColorFillMode(),t.SetColorRgba(.231*l,.251*l,.271*l,l),Ab.set(0,0,this._canvasCssWidth,this._canvasCssHeight),t.Rect(Ab);const c=Math.ceil(this._canvasCssWidth),u=Math.ceil(this._canvasCssHeight);let d,_;this._canvasCssHeight>256?(t.SetColorRgba(.302*l,.334*l,.365*l,l),d=c,_=Math.max(.005*u,2),Ab.setWH(0,.8*u-_/2,d,_),t.Rect(Ab),e?t.SetColorRgba(l,0,0,l):t.SetColorRgba(.161*l,.953*l,.816*l,l),d=c*this._loadingProgress,Ab.setWH(.5*c-d/2,.8*u-_/2,d,_),t.Rect(Ab),t.SetColorRgba(l,l,l,l),t.SetTextureFillMode(),i&&(d=1.5*fb.clamp(.22*u,105,.6*c),_=d/8,Ab.setWH(.5*c-d/2,.2*u-_/2,d,_),t.SetTexture(i),t.Rect(Ab)),s&&(d=Math.min(.395*u,.95*c),_=d,Ab.setWH(.5*c-d/2,.485*u-_/2,d,_),t.SetTexture(s),t.Rect(Ab)),n&&(d=1.5*fb.clamp(.22*u,105,.6*c),_=d/8,Ab.setWH(.5*c-d/2,.868*u-_/2,d,_),t.SetTexture(n),t.Rect(Ab))):(t.SetColorRgba(.302*l,.334*l,.365*l,l),d=c,_=Math.max(.005*u,2),Ab.setWH(0,.85*u-_/2,d,_),t.Rect(Ab),e?t.SetColorRgba(l,0,0,l):t.SetColorRgba(.161*l,.953*l,.816*l,l),d=c*this._loadingProgress,Ab.setWH(.5*c-d/2,.85*u-_/2,d,_),t.Rect(Ab),t.SetColorRgba(l,l,l,l),t.SetTextureFillMode(),s&&(d=.55*u,_=d,Ab.setWH(.5*c-d/2,.45*u-_/2,d,_),t.SetTexture(s),t.Rect(Ab))),this._splashFrameNumber++,"fade-in"===this._splashState&&r-this._loaderStartTime>=300&&this._splashFrameNumber>=2&&(this._splashState="wait",this._splashFadeInFinishTime=r),"wait"===this._splashState&&r-this._splashFadeInFinishTime>=h&&this._loadingProgress>=1&&(this._splashState="fade-out",this._splashFadeOutStartTime=r),("fade-out"===this._splashState&&r-this._splashFadeOutStartTime>=300+o||a&&this._loadingProgress>=1&&r-this._loaderStartTime<500)&&this._splashDoneResolve()}}}{const Eb=self.C3,Fb=self.C3Debugger,Ob=self.assert,Bb=self.ISDKBehaviorInstanceBase,Lb={messagePort:null,runtimeBaseUrl:"",headless:!1,hasDom:!0,isInWorker:!1,useAudio:!0,exportType:""};let kb=!0;Eb.Runtime=class extends Eb.DefendedBase{constructor(e){e=Object.assign({},Lb,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,kb=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=Eb.New(Eb.AssetManager,this,e),this._layoutManager=Eb.New(Eb.LayoutManager,this),this._eventSheetManager=Eb.New(Eb.EventSheetManager,this),this._addonManager=Eb.New(Eb.AddonManager,this,e.wrapperComponentIds),this._collisionEngine=Eb.New(Eb.CollisionEngine,this),this._timelineManager=Eb.New(Eb.TimelineManager,this),this._transitionManager=Eb.New(Eb.TransitionManager,this),this._templateManager=Eb.New(Eb.TemplateManager,this),this._flowchartManager=Eb.New(Eb.FlowchartManager,this),this._textIconManager=Eb.New(Eb.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 Eb.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=Eb.New(Eb.KahanSum),this._gameTimeRaw=Eb.New(Eb.KahanSum),this._wallTime=Eb.New(Eb.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=Eb.New(Eb.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:Eb.New(Eb.Event,"pretick",!1),tick:Eb.New(Eb.Event,"tick",!1),tick2:Eb.New(Eb.Event,"tick2",!1),instancecreate:Eb.New(Eb.Event,"instancecreate",!1),instancedestroy:Eb.New(Eb.Event,"instancedestroy",!1),beforelayoutchange:Eb.New(Eb.Event,"beforelayoutchange",!1),layoutchange:Eb.New(Eb.Event,"layoutchange",!1)},this._eventObjects.instancecreate.instance=null,this._eventObjects.instancedestroy.instance=null,this._userScriptDispatcher=Eb.New(Eb.Event.Dispatcher),this._userScriptEventObjects=null;const t=(e,t)=>Eb.BehaviorInstance.SortByTickSequence(this,e,t);this._behInstsToTick=Eb.New(Eb.RedBlackSet,t),this._behInstsToPostTick=Eb.New(Eb.RedBlackSet,t),this._behInstsToTick2=Eb.New(Eb.RedBlackSet,t),this._jobScheduler=Eb.New(Eb.JobSchedulerRuntime,this,e.jobScheduler),e.canvas&&(this._canvasManager=Eb.New(Eb.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 Eb.New(Eb.Runtime,e)}Release(){Eb.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)return void this._waitingToHandleEvents.push(e);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 e=new Eb.Event(s);e.data=i,this._dispatcher.dispatchEventAndWaitAsyncSequential(e)}if(a){const e=new Eb.Event(s,!0);for(const[t,s]of Object.entries(i))e[t]=s;this.DispatchUserScriptEvent(e)}}const h=this._domEventHandlers.get(t);if(!h)return void(r||a||console.warn(`[Runtime] No DOM event handlers for component '${t}'`));const l=h.get(s);if(!l)return void(r||a||console.warn(`[Runtime] No DOM handler '${s}' for component '${t}'`));let c=null;try{c=l(i)}catch(e){return console.error(`Exception in '${t}' handler '${s}':`,e),void(null!==o&&this._PostResultToDOM(o,!1,""+e))}null!==o&&(c&&c.then?c.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,c))}_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;this._pendingResponsePromises.get(t).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){Eb.CommonACES_SetRuntime(this),this.IsDebug()?await Fb.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 e=this.GetWebGLRenderer();console.info(`[C3 runtime] Hosted in ${this.IsInWorker()?"worker":"DOM"}, rendering with WebGL ${e.GetWebGLVersionNumber()} [${e.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 e of this._waitingToHandleEvents)this._OnEventFromDOM(e);Eb.clearArray(this._waitingToHandleEvents),this._canvasManager&&this._canvasManager.StartLoadingScreen();for(const t of e.runOnStartupFunctions)this._additionalLoadPromises.push(this._RunOnStartupFunction(t));if(await Promise.all([this._assetManager.WaitForAllToLoad(),...this._additionalLoadPromises]),Eb.clearArray(this._additionalLoadPromises),!this._assetManager.HasHadErrorLoading())return this._canvasManager&&await this._canvasManager.EndLoadingScreen(),await this._dispatcher.dispatchEventAndWaitAsync(new Eb.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;this._projectName=t[0],this._projectVersion=t[16],this._projectUniqueId=t[31],this._appId=t[38],this._exportTimestamp=t[36];const s=t[39]||"loading-logo.png";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];const i=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,e&&(this._loadingLogoAsset=i.LoadImage({url:e}))}this._canvasManager&&(this._canvasManager.SetFullscreenMode(Eb.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];n&&await this._LoadExportToVideoData(n),this._InitScriptInterfaces(),this._addonManager.CreateSystemPlugin(),this._objectReferenceTable=self.C3_GetObjectRefTable();const r=t[2];for(const e of r[1])this._addonManager.CreateBehavior(e);for(const e of r[0])this._addonManager.CreatePlugin(e);this._objectReferenceTable=self.C3_GetObjectRefTable(),this._LoadJsPropNameTable(),this._addonManager._InitAddonScriptInterfaces();for(const e of t[3]){const t=Eb.ObjectClass.Create(this,this._allObjectClasses.length,e);this._allObjectClasses.push(t),this._objectClassesByName.set(t.GetName().toLowerCase(),t),this._objectClassesBySid.set(t.GetSID(),t)}for(const e of t[4])this._allObjectClasses[e[0]]._LoadFamily(e);for(const e of t[27]){const t=e.map(e=>this._allObjectClasses[e]);this._allContainers.push(Eb.New(Eb.Container,this,t))}this._InitObjectsScriptInterface();for(const e of this._allObjectClasses)e._OnAfterCreate();for(const e of t[5])this._layoutManager.Create(e);const a=t[1];if(a){const e=this._layoutManager.GetLayoutByName(a);e&&this._layoutManager.SetFirstLayout(e)}for(const e of t[35])this._transitionManager.Create(e);for(const e of t[33])this._timelineManager.Create(e);for(const e of t[44])this._templateManager.Create(e);this._templateManager.HasTemplates()||(this._templateManager.Release(),this._templateManager=null);for(const e of t[49])this._flowchartManager.Create(e);this._flowchartManager.HasFlowcharts()||(this._flowchartManager.Release(),this._flowchartManager=null);for(const e of t[6])this._eventSheetManager.Create(e);this._eventSheetManager._PostInit(),this._InitGlobalVariableScriptInterface(),Eb.clearArray(this._objectReferenceTable),this.FlushPendingInstances();let o="any";const h=t[20];1===h?o="portrait":2===h&&(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 e=null;const t=new Promise(t=>e=t);if(this._usesLoaderLayout){for(const e of this._allObjectClasses)e.IsFamily()||e.IsOnLoaderLayout()||!e.IsWorldType()||e.OnCreate();(async()=>{await this._assetManager.WaitForAllToLoad(),await t,this._isLoading=!1,this._OnLoadFinished()})()}else this._isLoading=!1;this._assetManager.SetInitialLoadFinished(),this.IsDebug()&&Fb.RuntimeInit(kb);for(const e of this._layoutManager.GetAllLayouts())e._CreateGlobalNonWorlds();this.IsExportToVideo()&&await this._InitExportToVideo();const s=this._layoutManager.GetFirstLayout();await s._Load(null,this.GetRenderer()),await s._StartRunning(!0),this._fpsLastTime=performance.now(),e(),this._usesLoaderLayout||this._OnLoadFinished(),(await this.PostComponentMessageToDOMAsync("runtime","before-start-ticking")).isSuspended&&!this.IsExportToVideo()?(this._suspendCount++,this._isPageVisibilitySuspended=!0):this.Tick()}_OnLoadFinished(){this.Trigger(Eb.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=Eb.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=Eb.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&&Fb.StartMeasuringScriptTime(),this._userScriptDispatcher.dispatchEvent(e),t&&Fb.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)return;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)return;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 Eb.ObjectClass&&e.IsFamily()){const a=e.GetFamilyMembers(),o=Math.floor(this.Random()*a.length);return this.CreateInstance(a[o],t,s,i,n,r)}const a=this._templateManager.GetTemplateData(e,r);if(a){const e=this.CreateInstanceFromData(a,t,!1,s,i,!1,n,void 0,n);return this._templateManager.MapInstanceToTemplateName(e,r),e}}return this.CreateInstanceFromData(e,t,!1,s,i,!1,n,void 0,n)}CreateInstanceFromData(e,t,s,i,n,r,a,o,h){let l=null,c=null;if(e instanceof Eb.ObjectClass){if(c=e,c.IsFamily()){const e=c.GetFamilyMembers();c=e[Math.floor(this.Random()*e.length)]}l=c.GetDefaultInstanceData()}else l=e,c=this.GetObjectClassByIndex(l[1]);const u=c.GetPlugin().IsWorldType();if(this._isLoading&&u&&!c.IsOnLoaderLayout())return null;const d=t;let _;u||(t=null),_=s&&!r&&l&&!this._instancesByUid.has(l[2])?l[2]:this._nextUid++;const p=l?l[0]:null,g=Eb.New(Eb.Instance,{runtime:this,objectType:c,layer:t,worldData:p,instVarData:l?l[3]:null,uid:_,tags:l?l[6]:null});this._instancesByUid.set(_,g);let m=null;if(u&&(m=g.GetWorldInfo(),void 0!==i&&void 0!==n&&(m.SetX(i),m.SetY(n)),c._SetAnyCollisionCellChanged(!0)),t&&(h||t._AddInstance(g,!0),t.GetLayout().MaybeLoadTexturesFor(c)),this._objectCount++,c.IsInContainer()&&!s&&!r){const e=new Set;for(const t of c.GetContainer().objectTypes()){if(t===c)continue;const s=this._MaybeGetChildInstanceForObjectTypeData(t,m,e);if(s){const e=this.CreateInstanceFromData(s,d,!1,m?m.GetX():i,m?m.GetY():n,!0,!1,void 0,h);g._AddSibling(e)}else{const e=this.CreateInstanceFromData(t,d,!1,m?m.GetX():i,m?m.GetY():n,!0,!1,void 0,h);g._AddSibling(e)}}for(const e of g.siblings()){e._AddSibling(g);for(const t of g.siblings())e!==t&&e._AddSibling(t)}}if(u&&!s&&a&&this._CreateChildInstancesFromData(g,p,m,t,i,n,h),c.IsInContainer()&&!s&&!r&&a)for(const e of g.siblings()){const s=e.GetWorldInfo();if(!s)continue;const i=e.GetPlugin(),n=e.GetObjectClass().GetDefaultInstanceData()[0];i.IsWorldType()?this._CreateChildInstancesFromData(e,n,s,t,s.GetX(),s.GetY(),h):this._CreateChildInstancesFromData(e,n,s,t,void 0,void 0,h)}if(!r&&a){void 0===i&&(i=p[0]),void 0===n&&(n=p[1]);const e=m.GetTopParent(),t=i-m.GetX()+e.GetX(),s=n-m.GetY()+e.GetY();e.SetXY(t,s)}c._SetIIDsStale();const f=l?Eb.cloneArray(l[5]):null,S=l?l[4].map(e=>Eb.cloneArray(e)):null,G=u&&p&&p[13];if(G&&g._SetHasTilemap(),g._CreateSdkInstance(f,S),G){const e=p[13];g.GetSdkInstance().LoadTilemapData(e[2],e[0],e[1])}this._instancesPendingCreate.push(g),this._hasPendingInstances=!0,this.IsDebug()&&Fb.InstanceCreated(g);const y=this._eventObjects.instancecreate;return y.instance=g,this._dispatcher.dispatchEvent(y),g}_GetInstanceData(e){const t=e[0],s=e[1],i=e[2],n=e[6];return n||this._layoutManager.GetLayoutBySID(t).GetLayer(s).GetInitialInstanceData(i)}_MaybeGetChildInstanceForObjectTypeData(e,t,s){const i=t?.GetSceneGraphChildrenExportData()??[];for(const t of i){const i=this._GetInstanceData(t),n=!!t[4],r=this.GetObjectClassByIndex(i[1]);if(!s.has(i)&&e===r&&n)return s.add(i),i}}_CreateChildInstancesFromData(e,t,s,i,n,r,a){const o=s.GetSceneGraphZIndexExportData(),h=s.GetSceneGraphChildrenExportData();if(e.GetWorldInfo().SetSceneGraphZIndex(o),!h)return;void 0===n&&(n=t[0]),void 0===r&&(r=t[1]);const l=new Set,c=t[0],u=t[1];for(const t of h){const s=t[0],o=t[1],h=t[2],d=t[3],_=!!t[4],p=t[5],g=t[6];let m;m=g||this._layoutManager.GetLayoutBySID(s).GetLayer(o).GetInitialInstanceData(h);const f=this.GetObjectClassByIndex(m[1]),S=e.HasSibling(f),G=l.has(f);if(S&&!G&&_){const t=e.GetSibling(f);t.GetWorldInfo().Init(m[0]);const s=n+m[0][0]-c,i=r+m[0][1]-u;t.GetWorldInfo().SetXY(s,i),t.GetWorldInfo().SetSceneGraphZIndex(p),e.AddChild(t,{transformX:!!(1&d),transformY:!!(d>>1&1),transformWidth:!!(d>>2&1),transformHeight:!!(d>>3&1),transformAngle:!!(d>>4&1),destroyWithParent:!!(d>>5&1),transformZElevation:!!(d>>6&1),transformOpacity:!!(d>>7&1),transformVisibility:!!(d>>8&1)}),l.add(f)}else{const t=n+m[0][0]-c,s=r+m[0][1]-u,o=this.CreateInstanceFromData(m,i,!1,t,s,!1,!0,e,a);o.GetWorldInfo().SetSceneGraphZIndex(p),e.AddChild(o,{transformX:!!(1&d),transformY:!!(d>>1&1),transformWidth:!!(d>>2&1),transformHeight:!!(d>>3&1),transformAngle:!!(d>>4&1),destroyWithParent:!!(d>>5&1),transformZElevation:!!(d>>6&1),transformOpacity:!!(d>>7&1),transformVisibility:!!(d>>8&1)})}}}DestroyInstance(e){if(this._instancesPendingRelease.has(e))return;const t=e.GetObjectClass();let s=this._instancesPendingDestroy.get(t);if(s){if(s.has(e))return;s.add(e)}else s=new Set,s.add(e),this._instancesPendingDestroy.set(t,s);if(this.IsDebug()&&Fb.InstanceDestroyed(e),e._MarkDestroyed(),this._hasPendingInstances=!0,e.IsInContainer())for(const t of e.siblings())this.DestroyInstance(t);for(const t of e.children())t.GetDestroyWithParent()&&this.DestroyInstance(t);if(!this._layoutManager.IsEndingLayout()&&!this._isLoadingState){const t=this.GetEventSheetManager();t.BlockFlushingInstances(!0),e._TriggerOnDestroyed(),t.BlockFlushingInstances(!1)}e._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()}Eb.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 e of t){const t=this._eventObjects.instancedestroy;t.instance=e,this._dispatcher.dispatchEvent(t),this._instancesByUid.delete(e.GetUID()),this._instanceTimes.delete(e);const s=e.GetWorldInfo();s&&(s._RemoveFromCollisionCells(),s._RemoveFromRenderCells(),s._MarkDestroyed()),this._instancesPendingRelease.add(e),this._objectCount--}Eb.arrayRemoveAllInSet(e.GetInstances(),t),e._SetIIDsStale(),this._instancesPendingReleaseAffectedObjectClasses.add(e);for(const s of e.GetFamilies())Eb.arrayRemoveAllInSet(s.GetInstances(),t),s._SetIIDsStale(),this._instancesPendingReleaseAffectedObjectClasses.add(s);if(e.GetPlugin().IsWorldType()){const e=new Set([...t].map(e=>e.GetWorldInfo().GetLayer()));for(const s of e)s._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){e=!!e,this._isAutoSuspendEnabled!==e&&(this._isAutoSuspendEnabled=!!e,this._isAutoSuspendEnabled&&this._isPageVisibilitySuspended&&(this.SetSuspended(!1),this._isPageVisibilitySuspended=!1))}_IsAutoSuspendEnabled(){return this._isAutoSuspendEnabled}_OnRendererContextLost(){this._dispatcher.dispatchEvent(Eb.New(Eb.Event,"renderercontextlost")),this.SetSuspended(!0);for(const e of this._allObjectClasses)!e.IsFamily()&&e.HasLoadedTextures()&&e.ReleaseTextures();const e=this.GetMainRunningLayout();e&&e._OnRendererContextLost(),Eb.ImageInfo.OnRendererContextLost(),Eb.ImageAsset.OnRendererContextLost()}async _OnRendererContextRestored(){await this.GetMainRunningLayout()._Load(null,this.GetRenderer()),this._dispatcher.dispatchEvent(Eb.New(Eb.Event,"renderercontextrestored")),this.SetSuspended(!1),this.UpdateRender()}_OnVisibilityChange(e){if(!this._isAutoSuspendEnabled)return;const t=e.hidden;this.SetSuspended(t),this._isPageVisibilitySuspended=t,t||this.UpdateRender()}_OnWindowBlur(e){this.IsPreview()&&this._pauseOnBlur&&!Eb.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=Eb.RequestUnlimitedAnimationFrame(e.tickOnly)),-1===this._rafId&&(this._rafId=self.requestAnimationFrame(e.renderOnly))):-1===this._ruafId&&(this._ruafId=Eb.RequestUnlimitedAnimationFrame(e.normal))}_CancelAnimationFrame(){-1!==this._rafId&&(self.cancelAnimationFrame(this._rafId),this._rafId=-1),-1!==this._ruafId&&(Eb.CancelUnlimitedAnimationFrame(this._ruafId),this._ruafId=-1)}IsSuspended(){return this._suspendCount>0}SetSuspended(e){if(this.IsExportToVideo())return;const t=this.IsSuspended();this._suspendCount+=e?1:-1,this._suspendCount<0&&(this._suspendCount=0);const s=this.IsSuspended();if(!t&&s)console.log("[Construct] Suspending"),this._CancelAnimationFrame(),this._dispatcher.dispatchEvent(Eb.New(Eb.Event,"suspend")),this.DispatchUserScriptEvent(Eb.New(Eb.Event,"suspend")),this.Trigger(Eb.Plugins.System.Cnds.OnSuspend,null,null);else if(t&&!s){console.log("[Construct] Resuming");const e=performance.now();this._lastTickTime=e,this._fpsLastTime=e,this._fpsFrameCount=0,this._fps=0,this._tpsTickCount=0,this._tps=0,this._mainThreadTime=0,this._mainThreadTimeCounter=0,this._dispatcher.dispatchEvent(Eb.New(Eb.Event,"resume")),this.DispatchUserScriptEvent(Eb.New(Eb.Event,"resume")),this.Trigger(Eb.Plugins.System.Cnds.OnResume,null,null),this.HitBreakpoint()||this.Tick(e)}}_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){const s=t?performance.now():0;let i;return e instanceof Bb?(i=e._tick(),t&&Fb.AddIndividualBehaviorTickTime(e.behavior,performance.now()-s)):(i=e.Tick(),t&&Fb.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){const s=t?performance.now():0;let i;return e instanceof Bb?(i=e._postTick(),t&&Fb.AddIndividualBehaviorTickTime(e.behavior,performance.now()-s)):(i=e.PostTick(),t&&Fb.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){const s=t?performance.now():0;let i;return e instanceof Bb?(i=e._tick2(),t&&Fb.AddIndividualBehaviorTickTime(e.behavior,performance.now()-s)):(i=e.Tick2(),t&&Fb.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);Eb.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);Eb.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);Eb.IsIterator(s)&&(yield*s)}this._behInstsToTick2.SetQueueingEnabled(!1)}async Tick(e,t,s){this._hasStartedTicking=!0;const i="background-wake"===s,n="background-wake"!==s&&"skip-render"!==s,r=this.GetLayoutManager(),a=this.GetCanvasManager();if(!this._hasStarted||this.IsSuspended()&&!t&&!i)return;const o=performance.now();this._isInTick=!0,this._MeasureDt(e||0),this._tpsTickCount++,this._ReleasePendingInstances();const h=this.Step_BeforePreTick();this.IsDebugging()&&await h;const l=this._dispatcher.dispatchEventAndWait_AsyncOptional(this._eventObjects.pretick);l instanceof Promise&&await l,this.DispatchUserScriptEvent(this._userScriptEventObjects.pretick);const c=this.Step_AfterPreTick();this.IsDebugging()&&await c,this._NeedsHandleSaveOrLoad()&&await this._HandleSaveOrLoad(),r.IsPendingChangeMainLayout()&&await this._MaybeChangeLayout();const u=this.Step_RunEventsEtc();this.IsDebugging()&&await u;const d=r.GetMainRunningLayout(),_=d._GetPendingSetHTMLLayerCount();let p=!1;if(-1!==_&&(d._ResetPendingHTMLLayerCount(),a.GetHTMLLayerCount()!==_)){const e=this.GetCanvasManager().SetHTMLLayerCount(_);this.IsInWorker()&&(p=!0,await e)}this.PostComponentMessageToDOM("canvas","update-html-layer-dom-state",{layersDomState:d._GetRootLayers().filter(e=>e.IsHTMLElementsLayer()).map(e=>e._GetHTMLLayerDOMState())}),n&&this.Render(),p&&this.PostComponentMessageToDOM("canvas","cleanup-html-layers"),this.IsExportToVideo()&&(await this._ExportToVideoAddFrame(),this.GetGameTime()>=this.GetExportVideoDuration())?this._ExportToVideoFinish():(this.IsSuspended()||i||this._RequestAnimationFrame(),this._tickCount++,this._tickCountNoSave++,this._isInTick=!1,this._mainThreadTimeCounter+=performance.now()-o)}async Step_BeforePreTick(){const e=this._eventSheetManager,t=this.IsDebug();this.FlushPendingInstances(),e.BlockFlushingInstances(!0),this.PushCurrentLayout(this.GetMainRunningLayout()),t&&Fb.StartMeasuringTime(),this.IsDebugging()?await e.DebugRunScheduledWaits():e.RunScheduledWaits(),t&&Fb.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&&Fb.StartMeasuringTime(),s?await this.DebugIterateAndBreak(this._DebugBehaviorTick()):this._BehaviorTick(),s?await this.DebugIterateAndBreak(this._DebugBehaviorPostTick()):this._BehaviorPostTick(),t&&Fb.AddBehaviorTotalTickTime(),t&&Fb.StartMeasuringTime(),s?await this.DebugFireGeneratorEventAndBreak(n.tick):i.dispatchEvent(n.tick),t&&Fb.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&&Fb.StartMeasuringTime(),r?await e.DebugRunEvents(this._layoutManager):e.RunEvents(this._layoutManager),n&&Fb.AddEventsTime(),this._collisionEngine.ClearRegisteredCollisions(),this._ReleasePendingInstances(),this._isLayoutFirstTick=!1,e.BlockFlushingInstances(!0),n&&Fb.StartMeasuringTime(),r?await this.DebugIterateAndBreak(this._DebugBehaviorTick2()):this._BehaviorTick2(),n&&Fb.AddBehaviorTotalTickTime(),n&&Fb.StartMeasuringTime(),r?await this.DebugFireGeneratorEventAndBreak(s.tick2):t.dispatchEvent(s.tick2),n&&Fb.AddPluginTotalTickTime(),e.BlockFlushingInstances(!1),this.DispatchUserScriptEvent(i.tick2),r&&await e.RunQueuedDebugTriggersAsync(),this.FlushPendingInstances(),this._ReleasePendingInstances()}_ReleasePendingInstances(){if(0===this._instancesPendingRelease.size)return;const e=this._dispatcher;e.SetDelayRemoveEventsEnabled(!0);for(const e of this._instancesPendingReleaseAffectedObjectClasses)e.GetSolStack().RemoveInstances(this._instancesPendingRelease);this._instancesPendingReleaseAffectedObjectClasses.clear(),this._eventSheetManager._OnInstancesReleased(this._instancesPendingRelease);for(const e of this._instancesPendingRelease)e.Release();this._instancesPendingRelease.clear(),e.SetDelayRemoveEventsEnabled(!1)}async _MaybeChangeLayout(){const e=this.GetLayoutManager();let t=0;for(;e.IsPendingChangeMainLayout()&&t++<10;)await this._DoChangeLayout(e.GetPendingChangeMainLayout())}_MeasureDt(e){let t=0;this.IsExportToVideo()?(t=1/this.GetExportVideoFramerate(),this._dtRaw=t,this._dt1=t):0!==this._lastTickTime&&(t=Math.max(e-this._lastTickTime,0)/1e3,t>.5&&(t=0),this._dtRaw=t,this._dt1=Eb.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[e,t]of this._instanceTimes)t.Add(this._dt1*e.GetTimeScale());this._canvasManager&&this._canvasManager._UpdateTick(),e-this._fpsLastTime>=1e3&&(this._fpsLastTime+=1e3,e-this._fpsLastTime>=1e3&&(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()&&Fb.Update1sPerfStats())}_SetTrackingInstanceTime(e,t){if(t){if(!this._instanceTimes.has(e)){const t=Eb.New(Eb.KahanSum);t.Copy(this._gameTime),this._instanceTimes.set(e,t)}}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().GetMainRunningLayout();await s._StopRunning(),s._Unload(e,this.GetRenderer()),s===e&&this._eventSheetManager.ClearAllScheduledWaits(),this._collisionEngine.ClearRegisteredCollisions(),this._ReleasePendingInstances(),t.dispatchEvent(this._eventObjects.beforelayoutchange),Eb.Asyncify.SetHighThroughputMode(!0),await e._Load(s,this.GetRenderer()),Eb.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 e=this._canvasManager;if(!e||e.IsRendererContextLost())return;const t=this.GetRenderer(),s=t.SupportsGPUProfiling(),i=s&&t.IsWebGL(),n=s&&t.IsWebGPU();if(i&&t.CheckForQueryResults(),!this._needRender&&!this.IsExportToVideo())return void t.IncrementFrameNumber();const r=this._layoutManager.GetMainRunningLayout();this._fpsFrameCount++,t.Start();const a=this.IsDebug();a&&Fb.StartMeasuringTime(),this._needRender=!1;let o=null;i&&(o=e.GetGPUFrameTimingsBuffer().AddTimeElapsedQuery(),t.StartQuery(o));let h=null;n&&(h=t.StartFrameTiming(2*(1+r.GetLayerCount())),t.StartMeasuringRenderPassTime(0,1)),this.Uses3DFeatures()&&"low"===e.GetCurrentFullscreenScalingQuality()?t.SetFixedSizeDepthBuffer(e.GetDrawWidth(),e.GetDrawHeight()):t.SetAutoSizeDepthBuffer(),this._Render(this.GetRenderer(),r),o&&t.EndQuery(o),n&&(t.StopMeasuringRenderPassTime(),this._canvasManager._AddWebGPUFrameTiming(h)),t.Finish(),a&&(Fb.AddDrawCallsTime(),Fb.UpdateInspectHighlight()),e&&e._MaybeTakeSnapshot()}_NeedsHTMLLayerCompositing(e){return"low"===this.GetCanvasManager().GetCurrentFullscreenScalingQuality()||e.IsWebGL()&&(this.UsesAnyBackgroundBlending()||this.Uses3DFeatures())}_Render(e,t){e.SetTextureFillMode(),e.SetAlphaBlend(),e.ResetCullState(),e.SetColorRgba(1,1,1,1),e.SetRenderTarget(null),e.SetTexture(null),e.SetDepthEnabled(this.Uses3DFeatures()),this._NeedsHTMLLayerCompositing(e)&&t._MaybeStartDrawToOwnTexture(e);const s=t.GetHTMLLayerCount();for(let i=1;ithis.DeleteTextIconSet(e);this._iconChangeHandlers.set(e,t),e.Dispatcher().addEventListener("animationframeimagechange",t)}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 e of s.GetFrames()){const s=e.GetImageInfo();t.push({source:e,width:s.GetWidth(),height:s.GetHeight(),tag:e.GetTag()})}return{icons:t}}async _GetTextIconSetContent(e){const t=Eb.New(Eb.PromiseThrottle),s=[],i=new Map;for(const n of e.GetAnimations())for(const e of n.GetFrames()){const n=e.GetImageInfo().GetImageAsset();i.has(n)||(i.set(n,null),s.push(t.Add(async()=>{const e=await n.LoadToDrawable();i.set(n,e)})))}await Promise.all(s);const n=[];for(const s of e.GetAnimations())for(const e of s.GetFrames())n.push(t.Add(async()=>{const t=e.GetImageInfo(),s=i.get(t.GetImageAsset()),n=await t.ExtractImageToCanvas(s);return{drawable:await createImageBitmap(n)}}));const r=await Promise.all(n);for(const e of i.values())e instanceof ImageBitmap&&e.close&&e.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()&&Fb.StepIfPausedInDebugger()),this._saveToJsonString){const e=await this._SaveToJsonString();this._lastSaveJson=e,await this.TriggerAsync(Eb.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(Eb.Plugins.System.Cnds.OnLoadComplete,null),this._lastSaveJson=""}catch(e){console.error("[Construct] Failed to load state from JSON string: ",e),await this.TriggerAsync(Eb.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(Eb.Plugins.System.Cnds.OnSaveComplete,null),this._lastSaveJson=""}catch(e){console.error("[Construct] Failed to save state to storage: ",e),await this.TriggerAsync(Eb.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(Eb.Plugins.System.Cnds.OnLoadComplete,null),this._lastSaveJson=""}catch(e){console.error("[Construct] Failed to load state from storage: ",e),await this.TriggerAsync(Eb.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 t of this._allObjectClasses)t.IsFamily()||t.HasNoSaveBehavior()||(e.types[t.GetSID().toString()]=t._SaveToJson());for(const t of this._layoutManager.GetAllLayouts())e.layouts[t.GetSID().toString()]=t._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(s.version>1)throw new Error("C3 save data from future version");this.ClearIntancesNeedingAfterLoad(),this._dispatcher.dispatchEvent(Eb.New(Eb.Event,"beforeload"));for(const e of this.allInstances())e.GetObjectClass().HasNoSaveBehavior()||e._OnBeforeLoad();const i=s.rt;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;const n=i.running_layout;this._isLoadingState=!0;let r=!1;if(n!==this.GetMainRunningLayout().GetSID()){const e=t.GetLayoutBySID(n);if(!e)return;await this._DoChangeLayout(e),r=!0}for(const[e,i]of Object.entries(s.layouts)){const s=parseInt(e,10),n=t.GetLayoutBySID(s);n&&n._LoadFromJson(i)}const a=new Set;for(const[e,t]of Object.entries(s.types)){const s=parseInt(e,10),i=this.GetObjectClassBySID(s);!i||i.IsFamily()||i.HasNoSaveBehavior()||i._LoadFromJson(t,a)}for(const e of this._layoutManager.GetAllLayouts())for(const t of e.allLayers())t._LoadFromJsonAfterInstances();if(this.FlushPendingInstances(),this._RefreshUidMap(),this._isLoadingState=!1,r){for(const e of this.allInstances())e.SetupInitialSceneGraphConnections();for(const[e,t]of Object.entries(s.types)){const s=parseInt(e,10),i=this.GetObjectClassBySID(s);!i||i.IsFamily()||i.HasNoSaveBehavior()||i._SetupSceneGraphConnectionsOnChangeOfLayout(t)}}this._nextUid=i.next_uid,this._eventSheetManager._LoadFromJson(s.events);for(const e of this._allObjectClasses)if(!e.IsFamily()&&e.IsInContainer())for(const t of e.GetInstances()){const s=t.GetIID();t._ClearSiblings();for(const i of e.GetContainer().objectTypes()){if(i===e)continue;const n=i.GetInstances();if(s<0||s>=n.length)throw new Error("missing sibling instance");t._AddSibling(n[s])}}this._timelineManager._LoadFromJson(s.timelines),t.SetAllLayerProjectionChanged(),t.SetAllLayerMVChanged();for(const e of a)e._OnCreatedForLoadingSavegame();this.DoAfterLoad(),this._dispatcher.dispatchEvent(Eb.New(Eb.Event,"afterload")),this.DispatchUserScriptEvent(this._CreateUserScriptEvent("afterload"));for(const[e,t]of Object.entries(s.types)){const t=parseInt(e,10),s=this.GetObjectClassBySID(t);s&&s._ClearLoadInstancesJson()}const o=this._CreateUserScriptEvent("load");o.saveData=s.user_script_data,await this.DispatchUserScriptEventAsyncWait(o),this.UpdateRender()}SortOnTmpHierarchyPosition(e,t){return t.GetWorldInfo().GetTmpHierarchyPosition()-e.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,Eb.clearArray(this._instancesNeedingAfterLoadArray),Eb.SceneGraphInfo.ClearUpdatedInstances()}DoAfterLoad(e="full",t=null){this._instancesNeedingAfterLoadArray.sort(this.SortOnTmpHierarchyPosition),t||(t={}),t.processedWorldInfo=new Set;const s=this._instancesNeedingAfterLoadArray.length;for(const s of this._instancesNeedingAfterLoadArray)s._OnAfterLoad(this._instancesNeedingAfterLoadMap.get(s),e,t);for(const s of this._instancesNeedingAfterLoadArray)s._OnAfterLoad2(this._instancesNeedingAfterLoadMap.get(s),e,t);if(this.ClearIntancesNeedingAfterLoad(),s){this.FlushPendingInstances(),this._RefreshUidMap();for(const e of this._layoutManager.GetAllLayouts())for(const t of e.allLayers())t._SortInstancesByLastCachedZIndex(),t.SetZIndicesChanged()}}async AddJobWorkerScripts(e){const t=await Promise.all(e.map(async e=>{if(this.IsCordova()&&this._assetManager.IsFileProtocol()||"playable-ad-single-file"===this.GetExportType()){const t=await this._assetManager.FetchBlob(e);return URL.createObjectURL(t)}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())return(await this.PostComponentMessageToDOMAsync("runtime","raster-svg-image",{blob:e,imageWidth:t,imageHeight:s,surfaceWidth:i,surfaceHeight:n,imageBitmapOpts:r})).imageBitmap;{const a=await self.C3_RasterSvgImageBlob(e,t,s,i,n);return r?await self.createImageBitmap(a,r):a}}async GetSvgImageSize(e){return this.IsInWorker()?await this.PostComponentMessageToDOMAsync("runtime","get-svg-image-size",{blob:e}):await 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()&&Fb.HitBreakpoint()}DebugBreak(e){return this.IsDebugging()?Fb.DebugBreak(e):Promise.resolve()}DebugBreakNext(){return!!this.IsDebugging()&&Fb.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()&&Fb.IsCPUProfiling()}IsGPUProfiling(){return this.IsDebug()&&this.GetRenderer().SupportsGPUProfiling()&&Fb.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=Eb.New(Eb.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 Eb.ObjectClass))throw new Error("invalid IObjectClass");return t}_UnwrapIInstance(e){if(!(e instanceof self.IInstance))throw new TypeError("expected IInstance");const t=this._UnwrapScriptInterface(e);if(!(t&&t instanceof Eb.Instance))throw new Error("invalid IInstance");return t}_UnwrapIWorldInstance(e){if(!(e instanceof self.IWorldInstance))throw new TypeError("expected IWorldInstance");const t=this._UnwrapScriptInterface(e);if(!(t&&t instanceof Eb.Instance))throw new Error("invalid IInstance");return t}},self.C3_CreateRuntime=Eb.Runtime.Create,self.C3_InitRuntime=(e,t)=>e.Init(t)}{const Nb=self.C3;Nb.JobSchedulerRuntime=class extends Nb.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},h=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(),h}BroadcastJob(e,t,s,i){if(s||(s=[]),"number"==typeof i&&(i=Math.floor(i))<=0)throw new Error("invalid maxWorkerNum");const n={type:e,isBroadcast:!0,maxWorkerNum:i,jobId:this._nextJobId++,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(e.maxWorkerNum||1/0)-(t.maxWorkerNum||1/0));for(const s of t)e<(s.maxWorkerNum||1/0)&&e++;return e}async _MaybeCreateExtraWorker(){if(!(this._jobWorkerCount>=this._maxNumWorkers||this._isCreatingWorker||this._hadErrorCreatingWorker||this._GetWorkerCountNeededForPendingJobs()<=this._jobWorkerCount))try{this._isCreatingWorker=!0,(await this._runtime.PostComponentMessageToDOMAsync("runtime","create-job-worker")).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.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;\nstruct ShaderParams {\nbrightness : f32\n};\n%%SHADERPARAMS_BINDING%% var shaderParams : ShaderParams;\n%%C3_UTILITY_FUNCTIONS%%\n%%FRAGMENTINPUT_STRUCT%%\n%%FRAGMENTOUTPUT_STRUCT%%\n@fragment\nfn main(input : FragmentInput) -> FragmentOutput\n{\nvar front : vec4 = c3_unpremultiply(textureSample(textureFront, samplerFront, input.fragUV));\nvar output : FragmentOutput;\noutput.color = vec4((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"]]},self.C3_Shaders.replacecolor={glsl:"varying mediump vec2 vTex;\nuniform lowp sampler2D samplerFront;\nuniform lowp vec3 sourceColor;\nuniform lowp vec3 destColor;\nuniform lowp float tolerance;\nvoid main(void)\n{\nlowp vec4 front = texture2D(samplerFront, vTex);\nlowp float a = front.a;\nif (a != 0.0)\nfront.rgb /= a;\nlowp float diff = length(front.rgb - sourceColor);\nif (diff <= tolerance)\n{\nfront.rgb = mix(front.rgb, destColor, 1.0 - diff / tolerance);\n}\nfront.rgb *= a;\ngl_FragColor = front;\n}",glslWebGL2:"",wgsl:"%%SAMPLERFRONT_BINDING%% var samplerFront : sampler;\n%%TEXTUREFRONT_BINDING%% var textureFront : texture_2d;\nstruct ShaderParams {\nsourceColor : vec3,\ndestColor : vec3,\ntolerance : f32\n};\n%%SHADERPARAMS_BINDING%% var shaderParams : ShaderParams;\n%%C3_UTILITY_FUNCTIONS%%\n%%FRAGMENTINPUT_STRUCT%%\n%%FRAGMENTOUTPUT_STRUCT%%\n@fragment\nfn main(input : FragmentInput) -> FragmentOutput\n{\nvar front : vec4 = c3_unpremultiply(textureSample(textureFront, samplerFront, input.fragUV));\nvar rgb : vec3 = front.rgb;\nvar diff : f32 = length(rgb - shaderParams.sourceColor);\nif (diff <= shaderParams.tolerance)\n{\nrgb = mix(rgb, shaderParams.destColor, 1.0 - diff / shaderParams.tolerance);\n}\nvar output : FragmentOutput;\noutput.color = vec4(rgb * 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:[["sourceColor",0,"color"],["destColor",0,"color"],["tolerance",0,"percent"]]};{let Wb=function(e,t){const s=e[1],i=t[1];if("number"==typeof s&&"number"==typeof i)return s-i;{const e=""+s,t=""+i;return et?1:0}};ForEachOrdered_SortInstances=Wb;const Vb=self.C3;let Ub=null,jb="",Hb="",zb=[],Xb="",Yb="",qb="";const Kb=Vb.New(Vb.ArrayStack);Vb.Plugins.System=class extends Vb.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 Ub&&e===jb&&t===Hb||(Ub=new RegExp(e,t),jb=e,Hb=t),Ub.lastIndex=0,Ub}GetRegexMatches(e,t,s){if(e===Xb&&t===Yb&&s===qb)return zb;const i=this.GetRegex(t,s);return zb=e.match(i),Xb=e,Yb=t,qb=s,zb}async _LoadTexturesForObjectClasses(e,t){if(!t.length)return;this._imagesLoadingTotal+=t.length;const s=[];for(const i of t)s.push(e.MaybeLoadTexturesFor(i));await Vb.PromiseAllWithProgress(s,()=>{this._imagesLoadingComplete++}),this._imagesLoadingComplete++,this._imagesLoadingComplete===this._imagesLoadingTotal&&(this._imagesLoadingComplete=0,this._imagesLoadingTotal=0,this._runtime.Trigger(Vb.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 Kb}_Repeat(e){const t=this._runtime.GetEventSheetManager(),s=t.GetEventStack(),i=s.GetCurrentStackFrame(),n=i.GetCurrentEvent(),r=n.GetSolModifiers(),a=i.IsSolModifierAfterCnds(),o=s.Push(n),h=t.GetLoopStack(),l=h.Push();if(l.SetEnd(e),a)for(let s=0;s=s&&!u.IsStopped();--e)i.PushCopySol(o),u.SetIndex(e),a.Retrigger(r,l),i.PopSol(o);else for(let e=t;e>=s&&!u.IsStopped();--e)u.SetIndex(e),a.Retrigger(r,l);else if(h)for(let e=t;e<=s&&!u.IsStopped();++e)i.PushCopySol(o),u.SetIndex(e),a.Retrigger(r,l),i.PopSol(o);else for(let e=t;e<=s&&!u.IsStopped();++e)u.SetIndex(e),a.Retrigger(r,l);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(),h=r.IsSolModifierAfterCnds(),l=n.Push(a),c=i.GetLoopStack(),u=c.Push();if(u.SetName(e),u.SetEnd(s),s=s&&!u.IsStopped();--e)i.PushCopySol(o),u.SetIndex(e),yield*a.DebugRetrigger(r,l),i.PopSol(o);else for(let e=t;e>=s&&!u.IsStopped();--e)u.SetIndex(e),yield*a.DebugRetrigger(r,l);else if(h)for(let e=t;e<=s&&!u.IsStopped();++e)i.PushCopySol(o),u.SetIndex(e),yield*a.DebugRetrigger(r,l),i.PopSol(o);else for(let e=t;e<=s&&!u.IsStopped();++e)u.SetIndex(e),yield*a.DebugRetrigger(r,l);return n.Pop(),c.Pop(),!1}_ForEach(e){const t=e.GetCurrentSol(),s=t.GetInstances();if(0===s.length)return!1;const i=this._runtime.GetEventSheetManager(),n=i.GetEventStack(),r=n.GetCurrentStackFrame(),a=r.GetCurrentEvent(),o=a.GetSolModifiers(),h=r.IsSolModifierAfterCnds(),l=n.Push(a),c=i.GetLoopStack(),u=c.Push(),d=e.IsInContainer(),_=Kb.Push();if(Vb.shallowAssignArray(_,s),u.SetEnd(_.length),h)for(let t=0,s=_.length;t!0,OnLayoutStart:()=>!0,OnLayoutEnd:()=>!0,OnSuspend:()=>!0,OnResume:()=>!0,IsSuspended(){return this._runtime.IsSuspended()},Else(){const e=this._runtime.GetCurrentEventStackFrame();return!e.GetElseBranchRan()&&!e.GetLastEventTrue()},TriggerOnce(){const e=this._runtime.GetCurrentCondition().GetSavedDataMap();let t=e.get("TriggerOnce_lastTick");void 0===t&&(t=-1,e.set("TriggerOnce_lastTick",-1));const s=this._runtime.GetTickCount();return e.set("TriggerOnce_lastTick",s),this._runtime.IsLayoutFirstTick()||t!==s-1},Every(e){const t=this._runtime.GetCurrentCondition().GetSavedDataMap(),s=t.get("Every_lastTime")||0,i=this._runtime.GetGameTime();t.has("Every_seconds")||t.set("Every_seconds",e);const n=t.get("Every_seconds");return i>=s+n?(t.set("Every_lastTime",s+n),i>=t.get("Every_lastTime")+.04&&t.set("Every_lastTime",i),t.set("Every_seconds",e),!0):(iZb.Platform.IsMobile,OnLoadFinished:()=>!0,OnCanvasSnapshot:()=>!0,EffectsSupported:()=>!0,OnSaveComplete:()=>!0,OnSaveFailed:()=>!0,OnLoadComplete:()=>!0,OnLoadFailed:()=>!0,ObjectUIDExists(e){return!!this._runtime.GetInstanceByUID(e)},IsOnPlatform(e){switch(e){case 0:return"browser"===Zb.Platform.Context;case 1:return"iOS"===Zb.Platform.OS;case 2:return"Android"===Zb.Platform.OS;case 8:return"cordova"===Zb.Platform.Context;case 9:return"scirra-arcade"===this._runtime.GetExportType();case 10:return"nwjs"===Zb.Platform.Context;case 13:return"windows-uwp"===this._runtime.GetExportType();default:return!1}},RegexTest(e,t,s){return this.GetRegex(t,s).test(e)},Compare:(e,t,s)=>Zb.compare(e,t,s),CompareBetween:(e,t,s)=>e>=t&&e<=s,CompareVar:(e,t,s)=>Zb.compare(e.GetValue(),t,s),CompareBoolVar:e=>!!e.GetValue(),CompareTime(e,t){const s=this._runtime.GetGameTime();if(0===e){const e=this._runtime.GetCurrentCondition().GetSavedDataMap();return!e.get("CompareTime_executed")&&s>=t&&(e.set("CompareTime_executed",!0),!0)}return Zb.compare(s,e,t)},IsNaN:e=>isNaN(e),AngleWithin:(e,t,s)=>Zb.angleDiff(Zb.toRadians(e),Zb.toRadians(s))<=Zb.toRadians(t),IsClockwiseFrom:(e,t)=>Zb.angleClockwise(Zb.toRadians(e),Zb.toRadians(t)),IsBetweenAngles(e,t,s){let i=Zb.toRadians(e),n=Zb.toRadians(t),r=Zb.toRadians(s);return Zb.angleClockwise(r,n)?Zb.angleClockwise(i,n)&&!Zb.angleClockwise(i,r):!(!Zb.angleClockwise(i,n)&&Zb.angleClockwise(i,r))},IsValueType:(e,t)=>"number"==typeof e?0===t:1===t,EvaluateExpression:e=>!!e,OnSignal(e){return e.toLowerCase()===this._runtime.GetEventSheetManager().GetCurrentSignalTag()},PickByComparison(e,t,s,i){if(!e)return!1;const n=this._GetForEachStack(),r=n.Push(),a=e.GetCurrentSol();Zb.shallowAssignArray(r,a.GetInstances()),a.IsSelectAll()&&Zb.clearArray(a._GetOwnElseInstances());const o=this._runtime.GetCurrentCondition();let h=0;for(let e=0,n=r.length;eo)&&(o=s,a=i)}return i.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=>!!e&&(!!e.GetInstanceCount()&&(e.GetCurrentSol()._SetSelectAll(!0),e.ApplySolToContainer(),!0)),PickOverlappingPoint(e,t,s){if(!e)return!1;const i=e.GetCurrentSol(),n=i.GetInstances(),r=this._runtime.GetCurrentEvent().IsOrBlock(),a=this._runtime.GetCurrentCondition().IsInverted();i.IsSelectAll()?(Zb.shallowAssignArray(Qb,n),i.ClearArrays(),i._SetSelectAll(!1)):r?(Zb.shallowAssignArray(Qb,i._GetOwnElseInstances()),Zb.clearArray(i._GetOwnElseInstances())):(Zb.shallowAssignArray(Qb,i._GetOwnInstances()),Zb.clearArray(i._GetOwnInstances()));for(let e=0,n=Qb.length;e=0;--n){const r=i[n];if(t){if(r.GetObjectClass().BelongsToFamily(e)){s=r;break}}else if(r.GetObjectClass()===e){s=r;break}}if(!s){const t=e.GetInstances();t.length&&(s=t.at(-1))}return!!s&&(e.GetCurrentSol().PickOne(s),e.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=>!!e&&e.IsVisible(),LayerInteractive:e=>!!e&&e.IsSelfAndParentsInteractive(),LayerIsHTML:e=>!!e&&e.IsHTMLElementsLayer(),LayerEmpty:e=>!!e&&!e.GetInstanceCount(),LayerCmpOpacity:(e,t,s)=>!!e&&Zb.compare(100*e.GetOpacity(),t,s),LayerNameExists(e){const t=this._runtime.GetMainRunningLayout();return!!t&&t.HasLayerByName(e)},OnImageLoadingComplete:()=>!0,IsLoadingImages(){return this._imagesLoadingTotal>0},TemplateExists(e,t){const s=this._runtime.GetTemplateManager();return!!s&&!!t&&!!s.GetTemplateData(e,t)}}}{let ew=function(e,t){const s=e[0]-t[0];return 0!==s?s:e[1]-t[1]},tw=function(e,t){return e[1]-t[1]};SortZOrderList=ew,SortInstancesByValue=tw;const sw=self.C3,iw=[],nw=[],rw=sw.New(sw.Rect),aw=sw.New(sw.Color),ow=[];sw.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)return;const a=this._runtime.CreateInstance(e,t,s,i,n,r);if(!a)return;n&&t.SortAndAddInstancesByZIndex(a);const o=this._runtime.GetEventSheetManager();o.BlockFlushingInstances(!0),a._TriggerOnCreatedOnSelfAndRelated(),o.BlockFlushingInstances(!1);const h=new Map;a.CollectInstancesToPick(h,e,n);for(const[e,t]of h)e.GetCurrentSol().SetSetPicked(t)},CreateObjectByName(e,t,s,i,n,r){if(!e||!t)return;const a=this._runtime.GetObjectClassByName(e);a&&sw.Plugins.System.Acts.CreateObject.call(this,a,t,s,i,n,r)},RecreateInitialObjects(e,t,s,i,n,r,a,o,h,l,c){if(!e)return;const u=this._runtime.GetCurrentLayout();let d=u;if(r){const e=this._runtime.GetLayoutManager().GetLayoutByName(r);if(!e)return;d=e}let _=null;if(("number"!=typeof a||a>=0)&&(_=d.GetLayer(a),!_))return;let p=null;if(("number"!=typeof o||o>=0)&&(p=u.GetLayer(o),!p))return;rw.set(t,s,i,n);const g=d.RecreateInitialObjects(e,rw,_,p,h,l,c);e.GetCurrentSol().SetArrayPicked(g),e.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)return;const s=e.GetCurrentSol().GetInstances();for(const e of s)e.SetTimeScale(t)},RestoreObjectTimescale(e){if(!e)return;const t=e.GetCurrentSol().GetInstances();for(const e of t)e.RestoreTimeScale()},Wait(e,t){if(e<0)return;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(sw.Plugins.System.Cnds.OnCanvasSnapshot,null))},SetCanvasSize(e,t){if(e<=0||t<=0)return;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,t){if(!e)return;const s=e.GetCurrentSol().GetInstances(),i=iw,n=nw,r=this._runtime.GetCurrentLayout(),a=e.IsFamily(),o=e.GetFamilyIndex();for(let e=0,r=s.length;e0;c&&(a.IsCopyPicked()?o.PushCopySol(l):o.PushCleanSol(l));const u=[],d=o.FindFirstFunctionBlockParent(h);if(d){const e=d.GetFunctionParameters();for(let t=s,i=e.length;te.toString(),len:e=>"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){return e[Math.floor(this._runtime.Random()*e.length)]},chooseindex:(e,...t)=>("number"!=typeof e&&(e=0),t[e=hw.clamp(Math.floor(e),0,t.length-1)]),pi:()=>Math.PI,infinity:()=>1/0,sqrt:e=>Math.sqrt(e),abs:e=>Math.abs(e),round:e=>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=>Math.floor(e),ceil:e=>Math.ceil(e),sign:e=>Math.sign(e),sin:e=>Math.sin(hw.toRadians(e)),cos:e=>Math.cos(hw.toRadians(e)),tan:e=>Math.tan(hw.toRadians(e)),asin:e=>hw.toDegrees(Math.asin(e)),acos:e=>hw.toDegrees(Math.acos(e)),atan:e=>hw.toDegrees(Math.atan(e)),exp:e=>Math.exp(e),ln:e=>Math.log(e),log10:e=>Math.log10(e),max(...e){let t=e[0];"number"!=typeof t&&(t=0);for(let s=1,i=e.length;si&&(t=i)}return t},clamp:(e,t,s)=>hw.clamp(e,t,s),distance:(e,t,s,i)=>hw.distanceTo(e,t,s,i),angle:(e,t,s,i)=>hw.toDegrees(hw.angleTo(e,t,s,i)),lerp:(e,t,s)=>hw.lerp(e,t,s),unlerp:(e,t,s)=>hw.unlerp(e,t,s),qarp:(e,t,s,i)=>hw.qarp(e,t,s,i),cubic:(e,t,s,i,n)=>hw.cubic(e,t,s,i,n),cosp:(e,t,s)=>hw.cosp(e,t,s),anglediff:(e,t)=>hw.toDegrees(hw.angleDiff(hw.toRadians(e),hw.toRadians(t))),anglelerp:(e,t,s)=>hw.toDegrees(hw.angleLerp(hw.toRadians(e),hw.toRadians(t),s)),anglerotate:(e,t,s)=>hw.toDegrees(hw.angleRotate(hw.toRadians(e),hw.toRadians(t),hw.toRadians(s))),setbit:(e,t,s)=>(e|=0)&~(1<<(t|=0))|(s=0!==s?1:0)<(e|=0)^1<(e|=0)&1<<(t|=0)?1:0,newline:()=>"\n",uppercase:e=>"string"==typeof e?e.toUpperCase():"",lowercase:e=>"string"==typeof e?e.toLowerCase():"",left:(e,t)=>"string"==typeof e?e.substr(0,t):"",mid:(e,t,s)=>"string"!=typeof e?"":s<0?e.substr(t):e.substr(t,s),right:(e,t)=>"string"==typeof e?e.substr(Math.max(e.length-t,0)):"",trim:e=>"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)=>"string"==typeof e&&"string"==typeof t&&e.length?e.split(t).length:0,find:(e,t)=>"string"==typeof e&&"string"==typeof t?e.search(new RegExp(hw.EscapeRegex(t),"i")):-1,findcase:(e,t)=>"string"==typeof e&&"string"==typeof t?e.search(new RegExp(hw.EscapeRegex(t),"")):-1,replace:(e,t,s)=>"string"==typeof e&&"string"==typeof t&&"string"==typeof s?e.replace(new RegExp(hw.EscapeRegex(t),"gi"),s):"string"==typeof e?e:"",stringsub(e,...t){let s=e;for(let e=0,i=t.length;e=n.length?"":n[i]},zeropad(e,t){let s=e<0?"-":"";e<0&&(e=-e);const i=t-e.toString().length;return s+="0".repeat(Math.max(i,0)),s+e.toString()},urlencode:e=>encodeURIComponent(e),urldecode:e=>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:()=>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 hw.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 e=t.GetViewport3D();return(e.getLeft()+e.getRight())/2}return 0},viewportmidy(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);if(t){const e=t.GetViewport3D();return(e.getTop()+e.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,h]=r.LayerToCanvasCss(s,i);return a.CanvasCssToLayer(o,h)[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,h]=r.LayerToCanvasCss(s,i);return a.CanvasCssToLayer(o,h)[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?hw.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.GetEventSheetManager(),h=o.GetCurrentEvent().GetSolModifiersIncludingParents(),l=h.length>0;l&&(n.IsCopyPicked()?o.PushCopySol(h):o.PushCleanSol(h));const c=n.GetFunctionParameters();for(let e=s.length,t=c.length;ehw.PackRGB(e,t,s),rgbex:(e,t,s)=>hw.PackRGBEx(e/100,t/100,s/100),rgba:(e,t,s,i)=>hw.PackRGBAEx(e/100,t/100,s/100,i/100),rgbex255:(e,t,s)=>hw.PackRGBEx(e/255,t/255,s/255),rgba255:(e,t,s,i)=>hw.PackRGBAEx(e/255,t/255,s/255,i/255),projectname(){return this._runtime.GetProjectName()},projectversion(){return this._runtime.GetProjectVersion()},projectid(){return this._runtime.GetAppId()},projectuniqueid(){return this._runtime.GetProjectUniqueId()},currenteventsheetname(){return this._runtime.GetCurrentEvent().GetEventSheet().GetName()},currenteventnumber(){return this._runtime.GetCurrentEvent().GetDisplayNumber()}}}{const lw=self.C3;lw.Plugins.Sprite=class extends lw.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{const cw=self.C3,uw=self.C3X,dw=[];cw.Plugins.Sprite.Type=class extends cw.SDKTypeBase{constructor(e){super(e),this._animations=e.GetAnimations()}Release(){cw.clearArray(this._animations),super.Release()}OnCreate(){for(const e of this._animations)e.LoadAllAssets(this._runtime)}LoadTextures(e){const t={sampling:this._runtime.GetSampling()};return Promise.all(this._animations.map(s=>s.LoadAllTextures(e,t)))}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){cw.Plugins.Sprite.FinishCollisionCondition(this,e)}BeforeRunAction(e){dw.push({objectClass:null,createHierarchy:!1,instances:[]})}_SpawnPickInstance(e,t,s){const i=dw.at(-1);i.objectClass=e,i.createHierarchy=s,i.instances.push(t)}AfterRunAction(e){const t=dw.pop(),s=t.objectClass,i=t.createHierarchy;if(!s)return;const n=new Map;for(const e of t.instances)e.CollectInstancesToPick(n,s,i);for(const[e,t]of n)e.GetCurrentSol().SetSetPicked(t)}_AddAnimation(e){const t=this.GetObjectClass().AddAnimation(e),s=this.GetRuntime();return t.GetFrameAt(0).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=cw.AnimationFrameInfo.CreateDynamic(this.GetRuntime());s.InsertFrameAt(n,i);const r=this.GetRuntime();n.GetImageInfo().LoadStaticTexture(r.GetRenderer(),{sampling:r.GetSampling()}).then(()=>this._UpdateAllCurrentTexture());for(const e of this._objectClass.instancesIncludingPendingCreate())e.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 e of this._objectClass.instancesIncludingPendingCreate())e.GetSdkInstance()._OnAnimationFramesChanged()}GetScriptInterfaceClass(){return self.ISpriteObjectType}};const _w=new WeakMap;self.ISpriteObjectType=class extends self.IObjectType{constructor(e){super(e),_w.set(this,e.GetSdkType())}getAnimation(e){uw.RequireString(e);const t=_w.get(this).GetObjectClass().GetAnimationByName(e);return t?t.GetIAnimation():null}getAllAnimations(){return _w.get(this).GetObjectClass().GetAllAnimations().map(e=>e.GetIAnimation())}addAnimation(e){return uw.RequireString(e),_w.get(this)._AddAnimation(e).GetIAnimation()}removeAnimation(e){uw.RequireString(e),_w.get(this)._RemoveAnimation(e)}addAnimationFrame(e,t){if(uw.RequireString(e),"number"!=typeof t&&"string"!=typeof t)throw new TypeError("invalid insert location");return _w.get(this)._AddAnimationFrame(e,t).GetIAnimationFrame()}removeAnimationFrame(e,t){if(uw.RequireString(e),"number"!=typeof t&&"string"!=typeof t)throw new TypeError("invalid insert location");_w.get(this)._RemoveAnimationFrame(e,t)}}}{const pw=self.C3,gw=self.C3X,mw=0,fw=1,Sw=2,Gw=3,yw=pw.New(pw.Rect),Iw=pw.New(pw.Quad),Tw=pw.New(pw.Vector2),Cw=1,bw=2,ww=4;pw.Plugins.Sprite.Instance=class extends pw.SDKWorldInstanceBase{constructor(e,t){super(e);let s=!0,i="",n=0,r=!0;t&&(s=!!t[mw],i=t[fw],n=t[Sw],r=t[Gw]),this._currentAnimation=this._objectClass.GetAnimationByName(i)||this._objectClass.GetAnimations()[0],this._currentFrameIndex=pw.clamp(n,0,this._currentAnimation.GetFrameCount()-1),this._currentAnimationFrame=this._currentAnimation.GetFrameAt(this._currentFrameIndex);const a=this._currentAnimationFrame.GetImageInfo();this._currentTexture=a.GetTexture(),this._currentRcTex=a.GetTexRect(),this._currentQuadTex=a.GetTexQuad(),this.HandleRendererContextLoss(),e.SetFlag(bw,!0),e.SetFlag(Cw,this._currentAnimation.GetSpeed()>=0),this._currentAnimationSpeed=Math.abs(this._currentAnimation.GetSpeed()),this._currentAnimationRepeatTo=this._currentAnimation.GetRepeatTo(),this._animationTimer=pw.New(pw.KahanSum),this._frameStartTime=0,this._animationRepeats=0,this._animTriggerName="",this._changeAnimFrameIndex=-1,this._changeAnimationName="",this._changeAnimationFrom=0;const o=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)return;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(e,t){const s=e.GetTransformedMesh();if(e.IsMeshChanged()){e.CalculateBbox(yw,Iw,!1);let t=Iw;this._runtime.IsPixelRoundingEnabled()&&(t=e.PixelRoundQuad(t)),s.CalculateTransformedMesh(e.GetSourceMesh(),t,this._currentQuadTex),e.SetMeshChanged(!1)}s.Draw(t,e.GetTotalZElevation())}GetAnimationTime(){return this._animationTimer.Get()}IsAnimationPlaying(){return this._inst.GetFlag(bw)}SetAnimationPlaying(e){this._inst.SetFlag(bw,e)}IsPlayingForwards(){return this._inst.GetFlag(Cw)}SetPlayingForwards(e){this._inst.SetFlag(Cw,e)}IsInAnimationTrigger(){return this._inst.GetFlag(ww)}SetInAnimationTrigger(e){this._inst.SetFlag(ww,e)}Tick(){this._changeAnimationName&&this._DoChangeAnimation(),this._changeAnimFrameIndex>=0&&this._DoChangeAnimFrame();const e=this._currentAnimationSpeed;if(!this.IsAnimationPlaying()||0===e)return void this._StopTicking();const t=this._runtime.GetDt(this._inst);this._animationTimer.Add(t);const s=this.GetAnimationTime(),i=this._currentAnimationFrame,n=i.GetDuration()/e;if(s=o&&(c?(this.SetPlayingForwards(!1),this._currentFrameIndex=o-2):l?this._currentFrameIndex=a:(this._animationRepeats++,this._animationRepeats>=h?this._FinishAnimation(!1):this._currentFrameIndex=a)),this._currentFrameIndex<0&&(c?(this._currentFrameIndex=1,this.SetPlayingForwards(!0),l||(this._animationRepeats++,this._animationRepeats>=h&&this._FinishAnimation(!0))):l?this._currentFrameIndex=a:(this._animationRepeats++,this._animationRepeats>=h?this._FinishAnimation(!0):this._currentFrameIndex=a)),this._currentFrameIndex=pw.clamp(this._currentFrameIndex,0,o-1);const u=r.GetFrameAt(this._currentFrameIndex);s>this._frameStartTime+u.GetDuration()/e&&(this._frameStartTime=s),this._OnFrameChanged(i,u)}_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(pw.Plugins.Sprite.Cnds.OnAnyAnimFinished),this.Trigger(pw.Plugins.Sprite.Cnds.OnAnimFinished),this.SetInAnimationTrigger(!1),this._animationRepeats=0}_OnFrameChanged(e,t,s){if(e===t)return;const i=this.GetWorldInfo(),n=e.GetImageInfo(),r=t.GetImageInfo(),a=n.GetWidth(),o=n.GetHeight(),h=r.GetWidth(),l=r.GetHeight();s&&s.onFrameChange?s.onFrameChange(i,a,o,h,l):(a!==h&&i.SetWidth(i.GetWidth()*(h/a)),o!==l&&i.SetHeight(i.GetHeight()*(l/o))),i.SetOriginX(t.GetOriginX()),i.SetOriginY(t.GetOriginY()),i.SetSourceCollisionPoly(t.GetCollisionPoly()),i.SetBboxChanged(),this._currentAnimationFrame=t,this._currentTexture=r.GetTexture(),this._currentRcTex=r.GetTexRect(),this._currentQuadTex=r.GetTexQuad();const c=this.GetInstance().GetBehaviorInstances();for(let s=0,i=c.length;s1&&this._currentAnimationSpeed>0&&this._StartTicking()}_GetAnimFrame(){return this._currentFrameIndex}_GetAnimFrameTag(){return this._currentAnimationFrame.GetTag()}_SetAnimSpeed(e){this._currentAnimationSpeed=Math.abs(e),this.SetPlayingForwards(e>=0),this._currentAnimationSpeed>0&&this._StartTicking()}_GetAnimSpeed(){return this.IsPlayingForwards()?this._currentAnimationSpeed:-this._currentAnimationSpeed}_SetAnimRepeatToFrame(e){"string"==typeof e&&-1===(e=this._currentAnimation.GetFrameIndexByTag(e))||(e=pw.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)return;if(s===this._currentAnimation&&this.IsAnimationPlaying())return;this._currentAnimation=s,this.SetPlayingForwards(s.GetSpeed()>=0),this._currentAnimationSpeed=Math.abs(s.GetSpeed()),this._currentAnimationRepeatTo=s.GetRepeatTo(),this._currentFrameIndex=pw.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=pw.clamp(Math.floor(this._changeAnimFrameIndex),0,this._currentAnimation.GetFrameCount()-1),this._changeAnimFrameIndex=-1,!e&&s===this._currentFrameIndex)return;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){const t=this._currentAnimationFrame,s=this.GetWorldInfo();let 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(Tw.copy(i.GetVec2()),s.HasMesh()){const[e,t,i]=s.GetSourceMesh().TransformPoint(Tw.getX(),Tw.getY());Tw.set(e,t),n+=i}return Tw.offset(-t.GetOriginX(),-t.GetOriginY()),Tw.scale(s.GetWidth(),s.GetHeight()),Tw.rotate(s.GetAngle()),Tw.offset(s.GetX(),s.GetY()),[Tw.getX(),Tw.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===i&&(e=0),e<0||e>=i)return[0,0];const n=s.pointsArr();return[n[2*e+0]+t.GetX(),n[2*e+1]+t.GetY()]}GetDebuggerProperties(){const e=pw.Plugins.Sprite.Acts,t="plugins.sprite.debugger.animation-properties";return[{title:t+".title",properties:[{name:t+".current-animation",value:this._currentAnimation.GetName(),onedit:t=>this.CallAction(e.SetAnim,t,0)},{name:t+".current-frame",value:this._currentFrameIndex,onedit:t=>this.CallAction(e.SetAnimFrame,t)},{name:t+".is-playing",value:this.IsAnimationPlaying(),onedit:t=>t?this.CallAction(e.StartAnim,0):this.CallAction(e.StopAnim)},{name:t+".speed",value:this._currentAnimationSpeed,onedit:t=>this.CallAction(e.SetAnimSpeed,t)},{name:t+".repeats",value:this._animationRepeats,onedit:e=>this._animationRepeats=e}]}]}SaveToJson(){const e={a:this._currentAnimation.GetSID()};0!==this._frameStartTime&&(e.fs=this._frameStartTime);const t=this.GetAnimationTime();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());const s=this.GetWorldInfo();return s.IsCollisionEnabled()&&(e.ce=s.IsCollisionEnabled()),e}LoadFromJson(e){const t=this.GetObjectClass().GetAnimationBySID(e.a);t&&(this._currentAnimation=t),this._frameStartTime=e.hasOwnProperty("fs")?e.fs:0,this._animationTimer.Set(e.hasOwnProperty("at")?e.at:0);const s=e.hasOwnProperty("f")?e.f:0;this._currentFrameIndex=pw.clamp(s,0,this._currentAnimation.GetFrameCount()-1),this._currentAnimationSpeed=e.hasOwnProperty("cas")?e.cas:0,this._animationRepeats=e.hasOwnProperty("ar")?e.ar:1;const i=e.hasOwnProperty("rt")?e.rt:0;this._currentAnimationRepeatTo=pw.clamp(i,0,this._currentAnimation.GetFrameCount()-1),this.SetAnimationPlaying(!e.hasOwnProperty("ap")||!!e.ap),this.SetPlayingForwards(!e.hasOwnProperty("af")||!!e.af);const n=this._currentAnimation.GetFrameAt(this._currentFrameIndex);this._currentAnimationFrame=n,this._UpdateCurrentTexture();const r=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 Gw:return t.IsCollisionEnabled();case Sw:return pw.clamp(this._currentFrameIndex,0,this._currentAnimation.GetFrameCount()-1);case fw:return this._currentAnimation.GetName()}}SetPropertyValueByIndex(e,t,s){const i=this.GetWorldInfo();switch(e){case Gw:i.SetCollisionEnabled(!!t);break;case Sw:{this.SetAnimationPlaying(!1);const e=this._currentAnimation.GetFrameCount()-1,i=t=pw.clamp(t,0,e),n=this._currentAnimation.GetFrameAt(this._currentFrameIndex),r=this._currentAnimation.GetFrameAt(i);this._OnFrameChanged(n,r,s),this._currentFrameIndex=pw.clamp(i,0,e);break}case fw:this._changeAnimationName=t,this._DoChangeAnimation(s),this._currentAnimation.GetFrameCount()>1&&this._currentAnimation.GetSpeed()>0?this._StartTicking():this._StopTicking()}}GetScriptInterfaceClass(){return self.ISpriteInstance}};const Pw=new WeakMap,xw=new Map([["current-frame",0],["beginning",1]]);self.ISpriteInstance=class extends self.IWorldInstance{constructor(){super(),Pw.set(this,self.IInstance._GetInitInst().GetSdkInstance())}getImagePointCount(){return Pw.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 Pw.get(this).GetImagePoint(e)}getPolyPointCount(){return Pw.get(this).GetCollisionPolyPointCount()}getPolyPointX(e){return gw.RequireFiniteNumber(e),Pw.get(this).GetCollisionPolyPoint(e)[0]}getPolyPointY(e){return gw.RequireFiniteNumber(e),Pw.get(this).GetCollisionPolyPoint(e)[1]}getPolyPoint(e){return gw.RequireFiniteNumber(e),Pw.get(this).GetCollisionPolyPoint(e)}stopAnimation(){Pw.get(this).SetAnimationPlaying(!1)}startAnimation(e="current-frame"){gw.RequireString(e);const t=xw.get(e);if(void 0===t)throw new Error("invalid mode");Pw.get(this)._StartAnim(t)}setAnimation(e,t="beginning"){gw.RequireString(e),gw.RequireString(t);const s=xw.get(t);if(void 0===s)throw new Error("invalid mode");const i=Pw.get(this);if(!i.GetObjectClass().GetAnimationByName(e))throw new Error(`animation name "${e}" does not exist`);i._SetAnim(e,s)}getAnimation(e){gw.RequireString(e);const t=Pw.get(this).GetObjectClass().GetAnimationByName(e);return t?t.GetIAnimation():null}get animation(){return Pw.get(this)._GetCurrentAnimation().GetIAnimation()}get animationName(){return Pw.get(this)._GetCurrentAnimationName()}set animationFrame(e){gw.RequireFiniteNumber(e),Pw.get(this)._SetAnimFrame(e)}get animationFrame(){return Pw.get(this)._GetAnimFrame()}set animationFrameTag(e){gw.RequireString(e),Pw.get(this)._SetAnimFrame(e)}get animationFrameTag(){return Pw.get(this)._GetAnimFrameTag()}set animationSpeed(e){gw.RequireFiniteNumber(e),Pw.get(this)._SetAnimSpeed(e)}get animationSpeed(){return Pw.get(this)._GetAnimSpeed()}set animationRepeatToFrame(e){gw.RequireFiniteNumber(e),Pw.get(this)._SetAnimRepeatToFrame(e)}get animationRepeatToFrame(){return Pw.get(this)._GetAnimRepeatToFrame()}get imageWidth(){return Pw.get(this).GetCurrentImageInfo().GetWidth()}get imageHeight(){return Pw.get(this).GetCurrentImageInfo().GetHeight()}getImageSize(){const e=Pw.get(this).GetCurrentImageInfo();return[e.GetWidth(),e.GetHeight()]}async replaceCurrentAnimationFrame(e){gw.RequireInstanceOf(e,Blob);const t=Pw.get(this),s=t.GetRuntime(),i=t.GetCurrentImageInfo(),n=pw.New(pw.ImageInfo);if(n.LoadDynamicBlobAsset(s,e),await n.LoadStaticTexture(s.GetRenderer(),{sampling:s.GetSampling()}),t.WasReleased())return void n.Release();i.ReplaceWith(n);const r=t.GetSdkType();r._UpdateAllCurrentTexture(),r.GetObjectClass().Dispatcher().dispatchEvent(new pw.Event("animationframeimagechange")),s.UpdateRender()}setSolidCollisionFilter(e,t){gw.RequireString(t),Pw.get(this).GetWorldInfo().SetSolidCollisionFilter(!!e,t)}}}{const vw=self.C3;vw.Plugins.Sprite.Cnds={IsAnimPlaying(e){return vw.equalsNoCase(this._GetCurrentAnimationName(),e)},CompareFrame(e,t){return vw.compare(this._currentFrameIndex,e,t)},CompareFrameTag(e,t){if("string"!=typeof t)return!1;const s=this._currentAnimationFrame.GetTag();return vw.compare(s.toLowerCase(),e,t.toLowerCase())},CompareAnimSpeed(e,t){return vw.compare(this._GetAnimSpeed(),e,t)},OnAnimFinished(e){return vw.equalsNoCase(this._animTriggerName,e)},OnAnyAnimFinished:()=>!0,OnFrameChanged:()=>!0,IsMirrored(){return this.GetWorldInfo().GetWidth()<0},IsFlipped(){return this.GetWorldInfo().GetHeight()<0},OnURLLoaded:()=>!0,OnURLFailed:()=>!0,IsCollisionEnabled(){return this.GetWorldInfo().IsCollisionEnabled()}}}{const Aw=self.C3;Aw.Plugins.Sprite.Acts={Spawn(e,t,s,i,n){if(!e||!t)return;const[r,a]=this.GetImagePoint(s),o=this._runtime.CreateInstance(e,t,r,a,i,n);if(!o)return;if(i&&t.SortAndAddInstancesByZIndex(o),e.GetPlugin().IsRotatable()){const e=o.GetWorldInfo();e.SetAngle(this.GetWorldInfo().GetAngle()),e.SetBboxChanged()}const h=this._runtime.GetEventSheetManager();h.BlockFlushingInstances(!0),o._TriggerOnCreatedOnSelfAndRelated(),h.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(e,t){try{0===e?this.GetSdkType()._AddAnimation(t):this.GetSdkType()._RemoveAnimation(t)}catch(t){console.error(`[Construct] Error ${0===e?"adding":"removing"} animation: `,t)}},AddRemoveAnimationFrame(e,t,s){try{0===e?this.GetSdkType()._AddAnimationFrame(t,s):this.GetSdkType()._RemoveAnimationFrame(t,s)}catch(t){console.error(`[Construct] Error ${0===e?"adding":"removing"} animation frame: `,t)}},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.GetImageInfo(),s=this.GetWorldInfo(),i=s.GetWidth()<0?-1:1,n=s.GetHeight()<0?-1:1,r=t.GetWidth()*e*i,a=t.GetHeight()*e*n;s.GetWidth()===r&&s.GetHeight()===a||(s.SetSize(r,a),s.SetBboxChanged())},async LoadURL(e,t,s){const i=this._currentAnimationFrame.GetImageInfo(),n=this.GetWorldInfo(),r=this._runtime,a=this._sdkType;if(i.GetURL()===e)return 0===t&&(n.SetSize(i.GetWidth(),i.GetHeight()),n.SetBboxChanged()),void this.Trigger(Aw.Plugins.Sprite.Cnds.OnURLLoaded);const o=Aw.New(Aw.ImageInfo);try{if(await o.LoadDynamicAsset(r,e),!o.IsLoaded())throw new Error("image failed to load");if(this.WasReleased())return void o.Release();await o.LoadStaticTexture(r.GetRenderer(),{sampling:r.GetSampling()})}catch(e){return console.error("Load image from URL failed: ",e),void(this.WasReleased()||this.Trigger(Aw.Plugins.Sprite.Cnds.OnURLFailed))}this.WasReleased()?o.Release():(i.ReplaceWith(o),a._UpdateAllCurrentTexture(),a.GetObjectClass().Dispatcher().dispatchEvent(new Aw.Event("animationframeimagechange")),r.UpdateRender(),0===t&&(n.SetSize(i.GetWidth(),i.GetHeight()),n.SetBboxChanged()),await this.TriggerAsync(Aw.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()}}}self.C3.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 Rw=self.C3;Rw.Plugins.Touch=class extends Rw.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{let Mw=function(){return Fw.GetSingleGlobalInstance().GetSdkInstance()};GetTouchSdkInstance=Mw;const Dw=self.C3,Ew=self.C3X;Dw.Plugins.Touch.Type=class extends Dw.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}GetScriptInterfaceClass(){return self.ITouchObjectType}};let Fw=null;self.ITouchObjectType=class extends self.IObjectType{constructor(e){super(e),Fw=e,e.GetRuntime()._GetCommonScriptInterfaces().touch=this}requestPermission(e){Ew.RequireString(e);const t=Mw();if("orientation"===e)return t._RequestPermission(0);if("motion"===e)return t._RequestPermission(1);throw new Error("invalid type")}}}{const Ow=self.C3,Bw="touch";Ow.Plugins.Touch.Instance=class extends Ow.SDKInstanceBase{constructor(e,t){super(e,Bw),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 Ow.CompositeDisposable(Ow.Disposable.From(s,"pointerdown",e=>this._OnPointerDown(e.data)),Ow.Disposable.From(s,"pointermove",e=>this._OnPointerMove(e.data)),Ow.Disposable.From(s,"pointerup",e=>this._OnPointerUp(e.data,!1)),Ow.Disposable.From(s,"pointercancel",e=>this._OnPointerUp(e.data,!0)),Ow.Disposable.From(s,"deviceorientation",e=>this._OnDeviceOrientation(e.data)),Ow.Disposable.From(s,"deviceorientationabsolute",e=>this._OnDeviceOrientationAbsolute(e.data)),Ow.Disposable.From(s,"devicemotion",e=>this._OnDeviceMotion(e.data)),Ow.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))return;const s=e.pageX-this._runtime.GetCanvasClientX(),i=e.pageY-this._runtime.GetCanvasClientY(),n=performance.now(),r=this._touches.size;this._triggerIndex=r,this._triggerId=t;const a=Ow.New(Ow.Plugins.Touch.TouchInfo);a.Init(n,s,i,t,r),this._touches.set(t,a),this.Trigger(Ow.Plugins.Touch.Cnds.OnNthTouchStart),this.Trigger(Ow.Plugins.Touch.Cnds.OnTouchStart),this._curTouchX=s,this._curTouchY=i,this._triggerType=0,this.Trigger(Ow.Plugins.Touch.Cnds.OnTouchObject)}_OnPointerMove(e){if("mouse"===e.pointerType&&!this._isMouseDown)return;const t=this._touches.get(e.pointerId);if(!t)return;const s=performance.now();if(s-t.GetTime()<2)return;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 t=e.pageX-this._runtime.GetCanvasClientX(),s=e.pageY-this._runtime.GetCanvasClientY();this._curTouchX=t,this._curTouchY=s,this._triggerType=1,this.Trigger(Ow.Plugins.Touch.Cnds.OnTouchObject)}if(this.Trigger(Ow.Plugins.Touch.Cnds.OnNthTouchEnd),this.Trigger(Ow.Plugins.Touch.Cnds.OnTouchEnd),!t){const e=n.ShouldTriggerTap(s);"single-tap"===e?(this.Trigger(Ow.Plugins.Touch.Cnds.OnTapGesture),this._curTouchX=n.GetX(),this._curTouchY=n.GetY(),this.Trigger(Ow.Plugins.Touch.Cnds.OnTapGestureObject)):"double-tap"===e&&(this.Trigger(Ow.Plugins.Touch.Cnds.OnDoubleTapGesture),this._curTouchX=n.GetX(),this._curTouchY=n.GetY(),this.Trigger(Ow.Plugins.Touch.Cnds.OnDoubleTapGestureObject))}n.Release(),this._touches.delete(i)}}_RequestPermission(e){return this._PostToDOMMaybeSync("request-permission",{type:e}),new Promise((t,s)=>{this._permissionPromises.push({type:e,resolve:t,reject:s})})}_OnPermissionResult(e){const t=e.result,s=e.type;this._triggerPermission=s;const i=this._permissionPromises.filter(e=>e.type===s);for(const e of i)e.resolve(t?"granted":"denied");this._permissionPromises=this._permissionPromises.filter(e=>e.type!==s),t?(this.Trigger(Ow.Plugins.Touch.Cnds.OnPermissionGranted),0===s?this._runtime.RequestDeviceOrientationEvent():this._runtime.RequestDeviceMotionEvent()):this.Trigger(Ow.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;t&&(this._accX=t.x,this._accY=t.y,this._accZ=t.z);const s=e.accelerationIncludingGravity;s&&(this._accWithGX=s.x,this._accWithGY=s.y,this._accWithGZ=s.z)}_OnTick2(){const e=performance.now();let 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(Ow.Plugins.Touch.Cnds.OnHoldGesture),this._curTouchX=s.GetX(),this._curTouchY=s.GetY(),this.Trigger(Ow.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 e>=0&&t>=0&&e({name:"$"+e.GetId(),value:e.GetX()+", "+e.GetY()}))}]}}}{const Lw=self.C3;Lw.Plugins.Touch.Cnds={OnTouchStart:()=>!0,OnTouchEnd:()=>!0,IsInTouch(){return this._touches.size>0},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().IsInverted(),s=[...this._touches.values()].filter(e=>this._IsClientPosOnCanvas(e.GetX(),e.GetY())).map(e=>[e.GetX(),e.GetY()]);return Lw.xor(this._runtime.GetCollisionEngine().TestAndSelectCanvasPointOverlap(e,s,t),t)},CompareTouchSpeed(e,t,s){const i=this._GetTouchByIndex(e);return!!i&&Lw.compare(i.GetSpeed(),t,s)},OrientationSupported:()=>!0,MotionSupported:()=>!0,CompareOrientation(e,t,s){this._runtime.RequestDeviceOrientationEvent();let i=0;return i=0===e?this._orientAlpha:1===e?this._orientBeta:this._orientGamma,Lw.compare(i,t,s)},CompareAcceleration(e,t,s){this._runtime.RequestDeviceMotionEvent();let i=0;return i=0===e?this._accWithGX:1===e?this._accWithGY:2===e?this._accWithGZ:3===e?this._accX:4===e?this._accY:this._accZ,Lw.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:()=>!0,OnTapGesture:()=>!0,OnDoubleTapGesture:()=>!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}}}self.C3.Plugins.Touch.Acts={RequestPermission(e){this._RequestPermission(e)}};{const kw=self.C3;kw.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?kw.toDegrees(t.GetAngle()):0},AngleForID(e){const t=this._touches.get(e);return t?kw.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}}}{const Nw=self.C3,Ww=15,Vw=500,Uw=333,jw=25;let Hw=-1e3,zw=-1e3,Xw=-1e4;Nw.Plugins.Touch.TouchInfo=class extends Nw.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&&Nw.distanceTo(this._startX,this._startY,this._x,this._y)>=15&&(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=Nw.distanceTo(this._x,this._y,this._lastX,this._lastY),t=(this._time-this._lastTime)/1e3;return t>0?e/t:0}GetAngle(){return Nw.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>=500&&!this._isTooFarForHold&&Nw.distanceTo(this._startX,this._startY,this._x,this._y)<15&&(this._hasTriggeredHold=!0,!0)}ShouldTriggerTap(e){return this._hasTriggeredHold?"":e-this._startTime<=333&&!this._isTooFarForHold&&Nw.distanceTo(this._startX,this._startY,this._x,this._y)<15?e-Xw<=666&&Nw.distanceTo(Hw,zw,this._x,this._y)<25?(Hw=-1e3,zw=-1e3,Xw=-1e4,"double-tap"):(Hw=this._x,zw=this._y,Xw=e,"single-tap"):""}GetPositionForLayer(e,t,s){if(void 0===t)return e.GetLayerByIndex(0).CanvasCssToLayer_DefaultTransform(this._x,this._y)[s?0:1];{const i=e.GetLayer(t);return i?i.CanvasCssToLayer(this._x,this._y)[s?0:1]:0}}}}{const Yw=self.C3;Yw.Plugins.NinePatch=class extends Yw.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{const qw=self.C3;qw.Plugins.NinePatch.Type=class extends qw.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 Kw=self.C3,$w=0,Jw=1,Zw=2,Qw=3,eP=4,tP=5,sP=6,iP=8,nP=Kw.New(Kw.Rect),rP=Kw.New(Kw.Rect),aP=Kw.New(Kw.Quad);Kw.Plugins.NinePatch.Instance=class extends Kw.SDKWorldInstanceBase{constructor(e,t){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,t&&(this._leftMargin=t[$w],this._rightMargin=t[Jw],this._topMargin=t[Zw],this._bottomMargin=t[Qw],this._edges=t[eP],this._fill=t[tP],this._isSeamless=!!t[iP],this.GetWorldInfo().SetVisible(!!t[sP])),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,n){let r=this._sdkType.GetTextureSet();if(!r&&(this._sdkType.CreatePatch(this._leftMargin,this._rightMargin,this._topMargin,this._bottomMargin),r=this._sdkType.GetTextureSet(),!r))return;const a=r.GetImageWidth(),o=r.GetImageHeight(),h=Math.min(this._leftMargin,a),l=Math.min(this._rightMargin,a),c=Math.min(this._topMargin,o),u=Math.min(this._bottomMargin,o),d=a-l,_=o-u,p=this._isSeamless?1:0,g=this._edges,m=this._fill;if(h>0&&c>0&&this._DrawPatch(e,r.GetTexture(),0,0,h+p,c+p,t,s,h+p,c+p),l>0&&c>0&&this._DrawPatch(e,r.GetTexture(),d-p,0,l+p,c+p,t+i-l-p,s,l+p,c+p),l>0&&u>0&&this._DrawPatch(e,r.GetTexture(),d-p,_-p,l+p,u+p,t+i-l-p,s+n-u-p,l+p,u+p),h>0&&u>0&&this._DrawPatch(e,r.GetTexture(),0,_-p,h+p,u+p,t,s+n-u-p,h+p,u+p),0===g){const a=2===m?0:p;h>0&&_>c&&this._TilePatch(e,r.GetLeftTexture(),t,s+c,h+a,n-c-u,0,0),l>0&&_>c&&this._TilePatch(e,r.GetRightTexture(),t+i-l-a,s+c,l+a,n-c-u,a,0),c>0&&d>h&&this._TilePatch(e,r.GetTopTexture(),t+h,s,i-h-l,c+a,0,0),u>0&&d>h&&this._TilePatch(e,r.GetBottomTexture(),t+h,s+n-u-a,i-h-l,u+a,0,a)}else 1===g&&(h>0&&_>c&&this._DrawPatch(e,r.GetTexture(),0,c,h,_-c,t,s+c,h,n-c-u),l>0&&_>c&&this._DrawPatch(e,r.GetTexture(),d,c,l,_-c,t+i-l,s+c,l,n-c-u),c>0&&d>h&&this._DrawPatch(e,r.GetTexture(),h,0,d-h,c,t+h,s,i-h-l,c),u>0&&d>h&&this._DrawPatch(e,r.GetTexture(),h,_,d-h,u,t+h,s+n-u,i-h-l,u));_>c&&d>h&&(0===m?this._TilePatch(e,r.GetFillTexture(),t+h,s+c,i-h-l,n-c-u,0,0):1===m&&this._DrawPatch(e,r.GetTexture(),h,c,d-h,_-c,t+h,s+c,i-h-l,n-c-u))}_DrawPatch(e,t,s,i,n,r,a,o,h,l){const c=t.GetWidth(),u=t.GetHeight();if(e.SetTexture(t),nP.set(a,o,a+h,o+l),rP.set(s/c,i/u,(s+n)/c,(i+r)/u),null===this._callback3d){const t=this.GetWorldInfo(),s=t.GetBoundingQuad(),i=s.getTlx(),n=s.getTly();nP.offset(-i,-n),aP.setFromRotatedRect(nP,t.GetAngle()),aP.offset(i,n),e.Quad3(aP,rP)}else this._callback3d(nP,rP)}_TilePatch(e,t,s,i,n,r,a,o){const h=t.GetWidth(),l=t.GetHeight();if(e.SetTexture(t),nP.set(s,i,s+n,i+r),rP.set(-a/h,-o/l,(n-a)/h,(r-o)/l),null===this._callback3d){const t=this.GetWorldInfo(),s=t.GetBoundingQuad(),i=s.getTlx(),n=s.getTly();nP.offset(-i,-n),aP.setFromRotatedRect(nP,t.GetAngle()),aP.offset(i,n),e.Quad3(aP,rP)}else this._callback3d(nP,rP)}GetCurrentImageInfo(){this._objectClass.GetImageInfo()}GetPropertyValueByIndex(e){}SetPropertyValueByIndex(e,t){}}}self.C3.Plugins.NinePatch.Cnds={},self.C3.Plugins.NinePatch.Acts={SetEffect(e){this.GetWorldInfo().SetBlendMode(e),this._runtime.UpdateRender()}},self.C3.Plugins.NinePatch.Exps={};{let oP=function(e){const t=hP.CreateCanvas(e.width,e.height);return t.getContext("2d").drawImage(e,0,0),t};CloneDrawable=oP;const hP=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,n){this._SliceImage(e,t,s,i,n)}HasCreatedTextures(){return!!this._texture}_SliceImage(e,t,s,i,n){if(this._wasReleased)return;const r=e.width,a=e.height;this._imageWidth=r,this._imageHeight=a,t=Math.min(Math.floor(t),r),s=Math.min(Math.floor(s),r),i=Math.min(Math.floor(i),a);const o=r-s,h=a-(n=Math.min(Math.floor(n),a)),l=this._runtime.GetSampling(),c=this._runtime.GetCanvasManager().GetTextureAnisotropy();this._texture=this._renderer.CreateStaticTexture(oP(e),{sampling:l,anisotropy:c}),o>t&&h>i&&(this._fillTexture=this._renderer.CreateStaticTexture(this._SliceSubImage(oP(e),t,i,o,h),{wrapX:"repeat",wrapY:"repeat",sampling:l,anisotropy:c})),t>0&&h>i&&(this._leftTexture=this._renderer.CreateStaticTexture(this._SliceSubImage(oP(e),0,i,t,h),{wrapY:"repeat",sampling:l,anisotropy:c})),s>0&&h>i&&(this._rightTexture=this._renderer.CreateStaticTexture(this._SliceSubImage(oP(e),o,i,r,h),{wrapY:"repeat",sampling:l,anisotropy:c})),i>0&&o>t&&(this._topTexture=this._renderer.CreateStaticTexture(this._SliceSubImage(oP(e),t,0,o,i),{wrapX:"repeat",sampling:l,anisotropy:c})),n>0&&o>t&&(this._bottomTexture=this._renderer.CreateStaticTexture(this._SliceSubImage(oP(e),t,h,o,a),{wrapX:"repeat",sampling:l,anisotropy:c}))}_SliceSubImage(e,t,s,i,n){const r=i-t,a=n-s,o=hP.CreateCanvas(r,a);return o.getContext("2d").drawImage(e,t,s,r,a,0,0,r,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 lP=self.C3;lP.Plugins.Browser=class extends lP.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{const cP=self.C3;cP.Plugins.Browser.Type=class extends cP.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const uP=self.C3,dP="browser";uP.Plugins.Browser.Instance=class extends uP.SDKInstanceBase{constructor(e,t){super(e,dP),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 uP.CompositeDisposable(uP.Disposable.From(s,"afterfirstlayoutstart",()=>this._OnAfterFirstLayoutStart()),uP.Disposable.From(s,"window-resize",()=>this._OnWindowResize()),uP.Disposable.From(s,"window-focus",()=>this._OnWindowFocus()),uP.Disposable.From(s,"window-blur",()=>this._OnWindowBlur()),uP.Disposable.From(s,"suspend",()=>this._OnSuspend()),uP.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(uP.Plugins.Browser.Cnds.OnOnline):await this.TriggerAsync(uP.Plugins.Browser.Cnds.OnOffline))}async _OnWindowResize(){await this.TriggerAsync(uP.Plugins.Browser.Cnds.OnResize)}async _OnWindowFocus(){this._windowHasFocus=!0,await this.TriggerAsync(uP.Plugins.Browser.Cnds.OnWindowFocus)}async _OnWindowBlur(){this._windowHasFocus=!1,await this.TriggerAsync(uP.Plugins.Browser.Cnds.OnWindowBlur)}_OnSuspend(){this.Trigger(uP.Plugins.Browser.Cnds.OnPageHidden)}_OnResume(){this.Trigger(uP.Plugins.Browser.Cnds.OnPageVisible)}async _OnBackButton(){await this.TriggerAsync(uP.Plugins.Browser.Cnds.OnBackButton)}_OnSWMessage(e){const t=e.type;"downloading-update"===t?this.Trigger(uP.Plugins.Browser.Cnds.OnUpdateFound):"update-ready"===t||"update-pending"===t?this.Trigger(uP.Plugins.Browser.Cnds.OnUpdateReady):"offline-ready"===t&&this.Trigger(uP.Plugins.Browser.Cnds.OnOfflineReady)}_OnHashChange(e){this._initLocationStr=e.location,this.Trigger(uP.Plugins.Browser.Cnds.OnHashChange)}_OnInstallAvailable(){this._isInstallAvailable=!0,this.Trigger(uP.Plugins.Browser.Cnds.OnInstallAvailable)}_OnAppInstalled(e){this._isInstallAvailable=!1,this.Trigger(uP.Plugins.Browser.Cnds.OnAppInstalled)}_IsWarnOnCloseEnabled(){return this._isWarnOnCloseEnabled}_SetWarnOnCloseEnabled(e){e=!!e,this._isWarnOnCloseEnabled!==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 _P=self.C3;_P.Plugins.Browser.Cnds={IsOnline(){return this._isOnline},OnOnline:()=>!0,OnOffline:()=>!0,OnResize:()=>!0,OnWindowFocus:()=>!0,OnWindowBlur:()=>!0,WindowHasFocus(){return this._windowHasFocus},CookiesEnabled(){return this._isCookieEnabled},IsFullscreen(){return this._runtime.GetCanvasManager().IsDocumentFullscreen()},OnBackButton:()=>!0,IsPortraitLandscape(e){return(this._runtime.GetCanvasManager().GetLastWidth()<=this._runtime.GetCanvasManager().GetLastHeight()?0:1)===e},OnUpdateFound:()=>!0,OnUpdateReady:()=>!0,OnOfflineReady:()=>!0,OnHashChange:()=>!0,OnInstallAvailable:()=>!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:()=>!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:()=>!0,OnPageVisible:()=>!0,HasJava:()=>!1,IsDownloadingUpdate:()=>!1,OnMenuButton:()=>!1,OnSearchButton:()=>!1,IsMetered:()=>!1,IsCharging:()=>!0,SupportsFullscreen:()=>!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){e>=2&&(e+=1),6===e&&(e=2),1===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 t=e.split(",");for(let e=0,s=t.length;e=ORIENTATIONS.length)return;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).protocol:location.protocol},Domain(){return this._runtime.IsInWorker()?new URL(this._initLocationStr).hostname:location.hostname},Port(){return this._runtime.IsInWorker()?new URL(this._initLocationStr).port:location.port},PathName(){return this._runtime.IsInWorker()?new URL(this._initLocationStr).pathname:location.pathname},Hash(){return this._runtime.IsInWorker()?new URL(this._initLocationStr).hash:location.hash},QueryString(){return this._runtime.IsInWorker()?new URL(this._initLocationStr).search:location.search},QueryParam(e){const t=this._runtime.IsInWorker()?new URL(this._initLocationStr).search:location.search,s=RegExp("[?&]"+e+"=([^&]*)").exec(t);return s?decodeURIComponent(s[1].replace(/\+/g," ")):""},Referrer(){return this._referrer},Title(){return this._docTitle},Language:()=>navigator.language,Platform:()=>navigator.platform,UserAgent:()=>navigator.userAgent,ExecJS(jsStr){let result=0;try{result=eval(jsStr)}catch(e){console.error("Error executing JavaScript: ",e)}return"number"==typeof result||"string"==typeof result?result:"boolean"==typeof result&&result?1:0},CSSStyleValue(e){return this._cssStyleMap.get(e)||""},Name:()=>navigator.appName,Version:()=>navigator.appVersion,Product:()=>navigator.product,Vendor:()=>navigator.vendor,BatteryLevel:()=>1,BatteryTimeLeft:()=>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:()=>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 pP=self.C3;pP.Plugins.Text=class extends pP.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{const gP=self.C3;gP.Plugins.Text.Type=class extends gP.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}LoadTextures(e){}ReleaseTextures(){}}}{const mP=self.C3,fP=self.C3X,SP=[0,0,0],GP=0,yP=1,IP=2,TP=3,CP=4,bP=5,wP=6,PP=7,xP=8,vP=9,AP=10,RP=11,MP=12,DP=13,EP=15,FP=["left","center","right"],OP=["top","center","bottom"],BP=["ltr","rtl"],LP=["word","cjk","character"],kP=new mP.Rect,NP=new mP.Quad,WP=new mP.Color,VP=mP.New(mP.Vector2),UP=new Map([["b","strong"],["i","em"],["s","s"],["u","u"],["iconoffsety",null]]);mP.Plugins.Text.Instance=class extends mP.SDKWorldInstanceBase{constructor(e,t){if(super(e),this._text="",this._enableBBcode=!0,this._faceName="Arial",this._ptSize=12,this._lineHeightOffset=0,this._isBold=!1,this._isItalic=!1,this._color=mP.New(mP.Color),this._horizontalAlign=0,this._verticalAlign=0,this._wrapMode="word",this._textDirection=0,this._resolutionMode="auto",this._fixedScaleFactor=1,this._iconObjectClass=null,this._htmlString="",this._isHtmlStringUpToDate=!1,this._readAloud=!1,this._screenReaderText=null,this._typewriterStartTime=-1,this._typewriterEndTime=-1,this._typewriterLength=0,this._rendererText=mP.New(mP.Gfx.RendererText,this._runtime.GetRenderer(),{timeout:5}),this._rendererText.ontextureupdate=()=>this._runtime.UpdateRender(),this._animationframeimagechange_handler=()=>this._OnIconObjectClassImageChanged(),this._pendingUpdateIconSet=!1,t){this._text=t[GP],this._enableBBcode=!!t[yP],this._faceName=t[IP],this._ptSize=t[TP],this._lineHeightOffset=t[CP],this._isBold=!!t[bP],this._isItalic=!!t[wP],this._horizontalAlign=t[xP],this._verticalAlign=t[vP],this._wrapMode=LP[t[AP]],this._textDirection=t[RP],this._SetIconObjectClass(this._runtime.GetObjectClassBySID(t[MP]));const e=t[PP];this._color.setRgb(e[0],e[1],e[2]),this.GetWorldInfo().SetVisible(t[DP]),this._readAloud=!!t[EP]}this._UpdateTextSettings(),this._UpdateScreenReaderText()}Release(){this._SetIconObjectClass(null),this._CancelTypewriter(),this._screenReaderText&&(this._screenReaderText.Release(),this._screenReaderText=null),this._rendererText.Release(),this._rendererText=null,super.Release()}_UpdateTextSettings(){const e=this._rendererText;e.SetText(this._text),e.SetBBCodeEnabled(this._enableBBcode),this._rendererText.IsBBCodeEnabled()&&this._iconObjectClass?this._rendererText.SetIconSet(this.GetRuntime().GetTextIconSet(this._iconObjectClass)):this._rendererText.SetIconSet(null),e.SetIconSmoothing("nearest"!==this._runtime.GetSampling()),e.SetFontName(this._faceName),e.SetLineHeight(this._lineHeightOffset),e.SetBold(this._isBold),e.SetItalic(this._isItalic),e.SetColor(this._color),e.SetHorizontalAlignment(FP[this._horizontalAlign]),e.SetVerticalAlignment(OP[this._verticalAlign]),e.SetWordWrapMode(this._wrapMode),e.SetTextDirection(BP[this._textDirection])}_UpdateTextSize(){const e=this.GetWorldInfo();this._rendererText.SetFontSize(this._ptSize),this._rendererText.SetFontSizeScale(e.GetSceneGraphScale());const t=e.GetLayer();let s;"auto"===this._resolutionMode?s=t.GetResolutionScaleFactorToZ(e.GetTotalZElevation()):"fixed"===this._resolutionMode&&(s=this._fixedScaleFactor),e.HasMesh()&&s!==this._rendererText.GetZoom()&&e.SetMeshChanged(!0),this._rendererText.SetSize(e.GetWidth(),e.GetHeight(),s)}_SetIconObjectClass(e){e&&(e.IsFamily()||e.GetPlugin().constructor!==mP.Plugins.Sprite)||e!==this._iconObjectClass&&(this._iconObjectClass&&this._iconObjectClass.Dispatcher().removeEventListener("animationframeimagechange",this._animationframeimagechange_handler),this._iconObjectClass=e,this._iconObjectClass&&this._iconObjectClass.Dispatcher().addEventListener("animationframeimagechange",this._animationframeimagechange_handler),this._UpdateTextSettings(),this._isHtmlStringUpToDate=!1,this._runtime.UpdateRender())}_OnIconObjectClassImageChanged(){this._runtime.DeleteTextIconSet(this._iconObjectClass),this._runtime.UpdateRender(),this._pendingUpdateIconSet=!0}_UpdateScreenReaderText(){if(this._readAloud){let e=this._text;this._enableBBcode&&(e=mP.BBString.StripAnyTags(e)),this._screenReaderText?this._screenReaderText.SetText(e):this._screenReaderText=mP.New(mP.ScreenReaderText,this._runtime,e)}else this._screenReaderText&&(this._screenReaderText.Release(),this._screenReaderText=null)}Draw(e){const t=this.GetWorldInfo();this._UpdateTextSize(),this._pendingUpdateIconSet&&(this._pendingUpdateIconSet=!1,this._rendererText.IsBBCodeEnabled()&&this._iconObjectClass&&this._rendererText.SetIconSet(this.GetRuntime().GetTextIconSet(this._iconObjectClass)));const s=this._rendererText.GetTexture();if(!s)return;const i=t.GetLayer();if(0===t.GetAngle()&&0===i.GetAngle()&&0===t.GetTotalZElevation()&&!t.HasMesh()&&i.RendersIn2DMode()){const n=t.GetBoundingQuad(),[r,a]=i.LayerToDrawSurface(n.getTlx(),n.getTly()),[o,h]=i.LayerToDrawSurface(n.getBrx(),n.getBry()),l=r-Math.round(r),c=a-Math.round(a);kP.set(r,a,o,h),kP.offset(-l,-c),NP.setFromRect(kP);const[u,d]=e.GetRenderTargetSize(e.GetRenderTarget());e.IsWebGL()?this._runtime.GetCanvasManager().SetDeviceTransform(e,u,d):(e.SetNormalizedCoordsProgramVariant(!0),NP.divide(u,d)),e.SetTexture(s),e.Quad3(NP,this._rendererText.GetTexRect()),e.IsWebGL()?i._SetTransform(e):e.SetNormalizedCoordsProgramVariant(!1)}else e.SetTexture(s),t.HasMesh()?this._DrawMesh(t,e):this._DrawStandard(t,e)}_DrawStandard(e,t){let s=e.GetBoundingQuad();this._runtime.IsPixelRoundingEnabled()&&(s=this._PixelRoundQuad(s)),t.Quad3(s,this._rendererText.GetTexRect())}_DrawMesh(e,t){const s=e.GetTransformedMesh();if(e.IsMeshChanged()){e.CalculateBbox(kP,NP,!1);let t=NP;this._runtime.IsPixelRoundingEnabled()&&(t=this._PixelRoundQuad(t)),s.CalculateTransformedMesh(e.GetSourceMesh(),t,this._rendererText.GetTexRect()),e.SetMeshChanged(!1)}s.Draw(t,e.GetTotalZElevation())}_PixelRoundQuad(e){const t=e.getTlx()-Math.round(e.getTlx()),s=e.getTly()-Math.round(e.getTly());return 0===t&&0===s?e:(NP.copy(e),NP.offset(-t,-s),NP)}GetCurrentSurfaceSize(){const e=this._rendererText.GetTexture();return e?[e.GetWidth(),e.GetHeight()]:[100,100]}GetCurrentTexRect(){return this._rendererText.GetTexRect()}IsCurrentTexRotated(){return!1}SaveToJson(){const e={t:this._text,c:this._color.toJSON(),fn:this._faceName,ps:this._ptSize};return this._enableBBcode&&(e.bbc=this._enableBBcode),0!==this._horizontalAlign&&(e.ha=this._horizontalAlign),0!==this._verticalAlign&&(e.va=this._verticalAlign),"word"!==this._wrapMode&&(e.wr=this._wrapMode),0!==this._lineHeightOffset&&(e.lho=this._lineHeightOffset),this._isBold&&(e.b=this._isBold),this._isItalic&&(e.i=this._isItalic),-1!==this._typewriterEndTime&&(e.tw={st:this._typewriterStartTime,en:this._typewriterEndTime,l:this._typewriterLength}),this._iconObjectClass&&(e.ioc=this._iconObjectClass.GetSID()),"fixed"===this._resolutionMode&&(e.fs=this._fixedScaleFactor),e}LoadFromJson(e){if(this._CancelTypewriter(),this._text=e.t,this._color.setFromJSON(e.c),this._faceName=e.fn,this._ptSize=e.ps,this._enableBBcode=!!e.hasOwnProperty("bbc")&&e.bbc,this._horizontalAlign=e.hasOwnProperty("ha")?e.ha:0,this._verticalAlign=e.hasOwnProperty("va")?e.va:0,e.hasOwnProperty("wr")){const t=e.wr;this._wrapMode="boolean"==typeof t?t?"word":"character":t}else this._wrapMode="word";if(this._lineHeightOffset=e.hasOwnProperty("lho")?e.lho:0,this._isBold=!!e.hasOwnProperty("b")&&e.b,this._isItalic=!!e.hasOwnProperty("i")&&e.i,e.hasOwnProperty("tw")){const t=e.tw;this._typewriterStartTime=t.st,this._typewriterEndTime=t.en,this._typewriterLength=t.l}if(e.hasOwnProperty("ioc")){const t=this.GetRuntime().GetObjectClassBySID(e.ioc);t&&this._SetIconObjectClass(t)}else this._SetIconObjectClass(null);e.hasOwnProperty("fs")?(this._resolutionMode="fixed",this._fixedScaleFactor=e.fs):this._resolutionMode="auto",this._UpdateTextSettings(),this._UpdateScreenReaderText(),this._isHtmlStringUpToDate=!1,-1!==this._typewriterEndTime&&this._StartTicking()}GetPropertyValueByIndex(e){switch(e){case GP:return this.GetText();case yP:return this._enableBBcode;case IP:return this._GetFontFace();case TP:return this._GetFontSize();case CP:return this._GetLineHeight();case bP:return this._IsBold();case wP:return this._IsItalic();case PP:return SP[0]=this._color.getR(),SP[1]=this._color.getG(),SP[2]=this._color.getB(),SP;case xP:return this._GetHAlign();case vP:return this._GetVAlign();case AP:return this._GetWrapMode();case EP:return this._IsReadAloud()}}SetPropertyValueByIndex(e,t){switch(e){case GP:this._SetText(t);break;case yP:if(this._enableBBcode===!!t)return;this._enableBBcode=!!t,this._UpdateTextSettings();break;case IP:this._SetFontFace(t);break;case TP:this._SetFontSize(t);break;case CP:this._SetLineHeight(t);break;case bP:this._SetBold(t);break;case wP:this._SetItalic(t);break;case PP:const e=this._color,s=t;if(e.getR()===s[0]&&e.getG()===s[1]&&e.getB()===s[2])return;this._color.setRgb(s[0],s[1],s[2]),this._UpdateTextSettings();break;case xP:this._SetHAlign(t);break;case vP:this._SetVAlign(t);break;case AP:this._SetWrapMode(t)}}SetPropertyColorOffsetValueByIndex(e,t,s,i){0===t&&0===s&&0===i||e!==PP||(this._color.addRgb(t,s,i),this._UpdateTextSettings())}_SetText(e){this._text!==e&&(this._text=e,this._rendererText.SetText(e),this._UpdateScreenReaderText(),this._isHtmlStringUpToDate=!1,this._runtime.UpdateRender())}GetText(){return this._text}_StartTypewriter(e,t){this._UpdateTextSize(),this._SetText(e),this._typewriterStartTime=this._runtime.GetWallTime(),this._typewriterEndTime=this._typewriterStartTime+t/this.GetInstance().GetActiveTimeScale(),this._typewriterLength=this._rendererText.GetLengthInGraphemes(),this._rendererText.SetDrawMaxCharacterCount(0),this._StartTicking()}_CancelTypewriter(){this._typewriterStartTime=-1,this._typewriterEndTime=-1,this._typewriterLength=0,this._rendererText.SetDrawMaxCharacterCount(-1),this._StopTicking()}_FinishTypewriter(){-1!==this._typewriterEndTime&&(this._CancelTypewriter(),this.Trigger(mP.Plugins.Text.Cnds.OnTypewriterTextFinished),this._runtime.UpdateRender())}_SetFontFace(e){this._faceName!==e&&(this._faceName=e,this._rendererText.SetFontName(e),this._runtime.UpdateRender())}_GetFontFace(){return this._faceName}_SetBold(e){e=!!e,this._isBold!==e&&(this._isBold=e,this._rendererText.SetBold(e),this._runtime.UpdateRender())}_IsBold(){return this._isBold}_SetItalic(e){e=!!e,this._isItalic!==e&&(this._isItalic=e,this._rendererText.SetItalic(e),this._runtime.UpdateRender())}_IsItalic(){return this._isItalic}_SetFontSize(e){this._ptSize!==e&&(this._ptSize=e,this._runtime.UpdateRender())}_GetFontSize(){return this._ptSize}_SetFontColor(e){this._color.equalsIgnoringAlpha(e)||(this._color.copyRgb(e),this._rendererText.SetColor(this._color),this._runtime.UpdateRender())}_GetFontColor(){return this._color}_SetLineHeight(e){this._lineHeightOffset!==e&&(this._lineHeightOffset=e,this._UpdateTextSettings(),this._runtime.UpdateRender())}_GetLineHeight(){return this._lineHeightOffset}_SetHAlign(e){this._horizontalAlign!==e&&(this._horizontalAlign=e,this._UpdateTextSettings(),this._runtime.UpdateRender())}_GetHAlign(){return this._horizontalAlign}_SetVAlign(e){this._verticalAlign!==e&&(this._verticalAlign=e,this._UpdateTextSettings(),this._runtime.UpdateRender())}_GetVAlign(){return this._verticalAlign}_SetWrapModeByIndex(e){this._SetWrapMode(LP[e])}_SetWrapMode(e){this._wrapMode!==e&&(this._wrapMode=e,this._UpdateTextSettings(),this._runtime.UpdateRender())}_GetWrapMode(){return this._wrapMode}_SetTextDirection(e){this._textDirection!==e&&(this._textDirection=e,this._UpdateTextSettings(),this._runtime.UpdateRender())}_GetTextDirection(){return this._textDirection}_SetReadAloud(e){this._readAloud=!!e,this._UpdateScreenReaderText()}_IsReadAloud(){return this._readAloud}_SetResolutionMode(e){this._resolutionMode!==e&&(this._resolutionMode=e,this._runtime.UpdateRender())}_GetResolutionMode(){return this._resolutionMode}_SetFixedScaleFactor(e){this._fixedScaleFactor!==e&&(this._fixedScaleFactor=e,"fixed"===this._resolutionMode&&this._runtime.UpdateRender())}_GetFixedScaleFactor(){return this._fixedScaleFactor}_GetTextWidth(){return this._UpdateTextSize(),this._rendererText.GetTextWidth()}_GetTextHeight(){return this._UpdateTextSize(),this._rendererText.GetTextHeight()}_GetTagAtPosition(e,t){this._UpdateTextSize();const s=this.GetWorldInfo();VP.set(e-s.GetX(),t-s.GetY()),VP.rotate(-s.GetAngle()),VP.offset(s.GetWidth()*s.GetOriginX(),s.GetHeight()*s.GetOriginY()),VP.divide(s.GetWidth(),s.GetHeight()),VP.scale(this._rendererText.GetWidth(),this._rendererText.GetHeight());const i=this._rendererText.HitTestFragment(VP.getX(),VP.getY());if(i){const e=i.GetStyleTag("tag");if(e)return e.param}return""}_HasTagAtPosition(e,t,s){const i=this._GetTagAtPosition(t,s);return i&&mP.equalsNoCase(e,i)}_GetTagPosition(e,t){this._UpdateTextSize(),t=Math.floor(t);const s=this._rendererText.FindFragmentWithTag(e,t);if(!s)return null;const i=this.GetWorldInfo(),n=this._rendererText.GetDrawScale(),r=s.GetPosX(),a=s.GetPosY()-(s.GetHeight()-s.GetFontBoundingBoxDescent())*n,o=s.GetWidth()*n/this._rendererText.GetWidth()*i.GetWidth(),h=s.GetHeight()*n/this._rendererText.GetHeight()*i.GetHeight();return VP.set(r,a),VP.divide(this._rendererText.GetWidth(),this._rendererText.GetHeight()),VP.scale(i.GetWidth(),i.GetHeight()),VP.offset(-i.GetWidth()*i.GetOriginX(),-i.GetHeight()*i.GetOriginY()),VP.rotate(i.GetAngle()),VP.offset(i.GetX(),i.GetY()),{x:VP.getX(),y:VP.getY(),width:o,height:h}}_GetTagCount(e){return this._UpdateTextSize(),this._rendererText.CountFragmentsWithTag(e)}_GetHTMLCloseTag(e){let t=UP.get(e);return null===t?"":(t||(t="span"),``)}_GetHTMLOpenTag(e,t){let s=UP.get(e);if(null===s)return"";switch(s||(s="span"),e){case"color":return`<${s} style="color: ${t}">`;case"font":return`<${s} style="font-family: '${t}'">`;case"opacity":return`<${s} style="opacity: ${t}%">`;case"size":return`<${s} style="font-size: ${t}pt">`;case"background":return`<${s} style="background-color: ${t}">`;case"hide":return`<${s} style="visibility: hidden">`;case"class":return`<${s} class="${t}">`;case"tag":return`<${s} data-tag="${t}">`;default:return`<${s}>`}}async _UpdateHTMLString(){if(this._isHtmlStringUpToDate)return this._htmlString;const e=new mP.BBString(this._text,{noEscape:!0}).toFragmentList(),t=new Map;let s='`;const n=this._iconObjectClass?this.GetRuntime().GetTextIconSet(this._iconObjectClass):null;if(this._iconObjectClass){const s=mP.New(mP.PromiseThrottle),i=[],r=new Map;for(const t of e)if(t.IsIcon()){const e=t.GetTextIcon(n);if(e){const t=e.GetSource().GetImageInfo().GetImageAsset();if(r.has(t))continue;r.set(t,null),i.push(s.Add(async()=>{const e=await t.LoadToDrawable();r.set(t,e)}))}}await Promise.all(i);const a=[];for(const i of e)if(i.IsIcon()){const e=i.GetTextIcon(n);if(e){const i=e.GetSource(),n=i.GetImageInfo().GetImageAsset();a.push(s.Add(async()=>{const s=await i.GetImageInfo().ExtractImageToBlobURL(r.get(n));t.set(e,s)}))}}await Promise.all(a);for(const e of r.values())e instanceof ImageBitmap&&e.close&&e.close()}const r=new Map;for(const i of e){const e=i.GetStyleMap();let a=[...r.keys()];a.reverse();for(const t of a)e.has(t)&&e.get(t)===r.get(t)||(r.delete(t),s+=this._GetHTMLCloseTag(t));for(const[t,i]of e)r.has(t)||(r.set(t,i),s+=this._GetHTMLOpenTag(t,i));if(i.IsText()&&(s+=mP.ReplaceAll(mP.EscapeHTML(i.GetCharacterArray().join("")),"\n","
")),i.IsIcon()&&n){const r=i.GetTextIcon(n);if(r){const n=t.get(r);if(n){const t=[];let a="0.2em";const o=e.get("iconoffsety");if(o){let e=o.trim();a=e.endsWith("%")?parseFloat(e)/100+"em":e+"px"}t.push(`top: ${a}`),"nearest"===this._runtime.GetSampling()&&t.push("image-rendering: pixelated"),s+=``}}}}const a=[...r.keys()];a.reverse();for(const e of a)s+=this._GetHTMLCloseTag(e);return s+="
",this._htmlString=s,this._isHtmlStringUpToDate=!0,this._htmlString}Tick(){const e=this._runtime.GetWallTime();if(e>=this._typewriterEndTime)this._CancelTypewriter(),this.Trigger(mP.Plugins.Text.Cnds.OnTypewriterTextFinished),this._runtime.UpdateRender();else{let t=mP.relerp(this._typewriterStartTime,this._typewriterEndTime,e,0,this._typewriterLength);t=Math.floor(t),t!==this._rendererText.GetDrawMaxCharacterCount()&&(this._rendererText.SetDrawMaxCharacterCount(t),this._runtime.UpdateRender())}}GetDebuggerProperties(){const e="plugins.text";return[{title:e+".name",properties:[{name:e+".properties.text.name",value:this.GetText(),onedit:e=>this._SetText(e)},{name:e+".properties.font.name",value:this._GetFontFace(),onedit:e=>this._SetFontFace(e)},{name:e+".properties.size.name",value:this._GetFontSize(),onedit:e=>this._SetFontSize(e)},{name:e+".properties.line-height.name",value:this._GetLineHeight(),onedit:e=>this._SetLineHeight(e)},{name:e+".properties.bold.name",value:this._IsBold(),onedit:e=>this._SetBold(e)},{name:e+".properties.italic.name",value:this._IsItalic(),onedit:e=>this._SetItalic(e)},{name:e+".debugger.text-width",value:this._GetTextWidth()},{name:e+".debugger.text-height",value:this._GetTextHeight()}]}]}GetScriptInterfaceClass(){return self.ITextInstance}};const jP=new WeakMap,HP=new Map([["left",0],["center",1],["right",2]]),zP=new Map([["top",0],["center",1],["bottom",2]]),XP=["ltr","rtl"];self.ITextInstance=class extends self.IWorldInstance{constructor(){super(),jP.set(this,self.IInstance._GetInitInst().GetSdkInstance())}get text(){return jP.get(this).GetText()}set text(e){fP.RequireString(e);const t=jP.get(this);t._CancelTypewriter(),t._SetText(e)}typewriterText(e,t){fP.RequireString(e),fP.RequireFiniteNumber(t);const s=jP.get(this);s._CancelTypewriter(),s._StartTypewriter(e,t)}typewriterFinish(){jP.get(this)._FinishTypewriter()}set fontFace(e){fP.RequireString(e),jP.get(this)._SetFontFace(e)}get fontFace(){return jP.get(this)._GetFontFace()}set isBold(e){jP.get(this)._SetBold(e)}get isBold(){return jP.get(this)._IsBold()}set isItalic(e){jP.get(this)._SetItalic(e)}get isItalic(){return jP.get(this)._IsItalic()}set sizePt(e){fP.RequireFiniteNumber(e),jP.get(this)._SetFontSize(e)}get sizePt(){return jP.get(this)._GetFontSize()}set fontColor(e){if(fP.RequireArray(e),e.length<3)throw new Error("expected 3 elements");WP.setRgb(e[0],e[1],e[2]),jP.get(this)._SetFontColor(WP)}get fontColor(){const e=jP.get(this)._GetFontColor();return[e.getR(),e.getG(),e.getB()]}set lineHeight(e){fP.RequireFiniteNumber(e),jP.get(this)._SetLineHeight(e)}get lineHeight(){return jP.get(this)._GetLineHeight()}set horizontalAlign(e){fP.RequireString(e);const t=HP.get(e);if(void 0===t)throw new Error("invalid mode");jP.get(this)._SetHAlign(t)}get horizontalAlign(){return FP[jP.get(this)._GetHAlign()]}set verticalAlign(e){fP.RequireString(e);const t=zP.get(e);if(void 0===t)throw new Error("invalid mode");jP.get(this)._SetVAlign(t)}get verticalAlign(){return OP[jP.get(this)._GetVAlign()]}set wordWrapMode(e){if(!LP.includes(e))throw new Error("invalid mode");jP.get(this)._SetWrapMode(e)}get wordWrapMode(){return jP.get(this)._GetWrapMode()}set textDirection(e){fP.RequireString(e);const t=XP.indexOf(e);if(-1===t)throw new Error("invalid text direction");jP.get(this)._SetTextDirection(t)}get textDirection(){return XP[jP.get(this)._GetTextDirection()]}set readAloud(e){jP.get(this)._SetReadAloud(!!e)}get readAloud(){return jP.get(this)._IsReadAloud()}setFixedResolutionMode(e){fP.RequireFiniteNumber(e);const t=jP.get(this);t._SetResolutionMode("fixed"),t._SetFixedScaleFactor(e)}setAutoResolutionMode(){jP.get(this)._SetResolutionMode("auto")}get textWidth(){return jP.get(this)._GetTextWidth()}get textHeight(){return jP.get(this)._GetTextHeight()}getTextSize(){const e=jP.get(this);return[e._GetTextWidth(),e._GetTextHeight()]}hasTagAtPosition(e,t,s){return fP.RequireString(e),fP.RequireFiniteNumber(t),fP.RequireFiniteNumber(s),jP.get(this)._HasTagAtPosition(e,t,s)}getTagAtPosition(e,t){return fP.RequireFiniteNumber(e),fP.RequireFiniteNumber(t),jP.get(this)._GetTagAtPosition(e,t)}getTagPositionAndSize(e,t=0){return fP.RequireString(e),fP.RequireFiniteNumber(t),jP.get(this)._GetTagPosition(e,t)}getTagCount(e){return fP.RequireString(e),jP.get(this)._GetTagCount(e)}changeIconSet(e){const t=jP.get(this),s=t.GetRuntime()._UnwrapIObjectClass(e);t._SetIconObjectClass(s)}getAsHtmlString(){return jP.get(this)._UpdateHTMLString()}}}{const YP=self.C3;YP.Plugins.Text.Cnds={CompareText(e,t){return t?this._text===e:YP.equalsNoCase(this._text,e)},IsRunningTypewriterText(){return-1!==this._typewriterEndTime},OnTypewriterTextFinished:()=>!0,HasTagAtPosition(e,t,s){return this._HasTagAtPosition(e,t,s)}}}{const qP=self.C3,KP=qP.New(qP.Color);qP.Plugins.Text.Acts={SetText(e){this._CancelTypewriter(),"number"==typeof e&&e<1e9&&(e=Math.round(1e10*e)/1e10),this._SetText(e.toString())},AppendText(e){this._CancelTypewriter(),"number"==typeof e&&e<1e9&&(e=Math.round(1e10*e)/1e10),(e=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)},SetFontFace(e,t){let s=!1,i=!1;switch(t){case 1:s=!0;break;case 2:i=!0;break;case 3:s=!0,i=!0}e===this._faceName&&s===this._isBold&&i===this._isItalic||(this._SetFontFace(e),this._SetBold(s),this._SetItalic(i))},SetFontSize(e){this._SetFontSize(e)},SetFontColor(e){KP.setFromRgbValue(e),KP.clamp(),this._SetFontColor(KP)},SetWebFont(e,t){console.warn("[Text] 'Set web font' action is deprecated and no longer has any effect")},SetEffect(e){this.GetWorldInfo().SetBlendMode(e),this._runtime.UpdateRender()},TypewriterFinish(){this._FinishTypewriter()},SetLineHeight(e){this._SetLineHeight(e)},SetHAlign(e){this._SetHAlign(e)},SetVAlign(e){this._SetVAlign(e)},SetWrapping(e){this._SetWrapModeByIndex(e)},SetTextDirection(e){this._SetTextDirection(e)},ChangeIconSet(e){this._SetIconObjectClass(e)},UpdateHTML(){return this._UpdateHTMLString()},SetReadAloud(e){this._SetReadAloud(e)},SetResolutionMode(e,t){this._SetResolutionMode(["auto","fixed"][e]),this._SetFixedScaleFactor(t)}}}{const $P=self.C3;$P.Plugins.Text.Exps={Text(){return this._text},PlainText(){return this._enableBBcode?$P.BBString.StripAnyTags(this._text):this._text},FaceName(){return this._faceName},FaceSize(){return this._ptSize},TextWidth(){return this._GetTextWidth()},TextHeight(){return this._GetTextHeight()},LineHeight(){return this._lineHeightOffset},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},AsHTML(){return this._htmlString}}}{const JP=self.C3;JP.Plugins.Mouse=class extends JP.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{let ZP=function(){return tx.GetSingleGlobalInstance().GetSdkInstance()};GetMouseSdkInstance=ZP;const QP=self.C3,ex=self.C3X;QP.Plugins.Mouse.Type=class extends QP.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}GetScriptInterfaceClass(){return self.IMouseObjectType}};let tx=null;self.IMouseObjectType=class extends self.IObjectType{constructor(e){super(e),tx=e,e.GetRuntime()._GetCommonScriptInterfaces().mouse=this}getMouseX(e){return ZP().GetMousePositionForLayer(e)[0]}getMouseY(e){return ZP().GetMousePositionForLayer(e)[1]}getMousePosition(e){return ZP().GetMousePositionForLayer(e)}isMouseButtonDown(e){return ZP().IsMouseButtonDown(e)}setCursorStyle(e){ex.RequireString(e),ZP().SetCursorStyle(e)}setCursorObjectClass(e){const t=ZP(),s=t.GetRuntime()._UnwrapIObjectClass(e);t.SetCursorObjectClass(s)}}}{const sx=self.C3,ix="mouse";let nx=null;sx.Plugins.Mouse.Instance=class extends sx.SDKInstanceBase{constructor(e,t){super(e,ix),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 s=this.GetRuntime().Dispatcher();this._disposables=new sx.CompositeDisposable(sx.Disposable.From(s,"pointermove",e=>this._OnPointerMove(e.data)),sx.Disposable.From(s,"pointerdown",e=>this._OnPointerDown(e.data)),sx.Disposable.From(s,"pointerup",e=>this._OnPointerUp(e.data)),sx.Disposable.From(s,"dblclick",e=>this._OnDoubleClick(e.data)),sx.Disposable.From(s,"wheel",e=>this._OnMouseWheel(e.data)),sx.Disposable.From(s,"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(sx.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(sx.Plugins.Mouse.Cnds.OnAnyClick),this._triggerButton=e,this._triggerType=0,this.Trigger(sx.Plugins.Mouse.Cnds.OnClick),this.Trigger(sx.Plugins.Mouse.Cnds.OnObjectClicked)}_OnMouseUp(e){this._buttonMap[e]&&(this._buttonMap[e]=!1,this._triggerButton=e,this.Trigger(sx.Plugins.Mouse.Cnds.OnRelease))}_OnDoubleClick(e){this._triggerButton=e.button,this._triggerType=1,this.Trigger(sx.Plugins.Mouse.Cnds.OnClick),this.Trigger(sx.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(sx.Plugins.Mouse.Cnds.OnWheel)}_OnWindowBlur(){for(let e=0,t=this._buttonMap.length;e=0&&this._mouseYcanvas>=0&&this._mouseXcanvas({name:"$"+e.GetName(),value:e.CanvasCssToLayer(this._mouseXcanvas,this._mouseYcanvas).join(", ")}))}]}}}{const rx=self.C3;rx.Plugins.Mouse.Cnds={OnClick(e,t){return this._triggerButton===e&&this._triggerType===t},OnAnyClick:()=>!0,IsButtonDown(e){return this._buttonMap[e]},OnRelease(e){return this._triggerButton===e},IsOverObject(e){const t=this._runtime.GetCurrentCondition().IsInverted(),s=[];return this._IsMouseOverCanvas()&&s.push([this._mouseXcanvas,this._mouseYcanvas]),rx.xor(this._runtime.GetCollisionEngine().TestAndSelectCanvasPointOverlap(e,s,t),t)},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:()=>!0,OnPointerUnlocked:()=>!0,OnPointerLockError:()=>!0,HasPointerLock(){return this._hasPointerLock},OnMovement:()=>!0}}{const ax=self.C3,ox=["auto","pointer","text","crosshair","move","help","wait","none"],hx=["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"];ax.Plugins.Mouse.Acts={SetCursor(e){this.SetCursorStyle(ox[e])},SetCursor2(e){this.SetCursorStyle(hx[e])},SetCursorSprite(e){this.SetCursorObjectClass(e)},RequestPointerLock(e){this._PostToDOMMaybeSync("request-pointer-lock",{unadjustedMovement:e})},ReleasePointerLock(){this.PostToDOM("release-pointer-lock")}}}self.C3.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 lx=self.C3;lx.Plugins.TiledBg=class extends lx.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{let cx=function(e){switch(e){case 0:return"clamp-to-edge";case 1:return"repeat";case 2:return"mirror-repeat"}return"repeat"};WrapModeToStr=cx;const ux=self.C3;ux.Plugins.TiledBg.Type=class extends ux.SDKTypeBase{constructor(e,t){super(e),this._wrapX="repeat",this._wrapY="repeat",t&&(this._wrapX=cx(t[0]),this._wrapY=cx(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 dx=self.C3,_x=self.C3X,px=0,gx=4,mx=5,fx=6,Sx=7,Gx=8,yx=9,Ix=10,Tx=11,Cx=12,bx=13,wx=14,Px=dx.New(dx.Rect),xx=dx.New(dx.Quad),vx=dx.New(dx.Rect),Ax=dx.New(dx.Quad);dx.Plugins.TiledBg.Instance=class extends dx.SDKWorldInstanceBase{constructor(e,t){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,t&&(this.GetWorldInfo().SetVisible(!!t[px]),this._imageOffsetX=t[gx],this._imageOffsetY=t[mx],this._imageScaleX=t[fx],this._imageScaleY=t[Sx],this._imageAngle=dx.toRadians(t[Gx]),this._enableTileRandomization=!!t[yx],this._tileXRandom=t[Ix],this._tileYRandom=t[Tx],this._tileAngleRandom=t[Cx],this._tileBlendMarginX=t[bx],this._tileBlendMarginY=t[wx])}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,h=this._imageAngle;vx.set(0,0,e/(n*this._imageScaleX),t/(r*this._imageScaleY)),vx.offset(-a,-o),0===h?s.setFromRect(vx):s.setFromRotatedRect(vx,-h)}SetTilingShaderProgram(e,t=!0){if(this._enableTileRandomization){const t=this.GetCurrentImageInfo();e.SetTileRandomizationMode(),e.SetTileRandomizationInfo(t.GetWidth()*this._imageScaleX,t.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)return;this.SetTilingShaderProgram(e),e.SetTexture(s);const i=t.GetWidth(),n=t.GetHeight();let r=this._imageOffsetX/i,a=this._imageOffsetY/n;0!==this._imageAngle||this._enableTileRandomization||("repeat"===this.GetSdkType().GetWrapModeX()&&(r%=1),"repeat"===this.GetSdkType().GetWrapModeY()&&(a%=1));const o=this.GetWorldInfo();vx.set(0,0,o.GetWidth()/(i*this._imageScaleX),o.GetHeight()/(n*this._imageScaleY)),vx.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,vx):(Ax.setFromRotatedRect(vx,-this._imageAngle),t.Quad4(s,Ax))}_DrawMesh(e,t){const s=e.GetTransformedMesh();if(e.IsMeshChanged()){e.CalculateBbox(Px,xx,!1);let t=xx;this._runtime.IsPixelRoundingEnabled()&&(t=e.PixelRoundQuad(t));let i=vx;0!==this._imageAngle&&(Ax.setFromRotatedRect(vx,-this._imageAngle),i=Ax),s.CalculateTransformedMesh(e.GetSourceMesh(),t,i),e.SetMeshChanged(!1)}s.Draw(t,e.GetTotalZElevation())}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){e=!!e,this._enableTileRandomization!==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:dx.toDegrees(this._GetImageAngle()),onedit:e=>this._SetImageAngle(dx.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 gx:return this._GetImageOffsetX();case mx:return this._GetImageOffsetY();case fx:return this._GetImageScaleX();case Sx:return this._GetImageScaleY();case Gx:return this._GetImageAngle();case yx:return this._IsTileRandomizationEnabled();case Ix:return this._GetTileXRandom();case Tx:return this._GetTileYRandom();case Cx:return this._GetTileAngleRandom();case bx:return this._GetTileBlendMarginX();case wx:return this._GetTileBlendMarginY()}}SetPropertyValueByIndex(e,t){switch(e){case gx:this._SetImageOffsetX(t);break;case mx:this._SetImageOffsetY(t);break;case fx:this._SetImageScaleX(t);break;case Sx:this._SetImageScaleY(t);break;case Gx:this._SetImageAngle(t);break;case yx:this._SetTileRandomizationEnabled(!!t);break;case Ix:this._SetTileXRandom(t);break;case Tx:this._SetTileYRandom(t);break;case Cx:this._SetTileAngleRandom(t);break;case bx:this._SetTileBlendMarginX(t);break;case wx:this._SetTileBlendMarginY(t)}}GetScriptInterfaceClass(){return self.ITiledBackgroundInstance}};const Rx=new WeakMap;self.ITiledBackgroundInstance=class extends self.IWorldInstance{constructor(){super(),Rx.set(this,self.IInstance._GetInitInst().GetSdkInstance())}set imageOffsetX(e){_x.RequireFiniteNumber(e),Rx.get(this)._SetImageOffsetX(e)}get imageOffsetX(){return Rx.get(this)._GetImageOffsetX()}set imageOffsetY(e){_x.RequireFiniteNumber(e),Rx.get(this)._SetImageOffsetY(e)}get imageOffsetY(){return Rx.get(this)._GetImageOffsetY()}setImageOffset(e,t){_x.RequireFiniteNumber(e),_x.RequireFiniteNumber(t);const s=Rx.get(this);s._SetImageOffsetX(e),s._SetImageOffsetY(t)}getImageOffset(){const e=Rx.get(this);return[e._GetImageOffsetX(),e._GetImageOffsetY()]}set imageScaleX(e){_x.RequireFiniteNumber(e),Rx.get(this)._SetImageScaleX(e)}get imageScaleX(){return Rx.get(this)._GetImageScaleX()}set imageScaleY(e){_x.RequireFiniteNumber(e),Rx.get(this)._SetImageScaleY(e)}get imageScaleY(){return Rx.get(this)._GetImageScaleY()}setImageScale(e,t){_x.RequireFiniteNumber(e),_x.RequireFiniteNumber(t);const s=Rx.get(this);s._SetImageScaleX(e),s._SetImageScaleY(t)}getImageScale(){const e=Rx.get(this);return[e._GetImageScaleX(),e._GetImageScaleY()]}set imageAngle(e){_x.RequireFiniteNumber(e),Rx.get(this)._SetImageAngle(e)}get imageAngle(){return Rx.get(this)._GetImageAngle()}set imageAngleDegrees(e){_x.RequireFiniteNumber(e),Rx.get(this)._SetImageAngle(dx.toRadians(e))}get imageAngleDegrees(){return dx.toDegrees(Rx.get(this)._GetImageAngle())}get imageWidth(){return Rx.get(this).GetCurrentImageInfo().GetWidth()}get imageHeight(){return Rx.get(this).GetCurrentImageInfo().GetHeight()}getImageSize(){const e=Rx.get(this).GetCurrentImageInfo();return[e.GetWidth(),e.GetHeight()]}set enableTileRandomization(e){Rx.get(this)._SetTileRandomizationEnabled(!!e)}get enableTileRandomization(){return Rx.get(this)._IsTileRandomizationEnabled()}set tileXRandom(e){_x.RequireFiniteNumber(e),Rx.get(this)._SetTileXRandom(e)}get tileXRandom(){return Rx.get(this)._GetTileXRandom()}set tileYRandom(e){_x.RequireFiniteNumber(e),Rx.get(this)._SetTileYRandom(e)}get tileYRandom(){return Rx.get(this)._GetTileYRandom()}setTileRandom(e,t){_x.RequireFiniteNumber(e),_x.RequireFiniteNumber(t);const s=Rx.get(this);s._SetTileXRandom(e),s._SetTileYRandom(t)}getTileRandom(){const e=Rx.get(this);return[e._GetTileXRandom(),e._GetTileYRandom()]}set tileAngleRandom(e){_x.RequireFiniteNumber(e),Rx.get(this)._SetTileAngleRandom(e)}get tileAngleRandom(){return Rx.get(this)._GetTileAngleRandom()}set tileBlendMarginX(e){_x.RequireFiniteNumber(e),Rx.get(this)._SetTileBlendMarginX(e)}get tileBlendMarginX(){return Rx.get(this)._GetTileBlendMarginX()}set tileBlendMarginY(e){_x.RequireFiniteNumber(e),Rx.get(this)._SetTileBlendMarginY(e)}get tileBlendMarginY(){return Rx.get(this)._GetTileBlendMarginY()}setTileBlendMargin(e,t){_x.RequireFiniteNumber(e),_x.RequireFiniteNumber(t);const s=Rx.get(this);s._SetTileBlendMarginX(e),s._SetTileBlendMarginY(t)}getTileBlendMargin(){const e=Rx.get(this);return[e._GetTileBlendMarginX(),e._GetTileBlendMarginY()]}async replaceImage(e){_x.RequireInstanceOf(e,Blob);const t=Rx.get(this),s=t.GetRuntime(),i=dx.New(dx.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())}}}self.C3.Plugins.TiledBg.Cnds={OnURLLoaded:()=>!0,OnURLFailed:()=>!0,IsTileRandomizationEnabled(){return this._IsTileRandomizationEnabled()}};{const Mx=self.C3;Mx.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(Mx.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)return;const s=this._runtime,i=Mx.New(Mx.ImageInfo);try{if(await i.LoadDynamicAsset(s,e,!0),!i.IsLoaded())throw new Error("image failed to load");if(this.WasReleased())return i.Release(),null;if(!await i.LoadStaticTexture(s.GetRenderer(),{sampling:s.GetSampling(),wrapX:this.GetSdkType().GetWrapModeX(),wrapY:this.GetSdkType().GetWrapModeY()}))return}catch(e){return console.error("Load image from URL failed: ",e),void(this.WasReleased()||this.Trigger(Mx.Plugins.TiledBg.Cnds.OnURLFailed))}this.WasReleased()?i.Release():(this._ReleaseOwnImage(),this._ownImageInfo=i,s.UpdateRender(),await this.TriggerAsync(Mx.Plugins.TiledBg.Cnds.OnURLLoaded))}}}{const Dx=self.C3;Dx.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 Dx.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 Ex=self.C3;Ex.Plugins.Keyboard=class extends Ex.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{let Fx=function(){return Bx.GetSingleGlobalInstance().GetSdkInstance()};GetKeyboardSdkInstance=Fx;const Ox=self.C3;self.C3X,Ox.Plugins.Keyboard.Type=class extends Ox.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}GetScriptInterfaceClass(){return self.IKeyboardObjectType}};let Bx=null;self.IKeyboardObjectType=class extends self.IObjectType{constructor(e){super(e),Bx=e,e.GetRuntime()._GetCommonScriptInterfaces().keyboard=this}isKeyDown(e){const t=Fx();if("string"==typeof e)return t.IsKeyDown(e);if("number"==typeof e)return t.IsKeyCodeDown(e);throw new TypeError("expected string or number")}}}{const Lx=self.C3,kx="keyboard";Lx.Plugins.Keyboard.Instance=class extends Lx.SDKInstanceBase{constructor(e,t){super(e,kx),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 Lx.CompositeDisposable(Lx.Disposable.From(s,"keydown",e=>this._OnKeyDown(e.data)),Lx.Disposable.From(s,"keyup",e=>this._OnKeyUp(e.data)),Lx.Disposable.From(s,"window-blur",()=>this._OnWindowOrKeyboardBlur()),Lx.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(Lx.Plugins.Keyboard.Cnds.OnAnyKey),this.Trigger(Lx.Plugins.Keyboard.Cnds.OnKey),this.Trigger(Lx.Plugins.Keyboard.Cnds.OnLeftRightKeyPressed),this.Trigger(Lx.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(Lx.Plugins.Keyboard.Cnds.OnAnyKeyReleased),this.Trigger(Lx.Plugins.Keyboard.Cnds.OnKeyReleased),this.Trigger(Lx.Plugins.Keyboard.Cnds.OnLeftRightKeyReleased),this.Trigger(Lx.Plugins.Keyboard.Cnds.OnKeyCodeReleased)}_OnWindowOrKeyboardBlur(){for(const e of this._keysDownByWhich)this._keysDownByWhich.delete(e),this._triggerWhich=e,this.Trigger(Lx.Plugins.Keyboard.Cnds.OnAnyKeyReleased),this.Trigger(Lx.Plugins.Keyboard.Cnds.OnKeyReleased),this.Trigger(Lx.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:Lx.Plugins.Keyboard.Exps.StringFromKeyCode(this._triggerWhich)},{name:e+".debugger.last-typed-key",value:this._triggerTypedKey}]}]}}}{const Nx=self.C3,Wx=["ShiftLeft","ShiftRight","ControlLeft","ControlRight","AltLeft","AltRight","MetaLeft","MetaRight"];Nx.Plugins.Keyboard.Cnds={IsKeyDown(e){return this._keysDownByWhich.has(e)},OnKey(e){return this._triggerWhich===e},OnAnyKey:()=>!0,OnAnyKeyReleased:()=>!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=Wx[e];return this._triggerString===t},OnLeftRightKeyReleased(e){const t=Wx[e];return this._triggerString===t},IsLeftRightKeyDown(e){const t=Wx[e];return this._keysDownByString.has(t)},IsKeyboardLockSupported(){return this._isKeyboardLockSupported},OnKeyboardLocked:()=>!0,OnKeyboardLockError:()=>!0}}{const Vx=self.C3;Vx.Plugins.Keyboard.Acts={async LockKeyboard(e){if(!this._isKeyboardLockSupported)return;let t=[];e&&(t=e.split(",")),(await this.PostToDOMAsync("lock-keyboard",{keysArr:t})).isOk?this.Trigger(Vx.Plugins.Keyboard.Cnds.OnKeyboardLocked):this.Trigger(Vx.Plugins.Keyboard.Cnds.OnKeyboardLockError)},UnlockKeyboard(){this._isKeyboardLockSupported&&this.PostToDOMAsync("unlock-keyboard")}}}{let Ux=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=Ux,self.C3.Plugins.Keyboard.Exps={LastKeyCode(){return this._triggerWhich},StringFromKeyCode:e=>Ux(e),TypedKey(){return this._triggerTypedKey}}}{const jx=self.C3;jx.Plugins.Spritefont2=class extends jx.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{const Hx=self.C3;Hx.Plugins.Spritefont2.Type=class extends Hx.SDKTypeBase{constructor(e){super(e),this._spriteFont=Hx.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 n=this.GetImageInfo(),r=this._spriteFont;r.SetWidth(n.GetWidth()),r.SetHeight(n.GetHeight()),r.SetCharacterWidth(e),r.SetCharacterHeight(t),r.SetCharacterSet(s),r.SetSpacingData(i),r.UpdateCharacterMap()}}}{const zx=self.C3,Xx=self.C3X,Yx=zx.New(zx.Vector2),qx=0,Kx=1,$x=2,Jx=3,Zx=4,Qx=5,ev=6,tv=7,sv=8,iv=9,nv=10,rv=11,av=14,ov=["left","center","right"],hv=["top","center","bottom"],lv=["word","cjk","character"];zx.Plugins.Spritefont2.Instance=class extends zx.SDKWorldInstanceBase{constructor(e,t){super(e),this._text="",this._enableBBcode=!0,this._characterWidth=16,this._characterHeight=16,this._characterSet="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,;:?!-_~#\"'&()[]|`\\/@°+=*$£€<>";let s="";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=lv[t[11]],this.GetWorldInfo().SetVisible(t[12]),this._readAloud=!!t[av]),this._sdkType.UpdateSettings(this._characterWidth,this._characterHeight,this._characterSet,s),this._spriteFontText=zx.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(ov[this._horizontalAlign]),e.SetVerticalAlign(hv[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=zx.BBString.StripAnyTags(e)),this._screenReaderText?this._screenReaderText.SetText(e):this._screenReaderText=zx.New(zx.ScreenReaderText,this._runtime,e)}else this._screenReaderText&&(this._screenReaderText.Release(),this._screenReaderText=null)}Draw(e){const t=this._objectClass.GetImageInfo(),s=t.GetTexture();if(!s)return;e.SetTexture(s);const i=this.GetWorldInfo();let n=i.GetBoundingQuad();const r=this._spriteFontText;r.SetScale(this._characterScale),r.SetSceneGraphScale(i.GetSceneGraphScale()),this._runtime.IsPixelRoundingEnabled()&&(n=i.PixelRoundQuad(n)),r.SetSize(i.GetWidth(),i.GetHeight()),r.GetSpriteFont().SetTexRect(t.GetTexRect()),r.SetColor(i.GetUnpremultipliedColor()),r.Draw(e,n.getTlx(),n.getTly(),i.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 t=e.w;this._wrapMode="boolean"==typeof t?t?"word":"character":t}else this._wrapMode="word";if(e.hasOwnProperty("tw")){const t=e.tw;this._typewriterStartTime=t.st,this._typewriterEndTime=t.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 qx:return this.GetText();case Kx:return this._enableBBcode;case $x:return this._sdkType.GetSpriteFont().GetCharacterWidth();case Jx:return this._sdkType.GetSpriteFont().GetCharacterHeight();case Zx:return this._sdkType.GetSpriteFont().GetCharacterSet();case Qx:return this._sdkType.GetSpriteFont().GetSpacingData();case ev:return this._GetScale();case tv:return this._GetCharacterSpacing();case sv:return this._GetLineHeight();case iv:return this._GetHAlign();case nv:return this._GetVAlign();case rv:return this._GetWrapMode()}}SetPropertyValueByIndex(e,t){switch(e){case qx:this._SetText(t);break;case Kx:if(this._enableBBcode===!!t)return;this._enableBBcode=!!t,this._UpdateSettings();break;case $x:this._sdkType.GetSpriteFont().SetCharacterWidth(t);break;case Jx:this._sdkType.GetSpriteFont().SetCharacterHeight(t);break;case Zx:this._sdkType.GetSpriteFont().SetCharacterSet(t);break;case Qx:this._sdkType.GetSpriteFont().SetSpacingData(t);break;case ev:this._SetScale(t);break;case tv:this._SetCharacterSpacing(t);break;case sv:this._SetLineHeight(t);break;case iv:this._SetHAlign(t);break;case nv:this._SetVAlign(t);break;case rv:this._SetWrapMode(t)}}_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=zx.CountGraphemes(zx.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(zx.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(lv[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();Yx.set(e-s.GetX(),t-s.GetY()),Yx.rotate(-s.GetAngle()),Yx.offset(s.GetWidth()*s.GetOriginX(),s.GetHeight()*s.GetOriginY());const i=this._spriteFontText.HitTestFragment(Yx.getX(),Yx.getY());if(i){const e=i.GetStyleTag("tag");if(e)return e.param}return""}_HasTagAtPosition(e,t,s){const i=this._GetTagAtPosition(t,s);return i&&zx.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 Yx.set(s.GetPosX(),s.GetPosY()),Yx.offset(-i.GetWidth()*i.GetOriginX(),-i.GetHeight()*i.GetOriginY()),Yx.rotate(i.GetAngle()),Yx.offset(i.GetX(),i.GetY()),{x:Yx.getX(),y:Yx.getY(),width:s.GetWidth(),height:s.GetHeight()}}_GetTagCount(e){return this._UpdateTextSize(),this._spriteFontText.CountFragmentsWithTag(e)}Tick(){const e=this._runtime.GetWallTime();if(e>=this._typewriterEndTime)this._CancelTypewriter(),this.Trigger(zx.Plugins.Spritefont2.Cnds.OnTypewriterTextFinished),this._runtime.UpdateRender();else{let t=zx.relerp(this._typewriterStartTime,this._typewriterEndTime,e,0,this._typewriterLength);t=Math.floor(t),t!==this._spriteFontText.GetDrawMaxCharacterCount()&&(this._spriteFontText.SetDrawMaxCharacterCount(t),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)},{name:e+".debugger.text-width",value:this._GetTextWidth()},{name:e+".debugger.text-height",value:this._GetTextHeight()}]}]}GetScriptInterfaceClass(){return self.ISpriteFontInstance}};const cv=new WeakMap,uv=new Map([["left",0],["center",1],["right",2]]),dv=new Map([["top",0],["center",1],["bottom",2]]);self.ISpriteFontInstance=class extends self.IWorldInstance{constructor(){super(),cv.set(this,self.IInstance._GetInitInst().GetSdkInstance())}get text(){return cv.get(this).GetText()}set text(e){Xx.RequireString(e);const t=cv.get(this);t._CancelTypewriter(),t._SetText(e)}typewriterText(e,t){Xx.RequireString(e),Xx.RequireFiniteNumber(t);const s=cv.get(this);s._CancelTypewriter(),s._StartTypewriter(e,t)}typewriterFinish(){cv.get(this)._FinishTypewriter()}set characterScale(e){Xx.RequireFiniteNumber(e),cv.get(this)._SetScale(e)}get characterScale(){return cv.get(this)._GetScale()}set characterSpacing(e){Xx.RequireFiniteNumber(e),cv.get(this)._SetCharacterSpacing(e)}get characterSpacing(){return cv.get(this)._GetCharacterSpacing()}set lineHeight(e){Xx.RequireFiniteNumber(e),cv.get(this)._SetLineHeight(e)}get lineHeight(){return cv.get(this)._GetLineHeight()}set horizontalAlign(e){Xx.RequireString(e);const t=uv.get(e);if(void 0===t)throw new Error("invalid mode");cv.get(this)._SetHAlign(t)}get horizontalAlign(){return ov[cv.get(this)._GetHAlign()]}set verticalAlign(e){Xx.RequireString(e);const t=dv.get(e);if(void 0===t)throw new Error("invalid mode");cv.get(this)._SetVAlign(t)}get verticalAlign(){return hv[cv.get(this)._GetVAlign()]}set wordWrapMode(e){if(!lv.includes(e))throw new Error("invalid mode");cv.get(this)._SetWrapMode(e)}get wordWrapMode(){return cv.get(this)._GetWrapMode()}set readAloud(e){cv.get(this)._SetReadAloud(!!e)}get readAloud(){return cv.get(this)._IsReadAloud()}get textWidth(){return cv.get(this)._GetTextWidth()}get textHeight(){return cv.get(this)._GetTextHeight()}getTextSize(){const e=cv.get(this);return[e._GetTextWidth(),e._GetTextHeight()]}hasTagAtPosition(e,t,s){return Xx.RequireString(e),Xx.RequireFiniteNumber(t),Xx.RequireFiniteNumber(s),cv.get(this)._HasTagAtPosition(e,t,s)}getTagAtPosition(e,t){return Xx.RequireFiniteNumber(e),Xx.RequireFiniteNumber(t),cv.get(this)._GetTagAtPosition(e,t)}getTagPositionAndSize(e,t=0){return Xx.RequireString(e),Xx.RequireFiniteNumber(t),cv.get(this)._GetTagPosition(e,t)}getTagCount(e){return Xx.RequireString(e),cv.get(this)._GetTagCount(e)}}}{const _v=self.C3;_v.Plugins.Spritefont2.Cnds={CompareText(e,t){return t?this._text===e:_v.equalsNoCase(this._text,e)},IsRunningTypewriterText(){return-1!==this._typewriterEndTime},OnTypewriterTextFinished:()=>!0,HasTagAtPosition(e,t,s){return this._HasTagAtPosition(e,t,s)}}}self.C3.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(),"number"==typeof e&&e<1e9&&(e=Math.round(1e10*e)/1e10),(e=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;const i=this._sdkType.GetSpriteFont();for(const n of e)if(" "===n)i.SetSpaceWidth(t),s=!0;else{const e=i.GetCharacter(n);e&&(e.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 pv=self.C3;pv.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?pv.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 gv=self.C3;self.SpriteFontCharacter=class{constructor(e,t,s,i){let n=e.GetCharacterWidth(),r=e.GetCharacterHeight();this._spriteFont=e,this._char=t,this._pxRect=new gv.Rect(s,i,s+n,i+r),this._texRect=new gv.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 mv=function(e,t){e=e.trim();const s=parseFloat(e);return isFinite(s)?e.endsWith("%")?t*s/100:s:0},fv=function(e){return wv||(wv=Sv.CreateCanvas(32,32).getContext("2d")),wv.fillStyle="#FFFFFF",wv.fillStyle=e,wv.fillStyle};getOffsetParam=mv,normalizeCssColorString=fv;const Sv=self.C3,Gv=new Sv.Rect,yv=new Sv.Quad,Iv=new Sv.Color,Tv=new Set(["left","center","right"]),Cv=new Set(["top","center","bottom"]),bv=new Set(["word","cjk","character"]);let wv=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=Sv.New(Sv.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=Sv.New(Sv.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,n=e.GetStyleTag("scalex"),r=(n?parseFloat(n.param):1)*i,a=e.GetStyleTag("scaley"),o=(a?parseFloat(a.param):1)*i,h=this._spriteFont.GetCharacterHeight()*o+this._lineHeight,l=this.GetSpriteFont(),c=l.GetCharacterWidth()*r,u=this.GetSpacing();if(l.HasAnyCustomWidths()){let e=0,s=0;for(const i of t){let t=c;const n=l.GetCharacter(i);n?t=n.GetDisplayWidth()*r:" "===i&&(t=l.GetSpaceWidth()*r),s+=t,++e}return{width:s+e*u,height:h}}{const e=t.length;return{width:c*e+Math.max(e,0)*u,height:h}}}_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=t.GetPosX()&&ee+t.GetHeight(),0)-t;"center"===this._verticalAlign?e=Math.max(Math.floor(this._cssHeight/2-i/2),0):"bottom"===this._verticalAlign&&(e=Math.floor(this._cssHeight-i));for(let i=0,n=s.length;i0&&e>this._cssHeight-(r-t))break;e>=0&&this._LayoutTextLine(n,e),e+=r}}_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");t+=i?mv(i.param,e.GetHeight()):0;const n=e.GetStyleTag("offsety");s+=n?mv(n.param,e.GetHeight()):0,e.SetPosX(t),e.SetPosY(s)}Draw(e,t,s,i){this._UpdateTextMeasurements(),this._drawCharCount=0;const n=Sv.cloneArray(this._wrappedText.GetLines()),r=Math.sin(i),a=Math.cos(i);for(const i of n)this._DrawLine(e,i,t,s,r,a)}_DrawLine(e,t,s,i,n,r){const a=t.GetPosX(),o=t.GetPosY();if(!Number.isFinite(a)||!Number.isFinite(o))return;const h=t.GetHeight();for(const a of t.fragments())this._DrawFragment(e,a,s,i,n,r,h)}_DrawFragment(e,t,s,i,n,r,a){let o=t.GetPosX(),h=t.GetPosY();if(!Number.isFinite(o)||!Number.isFinite(h))return;let l=t.GetCharacterArray(),c=t.GetWidth();if(-1!==this._drawMaxCharCount){if(this._drawCharCount>=this._drawMaxCharCount)return;this._drawCharCount+l.length>this._drawMaxCharCount&&(l=l.slice(0,this._drawMaxCharCount-this._drawCharCount),c=this._MeasureText(t).width),this._drawCharCount+=l.length}const u=t.GetStyleTag("background");if(Sv.IsCharArrayAllWhitespace(l)&&!u||t.HasStyleTag("hide"))return;const d=t.GetStyleTag("scale"),_=(d?parseFloat(d.param):this._scale)*this._sceneGraphScale,p=t.GetStyleTag("scalex"),g=(p?parseFloat(p.param):1)*_,m=t.GetStyleTag("scaley"),f=(m?parseFloat(m.param):1)*_,S=this._spriteFont.GetCharacterHeight()*f;h+=a-this._lineHeight-S;let G=1;const y=t.GetStyleTag("opacity");y&&(G=parseFloat(y.param)/100),u&&(e.SetColorFillMode(),Iv.parseString(fv(u.param)),Iv.setA(Iv.getA()*G*this._color.getA()),Iv.premultiply(),e.SetColor(Iv),Gv.set(o,h,o+c,h+S),Gv.getRight()>this._cssWidth&&Gv.setRight(this._cssWidth),yv.setFromRotatedRectPrecalc(Gv,n,r),yv.offset(s,i),e.Quad(yv),e.SetTextureFillMode());const I=t.GetStyleTag("color");I?(Iv.parseString(fv(I.param)),Iv.setA(this._color.getA())):Iv.copy(this._color),Iv.setA(Iv.getA()*G),Iv.premultiply(),e.SetColor(Iv);const T=this._spriteFont.GetCharacterWidth()*g,C=Math.abs(this.GetSpacing());for(const t of l){const a=this._spriteFont.GetCharacter(t);if(a){const t=a.GetDisplayWidth()*g;if(o+t>this._cssWidth+C+1e-5)return;Gv.set(o,h,o+T,h+S),yv.setFromRotatedRectPrecalc(Gv,n,r),yv.offset(s,i),e.Quad3(yv,a.GetTexRect()),o+=t+this._spacing}else o+=this._spriteFont.GetSpaceWidth()*g+this._spacing}}GetSpriteFont(){return this._spriteFont}SetBBCodeEnabled(e){e=!!e,this._isBBcodeEnabled!==e&&(this._isBBcodeEnabled=e,this._SetWordWrapChanged())}IsBBCodeEnabled(){return this._isBBcodeEnabled}SetText(e){this._text!==e&&(this._text=e,this._SetWordWrapChanged())}SetWordWrapMode(e){if(!bv.has(e))throw new Error("invalid word wrap mode");this._wrapMode!==e&&(this._wrapMode=e,this._SetWordWrapChanged())}SetHorizontalAlign(e){if(!Tv.has(e))throw new Error("invalid alignment");this._horizontalAlign!==e&&(this._horizontalAlign=e,this._SetTextLayoutChanged())}SetVerticalAlign(e){if(!Cv.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=Sv.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 Pv=self.C3,xv=self.SpriteFontText,vv={width:256,height:256,characterWidth:16,characterHeight:16,characterSet:""};self.SpriteFont=class{constructor(e){if((e=Object.assign({},vv,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 Pv.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)return;this._ReleaseCharacters();let e=Pv.SplitGraphemes(this._characterSet),t=Math.floor(this._width/this._characterWidth),s=t*Math.floor(this._height/this._characterHeight);for(let i=0,n=e.length;i=s);++i){let s=e[i];if(this._characterMap.has(s))continue;let n=i%t,r=Math.floor(i/t);this._characterMap.set(s,Pv.New(self.SpriteFontCharacter,this,s,n*this._characterWidth,r*this._characterHeight))}if(this._hasAnyCustomWidths=!1,this._spaceWidth=-1,Array.isArray(this._spacingParsed))for(let e of this._spacingParsed){if(!Array.isArray(e))continue;if(2!==e.length)continue;let t=e[0],s=e[1];if("number"==typeof t&&isFinite(t)&&"string"==typeof s&&t!==this._characterWidth)for(let e of s){let s=this._characterMap.get(e);s?(s.SetDisplayWidth(t),this._hasAnyCustomWidths=!0):" "===e&&(this._spaceWidth=t,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 e of this._characterMap.values())e._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){e<0&&(e=-1),this._spaceWidth!==e&&(this._spaceWidth=e,this._spaceWidth>=0&&(this._hasAnyCustomWidths=!0))}GetSpaceWidth(){return this._spaceWidth<0?this._characterWidth:this._spaceWidth}}}{const Av=self.C3;Av.Plugins.Dictionary=class extends Av.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{const Rv=self.C3;Rv.Plugins.Dictionary.Type=class extends Rv.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const Mv=self.C3,Dv=(self.C3X,self.IInstance);Mv.Plugins.Dictionary.Instance=class extends Mv.SDKInstanceBase{constructor(e,t){super(e),this._data=new Map,this._curKey=""}Release(){this._data.clear(),super.Release()}GetAsJsonString(){return JSON.stringify({c2dictionary:!0,data:Mv.MapToObject(this._data)})}GetDataMap(){return this._data}SaveToJson(){return Mv.MapToObject(this._data)}LoadFromJson(e){Mv.ObjectToMap(e,this._data)}GetDebuggerProperties(){const e="plugins.dictionary";return[{title:e+".name",properties:[{name:e+".debugger.key-count",value:this._data.size},...[...this._data].map(e=>({name:"$"+e[0],value:e[1],onedit:t=>this._data.set(e[0],t)}))]}]}GetScriptInterfaceClass(){return self.IDictionaryInstance}};const Ev=new WeakMap;self.IDictionaryInstance=class extends Dv{constructor(){super(),Ev.set(this,Dv._GetInitInst().GetSdkInstance())}getDataMap(){return Ev.get(this).GetDataMap()}}}{const Fv=self.C3;Fv.Plugins.Dictionary.Cnds={CompareValue(e,t,s){const i=this._data.get(e);return void 0!==i&&Fv.compare(i,t,s)},ForEachKey(){const e=this._runtime,t=e.GetEventSheetManager(),s=e.GetCurrentEvent(),i=s.GetSolModifiers(),n=e.GetEventStack(),r=n.GetCurrentStackFrame(),a=n.Push(s);e.SetDebuggingEnabled(!1);for(const e of this._data.keys())this._curKey=e,t.PushCopySol(i),this.GetObjectClass().GetCurrentSol().PickOne(this.GetInstance()),s.Retrigger(r,a),t.PopSol(i);return e.SetDebuggingEnabled(!0),this._curKey="",n.Pop(),!1},CompareCurrentValue(e,t){const s=this._data.get(this._curKey);return void 0!==s&&Fv.compare(s,e,t)},HasKey(e){return this._data.has(e)},IsEmpty(){return 0===this._data.size}}}{const Ov=self.C3;Ov.Plugins.Dictionary.Acts={AddKey(e,t){this._data.set(e,t)},SetKey(e,t){this._data.has(e)&&this._data.set(e,t)},DeleteKey(e){this._data.delete(e)},Clear(){this._data.clear()},JSONLoad(e){let t=null;try{t=JSON.parse(e)}catch(e){return void console.error("[Construct] Error parsing JSON: ",e)}t.c2dictionary?Ov.ObjectToMap(t.data,this._data):console.warn("[Dictionary] Attempted to load JSON that does not appear to be Construct dictionary data - no data loaded")},JSONDownload(e){const t=URL.createObjectURL(new Blob([this.GetAsJsonString()],{type:"application/json"}));this._runtime.InvokeDownload(t,e)}}}self.C3.Plugins.Dictionary.Exps={Get(e){const t=this._data.get(e);return void 0===t?0:t},GetDefault(e,t){const s=this._data.get(e);return void 0===s?t:s},KeyCount(){return this._data.size},CurrentKey(){return this._curKey},CurrentValue(){return this._data.get(this._curKey)??0},AsJSON(){return this.GetAsJsonString()}};{const Bv=self.C3;Bv.Plugins.LocalStorage=class extends Bv.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{const Lv=self.C3;Lv.Plugins.LocalStorage.Type=class extends Lv.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const kv=self.C3,Nv="localstorage";kv.Plugins.LocalStorage.Instance=class extends kv.SDKInstanceBase{constructor(e,t){super(e,Nv),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"),kv.Wait(3e3)]);e&&(this._isPersistent=e.isPersistent)}Release(){super.Release()}async _TriggerStorageError(e){this._errorMessage=this._GetErrorString(e),await this.TriggerAsync(kv.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(e=>({name:"$"+e[0],value:e[1],onedit:t=>this._storage.setItem(e[0],t)}))}]}async _DebugCacheStorage(){this._isLoadingDebugCache=!0;try{const e=await this._storage.keys();e.sort((e,t)=>{const s=e.toLowerCase(),i=t.toLowerCase();return sthis._storage.getItem(e)));this._debugCache.clear();for(let s=0,i=e.length;s!0,OnItemGet(e){return this._currentKey===e},OnAnyItemGet:()=>!0,OnItemRemoved(e){return this._currentKey===e},OnAnyItemRemoved:()=>!0,OnCleared:()=>!0,OnAllKeyNamesLoaded:()=>!0,OnError:()=>!0,OnItemExists(e){return this._currentKey===e},OnItemMissing(e){return this._currentKey===e},CompareKey(e,t){return Wv.compare(this._currentKey,e,t)},CompareValue(e,t){return Wv.compare(this._lastValue,e,t)},IsProcessingSets(){return this._pendingSets>0},IsProcessingGets(){return this._pendingGets>0},OnAllSetsComplete:()=>!0,OnAllGetsComplete:()=>!0,IsPersistent(){return this._isPersistent}}}{let Vv=function(e){return"string"==typeof e||"number"==typeof e};IsExpressionType=Vv;const Uv=self.C3;Uv.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(Uv.Plugins.LocalStorage.Cnds.OnAnyItemSet),await this.TriggerAsync(Uv.Plugins.LocalStorage.Cnds.OnItemSet)})}catch(e){await this._TriggerStorageError(e)}finally{this._pendingSets--,0===this._pendingSets&&await this.TriggerAsync(Uv.Plugins.LocalStorage.Cnds.OnAllSetsComplete)}},async SetBinaryItem(e,t){if(!t)return;const s=t.GetFirstPicked(this._inst);if(!s)return;const i=s.GetSdkInstance();if(!i)return;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(Uv.Plugins.LocalStorage.Cnds.OnAnyItemSet),await this.TriggerAsync(Uv.Plugins.LocalStorage.Cnds.OnItemSet)})}catch(e){await this._TriggerStorageError(e)}finally{this._pendingSets--,0===this._pendingSets&&await this.TriggerAsync(Uv.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=Vv(t)?t:"",await this.TriggerAsync(Uv.Plugins.LocalStorage.Cnds.OnAnyItemGet),await this.TriggerAsync(Uv.Plugins.LocalStorage.Cnds.OnItemGet)})}catch(e){await this._TriggerStorageError(e)}finally{this._pendingGets--,0===this._pendingGets&&await this.TriggerAsync(Uv.Plugins.LocalStorage.Cnds.OnAllGetsComplete)}},async GetBinaryItem(e,t){if(!t)return;const s=t.GetFirstPicked(this._inst);if(!s)return;const i=s.GetSdkInstance();this._pendingGets++;try{let t=await this._storage.getItem(e);t=t instanceof ArrayBuffer?t:new ArrayBuffer(0),await this.ScheduleTriggers(async()=>{this._lastValue="",this._currentKey=e,i.SetArrayBufferTransfer(t),await this.TriggerAsync(Uv.Plugins.LocalStorage.Cnds.OnAnyItemGet),await this.TriggerAsync(Uv.Plugins.LocalStorage.Cnds.OnItemGet)})}catch(e){await this._TriggerStorageError(e)}finally{this._pendingGets--,0===this._pendingGets&&await this.TriggerAsync(Uv.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(Uv.Plugins.LocalStorage.Cnds.OnItemMissing)):(this._lastValue=Vv(t)?t:"",await this.TriggerAsync(Uv.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(Uv.Plugins.LocalStorage.Cnds.OnAnyItemRemoved),await this.TriggerAsync(Uv.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="",Uv.clearArray(this._keyNamesList),await this.TriggerAsync(Uv.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(Uv.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(e){if(!this._isInMemoryOnly)return;let t;try{t=JSON.parse(e)}catch(e){return void console.error("[Local Storage] Failed to parse memory storage JSON: ",e)}t&&t["is-c3-storage"]&&Array.isArray(t.items)||console.error("[Local Storage] Failed to load memory storage JSON: invalid data"),this._storage.SetMemoryStorage(new Map(t.items))}}}self.C3.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 jv=self.C3,Hv=[];jv.Plugins.Audio=class extends jv.SDKPluginBase{constructor(e){super(e)}_AddActionPromise(e){Hv.push(e)}static async WaitForAllActionPromises(){await Promise.all(Hv),jv.clearArray(Hv)}Release(){super.Release()}}}{let zv=function(){return Kv.GetSingleGlobalInstance().GetSdkInstance()},Xv=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=zv,GetAudioDOMInterface=Xv;const Yv=self.C3,qv=self.C3X;Yv.Plugins.Audio.Type=class extends Yv.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}GetScriptInterfaceClass(){return self.IAudioObjectType}};let Kv=null;self.IAudioObjectType=class extends self.IObjectType{constructor(e){super(e),Kv=e}get audioContext(){return Xv().GetAudioContextExtern()}get destinationNode(){return Xv().GetDestinationNodeExtern()}get isSilent(){return zv()._IsSilent()}set isSilent(e){zv()._SetSilent(e)}get masterVolume(){return zv()._GetMasterVolume()}set masterVolume(e){qv.RequireFiniteNumber(e),zv()._SetMasterVolume(e)}stopAll(){zv()._StopAll()}}}{const $v=self.C3,Jv="audio",Zv=["interactive","balanced","playback"];$v.Plugins.Audio.Instance=class extends $v.SDKInstanceBase{constructor(e,t){super(e,Jv),this._nextPlayTime=0,this._nextPlayOffset=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=Zv[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();this._disposables=new $v.CompositeDisposable($v.Disposable.From(i,"instancedestroy",e=>this._OnInstanceDestroyed(e.instance)),$v.Disposable.From(i,"afterload",()=>this._OnAfterLoad()),$v.Disposable.From(i,"suspend",()=>this._OnSuspend()),$v.Disposable.From(i,"resume",()=>this._OnResume()));const n=this._runtime.GetExportType(),r="Safari"===$v.Platform.Browser,a=this._runtime.IsiOSWebView()||"macos-wkwebview"===n,o=this._runtime.GetAssetManager().IsFileProtocol(),h="playable-ad-single-file"===n,l="cordova"===n&&"Android"===$v.Platform.OS,c=r||a||o||h||l;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(e,t){for(const s of t){let t=!1;for(const i of e)if($v.equalsNoCase(i,s)){t=!0;break}if(!t)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))}_GetScheduledPlayInfo(){let e=0;const t=!!self.C3_GetAudioContextCurrentTime;return e=t?this._nextPlayTime:this._nextPlayOffset,this._nextPlayTime=0,this._nextPlayOffset=0,{playOffset:e,isTrueClock:t}}_OnSuspend(){this._playInBackground||this.PostToDOM("set-suspended",{isSuspended:!0})}_OnResume(){this._playInBackground||this.PostToDOM("set-suspended",{isSuspended:!1})}_OnUpdateState(e){const t=e.tickCount;this._outputLatency=e.outputLatency;const s=this._lastAIState.filter(e=>e.hasOwnProperty("placeholder")&&(e.placeholder>t||-1===e.placeholder));this._lastAIState=e.audioInstances,this._lastAnalysersData=e.analysers,s.length>0&&$v.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 e of this._lastAIState)if(this._MatchTagLists(e.tags,t))return e;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 e of this._lastAIState)this._MatchTagLists(e.tags,t)&&(e.isPlaying=!1)}async _OnTrigger(e){const t=e.type;this._triggerTags=e.tags;const s=e.aiid;if("ended"===t){for(const e of this._lastAIState)if(e.aiid===s){e.isPlaying=!1;break}await this.TriggerAsync($v.Plugins.Audio.Cnds.OnEnded)}else"fade-ended"===t&&await this.TriggerAsync($v.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)return[e,t];const r=Math.sin(s),a=Math.cos(s),o=(e-=i)*r;return e=e*a-(t-=n)*r,t=t*a+o,[e+=i,t+=n]}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&&$v.equalsNoCase(s.tag,e))return s;return null}_IncrementEffectCount(e){for(const t of this._SplitTags(e)){const e=t.toLowerCase();this._effectCount.set(e,(this._effectCount.get(e)||0)+1)}}_IsSilent(){return this._isSilent}_SetSilent(e){e=!!e,this._isSilent!==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 e of this._lastAIState)e.hasOwnProperty("tag")&&!e.hasOwnProperty("tags")&&(e.tags=[e.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 e of this._lastAIState){const t=this._runtime.GetAssetManager().GetProjectAudioFileUrl(e.bufferOriginalUrl);t?(e.bufferUrl=t.url,e.bufferType=t.type):e.bufferUrl=null}for(const e of Object.values(this._lastFxState))for(const t of e)if(t.hasOwnProperty("bufferOriginalUrl")){const e=this._runtime.GetAssetManager().GetProjectAudioFileUrl(t.bufferOriginalUrl);e&&(t.bufferUrl=e.url,t.bufferType=e.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[t,s]of Object.entries(this._lastFxState))e.push({name:"$"+t,value:s.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}`}))]}]}}}self.C3.Plugins.Audio.Cnds={OnEnded(e){return this._MatchTriggerTag(e)},OnFadeEnded(e){return this._MatchTriggerTag(e)},PreloadsComplete(){return this._preloadCount===this._preloadTotal},AdvancedAudioSupported:()=>!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 Qv=self.C3,eA=["lowpass","highpass","bandpass","lowshelf","highshelf","peaking","notch","allpass"];Qv.Plugins.Audio.Acts={Play(e,t,s,i,n){const r=Qv.Plugins.Audio.Acts._DoPlay.call(this,e,t,s,i,n);return this._AddActionPromise(r),r},PlayFromTimeline(e,t,s,i){Qv.Plugins.Audio.Acts._DoPlay.call(this,e,0,t,0,s,i)},async _DoPlay(e,t,s,i,n,r){if(this._isSilent)return;const a=e[1],o=this._runtime.GetAssetManager().GetProjectAudioFileUrl(e[0]);if(!o)return;const{playOffset:h,isTrueClock:l}=this._GetScheduledPlayInfo(),c=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:Qv.clamp(i/100,-1,1),pos:r||0,off:h,trueClock:l})}finally{c&&(c.placeholder=this._runtime.GetTickCountNoSave())}},async PlayAtPosition(e,t,s,i,n,r,a,o,h,l,c){if(this._isSilent)return;const u=e[1],d=this._runtime.GetAssetManager().GetProjectAudioFileUrl(e[0]);if(!d)return;const{playOffset:_,isTrueClock:p}=this._GetScheduledPlayInfo(),g=this._MaybeMarkAsPlaying(e[0],c,u,0!==t,this.DbToLinear(s));try{await this.PostToDOMAsync("play",{originalUrl:e[0],url:d.url,type:d.type,isMusic:u,tags:this._SplitTags(c),isLooping:0!==t,vol:this.DbToLinear(s),pos:0,off:_,trueClock:p,panning:{x:i,y:n,z:r,angle:Qv.toRadians(a),innerAngle:Qv.toRadians(o),outerAngle:Qv.toRadians(h),outerGain:this.DbToLinear(l)}})}finally{g&&(g.placeholder=this._runtime.GetTickCountNoSave())}},async PlayAtObject(e,t,s,i,n,r,a,o){if(this._isSilent)return;if(!i)return;const h=i.GetFirstPicked();if(!h||!h.GetWorldInfo())return;const l=h.GetWorldInfo(),c=l.GetLayer().GetAngle(),[u,d]=this.rotatePtAround(l.GetX(),l.GetY(),-c,this._listenerPos[0],this._listenerPos[1]),_=e[1],p=this._runtime.GetAssetManager().GetProjectAudioFileUrl(e[0]);if(!p)return;const{playOffset:g,isTrueClock:m}=this._GetScheduledPlayInfo(),f=this._MaybeMarkAsPlaying(e[0],o,_,0!==t,this.DbToLinear(s));try{await this.PostToDOMAsync("play",{originalUrl:e[0],url:p.url,type:p.type,isMusic:_,tags:this._SplitTags(o),isLooping:0!==t,vol:this.DbToLinear(s),pos:0,off:g,trueClock:m,panning:{x:u,y:d,z:l.GetTotalZElevation(),angle:l.GetAngle()-c,innerAngle:Qv.toRadians(n),outerAngle:Qv.toRadians(r),outerGain:this.DbToLinear(a),uid:h.GetUID()}})}finally{f&&(f.placeholder=this._runtime.GetTickCountNoSave())}},async PlayByName(e,t,s,i,n,r){if(this._isSilent)return;const a=1===e,o=this._runtime.GetAssetManager().GetProjectAudioFileUrl(t)||this._remoteUrls.get(t.toLowerCase());if(!o)return;const{playOffset:h,isTrueClock:l}=this._GetScheduledPlayInfo(),c=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:Qv.clamp(n/100,-1,1),pos:0,off:h,trueClock:l})}finally{c&&(c.placeholder=this._runtime.GetTickCountNoSave())}},async PlayAtPositionByName(e,t,s,i,n,r,a,o,h,l,c,u){if(this._isSilent)return;const d=1===e,_=this._runtime.GetAssetManager().GetProjectAudioFileUrl(t)||this._remoteUrls.get(t.toLowerCase());if(!_)return;const{playOffset:p,isTrueClock:g}=this._GetScheduledPlayInfo(),m=this._MaybeMarkAsPlaying(t,u,d,0!==s,this.DbToLinear(i));try{await this.PostToDOMAsync("play",{originalUrl:t,url:_.url,type:_.type,isMusic:d,tags:this._SplitTags(u),isLooping:0!==s,vol:this.DbToLinear(i),pos:0,off:p,trueClock:g,panning:{x:n,y:r,z:a,angle:Qv.toRadians(o),innerAngle:Qv.toRadians(h),outerAngle:Qv.toRadians(l),outerGain:this.DbToLinear(c)}})}finally{m&&(m.placeholder=this._runtime.GetTickCountNoSave())}},async PlayAtObjectByName(e,t,s,i,n,r,a,o,h){if(this._isSilent)return;if(this._isSilent)return;if(!n)return;const l=n.GetFirstPicked();if(!l||!l.GetWorldInfo())return;const c=l.GetWorldInfo(),u=c.GetLayer().GetAngle(),[d,_]=this.rotatePtAround(c.GetX(),c.GetY(),-u,this._listenerPos[0],this._listenerPos[1]),p=1===e,g=this._runtime.GetAssetManager().GetProjectAudioFileUrl(t)||this._remoteUrls.get(t.toLowerCase());if(!g)return;const{playOffset:m,isTrueClock:f}=this._GetScheduledPlayInfo(),S=this._MaybeMarkAsPlaying(t,h,p,0!==s,this.DbToLinear(i));try{await this.PostToDOMAsync("play",{originalUrl:t,url:g.url,type:g.type,isMusic:p,tags:this._SplitTags(h),isLooping:0!==s,vol:this.DbToLinear(i),pos:0,off:m,trueClock:f,panning:{x:d,y:_,z:c.GetTotalZElevation(),angle:c.GetAngle()-u,innerAngle:Qv.toRadians(r),outerAngle:Qv.toRadians(a),outerGain:this.DbToLinear(o),uid:l.GetUID()}})}finally{S&&(S.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:Qv.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=eA[t];this._IncrementEffectCount(e),this.PostToDOM("add-effect",{type:"filter",tags:this._SplitTags(e),params:[o,s,i,n,r,Qv.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),Qv.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,Qv.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,Qv.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,Qv.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:[Qv.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,Qv.clamp(s/100,0,1)]})},AddRingModEffect(e,t,s){this._IncrementEffectCount(e),this.PostToDOM("add-effect",{type:"ringmod",tags:this._SplitTags(e),params:[t,Qv.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),Qv.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 e of t)this._effectCount.set(e.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)return;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),this._nextPlayOffset=Math.max(e-performance.now()/1e3,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 tA=self.C3;tA.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]:0},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:()=>self.C3_GetAudioContextCurrentTime?self.C3_GetAudioContextCurrentTime():performance.now()/1e3,OutputLatency(){return this._outputLatency},NormalizedVolume(e,t){return 0==(e=tA.clamp(+e,0,100)/100)?-1/0:e<.1?this.LinearToDb(tA.lerp(0,this.DbToLinear(t),10*e)):tA.lerp(t,0,(e-.1)/.9)}}}{const sA=self.C3;sA.Plugins.Json=class extends sA.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{const iA=self.C3;iA.Plugins.Json.Type=class extends iA.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const nA=self.C3,rA=self.C3X,aA=self.IInstance;nA.Plugins.Json.Instance=class extends nA.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(e,t){const s=this._valueCache[0];if(null===e||null===s)return!1;if(s===e||nA.arraysEqual(s,e))return!0;if(t&&s.length>0){for(let t=0,i=Math.min(e.length,s.length);t=s.length||!isFinite(e)){s=null;break}s=s[e]}else{if("object"!=typeof s||null===s){s=null;break}if(s.hasOwnProperty(i))s=s[i];else{if(!t){s=null;break}{const e={};s[i]=e,s=e}}}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 e=parseInt(s,10);return e>=0&&e=0&&e=n.length||(n[e]=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){return"number"==typeof e?isFinite(e)?e:0:"object"==typeof e?JSON.stringify(e):e+""}GetDebuggerProperties(){const e="plugins.json.debugger";let 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}};const oA=new WeakMap;self.IJSONInstance=class extends aA{constructor(){super(),oA.set(this,aA._GetInitInst().GetSdkInstance())}getJsonDataCopy(){const e=oA.get(this)._GetData();return JSON.parse(JSON.stringify(e))}setJsonDataCopy(e){try{const t=JSON.parse(JSON.stringify(e));oA.get(this)._SetData(t)}catch(e){throw console.error("[JSON plugin] setJsonData: object is not valid JSON: ",e),e}}setJsonString(e){rA.RequireString(e);try{const t=JSON.parse(e);oA.get(this)._SetData(t)}catch(e){throw console.error("[JSON plugin] setJsonString: string is not valid JSON: ",e),e}}toCompactString(){return JSON.stringify(oA.get(this)._GetData())}toBeautifiedString(){return JSON.stringify(oA.get(this)._GetData(),null,4)}}}{const hA=self.C3,lA=["null","boolean","number","string","object","array"];hA.Plugins.Json.Cnds={HasKey(e){return this._HasKey(e)},CompareType(e,t){return this._GetTypeOf(e)===lA[t]},CompareValue(e,t,s){return hA.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)return!1;const s=this._runtime,i=s.GetEventSheetManager(),n=s.GetCurrentEvent(),r=n.GetSolModifiers(),a=s.GetEventStack(),o=a.GetCurrentStackFrame(),h=a.Push(n),l=this._path,c=this._currentKey,u=this._currentValue,d=this._ParsePathUnsafe(e);s.SetDebuggingEnabled(!1);for(const[e,s]of Object.entries(t))this._path=hA.cloneArray(d),this._path.push(e),this._currentKey=e,this._currentValue=s,i.PushCopySol(r),this.GetObjectClass().GetCurrentSol().PickOne(this.GetInstance()),n.Retrigger(o,h),i.PopSol(r);return s.SetDebuggingEnabled(!0),this._path=l,this._InvalidateLocationCache(),this._currentKey=c,this._currentValue=u,a.Pop(),!1},OnParseError:()=>!0,OnParseSuccess:()=>!0}}{const cA=self.C3;cA.Plugins.Json.Acts={Parse(e){try{this._SetData(JSON.parse(e)),this.Trigger(cA.Plugins.Json.Cnds.OnParseSuccess)}catch(e){console.warn("[JSON plugin] Failed to parse JSON data: ",e),this._SetData({}),this.Trigger(cA.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)?cA.resizeArray(s,t,0):(s=[],cA.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(cA.Plugins.Json.Cnds.OnParseSuccess)}catch(e){console.warn("[JSON plugin] Failed to parse JSON data: ",e),this.Trigger(cA.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)&&e>0&&(i.splice(s,e),this._InvalidateValueCache())}}}self.C3.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 e=t[0];return this._ToSafeValue(e)}return-1},Back(e){const t=this._GetValue(e);if(Array.isArray(t)){const e=t.at(-1);return this._ToSafeValue(e)}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)}},C3.Plugins.Gamezop=class extends C3.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}},C3.Plugins.Gamezop.Type=class extends C3.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}},Gamezop=globalThis.Gamezop,C3.Plugins.Gamezop.Instance=class extends C3.SDKInstanceBase{constructor(e,t){super(e,t),this.gameData={},this.kia=!0,this.mia=!0,this.isContest=!1,this.isBattle=!1,this.foundBattle=!1,this.pname="Gamezop",this.entryPointData="",this.currentState="",this.maxTriesAllowed=1,this.battleLevelData="",this.levelConfigFromGame="",this.watchedAd=!1}Release(){}OnCreate(){}OnPropertyChanged(e,t){}LoadC2Property(e,t){return!1}InitError(e){console.log("Initialisation error"),this.Trigger(C3.Plugins.Gamezop.Cnds.OnInit)}InitDone(e){const t=this;if(e){if(console.log("⚽ Initialization Done"),this.entryPointData=gamezop.getEntryPointData()||{},this.gameData=gamezop.data.metadata||{},this.kia=void 0===gamezop.isKia||gamezop.isKia,this.mia=void 0===gamezop.isMia||gamezop.isMia,this.isContest=gamezop&&gamezop.isContestGame&&gamezop.isContestGame(),this.isBattle=gamezop&&gamezop.isBattleGame&&gamezop.isBattleGame(),this.isBattle){const e=gamezop.isBattleGame().data;this.maxTriesAllowed=JSON.parse(e).maxTriesAllowed}console.log("⚽ Initialization Done"),t.Trigger(C3.Plugins.Gamezop.Cnds.OnInit)}else t.Trigger(C3.Plugins.Gamezop.Cnds.OnInit),console.log("Initialisation ! done")}ResumeGame(){console.log("INSTANCE RESUMED"),this.Trigger(C3.Plugins.Gamezop.Cnds.OnResume)}PauseGame(){console.log("INSTANCE PAUSED"),this.Trigger(C3.Plugins.Gamezop.Cnds.OnPause)}MuteGame(){this.Trigger(C3.Plugins.Gamezop.Cnds.OnMute)}UnMuteGame(){this.Trigger(C3.Plugins.Gamezop.Cnds.OnUnMute)}RestartGame(){this.Trigger(C3.Plugins.Gamezop.Cnds.OnRestart)}GameInit(e){""!=e.matchId&&(this.battleLevelData=e.gameConfig,this.Trigger(C3.Plugins.Gamezop.Cnds.OnGameInit))}GameEnd(){this.Trigger(C3.Plugins.Gamezop.Cnds.OnGameEnd)}GameContinue(){this.Trigger(C3.Plugins.Gamezop.Cnds.OnGameContinue)}getGameConfig(){return this.levelConfigFromGame}RewardedAd(e){this.watchedAd=e,this.watchedAd&&this.Trigger(C3.Plugins.Gamezop.Cnds.OnRewardedAdComplete)}},C3.Plugins.Gamezop.Cnds={OnPause:()=>(console.log("PAUSED"),!0),OnResume:()=>(console.log("RESUMED"),!0),OnMute:()=>!0,OnUnMute:()=>!0,OnInit:()=>(console.log("ON INIT"),!0),HasMeta(e){return null==this.gameData&&(this.gameData={}),this.gameData.hasOwnProperty(e)},OnRestart:()=>!0,OnGameInit:()=>!0,OnGameContinue:()=>!0,OnGameEnd:()=>!0,IsSoundEnabled:()=>gamezop.isSoundEnabled(),isBattleGame(){return this.isBattle},isContestGame(){return this.isContest},OnRewardedAdComplete:()=>!0,OnRewardedAdSkipped:()=>!0,OnRewardedAdError:()=>!0,isKia:()=>gamezop.isKia,isMia:()=>gamezop.isMia,getGameConfig:()=>!0,isAllowRewardedAds:()=>gamezop.allowRewardedAds()};{const uA=globalThis.Gamezop;C3.Plugins.Gamezop.Acts={Init(e,t){const s=this,i=[105,102,40,100,97,116,97,46,105,110,71,97,109,101,83],n=[104,97,114,101,32,61,61,32,39,84,119,105,116,116],r=[101,114,32,45,32,70,97,99,101,98,111,111],a=[107,32,45,32,71,111,111,103,108],o=[101,39,41,123,114,101,116,117,114,110,32,100,97,116,97,59,125],h=function(e){for(var t=[],s=0;sthis.gameData[a]&&(this.gameData[a]=e):this.gameData[a]=e,gamezop.setState({score:e,state:t,afps:s,tcount:i,kcount:n,metadata:this.gameData,leaderboard:r}),this.currentState=t},SetLevel(e){},SetMeta(e,t){this.gameData[e]=t},SetState(e){},SetLevelComplete(e,t){},SetGameOver(e,t){},UpdateLeaderboard(e,t){gamezop.setState({score:e,leaderboard:t,state:this.currentState})},ShowRewardedAds(){console.log("C3 Rewarded Ads 158545");const e=this;try{console.log("gamezop ref",gamezop),console.log("gamezop ref",gamezop.showAd),gamezop.showAd({type:"nonskipvideo"},function(t,s){console.log("rewarded ad callback"),console.log("rewarded ad "+s),console.log("WATCHED AD === ",t),t?(console.log("rewarded ad watched"),e.Trigger(C3.Plugins.Gamezop.Cnds.OnRewardedAdComplete)):"ad-unavailable"===s?(console.log("AD unavailable"),e.Trigger(C3.Plugins.Gamezop.Cnds.OnRewardedAdError)):(console.log("AD Skipped"),e.Trigger(C3.Plugins.Gamezop.Cnds.OnRewardedAdSkipped))})}catch(e){console.log("error in showing rewarded ads",e)}},SetGameMuted(e){gamezop.gameMuted=1==e},SetGamePaused(e){gamezop.isGamePaused=1==e},ShowAds(){try{gamezop.showAd({type:"320x50",position:"bottom",show:!0})}catch(e){console.log("error in showing banner ads",e)}},ShowAdsGeneric(e){try{"banner"==e?gamezop.showAd({type:"320x50",show:!1}):"midroll"==e&&gamezop.showAd({type:"midroll-ad"})}catch(e){console.log("error in showing ads",e)}},HideAds(){try{gamezop.showAd({type:"320x50",show:!1})}catch(e){console.log("error in removing banner ads",e)}},BroadcastActivityStatus(e,t){"activity"==e?gamezop.broadcastWinner({eventName:e}):"inactivity"==e&&gamezop.broadcastWinner({time:t,eventName:e})},BroadcastLoadingProgress(e,t){window.postMessage({type:"loading",gameCode:e,progress:t},"*"),window.parent!==window&&window.parent.postMessage({type:"loading",gameCode:e,progress:t},"*")},SetBattleLevelConfig(e){this.levelConfigFromGame=e}}}{const dA=globalThis.Gamezop;C3.Plugins.Gamezop.Exps={Score:()=>!0,Level:()=>!0,Meta(e){return this.gameData[e]},ShareLink:()=>!0,FBShareLink:()=>!0,TWShareLink:()=>!0,BattleConfigData(){return this.battleLevelData}}}{const _A=self.C3;_A.Plugins.PlatformInfo=class extends _A.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{const pA=self.C3;pA.Plugins.PlatformInfo.Type=class extends pA.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const gA=self.C3,mA="platform-info";gA.Plugins.PlatformInfo.Instance=class extends gA.SDKInstanceBase{constructor(e,t){super(e,mA),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(gA.Plugins.PlatformInfo.Cnds.OnNetworkChange)}async _OnWakeLockAcquired(){this._isWakeLockActive=!0,await this.TriggerAsync(gA.Plugins.PlatformInfo.Cnds.OnWakeLockAcquired)}async _OnWakeLockError(){this._isWakeLockActive=!1,await this.TriggerAsync(gA.Plugins.PlatformInfo.Cnds.OnWakeLockError)}async _OnWakeLockReleased(){this._isWakeLockActive=!1,await this.TriggerAsync(gA.Plugins.PlatformInfo.Cnds.OnWakeLockReleased)}}}{const fA=self.C3;fA.Plugins.PlatformInfo.Cnds={IsOnMobile:()=>fA.Platform.IsMobile,IsOnWindows:()=>"Windows"===fA.Platform.OS,IsOnMacOS:()=>"macOS"===fA.Platform.OS,IsOnLinux:()=>"Linux"===fA.Platform.OS,IsOnChromeOS:()=>"Chrome OS"===fA.Platform.OS,IsOnAndroid:()=>"Android"===fA.Platform.OS,IsOniOS:()=>"iOS"===fA.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:()=>!0,OnWakeLockAcquired:()=>!0,OnWakeLockError:()=>!0,OnWakeLockReleased:()=>!0,IsWakeLockActive(){return this._isWakeLockActive},IsWakeLockSupported(){return this._supportsWakeLock}}}self.C3.Plugins.PlatformInfo.Acts={RequestWakeLock(){this._supportsWakeLock&&this._PostToDOMMaybeSync("request-wake-lock")},ReleaseWakeLock(){this._supportsWakeLock&&(this._isWakeLockActive=!1,this.PostToDOM("release-wake-lock"))}},self.C3.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:()=>navigator.connection&&navigator.connection.downlink||0,DownlinkMax:()=>navigator.connection&&navigator.connection.downlinkMax||0,ConnectionType:()=>navigator.connection&&navigator.connection.type||"unknown",ConnectionEffectiveType:()=>navigator.connection&&navigator.connection.effectiveType||"unknown",ConnectionRTT:()=>navigator.connection&&navigator.connection.rtt||0,HardwareConcurrency:()=>navigator.hardwareConcurrency||0,DeviceMemory:()=>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 SA=self.C3;SA.Plugins.Date=class extends SA.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{const GA=self.C3;GA.Plugins.Date.Type=class extends GA.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const yA=self.C3;yA.Plugins.Date.Instance=class extends yA.SDKInstanceBase{constructor(e,t){super(e)}}}{const IA=self.C3,TA=[];TA[0]=[e=>IA.Plugins.Date.Exps.GetYear(e),e=>IA.Plugins.Date.Exps.GetMonth(e),e=>IA.Plugins.Date.Exps.GetDate(e),e=>IA.Plugins.Date.Exps.GetDay(e),e=>IA.Plugins.Date.Exps.GetHours(e),e=>IA.Plugins.Date.Exps.GetMinutes(e),e=>IA.Plugins.Date.Exps.GetSeconds(e),e=>IA.Plugins.Date.Exps.GetMilliseconds(e)],TA[1]=[e=>IA.Plugins.Date.Exps.GetUTCYear(e),e=>IA.Plugins.Date.Exps.GetUTCMonth(e),e=>IA.Plugins.Date.Exps.GetUTCDate(e),e=>IA.Plugins.Date.Exps.GetUTCDay(e),e=>IA.Plugins.Date.Exps.GetUTCHours(e),e=>IA.Plugins.Date.Exps.GetUTCMinutes(e),e=>IA.Plugins.Date.Exps.GetUTCSeconds(e),e=>IA.Plugins.Date.Exps.GetUTCMilliseconds(e)];const CA=e=>IA.Plugins.Date.Exps.Parse(e);IA.Plugins.Date.Cnds={CompareTimeStamps:(e,t,s)=>IA.compare(e,t,s),CompareDateStrings:(e,t,s)=>IA.compare(CA(e),t,CA(s)),CompareTimestampParts:(e,t,s,i)=>IA.compare(TA[1][i](e),t,TA[1][i](s)),CompareDateStringParts:(e,t,s,i,n)=>IA.compare(TA[n][i](CA(e)),t,TA[n][i](CA(s)))}}self.C3.Plugins.Date.Acts={};{const bA=self.C3,wA=self.Intl,PA=new Map;PA.set("local",new Map([["year",e=>new Date(e).getFullYear()],["month",e=>new Date(e).getMonth()],["date",e=>new Date(e).getDate()],["day",e=>new Date(e).getDay()],["hours",e=>new Date(e).getHours()],["minutes",e=>new Date(e).getMinutes()],["seconds",e=>new Date(e).getSeconds()],["milliseconds",e=>new Date(e).getMilliseconds()]])),PA.set("universal",new Map([["year",e=>new Date(e).getUTCFullYear()],["month",e=>new Date(e).getUTCMonth()],["date",e=>new Date(e).getUTCDate()],["day",e=>new Date(e).getUTCDay()],["hours",e=>new Date(e).getUTCHours()],["minutes",e=>new Date(e).getUTCMinutes()],["seconds",e=>new Date(e).getUTCSeconds()],["milliseconds",e=>new Date(e).getUTCMilliseconds()]]));const xA=new Map;xA.set("local",new Map([["year",(e,t)=>new Date(e).setFullYear(t)],["month",(e,t)=>new Date(e).setMonth(t)],["date",(e,t)=>new Date(e).setDate(t)],["hours",(e,t)=>new Date(e).setHours(t)],["minutes",(e,t)=>new Date(e).setMinutes(t)],["seconds",(e,t)=>new Date(e).setSeconds(t)],["milliseconds",(e,t)=>new Date(e).setMilliseconds(t)]])),xA.set("universal",new Map([["year",(e,t)=>new Date(e).setUTCFullYear(t)],["month",(e,t)=>new Date(e).setUTCMonth(t)],["date",(e,t)=>new Date(e).setUTCDate(t)],["hours",(e,t)=>new Date(e).setUTCHours(t)],["minutes",(e,t)=>new Date(e).setUTCMinutes(t)],["seconds",(e,t)=>new Date(e).setUTCSeconds(t)],["milliseconds",(e,t)=>new Date(e).setUTCMilliseconds(t)]]));const vA=function(e,t,s,i){s.includes(e)&&(i[t]=e)},AA=function(e,t){e&&("12"===e?t.hour12=!0:"24"===e&&(t.hour12=!1))},RA=function(e){try{return wA.getCanonicalLocales(e)}catch(e){return self.navigator.language}},MA=["full","long","medium","short"],DA=["full","long","medium","short"],EA=["long","short","narrow"],FA=["numeric","2-digit"],OA=["numeric","2-digit","long","short","narrow"],BA=["numeric","2-digit"],LA=["numeric","2-digit"],kA=["numeric","2-digit"],NA=["numeric","2-digit"];bA.Plugins.Date.Exps={ToString:e=>new Date(e).toString(),ToDateString:e=>new Date(e).toDateString(),ToTimeString:e=>new Date(e).toTimeString(),ToLocaleString:e=>new Date(e).toLocaleString(),ToLocaleDateString:e=>new Date(e).toLocaleDateString(),ToLocaleTimeString:e=>new Date(e).toLocaleTimeString(),ToUTCString:e=>new Date(e).toUTCString(),Parse:e=>Date.parse(e),Get:(e,t,s,i,n,r,a)=>Date.UTC(e,t,s,i,n,r,a),Now:()=>Date.now(),ExportTimestamp(){return this.GetRuntime().GetExportTimestamp()},TimezoneOffset:()=>new Date(Date.now()).getTimezoneOffset(),GetYear:e=>PA.get("local").get("year")(e),GetUTCYear:e=>PA.get("universal").get("year")(e),GetMonth:e=>PA.get("local").get("month")(e),GetUTCMonth:e=>PA.get("universal").get("month")(e),GetDate:e=>PA.get("local").get("date")(e),GetUTCDate:e=>PA.get("universal").get("date")(e),GetDay:e=>PA.get("local").get("day")(e),GetUTCDay:e=>PA.get("universal").get("day")(e),GetHours:e=>PA.get("local").get("hours")(e),GetUTCHours:e=>PA.get("universal").get("hours")(e),GetMinutes:e=>PA.get("local").get("minutes")(e),GetUTCMinutes:e=>PA.get("universal").get("minutes")(e),GetSeconds:e=>PA.get("local").get("seconds")(e),GetUTCSeconds:e=>PA.get("universal").get("seconds")(e),GetMilliseconds:e=>PA.get("local").get("milliseconds")(e),GetUTCMilliseconds:e=>PA.get("universal").get("milliseconds")(e),ChangeYear:(e,t)=>xA.get("local").get("year")(e,t),ChangeUTCYear:(e,t)=>xA.get("universal").get("year")(e,t),ChangeMonth:(e,t)=>xA.get("local").get("month")(e,t),ChangeUTCMonth:(e,t)=>xA.get("universal").get("month")(e,t),ChangeDate:(e,t)=>xA.get("local").get("date")(e,t),ChangeUTCDate:(e,t)=>xA.get("universal").get("date")(e,t),ChangeDay(e,t){const s=bA.Plugins.Date.Exps.GetYear(e),i=bA.Plugins.Date.Exps.GetMonth(e),n=bA.Plugins.Date.Exps.GetDate(e),r=bA.Plugins.Date.Exps.GetHours(e),a=bA.Plugins.Date.Exps.GetMinutes(e),o=bA.Plugins.Date.Exps.GetSeconds(e),h=bA.Plugins.Date.Exps.GetMilliseconds(e),l=bA.Plugins.Date.Exps.GetDay(e);return new Date(s,i,n+(t-l),r,a,o,h).getTime()},ChangeUTCDay(e,t){const s=bA.Plugins.Date.Exps.GetUTCYear(e),i=bA.Plugins.Date.Exps.GetUTCMonth(e),n=bA.Plugins.Date.Exps.GetUTCDate(e),r=bA.Plugins.Date.Exps.GetUTCHours(e),a=bA.Plugins.Date.Exps.GetUTCMinutes(e),o=bA.Plugins.Date.Exps.GetUTCSeconds(e),h=bA.Plugins.Date.Exps.GetUTCMilliseconds(e),l=t-bA.Plugins.Date.Exps.GetUTCDay(e);return bA.Plugins.Date.Exps.Get(s,i,n+l,r,a,o,h)},ChangeHours:(e,t)=>xA.get("local").get("hours")(e,t),ChangeUTCHours:(e,t)=>xA.get("universal").get("hours")(e,t),ChangeMinutes:(e,t)=>xA.get("local").get("minutes")(e,t),ChangeUTCMinutes:(e,t)=>xA.get("universal").get("minutes")(e,t),ChangeSeconds:(e,t)=>xA.get("local").get("seconds")(e,t),ChangeUTCSeconds:(e,t)=>xA.get("universal").get("seconds")(e,t),ChangeMilliseconds:(e,t)=>xA.get("local").get("milliseconds")(e,t),ChangeUTCMilliseconds:(e,t)=>xA.get("universal").get("milliseconds")(e,t),Difference:(e,t)=>t-e,ToTimerHours:e=>Math.trunc(bA.Plugins.Date.Exps.ToTotalHours(e)),ToTimerMinutes:e=>Math.trunc(bA.Plugins.Date.Exps.ToTotalMinutes(e))%60,ToTimerSeconds:e=>Math.trunc(bA.Plugins.Date.Exps.ToTotalSeconds(e))%60,ToTimerMilliseconds:e=>e%1e3,ToTotalHours:e=>e/36e5,ToTotalMinutes:e=>e/6e4,ToTotalSeconds:e=>e/1e3,FormatDateWithStyles(e,t,s,i,n){const r=RA(e);if(!r)return;let a={};return vA.call(this,s,"dateStyle",MA,a),vA.call(this,i,"timeStyle",DA,a),AA.call(this,n,a),new wA.DateTimeFormat(r,a).format(t)},FormatDateWithComponents(e,t,s,i,n,r,a,o,h,l){const c=RA(e);if(!c)return;const u={};return vA.call(this,s,"weekday",EA,u),vA.call(this,i,"year",FA,u),vA.call(this,n,"month",OA,u),vA.call(this,r,"day",BA,u),vA.call(this,a,"hour",LA,u),vA.call(this,o,"minute",kA,u),vA.call(this,h,"second",NA,u),AA.call(this,l,u),new wA.DateTimeFormat(c,u).format(t)}}}{const WA=self.C3,VA="button";WA.Plugins.Button=class extends WA.SDKDOMPluginBase{constructor(e){super(e,VA),this.AddElementMessageHandler("click",(e,t)=>e._OnClick(t))}Release(){super.Release()}}}{const UA=self.C3;UA.Plugins.Button.Type=class extends UA.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const jA=self.C3,HA=self.C3X,zA=0,XA=1,YA=2,qA=3,KA=4,$A=5,JA=6,ZA=7,QA=8,eR="button";jA.Plugins.Button.Instance=class extends jA.SDKDOMInstanceBase{constructor(e,t){super(e,eR),this._text="OK",this._isCheckbox=!1,this._isChecked=!1,this._title="",this._id="",this._className="",this._isEnabled=!0,this._autoFontSize=!0,t&&(this._isCheckbox=1===t[zA],this._text=t[XA],this._title=t[YA],this.GetWorldInfo().SetVisible(t[qA]),this._isEnabled=t[KA],this._autoFontSize=t[$A],this._isChecked=t[JA],this._id=t[ZA],this._className=t[QA]),this.CreateElement({id:this._id,className:this._className})}Release(){super.Release()}GetElementState(){return{text:this._text,isCheckbox:this._isCheckbox,isChecked:this._isChecked,title:this._title,isVisible:this.GetWorldInfo().IsVisible(),isEnabled:this._isEnabled}}async _OnClick(e){this._isChecked=e.isChecked,this.DispatchScriptEvent("click",!0),await this.TriggerAsync(jA.Plugins.Button.Cnds.OnClicked)}_SetText(e){this._text!==e&&(this._text=e,this.UpdateElementState())}_GetText(){return this._text}_SetTooltip(e){this._title!==e&&(this._title=e,this.UpdateElementState())}_GetTooltip(){return this._title}_SetEnabled(e){e=!!e,this._isEnabled!==e&&(this._isEnabled=e,this.UpdateElementState())}_IsEnabled(){return this._isEnabled}_SetChecked(e){this._isCheckbox&&(e=!!e,this._isChecked!==e&&(this._isChecked=e,this.UpdateElementState()))}_IsChecked(){return this._isChecked}Draw(e){}SaveToJson(){return{text:this._text,checked:this._isChecked,title:this._title,enabled:this._isEnabled}}LoadFromJson(e){this._text=e.text,this._isChecked=e.checked,this._title=e.title,this._isEnabled=e.enabled,this.UpdateElementState()}GetPropertyValueByIndex(e){switch(e){case XA:return this._GetText();case YA:return this._GetTooltip();case KA:return this._IsEnabled();case $A:return this._autoFontSize;case JA:return this._IsChecked()}}SetPropertyValueByIndex(e,t){switch(e){case XA:this._SetText(t);break;case YA:this._SetTooltip(t);break;case KA:this._SetEnabled(!!t);break;case $A:this._autoFontSize=!!t;break;case JA:this._SetChecked(!!t)}}GetDebuggerProperties(){const e="plugins.button";return[{title:e+".name",properties:[{name:e+".properties.text.name",value:this._GetText(),onedit:e=>this._SetText(e)},{name:e+".properties.enabled.name",value:this._IsEnabled(),onedit:e=>this._SetEnabled(e)},{name:e+".properties.checked.name",value:this._IsChecked(),onedit:e=>this._SetChecked(e)}]}]}GetScriptInterfaceClass(){return self.IButtonInstance}};const tR=new WeakMap;self.IButtonInstance=class extends self.IDOMInstance{constructor(){super(),tR.set(this,self.IInstance._GetInitInst().GetSdkInstance())}set text(e){HA.RequireString(e),tR.get(this)._SetText(e)}get text(){return tR.get(this)._GetText()}set tooltip(e){HA.RequireString(e),tR.get(this)._SetTooltip(e)}get tooltip(){return tR.get(this)._GetTooltip()}set isEnabled(e){tR.get(this)._SetEnabled(e)}get isEnabled(){return tR.get(this)._IsEnabled()}set isChecked(e){tR.get(this)._SetChecked(e)}get isChecked(){return tR.get(this)._IsChecked()}}}{const sR=self.C3;sR.Plugins.Button.Cnds={OnClicked:()=>!0,IsChecked(){return this._isChecked},CompareText(e,t){return t?this._text===e:sR.equalsNoCase(this._text,e)}}}self.C3.Plugins.Button.Acts={SetText(e){this._SetText(e)},SetTooltip(e){this._SetTooltip(e)},SetChecked(e){this._SetChecked(0!==e)},ToggleChecked(){this._isCheckbox&&(this._isChecked=!this._isChecked,this.UpdateElementState())}},self.C3.Plugins.Button.Exps={Text(){return this._text}},C3.Plugins.GameAnalytics=class extends C3.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}},C3.Plugins.GameAnalytics.Type=class extends C3.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}},C3.Plugins.GameAnalytics.Instance=class extends C3.SDKInstanceBase{constructor(e,t){super(e),this._build="",this._customUserId="",this._enableManualSessionHandling=!1,this._enableInfoLog=!1,this._enableVerboseLog=!1,this._autoDetectAppVersion=!1,this._gameKeyBrowser="",this._secretKeyBrowser="",this._gameKeyAndroid="",this._secretKeyAndroid="",this._gameKeyIOS="",this._secretKeyIOS="",this._customDimensions01=[],this._customDimensions02=[],this._customDimensions03=[],this._resourceCurrencies=[],this._resourceItemTypes=[],t&&(this._build=t[0],this._customUserId=t[1],this._enableManualSessionHandling=t[2],this._enableInfoLog=t[3],this._enableVerboseLog=t[4],this._autoDetectAppVersion=t[5],this._gameKeyBrowser=t[6],this._secretKeyBrowser=t[7],this._gameKeyAndroid=t[8],this._secretKeyAndroid=t[9],this._gameKeyIOS=t[10],this._secretKeyIOS=t[11])}Release(){super.Release()}SaveToJson(){return{}}LoadFromJson(e){}},C3.Plugins.GameAnalytics.Cnds={isRemoteConfigsReady(e){if(void 0!==globalThis.GameAnalytics&&"function"==typeof globalThis.GameAnalytics.isRemoteConfigsReady){return globalThis.GameAnalytics.isRemoteConfigsReady(function(t){e&&globalThis.c2_callFunction&&globalThis.c2_callFunction(e,[t?1:0])}),!1}return void 0!==globalThis.gameanalytics&&void 0!==globalThis.gameanalytics.GameAnalytics?globalThis.gameanalytics.GameAnalytics.isRemoteConfigsReady():(console.log("isRemoteConfigsReady: GameAnalytics object not found"),!1)}},C3.Plugins.GameAnalytics.Acts={addAvailableCustomDimension01(e){this._customDimensions01.push(e)},addAvailableCustomDimension02(e){this._customDimensions02.push(e)},addAvailableCustomDimension03(e){this._customDimensions03.push(e)},addAvailableResourceCurrency(e){this._resourceCurrencies.push(e)},addAvailableResourceItemType(e){this._resourceItemTypes.push(e)},initialize(){var e="3.0.14";if(void 0!==globalThis.GameAnalytics&&"function"==typeof globalThis.GameAnalytics.initialize){var t=globalThis.GameAnalytics;this._enableInfoLog&&t.setEnabledInfoLog(!0),this._enableVerboseLog&&t.setEnabledVerboseLog(!0),this._enableManualSessionHandling&&t.setEnabledManualSessionHandling(!0),this._customDimensions01.length>0&&t.configureAvailableCustomDimensions01(this._customDimensions01),this._customDimensions02.length>0&&t.configureAvailableCustomDimensions02(this._customDimensions02),this._customDimensions03.length>0&&t.configureAvailableCustomDimensions03(this._customDimensions03),this._resourceCurrencies.length>0&&t.configureAvailableResourceCurrencies(this._resourceCurrencies),this._resourceItemTypes.length>0&&t.configureAvailableResourceItemTypes(this._resourceItemTypes),t.configureBuild(this._build),this._autoDetectAppVersion&&t.configureAutoDetectAppVersion(!0);var s="construct "+e,i="Android"===globalThis.device.platform?this._gameKeyAndroid:this._gameKeyIOS,n="Android"===globalThis.device.platform?this._secretKeyAndroid:this._secretKeyIOS;t.initialize({gameKey:i,secretKey:n,sdkVersion:s})}else{if(void 0===globalThis.gameanalytics||void 0===globalThis.gameanalytics.GameAnalytics)return void console.log("initialize: GameAnalytics object not found");t=globalThis.gameanalytics.GameAnalytics;this._enableInfoLog&&t.setEnabledInfoLog(!0),this._enableVerboseLog&&t.setEnabledVerboseLog(!0),this._enableManualSessionHandling&&t.setEnabledManualSessionHandling(!0),this._customDimensions01.length>0&&t.configureAvailableCustomDimensions01(this._customDimensions01),this._customDimensions02.length>0&&t.configureAvailableCustomDimensions02(this._customDimensions02),this._customDimensions03.length>0&&t.configureAvailableCustomDimensions03(this._customDimensions03),this._resourceCurrencies.length>0&&t.configureAvailableResourceCurrencies(this._resourceCurrencies),this._resourceItemTypes.length>0&&t.configureAvailableResourceItemTypes(this._resourceItemTypes),t.configureBuild(this._build),t.configureSdkGameEngineVersion("construct "+e),t.initialize(this._gameKeyBrowser,this._secretKeyBrowser)}},addBusinessEvent(e,t,s,i,n){if(void 0!==globalThis.GameAnalytics&&"function"==typeof globalThis.GameAnalytics.addBusinessEvent)globalThis.GameAnalytics.addBusinessEvent({currency:e,amount:t,itemType:s,itemId:i,cartType:n});else{if(void 0===globalThis.gameanalytics||void 0===globalThis.gameanalytics.GameAnalytics)return void console.log("addBusinessEvent: GameAnalytics object not found");globalThis.gameanalytics.GameAnalytics.addBusinessEvent(e,t,s,i,n)}},addResourceEvent(e,t,s,i,n){if(void 0!==globalThis.GameAnalytics&&"function"==typeof globalThis.GameAnalytics.addResourceEvent)globalThis.GameAnalytics.addResourceEvent({flowType:e,currency:t,amount:s,itemType:i,itemId:n});else{if(void 0===globalThis.gameanalytics||void 0===globalThis.gameanalytics.GameAnalytics)return void console.log("addResourceEvent: GameAnalytics object not found");globalThis.gameanalytics.GameAnalytics.addResourceEvent(e,t,s,i,n)}},addProgressionEvent(e,t,s,i){if(void 0!==globalThis.GameAnalytics&&"function"==typeof globalThis.GameAnalytics.addProgressionEvent)globalThis.GameAnalytics.addProgressionEvent({progressionStatus:e,progression01:t,progression02:s,progression03:i});else{if(void 0===globalThis.gameanalytics||void 0===globalThis.gameanalytics.GameAnalytics)return void console.log("addProgressionEvent: GameAnalytics object not found");globalThis.gameanalytics.GameAnalytics.addProgressionEvent(e,t,s,i)}},addProgressionEventWithScore(e,t,s,i,n){if(void 0!==globalThis.GameAnalytics&&"function"==typeof globalThis.GameAnalytics.addProgressionEvent)globalThis.GameAnalytics.addProgressionEvent({progressionStatus:e,progression01:t,progression02:s,progression03:i,score:n});else{if(void 0===globalThis.gameanalytics||void 0===globalThis.gameanalytics.GameAnalytics)return void console.log("addProgressionEventWithScore: GameAnalytics object not found");globalThis.gameanalytics.GameAnalytics.addProgressionEvent(e,t,s,i,n)}},addDesignEvent(e){if(void 0!==globalThis.GameAnalytics&&"function"==typeof globalThis.GameAnalytics.addDesignEvent)globalThis.GameAnalytics.addDesignEvent({eventId:e});else{if(void 0===globalThis.gameanalytics||void 0===globalThis.gameanalytics.GameAnalytics)return void console.log("addDesignEvent: GameAnalytics object not found");globalThis.gameanalytics.GameAnalytics.addDesignEvent(e)}},addDesignEventWithValue(e,t){if(void 0!==globalThis.GameAnalytics&&"function"==typeof globalThis.GameAnalytics.addDesignEvent)globalThis.GameAnalytics.addDesignEvent({eventId:e,value:t});else{if(void 0===globalThis.gameanalytics||void 0===globalThis.gameanalytics.GameAnalytics)return void console.log("addDesignEventWithValue: GameAnalytics object not found");globalThis.gameanalytics.GameAnalytics.addDesignEvent(e,t)}},addErrorEvent(e,t){if(void 0!==globalThis.GameAnalytics&&"function"==typeof globalThis.GameAnalytics.addErrorEvent)globalThis.GameAnalytics.addErrorEvent({severity:e,message:t});else{if(void 0===globalThis.gameanalytics||void 0===globalThis.gameanalytics.GameAnalytics)return void console.log("addErrorEvent: GameAnalytics object not found");globalThis.gameanalytics.GameAnalytics.addErrorEvent(e,t)}},setEnabledEventSubmission(e){if(void 0!==globalThis.GameAnalytics&&"function"==typeof globalThis.GameAnalytics.setEnabledEventSubmission)globalThis.GameAnalytics.setEnabledEventSubmission(!!e);else{if(void 0===globalThis.gameanalytics||void 0===globalThis.gameanalytics.GameAnalytics)return void console.log("setEnabledEventSubmission: GameAnalytics object not found");globalThis.gameanalytics.GameAnalytics.setEnabledEventSubmission(!!e)}},setEnabledManualSessionHandling(e){if(void 0!==globalThis.GameAnalytics&&"function"==typeof globalThis.GameAnalytics.setEnabledManualSessionHandling)globalThis.GameAnalytics.setEnabledManualSessionHandling(!!e);else{if(void 0===globalThis.gameanalytics||void 0===globalThis.gameanalytics.GameAnalytics)return void console.log("setEnabledManualSessionHandling: GameAnalytics object not found");globalThis.gameanalytics.GameAnalytics.setEnabledManualSessionHandling(!!e)}},setCustomDimension01(e){if(void 0!==globalThis.GameAnalytics&&"function"==typeof globalThis.GameAnalytics.setCustomDimension01)globalThis.GameAnalytics.setCustomDimension01(e);else{if(void 0===globalThis.gameanalytics||void 0===globalThis.gameanalytics.GameAnalytics)return void console.log("setCustomDimension01: GameAnalytics object not found");globalThis.gameanalytics.GameAnalytics.setCustomDimension01(e)}},setCustomDimension02(e){if(void 0!==globalThis.GameAnalytics&&"function"==typeof globalThis.GameAnalytics.setCustomDimension02)globalThis.GameAnalytics.setCustomDimension02(e);else{if(void 0===globalThis.gameanalytics||void 0===globalThis.gameanalytics.GameAnalytics)return void console.log("setCustomDimension02: GameAnalytics object not found");globalThis.gameanalytics.GameAnalytics.setCustomDimension02(e)}},setCustomDimension03(e){if(void 0!==globalThis.GameAnalytics&&"function"==typeof globalThis.GameAnalytics.setCustomDimension03)globalThis.GameAnalytics.setCustomDimension03(e);else{if(void 0===globalThis.gameanalytics||void 0===globalThis.gameanalytics.GameAnalytics)return void console.log("setCustomDimension03: GameAnalytics object not found");globalThis.gameanalytics.GameAnalytics.setCustomDimension03(e)}},startSession(){if(void 0!==globalThis.GameAnalytics&&"function"==typeof globalThis.GameAnalytics.startSession)globalThis.GameAnalytics.startSession();else{if(void 0===globalThis.gameanalytics||void 0===globalThis.gameanalytics.GameAnalytics)return void console.log("startSession: GameAnalytics object not found");globalThis.gameanalytics.GameAnalytics.startSession()}},endSession(){if(void 0!==globalThis.GameAnalytics&&"function"==typeof globalThis.GameAnalytics.endSession)globalThis.GameAnalytics.endSession();else{if(void 0===globalThis.gameanalytics||void 0===globalThis.gameanalytics.GameAnalytics)return void console.log("endSession: GameAnalytics object not found");globalThis.gameanalytics.GameAnalytics.endSession()}},configureBuild(e){this._build=e}},C3.Plugins.GameAnalytics.Exps={getRemoteConfigsValueAsString(e,t,s){if(void 0!==globalThis.GameAnalytics&&"function"==typeof globalThis.GameAnalytics.getRemoteConfigsValueAsString){return globalThis.GameAnalytics.getRemoteConfigsValueAsString({key:e,defaultValue:t},function(e){s&&globalThis.c2_callFunction&&globalThis.c2_callFunction(s,[e])}),""}return void 0!==globalThis.gameanalytics&&void 0!==globalThis.gameanalytics.GameAnalytics?globalThis.gameanalytics.GameAnalytics.getRemoteConfigsValueAsString(e,t):(console.log("getRemoteConfigsValueAsString: GameAnalytics object not found"),"")},getRemoteConfigsContentAsString(e){if(void 0!==globalThis.GameAnalytics&&"function"==typeof globalThis.GameAnalytics.getRemoteConfigsContentAsString){return globalThis.GameAnalytics.getRemoteConfigsContentAsString(function(t){e&&globalThis.c2_callFunction&&globalThis.c2_callFunction(e,[t])}),""}return void 0!==globalThis.gameanalytics&&void 0!==globalThis.gameanalytics.GameAnalytics?globalThis.gameanalytics.GameAnalytics.getRemoteConfigsContentAsString():(console.log("endSession: GameAnalytics object not found"),"")}};{const iR=self.C3;iR.Behaviors.MoveTo=class extends iR.SDKBehaviorBase{constructor(e){super(e)}Release(){super.Release()}}}{const nR=self.C3;nR.Behaviors.MoveTo.Type=class extends nR.SDKBehaviorTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const rR=self.C3,aR=self.C3X,oR=self.IBehaviorInstance,hR=0,lR=1,cR=2,uR=3,dR=4,_R=5,pR=6;rR.Behaviors.MoveTo.Instance=class extends rR.SDKBehaviorInstanceBase{constructor(e,t){super(e),this._maxSpeed=200,this._acc=600,this._dec=600,this._rotateSpeed=0,this._setAngle=!0,this._stopOnSolids=!1,this._isEnabled=!0,this._speed=0,this._movingAngle=this.GetWorldInfo().GetAngle(),this._waypoints=[],t&&(this._maxSpeed=t[hR],this._acc=t[lR],this._dec=t[cR],this._rotateSpeed=rR.toRadians(t[uR]),this._setAngle=t[dR],this._stopOnSolids=t[_R],this._isEnabled=t[pR]),this._timelineInfo=null,this._lastTargetX=NaN,this._lastTargetY=NaN,this._lastTargetAngle=NaN,this._tRange=[0,0],this._timelineInfoProjectionRange={tRange:this._tRange}}Release(){this._timelineInfo&&(this._timelineInfo.Release(),this._timelineInfo=null),this._lastTargetX=NaN,this._lastTargetY=NaN,this._lastTargetAngle=NaN,this._tRange=null,this._timelineInfoProjectionRange=null,super.Release()}SaveToJson(){return{ms:this._maxSpeed,acc:this._acc,dec:this._dec,rs:this._rotateSpeed,sa:this._setAngle,sos:this._stopOnSolids,s:this._speed,ma:this._movingAngle,wp:this._waypoints.map(e=>({x:e.x,y:e.y})),e:this._isEnabled}}LoadFromJson(e){this._maxSpeed=e.ms,this._acc=e.acc,this._dec=e.dec,this._rotateSpeed=e.rs,this._setAngle=e.sa,this._stopOnSolids=e.sos,this._speed=e.s,this._movingAngle=e.ma,this._waypoints=e.wp.map(e=>({x:e.x,y:e.y})),this._SetEnabled(e.e),this._isEnabled&&this._waypoints.length>0&&this._StartTicking()}_AddWaypoint(e,t,s,i){s&&rR.clearArray(this._waypoints),this._waypoints.push({x:e,y:t,opts:i}),this._isEnabled&&this._StartTicking()}_GetWaypointCount(){return this._waypoints.length}_GetWaypointXAt(e){return(e=Math.floor(e))<0||e>=this._waypoints.length?0:this._waypoints[e].x}_GetWaypointYAt(e){return(e=Math.floor(e))<0||e>=this._waypoints.length?0:this._waypoints[e].y}_IsMoving(){return this._waypoints.length>0}_Stop(){rR.clearArray(this._waypoints),this._speed=0,this._StopTicking()}_GetTargetX(){return this._waypoints.length>0?this._waypoints[0].x:0}_GetTargetY(){return this._waypoints.length>0?this._waypoints[0].y:0}_GetTargetIsBezier(){if(this._waypoints.length>0){const e=this._waypoints[0];if(e.opts)return e.opts.isBezier}return!1}_GetTargetIsBezierFirst(){if(this._waypoints.length>0){const e=this._waypoints[0];if(e.opts)return e.opts.isBezier&&e.opts.isFirst}return!1}_GetTargetBezierAngle(){if(this._waypoints.length>0){const e=this._waypoints[0];if(e.opts)return e.opts.bezierAngle}return NaN}_SetSpeed(e){this._IsMoving()&&(this._speed=Math.min(e,this._maxSpeed))}_GetSpeed(){return this._speed}_SetMaxSpeed(e){this._maxSpeed=Math.max(e,0),this._SetSpeed(this._speed)}_GetMaxSpeed(){return this._maxSpeed}_IsRotationEnabled(){return 0!==this._rotateSpeed}Tick(){if(!this._isEnabled||!this._IsMoving())return;const e=this._runtime.GetDt(this._inst),t=this._inst.GetWorldInfo(),s=t.GetX(),i=t.GetY(),n=t.GetAngle();let r=this._speed,a=this._maxSpeed;const o=this._acc,h=this._dec,l=this._GetTargetX(),c=this._GetTargetY(),u=rR.angleTo(s,i,l,c);let d=!1;if(h>0&&1===this._waypoints.length){const e=.5*r*r/h*1.0001;if(d=rR.distanceSquared(s,i,l,c)<=e*e,d){const e=rR.distanceTo(s,i,l,c);r=Math.sqrt(2*h*e),a=r,this._speed=r}}if(this._IsRotationEnabled()){const e=rR.angleDiff(this._movingAngle,u);if(e>Number.EPSILON){const s=e/this._rotateSpeed,i=rR.distanceTo(t.GetX(),t.GetY(),l,c)/(2*Math.sin(e))*e;a=Math.min(a,rR.clamp(i/s,0,this._maxSpeed))}}let _=d?-h:o;const p=Math.min(r*e+.5*_*e*e,a*e);if(d){if(h>0&&(this._speed=Math.max(this._speed-h*e,0),0===this._speed))return void this._OnArrived(t,l,c)}else this._speed=0===o?a:Math.min(this._speed+o*e,a);if(rR.distanceSquared(t.GetX(),t.GetY(),l,c)<=p*p)this._OnArrived(t,l,c);else{if(this._IsRotationEnabled()?this._movingAngle=rR.angleRotate(this._movingAngle,u,this._rotateSpeed*e):this._movingAngle=u,t.OffsetXY(Math.cos(this._movingAngle)*p,Math.sin(this._movingAngle)*p),this._setAngle){const e=this._GetTargetIsBezier(),s=this._GetTargetIsBezierFirst();if(e&&!s){const e=rR.distanceTo(this._lastTargetX,this._lastTargetY,t.GetX(),t.GetY())/rR.distanceTo(this._lastTargetX,this._lastTargetY,l,c);t.SetAngle(rR.angleLerp(this._lastTargetAngle,this._GetTargetBezierAngle(),e))}else t.SetAngle(this._movingAngle),this._lastTargetX=NaN,this._lastTargetY=NaN,this._lastTargetAngle=NaN}t.SetBboxChanged(),this._CheckSolidCollision(s,i,n)}}_OnArrived(e,t,s){e.SetXY(t,s);const i=this._waypoints[0];i.opts&&i.opts.isBezier?(this._lastTargetX=i.x,this._lastTargetY=i.y,this._lastTargetAngle=i.opts.bezierAngle,this._setAngle&&e.SetAngle(this._lastTargetAngle)):(this._lastTargetX=NaN,this._lastTargetY=NaN,this._lastTargetAngle=NaN),e.SetBboxChanged(),this._waypoints.shift(),0===this._waypoints.length&&(this._timelineInfo&&(this._timelineInfo.Release(),this._timelineInfo=null,this._lastTargetX=NaN,this._lastTargetY=NaN,this._lastTargetAngle=NaN),this._speed=0,this._StopTicking()),this.DispatchScriptEvent("arrived"),this.Trigger(rR.Behaviors.MoveTo.Cnds.OnArrived)}_CheckSolidCollision(e,t,s){const i=this._runtime.GetCollisionEngine();if(this._stopOnSolids&&i.TestOverlapSolid(this._inst)){this._Stop();const n=this._inst.GetWorldInfo(),r=n.GetX(),a=n.GetY(),o=rR.angleTo(r,a,e,t),h=rR.distanceTo(r,a,e,t);i.PushOutSolid(this._inst,Math.cos(o),Math.sin(o),Math.max(h,1))||(n.SetXY(e,t),n.SetAngle(s),n.SetBboxChanged()),this.DispatchScriptEvent("hitsolid"),this.Trigger(rR.Behaviors.MoveTo.Cnds.OnHitSolid)}}_IsSetAngle(){return this._setAngle}_SetSetAngle(e){this._setAngle=!!e}_SetAngleOfMotion(e){if(this._movingAngle=e,this._isEnabled&&this._setAngle&&!this._IsMoving()){const e=this.GetWorldInfo();e.SetAngle(this._movingAngle),e.SetBboxChanged()}}_GetAngleOfMotion(){return this._movingAngle}_SetAcceleration(e){this._acc=Math.max(e,0)}_GetAcceleration(){return this._acc}_SetDeceleration(e){this._dec=Math.max(e,0)}_GetDeceleration(){return this._dec}_SetRotateSpeed(e){this._rotateSpeed=Math.max(e,0)}_GetRotateSpeed(){return this._rotateSpeed}_SetStopOnSolids(e){this._stopOnSolids=!!e}_IsStopOnSolids(){return this._stopOnSolids}_SetEnabled(e){e=!!e,this._isEnabled!==e&&(this._isEnabled=e,this._isEnabled&&this._IsMoving()?this._StartTicking():this._StopTicking())}_IsEnabled(){return this._isEnabled}GetPropertyValueByIndex(e){switch(e){case hR:return this._GetMaxSpeed();case lR:return this._GetAcceleration();case cR:return this._GetDeceleration();case uR:return rR.toDegrees(this._GetRotateSpeed());case dR:return this._IsSetAngle();case _R:return this._IsStopOnSolids();case pR:return this._IsEnabled()}}SetPropertyValueByIndex(e,t){switch(e){case hR:this._SetMaxSpeed(t);break;case lR:this._SetAcceleration(t);break;case cR:this._SetDeceleration(t);break;case uR:this._SetRotateSpeed(rR.toRadians(t));break;case dR:this._SetSetAngle(t);break;case _R:this._SetStopOnSolids(t);break;case pR:this._SetEnabled(t)}}GetDebuggerProperties(){const e="behaviors.moveto";return[{title:"$"+this.GetBehaviorType().GetName(),properties:[{name:e+".debugger.speed",value:this._GetSpeed(),onedit:e=>this._SetSpeed(e)},{name:e+".debugger.angle-of-motion",value:rR.toDegrees(this._GetAngleOfMotion()),onedit:e=>this._movingAngle=rR.toRadians(e)},{name:e+".debugger.target-x",value:this._GetTargetX()},{name:e+".debugger.target-y",value:this._GetTargetY()},{name:e+".debugger.waypoint-count",value:this._GetWaypointCount()},{name:e+".properties.max-speed.name",value:this._GetMaxSpeed(),onedit:e=>this._SetMaxSpeed(e)},{name:e+".properties.acceleration.name",value:this._GetAcceleration(),onedit:e=>this._SetAcceleration(e)},{name:e+".properties.deceleration.name",value:this._GetDeceleration(),onedit:e=>this._SetDeceleration(e)},{name:e+".properties.rotate-speed.name",value:rR.toDegrees(this._GetRotateSpeed()),onedit:e=>this._SetRotateSpeed(rR.toRadians(e))},{name:e+".properties.enabled.name",value:this._IsEnabled(),onedit:e=>this._SetEnabled(e)}]}]}GetScriptInterfaceClass(){return self.IMoveToBehaviorInstance}};const gR=new WeakMap;self.IMoveToBehaviorInstance=class extends oR{constructor(){super(),gR.set(this,oR._GetInitInst().GetSdkInstance())}moveToPosition(e,t,s=!0){aR.RequireFiniteNumber(e),aR.RequireFiniteNumber(t),gR.get(this)._AddWaypoint(e,t,!!s)}getTargetX(){return gR.get(this)._GetTargetX()}getTargetY(){return gR.get(this)._GetTargetY()}getTargetPosition(){const e=gR.get(this);return[e._GetTargetX(),e._GetTargetY()]}getWaypointCount(){return gR.get(this)._GetWaypointCount()}getWaypointX(e){return aR.RequireFiniteNumber(e),gR.get(this)._GetWaypointXAt(e)}getWaypointY(e){return aR.RequireFiniteNumber(e),gR.get(this)._GetWaypointYAt(e)}getWaypoint(e){aR.RequireFiniteNumber(e);const t=gR.get(this);return[t._GetWaypointXAt(e),t._GetWaypointYAt(e)]}stop(){gR.get(this)._Stop()}get isMoving(){return gR.get(this)._IsMoving()}get speed(){return gR.get(this)._GetSpeed()}set speed(e){aR.RequireFiniteNumber(e),gR.get(this)._SetSpeed(e)}get maxSpeed(){return gR.get(this)._GetMaxSpeed()}set maxSpeed(e){aR.RequireFiniteNumber(e),gR.get(this)._SetMaxSpeed(e)}get acceleration(){return gR.get(this)._GetAcceleration()}set acceleration(e){aR.RequireFiniteNumber(e),gR.get(this)._SetAcceleration(e)}get deceleration(){return gR.get(this)._GetDeceleration()}set deceleration(e){aR.RequireFiniteNumber(e),gR.get(this)._SetDeceleration(e)}get angleOfMotion(){return gR.get(this)._GetAngleOfMotion()}set angleOfMotion(e){aR.RequireFiniteNumber(e),gR.get(this)._SetAngleOfMotion(e)}get rotateSpeed(){return gR.get(this)._GetRotateSpeed()}set rotateSpeed(e){aR.RequireFiniteNumber(e),gR.get(this)._SetRotateSpeed(e)}get isStopOnSolids(){return gR.get(this)._IsStopOnSolids()}set isStopOnSolids(e){gR.get(this)._SetStopOnSolids(e)}get isEnabled(){return gR.get(this)._IsEnabled()}set isEnabled(e){gR.get(this)._SetEnabled(e)}}}{const mR=self.C3;mR.Behaviors.MoveTo.Cnds={IsMoving(){return this._IsMoving()},CompareSpeed(e,t){return mR.compare(this._GetSpeed(),e,t)},IsEnabled(){return this._IsEnabled()},OnArrived:()=>!0,OnHitSolid:()=>!0}}{const fR=self.C3,SR=25;fR.Behaviors.MoveTo.Acts={MoveToPosition(e,t,s){this._AddWaypoint(e,t,0===s)},MoveToObject(e,t,s){if(!e)return;const i=e.GetPairedInstance(this._inst);if(!i||!i.GetWorldInfo())return;const[n,r]=i.GetImagePoint(t);this._AddWaypoint(n,r,0===s)},MoveAlongPathfindingPath(e){const t=this._inst.GetBehaviorSdkInstanceFromCtor(fR.Behaviors.Pathfinding);if(!t)return;const s=t._GetPath();if(0!==s.length)for(let t=0,i=s.length;tthis._OnAfterLoad(),this.GetRuntime().Dispatcher().addEventListener("afterload",this._afterLoad)}Release(){this.GetRuntime().Dispatcher().removeEventListener("afterload",this._afterLoad),this._afterLoad=null,this._finishingTween&&(this.ReleaseAndCompleteTween(this._finishingTween),this._finishingTween=null),this.ReleaseAndCompleteTweens(),this._tweens=null,this.ClearDisabledList(),this._disabledTweens=null,this._ReleaseWaitingTweens(),this._waitingForReleaseTweens=null,this._triggerTweens=null,super.Release()}PushTriggerTween(e){this._triggerTweens.push(e)}PopTriggerTween(){this._triggerTweens.pop()}GetTriggerTween(){return this._triggerTweens[this._triggerTweens.length-1]}SetEnabled(e){this._enabled=!!e,e?this._waitingForReleaseTweens&&this._waitingForReleaseTweens.size&&this._StartTicking2():this._StopTicking2();for(const t of this.AllTweens())e?this.IsInDisabledList(t)&&t.Resume():((t.IsPlaying()||t.IsScheduled())&&this.AddToDisabledList(t),t.Stop());e&&this.ClearDisabledList()}IsEnabled(){return this._enabled}AddToDisabledList(e){this._disabledTweens.push(e)}IsInDisabledList(e){return this._disabledTweens.includes(e)}ClearDisabledList(){TR.clearArray(this._disabledTweens)}GetFinishingTween(){return this._finishingTween}IsInstanceValid(){const e=this.GetObjectInstance();return!!e&&!e.IsDestroyed()}GetTween(e,t,s=!1){const i=t?this.PropertyTweens(t,s):this.AllTweens(s);if(i&&i.length)for(const t of i)if(t.HasTags(e))return t}CheckTweensWithTags(e,t){for(const s of this._activeTweens.values())for(const i of s)if(!i.IsReleased()&&i.HasTags(e)&&t(i))return!0;for(const s of this._waitingForReleaseTweens.values())for(const i of s)if(!i.IsReleased()&&i.HasTags(e)&&t(i))return!0;return!1}CheckTweens(e){for(const t of this._activeTweens.values())for(const s of t)if(!s.IsReleased()&&e(s))return!0;for(const t of this._waitingForReleaseTweens.values())for(const s of t)if(!s.IsReleased()&&e(s))return!0;return!1}GetTweenIncludingWaitingForRelease(e,t){return this.GetTween(e,t,!0)}*GetTweens(e,t,s=!1){const i=t?this.PropertyTweens(t,s):this.AllTweens(s);if(i&&i.length)for(const t of i)t.HasTags(e)&&(yield t)}*GetTweensIncludingWaitingForRelease(e,t){yield*this.GetTweens(e,t,!0)}PropertyTweens(e,t){if(t){let t=this._activeTweens.get(e),s=this._waitingForReleaseTweens.get(e);return t||(t=[]),s||(s=[]),t.concat(s).filter(e=>e).filter(e=>!e.IsReleased())}{let t=this._activeTweens.get(e);return t||(t=[]),t.filter(e=>e).filter(e=>!e.IsReleased())}}AllTweens(e){if(e){const e=[...this._activeTweens.values()].flat(),t=[...this._waitingForReleaseTweens.values()].flat();return e.concat(t).filter(e=>e).filter(e=>!e.IsReleased())}return[...this._activeTweens.values()].flat().filter(e=>e).filter(e=>!e.IsReleased())}AllTweensIncludingWaitingForRelease(){return this.AllTweens(!0)}SaveToJson(e="full"){return{s:!1,e:!!this._enabled,at:this._SaveActiveTweensToJson(),dt:this._SaveDisabledTweensToJson(),wt:this._SaveWaitingForReleaseTweensToJson(),ft:this._SaveFinishingTweenToJson()}}LoadFromJson(e,t="full"){e&&(this._activeTweensJson=e.at,this._disabledTweensJson=e.dt,this._waitingForReleaseTweensJson=e.wt,this._finishingTweenName=e.ft,this._allowMultiple=!1,this._enabled=!!e.e,"state"===t&&this._OnAfterLoad())}_OnAfterLoad(){const e=this.GetRuntime().GetTimelineManager();if(this._PopulateTweenMap(this._activeTweensJson,this._activeTweens,e),this._disabledTweensJson){TR.clearArray(this._disabledTweens);for(const t of this._disabledTweensJson)this._PopulateTweenArray(this._disabledTweens,t,e)}this._PopulateTweenMap(this._waitingForReleaseTweensJson,this._waitingForReleaseTweens,e),this._finishingTween=this._GetTween(this._finishingTweenName,e),this._enabled?this._waitingForReleaseTweens&&this._waitingForReleaseTweens.size&&this._StartTicking2():this._StopTicking2()}_PopulateTweenMap(e,t,s){if(e)for(const i in e){let n=t.get(i);n?TR.clearArray(n):n=[];const r=e[i];for(const e of r)if(this._PopulateTweenArray(n,e.name,s))this._LoadTweenFromJson(e.name,e,s);else{const t=TR.TweenState.Build({runtime:this.GetRuntime(),json:e});TR.TweenState.SetInstanceUID(t,this.GetObjectInstance().GetUID()),t.AddCompletedCallback(e=>this._FinishTriggers(e)),t.SetBehaviorInstance(this),s.AddScheduledTimeline(t),this._PopulateTweenArray(n,t,s)}t.set(i,n)}}_GetTween(e,t){return t.GetScheduledOrPlayingTimelineByName(e)}_PopulateTweenArray(e,t,s){if("string"!=typeof t)return!!e.push(t);{const i=this._GetTween(t,s);if(i)return!!e.push(i)}return!1}_LoadTweenFromJson(e,t,s){if("string"==typeof e){const i=this._GetTween(e,s);i&&(i._LoadFromJson(t),TR.TweenState.SetInstanceUID(i,this.GetObjectInstance().GetUID()),TR.TweenState.SetBehaviorInstance(i,this))}else e._LoadFromJson(t),TR.TweenState.SetInstanceUID(e,this.GetObjectInstance().GetUID()),TR.TweenState.SetBehaviorInstance(e,this)}_SaveActiveTweensToJson(){const e={};for(const[t,s]of this._activeTweens)e[t]=s.filter(e=>!e.IsReleased()).map(e=>e._SaveToJson());return e}_SaveDisabledTweensToJson(){return this._disabledTweens.filter(e=>!e.IsReleased()).map(e=>e.GetName())}_SaveWaitingForReleaseTweensToJson(){const e={};for(const[t,s]of this._waitingForReleaseTweens)e[t]=s.map(e=>e._SaveToJson());return e}_SaveFinishingTweenToJson(){return this._finishingTween?this._finishingTween.GetName():""}Tick2(){this._ReleaseWaitingTweens()}CreateTween(e){const t=CR.Config.GetPropertyTracksConfig(e.property,e.startValue,e.endValue,e.ease,e.resultMode,this.GetObjectInstance()),s=CR.Maps.GetPropertyFromIndex(e.property);CR.Maps.IsValueId(s)||this.ReleaseTweens(e.property);const i=TR.TweenState.Build({runtime:this.GetRuntime(),id:s,tags:e.tags,time:e.time,instance:this.GetObjectInstance(),releaseOnComplete:!!e.releaseOnComplete,loop:!!e.loop,pingPong:!!e.pingPong,repeatCount:e.repeatCount,initialValueMode:e.initialValueMode,propertyTracksConfig:t});return i.AddCompletedCallback(e=>this._FinishTriggers(e)),i.SetBehaviorInstance(this),this._AddTween(i,e.property),i}_MaybeRemoveFromActiveTweenMap(e){const t=e.GetId();if(this._activeTweens.has(t)){const s=this._activeTweens.get(t);if(s){const t=s.indexOf(e);-1!==t&&s.splice(t,1)}}}ReleaseTween(e,t=!1){this._MaybeRemoveFromActiveTweenMap(e),e.IsReleased()||this._IsInWaitingList(e)||(e.Stop(t),this._AddToWaitingList(e))}ReleaseTweens(e,t=!1){if(TR.IsFiniteNumber(e)){const s=CR.Maps.GetPropertyFromIndex(e);if(!this._activeTweens.has(s))return;const i=this._activeTweens.get(s),n=this.GetFinishingTween();for(const e of i)e!==n&&(e.IsReleased()||this._IsInWaitingList(e)||(e.Stop(t),e.Release()));TR.clearArray(i)}else{const e=this.GetFinishingTween();for(const s of this.AllTweens())s!==e&&(s.IsReleased()||this._IsInWaitingList(s)||(s.Stop(t),s.Release()));for(const e of this._activeTweens.keys())TR.clearArray(this._activeTweens.get(e)),this._activeTweens.delete(e);this._activeTweens.clear()}}ReleaseAndCompleteTween(e){this.ReleaseTween(e,!0)}ReleaseAndCompleteTweens(){this.ReleaseTweens(NaN,!0)}GetPropertyValueByIndex(e){if(e===bR)return this._enabled}SetPropertyValueByIndex(e,t){e===bR&&(this._enabled=!!t)}_GetBehaviorType(e){const t=e.GetInstance().GetBehaviorInstances();for(const e of t){const t=e.GetBehaviorType();if(t.GetInstanceSdkCtor()===this.constructor)return t}}Trigger(e,t,s,i){return this._runtime?super.Trigger(e):t.Trigger(e,s,i)}_FinishTriggers(e){let t,s;if(this._finishingTween=e,CR.Cnds.SetFinishingTween(e),this.GetRuntime())t=this._inst,s=this._runtime,this.Trigger(CR.Cnds.OnTweensFinished),this.Trigger(CR.Cnds.OnAnyTweensFinished),this.ReleaseTween(e);else{if(t=e.GetInstance(),!t)return;if(t&&t.IsDestroyed())return;s=t.GetRuntime();const i=this._GetBehaviorType(e);this.Trigger(CR.Cnds.OnTweensFinished,s,t,i),this.Trigger(CR.Cnds.OnAnyTweensFinished,s,t,i),e.Stop()}this._finishingTween=null,CR.Cnds.SetFinishingTween(null),e.GetDestroyInstanceOnComplete()&&s.DestroyInstance(t)}_AddTween(e,t){const s=CR.Maps.GetPropertyFromIndex(t);this._activeTweens.has(s)||this._activeTweens.set(s,[]),this._activeTweens.get(s).push(e)}_AddToWaitingList(e){const t=e.GetId();this._waitingForReleaseTweens.has(t)||this._waitingForReleaseTweens.set(t,[]),this._waitingForReleaseTweens.get(t).push(e),this.IsTicking2()||this._StartTicking2()}_IsInWaitingList(e){const t=e.GetId();return!!this._waitingForReleaseTweens.has(t)&&this._waitingForReleaseTweens.get(t).includes(e)}_ReleaseWaitingTweens(){if(this._waitingForReleaseTweens.size){for(const e of this._waitingForReleaseTweens.values()){for(const t of e)t.IsReleased()||t.Release();TR.clearArray(e)}this._waitingForReleaseTweens.clear(),this.IsTicking2()&&this._StopTicking2()}}GetDebuggerProperties(){return[{title:"$"+this.GetBehaviorType().GetName(),properties:[{name:"behaviors.tween.properties.enabled.name",value:this.IsEnabled(),onedit:e=>this.SetEnabled(e)}]}]}GetScriptInterfaceClass(){return self.ITweenBehaviorInstance}}}{const wR=self.C3;let PR=null;wR.Behaviors.Tween.Cnds={OnAnyTweenLoop:()=>!0,OnTweensLoop(e){const t=this.GetTriggerTween();return!!t&&t.HasTags(e)},OnAnyTweenPingPong(e){const t=this.GetTriggerTween();return!!t&&(t.GetPingPongState()===e||2===e)},OnTweensPingPong(e,t){const s=this.GetTriggerTween();return!!s&&(s.GetPingPongState()===t||2===t)&&s.HasTags(e)},SetFinishingTween(e){PR=e},OnTweensFinished:e=>PR.HasTags(e),OnAnyTweensFinished:()=>!0,IsPlaying(e){return this.CheckTweensWithTags(e,wR.TweenState.IsPlaying)},IsAnyPlaying(){return this.CheckTweens(wR.TweenState.IsPlaying)},IsPaused(e){return this.CheckTweensWithTags(e,wR.TweenState.IsPaused)},IsAnyPaused(){return this.CheckTweens(wR.TweenState.IsPaused)},IsPingPong(e,t){return 0===t?this.CheckTweensWithTags(e,wR.TweenState.IsPing):1===t&&this.CheckTweensWithTags(e,wR.TweenState.IsPong)},IsAnyPingPong(e){return 0===e?this.CheckTweens(wR.TweenState.IsPing):1===e&&this.CheckTweens(wR.TweenState.IsPong)}}}{const xR=self.C3,vR=self.Ease,AR=xR.Behaviors.Tween;AR.Acts={SetEnabled(e){this.SetEnabled(!!e)},async TweenOneProperty(...e){if(!this.IsEnabled()||!this.IsInstanceValid())return;const t=this.CreateTween(AR.TweenArguments.OneProperty(this,...e));t.Play()&&await t.GetPlayPromise()},async TweenTwoProperties(...e){if(!this.IsEnabled()||!this.IsInstanceValid())return;const t=this.CreateTween(AR.TweenArguments.TwoProperties(this,...e));t.Play()&&await t.GetPlayPromise()},async TweenValue(...e){if(!this.IsEnabled()||!this.IsInstanceValid())return;const t=this.CreateTween(AR.TweenArguments.ValueProperty(this,...e));t.Play()&&await t.GetPlayPromise()},PauseTweens(e){if(this.IsEnabled()&&this.IsInstanceValid())for(const t of this.GetTweens(e))t.Stop()},PauseAllTweens(){if(this.IsEnabled()&&this.IsInstanceValid())for(const e of this.AllTweens())e.Stop()},ResumeTweens(e){if(this.IsEnabled()&&this.IsInstanceValid())for(const t of this.GetTweens(e))t.Resume()},ResumeAllTweens(){if(this.IsEnabled()&&this.IsInstanceValid())for(const e of this.AllTweens())e.Resume()},StopTweens(e){if(this.IsEnabled()&&this.IsInstanceValid())for(const t of this.GetTweens(e))this.ReleaseTween(t)},StopAllTweens(){if(this.IsEnabled()&&this.IsInstanceValid())for(const e of this.AllTweens())this.ReleaseTween(e)},SetOnePropertyTweensEndValue(e,t,s){if(!this.IsEnabled()||!this.IsInstanceValid())return;const i=xR.Behaviors.Tween.Maps.GetSinglePropertyFromIndex(t);for(const t of this.GetTweens(e))t.BeforeSetEndValues([i]),t.SetEndValue(s,i)},SetTwoPropertiesTweensEndValue(e,t,s,i){if(!this.IsEnabled()||!this.IsInstanceValid())return;const n=xR.Behaviors.Tween.Maps.GetRealProperties(t);for(const t of this.GetTweens(e))t.BeforeSetEndValues(n),t.SetEndValue(s,n[0]),t.SetEndValue(i,n[1])},SetValuePropertyTweensStartValue(e,t){if(this.IsEnabled()&&this.IsInstanceValid())for(const s of this.GetTweens(e,"value"))s.SetStartValue(t,"value")},SetValuePropertyTweensEndValue(e,t){if(this.IsEnabled()&&this.IsInstanceValid())for(const s of this.GetTweens(e,"value"))s.BeforeSetEndValues(["value"]),s.SetEndValue(t,"value")},SetTweensEase(e,t){if(!this.IsEnabled()||!this.IsInstanceValid())return;const s=vR.GetEaseFromIndex(t);for(const t of this.GetTweens(e))t.SetEase(s)},SetAllTweensEase(e){if(!this.IsEnabled()||!this.IsInstanceValid())return;const t=vR.GetEaseFromIndex(e);for(const e of this.AllTweens())e.SetEase(t)},SetTweensTime(e,t){if(this.IsEnabled()&&this.IsInstanceValid())for(const s of this.GetTweens(e))s.SetTime(t)},SetAllTweensTime(e){if(this.IsEnabled()&&this.IsInstanceValid())for(const t of this.AllTweens())t.SetTime(e)},SetTweensPlaybackRate(e,t){if(this.IsEnabled()&&this.IsInstanceValid())for(const s of this.GetTweens(e))s.SetPlaybackRate(t)},SetAllTweensPlaybackRate(e){if(this.IsEnabled()&&this.IsInstanceValid())for(const t of this.AllTweens())t.SetPlaybackRate(e)},SetTweensDestroyOnComplete(e,t){if(this.IsEnabled()&&this.IsInstanceValid())for(const s of this.GetTweens(e))s.SetDestroyInstanceOnComplete(!!t)},SetAllTweensDestroyOnComplete(e){if(this.IsEnabled()&&this.IsInstanceValid())for(const t of this.AllTweens())t.SetDestroyInstanceOnComplete(!!e)}}}self.C3.Behaviors.Tween.Exps={Time(e){const t=this.GetTweenIncludingWaitingForRelease(e);return t?t.GetTime():0},Progress(e){const t=this.GetTweenIncludingWaitingForRelease(e);return t?t.GetTime()/t.GetTotalTime():0},PlaybackRate(e){const t=this.GetTweenIncludingWaitingForRelease(e);return t?t.GetPlaybackRate():0},Value(e){const t=this.GetTweenIncludingWaitingForRelease(e,"value");return t?t.GetPropertyTrack("value").GetSourceAdapterValue():0},Tags(){let e=this.GetFinishingTween();return e?e.GetStringTags():(e=this.GetTriggerTween(),e?e.GetStringTags():"")}};{const RR=self.C3,MR=self.Ease,DR=["position","size","scale"],ER=["offsetX","offsetY","offsetWidth","offsetHeight","offsetAngle","offsetOpacity","offsetColor","offsetZElevation","offsetScaleX","offsetScaleY"],FR=["value"],OR=[].concat(DR).concat(ER).concat(FR),BR={position:["offsetX","offsetY"],size:["offsetWidth","offsetHeight"],scale:["offsetScaleX","offsetScaleY"]},LR=Object.assign({},OR.reduce((e,t)=>Object.assign({},e,{[t]:[t]}),{}),BR);RR.Behaviors.Tween.Maps=class{constructor(){}static GetEases(){return[...MR.GetRuntimeEaseNames()]}static GetEaseFromIndex(e){return[...MR.GetRuntimeEaseNames()][e]}static GetPropertyFromIndex(e){return OR[e]}static GetPropertyIndexFromName(e){return OR.indexOf(e)}static GetPairPropertyFromIndex(e){return DR[e]}static GetSinglePropertyFromIndex(e){return ER[e]}static GetValuePropertyFromIndex(e){return FR[e]}static GetPairProperties(e){return BR[e]}static GetRealProperties(e){return RR.IsString(e)?LR[e]:LR[OR[e]]}static IsPairId(e){return!!BR[e]}static IsColorId(e){return"offsetColor"===e}static IsAngleId(e){return"offsetAngle"===e}static IsOpacityId(e){return"offsetOpacity"===e}static IsValueId(e){return"value"===e}}}{const kR=self.C3,NR=kR.Behaviors.Tween,WR=new Map;NR.Config=class{constructor(){}static GetPropertyTracksConfig(e,t,s,i,n,r){0===WR.size&&this._CreateConfigObjects();const a=NR.PropertyTypes.Pick(e);let o=WR.get(a);return kR.IsFiniteNumber(e)&&(e=NR.Maps.GetPropertyFromIndex(e)),this._GetConfig(o,e,t,s,i,n,r)}static TransformValue(e,t){return kR.Behaviors.Tween.GetPropertyTracksConfig(e).valueGetter(t)}static _CreateConfigObjects(){const e=NR.PropertyTypes,t=NR.ValueGetters;this._AddConfigObject(e.PAIR,this._GetPairConfig,t._GetPropertyValue),this._AddConfigObject(e.COLOR,this._GetColorConfig,t._GetColorPropertyValue),this._AddConfigObject(e.ANGLE,this._GetAngleConfig,t._GetPropertyAngleValue),this._AddConfigObject(e.VALUE,this._GetValueConfig,t._GetPropertyValue),this._AddConfigObject(e.OTHER,this._GetCommonConfig,t._GetPropertyValue)}static _AddConfigObject(e,t,s){WR.set(e,this._CreateConfigObject(e,t,s))}static _CreateConfigObject(e,t,s){return{name:e,configFunc:t,valueGetter:s}}static _GetConfig(e,t,s,i,n,r,a){return e.configFunc(t,e.valueGetter(s),e.valueGetter(i),n,r,a)}static _GetPairConfig(e,t,s,i,n,r){return NR.Maps.GetPairProperties(e).map((e,r)=>({sourceId:"world-instance",property:e,type:"float",valueType:"numeric",startValue:t[r],endValue:s[r],ease:NR.Maps.GetEaseFromIndex(i),resultMode:n}))}static _GetColorConfig(e,t,s,i,n,r){return kR.Plugins.Text&&r.GetPlugin()instanceof kR.Plugins.Text?{sourceId:"plugin",sourceArgs:[7],property:"color",type:"color",valueType:"color",startValue:t,endValue:s,ease:NR.Maps.GetEaseFromIndex(i),resultMode:n}:{sourceId:"world-instance",property:e,type:"color",valueType:"color",startValue:t,endValue:s,ease:NR.Maps.GetEaseFromIndex(i),resultMode:n}}static _GetAngleConfig(e,t,s,i,n,r){return{sourceId:"world-instance",property:e,type:"angle",valueType:"angle",startValue:t,endValue:s,ease:NR.Maps.GetEaseFromIndex(i),resultMode:n}}static _GetCommonConfig(e,t,s,i,n,r){return{sourceId:"world-instance",property:e,type:"float",valueType:"numeric",startValue:t,endValue:s,ease:NR.Maps.GetEaseFromIndex(i),resultMode:n}}static _GetValueConfig(e,t,s,i,n,r){return{sourceId:"value",property:e,type:"float",valueType:"numeric",startValue:t,endValue:s,ease:NR.Maps.GetEaseFromIndex(i),resultMode:n}}}}{const VR=self.C3,UR=VR.Behaviors.Tween,jR={resultMode:"absolute"},HR=Object.assign({},jR,{tags:"",property:"",time:0,ease:0,releaseOnComplete:0,loop:!1,pingPong:!1,repeatCount:1}),zR=Object.assign({},HR,{initialValueMode:"current-state",startValue:0,endValue:0}),XR=Object.assign({},HR,{initialValueMode:"current-state",startValue:[0,0],endValue:[0,0]}),YR=Object.assign({},HR,{initialValueMode:"current-state",startValue:[0,0,0],endValue:[0,0,0]}),qR=Object.assign({},zR,{initialValueMode:"start-value"}),KR=0,$R=1,JR=0,ZR=1,QR=2;UR.TweenArguments=class{constructor(){}static _SetCommonProperties(e,t,s,i,n,r,a,o){e.tags=t,e.time=s,e.ease=i,e.releaseOnComplete=n,e.loop=r,e.pingPong=a,e.repeatCount=o}static OneProperty(e,t,s,i,n,r,a,o,h,l){const c="string"==typeof s?s:UR.Maps.GetSinglePropertyFromIndex(s),u=UR.Maps.IsColorId(c)?YR:zR;return this._SetCommonProperties(u,t,n,r,a,o,h,l),UR.Maps.IsColorId(c)?(YR.endValue[0]=VR.GetRValue(i),YR.endValue[1]=VR.GetGValue(i),YR.endValue[2]=VR.GetBValue(i),YR.property=UR.Maps.GetPropertyIndexFromName(c)):UR.Maps.IsOpacityId(c)?zR.endValue=i/100:zR.endValue=i,u.property=UR.Maps.GetPropertyIndexFromName(c),u}static TwoProperties(e,t,s,i,n,r,a,o,h,l,c){this._SetCommonProperties(XR,t,r,a,o,h,l,c);const u="string"==typeof s?s:UR.Maps.GetPairPropertyFromIndex(s);return XR.endValue[0]=i,XR.endValue[1]=n,XR.property=UR.Maps.GetPropertyIndexFromName(u),XR}static ValueProperty(e,t,s,i,n,r,a,o,h,l){return this._SetCommonProperties(qR,t,n,r,a,o,h,l),qR.startValue=s,qR.endValue=i,qR.property=UR.Maps.GetPropertyIndexFromName("value"),qR}}}{const eM=self.C3,tM=eM.Behaviors.Tween,sM=[];tM.PropertyTypes=class{constructor(){}static Pick(e){if(0===sM.length){const e=sM;e.push({checkFunc:tM.Maps.IsPairId,result:this.PAIR}),e.push({checkFunc:tM.Maps.IsColorId,result:this.COLOR}),e.push({checkFunc:tM.Maps.IsAngleId,result:this.ANGLE}),e.push({checkFunc:tM.Maps.IsValueId,result:this.VALUE}),e.push({checkFunc:()=>!0,result:this.OTHER})}eM.IsFiniteNumber(e)&&(e=eM.Behaviors.Tween.Maps.GetPropertyFromIndex(e));for(const t of sM)if(t.checkFunc(e))return t.result}static get PAIR(){return"pair"}static get COLOR(){return"color"}static get ANGLE(){return"angle"}static get VALUE(){return"value"}static get OTHER(){return"other"}}}{const iM=self.C3,nM=iM.Behaviors.Tween;nM.ValueGetters=class{constructor(){}static _GetPropertyAngleValue(e){const t=iM.toRadians(parseFloat(e));return iM.clampAngle(t)}static _GetColorPropertyValue(e){return e.slice(0)}static _GetPropertyValue(e){return e}}}{let rM=function(e){hM.RequireString(e);const t=cM.ToInternal(e);let s;if(s=t?cM.GetIndexForEase(t,null):cM.GetIndexForEase(e,null),-1===s)throw new Error(`invalid ease name '${e}'`);return s},aM=function(e,t=!1){if(!(t&&null==e||"string"==typeof e||Array.isArray(e)))throw new Error("invalid tags")};getIndexForEase=rM,ValidateTags=aM;const oM=self.C3,hM=self.C3X,lM=self.IBehaviorInstance,cM=self.Ease,uM=oM.Behaviors.Tween,dM=new WeakMap,_M=new Map([["x",{name:"offsetX",type:"one"}],["y",{name:"offsetY",type:"one"}],["width",{name:"offsetWidth",type:"one"}],["height",{name:"offsetHeight",type:"one"}],["angle",{name:"offsetAngle",type:"one"}],["opacity",{name:"offsetOpacity",type:"one"}],["color",{name:"offsetColor",type:"color"}],["z-elevation",{name:"offsetZElevation",type:"one"}],["x-scale",{name:"offsetScaleX",type:"one"}],["y-scale",{name:"offsetScaleY",type:"one"}],["position",{name:"position",type:"two"}],["size",{name:"size",type:"two"}],["scale",{name:"scale",type:"two"}],["value",{name:"value",type:"value"}]]),pM={tags:"",destroyOnComplete:!1,loop:!1,pingPong:!1,repeatCount:1,startValue:0},gM={easeToIndexFunc:rM};self.ITweenBehaviorInstance=class extends lM{constructor(){super(),dM.set(this,lM._GetInitInst().GetSdkInstance())}startTween(e,t,s,i,n){const r=dM.get(this);if(!r.IsEnabled()||!r.IsInstanceValid())return null;const a=_M.get(e);if(!a)throw new Error("invalid tween property");"one"===a.type||"value"===a.type?hM.RequireNumber(t):(hM.RequireArray(t),"two"===a.type?(hM.RequireNumber(t[0]),hM.RequireNumber(t[1])):"color"===a.type&&(hM.RequireNumber(t[0]),hM.RequireNumber(t[1]),hM.RequireNumber(t[2]))),"angle"===e?t=oM.toDegrees(t):"opacity"===e?t*=100:"color"===e&&(t=oM.PackRGBEx(t[0],t[1],t[2]));const o=rM(i);let h;if(hM.RequireFiniteNumber(s),n=Object.assign({},pM,n),"value"===a.type&&hM.RequireNumber(n.startValue),aM(n.tags,!0),"one"===a.type||"color"===a.type?h=r.CreateTween(uM.TweenArguments.OneProperty(r,n.tags,a.name,t,s,o,!!n.destroyOnComplete,!!n.loop,!!n.pingPong,n.repeatCount)):"two"===a.type?h=r.CreateTween(uM.TweenArguments.TwoProperties(r,n.tags,a.name,t[0],t[1],s,o,!!n.destroyOnComplete,!!n.loop,!!n.pingPong,n.repeatCount)):"value"===a.type&&(h=r.CreateTween(uM.TweenArguments.ValueProperty(r,n.tags,n.startValue,t,s,o,!!n.destroyOnComplete,!!n.loop,!!n.pingPong,n.repeatCount))),h.SetBehaviorInstance(r.GetBehaviorInstance().GetSdkInstance()),!h.Play())throw new Error("failed to start tween");return h.GetITweenState(r,gM)}*allTweens(){const e=dM.get(this);for(const t of e.AllTweens())yield t.GetITweenState(e,gM)}*tweensByTags(e){aM(e);const t=dM.get(this);for(const s of t.GetTweens(e))yield s.GetITweenState(t,gM)}get isEnabled(){return dM.get(this).IsEnabled()}set isEnabled(e){dM.get(this).SetEnabled(e)}}}{const mM=self.C3;mM.Behaviors.Bullet=class extends mM.SDKBehaviorBase{constructor(e){super(e)}Release(){super.Release()}}}{const fM=self.C3;fM.Behaviors.Bullet.Type=class extends fM.SDKBehaviorTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const SM=self.C3,GM=self.C3X,yM=self.IBehaviorInstance,IM=0,TM=1,CM=2,bM=3,wM=4,PM=5,xM=6;SM.Behaviors.Bullet.Instance=class extends SM.SDKBehaviorInstanceBase{constructor(e,t){super(e);const s=this.GetWorldInfo();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[IM],this._acc=t[TM],this._g=t[CM],this._bounceOffSolid=!!t[bM],this._setAngle=!!t[wM],this._isStepping=!!t[PM],this._isEnabled=!!t[xM]);const i=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)return;const e=this._runtime.GetDt(this._inst),t=this._inst.GetWorldInfo();if(t.GetAngle()!==this._lastKnownAngle){const e=t.GetAngle();if(this._setAngle){const t=SM.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 n=SM.distanceTo(0,0,this._dx,this._dy),r=0;r=0===this._dx&&0===this._dy?t.GetAngle():SM.angleTo(0,0,this._dx,this._dy),n+=this._acc*e,s=Math.cos(r)*this._acc,i=Math.sin(r)*this._acc,n<0&&(n=0,s=0,i=0),this._dx=Math.cos(r)*n,this._dy=Math.sin(r)*n}if(0!==this._g&&(this._dy+=this._g*e,i+=this._g),this._lastX=t.GetX(),this._lastY=t.GetY(),0!==this._dx||0!==this._dy){const n=this._dx*e+.5*s*e*e,r=this._dy*e+.5*i*e*e,a=SM.distanceTo(0,0,n,r);if(this._MoveBy(n,r,a),this._travelled+=a,this._setAngle&&(0!==n||0!==r)){const e=SM.angleTo(0,0,n,r);t.SetAngle(e),this._lastKnownAngle=t.GetAngle()}t.SetBboxChanged()}}_MoveBy(e,t,s){const i=this.GetWorldInfo();if(!this._isStepping||s<=this._stepSize)return i.OffsetXY(e,t),i.SetBboxChanged(),void(this._isStepping&&this.Trigger(SM.Behaviors.Bullet.Cnds.OnStep));this._stopStepping=!1;const n=i.GetX(),r=i.GetY(),a=n+e,o=r+t,h=SM.angleTo(0,0,e,t),l=Math.cos(h)*this._stepSize,c=Math.sin(h)*this._stepSize,u=Math.floor(s/this._stepSize);for(let e=1;e<=u;++e)if(i.SetXY(n+l*e,r+c*e),i.SetBboxChanged(),this.Trigger(SM.Behaviors.Bullet.Cnds.OnStep),this._inst.IsDestroyed()||this._stopStepping)return;i.SetXY(a,o),i.SetBboxChanged(),this.Trigger(SM.Behaviors.Bullet.Cnds.OnStep)}PostTick(){if(!this._isEnabled||!this._bounceOffSolid||0===this._dx&&0===this._dy)return;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 n=SM.distanceTo(0,0,this._dx,this._dy),r=s.CalculateBounceAngle(this._inst,this._lastX,this._lastY);this._dx=Math.cos(r)*n,this._dy=Math.sin(r)*n,t.OffsetXY(this._dx*e,this._dy*e),t.SetBboxChanged(),this._setAngle&&(t.SetAngle(r),this._lastKnownAngle=t.GetAngle(),t.SetBboxChanged()),s.PushOutSolid(this._inst,this._dx/n,this._dy/n,Math.max(2.5*n*e,30))||s.PushOutSolidNearest(this._inst,100)}}GetPropertyValueByIndex(e){switch(e){case IM:return this._GetSpeed();case TM:return this._GetAcceleration();case CM:return this._GetGravity();case wM:return this._setAngle;case PM:return this._isStepping;case xM:return this._IsEnabled()}}SetPropertyValueByIndex(e,t){switch(e){case IM:this._SetSpeed(t);break;case TM:this._acc=t;break;case CM:this._g=t;break;case wM:this._setAngle=!!t;break;case PM:this._isStepping=!!t;break;case xM:this._SetEnabled(!!t)}}_SetSpeed(e){const t=SM.angleTo(0,0,this._dx,this._dy);this._dx=Math.cos(t)*e,this._dy=Math.sin(t)*e}_GetSpeed(){return SM.roundToDp(SM.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=SM.distanceTo(0,0,this._dx,this._dy);this._dx=Math.cos(e)*t,this._dy=Math.sin(e)*t}_GetAngleOfMotion(){return SM.angleTo(0,0,this._dx,this._dy)}_SetBounceOffSolids(e){e=!!e,this._bounceOffSolid!==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:SM.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}};const vM=new WeakMap;self.IBulletBehaviorInstance=class extends yM{constructor(){super(),vM.set(this,yM._GetInitInst().GetSdkInstance())}get speed(){return vM.get(this)._GetSpeed()}set speed(e){GM.RequireFiniteNumber(e),vM.get(this)._SetSpeed(e)}get acceleration(){return vM.get(this)._GetAcceleration()}set acceleration(e){GM.RequireFiniteNumber(e),vM.get(this)._SetAcceleration(e)}get gravity(){return vM.get(this)._GetGravity()}set gravity(e){GM.RequireFiniteNumber(e),vM.get(this)._SetGravity(e)}get angleOfMotion(){return vM.get(this)._GetAngleOfMotion()}set angleOfMotion(e){GM.RequireFiniteNumber(e),vM.get(this)._SetAngleOfMotion(e)}get bounceOffSolids(){return vM.get(this)._IsBounceOffSolids()}set bounceOffSolids(e){vM.get(this)._SetBounceOffSolids(!!e)}get distanceTravelled(){return vM.get(this)._GetDistanceTravelled()}set distanceTravelled(e){GM.RequireFiniteNumber(e),vM.get(this)._SetDistanceTravelled(e)}get isEnabled(){return vM.get(this)._IsEnabled()}set isEnabled(e){vM.get(this)._SetEnabled(e)}}}{const AM=self.C3;AM.Behaviors.Bullet.Cnds={CompareSpeed(e,t){const s=Math.hypot(this._dx,this._dy);return AM.compare(s,e,t)},CompareTravelled(e,t){return AM.compare(this._GetDistanceTravelled(),e,t)},OnStep:()=>!0,IsEnabled(){return this._IsEnabled()}}}{const RM=self.C3;RM.Behaviors.Bullet.Acts={SetSpeed(e){this._SetSpeed(e)},SetAcceleration(e){this._SetAcceleration(e)},SetGravity(e){this._SetGravity(e)},SetAngleOfMotion(e){this._SetAngleOfMotion(RM.toRadians(e))},Bounce(e){if(!e)return;const t=e.GetFirstPicked(this._inst);if(!t)return;const s=this._inst.GetWorldInfo(),i=this._runtime.GetCollisionEngine(),n=this._runtime.GetDt(this._inst),r=RM.distanceTo(0,0,this._dx,this._dy),a=i.CalculateBounceAngle(this._inst,this._lastX,this._lastY,t);this._dx=Math.cos(a)*r,this._dy=Math.sin(a)*r,s.OffsetXY(this._dx*n,this._dy*n),s.SetBboxChanged(),this._setAngle&&(s.SetAngle(a),this._lastKnownAngle=s.GetAngle(),s.SetBboxChanged()),0!==r&&(this._bounceOffSolid?i.PushOutSolid(this._inst,this._dx/r,this._dy/r,Math.max(2.5*r*n,30))||i.PushOutSolidNearest(this._inst,100):i.PushOut(this._inst,this._dx/r,this._dy/r,Math.max(2.5*r*n,30),t))},SetBounceOffSolids(e){this._SetBounceOffSolids(e)},SetDistanceTravelled(e){this._SetDistanceTravelled(e)},SetEnabled(e){this._SetEnabled(e)},StopStepping(){this._stopStepping=!0}}}{const MM=self.C3;MM.Behaviors.Bullet.Exps={Speed(){return this._GetSpeed()},Acceleration(){return this._GetAcceleration()},AngleOfMotion(){return MM.toDegrees(this._GetAngleOfMotion())},DistanceTravelled(){return this._GetDistanceTravelled()},Gravity(){return this._GetGravity()}}}{const DM=self.C3;DM.Behaviors.Pin=class extends DM.SDKBehaviorBase{constructor(e){super(e)}Release(){super.Release()}}}{const EM=self.C3;EM.Behaviors.Pin.Type=class extends EM.SDKBehaviorTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const FM=self.C3;FM.Behaviors.Pin.Instance=class extends FM.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 FM.CompositeDisposable(FM.Disposable.From(s,"instancedestroy",e=>this._OnInstanceDestroyed(e.instance)),FM.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)return;const i=e.GetFirstPicked(this._inst);if(!i)return;this._mode=t,this._SetPinInst(i);const n=this._inst.GetWorldInfo(),r=i.GetWorldInfo();if("properties"===this._mode){const e=this._propSet;e.clear();for(const t of s)e.add(t);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(),e.has("x")&&e.has("y")&&(this._pinAngle=FM.angleTo(r.GetX(),r.GetY(),n.GetX(),n.GetY())-r.GetAngle(),this._pinDist=FM.distanceTo(r.GetX(),r.GetY(),n.GetX(),n.GetY())),e.has("width-abs")?this._dWidth=n.GetWidth()-r.GetWidth():e.has("width-scale")&&(this._dWidth=n.GetWidth()/r.GetWidth()),e.has("height-abs")?this._dHeight=n.GetHeight()-r.GetHeight():e.has("height-scale")&&(this._dHeight=n.GetHeight()/r.GetHeight())}else this._pinDist=FM.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){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 t of e.ps)s.add(t);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)}}else this._LoadFromJson_Legacy(e)}_LoadFromJson_Legacy(e){const t=this._propSet,s=e.msa,i=e.tsa,n=e.pa,r=e.pd;switch(e.m){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 e=this._pinInst;if(!e||e.IsDestroyed())return;const t=e.GetWorldInfo(),s=this._inst.GetWorldInfo(),i=this._mode;let n=!1;if("rope"===i||"bar"===i){const e=FM.distanceTo(s.GetX(),s.GetY(),t.GetX(),t.GetY());if(e>this._pinDist||"bar"===i&&ethis._SetSpeed(LM.toRadians(e))},{name:e+".properties.acceleration.name",value:LM.toDegrees(this._GetAcceleration()),onedit:e=>this._SetAcceleration(LM.toRadians(e))},{name:e+".properties.enabled.name",value:this._IsEnabled(),onedit:e=>this._SetEnabled(e)}]}]}GetScriptInterfaceClass(){return self.IRotateBehaviorInstance}};const jM=new WeakMap;self.IRotateBehaviorInstance=class extends NM{constructor(){super(),jM.set(this,NM._GetInitInst().GetSdkInstance())}set speed(e){kM.RequireFiniteNumber(e),jM.get(this)._SetSpeed(e)}get speed(){return jM.get(this)._GetSpeed()}set acceleration(e){kM.RequireFiniteNumber(e),jM.get(this)._SetAcceleration(e)}get acceleration(){return jM.get(this)._GetAcceleration()}get isEnabled(){return jM.get(this)._IsEnabled()}set isEnabled(e){jM.get(this)._SetEnabled(e)}}}self.C3.Behaviors.Rotate.Cnds={IsEnabled(){return this._IsEnabled()}};{const HM=self.C3;HM.Behaviors.Rotate.Acts={SetSpeed(e){this._SetSpeed(HM.toRadians(e))},SetAcceleration(e){this._SetAcceleration(HM.toRadians(e))},SetEnabled(e){this._SetEnabled(e)}}}{const zM=self.C3;zM.Behaviors.Rotate.Exps={Speed(){return zM.toDegrees(this._GetSpeed())},Acceleration(){return zM.toDegrees(this._GetAcceleration())}}}{const XM=self.C3;XM.Behaviors.Sin=class extends XM.SDKBehaviorBase{constructor(e){super(e)}Release(){super.Release()}}}{const YM=self.C3;YM.Behaviors.Sin.Type=class extends YM.SDKBehaviorTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const qM=self.C3,KM=self.C3X,$M=self.IBehaviorInstance,JM=0,ZM=1,QM=2,eD=3,tD=4,sD=5,iD=6,nD=7,rD=8,aD=0,oD=1,hD=2,lD=3,cD=4,uD=5,dD=6,_D=7,pD=8,gD=9,mD=0,fD=1,SD=2,GD=3,yD=4,ID=2*Math.PI,TD=Math.PI/2,CD=3*Math.PI/2,bD=[0,1,8,3,4,2,5,6,9,7];qM.Behaviors.Sin.Instance=class extends qM.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=bD[t[JM]],this._wave=t[ZM],this._periodRandom=this._runtime.Random()*t[eD],this._basePeriod=t[QM],this._period=t[QM],this._period+=this._periodRandom,this._basePeriodOffset=t[tD],0!==this._period&&(this._periodOffsetRandom=this._runtime.Random()*t[sD],this._i=t[tD]/this._period*ID,this._i+=this._periodOffsetRandom/this._period*ID),this._magnitudeRandom=this._runtime.Random()*t[nD],this._baseMag=t[iD],this._mag=t[iD],this._mag+=this._magnitudeRandom,this._isEnabled=!!t[rD]),this._movement===uD&&(this._mag=qM.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 aD:this._initialValue=e.GetX();break;case oD:this._initialValue=e.GetY();break;case hD:this._initialValue=e.GetWidth(),this._ratio=e.GetHeight()/e.GetWidth();break;case lD:this._initialValue=e.GetWidth();break;case cD:this._initialValue=e.GetHeight();break;case uD:this._initialValue=e.GetAngle();break;case dD:this._initialValue=e.GetOpacity();break;case _D:this._initialValue=0;break;case pD:this._initialValue=e.GetX(),this._initialValue2=e.GetY();break;case gD:this._initialValue=e.GetZElevation()}this._lastKnownValue=this._initialValue,this._lastKnownValue2=this._initialValue2}WaveFunc(e){switch(e%=ID,this._wave){case mD:return Math.sin(e);case fD:return e<=TD?e/TD:e<=CD?1-2*(e-TD)/Math.PI:(e-CD)/TD-1;case SD:return 2*e/ID-1;case GD:return-2*e/ID+1;case yD:return ethis._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}};const wD=new WeakMap,PD=["horizontal","vertical","size","width","height","angle","opacity","value-only","forwards-backwards","z-elevation"],xD=["sine","triangle","sawtooth","reverse-sawtooth","square"];self.ISineBehaviorInstance=class extends $M{constructor(){super(),wD.set(this,$M._GetInitInst().GetSdkInstance())}set period(e){KM.RequireFiniteNumber(e),wD.get(this)._SetPeriod(e)}get period(){return wD.get(this)._GetPeriod()}set magnitude(e){KM.RequireFiniteNumber(e),wD.get(this)._SetMagnitude(e)}get magnitude(){return wD.get(this)._GetMagnitude()}set phase(e){wD.get(this)._SetPhase(e)}get phase(){return wD.get(this)._GetPhase()}set movement(e){KM.RequireString(e);const t=PD.indexOf(e);if(-1===t)throw new Error("invalid movement");wD.get(this)._SetMovement(t)}get movement(){return PD[wD.get(this)._GetMovement()]}set wave(e){KM.RequireString(e);const t=xD.indexOf(e);if(-1===t)throw new Error("invalid wave");wD.get(this)._SetWave(t)}get wave(){return xD[wD.get(this)._GetWave()]}get value(){const e=wD.get(this);return e.WaveFunc(e._GetPhase())*e._GetMagnitude()}updateInitialState(){wD.get(this).Init()}set isEnabled(e){wD.get(this)._SetEnabled(!!e)}get isEnabled(){return wD.get(this)._IsEnabled()}}}{const vD=self.C3;vD.Behaviors.Sin.Cnds={IsEnabled(){return this._IsEnabled()},CompareMovement(e){return this._GetMovement()===e},ComparePeriod(e,t){return vD.compare(this._GetPeriod(),e,t)},CompareMagnitude(e,t){return vD.compare(this._GetMagnitude_ConvertAngle(),e,t)},CompareWave(e){return this._GetWave()===e}}}self.C3.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()}},self.C3.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 AD=self.C3;AD.Behaviors.Timer=class extends AD.SDKBehaviorBase{constructor(e){super(e)}Release(){super.Release()}}}{const RD=self.C3;RD.Behaviors.Timer.Type=class extends RD.SDKBehaviorTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const MD=self.C3,DD=self.C3X,ED=self.IBehaviorInstance;MD.Behaviors.Timer.SingleTimer=class{constructor(e,t,s,i){this._current=MD.New(MD.KahanSum),this._current.Set(e||0),this._total=MD.New(MD.KahanSum),this._total.Set(t||0),this._duration=s||0,this._isRegular=!!i,this._isPaused=!1}GetCurrentTime(){return this._current.Get()}GetTotalTime(){return this._total.Get()}GetDuration(){return this._duration}SetPaused(e){this._isPaused=!!e}IsPaused(){return this._isPaused}Add(e){this._current.Add(e),this._total.Add(e)}HasFinished(){return this._current.Get()>=this._duration}Update(){if(this.HasFinished()){if(!this._isRegular)return!0;this._current.Subtract(this._duration)}return!1}SaveToJson(){return{c:this._current.Get(),t:this._total.Get(),d:this._duration,r:this._isRegular,p:this._isPaused}}LoadFromJson(e){this._current.Set(e.c),this._total.Set(e.t),this._duration=e.d,this._isRegular=!!e.r,this._isPaused=!!e.p}},MD.Behaviors.Timer.Instance=class extends MD.SDKBehaviorInstanceBase{constructor(e,t){super(e),this._timers=new Map}Release(){this._timers.clear(),super.Release()}_StartTimer(e,t,s){const i=new MD.Behaviors.Timer.SingleTimer(0,0,e,s);this._timers.set(t.toLowerCase(),i),this._UpdateTickState()}_StopTimer(e){this._timers.delete(e.toLowerCase()),this._UpdateTickState()}_StopAllTimers(){this._timers.clear(),this._UpdateTickState()}_IsTimerRunning(e){return this._timers.has(e.toLowerCase())}_GetTimerCurrentTime(e){const t=this._timers.get(e.toLowerCase());return t?t.GetCurrentTime():0}_GetTimerNormalizedProgress(e){const t=this._timers.get(e.toLowerCase());return t?t.GetCurrentTime()/t.GetDuration():0}_GetTimerTotalTime(e){const t=this._timers.get(e.toLowerCase());return t?t.GetTotalTime():0}_GetTimerDuration(e){const t=this._timers.get(e.toLowerCase());return t?t.GetDuration():0}_HasTimerFinished(e){const t=this._timers.get(e.toLowerCase());return!!t&&t.HasFinished()}_SetTimerPaused(e,t){const s=this._timers.get(e.toLowerCase());s&&s.SetPaused(t)}_IsTimerPaused(e){const t=this._timers.get(e.toLowerCase());return!!t&&t.IsPaused()}_SetAllTimersPaused(e){for(const t of this._timers.values())t.SetPaused(e)}_UpdateTickState(){this._timers.size>0?(this._StartTicking(),this._StartTicking2()):(this._StopTicking(),this._StopTicking2())}SaveToJson(){const e={};for(const[t,s]of this._timers.entries())e[t]=s.SaveToJson();return e}LoadFromJson(e){this._timers.clear();for(const[t,s]of Object.entries(e)){const e=new MD.Behaviors.Timer.SingleTimer;e.LoadFromJson(s),this._timers.set(t,e)}this._UpdateTickState()}Tick(){const e=this._runtime.GetDt(this._inst);for(const[t,s]of this._timers)s.IsPaused()||(s.Add(e),s.HasFinished()&&this.DispatchScriptEvent("timer",!1,{tag:t}))}Tick2(){for(const[e,t]of this._timers.entries())t.Update()&&this._timers.delete(e)}GetDebuggerProperties(){return[{title:"behaviors.timer.debugger.timers",properties:[...this._timers.entries()].map(e=>({name:"$"+e[0],value:`${Math.round(10*e[1].GetCurrentTime())/10} / ${Math.round(10*e[1].GetDuration())/10}`}))}]}GetScriptInterfaceClass(){return self.ITimerBehaviorInstance}};const FD=["once","regular"];self.ITimerBehaviorInstance=class extends ED{#e;constructor(){super(),this.#e=ED._GetInitInst().GetSdkInstance()}startTimer(e,t,s="once"){DD.RequireFiniteNumber(e),DD.RequireString(t);const i=FD.indexOf(s);if(-1===i)throw new Error("invalid type");this.#e._StartTimer(e,t,1===i)}setTimerPaused(e,t){DD.RequireString(e),this.#e._SetTimerPaused(e,!!t)}setAllTimersPaused(e){this.#e._SetAllTimersPaused(!!e)}stopTimer(e){DD.RequireString(e),this.#e._StopTimer(e)}stopAllTimers(){this.#e._StopAllTimers()}isTimerRunning(e){return DD.RequireString(e),this.#e._IsTimerRunning(e)}isTimerPaused(e){return DD.RequireString(e),this.#e._IsTimerPaused(e)}getCurrentTime(e){return DD.RequireString(e),this.#e._GetTimerCurrentTime(e)}getNormalizedProgress(e){return DD.RequireString(e),this.#e._GetTimerNormalizedProgress(e)}getTotalTime(e){return DD.RequireString(e),this.#e._GetTimerTotalTime(e)}getDuration(e){return DD.RequireString(e),this.#e._GetTimerDuration(e)}hasFinished(e){return DD.RequireString(e),this.#e._HasTimerFinished(e)}}}self.C3.Behaviors.Timer.Cnds={OnTimer(e){return this._HasTimerFinished(e)},IsTimerRunning(e){return this._IsTimerRunning(e)},IsTimerPaused(e){return this._IsTimerPaused(e)}},self.C3.Behaviors.Timer.Acts={StartTimer(e,t,s){this._StartTimer(e,s,1===t)},StopTimer(e){this._StopTimer(e)},StopAllTimers(){this._StopAllTimers()},PauseResumeTimer(e,t){this._SetTimerPaused(e,0===t)},PauseResumeAllTimers(e){this._SetAllTimersPaused(0===e)}},self.C3.Behaviors.Timer.Exps={CurrentTime(e){return this._GetTimerCurrentTime(e)},NormalizedProgress(e){return this._GetTimerNormalizedProgress(e)},TotalTime(e){return this._GetTimerTotalTime(e)},Duration(e){return this._GetTimerDuration(e)}};{let OD=function(e){return"number"==typeof e?-e:e},BD=function(e,t){return"number"==typeof e&&"number"==typeof t},LD=function(e,t){return BD(e,t)?e+t:e},kD=function(e,t){return BD(e,t)?e-t:e},ND=function(e,t){return BD(e,t)?e*t:e},WD=function(e,t){return BD(e,t)?e/t:e},VD=function(e,t){return BD(e,t)?e%t:e},UD=function(e,t){return BD(e,t)?Math.pow(e,t):e},jD=function(e,t){if("string"==typeof e||"string"==typeof t){let s,i;return s="number"==typeof e?(Math.round(1e10*e)/1e10).toString():e,i="number"==typeof t?(Math.round(1e10*t)/1e10).toString():t,s+i}return e&&t?1:0},HD=function(e,t){return BD(e,t)?e||t?1:0:e};unaryminus=OD,bothNumbers=BD,add=LD,subtract=kD,multiply=ND,divide=WD,mod=VD,pow=UD,and=jD,or=HD;const zD=self.C3;self.C3_ExpressionFuncs=[()=>"[Serialized Fields]",()=>3,()=>15,()=>.3,()=>.2,()=>5e3,()=>"0,30",()=>5,()=>.5,()=>50,()=>7,()=>40,()=>1,()=>0,()=>120,()=>1.5,()=>2,()=>9,()=>500,()=>700,()=>1e3,()=>33,()=>10,()=>129,()=>513,e=>{const t=e._GetNode(0).GetVar();return()=>t.GetValue()},()=>100,()=>200,()=>300,()=>4,()=>400,()=>6,()=>600,e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetVar(),i=e._GetNode(2).GetVar(),n=e._GetNode(3).GetVar();return()=>t(Math.pow(s.GetValue(),i.GetValue()-1)*n.GetValue())},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(0,1,2,3,4,5)},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(0,1,2,3,4,4,4,5,5,5)},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(0,1,1,2,2,3,3,4,4,5,5,6)},()=>8,e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,7,8,9)},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(0,1,2)},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(0,1,2,2)},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(0,1,2,3,3,3)},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(0,1,2,3,3,3,3)},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(0,1,2,4,4,5,5,5)},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(0,1,2,3,4,4,4,5,5)},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(0,1,2,3,3,4,4,4,5,5)},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(1,2,3,4,4,4,5,5,5)},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(1,2,2,3,3,4,4,4,5,5,5,6,6,7)},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(1,2,2,3,3,4,4,4,5,5,6,6,7)},()=>11,e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(1,2,3,3,4,4,4,5,5,5,6,6,7)},()=>12,e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(1,2,3,3,4,4,5,5,6,6,6,7,7,8)},()=>13,()=>14,()=>16,()=>17,()=>18,()=>19,()=>20,()=>21,()=>22,e=>{const t=e._GetNode(0).GetVar();return()=>jD("coin:",200*t.GetValue())+"|bomb:1|"},e=>{const t=e._GetNode(0).GetVar();return()=>jD("coin:",200*t.GetValue())+"|blade:1|"},e=>{const t=e._GetNode(0).GetVar();return()=>jD("coin:",200*t.GetValue())+"|blade:1|space1:1|"},e=>{const t=e._GetNode(0).GetVar();return()=>jD("coin:",200*t.GetValue())+"|lightning:1|"},e=>{const t=e._GetNode(0).GetVar();return()=>jD("coin:",200*t.GetValue())+"|space2:1|"},e=>{const t=e._GetNode(0).GetVar();return()=>jD("coin:",200*t.GetValue())+"|space3:1|blade:1|"},e=>{const t=e._GetNode(0).GetVar();return()=>jD("coin:",200*t.GetValue())+"|lightning:1|space2:1|"},e=>{const t=e._GetNode(0).GetVar();return()=>jD("coin:",200*t.GetValue())+"|bomb:1|blade:1|"},e=>{const t=e._GetNode(0).GetVar();return()=>jD("coin:",200*t.GetValue())+"|bomb:1|lightning:2|"},e=>{const t=e._GetNode(0).GetVar();return()=>jD("coin:",200*t.GetValue())+"|blade:1|space3:1|"},e=>{const t=e._GetNode(0).GetVar(),s=e._GetNode(1).GetBoundMethod(),i=e._GetNode(2).GetBoundMethod();return()=>jD(jD("coin:",200*t.GetValue())+"|",s(i(1,2)))},()=>"Get Random Items",()=>"",e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetBoundMethod(),i=e._GetNode(2).GetBoundMethod(),n=e._GetNode(3).GetVar();return()=>t(s(0,i(n.GetValue(),"|")-1))},e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetVar(),i=e._GetNode(2).GetVar();return()=>t(s.GetValue(),i.GetValue(),"|")+"|"},e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetVar(),i=e._GetNode(2).GetBoundMethod(),n=e._GetNode(3).GetVar(),r=e._GetNode(4).GetVar();return()=>t(s.GetValue(),i(n.GetValue(),r.GetValue(),"|")+"|","")},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t()},()=>"Start",e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetVar();return()=>t(s.GetValue())},()=>.1,()=>"Transition",e=>{const t=e._GetNode(0).GetVar(),s=e._GetNode(1).GetVar(),i=e._GetNode(2).GetVar();return()=>t.GetValue()-(s.GetValue()-1)*i.GetValue()},()=>"BestScore",e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetBoundMethod();return()=>t(s("BestScore"))},e=>{const t=e._GetNode(0).GetVar();return()=>jD("Best Score: ",t.GetValue())},()=>"Spots",e=>{const t=e._GetNode(0);return()=>t.ExpObject()},()=>"Game",e=>{const t=e._GetNode(0),s=e._GetNode(1).GetVar();return()=>t.ExpInstVar()+s.GetValue()},e=>{const t=e._GetNode(0);return()=>t.ExpInstVar()},e=>{const t=e._GetNode(0),s=e._GetNode(1).GetVar();return()=>t.ExpInstVar()-s.GetValue()},e=>{const t=e._GetNode(0),s=e._GetNode(1).GetVar();return()=>t.ExpInstVar()+s.GetValue()/2},e=>{const t=e._GetNode(0),s=e._GetNode(1).GetVar();return()=>t.ExpInstVar()-s.GetValue()/2},e=>{const t=e._GetNode(0).GetVar();return()=>t.GetValue()-1},e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1);return()=>t()-s.ExpObject()/2},e=>{const t=e._GetNode(0);return()=>0+t.ExpObject()/2},e=>{const t=e._GetNode(0);return()=>t.ExpObject()/2},e=>{const t=e._GetNode(0);return()=>t.ExpObject()+10},e=>{const t=e._GetNode(0);return()=>t.ExpInstVar_Family()},()=>"Walls",e=>{const t=e._GetNode(0);return()=>t.ExpObject()-30},()=>60,e=>{const t=e._GetNode(0);return()=>t.ExpObject()+30},()=>"Circle",e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetVar(),i=e._GetNode(2);return()=>t(s.GetValue(),jD(",",i.ExpObject())+",")},()=>-1,e=>{const t=e._GetNode(0);return()=>jD(t.ExpObject(),",")},e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1),i=e._GetNode(2),n=e._GetNode(3).GetBoundMethod();return()=>t(zD.distanceTo(s.ExpObject(),i.ExpObject(),n()/2-35,-500))},()=>"rows",e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t("rows")%2},()=>94.5,()=>175.5,e=>{const t=e._GetNode(0).GetVar(),s=e._GetNode(1).GetBoundMethod();return()=>t.GetValue()+162*s()},e=>{const t=e._GetNode(0).GetVar(),s=e._GetNode(1).GetBoundMethod();return()=>t.GetValue()+140*s("rows")},()=>"Shootable Circle",e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t()/2+130},e=>{const t=e._GetNode(0);return()=>t.ExpObject()+70},()=>80,e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t()/2},()=>160,()=>"HUD",()=>"Swapping",()=>"LevelUp",()=>"Aiming",()=>155,e=>{const t=e._GetNode(0).GetVar();return()=>360-t.GetValue()},()=>90,e=>{const t=e._GetNode(0).GetVar();return()=>180+t.GetValue()},e=>{const t=e._GetNode(0);return()=>t.ExpObject()-10},e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1);return()=>t()/2+20*Math.cos(zD.toRadians(s.ExpObject()-180))},e=>{const t=e._GetNode(0),s=e._GetNode(1);return()=>t.ExpObject()+20*Math.sin(zD.toRadians(s.ExpObject()-180))},e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1),i=e._GetNode(2),n=e._GetNode(3).GetVar(),r=e._GetNode(4).GetVar();return()=>t(zD.toDegrees(zD.angleTo(s.ExpObject(),i.ExpObject(),n.GetValue(),r.GetValue())))},e=>{const t=e._GetNode(0),s=e._GetNode(1),i=e._GetNode(2),n=e._GetNode(3);return()=>zD.distanceTo(t.ExpObject(),s.ExpObject(),i.ExpObject(),n.ExpObject())-160},()=>140,e=>{const t=e._GetNode(0);return()=>t.ExpObject()+8},()=>650,e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetBoundMethod(),i=e._GetNode(2).GetBoundMethod();return()=>t(s(0),i(0))},e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetVar();return()=>t(s.GetValue(),"|")},e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1),i=e._GetNode(2).GetBoundMethod(),n=e._GetNode(3);return()=>jD(jD(t(s.ExpObject()),","),i(n.ExpObject()))+"|"},e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1),i=e._GetNode(2).GetBoundMethod(),n=e._GetNode(3);return()=>jD(jD(t(s.ExpObject(1)),","),i(n.ExpObject(1)))+"|"},e=>{const t=e._GetNode(0);return()=>t.ExpInstVar()+1},e=>{const t=e._GetNode(0);return()=>t.ExpObject(1)},e=>{const t=e._GetNode(0);return()=>-t.ExpObject()-180},e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetVar(),i=e._GetNode(2).GetBoundMethod(),n=e._GetNode(3),r=e._GetNode(4).GetBoundMethod(),a=e._GetNode(5);return()=>t(s.GetValue(),jD(jD(i(n.ExpObject()),","),r(a.ExpObject()))+"|")},e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetBoundMethod(),i=e._GetNode(2).GetVar();return()=>t(s(i.GetValue(),0,","))},()=>"Default",e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetBoundMethod(),i=e._GetNode(2).GetVar();return()=>t(s(i.GetValue(),1,","))},()=>"Item",()=>"Trajectory",e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetBoundMethod(),i=e._GetNode(2),n=e._GetNode(3),r=e._GetNode(4).GetBoundMethod(),a=e._GetNode(5).GetBoundMethod(),o=e._GetNode(6).GetBoundMethod(),h=e._GetNode(7).GetVar(),l=e._GetNode(8),c=e._GetNode(9).GetBoundMethod(),u=e._GetNode(10).GetBoundMethod(),d=e._GetNode(11).GetBoundMethod(),_=e._GetNode(12).GetVar(),p=e._GetNode(13),g=e._GetNode(14),m=e._GetNode(15),f=e._GetNode(16);return()=>t(s(zD.distanceTo(i.ExpObject(),n.ExpObject(),r(a(o(h.GetValue(),l.ExpInstVar()-1,"|"),0,",")),c(u(d(_.GetValue(),p.ExpInstVar()-1,"|"),1,","))),g.ExpObject())/m.ExpObject())*f.ExpObject()-2},e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1);return()=>t(s.ExpObject())},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(255,0,245,255)},()=>"Shoot",()=>"first_bubble_shot",()=>159,e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetVar();return()=>t(s.GetValue(),"0,0|")},e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetBoundMethod(),i=e._GetNode(2).GetBoundMethod(),n=e._GetNode(3).GetVar(),r=e._GetNode(4);return()=>t(s(i(n.GetValue(),r.ExpInstVar(),"|"),0,","))},e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetBoundMethod(),i=e._GetNode(2).GetBoundMethod(),n=e._GetNode(3).GetVar(),r=e._GetNode(4);return()=>t(s(i(n.GetValue(),r.ExpInstVar(),"|"),1,","))},()=>"blade",()=>"Animation 2",()=>"hit",()=>2.5,()=>"explosion",()=>"Move a Bit",e=>{const t=e._GetNode(0),s=e._GetNode(1),i=e._GetNode(2),n=e._GetNode(3);return()=>zD.distanceTo(t.ExpObject(),s.ExpObject(),i.ExpObject(),n.ExpObject())},e=>{const t=e._GetNode(0);return()=>1.5*t.ExpObject()},e=>{const t=e._GetNode(0),s=e._GetNode(1),i=e._GetNode(2),n=e._GetNode(3);return()=>20-zD.distanceTo(t.ExpObject(),s.ExpObject(),i.ExpObject(),n.ExpObject())/25},()=>"pos2",e=>{const t=e._GetNode(0),s=e._GetNode(1),i=e._GetNode(2),n=e._GetNode(3),r=e._GetNode(4),a=e._GetNode(5).GetVar();return()=>t.ExpObject()+Math.cos(zD.toRadians(zD.toDegrees(zD.angleTo(s.ExpObject(),i.ExpObject(),n.ExpInstVar_Family(),r.ExpInstVar_Family()))))*a.GetValue()},e=>{const t=e._GetNode(0),s=e._GetNode(1),i=e._GetNode(2),n=e._GetNode(3),r=e._GetNode(4),a=e._GetNode(5).GetVar();return()=>t.ExpObject()+Math.sin(zD.toRadians(zD.toDegrees(zD.angleTo(s.ExpObject(),i.ExpObject(),n.ExpInstVar_Family(),r.ExpInstVar_Family()))))*a.GetValue()},()=>.04,()=>"Merge",e=>{const t=e._GetNode(0);return()=>t.ExpObject()+5},()=>.01,()=>",",e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetVar();return()=>t(s.GetValue(),",")-2},e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetBoundMethod(),i=e._GetNode(2).GetVar(),n=e._GetNode(3).GetBoundMethod();return()=>t(s(i.GetValue(),n(),","))},()=>"pos",e=>{const t=e._GetNode(0);return()=>Math.pow(2,t.ExpObject()+1)},e=>{const t=e._GetNode(0);return()=>t.ExpObject()+1},e=>{const t=e._GetNode(0).GetVar();return()=>t.GetValue()+.01},()=>"Bg",e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(0)},()=>"After Merge",e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetBoundMethod(),i=e._GetNode(2).GetVar();return()=>t(WD(s(),i.GetValue()))},()=>"Connections",e=>{const t=e._GetNode(0).GetVar();return()=>t.GetValue()-140},e=>{const t=e._GetNode(0).GetVar();return()=>t.GetValue()+5},e=>{const t=e._GetNode(0).GetVar();return()=>t.GetValue()-5},e=>{const t=e._GetNode(0),s=e._GetNode(1),i=e._GetNode(2),n=e._GetNode(3);return()=>zD.distanceTo(t.ExpInstVar_Family(),s.ExpInstVar_Family(),i.ExpInstVar(),n.ExpInstVar())},()=>170,e=>{const t=e._GetNode(0),s=e._GetNode(1),i=e._GetNode(2),n=e._GetNode(3);return()=>zD.distanceTo(t.ExpObject(),s.ExpObject(),i.ExpInstVar(),n.ExpInstVar())},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>(t()-2)/100},()=>"Circle2",e=>{const t=e._GetNode(0);return()=>t.ExpObject()-100},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>270+t(-5,5)},()=>"New Circles",()=>"goingSmall",()=>26,()=>"true",e=>{const t=e._GetNode(0);return()=>t.ExpBehavior("goingSmall")},()=>.9,()=>"goingBig",()=>940,e=>{const t=e._GetNode(0).GetBoundMethod();return()=>175.5+162*t()},e=>{const t=e._GetNode(0);return()=>t.ExpObject()+140},e=>{const t=e._GetNode(0);return()=>t.ExpInstVar()+140},e=>{const t=e._GetNode(0);return()=>t.ExpObject()+81},e=>{const t=e._GetNode(0);return()=>t.ExpInstVar_Family()+140},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>94.5+162*t()},e=>{const t=e._GetNode(0);return()=>t.ExpObject()-81},()=>"Texts",e=>{const t=e._GetNode(0).GetVar();return()=>jD(t.GetValue()," $")},e=>{const t=e._GetNode(0).GetVar();return()=>jD("Level ",t.GetValue())},()=>"Gift Bar",()=>"Lv.1",e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetVar(),i=e._GetNode(2).GetBoundMethod();return()=>t(293,ND(ND(s.GetValue(),WD(100,i())),2.93))},()=>292,()=>"Coins",()=>"coin",e=>{const t=e._GetNode(0).GetVar(),s=e._GetNode(1).GetVar();return()=>t.GetValue()-s.GetValue()},()=>"playing",()=>"default",e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetVar(),i=e._GetNode(2).GetVar();return()=>t(s.GetValue(),i.GetValue())},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t()/50},e=>{const t=e._GetNode(0);return()=>t.ExpObject()/1.5},e=>{const t=e._GetNode(0),s=e._GetNode(1).GetBoundMethod(),i=e._GetNode(2).GetBoundMethod();return()=>t.ExpObject()+Math.cos(zD.toRadians(s(360)))*i(50,80)},e=>{const t=e._GetNode(0),s=e._GetNode(1).GetBoundMethod(),i=e._GetNode(2).GetBoundMethod();return()=>t.ExpObject()+Math.sin(zD.toRadians(s(360)))*i(50,80)},e=>{const t=e._GetNode(0);return()=>t.ExpBehavior("pos")},()=>.6,()=>"opacity",()=>"Items",()=>"Use Items",()=>"bomb",()=>"lightning",()=>"Lock /Unlock",e=>{const t=e._GetNode(0);return()=>t.ExpObject()+50},e=>{const t=e._GetNode(0);return()=>jD("Lv. ",t.ExpInstVar_Family())},()=>"Items Texts",e=>{const t=e._GetNode(0),s=e._GetNode(1);return()=>jD(jD(t.ExpInstVar(),"/"),s.ExpInstVar())},()=>"Bomb",()=>"Animation 1",e=>{const t=e._GetNode(0);return()=>t.ExpObject()+160},e=>{const t=e._GetNode(0);return()=>t.ExpObject()+0},e=>{const t=e._GetNode(0);return()=>t.ExpObject()-160},e=>{const t=e._GetNode(0);return()=>t.ExpObject()-80},e=>{const t=e._GetNode(0);return()=>t.ExpObject()+80},e=>{const t=e._GetNode(0);return()=>t.ExpObject()-140},()=>"Blade",()=>30,()=>"Lightning",e=>{const t=e._GetNode(0);return()=>t.ExpObject()-5},()=>185.5,()=>894.5,()=>"Item Coins",e=>{const t=e._GetNode(0).GetVar(),s=e._GetNode(1).GetVar();return()=>(t.GetValue()+s.GetValue())/2},()=>.4,()=>"Stroke",()=>"Buying Items",()=>"BuyItem",e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1);return()=>t(0)-s.ExpObject()-10},()=>70,e=>{const t=e._GetNode(0);return()=>jD(t.ExpInstVar(),"$")},e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1),i=e._GetNode(2).GetVar();return()=>t(s.ExpInstVar()*i.GetValue())},()=>"Level Up",()=>807,()=>42,()=>102,e=>{const t=e._GetNode(0);return()=>t.ExpObject()/100},e=>{const t=e._GetNode(0);return()=>t.ExpObject()/100/5},()=>"Black",()=>"level-up",()=>750,e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t()-400},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t()/2-200},e=>{const t=e._GetNode(0);return()=>3*t.ExpObject()},()=>.8,e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t()/2+370},e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetVar();return()=>t(s.GetValue(),"|")-2},e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetBoundMethod();return()=>t()/2+220*s()},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t()/2+200},e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetBoundMethod(),i=e._GetNode(2).GetBoundMethod(),n=e._GetNode(3).GetVar(),r=e._GetNode(4).GetBoundMethod();return()=>t(s(i(n.GetValue(),r(),"|"),0,":"))},e=>{const t=e._GetNode(0);return()=>t.ExpObject()+-5},e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetBoundMethod(),i=e._GetNode(2).GetVar(),n=e._GetNode(3).GetBoundMethod();return()=>"x"+t(s(i.GetValue(),n(),"|"),1,":")},e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetBoundMethod(),i=e._GetNode(2).GetBoundMethod(),n=e._GetNode(3).GetBoundMethod(),r=e._GetNode(4).GetVar(),a=e._GetNode(5).GetBoundMethod();return()=>t(s(i(n(r.GetValue(),a(),"|"),0,":"),1))},e=>{const t=e._GetNode(0);return()=>t.ExpObject()-50},()=>"coins",()=>"blades",()=>"bombs",()=>"lightnings",()=>"space1",()=>"space2",()=>"space3",()=>"Collecting Gifts",e=>{const t=e._GetNode(0).GetVar();return()=>t.GetValue()/2},e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetVar();return()=>t()/s.GetValue()},e=>{const t=e._GetNode(0);return()=>t.ExpObject()-20},e=>{const t=e._GetNode(0).GetVar();return()=>jD("power_up:Blade: received: level:",t.GetValue())},e=>{const t=e._GetNode(0).GetVar();return()=>jD("power_up:Bomb: received: level:",t.GetValue())},e=>{const t=e._GetNode(0).GetVar();return()=>jD("power_up:Lightning: received: level:",t.GetValue())},e=>{const t=e._GetNode(0);return()=>t.ExpBehavior("")},()=>"collect",()=>"error",e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetBoundMethod(),i=e._GetNode(2),n=e._GetNode(3).GetBoundMethod(),r=e._GetNode(4);return()=>t(s(i.ExpObject(),n(r.ExpObject())-1))},e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1),i=e._GetNode(2).GetBoundMethod(),n=e._GetNode(3).GetBoundMethod(),r=e._GetNode(4),a=e._GetNode(5).GetBoundMethod(),o=e._GetNode(6),h=e._GetNode(7);return()=>t(s.ExpInstVar()+i(n(r.ExpObject(),a(o.ExpObject())-1)),h.ExpInstVar())},e=>{const t=e._GetNode(0).GetVar();return()=>jD("level_:",t.GetValue())+":completed"},e=>{const t=e._GetNode(0).GetVar();return()=>jD("level_:",t.GetValue())+":started"},e=>{const t=e._GetNode(0);return()=>1.3*t.ExpInstVar_Family()},()=>104,()=>"Particles",e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(40,90)},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(10,30)},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(360)},()=>150,()=>"pop",e=>{const t=e._GetNode(0),s=e._GetNode(1).GetVar(),i=e._GetNode(2).GetVar();return()=>t.ExpObject()+Math.cos(zD.toRadians(s.GetValue()))*i.GetValue()},e=>{const t=e._GetNode(0),s=e._GetNode(1).GetVar(),i=e._GetNode(2).GetVar();return()=>t.ExpObject()+Math.sin(zD.toRadians(s.GetValue()))*i.GetValue()},()=>"end",e=>{const t=e._GetNode(0);return()=>t.ExpInstVar()/200},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(80,218,237,255)},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(255,194,26,255)},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(255,71,51,255)},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(255,122,51,255)},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(33,202,44,255)},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(80,85,220,255)},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(196,101,230,255)},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(230,101,221,255)},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(180,231,70,255)},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(47,77,146,255)},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(184,46,46,255)},()=>"Messages",e=>{const t=e._GetNode(0).GetVar();return()=>t.GetValue()-3},()=>"msg",()=>.7,()=>"Pause",()=>"over",()=>"Game Over",e=>{const t=e._GetNode(0);return()=>t.ExpObject()-200},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(.4,.6)},()=>"GameOver",()=>382,()=>1560,()=>695,()=>"game_end",()=>-100,()=>1.55,()=>"ResetGame / GoHome",()=>"In-game Gift",e=>{const t=e._GetNode(0);return()=>t.ExpObject()+200},()=>"0,",()=>"1,",()=>"2,",e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetBoundMethod(),i=e._GetNode(2).GetVar(),n=e._GetNode(3).GetBoundMethod(),r=e._GetNode(4).GetBoundMethod(),a=e._GetNode(5).GetVar();return()=>t(s(i.GetValue(),n(0,r(a.GetValue(),",")-1),","))},()=>110,e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1),i=e._GetNode(2);return()=>t(s.ExpInstVar()+1,i.ExpInstVar())},()=>"Tutorials",e=>{const t=e._GetNode(0);return()=>t.ExpObject()/1.3},e=>{const t=e._GetNode(0).GetVar();return()=>6*t.GetValue()},()=>320,()=>"Battle Game",()=>"activity",()=>"inactivity",e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetBoundMethod(),i=e._GetNode(2).GetVar(),n=e._GetNode(3).GetBoundMethod();return()=>t(s(i.GetValue(),n())/1e3)},()=>"Rewarded AD",()=>252,()=>825,()=>99,()=>"continue",()=>"AD Skipped",()=>"Ad Skipped",()=>"AD Unavailable",()=>"Ad Unavailable",()=>"SDK",()=>"Muted",()=>"Game End",()=>"Game End 1",()=>"Game MUTED FOR REAL",e=>{const t=e._GetNode(0).GetBoundMethod();return()=>Math.floor(t(500))},()=>"music",()=>"Start ",()=>"Bg ",()=>"Buttons",()=>"Brightness",()=>"Clear Data",()=>"ClearData",()=>"Menu",()=>"Info",()=>"https://doondook.studio/buy-html5-games",()=>"NewWindow",()=>"Play",()=>"Loading",()=>"LoadingBg",()=>"Bubbles",()=>"Debug: loading 1",()=>"game_started",()=>"Debug: loading 2",()=>840,e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(.1,.4)},()=>"Debug: loading 2.2",()=>"Debug: loading 3",()=>.18,()=>"Debug: loading 4",()=>"Debug: loading 5",()=>"Debug: loading 6",()=>"Debug: loading !00",()=>"Local Storage",()=>"DD2KShoot_Data",e=>{const t=e._GetNode(0).GetBoundMethod(),s=e._GetNode(1).GetBoundMethod(),i=e._GetNode(2).GetBoundMethod();return()=>t(s(i(),0,"|"))},e=>{const t=e._GetNode(0).GetVar();return()=>jD(t.GetValue(),"|")},()=>"Sounds / Music",()=>"click",e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t("pop1","pop2","pop3")},()=>-10,()=>-15,()=>-20,()=>-5,e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t("good1","good2")},e=>{const t=e._GetNode(0).GetBoundMethod();return()=>t(0)*(1920/1080)},()=>"57d370d9-d604-4b6b-8628-95ee800b2386",()=>"ryJGkhT7qAB",()=>"Build Version is 0.5.3",e=>{const t=e._GetNode(0).GetBoundMethod();return()=>Math.round(500*t())},()=>"loaded",()=>"game_loaded",e=>{const t=e._GetNode(0).GetVar();return()=>Math.round(t.GetValue())},()=>"Rotate",e=>{const t=e._GetNode(0).GetBoundMethod();return()=>.5625*t(0)},()=>-717750023016447]}}}),import_c3runtime=__toESM(require_c3runtime()),C32=self.C3;self.C3_GetObjectRefTable=function(){return[C32.Plugins.Sprite,C32.Plugins.Touch,C32.Behaviors.MoveTo,C32.Behaviors.Tween,C32.Plugins.NinePatch,C32.Plugins.Browser,C32.Plugins.Text,C32.Plugins.Mouse,C32.Plugins.TiledBg,C32.Behaviors.Bullet,C32.Plugins.Keyboard,C32.Plugins.Spritefont2,C32.Plugins.Dictionary,C32.Behaviors.Pin,C32.Behaviors.Rotate,C32.Plugins.LocalStorage,C32.Plugins.Audio,C32.Plugins.Json,C32.Behaviors.Sin,C32.Behaviors.Timer,C32.Plugins.Gamezop,C32.Plugins.PlatformInfo,C32.Plugins.Date,C32.Plugins.Button,C32.Plugins.GameAnalytics,C32.Plugins.System.Cnds.IsGroupActive,C32.Plugins.System.Cnds.OnLayoutStart,C32.Plugins.System.Acts.SetVar,C32.Plugins.Sprite.Acts.SetInstanceVar,C32.Plugins.System.Cnds.CompareVar,C32.Plugins.System.Acts.SetFunctionReturnValue,C32.Plugins.System.Cnds.Compare,C32.Plugins.System.Exps.int,C32.Plugins.System.Exps.choose,C32.Plugins.System.Cnds.For,C32.Plugins.System.Exps.random,C32.Plugins.System.Exps.tokencount,C32.Plugins.System.Acts.AddVar,C32.Plugins.System.Exps.tokenat,C32.Plugins.System.Exps.replace,C32.Plugins.System.Exps.loopindex,C32.Plugins.Sprite.Acts.Destroy,C32.Plugins.TiledBg.Acts.Destroy,C32.Plugins.System.Acts.Wait,C32.Plugins.Sprite.Acts.SetOpacity,C32.Plugins.TiledBg.Cnds.IsOnLayer,C32.Plugins.TiledBg.Acts.SetOpacity,C32.Behaviors.Tween.Acts.TweenOneProperty,C32.Plugins.Sprite.Cnds.OnCreated,C32.Plugins.TiledBg.Cnds.OnCreated,C32.Plugins.System.Cnds.TriggerOnce,C32.Plugins.Gamezop.Cnds.HasMeta,C32.Plugins.Gamezop.Exps.Meta,C32.Plugins.Spritefont2.Acts.SetText,C32.Plugins.System.Cnds.Else,C32.Plugins.Sprite.Cnds.PickByUID,C32.Plugins.Sprite.Cnds.IsOverlapping,C32.Plugins.Sprite.Cnds.PickTopBottom,C32.Plugins.Sprite.Cnds.CompareInstanceVar,C32.Plugins.Sprite.Exps.Y,C32.Plugins.Sprite.Acts.MoveToBottom,C32.Plugins.System.Cnds.ForEach,C32.Plugins.System.Acts.CreateObject,C32.Plugins.Sprite.Exps.UID,C32.Plugins.Sprite.Cnds.CompareY,C32.Plugins.Sprite.Cnds.CompareX,C32.Plugins.System.Exps.layoutwidth,C32.Plugins.Sprite.Exps.Width,C32.Plugins.Sprite.Cnds.PickInstVarHiLow,C32.Plugins.NinePatch.Exps.BBoxLeft,C32.Plugins.NinePatch.Exps.Y,C32.Plugins.Sprite.Acts.SetSize,C32.Plugins.NinePatch.Exps.Height,C32.Plugins.NinePatch.Exps.BBoxRight,C32.Plugins.Sprite.Exps.X,C32.Plugins.Sprite.Acts.ZMoveToObject,C32.Plugins.System.Exps.find,C32.Plugins.Sprite.Exps.AnimationFrame,C32.Plugins.Sprite.Acts.SetAnimFrame,C32.Plugins.NinePatch.Exps.BBoxBottom,C32.Plugins.System.Cnds.PickByComparison,C32.Plugins.Sprite.Exps.IID,C32.Plugins.Sprite.Acts.MoveToTop,C32.Behaviors.Tween.Acts.TweenTwoProperties,C32.Plugins.Sprite.Acts.SetPos,C32.Plugins.Sprite.Acts.SetWidth,C32.Plugins.Touch.Cnds.OnTouchStart,C32.Plugins.Touch.Cnds.IsTouchingObject,C32.Plugins.System.Cnds.LayerVisible,C32.Behaviors.MoveTo.Cnds.IsMoving,C32.Plugins.Sprite.Exps.Count,C32.Plugins.Touch.Cnds.OnTouchEnd,C32.Plugins.Sprite.Cnds.CompareFrame,C32.Plugins.Sprite.Acts.AddInstanceVar,C32.Plugins.Touch.Cnds.IsInTouch,C32.Plugins.Mouse.Cnds.IsButtonDown,C32.Plugins.Sprite.Cnds.CompareWidth,C32.Plugins.Touch.Exps.Y,C32.Plugins.Sprite.Exps.BBoxTop,C32.Plugins.TiledBg.Exps.BBoxBottom,C32.Plugins.System.Cnds.IsBetweenAngles,C32.Plugins.Touch.Exps.X,C32.Plugins.Sprite.Exps.Height,C32.Plugins.Sprite.Acts.SetAngle,C32.Plugins.Sprite.Exps.Angle,C32.Plugins.Sprite.Acts.SetVisible,C32.Plugins.TiledBg.Cnds.CompareOpacity,C32.Plugins.System.Cnds.Repeat,C32.Plugins.System.Acts.StopLoop,C32.Plugins.System.Exps.max,C32.Plugins.System.Exps.viewportwidth,C32.Plugins.System.Exps.viewportheight,C32.Plugins.System.Cnds.CompareBoolVar,C32.Plugins.Sprite.Exps.ImagePointX,C32.Plugins.Sprite.Exps.ImagePointY,C32.Plugins.Sprite.Cnds.PickDistance,C32.Plugins.Sprite.Acts.SetAnim,C32.Plugins.Sprite.Cnds.IsVisible,C32.Plugins.TiledBg.Acts.SetPosToObject,C32.Plugins.TiledBg.Acts.SetAngle,C32.Plugins.TiledBg.Acts.SetVisible,C32.Plugins.TiledBg.Acts.SetWidth,C32.Plugins.System.Exps.min,C32.Plugins.TiledBg.Exps.X,C32.Plugins.TiledBg.Exps.Y,C32.Plugins.TiledBg.Exps.ImageWidth,C32.Plugins.TiledBg.Acts.MoveToTop,C32.Plugins.TiledBg.Acts.SetDefaultColor,C32.Plugins.System.Exps.rgba255,C32.Plugins.GameAnalytics.Acts.addDesignEvent,C32.Behaviors.MoveTo.Acts.SetMaxSpeed,C32.Behaviors.MoveTo.Acts.MoveToPosition,C32.Behaviors.Tween.Cnds.IsAnyPlaying,C32.Behaviors.MoveTo.Cnds.OnArrived,C32.Plugins.Sprite.Acts.SetScale,C32.Behaviors.Tween.Cnds.OnTweensFinished,C32.Behaviors.Tween.Cnds.IsPlaying,C32.Plugins.TiledBg.Acts.SetSize,C32.Plugins.TiledBg.Exps.Height,C32.Plugins.NinePatch.Exps.Width,C32.Plugins.TiledBg.Acts.SetPos,C32.Plugins.System.Exps.scrollx,C32.Plugins.System.Exps.scrolly,C32.Plugins.Sprite.Cnds.OnCollision,C32.Plugins.System.Cnds.ForEachOrdered,C32.Behaviors.Bullet.Acts.SetSpeed,C32.Behaviors.Bullet.Acts.SetAngleOfMotion,C32.Behaviors.Bullet.Acts.SetEnabled,C32.Plugins.Sprite.Cnds.IsOnScreen,C32.Plugins.Sprite.Cnds.CompareOpacity,C32.Behaviors.Tween.Exps.Progress,C32.Plugins.Sprite.Acts.SetY,C32.Plugins.Dictionary.Acts.AddKey,C32.Plugins.TiledBg.Cnds.CompareWidth,C32.Plugins.Gamezop.Acts.SetScore,C32.Plugins.System.Exps.fps,C32.Plugins.Gamezop.Acts.SetMeta,C32.Plugins.Sprite.Exps.ImageWidth,C32.Plugins.Sprite.Exps.ImageHeight,C32.Plugins.Spritefont2.Exps.X,C32.Plugins.Spritefont2.Exps.Y,C32.Plugins.Spritefont2.Acts.Destroy,C32.Plugins.Sprite.Acts.SubInstanceVar,C32.Plugins.Spritefont2.Cnds.CompareInstanceVar,C32.Plugins.Sprite.Cnds.OnAnimFinished,C32.Plugins.TiledBg.Cnds.IsVisible,C32.Plugins.Sprite.Acts.SetHeight,C32.Plugins.Sprite.Acts.RotateClockwise,C32.Plugins.TiledBg.Exps.Angle,C32.Plugins.Sprite.Acts.SetMirrored,C32.Plugins.Sprite.Exps.AnimationName,C32.Plugins.Sprite.Cnds.OnDestroyed,C32.Plugins.Sprite.Cnds.IsOnLayer,C32.Behaviors.Pin.Acts.PinByProperties,C32.Plugins.Spritefont2.Cnds.IsOnLayer,C32.Plugins.System.Exps.viewporttop,C32.Plugins.System.Exps.layoutheight,C32.Behaviors.Tween.Acts.PauseTweens,C32.Plugins.Spritefont2.Acts.SetOpacity,C32.Behaviors.Tween.Acts.ResumeTweens,C32.Plugins.System.Acts.SubVar,C32.Plugins.System.Acts.SetLayerVisible,C32.Plugins.Gamezop.Cnds.isBattleGame,C32.Plugins.Spritefont2.Acts.SetVisible,C32.Plugins.Spritefont2.Acts.SetPos,C32.Plugins.System.Acts.SetLayerOpacity,C32.Plugins.Sprite.Exps.Opacity,C32.Plugins.System.Acts.SetLayerScale,C32.Plugins.Keyboard.Cnds.OnKey,C32.Plugins.Spritefont2.Acts.SetScale,C32.Plugins.Spritefont2.Exps.Width,C32.Plugins.Spritefont2.Acts.SetWidth,C32.Plugins.Sprite.Exps.BBoxRight,C32.Plugins.Spritefont2.Exps.TextWidth,C32.Plugins.Spritefont2.Acts.SetInstanceVar,C32.Plugins.System.Exps.right,C32.Plugins.Sprite.Exps.BBoxLeft,C32.Plugins.Spritefont2.Exps.BBoxRight,C32.Behaviors.Pin.Acts.Unpin,C32.Plugins.Sprite.Exps.LayerName,C32.Plugins.Spritefont2.Acts.MoveToLayer,C32.Plugins.Spritefont2.Exps.UID,C32.Plugins.Sprite.Acts.MoveToLayer,C32.Plugins.Spritefont2.Acts.MoveToTop,C32.Plugins.Spritefont2.Exps.Text,C32.Plugins.System.Exps.len,C32.Plugins.Spritefont2.Cnds.PickByUID,C32.Plugins.Sprite.Acts.SetDefaultColor,C32.Plugins.Gamezop.Acts.SetGamePaused,C32.Behaviors.Sin.Acts.SetPeriod,C32.Behaviors.Sin.Acts.SetEnabled,C32.Plugins.Text.Acts.SetVisible,C32.Plugins.Gamezop.Cnds.isContestGame,C32.Plugins.Audio.Acts.UnloadAll,C32.Plugins.Audio.Acts.StopAll,C32.Plugins.Audio.Acts.SetMasterVolume,C32.Plugins.Gamezop.Cnds.isAllowRewardedAds,C32.Plugins.TiledBg.Acts.MoveToLayer,C32.Plugins.TiledBg.Acts.MoveToBottom,C32.Plugins.Sprite.Acts.StartAnim,C32.Behaviors.Sin.Acts.SetPhase,C32.Plugins.System.Cnds.Every,C32.Plugins.Text.Acts.SetText,C32.Plugins.System.Acts.ResetGlobals,C32.Plugins.System.Acts.RestartLayout,C32.Plugins.System.Acts.GoToLayout,C32.Behaviors.Timer.Acts.StartTimer,C32.Behaviors.Sin.Cnds.IsEnabled,C32.Behaviors.Timer.Exps.CurrentTime,C32.Plugins.TiledBg.Exps.Count,C32.Plugins.TiledBg.Acts.ZMoveToObject,C32.Plugins.Sprite.Acts.SetAnimSpeed,C32.Plugins.Gamezop.Acts.BroadcastActivityStatus,C32.Plugins.System.Cnds.OnSuspend,C32.Plugins.Date.Exps.Now,C32.Plugins.System.Cnds.OnResume,C32.Plugins.Date.Exps.Difference,C32.Plugins.Gamezop.Acts.ShowRewardedAds,C32.Plugins.Gamezop.Cnds.OnRewardedAdComplete,C32.Plugins.PlatformInfo.Cnds.IsOnMobile,C32.Plugins.Browser.Cnds.IsPortraitLandscape,C32.Plugins.Gamezop.Cnds.OnRewardedAdSkipped,C32.Plugins.Browser.Acts.ConsoleLog,C32.Plugins.Gamezop.Cnds.OnRewardedAdError,C32.Plugins.Gamezop.Cnds.OnPause,C32.Plugins.System.Acts.SetTimescale,C32.Plugins.Gamezop.Cnds.OnResume,C32.Plugins.Gamezop.Cnds.OnMute,C32.Plugins.Gamezop.Cnds.OnUnMute,C32.Plugins.Gamezop.Cnds.OnGameEnd,C32.Plugins.Gamezop.Cnds.OnGameInit,C32.Plugins.Audio.Acts.Play,C32.Plugins.Audio.Cnds.IsAnyPlaying,C32.Plugins.Sprite.Acts.SetEffectParam,C32.Plugins.Gamezop.Acts.SetGameMuted,C32.Plugins.LocalStorage.Acts.ClearStorage,C32.Plugins.Browser.Acts.GoToURLWindow,C32.Plugins.Sprite.Exps.AnimationFrameCount,C32.Plugins.LocalStorage.Cnds.OnItemExists,C32.Plugins.LocalStorage.Exps.ItemValue,C32.Plugins.LocalStorage.Acts.SetItem,C32.Plugins.Audio.Acts.PlayByName,C32.Plugins.Audio.Acts.Stop,C32.Plugins.Audio.Cnds.IsTagPlaying,C32.Plugins.Gamezop.Acts.Init,C32.Plugins.GameAnalytics.Acts.initialize,C32.Plugins.Gamezop.Cnds.OnInit,C32.Plugins.System.Cnds.EveryTick,C32.Plugins.System.Exps.loadingprogress,C32.Plugins.Gamezop.Acts.BroadcastLoadingProgress,C32.Plugins.System.Cnds.OnLayoutEnd,C32.Plugins.System.Acts.SetLayerBackground,C32.Plugins.System.Acts.SetLayerTransparent]},self.C3_JsPropNameTable=[{Neighbours:0},{NeighFlg:0},{myX:0},{myY:0},{Connected:0},{DistToCenter:0},{HaveC2:0},{Stroke:0},{TwoKFlg:0},{Throw:0},{Circle:0},{Undestroyable:0},{Spot:0},{Touch:0},{Shoot:0},{Reach:0},{Dne:0},{moving:0},{m:0},{num:0},{Lunched:0},{MoveTo:0},{Tween:0},{ShootableCircle:0},{Bound:0},{Wall:0},{n:0},{TheAngle:0},{TheAngleTemp:0},{Line:0},{Browser:0},{Line2:0},{txtNum:0},{Mouse:0},{Trajectory:0},{flg:0},{Bullet:0},{Circle2:0},{Keyboard:0},{TimeBar:0},{TopPanel:0},{Bg:0},{Platform:0},{type:0},{txtLevel:0},{Clickable:0},{BtnPause:0},{GiftBarBg:0},{GiftBar:0},{txtCoins:0},{Dictionary:0},{added:0},{Coin:0},{UnlockLevel:0},{Space:0},{StartingPrice:0},{FirstWidth:0},{FirstHeight:0},{tempN:0},{txtLockFlg:0},{JustUnlocked:0},{ClickAvailable:0},{BtnItemBlade:0},{BtnItemBomb:0},{BtnItemLightning:0},{LosingLine:0},{txtItemNum:0},{Item:0},{Explosion:0},{Bubble:0},{LevelUpBox:0},{txtBoxTitle:0},{Black:0},{Medal:0},{Pin:0},{txtLvUp:0},{for:0},{targetUID:0},{LvUpGift:0},{parent:0},{txtGiftNum:0},{BoxOn:0},{Clicked:0},{BtnOK:0},{LvUpController:0},{FirstX:0},{FirstY:0},{Prticls:0},{Prticls2:0},{Msg:0},{PauseBox:0},{BtnClose:0},{BtnResume:0},{BtnMusic:0},{BtnSound:0},{BtnHome:0},{txtBoxTitleBlue:0},{ClickStart:0},{SwapArea:0},{PauseBlack:0},{LightningAnim:0},{GOBox:0},{GOBlack:0},{BtnHome2:0},{BtnReset:0},{BuyItemBlack:0},{BuyItemBox:0},{ItemShow:0},{Price:0},{ForItem:0},{Pin2:0},{BtnBuy:0},{txtBtnBuy:0},{GiftIcon:0},{BladePath:0},{Title:0},{clicked:0},{BtnPlay:0},{BtnInfo:0},{BtnClear:0},{ClearDataBox:0},{BtnYes:0},{AboutUsBox:0},{txtInfo:0},{BtnDoonDookStudio:0},{LoadingBg:0},{Rotate:0},{LoadingCircle:0},{LoadingBarBg:0},{LoadingBar:0},{LoadingBubbles:0},{LocalStorage:0},{LvUpGift2:0},{txtCoinHelper:0},{Audio:0},{InGameGift:0},{JSON:0},{del:0},{Sine:0},{Timer:0},{Hand:0},{txtLock:0},{HandBg:0},{Target:0},{img_LoadingBg:0},{img_UnfilledLogo:0},{img_FilledLogo:0},{Gamezop:0},{txtMenuBestScore:0},{imgGameOverText:0},{txtGameScore:0},{txtScore:0},{txtOverScore:0},{txtOverBest:0},{imgTimerBG:0},{txtGameTimer:0},{ImgTop1:0},{ImgTop2:0},{BtnContinue:0},{imgNotificationBadge:0},{txtAdLeft:0},{imgRotateScreen:0},{PlatformInfo:0},{Sprite:0},{AdsBG:0},{AdSkipped:0},{AdUnavailable:0},{AdText:0},{Text:0},{TimerAnim:0},{ReviveTimerText:0},{Date:0},{LoadingScreen:0},{Best:0},{Button:0},{Button2:0},{GameAnalytics:0},{FCircle:0},{FSpot:0},{FLine:0},{FWall:0},{FTxt:0},{FCoin:0},{FBtnItems:0},{FButtons:0},{RowsAtStart:0},{MaxLines:0},{TheSpot:0},{PosList:0},{InMergeList:0},{MoveSpd:0},{AddFrame:0},{Size:0},{TopSpots:0},{AngleDif:0},{DelFlg:0},{FallSpeed:0},{FirstLineY:0},{MergeMoveTime:0},{NewCirclesFlg:0},{TrajectoryAvailable:0},{SpotsOpacity:0},{NewRowTime:0},{NewRowTimeSeconds:0},{TimeBarFinished:0},{AnyMove:0},{BallsList:0},{Score:0},{BallsValues:0},{vBallFrame:0},{VMoveaBit:0},{LvUpAnimations:0},{ShootSpeed:0},{CollectGiftsRate:0},{Combo:0},{ComboForFall:0},{Pause:0},{GameOver:0},{SwapAvailable:0},{SwapFlg:0},{LightingCircleUID:0},{BuyItem:0},{ItemsPriceMultiplier:0},{ShootON:0},{GiftsMoveSpd:0},{BackToTheLayerTime:0},{LastCircle:0},{CoinsDivider:0},{MaxCoins:0},{RowTimeMultiplier:0},{MinBallsForNewRow:0},{BladeCollisionWidth:0},{TimerStart:0},{Tutorials:0},{TutStep:0},{userMuted:0},{battleGameTime:0},{numberOfAdsLeft:0},{watchedAd:0},{isAdPlaying:0},{inactivityTimer:0},{isFirstShoot:0},{StartingScore:0},{Multiplier:0},{vList:0},{vGet:0},{picked:0},{SpcX:0},{SpcY:0},{Parameter0:0},{CircleUID:0},{vStartX:0},{TheFrame:0},{MyAngle:0},{X:0},{Y:0},{LineUID:0},{isBall:0},{vDist:0},{Parameter:0},{CreateCoins:0},{StartY:0},{v:0},{UID:0},{wait:0},{Flg:0},{Count:0},{Name:0},{vLeft:0},{vRight:0},{vTop:0},{vBottom:0},{Frame:0},{ItemsList:0},{ItemName:0},{Dist:0},{vSize:0},{Ang:0},{adPlaying:0},{adLeftLocal:0},{vSound:0},{vMusic:0},{pScore:0},{UnlockedItems:0},{pick:0},{clickableAll:0},{currentTime:0},{gameContinue:0},{isGameBattle:0},{reviveTimer:0},{Sound:0},{Music:0},{ClearData:0},{Info:0},{LoadingDone:0},{Coins:0},{BestScore:0},{Level:0},{tc:0},{kc:0},{current_scr:0},{start_scr:0},{gameState:0},{data:0},{SoundName:0},{initDone:0},{new:0},{loading:0}],self.InstanceType={Circle:class extends self.ISpriteInstance{},Spot:class extends self.ISpriteInstance{},Touch:class extends self.IInstance{},ShootableCircle:class extends self.ISpriteInstance{},Bound:class extends self.IWorldInstance{},Wall:class extends self.ISpriteInstance{},Line:class extends self.ISpriteInstance{},Browser:class extends self.IInstance{},Line2:class extends self.ISpriteInstance{},txtNum:class extends self.ITextInstance{},Mouse:class extends self.IInstance{},Trajectory:class extends self.ITiledBackgroundInstance{},Circle2:class extends self.ISpriteInstance{},Keyboard:class extends self.IInstance{},TimeBar:class extends self.IWorldInstance{},TopPanel:class extends self.ITiledBackgroundInstance{},Bg:class extends self.ITiledBackgroundInstance{},Platform:class extends self.ISpriteInstance{},txtLevel:class extends self.ISpriteFontInstance{},BtnPause:class extends self.ISpriteInstance{},GiftBarBg:class extends self.ISpriteInstance{},GiftBar:class extends self.ITiledBackgroundInstance{},txtCoins:class extends self.ISpriteFontInstance{},Dictionary:class extends self.IDictionaryInstance{},Coin:class extends self.ISpriteInstance{},BtnItemBlade:class extends self.ISpriteInstance{},BtnItemBomb:class extends self.ISpriteInstance{},BtnItemLightning:class extends self.ISpriteInstance{},LosingLine:class extends self.ISpriteInstance{},txtItemNum:class extends self.ISpriteFontInstance{},Item:class extends self.ISpriteInstance{},Explosion:class extends self.ISpriteInstance{},Bubble:class extends self.ISpriteInstance{},LevelUpBox:class extends self.ISpriteInstance{},txtBoxTitle:class extends self.ISpriteFontInstance{},Black:class extends self.ITiledBackgroundInstance{},Medal:class extends self.ISpriteInstance{},txtLvUp:class extends self.ISpriteFontInstance{},LvUpGift:class extends self.ISpriteInstance{},txtGiftNum:class extends self.ISpriteFontInstance{},BoxOn:class extends self.ISpriteInstance{},BtnOK:class extends self.ISpriteInstance{},LvUpController:class extends self.ISpriteInstance{},Prticls:class extends self.ISpriteInstance{},Prticls2:class extends self.ISpriteInstance{},Msg:class extends self.ISpriteInstance{},PauseBox:class extends self.ISpriteInstance{},BtnClose:class extends self.ISpriteInstance{},BtnResume:class extends self.ISpriteInstance{},BtnMusic:class extends self.ISpriteInstance{},BtnSound:class extends self.ISpriteInstance{},BtnHome:class extends self.ISpriteInstance{},txtBoxTitleBlue:class extends self.ISpriteFontInstance{},Stroke:class extends self.ISpriteInstance{},SwapArea:class extends self.ISpriteInstance{},PauseBlack:class extends self.ITiledBackgroundInstance{},LightningAnim:class extends self.ISpriteInstance{},GOBox:class extends self.ISpriteInstance{},GOBlack:class extends self.ITiledBackgroundInstance{},BtnHome2:class extends self.ISpriteInstance{},BtnReset:class extends self.ISpriteInstance{},BuyItemBlack:class extends self.ITiledBackgroundInstance{},BuyItemBox:class extends self.ISpriteInstance{},ItemShow:class extends self.ISpriteInstance{},BtnBuy:class extends self.ISpriteInstance{},txtBtnBuy:class extends self.ISpriteFontInstance{},GiftIcon:class extends self.ISpriteInstance{},BladePath:class extends self.ISpriteInstance{},Title:class extends self.ISpriteInstance{},BtnPlay:class extends self.ISpriteInstance{},BtnInfo:class extends self.ISpriteInstance{},BtnClear:class extends self.ISpriteInstance{},ClearDataBox:class extends self.ISpriteInstance{},BtnYes:class extends self.ISpriteInstance{},AboutUsBox:class extends self.ISpriteInstance{},txtInfo:class extends self.ISpriteFontInstance{},BtnDoonDookStudio:class extends self.ISpriteInstance{},LoadingBg:class extends self.ISpriteInstance{},LoadingCircle:class extends self.ISpriteInstance{},LoadingBarBg:class extends self.ISpriteInstance{},LoadingBar:class extends self.ITiledBackgroundInstance{},LoadingBubbles:class extends self.ISpriteInstance{},LocalStorage:class extends self.IInstance{},LvUpGift2:class extends self.ISpriteInstance{},txtCoinHelper:class extends self.ISpriteInstance{},Audio:class extends self.IInstance{},InGameGift:class extends self.ISpriteInstance{},JSON:class extends self.IJSONInstance{},Hand:class extends self.ISpriteInstance{},txtLock:class extends self.ISpriteFontInstance{},HandBg:class extends self.ITiledBackgroundInstance{},Target:class extends self.ISpriteInstance{},img_LoadingBg:class extends self.ISpriteInstance{},img_UnfilledLogo:class extends self.ISpriteInstance{},img_FilledLogo:class extends self.ITiledBackgroundInstance{},Gamezop:class extends self.IInstance{},txtMenuBestScore:class extends self.ISpriteFontInstance{},imgGameOverText:class extends self.ISpriteInstance{},txtGameScore:class extends self.ISpriteFontInstance{},txtScore:class extends self.ISpriteFontInstance{},txtOverScore:class extends self.ISpriteFontInstance{},txtOverBest:class extends self.ISpriteFontInstance{},imgTimerBG:class extends self.ISpriteInstance{},txtGameTimer:class extends self.ISpriteFontInstance{},ImgTop1:class extends self.ISpriteInstance{},ImgTop2:class extends self.ISpriteInstance{},BtnContinue:class extends self.ISpriteInstance{},imgNotificationBadge:class extends self.ISpriteInstance{},txtAdLeft:class extends self.ISpriteFontInstance{},imgRotateScreen:class extends self.ISpriteInstance{},PlatformInfo:class extends self.IInstance{},Sprite:class extends self.ISpriteInstance{},AdsBG:class extends self.ISpriteInstance{},AdSkipped:class extends self.ISpriteInstance{},AdUnavailable:class extends self.ISpriteInstance{},AdText:class extends self.ITextInstance{},Timer:class extends self.ISpriteInstance{},Text:class extends self.ITextInstance{},TimerAnim:class extends self.ISpriteInstance{},ReviveTimerText:class extends self.ITextInstance{},Date:class extends self.IInstance{},LoadingScreen:class extends self.ISpriteInstance{},Best:class extends self.ISpriteInstance{},Button:class extends self.IButtonInstance{},Button2:class extends self.IButtonInstance{},GameAnalytics:class extends self.IInstance{},FCircle:class extends self.ISpriteInstance{},FSpot:class extends self.ISpriteInstance{},FLine:class extends self.ISpriteInstance{},FWall:class extends self.ISpriteInstance{},FTxt:class extends self.ISpriteFontInstance{},FCoin:class extends self.ISpriteInstance{},FBtnItems:class extends self.ISpriteInstance{},FButtons:class extends self.ISpriteInstance{}}; /*! @fileoverview gl-matrix - High performance matrix and vector operations @author Brandon Jones @author Colin MacKenzie IV @version 3.4.1 Copyright (c) 2015-2021, Brandon Jones, Colin MacKenzie IV. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */