Файловый менеджер - Редактировать - /home/jogoso94/public_html/jogos/parking_jem/scripts/c3runtime.js
�азад
// Generated by Construct, the game and animation creation tool // Visit: https://www.construct.net // ../3rdparty/glmatrix.js { var EPSILON=1e-6,ARRAY_TYPE="undefined"!=typeof Float32Array?Float32Array:Array,RANDOM=Math.random,ANGLE_ORDER="zyx";function setMatrixArrayType(t){ARRAY_TYPE=t}var degree=Math.PI/180;function toRadian(t){return t*degree}function equals$9(t,a){return Math.abs(t-a)<=EPSILON*Math.max(1,Math.abs(t),Math.abs(a))}Math.hypot||(Math.hypot=function(){for(var t=0,a=arguments.length;a--;)t+=arguments[a]*arguments[a];return Math.sqrt(t)});var common={__proto__:null,EPSILON:EPSILON,get ARRAY_TYPE(){return ARRAY_TYPE},RANDOM:RANDOM,ANGLE_ORDER:ANGLE_ORDER,setMatrixArrayType:setMatrixArrayType,toRadian:toRadian,equals:equals$9};function create$8(){var t=new ARRAY_TYPE(4);return ARRAY_TYPE!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t}function clone$8(t){var a=new ARRAY_TYPE(4);return a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a}function copy$8(t,a){return t[0]=a[0],t[1]=a[1],t[2]=a[2],t[3]=a[3],t}function identity$5(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t}function fromValues$8(t,a,r,n){var e=new ARRAY_TYPE(4);return e[0]=t,e[1]=a,e[2]=r,e[3]=n,e}function set$8(t,a,r,n,e){return t[0]=a,t[1]=r,t[2]=n,t[3]=e,t}function transpose$2(t,a){var r;return t===a?(r=a[1],t[1]=a[2],t[2]=r):(t[0]=a[0],t[1]=a[2],t[2]=a[1],t[3]=a[3]),t}function invert$5(t,a){var r=a[0],n=a[1],e=a[2],a=a[3],o=r*a-e*n;return o?(t[0]=a*(o=1/o),t[1]=-n*o,t[2]=-e*o,t[3]=r*o,t):null}function adjoint$2(t,a){var r=a[0];return t[0]=a[3],t[1]=-a[1],t[2]=-a[2],t[3]=r,t}function determinant$3(t){return t[0]*t[3]-t[2]*t[1]}function multiply$8(t,a,r){var n=a[0],e=a[1],o=a[2],a=a[3],u=r[0],s=r[1],i=r[2],r=r[3];return t[0]=n*u+o*s,t[1]=e*u+a*s,t[2]=n*i+o*r,t[3]=e*i+a*r,t}function rotate$4(t,a,r){var n=a[0],e=a[1],o=a[2],a=a[3],u=Math.sin(r),r=Math.cos(r);return t[0]=n*r+o*u,t[1]=e*r+a*u,t[2]=n*-u+o*r,t[3]=e*-u+a*r,t}function scale$8(t,a,r){var n=a[0],e=a[1],o=a[2],a=a[3],u=r[0],r=r[1];return t[0]=n*u,t[1]=e*u,t[2]=o*r,t[3]=a*r,t}function fromRotation$4(t,a){var r=Math.sin(a),a=Math.cos(a);return t[0]=a,t[1]=r,t[2]=-r,t[3]=a,t}function fromScaling$3(t,a){return t[0]=a[0],t[1]=0,t[2]=0,t[3]=a[1],t}function str$8(t){return"mat2("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"}function frob$3(t){return Math.hypot(t[0],t[1],t[2],t[3])}function LDU(t,a,r,n){return t[2]=n[2]/n[0],r[0]=n[0],r[1]=n[1],r[3]=n[3]-t[2]*r[1],[t,a,r]}function add$8(t,a,r){return t[0]=a[0]+r[0],t[1]=a[1]+r[1],t[2]=a[2]+r[2],t[3]=a[3]+r[3],t}function subtract$6(t,a,r){return t[0]=a[0]-r[0],t[1]=a[1]-r[1],t[2]=a[2]-r[2],t[3]=a[3]-r[3],t}function exactEquals$8(t,a){return t[0]===a[0]&&t[1]===a[1]&&t[2]===a[2]&&t[3]===a[3]}function equals$8(t,a){var r=t[0],n=t[1],e=t[2],t=t[3],o=a[0],u=a[1],s=a[2],a=a[3];return Math.abs(r-o)<=EPSILON*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(n-u)<=EPSILON*Math.max(1,Math.abs(n),Math.abs(u))&&Math.abs(e-s)<=EPSILON*Math.max(1,Math.abs(e),Math.abs(s))&&Math.abs(t-a)<=EPSILON*Math.max(1,Math.abs(t),Math.abs(a))}function multiplyScalar$3(t,a,r){return t[0]=a[0]*r,t[1]=a[1]*r,t[2]=a[2]*r,t[3]=a[3]*r,t}function multiplyScalarAndAdd$3(t,a,r,n){return t[0]=a[0]+r[0]*n,t[1]=a[1]+r[1]*n,t[2]=a[2]+r[2]*n,t[3]=a[3]+r[3]*n,t}var mul$8=multiply$8,sub$6=subtract$6,mat2=Object.freeze({__proto__:null,create:create$8,clone:clone$8,copy:copy$8,identity:identity$5,fromValues:fromValues$8,set:set$8,transpose:transpose$2,invert:invert$5,adjoint:adjoint$2,determinant:determinant$3,multiply:multiply$8,rotate:rotate$4,scale:scale$8,fromRotation:fromRotation$4,fromScaling:fromScaling$3,str:str$8,frob:frob$3,LDU:LDU,add:add$8,subtract:subtract$6,exactEquals:exactEquals$8,equals:equals$8,multiplyScalar:multiplyScalar$3,multiplyScalarAndAdd:multiplyScalarAndAdd$3,mul:mul$8,sub:sub$6});function create$7(){var t=new ARRAY_TYPE(6);return ARRAY_TYPE!=Float32Array&&(t[1]=0,t[2]=0,t[4]=0,t[5]=0),t[0]=1,t[3]=1,t}function clone$7(t){var a=new ARRAY_TYPE(6);return a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a}function copy$7(t,a){return t[0]=a[0],t[1]=a[1],t[2]=a[2],t[3]=a[3],t[4]=a[4],t[5]=a[5],t}function identity$4(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t}function fromValues$7(t,a,r,n,e,o){var u=new ARRAY_TYPE(6);return u[0]=t,u[1]=a,u[2]=r,u[3]=n,u[4]=e,u[5]=o,u}function set$7(t,a,r,n,e,o,u){return t[0]=a,t[1]=r,t[2]=n,t[3]=e,t[4]=o,t[5]=u,t}function invert$4(t,a){var r=a[0],n=a[1],e=a[2],o=a[3],u=a[4],a=a[5],s=r*o-n*e;return s?(t[0]=o*(s=1/s),t[1]=-n*s,t[2]=-e*s,t[3]=r*s,t[4]=(e*a-o*u)*s,t[5]=(n*u-r*a)*s,t):null}function determinant$2(t){return t[0]*t[3]-t[1]*t[2]}function multiply$7(t,a,r){var n=a[0],e=a[1],o=a[2],u=a[3],s=a[4],a=a[5],i=r[0],c=r[1],l=r[2],$=r[3],h=r[4],r=r[5];return t[0]=n*i+o*c,t[1]=e*i+u*c,t[2]=n*l+o*$,t[3]=e*l+u*$,t[4]=n*h+o*r+s,t[5]=e*h+u*r+a,t}function rotate$3(t,a,r){var n=a[0],e=a[1],o=a[2],u=a[3],s=a[4],a=a[5],i=Math.sin(r),r=Math.cos(r);return t[0]=n*r+o*i,t[1]=e*r+u*i,t[2]=n*-i+o*r,t[3]=e*-i+u*r,t[4]=s,t[5]=a,t}function scale$7(t,a,r){var n=a[0],e=a[1],o=a[2],u=a[3],s=a[4],a=a[5],i=r[0],r=r[1];return t[0]=n*i,t[1]=e*i,t[2]=o*r,t[3]=u*r,t[4]=s,t[5]=a,t}function translate$3(t,a,r){var n=a[0],e=a[1],o=a[2],u=a[3],s=a[4],a=a[5],i=r[0],r=r[1];return t[0]=n,t[1]=e,t[2]=o,t[3]=u,t[4]=n*i+o*r+s,t[5]=e*i+u*r+a,t}function fromRotation$3(t,a){var r=Math.sin(a),a=Math.cos(a);return t[0]=a,t[1]=r,t[2]=-r,t[3]=a,t[4]=0,t[5]=0,t}function fromScaling$2(t,a){return t[0]=a[0],t[1]=0,t[2]=0,t[3]=a[1],t[4]=0,t[5]=0,t}function fromTranslation$3(t,a){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=a[0],t[5]=a[1],t}function str$7(t){return"mat2d("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+")"}function frob$2(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],1)}function add$7(t,a,r){return t[0]=a[0]+r[0],t[1]=a[1]+r[1],t[2]=a[2]+r[2],t[3]=a[3]+r[3],t[4]=a[4]+r[4],t[5]=a[5]+r[5],t}function subtract$5(t,a,r){return t[0]=a[0]-r[0],t[1]=a[1]-r[1],t[2]=a[2]-r[2],t[3]=a[3]-r[3],t[4]=a[4]-r[4],t[5]=a[5]-r[5],t}function multiplyScalar$2(t,a,r){return t[0]=a[0]*r,t[1]=a[1]*r,t[2]=a[2]*r,t[3]=a[3]*r,t[4]=a[4]*r,t[5]=a[5]*r,t}function multiplyScalarAndAdd$2(t,a,r,n){return t[0]=a[0]+r[0]*n,t[1]=a[1]+r[1]*n,t[2]=a[2]+r[2]*n,t[3]=a[3]+r[3]*n,t[4]=a[4]+r[4]*n,t[5]=a[5]+r[5]*n,t}function exactEquals$7(t,a){return t[0]===a[0]&&t[1]===a[1]&&t[2]===a[2]&&t[3]===a[3]&&t[4]===a[4]&&t[5]===a[5]}function equals$7(t,a){var r=t[0],n=t[1],e=t[2],o=t[3],u=t[4],t=t[5],s=a[0],i=a[1],c=a[2],l=a[3],$=a[4],a=a[5];return Math.abs(r-s)<=EPSILON*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(n-i)<=EPSILON*Math.max(1,Math.abs(n),Math.abs(i))&&Math.abs(e-c)<=EPSILON*Math.max(1,Math.abs(e),Math.abs(c))&&Math.abs(o-l)<=EPSILON*Math.max(1,Math.abs(o),Math.abs(l))&&Math.abs(u-$)<=EPSILON*Math.max(1,Math.abs(u),Math.abs($))&&Math.abs(t-a)<=EPSILON*Math.max(1,Math.abs(t),Math.abs(a))}var mul$7=multiply$7,sub$5=subtract$5,mat2d=Object.freeze({__proto__:null,create:create$7,clone:clone$7,copy:copy$7,identity:identity$4,fromValues:fromValues$7,set:set$7,invert:invert$4,determinant:determinant$2,multiply:multiply$7,rotate:rotate$3,scale:scale$7,translate:translate$3,fromRotation:fromRotation$3,fromScaling:fromScaling$2,fromTranslation:fromTranslation$3,str:str$7,frob:frob$2,add:add$7,subtract:subtract$5,multiplyScalar:multiplyScalar$2,multiplyScalarAndAdd:multiplyScalarAndAdd$2,exactEquals:exactEquals$7,equals:equals$7,mul:mul$7,sub:sub$5});function create$6(){var t=new ARRAY_TYPE(9);return ARRAY_TYPE!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function fromMat4$1(t,a){return t[0]=a[0],t[1]=a[1],t[2]=a[2],t[3]=a[4],t[4]=a[5],t[5]=a[6],t[6]=a[8],t[7]=a[9],t[8]=a[10],t}function clone$6(t){var a=new ARRAY_TYPE(9);return a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7],a[8]=t[8],a}function copy$6(t,a){return t[0]=a[0],t[1]=a[1],t[2]=a[2],t[3]=a[3],t[4]=a[4],t[5]=a[5],t[6]=a[6],t[7]=a[7],t[8]=a[8],t}function fromValues$6(t,a,r,n,e,o,u,s,i){var c=new ARRAY_TYPE(9);return c[0]=t,c[1]=a,c[2]=r,c[3]=n,c[4]=e,c[5]=o,c[6]=u,c[7]=s,c[8]=i,c}function set$6(t,a,r,n,e,o,u,s,i,c){return t[0]=a,t[1]=r,t[2]=n,t[3]=e,t[4]=o,t[5]=u,t[6]=s,t[7]=i,t[8]=c,t}function identity$3(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t}function transpose$1(t,a){var r,n,e;return t===a?(r=a[1],n=a[2],e=a[5],t[1]=a[3],t[2]=a[6],t[3]=r,t[5]=a[7],t[6]=n,t[7]=e):(t[0]=a[0],t[1]=a[3],t[2]=a[6],t[3]=a[1],t[4]=a[4],t[5]=a[7],t[6]=a[2],t[7]=a[5],t[8]=a[8]),t}function invert$3(t,a){var r=a[0],n=a[1],e=a[2],o=a[3],u=a[4],s=a[5],i=a[6],c=a[7],a=a[8],l=a*u-s*c,$=-a*o+s*i,h=c*o-u*i,f=r*l+n*$+e*h;return f?(t[0]=l*(f=1/f),t[1]=(-a*n+e*c)*f,t[2]=(s*n-e*u)*f,t[3]=$*f,t[4]=(a*r-e*i)*f,t[5]=(-s*r+e*o)*f,t[6]=h*f,t[7]=(-c*r+n*i)*f,t[8]=(u*r-n*o)*f,t):null}function adjoint$1(t,a){var r=a[0],n=a[1],e=a[2],o=a[3],u=a[4],s=a[5],i=a[6],c=a[7],a=a[8];return t[0]=u*a-s*c,t[1]=e*c-n*a,t[2]=n*s-e*u,t[3]=s*i-o*a,t[4]=r*a-e*i,t[5]=e*o-r*s,t[6]=o*c-u*i,t[7]=n*i-r*c,t[8]=r*u-n*o,t}function determinant$1(t){var a=t[0],r=t[3],n=t[4],e=t[5],o=t[6],u=t[7],s=t[8];return a*(s*n-e*u)+t[1]*(-s*r+e*o)+t[2]*(u*r-n*o)}function multiply$6(t,a,r){var n=a[0],e=a[1],o=a[2],u=a[3],s=a[4],i=a[5],c=a[6],l=a[7],a=a[8],$=r[0],h=r[1],f=r[2],M=r[3],m=r[4],d=r[5],v=r[6],b=r[7],r=r[8];return t[0]=$*n+h*u+f*c,t[1]=$*e+h*s+f*l,t[2]=$*o+h*i+f*a,t[3]=M*n+m*u+d*c,t[4]=M*e+m*s+d*l,t[5]=M*o+m*i+d*a,t[6]=v*n+b*u+r*c,t[7]=v*e+b*s+r*l,t[8]=v*o+b*i+r*a,t}function translate$2(t,a,r){var n=a[0],e=a[1],o=a[2],u=a[3],s=a[4],i=a[5],c=a[6],l=a[7],a=a[8],$=r[0],r=r[1];return t[0]=n,t[1]=e,t[2]=o,t[3]=u,t[4]=s,t[5]=i,t[6]=$*n+r*u+c,t[7]=$*e+r*s+l,t[8]=$*o+r*i+a,t}function rotate$2(t,a,r){var n=a[0],e=a[1],o=a[2],u=a[3],s=a[4],i=a[5],c=a[6],l=a[7],a=a[8],$=Math.sin(r),r=Math.cos(r);return t[0]=r*n+$*u,t[1]=r*e+$*s,t[2]=r*o+$*i,t[3]=r*u-$*n,t[4]=r*s-$*e,t[5]=r*i-$*o,t[6]=c,t[7]=l,t[8]=a,t}function scale$6(t,a,r){var n=r[0],r=r[1];return t[0]=n*a[0],t[1]=n*a[1],t[2]=n*a[2],t[3]=r*a[3],t[4]=r*a[4],t[5]=r*a[5],t[6]=a[6],t[7]=a[7],t[8]=a[8],t}function fromTranslation$2(t,a){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=a[0],t[7]=a[1],t[8]=1,t}function fromRotation$2(t,a){var r=Math.sin(a),a=Math.cos(a);return t[0]=a,t[1]=r,t[2]=0,t[3]=-r,t[4]=a,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t}function fromScaling$1(t,a){return t[0]=a[0],t[1]=0,t[2]=0,t[3]=0,t[4]=a[1],t[5]=0,t[6]=0,t[7]=0,t[8]=1,t}function fromMat2d(t,a){return t[0]=a[0],t[1]=a[1],t[2]=0,t[3]=a[2],t[4]=a[3],t[5]=0,t[6]=a[4],t[7]=a[5],t[8]=1,t}function fromQuat$1(t,a){var r=a[0],n=a[1],e=a[2],a=a[3],o=r+r,u=n+n,s=e+e,r=r*o,i=n*o,n=n*u,c=e*o,l=e*u,e=e*s,o=a*o,u=a*u,a=a*s;return t[0]=1-n-e,t[3]=i-a,t[6]=c+u,t[1]=i+a,t[4]=1-r-e,t[7]=l-o,t[2]=c-u,t[5]=l+o,t[8]=1-r-n,t}function normalFromMat4(t,a){var r=a[0],n=a[1],e=a[2],o=a[3],u=a[4],s=a[5],i=a[6],c=a[7],l=a[8],$=a[9],h=a[10],f=a[11],M=a[12],m=a[13],d=a[14],a=a[15],v=r*s-n*u,b=r*i-e*u,p=r*c-o*u,A=n*i-e*s,y=n*c-o*s,g=e*c-o*i,R=l*m-$*M,E=l*d-h*M,l=l*a-f*M,q=$*d-h*m,$=$*a-f*m,h=h*a-f*d,f=v*h-b*$+p*q+A*l-y*E+g*R;return f?(t[0]=(s*h-i*$+c*q)*(f=1/f),t[1]=(i*l-u*h-c*E)*f,t[2]=(u*$-s*l+c*R)*f,t[3]=(e*$-n*h-o*q)*f,t[4]=(r*h-e*l+o*E)*f,t[5]=(n*l-r*$-o*R)*f,t[6]=(m*g-d*y+a*A)*f,t[7]=(d*p-M*g-a*b)*f,t[8]=(M*y-m*p+a*v)*f,t):null}function projection(t,a,r){return t[0]=2/a,t[1]=0,t[2]=0,t[3]=0,t[4]=-2/r,t[5]=0,t[6]=-1,t[7]=1,t[8]=1,t}function str$6(t){return"mat3("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+")"}function frob$1(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])}function add$6(t,a,r){return t[0]=a[0]+r[0],t[1]=a[1]+r[1],t[2]=a[2]+r[2],t[3]=a[3]+r[3],t[4]=a[4]+r[4],t[5]=a[5]+r[5],t[6]=a[6]+r[6],t[7]=a[7]+r[7],t[8]=a[8]+r[8],t}function subtract$4(t,a,r){return t[0]=a[0]-r[0],t[1]=a[1]-r[1],t[2]=a[2]-r[2],t[3]=a[3]-r[3],t[4]=a[4]-r[4],t[5]=a[5]-r[5],t[6]=a[6]-r[6],t[7]=a[7]-r[7],t[8]=a[8]-r[8],t}function multiplyScalar$1(t,a,r){return t[0]=a[0]*r,t[1]=a[1]*r,t[2]=a[2]*r,t[3]=a[3]*r,t[4]=a[4]*r,t[5]=a[5]*r,t[6]=a[6]*r,t[7]=a[7]*r,t[8]=a[8]*r,t}function multiplyScalarAndAdd$1(t,a,r,n){return t[0]=a[0]+r[0]*n,t[1]=a[1]+r[1]*n,t[2]=a[2]+r[2]*n,t[3]=a[3]+r[3]*n,t[4]=a[4]+r[4]*n,t[5]=a[5]+r[5]*n,t[6]=a[6]+r[6]*n,t[7]=a[7]+r[7]*n,t[8]=a[8]+r[8]*n,t}function exactEquals$6(t,a){return t[0]===a[0]&&t[1]===a[1]&&t[2]===a[2]&&t[3]===a[3]&&t[4]===a[4]&&t[5]===a[5]&&t[6]===a[6]&&t[7]===a[7]&&t[8]===a[8]}function equals$6(t,a){var r=t[0],n=t[1],e=t[2],o=t[3],u=t[4],s=t[5],i=t[6],c=t[7],t=t[8],l=a[0],$=a[1],h=a[2],f=a[3],M=a[4],m=a[5],d=a[6],v=a[7],a=a[8];return Math.abs(r-l)<=EPSILON*Math.max(1,Math.abs(r),Math.abs(l))&&Math.abs(n-$)<=EPSILON*Math.max(1,Math.abs(n),Math.abs($))&&Math.abs(e-h)<=EPSILON*Math.max(1,Math.abs(e),Math.abs(h))&&Math.abs(o-f)<=EPSILON*Math.max(1,Math.abs(o),Math.abs(f))&&Math.abs(u-M)<=EPSILON*Math.max(1,Math.abs(u),Math.abs(M))&&Math.abs(s-m)<=EPSILON*Math.max(1,Math.abs(s),Math.abs(m))&&Math.abs(i-d)<=EPSILON*Math.max(1,Math.abs(i),Math.abs(d))&&Math.abs(c-v)<=EPSILON*Math.max(1,Math.abs(c),Math.abs(v))&&Math.abs(t-a)<=EPSILON*Math.max(1,Math.abs(t),Math.abs(a))}var mul$6=multiply$6,sub$4=subtract$4,mat3=Object.freeze({__proto__:null,create:create$6,fromMat4:fromMat4$1,clone:clone$6,copy:copy$6,fromValues:fromValues$6,set:set$6,identity:identity$3,transpose:transpose$1,invert:invert$3,adjoint:adjoint$1,determinant:determinant$1,multiply:multiply$6,translate:translate$2,rotate:rotate$2,scale:scale$6,fromTranslation:fromTranslation$2,fromRotation:fromRotation$2,fromScaling:fromScaling$1,fromMat2d:fromMat2d,fromQuat:fromQuat$1,normalFromMat4:normalFromMat4,projection:projection,str:str$6,frob:frob$1,add:add$6,subtract:subtract$4,multiplyScalar:multiplyScalar$1,multiplyScalarAndAdd:multiplyScalarAndAdd$1,exactEquals:exactEquals$6,equals:equals$6,mul:mul$6,sub:sub$4});function create$5(){var t=new ARRAY_TYPE(16);return ARRAY_TYPE!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function clone$5(t){var a=new ARRAY_TYPE(16);return a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7],a[8]=t[8],a[9]=t[9],a[10]=t[10],a[11]=t[11],a[12]=t[12],a[13]=t[13],a[14]=t[14],a[15]=t[15],a}function copy$5(t,a){return t[0]=a[0],t[1]=a[1],t[2]=a[2],t[3]=a[3],t[4]=a[4],t[5]=a[5],t[6]=a[6],t[7]=a[7],t[8]=a[8],t[9]=a[9],t[10]=a[10],t[11]=a[11],t[12]=a[12],t[13]=a[13],t[14]=a[14],t[15]=a[15],t}function fromValues$5(t,a,r,n,e,o,u,s,i,c,l,$,h,f,M,m){var d=new ARRAY_TYPE(16);return d[0]=t,d[1]=a,d[2]=r,d[3]=n,d[4]=e,d[5]=o,d[6]=u,d[7]=s,d[8]=i,d[9]=c,d[10]=l,d[11]=$,d[12]=h,d[13]=f,d[14]=M,d[15]=m,d}function set$5(t,a,r,n,e,o,u,s,i,c,l,$,h,f,M,m,d){return t[0]=a,t[1]=r,t[2]=n,t[3]=e,t[4]=o,t[5]=u,t[6]=s,t[7]=i,t[8]=c,t[9]=l,t[10]=$,t[11]=h,t[12]=f,t[13]=M,t[14]=m,t[15]=d,t}function identity$2(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function transpose(t,a){var r,n,e,o,u,s;return t===a?(r=a[1],n=a[2],e=a[3],o=a[6],u=a[7],s=a[11],t[1]=a[4],t[2]=a[8],t[3]=a[12],t[4]=r,t[6]=a[9],t[7]=a[13],t[8]=n,t[9]=o,t[11]=a[14],t[12]=e,t[13]=u,t[14]=s):(t[0]=a[0],t[1]=a[4],t[2]=a[8],t[3]=a[12],t[4]=a[1],t[5]=a[5],t[6]=a[9],t[7]=a[13],t[8]=a[2],t[9]=a[6],t[10]=a[10],t[11]=a[14],t[12]=a[3],t[13]=a[7],t[14]=a[11],t[15]=a[15]),t}function invert$2(t,a){var r=a[0],n=a[1],e=a[2],o=a[3],u=a[4],s=a[5],i=a[6],c=a[7],l=a[8],$=a[9],h=a[10],f=a[11],M=a[12],m=a[13],d=a[14],a=a[15],v=r*s-n*u,b=r*i-e*u,p=r*c-o*u,A=n*i-e*s,y=n*c-o*s,g=e*c-o*i,R=l*m-$*M,E=l*d-h*M,q=l*a-f*M,x=$*d-h*m,P=$*a-f*m,L=h*a-f*d,O=v*L-b*P+p*x+A*q-y*E+g*R;return O?(t[0]=(s*L-i*P+c*x)*(O=1/O),t[1]=(e*P-n*L-o*x)*O,t[2]=(m*g-d*y+a*A)*O,t[3]=(h*y-$*g-f*A)*O,t[4]=(i*q-u*L-c*E)*O,t[5]=(r*L-e*q+o*E)*O,t[6]=(d*p-M*g-a*b)*O,t[7]=(l*g-h*p+f*b)*O,t[8]=(u*P-s*q+c*R)*O,t[9]=(n*q-r*P-o*R)*O,t[10]=(M*y-m*p+a*v)*O,t[11]=($*p-l*y-f*v)*O,t[12]=(s*E-u*x-i*R)*O,t[13]=(r*x-n*E+e*R)*O,t[14]=(m*b-M*A-d*v)*O,t[15]=(l*A-$*b+h*v)*O,t):null}function adjoint(t,a){var r=a[0],n=a[1],e=a[2],o=a[3],u=a[4],s=a[5],i=a[6],c=a[7],l=a[8],$=a[9],h=a[10],f=a[11],M=a[12],m=a[13],d=a[14],a=a[15],v=r*s-n*u,b=r*i-e*u,p=r*c-o*u,A=n*i-e*s,y=n*c-o*s,g=e*c-o*i,R=l*m-$*M,E=l*d-h*M,q=l*a-f*M,x=$*d-h*m,P=$*a-f*m,L=h*a-f*d;return t[0]=s*L-i*P+c*x,t[1]=e*P-n*L-o*x,t[2]=m*g-d*y+a*A,t[3]=h*y-$*g-f*A,t[4]=i*q-u*L-c*E,t[5]=r*L-e*q+o*E,t[6]=d*p-M*g-a*b,t[7]=l*g-h*p+f*b,t[8]=u*P-s*q+c*R,t[9]=n*q-r*P-o*R,t[10]=M*y-m*p+a*v,t[11]=$*p-l*y-f*v,t[12]=s*E-u*x-i*R,t[13]=r*x-n*E+e*R,t[14]=m*b-M*A-d*v,t[15]=l*A-$*b+h*v,t}function determinant(t){var a=t[0],r=t[1],n=t[2],e=t[4],o=t[5],u=t[6],s=t[8],i=t[9],c=t[10],l=t[12],$=t[13],h=t[14],f=a*o-r*e,M=a*u-n*e,m=r*u-n*o,d=s*$-i*l,v=s*h-c*l,b=i*h-c*$;return t[7]*(a*b-r*v+n*d)-t[3]*(e*b-o*v+u*d)+t[15]*(s*m-i*M+c*f)-t[11]*(l*m-$*M+h*f)}function multiply$5(t,a,r){var n=a[0],e=a[1],o=a[2],u=a[3],s=a[4],i=a[5],c=a[6],l=a[7],$=a[8],h=a[9],f=a[10],M=a[11],m=a[12],d=a[13],v=a[14],a=a[15],b=r[0],p=r[1],A=r[2],y=r[3];return t[0]=b*n+p*s+A*$+y*m,t[1]=b*e+p*i+A*h+y*d,t[2]=b*o+p*c+A*f+y*v,t[3]=b*u+p*l+A*M+y*a,t[4]=(b=r[4])*n+(p=r[5])*s+(A=r[6])*$+(y=r[7])*m,t[5]=b*e+p*i+A*h+y*d,t[6]=b*o+p*c+A*f+y*v,t[7]=b*u+p*l+A*M+y*a,t[8]=(b=r[8])*n+(p=r[9])*s+(A=r[10])*$+(y=r[11])*m,t[9]=b*e+p*i+A*h+y*d,t[10]=b*o+p*c+A*f+y*v,t[11]=b*u+p*l+A*M+y*a,t[12]=(b=r[12])*n+(p=r[13])*s+(A=r[14])*$+(y=r[15])*m,t[13]=b*e+p*i+A*h+y*d,t[14]=b*o+p*c+A*f+y*v,t[15]=b*u+p*l+A*M+y*a,t}function translate$1(t,a,r){var n,e,o,u,s,i,c,l,$,h,f,M,m=r[0],d=r[1],r=r[2];return a===t?(t[12]=a[0]*m+a[4]*d+a[8]*r+a[12],t[13]=a[1]*m+a[5]*d+a[9]*r+a[13],t[14]=a[2]*m+a[6]*d+a[10]*r+a[14],t[15]=a[3]*m+a[7]*d+a[11]*r+a[15]):(n=a[0],e=a[1],o=a[2],u=a[3],s=a[4],i=a[5],c=a[6],l=a[7],$=a[8],h=a[9],f=a[10],M=a[11],t[0]=n,t[1]=e,t[2]=o,t[3]=u,t[4]=s,t[5]=i,t[6]=c,t[7]=l,t[8]=$,t[9]=h,t[10]=f,t[11]=M,t[12]=n*m+s*d+$*r+a[12],t[13]=e*m+i*d+h*r+a[13],t[14]=o*m+c*d+f*r+a[14],t[15]=u*m+l*d+M*r+a[15]),t}function scale$5(t,a,r){var n=r[0],e=r[1],r=r[2];return t[0]=a[0]*n,t[1]=a[1]*n,t[2]=a[2]*n,t[3]=a[3]*n,t[4]=a[4]*e,t[5]=a[5]*e,t[6]=a[6]*e,t[7]=a[7]*e,t[8]=a[8]*r,t[9]=a[9]*r,t[10]=a[10]*r,t[11]=a[11]*r,t[12]=a[12],t[13]=a[13],t[14]=a[14],t[15]=a[15],t}function rotate$1(t,a,r,n){var e,o,u,s,i,c,l,$,h,f,M,m,d,v,b,p,A,y,g,R,E=n[0],q=n[1],n=n[2],x=Math.hypot(E,q,n);return x<EPSILON?null:(E*=x=1/x,q*=x,n*=x,x=Math.sin(r),r=Math.cos(r),o=a[0],u=a[1],s=a[2],i=a[3],l=a[5],$=a[6],h=a[7],M=a[9],m=a[10],d=a[11],b=E*q*(e=1-r)-n*x,p=q*q*e+r,A=n*q*e+E*x,y=E*n*e+q*x,g=q*n*e-E*x,R=n*n*e+r,t[0]=o*(r=E*E*e+r)+(c=a[4])*(v=q*E*e+n*x)+(f=a[8])*(n=n*E*e-q*x),t[1]=u*r+l*v+M*n,t[2]=s*r+$*v+m*n,t[3]=i*r+h*v+d*n,t[4]=o*b+c*p+f*A,t[5]=u*b+l*p+M*A,t[6]=s*b+$*p+m*A,t[7]=i*b+h*p+d*A,t[8]=o*y+c*g+f*R,t[9]=u*y+l*g+M*R,t[10]=s*y+$*g+m*R,t[11]=i*y+h*g+d*R,a!==t&&(t[12]=a[12],t[13]=a[13],t[14]=a[14],t[15]=a[15]),t)}function rotateX$3(t,a,r){var n=Math.sin(r),r=Math.cos(r),e=a[4],o=a[5],u=a[6],s=a[7],i=a[8],c=a[9],l=a[10],$=a[11];return a!==t&&(t[0]=a[0],t[1]=a[1],t[2]=a[2],t[3]=a[3],t[12]=a[12],t[13]=a[13],t[14]=a[14],t[15]=a[15]),t[4]=e*r+i*n,t[5]=o*r+c*n,t[6]=u*r+l*n,t[7]=s*r+$*n,t[8]=i*r-e*n,t[9]=c*r-o*n,t[10]=l*r-u*n,t[11]=$*r-s*n,t}function rotateY$3(t,a,r){var n=Math.sin(r),r=Math.cos(r),e=a[0],o=a[1],u=a[2],s=a[3],i=a[8],c=a[9],l=a[10],$=a[11];return a!==t&&(t[4]=a[4],t[5]=a[5],t[6]=a[6],t[7]=a[7],t[12]=a[12],t[13]=a[13],t[14]=a[14],t[15]=a[15]),t[0]=e*r-i*n,t[1]=o*r-c*n,t[2]=u*r-l*n,t[3]=s*r-$*n,t[8]=e*n+i*r,t[9]=o*n+c*r,t[10]=u*n+l*r,t[11]=s*n+$*r,t}function rotateZ$3(t,a,r){var n=Math.sin(r),r=Math.cos(r),e=a[0],o=a[1],u=a[2],s=a[3],i=a[4],c=a[5],l=a[6],$=a[7];return a!==t&&(t[8]=a[8],t[9]=a[9],t[10]=a[10],t[11]=a[11],t[12]=a[12],t[13]=a[13],t[14]=a[14],t[15]=a[15]),t[0]=e*r+i*n,t[1]=o*r+c*n,t[2]=u*r+l*n,t[3]=s*r+$*n,t[4]=i*r-e*n,t[5]=c*r-o*n,t[6]=l*r-u*n,t[7]=$*r-s*n,t}function fromTranslation$1(t,a){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=a[0],t[13]=a[1],t[14]=a[2],t[15]=1,t}function fromScaling(t,a){return t[0]=a[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=a[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function fromRotation$1(t,a,r){var n,e=r[0],o=r[1],r=r[2],u=Math.hypot(e,o,r);return u<EPSILON?null:(e*=u=1/u,o*=u,r*=u,u=Math.sin(a),a=Math.cos(a),t[0]=e*e*(n=1-a)+a,t[1]=o*e*n+r*u,t[2]=r*e*n-o*u,t[3]=0,t[4]=e*o*n-r*u,t[5]=o*o*n+a,t[6]=r*o*n+e*u,t[7]=0,t[8]=e*r*n+o*u,t[9]=o*r*n-e*u,t[10]=r*r*n+a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}function fromXRotation(t,a){var r=Math.sin(a),a=Math.cos(a);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=r,t[7]=0,t[8]=0,t[9]=-r,t[10]=a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function fromYRotation(t,a){var r=Math.sin(a),a=Math.cos(a);return t[0]=a,t[1]=0,t[2]=-r,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=r,t[9]=0,t[10]=a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function fromZRotation(t,a){var r=Math.sin(a),a=Math.cos(a);return t[0]=a,t[1]=r,t[2]=0,t[3]=0,t[4]=-r,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function fromRotationTranslation$1(t,a,r){var n=a[0],e=a[1],o=a[2],a=a[3],u=n+n,s=e+e,i=o+o,c=n*u,l=n*s,n=n*i,$=e*s,e=e*i,o=o*i,u=a*u,s=a*s,a=a*i;return t[0]=1-($+o),t[1]=l+a,t[2]=n-s,t[3]=0,t[4]=l-a,t[5]=1-(c+o),t[6]=e+u,t[7]=0,t[8]=n+s,t[9]=e-u,t[10]=1-(c+$),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function fromQuat2(t,a){var r=new ARRAY_TYPE(3),n=-a[0],e=-a[1],o=-a[2],u=a[3],s=a[4],i=a[5],c=a[6],l=a[7],$=n*n+e*e+o*o+u*u;return 0<$?(r[0]=2*(s*u+l*n+i*o-c*e)/$,r[1]=2*(i*u+l*e+c*n-s*o)/$,r[2]=2*(c*u+l*o+s*e-i*n)/$):(r[0]=2*(s*u+l*n+i*o-c*e),r[1]=2*(i*u+l*e+c*n-s*o),r[2]=2*(c*u+l*o+s*e-i*n)),fromRotationTranslation$1(t,a,r),t}function getTranslation$1(t,a){return t[0]=a[12],t[1]=a[13],t[2]=a[14],t}function getScaling(t,a){var r=a[0],n=a[4],e=a[5],o=a[6],u=a[8],s=a[9],i=a[10];return t[0]=Math.hypot(r,a[1],a[2]),t[1]=Math.hypot(n,e,o),t[2]=Math.hypot(u,s,i),t}function getRotation(t,a){var r=new ARRAY_TYPE(3),n=(getScaling(r,a),1/r[0]),e=1/r[1],r=1/r[2],o=a[0]*n,u=a[1]*e,s=a[2]*r,i=a[4]*n,c=a[5]*e,l=a[6]*r,n=a[8]*n,e=a[9]*e,a=a[10]*r,r=o+c+a,$=0;return 0<r?($=2*Math.sqrt(1+r),t[3]=.25*$,t[0]=(l-e)/$,t[1]=(n-s)/$,t[2]=(u-i)/$):c<o&&a<o?($=2*Math.sqrt(1+o-c-a),t[3]=(l-e)/$,t[0]=.25*$,t[1]=(u+i)/$,t[2]=(n+s)/$):a<c?($=2*Math.sqrt(1+c-o-a),t[3]=(n-s)/$,t[0]=(u+i)/$,t[1]=.25*$,t[2]=(l+e)/$):($=2*Math.sqrt(1+a-o-c),t[3]=(u-i)/$,t[0]=(n+s)/$,t[1]=(l+e)/$,t[2]=.25*$),t}function decompose(t,a,r,n){a[0]=n[12],a[1]=n[13],a[2]=n[14];var a=n[0],e=n[1],o=n[2],u=n[4],s=n[5],i=n[6],c=n[8],l=n[9],n=n[10],$=(r[0]=Math.hypot(a,e,o),r[1]=Math.hypot(u,s,i),r[2]=Math.hypot(c,l,n),1/r[0]),h=1/r[1],r=1/r[2],a=a*$,e=e*h,o=o*r,u=u*$,s=s*h,i=i*r,c=c*$,$=l*h,l=n*r,h=a+s+l,n=0;return 0<h?(n=2*Math.sqrt(1+h),t[3]=.25*n,t[0]=(i-$)/n,t[1]=(c-o)/n,t[2]=(e-u)/n):s<a&&l<a?(n=2*Math.sqrt(1+a-s-l),t[3]=(i-$)/n,t[0]=.25*n,t[1]=(e+u)/n,t[2]=(c+o)/n):l<s?(n=2*Math.sqrt(1+s-a-l),t[3]=(c-o)/n,t[0]=(e+u)/n,t[1]=.25*n,t[2]=(i+$)/n):(n=2*Math.sqrt(1+l-a-s),t[3]=(e-u)/n,t[0]=(c+o)/n,t[1]=(i+$)/n,t[2]=.25*n),t}function fromRotationTranslationScale(t,a,r,n){var e=a[0],o=a[1],u=a[2],a=a[3],s=e+e,i=o+o,c=u+u,l=e*s,$=e*i,e=e*c,h=o*i,o=o*c,u=u*c,s=a*s,i=a*i,a=a*c,c=n[0],f=n[1],n=n[2];return t[0]=(1-(h+u))*c,t[1]=($+a)*c,t[2]=(e-i)*c,t[3]=0,t[4]=($-a)*f,t[5]=(1-(l+u))*f,t[6]=(o+s)*f,t[7]=0,t[8]=(e+i)*n,t[9]=(o-s)*n,t[10]=(1-(l+h))*n,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function fromRotationTranslationScaleOrigin(t,a,r,n,e){var o=a[0],u=a[1],s=a[2],a=a[3],i=o+o,c=u+u,l=s+s,$=o*i,h=o*c,o=o*l,f=u*c,u=u*l,s=s*l,i=a*i,c=a*c,a=a*l,l=n[0],M=n[1],n=n[2],m=e[0],d=e[1],e=e[2],v=(1-(f+s))*l,b=(h+a)*l,l=(o-c)*l,h=(h-a)*M,a=(1-($+s))*M,s=(u+i)*M,M=(o+c)*n,o=(u-i)*n,c=(1-($+f))*n;return t[0]=v,t[1]=b,t[2]=l,t[3]=0,t[4]=h,t[5]=a,t[6]=s,t[7]=0,t[8]=M,t[9]=o,t[10]=c,t[11]=0,t[12]=r[0]+m-(v*m+h*d+M*e),t[13]=r[1]+d-(b*m+a*d+o*e),t[14]=r[2]+e-(l*m+s*d+c*e),t[15]=1,t}function fromQuat(t,a){var r=a[0],n=a[1],e=a[2],a=a[3],o=r+r,u=n+n,s=e+e,r=r*o,i=n*o,n=n*u,c=e*o,l=e*u,e=e*s,o=a*o,u=a*u,a=a*s;return t[0]=1-n-e,t[1]=i+a,t[2]=c-u,t[3]=0,t[4]=i-a,t[5]=1-r-e,t[6]=l+o,t[7]=0,t[8]=c+u,t[9]=l-o,t[10]=1-r-n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function frustum(t,a,r,n,e,o,u){var s=1/(r-a),i=1/(e-n),c=1/(o-u);return t[0]=2*o*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=2*o*i,t[6]=0,t[7]=0,t[8]=(r+a)*s,t[9]=(e+n)*i,t[10]=(u+o)*c,t[11]=-1,t[12]=0,t[13]=0,t[14]=u*o*2*c,t[15]=0,t}function perspectiveNO(t,a,r,n,e){a=1/Math.tan(a/2);return t[0]=a/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=e&&e!==1/0?(t[10]=(e+n)*(r=1/(n-e)),t[14]=2*e*n*r):(t[10]=-1,t[14]=-2*n),t}var perspective=perspectiveNO;function perspectiveZO(t,a,r,n,e){a=1/Math.tan(a/2);return t[0]=a/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=e&&e!==1/0?(t[10]=e*(r=1/(n-e)),t[14]=e*n*r):(t[10]=-1,t[14]=-n),t}function perspectiveFromFieldOfView(t,a,r,n){var e=Math.tan(a.upDegrees*Math.PI/180),o=Math.tan(a.downDegrees*Math.PI/180),u=Math.tan(a.leftDegrees*Math.PI/180),a=Math.tan(a.rightDegrees*Math.PI/180),s=2/(u+a),i=2/(e+o);return t[0]=s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i,t[6]=0,t[7]=0,t[8]=-(u-a)*s*.5,t[9]=(e-o)*i*.5,t[10]=n/(r-n),t[11]=-1,t[12]=0,t[13]=0,t[14]=n*r/(r-n),t[15]=0,t}function orthoNO(t,a,r,n,e,o,u){var s=1/(a-r),i=1/(n-e),c=1/(o-u);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*i,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(a+r)*s,t[13]=(e+n)*i,t[14]=(u+o)*c,t[15]=1,t}var ortho=orthoNO;function orthoZO(t,a,r,n,e,o,u){var s=1/(a-r),i=1/(n-e),u=1/(o-u);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*i,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=u,t[11]=0,t[12]=(a+r)*s,t[13]=(e+n)*i,t[14]=o*u,t[15]=1,t}function lookAt(t,a,r,n){var e,o,u,s,i=a[0],c=a[1],a=a[2],l=n[0],$=n[1],n=n[2],h=r[0],f=r[1],r=r[2];return Math.abs(i-h)<EPSILON&&Math.abs(c-f)<EPSILON&&Math.abs(a-r)<EPSILON?identity$2(t):(h=i-h,f=c-f,r=a-r,e=$*(r*=s=1/Math.hypot(h,f,r))-n*(f*=s),n=n*(h*=s)-l*r,l=l*f-$*h,(s=Math.hypot(e,n,l))?(e*=s=1/s,n*=s,l*=s):l=n=e=0,$=f*l-r*n,o=r*e-h*l,u=h*n-f*e,(s=Math.hypot($,o,u))?($*=s=1/s,o*=s,u*=s):u=o=$=0,t[0]=e,t[1]=$,t[2]=h,t[3]=0,t[4]=n,t[5]=o,t[6]=f,t[7]=0,t[8]=l,t[9]=u,t[10]=r,t[11]=0,t[12]=-(e*i+n*c+l*a),t[13]=-($*i+o*c+u*a),t[14]=-(h*i+f*c+r*a),t[15]=1,t)}function targetTo(t,a,r,n){var e=a[0],o=a[1],a=a[2],u=n[0],s=n[1],n=n[2],i=e-r[0],c=o-r[1],r=a-r[2],l=i*i+c*c+r*r,$=(0<l&&(i*=l=1/Math.sqrt(l),c*=l,r*=l),s*r-n*c),n=n*i-u*r,u=u*c-s*i;return 0<(l=$*$+n*n+u*u)&&($*=l=1/Math.sqrt(l),n*=l,u*=l),t[0]=$,t[1]=n,t[2]=u,t[3]=0,t[4]=c*u-r*n,t[5]=r*$-i*u,t[6]=i*n-c*$,t[7]=0,t[8]=i,t[9]=c,t[10]=r,t[11]=0,t[12]=e,t[13]=o,t[14]=a,t[15]=1,t}function str$5(t){return"mat4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+", "+t[9]+", "+t[10]+", "+t[11]+", "+t[12]+", "+t[13]+", "+t[14]+", "+t[15]+")"}function frob(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15])}function add$5(t,a,r){return t[0]=a[0]+r[0],t[1]=a[1]+r[1],t[2]=a[2]+r[2],t[3]=a[3]+r[3],t[4]=a[4]+r[4],t[5]=a[5]+r[5],t[6]=a[6]+r[6],t[7]=a[7]+r[7],t[8]=a[8]+r[8],t[9]=a[9]+r[9],t[10]=a[10]+r[10],t[11]=a[11]+r[11],t[12]=a[12]+r[12],t[13]=a[13]+r[13],t[14]=a[14]+r[14],t[15]=a[15]+r[15],t}function subtract$3(t,a,r){return t[0]=a[0]-r[0],t[1]=a[1]-r[1],t[2]=a[2]-r[2],t[3]=a[3]-r[3],t[4]=a[4]-r[4],t[5]=a[5]-r[5],t[6]=a[6]-r[6],t[7]=a[7]-r[7],t[8]=a[8]-r[8],t[9]=a[9]-r[9],t[10]=a[10]-r[10],t[11]=a[11]-r[11],t[12]=a[12]-r[12],t[13]=a[13]-r[13],t[14]=a[14]-r[14],t[15]=a[15]-r[15],t}function multiplyScalar(t,a,r){return t[0]=a[0]*r,t[1]=a[1]*r,t[2]=a[2]*r,t[3]=a[3]*r,t[4]=a[4]*r,t[5]=a[5]*r,t[6]=a[6]*r,t[7]=a[7]*r,t[8]=a[8]*r,t[9]=a[9]*r,t[10]=a[10]*r,t[11]=a[11]*r,t[12]=a[12]*r,t[13]=a[13]*r,t[14]=a[14]*r,t[15]=a[15]*r,t}function multiplyScalarAndAdd(t,a,r,n){return t[0]=a[0]+r[0]*n,t[1]=a[1]+r[1]*n,t[2]=a[2]+r[2]*n,t[3]=a[3]+r[3]*n,t[4]=a[4]+r[4]*n,t[5]=a[5]+r[5]*n,t[6]=a[6]+r[6]*n,t[7]=a[7]+r[7]*n,t[8]=a[8]+r[8]*n,t[9]=a[9]+r[9]*n,t[10]=a[10]+r[10]*n,t[11]=a[11]+r[11]*n,t[12]=a[12]+r[12]*n,t[13]=a[13]+r[13]*n,t[14]=a[14]+r[14]*n,t[15]=a[15]+r[15]*n,t}function exactEquals$5(t,a){return t[0]===a[0]&&t[1]===a[1]&&t[2]===a[2]&&t[3]===a[3]&&t[4]===a[4]&&t[5]===a[5]&&t[6]===a[6]&&t[7]===a[7]&&t[8]===a[8]&&t[9]===a[9]&&t[10]===a[10]&&t[11]===a[11]&&t[12]===a[12]&&t[13]===a[13]&&t[14]===a[14]&&t[15]===a[15]}function equals$5(t,a){var r=t[0],n=t[1],e=t[2],o=t[3],u=t[4],s=t[5],i=t[6],c=t[7],l=t[8],$=t[9],h=t[10],f=t[11],M=t[12],m=t[13],d=t[14],t=t[15],v=a[0],b=a[1],p=a[2],A=a[3],y=a[4],g=a[5],R=a[6],E=a[7],q=a[8],x=a[9],P=a[10],L=a[11],O=a[12],S=a[13],Y=a[14],a=a[15];return Math.abs(r-v)<=EPSILON*Math.max(1,Math.abs(r),Math.abs(v))&&Math.abs(n-b)<=EPSILON*Math.max(1,Math.abs(n),Math.abs(b))&&Math.abs(e-p)<=EPSILON*Math.max(1,Math.abs(e),Math.abs(p))&&Math.abs(o-A)<=EPSILON*Math.max(1,Math.abs(o),Math.abs(A))&&Math.abs(u-y)<=EPSILON*Math.max(1,Math.abs(u),Math.abs(y))&&Math.abs(s-g)<=EPSILON*Math.max(1,Math.abs(s),Math.abs(g))&&Math.abs(i-R)<=EPSILON*Math.max(1,Math.abs(i),Math.abs(R))&&Math.abs(c-E)<=EPSILON*Math.max(1,Math.abs(c),Math.abs(E))&&Math.abs(l-q)<=EPSILON*Math.max(1,Math.abs(l),Math.abs(q))&&Math.abs($-x)<=EPSILON*Math.max(1,Math.abs($),Math.abs(x))&&Math.abs(h-P)<=EPSILON*Math.max(1,Math.abs(h),Math.abs(P))&&Math.abs(f-L)<=EPSILON*Math.max(1,Math.abs(f),Math.abs(L))&&Math.abs(M-O)<=EPSILON*Math.max(1,Math.abs(M),Math.abs(O))&&Math.abs(m-S)<=EPSILON*Math.max(1,Math.abs(m),Math.abs(S))&&Math.abs(d-Y)<=EPSILON*Math.max(1,Math.abs(d),Math.abs(Y))&&Math.abs(t-a)<=EPSILON*Math.max(1,Math.abs(t),Math.abs(a))}var mul$5=multiply$5,sub$3=subtract$3,mat4=Object.freeze({__proto__:null,create:create$5,clone:clone$5,copy:copy$5,fromValues:fromValues$5,set:set$5,identity:identity$2,transpose:transpose,invert:invert$2,adjoint:adjoint,determinant:determinant,multiply:multiply$5,translate:translate$1,scale:scale$5,rotate:rotate$1,rotateX:rotateX$3,rotateY:rotateY$3,rotateZ:rotateZ$3,fromTranslation:fromTranslation$1,fromScaling:fromScaling,fromRotation:fromRotation$1,fromXRotation:fromXRotation,fromYRotation:fromYRotation,fromZRotation:fromZRotation,fromRotationTranslation:fromRotationTranslation$1,fromQuat2:fromQuat2,getTranslation:getTranslation$1,getScaling:getScaling,getRotation:getRotation,decompose:decompose,fromRotationTranslationScale:fromRotationTranslationScale,fromRotationTranslationScaleOrigin:fromRotationTranslationScaleOrigin,fromQuat:fromQuat,frustum:frustum,perspectiveNO:perspectiveNO,perspective:perspective,perspectiveZO:perspectiveZO,perspectiveFromFieldOfView:perspectiveFromFieldOfView,orthoNO:orthoNO,ortho:ortho,orthoZO:orthoZO,lookAt:lookAt,targetTo:targetTo,str:str$5,frob:frob,add:add$5,subtract:subtract$3,multiplyScalar:multiplyScalar,multiplyScalarAndAdd:multiplyScalarAndAdd,exactEquals:exactEquals$5,equals:equals$5,mul:mul$5,sub:sub$3});function create$4(){var t=new ARRAY_TYPE(3);return ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function clone$4(t){var a=new ARRAY_TYPE(3);return a[0]=t[0],a[1]=t[1],a[2]=t[2],a}function length$4(t){var a=t[0];return Math.hypot(a,t[1],t[2])}function fromValues$4(t,a,r){var n=new ARRAY_TYPE(3);return n[0]=t,n[1]=a,n[2]=r,n}function copy$4(t,a){return t[0]=a[0],t[1]=a[1],t[2]=a[2],t}function set$4(t,a,r,n){return t[0]=a,t[1]=r,t[2]=n,t}function add$4(t,a,r){return t[0]=a[0]+r[0],t[1]=a[1]+r[1],t[2]=a[2]+r[2],t}function subtract$2(t,a,r){return t[0]=a[0]-r[0],t[1]=a[1]-r[1],t[2]=a[2]-r[2],t}function multiply$4(t,a,r){return t[0]=a[0]*r[0],t[1]=a[1]*r[1],t[2]=a[2]*r[2],t}function divide$2(t,a,r){return t[0]=a[0]/r[0],t[1]=a[1]/r[1],t[2]=a[2]/r[2],t}function ceil$2(t,a){return t[0]=Math.ceil(a[0]),t[1]=Math.ceil(a[1]),t[2]=Math.ceil(a[2]),t}function floor$2(t,a){return t[0]=Math.floor(a[0]),t[1]=Math.floor(a[1]),t[2]=Math.floor(a[2]),t}function min$2(t,a,r){return t[0]=Math.min(a[0],r[0]),t[1]=Math.min(a[1],r[1]),t[2]=Math.min(a[2],r[2]),t}function max$2(t,a,r){return t[0]=Math.max(a[0],r[0]),t[1]=Math.max(a[1],r[1]),t[2]=Math.max(a[2],r[2]),t}function round$2(t,a){return t[0]=Math.round(a[0]),t[1]=Math.round(a[1]),t[2]=Math.round(a[2]),t}function scale$4(t,a,r){return t[0]=a[0]*r,t[1]=a[1]*r,t[2]=a[2]*r,t}function scaleAndAdd$2(t,a,r,n){return t[0]=a[0]+r[0]*n,t[1]=a[1]+r[1]*n,t[2]=a[2]+r[2]*n,t}function distance$2(t,a){var r=a[0]-t[0];return Math.hypot(r,a[1]-t[1],a[2]-t[2])}function squaredDistance$2(t,a){var r=a[0]-t[0],n=a[1]-t[1],a=a[2]-t[2];return r*r+n*n+a*a}function squaredLength$4(t){var a=t[0],r=t[1],t=t[2];return a*a+r*r+t*t}function negate$2(t,a){return t[0]=-a[0],t[1]=-a[1],t[2]=-a[2],t}function inverse$2(t,a){return t[0]=1/a[0],t[1]=1/a[1],t[2]=1/a[2],t}function normalize$4(t,a){var r=a[0],n=a[1],e=a[2],r=r*r+n*n+e*e;return 0<r&&(r=1/Math.sqrt(r)),t[0]=a[0]*r,t[1]=a[1]*r,t[2]=a[2]*r,t}function dot$4(t,a){return t[0]*a[0]+t[1]*a[1]+t[2]*a[2]}function cross$2(t,a,r){var n=a[0],e=a[1],a=a[2],o=r[0],u=r[1],r=r[2];return t[0]=e*r-a*u,t[1]=a*o-n*r,t[2]=n*u-e*o,t}function lerp$4(t,a,r,n){var e=a[0],o=a[1],a=a[2];return t[0]=e+n*(r[0]-e),t[1]=o+n*(r[1]-o),t[2]=a+n*(r[2]-a),t}function slerp$1(t,a,r,n){var e=Math.acos(Math.min(Math.max(dot$4(a,r),-1),1)),o=Math.sin(e),u=Math.sin((1-n)*e)/o,n=Math.sin(n*e)/o;return t[0]=u*a[0]+n*r[0],t[1]=u*a[1]+n*r[1],t[2]=u*a[2]+n*r[2],t}function hermite(t,a,r,n,e,o){var u=o*o,s=u*(2*o-3)+1,i=u*(o-2)+o,c=u*(o-1),u=u*(3-2*o);return t[0]=a[0]*s+r[0]*i+n[0]*c+e[0]*u,t[1]=a[1]*s+r[1]*i+n[1]*c+e[1]*u,t[2]=a[2]*s+r[2]*i+n[2]*c+e[2]*u,t}function bezier(t,a,r,n,e,o){var u=1-o,s=u*u,i=o*o,c=s*u,s=3*o*s,u=3*i*u,i=i*o;return t[0]=a[0]*c+r[0]*s+n[0]*u+e[0]*i,t[1]=a[1]*c+r[1]*s+n[1]*u+e[1]*i,t[2]=a[2]*c+r[2]*s+n[2]*u+e[2]*i,t}function random$3(t,a){a=a||1;var r=2*RANDOM()*Math.PI,n=2*RANDOM()-1,e=Math.sqrt(1-n*n)*a;return t[0]=Math.cos(r)*e,t[1]=Math.sin(r)*e,t[2]=n*a,t}function transformMat4$2(t,a,r){var n=a[0],e=a[1],a=a[2],o=r[3]*n+r[7]*e+r[11]*a+r[15];return t[0]=(r[0]*n+r[4]*e+r[8]*a+r[12])/(o=o||1),t[1]=(r[1]*n+r[5]*e+r[9]*a+r[13])/o,t[2]=(r[2]*n+r[6]*e+r[10]*a+r[14])/o,t}function transformMat3$1(t,a,r){var n=a[0],e=a[1],a=a[2];return t[0]=n*r[0]+e*r[3]+a*r[6],t[1]=n*r[1]+e*r[4]+a*r[7],t[2]=n*r[2]+e*r[5]+a*r[8],t}function transformQuat$1(t,a,r){var n=r[0],e=r[1],o=r[2],u=a[0],s=a[1],a=a[2],i=e*a-o*s,c=o*u-n*a,l=n*s-e*u,$=e*l-o*c,o=o*i-n*l,n=n*c-e*i,e=2*r[3];return c*=e,l*=e,o*=2,n*=2,t[0]=u+(i*=e)+($*=2),t[1]=s+c+o,t[2]=a+l+n,t}function rotateX$2(t,a,r,n){var e=[],o=[];return e[0]=a[0]-r[0],e[1]=a[1]-r[1],e[2]=a[2]-r[2],o[0]=e[0],o[1]=e[1]*Math.cos(n)-e[2]*Math.sin(n),o[2]=e[1]*Math.sin(n)+e[2]*Math.cos(n),t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function rotateY$2(t,a,r,n){var e=[],o=[];return e[0]=a[0]-r[0],e[1]=a[1]-r[1],e[2]=a[2]-r[2],o[0]=e[2]*Math.sin(n)+e[0]*Math.cos(n),o[1]=e[1],o[2]=e[2]*Math.cos(n)-e[0]*Math.sin(n),t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function rotateZ$2(t,a,r,n){var e=[],o=[];return e[0]=a[0]-r[0],e[1]=a[1]-r[1],e[2]=a[2]-r[2],o[0]=e[0]*Math.cos(n)-e[1]*Math.sin(n),o[1]=e[0]*Math.sin(n)+e[1]*Math.cos(n),o[2]=e[2],t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function angle$1(t,a){var r=t[0],n=t[1],e=t[2],o=a[0],u=a[1],s=a[2],r=Math.sqrt((r*r+n*n+e*e)*(o*o+u*u+s*s)),n=r&&dot$4(t,a)/r;return Math.acos(Math.min(Math.max(n,-1),1))}function zero$2(t){return t[0]=0,t[1]=0,t[2]=0,t}function str$4(t){return"vec3("+t[0]+", "+t[1]+", "+t[2]+")"}function exactEquals$4(t,a){return t[0]===a[0]&&t[1]===a[1]&&t[2]===a[2]}function equals$4(t,a){var r=t[0],n=t[1],t=t[2],e=a[0],o=a[1],a=a[2];return Math.abs(r-e)<=EPSILON*Math.max(1,Math.abs(r),Math.abs(e))&&Math.abs(n-o)<=EPSILON*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(t-a)<=EPSILON*Math.max(1,Math.abs(t),Math.abs(a))}var sub$2=subtract$2,mul$4=multiply$4,div$2=divide$2,dist$2=distance$2,sqrDist$2=squaredDistance$2,len$4=length$4,sqrLen$4=squaredLength$4,forEach$2=function(){var i=create$4();return function(t,a,r,n,e,o){var u,s;for(a=a||3,r=r||0,s=n?Math.min(n*a+r,t.length):t.length,u=r;u<s;u+=a)i[0]=t[u],i[1]=t[u+1],i[2]=t[u+2],e(i,i,o),t[u]=i[0],t[u+1]=i[1],t[u+2]=i[2];return t}}(),vec3=Object.freeze({__proto__:null,create:create$4,clone:clone$4,length:length$4,fromValues:fromValues$4,copy:copy$4,set:set$4,add:add$4,subtract:subtract$2,multiply:multiply$4,divide:divide$2,ceil:ceil$2,floor:floor$2,min:min$2,max:max$2,round:round$2,scale:scale$4,scaleAndAdd:scaleAndAdd$2,distance:distance$2,squaredDistance:squaredDistance$2,squaredLength:squaredLength$4,negate:negate$2,inverse:inverse$2,normalize:normalize$4,dot:dot$4,cross:cross$2,lerp:lerp$4,slerp:slerp$1,hermite:hermite,bezier:bezier,random:random$3,transformMat4:transformMat4$2,transformMat3:transformMat3$1,transformQuat:transformQuat$1,rotateX:rotateX$2,rotateY:rotateY$2,rotateZ:rotateZ$2,angle:angle$1,zero:zero$2,str:str$4,exactEquals:exactEquals$4,equals:equals$4,sub:sub$2,mul:mul$4,div:div$2,dist:dist$2,sqrDist:sqrDist$2,len:len$4,sqrLen:sqrLen$4,forEach:forEach$2});function create$3(){var t=new ARRAY_TYPE(4);return ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function clone$3(t){var a=new ARRAY_TYPE(4);return a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a}function fromValues$3(t,a,r,n){var e=new ARRAY_TYPE(4);return e[0]=t,e[1]=a,e[2]=r,e[3]=n,e}function copy$3(t,a){return t[0]=a[0],t[1]=a[1],t[2]=a[2],t[3]=a[3],t}function set$3(t,a,r,n,e){return t[0]=a,t[1]=r,t[2]=n,t[3]=e,t}function add$3(t,a,r){return t[0]=a[0]+r[0],t[1]=a[1]+r[1],t[2]=a[2]+r[2],t[3]=a[3]+r[3],t}function subtract$1(t,a,r){return t[0]=a[0]-r[0],t[1]=a[1]-r[1],t[2]=a[2]-r[2],t[3]=a[3]-r[3],t}function multiply$3(t,a,r){return t[0]=a[0]*r[0],t[1]=a[1]*r[1],t[2]=a[2]*r[2],t[3]=a[3]*r[3],t}function divide$1(t,a,r){return t[0]=a[0]/r[0],t[1]=a[1]/r[1],t[2]=a[2]/r[2],t[3]=a[3]/r[3],t}function ceil$1(t,a){return t[0]=Math.ceil(a[0]),t[1]=Math.ceil(a[1]),t[2]=Math.ceil(a[2]),t[3]=Math.ceil(a[3]),t}function floor$1(t,a){return t[0]=Math.floor(a[0]),t[1]=Math.floor(a[1]),t[2]=Math.floor(a[2]),t[3]=Math.floor(a[3]),t}function min$1(t,a,r){return t[0]=Math.min(a[0],r[0]),t[1]=Math.min(a[1],r[1]),t[2]=Math.min(a[2],r[2]),t[3]=Math.min(a[3],r[3]),t}function max$1(t,a,r){return t[0]=Math.max(a[0],r[0]),t[1]=Math.max(a[1],r[1]),t[2]=Math.max(a[2],r[2]),t[3]=Math.max(a[3],r[3]),t}function round$1(t,a){return t[0]=Math.round(a[0]),t[1]=Math.round(a[1]),t[2]=Math.round(a[2]),t[3]=Math.round(a[3]),t}function scale$3(t,a,r){return t[0]=a[0]*r,t[1]=a[1]*r,t[2]=a[2]*r,t[3]=a[3]*r,t}function scaleAndAdd$1(t,a,r,n){return t[0]=a[0]+r[0]*n,t[1]=a[1]+r[1]*n,t[2]=a[2]+r[2]*n,t[3]=a[3]+r[3]*n,t}function distance$1(t,a){var r=a[0]-t[0];return Math.hypot(r,a[1]-t[1],a[2]-t[2],a[3]-t[3])}function squaredDistance$1(t,a){var r=a[0]-t[0],n=a[1]-t[1],e=a[2]-t[2],a=a[3]-t[3];return r*r+n*n+e*e+a*a}function length$3(t){var a=t[0];return Math.hypot(a,t[1],t[2],t[3])}function squaredLength$3(t){var a=t[0],r=t[1],n=t[2],t=t[3];return a*a+r*r+n*n+t*t}function negate$1(t,a){return t[0]=-a[0],t[1]=-a[1],t[2]=-a[2],t[3]=-a[3],t}function inverse$1(t,a){return t[0]=1/a[0],t[1]=1/a[1],t[2]=1/a[2],t[3]=1/a[3],t}function normalize$3(t,a){var r=a[0],n=a[1],e=a[2],a=a[3],o=r*r+n*n+e*e+a*a;return 0<o&&(o=1/Math.sqrt(o)),t[0]=r*o,t[1]=n*o,t[2]=e*o,t[3]=a*o,t}function dot$3(t,a){return t[0]*a[0]+t[1]*a[1]+t[2]*a[2]+t[3]*a[3]}function cross$1(t,a,r,n){var e=r[0]*n[1]-r[1]*n[0],o=r[0]*n[2]-r[2]*n[0],u=r[0]*n[3]-r[3]*n[0],s=r[1]*n[2]-r[2]*n[1],i=r[1]*n[3]-r[3]*n[1],r=r[2]*n[3]-r[3]*n[2],n=a[0],c=a[1],l=a[2],a=a[3];return t[0]=c*r-l*i+a*s,t[1]=-n*r+l*u-a*o,t[2]=n*i-c*u+a*e,t[3]=-n*s+c*o-l*e,t}function lerp$3(t,a,r,n){var e=a[0],o=a[1],u=a[2],a=a[3];return t[0]=e+n*(r[0]-e),t[1]=o+n*(r[1]-o),t[2]=u+n*(r[2]-u),t[3]=a+n*(r[3]-a),t}function random$2(t,a){var r,n,e,o,u,s;for(a=a||1;1<=(u=(r=2*RANDOM()-1)*r+(n=2*RANDOM()-1)*n););for(;1<=(s=(e=2*RANDOM()-1)*e+(o=2*RANDOM()-1)*o););var i=Math.sqrt((1-u)/s);return t[0]=a*r,t[1]=a*n,t[2]=a*e*i,t[3]=a*o*i,t}function transformMat4$1(t,a,r){var n=a[0],e=a[1],o=a[2],a=a[3];return t[0]=r[0]*n+r[4]*e+r[8]*o+r[12]*a,t[1]=r[1]*n+r[5]*e+r[9]*o+r[13]*a,t[2]=r[2]*n+r[6]*e+r[10]*o+r[14]*a,t[3]=r[3]*n+r[7]*e+r[11]*o+r[15]*a,t}function transformQuat(t,a,r){var n=a[0],e=a[1],o=a[2],u=r[0],s=r[1],i=r[2],r=r[3],c=r*n+s*o-i*e,l=r*e+i*n-u*o,$=r*o+u*e-s*n,n=-u*n-s*e-i*o;return t[0]=c*r+n*-u+l*-i-$*-s,t[1]=l*r+n*-s+$*-u-c*-i,t[2]=$*r+n*-i+c*-s-l*-u,t[3]=a[3],t}function zero$1(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t}function str$3(t){return"vec4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"}function exactEquals$3(t,a){return t[0]===a[0]&&t[1]===a[1]&&t[2]===a[2]&&t[3]===a[3]}function equals$3(t,a){var r=t[0],n=t[1],e=t[2],t=t[3],o=a[0],u=a[1],s=a[2],a=a[3];return Math.abs(r-o)<=EPSILON*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(n-u)<=EPSILON*Math.max(1,Math.abs(n),Math.abs(u))&&Math.abs(e-s)<=EPSILON*Math.max(1,Math.abs(e),Math.abs(s))&&Math.abs(t-a)<=EPSILON*Math.max(1,Math.abs(t),Math.abs(a))}var sub$1=subtract$1,mul$3=multiply$3,div$1=divide$1,dist$1=distance$1,sqrDist$1=squaredDistance$1,len$3=length$3,sqrLen$3=squaredLength$3,forEach$1=function(){var i=create$3();return function(t,a,r,n,e,o){var u,s;for(a=a||4,r=r||0,s=n?Math.min(n*a+r,t.length):t.length,u=r;u<s;u+=a)i[0]=t[u],i[1]=t[u+1],i[2]=t[u+2],i[3]=t[u+3],e(i,i,o),t[u]=i[0],t[u+1]=i[1],t[u+2]=i[2],t[u+3]=i[3];return t}}(),vec4=Object.freeze({__proto__:null,create:create$3,clone:clone$3,fromValues:fromValues$3,copy:copy$3,set:set$3,add:add$3,subtract:subtract$1,multiply:multiply$3,divide:divide$1,ceil:ceil$1,floor:floor$1,min:min$1,max:max$1,round:round$1,scale:scale$3,scaleAndAdd:scaleAndAdd$1,distance:distance$1,squaredDistance:squaredDistance$1,length:length$3,squaredLength:squaredLength$3,negate:negate$1,inverse:inverse$1,normalize:normalize$3,dot:dot$3,cross:cross$1,lerp:lerp$3,random:random$2,transformMat4:transformMat4$1,transformQuat:transformQuat,zero:zero$1,str:str$3,exactEquals:exactEquals$3,equals:equals$3,sub:sub$1,mul:mul$3,div:div$1,dist:dist$1,sqrDist:sqrDist$1,len:len$3,sqrLen:sqrLen$3,forEach:forEach$1});function create$2(){var t=new ARRAY_TYPE(4);return ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function identity$1(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function setAxisAngle(t,a,r){r*=.5;var n=Math.sin(r);return t[0]=n*a[0],t[1]=n*a[1],t[2]=n*a[2],t[3]=Math.cos(r),t}function getAxisAngle(t,a){var r=2*Math.acos(a[3]),n=Math.sin(r/2);return EPSILON<n?(t[0]=a[0]/n,t[1]=a[1]/n,t[2]=a[2]/n):(t[0]=1,t[1]=0,t[2]=0),r}function getAngle(t,a){t=dot$2(t,a);return Math.acos(2*t*t-1)}function multiply$2(t,a,r){var n=a[0],e=a[1],o=a[2],a=a[3],u=r[0],s=r[1],i=r[2],r=r[3];return t[0]=n*r+a*u+e*i-o*s,t[1]=e*r+a*s+o*u-n*i,t[2]=o*r+a*i+n*s-e*u,t[3]=a*r-n*u-e*s-o*i,t}function rotateX$1(t,a,r){r*=.5;var n=a[0],e=a[1],o=a[2],a=a[3],u=Math.sin(r),r=Math.cos(r);return t[0]=n*r+a*u,t[1]=e*r+o*u,t[2]=o*r-e*u,t[3]=a*r-n*u,t}function rotateY$1(t,a,r){r*=.5;var n=a[0],e=a[1],o=a[2],a=a[3],u=Math.sin(r),r=Math.cos(r);return t[0]=n*r-o*u,t[1]=e*r+a*u,t[2]=o*r+n*u,t[3]=a*r-e*u,t}function rotateZ$1(t,a,r){r*=.5;var n=a[0],e=a[1],o=a[2],a=a[3],u=Math.sin(r),r=Math.cos(r);return t[0]=n*r+e*u,t[1]=e*r-n*u,t[2]=o*r+a*u,t[3]=a*r-o*u,t}function calculateW(t,a){var r=a[0],n=a[1],a=a[2];return t[0]=r,t[1]=n,t[2]=a,t[3]=Math.sqrt(Math.abs(1-r*r-n*n-a*a)),t}function exp(t,a){var r=a[0],n=a[1],e=a[2],a=a[3],o=Math.sqrt(r*r+n*n+e*e),a=Math.exp(a),u=0<o?a*Math.sin(o)/o:0;return t[0]=r*u,t[1]=n*u,t[2]=e*u,t[3]=a*Math.cos(o),t}function ln(t,a){var r=a[0],n=a[1],e=a[2],a=a[3],o=Math.sqrt(r*r+n*n+e*e),o=0<o?Math.atan2(o,a)/o:0;return t[0]=r*o,t[1]=n*o,t[2]=e*o,t[3]=.5*Math.log(r*r+n*n+e*e+a*a),t}function pow(t,a,r){return ln(t,a),scale$2(t,t,r),exp(t,t),t}function slerp(t,a,r,n){var e,o,u=a[0],s=a[1],i=a[2],a=a[3],c=r[0],l=r[1],$=r[2],r=r[3],h=u*c+s*l+i*$+a*r;return h<0&&(h=-h,c=-c,l=-l,$=-$,r=-r),h=EPSILON<1-h?(h=Math.acos(h),e=Math.sin(h),o=Math.sin((1-n)*h)/e,Math.sin(n*h)/e):(o=1-n,n),t[0]=o*u+h*c,t[1]=o*s+h*l,t[2]=o*i+h*$,t[3]=o*a+h*r,t}function random$1(t){var a=RANDOM(),r=RANDOM(),n=RANDOM(),e=Math.sqrt(1-a),a=Math.sqrt(a);return t[0]=e*Math.sin(2*Math.PI*r),t[1]=e*Math.cos(2*Math.PI*r),t[2]=a*Math.sin(2*Math.PI*n),t[3]=a*Math.cos(2*Math.PI*n),t}function invert$1(t,a){var r=a[0],n=a[1],e=a[2],a=a[3],o=r*r+n*n+e*e+a*a,o=o?1/o:0;return t[0]=-r*o,t[1]=-n*o,t[2]=-e*o,t[3]=a*o,t}function conjugate$1(t,a){return t[0]=-a[0],t[1]=-a[1],t[2]=-a[2],t[3]=a[3],t}function fromMat3(t,a){var r,n,e,o=a[0]+a[4]+a[8];return 0<o?(e=Math.sqrt(o+1),t[3]=.5*e,t[0]=(a[5]-a[7])*(e=.5/e),t[1]=(a[6]-a[2])*e,t[2]=(a[1]-a[3])*e):(r=((o=a[3*(o=a[4]>a[o=0]?1:o)+o]<a[8]?2:o)+1)%3,n=(o+2)%3,e=Math.sqrt(a[3*o+o]-a[3*r+r]-a[3*n+n]+1),t[o]=.5*e,t[3]=(a[3*r+n]-a[3*n+r])*(e=.5/e),t[r]=(a[3*r+o]+a[3*o+r])*e,t[n]=(a[3*n+o]+a[3*o+n])*e),t}function fromEuler(t,a,r,n){var e=4<arguments.length&&void 0!==arguments[4]?arguments[4]:ANGLE_ORDER,o=Math.PI/360,u=(n*=o,r*=o,Math.sin(a*=o)),s=Math.cos(a),i=Math.sin(r),c=Math.cos(r),l=Math.sin(n),$=Math.cos(n);switch(e){case"xyz":t[0]=u*c*$+s*i*l,t[1]=s*i*$-u*c*l,t[2]=s*c*l+u*i*$,t[3]=s*c*$-u*i*l;break;case"xzy":t[0]=u*c*$-s*i*l,t[1]=s*i*$-u*c*l,t[2]=s*c*l+u*i*$,t[3]=s*c*$+u*i*l;break;case"yxz":t[0]=u*c*$+s*i*l,t[1]=s*i*$-u*c*l,t[2]=s*c*l-u*i*$,t[3]=s*c*$+u*i*l;break;case"yzx":t[0]=u*c*$+s*i*l,t[1]=s*i*$+u*c*l,t[2]=s*c*l-u*i*$,t[3]=s*c*$-u*i*l;break;case"zxy":t[0]=u*c*$-s*i*l,t[1]=s*i*$+u*c*l,t[2]=s*c*l+u*i*$,t[3]=s*c*$-u*i*l;break;case"zyx":t[0]=u*c*$-s*i*l,t[1]=s*i*$+u*c*l,t[2]=s*c*l-u*i*$,t[3]=s*c*$+u*i*l;break;default:throw new Error("Unknown angle order "+e)}return t}function str$2(t){return"quat("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"}var clone$2=clone$3,fromValues$2=fromValues$3,copy$2=copy$3,set$2=set$3,add$2=add$3,mul$2=multiply$2,scale$2=scale$3,dot$2=dot$3,lerp$2=lerp$3,length$2=length$3,len$2=length$2,squaredLength$2=squaredLength$3,sqrLen$2=squaredLength$2,normalize$2=normalize$3,exactEquals$2=exactEquals$3;function equals$2(t,a){return Math.abs(dot$3(t,a))>=1-EPSILON}var rotationTo=function(){var e=create$4(),o=fromValues$4(1,0,0),u=fromValues$4(0,1,0);return function(t,a,r){var n=dot$4(a,r);return n<-.999999?(cross$2(e,o,a),len$4(e)<1e-6&&cross$2(e,u,a),normalize$4(e,e),setAxisAngle(t,e,Math.PI),t):.999999<n?(t[0]=0,t[1]=0,t[2]=0,t[3]=1,t):(cross$2(e,a,r),t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=1+n,normalize$2(t,t))}}(),sqlerp=function(){var u=create$2(),s=create$2();return function(t,a,r,n,e,o){return slerp(u,a,e,o),slerp(s,r,n,o),slerp(t,u,s,2*o*(1-o)),t}}(),setAxes=function(){var e=create$6();return function(t,a,r,n){return e[0]=r[0],e[3]=r[1],e[6]=r[2],e[1]=n[0],e[4]=n[1],e[7]=n[2],e[2]=-a[0],e[5]=-a[1],e[8]=-a[2],normalize$2(t,fromMat3(t,e))}}(),quat=Object.freeze({__proto__:null,create:create$2,identity:identity$1,setAxisAngle:setAxisAngle,getAxisAngle:getAxisAngle,getAngle:getAngle,multiply:multiply$2,rotateX:rotateX$1,rotateY:rotateY$1,rotateZ:rotateZ$1,calculateW:calculateW,exp:exp,ln:ln,pow:pow,slerp:slerp,random:random$1,invert:invert$1,conjugate:conjugate$1,fromMat3:fromMat3,fromEuler:fromEuler,str:str$2,clone:clone$2,fromValues:fromValues$2,copy:copy$2,set:set$2,add:add$2,mul:mul$2,scale:scale$2,dot:dot$2,lerp:lerp$2,length:length$2,len:len$2,squaredLength:squaredLength$2,sqrLen:sqrLen$2,normalize:normalize$2,exactEquals:exactEquals$2,equals:equals$2,rotationTo:rotationTo,sqlerp:sqlerp,setAxes:setAxes});function create$1(){var t=new ARRAY_TYPE(8);return ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[4]=0,t[5]=0,t[6]=0,t[7]=0),t[3]=1,t}function clone$1(t){var a=new ARRAY_TYPE(8);return a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7],a}function fromValues$1(t,a,r,n,e,o,u,s){var i=new ARRAY_TYPE(8);return i[0]=t,i[1]=a,i[2]=r,i[3]=n,i[4]=e,i[5]=o,i[6]=u,i[7]=s,i}function fromRotationTranslationValues(t,a,r,n,e,o,u){var s=new ARRAY_TYPE(8),e=(s[0]=t,s[1]=a,s[2]=r,s[3]=n,.5*e),o=.5*o,u=.5*u;return s[4]=e*n+o*r-u*a,s[5]=o*n+u*t-e*r,s[6]=u*n+e*a-o*t,s[7]=-e*t-o*a-u*r,s}function fromRotationTranslation(t,a,r){var n=.5*r[0],e=.5*r[1],r=.5*r[2],o=a[0],u=a[1],s=a[2],a=a[3];return t[0]=o,t[1]=u,t[2]=s,t[3]=a,t[4]=n*a+e*s-r*u,t[5]=e*a+r*o-n*s,t[6]=r*a+n*u-e*o,t[7]=-n*o-e*u-r*s,t}function fromTranslation(t,a){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t[4]=.5*a[0],t[5]=.5*a[1],t[6]=.5*a[2],t[7]=0,t}function fromRotation(t,a){return t[0]=a[0],t[1]=a[1],t[2]=a[2],t[3]=a[3],t[4]=0,t[5]=0,t[6]=0,t[7]=0,t}function fromMat4(t,a){var r=create$2(),n=(getRotation(r,a),new ARRAY_TYPE(3));return getTranslation$1(n,a),fromRotationTranslation(t,r,n),t}function copy$1(t,a){return t[0]=a[0],t[1]=a[1],t[2]=a[2],t[3]=a[3],t[4]=a[4],t[5]=a[5],t[6]=a[6],t[7]=a[7],t}function identity(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t[6]=0,t[7]=0,t}function set$1(t,a,r,n,e,o,u,s,i){return t[0]=a,t[1]=r,t[2]=n,t[3]=e,t[4]=o,t[5]=u,t[6]=s,t[7]=i,t}var getReal=copy$2;function getDual(t,a){return t[0]=a[4],t[1]=a[5],t[2]=a[6],t[3]=a[7],t}var setReal=copy$2;function setDual(t,a){return t[4]=a[0],t[5]=a[1],t[6]=a[2],t[7]=a[3],t}function getTranslation(t,a){var r=a[4],n=a[5],e=a[6],o=a[7],u=-a[0],s=-a[1],i=-a[2],a=a[3];return t[0]=2*(r*a+o*u+n*i-e*s),t[1]=2*(n*a+o*s+e*u-r*i),t[2]=2*(e*a+o*i+r*s-n*u),t}function translate(t,a,r){var n=a[0],e=a[1],o=a[2],u=a[3],s=.5*r[0],i=.5*r[1],r=.5*r[2],c=a[4],l=a[5],$=a[6],a=a[7];return t[0]=n,t[1]=e,t[2]=o,t[3]=u,t[4]=u*s+e*r-o*i+c,t[5]=u*i+o*s-n*r+l,t[6]=u*r+n*i-e*s+$,t[7]=-n*s-e*i-o*r+a,t}function rotateX(t,a,r){var n=-a[0],e=-a[1],o=-a[2],u=a[3],s=a[4],i=a[5],c=a[6],l=a[7],$=s*u+l*n+i*o-c*e,h=i*u+l*e+c*n-s*o,f=c*u+l*o+s*e-i*n,l=l*u-s*n-i*e-c*o;return rotateX$1(t,a,r),n=t[0],t[4]=$*(u=t[3])+l*n+h*(o=t[2])-f*(e=t[1]),t[5]=h*u+l*e+f*n-$*o,t[6]=f*u+l*o+$*e-h*n,t[7]=l*u-$*n-h*e-f*o,t}function rotateY(t,a,r){var n=-a[0],e=-a[1],o=-a[2],u=a[3],s=a[4],i=a[5],c=a[6],l=a[7],$=s*u+l*n+i*o-c*e,h=i*u+l*e+c*n-s*o,f=c*u+l*o+s*e-i*n,l=l*u-s*n-i*e-c*o;return rotateY$1(t,a,r),n=t[0],t[4]=$*(u=t[3])+l*n+h*(o=t[2])-f*(e=t[1]),t[5]=h*u+l*e+f*n-$*o,t[6]=f*u+l*o+$*e-h*n,t[7]=l*u-$*n-h*e-f*o,t}function rotateZ(t,a,r){var n=-a[0],e=-a[1],o=-a[2],u=a[3],s=a[4],i=a[5],c=a[6],l=a[7],$=s*u+l*n+i*o-c*e,h=i*u+l*e+c*n-s*o,f=c*u+l*o+s*e-i*n,l=l*u-s*n-i*e-c*o;return rotateZ$1(t,a,r),n=t[0],t[4]=$*(u=t[3])+l*n+h*(o=t[2])-f*(e=t[1]),t[5]=h*u+l*e+f*n-$*o,t[6]=f*u+l*o+$*e-h*n,t[7]=l*u-$*n-h*e-f*o,t}function rotateByQuatAppend(t,a,r){var n=r[0],e=r[1],o=r[2],r=r[3],u=a[0],s=a[1],i=a[2],c=a[3];return t[0]=u*r+c*n+s*o-i*e,t[1]=s*r+c*e+i*n-u*o,t[2]=i*r+c*o+u*e-s*n,t[3]=c*r-u*n-s*e-i*o,t[4]=(u=a[4])*r+(c=a[7])*n+(s=a[5])*o-(i=a[6])*e,t[5]=s*r+c*e+i*n-u*o,t[6]=i*r+c*o+u*e-s*n,t[7]=c*r-u*n-s*e-i*o,t}function rotateByQuatPrepend(t,a,r){var n=a[0],e=a[1],o=a[2],a=a[3],u=r[0],s=r[1],i=r[2],c=r[3];return t[0]=n*c+a*u+e*i-o*s,t[1]=e*c+a*s+o*u-n*i,t[2]=o*c+a*i+n*s-e*u,t[3]=a*c-n*u-e*s-o*i,t[4]=n*(c=r[7])+a*(u=r[4])+e*(i=r[6])-o*(s=r[5]),t[5]=e*c+a*s+o*u-n*i,t[6]=o*c+a*i+n*s-e*u,t[7]=a*c-n*u-e*s-o*i,t}function rotateAroundAxis(t,a,r,n){var e,o,u,s,i,c;return Math.abs(n)<EPSILON?copy$1(t,a):(c=Math.hypot(r[0],r[1],r[2]),n*=.5,e=(u=Math.sin(n))*r[0]/c,o=u*r[1]/c,u=u*r[2]/c,r=Math.cos(n),c=a[0],t[0]=c*r+(n=a[3])*e+(s=a[1])*u-(i=a[2])*o,t[1]=s*r+n*o+i*e-c*u,t[2]=i*r+n*u+c*o-s*e,t[3]=n*r-c*e-s*o-i*u,t[4]=(n=a[4])*r+(c=a[7])*e+(s=a[5])*u-(i=a[6])*o,t[5]=s*r+c*o+i*e-n*u,t[6]=i*r+c*u+n*o-s*e,t[7]=c*r-n*e-s*o-i*u,t)}function add$1(t,a,r){return t[0]=a[0]+r[0],t[1]=a[1]+r[1],t[2]=a[2]+r[2],t[3]=a[3]+r[3],t[4]=a[4]+r[4],t[5]=a[5]+r[5],t[6]=a[6]+r[6],t[7]=a[7]+r[7],t}function multiply$1(t,a,r){var n=a[0],e=a[1],o=a[2],u=a[3],s=r[4],i=r[5],c=r[6],l=r[7],$=a[4],h=a[5],f=a[6],a=a[7],M=r[0],m=r[1],d=r[2],r=r[3];return t[0]=n*r+u*M+e*d-o*m,t[1]=e*r+u*m+o*M-n*d,t[2]=o*r+u*d+n*m-e*M,t[3]=u*r-n*M-e*m-o*d,t[4]=n*l+u*s+e*c-o*i+$*r+a*M+h*d-f*m,t[5]=e*l+u*i+o*s-n*c+h*r+a*m+f*M-$*d,t[6]=o*l+u*c+n*i-e*s+f*r+a*d+$*m-h*M,t[7]=u*l-n*s-e*i-o*c+a*r-$*M-h*m-f*d,t}var mul$1=multiply$1;function scale$1(t,a,r){return t[0]=a[0]*r,t[1]=a[1]*r,t[2]=a[2]*r,t[3]=a[3]*r,t[4]=a[4]*r,t[5]=a[5]*r,t[6]=a[6]*r,t[7]=a[7]*r,t}var dot$1=dot$2;function lerp$1(t,a,r,n){var e=1-n;return dot$1(a,r)<0&&(n=-n),t[0]=a[0]*e+r[0]*n,t[1]=a[1]*e+r[1]*n,t[2]=a[2]*e+r[2]*n,t[3]=a[3]*e+r[3]*n,t[4]=a[4]*e+r[4]*n,t[5]=a[5]*e+r[5]*n,t[6]=a[6]*e+r[6]*n,t[7]=a[7]*e+r[7]*n,t}function invert(t,a){var r=squaredLength$1(a);return t[0]=-a[0]/r,t[1]=-a[1]/r,t[2]=-a[2]/r,t[3]=a[3]/r,t[4]=-a[4]/r,t[5]=-a[5]/r,t[6]=-a[6]/r,t[7]=a[7]/r,t}function conjugate(t,a){return t[0]=-a[0],t[1]=-a[1],t[2]=-a[2],t[3]=a[3],t[4]=-a[4],t[5]=-a[5],t[6]=-a[6],t[7]=a[7],t}var length$1=length$2,len$1=length$1,squaredLength$1=squaredLength$2,sqrLen$1=squaredLength$1;function normalize$1(t,a){var r,n,e,o,u,s,i,c,l=squaredLength$1(a);return 0<l&&(l=Math.sqrt(l),c=(r=a[0]/l)*(u=a[4])+(n=a[1]/l)*(s=a[5])+(e=a[2]/l)*(i=a[6])+(o=a[3]/l)*(a=a[7]),t[0]=r,t[1]=n,t[2]=e,t[3]=o,t[4]=(u-r*c)/l,t[5]=(s-n*c)/l,t[6]=(i-e*c)/l,t[7]=(a-o*c)/l),t}function str$1(t){return"quat2("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+")"}function exactEquals$1(t,a){return t[0]===a[0]&&t[1]===a[1]&&t[2]===a[2]&&t[3]===a[3]&&t[4]===a[4]&&t[5]===a[5]&&t[6]===a[6]&&t[7]===a[7]}function equals$1(t,a){var r=t[0],n=t[1],e=t[2],o=t[3],u=t[4],s=t[5],i=t[6],t=t[7],c=a[0],l=a[1],$=a[2],h=a[3],f=a[4],M=a[5],m=a[6],a=a[7];return Math.abs(r-c)<=EPSILON*Math.max(1,Math.abs(r),Math.abs(c))&&Math.abs(n-l)<=EPSILON*Math.max(1,Math.abs(n),Math.abs(l))&&Math.abs(e-$)<=EPSILON*Math.max(1,Math.abs(e),Math.abs($))&&Math.abs(o-h)<=EPSILON*Math.max(1,Math.abs(o),Math.abs(h))&&Math.abs(u-f)<=EPSILON*Math.max(1,Math.abs(u),Math.abs(f))&&Math.abs(s-M)<=EPSILON*Math.max(1,Math.abs(s),Math.abs(M))&&Math.abs(i-m)<=EPSILON*Math.max(1,Math.abs(i),Math.abs(m))&&Math.abs(t-a)<=EPSILON*Math.max(1,Math.abs(t),Math.abs(a))}var quat2=Object.freeze({__proto__:null,create:create$1,clone:clone$1,fromValues:fromValues$1,fromRotationTranslationValues:fromRotationTranslationValues,fromRotationTranslation:fromRotationTranslation,fromTranslation:fromTranslation,fromRotation:fromRotation,fromMat4:fromMat4,copy:copy$1,identity:identity,set:set$1,getReal:getReal,getDual:getDual,setReal:setReal,setDual:setDual,getTranslation:getTranslation,translate:translate,rotateX:rotateX,rotateY:rotateY,rotateZ:rotateZ,rotateByQuatAppend:rotateByQuatAppend,rotateByQuatPrepend:rotateByQuatPrepend,rotateAroundAxis:rotateAroundAxis,add:add$1,multiply:multiply$1,mul:mul$1,scale:scale$1,dot:dot$1,lerp:lerp$1,invert:invert,conjugate:conjugate,length:length$1,len:len$1,squaredLength:squaredLength$1,sqrLen:sqrLen$1,normalize:normalize$1,str:str$1,exactEquals:exactEquals$1,equals:equals$1});function create(){var t=new ARRAY_TYPE(2);return ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0),t}function clone(t){var a=new ARRAY_TYPE(2);return a[0]=t[0],a[1]=t[1],a}function fromValues(t,a){var r=new ARRAY_TYPE(2);return r[0]=t,r[1]=a,r}function copy(t,a){return t[0]=a[0],t[1]=a[1],t}function set(t,a,r){return t[0]=a,t[1]=r,t}function add(t,a,r){return t[0]=a[0]+r[0],t[1]=a[1]+r[1],t}function subtract(t,a,r){return t[0]=a[0]-r[0],t[1]=a[1]-r[1],t}function multiply(t,a,r){return t[0]=a[0]*r[0],t[1]=a[1]*r[1],t}function divide(t,a,r){return t[0]=a[0]/r[0],t[1]=a[1]/r[1],t}function ceil(t,a){return t[0]=Math.ceil(a[0]),t[1]=Math.ceil(a[1]),t}function floor(t,a){return t[0]=Math.floor(a[0]),t[1]=Math.floor(a[1]),t}function min(t,a,r){return t[0]=Math.min(a[0],r[0]),t[1]=Math.min(a[1],r[1]),t}function max(t,a,r){return t[0]=Math.max(a[0],r[0]),t[1]=Math.max(a[1],r[1]),t}function round(t,a){return t[0]=Math.round(a[0]),t[1]=Math.round(a[1]),t}function scale(t,a,r){return t[0]=a[0]*r,t[1]=a[1]*r,t}function scaleAndAdd(t,a,r,n){return t[0]=a[0]+r[0]*n,t[1]=a[1]+r[1]*n,t}function distance(t,a){var r=a[0]-t[0];return Math.hypot(r,a[1]-t[1])}function squaredDistance(t,a){var r=a[0]-t[0],a=a[1]-t[1];return r*r+a*a}function length(t){var a=t[0];return Math.hypot(a,t[1])}function squaredLength(t){var a=t[0],t=t[1];return a*a+t*t}function negate(t,a){return t[0]=-a[0],t[1]=-a[1],t}function inverse(t,a){return t[0]=1/a[0],t[1]=1/a[1],t}function normalize(t,a){var r=a[0],n=a[1],r=r*r+n*n;return 0<r&&(r=1/Math.sqrt(r)),t[0]=a[0]*r,t[1]=a[1]*r,t}function dot(t,a){return t[0]*a[0]+t[1]*a[1]}function cross(t,a,r){a=a[0]*r[1]-a[1]*r[0];return t[0]=t[1]=0,t[2]=a,t}function lerp(t,a,r,n){var e=a[0],a=a[1];return t[0]=e+n*(r[0]-e),t[1]=a+n*(r[1]-a),t}function random(t,a){a=a||1;var r=2*RANDOM()*Math.PI;return t[0]=Math.cos(r)*a,t[1]=Math.sin(r)*a,t}function transformMat2(t,a,r){var n=a[0],a=a[1];return t[0]=r[0]*n+r[2]*a,t[1]=r[1]*n+r[3]*a,t}function transformMat2d(t,a,r){var n=a[0],a=a[1];return t[0]=r[0]*n+r[2]*a+r[4],t[1]=r[1]*n+r[3]*a+r[5],t}function transformMat3(t,a,r){var n=a[0],a=a[1];return t[0]=r[0]*n+r[3]*a+r[6],t[1]=r[1]*n+r[4]*a+r[7],t}function transformMat4(t,a,r){var n=a[0],a=a[1];return t[0]=r[0]*n+r[4]*a+r[12],t[1]=r[1]*n+r[5]*a+r[13],t}function rotate(t,a,r,n){var e=a[0]-r[0],a=a[1]-r[1],o=Math.sin(n),n=Math.cos(n);return t[0]=e*n-a*o+r[0],t[1]=e*o+a*n+r[1],t}function angle(t,a){var r=t[0],t=t[1],n=a[0],a=a[1],e=Math.sqrt((r*r+t*t)*(n*n+a*a));return Math.acos(Math.min(Math.max(e&&(r*n+t*a)/e,-1),1))}function zero(t){return t[0]=0,t[1]=0,t}function str(t){return"vec2("+t[0]+", "+t[1]+")"}function exactEquals(t,a){return t[0]===a[0]&&t[1]===a[1]}function equals(t,a){var r=t[0],t=t[1],n=a[0],a=a[1];return Math.abs(r-n)<=EPSILON*Math.max(1,Math.abs(r),Math.abs(n))&&Math.abs(t-a)<=EPSILON*Math.max(1,Math.abs(t),Math.abs(a))}var len=length,sub=subtract,mul=multiply,div=divide,dist=distance,sqrDist=squaredDistance,sqrLen=squaredLength,forEach=function(){var i=create();return function(t,a,r,n,e,o){var u,s;for(a=a||2,r=r||0,s=n?Math.min(n*a+r,t.length):t.length,u=r;u<s;u+=a)i[0]=t[u],i[1]=t[u+1],e(i,i,o),t[u]=i[0],t[u+1]=i[1];return t}}(),vec2=Object.freeze({__proto__:null,create:create,clone:clone,fromValues:fromValues,copy:copy,set:set,add:add,subtract:subtract,multiply:multiply,divide:divide,ceil:ceil,floor:floor,min:min,max:max,round:round,scale:scale,scaleAndAdd:scaleAndAdd,distance:distance,squaredDistance:squaredDistance,length:length,squaredLength:squaredLength,negate:negate,inverse:inverse,normalize:normalize,dot:dot,cross:cross,lerp:lerp,random:random,transformMat2:transformMat2,transformMat2d:transformMat2d,transformMat3:transformMat3,transformMat4:transformMat4,rotate:rotate,angle:angle,zero:zero,str:str,exactEquals:exactEquals,equals:equals,len:len,sub:sub,mul:mul,div:div,dist:dist,sqrDist:sqrDist,sqrLen:sqrLen,forEach:forEach});globalThis.glMatrix=common,globalThis.glMatrix.mat2=mat2,globalThis.glMatrix.mat2d=mat2d,globalThis.glMatrix.mat3=mat3,globalThis.glMatrix.mat4=mat4,globalThis.glMatrix.quat=quat,globalThis.glMatrix.quat2=quat2,globalThis.glMatrix.vec2=vec2,globalThis.glMatrix.vec3=vec3,globalThis.glMatrix.vec4=vec4; } // 3rdparty/poly-decomp.js { function lineInt(o,n,t){var e=[0,0],l=o[1][1]-o[0][1],p=o[0][0]-o[1][0],o=l*o[0][0]+p*o[0][1],g=n[1][1]-n[0][1],r=n[0][0]-n[1][0],n=g*n[0][0]+r*n[0][1],i=l*r-g*p;return scalar_eq(i,0,t=t||0)||(e[0]=(r*o-p*n)/i,e[1]=(l*n-g*o)/i),e}function lineSegmentsIntersect(o,n,t,e){var l,p=n[0]-o[0],n=n[1]-o[1],g=e[0]-t[0],e=e[1]-t[1];return g*n-e*p!=0&&(l=(g*(o[1]-t[1])+e*(t[0]-o[0]))/(e*p-g*n),0<=(o=(p*(t[1]-o[1])+n*(o[0]-t[0]))/(g*n-e*p)))&&o<=1&&0<=l&&l<=1}function triangleArea(o,n,t){return(n[0]-o[0])*(t[1]-o[1])-(t[0]-o[0])*(n[1]-o[1])}function isLeft(o,n,t){return 0<triangleArea(o,n,t)}function isLeftOn(o,n,t){return 0<=triangleArea(o,n,t)}function isRight(o,n,t){return triangleArea(o,n,t)<0}function isRightOn(o,n,t){return triangleArea(o,n,t)<=0}var tmpPoint1=[],tmpPoint2=[];function collinear(o,n,t,e){var l,p,g;return e?(g=tmpPoint2,(p=tmpPoint1)[0]=n[0]-o[0],p[1]=n[1]-o[1],g[0]=t[0]-n[0],g[1]=t[1]-n[1],l=p[0]*g[0]+p[1]*g[1],p=Math.sqrt(p[0]*p[0]+p[1]*p[1]),g=Math.sqrt(g[0]*g[0]+g[1]*g[1]),Math.acos(l/(p*g))<e):0===triangleArea(o,n,t)}function sqdist(o,n){var t=n[0]-o[0],n=n[1]-o[1];return t*t+n*n}function polygonAt(o,n){var t=o.length;return o[n<0?n%t+t:n%t]}function polygonClear(o){o.length=0}function polygonAppend(o,n,t,e){for(var l=t;l<e;l++)o.push(n[l])}function polygonMakeCCW(o){for(var n=0,t=o,e=1;e<o.length;++e)(t[e][1]<t[n][1]||t[e][1]===t[n][1]&&t[e][0]>t[n][0])&&(n=e);return!isLeft(polygonAt(o,n-1),polygonAt(o,n),polygonAt(o,n+1))&&(polygonReverse(o),!0)}function polygonReverse(o){for(var n=[],t=o.length,e=0;e!==t;e++)n.push(o.pop());for(e=0;e!==t;e++)o[e]=n[e]}function polygonIsReflex(o,n){return isRight(polygonAt(o,n-1),polygonAt(o,n),polygonAt(o,n+1))}var tmpLine1=[],tmpLine2=[];function polygonCanSee(o,n,t){var e,l=tmpLine1,p=tmpLine2;if(isLeftOn(polygonAt(o,n+1),polygonAt(o,n),polygonAt(o,t))&&isRightOn(polygonAt(o,n-1),polygonAt(o,n),polygonAt(o,t)))return!1;for(var g=sqdist(polygonAt(o,n),polygonAt(o,t)),r=0;r!==o.length;++r)if((r+1)%o.length!==n&&r!==n&&isLeftOn(polygonAt(o,n),polygonAt(o,t),polygonAt(o,r+1))&&isRightOn(polygonAt(o,n),polygonAt(o,t),polygonAt(o,r))&&(l[0]=polygonAt(o,n),l[1]=polygonAt(o,t),p[0]=polygonAt(o,r),p[1]=polygonAt(o,r+1),e=lineInt(l,p),sqdist(polygonAt(o,n),e)<g))return!1;return!0}function polygonCanSee2(o,n,t){for(var e=0;e!==o.length;++e)if(e!==n&&e!==t&&(e+1)%o.length!==n&&(e+1)%o.length!==t&&lineSegmentsIntersect(polygonAt(o,n),polygonAt(o,t),polygonAt(o,e),polygonAt(o,e+1)))return!1;return!0}function polygonCopy(o,n,t,e){var l=e||[];if(polygonClear(l),n<t)for(var p=n;p<=t;p++)l.push(o[p]);else{for(p=0;p<=t;p++)l.push(o[p]);for(p=n;p<o.length;p++)l.push(o[p])}return l}function polygonGetCutEdges(o){for(var n=[],t=[],e=[],l=Number.MAX_VALUE,p=0;p<o.length;++p)if(polygonIsReflex(o,p))for(var g=0;g<o.length;++g)if(polygonCanSee(o,p,g)){for(var t=polygonGetCutEdges(polygonCopy(o,p,g,e)),r=polygonGetCutEdges(polygonCopy(o,g,p,e)),i=0;i<r.length;i++)t.push(r[i]);t.length<l&&(l=(n=t).length,n.push([polygonAt(o,p),polygonAt(o,g)]))}return n}function polygonDecomp(o){var n=polygonGetCutEdges(o);return 0<n.length?polygonSlice(o,n):[o]}function polygonSlice(o,n){if(0===n.length)return[o];if(n instanceof Array&&n.length&&n[0]instanceof Array&&2===n[0].length&&n[0][0]instanceof Array){for(var t=[o],e=0;e<n.length;e++)for(var l=n[e],p=0;p<t.length;p++){var g=polygonSlice(t[p],l);if(g){t.splice(p,1),t.push(g[0],g[1]);break}}return t}return e=o.indexOf((l=n)[0]),p=o.indexOf(l[1]),-1!==e&&-1!==p&&[polygonCopy(o,e,p),polygonCopy(o,p,e)]}function polygonIsSimple(o){for(var n=o,t=0;t<n.length-1;t++)for(var e=0;e<t-1;e++)if(lineSegmentsIntersect(n[t],n[t+1],n[e],n[e+1]))return!1;for(t=1;t<n.length-2;t++)if(lineSegmentsIntersect(n[0],n[n.length-1],n[t],n[t+1]))return!1;return!0}function getIntersectionPoint(o,n,t,e,l){var p=n[1]-o[1],n=o[0]-n[0],o=p*o[0]+n*o[1],g=e[1]-t[1],e=t[0]-e[0],t=g*t[0]+e*t[1],r=p*e-g*n;return scalar_eq(r,0,l=l||0)?[0,0]:[(e*o-n*t)/r,(p*t-g*o)/r]}function polygonQuickDecomp(o,n,t,e,l,p,g){p=p||100,g=g||0,l=l||25,n=void 0!==n?n:[],t=t||[],e=e||[];var r=[0,0],i=[0,0],y=[0,0],s=0,A=0,u=0,a=0,f=0,c=0,h=0,v=[],m=[],d=o,C=o;if(!(C.length<3))if(p<++g)console.warn("quickDecomp: max level ("+p+") reached.");else{for(var R=0;R<o.length;++R)if(polygonIsReflex(d,R)){t.push(d[R]);for(var s=A=Number.MAX_VALUE,q=0;q<o.length;++q)isLeft(polygonAt(d,R-1),polygonAt(d,R),polygonAt(d,q))&&isRightOn(polygonAt(d,R-1),polygonAt(d,R),polygonAt(d,q-1))&&(y=getIntersectionPoint(polygonAt(d,R-1),polygonAt(d,R),polygonAt(d,q),polygonAt(d,q-1)),isRight(polygonAt(d,R+1),polygonAt(d,R),y))&&(u=sqdist(d[R],y))<A&&(A=u,i=y,c=q),isLeft(polygonAt(d,R+1),polygonAt(d,R),polygonAt(d,q+1))&&isRightOn(polygonAt(d,R+1),polygonAt(d,R),polygonAt(d,q))&&(y=getIntersectionPoint(polygonAt(d,R+1),polygonAt(d,R),polygonAt(d,q),polygonAt(d,q+1)),isLeft(polygonAt(d,R-1),polygonAt(d,R),y))&&(u=sqdist(d[R],y))<s&&(s=u,r=y,f=q);if(c===(f+1)%o.length)y[0]=(i[0]+r[0])/2,y[1]=(i[1]+r[1])/2,e.push(y),R<f?(polygonAppend(v,d,R,f+1),v.push(y),m.push(y),0!==c&&polygonAppend(m,d,c,d.length),polygonAppend(m,d,0,R+1)):(0!==R&&polygonAppend(v,d,R,d.length),polygonAppend(v,d,0,f+1),v.push(y),m.push(y),polygonAppend(m,d,c,R+1));else{if(f<c&&(f+=o.length),a=Number.MAX_VALUE,f<c)return n;for(q=c;q<=f;++q)isLeftOn(polygonAt(d,R-1),polygonAt(d,R),polygonAt(d,q))&&isRightOn(polygonAt(d,R+1),polygonAt(d,R),polygonAt(d,q))&&(u=sqdist(polygonAt(d,R),polygonAt(d,q)))<a&&polygonCanSee2(d,R,q)&&(a=u,h=q%o.length);R<h?(polygonAppend(v,d,R,h+1),0!==h&&polygonAppend(m,d,h,C.length),polygonAppend(m,d,0,R+1)):(0!==R&&polygonAppend(v,d,R,C.length),polygonAppend(v,d,0,h+1),polygonAppend(m,d,h,R+1))}return v.length<m.length?(polygonQuickDecomp(v,n,t,e,l,p,g),polygonQuickDecomp(m,n,t,e,l,p,g)):(polygonQuickDecomp(m,n,t,e,l,p,g),polygonQuickDecomp(v,n,t,e,l,p,g)),n}n.push(o)}return n}function polygonRemoveCollinearPoints(o,n){for(var t=0,e=o.length-1;3<o.length&&0<=e;--e)collinear(polygonAt(o,e-1),polygonAt(o,e),polygonAt(o,e+1),n)&&(o.splice(e%o.length,1),t++);return t}function polygonRemoveDuplicatePoints(o,n){for(var t=o.length-1;1<=t;--t)for(var e=o[t],l=t-1;0<=l;--l)points_eq(e,o[l],n)&&o.splice(t,1)}function scalar_eq(o,n,t){return t=t||0,Math.abs(o-n)<=t}function points_eq(o,n,t){return scalar_eq(o[0],n[0],t)&&scalar_eq(o[1],n[1],t)}self.polyDecomp={decomp:polygonDecomp,quickDecomp:polygonQuickDecomp,isSimple:polygonIsSimple,removeCollinearPoints:polygonRemoveCollinearPoints,removeDuplicatePoints:polygonRemoveDuplicatePoints,makeCCW:polygonMakeCCW}; } // lib/c3.js { let isReady=!1,hasAppStarted=!1,buildMode="dev";const internalApiToken=Symbol("Construct internal API token");let internalApiTokenAccessesRemaining=14;const C3=self.C3=class{constructor(){throw TypeError("static class can't be instantiated")}static _GetInternalAPIToken(){if(internalApiTokenAccessesRemaining<=0)throw new Error("cannot obtain internal API token");return--internalApiTokenAccessesRemaining,internalApiToken}static SetReady(){isReady=!0}static IsReady(){return isReady}static SetAppStarted(){hasAppStarted=!0}static HasAppStarted(){return hasAppStarted}static SetBuildMode(e){buildMode=e}static GetBuildMode(){return buildMode}static IsReleaseBuild(){return"final"===buildMode}};C3.isDebug=!1,C3.isDebugDefend=!1,C3.hardwareConcurrency=navigator.hardwareConcurrency||2,self.C3X={}; } // ../lib/queryParser.js { const C3=self.C3;C3.QueryParser=class{constructor(e){this._queryString=e,this._parameters=new Map,this._Parse()}_Parse(){let e=this._queryString;const r=(e=e.startsWith("?")||e.startsWith("#")?e.substr(1):e).split("&");for(const t of r)this._ParseParameter(t)}_ParseParameter(e){if(e)if(e.includes("=")){const r=e.indexOf("="),t=decodeURIComponent(e.substring(0,r)),s=decodeURIComponent(e.substring(r+1));this._parameters.set(t,s)}else this._parameters.set(e,null)}LogAll(){for(const e of this._parameters)console.log("[QueryParser] Parameter '"+e[0]+"' = "+(null===e[1]?"null":"'"+e[1]+"'"))}Has(e){return this._parameters.has(e)}Get(e){const r=this._parameters.get(e);return void 0===r?null:r}ClearHash(){history.replaceState("",document.title,location.pathname+location.search)}Reparse(e){this._queryString=e,this._parameters.clear(),this._Parse()}},C3.QueryString=new C3.QueryParser(location.search),C3.LocationHashString=new C3.QueryParser(location.hash),C3.QueryString.Has("perf")&&(C3.isPerformanceProfiling=!0),"dev"!==C3.QueryString.Get("mode")&&C3.SetBuildMode("final"); } // ../lib/detect/detect.js { const C3=self.C3,UNKNOWN="(unknown)",windowsNTVerMap=(C3.Platform={OS:UNKNOWN,OSVersion:UNKNOWN,Browser:UNKNOWN,BrowserVersion:UNKNOWN,BrowserVersionNumber:NaN,BrowserEngine:UNKNOWN,Context:"browser",IsDesktop:!0,IsMobile:!1,IsAppleOS:!1,IsIpadOS:!1,GetDetailedInfo:async()=>{}},new Map([[5,"2000"],[5.1,"XP"],[5.2,"XP"],[6,"Vista"],[6.1,"7"],[6.2,"8"],[6.3,"8.1"],[10,"10"]]));function GetWindowsNTVersionName(r){const o=parseFloat(r),e=windowsNTVerMap.get(o);return e||(13<=o?"11":"NT "+r)}const uaStr=navigator.userAgent,uaData=navigator["userAgentData"];if(uaData&&0<uaData["brands"].length){C3.Platform.OS=uaData["platform"],C3.Platform.IsMobile=uaData["mobile"],C3.Platform.IsDesktop=!C3.Platform.IsMobile;const d=new Map([["Google Chrome","Chrome"],["Microsoft Edge","Edge"],["Opera","Opera"],["Opera GX","Opera GX"],["Mozilla Firefox","Firefox"],["Apple Safari","Safari"],["NW.js","NW.js"]]),e=new Map([["Chromium","Chromium"],["Gecko","Gecko"],["WebKit","WebKit"]]);function ReadBrandList(r){let o="",t="",a="",s="";for(const i of r){const n=d.get(i["brand"]),m=(!o&&n&&(o=n,t=i["version"]),e.get(i["brand"]));!a&&m&&(a=m,s=i["version"])}o||"Chromium"!==a||(C3.Platform.Browser="Chromium",C3.Platform.BrowserVersion=s),C3.Platform.Browser=o||UNKNOWN,C3.Platform.BrowserVersion=t||UNKNOWN,C3.Platform.BrowserEngine=a||UNKNOWN}ReadBrandList(uaData["brands"]);let o=!1;C3.Platform.GetDetailedInfo=async()=>{if(!o)try{const r=await navigator["userAgentData"]["getHighEntropyValues"](["platformVersion","fullVersionList"]);ReadBrandList(r["fullVersionList"]),"Windows"===C3.Platform.OS?C3.Platform.OSVersion=GetWindowsNTVersionName(r["platformVersion"]):C3.Platform.OSVersion=r["platformVersion"],o=!0}catch(r){console.warn("Failed to get detailed user agent information: ",r)}}}else{function RunTest(r,o){const e=Array.isArray(r)?r:[r];for(const t of e){const a=t.exec(uaStr);if(a){o(a);break}}}RunTest(/windows\s+nt\s+([\d\.]+)/i,r=>{C3.Platform.OS="Windows";const o=r[1];C3.Platform.OSVersion=GetWindowsNTVersionName(o)}),RunTest(/mac\s+os\s+x\s+([\d\._]+)/i,r=>{C3.Platform.OS="macOS",C3.Platform.OSVersion=r[1].replace(/_/g,".")}),RunTest(/CrOS/,()=>{C3.Platform.OS="Chrome OS"}),RunTest(/linux|openbsd|freebsd|netbsd/i,()=>{C3.Platform.OS="Linux"}),RunTest(/android/i,()=>{C3.Platform.OS="Android"}),RunTest(/android\s+([\d\.]+)/i,r=>{C3.Platform.OS="Android",C3.Platform.OSVersion=r[1]}),C3.Platform.OS===UNKNOWN&&(RunTest(/(iphone|ipod|ipad)/i,r=>{C3.Platform.OS="iOS"}),RunTest([/iphone\s+os\s+([\d\._]+)/i,/ipad[^)]*os\s+([\d\._]+)/i],r=>{C3.Platform.OS="iOS",C3.Platform.OSVersion=r[1].replace(/_/g,".")}));const q=/chrome\//i.test(uaStr),r=/chromium\//i.test(uaStr),s=/edg\//i.test(uaStr),t=/OPR\//.test(uaStr),u=/nwjs/i.test(uaStr),v=/safari\//i.test(uaStr),w=/webkit/i.test(uaStr),x=(s||t||RunTest(/chrome\/([\d\.]+)/i,r=>{C3.Platform.Browser="Chrome",C3.Platform.BrowserVersion=r[1],C3.Platform.BrowserEngine="Chromium"}),RunTest(/edg\/([\d\.]+)/i,r=>{C3.Platform.Browser="Edge",C3.Platform.BrowserVersion=r[1],C3.Platform.BrowserEngine="Chromium"}),RunTest(/OPR\/([\d\.]+)/,r=>{C3.Platform.Browser="Opera",C3.Platform.BrowserVersion=r[1],C3.Platform.BrowserEngine="Chromium"}),RunTest(/chromium\/([\d\.]+)/i,r=>{C3.Platform.Browser="Chromium",C3.Platform.BrowserVersion=r[1],C3.Platform.BrowserEngine="Chromium"}),RunTest(/nwjs\/[0-9.]+/i,r=>{C3.Platform.Browser="NW.js",C3.Platform.BrowserVersion=r[1],C3.Platform.BrowserEngine="Chromium",C3.Platform.Context="nwjs"}),RunTest(/firefox\/([\d\.]+)/i,r=>{C3.Platform.Browser="Firefox",C3.Platform.BrowserVersion=r[1],C3.Platform.BrowserEngine="Gecko"}),!v||q||r||s||t||u||(C3.Platform.Browser="Safari",C3.Platform.BrowserEngine="WebKit",RunTest(/version\/([\d\.]+)/i,r=>{C3.Platform.BrowserVersion=r[1]}),RunTest(/crios\/([\d\.]+)/i,r=>{C3.Platform.Browser="Chrome for iOS",C3.Platform.BrowserVersion=r[1]}),RunTest(/fxios\/([\d\.]+)/i,r=>{C3.Platform.Browser="Firefox for iOS",C3.Platform.BrowserVersion=r[1]}),RunTest(/edgios\/([\d\.]+)/i,r=>{C3.Platform.Browser="Edge for iOS",C3.Platform.BrowserVersion=r[1]})),C3.Platform.BrowserEngine===UNKNOWN&&w&&(C3.Platform.BrowserEngine="WebKit"),"Android"===C3.Platform.OS&&"Safari"===C3.Platform.Browser&&(C3.Platform.Browser="Stock"),new Set(["Windows","macOS","Linux","Chrome OS"])),y=x.has(C3.Platform.OS)||"nwjs"===C3.Platform.Context;C3.Platform.IsDesktop=y,C3.Platform.IsMobile=!y}"Chrome"===C3.Platform.Browser&&"browser"===C3.Platform.Context&&/wv\)/.test(uaStr)&&(C3.Platform.Context="webview"),"nwjs"!==C3.Platform.Context&&"undefined"!=typeof window&&(window.matchMedia&&window.matchMedia("(display-mode: standalone)").matches||navigator["standalone"])&&(C3.Platform.Context="webapp"),C3.Platform.BrowserVersionNumber=parseFloat(C3.Platform.BrowserVersion);const looksLikeIPadOS="macOS"===C3.Platform.OS&&navigator["maxTouchPoints"]&&2<navigator["maxTouchPoints"];looksLikeIPadOS&&(C3.Platform.OS="iOS",C3.Platform.OSVersion=C3.Platform.BrowserVersion,C3.Platform.IsDesktop=!1,C3.Platform.IsMobile=!0,C3.Platform.IsIpadOS=!0),C3.Platform.IsAppleOS="macOS"===C3.Platform.OS||"iOS"===C3.Platform.OS; } // ../lib/storage/kvStorage.js { "use strict";{const a=2,b="keyvaluepairs",c=new Map,d="undefined"!=typeof IDBObjectStore&&"function"==typeof IDBObjectStore.prototype.getAll,e="undefined"!=typeof IDBObjectStore&&"function"==typeof IDBObjectStore.prototype.getAllKeys;function asyncifyRequest(n){return new Promise((e,t)=>{n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}function asyncifyTransaction(n){return new Promise((e,t)=>{n.oncomplete=()=>e(),n.onerror=()=>t(n.error),n.onabort=()=>t(n.error)})}function openReadOnlyTransaction(e,t){return openTransaction(e,t)}function openWriteTransaction(e,t){return openTransaction(e,t,!0)}async function openTransaction(t,n,r=!1,a=!0){const e=await lazyOpenDatabase(t);try{const s=e.transaction([b],r?"readwrite":"readonly");return n(s)}catch(e){if(a&&"InvalidStateError"===e["name"])return c.delete(t),openTransaction(t,n,r,!1);throw e}}function lazyOpenDatabase(t){RequireString(t);let e=c.get(t);return e instanceof Promise||(e=openDatabase(t),c.set(t,e),e.catch(e=>c.delete(t))),e}async function openDatabase(n){RequireString(n);const e=indexedDB.open(n,a);return e.addEventListener("upgradeneeded",e=>{try{const t=e.target.result;t.createObjectStore(b)}catch(e){console.error("Failed to create objectstore for database "+n,e)}}),asyncifyRequest(e)}function RequireString(e){if("string"!=typeof e)throw new TypeError("expected string")}function getEntriesFromCursor(e,a){const t=e.objectStore(b).openCursor();return new Promise(n=>{const r=[];t.onsuccess=e=>{const t=e.target.result;if(t){switch(a){case"entries":r.push([t.key,t.value]);break;case"keys":r.push(t.key);break;case"values":r.push(t.value)}t.continue()}else n(r)}})}class f{constructor(e){RequireString(e),this.name=e}async ready(){await lazyOpenDatabase(this.name)}set(a,s){return RequireString(a),openWriteTransaction(this.name,async e=>{const t=e.objectStore(b).put(s,a),n=asyncifyRequest(t),r=asyncifyTransaction(e);await Promise.all([r,n])})}get(s){return RequireString(s),openReadOnlyTransaction(this.name,async e=>{const t=e.objectStore(b).get(s),n=asyncifyRequest(t),r=asyncifyTransaction(e),[,a]=await Promise.all([r,n]);return a})}delete(a){return RequireString(a),openWriteTransaction(this.name,async e=>{const t=e.objectStore(b).delete(a),n=asyncifyRequest(t),r=asyncifyTransaction(e);await Promise.all([r,n])})}clear(){return openWriteTransaction(this.name,async e=>{const t=e.objectStore(b).clear(),n=asyncifyRequest(t),r=asyncifyTransaction(e);await Promise.all([r,n])})}keys(){return openReadOnlyTransaction(this.name,async t=>{let n;if(e){const s=t.objectStore(b).getAllKeys();n=asyncifyRequest(s)}else n=getEntriesFromCursor(t,"keys");const r=asyncifyTransaction(t),[,a]=await Promise.all([r,n]);return a})}values(){return openReadOnlyTransaction(this.name,async e=>{let t;if(d){const a=e.objectStore(b).getAll();t=asyncifyRequest(a)}else t=getEntriesFromCursor(e,"values");const n=asyncifyTransaction(e),[,r]=await Promise.all([n,t]);return r})}entries(){return openReadOnlyTransaction(this.name,async e=>{const t=getEntriesFromCursor(e,"entries"),n=asyncifyTransaction(e),[,r]=await Promise.all([n,t]);return r})}}self.KVStorageContainer=f} } // ../lib/storage/localForageAdaptor.js { "use strict";{const a=self.KVStorageContainer,b=[/no available storage method found/i,/an attempt was made to break through the security policy of the user agent/i,/the user denied permission to access the database/i,/a mutation operation was attempted on a database that did not allow mutations/i,/idbfactory\.open\(\) called in an invalid security context/i],c=new WeakMap;function NOT_IMPLEMENTED(e){throw new Error(`"${e}" is not implemented`)}function DISALLOW_CALLBACK(e){if("function"==typeof e)throw new Error("localforage callback API is not implemented; please use the promise API instead")}function StructuredClone(a){return"object"==typeof a?new Promise(t=>{const{port1:e,port2:r}=new MessageChannel;r.onmessage=e=>t(e.data),e.postMessage(a)}):Promise.resolve(a)}class d{constructor(e){this._inst=e,this._isInMemory=!this._inst,this._isInMemory||"undefined"!=typeof indexedDB||(this._isInMemory=!0,console.warn("Unable to use local storage because IndexedDB API is not available")),this._memoryStorage=new Map}_MaybeSwitchToMemoryFallback(e){if(!this._isInMemory)for(const t of b)if(e&&t.test(e.message)){console.error("Unable to use local storage, reverting to in-memory store: ",e,e.message),this._isInMemory=!0;break}}async _getItemFallback(e){const t=this._memoryStorage.get(e),r=await StructuredClone(t);return void 0===r?null:r}async _setItemFallback(e,t){t=await StructuredClone(t),this._memoryStorage.set(e,t)}_removeItemFallback(e){this._memoryStorage.delete(e)}_clearFallback(){this._memoryStorage.clear()}_keysFallback(){return Array.from(this._memoryStorage.keys())}IsInMemory(){return this._isInMemory}GetMemoryStorage(){return this._memoryStorage}SetMemoryStorage(e){this._memoryStorage=e}async getItem(t,e){if(DISALLOW_CALLBACK(e),this._isInMemory)return this._getItemFallback(t);let r;try{r=await this._inst.get(t)}catch(e){return this._MaybeSwitchToMemoryFallback(e),this._isInMemory?this._getItemFallback(t):(console.error(`Error reading '${t}' from storage, returning null: `,e),null)}return void 0===r?null:r}async setItem(t,r,e){if(DISALLOW_CALLBACK(e),void 0===r&&(r=null),this._isInMemory)await this._setItemFallback(t,r);else try{await this._inst.set(t,r)}catch(e){if(this._MaybeSwitchToMemoryFallback(e),!this._isInMemory)throw e;await this._setItemFallback(t,r)}}async removeItem(t,e){if(DISALLOW_CALLBACK(e),this._isInMemory)this._removeItemFallback(t);else try{await this._inst.delete(t)}catch(e){this._MaybeSwitchToMemoryFallback(e),this._isInMemory?this._removeItemFallback(t):console.error(`Error removing '${t}' from storage: `,e)}}async clear(e){if(DISALLOW_CALLBACK(e),this._isInMemory)this._clearFallback();else try{await this._inst.clear()}catch(e){this._MaybeSwitchToMemoryFallback(e),this._isInMemory?this._clearFallback():console.error("Error clearing storage: ",e)}}async keys(e){if(DISALLOW_CALLBACK(e),this._isInMemory)return this._keysFallback();let t=[];try{t=await this._inst.keys()}catch(e){if(this._MaybeSwitchToMemoryFallback(e),this._isInMemory)return this._keysFallback();console.error("Error getting storage keys: ",e)}return t}ready(e){return DISALLOW_CALLBACK(e),this._isInMemory?Promise.resolve(!0):this._inst.ready()}createInstance(e){if(e.forceInMemoryFallback)return new d(null);{const t=e.name;if("string"!=typeof t)throw new TypeError("invalid store name");const r=new a(t);return new d(r)}}length(e){NOT_IMPLEMENTED("localforage.length()")}key(e,t){NOT_IMPLEMENTED("localforage.key()")}iterate(e,t){NOT_IMPLEMENTED("localforage.iterate()")}setDriver(e){NOT_IMPLEMENTED("localforage.setDriver()")}config(e){NOT_IMPLEMENTED("localforage.config()")}defineDriver(e){NOT_IMPLEMENTED("localforage.defineDriver()")}driver(){NOT_IMPLEMENTED("localforage.driver()")}supports(e){NOT_IMPLEMENTED("localforage.supports()")}dropInstance(){NOT_IMPLEMENTED("localforage.dropInstance()")}}self["localforage"]=new d(new a("localforage"))} } // ../lib/misc/supports.js { const C3=self.C3;if(C3.Supports={},C3.Supports.WebAnimations=(()=>{try{if("undefined"==typeof document)return!1;const e=document.createElement("div");if(void 0===e.animate)return!1;const t=e.animate([{opacity:"0"},{opacity:"1"}],1e3);return void 0!==t.reverse}catch(e){return!1}})(),C3.Supports.DialogElement="undefined"!=typeof HTMLDialogElement,C3.Supports.RequestIdleCallback=!!self.requestIdleCallback,C3.Supports.ImageBitmap=!!self.createImageBitmap,C3.Supports.ImageBitmapOptions=!1,C3.Supports.ImageBitmapOptionsResize=!1,C3.Supports.ImageBitmap){try{self.createImageBitmap(new ImageData(32,32),{"premultiplyAlpha":"none"}).then(()=>{C3.Supports.ImageBitmapOptions=!0}).catch(()=>{C3.Supports.ImageBitmapOptions=!1})}catch(e){C3.Supports.ImageBitmapOptions=!1}try{self.createImageBitmap(new ImageData(32,32),{"resizeWidth":10,"resizeHeight":10}).then(e=>{C3.Supports.ImageBitmapOptionsResize=10===e.width&&10===e.height}).catch(()=>{C3.Supports.ImageBitmapOptionsResize=!1})}catch(e){C3.Supports.ImageBitmapOptionsResize=!1}}if(C3.Supports.ClipboardReadText=!(!navigator["clipboard"]||!navigator["clipboard"]["readText"]),C3.Supports.PermissionsQuery=!(!navigator["permissions"]||!navigator["permissions"]["query"]),C3.Supports.ClipboardPermissionsQuery=!1,C3.Supports.PermissionsQuery){const g={"name":"clipboard-read"};navigator["permissions"]["query"](g).then(()=>{C3.Supports.ClipboardPermissionsQuery=!0}).catch(()=>{C3.Supports.ClipboardPermissionsQuery=!1})}C3.Supports.AsyncClipboardApi=!!(navigator["permissions"]&&navigator["clipboard"]&&self["ClipboardItem"]),C3.Supports.Proxies="undefined"!=typeof Proxy,C3.Supports.DownloadAttribute=(()=>{if("undefined"==typeof document)return!1;const e=document.createElement("a");return void 0!==e.download})(),C3.Supports.Fetch="function"==typeof fetch,C3.Supports.PersistentStorage=!!(self.isSecureContext&&"Opera"!==C3.Platform.Browser&&navigator["storage"]&&navigator["storage"]["persist"]),C3.Supports.StorageQuotaEstimate=!!(self.isSecureContext&&navigator["storage"]&&navigator["storage"]["estimate"]),C3.Supports.Fullscreen=(()=>{if("undefined"==typeof document)return!1;if("iOS"===C3.Platform.OS)return!1;const e=document.documentElement;return!!(e.requestFullscreen||e.msRequestFullscreen||e.mozRequestFullScreen||e.webkitRequestFullscreen)})(),C3.Supports.ImageDecoder=void 0!==self["ImageDecoder"],C3.Supports.WebCodecs=!!self["VideoEncoder"],C3.Supports.NativeFileSystemAPI=!!self["showOpenFilePicker"],C3.Supports.QueryLocalFonts=!!self["queryLocalFonts"],C3.Supports.UserActivation=!!navigator["userActivation"],C3.Supports.CanvasToBlobWebP=!1,(async()=>{let t;"undefined"==typeof document?t=new OffscreenCanvas(32,32):((t=document.createElement("canvas")).width=32,t.height=32);const e=t.getContext("2d");e.fillStyle="blue",e.fillRect(0,0,32,32);let o=null;try{t["convertToBlob"]?o=await t["convertToBlob"]({"type":"image/webp","quality":1}):t.toBlob&&(o=await new Promise(e=>t.toBlob(e,"image/webp",1))),C3.Supports.CanvasToBlobWebP=o&&"image/webp"===o.type}catch(e){C3.Supports.CanvasToBlobWebP=!1}})(); } // ../lib/misc/polyfills.js { const C3=self.C3;if(!String.prototype.trimStart){const a=/^[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]*/;String.prototype.trimStart=function(){return this.replace(a,"")}}if(!String.prototype.trimEnd){const c=/[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]*$/;String.prototype.trimEnd=function(){return this.replace(c,"")}}function arrayFlat(t,e){return t.reduce((t,r)=>(0<e&&Array.isArray(r)?Array.prototype.push.apply(t,arrayFlat(r,e-1)):t.push(r),t),[])}String.prototype.replaceAll||(String.prototype.replaceAll=function(t,r){return this.replace(new RegExp(C3.EscapeRegex(t),"g"),r)}),Array.prototype.values||(Array.prototype.values=function*(){for(const t of this)yield t}),Array.prototype.flat||(Array.prototype.flat=function(t=1){return arrayFlat(this,t)}),Array.prototype.at||(Array.prototype.at=function(t){if((t=Math.trunc(t)||0)<0&&(t+=this.length),!(t<0||t>=this.length))return this[t]}),String.prototype.at||(String.prototype.at=function(t){if((t=Math.trunc(t)||0)<0&&(t+=this.length),!(t<0||t>=this.length))return this[t]}),RegExp.escape||(RegExp.escape=function(t){return String(t).replace(/[\\^$*+?.()|[\]{}]/g,"\\$&")}),Set.prototype.isSubsetOf||(Set.prototype.isSubsetOf=function(t){if(!(t instanceof Set))throw new TypeError("argument must be a Set");for(const r of this)if(!t.has(r))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,r)=>e({"usage":t,"quota":r}),t))}),void 0===self.isSecureContext&&(self.isSecureContext="https:"===location.protocol),void 0===self["globalThis"]&&(self["globalThis"]=self); } // lib/misc/assert.js { const C3=self.C3;function assertFail(e){let s=C3.GetCallStack(),t="Assertion failure: "+e+"\n\nStack trace:\n"+s;console.error(t)}self.assert=function(e,s){e||assertFail(s)}; } // ../lib/misc/typeChecks.js { const C3=self.C3,C3X=self.C3X,TypedArray=(C3.IsNumber=function(e){return"number"==typeof e},C3.IsFiniteNumber=function(e){return C3.IsNumber(e)&&isFinite(e)},C3.RequireNumber=function(e){if(!C3.IsNumber(e))throw new TypeError("expected number")},C3.RequireOptionalNumber=function(e){C3.IsNullOrUndefined(e)},C3.RequireNumberInRange=function(e,n,r){if(!C3.IsNumber(e)||isNaN(e)||e<n||r<e)throw new RangeError("number outside of range")},C3.RequireAllNumber=function(...n){for(let e of n);},C3.RequireFiniteNumber=function(e){if(!C3.IsFiniteNumber(e))throw new TypeError("expected finite number")},C3.RequireOptionalFiniteNumber=function(e){C3.IsNullOrUndefined(e)},C3.RequireAllFiniteNumber=function(...n){for(let e of n);},C3.IsString=function(e){return"string"==typeof e},C3.RequireString=function(e){if(!C3.IsString(e))throw new TypeError("expected string")},C3.RequireOptionalString=function(e){C3.IsNullOrUndefined(e)},C3.RequireAllString=function(...n){for(let e of n);},C3.IsSimpleObject=function(e){if("object"!=typeof e||null===e)return!1;let n=Object.getPrototypeOf(e);return n?n.constructor===Object:null===n},C3.RequireSimpleObject=function(e){if(!C3.IsSimpleObject(e))throw new TypeError("expected simple object")},C3.RequireOptionalSimpleObject=function(e){if(!C3.IsNullOrUndefined(e)&&!C3.IsSimpleObject(e))throw new TypeError("expected simple object")},C3.IsObject=function(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)},C3.RequireObject=function(e){if(!C3.IsObject(e))throw new TypeError("expected object")},C3.RequireOptionalObject=function(e){C3.IsNullOrUndefined(e)},C3.RequireAllObject=function(...n){for(let e of n);},C3.IsFileLike=function(e){return C3.WeakIsInstanceOf(e,Blob)&&"string"==typeof e["name"]},C3.RequireFileLike=function(e){if(!C3.IsFileLike(e))throw new TypeError("expected file")},C3.RequireOptionalFileLike=function(e){C3.IsNullOrUndefined(e)},C3.IsArray=function(e){return Array.isArray(e)},C3.RequireArray=function(e){if(!C3.IsArray(e))throw new TypeError("expected array")},C3.RequireOptionalArray=function(e){C3.IsNullOrUndefined(e)},C3.RequireAllArray=function(...n){for(let e of n);},C3.Is2DArray=function(e){return!(!C3.IsArray(e)||e.length&&!C3.IsArray(e[0]))},C3.Require2DArray=function(n){if(!C3.Is2DArray(n))throw new TypeError("expected 2d array");for(let e of n)if(!C3.IsArray(e))throw new TypeError("expected 2d array")},C3.RequireOptional2DArray=function(e){C3.IsNullOrUndefined(e)},C3.IsFunction=function(e){return"function"==typeof e},C3.RequireFunction=function(e,n){if(!C3.IsFunction(e))throw new TypeError("expected function");if(!C3.IsNullOrUndefined(n)&&e!==n)throw new TypeError("expected same function reference")},C3.RequireOptionalFunction=function(e){C3.IsNullOrUndefined(e)},C3.RequireAllFunction=function(...n){for(let e of n);},C3.RequireAnyFunction=function(n,...r){if(!C3.IsFunction(n))throw new TypeError("expected function");if(!r.length)throw new Error("missing comparison functions");for(let e of r)if(!C3.IsNullOrUndefined(e)&&n===e)return;throw new TypeError("expected same function reference")},C3.RequireOptionalAllFunction=function(...n){if(!C3.IsNullOrUndefined(n))for(let e of n);},C3.IsInstanceOf=function(e,n){return e instanceof n},C3.IsInstanceOfAny=function(n,...r){for(let e of r)if(C3.IsInstanceOf(n,e))return!0;return!1},C3.RequireInstanceOf=function(e,n){if(!C3.IsInstanceOf(e,n))throw new TypeError("unexpected type")},C3.RequireOptionalInstanceOf=function(e,n){C3.IsNullOrUndefined(e)},C3.RequireAllInstanceOf=function(e,...n){for(let e of n);},C3.RequireAnyInstanceOf=function(e,...n){if(!C3.IsInstanceOfAny(e,...n))throw new TypeError("unexpected type")},C3.RequireAnyOptionalInstanceOf=function(e,...n){if(!C3.IsNullOrUndefined(e)&&!C3.IsInstanceOfAny(e,...n))throw new TypeError("unexpected type")},C3.IsArrayOf=function(n,r){for(let e of n)if(!C3.IsInstanceOf(e,r))return!1;return!0},C3.IsArrayOfFiniteNumbers=function(n){for(let e of n)if(!C3.IsFiniteNumber(e))return!1;return!0},C3.RequireArrayOf=function(n,e){for(let e of n);},C3.RequireOptionalArrayOf=function(n,e){if(!C3.IsNullOrUndefined(n))for(let e of n);},C3.RequireOptionalArrayOfFunctions=function(n,e){if(!C3.IsNullOrUndefined(n))for(let e of n);},C3.RequireArrayOfAny=function(n){for(let e of n);},C3.RequireOptionalArrayOfAny=function(n){if(!C3.IsNullOrUndefined(n))for(let e of n);},C3.IsDOMNode=function(e,n){return!(C3.IsNullOrUndefined(e)||!C3.IsString(e.nodeName))&&(!n||C3.equalsNoCase(e.nodeName,n))},C3.RequireDOMNode=function(e,n){if(C3.IsNullOrUndefined(e)||!C3.IsString(e.nodeName))throw new TypeError("expected DOM node");if(n&&!C3.equalsNoCase(e.nodeName,n))throw new TypeError(`expected DOM '${n}' node`)},C3.RequireOptionalDOMNode=function(e,n){C3.IsNullOrUndefined(e)},C3.IsHTMLElement=function(e,n){return!(C3.IsNullOrUndefined(e)||!C3.IsString(e.tagName))&&(!n||C3.equalsNoCase(e.tagName,n))},C3.RequireHTMLElement=function(e,n){if(C3.IsNullOrUndefined(e)||!C3.IsString(e.tagName))throw new TypeError("expected HTML element");if(n&&!C3.equalsNoCase(e.tagName,n))throw new TypeError(`expected HTML '${n}' element`)},C3.RequireOptionalHTMLElement=function(e,n){C3.IsNullOrUndefined(e)},C3.IsDrawable=function(e){return C3.IsHTMLElement(e,"img")||C3.IsHTMLElement(e,"canvas")||C3.IsHTMLElement(e,"video")||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap},C3.RequireDrawable=function(e){if(!C3.IsDrawable(e))throw new TypeError("expected drawable")},C3.RequireOptionalDrawable=function(e){C3.IsNullOrUndefined(e)},C3.IsDrawableOrImageData=function(e){return e instanceof ImageData||C3.IsDrawable(e)},C3.RequireDrawableOrImageData=function(e){if(!C3.IsDrawableOrImageData(e))throw new TypeError("expected drawable or image data")},C3.RequireOptionalDrawableOrImageData=function(e){if(!C3.IsNullOrUndefined(e)&&!C3.IsDrawableOrImageData(e))throw new TypeError("expected drawable or image data")},C3.IsStringLike=function(e){return"string"==typeof e||C3.HtmlString&&e instanceof C3.HtmlString||e instanceof C3.BBString},C3.RequireStringLike=function(e){if(!C3.IsStringLike(e))throw new TypeError("expected string-like")},C3.RequireOptionalStringLike=function(e){C3.IsNullOrUndefined(e)},C3.RequireAllStringLike=function(...n){for(let e of n);},C3.RequireOverride=function(){throw new Error("must be overridden")},C3.NotYetImplemented=function(){throw new Error("not yet implemented")},C3.IsGeneratorFunction=function(e){return e.constructor===function*(){}.constructor},C3.RequireGeneratorFunction=function(e){if(!C3.IsGeneratorFunction(e))throw new Error("expected generator function")},C3.IsIterable=function(e){return"function"===e[Symbol.iterator]},C3.RequireIterable=function(e){if(!C3.IsIterable(e))throw new Error("expected iterable")},C3.IsDefined=function(e){return!C3.IsNullOrUndefined(e)},C3.IsNullOrUndefined=function(e){return null==e},C3.AreArrayElementsOfSameType=function(n){let r=n[0].constructor;for(let e of n)if(e.constructor!==r)return!1;return r},C3.AreArrayElementsOfType=function(n,r){for(let e of n)if(!(e instanceof r))return!1;return!0},Object.getPrototypeOf(Uint8Array));C3.IsTypedArray=function(e){return C3.IsInstanceOf(e,TypedArray)},C3.RequireTypedArray=function(e){},C3.WeakRequireTypedArray=function(e){C3.WeakRequireInstanceOf(e,TypedArray)},C3.WeakRequireAnyInstanceOf=function(e,...n){if(!C3.WeakIsAnyInstanceOf(e,...n))throw new TypeError("unexpected type")},C3.WeakIsAnyInstanceOf=function(e,...n){for(const r of n)if(C3.WeakIsInstanceOf(e,r))return!0;return!1},C3.WeakRequireInstanceOf=function(e,n){if(!C3.WeakIsInstanceOf(e,n))throw new TypeError("unexpected type")},C3.WeakIsInstanceOf=function(e,n){for(;e=Object.getPrototypeOf(e);)if(e.constructor.name===n.name)return!0;return!1},C3X.RequireNumber=C3.RequireNumber,C3X.RequireOptionalNumber=C3.RequireOptionalNumber,C3X.RequireFiniteNumber=C3.RequireFiniteNumber,C3X.RequireOptionalFiniteNumber=C3.RequireOptionalFiniteNumber,C3X.RequireString=C3.RequireString,C3X.RequireOptionalString=C3.RequireOptionalString,C3X.RequireObject=C3.RequireObject,C3X.RequireOptionalObject=C3.RequireOptionalObject,C3X.RequireArray=C3.RequireArray,C3X.RequireOptionalArray=C3.RequireOptionalArray,C3X.RequireFunction=C3.RequireFunction,C3X.RequireOptionalFunction=C3.RequireOptionalFunction,C3X.RequireInstanceOf=C3.RequireInstanceOf,C3X.RequireOptionalInstanceOf=C3.RequireOptionalInstanceOf,C3X.IsNullOrUndefined=C3.IsNullOrUndefined; } // ../lib/misc/jsutil.js { const C3=self.C3,logRafIds=new Map;C3.ColorLog=function(e,t){console.log("%c"+e,"font-weight: bold; color:"+t)},C3.RafLog=function(e,...t){logRafIds.has(e)||logRafIds.set(e,-1),-1===logRafIds.get(e)&&logRafIds.set(e,requestAnimationFrame(()=>{console.log("%c"+e,"font-weight: bold",...t),logRafIds.set(e,-1)}))};let measures;function isValidTypeChange(e,t){let r=C3.getType(e),n=C3.getType(t);return"null"===r||"null"===n||"undefined"!==r&&"undefined"!==n&&r===n}C3.StartMeasure=function(e){performance.mark(e),(measures=measures||new Map).has(e)||measures.set(e,{current:0,total:0,average:0,calls:1,toString:function(){return`${e} :: current => ${this.current.toPrecision(3)} :: average => ${this.average.toPrecision(3)} :: calls => `+this.calls}})},C3.EndMeasure=function(e){performance.measure("measure-"+e,e);const t=performance.getEntriesByName("measure-"+e)[0],r=measures.get(e);r.current=t.duration,r.total+=r.current,r.average=r.total/r.calls,console.log(r.toString()),r.calls++,performance.clearMarks(e),performance.clearMeasures("measure-"+e)},C3.GetCallStack=function(){return(new Error).stack},C3.Debugger=function(){},C3.cast=function(e,t){return e&&e instanceof t?e:null},C3.getName=function(e){return void 0===e?"undefined":null===e?"null":"boolean"==typeof e?"<boolean>":C3.IsNumber(e)?"<number>":C3.IsString(e)?"<string>":C3.IsArray(e)?"<array>":"symbol"==typeof e?"<"+e.toString()+">":C3.IsFunction(e)?e.name&&"Function"!==e.name?e.name:"<anonymous function>":"object"==typeof e?e.constructor&&e.constructor.name&&"Object"!==e.constructor.name?e.constructor.name:"<anonymous object>":"<unknown>"},C3.getType=function(e){return null===e?"null":Array.isArray(e)?"array":typeof e},C3.range=function*(t,r){if(!isFinite(Math.abs(t-r)))throw new Error("Invalid parameters");if(r<t)for(let e=t-1;e>=r;e--)yield e;else for(let e=t;e<r;e++)yield e};let ctorObjectToProxy=new Map,ctorProxyToObject=new Map,proxyToObject=new WeakMap,releasedObjects=new WeakMap;C3.DefendHandler={};const VALID_GET_MISSING_KEYS=new Set(["then","splice"]);function logDefendedObjectWarning(e){console.warn("[Defence] "+e+" @",C3.GetCallStack())}C3.DefendHandler.get=function(e,t){return t in e||"symbol"==typeof t||VALID_GET_MISSING_KEYS.has(t)||logDefendedObjectWarning(`Accessed missing property '${t}' from defended object '${C3.getName(e)}', returning undefined`),releasedObjects.has(e)&&"symbol"!=typeof t&&!VALID_GET_MISSING_KEYS.has(t)&&logDefendedObjectWarning(`Accessed property '${t}' on a released object '${C3.getName(e)}' Object was originally released at: ${releasedObjects.get(e)}) Call stack at access: `),e[t]},C3.DefendHandler.set=function(e,t,r){return t in e||ctorObjectToProxy.has(e)||logDefendedObjectWarning(`Set non-existent property '${t}' to '${r}' on defended object '${C3.getName(e)}'`),isValidTypeChange(e[t],r)||ctorObjectToProxy.has(e)||logDefendedObjectWarning(`Set '${C3.getType(e[t])}' property '${t}' to type '${C3.getType(r)}' on defended object '${C3.getName(e)}'`),releasedObjects.has(e)&&logDefendedObjectWarning(`Set property '${t}' on a released object '${C3.getName(e)}' Object was originally released at: ${releasedObjects.get(e)}) Call stack at access: `),e[t]=r,!0},C3.DefendHandler.deleteProperty=function(e,t){throw new ReferenceError(`Cannot delete property '${t}' from defended object '${C3.getName(e)}'`)},C3.DefendHandler.defineProperty=function(e,t,r){throw new ReferenceError(`Cannot define property '${t}' on defended object '${C3.getName(e)}'`)},C3.DefendHandler.enumerate=function(e){throw new ReferenceError(`Cannot enumerate defended object '${C3.getName(e)}'`)};let checkRafId=-1;function CheckDefendedObjectsUsedCorrectly(){if(checkRafId=-1,0<ctorObjectToProxy.size||0<ctorProxyToObject.size){let e=new Set([...ctorObjectToProxy.keys()].map(e=>C3.getName(e))),t=[...e].join(",");console.warn("An object derived from DefendedBase was not protected with debugDefend(). This will disable some checks. See the coding guidelines! Possible affected class names: "+t),ctorObjectToProxy.clear(),ctorProxyToObject.clear()}}C3.DefendedBase=class{constructor(){if(C3.isDebugDefend&&C3.Supports.Proxies){let e=Object.create(new.target.prototype),t=new Proxy(e,C3.DefendHandler);return ctorObjectToProxy.set(e,t),ctorProxyToObject.set(t,e),proxyToObject.set(t,e),-1===checkRafId&&(checkRafId=requestAnimationFrame(CheckDefendedObjectsUsedCorrectly)),t}}},C3.debugDefend=function(t){if(C3.isDebugDefend&&C3.Supports.Proxies&&t instanceof C3.DefendedBase){if(ctorProxyToObject.has(t)){let e=ctorProxyToObject.get(t);ctorProxyToObject.delete(t),ctorObjectToProxy.delete(e)}return t}return C3.isDebug?Object.seal(t):t},C3.New=function(e,...t){let r;try{r=new e(...t)}catch(e){throw ctorProxyToObject.clear(),ctorObjectToProxy.clear(),e}return C3.isDebugDefend&&VerifyObjectPropertiesConsistent(e,r),C3.debugDefend(r)},C3.Release=function(e){let t=proxyToObject.get(e);t&&releasedObjects.set(t,C3.GetCallStack())},C3.WasReleased=function(e){let t=proxyToObject.get(e);return!!t&&!!releasedObjects.get(t)};let typeProperties=new Map;function getObjectPropertySet(t){let r=new Set;for(let e in t)r.add(e);return r}function VerifyObjectPropertiesConsistent(e,t){let r=getObjectPropertySet(t),n=typeProperties.get(e);if(n){let t=[];for(let e of n.values())r.has(e)?r.delete(e):t.push(e);C3.appendArray(t,[...r]),t.length&&console.warn(`[Defence] '${C3.getName(e)}' constructor creates inconsistent properties: `+t.join(", "))}else typeProperties.set(e,r)}C3.PerfMark=class{constructor(e){this._name="",e&&this.start(e)}start(e){C3.isPerformanceProfiling&&(this._name=e,performance.mark(this._name+"-Start"))}end(){C3.isPerformanceProfiling&&(performance.mark(this._name+"-End"),performance.measure(this._name,this._name+"-Start",this._name+"-End"))}next(e){C3.isPerformanceProfiling&&(this.end(),this._name=e,performance.mark(this._name+"-Start"))}}; } // ../lib/misc/mathutil.js { const C3=self.C3,TWO_PI=2*Math.PI,D_TO_R=Math.PI/180,R_TO_D=180/Math.PI,ALPHAEX_SHIFT=(C3.wrap=function(t,n,e){t=Math.floor(t),n=Math.floor(n);const r=(e=Math.floor(e))-n;if(0==r)return e;if(t<n){const a=e-(n-t)%r;return a===e?0:a}return n+(t-n)%r},C3.mapToRange=function(t,n,e,r,a){const o=e-n;if(0==o&&0===r)return t;const c=a-r;return(t-n)*c/o+r},C3.normalize=function(t,n,e){return n-e==0?1:(t-n)/(e-n)},C3.clamp=function(t,n,e){return t<n?n:e<t?e:t},C3.clampAngle=function(t){return(t%=TWO_PI)<0&&(t+=TWO_PI),t},C3.toRadians=function(t){return t*D_TO_R},C3.toDegrees=function(t){return t*R_TO_D},C3.hypot2DFast=function(t,n){return Math.sqrt(t*t+n*n)},C3.hypot3DFast=function(t,n,e){return Math.sqrt(t*t+n*n+e*e)},C3.distanceTo=function(t,n,e,r){return C3.hypot2DFast(e-t,r-n)},C3.distanceSquared=function(t,n,e,r){const a=e-t,o=r-n;return a*a+o*o},C3.angleTo=function(t,n,e,r){return Math.atan2(r-n,e-t)},C3.angleDiff=function(t,n){if(t===n)return 0;let e=Math.sin(t),r=Math.cos(t),a=Math.sin(n),o=Math.cos(n),c=e*a+r*o;return 1<=c?0:c<=-1?Math.PI:Math.acos(c)},C3.angleRotate=function(t,n,e){let r=Math.sin(t),a=Math.cos(t),o=Math.sin(n),c=Math.cos(n);return Math.acos(r*o+a*c)>e?0<a*o-r*c?C3.clampAngle(t+e):C3.clampAngle(t-e):C3.clampAngle(n)},C3.angleClockwise=function(t,n){let e=Math.sin(t),r=Math.cos(t),a=Math.sin(n),o=Math.cos(n);return r*a-e*o<=0},C3.angleLerp=function(t,n,e,r=0){let a=C3.angleDiff(t,n);const o=TWO_PI*r;return C3.angleClockwise(n,t)?C3.clampAngle(t+(a+o)*e):C3.clampAngle(t-(a+o)*e)},C3.angleLerpClockwise=function(t,n,e,r=0){const a=C3.angleDiff(t,n),o=TWO_PI*r;return C3.angleClockwise(n,t)?C3.clampAngle(t+(a+o)*e):C3.clampAngle(t+(TWO_PI-a+o)*e)},C3.angleLerpAntiClockwise=function(t,n,e,r=0){const a=C3.angleDiff(t,n),o=TWO_PI*r;return C3.angleClockwise(n,t)?C3.clampAngle(t-(-TWO_PI+a-o)*e):C3.clampAngle(t-(a+o)*e)},C3.angleReflect=function(t,n){const e=C3.angleDiff(t,n);return C3.angleClockwise(t,n)?C3.clampAngle(n-e):C3.clampAngle(n+e)},C3.lerp=function(t,n,e){return t+e*(n-t)},C3.unlerp=function(t,n,e){return t===n?0:(e-t)/(n-t)},C3.relerp=function(t,n,e,r,a){return C3.lerp(r,a,C3.unlerp(t,n,e))},C3.qarp=function(t,n,e,r){return C3.lerp(C3.lerp(t,n,r),C3.lerp(n,e,r),r)},C3.cubic=function(t,n,e,r,a){return C3.lerp(C3.qarp(t,n,e,a),C3.qarp(n,e,r,a),a)},C3.cosp=function(t,n,e){return(t+n+(t-n)*Math.cos(e*Math.PI))/2},C3.isPOT=function(t){return 0<t&&0==(t-1&t)},C3.nextHighestPowerOfTwo=function(n){--n;for(let t=1;t<32;t<<=1)n|=n>>t;return n+1},C3.roundToNearestFraction=function(t,n){return Math.round(t*n)/n},C3.floorToNearestFraction=function(t,n){return Math.floor(t*n)/n},C3.roundToDp=function(t,n){n=Math.max(Math.floor(n),0);const e=Math.pow(10,n);return Math.round(t*e)/e},C3.countDecimals=function(t){return Math.floor(t)!==t&&t.toString().split(".")[1].length||0},C3.toFixed=function(t,n){let e=t.toFixed(n),r=e.length-1;for(;0<=r&&"0"===e.charAt(r);--r);return 0<=r&&"."===e.charAt(r)&&--r,r<0?e:e.substr(0,r+1)},C3.PackRGB=function(t,n,e){return C3.clamp(t,0,255)|C3.clamp(n,0,255)<<8|C3.clamp(e,0,255)<<16},1024),ALPHAEX_MAX=1023,RGBEX_SHIFT=16384,RGBEX_MAX=8191,RGBEX_MIN=-8192;function isNegativeZero(t){return 0===t&&1/t<0}C3.PackRGBAEx=function(t,n,e,r){return t=C3.clamp(Math.floor(1024*t),RGBEX_MIN,RGBEX_MAX),n=C3.clamp(Math.floor(1024*n),RGBEX_MIN,RGBEX_MAX),e=C3.clamp(Math.floor(1024*e),RGBEX_MIN,RGBEX_MAX),r=C3.clamp(Math.floor(r*ALPHAEX_MAX),0,ALPHAEX_MAX),t<0&&(t+=RGBEX_SHIFT),n<0&&(n+=RGBEX_SHIFT),e<0&&(e+=RGBEX_SHIFT),-(t*RGBEX_SHIFT*RGBEX_SHIFT*ALPHAEX_SHIFT+n*RGBEX_SHIFT*ALPHAEX_SHIFT+e*ALPHAEX_SHIFT+r)},C3.PackRGBEx=function(t,n,e){return C3.PackRGBAEx(t,n,e,1)},C3.GetRValue=function(n){if(0<=n)return(255&n)/255;{let t=Math.floor(-n/(RGBEX_SHIFT*RGBEX_SHIFT*ALPHAEX_SHIFT));return t>RGBEX_MAX&&(t-=RGBEX_SHIFT),t/1024}},C3.GetGValue=function(n){if(0<=n)return((65280&n)>>8)/255;{let t=Math.floor(-n%(RGBEX_SHIFT*RGBEX_SHIFT*ALPHAEX_SHIFT)/(RGBEX_SHIFT*ALPHAEX_SHIFT));return t>RGBEX_MAX&&(t-=RGBEX_SHIFT),t/1024}},C3.GetBValue=function(n){if(0<=n)return((16711680&n)>>16)/255;{let t=Math.floor(-n%(RGBEX_SHIFT*ALPHAEX_SHIFT)/ALPHAEX_SHIFT);return t>RGBEX_MAX&&(t-=RGBEX_SHIFT),t/1024}},C3.GetAValue=function(t){if(isNegativeZero(t))return 0;if(0<=t)return 1;{const n=Math.floor(-t%ALPHAEX_SHIFT);return n/ALPHAEX_MAX}},C3.greatestCommonDivisor=function(n,e){for(n=Math.floor(n),e=Math.floor(e);0!==e;){let t=e;e=n%e,n=t}return n};const COMMON_ASPECT_RATIOS=[[3,2],[4,3],[5,4],[5,3],[6,5],[14,9],[16,9],[16,10],[21,9]],NO_HIT=(C3.getAspectRatio=function(e,r){if((e=Math.floor(e))===(r=Math.floor(r)))return[1,1];for(let n of COMMON_ASPECT_RATIOS){let t=e/n[0]*n[1];if(Math.abs(r-t)<1)return n.slice(0);if(t=e/n[1]*n[0],Math.abs(r-t)<1)return[n[1],n[0]]}let t=C3.greatestCommonDivisor(e,r);return[e/t,r/t]},C3.segmentsIntersect=function(t,n,e,r,a,o,c,u){const i=Math.min(t,e),l=Math.max(t,e),s=Math.min(a,c),C=Math.max(a,c);if(l<s||C<i)return!1;const f=Math.min(n,r),M=Math.max(n,r),h=Math.min(o,u),A=Math.max(o,u);if(M<h||A<f)return!1;const I=a-t+c-e,_=o-n+u-r,g=e-t,T=r-n,m=c-a,X=u-o,E=Math.abs(T*m-X*g),p=m*_-X*I;if(Math.abs(p)>E)return!1;const P=g*_-T*I;return Math.abs(P)<=E},C3.segmentsIntersectPreCalc=function(t,n,e,r,a,o,c,u,i,l,s,C){const f=Math.min(i,s),M=Math.max(i,s);if(o<f||M<a)return!1;const h=Math.min(l,C),A=Math.max(l,C);if(u<h||A<c)return!1;const I=i-t+s-e,_=l-n+C-r,g=e-t,T=r-n,m=s-i,X=C-l,E=Math.abs(T*m-X*g),p=m*_-X*I;if(Math.abs(p)>E)return!1;const P=g*_-T*I;return Math.abs(P)<=E},C3.segmentIntersectsQuad=function(t,n,e,r,a){const o=Math.min(t,e),c=Math.max(t,e),u=Math.min(n,r),i=Math.max(n,r),l=a.getTlx(),s=a.getTly(),C=a.getTrx(),f=a.getTry(),M=a.getBrx(),h=a.getBry(),A=a.getBlx(),I=a.getBly();return C3.segmentsIntersectPreCalc(t,n,e,r,o,c,u,i,l,s,C,f)||C3.segmentsIntersectPreCalc(t,n,e,r,o,c,u,i,C,f,M,h)||C3.segmentsIntersectPreCalc(t,n,e,r,o,c,u,i,M,h,A,I)||C3.segmentsIntersectPreCalc(t,n,e,r,o,c,u,i,A,I,l,s)},C3.segmentIntersectsAnyN=function(n,e,r,a,o){const c=Math.min(n,r),u=Math.max(n,r),i=Math.min(e,a),l=Math.max(e,a);let s=0;for(let t=o.length-4;s<=t;s+=2)if(C3.segmentsIntersectPreCalc(n,e,r,a,c,u,i,l,o[s],o[s+1],o[s+2],o[s+3]))return!0;return C3.segmentsIntersectPreCalc(n,e,r,a,c,u,i,l,o[s],o[s+1],o[0],o[1])},2),PADDING=1e-6;C3.rayIntersect=function(t,n,e,r,a,o,c,u){const i=e-t,l=r-n,s=c-a,C=u-o,f=i*C-l*s;if(0==f)return NO_HIT;const M=((n-r)*(c-t)+i*(u-n))/f;return 0<M&&M<1+PADDING?(C*(c-t)+(a-c)*(u-n))/f:NO_HIT},C3.rayIntersectExtended=function(t,n,e,r,a,o,c,u,i){const l=(c-a)*i,s=(u-o)*i;return C3.rayIntersect(t,n,e,r,a-l,o-s,c+l,u+s)},C3.isPointInTriangleInclusive=function(t,n,e,r,a,o,c,u){const i=a-e,l=o-r,s=c-e,C=u-r,f=t-e,M=n-r,h=i*i+l*l,A=i*s+l*C,I=i*f+l*M,_=s*s+C*C,g=s*f+C*M,T=1/(h*_-A*A),m=(_*I-A*g)*T,X=(h*g-A*I)*T;return 0<=m&&0<=X&&m+X<=1},C3.triangleCartesianToBarycentric=function(t,n,e,r,a,o,c,u){const i=a-e,l=o-r,s=c-e,C=u-r,f=t-e,M=n-r,h=i*i+l*l,A=i*s+l*C,I=s*s+C*C,_=f*i+M*l,g=f*s+M*C,T=h*I-A*A,m=(I*_-A*g)/T,X=(h*g-A*_)/T,E=1-m-X;return[E,m,X]},C3.triangleBarycentricToCartesian3d=function(t,n,e,r,a,o,c,u,i,l,s,C){return[t*r+n*c+e*l,t*a+n*u+e*s,t*o+n*i+e*C]}; } // ../lib/misc/miscutil.js { const C3=self.C3;let mainDocument=null,baseHref="";if("undefined"!=typeof document){const a=(mainDocument=document).querySelector("base");!(baseHref=a&&a.hasAttribute("href")?a.getAttribute("href"):"")||(baseHref=baseHref.startsWith("/")?baseHref.substr(1):baseHref).endsWith("/")||(baseHref+="/")}C3.GetBaseHref=function(){return baseHref},C3.GetBaseURL=function(){if(!mainDocument)return"";const e=mainDocument.location;return C3.GetPathFromURL(e.origin+e.pathname)+baseHref},C3.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)},C3.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)},C3.GetFileExtension=function(e){let t=e.lastIndexOf(".");return t<1?"":e.substr(t)},C3.SetFileExtension=function(e,t){const n=e.lastIndexOf(".");return-1===n?e+"."+t:e.substr(0,n+1)+t},C3.GetFileNamePart=function(e){let t=e.lastIndexOf(".");return t<1?e:e.substr(0,t)},C3.NormalizeFileSeparator=function(e){return e.replace(/\\/g,"/")},C3.IsFileExtension=function(e,t){const n=e?C3.GetFileExtension(e).slice(1):"";return t===n},C3.FileNameEquals=function(e,t){let n,r;return C3.IsFileLike(e)&&(n=C3.GetFileNamePart(e["name"])),C3.IsString(e)&&(n=C3.GetFileNamePart(e)),C3.IsFileLike(t)&&(r=C3.GetFileNamePart(t["name"])),C3.IsString(t)&&(r=C3.GetFileNamePart(t)),n===r},C3.ParseFilePath=function(e){e=C3.NormalizeFileSeparator(e);let t=/^\w\:\//.exec(e);t?(t=t[0],"/"!==(e=e.slice(3))[0]&&(e="/"+e)):t="";const n=(e=1<(e=e.replace(/\/{2,}/g,"/")).length&&"/"===e.slice(-1)?e.slice(0,-1):e).lastIndexOf("/")+1;let r="",a=e,o,s="";0<n&&(r=e.slice(0,n),a=e.slice(n));const i=(o=a).lastIndexOf("."),l=(0<i&&(s=a.slice(i),o=a.slice(0,-s.length)),t+r+a);return{dir:r,base:a,name:o,root:t,ext:s,full:l}},C3.Wait=function(n,r){return new Promise((e,t)=>{self.setTimeout(e,n,r)})},C3.swallowException=function(e){try{e()}catch(e){C3.isDebug&&console.warn("Swallowed exception: ",e)}},C3.noop=function(){},C3.equalsNoCase=function(e,t){return"string"==typeof e&&"string"==typeof t&&(e===t||e.normalize().toLowerCase()===t.normalize().toLowerCase())},C3.equalsCase=function(e,t){return"string"==typeof e&&"string"==typeof t&&(e===t||e.normalize()===t.normalize())},C3.typedArraySet16=function(e,t,n){e[n++]=t[0],e[n++]=t[1],e[n++]=t[2],e[n++]=t[3],e[n++]=t[4],e[n++]=t[5],e[n++]=t[6],e[n++]=t[7],e[n++]=t[8],e[n++]=t[9],e[n++]=t[10],e[n++]=t[11],e[n++]=t[12],e[n++]=t[13],e[n++]=t[14],e[n]=t[15]},C3.truncateArray=function(e,t){e.length=t},C3.clearArray=function(e){e&&0!==e.length&&C3.truncateArray(e,0)},C3.clear2DArray=function(n){if(n){for(let t=0;t<n.length;t++){let e=n[t];C3.truncateArray(e,0)}C3.truncateArray(n,0)}},C3.extendArray=function(t,n,r){n|=0;const a=t.length;if(!(n<=a))for(let e=a;e<n;++e)t.push(r)},C3.resizeArray=function(e,t,n){const r=e.length;(t|=0)<r?C3.truncateArray(e,t):r<t&&C3.extendArray(e,t,n)},C3.shallowAssignArray=function(e,t){C3.clearArray(e),C3.appendArray(e,t)},C3.appendArray=function(n,r){if(r.length<1e4)n.push(...r);else for(let e=0,t=r.length;e<t;++e)n.push(r[e])},C3.arrayRemove=function(n,r){if(!((r=Math.floor(r))<0||r>=n.length)){let t=n.length-1;for(let e=r;e<t;++e)n[e]=n[e+1];C3.truncateArray(n,t)}},C3.arrayFindRemove=function(e,t){let n=e.indexOf(t);0<=n&&e.splice(n,1)},C3.arraysEqual=function(t,n){let r=t.length;if(n.length!==r)return!1;for(let e=0;e<r;++e)if(t[e]!==n[e])return!1;return!0},C3.arrayFilterOut=function(n,r){let a=[],o=0;for(let t=0,e=n.length;t<e;++t){let e=n[t];r(e)?a.push(e):(n[o]=e,++o)}return C3.truncateArray(n,o),a},C3.arrayRemoveAllInSet=function(n,r){const e=n.length;let a=0;for(let t=0,e=n.length;t<e;++t){let e=n[t];r.has(e)||(n[a++]=e)}return C3.truncateArray(n,a),e-a},C3.isArrayIndexInBounds=function(e,t){return e===Math.floor(e)&&0<=e&&e<t.length},C3.validateArrayIndex=function(e,t){if(!C3.isArrayIndexInBounds(e,t))throw new RangeError("array index out of bounds")},C3.cloneArray=function(e){return e.slice()},C3.deepCloneArray=function(e,n){let r=[];for(let t of e)if(C3.IsObject(t)){let e=n(t);if(!e)throw new Error("missing clone");if(e.constructor!==t.constructor)throw new Error("object is not a clone");r.push(e)}else C3.IsArray(t)?r.push(C3.deepCloneArray(t,n)):r.push(t);return r},C3.clone2DArray=function(t){let n=[];for(let e of t)n.push(e.slice());return n},C3.splitStringAndNormalize=function(e,t=" "){return e?e.split(t).map(e=>e.trim()).filter(e=>!!e):[]},C3.filterSet=function(e,t,n){const r=new Set;for(const a of e.values())t(a)&&(n?r.add(n(a)):r.add(a));return r},C3.mergeSets=function(e,t){return e["union"]?e["union"](t):new Set([...e,...t])},C3.mergeSetsInPlace=function(e,t){for(const n of t)e.add(n);return e},C3.first=function(t){for(let e of t)return e;return null},C3.xor=function(e,t){return!e!=!t},C3.compare=function(e,t,n){switch(t){case 0:return e===n;case 1:return e!==n;case 2:return e<n;case 3:return e<=n;case 4:return n<e;case 5:return n<=e;default:return!1}},C3.hasAnyOwnProperty=function(t){for(let e in t)if(t.hasOwnProperty(e))return!0;return!1},C3.PromiseAllWithProgress=function(i,l){return i.length?new Promise((n,r)=>{const a=[];let o=0,s=!1;for(let t=0,e=i.length;t<e;++t)a.push(void 0),i[t].then(e=>{s||(a[t]=e,++o===i.length?n(a):l(o,i.length))}).catch(e=>{s=!0,r(e)})}):Promise.resolve([])};let memoryCallbacks=[],nextTaskId=(C3.AddLibraryMemoryCallback=function(e){memoryCallbacks.push(e)},C3.GetEstimatedLibraryMemoryUsage=function(){let n=0;for(let t of memoryCallbacks){let e=t();n+=e}return Math.floor(n)},1);const activeTaskIds=new Map,taskMessageChannel=new MessageChannel,activeRPAFids=(taskMessageChannel.port2.onmessage=function(e){const t=e.data,n=activeTaskIds.get(t);activeTaskIds.delete(t),n&&n(performance.now())},C3.RequestUnlimitedAnimationFrame=function(e){const t=nextTaskId++;return activeTaskIds.set(t,e),taskMessageChannel.port1.postMessage(t),t},C3.CancelUnlimitedAnimationFrame=function(e){activeTaskIds.delete(e)},C3.PostTask=C3.RequestUnlimitedAnimationFrame,C3.WaitForNextTask=function(){return new Promise(e=>C3.PostTask(e))},new Set);C3.RequestPostAnimationFrame=function(t){const n=self.requestAnimationFrame(async e=>{await C3.WaitForNextTask(),activeRPAFids.has(n)&&(activeRPAFids.delete(n),t(e))});return activeRPAFids.add(n),n},C3.CancelPostAnimationFrame=function(e){activeRPAFids.has(e)&&(self.cancelAnimationFrame(e),activeRPAFids.delete(e))}; } // lib/misc/runtimeutil.js { const C3=self.C3;C3.IsAbsoluteURL=function(e){return/^(?:[a-z\-]+:)?\/\//.test(e)||"data:"===e.substr(0,5)||"blob:"===e.substr(0,5)},C3.IsRelativeURL=function(e){return!C3.IsAbsoluteURL(e)},C3.ThrowIfNotOk=function(e){if(!e.ok)throw new Error(`fetch '${e.url}' response returned ${e.status} `+e.statusText)},C3.FetchOk=function(e,t){return fetch(e,t).then(e=>(C3.ThrowIfNotOk(e),e))},C3.FetchText=function(e){return C3.FetchOk(e).then(e=>e.text())},C3.FetchJson=function(e){return C3.FetchOk(e).then(e=>e.json())},C3.FetchBlob=function(e){return C3.FetchOk(e).then(e=>e.blob())},C3.FetchArrayBuffer=function(e){return C3.FetchOk(e).then(e=>e.arrayBuffer())},C3.FetchImage=function(r){return new Promise((e,t)=>{const n=new Image;n.onload=()=>e(n),n.onerror=e=>t(e),n.src=r})},C3.BlobToArrayBuffer=function(r){return"function"==typeof r["arrayBuffer"]?r["arrayBuffer"]():new Promise((e,t)=>{const n=new FileReader;n.onload=()=>e(n.result),n.onerror=()=>t(n.error),n.readAsArrayBuffer(r)})},C3.BlobToString=function(r){return"function"==typeof r["text"]?r["text"]():new Promise((e,t)=>{const n=new FileReader;n.onload=()=>e(n.result),n.onerror=()=>t(n.error),n.readAsText(r)})},C3.BlobToJson=function(e){return C3.BlobToString(e).then(e=>JSON.parse(e))},C3.BlobToImage=async function(e,t){let n=URL.createObjectURL(e);try{const r=await C3.FetchImage(n);return URL.revokeObjectURL(n),n="",t&&"function"==typeof r["decode"]&&await r["decode"](),r}finally{n&&URL.revokeObjectURL(n)}},C3.CreateCanvas=function(e,t){if("undefined"==typeof document||"function"!=typeof document.createElement)return new OffscreenCanvas(e,t);{const n=document.createElement("canvas");return n.width=e,n.height=t,n}},C3.CanvasToBlob=function(t,n,r){if("number"!=typeof r&&(r=1),n=n||"image/png",r=C3.clamp(r,0,1),t["convertToBlob"])return t["convertToBlob"]({"type":n,"quality":r});if(t.toBlob)return new Promise(e=>t.toBlob(e,n,r));throw new Error("could not convert canvas to blob")},C3.DrawableToBlob=function(e,t,n){const r=C3.CreateCanvas(e.width,e.height),o=r.getContext("2d");return o.drawImage(e,0,0),C3.CanvasToBlob(r,t,n)},C3.ImageDataToBlob=function(e,t,n){if(C3.Supports.ImageBitmapOptions)return createImageBitmap(e,{"premultiplyAlpha":"none"}).then(e=>C3.DrawableToBlob(e,t,n));if(C3.Supports.ImageBitmap)return createImageBitmap(e).then(e=>C3.DrawableToBlob(e,t,n));{const r=C3.CreateCanvas(e.width,e.height),o=r.getContext("2d");return o.putImageData(e,0,0),C3.CanvasToBlob(r,t,n)}},C3.CopySet=function(e,t){e.clear();for(const n of t)e.add(n)},C3.MapToObject=function(e){const t=Object.create(null);for(const[n,r]of e.entries())t[n]=r;return t},C3.ObjectToMap=function(e,t){t.clear();for(const[n,r]of Object.entries(e))t.set(n,r)},C3.ToSuperJSON=function t(e){if("object"!=typeof e||null===e)return e;if(e instanceof Set)return{"_c3type_":"set","data":[...e].map(e=>t(e))};if(e instanceof Map)return{"_c3type_":"map","data":[...e].map(e=>[e[0],t(e[1])])};{const n=Object.create(null);for(const[r,o]of Object.entries(e))n[r]=t(o);return n}},C3.FromSuperJSON=function t(e){if("object"==typeof e&null!==e){if("set"===e["_c3type_"])return new Set(e["data"].map(e=>t(e)));if("map"===e["_c3type_"])return new Map(e["data"].map(e=>[e[0],t(e[1])]));{const n=Object.create(null);for(const[r,o]of Object.entries(e))n[r]=t(o);return n}}return e},C3.CSSToCamelCase=function(e){if(e.startsWith("--"))return e;let t="",n=!1,r=0;for(const o of e)"-"===o?0<r&&(n=!0):n?(t+=o.toUpperCase(),n=!1):t+=o,++r;return t},C3.IsIterator=function(e){return"object"==typeof e&&"function"==typeof e.next},C3.MakeFilledArray=function(t,n){const r=[];if("function"==typeof n)for(let e=0;e<t;++e)r.push(n());else for(let e=0;e<t;++e)r.push(n);return r}; } // ../lib/misc/color.js { const C3=self.C3,HSL_TEST=/([0-9.]+),([0-9.]+)\%?,([0-9.]+)\%?/i,HSLA_TEST=/([0-9.]+),([0-9.]+)\%?,([0-9.]+)\%?,([0-9.])/i;function padTwoDigits(t){return 0===t.length?"00":1===t.length?"0"+t:t}function hueToRGB(t,s,e){return e<0&&(e+=1),1<e&&--e,e<1/6?t+6*(s-t)*e:e<.5?s:e<2/3?t+(s-t)*(2/3-e)*6:t}C3.Color=class{constructor(t,s,e,r){this._r=NaN,this._g=NaN,this._b=NaN,this._a=NaN,this._r=0,this._g=0,this._b=0,this._a=0,t instanceof C3.Color?this.set(t):this.setRgba(t||0,s||0,e||0,r||0)}setRgb(t,s,e){return this._r=+t,this._g=+s,this._b=+e,this.clamp(),this}setRgba(t,s,e,r){return this._r=+t,this._g=+s,this._b=+e,this._a=+r,this.clamp(),this}set(t){return this._r=t._r,this._g=t._g,this._b=t._b,this._a=t._a,this}copy(t){return this.set(t)}add(t){this._r+=t._r,this._g+=t._g,this._b+=t._b,this._a+=t._a,this.clamp()}addRgb(t,s,e,r=0){this._r+=+t,this._g+=+s,this._b+=+e,this._a+=+r,this.clamp()}diff(t){this.setR(Math.max(this._r,t._r)-Math.min(this._r,t._r)),this.setG(Math.max(this._g,t._g)-Math.min(this._g,t._g)),this.setB(Math.max(this._b,t._b)-Math.min(this._b,t._b)),this.setA(Math.max(this._a,t._a)-Math.min(this._a,t._a)),this.clamp()}copyRgb(t){this._r=t._r,this._g=t._g,this._b=t._b}setR(t){this._r=C3.clamp(+t,0,1)}getR(){return this._r}setG(t){this._g=C3.clamp(+t,0,1)}getG(){return this._g}setB(t){this._b=C3.clamp(+t,0,1)}getB(){return this._b}setA(t){this._a=C3.clamp(+t,0,1)}getA(){return this._a}clone(){return C3.New(C3.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(t,s){t[s++]=this._r,t[s++]=this._g,t[s++]=this._b,t[s]=this._a}writeRGBToTypedArray(t,s){t[s++]=this._r,t[s++]=this._g,t[s]=this._b}equals(t){return this._r===t._r&&this._g===t._g&&this._b===t._b&&this._a===t._a}equalsIgnoringAlpha(t){return this._r===t._r&&this._g===t._g&&this._b===t._b}equalsRgb(t,s,e){return this._r===t&&this._g===s&&this._b===e}equalsRgba(t,s,e,r){return this._r===t&&this._g===s&&this._b===e&&this._a===r}equalsF32Array(t,s){return t[s]===Math.fround(this._r)&&t[s+1]===Math.fround(this._g)&&t[s+2]===Math.fround(this._b)&&t[s+3]===Math.fround(this._a)}equalsRGBF32Array(t,s){return t[s]===Math.fround(this._r)&&t[s+1]===Math.fround(this._g)&&t[s+2]===Math.fround(this._b)}multiply(t){this._r*=t._r,this._g*=t._g,this._b*=t._b,this._a*=t._a}multiplyAlpha(t){this._r*=t,this._g*=t,this._b*=t,this._a*=t}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=C3.clamp(this._r,0,1),this._g=C3.clamp(this._g,0,1),this._b=C3.clamp(this._b,0,1),this._a=C3.clamp(this._a,0,1),this}setFromRgbValue(t){this._r=C3.GetRValue(t),this._g=C3.GetGValue(t),this._b=C3.GetBValue(t),this._a=C3.GetAValue(t)}getCssRgb(t,s,e){const r=C3.IsFiniteNumber(t)?t:this.getR(),i=C3.IsFiniteNumber(s)?s:this.getG(),a=C3.IsFiniteNumber(e)?e:this.getB();return`rgb(${100*r}%, ${100*i}%, ${100*a}%)`}getCssRgba(t,s,e,r){const i=C3.IsFiniteNumber(t)?t:this.getR(),a=C3.IsFiniteNumber(s)?s:this.getG(),h=C3.IsFiniteNumber(e)?e:this.getB(),n=C3.IsFiniteNumber(r)?r:this.getA();return`rgba(${100*i}%, ${100*a}%, ${100*h}%, ${n})`}toHexString(){const t=Math.round(255*this.getR()),s=Math.round(255*this.getG()),e=Math.round(255*this.getB());return"#"+padTwoDigits(t.toString(16))+padTwoDigits(s.toString(16))+padTwoDigits(e.toString(16))}parseHexString(t){if("string"!=typeof t)return!1;let s,e,r;if(3===(t="#"===(t=t.trim()).charAt(0)?t.substr(1):t).length)s=parseInt(t[0],16)/15,e=parseInt(t[1],16)/15,r=parseInt(t[2],16)/15;else{if(6!==t.length)return!1;s=parseInt(t.substr(0,2),16)/255,e=parseInt(t.substr(2,2),16)/255,r=parseInt(t.substr(4,2),16)/255}return isFinite(s)&&this.setR(s),isFinite(e)&&this.setG(e),isFinite(r)&&this.setB(r),this.setA(1),!0}toCommaSeparatedRgb(){const t=Math.round(255*this.getR()),s=Math.round(255*this.getG()),e=Math.round(255*this.getB());return t+`, ${s}, `+e}toRgbArray(){const t=Math.round(255*this.getR()),s=Math.round(255*this.getG()),e=Math.round(255*this.getB());return[t,s,e]}parseCommaSeparatedRgb(t){if("string"!=typeof t)return!1;const s=(t=t.replace(/^rgb\(|\)|%/,"")).split(",");if(s.length<3)return!1;const e=parseInt(s[0].trim(),10)/255,r=parseInt(s[1].trim(),10)/255,i=parseInt(s[2].trim(),10)/255;return isFinite(e)&&this.setR(e),isFinite(r)&&this.setG(r),isFinite(i)&&this.setB(i),this.setA(1),!0}parseCommaSeparatedPercentageRgb(t){if("string"!=typeof t)return!1;const s=(t=t.replace(/^rgb\(|\)|%/,"")).split(",");if(s.length<3)return!1;const e=parseInt(s[0].trim(),10)/100,r=parseInt(s[1].trim(),10)/100,i=parseInt(s[2].trim(),10)/100;return isFinite(e)&&this.setR(e),isFinite(r)&&this.setG(r),isFinite(i)&&this.setB(i),this.setA(1),!0}parseCommaSeparatedRgba(t){if("string"!=typeof t)return!1;const s=(t=t.replace(/^rgba\(|\)|%/,"")).split(",");if(s.length<4)return!1;const e=parseInt(s[0].trim(),10)/255,r=parseInt(s[1].trim(),10)/255,i=parseInt(s[2].trim(),10)/255,a=parseFloat(s[3].trim());return isFinite(e)&&this.setR(e),isFinite(r)&&this.setG(r),isFinite(i)&&this.setB(i),isFinite(a)&&this.setA(a),!0}parseCommaSeparatedPercentageRgba(t){if("string"!=typeof t)return!1;const s=(t=t.replace(/^rgba\(|\)|%/,"")).split(",");if(s.length<4)return!1;const e=parseInt(s[0].trim(),10)/100,r=parseInt(s[1].trim(),10)/100,i=parseInt(s[2].trim(),10)/100,a=parseFloat(s[3].trim());return isFinite(e)&&this.setR(e),isFinite(r)&&this.setG(r),isFinite(i)&&this.setB(i),isFinite(a)&&this.setA(a),!0}parseString(t){if("string"!=typeof t)return!1;if((t=t.replace(/\s+/,"")).includes(",")){if(t.startsWith("rgb("))return t.includes("%")?this.parseCommaSeparatedPercentageRgb(t):this.parseCommaSeparatedRgb(t);if(t.startsWith("rgba("))return t.includes("%")?this.parseCommaSeparatedPercentageRgba(t):this.parseCommaSeparatedRgba(t);if(t.startsWith("hsl(")||t.startsWith("hsla("))return this.parseHSLString(t);{const s=t.split(",");return t.includes("%")?3===s.length?this.parseCommaSeparatedPercentageRgb(t):4===s.length&&this.parseCommaSeparatedPercentageRgba(t):3===s.length?this.parseCommaSeparatedRgb(t):4===s.length&&this.parseCommaSeparatedRgba(t)}}return this.parseHexString(t)}toJSON(){return[this._r,this._g,this._b,this._a]}setFromHSLA(t,s,e,r){let i,a,h;if(t%=360,s=C3.clamp(s,0,100),e=C3.clamp(e,0,100),r=C3.clamp(r,0,1),t/=360,e/=100,0===(s/=100))i=a=h=e;else{const n=e<.5?e*(1+s):e+s-e*s,_=2*e-n;i=hueToRGB(_,n,t+1/3),a=hueToRGB(_,n,t),h=hueToRGB(_,n,t-1/3)}return this.setR(i),this.setG(a),this.setB(h),this.setA(r),this}parseHSLString(t){const s=t.replace(/ |hsl|hsla|\(|\)|;/gi,""),e=HSL_TEST.exec(s),r=HSLA_TEST.exec(s);return e&&4===e.length?(this.setFromHSLA(+e[1],+e[2],+e[3],1),!0):!(!r||5!==r.length||(this.setFromHSLA(+e[1],+e[2],+e[3],+e[4]),0))}toHSLAString(){const t=this._r,s=this._g,e=this._b,r=this._a,i=C3.Color.GetHue(t,s,e),a=C3.Color.GetSaturation(t,s,e),h=C3.Color.GetLuminosity(t,s,e);return`hsla(${i}, ${a}%, ${h}%, ${r})`}toHSLAArray(){const t=this._r,s=this._g,e=this._b;return[C3.Color.GetHue(t,s,e),C3.Color.GetSaturation(t,s,e),C3.Color.GetLuminosity(t,s,e),this._a]}setFromJSON(t){!Array.isArray(t)||t.length<3||(this._r=t[0],this._g=t[1],this._b=t[2],this._a=4<=t.length?t[3]:1)}set r(t){this.setR(t)}get r(){return this.getR()}set g(t){this.setG(t)}get g(){return this.getG()}set b(t){this.setB(t)}get b(){return this.getB()}set a(t){this.setA(t)}get a(){return this.getA()}setAtIndex(t,s){switch(t){case 0:this.setR(s);break;case 1:this.setG(s);break;case 2:this.setB(s);break;case 3:this.setA(s);break;default:throw new RangeError("invalid color index")}}getAtIndex(t){switch(t){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(t,s){let e,r;if(Array.isArray(t))(e=new C3.Color).setFromJSON(t);else{if(!(t instanceof C3.Color))throw new Error("unexpected type");e=t}if(Array.isArray(s))(r=new C3.Color).setFromJSON(s);else{if(!(s instanceof C3.Color))throw new Error("unexpected type");r=s}return e.equals(r)}static DiffChannel(t,s){return C3.clamp(Math.max(t,s)-Math.min(t,s),0,1)}static Diff(t,s){const e=new C3.Color;return e.setR(Math.max(t._r,s._r)-Math.min(t._r,s._r)),e.setG(Math.max(t._g,s._g)-Math.min(t._g,s._g)),e.setB(Math.max(t._b,s._b)-Math.min(t._b,s._b)),e.setA(Math.max(t._a,s._a)-Math.min(t._a,s._a)),e}static DiffNoAlpha(t,s){const e=new C3.Color(0,0,0,1);return e.setR(Math.max(t._r,s._r)-Math.min(t._r,s._r)),e.setG(Math.max(t._g,s._g)-Math.min(t._g,s._g)),e.setB(Math.max(t._b,s._b)-Math.min(t._b,s._b)),e}static GetHue(t,s,e){const r=Math.max(t,s,e),i=Math.min(t,s,e);if(r===i)return 0;let a=0;switch(r){case t:a=(s-e)/(r-i)+(s<e?6:0);break;case s:a=(e-t)/(r-i)+2;break;case e:a=(t-s)/(r-i)+4}return Math.round(a/6*360)}static GetSaturation(t,s,e){const r=Math.max(t,s,e),i=Math.min(t,s,e);if(r===i)return 0;const a=(r+i)/2,h=r-i,n=.5<a?h/(2-r-i):h/(r+i);return Math.round(100*n)}static GetLuminosity(t,s,e){const r=Math.max(t,s,e),i=Math.min(t,s,e),a=(r+i)/2;return r?Math.round(100*a):0}},C3.Color.White=Object.freeze(C3.New(C3.Color,1,1,1,1)),C3.Color.Black=Object.freeze(C3.New(C3.Color,0,0,0,1)),C3.Color.TransparentBlack=Object.freeze(C3.New(C3.Color,0,0,0,0)); } // ../lib/misc/vector2.js { const C3=self.C3;C3.Vector2=class{constructor(t,s){this._x=0,this._y=0,t instanceof C3.Vector2?this.copy(t):this.set(t||0,s||0)}set(t,s){this._x=+t,this._y=+s}copy(t){this._x=t._x,this._y=t._y}equals(t){return this._x===t._x&&this._y===t._y}equalsValues(t,s){return this._x===t&&this._y===s}equalsF32Array(t,s){return t[s]===Math.fround(this._x)&&t[s+1]===Math.fround(this._y)}setX(t){this._x=+t}getX(){return this._x}setY(t){this._y=+t}getY(){return this._y}toArray(){return[this._x,this._y]}toTypedArray(){return new Float64Array(this.toArray())}writeToTypedArray(t,s){t[s++]=this._x,t[s]=this._y}offset(t,s){this._x+=+t,this._y+=+s}scale(t,s){this._x*=t,this._y*=s}divide(t,s){this._x/=t,this._y/=s}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 C3.angleTo(0,0,this._x,this._y)}lengthSquared(){return this._x*this._x+this._y*this._y}length(){return C3.hypot2DFast(this._x,this._y)}rotatePrecalc(t,s){const h=this._x*s-this._y*t;this._y=this._y*s+this._x*t,this._x=h}rotate(t){0!==t&&this.rotatePrecalc(Math.sin(t),Math.cos(t))}rotateAbout(t,s,h){0===t||s===this._x&&h===this._y||(this._x-=s,this._y-=h,this.rotatePrecalc(Math.sin(t),Math.cos(t)),this._x+=+s,this._y+=+h)}move(t,s){0!==s&&(this._x+=Math.cos(t)*s,this._y+=Math.sin(t)*s)}normalize(){const t=this.length();0!==t&&1!==t&&(this._x/=t,this._y/=t)}clamp(t,s){this._x=C3.clamp(this._x,t,s),this._y=C3.clamp(this._y,t,s)}dot(t){return this._x*t._x+this._y*t._y}reverse(){this._x=-this._x,this._y=-this._y}perp(){let t=this._x;return this._x=this._y,this._y=-t,this}}; } // ../lib/misc/rect.js { const C3=self.C3;C3.Rect=class{constructor(t,h,i,o){this._left=NaN,this._top=NaN,this._right=NaN,this._bottom=NaN,this._left=0,this._top=0,this._right=0,this._bottom=0,t instanceof C3.Rect?this.copy(t):this.set(t||0,h||0,i||0,o||0)}set(t,h,i,o){this._left=+t,this._top=+h,this._right=+i,this._bottom=+o}setWH(t,h,i,o){h=+h,this._left=t=+t,this._top=h,this._right=t+ +i,this._bottom=h+ +o}copy(t){this._left=+t._left,this._top=+t._top,this._right=+t._right,this._bottom=+t._bottom}clone(){return new C3.Rect(this._left,this._top,this._right,this._bottom)}static Merge(t,h){const i=new C3.Rect;return i.setLeft(Math.min(t._left,h._left)),i.setTop(Math.min(t._top,h._top)),i.setRight(Math.max(t._right,h._right)),i.setBottom(Math.max(t._bottom,h._bottom)),i}static FromObject(t){return new C3.Rect(t.left,t.top,t.right,t.bottom)}equals(t){return this._left===t._left&&this._top===t._top&&this._right===t._right&&this._bottom===t._bottom}equalsWH(t,h,i,o){return this._left===t&&this._top===h&&this.width()===i&&this.height()===o}equalsF32Array(t,h){return t[h]===Math.fround(this._left)&&t[h+1]===Math.fround(this._top)&&t[h+2]===Math.fround(this._right)&&t[h+3]===Math.fround(this._bottom)}setLeft(t){this._left=+t}getLeft(){return this._left}setTop(t){this._top=+t}getTop(){return this._top}setRight(t){this._right=+t}getRight(){return this._right}setBottom(t){this._bottom=+t}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(t){return C3.New(C3.Rect,t.left,t.top,t.right,t.bottom)}writeToTypedArray(t,h){t[h++]=this._left,t[h++]=this._top,t[h++]=this._right,t[h]=this._bottom}writeAsQuadToTypedArray(t,h){t[h++]=this._left,t[h++]=this._top,t[h++]=this._right,t[h++]=this._top,t[h++]=this._right,t[h++]=this._bottom,t[h++]=this._left,t[h]=this._bottom}writeAsQuadToTypedArray3D(t,h,i){t[h++]=this._left,t[h++]=this._top,t[h++]=i,t[h++]=this._right,t[h++]=this._top,t[h++]=i,t[h++]=this._right,t[h++]=this._bottom,t[h++]=i,t[h++]=this._left,t[h++]=this._bottom,t[h]=i}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(t,h){h=+h,this._left+=t=+t,this._top+=h,this._right+=t,this._bottom+=h}offsetLeft(t){this._left+=+t}offsetTop(t){this._top+=+t}offsetRight(t){this._right+=+t}offsetBottom(t){this._bottom+=+t}toSquare(t){if("x"!==t)throw new Error("invalid axis, only 'x' supported");this._top<this._bottom?this._left<this._right?this._bottom=this._top+this.width():this._bottom=this._top-this.width():this._left<this._right?this._bottom=this._top-this.width():this._bottom=this._top+this.width()}inflate(t,h){h=+h,this._left-=t=+t,this._top-=h,this._right+=t,this._bottom+=h}deflate(t,h){h=+h,this._left+=t=+t,this._top+=h,this._right-=t,this._bottom-=h}multiply(t,h){this._left*=t,this._top*=h,this._right*=t,this._bottom*=h}divide(t,h){this._left/=t,this._top/=h,this._right/=t,this._bottom/=h}mirrorAround(t){this._left=+t-this._left,this._right=+t-this._right}flipAround(t){this._top=+t-this._top,this._bottom=+t-this._bottom}rotate90DegreesAround(t,h){const i=this.width(),o=this.height(),s=this.getLeft()+i*t,_=this.getTop()+o*h;this.setWH(s-o*h,_-i*t,o,i)}swapLeftRight(){const t=this._left;this._left=this._right,this._right=t}swapTopBottom(){const t=this._top;this._top=this._bottom,this._bottom=t}shuntY(t){const h=this._top;this._top=+t-this._bottom,this._bottom=+t-h}round(){this._left=Math.round(this._left),this._top=Math.round(this._top),this._right=Math.round(this._right),this._bottom=Math.round(this._bottom)}roundInner(){this._left=Math.ceil(this._left),this._top=Math.ceil(this._top),this._right=Math.floor(this._right),this._bottom=Math.floor(this._bottom)}roundOuter(){this._left=Math.floor(this._left),this._top=Math.floor(this._top),this._right=Math.ceil(this._right),this._bottom=Math.ceil(this._bottom)}floor(){this._left=Math.floor(this._left),this._top=Math.floor(this._top),this._right=Math.floor(this._right),this._bottom=Math.floor(this._bottom)}ceil(){this._left=Math.ceil(this._left),this._top=Math.ceil(this._top),this._right=Math.ceil(this._right),this._bottom=Math.ceil(this._bottom)}clamp(t,h,i,o){this._left=Math.max(this._left,+t),this._top=Math.max(this._top,+h),this._right=Math.min(this._right,+i),this._bottom=Math.min(this._bottom,+o)}clampBoth(t,h,i,o){t=+t,h=+h,i=+i,o=+o,this._left=C3.clamp(this._left,t,i),this._top=C3.clamp(this._top,h,o),this._right=C3.clamp(this._right,t,i),this._bottom=C3.clamp(this._bottom,h,o)}normalize(){this._left>this._right&&this.swapLeftRight(),this._top>this._bottom&&this.swapTopBottom()}intersectsRect(t){return!(t._right<this._left||t._bottom<this._top||t._left>this._right||t._top>this._bottom)}intersectsRectOffset(t,h,i){return!(t._right+h<this._left||t._bottom+i<this._top||t._left+h>this._right||t._top+i>this._bottom)}containsPoint(t,h){return t>=this._left&&t<=this._right&&h>=this._top&&h<=this._bottom}containsRect(t){return t._left>=this._left&&t._top>=this._top&&t._right<=this._right&&t._bottom<=this._bottom}expandToContain(t){t._left<this._left&&(this._left=+t._left),t._top<this._top&&(this._top=+t._top),t._right>this._right&&(this._right=+t._right),t._bottom>this._bottom&&(this._bottom=+t._bottom)}lerpInto(t){this._left=C3.lerp(t._left,t._right,this._left),this._top=C3.lerp(t._top,t._bottom,this._top),this._right=C3.lerp(t._left,t._right,this._right),this._bottom=C3.lerp(t._top,t._bottom,this._bottom)}}; } // ../lib/misc/quad.js { const C3=self.C3;C3.Quad=class{constructor(t,s,i,h,_,r,l,e){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,t instanceof C3.Quad?this.copy(t):this.set(t||0,s||0,i||0,h||0,_||0,r||0,l||0,e||0)}set(t,s,i,h,_,r,l,e){this._tlx=+t,this._tly=+s,this._trx=+i,this._try=+h,this._brx=+_,this._bry=+r,this._blx=+l,this._bly=+e}setRect(t,s,i,h){this.set(t,s,i,s,i,h,t,h)}copy(t){this._tlx=t._tlx,this._tly=t._tly,this._trx=t._trx,this._try=t._try,this._brx=t._brx,this._bry=t._bry,this._blx=t._blx,this._bly=t._bly}equals(t){return this._tlx===t._tlx&&this._tly===t._tly&&this._trx===t._trx&&this._try===t._try&&this._brx===t._brx&&this._bry===t._bry&&this._blx===t._blx&&this._bly===t._bly}setTlx(t){this._tlx=+t}getTlx(){return this._tlx}setTly(t){this._tly=+t}getTly(){return this._tly}setTrx(t){this._trx=+t}getTrx(){return this._trx}setTry(t){this._try=+t}getTry(){return this._try}setBrx(t){this._brx=+t}getBrx(){return this._brx}setBry(t){this._bry=+t}getBry(){return this._bry}setBlx(t){this._blx=+t}getBlx(){return this._blx}setBly(t){this._bly=+t}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(t){return C3.New(C3.Quad,t.p1.x,t.p1.y,t.p2.x,t.p2.y,t.p3.x,t.p3.y,t.p4.x,t.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(t,s){t[s++]=this._tlx,t[s++]=this._tly,t[s++]=this._trx,t[s++]=this._try,t[s++]=this._brx,t[s++]=this._bry,t[s++]=this._blx,t[s]=this._bly}writeToTypedArray3D(t,s,i){t[s++]=this._tlx,t[s++]=this._tly,t[s++]=i,t[s++]=this._trx,t[s++]=this._try,t[s++]=i,t[s++]=this._brx,t[s++]=this._bry,t[s++]=i,t[s++]=this._blx,t[s++]=this._bly,t[s]=i}offset(t,s){s=+s,this._tlx+=t=+t,this._tly+=s,this._trx+=t,this._try+=s,this._brx+=t,this._bry+=s,this._blx+=t,this._bly+=s}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(t){this._tlx=t._left,this._tly=t._top,this._trx=t._right,this._try=t._top,this._brx=t._right,this._bry=t._bottom,this._blx=t._left,this._bly=t._bottom}setFromRotatedRect(t,s){0===s?this.setFromRect(t):this.setFromRotatedRectPrecalc(t,Math.sin(s),Math.cos(s))}setFromRotatedRectPrecalc(t,s,i){const h=t._left*s,_=t._top*s,r=t._right*s,l=t._bottom*s,e=t._left*i,x=t._top*i,y=t._right*i,b=t._bottom*i;this._tlx=e-_,this._tly=x+h,this._trx=y-_,this._try=x+r,this._brx=y-l,this._bry=b+r,this._blx=e-l,this._bly=b+h}getBoundingBox(t){t.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(t,s){let i=this._trx-this._tlx,h=this._try-this._tly;const _=this._brx-this._tlx,r=this._bry-this._tly,l=t-this._tlx,e=s-this._tly;let x=i*i+h*h,y=i*_+h*r,b=i*l+h*e;const a=_*_+r*r,n=_*l+r*e;let o=1/(x*a-y*y),c=(a*b-y*n)*o,u=(x*n-y*b)*o;return 0<=c&&0<u&&c+u<1||(u=((x=(i=this._blx-this._tlx)*i+(h=this._bly-this._tly)*h)*n-(y=i*_+h*r)*(b=i*l+h*e))*(o=1/(x*a-y*y)),0<=(c=(a*b-y*n)*o)&&0<u&&c+u<1)}midX(){return(this._tlx+this._trx+this._brx+this._blx)/4}midY(){return(this._tly+this._try+this._bry+this._bly)/4}intersectsSegment(t,s,i,h){return!(!this.containsPoint(t,s)&&!this.containsPoint(i,h))||C3.segmentIntersectsQuad(t,s,i,h,this)}intersectsQuad(t){let s=t.midX(),i=t.midY();if(this.containsPoint(s,i))return!0;if(s=this.midX(),i=this.midY(),t.containsPoint(s,i))return!0;const h=this._tlx,_=this._tly,r=this._trx,l=this._try,e=this._brx,x=this._bry,y=this._blx,b=this._bly;return C3.segmentIntersectsQuad(h,_,r,l,t)||C3.segmentIntersectsQuad(r,l,e,x,t)||C3.segmentIntersectsQuad(e,x,y,b,t)||C3.segmentIntersectsQuad(y,b,h,_,t)}rotatePointsAnticlockwise(){const t=this._tlx,s=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=t,this._bly=s}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(t,s){const i=this._getAtIndex(t);this._setAtIndex(t,this._getAtIndex(s)),this._setAtIndex(s,i)}_getAtIndex(t){switch(t){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(t,s){switch(s=+s,t){case 0:this._tlx=s;break;case 1:this._tly=s;break;case 2:this._trx=s;break;case 3:this._try=s;break;case 4:this._brx=s;break;case 5:this._bry=s;break;case 6:this._blx=s;break;case 7:this._bly=s;break;default:throw new RangeError("invalid quad point index")}}}; } // lib/misc/collisionPoly.js { const C3=self.C3,assert=self.assert,DEFAULT_POLY_POINTS=[0,0,1,0,1,1,0,1],tempQuad=C3.New(C3.Quad);C3.CollisionPoly=class extends C3.DefendedBase{constructor(t,s=!0){super(),t=t||DEFAULT_POLY_POINTS,this._ptsArr=Float64Array.from(t),this._bbox=new C3.Rect,this._isBboxChanged=!0,this._enabled=s}Release(){}pointsArr(){return this._ptsArr}pointCount(){return this._ptsArr.length/2}setPoints(t){this._ptsArr.length===t.length?this._ptsArr.set(t):this._ptsArr=Float64Array.from(t),this._isBboxChanged=!0}setDefaultPoints(){this.setPoints(DEFAULT_POLY_POINTS)}copy(t){this.setPoints(t._ptsArr)}setBboxChanged(){this._isBboxChanged=!0}_updateBbox(){if(this._isBboxChanged){const i=this._ptsArr;let e=i[0],r=i[1],n=e,o=r;for(let t=0,s=i.length;t<s;t+=2){const h=i[t],l=i[t+1];h<e&&(e=h),h>n&&(n=h),l<r&&(r=l),l>o&&(o=l)}this._bbox.set(e,r,n,o),this._isBboxChanged=!1}}setFromRect(t,s,e){let r=this._ptsArr;8!==r.length&&(r=new Float64Array(8),this._ptsArr=r),r[0]=t.getLeft()-s,r[1]=t.getTop()-e,r[2]=t.getRight()-s,r[3]=t.getTop()-e,r[4]=t.getRight()-s,r[5]=t.getBottom()-e,r[6]=t.getLeft()-s,r[7]=t.getBottom()-e,this._bbox.copy(t),0===s&&0===e||this._bbox.offset(-s,-e),this._isBboxChanged=!1}setFromQuad(t,s,e){tempQuad.copy(t),tempQuad.offset(s,e),this.setPoints(tempQuad.toArray()),this._isBboxChanged=!0}transform(t,s,e){let r=0,n=1;0!==e&&(r=Math.sin(e),n=Math.cos(e)),this.transformPrecalc(t,s,r,n)}transformPrecalc(e,r,n,o){const i=this._ptsArr;for(let t=0,s=i.length;t<s;t+=2){const h=t+1,l=i[t]*e,a=i[h]*r;i[t]=l*o-a*n,i[h]=a*o+l*n}this._isBboxChanged=!0}offset(e,r){const n=this._ptsArr;for(let t=0,s=n.length;t<s;t+=2)n[t]+=e,n[t+1]+=r}containsPoint(e,r){const n=this._ptsArr;if(e===n[0]&&r===n[1])return!0;this._updateBbox();const t=this._bbox,o=t.getLeft()-110,i=t.getTop()-101,h=t.getRight()+131,l=t.getBottom()+120;let a=0,c=0,g=0,_=0,p=0,f=0,u=0,C=0,A=(g=o<e?(a=o,e):(a=e,o),_=i<r?(c=i,r):(c=r,i),u=h<e?(p=h,e):(p=e,h),C=l<r?(f=l,r):(f=r,l),0),d=0;for(let t=0,s=n.length;t<s;t+=2){const b=(t+2)%s,P=n[t],m=n[t+1],x=n[b],B=n[1+b];C3.segmentsIntersectPreCalc(o,i,e,r,a,g,c,_,P,m,x,B)&&++A,C3.segmentsIntersectPreCalc(h,l,e,r,p,u,f,C,P,m,x,B)&&++d}return A%2==1||d%2==1}intersectsPoly(t,i,h){const l=t._ptsArr,a=this._ptsArr;if(this.containsPoint(l[0]+i,l[1]+h))return!0;if(t.containsPoint(a[0]-i,a[1]-h))return!0;for(let t=0,s=a.length;t<s;t+=2){const c=(t+2)%s,g=a[t],_=a[t+1],p=a[c],f=a[1+c];let e=0,r=0,n=0,o=0;n=g<p?(e=g,p):(e=p,g),o=_<f?(r=_,f):(r=f,_);for(let t=0,s=l.length;t<s;t+=2){const u=(t+2)%s,C=l[t]+i,A=l[t+1]+h,d=l[u]+i,b=l[1+u]+h;if(C3.segmentsIntersectPreCalc(g,_,p,f,e,n,r,o,C,A,d,b))return!0}}return!1}intersectsSegment(e,r,n,o,i,h){if(this.containsPoint(n-e,o-r))return!0;if(this.containsPoint(i-e,h-r))return!0;let l=0,a=0,c=0,g=0;c=n<i?(l=n,i):(l=i,n),g=o<h?(a=o,h):(a=h,o);const _=this._ptsArr;for(let t=0,s=_.length;t<s;t+=2){const p=(t+2)%s,f=_[t]+e,u=_[t+1]+r,C=_[p]+e,A=_[1+p]+r;if(C3.segmentsIntersectPreCalc(n,o,i,h,l,c,a,g,f,u,C,A))return!0}return!1}mirror(e){const r=this._ptsArr;for(let t=0,s=r.length;t<s;t+=2)r[t]=2*e-r[t];this._isBboxChanged=!0}flip(e){const r=this._ptsArr;for(let t=0,s=r.length;t<s;t+=2){const n=t+1;r[n]=2*e-r[n]}this._isBboxChanged=!0}diag(){const e=this._ptsArr;for(let t=0,s=e.length;t<s;t+=2){const r=t+1,n=e[t];e[t]=e[r],e[r]=n}this._isBboxChanged=!0}GetMidX(){const e=this._ptsArr;let r=0;for(let t=0,s=e.length;t<s;t+=2)r+=e[t];return r/this.pointCount()}GetMidY(){const e=this._ptsArr;let r=0;for(let t=0,s=e.length;t<s;t+=2)r+=e[t+1];return r/this.pointCount()}GetPointsArray(){return this._ptsArr}GetPointCount(){return this.pointCount()}IsEnabled(){return this._enabled}}; } // lib/misc/pairMap.js { const C3=self.C3;C3.PairMap=class extends C3.DefendedBase{constructor(e){if(super(),this._firstMap=new Map,e)for(const[t,s,r]of e)this.Set(t,s,r)}Release(){this.Clear(),this._firstMap=null}IsEmpty(){return 0===this._firstMap.size}Clear(){const e=this._firstMap;for(const t of e.values())t.clear();e.clear()}Set(e,t,s){const r=this._firstMap;let i=r.get(e);i||(i=new Map,r.set(e,i)),i.set(t,s)}Get(e,t){const s=this._firstMap.get(e);return s&&s.get(t)}Has(e,t){const s=this._firstMap.get(e);return!!s&&s.has(t)}Delete(e,t){const s=this._firstMap,r=s.get(e);if(!r)return!1;const i=r.delete(t);return i&&0===r.size&&s.delete(e),i}DeleteEither(e){const t=this._firstMap,s=t.get(e);s&&(s.clear(),t.delete(e));for(const[r,s]of t.entries())s.delete(e)&&0===s.size&&t.delete(r)}GetSize(){let e=0;for(const t of this._firstMap.values())e+=t.size;return e}*values(){for(const e of this._firstMap.values())yield*e.values()}*keyPairs(){for(const[e,t]of this._firstMap.entries())for(const s of t.keys())yield[e,s]}*entries(){for(const[e,t]of this._firstMap.entries())for(const[s,r]of t.entries())yield[e,s,r]}}; } // lib/misc/arraySet.js { const C3=self.C3;C3.ArraySet=class extends C3.DefendedBase{constructor(){super(),this._set=new Set,this._arr=[],this._needToRebuildArray=!1}Release(){this.Clear()}Clear(){this._set.clear(),C3.clearArray(this._arr),this._needToRebuildArray=!1}Add(e){this._set.has(e)||(this._set.add(e),this._needToRebuildArray)||this._arr.push(e)}Has(e){return this._set.has(e)}Delete(e){this._set.delete(e)&&(this._needToRebuildArray=!0)}GetSize(){return this._set.size}IsEmpty(){return 0===this._set.size}GetArray(){return this._needToRebuildArray&&(this._RebuildArray(),this._needToRebuildArray=!1),this._arr}_RebuildArray(){const e=this._arr;C3.clearArray(e);for(const r of this._set)e.push(r)}}; } // ../lib/misc/ease.js { const C3=self.C3,EASE_MAP=new Map,PREDEFINED_EASE_MAP=new Map,CUSTOM_EASE_EDITOR_MAP=new Map,CUSTOM_EASE_DATA_EDITOR_MAP=new Map,CUSTOM_EASE_RUNTIME_MAP=new Map,CUSTOM_EASE_DATA_RUNTIME_MAP=new Map,PRIVATE_EASE_MAP=new Map,BUILT_IN_TRANSITION_MAP=new Map,ALIAS_MAP=new Map,EASE_TRANSLATION_KEYS=(ALIAS_MAP.set("linear","noease"),ALIAS_MAP.set("default","noease"),["default","noease","easeinquad","easeoutquad","easeinoutquad","easeincubic","easeoutcubic","easeinoutcubic","easeinquart","easeoutquart","easeinoutquart","easeinquint","easeoutquint","easeinoutquint","easeinsine","easeoutsine","easeinoutsine","easeinexpo","easeoutexpo","easeinoutexpo","easeincirc","easeoutcirc","easeinoutcirc","easeinelastic","easeoutelastic","easeinoutelastic","easeinback","easeoutback","easeinoutback","easeinbounce","easeoutbounce","easeinoutbounce"]),SHORT_EASE_TRANSLATION_KEYS=["default","noease","quad","cubic","quart","quint","sine","expo","circ","elastic","back","bounce"],EASE_API2INTERNAL_NAMES=new Map([["linear","noease"],["in-sine","easeinsine"],["out-sine","easeoutsine"],["in-out-sine","easeinoutsine"],["in-elastic","easeinelastic"],["out-elastic","easeoutelastic"],["in-out-elastic","easeinoutelastic"],["in-back","easeinback"],["out-back","easeoutback"],["in-out-back","easeinoutback"],["in-bounce","easeinbounce"],["out-bounce","easeoutbounce"],["in-out-bounce","easeinoutbounce"],["in-cubic","easeincubic"],["out-cubic","easeoutcubic"],["in-out-cubic","easeinoutcubic"],["in-quadratic","easeinquad"],["out-quadratic","easeoutquad"],["in-out-quadratic","easeinoutquad"],["in-quartic","easeinquart"],["out-quartic","easeoutquart"],["in-out-quartic","easeinoutquart"],["in-quintic","easeinquint"],["out-quintic","easeoutquint"],["in-out-quintic","easeinoutquint"],["in-circular","easeincirc"],["out-circular","easeoutcirc"],["in-out-circular","easeinoutcirc"],["in-exponential","easeinexpo"],["out-exponential","easeoutexpo"],["in-out-exponential","easeinoutexpo"]]),SAMPLE_COUNT=(self.Ease=class d{constructor(){}static InheritEase(){return"default"}static DefaultEase(){return"noease"}static ToInternal(e){return EASE_API2INTERNAL_NAMES.get(e)}static GetEditorEaseNames(a,...s){this._CreateEaseMap();let e,t;const i=(t=a?(CUSTOM_EASE_EDITOR_MAP.has(a)||CUSTOM_EASE_EDITOR_MAP.set(a,new Map),[...(e=CUSTOM_EASE_EDITOR_MAP.get(a)).keys()].filter(e=>!d.GetEditorEaseData(e,a)||d.GetEditorEaseData(e,a).transition.IsForAnyPurpose())):[...(e=CUSTOM_EASE_RUNTIME_MAP).keys()]).sort();return[...PREDEFINED_EASE_MAP.keys()].concat(i).filter(e=>!s.includes(e))}static GetRuntimeEaseNames(){this._CreateEaseMap();const e=[...CUSTOM_EASE_RUNTIME_MAP.keys()];return e.sort(),[...PREDEFINED_EASE_MAP.keys()].concat(e)}static GetCustomRuntimeEaseNames(){this._CreateEaseMap();const e=[...CUSTOM_EASE_RUNTIME_MAP.keys()];return e.sort(),e}static IsPredefinedTranslatedName(e){for(const a of EASE_TRANSLATION_KEYS){const s=self.lang("ui.bars.timeline.eases."+a);if(s===e)return!0}for(const t of SHORT_EASE_TRANSLATION_KEYS){const i=self.lang("ui.bars.timeline.short-eases."+t);if(i===e)return!0}}static IsNamePredefined(e){return this._CreateEaseMap(),[...PREDEFINED_EASE_MAP.keys()].includes(e)}static _GetEase(e){const a=ALIAS_MAP.get(e);return a?EASE_MAP.get(a):d.IsNamePredefined(e)?EASE_MAP.get(e):PRIVATE_EASE_MAP.has(e)?PRIVATE_EASE_MAP.get(e):void 0}static GetBuiltInTransition(e){return this._CreateEaseMap(),BUILT_IN_TRANSITION_MAP.get(e)}static GetEditorEase(e,a){this._CreateEaseMap();const s=d._GetEase(e);if(s)return s;if(a)return CUSTOM_EASE_EDITOR_MAP.get(a).get(e);throw new Error("missing ease function")}static GetEditorEaseData(e,a){this._CreateEaseMap();const s=CUSTOM_EASE_DATA_EDITOR_MAP.get(a);if(s)return s.get(e)}static HasEditorEase(e,a){this._CreateEaseMap();const s=d._GetEase(e);return!!s||!!CUSTOM_EASE_EDITOR_MAP.get(a).get(e)}static GetRuntimeEase(e){this._CreateEaseMap();const a=d._GetEase(e);return a||CUSTOM_EASE_RUNTIME_MAP.get(e)}static GetRuntimeEaseData(e){return this._CreateEaseMap(),CUSTOM_EASE_DATA_RUNTIME_MAP.get(e)}static GetEaseFromIndex(e){this._CreateEaseMap();const a=this.GetRuntimeEaseNames();return a[e]}static GetIndexForEase(e,a){this._CreateEaseMap();const s=this.GetEditorEaseNames(a);return s.indexOf(e)}static GetIndexForEaseAtRuntime(e){return this.GetIndexForEase(e)}static _CreateEaseMap(){0===EASE_MAP.size&&(this._AddPredifinedEase("default",()=>{}),this._AddPredifinedEase("noease",[{"x":0,"y":0,"sax":.336,"say":0,"eax":0,"eay":0,"se":!0,"ee":!1},{"x":1,"y":1,"sax":0,"say":0,"eax":-.336,"eay":0,"se":!1,"ee":!0}],!0),this._AddPredifinedEase("easeinsine",[{"x":0,"y":0,"sax":.485,"say":0,"eax":0,"eay":0,"se":!0,"ee":!1},{"x":1,"y":1,"sax":0,"say":0,"eax":-.038,"eay":0,"se":!1,"ee":!0}]),this._AddPredifinedEase("easeoutsine",[{"x":0,"y":0,"sax":.038,"say":0,"eax":0,"eay":0,"se":!0,"ee":!1},{"x":1,"y":1,"sax":0,"say":0,"eax":-.485,"eay":0,"se":!1,"ee":!0}]),this._AddPredifinedEase("easeinoutsine",[{"x":0,"y":0,"sax":.336,"say":0,"eax":0,"eay":0,"se":!0,"ee":!1},{"x":1,"y":1,"sax":0,"say":0,"eax":-.336,"eay":0,"se":!1,"ee":!0}]),this._AddPredifinedEase("easeinelastic",[{"x":0,"y":0,"sax":.018,"say":0,"eax":0,"eay":0,"se":!0,"ee":!1},{"x":.116,"y":.002,"sax":.025,"say":0,"eax":-.025,"eay":0,"se":!0,"ee":!0},{"x":.266,"y":-.005,"sax":.024,"say":0,"eax":-.021,"eay":0,"se":!0,"ee":!0},{"x":.416,"y":.016,"sax":.024,"say":0,"eax":-.026,"eay":0,"se":!0,"ee":!0},{"x":.566,"y":-.045,"sax":.061,"say":0,"eax":-.025,"eay":0,"se":!0,"ee":!0},{"x":.716,"y":.132,"sax":.072,"say":-.004,"eax":-.045,"eay":0,"se":!0,"ee":!0},{"x":.866,"y":-.373,"sax":.06,"say":0,"eax":-.049,"eay":-.002,"se":!0,"ee":!0},{"x":1,"y":1,"sax":0,"say":0,"eax":-.038,"eay":-.263,"se":!1,"ee":!0}]),this._AddPredifinedEase("easeoutelastic",[{"x":0,"y":0,"sax":.038,"say":.263,"eax":0,"eay":0,"se":!0,"ee":!1},{"x":.136,"y":1.373,"sax":.049,"say":.002,"eax":-.06,"eay":0,"se":!0,"ee":!0},{"x":.286,"y":.868,"sax":.045,"say":0,"eax":-.072,"eay":.004,"se":!0,"ee":!0},{"x":.436,"y":1.045,"sax":.025,"say":0,"eax":-.061,"eay":0,"se":!0,"ee":!0},{"x":.586,"y":.984,"sax":.026,"say":0,"eax":-.024,"eay":0,"se":!0,"ee":!0},{"x":.736,"y":1.005,"sax":.021,"say":0,"eax":-.024,"eay":0,"se":!0,"ee":!0},{"x":.886,"y":.998,"sax":.025,"say":0,"eax":-.025,"eay":0,"se":!0,"ee":!0},{"x":1,"y":1,"sax":0,"say":0,"eax":-.018,"eay":0,"se":!1,"ee":!0}]),this._AddPredifinedEase("easeinoutelastic",[{"x":0,"y":0,"sax":.025,"say":0,"eax":0,"eay":0,"se":!0,"ee":!1},{"x":.067,"y":.001,"sax":.025,"say":0,"eax":-.025,"eay":0,"se":!0,"ee":!0},{"x":.18,"y":-.005,"sax":.025,"say":0,"eax":-.025,"eay":0,"se":!0,"ee":!0},{"x":.292,"y":.025,"sax":.053,"say":0,"eax":-.025,"eay":0,"se":!0,"ee":!0},{"x":.405,"y":-.118,"sax":.069,"say":0,"eax":-.027,"eay":0,"se":!0,"ee":!0},{"x":.597,"y":1.118,"sax":.027,"say":0,"eax":-.069,"eay":0,"se":!0,"ee":!0},{"x":.71,"y":.975,"sax":.025,"say":0,"eax":-.053,"eay":0,"se":!0,"ee":!0},{"x":.822,"y":1.005,"sax":.025,"say":0,"eax":-.025,"eay":0,"se":!0,"ee":!0},{"x":.935,"y":.999,"sax":.025,"say":0,"eax":-.025,"eay":0,"se":!0,"ee":!0},{"x":1,"y":1,"sax":0,"say":0,"eax":-.025,"eay":0,"se":!1,"ee":!0}]),this._AddPredifinedEase("easeinback",[{"x":0,"y":0,"sax":.35,"say":0,"eax":0,"eay":0,"se":!0,"ee":!1},{"x":1,"y":1,"sax":0,"say":0,"eax":-.34,"eay":-1.579,"se":!1,"ee":!0}]),this._AddPredifinedEase("easeoutback",[{"x":0,"y":0,"sax":.34,"say":1.579,"eax":0,"eay":0,"se":!0,"ee":!1},{"x":1,"y":1,"sax":0,"say":0,"eax":-.35,"eay":0,"se":!1,"ee":!0}]),this._AddPredifinedEase("easeinoutback",[{"x":0,"y":0,"sax":.035,"say":0,"eax":0,"eay":0,"se":!0,"ee":!1},{"x":.242,"y":-.1,"sax":.258,"say":0,"eax":-.025,"eay":0,"se":!0,"ee":!0},{"x":.76,"y":1.1,"sax":.025,"say":0,"eax":-.26,"eay":0,"se":!0,"ee":!0},{"x":1,"y":1,"sax":0,"say":0,"eax":-.035,"eay":0,"se":!1,"ee":!0}]),this._AddPredifinedEase("easeinbounce",[{"x":0,"y":0,"sax":.033,"say":.025,"eax":0,"eay":0,"se":!0,"ee":!1},{"x":.092,"y":0,"sax":.026,"say":.078,"eax":-.033,"eay":.025,"se":!0,"ee":!0},{"x":.274,"y":0,"sax":.097,"say":.319,"eax":-.026,"eay":.078,"se":!0,"ee":!0},{"x":.637,"y":0,"sax":.105,"say":.625,"eax":-.097,"eay":.319,"se":!0,"ee":!0},{"x":1,"y":1,"sax":0,"say":0,"eax":-.125,"eay":-.004,"se":!1,"ee":!0}]),this._AddPredifinedEase("easeoutbounce",[{"x":0,"y":0,"sax":.125,"say":.004,"eax":0,"eay":0,"se":!0,"ee":!1},{"x":.365,"y":1,"sax":.097,"say":-.319,"eax":-.105,"eay":-.625,"se":!0,"ee":!0},{"x":.728,"y":1,"sax":.026,"say":-.078,"eax":-.097,"eay":-.319,"se":!0,"ee":!0},{"x":.91,"y":1,"sax":.033,"say":-.025,"eax":-.026,"eay":-.078,"se":!0,"ee":!0},{"x":1,"y":1,"sax":0,"say":0,"eax":-.033,"eay":-.025,"se":!1,"ee":!0}]),this._AddPredifinedEase("easeinoutbounce",[{"x":0,"y":0,"sax":.01,"say":.006,"eax":0,"eay":0,"se":!0,"ee":!1},{"x":.046,"y":0,"sax":.021,"say":.038,"eax":-.01,"eay":.006,"se":!0,"ee":!0},{"x":.137,"y":0,"sax":.059,"say":.158,"eax":-.021,"eay":.038,"se":!0,"ee":!0},{"x":.319,"y":0,"sax":.117,"say":.744,"eax":-.059,"eay":.158,"se":!0,"ee":!0},{"x":.683,"y":1,"sax":.059,"say":-.158,"eax":-.117,"eay":-.744,"se":!0,"ee":!0},{"x":.865,"y":1,"sax":.021,"say":-.038,"eax":-.059,"eay":-.158,"se":!0,"ee":!0},{"x":.956,"y":1,"sax":.01,"say":-.006,"eax":-.021,"eay":-.038,"se":!0,"ee":!0},{"x":1,"y":1,"sax":0,"say":0,"eax":-.01,"eay":-.006,"se":!1,"ee":!0}]),this._AddPredifinedEase("easeincubic",[{"x":0,"y":0,"sax":.75,"say":0,"eax":0,"eay":0,"se":!0,"ee":!1},{"x":1,"y":1,"sax":0,"say":0,"eax":-.138,"eay":-.321,"se":!1,"ee":!0}]),this._AddPredifinedEase("easeoutcubic",[{"x":0,"y":0,"sax":.138,"say":.321,"eax":0,"eay":0,"se":!0,"ee":!1},{"x":1,"y":1,"sax":0,"say":0,"eax":-.75,"eay":0,"se":!1,"ee":!0}]),this._AddPredifinedEase("easeinoutcubic",[{"x":0,"y":0,"sax":.285,"say":0,"eax":0,"eay":0,"se":!0,"ee":!1},{"x":.5,"y":.5,"sax":.081,"say":.272,"eax":-.081,"eay":-.272,"se":!0,"ee":!0},{"x":1,"y":1,"sax":0,"say":0,"eax":-.285,"eay":0,"se":!1,"ee":!0}]),this._AddPredifinedEase("easeinquad",[{"x":0,"y":0,"sax":.4,"say":0,"eax":0,"eay":0,"se":!0,"ee":!1},{"x":1,"y":1,"sax":0,"say":0,"eax":-.178,"eay":-.392,"se":!1,"ee":!0}]),this._AddPredifinedEase("easeoutquad",[{"x":0,"y":0,"sax":.178,"say":.392,"eax":0,"eay":0,"se":!0,"ee":!1},{"x":1,"y":1,"sax":0,"say":0,"eax":-.4,"eay":0,"se":!1,"ee":!0}]),this._AddPredifinedEase("easeinoutquad",[{"x":0,"y":0,"sax":.25,"say":0,"eax":0,"eay":0,"se":!0,"ee":!1},{"x":.5,"y":.5,"sax":.03,"say":.065,"eax":-.03,"eay":-.065,"se":!0,"ee":!0},{"x":1,"y":1,"sax":0,"say":0,"eax":-.25,"eay":0,"se":!1,"ee":!0}]),this._AddPredifinedEase("easeinquart",[{"x":0,"y":0,"sax":.25,"say":1,"eax":0,"eay":0,"se":!0,"ee":!1},{"x":1,"y":1,"sax":0,"say":0,"eax":-.5,"eay":0,"se":!1,"ee":!0}]),this._AddPredifinedEase("easeoutquart",[{"x":0,"y":0,"sax":.5,"say":0,"eax":0,"eay":0,"se":!0,"ee":!1},{"x":1,"y":1,"sax":0,"say":0,"eax":-.25,"eay":-1,"se":!1,"ee":!0}]),this._AddPredifinedEase("easeinoutquart",[{"x":0,"y":0,"sax":.765,"say":.03,"eax":0,"eay":0,"se":!0,"ee":!1},{"x":1,"y":1,"sax":0,"say":0,"eax":-.765,"eay":-.03,"se":!1,"ee":!0}]),this._AddPredifinedEase("easeinquint",[{"x":0,"y":0,"sax":.6,"say":0,"eax":0,"eay":0,"se":!0,"ee":!1},{"x":1,"y":1,"sax":0,"say":0,"eax":-.2,"eay":-1,"se":!1,"ee":!0}]),this._AddPredifinedEase("easeoutquint",[{"x":0,"y":0,"sax":.2,"say":1,"eax":0,"eay":0,"se":!0,"ee":!1},{"x":1,"y":1,"sax":0,"say":0,"eax":-.6,"eay":0,"se":!1,"ee":!0}]),this._AddPredifinedEase("easeinoutquint",[{"eax":0,"eay":0,"ee":!1,"sax":.84,"say":0,"se":!0,"x":0,"y":0},{"eax":-.84,"eay":0,"ee":!0,"sax":0,"say":0,"se":!1,"x":1,"y":1}]),this._AddPredifinedEase("easeincirc",[{"x":0,"y":0,"sax":.25,"say":0,"eax":0,"eay":0,"se":!0,"ee":!1},{"x":1,"y":1,"sax":0,"say":0,"eax":-.024,"eay":-.808,"se":!1,"ee":!0}]),this._AddPredifinedEase("easeoutcirc",[{"x":0,"y":0,"sax":.024,"say":.808,"eax":0,"eay":0,"se":!0,"ee":!1},{"x":1,"y":1,"sax":0,"say":0,"eax":-.25,"eay":0,"se":!1,"ee":!0}]),this._AddPredifinedEase("easeinoutcirc",[{"x":0,"y":0,"sax":.125,"say":0,"eax":0,"eay":0,"se":!0,"ee":!1},{"x":.5,"y":.5,"sax":.02,"say":.428,"eax":-.02,"eay":-.428,"se":!0,"ee":!0},{"x":1,"y":1,"sax":0,"say":0,"eax":-.125,"eay":0,"se":!1,"ee":!0}]),this._AddPredifinedEase("easeinexpo",[{"x":0,"y":0,"sax":.66,"say":0,"eax":0,"eay":0,"se":!0,"ee":!1},{"x":1,"y":1,"sax":0,"say":0,"eax":-.14,"eay":-1,"se":!1,"ee":!0}]),this._AddPredifinedEase("easeoutexpo",[{"x":0,"y":0,"sax":.14,"say":1,"eax":0,"eay":0,"se":!0,"ee":!1},{"x":1,"y":1,"sax":0,"say":0,"eax":-.66,"eay":0,"se":!1,"ee":!0}]),this._AddPredifinedEase("easeinoutexpo",[{"eax":0,"eay":0,"ee":!1,"sax":.345,"say":0,"se":!0,"x":0,"y":0},{"eax":-.06,"eay":-.5,"ee":!0,"sax":.06,"say":.5,"se":!0,"x":.5,"y":.5},{"eax":-.335,"eay":0,"ee":!0,"sax":0,"say":0,"se":!1,"x":1,"y":1}]),this._AddPrivateCustomEase("cubicbezier",this.EaseCubicBezier),this._AddPrivateCustomEase("spline",this.EaseSpline))}static _AddPredifinedEase(e,a,s=!1){if("function"==typeof a)d._AddEase(e,a,"predefined");else{if(!C3.IsArray(a))throw new Error("unexpected arguments");if(self.BuiltInTransition){const i=C3.New(self.BuiltInTransition,e,s);i.SetFromJson(a),d._AddEase(e,(e,a,s,t)=>i.Interpolate(e,a,s,t),"predefined"),BUILT_IN_TRANSITION_MAP.set(e,i)}else{const x=C3.New(C3.Transition,[e,a.map(e=>[e["x"],e["y"],e["sax"],e["say"],e["eax"],e["eay"],e["se"],e["ee"]])],!1);x.MakeLinear(s),d._AddEase(e,(e,a,s,t)=>x.Interpolate(e,a,s,t),"predefined")}}}static _AddPrivateCustomEase(e,a){d._AddEase(e,a,"private")}static AddCustomEase(e,a,s,t){this._CreateEaseMap(),d._AddEase(e,a,"custom",s,t)}static RemoveCustomEase(e,a){if(!this.IsNamePredefined(e)&&![...PRIVATE_EASE_MAP.keys()].includes(e)){const s=CUSTOM_EASE_EDITOR_MAP.get(a),t=(s&&s.delete(e),CUSTOM_EASE_DATA_EDITOR_MAP.get(a));t&&t.delete(e)}}static _AddEase(e,a,s,t,i){switch(s){case"predefined":EASE_MAP.set(e,a),PREDEFINED_EASE_MAP.set(e,a);break;case"custom":if(t){CUSTOM_EASE_EDITOR_MAP.has(t)||CUSTOM_EASE_EDITOR_MAP.set(t,new Map),CUSTOM_EASE_DATA_EDITOR_MAP.has(t)||CUSTOM_EASE_DATA_EDITOR_MAP.set(t,new Map);const x=CUSTOM_EASE_EDITOR_MAP.get(t),y=(x.set(e,a),CUSTOM_EASE_DATA_EDITOR_MAP.get(t));y.set(e,i)}else CUSTOM_EASE_RUNTIME_MAP.set(e,a),CUSTOM_EASE_DATA_RUNTIME_MAP.set(e,i);break;case"private":EASE_MAP.set(e,a),PRIVATE_EASE_MAP.set(e,a);break;default:throw new Error("unexpected ease mode")}}static NoEase(e,a,s,t){return 0===t?a:s*e/t+a}static EaseCubicBezier(e,a,s,t,i){const x=a,y=3*e*(s-a),n=3*e**2*(a+t-2*s),E=e**3*(i-a+3*s-3*t);return x+y+n+E}static EaseSpline(e,s,t,i,x,y,n,E,_,r){if(i===x&&y===n)return e;const u=get_t_for_x(e,s,i,y,E,r),d=a(t,x,n,_),A=b(t,x,n,_),o=c(t,x,n,_);return calc_bezier(u,d,A,o)}static GetBezierSamples(e,s,t,i){const x=[],y=a(e,s,t,i),n=b(e,s,t,i),E=c(e,s,t,i);for(let e=0;e<SAMPLE_COUNT;++e){const _=calc_bezier(e*SAMPLE_STEP,y,n,E);x.push(_)}return x}},11),SAMPLE_STEP=1/(SAMPLE_COUNT-1),NEWTON_RAPHSON_ITERATIONS=4,NEWTON_RAPHSON_MIN_SLOPE=.01,SUBDIVISION_PRECISION=1e-7,SUBDIVISION_MAX_ITERATIONS=10,a=(e,a,s,t)=>t-3*s+3*a-e,b=(e,a,s,t)=>3*s-6*a+3*e,c=(e,a,s,t)=>3*(a-e),calc_bezier=(e,a,s,t)=>((a*e+s)*e+t)*e,get_slope=(e,a,s,t)=>3*a*e*e+2*s*e+t,get_t_for_x=(y,e,s,t,i,x)=>{if(1==y)return 1;let n=0,E=1,_=x[E],r=SAMPLE_COUNT-1;SAMPLE_COUNT;for(;E!=r&&_<=y;)E++,_=x[E],n+=SAMPLE_STEP;E--;const u=(y-(_=x[E]))/(x[E+1]-_);let d=n+u*SAMPLE_STEP;const A=a(e,s,t,i),o=b(e,s,t,i),S=c(e,s,t,i),M=get_slope(d,A,o,S);if(0===M)return d;if(M>=NEWTON_RAPHSON_MIN_SLOPE){for(let e=0;e<NEWTON_RAPHSON_ITERATIONS;++e){const P=calc_bezier(d,A,o,S)-y,T=get_slope(d,A,o,S);d-=P/T}return d}{let a=n,s=n+SAMPLE_STEP,t=0,i,x;do{d=a+(s-a)/2;let e=calc_bezier(d,A,o,S)-y;0<e?s=d:a=d,i=Math.abs(e)>SUBDIVISION_PRECISION,x=++t<SUBDIVISION_MAX_ITERATIONS}while(i&&x);return d}}; } // ../lib/misc/probability.js { const C3=self.C3;function RequireStringOrNumber(t){C3.IsString(t)}C3.ProbabilityTable=class{constructor(t){this._items=[],this._name=t||"",this._totalWeight=0}Release(){this.Clear(),this._items=null}GetName(){return this._name}Clear(){C3.clear2DArray(this._items),this._totalWeight=0}GetTotalWeight(){return this._totalWeight}Sample(t=Math.random()*this.GetTotalWeight()){let e=0;for(const[i,s]of this._items)if(t<(e+=i))return s;return 0}AddItem(t,e){RequireStringOrNumber(e),this._totalWeight+=t,this._items.push([t,e])}RemoveItem(e,i){RequireStringOrNumber(i);const s=0===e;for(let t=0;t<this._items.length;t++){const r=this._items[t],h=s||r[0]===e,a=r[1]===i;if(h&&a){this._items.splice(t,1),this._totalWeight-=r[0];break}}}asJSON(){return JSON.stringify(this._items)}static fromJSON(t,e){const i=new C3.ProbabilityTable(e),s=JSON.parse(t);for(const r of s){const h=r[0],a=r[1];i.AddItem(h,a)}return i}}; } // lib/misc/screenReaderText.js { const C3=self.C3;let nextId=0;C3.ScreenReaderText=class{constructor(t,e){this._runtime=t,this._text=e,this._id=nextId++,this._runtime.PostComponentMessageToDOM("runtime","screen-reader-text",{"type":"create","id":this._id,"text":this._text})}Release(){this._runtime.PostComponentMessageToDOM("runtime","screen-reader-text",{"type":"release","id":this._id}),this._runtime=null,this._text="",this._id=-1}SetText(t){this._text!==t&&(this._text=t,this._runtime.PostComponentMessageToDOM("runtime","screen-reader-text",{"type":"update","id":this._id,"text":this._text}))}}; } // ../lib/events/event.js { const C3=self.C3;C3.Event=class{constructor(t,e){this.type=t,this.cancelable=!!e,this.defaultPrevented=!1,this.propagationStopped=!1,this.isAsync=!1}preventDefault(){if(!this.cancelable)throw new Error(`event '${this.type}' is not cancelable`);this.defaultPrevented=!0}stopPropagation(){if(!this.cancelable)throw new Error(`event '${this.type}' cannot be stopped`);if(this.isAsync)throw new Error(`cannot stop async event '${this.type}' propagation`);this.propagationStopped=!0}}; } // ../lib/events/handler.js { const C3=self.C3,assert=self.assert;C3.Event.Handler=class extends C3.DefendedBase{constructor(e){super(),this._type=e,this._captureListeners=[],this._captureListenersSet=new Set,this._listeners=[],this._listenersSet=new Set,this._fireDepth=0,this._queueModifyListeners=[]}Release(){0<this._fireDepth||(C3.clearArray(this._captureListeners),this._captureListenersSet.clear(),C3.clearArray(this._listeners),this._listenersSet.clear(),C3.clearArray(this._queueModifyListeners),C3.Release(this))}_AddListener(e,t){this._IsFiring()?this._queueModifyListeners.push({op:"add",func:e,capture:t}):t?this._captureListenersSet.has(e)||(this._captureListeners.push(e),this._captureListenersSet.add(e)):this._listenersSet.has(e)||(this._listeners.push(e),this._listenersSet.add(e))}_RemoveListener(e,t){this._IsFiring()?this._queueModifyListeners.push({op:"remove",func:e,capture:t}):t?this._captureListenersSet.has(e)&&(this._captureListenersSet.delete(e),C3.arrayFindRemove(this._captureListeners,e)):this._listenersSet.has(e)&&(this._listenersSet.delete(e),C3.arrayFindRemove(this._listeners,e))}_IsEmpty(){return!this._captureListeners.length&&!this._listeners.length}_IsFiring(){return 0<this._fireDepth}_ProcessQueuedListeners(){const e=new Set,t=new Set;for(const s of this._queueModifyListeners)if("add"===s.op)this._AddListener(s.func,s.capture),(s.capture?t:e).delete(s.func);else{if("remove"!==s.op)throw new Error("invalid op");(s.capture?(this._captureListenersSet.delete(s.func),t):(this._listenersSet.delete(s.func),e)).add(s.func)}C3.arrayRemoveAllInSet(this._listeners,e),C3.arrayRemoveAllInSet(this._captureListeners,t),C3.clearArray(this._queueModifyListeners)}_FireCancellable(s){this._IncreaseFireDepth();let r=!1;for(let e=0,t=this._captureListeners.length;e<t;++e)if(this._captureListeners[e](s),s.propagationStopped){r=!0;break}if(!r)for(let e=0,t=this._listeners.length;e<t&&(this._listeners[e](s),!s.propagationStopped);++e);return this._DecreaseFireDepth(),!s.defaultPrevented}_FireNonCancellable(s){this._IncreaseFireDepth();for(let e=0,t=this._captureListeners.length;e<t;++e)this._captureListeners[e](s);for(let e=0,t=this._listeners.length;e<t;++e)this._listeners[e](s);return this._DecreaseFireDepth(),!0}_IncreaseFireDepth(){this._fireDepth++}_DecreaseFireDepth(){this._fireDepth--,0===this._fireDepth&&0<this._queueModifyListeners.length&&this._ProcessQueuedListeners()}SetDelayRemoveEventsEnabled(e){e?this._IncreaseFireDepth():this._DecreaseFireDepth()}_FireAsync(s){let r=[];for(let t=0,e=this._captureListeners.length;t<e;++t){let e=this._captureListeners[t];r.push(C3.Asyncify(()=>e(s)))}for(let t=0,e=this._listeners.length;t<e;++t){let e=this._listeners[t];r.push(C3.Asyncify(()=>e(s)))}return Promise.all(r).then(()=>!s.defaultPrevented)}_FireAndWait_AsyncOptional(s){const r=[];this._IncreaseFireDepth();for(let e=0,t=this._captureListeners.length;e<t;++e){const i=this._captureListeners[e](s);i instanceof Promise&&r.push(i)}for(let e=0,t=this._listeners.length;e<t;++e){const n=this._listeners[e](s);n instanceof Promise&&r.push(n)}return this._DecreaseFireDepth(),r.length?Promise.all(r).then(()=>!s.defaultPrevented):!s.defaultPrevented}async _FireAndWaitAsync(e){return this._FireAndWait_AsyncOptional(e)}async _FireAndWaitAsyncSequential(s){this._IncreaseFireDepth();for(let e=0,t=this._captureListeners.length;e<t;++e){const r=this._captureListeners[e](s);r instanceof Promise&&await r}for(let e=0,t=this._listeners.length;e<t;++e){const i=this._listeners[e](s);i instanceof Promise&&await i}return this._DecreaseFireDepth(),!s.defaultPrevented}*_FireAsGenerator(s){this._IncreaseFireDepth();for(let e=0,t=this._captureListeners.length;e<t;++e){const r=this._captureListeners[e](s);C3.IsIterator(r)&&(yield*r)}for(let e=0,t=this._listeners.length;e<t;++e){const i=this._listeners[e](s);C3.IsIterator(i)&&(yield*i)}this._DecreaseFireDepth()}}; } // ../lib/events/dispatcher.js { const C3=self.C3;C3.Event.Dispatcher=class extends C3.DefendedBase{constructor(){super(),this._eventHandlers=new Map,this._dispatcherWasReleased=!1}Release(){if(this._dispatcherWasReleased)throw new Error("already released");this.ClearEvents(),this._dispatcherWasReleased=!0,C3.Release(this)}WasReleased(){return this._dispatcherWasReleased}ClearEvents(){if(this._eventHandlers){for(let e of this._eventHandlers.values())e.Release();this._eventHandlers.clear()}}_GetHandlerByType(e,t){let n=this._eventHandlers.get(e);return n||(t?(n=C3.New(C3.Event.Handler,e),this._eventHandlers.set(e,n),n):null)}HasAnyHandlerFor(e){return this._eventHandlers.has(e)}addEventListener(e,t,n){let s=this._GetHandlerByType(e,!0);s._AddListener(t,!!n)}removeEventListener(e,t,n){let s=this._GetHandlerByType(e,!1);s&&(s._RemoveListener(t,!!n),s._IsEmpty())&&this._eventHandlers.delete(e)}dispatchEvent(e){const t=this._GetHandlerByType(e.type,!1);return!t||(e.cancelable?t._FireCancellable(e):t._FireNonCancellable(e))}dispatchEventAsync(e){const t=this._GetHandlerByType(e.type,!1);return t?(e.isAsync=!0,t._FireAsync(e)):Promise.resolve(!0)}async dispatchEventAndClearAsync(e){const t=this._GetHandlerByType(e.type,!1);if(!t)return!0;this._eventHandlers.delete(e.type),e.isAsync=!0;const n=await t._FireAsync(e);return t.Release(),n}async dispatchEventAndWaitAsync(e){const t=this._GetHandlerByType(e.type,!1);return!t||t._FireAndWaitAsync(e)}dispatchEventAndWait_AsyncOptional(e){const t=this._GetHandlerByType(e.type,!1);return!t||t._FireAndWait_AsyncOptional(e)}async dispatchEventAndWaitAsyncSequential(e){const t=this._GetHandlerByType(e.type,!1);return!t||t._FireAndWaitAsyncSequential(e)}dispatchGeneratorEvent(e){const t=this._GetHandlerByType(e.type,!1);if(!t)return null;if(e.cancelable)throw new Error("not supported");return t._FireAsGenerator(e)}SetDelayRemoveEventsEnabled(e){for(const t of this._eventHandlers.values())t.SetDelayRemoveEventsEnabled(e)}}; } // ../lib/util/asyncify.js { const C3=self.C3,SETTIMEOUT_WORK_DURATION=12,SETTIMEOUT_INTERVAL=16,IDLECALLBACK_TIMEOUT=35,SUPPORTS_RIC="undefined"!=typeof requestIdleCallback;let workQueue=[],callbackId=-1,highThroughputMode=0;function SetNewCallback(e){callbackId=SUPPORTS_RIC&&0===highThroughputMode?requestIdleCallback(DoAsyncifiedWork,{timeout:IDLECALLBACK_TIMEOUT}):setTimeout(DoAsyncifiedWork,0<highThroughputMode?1:e)}function DoAsyncifiedWork(n){if(callbackId=-1,workQueue.length){let i=performance.now(),t=i,e=0,o;for(;DoNextAsyncifiedJob(workQueue.shift()),t=performance.now(),++e,o=(t-i)/e*1.1,workQueue.length&&(SUPPORTS_RIC&&0===highThroughputMode&&void 0!==n?o<n["timeRemaining"]():t-i+o<SETTIMEOUT_WORK_DURATION););if(-1===callbackId&&workQueue.length){let e=t-i,o=Math.max(SETTIMEOUT_INTERVAL-e,4);SetNewCallback(o)}}}function DoNextAsyncifiedJob(o){let e;try{e=o.func()}catch(e){return void o.reject(e)}o.resolve(e)}let asyncifyDisabled=C3.QueryString.Has("disable-asyncify");asyncifyDisabled&&console.warn("[Asyncify] Asyncify has been disabled due to disable-asyncify in the query string. Some work will now be done synchronously."),C3.Asyncify=function(i){let t=null;return C3.isDebug&&(t=C3.GetCallStack()),new Promise((e,o)=>{workQueue.push({func:i,resolve:e,reject:o,stack:t}),asyncifyDisabled?DoNextAsyncifiedJob(workQueue.pop()):-1===callbackId&&SetNewCallback(SETTIMEOUT_INTERVAL)})},C3.Asyncify.SetHighThroughputMode=function(e){if(e)++highThroughputMode;else if(--highThroughputMode<0)throw new Error("already turned off high throughput mode")}; } // ../lib/util/idleTimeout.js { const C3=self.C3,IDLE_CHECK_MIN_INTERVAL=1e3,IDLE_CHECK_TIMER_OVERSHOOT=100;let cachedNowTime=-1;function ClearTimeCache(){cachedNowTime=-1}C3.FastGetDateNow=function(){return-1===cachedNowTime&&(cachedNowTime=Date.now(),self.setTimeout(ClearTimeCache,16)),cachedNowTime};let timerId=-1,nextDeadline=-1,activeIdleTimeouts=new Set;function CheckActiveIdleTimeouts(){timerId=-1,nextDeadline=-1;let i=Date.now();for(let t of activeIdleTimeouts)if(t._CheckTimeout(i)){let e=t._GetDeadline();(-1===nextDeadline||e<nextDeadline)&&(nextDeadline=e)}else activeIdleTimeouts.delete(t);if(-1!==nextDeadline){let e=Math.max(nextDeadline-i+IDLE_CHECK_TIMER_OVERSHOOT,IDLE_CHECK_MIN_INTERVAL);timerId=self.setTimeout(CheckActiveIdleTimeouts,e)}}C3.IdleTimeout=class{constructor(e,t){this._callback=e,this._timeout=1e3*t,this._deadline=0,this._isActive=!1}Reset(){let e=C3.FastGetDateNow();this._deadline=e+this._timeout,this._isActive||(activeIdleTimeouts.add(this),this._isActive=!0),-1===timerId?(nextDeadline=this._deadline,timerId=self.setTimeout(CheckActiveIdleTimeouts,this._timeout+IDLE_CHECK_TIMER_OVERSHOOT)):this._deadline<nextDeadline&&nextDeadline>e+IDLE_CHECK_MIN_INTERVAL&&(self.clearTimeout(timerId),nextDeadline=this._deadline,timerId=self.setTimeout(CheckActiveIdleTimeouts,this._timeout+IDLE_CHECK_TIMER_OVERSHOOT))}_CheckTimeout(e){return!(e>=this._deadline)||(this._callback()?(this._deadline=e+this._timeout,!0):this._isActive=!1)}_GetDeadline(){return this._deadline}Cancel(){this._isActive&&(activeIdleTimeouts.delete(this),this._isActive=!1,0===activeIdleTimeouts.size)&&-1!==timerId&&(self.clearTimeout(timerId),timerId=-1,nextDeadline=-1)}Release(){this.Cancel(),this._callback=null}}; } // ../lib/util/disposable.js { const C3=self.C3;C3.Disposable=class a{constructor(s){this._disposed=!1,this._disposeAction=s}Dispose(){this._disposed||(this._disposed=!0,this._disposeAction&&(this._disposeAction(),this._disposeAction=null))}IsDisposed(){return this._disposed}Release(){this.Dispose()}static Release(s){return new a(()=>s.Release())}static From(e,i,o,t,s){if(null==t)t=!1;else if("boolean"!=typeof t&&"object"!=typeof t)throw new TypeError("invalid event listener options");if(s&&(o=o.bind(s)),i.includes(" ")){i=i.split(" ");const d=new C3.CompositeDisposable;for(let s of i)e.addEventListener(s,o,t),d.Add(C3.New(C3.Disposable,()=>e.removeEventListener(s,o,t)));return d}return e.addEventListener(i,o,t),C3.New(C3.Disposable,()=>e.removeEventListener(i,o,t))}},C3.StubDisposable=class extends C3.Disposable{SetAction(s){this._disposeAction=s}},C3.CompositeDisposable=class extends C3.Disposable{constructor(...e){super(),this._disposables=new Set;for(let s of e)this.Add(s)}Add(...e){if(this._disposed)throw new Error("already disposed");for(let s of e)this._disposables.add(s)}Remove(s){if(this._disposed)throw new Error("already disposed");this._disposables.delete(s)}RemoveAll(){if(this._disposed)throw new Error("already disposed");if(this._disposables){for(let s of this._disposables)s.Dispose();this._disposables.clear()}}IsDisposed(){return this._disposed}Dispose(){if(this._disposed)throw new Error("already disposed");this._disposed=!0;for(let s of this._disposables)s.Dispose();this._disposables.clear(),this._disposables=null}Release(){this.Dispose()}}; } // lib/util/kahanSum.js { const C3=self.C3;C3.KahanSum=class extends C3.DefendedBase{constructor(){super(),this._c=0,this._y=0,this._t=0,this._sum=0}Add(s){this._y=(s=+s)-this._c,this._t=this._sum+this._y,this._c=this._t-this._sum-this._y,this._sum=this._t}Subtract(s){this._sum-=+s}Get(){return this._sum}Reset(){this._c=0,this._y=0,this._t=0,this._sum=0}Set(s){this._c=0,this._y=0,this._t=0,this._sum=+s}Copy(s){this._c=s._c,this._y=s._y,this._t=s._t,this._sum=s._sum}Release(){}}; } // lib/util/redblackset.js { const C3=self.C3,js_cols={},RED=!0,BLACK=!1;js_cols.RBnode=function(t){this.tree=t,this.right=this.tree.sentinel,this.left=this.tree.sentinel,this.parent=null,this.color=!1,this.key=null},js_cols.RedBlackSet=function(t){this.size=0,this.sentinel=new js_cols.RBnode(this),this.sentinel.color=BLACK,this.root=this.sentinel,this.root.parent=this.sentinel,this.compare=t||this.default_compare},js_cols.RedBlackSet.prototype.default_compare=function(t,e){return t<e?-1:e<t?1:0},js_cols.RedBlackSet.prototype.clone=function(){var t=new js_cols.RedBlackSet(this.compare);return t.insertAll(this),t},js_cols.RedBlackSet.prototype.clear=function(){this.size=0,this.sentinel=new js_cols.RBnode(this),this.sentinel.color=BLACK,this.root=this.sentinel,this.root.parent=this.sentinel},js_cols.RedBlackSet.prototype.leftRotate=function(t){var e=t.right;t.right=e.left,e.left!=this.sentinel&&(e.left.parent=t),e.parent=t.parent,t.parent==this.sentinel?this.root=e:t==t.parent.left?t.parent.left=e:t.parent.right=e,(e.left=t).parent=e},js_cols.RedBlackSet.prototype.rightRotate=function(t){var e=t.left;t.left=e.right,e.right!=this.sentinel&&(e.right.parent=t),e.parent=t.parent,t.parent==this.sentinel?this.root=e:t==t.parent.right?t.parent.right=e:t.parent.left=e,(e.right=t).parent=e},js_cols.RedBlackSet.prototype.insert=function(t){if(this.contains(t))this.get_(t).key=t;else{for(var e=new js_cols.RBnode(this),s=(e.key=t,this.sentinel),r=this.root;r!=this.sentinel;)s=r,r=this.compare(e.key,r.key)<0?r.left:r.right;(e.parent=s)==this.sentinel?this.root=e:this.compare(e.key,s.key)<0?s.left=e:s.right=e,e.left=this.sentinel,e.right=this.sentinel,e.color=RED,this.insertFixup(e),this.size++}},js_cols.RedBlackSet.prototype.insertFixup=function(t){for(;t!=this.sentinel&&t!=this.root&&t.parent.color==RED;){var e;t.parent==t.parent.parent.left?(e=t.parent.parent.right).color==RED?(t.parent.color=BLACK,e.color=BLACK,t.parent.parent.color=RED,t=t.parent.parent):(t==t.parent.right&&(t=t.parent,this.leftRotate(t)),t.parent.color=BLACK,t.parent.parent.color=RED,t.parent.parent!=this.sentinel&&this.rightRotate(t.parent.parent)):(e=t.parent.parent.left).color==RED?(t.parent.color=BLACK,e.color=BLACK,t.parent.parent.color=RED,t=t.parent.parent):(t==t.parent.left&&(t=t.parent,this.rightRotate(t)),t.parent.color=BLACK,t.parent.parent.color=RED,t.parent.parent!=this.sentinel&&this.leftRotate(t.parent.parent))}this.root.color=BLACK},js_cols.RedBlackSet.prototype.delete_=function(t){var e=t.left==this.sentinel||t.right==this.sentinel?t:this.successor_(t),s=e.left!=this.sentinel?e.left:e.right;s.parent=e.parent,e.parent==this.sentinel?this.root=s:e==e.parent.left?e.parent.left=s:e.parent.right=s,e!=t&&(t.key=e.key),e.color==BLACK&&this.deleteFixup(s),this.size--},js_cols.RedBlackSet.prototype.deleteFixup=function(t){for(;t!=this.root&&t.color==BLACK;){var e;t=t==t.parent.left?((e=t.parent.right).color==RED&&(e.color=BLACK,t.parent.color=RED,this.leftRotate(t.parent),e=t.parent.right),e.left.color==BLACK&&e.right.color==BLACK?(e.color=RED,t.parent):(e.right.color==BLACK&&(e.left.color=BLACK,e.color=RED,this.rightRotate(e),e=t.parent.right),e.color=t.parent.color,t.parent.color=BLACK,e.right.color=BLACK,this.leftRotate(t.parent),this.root)):((e=t.parent.left).color==RED&&(e.color=BLACK,t.parent.color=RED,this.rightRotate(t.parent),e=t.parent.left),e.right.color==BLACK&&e.left.color==BLACK?(e.color=RED,t.parent):(e.left.color==BLACK&&(e.right.color=BLACK,e.color=RED,this.leftRotate(e),e=t.parent.left),e.color=t.parent.color,t.parent.color=BLACK,e.left.color=BLACK,this.rightRotate(t.parent),this.root))}t.color=BLACK},js_cols.RedBlackSet.prototype.remove=function(t){var e,t=this.get_(t);return t!=this.sentinel?(e=t.key,this.delete_(t),e):null},js_cols.RedBlackSet.prototype.removeSwapped=function(t,e){this.remove(e)},js_cols.RedBlackSet.prototype.min=function(t){for(;t.left!=this.sentinel;)t=t.left;return t},js_cols.RedBlackSet.prototype.max=function(t){for(;t.right!=this.sentinel;)t=t.right;return t},js_cols.RedBlackSet.prototype.successor_=function(t){if(t.right!=this.sentinel)return this.min(t.right);for(var e=t.parent;e!=this.sentinel&&t==e.right;)e=(t=e).parent;return e},js_cols.RedBlackSet.prototype.predeccessor_=function(t){if(t.left!=this.sentinel)return this.max(t.left);for(var e=t.parent;e!=this.sentinel&&t==e.left;)e=(t=e).parent;return e},js_cols.RedBlackSet.prototype.successor=function(t){if(0<this.size){var e=this.get_(t);if(e==this.sentinel)return null;if(e.right!=this.sentinel)return this.min(e.right).key;for(var s=e.parent;s!=this.sentinel&&e==s.right;)s=(e=s).parent;return s!=this.sentinel?s.key:null}return null},js_cols.RedBlackSet.prototype.predecessor=function(t){if(0<this.size){var e=this.get_(t);if(e==this.sentinel)return null;if(e.left!=this.sentinel)return this.max(e.left).key;for(var s=e.parent;s!=this.sentinel&&e==s.left;)s=(e=s).parent;return s!=this.sentinel?s.key:null}return null},js_cols.RedBlackSet.prototype.getMin=function(){return this.min(this.root).key},js_cols.RedBlackSet.prototype.getMax=function(){return this.max(this.root).key},js_cols.RedBlackSet.prototype.get_=function(t){for(var e=this.root;e!=this.sentinel&&0!=this.compare(e.key,t);)e=this.compare(t,e.key)<0?e.left:e.right;return e},js_cols.RedBlackSet.prototype.contains=function(t){return null!=this.get_(t).key},js_cols.RedBlackSet.prototype.getValues=function(){var e=[];return this.forEach(function(t){e.push(t)}),e},js_cols.RedBlackSet.prototype.insertAll=function(t){if("array"==js_cols.typeOf(t))for(var e=0;e<t.length;e++)this.insert(t[e]);else if("function"==js_cols.typeOf(t.forEach))t.forEach(this.insert,this);else if("function"==js_cols.typeOf(t.getValues))for(var s=t.getValues(),e=0;e<s.length;e++)this.insert(s[e]);else if("object"==js_cols.typeOf(t))for(var r in t)this.insert(t[r])},js_cols.RedBlackSet.prototype.removeAll=function(t){if("array"==js_cols.typeOf(t))for(var e=0;e<t.length;e++)this.remove(t[e]);else if("function"==js_cols.typeOf(t.forEach))t.forEach(this.removeSwapped,this);else if("function"==js_cols.typeOf(t.getValues))for(var s=t.getValues(),e=0;e<s.length;e++)this.remove(s[e]);else if("object"==js_cols.typeOf(t))for(var r in t)this.remove(t[r])},js_cols.RedBlackSet.prototype.containsAll=function(t){if("array"==js_cols.typeOf(t)){for(var e=0;e<t.length;e++)if(!this.contains(t[e]))return!1;return!0}if("function"==js_cols.typeOf(t.forEach))return t.every(this.contains,this);if("function"==js_cols.typeOf(t.getValues)){for(var s=t.getValues(),e=0;e<s.length;e++)if(!this.contains(s[e]))return!1;return!0}if("object"==js_cols.typeOf(t)){for(var r in t)if(!this.contains(t[r]))return!1;return!0}},js_cols.RedBlackSet.prototype.range=function(t,e){var s=[];return this.traverseFromTo(function(t){s.push(t)},t,e),s},js_cols.RedBlackSet.prototype.traverse=function(t,e){if(!this.isEmpty())for(var s=this.min(this.root);s!=this.sentinel;){if(t.call(e,s.key,this))return;s=this.successor_(s)}},js_cols.RedBlackSet.prototype.traverseFrom=function(t,e,s){if(!this.isEmpty())for(var r=this.get_(e);r!=this.sentinel;){if(t.call(s,r.key,this))return;r=this.successor_(r)}},js_cols.RedBlackSet.prototype.traverseTo=function(t,e,s){if(!this.isEmpty())for(var r=this.min(this.root),i=this.get_(e);r!=i;){if(t.call(s,r.key,this))return;r=this.successor_(r)}},js_cols.RedBlackSet.prototype.traverseFromTo=function(t,e,s,r){if(!this.isEmpty())for(var i=this.get_(e),o=this.get_(s);i!=o;){if(t.call(r,i.key,this))return;i=this.successor_(i)}},js_cols.RedBlackSet.prototype.traverseBackwards=function(t,e){if(!this.isEmpty())for(var s=this.max(this.root);s!=this.sentinel;){if(t.call(e,s.key,this))return;s=this.predeccessor_(s)}},js_cols.RedBlackSet.prototype.forEach=function(t,e){if(!this.isEmpty())for(var s=this.min(this.root);s!=this.sentinel;s=this.successor_(s))t.call(e,s.key,s.key,this)},js_cols.RedBlackSet.prototype.some=function(t,e){if(!this.isEmpty())for(var s=this.min(this.root);s!=this.sentinel;s=this.successor_(s))if(t.call(e,s.key,s.key,this))return!0;return!1},js_cols.RedBlackSet.prototype.every=function(t,e){if(this.isEmpty())return!1;for(var s=this.min(this.root);s!=this.sentinel;s=this.successor_(s))if(!t.call(e,s.key,s.key,this))return!1;return!0},js_cols.RedBlackSet.prototype.map=function(t,e){var s=[];if(!this.isEmpty())for(var r=this.min(this.root);r!=this.sentinel;r=this.successor_(r))s.push(t.call(e,r.key,r.key,this));return s},js_cols.RedBlackSet.prototype.filter=function(t,e){var s=[];if(!this.isEmpty())for(var r=this.min(this.root);r!=this.sentinel;r=this.successor_(r))t.call(e,r.key,r.key,this)&&s.push(r.key);return s},js_cols.RedBlackSet.prototype.getCount=function(){return this.size},js_cols.RedBlackSet.prototype.isEmpty=function(){return 0==this.size},js_cols.RedBlackSet.prototype.isSubsetOf=function(t){var e=js_cols.getCount(t);if(this.getCount()>e)return!1;var s=0;if(this.isEmpty())return!0;for(var r=this.min(this.root);r!=this.sentinel;r=this.successor_(r))js_cols.contains.call(t,t,r.key)&&s++;return s==this.getCount()},js_cols.RedBlackSet.prototype.intersection=function(t){var e=new js_cols.RedBlackSet(this.compare);if(!this.isEmpty())for(var s=this.min(this.root);s!=this.sentinel;s=this.successor_(s))t.contains.call(t,s.key,s.key,this)&&e.insert(s.key);return e},C3.RedBlackSet=class extends C3.DefendedBase{constructor(t){super(),this._rbSet=new js_cols.RedBlackSet(t),this._enableQueue=!1,this._queueInsert=new Set,this._queueRemove=new Set}Add(t){this._enableQueue?this._rbSet.contains(t)?this._queueRemove.delete(t):this._queueInsert.add(t):this._rbSet.insert(t)}Remove(t){this._enableQueue?this._rbSet.contains(t)?this._queueRemove.add(t):this._queueInsert.delete(t):this._rbSet.remove(t)}Has(t){return this._enableQueue?!!this._queueInsert.has(t)||!this._queueRemove.has(t)&&this._rbSet.contains(t):this._rbSet.contains(t)}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 t=this._rbSet,e=t.min(t.root);return e.key}Shift(){if(this.IsEmpty())throw new Error("empty set");if(this._enableQueue)throw new Error("cannot be used in queueing mode");const t=this.Front();return this.Remove(t),t}SetQueueingEnabled(t){if(this._enableQueue!==(t=!!t)&&!(this._enableQueue=t)){for(const e of this._queueRemove)this._rbSet.remove(e);this._queueRemove.clear();for(const s of this._queueInsert)this._rbSet.insert(s);this._queueInsert.clear()}}ForEach(t){this._rbSet.forEach(t)}*values(){if(!this.IsEmpty()){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()}}; } // ../lib/util/promiseThrottle.js { const C3=self.C3;C3.PromiseThrottle=class{constructor(e=C3.hardwareConcurrency){this._maxParallel=e,this._queue=[],this._activeCount=0}Add(s){return new Promise((e,t)=>{this._queue.push({func:s,resolve:e,reject:t}),this._MaybeStartNext()})}_FindInQueue(s){for(let e=0,t=this._queue.length;e<t;++e)if(this._queue[e].func===s)return e;return-1}RemoveAndResolve(e,t){const s=this._FindInQueue(e);if(-1===s)throw new Error("cannot find promise to resolve");this._queue[s].resolve(t),this._queue.splice(s,1)}RemoveAndReject(e,t){const s=this._FindInQueue(e);if(-1===s)throw new Error("cannot find promise to reject");this._queue[s].reject(t),this._queue.splice(s,1)}async _MaybeStartNext(){if(this._queue.length&&!(this._activeCount>=this._maxParallel)){this._activeCount++;const t=this._queue.shift();try{const e=await t.func();t.resolve(e)}catch(e){t.reject(e)}this._activeCount--,this._MaybeStartNext()}}static async Batch(e,t){const s=[];let r=!1;const i=[];for(;e--;)i.push((async()=>{let e;for(;e=t.pop();){if(r)return;try{s.push(await e())}catch(e){throw r=!0,e}}})());return await Promise.all(i),s}}; } // ../lib/util/rateLimiter.js { const C3=self.C3;C3.RateLimiter=class{constructor(t,e,i){this._callback=t,this._interval=e,this._intervalOnBattery=i||2*e,this._timerId=-1,this._lastCallTime=-1/0,this._timerCallFunc=()=>this._OnTimer(),this._ignoreReset=!1,this._canRunImmediate=!1,this._callbackArguments=null}SetCanRunImmediate(t){this._canRunImmediate=!!t}_GetInterval(){return void 0!==C3.Battery&&C3.Battery.IsOnBatteryPower()?this._intervalOnBattery:this._interval}Call(...l){if(-1===this._timerId){this._callbackArguments=l;let t=C3.FastGetDateNow(),e=t-this._lastCallTime,i=this._GetInterval();i<=e&&this._canRunImmediate?(this._lastCallTime=t,this._RunCallback()):this._timerId=self.setTimeout(this._timerCallFunc,Math.max(i-e,4))}}_RunCallback(){this._ignoreReset=!0;const t=this._callbackArguments;this._callbackArguments=null,t?this._callback(...t):this._callback(),this._ignoreReset=!1}Reset(){this._ignoreReset||(this._CancelTimer(),this._callbackArguments=null,this._lastCallTime=C3.FastGetDateNow())}_OnTimer(){this._timerId=-1,this._lastCallTime=C3.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}}; } // ../lib/util/svgRaster/svgRasterManager.js { const C3=self.C3;C3.SVGRasterManager=class{constructor(){this._images=new Map,this._allowNpotSurfaces=!1,this._getBaseSizeCallback=null,this._rasterAtSizeCallback=null,this._releaseResultCallback=null,this._redrawCallback=null}SetNpotSurfaceAllowed(e){this._allowNpotSurfaces=!!e}IsNpotSurfaceAllowed(){return this._allowNpotSurfaces}SetGetBaseSizeCallback(e){this._getBaseSizeCallback=e}GetBaseSize(e){if(this._getBaseSizeCallback)return this._getBaseSizeCallback(e);throw new Error("no get base size callback set")}SetRasterAtSizeCallback(e){this._rasterAtSizeCallback=e}RasterAtSize(e,a,t,l,s,r){if(this._rasterAtSizeCallback)return this._rasterAtSizeCallback(e,a,t,l,s,r);throw new Error("no raster at size callback set")}SetReleaseResultCallback(e){this._releaseResultCallback=e}ReleaseResult(e){if(!this._releaseResultCallback)throw new Error("no release result callback set");this._releaseResultCallback(e)}SetRedrawCallback(e){this._redrawCallback=e}Redraw(){if(!this._redrawCallback)throw new Error("no redraw callback set");this._redrawCallback()}AddImage(e){let a=this._images.get(e);return a||(a=C3.New(C3.SVGRasterImage,this,e),this._images.set(e,a)),a.IncReference(),a}_RemoveImage(e){this._images.delete(e.GetDataSource())}OnTexturesChanged(){for(const e of this._images.values())e.ReleaseRasterizedResult(),e.ForceRasterAgain()}}; } // ../lib/util/svgRaster/svgRasterImage.js { const C3=self.C3,MAX_SURFACE_SIZE=4096;C3.SVGRasterImage=class{constructor(e,t){this._manager=e,this._dataSource=t,this._refCount=0,this._baseWidth=0,this._baseHeight=0,this._getBaseSizePromise=this._manager.GetBaseSize(t).then(e=>{this._manager&&(this._baseWidth=e[0],this._baseHeight=e[1],this._manager.Redraw())}).catch(e=>{console.error("[SVG] Error loading SVG: ",e),this._hadError=!0,this._manager&&this._manager.Redraw()}),this._rasterSurfaceWidth=0,this._rasterSurfaceHeight=0,this._rasterImageWidth=0,this._rasterImageHeight=0,this._isRasterizing=!1,this._rasterizedResult=null,this._forceRaster=!1,this._hadError=!1}Release(){if(this._refCount<=0)throw new Error("already released");this._refCount--,0===this._refCount&&this._Release()}ReleaseRasterizedResult(){this._rasterizedResult&&(this._manager.ReleaseResult(this._rasterizedResult),this._rasterizedResult=null)}_Release(){this.ReleaseRasterizedResult(),this._manager._RemoveImage(this),this._manager=null}GetDataSource(){return this._dataSource}IncReference(){this._refCount++}HasReferences(){return 0<this._refCount}GetRasterizedResult(){return this._rasterizedResult}ForceRasterAgain(){this._forceRaster=!0}async StartRasterForSize(s,r,a){if(0!==r&&0!==a&&!this._hadError&&!this._isRasterizing){let e=C3.nextHighestPowerOfTwo(Math.ceil(r)),t=C3.nextHighestPowerOfTwo(Math.ceil(a));const i=Math.max(e,t);if(i>MAX_SURFACE_SIZE){const h=MAX_SURFACE_SIZE/i;r*=h,a*=h,e=Math.min(Math.ceil(e*h),MAX_SURFACE_SIZE),t=Math.min(Math.ceil(t*h),MAX_SURFACE_SIZE)}if(r<e&&a<t){const _=r/a,n=e/t;a=_<n?(r=t*_,t):(r=e)/_}if(this._manager.IsNpotSurfaceAllowed()&&(e=Math.ceil(r),t=Math.ceil(a)),!(e<=this._rasterSurfaceWidth&&t<=this._rasterSurfaceHeight)||this._forceRaster){this._isRasterizing=!0,this._rasterSurfaceWidth=e,this._rasterSurfaceHeight=t;const R=await this._manager.RasterAtSize(this._dataSource,s,this._rasterSurfaceWidth,this._rasterSurfaceHeight,r,a);this._manager&&(this.ReleaseRasterizedResult(),this._rasterizedResult=R,this._rasterImageWidth=r,this._rasterImageHeight=a,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}}; } // ../lib/str/str.js { const C3=self.C3,NUMERIC_CHARS=(C3.UTF8_BOM="\ufeff",new Set("0123456789")),WHITESPACE_CHARS=(C3.IsNumericChar=function(t){return NUMERIC_CHARS.has(t)},new Set(" \t\n\r \u2028\u2029 "));C3.IsWhitespaceChar=function(t){return WHITESPACE_CHARS.has(t)},C3.FilterWhitespace=function(t){return[...t].filter(t=>!C3.IsWhitespaceChar(t)).join("")},C3.IsStringAllWhitespace=function(t){for(const e of t)if(!C3.IsWhitespaceChar(e))return!1;return!0},C3.IsCharArrayAllWhitespace=function(t){for(const e of t)if(!C3.IsWhitespaceChar(e))return!1;return!0},C3.IsUnprintableChar=function(t){return 1===t.length&&t.charCodeAt(0)<32},C3.FilterUnprintableChars=function(t){return[...t].filter(t=>!C3.IsUnprintableChar(t)).join("")};let cjkPunctuationRegex=null;try{cjkPunctuationRegex=new RegExp("\\p{P}(?<=[\\u3000-\\u303F\\uFF00-\\uFFEF])","u")}catch(t){console.warn("Unable to detect CJK punctuation: ",t)}C3.IsCJKPunctuationChar=function(t){return!C3.IsWhitespaceChar(t)&&cjkPunctuationRegex&&cjkPunctuationRegex.test(t)};const NUMERIC_STRING_CHARS=new Set("0123456789.+-e"),HTML_ENTITY_MAP=(C3.IsStringNumber=function(e){if(!(e=e.trim()).length)return!1;let t=e.charAt(0);if("-"!==t&&!NUMERIC_CHARS.has(t))return!1;for(let t of e)if(!NUMERIC_STRING_CHARS.has(t))return!1;return!0},C3.RemoveTrailingDigits=function(e){let n=e.length;for(;0<n;){let t=e.charAt(n-1);if(!C3.IsNumericChar(t))break;--n}return e.substr(0,n)},C3.IncrementNumberAtEndOf=function(t){let e=C3.RemoveTrailingDigits(t),n=t.substr(e.length);return e+(n=n?(parseInt(n,10)+1).toString():"2")},new Map([["&","&"],["<","<"],[">",">"],['"',"""],["'","'"]]));function lookupHtmlEntity(t){return HTML_ENTITY_MAP.get(t)}const HTML_ENTITY_REGEX=/[&<>"']/g,ESCAPE_REGEX=(C3.EscapeHTML=function(t){return t.replace(HTML_ENTITY_REGEX,lookupHtmlEntity)},C3.EscapeJS=function(t){let e=C3.ReplaceAll(t,"\\","\\\\");return e=C3.ReplaceAll(e,'"','\\"'),e=C3.ReplaceAll(e,"\t","\\t"),e=C3.ReplaceAll(e,"\r",""),C3.ReplaceAll(e,"\n","\\n")},C3.EscapeXML=function(t){let e=C3.ReplaceAll(t,"&","&");return e=C3.ReplaceAll(e,"<","<"),e=C3.ReplaceAll(e,">",">"),C3.ReplaceAll(e,'"',""")},/[-[\]{}()*+?.,\\^$|#\s]/g),intlSegmenter=(C3.EscapeRegex=function(t){return t.replace(ESCAPE_REGEX,"\\$&")},C3.CountCharsInString=function(t,e){let n=0;for(const r of t)r===e&&++n;return n},C3.FindAll=function(t,e,n=!1){if(!e)return[];n||(t=t.toLowerCase(),e=e.toLowerCase());const r=e.length;let o=0,i,l=[];for(;-1<(i=t.indexOf(e,o));)l.push(i),o=i+r;return l},C3.ReplaceAll=function(t,e,n){return t.replaceAll(e,()=>n)},C3.ReplaceAllCaseInsensitive=function(t,e,n){return t.replace(new RegExp(C3.EscapeRegex(e),"gi"),()=>n)},C3.SetElementContent=function(t,e){"string"==typeof e?t.textContent=e:e.isPlainText()?t.textContent=e.toString():(t.innerHTML=e.toHTML(),e instanceof C3.BBString&&e.attachLinkHandlers(t))},C3.StringLikeEquals=function(t,e){return t instanceof C3.HtmlString||t instanceof C3.BBString?t.equals(e):e instanceof C3.HtmlString||e instanceof C3.BBString?e.equals(t):t===e},C3.StringSubstitute=function(n,...r){let o=n;for(let t=0,e=r.length;t<e;++t){const i=`{${t}}`;if(!n.includes(i))throw new Error(`missing placeholder '${i}' in string substitution`);o=o.replace(i,r[t].toString())}return o},C3.StringSubstituteAllowMissing=function(n,...r){let o=n,i=-1,l=-1;for(let t=0,e=r.length;t<e;++t){const s=`{${t}}`;n.includes(s)?(l=t,o=o.replace(s,r[t].toString())):-1===i&&(i=t)}if(0<=i&&0<=l&&i<l)throw new Error(`missing placeholder '${i}' in string substitution`);return o},C3.StringSubstituteMap=function(t,n){let r=t;for(let[t,e]of Object.entries(n))r=r.replaceAll(t,e.toString());return r},C3.SortAZ=function(t,e){return e<t?1:t<e?-1:0},C3.SortAZCaseInsensitive=function(t,e){let n=t.toLowerCase(),r=e.toLowerCase();return r<n?1:n<r?-1:0},new self["Intl"]["Segmenter"]),KILOBYTE=(C3.SplitGraphemes=function(t){const e=[];for(const n of intlSegmenter["segment"](t))e.push(n["segment"]);return e},C3.IterateGraphemes=function*(t){for(const e of intlSegmenter["segment"](t))yield e["segment"]},C3.CountGraphemes=function(t){let e=0;for(const n of intlSegmenter["segment"](t))++e;return e},1024),MEGABYTE=1024*KILOBYTE,GIGABYTE=1024*MEGABYTE,TERABYTE=1024*GIGABYTE,DEFAULT_FORMATTIME_OPTS={approximate:!(C3.FormatDataSize=function(e,t){let n="common."+(t?"dataRates":"dataSizes")+".";const r=self.langSub;if(e<KILOBYTE)return r(n+"bytes",e);if(e<MEGABYTE){let t=e/KILOBYTE;return t=t<10?Math.round(10*t)/10:Math.round(t),r(n+"kilobytes",t)}if(e<GIGABYTE){let t=e/MEGABYTE;return t=t<10?Math.round(10*t)/10:Math.round(t),r(n+"megabytes",t)}if(e<TERABYTE){let t=e/GIGABYTE;return t=t<10?Math.round(10*t)/10:Math.round(t),r(n+"gigabytes",t)}{let t=e/TERABYTE;return t=t<10?Math.round(10*t)/10:Math.round(t),r(n+"terabytes",t)}}),days:!0,hours:!0,minutes:!0,seconds:!0};C3.FormatTime=function(t,e){e=Object.assign({},DEFAULT_FORMATTIME_OPTS,e),C3.Lang.PushContext("common.time");const n=[],r=self.lang,o=self.langPluralSub;if(e.days){const l=Math.floor(t/86400);0<l&&(t-=24*l*3600,n.push(o(".days",null,l)))}if(e.hours){const s=Math.floor(t/3600);(0<s||n.length)&&(t-=3600*s,n.push(o(".hours",null,s)))}if(e.minutes){const a=Math.floor(t/60);(0<a||n.length||!e.seconds)&&(t-=60*a,n.push(o(".minutes",null,a)))}if(e.seconds){const u=Math.floor(t%60);n.push(o(".seconds",null,u))}const i=(e.approximate?r(".approx-prefix"):"")+n.join(r(".separator"));return C3.Lang.PopContext(),i},C3.ZeroPad=function(t,e){let n=t<0?"-":"",r=(t=Math.abs(t)).toString(),o=e-r.length;for(let t=0;t<o;++t)n+="0";return n+r},C3.StringToTitleCase=function(t){return t.toLowerCase().replace(/\b\w/g,t=>t.toUpperCase())},C3.CompareVersionStrings=function(t,e){let n=t.split(".").map(t=>t.trim()),r=e.split(".").map(t=>t.trim());C3.resizeArray(n,4,"0"),C3.resizeArray(r,4,"0"),n=n.map(t=>parseInt(t,10)),r=r.map(t=>parseInt(t,10));for(let t=0;t<4;++t){const o=n[t]-r[t];if(0!=o)return o<0?-1:1}return 0},C3.CreateGUID=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=Math.floor(16*Math.random()),n="x"===t?e:3&e|8;return n.toString(16)})},C3.StringHammingDistance=function(n,r){if(n.length!==r.length)throw new Error("strings must be same length");let o=0;for(let t=0,e=n.length;t<e;++t)n.charAt(t)!==r.charAt(t)&&++o;return o},C3.StringLevenshteinDistance=function(t,e){if(0===t.length)return e.length;if(0===e.length)return t.length;let n,r,o,i,l,s;for(e.length<t.length&&(n=t,t=e,e=n),s=Array(t.length+1),r=0;r<=t.length;r++)s[r]=r;for(r=1;r<=e.length;r++){for(i=r,o=1;o<=t.length;o++)l=e[r-1]===t[o-1]?s[o-1]:Math.min(s[o-1]+1,Math.min(i+1,s[o]+1)),s[o-1]=i,i=l;s[t.length]=i}return s[t.length]}; } // ../lib/str/bbstring.js { const C3=self.C3,assert=self.assert,BB_CODE_MAP=new Map([["b","strong"],["i","em"],["s","s"],["u","u"],["sub","sub"],["sup","sup"],["small","small"],["mark","mark"],["code","code"],["a1","a"],["a2","a"],["a3","a"],["a4","a"],["a5","a"],["a6","a"],["a7","a"],["a8","a"],["a9","a"],["tip1","abbr"],["tip2","abbr"],["tip3","abbr"],["tip4","abbr"],["tip5","abbr"],["tip6","abbr"],["tip7","abbr"],["tip8","abbr"],["tip9","abbr"],["bad",["span","bbCodeBad"]],["good",["span","bbCodeGood"]],["info",["span","bbCodeInfo"]],["h1",["span","bbCodeH1"]],["h2",["span","bbCodeH2"]],["h3",["span","bbCodeH3"]],["h4",["span","bbCodeH4"]],["item",["span","bbCodeItem"]]]),SELF_CLOSING_TAGS=new Set(["icon"]),BBREGEX=/\[(\/?)([a-zA-Z0-9]+)\]/g,CUSTOM_BBREGEX=/\[(\/?)([^\[\n]*?)\]/g;let linkActions=null,tipList=null,classIndex=0;function bbToHtmlReplacerFunc(t,i,s){const n=BB_CODE_MAP.get(s);if(!n)return"class"===s?i?"</span>":`<span class="bbclass${classIndex++}">`:t;if("string"==typeof n){if("a"===n&&0===linkActions.length||"abbr"===n&&0===tipList.length)return t;if("a"!==n||i){if("abbr"!==n||i)return"<"+i+n+">";{const e=parseInt(s.substring(3),10)-1;if(e<0||e>=tipList.length)throw new Error("invalid bbcode tip substitution");const r=tipList[e];let t="";if("string"==typeof r?t=r:"function"==typeof r&&(t=r()),"string"!=typeof t)throw new TypeError("invalid bbcode tip");return`<abbr title="${C3.ReplaceAll(t,'"',""")}">`}}{const a=parseInt(s.substring(1),10)-1;if(a<0||a>=linkActions.length)throw new Error("invalid bbcode link substitution");const o=linkActions[a];if("string"==typeof o)return`<a href="${linkActions[a]}">`;if("function"==typeof o)return`<a class="bblink${a}">`;throw new TypeError("invalid bbcode link action")}}if(Array.isArray(n)){let t=n[0],s=n[1];return i?"</"+t+">":`<${t} class="${s}">`}}const LINEBREAK_REGEX=/\n/g;C3.BBString=class{constructor(t,s){if(this._bbstr=s&&s.noEscape?t:C3.EscapeHTML(t),this._htmlstr="",this._convertLineBreaks=!1,this._linkActions=[],this._tipList=[],s){if(this._convertLineBreaks=!!s.convertLineBreaks,s.links){if(9<s.links.length)throw new Error("too many links");this._linkActions=s.links}if(s.tips){if(9<s.tips.length)throw new Error("too many tips");this._tipList=s.tips}}this._hasAnyBBtags=this._bbstr.includes("["),this._needsLineBreakConversion=this._convertLineBreaks&&this._bbstr.includes("\n"),this._isPlain=!this._hasAnyBBtags&&!this._needsLineBreakConversion&&!this._bbstr.includes("&"),this._hasParsedFragments=!1,this._fragments=[]}toString(){return this._bbstr}valueOf(){return this._bbstr}isPlainText(){return this._isPlain}toPlainText(){return this._hasAnyBBtags?this._bbstr.replace(BBREGEX,""):this._bbstr}toHTML(){if(this._isPlain)return this._bbstr;if(!this._htmlstr&&this._bbstr){let t=this._bbstr;this._hasAnyBBtags&&(classIndex=0,linkActions=this._linkActions,tipList=this._tipList,t=t.replace(BBREGEX,bbToHtmlReplacerFunc),linkActions=null,tipList=null),this._needsLineBreakConversion&&(t=t.replace(LINEBREAK_REGEX,"<br>")),this._htmlstr=t}return this._htmlstr}attachLinkHandlers(i){if(this._linkActions.length)for(let t=0,s=this._linkActions.length;t<s;++t){const n=this._linkActions[t];if("function"==typeof n){const e=i.querySelector(".bblink"+t);if(!e)throw new Error("unable to attach BBString link handler");e.onclick=n}}}equals(t){return t instanceof C3.HtmlString?this.toHTML()===t.toHTML():t instanceof C3.BBString?this._bbstr===t._bbstr:this._bbstr===t}toFragmentList(){if(!this._hasParsedFragments){const i=[],n=this._bbstr,e=[];let t=CUSTOM_BBREGEX.lastIndex=0,s;for(;null!==(s=CUSTOM_BBREGEX.exec(n));){const r=s.index;if(!(0<r&&"\\"===n.charAt(r-1))){const a=s[0],o=s[1],l=s[2],b=n.substring(t,r);if(t=r+a.length,b&&i.push({text:b,styles:e.slice(0)}),l)if(o){const c=l.toLowerCase();for(let t=e.length-1;0<=t;--t)if(e[t].tag===c){e.splice(t,1);break}}else{let t=l,s=null;const h=l.indexOf("=");if(-1!==h?(t=l.substring(0,h).toLowerCase(),s=l.substring(h+1)):t=t.toLowerCase(),SELF_CLOSING_TAGS.has(t)){if("icon"!==t)throw new Error("unknown self-closing tag "+t);i.push({icon:s,styles:e.slice(0)})}else e.push({tag:t,param:s})}}}t<n.length&&i.push({text:n.substring(t),styles:e.slice(0)});for(const p of i)p.text&&(p.text=this._ProcessBBCodeEscapeSequences(p.text));this._fragments=i.map(t=>t.icon?C3.New(C3.IconFragment,{icon:t.icon,styles:t.styles}):C3.New(C3.TextFragment,{chArr:C3.SplitGraphemes(t.text),styles:t.styles})),this._hasParsedFragments=!0}return this._fragments}_ProcessBBCodeEscapeSequences(t){return t=C3.ReplaceAll(t,"\\[","["),C3.ReplaceAll(t,"\\\\","\\")}static StripTags(t){return C3.New(C3.BBString,t,{noEscape:!0}).toPlainText()}static StripAnyTags(t){return t.replace(CUSTOM_BBREGEX,"")}}; } // ../lib/str/textLayout/wordWrap.js { const C3=self.C3;function IsWordBreakWhiteSpace(e){return" "!==e&&" "!==e&&C3.IsWhitespaceChar(e)}const CJK_OPEN_PUNCTUATION=new Set("〈《「『【〔〖〘〚〝");function IsOpeningCJKPunctiationChar(e){return CJK_OPEN_PUNCTUATION.has(e)}function IsContinuingCJKPunctuationChar(e){return C3.IsCJKPunctuationChar(e)&&!IsOpeningCJKPunctiationChar(e)}function WordBreakTrimEnd(e){for(;0<e.length&&IsWordBreakWhiteSpace(e.at(-1));)e.pop()}function IsNewline(e){return"\n"===e||"\r\n"===e}C3.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 n=0,s=0,i=0,o=0,r=0;for(const h of e){if(-1===h.GetWidth()){const a=t(h);h.SetHeight(a.height),h.SetFontBoundingBoxAscent(a.fontBoundingBoxAscent||0),h.SetFontBoundingBoxDescent(a.fontBoundingBoxDescent||0),h.SetTopToAlphabeticDistance(a.topToAlphabeticDistance||0),h.IsText()?h.SetWidth(a.width):h.IsIcon()&&h.CalculateWidthFromHeight(this._iconSet)}n+=h.GetWidth(),s=Math.max(s,h.GetHeight()),i=Math.max(i,h.GetFontBoundingBoxAscent()),o=Math.max(o,h.GetFontBoundingBoxDescent()),r=Math.max(r,h.GetTopToAlphabeticDistance())}return{width:n,height:s,fontBoundingBoxAscent:i,fontBoundingBoxDescent:o,topToAlphabeticDistance:r}}_AddLine(e,t,n,s,i,o){this._lines.push(C3.New(C3.WordWrap.Line,{fragments:e,width:t,height:n,fontBoundingBoxAscent:s,fontBoundingBoxDescent:i,topToAlphabeticDistance:o}))}WordWrap(t,o,r,n,h){if("string"==typeof t&&(t=[C3.New(C3.TextFragment,{chArr:C3.SplitGraphemes(t)})]),C3.clearArray(this._lines),!(!t.length||1===t.length&&t[0].IsText()&&t[0].IsEmpty()||r<2)){if(1===t.length){const a=t[0];if(a.IsText()&&a.GetLength()<=100&&!a.HasNewLine()){let{width:e,height:t,fontBoundingBoxAscent:n,fontBoundingBoxDescent:s,topToAlphabeticDistance:i}=o(a);if(e+=h,a.SetWidth(e),a.SetHeight(t),a.SetFontBoundingBoxAscent(n||0),a.SetFontBoundingBoxDescent(s||0),a.SetTopToAlphabeticDistance(i||0),e<=r)return void this._AddLine([a],e,t,n,s,i)}}let e;e="word"===n?this._TokeniseByWord(t):"cjk"===n?this._TokeniseByCJK(t):this._TokeniseByChar(t),this._WrapText(e,o,r,h)}}_TokeniseByWord(e){const t=[];let n=[],s=!1;for(const i of e){const o=i.GetStyles();if(i.IsIcon())0<n.length&&t.push(n),t.push([i]),n=[];else for(const r of i.GetCharacterArray())if(IsNewline(r))0<n.length&&t.push(n),t.push([C3.New(C3.TextFragment,{chArr:["\n"],styles:o})]),n=[];else if(0===n.length)n.push(C3.New(C3.TextFragment,{chArr:[r],styles:o})),s=IsWordBreakWhiteSpace(r);else{const h=IsWordBreakWhiteSpace(r);if(h===s){const a=n.at(-1);a.GetStyles()===o?a._AppendChar(r):n.push(C3.New(C3.TextFragment,{chArr:[r],styles:o}))}else t.push(n),n=[C3.New(C3.TextFragment,{chArr:[r],styles:o})],s=h}}return 0<n.length&&t.push(n),t}_TokeniseByCJK(e){const t=[];let n=[],s=!1;for(const i of e){const o=i.GetStyles();if(i.IsIcon())0<n.length&&t.push(n),t.push([i]),n=[];else for(const r of i.GetCharacterArray())if(IsNewline(r))0<n.length&&t.push(n),t.push([C3.New(C3.TextFragment,{chArr:["\n"],styles:o})]),n=[];else{if(0===n.length)n.push(C3.New(C3.TextFragment,{chArr:[r],styles:o}));else if(s||IsContinuingCJKPunctuationChar(r)){const h=n.at(-1);h.GetStyles()===o?h._AppendChar(r):n.push(C3.New(C3.TextFragment,{chArr:[r],styles:o}))}else t.push(n),n=[C3.New(C3.TextFragment,{chArr:[r],styles:o})];s=IsOpeningCJKPunctiationChar(r)}}return 0<n.length&&t.push(n),t}_TokeniseByChar(e){const t=[];for(const n of e)if(n.IsText()){const s=n.GetCharacterArray();C3.appendArray(t,s.map(e=>[C3.New(C3.TextFragment,{chArr:[e],styles:n.GetStyles()})]))}else t.push([n]);return t}_CopyLine(e){return e.map(e=>e._Clone())}_AddWordToLine(t,n){const e=t.length?t.at(-1):null;let s=0;e&&e.IsText()&&n[0].IsText()&&n[0].GetStyles()===e.GetStyles()&&(e._Append(n[0].GetCharacterArray()),s=1);for(let e=n.length;s<e;++s){const i=n[s];t.push(i._Clone())}}_WrapText(e,t,n,s){let i=[],o=0,r=0,h=0,a=0,c=0;for(const l of e)if(1===l.length&&l[0].IsText()&&1===l[0].GetLength()&&IsNewline(l[0].GetCharacterArray()[0])){if(0===r){const d=C3.New(C3.TextFragment,{chArr:[" "],styles:l[0].GetStyles()}),g=t(d);r=g.height,h=g.fontBoundingBoxAscent||0,a=g.fontBoundingBoxDescent||0,c=g.topToAlphabeticDistance||0}this._AddLine(i,o,r,h,a,c),i=[],o=0,r=0,h=0,a=0,c=0}else{const u=this._CopyLine(i),p=(this._AddWordToLine(u,l),this._MeasureLine(u,t)),C=p.width;if(n<=C)if(0<i.length&&this._AddLine(i,o,r,h,a,c),i=[],l[0].IsText()&&C3.IsCharArrayAllWhitespace(l[0].GetCharacterArray()))o=0,r=0,h=0,a=0,c=0;else{this._AddWordToLine(i,l);const f=this._MeasureLine(i,t);o=f.width,r=f.height,h=f.fontBoundingBoxAscent,a=f.fontBoundingBoxDescent,c=f.topToAlphabeticDistance}else i=u,o=C,r=p.height,h=p.fontBoundingBoxAscent,a=p.fontBoundingBoxDescent,c=p.topToAlphabeticDistance}0<i.length&&this._AddLine(i,o,r,h,a,c),this._TrimLinesTrailingWhitespace(t,s)}_TrimLinesTrailingWhitespace(t,n){for(const s of this._lines){const i=s._GetFragmentsArray();if(i.length){let e=i.at(-1);if(e.IsText()){const o=e.GetCharacterArray(),r=o.slice(0);if(WordBreakTrimEnd(r),0===r.length)s.OffsetWidth(-e.GetWidth()),i.pop();else if(r.length<o.length){e.SetCharacterArray(r);const h=t(e).width,a=e.GetWidth()-h;e.SetWidth(h),s.OffsetWidth(-a)}0!==n&&0<i.length&&((e=i.at(-1)).OffsetWidth(n),s.OffsetWidth(n))}}}}Clear(){C3.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)}}; } // ../lib/str/textLayout/line.js { const C3=self.C3;C3.WordWrap.Line=class{constructor(t){this._fragments=t.fragments||[],this._width=t.width||-1,this._height=t.height||-1,this._fontBoundingBoxAscent=t.fontBoundingBoxAscent||-1,this._fontBoundingBoxDescent=t.fontBoundingBoxDescent||-1,this._topToAlphabeticDistance=t.topToAlphabeticDistance||-1,this._posX=0,this._posY=0}fragments(){return this._fragments.values()}*fragmentsReverse(){const e=this._fragments;for(let t=e.length-1;0<=t;--t)yield e[t]}_GetFragmentsArray(){return this._fragments}OffsetWidth(t){this._width+=t}GetWidth(){return this._width}GetHeight(){return this._height}GetFoundBoundingBoxAscent(){return this._fontBoundingBoxAscent}GetFontBoundingBoxDescent(){return this._fontBoundingBoxDescent}GetTopToAlphabeticDistance(){return this._topToAlphabeticDistance}SetPosX(t){this._posX=t}GetPosX(){return this._posX}SetPosY(t){this._posY=t}GetPosY(){return this._posY}}; } // ../lib/str/textLayout/fragmentBase.js { const C3=self.C3;C3.FragmentBase=class{constructor(t){this._styles=t.styles||[],this._width=t.width||-1,this._height=t.height||-1,this._fontBoundingBoxAscent=t.fontBoundingBoxAscent||-1,this._fontBoundingBoxDescent=t.fontBoundingBoxDescent||-1,this._topToAlphabeticDistance=t.topToAlphabeticDistance||-1,this._posX=0,this._posY=0}IsText(){return!1}IsIcon(){return!1}GetStyles(){return this._styles}GetStyleTag(e){const s=this._styles;for(let t=s.length-1;0<=t;--t){const n=s[t];if(n.tag===e)return n}return null}HasStyleTag(t){return!!this.GetStyleTag(t)}GetStyleMap(){const t=new Map;for(const e of this._styles)t.set(e.tag,e.param);return t}OffsetWidth(t){this._width+=t}SetWidth(t){this._width=t}GetWidth(){return this._width}SetHeight(t){this._height=t}GetHeight(){return this._height}SetFontBoundingBoxAscent(t){this._fontBoundingBoxAscent=t}GetFontBoundingBoxAscent(){return this._fontBoundingBoxAscent}SetFontBoundingBoxDescent(t){this._fontBoundingBoxDescent=t}GetFontBoundingBoxDescent(){return this._fontBoundingBoxDescent}SetTopToAlphabeticDistance(t){this._topToAlphabeticDistance=t}GetTopToAlphabeticDistance(){return this._topToAlphabeticDistance}SetPosX(t){this._posX=t}GetPosX(){return this._posX}SetPosY(t){this._posY=t}GetPosY(){return this._posY}}; } // ../lib/str/textLayout/textFragment.js { const C3=self.C3;C3.TextFragment=class extends C3.FragmentBase{constructor(t){super(t),this._chArr=t.chArr}IsText(){return!0}_Append(t){C3.appendArray(this._chArr,t),this._width=-1,this._height=-1,this._fontBoundingBoxAscent=-1,this._fontBoundingBoxDescent=-1,this._topToAlphabeticDistance=-1}_AppendChar(t){this._chArr.push(t)}_Clone(){return C3.New(C3.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(t){this._chArr=t}GetLength(){return this._chArr.length}IsEmpty(){return 0===this._chArr.length}HasNewLine(){return this._chArr.includes("\n")}}; } // ../lib/str/textLayout/iconFragment.js { const C3=self.C3;C3.IconFragment=class extends C3.FragmentBase{constructor(t){super(t),this._icon=t.icon}IsIcon(){return!0}GetIconParameter(){return this._icon}_Clone(){return C3.New(C3.IconFragment,{icon:this._icon,styles:this._styles,width:this._width,height:this._height,fontBoundingBoxAscent:this._fontBoundingBoxAscent,fontBoundingBoxDescent:this._fontBoundingBoxDescent,topToAlphabeticDistance:this._topToAlphabeticDistance})}GetTextIcon(t){if(!t)return null;let e=Number(this._icon);return String(e)===this._icon?(e=Math.floor(e),t.GetTextIconByIndex(e)):t.GetTextIconByTag(this._icon)}CalculateWidthFromHeight(t){const e=this.GetTextIcon(t);this._width=e?this._height*e.GetWidth()/e.GetHeight():0}GetDrawable(t){const e=this.GetTextIcon(t);return e?e.GetDrawable():null}GetLength(){return 1}}; } // ../lib/str/textLayout/textIconManager.js { const C3=self.C3;C3.TextIconManager=class{constructor(t){this._iconSets=new Map,this._getIconSetMetaCallback=t.getIconSetMeta,this._getIconSetContentCallback=t.getIconSetContent}Release(){for(const t of this._iconSets.values())t.Release();this._iconSets.clear()}GetIconSet(t){let e=this._iconSets.get(t);if(!e){const n=this._getIconSetMetaCallback(t);e=C3.New(C3.TextIconSet,this,{source:t,iconMeta:n}),this._iconSets.set(t,e)}return e}HasIconSet(t){return this._iconSets.has(t)}DeleteIconSet(t){const e=this._iconSets.get(t);e&&e.Release(),this._iconSets.delete(t)}async _GetIconSetContent(t){return this._getIconSetContentCallback(t)}}; } // ../lib/str/textLayout/textIconSet.js { const C3=self.C3;C3.TextIconSet=class{constructor(t,s){this._textIconManager=t,this._source=s.source,this._iconsArray=[],this._iconsByTag=new Map,this._hasStartedLoad=!1,this._isLoading=!1,this._loadPromise=null;const o=s.iconMeta.icons;for(let t=0,s=o.length;t<s;++t){const e=o[t],a=C3.New(C3.TextIcon,this,{index:t,tag:e.tag,source:e.source,width:e.width,height:e.height});this._iconsArray.push(a),e.tag&&this._iconsByTag.set(e.tag.toLowerCase(),a)}}Release(){for(const t of this._iconsArray)t.Release();C3.clearArray(this._iconsArray),this._iconsByTag.clear(),this._textIconManager=null,this._source=null}HasLoaded(){return this._hasStartedLoad}IsLoading(){return this._isLoading}LoadContent(){return this._loadPromise||(this._loadPromise=this._DoLoadContent()),this._loadPromise}async _DoLoadContent(){if(!this._hasStartedLoad){this._hasStartedLoad=!0,this._isLoading=!0;const t=await this._textIconManager._GetIconSetContent(this._source);if(this._textIconManager){const o=t.icons;for(let t=0,s=Math.min(o.length,this._iconsArray.length);t<s;++t){const e=o[t].drawable;this._iconsArray[t]._SetDrawable(e)}this._isLoading=!1}}}GetTextIconByIndex(t){return(t=Math.floor(t))<0||t>=this._iconsArray.length?null:this._iconsArray[t]}GetTextIconByTag(t){return this._iconsByTag.get(t.toLowerCase())||null}}; } // ../lib/str/textLayout/textIcon.js { const C3=self.C3;C3.TextIcon=class{constructor(t,e){this._textIconSet=t,this._source=e.source||null,this._index=e.index,this._tag=e.tag,this._width=e.width,this._height=e.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(t){this._drawable=t}GetDrawable(){return this._drawable}}; } // ../lib/gfx/gfx.js { const C3=self.C3,glMatrix=self.glMatrix,vec3=glMatrix.vec3,vec4=glMatrix.vec4,mat4=glMatrix.mat4,tempVec3a=vec3.create(),tempVec3b=vec3.create(),tempVec3c=vec3.create(),tempVec4=vec4.create(),tempMat4=mat4.create(),neartl=vec3.create(),neartr=vec3.create(),nearbl=vec3.create(),nearbr=vec3.create(),fartl=vec3.create(),fartr=vec3.create(),farbl=vec3.create(),farbr=vec3.create(),unitViewport=vec4.fromValues(0,0,1,1);function PlaneFromPoints(t,e,r,n){const a=tempVec3c;vec3.subtract(tempVec3a,r,e),vec3.subtract(tempVec3b,t,e),vec3.cross(a,tempVec3a,tempVec3b),vec3.normalize(a,a),n.set(a[0],a[1],a[2],vec3.dot(t,a))}function IsInFrontOfPlane(t,e,r,n,a,c,s){const o=s.x,i=s.y,l=s.z,f=s.w,P=s.xF,h=s.yF,m=s.zF,p=1-P,v=1-h,u=1-m,b=o*t*P+o*n*p+i*e*h+i*a*v+l*r*m+l*c*u;if(f<=b)return!0;const F=o*n*P+o*t*p+i*a*h+i*e*v+l*c*m+l*r*u;return f<F}function IsPointInFrontOfPlane(t,e,r,n){const a=n.x,c=n.y,s=n.z,o=n.w,i=a*t+c*e+s*r;return o<=i}C3.Gfx={Project(t,e,r,n,a,c,s){const o=n[0]*t+n[4]*e+n[8]*r+n[12],i=n[1]*t+n[5]*e+n[9]*r+n[13],l=n[2]*t+n[6]*e+n[10]*r+n[14],f=n[3]*t+n[7]*e+n[11]*r+n[15];let P=a[0]*o+a[4]*i+a[8]*l+a[12]*f,h=a[1]*o+a[5]*i+a[9]*l+a[13]*f,m=a[2]*o+a[6]*i+a[10]*l+a[14]*f,p=a[3]*o+a[7]*i+a[11]*l+a[15]*f;return 0!=p&&(h*=p=1/p,m*=p,s[0]=(.5*(P*=p)+.5)*c[2]+c[0],s[1]=(.5*h+.5)*c[3]+c[1],s[2]=.5*(1+m),!0)},Unproject(t,e,r,n,a,c,s){const o=tempMat4,i=tempVec4;return mat4.multiply(o,a,n),null!==mat4.invert(o,o)&&(i[0]=(t-c[0])/c[2]*2-1,i[1]=(e-c[1])/c[3]*2-1,i[2]=2*r-1,i[3]=1,vec4.transformMat4(i,i,o),0!==i[3])&&(i[3]=1/i[3],s[0]=i[0]*i[3],s[1]=i[1]*i[3],s[2]=i[2]*i[3],!0)},UnprojectScreenToWorldZ(t,e,r,n,a,c,s){const o=tempVec3a,i=tempVec3b;if(!C3.Gfx.Unproject(t,e,0,n,a,c,o))return!1;if(!C3.Gfx.Unproject(t,e,1,n,a,c,i))return!1;const l=tempVec3b,f=(vec3.subtract(l,i,o),tempVec3c),P=(vec3.set(f,0,0,1),-r),h=vec3.dot(f,l);let m=0;if(0===h){const p=vec3.dot(f,o)+P;if(0!==p)return!1}else if((m=-(vec3.dot(o,f)+P)/h)<0)return!1;return vec3.scaleAndAdd(s,o,l,m),!0}};class Plane{constructor(){this.x=NaN,this.y=NaN,this.z=NaN,this.w=NaN,this.xF=NaN,this.yF=NaN,this.zF=NaN}set(t,e,r,n){this.x=t,this.y=e,this.z=r,this.w=n,this.xF=0<t?1:0,this.yF=0<e?1:0,this.zF=0<r?1:0}}C3.Gfx.ViewFrustum=class{constructor(){this._leftP=new Plane,this._topP=new Plane,this._rightP=new Plane,this._bottomP=new Plane,this._nearP=new Plane,this._farP=new Plane}CalculatePlanes(t,e){const r=unitViewport;C3.Gfx.Unproject(0,1,0,t,e,r,neartl),C3.Gfx.Unproject(1,1,0,t,e,r,neartr),C3.Gfx.Unproject(0,0,0,t,e,r,nearbl),C3.Gfx.Unproject(1,0,0,t,e,r,nearbr),C3.Gfx.Unproject(0,1,1,t,e,r,fartl),C3.Gfx.Unproject(1,1,1,t,e,r,fartr),C3.Gfx.Unproject(0,0,1,t,e,r,farbl),C3.Gfx.Unproject(1,0,1,t,e,r,farbr),PlaneFromPoints(nearbl,neartl,fartl,this._leftP),PlaneFromPoints(neartl,neartr,fartr,this._topP),PlaneFromPoints(neartr,nearbr,farbr,this._rightP),PlaneFromPoints(nearbr,nearbl,farbl,this._bottomP),PlaneFromPoints(farbl,fartl,fartr,this._farP),PlaneFromPoints(nearbr,neartr,neartl,this._nearP)}ContainsAABB(t,e,r,n,a,c){return IsInFrontOfPlane(t,e,r,n,a,c,this._leftP)&&IsInFrontOfPlane(t,e,r,n,a,c,this._topP)&&IsInFrontOfPlane(t,e,r,n,a,c,this._rightP)&&IsInFrontOfPlane(t,e,r,n,a,c,this._bottomP)&&IsInFrontOfPlane(t,e,r,n,a,c,this._nearP)&&IsInFrontOfPlane(t,e,r,n,a,c,this._farP)}IsBehindNearPlane(t,e,r){return!IsPointInFrontOfPlane(t,e,r,this._nearP)}}; } // ../lib/gfx/rendererBase.js { const C3=self.C3,glMatrix=self.glMatrix,vec3=glMatrix.vec3,vec4=glMatrix.vec4,mat4=glMatrix.mat4,tempMat4=mat4.create(),tmpVec3a=vec3.fromValues(0,0,0),tmpVec3b=vec3.fromValues(0,0,0),tmpVec3c=vec3.fromValues(0,0,0),defaultUpVector=vec3.fromValues(0,1,0),tmpVec4=vec4.fromValues(0,0,0,0),tmpQuad=new C3.Quad,tmpRect=new C3.Rect,defaultTexCoordsQuad=new C3.Quad(0,0,1,0,1,1,0,1),DEFAULT_RENDERERBASE_OPTS={nearZ:1,farZ:1e4},matWebGLtoWebGPU=mat4.fromValues(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1);C3.Gfx.RendererBase=class{constructor(e){e=Object.assign({},DEFAULT_RENDERERBASE_OPTS,e),this._width=0,this._height=0,this._fovY=C3.toRadians(45),this._tan_fovY_2=Math.tan(this._fovY/2),this._matP=mat4.create(),this._matMV=mat4.create(),this._zAxisScale=!1,this._nearZ=e.nearZ,this._farZ=e.farZ,this._allShaderPrograms=[],this._shaderProgramsByName=new Map,this._spTextureFill=null,this._spPoints=null,this._spTilemapFill=null,this._spTileRandomization=null,this._spColorFill=null,this._spLinearGradientFill=null,this._spPenumbraFill=null,this._spHardEllipseFill=null,this._spHardEllipseOutline=null,this._spSmoothEllipseFill=null,this._spSmoothEllipseOutline=null,this._spSmoothLineFill=null,this._stateGroups=new Map,this._currentStateGroup=null,this._blendModeTable=[],this._namedBlendModeMap=new Map,this._baseZ=0,this._currentZ=0,this._lineWidth=1,this._lineWidthStack=[this._lineWidth],this._lineCap=1,this._lineCapStack=[this._lineCap],this._lineOffset=.5,this._lineOffsetStack=[this._lineOffset],this._frameNumber=0,this._enableMipmaps=!0,this._hasMajorPerformanceCaveat=!1}FillIndexBufferData(e){let t=0,i=e.length,a=0;for(;t<i;)e[t++]=a,e[t++]=a+1,e[t++]=a+2,e[t++]=a,e[t++]=a+2,e[t++]=a+3,a+=4}_ClearState(){this._baseZ=0,this._currentZ=0,this._spTextureFill=null,this._spPoints=null,this._spTilemapFill=null,this._spTileRandomization=null,this._spColorFill=null,this._spLinearGradientFill=null,this._spPenumbraFill=null,this._spHardEllipseFill=null,this._spHardEllipseOutline=null,this._spSmoothEllipseFill=null,this._spSmoothEllipseOutline=null,this._spSmoothLineFill=null,this._ClearAllShaderPrograms()}InitState(){this._ClearState(),this._currentStateGroup=null}OnDeviceOrContextLost(){for(const e of this._allShaderPrograms)e.Release();this._ClearState()}GetWidth(){return this._width}GetHeight(){return this._height}GetDefaultCameraZ(e){return this.IsZAxisScaleNormalized()?100:e/(2*this._GetTanFovYDiv2())}GetZAxisScaleFactor(e){if(this.IsZAxisScaleNormalized()){const t=e/(2*this._GetTanFovYDiv2());return t/this.GetDefaultCameraZ(e)}return 1}SetNearZ(e){this._nearZ=e}GetNearZ(){return this._nearZ}SetFarZ(e){this._farZ=e}GetFarZ(){return this._farZ}SetFovY(e){this._fovY=e,this._tan_fovY_2=Math.tan(this._fovY/2)}GetFovY(){return this._fovY}_GetTanFovYDiv2(){return this._tan_fovY_2}SetZAxisScaleNormalized(){this._zAxisScale=!1}SetZAxisScaleRegular(){this._zAxisScale=!0}IsZAxisScaleNormalized(){return!this._zAxisScale}IsZAxisScaleRegular(){return this._zAxisScale}CalculatePerspectiveMatrix(e,t,i=.5,a=.5){const s=this.GetNearZ(),r=this.GetFarZ(),l=this.GetFovY();if(.5===i&&.5===a)this.IsWebGPU()?mat4.perspectiveZO(e,l,t,s,r):mat4.perspective(e,l,t,s,r);else{const n=2*(i=1-i)-2,h=2*i,o=2*a-2,p=2*a,_=this._GetTanFovYDiv2()*s,c=_*t;mat4.frustum(e,n*c,h*c,o*_,p*_,s,r),this.IsWebGPU()&&mat4.mul(e,matWebGLtoWebGPU,e)}}CalculateOrthographicMatrix(e,t,i,a=1){const s=self.devicePixelRatio,r=2*this.GetDefaultCameraZ(i)*s*this._GetTanFovYDiv2()/i,l=t*r/(2*s*a),n=i*r/(2*s*a),h=-l,o=l,p=-n,_=n;this.IsWebGPU()?mat4.orthoZO(e,h,o,p,_,this.GetNearZ(),this.GetFarZ()):mat4.ortho(e,h,o,p,_,this.GetNearZ(),this.GetFarZ())}CalculateLookAtModelView(e,t,i,a,s,r=1){let l=1;this.IsZAxisScaleNormalized()&&(l=200*this._GetTanFovYDiv2()/s);const n=tmpVec3c,h=(vec3.set(n,l,-l,1),tmpVec3a),o=tmpVec3b;vec3.multiply(h,t,n),vec3.multiply(o,i,n),mat4.lookAt(e,h,o,a||defaultUpVector),n[2]=r,mat4.scale(e,e,n)}CalculateLookAtModelView2(e,t,i,a,s,r,l,n){return vec3.set(tmpVec3a,e,t,i),vec3.set(tmpVec3b,a,s,r),this.CalculateLookAtModelView(tempMat4,tmpVec3a,tmpVec3b,defaultUpVector,l,n),tempMat4}_AddShaderProgram(e){this._allShaderPrograms.push(e),this._shaderProgramsByName.set(e.GetName(),e)}_RemoveShaderProgram(e){const t=this._allShaderPrograms.indexOf(e);-1!==t&&this._allShaderPrograms.splice(t,1),this._shaderProgramsByName.delete(e.GetName())}_ClearAllShaderPrograms(){C3.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,i,a){const s=C3.Gfx.StateGroup.MakeKey(e,t,i,a);let r=this._stateGroups.get(s);return r||(r=C3.New(C3.Gfx.StateGroup,this,e,t,i,a),this._stateGroups.set(s,r)),r.AddRef(),r}ReleaseStateGroup(e){e.DecRef(),0===e._GetRefCount()&&(this._currentStateGroup===e&&(this._currentStateGroup=null),this._stateGroups.delete(e.GetKey()),e.Release())}_InitBlendModeData(e){C3.clearArray(this._blendModeTable),this._namedBlendModeMap.clear();let t=0;for(const i of e){const a=i[0],s=i[1],r=i[2];this._blendModeTable.push([s,r]),this._namedBlendModeMap.set(a,{number:t,srcBlend:s,destBlend:r}),t++}}_GetBlendByIndex(e){return this._blendModeTable[e]}GetSrcBlendByIndex(e){return this._GetBlendByIndex(e)[0]}GetDestBlendByIndex(e){return this._GetBlendByIndex(e)[1]}GetNamedBlend(e){const t=this._namedBlendModeMap.get(e);if(void 0===t)throw new Error("invalid blend name");return t}NamedBlendToNumber(e){const t=this._namedBlendModeMap.get(e);if(void 0===t)throw new Error("invalid blend name");return t.number}SetBaseZ(e){this._baseZ=e}GetBaseZ(){return this._baseZ}SetCurrentZ(e){this._currentZ=e,this._currentStateGroup=null}GetCurrentZ(){return this._currentZ}Line(e,t,i,a){const s=C3.angleTo(e,t,i,a),r=Math.sin(s),l=Math.cos(s),n=.5*this._lineWidth,h=r*n,o=l*n,p=this._lineCap;2===p?this.LinePreCalc_LineCap2(e,t,0,i,a,0,h,o):1===p?this.LinePreCalc_LineCap1(e,t,0,i,a,0,h,o):this.LinePreCalc_LineCap0(e,t,0,i,a,0,h,o)}Line3D(e,t,i,a,s,r){const l=C3.angleTo(e,t,a,s),n=Math.sin(l),h=Math.cos(l),o=.5*this._lineWidth,p=n*o,_=h*o,c=this._lineCap;2===c?this.LinePreCalc_LineCap2(e,t,i,a,s,r,p,_):1===c?this.LinePreCalc_LineCap1(e,t,i,a,s,r,p,_):this.LinePreCalc_LineCap0(e,t,i,a,s,r,p,_)}LinePreCalc_LineCap2(e,t,i,a,s,r,l,n){const h=this._lineOffset,o=e+h-n,p=t+h-l,_=a+h+n,c=s+h+l,u=2*n,d=2*l,C=o+l,m=p-n,L=o-l+u,f=p+n+d,g=_+l,S=c-n,P=_-l-u,G=c+n-d;this.Quad3D2(C,m,i,g,S,r,P,G,r,L,f,i,defaultTexCoordsQuad)}LinePreCalc_LineCap1(e,t,i,a,s,r,l,n){const h=this._lineOffset,o=e+h-n,p=t+h-l,_=a+h+n,c=s+h+l,u=o+l,d=p-n,C=o-l,m=p+n,L=_+l,f=c-n,g=_-l,S=c+n;this.Quad3D2(u,d,i,L,f,r,g,S,r,C,m,i,defaultTexCoordsQuad)}LinePreCalc_LineCap0(e,t,i,a,s,r,l,n){const h=this._lineOffset,o=e+h,p=t+h,_=a+h,c=s+h,u=o+l,d=p-n,C=o-l,m=p+n,L=_+l,f=c-n,g=_-l,S=c+n;this.Quad3D2(u,d,i,L,f,r,g,S,r,C,m,i,defaultTexCoordsQuad)}TexturedLine(e,t,i,a,s,r){const l=C3.angleTo(e,t,i,a),n=Math.sin(l),h=Math.cos(l),o=.5*this._lineWidth,p=n*o,_=h*o,c=this._lineCap;2===c?this.TexturedLinePreCalc_LineCap2(e,t,i,a,p,_,s,r):1===c?this.TexturedLinePreCalc_LineCap1(e,t,i,a,p,_,s,r):this.TexturedLinePreCalc_LineCap0(e,t,i,a,p,_,s,r)}TexturedLinePreCalc_LineCap2(e,t,i,a,s,r,l,n){const h=this._lineOffset,o=e+h-r,p=t+h-s,_=i+h+r,c=a+h+s,u=2*r,d=2*s,C=o+s,m=p-r,L=o-s+u,f=p+r+d,g=_+s,S=c-r,P=_-s-u,G=c+r-d;tmpQuad.set(C,m,g,S,P,G,L,f),tmpRect.set(l,0,n,0),this.Quad3(tmpQuad,tmpRect)}TexturedLinePreCalc_LineCap1(e,t,i,a,s,r,l,n){const h=this._lineOffset,o=e+h-r,p=t+h-s,_=i+h+r,c=a+h+s,u=o+s,d=p-r,C=o-s,m=p+r,L=_+s,f=c-r,g=_-s,S=c+r;tmpQuad.set(u,d,L,f,g,S,C,m),tmpRect.set(l,0,n,0),this.Quad3(tmpQuad,tmpRect)}TexturedLinePreCalc_LineCap0(e,t,i,a,s,r,l,n){const h=this._lineOffset,o=e+h,p=t+h,_=i+h,c=a+h,u=o+s,d=p-r,C=o-s,m=p+r,L=_+s,f=c-r,g=_-s,S=c+r;tmpQuad.set(u,d,L,f,g,S,C,m),tmpRect.set(l,0,n,0),this.Quad3(tmpQuad,tmpRect)}LineRect(e,t,i,a){const s=.5*this._lineWidth,r=this._lineCap;2===r?this._LineRectPreCalc_LineCap2(e,t,i,a,s):1===r?this._LineRectPreCalc_LineCap1(e,t,i,a,s):this._LineRectPreCalc_LineCap0(e,t,i,a,s)}_LineRectPreCalc_LineCap2(e,t,i,a,s){this.LinePreCalc_LineCap2(e,t,0,i,t,0,0,s),this.LinePreCalc_LineCap2(i,t,0,i,a,0,s,0),this.LinePreCalc_LineCap2(i,a,0,e,a,0,0,-s),this.LinePreCalc_LineCap2(e,a,0,e,t,0,-s,0)}_LineRectPreCalc_LineCap1(e,t,i,a,s){this.LinePreCalc_LineCap1(e,t,0,i,t,0,0,s),this.LinePreCalc_LineCap1(i,t,0,i,a,0,s,0),this.LinePreCalc_LineCap1(i,a,0,e,a,0,0,-s),this.LinePreCalc_LineCap1(e,a,0,e,t,0,-s,0)}_LineRectPreCalc_LineCap0(e,t,i,a,s){this.LinePreCalc_LineCap0(e,t,0,i,t,0,0,s),this.LinePreCalc_LineCap0(i,t,0,i,a,0,s,0),this.LinePreCalc_LineCap0(i,a,0,e,a,0,0,-s),this.LinePreCalc_LineCap0(e,a,0,e,t,0,-s,0)}LineRect2(e){this.LineRect(e.getLeft(),e.getTop(),e.getRight(),e.getBottom())}LineQuad(e){const t=C3.angleTo(e.getTlx(),e.getTly(),e.getTrx(),e.getTry()),i=Math.sin(t),a=Math.cos(t),s=.5*this._lineWidth,r=i*s,l=a*s,n=this._lineCap;2===n?this._LineQuadPreCalc_LineCap2(e,r,l):1===n?this._LineQuadPreCalc_LineCap1(e,r,l):this._LineQuadPreCalc_LineCap0(e,r,l)}_LineQuadPreCalc_LineCap2(e,t,i){this.LinePreCalc_LineCap2(e.getTlx(),e.getTly(),0,e.getTrx(),e.getTry(),0,t,i),this.LinePreCalc_LineCap2(e.getTrx(),e.getTry(),0,e.getBrx(),e.getBry(),0,i,-t),this.LinePreCalc_LineCap2(e.getBrx(),e.getBry(),0,e.getBlx(),e.getBly(),0,-t,-i),this.LinePreCalc_LineCap2(e.getBlx(),e.getBly(),0,e.getTlx(),e.getTly(),0,-i,t)}_LineQuadPreCalc_LineCap1(e,t,i){this.LinePreCalc_LineCap1(e.getTlx(),e.getTly(),0,e.getTrx(),e.getTry(),0,t,i),this.LinePreCalc_LineCap1(e.getTrx(),e.getTry(),0,e.getBrx(),e.getBry(),0,i,-t),this.LinePreCalc_LineCap1(e.getBrx(),e.getBry(),0,e.getBlx(),e.getBly(),0,-t,-i),this.LinePreCalc_LineCap1(e.getBlx(),e.getBly(),0,e.getTlx(),e.getTly(),0,-i,t)}_LineQuadPreCalc_LineCap0(e,t,i){this.LinePreCalc_LineCap0(e.getTlx(),e.getTly(),0,e.getTrx(),e.getTry(),0,t,i),this.LinePreCalc_LineCap0(e.getTrx(),e.getTry(),0,e.getBrx(),e.getBry(),0,i,-t),this.LinePreCalc_LineCap0(e.getBrx(),e.getBry(),0,e.getBlx(),e.getBly(),0,-t,-i),this.LinePreCalc_LineCap0(e.getBlx(),e.getBly(),0,e.getTlx(),e.getTly(),0,-i,t)}SetLineWidth(e){this._lineWidth=e,this._lineWidthStack[this._lineWidthStack.length-1]=e}GetLineWidth(){return this._lineWidth}PushLineWidth(e){if(100<=this._lineWidthStack.length)throw new Error("pushed too many line widths - check push/pop pairs");this._lineWidthStack.push(e),this._lineWidth=e}PopLineWidth(){if(this._lineWidthStack.length<=1)throw new Error("cannot pop last line width - check push/pop pairs");this._lineWidthStack.pop(),this._lineWidth=this._lineWidthStack.at(-1)}SetLineCapButt(){this._lineCap=0,this._lineCapStack[this._lineCapStack.length-1]=0}SetLineCapSquare(){this._lineCap=1,this._lineCapStack[this._lineCapStack.length-1]=0}SetLineCapZag(){this._lineCap=2,this._lineCapStack[this._lineCapStack.length-1]=0}PushLineCap(e){if("butt"===e)this.PushLineCapButt();else if("square"===e)this.PushLineCapSquare();else{if("zag"!==e)throw new Error("invalid line cap");this.PushLineCapZag()}}PushLineCapButt(){if(100<=this._lineCapStack.length)throw new Error("pushed too many line caps - check push/pop pairs");this._lineCapStack.push(0),this._lineCap=0}PushLineCapSquare(){if(100<=this._lineCapStack.length)throw new Error("pushed too many line caps - check push/pop pairs");this._lineCapStack.push(1),this._lineCap=1}PushLineCapZag(){if(100<=this._lineCapStack.length)throw new Error("pushed too many line caps - check push/pop pairs");this._lineCapStack.push(2),this._lineCap=2}PopLineCap(){if(this._lineCapStack.length<=1)throw new Error("cannot pop last line cap - check push/pop pairs");this._lineCapStack.pop(),this._lineCap=this._lineCapStack.at(-1)}SetLineOffset(e){this._lineOffset=e,this._lineOffsetStack[this._lineOffsetStack.length-1]=e}GetLineOffset(){return this._lineOffset}PushLineOffset(e){if(100<=this._lineOffsetStack.length)throw new Error("pushed too many line offsets - check push/pop pairs");this._lineOffsetStack.push(e),this._lineOffset=e}PopLineOffset(){if(this._lineOffsetStack.length<=1)throw new Error("cannot pop last line offset - check push/pop pairs");this._lineOffsetStack.pop(),this._lineOffset=this._lineOffsetStack.at(-1)}ConvexPoly(t){const e=t.length/2;if(e<3)throw new Error("need at least 3 points");const i=e-2,a=i-1,s=t[0],r=t[1];for(let e=0;e<i;e+=2){const l=2*e,n=t[2+l],h=t[3+l],o=t[4+l],p=t[5+l];if(e===a)this.Quad2(s,r,n,h,o,p,o,p);else{const _=t[6+l],c=t[7+l];this.Quad2(s,r,n,h,o,p,_,c)}}}GetNumVertexComponents(){return 3}Finish(){this.EndBatch(!0),this._frameNumber++}GetFrameNumber(){return this._frameNumber}IncrementFrameNumber(){this._frameNumber++}SetMipmapsEnabled(e){this._enableMipmaps=!!e}AreMipmapsEnabled(){return this._enableMipmaps}SetHasMajorPerformanceCaveat(e){this._hasMajorPerformanceCaveat=!!e}HasMajorPerformanceCaveat(){return this._hasMajorPerformanceCaveat}IsWebGL(){return!1}IsWebGPU(){return!1}GetEstimatedBackBufferMemoryUsage(){}GetEstimatedRenderBufferMemoryUsage(){}GetEstimatedTextureMemoryUsage(){}GetEstimatedTotalMemoryUsage(){return this.GetEstimatedBackBufferMemoryUsage()+this.GetEstimatedRenderBufferMemoryUsage()+this.GetEstimatedTextureMemoryUsage()}CreateRendererText(){return C3.New(C3.Gfx.RendererText,this)}}; } // ../lib/gfx/shaderProgramBase.js { const C3=self.C3;C3.Gfx.ShaderProgramBase=class{constructor(e,t){this._name=t.name,this._renderer=e,this._extendBoxHorizontal=t.extendBoxHorizontal||0,this._extendBoxVertical=t.extendBoxVertical||0,this._crossSampling=!!t.crossSampling,this._mustPreDraw=!!t.mustPreDraw,this._preservesOpaqueness=!!t.preservesOpaqueness,this._supports3dDirectRendering=!!t.supports3dDirectRendering,this._animated=!!t.animated,this._blendsBackground=!!t.blendsBackground,this._usesDepth=!!t.usesDepth,this._usesAnySrcRectOrPixelSize=!1,this._needsPostDrawOrExtendBox=this._crossSampling||this._blendsBackground||0!==this._extendBoxHorizontal||0!==this._extendBoxVertical}Release(){this._renderer=null}GetRenderer(){return this._renderer}GetName(){return this._name}ExtendsBox(){return 0!==this._extendBoxHorizontal||0!==this._extendBoxVertical}GetBoxExtendHorizontal(){return this._extendBoxHorizontal}GetBoxExtendVertical(){return this._extendBoxVertical}UsesCrossSampling(){return this._crossSampling}MustPreDraw(){return this._mustPreDraw}PreservesOpaqueness(){return this._preservesOpaqueness}Supports3DDirectRendering(){return this._supports3dDirectRendering}IsAnimated(){return this._animated}BlendsBackground(){return this._blendsBackground}UsesDepth(){return this._usesDepth}UsesAnySrcRectOrPixelSize(){return this._usesAnySrcRectOrPixelSize}NeedsPostDrawOrExtendsBox(){return this._needsPostDrawOrExtendBox}UsesIsSrcTexRotated(){return!1}}; } // ../lib/gfx/stateGroup.js { const C3=self.C3;C3.Gfx.StateGroup=class{constructor(e,r,t,s,o){this._renderer=e,this._refCount=0,this._shaderProgram=null,this._shaderProgramName="",this._blendMode=t,this._color=C3.New(C3.Color),this._color.set(s),this._zElevation=o,"string"==typeof r?this._shaderProgramName=r:(this._shaderProgram=r,this._shaderProgramName=this._shaderProgram.GetName())}Release(){if(0<this._refCount)throw new Error("releasing state group still in use");this._renderer=null,this._shaderProgram=null,this._shaderProgramName=""}Apply(){const e=this._renderer;e.SetProgram(this._shaderProgram),e.SetBlendMode(this._blendMode),e.SetColor(this._color),e.SetCurrentZ(this._zElevation),e._SetCurrentStateGroup(this)}GetKey(){return C3.Gfx.StateGroup.MakeKey(this._shaderProgramName,this._blendMode,this._color,this._zElevation)}AddRef(){++this._refCount}DecRef(){--this._refCount}_GetRefCount(){return this._refCount}OnContextLost(){this._shaderProgram=null}OnContextRestored(e){if(this._shaderProgram=e.GetShaderProgramByName(this._shaderProgramName),!this._shaderProgram)throw new Error("failed to restore shader program")}static MakeKey(e,r,t,s){const o="string"==typeof e?e:e.GetName();return o+","+r+","+t.getR()+","+t.getG()+","+t.getB()+","+t.getA()+","+s}}; } // ../lib/gfx/mesh.js { const C3=self.C3,tempQuadTex=C3.New(C3.Quad);function interpolateQuad(t,e,s){const i=s.getTlx(),n=s.getTly(),o=s.getTrx()-i,h=s.getTry()-n,r=s.getBlx()-i,a=s.getBly()-n,l=o*t,_=h*t,G=r*e,u=a*e;return[i+l+G,n+_+u]}C3.Gfx.MeshPoint=class{constructor(t,e,s){this._mesh=t,this._col=e,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(t,e,s,i){this._x=t,this._y=e,this._u=s,this._v=i}GetX(){return this._x}SetX(t){this._x!==t&&(this._x=t,this._mesh._SetPointsChanged())}GetY(){return this._y}SetY(t){this._y!==t&&(this._y=t,this._mesh._SetPointsChanged())}GetZElevation(){return this._zElevation}SetZElevation(t){this._zElevation!==t&&(this._zElevation=Math.max(t,0),this._mesh._SetPointsChanged())}GetU(){return this._u}SetU(t){this._u=t}GetV(){return this._v}SetV(t){this._v=t}_Interpolate_TexRect(t,e,s){[this._x,this._y]=interpolateQuad(t._x,t._y,e),this._zElevation=t._zElevation,this._u=C3.lerp(s.getLeft(),s.getRight(),t._u),this._v=C3.lerp(s.getTop(),s.getBottom(),t._v)}_Interpolate_TexQuad(t,e,s){[this._x,this._y]=interpolateQuad(t._x,t._y,e),this._zElevation=t._zElevation,[this._u,this._v]=interpolateQuad(t._u,t._v,s)}SaveToJson(){return{"x":this.GetX(),"y":this.GetY(),"z":this.GetZElevation(),"u":this.GetU(),"v":this.GetV()}}LoadFromJson(t){this.SetX(t["x"]),this.SetY(t["y"]),t.hasOwnProperty("z")&&this.SetZElevation(t["z"]),this.SetU(t["u"]),this.SetV(t["v"])}GetMesh(){return this._mesh}GetColumn(){return this._col}GetRow(){return this._row}},C3.Gfx.Mesh=class{constructor(s,t,e){if(s<2||t<2)throw new Error("invalid mesh size");this._hsize=s,this._vsize=t,this._owner=e||null,this._pts=[],this._minX=0,this._minY=0,this._maxX=1,this._maxY=1,this._maxZ=0,this._pointsChanged=!1;const i=s-1,n=t-1;for(let e=0;e<t;++e){const o=[];for(let t=0;t<s;++t){const h=C3.New(C3.Gfx.MeshPoint,this,t,e),r=t/i,a=e/n;h._Init(r,a,r,a),o.push(h)}this._pts.push(o)}}Release(){C3.clearArray(this._pts)}GetHSize(){return this._hsize}GetVSize(){return this._vsize}GetOwner(){return this._owner}_GetPoints(){return this._pts}_SetPointsChanged(){this._pointsChanged=!0}_MaybeComputeBounds(){if(this._pointsChanged){let t=1/0,e=1/0,s=-1/0,i=-1/0,n=0;for(const o of this._pts)for(const h of o){const r=h.GetX(),a=h.GetY();t=Math.min(t,r),e=Math.min(e,a),s=Math.max(s,r),i=Math.max(i,a),n=Math.max(n,h.GetZElevation())}this._minX=t,this._minY=e,this._maxX=s,this._maxY=i,this._maxZ=n,this._pointsChanged=!1}}GetMinX(){return this._MaybeComputeBounds(),this._minX}GetMinY(){return this._MaybeComputeBounds(),this._minY}GetMaxX(){return this._MaybeComputeBounds(),this._maxX}GetMaxY(){return this._MaybeComputeBounds(),this._maxY}GetMaxZ(){return this._MaybeComputeBounds(),this._maxZ}HasAnyZElevation(){return 0<this.GetMaxZ()}GetMeshPointAt(t,e){return t=Math.floor(t),e=Math.floor(e),t<0||t>=this._hsize||e<0||e>=this._vsize?null:this._pts[e][t]}CalculateTransformedMesh(t,s,i){const n=i instanceof C3.Rect;if(t.GetHSize()!==this.GetHSize()||t.GetVSize()!==this.GetVSize())throw new Error("source mesh wrong size");const o=t._pts,h=this._pts;for(let t=0,e=h.length;t<e;++t){const r=o[t],a=h[t];for(let t=0,e=a.length;t<e;++t){const l=r[t],_=a[t];n?_._Interpolate_TexRect(l,s,i):_._Interpolate_TexQuad(l,s,i)}}}Draw(n){const o=this._pts;let h=o[0];for(let t=1,e=o.length;t<e;++t){const r=o[t];let s=h[0],i=r[0];for(let t=1,e=r.length;t<e;++t){const a=h[t],l=r[t];tempQuadTex.set(s.GetU(),s.GetV(),a.GetU(),a.GetV(),l.GetU(),l.GetV(),i.GetU(),i.GetV()),n.Quad3D2(s.GetX(),s.GetY(),s.GetZElevation(),a.GetX(),a.GetY(),a.GetZElevation(),l.GetX(),l.GetY(),l.GetZElevation(),i.GetX(),i.GetY(),i.GetZElevation(),tempQuadTex),s=a,i=l}h=r}}Outline(h,r){r=r||((t,e,s)=>[t,e,s]);const t=this._pts;let a=t[0];for(let n=1,o=t.length;n<o;++n){const l=t[n];let s=a[0],i=l[0];for(let t=1,e=l.length;t<e;++t){const _=a[t],G=l[t],[u,c,m]=r(s.GetX(),s.GetY(),s.GetZElevation()),[p,C,f]=r(_.GetX(),_.GetY(),_.GetZElevation()),[x,v,M]=r(G.GetX(),G.GetY(),G.GetZElevation()),[g,y,d]=r(i.GetX(),i.GetY(),i.GetZElevation());h.Line3D(u,c,m,p,C,f),h.Line3D(u,c,m,x,v,M),h.Line3D(u,c,m,g,y,d),t===e-1&&h.Line3D(p,C,f,x,v,M),n===o-1&&h.Line3D(g,y,d,x,v,M),s=_,i=G}a=l}}InsertPolyMeshVertices(t){const s=.001,i=.99999999,n=t.pointsArr(),o=[],h=this.GetHSize()-1,r=this.GetVSize()-1,a=1/h,l=1/r,_=h-1,G=r-1;let u=n[0],c=n[1],m=C3.clamp(Math.floor(u*h),0,_),p=C3.clamp(Math.floor(c*r),0,G),C=!0,f=0,x=0,v=0;let M=-1;const g=()=>{u=C3.clamp(C3.lerp(u,f,v),0,1),c=C3.clamp(C3.lerp(c,x,v),0,1),o.push(u,c)};for(let t=0,e=n.length;t<e;t+=2){u=n[t],c=n[t+1],o.push(u,c),m=C3.clamp(Math.floor(u*h),0,_),p=C3.clamp(Math.floor(c*r),0,G);const y=(t+2)%e;for(f=n[y],x=n[1+y],M=-1;;){if(1e6<o.length)throw new Error("Too many mesh poly points");const d=m*a,z=p*l,E=(m+1)*a,S=(p+1)*l;if(C=C3.isPointInTriangleInclusive(u,c,d,z,E,z,E,S),0!==M&&0<=(v=C3.rayIntersectExtended(u,c,f,x,d,z,E,S,-s))&&v<=i)g(),C=!C,M=0;else if(0<p&&2!==M&&0<=(v=C3.rayIntersectExtended(u,c,f,x,d,z,E,z,s))&&v<=i)g(),p--,C=!1,M=4;else if(m<_&&3!==M&&0<=(v=C3.rayIntersectExtended(u,c,f,x,E,z,E,S,s))&&v<=i)g(),m++,C=!1,M=1;else if(0<m&&1!==M&&0<=(v=C3.rayIntersectExtended(u,c,f,x,d,z,d,S,s))&&v<=i)g(),m--,C=!0,M=3;else{if(!(p<G&&4!==M&&0<=(v=C3.rayIntersectExtended(u,c,f,x,d,S,E,S,s))&&v<=i))break;g(),p++,C=!0,M=2}}}return C3.New(C3.CollisionPoly,o)}TransformCollisionPoly(t,e){const s=this._TransformPolyPoints(t);this._SimplifyPoly(s),e.setPoints(s)}_TransformPolyPoints(t){const s=[],i=t.pointsArr();for(let t=0,e=i.length;t<e;t+=2){const n=i[t],o=i[t+1],[h,r]=this.TransformPoint(n,o);s.push(h,r)}return s}TransformPoint(t,e){const s=this.GetHSize()-1,i=this.GetVSize()-1,n=1/s,o=1/i,h=C3.clamp(Math.floor(t*s),0,s-1),r=C3.clamp(Math.floor(e*i),0,i-1),a=h*n,l=r*o,_=(h+1)*n,G=(r+1)*o,u=this.GetMeshPointAt(h,r),c=this.GetMeshPointAt(h+1,r+1),m=C3.isPointInTriangleInclusive(t,e,a,l,_,l,_,G),p=m?a+n:a,C=m?l:l+o,f=this.GetMeshPointAt(h+(m?1:0),r+(m?0:1)),[x,v,M]=C3.triangleCartesianToBarycentric(t,e,a,l,p,C,_,G);return C3.triangleBarycentricToCartesian3d(x,v,M,u.GetX(),u.GetY(),u.GetZElevation(),f.GetX(),f.GetY(),f.GetZElevation(),c.GetX(),c.GetY(),c.GetZElevation())}_SimplifyPoly(s){const i=[];let n=s[0],o=s[1],h=n-s.at(-2),r=o-s.at(-1);for(let t=0,e=s.length;t<e;t+=2){const a=(t+2)%e,l=s[a],_=s[1+a],G=l-n,u=_-o,c=Math.abs(G)<1e-7&&Math.abs(h)<1e-7&&Math.sign(u)===Math.sign(r),m=Math.abs(u)<1e-7&&Math.abs(r)<1e-7&&Math.sign(G)===Math.sign(h);(!c&&!m&&.001<Math.abs(G/h-u/r)||0==G&&0==u)&&i.push(n,o),n=l,o=_,h=G,r=u}6<=i.length&&i.length<s.length&&C3.shallowAssignArray(s,i)}SaveToJson(){return{"cols":this.GetHSize(),"rows":this.GetVSize(),"points":this._pts.map(t=>t.map(t=>t.SaveToJson()))}}LoadFromJson(t){const s=this.GetHSize(),i=this.GetVSize();if(t["cols"]!==s||t["rows"]!==i)throw new Error("mesh data wrong size");const n=t["points"];for(let e=0;e<i;++e){const o=n[e];for(let t=0;t<s;++t){const h=this.GetMeshPointAt(t,e);h.LoadFromJson(o[t])}}}}; } // ../lib/gfx/webgl/texture.js { const C3=self.C3,VALID_PIXEL_FORMATS=new Set(["rgba8","rgb8","rgba4","rgb5_a1","rgb565"]),VALID_SAMPLINGS=new Set(["nearest","bilinear","trilinear"]),VALID_MIPMAP_QUALITIES=new Set(["default","low","high"]),VALID_WRAP_MODES=new Set(["clamp-to-edge","repeat","mirror-repeat"]);function GetFormatSpecifiers(e,t){let i,r,a,s;switch(e){case"rgba8":i=t.RGBA8,r=t.RGBA,a=t.RGBA,s=t.UNSIGNED_BYTE;break;case"rgb8":i=t.RGB8,r=t.RGB,a=t.RGB,s=t.UNSIGNED_BYTE;break;case"rgba4":i=t.RGBA4,r=t.RGBA,a=t.RGBA,s=t.UNSIGNED_SHORT_4_4_4_4;break;case"rgb5_a1":i=t.RGB5_A1,r=t.RGBA,a=t.RGBA,s=t.UNSIGNED_SHORT_5_5_5_1;break;case"rgb565":i=t.RGB565,r=t.RGB,a=t.RGB,s=t.UNSIGNED_SHORT_5_6_5;break;default:throw new Error("invalid pixel format")}return{sizedinternalformat:i,internalformat:r,format:a,type:s}}const CREATEFROM_DEFAULT_OPTIONS={wrapX:"clamp-to-edge",wrapY:"clamp-to-edge",sampling:"trilinear",anisotropy:0,pixelFormat:"rgba8",mipMap:!0,mipMapQuality:"default",premultiplyAlpha:!0,isSvg:!1,width:-1,height:-1},UPDATE_DEFAULT_OPTIONS={premultiplyAlpha:!0,flipY:!1},allTextures=new Set;C3.Gfx.WebGLRendererTexture=class{constructor(e){this._renderer=e,this._texture=null,this._width=0,this._height=0,this._isStatic=!0,this._wrapX="clamp-to-edge",this._wrapY="clamp-to-edge",this._sampling="trilinear",this._anisotropy=0,this._pixelFormat="rgba8",this._isMipMapped=!1,this._mipMapQuality="default",this._refCount=0}_CreateStatic(t,e){if(!("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas||t instanceof ImageData||t instanceof ArrayBuffer||null===t))throw new Error("invalid texture source");if(e=Object.assign({},CREATEFROM_DEFAULT_OPTIONS,e),this._texture)throw new Error("already created texture");if(this._wrapX=e.wrapX,this._wrapY=e.wrapY,this._sampling=e.sampling,this._anisotropy=e.anisotropy,this._pixelFormat=e.pixelFormat,this._isMipMapped=!!e.mipMap&&this._renderer.AreMipmapsEnabled(),this._mipMapQuality=e.mipMapQuality,!VALID_WRAP_MODES.has(this._wrapX)||!VALID_WRAP_MODES.has(this._wrapY))throw new Error("invalid wrap mode");if(!VALID_SAMPLINGS.has(this._sampling))throw new Error("invalid sampling");if(!VALID_PIXEL_FORMATS.has(this._pixelFormat))throw new Error("invalid pixel format");if(!VALID_MIPMAP_QUALITIES.has(this._mipMapQuality))throw new Error("invalid mipmap quality");if(this._isStatic=!0,t instanceof ArrayBuffer||null===t||e.isSvg){if(this._width=e.width,this._height=e.height,t instanceof ArrayBuffer&&t.byteLength!==this._width*this._height*4)throw new Error("ArrayBuffer wrong size")}else this._width=t.width,this._height=t.height;if(this._width<=0||this._height<=0)throw new Error("invalid texture data size");if(e.isSvg){const n=C3.CreateCanvas(this._width,this._height),_=n.getContext("2d");_.drawImage(t,0,0,this._width,this._height),t=n}const i=C3.isPOT(this._width)&&C3.isPOT(this._height),r=this._renderer.GetMaxTextureSize();if(this._width>r||this._height>r)throw new Error("texture data exceeds maximum texture size");const a=this._renderer.GetContext(),s=this._renderer.GetWebGLVersionNumber(),h=(this._texture=a.createTexture(),a.bindTexture(a.TEXTURE_2D,this._texture),a.pixelStorei(a["UNPACK_PREMULTIPLY_ALPHA_WEBGL"],e.premultiplyAlpha),a.pixelStorei(a["UNPACK_FLIP_Y_WEBGL"],!1),GetFormatSpecifiers(this._pixelFormat,a));if(this._renderer.SupportsNPOTTextures()||i||!this._IsTiled())if(2<=s){let e;e=this._isMipMapped?Math.floor(Math.log2(Math.max(this._width,this._height))+1):1,a.texStorage2D(a.TEXTURE_2D,e,h.sizedinternalformat,this._width,this._height),t instanceof ArrayBuffer?a.texSubImage2D(a.TEXTURE_2D,0,0,0,this._width,this._height,h.format,h.type,new Uint8Array(t)):null!==t&&a.texSubImage2D(a.TEXTURE_2D,0,0,0,h.format,h.type,t)}else t instanceof ArrayBuffer?a.texImage2D(a.TEXTURE_2D,0,h.internalformat,this._width,this._height,0,h.format,h.type,new Uint8Array(t)):null===t?a.texImage2D(a.TEXTURE_2D,0,h.internalformat,this._width,this._height,0,h.format,h.type,null):a.texImage2D(a.TEXTURE_2D,0,h.internalformat,h.format,h.type,t);else{if(null===t)throw new Error("cannot pass null data when creating a NPOT tiled texture without NPOT support");if((t=t instanceof ArrayBuffer?new ImageData(new Uint8ClampedArray(t),this._width,this._height):t)instanceof ImageData){const l=C3.CreateCanvas(this._width,this._height),T=l.getContext("2d");T.putImageData(t,0,0),t=l}const o=C3.CreateCanvas(C3.nextHighestPowerOfTwo(this._width),C3.nextHighestPowerOfTwo(this._height)),p=o.getContext("2d");p.imageSmoothingEnabled="nearest"!==this._sampling,p.drawImage(t,0,0,this._width,this._height,0,0,o.width,o.height),a.texImage2D(a.TEXTURE_2D,0,h.internalformat,h.format,h.type,o)}null!==t&&this._SetTextureParameters(a),a.bindTexture(a.TEXTURE_2D,null),this._renderer._ResetLastTexture(),this._refCount=1,allTextures.add(this)}_CreateDynamic(e,t,i){if(i=Object.assign({},CREATEFROM_DEFAULT_OPTIONS,i),this._texture)throw new Error("already created texture");if(this._wrapX=i.wrapX,this._wrapY=i.wrapY,this._sampling=i.sampling,this._pixelFormat=i.pixelFormat,this._isMipMapped=!!i.mipMap&&this._renderer.AreMipmapsEnabled(),this._mipMapQuality=i.mipMapQuality,!VALID_WRAP_MODES.has(this._wrapX)||!VALID_WRAP_MODES.has(this._wrapY))throw new Error("invalid wrap mode");if(!VALID_SAMPLINGS.has(this._sampling))throw new Error("invalid sampling");if(!VALID_PIXEL_FORMATS.has(this._pixelFormat))throw new Error("invalid pixel format");if(!VALID_MIPMAP_QUALITIES.has(this._mipMapQuality))throw new Error("invalid mipmap quality");this._isStatic=!1,this._width=Math.floor(e),this._height=Math.floor(t);const r=C3.isPOT(this._width)&&C3.isPOT(this._height),a=this._renderer.GetMaxTextureSize();if(this._width<=0||this._height<=0)throw new Error("invalid texture size");if(this._width>a||this._height>a)throw new Error("texture exceeds maximum texture size");if(!this._renderer.SupportsNPOTTextures()&&this._IsTiled()&&!r)throw new Error("non-power-of-two tiled textures not supported");const s=this._renderer.GetContext(),h=this._renderer.GetWebGLVersionNumber(),n=(this._texture=s.createTexture(),s.bindTexture(s.TEXTURE_2D,this._texture),s.pixelStorei(s["UNPACK_PREMULTIPLY_ALPHA_WEBGL"],i.premultiplyAlpha),s.pixelStorei(s["UNPACK_FLIP_Y_WEBGL"],!1),GetFormatSpecifiers(this._pixelFormat,s)),_=2<=h?n.sizedinternalformat:n.internalformat;s.texImage2D(s.TEXTURE_2D,0,_,this._width,this._height,0,n.format,n.type,null),this._SetTextureParameters(s),s.bindTexture(s.TEXTURE_2D,null),this._renderer._ResetLastTexture(),this._refCount=1,allTextures.add(this)}_GetMipMapHint(e){if("default"===this._mipMapQuality)return this._isStatic?e.NICEST:e.FASTEST;if("low"===this._mipMapQuality)return e.FASTEST;if("high"===this._mipMapQuality)return e.NICEST;throw new Error("invalid mipmap quality")}_IsTiled(){return"clamp-to-edge"!==this._wrapX||"clamp-to-edge"!==this._wrapY}_GetTextureWrapMode(e,t){if("clamp-to-edge"===t)return e.CLAMP_TO_EDGE;if("repeat"===t)return e.REPEAT;if("mirror-repeat"===t)return e.MIRRORED_REPEAT;throw new Error("invalid wrap mode")}_SetTextureParameters(e){const t=C3.isPOT(this._width)&&C3.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 r="trilinear"===this._sampling&&!this._renderer.HasMajorPerformanceCaveat();e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,r?e.LINEAR_MIPMAP_LINEAR:e.LINEAR_MIPMAP_NEAREST)}else e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),this._isMipMapped=!1;const i=this._renderer._GetAnisotropicExtension();i&&0<this._anisotropy&&"nearest"!==this._sampling&&e.texParameterf(e.TEXTURE_2D,i["TEXTURE_MAX_ANISOTROPY_EXT"],Math.min(this._anisotropy,this._renderer._GetMaxAnisotropy()))}_Update(e,t){if(!("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas||e instanceof ImageData))throw new Error("invalid texture source");if(!this._texture||this._refCount<=0)throw new Error("texture not created");if(this._isStatic)throw new Error("cannot update static texture");t=Object.assign({},UPDATE_DEFAULT_OPTIONS,t);const i=e.width||e.videoWidth,r=e.height||e.videoHeight,a=this._renderer.GetWebGLVersionNumber(),s=this._renderer.GetContext(),h=(s.bindTexture(s.TEXTURE_2D,this._texture),s.pixelStorei(s["UNPACK_PREMULTIPLY_ALPHA_WEBGL"],t.premultiplyAlpha),s.pixelStorei(s["UNPACK_FLIP_Y_WEBGL"],!!t.flipY),GetFormatSpecifiers(this._pixelFormat,s)),n=2<=a?h.sizedinternalformat:h.internalformat;try{if(this._width===i&&this._height===r){const _=C3.isPOT(this._width)&&C3.isPOT(this._height);s.texSubImage2D(s.TEXTURE_2D,0,0,0,h.format,h.type,e),(_||this._renderer.SupportsNPOTTextures())&&this._isMipMapped&&(s.hint(s.GENERATE_MIPMAP_HINT,this._GetMipMapHint(s)),s.generateMipmap(s.TEXTURE_2D))}else{this._width=i,this._height=r;const o=C3.isPOT(this._width)&&C3.isPOT(this._height);if(!this._renderer.SupportsNPOTTextures()&&this._IsTiled()&&!o)throw new Error("non-power-of-two tiled textures not supported");s.texImage2D(s.TEXTURE_2D,0,n,h.format,h.type,e),(o||this._renderer.SupportsNPOTTextures())&&this._isMipMapped&&(s.hint(s.GENERATE_MIPMAP_HINT,this._GetMipMapHint(s)),s.generateMipmap(s.TEXTURE_2D))}}catch(e){console.error("Error updating WebGL texture: ",e)}s.bindTexture(s.TEXTURE_2D,null),this._renderer._ResetLastTexture()}_Delete(){if(0<this._refCount)throw new Error("texture still has references");if(!this._texture)throw new Error("already deleted texture");allTextures.delete(this);const e=this._renderer.GetContext();e.deleteTexture(this._texture),this._texture=null}IsValid(){return!!this._texture}_GetTexture(){return this._texture}GetRenderer(){return this._renderer}AddReference(){this._refCount++}SubtractReference(){if(this._refCount<=0)throw new Error("no more references");this._refCount--}GetReferenceCount(){return this._refCount}GetWidth(){return this._width}GetHeight(){return this._height}IsStatic(){return this._isStatic}GetEstimatedMemoryUsage(){let e=this._width*this._height;switch(this._pixelFormat){case"rgba8":e*=4;break;case"rgb8":e*=3;break;case"rgba4":case"rgb5_a1":case"rgb565":e*=2}return this._isMipMapped&&(e+=Math.floor(e/3)),e}static OnContextLost(){allTextures.clear()}static allTextures(){return allTextures.values()}}; } // ../lib/gfx/webgl/renderTarget.js { const C3=self.C3,assert=self.assert,glMatrix=self.glMatrix,vec3=glMatrix.vec3,mat4=glMatrix.mat4,VALID_SAMPLINGS=new Set(["nearest","bilinear","trilinear"]),DEFAULT_RENDERTARGET_OPTIONS={sampling:"trilinear",alpha:!0,depth:!1,isSampled:!0,isDefaultSize:!0,multisampling:0},allRenderTargets=new Set;C3.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=mat4.create(),this._lastFov=0,this._lastNearZ=0,this._lastFarZ=0}_Create(e,t,r){r=Object.assign({},DEFAULT_RENDERTARGET_OPTIONS,r);const i=this._renderer.GetWebGLVersionNumber();if(this._texture||this._renderBuffer)throw new Error("already created render target");if(this._sampling=r.sampling,this._alpha=!!r.alpha,this._depth=!!r.depth,this._isSampled=!!r.isSampled,this._isDefaultSize=!!r.isDefaultSize,this._multisampling=r.multisampling,!VALID_SAMPLINGS.has(this._sampling))throw new Error("invalid sampling");if(0<this._multisampling&&(i<2||this._isSampled))throw new Error("invalid use of multisampling");if(i<2&&(this._isSampled=!0),this._width=e,this._height=t,this._width<=0||this._height<=0)throw new Error("invalid render target size");this._CalculateProjection();const s=this._renderer.GetContext();if(this._frameBuffer=s.createFramebuffer(),this._depth&&(this._frameBufferNoDepth=s.createFramebuffer()),this._isSampled){this._texture=this._renderer.CreateDynamicTexture(this._width,this._height,{sampling:this._sampling,pixelFormat:this._alpha?"rgba8":"rgb8",mipMap:!1});const a=this._texture._GetTexture();s.bindFramebuffer(s.FRAMEBUFFER,this._frameBuffer),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,a,0),this._depth&&(s.bindFramebuffer(s.FRAMEBUFFER,this._frameBufferNoDepth),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,a,0))}else{this._renderBuffer=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,this._renderBuffer);const f=this._alpha?s.RGBA8:s.RGB8;if(0<this._multisampling){const n=s.getInternalformatParameter(s.RENDERBUFFER,f,s.SAMPLES);if(n&&n[0]){const _=n[0];this._multisampling>_&&(this._multisampling=_)}else this._multisampling=0}0===this._multisampling?s.renderbufferStorage(s.RENDERBUFFER,f,this._width,this._height):s.renderbufferStorageMultisample(s.RENDERBUFFER,this._multisampling,f,this._width,this._height),s.bindFramebuffer(s.FRAMEBUFFER,this._frameBuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,this._renderBuffer),this._depth&&(s.bindFramebuffer(s.FRAMEBUFFER,this._frameBufferNoDepth),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,this._renderBuffer)),s.bindRenderbuffer(s.RENDERBUFFER,null)}const h=this._renderer._GetDepthBuffer();this._depth&&h&&(s.bindFramebuffer(s.FRAMEBUFFER,this._frameBuffer),this._renderer._CanSampleDepth()?s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,h,0):s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,h)),s.bindFramebuffer(s.FRAMEBUFFER,null),allRenderTargets.add(this)}_Resize(e,t){if(this._width!==e||this._height!==t){this._width=e,this._height=t,this._CalculateProjection();const r=this._renderer.GetContext(),i=(r.bindFramebuffer(r.FRAMEBUFFER,this._frameBuffer),this._texture?this._texture._Update(new ImageData(this._width,this._height)):(r.bindRenderbuffer(r.RENDERBUFFER,this._renderBuffer),r.renderbufferStorage(r.RENDERBUFFER,this._alpha?r.RGBA8:r.RGB8,this._width,this._height),r.bindRenderbuffer(r.RENDERBUFFER,null)),this._renderer._GetDepthBuffer());this._depth&&i&&(this._renderer._CanSampleDepth()?r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.TEXTURE_2D,i,0):r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,i)),r.bindFramebuffer(r.FRAMEBUFFER,null)}}_Delete(){if(!this._texture&&!this._renderBuffer)throw new Error("already deleted render target");allRenderTargets.delete(this);const e=this._renderer.GetContext(),t=(this._texture?(e.bindFramebuffer(e.FRAMEBUFFER,this._frameBuffer),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,null,0),this._depth&&(e.bindFramebuffer(e.FRAMEBUFFER,this._frameBufferNoDepth),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,null,0)),this._renderer.DeleteTexture(this._texture),this._texture=null):this._renderBuffer&&(e.bindFramebuffer(e.FRAMEBUFFER,this._frameBuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,null),this._depth&&(e.bindFramebuffer(e.FRAMEBUFFER,this._frameBufferNoDepth),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,null)),e.deleteRenderbuffer(this._renderBuffer),this._renderBuffer=null),e.bindFramebuffer(e.FRAMEBUFFER,null),2<=this._renderer.GetWebGLVersionNumber()&&(e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null)),e.deleteFramebuffer(this._frameBuffer),this._depth&&e.deleteFramebuffer(this._frameBufferNoDepth),this._renderer.GetBatchState());t.currentFramebuffer=null,this._frameBuffer=t.currentFramebufferNoDepth=null}_CalculateProjection(){this._renderer.CalculatePerspectiveMatrix(this._projectionMatrix,this._width/this._height),this._lastFov=this._renderer.GetFovY(),this._lastNearZ=this._renderer.GetNearZ(),this._lastFarZ=this._renderer.GetFarZ()}_GetFramebuffer(){return this._frameBuffer}_GetFramebufferNoDepth(){return this._frameBufferNoDepth}GetRenderer(){return this._renderer}GetTexture(){return this._texture}GetProjectionMatrix(){return this._renderer.GetFovY()===this._lastFov&&this._renderer.GetNearZ()===this._lastNearZ&&this._renderer.GetFarZ()===this._lastFarZ||this._CalculateProjection(),this._projectionMatrix}IsLinearSampling(){return"nearest"!==this._sampling}HasAlpha(){return this._alpha}IsSampled(){return this._isSampled}HasDepthBuffer(){return this._depth}GetWidth(){return this._width}GetHeight(){return this._height}IsDefaultSize(){return this._isDefaultSize}GetMultisampling(){return this._multisampling}GetOptions(){const e={sampling:this._sampling,alpha:this._alpha,isSampled:this._isSampled};return this._isDefaultSize||(e.width=this._width,e.height=this._height),e}IsCompatibleWithOptions(e){return"nearest"!==(e=Object.assign({},DEFAULT_RENDERTARGET_OPTIONS,e)).sampling===this.IsLinearSampling()&&!!e.alpha===this.HasAlpha()&&!!e.depth===this.HasDepthBuffer()&&!(2<=this._renderer.GetWebGLVersionNumber()&&!!e.isSampled!==this.IsSampled())&&("number"==typeof e.width||"number"==typeof e.height?!this.IsDefaultSize()&&this.GetWidth()===Math.floor(e.width)&&this.GetHeight()===Math.floor(e.height):this.IsDefaultSize())}_GetWebGLTexture(){return this._texture?this._texture._GetTexture():null}GetEstimatedMemoryUsage(){return this._texture?this._texture.GetEstimatedMemoryUsage():this._width*this._height*(this._alpha?4:3)}static async DebugReadPixelsToBlob(e,t){const r=await e.ReadBackRenderTargetToImageData(t,!0);return C3.ImageDataToBlob(r)}static OnContextLost(){allRenderTargets.clear()}static allRenderTargets(){return allRenderTargets.values()}static ResizeAll(e,t){for(const r of allRenderTargets)r.IsDefaultSize()&&r._Resize(e,t)}}; } // ../lib/gfx/webgl/shaderProgram.js { const C3=self.C3,glMatrix=self.glMatrix,vec3=glMatrix.vec3,mat4=glMatrix.mat4,RESERVED_UNIFORM_NAMES=new Set(["aPos","aTex","aPoints","matP","matMV","samplerFront","samplerBack","samplerDepth","destStart","destEnd","srcStart","srcEnd","srcOriginStart","srcOriginEnd","pixelSize","seconds","devicePixelRatio","layerScale","layerAngle","layoutStart","layoutEnd","color","color2_","pointTexStart","pointTexEnd","zElevation","tileSize","tileSpacing","outlineThickness","zNear","zFar"]);C3.Gfx.WebGLShaderProgram=class extends C3.Gfx.ShaderProgramBase{static async Compile(e,t){const i=e.GetContext(),r=t.src,o=t.vertexSrc,n=t.name,a=i.createShader(i.FRAGMENT_SHADER),l=(i.shaderSource(a,r),i.compileShader(a),i.createShader(i.VERTEX_SHADER)),s=(i.shaderSource(l,o),i.compileShader(l),i.createProgram()),d=(i.attachShader(s,a),i.attachShader(s,l),i.bindAttribLocation(s,0,"aPos"),i.bindAttribLocation(s,1,"aTex"),i.bindAttribLocation(s,2,"aPoints"),i.linkProgram(s),e._GetParallelShaderCompileExtension());if(d?await e._WaitForObjectReady(()=>i.getProgramParameter(s,d["COMPLETION_STATUS_KHR"])):await C3.Wait(5),!i.getShaderParameter(a,i.COMPILE_STATUS)){const m=i.getShaderInfoLog(a);throw i.deleteShader(a),i.deleteShader(l),i.deleteProgram(s),new Error("Error compiling fragment shader: "+m)}if(!i.getShaderParameter(l,i.COMPILE_STATUS)){const h=i.getShaderInfoLog(l);throw i.deleteShader(a),i.deleteShader(l),i.deleteProgram(s),new Error("Error compiling vertex shader: "+h)}if(!i.getProgramParameter(s,i.LINK_STATUS)){const u=i.getProgramInfoLog(s);throw i.deleteShader(a),i.deleteShader(l),i.deleteProgram(s),new Error("Error linking shader program: "+u)}const c=C3.FilterUnprintableChars(i.getProgramInfoLog(s)||"").trim();return c&&!C3.IsStringAllWhitespace(c)&&console.info(`[WebGL] Shader program '${n}' compilation log: `,c),i.deleteShader(a),i.deleteShader(l),s}static async Create(e,t){const i=await C3.Gfx.WebGLShaderProgram.Compile(e,t);return new C3.Gfx.WebGLShaderProgram(e,i,t)}constructor(e,t,i){super(e,i);const r=e.GetContext(),o=e.GetBatchState(),n=(e.EndBatch(),r.useProgram(t),this._gl=r,this._shaderProgram=t,this._isDeviceTransform="<default-device-transform>"===i.name,r.getAttribLocation(t,"aPos")),a=r.getAttribLocation(t,"aTex"),l=(this._locAPoints=r.getAttribLocation(t,"aPoints"),-1!==n&&(r.bindBuffer(r.ARRAY_BUFFER,e._vertexBuffer),r.vertexAttribPointer(n,e.GetNumVertexComponents(),r.FLOAT,!1,0,0),r.enableVertexAttribArray(n)),-1!==a&&(r.bindBuffer(r.ARRAY_BUFFER,e._texcoordBuffer),r.vertexAttribPointer(a,2,r.FLOAT,!1,0,0),r.enableVertexAttribArray(a)),-1!==this._locAPoints&&(r.bindBuffer(r.ARRAY_BUFFER,e._pointBuffer),r.vertexAttribPointer(this._locAPoints,4,r.FLOAT,!1,0,0),r.enableVertexAttribArray(this._locAPoints)),r.bindBuffer(r.ARRAY_BUFFER,null),this._uMatP=new C3.Gfx.WebGLShaderUniform(this,"matP","mat4"),this._uMatMV=new C3.Gfx.WebGLShaderUniform(this,"matMV","mat4"),this._uColor=new C3.Gfx.WebGLShaderUniform(this,"color","vec4"),this._uSamplerFront=new C3.Gfx.WebGLShaderUniform(this,"samplerFront","sampler"),this._uPointTexStart=new C3.Gfx.WebGLShaderUniform(this,"pointTexStart","vec2"),this._uPointTexEnd=new C3.Gfx.WebGLShaderUniform(this,"pointTexEnd","vec2"),this._uZElevation=new C3.Gfx.WebGLShaderUniform(this,"zElevation","float"),this._uTileSize=new C3.Gfx.WebGLShaderUniform(this,"tileSize","vec2"),this._uTileSpacing=new C3.Gfx.WebGLShaderUniform(this,"tileSpacing","vec2"),this._uColor2=new C3.Gfx.WebGLShaderUniform(this,"color2_","vec4"),this._uOutlineThickness=new C3.Gfx.WebGLShaderUniform(this,"outlineThickness","float"),this._uSamplerBack=new C3.Gfx.WebGLShaderUniform(this,"samplerBack","sampler"),this._uSamplerDepth=new C3.Gfx.WebGLShaderUniform(this,"samplerDepth","sampler"),this._uDestStart=new C3.Gfx.WebGLShaderUniform(this,"destStart","vec2"),this._uDestEnd=new C3.Gfx.WebGLShaderUniform(this,"destEnd","vec2"),this._uSrcStart=new C3.Gfx.WebGLShaderUniform(this,"srcStart","vec2"),this._uSrcEnd=new C3.Gfx.WebGLShaderUniform(this,"srcEnd","vec2"),this._uSrcOriginStart=new C3.Gfx.WebGLShaderUniform(this,"srcOriginStart","vec2"),this._uSrcOriginEnd=new C3.Gfx.WebGLShaderUniform(this,"srcOriginEnd","vec2"),this._uPixelSize=new C3.Gfx.WebGLShaderUniform(this,"pixelSize","vec2"),this._uSeconds=new C3.Gfx.WebGLShaderUniform(this,"seconds","float"),this._uDevicePixelRatio=new C3.Gfx.WebGLShaderUniform(this,"devicePixelRatio","float"),this._uLayerScale=new C3.Gfx.WebGLShaderUniform(this,"layerScale","float"),this._uLayerAngle=new C3.Gfx.WebGLShaderUniform(this,"layerAngle","float"),this._uLayoutStart=new C3.Gfx.WebGLShaderUniform(this,"layoutStart","vec2"),this._uLayoutEnd=new C3.Gfx.WebGLShaderUniform(this,"layoutEnd","vec2"),this._uZNear=new C3.Gfx.WebGLShaderUniform(this,"zNear","float"),this._uZFar=new C3.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()),i.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 d of l){const c=d[0],m=d[2],h=new C3.Gfx.WebGLShaderUniform(this,c,m);"color"===m?h.Init3f(0,0,0):h.Init1f(0),this._uCustomParameters.push(h)}this._isDeviceTransform?this._UpdateDeviceTransformUniforms(o.currentMatP):(this.UpdateMatP(o.currentMatP,!0),this.UpdateMatMV(o.currentMV,!0));const s=o.currentShader;r.useProgram(s?s._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(i){for(let e=0,t=i.length;e<t;++e)if(!this._uCustomParameters[e].IsSetToCustomInBatch(i[e]))return!1;return!0}SetCustomParametersInBatch(i){for(let e=0,t=i.length;e<t;++e)this._uCustomParameters[e].SetBatchValueCustom(i[e])}AreOptionalUniformsAlreadySetInBatch(e,t,i,r,o,n,a,l,s,d){return!this._uSamplerBack.IsUsed()&&!(this._uPixelSize.IsUsed()&&!this._uPixelSize.IsSetTo2InBatch(o,n)||this._uDestStart.IsUsed()&&!this._uDestStart.IsSetTo2InBatch(e.getLeft(),e.getTop())||this._uDestEnd.IsUsed()&&!this._uDestEnd.IsSetTo2InBatch(e.getRight(),e.getBottom())||this._uDevicePixelRatio.IsUsed()&&!this._uDevicePixelRatio.IsSetTo1InBatch(a)||this._uLayerScale.IsUsed()&&!this._uLayerScale.IsSetTo1InBatch(l)||this._uLayerAngle.IsUsed()&&!this._uLayerAngle.IsSetTo1InBatch(s)||this._uSrcStart.IsUsed()&&!this._uSrcStart.IsSetTo2InBatch(t.getLeft(),t.getTop())||this._uSrcEnd.IsUsed()&&!this._uSrcEnd.IsSetTo2InBatch(t.getRight(),t.getBottom())||this._uSrcOriginStart.IsUsed()&&!this._uSrcOriginStart.IsSetTo2InBatch(i.getLeft(),i.getTop())||this._uSrcOriginEnd.IsUsed()&&!this._uSrcOriginEnd.IsSetTo2InBatch(i.getRight(),i.getBottom())||this._uLayoutStart.IsUsed()&&!this._uLayoutStart.IsSetTo2InBatch(r.getLeft(),r.getTop())||this._uLayoutEnd.IsUsed()&&!this._uLayoutEnd.IsSetTo2InBatch(r.getTop(),r.getBottom())||this._uSeconds.IsUsed()&&!this._uSeconds.IsSetTo1InBatch(d))}SetOptionalUniformsInBatch(e,t,i,r,o,n,a,l,s,d){this._uSamplerBack.IsUsed()||(this._uPixelSize.IsUsed()&&this._uPixelSize.SetBatch2(o,n),this._uDestStart.IsUsed()&&this._uDestStart.SetBatch2(e.getLeft(),e.getTop()),this._uDestEnd.IsUsed()&&this._uDestEnd.SetBatch2(e.getRight(),e.getBottom()),this._uDevicePixelRatio.IsUsed()&&this._uDevicePixelRatio.SetBatch1(a),this._uLayerScale.IsUsed()&&this._uLayerScale.SetBatch1(l),this._uLayerAngle.IsUsed()&&this._uLayerAngle.SetBatch1(s),this._uSrcStart.IsUsed()&&this._uSrcStart.SetBatch2(t.getLeft(),t.getTop()),this._uSrcEnd.IsUsed()&&this._uSrcEnd.SetBatch2(t.getRight(),t.getBottom()),this._uSrcOriginStart.IsUsed()&&this._uSrcOriginStart.SetBatch2(i.getLeft(),i.getTop()),this._uSrcOriginEnd.IsUsed()&&this._uSrcOriginEnd.SetBatch2(i.getRight(),i.getBottom()),this._uLayoutStart.IsUsed()&&this._uLayoutStart.SetBatch2(r.getLeft(),r.getTop()),this._uLayoutEnd.IsUsed()&&this._uLayoutEnd.SetBatch2(r.getTop(),r.getBottom()),this._uSeconds.IsUsed()&&this._uSeconds.SetBatch1(d))}UpdateMatP(e,t){this._hasCurrentMatP&&!t||this._isDeviceTransform||(this._uMatP.IsUsed()&&this._uMatP.UpdateMatrix4fv(e),this._hasCurrentMatP=!0)}SetMatPStale(){this._hasCurrentMatP=!1}UpdateMatMV(e,t){this._hasCurrentMatMV&&!t||this._isDeviceTransform||(this._uMatMV.IsUsed()&&this._uMatMV.UpdateMatrix4fv(e),this._hasCurrentMatMV=!0)}SetMatMVStale(){this._hasCurrentMatMV=!1}_UpdateDeviceTransformUniforms(e){if(!this._isDeviceTransform)throw new Error("not device transform shader");this._uMatP.UpdateMatrix4fv(e);const t=this._renderer,i=t.GetWidth()/2,r=t.GetHeight()/2,o=t.CalculateLookAtModelView2(i,r,t.GetDefaultCameraZ(t.GetHeight()),i,r,0,t.GetHeight());this._uMatMV.UpdateMatrix4fv(o)}UpdateColor(e){this._uColor.IsUsed()&&this._uColor.Update4f(e[0],e[1],e[2],e[3])}static GetReservedUniformNames(){return RESERVED_UNIFORM_NAMES}static GetDefaultVertexShaderSource(e){const t=e?"highmedp":"mediump";return["#ifdef GL_FRAGMENT_PRECISION_HIGH","#define highmedp highp","#else","#define highmedp mediump","#endif","attribute highp vec3 aPos;",`attribute ${t} vec2 aTex;`,`varying ${t} vec2 vTex;`,"uniform highp mat4 matP;","uniform highp mat4 matMV;","void main(void) {",` gl_Position = matP * matMV * vec4(aPos, 1.0);`,` vTex = aTex;`,"}"].join("\n")}static GetDefaultVertexShaderSource_WebGL2(e){const t=e?"highp":"mediump";return["#version 300 es","in highp vec3 aPos;",`in ${t} vec2 aTex;`,`out ${t} vec2 vTex;`,"uniform highp mat4 matP;","uniform highp mat4 matMV;","void main(void) {",` gl_Position = matP * matMV * vec4(aPos, 1.0);`,` vTex = aTex;`,"}"].join("\n")}static GetTextureFillFragmentShaderSource_WebGL1_NoFragDepth(){return["varying mediump vec2 vTex;","uniform lowp vec4 color;","uniform lowp sampler2D samplerFront;","void main(void) {","\tgl_FragColor = texture2D(samplerFront, vTex) * color;","}"].join("\n")}static GetTextureFillFragmentShaderSource_WebGL1_FragDepthEXT(){return["#extension GL_EXT_frag_depth : enable","varying mediump vec2 vTex;","uniform lowp vec4 color;","uniform lowp sampler2D samplerFront;","void main(void) {","\tgl_FragColor = texture2D(samplerFront, vTex) * color;","\tgl_FragDepthEXT = (gl_FragColor.a == 0.0 ? 1.0 : gl_FragCoord.z);","}"].join("\n")}static GetTextureFillFragmentShaderSource_WebGL2(){return["#version 300 es","in mediump vec2 vTex;","out lowp vec4 outColor;","uniform lowp vec4 color;","uniform lowp sampler2D samplerFront;","void main(void) {","\toutColor = texture(samplerFront, vTex) * color;","\tgl_FragDepth = (outColor.a == 0.0 ? 1.0 : gl_FragCoord.z);","}"].join("\n")}static GetTilemapFragmentShaderSource_WebGL1_NoFragDepth(){return["#ifdef GL_FRAGMENT_PRECISION_HIGH","#define highmedp highp","#else","#define highmedp mediump","#endif","varying highmedp vec2 vTex;","uniform lowp vec4 color;","uniform lowp sampler2D samplerFront;","uniform highmedp vec2 srcStart;","uniform highmedp vec2 pixelSize;","uniform highmedp vec2 tileSize;","uniform highmedp vec2 tileSpacing;","void main(void) {","\thighmedp vec2 tile = floor(vTex);","\thighmedp vec2 tex = fract(vTex);","\thighmedp vec2 tileOrigin = srcStart + tile * (tileSize + tileSpacing);","\thighmedp vec2 lowerBound = tileOrigin + pixelSize / 2.0;","\thighmedp vec2 upperBound = tileOrigin + tileSize - pixelSize / 2.0;","\tgl_FragColor = texture2D(samplerFront, clamp(tex, lowerBound, upperBound), -16.0) * color;","}"].join("\n")}static GetTilemapFragmentShaderSource_WebGL1_FragDepthEXT(){return["#extension GL_EXT_frag_depth : enable","#ifdef GL_FRAGMENT_PRECISION_HIGH","#define highmedp highp","#else","#define highmedp mediump","#endif","varying highmedp vec2 vTex;","uniform lowp vec4 color;","uniform lowp sampler2D samplerFront;","uniform highmedp vec2 srcStart;","uniform highmedp vec2 pixelSize;","uniform highmedp vec2 tileSize;","uniform highmedp vec2 tileSpacing;","void main(void) {","\thighmedp vec2 tile = floor(vTex);","\thighmedp vec2 tex = fract(vTex);","\thighmedp vec2 tileOrigin = srcStart + tile * (tileSize + tileSpacing);","\thighmedp vec2 lowerBound = tileOrigin + pixelSize / 2.0;","\thighmedp vec2 upperBound = tileOrigin + tileSize - pixelSize / 2.0;","\tgl_FragColor = texture2D(samplerFront, clamp(tex, lowerBound, upperBound), -16.0) * color;","\tgl_FragDepthEXT = (gl_FragColor.a == 0.0 ? 1.0 : gl_FragCoord.z);","}"].join("\n")}static GetTilemapFragmentShaderSource_WebGL2(){return["#version 300 es","in highp vec2 vTex;","out lowp vec4 outColor;","uniform lowp vec4 color;","uniform lowp sampler2D samplerFront;","uniform highp vec2 srcStart;","uniform highp vec2 pixelSize;","uniform highp vec2 tileSize;","uniform highp vec2 tileSpacing;","void main(void) {","\thighp vec2 tile = floor(vTex);","\thighp vec2 tex = fract(vTex);","\thighp vec2 tileOrigin = srcStart + tile * (tileSize + tileSpacing);","\thighp vec2 lowerBound = tileOrigin + pixelSize / 2.0;","\thighp vec2 upperBound = tileOrigin + tileSize - pixelSize / 2.0;","\toutColor = texture(samplerFront, clamp(tex, lowerBound, upperBound), -16.0) * color;","\tgl_FragDepth = (outColor.a == 0.0 ? 1.0 : gl_FragCoord.z);","}"].join("\n")}static GetTileRandomizationFragmentShaderSource(e,t,i){let r="";return 2<=e?r="#version 300 es\n":(t&&(r="#extension GL_EXT_frag_depth : enable\n"),i&&(r+="#extension GL_EXT_shader_texture_lod : enable\n#extension GL_OES_standard_derivatives : enable\n")),r+` #ifdef GL_FRAGMENT_PRECISION_HIGH #define highmedp highp #else #define highmedp mediump #endif precision highmedp float; ${2<=e?"in":"varying"} vec2 vTex; ${2<=e?"out lowp vec4 outColor;":""} uniform lowp vec4 color; uniform lowp sampler2D samplerFront; uniform vec2 pixelSize; uniform vec2 tileSize; uniform vec2 tileSpacing; uniform float outlineThickness; const float PI = 3.1415926; lowp vec4 cospVec4(lowp vec4 a, lowp vec4 b, float x) { return (a + b + (a - b) * cos(x * PI)) / 2.0; } vec3 randVec3(vec2 seed) { return vec3(fract(sin(dot(seed.xy + vec2(0.1, 0.1), vec2(12.9898,78.233))) * 43758.5453), fract(sin(dot(seed.yx + vec2(0.1, 0.1), vec2(12.9898,-78.233))) * 43758.5453), fract(sin(dot(seed.xy + vec2(0.1, 0.1), vec2(-12.9898,-78.233))) * 43758.5453)); } lowp vec4 sampleTile(vec2 tile, vec2 uv, vec2 ddx, vec2 ddy) { vec2 posRandom = tileSize; float angleRandom = outlineThickness; vec3 rand = (randVec3(floor(tile + 0.5)) - 0.5) * 2.0; float angle = angleRandom * rand.z * PI; float sin_a = sin(angle); float cos_a = cos(angle); float aspect = pixelSize.x / pixelSize.y; vec2 mid = tile + vec2(0.5, 0.5); vec2 dp = uv - mid; dp.x /= aspect; vec2 r = vec2(dp.x * cos_a - dp.y * sin_a, dp.y * cos_a + dp.x * sin_a); r.x *= aspect; vec2 p = mid + r + (posRandom * rand.xy / 2.0); ${2<=e?"return textureGrad(samplerFront, p, ddx, ddy);":""} ${e<2&&i?"return texture2DGradEXT(samplerFront, p, ddx, ddy);":""} ${e<2&&!i?"return texture2D(samplerFront, p);":""} } void main(void) { ${e<2?"lowp vec4 outColor;":""} float blendMarginX = tileSpacing.x; float blendMarginY = tileSpacing.y; vec2 tile = floor(vTex); vec2 tex = fract(vTex); vec2 ddx = ${2<=e||i?"dFdx(vTex)":"vec2(0.0, 0.0)"}; vec2 ddy = ${2<=e||i?"dFdy(vTex)":"vec2(0.0, 0.0)"}; vec4 curTile = sampleTile(tile, vTex, ddx, ddy); bool inLeftMargin = (tex.x < blendMarginX); bool inRightMargin = (tex.x > 1.0 - blendMarginX); bool inTopMargin = (tex.y < blendMarginY); bool inBottomMargin = (tex.y > 1.0 - blendMarginY); if (inLeftMargin) { lowp vec4 leftTile = sampleTile(tile + vec2(-1.0, 0.0), vTex, ddx, ddy); float leftMix = (tex.x / (blendMarginX * 2.0)) + 0.5; lowp vec4 leftMixedTile = cospVec4(leftTile, curTile, leftMix); if (inTopMargin) { lowp vec4 topTile = sampleTile(tile + vec2(0.0, -1.0), vTex, ddx, ddy); lowp vec4 topLeftTile = sampleTile(tile + vec2(-1.0, -1.0), vTex, ddx, ddy); lowp vec4 topLeftMixedTile = cospVec4(topLeftTile, topTile, leftMix); outColor = cospVec4(topLeftMixedTile, leftMixedTile, (tex.y / (blendMarginY * 2.0)) + 0.5); } else if (inBottomMargin) { lowp vec4 bottomTile = sampleTile(tile + vec2(0.0, 1.0), vTex, ddx, ddy); lowp vec4 bottomLeftTile = sampleTile(tile + vec2(-1.0, 1.0), vTex, ddx, ddy); lowp vec4 bottomLeftMixedTile = cospVec4(bottomLeftTile, bottomTile, leftMix); outColor = cospVec4(leftMixedTile, bottomLeftMixedTile, (tex.y - (1.0 - blendMarginY)) / (blendMarginY * 2.0)); } else { outColor = leftMixedTile; } } else if (inRightMargin) { lowp vec4 rightTile = sampleTile(tile + vec2(1.0, 0.0), vTex, ddx, ddy); float rightMix = (tex.x - (1.0 - blendMarginX)) / (blendMarginX * 2.0); lowp vec4 rightMixedTile = cospVec4(curTile, rightTile, rightMix); if (inTopMargin) { lowp vec4 topTile = sampleTile(tile + vec2(0.0, -1.0), vTex, ddx, ddy); lowp vec4 topRightTile = sampleTile(tile + vec2(1.0, -1.0), vTex, ddx, ddy); lowp vec4 topRightMixedTile = cospVec4(topTile, topRightTile, rightMix); outColor = cospVec4(topRightMixedTile, rightMixedTile, (tex.y / (blendMarginY * 2.0)) + 0.5); } else if (inBottomMargin) { lowp vec4 bottomTile = sampleTile(tile + vec2(0.0, 1.0), vTex, ddx, ddy); lowp vec4 bottomRightTile = sampleTile(tile + vec2(1.0, 1.0), vTex, ddx, ddy); lowp vec4 bottomRightMixedTile = cospVec4(bottomTile, bottomRightTile, rightMix); outColor = cospVec4(rightMixedTile, bottomRightMixedTile, (tex.y - (1.0 - blendMarginY)) / (blendMarginY * 2.0)); } else { outColor = rightMixedTile; } } else if (inTopMargin) { lowp vec4 topTile = sampleTile(tile + vec2(0.0, -1.0), vTex, ddx, ddy); outColor = cospVec4(topTile, curTile, (tex.y / (blendMarginY * 2.0)) + 0.5); } else if (inBottomMargin) { lowp vec4 bottomTile = sampleTile(tile + vec2(0.0, 1.0), vTex, ddx, ddy); outColor = cospVec4(curTile, bottomTile, (tex.y - (1.0 - blendMarginY)) / (blendMarginY * 2.0)); } else { outColor = curTile; } outColor *= color; ${e<2?"gl_FragColor = outColor;":""} ${2<=e?"gl_FragDepth = (outColor.a == 0.0 ? 1.0 : gl_FragCoord.z);":""} ${e<2&&t?"gl_FragDepthEXT = (outColor.a == 0.0 ? 1.0 : gl_FragCoord.z);":""} } `}static GetPointVertexShaderSource_WebGL1(){return["attribute vec4 aPoints;","varying float pointOpacity;","uniform float zElevation;","uniform mat4 matP;","uniform mat4 matMV;","void main(void) {","\tgl_Position = matP * matMV * vec4(aPoints.xy, zElevation, 1.0);","\tgl_PointSize = aPoints.z;","\tpointOpacity = aPoints.w;","}"].join("\n")}static GetPointVertexShaderSource_WebGL2(){return["#version 300 es","in vec4 aPoints;","out float pointOpacity;","uniform float zElevation;","uniform mat4 matP;","uniform mat4 matMV;","void main(void) {","\tgl_Position = matP * matMV * vec4(aPoints.xy, zElevation, 1.0);","\tgl_PointSize = aPoints.z;","\tpointOpacity = aPoints.w;","}"].join("\n")}static GetPointFragmentShaderSource_WebGL1_NoFragDepth(){return["uniform lowp sampler2D samplerFront;","varying lowp float pointOpacity;","uniform mediump vec2 pointTexStart;","uniform mediump vec2 pointTexEnd;","uniform lowp vec4 color;","void main(void) {","\tmediump vec2 pointTexMin = min(pointTexStart, pointTexEnd);","\tmediump vec2 pointTexMax = max(pointTexStart, pointTexEnd);","\tmediump vec2 pointCoord = (pointTexEnd.x > pointTexStart.x ? gl_PointCoord : vec2(1.0 - gl_PointCoord.y, gl_PointCoord.x));","\tgl_FragColor = texture2D(samplerFront, mix(pointTexMin, pointTexMax, pointCoord)) * color * pointOpacity;","}"].join("\n")}static GetPointFragmentShaderSource_WebGL1_FragDepthEXT(){return["#extension GL_EXT_frag_depth : enable","uniform lowp sampler2D samplerFront;","varying lowp float pointOpacity;","uniform mediump vec2 pointTexStart;","uniform mediump vec2 pointTexEnd;","uniform lowp vec4 color;","void main(void) {","\tmediump vec2 pointTexMin = min(pointTexStart, pointTexEnd);","\tmediump vec2 pointTexMax = max(pointTexStart, pointTexEnd);","\tmediump vec2 pointCoord = (pointTexEnd.x > pointTexStart.x ? gl_PointCoord : vec2(1.0 - gl_PointCoord.y, gl_PointCoord.x));","\tgl_FragColor = texture2D(samplerFront, mix(pointTexMin, pointTexMax, pointCoord)) * color * pointOpacity;","\tgl_FragDepthEXT = (gl_FragColor.a == 0.0 ? 1.0 : gl_FragCoord.z);","}"].join("\n")}static GetPointFragmentShaderSource_WebGL2(){return["#version 300 es","uniform lowp sampler2D samplerFront;","in lowp float pointOpacity;","uniform mediump vec2 pointTexStart;","uniform mediump vec2 pointTexEnd;","uniform lowp vec4 color;","out lowp vec4 outColor;","void main(void) {","\tmediump vec2 pointTexMin = min(pointTexStart, pointTexEnd);","\tmediump vec2 pointTexMax = max(pointTexStart, pointTexEnd);","\tmediump vec2 pointCoord = (pointTexEnd.x > pointTexStart.x ? gl_PointCoord : vec2(1.0 - gl_PointCoord.y, gl_PointCoord.x));","\toutColor = texture(samplerFront, mix(pointTexMin, pointTexMax, pointCoord)) * color * pointOpacity;","\tgl_FragDepth = (outColor.a == 0.0 ? 1.0 : gl_FragCoord.z);","}"].join("\n")}static GetColorFillFragmentShaderSource(){return["uniform lowp vec4 color;","void main(void) {","\tgl_FragColor = color;","}"].join("\n")}static GetLinearGradientFillFragmentShaderSource(){return["precision lowp float;","varying mediump vec2 vTex;","uniform vec4 color;","uniform vec4 color2_;","vec3 fromLinear(vec3 linearRGB)","{","\tbvec3 cutoff = lessThan(linearRGB, vec3(0.0031308));","\tvec3 higher = vec3(1.055) * pow(abs(linearRGB), vec3(1.0/2.4)) - vec3(0.055);","\tvec3 lower = linearRGB * vec3(12.92);","\treturn mix(higher, lower, vec3(cutoff));","}","vec3 toLinear(vec3 sRGB)","{","\tbvec3 cutoff = lessThan(sRGB, vec3(0.04045));","\tvec3 higher = pow(abs((sRGB + vec3(0.055))/vec3(1.055)), vec3(2.4));","\tvec3 lower = sRGB/vec3(12.92);","\treturn mix(higher, lower, vec3(cutoff));","}","void main(void) {","\tvec3 linearGrad = mix(toLinear(color.rgb), toLinear(color2_.rgb), vTex.x);","\tfloat a = mix(color.a, color2_.a, vTex.x);","\tgl_FragColor = vec4(fromLinear(linearGrad) * a, a);","}"].join("\n")}static GetPenumbraFillFragmentShaderSource(){return["#ifdef GL_FRAGMENT_PRECISION_HIGH","#define highmedp highp","#else","#define highmedp mediump","#endif","precision lowp float;","varying highmedp vec2 vTex;","uniform vec4 color;","void main(void) {",` highmedp float grad = vTex.x / (1.0 - vTex.y);`,` gl_FragColor = color * (1.0 - (cos(grad * 3.141592653589793) + 1.0) / 2.0);`,"}"].join("\n")}static GetSmoothLineFillFragmentShaderSource(){return["varying mediump vec2 vTex;","uniform lowp vec4 color;","void main(void) {","\tlowp float f = 1.0 - abs(vTex.y - 0.5) * 2.0;","\tgl_FragColor = color * f;","}"].join("\n")}static GetHardEllipseFillFragmentShaderSource(){return["varying mediump vec2 vTex;","uniform lowp vec4 color;","void main(void) {","\tmediump vec2 diff = vTex - vec2(0.5, 0.5);","\tmediump vec2 diffSq = diff * diff;","\tmediump float f = step(diffSq.x + diffSq.y, 0.25);","\tgl_FragColor = color * f;","}"].join("\n")}static GetHardEllipseOutlineFragmentShaderSource(){return["varying mediump vec2 vTex;","uniform lowp vec4 color;","uniform mediump vec2 pixelSize;","uniform mediump float outlineThickness;","void main(void) {","\tmediump vec2 diff = vTex - vec2(0.5, 0.5);","\tmediump vec2 diffSq = diff * diff;","\tmediump float distSq = diffSq.x + diffSq.y;","\tmediump vec2 norm = normalize(diff);","\tmediump vec2 halfNorm = norm * 0.5;","\tmediump float innerF = step(distSq, 0.25);","\tmediump vec2 innerEdge = halfNorm - pixelSize * norm * outlineThickness;","\tmediump vec2 innerEdgeSq = innerEdge * innerEdge;","\tmediump float outerF = step(innerEdgeSq.x + innerEdgeSq.y, distSq);","\tgl_FragColor = color * innerF * outerF;","}"].join("\n")}static GetSmoothEllipseFillFragmentShaderSource(){return["varying mediump vec2 vTex;","uniform lowp vec4 color;","uniform mediump vec2 pixelSize;","void main(void) {","\tmediump vec2 diff = vTex - vec2(0.5, 0.5);","\tmediump vec2 diffSq = diff * diff;","\tmediump vec2 norm = normalize(diff);","\tmediump vec2 halfNorm = norm * 0.5;","\tmediump vec2 halfNormSq = halfNorm * halfNorm;","\tmediump vec2 innerEdge = halfNorm - pixelSize * norm;","\tmediump vec2 innerEdgeSq = innerEdge * innerEdge;","\tmediump float f = smoothstep(halfNormSq.x + halfNormSq.y, innerEdgeSq.x + innerEdgeSq.y, diffSq.x + diffSq.y);","\tgl_FragColor = color * f;","}"].join("\n")}static GetSmoothEllipseOutlineFragmentShaderSource(){return["varying mediump vec2 vTex;","uniform lowp vec4 color;","uniform mediump vec2 pixelSize;","uniform mediump float outlineThickness;","void main(void) {","\tmediump vec2 diff = vTex - vec2(0.5, 0.5);","\tmediump vec2 diffSq = diff * diff;","\tmediump float distSq = diffSq.x + diffSq.y;","\tmediump vec2 norm = normalize(diff);","\tmediump vec2 halfNorm = norm * 0.5;","\tmediump vec2 halfNormSq = halfNorm * halfNorm;","\tmediump vec2 pxNorm = pixelSize * norm;","\tmediump vec2 innerEdge1 = halfNorm - pxNorm;","\tmediump vec2 innerEdge1Sq = innerEdge1 * innerEdge1;","\tmediump float innerF = smoothstep(halfNormSq.x + halfNormSq.y, innerEdge1Sq.x + innerEdge1Sq.y, distSq);","\tmediump vec2 innerEdge2 = halfNorm - pxNorm * outlineThickness;","\tmediump vec2 innerEdge2Sq = innerEdge2 * innerEdge2;","\tmediump vec2 innerEdge3 = halfNorm - pxNorm * (outlineThickness + 1.0);","\tmediump vec2 innerEdge3Sq = innerEdge3 * innerEdge3;","\tmediump float outerF = smoothstep(innerEdge3Sq.x + innerEdge3Sq.y, innerEdge2Sq.x + innerEdge2Sq.y, distSq);","\tgl_FragColor = color * innerF * outerF;","}"].join("\n")}}; } // ../lib/gfx/webgl/shaderUniform.js { const C3=self.C3,glMatrix=self.glMatrix,mat4=glMatrix.mat4,TYPE_SIZES=new Map([["float",1],["percent",1],["sampler",1],["vec2",2],["vec3",3],["color",3],["vec4",4],["mat4",16]]);C3.Gfx.WebGLShaderUniform=class{constructor(t,s,a){if(!TYPE_SIZES.has(a))throw new Error("invalid uniform type");this._owner=t,this._gl=this._owner.GetWebGLContext(),this._name=s,this._type=a,this._isColorType="color"===this._type,this._location=this._gl.getUniformLocation(this._owner.GetShaderProgram(),s),this._isUsed=!!this._location;const i=TYPE_SIZES.get(a);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(t){this.IsUsed()&&(this._lastValue[0]=t,this._lastBatchValue.set(this._lastValue),this._gl.uniform1f(this._location,t))}Init1i(t){this.IsUsed()&&(this._lastValue[0]=t,this._lastBatchValue.set(this._lastValue),this._gl.uniform1i(this._location,t))}Init2f(t,s){this.IsUsed()&&(this._lastValue[0]=t,this._lastValue[1]=s,this._lastBatchValue.set(this._lastValue),this._gl.uniform2f(this._location,t,s))}Init3f(t,s,a){this.IsUsed()&&(this._lastValue[0]=t,this._lastValue[1]=s,this._lastValue[2]=a,this._lastBatchValue.set(this._lastValue),this._gl.uniform3f(this._location,t,s,a))}Init4f(t,s,a,i){this.IsUsed()&&(this._lastValue[0]=t,this._lastValue[1]=s,this._lastValue[2]=a,this._lastValue[3]=i,this._lastBatchValue.set(this._lastValue),this._gl.uniform4f(this._location,t,s,a,i))}Update1f(t){t=Math.fround(t);const s=this._lastValue;s[0]!==t&&(s[0]=t,this._gl.uniform1f(this._location,t))}Update1i(t){const s=this._lastValue;s[0]!==t&&this._gl.uniform1i(this._location,s[0]=t)}Update2f(t,s){t=Math.fround(t),s=Math.fround(s);const a=this._lastValue;a[0]===t&&a[1]===s||(a[0]=t,a[1]=s,this._gl.uniform2f(this._location,t,s))}Update3f(t,s,a){t=Math.fround(t),s=Math.fround(s),a=Math.fround(a);const i=this._lastValue;i[0]===t&&i[1]===s&&i[2]===a||(i[0]=t,i[1]=s,i[2]=a,this._gl.uniform3f(this._location,t,s,a))}Update4f(t,s,a,i){t=Math.fround(t),s=Math.fround(s),a=Math.fround(a),i=Math.fround(i);const l=this._lastValue;l[0]===t&&l[1]===s&&l[2]===a&&l[3]===i||(l[0]=t,l[1]=s,l[2]=a,l[3]=i,this._gl.uniform4f(this._location,t,s,a,i))}UpdateMatrix4fv(t){const s=this._lastValue;mat4.exactEquals(s,t)||(C3.typedArraySet16(s,t,0),this._gl.uniformMatrix4fv(this._location,!1,t))}IsSetToCustomInBatch(t){const s=this._lastBatchValue;return this.IsColorType()?s[0]===Math.fround(t.getR())&&s[1]===Math.fround(t.getG())&&s[2]===Math.fround(t.getB()):s[0]===Math.fround(t)}SetBatchValueCustom(t){const s=this._lastBatchValue;this.IsColorType()?(s[0]=t.getR(),s[1]=t.getG(),s[2]=t.getB()):s[0]=t}IsSetTo1InBatch(t){return this._lastBatchValue[0]===Math.fround(t)}IsSetTo2InBatch(t,s){const a=this._lastBatchValue;return a[0]===Math.fround(t)&&a[1]===Math.fround(s)}SetBatch1(t){this._lastBatchValue[0]=t}SetBatch2(t,s){const a=this._lastBatchValue;a[0]=t,a[1]=s}}; } // ../lib/gfx/webgl/batchJob.js { const C3=self.C3,glMatrix=self.glMatrix,vec4=glMatrix.vec4,mat4=glMatrix.mat4,BATCH_NULL=0,BATCH_QUAD=1,BATCH_SETTEXTURE=2,BATCH_SETCOLOR=3,BATCH_SETBLEND=4,BATCH_SETVIEWPORT=5,BATCH_SETPROJECTION=6,BATCH_SETMODELVIEW=7,BATCH_SETRENDERTARGET=8,BATCH_CLEARSURFACE=9,BATCH_POINTS=10,BATCH_SETPROGRAM=11,BATCH_SETPROGRAMPARAMETERS=12,BATCH_SETPROGRAMCUSTOMPARAMETERS=13,BATCH_INVALIDATEFRAMEBUFFER=14,BATCH_SETPOINTTEXCOORDS=15,BATCH_SETTILEMAPINFO=16,BATCH_BLITFRAMEBUFFER=17,BATCH_STARTQUERY=18,BATCH_ENDQUERY=19,BATCH_SETELLIPSEPARAMS=20,BATCH_SETGRADIENTCOLOR=21,BATCH_CLEARDEPTH=22,BATCH_SETDEPTHENABLED=23,BATCH_SETDEPTHSAMPLINGENABLED=24,BATCH_COPLANAR_STARTSTENCILPASS=25,BATCH_COPLANAR_STARTCOLORPASS=26,BATCH_COPLANAR_RESTORE=27,BATCH_SET_SCISSOR=28,BATCH_SETTILERANDOMIZATIONINFO=29;C3.Gfx.BatchState=class{constructor(t){this.renderer=t,this.currentMV=mat4.create(),this.currentMatP=mat4.create(),this.currentFramebuffer=null,this.currentFramebufferNoDepth=null,this.isDepthSamplingEnabled=!1,this.currentColor=vec4.fromValues(1,1,1,1),this.currentShader=null,this.pointTexCoords=new C3.Rect,this.clearColor=C3.New(C3.Color,0,0,0,0)}},C3.Gfx.WebGLBatchJob=class{constructor(t){const e=new ArrayBuffer(96);this._type=0,this._batchState=t,this._gl=t.renderer.GetContext(),this._startIndex=0,this._indexCount=0,this._texParam=null,this._mat4param=new Float32Array(e,0,16),this._colorParam=new Float32Array(e,64,4),this._srcOriginRect=new Float32Array(e,80,4),this._shaderParams=[]}InitQuad(t,e){this._type=BATCH_QUAD,this._startIndex=t,this._indexCount=e}DoQuad(){const t=this._gl;t.drawElements(t.TRIANGLES,this._indexCount,t.UNSIGNED_SHORT,this._startIndex)}InitSetTexture(t){this._type=BATCH_SETTEXTURE,this._texParam=t}DoSetTexture(){const t=this._gl,e=this._texParam;t.bindTexture(t.TEXTURE_2D,e?e._GetTexture():null)}InitSetColor(t){this._type=BATCH_SETCOLOR,t.writeToTypedArray(this._colorParam,0)}DoSetColor(){const t=this._colorParam,e=this._batchState;vec4.copy(e.currentColor,t),e.currentShader.UpdateColor(t)}InitSetGradientColor(t){this._type=BATCH_SETGRADIENTCOLOR,t.writeToTypedArray(this._colorParam,0)}DoSetGradientColor(){const t=this._colorParam,e=this._batchState.currentShader;e._uColor2.IsUsed()&&e._uColor2.Update4f(t[0],t[1],t[2],t[3])}InitSetBlend(t,e){this._type=BATCH_SETBLEND,this._startIndex=t,this._indexCount=e}DoSetBlend(){this._gl.blendFunc(this._startIndex,this._indexCount)}InitSetViewport(t,e,r,a){this._type=BATCH_SETVIEWPORT;const s=this._colorParam;s[0]=t,s[1]=e,s[2]=r,s[3]=a}DoSetViewport(){const t=this._colorParam;this._gl.viewport(t[0],t[1],t[2],t[3])}InitSetProjection(t){this._type=BATCH_SETPROJECTION,mat4.copy(this._mat4param,t)}DoSetProjection(){const t=this._batchState,r=t.renderer._allShaderPrograms,a=t.currentShader,s=this._mat4param;for(let t=0,e=r.length;t<e;++t){const i=r[t];i===a?i.UpdateMatP(s,!0):i.SetMatPStale()}mat4.copy(t.currentMatP,s)}InitSetModelView(t){this._type=BATCH_SETMODELVIEW,mat4.copy(this._mat4param,t)}DoSetModelView(){const t=this._batchState,r=t.renderer._allShaderPrograms,a=t.currentShader,s=this._mat4param;for(let t=0,e=r.length;t<e;++t){const i=r[t];i===a?i.UpdateMatMV(s,!0):i.SetMatMVStale()}mat4.copy(t.currentMV,s)}InitSetRenderTarget(t){this._type=BATCH_SETRENDERTARGET,this._texParam=t}DoSetRenderTarget(){const t=this._gl,e=this._texParam,r=this._batchState;e?(r.currentFramebuffer=e._GetFramebuffer(),r.currentFramebufferNoDepth=e._GetFramebufferNoDepth(),r.isDepthSamplingEnabled&&r.currentFramebufferNoDepth?t.bindFramebuffer(t.FRAMEBUFFER,r.currentFramebufferNoDepth):t.bindFramebuffer(t.FRAMEBUFFER,r.currentFramebuffer)):(r.currentFramebuffer=null,r.currentFramebufferNoDepth=null,t.bindFramebuffer(t.FRAMEBUFFER,null))}InitClearSurface(t){this._type=BATCH_CLEARSURFACE,t.writeToTypedArray(this._mat4param,0)}InitClearSurface2(t,e,r,a){this._type=BATCH_CLEARSURFACE;const s=this._mat4param;s[0]=t,s[1]=e,s[2]=r,s[3]=a}DoClearSurface(){const t=this._gl,e=this._mat4param,r=this._batchState,a=r.clearColor,s=e[0],i=e[1],n=e[2],o=e[3];a.equalsRgba(s,i,n,o)||(t.clearColor(s,i,n,o),a.setRgba(s,i,n,o)),t.clear(t.COLOR_BUFFER_BIT)}InitSetPointTexCoords(t){this._type=BATCH_SETPOINTTEXCOORDS,t.writeToTypedArray(this._mat4param,0)}DoSetPointTextureCoords(){const t=this._mat4param;this._batchState.pointTexCoords.set(t[0],t[1],t[2],t[3])}InitPoints(t,e){this._type=BATCH_POINTS,this._startIndex=t,this._indexCount=1,this._mat4param[0]=e}DoPoints(){const t=this._gl,e=this._batchState,r=e.renderer,a=r._spPoints,s=(t.useProgram(a._shaderProgram),a.UpdateMatP(e.currentMatP,!1),a.UpdateMatMV(e.currentMV,!1),e.pointTexCoords),i=(a._uPointTexStart.IsUsed()&&a._uPointTexStart.Update2f(s.getLeft(),s.getTop()),a._uPointTexEnd.IsUsed()&&a._uPointTexEnd.Update2f(s.getRight(),s.getBottom()),this._mat4param[0]);if(a._uZElevation.IsUsed()&&a._uZElevation.Update1f(i),a._uColor.IsUsed()){const n=e.currentColor;a._uColor.Update4f(n[0],n[1],n[2],n[3])}t.drawArrays(t.POINTS,this._startIndex/4,this._indexCount),t.useProgram(e.currentShader._shaderProgram)}InitSetProgram(t){this._type=BATCH_SETPROGRAM,this._texParam=t}DoSetProgram(){const t=this._gl,e=this._batchState,r=this._texParam;if(e.currentShader=r,t.useProgram(r._shaderProgram),r.UpdateMatP(e.currentMatP,!1),r.UpdateMatMV(e.currentMV,!1),r._uColor.IsUsed()){const a=e.currentColor;r._uColor.Update4f(a[0],a[1],a[2],a[3])}}InitSetProgramParameters(){this._type=BATCH_SETPROGRAMPARAMETERS}DoSetProgramParameters(){const t=this._batchState.currentShader,e=this._gl,r=this._mat4param,a=this._colorParam,s=this._srcOriginRect;if(t._uSamplerBack.IsUsed()){const i=this._batchState.renderer,n=this._texParam;i._lastTexture1!==n&&(e.activeTexture(e.TEXTURE1),e.bindTexture(e.TEXTURE_2D,n?n._GetTexture():null),i._lastTexture1=n,e.activeTexture(e.TEXTURE0))}t._uPixelSize.IsUsed()&&t._uPixelSize.Update2f(r[0],r[1]),t._uDestStart.IsUsed()&&t._uDestStart.Update2f(r[2],r[3]),t._uDestEnd.IsUsed()&&t._uDestEnd.Update2f(r[4],r[5]),t._uDevicePixelRatio.IsUsed()&&t._uDevicePixelRatio.Update1f(this._indexCount),t._uLayerScale.IsUsed()&&t._uLayerScale.Update1f(r[6]),t._uLayerAngle.IsUsed()&&t._uLayerAngle.Update1f(r[7]),t._uSrcStart.IsUsed()&&t._uSrcStart.Update2f(r[12],r[13]),t._uSrcEnd.IsUsed()&&t._uSrcEnd.Update2f(r[14],r[15]),t._uSrcOriginStart.IsUsed()&&t._uSrcOriginStart.Update2f(s[0],s[1]),t._uSrcOriginEnd.IsUsed()&&t._uSrcOriginEnd.Update2f(s[2],s[3]),t._uLayoutStart.IsUsed()&&t._uLayoutStart.Update2f(a[0],a[1]),t._uLayoutEnd.IsUsed()&&t._uLayoutEnd.Update2f(a[2],a[3]),t._uSeconds.IsUsed()&&t._uSeconds.Update1f(this._startIndex)}InitSetProgramCustomParameters(){this._type=BATCH_SETPROGRAMCUSTOMPARAMETERS}DoSetProgramCustomParameters(){const t=this._batchState.currentShader,r=t._uCustomParameters,a=this._shaderParams;for(let t=0,e=r.length;t<e;++t){const s=r[t],i=a[t];s.IsColorType()?s.Update3f(i.getR(),i.getG(),i.getB()):s.Update1f(i)}}InitInvalidateFramebuffer(t){this._type=BATCH_INVALIDATEFRAMEBUFFER,this._texParam=t}DoInvalidateFramebuffer(){const t=this._gl,e=this._texParam,r=this._batchState.currentFramebuffer;e!==r&&t.bindFramebuffer(t.FRAMEBUFFER,e),t.invalidateFramebuffer(t.FRAMEBUFFER,[t.COLOR_ATTACHMENT0]),e!==r&&t.bindFramebuffer(t.FRAMEBUFFER,r)}InitBlitFramebuffer(t,e,r){this._type=BATCH_BLITFRAMEBUFFER;const a=this._mat4param,s=this._batchState.renderer,i=(a[0]=t.GetWidth(),a[1]=t.GetHeight(),a[2]=(e||s).GetWidth(),a[3]=(e||s).GetHeight(),a[4]=t.IsLinearSampling()?1:0,a[5]="stretch"===r,this._shaderParams);C3.clearArray(i),i.push(t._GetFramebuffer()),i.push(e?e._GetFramebuffer():null)}DoBlitFramebuffer(){const t=this._mat4param,e=this._shaderParams,r=this._gl,a=t[0],s=t[1],i=t[2],n=t[3],o=0!==t[4],_=0!==t[5],h=e[0],S=e[1];if(r.bindFramebuffer(r.READ_FRAMEBUFFER,h),r.bindFramebuffer(r.DRAW_FRAMEBUFFER,S),_)r.blitFramebuffer(0,0,a,s,0,0,i,n,r.COLOR_BUFFER_BIT,o?r.LINEAR:r.NEAREST);else{const T=Math.min(a,i),u=Math.min(s,n),d=Math.max(s-n,0),E=Math.max(n-s,0);r.blitFramebuffer(0,d,T,u+d,0,E,T,u+E,r.COLOR_BUFFER_BIT,r.NEAREST)}}InitStartQuery(t){this._type=BATCH_STARTQUERY,this._texParam=t}DoStartQuery(){this._texParam.BeginTimeElapsed(),this._texParam=null}InitEndQuery(t){this._type=BATCH_ENDQUERY,this._texParam=t}DoEndQuery(){this._texParam.EndTimeElapsed(),this._texParam=null}InitSetEllipseParams(t,e,r){this._type=BATCH_SETELLIPSEPARAMS;const a=this._mat4param;a[0]=t,a[1]=e,a[2]=r}DoSetEllipseParams(){const t=this._batchState.currentShader,e=this._mat4param;t._uPixelSize.IsUsed()&&t._uPixelSize.Update2f(e[0],e[1]),t._uOutlineThickness.IsUsed()&&t._uOutlineThickness.Update1f(e[2])}InitSetTilemapInfo(t,e,r,a,s,i,n){this._type=BATCH_SETTILEMAPINFO;const o=this._mat4param;t.writeToTypedArray(o,0),o[4]=1/e,o[5]=1/r,o[6]=a/e,o[7]=s/r,o[8]=i/e,o[9]=n/r}DoSetTilemapInfo(){const t=this._batchState.currentShader,e=this._mat4param;t._uSrcStart.IsUsed()&&t._uSrcStart.Update2f(e[0],e[1]),t._uPixelSize.IsUsed()&&t._uPixelSize.Update2f(e[4],e[5]),t._uTileSize.IsUsed()&&t._uTileSize.Update2f(e[6],e[7]),t._uTileSpacing.IsUsed()&&t._uTileSpacing.Update2f(e[8],e[9])}InitSetTileRandomizationInfo(t,e,r,a,s,i,n){this._type=BATCH_SETTILERANDOMIZATIONINFO;const o=this._mat4param;o[0]=1/t,o[1]=1/e,o[2]=r,o[3]=a,o[4]=s,o[5]=i,o[6]=n}DoSetTileRandomizationInfo(){const t=this._batchState.currentShader,e=this._mat4param;t._uPixelSize.IsUsed()&&t._uPixelSize.Update2f(e[0],e[1]),t._uTileSize.IsUsed()&&t._uTileSize.Update2f(e[2],e[3]),t._uOutlineThickness.IsUsed()&&t._uOutlineThickness.Update1f(e[4]),t._uTileSpacing.IsUsed()&&t._uTileSpacing.Update2f(e[5],e[6])}InitClearDepth(t){this._type=BATCH_CLEARDEPTH,this._startIndex=t?1:0}DoClearDepth(){const t=this._gl,e=0!==this._startIndex;e||t.depthMask(!0),t.clear(t.DEPTH_BUFFER_BIT),e||t.depthMask(!1)}InitSetDepthEnabled(t){this._type=BATCH_SETDEPTHENABLED,this._startIndex=t?1:0}DoSetDepthEnabled(){const t=this._gl;0===this._startIndex?(t.disable(t.DEPTH_TEST),t.depthMask(!1)):(t.enable(t.DEPTH_TEST),t.depthMask(!0))}InitSetDepthSamplingEnabled(t){this._type=BATCH_SETDEPTHSAMPLINGENABLED,this._startIndex=t?1:0}DoSetDepthSamplingEnabled(){const t=this._gl,e=this._batchState,r=e.renderer,a=0!==this._startIndex;e.isDepthSamplingEnabled=a,t.activeTexture(t.TEXTURE2),a?(e.currentFramebufferNoDepth&&t.bindFramebuffer(t.FRAMEBUFFER,e.currentFramebufferNoDepth),t.bindTexture(t.TEXTURE_2D,r._GetDepthBuffer())):(t.bindTexture(t.TEXTURE_2D,null),e.currentFramebufferNoDepth&&t.bindFramebuffer(t.FRAMEBUFFER,e.currentFramebuffer)),t.activeTexture(t.TEXTURE0)}InitCoplanarStartStencilPass(){this._type=BATCH_COPLANAR_STARTSTENCILPASS}DoCoplanarStartStencilPass(){const t=this._gl;t.clear(t.STENCIL_BUFFER_BIT),t.enable(t.STENCIL_TEST),t.stencilFunc(t.ALWAYS,1,1),t.stencilOp(t.KEEP,t.KEEP,t.REPLACE),t.colorMask(!1,!1,!1,!1)}InitCoplanarStartColorPass(){this._type=BATCH_COPLANAR_STARTCOLORPASS}DoCoplanarStartColorPass(){const t=this._gl;t.colorMask(!0,!0,!0,!0),t.stencilFunc(t.EQUAL,1,1),t.stencilOp(t.KEEP,t.KEEP,t.KEEP)}InitCoplanarRestore(){this._type=BATCH_COPLANAR_RESTORE}DoCoplanarRestore(){const t=this._gl;t.disable(t.STENCIL_TEST)}InitSetScissor(t,e,r,a,s){this._type=BATCH_SET_SCISSOR,this._startIndex=t?1:0;const i=this._mat4param;i[0]=e,i[1]=r,i[2]=a,i[3]=s}DoSetScissor(){const t=this._gl,e=this._mat4param;1===this._startIndex?(t.enable(t.SCISSOR_TEST),t.scissor(e[0],e[1],e[2],e[3])):t.disable(t.SCISSOR_TEST)}Run(){switch(this._type){case 1:return void this.DoQuad();case 2:return void this.DoSetTexture();case 3:return void this.DoSetColor();case 4:return void this.DoSetBlend();case 5:return void this.DoSetViewport();case 6:return void this.DoSetProjection();case 7:return void this.DoSetModelView();case 8:return void this.DoSetRenderTarget();case 9:return void this.DoClearSurface();case 10:return void this.DoPoints();case 11:return void this.DoSetProgram();case 12:return void this.DoSetProgramParameters();case 13:return void this.DoSetProgramCustomParameters();case 14:return void this.DoInvalidateFramebuffer();case 15:return void this.DoSetPointTextureCoords();case 16:return void this.DoSetTilemapInfo();case 17:return void this.DoBlitFramebuffer();case 18:return void this.DoStartQuery();case 19:return void this.DoEndQuery();case 20:return void this.DoSetEllipseParams();case 21:return void this.DoSetGradientColor();case 22:return void this.DoClearDepth();case 23:return void this.DoSetDepthEnabled();case 24:return void this.DoSetDepthSamplingEnabled();case 25:return void this.DoCoplanarStartStencilPass();case 26:return void this.DoCoplanarStartColorPass();case 27:return void this.DoCoplanarRestore();case 28:return void this.DoSetScissor();case 29:return void this.DoSetTileRandomizationInfo()}}}; } // ../lib/gfx/text.js { const C3=self.C3,MAX_TEXTURE_SIZE=4096,EXTRA_LINE_HEIGHT=4,GENERIC_FONT_FAMILIES=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),DEFAULT_OPTS={timeout:60},tempColor=new C3.Color(0,0,0,1),VALID_HORIZ_ALIGNMENTS=new Set(["left","center","right"]),VALID_VERT_ALIGNMENTS=new Set(["top","center","bottom"]),VALID_WORD_WRAP_MODES=new Set(["word","cjk","character"]),VALID_TEXT_DIRECTIONS=new Set(["ltr","rtl"]),allRendererTexts=new Set;function fillOrStrokeRect(t,e,i,s,a,n){e?t.strokeRect(i,s,a,n):t.fillRect(i,s,a,n)}function ptToPx(t){return t*(4/3)}function getOffsetParam(t,e){t=t.trim();const i=parseFloat(t);return isFinite(i)?t.endsWith("%")?e*i/100:i:0}C3.FontManager&&C3.FontManager.addEventListener("fontload",t=>{const e=t.font.GetName();for(const i of allRendererTexts)(i.IsBBCodeEnabled()||C3.equalsNoCase(i.GetFontName(),e))&&i._SetWordWrapChanged()});let didCheckFoundBoundingBoxSupport=!1,supportsFontBoundingBoxMeasurements=!1;C3.Gfx.RendererText=class{constructor(t,e){e=Object.assign({},DEFAULT_OPTS,e),this._renderer=t,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=C3.New(C3.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=t=>this._MeasureText(t),this._texture=null,this._rcTex=new C3.Rect,this._scaleFactor=1,this._textureTimeout=new C3.IdleTimeout(()=>{this.ReleaseTexture(),this._SetTextCanvasSize(8,8)},e.timeout),this.ontextureupdate=null,this._wasReleased=!1,allRendererTexts.add(this)}Release(){this.onloadfont=null,this._alreadyLoadedFonts.clear(),this._iconSet=null,this._bbString=null,this._textCanvas=null,this._textContext=null,this._measureContext=null,this._measureContextTop=null,this._measureTextCallback=null,this._textureTimeout.Release(),this.ontextureupdate=null,this.ReleaseTexture(),this._wrappedText.Clear(),this._wrappedText=null,this._renderer=null,this._wasReleased=!0,allRendererTexts.delete(this)}_SetDrawChanged(){this._drawChanged=!0}_SetTextLayoutChanged(){this._SetDrawChanged(),this._textLayoutChanged=!0}_SetWordWrapChanged(){this._SetTextLayoutChanged(),this._wordWrapChanged=!0}SetBBCodeEnabled(t){if(this._isBBcodeEnabled!==(t=!!t)){this._isBBcodeEnabled=t;const e=this._isBBcodeEnabled?"alphabetic":"top";this._textContext&&(this._textContext.textBaseline=e),this._measureContext&&(this._measureContext.textBaseline=e),this._SetWordWrapChanged()}}IsBBCodeEnabled(){return this._isBBcodeEnabled}SetIconSet(t){this._iconSet!==t&&(this._iconSet=t,this._wrappedText.SetIconSet(t),this._iconSet&&this._iconSet.IsLoading()&&this._iconSet.LoadContent().then(()=>this._SetDrawChanged()),this._SetWordWrapChanged())}SetIconSmoothing(t){this._iconSmoothing!==(t=!!t)&&(this._iconSmoothing=t,this._SetDrawChanged())}SetFontName(t){this._fontName!==(t=t||"serif")&&(this._fontName=t,this._SetWordWrapChanged())}GetFontName(){return this._fontName}SetFontSize(t){this._fontSize!==(t=t<.1?.1:t)&&(this._fontSize=t,this._SetWordWrapChanged())}GetFontSize(){return this._fontSize}SetFontSizeScale(t){this._fontSizeScale!==t&&(this._fontSizeScale=t,this._SetWordWrapChanged())}SetLineHeight(t){this._lineHeight!==t&&(this._lineHeight=t,this._SetTextLayoutChanged())}GetLineHeight(){return this._lineHeight}SetBold(t){this._isBold!==(t=!!t)&&(this._isBold=t,this._SetWordWrapChanged())}IsBold(){return this._isBold}SetItalic(t){this._isItalic!==(t=!!t)&&(this._isItalic=t,this._SetWordWrapChanged())}IsItalic(){return this._isItalic}SetDrawMaxCharacterCount(t){t=Math.floor(t),this._drawMaxCharCount!==t&&(this._drawMaxCharCount=t,this._SetDrawChanged())}GetDrawMaxCharacterCount(){return this._drawMaxCharCount}_GetFontString(t,e){let i=[];(this._isBold||e.HasStyleTag("b"))&&i.push("bold"),(this._isItalic||e.HasStyleTag("i"))&&i.push("italic");const s=e.GetStyleTag("size"),a=(s?parseFloat(s.param):this._fontSize)*this._fontSizeScale;i.push(t?a+"pt":a*this.GetDrawScale()+"pt");let n=this._fontName;const h=e.GetStyleTag("font");return h&&h.param&&(n=h.param,this.onloadfont)&&!this._alreadyLoadedFonts.has(n)&&(this.onloadfont(n),this._alreadyLoadedFonts.add(n)),n&&(GENERIC_FONT_FAMILIES.has(n)?i.push(n):i.push('"'+n+'"')),i.join(" ")}SetColor(t){t instanceof C3.Color&&(t=t.getCssRgb()),this._colorStr!==t&&(this._colorStr=t,this._SetDrawChanged())}SetColorRgb(t,e,i){tempColor.setRgb(t,e,i),this.SetColor(tempColor)}SetHorizontalAlignment(t){if(!VALID_HORIZ_ALIGNMENTS.has(t))throw new Error("invalid horizontal alignment");this._horizontalAlign!==t&&(this._horizontalAlign=t,this._SetTextLayoutChanged())}GetHorizontalAlignment(){return this._horizontalAlign}SetVerticalAlignment(t){if(!VALID_VERT_ALIGNMENTS.has(t))throw new Error("invalid vertical alignment");this._verticalAlign!==t&&(this._verticalAlign=t,this._SetTextLayoutChanged())}GetVerticalAlignment(){return this._verticalAlign}SetWordWrapMode(t){if(!VALID_WORD_WRAP_MODES.has(t))throw new Error("invalid word wrap mode");this._wrapMode!==t&&(this._wrapMode=t,this._SetWordWrapChanged())}GetWordWrapMode(){return this._wrapMode}SetTextDirection(t){if(!VALID_TEXT_DIRECTIONS.has(t))throw new Error("invalid text direction");this._textDirection!==t&&(this._textDirection=t,this._textContext&&(this._textContext.direction=this._textDirection),this._measureContext&&(this._measureContext.direction=this._textDirection),this._SetWordWrapChanged())}GetTextDirection(){return this._textDirection}SetText(t){this._text!==t&&(this._text=t,this._SetWordWrapChanged())}GetText(){return this._text}GetDrawScale(){return this._scaleFactor*this._zoom*self.devicePixelRatio}SetSize(e,i,s){if(void 0===s&&(s=1),!(e<=0||this._cssWidth===e&&this._cssHeight===i&&this._zoom===s)){const a=this._cssWidth,n=(this._cssWidth=e,this._cssHeight=i,this._zoom=s,self.devicePixelRatio),h=(this._width=this._cssWidth*this._zoom*n,this._height=this._cssHeight*this._zoom*n,Math.max(this._width,this._height)),o=Math.min(this._renderer.GetMaxTextureSize(),MAX_TEXTURE_SIZE);let t=1;o<h&&(t=o/h,this._width=Math.min(this._width*t,o),this._height=Math.min(this._height*t,o)),this._scaleFactor=t,this._cssWidth!==a?this._SetWordWrapChanged():this._SetTextLayoutChanged()}}GetWidth(){return this._width}GetHeight(){return this._height}GetZoom(){return this._zoom}GetTextWidth(){return this._UpdateTextMeasurements(),this._wrappedText.GetMaxLineWidth()}GetTextHeight(){return this._UpdateTextMeasurements(),this._wrappedText.GetTotalLineHeight()+this._wrappedText.GetLineCount()*(this._lineHeight+EXTRA_LINE_HEIGHT)-this._lineHeight}GetLengthInGraphemes(){this._UpdateTextMeasurements();let t=0;for(const e of this._wrappedText.GetLines())for(const i of e.fragments())t+=i.GetLength();return t}GetTexture(){return this._textureTimeout.Reset(),this._MaybeUpdate(),this._texture}HitTestFragment(t,e){this._UpdateTextMeasurements();const i=this.GetDrawScale(),s=this._wrappedText.GetLines();for(const a of s){const n=a.GetFontBoundingBoxDescent()*i;if(e>=a.GetPosY()-a.GetHeight()*i+n&&e<a.GetPosY()+n)for(const h of a.fragments())if(t>=h.GetPosX()&&t<h.GetPosX()+h.GetWidth()*i)return h}return null}*fragmentsWithTag(t){this._UpdateTextMeasurements();const e=this._wrappedText.GetLines();for(const i of e)for(const s of i.fragments()){const a=s.GetStyleTag("tag");a&&C3.equalsNoCase(a.param,t)&&(yield s)}}FindFragmentWithTag(t,e){for(const i of this.fragmentsWithTag(t)){if(0===e)return i;--e}return null}CountFragmentsWithTag(t){let e=0;for(const i of this.fragmentsWithTag(t))++e;return e}_MaybeUpdate(){this._texture&&!this._drawChanged&&!this._textLayoutChanged&&!this._wordWrapChanged||this._wasReleased||this._width<=0||this._height<=0||(this._drawChanged=!1,this._DoUpdate())}_DoUpdate(){this._wasReleased||(this._UpdateTextMeasurements(),this._SetTextCanvasSize(Math.max(C3.nextHighestPowerOfTwo(Math.ceil(this._width)),128),Math.max(C3.nextHighestPowerOfTwo(Math.ceil(this._height)),64)),this._DrawTextToCanvas(),this._UpdateTexture(),this._textureTimeout.Reset())}_SetTextCanvasSize(t,e){this._textCanvas||(this._textCanvas=C3.CreateCanvas(16,16));let i=!1;this._lastCanvasWidth===t&&this._lastCanvasHeight===e||(this._lastCanvasWidth=t,this._lastCanvasHeight=e,this._textCanvas.width=t,this._textCanvas.height=e,i=!0),this._textContext||(this._textContext=this._textCanvas.getContext("2d"),i=!0),i?(this._textContext.textBaseline=this._isBBcodeEnabled?"alphabetic":"top",this._textContext.direction=this._textDirection,this._textContext.font=this._lastTextCanvasFont,this._textContext.fillStyle=this._lastTextCanvasFillStyle,this._textContext.strokeStyle=this._lastTextCanvasFillStyle,this._textContext.globalAlpha=this._lastTextCanvasOpacity,this._textContext.lineWidth=this._lastTextCanvasLineWidth):this._textContext.clearRect(0,0,t,e)}_MaybeCreateMeasureContext(){this._measureContext||(this._measureContext=C3.CreateCanvas(16,16).getContext("2d"),this._measureContextTop=C3.CreateCanvas(16,16).getContext("2d"),this._measureContext.textBaseline=this._isBBcodeEnabled?"alphabetic":"top",this._measureContextTop.textBaseline="top",this._measureContext.direction=this._textDirection,this._measureContextTop.direction=this._textDirection)}_SetMeasureFontString(t){this._lastMeasureCanvasFont!==t&&(this._lastMeasureCanvasFont=t,this._measureContext.font=t,this._measureContextTop.font=t)}_SupportsFontBoundingBoxMeasurements(){if(!didCheckFoundBoundingBoxSupport){didCheckFoundBoundingBoxSupport=!0,this._MaybeCreateMeasureContext();const t=this._measureContext.measureText("test");supportsFontBoundingBoxMeasurements="number"==typeof t["fontBoundingBoxAscent"]&&"number"==typeof t["fontBoundingBoxDescent"]}return supportsFontBoundingBoxMeasurements}_UpdateTextMeasurements(){this._UpdateWordWrap(),this._UpdateTextLayout()}_UpdateWordWrap(){this._wordWrapChanged&&(this._MaybeCreateMeasureContext(),!this._isBBcodeEnabled||this._bbString&&this._bbString.toString()===this._text||(this._bbString=new C3.BBString(this._text,{noEscape:!0})),this._wrappedText.WordWrap(this._isBBcodeEnabled?this._bbString.toFragmentList():this._text,this._measureTextCallback,this._cssWidth,this._wrapMode,0),this._wordWrapChanged=!1)}_UpdateTextLayout(){this._textLayoutChanged&&(this._LayoutText(),this._textLayoutChanged=!1)}_MeasureText(t){const e=t.IsText()?t.GetCharacterArray().join(""):" ",i=(this._SetMeasureFontString(this._GetFontString(!0,t)),t.GetStyleTag("size")),s=(i?parseFloat(i.param):this._fontSize)*this._fontSizeScale,a=this._measureContext.measureText(e);let n=0;if(this._isBBcodeEnabled&&this._SupportsFontBoundingBoxMeasurements()){const h=this._measureContextTop.measureText(e);n=a["fontBoundingBoxAscent"]-h["fontBoundingBoxAscent"]}return{width:a.width,height:ptToPx(s),fontBoundingBoxAscent:a["fontBoundingBoxAscent"]||0,fontBoundingBoxDescent:a["fontBoundingBoxDescent"]||0,topToAlphabeticDistance:n}}_SetDrawFontString(t){this._lastTextCanvasFont!==t&&(this._lastTextCanvasFont=t,this._textContext.font=t)}_SetDrawCanvasColor(t){this._lastTextCanvasFillStyle!==t&&(this._lastTextCanvasFillStyle=t,this._textContext.fillStyle=t,this._textContext.strokeStyle=t)}_SetDrawCanvasOpacity(t){this._lastTextCanvasOpacity!==t&&(this._lastTextCanvasOpacity=t,this._textContext.globalAlpha=t)}_SetDrawCanvasLineWith(t){this._lastTextCanvasLineWidth!==t&&(this._lastTextCanvasLineWidth=t,this._textContext.lineWidth=t)}_LayoutText(){const s=this.GetDrawScale(),a=(EXTRA_LINE_HEIGHT+this._lineHeight)*s;let n=0;const h=this._wrappedText.GetLines();if(0!==h.length){for(const e of h){e.SetPosX(NaN),e.SetPosY(NaN);for(const o of e.fragments())o.SetPosX(NaN),o.SetPosY(NaN)}const t=this._isBBcodeEnabled&&this._SupportsFontBoundingBoxMeasurements();let i=h[0].GetHeight()*s;if("center"===this._verticalAlign){const r=h.reduce((t,e)=>t+e.GetHeight()*s+a,0)-a;n=Math.max(this._height/2-r/2,0),t&&(i=h[0].GetTopToAlphabeticDistance()*s)}else if("bottom"===this._verticalAlign){const _=h.reduce((t,e)=>t+e.GetHeight()*s+a,0)-this._lineHeight*s,l=t?h.at(-1).GetFontBoundingBoxDescent()*s:0;n=this._height-_-l-2}for(let t=0,e=h.length;t<e;++t){const d=h[t],x=d.GetHeight()*s,C=n;if(this._isBBcodeEnabled){if(n+=0===t?i:x,0<t&&n>this._height-EXTRA_LINE_HEIGHT*s)break}else if(0<t&&n>=this._height-x)break;0<=C&&this._LayoutTextLine(d,n,s),this._isBBcodeEnabled||(n+=x),n+=a}}}_LayoutTextLine(t,e,i){let s=0;"center"===this._horizontalAlign?s=Math.floor((this._width-t.GetWidth()*i)/2):"right"===this._horizontalAlign&&(s=this._width-t.GetWidth()*i),t.SetPosX(s),t.SetPosY(e);for(const a of"ltr"===this._textDirection?t.fragments():t.fragmentsReverse())this._LayoutFragment(a,s,e,i),s+=a.GetWidth()*i}_LayoutFragment(t,e,i,s){const a=t.GetStyleTag("offsetx"),n=(e+=a?getOffsetParam(a.param,t.GetHeight())*s:0,t.GetStyleTag("offsety"));if(i+=n?getOffsetParam(n.param,t.GetHeight())*s:0,t.IsIcon()){const h=t.GetStyleTag("iconoffsety");i+=h?getOffsetParam(h.param,t.GetHeight())*s:.2*t.GetHeight()*s}t.SetPosX(e),t.SetPosY(i)}_DrawTextToCanvas(){this._textContext.imageSmoothingEnabled=this._iconSmoothing,this._textContext.imageSmoothingQuality="high",this._drawCharCount=0;const t=this.GetDrawScale(),e=this._wrappedText.GetLines();for(const i of e)this._DrawTextLine(i,t)}_DrawTextLine(t,e){const i=t.GetPosX(),s=t.GetPosY();if(Number.isFinite(i)&&Number.isFinite(s))for(const a of"ltr"===this._textDirection?t.fragments():t.fragmentsReverse())this._DrawFragment(a,e,t.GetHeight())}_DrawFragment(i,s,a){const n=this._textContext,h=i.GetPosX(),o=i.GetPosY();if(Number.isFinite(h)&&Number.isFinite(o)){const r=a/16;let t=i.GetWidth()*s;const _=i.GetHeight()*s,l=i.GetHeight()/16,d=(EXTRA_LINE_HEIGHT+this._lineHeight)*s;let e=i.IsText()?i.GetCharacterArray():null;if(-1!==this._drawMaxCharCount){if(this._drawCharCount>=this._drawMaxCharCount)return;i.IsText()&&this._drawCharCount+e.length>this._drawMaxCharCount&&(e=e.slice(0,this._drawMaxCharCount-this._drawCharCount),t=this._MeasureText(i).width*s),this._drawCharCount+=i.GetLength()}const x=i.GetStyleTag("background"),C=i.HasStyleTag("u"),u=i.HasStyleTag("s");if((!i.IsText()||!C3.IsCharArrayAllWhitespace(e)||x||C||u)&&!i.HasStyleTag("hide")){const c=i.GetStyleTag("color"),g=i.GetStyleTag("opacity"),S=(this._SetDrawCanvasOpacity(g?parseFloat(g.param)/100:1),x&&(this._SetDrawCanvasColor(x.param),n.fillRect(h,o-_,t,_+d)),i.GetStyleTag("linethickness")),T=S?parseFloat(S.param):1,p=i.HasStyleTag("stroke");if(p&&this._SetDrawCanvasLineWith(.5*l*T*this.GetDrawScale()),i.IsText()){const f=e.join("");if(this._SetDrawFontString(this._GetFontString(!1,i)),!p){this._SetDrawCanvasLineWith(.5*l*T*this.GetDrawScale());const m=i.GetStyleTag("outlineback");m&&(this._SetDrawCanvasColor(m.param),this._FillOrStrokeText(!0,f,h,o,t))}if(this._SetDrawCanvasColor(c?c.param:this._colorStr),this._FillOrStrokeText(p,f,h,o,t),!p){this._SetDrawCanvasLineWith(.5*l*T*this.GetDrawScale());const w=i.GetStyleTag("outline");w&&(this._SetDrawCanvasColor(w.param),this._FillOrStrokeText(!0,f,h,o,t))}}else if(i.IsIcon()&&0<i.GetWidth()){const G=i.GetDrawable(this._iconSet);G&&n.drawImage(G,h,o-_,t,_)}if(this._SetDrawCanvasColor(c?c.param:this._colorStr),C&&fillOrStrokeRect(n,p,h,o+s*r,t,s*r*T),u){const B=o-_/4,W=s*l,D=B+W/2;n.fillRect(h,D-W*T/2,t,W*T)}}}}_FillOrStrokeText(t,e,i,s,a){"rtl"===this._textDirection&&(i+=a),t?"Gecko"===C3.Platform.BrowserEngine?this._textContext.strokeText(e,i,s,a):this._textContext.strokeText(e,i,s):"Gecko"===C3.Platform.BrowserEngine?this._textContext.fillText(e,i,s,a):this._textContext.fillText(e,i,s)}_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 t of allRendererTexts)t.ReleaseTexture()}static GetAll(){return allRendererTexts.values()}}; } // ../lib/gfx/webgl/query.js { const C3=self.C3;class WebGLRealTimeElapsedQuery{constructor(e){this._gl=e.GetContext(),this._version=e.GetWebGLVersionNumber(),this._timerExt=e._GetDisjointTimerQueryExtension(),this._query=null,this._isActive=!1,this._hasResult=!1,this._result=0,1===this._version?this._query=this._timerExt["createQueryEXT"]():this._query=this._gl["createQuery"]()}Release(){this._DeleteQueryObject(),this._gl=null,this._timerExt=null,this._hasResult=!1}_DeleteQueryObject(){this._query&&(1===this._version?this._timerExt["deleteQueryEXT"](this._query):this._gl["deleteQuery"](this._query),this._query=null)}BeginTimeElapsed(){if(this._isActive)throw new Error("query already active");1===this._version?this._timerExt["beginQueryEXT"](this._timerExt["TIME_ELAPSED_EXT"],this._query):this._gl["beginQuery"](this._timerExt["TIME_ELAPSED_EXT"],this._query),this._isActive=!0}EndTimeElapsed(){if(!this._isActive)throw new Error("query not active");1===this._version?this._timerExt["endQueryEXT"](this._timerExt["TIME_ELAPSED_EXT"]):this._gl["endQuery"](this._timerExt["TIME_ELAPSED_EXT"]),this._isActive=!1}CheckForResult(){if(this._query&&!this._hasResult&&!this._isActive){let e=!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)return this._result;throw new Error("no result available")}}C3.Gfx.WebGLTimeElapsedQuery=class{constructor(e){this._renderer=e,this._frameNumber=e.GetFrameNumber(),this._isActive=!1,this._parentQuery=null,this._isNested=!1,this._realQuery=null,this._queries=[]}Release(){for(const e of this._queries)e instanceof WebGLRealTimeElapsedQuery&&e.Release();C3.clearArray(this._queries),this._parentQuery=null,this._realQuery=null,this._renderer=null}BeginTimeElapsed(){if(this._isActive)throw new Error("query already active");const e=this._renderer._GetTimeQueryStack();0<e.length?(this._isNested=!0,this._parentQuery=e.at(-1),this._parentQuery._EndReal(),this._parentQuery._queries.push(this)):(this._isNested=!1,this._parentQuery=null),this._isActive=!0,e.push(this),this._StartReal()}EndTimeElapsed(){if(!this._isActive)throw new Error("query not active");const e=this._renderer._GetTimeQueryStack().pop();if(e!==this)throw new Error("can only end most nested query");this._isActive=!1,this._EndReal(),this._parentQuery&&(this._parentQuery._StartReal(),this._parentQuery=null)}_StartReal(){this._realQuery=C3.New(WebGLRealTimeElapsedQuery,this._renderer),this._queries.push(this._realQuery),this._realQuery.BeginTimeElapsed()}_EndReal(){this._realQuery.EndTimeElapsed(),this._realQuery=null}CheckForResult(){for(const e of this._queries)e.CheckForResult()}IsNested(){return this._isNested}HasResult(){return this._queries.every(e=>e.HasResult())}GetResult(){return this._queries.reduce((e,t)=>e+t.GetResult(),0)}GetFrameNumber(){return this._frameNumber}}; } // ../lib/gfx/webgl/queryResultBuffer.js { const C3=self.C3;C3.Gfx.WebGLQueryResultBuffer=class{constructor(e,r=1e3){this._renderer=e,this._maxQueries=r,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();C3.clearArray(this._buffer)}AddTimeElapsedQuery(){const e=new C3.Gfx.WebGLTimeElapsedQuery(this._renderer);if(this._buffer.push(e),this._buffer.length>this._maxQueries){const r=this._buffer.shift();r.Release()}return e}CheckForResults(e){for(const r of this._buffer){if(r.GetFrameNumber()>=e)return;if(r.IsNested())return;r.CheckForResult()}}GetFrameRangeResultSum(e,r){if(r<=e)return NaN;let t=0;for(const s of this._buffer){if(s.GetFrameNumber()>=r)break;if(!(s.GetFrameNumber()<e)){if(!s.HasResult())return NaN;t+=s.GetResult()}}return t}DeleteAllBeforeFrameNumber(t){for(let e=0,r=this._buffer.length;e<r;++e){const s=this._buffer[e];if(!(s.GetFrameNumber()<t))return void(0<e&&this._buffer.splice(0,e));s.Release()}}}; } // ../lib/gfx/webgl/webglRenderer.js { const C3=self.C3,assert=self.assert,glMatrix=self.glMatrix,vec3=glMatrix.vec3,vec4=glMatrix.vec4,mat4=glMatrix.mat4,DEFAULT_WEBGLRENDERER_OPTS={powerPreference:"default",enableGpuProfiling:!0,alpha:!1,depth:!1,canSampleDepth:!1,maxWebGLVersion:2,failIfMajorPerformanceCaveat:!1},VALID_POWER_PREFERENCES=new Set(["default","low-power","high-performance"]),MAX_VERTICES=8e3,MAX_INDICES=MAX_VERTICES/2*3,MAX_POINTS=8e3,LAST_POINT=MAX_POINTS-4,PARTIAL_TEXTURE_UPLOAD_CHUNK_SIZE=262144,defaultTexCoordsQuad=new C3.Quad(0,0,1,0,1,1,0,1),tmpProjection=mat4.create(),tmpModelView=mat4.create(),tmpQuad=new C3.Quad,tmpRect=new C3.Rect;let loseContextExtension=null;C3.isDebug&&(self.debug_lose_webgl_context=function(){loseContextExtension?loseContextExtension.loseContext():console.warn("WEBGL_lose_context not supported")},self.debug_restore_webgl_context=function(){loseContextExtension?loseContextExtension.restoreContext():console.warn("WEBGL_lose_context not supported")});const pendingPolls=new Set;let pollRafId=-1;function CheckPendingPolls(){pollRafId=-1;for(const t of pendingPolls)t.checkFunc()&&(t.resolve(),pendingPolls.delete(t));0<pendingPolls.size&&(pollRafId=self.requestAnimationFrame(CheckPendingPolls))}C3.Gfx.WebGLRenderer=class extends C3.Gfx.RendererBase{constructor(t,e){if(super(e),e=Object.assign({},DEFAULT_WEBGLRENDERER_OPTS,e),!VALID_POWER_PREFERENCES.has(e.powerPreference))throw new Error("invalid power preference");const r={"alpha":!!e.alpha,"depth":!1,"antialias":!1,"powerPreference":e.powerPreference,"failIfMajorPerformanceCaveat":!!e.failIfMajorPerformanceCaveat};let i=null,s=0;if(2<=e.maxWebGLVersion&&(i=t.getContext("webgl2",r),s=2),i||(i=t.getContext("webgl",r),s=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=s,this._viewport=vec4.create(),this._didChangeTransform=!1,this._bbProjectionMatrix=mat4.create(),this._usesDepthBuffer=!!e.depth,this._canSampleDepth=!(!e.depth||!e.canSampleDepth),this._isDepthEnabled=this._usesDepthBuffer,this._isDepthSamplingEnabled=!1,this._depthBuffer=null,this._isAutoSizeDepthBuffer=!0,this._depthBufferWidth=0,this._depthBufferHeight=0,this._vertexBuffer=null,this._texcoordBuffer=null,this._indexBuffer=null,this._pointBuffer=null,this._vertexData=new Float32Array(MAX_VERTICES*this.GetNumVertexComponents()),this._indexData=new Uint16Array(MAX_INDICES),this._texcoordData=new Float32Array(2*MAX_VERTICES),this._pointData=new Float32Array(4*MAX_POINTS),this._vertexPtr=0,this._texPtr=0,this._pointPtr=0,this._lastVertexPtr=0,this._lastProgram=null,this._spDeviceTransformTextureFill=null,this._batch=[],this._batchPtr=0,this._topOfBatch=0,this._currentRenderTarget=null,this._lastPointZ=0,this._batchState=C3.New(C3.Gfx.BatchState,this),this._lastColor=C3.New(C3.Color,1,1,1,1),this._lastTexture0=null,this._lastTexture1=null,this._lastSrcBlend=0,this._lastDestBlend=0,this._lastPointTexCoords=new C3.Rect,this._lastScissorRect=C3.New(C3.Rect,0,0,-1,-1),this._coplanarMode=0,this._maxTextureSize=-1,this._minPointSize=0,this._maxPointSize=0,this._highpPrecision=0,this._unmaskedVendor="(unavailable)",this._unmaskedRenderer="(unavailable)",this._extensions=[],this._isInitialisingAfterContextRestored=!1,this._parallelShaderCompileExt=null,this._anisotropicExt=null,this._depthTextureExt=null,this._fragDepthExt=null,this._stdDerivativesExt=null,this._textureLodExt=null,this._maxAnisotropy=0,this._isGpuProfilingEnabled=!!e.enableGpuProfiling,this._timerExt=null,this._allQueryResultBuffers=new Set,this._timeQueryStack=[],this.FillIndexBufferData(this._indexData)}IsWebGL(){return!0}async InitState(){super.InitState();const t=this._gl,e=this.GetNumVertexComponents(),r=(this._lastColor.setRgba(1,1,1,1),this._lastTexture0=null,this._lastTexture1=null,this._vertexPtr=0,this._pointPtr=0,this._lastVertexPtr=MAX_VERTICES*e-4*e,C3.clearArray(this._batch),this._batchPtr=0,this._topOfBatch=0,this._lastProgram=null,this._currentRenderTarget=null,this._lastPointTexCoords.set(0,0,1,1),this._lastPointZ=0,this._batchState),i=(r.currentShader=null,r.currentFramebuffer=null,r.currentFramebufferNoDepth=null,vec4.set(r.currentColor,1,1,1,1),r.clearColor.setRgba(0,0,0,0),r.pointTexCoords.set(0,0,1,1),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.enable(t.BLEND),t.blendFunc(t.ONE,t.ONE_MINUS_SRC_ALPHA),this._lastSrcBlend=t.ONE,this._lastDestBlend=t.ONE_MINUS_SRC_ALPHA,this._InitBlendModes(t),t.disable(t.CULL_FACE),t.disable(t.STENCIL_TEST),t.disable(t.DITHER),this._usesDepthBuffer?(t.enable(t.DEPTH_TEST),t.depthMask(!0),t.depthFunc(t.LEQUAL)):(t.disable(t.DEPTH_TEST),t.depthMask(!1)),this._isDepthEnabled=this._usesDepthBuffer,this._isDepthSamplingEnabled=!1,this._pointBuffer=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,this._pointBuffer),t.bufferData(t.ARRAY_BUFFER,this._pointData.byteLength,t.DYNAMIC_DRAW),this._vertexBuffer=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,this._vertexBuffer),t.bufferData(t.ARRAY_BUFFER,this._vertexData.byteLength,t.DYNAMIC_DRAW),this._texcoordBuffer=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,this._texcoordBuffer),t.bufferData(t.ARRAY_BUFFER,this._texcoordData.byteLength,t.DYNAMIC_DRAW),this._indexBuffer=t.createBuffer(),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this._indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this._indexData,t.STATIC_DRAW),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,null),this._maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),t.getParameter(t.ALIASED_POINT_SIZE_RANGE)),s=(this._minPointSize=i[0],this._maxPointSize=i[1],t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT)),a=t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT),h=(this._highpPrecision=s&&a?Math.min(s["precision"],a["precision"]):0,2048<this._maxPointSize&&(this._maxPointSize=2048),this._extensions=t.getSupportedExtensions(),t.getExtension("WEBGL_debug_renderer_info"));if(h&&(this._unmaskedVendor=t.getParameter(h["UNMASKED_VENDOR_WEBGL"]),this._unmaskedRenderer=t.getParameter(h["UNMASKED_RENDERER_WEBGL"])),this._parallelShaderCompileExt=t.getExtension("KHR_parallel_shader_compile"),C3.isDebug&&(loseContextExtension=t.getExtension("WEBGL_lose_context")),this._isGpuProfilingEnabled&&(1===this.GetWebGLVersionNumber()?this._timerExt=t.getExtension("EXT_disjoint_timer_query"):this._timerExt=t.getExtension("EXT_disjoint_timer_query_webgl2")||t.getExtension("EXT_disjoint_timer_query")),this._anisotropicExt=t.getExtension("EXT_texture_filter_anisotropic"),this._anisotropicExt?this._maxAnisotropy=t.getParameter(this._anisotropicExt["MAX_TEXTURE_MAX_ANISOTROPY_EXT"]):this._maxAnisotropy=0,this.GetWebGLVersionNumber()<2&&this._usesDepthBuffer&&this._canSampleDepth&&(this._depthTextureExt=t.getExtension("WEBGL_depth_texture"),!this._depthTextureExt))throw new Error("no depth texture support");this.GetWebGLVersionNumber()<2&&(this._fragDepthExt=t.getExtension("EXT_frag_depth"),this._stdDerivativesExt=t.getExtension("OES_standard_derivatives"),this._textureLodExt=t.getExtension("EXT_shader_texture_lod"));const n=C3.Gfx.WebGLShaderProgram,o=n.GetDefaultVertexShaderSource(!1);let l=n.GetTextureFillFragmentShaderSource_WebGL1_NoFragDepth(),_=o,u=n.GetPointFragmentShaderSource_WebGL1_NoFragDepth(),d=n.GetPointVertexShaderSource_WebGL1(),c=n.GetTilemapFragmentShaderSource_WebGL1_NoFragDepth(),f=n.GetDefaultVertexShaderSource(!0),p=!1;this._usesDepthBuffer&&(this.GetWebGLVersionNumber()<2?this._fragDepthExt&&(l=n.GetTextureFillFragmentShaderSource_WebGL1_FragDepthEXT(),u=n.GetPointFragmentShaderSource_WebGL1_FragDepthEXT(),c=n.GetTilemapFragmentShaderSource_WebGL1_FragDepthEXT(),p=!0):(_=n.GetDefaultVertexShaderSource_WebGL2(),l=n.GetTextureFillFragmentShaderSource_WebGL2(),u=n.GetPointFragmentShaderSource_WebGL2(),d=n.GetPointVertexShaderSource_WebGL2(),c=n.GetTilemapFragmentShaderSource_WebGL2(),f=n.GetDefaultVertexShaderSource_WebGL2(!0)));const x=n.GetTileRandomizationFragmentShaderSource(this.GetWebGLVersionNumber(),p,this._stdDerivativesExt&&this._textureLodExt),E=2<=this.GetWebGLVersionNumber()?n.GetDefaultVertexShaderSource_WebGL2():o,S=[[l,_,"<default>"],[l,_,"<default-device-transform>"],[u,d,"<point>"],[n.GetColorFillFragmentShaderSource(),o,"<fill>"],[n.GetLinearGradientFillFragmentShaderSource(),o,"<lineargradient>"],[n.GetPenumbraFillFragmentShaderSource(),o,"<penumbra>"],[n.GetHardEllipseFillFragmentShaderSource(),o,"<hardellipse>"],[n.GetHardEllipseOutlineFragmentShaderSource(),o,"<hardellipseoutline>"],[n.GetSmoothEllipseFillFragmentShaderSource(),o,"<smoothellipse>"],[n.GetSmoothEllipseOutlineFragmentShaderSource(),o,"<smoothellipseoutline>"],[n.GetSmoothLineFillFragmentShaderSource(),o,"<smoothline>"],[c,f,"<tilemap>"],[x,E,"<tilerandomization>"]],T=await Promise.all(S.map(t=>this.CreateShaderProgram({src:t[0],vertexSrc:t[1],name:t[2]})));this._spTextureFill=T[0],this._spDeviceTransformTextureFill=T[1],this._spPoints=T[2],this._spColorFill=T[3],this._spLinearGradientFill=T[4],this._spPenumbraFill=T[5],this._spHardEllipseFill=T[6],this._spHardEllipseOutline=T[7],this._spSmoothEllipseFill=T[8],this._spSmoothEllipseOutline=T[9],this._spSmoothLineFill=T[10],this._spTilemapFill=T[11],this._spTileRandomization=T[12],this.SetTextureFillMode()}async CreateShaderProgram(t){const e=await C3.Gfx.WebGLShaderProgram.Create(this,t);return this._AddShaderProgram(e),e}ResetLastProgram(){this._lastProgram=null}SetSize(t,e,r){if(this._width!==t||this._height!==e||r){this.EndBatch();const i=this._gl,s=this._batchState;this._width=t,this._height=e,this._SetViewport(0,0,t,e),this.CalculatePerspectiveMatrix(this._bbProjectionMatrix,t/e),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,s.currentFramebuffer=null,s.currentFramebufferNoDepth=null}}_SetDepthBufferSize(t,e){const r=this._gl;this._depthBuffer&&this._depthBufferWidth===t&&this._depthBufferHeight===e||(this._canSampleDepth?(this._depthBuffer&&r.deleteTexture(this._depthBuffer),this._depthBuffer=r.createTexture(),r.bindTexture(r.TEXTURE_2D,this._depthBuffer),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),2<=this.GetWebGLVersionNumber()?r.texImage2D(r.TEXTURE_2D,0,r.DEPTH24_STENCIL8,t,e,0,r.DEPTH_STENCIL,r.UNSIGNED_INT_24_8,null):this._depthTextureExt&&r.texImage2D(r.TEXTURE_2D,0,r.DEPTH_STENCIL,t,e,0,r.DEPTH_STENCIL,this._depthTextureExt["UNSIGNED_INT_24_8_WEBGL"],null),r.bindTexture(r.TEXTURE_2D,null)):(this._depthBuffer&&r.deleteRenderbuffer(this._depthBuffer),this._depthBuffer=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,this._depthBuffer),r.renderbufferStorage(r.RENDERBUFFER,2<=this._version?r.DEPTH24_STENCIL8:r.DEPTH_STENCIL,t,e),r.bindRenderbuffer(r.RENDERBUFFER,null)),this._depthBufferWidth=t,this._depthBufferHeight=e)}SetFixedSizeDepthBuffer(t,e){this._usesDepthBuffer&&(this._isAutoSizeDepthBuffer=!1,this._SetDepthBufferSize(t,e))}SetAutoSizeDepthBuffer(){this._usesDepthBuffer&&(this._isAutoSizeDepthBuffer=!0,this._SetDepthBufferSize(this._width,this._height))}_SetViewport(t,e,r,i){const s=this._viewport;if(s[0]!==t||s[1]!==e||s[2]!==r||s[3]!==i){const a=this.PushBatch();a.InitSetViewport(t,e,r,i),vec4.set(s,t,e,r,i),this._topOfBatch=0}}SetFovY(t){super.SetFovY(t),this.CalculatePerspectiveMatrix(this._bbProjectionMatrix,this._width/this._height)}SetNearZ(t){super.SetNearZ(t),this.CalculatePerspectiveMatrix(this._bbProjectionMatrix,this._width/this._height)}SetFarZ(t){super.SetFarZ(t),this.CalculatePerspectiveMatrix(this._bbProjectionMatrix,this._width/this._height)}SetProjectionMatrix(t){if(!mat4.exactEquals(this._matP,t)){const e=this.PushBatch();e.InitSetProjection(t),mat4.copy(this._matP,t),this._topOfBatch=0,this._didChangeTransform=!0}}SetDefaultRenderTargetProjectionState(){let t,e,r;const i=this._currentRenderTarget;r=(null===i?(t=this._bbProjectionMatrix,e=this.GetWidth(),this):(t=i.GetProjectionMatrix(),e=i.GetWidth(),i)).GetHeight(),this.SetProjectionMatrix(t),this._SetViewport(0,0,e,r)}SetModelViewMatrix(t){if(!mat4.exactEquals(this._matMV,t)){const e=this.PushBatch();e.InitSetModelView(t),mat4.copy(this._matMV,t),this._topOfBatch=0,this._didChangeTransform=!0}}ResetDidChangeTransformFlag(){this._didChangeTransform=!1}DidChangeTransform(){return this._didChangeTransform}GetBatchState(){return this._batchState}PushBatch(){const t=this._batch;return this._batchPtr===t.length&&t.push(new C3.Gfx.WebGLBatchJob(this._batchState)),t[this._batchPtr++]}EndBatch(){0===this._batchPtr||this.IsContextLost()||(this._WriteBuffers(),this._ExecuteBatch(),this._batchPtr=0,this._vertexPtr=0,this._texPtr=0,this._pointPtr=0,this._topOfBatch=0)}_WriteBuffers(){const t=this._gl;0<this._pointPtr&&(t.bindBuffer(t.ARRAY_BUFFER,this._pointBuffer),t.bufferSubData(t.ARRAY_BUFFER,0,this._pointData.subarray(0,this._pointPtr))),0<this._vertexPtr&&(t.bindBuffer(t.ARRAY_BUFFER,this._vertexBuffer),t.bufferSubData(t.ARRAY_BUFFER,0,this._vertexData.subarray(0,this._vertexPtr)),t.bindBuffer(t.ARRAY_BUFFER,this._texcoordBuffer),t.bufferSubData(t.ARRAY_BUFFER,0,this._texcoordData.subarray(0,this._texPtr)))}_ExecuteBatch(){const r=this._batch;for(let t=0,e=this._batchPtr;t<e;++t)r[t].Run()}GetOpacity(){return this._lastColor.getA()}SetColorRgba(t,e,r,i){const s=this._lastColor;if(!s.equalsRgba(t,e,r,i)){s.setRgba(t,e,r,i);const a=this.PushBatch();a.InitSetColor(s),this._topOfBatch=0,this._currentStateGroup=null}}SetOpacity(t){const e=this._lastColor;if(e.getA()!==t){e.setA(t);const r=this.PushBatch();r.InitSetColor(e),this._topOfBatch=0,this._currentStateGroup=null}}SetColor(t){const e=this._lastColor;if(!e.equals(t)){e.set(t);const r=this.PushBatch();r.InitSetColor(e),this._topOfBatch=0,this._currentStateGroup=null}}ResetColor(){this.SetColorRgba(1,1,1,1)}GetColor(){return this._lastColor}SetTexture(t){if(t!==this._lastTexture0){const e=this.PushBatch();e.InitSetTexture(t),this._lastTexture0=t,this._topOfBatch=0}}_ResetLastTexture(){this._lastTexture0=null}SetBlendMode(t){const e=this._GetBlendByIndex(t);this._SetBlend(e[0],e[1])}SetNamedBlendMode(t){const e=this.GetNamedBlend(t);this._SetBlend(e.srcBlend,e.destBlend)}_SetBlend(t,e){if(t!==this._lastSrcBlend||e!==this._lastDestBlend){const r=this.PushBatch();r.InitSetBlend(t,e),this._lastSrcBlend=t,this._lastDestBlend=e,this._topOfBatch=0,this._currentStateGroup=null}}IsPremultipliedAlphaBlend(){return this._lastSrcBlend===this._gl.ONE&&this._lastDestBlend===this._gl.ONE_MINUS_SRC_ALPHA}SetAlphaBlend(){this._SetBlend(this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA)}SetNoPremultiplyAlphaBlend(){this._SetBlend(this._gl.SRC_ALPHA,this._gl.ONE_MINUS_SRC_ALPHA)}SetCopyBlend(){this._SetBlend(this._gl.ONE,this._gl.ZERO)}Rect(t){this.Rect2(t.getLeft(),t.getTop(),t.getRight(),t.getBottom())}Rect2(t,e,r,i){this.Quad2(t,e,r,e,r,i,t,i)}_ExtendQuadBatch(){let t=this._vertexPtr;if(t>=this._lastVertexPtr&&(this.EndBatch(),t=0),1===this._topOfBatch)this._batch[this._batchPtr-1]._indexCount+=6;else{const e=this.PushBatch();e.InitQuad(t,6),this._topOfBatch=1}}_WriteQuadToVertexBuffer(t){t.writeToTypedArray3D(this._vertexData,this._vertexPtr,this._baseZ+this._currentZ),this._vertexPtr+=12}Quad(t){this._ExtendQuadBatch(),this._WriteQuadToVertexBuffer(t),defaultTexCoordsQuad.writeToTypedArray(this._texcoordData,this._texPtr),this._texPtr+=8}Quad2(t,e,r,i,s,a,h,n){this._ExtendQuadBatch();const o=this._vertexData;let l=this._vertexPtr;const _=this._baseZ+this._currentZ;o[l++]=t,o[l++]=e,o[l++]=_,o[l++]=r,o[l++]=i,o[l++]=_,o[l++]=s,o[l++]=a,o[l++]=_,o[l++]=h,o[l++]=n,o[l++]=_,this._vertexPtr=l,defaultTexCoordsQuad.writeToTypedArray(this._texcoordData,this._texPtr),this._texPtr+=8}Quad3(t,e){this._ExtendQuadBatch(),this._WriteQuadToVertexBuffer(t),e.writeAsQuadToTypedArray(this._texcoordData,this._texPtr),this._texPtr+=8}Quad4(t,e){this._ExtendQuadBatch(),this._WriteQuadToVertexBuffer(t),e.writeToTypedArray(this._texcoordData,this._texPtr),this._texPtr+=8}Quad3D(t,e,r,i,s,a,h,n,o,l,_,u,d){this._ExtendQuadBatch();const c=this._vertexData;let f=this._vertexPtr;const p=this._baseZ+this._currentZ;c[f++]=t,c[f++]=e,c[f++]=p+r,c[f++]=i,c[f++]=s,c[f++]=p+a,c[f++]=h,c[f++]=n,c[f++]=p+o,c[f++]=l,c[f++]=_,c[f++]=p+u,this._vertexPtr=f,d.writeAsQuadToTypedArray(this._texcoordData,this._texPtr),this._texPtr+=8}Quad3D2(t,e,r,i,s,a,h,n,o,l,_,u,d){this._ExtendQuadBatch();const c=this._vertexData;let f=this._vertexPtr;const p=this._baseZ+this._currentZ;c[f++]=t,c[f++]=e,c[f++]=p+r,c[f++]=i,c[f++]=s,c[f++]=p+a,c[f++]=h,c[f++]=n,c[f++]=p+o,c[f++]=l,c[f++]=_,c[f++]=p+u,this._vertexPtr=f,d.writeToTypedArray(this._texcoordData,this._texPtr),this._texPtr+=8}DrawMesh(i,s,a){const h=this._vertexData,n=this._texcoordData;if(a.length%3!=0)throw new Error("invalid index buffer length");for(let r=0,t=a.length;r<t;){const o=a[r++],l=a[r++],_=a[r++],u=3*o,d=3*l,c=3*_,f=2*o,p=2*l,x=2*_;this._ExtendQuadBatch();let t=this._vertexPtr,e=this._texPtr;h[t++]=i[0+u],h[t++]=i[1+u],h[t++]=i[2+u],h[t++]=i[0+d],h[t++]=i[1+d],h[t++]=i[2+d],h[t++]=i[0+c],h[t++]=i[1+c],h[t++]=i[2+c],h[t++]=i[0+c],h[t++]=i[1+c],h[t++]=i[2+c],n[e++]=s[0+f],n[e++]=s[1+f],n[e++]=s[0+p],n[e++]=s[1+p],n[e++]=s[0+x],n[e++]=s[1+x],n[e++]=s[0+x],n[e++]=s[1+x],this._vertexPtr=t,this._texPtr=e}}FullscreenQuad(t,e){this.SetCurrentZ(0),mat4.copy(tmpProjection,this._matP),mat4.copy(tmpModelView,this._matMV),this.SetDefaultRenderTargetProjectionState();const[r,i]=this.GetRenderTargetSize(this._currentRenderTarget),s=this.CalculateLookAtModelView2(0,0,this.GetDefaultCameraZ(i),0,0,0,i);if(this.SetModelViewMatrix(s),"crop"===t&&this._currentRenderTarget&&e){const a=this._width/2,h=this._height/2,n=e.GetWidth(),o=e.GetHeight(),l=this._currentRenderTarget.GetWidth(),_=this._currentRenderTarget.GetHeight(),u=Math.min(l,n),d=Math.min(_,o),c=Math.max(o-_,0),f=Math.max(_-o,0);tmpRect.set(-a,h-f,-a+u,h-d-f),tmpQuad.setFromRect(tmpRect),tmpRect.set(0,c,u,d+c),tmpRect.divide(n,o),this.Quad3(tmpQuad,tmpRect)}else{const p=r/2,x=i/2;this.Rect2(-p,x,p,-x)}this.SetProjectionMatrix(tmpProjection),this.SetModelViewMatrix(tmpModelView)}StartRenderingPoints(t){if(!this._lastPointTexCoords.equals(t)){this._lastPointTexCoords.copy(t);const e=this.PushBatch();e.InitSetPointTexCoords(t),this._topOfBatch=0}}FinishRenderingPoints(){}Point(t,e,r,i){this._pointPtr>=LAST_POINT&&this.EndBatch();let s=this._pointPtr;const a=this._baseZ+this._currentZ;if(2===this._topOfBatch&&this._lastPointZ===a)this._batch[this._batchPtr-1]._indexCount++;else{const n=this.PushBatch();n.InitPoints(s,a),this._topOfBatch=2,this._lastPointZ=a}const h=this._pointData;h[s++]=t,h[s++]=e,h[s++]=r,h[s++]=i,this._pointPtr=s}SetProgram(t){if(this._lastProgram!==t){const e=this.PushBatch();e.InitSetProgram(t),this._lastProgram=t,this._topOfBatch=0,this._currentStateGroup=null}}GetProgram(){return this._lastProgram}SetDeviceTransformTextureFillMode(){this.SetProgram(this._spDeviceTransformTextureFill)}SetGradientColor(t){const e=this.PushBatch();e.InitSetGradientColor(t),this._topOfBatch=0}SetEllipseParams(t,e,r=1){const i=this.PushBatch();i.InitSetEllipseParams(t,e,r),this._topOfBatch=0}SetTilemapInfo(t,e,r,i,s,a,h){if(this._lastProgram!==this._spTilemapFill)throw new Error("must set tilemap fill mode first");const n=this.PushBatch();n.InitSetTilemapInfo(t,e,r,i,s,a,h),this._topOfBatch=0}SetTileRandomizationInfo(t,e,r,i,s,a,h){if(this._lastProgram!==this._spTileRandomization)throw new Error("must set tile randomization mode first");const n=this.PushBatch();n.InitSetTileRandomizationInfo(t,e,r,i,s,a,h),this._topOfBatch=0}SetProgramParameters(t,e,r,i,s,a,h,n,o,l,_){const u=this._lastProgram;if(_%=10800,u._hasAnyOptionalUniforms&&!u.AreOptionalUniformsAlreadySetInBatch(e,r,i,s,a,h,n,o,l,_)){const d=this.PushBatch(),c=(d.InitSetProgramParameters(),u.SetOptionalUniformsInBatch(e,r,i,s,a,h,n,o,l,_),d._mat4param),f=(c[0]=a,c[1]=h,e.writeToTypedArray(c,2),c[6]=o,c[7]=l,r.writeToTypedArray(c,12),d._colorParam),p=(s.writeToTypedArray(f,0),f[1]);f[1]=f[3],f[3]=p,i.writeToTypedArray(d._srcOriginRect,0),d._startIndex=_,d._indexCount=n,u._uSamplerBack.IsUsed()?d._texParam=t?t.GetTexture():null:d._texParam=null,this._topOfBatch=0}}SetProgramCustomParameters(t){const e=this._lastProgram;if(0!==t.length&&!e.AreCustomParametersAlreadySetInBatch(t)){const r=this.PushBatch();r.InitSetProgramCustomParameters(),e.SetCustomParametersInBatch(t),C3.shallowAssignArray(r._shaderParams,t),this._topOfBatch=0}}ClearRgba(t,e,r,i){const s=this.PushBatch();s.InitClearSurface2(t,e,r,i),this._topOfBatch=0}Clear(t){const e=this.PushBatch();e.InitClearSurface(t),this._topOfBatch=0}Start(){}Finish(){super.Finish(),this._gl.flush()}ClearDepth(){if(this._usesDepthBuffer&&this._currentRenderTarget&&this._currentRenderTarget.HasDepthBuffer()){const t=this.PushBatch();t.InitClearDepth(this._isDepthEnabled),this._topOfBatch=0}}SetDepthEnabled(t){if(this._isDepthEnabled!==(t=!!t)&&this._usesDepthBuffer){this._isDepthEnabled=t;const e=this.PushBatch();e.InitSetDepthEnabled(t),this._topOfBatch=0}}IsDepthEnabled(){return this._isDepthEnabled}_GetDepthBuffer(){return this._depthBuffer}_CanSampleDepth(){return this._canSampleDepth}SetDepthSamplingEnabled(t){if(t=!!t,this._canSampleDepth&&this._isDepthSamplingEnabled!==t){if(t&&this.IsDepthEnabled())throw new Error("depth still enabled");this._isDepthSamplingEnabled=t;const e=this.PushBatch();e.InitSetDepthSamplingEnabled(t),this._topOfBatch=0}}SetScissorRect(t,e,r,i,s=0){if(t=Math.floor(t),e=Math.floor(e),r=Math.floor(r),i=Math.floor(i),!this._lastScissorRect.equalsWH(t,e,r,i)){this._lastScissorRect.setWH(t,e,r,i);const a=s||this.GetRenderTargetSize(this.GetRenderTarget())[1],h=(e=a-e-i,this.PushBatch());h.InitSetScissor(!0,t,e,r,i),this._topOfBatch=0}}RemoveScissorRect(){if(-1!==this._lastScissorRect.getRight()){this._lastScissorRect.set(0,0,-1,-1);const t=this.PushBatch();t.InitSetScissor(!1,0,0,0,0),this._topOfBatch=0}}CheckForQueryResults(){for(const t of this._allQueryResultBuffers)t.CheckForResults(this._frameNumber)}IsContextLost(){return!this._gl||this._gl.isContextLost()||this._isInitialisingAfterContextRestored}OnContextLost(){super.OnDeviceOrContextLost(),C3.Gfx.WebGLRendererTexture.OnContextLost(),C3.Gfx.WebGLRenderTarget.OnContextLost(),C3.Gfx.RendererText.OnContextLost();for(const t of this._allQueryResultBuffers)t.Clear();this._extensions=[],this._timerExt=null,this._parallelShaderCompileExt=null,this._anisotropicExt=null,this._depthTextureExt=null,this._fragDepthExt=null,this._stdDerivativesExt=null,this._textureLodExt=null,this._maxAnisotropy=0,this._unmaskedVendor="(unavailable)",this._unmaskedRenderer="(unavailable)",this._lastProgram=null,this._spDeviceTransformTextureFill=null,this._depthBuffer=null;for(const e of this._stateGroups.values())e.OnContextLost()}async OnContextRestored(){this._isInitialisingAfterContextRestored=!0,await this.InitState(),this._isInitialisingAfterContextRestored=!1;for(const t of this._stateGroups.values())t.OnContextRestored(this);this.SetSize(this._width,this._height,!0)}CreateStaticTexture(t,e){if(this.IsContextLost())throw new Error("context lost");this.EndBatch();const r=C3.New(C3.Gfx.WebGLRendererTexture,this);return r._CreateStatic(t,e),r}async CreateStaticTextureAsync(e,r){if(this.IsContextLost())throw new Error("context lost");if(r=Object.assign({},r),C3.Supports.ImageBitmapOptions){let t=await createImageBitmap(e,{"premultiplyAlpha":"premultiply"});const i=r.wrapX&&"clamp-to-edge"!==r.wrapX||r.wrapY&&"clamp-to-edge"!==r.wrapY,s=C3.isPOT(t.width)&&C3.isPOT(t.height);return this.SupportsNPOTTextures()||s||!i?r.premultiplyAlpha=!1:C3.Supports.ImageBitmapOptionsResize?(t=await createImageBitmap(e,{"premultiplyAlpha":"premultiply","resizeWidth":C3.nextHighestPowerOfTwo(t.width),"resizeHeight":C3.nextHighestPowerOfTwo(t.height)}),r.premultiplyAlpha=!1):t=await createImageBitmap(e,{"premultiplyAlpha":"none"}),C3.Asyncify(()=>this.CreateStaticTexture(t,r))}if(e instanceof Blob){if("undefined"==typeof Image)throw new Error("texture upload variant not supported in worker");const t=await C3.BlobToImage(e);e=t}return C3.Asyncify(()=>this.CreateStaticTexture(e,r))}CreateDynamicTexture(t,e,r){this.EndBatch();const i=C3.New(C3.Gfx.WebGLRendererTexture,this);return i._CreateDynamic(t,e,r),i}UpdateTexture(t,e,r){this.EndBatch(),e._Update(t,r)}DeleteTexture(t){t&&(t.SubtractReference(),0<t.GetReferenceCount()||(this.EndBatch(),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),t._Delete()))}CreateRenderTarget(t){let e=this._width,r=this._height,i=!0;if(t&&("number"==typeof t.width&&(e=Math.floor(t.width),i=!1),"number"==typeof t.height)&&(r=Math.floor(t.height),i=!1),e<=0||r<=0)throw new Error("invalid size");this.EndBatch();const s=C3.New(C3.Gfx.WebGLRenderTarget,this);return s._Create(e,r,Object.assign({isDefaultSize:i},t)),this._currentRenderTarget=null,this._batchState.currentFramebuffer=null,this._batchState.currentFramebufferNoDepth=null,s}SetRenderTarget(t,e=!0){if(t!==this._currentRenderTarget){t&&t.IsDefaultSize()&&t._Resize(this._width,this._height);const r=this.PushBatch();r.InitSetRenderTarget(t),this._currentRenderTarget=t,this._topOfBatch=0,e&&this.SetDefaultRenderTargetProjectionState()}}GetRenderTarget(){return this._currentRenderTarget}GetRenderTargetSize(t){return t?[t.GetWidth(),t.GetHeight()]:[this._width,this._height]}CopyRenderTarget(t,e="stretch"){if(this._version<2||this._currentRenderTarget&&0<this._currentRenderTarget.GetMultisampling())this.SetCopyBlend(),this.ResetColor(),this.DrawRenderTarget(t,e);else{const r=this.PushBatch();r.InitBlitFramebuffer(t,this._currentRenderTarget,e),this._topOfBatch=0}}DrawRenderTarget(t,e="stretch"){const r=t.GetTexture();if(!r)throw new Error("not a texture-backed render target");this.SetTexture(r),this.FullscreenQuad(e,r)}InvalidateRenderTarget(t){if(!(this._version<2)){const e=this.PushBatch();e.InitInvalidateFramebuffer(t._GetFramebuffer()),this._topOfBatch=0}}DeleteRenderTarget(t){this.SetRenderTarget(null),this.EndBatch();const e=t.GetTexture();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),t._Delete()}async ReadBackRenderTargetToImageData(t,e,r){this.EndBatch();const i=this._currentRenderTarget;let s,a,h,n=(h=t?(s=t.GetWidth(),a=t.GetHeight(),t._GetFramebuffer()):(s=this.GetWidth(),a=this.GetHeight(),null),0),o=0,l=s,_=a;if(r){n=C3.clamp(Math.floor(r.getLeft()),0,s-1),o=C3.clamp(Math.floor(r.getTop()),0,a-1);let t=r.width(),e=(t=0===t?s-n:C3.clamp(Math.floor(t),0,s-n),r.height());e=0===e?a-o:C3.clamp(Math.floor(e),0,a-o),l=t,_=e,o=a-(o+_)}const u=this._gl,d=(u.bindFramebuffer(u.FRAMEBUFFER,h),()=>{u.bindFramebuffer(u.FRAMEBUFFER,null),this._currentRenderTarget=null,this._batchState.currentFramebuffer=null,this._batchState.currentFramebufferNoDepth=null,this.SetRenderTarget(i)});let c;if(!e&&2<=this.GetWebGLVersionNumber()){u.bindFramebuffer(u.READ_FRAMEBUFFER,h);const f=u.createBuffer(),p=l*_*4,x=u["PIXEL_PACK_BUFFER"],E=(u.bindBuffer(x,f),u.bufferData(x,p,u["STREAM_READ"]),u.readPixels(n,o,l,_,u.RGBA,u.UNSIGNED_BYTE,0),u.bindFramebuffer(u.READ_FRAMEBUFFER,null),u.bindBuffer(x,null),d(),u["fenceSync"](u["SYNC_GPU_COMMANDS_COMPLETE"],0));await this._WaitForObjectReady(()=>u["getSyncParameter"](E,u["SYNC_STATUS"])===u["SIGNALED"]),u["deleteSync"](E),c=new ImageData(l,_),u.bindBuffer(x,f),u["getBufferSubData"](x,0,new Uint8Array(c.data.buffer),0,p),u.bindBuffer(x,null),u.deleteBuffer(f)}else c=new ImageData(l,_),u.readPixels(n,o,l,_,u.RGBA,u.UNSIGNED_BYTE,new Uint8Array(c.data.buffer)),d();return c}CoplanarStartStencilPass(){this.SetDepthEnabled(!0);const t=this.PushBatch();t.InitCoplanarStartStencilPass(),this._topOfBatch=0,this._coplanarMode=1}CoplanarStartColorPass(){this.SetDepthEnabled(!1);const t=this.PushBatch();t.InitCoplanarStartColorPass(),this._topOfBatch=0,this._coplanarMode=2}IsCoplanarColorPass(){return 2===this._coplanarMode}CoplanarRestoreStandardRendering(){this.SetDepthEnabled(!0);const t=this.PushBatch();t.InitCoplanarRestore(),this._topOfBatch=0,this._coplanarMode=0}StartQuery(t){if(this.SupportsGPUProfiling()){const e=this.PushBatch();e.InitStartQuery(t),this._topOfBatch=0}}EndQuery(t){if(this.SupportsGPUProfiling()){const e=this.PushBatch();e.InitEndQuery(t),this._topOfBatch=0}}_WaitForObjectReady(e){const t=new Promise(t=>pendingPolls.add({resolve:t,checkFunc:e}));return-1===pollRafId&&(pollRafId=self.requestAnimationFrame(CheckPendingPolls)),t}GetEstimatedBackBufferMemoryUsage(){return this._width*this._height*(this._attribs["alpha"]?4:3)}GetEstimatedRenderBufferMemoryUsage(){let t=0;for(const e of C3.Gfx.WebGLRenderTarget.allRenderTargets())e.GetTexture()||(t+=e.GetEstimatedMemoryUsage());return t}GetEstimatedTextureMemoryUsage(){let t=0;for(const e of C3.Gfx.WebGLRendererTexture.allTextures())t+=e.GetEstimatedMemoryUsage();return t}GetWebGLVersionString(){return this._versionString}GetWebGLVersionNumber(){return this._version}GetDisplayName(){return"webgl"+this.GetWebGLVersionNumber()}SupportsNPOTTextures(){return 2<=this.GetWebGLVersionNumber()}GetMaxTextureSize(){return this._maxTextureSize}GetMinPointSize(){return this._minPointSize}GetMaxPointSize(){return this._maxPointSize}SupportsHighP(){return 0!==this._highpPrecision}GetHighPPrecision(){return this._highpPrecision}GetUnmaskedVendor(){return this._unmaskedVendor}GetUnmaskedRenderer(){return this._unmaskedRenderer}GetWebGLExtensionsAnalyticsString(){if(2<=this.GetWebGLVersionNumber())return"webgl2";{const t=[];return this._fragDepthExt&&t.push("EXT_frag_depth"),this._stdDerivativesExt&&t.push("OES_standard_derivatives"),this._textureLodExt&&t.push("EXT_shader_texture_lod"),0<t.length?"webgl1:"+t.join(","):"webgl1:none"}}GetExtensions(){return this._extensions}SupportsGPUProfiling(){return!!this._timerExt}_GetDisjointTimerQueryExtension(){return this._timerExt}_GetParallelShaderCompileExtension(){return this._parallelShaderCompileExt}_GetAnisotropicExtension(){return this._anisotropicExt}_GetMaxAnisotropy(){return this._maxAnisotropy}_AddQueryResultBuffer(t){this._allQueryResultBuffers.add(t)}_RemoveQueryResultBuffer(t){this._allQueryResultBuffers.delete(t)}_GetTimeQueryStack(){return this._timeQueryStack}GetContext(){return this._gl}_InitBlendModes(t){this._InitBlendModeData([["normal",t.ONE,t.ONE_MINUS_SRC_ALPHA],["additive",t.ONE,t.ONE],["xor",t.ONE,t.ONE_MINUS_SRC_ALPHA],["copy",t.ONE,t.ZERO],["destination-over",t.ONE_MINUS_DST_ALPHA,t.ONE],["source-in",t.DST_ALPHA,t.ZERO],["destination-in",t.ZERO,t.SRC_ALPHA],["source-out",t.ONE_MINUS_DST_ALPHA,t.ZERO],["destination-out",t.ZERO,t.ONE_MINUS_SRC_ALPHA],["source-atop",t.DST_ALPHA,t.ONE_MINUS_SRC_ALPHA],["destination-atop",t.ONE_MINUS_DST_ALPHA,t.SRC_ALPHA]])}CreateWebGLText(){return this.CreateRendererText()}}; } // ../lib/gfx/effectCompositor/effectChainManager.js { const C3=self.C3,DEFAULT_CTOR_OPTS={getDrawSize:null,getRenderTarget:null,releaseRenderTarget:null,getTime:null,redraw:null};C3.Gfx.EffectChainManager=class{constructor(e){e=Object.assign({},DEFAULT_CTOR_OPTS,e),this._cbGetDrawSize=e.getDrawSize,this._cbGetRenderTarget=e.getRenderTarget,this._cbReleaseRenderTarget=e.releaseRenderTarget,this._cbGetTime=e.getTime,this._cbRedraw=e.redraw,this._webgpuBackTexture=null,this._allEffectChains=new Set}_AddEffectChain(e){this._allEffectChains.add(e)}_RemoveEffectChain(e){this._allEffectChains.delete(e)}OnContextLost(){this._webgpuBackTexture=null;for(const e of this._allEffectChains)e.OnContextLost()}GetDrawSize(e){return this._cbGetDrawSize?this._cbGetDrawSize(e):[e.GetWidth(),e.GetHeight()]}GetRenderTarget(e){return this._cbGetRenderTarget(e)}ReleaseRenderTarget(e,t){this._cbReleaseRenderTarget(e,t)}GetTime(){return this._cbGetTime()}Redraw(e){this._cbRedraw(e)}_GetWebGPUBackTexture(e,t,r){return t=Math.floor(t),r=Math.floor(r),!this._webgpuBackTexture||this._webgpuBackTexture.GetWidth()===t&&this._webgpuBackTexture.GetHeight()===r||(e.DeleteTexture(this._webgpuBackTexture),this._webgpuBackTexture=null),null===this._webgpuBackTexture&&(this._webgpuBackTexture=e.CreateStaticTexture(null,{width:t,height:r,sampling:"nearest",mipMap:!1})),this._webgpuBackTexture}}; } // ../lib/gfx/effectCompositor/effectChain.js { const C3=self.C3,assert=self.assert,glMatrix=self.glMatrix,mat4=glMatrix.mat4,tempRect=C3.New(C3.Rect),tempRect2=C3.New(C3.Rect),tempRect3=C3.New(C3.Rect),tempRect4=C3.New(C3.Rect),tempMat4a=mat4.create(),tempMat4b=mat4.create(),DEFAULT_CTOR_OPTS={drawContent:null,getSourceTextureInfo:null,getShaderParameters:null,invalidateRenderTargets:!1},DEFAULT_BUILDSTEPS_OPTS={indexMap:null,forcePreDraw:!1,forcePostDraw:!1,is3D:!1,isSourceTextureRotated:!1,isRotatedOrNegativeSizeInstance:!1,useFullSurface:!1};C3.Gfx.EffectChain=class{constructor(e,t){t=Object.assign({},DEFAULT_CTOR_OPTS,t),this._manager=e,this._cbDrawContent=t.drawContent,this._cbGetSourceTextureInfo=t.getSourceTextureInfo,this._cbGetShaderParameters=t.getShaderParameters,this._cbDrawContentHook=null,this._shaderProgramList=[],this._shaderProgramIndices=[],this._steps=[],this._needsRebuild=!1,this._blendMode=0,this._isAnyShaderAnimated=!1,this._isAnyShaderDepthSampling=!1,this._isAnyShaderBackgroundBlending=!1,this._isAnyShaderCrossSampling=!1,this._isAnyIsSrcTexRotated=!1,this._useCopyTextureBackgroundSampling=!1,this._didChangeTransform=!1,this._depthEnabledAtStart=!1,this._coplanarColorPassAtStart=!1,this._canUseFastPath=!1,this._useFullSurface=!1,this._isSourceTextureRotated=!1,this._numTempSurfacesRequired=0,this._renderTargets=[null,null,null],this._invalidateRenderTargets=!!t.invalidateRenderTargets,this._boxExtendHorizontal=0,this._boxExtendVertical=0,this._drawWidth=0,this._drawHeight=0,this._contentObject=null,this._contextObject=null,this._layoutRect=C3.New(C3.Rect),this._drawSurfaceRect=C3.New(C3.Rect),this._rcTexOriginal=C3.New(C3.Rect),this._rcTexBounce=C3.New(C3.Rect),this._rcTexDest=C3.New(C3.Rect),this._devicePixelRatio=1,this._layerScale=1,this._layerAngle=0,this._time=0,this._destRenderTarget=null,this._backTex=null,this._compositOffX=0,this._compositOffY=0,this._updateOwnProjection=!1,this._projectionMatrix=mat4.create(),this._modelViewMatrix=mat4.create(),this._manager._AddEffectChain(this)}Release(){this._manager._RemoveEffectChain(this),C3.clearArray(this._steps),C3.clearArray(this._shaderProgramList),C3.clearArray(this._shaderProgramIndices),this._contentObject=null,this._contextObject=null,this._cbDrawContent=null,this._cbGetSourceTextureInfo=null,this._cbGetShaderParameters=null}OnContextLost(){this._needsRebuild=!0,C3.clearArray(this._steps),C3.clearArray(this._shaderProgramList),C3.clearArray(this._shaderProgramIndices)}NeedsRebuild(){return this._needsRebuild}BuildSteps(i,e){if(e=Object.assign({},DEFAULT_BUILDSTEPS_OPTS,e),C3.clearArray(this._steps),this._boxExtendHorizontal=0,this._boxExtendVertical=0,this._isAnyShaderAnimated=!1,this._isAnyShaderDepthSampling=!1,this._isAnyShaderBackgroundBlending=!1,this._isAnyShaderCrossSampling=!1,this._isAnyIsSrcTexRotated=!1,this._useCopyTextureBackgroundSampling=!1,this._numTempSurfacesRequired=0,this._isSourceTextureRotated=!!e.isSourceTextureRotated,this._useFullSurface=!!e.useFullSurface,this._needsRebuild=!1,C3.shallowAssignArray(this._shaderProgramList,i),0!==i.length){if(e.indexMap){if(e.indexMap.length!==i.length)throw new Error("incorrect indexMap length");C3.shallowAssignArray(this._shaderProgramIndices,e.indexMap)}else{C3.clearArray(this._shaderProgramIndices);for(let e=0,t=i.length;e<t;++e)this._shaderProgramIndices.push(e)}for(const t of i)this._boxExtendHorizontal+=t.GetBoxExtendHorizontal(),this._boxExtendVertical+=t.GetBoxExtendVertical(),t.IsAnimated()&&(this._isAnyShaderAnimated=!0),t.UsesDepth()&&(this._isAnyShaderDepthSampling=!0),t.BlendsBackground()&&(this._isAnyShaderBackgroundBlending=!0),t.UsesCrossSampling()&&(this._isAnyShaderCrossSampling=!0),t.UsesIsSrcTexRotated()&&(this._isAnyIsSrcTexRotated=!0);this._useCopyTextureBackgroundSampling=this._ShouldUseCopyTextureBackgroundSampling(i[0].GetRenderer());const a=this._ShouldPreDraw(i[0],e),n=this._ShouldPostDraw(i.at(-1),e);if(1!==i.length||a||n){this._canUseFastPath=!1;let s=0;a&&(this._numTempSurfacesRequired=1,this._steps.push(C3.New(C3.Gfx.EffectChain.Step.PreDraw,this,-1,1)),s=1);for(let t=0,r=i.length;t<r;++t)if(0!==t||a){let e=1===s?2:1;t!==r-1||n||(e=0),this._numTempSurfacesRequired=Math.max(this._numTempSurfacesRequired,e),this._steps.push(C3.New(C3.Gfx.EffectChain.Step.Bounce,this,s,e,t)),s=e}else this._numTempSurfacesRequired=1,this._steps.push(C3.New(C3.Gfx.EffectChain.Step.FirstBounce,this,-1,1,t)),s=1;n&&this._steps.push(C3.New(C3.Gfx.EffectChain.Step.PostDraw,this,s,0))}else this._canUseFastPath=!0}}_ShouldPreDraw(e,t){return!!(t.forcePreDraw||e.MustPreDraw()||t.is3D&&!e.Supports3DDirectRendering()||e.UsesDepth()&&!this._useFullSurface||0!==this._boxExtendHorizontal||0!==this._boxExtendVertical)||(e.GetRenderer().IsWebGL()?e.BlendsBackground()&&(t.isRotatedOrNegativeSizeInstance||t.isSourceTextureRotated)||e.UsesAnySrcRectOrPixelSize()&&t.isSourceTextureRotated:e.BlendsBackground()&&!this._useCopyTextureBackgroundSampling&&t.isRotatedOrNegativeSizeInstance)}_ShouldPostDraw(e,t){return!!t.forcePostDraw||(e.GetRenderer().IsWebGL()?e.BlendsBackground()||e.UsesCrossSampling():(e.BlendsBackground()||e.UsesCrossSampling())&&this._UseRenderTargetBackgroundSampling())}_ShouldUseCopyTextureBackgroundSampling(e){return e.IsWebGPU()&&this._isAnyShaderBackgroundBlending&&!this._isAnyShaderCrossSampling}Render(e,t,r){e.IsWebGPU()&&null===t&&(t=e.GetBackbufferRenderTarget()),this._destRenderTarget=t,this._contentObject=r.contentObject||null,this._contextObject=r.contextObject||null,this._blendMode=r.blendMode||0,this._devicePixelRatio=r.devicePixelRatio||1,this._layerScale=r.layerScale||1,this._layerAngle=r.layerAngle||0,this._time="number"==typeof r.time?r.time:this._manager.GetTime(),this._didChangeTransform=!1,e.ResetDidChangeTransformFlag(),this._isAnyShaderAnimated&&this._Redraw();let s=!1;if(this._UseCopyTextureBackgroundSampling()&&(this._CalculateDrawSizeAndRectangles(e,r),s=!0,this._backTex=this._manager._GetWebGPUBackTexture(e,this._drawWidth,this._drawHeight),tempRect.copy(this._drawSurfaceRect),tempRect.roundOuter(),e.IsWebGPU()&&e._MaybeDoPendingClearRenderPass(this._destRenderTarget),e.CopyTextureToTexture(this._destRenderTarget.GetTexture(),this._backTex,tempRect.getLeft(),tempRect.getTop(),tempRect.width(),tempRect.height())),this._canUseFastPath)this._Render_FastPath(e,r);else if(s||this._CalculateDrawSizeAndRectangles(e,r),0!==this._rcTexOriginal.width()||0!==this._rcTexOriginal.height()){e.SetAlphaBlend(),e.ResetColor(),e.SetBaseZ(0),e.SetCurrentZ(0),this._cbDrawContentHook=r.drawContentHook||null,this._compositOffX=r.compositOffX||0,this._compositOffY=r.compositOffY||0,this._updateOwnProjection=!!r.updateOwnProjection,this._OnBeforeStartEffectChain(e),this._renderTargets[0]=t,this._renderTargets[1]=1<=this._numTempSurfacesRequired?this._GetRenderTarget():null,this._renderTargets[2]=2===this._numTempSurfacesRequired?this._GetRenderTarget():null;for(const i of this._steps){const a=this._GetRenderTargetForId(i.GetSrcTargetId()),n=this._GetRenderTargetForId(i.GetDestTargetId());e.IsWebGPU()?i.Run_WebGPU(e,a,n):i.Run_WebGL(e,a,n)}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[r,s]=this._manager.GetDrawSize(e);this._SetDrawSize(e,r,s),this._CalculateRectangles(t)}_SetDrawSize(e,t,r){if(t<=0||r<=0)throw new Error("invalid draw size");this._drawWidth===t&&this._drawHeight===r||this._CalculateDeviceTransformMatrices(e,t,r,0,0,this._projectionMatrix,this._modelViewMatrix),this._drawWidth=t,this._drawHeight=r}_CalculateDeviceTransformMatrices(e,t,r,s,i,a,n){const h=t/2+s,c=r/2+i,o=(e.CalculatePerspectiveMatrix(a,t/r),e.CalculateLookAtModelView2(h,c,e.GetDefaultCameraZ(r),h,c,0,r));mat4.copy(n,o)}_CalculateRectangles(e){this._layoutRect.copy(e.layoutRect),e.drawSurfaceRect?this._drawSurfaceRect.copy(e.drawSurfaceRect):this._drawSurfaceRect.set(0,0,this._drawWidth,this._drawHeight),this._rcTexOriginal.copy(this._drawSurfaceRect),this._rcTexOriginal.divide(this._drawWidth,this._drawHeight);const t=this._layerScale*this._devicePixelRatio;this._drawSurfaceRect.inflate(this._boxExtendHorizontal*t,this._boxExtendVertical*t),this._rcTexDest.copy(this._drawSurfaceRect),this._rcTexDest.divide(this._drawWidth,this._drawHeight),this._drawSurfaceRect.clampBoth(0,0,this._drawWidth,this._drawHeight),this._rcTexBounce.copy(this._drawSurfaceRect),this._rcTexBounce.divide(this._drawWidth,this._drawHeight)}_OnBeforeStartEffectChain(e){if(this._depthEnabledAtStart=e.IsDepthEnabled(),this._coplanarColorPassAtStart=e.IsCoplanarColorPass(),this._useFullSurface)e.SetDepthEnabled(!1),this._isAnyShaderDepthSampling&&e.SetDepthSamplingEnabled(!0);else{if(tempRect.copy(this._drawSurfaceRect),e.IsWebGL()){const t=this._layerScale*this._devicePixelRatio;tempRect.inflate(Math.max(this._boxExtendHorizontal,1)*t,Math.max(this._boxExtendVertical,1)*t),tempRect.roundOuter(),tempRect.clamp(0,0,this._drawWidth,this._drawHeight)}else tempRect.roundOuter();e.SetScissorRect(tempRect.getLeft(),tempRect.getTop(),tempRect.width(),tempRect.height(),this._drawHeight)}}_OnAfterEffectChainDrawContent(e){e.ResetColor(),this._useFullSurface||(this._coplanarColorPassAtStart&&e.CoplanarRestoreStandardRendering(),e.SetDepthEnabled(!1),this._isAnyShaderDepthSampling&&e.SetDepthSamplingEnabled(!0)),e.IsWebGPU()&&e.SetNormalizedCoordsProgramVariant(!0)}_OnAfterEndEffectChain(e){e.SetDepthSamplingEnabled(!1),this._coplanarColorPassAtStart&&e.CoplanarStartColorPass(),e.SetDepthEnabled(this._depthEnabledAtStart),this._useFullSurface||e.RemoveScissorRect(),e.IsWebGPU()&&e.SetNormalizedCoordsProgramVariant(!1),this._didChangeTransform=e.DidChangeTransform()}_ClampRcTexDest(){this._rcTexDest.clamp(0,0,1,1)}_GetRenderTargetForId(e){return e<0?null:this._renderTargets[e]}_GetRenderTarget(){return this._manager.GetRenderTarget(this)}_GetDestRenderTarget(){return this._destRenderTarget}_ReleaseRenderTarget(e){this._manager.ReleaseRenderTarget(e,this)}_GetShaderProgramAt(e){return this._shaderProgramList[e]}_DrawContent(e){this._cbDrawContentHook?this._cbDrawContentHook(this,e,()=>this._cbDrawContent(e,this)):this._cbDrawContent(e,this),this._canUseFastPath||this._OnAfterEffectChainDrawContent(e)}_IsRenderTargetSameSizeAndOffset(e){if(this._useFullSurface)return!0;if(0!==this._compositOffX||0!==this._compositOffY)return!1;const[t,r]=e.GetRenderTargetSize(e.GetRenderTarget());return t===this._drawWidth&&r===this._drawHeight}_SetDeviceTransform(e,t){let r=this._projectionMatrix,s=this._modelViewMatrix;if(t&&!this._IsRenderTargetSameSizeAndOffset(e)){r=tempMat4a,s=tempMat4b;const[i,a]=e.GetRenderTargetSize(e.GetRenderTarget());this._CalculateDeviceTransformMatrices(e,i,a,this._compositOffX,this._compositOffY,r,s),this._useFullSurface||e.RemoveScissorRect()}e.SetProjectionMatrix(r),e.SetModelViewMatrix(s)}_Redraw(){this._manager.Redraw(this)}_GetShaderParameters(e,t){return this._cbGetShaderParameters(this._shaderProgramIndices[e],t)}_SetProgramParameters(e,t){let r=this._rcTexDest,s=this._rcTexBounce,i=this._rcTexOriginal;e.IsWebGL()&&(tempRect2.copy(r),tempRect2.flipAround(1),r=tempRect2,tempRect3.copy(s),tempRect3.flipAround(1),s=tempRect3,tempRect4.copy(i),tempRect4.flipAround(1),i=tempRect4),this._DoSetProgramParameters(e,t,s,i,r,1/this._drawWidth,1/this._drawHeight)}_SetFirstBounceProgramParameters(e,t){let s=this._rcTexBounce,i=this._rcTexOriginal,a=1/this._drawWidth,n=1/this._drawHeight;if(this._cbGetSourceTextureInfo){let{srcTexRect:e,srcWidth:t,srcHeight:r}=this._cbGetSourceTextureInfo(this._contentObject);e||(tempRect.set(0,0,0,0),e=tempRect),t=t||this._drawWidth,r=r||this._drawHeight,s=e,i=e,a=1/t,n=1/r}else e.IsWebGL()&&(tempRect3.copy(s),tempRect3.flipAround(1),s=tempRect3,tempRect4.copy(i),tempRect4.flipAround(1),i=tempRect4);let r=this._rcTexDest;e.IsWebGL()&&((r=tempRect2).copy(this._rcTexDest),r.flipAround(1)),this._DoSetProgramParameters(e,t,s,i,r,a,n),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,r,s,i,a,n){e.SetProgramParameters(this._GetBackTex(e),i,r,s,this._layoutRect,a,n,this._devicePixelRatio,this._layerScale,this._layerAngle,this._time),e.SetProgramCustomParameters(this._GetShaderParameters(t,e))}_Render_FastPath(e,t){const r=this._shaderProgramList[0],s=e.IsDepthEnabled(),i=r.UsesDepth();i&&(e.SetDepthEnabled(!1),e.SetDepthSamplingEnabled(!0),this._rcTexDest.set(0,0,1,1),this._rcTexOriginal.set(0,0,1,1)),e.SetProgram(r),e.SetBlendMode(this._blendMode),e.SetRenderTarget(this._destRenderTarget);let a=0,n=1;if(this._rcTexOriginal.set(0,0,1,1),r.UsesAnySrcRectOrPixelSize()&&this._cbGetSourceTextureInfo){const{srcTexRect:h,srcWidth:c,srcHeight:o}=this._cbGetSourceTextureInfo(this._contentObject);h&&this._rcTexOriginal.copy(h),a=Number.isFinite(c)?1/c:0,n=Number.isFinite(o)?1/o:0}else{const[d,_]=this._manager.GetDrawSize(e);a=1/d,n=1/_}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,a,n,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),i&&(e.SetDepthSamplingEnabled(!1),e.SetDepthEnabled(s))}_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,r){}}; } // ../lib/gfx/effectCompositor/step.js { const C3=self.C3;C3.Gfx.EffectChain.Step=class{constructor(t,e,r,s=-1){this._effectChain=t,this._srcTargetId=e,this._destTargetId=r,this._index=s}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(t,e,r){}Run_WebGPU(t,e,r){}}; } // ../lib/gfx/effectCompositor/preDrawStep.js { const C3=self.C3;C3.Gfx.EffectChain.Step.PreDraw=class extends C3.Gfx.EffectChain.Step{constructor(e,t,n,a){super(e,t,n,a)}Run_WebGL(e,t,n){const a=this.GetEffectChain();e.SetAlphaBlend(),e.SetTextureFillMode(),e.SetRenderTarget(n,a._UpdateOwnProjection()),e.ClearRgba(0,0,0,0),a._DrawContent(e),a._ClampRcTexDest()}Run_WebGPU(e,t,n){const a=this.GetEffectChain();e.SetAlphaBlend(),e.SetTextureFillMode(),e.SetRenderTarget(n,!1),e.ClearRgba(0,0,0,0),a._DrawContent(e),a._ClampRcTexDest()}}; } // ../lib/gfx/effectCompositor/postDrawStep.js { const C3=self.C3,tempRect=C3.New(C3.Rect),tempQuad=C3.New(C3.Quad);C3.Gfx.EffectChain.Step.PostDraw=class extends C3.Gfx.EffectChain.Step{constructor(e,t,r,a){super(e,t,r,a)}Run_WebGL(e,t,r){const a=this.GetEffectChain();e.SetTextureFillMode(),e.SetRenderTarget(r),a._SetDeviceTransform(e,!0),e.SetBlendMode(a._GetBlendMode()),e.SetTexture(t.GetTexture()),tempQuad.setFromRect(a._GetDrawSurfaceRect()),tempRect.copy(a._GetRcTexBounce()),tempRect.flipAround(1),e.Quad3(tempQuad,tempRect),a._ShouldInvalidateRenderTargets()&&e.InvalidateRenderTarget(t)}Run_WebGPU(e,t,r){const a=this.GetEffectChain();e.SetTextureFillMode(),e.SetRenderTarget(r,!1),a._IsRenderTargetSameSizeAndOffset(e)?tempQuad.setFromRect(a._GetRcTexBounce()):(e.SetNormalizedCoordsProgramVariant(!1),a._SetDeviceTransform(e,!0),tempQuad.setFromRect(a._GetDrawSurfaceRect())),e.SetBackTexture(null),e.SetBlendMode(a._GetBlendMode()),e.SetTexture(t.GetTexture()),a.UseFullSurface()?e.FullscreenQuad():e.Quad3(tempQuad,a._GetRcTexBounce())}}; } // ../lib/gfx/effectCompositor/firstBounceStep.js { const C3=self.C3;C3.Gfx.EffectChain.Step.FirstBounce=class extends C3.Gfx.EffectChain.Step{constructor(e,t,r,a){super(e,t,r,a)}Run_WebGL(e,t,r){const a=this.GetEffectChain();e.SetRenderTarget(r,a._UpdateOwnProjection()),e.ClearRgba(0,0,0,0),e.SetCopyBlend(),e.SetProgram(this.GetShaderProgram()),a._SetFirstBounceProgramParameters(e,this.GetIndex()),a._DrawContent(e),a._ClampRcTexDest()}Run_WebGPU(e,t,r){const a=this.GetEffectChain();e.SetRenderTarget(r,!1),e.ClearRgba(0,0,0,0),e.SetCopyBlend(),e.SetProgram(this.GetShaderProgram()),a._SetFirstBounceProgramParameters(e,this.GetIndex()),a._DrawContent(e),a._ClampRcTexDest()}}; } // ../lib/gfx/effectCompositor/bounceStep.js { const C3=self.C3,tempRect=C3.New(C3.Rect),tempQuad=C3.New(C3.Quad);C3.Gfx.EffectChain.Step.Bounce=class extends C3.Gfx.EffectChain.Step{constructor(e,t,r,a){super(e,t,r,a)}Run_WebGL(e,t,r){const a=this.GetEffectChain(),d=(e.SetRenderTarget(r),0===this.GetDestTargetId());d?e.SetBlendMode(a._GetBlendMode()):(e.ClearRgba(0,0,0,0),e.SetCopyBlend()),e.SetProgram(this.GetShaderProgram()),a._SetProgramParameters(e,this.GetIndex()),e.SetTexture(t.GetTexture()),a._SetDeviceTransform(e,d),tempQuad.setFromRect(a._GetDrawSurfaceRect()),tempRect.copy(a._GetRcTexBounce()),tempRect.flipAround(1),e.Quad3(tempQuad,tempRect),a._ShouldInvalidateRenderTargets()&&e.InvalidateRenderTarget(t)}Run_WebGPU(e,t,r){const a=this.GetEffectChain(),d=(e.SetRenderTarget(r,!1),0===this.GetDestTargetId());d?(e.SetBlendMode(a._GetBlendMode()),e.SetBackTexture(null),a._IsRenderTargetSameSizeAndOffset(e)?tempQuad.setFromRect(a._GetRcTexBounce()):(e.SetNormalizedCoordsProgramVariant(!1),a._SetDeviceTransform(e,!0),tempQuad.setFromRect(a._GetDrawSurfaceRect()))):(e.ClearRgba(0,0,0,0),e.SetCopyBlend(),tempQuad.setFromRect(a._GetRcTexBounce())),e.SetProgram(this.GetShaderProgram()),a._SetProgramParameters(e,this.GetIndex()),e.SetTexture(t.GetTexture()),a.UseFullSurface()?e.FullscreenQuad():e.Quad3(tempQuad,a._GetRcTexBounce())}}; } // interfaces/IRuntime.js { const C3=self.C3,C3X=self.C3X;let runtime=null;const keysDownByKey=new Set;function SortZOrderList(e,t){const r=e[0],n=t[0],i=r-n;if(0!=i)return i;const o=e[1],a=t[1];return o-a}const tempZOrderList=[],tempInstances=[];let didWarnInAlertPolyfill=!1,didWarnFpsDeprecated=!1;const VALID_FRAMERATE_MODES=new Set(["vsync","unlimited-tick","unlimited-frame"]);self.IRuntime=class{constructor(e){runtime=e,Object.defineProperties(this,{assets:{value:runtime.GetAssetManager().GetIAssetManager(),writable:!1},collisions:{value:runtime.GetCollisionEngine().GetICollisionEngine(),writable:!1},objects:{value:{},writable:!1},globalVars:{value:{},writable:!1},projectName:{value:runtime.GetProjectName(),writable:!1},projectVersion:{value:runtime.GetProjectVersion(),writable:!1},exportDate:{value:new Date(runtime.GetExportTimestamp()),writable:!1},storage:{value:new self.IStorage(runtime),writable:!1},isInWorker:{value:runtime.IsInWorker(),writable:!1},viewportWidth:{value:runtime.GetOriginalViewportWidth(),writable:!1},viewportHeight:{value:runtime.GetOriginalViewportHeight(),writable:!1},sampling:{value:runtime.GetSampling(),writable:!1},isPixelRoundingEnabled:{value:runtime.IsPixelRoundingEnabled(),writable:!1},platformInfo:{value:new self.IPlatformInfo(e),writable:!1},sdk:{value:new self.ISDKUtils(e),writable:!1}}),runtime.UserScriptDispatcher().addEventListener("keydown",e=>{keysDownByKey.has(e["key"])?e.stopPropagation():keysDownByKey.add(e["key"])}),runtime.UserScriptDispatcher().addEventListener("keyup",e=>keysDownByKey.delete(e["key"])),runtime.Dispatcher().addEventListener("window-blur",()=>keysDownByKey.clear()),runtime.IsInWorker()&&(self["alert"]=e=>(didWarnInAlertPolyfill||(didWarnInAlertPolyfill=!0,console.warn("[Construct] alert() was called from a Web Worker, because the project 'Use worker' setting is enabled. This method is not normally available in a Web Worker. Construct has implemented the alert for you, but note that other features may be missing in worker mode. You may wish to disable 'Use worker', or use a more convenient function like console.log(). For more information please refer to the scripting section of the manual.")),this.alert(e)))}_InitObjects(e){Object.defineProperties(this.objects,e)}_InitGlobalVars(e){Object.defineProperties(this.globalVars,e)}addEventListener(e,t){runtime.UserScriptDispatcher().addEventListener(e,t)}removeEventListener(e,t){runtime.UserScriptDispatcher().removeEventListener(e,t)}callFunction(e,...t){C3X.RequireString(e);const r=runtime.GetEventSheetManager(),n=r.GetFunctionBlockByName(e);if(!n)throw new Error(`cannot find function name '${e}'`);if(!n.IsEnabled())return n.GetDefaultReturnValue();if(t.length<n.GetFunctionParameterCount())throw new Error(`not enough function parameters passed for '${e}' (${t.length} passed, ${n.GetFunctionParameterCount()} expected)`);const i=n.GetEventBlock();let o=i.GetSolModifiersIncludingParents();const a=r.GetCurrentEvent();if(a){o=o.slice(0);const u=new Set(o);for(const l of a.GetSolModifiersIncludingParents())u.has(l)||(o.push(l),u.add(l));for(const m of r.GetDynamicSolModifiersSet())u.has(m)||(o.push(m),u.add(m))}const s=i.RunAsExpressionFunctionCall(o,n.IsCopyPicked(),n.GetReturnType(),n.GetDefaultReturnValue(),...t);return s}setReturnValue(e){const t=runtime.GetEventStack().GetCurrentExpFuncStackFrame();if(!t)throw new Error("not in a function which returns a value");switch(t.GetFunctionReturnType()){case 1:"number"==typeof e&&t.SetFunctionReturnValue(e);break;case 2:"string"==typeof e&&t.SetFunctionReturnValue(e);break;case 3:"number"!=typeof e&&"string"!=typeof e||t.SetFunctionReturnValue(e)}}signal(e){C3X.RequireString(e),runtime.GetEventSheetManager().Signal(e)}waitForSignal(e){return C3X.RequireString(e),runtime.GetEventSheetManager().WaitForSignal(e)}getViewportSize(){return[runtime.GetOriginalViewportWidth(),runtime.GetOriginalViewportHeight()]}get isSuspended(){return runtime.IsSuspended()}get dt(){return runtime.GetDt()}get dtRaw(){return runtime.GetDtRaw()}get gameTime(){return runtime.GetGameTime()}get wallTime(){return runtime.GetWallTime()}get timeScale(){return runtime.GetTimeScale()}set timeScale(e){C3X.RequireFiniteNumber(e),runtime.SetTimeScale(e)}get fps(){return didWarnFpsDeprecated||(console.warn("IRuntime.fps is deprecated. Use IRuntime.framesPerSecond instead."),didWarnFpsDeprecated=!0),runtime.GetFramesPerSecond()}get framesPerSecond(){return runtime.GetFramesPerSecond()}get ticksPerSecond(){return runtime.GetTicksPerSecond()}get cpuUtilisation(){return runtime.GetMainThreadTime()}get gpuUtilisation(){return runtime.GetGPUUtilisation()}get framerateMode(){return runtime.GetFramerateMode()}set framerateMode(e){if(!VALID_FRAMERATE_MODES.has(e))throw new Error("invalid framerate mode");runtime._SetFramerateMode(e)}get minDt(){return runtime.GetMinDt()}set minDt(e){C3X.RequireFiniteNumber(e),runtime.SetMinDt(e)}get maxDt(){return runtime.GetMaxDt()}set maxDt(e){runtime.SetMaxDt(e)}get loadingProgress(){return runtime.GetAssetManager().GetLoadProgress()}get imageLoadingProgress(){return runtime.GetAssetManager().GetImageLoadProgress()}random(){return runtime.Random()}get layout(){const e=runtime.GetMainRunningLayout();if(e)return e.GetILayout();throw new Error("no layout is running - make sure a layout is loaded before accessing")}getLayout(e){const t=runtime.GetLayoutManager();let r=null;if("number"!=typeof e&&"string"!=typeof e)throw new TypeError("expected string or number");if(r=t.GetLayout(e))return r.GetILayout();throw new Error("invalid layout")}getAllLayouts(){return runtime.GetLayoutManager().GetAllLayouts().map(e=>e.GetILayout())}goToLayout(e){const t=runtime.GetLayoutManager();let r=null;if("number"!=typeof e&&"string"!=typeof e)throw new TypeError("expected string or number");if(!(r=t.GetLayout(e)))throw new Error("invalid layout");t.IsPendingChangeMainLayout()||t.ChangeMainLayout(r)}get keyboard(){const e=runtime._GetCommonScriptInterfaces().keyboard;if(e)return e;throw new Error("runtime.keyboard used but Keyboard object missing - add it to your project first")}get mouse(){const e=runtime._GetCommonScriptInterfaces().mouse;if(e)return e;throw new Error("runtime.mouse used but Mouse object missing - add it to your project first")}get touch(){const e=runtime._GetCommonScriptInterfaces().touch;if(e)return e;throw new Error("runtime.touch used but Touch object missing - add it to your project first")}get timelineController(){const e=runtime._GetCommonScriptInterfaces().timelineController;if(e)return e;throw new Error("runtime.timelineController used but Timeline Controller object missing - add it to your project first")}invokeDownload(e,t){C3X.RequireString(e),C3X.RequireString(t),runtime.InvokeDownload(e,t)}getInstanceByUid(e){C3X.RequireFiniteNumber(e);const t=runtime.GetInstanceByUID(e);return t?t.GetInterfaceClass():null}sortZOrder(e,n){C3X.RequireFunction(n);const i=runtime.GetCurrentLayout();for(const t of e){const r=runtime._UnwrapIWorldInstance(t),o=r.GetWorldInfo();tempZOrderList.push([o.GetLayer().GetIndex(),o.GetZIndex()]),tempInstances.push(r)}if(0!==tempZOrderList.length){tempZOrderList.sort(SortZOrderList),tempInstances.sort((e,t)=>n(e.GetInterfaceClass(),t.GetInterfaceClass()));let r=!1;for(let e=0,t=tempZOrderList.length;e<t;++e){const a=tempInstances[e],s=i.GetLayerByIndex(tempZOrderList[e][0]),u=tempZOrderList[e][1],l=s._GetInstances();l[u]!==a&&((l[u]=a).GetWorldInfo()._SetLayer(s,!0),s.SetZIndicesChanged(a),r=!0)}r&&runtime.UpdateRender(),C3.clearArray(tempZOrderList),C3.clearArray(tempInstances)}}async createWorker(e,t){const r=new MessageChannel,n=r.port1,i=r.port2;return await runtime.PostComponentMessageToDOMAsync("runtime","script-create-worker",{"url":e,"opts":t,"port2":i},[i]),n}alert(e){return runtime.PostComponentMessageToDOMAsync("runtime","alert",{"message":e+(runtime.IsInWorker()?" [via Web Worker]":"")})}getHTMLLayer(e){return C3X.RequireFiniteNumber(e),runtime._GetHTMLLayerWrapElement(e)}addLoadPromise(e){runtime.AddLoadPromise(e)}}; } // interfaces/other/IAssetManager.js { const C3=self.C3,C3X=self.C3X;let assetManager=null;self.IAssetManager=class{constructor(e){assetManager=e,Object.defineProperties(this,{isWebMOpusSupported:{value:!0,writable:!1}})}loadImageAsset(e){const t=self.IImageInfo._Unwrap(e);if(!t)throw new Error("invalid IImageInfo");t.LoadAsset(assetManager.GetRuntime())}fetchText(e){return assetManager.FetchText(e)}fetchJson(e){return assetManager.FetchJson(e)}fetchBlob(e){return assetManager.FetchBlob(e)}fetchArrayBuffer(e){return assetManager.FetchArrayBuffer(e)}getProjectFileUrl(e){return assetManager.GetProjectFileUrl(e)}getMediaFileUrl(e){return"flat"===assetManager.GetFileStructure()&&C3.IsRelativeURL(e)&&(e=e.toLowerCase()),assetManager.GetMediaFileUrl(e)}get mediaFolder(){return assetManager.GetMediaSubfolder()}async decodeWebMOpus(e,t){throw new Error("decodeWebMOpus() is no longer supported - use Web Audio's decodeAudioData() directly as all supported platforms now support WebM Opus")}loadScripts(...e){return assetManager.LoadScripts(...e)}compileWebAssembly(e){return assetManager.CompileWebAssembly(e)}loadStyleSheet(e){return assetManager.LoadStyleSheet(e)}}; } // interfaces/other/ICollisionEngine.js { const C3=self.C3,C3X=self.C3X;let collisionEngine=null;self.ICollisionEngine=class{constructor(n){collisionEngine=n,Object.defineProperties(this,{runtime:{value:collisionEngine.GetRuntime(),writable:!1}})}testOverlap(n,e){const l=collisionEngine.GetRuntime(),i=l._UnwrapIWorldInstance(n),t=l._UnwrapIWorldInstance(e);return collisionEngine.TestOverlap(i,t)}testOverlapAny(n,e){const l=collisionEngine.GetRuntime(),i=l._UnwrapIWorldInstance(n);for(const t of e){const o=l._UnwrapIWorldInstance(t);if(collisionEngine.TestOverlap(i,o))return t}return null}testOverlapSolid(n){const e=collisionEngine.GetRuntime()._UnwrapIWorldInstance(n),l=collisionEngine.TestOverlapSolid(e);return l?l.GetInterfaceClass():null}setCollisionCellSize(n,e){if(C3X.RequireFiniteNumber(n),C3X.RequireFiniteNumber(e),n=Math.floor(n),e=Math.floor(e),n<=0||e<=0)throw new Error("invalid cell size");collisionEngine.SetCollisionCellSize(n,e)}getCollisionCellSize(){return collisionEngine.GetCollisionCellSize()}getCollisionCandidates(n,e){const l=collisionEngine.GetRuntime();let i;i=Array.isArray(n)?n.map(n=>l._UnwrapIObjectClass(n)):[l._UnwrapIObjectClass(n)];const t=C3.Rect.FromObject(e),o=[];return collisionEngine.GetObjectClassesCollisionCandidates(null,i,t,o),o.map(n=>n.GetInterfaceClass())}}; } // interfaces/other/IPlatformInfo.js { const C3=self.C3,C3X=self.C3X;let runtime=null;const osMap=new Map([["Windows","windows"],["macOS","macos"],["Linux","linux"],["Chrome OS","chrome-os"],["Android","android"],["iOS","ios"]]),browserMap=new Map([["Chrome","chrome"],["Chromium","chromium"],["Edge","edge"],["Opera","opera"],["NW.js","nwjs"],["Firefox","firefox"],["Safari","safari"]]),browserEngineMap=new Map([["Chromium","chromium"],["Gecko","gecko"],["WebKit","webkit"]]);self.IPlatformInfo=class{constructor(e){runtime=e,Object.defineProperties(this,{isMobile:{value:C3.Platform.IsMobile,writable:!1},os:{value:osMap.get(C3.Platform.OS)||"unknown",writable:!1},osVersion:{value:C3.Platform.OSVersion,writable:!1},browser:{value:browserMap.get(C3.Platform.Browser)||"unknown",writable:!1},browserVersion:{value:C3.Platform.BrowserVersion,writable:!1},browserEngine:{value:browserEngineMap.get(C3.Platform.BrowserEngine)||"unknown",writable:!1}})}get exportType(){let e=runtime.GetExportType();return runtime.IsNWjs()?e="nwjs":runtime.IsWindowsWebView2()?e="windows-webview2":"cordova"===e?e="Android"===C3.Platform.OS?"cordova-android":"cordova-ios":"playable-ad-single-file"!==e&&"playable-ad-zip"!==e||(e="playable-ad"),e}get renderer(){return runtime.GetCanvasManager().GetRendererString()}get rendererDetail(){return runtime.GetCanvasManager().GetRendererDetailString()}get canvasCssWidth(){return runtime.GetCanvasManager().GetCssWidth()}get canvasCssHeight(){return runtime.GetCanvasManager().GetCssHeight()}get canvasDeviceWidth(){return runtime.GetCanvasManager().GetDeviceWidth()}get canvasDeviceHeight(){return runtime.GetCanvasManager().GetDeviceHeight()}get devicePixelRatio(){return runtime.GetDevicePixelRatio()}}; } // interfaces/other/IStorage.js { const C3=self.C3,C3X=self.C3X;self.IStorage=class{constructor(e){this._storage=e._GetProjectStorage()}getItem(e){return C3X.RequireString(e),this._storage.getItem(e)}setItem(e,t){return C3X.RequireString(e),this._storage.setItem(e,t)}removeItem(e){return C3X.RequireString(e),this._storage.removeItem(e)}clear(){return this._storage.clear()}keys(){return this._storage.keys()}}; } // interfaces/objects/IPlugin.js { const C3=self.C3,C3X=self.C3X,internalApiToken=C3._GetInternalAPIToken();self.IPlugin=class{#private;constructor(){const e=C3.AddonManager._GetInitObject2(internalApiToken);this.#private=e,Object.defineProperties(this,{runtime:{value:e.GetRuntime().GetIRuntime(),writable:!1},isSingleGlobal:{value:e.IsSingleGlobal(),writable:!1},isWorldType:{value:e.IsWorldType(),writable:!1},isHTMLElementType:{value:e.IsHTMLElementType(),writable:!1},isRotatable:{value:e.IsRotatable(),writable:!1},hasEffects:{value:e.HasEffects(),writable:!1},is3d:{value:e.Is3D(),writable:!1},supportsHierarchies:{value:e.SupportsSceneGraph(),writable:!1},supportsMesh:{value:e.SupportsMesh(),writable:!1}}),e.GetRuntime()._MapScriptInterface(this,e)}static getByConstructor(e){if(!e)return null;const t=C3.AddonManager.GetPluginByConstructorFunction(e);return t?t.GetIPlugin():null}getSingleGlobalObjectType(){return this.#private.GetSingleGlobalObjectClass().GetIObjectClass()}getSingleGlobalInstance(){return this.#private.GetSingleGlobalInstance().GetInterfaceClass()}}; } // interfaces/objects/IObjectClass.js { const C3=self.C3,C3X=self.C3X,internalApiToken=C3._GetInternalAPIToken();self.IObjectClass=class{#private;constructor(){const e=C3.AddonManager._GetInitObject2(internalApiToken);this.#private=e,Object.defineProperties(this,{name:{value:e.GetName(),writable:!1},runtime:{value:e.GetRuntime().GetIRuntime(),writable:!1},plugin:{value:e.GetPlugin().GetIPlugin(),writable:!1}}),e.GetRuntime()._MapScriptInterface(this,e)}addEventListener(e,t){C3X.RequireString(e),C3X.RequireFunction(t),this.#private.UserScriptDispatcher().addEventListener(e,t)}removeEventListener(e,t){C3X.RequireString(e),C3X.RequireFunction(t),this.#private.UserScriptDispatcher().removeEventListener(e,t)}getAllInstances(){return[...this.instances()]}getFirstInstance(){return C3.first(this.instances())}getPickedInstances(){return[...this.pickedInstances()]}getFirstPickedInstance(){return C3.first(this.pickedInstances())}getPairedInstance(e){const t=this.#private,n=t.GetRuntime()._UnwrapIInstance(e),s=t.GetPairedInstance(n);return s?s.GetInterfaceClass():null}*instances(){for(const e of this.#private.instancesIncludingPendingCreate())yield e.GetInterfaceClass()}*pickedInstances(){for(const e of this.#private.GetCurrentSol().GetInstances())yield e.GetInterfaceClass()}setInstanceClass(e){C3X.RequireFunction(e);const t=this.#private;if(0<t.GetInstanceCount())throw new Error("setInstanceClass() called too late, because instances have already been created - call in runOnStartup");t._SetUserScriptInstanceClass(e)}createInstance(e,t,n,s,r){if(C3X.RequireNumber(t),C3X.RequireNumber(n),"number"!=typeof e&&"string"!=typeof e)throw new TypeError("invalid layer parameter");const i=this.#private,a=i.GetRuntime(),c=a.GetMainRunningLayout().GetLayer(e);if(!c)throw new Error("invalid layer");const l=a.CreateInstance(i,c,t,n,s,r),u=(s&&c.SortAndAddInstancesByZIndex(l),a.GetEventSheetManager());return u.BlockFlushingInstances(!0),l._TriggerOnCreatedOnSelfAndRelated(),u.BlockFlushingInstances(!1),u.IsInEventEngine()||a.GetLayoutManager().IsEndingLayout()||a.FlushPendingInstances(),l.GetInterfaceClass()}}; } // interfaces/layouts/ILayout.js { const C3=self.C3,C3X=self.C3X,map=new WeakMap,VALID_WHERE_STRINGS=["above","below","top-sublayer","bottom-sublayer"];self.ILayout=class{constructor(e){map.set(this,e);const t=[],r=e.GetEffectList(),i=r.GetAllEffectTypes().length;for(let e=0;e<i;++e)t.push(new self.IEffectInstance(r,e));Object.defineProperties(this,{name:{value:e.GetName(),writable:!1},index:{value:e.GetIndex(),writable:!1},effects:{value:t,writable:!1}})}addEventListener(e,t){C3X.RequireString(e),C3X.RequireFunction(t),map.get(this).UserScriptDispatcher().addEventListener(e,t)}removeEventListener(e,t){C3X.RequireString(e),C3X.RequireFunction(t),map.get(this).UserScriptDispatcher().removeEventListener(e,t)}get width(){return map.get(this).GetWidth()}set width(e){C3X.RequireFiniteNumber(e),map.get(this).SetWidth(e)}get height(){return map.get(this).GetHeight()}set height(e){C3X.RequireFiniteNumber(e),map.get(this).SetHeight(e)}setSize(e,t){C3X.RequireFiniteNumber(e),C3X.RequireFiniteNumber(t);const r=map.get(this);r.SetWidth(e),r.SetHeight(t)}getSize(){const e=map.get(this);return[e.GetWidth(),e.GetHeight()]}set scale(e){C3X.RequireFiniteNumber(e),map.get(this).SetScale(e)}get scale(){return map.get(this).GetScale()}set angle(e){C3X.RequireFiniteNumber(e),map.get(this).SetAngle(e)}get angle(){return map.get(this).GetAngle()}set scrollX(e){C3X.RequireNumber(e),map.get(this).SetScrollX(e)}get scrollX(){return map.get(this).GetScrollX()}set scrollY(e){C3X.RequireNumber(e),map.get(this).SetScrollY(e)}get scrollY(){return map.get(this).GetScrollY()}scrollTo(e,t){C3X.RequireNumber(e),C3X.RequireNumber(t);const r=map.get(this);r.SetScrollX(e),r.SetScrollY(t)}getScrollPosition(){const e=map.get(this);return[e.GetScrollX(),e.GetScrollY()]}getLayer(e){const t=map.get(this);let r=null;if("number"!=typeof e&&"string"!=typeof e)throw new TypeError("expected string or number");return(r=t.GetLayer(e))?r.GetILayer():null}getAllLayers(){return map.get(this).GetLayers().map(e=>e.GetILayer())}*allLayers(){for(const e of map.get(this).allLayers())yield e.GetILayer()}addLayer(e,t,r){const i=map.get(this),n=self.ILayer,a=(C3X.RequireString(e),C3X.RequireOptionalInstanceOf(t,n),t?i.GetRuntime()._UnwrapScriptInterface(t):null),s=VALID_WHERE_STRINGS.indexOf(r);if(s<0)throw new Error("invalid location");i.AddLayer(e,a,s)}moveLayer(e,t,r){const i=map.get(this),n=i.GetRuntime(),a=self.ILayer,s=(C3X.RequireInstanceOf(e,a),n._UnwrapScriptInterface(e));if(!s)throw new Error("invalid layer");C3X.RequireOptionalInstanceOf(t,a);const o=t?n._UnwrapScriptInterface(t):null,l=VALID_WHERE_STRINGS.indexOf(r);if(l<0)throw new Error("invalid location");i.MoveLayer(s,o,l)}removeLayer(e){const t=map.get(this),r=self.ILayer,i=(C3X.RequireInstanceOf(e,r),t.GetRuntime()._UnwrapScriptInterface(e));if(!i)throw new Error("invalid layer");const n=i.GetRuntime();t.RemoveLayer(i),n.GetEventSheetManager().IsInEventEngine()||n.FlushPendingInstances()}removeAllDynamicLayers(){const e=map.get(this),t=e.GetRuntime();e.RemoveAllDynamicLayers(),t.GetEventSheetManager().IsInEventEngine()||t.FlushPendingInstances()}setVanishingPoint(e,t){C3X.RequireFiniteNumber(e),C3X.RequireFiniteNumber(t),map.get(this).SetVanishingPointXY(e,t)}getVanishingPoint(){return map.get(this)._GetVanishingPoint()}set projection(e){C3X.RequireString(e);const t=map.get(this);if("perspective"===e)t.SetPerspectiveProjection();else{if("orthographic"!==e)throw new Error("invalid projection");t.SetOrthographicProjection()}}get projection(){return map.get(this).IsOrthographicProjection()?"orthographic":"perspective"}}; } // interfaces/layouts/ILayer.js { const C3=self.C3,C3X=self.C3X,map=new WeakMap,BLEND_MODE_TO_INDEX=new Map([["normal",0],["additive",1],["copy",3],["destination-over",4],["source-in",5],["destination-in",6],["source-out",7],["destination-out",8],["source-atop",9],["destination-atop",10]]),INDEX_TO_BLEND_MODE=new Map([...BLEND_MODE_TO_INDEX.entries()].map(e=>[e[1],e[0]])),tempColor=C3.New(C3.Color);self.ILayer=class{constructor(e){map.set(this,e);const t=[],r=e.GetEffectList(),a=r.GetAllEffectTypes().length;for(let e=0;e<a;++e)t.push(new self.IEffectInstance(r,e));Object.defineProperties(this,{name:{value:e.GetName(),writable:!1},layout:{value:e.GetLayout().GetILayout(),writable:!1},effects:{value:t,writable:!1}}),e.GetRuntime()._MapScriptInterface(this,e)}get parentLayer(){const e=map.get(this).GetParentLayer();return e?e.GetILayer():null}*parentLayers(){for(const e of map.get(this).parentLayers())yield e.GetILayer()}*subLayers(){for(const e of map.get(this).GetSubLayers())yield e.GetILayer()}*allSubLayers(){for(const e of map.get(this).GetSubLayers())for(const t of e.selfAndAllSubLayers())yield t.GetILayer()}get index(){return map.get(this).GetIndex()}get isVisible(){return map.get(this)._IsVisibleFlagSet()}set isVisible(e){map.get(this).SetVisible(e)}get isSelfAndParentsVisible(){return map.get(this).IsVisible()}get isInteractive(){return map.get(this).IsInteractive()}set isInteractive(e){map.get(this).SetInteractive(e)}get isHTMLElementsLayer(){return map.get(this).IsHTMLElementsLayer()}set isHTMLElementsLayer(e){map.get(this).SetIsHTMLElementsLayer(!!e)}get isSelfAndParentsInteractive(){return map.get(this).IsSelfAndParentsInteractive()}get opacity(){return map.get(this).GetOpacity()}set opacity(e){e=C3.clamp(+e,0,1),isNaN(e)||map.get(this).SetOpacity(e)}set scale(e){C3X.RequireFiniteNumber(e),map.get(this).SetOwnScale(e)}get scale(){return map.get(this).GetOwnScale()}set scaleRate(e){C3X.RequireFiniteNumber(e),map.get(this).SetScaleRate(e)}get scaleRate(){return map.get(this).GetScaleRate()}set angle(e){C3X.RequireFiniteNumber(e),map.get(this).SetAngle(e)}get angle(){return map.get(this).GetOwnAngle()}set parallaxX(e){C3X.RequireFiniteNumber(e),map.get(this).SetParallaxX(e)}get parallaxX(){return map.get(this).GetParallaxX()}set parallaxY(e){C3X.RequireFiniteNumber(e),map.get(this).SetParallaxY(e)}get parallaxY(){return map.get(this).GetParallaxY()}set zElevation(e){C3X.RequireFiniteNumber(e),map.get(this).SetZElevation(e)}get zElevation(){return map.get(this).GetZElevation()}set isTransparent(e){map.get(this).SetTransparent(e)}get isTransparent(){return map.get(this).IsTransparent()}set isForceOwnTexture(e){map.get(this).SetForceOwnTexture(e)}get isForceOwnTexture(){return map.get(this).IsForceOwnTexture()}set blendMode(e){C3X.RequireString(e);const t=BLEND_MODE_TO_INDEX.get(e);if("number"!=typeof t)throw new Error("invalid blend mode");map.get(this).SetBlendMode(t)}get blendMode(){return INDEX_TO_BLEND_MODE.get(map.get(this).GetBlendMode())}set backgroundColor(e){if(C3X.RequireArray(e),e.length<3)throw new Error("expected 3 elements");tempColor.setRgb(e[0],e[1],e[2]);const t=map.get(this),r=t.GetBackgroundColor();r.equalsIgnoringAlpha(tempColor)||(r.copyRgb(tempColor),t.GetRuntime().UpdateRender())}get backgroundColor(){const e=map.get(this).GetBackgroundColor();return[e.getR(),e.getG(),e.getB()]}set scrollX(e){C3X.RequireNumber(e);const t=map.get(this);t.SetOwnScrollPositionEnabled(!0),t.SetScrollX(e)}get scrollX(){return map.get(this).GetScrollX()}set scrollY(e){C3X.RequireNumber(e);const t=map.get(this);t.SetOwnScrollPositionEnabled(!0),t.SetScrollY(e)}get scrollY(){return map.get(this).GetScrollY()}scrollTo(e,t){C3X.RequireNumber(e),C3X.RequireNumber(t);const r=map.get(this);r.SetOwnScrollPositionEnabled(!0),r.SetScrollX(e),r.SetScrollY(t)}getScrollPosition(){const e=map.get(this);return[e.GetScrollX(),e.GetScrollY()]}restoreScrollPosition(){map.get(this).SetOwnScrollPositionEnabled(!1)}getViewport(){return map.get(this).GetViewport().toDOMRect()}cssPxToLayer(e,t,r=0){C3X.RequireNumber(e),C3X.RequireNumber(t),C3X.RequireNumber(r);const a=map.get(this),s=a.GetRuntime();return a.CanvasCssToLayer(e-s.GetCanvasClientX(),t-s.GetCanvasClientY(),r)}layerToCssPx(e,t,r=0){C3X.RequireNumber(e),C3X.RequireNumber(t),C3X.RequireNumber(r);const a=map.get(this),s=a.GetRuntime(),[i,n]=a.LayerToCanvasCss(e,t,r);return[i+s.GetCanvasClientX(),n+s.GetCanvasClientY()]}drawSurfaceToLayer(e,t,r=0){return C3X.RequireNumber(e),C3X.RequireNumber(t),C3X.RequireNumber(r),map.get(this).DrawSurfaceToLayer(e,t,r)}layerToDrawSurface(e,t,r=0){return C3X.RequireNumber(e),C3X.RequireNumber(t),C3X.RequireNumber(r),map.get(this).LayerToDrawSurface(e,t,r)}get renderScale(){return map.get(this).GetRenderScale()}}; } // interfaces/objects/IInstance.js { const C3=self.C3,C3X=self.C3X,dispatchers=new WeakMap,internalApiToken=C3._GetInternalAPIToken();function GetDispatcher(e){let t=dispatchers.get(e);return t||(t=C3.New(C3.Event.Dispatcher),dispatchers.set(e,t)),t}self.IInstance=class{#private;constructor(){const e=C3.AddonManager._GetInitObject2(internalApiToken),t={runtime:{value:(this.#private=e).GetRuntime().GetIRuntime(),writable:!1},objectType:{value:e.GetObjectClass().GetIObjectClass(),writable:!1},plugin:{value:e.GetPlugin().GetIPlugin(),writable:!1}};e._GetInstVarsScriptDescriptor(t),e._GetBehaviorsScriptDescriptor(t),Object.defineProperties(this,t),e.GetRuntime()._MapScriptInterface(this,e)}static _GetInitInst(){return C3.AddonManager._GetInitObject()}_release(){const e=dispatchers.get(this);e&&(e.Release(),dispatchers.delete(this))}addEventListener(e,t,i){C3X.RequireString(e),C3X.RequireFunction(t),GetDispatcher(this).addEventListener(e,t,i)}removeEventListener(e,t,i){C3X.RequireString(e),C3X.RequireFunction(t),GetDispatcher(this).removeEventListener(e,t,i)}dispatchEvent(e){GetDispatcher(this).dispatchEvent(e)}destroy(){const e=this.#private,t=e.GetRuntime();t.DestroyInstance(e),t.GetEventSheetManager().IsInEventEngine()||t.GetLayoutManager().IsEndingLayout()||t.GetEventSheetManager().IsFlushingBlocked()||t.FlushPendingInstances()}getOtherContainerInstances(){const e=this.#private.GetSiblings();return e?e.map(e=>e.GetInterfaceClass()):[]}*otherContainerInstances(){const e=this.#private;if(e.IsInContainer())for(const t of e.siblings())yield t.GetInterfaceClass()}get uid(){return this.#private.GetUID()}get iid(){return this.#private.GetIID()}get templateName(){return this.#private.GetTemplateName()}set timeScale(e){C3X.RequireFiniteNumber(e),this.#private.SetTimeScale(e)}get timeScale(){return this.#private.GetActiveTimeScale()}restoreTimeScale(){this.#private.RestoreTimeScale()}get dt(){const e=this.#private;return e.GetRuntime().GetDt(e)}hasTags(...e){C3X.RequireArray(e);const t=new Set(e),i=this.#private.GetTagsSet();return t.isSubsetOf(i)}setAllTags(e){C3X.RequireInstanceOf(e,Set),this.#private.SetTagsSet(e)}getAllTags(){return new Set(this.#private.GetTagsSet())}signal(e){C3X.RequireString(e);const t=this.#private;t.GetRuntime().GetEventSheetManager().InstanceSignal(t,e)}waitForSignal(e){C3X.RequireString(e);const t=this.#private;return t.GetRuntime().GetEventSheetManager().WaitForInstanceSignal(t,e)}}; } // interfaces/sdk/ISDKInstanceBase.js { const C3=self.C3,C3X=self.C3X,internalApiToken=C3._GetInternalAPIToken();self.ISDKInstanceBase=class extends self.IInstance{#private;#isTicking=!1;#tickFunc=null;#isTicking2=!1;#tickFunc2=null;#domComponentId;#wrapperComponentId;constructor(e){super(),this.#private=C3.AddonManager._GetInitObject2(internalApiToken),this.#isTicking=!1,this.#tickFunc=null,this.#isTicking2=!1,this.#tickFunc2=null,this.#domComponentId=e?.domComponentId,this.#wrapperComponentId=e?.wrapperComponentId}_release(){this._setTicking(!1),this._setTicking2(!1),super._release()}_getInitProperties(){return C3.AddonManager._GetInitProperties()}_trigger(e){const t=this.#private;t.GetRuntime().Trigger(e,t)}_triggerAsync(e){const t=this.#private;return t.GetRuntime().TriggerAsync(e,t)}_addDOMMessageHandler(e,t){if(C3X.RequireString(e),C3X.RequireFunction(t),!this.#domComponentId)throw new Error("no DOM component id set");const n=this.#private.GetRuntime();n.AddDOMComponentMessageHandler(this.#domComponentId,e,t)}_addDOMMessageHandlers(e){C3X.RequireArray(e);for(const[t,n]of e)this._addDOMMessageHandler(t,n)}_postToDOM(e,t){if(C3X.RequireString(e),!this.#domComponentId)throw new Error("no DOM component id set");const n=this.#private.GetRuntime();n.PostComponentMessageToDOM(this.#domComponentId,e,t)}_postToDOMAsync(e,t){if(C3X.RequireString(e),!this.#domComponentId)throw new Error("no DOM component id set");const n=this.#private.GetRuntime();return n.PostComponentMessageToDOMAsync(this.#domComponentId,e,t)}_postToDOMMaybeSync(e,t){const n=this.#private.GetRuntime();if(!n.IsInWorker())return window["c3_runtimeInterface"]["_OnMessageFromRuntime"]({"type":"event","component":this.#domComponentId,"handler":e,"data":t,"responseId":null});this._postToDOM(e,t)}_setTicking(e){if(this.#isTicking!==(e=!!e)){this.#isTicking=e;const t=this.#private.GetRuntime();if(e){if(!this.#tickFunc)if(this.#private.GetRuntime().IsDebug()){const n=globalThis.C3Debugger,i=this.plugin;this.#tickFunc=()=>{const e=performance.now();this._tick(),n.AddIndividualPluginTickTime(i,performance.now()-e)}}else this.#tickFunc=()=>this._tick();t.Dispatcher().addEventListener("tick",this.#tickFunc)}else t.Dispatcher().removeEventListener("tick",this.#tickFunc)}}_isTicking(){return this.#isTicking}_tick(){}_setTicking2(e){if(this.#isTicking2!==(e=!!e)){this.#isTicking2=e;const t=this.#private.GetRuntime();if(e){if(!this.#tickFunc2)if(this.#private.GetRuntime().IsDebug()){const n=globalThis.C3Debugger,i=this.plugin;this.#tickFunc2=()=>{const e=performance.now();this._tick2(),n.AddIndividualPluginTickTime(i,performance.now()-e)}}else this.#tickFunc2=()=>this._tick2();t.Dispatcher().addEventListener("tick2",this.#tickFunc2)}else t.Dispatcher().removeEventListener("tick2",this.#tickFunc2)}}_isTicking2(){return this.#isTicking2}_tick2(){}_getDebuggerProperties(){return[]}_saveToJson(){return null}_loadFromJson(e){}_isWrapperExtensionAvailable(){if(!this.#wrapperComponentId)throw new Error("no wrapper component id set");const e=this.#private.GetRuntime();return e.HasWrapperComponentId(this.#wrapperComponentId)}_addWrapperExtensionMessageHandler(e,t){if(C3X.RequireString(e),C3X.RequireFunction(t),!this.#wrapperComponentId)throw new Error("no wrapper component id set");const n=this.#private.GetRuntime();n.AddWrapperExtensionMessageHandler(this.#wrapperComponentId,e,t)}_addWrapperMessageHandlers(e){C3X.RequireArray(e);for(const[t,n]of e)this._addWrapperExtensionMessageHandler(t,n)}_sendWrapperExtensionMessage(e,t){if(!this.#wrapperComponentId)throw new Error("no wrapper component id set");this.runtime.sdk.sendWrapperExtensionMessage(this.#wrapperComponentId,e,t)}_sendWrapperExtensionMessageAsync(e,t){if(this.#wrapperComponentId)return this.runtime.sdk.sendWrapperExtensionMessageAsync(this.#wrapperComponentId,e,t);throw new Error("no wrapper component id set")}}; } // interfaces/objects/IWorldInstance.js { const C3=self.C3,C3X=self.C3X,IInstance=self.IInstance,ILayer=self.ILayer,map=new WeakMap,internalApiToken=C3._GetInternalAPIToken(),BLEND_MODE_TO_INDEX=new Map([["normal",0],["additive",1],["copy",3],["destination-over",4],["source-in",5],["destination-in",6],["source-out",7],["destination-out",8],["source-atop",9],["destination-atop",10]]),INDEX_TO_BLEND_MODE=new Map([...BLEND_MODE_TO_INDEX.entries()].map(e=>[e[1],e[0]])),tempColor=C3.New(C3.Color);function MakeIWorldInstanceClass(e){return class r extends e{#privateInst;#privateWi;constructor(e){super(e);const t=C3.AddonManager._GetInitObject2(internalApiToken),i=t.GetWorldInfo(),n=(this.#privateInst=t,this.#privateWi=i,map.set(this,t),[]),r=i.GetInstanceEffectList();if(r){const a=i.GetObjectClass().GetEffectList().GetAllEffectTypes().length;for(let e=0;e<a;++e)n.push(new self.IEffectInstance(r,e))}const s={effects:{value:n,writable:!1}};Object.defineProperties(this,s)}get layout(){return this.#privateWi.GetLayout().GetILayout()}get layer(){return this.#privateWi.GetLayer().GetILayer()}get x(){return this.#privateWi.GetX()}set x(e){e=+e;const t=this.#privateWi;isNaN(e)||t.GetX()===e||(t.SetX(e),t.SetBboxChanged())}get y(){return this.#privateWi.GetY()}set y(e){e=+e;const t=this.#privateWi;isNaN(e)||t.GetY()===e||(t.SetY(e),t.SetBboxChanged())}setPosition(e,t){e=+e,t=+t;const i=this.#privateWi;isNaN(e)||isNaN(t)||i.GetX()===e&&i.GetY()===t||(i.SetXY(e,t),i.SetBboxChanged())}getPosition(){const e=this.#privateWi;return[e.GetX(),e.GetY()]}offsetPosition(e,t){if(e=+e,t=+t,!(isNaN(e)||isNaN(t)||0===e&&0===t)){const i=this.#privateWi;i.OffsetXY(e,t),i.SetBboxChanged()}}get zElevation(){return this.#privateWi.GetZElevation()}set zElevation(e){e=+e;const t=this.#privateInst,i=this.#privateWi;isNaN(e)||i.GetZElevation()===e||(i.SetZElevation(e),t.GetRuntime().UpdateRender())}get totalZElevation(){return this.#privateWi.GetTotalZElevation()}get width(){return this.#privateWi.GetWidth()}set width(e){e=+e;const t=this.#privateWi;isNaN(e)||t.GetWidth()===e||(t.SetWidth(e),t.SetBboxChanged())}get height(){return this.#privateWi.GetHeight()}set height(e){e=+e;const t=this.#privateWi;isNaN(e)||t.GetHeight()===e||(t.SetHeight(e),t.SetBboxChanged())}setSize(e,t){e=+e,t=+t;const i=this.#privateWi;isNaN(e)||isNaN(t)||i.GetWidth()===e&&i.GetHeight()===t||(i.SetSize(e,t),i.SetBboxChanged())}getSize(){const e=this.#privateWi;return[e.GetWidth(),e.GetHeight()]}get angle(){return this.#privateWi.GetAngle()}set angle(e){e=C3.clampAngle(+e);const t=this.#privateWi;isNaN(e)||t.GetAngle()===e||(t.SetAngle(e),t.SetBboxChanged())}get angleDegrees(){return C3.toDegrees(this.angle)}set angleDegrees(e){this.angle=C3.toRadians(e)}getBoundingBox(){return this.#privateWi.GetBoundingBox().toDOMRect()}getBoundingQuad(){return this.#privateWi.GetBoundingQuad().toDOMQuad()}isOnScreen(){return this.#privateWi.IsInViewport2()}get isVisible(){return this.#privateWi.IsVisible()}set isVisible(e){e=!!e;const t=this.#privateInst,i=this.#privateWi;i.IsVisible()!==e&&(i.SetVisible(e),t.GetRuntime().UpdateRender())}get opacity(){return this.#privateWi.GetOpacity()}set opacity(e){e=C3.clamp(+e,0,1);const t=this.#privateInst,i=this.#privateWi;isNaN(e)||i.GetOpacity()===e||(i.SetOpacity(e),t.GetRuntime().UpdateRender())}set colorRgb(e){if(C3X.RequireArray(e),e.length<3)throw new Error("expected 3 elements");tempColor.setRgb(e[0],e[1],e[2]);const t=this.#privateInst,i=this.#privateWi;i.GetUnpremultipliedColor().equalsIgnoringAlpha(tempColor)||(i.SetUnpremultipliedColor(tempColor),t.GetRuntime().UpdateRender())}get colorRgb(){const e=this.#privateWi.GetUnpremultipliedColor();return[e.getR(),e.getG(),e.getB()]}set blendMode(e){C3X.RequireString(e);const t=BLEND_MODE_TO_INDEX.get(e);if("number"!=typeof t)throw new Error("invalid blend mode");const i=this.#privateInst,n=this.#privateWi;n.SetBlendMode(t),i.GetRuntime().UpdateRender()}get blendMode(){return INDEX_TO_BLEND_MODE.get(this.#privateWi.GetBlendMode())}moveToTop(){this.#privateWi.ZOrderMoveToTop()}moveToBottom(){this.#privateWi.ZOrderMoveToBottom()}moveToLayer(e){C3X.RequireInstanceOf(e,ILayer);const t=this.#privateInst,i=t.GetRuntime()._UnwrapScriptInterface(e);if(!i)throw new Error("invalid layer");t.GetWorldInfo().ZOrderMoveToLayer(i)}moveAdjacentToInstance(e,t){C3X.RequireInstanceOf(e,r),this.#privateWi.ZOrderMoveAdjacentToInstance(map.get(e),t)}get zIndex(){return this.#privateWi.GetZIndex()}get isCollisionEnabled(){return this.#privateWi.IsCollisionEnabled()}set isCollisionEnabled(e){this.#privateWi.SetCollisionEnabled(!!e)}containsPoint(e,t){return C3X.RequireNumber(e),C3X.RequireNumber(t),this.#privateWi.ContainsPoint(+e,+t)}testOverlap(e){C3X.RequireInstanceOf(e,r);const t=this.#privateInst,i=map.get(e);return t.GetRuntime().GetCollisionEngine().TestOverlap(t,i)}testOverlapSolid(){const e=this.#privateInst,t=e.GetRuntime().GetCollisionEngine().TestOverlapSolid(e);return t?t.GetInterfaceClass():null}getParent(){const e=this.#privateInst.GetParent();return e?e.GetInterfaceClass():null}getTopParent(){const e=this.#privateInst.GetTopParent();return e?e.GetInterfaceClass():null}*parents(){for(const e of this.#privateInst.parents())yield e.GetInterfaceClass()}getChildCount(){return this.#privateInst.GetChildCount()}getChildAt(e){const t=this.#privateInst.GetChildAt(e);return t?t.GetInterfaceClass():null}*children(){for(const e of this.#privateInst.children())yield e.GetInterfaceClass()}*allChildren(){for(const e of this.#privateInst.allChildren())yield e.GetInterfaceClass()}addChild(e,t){C3X.RequireInstanceOf(e,r),C3X.RequireOptionalObject(t),t=t||{};const i=this.#privateInst,n=map.get(e);i.AddChild(n,t)}removeChild(e){C3X.RequireInstanceOf(e,r);const t=this.#privateInst,i=map.get(e);t.RemoveChild(i)}removeFromParent(){const e=this.#privateInst;if(e.HasParent()){const t=e.GetParent();t.RemoveChild(e)}}getHierarchyOpts(){const e=this.#privateWi;return{transformX:e.GetTransformWithParentX(),transformY:e.GetTransformWithParentY(),transformWidth:e.GetTransformWithParentWidth(),transformHeight:e.GetTransformWithParentHeight(),transformAngle:e.GetTransformWithParentAngle(),transformZElevation:e.GetTransformWithParentZElevation(),transformOpacity:e.GetTransformWithParentOpacity(),transformVisibility:e.GetTransformWithParentVisibility(),destroyWithParent:e.GetDestroyWithParent()}}createMesh(e,t){C3X.RequireFiniteNumber(e),C3X.RequireFiniteNumber(t),this.#privateWi.CreateMesh(e,t)}releaseMesh(){const e=this.#privateWi;e.ReleaseMesh(),e.SetBboxChanged()}setMeshPoint(e,t,i){C3X.RequireFiniteNumber(e),C3X.RequireFiniteNumber(t),C3X.RequireObject(i);const n=this.#privateWi;n.SetMeshPoint(e,t,i)&&n.SetBboxChanged()}getMeshPoint(e,t){let i=NaN,n=NaN,r=NaN,s=NaN,a=NaN;const o=this.#privateWi;if(o.HasMesh()){const l=o.GetSourceMesh(),h=l.GetMeshPointAt(e,t);null!==h&&(i=h.GetX(),n=h.GetY(),r=h.GetZElevation(),s=h.GetU(),a=h.GetV())}return{x:i,y:n,zElevation:r,u:s,v:a}}getMeshSize(){const e=this.#privateWi;if(!e.HasMesh())return[0,0];const t=e.GetSourceMesh();return[t.GetHSize(),t.GetVSize()]}}}self.IWorldInstance=MakeIWorldInstanceClass(self.IInstance),self.IWorldInstanceSDKBase=MakeIWorldInstanceClass(self.ISDKInstanceBase); } // interfaces/objects/IDOMInstance.js { const C3=self.C3,C3X=self.C3X;self.IDOMInstance=class extends self.IWorldInstance{#private;constructor(){super(),this.#private=self.IInstance._GetInitInst()}getElement(){return this.#private.GetSdkInstance()._GetElementInDOMMode()}focus(){this.#private.GetSdkInstance().FocusElement()}blur(){this.#private.GetSdkInstance().BlurElement()}setCssStyle(e,t){C3X.RequireString(e),this.#private.GetSdkInstance().SetElementCSSStyle(e,t)}}; } // interfaces/objects/IBehaviorInstance.js { const C3=self.C3,C3X=self.C3X,dispatchers=new WeakMap,internalApiToken=C3._GetInternalAPIToken();function GetDispatcher(e){let t=dispatchers.get(e);return t||(t=C3.New(C3.Event.Dispatcher),dispatchers.set(e,t)),t}self.IBehaviorInstance=class{#private;constructor(){const e=C3.AddonManager._GetInitObject2(internalApiToken),t={runtime:{value:(this.#private=e).GetRuntime().GetIRuntime(),writable:!1},behavior:{value:e.GetBehavior().GetIBehavior(),writable:!1},behaviorType:{value:e.GetBehaviorType().GetIBehaviorType(),writable:!1}};Object.defineProperties(this,t),e.GetRuntime()._MapScriptInterface(this,e)}static _GetInitInst(){return C3.AddonManager._GetInitObject()}get instance(){return this.#private.GetObjectInstance().GetInterfaceClass()}_release(){const e=dispatchers.get(this);e&&(e.Release(),dispatchers.delete(this))}addEventListener(e,t,i){C3X.RequireString(e),C3X.RequireFunction(t),GetDispatcher(this).addEventListener(e,t,i)}removeEventListener(e,t,i){C3X.RequireString(e),C3X.RequireFunction(t),GetDispatcher(this).removeEventListener(e,t,i)}dispatchEvent(e){GetDispatcher(this).dispatchEvent(e)}}; } // interfaces/objects/IBehaviorType.js { const C3=self.C3,C3X=self.C3X,internalApiToken=C3._GetInternalAPIToken();self.IBehaviorType=class{constructor(){const e=C3.AddonManager._GetInitObject2(internalApiToken),t={runtime:{value:e.GetRuntime().GetIRuntime(),writable:!1},behavior:{value:e.GetBehavior().GetIBehavior(),writable:!1},name:{value:e.GetName(),writable:!1}};Object.defineProperties(this,t)}}; } // interfaces/objects/IBehavior.js { const C3=self.C3,C3X=self.C3X,internalApiToken=C3._GetInternalAPIToken();self.IBehavior=class{#private;constructor(){const t=C3.AddonManager._GetInitObject2(internalApiToken),e={runtime:{value:(this.#private=t).GetRuntime().GetIRuntime(),writable:!1}};Object.defineProperties(this,e),t.GetRuntime()._MapScriptInterface(this,t)}getAllInstances(){return this.#private.GetInstances().map(t=>t.GetInterfaceClass())}static getByConstructor(t){if(!t)return null;const e=C3.AddonManager.GetBehaviorByConstructorFunction(t);return e?e.GetIBehavior():null}}; } // interfaces/objects/IEffectInstance.js { const C3=self.C3,C3X=self.C3X,tempColor=C3.New(C3.Color);self.IEffectInstance=class{#private;constructor(e,t){this.#private=e;const i={index:{value:t,writable:!1}};Object.defineProperties(this,i)}get name(){const e=this.#private.GetAllEffectTypes();return e[this.index].GetName()}get isActive(){return this.#private.IsEffectIndexActive(this.index)}set isActive(e){e=!!e;const t=this.#private;t.IsEffectIndexActive(this.index)!==e&&(t.SetEffectIndexActive(this.index,e),t.UpdateActiveEffects(),t.GetRuntime().UpdateRender())}setParameter(e,t){C3X.RequireFiniteNumber(e),e=Math.floor(+e);const i=this.#private,r=i.GetEffectParameter(this.index,e);if(null===r)throw new RangeError("invalid index");if(r instanceof C3.Color){if(!Array.isArray(t)||t.length<3)throw new TypeError("expected array with 3 elements");tempColor.setRgb(t[0],t[1],t[2]),t=tempColor}else if("number"!=typeof t)throw new TypeError("expected number");const n=i.SetEffectParameter(this.index,e,t);n&&i.IsEffectIndexActive(this.index)&&i.GetRuntime().UpdateRender()}getParameter(e){C3X.RequireFiniteNumber(e),e=Math.floor(+e);const t=this.#private,i=t.GetEffectParameter(this.index,e);if(null===i)throw new RangeError("invalid index");return i instanceof C3.Color?[i.getR(),i.getG(),i.getB()]:i}}; } // interfaces/objects/IAnimation.js { const C3=self.C3,C3X=self.C3X;self.IAnimation=class{#private;constructor(e){this.#private=e,Object.defineProperties(this,{name:{value:e.GetName(),writable:!1}})}get speed(){return this.#private.GetSpeed()}get isLooping(){return this.#private.IsLooping()}get repeatCount(){return this.#private.GetRepeatCount()}get repeatTo(){return this.#private.GetRepeatTo()}get isPingPong(){return this.#private.IsPingPong()}get frameCount(){return this.#private.GetFrameCount()}getFrames(){return this.#private.GetFrames().map(e=>e.GetIAnimationFrame())}*frames(){for(const e of this.#private.GetFrames())yield e.GetIAnimationFrame()}}; } // interfaces/objects/IImageInfo.js { const C3=self.C3,C3X=self.C3X;self.IImageInfo=class{#private;constructor(t){this.#private=t}static _Unwrap(t){return t.#private}get width(){return this.#private.GetWidth()}get height(){return this.#private.GetHeight()}getSize(){const t=this.#private;return[t.GetWidth(),t.GetHeight()]}getTexture(t){return t.getTextureForImageInfo(this)}getTexRect(){return this.#private.GetTexRect().toDOMRect()}}; } // interfaces/objects/IAnimationFrame.js { const C3=self.C3,C3X=self.C3X;self.IAnimationFrame=class extends self.IImageInfo{#private;constructor(t){super(t.GetImageInfo()),this.#private=t,Object.defineProperties(this,{duration:{value:t.GetDuration(),writable:!1},originX:{value:t.GetOriginX(),writable:!1},originY:{value:t.GetOriginY(),writable:!1}})}getOrigin(){const t=this.#private;return[t.GetOriginX(),t.GetOriginY()]}getImagePointCount(){return this.#private.GetImagePointCount()}getImagePointX(t){return this.getImagePoint(t)[0]}getImagePointY(t){return this.getImagePoint(t)[1]}getImagePoint(t){const e=this.#private;let i=null;if("number"==typeof t)i=e.GetImagePointByIndex(Math.floor(t));else{if("string"!=typeof t)throw new TypeError("expected string or number");i=e.GetImagePointByName(t)}return i?[i.GetX(),i.GetY()]:this.getOrigin()}getPolyPointCount(){const t=this.#private.GetCollisionPoly();return t?t.pointCount():0}getPolyPointX(t){return this.getPolyPoint(t)[0]}getPolyPointY(t){return this.getPolyPoint(t)[1]}getPolyPoint(t){C3X.RequireFiniteNumber(t),t=Math.floor(t);const e=this.#private.GetCollisionPoly();if(!e||t<0||t>=e.pointCount())return[0,0];const i=e.pointsArr(),n=i[2*t],r=i[2*t+1];return[n,r]}get tag(){return this.#private.GetTag()}}; } // interfaces/other/ITimelineStateBase.js { const C3=self.C3,C3X=self.C3X,map=new WeakMap;function GetTimelineState(e){const t=map.get(e);if(t.IsReleased())throw new Error("timeline/tween was released and is no longer valid");return t}self.ITimelineStateBase=class{constructor(e){map.set(this,e),e.GetRuntime()._MapScriptInterface(this,e)}pause(){GetTimelineState(this).Stop()}resume(){GetTimelineState(this).Resume()}stop(){GetTimelineState(this).Reset()}hasTags(e){return GetTimelineState(this).HasTags(e)}set time(e){C3X.RequireFiniteNumber(e),GetTimelineState(this).SetTime(e)}get time(){return GetTimelineState(this).GetTime()}set totalTime(e){C3X.RequireFiniteNumber(e),GetTimelineState(this).SetTotalTime(e)}get totalTime(){return GetTimelineState(this).GetTotalTime()}set isLooping(e){GetTimelineState(this).SetLoop(!!e)}get isLooping(){return GetTimelineState(this).GetLoop()}set isPingPong(e){GetTimelineState(this).SetPingPong(!!e)}get isPingPong(){return GetTimelineState(this).GetPingPong()}set playbackRate(e){C3X.RequireFiniteNumber(e),GetTimelineState(this).SetPlaybackRate(e)}get playbackRate(){return GetTimelineState(this).GetPlaybackRate()}get progress(){const e=GetTimelineState(this);return e.GetTime()/e.GetTotalTime()}get tags(){return GetTimelineState(this).GetTags()}get finished(){return GetTimelineState(this).GetPlayPromise()}get isPlaying(){return GetTimelineState(this).IsPlaying()}get isPaused(){return GetTimelineState(this).IsPaused()}get isReleased(){return map.get(this).IsReleased()}}; } // interfaces/other/ITimelineState.js { const C3=self.C3,C3X=self.C3X,map=new WeakMap;let easeToIndexFunc=null;function GetTimelineState(e){const t=map.get(e);if(t.IsReleased())throw new Error("timeline was released and is no longer valid");return t}self.ITimelineState=class extends self.ITimelineStateBase{constructor(e){super(e),map.set(this,e);const t={name:{value:e.GetName(),writable:!1}};Object.defineProperties(this,t)}}; } // interfaces/other/ITweenState.js { const C3=self.C3,C3X=self.C3X,map=new WeakMap,behInstMap=new WeakMap;let easeToIndexFunc=null;function GetTweenState(e){const t=map.get(e);if(t.IsReleased())throw new Error("tween was released and is no longer valid");return t}self.ITweenState=class extends self.ITimelineStateBase{constructor(e,t,n){super(e),easeToIndexFunc=easeToIndexFunc||n.easeToIndexFunc,map.set(this,e),t&&behInstMap.set(this,t)}stop(){const e=GetTweenState(this),t=behInstMap.get(this);t.ReleaseTween(e)}setEase(e){C3X.RequireString(e);const t=self.Ease.GetEaseFromIndex(easeToIndexFunc(e));GetTweenState(this).SetEase(t)}get instance(){const e=GetTweenState(this).GetInstance();return e?e.GetInterfaceClass():null}get isDestroyOnComplete(){return GetTweenState(this).GetDestroyInstanceOnComplete()}set isDestroyOnComplete(e){GetTweenState(this).SetDestroyInstanceOnComplete(!!e)}get value(){const e=GetTweenState(this);if("value"!==e.GetId())throw new Error("not a value tween");return e.GetPropertyTrack("value").GetSourceAdapterValue()}}; } // interfaces/sdk/ISDKPluginBase.js { const C3=self.C3,C3X=self.C3X;self.ISDKPluginBase=class extends self.IPlugin{constructor(){super()}}; } // interfaces/sdk/ISDKDOMPluginBase.js { const C3=self.C3,C3X=self.C3X,internalApiToken=C3._GetInternalAPIToken();self.ISDKDOMPluginBase=class extends self.ISDKPluginBase{#private;#domComponentId;#nextElementId=0;#instMap=new Map;constructor(e){if(super(),this.#private=C3.AddonManager._GetInitObject2(internalApiToken),!e?.domComponentId)throw new Error("no DOM component ID specified");this.#domComponentId=e.domComponentId,this._addElementMessageHandler("elem-focused",e=>e._onElemFocused()),this._addElementMessageHandler("elem-blurred",e=>{e&&e._onElemBlurred()})}_addElement(e){const n=this.#nextElementId++;return this.#instMap.set(n,e),n}_removeElement(e){this.#instMap.delete(e)}_addElementMessageHandler(e,t){const n=this.#private.GetRuntime();n.AddDOMComponentMessageHandler(this.#domComponentId,e,e=>{const n=this.#instMap.get(e["elementId"]);t(n,e)})}_addElementMessageHandlers(e){C3X.RequireArray(e);for(const[n,t]of e)this._addElementMessageHandlers(n,t)}}; } // interfaces/sdk/ISDKObjectTypeBase.js { const C3=self.C3,C3X=self.C3X,map=new WeakMap,internalApiToken=C3._GetInternalAPIToken();self.ISDKObjectTypeBase=class extends self.IObjectClass{#private;constructor(){super(),this.#private=C3.AddonManager._GetInitObject2(internalApiToken)}_onCreate(){}getImageInfo(){return this.#private.GetImageInfo().GetIImageInfo()}_loadTextures(e){}_releaseTextures(e){}_onDynamicTextureLoadComplete(){}_preloadTexturesWithInstances(e){}}; } // interfaces/sdk/ISDKWorldInstanceBase.js { const C3=self.C3,C3X=self.C3X,map=new WeakMap,internalApiToken=C3._GetInternalAPIToken();self.ISDKWorldInstanceBase=class extends self.IWorldInstanceSDKBase{#private;#renderercontextlost_handler=null;#renderercontextrestored_handler=null;constructor(e){super(e),this.#private=C3.AddonManager._GetInitObject2(internalApiToken)}_release(){if(super._release(),this.#renderercontextlost_handler){const e=this.#private.GetRuntime().Dispatcher();e.removeEventListener("renderercontextlost",this.#renderercontextlost_handler),e.removeEventListener("renderercontextrestored",this.#renderercontextrestored_handler),this.#renderercontextlost_handler=null,this.#renderercontextrestored_handler=null}}_handleRendererContextLoss(){if(!this.#renderercontextlost_handler){this.#renderercontextlost_handler=()=>this._onRendererContextLost(),this.#renderercontextrestored_handler=()=>this._onRendererContextRestored();const e=this.#private.GetRuntime().Dispatcher();e.addEventListener("renderercontextlost",this.#renderercontextlost_handler),e.addEventListener("renderercontextrestored",this.#renderercontextrestored_handler)}}_onRendererContextLost(){}_onRendererContextRestored(){}_draw(e){}}; } // interfaces/sdk/ISDKDOMInstanceBase.js { const C3=self.C3,C3X=self.C3X,tempRect=C3.New(C3.Rect),map=new WeakMap,internalApiToken=C3._GetInternalAPIToken();self.ISDKDOMInstanceBase=class extends self.ISDKWorldInstanceBase{#elementId=-1;#isElementShowing=!0;#elemHasFocus=!1;#autoFontSize=!1;#autoFontSizeOffset=-.2;#lastRect=C3.New(C3.Rect,0,0,-1,-1);#lastWindowWidth=0;#lastWindowHeight=0;#lastHTMLIndex=-1;#lastHTMLZIndex=-1;#isPendingUpdateState=!1;constructor(e){if(!e?.domComponentId)throw new Error("no DOM component ID specified");super(e);const t=C3.AddonManager._GetInitObject2(internalApiToken),s=(map.set(this,t),this.#elementId=this.plugin._addElement(this),t.GetRuntime().GetCanvasManager());this.#lastWindowWidth=s.GetLastWidth(),this.#lastWindowHeight=s.GetLastHeight(),this._setTicking(!0)}_release(){super._release(),this.plugin._removeElement(this.#elementId),this._postToDOMElement("destroy"),this.#elementId=-1,map.delete(this)}_getElementInDOMMode(){const e=map.get(this).GetRuntime();if(e.IsInWorker())throw new Error("not valid in worker mode");return this._postToDOMElementMaybeSync("get-element")}_postToDOMElement(e,t){(t=t||{})["elementId"]=this.#elementId,this._postToDOM(e,t)}_postToDOMElementMaybeSync(e,t){return(t=t||{})["elementId"]=this.#elementId,this._postToDOMMaybeSync(e,t)}_postToDOMElementAsync(e,t){return(t=t||{})["elementId"]=this.#elementId,this._postToDOMAsync(e,t)}_createElement(e){e=e||{};const t=map.get(this).GetWorldInfo();e["elementId"]=this.#elementId,e["isVisible"]=t.IsVisible(),e["htmlIndex"]=t.GetLayer().GetHTMLIndex(),e["htmlZIndex"]=t.GetHTMLZIndex(),Object.assign(e,this._getElementState()),this.#isElementShowing=!!e["isVisible"],this._postToDOMMaybeSync("create",e),this._updatePosition(!0)}setElementVisible(e){this.#isElementShowing!==(e=!!e)&&(this.#isElementShowing=e,this._postToDOMElement("set-visible",{"isVisible":e}))}_tick(){this._updatePosition(!1)}_shouldPreserveElement(){const e=map.get(this).GetRuntime(),t=e.GetCanvasManager().GetFullscreenMode();return"Android"===C3.Platform.OS&&("scale-inner"===t||"scale-outer"===t||"crop"===t)}_updatePosition(n){const o=map.get(this);if(!o.IsDestroyed()){const l=o.GetWorldInfo(),a=l.GetLayer(),h=l.GetBoundingBox();let[e,t]=a.LayerToCanvasCss(h.getLeft(),h.getTop()),[s,i]=a.LayerToCanvasCss(h.getRight(),h.getBottom());const m=o.GetRuntime().GetCanvasManager(),d=m.GetCssWidth(),r=m.GetCssHeight();if(l.IsVisible()&&a.IsVisible())if(!this._shouldPreserveElement()&&(s<=0||i<=0||d<=e||r<=t))this.setElementVisible(!1);else{tempRect.set(e,t,s,i);const c=m.GetLastWidth(),p=m.GetLastHeight(),u=a.GetHTMLIndex(),M=l.GetHTMLZIndex();if(!n&&tempRect.equals(this.#lastRect)&&this.#lastWindowWidth===c&&this.#lastWindowHeight===p&&this.#lastHTMLIndex===u&&this.#lastHTMLZIndex===M)this.setElementVisible(!0);else{this.#lastRect.copy(tempRect),this.#lastWindowWidth=c,this.#lastWindowHeight=p,this.#lastHTMLIndex=u,this.#lastHTMLZIndex=M,this.setElementVisible(!0);let e=null;this.#autoFontSize&&(e=a.GetDisplayScale()+this.#autoFontSizeOffset),this._postToDOMElement("update-position",{"left":Math.round(this.#lastRect.getLeft()),"top":Math.round(this.#lastRect.getTop()),"width":Math.round(this.#lastRect.width()),"height":Math.round(this.#lastRect.height()),"htmlIndex":u,"htmlZIndex":M,"fontSize":e})}}else this.setElementVisible(!1)}}focusElement(){this._postToDOMElementMaybeSync("focus",{"focus":!0})}blurElement(){this._postToDOMElementMaybeSync("focus",{"focus":!1})}_onElemFocused(){this.#elemHasFocus=!0}_onElemBlurred(){this.#elemHasFocus=!1}isElementFocused(){return this.#elemHasFocus}setElementCSSStyle(e,t){this.postToDOMElement("set-css-style",{"prop":C3.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}}; } // interfaces/sdk/ISDKBehaviorBase.js { const C3=self.C3,C3X=self.C3X;self.ISDKBehaviorBase=class extends self.IBehavior{constructor(){super()}}; } // interfaces/sdk/ISDKBehaviorTypeBase.js { const C3=self.C3,C3X=self.C3X;self.ISDKBehaviorTypeBase=class extends globalThis.IBehaviorType{constructor(){super()}_onCreate(){}}; } // interfaces/sdk/ISDKBehaviorInstanceBase.js { const C3=self.C3,C3X=self.C3X,map=new WeakMap,internalApiToken=C3._GetInternalAPIToken();self.ISDKBehaviorInstanceBase=class extends self.IBehaviorInstance{#isTicking=!1;#isTicking2=!1;#isPostTicking=!1;constructor(){super(),map.set(this,C3.AddonManager._GetInitObject2(internalApiToken))}_release(){super._release(),this._setTicking(!1),this._setTicking2(!1),this._setPostTicking(!1),map.delete(this)}_getInitProperties(){return C3.AddonManager._GetInitProperties()}_postCreate(){}_trigger(i){const t=map.get(this);t.GetRuntime().Trigger(i,t.GetObjectInstance(),t.GetBehaviorType())}_triggerAsync(i){const t=map.get(this);return t.GetRuntime().TriggerAsync(i,t.GetObjectInstance(),t.GetBehaviorType())}_setTicking(i){if(this.#isTicking!==(i=!!i)){this.#isTicking=i;const t=map.get(this).GetRuntime();i?t._AddBehInstToTick(this):t._RemoveBehInstToTick(this)}}_isTicking(){return this.#isTicking}_tick(){}_setTicking2(i){if(this.#isTicking2!==(i=!!i)){this.#isTicking2=i;const t=map.get(this).GetRuntime();i?t._AddBehInstToTick2(this):t._RemoveBehInstToTick2(this)}}_isTicking2(){return this.#isTicking2}_tick2(){}_setPostTicking(i){if(this.#isPostTicking!==(i=!!i)){this.#isPostTicking=i;const t=map.get(this).GetRuntime();i?t._AddBehInstToPostTick(this):t._RemoveBehInstToPostTick(this)}}_isPostTicking(){return this.#isPostTicking}_postTick(){}_getDebuggerProperties(){return[]}_saveToJson(){return null}_loadFromJson(i){}}; } // interfaces/sdk/ISDKUtils.js { const C3=self.C3,C3X=self.C3X;let runtime=null;self.ISDKUtils=class{constructor(e){runtime=e}addLoadPromise(e){runtime.AddLoadPromise(e)}sendWrapperExtensionMessage(e,n,t){C3X.RequireString(e),C3X.RequireString(n),C3X.RequireOptionalArray(t),runtime.SendWrapperExtensionMessage(e,n,t)}sendWrapperExtensionMessageAsync(e,n,t){return C3X.RequireString(e),C3X.RequireString(n),C3X.RequireOptionalArray(t),runtime.SendWrapperExtensionMessageAsync(e,n,t)}createLoopingConditionContext(e){return C3X.RequireOptionalString(e),new self.ILoopingConditionContext(runtime,e)}set isAutoSuspendEnabled(e){runtime._SetAutoSuspendEnabled(!!e)}get isAutoSuspendEnabled(){return runtime._IsAutoSuspendEnabled()}setSuspended(e){runtime.SetSuspended(!!e)}getObjectClassBySid(e){C3X.RequireNumber(e);const n=runtime.GetObjectClassBySID(e);return n?n.GetIObjectClass():null}}; } // interfaces/sdk/ILoopingConditionContext.js { const C3=self.C3,C3X=self.C3X;self.ILoopingConditionContext=class{#runtime;#currentEvent;#solModifiers;#oldFrame;#newFrame;#loop;constructor(e,t){const o=(this.#runtime=e).GetEventSheetManager(),n=e.GetCurrentEvent(),r=(this.#currentEvent=n,this.#solModifiers=n.GetSolModifiers(),e.GetEventStack()),s=(this.#oldFrame=r.GetCurrentStackFrame(),this.#newFrame=r.Push(n),o.GetLoopStack()),i=s.Push();this.#loop=i,t&&i.SetName(t),e.SetDebuggingEnabled(!1)}retrigger(){const e=this.#runtime.GetEventSheetManager(),t=this.#solModifiers,o=this.#loop;e.PushCopySol(t),this.#currentEvent.Retrigger(this.#oldFrame,this.#newFrame),e.PopSol(t),o.SetIndex(o.GetIndex()+1)}get isStopped(){return this.#loop.IsStopped()}release(){const e=this.#runtime,t=e.GetEventStack(),o=e.GetEventSheetManager().GetLoopStack();e.SetDebuggingEnabled(!0),o.Pop(),t.Pop()}}; } // interfaces/gfx/IRenderer.js { const C3=self.C3,C3X=self.C3X;let renderer=null,runtime=null;self.IRenderer=class{constructor(e,r){runtime=e,renderer=r}setAlphaBlendMode(){renderer.SetAlphaBlend()}setBlendMode(e){renderer.SetNamedBlendMode(e)}setColorFillMode(){renderer.SetColorFillMode()}setTextureFillMode(){renderer.SetTextureFillMode()}setSmoothLineFillMode(){renderer.SetSmoothLineFillMode()}setColor(e){renderer.SetColorRgba(e[0],e[1],e[2],e[3])}setColorRgba(e,r,n,t){renderer.SetColorRgba(e,r,n,t)}resetColor(){renderer.ResetColor()}setOpacity(e){renderer.SetOpacity(e)}setCurrentZ(e){renderer.SetCurrentZ(e)}getCurrentZ(){renderer.GetCurrentZ()}rect(e){renderer.Rect2(e.left,e.top,e.right,e.bottom)}rect2(e,r,n,t){renderer.Rect2(e,r,n,t)}quad(e){renderer.Quad(C3.Quad.fromDOMQuad(e))}quad2(e,r,n,t,a,d,o,i){renderer.Quad2(e,r,n,t,a,d,o,i)}quad3(e,r){renderer.Quad3(C3.Quad.fromDOMQuad(e),C3.Rect.fromDOMRect(r))}quad4(e,r){renderer.Quad4(C3.Quad.fromDOMQuad(e),C3.Quad.fromDOMQuad(r))}quad3D(e,r,n,t,a,d,o,i,u,l,s,p,c){renderer.Quad3D(e,r,n,t,a,d,o,i,u,l,s,p,C3.Rect.fromDOMRect(c))}quad3D2(e,r,n,t,a,d,o,i,u,l,s,p,c){renderer.Quad3D2(e,r,n,t,a,d,o,i,u,l,s,p,C3.Quad.fromDOMQuad(c))}drawMesh(e,r,n){renderer.DrawMesh(e,r,n)}convexPoly(e){renderer.ConvexPoly(e)}line(e,r,n,t){renderer.Line(e,r,n,t)}texturedLine(e,r,n,t,a,d){renderer.TexturedLine(e,r,n,t,a,d)}lineRect(e,r,n,t){renderer.LineRect(e,r,n,t)}lineRect2(e){renderer.LineRect2(C3.Rect.fromDOMRect(e))}lineQuad(e){renderer.LineQuad(C3.Quad.fromDOMQuad(e))}pushLineWidth(e){renderer.PushLineWidth(e)}popLineWidth(){renderer.PopLineWidth()}pushLineCap(e){renderer.PushLineCap(e)}popLineCap(){renderer.PopLineCap()}setTexture(e){C3X.RequireOptionalInstanceOf(e,self.ITexture);const r=e?runtime._UnwrapScriptInterface(e):null;renderer.SetTexture(r)}loadTextureForImageInfo(e,r){const n=self.IImageInfo._Unwrap(e);if(n)return n.LoadStaticTexture(renderer,{wrapX:r?.wrapX??"clamp-to-edge",wrapY:r?.wrapY??"clamp-to-edge",sampling:r?.sampling??"trilinear",mipMap:r?.mipMap??!0});throw new Error("invalid IImageInfo")}releaseTextureForImageInfo(e){const r=self.IImageInfo._Unwrap(e);if(!r)throw new Error("invalid IImageInfo");r.ReleaseTexture()}getTextureForImageInfo(e){const r=self.IImageInfo._Unwrap(e);if(!r)throw new Error("invalid IImageInfo");const n=r.GetTexture();return self.ITexture.GetInterface(runtime,n)}createDynamicTexture(e,r,n){C3X.RequireFiniteNumber(e),C3X.RequireFiniteNumber(r);const t=renderer.CreateDynamicTexture(e,r,{wrapX:n?.wrapX??"clamp-to-edge",wrapY:n?.wrapY??"clamp-to-edge",sampling:n?.sampling??"trilinear",mipMap:n?.mipMap??!0});return self.ITexture.GetInterface(runtime,t)}updateTexture(e,r,n){C3X.RequireInstanceOf(r,self.ITexture);const t=runtime._UnwrapScriptInterface(r);renderer.UpdateTexture(e,t,{premultiplyAlpha:n?.premultiplyAlpha??!0})}deleteTexture(e){C3X.RequireInstanceOf(e,self.ITexture);const r=runtime._UnwrapScriptInterface(e);renderer.DeleteTexture(r)}createRendererText(){const e=renderer.CreateRendererText();return new self.IRendererText(runtime,e)}setDeviceTransform(){runtime.GetCanvasManager().SetDeviceTransform(renderer)}setLayerTransform(e){C3X.RequireInstanceOf(e,globalThis.ILayer);const r=runtime._UnwrapScriptInterface(e);r._SetTransform(renderer)}}; } // interfaces/gfx/ITexture.js { const C3=self.C3,C3X=self.C3X,map=new WeakMap,reverseMap=new WeakMap;self.ITexture=class{constructor(e,t){map.set(this,{runtime:e,texture:t}),reverseMap.set(t,this),e._MapScriptInterface(this,t),Object.defineProperties(this,{width:{value:t.GetWidth(),writable:!1},height:{value:t.GetHeight(),writable:!1}})}static GetInterface(e,t){if(!t)return null;const r=reverseMap.get(t);return r||new self.ITexture(e,t)}}; } // interfaces/gfx/IRendererText.js { const C3=self.C3,C3X=self.C3X,map=new WeakMap;function getActual(t){return map.get(t).rendererText}self.IRendererText=class{constructor(t,e){map.set(this,{runtime:t,rendererText:e}),t._MapScriptInterface(this,e)}release(){getActual(this).Release()}set fontFace(t){C3X.RequireString(t),getActual(this).SetFontName(t)}get fontFace(){return getActual(this).GetFontName()}set sizePt(t){C3X.RequireFiniteNumber(t),getActual(this).SetFontSize(t)}get sizePt(){return getActual(this).GetFontSize()}set lineHeight(t){C3X.RequireFiniteNumber(t),getActual(this).SetLineHeight(t)}get lineHeight(){return getActual(this).GetLineHeight()}set isBold(t){getActual(this).SetBold(t)}get isBold(){return getActual(this).IsBold()}set isItalic(t){getActual(this).SetItalic(t)}get isItalic(){return getActual(this).IsItalic()}setColor(t){C3X.RequireArray(t),this.setColorRgb(t[0],t[1],t[2])}setColorRgb(t,e,i){getActual(this).SetColorRgb(t,e,i)}setCssColor(t){C3X.RequireString(t),getActual(this).SetColor(t)}set horizontalAlign(t){getActual(this).SetHorizontalAlignment(t)}get horizontalAlign(){return getActual(this).GetHorizontalAlignment()}set verticalAlign(t){getActual(this).SetVerticalAlignment(t)}get verticalAlign(){return getActual(this).GetVerticalAlignment()}set wordWrapMode(t){getActual(this).SetWordWrapMode(t)}get wordWrapMode(){return getActual(this).GetWordWrapMode()}set textDirection(t){getActual(this).SetTextDirection(t)}get textDirection(){return getActual(this).GetTextDirection()}set text(t){C3X.RequireString(t),getActual(this).SetText(t)}get text(){return getActual(this).GetText()}setSize(t,e,i){C3X.RequireFiniteNumber(t),C3X.RequireFiniteNumber(e),C3X.RequireFiniteNumber(i),getActual(this).SetSize(t,e,i)}getTexture(){const{runtime:t,rendererText:e}=map.get(this),i=e.GetTexture();return self.ITexture.GetInterface(t,i)}getTexRect(){return getActual(this).GetTexRect().toDOMRect()}setTextureUpdateCallback(t){C3X.RequireFunction(t),getActual(this).ontextureupdate=t}releaseTexture(){getActual(this).ReleaseTexture()}get textWidth(){return getActual(this).GetTextWidth()}get textHeight(){return getActual(this).GetTextHeight()}}; } // assets/assetManager.js { const C3=self.C3,VALID_LOAD_POLICIES=new Set(["local","remote"]),EXT_TO_TYPE=new Map([["mp4","video/mp4"],["webm","video/webm"],["m4a","audio/mp4"],["mp3","audio/mpeg"],["js","application/javascript"],["wasm","application/wasm"],["svg","image/svg+xml"],["html","text/html"]]);function GetTypeFromFileExtension(e){if(!e)return"";const t=e.split(".");if(t.length<2)return"";const i=t.at(-1).toLowerCase();return EXT_TO_TYPE.get(i)||""}function AddScript(o){return new Promise((e,t)=>{const i=document.createElement("script");i.onload=e,i.onerror=t,i.async=!1,i.type="module",i.src=o,document.head.appendChild(i)})}C3.AssetManager=class extends C3.DefendedBase{constructor(e,t){super();const i=t["exportType"],o=(this._runtime=e,this._fileStructure="folders",this._cordovaBlobUrlCache=new Map,this._isCordova="cordova"===i,this._isiOSCordova=!!t["isiOSCordova"],this._isFileProtocol=!!t["isFileProtocol"],this._swClientId=t["swClientId"],this._supportedAudioFormats=t["supportedAudioFormats"]||{},this._audioFiles=new Map,this._preloadSounds=!1,this._scriptSubfolder=t["scriptFolder"],this._mediaSubfolder="",this._fontsSubfolder="",this._iconsSubfolder="",this._fileMap=t["fileMap"]||new Map,this._fileMapBlobUrls=new Map,"html5"===i||"scirra-arcade"===i||"instant-games"===i);this._defaultLoadPolicy=o?"remote":"local",this._assetsByUrl=new Map,this._webFonts=[],this._loadPromises=[],this._hasFinishedInitialLoad=!1,this._totalAssetSizeToLoad=0,this._assetSizeLoaded=0,this._lastLoadProgress=0,this._hasHadErrorLoading=!1,this._loadingRateLimiter=C3.New(C3.RateLimiter,()=>this._FireLoadingProgressEvent(),50),this._localPromiseThrottle=C3.New(C3.PromiseThrottle,Math.max(C3.hardwareConcurrency,8)),this._remotePromiseThrottle=C3.New(C3.PromiseThrottle,20),this._iAssetManager=new self.IAssetManager(this)}Release(){for(const e of this._assetsByUrl.values())e.Release();this._assetsByUrl.clear(),C3.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,C3.IsRelativeURL(e)?("flat"===this._fileStructure&&(e=e.toLowerCase()),this._isCordova&&this._isFileProtocol?this.CordovaFetchLocalFileAsBlob(e):"playable-ad-single-file"===this._runtime.GetExportType()?self["c3_runtimeInterface"]["_PlayableAdFetchBlob"](e):("local"===t?this._localPromiseThrottle:this._remotePromiseThrottle).Add(()=>C3.FetchBlob(e))):C3.FetchBlob(e)}FetchArrayBuffer(e){return C3.IsRelativeURL(e)?("flat"===this._fileStructure&&(e=e.toLowerCase()),this._isCordova&&this._isFileProtocol?this.CordovaFetchLocalFileAsArrayBuffer(e):"playable-ad-single-file"===this._runtime.GetExportType()?C3.BlobToArrayBuffer(self["c3_runtimeInterface"]["_PlayableAdFetchBlob"](e)):("local"===this._defaultLoadPolicy?this._localPromiseThrottle:this._remotePromiseThrottle).Add(()=>C3.FetchArrayBuffer(e))):C3.FetchArrayBuffer(e)}FetchText(e){return C3.IsRelativeURL(e)?("flat"===this._fileStructure&&(e=e.toLowerCase()),this._isCordova&&this._isFileProtocol?this.CordovaFetchLocalFileAsText(e):"playable-ad-single-file"===this._runtime.GetExportType()?C3.BlobToString(self["c3_runtimeInterface"]["_PlayableAdFetchBlob"](e)):("local"===this._defaultLoadPolicy?this._localPromiseThrottle:this._remotePromiseThrottle).Add(()=>C3.FetchText(e))):C3.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"),i=GetTypeFromFileExtension(e);return new Blob([t],{"type":i})}async CordovaFetchLocalFileAsBlobURL(e){"flat"===this._fileStructure&&(e=e.toLowerCase());let t=this._cordovaBlobUrlCache.get(e);if(!t){const i=await this.CordovaFetchLocalFileAsBlob(e);t=URL.createObjectURL(i),this._cordovaBlobUrlCache.set(e,t)}return t}CordovaFetchLocalFileAsArrayBuffer(e){return this._CordovaFetchLocalFileAs(e,"buffer")}GetMediaFileUrl(e){"flat"===this._fileStructure&&(e=e.toLowerCase());let t=this._mediaSubfolder+e;return t="Gecko"===C3.Platform.BrowserEngine&&"preview"===this._runtime.GetExportType()?this._GetLocalBlobURLFromFileMap(t):t}GetProjectFileUrl(e){return C3.IsAbsoluteURL(e)?Promise.resolve(e):this._isCordova&&this._isFileProtocol?this.CordovaFetchLocalFileAsBlobURL(e):"playable-ad-single-file"===this._runtime.GetExportType()?URL.createObjectURL(self["c3_runtimeInterface"]["_PlayableAdFetchBlob"](e)):("flat"===this._fileStructure&&(e=e.toLowerCase()),Promise.resolve(e))}GetProjectFileIframeUrl(t){if(C3.IsAbsoluteURL(t)||"preview"!==this._runtime.GetExportType()||!this._swClientId||!t)return t;try{const e=new URL(t,location.href);return e.searchParams.set("__c3_client_id",this._swClientId),e.toString()}catch(e){return console.warn("Invalid iframe URL: "+t),t}}LoadProjectFileUrl(e){return this.GetProjectFileUrl(e)}LoadImage(e){if(e.loadPolicy&&!VALID_LOAD_POLICIES.has(e.loadPolicy))throw new Error("invalid load policy");let t=this._assetsByUrl.get(e.url);return t||(t=C3.New(C3.ImageAsset,this,{url:e.url,size:e.size||0,loadPolicy:e.loadPolicy||this._defaultLoadPolicy}),this._assetsByUrl.set(t.GetURL(),t),this._hasFinishedInitialLoad)||(this._totalAssetSizeToLoad+=t.GetSize(),this._loadPromises.push(t.Load().then(()=>this._AddLoadedSize(t.GetSize())))),t}_ReleaseAsset(e){this._assetsByUrl.delete(e.GetURL())}async WaitForAllToLoad(){try{await Promise.all(this._loadPromises),this._lastLoadProgress=1}catch(e){console.error("Error loading: ",e),this._hasHadErrorLoading=!0,this._FireLoadingProgressEvent()}}SetInitialLoadFinished(){this._hasFinishedInitialLoad=!0}HasHadErrorLoading(){return this._hasHadErrorLoading}_AddLoadedSize(e){this._assetSizeLoaded+=e,this._loadingRateLimiter.Call()}_FireLoadingProgressEvent(){const e=C3.New(C3.Event,"loadingprogress");this._lastLoadProgress=C3.clamp(this._assetSizeLoaded/this._totalAssetSizeToLoad,0,1),e.progress=this._lastLoadProgress,this._runtime.Dispatcher().dispatchEvent(e)}GetLoadProgress(){return this._lastLoadProgress}GetImageLoadProgress(){return this._runtime.GetSystemPlugin().GetImageLoadingProgress()}_SetWebFonts(e){C3.shallowAssignArray(this._webFonts,e),this._webFonts.length&&this._loadPromises.push(this._LoadWebFonts())}async _LoadWebFonts(){const e=[],t=[];for(const[i,o,s]of this._webFonts)this._totalAssetSizeToLoad+=s,e.push(this._LoadWebFont(i,o,t).then(()=>this._AddLoadedSize(s)));await Promise.all(e),this._runtime.IsInWorker()&&0<t.length&&await this._runtime.PostComponentMessageToDOMAsync("runtime","load-webfonts",{"webfonts":t})}async _LoadWebFont(t,i,o){try{let e=await this.GetProjectFileUrl(i);"Gecko"===C3.Platform.BrowserEngine&&(t=`'${t}'`),("Gecko"===C3.Platform.BrowserEngine&&"preview"===this._runtime.GetExportType()||"playable-ad-single-file"===this._runtime.GetExportType())&&(e=this._GetLocalBlobURLFromFileMap(e));const s=new FontFace(t,`url('${e}')`);(this._runtime.IsInWorker()?self:document).fonts.add(s),await s.load(),this._runtime.IsInWorker()&&o.push({name:t,url:e})}catch(e){console.warn(`[C3 runtime] Failed to load web font '${t}': `,e)}}IsAudioFormatSupported(e){return!!this._supportedAudioFormats[e]}_SetAudioFiles(e,t){this._preloadSounds=!!t;for(const[i,o,s]of e)this._audioFiles.set(i,{fileName:i,formats:o.map(e=>({type:e[0],fileExtension:e[1],fullName:i+e[1],fileSize:e[2]})),isMusic:s})}GetPreferredAudioFile(e){"flat"===this._fileStructure&&(e=e.toLowerCase());const t=this._audioFiles.get(e);if(!t)return null;let i=null;for(const o of t.formats)if(i||"audio/webm; codecs=opus"!==o.type||(i=o),this.IsAudioFormatSupported(o.type))return o;return i}GetProjectAudioFileUrl(e){const t=this.GetPreferredAudioFile(e);return t?{url:this.GetMediaFileUrl(t.fullName),type:t.type}:null}GetAudioToPreload(){if(this._preloadSounds){const e=[];for(const t of this._audioFiles.values())if(!t.isMusic){const i=this.GetPreferredAudioFile(t.fileName);i&&e.push({originalUrl:t.fileName,url:this.GetMediaFileUrl(i.fullName),type:i.type,fileSize:i.fileSize})}return e}return[]}_GetLocalBlobFromFileMap(e){return"preview"===this._runtime.GetExportType()&&(e=new URL(e,location.href).toString()),this._fileMap.get(e)||null}_GetLocalBlobURLFromFileMap(e){let t=this._fileMapBlobUrls.get(e);if(!t){const i=this._GetLocalBlobFromFileMap(e);if(!i)return e;t=URL.createObjectURL(i),this._fileMapBlobUrls.set(e,t)}return t}GetIAssetManager(){return this._iAssetManager}async LoadScripts(...e){const t=await Promise.all(e.map(e=>this.GetProjectFileUrl(e)));if(this._runtime.IsInWorker())if(1===e.length){const i=e[0];await import((C3.IsRelativeURL(i)?"./":"")+i)}else{const o=e.map(e=>`import "${C3.IsRelativeURL(e)?"./":""}${e}";`).join("\n"),s=URL.createObjectURL(new Blob([o],{type:"application/javascript"}));await import(s)}else await Promise.all(t.map(e=>AddScript(e)))}async CompileWebAssembly(e){if(WebAssembly.compileStreaming){const t=await this.GetProjectFileUrl(e);return WebAssembly.compileStreaming(fetch(t))}{const i=await C3.FetchArrayBuffer(e);return WebAssembly.compile(i)}}async LoadStyleSheet(e){const t=await this.GetProjectFileUrl(e);return this._runtime.PostComponentMessageToDOMAsync("runtime","add-stylesheet",{"url":t})}}; } // assets/asset.js { const C3=self.C3;C3.Asset=class extends C3.DefendedBase{constructor(s,e){super(),this._assetManager=s,this._runtime=s.GetRuntime(),this._url=e.url||"",this._size=e.size,this._loadPolicy=e.loadPolicy,this._blob=e.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(s=>(this._isLoaded=!0,this._loadPromise=null,this._blob=s)).catch(s=>{console.error("Error loading resource: ",s),this._loadPromise=null})),this._loadPromise)}IsLoaded(){return this._isLoaded}GetBlob(){return this._blob?Promise.resolve(this._blob):this._loadPromise||this._assetManager.FetchBlob(this._url,this._loadPolicy)}}; } // assets/imageAsset.js { const C3=self.C3,promiseThrottle=new C3.PromiseThrottle,allImageAssets=new Set;C3.ImageAsset=class extends C3.Asset{constructor(e,t){super(e,t),this._texturePromise=null,this._webglTexture=null,this._refCount=0,this._imageWidth=-1,this._imageHeight=-1,allImageAssets.add(this)}Release(){if(0!==this._refCount)throw new Error("released image asset which still has texture references");this._assetManager._ReleaseAsset(this),this._texturePromise=null,allImageAssets.delete(this),super.Release()}static OnRendererContextLost(){for(const e of allImageAssets)e._texturePromise=null,e._webglTexture=null,e._refCount=0}LoadStaticTexture(e,t){return t=t||{},this._refCount++,this._webglTexture?Promise.resolve(this._webglTexture):(this._texturePromise||(t.anisotropy=this._runtime.GetCanvasManager().GetTextureAnisotropy(),this._texturePromise=this._DoLoadStaticTexture(e,t)),this._texturePromise)}async _DoLoadStaticTexture(t,s){try{const r=await this.GetBlob();return 0===this._refCount?this._texturePromise=null:await promiseThrottle.Add(async()=>{const e=await t.CreateStaticTextureAsync(r,s);return this._texturePromise=null,0===this._refCount?(t.DeleteTexture(e),null):(this._webglTexture=e,this._imageWidth=e.GetWidth(),this._imageHeight=e.GetHeight(),this._webglTexture)})}catch(e){throw console.error("Failed to load texture: ",e),e}}ReleaseTexture(){if(this._refCount<=0)throw new Error("texture released too many times");if(this._refCount--,0===this._refCount&&this._webglTexture){const e=this._webglTexture.GetRenderer();e.DeleteTexture(this._webglTexture),this._webglTexture=null}}GetRefCount(){return this._refCount}GetTexture(){return this._webglTexture}GetWidth(){return this._imageWidth}GetHeight(){return this._imageHeight}async LoadToDrawable(){const e=await this.GetBlob();return C3.Supports.ImageBitmap?createImageBitmap(e):C3.BlobToImage(e)}}; } // layouts/renderCell.js { const C3=self.C3,assert=self.assert;function SortByInstLastCachedZIndex(e,s){return e.GetWorldInfo()._GetLastCachedZIndex()-s.GetWorldInfo()._GetLastCachedZIndex()}C3.RenderCell=class extends C3.DefendedBase{constructor(e,s,n){super(),this._grid=e,this._x=s,this._y=n,this._instances=[],this._isSorted=!0,this._pendingRemoval=new Set,this._isAnyPendingRemoval=!1}Release(){C3.clearArray(this._instances),this._pendingRemoval.clear(),this._grid=null}Reset(){C3.clearArray(this._instances),this._isSorted=!0,this._pendingRemoval.clear(),this._isAnyPendingRemoval=!1}SetChanged(){this._isSorted=!1}IsEmpty(){if(this._instances.length){if(this._instances.length>this._pendingRemoval.size)return!1;this._FlushPending()}return!0}Insert(e){this._pendingRemoval.has(e)?(this._pendingRemoval.delete(e),0===this._pendingRemoval.size&&(this._isAnyPendingRemoval=!1)):(this._instances.push(e),this._isSorted=1===this._instances.length)}Remove(e){this._pendingRemoval.add(e),this._isAnyPendingRemoval=!0,50<=this._pendingRemoval.size&&this._FlushPending()}_FlushPending(){this._isAnyPendingRemoval&&(this._instances.length===this._pendingRemoval.size?this.Reset():(C3.arrayRemoveAllInSet(this._instances,this._pendingRemoval),this._pendingRemoval.clear(),this._isAnyPendingRemoval=!1))}_EnsureSorted(){this._isSorted||(this._instances.sort(SortByInstLastCachedZIndex),this._isSorted=!0)}Dump(e){this._FlushPending(),this._EnsureSorted(),this._instances.length&&e.push(this._instances)}}; } // layouts/renderGrid.js { const C3=self.C3;C3.RenderGrid=class extends C3.DefendedBase{constructor(e,t){super(),this._cellWidth=e,this._cellHeight=t,this._cells=C3.New(C3.PairMap)}Release(){this._cells.Release(),this._cells=null}GetCell(e,t,l){let s=this._cells.Get(e,t);return s||(l?(s=C3.New(C3.RenderCell,this,e,t),this._cells.Set(e,t,s),s):null)}XToCell(e){return Math.floor(e/this._cellWidth)}YToCell(e){return Math.floor(e/this._cellHeight)}Update(s,o,i){if(o)for(let l=o.getLeft(),e=o.getRight();l<=e;++l)for(let e=o.getTop(),t=o.getBottom();e<=t;++e)if(!i||!i.containsPoint(l,e)){const h=this.GetCell(l,e,!1);h&&(h.Remove(s),h.IsEmpty())&&this._cells.Delete(l,e)}if(i)for(let l=i.getLeft(),e=i.getRight();l<=e;++l)for(let e=i.getTop(),t=i.getBottom();e<=t;++e)o&&o.containsPoint(l,e)||this.GetCell(l,e,!0).Insert(s)}QueryRange(e,t){let l=this.XToCell(e.getLeft());const s=this.YToCell(e.getTop()),o=this.XToCell(e.getRight()),i=this.YToCell(e.getBottom());for(;l<=o;++l)for(let e=s;e<=i;++e){const h=this.GetCell(l,e,!1);h&&h.Dump(t)}}MarkRangeChanged(e){let t=e.getLeft();const l=e.getTop(),s=e.getRight(),o=e.getBottom();for(;t<=s;++t)for(let e=l;e<=o;++e){const i=this.GetCell(t,e,!1);i&&i.SetChanged()}}}; } // layouts/layer.js { const C3=self.C3,assert=self.assert,tmpRect=new C3.Rect,tmpQuad=new C3.Quad,renderCellArr=[],tmpDestRect=new C3.Rect,tmpSrcRect=new C3.Rect,glMatrix=self.glMatrix,vec3=glMatrix.vec3,vec4=glMatrix.vec4,mat4=glMatrix.mat4,tempMat4=mat4.create(),tempVec3=vec3.create(),tempVec4=vec4.create(),camVector=vec3.create(),lookVector=vec3.create(),upVector=vec3.create(),tempVec2=C3.New(C3.Vector2),tempRect=C3.New(C3.Rect);function SortByInstLastCachedZIndex(e,t){return e.GetWorldInfo()._GetLastCachedZIndex()-t.GetWorldInfo()._GetLastCachedZIndex()}function SortByInstZElevation(e,t){return e.GetWorldInfo().GetZElevation()-t.GetWorldInfo().GetZElevation()}const tempInstanceList1=[],tempInstanceList2=[],tempInstancesByCameraDist=[],DEFAULT_LAYER_OPTIONS={name:"",sid:-1,isDynamic:!1,isVisible:!0,isInteractive:!0,isHTMLElementsLayer:!1,backgroundColor:[1,1,1,1],isTransparent:!0,parallax:[1,1],opacity:1,isForceOwnTexture:!1,renderAs3d:!1,useCameraDistanceDrawOrder:!1,useRenderCells:!1,scaleRate:1,blendMode:0,zElevation:0,initialInstancesData:[],effectListData:[],subLayersData:[]};C3.Layer=class extends C3.DefendedBase{constructor(e,t,s){super(),s=Object.assign({},DEFAULT_LAYER_OPTIONS,s),this._layout=e,this._runtime=e.GetRuntime(),this._parentLayer=t,this._name=s.name,this._index=-1,this._isHTMLElementsLayer=!!s.isHTMLElementsLayer,this._htmlIndex=-1,this._sid=s.sid,this._isDynamic=!!s.isDynamic,this._isVisible=!!s.isVisible,this._isInteractive=!!s.isInteractive,this._backgroundColor=C3.New(C3.Color),this._backgroundColor.setFromJSON(s.backgroundColor),this._isTransparent=!!s.isTransparent,this._parallaxX=s.parallax[0],this._parallaxY=s.parallax[1],this._color=C3.New(C3.Color,1,1,1,s.opacity),this._premultipliedColor=C3.New(C3.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=C3.New(C3.Rect),this._viewportZ0=C3.New(C3.Rect),this._viewport3D=C3.New(C3.Rect),this._isViewportChanged=!0,this._projectionMatrix=mat4.create(),this._isProjectionMatrixChanged=!0,this._modelViewMatrix=mat4.create(),this._isMVMatrixChanged=!0,this._viewFrustum=C3.New(C3.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=C3.New(C3.EffectList,this,s.effectListData),this._effectChain=C3.New(C3.Gfx.EffectChain,i.GetEffectChainManager(),{drawContent:(e,t)=>{const s=t.GetContentObject(),a=s.GetRenderTarget();e.SetColor(s.GetPremultipliedColor()),e.DrawRenderTarget(a),e.InvalidateRenderTarget(a),i.ReleaseAdditionalRenderTarget(a)},getShaderParameters:e=>this.GetEffectList()._GetEffectChainShaderParametersForIndex(e)}),this._needsRebuildEffectChainSteps=!0,this._wasDefaultColor=!0,this._renderGrid=null,this._lastRenderList=[],this._isRenderListUpToDate=!1,this._lastRenderCells=C3.New(C3.Rect,0,0,-1,-1),this._curRenderCells=C3.New(C3.Rect,0,0,-1,-1),this._iLayer=new self.ILayer(this),this._UpdatePremultipliedColor(),this.UsesRenderCells()&&(this._renderGrid=C3.New(C3.RenderGrid,this._runtime.GetOriginalViewportWidth(),this._runtime.GetOriginalViewportHeight())),this._subLayers=s.subLayersData.map(e=>C3.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)}C3.shallowAssignArray(this._startupInitialInstances,this._initialInstances),this._initialInstancesData=null}static CreateFromExportData(e,t,s){return C3.New(C3.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();C3.clearArray(this._subLayers);for(const t of this._instances)this._runtime.DestroyInstance(t);C3.clearArray(this._instances),this._effectList.Release(),this._effectList=null,this._effectChain.Release(),this._effectChain=null,this._iLayer=null,this._parentLayer=null,this._layout=null,this._runtime=null}GetInitialInstanceData(e){return this._initialUIDsToInstanceData.get(e)}CreateInitialInstances(s){const a=this._layout.IsFirstVisit();let i=0;const r=this._initialInstances;for(let t=0,e=r.length;t<e;++t){const n=r[t],l=this._runtime.GetObjectClassByIndex(n[1]);let e=!0;if(!l.HasPersistBehavior()||a){const o=this._runtime.CreateInstanceFromData(n,this,!0);s.push(o),l.IsGlobal()&&(e=!1,this._createdGlobalUids.push(o.GetUID()))}e&&(r[i]=r[t],++i)}C3.truncateArray(r,i),this._runtime.FlushPendingInstances(),this.SetZIndicesChanged()}_AddInstance(e,t){if(!e.GetPlugin().IsWorldType())throw new Error("instance is not of world type");const s=e.GetWorldInfo();if(s.GetLayer()!==this)throw new Error("instance added to wrong layer");this._instances.push(e),0!==s.GetZElevation()&&(this._anyInstanceZElevated=!0),t&&this.UsesRenderCells()&&e.GetWorldInfo().SetBboxChanged(),this.SetZIndicesChanged(e)}_MaybeAddInstance(e){this._instances.includes(e)||(this._instances.push(e),0!==e.GetWorldInfo().GetZElevation()&&(this._anyInstanceZElevated=!0),this.SetZIndicesChanged(e))}_PrependInstance(e,t){const s=e.GetWorldInfo();if(s.GetLayer()!==this)throw new Error("instance added to wrong layer");this._instances.unshift(e),0!==s.GetZElevation()&&(this._anyInstanceZElevated=!0),this.SetZIndicesChanged(e),t&&this.UsesRenderCells()&&e.GetWorldInfo().SetBboxChanged()}_RemoveInstance(e,t){const s=this._instances.indexOf(e);s<0||(t&&this.UsesRenderCells()&&e.GetWorldInfo()._RemoveFromRenderCells(),this._instances.splice(s,1),this.SetZIndicesChanged(e),this._MaybeResetAnyInstanceZElevatedFlag())}_SetAnyInstanceZElevated(){this._anyInstanceZElevated=!0}_MaybeResetAnyInstanceZElevatedFlag(){0===this._instances.length&&(this._anyInstanceZElevated=!1)}_SortInstancesByLastCachedZIndex(e){if(e){const t=new Set;for(const s of this._instances){const a=s.GetWorldInfo()._GetLastCachedZIndex();0<=a&&t.add(a)}let e=-1;for(const i of this._instances){const r=i.GetWorldInfo();if(!(0<=r._GetLastCachedZIndex())){for(++e;t.has(e);)++e;r._SetZIndex(e)}}}this._instances.sort(SortByInstLastCachedZIndex)}_Start(){}_End(){for(const e of this._instances)e.GetObjectClass().IsGlobal()||this._runtime.DestroyInstance(e);this._runtime.FlushPendingInstances(),C3.clearArray(this._instances),this._anyInstanceZElevated=!1,this.SetZIndicesChanged()}RecreateInitialObjects(t,e,s,a,i,r){const n=this._runtime.GetEventSheetManager(),l=this._runtime.GetAllObjectClasses(),o=t.IsFamily(),h=[];for(const c of this._initialInstances){const d=c[0],_=d[0],u=d[1];if(e.containsPoint(_,u)){const G=l[c[1]];if(G!==t){if(!o)continue;if(!t.FamilyHasMember(G))continue}let e=i;if(!e){const I=this._runtime.GetCurrentLayout();e=this.GetLayout()===I?this:(e=I.GetLayerByName(this.GetName()))||I.GetLayerByIndex(this.GetIndex())}const f=this._runtime.CreateInstanceFromData(c,e,!1,void 0,void 0,!1,r),p=(e.SortAndAddInstancesByZIndex(f),f.GetWorldInfo());p.OffsetXY(s,a),p.SetBboxChanged(),n.BlockFlushingInstances(!0),f._TriggerOnCreatedOnSelfAndRelated(),n.BlockFlushingInstances(!1),h.push(f)}}return h}GetInstanceCount(){return this._instances.length}GetLayout(){return this._layout}GetName(){return this._name}_SetIndex(e){this._index=e}GetIndex(){return this._index}_SetHTMLIndex(e){this._htmlIndex=e}GetHTMLIndex(){return this._htmlIndex}IsHTMLElementsLayer(){return this._isHTMLElementsLayer}SetIsHTMLElementsLayer(e){this._isHTMLElementsLayer!==(e=!!e)&&(this._isHTMLElementsLayer=e,this._layout._ReindexAndUpdateAllLayers(),this._runtime.UpdateRender())}_GetSiblingIndex(){let e=-1;const t=this.GetParentLayer();return e=(t?t.GetSubLayers():this.GetLayout()._GetRootLayers()).indexOf(this)}GetSID(){return this._sid}GetRuntime(){return this._runtime}IsDynamic(){return this._isDynamic}HasAnyDynamicParentLayer(){for(const e of this.parentLayers())if(e.IsDynamic())return!0;return!1}GetDevicePixelRatio(){return this._runtime.GetDevicePixelRatio()}GetEffectList(){return this._effectList}GetEffectChain(){return this._MaybeRebuildEffectChainSteps(),this._effectChain}_MaybeRebuildEffectChainSteps(){const e=this.HasDefaultColor();if(this._needsRebuildEffectChainSteps||e!==this._wasDefaultColor||this._effectChain.NeedsRebuild()){const t=this.GetEffectList().GetActiveEffectTypes();this._effectChain.BuildSteps(t.map(e=>e.GetShaderProgram()),{indexMap:t.map(e=>e.GetIndex()),forcePreDraw:!e,useFullSurface:!0}),this._needsRebuildEffectChainSteps=!1,this._wasDefaultColor=e}}UpdateActiveEffects(){this.GetEffectList().UpdateActiveEffects(),this._needsRebuildEffectChainSteps=!0}UsesRenderCells(){return this._useRenderCells&&!this._useCameraDistanceDrawOrder}GetRenderGrid(){return this._renderGrid}SetRenderListStale(){this._isRenderListUpToDate=!1}IsVisible(){for(const e of this.selfAndParentLayers())if(!e._IsVisibleFlagSet())return!1;return!0}_IsVisibleFlagSet(){return this._isVisible}SetVisible(e){this._isVisible!==(e=!!e)&&(this._isVisible=e,this._runtime.UpdateRender())}SetInteractive(e){this._isInteractive=!!e}IsInteractive(){return this._isInteractive}IsSelfAndParentsInteractive(){for(const e of this.selfAndParentLayers())if(!e.IsInteractive())return!1;return!0}SetOwnScrollPositionEnabled(e){if(this._hasOwnScrollPosition!==(e=!!e)){if(this._hasOwnScrollPosition=e){const t=this.GetLayout();this._scrollX=t.GetScrollX(),this._scrollY=t.GetScrollY()}this._SetMVMatrixChanged(),this._runtime.UpdateRender()}}IsOwnScrollPositionEnabled(){return this._hasOwnScrollPosition}SetScrollX(e){const t=this.GetLayout(),s=t.GetScrollLeftBound(),a=t.GetScrollRightBound();this._scrollX!==(e=(e=a<e?a:e)<s?s:e)&&(this._scrollX=e,this.IsOwnScrollPositionEnabled())&&(this._SetMVMatrixChanged(),this._runtime.UpdateRender())}SetScrollY(e){const t=this.GetLayout(),s=t.GetScrollTopBound(),a=t.GetScrollBottomBound();this._scrollY!==(e=(e=a<e?a:e)<s?s:e)&&(this._scrollY=e,this.IsOwnScrollPositionEnabled())&&(this._SetMVMatrixChanged(),this._runtime.UpdateRender())}GetScrollX(){return this.IsOwnScrollPositionEnabled()?this._scrollX:this.GetLayout().GetScrollX()}GetScrollY(){return this.IsOwnScrollPositionEnabled()?this._scrollY:this.GetLayout().GetScrollY()}GetViewport(){return this._MaybeUpdateViewport(),this._viewport}_GetViewportZ0(){return this._MaybeUpdateViewport(),this._viewportZ0}GetViewport3D(){return this._MaybeUpdateViewport(),this._viewport3D}_GetVanishingPoint(){const e=this.GetLayout();return[e.GetVanishingPointX(),e.GetVanishingPointY()]}GetDefaultCameraZ(e){return this._runtime.GetDefaultCameraZ(e)}GetViewportForZ(l,o){const h=this._GetViewportZ0();if(0===l)o.copy(h);else{let s=h.midX(),a=h.midY(),e=this.Get2DScaleFactorToZ(l),t=h.width()/e,i=h.height()/e,[r,n]=this._GetVanishingPoint();if(.5!==r||.5!==n){const c=this.Get2DCameraZ(),d=this._runtime,_=this.GetDefaultCameraZ()/c;let e=(r-.5)*d.GetViewportWidth()/_,t=(n-.5)*d.GetViewportHeight()/_;const u=this.GetAngle(),G=(0!==u&&(tempVec2.set(e,t),tempVec2.rotate(u),e=tempVec2.getX(),t=tempVec2.getY()),C3.unlerp(c,0,l));s+=C3.lerp(e,0,G),a+=C3.lerp(t,0,G)}o.set(s-t/2,a-i/2,s+t/2,a+i/2)}}GetOpacity(){return this._color.getA()}SetOpacity(e){e=C3.clamp(e,0,1),this._color.getA()!==e&&(this._color.setA(e),this._UpdatePremultipliedColor(),this._runtime.UpdateRender())}_UpdatePremultipliedColor(){this._premultipliedColor.copy(this._color),this._premultipliedColor.premultiply()}GetPremultipliedColor(){return this._premultipliedColor}HasDefaultColor(){return this._color.equalsRgba(1,1,1,1)}GetScaleRate(){return this._scaleRate}SetScaleRate(e){this._scaleRate!==e&&(this._scaleRate=e,this._SetMVMatrixChanged(),this._runtime.UpdateRender())}GetParallaxX(){return this._parallaxX}GetParallaxY(){return this._parallaxY}SetParallax(e,t){this._parallaxX===e&&this._parallaxY===t||(this._parallaxX=e,this._parallaxY=t,this._SetMVMatrixChanged(),this._runtime.UpdateRender())}SetParallaxX(e){this.SetParallax(e,this.GetParallaxY())}SetParallaxY(e){this.SetParallax(this.GetParallaxX(),e)}SetZElevation(e){this._zElevation!==e&&(this._zElevation=e,this._runtime.UpdateRender())}GetZElevation(){return this._zElevation}SetAngle(e){e=C3.clampAngle(e),this._angle!==e&&(this._angle=e,this._SetMVMatrixChanged(),this._runtime.UpdateRender())}GetAngle(){return C3.clampAngle(this._layout.GetAngle()+this._angle)}GetOwnAngle(){return this._angle}HasInstances(){return 0<this._instances.length}_GetInstances(){return this._instances}_GetInstancesInDrawOrder(){return this.RendersIn3DMode()&&this._useCameraDistanceDrawOrder?(C3.shallowAssignArray(tempInstancesByCameraDist,this._GetInstances()),tempInstancesByCameraDist.sort((e,t)=>this._SortInstancesByCameraDistance(e,t)),tempInstancesByCameraDist):this._GetInstances()}_AppendAllInstancesIncludingSubLayersInDrawOrder(e){C3.appendArray(e,this._GetInstancesInDrawOrder());for(const t of this._subLayers)t.IsVisible()&&0<t.GetOpacity()&&t._AppendAllInstancesIncludingSubLayersInDrawOrder(e)}_SortInstancesByCameraDistance(e,t){const s=this.GetLayout().Get3DCameraPosition(),a=s[0],i=s[1],r=s[2],n=e.GetWorldInfo(),l=t.GetWorldInfo(),o=n.GetX()-a,h=n.GetY()-i,c=n.GetZElevation()-r,d=l.GetX()-a,_=l.GetY()-i,u=l.GetZElevation()-r;return d*d+_*_+u*u-(o*o+h*h+c*c)}GetBackgroundColor(){return this._backgroundColor}IsTransparent(){return this._isTransparent}SetTransparent(e){this._isTransparent!==(e=!!e)&&(this._isTransparent=e,this._runtime.UpdateRender())}IsForceOwnTexture(){return this._isForceOwnTexture}SetForceOwnTexture(e){this._isForceOwnTexture!==(e=!!e)&&(this._isForceOwnTexture=e,this._runtime.UpdateRender())}RendersIn2DMode(){return!this.GetRuntime().Uses3DFeatures()||!this._renderAs3d}RendersIn3DMode(){return!this.RendersIn2DMode()}Has3DCamera(){return this.RendersIn3DMode()&&this.GetLayout().Is3DCameraEnabled()}SelfAndAllSubLayersHave3DCamera(){if(!this.Has3DCamera())return!1;for(const e of this._subLayers)if(!e.SelfAndAllSubLayersHave3DCamera())return!1;return!0}SetBlendMode(e){this._blendMode!==e&&(this._blendMode=e,this._runtime.UpdateRender())}GetBlendMode(){return this._blendMode}IsRootLayer(){return!this._parentLayer}GetParentLayer(){return this._parentLayer}_SetParentLayer(e){this._parentLayer=e}GetSubLayers(){return this._subLayers}HasAnySubLayers(){return 0<this._subLayers.length}_AddSubLayer(e,t=!0){t?this._subLayers.push(e):this._subLayers.unshift(e)}_InsertSubLayer(e,t,s){let a=this._subLayers.indexOf(t);if(-1===a)throw new Error("cannot find layer to insert by");s&&++a,this._subLayers.splice(a,0,e)}_RemoveSubLayer(e){const t=this._subLayers.indexOf(e);if(-1===t)throw new Error("cannot find layer to remove");this._subLayers.splice(t,1)}HasAnyVisibleSubLayer(){for(const e of this._subLayers)if(e.ShouldDraw())return!0;return!1}*selfAndAllSubLayers(){for(const e of this._subLayers)yield*e.selfAndAllSubLayers();yield this}*parentLayers(){let e=this.GetParentLayer();for(;e;)yield e,e=e.GetParentLayer()}*selfAndParentLayers(){yield this,yield*this.parentLayers()}HasParentLayer(e){for(const t of this.parentLayers())if(t===e)return!0;return!1}IsTransformCompatibleWith(e){return this===e||this._parallaxX===e._parallaxX&&this._parallaxY===e._parallaxY&&this._scale===e._scale&&this._scaleRate===e._scaleRate&&this._angle===e._angle&&this.GetScrollX()===e.GetScrollX()&&this.GetScrollY()===e.GetScrollY()}SaveTransform(){return{"parallaxX":this.GetParallaxX(),"parallaxY":this.GetParallaxY(),"scale":this.GetOwnScale(),"scaleRate":this.GetScaleRate(),"angle":this.GetOwnAngle(),"hasOwnScroll":this.IsOwnScrollPositionEnabled(),"scrollX":this.GetScrollX(),"scrollY":this.GetScrollY()}}RestoreTransform(e){this.SetParallax(e["parallaxX"],e["parallaxY"]),this.SetOwnScale(e["scale"]),this.SetScaleRate(e["scaleRate"]),this.SetAngle(e["angle"]),this.SetOwnScrollPositionEnabled(e["hasOwnScroll"]),this.SetScrollX(e["scrollX"]),this.SetScrollY(e["scrollY"]),this._MaybeUpdateViewport()}_RemoveAllInstancesInSet(e){if(0!==e.size){const t=C3.arrayRemoveAllInSet(this._instances,e);0<t&&(this._MaybeResetAnyInstanceZElevatedFlag(),this.SetZIndicesChanged())}}SetZIndicesChanged(e){this._zIndicesUpToDate=!1,this._isRenderListUpToDate=!1,e&&!e.GetObjectClass().GetPlugin().IsHTMLElementType()||(this._htmlZIndicesUpToDate=!1)}_UpdateZIndices(){if(!this._zIndicesUpToDate){if(this._instances.sort(SortByInstZElevation),this.UsesRenderCells())for(let e=0,t=this._instances.length;e<t;++e){const s=this._instances[e].GetWorldInfo();s._SetZIndex(e),this._renderGrid.MarkRangeChanged(s.GetRenderCellRange())}else for(let e=0,t=this._instances.length;e<t;++e)this._instances[e].GetWorldInfo()._SetZIndex(e);this._zIndicesUpToDate=!0}}_UpdateHTMLZIndices(){if(!this._htmlZIndicesUpToDate){const t=this._layout.GetRootLayersForHTMLLayer(this.GetHTMLIndex()),s=t.map(e=>[...e.selfAndAllSubLayers()]).flat();let e=0;for(const a of s){for(const i of a._GetInstances())i.GetObjectClass().GetPlugin().IsHTMLElementType()&&i.GetWorldInfo()._SetHTMLZIndex(e++);a._SetHTMLZIndicesUpToDate()}}}_SetHTMLZIndicesUpToDate(){this._htmlZIndicesUpToDate=!0}_GetHTMLLayerDOMState(){return{"isVisible":this.IsVisible(),"opacity":this.GetOpacity(),"isInteractive":this.IsInteractive()}}MoveInstanceAdjacent(e,t,s){const a=e.GetWorldInfo(),i=t.GetWorldInfo();if(a.GetLayer()!==this||i.GetLayer()!==this)throw new Error("can't arrange Z order unless both objects on this layer");const r=a.GetZIndex();let n=i.GetZIndex();return r!==n+(s?1:-1)&&(C3.arrayRemove(this._instances,r),r<n&&n--,s&&n++,n===this._instances.length?this._instances.push(e):this._instances.splice(n,0,e),this.SetZIndicesChanged(e),!0)}_MergeSortedZArrays(e,t){const s=[];let a=0,i=0,r=e.length,n=t.length;for(;a<r&&i<n;){const l=e[a],o=t[i];l.GetWorldInfo()._GetLastCachedZIndex()<o.GetWorldInfo()._GetLastCachedZIndex()?(s.push(l),++a):(s.push(o),++i)}for(;a<r;++a)s.push(e[a]);for(;i<n;++i)s.push(t[i]);return s}_MergeAllSortedZArrays_pass(t){const s=[],a=t.length;for(let e=0;e<a-1;e+=2){const i=t[e],r=t[e+1];s.push(this._MergeSortedZArrays(i,r))}return a%2==1&&s.push(t[a-1]),s}_MergeAllSortedZArrays(e){for(;1<e.length;)e=this._MergeAllSortedZArrays_pass(e);return e[0]}_GetRenderCellInstancesToDraw(){return this._UpdateZIndices(),C3.clearArray(renderCellArr),this._renderGrid.QueryRange(this.GetViewport(),renderCellArr),renderCellArr.length?1===renderCellArr.length?renderCellArr[0]:this._MergeAllSortedZArrays(renderCellArr):[]}ShouldDraw(){return this.IsVisible()&&0<this.GetOpacity()&&this._DrawsAnyContentInSelfOrSubLayers()}_DrawsAnyContentInSelfOrSubLayers(){if(this.HasInstances()||!this.IsTransparent())return!0;for(const e of this._subLayers)if(e._DrawsAnyContentInSelfOrSubLayers())return!0;return!1}UsesOwnTexture(){return this.IsForceOwnTexture()||!this.HasDefaultColor()||0!==this.GetBlendMode()||this._effectList.HasAnyActiveEffect()}SelfOrAnySubLayerUsesOwnTexture(){if(this.UsesOwnTexture())return!0;for(const e of this._subLayers)if(e.SelfOrAnySubLayerUsesOwnTexture())return!0;return!1}GetRenderTarget(){return this._curRenderTarget}Get2DScaleFactorToZ(e){if(this._layout.IsOrthographicProjection())return 1;{const t=this.Get3DCameraZ();return t/(t-e)}}GetResolutionScaleFactorToZ(e){const t=this._runtime.GetRenderScale();if(this._layout.IsOrthographicProjection())return t;{const s=this.Get3DCameraZ(),a=this.GetDefaultCameraZ();return a/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 a=this._runtime,i=this.GetLayout(),r=a.GetParallaxXOrigin(),n=a.GetParallaxYOrigin();let l=(this.GetScrollX()-r)*this._parallaxX+r,o=(this.GetScrollY()-n)*this._parallaxY+n,h=(a.IsPixelRoundingEnabled()&&(l=Math.round(l),o=Math.round(o)),l+e),c=o+t,d=i.IsOrthographicProjection()?this.GetDefaultCameraZ(s):this.Get2DCameraZ(s),[_,u]=this._GetVanishingPoint();if(.5!==_||.5!==u){const G=this.GetDefaultCameraZ(s)/d;let e=(_-.5)*a.GetViewportWidth()/G,t=(u-.5)*a.GetViewportHeight()/G;const f=this.GetAngle();0!==f&&(tempVec2.set(e,t),tempVec2.rotate(f),e=tempVec2.getX(),t=tempVec2.getY()),h+=e,c+=t}return[h,c,d]}_CalculateModelViewMatrix(e,t,s,a,i){const r=this._runtime,n=this.GetLayout();if(this.Has3DCamera()){vec3.copy(camVector,n.Get3DCameraPosition()),vec3.copy(lookVector,n.Get3DCameraLookAt()),vec3.copy(upVector,n.Get3DCameraUpVector());const l=r.GetParallaxXOrigin(),o=r.GetParallaxYOrigin(),h=lookVector[0]-camVector[0],c=lookVector[1]-camVector[1],d=lookVector[2]-camVector[2];camVector[0]=(camVector[0]-l)*this._parallaxX+l,camVector[1]=(camVector[1]-o)*this._parallaxY+o,camVector[2]*=Math.max(this._parallaxX,this._parallaxY),lookVector[0]=camVector[0]+h,lookVector[1]=camVector[1]+c,lookVector[2]=camVector[2]+d}else{const[_,u,G]=this._Get2DCameraPosition(s,a,i),f=(vec3.set(camVector,_,u,G),vec3.set(lookVector,_,u,G-100),this.GetAngle());0===f?vec3.set(upVector,0,1,0):vec3.set(upVector,Math.sin(f),Math.cos(f),0)}e.CalculateLookAtModelView(t,camVector,lookVector,upVector,i||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,a]=this._GetVanishingPoint();if(this._layout.IsOrthographicProjection())e.CalculateOrthographicMatrix(this._projectionMatrix,t.GetDrawWidth(),t.GetDrawHeight());else if(.5===s&&.5===a)mat4.copy(this._projectionMatrix,t.GetDefaultProjectionMatrix());else{const i=t.GetDrawWidth(),r=t.GetDrawHeight();e.CalculatePerspectiveMatrix(this._projectionMatrix,i/r,s,a)}}_SetTransform(e,t=!0,s=0,a=0,i=0){t&&e.SetProjectionMatrix(this._GetProjectionMatrix(e));let r=null;r=0===s&&0===a&&0===i?this._GetModelViewMatrix(e):(this._CalculateModelViewMatrix(e,tempMat4,s,a,i),tempMat4),e.SetModelViewMatrix(r)}PrepareForDraw(e){this._SetTransform(e),e.SetBaseZ(this.GetZElevation())}_MaybeStartWebGLProfiling(e){let t=null;if(e.IsWebGL()&&this._runtime.IsGPUProfiling()){const s=this._runtime.GetCanvasManager().GetLayerTimingsBuffer(this);s&&(t=s.AddTimeElapsedQuery(),e.StartQuery(t))}return t}_MaybeStartWebGPUProfiling(e){if(e.IsWebGPU()&&this._runtime.IsGPUProfiling()){const t=2*(this.GetIndex()+1);e.StartMeasuringRenderPassTime(t,1+t)}}Draw(e,t,s){const a=this._runtime.GetCanvasManager(),i=this.UsesOwnTexture();let r=null;const n=this._MaybeStartWebGLProfiling(e);if(this._MaybeStartWebGPUProfiling(e),i){const l={sampling:this._runtime.GetSampling(),isSampled:!0,canReadPixels:!!e.IsWebGPU()&&this._runtime.UsesAnyBackgroundBlending()};"low"===a.GetCurrentFullscreenScalingQuality()&&(l.width=a.GetDrawWidth(),l.height=a.GetDrawHeight()),r=this._runtime.GetAdditionalRenderTarget(l),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,i&&this.IsTransparent()),this._MaybeStartWebGPUProfiling(e),this._SetTransform(e),e.SetBaseZ(this.GetZElevation()),e.SetDepthEnabled(this.RendersIn3DMode()),this.GetNormalScale()>Number.EPSILON){this._UpdateZIndices();const o=this.UsesRenderCells()&&0===this.GetZElevation()&&!this._anyInstanceZElevated;this.Has3DCamera()?this._DrawInstances_3DCamera(e):o?this._DrawInstances_RenderCells(e):this._DrawInstances(e,this._GetInstancesInDrawOrder())}e.SetBaseZ(0),e.SetCurrentZ(0),i&&(e.SetDepthEnabled(!1),this._DrawLayerOwnTextureToRenderTarget(e,r,t,s)),n&&e.EndQuery(n),this._curRenderTarget=null}_DrawInstances(s,a){const i=this.GetViewport(),r=this._curRenderTarget,n=this.GetLayout().IsOrthographicProjection(),l=this.GetLayout().HasVanishingPointOutsideViewport();let o=null;for(let e=0,t=a.length;e<t;++e){const h=a[e];if(h!==o){const c=(o=h).GetWorldInfo();c.IsVisible()&&c.IsInViewport(i,l,n)&&this._DrawInstanceMaybeWithEffects(h,c,s,r)}}}_DrawInstances_3DCamera(a){const i=this._curRenderTarget,r=this._GetViewFrustum(),n=tempInstanceList1,l=tempInstanceList2,o=this._GetInstancesInDrawOrder();for(let t=0,s=o.length;t<s;){const h=o[t],c=h.GetWorldInfo();if(c.IsVisible()&&c.IsInViewport3D(r)){(!h.RendersToOwnZPlane()||0<c.GetDepth())&&l.push(h);const d=h.GetWorldInfo().GetTotalZElevation();n.push(h);let e=t+1;for(;e<s;++e){const _=o[e],u=_.GetWorldInfo();if(u.IsVisible()&&u.IsInViewport3D(r)){if(u.GetTotalZElevation()!==d)break;(_.RendersToOwnZPlane()?(0<u.GetDepth()&&l.push(_),n):l).push(_)}}if(1!==n.length||n[0].MustMitigateZFighting()){this._DrawCoplanarInstances_3DCamera(a,n);for(let e=0,t=l.length;e<t;++e){const G=l[e],f=G.GetWorldInfo();f._SetDrawNonBackFacesOnly(!0),this._DrawInstanceMaybeWithEffects(G,f,a,i),f._SetDrawNonBackFacesOnly(!1)}}else{this._DrawInstanceMaybeWithEffects(h,c,a,i);for(let e=0,t=l.length;e<t;++e){const p=l[e];if(p!==h){const I=p.GetWorldInfo(),C=I.GetLayer();C._DrawInstanceMaybeWithEffects(p,I,a,i)}}}t=e,C3.clearArray(n),C3.clearArray(l)}else++t}}_DrawCoplanarInstances_3DCamera(s,a){const i=this._curRenderTarget;s.CoplanarStartStencilPass();for(let e=0,t=a.length;e<t;++e){const r=a[e],n=r.GetWorldInfo();n._SetDrawBackFaceOnly(!0),this._DrawInstance(r,n,s)}s.CoplanarStartColorPass();for(let e=0,t=a.length;e<t;++e){const l=a[e],o=l.GetWorldInfo();this._DrawInstanceMaybeWithEffects(l,o,s,i),o._SetDrawBackFaceOnly(!1)}s.CoplanarRestoreStandardRendering()}_DrawInstances_RenderCells(e){const t=this._renderGrid,s=this._curRenderCells,a=this._lastRenderCells,i=this.GetViewport();let r;s.set(t.XToCell(i.getLeft()),t.YToCell(i.getTop()),t.XToCell(i.getRight()),t.YToCell(i.getBottom())),this._isRenderListUpToDate&&s.equals(a)?r=this._lastRenderList:(r=this._GetRenderCellInstancesToDraw(),this._isRenderListUpToDate=!0,a.copy(s)),this._DrawInstances(e,r),r!==this._lastRenderList&&C3.shallowAssignArray(this._lastRenderList,r)}_DrawInstanceMaybeWithEffects(e,t,s,a){t.HasAnyActiveEffect()?this._DrawInstanceWithEffectsAndRestore(e,t,s,a):this._DrawInstance(e,t,s)}_DrawInstance(e,t,s){const a=t.GetRendererStateGroup();s.GetCurrentStateGroup()!==a&&a.Apply(),e.Draw(s)}_DrawInstanceWithEffectsAndRestore(e,t,s,a){this._DrawInstanceWithEffects(e,t,s,a,null)&&this._SetTransform(s)}_DrawInstanceWithEffects(e,t,s,a,i){const r=t.GetInstanceEffectList().GetEffectChain();return r.Render(s,a,{contentObject:e,blendMode:t.GetBlendMode(),devicePixelRatio:this._runtime.GetEffectDevicePixelRatioParam(),time:e.GetInstanceGameTime(),layerScale:this._runtime.GetEffectLayerScaleParam()*this.GetNormalScale(),layerAngle:this.GetAngle(),layoutRect:t.GetBoundingBox(),drawSurfaceRect:r.CanSkipCalculatingDrawSurfaceRect()?null:this._InstanceBoxToDrawSurface(t),drawContentHook:i&&i.drawContentHook,compositOffX:i&&i.compositOffX,compositOffY:i&&i.compositOffY,updateOwnProjection:i&&i.updateOwnProjection}),s.SetBaseZ(this.GetZElevation()),r.DidChangeTransform()}_DrawLayerOwnTextureToRenderTarget(e,t,s,a){const i=this._effectList.GetActiveEffectTypes(),r=this._runtime;0===i.length?(e.SetRenderTarget(s),e.SetTextureFillMode(),a&&0===this._blendMode&&this.HasDefaultColor()?e.CopyRenderTarget(t):(e.SetBlendMode(this._blendMode),e.SetColor(this._premultipliedColor),e.DrawRenderTarget(t)),e.InvalidateRenderTarget(t),r.ReleaseAdditionalRenderTarget(t)):this.GetEffectChain().Render(e,s,{contentObject:this,blendMode:this.GetBlendMode(),devicePixelRatio:r.GetEffectDevicePixelRatioParam(),layerScale:r.GetEffectLayerScaleParam()*this.GetNormalScale(),layerAngle:this.GetAngle(),layoutRect:this.GetViewport(),drawSurfaceRect:null,invalidateRenderTargets:!0})}GetOwnScale(){return this._scale}SetOwnScale(e){this._scale!==e&&(this._scale=e,this._layout.BoundScrolling(),this._SetMVMatrixChanged(),this._runtime.UpdateRender())}GetRenderScale(){return this.GetNormalScale()*this._runtime.GetRenderScale()}GetDisplayScale(){return this.GetNormalScale()*this._runtime.GetDisplayScale()}GetNormalScale(){return(this._scale*this._layout.GetScale()-1)*this._scaleRate+1}_MaybeUpdateViewport(){if(this._isViewportChanged){this._isViewportChanged=!1;const s=this._runtime.GetParallaxXOrigin(),a=this._runtime.GetParallaxYOrigin(),i=(this.GetScrollX()-s)*this._parallaxX+s,r=(this.GetScrollY()-a)*this._parallaxY+a,n=this.GetNormalScale(),l=this._runtime.GetViewportWidth()/n,o=this._runtime.GetViewportHeight()/n;let e=i-l/2,t=r-o/2;this._runtime.IsPixelRoundingEnabled()&&(e=Math.round(e),t=Math.round(t));const h=this._viewportZ0,c=(h.set(e,t,e+l,t+o),this.GetAngle()),d=(0!==c&&(tmpRect.copy(h),tmpRect.offset(-h.midX(),-h.midY()),tmpQuad.setFromRotatedRect(tmpRect,c),tmpQuad.getBoundingBox(tmpRect),tmpRect.offset(h.midX(),h.midY()),h.copy(tmpRect)),this._zElevation);this.GetViewportForZ(d,this._viewport),this.Has3DCamera()?this.CalculateViewport3D(d,this._viewport3D):this._viewport3D.copy(this._viewport)}}CalculateViewport3D(e,t){let s=this._runtime.GetCanvasManager(),a=s.GetCssWidth(),i=s.GetCssHeight(),[r,n]=this.CanvasCssToLayer(0,0,e),[l,o]=this.CanvasCssToLayer(a,0,e),[h,c]=this.CanvasCssToLayer(a,i,e),[d,_]=this.CanvasCssToLayer(0,i,e),u=Math.min(r,l,h,d),G=Math.min(n,o,c,_),f=Math.max(r,l,h,d),p=Math.max(n,o,c,_);isFinite(u)||(u=-1/0),isFinite(G)||(G=-1/0),isFinite(f)||(f=1/0),isFinite(p)||(p=1/0),t.set(u,G,f,p)}CanvasCssToLayer(e,t,s=0){return this._CanvasToLayer(e,t,s,this.GetDisplayScale())}DrawSurfaceToLayer(e,t,s=0){return this._CanvasToLayer(e,t,s,this.GetRenderScale()*this.GetDevicePixelRatio())}_CanvasToLayer(e,t,s,a){const i=this._runtime,r=i.GetRenderer(),n=this.GetNormalScale(),l=i.GetViewportWidth()/n,o=i.GetViewportHeight()/n,h=tempVec4,c=(vec4.set(h,0,0,l,o),e/=a,t=h[3]-t/a,this._GetProjectionMatrix(r)),d=this._GetModelViewMatrix(r),_=tempVec3,u=C3.Gfx.UnprojectScreenToWorldZ(e,t,s,d,c,h,_);return u?[_[0],_[1]]:[NaN,NaN]}CanvasCssToLayer_DefaultTransform(e,t){const s=this._scale,a=this._scaleRate,i=this._parallaxX,r=this._parallaxY,n=this._angle,l=(this._scale=1,this._scaleRate=1,this._parallaxX=1,this._parallaxY=1,this._angle=0,this._SetMVMatrixChanged(),this.CanvasCssToLayer(e,t));return this._scale=s,this._scaleRate=a,this._parallaxX=i,this._parallaxY=r,this._angle=n,this._SetMVMatrixChanged(),l}LayerToCanvasCss(e,t,s=0){return this._LayerToCanvas(e,t,s,this.GetDisplayScale())}LayerToDrawSurface(e,t,s=0){return this._LayerToCanvas(e,t,s,this.GetRenderScale()*this.GetDevicePixelRatio())}_LayerToCanvas(e,t,s,a){const i=this._runtime,r=i.GetRenderer(),n=this.GetNormalScale(),l=i.GetViewportWidth()/n,o=i.GetViewportHeight()/n,h=tempVec4,c=(vec4.set(h,0,0,l,o),this._GetProjectionMatrix(r)),d=this._GetModelViewMatrix(r),_=tempVec3,u=C3.Gfx.Project(e,t,s,d,c,h,_);return u?[_[0]*a,(h[3]-_[1])*a]:[NaN,NaN]}_GetLayerToDrawSurfaceScale(e,t){return e*=this.GetRenderScale()*this.GetDevicePixelRatio(),0!==t&&(e*=this.Get2DScaleFactorToZ(t)),e}_InstanceBoxToDrawSurface(e){const t=e.GetBoundingBox(),s=e.GetTotalZElevation(),a=e.GetDepth(),h=s+a,c=t.getLeft(),d=t.getTop(),_=t.getRight(),u=t.getBottom();if(this.Has3DCamera()){if(this._IsPointBehindNearPlane(c,d,s)||this._IsPointBehindNearPlane(_,d,s)||this._IsPointBehindNearPlane(_,u,s)||this._IsPointBehindNearPlane(c,u,s))return null;if(0<a&&(this._IsPointBehindNearPlane(c,d,h)||this._IsPointBehindNearPlane(_,d,h)||this._IsPointBehindNearPlane(_,u,h)||this._IsPointBehindNearPlane(c,u,h)))return null}else if(h>=this.Get2DCameraZ())return null;let[G,f]=this.LayerToDrawSurface(c,d,s),[p,I]=this.LayerToDrawSurface(_,u,s);if(0!==this.GetAngle()||0<a||this.Has3DCamera()){const[C,m]=this.LayerToDrawSurface(_,d,s),[y,S]=this.LayerToDrawSurface(c,u,s);if(0<a){let[e,t]=this.LayerToDrawSurface(c,d,h),[s,a]=this.LayerToDrawSurface(_,d,h),[i,r]=this.LayerToDrawSurface(_,u,h),[n,l]=this.LayerToDrawSurface(c,u,h),o=Math.min(G,p,C,y,e,s,i,n);p=Math.max(G,p,C,y,e,s,i,n),G=o,o=Math.min(f,I,m,S,t,a,r,l),I=Math.max(f,I,m,S,t,a,r,l),f=o}else{let e=Math.min(G,p,C,y);p=Math.max(G,p,C,y),G=e,e=Math.min(f,I,m,S),I=Math.max(f,I,m,S),f=e}}return tmpRect.set(G,f,p,I),tmpRect}_GetViewFrustum(){return this._isViewFrustumChanged&&(this._UpdateViewFrustum(),this._isViewFrustumChanged=!1),this._viewFrustum}_UpdateViewFrustum(){const e=this._runtime.GetRenderer(),t=this._GetProjectionMatrix(e),s=this._GetModelViewMatrix(e);this._viewFrustum.CalculatePlanes(s,t)}_IsPointBehindNearPlane(e,t,s){return this._GetViewFrustum().IsBehindNearPlane(e,t,s)}_SaveToJson(){const e={"d":this.IsDynamic(),"s":this.GetOwnScale(),"a":this.GetOwnAngle(),"v":this._IsVisibleFlagSet(),"i":this.IsInteractive(),"html":this.IsHTMLElementsLayer(),"bc":this._backgroundColor.toJSON(),"t":this.IsTransparent(),"sx":this._scrollX,"sy":this._scrollY,"hosp":this._hasOwnScrollPosition,"px":this.GetParallaxX(),"py":this.GetParallaxY(),"c":this._color.toJSON(),"sr":this.GetScaleRate(),"fx":this._effectList.SaveToJson(),"cg":this._createdGlobalUids};return e}_LoadFromJson(e){this._isDynamic=!!e["d"],this._scale=e["s"],this._angle=e["a"],this._isVisible=!!e["v"],this._isInteractive=!e.hasOwnProperty("i")||e["i"],this._isHTMLElementsLayer=!!e["html"],this._backgroundColor.setFromJSON(e["bc"]),this._isTransparent=!!e["t"],e.hasOwnProperty("sx")&&(this._scrollX=e["sx"]),e.hasOwnProperty("sy")&&(this._scrollY=e["sy"]),e.hasOwnProperty("hosp")&&(this._hasOwnScrollPosition=!!e["hosp"]),this._parallaxX=e["px"],this._parallaxY=e["py"],this._color.setFromJSON(e["c"]),this._UpdatePremultipliedColor(),this._scaleRate=e["sr"],C3.shallowAssignArray(this._createdGlobalUids,e["cg"]),C3.shallowAssignArray(this._initialInstances,this._startupInitialInstances);const s=new Set(this._createdGlobalUids);let a=0;for(let e=0,t=this._initialInstances.length;e<t;++e)s.has(this._initialInstances[e][2])||(this._initialInstances[a]=this._initialInstances[e],++a);C3.truncateArray(this._initialInstances,a),this._effectList.LoadFromJson(e["fx"]),this._needsRebuildEffectChainSteps=!0}_LoadFromJsonAfterInstances(){this._SortInstancesByLastCachedZIndex(!1),this.SetZIndicesChanged(),this._SetMVMatrixChanged(),this._SetProjectionMatrixChanged()}GetILayer(){return this._iLayer}SortAndAddInstancesByZIndex(e,t=!1){if(this._instances.includes(e))t&&this._instances.sort((e,t)=>{const s=e.GetWorldInfo().GetSceneGraphZIndex(),a=t.GetWorldInfo().GetSceneGraphZIndex();return s-a});else if(e.HasChildren()){const s=[...e.allChildren()];s.push(e),s.sort((e,t)=>{const s=e.GetWorldInfo().GetSceneGraphZIndex(),a=t.GetWorldInfo().GetSceneGraphZIndex();return s-a});for(const a of s)if(a.IsInContainer())for(const i of a.siblings())if(!s.includes(i)){const r=[...i.allChildren()];r.push(i),r.sort((e,t)=>{const s=e.GetWorldInfo().GetSceneGraphZIndex(),a=t.GetWorldInfo().GetSceneGraphZIndex();return s-a}),r&&r.length&&s.splice(s.length,0,...r)}for(const n of s)n.GetPlugin().IsWorldType()&&this._AddInstance(n,!0)}else if(e.GetPlugin().IsWorldType()&&this._AddInstance(e,!0),e.IsInContainer())for(const l of e.siblings()){const o=[...l.allChildren()];if(o.push(l),o.sort((e,t)=>{const s=e.GetWorldInfo().GetSceneGraphZIndex(),a=t.GetWorldInfo().GetSceneGraphZIndex();return s-a}),o&&o.length)for(const h of o)h.GetPlugin().IsWorldType()&&this._AddInstance(h,!0)}}}; } // layouts/layout.js { const C3=self.C3,C3Debugger=self.C3Debugger,assert=self.assert,tempDestRect=C3.New(C3.Rect),tempSrcRect=C3.New(C3.Rect),tempLayoutRect=C3.New(C3.Rect),tempColor=C3.New(C3.Color),glMatrix=self.glMatrix,vec3=glMatrix.vec3,tempRender3dList=[],tempInstanceList1=[],tempInstanceList2=[],tempInstanceList3=[];function vec3EqualsXYZ(e,t,s,a){return e[0]===Math.fround(t)&&e[1]===Math.fround(s)&&e[2]===Math.fround(a)}let lastLayerPreparedForDrawing=null;function MaybePrepareLayerDraw(e,t){lastLayerPreparedForDrawing!==e&&(e.PrepareForDraw(t),lastLayerPreparedForDrawing=e)}C3.Layout=class extends C3.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=vec3.create(),this._cam3dlook=vec3.create(),this._cam3dup=vec3.create(),this._rootLayers=[],this._allLayersFlat=[],this._layersByName=new Map,this._layersBySid=new Map,this._pendingSetHTMLLayerCount=-1;const r=this._runtime.GetCanvasManager();this._effectList=C3.New(C3.EffectList,this,s[11]),this._effectChain=C3.New(C3.Gfx.EffectChain,r.GetEffectChainManager(),{drawContent:(e,t)=>{const s=t.GetContentObject(),a=s.GetRenderTarget();e.ResetColor(),e.DrawRenderTarget(a),e.InvalidateRenderTarget(a),r.ReleaseAdditionalRenderTarget(a)},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=C3.New(C3.Event.Dispatcher);for(const a of s[9])this._rootLayers.push(C3.Layer.CreateFromExportData(this,null,a));this._ReindexLayers();for(const n of this.allLayers())n._InitInitialInstances();for(const i of s[10]){const o=this._runtime.GetObjectClassByIndex(i[1]);if(!o)throw new Error("missing nonworld object class");o.GetDefaultInstanceData()||o.SetDefaultInstanceData(i),this._initialNonWorld.push(i),this._AddInitialObjectClass(o)}}Release(){for(const e of this._allLayersFlat)e.Release();C3.clearArray(this._allLayersFlat),this._textureLoadPendingPromises.clear(),this._eventSheet=null,this._layoutManager=null,this._runtime=null}GetRuntime(){return this._runtime}GetName(){return this._name}GetSID(){return this._sid}GetIndex(){return this._index}GetEffectList(){return this._effectList}GetEffectChain(){return this._MaybeRebuildEffectChainSteps(),this._effectChain}_MaybeRebuildEffectChainSteps(){const e="low"===this._runtime.GetCanvasManager().GetCurrentFullscreenScalingQuality();if(this._needsRebuildEffectChainSteps||this._wasFullScreenQualityLow!==e||this._effectChain.NeedsRebuild()){const t=this.GetEffectList().GetActiveEffectTypes();this._effectChain.BuildSteps(t.map(e=>e.GetShaderProgram()),{indexMap:t.map(e=>e.GetIndex()),forcePostDraw:e,useFullSurface:!0}),this._needsRebuildEffectChainSteps=!1,this._wasFullScreenQualityLow=e}}UpdateActiveEffects(){this.GetEffectList().UpdateActiveEffects(),this._needsRebuildEffectChainSteps=!0}GetMinLayerScale(){let s=this._allLayersFlat[0].GetNormalScale();for(let e=1,t=this._allLayersFlat.length;e<t;++e){const a=this._allLayersFlat[e];0===a.GetParallaxX()&&0===a.GetParallaxY()||(s=Math.min(s,a.GetNormalScale()))}return s}_GetScrollBoundMarginHorizontal(){return.5*this._runtime.GetViewportWidth()/this.GetMinLayerScale()}_GetScrollBoundMarginVertical(){return.5*this._runtime.GetViewportHeight()/this.GetMinLayerScale()}GetScrollLeftBound(){return this.IsUnboundedScrolling()?-1/0:this._GetScrollBoundMarginHorizontal()}GetScrollRightBound(){return this.IsUnboundedScrolling()?1/0:this.GetWidth()-this._GetScrollBoundMarginHorizontal()}GetScrollTopBound(){return this.IsUnboundedScrolling()?-1/0:this._GetScrollBoundMarginVertical()}GetScrollBottomBound(){return this.IsUnboundedScrolling()?1/0:this.GetHeight()-this._GetScrollBoundMarginVertical()}SetScrollX(e){const t=this.GetScrollLeftBound(),s=this.GetScrollRightBound();this._scrollX!==(e=(e=s<e?s:e)<t?t:e)&&(this._scrollX=e,this._SetAllLayersMVChanged(),this._runtime.UpdateRender())}GetScrollX(){return this._scrollX}SetScrollY(e){const t=this.GetScrollTopBound(),s=this.GetScrollBottomBound();this._scrollY!==(e=(e=s<e?s:e)<t?t:e)&&(this._scrollY=e,this._SetAllLayersMVChanged(),this._runtime.UpdateRender())}GetScrollY(){return this._scrollY}IsUnboundedScrolling(){return this._isUnboundedScrolling}BoundScrolling(){this.SetScrollX(this.GetScrollX()),this.SetScrollY(this.GetScrollY());for(const e of this._allLayersFlat)e.IsOwnScrollPositionEnabled()&&(e.SetScrollX(e.GetScrollX()),e.SetScrollY(e.GetScrollY()))}SetVanishingPointXY(e,t){this._vanishingPointX===e&&this._vanishingPointY===t||(this._vanishingPointX=e,this._vanishingPointY=t,this.IsPerspectiveProjection()&&(this._SetAllLayersProjectionChanged(),this._SetAllLayersMVChanged(),this._runtime.UpdateRender()))}GetVanishingPointX(){return this.IsOrthographicProjection()?.5:this._vanishingPointX}GetVanishingPointY(){return this.IsOrthographicProjection()?.5:this._vanishingPointY}HasVanishingPointOutsideViewport(){const e=this.GetVanishingPointX(),t=this.GetVanishingPointY();return e<0||1<e||t<0||1<t}SetPerspectiveProjection(){this._isOrthographicProjection&&(this._isOrthographicProjection=!1,this._SetAllLayersProjectionChanged(),this._SetAllLayersMVChanged(),this._runtime.UpdateRender())}SetOrthographicProjection(){this._isOrthographicProjection||(this._isOrthographicProjection=!0,this._SetAllLayersProjectionChanged(),this._SetAllLayersMVChanged(),this._runtime.UpdateRender())}IsOrthographicProjection(){return this._isOrthographicProjection}IsPerspectiveProjection(){return!this.IsOrthographicProjection()}Set3DCameraEnabled(e){this._is3dCameraEnabled!==(e=!!e)&&(this._is3dCameraEnabled=e,this._SetAllLayersMVChanged(),this._runtime.UpdateRender())}Is3DCameraEnabled(){return this._is3dCameraEnabled}Set3DCameraOrientation(e,t,s,a,r,n,i,o,l){vec3EqualsXYZ(this._cam3dposition,e,t,s)&&vec3EqualsXYZ(this._cam3dlook,a,r,n)&&vec3EqualsXYZ(this._cam3dup,i,o,l)||(vec3.set(this._cam3dposition,e,t,s),vec3.set(this._cam3dlook,a,r,n),vec3.set(this._cam3dup,i,o,l),this.Set3DCameraChanged())}Set3DCameraChanged(){this._SetAllLayersMVChanged(),this._runtime.UpdateRender()}Get3DCameraPosition(){return this._cam3dposition}Get3DCameraLookAt(){return this._cam3dlook}Get3DCameraUpVector(){return this._cam3dup}GetScale(){return this._scale}SetScale(e){this._scale!==e&&(this._scale=e,this._SetAllLayersMVChanged(),this.BoundScrolling(),this._runtime.UpdateRender())}SetAngle(e){e=C3.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=C3.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 a=2<=s?t:t.GetParentLayer(),r=C3.New(C3.Layer,this,a,{name:e,sid:Math.floor(1e15*Math.random()),isDynamic:!0});this._InsertLayer(r,t,s),this.GetRuntime().UpdateRender(),this._ReindexAndUpdateAllLayers()}MoveLayer(e,t,s){if(!t&&s<2)throw new Error("invalid insert position");e===t&&s<2||(this._RemoveLayer(e),this._InsertLayer(e,t,s),this.GetRuntime().UpdateRender(),this._ReindexAndUpdateAllLayers())}RemoveLayer(e){if(this._RemoveLayer(e)){const t=this._runtime.GetEventSheetManager();t.BlockFlushingInstances(!0),e.Release(),t.BlockFlushingInstances(!1),this.GetRuntime().UpdateRender(),this._ReindexAndUpdateAllLayers()}}RemoveAllDynamicLayers(){const e=new Set;for(const t of this.allLayers())t.IsDynamic()&&!t.HasAnyDynamicParentLayer()&&e.add(t);if(0!==e.size){const s=this._runtime.GetEventSheetManager();s.BlockFlushingInstances(!0);for(const a of e)this._RemoveLayer(a),a.Release();s.BlockFlushingInstances(!1),this.GetRuntime().UpdateRender(),this._ReindexAndUpdateAllLayers()}}_InsertLayer(t,s,a){if(2<=a)if(s){if(s===t||s.HasParentLayer(t))throw new Error(`cannot move layer '${t.GetName()}' to sub-layer of itself`);s._AddSubLayer(t,2===a),t._SetParentLayer(s)}else 2===a?this._rootLayers.push(t):this._rootLayers.unshift(t),t._SetParentLayer(null);else{const e=s.GetParentLayer();if(e){if(s.HasParentLayer(t))throw new Error(`cannot move layer '${t.GetName()}' to sub-layer of itself`);e._InsertSubLayer(t,s,0===a),t._SetParentLayer(e)}else{let e=this._rootLayers.indexOf(s);if(-1===e)throw new Error("cannot find layer to insert by");0===a&&++e,this._rootLayers.splice(e,0,t),t._SetParentLayer(null)}}}_RemoveLayer(e){const t=e.GetParentLayer();if(t)return t._RemoveSubLayer(e),!0;if(1<this._rootLayers.length){const s=this._rootLayers.indexOf(e);if(-1===s)throw new Error("cannot find layer to remove");return this._rootLayers.splice(s,1),!0}return!1}_ReindexLayers(){this._allLayersFlat=[...this.allLayers()],this._layersByName.clear(),this._layersBySid.clear();for(let e=0,t=this._allLayersFlat.length;e<t;++e){const s=this._allLayersFlat[e];s._SetIndex(e),this._layersByName.set(s.GetName().toLowerCase(),s),this._layersBySid.set(s.GetSID(),s)}}_ReindexHTMLLayers(){let e=0;for(const t of this._rootLayers){for(const s of t.selfAndAllSubLayers())s._SetHTMLIndex(e);t.IsHTMLElementsLayer()&&e++}}GetHTMLLayerCount(){return this._rootLayers.at(-1).GetHTMLIndex()+1}async _ReindexAndUpdateAllLayers(){this._ReindexLayers(),this._ReindexHTMLLayers(),this._pendingSetHTMLLayerCount=this.GetHTMLLayerCount()}_GetPendingSetHTMLLayerCount(){return this._pendingSetHTMLLayerCount}_ResetPendingHTMLLayerCount(){this._pendingSetHTMLLayerCount=-1}GetRootLayersForHTMLLayer(e){const t=[];for(const s of this._rootLayers){const a=s.GetHTMLIndex();if(a===e)t.push(s);else if(e<a)break}return t}SaveTransform(){return{"scrollX":this.GetScrollX(),"scrollY":this.GetScrollY(),"scale":this.GetScale(),"angle":this.GetAngle(),"vpX":this.GetVanishingPointX(),"vpY":this.GetVanishingPointY()}}RestoreTransform(e){this.SetScrollX(e["scrollX"]),this.SetScrollY(e["scrollY"]),this.SetScale(e["scale"]),this.SetAngle(e["angle"]),this.SetVanishingPointXY(e["vpX"],e["vpY"])}GetLayoutBackgroundColor(){let e=this._rootLayers.filter(e=>e.ShouldDraw())[0];for(;e;){if(!e.IsTransparent())return tempColor.copyRgb(e.GetBackgroundColor()),tempColor.setA(1),tempColor;if(e.UsesOwnTexture())return tempColor.setRgba(0,0,0,0),tempColor;e=e.GetSubLayers().filter(e=>e.ShouldDraw())[0]}return tempColor.setRgba(0,0,0,0),tempColor}IsFirstVisit(){return this._isFirstVisit}_GetInitialObjectClasses(){return[...this._initialObjectClasses]}_AddInitialObjectClass(e){if(e.IsInContainer())for(const t of e.GetContainer().GetObjectTypes())this._initialObjectClasses.add(t);else this._initialObjectClasses.add(e)}_GetTextureLoadedObjectTypes(){return[...this._textureLoadedTypes]}_Load(e,t){if(e===this||!t)return Promise.resolve();e&&(C3.CopySet(this._textureLoadedTypes,e._textureLoadedTypes),e._textureLoadedTypes.clear());const s=[];for(const a of this._initialObjectClasses)this._textureLoadedTypes.has(a)||(s.push(a.LoadTextures(t)),this._textureLoadedTypes.add(a));return Promise.all(s)}async MaybeLoadTexturesFor(e){if(e.IsFamily())throw new Error("cannot load textures for family");const t=this._runtime.GetRenderer();if(t&&!t.IsContextLost()&&!this._textureLoadedTypes.has(e)){this._textureLoadedTypes.add(e);const s=e.LoadTextures(t);this._AddPendingTextureLoadPromise(s),await s,e.OnDynamicTextureLoadComplete(),this._runtime.UpdateRender()}}_AddPendingTextureLoadPromise(e){this._textureLoadPendingPromises.add(e),e.then(()=>this._textureLoadPendingPromises.delete(e)).catch(()=>this._textureLoadPendingPromises.delete(e))}WaitForPendingTextureLoadsToComplete(){return Promise.all([...this._textureLoadPendingPromises])}MaybeUnloadTexturesFor(e){if(e.IsFamily()||0<e.GetInstanceCount())throw new Error("cannot unload textures");const t=this._runtime.GetRenderer();t&&this._textureLoadedTypes.has(e)&&(this._textureLoadedTypes.delete(e),e.ReleaseTextures(t))}_Unload(e,t){if(e!==this&&t)for(const s of this._textureLoadedTypes)s.IsGlobal()||e._initialObjectClasses.has(s)||(s.ReleaseTextures(),this._textureLoadedTypes.delete(s))}_OnRendererContextLost(){this._textureLoadedTypes.clear()}async _StartRunning(e){const t=this._runtime,s=this._layoutManager,a=t.GetEventSheetManager(),r=(this._eventSheetName&&(this._eventSheet=a.GetEventSheetByName(this._eventSheetName),this._eventSheet._UpdateDeepIncludes()),s._SetMainRunningLayout(this),this._width=this._originalWidth,this._height=this._originalHeight,this._scrollX=t.GetOriginalViewportWidth()/2,this._scrollY=t.GetOriginalViewportHeight()/2,this.BoundScrolling(),this._SetAllLayersProjectionChanged(),this._SetAllLayersMVChanged(),this._ReindexHTMLLayers(),await this._runtime.GetCanvasManager().SetHTMLLayerCount(this.GetHTMLLayerCount(),!0),this._MoveGlobalObjectsToThisLayout(e),this._runtime.SetUsingCreatePromises(!0),this._CreateInitialInstances(),this._isFirstVisit||this._CreatePersistedInstances(),this._CreateAndLinkContainerInstances(this._createdInstances),this._CreateAndLinkContainerInstances(this._createdPersistedInstances),this._CreateInitialNonWorldInstances(),s.ClearPendingChangeLayout(),t.FlushPendingInstances(),this._runtime.SetUsingCreatePromises(!1),this._runtime.GetCreatePromises());if(await Promise.all(r),C3.clearArray(r),!t.IsLoadingState()){for(const n of this._createdInstances)n.SetupInitialSceneGraphConnections();for(const i of this._createdPersistedInstances)i.SetupPersistedSceneGraphConnections(this._createdPersistedInstancesToDataMap,this._createdPersistedIndexToInstanceMap);for(const[o,l]of Object.entries(this._persistData)){const h=this._runtime.GetObjectClassBySID(parseInt(o,10));h&&!h.IsFamily()&&h.HasPersistBehavior()&&C3.clearArray(l)}for(const c of this._createdInstances)c._TriggerOnCreated();for(const d of this._createdPersistedInstances)d._TriggerOnCreated();for(const _ of this._createdInstances)_.HasParent()||_._OnHierarchyReady();for(const u of this._createdPersistedInstances)u.HasParent()||u._OnHierarchyReady()}C3.clearArray(this._createdInstances),C3.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 C3.Event("beforefirstlayoutstart")),await t.DispatchUserScriptEventAsyncWait(new C3.Event("beforeprojectstart"))),await this.DispatchRuntimeUserScriptEventAsyncWait(new C3.Event("beforeanylayoutstart")),t.Dispatcher().dispatchEvent(new C3.Event("beforelayoutstart")),await this.DispatchUserScriptEventAsyncWait(new C3.Event("beforelayoutstart")),t.IsLoadingState()||await t.TriggerAsync(C3.Plugins.System.Cnds.OnLayoutStart,null,null),t.Dispatcher().dispatchEvent(new C3.Event("afterlayoutstart")),await this.DispatchUserScriptEventAsyncWait(new C3.Event("afterlayoutstart")),await this.DispatchRuntimeUserScriptEventAsyncWait(new C3.Event("afteranylayoutstart")),e&&(t.Dispatcher().dispatchEvent(new C3.Event("afterfirstlayoutstart")),await t.DispatchUserScriptEventAsyncWait(new C3.Event("afterprojectstart"))),a._RunQueuedTriggers(s),await this.WaitForPendingTextureLoadsToComplete(),this._isFirstVisit=!1}_MoveGlobalObjectsToThisLayout(e){for(const t of this._runtime.GetAllObjectClasses())if(!t.IsFamily()&&t.IsWorldType())for(const s of t.GetInstances()){const a=s.GetWorldInfo(),r=a.GetLayer(),n=C3.clamp(r.GetIndex(),0,this._allLayersFlat.length-1),i=this._allLayersFlat[n];a._SetLayer(i,!0),i._MaybeAddInstance(s)}if(!e)for(const o of this._allLayersFlat)o._SortInstancesByLastCachedZIndex(!1)}_CreateInitialInstances(){for(const e of this._allLayersFlat)e.CreateInitialInstances(this._createdInstances),e._Start()}_CreatePersistedInstances(){let t=!1;for(const[e,s]of Object.entries(this._persistData)){const a=this._runtime.GetObjectClassBySID(parseInt(e,10));if(a&&!a.IsFamily()&&a.HasPersistBehavior())for(const r of s){let e=null;if(!a.IsWorldType()||(e=r.hasOwnProperty("instJson")?this.GetLayerBySID(r["instJson"]["w"]["l"]):this.GetLayerBySID(r["w"]["l"]))){const n=this._runtime.CreateInstanceFromData(a,e,!1,0,0,!0);r.hasOwnProperty("instJson")?n.LoadFromJson(r["instJson"]):n.LoadFromJson(r),t=!0,this._createdPersistedInstances.push(n),r.hasOwnProperty("instJson")&&(this._createdPersistedInstancesToDataMap.set(n,r),this._createdPersistedIndexToInstanceMap.set(r["index"],n))}}}for(const i of this._allLayersFlat)i._SortInstancesByLastCachedZIndex(!0),i.SetZIndicesChanged();t&&(this._runtime.FlushPendingInstances(),this._runtime._RefreshUidMap())}_CreateAndLinkContainerInstances(t){for(const s of t)if(s.IsInContainer()){const a=s.GetWorldInfo(),e=s.GetIID();for(const r of s.GetObjectClass().GetContainer().objectTypes())if(r!==s.GetObjectClass()){const n=r.GetInstances();if(n.length>e)s._AddSibling(n[e]);else{let e;e=a?this._runtime.CreateInstanceFromData(r,a.GetLayer(),!0,a.GetX(),a.GetY(),!0):this._runtime.CreateInstanceFromData(r,null,!0,0,0,!0),this._runtime.FlushPendingInstances(),r._UpdateIIDs(),s._AddSibling(e),t.push(e)}}}}_CreateInitialNonWorldInstances(){for(const e of this._initialNonWorld){const t=this._runtime.GetObjectClassByIndex(e[1]);t.IsInContainer()||this._runtime.CreateInstanceFromData(e,null,!0)}}_CreateGlobalNonWorlds(){const s=[],a=this._initialNonWorld;let r=0;for(let e=0,t=a.length;e<t;++e){const n=a[e],i=this._runtime.GetObjectClassByIndex(n[1]);i.IsGlobal()?i.IsInContainer()&&i.GetContainer().HasAnyWorldType()||s.push(this._runtime.CreateInstanceFromData(n,null,!0)):(a[r]=n,++r)}C3.truncateArray(a,r),this._runtime.FlushPendingInstances(),this._CreateAndLinkContainerInstances(s)}RecreateInitialObjects(e,t,s,a,r,n,i){if(s)return s.RecreateInitialObjects(e,t,r,n,a,i);{const o=[];for(const l of this._allLayersFlat)o.push(l.RecreateInitialObjects(e,t,r,n,a,i));return o.flat()}}async _StopRunning(){const e=this._layoutManager;this._runtime.IsLoadingState()||(await this.DispatchRuntimeUserScriptEventAsyncWait(new C3.Event("beforeanylayoutend")),await this.DispatchUserScriptEventAsyncWait(new C3.Event("beforelayoutend")),await this._runtime.TriggerAsync(C3.Plugins.System.Cnds.OnLayoutEnd,null,null),await this.DispatchUserScriptEventAsyncWait(new C3.Event("afterlayoutend")),await this.DispatchRuntimeUserScriptEventAsyncWait(new C3.Event("afteranylayoutend"))),e.SetIsEndingLayout(!0),this._runtime.GetEventSheetManager().ClearAllScheduledWaits(),this._isFirstVisit||this._SavePersistData();for(const t of this._allLayersFlat)t._End();for(const s of this._runtime.GetAllObjectClasses())if(!(s.IsGlobal()||s.IsWorldType()||s.GetPlugin().IsSingleGlobal()||s.IsFamily())){for(const a of s.GetInstances())this._runtime.DestroyInstance(a);this._runtime.FlushPendingInstances()}e.SetIsEndingLayout(!1),e.GetMainRunningLayout()===this&&e._SetMainRunningLayout(null)}_SaveInstanceToPersist(e,t){const s=e.GetObjectClass().GetSID().toString(),a=(this._persistData.hasOwnProperty(s)||(this._persistData[s]=[]),this._persistData[s]),r={"index":t,"instJson":e.SaveToJson(),"sceneGraphJson":{"children":[]}};a.push(r),this._persistedIntances.set(e,r)}_SaveSceneGraphInfoToPersist(e){const t=this._persistedIntances.get(e);for(const s of e.GetChildren()){const a=this._persistedIntances.get(s);a&&t["sceneGraphJson"]["children"].push({"index":a["index"],"flags":C3.SceneGraphInfo._GetFlagsNumber(s.GetWorldInfo())})}}_SavePersistData(){this._persistedIntances.clear();let e=0;for(const t of this._allLayersFlat){t._UpdateZIndices();for(const s of t._GetInstances()){const a=s.GetObjectClass();!a.IsGlobal()&&a.HasPersistBehavior()&&(this._SaveInstanceToPersist(s,e),e++)}}for(const r of this._allLayersFlat)for(const n of r._GetInstances()){const i=n.GetObjectClass();!i.IsGlobal()&&i.HasPersistBehavior()&&this._SaveSceneGraphInfoToPersist(n)}this._persistedIntances.clear()}ResetPersistData(){this._persistData={},this._isFirstVisit=!0}GetRenderTarget(){return this._curRenderTarget}UsesOwnTexture(){const e=this._runtime,t=e.GetRenderer().IsWebGL();return"low"===e.GetCanvasManager().GetCurrentFullscreenScalingQuality()||t&&e.UsesAnyBackgroundBlending()||this._effectList.HasAnyActiveEffect()||t&&e.Uses3DFeatures()}_MaybeStartDrawToOwnTexture(e){const t=this._runtime.GetCanvasManager();if(this.UsesOwnTexture()){e.SetRenderTarget(null),e.ClearRgba(0,0,0,0);const s={sampling:this._runtime.GetSampling(),isSampled:e.IsWebGPU()||this._runtime.UsesAnyBackgroundBlending()||this._effectList.HasAnyActiveEffect(),canReadPixels:!!e.IsWebGPU()&&this._runtime.UsesAnyBackgroundBlending()};"low"===t.GetCurrentFullscreenScalingQuality()&&(s.width=t.GetDrawWidth(),s.height=t.GetDrawHeight()),this._curRenderTarget=this._runtime.GetAdditionalRenderTarget(s)}else this._curRenderTarget=null}_MaybeCopyOwnTextureToBackbuffer(e){this._runtime._NeedsHTMLLayerCompositing(e)&&(e.SetDepthEnabled(!1),e.SetRenderTarget(null),e.SetTextureFillMode(),e.CopyRenderTarget(this._curRenderTarget))}_MaybeEndDrawToOwnTexture(e){this.UsesOwnTexture()&&(e.SetDepthEnabled(!1),this._DrawLayoutOwnTextureToRenderTarget(e,this._curRenderTarget))}DrawMain(e){e.SetRenderTarget(this._curRenderTarget),e.Clear(this.GetLayoutBackgroundColor()),this._runtime.Uses3DFeatures()&&e.ClearDepth();const t=this.GetRootLayersForHTMLLayer(0);this._DrawLayerList(e,this._curRenderTarget,t,!0),e.IsWebGPU()&&e.StartMeasuringRenderPassTime(0,1),this._MaybeEndDrawToOwnTexture(e),this._curRenderTarget=null}DrawForHTMLLayerIndex(e,t){let s=null;this._runtime._NeedsHTMLLayerCompositing(e)&&(s=this._curRenderTarget),e.SetRenderTarget(s),e.ClearRgba(0,0,0,0),this._runtime.Uses3DFeatures()&&e.ClearDepth();const a=this.GetRootLayersForHTMLLayer(t);this._DrawLayerList(e,s,a,!0),this._MaybeCopyOwnTextureToBackbuffer(e),e.EndBatch(),this._runtime.GetCanvasManager().BlitMainCanvasToHTMLLayerCanvas(t)}_DrawLayerList(e,a,t,r){const n=t.filter(e=>e.ShouldDraw());for(let t=0,s=n.length;t<s;){const i=n[t];if(i.SelfAndAllSubLayersHave3DCamera()&&!i.SelfOrAnySubLayerUsesOwnTexture()){tempRender3dList.push(i);for(let e=t+1;e<s;++e){const o=n[e];if(!o.SelfAndAllSubLayersHave3DCamera()||o.SelfOrAnySubLayerUsesOwnTexture())break;tempRender3dList.push(n[e])}if(2<=tempRender3dList.length||1===tempRender3dList.length&&tempRender3dList[0].HasAnyVisibleSubLayer()){this._Draw3DLayers(e,a,tempRender3dList),t+=tempRender3dList.length,C3.clearArray(tempRender3dList);continue}C3.clearArray(tempRender3dList)}i.Draw(e,a,r&&0===t),++t}}_DrawLayoutOwnTextureToRenderTarget(e,t){const s=this._effectList.GetActiveEffectTypes(),a=this._runtime;0===s.length?(e.SetRenderTarget(null),e.SetTextureFillMode(),e.CopyRenderTarget(t),e.InvalidateRenderTarget(t),a.ReleaseAdditionalRenderTarget(t)):(tempLayoutRect.set(0,0,a.GetViewportWidth(),a.GetViewportHeight()),this.GetEffectChain().Render(e,null,{contentObject:this,blendMode:3,devicePixelRatio:this._runtime.GetEffectDevicePixelRatioParam(),layerScale:this._runtime.GetEffectLayerScaleParam()*this.GetScale(),layerAngle:this.GetAngle(),layoutRect:tempLayoutRect,drawSurfaceRect:null,invalidateRenderTargets:!0}))}_Draw3DLayers(a,r,e){e[0].IsTransparent()||(tempColor.copyRgb(e[0].GetBackgroundColor()),tempColor.setA(1),a.Clear(tempColor));this._runtime.GetCanvasManager();a.SetDepthEnabled(!0);const n=tempInstanceList1,i=tempInstanceList2,o=tempInstanceList3;for(const l of e)l._UpdateZIndices(),l._AppendAllInstancesIncludingSubLayersInDrawOrder(n);const t=e[0],s=t._MaybeStartWebGLProfiling(a);t._MaybeStartWebGPUProfiling(a);for(let t=0,s=n.length;t<s;){const h=n[t],c=h.GetWorldInfo(),d=c.GetLayer();if(c.IsVisible()&&c.IsInViewport3D(d._GetViewFrustum())){(!h.RendersToOwnZPlane()||0<c.GetDepth())&&o.push(h);const _=h.GetWorldInfo().GetTotalZElevation();i.push(h);let e=t+1;for(;e<s;++e){const u=n[e],y=u.GetWorldInfo();if(y.IsVisible()&&y.IsInViewport3D(y.GetLayer()._GetViewFrustum())){if(y.GetTotalZElevation()!==_)break;(u.RendersToOwnZPlane()?(0<y.GetDepth()&&o.push(u),i):o).push(u)}}if(1!==i.length||i[0].MustMitigateZFighting()){this._Draw3DLayersCoplanarInstances(a,r,i);for(let e=0,t=o.length;e<t;++e){const L=o[e],f=L.GetWorldInfo(),p=f.GetLayer();f._SetDrawNonBackFacesOnly(!0),MaybePrepareLayerDraw(p,a),p._DrawInstanceMaybeWithEffects(L,f,a,r),f._SetDrawNonBackFacesOnly(!1)}}else{MaybePrepareLayerDraw(d,a),d._DrawInstanceMaybeWithEffects(h,c,a,r);for(let e=0,t=o.length;e<t;++e){const g=o[e];if(g!==h){const S=g.GetWorldInfo(),m=S.GetLayer();MaybePrepareLayerDraw(m,a),m._DrawInstanceMaybeWithEffects(g,S,a,r)}}}t=e,C3.clearArray(i),C3.clearArray(o)}else++t}s&&a.EndQuery(s),C3.clearArray(n),lastLayerPreparedForDrawing=null}_Draw3DLayersCoplanarInstances(s,a,r){s.CoplanarStartStencilPass();for(let e=0,t=r.length;e<t;++e){const n=r[e],i=n.GetWorldInfo(),o=i.GetLayer();i._SetDrawBackFaceOnly(!0),MaybePrepareLayerDraw(o,s),o._DrawInstance(n,i,s)}s.CoplanarStartColorPass();for(let e=0,t=r.length;e<t;++e){const l=r[e],h=l.GetWorldInfo(),c=h.GetLayer();MaybePrepareLayerDraw(c,s),c._DrawInstanceMaybeWithEffects(l,h,s,a),h._SetDrawBackFaceOnly(!1)}s.CoplanarRestoreStandardRendering()}_SaveToJson(){const e={"sx":this.GetScrollX(),"sy":this.GetScrollY(),"s":this.GetScale(),"a":this.GetAngle(),"w":this.GetWidth(),"h":this.GetHeight(),"ortho":this.IsOrthographicProjection(),"vpX":this.GetVanishingPointX(),"vpY":this.GetVanishingPointY(),"fv":this._isFirstVisit,"persist":this._persistData,"fx":this._effectList.SaveToJson(),"layers":{},"dynamicLayers":[]};for(const t of this._allLayersFlat)if(t.IsDynamic()){const s=t.GetParentLayer();e["dynamicLayers"].push({"sid":t.GetSID(),"name":t.GetName(),"parentSid":s?s.GetSID():null,"siblingIndex":t._GetSiblingIndex(),"data":t._SaveToJson()})}else e["layers"][t.GetSID().toString()]=t._SaveToJson();return e}_LoadFromJson(e){this._scrollX=e["sx"],this._scrollY=e["sy"],this._scale=e["s"],this._angle=e["a"],this._width=e["w"],this._height=e["h"],this._isOrthographicProjection=!!e["ortho"],e.hasOwnProperty("vpX")&&(this._vanishingPointX=e["vpX"]),e.hasOwnProperty("vpY")&&(this._vanishingPointY=e["vpY"]),this._isFirstVisit=!!e["fv"],this._persistData=e["persist"],this._effectList.LoadFromJson(e["fx"]),this._needsRebuildEffectChainSteps=!0;for(const[t,s]of Object.entries(e["layers"])){const a=parseInt(t,10),r=this.GetLayerBySID(a);r&&r._LoadFromJson(s)}if(e.hasOwnProperty("dynamicLayers")){this.RemoveAllDynamicLayers(),this._runtime.FlushPendingInstances();const n=new Map,i=e["dynamicLayers"];for(let e=i.length-1;0<=e;--e){const o=i[e],l=o["sid"],h=o["name"],c=o["parentSid"],d=o["siblingIndex"],_=o["data"];if(this._ReindexLayers(),!this.HasLayerByName(h)&&!this.GetLayerBySID(l)){let e,t;if(null===c)e=null,t=this._rootLayers;else{if(!(e=this.GetLayerBySID(c)))continue;t=e.GetSubLayers()}const u=C3.New(C3.Layer,this,e,{name:h,sid:l,isDynamic:!0});t.push(u);let s=n.get(t);s||(s=[],n.set(t,s)),s.push({layer:u,siblingIndex:d}),u._LoadFromJson(_)}}for(const[y,L]of n){L.sort((e,t)=>e.siblingIndex-t.siblingIndex);for(const f of L){const p=f.layer,g=f.siblingIndex;let e=y.indexOf(p);y.splice(e,1),y.splice(g,0,p)}}}this._ReindexAndUpdateAllLayers(),this._SetAllLayersProjectionChanged(),this._SetAllLayersMVChanged()}GetILayout(){return this._iLayout}UserScriptDispatcher(){return this._userScriptDispatcher}DispatchUserScriptEvent(e){e.layout=this.GetILayout();const t=this._runtime,s=t.IsDebug()&&!t.GetEventSheetManager().IsInEventEngine();s&&C3Debugger.StartMeasuringScriptTime(),this._userScriptDispatcher.dispatchEvent(e),s&&C3Debugger.AddScriptTime()}DispatchUserScriptEventAsyncWait(e){return e.layout=this.GetILayout(),this._userScriptDispatcher.dispatchEventAndWaitAsync(e)}DispatchRuntimeUserScriptEventAsyncWait(e){return e.layout=this.GetILayout(),this._runtime.DispatchUserScriptEventAsyncWait(e)}_LogLayerTree(){this._LogLayerList(this._rootLayers)}_LogLayerList(e,t=0){const s=e.slice(0);s.reverse();for(const a of s)console.log("\t".repeat(t)+"- "+a.GetName()),this._LogLayerList(a.GetSubLayers(),t+1)}}; } // layouts/layoutManager.js { const C3=self.C3;C3.LayoutManager=class extends C3.DefendedBase{#runtime;#allLayouts=[];#layoutsByName=new Map;#layoutsBySid=new Map;#mainRunningLayout=null;#runningSubLayouts=[];#firstLayout=null;#isEndingLayout=0;#pendingChangeLayout=null;constructor(t){super(),this.#runtime=t}Release(){this.#runtime=null,this.#mainRunningLayout=null,this.#firstLayout=null,this.#pendingChangeLayout=null,C3.clearArray(this.#allLayouts),this.#layoutsByName.clear(),this.#layoutsBySid.clear(),C3.clearArray(this.#runningSubLayouts)}Create(t){const n=C3.New(C3.Layout,this,this.#allLayouts.length,t);this.#allLayouts.push(n),this.#layoutsByName.set(n.GetName().toLowerCase(),n),this.#layoutsBySid.set(n.GetSID(),n)}GetRuntime(){return this.#runtime}SetFirstLayout(t){this.#firstLayout=t}GetFirstLayout(){if(this.#firstLayout)return this.#firstLayout;if(this.#allLayouts.length)return this.#allLayouts[0];throw new Error("no first layout")}GetLayoutByName(t){return this.#layoutsByName.get(t.toLowerCase())||null}GetLayoutBySID(t){return this.#layoutsBySid.get(t)||null}GetLayoutByIndex(t){return t=C3.clamp(Math.floor(t),0,this.#allLayouts.length-1),this.#allLayouts[t]}GetLayout(t){return"number"==typeof t?this.GetLayoutByIndex(t):this.GetLayoutByName(t.toString())}GetAllLayouts(){return this.#allLayouts}_SetMainRunningLayout(t){this.#mainRunningLayout=t}GetMainRunningLayout(){return this.#mainRunningLayout}_AddRunningSubLayout(t){if(this.#runningSubLayouts.includes(t))throw new Error("layout already running");this.#runningSubLayouts.push(t)}_RemoveRunningSubLayout(t){const n=this.#runningSubLayouts.indexOf(t);if(-1===n)throw new Error("layout not running");this.#runningSubLayouts.splice(n,1)}*runningLayouts(){this.#mainRunningLayout&&(yield this.#mainRunningLayout),this.#runningSubLayouts.length&&(yield*this.#runningSubLayouts)}IsLayoutRunning(t){return this.#mainRunningLayout===t||this.#runningSubLayouts.includes(t)}SetIsEndingLayout(t){if(t)this.#isEndingLayout++;else{if(this.#isEndingLayout<=0)throw new Error("already unset");this.#isEndingLayout--}}IsEndingLayout(){return 0<this.#isEndingLayout}ChangeMainLayout(t){this.#pendingChangeLayout=t}ClearPendingChangeLayout(){this.#pendingChangeLayout=null}IsPendingChangeMainLayout(){return!!this.#pendingChangeLayout}GetPendingChangeMainLayout(){return this.#pendingChangeLayout}SetAllLayerProjectionChanged(){const t=this.GetMainRunningLayout();t&&t._SetAllLayersProjectionChanged()}SetAllLayerMVChanged(){const t=this.GetMainRunningLayout();t&&t._SetAllLayersMVChanged()}}; } // timelines/timelineManager.js { const C3=self.C3,NAMES_REGEXP=new RegExp("<(.+?)>","g");C3.TimelineManager=class extends C3.DefendedBase{constructor(e){super(),this._runtime=e,this._timelineDataManager=C3.New(C3.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();C3.clearArray(this._timelines),this._timelines=null,this._timelineDataManager.Release(),this._timelineDataManager=null,C3.clearArray(this._scheduledTimelines),this._scheduledTimelines=null,C3.clearArray(this._playingTimelines),this._playingTimelines=null,C3.clearArray(this._markedForRemovalTimelines),this._markedForRemovalTimelines=null,this._timelinesByName.clear(),this._timelinesByName=null,this._objectClassToTimelineMap.clear(),this._objectClassToTimelineMap=null,this._timelinesCreatedByTemplate.clear(),this._timelinesCreatedByTemplate=null,C3.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 i=C3.TimelineState.CreateInitial(e,this);this.Add(i),this.SetTimelineObjectClassesToMap(i),this._timelinesCreatedByTemplate.set(i.GetName(),0)}CreateFromTemplate(e){const i=this.GetTimelineDataManager(),t=e.GetTemplateName(),s=i.Get(t),n=C3.TimelineState.CreateFromTemplate(t+":"+this._timelinesCreatedByTemplate.get(t),s,this);return this._IncreaseTemplateTimelinesCount(t),this.Add(n),n}_IncreaseTemplateTimelinesCount(e){this._timelinesCreatedByTemplate.set(e,this._timelinesCreatedByTemplate.get(e)+1)}_SetCreatedTemplateTimelinesCount(){for(const e of this._timelines)if(!e.IsTemplate()){const i=e.GetTemplateName();this._IncreaseTemplateTimelinesCount(i)}}_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()||(C3.arrayFindRemove(this._timelines,e),C3.arrayFindRemove(this._scheduledTimelines,e),C3.arrayFindRemove(this._playingTimelines,e),C3.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,i){this._objectClassToTimelineMap.has(e)||this._objectClassToTimelineMap.set(e,new Set),this._objectClassToTimelineMap.get(e).add(i)}SetTimelineObjectClassesToMap(e){for(const i of e.GetObjectClasses())this.SetTimelineObjectClassToMap(i,e)}RemoveTimelineFromObjectClassMap(e){for(const[i,t]of this._objectClassToTimelineMap.entries())t.has(e)&&(t.delete(e),0===t.size)&&this._objectClassToTimelineMap.delete(i)}GetTimelinesForObjectClass(e){if(this._objectClassToTimelineMap.has(e))return this._objectClassToTimelineMap.get(e)}GetTimelineOfTemplateForInstances(e,i){if(i)for(const t of this._timelines){const s=i.every(e=>t.HasTrackInstance(e.instance,e.trackId));if(s&&t.GetName().includes(e.GetName()))return t}}GetTimelineByName(e){return this._timelinesByName.get(e.toLowerCase())||null}GetScheduledOrPlayingTimelineByName(e){for(const i of this._scheduledTimelines)if(i.GetName()===e)return i;for(const t of this._playingTimelines)if(t.GetName()===e)return t;return null}*GetTimelinesByName(i){if(NAMES_REGEXP.test(i)){NAMES_REGEXP.lastIndex=0;let e;const t=new Set;do{if(e=NAMES_REGEXP.exec(i)){const s=e[1].split(",");for(const i of s)t.add(i)}}while(e);for(const i of t.values()){const n=this.GetTimelineByName(i);n&&(yield n)}t.clear()}else{const e=this.GetTimelineByName(i);e&&(yield e)}}*GetTimelinesByTags(e){for(const i of this._timelines)i.HasTags(e)&&(yield i)}AddScheduledTimeline(e){this._scheduledTimelines.includes(e)||this._scheduledTimelines.push(e),this._MaybeEnableRuntimeListeners()}RemovePlayingTimeline(e){C3.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(),C3.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),C3.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),C3.arrayFindRemove(this._playingTimelines,e)}CompleteTimelineAndResolve(e){this.CompleteTimeline(e),e.ResolvePlayPromise()}_OnTick(){if(!this.GetRuntime().IsLoadingState()&&this._hasRuntimeListeners&&!this._changingLayout){for(this._isTickingTimelines=!0;this._scheduledTimelines.length;){const e=this._scheduledTimelines.pop();(e.IsMarkedForRemoval()?(e.SetInitialStateForce(),this._markedForRemovalTimelines):(e.SetInitialState(),this._playingTimelines)).push(e),0!==e.GetRenderChange()&&(this._renderChange=1)}const i=this._runtime._GetDtFast(),t=this._runtime.GetDt1(),s=this._runtime.GetTimeScale();for(let e=this._playingTimelines.length-1;0<=e;e--){const n=this._playingTimelines[e];n&&n.Tick(i,s,t)}this._isTickingTimelines=!1,0!==this._renderChange&&this.GetRuntime().UpdateRender()}}_OnTick2(){if(!this.GetRuntime().IsLoadingState()&&this._hasRuntimeListeners&&!this._changingLayout){let t;for(let e=0,i=this._markedForRemovalTimelines.length;e<i;e++){const s=this._markedForRemovalTimelines[e];t=t||new Set,s.Removed(),this._MaybeExecuteTimelineFinishTriggers(s),t.add(s)}if(t){C3.arrayRemoveAllInSet(this._markedForRemovalTimelines,t);for(let e=this._renderChange=0,i=this._playingTimelines.length;e<i;e++)if(0!==this._playingTimelines[e].GetRenderChange()){this._renderChange=1;break}}this._MaybeDisableRuntimeListeners()}}_MaybeExecuteTimelineFinishTriggers(e){e.IsReleased()||e.HasValidTracks()&&e.IsComplete()&&e.InitialStateSet()&&e.FinishTriggers()}_MaybeEnableRuntimeListeners(){this._hasRuntimeListeners||(this._hasRuntimeListeners=!0)}_MaybeDisableRuntimeListeners(){this._markedForRemovalTimelines.length||this._playingTimelines.length||this._scheduledTimelines.length||this._isTickingTimelines||(this._hasRuntimeListeners=!1)}_OnBeforeChangeLayout(){for(this._changingLayout=!0;this._scheduledTimelines.length;)this.DeScheduleTimeline(this._scheduledTimelines.pop());const e=new Set;for(const i of this._playingTimelines){const t=i._OnBeforeChangeLayout();t&&(i.Removed(),e.add(i))}C3.arrayRemoveAllInSet(this._playingTimelines,e),e.clear();for(const s of this._markedForRemovalTimelines){const n=s._OnBeforeChangeLayout();n&&(s.Removed(),e.add(s))}C3.arrayRemoveAllInSet(this._markedForRemovalTimelines,e),this._MaybeDisableRuntimeListeners();for(const a of this._timelines)a.CleanCaches()}_OnAfterChangeLayout(){this._changingLayout=!1}_OnInstanceDestroy(e){const i=e.GetObjectClass(),t=this.GetTimelinesForObjectClass(i);if(t)if(this._runtime.IsLoadingState())this._destroyedWhileLoadingState.push(e);else for(const s of t)s.IsTemplate()||(s.IsReleased()?this.Remove(s):s.HasValidTracks()||(this._MaybeExecuteTimelineFinishTriggers(s),this.Remove(s)))}_OnBeforeLoad(){for(const e of this._scheduledTimelines.map(e=>e))this._MaybeExecuteTimelineFinishTriggers(e),this.Remove(e);for(const i of this._playingTimelines.map(e=>e))this._MaybeExecuteTimelineFinishTriggers(i),this.Remove(i)}_OnAfterLoad(){for(const e of this._destroyedWhileLoadingState)this._OnInstanceDestroy(e);C3.clearArray(this._destroyedWhileLoadingState);for(const i of this._timelines)i._OnAfterLoad()}_OnAfterLayoutStart(){const e=this._runtime.GetLayoutManager(),i=e.GetMainRunningLayout();if(i)for(const t of this._timelines){const s=t.GetStartOnLayout();s&&i.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 i of e){let e=this.GetTimelineByName(i["name"]);if(e)e._LoadFromJson(i);else{const t=this._GetTemplateNameFromJson(i);if(!t)continue;const s=this.GetTimelineByName(t);(e=this.CreateFromTemplate(s))._LoadFromJson(i)}e.HasTracks()||this.Remove(e)}}_GetTemplateNameFromJson(e){const i=e["name"],t=i.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,i){if(i)for(const t of i)if(t===e.GetName())return!0;return!1}_SaveTimelines(e){return e.map(e=>e.GetName())}_LoadTimelines(e,i){const t=new Set;for(const s of i)this._IsTimelineInJson(s,e)||t.add(s);if(C3.arrayRemoveAllInSet(i,t),e)for(const n of e){const a=this.GetTimelineByName(n);if(a){const l=i.find((i=>e=>e.GetName()===i)(n));l||i.push(a)}}}}; } // timelines/timelineInfo.js { const C3=self.C3,STEPS=100,LENGTH_STEP_SIZE=.01,BEZIER_STEP_SIZE=25,REFINE_ITERATIONS=20,LOOKUP_STEPS_FROM_LAST=5,TANGENT_RESULT=[0,0],MAP_RESULT=[0,0],SHORT_PROJECTION_RESULT=[0,0],PROJECTION_RESULT=[0,0,0,0,0],REFINE_LUT=new Array(4),REFINE_LUT_OBJECTS=[{x:0,y:0,t:0,distance:0},{x:0,y:0,t:0,distance:0},{x:0,y:0,t:0,distance:0}],REFINE_RESULT={x:0,y:0,t:0,distance:0};C3.TimelineInfo=class{constructor(t,i){this._initialized=!1,this._timeline=t,this._segments=[];let e=null;if(e=i?this._timeline.GetTrackById(i):C3.first(this._timeline.GetTracks())){const s=e.GetPropertyTrack("offsetX"),_=e.GetPropertyTrack("offsetY");if(s&&_){this._xTrack=s,this._yTrack=_;const h=s.GetPropertyKeyframeDataItemArrayIncludingDisabled(),n=_.GetPropertyKeyframeDataItemArrayIncludingDisabled();for(let t=1,i=Math.min(h.length,n.length);t<i;++t){const r=h[t],a=(r.GetNext(),r.GetPrevious()),c=n[t],l=(c.GetNext(),c.GetPrevious());a&&"cubic-bezier"===a.GetPathMode()&&l&&"cubic-bezier"===l.GetPathMode()?this._segments.push(C3.New(C3.TimelineCubicBezierSegmentInfo,a,l,r,c,this._segments.length)):(a&&"line"===a.GetPathMode()&&l&&l.GetPathMode(),this._segments.push(C3.New(C3.TimelineLineSegmentInfo,r,c,this._segments.length)))}this._initialized=!0}}}Release(){for(const t of this._segments)t.Release();C3.clearArray(this._segments),this._segments=null,this._timeline=null,this._xTrack=null,this._yTrack=null}WasInitialized(){return this._initialized}segments(){return this._segments}SetOrigin(t){const i="relative"===this._xTrack.GetResultMode()?t.GetX():0,e="relative"===this._yTrack.GetResultMode()?t.GetY():0;for(const s of this._segments)s.SetOrigin(i,e)}Project(i,e,t){let s=NaN,_=this._segments.length;for(let t=0;t<_;t++){const h=this._segments[t];if("cubic-bezier"===h.GetType()){const n=h.Project(i,e);(isNaN(s)||n[3]<s)&&(s=n[3],SHORT_PROJECTION_RESULT[0]=n[2],SHORT_PROJECTION_RESULT[1]=h.GetIndex())}}return SHORT_PROJECTION_RESULT}ProjectWithOptions(i,e,t){const s=t.tRange;C3.IsFiniteNumber(s[0])||(s[0]=0),C3.IsFiniteNumber(s[1])||(s[1]=1);let _=NaN,h=this._segments.length;for(let t=0;t<h;t++){const n=this._segments[t];if("cubic-bezier"===n.GetType()){const r=n.ProjectWithRange(i,e,s);(isNaN(_)||r[3]<_)&&(_=r[3],SHORT_PROJECTION_RESULT[0]=r[2],SHORT_PROJECTION_RESULT[1]=n.GetIndex())}}return SHORT_PROJECTION_RESULT}Tangent(t,i){return this._segments[i].Tangent(t)}TangentAngle(t,i){return this._segments[i].TangentAngle(t)}},C3.TimelineCubicBezierSegmentInfo=class{constructor(t,i,e,s,_){this._index=_;const h=t.GetAddOn("cubic-bezier"),n=e.GetAddOn("cubic-bezier"),r=i.GetAddOn("cubic-bezier"),a=s.GetAddOn("cubic-bezier");this._aX=t.GetValueWithResultMode(),this._aY=i.GetValueWithResultMode(),this._bX=t.GetValueWithResultMode()+h.GetStartAnchor(),this._bY=i.GetValueWithResultMode()+r.GetStartAnchor(),this._cX=e.GetValueWithResultMode()+n.GetEndAnchor(),this._cY=s.GetValueWithResultMode()+a.GetEndAnchor(),this._dX=e.GetValueWithResultMode(),this._dY=s.GetValueWithResultMode(),this._aXO=0,this._aYO=0,this._bXO=0,this._bYO=0,this._cXO=0,this._cYO=0,this._dXO=0,this._dYO=0,this._d0x=0,this._d0y=0,this._d1x=0,this._d1y=0,this._d2x=0,this._d2y=0,this._x1Factor=0,this._x2Factor=0,this._x3Factor=0,this._y1Factor=0,this._y2Factor=0,this._y3Factor=0,this._lutIndex=NaN,this._initialized=!1,this._len=STEPS,this._arcLengths=new Array(this._len+1),this._arcLengths[0]=0,this._length=0,this._lut=[],this._lutObjects=[];for(let t=0;t<STEPS;t++)this._lutObjects.push({x:0,y:0,t:0,distance:0});this._CalculateLength()}Release(){C3.clearArray(this._arcLengths),this._arcLengths=null,C3.clearArray(this._lut),this._lut=null,C3.clearArray(this._lutObjects),this._lutObjects=null}GetType(){return"cubic-bezier"}GetIndex(){return this._index}GetStepCount(){return Math.floor(this._length/BEZIER_STEP_SIZE)}GetStepIncrement(){return 1/this.GetStepCount()}SetOrigin(t,i){this._originX=t,this._originY=i,this._arcLengths=new Array(this._len+1),this._arcLengths[0]=0,this._CalculateLength(),this._aXO=this._aX+this._originX,this._aYO=this._aY+this._originY,this._bXO=this._bX+this._originX,this._bYO=this._bY+this._originY,this._cXO=this._cX+this._originX,this._cYO=this._cY+this._originY,this._dXO=this._dX+this._originX,this._dYO=this._dY+this._originY,this._d0x=3*(this._bXO-this._aXO),this._d0y=3*(this._bYO-this._aYO),this._d1x=3*(this._cXO-this._bXO),this._d1y=3*(this._cYO-this._bYO),this._d2x=3*(this._dXO-this._cXO),this._d2y=3*(this._dYO-this._cYO),this._x1Factor=3*(this._bXO-this._aXO),this._x2Factor=3*(this._aXO+this._cXO-2*this._bXO),this._x3Factor=this._dXO-this._aXO+3*(this._bXO-this._cXO),this._y1Factor=3*(this._bYO-this._aYO),this._y2Factor=3*(this._aYO+this._cYO-2*this._bYO),this._y3Factor=this._dYO-this._aYO+3*(this._bYO-this._cYO)}Map(t){if(!this._initialized)return NaN;const i=this._Map(t);return MAP_RESULT[0]=this._X(i),MAP_RESULT[1]=this._Y(i),MAP_RESULT}Project(t,i){const e=this._GenerateLUT(STEPS),s=this._FindClosestFromLUT(t,i,e),_=this._RefineProjection(t,i,e,s);return PROJECTION_RESULT[0]=_.x,PROJECTION_RESULT[1]=_.y,PROJECTION_RESULT[2]=_.t,PROJECTION_RESULT[3]=_.distance,PROJECTION_RESULT}ProjectWithRange(t,i,e){const s=this._GenerateLUT(STEPS),_=this._FindClosestFromLUTWithRange(t,i,s,e),h=this._RefineProjection(t,i,s,_);return PROJECTION_RESULT[0]=h.x,PROJECTION_RESULT[1]=h.y,PROJECTION_RESULT[2]=h.t,PROJECTION_RESULT[3]=h.distance,PROJECTION_RESULT}Tangent(t){const i=1-t,e=i*i,s=2*i*t,_=t*t,h=e*this._d0x+s*this._d1x+_*this._d2x,n=e*this._d0y+s*this._d1y+_*this._d2y,r=C3.hypot2DFast(h,n);return TANGENT_RESULT[0]=h/r,TANGENT_RESULT[1]=n/r,TANGENT_RESULT}TangentAngle(t){const i=1-t,e=i*i,s=2*i*t,_=t*t,h=e*this._d0x+s*this._d1x+_*this._d2x,n=e*this._d0y+s*this._d1y+_*this._d2y;return Math.atan2(n,h)}_Map(_){if(this._initialized){let t=_*this._arcLengths[this._len],i=0,e=this._len,s=0;for(;i<e;)s=i+((e-i)/2|0),this._arcLengths[s]<t?i=s+1:e=s;this._arcLengths[s]>t&&s--;const h=this._arcLengths[s];return h===t?s/this._len:(s+(t-h)/(this._arcLengths[s+1]-h))/this._len}}_X(t){return this._initialized?self.Ease.GetRuntimeEase("cubicbezier")(t,this._aX+this._originX,this._bX+this._originX,this._cX+this._originX,this._dX+this._originX):NaN}_Y(t){return this._initialized?self.Ease.GetRuntimeEase("cubicbezier")(t,this._aY+this._originY,this._bY+this._originY,this._cY+this._originY,this._dY+this._originY):NaN}_GenerateLUT(i){if(i=i||STEPS,!(this._lut.length>=i)){this._lut=new Array(i),i++;for(let t=0;t<i-1;t++){const e=t/(i-1),s=e**2,_=e**3,h=this._x1Factor*e,n=this._x2Factor*s,r=this._x3Factor*_,a=this._y1Factor*e,c=this._y2Factor*s,l=this._y3Factor*_,o=this._aXO+h+n+r,T=this._aYO+a+c+l;this._lutObjects[t].x=o,this._lutObjects[t].y=T,this._lutObjects[t].t=e,this._lutObjects[t].distance=0,this._lut[t]=this._lutObjects[t]}}return this._lut}_FindClosestFromLUT(i,e,s,t=0,_=Number.MAX_SAFE_INTEGER){let h=0;if(isNaN(this._lutIndex))for(let t=0;t<STEPS;t++){const n=s[t],r=n.x-i,a=n.y-e;n.distance=r*r+a*a,n.distance<_&&(_=n.distance,h=t)}else{for(let t=this._lutIndex;t<this._lutIndex+LOOKUP_STEPS_FROM_LAST&&!(t>=s.length);t++){const c=s[t],l=c.x-i,o=c.y-e;c.distance=l*l+o*o,c.distance<_&&(_=c.distance,h=t)}for(let t=this._lutIndex;t>this._lutIndex-LOOKUP_STEPS_FROM_LAST&&!(t<0);t--){const T=s[t],d=T.x-i,E=T.y-e;T.distance=d*d+E*E,T.distance<_&&(_=T.distance,h=t)}}return this._lutIndex=h}_FindClosestFromLUTWithRange(i,e,s,_,h=Number.MAX_SAFE_INTEGER){let n=0;if(isNaN(this._lutIndex))for(let t=0;t<STEPS;t++){const r=s[t],a=r.x-i,c=r.y-e;r.distance=a*a+c*c,r.t>=_[0]&&r.t<=_[1]&&r.distance<h&&(h=r.distance,n=t)}else{for(let t=this._lutIndex;t<this._lutIndex+LOOKUP_STEPS_FROM_LAST&&!(t>=s.length);t++){const l=s[t],o=l.x-i,T=l.y-e;l.distance=o*o+T*T,l.t>=_[0]&&l.t<=_[1]&&l.distance<h&&(h=l.distance,n=t)}for(let t=this._lutIndex;t>this._lutIndex-LOOKUP_STEPS_FROM_LAST&&!(t<0);t--){const d=s[t],E=d.x-i,O=d.y-e;d.distance=E*E+O*O,d.t>=_[0]&&d.t<=_[1]&&d.distance<h&&(h=d.distance,n=t)}}return this._lutIndex=n}_RefineProjection(h,n,r,a){let c=r[a],t=1,l=Number.MAX_SAFE_INTEGER;t:do{const o=r.length;let t=0===a?0:a-1,i=a===o-1?o-1:a+1,e=r[t].t,s=r[i].t,_=(s-e)/4;if(_<.001)break;REFINE_LUT[0]=r[t];for(let t=1;t<=2;t++){const T=e+t*_,d=T**2,E=T**3,O=this._x1Factor*T,u=this._x2Factor*d,R=this._x3Factor*E,S=this._y1Factor*T,g=this._y2Factor*d,I=this._y3Factor*E,N=this._aXO+O+u+R,L=this._aYO+S+g+I,x=N-h,y=L-n,G=x*x+y*y;if(G<l){l=G,a=t,REFINE_RESULT.x=N,REFINE_RESULT.y=L,REFINE_RESULT.t=T,REFINE_RESULT.distance=G,c=REFINE_RESULT;break t}const P=REFINE_LUT_OBJECTS[t-1];P.x=N,P.y=L,P.t=T,P.distance=G,REFINE_LUT[t]=P}REFINE_LUT[3]=r[i],r=REFINE_LUT}while(t++<REFINE_ITERATIONS);return c}_CalculateLength(){this._initialized=!0;let i=this._X(0),e=this._Y(0),s=0;for(let t=1;t<=this._len;t++){const _=this._X(t*LENGTH_STEP_SIZE),h=this._Y(t*LENGTH_STEP_SIZE),n=i-_,r=e-h;s+=C3.hypot2DFast(n,r),this._arcLengths[t]=s,i=_,e=h}this._length=s}},C3.TimelineLineSegmentInfo=class{constructor(t,i,e){this._index=e,this._targetX=t.GetValueWithResultMode(),this._targetY=i.GetValueWithResultMode(),this._originX=0,this._originY=0}Release(){}GetType(){return"line"}GetIndex(){return this._index}SetOrigin(t,i){this._originX=t,this._originY=i}GetX(){return this._targetX+this._originX}GetY(){return this._targetY+this._originY}}; } // timelines/state/timelineState.js { const C3=self.C3,PING_PONG_BEGIN=0,PING_PONG_END=1;C3.TimelineState=class extends C3.DefendedBase{constructor(e,t,i){super(),this._runtime=i.GetRuntime(),this._timelineManager=i,this._timelineDataItem=t,this._name=e,this._tracks=[],this._tracksLength=0,this._beforeAndAfterTracks=null,this._beforeAndAfterTracksLength=0,this.CreateTrackStates(),this._playPromise=null,this._playResolve=null,this._playheadTime=0,this._overshoot=0,this._playbackRate=1,this._pingPongState=PING_PONG_BEGIN,this._currentRepeatCount=1,this._isPlaying=!1,this._isScheduled=!1,this._initialStateSet=!1,this._complete=!0,this._released=!1,this._markedForRemoval=!1,this._completedTick=-1,this._implicitPause=!1,this._isTemplate=!1,this._finishedTriggers=!1,this._firstTick=!1,this._lastDelta=NaN,this._tags=[""],this._stringTags="",this._tagsChanged=!1,this._renderChange=0,this._hasNestedContent=0,this._iTimelineState=null}static CreateInitial(e,t){const i=t.GetTimelineDataManager(),s=i.GetNameId(),a=i.Get(e[s]),n=C3.New(C3.TimelineState,e[s],a,t);return n.SetIsTemplate(!0),n}static CreateFromTemplate(e,t,i){return C3.New(C3.TimelineState,e,t,i)}Release(){if(!this.IsReleased()){const e=this._runtime.Dispatcher();this._timelineManager.DeScheduleTimeline(this),this._timelineManager.CompleteTimelineAndResolve(this);for(const t of this._tracks)t.Release();C3.clearArray(this._tracks),this._tracks=null,this._runtime=null,this._timelineManager=null,this._timelineDataItem=null,this._released=!0,this._playPromise=null,this._playResolve=null,this.FireReleaseEvent(e)}}FireReleaseEvent(e){const t=C3.New(C3.Event,"timelinestatereleased");t.timelineState=this,e.dispatchEvent(t)}GetType(){return 0}CreateTrackStates(){for(const e of this._timelineDataItem.GetTrackData().trackDataItems())this._tracksLength=this._tracks.push(C3.TrackState.Create(this,e))}GetTimelineManager(){return this._timelineManager}GetRuntime(){return this._runtime}GetTracks(){return this._tracks}GetSimilarPropertyTracks(s,a,n,r){if(this._hasNestedContent){let i;for(let t=0;t<this._tracks.length;t++){let e=this._tracks[t];if(s===e.GetInstance()){const h=e.GetPropertyTrack(n);h&&a.constructor===h.GetSourceAdapter().constructor&&h.GetResultMode()===r.GetResultMode()&&(i=i||[]).push(h)}}return i}}HasTracks(){return!!this._tracks.length}GetTrackById(e){for(const t of this._tracks)if(C3.equalsNoCase(t.GetId(),e))return t;return null}GetTrackByName(e){for(const t of this._tracks)if(!t.IsInstanceTrack()&&C3.equalsNoCase(t.GetName(),e))return t;return null}SetName(e){this._name=e}GetName(){return this._name}GetTimelineDataItem(){return this._timelineDataItem}GetTemplateName(){return this._timelineDataItem.GetName()}GetTotalTime(){return this._timelineDataItem.GetTotalTime()}SetTotalTime(e){this._timelineDataItem.SetTotalTime(e)}GetStep(){return this._timelineDataItem.GetStep()}SetStep(e){this._timelineDataItem.SetStep(e)}GetInterpolationMode(){return this._timelineDataItem.GetInterpolationMode()}SetInterpolationMode(e){this._timelineDataItem.SetInterpolationMode(e)}GetResultMode(){return this._timelineDataItem.GetResultMode()}SetResultMode(e){this._timelineDataItem.GetResultMode(e)}SetEase(e){for(const t of this.GetTracks())t.SetEase(e)}GetLoop(){return this._timelineDataItem.GetLoop()}SetLoop(e){return this._timelineDataItem.SetLoop(e)}GetPingPong(){return this._timelineDataItem.GetPingPong()}SetPingPong(e){return this._timelineDataItem.SetPingPong(e)}GetRepeatCount(){return this._timelineDataItem.GetRepeatCount()}SetRepeatCount(e){return this._timelineDataItem.SetRepeatCount(e)}SetPlaybackRate(e){return this._playbackRate=e}GetPlaybackRate(){return this._playbackRate}GetStartOnLayout(){return this._timelineDataItem.GetStartOnLayout()}GetTransformWithSceneGraph(){return this._timelineDataItem.GetTransformWithSceneGraph()}GetUseSystemTimescale(){return this._timelineDataItem.GetUseSystemTimescale()}GetPingPongState(){return this._pingPongState}IsForwardPlayBack(){return!this.IsPlaying()||0<this._playbackRate}GetPlayPromise(){return this._playPromise||(this._playPromise=new Promise(e=>{this._playResolve=e})),this._playPromise}ResolvePlayPromise(){this._playPromise&&(this._playResolve(),this._playPromise=null,this._playResolve=null)}SetTags(e){this._tags=C3.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=C3.TimelineState._GetTagArray(e);return!!t&&!!t.length&&t.every(C3.TimelineState._HasTag,this)}OnStarted(){C3.Plugins.Timeline&&this.constructor===C3.TimelineState&&(C3.Plugins.Timeline.Cnds.PushTriggerTimeline(this),this._timelineManager.Trigger(C3.Plugins.Timeline.Cnds.OnTimelineStarted),this._timelineManager.Trigger(C3.Plugins.Timeline.Cnds.OnTimelineStartedByName),this._timelineManager.Trigger(C3.Plugins.Timeline.Cnds.OnTimelineStartedByTags),this._timelineManager.Trigger(C3.Plugins.Timeline.Cnds.OnAnyTimelineStarted),C3.Plugins.Timeline.Cnds.PopTriggerTimeline())}OnCompleted(){this._completedTick=this._runtime.GetTickCount()}FinishTriggers(){this._finishedTriggers||(this._finishedTriggers=!0,C3.Plugins.Timeline&&this.constructor===C3.TimelineState&&(C3.Plugins.Timeline.Cnds.PushTriggerTimeline(this),this._timelineManager.Trigger(C3.Plugins.Timeline.Cnds.OnTimelineFinished),this._timelineManager.Trigger(C3.Plugins.Timeline.Cnds.OnTimelineFinishedByName),this._timelineManager.Trigger(C3.Plugins.Timeline.Cnds.OnTimelineFinishedByTags),this._timelineManager.Trigger(C3.Plugins.Timeline.Cnds.OnAnyTimelineFinished),C3.Plugins.Timeline.Cnds.PopTriggerTimeline()))}SetPlaying(e){this._isPlaying=e}IsCompletedTick(){return this._completedTick===this._runtime.GetTickCount()}IsPlaying(e=!1){return!!this.IsCompletedTick()||!(!this.IsScheduled()||e)||this._isPlaying}_IsPlaying(){return this.IsPlaying(!0)}IsPaused(){return this._IsPaused()}_IsPaused(){return!(this.IsReleased()||this.IsScheduled()||this._IsPlaying()||this.IsComplete())}SetScheduled(e){this._isScheduled=e}IsScheduled(){return this._isScheduled}SetComplete(e){this._complete=e;const t=this.GetTime();(t<=0||t>=this.GetTotalTime())&&(this._complete=!0)}IsComplete(){return this._complete}IsReleased(){return this._released}SetMarkedForRemoval(e){this._markedForRemoval=e}IsMarkedForRemoval(){return this._markedForRemoval}SetImplicitPause(e){this._implicitPause=e}IsImplicitPause(){return this._implicitPause}SetIsTemplate(e){this._isTemplate=!!e}IsTemplate(){return this._isTemplate}InitialStateSet(){return this._initialStateSet}GetTime(){return this._playheadTime}SetTime(e){const t=this.GetTime();this._SetTime(e),this.SetComplete(!1),this.IsComplete()||this.SetImplicitPause(!0),!this._IsPlaying()&&!this.IsScheduled()&&this._initialStateSet||(this._IsPlaying()||this.IsScheduled()||this._initialStateSet?this._IsPlaying()?this.Stop():this.IsScheduled()&&(this._timelineManager.DeScheduleTimeline(this),this.SetInitialStateFromSetTime()):this.SetInitialStateFromSetTime()),this._SetUpdateStateBefore(),this._Interpolate(this.GetTime(),!1,!0,!0,t),this._SetUpdateStateAfter(),this._renderChange&&this.GetRuntime().UpdateRender(),this._OnSetTime()}_SetTime(e){(e=C3.IsFiniteNumber(e)?e:this.GetTotalTime())<0?this._playheadTime=0:e>=this.GetTotalTime()?this._playheadTime=this.GetTotalTime():this._playheadTime=e}_SetTimeAndReset(e){(e=C3.IsFiniteNumber(e)?e:this.GetTotalTime())<0?this._playheadTime=0:e>=this.GetTotalTime()?this._playheadTime=this.GetTotalTime():this._playheadTime=e;for(const t of this._tracks)t.SetResetState()}_OnSetTime(){C3.Plugins.Timeline&&this.constructor===C3.TimelineState&&(C3.Plugins.Timeline.Cnds.PushTriggerTimeline(this),this._timelineManager.Trigger(C3.Plugins.Timeline.Cnds.OnTimeSet),this._timelineManager.Trigger(C3.Plugins.Timeline.Cnds.OnTimeSetByName),this._timelineManager.Trigger(C3.Plugins.Timeline.Cnds.OnTimeSetByTags),C3.Plugins.Timeline.Cnds.PopTriggerTimeline())}_CanResume(){if(!this.GetLoop())if(this.GetPingPong()&&this._pingPongState===PING_PONG_END){if(this.IsForwardPlayBack()){if(this.GetTime()>=this.GetTotalTime())return!1}else if(this.GetTime()<=0)return!1}else if(!this.GetLoop()&&!this.GetPingPong())if(this.IsForwardPlayBack()){if(this.GetTime()>=this.GetTotalTime())return!1}else if(this.GetTime()<=0)return!1;return!0}Resume(){this.IsReleased()||this._CanResume()&&this.Play(!0)}Play(e=!1){return!this.IsReleased()&&!this.IsScheduled()&&(this._IsPlaying()&&this.IsCompletedTick()?this._SchedulePlayingTimeline():!this._IsPlaying()&&!!(this.IsComplete()||e||this.IsImplicitPause())&&this._ScheduleStoppedTimeline())}_SchedulePlayingTimeline(){return this.SetImplicitPause(!1),this._timelineManager.RemovePlayingTimeline(this),this._timelineManager.ScheduleTimeline(this),this.GetPlayPromise(),!0}_ScheduleStoppedTimeline(){return this.SetImplicitPause(!1),this._timelineManager.ScheduleTimeline(this),this.GetPlayPromise(),!0}Stop(e=!1){this.IsReleased()||(this.SetComplete(e),this._timelineManager.CompleteTimeline(this),this.IsComplete()&&this.ResolvePlayPromise())}Reset(e=!0,t=!1){if(!this.IsReleased()){if(!this._IsPlaying()&&this.IsScheduled())return this._timelineManager.DeScheduleTimeline(this);if(!this.IsComplete()){this.Stop(!0),this.IsForwardPlayBack()?this._SetTime(0):this._SetTime(this.GetTotalTime());const i=this.GetTime();this._SetUpdateStateBefore(),t?this._InterpolateBeforeChangeLayout(i):this._Interpolate(i,!1,!1,!0),e&&this._OnSetTime(),this._SetUpdateStateAfter(),this._renderChange&&e&&this.GetRuntime().UpdateRender()}}}ResetBeforeChangeLayout(){this.Reset(!1,!0)}_InterpolateBeforeChangeLayout(e){this._Interpolate(e,!1,!1,!0,NaN,!1,!0)}_OnBeforeChangeLayout(){if(!this.IsReleased()){if(!this.GetRuntime().IsLoadingState()&&this.HasValidGlobalTracks())return!1;this._timelineManager.CompleteTimelineBeforeChangeOfLayout(this),this.GetRuntime().IsLoadingState()||this.ResetBeforeChangeLayout()}return!0}SetInitialStateFromSetTime(){this.SetInitialState(!0)}SetInitialStateForce(){this.SetInitialState(!1,!0),this.SetPlaying(!1),this.SetScheduled(!1)}SetInitialState(e=!1,t=!1){if(!this.IsMarkedForRemoval()||t){if(e){this._finishedTriggers=!1,this._initialStateSet=!0,this._firstTick=!0,this._SetUpdateStateBefore();for(const i of this._tracks)i.SetInitialState()}else if(this.SetPlaying(!0),this.SetScheduled(!1),this.OnStarted(),this.IsComplete()){this._completedTick=-1,this._pingPongState!==PING_PONG_BEGIN&&(this._playbackRate=Math.abs(this._playbackRate)),this._pingPongState=PING_PONG_BEGIN,this._currentRepeatCount=1,this._complete=!1,this._finishedTriggers=!1,this._initialStateSet=!0,this._firstTick=!0,this.IsForwardPlayBack()?this._SetTime(0):this._SetTime(this.GetTotalTime()),this._SetUpdateStateBefore();for(const s of this._tracks)s.SetInitialState()}else{this._firstTick=!0,this._finishedTriggers=!1,this._SetUpdateStateBefore();for(const a of this._tracks)a.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,i){if(this.GetUseSystemTimescale()){if(0===e&&0===this._lastDelta)return;this._lastDelta=e,e=i}else{if(0===i&&0===this._lastDelta)return;e=this._lastDelta=i,t=1}const s=this._playheadTime+this._overshoot,a=e*t*this._playbackRate,n=s+a,r=this._timelineDataItem._totalTime;n<0?(this._playheadTime=0,this._overshoot=-n):r<=n?(this._playheadTime=r,this._overshoot=this._playheadTime-n):(this._playheadTime=n,this._overshoot=0);let h=!1,l=!1;const o=this.GetLoop(),_=this.GetPingPong();o||_?o&&!_?0<this._playbackRate?this._playheadTime>=r&&(this._SetTimeAndReset(0),l=!0):this._playheadTime<=0&&(this._SetTimeAndReset(r),l=!0):!o&&_?0<this._playbackRate?this._playheadTime>=r&&(this._SetTime(r),this.SetPlaybackRate(-1*this.GetPlaybackRate()),l=!0,this._pingPongState===PING_PONG_END?this._currentRepeatCount<this.GetRepeatCount()?(this._currentRepeatCount++,this._pingPongState=PING_PONG_BEGIN):h=!0:this._pingPongState===PING_PONG_BEGIN&&(this._pingPongState=PING_PONG_END)):this._playheadTime<=0&&(this._SetTime(0),this.SetPlaybackRate(-1*this.GetPlaybackRate()),l=!0,this._pingPongState===PING_PONG_END?this._currentRepeatCount<this.GetRepeatCount()?(this._currentRepeatCount++,this._pingPongState=PING_PONG_BEGIN):h=!0:this._pingPongState===PING_PONG_BEGIN&&(this._pingPongState=PING_PONG_END)):o&&_&&(0<this._playbackRate?this._playheadTime>=r&&(this._SetTime(r),this.SetPlaybackRate(-1*this.GetPlaybackRate()),l=!0,this._pingPongState++,C3.wrap(this._pingPongState,0,2)):this._playheadTime<=0&&(this._SetTime(0),this.SetPlaybackRate(-1*this.GetPlaybackRate()),l=!0,this._pingPongState++,C3.wrap(this._pingPongState,0,2))):0<this._playbackRate?this._playheadTime>=r&&(this._currentRepeatCount<this.GetRepeatCount()?(this._currentRepeatCount++,this._SetTimeAndReset(0),l=!0):(this._SetTime(r),h=!0)):this._playheadTime<=0&&(this._currentRepeatCount<this.GetRepeatCount()?(this._currentRepeatCount++,this._SetTimeAndReset(r),l=!0):(this._SetTime(0),h=!0));let m;const c=this._tracksLength;if(h){for(m=0;m<c;m++)this._tracks[m].SetEndState();this.Stop(!0),this.OnCompleted()}else{const T=this._beforeAndAfterTracksLength;for(m=0;m<T;m++)this._beforeAndAfterTracks[m].BeforeInterpolate();if(1===this._hasNestedContent)for(m=0;m<c;m++){const g=this._tracks[m],d=g.GetStartOffset(),u=this._playheadTime-d,S=s-d;u<0&&0<S?(this._playheadTime=d<0?0:r<=d?r:d,g.Interpolate(d,!0,!1,l,this._firstTick,!1)):g.Interpolate(this._playheadTime,!0,!1,l,this._firstTick,!1)}else for(m=0;m<c;m++)this._tracks[m].Interpolate(this._playheadTime,!0,!1,l,this._firstTick,!1);for(m=0;m<T;m++)this._beforeAndAfterTracks[m].AfterInterpolate();this._firstTick&&(this._firstTick=!1)}}_Interpolate(t,i=!1,s=!1,a=!1,n=NaN,e=!1,r=!1){for(const h of this._tracks)h.BeforeInterpolate();for(const l of this._tracks){let e=t;if("number"==typeof n&&!isNaN(n)){const o=this.GetTime(),_=o-l.GetStartOffset(),m=n-l.GetStartOffset();_<0&&0<m&&(e=l.GetStartOffset(),this._SetTime(e))}l.Interpolate(e,i,s,a,this._firstTick,r)}for(const c of this._tracks)c.AfterInterpolate();this._firstTick&&e&&(this._firstTick=!1)}AddTrack(){const e=this._timelineDataItem.GetTrackData().AddEmptyTrackDataItem(),t=C3.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,i){if(t){if("number"==typeof i&&0<=i){const s=this._tracks[i];return s?(s.SetInstance(t),void this._timelineManager.SetTimelineObjectClassToMap(t.GetObjectClass(),this)):void 0}for(const a of this._tracks)if(a.IsInstanceTrack())if(e){if(a.GetId()===e){a.SetInstance(t),this._timelineManager.SetTimelineObjectClassToMap(t.GetObjectClass(),this);break}}else if(!a.HasInstance()){a.SetInstance(t),this._timelineManager.SetTimelineObjectClassToMap(t.GetObjectClass(),this);break}}}HasTrackInstance(e,t){for(const i of this._tracks)if(i.IsInstanceTrack())if(t){if(t===i.GetId()&&e===i.GetInstance())return!0}else if(e===i.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():!1}return!1})}GetPropertyTrack(e){for(const t of this.GetTracks())for(const i of t.GetPropertyTracks())if(i.GetPropertyName()===e)return i}GetTrackFromInstance(e){for(const t of this._tracks)if(e===t.GetInstance())return t;return null}GetKeyframeWithTags(e){let t=e?e.split(" "):[];const i=new Set(t.map(e=>e.toLowerCase().trim()));t=[...i.values()];for(const s of this.GetTracks())for(const a of s.GetKeyframeDataItems()){const n=t.every(e=>a.HasTag(e));if(n)return a}}GetObjectClasses(){const e=[];for(const t of this.GetTracks())e.push(t.GetObjectClass());return e.filter(e=>e)}_OnAfterLoad(){for(const e of this.GetTracks())e._OnAfterLoad()}_SaveToJson(){return{"tracksJson":this._SaveTracksToJson(),"name":this._name,"playheadTime":this.GetTime(),"playbackRate":this._playbackRate,"pingPongState":this._pingPongState,"currentRepeatCount":this._currentRepeatCount,"isPlaying":this._isPlaying,"isScheduled":this._isScheduled,"initialStateSet":this._initialStateSet,"finishedTriggers":this._finishedTriggers,"complete":this._complete,"released":this._released,"markedForRemoval":this._markedForRemoval,"completedTick":this._completedTick,"implicitPause":this._implicitPause,"isTemplate":this._isTemplate,"tags":this._tags.join(" "),"stringTags":this._stringTags,"tagsChanged":this._tagsChanged,"firstTick":this._firstTick}}_LoadFromJson(e){e&&(this._LoadTracksFromJson(e["tracksJson"]),this._name=e["name"],this._playheadTime=e["playheadTime"],this._playbackRate=e["playbackRate"],this._pingPongState=e["pingPongState"],this._currentRepeatCount=e["currentRepeatCount"],this._isPlaying=!!e["isPlaying"],this._isScheduled=!!e["isScheduled"],this._initialStateSet=!!e["initialStateSet"],this._finishedTriggers=!!e.hasOwnProperty("finishedTriggers")&&!!e["finishedTriggers"],this._complete=!!e["complete"],this._released=!!e["released"],this._markedForRemoval=!!e["markedForRemoval"],this._completedTick=e["completedTick"],this._implicitPause=!!e["implicitPause"],this._isTemplate=!!e["isTemplate"],this._tags=e["tags"].split(" "),this._stringTags=e["stringTags"],this._tagsChanged=!!e["tagsChanged"],this._firstTick=!!e["firstTick"])}_SaveTracksToJson(){return this._tracks.map(e=>e._SaveToJson())}_LoadTracksFromJson(e){this.ClearTrackInstances(),e.forEach((e,t)=>{const i=this._tracks[t];i._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(C3.IsArray(e))return e.slice(0);if(C3.IsString(e))return e.split(" ");throw new Error("invalid tags")}GetITimelineState(){return this._iTimelineState||(this._iTimelineState=C3.New(self.ITimelineState,this)),this._iTimelineState}}; } // timelines/state/trackState.js { const C3=self.C3,INSTANCE_TRACK=0,VALUE_TRACK=1,AUDIO_TRACK=2;C3.TrackState=class extends C3.DefendedBase{constructor(t,e){super(),this._timeline=t,this._trackDataItem=e,this._trackData=e.GetTrackData(),this._instanceUid=NaN,this._objectClassIndex=NaN,this._instance=null,this._worldInfo=null,this._cleared=!1,this._isNested=0<e.GetStartOffset(),this._initialStateOfNestedSet=!1,this._endStateOfNestedSet=!1,this._instanceUidToLoad=NaN,this._lastKeyframeDataItem=null,this._keyframeDataItems=this._trackDataItem.GetKeyframeData().GetKeyframeDataItemArray(),this._propertyTracks=[],this.CreatePropertyTrackStates(),this._worldInfoChange=0,this._renderChange=0,this._needsBeforeAndAfter=0}static Create(t,e){return C3.New(C3.TrackState,t,e)}Release(){this._keyframeDataItems=null;for(const t of this._propertyTracks)t.Release();C3.clearArray(this._propertyTracks),this._propertyTracks=null,this._timeline=null,this._instance=null,this._worldInfo=null,this._trackDataItem=null,this._lastKeyframeDataItem=null}CreatePropertyTrackStates(){for(const t of this._trackDataItem.GetPropertyTrackData().propertyTrackDataItems())this._propertyTracks.push(C3.PropertyTrackState.Create(this,t))}TimelineRemoved(){for(const t of this._propertyTracks)t.TimelineRemoved()}CleanCaches(){for(const t of this._propertyTracks)t.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;t<this._propertyTracks.length;t++){const a=this._propertyTracks[t];if(a.GetPropertyName()===e)return a}}MaybeGetInstance(){this._instance||this.GetInstance()}IsInstanceValid(){return!!this._instance&&!this._instance.IsDestroyed()}CanInstanceBeValid(){if(!this.IsInstanceTrack())return!1;const t=this.GetInstanceUID(),e=this.GetRuntime().GetInstanceByUID(t);return!!e&&!e.IsDestroyed()}GetObjectClass(){if(this.IsInstanceTrack()){const t=this.GetObjectClassIndex();if(-1!==t)return this.GetRuntime().GetObjectClassByIndex(t)}}GetTrackIndexInTimeline(){return this._timeline.GetTracks().indexOf(this)}ClearInstance(){this._instance=null,this._instanceUid=NaN,this._worldInfo=null,this._objectClassIndex=NaN,this._cleared=!0}HasInstance(){return!!this._instance}GetInstance(){if(!this._cleared){if(!this._instance||!this.IsInstanceValid()){const t=this.GetInstanceUID();this._instance=this.GetRuntime().GetInstanceByUID(t)}return this._instance}}SetInstance(t){if(this._cleared=!1,this._instance!==t){this.CleanCaches(),this._instance=t,this._objectClassIndex=t.GetObjectClass().GetIndex(),this._instanceUid=t.GetUID(),this._worldInfo=t.GetWorldInfo();for(const e of this.propertyTrackItems()){const a=e.propertyTrack,s=e.sourceAdapter,r=a.GetSourceAdapterId();switch(r){case"instance-variable":{s.GetEditorIndex();const i=t.GetObjectClass(),n=i.GetInstanceVariableIndexByName(e.name),o=i.GetInstanceVariableName(n),h=i.GetInstanceVariableType(n);o===e.name&&h===e.type&&s.UpdateInstanceVariableIndex(n);break}case"behavior":{const c=e.behaviorType,l=this.GetObjectClass(),I=t.GetObjectClass(),d=s.GetBehaviorType(I);if(c&&d){const f=c.GetName();l.GetBehaviorIndexByName(f),I.GetBehaviorIndexByName(f),s.GetEditorIndex();s.UpdateBehaviorTypeSid(d.GetSID())}break}}}}}*propertyTrackItems(){for(const t of this._propertyTracks){const e=t.GetSourceAdapter(),a=this.GetObjectClass(),s={propertyTrack:t,sourceAdapter:e};switch(t.GetSourceAdapterId()){case"world-instance":s.property=t.GetPropertyName();break;case"instance-variable":{const r=e.GetEditorIndex();s.name=a.GetInstanceVariableName(r),s.type=a.GetInstanceVariableType(r);break}case"effect":{const i=a.GetEffectList(),n=e.GetEffectType(i);s.effectType=n;break}case"behavior":{const o=e.GetBehaviorType(a);s.behaviorType=o;break}case"plugin":s.plugin=a.GetPlugin()}yield s}}GetWorldInfo(){if(!this._worldInfo||!this.IsInstanceValid()){const t=this.GetInstance();t&&(this._worldInfo=t.GetWorldInfo())}return this._worldInfo}GetTrackDataItem(){return this._trackDataItem}GetInstanceUID(){return isNaN(this._instanceUid)?this._trackDataItem.GetInstanceUID():this._instanceUid}SetInstanceUID(t){this._trackDataItem.SetInstanceUID(t)}GetInterpolationMode(){return this._trackDataItem.GetInterpolationMode()}SetInterpolationMode(t){this._trackDataItem.SetInterpolationMode(t)}GetResultMode(){return this._trackDataItem.GetResultMode()}GetId(){return this._trackDataItem.GetId()}GetStartOffset(){return this._trackDataItem.GetStartOffset()}GetLocalTotalTime(){return this._trackDataItem.GetLocalTotalTime()}SetLocalTotalTime(t){this._trackDataItem.SetLocalTotalTime(t)}SetResultMode(t){this._trackDataItem.SetResultMode(t)}SetEase(t){for(const e of this.GetKeyframeDataItems())e.SetEase(t);for(const a of this.GetPropertyTracks())a.SetEase(t)}GetEnable(){return this._trackDataItem.GetEnable()}SetEnable(t){this._trackDataItem.SetEnable(t)}GetObjectClassIndex(){return isNaN(this._objectClassIndex)?this._trackDataItem.GetObjectClassIndex():this._objectClassIndex}SetObjectClassIndex(t){this._trackDataItem.SetObjectClassIndex(t)}SetOriginalWidth(t){this._trackDataItem.SetOriginalWidth(t)}GetOriginalWidth(){const t=this.GetInstance();if(t){const e=t.GetSdkInstance();if(e.IsOriginalSizeKnown())return t.GetSdkInstance().GetOriginalWidth()}return this._trackDataItem.GetOriginalWidth()}SetOriginalHeight(t){this._trackDataItem.SetOriginalHeight(t)}GetOriginalHeight(){const t=this.GetInstance();if(t){const e=t.GetSdkInstance();if(e.IsOriginalSizeKnown())return t.GetSdkInstance().GetOriginalHeight()}return this._trackDataItem.GetOriginalHeight()}GetType(){return this._trackDataItem.GetType()}GetName(){return this._trackDataItem.GetName()}IsInstanceTrack(){return this.GetType()===INSTANCE_TRACK}IsValueTrack(){return this.GetType()===VALUE_TRACK}IsAudioTrack(){return this.GetType()===AUDIO_TRACK}GetWorldInfoChange(){return this._worldInfoChange}GetRenderChange(){return this._renderChange}GetNeedsBeforeAndAfter(){return this._needsBeforeAndAfter}IsNested(){return this._isNested}SetResetState(){for(const t of this._propertyTracks)t.SetResetState()}SetInitialState(){if(this.MaybeGetInstance(),this.IsInstanceValid()||!this.IsInstanceTrack()){const t=this.GetTimeline(),e=t.IsForwardPlayBack(),a=e?0:this.GetLocalTotalTime();for(const r of this._propertyTracks)r.SetInitialState(a),0===this._worldInfoChange&&1===r.GetWorldInfoChange()&&(this._worldInfoChange=1),0===this._renderChange&&1===r.GetRenderChange()&&(this._renderChange=1);this._needsBeforeAndAfter=0;const s=this._propertyTracks.some(t=>t.GetNeedsBeforeAndAfter());s&&(this._needsBeforeAndAfter=1),this._lastKeyframeDataItem=this._GetLastKeyFrameBeforeTime(a),this._initialStateOfNestedSet=!1,this._endStateOfNestedSet=!1,this.Interpolate(a),this.OnKeyframeReached(this._GetLastKeyFrameBeforeTime(a))}}SetResumeState(){if(this.MaybeGetInstance(),this.IsInstanceValid()||!this.IsInstanceTrack()){this._timeline.IsForwardPlayBack();const t=this._timeline.GetTime()-this.GetStartOffset();this._lastKeyframeDataItem=this._GetLastKeyFrameBeforeTime(t);for(const e of this._propertyTracks)e.SetResumeState(t)}}SetEndState(){if(!this.GetTimeline().IsComplete()&&(this.MaybeGetInstance(),this.IsInstanceValid()||!this.IsInstanceTrack())&&!this._isNested){const t=this._timeline.GetTime(),e=this.GetStartOffset()+this.GetLocalTotalTime();e<=t?this.Interpolate(this.GetLocalTotalTime(),!0,!1,!0,!1,!1,!0):t<=0&&this.Interpolate(0,!0,!1,!0,!1,!1,!0)}}_SetUpdateState(){for(let t=0,e=this._propertyTracks.length;t<e;t++){const a=this._propertyTracks[t];a._SetUpdateState(),0===this._worldInfoChange&&1===a.GetWorldInfoChange()&&(this._worldInfoChange=1),0===this._renderChange&&1===a.GetRenderChange()&&(this._renderChange=1)}}BeforeInterpolate(){const e=this._propertyTracks.length;for(let t=0;t<e;t++)this._propertyTracks[t].BeforeInterpolate()}Interpolate(a,t=!1,s=!1,r=!1,e=!1,i=!1,n=!1){this._instance||this.GetInstance();const o=this._instance&&!this._instance.IsDestroyed(),h=this._trackDataItem._type===INSTANCE_TRACK;if((o||!h)&&!(i&&h&&this.GetObjectClass().IsGlobal()||(a-=this.GetStartOffset())<0)){this.MaybeSetInitialStateOfNestedTrack(a,t),this.MaybeTriggerKeyframeReachedConditions(a,t,e);for(let t=0,e=this._propertyTracks.length;t<e;t++)this._propertyTracks[t].Interpolate(a,s,r,n);this.MaybeSetEndStateOfNestedTrack(a,t),0!==this._worldInfoChange&&(this._worldInfo||(this._worldInfo=this._instance.GetWorldInfo()),this._worldInfo)&&this._worldInfo.SetBboxChanged()}}AfterInterpolate(){const e=this._propertyTracks.length;for(let t=0;t<e;t++)this._propertyTracks[t].AfterInterpolate()}MaybeSetInitialStateOfNestedTrack(t,e){if(e&&this._isNested&&!this._initialStateOfNestedSet){const a=this.GetTimeline();if(a.IsForwardPlayBack()){if(t<0)return}else if(t>this.GetLocalTotalTime())return;for(const s of this._propertyTracks)s.SetInitialState();this._initialStateOfNestedSet=!0}}MaybeSetEndStateOfNestedTrack(t,e){if(e&&this._isNested&&!this._endStateOfNestedSet){const a=this.GetTimeline();if(a.IsForwardPlayBack()){if(t>=this.GetLocalTotalTime()){for(const s of this._propertyTracks)s.Interpolate(this.GetLocalTotalTime(),!1,!0);this._endStateOfNestedSet=!0}}else if(t<=0){for(const r of this._propertyTracks)r.Interpolate(0,!1,!0);this._endStateOfNestedSet=!0}}}MaybeTriggerKeyframeReachedConditions(t,e,a){if(!a&&e&&C3.Plugins.Timeline){const s=this.GetTimeline(),r=this._lastKeyframeDataItem.GetNext(),i=this._lastKeyframeDataItem.GetTime(),n=r?r.GetTime():s.GetTotalTime();if(t<=i||n<=t)if(this._lastKeyframeDataItem=this._trackData.GetFirstKeyFrameDataItemLowerOrEqualThan(t,this._trackDataItem),s.IsForwardPlayBack())r&&this.OnKeyframeReached(this._lastKeyframeDataItem);else{const r=this._lastKeyframeDataItem.GetNext();r&&this.OnKeyframeReached(r)}}}_GetLastKeyFrameBeforeTime(t){const e=this._trackData.GetKeyFrameDataItemAtTime(t,this._trackDataItem);return e||this._trackData.GetFirstKeyFrameDataItemLowerOrEqualThan(t,this._trackDataItem)}OnKeyframeReached(t){if(C3.Plugins.Timeline){const e=this.GetTimeline(),a=e.GetTimelineManager();C3.Plugins.Timeline.Cnds.PushTriggerTimeline(e),C3.Plugins.Timeline.Cnds.PushTriggerKeyframe(t),a.Trigger(C3.Plugins.Timeline.Cnds.OnAnyKeyframeReached),a.Trigger(C3.Plugins.Timeline.Cnds.OnKeyframeReached),C3.Plugins.Timeline.Cnds.PopTriggerTimeline(e),C3.Plugins.Timeline.Cnds.PopTriggerKeyframe(t)}}AddKeyframe(){const t=this._trackDataItem.GetKeyframeData(),e=t.AddEmptyKeyframeDataItem();return e}AddPropertyTrack(){const t=this._trackDataItem.GetPropertyTrackData(),e=t.AddEmptyPropertyTrackDataItem(),a=C3.PropertyTrackState.Create(this,e);return this._propertyTracks.push(a),a}DeleteKeyframes(t){const e=this._trackDataItem.GetKeyframeData();e.DeleteKeyframeDataItems(t)}DeletePropertyKeyframes(t){for(const e of this._propertyTracks)e.DeletePropertyKeyframes(t)}SaveState(){for(const t of this._propertyTracks)t.SaveState()}CompareInitialStateWithCurrent(){if(this.MaybeGetInstance(),this.IsInstanceValid()||!this.IsInstanceTrack())for(const t of this._propertyTracks)t.CompareInitialStateWithCurrent()}CompareSaveStateWithCurrent(){if(this.MaybeGetInstance(),this.IsInstanceValid()||!this.IsInstanceTrack()){let t=!1;for(const e of this._propertyTracks){const a=e.CompareSaveStateWithCurrent();!t&&a&&(t=!0)}if(t){const s=this.AddKeyframe();s.SetTime(this.GetTimeline().GetTime()),s.SetEase("noease"),s.SetEnable(!0),s.SetTags("")}}}_OnAfterLoad(){isNaN(this._instanceUidToLoad)||this._LoadInstanceFromJson(this._instanceUidToLoad),this._instanceUidToLoad=NaN}_SaveToJson(){const t=this.GetInstance(),e=t?t.GetUID():this.GetInstanceUID();return{"propertyTracksJson":this._SavePropertyTracksToJson(),"lastKeyframeDataItemJson":this._SaveLastKeyframeDataItemToJson(),"initialStateOfNestedSet":this._initialStateOfNestedSet,"endStateOfNestedSet":this._endStateOfNestedSet,"instanceUid":e,"cleared":this._cleared}}_LoadFromJson(t){if(t){this._LoadPropertyTracksFromJson(t["propertyTracksJson"]),this._LoadLastKeyframeDataItemFromJson(t["lastKeyframeDataItemJson"]),this._instanceUidToLoad=t["instanceUid"],this._initialStateOfNestedSet=!1,t.hasOwnProperty["initialStateOfNestedSet"]&&(this._initialStateOfNestedSet=t["initialStateOfNestedSet"]),this._endStateOfNestedSet=!1,t.hasOwnProperty["endStateOfNestedSet"]&&(this._endStateOfNestedSet=t["endStateOfNestedSet"]),this._cleared=!!t.hasOwnProperty("cleared")&&t["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(t=>t.GetNeedsBeforeAndAfter())&&(this._needsBeforeAndAfter=1)}}_SaveLastKeyframeDataItemToJson(){const t=this._trackDataItem.GetKeyframeData();return t.GetKeyframeDataItemIndex(this._lastKeyframeDataItem)}_SavePropertyTracksToJson(){return this._propertyTracks.map(t=>t._SaveToJson())}_LoadPropertyTracksFromJson(t){t.forEach((t,e)=>{const a=this._propertyTracks[e];a._LoadFromJson(t)})}_LoadInstanceFromJson(t){if(C3.IsFiniteNumber(t)){const e=this.GetRuntime().GetInstanceByUID(t);if(e){const a=this.GetTimeline();a.SetTrackInstance(this._trackDataItem.GetId(),e,this.GetTrackIndexInTimeline())}}}_LoadLastKeyframeDataItemFromJson(t){const e=this._trackDataItem.GetKeyframeData();this._lastKeyframeDataItem=e.GetKeyframeDataItemFromIndex(t)}}; } // timelines/state/propertyTrackState.js { const C3=self.C3;C3.PropertyTrackState=class extends C3.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 C3.New(C3.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){const t=this._propertyTrackDataItem.GetSourceAdapterId();let e;switch(t){case"behavior":e=new C3.PropertyTrackState.BehaviorSourceAdapter(this);break;case"effect":e=new C3.PropertyTrackState.EffectSourceAdapter(this),this._renderChange=1;break;case"instance-variable":e=new C3.PropertyTrackState.InstanceVariableSourceAdapter(this);break;case"plugin":e=new C3.PropertyTrackState.PluginSourceAdapter(this),this._renderChange=1;break;case"world-instance":e=new C3.PropertyTrackState.PropertySourceAdapter(this),this._renderChange=1,this._worldInfoChange=1;break;case"value":e=new C3.PropertyTrackState.ValueSourceAdapter(this);break;case"audio":e=new C3.PropertyTrackState.AudioSourceAdapter(this)}this._sourceAdapter=e}return this._sourceAdapter}GetSourceAdapterId(){return this._propertyTrackDataItem.GetSourceAdapterId()}SetSourceAdapterId(e){this._propertyTrackDataItem.SetSourceAdapterId(e)}GetSourceAdapterArgs(){return this._propertyTrackDataItem.GetSourceAdapterArguments()}SetSourceAdapterArgs(e){this._propertyTrackDataItem.SetSourceAdapterArguments(e)}GetSourceAdapterValue(){return this.GetSourceAdapter().GetValue()}GetPropertyName(){return this._propertyTrackDataItem.GetProperty()}SetPropertyName(e){this._propertyTrackDataItem.SetProperty(e)}GetPropertyType(){return this._propertyTrackDataItem.GetType()}SetPropertyType(e){this._propertyTrackDataItem.SetType(e)}GetPropertyKeyframeType(){return this.GetPropertyTrackData().GetFirstPropertyKeyframeDataItem(this._propertyTrackDataItem).GetType()}GetMin(){return this._propertyTrackDataItem.GetMin()}SetMin(e){this._propertyTrackDataItem.SetMin(e)}GetMax(){return this._propertyTrackDataItem.GetMax()}SetMax(e){this._propertyTrackDataItem.SetMax(e)}GetEnable(){return this._propertyTrackDataItem.GetEnable()}SetEnable(e){this._propertyTrackDataItem.SetEnable(e)}GetInterpolationMode(){return this._propertyTrackDataItem.GetInterpolationMode()}SetInterpolationMode(e){this._propertyTrackDataItem.SetInterpolationMode(e)}GetResultMode(){return this._propertyTrackDataItem.GetResultMode()}SetResultMode(e){this._propertyTrackDataItem.SetResultMode(e)}SetEase(e){for(const t of this.GetPropertyKeyframeDataItems())t.SetEase(e)}CanHavePropertyKeyframes(){return this._propertyTrackDataItem.CanHavePropertyKeyframes()}GetPropertyKeyframeDataItems(){return this._propertyKeyframeDataItems||(this._propertyKeyframeDataItems=this._propertyTrackDataItem.GetPropertyKeyframeData().GetPropertyKeyframeDataItemArray()),this._propertyKeyframeDataItems}GetPropertyKeyframeDataItemArrayIncludingDisabled(){return this._propertyTrackDataItem.GetPropertyKeyframeData().GetPropertyKeyframeDataItemArrayIncludingDisabled()}GetPropertyKeyFrameDataItemAtTime(e){return this._propertyTrackData.GetPropertyKeyFrameDataItemAtTime(e,this._propertyTrackDataItem)}GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e){return this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,this._propertyTrackDataItem)}GetPropertyKeyframeDataItemPairForTime(e){let t=this._propertyTrackData.GetPropertyKeyFrameDataItemAtTime(e,this._propertyTrackDataItem),r;return r=t?this._propertyTrackData.GetFirstPropertyKeyFrameDataItemHigherThan(e,this._propertyTrackDataItem):(t=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,this._propertyTrackDataItem),this._propertyTrackData.GetFirstPropertyKeyFrameDataItemHigherOrEqualThan(e,this._propertyTrackDataItem)),{start:t,end:r}}*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(),r=e.GetInstance(),a=this.GetSourceAdapter(),o=this.GetPropertyName(),s=a.MayNeedBeforeAndAfterInterpolate();if(s){const p=t.GetSimilarPropertyTracks(r,a,o,this);p&&p.length&&(this._needsBeforeAndAfter=1)}else this._needsBeforeAndAfter=0}}_GetLastPropertyKeyFrameBeforeTime(e){const t=this.GetTimeline(),r=this._propertyTrackData.GetPropertyKeyFrameDataItemAtTime(e,this._propertyTrackDataItem);return r||(t.IsForwardPlayBack()?this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,this._propertyTrackDataItem):this._propertyTrackData.GetFirstPropertyKeyFrameDataItemHigherOrEqualThan(e,this._propertyTrackDataItem))}BeforeInterpolate(){this._sourceAdapter.BeforeInterpolate()}Interpolate(e,t=!1,r=!1,a=!1){let o,s,p=!1;if(t)o=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,this._propertyTrackDataItem);else{if(this._lastPropertyKeyframeDataItem){const i=this.GetTimeline(),y=this._lastPropertyKeyframeDataItem.GetNext(),m=this._lastPropertyKeyframeDataItem.GetTime(),n=y?y.GetTime():i.GetTotalTime();(e<=m||n<=e)&&(this._lastPropertyKeyframeDataItem=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,this._propertyTrackDataItem),p=!0)}else this._lastPropertyKeyframeDataItem=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,this._propertyTrackDataItem),p=!0;o=this._lastPropertyKeyframeDataItem}o&&(s=o.GetNext()),this._sourceAdapter.Interpolate(e,o,s,t,r,a,p)}GetInterpolatedValue(e){if(this._lastPropertyKeyframeDataItem){const a=this.GetTimeline(),o=this._lastPropertyKeyframeDataItem.GetNext(),s=this._lastPropertyKeyframeDataItem.GetTime(),p=o?o.GetTime():a.GetTotalTime();(e<=s||p<=e)&&(this._lastPropertyKeyframeDataItem=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,this._propertyTrackDataItem))}else this._lastPropertyKeyframeDataItem=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,this._propertyTrackDataItem);const t=this._lastPropertyKeyframeDataItem,r=t.GetNext();return this._sourceAdapter.GetInterpolatedValue(e,t,r)}GetInterpolatedValueFast(e,t,r){return this._sourceAdapter.GetInterpolatedValue(e,t,r)}AfterInterpolate(){this._sourceAdapter.AfterInterpolate()}static GetStartPropertyKeyframeForTime(e,t){const r=t.GetPropertyTrackDataItem(),a=t._propertyTrackData;return a.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,r)}static GetEndPropertyKeyframeForTime(e,t){const r=t.GetPropertyTrackDataItem(),a=t._propertyTrackData;return a.GetFirstPropertyKeyFrameDataItemHigherOrEqualThan(e,r)}AddPropertyKeyframe(){const e=this._propertyTrackDataItem.GetPropertyKeyframeData(),t=e.AddEmptyPropertyKeyframeDataItem();return this._lastPropertyKeyframeDataItem=null,t}DeletePropertyKeyframes(e){this._lastPropertyKeyframeDataItem=null;const t=this._propertyTrackDataItem.GetPropertyKeyframeData();t.DeletePropertyKeyframeDataItems(e)}SaveState(){this.GetSourceAdapter().SaveState()}CompareInitialStateWithCurrent(){const e=this.GetSourceAdapter().CompareInitialStateWithCurrent();if(e){const t=this._propertyTrackData.GetFirstPropertyKeyframeDataItem(this._propertyTrackDataItem),r=this.GetSourceAdapter().GetCurrentState();t.SetAbsoluteValue(r)}}CompareSaveStateWithCurrent(){const e=this.GetSourceAdapter().CompareSaveStateWithCurrent();return e&&this.AddPropertyKeyframeAtCurrentTime(),this.GetSourceAdapter().ClearSaveState(),e}AddPropertyKeyframeAtCurrentTime(){const e=this.GetTimeline().GetTime(),t=this.GetSourceAdapter(),r=C3.PropertyTrackState.GetStartPropertyKeyframeForTime(e,this),a=this.AddPropertyKeyframe();a.SetType(r.GetType()),a.SetTime(e),a.SetEase(r.GetEase()),a.SetEnable(!0),a.SetValue(t.GetValueAtTime()),a.SetAbsoluteValue(t.GetCurrentState())}_SaveToJson(){return{"sourceAdapterJson":this.GetSourceAdapter()._SaveToJson()}}_LoadFromJson(e){e&&this.GetSourceAdapter()._LoadFromJson(e["sourceAdapterJson"])}}; } // timelines/state/propertySourceAdapters/propertySourceAdapter.js { const C3=self.C3,NS=C3.PropertyTrackState;NS.PropertySourceAdapter=class{constructor(e){this._propertyTrack=e,this._propertyAdapter=null,this.GetPropertyAdapter()}Release(){this._propertyAdapter&&(this._propertyAdapter.Release(),this._propertyAdapter=null),this._propertyTrack=null}MayNeedBeforeAndAfterInterpolate(){return this._propertyAdapter.MayNeedBeforeAndAfterInterpolate()}GetPropertyTrack(){return this._propertyTrack}TimelineRemoved(){this._propertyAdapter&&this._propertyAdapter.TimelineRemoved()}CleanCaches(){this._propertyAdapter&&this._propertyAdapter.CleanCaches()}GetPropertyAdapter(){return this._propertyAdapter||(this._propertyAdapter=this._CreatePropertyAdapter()),this._propertyAdapter}GetEditorIndex(){}GetIndex(){return this.GetEditorIndex()}GetTarget(){}SetResetState(){this.GetPropertyAdapter().SetResetState()}SetInitialState(){this.GetPropertyAdapter().SetInitialState()}SetResumeState(){this.GetPropertyAdapter().SetResumeState()}BeforeInterpolate(){this._propertyAdapter.BeforeChangeProperty()}Interpolate(e,t,r,p,a,o,n){const s=this._propertyTrack.GetPropertyKeyframeType();let i;switch(s){case"numeric":i=NS.NumericTypeAdapter.Interpolate(e,t,r,this._propertyTrack);break;case"angle":i=NS.AngleTypeAdapter.Interpolate(e,t,r,this._propertyTrack);break;case"boolean":i=NS.BooleanTypeAdapter.Interpolate(e,t,r,this._propertyTrack);break;case"color":i=NS.ColorTypeAdapter.Interpolate(e,t,r,this._propertyTrack);break;case"text":i=NS.TextTypeAdapter.Interpolate(e,t,r,this._propertyTrack)}this._propertyAdapter.ChangeProperty(e,i,t,r,p,a,o,n)}GetInterpolatedValue(e,t,r){switch(this._propertyTrack.GetPropertyKeyframeType()){case"numeric":return NS.NumericTypeAdapter.Interpolate(e,t,r,this._propertyTrack);case"angle":return NS.AngleTypeAdapter.Interpolate(e,t,r,this._propertyTrack);case"boolean":return NS.BooleanTypeAdapter.Interpolate(e,t,r,this._propertyTrack);case"color":return NS.ColorTypeAdapter.Interpolate(e,t,r,this._propertyTrack);case"text":return NS.TextTypeAdapter.Interpolate(e,t,r,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(),r=t.GetTimeline().GetTime(),p=NS.GetStartPropertyKeyframeForTime(r,e),a=p.GetNext(),o=e.GetPropertyKeyframeType();switch(o){case"numeric":return NS.NumericTypeAdapter.Interpolate(r,p,a,e);case"angle":return NS.AngleTypeAdapter.Interpolate(r,p,a,e);case"boolean":return NS.BooleanTypeAdapter.Interpolate(r,p,a,e);case"color":return NS.ColorTypeAdapter.Interpolate(r,p,a,e);case"text":return NS.TextTypeAdapter.Interpolate(r,p,a,e)}}_CreatePropertyAdapter(){const e=this._propertyTrack,t=e.CanHavePropertyKeyframes()?e.GetPropertyKeyframeType():"";switch(t){case"combo":case"boolean":case"text":case"string":return new NS.PropertyInterpolationAdapter.NoInterpolationAdapter(this);case"numeric":case"number":case"angle":return new("combo"===this._propertyTrack.GetPropertyType()?NS.PropertyInterpolationAdapter.NoInterpolationAdapter:NS.PropertyInterpolationAdapter.NumericInterpolationAdapter)(this);case"color":case"offsetColor":return new NS.PropertyInterpolationAdapter.ColorInterpolationAdapter(this);default:return new NS.PropertyInterpolationAdapter.NumericInterpolationAdapter(this)}}_SaveToJson(){return{"propertyAdapterJson":this.GetPropertyAdapter()._SaveToJson()}}_LoadFromJson(e){e&&this.GetPropertyAdapter()._LoadFromJson(e["propertyAdapterJson"])}}; } // timelines/state/propertySourceAdapters/instanceVariableSourceAdapter.js { const C3=self.C3,INDEX=0;class InstanceVariableSourceAdapter extends C3.PropertyTrackState.PropertySourceAdapter{constructor(e){super(e),this._updatedIndex=NaN}GetEditorIndex(){return this._propertyTrack.GetPropertyTrackDataItem().GetSourceAdapterArguments()[INDEX]}GetIndex(){return this._updatedIndex||super.GetIndex()}GetTarget(){return this._propertyTrack.GetTrack().GetInstance()}UpdateInstanceVariableIndex(e){const t=this._propertyTrack.GetPropertyTrackDataItem().GetSourceAdapterArguments()[INDEX];t!==e&&(this._updatedIndex=e)}Interpolate(e,t,r,a,n,p,d){this.GetPropertyAdapter().CanChange(t.GetValue())&&super.Interpolate(e,t,r,a,n,p,d)}GetInterpolatedValue(e,t,r){if(this.GetPropertyAdapter().CanChange(t.GetValue()))return super.GetInterpolatedValue(e,t,r)}_SaveToJson(){return Object.assign(super._SaveToJson(),{"index":this._updatedIndex})}_LoadFromJson(e){e&&(super._LoadFromJson(e),this._updatedIndex=e["index"])}}C3.PropertyTrackState.InstanceVariableSourceAdapter=InstanceVariableSourceAdapter; } // timelines/state/propertySourceAdapters/behaviorSourceAdapter.js { const C3=self.C3,SID=0,INDEX=1,NAME=2;class BehaviorSourceAdapter extends C3.PropertyTrackState.PropertySourceAdapter{constructor(e){super(e),this._sid=NaN}GetEditorIndex(){const e=this._propertyTrack.GetPropertyTrackDataItem();return e.GetSourceAdapterArguments()[INDEX]}GetTarget(){const e=this._propertyTrack.GetPropertyTrackDataItem(),t=this._propertyTrack.GetTrack(),r=this._sid||e.GetSourceAdapterArguments()[SID],a=t.GetInstance(),s=a.GetBehaviorIndexBySID(r),o=a.GetBehaviorInstances()[s];return o.GetSdkInstance()}GetBehaviorType(e){const t=this._propertyTrack.GetPropertyTrackDataItem(),r=t.GetSourceAdapterArguments()[NAME];return e.GetBehaviorTypeByName(r)}UpdateBehaviorTypeSid(e){const t=this._propertyTrack.GetPropertyTrackDataItem();t.GetSourceAdapterArguments()[SID]!==e&&(this._sid=e)}Interpolate(e,t,r,a,s,o,p){const c=this._propertyTrack.GetTrack(),n=c.GetInstance();this.GetBehaviorType(n.GetObjectClass())&&super.Interpolate(e,t,r,a,s,o,p)}GetInterpolatedValue(e,t,r){const a=this._propertyTrack.GetTrack(),s=a.GetInstance();if(this.GetBehaviorType(s.GetObjectClass()))return super.GetInterpolatedValue(e,t,r)}_SaveToJson(){return Object.assign(super._SaveToJson(),{"sid":this._sid})}_LoadFromJson(e){e&&(super._LoadFromJson(e),this._sid=e["sid"])}}C3.PropertyTrackState.BehaviorSourceAdapter=BehaviorSourceAdapter; } // timelines/state/propertySourceAdapters/effectSourceAdapter.js { const C3=self.C3,NAME=0,INDEX=1;class EffectSourceAdapter extends C3.PropertyTrackState.PropertySourceAdapter{constructor(e){super(e)}GetEditorIndex(){return this._propertyTrack.GetPropertyTrackDataItem().GetSourceAdapterArguments()[INDEX]}GetTarget(){const e=this._propertyTrack,t=e.GetTrack(),r=t.GetWorldInfo(),c=r.GetInstanceEffectList(),f=c.GetEffectList(),a=this.GetEffectType(f),s=a.GetIndex();return c.IsEffectIndexActive(s)?c.GetEffectParametersForIndex(s):null}GetEffectType(e){const t=this._propertyTrack,r=t.GetPropertyTrackDataItem().GetSourceAdapterArguments()[NAME];return e.GetEffectTypeByName(r)}Interpolate(e,t,r,c,f,a,s){this._IsEffectActive()&&super.Interpolate(e,t,r,c,f,a,s)}GetInterpolatedValue(e,t,r){if(this._IsEffectActive())return super.GetInterpolatedValue(e,t,r)}_IsEffectActive(){const e=this._propertyTrack,t=e.GetTrack(),r=t.GetWorldInfo(),c=r.GetInstanceEffectList(),f=c.GetEffectList(),a=this.GetEffectType(f);if(a){const s=a.GetIndex();return c.IsEffectIndexActive(s)}}}C3.PropertyTrackState.EffectSourceAdapter=EffectSourceAdapter; } // timelines/state/propertySourceAdapters/pluginSourceAdapter.js { const C3=self.C3,INDEX=0;class PluginSourceAdapter extends C3.PropertyTrackState.PropertySourceAdapter{constructor(t){super(t)}GetEditorIndex(){return this._propertyTrack.GetPropertyTrackDataItem().GetSourceAdapterArguments()[INDEX]}GetTarget(){return this._propertyTrack.GetTrack().GetInstance().GetSdkInstance()}Interpolate(t,e,r,a,s,n,c){const p=this._propertyTrack.GetTrack(),i=p.GetObjectClass().GetPlugin(),o=p.GetInstance().GetObjectClass().GetPlugin();i===o&&super.Interpolate(t,e,r,a,s,n,c)}GetInterpolatedValue(t,e,r){const a=this._propertyTrack.GetTrack(),s=a.GetObjectClass().GetPlugin(),n=a.GetInstance().GetObjectClass().GetPlugin();if(s===n)return super.GetInterpolatedValue(t,e,r)}GetOptionalCallbacks(){const t=this._propertyTrack.GetTrack(),e=t.GetObjectClass().GetPlugin();if(C3.Plugins.Sprite&&e instanceof C3.Plugins.Sprite&&("initial-frame"===this._propertyTrack.GetPropertyName()||"initial-animation"===this._propertyTrack.GetPropertyName()))switch(this._propertyTrack.GetResultMode()){case"relative":case"absolute":return null}}}C3.PropertyTrackState.PluginSourceAdapter=PluginSourceAdapter; } // timelines/state/propertySourceAdapters/valueSourceAdapter.js { const C3=self.C3;class ValueSourceAdapter extends C3.PropertyTrackState.PropertySourceAdapter{constructor(t){super(t),this._value=0,this._init=!1}MayNeedBeforeAndAfterInterpolate(){return!1}SetInitialState(){const t=this._propertyTrack.GetPropertyTrackData();let e=this._propertyTrack.GetPropertyTrackDataItem();e=t.GetFirstPropertyKeyframeDataItem(e),this._value=e.GetValueWithResultMode()}SetResumeState(){}GetValue(){return this._init||this._propertyTrack.Interpolate(0),this._value}Interpolate(t,e,r,a,i,o,u){this._value=C3.PropertyTrackState.NumericTypeAdapter.Interpolate(t,e,r,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(t){t&&(this._value=t["value"],this._init=!t.hasOwnProperty("init")||t["init"])}}C3.PropertyTrackState.ValueSourceAdapter=ValueSourceAdapter; } // timelines/state/propertySourceAdapters/audioSourceAdapter.js { const C3=self.C3,PROJECT_FILE=0,PROJECT_FILE_NAME=0,PROJECT_FILE_TYPE=1,START_OFFSET=1,AUDIO_DURATION=2,AUDIO_TAG=3;class AudioSourceAdapter extends C3.PropertyTrackState.PropertySourceAdapter{constructor(t){super(t),this._audioPlaybackStarted=!1,this._sdkInstance=null,this._actions=null,this._expressions=null,this._timeline=this._propertyTrack.GetTimeline(),this._track=this._propertyTrack.GetTrack(),this._sourceAdapterArgs=this._propertyTrack.GetSourceAdapterArgs(),this._fileArgs=this._sourceAdapterArgs[PROJECT_FILE],this._startOffsetTime=this._sourceAdapterArgs[START_OFFSET],this._sourceAdapterArgs[AUDIO_TAG]?this._audioTag=this._sourceAdapterArgs[AUDIO_TAG]:this._audioTag=Math.random().toString(36).slice(2),this._pauseTime=NaN,this._pauseVolume=NaN,this._volume=NaN,this._audioSource=null,this._Initialize()}Release(){super.Release(),this._sdkInstance=null,this._actions=null,this._expressions=null,this._timeline=null,this._track=null,this._sourceAdapterArgs=null,this._fileArgs=null,this._audioSource=null}_Initialize(){if(self.C3.Plugins.Audio){const t=this._propertyTrack.GetRuntime(),e=t.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){const t=this._propertyTrack.GetTrack(),e=t.GetPropertyTrack("audioSource");e&&(this._audioSource=e.GetSourceAdapter())}}_GetPauseVolume(){const t=this._propertyTrack.GetTrack(),e=t.GetPropertyTrack("volume");return(e?e.GetSourceAdapter():this)._pauseVolume}TimelineRemoved(){super.TimelineRemoved(),this._audioPlaybackStarted=!1,this._sdkInstance&&(this._expressions&&(this._pauseTime=this._expressions.PlaybackTime.call(this._sdkInstance,this._audioTag),this._pauseVolume=this._expressions.Volume.call(this._sdkInstance,this._audioTag)),this._actions)&&this._actions.Stop.call(this._sdkInstance,this._audioTag)}GetAudioTag(){return this._audioTag}GetVolume(){return this._volume}SetVolume(t){this._volume=t}SetInitialState(){super.SetInitialState(),this._pauseTime=NaN,this._audioPlaybackStarted=!1}SetResumeState(){super.SetResumeState();const t=this._propertyTrack.GetTimeline(),e=t.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(t,e,s,i,a,o,r){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(t<this._startOffsetTime)return void(this._audioPlaybackStarted=!1);const u=this._expressions.PlaybackRate.call(this._sdkInstance,this._audioTag),_=this._timeline.GetPlaybackRate();if(_!==u&&this._actions.SetPlaybackRate.call(this._sdkInstance,this._audioTag,_),this._audioPlaybackStarted)return;if(!this._propertyTrack.GetTimeline().IsPlaying())return;if(this._audioPlaybackStarted=!0,isNaN(this._pauseTime)){const l=self["performance"].now(),h=t-this._startOffsetTime,c=this._sdkInstance.GetAudioContextState();if("suspended"===c)return void(this._audioPlaybackStarted=!1);const n=self["performance"].now(),d=(n-l)/1e3,p=h+d;if(this._actions){let t=this.GetVolume();isNaN(t)?(this.SetVolume(0),t=0):this.SetVolume(t),this._actions.PlayFromTimeline.call(this._sdkInstance,this._fileArgs,t,this._audioTag,p)}}else{const S=this._pauseTime,m=(this._pauseTime=NaN,this._GetPauseVolume()),T=(this._pauseVolume=NaN,this._sdkInstance.GetAudioContextState());if("suspended"===T)return void(this._audioPlaybackStarted=!1);this._actions&&(this.SetVolume(m),this._actions.PlayFromTimeline.call(this._sdkInstance,this._fileArgs,m,this._audioTag,S))}break}case"volume":this._MaybeSetAudioSource(),super.Interpolate(t,e,s,i,a,o,r)}}GetInterpolatedValue(t,e,s){if(this._sdkInstance)switch(this._propertyTrack.GetPropertyName()){case"audioSource":return;case"volume":return this._MaybeSetAudioSource(),super.GetInterpolatedValue(t,e,s)}}Getter(t,e){return this._audioSource?this._audioSource.GetVolume():0}Setter(t,e,s,i){this._audioSource&&this._audioSource.SetVolume(this.Getter()+e),this._actions&&this._audioSource&&this._actions.SetVolume.call(this._sdkInstance,this._audioSource.GetAudioTag(),this._audioSource.GetVolume())}AbsoluteSetter(t,e,s){this._audioSource&&this._audioSource.SetVolume(e),this._actions&&this._audioSource&&this._actions.SetVolume.call(this._sdkInstance,this._audioSource.GetAudioTag(),this._audioSource.GetVolume())}DoesRounding(){return!0}_SaveToJson(){return{"audioPlaybackStarted":this._audioPlaybackStarted,"audioTag":this._audioTag,"pauseTime":this._pauseTime,"pauseVolume":this._pauseVolume,"volume":this._volume}}_LoadFromJson(t){t&&(this._audioPlaybackStarted=t["audioPlaybackStarted"],this._audioTag=t["audioTag"],this._pauseTime=t["pauseTime"],this._pauseVolume=t["pauseVolume"],this._volume=t["volume"],this._Initialize())}}C3.PropertyTrackState.AudioSourceAdapter=AudioSourceAdapter; } // timelines/state/propertyInterpolationAdapters/propertyInterpolationAdapter.js { const C3=self.C3;C3.PropertyTrackState.PropertyInterpolationAdapter=class{constructor(t){this._sourceAdapter=t,this._propertyTrack=t.GetPropertyTrack(),this._worldInfo=this._propertyTrack.GetTrack().GetWorldInfo(),this._property=this._propertyTrack.GetPropertyName(),this._firstAbsoluteUpdate=!1,this._saveState=null,this._target=null}Release(){this._sourceAdapter=null,this._propertyTrack=null,this._worldInfo=null,this._saveState=null,this._target=null}MayNeedBeforeAndAfterInterpolate(){return!1}TimelineRemoved(){}CleanCaches(){this._worldInfo=null,this._saveState=null,this._target=null}GetSourceAdapter(){return this._sourceAdapter}GetPropertyTrack(){return this._propertyTrack}GetWorldInfo(){return this._worldInfo||(this._worldInfo=this._propertyTrack.GetTrack().GetWorldInfo()),this._worldInfo}SetFirstAbsoluteUpdate(t){this._firstAbsoluteUpdate=!!t}GetFirstAbsoluteUpdate(){return this._firstAbsoluteUpdate}SetResetState(){}SetInitialState(){}SetResumeState(){}SetSaveState(){this._saveState=this.GetCurrentState()}ClearSaveState(){this._saveState=null}GetCurrentState(){}CompareInitialStateWithCurrent(){}CompareSaveStateWithCurrent(){}CanChange(t){const e=typeof this._Getter(),r=typeof t;return e==r}BeforeChangeProperty(){}ChangeProperty(t,e,r,a,s,o,i,n){}AfterChangeProperty(){}_FirstKeyframeGetter(){const t=this._PickTimelinePlaybackMode(()=>{const t=this._propertyTrack.GetPropertyTrackDataItem(),e=this._propertyTrack.GetPropertyTrackData();return e.GetFirstPropertyKeyframeDataItem(t)},()=>{const t=this._propertyTrack.GetPropertyTrackDataItem(),e=this._propertyTrack.GetPropertyTrackData();return e.GetLastPropertyKeyframeDataItem(t)});return t.GetAbsoluteValue()}_CurrentKeyframeGetter(){const t=this._propertyTrack.GetTimeline(),a=t.GetTime()-this._propertyTrack.GetTrack().GetStartOffset(),e=this._PickTimelinePlaybackMode(()=>{const t=this._propertyTrack.GetPropertyTrackDataItem(),e=this._propertyTrack.GetPropertyTrackData();return e.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(a,t)},()=>{const t=this._propertyTrack.GetPropertyTrackDataItem(),e=this._propertyTrack.GetPropertyTrackData(),r=e.GetFirstPropertyKeyFrameDataItemHigherOrEqualThan(a,t);return r||e.GetLastPropertyKeyframeDataItem(t)});return e.GetAbsoluteValue()}_PickTimelinePlaybackMode(t,e){const r=this._propertyTrack.GetTimeline();return(r.IsForwardPlayBack()?t:e)()}_PickResultMode(t,e){const r=this._propertyTrack.GetResultMode();return("relative"===r?t:e)()}_PickFirstAbsoluteUpdate(t,e){return(this.GetFirstAbsoluteUpdate()?(this.SetFirstAbsoluteUpdate(!1),t):e)()}_GetAbsoluteInitialValue(t){}_GetIndex(){return this._sourceAdapter.GetIndex()}_GetTarget(){return this._target||(this._target=this._sourceAdapter.GetTarget()),this._target}_PickSource(t,e,r,a,s,o){const i=this._propertyTrack.GetSourceAdapterId();switch(i){case"behavior":return t();case"effect":return e();case"instance-variable":return r();case"plugin":return a();case"world-instance":return s();case"audio":return o()}}_SaveToJson(){return{"firstAbsoluteUpdate":this._firstAbsoluteUpdate,"saveState":this._saveState}}_LoadFromJson(t){t&&(this._firstAbsoluteUpdate=t["firstAbsoluteUpdate"],this._saveState=t["saveState"])}_GetPropertyKeyframeStubs(t,e=!1){const r=[];for(const a of t){const s=a.GetTrack().GetStartOffset();for(const o of a.GetPropertyKeyframeDataItems())(!e||0!==o.GetTime())&&e||r.push({time:s+o.GetTime(),value:o.GetAbsoluteValue()})}return r.sort((t,e)=>t.time-e.time)}_GetLastPropertyKeyframeStub(t,e,r){return this._GetPropertyKeyframeStubLowerThanPlayhead(e,r)}_GetPropertyKeyframeStubLowerThanPlayhead(e,r){for(let t=r.length-1;0<=t;t--){const a=r[t].time;if(a<=e)return r[t]}return null}}; } // timelines/state/propertyInterpolationAdapters/colorInterpolationAdapter.js { const C3=self.C3,TMP_COLORS_MAP=new Map,TMP_COLOR=[0,0,0];class ColorInterpolationAdapter extends C3.PropertyTrackState.PropertyInterpolationAdapter{constructor(e){super(e)}SetResetState(){}SetInitialState(){}SetResumeState(){}GetCurrentState(){const e=this._propertyTrack.GetSourceAdapterId(),t=this._GetTarget(),r=this._GetIndex();switch(e){case"behavior":return this._ToColorArray(t.GetPropertyValueByIndex(r));case"effect":return this._ToColorArray(t[r]);case"plugin":return this._ToColorArray(t.GetPropertyValueByIndex(r));case"world-instance":return this._ToColorArray(this._Getter())}}CompareInitialStateWithCurrent(){const e=this._FirstKeyframeGetter();return!this._CompareColors(e,this._Getter())}CompareSaveStateWithCurrent(){return!C3.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(C3.IsInstanceOf(e,C3.Color)?e.toArray():e).slice(0,3)}_GetColorFromArray(e){return C3.IsInstanceOf(e,C3.Color)?e:new C3.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(),r=this._propertyTrack.GetSourceAdapter(),o=e.GetSimilarPropertyTracks(t,r,this._property,this._propertyTrack);if(o&&1<o.length){TMP_COLORS_MAP.has(t)||TMP_COLORS_MAP.set(t,new Map);const a=TMP_COLORS_MAP.get(t),s=this._propertyTrack.GetSourceAdapterId(),n=(a.has(s)||a.set(s,new Map),a.get(s));n.has(this._property)||n.set(this._property,{used:!1,color:new C3.Color(0,0,0,1)})}}_GetTmpColor(e,t,r){const o=TMP_COLORS_MAP.get(e).get(t).get(r);return o.used=!0,o.color}ChangeProperty(e,t,r,o,a,s,n,i){const p=this._propertyTrack.GetTimeline(),_=this._propertyTrack.GetTrack(),l=this._propertyTrack.GetInstance(),c=this._propertyTrack.GetSourceAdapter(),h=this._propertyTrack.GetSourceAdapterId(),C=this._property,y=p.GetSimilarPropertyTracks(l,c,C,this._propertyTrack);if(y&&1<y.length){const u=this._GetPropertyKeyframeStubs(y,!0),G=this._GetLastPropertyKeyframeStub(p,p.GetTime(),u);if(G){const T=_.GetStartOffset(),d=G.time-T;if(0==d)this._GetTmpColor(l,h,this._property).addRgb(t[0],t[1],t[2]);else if(!(d<0)){const P=t[0],S=t[1],f=t[2],A=this._propertyTrack.Interpolate(d,!1,!0),O=C3.Color.DiffChannel(P,A[0]),I=C3.Color.DiffChannel(S,A[1]),m=C3.Color.DiffChannel(f,A[2]);this._GetTmpColor(l,h,this._property).addRgb(O,I,m)}}}else this._Setter(t[0],t[1],t[2])}AfterChangeProperty(){const e=this._propertyTrack.GetInstance();if(TMP_COLORS_MAP.has(e)){const t=TMP_COLORS_MAP.get(e),r=this._propertyTrack.GetSourceAdapterId();if(t.has(r)){const o=t.get(r);if(o.has(this._property)){const a=o.get(this._property),s=a.used,n=a.color;s&&this._Setter(n.getR(),n.getG(),n.getB()),0===o.size&&t.delete(r),0===t.size&&TMP_COLORS_MAP.delete(e)}}}}_Getter(){const e=this._propertyTrack.GetSourceAdapterId(),t=this._GetTarget(),r=this._GetIndex();switch(e){case"behavior":return this._GetColorFromArray(t.GetPropertyValueByIndex(r));case"effect":return t[r].clone();case"plugin":return this._GetColorFromArray(t.GetPropertyValueByIndex(r));case"world-instance":return this.GetWorldInfo().GetUnpremultipliedColor().clone()}}_Setter(e,t,r){const o=this._propertyTrack.GetSourceAdapterId(),a=this._GetTarget(),s=this._GetIndex();switch(o){case"behavior":TMP_COLOR[0]=e,TMP_COLOR[1]=t,TMP_COLOR[2]=r,a.SetPropertyValueByIndex(s,TMP_COLOR);break;case"effect":a[s].setRgb(e,t,r);break;case"plugin":TMP_COLOR[0]=e,TMP_COLOR[1]=t,TMP_COLOR[2]=r,a.SetPropertyValueByIndex(s,TMP_COLOR);break;case"world-instance":this.GetWorldInfo().SetUnpremultipliedColorRGB(e,t,r)}}_SaveToJson(){}_LoadFromJson(e){}}C3.PropertyTrackState.PropertyInterpolationAdapter.ColorInterpolationAdapter=ColorInterpolationAdapter; } // timelines/state/propertyInterpolationAdapters/noInterpolationAdapter.js { const C3=self.C3,NS=C3.PropertyTrackState;class NoInterpolationAdapter extends C3.PropertyTrackState.PropertyInterpolationAdapter{constructor(e){super(e)}SetResetState(){}SetInitialState(){}SetResumeState(){}GetCurrentState(){return this._Getter()}CompareInitialStateWithCurrent(){const e=this._FirstKeyframeGetter();return e!==this.GetCurrentState()}CompareSaveStateWithCurrent(){return!C3.IsNullOrUndefined(this._saveState)&&this._saveState!==this.GetCurrentState()}MayNeedBeforeAndAfterInterpolate(){return!1}ChangeProperty(e,t,r,a,n,s,i,o){const p=this._propertyTrack,c=p.GetTrack(),l=p.GetSourceAdapterId(),h=p.GetTimeline(),u=c.GetInstance(),S=p.GetSourceAdapter(),G=this._property,d=h.GetSimilarPropertyTracks(u,S,G,p);if(d&&1<d.length){const _=this._GetPropertyKeyframeStubs(d),I=e+c.GetStartOffset(),T=this._GetLastPropertyKeyframeStub(h,I,_);T&&(t=T.value)}const y=p.GetPropertyKeyframeType();switch(y){case"numeric":if(NS.NumericTypeAdapter.WillChange(this._GetIndex(),this._GetTarget(),t,l))break;return;case"angle":if(NS.AngleTypeAdapter.WillChange(this._GetIndex(),this._GetTarget(),t,l))break;return;case"boolean":if(NS.BooleanTypeAdapter.WillChange(this._GetIndex(),this._GetTarget(),t,l))break;return;case"color":if(NS.ColorTypeAdapter.WillChange(this._GetIndex(),this._GetTarget(),t,l))break;return;case"text":if(!NS.TextTypeAdapter.WillChange(this._GetIndex(),this._GetTarget(),t,l))return}this._Setter(t)}_Getter(){const e=this._propertyTrack.GetSourceAdapterId(),t=this._GetTarget(),r=this._GetIndex();switch(e){case"behavior":return t.GetPropertyValueByIndex(r);case"effect":return t[r];case"instance-variable":return t.GetInstanceVariableValue(r);case"plugin":return t.GetPropertyValueByIndex(r)}}_Setter(e){const t=this._propertyTrack.GetSourceAdapterId(),r=this._GetTarget(),a=this._GetIndex();switch(t){case"behavior":r.SetPropertyValueByIndex(a,e);break;case"effect":r[a]=e;break;case"instance-variable":r.SetInstanceVariableValue(a,e);break;case"plugin":r.SetPropertyValueByIndex(a,e)}}}C3.PropertyTrackState.PropertyInterpolationAdapter.NoInterpolationAdapter=NoInterpolationAdapter; } // timelines/state/propertyInterpolationAdapters/numericInterpolationAdapter.js { const C3=self.C3,NS=C3.PropertyTrackState.PropertyInterpolationAdapter,INSTANCE_FUNC_MAP=new Map,add=(t,e,r,a,i,s=!1,o=null,n=null)=>{INSTANCE_FUNC_MAP.set(t,{setter:e,absolute_setter:r,getter:a,round:i,fRound:s,init:o,reset:n})};add("offsetX",(t,e,r,a)=>{"relative"===a._propertyTrack.GetResultMode()?t.OffsetX(e,r.GetTimeline().GetTransformWithSceneGraph()):t.OffsetX(e)},(t,e)=>t.SetX(e),t=>t.GetX(),!0),add("offsetY",(t,e,r,a)=>{"relative"===a._propertyTrack.GetResultMode()?t.OffsetY(e,r.GetTimeline().GetTransformWithSceneGraph()):t.OffsetY(e)},(t,e)=>t.SetY(e),t=>t.GetY(),!0),add("offsetWidth",(e,t,a,i,r)=>{if(0!==t){const s="relative"===i._propertyTrack.GetResultMode(),o=1===i._typeAdapter.GetType();if((s||o)&&e.HasParent()&&e.GetTransformWithParentWidth()){if(isNaN(i._absoluteToFactor)){const n=[];let t=e.GetParent();for(;t;)n.push(t),t=t.GetParent();n.reverse();const c=(t,e)=>e.GetTimeline().GetTrackFromInstance(t.GetInstance()),l=(t,e)=>{const r=c(t,e);if(r)return r.GetOriginalWidth();const a=t.GetInstance().GetSdkInstance();return a.IsOriginalSizeKnown()?a.GetOriginalWidth():t._GetSceneGraphInfo()._GetStartWidth()},p=(t,e,r,a=0)=>{const i=c(t,e);if(!i)return a;const s=i.GetPropertyTrack(r);if(!s)return a;const o=s.GetPropertyTrackDataItem().GetPropertyKeyframeData();if(!o)return a;const n=o.GetLastPropertyKeyframeDataItem();return n?n.GetValue():a};let r;if(o){let t=n[n.length-1];r=t.GetWidth()}else{let e=n[0];const _=e._GetSceneGraphInfo()._GetStartWidth(),h=e._GetSceneGraphInfo().GetStartScaleX();r=_*h,r=(r+=p(e,a,"offsetWidth"))+l(e,a)*p(e,a,"offsetScaleX");for(let t=1;t<n.length;t++){const u=(e=n[t])._GetSceneGraphInfo().GetStartScaleX();r=(r=(r*=u)+p(e,a,"offsetWidth"))+l(e,a)*p(e,a,"offsetScaleX")}}i._absoluteToFactor=0===r?Number.EPSILON:r}r||e.OffsetWidth(t/i._absoluteToFactor,!0)}else e.OffsetWidth(t)}},(t,e)=>t.SetWidth(e),t=>t.GetWidth(),!0),add("offsetHeight",(e,t,a,i,r)=>{if(0!==t){const s="relative"===i._propertyTrack.GetResultMode(),o=1===i._typeAdapter.GetType();if((s||o)&&e.HasParent()&&e.GetTransformWithParentHeight()){if(isNaN(i._absoluteToFactor)){const n=[];let t=e.GetParent();for(;t;)n.push(t),t=t.GetParent();n.reverse();const c=(t,e)=>{a=t;const r=e.GetTimeline().GetTrackFromInstance(a.GetInstance());var a;if(r)return r.GetOriginalHeight();const i=t.GetInstance().GetSdkInstance();return i.IsOriginalSizeKnown()?i.GetOriginalHeight():t._GetSceneGraphInfo()._GetStartHeight()},l=(t,e,r,a=0)=>{const i=e.GetTimeline().GetTrackFromInstance(t.GetInstance());if(!i)return a;const s=i.GetPropertyTrack(r);if(!s)return a;const o=s.GetPropertyTrackDataItem().GetPropertyKeyframeData();if(!o)return a;const n=o.GetLastPropertyKeyframeDataItem();return n?n.GetValue():a};let r;if(o){let t=n[n.length-1];r=t.GetHeight()}else{let e=n[0];const p=e._GetSceneGraphInfo()._GetStartHeight(),_=e._GetSceneGraphInfo().GetStartScaleY();r=p*_,r=(r+=l(e,a,"offsetHeight"))+c(e,a)*l(e,a,"offsetScaleY");for(let t=1;t<n.length;t++){const h=(e=n[t])._GetSceneGraphInfo().GetStartScaleY();r=(r=(r*=h)+l(e,a))+c(e,a)*l(e,a,"offsetScaleY")}}i._absoluteToFactor=0===r?Number.EPSILON:r}r||e.OffsetHeight(t/i._absoluteToFactor,!0)}else e.OffsetHeight(t)}},(t,e)=>t.SetHeight(e),t=>t.GetHeight(),!0),add("offsetAngle",(t,e,r,a,i)=>{t.OffsetAngle(e)},(t,e)=>t.SetAngle(e),t=>t.GetAngle(),!1,!0),add("offsetOpacity",(t,e,r,a,i)=>{const s=a._opacityFactor||1,o=(e/=s,t.GetOpacity()),n=o+e;if(0===a._clampAccumulator)1<n?a._clampAccumulator+=n-1:n<0&&(a._clampAccumulator+=n),t.OffsetOpacity(e);else{const n=t.GetOpacity()+e;0<e&&0<a._clampAccumulator?1<n&&(a._clampAccumulator+=n-1):0<e&&a._clampAccumulator<0?(a._clampAccumulator+=e,0<a._clampAccumulator&&(t.OffsetOpacity(a._clampAccumulator),a._clampAccumulator=0)):e<0&&0<a._clampAccumulator?(a._clampAccumulator+=e,a._clampAccumulator<0&&(t.OffsetOpacity(a._clampAccumulator),a._clampAccumulator=0)):e<0&&a._clampAccumulator<0&&n<0&&(a._clampAccumulator+=n)}},(t,e)=>{t.SetOpacity(e)},t=>t.GetOpacity(),!1,!0,(r,a,i)=>{switch(r._clampAccumulator=0,r._propertyTrack.GetResultMode()){case"relative":{r._propertyTrack.GetPropertyTrackData();const s=r._propertyTrack.GetPropertyTrackDataItem(),o=s.GetPropertyKeyframeData(),n=o.GetPropertyKeyframeDataItemArray();let t=r.GetWorldInfo().GetOpacity(),e=t;for(const c of n){const l=c.GetTime(),p=r._propertyTrack.GetInterpolatedValue(l);e=t+p,e=C3.clamp(e,0,1)}r._totalForewardOpacityDelta=t-e,r._totalForewardOpacityDelta=Math.round(100*(r._totalForewardOpacityDelta+Number.EPSILON))/100,e=t;for(let t=n.length-1;0<=t;t--){const _=n[t].GetTime(),h=r._propertyTrack.GetInterpolatedValue(_);e-=h,e=C3.clamp(e,0,1)}r._totalBackwardOpacityDelta=e,r._totalBackwardOpacityDelta=Math.round(100*(r._totalBackwardOpacityDelta+Number.EPSILON))/100;break}}const t="relative"===r._propertyTrack.GetResultMode(),e=1===r._typeAdapter.GetType();if((t||e)&&a.HasParent()&&a.GetTransformWithParentOpacity()){const u=[];let t=a.GetParent();for(;t;)u.push(t),t=t.GetParent();u.reverse();const f=(t,e,r)=>{const a=e.GetTimeline().GetTrackFromInstance(t.GetInstance());if(!a)return 0;const i=a.GetPropertyTrack(r);if(!i)return 0;const s=i.GetPropertyTrackDataItem().GetPropertyKeyframeData();if(!s)return 0;const o=s.GetLastPropertyKeyframeDataItem();return o?o.GetValue():0};let e=u[0]._GetSceneGraphInfo().GetStartOpacity();e+=f(u[0],i,"offsetOpacity");for(let t=1;t<u.length;t++)e+=f(u[t],i,"offsetOpacity");r._opacityFactor=0===e?1:e}},e=>{switch(e._propertyTrack.GetResultMode()){case"relative":{e._clampAccumulator=0;const r=e.GetWorldInfo();let t=r.GetOpacity();t=Math.round(100*(t+Number.EPSILON))/100,e._propertyTrack.GetTimeline().IsForwardPlayBack()?(r.SetOpacity(t+e._totalForewardOpacityDelta),e._lastValue=0):(r.SetOpacity(t-e._totalBackwardOpacityDelta),e._lastValue=e.GetSourceAdapter().GetValueAtTime());break}}}),add("offsetOriginX",(t,e)=>t.OffsetOriginX(e),(t,e)=>t.SetOriginX(e),t=>t.GetOriginX(),!1),add("offsetOriginY",(t,e)=>t.OffsetOriginY(e),(t,e)=>t.SetOriginY(e),t=>t.GetOriginY(),!1),add("offsetZElevation",(t,e)=>t.OffsetZElevation(e),(t,e)=>t.SetZElevation(e),t=>t.GetZElevation(),!0),add("offsetScaleX",(t,e,r,a)=>{if(0!==e){const i=t.GetWidth()<0?-1:1;if("relative"===a._propertyTrack.GetResultMode()&&t.HasParent()&&t.GetTransformWithParentWidth()){const s=r.GetOriginalWidth()*i*e;isNaN(a._absoluteToFactor)&&INSTANCE_FUNC_MAP.get("offsetWidth").setter(t,1,r,a,!0),t.OffsetWidth(s/a._absoluteToFactor,!0)}else t.OffsetWidth(r.GetOriginalWidth()*i*e)}},(t,e,r)=>{t.SetWidth(r.GetOriginalWidth()*e)},(e,r)=>{const a=e.GetWidth()<0?-1:1;if(e.GetTransformWithParentWidth()){const i=e.GetParent(),s=r.GetTimeline().GetTrackFromInstance(i.GetInstance());let t=NaN;if(s)t=i.GetWidth()/s.GetOriginalWidth();else{const o=i.GetInstance().GetSdkInstance();t=o.IsOriginalSizeKnown()?i.GetWidth()/o.GetOriginalWidth():1}return e.GetWidth()*a/(r.GetOriginalWidth()*t)}return e.GetWidth()*a/r.GetOriginalWidth()},!1),add("offsetScaleY",(t,e,r,a)=>{if(0!==e){const i=t.GetHeight()<0?-1:1;if("relative"===a._propertyTrack.GetResultMode()&&t.HasParent()&&t.GetTransformWithParentHeight()){const s=r.GetOriginalHeight()*i*e;isNaN(a._absoluteToFactor)&&INSTANCE_FUNC_MAP.get("offsetHeight").setter(t,1,r,a,!0),t.OffsetHeight(s/a._absoluteToFactor,!0)}else t.OffsetHeight(r.GetOriginalHeight()*i*e)}},(t,e,r)=>{t.SetHeight(r.GetOriginalHeight()*e)},(e,r)=>{const a=e.GetHeight()<0?-1:1;if(e.GetTransformWithParentHeight()){const i=e.GetParent(),s=r.GetTimeline().GetTrackFromInstance(i.GetInstance());let t=NaN;if(s)t=i.GetHeight()/s.GetOriginalHeight();else{const o=i.GetInstance().GetSdkInstance();t=o.IsOriginalSizeKnown()?i.GetHeight()/o.GetOriginalHeight():1}return e.GetHeight()*a/(r.GetOriginalHeight()*t)}return e.GetHeight()*a/r.GetOriginalHeight()},!1);class NumericInterpolationAdapter extends C3.PropertyTrackState.PropertyInterpolationAdapter{constructor(t){super(t),this._lastValue=0,this._clampAccumulator=0,this._totalForewardOpacityDelta=0,this._totalBackwardOpacityDelta=0,this._opacityFactor=NaN,this._absoluteToFactor=NaN,this._angleReflectMirrorOrFlip=void 0,this._angleReflectMirrorAndFlip=void 0,this._instance_getter=null,this._instance_setter=null,this._instance_absolute_setter=null,this._reset_action=null,this._init_action=null,this._source_adapter_getter=null,this._source_adapter_setter=null,this._source_adapter_absolute_setter=null,this._round=!1,this._fRound=!1,C3.IsInstanceOf(this._propertyTrack.GetTimeline(),C3.TweenState)?this._typeAdapter=new C3.PropertyTrackState.PropertyInterpolationAdapter.NumericInterpolationAdapterForTween(this):this._typeAdapter=new C3.PropertyTrackState.PropertyInterpolationAdapter.NumericInterpolationAdapterForTimeline(this);const e=this._propertyTrack.GetPropertyName();switch(this._propertyTrack.GetSourceAdapterId()){case"world-instance":{const r=INSTANCE_FUNC_MAP.get(e);this._instance_getter=r.getter,this._instance_setter=r.setter,this._instance_absolute_setter=r.absolute_setter,this._round=r.round,this._fRound=r.fRound,this._init_action=r.init,this._reset_action=r.reset;break}case"audio":this._source_adapter_getter=t.Getter,this._source_adapter_setter=t.Setter,this._source_adapter_absolute_setter=t.AbsoluteSetter,this._round=!!t.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(t){this._lastValue=t}SetResetState(){this._reset_action&&this._reset_action(this)}SetInitialState(){const t=this._typeAdapter.SetInitialState();if("number"==typeof t&&(this._lastValue=t),this._init_action){const e=this.GetWorldInfo(),r=this._propertyTrack.GetTrack();this._init_action(this,e,r)}}SetResumeState(){const t=this._typeAdapter.SetResumeState();"number"==typeof t&&(this._lastValue=t)}GetCurrentState(){return this._Getter()}CompareInitialStateWithCurrent(){const t=this._FirstKeyframeGetter();return t!==this.GetCurrentState()}CompareSaveStateWithCurrent(){return!C3.IsNullOrUndefined(this._saveState)&&this._saveState!==this.GetCurrentState()}BeforeChangeProperty(){this._typeAdapter.BeforeChangeProperty()}ChangeProperty(t,e,r,a,i,s,o,n){return this._typeAdapter.ChangeProperty(t,e,r,a,i,s,o,n)}AfterChangeProperty(){this._typeAdapter.AfterChangeProperty()}_Getter(){const t=this._GetTarget(),e=this._GetIndex(),r=this.GetWorldInfo(),a=this._propertyTrack.GetTrack(),i=this._propertyTrack.GetSourceAdapterId();switch(i){case"behavior":return t.GetPropertyValueByIndex(e);case"effect":return t[e];case"instance-variable":return t.GetInstanceVariableValue(e);case"plugin":return t.GetPropertyValueByIndex(e);case"world-instance":return this._instance_getter(r,a);case"audio":return this._source_adapter_getter.call(this.GetSourceAdapter(),r,a)}}_Setter(t,e,r){const a=this._GetTarget(),i=this._GetIndex(),s=this.GetWorldInfo(),o=this._propertyTrack.GetTrack(),n=this._propertyTrack.GetSourceAdapterId();switch(n){case"behavior":a.OffsetPropertyValueByIndex(i,t);break;case"effect":a[i]+=t;break;case"instance-variable":a.SetInstanceVariableOffset(i,t);break;case"plugin":a.OffsetPropertyValueByIndex(i,t,this.GetSourceAdapter().GetOptionalCallbacks());break;case"world-instance":this._instance_setter(s,t,o,this);break;case"audio":this._source_adapter_setter.call(this.GetSourceAdapter(),s,t,o,this)}}_SetterAbsolute(t,e,r){let a=this._propertyTrack.GetInterpolationMode();if("discrete"!==(a="default"===a?"continuous":a)||e){if("discrete"===a&&r){const l=this._propertyTrack.GetTimeline(),p=l.GetTime(),_=this._propertyTrack.GetPropertyKeyFrameDataItemAtTime(p);if(!_)return}const i=this._GetTarget(),s=this._GetIndex(),o=this.GetWorldInfo(),n=this._propertyTrack.GetTrack(),c=this._propertyTrack.GetSourceAdapterId();switch(c){case"behavior":i.SetPropertyValueByIndex(s,t);break;case"effect":i[s]=t;break;case"instance-variable":i.SetInstanceVariableValue(s,t);break;case"plugin":i.SetPropertyValueByIndex(s,t,this.GetSourceAdapter().GetOptionalCallbacks());break;case"world-instance":this._instance_absolute_setter(o,t,n);break;case"audio":this._source_adapter_absolute_setter.call(this.GetSourceAdapter(),o,t,n)}}}_MaybeEnsureValue(t,e,r,a,i,s,o,n){this._typeAdapter._MaybeEnsureValue(t,e,r,a,i,s,o,n)}_AddDelta(t,e,r,a,i){const s=(t="angle"===this._propertyTrack.GetPropertyType()?C3.toDegrees(t):t).toString(),o=s.split(".")[1]||"",n=o.length,c=this._Getter();let l;switch(l=0===n?this._round?Math.round(c):this._fRound?"angle"===this._propertyTrack.GetPropertyType()?C3.toRadians(Math.round(C3.toDegrees(c))):Number(C3.toFixed(c,2)):c:this._round?Number(C3.toFixed(c,n)):(this._fRound,c),this._Setter(l-c,e,r),this._propertyTrack.GetPropertyName()){case"offsetWidth":case"offsetScaleX":{const p=this.GetWorldInfo(),_=p.GetWidth(),h=Number(C3.toFixed(_,2));p.OffsetWidth(h-_);break}case"offsetHeight":case"offsetScaleY":{const u=this.GetWorldInfo(),f=u.GetHeight(),d=Number(C3.toFixed(f,2));u.OffsetHeight(d-f);break}}}_SaveToJson(){return Object.assign(super._SaveToJson(),{"v":this._lastValue,"a":this._clampAccumulator,"fod":this._totalForewardOpacityDelta,"bod":this._totalBackwardOpacityDelta,"of":this._opacityFactor,"sf":this._absoluteToFactor,"armorf":this._angleReflectMirrorOrFlip,"armandf":this._angleReflectMirrorAndFlip})}_LoadFromJson(t){t&&(super._LoadFromJson(t),this._lastValue=t["v"],this._clampAccumulator=t["a"],this._totalForewardOpacityDelta=C3.IsFiniteNumber(t["fod"])?t["fod"]:0,this._totalBackwardOpacityDelta=C3.IsFiniteNumber(t["bod"])?t["bod"]:0,this._opacityFactor=C3.IsFiniteNumber(t["of"])?t["of"]:NaN,this._absoluteToFactor=C3.IsFiniteNumber(t["sf"])?t["sf"]:NaN,this._angleReflectMirrorOrFlip=C3.IsFiniteNumber(t["armorf"])?t["armorf"]:void 0,this._angleReflectMirrorAndFlip=C3.IsFiniteNumber(t["armandf"])?t["armandf"]:void 0)}}C3.PropertyTrackState.PropertyInterpolationAdapter.NumericInterpolationAdapter=NumericInterpolationAdapter; } // timelines/state/propertyInterpolationAdapters/numericInterpolationAdapterForTimeline.js { const C3=self.C3;class AbsoluteValueObject{constructor(e){this._used=!1,this._value=0,this._propertyKeyframeReached=!1,this._endState=!1,this._propertyTracks=e;for(let e=0,t=this._propertyTracks.length;e<t;e++)this._propertyTracks[e].SetAbsoluteValueObject(this)}GetPropertyTracks(){return this._propertyTracks}SetUsed(){this._used=!0}GetUsed(){return this._used}SetValue(e){this._value=e}GetValue(){return this._value}SetPropertyKeyframeReached(e){this._propertyKeyframeReached=e}GetPropertyKeyframeReached(){return this._propertyKeyframeReached}SetEndState(e){this._endState=e}GetEndState(){return this._endState}Reset(){this._used=!1,this._value=0,this._propertyKeyframeReached=!1,this._endState=!1}}class NumericInterpolationAdapterForTimeline{constructor(e){this._numericInterpolationAdapter=e}Release(){this._numericInterpolationAdapter=null}GetType(){return 0}SetInitialState(){const e=this._numericInterpolationAdapter;this._numericInterpolationAdapter.GetPropertyTrack();return e._PickResultMode(()=>e._PickTimelinePlaybackMode(()=>0,()=>e.GetSourceAdapter().GetValueAtTime()),()=>{})}SetResumeState(){}MayNeedBeforeAndAfterInterpolate(){this._numericInterpolationAdapter;const e=this._numericInterpolationAdapter.GetPropertyTrack();switch(e.GetResultMode()){case"relative":return!1;case"absolute":return!0}}BeforeChangeProperty(){this._numericInterpolationAdapter;const e=this._numericInterpolationAdapter.GetPropertyTrack(),t=e.GetPropertyName();switch(e.GetResultMode()){case"relative":break;case"absolute":if(e.HasAbsoluteValueObject()){const r=e.GetAbsoluteValueObject();r.Reset()}else{const a=e.GetTimeline(),s=e.GetInstance(),o=e.GetSourceAdapter(),i=a.GetSimilarPropertyTracks(s,o,t,e);i&&1<i.length&&new AbsoluteValueObject(i)}}}ChangeProperty(e,t,r,a,s,o,i,n){const l=this._numericInterpolationAdapter,u=this._numericInterpolationAdapter.GetPropertyTrack();switch(u.GetResultMode()){case"relative":{const c=l.GetLastValue();l._Setter(t-c,r,a),o&&this._MaybeEnsureValue(e,r,a,s,c,t),l.SetLastValue(t);break}case"absolute":{const p=u.GetTimeline(),d=u.GetTrack();u.GetInstance(),u.GetSourceAdapter();if(u.HasAbsoluteValueObject()){const h=u.GetAbsoluteValueObject(),G=h.GetPropertyTracks(),y=l._GetPropertyKeyframeStubs(G,!0),_=l._GetLastPropertyKeyframeStub(p,p.GetTime(),y);if(_){const m=d.GetStartOffset(),A=_.time-m;if(0==A)h.SetEndState(i),h.SetPropertyKeyframeReached(n),h.SetUsed(),h.SetValue(h.GetValue()+t);else{if(A<0)return;const S=u.GetInterpolatedValue(A);h.SetEndState(i),h.SetPropertyKeyframeReached(n),h.SetUsed(),h.SetValue(h.GetValue()+(t-S))}}}else l._SetterAbsolute(t,n,i);break}}}AfterChangeProperty(){const e=this._numericInterpolationAdapter,t=this._numericInterpolationAdapter.GetPropertyTrack();switch(t.GetResultMode()){case"relative":break;case"absolute":if(t.HasAbsoluteValueObject()){const r=t.GetAbsoluteValueObject();r.GetUsed()&&e._SetterAbsolute(r.GetValue(),r.GetPropertyKeyframeReached(),r.GetEndState())}}}_MaybeEnsureValue(e,t,r,a,s,o){const i=this._numericInterpolationAdapter;a||(t&&e===t.GetTime()?i._AddDelta(t.GetValueWithResultMode(),t,r):r&&e===r.GetTime()?i._AddDelta(r.GetValueWithResultMode(),t,r):o-s==0&&i._AddDelta(t.GetValueWithResultMode(),t,r))}}C3.PropertyTrackState.PropertyInterpolationAdapter.NumericInterpolationAdapterForTimeline=NumericInterpolationAdapterForTimeline; } // timelines/state/propertyInterpolationAdapters/numericInterpolationAdapterForTween.js { const C3=self.C3;class NumericInterpolationAdapterForTween{constructor(e){this._numericInterpolationAdapter=e}Release(){this._numericInterpolationAdapter=null}GetType(){return 1}SetInitialState(){const e=this._numericInterpolationAdapter;return e.SetFirstAbsoluteUpdate(!0),this._GetAbsoluteInitialValue(e._FirstKeyframeGetter())}SetResumeState(){const e=this._numericInterpolationAdapter;if(e._FirstKeyframeGetter()!==e._CurrentKeyframeGetter())return e.SetFirstAbsoluteUpdate(!0),this._GetAbsoluteInitialValue(e._CurrentKeyframeGetter())}MayNeedBeforeAndAfterInterpolate(){return!1}BeforeChangeProperty(){}ChangeProperty(e,t,r,a,n,i,o,l){const s=this._numericInterpolationAdapter,u=s.GetLastValue();switch(s.GetPropertyTrack().GetResultMode()){case"relative":s._Setter(t-u,r,a),i&&this._MaybeEnsureValue(e,r,a,n,u,t,!1,o);break;case"absolute":s.GetFirstAbsoluteUpdate()?(s.SetFirstAbsoluteUpdate(!1),s._Setter(u,r,a)):0===e&&0===s.GetPropertyTrack().GetTimeline().GetTotalTime()?s._SetterAbsolute(t,!0,!1):(s._Setter(t-u,r,a),i&&this._MaybeEnsureValue(e,r,a,n,u,t,this._ForceEndValue(),o))}s.SetLastValue(t)}AfterChangeProperty(){}_GetAbsoluteInitialValue(e){const t=this._numericInterpolationAdapter;return e-t.GetCurrentState()}_ForceEndValue(){const e=this._numericInterpolationAdapter,t=e.GetWorldInfo().GetInstance(),r=e.GetPropertyTrack().GetRuntime(),a=r.GetTimelineManager();let n=0;for(const i of a.GetPlayingTimelines())0===i.GetType()?i.HasTrackInstance(t)&&n++:1===i.GetType()&&i.GetInstance()===t&&n++;return n<=1}_MaybeEnsureValue(e,t,r,a,n,i,o,l){const s=this._numericInterpolationAdapter;a?t&&e===t.GetTime()?s._AddDelta(t.GetValueWithResultMode(),t,r,o,l):r&&e===r.GetTime()?s._AddDelta(r.GetValueWithResultMode(),t,r,o,l):r||s._AddDelta(t.GetValueWithResultMode(),t,r,o,l):t&&e===t.GetTime()?s._AddDelta(t.GetValueWithResultMode(),t,r,o,l):r&&e===r.GetTime()?s._AddDelta(r.GetValueWithResultMode(),t,r,o,l):i-n==0&&s._AddDelta(t.GetValueWithResultMode(),t,r,o,l)}}C3.PropertyTrackState.PropertyInterpolationAdapter.NumericInterpolationAdapterForTween=NumericInterpolationAdapterForTween; } // timelines/state/propertyTypeAdapters/numericTypeAdapter.js { const C3=self.C3,Ease=self.Ease;C3.PropertyTrackState.NumericTypeAdapter=class{constructor(){}static WillChange(e,t,a,r){let s;switch(r){case"behavior":s=t.GetPropertyValueByIndex(e);break;case"effect":s=t[e];break;case"instance-variable":s=t.GetInstanceVariableValue(e);break;case"plugin":s=t.GetPropertyValueByIndex(e)}return s!==a}static Interpolate(t,a,r,s){if(!r){let e=s.GetPropertyTrackDataItem();const i=s.GetPropertyTrackData();return(e=i.GetLastPropertyKeyframeDataItem(e)).GetValueWithResultMode()}let n=s.GetInterpolationMode();if("default"===n&&(n="continuous"),"discrete"===(n="combo"===s.GetPropertyType()?"discrete":n))return a.GetValueWithResultMode();if("continuous"===n||"step"===n){const o=s.GetTimeline().GetStep();if("step"===n&&0!==o){const m=1/o;t=Math.floor(t*m)/m}const c=a.GetValueWithResultMode(),l=r.GetValueWithResultMode(),u=a.GetAddOn("cubic-bezier"),G=r.GetAddOn("cubic-bezier"),p=u&&u.GetStartEnable()&&G&&G.GetEndEnable();if(!p&&c===l)return c;const d=a.GetTime(),b=r.GetTime(),f=("step"===n&&0!==o&&(t=C3.clamp(t,d,b)),C3.normalize(t,d,b)),y=a.GetEase();let e;if(p){const E=b-d;e=Ease.GetRuntimeEase(y)(E*f,0,1,E),e=Ease.GetRuntimeEase("cubicbezier")(e,c,c+u.GetStartAnchor(),l+G.GetEndAnchor(),l)}else e=Ease.GetRuntimeEase(y)((b-d)*f,c,l-c,b-d);return"integer"===s.GetPropertyType()?Math.floor(e):e}}}; } // timelines/state/propertyTypeAdapters/angleTypeAdapter.js { const C3=self.C3;C3.PropertyTrackState.AngleTypeAdapter=class{constructor(){}static WillChange(e,t,a,r){let s;switch(r){case"behavior":s=t.GetPropertyValueByIndex(e);break;case"effect":s=t[e];break;case"instance-variable":s=t.GetInstanceVariableValue(e);break;case"plugin":s=t.GetPropertyValueByIndex(e)}return s!==a}static Interpolate(e,t,a,r){if(!a){let e=r.GetPropertyTrackDataItem();const n=r.GetPropertyTrackData();return(e=n.GetLastPropertyKeyframeDataItem(e)).GetValueWithResultMode()}let s=r.GetInterpolationMode();if("default"===s&&(s="continuous"),"discrete"===(s="combo"===r.GetPropertyType()?"discrete":s))return t.GetValueWithResultMode();if("continuous"===s||"step"===s){const o=r.GetTimeline().GetStep();if("step"===s&&0!==o){const p=1/o;e=Math.floor(e*p)/p}const i=t.GetTime(),l=a.GetTime(),c=t.GetValueWithResultMode(),u=a.GetValueWithResultMode(),G=("step"===s&&0!==o&&(e=C3.clamp(e,i,l)),t.GetAddOn("angle"));if(!G){if(c===u)return c;const f=C3.normalize(e,i,l),d=self.Ease.GetRuntimeEase(t.GetEase());return C3.angleLerp(c,u,d(f,0,1,1))}{const C=G.GetRevolutions();if(c===u&&0===C)return c;const m=C3.normalize(e,i,l),y=self.Ease.GetRuntimeEase(t.GetEase()),k=y(m,0,1,1);switch(G.GetDirection()){case"closest":return C3.angleLerp(c,u,k,C);case"clockwise":return C3.angleLerpClockwise(c,u,k,C);case"anti-clockwise":return C3.angleLerpAntiClockwise(c,u,k,C)}}}}}; } // timelines/state/propertyTypeAdapters/booleanTypeAdapter.js { const C3=self.C3;C3.PropertyTrackState.BooleanTypeAdapter=class{constructor(){}static WillChange(e,t,a,r){let c;switch(r){case"behavior":c=t.GetPropertyValueByIndex(e);break;case"effect":c=t[e];break;case"instance-variable":c=t.GetInstanceVariableValue(e);break;case"plugin":c=t.GetPropertyValueByIndex(e)}return!!c!=!!a}static Interpolate(e,t,a,r){if(a)return t.GetValueWithResultMode()?1:0;{let e=r.GetPropertyTrackDataItem();const c=r.GetPropertyTrackData();return(e=c.GetLastPropertyKeyframeDataItem(e)).GetValueWithResultMode()?1:0}}}; } // timelines/state/propertyTypeAdapters/colorTypeAdapter.js { const C3=self.C3,TEMP_COLOR_ARRAY=[0,0,0],TEMP_COLOR_ARRAY_2=[0,0,0],TEMP_COLOR_ARRAY_3=[0,0,0];C3.PropertyTrackState.ColorTypeAdapter=class{constructor(){}static WillChange(R,e,_,t){let A;switch(t){case"behavior":A=e.GetPropertyValueByIndex(R);break;case"effect":A=e[R];break;case"instance-variable":A=e.GetInstanceVariableValue(R);break;case"plugin":A=e.GetPropertyValueByIndex(R)}return Array.isArray(_)?(TEMP_COLOR_ARRAY[0]=_[0],TEMP_COLOR_ARRAY[1]=_[1],TEMP_COLOR_ARRAY[2]=_[2]):(TEMP_COLOR_ARRAY_3.parseCommaSeparatedRgb(_),TEMP_COLOR_ARRAY[0]=Math.floor(255*TEMP_COLOR_ARRAY_3.getR()),TEMP_COLOR_ARRAY[1]=Math.floor(255*TEMP_COLOR_ARRAY_3.getG()),TEMP_COLOR_ARRAY[2]=Math.floor(255*TEMP_COLOR_ARRAY_3.getB())),Array.isArray(A)?(TEMP_COLOR_ARRAY_2[0]=A[0],TEMP_COLOR_ARRAY_2[1]=A[1],TEMP_COLOR_ARRAY_2[2]=A[2]):(TEMP_COLOR_ARRAY_3.parseCommaSeparatedRgb(A),TEMP_COLOR_ARRAY_2[0]=Math.floor(255*TEMP_COLOR_ARRAY_3.getR()),TEMP_COLOR_ARRAY_2[1]=Math.floor(255*TEMP_COLOR_ARRAY_3.getG()),TEMP_COLOR_ARRAY_2[2]=Math.floor(255*TEMP_COLOR_ARRAY_3.getB())),TEMP_COLOR_ARRAY[0]!==TEMP_COLOR_ARRAY_2[0]||TEMP_COLOR_ARRAY[1]!==TEMP_COLOR_ARRAY_2[1]||TEMP_COLOR_ARRAY[2]!==TEMP_COLOR_ARRAY_2[2]}static Interpolate(R,e,_,t){if(!_){let R=t.GetPropertyTrackDataItem();const O=t.GetPropertyTrackData(),a=(R=O.GetLastPropertyKeyframeDataItem(R)).GetValueWithResultMode();return TEMP_COLOR_ARRAY[0]=a[0],TEMP_COLOR_ARRAY[1]=a[1],TEMP_COLOR_ARRAY[2]=a[2],TEMP_COLOR_ARRAY}let A=t.GetInterpolationMode();if("discrete"===(A="default"===A?"continuous":A)){const r=e.GetValueWithResultMode();return TEMP_COLOR_ARRAY[0]=r[0],TEMP_COLOR_ARRAY[1]=r[1],TEMP_COLOR_ARRAY[2]=r[2],TEMP_COLOR_ARRAY}if("continuous"===A||"step"===A){const M=t.GetTimeline().GetStep();if("step"===A&&0!==M){const f=1/M;R=Math.floor(R*f)/f}const C=e.GetTime(),T=_.GetTime(),P=e.GetValueWithResultMode(),o=_.GetValueWithResultMode(),E=("step"===A&&0!==M&&(R=C3.clamp(R,C,T)),C3.normalize(R,C,T)),L=e.GetEase(),Y=P[0],s=P[1],l=P[2],i=o[0],n=o[1],c=o[2],u=self.Ease.GetRuntimeEase(L),p=T-C,G=p*E;return TEMP_COLOR_ARRAY[0]=Y===i?Y:u(G,Y,i-Y,p),TEMP_COLOR_ARRAY[1]=s===n?s:u(G,s,n-s,p),TEMP_COLOR_ARRAY[2]=l===c?l:u(G,l,c-l,p),TEMP_COLOR_ARRAY}}}; } // timelines/state/propertyTypeAdapters/textTypeAdapter.js { const C3=self.C3;C3.PropertyTrackState.TextTypeAdapter=class{constructor(){}static WillChange(e,t,a,r){let c;switch(r){case"behavior":c=t.GetPropertyValueByIndex(e);break;case"effect":c=t[e];break;case"instance-variable":c=t.GetInstanceVariableValue(e);break;case"plugin":c=t.GetPropertyValueByIndex(e)}return c!==a}static Interpolate(e,t,a,r){if(a)return t.GetValueWithResultMode();{let e=r.GetPropertyTrackDataItem();const c=r.GetPropertyTrackData();return(e=c.GetLastPropertyKeyframeDataItem(e)).GetValueWithResultMode()}}}; } // timelines/data/timelineDataManager.js { const C3=self.C3;C3.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 a=new C3.TimelineDataItem(e),t=a.GetName();this._timelineDataItems.set(t,a)}Get(e){return this._timelineDataItems.get(e)}GetNameId(){return 0}static _CreateDataItems(e,a,t,s){if(a)for(const i of a)C3.TimelineDataManager._CreateDataItem("create",i,e,t,s)}static _CreateDataItemsIncludingDisabled(e,a,t,s){if(a)for(const i of a)C3.TimelineDataManager._CreateDataItem("create-including-disabled",i,e,t,s)}static _LoadDataItemsFromJson(t,e,a,s){t.length?e.forEach((e,a)=>{t[a]._LoadFromJson(e)}):e.forEach(e=>{C3.TimelineDataManager._CreateDataItem("load",e,t,a,s)})}static _CreateDataItem(e,a,t,s,i){let n;if("function"==typeof s)switch(e){case"load":n=new s(null,i);break;case"create":case"create-including-disabled":n=new s(a,i)}else if("object"==typeof s){const c=s.prop,l=a[c],r=s.map.get(l);switch(e){case"load":n=new r(null,i);break;case"create":case"create-including-disabled":n=new r(a,i)}}switch(e){case"load":n._LoadFromJson(a),t.push(n);break;case"create":if("function"==typeof n.GetEnable&&!n.GetEnable())return n.Release();t.push(n);break;case"create-including-disabled":t.push(n)}}}; } // timelines/data/timelineData.js { const C3=self.C3,NAME=0,TOTAL_TIME=1,STEP=2,INTERPOLATION_MODE=3,RESULT_MODE=4,TRACKS=5,LOOP=6,PING_PONG=7,REPEAT_COUNT=8,START_ON_LAYOUT=9,TRANSFORM_WITH_SCENE_GRAPH=10,USE_SYSTEM_TIMESCALE=11;C3.TimelineDataItem=class{constructor(t){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,t&&(this._name=t[NAME],this._totalTime=t[TOTAL_TIME],this._step=t[STEP],this._interpolationMode=t[INTERPOLATION_MODE],this._resultMode=t[RESULT_MODE],this._loop=!!t[LOOP],this._pingPong=!!t[PING_PONG],this._repeatCount=t[REPEAT_COUNT],this._startOnLayout=t[START_ON_LAYOUT],this._transformWithSceneGraph=!!t[TRANSFORM_WITH_SCENE_GRAPH],this._useSystemTimescale=!!t[USE_SYSTEM_TIMESCALE],this._trackData=new C3.TrackData(t[TRACKS],this))}Release(){this._trackData.Release(),this._trackData=null}GetTrackData(){return this._trackData||(this._trackData=new C3.TrackData(null,this)),this._trackData}GetName(){return this._name}SetName(t){this._name=t}GetTotalTime(){return this._totalTime}SetTotalTime(t){this._totalTime=t}GetStep(){return this._step}SetStep(t){this._step=t}GetInterpolationMode(){return this._interpolationMode}SetInterpolationMode(t){this._interpolationMode=t}GetResultMode(){return this._resultMode}SetResultMode(t){this._resultMode=t}GetLoop(){return this._loop}SetLoop(t){this._loop=t}GetPingPong(){return this._pingPong}SetPingPong(t){this._pingPong=t}GetRepeatCount(){return this._repeatCount}SetRepeatCount(t){this._repeatCount=t}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(t){t&&(this.GetTrackData()._LoadFromJson(t["trackDataJson"]),this._name=t["name"],this._totalTime=t["totalTime"],this._step=t["step"],this._interpolationMode=t["interpolationMode"],this._resultMode=t["resultMode"],this._loop=t["loop"],this._pingPong=t["pingPong"],this._repeatCount=t["repeatCount"],this._startOnLayout=t["startOnLayout"],this._transformWithSceneGraph=!!t["transformWithSceneGraph"],this._useSystemTimescale=!!t["useSystemTimescale"])}}; } // timelines/data/trackData.js { const C3=self.C3,WI_DATA=0,OC_INDEX=1,WI_UID=2,INTERPOLATION_MODE=1,RESULT_MODE=2,ENABLED=3,KEYFRAMES=4,PROPERTY_TRACKS=5,ID=6,NESTED_DATA=7,START_OFFSET=0,LOCAL_TOTAL_TIME=1,WI_ADDITIONAL_DATA=8,ORIGINAL_WIDTH=0,ORIGINAL_HEIGHT=1,TRACK_TYPE=9,TRACK_NAME=10;class TrackDataItem{constructor(t,a){this._trackData=a,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="",t&&(t[WI_DATA]&&(this._instanceData=t[WI_DATA],this._instanceUid=t[WI_DATA][WI_UID],this._objectClassIndex=t[WI_DATA][OC_INDEX]),this._interpolationMode=t[INTERPOLATION_MODE],this._resultMode=t[RESULT_MODE],this._enabled=!!t[ENABLED],t[ID]&&(this._id=t[ID]),t[NESTED_DATA]&&(this._nestedData=t[NESTED_DATA],this._startOffset=t[NESTED_DATA][START_OFFSET],this._localTotalTime=t[NESTED_DATA][LOCAL_TOTAL_TIME]),t[WI_ADDITIONAL_DATA]&&(this._additionalInstanceData=t[WI_ADDITIONAL_DATA]),t[WI_ADDITIONAL_DATA]&&(this._additionalInstanceData=t[WI_ADDITIONAL_DATA]),t[TRACK_TYPE]&&(this._type=t[TRACK_TYPE]),t[TRACK_NAME]&&(this._name=t[TRACK_NAME]),this._keyframeData=new C3.KeyframeData(t[KEYFRAMES],this),this._propertyTrackData=new C3.PropertyTrackData(t[PROPERTY_TRACKS],this))}Release(){this._instanceData=null,this._trackData=null,this._keyframeData&&(this._keyframeData.Release(),this._keyframeData=null),this._propertyTrackData&&(this._propertyTrackData.Release(),this._propertyTrackData=null),this._nestedData=null}GetTrackData(){return this._trackData}GetKeyframeData(){return this._keyframeData||(this._keyframeData=new C3.KeyframeData(null,this)),this._keyframeData}GetPropertyTrackData(){return this._propertyTrackData||(this._propertyTrackData=new C3.PropertyTrackData(null,this)),this._propertyTrackData}GetInstanceData(){return this._instanceData}GetObjectClassIndex(){return this._objectClassIndex}SetObjectClassIndex(t){this._objectClassIndex=t}GetInstanceUID(){return this._instanceUid}SetInstanceUID(t){this._instanceUid=t}GetInterpolationMode(){return this._interpolationMode}SetInterpolationMode(t){this._interpolationMode=t}GetResultMode(){return this._resultMode}SetResultMode(t){this._resultMode=t}GetEnable(){return this._enabled}SetEnable(t){this._enabled=!!t}GetId(){return this._id}GetStartOffset(){return this._startOffset}GetLocalTotalTime(){return this._localTotalTime}SetLocalTotalTime(t){this._localTotalTime=t}GetOriginalWidth(){return this._additionalInstanceData[ORIGINAL_WIDTH]}SetOriginalWidth(t){this._additionalInstanceData||(this._additionalInstanceData=[]),this._additionalInstanceData[ORIGINAL_WIDTH]=t}GetOriginalHeight(){return this._additionalInstanceData||(this._additionalInstanceData=[]),this._additionalInstanceData[ORIGINAL_HEIGHT]}SetOriginalHeight(t){this._additionalInstanceData||(this._additionalInstanceData=[]),this._additionalInstanceData[ORIGINAL_HEIGHT]=t}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(t){t&&(this._instanceData=t["instanceData"],this._instanceUid=t["instanceUid"],this._objectClassIndex=t["objectClassIndex"],this._interpolationMode=t["interpolationMode"],this._resultMode=t["resultMode"],this._enabled=t["enabled"],this._id=t["id"],this._type=t["type"]||0,this._name=t["name"]||"",this._localTotalTime=this._trackData.GetTimelineDataItem().GetTotalTime(),t["nestedData"]&&(this._nestedData=t["nestedData"],this._startOffset=this._nestedData[START_OFFSET],this._localTotalTime=this._nestedData[LOCAL_TOTAL_TIME]),t["additionalInstanceData"]&&(this._additionalInstanceData=t["additionalInstanceData"]),this.GetKeyframeData()._LoadFromJson(t["keyframeDataJson"]),this.GetPropertyTrackData()._LoadFromJson(t["propertyTrackDataJson"]))}}C3.TrackData=class{constructor(t,a){this._timelineDataItem=a,this._trackDataItems=[],C3.TimelineDataManager._CreateDataItems(this._trackDataItems,t,TrackDataItem,this)}Release(){this._timelineDataItem=null;for(const t of this._trackDataItems)t.Release();C3.clearArray(this._trackDataItems),this._trackDataItems=null}GetTimelineDataItem(){return this._timelineDataItem}AddEmptyTrackDataItem(){const t=new TrackDataItem(null,this);return this._trackDataItems.push(t),t}GetFirstKeyframeDataItem(t){return t.GetKeyframeData().GetKeyframeDataItemArray()[0]}GetLastKeyframeDataItem(t){const a=t.GetKeyframeData().GetKeyframeDataItemArray();return a.at(-1)}GetKeyFrameDataItemAtTime(a,t){const e=t.GetKeyframeData().GetKeyframeDataItemArray(),s=e.length;for(let t=0;t<s;t++){const i=e[t];if(i.GetTime()===a)return i}}GetFirstKeyFrameDataItemHigherThan(a,t){const e=t.GetKeyframeData().GetKeyframeDataItemArray(),s=e.length;for(let t=0;t<s;t++){const i=e[t];if(i.GetTime()>a)return i}}GetFirstKeyFrameDataItemHigherOrEqualThan(a,t){const e=t.GetKeyframeData().GetKeyframeDataItemArray(),s=e.length;for(let t=0;t<s;t++){const i=e[t];if(i.GetTime()>=a)return i}}GetFirstKeyFrameDataItemLowerOrEqualThan(a,t){const e=t.GetKeyframeData().GetKeyframeDataItemArray();for(let t=e.length-1;0<=t;t--){const s=e[t];if(s.GetTime()<=a)return s}}*trackDataItems(){for(const t of this._trackDataItems)yield t}_SaveToJson(){return{"trackDataItemsJson":this._trackDataItems.map(t=>t._SaveToJson())}}_LoadFromJson(t){t&&C3.TimelineDataManager._LoadDataItemsFromJson(this._trackDataItems,t["trackDataItemsJson"],TrackDataItem,this)}}; } // timelines/data/propertyTrackData.js { const C3=self.C3,SOURCE_DATA=0,SOURCE=0,PROPERTY=1,TYPE=2,MIN=3,MAX=4,INTERPOLATION_MODE=5,RESULT_MODE=6,ENABLED=7,PROPERTY_KEYFRAMES=8,CAN_HAVE_PROPERTY_KEYFRAMES=9;class PropertyTrackDataItem{constructor(t,e){this._propertyTrackData=e,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,t&&(this._sourceAdapterId=t[SOURCE_DATA][SOURCE],this._sourceAdapterArguments=t[SOURCE_DATA].slice(1),this._property=t[PROPERTY],this._type=t[TYPE],this._min=t[MIN],this._max=t[MAX],this._interpolationMode=t[INTERPOLATION_MODE],this._resultMode=t[RESULT_MODE],this._enabled=!!t[ENABLED],this._propertyKeyframeData=new C3.PropertyKeyframeData(t[PROPERTY_KEYFRAMES],this),this._canHavePropertyKeyframes=t[CAN_HAVE_PROPERTY_KEYFRAMES])}Release(){this._propertyKeyframeData.Release(),this._propertyKeyframeData=null,this._propertyTrackData=null,this._sourceAdapterArguments=null}GetPropertyTrackData(){return this._propertyTrackData}GetPropertyKeyframeData(){return this._propertyKeyframeData||(this._propertyKeyframeData=new C3.PropertyKeyframeData(null,this)),this._propertyKeyframeData}GetSourceAdapterId(){return this._sourceAdapterId}SetSourceAdapterId(t){this._sourceAdapterId=t}GetSourceAdapterArguments(){return this._sourceAdapterArguments}SetSourceAdapterArguments(t){this._sourceAdapterArguments=t}GetProperty(){return this._property}SetProperty(t){this._property=t}GetType(){return this._type}SetType(t){this._type=t}GetMin(){return this._min}SetMin(t){this._min=t}GetMax(){return this._max}SetMax(t){this._max=t}GetInterpolationMode(){return this._interpolationMode}SetInterpolationMode(t){this._interpolationMode=t}GetResultMode(){return this._resultMode}SetResultMode(t){this._resultMode=t}GetEnable(){return this._enabled}SetEnable(t){this._enabled=!!t}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(t){t&&(this._sourceAdapterId=t["sourceAdapterId"],this._sourceAdapterArguments=t["sourceAdapterArguments"],this._property=t["property"],this._type=t["type"],this._min=t["min"],this._max=t["max"],this._interpolationMode=t["interpolationMode"],this._resultMode=t["resultMode"],this._enabled=t["enabled"],this._canHavePropertyKeyframes=t["canHavePropertyKeyframes"],this.GetPropertyKeyframeData()._LoadFromJson(t["propertyKeyframeDataJson"]))}}C3.PropertyTrackData=class{constructor(t,e){this._trackDataItem=e,this._propertyTrackDataItems=[],C3.TimelineDataManager._CreateDataItems(this._propertyTrackDataItems,t,PropertyTrackDataItem,this)}Release(){this._trackDataItem=null;for(const t of this._propertyTrackDataItems)t.Release();C3.clearArray(this._propertyTrackDataItems),this._propertyTrackDataItems=null}GetTrackDataItem(){return this._trackDataItem}AddEmptyPropertyTrackDataItem(){const t=new PropertyTrackDataItem(null,this);return this._propertyTrackDataItems.push(t),t}GetFirstPropertyKeyframeDataItem(t){const e=t.GetPropertyKeyframeData();return e.GetPropertyKeyframeDataItemArray()[0]}GetLastPropertyKeyframeDataItem(t){const e=t.GetPropertyKeyframeData(),r=e.GetPropertyKeyframeDataItemArray();return r.at(-1)}GetPropertyKeyFrameDataItemAtTime(e,t){const r=t.GetPropertyKeyframeData(),a=r.GetPropertyKeyframeDataItemArray(),s=a.length;for(let t=0;t<s;t++){const o=a[t];if(o.GetTime()===e)return o}}GetFirstPropertyKeyFrameDataItemHigherThan(e,t){const r=t.GetPropertyKeyframeData(),a=r.GetPropertyKeyframeDataItemArray(),s=a.length;for(let t=0;t<s;t++){const o=a[t];if(o.GetTime()>e)return o}}GetFirstPropertyKeyFrameDataItemHigherOrEqualThan(e,t){const r=t.GetPropertyKeyframeData(),a=r.GetPropertyKeyframeDataItemArray(),s=a.length;for(let t=0;t<s;t++){const o=a[t];if(o.GetTime()>=e)return o}}GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(e,t){const r=t.GetPropertyKeyframeData(),a=r.GetPropertyKeyframeDataItemArray();for(let t=a.length-1;0<=t;t--){const s=a[t];if(s.GetTime()<=e)return s}}*propertyTrackDataItems(){for(const t of this._propertyTrackDataItems)yield t}_SaveToJson(){return{"propertyTrackDataItemsJson":this._propertyTrackDataItems.map(t=>t._SaveToJson())}}_LoadFromJson(t){t&&C3.TimelineDataManager._LoadDataItemsFromJson(this._propertyTrackDataItems,t["propertyTrackDataItemsJson"],PropertyTrackDataItem,this)}}; } // timelines/data/keyframeData.js { const C3=self.C3,TIME=0,EASE=1,ENABLE=2,TAGS=3;class KeyframeDataItem{constructor(e,t){if(this._keyframeData=t,this._time=-1,this._ease="noease",this._enable=!1,this._tags=null,this._lowerTags=null,e){this._time=e[TIME],this._ease=e[EASE],this._enable=!!e[ENABLE];const a=e[TAGS];this._tags=a?a.split(" "):[],this._lowerTags=new Set(this._tags.map(e=>e.toLowerCase())),this._next=null}}Release(){this._keyframeData=null,C3.clearArray(this._tags),this._tags=null,this._lowerTags.clear(),this._lowerTags=null,this._next=null}GetKeyframeData(){return this._keyframeData}GetNext(){return this._next}SetNext(e){this._next=e}GetTime(){return this._time}SetTime(e){this._time=e,this._keyframeData._LinkKeyframeDataItems()}GetEase(){return this._ease}SetEase(e){this._ease=e}GetEnable(){return this._enable}SetEnable(e){this._enable=!!e}GetTags(){return this._tags}SetTags(e){this._tags=e?e.split(" "):[],this._lowerTags=new Set(this._tags.map(e=>e.toLowerCase()))}GetLowerTags(){return this._lowerTags}HasTag(e){return this._lowerTags.has(e.toLowerCase())}_SaveToJson(){return{"time":this._time,"ease":this._ease,"enable":this._enable,"tags":this._tags}}_LoadFromJson(e){e&&(this._time=e["time"],this._ease=e["ease"],this._enable=e["enable"],this._tags=e["tags"],this._lowerTags=new Set(this._tags.map(e=>e.toLowerCase())))}}C3.KeyframeData=class{constructor(e,t){this._trackDataItem=t,this._keyframeDataItems=[],C3.TimelineDataManager._CreateDataItems(this._keyframeDataItems,e,KeyframeDataItem,this),this._LinkKeyframeDataItems()}Release(){this._trackDataItem=null;for(const e of this._keyframeDataItems)e.Release();C3.clearArray(this._keyframeDataItems),this._keyframeDataItems=null}_LinkKeyframeDataItems(){this._keyframeDataItems.sort((e,t)=>e.GetTime()-t.GetTime());for(let e=0;e<this._keyframeDataItems.length;e++){const t=this._keyframeDataItems[e];t.SetNext(this._keyframeDataItems[e+1])}}GetTrackDataItem(){return this._trackDataItem}GetKeyframeDataItemCount(){return this._keyframeDataItems.length}GetKeyframeDataItemArray(){return this._keyframeDataItems}AddEmptyKeyframeDataItem(){const e=new KeyframeDataItem(null,this);return this._keyframeDataItems.push(e),this._LinkKeyframeDataItems(),e}DeleteKeyframeDataItems(e){for(const t of this._keyframeDataItems)if(e(t)){const a=this._keyframeDataItems.indexOf(t);-1!==a&&(t.Release(),this._keyframeDataItems.splice(a,1))}this.SortKeyframeDataItems(),this._LinkKeyframeDataItems()}SortKeyframeDataItems(){this._keyframeDataItems.sort((e,t)=>e.GetTime()-t.GetTime())}GetKeyframeDataItemIndex(e){return this._keyframeDataItems.indexOf(e)}GetKeyframeDataItemFromIndex(e){return this._keyframeDataItems[e]}*keyframeDataItems(){for(const e of this._keyframeDataItems)yield e}*keyframeDataItemsReverse(){for(let e=this._keyframeDataItems.length-1;0<=e;e--)yield this._keyframeDataItems[e]}_SaveToJson(){return{"keyframeDataItemsJson":this._keyframeDataItems.map(e=>e._SaveToJson())}}_LoadFromJson(e){e&&(C3.TimelineDataManager._LoadDataItemsFromJson(this._keyframeDataItems,e["keyframeDataItemsJson"],KeyframeDataItem,this),this._LinkKeyframeDataItems())}}; } // timelines/data/propertyKeyframeData.js { const C3=self.C3,VALUE_DATA=0,VALUE_DATA_VALUE=0,VALUE_DATA_ABSOLUTE_VALUE=1,VALUE_DATA_TYPE=2,TIME=1,EASE=2,ENABLE=3,ADDONS=4,PATH_MODE=5;class PropertyKeyframeDataItem{constructor(e,t){this._propertyKeyframeData=t,this._value=null,this._aValue=null,this._type="",this._time=NaN,this._ease="noease",this._enable=!1,this._addonData=null,this._addonInstance=void 0,this._pathMode="line",e&&(this._value=e[VALUE_DATA][VALUE_DATA_VALUE],this._aValue=e[VALUE_DATA][VALUE_DATA_ABSOLUTE_VALUE],this._type=e[VALUE_DATA][VALUE_DATA_TYPE],this._time=e[TIME],this._ease=e[EASE],this._enable=!!e[ENABLE],this._pathMode=e[PATH_MODE],this._addonData=null,e[ADDONS]&&(this._addonData=new C3.AddonData(e[ADDONS],this)),this._next=null,this._prev=null)}Release(){this._propertyKeyframeData=null,this._addonData&&(this._addonData.Release(),this._addonData=null),this._next=null,this._prev=null}GetAddonData(){return this._addonData}SetNext(e){this._next=e}GetNext(){return this._next}SetPrevious(e){this._prev=e}GetPrevious(){return this._prev}GetValue(){return this._value}SetValue(e){"color"===this._type&&C3.IsFiniteNumber(e)?(this._value[0]=C3.GetRValue(e),this._value[1]=C3.GetGValue(e),this._value[2]=C3.GetBValue(e)):this._value=e}GetAbsoluteValue(){return this._aValue}SetAbsoluteValue(e){"color"===this._type&&C3.IsFiniteNumber(e)?(this._aValue[0]=C3.GetRValue(e),this._aValue[1]=C3.GetGValue(e),this._aValue[2]=C3.GetBValue(e)):this._aValue=e}GetValueWithResultMode(){const e=this._propertyKeyframeData.GetPropertyTrackDataItem().GetResultMode();return"relative"===e?this.GetValue():"absolute"===e?this.GetAbsoluteValue():void 0}GetType(){return this._type}SetType(e){this._type=e}GetTime(){return this._time}SetTime(e){this._time=e,this._propertyKeyframeData._LinkPropertyKeyframeDataItems()}GetEase(){return this._ease}SetEase(e){this._ease=e}GetEnable(){return this._enable}SetEnable(e){this._enable=!!e}GetPathMode(){return this._pathMode}GetAddOn(t){if(this._addonData){if(!this._addonInstance&&null!==this._addonInstance){const a=this._addonData.GetAddDataItemArray();if(a){const r=a.length;for(let e=0;e<r;e++){const s=a[e];if(s.GetId()===t)return this._addonInstance=s,this._addonInstance}}this._addonInstance=null}return this._addonInstance}}_SaveToJson(){const e=this._addonData;return{"addonDataJson":e&&e._SaveToJson(),"value":this._value,"aValue":this._aValue,"type":this._type,"time":this._time,"ease":this._ease,"enable":this._enable}}_LoadFromJson(e){e&&(e["addonDataJson"]&&this._addonData._SetFromJson(e["addonDataJson"]),this._value=e["value"],this._aValue=e["aValue"],this._type=e["type"],this._time=e["time"],this._ease=e["ease"],this._enable=e["enable"])}}C3.PropertyKeyframeData=class{constructor(e,t){this._propertyTrackDataItem=t,this._propertyKeyframeDataItems=[],this._propertyKeyframeDataItemsIncludingDisabled=[],C3.TimelineDataManager._CreateDataItems(this._propertyKeyframeDataItems,e,PropertyKeyframeDataItem,this),C3.TimelineDataManager._CreateDataItemsIncludingDisabled(this._propertyKeyframeDataItemsIncludingDisabled,e,PropertyKeyframeDataItem,this),this._LinkPropertyKeyframeDataItems()}Release(){this._propertyTrackDataItem=null;for(const e of this._propertyKeyframeDataItems)e.Release();C3.clearArray(this._propertyKeyframeDataItems),this._propertyKeyframeDataItems=null;for(const t of this._propertyKeyframeDataItemsIncludingDisabled)t.Release();C3.clearArray(this._propertyKeyframeDataItemsIncludingDisabled),this._propertyKeyframeDataItemsIncludingDisabled=null}_LinkPropertyKeyframeDataItems(){let t=this._propertyKeyframeDataItems;t.sort((e,t)=>e.GetTime()-t.GetTime());for(let e=0;e<t.length;e++){const a=t[e];e+1<t.length&&a.SetNext(t[e+1]),0<=e-1&&a.SetPrevious(t[e-1])}(t=this._propertyKeyframeDataItemsIncludingDisabled).sort((e,t)=>e.GetTime()-t.GetTime());for(let e=0;e<t.length;e++){const r=t[e];e+1<t.length&&r.SetNext(t[e+1]),0<=e-1&&r.SetPrevious(t[e-1])}}AddEmptyPropertyKeyframeDataItem(){const e=new PropertyKeyframeDataItem(null,this);return this._propertyKeyframeDataItems.push(e),this._LinkPropertyKeyframeDataItems(),e}DeletePropertyKeyframeDataItems(e){for(const t of this._propertyKeyframeDataItems)if(e(t)){const a=this._propertyKeyframeDataItems.indexOf(t);-1!==a&&(t.Release(),this._propertyKeyframeDataItems.splice(a,1))}this.SortPropertyKeyFrameDataItems(),this._LinkPropertyKeyframeDataItems()}SortPropertyKeyFrameDataItems(){this._propertyKeyframeDataItems.sort((e,t)=>e.GetTime()-t.GetTime())}GetPropertyTrackDataItem(){return this._propertyTrackDataItem}GetPropertyKeyframeDataItemCount(){return this._propertyKeyframeDataItems.length}GetLastPropertyKeyframeDataItem(){return this._propertyKeyframeDataItems[this._propertyKeyframeDataItems.length-1]}GetPropertyKeyframeDataItemArray(){return this._propertyKeyframeDataItems}GetPropertyKeyframeDataItemArrayIncludingDisabled(){return this._propertyKeyframeDataItemsIncludingDisabled}*propertyKeyframeDataItems(){for(const e of this._propertyKeyframeDataItems)yield e}*propertyKeyframeDataItemsReverse(){for(let e=this._propertyKeyframeDataItems.length-1;0<=e;e--)yield this._propertyKeyframeDataItems[e]}_SaveToJson(){const e=this._propertyKeyframeDataItems,t=this._propertyKeyframeDataItemsIncludingDisabled;return{"propertyKeyframeDataItemsJson":e.map(e=>e._SaveToJson()),"propertyKeyframeDataItemsIncludingDisabledJson":t.map(e=>e._SaveToJson())}}_LoadFromJson(e){e&&(C3.TimelineDataManager._LoadDataItemsFromJson(this._propertyKeyframeDataItems,e["propertyKeyframeDataItemsJson"],PropertyKeyframeDataItem,this),C3.TimelineDataManager._LoadDataItemsFromJson(this._propertyKeyframeDataItemsIncludingDisabled,e["propertyKeyframeDataItemsIncludingDisabledJson"],PropertyKeyframeDataItem,this),this._LinkPropertyKeyframeDataItems())}}; } // timelines/data/propertyKeyframeAddonData.js { const C3=self.C3,ADDON_ID=0,ADDON_DATA=1;class AddonDataItem{constructor(t,a){this._addonData=a,this._id=t[ADDON_ID],this._data=t[ADDON_DATA]}Release(){this._addonData=null,this._data=null}GetAddonData(){return this._addonData}GetId(){return this._id}_SaveToJson(){return{"id":this._id,"data":this._data}}_LoadFromJson(t){t&&(this._id=t["id"],this._data=t["data"])}}const START_ANCHOR=0,START_ENABLE=1,END_ANCHOR=2,END_ENABLE=3;class AddonDataCubicBezierItem extends AddonDataItem{constructor(t,a){super(t,a),this._startAnchor=this._data[START_ANCHOR],this._startEnable=!!this._data[START_ENABLE],this._endAnchor=this._data[END_ANCHOR],this._endEnable=!!this._data[END_ENABLE]}Release(){super.Release()}GetStartAnchor(){return this._startAnchor}GetStartEnable(){return this._startEnable}GetEndAnchor(){return this._endAnchor}GetEndEnable(){return this._endEnable}_SaveToJson(){return Object.assign(super._SaveToJson(),{"startAnchor":this._startAnchor,"startEnable":!!this._startEnable,"endAnchor":this._endAnchor,"endEnable":!!this._endEnable})}_LoadFromJson(t){t&&(super._LoadFromJson(t),this._startAnchor=t["startAnchor"],this._startEnable=!!t["startEnable"],this._endAnchor=t["endAnchor"],this._endEnable=!!t["endEnable"])}}const DIRECTION=0,REVOLUTIONS=1;class AddonDataAngleItem extends AddonDataItem{constructor(t,a){super(t,a),this._direction=this._data[DIRECTION],this._revolutions=this._data[REVOLUTIONS]}Release(){super.Release()}GetDirection(){return this._direction}GetRevolutions(){return this._revolutions}_SaveToJson(){return Object.assign(super._SaveToJson(),{"direction":this._direction,"revolutions":this._revolutions})}_LoadFromJson(t){t&&(super._LoadFromJson(t),this._direction=t["direction"],this._revolutions=t["revolutions"])}}C3.AddonData=class{constructor(t,a){this._propertyKeyframeDataItem=a,this._addonDataItems=[],C3.TimelineDataManager._CreateDataItems(this._addonDataItems,t,{prop:0,map:new Map([["cubic-bezier",AddonDataCubicBezierItem],["angle",AddonDataAngleItem]])},this)}Release(){this._propertyKeyframeDataItem=null;for(const t of this._addonDataItems)t.Release();C3.clearArray(this._addonDataItems),this._addonDataItems=null}GetPropertyKeyframeDataItem(){return this._propertyKeyframeDataItem}GetAddDataItemArray(){return this._addonDataItems}*addonDataItems(){for(const t of this._addonDataItems)yield t}_SaveToJson(){return{"addonDataItemsJson":this._addonDataItems.map(t=>t._SaveToJson())}}_LoadFromJson(t){t&&C3.TimelineDataManager._LoadDataItemsFromJson(this._addonDataItems,t["addonDataItemsJson"],{prop:"id",map:new Map([["cubic-bezier",AddonDataCubicBezierItem],["angle",AddonDataAngleItem]])},this)}}; } // timelines/tweens/tweenState.js { const C3=self.C3,INITIAL_VALUE_MODE_START_VALUE="start-value",INITIAL_VALUE_MODE_CURRENT_STATE="current-state",PING_PONG_BEGIN=0,PING_PONG_END=1;let createdTweens=0;C3.TweenState=class extends C3.TimelineState{constructor(e,t){super("tween-"+createdTweens++,e,t),this._id="",this._destroyInstanceOnComplete=!1,this._initialValueMode=INITIAL_VALUE_MODE_START_VALUE,this._instance=null,this._on_completed_callbacks=null,this._on_started_callbacks=null,this._track=null,this._iTweenState=null}FireReleaseEvent(e){const t=C3.New(C3.Event,"tweenstatereleased");t.tweenState=this,e.dispatchEvent(t)}GetType(){return 1}CreateTrackStates(){for(const e of this._timelineDataItem.GetTrackData().trackDataItems())this._tracks.push(C3.TweenTrackState.Create(this,e));this._track=this._tracks[0]}AddTrack(){const e=this._timelineDataItem.GetTrackData().AddEmptyTrackDataItem(),t=C3.TweenTrackState.Create(this,e);return this._tracks.push(t),this._CacheTrack(),t}_CacheTrack(){this._track=this._tracks[0]}GetPropertyTrack(e){return this._track.GetPropertyTracks()[0]}SetPropertyType(e){this._propertyType=e}GetInstance(){const e=this.GetTracks();if(e&&e.length){const t=e[0];if(this._track=t){const n=t.GetInstance();return t.IsInstanceValid()?n:void 0}}}AddStartedCallback(e){this._on_started_callbacks||(this._on_started_callbacks=[]),this._on_started_callbacks.push(e)}AddCompletedCallback(e){this._on_completed_callbacks||(this._on_completed_callbacks=[]),this._on_completed_callbacks.push(e)}RemoveStartedCallback(e){if(this._on_started_callbacks){const t=this._on_started_callbacks.indexOf(e);-1!==t&&this._on_started_callbacks.splice(t,1)}}RemoveCompletedCallback(e){if(this._on_completed_callbacks){const t=this._on_completed_callbacks.indexOf(e);-1!==t&&this._on_completed_callbacks.splice(t,1)}}SetStartValue(e,t){for(const n of this._tracks)for(const s of n._propertyTracks)if(s.GetPropertyName()===t){const i=s.GetPropertyTrackData(),a=s.GetPropertyTrackDataItem(),r=i.GetFirstPropertyKeyframeDataItem(a);r.SetValue(e),r.SetAbsoluteValue(e)}}_GetPropertyTrackState(e){for(const t of this._tracks)for(const n of t._propertyTracks)if(n.GetPropertyName()===e)return n}BeforeSetEndValues(e){for(const t of e){const n=this._GetPropertyTrackState(t);this.SetStartValue(n.GetCurrentState(),t)}if(this.IsForwardPlayBack()){const s=this.GetTotalTime()-this.GetTime();this.SetTotalTime(s);for(const i of this._tracks)i.SetLocalTotalTime(s);this._SetTime(0)}else{const a=this.GetTime();this.SetTotalTime(a);for(const r of this._tracks)r.SetLocalTotalTime(a);this._SetTime(a)}this.SetInitialStateFromSetTime()}SetEndValue(e,t){const n=this._GetPropertyTrackState(t),s=n.GetPropertyTrackData(),i=n.GetPropertyTrackDataItem(),a=s.GetLastPropertyKeyframeDataItem(i);a.SetTime(this.GetTotalTime()),a.SetValue(e),a.SetAbsoluteValue(e)}SetId(e){this._id=e}GetId(){return this._id}SetInitialValueMode(e){this._initialValueMode=e}GetInitialValueMode(){return this._initialValueMode}SetDestroyInstanceOnComplete(e){this._destroyInstanceOnComplete=e}GetDestroyInstanceOnComplete(){return this._destroyInstanceOnComplete}OnStarted(){if(this._on_started_callbacks)for(const e of this._on_started_callbacks)e(this);if(!this.IsComplete())for(const t of this._tracks)t.CompareSaveStateWithCurrent()}OnCompleted(){this._completedTick=this._runtime.GetTickCount()}FinishTriggers(){if(!this._finishedTriggers&&(this._finishedTriggers=!0,this._on_completed_callbacks))for(const e of this._on_completed_callbacks)e(this)}SetTime(e){this._DeleteIntermediateKeyframes(),super.SetTime(e)}_SetTimeAndReset(e){(e=C3.IsFiniteNumber(e)?e:this.GetTotalTime())<0?this._playheadTime=0:e>=this.GetTotalTime()?this._playheadTime=this.GetTotalTime():this._playheadTime=e,this._track.SetResetState()}SetInitialState(e){if(!this.InitialStateSet()&&this.GetInitialValueMode()===INITIAL_VALUE_MODE_CURRENT_STATE)for(const t of this._tracks)t.CompareInitialStateWithCurrent();super.SetInitialState(e)}Stop(e=!1){if(super.Stop(e),!this.IsComplete())for(const t of this._tracks)t.SaveState()}Reset(e=!0,t=!1){this._DeleteIntermediateKeyframes(),super.Reset(e,t)}_DeleteIntermediateKeyframes(){for(const e of this._tracks){const t=e=>{const t=e.GetTime(),n=this.GetTotalTime();return 0!==t&&t!==n};e.DeleteKeyframes(t),e.DeletePropertyKeyframes(t)}}_OnBeforeChangeLayout(){if(!this.IsReleased()){const e=this.GetInstance();if(e&&e.GetObjectClass().IsGlobal())return!1;this._timelineManager.CompleteTimelineBeforeChangeOfLayout(this),this.ResetBeforeChangeLayout()}return!0}Tick(n,e,t){if(this._instance||(this._instance=this.GetInstance()),!this._instance||this._instance.IsDestroyed())this.Stop(!0),this.OnCompleted();else{const s=this._instance.GetTimeScale();if(0!==(n=-1!==s?t*s:n)||0!==this._lastDelta){this._lastDelta=n;const i=this._playheadTime+this._overshoot,a=n*this._playbackRate,r=i+a,o=this._timelineDataItem._totalTime;r<0?(this._playheadTime=0,this._overshoot=-r):o<=r?(this._playheadTime=o,this._overshoot=this._playheadTime-r):(this._playheadTime=r,this._overshoot=0);let e=!1,t=!1;const h=this.GetLoop(),T=this.GetPingPong();h||T?h&&!T?0<this._playbackRate?this._playheadTime>=o&&(this._SetTimeAndReset(0),this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnAnyTweenLoop),this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnTweensLoop),t=!0):this._playheadTime<=0&&(this._SetTimeAndReset(o),this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnAnyTweenLoop),this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnTweensLoop),t=!0):!h&&T?0<this._playbackRate?this._playheadTime>=o&&(this._SetTime(o),this.SetPlaybackRate(-1*this.GetPlaybackRate()),t=!0,this._pingPongState===PING_PONG_END?this._currentRepeatCount<this.GetRepeatCount()?(this._currentRepeatCount++,this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnAnyTweenLoop),this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnTweensLoop),this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnAnyTweenPingPong),this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnTweensPingPong),this._pingPongState=PING_PONG_BEGIN):(this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnAnyTweenPingPong),this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnTweensPingPong),e=!0):this._pingPongState===PING_PONG_BEGIN&&(this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnAnyTweenPingPong),this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnTweensPingPong),this._pingPongState=PING_PONG_END)):this._playheadTime<=0&&(this._SetTime(0),this.SetPlaybackRate(-1*this.GetPlaybackRate()),t=!0,this._pingPongState===PING_PONG_END?this._currentRepeatCount<this.GetRepeatCount()?(this._currentRepeatCount++,this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnAnyTweenLoop),this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnTweensLoop),this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnAnyTweenPingPong),this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnTweensPingPong),this._pingPongState=PING_PONG_BEGIN):(e=!0,this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnAnyTweenPingPong),this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnTweensPingPong)):this._pingPongState===PING_PONG_BEGIN&&(this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnAnyTweenPingPong),this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnTweensPingPong),this._pingPongState=PING_PONG_END)):h&&T&&(0<this._playbackRate?this._playheadTime>=o&&(this._SetTime(o),this.SetPlaybackRate(-1*this.GetPlaybackRate()),t=!0,this._pingPongState===PING_PONG_BEGIN&&(this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnAnyTweenPingPong),this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnTweensPingPong)),this._pingPongState===PING_PONG_END&&(this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnAnyTweenLoop),this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnTweensLoop),this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnAnyTweenPingPong),this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnTweensPingPong)),this._pingPongState++,this._pingPongState=C3.wrap(this._pingPongState,0,2)):this._playheadTime<=0&&(this._SetTime(0),this.SetPlaybackRate(-1*this.GetPlaybackRate()),t=!0,this._pingPongState===PING_PONG_BEGIN&&(this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnAnyTweenPingPong),this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnTweensPingPong)),this._pingPongState===PING_PONG_END&&(this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnAnyTweenLoop),this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnTweensLoop),this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnAnyTweenPingPong),this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnTweensPingPong)),this._pingPongState++,this._pingPongState=C3.wrap(this._pingPongState,0,2))):0<this._playbackRate?this._playheadTime>=o&&(this._currentRepeatCount<this.GetRepeatCount()?(this._currentRepeatCount++,this._SetTimeAndReset(0),this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnAnyTweenLoop),this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnTweensLoop),t=!0):(this._SetTime(o),e=!0)):this._playheadTime<=0&&(this._currentRepeatCount<this.GetRepeatCount()?(this._currentRepeatCount++,this._SetTimeAndReset(o),this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnAnyTweenLoop),this._TweenTrigger(C3.Behaviors.Tween.Cnds.OnTweensLoop),t=!0):(this._SetTime(0),e=!0)),e?(this._track.SetEndState(),this.Stop(!0),this.OnCompleted()):(this._track.Interpolate(this._playheadTime,!0,!1,t,this._firstTick,!1),this._firstTick&&(this._firstTick=!1))}}}_TweenTrigger(e){const t=this.GetInstance(),n=t.GetBehaviorSdkInstanceFromCtor(C3.Behaviors.Tween);n.PushTriggerTween(this),this._runtime.Trigger(e,t,n.GetBehaviorType()),n.PopTriggerTween()}_SaveToJson(){const e=super._SaveToJson(),t=this.GetTimelineDataItem();return Object.assign(e,{"tweenDataItemJson":t._SaveToJson(),"id":this._id,"destroyInstanceOnComplete":this._destroyInstanceOnComplete,"initialValueMode":this._initialValueMode})}_LoadFromJson(e){if(e){const t=this.GetTimelineDataItem();t._LoadFromJson(e["tweenDataItemJson"]),super._LoadFromJson(e),this._id=e["id"],this._destroyInstanceOnComplete=e["destroyInstanceOnComplete"],this._initialValueMode=e["initialValueMode"],this._CacheTrack()}}static IsPlaying(e){return e.IsPlaying()}static IsPaused(e){return e.IsPaused()}static IsPing(e){return!!e.GetPingPong()&&e.GetPingPongState()===PING_PONG_BEGIN}static IsPong(e){return!!e.GetPingPong()&&e.GetPingPongState()===PING_PONG_END}static Build(e){const t=e.runtime.GetTimelineManager(),n=new C3.TimelineDataItem;if(e.json){n._LoadFromJson(e.json["tweenDataItemJson"]);const s=new C3.TweenState(n,t);return s._LoadFromJson(e.json),s}{const i=new C3.TweenState(n,t),a=(C3.IsArray(e.propertyTracksConfig)||(e.propertyTracksConfig=[e.propertyTracksConfig]),i.SetId(e.id),i.SetTags(e.tags),i.SetInitialValueMode(e.initialValueMode),i.SetDestroyInstanceOnComplete(e.releaseOnComplete),i.SetLoop(e.loop),i.SetPingPong(e.pingPong),i.SetTotalTime(e.time),i.SetStep(0),i.SetInterpolationMode("default"),i.SetResultMode(e.propertyTracksConfig[0].resultMode),i.SetRepeatCount(e.repeatCount),i.AddTrack()),r=(a.SetInstanceUID(e.instance.GetUID()),a.SetInterpolationMode("default"),a.SetResultMode(e.propertyTracksConfig[0].resultMode),a.SetEnable(!0),a.SetObjectClassIndex(e.instance.GetObjectClass().GetIndex()),e.instance.GetSdkInstance()),o=r.IsOriginalSizeKnown()?r.GetOriginalWidth():e.instance.GetWorldInfo().GetWidth(),h=r.IsOriginalSizeKnown()?r.GetOriginalHeight():e.instance.GetWorldInfo().GetHeight(),T=(a.SetOriginalWidth(o),a.SetOriginalHeight(h),a.AddKeyframe()),_=(T.SetTime(0),T.SetEase("noease"),T.SetEnable(!0),T.SetTags(""),a.AddKeyframe());_.SetTime(e.time),_.SetEase("noease"),_.SetEnable(!0),_.SetTags("");for(const l of e.propertyTracksConfig){const c=a.AddPropertyTrack(),g=(c.SetSourceAdapterId(l.sourceId),c.SetSourceAdapterArgs(l.sourceArgs),c.SetPropertyName(l.property),c.SetPropertyType(l.type),c.SetMin(NaN),c.SetMax(NaN),c.SetInterpolationMode("default"),c.SetResultMode(l.resultMode),c.SetEnable(!0),c.AddPropertyKeyframe()),d=(g.SetType(l.valueType),g.SetTime(0),g.SetEase(l.ease),g.SetEnable(!0),g.SetValue(l.startValue),g.SetAbsoluteValue(l.startValue),c.AddPropertyKeyframe());d.SetType(l.valueType),d.SetTime(e.time),d.SetEase(l.ease),d.SetEnable(!0),d.SetValue(l.endValue),d.SetAbsoluteValue(l.endValue),c.GetSourceAdapter()}return i}}static SetInstanceUID(e,t){if(!isNaN(t))for(const n of e.GetTracks())n.SetInstanceUID(t)}GetITweenState(e,t){return this._iTweenState||(this._iTweenState=C3.New(self.ITweenState,this,e,t)),this._iTweenState}}; } // timelines/tweens/tweenTrackState.js { const C3=self.C3;C3.TweenTrackState=class extends C3.TrackState{constructor(t,e){super(t,e),this._firstPropertyTrack=null,this._secondPropertyTrack=null}static Create(t,e){return C3.New(C3.TweenTrackState,t,e)}_CachePropertyTracks(){1===this._propertyTracks.length?this._firstPropertyTrack=this._propertyTracks[0]:(this._firstPropertyTrack=this._propertyTracks[0],this._secondPropertyTrack=this._propertyTracks[1])}CreatePropertyTrackStates(){for(const t of this._trackDataItem.GetPropertyTrackData().propertyTrackDataItems())this._propertyTracks.push(C3.TweenPropertyTrackState.Create(this,t));this._CachePropertyTracks()}AddPropertyTrack(){const t=this._trackDataItem.GetPropertyTrackData(),e=t.AddEmptyPropertyTrackDataItem(),r=C3.TweenPropertyTrackState.Create(this,e);return this._propertyTracks.push(r),this._CachePropertyTracks(),r}SetInitialState(){if(this.MaybeGetInstance(),this.IsInstanceValid()||!this.IsInstanceTrack()){const t=this.GetTimeline(),e=t.IsForwardPlayBack(),r=e?0:this.GetLocalTotalTime();for(const a of this._propertyTracks)a.SetInitialState(r),0===this._worldInfoChange&&1===a.GetWorldInfoChange()&&(this._worldInfoChange=1),0===this._renderChange&&1===a.GetRenderChange()&&(this._renderChange=1);this._needsBeforeAndAfter=0;const s=this._propertyTracks.some(t=>t.GetNeedsBeforeAndAfter());s&&(this._needsBeforeAndAfter=1),this._lastKeyframeDataItem=this._GetLastKeyFrameBeforeTime(r),this._initialStateOfNestedSet=!1,this._endStateOfNestedSet=!1,this.Interpolate(r)}}BeforeInterpolate(){}Interpolate(t,e=0,r=!1,s=!1,a,o=!1,i=!1){if(this._instance||this.GetInstance(),this._instance){const n=!this._instance.IsDestroyed();return n?(!o||!this.GetObjectClass().IsGlobal())&&((this._secondPropertyTrack?(this._firstPropertyTrack.Interpolate(t,r,s,i),this._secondPropertyTrack):this._firstPropertyTrack).Interpolate(t,r,s,i),void(0!==this._firstPropertyTrack.GetWorldInfoChange()&&(this._worldInfo||(this._worldInfo=this._instance.GetWorldInfo()),this._worldInfo)&&this._worldInfo.SetBboxChanged())):!1}}AfterInterpolate(){}_LoadFromJson(t){super._LoadFromJson(t),this._CachePropertyTracks()}}; } // timelines/tweens/tweenPropertyTrackState.js { const C3=self.C3;C3.TweenPropertyTrackState=class extends C3.PropertyTrackState{constructor(t,e){super(t,e),this._basic=!1}static Create(t,e){return C3.New(C3.TweenPropertyTrackState,t,e)}Interpolate(t,e=!1,r=!1,a=!1){let s,o;if(this._basic)s=this._propertyKeyframeDataItems[0],o=this._propertyKeyframeDataItems[1];else{if(e)s=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(t,this._propertyTrackDataItem);else{if(this._lastPropertyKeyframeDataItem){const y=this.GetTimeline(),p=this._lastPropertyKeyframeDataItem.GetNext(),i=this._lastPropertyKeyframeDataItem.GetTime(),m=p?p.GetTime():y.GetTotalTime();(t<=i||m<=t)&&(this._lastPropertyKeyframeDataItem=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(t,this._propertyTrackDataItem))}else this._lastPropertyKeyframeDataItem=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(t,this._propertyTrackDataItem);s=this._lastPropertyKeyframeDataItem}o=s.GetNext()}this._sourceAdapter.Interpolate(t,s,o,e,r,a)}AddPropertyKeyframe(){const t=this._propertyTrackDataItem.GetPropertyKeyframeData(),e=t.AddEmptyPropertyKeyframeDataItem();return this._lastPropertyKeyframeDataItem=null,this._basic=this.GetPropertyKeyframeDataItems().length<=2,e}DeletePropertyKeyframes(t){this._lastPropertyKeyframeDataItem=null;const e=this._propertyTrackDataItem.GetPropertyKeyframeData();e.DeletePropertyKeyframeDataItems(t),this._basic=this.GetPropertyKeyframeDataItems().length<=2}_SaveToJson(){return{"sourceAdapterJson":this.GetSourceAdapter()._SaveToJson(),"basic":this._basic}}_LoadFromJson(t){t&&(this.GetSourceAdapter()._LoadFromJson(t["sourceAdapterJson"]),this._basic=t["basic"])}}; } // timelines/transitions/transition.js { const C3=self.C3,Ease=self.Ease,NAME=0,TRANSITION_KEYFRAMES=1,LINEAR=2;C3.Transition=class extends C3.DefendedBase{constructor(e,t=!0){super(),this._name=e[NAME],this._linear=e[LINEAR],this._transitionKeyframes=[];for(const a of e[TRANSITION_KEYFRAMES]){const s=C3.TransitionKeyframe.Create(this,a);this._transitionKeyframes.push(s)}for(let e=0;e<this._transitionKeyframes.length;e++){const r=this._transitionKeyframes[e],i=this._transitionKeyframes[e+1],n=this._transitionKeyframes[e-1];r.SetNext(i),r.SetPrevious(n)}this._precalculatedSamples=new Map,this._transitionKeyframeCache=new Map,this._PreCalcSamples(),t&&Ease.AddCustomEase(this._name,(e,t,a,s)=>this.Interpolate(e,t,a,s),null,{transition:this})}static Create(e){return C3.New(C3.Transition,e)}Release(){for(const e of this._transitionKeyframes)e.Release();C3.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(t){for(let e=this._transitionKeyframes.length-1;0<=e;e--){const a=this._transitionKeyframes[e],s=a.GetValueX();if(s<=t){let e=a;if(s<t)return e;if(s===t){for(;e;){const r=e.GetPrevious();if(!r)break;if(r.GetValueX()!==e.GetValueX())break;e=r}return e}}}}Interpolate(e,t,a,s){let r=e/s;if(this._linear){const E=this.GetTransitionKeyFrameAt(0),n=this.GetTransitionKeyFrameAt(1),V=t+(t+a)*E.GetValueY(),p=(t+a)*n.GetValueY(),S=p-V;return 0===s?V+S:Ease.NoEase(e,V,S,s)}0===s&&(r=1);let i=this.GetFirstTransitionKeyFrameLowerOrEqualThan(r),n=i.GetNext();if(!n){const X=i.GetPrevious(),A=i;i=X,n=A}const l=n.GetValueX()-i.GetValueX(),o=C3.mapToRange(r,i.GetValueX(),n.GetValueX(),0,l);if(i.IsSegmentLinear()||0==l){const C=t+(t+a)*i.GetValueY(),d=(t+a)*n.GetValueY(),T=d-C;return 0==l?1===o?C+T:C:Ease.NoEase(o,C,T,l)}const h=i.GetValueX(),u=i.GetValueY(),c=i.GetValueX()+i.GetStartAnchorX(),f=i.GetValueY()+i.GetStartAnchorY(),G=n.GetValueX()+n.GetEndAnchorX(),m=n.GetValueY()+n.GetEndAnchorY(),_=n.GetValueX(),K=n.GetValueY();let y=Ease.GetRuntimeEase("spline")(o,h,u,c,f,G,m,_,K,this._precalculatedSamples.get(i));return(1-(y+=i.GetValueY()))*t+y*(t+a)}_PreCalcSamples(){this._precalculatedSamples.clear();for(let e=0;e<this._transitionKeyframes.length-1;e++){const t=this._transitionKeyframes[e];if(t.GetStartEnable()){const a=t,s=this._transitionKeyframes[e+1];if(s.GetEndEnable()){const r=a.GetValueX(),i=a.GetValueX()+a.GetStartAnchorX(),n=s.GetValueX()+s.GetEndAnchorX(),l=s.GetValueX();this._precalculatedSamples.set(a,Ease.GetBezierSamples(r,i,n,l))}}}}}; } // timelines/transitions/transitionKeyframe.js { const C3=self.C3,VALUE_X=0,VALUE_Y=1,START_ANCHOR_X=2,START_ANCHOR_Y=3,END_ANCHOR_X=4,END_ANCHOR_Y=5,START_ENABLE=6,END_ENABLE=7,SEGMENT_MODE=8;C3.TransitionKeyframe=class extends C3.DefendedBase{constructor(t,e){super(),this._transition=t,this._valueX=e[VALUE_X],this._valueY=e[VALUE_Y],this._startAnchorX=e[START_ANCHOR_X],this._startAnchorY=e[START_ANCHOR_Y],this._endAnchorX=e[END_ANCHOR_X],this._endAnchorY=e[END_ANCHOR_Y],this._startEnable=e[START_ENABLE],this._endEnable=e[END_ENABLE],this._segmentMode=e[SEGMENT_MODE],this._next=null,this._prev=null}Release(){this._transition=null}static Create(t,e){return C3.New(C3.TransitionKeyframe,t,e)}SetNext(t){this._next=t}GetNext(){return this._next}SetPrevious(t){this._prev=t}GetPrevious(){return this._prev}GetValueX(){return this._valueX}GetValueY(){return this._valueY}GetStartAnchorX(){return this._startAnchorX}GetStartAnchorY(){return this._startAnchorY}GetEndAnchorX(){return this._endAnchorX}GetEndAnchorY(){return this._endAnchorY}GetStartEnable(){return this._startEnable}GetEndEnable(){return this._endEnable}IsSegmentLinear(){return"linear"===this._segmentMode}IsSegmentCubic(){return"cubic"===this._segmentMode}}; } // timelines/transitions/transitionManager.js { const C3=self.C3;C3.TransitionManager=class extends C3.DefendedBase{constructor(s){super(),this._runtime=s,this._transitions=[]}Release(){for(const s of this._transitions)s.Release();C3.clearArray(this._transitions),this._transitions=null}Create(s){this._transitions.push(C3.Transition.Create(s))}}; } // templates/templateManager.js { const C3=self.C3;C3.TemplateManager=class extends C3.DefendedBase{constructor(e){super(),this._runtime=e,this._templateDataMap=null,this._instanceToTemplateNameMap=null,this._instanceDestroy=e=>this._OnInstanceDestroy(e.instance)}Release(){if(this.RemoveRuntimeListeners(),this._templateDataMap){for(const e of this._templateDataMap.values())e.clear();this._templateDataMap.clear()}this._templateDataMap=null,this._runtime=null}Create(e){if(this._templateDataMap||(this._templateDataMap=new Map),e){const t=e[0][16],a=t[0],s=e[1],n=(this._templateDataMap.has(s)||this._templateDataMap.set(s,new Map),this._templateDataMap.get(s));n.set(a,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 a=0;if(a=e instanceof C3.ObjectClass?e.GetIndex():e,this._templateDataMap.has(a)){const s=this._templateDataMap.get(a).get(t);return s?JSON.parse(JSON.stringify(s)):void 0}}MapInstanceToTemplateName(e,t){this._instanceToTemplateNameMap||(this._instanceToTemplateNameMap=new WeakMap),this._instanceToTemplateNameMap.has(e)||this._instanceToTemplateNameMap.set(e,t)}GetInstanceTemplateName(e){if(!this._instanceToTemplateNameMap)return"";const t=this._instanceToTemplateNameMap.get(e);return t||""}_OnInstanceDestroy(e){this._instanceToTemplateNameMap&&this._instanceToTemplateNameMap.has(e)&&this._instanceToTemplateNameMap.delete(e)}}; } // flowcharts/flowchartManager.js { const C3=self.C3;C3.FlowchartManager=class{constructor(a){this._runtime=a,this._flowchartDataManager=new C3.FlowchartDataManager}Release(){this._flowchartDataManager.Release(),this._flowchartDataManager=null,this._runtime=null}GetRuntime(){return this._runtime}Create(a){this._flowchartDataManager.Add(a)}GetFlowchartDataItemByName(a){return this._flowchartDataManager.Get(a)}HasFlowcharts(){return this._flowchartDataManager.HasFlowcharts()}}; } // flowcharts/state/flowchartState.js { const C3=self.C3;C3.FlowchartState=class{constructor(t,e,r,a,o,h,s){this._runtime=o.GetRuntime(),this._flowchartManager=o,this._flowchartName=t,this._startNodeTag=r,this._flowchartDataItem=a,this._tag=e,this._pluginInstance=h,this._pluginUID=s??h.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||(C3.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 t=this.GetCurrentNode();return t?t.GetTag():""}GetCurrentNodeTags(){const t=this.GetCurrentNode();return t?t.GetTags():[]}CurrentNodeHasTags(t){const e=this.GetCurrentNodeTags();if(!e)return!1;if(!e.length)return!1;const r=C3.FlowchartState._GetTagArray(t);return!(!r||!r.length)&&r.every(C3.FlowchartState._HasTag,e)}CurrentNodeCompareTags(t,e){const r=this.GetCurrentNodeTags();if(!r)return!1;if(!r.length)return!1;const a=C3.FlowchartState._GetTagArray(t);return!(!a||!a.length)&&a.every(t=>C3.FlowchartState._CompareTag.call(r,t,e))}static _HasTag(t){const e=this;return""===t?1===e.length&&""===e[0]:e.map(t=>t.trim().toLowerCase()).includes(t.trim().toLowerCase())}static _GetTagArray(t){return t.trim().split(" ")}static _CompareTag(e,r){const t=this;return""===e?1===t.length&&""===t[0]:t.some(t=>C3.compare(t.trim(),r,e.trim()))}GetCurrentNodeParent(t){const e=this.GetCurrentNode();if(e){if(C3.IsFiniteNumber(t)){const r=e.GetParentFlowchartIds(),a=r?r[t]:void 0;if(C3.IsFiniteNumber(a))return this.GetFlowchartElementById(a)}if("string"==typeof t)for(const o of e.GetParentFlowchartIds()){const h=this.GetFlowchartElementById(o);if(h.HasTags(t))return this.GetFlowchartElementById(h.GetFlowchartId())}}}GetCurrentNodeParentTag(t){const e=this.GetCurrentNodeParent(t);return e?e.GetTag():""}GetCurrentNodeParentTags(t){const e=this.GetCurrentNodeParent(t);return e?e.GetTags():""}GetCurrentNodeParentIndex(t){const e=this.GetCurrentNode();if(!e)return-1;const r=e.GetParentFlowchartIds();if(!r)return-1;const a=this.GetCurrentNodeParent(t);return a?r.indexOf(a.GetFlowchartId()):-1}GetCurrentNodeParentCount(){const t=this.GetCurrentNode();if(!t)return 0;const e=t.GetParentFlowchartIds();return e?e.length:0}GetFlowchartElementById(t){return this._flowchartDataItem.GetFlowchartElementById(t)}Reset(){const t=this._GetRootFlowchartState();t._Reset(!0)}_Reset(t){if(this._GetReferenceFlowchartStates()){for(const[e,r]of this._GetReferenceFlowchartStates().entries())r._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=[],t){this._flowchartManager.SetCurrentFlowchartState(this);const a=this._startFlowchartNode.GetFlowchartId();a!==this._currentFlowchartNodeId&&this._GotoFlowchartNode(a)}else this._currentFlowchartNodeId=this._startFlowchartNode.GetFlowchartId()}GetCurrentNodeOutputCount(){const t=this._flowchartDataItem.GetFlowchartElementById(this._currentFlowchartNodeId);return t?t.GetFlowchartNodeOutputData().GetFlowchartNodeOutputDataItemCount():0}GetCurrentNodeOutputNameAt(t){const e=this._GetFlowchartNodeOutputAt(t);return e?e.GetName():""}GetCurrentNodeOutputValueAt(t){let e;return C3.IsFiniteNumber(t)&&(e=this._GetFlowchartNodeOutputAt(t)),"string"==typeof t&&(e=this._GetFlowchartNodeOutputByName(t)),"number"!=typeof t&&"string"!=typeof t&&console.warn("[Flowcharts] unexpected argument type in GetCurrentNodeOutputValueAt expression"),e?e.GetValue():""}GotoNextFlowchartNode(t){let e;if(C3.IsFiniteNumber(t)&&(e=this._GetFlowchartNodeOutputAt(t)),e="string"==typeof t?this._GetFlowchartNodeOutputByName(t):e){const r=e.GetConnectedFlowchartNodeFlowchartId();C3.IsFiniteNumber(r)&&(this._previousFlowchartNodeIds.push(this._currentFlowchartNodeId),this._GotoFlowchartNode(r))}}GotoAnyFlowchartNode(t){const e=this._flowchartDataItem.GetFlowchartNodeByTags(t);if(e){const r=this._flowchartDataItem.GetFlowchartElementById(e.GetFlowchartId());r&&(this._previousFlowchartNodeIds.push(this._currentFlowchartNodeId),this._GotoFlowchartNode(r.GetFlowchartId()))}}GotoPreviousFlowchartNode(){const t=this._previousFlowchartNodeIds.pop();C3.IsFiniteNumber(t)?this._GotoFlowchartNode(t):this._GetPreviousFlowchartState()&&(this._flowchartManager.SetCurrentFlowchartState(this._GetPreviousFlowchartState(),!0,!1,!1),this._GetPreviousFlowchartState()._GotoFlowchartNode(this._GetPreviousFlowchartStateStartNodeId()),this._GetRootFlowchartState()._SetCurrentReferenceFlowchart(this._GetPreviousFlowchartState()))}GotoParentFlowchartNode(t){const e=this.GetCurrentNode();if(e){e.GetFlowchartId();const r=this.GetCurrentNodeParent(t);r&&(this._previousFlowchartNodeIds.push(this._currentFlowchartNodeId),this._GotoFlowchartNode(r.GetFlowchartId()))}}HasOutput(e){if(C3.IsFiniteNumber(e)){const t=this._flowchartDataItem.GetFlowchartElementById(this._currentFlowchartNodeId),r=t.GetFlowchartNodeOutputData().GetFlowchartNodeOutputDataItems();return!!r[e]}if("string"==typeof e){const a=this._flowchartDataItem.GetFlowchartElementById(this._currentFlowchartNodeId),o=a.GetFlowchartNodeOutputData().GetFlowchartNodeOutputDataItems();for(let t=0;t<o.length;t++)if(o[t].GetName()===e)return!0}return!1}MarkForRelease(){this._markForRelease=!0}IsInTriggerState(){return 0<this._triggerCount}PushIsTriggerState(){this._triggerCount++}PopIsTriggerState(){this._triggerCount--,0===this._triggerCount&&this._markForRelease&&this._flowchartManager.RemoveFlowchartState(this)}_GotoFlowchartNode(t){const r=this._currentFlowchartNodeId,e=this.GetPluginInstance().GetInstance();if(this.PushIsTriggerState(),this._flowchartManager.PushFlowchartState(this),this._runtime.Trigger(C3.Plugins.Flowchart.Cnds.OnBeforeAnyNodeChange,e),this._runtime.Trigger(C3.Plugins.Flowchart.Cnds.OnBeforeTaggedNodeChange,e),this._runtime.Trigger(C3.Plugins.Flowchart.Cnds.OnBeforeAnyNodeChangeInFlowchart,e),this._runtime.Trigger(C3.Plugins.Flowchart.Cnds.OnBeforeTaggedNodeChangeInFlowchart,e),this._currentFlowchartNodeId=t,this._runtime.Trigger(C3.Plugins.Flowchart.Cnds.OnAnyNodeChange,e),this._runtime.Trigger(C3.Plugins.Flowchart.Cnds.OnTaggedNodeChange,e),this._runtime.Trigger(C3.Plugins.Flowchart.Cnds.OnAnyNodeChangeInFlowchart,e),this._runtime.Trigger(C3.Plugins.Flowchart.Cnds.OnTaggedNodeChangeInFlowchart,e),this._flowchartManager.PopFlowchartState(),this.PopIsTriggerState(),!this.WasReleased()){const a=this.GetFlowchartElementById(this._currentFlowchartNodeId);if("reference"===a.GetType()){const o=a.GetReferenceFlowchartName();if(this._HasReferenceFlowchartState(a)){this._previousFlowchartNodeIds.pop();const h=this._GetReferenceFlowchartState(a),s=(this._flowchartManager.SetCurrentFlowchartState(h,!0,!0,!1),h._SetPreviousFlowchart(this,r),this._GetRootFlowchartState());s._SetCurrentReferenceFlowchart(h)}else{const c=a.GetReferenceFlowchartStartNodeTag();if(o){this._previousFlowchartNodeIds.pop();let e=a.GetReferenceFlowchartTag();if(e){let t=this._flowchartManager.GetFlowchartState(e);for(;t;)e=C3.IncrementNumberAtEndOf(e),t=this._flowchartManager.GetFlowchartState(e)}else{e=o+"-ref";let t=this._flowchartManager.GetFlowchartState(e);for(;t;)e=C3.IncrementNumberAtEndOf(e),t=this._flowchartManager.GetFlowchartState(e)}const n=this._flowchartManager.AddFlowchartState(o,c,e,this._pluginInstance,!0),l=(n._SetPreviousFlowchart(this,r),this._SetReferenceFlowchartState(a,n),this._GetRootFlowchartState());n._SetRootFlowchartState(l),l._SetCurrentReferenceFlowchart(n)}}}}}_GetFlowchartNodeOutputAt(t){const e=this._flowchartDataItem.GetFlowchartElementById(this._currentFlowchartNodeId);if(!e)return null;const r=e.GetFlowchartNodeOutputData().GetFlowchartNodeOutputDataItems();if(!r)return null;const a=r[t];return a||null}_GetFlowchartNodeOutputByName(t){const e=this._flowchartDataItem.GetFlowchartElementById(this._currentFlowchartNodeId);if(!e)return null;const r=e.GetFlowchartNodeOutputData().GetFlowchartNodeOutputDataItemByName(t);return r||null}_SetStartFlowchartNode(e){if("number"==typeof e){let t=this.GetFlowchartElementById(e);t=t||this._flowchartDataItem.GetFlowchartStartNode(),this._startFlowchartNode=t}else{let t=this._flowchartDataItem.GetFlowchartNodeByTags(this._startNodeTag);t=t||this._flowchartDataItem.GetFlowchartStartNode(),this._startFlowchartNode=t}}_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":C3.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 t=[];for(const[e,r]of this._GetReferenceFlowchartStates().entries())t.push({"flowchartElementId":e.GetFlowchartId(),"flowchartStateTag":r.GetTag()});return t.length?t:null}_LoadFromJson(t){if(t){if(this._flowchartName=t["flowchartName"],this._tag=t["flowchartTag"],this._startNodeTag=t["startNodeTag"],this._currentFlowchartNodeId=t["currentNodeId"],this._previousFlowchartNodeIds=t["previousNodeIds"],this._pluginUID=t["pluginUID"],t.hasOwnProperty("reference")){const e=t["reference"];this._previousFlowchartStateTag=e["previousFlowchartTag"],this._previousFlowchartStateStartNodeId=e["previousStartNodeId"],this._referenceFlowchartStatesJson=e["referencesJson"],this._currentReferenceFlowchartStateTag=e["currentReferenceFlowchartTag"],this._rootFlowchartStateTag=e["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(t,e){this._previousFlowchartState=t,this._previousFlowchartStateStartNodeId=e}GetCurrentReferenceFlowchart(){return"string"==typeof this._currentReferenceFlowchartStateTag&&this._currentReferenceFlowchartStateTag&&(this._currentReferenceFlowchartState=this._flowchartManager.GetFlowchartState(this._currentReferenceFlowchartStateTag),this._currentReferenceFlowchartStateTag=""),this._currentReferenceFlowchartState}_SetCurrentReferenceFlowchart(t){this._currentReferenceFlowchartState=t,this._currentReferenceFlowchartState===this&&(this._currentReferenceFlowchartState=null)}_GetRootFlowchartState(){return"string"==typeof this._rootFlowchartStateTag&&this._rootFlowchartStateTag&&(this._rootFlowchartState=this._flowchartManager.GetFlowchartState(this._rootFlowchartStateTag),this._rootFlowchartStateTag=""),this._rootFlowchartState||this}_SetRootFlowchartState(t){this._rootFlowchartState=t}_HasReferenceFlowchartStates(){return this._RebuildReferenceFlowchartStates(),!!this._referenceFlowchartStates}_HasReferenceFlowchartState(t){return this._RebuildReferenceFlowchartStates(),this._referenceFlowchartStates&&this._referenceFlowchartStates.has(t)}_RebuildReferenceFlowchartStates(){if(this._referenceFlowchartStatesJson){this._referenceFlowchartStates&&this._referenceFlowchartStates.clear(),this._referenceFlowchartStates||(this._referenceFlowchartStates=new Map);for(const t of this._referenceFlowchartStatesJson){const e=this._flowchartManager.GetFlowchartState(t["flowchartStateTag"]),r=e.GetFlowchartElementById(t["flowchartElementId"]);this._referenceFlowchartStates.set(r,e)}this._referenceFlowchartStatesJson=null}}_GetReferenceFlowchartStates(){return this._RebuildReferenceFlowchartStates(),this._referenceFlowchartStates}_GetReferenceFlowchartState(t){return this._RebuildReferenceFlowchartStates(),this._referenceFlowchartStates.get(t)}_SetReferenceFlowchartState(t,e){this._referenceFlowchartStates||(this._referenceFlowchartStates=new Map),this._referenceFlowchartStates.set(t,e)}}; } // flowcharts/state/flowchartStateManager.js { const C3=self.C3;C3.FlowchartStateManager=class{constructor(t){this._runtime=t,this._flowchartStates=new Map,this._currentFlowchartState=null,this._flowchartStateStack=[],this._on_after_load=()=>this._OnAfterLoad(),this._loadJson=null}Release(){C3.clearArray(this._flowchartStateStack),this._flowchartStateStack=null,this._flowchartStates.clear(),this._flowchartStates=null,this._currentFlowchartState=null,this._runtime=null,this._loadJson=null}GetRuntime(){return this._runtime}AddFlowchartState(t,e,a,r,h,s){const o=this._runtime.GetFlowchartManager().GetFlowchartDataItemByName(t);if(o){if(!this._flowchartStates.has(a)){const c=new C3.FlowchartState(t,a,e,o,this,r,s);return this._flowchartStates.set(a,c),h&&this.SetCurrentFlowchartState(c,!0),c}{const c=this._flowchartStates.get(a);void(c&&this.RemoveFlowchartState(c))}}else console.warn(`[Flowcharts] no flowchart found with name '${t}'`)}RemoveFlowchartState(t){if(t.MarkForRelease(),!t.IsInTriggerState()){const e=t.GetTag();this._flowchartStates.delete(e),t.Release(),this._currentFlowchartState===t&&(this._currentFlowchartState=null)}}ResetFlowchartState(t){t.Reset()}GetFlowchartState(t){return this._flowchartStates.get(t)}PushFlowchartState(t){this._flowchartStateStack.push(t)}PopFlowchartState(){this._flowchartStateStack.pop()}SetCurrentFlowchartState(t,e=!1,a=!1,r=!0){if(r){const h=t.GetCurrentReferenceFlowchart();t=h||t}t!==this._currentFlowchartState&&(this._TriggerBeforeFlowchartChange(),this._TriggerAfterFlowchartChange(t,e,a))}GetCurrentFlowchartState(t){return"string"==typeof t?this.GetFlowchartState(t):this._flowchartStateStack.length?this._flowchartStateStack[this._flowchartStateStack.length-1]:this._currentFlowchartState}_TriggerBeforeFlowchartChange(){if(this._currentFlowchartState&&!this._currentFlowchartState.WasReleased()){const t=this._currentFlowchartState.GetPluginInstance().GetInstance();this._currentFlowchartState.PushIsTriggerState(),this.PushFlowchartState(this._currentFlowchartState),this._runtime.Trigger(C3.Plugins.Flowchart.Cnds.OnBeforeFlowchartChange,t),this.PopFlowchartState(),this._currentFlowchartState.PopIsTriggerState()}}_TriggerAfterFlowchartChange(t,e=!1,a=!1){if(this._currentFlowchartState=t,this._currentFlowchartState&&!this._currentFlowchartState.WasReleased()){const r=this._currentFlowchartState.GetPluginInstance().GetInstance();this._currentFlowchartState.PushIsTriggerState(),this.PushFlowchartState(this._currentFlowchartState),this._runtime.Trigger(C3.Plugins.Flowchart.Cnds.OnFlowchartChange,r),!0!==a&&"number"!=typeof a||this._currentFlowchartState._SetStartFlowchartNode(a),e&&(this._runtime.Trigger(C3.Plugins.Flowchart.Cnds.OnAnyNodeChange,r),this._runtime.Trigger(C3.Plugins.Flowchart.Cnds.OnTaggedNodeChange,r)),this.PopFlowchartState(),this._currentFlowchartState.PopIsTriggerState()}}_SaveToJson(){return{"flowchartJsonObjects":[...this._flowchartStates.values()].map(t=>t._SaveToJson()),"currentFlowchartTag":this._currentFlowchartState?this._currentFlowchartState.GetTag():null}}_LoadFromJson(t){if(t){this._loadJson=t;const e=new Map;for(const a of this._loadJson["flowchartJsonObjects"]){const r=a["flowchartTag"];if(this._flowchartStates.has(r)){const h=this._flowchartStates.get(r);h._LoadFromJson(a),e.set(r,h)}else{const s=this.AddFlowchartState(a["flowchartName"],a["startNodeTag"],a["flowchartTag"],null,!1,a["pluginUID"]);s._LoadFromJson(a),e.set(a["flowchartTag"],s)}}for(const[o,c]of this._flowchartStates.entries())e.has(o)||c.Release();this._flowchartStates.clear(),this._flowchartStates=e,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 t=this._flowchartStates.get(this._loadJson["currentFlowchartTag"]);t&&this.SetCurrentFlowchartState(t,!0),this._loadJson=null}}; } // flowcharts/data/flowchartDataManager.js { const C3=self.C3;C3.FlowchartDataManager=class{constructor(){this._flowchartDataItems=new Map}Release(){for(const t of this._flowchartDataItems.values())t.Release();this._flowchartDataItems.clear(),this._flowchartDataItems=null}Add(t){const a=new C3.FlowchartDataItem(t),s=a.GetName();this._flowchartDataItems.set(s,a)}Get(t){return this._flowchartDataItems.get(t)}HasFlowcharts(){return!!this._flowchartDataItems.size}static CreateDataItems(t,a,s,e){if(a)for(const o of a){const r=new s(o,e);t.push(r)}}}; } // flowcharts/data/flowchartData.js { const C3=self.C3,NAME=0,NODES=1;C3.FlowchartDataItem=class{constructor(t){this._name=t[NAME],this._flowchartNodeData=new C3.FlowchartNodeData(t[NODES],this)}Release(){this._flowchartNodeData.Release(),this._flowchartNodeData=null}GetFlowchartNodeData(){return this._flowchartNodeData}GetFlowchartElementById(t){return this._flowchartNodeData.GetFlowchartElementById(t)}GetFlowchartNodeByTags(t){return this._flowchartNodeData.GetFlowchartNodeByTags(t)}GetFlowchartStartNode(){return this._flowchartNodeData.GetFlowchartStartNode()}GetName(){return this._name}}; } // flowcharts/data/flowchartNodeData.js { const C3=self.C3,FLOWCHART_ID=0,TAG=1,PARENT_FLOWCHART_IDS=2,PARENT_OUTPUT_FLOWCHART_IDS=3,CHILDREN_FLOWCHART_IDS=4,OUTPUTS=5,IS_START=6,TYPE=7,REFERENCE_FLOWCHART=8,REFERENCE_FLOWCHART_START_NODE=9,REFERENCE_FLOWCHART_TAG=10;class FlowchartNodeDataItem{constructor(t,e){this._flowchartNodeData=e,this._type=t[TYPE],this._flowchartId=t[FLOWCHART_ID],this._tag=t[TAG],this._tag?this._tags=this._tag.trim().split(" ").map(t=>t.trim()):this._tags=[],this._parentFlowchartIds=t[PARENT_FLOWCHART_IDS],this._parentOutputFlowchartIds=null,this._childrenFlowchartIds=null,"dictionary"===this._type&&(this._parentOutputFlowchartIds=t[PARENT_OUTPUT_FLOWCHART_IDS],this._childrenFlowchartIds=t[CHILDREN_FLOWCHART_IDS]),this._isStart=t[IS_START],this._referenceFlowchartName=null,this._referenceFlowchartStartNodeTag=null,this._referenceFlowchartTag=null,"reference"===this._type&&(this._referenceFlowchartName=t[REFERENCE_FLOWCHART],this._referenceFlowchartStartNodeTag=t[REFERENCE_FLOWCHART_START_NODE],this._referenceFlowchartTag=t[REFERENCE_FLOWCHART_TAG]),this._flowchartNodeOutputData=new C3.FlowchartNodeOutputData(t[OUTPUTS],this)}Release(){this._flowchartNodeData=null}GetFlowchartNodeData(){return this._flowchartNodeData}GetFlowchartNodeOutputData(){return this._flowchartNodeOutputData}GetFlowchartId(){return this._flowchartId}GetTag(){return this._tag}GetTags(){return this._tags}HasTags(t){if(!this._tags)return!1;if(!this._tags.length)return!1;const e=C3.FlowchartState._GetTagArray(t);return!(!e||!e.length)&&e.every(C3.FlowchartState._HasTag,this._tags)}GetIsStart(){return this._isStart}SetIsStart(t){this._isStart=!!t}CanBeStartNode(){if("dictionary"===this._type)return!0;if("reference"===this._type)return!1;throw new Error("unexpected flowchart node type: "+this._type)}GetParentFlowchartIds(){return this._parentFlowchartIds}GetParentOutputFlowchartIds(){return this._parentOutputFlowchartIds}GetChildrenFlowchartIds(){return this._childrenFlowchartIds}GetType(){return this._type}GetReferenceFlowchartName(){return this._referenceFlowchartName}GetReferenceFlowchartStartNodeTag(){return this._referenceFlowchartStartNodeTag}GetReferenceFlowchartTag(){return this._referenceFlowchartTag}}C3.FlowchartNodeData=class{constructor(t,e){this._flowchartDataItem=e,this._flowchartNodeItems=[],this._flowchartNodeItemsIdMap=new Map,this._flowchartNodeItemsTagMap=new Map,this._flowchartNodeStartItem=null,C3.FlowchartDataManager.CreateDataItems(this._flowchartNodeItems,t,FlowchartNodeDataItem,this);for(const a of this._flowchartNodeItems){const r=a.GetFlowchartId(),o=a.GetTag(),s=a.GetTags(),h=a.GetIsStart();if(this._flowchartNodeItemsIdMap.set(r,a),o)for(const l of s)this._flowchartNodeItemsTagMap.has(l)||this._flowchartNodeItemsTagMap.set(l,new Set),this._flowchartNodeItemsTagMap.get(l).add(a);h&&(this._flowchartNodeStartItem=a);const c=a.GetFlowchartNodeOutputData();for(const i of c.flowchartNodeOutputDataItems()){const n=i.GetFlowchartId();this._flowchartNodeItemsIdMap.set(n,i)}}this._flowchartNodeStartItem||this._SetStartNodeIfMissing()}Release(){this._flowchartDataItem=null;for(const t of this._flowchartNodeItems)t.Release();C3.clearArray(this._flowchartNodeItems),this._flowchartNodeItems=null}GetFlowchartDataItem(){return this._flowchartDataItem}GetFlowchartElementById(t){return this._flowchartNodeItemsIdMap.get(t)}GetFlowchartNodeByTags(t){if(!t||!t.length)return null;const a=[];for(const r of t.trim().split(" ")){let t=this._flowchartNodeItemsTagMap.get(r.trim())??new Set;if(0===t.size)return null;a.push(t)}const e=a.reduce((t,e)=>e.size<t.size?e:t);return[...e].filter(e=>a.every(t=>t.has(e)))[0]}GetFlowchartStartNode(){return this._flowchartNodeStartItem}*flowchartNodeDataItems(){for(const t of this._flowchartNodeItems)yield t}_SetStartNodeIfMissing(){let t=0;for(const e of this.flowchartNodeDataItems())e.GetIsStart()&&t++;if(0===t){for(const a of this.flowchartNodeDataItems())if(a.CanBeStartNode()&&!a.GetIsStart())return void a.SetIsStart(!0)}else{if(1===t)return;if(1<t){let t=!0;for(const r of this.flowchartNodeDataItems())r.CanBeStartNode()&&(r.GetIsStart()&&t?t=!1:r.GetIsStart()&&!t&&r.SetIsStart(!1))}}for(const o of this.flowchartNodeDataItems())if(o.CanBeStartNode()&&o.GetIsStart())return void(this._flowchartNodeStartItem=o)}}; } // flowcharts/data/flowchartNodeOutputData.js { const C3=self.C3,FLOWCHART_ID=0,NAME=1,VALUE=2,CONNECTED_FLOWCHART_NODE_FLOWCHART_ID=3;class FlowchartNodeDataOutputItem{constructor(t,e){this._flowchartNodeOutputData=e,this._flowchartId=t[FLOWCHART_ID],this._name=t[NAME],this._value=t[VALUE],this._connectedFlowchartNodeFlowchartId=t[CONNECTED_FLOWCHART_NODE_FLOWCHART_ID]}Release(){this._flowchartNodeOutputData=null}GetFlowchartNodeOutputData(){return this._flowchartNodeOutputData}GetFlowchartId(){return this._flowchartId}GetName(){return this._name}GetValue(){return this._value}GetConnectedFlowchartNodeFlowchartId(){return this._connectedFlowchartNodeFlowchartId}}C3.FlowchartNodeOutputData=class{constructor(t,e){this._flowchartDataNodeItem=e,this._flowchartNodeOutputItems=[],this._flowchartNodeOutputItemsNameMap=new Map,C3.FlowchartDataManager.CreateDataItems(this._flowchartNodeOutputItems,t,FlowchartNodeDataOutputItem,this);for(const a of this._flowchartNodeOutputItems)this._flowchartNodeOutputItemsNameMap.set(a.GetName(),a)}Release(){this._flowchartDataNodeItem=null;for(const t of this._flowchartNodeOutputItems)t.Release();C3.clearArray(this._flowchartNodeOutputItems),this._flowchartNodeOutputItems=null}GetFlowchartNodeDataItem(){return this._flowchartDataNodeItem}GetFlowchartNodeOutputDataItemCount(){return this._flowchartNodeOutputItems.length}GetFlowchartNodeOutputDataItems(){return this._flowchartNodeOutputItems}GetFlowchartNodeOutputDataItemByName(t){return this._flowchartNodeOutputItemsNameMap.get(t)}*flowchartNodeOutputDataItems(){for(const t of this._flowchartNodeOutputItems)yield t}}; } // events/stacks/solStack.js { const C3=self.C3;C3.SolStack=class extends C3.DefendedBase{constructor(t){super(),this._objectClass=t,this._stack=[],this._stack.push(C3.New(C3.Sol,this)),this._index=0,this._current=this._stack[0]}Release(){for(const t of this._stack)t.Release();C3.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 t=this._stack,s=++this._index;if(s===t.length){const e=C3.New(C3.Sol,this);t.push(e),this._current=e}else{const n=t[s];n.Reset(),this._current=n}}PushCopy(){const t=this._stack,s=++this._index,e=(s===t.length&&t.push(C3.New(C3.Sol,this)),t[s]);e.Copy(t[s-1]),this._current=e}Pop(){this._current=this._stack[--this._index]}RemoveInstances(e){const n=this._stack;for(let t=0,s=n.length;t<s;++t)n[t].RemoveInstances(e)}}; } // events/stacks/sol.js { const C3=self.C3;C3.Sol=class extends C3.DefendedBase{constructor(s){super(),this._stack=s,this._objectClass=this._stack.GetObjectClass(),this._eventStack=this._objectClass.GetRuntime().GetEventStack(),this._selectAll=!0,this._instances=[],this._elseInstances=[]}Release(){this.ClearArrays(),this._stack=null,this._objectClass=null,this._eventStack=null}ClearArrays(){C3.clearArray(this._instances),C3.clearArray(this._elseInstances)}GetObjectClass(){return this._objectClass}IsSelectAll(){return this._selectAll}HasAnyInstances(){return this._selectAll?!!this._objectClass.GetInstanceCount():!!this._instances.length}GetInstances(){return this._selectAll?this._objectClass.GetInstances():this._instances}HasAnyElseInstances(){return!!this._elseInstances.length}GetElseInstances(){return this._elseInstances}GetExpressionInstances(){const s=this.GetInstances();return s.length?s:this._elseInstances}Reset(){this._selectAll=!0,C3.clearArray(this._elseInstances)}Clear(){this._selectAll=!0}Copy(s){s.IsSelectAll()?this.Reset():(this._selectAll=!1,C3.shallowAssignArray(this._instances,s._instances),C3.clearArray(this._elseInstances))}_PushInstance(s){this._instances.push(s)}_PushElseInstance(s){this._elseInstances.push(s)}_SetSelectAll(s){this._selectAll=!!s}_GetOwnInstances(){return this._instances}_GetOwnElseInstances(){return this._elseInstances}SetSinglePicked(s){this._selectAll=!1,C3.clearArray(this._instances),this._instances.push(s)}SetArrayPicked(s){this._selectAll=!1,C3.shallowAssignArray(this._instances,s)}SetSetPicked(s){this._selectAll=!1,C3.clearArray(this._instances);for(const e of s)this._instances.push(e)}AddElseInstances(s,e){for(const t of e)s.has(t)||this._elseInstances.push(t)}TransferElseInstancesToOwn(s){for(const e of s)this._instances.push(e);C3.arrayRemoveAllInSet(this._elseInstances,s)}ClearElseInstances(){C3.clearArray(this._elseInstances)}PickOne(s){if(s)if(this._eventStack.GetCurrentStackFrame().GetCurrentEvent().IsOrBlock()){this.IsSelectAll()&&(C3.clearArray(this._instances),C3.shallowAssignArray(this._elseInstances,s.GetObjectClass().GetInstances()),this._selectAll=!1);const e=this._elseInstances.indexOf(s);-1!==e&&(this._instances.push(this._elseInstances[e]),this._elseInstances.splice(e,1))}else this.SetSinglePicked(s)}RemoveInstances(s){C3.arrayRemoveAllInSet(this._instances,s),C3.arrayRemoveAllInSet(this._elseInstances,s)}}; } // events/stacks/eventStack.js { const C3=self.C3;C3.EventStack=class extends C3.DefendedBase{constructor(t){super(),this._eventSheetManager=t,this._runtime=this._eventSheetManager.GetRuntime(),this._stack=[],this._stack.push(C3.New(C3.EventStackFrame,this,null)),this._index=0,this._expFuncStack=[]}Release(){for(const t of this._stack)t.Release();C3.clearArray(this._stack),C3.clearArray(this._expFuncStack),this._eventSheetManager=null,this._runtime=null}GetEventSheetManager(){return this._eventSheetManager}GetRuntime(){return this._runtime}GetCurrentStackFrame(){return this._stack[this._index]}GetAllStackFrames(){return this._stack}GetCurrentStackFrameIndex(){return this._index}Push(t){const e=this._stack,n=++this._index;if(n===e.length){const s=C3.New(C3.EventStackFrame,this,t);return e.push(s),s}{const r=e[n];return r.Reset(t),r}}Pop(){--this._index}PushExpFunc(t){this._expFuncStack.push(t)}PopExpFunc(){this._expFuncStack.pop()}GetCurrentExpFuncStackFrame(){const t=this._expFuncStack;return 0===t.length?null:t.at(-1)}}; } // events/stacks/eventStackFrame.js { const C3=self.C3;C3.EventStackFrame=class extends C3.DefendedBase{constructor(t,e){super(),this._stack=t,this._runtime=this._stack.GetRuntime(),this._currentEvent=e,this._cndIndex=0,this._actIndex=0,this._lastEventTrue=!1,this._elseBranchRan=!1,this._expressionObjectClass=null,this._functionReturnType=0,this._functionReturnValue=0,this._dynamicSolModifiers=null}Release(){this.Reset(null),this._stack=null,this._runtime=null}Reset(t){this._currentEvent=t,this._cndIndex=0,this._actIndex=0,this._lastEventTrue=!1,this._elseBranchRan=!1,this._dynamicSolModifiers=null}_Restore(t,e){this._currentEvent=t,this._cndIndex=0,this._actIndex=e}ResetQuick(){this._cndIndex=0,this._actIndex=0}GetCurrentEvent(){return this._currentEvent}SetCurrentEvent(t){this._currentEvent=t}GetConditionIndex(){return this._cndIndex}SetConditionIndex(t){this._cndIndex=t}GetActionIndex(){return this._actIndex}SetActionIndex(t){this._actIndex=t}SetLastEventTrue(t){this._lastEventTrue=!!t}GetLastEventTrue(){return this._lastEventTrue}SetElseBranchRan(t){this._elseBranchRan=!!t}GetElseBranchRan(){return this._elseBranchRan}SetExpressionObjectClass(t){this._expressionObjectClass=t}GetExpressionObjectClass(){return this._expressionObjectClass}InitCallFunctionExpression(t,e){this._functionReturnType=t,this._functionReturnValue=e}GetFunctionReturnType(){return this._functionReturnType}SetFunctionReturnValue(t){this._functionReturnValue=t}GetFunctionReturnValue(){return this._functionReturnValue}IsSolModifierAfterCnds(){const t=this._currentEvent;return!!t.IsSolWriterAfterCnds()||this._cndIndex<t.GetConditionCount()-1&&!!t.GetSolModifiers().length}SetDynamicSolModifiers(t){this._dynamicSolModifiers=t}GetDynamicSolModifiers(){return this._dynamicSolModifiers}}; } // events/stacks/localVarStack.js { const C3=self.C3;C3.LocalVarStack=class extends C3.DefendedBase{constructor(t){super(),this._eventSheetManager=t,this._runtime=this._eventSheetManager.GetRuntime(),this._stack=[],this._index=-1,this._current=null,this._initialValues=[]}Release(){C3.clearArray(this._stack),this._eventSheetManager=null,this._runtime=null}_SetInitialValues(t){this._initialValues=t;const e=this._initialValues.slice(0);this._stack.push(e),this._index=0,this._current=e}GetEventSheetManager(){return this._eventSheetManager}GetRuntime(){return this._runtime}GetCurrent(){return this._current}Push(){const t=++this._index,e=this._stack;t===e.length?e.push(this._initialValues.slice(0)):C3.shallowAssignArray(e[t],this._initialValues),this._current=e[t]}Pop(){this._current=this._stack[--this._index]}}; } // events/stacks/loopStack.js { const C3=self.C3;C3.LoopStack=class extends C3.DefendedBase{constructor(t){super(),this._eventSheetManager=t,this._runtime=this._eventSheetManager.GetRuntime(),this._stack=[],this._index=-1}Release(){C3.clearArray(this._stack),this._eventSheetManager=null,this._runtime=null}GetEventSheetManager(){return this._eventSheetManager}GetRuntime(){return this._runtime}IsInLoop(){return 0<=this._index}GetCurrent(){return this._stack[this._index]}Push(){if(++this._index,this._index===this._stack.length){const t=C3.New(C3.Loop,this);return this._stack.push(t),t}{const e=this._stack[this._index];return e.Reset(),e}}Pop(){--this._index}FindByName(e){const s=this._stack;for(let t=this._index;0<=t;--t){const n=s[t];if(n.GetName()===e)return n}return null}_GetStack(){return this._stack.slice(0,this._index+1)}}; } // events/stacks/loop.js { const C3=self.C3;C3.Loop=class extends C3.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}}; } // events/stacks/arrayStack.js { const C3=self.C3;C3.ArrayStack=class extends C3.DefendedBase{constructor(){super(),this._stack=[],this._index=-1}Release(){C3.clearArray(this._stack)}GetCurrent(){return this._stack[this._index]}Push(){if(++this._index,this._index!==this._stack.length)return this._stack[this._index];{const s=[];return this._stack.push(s),s}}Pop(){--this._index}}; } // events/eventSheetManager.js { const C3=self.C3,assert=self.assert;function SortSolArray(t,e){return t.GetIndex()-e.GetIndex()}function IsSolArrayIdentical(s,n){for(let t=0,e=s.length;t<e;++t)if(s[t]!==n[t])return!1;return!0}C3.EventSheetManager=class extends C3.DefendedBase{constructor(t){super(),this._runtime=t,this._allSheets=[],this._sheetsByName=new Map,this._allGroups=[],this._groupsByName=new Map,this._blocksBySid=new Map,this._cndsBySid=new Map,this._actsBySid=new Map,this._allUniqueSolModifiers=new Map,this._eventVarsBySid=new Map,this._nextLocalVarIndex=0,this._allGlobalVars=[],this._allLocalVars=[],this._localVarInitialValues=[],this._functionBlocksByName=new Map,this._customActionBlocksMap=new Map,this._eventStack=C3.New(C3.EventStack,this),this._localVarStack=C3.New(C3.LocalVarStack,this),this._loopStack=C3.New(C3.LoopStack,this),this._triggersToPostInit=[],this._queuedTriggers=[],this._queuedDebugTriggers=[],this._runningEventsDepth=0,this._executingTriggerDepth=0,this._blockFlushingDepth=0,this._scheduledWaits=[],this._asyncActionPromises=[],this._signalTags=[],this._signalPromises=new Map,this._instSignals=new Map,self["c3_callFunction"]=(t,e)=>this._InvokeFunctionFromJS(t,e)}Release(){this.ClearAllScheduledWaits(),this._eventStack.Release(),this._eventStack=null,this._localVarStack.Release(),this._localVarStack=null,C3.clearArray(this._queuedTriggers),C3.clearArray(this._queuedDebugTriggers),this._runtime=null,C3.clearArray(this._allSheets),this._sheetsByName.clear()}Create(t){const e=C3.New(C3.EventSheet,this,t);this._allSheets.push(e),this._sheetsByName.set(e.GetName().toLowerCase(),e)}_AddTriggerToPostInit(t){this._triggersToPostInit.push(t)}_PostInit(){for(const t of this._customActionBlocksMap.values())t._CheckOverrideState();for(const e of this._functionBlocksByName.values())e._PostInit();for(const s of this._customActionBlocksMap.values())s._PostInit();for(const n of this._allSheets)n._PostInit();for(const i of this._allSheets)i._UpdateDeepIncludes();for(const r of this._triggersToPostInit)r._PostInit(!1);C3.clearArray(this._triggersToPostInit),this._localVarStack._SetInitialValues(this._localVarInitialValues)}GetRuntime(){return this._runtime}GetEventSheetByName(t){return this._sheetsByName.get(t.toLowerCase())||null}_RegisterGroup(t){this._allGroups.push(t),this._groupsByName.set(t.GetGroupName(),t)}_RegisterEventBlock(t){this._blocksBySid.set(t.GetSID(),t)}_RegisterCondition(t){this._cndsBySid.set(t.GetSID(),t)}_RegisterAction(t){this._actsBySid.set(t.GetSID(),t)}_RegisterFunctionBlock(t){switch(t.GetFunctionType()){case 0:this._functionBlocksByName.set(t.GetFunctionName().toLowerCase(),t);break;case 1:this._customActionBlocksMap.set(t.GetFunctionName().toLowerCase(),t)}}_RegisterEventVariable(t){this._eventVarsBySid.set(t.GetSID(),t),(t.IsGlobal()?this._allGlobalVars:this._allLocalVars).push(t)}_DeduplicateSolModifierList(s){2<=s.length&&s.sort(SortSolArray);let n=this._allUniqueSolModifiers.get(s.length);n||(n=[],this._allUniqueSolModifiers.set(s.length,n));for(let t=0,e=n.length;t<e;++t){const i=n[t];if(IsSolArrayIdentical(s,i))return i}return n.push(s),s}_GetNextLocalVarIndex(t){return this._localVarInitialValues.push(t.GetInitialValue()),this._nextLocalVarIndex++}GetEventStack(){return this._eventStack}GetCurrentEventStackFrame(){return this.GetEventStack().GetCurrentStackFrame()}GetCurrentEvent(){return this.GetCurrentEventStackFrame().GetCurrentEvent()}GetCurrentCondition(){const t=this.GetCurrentEventStackFrame(),e=t.GetCurrentEvent();return e.GetConditionAt(t.GetConditionIndex())}GetCurrentAction(){const t=this.GetCurrentEventStackFrame(),e=t.GetCurrentEvent();return e.GetActionAt(t.GetActionIndex())}GetLocalVarStack(){return this._localVarStack}GetLoopStack(){return this._loopStack}GetAllLocalVariablesInScope(t){const e=[];for(t=t.GetScopeParent();t;)C3.appendArray(e,t._GetAllLocalVariablesInScope()),t=t.GetScopeParent();return e}_GetLocalVariablesScriptInterface(t){const e={};for(const s of this.GetAllLocalVariablesInScope(t))e[s.GetJsPropName()]=s._GetScriptInterfaceDescriptor();return Object.create(Object.prototype,e)}GetEventVariableBySID(t){return this._eventVarsBySid.get(t)||null}GetEventBlockBySID(t){return this._blocksBySid.get(t)||null}GetConditionBySID(t){return this._cndsBySid.get(t)||null}GetActionBySID(t){return this._actsBySid.get(t)||null}GetFunctionBlockByName(t){return this._functionBlocksByName.get(t.toLowerCase())||null}GetCustomActionBlockByName(t,e){let s=this._customActionBlocksMap.get((t.GetName()+"."+e).toLowerCase());if(s)return s;if(!t.IsFamily())for(const n of t.GetFamilies())if(s=this._customActionBlocksMap.get((n.GetName()+"."+e).toLowerCase()))return s;return null}GetAllGlobalVariables(){return this._allGlobalVars}GetAllLocalVariables(){return this._allLocalVars}ResetAllGlobalsToInitialValue(t){for(const e of this._allGlobalVars)e.ResetToInitialValue();if(t)for(const s of this._allLocalVars)s.IsStatic()&&s.ResetToInitialValue()}GetEventGroupByName(t){return this._groupsByName.get(t.toLowerCase())||null}GetEventGroupBySID(t){const e=this._blocksBySid.get(t);return e&&e.IsGroup()?e:null}GetAllGroups(){return this._allGroups}ResetAllGroupsInitialActivation(){for(const t of this._allGroups)t.ResetInitialActivation()}_ResetAllHasRunFlags(){for(const t of this._allSheets)t._ResetHasRunFlag()}RunEvents(t){this._ResetAllHasRunFlags(),this._runningEventsDepth++;for(const e of t.runningLayouts()){const s=e.GetEventSheet();s&&(this._runtime.PushCurrentLayout(e),s.Run(),this._runtime.PopCurrentLayout())}this._runningEventsDepth--}async DebugRunEvents(t){this._ResetAllHasRunFlags(),this._runningEventsDepth++;for(const e of this._DebugRunEventsGen(t))await this._runtime.DebugBreak(e);this._runningEventsDepth--}*_DebugRunEventsGen(t){for(const e of t.runningLayouts()){const s=e.GetEventSheet();s&&(this._runtime.PushCurrentLayout(e),yield*s.DebugRun(),this._runtime.PopCurrentLayout())}}_Trigger(t,e,s,n){let i=!1;if(!t.GetMainRunningLayout())return this.QueueTrigger(e,s,n);this._executingTriggerDepth++;for(const r of t.runningLayouts()){const o=r.GetEventSheet();if(o){this._runtime.PushCurrentLayout(r);for(const l of o.deepIncludes()){const u=l._Trigger(e,s,n);i=i||u}const a=o._Trigger(e,s,n);i=i||a,this._runtime.PopCurrentLayout()}}return this._executingTriggerDepth--,i}*_DebugTrigger(t,e,s,n){let i=!1;if(!t.GetMainRunningLayout())return this.QueueTrigger(e,s,n);this._executingTriggerDepth++;for(const r of t.runningLayouts()){const o=r.GetEventSheet();if(o){this._runtime.PushCurrentLayout(r);for(const l of o.deepIncludes()){const u=yield*l._DebugTrigger(e,s,n);i=i||u}const a=yield*o._DebugTrigger(e,s,n);i=i||a,this._runtime.PopCurrentLayout()}}return this._executingTriggerDepth--,i}QueueTrigger(t,e,s){return this._queuedTriggers.push([t,e,s]),!1}QueueDebugTrigger(t,e,s){let n=null;const i=new Promise(t=>n=t);return this._queuedDebugTriggers.push([t,e,s,n]),i}*_RunQueuedDebugTriggersGen(){if(this._runtime.HitBreakpoint())throw new Error("should not be in breakpoint");const t=this._runtime.GetLayoutManager();for(;this._queuedDebugTriggers.length;){const[e,s,n,i]=this._queuedDebugTriggers.shift(),r=yield*this._DebugTrigger(t,e,s,n);i(r)}}async RunQueuedDebugTriggersAsync(){for(const t of this._RunQueuedDebugTriggersGen())await this._runtime.DebugBreak(t)}_FastTrigger(t,s,n,i){let r=!1;const e=t.GetMainRunningLayout(),o=e.GetEventSheet();if(o){this._executingTriggerDepth++,this._runtime.PushCurrentLayout(e);const a=o.deepIncludes();for(let t=0,e=a.length;t<e;++t){const u=a[t]._FastTrigger(s,n,i);r=r||u}const l=o._FastTrigger(s,n,i);return r=r||l,this._runtime.PopCurrentLayout(),this._executingTriggerDepth--,r}}*_DebugFastTrigger(t,s,n,i){let r=!1;const e=t.GetMainRunningLayout(),o=e.GetEventSheet();if(o){this._executingTriggerDepth++,this._runtime.PushCurrentLayout(e);const a=o.deepIncludes();for(let t=0,e=a.length;t<e;++t){const u=yield*a[t]._DebugFastTrigger(s,n,i);r=r||u}const l=yield*o._DebugFastTrigger(s,n,i);return r=r||l,this._runtime.PopCurrentLayout(),this._executingTriggerDepth--,r}}GetTriggerDepth(){return this._executingTriggerDepth}IsInTrigger(){return 0<this.GetTriggerDepth()}_IncTriggerDepth(){return++this._executingTriggerDepth}_DecTriggerDepth(){--this._executingTriggerDepth}IsRunningEvents(){return 0<this._runningEventsDepth}IsInEventEngine(){return this.IsRunningEvents()||this.IsInTrigger()}_RunQueuedTriggers(t){for(const[e,s,n]of this._queuedTriggers)this._Trigger(t,e,s,n);C3.clearArray(this._queuedTriggers)}BlockFlushingInstances(t){t?this._blockFlushingDepth++:this._blockFlushingDepth--}IsFlushingBlocked(){return 0<this._blockFlushingDepth}ClearSol(s){for(let t=0,e=s.length;t<e;++t)s[t].GetSolStack().Clear()}PushCleanSol(s){for(let t=0,e=s.length;t<e;++t)s[t].GetSolStack().PushClean()}PushCopySol(s){for(let t=0,e=s.length;t<e;++t)s[t].GetSolStack().PushCopy()}PopSol(s){for(let t=0,e=s.length;t<e;++t)s[t].GetSolStack().Pop()}GetDynamicSolModifiersSet(e){const s=new Set,n=this._eventStack.GetAllStackFrames(),i=this._eventStack.GetCurrentStackFrameIndex();for(let t=0;t<=i;++t){const r=n[t].GetDynamicSolModifiers();if(r)for(const o of r)e&&e.has(o)||s.add(o)}return s}PushCleanSolDynamic(t){const e=new Set([...t]),s=this.GetDynamicSolModifiersSet(e);if(0<s.size){for(const n of s)n.GetSolStack().PushClean();return[...s]}return null}AddScheduledWait(){const t=C3.New(C3.ScheduledWait,this);return this._scheduledWaits.push(t),t}scheduledWaits(){return this._scheduledWaits}RunScheduledWaits(){if(this._scheduledWaits.length){const n=this.GetCurrentEventStackFrame();let s=!1;this._runningEventsDepth++;for(let t=0,e=this._scheduledWaits.length;t<e;++t){const i=this._scheduledWaits[t];i._ShouldRun()&&i._Run(n),i.ShouldRelease()&&(s=!0)}s&&(this._FilterScheduledWaitsToRelease(),n.Reset(null)),this._runningEventsDepth--}}async DebugRunScheduledWaits(){if(this._scheduledWaits.length){const n=this.GetCurrentEventStackFrame();let s=!1;this._runningEventsDepth++;for(let t=0,e=this._scheduledWaits.length;t<e;++t){const i=this._scheduledWaits[t];i._ShouldRun()&&await i._DebugRun(n),i.ShouldRelease()&&(s=!0)}s&&(this._FilterScheduledWaitsToRelease(),n.Reset(null)),this._runningEventsDepth--}}_FilterScheduledWaitsToRelease(){const t=C3.arrayFilterOut(this._scheduledWaits,t=>t.ShouldRelease());for(const e of t)e.Release()}ClearAllScheduledWaits(){for(const t of this._scheduledWaits)t.Release();C3.clearArray(this._scheduledWaits)}_OnInstancesReleased(t){for(const e of this._scheduledWaits)e.RemoveInstances(t);for(const s of t){const n=this._instSignals.get(s);if(this._instSignals.delete(s),n)for(const{resolve:i}of n.signalPromises.values())i(!0)}}AddAsyncActionPromise(t){this._asyncActionPromises.push({promise:t,triggerDepth:this.GetTriggerDepth()})}ClearAsyncActionPromises(){C3.clearArray(this._asyncActionPromises)}ClearNestedAsyncActionPromises(){const e=this.GetTriggerDepth();this._asyncActionPromises=this._asyncActionPromises.filter(t=>t.triggerDepth<=e)}GetPromiseForAllAsyncActions(){const t=Promise.all(this._asyncActionPromises.map(t=>t.promise));return this._asyncActionPromises=[],t}Signal(t){const e=t.toLowerCase();this._signalTags.push(e),this._runtime.Trigger(C3.Plugins.System.Cnds.OnSignal,null),this._signalTags.pop();for(const n of this._runtime.GetEventSheetManager().scheduledWaits())n.IsSignal()&&n.GetSignalTag()===e&&n.SetSignalled();const s=this._signalPromises.get(e);s&&(s.resolve(),this._signalPromises.delete(e))}WaitForSignal(t){const s=t.toLowerCase(),e=this._signalPromises.get(s);if(e)return e.promise;{let e=null;const n=new Promise(t=>e=t);return this._signalPromises.set(s,{promise:n,resolve:e}),n}}GetCurrentSignalTag(){if(0===this._signalTags.length)throw new Error("not in a signal");return this._signalTags.at(-1)}_GetInstanceSignalState(t){let e=this._instSignals.get(t);return e||(e={signalTags:[],signalPromises:new Map},this._instSignals.set(t,e)),e}InstanceSignal(t,e){const s=this._GetInstanceSignalState(t),n=e.toLowerCase();s.signalTags.push(n),this._runtime.Trigger(t.GetPlugin().GetConstructor().Cnds.OnInstanceSignal,t),s.signalTags.pop();for(const r of this._runtime.GetEventSheetManager().scheduledWaits())r.IsInstanceSignals()&&r.GetSignalTag()===n&&r.SetInstanceSignalled(t);const i=s.signalPromises.get(n);i&&(i.resolve(!1),s.signalPromises.delete(n)),0===s.signalTags.length&&0===s.signalPromises.size&&this._instSignals.delete(t)}WaitForInstanceSignal(t,e){const s=this._GetInstanceSignalState(t),n=e.toLowerCase(),i=s.signalPromises.get(n);if(i)return i.promise;{let e=null;const r=new Promise(t=>e=t);return s.signalPromises.set(n,{promise:r,resolve:e}),r}}GetCurrentInstanceSignalTag(t){const e=this._GetInstanceSignalState(t);if(e&&0!==e.signalTags.length)return e.signalTags.at(-1);throw new Error("not in a signal")}_SaveToJson(){return{"groups":this._SaveGroupsToJson(),"cnds":this._SaveCndsToJson(),"acts":this._SaveActsToJson(),"vars":this._SaveVarsToJson(),"waits":this._SaveScheduledWaitsToJson()}}_LoadFromJson(t){this._LoadGroupsFromJson(t["groups"]),this._LoadCndsFromJson(t["cnds"]),this._LoadActsFromJson(t["acts"]),this._LoadVarsFromJson(t["vars"]),this._LoadScheduledWaitsFromJson(t["waits"])}_SaveGroupsToJson(){const t={};for(const e of this.GetAllGroups())t[e.GetSID().toString()]=e.IsGroupActive();return t}_LoadGroupsFromJson(t){for(const[e,s]of Object.entries(t)){const n=parseInt(e,10),i=this.GetEventGroupBySID(n);i&&i.SetGroupActive(s)}}_SaveCndsToJson(){const t={};for(const[e,s]of this._cndsBySid){const n=s._SaveToJson();n&&(t[e.toString()]=n)}return t}_LoadCndsFromJson(t){const e=new Map;for(const[s,n]of Object.entries(t))e.set(parseInt(s,10),n);for(const[i,r]of this._cndsBySid)r._LoadFromJson(e.get(i)||null)}_SaveActsToJson(){const t={};for(const[e,s]of this._actsBySid){const n=s._SaveToJson();n&&(t[e.toString()]=n)}return t}_LoadActsFromJson(t){const e=new Map;for(const[s,n]of Object.entries(t))e.set(parseInt(s,10),n);for(const[i,r]of this._actsBySid)r._LoadFromJson(e.get(i)||null)}_SaveVarsToJson(){const t={};for(const[e,s]of this._eventVarsBySid)s.IsConstant()||!s.IsGlobal()&&!s.IsStatic()||(t[e.toString()]=s.GetValue());return t}_LoadVarsFromJson(t){for(const[e,s]of Object.entries(t)){const n=parseInt(e,10),i=this.GetEventVariableBySID(n);i&&i.SetValue(s)}}_SaveScheduledWaitsToJson(){return this._scheduledWaits.filter(t=>!t.IsPromise()).map(t=>t._SaveToJson())}_LoadScheduledWaitsFromJson(t){this.ClearAllScheduledWaits();for(const e of t){const s=C3.ScheduledWait._CreateFromJson(this,e);s&&this._scheduledWaits.push(s)}}_GetPerfRecords(){return[...this._runtime.GetLayoutManager().runningLayouts()].map(t=>t.GetEventSheet()).filter(t=>t).map(t=>t._GetPerfRecord())}FindFirstFunctionBlockParent(t){for(;t;){const e=t.GetScopeParent();if(e instanceof C3.FunctionBlock)return e;t=e}return null}_InvokeFunctionFromJS(t,e){Array.isArray(e)||(e=[]);const s=this.GetFunctionBlockByName(t.toLowerCase());if(!s)return null;if(!s.IsEnabled())return s.GetDefaultReturnValue();const n=s.GetFunctionParameters();if(e.length<n.length)for(e=e.slice(0);e.push(n[e.length].GetInitialValue()),e.length<n.length;);const i=s.GetEventBlock();return i.RunAsExpressionFunctionCall(i.GetSolModifiersIncludingParents(),!1,s.GetReturnType(),s.GetDefaultReturnValue(),...e)}}; } // events/eventSheet.js { const C3=self.C3;C3.EventSheet=class extends C3.DefendedBase{constructor(e,t){super(),this._eventSheetManager=e,this._runtime=e.GetRuntime(),this._name=t[0],this._events=[],this._triggers=new Map,this._fastTriggers=new Map,this._eventsByDisplayNumber=new Map,this._hasRun=!1,this._shallowIncludes=[],this._deepIncludes=[],this._alreadyIncludedSheets=new Set;for(const s of t[1])this._CreateEvent(s,null,this._events);this._perfRecord=this._runtime.IsDebug()?{type:"sheet",name:this._name,totalTimeCounter:0,children:[]}:null}Release(){this._eventSheetManager=null,this._runtime=null}_CreateEvent(e,t,s){switch(e[0]){case 0:case 3:this._CreateEventBlock(e,t,s);break;case 1:this._CreateEventVariable(e,t,s);break;case 2:this._CreateInclude(e,t,s);break;case 4:this._CreateFunctionBlock(e,t);break;case 5:this._CreateScriptBlock(e,t,s);break;case 6:this._CreateCustomACEBlock(e,t);break;default:throw new Error("invalid event type")}}_CreateEventBlock(e,t,s){const n=C3.EventBlock.Create(this,t,e);if(n.IsOrBlock()){s.push(n);const r=n.GetConditions();for(let e=0,t=r.length;e<t;++e)r[e].IsTrigger()&&this._InitTrigger(n,e)}else n.IsTrigger()?this._InitTrigger(n,0):s.push(n)}_CreateFunctionBlock(e,t){const s=C3.FunctionBlock.CreateFunctionBlock(this,t,e);this._eventSheetManager._RegisterFunctionBlock(s)}_CreateCustomACEBlock(e,t){const s=C3.FunctionBlock.CreateCustomACEBlock(this,t,e);this._eventSheetManager._RegisterFunctionBlock(s)}_CreateEventVariable(e,t,s){const n=C3.EventVariable.Create(this,t,e);s.push(n)}_CreateInclude(e,t,s){const n=C3.EventInclude.Create(this,t,e);s.push(n)}_CreateScriptBlock(e,t,s){const n=C3.EventScript.Create(this,t,e);s.push(n)}_InitTrigger(n,r){n.IsOrBlock()||this._eventSheetManager._AddTriggerToPostInit(n);const i=n.GetConditionAt(r),l=i._GetFunc(),o=i.GetObjectClass();if(i.IsFastTrigger()){let e=this._fastTriggers.get(o);e||(e=new Map,this._fastTriggers.set(o,e));const a=i.GetFastTriggerValue().toLowerCase();let t=e.get(l),s=(t||(t=new Map,e.set(l,t)),t.get(a));s||(s=[],t.set(a,s)),s.push([n,r])}else{let e=this._triggers.get(o);e||(e={methodMap:new Map,behaviors:new Map},this._triggers.set(o,e));const c=i.GetBehaviorType();let t,s=(c?(t=e.behaviors.get(c))||(t=new Map,e.behaviors.set(c,t)):t=e.methodMap,t.get(l));s||(s=[],t.set(l,s)),s.push([n,r])}}_PostInit(){const s=this._events;for(let e=0,t=s.length;e<t;++e){const n=e<t-1&&s[e+1]instanceof C3.EventBlock&&s[e+1].IsElseBlock();s[e]._PostInit(n)}}_AddShallowInclude(e){this._shallowIncludes.push(e)}_UpdateDeepIncludes(){C3.clearArray(this._deepIncludes),this._AddDeepIncludes(this),this._alreadyIncludedSheets.clear()}_AddDeepIncludes(e){const t=e._deepIncludes,s=e._alreadyIncludedSheets;for(const n of this._shallowIncludes){const r=n.GetIncludeSheet();n.IsActive()&&e!==r&&!s.has(r)&&(s.add(r),r._AddDeepIncludes(e),t.push(r))}}deepIncludes(){return this._deepIncludes}GetEventSheetManager(){return this._eventSheetManager}GetRuntime(){return this._runtime}GetName(){return this._name}_RegisterEventByDisplayNumber(e,t){this._eventsByDisplayNumber.set(t,e)}_GetEventByDisplayNumber(e){return this._eventsByDisplayNumber.get(e)||null}_ResetHasRunFlag(){this._hasRun=!1}Run(){if(!this._hasRun){const e=this._runtime,t=e.IsCPUProfiling(),s=t?performance.now():0,n=(this._hasRun=!0,this.GetEventSheetManager()),r=n.GetCurrentEventStackFrame();for(const i of this._events)i.Run(r),n.ClearSol(i.GetSolModifiers()),n.ClearAsyncActionPromises(),e.FlushPendingInstances();r.Reset(null),t&&(this._perfRecord.totalTimeCounter+=performance.now()-s)}}*DebugRun(){if(!this._hasRun){this._hasRun=!0;const e=this._runtime,t=this.GetEventSheetManager(),s=t.GetCurrentEventStackFrame();for(const n of this._events)yield*n.DebugRun(s),t.ClearSol(n.GetSolModifiers()),t.ClearAsyncActionPromises(),e.FlushPendingInstances();s.Reset(null)}}_Trigger(s,n,r){if(!n)return this._TriggerForClass(s,n,null,null);{const i=n.GetObjectClass();let e=!1,t=this._TriggerForClass(s,n,i,r);e=e||t;for(const l of i.GetFamilies())t=this._TriggerForClass(s,n,l,r),e=e||t}}_TriggerForClass(e,t,s,n){const r=this._triggers.get(s);if(!r)return!1;const i=n?r.behaviors.get(n):r.methodMap;if(!i)return!1;const l=i.get(e);if(!l)return!1;let o=!1;for(const[a,c]of l){const u=this._ExecuteTrigger(t,a,c);o=o||u}return o}*_DebugTrigger(s,n,r){if(!n)return yield*this._DebugTriggerForClass(s,n,null,null);{const i=n.GetObjectClass();let e=!1,t=yield*this._DebugTriggerForClass(s,n,i,r);e=e||t;for(const l of i.GetFamilies())t=yield*this._DebugTriggerForClass(s,n,l,r),e=e||t}}*_DebugTriggerForClass(e,t,s,n){const r=this._triggers.get(s);if(!r)return!1;const i=n?r.behaviors.get(n):r.methodMap;if(!i)return!1;const l=i.get(e);if(!l)return!1;let o=!1;for(const[a,c]of l){let e;e=a.DebugCanRunFast()?this._ExecuteTrigger(t,a,c):yield*this._DebugExecuteTrigger(t,a,c),o=o||e}return o}_FastTrigger(e,t,s){const n=t.GetObjectClass(),r=this._fastTriggers.get(n);if(!r)return!1;const i=r.get(e);if(!i)return!1;const l=i.get(s);if(!l)return!1;let o=!1;for(let e=0,t=l.length;e<t;++e){const a=l[e],c=this._ExecuteTrigger(null,a[0],a[1]);o=o||c}return o}*_DebugFastTrigger(e,t,s){const n=t.GetObjectClass(),r=this._fastTriggers.get(n);if(!r)return!1;const i=r.get(e);if(!i)return!1;const l=i.get(s);if(!l)return!1;let o=!1;for(let t=0,e=l.length;t<e;++t){const a=l[t],c=a[0],u=a[1];let e;e=c.DebugCanRunFast()?this._ExecuteTrigger(null,c,u):yield*this._DebugExecuteTrigger(null,c,u),o=o||e}return o}_ExecuteTrigger(e,t,s){const n=this._runtime,r=this._eventSheetManager,i=r.GetCurrentEvent(),l=r.GetEventStack(),o=r.GetTriggerDepth();let a=!1;i&&r.PushCleanSol(i.GetSolModifiersIncludingParents()),r.PushCleanSol(t.GetSolModifiersIncludingParents());const c=1<o,u=(c&&r.GetLocalVarStack().Push(),l.Push(t));if(e){const h=t.GetConditions()[s].GetObjectClass(),_=h.GetCurrentSol();_.SetSinglePicked(e),e.IsInContainer()&&e.SetSiblingsSinglePicked()}let g=!0;if(t.GetParent()){const d=t.GetTriggerParents();for(let e=0,t=d.length;e<t;++e)if(!d[e].RunPreTrigger(u)){g=!1;break}}return g&&(t.IsOrBlock()?t.RunOrBlockTrigger(u,s):t.Run(u),a=u.GetLastEventTrue()),l.Pop(),c&&r.GetLocalVarStack().Pop(),r.PopSol(t.GetSolModifiersIncludingParents()),i&&r.PopSol(i.GetSolModifiersIncludingParents()),i||1!==o||(r.ClearAsyncActionPromises(),r.IsFlushingBlocked())||n.FlushPendingInstances(),a}*_DebugExecuteTrigger(e,t,s){const n=this._runtime,r=this._eventSheetManager,i=r.GetCurrentEvent(),l=r.GetEventStack(),o=r.GetTriggerDepth();let a=!1;i&&r.PushCleanSol(i.GetSolModifiersIncludingParents()),r.PushCleanSol(t.GetSolModifiersIncludingParents());const c=1<o,u=(c&&r.GetLocalVarStack().Push(),l.Push(t));if(e){const h=t.GetConditions()[s].GetObjectClass(),_=h.GetCurrentSol();_.SetSinglePicked(e),e.IsInContainer()&&e.SetSiblingsSinglePicked()}let g=!0;if(t.GetParent()){const d=t.GetTriggerParents();for(let e=0,t=d.length;e<t;++e)if(!(yield*d[e].DebugRunPreTrigger(u))){g=!1;break}}return g&&(t.IsOrBlock()?yield*t.DebugRunOrBlockTrigger(u,s):yield*t.DebugRun(u),a=u.GetLastEventTrue()),l.Pop(),c&&r.GetLocalVarStack().Pop(),r.PopSol(t.GetSolModifiersIncludingParents()),i&&r.PopSol(i.GetSolModifiersIncludingParents()),i||1!==o||(r.ClearAsyncActionPromises(),r.IsFlushingBlocked())||n.FlushPendingInstances(),a}_GetPerfRecord(){return this._perfRecord}}; } // events/eventBlock.js { const C3=self.C3,EMPTY_ARRAY=[];function NoActions(t,e){return!0}function*DebugNoActions(t,e){return!0}C3.EventBlock=class extends C3.DefendedBase{constructor(t,e,n){super(),this._eventSheet=t,this._runtime=t.GetRuntime(),this._parent=e,this._scopeParent=null,this._eventStack=this._runtime.GetEventSheetManager().GetEventStack(),this._solModifiers=[],this._solModifiersIncludingParents=[],this._hasGotSolModifiersIncludingParents=!1,this._isSolWriterAfterCnds=!1,this._isTopLevelGroup=!1,this._hasElseBlock=!1,this._isOrBlock=!!n[2],this._isElseBlock=!1,this._triggerParents=null,this._conditions=[],this._actions=[],this._subEvents=[],this._RunActions=NoActions,this._DebugRunActions=DebugNoActions,this._isGroup=!1,this._isInitiallyActive=!1,this._groupName="",this._isGroupActive=!1,this._containedIncludes=null,this._perfRecord=null,this._sid=n[4],this._displayNumber=n[5],this._eventSheet._RegisterEventByDisplayNumber(this,this._displayNumber),this._debugData=this._runtime.IsDebug()?{isBreakpoint:n[3][0],isBreakable:n[3][1],canRunAllConditionsFast:!1,canRunAllActionsFast:!1,canRunAllSubEventsFast:!1,canRunSelfFast:!1}:null,this.GetEventSheetManager()._RegisterEventBlock(this),3===n[0]&&this._InitGroup(n[1]);let s=0;for(const i of n[6]){const o=C3.Condition.Create(this,i,s++);this._conditions.push(o),this._AddSolModifier(o.GetObjectClass())}s=0;for(const r of n[7]){const u=C3.Action.Create(this,r,s++);this._actions.push(u)}if(9===n.length){const l=n[8];for(const a of l)this._eventSheet._CreateEvent(a,this,this._subEvents)}this._conditions.length&&(this._isElseBlock=null===this._conditions[0].GetObjectClass()&&this._conditions[0]._GetFunc()===C3.Plugins.System.Cnds.Else),0===this._conditions.length&&(this._conditions=EMPTY_ARRAY),0===this._actions.length&&(this._actions=EMPTY_ARRAY),0===this._subEvents.length&&(this._subEvents=EMPTY_ARRAY)}static Create(t,e,n){return C3.New(C3.EventBlock,t,e,n)}_InitGroup(t){this._isGroup=!0,this._isInitiallyActive=!!t[0],this._isGroupActive=this._isInitiallyActive,this._groupName=t[1].toLowerCase(),this._containedIncludes=[],this.GetEventSheetManager()._RegisterGroup(this),this._runtime.IsDebug()&&(this._perfRecord={type:"group",name:t[1],totalTimeCounter:0,children:[]})}_AddContainedInclude(t){this._containedIncludes.push(t)}_AddContainerSolModifierToList(t,e){for(const n of t.GetContainer().objectTypes())e.includes(n)||e.push(n)}_AddSolModifierToList(t,e){if(t)if(e.includes(t)||e.push(t),t.IsFamily())for(const n of t.GetFamilyMembers())n.IsInContainer()&&this._AddContainerSolModifierToList(n,e);else t.IsInContainer()&&this._AddContainerSolModifierToList(t,e)}_AddSolModifier(t){this._AddSolModifierToList(t,this._solModifiers)}_AddParentSolModifier(t){this._AddSolModifierToList(t,this._solModifiersIncludingParents)}SetAllSolModifiers(){this._solModifiers=this._runtime.GetAllObjectClasses()}_PostInit(t){this._hasElseBlock=!!t,this._IdentifyTopLevelGroup(),this._IdentifyTriggerParents();for(const e of this._conditions)e._PostInit();if(0<this._actions.length){let t=!1;for(const s of this._actions)s._PostInit(),s.HasReturnType()&&(t=!0);t?(this._RunActions=this._RunActions_ReturnValue,this._DebugRunActions=this._DebugRunActions_ReturnValue):(this._RunActions=this._RunActions_Fast,this._DebugRunActions=this._DebugRunActions_Fast)}const n=this._subEvents;for(let t=0,e=n.length;t<e;++t){const i=t<e-1&&n[t+1]instanceof C3.EventBlock&&n[t+1].IsElseBlock();n[t]._PostInit(i)}this._debugData&&this._UpdateCanRunFast(),this._perfRecord&&this._GetPerfRecordParent()._GetPerfRecord().children.push(this._perfRecord)}_GetPerfRecord(){return this._perfRecord}_GetPerfRecordParent(){let t=this.GetParent();for(;t;){if(t.IsGroup())return t;t=t.GetParent()}return this._eventSheet}_UpdateCanRunFast(){const t=this._debugData;t.canRunAllConditionsFast=this._conditions.every(t=>t.DebugCanRunFast()),t.canRunAllActionsFast=this._actions.every(t=>t.DebugCanRunFast()),t.canRunAllSubEventsFast=this._subEvents.every(t=>t.DebugCanRunFast()),t.canRunSelfFast=t.canRunAllConditionsFast&&t.canRunAllActionsFast&&t.canRunAllSubEventsFast}_UpdateCanRunFastRecursive(){let t=this;for(;t._UpdateCanRunFast(),t=t.GetParent(););}_IdentifyTopLevelGroup(){if(this.IsGroup()){let t=this.GetParent();for(this._isTopLevelGroup=!0;t;){if(!t.IsGroup()){this._isTopLevelGroup=!1;break}t=t.GetParent()}}}_IdentifySolModifiersIncludingParents(){const t=this._runtime.GetAllObjectClasses();if(this._solModifiers===t)this._solModifiersIncludingParents=t;else{this._solModifiersIncludingParents=C3.cloneArray(this._solModifiers);let t=this.GetParent();for(;t;){for(const n of t._solModifiers)this._AddParentSolModifier(n);t=t.GetParent()}const e=this.GetEventSheetManager();this._solModifiers=e._DeduplicateSolModifierList(this._solModifiers),this._solModifiersIncludingParents=e._DeduplicateSolModifierList(this._solModifiersIncludingParents)}}_IdentifyTriggerParents(){if(this.HasAnyTriggeredCondition()){this._triggerParents=[];let t=this.GetParent();for(;t;)this._triggerParents.push(t),t=t.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(t){return this._solModifiers.includes(t)}GetTriggerParents(){return this._triggerParents}GetEventSheet(){return this._eventSheet}GetEventSheetManager(){return this._eventSheet.GetEventSheetManager()}GetRuntime(){return this._runtime}GetParent(){return this._parent}_SetScopeParent(t){this._scopeParent=t}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(t){this._debugData.isBreakpoint=!!t,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(t){if(t=!!t,!this._isGroup)throw new Error("not a group");if(this._isGroupActive!==t){this._isGroupActive=t;for(const e of this._containedIncludes)e.UpdateActive();if(this._containedIncludes.length){const n=this._runtime.GetCurrentLayout(),s=n.GetEventSheet();s&&s._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 C3.FunctionBlock}HasAnyTriggeredCondition(){return this.IsForFunctionBlock()||this._conditions.some(t=>t.IsTrigger())}GetConditions(){return this._conditions}GetConditionCount(){return this._conditions.length}GetConditionAt(t){if((t=Math.floor(t))<0||t>=this._conditions.length)throw new RangeError("invalid condition index");return this._conditions[t]}GetConditionByDebugIndex(t){return this.GetConditionAt(t)}IsFirstConditionOfType(t){let e=t.GetIndex();if(0!==e){--e;const n=t.IsSystemOrSingleGlobalCondition()?t.GetFirstObjectParameterObjectClass():t.GetObjectClass();for(;0<=e;--e){const s=this._conditions[e];if(n===s.GetObjectClass()||s.IsSystemOrSingleGlobalCondition()&&s.GetFirstObjectParameterObjectClass()===n)return!1}}return!0}GetActions(){return this._actions}GetActionCount(){return this._actions.length}GetActionAt(t){if((t=Math.floor(t))<0||t>=this._actions.length)throw new RangeError("invalid action index");return this._actions[t]}GetActionByDebugIndex(e){e=Math.floor(e);const t=this._actions.find(t=>t.GetDebugIndex()===e);if(t)return t;throw new RangeError("invalid action debug index")}_HasActionIndex(t){return 0<=(t=Math.floor(t))&&t<this._actions.length}GetSubEvents(){return this._subEvents}_GetAllLocalVariablesInScope(){return this._subEvents.filter(t=>t instanceof C3.EventVariable)}RunPreTrigger(n){n.SetCurrentEvent(this);const s=this._conditions;let i=0===s.length;for(let t=0,e=s.length;t<e;++t){const o=s[t];if(n.SetConditionIndex(t),o.IsLooping())throw new Error("trigger cannot be used as sub-event to a loop");if(o.Run())i=!0;else if(!this._isOrBlock)return!1}return!this._isOrBlock||i}RunOrBlockTrigger(t,e){t.SetCurrentEvent(this),t.SetConditionIndex(e),this._conditions[e].Run()&&(this._RunActions(t,0)&&this._RunSubEvents(t),t.SetLastEventTrue(!0))}*DebugRunPreTrigger(n){n.SetCurrentEvent(this);const s=this._conditions;let i=0===s.length;for(let e=0,t=s.length;e<t;++e){const o=s[e];if(n.SetConditionIndex(e),o.IsLooping())throw new Error("trigger cannot be used as sub-event to a loop");let t;if(t=o.DebugCanRunFast()?o.Run():yield*o.DebugRun())i=!0;else if(!this._isOrBlock)return!1}return!this._isOrBlock||i}*DebugRunOrBlockTrigger(e,t){e.SetCurrentEvent(this),e.SetConditionIndex(t);const n=this._conditions[t];let s;if(s=n.DebugCanRunFast()?n.Run():yield*n.DebugRun()){let t;(t=this.DebugCanRunActionsFast()?this._RunActions(e,0):yield*this._DebugRunActions(e,0))&&(this.DebugCanRunSubEventsFast()?this._RunSubEvents():yield*this._DebugRunSubEvents()),e.SetLastEventTrue(!0)}}Run(t){t.SetCurrentEvent(this),this._isElseBlock||t.SetElseBranchRan(!1),this._isOrBlock?this._RunOrBlock(t):this._RunAndBlock(t)}*DebugRun(t){(this.IsDebugBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),t.SetCurrentEvent(this),this._isElseBlock||t.SetElseBranchRan(!1),this._isOrBlock?yield*this._DebugRunOrBlock(t):yield*this._DebugRunAndBlock(t)}_RunOrBlock(n){const s=this._conditions;let i=0===s.length;for(let t=0,e=s.length;t<e;++t){const o=s[t];if(!o.IsTrigger()){n.SetConditionIndex(t);const r=o.Run();i=i||r}}n.SetLastEventTrue(i),i&&(this._RunActions(n,0)&&this._RunSubEvents(n),this._hasElseBlock)&&n.SetElseBranchRan(!0)}*_DebugRunOrBlock(n){const s=this._conditions;let i=0===s.length;for(let e=0,t=s.length;e<t;++e){const o=s[e];if(!o.IsTrigger()){n.SetConditionIndex(e);let t;t=o.DebugCanRunFast()?o.Run():yield*o.DebugRun(),i=i||t}}if(n.SetLastEventTrue(i),i){let t;(t=this.DebugCanRunActionsFast()?this._RunActions(n,0):yield*this._DebugRunActions(n,0))&&(this.DebugCanRunSubEventsFast()?this._RunSubEvents():yield*this._DebugRunSubEvents()),this._hasElseBlock&&n.SetElseBranchRan(!0)}}_RunAndBlock(n){const s=this._conditions;for(let t=0,e=s.length;t<e;++t){const i=s[t],o=(n.SetConditionIndex(t),i.Run());if(!o)return void n.SetLastEventTrue(!1)}n.SetLastEventTrue(!0),this._RunActions(n,0)&&this._RunSubEvents(n),n.GetLastEventTrue()&&this._hasElseBlock&&n.SetElseBranchRan(!0)}*_DebugRunAndBlock(n){const s=this._conditions;for(let e=0,t=s.length;e<t;++e){const i=s[e];n.SetConditionIndex(e);let t;if(!(t=i.DebugCanRunFast()?i.Run():yield*i.DebugRun()))return void n.SetLastEventTrue(!1)}n.SetLastEventTrue(!0);let t;(t=this.DebugCanRunActionsFast()?this._RunActions(n,0):yield*this._DebugRunActions(n,0))&&(this.DebugCanRunSubEventsFast()?this._RunSubEvents():yield*this._DebugRunSubEvents()),n.GetLastEventTrue()&&this._hasElseBlock&&n.SetElseBranchRan(!0)}_RunActions_Fast(n,s){const i=this._actions;for(let t=s,e=i.length;t<e;++t){const o=i[t];n.SetActionIndex(t),o.Run()}return!0}*_DebugRunActions_Fast(n,s){const i=this._actions;for(let t=s,e=i.length;t<e;++t){const o=i[t];n.SetActionIndex(t),o.DebugCanRunFast()?o.Run():yield*o.DebugRun()}return!0}_RunActions_ReturnValue(n,s){const i=this.GetEventSheetManager(),o=this._actions;for(let t=s,e=o.length;t<e;++t){const r=o[t],u=(n.SetActionIndex(t),r.Run());if(r.CanBailOut()&&!0===u)return!1;r.IsAsync()&&u instanceof Promise&&i.AddAsyncActionPromise(u)}return!0}*_DebugRunActions_ReturnValue(n,s){const i=this.GetEventSheetManager(),o=this._actions;for(let e=s,t=o.length;e<t;++e){const r=o[e];n.SetActionIndex(e);let t;if(t=r.DebugCanRunFast()?r.Run():yield*r.DebugRun(),r.CanBailOut()&&!0===t)return!1;r.IsAsync()&&t instanceof Promise&&i.AddAsyncActionPromise(t)}return!0}_ResumeActionsAndSubEvents(t){this._RunActions(t,t.GetActionIndex())&&this._RunSubEvents()}*_DebugResumeActionsAndSubEvents(t){(yield*this._DebugRunActions(t,t.GetActionIndex()))&&(yield*this._DebugRunSubEvents())}_RunSubEvents(){if(this._subEvents.length){const t=this.IsGroup()&&this._runtime.IsCPUProfiling(),e=t?performance.now():0,n=this._eventStack,s=n.Push(this);this._isSolWriterAfterCnds?this._RunSubEvents_SolWriterAfterCnds(s):this._RunSubEvents_Fast(s),n.Pop(),t&&(this._perfRecord.totalTimeCounter+=performance.now()-e)}}_RunSubEvents_SolWriterAfterCnds(s){const i=this._isGroup,o=this._isTopLevelGroup,r=this.GetEventSheetManager(),u=this._subEvents;for(let t=0,e=u.length,n=e-1;t<e;++t){const l=u[t],a=l.GetSolModifiers(),h=!o||!i&&t<n;h&&r.PushCopySol(a),l.Run(s),h?r.PopSol(a):r.ClearSol(a)}}_RunSubEvents_Fast(n){const s=this._subEvents;for(let t=0,e=s.length;t<e;++t)s[t].Run(n)}*_DebugRunSubEvents(){if(this._subEvents.length){const t=this._eventStack,e=t.Push(this);this._isSolWriterAfterCnds?yield*this._DebugRunSubEvents_SolWriterAfterCnds(e):yield*this._DebugRunSubEvents_Fast(e),t.Pop()}}*_DebugRunSubEvents_SolWriterAfterCnds(s){const i=this._isGroup,o=this._isTopLevelGroup,r=this.GetEventSheetManager(),u=this._subEvents;for(let t=0,e=u.length,n=e-1;t<e;++t){const l=u[t],a=l.GetSolModifiers(),h=!o||!i&&t<n;h&&r.PushCopySol(a),yield*l.DebugRun(s),h?r.PopSol(a):r.ClearSol(a)}}*_DebugRunSubEvents_Fast(n){const s=this._subEvents;for(let t=0,e=s.length;t<e;++t)yield*s[t].DebugRun(n)}Retrigger(n,s){s.ResetQuick();const i=this._conditions;if(!this.IsOrBlock())for(let t=n.GetConditionIndex()+1,e=i.length;t<e;++t){const o=i[t],r=(s.SetConditionIndex(t),o.Run());if(!r)return!1}return this._RunActions(s,0)&&this._RunSubEvents(s),!0}*DebugRetrigger(n,s){s.ResetQuick();const i=this._conditions;if(!this.IsOrBlock())for(let e=n.GetConditionIndex()+1,t=i.length;e<t;++e){const o=i[e];s.SetConditionIndex(e);let t;if(!(t=o.DebugCanRunFast()?o.Run():yield*o.DebugRun()))return!1}let t;return(t=this.DebugCanRunActionsFast()?this._RunActions(s,0):yield*this._DebugRunActions(s,0))&&(this.DebugCanRunSubEventsFast()?this._RunSubEvents():yield*this._DebugRunSubEvents()),!0}DebugCanRunFast(){return!this.IsDebugBreakpoint()&&!this._runtime.DebugBreakNext()&&this._debugData.canRunSelfFast}DebugCanRunActionsFast(){return!this._runtime.DebugBreakNext()&&this._debugData.canRunAllActionsFast}DebugCanRunSubEventsFast(){return!this._runtime.DebugBreakNext()&&this._debugData.canRunAllSubEventsFast}_CheckParentsOKToRun(n){if(this.GetParent()){const s=this.GetTriggerParents();for(let t=0,e=s.length;t<e;++t)if(!s[t].RunPreTrigger(n))return!1}return!0}*_DebugCheckParentsOKToRun(n){if(this.GetParent()){const s=this.GetTriggerParents();for(let t=0,e=s.length;t<e;++t)if(!(yield*s[t].DebugRunPreTrigger(n)))return!1}return!0}_EvaluateFunctionCallParameters(t,e,n){if(0<e.length)if(n){const s=e.map(t=>t.Get(0));t.GetLocalVarStack().Push(),this._scopeParent.SetFunctionParameters(s)}else this._scopeParent.EvaluateFunctionParameters(e);else n&&t.GetLocalVarStack().Push()}RunAsFunctionCall(t,e,n,s){let i,o;const r=0<t.length;let u=null;const l=this._runtime,a=this._eventStack,h=l.GetEventSheetManager(),c=this._scopeParent,_=c.IsAsync(),d=h._IncTriggerDepth(),g=1<d;if(this._EvaluateFunctionCallParameters(h,e,g),r&&(n?h.PushCopySol(t):h.PushCleanSol(t)),null!==s){if(s.copyFromObjectClass){const b=n?s.copyFromObjectClass.GetCurrentSol():s.copyFromObjectClass.GetSolStack().GetOneBelowCurrentSol(),R=s.copyToObjectClass.GetCurrentSol();R.SetArrayPicked(b.GetInstances()),R.ClearElseInstances(),n||s.copyToObjectClass.ApplySolToContainer()}else if(s.pickObjectClass){const C=s.pickObjectClass.GetCurrentSol();C.SetArrayPicked(s.pickInstances),C.ClearElseInstances()}s.pushCleanSolDynamic&&(u=h.PushCleanSolDynamic(t))}const S=a.Push(this);return n&&S.SetDynamicSolModifiers(t),this._CheckParentsOKToRun(S)&&(S.SetCurrentEvent(this),_&&([o,i]=c.StartAsyncFunctionCall()),this._RunAndBlock(S),_)&&c.MaybeFinishAsyncFunctionCall(o),a.Pop(),g&&h.GetLocalVarStack().Pop(),null!==u&&h.PopSol(u),r&&h.PopSol(t),h._DecTriggerDepth(),_||h.ClearNestedAsyncActionPromises(),i}*DebugRunAsFunctionCall(t,e,n,s){let i,o;(this.IsDebugBreakpoint()||this._runtime.DebugBreakNext())&&(yield this);const r=0<t.length;let u=null;const l=this._runtime,a=this._eventStack,h=l.GetEventSheetManager(),c=this._scopeParent,_=c.IsAsync(),d=h._IncTriggerDepth(),g=1<d;if(this._EvaluateFunctionCallParameters(h,e,g),r&&(n?h.PushCopySol(t):h.PushCleanSol(t)),null!==s){if(s.copyFromObjectClass){const b=n?s.copyFromObjectClass.GetCurrentSol():s.copyFromObjectClass.GetSolStack().GetOneBelowCurrentSol(),R=s.copyToObjectClass.GetCurrentSol();R.SetArrayPicked(b.GetInstances()),R.ClearElseInstances(),n||s.copyToObjectClass.ApplySolToContainer()}else if(s.pickObjectClass){const C=s.pickObjectClass.GetCurrentSol();C.SetArrayPicked(s.pickInstances),C.ClearElseInstances()}s.pushCleanSolDynamic&&(u=h.PushCleanSolDynamic(t))}const S=a.Push(this);return n&&S.SetDynamicSolModifiers(t),(yield*this._DebugCheckParentsOKToRun(S))&&(S.SetCurrentEvent(this),_&&([o,i]=c.StartAsyncFunctionCall()),yield*this._DebugRunAndBlock(S),_)&&c.MaybeFinishAsyncFunctionCall(o),a.Pop(),g&&h.GetLocalVarStack().Pop(),null!==u&&h.PopSol(u),r&&h.PopSol(t),h._DecTriggerDepth(),_||h.ClearNestedAsyncActionPromises(),i}RunAsMappedFunctionCall(t,e){const n=this.GetSolModifiersIncludingParents(),s=0<n.length,i=this._runtime,o=this._eventStack,r=i.GetEventSheetManager(),u=r._IncTriggerDepth(),l=1<u,a=(l&&r.GetLocalVarStack().Push(),this._scopeParent.SetFunctionParameters(t),s&&(e?r.PushCopySol(n):r.PushCleanSol(n)),o.Push(this));this._CheckParentsOKToRun(a)&&(a.SetCurrentEvent(this),this._RunAndBlock(a)),o.Pop(),l&&r.GetLocalVarStack().Pop(),s&&r.PopSol(n),r._DecTriggerDepth(),r.ClearNestedAsyncActionPromises()}*DebugRunAsMappedFunctionCall(t,e){(this.IsDebugBreakpoint()||this._runtime.DebugBreakNext())&&(yield this);const n=this.GetSolModifiersIncludingParents(),s=0<n.length,i=this._runtime,o=this._eventStack,r=i.GetEventSheetManager(),u=r._IncTriggerDepth(),l=1<u,a=(l&&r.GetLocalVarStack().Push(),this._scopeParent.SetFunctionParameters(t),s&&(e?r.PushCopySol(n):r.PushCleanSol(n)),o.Push(this));(yield*this._DebugCheckParentsOKToRun(a))&&(a.SetCurrentEvent(this),yield*this._DebugRunAndBlock(a)),o.Pop(),l&&r.GetLocalVarStack().Pop(),s&&r.PopSol(n),r._DecTriggerDepth(),r.ClearNestedAsyncActionPromises()}RunAsExpressionFunctionCall(t,e,n,s,...i){let o,r;const u=0<t.length,l=this._runtime,a=this._eventStack,h=l.GetEventSheetManager(),c=this._scopeParent,_=c.IsAsync(),d=h._IncTriggerDepth(),g=1<d,S=(g&&h.GetLocalVarStack().Push(),0<i.length&&this._scopeParent.SetFunctionParameters(i),u&&(e?h.PushCopySol(t):h.PushCleanSol(t)),a.Push(this));return S.InitCallFunctionExpression(n,s),a.PushExpFunc(S),l.SetDebuggingEnabled(!1),this._CheckParentsOKToRun(S)&&(S.SetCurrentEvent(this),_&&([r,o]=c.StartAsyncFunctionCall()),this._RunAndBlock(S),_)&&c.MaybeFinishAsyncFunctionCall(r),l.SetDebuggingEnabled(!0),a.Pop(),a.PopExpFunc(),g&&h.GetLocalVarStack().Pop(),u&&h.PopSol(t),h._DecTriggerDepth(),_||h.ClearNestedAsyncActionPromises(),o||S.GetFunctionReturnValue()}}; } // events/eventScript.js { const C3=self.C3,EMPTY_SOL_MODIFIERS=[];let hadUserScriptException=!1;C3.EventScript=class extends C3.DefendedBase{constructor(e,t,i){super();const r=e.GetRuntime(),n=e.GetEventSheetManager(),s=(this._eventSheet=e,this._eventSheetManager=n,this._runtime=e.GetRuntime(),this._parent=t,r.GetObjectReference(i[1]));this._func=s,this._displayNumber=i[2],this._eventSheet._RegisterEventByDisplayNumber(this,this._displayNumber),this._debugData=r.IsDebug()?{isBreakpoint:i[3][0],isBreakable:i[3][1]}:null}static Create(e,t,i){return C3.New(C3.EventScript,e,t,i)}_PostInit(){const e=this._func,t=this._runtime.GetEventSheetManager()._GetLocalVariablesScriptInterface(this);this._func=e.bind(null,this._runtime.GetIRuntime(),t)}GetParent(){return this._parent}GetScopeParent(){return this._parent}GetEventSheet(){return this._eventSheet}GetDisplayNumber(){return this._displayNumber}IsDebugBreakable(){return this._debugData&&this._debugData.isBreakable}IsDebugBreakpoint(){return this.IsDebugBreakable()&&this._debugData.isBreakpoint}_SetDebugBreakpoint(e){this._debugData.isBreakpoint=!!e}IsElseBlock(){return!1}GetSolModifiers(){return EMPTY_SOL_MODIFIERS}GetSolModifiersIncludingParents(){return this._parent?this._parent.GetSolModifiersIncludingParents():EMPTY_SOL_MODIFIERS}Run(e){e.SetCurrentEvent(this),this._eventSheetManager.AddAsyncActionPromise(this._RunUserScript())}async _RunUserScript(){try{await this._func()}catch(e){console.error(`Unhandled exception running script %c${this.GetEventSheet().GetName()}, event ${this.GetDisplayNumber()}:`,"font-size: 1.2em; font-weight: bold;",e),self.C3Debugger&&self.C3Debugger._SetLastErrorScript(this),hadUserScriptException||(console.info("%cTip:%c run this to highlight in Construct the last script that had an error: %cgoToLastErrorScript()","font-weight: bold; text-decoration: underline","","font-weight: bold"),hadUserScriptException=!0)}}*DebugRun(e){e.SetCurrentEvent(this),(this.IsDebugBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this.Run(e)}DebugCanRunFast(){return!this.IsDebugBreakpoint()&&!this._runtime.DebugBreakNext()}static HadUserScriptException(){return hadUserScriptException}static SetHadUserScriptException(){hadUserScriptException=!0}}; } // events/functionBlock.js { const C3=self.C3,assert=self.assert;C3.FunctionBlock=class extends C3.DefendedBase{constructor(t,e,s){super(),this._eventSheet=t,this._runtime=t.GetRuntime(),this._parent=e,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=C3.EventBlock.Create(t,e,s),this._eventBlock._SetScopeParent(this)}InitFunctionBlock(t){this._functionType=0,this._functionName=t[0],this._returnType=t[1],this._functionParameters=t[2].map(t=>C3.EventVariable.Create(this._eventSheet,this,t)),this._isEnabled=t[3],this._isAsync=t[4],this._isCopyPicked=t[5]}InitCustomACEBlock(t){this._functionType=1,this._aceName=t[1],this._objectClass=this._runtime.GetObjectClassByIndex(t[2]),this._eventBlock._AddSolModifier(this._objectClass),this._functionName=this._objectClass.GetName()+"."+this._aceName,this._returnType=t[3],this._functionParameters=t[4].map(t=>C3.EventVariable.Create(this._eventSheet,this,t)),this._isEnabled=t[5],this._isAsync=t[6],this._isCopyPicked=t[7],this._objectClass.AddCustomAction(this)}static CreateFunctionBlock(t,e,s){const n=C3.New(C3.FunctionBlock,t,e,s),i=s[1];return n.InitFunctionBlock(i),n}static CreateCustomACEBlock(t,e,s){const n=C3.New(C3.FunctionBlock,t,e,s),i=s[1];return n.InitCustomACEBlock(i),n}_CheckOverrideState(){if(this._objectClass&&this._objectClass.IsFamily())for(const t of this._objectClass.GetFamilyMembers())if(t.HasOwnCustomActionByName(this._aceName)){this._hasOverrides=!0;break}}_PostInit(){for(const t of this._functionParameters)t._PostInit();this._eventBlock._PostInit(!1)}GetFunctionType(){return this._functionType}_GetAllLocalVariablesInScope(){return this._functionParameters}GetFunctionParameters(){return this._functionParameters}GetFunctionParameterCount(){return this._functionParameters.length}_RegisterLocalVariable(t){this._innerLocalVariables.push(t)}_GetAllInnerLocalVariables(){return this._innerLocalVariables}EvaluateFunctionParameters(s){const n=this._functionParameters;for(let t=0,e=n.length;t<e;++t)n[t].SetValue(s[t].Get(0))}SetFunctionParameters(s){const n=this._functionParameters;for(let t=0,e=n.length;t<e;++t)n[t].SetValue(s[t])}CaptureFunctionParameters(){return this._functionParameters.map(t=>t.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 t=this._nextAsyncId++;this._currentAsyncId=t;let e;const s=new Promise(t=>e=t);return this._asyncMap.set(t,{resolve:e,pauseCount:0}),[t,s]}MaybeFinishAsyncFunctionCall(t){const e=this._asyncMap.get(t);0===e.pauseCount&&(e.resolve(),this._asyncMap.delete(t)),this._currentAsyncId=-1}PauseCurrentAsyncFunction(){const t=this._asyncMap.get(this._currentAsyncId);return t.pauseCount++,this._currentAsyncId}ResumeAsyncFunction(t){this._currentAsyncId=t;const e=this._asyncMap.get(t);e.pauseCount--}RunAsFamilyCustomActionWithOverrides(t,e){const s=new Map,n=[];for(const i of this._objectClass.GetCurrentSol().GetInstances()){const c=i.GetObjectClass();if(c.HasOwnCustomActionByName(this._aceName)){const a=s.get(c);Array.isArray(a)?a.push(i):s.set(c,[i])}else n.push(i)}if(0<n.length&&this._eventBlock.RunAsFunctionCall(t,e,this._isCopyPicked,{pickObjectClass:this._objectClass,pickInstances:n}),0<s.size)for(const[r,o]of s){const u=r.GetOwnCustomActionByName(this._aceName).GetEventBlock(),h=[...new Set([...t,...u.GetSolModifiers()])];u.RunAsFunctionCall(h,e,this._isCopyPicked,{pickObjectClass:r,pickInstances:o})}}*DebugRunAsFamilyCustomActionWithOverrides(t,e){const s=new Map,n=[];for(const i of this._objectClass.GetCurrentSol().GetInstances()){const c=i.GetObjectClass();if(c.HasOwnCustomActionByName(this._aceName)){const a=s.get(c);Array.isArray(a)?a.push(i):s.set(c,[i])}else n.push(i)}if(0<n.length&&(yield*this._eventBlock.DebugRunAsFunctionCall(t,e,this._isCopyPicked,{pickObjectClass:this._objectClass,pickInstances:n})),0<s.size)for(const[r,o]of s){const u=r.GetOwnCustomActionByName(this._aceName).GetEventBlock(),h=[...new Set([...t,...u.GetSolModifiers()])];yield*u.DebugRunAsFunctionCall(h,e,this._isCopyPicked,{pickObjectClass:r,pickInstances:o})}}}; } // events/eventVariable.js { const C3=self.C3,EMPTY_SOL_MODIFIERS=[];C3.EventVariable=class extends C3.DefendedBase{constructor(t,e,s){super();const i=t.GetEventSheetManager();this._eventSheet=t,this._eventSheetManager=i,this._runtime=t.GetRuntime(),this._parent=e,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=e instanceof C3.FunctionBlock,this._sid=s[6],this._jsPropName=this._runtime.GetJsPropName(s[8]),this._scriptSetter=t=>this.SetValue(t),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(t,e,s){return C3.New(C3.EventVariable,t,e,s)}_PostInit(){if(this.IsLocal()&&!this.IsStatic()&&!this.IsConstant()&&!this.IsFunctionParameter()){const t=this._eventSheetManager.FindFirstFunctionBlockParent(this);t&&t._RegisterLocalVariable(this)}}GetName(){return this._name}GetJsPropName(){return this._jsPropName}GetParent(){return this._parent}GetScopeParent(){return this.GetParent()}IsGlobal(){return!this.GetParent()}IsLocal(){return!this.IsGlobal()}IsFunctionParameter(){return this._isFunctionParameter}IsStatic(){return this._isStatic}IsConstant(){return this._isConstant}IsNumber(){return 0===this._type}IsString(){return 1===this._type}IsBoolean(){return 2===this._type}IsElseBlock(){return!1}GetSID(){return this._sid}GetInitialValue(){return this._initialValue}GetSolModifiers(){return EMPTY_SOL_MODIFIERS}Run(t){!this.IsLocal()||this.IsStatic()||this.IsConstant()||this.SetValue(this.GetInitialValue())}DebugCanRunFast(){return!0}*DebugRun(t){this.Run(t)}SetValue(t){this.IsNumber()?"number"!=typeof t&&(t=parseFloat(t)):this.IsString()?"string"!=typeof t&&(t=t.toString()):this.IsBoolean()&&(t=t?1:0),this._hasSingleValue?this._value=t:this._localVarStack.GetCurrent()[this._localIndex]=t}GetValue(){return this._hasSingleValue?this._value:this._localVarStack.GetCurrent()[this._localIndex]}GetTypedValue(){let t=this.GetValue();return t=this.IsBoolean()?!!t:t}ResetToInitialValue(){this._value=this._initialValue}_GetScriptInterfaceDescriptor(){return{configurable:!1,enumerable:!0,get:this._scriptGetter,set:this._scriptSetter}}}; } // events/eventInclude.js { const C3=self.C3,assert=self.assert,EMPTY_SOL_MODIFIERS=[];C3.EventInclude=class extends C3.DefendedBase{constructor(e,t,n){super();const s=e.GetEventSheetManager();this._eventSheet=e,this._eventSheetManager=s,this._runtime=e.GetRuntime(),this._parent=t,this._includeSheet=null,this._includeSheetName=n[1],this._isActive=!0}static Create(e,t,n){return C3.New(C3.EventInclude,e,t,n)}_PostInit(){this._includeSheet=this._eventSheetManager.GetEventSheetByName(this._includeSheetName),this._eventSheet._AddShallowInclude(this);let e=this.GetParent();for(;e;)e instanceof C3.EventBlock&&e.IsGroup()&&e._AddContainedInclude(this),e=e.GetParent();this.UpdateActive(),this._runtime.IsDebug()&&this._eventSheet._GetPerfRecord().children.push(this._includeSheet._GetPerfRecord())}GetParent(){return this._parent}GetSolModifiers(){return EMPTY_SOL_MODIFIERS}GetIncludeSheet(){return this._includeSheet}Run(e){const t=!!this.GetParent(),n=this._runtime.GetAllObjectClasses();t&&this._eventSheetManager.PushCleanSol(n),this._includeSheet.Run(),t&&this._eventSheetManager.PopSol(n)}*DebugRun(e){const t=!!this.GetParent(),n=this._runtime.GetAllObjectClasses();t&&this._eventSheetManager.PushCleanSol(n),yield*this._includeSheet.DebugRun(),t&&this._eventSheetManager.PopSol(n)}DebugCanRunFast(){return!1}IsActive(){return this._isActive}UpdateActive(){let e=this.GetParent();for(;e;){if(e instanceof C3.EventBlock&&e.IsGroup()&&!e.IsGroupActive())return void(this._isActive=!1);e=e.GetParent()}this._isActive=!0}}; } // events/expNode.js { const C3=self.C3,assert=self.assert;C3.ExpNode=class extends C3.DefendedBase{constructor(e){super(),this._owner=e,this._runtime=e.GetRuntime()}_PostInit(){}static CreateNode(e,t){const s=t[0],n=[BehaviorExpressionNode,ObjectExpressionNode,InstVarExpressionNode,EventVarExpNode,SystemExpressionExpNode,CallFunctionExpressionExpNode];return C3.New(n[s],e,t)}};class SystemExpressionExpNode extends C3.ExpNode{constructor(e,t){super(e),this._systemPlugin=this._runtime.GetSystemPlugin(),this._func=this._runtime.GetObjectReference(t[1]),this._func!==C3.Plugins.System.Exps.random&&this._func!==C3.Plugins.System.Exps.choose||this._owner.SetVariesPerInstance()}GetBoundMethod(){return this._systemPlugin._GetBoundACEMethod(this._func,this._systemPlugin)}}class CallFunctionExpressionExpNode extends C3.ExpNode{constructor(e,t){super(e),this._functionBlock=null,this._functionName=t[1],this._owner.SetVariesPerInstance()}_PostInit(){const e=this._runtime.GetEventSheetManager(),t=(this._functionBlock=e.GetFunctionBlockByName(this._functionName),this._functionName=null,this._owner.GetEventBlock()),s=this._functionBlock.GetEventBlock();this._combinedSolModifiers=[...new Set([...t.GetSolModifiersIncludingParents(),...s.GetSolModifiersIncludingParents()])],this._combinedSolModifiers=e._DeduplicateSolModifierList(this._combinedSolModifiers)}GetBoundMethod(){const e=this._functionBlock;if(e.IsEnabled()){const t=e.GetEventBlock();return C3.EventBlock.prototype.RunAsExpressionFunctionCall.bind(t,this._combinedSolModifiers,e.IsCopyPicked(),e.GetReturnType(),e.GetDefaultReturnValue())}{const s=e.GetDefaultReturnValue();return()=>s}}}function WrapIndex(e,t){return t<=e?e%t:(e<0&&(e<=-t&&(e%=t),e<0)&&(e+=t),e)}class ObjectExpressionNode extends C3.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(),n=s.length;if(0===n)return this._returnsString?"":0;const r=WrapIndex(this._owner.GetSolIndex(),n);return this._eventStack.GetCurrentStackFrame().SetExpressionObjectClass(t),this._func.apply(s[r].GetSdkInstance(),e)}ExpObject_InstExpr(e,...t){const s=this._objectClass,n=s.GetInstances(),r=n.length;if(0===r||"number"!=typeof e)return this._returnsString?"":0;const i=WrapIndex(e,r);return this._eventStack.GetCurrentStackFrame().SetExpressionObjectClass(s),this._func.apply(n[i].GetSdkInstance(),t)}}class InstVarExpressionNode extends C3.ExpNode{constructor(e,t){super(e),this._objectClass=this._runtime.GetObjectClassByIndex(t[1]),this._varIndex=t[3],this._returnsString=!!t[2],this._owner._MaybeVaryFor(this._objectClass)}ExpInstVar(){const e=this._objectClass.GetCurrentSol().GetExpressionInstances(),t=e.length;if(0===t)return this._returnsString?"":0;const s=WrapIndex(this._owner.GetSolIndex(),t);return e[s]._GetInstanceVariableValueUnchecked(this._varIndex)}ExpInstVar_Family(){const e=this._objectClass,t=e.GetCurrentSol().GetExpressionInstances(),s=t.length;if(0===s)return this._returnsString?"":0;const n=WrapIndex(this._owner.GetSolIndex(),s),r=t[n],i=r.GetObjectClass().GetFamilyInstanceVariableOffset(e.GetFamilyIndex());return r._GetInstanceVariableValueUnchecked(this._varIndex+i)}ExpInstVar_InstExpr(e){const t=this._objectClass,s=t.GetInstances(),n=s.length;if(0===n||"number"!=typeof e)return this._returnsString?"":0;const r=WrapIndex(e,n),i=s[r];let o=0;return t.IsFamily()&&(o=i.GetObjectClass().GetFamilyInstanceVariableOffset(t.GetFamilyIndex())),i._GetInstanceVariableValueUnchecked(this._varIndex+o)}}class BehaviorExpressionNode extends C3.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(),n=s.length;if(0===n)return this._returnsString?"":0;const r=WrapIndex(this._owner.GetSolIndex(),n),i=(this._eventStack.GetCurrentStackFrame().SetExpressionObjectClass(t),s[r]);let o=0;return t.IsFamily()&&(o=i.GetObjectClass().GetFamilyBehaviorOffset(t.GetFamilyIndex())),this._func.apply(i.GetBehaviorInstances()[this._behaviorIndex+o].GetSdkInstance(),e)}ExpBehavior_InstExpr(e,...t){const s=this._objectClass,n=s.GetInstances(),r=n.length;if(0===r||"number"!=typeof e)return this._returnsString?"":0;const i=WrapIndex(e,r),o=(this._eventStack.GetCurrentStackFrame().SetExpressionObjectClass(s),n[i]);let a=0;return s.IsFamily()&&(a=o.GetObjectClass().GetFamilyBehaviorOffset(s.GetFamilyIndex())),this._func.apply(o.GetBehaviorInstances()[this._behaviorIndex+a].GetSdkInstance(),t)}}class EventVarExpNode extends C3.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}} } // events/parameter.js { const C3=self.C3,assert=self.assert;function GetExpressionFunc(t){const e=self.C3_ExpressionFuncs[t];if(e)return e;throw new Error("invalid expression number")}C3.Parameter=class extends C3.DefendedBase{constructor(t,e,s){super(),this._owner=t,this._index=s,this._type=e,this.Get=null,this._variesPerInstance=!1,this._isConstant=!1}static Create(t,e,s){const r=e[0],n=[ExpressionParameter,StringExpressionParameter,FileParameter,ComboParameter,ObjectParameter,LayerExpressionParameter,LayoutParameter,ExpressionParameter,ComboParameter,ComboParameter,InstVarParameter,EventVarParameter,FileParameter,VariadicParameter,StringExpressionParameter,TimelineParameter,BooleanParameter,FunctionParameter,EaseParameter,TilemapBrushParameter,TemplateExpressionParameter,FlowchartParameter];return C3.New(n[r],t,r,s,e)}_PostInit(){}SetVariesPerInstance(){this._variesPerInstance=!0}_MaybeVaryFor(t){this._variesPerInstance||!t||t.GetPlugin().IsSingleGlobal()||(this._variesPerInstance=!0)}VariesPerInstance(){return this._variesPerInstance}GetIndex(){return this._index}GetRuntime(){return this._owner.GetRuntime()}GetEventBlock(){return this._owner.GetEventBlock()}IsConstant(){return this._isConstant}IsObjectParameter(){return 4===this._type}};class ExpressionParameter extends C3.Parameter{constructor(t,e,s,r){super(t,e,s),this._solIndex=0;const n=r[1];this._expressionNumber=n[0],this._numberedNodes=[],this._expressionFunc=null;for(let t=1,e=n.length;t<e;++t)this._numberedNodes.push(C3.ExpNode.CreateNode(this,n[t]));this._numberedNodes.length?this.Get=this.GetExpression:(this.Get=GetExpressionFunc(this._expressionNumber),this._isConstant=!0)}_GetNode(t){if(t<0||t>=this._numberedNodes.length)throw new RangeError("invalid numbered node");return this._numberedNodes[t]}_PostInit(){for(const e of this._numberedNodes)e._PostInit();const t=GetExpressionFunc(this._expressionNumber);this._numberedNodes.length?this._expressionFunc=t(this):this._expressionFunc=t}GetSolIndex(){return this._solIndex}GetExpression(t){return this._solIndex=t,this._expressionFunc()}}class StringExpressionParameter extends ExpressionParameter{constructor(t,e,s,r){super(t,e,s,r),this.Get=this.GetStringExpression,14===e&&(this.GetEventBlock().SetAllSolModifiers(),this._owner instanceof C3.Action)&&this.GetEventBlock().SetSolWriterAfterCnds()}GetStringExpression(t){this._solIndex=t;const e=this._expressionFunc();return"string"==typeof e?e:""}_GetFastTriggerValue(){return GetExpressionFunc(this._expressionNumber)()}}class LayerExpressionParameter extends ExpressionParameter{constructor(t,e,s,r){super(t,e,s,r),2<=t.GetImplementationSdkVersion()?this.Get=this.GetILayer:this.Get=this.GetLayer,this._isConstant=!1}GetLayer(t){this._solIndex=t;const e=this._expressionFunc(),s=this.GetRuntime().GetCurrentLayout();return s.GetLayer(e)}GetILayer(t){const e=this.GetLayer(t);return e?e.GetILayer():null}}class ComboParameter extends C3.Parameter{constructor(t,e,s,r){super(t,e,s),this._combo=r[1],this.Get=this.GetCombo,this._isConstant=!0}GetCombo(){return this._combo}}class BooleanParameter extends C3.Parameter{constructor(t,e,s,r){super(t,e,s),this._bool=r[1],this.Get=this.GetBoolean,this._isConstant=!0}GetBoolean(){return this._bool}}class ObjectParameter extends C3.Parameter{constructor(t,e,s,r){super(t,e,s),this._objectClass=this.GetRuntime().GetObjectClassByIndex(r[1]),2<=t.GetImplementationSdkVersion()?this.Get=this.GetIObjectClass:this.Get=this.GetObjectClass;const n=this.GetEventBlock();n._AddSolModifier(this._objectClass),this._owner instanceof C3.Action?n.SetSolWriterAfterCnds():n.GetParent()&&n.GetParent().SetSolWriterAfterCnds(),this._isConstant=!0}GetObjectClass(){return this._objectClass}GetIObjectClass(){return this._objectClass?this._objectClass.GetIObjectClass():null}}class LayoutParameter extends C3.Parameter{constructor(t,e,s,r){super(t,e,s),this._layout=this.GetRuntime().GetLayoutManager().GetLayoutByName(r[1]),2<=t.GetImplementationSdkVersion()?this.Get=this.GetILayout:this.Get=this.GetLayout,this._isConstant=!0}GetLayout(){return this._layout}GetILayout(){return this._layout?this._layout.GetILayout():null}}class TimelineParameter extends C3.Parameter{constructor(t,e,s,r){super(t,e,s),this._timeline=this.GetRuntime().GetTimelineManager().GetTimelineByName(r[1]),2<=t.GetImplementationSdkVersion()?this.Get=this.GetITimelineState:this.Get=this.GetTimeline,this._isConstant=!0}GetTimeline(){return this._timeline}GetITimelineState(){return this._timeline?this._timeline.GetITimelineState():null}}class FileParameter extends C3.Parameter{constructor(t,e,s,r){super(t,e,s),this._fileInfo=r[1],this.Get=this.GetFile,this._isConstant=!0}GetFile(){return this._fileInfo}}class InstVarParameter extends C3.Parameter{constructor(t,e,s,r){super(t,e,s),this._instVarIndex=r[1];const n=this._owner.GetObjectClass();!(this._owner instanceof C3.Condition&&this._owner.IsStatic())&&n&&n.IsFamily()?(this.Get=this.GetFamilyInstanceVariable,this.SetVariesPerInstance()):(this.Get=this.GetInstanceVariable,this._isConstant=!0)}GetInstanceVariable(){return this._instVarIndex}GetFamilyInstanceVariable(t){t=t||0;const e=this._owner.GetObjectClass(),s=e.GetCurrentSol(),r=s.GetInstances();let n=null;if(r.length)n=r[t%r.length].GetObjectClass();else if(s.HasAnyElseInstances()){const i=s.GetElseInstances();n=i[t%i.length].GetObjectClass()}else{if(!(0<e.GetInstanceCount()))return 0;{const a=e.GetInstances();n=a[t%a.length].GetObjectClass()}}return this._instVarIndex+n.GetFamilyInstanceVariableOffset(e.GetFamilyIndex())}}class EventVarParameter extends C3.Parameter{constructor(t,e,s,r){super(t,e,s),this._eventVarSid=r[1],this._eventVar=null,2<=t.GetImplementationSdkVersion()?this.Get=this.GetIEventVariable:this.Get=this.GetEventVariable,this._isConstant=!0}_PostInit(){this._eventVar=this.GetRuntime().GetEventSheetManager().GetEventVariableBySID(this._eventVarSid)}GetEventVariable(){return this._eventVar}GetIEventVariable(){return null}}class FunctionParameter extends C3.Parameter{constructor(t,e,s,r){super(t,e,s),this._functionBlockName=r[1],this._functionBlock=null,2<=t.GetImplementationSdkVersion()?this.Get=this.GetIFunction:this.Get=this.GetFunction,this._isConstant=!0}_PostInit(){this._functionBlock=this.GetRuntime().GetEventSheetManager().GetFunctionBlockByName(this._functionBlockName),this._functionBlockName=null}GetFunction(){return this._functionBlock}GetIFunction(){return null}}class VariadicParameter extends C3.Parameter{constructor(t,e,s,r){super(t,e,s),this._subParams=[],this._variadicRet=[],this._isConstant=!0;for(let t=1,e=r.length;t<e;++t){const n=C3.Parameter.Create(this._owner,r[t],0);this._subParams.push(n),this._variadicRet.push(0),n.IsConstant()||(this._isConstant=!1)}this.Get=this.GetVariadic}_PostInit(){for(const t of this._subParams)t._PostInit()}GetVariadic(){const s=this._subParams,r=this._variadicRet;for(let t=0,e=s.length;t<e;++t)r[t]=s[t].Get(0);return r}}class EaseParameter extends C3.Parameter{constructor(t,e,s,r){super(t,e,s),this._easeIndex=r[1],this.Get=this.GetEase,this._isConstant=!0}GetEase(){return this._easeIndex}}class TilemapBrushParameter extends C3.Parameter{constructor(t,e,s,r){super(t,e,s),this._brushIndex=r[1],this.Get=this.GetTilemapBrush,this._isConstant=!0}GetTilemapBrush(){return this._brushIndex}}class TemplateExpressionParameter extends ExpressionParameter{constructor(t,e,s,r){super(t,e,s,r),this.Get=this.GetTemplateName,this._isConstant=!1}GetTemplateName(){return this._expressionFunc()}}class FlowchartParameter extends C3.Parameter{constructor(t,e,s,r){super(t,e,s),this._flowchartDataItem=this.GetRuntime().GetFlowchartManager().GetFlowchartDataItemByName(r[1]),this.Get=this.GetFlowchartName,this._isConstant=!0}GetFlowchartName(){return this._flowchartDataItem.GetName()}} } // events/condition.js { const C3=self.C3,assert=self.assert;function EvalParams(s,n){for(let t=0,e=s.length;t<e;++t)n[t]=s[t].Get(0)}const EMPTY_PARAMS_ARRAY=[],noop=function(){};C3.Condition=class extends C3.DefendedBase{constructor(t,s,e){if(super(),this._eventBlock=t,this._runtime=t.GetRuntime(),this._index=e,this._func=this._runtime.GetObjectReference(s[1]),this._isTrigger=0<s[3],this._isFastTrigger=2===s[3],this._isLooping=!!s[4],this._isInverted=!!s[5],this._isStatic=!!s[6],this._sid=s[7],this._isInOrBlock=this._eventBlock.IsOrBlock(),this._objectClass=null,this._behaviorType=null,this._behaviorIndex=-1,this._systemPlugin=null,this.Run=noop,this.DebugRun=noop,this._parameters=[],this._results=[],this._anyParamVariesPerInstance=!1,this._savedData=null,this._unsavedData=null,this._debugData=this._runtime.IsDebug()?{isBreakpoint:s[8][0],canDebug:s[8][1]}:null,-1===s[0]?this._systemPlugin=this._runtime.GetSystemPlugin():(this._objectClass=this._runtime.GetObjectClassByIndex(s[0]),s[2]&&(this._behaviorType=this._objectClass.GetBehaviorTypeByName(s[2]),this._behaviorIndex=this._objectClass.GetBehaviorIndexByName(s[2])),this._eventBlock.GetParent()&&this._eventBlock.GetParent().SetSolWriterAfterCnds()),10===s.length){let e=s[9];for(let t of e)this._parameters.push(C3.Parameter.Create(this,t,this._parameters.length)),this._results.push(0)}0===this._parameters.length&&(this._parameters=EMPTY_PARAMS_ARRAY,this._results=EMPTY_PARAMS_ARRAY),this._eventBlock.GetEventSheetManager()._RegisterCondition(this)}static Create(t,e,s){return C3.New(C3.Condition,t,e,s)}_PostInit(){for(const t of this._parameters)t._PostInit(),t.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 t=this._systemPlugin,e=this._systemPlugin;this._SetRunMethodForBoundFunc(t,e,this._RunSystem)}_SetSingleGlobalRunMethod(){const t=this._objectClass.GetPlugin(),e=this._objectClass.GetSingleGlobalInstance().GetSdkInstance();this._SetRunMethodForBoundFunc(t,e,this._RunSingleGlobal)}_SetRunMethodForBoundFunc(t,e,s){const n=this._func,i=this._isInverted,r=this._parameters;if(0===r.length){const a=t._GetBoundACEMethod(n,e);i?this.Run=function(){return C3.xor(a(),i)}:this.Run=a}else if(1===r.length){const h=r[0];if(!i&&h.IsConstant())this.Run=t._GetBoundACEMethod_1param(n,e,h.Get(0));else{const o=t._GetBoundACEMethod(n,e);this.Run=function(){return C3.xor(o(h.Get(0)),i)}}}else if(2===r.length){const l=r[0],u=r[1];if(!i&&l.IsConstant()&&u.IsConstant())this.Run=t._GetBoundACEMethod_2params(n,e,l.Get(0),u.Get(0));else{const _=t._GetBoundACEMethod(n,e);this.Run=function(){return C3.xor(_(l.Get(0),u.Get(0)),i)}}}else if(3===r.length){const c=r[0],g=r[1],d=r[2];if(!i&&c.IsConstant()&&g.IsConstant()&&d.IsConstant())this.Run=t._GetBoundACEMethod_3params(n,e,c.Get(0),g.Get(0),d.Get(0));else{const I=t._GetBoundACEMethod(n,e);this.Run=function(){return C3.xor(I(c.Get(0),g.Get(0),d.Get(0)),i)}}}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 t=this.GetImplementationAddon();return t?t.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 t of this._parameters)if(t.IsObjectParameter())return t.GetObjectClass();return null}_SetBreakpoint(t){this._debugData.isBreakpoint=!!t,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 t=this._results;return EvalParams(this._parameters,t),C3.xor(this._func.apply(this._systemPlugin,t),this._isInverted)}*_DebugRunSystem(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const e=this._results;EvalParams(this._parameters,e);let t=this._func.apply(this._systemPlugin,e);return C3.IsIterator(t)&&(t=yield*t),C3.xor(t,this._isInverted)}return this.Run()}_RunSingleGlobal(){const t=this._results,e=(EvalParams(this._parameters,t),this._objectClass.GetSingleGlobalInstance().GetSdkInstance());return C3.xor(this._func.apply(e,t),this._isInverted)}*_DebugRunSingleGlobal(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const e=this._results,s=(EvalParams(this._parameters,e),this._objectClass.GetSingleGlobalInstance().GetSdkInstance());let t=this._func.apply(s,e);return C3.IsIterator(t)&&(t=yield*t),C3.xor(t,this._isInverted)}return this.Run()}_RunFastTrigger(){return!0}*_DebugRunFastTrigger(){return(this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),!0}_GetStaticConditionThis(){return this._behaviorType?2<=this._behaviorType.GetBehavior().GetSdkVersion()?this._behaviorType.GetIBehaviorType():this._behaviorType:2<=this._objectClass.GetPlugin().GetSdkVersion()?this._objectClass.GetIObjectClass():this._objectClass}_RunStatic(){const t=this._results,e=(EvalParams(this._parameters,t),this._func.apply(this._GetStaticConditionThis(),t));return this._objectClass.ApplySolToContainer(),e}*_DebugRunStatic(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const e=this._results;EvalParams(this._parameters,e);let t=this._func.apply(this._GetStaticConditionThis(),e);return C3.IsIterator(t)&&(t=yield*t),this._objectClass.ApplySolToContainer(),t}return this.Run()}_RunObject(){const s=this._parameters,n=this._results,t=this._objectClass.GetCurrentSol();for(let t=0,e=s.length;t<e;++t){const i=s[t];i.VariesPerInstance()||(n[t]=i.Get(0))}return t.IsSelectAll()?this._RunObject_FirstFilter(t):this._RunObject_NextFilter(t)}*_DebugRunObject(){return(this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._RunObject()}_EvaluateVaryingParameters(s){const n=this._parameters,i=this._results;for(let t=0,e=n.length;t<e;++t){const r=n[t];r.VariesPerInstance()&&(i[t]=r.Get(s))}}_RunObject_FirstFilter(s){const t=this._objectClass,n=t.IsFamily(),i=t.GetFamilyIndex(),r=this._behaviorIndex,a=0<=r,h=t.GetInstances(),o=this._anyParamVariesPerInstance,l=this._results,u=this._func,_=this._isInverted,c=this._isInOrBlock&&!this._isTrigger;s.ClearArrays();for(let e=0,t=h.length;e<t;++e){const g=h[e];o&&this._EvaluateVaryingParameters(e);let t;if(a){const d=n?g.GetObjectClass().GetFamilyBehaviorOffset(i):0;t=u.apply(g.GetBehaviorInstances()[r+d].GetSdkInstance(),l)}else t=u.apply(g.GetSdkInstance(),l);C3.xor(t,_)?s._PushInstance(g):c&&s._PushElseInstance(g)}return t.FinishCondition(!0),s._SetSelectAll(!1),t.ApplySolToContainer(),s.HasAnyInstances()}_RunObject_NextFilter(t){const e=this._objectClass,s=e.IsFamily(),n=e.GetFamilyIndex(),i=e.IsInContainer(),r=this._behaviorIndex,a=0<=r,h=this._anyParamVariesPerInstance,o=this._results,l=this._func,u=this._isInverted,_=this._isInOrBlock&&!this._isTrigger,c=t._GetOwnInstances(),g=t._GetOwnElseInstances(),d=_&&!this._eventBlock.IsFirstConditionOfType(this),I=d?g:c;let G=0,b=!1;for(let e=0,t=I.length;e<t;++e){const p=I[e];h&&this._EvaluateVaryingParameters(e);let t;if(a){const C=s?p.GetObjectClass().GetFamilyBehaviorOffset(n):0;t=l.apply(p.GetBehaviorInstances()[r+C].GetSdkInstance(),o)}else t=l.apply(p.GetSdkInstance(),o);C3.xor(t,u)?(b=!0,d?(c.push(p),i&&p._PushSiblingsToSolInstances()):(I[G]=p,i&&p._SetSiblingsToSolInstancesIndex(G),++G)):d?(I[G]=p,i&&p._SetSiblingsToSolElseInstancesIndex(G),++G):_&&(g.push(p),i)&&p._PushSiblingsToSolElseInstances()}C3.truncateArray(I,G),i&&e._TruncateContainerSols(d,G);const m=b;return d&&!b&&(b=this._OrBlockCheckInstances(c)),e.FinishCondition(m||_),_?b:t.HasAnyInstances()}_OrBlockCheckInstances(s){const t=this._objectClass,n=t.IsFamily(),i=t.GetFamilyIndex(),r=this._anyParamVariesPerInstance,a=this._behaviorIndex,h=0<=a,o=this._results,l=this._func,u=this._isInverted;for(let e=0,t=s.length;e<t;++e){const _=s[e];r&&this._EvaluateVaryingParameters(e);let t;if(h){const c=n?_.GetObjectClass().GetFamilyBehaviorOffset(i):0;t=l.apply(_.GetBehaviorInstances()[a+c].GetSdkInstance(),o)}else t=l.apply(_.GetSdkInstance(),o);if(C3.xor(t,u))return!0}return!1}ReevaluateParameter(t,e){return this._parameters[t].Get(e)}GetFastTriggerValue(){const t=this._parameters;if(t.length)return t[0]._GetFastTriggerValue();throw new Error("no parameters")}_SaveToJson(){if(!this._savedData||!this._savedData.size)return null;const e={};for(const[s,n]of this._savedData.entries()){let t=n;"collmemory"===s&&(t=[...n.entries()].map(t=>[t[0].GetUID(),t[1].GetUID(),t[2]])),e[s]=t}return{"ex":e}}_LoadFromJson(t){if(this._savedData&&(this._savedData.clear(),this._savedData=null),t){const e=this._runtime,s=t["ex"];if(s){const n=this.GetSavedDataMap();n.clear();for(const[i,r]of Object.entries(s)){let t=r;"collmemory"===i&&(t=C3.New(C3.PairMap,r.map(t=>[e.GetInstanceByUID(t[0]),e.GetInstanceByUID(t[1]),t[2]]).filter(t=>t[0]&&t[1]))),n.set(i,t)}}}}}; } // events/action.js { const C3=self.C3,assert=self.assert;function EvalParams(s,n){for(let t=0,e=s.length;t<e;++t)n[t]=s[t].Get(0)}const EMPTY_PARAMS_ARRAY=[],noop=function(){},noopGenerator=function*(){},FLAG_CANPICKANYOBJECTCLASS=1,FLAG_COPYPICKED=2,FLAG_CUSTOM_ACE=4,FLAG_IS_ASYNC=8,FLAG_CAN_BAIL_OUT=16;C3.Action=class extends C3.DefendedBase{constructor(t,e,s){super();const n=(this._eventBlock=t).GetRuntime(),i=(this._runtime=n,this._index=s,this._sid=4<=e.length?e[3]:-1,this._actionType=5<=e.length?255&e[4]:0,this._flags=5<=e.length?e[4]>>8:0,this._func=null,this._objectClass=null,this._behaviorType=null,this._behaviorIndex=-1,this._systemPlugin=null,this._callFunctionName="",this._callCustomAceObjectClass=null,this._callEventBlock=null,this.Run=noop,this.DebugRun=noop,this._parameters=[],this._results=[],this._anyParamVariesPerInstance=!1,this._savedData=null,this._unsavedData=null,-3===e[0]),a=i?e[2]:e[5];if(this._debugData=n.IsDebug()||i?{isBreakpoint:a[0],canDebug:a[1],index:a[2]}:null,-1===e[0])this._systemPlugin=n.GetSystemPlugin(),this._func=n.GetObjectReference(e[1]);else if(-2===e[0])this._callFunctionName=e[1];else if(i){const r=n.GetObjectReference(e[1]);this._func=r,this.Run=this.RunUserScript,this.DebugRun=this.DebugRunUserScript,this._flags|=FLAG_IS_ASYNC}else this._objectClass=n.GetObjectClassByIndex(e[0]),this._flags&FLAG_CUSTOM_ACE?(this._callFunctionName=e[1],this._callCustomAceObjectClass=n.GetObjectClassByIndex(e[2])):(e[2]&&(this._behaviorType=this._objectClass.GetBehaviorTypeByName(e[2]),this._behaviorIndex=this._objectClass.GetBehaviorIndexByName(e[2])),this._func=n.GetObjectReference(e[1]));if(7===e.length){const o=e[6];for(const e of o)this._parameters.push(C3.Parameter.Create(this,e,this._parameters.length)),this._results.push(0)}0===this._parameters.length&&(this._parameters=EMPTY_PARAMS_ARRAY,this._results=EMPTY_PARAMS_ARRAY),this.CanPickAnyObjectClass()&&(this._eventBlock.SetAllSolModifiers(),this._eventBlock.SetSolWriterAfterCnds()),this._eventBlock.GetEventSheetManager()._RegisterAction(this)}static Create(t,e,s){return C3.New(C3.Action,t,e,s)}_PostInit(){for(const t of this._parameters)t._PostInit(),t.VariesPerInstance()&&(this._anyParamVariesPerInstance=!0);if(this._systemPlugin)this._SetSystemRunMethod(),this.DebugRun=this._DebugRunSystem;else if(this._callFunctionName)this._flags&FLAG_CUSTOM_ACE?this._SetCallCustomActionRunMethod():this._SetCallFunctionRunMethod(),this._callFunctionName="",this._callCustomAceObjectClass=null;else if(this.Run===this.RunUserScript){const e=this._func,s=this._runtime.GetEventSheetManager()._GetLocalVariablesScriptInterface(this._eventBlock);this._func=e.bind(null,this._runtime.GetIRuntime(),s)}else this._behaviorType?this.IsAsync()?(this.Run=this._RunBehavior_Async,this.DebugRun=this._DebugRunBehavior_Async):(this.Run=this._RunBehavior,this.DebugRun=this._DebugRunBehavior):this._objectClass.GetPlugin().IsSingleGlobal()?(this._SetSingleGlobalRunMethod(),this.DebugRun=this._DebugRunSingleGlobal):this.IsStatic()?(this.Run=this._RunObject_Static,this.DebugRun=this._DebugRunObject_Static):this.IsAsync()?(this.Run=this._RunObject_Async,this.DebugRun=this._DebugRunObject_Async):this.CallBeforeAfterHooks()?(this.Run=this._RunObject_BeforeAfterHooks,this.DebugRun=this._DebugRunObject_BeforeAfterHooks):this._parameters.length?this._parameters.every(t=>t.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(t=>t.IsConstant())?(EvalParams(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 t=this._systemPlugin,e=this._systemPlugin;this._SetRunMethodForBoundFunc(t,e,this._RunSystem)}_SetSingleGlobalRunMethod(){const t=this._objectClass.GetPlugin(),e=this._objectClass.GetSingleGlobalInstance().GetSdkInstance();this._SetRunMethodForBoundFunc(t,e,this._RunSingleGlobal)}_SetCallFunctionRunMethod(){const t=this._eventBlock.GetEventSheetManager(),s=t.GetFunctionBlockByName(this._callFunctionName);if(s.IsEnabled()){const n=0!=(this._flags&FLAG_COPYPICKED);this._callEventBlock=s.GetEventBlock();let e=[...new Set([...this._eventBlock.GetSolModifiersIncludingParents(),...this._callEventBlock.GetSolModifiersIncludingParents()])];e=t._DeduplicateSolModifierList(e);const i=!s.IsCopyPicked()&&this._HasCopyPickedParent()?{pushCleanSolDynamic:!0}:null;if(this.Run=C3.EventBlock.prototype.RunAsFunctionCall.bind(this._callEventBlock,e,this._parameters,n,i),this._runtime.IsDebug()){const a=this;this.DebugRun=function*(){(a.IsBreakpoint()||a._runtime.DebugBreakNext())&&(yield a);const t=yield*a._callEventBlock.DebugRunAsFunctionCall(e,a._parameters,n,i);return t}}else this.DebugRun=noopGenerator}else this.Run=noop,this.DebugRun=noopGenerator}_SetCallCustomActionRunMethod(){const t=this._eventBlock.GetEventSheetManager(),n=t.GetCustomActionBlockByName(this._callCustomAceObjectClass,this._callFunctionName);if(n.IsEnabled()){const i=0!=(this._flags&FLAG_COPYPICKED);this._callEventBlock=n.GetEventBlock();let e=[...new Set([...this._eventBlock.GetSolModifiersIncludingParents(),...this._callEventBlock.GetSolModifiersIncludingParents(),this._objectClass,n.GetObjectClass()])];e=t._DeduplicateSolModifierList(e);const a=!this._objectClass.IsFamily()&&!n.GetObjectClass().IsFamily(),r=!this._objectClass.IsFamily()&&n.GetObjectClass().IsFamily(),o=this._objectClass.IsFamily();let s=null;if(!n.IsCopyPicked()&&this._HasCopyPickedParent()&&((s=s||{}).pushCleanSolDynamic=!0),!r&&i||((s=s||{}).copyFromObjectClass=this._objectClass,s.copyToObjectClass=n.GetObjectClass()),a||r||o&&!n.HasCustomACEOverrides()?this.Run=C3.EventBlock.prototype.RunAsFunctionCall.bind(this._callEventBlock,e,this._parameters,i,s):o&&(this.Run=C3.FunctionBlock.prototype.RunAsFamilyCustomActionWithOverrides.bind(n,e,this._parameters)),this._runtime.IsDebug()){const l=this;a||r||o&&!n.HasCustomACEOverrides()?this.DebugRun=function*(){(l.IsBreakpoint()||l._runtime.DebugBreakNext())&&(yield l);const t=yield*l._callEventBlock.DebugRunAsFunctionCall(e,l._parameters,i,s);return t}:o&&(this.DebugRun=function*(){(l.IsBreakpoint()||l._runtime.DebugBreakNext())&&(yield l);const t=yield*n.DebugRunAsFamilyCustomActionWithOverrides(e,l._parameters);return t})}else this.DebugRun=noopGenerator}else this.Run=noop,this.DebugRun=noopGenerator}_SetRunMethodForBoundFunc(t,e,s){const n=this._func,i=this._parameters;if(0===i.length)this.Run=t._GetBoundACEMethod(n,e);else if(1===i.length){const a=i[0];if(a.IsConstant())this.Run=t._GetBoundACEMethod_1param(n,e,a.Get(0));else{const r=t._GetBoundACEMethod(n,e);this.Run=function(){return r(a.Get(0))}}}else if(2===i.length){const o=i[0],l=i[1];if(o.IsConstant()&&l.IsConstant())this.Run=t._GetBoundACEMethod_2params(n,e,o.Get(0),l.Get(0));else{const h=t._GetBoundACEMethod(n,e);this.Run=function(){return h(o.Get(0),l.Get(0))}}}else if(3===i.length){const u=i[0],c=i[1],_=i[2];if(u.IsConstant()&&c.IsConstant()&&_.IsConstant())this.Run=t._GetBoundACEMethod_3params(n,e,u.Get(0),c.Get(0),_.Get(0));else{const b=t._GetBoundACEMethod(n,e);this.Run=function(){return b(u.Get(0),c.Get(0),_.Get(0))}}}else this.Run=s}GetSID(){return this._sid}IsAsync(){return 0!=(this._flags&FLAG_IS_ASYNC)}CanBailOut(){return 0!=(this._flags&FLAG_CAN_BAIL_OUT)}CallBeforeAfterHooks(){return 1===this._actionType}IsStatic(){return 2===this._actionType}CanPickAnyObjectClass(){return 0!=(this._flags&FLAG_CANPICKANYOBJECTCLASS)}HasReturnType(){return this.IsAsync()||this.CanBailOut()}GetObjectClass(){return this._objectClass}GetImplementationAddon(){return this._behaviorType?this._behaviorType.GetBehavior():this._objectClass?this._objectClass.GetPlugin():null}GetImplementationSdkVersion(){const t=this.GetImplementationAddon();return t?t.GetSdkVersion():1}GetEventBlock(){return this._eventBlock}_HasCopyPickedParent(){let t=this._eventBlock;do{if(t instanceof C3.FunctionBlock&&t.IsCopyPicked())return!0}while(t=t.GetScopeParent());return!1}GetRuntime(){return this._runtime}GetIndex(){return this._index}GetDebugIndex(){return this._debugData.index}IsBreakpoint(){return this._debugData.isBreakpoint}_SetBreakpoint(t){this._debugData.isBreakpoint=!!t,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 t=this._results;return EvalParams(this._parameters,t),this._func.apply(this._systemPlugin,t)}*_DebugRunSystem(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const t=this._results,e=(EvalParams(this._parameters,t),yield*this._func.apply(this._systemPlugin,t));return e}return this.Run()}_RunSingleGlobal(){const t=this._results;return EvalParams(this._parameters,t),this._func.apply(this._objectClass.GetSingleGlobalInstance().GetSdkInstance(),t)}*_DebugRunSingleGlobal(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const t=this._results,e=(EvalParams(this._parameters,t),yield*this._func.apply(this._objectClass.GetSingleGlobalInstance().GetSdkInstance(),t));return e}return this.Run()}_RunObject_ParamsConst(){const s=this._results,n=this._objectClass.GetCurrentSol().GetInstances();for(let t=0,e=n.length;t<e;++t)this._func.apply(n[t].GetSdkInstance(),s)}*_DebugRunObject_ParamsConst(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const s=this._results,n=this._objectClass.GetCurrentSol().GetInstances();for(let t=0,e=n.length;t<e;++t)yield*this._func.apply(n[t].GetSdkInstance(),s)}else this._RunObject_ParamsConst()}_RunObject_ParamsDontVary(){const s=this._results,n=(EvalParams(this._parameters,s),this._objectClass.GetCurrentSol().GetInstances());for(let t=0,e=n.length;t<e;++t)this._func.apply(n[t].GetSdkInstance(),s)}*_DebugRunObject_ParamsDontVary(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const s=this._results,n=(EvalParams(this._parameters,s),this._objectClass.GetCurrentSol().GetInstances());for(let t=0,e=n.length;t<e;++t)yield*this._func.apply(n[t].GetSdkInstance(),s)}else this._RunObject_ParamsDontVary()}_RunObject_AllParamsVary(){const n=this._parameters,i=this._results,e=this._func,a=this._objectClass.GetCurrentSol().GetInstances();for(let s=0,t=a.length;s<t;++s){const r=a[s];for(let t=0,e=n.length;t<e;++t)i[t]=n[t].Get(s);e.apply(r.GetSdkInstance(),i)}}*_DebugRunObject_AllParamsVary(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const n=this._parameters,i=this._results,e=this._func,a=this._objectClass.GetCurrentSol().GetInstances();for(let s=0,t=a.length;s<t;++s){const r=a[s];for(let t=0,e=n.length;t<e;++t)i[t]=n[t].Get(s);yield*e.apply(r.GetSdkInstance(),i)}}else this._RunObject_AllParamsVary()}_RunObject_SomeParamsVary(){const n=this._parameters,i=this._results,e=this._func,a=this._objectClass.GetCurrentSol().GetInstances();for(let t=0,e=n.length;t<e;++t){const s=n[t];s.VariesPerInstance()||(i[t]=s.Get(0))}for(let s=0,t=a.length;s<t;++s){const r=a[s];for(let t=0,e=n.length;t<e;++t){const o=n[t];o.VariesPerInstance()&&(i[t]=o.Get(s))}e.apply(r.GetSdkInstance(),i)}}*_DebugRunObject_SomeParamsVary(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const n=this._parameters,i=this._results,e=this._func,a=this._objectClass.GetCurrentSol().GetInstances();for(let t=0,e=n.length;t<e;++t){const s=n[t];s.VariesPerInstance()||(i[t]=s.Get(0))}for(let s=0,t=a.length;s<t;++s){const r=a[s];for(let t=0,e=n.length;t<e;++t){const o=n[t];o.VariesPerInstance()&&(i[t]=o.Get(s))}yield*e.apply(r.GetSdkInstance(),i)}}else this._RunObject_SomeParamsVary()}_RunObject_BeforeAfterHooks(){const n=this._parameters,i=this._results,e=this._func,t=this._objectClass,s=t.GetSdkType(),a=t.GetCurrentSol().GetInstances();s.BeforeRunAction(e);for(let s=0,t=a.length;s<t;++s){const r=a[s];for(let t=0,e=n.length;t<e;++t)i[t]=n[t].Get(s);e.apply(r.GetSdkInstance(),i)}s.AfterRunAction(e)}*_DebugRunObject_BeforeAfterHooks(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const n=this._parameters,i=this._results,e=this._func,t=this._objectClass,s=t.GetSdkType(),a=t.GetCurrentSol().GetInstances();s.BeforeRunAction(e);for(let s=0,t=a.length;s<t;++s){const r=a[s];for(let t=0,e=n.length;t<e;++t)i[t]=n[t].Get(s);yield*e.apply(r.GetSdkInstance(),i)}s.AfterRunAction(e)}else this._RunObject_BeforeAfterHooks()}_GetStaticActionThis(){return this._behaviorType?2<=this._behaviorType.GetBehavior().GetSdkVersion()?this._behaviorType.GetIBehaviorType():this._behaviorType:2<=this._objectClass.GetPlugin().GetSdkVersion()?this._objectClass.GetIObjectClass():this._objectClass}_RunObject_Static(){const t=this._results;return EvalParams(this._parameters,t),this._func.apply(this._GetStaticActionThis(),t)}*_DebugRunObject_Static(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const e=this._results;EvalParams(this._parameters,e);let t=this._func.apply(this._GetStaticActionThis(),e);return t=C3.IsIterator(t)?yield*t:t}return this._RunObject_Static()}_RunBehavior(){const t=this._objectClass,e=t.IsFamily(),n=t.GetFamilyIndex(),i=this._parameters,a=this._anyParamVariesPerInstance,r=this._results,o=this._func,l=this._behaviorIndex,h=t.GetCurrentSol().GetInstances();for(let t=0,e=i.length;t<e;++t){const s=i[t];s.VariesPerInstance()||(r[t]=s.Get(0))}for(let s=0,t=h.length;s<t;++s){const u=h[s];if(a)for(let t=0,e=i.length;t<e;++t){const _=i[t];_.VariesPerInstance()&&(r[t]=_.Get(s))}const c=e?u.GetObjectClass().GetFamilyBehaviorOffset(n):0;o.apply(u.GetBehaviorInstances()[l+c].GetSdkInstance(),r)}}*_DebugRunBehavior(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const t=this._objectClass,e=t.IsFamily(),n=t.GetFamilyIndex(),i=this._parameters,a=this._anyParamVariesPerInstance,r=this._results,o=this._func,l=this._behaviorIndex,h=t.GetCurrentSol().GetInstances();for(let t=0,e=i.length;t<e;++t){const s=i[t];s.VariesPerInstance()||(r[t]=s.Get(0))}for(let s=0,t=h.length;s<t;++s){const u=h[s];if(a)for(let t=0,e=i.length;t<e;++t){const _=i[t];_.VariesPerInstance()&&(r[t]=_.Get(s))}const c=e?u.GetObjectClass().GetFamilyBehaviorOffset(n):0;yield*o.apply(u.GetBehaviorInstances()[l+c].GetSdkInstance(),r)}}else this._RunBehavior()}_RunObject_Async(){const n=this._parameters,i=this._results,e=this._func,a=this._objectClass.GetCurrentSol().GetInstances(),r=[];for(let s=0,t=a.length;s<t;++s){const o=a[s];for(let t=0,e=n.length;t<e;++t)i[t]=n[t].Get(s);r.push(e.apply(o.GetSdkInstance(),i))}return Promise.all(r)}*_DebugRunObject_Async(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const n=this._parameters,i=this._results,e=this._func,a=this._objectClass.GetCurrentSol().GetInstances(),r=[];for(let s=0,t=a.length;s<t;++s){const o=a[s];for(let t=0,e=n.length;t<e;++t)i[t]=n[t].Get(s);r.push(yield*e.apply(o.GetSdkInstance(),i))}return Promise.all(r)}return this._RunObject_Async()}_RunBehavior_Async(){const t=this._objectClass,e=t.IsFamily(),n=t.GetFamilyIndex(),i=this._parameters,a=this._results,r=this._func,o=this._behaviorIndex,l=t.GetCurrentSol().GetInstances(),h=[];for(let s=0,t=l.length;s<t;++s){const u=l[s];for(let t=0,e=i.length;t<e;++t)a[t]=i[t].Get(s);const c=e?u.GetObjectClass().GetFamilyBehaviorOffset(n):0;h.push(r.apply(u.GetBehaviorInstances()[o+c].GetSdkInstance(),a))}return Promise.all(h)}*_DebugRunBehavior_Async(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const t=this._objectClass,e=t.IsFamily(),n=t.GetFamilyIndex(),i=this._parameters,a=this._results,r=this._func,o=this._behaviorIndex,l=t.GetCurrentSol().GetInstances(),h=[];for(let s=0,t=l.length;s<t;++s){const u=l[s];for(let t=0,e=i.length;t<e;++t)a[t]=i[t].Get(s);const c=e?u.GetObjectClass().GetFamilyBehaviorOffset(n):0;h.push(yield*r.apply(u.GetBehaviorInstances()[o+c].GetSdkInstance(),a))}return Promise.all(h)}return this._RunBehavior_Async()}async RunUserScript(){try{await this._func()}catch(t){console.error(`Unhandled exception running script %c${this._eventBlock.GetEventSheet().GetName()}, event ${this._eventBlock.GetDisplayNumber()}, action ${this.GetDebugIndex()+1}:`,"font-size: 1.2em; font-weight: bold;",t),self.C3Debugger&&self.C3Debugger._SetLastErrorScript(this),C3.EventScript.HadUserScriptException()||(console.info("%cTip:%c run this to highlight in Construct the last script that had an error: %cgoToLastErrorScript()","font-weight: bold; text-decoration: underline","","font-weight: bold"),C3.EventScript.SetHadUserScriptException())}}*DebugRunUserScript(){return(this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this.RunUserScript()}_SaveToJson(){return this._savedData&&this._savedData.size?{"ex":C3.ToSuperJSON(this._savedData)}:null}_LoadFromJson(t){if(this._savedData&&(this._savedData.clear(),this._savedData=null),t){const e=t["ex"];e&&(this._savedData=C3.FromSuperJSON(e))}}}; } // events/commonACEs.js { const C3=self.C3,tempColor=new C3.Color,AnySDK={},SDKv1={},SDKv2={};let runtime=null;C3.CommonACES_SetRuntime=function(t){runtime=t};const IInstance=self.IInstance,IObjectClass=self.IObjectClass,ILayer=self.ILayer;function GetInst(t){return t instanceof IInstance?runtime._UnwrapScriptInterface(t):t.GetInstance()}function GetWorldInfo(t){return GetInst(t).GetWorldInfo()}function GetInst_SDKv2(t){return runtime._UnwrapScriptInterface(t)}function GetWorldInfo_SDKv2(t){return GetInst_SDKv2(t).GetWorldInfo()}function GetObjectClass(t){return t instanceof IObjectClass?runtime._UnwrapScriptInterface(t):t}function GetLayer(t){return t instanceof ILayer?runtime._UnwrapScriptInterface(t):t}SDKv1.CompareX=function(t,e){return C3.compare(this.GetWorldInfo().GetX(),t,e)},SDKv2.CompareX=function(t,e){return C3.compare(this.x,t,e)},SDKv1.CompareY=function(t,e){return C3.compare(this.GetWorldInfo().GetY(),t,e)},SDKv2.CompareY=function(t,e){return C3.compare(this.y,t,e)},SDKv1.IsOnScreen=function(){return this.GetWorldInfo().IsInViewport2()},SDKv2.IsOnScreen=function(){return this.isOnScreen()},AnySDK.IsOutsideLayout=function(){const t=GetWorldInfo(this),e=t.GetLayout(),n=t.GetBoundingBox();return n.getRight()<0||n.getBottom()<0||n.getLeft()>e.GetWidth()||n.getTop()>e.GetHeight()},AnySDK.PickDistance=function(n,o,s){const t=GetObjectClass(this),e=t.GetCurrentSol(),i=e.GetInstances();if(!i.length)return!1;let r=i[0],a=r.GetWorldInfo(),l=r,c=C3.distanceSquared(a.GetX(),a.GetY(),o,s);for(let t=1,e=i.length;t<e;++t){r=i[t],a=r.GetWorldInfo();const u=C3.distanceSquared(a.GetX(),a.GetY(),o,s);(0===n&&u<c||1===n&&u>c)&&(c=u,l=r)}return e.PickOne(l),!0},SDKv1.SetX=function(t){const e=this.GetWorldInfo();e.GetX()!==t&&(e.SetX(t),e.SetBboxChanged())},SDKv2.SetX=function(t){this.x=+t},SDKv1.SetY=function(t){const e=this.GetWorldInfo();e.GetY()!==t&&(e.SetY(t),e.SetBboxChanged())},SDKv2.SetY=function(t){this.y=+t},SDKv1.SetPos=function(t,e){const n=this.GetWorldInfo();n.EqualsXY(t,e)||(n.SetXY(t,e),n.SetBboxChanged())},SDKv2.SetPos=function(t,e){this.setPosition(t,e)},AnySDK.SetPosToObject=function(t,e){if(t=GetObjectClass(t)){const n=GetInst(this),o=t.GetPairedInstance(n);if(o){const[s,i]=o.GetImagePoint(e),r=n.GetWorldInfo();r.GetX()===s&&r.GetY()===i||(r.SetXY(s,i),r.SetBboxChanged())}}},AnySDK.MoveForward=function(t){if(0!==t){const e=GetWorldInfo(this);e.OffsetXY(e.GetCosAngle()*t,e.GetSinAngle()*t),e.SetBboxChanged()}},SDKv1.MoveAtAngle=function(t,e){if(0!==e){const n=this.GetWorldInfo();t=C3.toRadians(t),n.OffsetXY(Math.cos(t)*e,Math.sin(t)*e),n.SetBboxChanged()}},SDKv2.MoveAtAngle=function(t,e){0!==e&&(t=C3.toRadians(t),this.offsetPosition(Math.cos(t)*e,Math.sin(t)*e))},SDKv1.GetX=function(){return this.GetWorldInfo().GetX()},SDKv2.GetX=function(){return this.x},SDKv1.GetY=function(){return this.GetWorldInfo().GetY()},SDKv2.GetY=function(){return this.y},AnySDK.GetDt=function(){return runtime.GetDt(GetInst(this))},SDKv1.CompareWidth=function(t,e){return C3.compare(this.GetWorldInfo().GetWidth(),t,e)},SDKv2.CompareWidth=function(t,e){return C3.compare(this.width,t,e)},SDKv1.CompareHeight=function(t,e){return C3.compare(this.GetWorldInfo().GetHeight(),t,e)},SDKv2.CompareHeight=function(t,e){return C3.compare(this.height,t,e)},SDKv1.SetWidth=function(t){const e=this.GetWorldInfo();e.GetWidth()!==t&&(e.SetWidth(t),e.SetBboxChanged())},SDKv2.SetWidth=function(t){this.width=t},SDKv1.SetHeight=function(t){const e=this.GetWorldInfo();e.GetHeight()!==t&&(e.SetHeight(t),e.SetBboxChanged())},SDKv2.SetHeight=function(t){this.height=t},SDKv1.SetSize=function(t,e){const n=GetWorldInfo(this);n.GetWidth()===t&&n.GetHeight()===e||(n.SetSize(t,e),n.SetBboxChanged())},SDKv2.SetSize=function(t,e){this.setSize(t,e)},SDKv1.GetWidth=function(){return this.GetWorldInfo().GetWidth()},SDKv2.GetWidth=function(){return this.width},SDKv1.GetHeight=function(){return this.GetWorldInfo().GetHeight()},SDKv2.GetHeight=function(){return this.height},AnySDK.GetBboxLeft=function(){return GetWorldInfo(this).GetBoundingBox().getLeft()},AnySDK.GetBboxTop=function(){return GetWorldInfo(this).GetBoundingBox().getTop()},AnySDK.GetBboxRight=function(){return GetWorldInfo(this).GetBoundingBox().getRight()},AnySDK.GetBboxBottom=function(){return GetWorldInfo(this).GetBoundingBox().getBottom()},AnySDK.GetBboxMidX=function(){const t=GetWorldInfo(this).GetBoundingBox();return(t.getLeft()+t.getRight())/2},AnySDK.GetBboxMidY=function(){const t=GetWorldInfo(this).GetBoundingBox();return(t.getTop()+t.getBottom())/2},AnySDK.IsAngleWithin=function(t,e){return C3.angleDiff(GetWorldInfo(this).GetAngle(),C3.toRadians(e))<=C3.toRadians(t)},AnySDK.IsAngleClockwiseFrom=function(t){return C3.angleClockwise(GetWorldInfo(this).GetAngle(),C3.toRadians(t))},AnySDK.IsBetweenAngles=function(t,e){const n=C3.toRadians(t),o=C3.toRadians(e),s=GetWorldInfo(this).GetAngle(),i=!C3.angleClockwise(o,n);return i?!(!C3.angleClockwise(s,n)&&C3.angleClockwise(s,o)):C3.angleClockwise(s,n)&&!C3.angleClockwise(s,o)},SDKv1.SetAngle=function(t){const e=this.GetWorldInfo(),n=C3.clampAngle(C3.toRadians(t));isNaN(n)||e.GetAngle()===n||(e.SetAngle(n),e.SetBboxChanged())},SDKv2.SetAngle=function(t){this.angleDegrees=t},AnySDK.RotateClockwise=function(t){if(!isNaN(t)&&0!==t){const e=GetWorldInfo(this);e.SetAngle(e.GetAngle()+C3.toRadians(t)),e.SetBboxChanged()}},AnySDK.RotateCounterclockwise=function(t){if(!isNaN(t)&&0!==t){const e=GetWorldInfo(this);e.SetAngle(e.GetAngle()-C3.toRadians(t)),e.SetBboxChanged()}},AnySDK.RotateTowardAngle=function(t,e){const n=GetWorldInfo(this),o=n.GetAngle(),s=C3.angleRotate(o,C3.toRadians(e),C3.toRadians(t));isNaN(s)||o===s||(n.SetAngle(s),n.SetBboxChanged())},AnySDK.RotateTowardPosition=function(t,e,n){const o=GetWorldInfo(this),s=o.GetAngle(),i=e-o.GetX(),r=n-o.GetY(),a=Math.atan2(r,i),l=C3.angleRotate(s,a,C3.toRadians(t));isNaN(l)||s===l||(o.SetAngle(l),o.SetBboxChanged())},AnySDK.SetTowardPosition=function(t,e){const n=GetWorldInfo(this),o=n.GetAngle(),s=t-n.GetX(),i=e-n.GetY(),r=Math.atan2(i,s);isNaN(r)||o===r||(n.SetAngle(r),n.SetBboxChanged())},SDKv1.GetAngle=function(){return C3.toDegrees(this.GetWorldInfo().GetAngle())},SDKv2.GetAngle=function(){return this.angleDegrees},AnySDK.CompareOpacity=function(t,e){return C3.compare(C3.roundToDp(100*GetWorldInfo(this).GetOpacity(),6),t,e)},SDKv1.IsVisible=function(){return this.GetWorldInfo().IsVisible()},SDKv2.IsVisible=function(){return this.isVisible},AnySDK.SetVisible=function(t){const e=GetWorldInfo(this);t=2===t?!e.IsVisible():0!==t,e.IsVisible()!==t&&(e.SetVisible(t),runtime.UpdateRender())},AnySDK.SetOpacity=function(t){const e=C3.clamp(t/100,0,1),n=GetWorldInfo(this);if(n.GetTransformWithParentOpacity()){if(n._GetSceneGraphInfo().GetOwnOpacity()===e)return}else if(n.GetOpacity()===e)return;n.SetOpacity(e),runtime.UpdateRender()},AnySDK.SetDefaultColor=function(t){tempColor.setFromRgbValue(t);const e=GetWorldInfo(this);e.GetUnpremultipliedColor().equalsIgnoringAlpha(tempColor)||(e.SetUnpremultipliedColor(tempColor),runtime.UpdateRender())},AnySDK.GetColor=function(){const t=GetWorldInfo(this).GetUnpremultipliedColor();return C3.PackRGBAEx(t.getR(),t.getG(),t.getB(),t.getA())},AnySDK.GetOpacity=function(){return C3.roundToDp(100*GetWorldInfo(this).GetOpacity(),6)},AnySDK.IsOnLayer=function(t){return!!(t=GetLayer(t))&&GetWorldInfo(this).GetLayer()===t},AnySDK.PickTopBottom=function(n){const t=GetObjectClass(this),e=t.GetCurrentSol(),o=e.GetInstances();if(!o.length)return!1;let s=o[0],i=s;for(let t=1,e=o.length;t<e;++t){const s=o[t],r=s.GetWorldInfo(),a=i.GetWorldInfo(),l=r.GetLayer().GetIndex(),c=a.GetLayer().GetIndex();0===n?(c<l||l===c&&r.GetZIndex()>a.GetZIndex())&&(i=s):(l<c||l===c&&r.GetZIndex()<a.GetZIndex())&&(i=s)}return e.PickOne(i),!0},SDKv1.CompareZElevation=function(t,e,n){const o=this.GetWorldInfo(),s=0===t?o.GetZElevation():o.GetTotalZElevation();return C3.compare(s,e,n)},SDKv2.CompareZElevation=function(t,e,n){const o=0===t?this.zElevation:this.totalZElevation;return C3.compare(o,e,n)},SDKv1.MoveToTop=function(){this.GetWorldInfo().ZOrderMoveToTop()},SDKv2.MoveToTop=function(){this.moveToTop()},SDKv1.MoveToBottom=function(){this.GetWorldInfo().ZOrderMoveToBottom()},SDKv2.MoveToBottom=function(){this.moveToBottom()},AnySDK.MoveToLayer=function(t){(t=GetLayer(t))&&GetWorldInfo(this).ZOrderMoveToLayer(t)},AnySDK.ZMoveToObject=function(t,e){const n=0===t;if(e=GetObjectClass(e)){const o=GetInst(this),s=e.GetFirstPicked(o);s&&o.GetWorldInfo().ZOrderMoveAdjacentToInstance(s,n)}},SDKv1.SetZElevation=function(t){const e=this.GetWorldInfo();e.GetZElevation()!==t&&(e.SetZElevation(t),runtime.UpdateRender())},SDKv2.SetZElevation=function(t){this.zElevation=t},AnySDK.LayerNumber=function(){return GetWorldInfo(this).GetLayer().GetIndex()},AnySDK.LayerName=function(){return GetWorldInfo(this).GetLayer().GetName()},SDKv1.ZIndex=function(){return this.GetWorldInfo().GetZIndex()},SDKv2.ZIndex=function(){return this.zIndex},SDKv1.ZElevation=function(){return this.GetWorldInfo().GetZElevation()},SDKv2.ZElevation=function(){return this.zElevation},SDKv1.TotalZElevation=function(){return this.GetWorldInfo().GetTotalZElevation()},SDKv2.TotalZElevation=function(){return this.totalZElevation},AnySDK.IsEffectEnabled=function(t){const e=GetInst(this),n=e.GetObjectClass().GetEffectList().GetEffectTypeByName(t);if(n){const o=n.GetIndex(),s=e.GetWorldInfo().GetInstanceEffectList();return s.IsEffectIndexActive(o)}},AnySDK.SetEffectEnabled=function(t,e){const n=GetInst(this),o=n.GetObjectClass().GetEffectList().GetEffectTypeByName(e);if(o){const s=o.GetIndex(),i=1===t,r=n.GetWorldInfo().GetInstanceEffectList();r.IsEffectIndexActive(s)!==i&&(r.SetEffectIndexActive(s,i),r.UpdateActiveEffects(),runtime.UpdateRender())}},AnySDK.SetEffectParam=function(t,e,n){const o=GetInst(this),s=o.GetObjectClass().GetEffectList().GetEffectTypeByName(t);if(s){e=Math.floor(e);const i=s.GetShaderProgram().GetParameterType(e);if(i){"color"===i?(tempColor.setFromRgbValue(n),n=tempColor):"percent"===i&&(n/=100);const r=s.GetIndex(),a=o.GetWorldInfo().GetInstanceEffectList(),l=a.SetEffectParameter(r,e,n);l&&a.IsEffectIndexActive(r)&&runtime.UpdateRender()}}};const tempRect=C3.New(C3.Rect),tempCandidates1=[],tempCandidates2=[];let needsCollisionFinish=!1,rPickType=null,rPickFromElseInstances=!1;const rToPick=new Set;function CollMemory_Add(t,e,n,o){const s=e.GetUID(),i=n.GetUID();s<i?t.Set(e,n,o):t.Set(n,e,o)}function CollMemory_Remove(t,e,n){const o=e.GetUID(),s=n.GetUID();o<s?t.Delete(e,n):t.Delete(n,e)}function CollMemory_RemoveInstance(t,e){t.DeleteEither(e)}function CollMemory_Get(t,e,n){const o=e.GetUID(),s=n.GetUID();return o<s?t.Get(e,n):t.Get(n,e)}function DoOverlapCondition(t,e,n,o){if(!e)return!1;const s=0!==n||0!==o,i=t.GetWorldInfo(),r=runtime.GetCollisionEngine(),a=runtime.GetCurrentCondition(),l=a.GetEventBlock().IsOrBlock(),c=a.GetObjectClass(),u=a.IsInverted(),S=e.GetCurrentSol(),f=c!==e;rPickType=e,needsCollisionFinish=f&&!u;let G,d=0,I=0,C=rPickFromElseInstances=!1;S.IsSelectAll()?(tempRect.copy(i.GetBoundingBox()),tempRect.offset(n,o),r.GetCollisionCandidates(i.GetLayer(),e,tempRect,tempCandidates2),G=tempCandidates2):!l||runtime.IsCurrentConditionFirst()&&!S._GetOwnElseInstances().length&&S._GetOwnInstances().length?G=S._GetOwnInstances():(G=S._GetOwnElseInstances(),rPickFromElseInstances=!0),s&&(d=i.GetX(),I=i.GetY(),i.OffsetXY(n,o),i.SetBboxChanged());for(const h of G)if(r.TestOverlap(t,h)){if(C=!0,u)break;f&&rToPick.add(h)}return s&&(i.SetXY(d,I),i.SetBboxChanged()),C3.clearArray(tempCandidates2),C}function FinishCollisionConditionPicking(t){const e=runtime.GetCurrentEvent().IsOrBlock(),n=rPickType.GetCurrentSol(),o=n._GetOwnInstances(),s=n._GetOwnElseInstances();n.IsSelectAll()?(n.SetSetPicked(rToPick),e&&(C3.clearArray(s),n.AddElseInstances(rToPick,rPickType.GetInstances()))):e?rPickFromElseInstances?n.TransferElseInstancesToOwn(rToPick):(n.AddElseInstances(rToPick,o),n.SetSetPicked(rToPick)):n.SetSetPicked(rToPick),rPickType.ApplySolToContainer()}function FinishCollisionCondition(t,e){needsCollisionFinish&&(e&&FinishCollisionConditionPicking(t),rToPick.clear(),rPickType=null,needsCollisionFinish=!1)}function*DebugOnCollision(o){if(o){const t=this.GetRuntime(),s=t.GetCollisionEngine(),i=t.GetEventSheetManager(),r=i.GetEventStack(),a=i.GetCurrentCondition(),l=a.GetObjectClass(),c=a.GetSavedDataMap(),u=a.GetUnsavedDataMap(),S=r.GetCurrentStackFrame(),f=t.GetTickCount(),G=f-1,d=S.GetCurrentEvent(),I=r.Push(d);let n=c.get("collmemory");n||(n=C3.New(C3.PairMap),c.set("collmemory",n)),u.get("collisionCreatedDestroyCallback")||(u.set("collisionCreatedDestroyCallback",!0),t.Dispatcher().addEventListener("instancedestroy",t=>CollMemory_RemoveInstance(n,t.instance)));const C=l.GetCurrentSol(),h=o.GetCurrentSol(),m=C.GetInstances();let e=null;for(let t=0;t<m.length;++t){const g=m[t];h.IsSelectAll()?(s.GetCollisionCandidates(g.GetWorldInfo().GetLayer(),o,g.GetWorldInfo().GetBoundingBox(),tempCandidates1),e=tempCandidates1,s.AddRegisteredCollisionCandidates(g,o,e)):e=h.GetInstances();for(let t=0;t<e.length;++t){const y=e[t];if(s.TestOverlap(g,y)||s.CheckRegisteredCollision(g,y)){const p=CollMemory_Get(n,g,y);let t=!1,e=-2;"number"==typeof p&&(t=!0,e=p);const D=!t||e<G;if(CollMemory_Add(n,g,y,f),D){const A=d.GetSolModifiers(),v=(i.PushCopySol(A),l.GetCurrentSol()),b=o.GetCurrentSol();if(v._SetSelectAll(!1),b._SetSelectAll(!1),l===o){const K=v._GetOwnInstances();C3.clearArray(K),K.push(g),K.push(y),l.ApplySolToContainer()}else{const O=v._GetOwnInstances(),E=b._GetOwnInstances();C3.clearArray(O),C3.clearArray(E),O.push(g),E.push(y),l.ApplySolToContainer(),o.ApplySolToContainer()}yield*d.DebugRetrigger(S,I),i.PopSol(A)}}else CollMemory_Remove(n,g,y)}C3.clearArray(tempCandidates1)}r.Pop()}return!1}function PickByUID_Normal(t,e){const n=runtime.GetInstanceByUID(e);if(n){const o=t.GetCurrentSol();if(o.IsSelectAll()||o._GetOwnInstances().includes(n))if(t.IsFamily()){if(n.GetObjectClass().BelongsToFamily(t))return o.PickOne(n),t.ApplySolToContainer(),!0}else if(n.GetObjectClass()===t)return o.PickOne(n),t.ApplySolToContainer(),!0}return!1}function PickByUID_Inverted(t,o){const s=t.GetCurrentSol();if(s.IsSelectAll()){s._SetSelectAll(!1),s.ClearArrays();const n=t.GetInstances();for(let t=0,e=n.length;t<e;++t){const i=n[t];i.GetUID()===o?s._PushElseInstance(i):s._PushInstance(i)}return t.ApplySolToContainer(),!!s._GetOwnInstances().length}{const r=s._GetOwnInstances();let n=0;for(let t=0,e=r.length;t<e;++t){const a=r[t];(r[n]=a).GetUID()===o?s._PushElseInstance(a):++n}return C3.truncateArray(r,n),t.ApplySolToContainer(),!!r.length}}AnySDK.OnCollision=function(o){const t=GetObjectClass(this),s=(o=GetObjectClass(o),t.GetRuntime());if(s.IsDebugging())return DebugOnCollision.call(t,o);if(o){const i=s.GetCollisionEngine(),r=s.GetEventSheetManager(),a=r.GetEventStack(),l=r.GetCurrentCondition(),c=l.GetObjectClass(),u=l.GetSavedDataMap(),S=l.GetUnsavedDataMap(),f=a.GetCurrentStackFrame(),G=s.GetTickCount(),d=G-1,I=f.GetCurrentEvent(),C=a.Push(I);let n=u.get("collmemory");n||(n=C3.New(C3.PairMap),u.set("collmemory",n)),S.get("collisionCreatedDestroyCallback")||(S.set("collisionCreatedDestroyCallback",!0),s.Dispatcher().addEventListener("instancedestroy",t=>CollMemory_RemoveInstance(n,t.instance)));const h=c.GetCurrentSol(),m=o.GetCurrentSol(),g=h.GetInstances();let e=null;for(let t=0;t<g.length;++t){const y=g[t];m.IsSelectAll()?(i.GetCollisionCandidates(y.GetWorldInfo().GetLayer(),o,y.GetWorldInfo().GetBoundingBox(),tempCandidates1),e=tempCandidates1,i.AddRegisteredCollisionCandidates(y,o,e)):e=m.GetInstances();for(let t=0;t<e.length;++t){const p=e[t];if(i.TestOverlap(y,p)||i.CheckRegisteredCollision(y,p)){const D=CollMemory_Get(n,y,p);let t=!1,e=-2;"number"==typeof D&&(t=!0,e=D);const A=!t||e<d;if(CollMemory_Add(n,y,p,G),A){const v=I.GetSolModifiers(),b=(r.PushCopySol(v),c.GetCurrentSol()),K=o.GetCurrentSol();if(b._SetSelectAll(!1),K._SetSelectAll(!1),c===o){const O=b._GetOwnInstances();C3.clearArray(O),O.push(y),O.push(p),c.ApplySolToContainer()}else{const E=b._GetOwnInstances(),T=K._GetOwnInstances();C3.clearArray(E),C3.clearArray(T),E.push(y),T.push(p),c.ApplySolToContainer(),o.ApplySolToContainer()}I.Retrigger(f,C),r.PopSol(v)}}else CollMemory_Remove(n,y,p)}C3.clearArray(tempCandidates1)}a.Pop()}return!1},AnySDK.IsOverlapping=function(t){return t=GetObjectClass(t),DoOverlapCondition(GetInst(this),t,0,0)},AnySDK.IsOverlappingOffset=function(t,e,n){return t=GetObjectClass(t),DoOverlapCondition(GetInst(this),t,e,n)},AnySDK.OnHierarchyReady=function(){return!0},AnySDK.HasParent=function(){return GetWorldInfo(this).HasParent()},AnySDK.HasChildren=function(){return GetWorldInfo(this).HasChildren()},AnySDK.PickParent=function(n,o){const t=GetObjectClass(this),e=(n=GetObjectClass(n),t.GetRuntime()),s=this.GetCurrentSol(),i=s.GetInstances();if(0===i.length)return!1;const r=n.GetCurrentSol();let a=r.GetInstances();if(r.IsSelectAll()){const u=[...e.instancesPendingCreateForObjectClass(n)];0<u.length&&(a=a.concat(u))}if(0===a.length)return!1;const l=r.IsSelectAll()?null:new Set(a),c=new Set;for(let t=0,e=i.length;t<e;++t){const S=i[t];if(1===o)for(const f of S.parents())f.BelongsToObjectClass(n)&&(null===l||l.has(f))&&c.add(f);else{let t;if(0===o){if(null===(t=S.GetParent()))continue}else t=S.GetTopParent();t.BelongsToObjectClass(n)&&(null===l||l.has(t))&&c.add(t)}}return 0!==c.size&&(r.SetSetPicked(c),n.ApplySolToContainer(),!0)},AnySDK.PickChildren=function(n,o){const t=GetObjectClass(this),e=(n=GetObjectClass(n),t.GetRuntime()),s=t.GetCurrentSol(),i=s.GetInstances();if(0===i.length)return!1;const r=n.GetCurrentSol();let a=r.GetInstances();if(r.IsSelectAll()){const u=[...e.instancesPendingCreateForObjectClass(n)];0<u.length&&(a=a.concat(u))}if(0===a.length)return!1;const l=r.IsSelectAll()?null:new Set(a),c=new Set;for(let t=0,e=i.length;t<e;++t){const S=i[t];2!==o||S.HasChildren()||!S.BelongsToObjectClass(n)||null!==l&&!l.has(S)||c.add(S);for(const f of 0===o?S.children():S.allChildren())2===o&&f.HasChildren()||f.BelongsToObjectClass(n)&&(null===l||l.has(f))&&c.add(f)}return 0!==c.size&&(r.SetSetPicked(c),n.ApplySolToContainer(),!0)},AnySDK.PickNthChild=function(n,o,s){const t=GetObjectClass(this),e=(n=GetObjectClass(n),t.GetRuntime()),i=t.GetCurrentSol(),r=i.GetInstances();if(0===r.length)return!1;const a=n.GetCurrentSol();let l=a.GetInstances();if(a.IsSelectAll()){const S=[...e.instancesPendingCreateForObjectClass(n)];0<S.length&&(l=l.concat(S))}if(0===l.length)return!1;const c=a.IsSelectAll()?null:new Set(l),u=[];for(let t=0,e=r.length;t<e;++t){const f=r[t];if(0===o){const G=f.GetChildAt(s);null!==G&&G.BelongsToObjectClass(n)&&(null===c||c.has(G))&&u.push(G)}else if(1===o)for(const d of f.children())if(d.BelongsToObjectClass(n)){if(0===s){null!==c&&!c.has(d)||u.push(d);break}--s}}return 0!==u.length&&(a.SetArrayPicked(u),n.ApplySolToContainer(),!0)},AnySDK.CompareChildCount=function(t,e,n){const o=GetInst(this);switch(t){case 0:default:return C3.compare(o.GetChildCount(),e,n);case 1:return C3.compare(o.GetAllChildCount(),e,n)}},AnySDK.AddChild=function(t,e,n,o,s,i,r,a,l,c){t=GetObjectClass(t);const u=GetInst(this),S=runtime.GetCurrentAction().GetObjectClass();for(const f of t.allCorrespondingInstances(u,S)){if(!f.GetPlugin().SupportsSceneGraph())return;u.AddChild(f,{transformX:e,transformY:n,transformWidth:o,transformHeight:s,transformAngle:i,transformOpacity:r,transformZElevation:a,transformVisibility:l,destroyWithParent:c})}},AnySDK.RemoveChild=function(t){t=GetObjectClass(t);const e=GetInst(this),n=runtime.GetCurrentAction().GetObjectClass();for(const o of t.allCorrespondingInstances(e,n))e.RemoveChild(o)},AnySDK.RemoveFromParent=function(){const t=GetInst(this);if(t.HasParent()){const e=t.GetParent();e.RemoveChild(t)}},AnySDK.ParentUID=function(){const t=GetInst(this).GetParent();return t?t.GetUID():-1},AnySDK.ChildCount=function(){return GetInst(this).GetChildCount()},AnySDK.AllChildCount=function(){return GetInst(this).GetAllChildCount()},AnySDK.SetMeshSize=function(t,e){t=Math.floor(t),e=Math.floor(e);const n=GetWorldInfo(this);t<2||e<2||!isFinite(t)||!isFinite(e)?(n.ReleaseMesh(),n.SetBboxChanged()):n.CreateMesh(t,e)},AnySDK.SetMeshPoint=function(t,e,n,o,s,i,r,a){const l=GetWorldInfo(this),c=l.SetMeshPoint(t,e,{mode:0===n?"absolute":"relative",x:o,y:s,zElevation:i,u:r,v:a});c&&l.SetBboxChanged()},AnySDK.MeshColumns=function(){const t=GetWorldInfo(this);return t.HasMesh()?t.GetSourceMesh().GetHSize():0},AnySDK.MeshRows=function(){const t=GetWorldInfo(this);return t.HasMesh()?t.GetSourceMesh().GetVSize():0},AnySDK.SetElementVisible=function(t){const e=GetWorldInfo(this);t=2===t?!e.IsVisible():0!==t,e.IsVisible()!==t&&e.SetVisible(t)},AnySDK.SetElementCSSStyle=function(t,e){this instanceof self.IInstance?this.setElementCSSStyle(t,e):this.SetElementCSSStyle(t,e)},AnySDK.SetElementAttribute=function(t,e){this instanceof self.IInstance?this.setElementAttribute(t,""+e):this.SetElementAttribute(t,""+e)},AnySDK.RemoveElementAttribute=function(t){this instanceof self.IInstance?this.removeElementAttribute(t):this.RemoveElementAttribute(t)},AnySDK.SetElementFocus=function(){this instanceof self.IInstance?this.focusElement():this.FocusElement()},AnySDK.SetElementBlur=function(){this instanceof self.IInstance?this.blurElement():this.BlurElement()},AnySDK.IsElementFocused=function(){return this instanceof self.IInstance?this.isElementFocused():this.IsElementFocused()},AnySDK.SetElementEnabled=function(t){this instanceof self.IInstance?this._setEnabled(0!==t):this._SetEnabled(0!==t)},AnySDK.IsElementEnabled=function(){return this instanceof self.IInstance?this._isEnabled():this._IsEnabled()},SDKv1.CompareInstanceVar=function(t,e,n){return C3.compare(this.GetInstance().GetInstanceVariableValue(t),e,n)},SDKv2.CompareInstanceVar=function(t,e,n){return C3.compare(GetInst_SDKv2(this).GetInstanceVariableValue(t),e,n)},SDKv1.IsBoolInstanceVarSet=function(t){return!!this.GetInstance().GetInstanceVariableValue(t)},SDKv2.IsBoolInstanceVarSet=function(t){return!!GetInst_SDKv2(this).GetInstanceVariableValue(t)},AnySDK.PickInstVarHiLow=function(n,o){const s=GetObjectClass(this),t=s.GetCurrentSol(),i=t.GetInstances();if(!i.length)return!1;const r=s.IsFamily();let a=null,l=0;for(let t=0,e=i.length;t<e;++t){const c=i[t],u=r?c.GetObjectClass().GetFamilyInstanceVariableOffset(s.GetFamilyIndex()):0,S=c.GetInstanceVariableValue(u+o);(null===a||0===n&&S<l||1===n&&S>l)&&(l=S,a=c)}return t.PickOne(a),!0},AnySDK.PickByUID=function(t){const e=GetObjectClass(this);return(e.GetRuntime().GetCurrentCondition().IsInverted()?PickByUID_Inverted:PickByUID_Normal)(e,t)},AnySDK.HasTags=function(t){const e=new Set(C3.splitStringAndNormalize(t)),n=GetInst(this).GetTagsSet();return e.isSubsetOf(n)},AnySDK.Tags=function(){return GetInst(this).GetTagsString()},AnySDK.TagsCount=function(){return GetInst(this).GetTagsSet().size},AnySDK.TagAt=function(t){return GetInst(this).GetTagAt(t)},AnySDK.ChangeTags=function(t,e){const n=C3.splitStringAndNormalize(e);if(0!==n.length){const o=GetInst(this),s=new Set(o.GetTagsSet());if(0===t)for(const i of n)s.add(i);else if(1===t)for(const r of n)s.delete(r);o.SetTagsSet(s)}},AnySDK.Destroy=function(){runtime.DestroyInstance(GetInst(this))},AnySDK.OnCreated=function(){return!0},AnySDK.OnDestroyed=function(){return!0},SDKv1.SetInstanceVar=function(t,e){this.GetInstance().SetInstanceVariableValue(t,e)},SDKv2.SetInstanceVar=function(t,e){GetInst_SDKv2(this).SetInstanceVariableValue(t,e)},SDKv1.AddInstanceVar=function(t,e){const n=this.GetInstance(),o=n.GetInstanceVariableValue(t);"number"==typeof o&&"number"!=typeof e?e=parseFloat(e):"string"==typeof o&&"string"!=typeof e&&(e=e.toString()),n.SetInstanceVariableValue(t,o+e)},SDKv2.AddInstanceVar=function(t,e){const n=GetInst_SDKv2(this),o=n.GetInstanceVariableValue(t);"number"==typeof o&&"number"!=typeof e?e=parseFloat(e):"string"==typeof o&&"string"!=typeof e&&(e=e.toString()),n.SetInstanceVariableValue(t,o+e)},SDKv1.SubInstanceVar=function(t,e){const n=this.GetInstance(),o=n.GetInstanceVariableValue(t);"number"==typeof o&&("number"!=typeof e&&(e=parseFloat(e)),n.SetInstanceVariableValue(t,o-e))},SDKv2.SubInstanceVar=function(t,e){const n=GetInst_SDKv2(this),o=n.GetInstanceVariableValue(t);"number"==typeof o&&("number"!=typeof e&&(e=parseFloat(e)),n.SetInstanceVariableValue(t,o-e))},SDKv1.SetBoolInstanceVar=function(t,e){this.GetInstance().SetInstanceVariableValue(t,e?1:0)},SDKv2.SetBoolInstanceVar=function(t,e){GetInst_SDKv2(this).SetInstanceVariableValue(t,e?1:0)},SDKv1.ToggleBoolInstanceVar=function(t){const e=this.GetInstance();e.SetInstanceVariableValue(t,0===e.GetInstanceVariableValue(t)?1:0)},SDKv2.ToggleBoolInstanceVar=function(t){const e=GetInst_SDKv2(this);e.SetInstanceVariableValue(t,0===e.GetInstanceVariableValue(t)?1:0)},AnySDK.LoadFromJsonString=function(t){let e;try{e=JSON.parse(t)}catch(t){return void console.error("Failed to load from JSON string: ",t)}const n=GetInst(this),o="state";runtime.ClearIntancesNeedingAfterLoad(),n._OnBeforeLoad(o),n.LoadFromJson(e,o),runtime.DoAfterLoad(o,{setFromJson:!0})},AnySDK.AsJSON=function(){return JSON.stringify(GetInst(this).SaveToJson("state"))},AnySDK.ObjectTypeName=function(){return GetInst(this).GetObjectClass().GetName()},AnySDK.Count=function(){const t=runtime.GetCurrentEventStackFrame().GetExpressionObjectClass();let e=t.GetInstanceCount();for(const n of runtime.instancesPendingCreateForObjectClass(t))++e;return e},AnySDK.PickedCount=function(){return runtime.GetCurrentEventStackFrame().GetExpressionObjectClass().GetCurrentSol().GetInstances().length},SDKv1.GetIID=function(){return this.GetInstance().GetIID()},SDKv2.GetIID=function(){return GetInst_SDKv2(this).GetIID()},SDKv1.GetUID=function(){return this.GetInstance().GetUID()},SDKv2.GetUID=function(){return GetInst_SDKv2(this).GetUID()},AnySDK.OnInstanceSignal=function(t){const e=GetInst(this);return t.toLowerCase()===runtime.GetEventSheetManager().GetCurrentInstanceSignalTag(e)},AnySDK.InstanceSignal=function(t){const e=GetInst(this);runtime.GetEventSheetManager().InstanceSignal(e,t)},AnySDK.InstanceWaitForSignal=function(t){const e=GetObjectClass(this);return runtime.GetEventSheetManager().AddScheduledWait().InitInstanceSignals(e.GetCurrentSol().GetInstances(),t),!0},AnySDK.TemplateName=function(){return GetInst(this).GetTemplateName()},C3.AddCommonACEs=function(t,e,n){const o=t[1],s=t[3],i=t[4],r=t[5],a=t[6],l=t[7],c=t[8],u=t[10],S=t[11],f=t[12],G=t[13],d=t[14],I=t[15],C=t[16],h=e.Cnds,m=e.Acts,g=e.Exps,y=Object.assign({},AnySDK,2<=n?SDKv2:SDKv1);s&&(h.CompareX=y.CompareX,h.CompareY=y.CompareY,h.IsOnScreen=y.IsOnScreen,h.IsOutsideLayout=y.IsOutsideLayout,h.PickDistance=y.PickDistance,m.SetX=y.SetX,m.SetY=y.SetY,m.SetPos=y.SetPos,m.SetPosToObject=y.SetPosToObject,m.MoveForward=y.MoveForward,m.MoveAtAngle=y.MoveAtAngle,g.X=y.GetX,g.Y=y.GetY,g.dt=y.GetDt),i&&(h.CompareWidth=y.CompareWidth,h.CompareHeight=y.CompareHeight,m.SetWidth=y.SetWidth,m.SetHeight=y.SetHeight,m.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),r&&(h.AngleWithin=y.IsAngleWithin,h.IsClockwiseFrom=y.IsAngleClockwiseFrom,h.IsBetweenAngles=y.IsBetweenAngles,m.SetAngle=y.SetAngle,m.RotateClockwise=y.RotateClockwise,m.RotateCounterclockwise=y.RotateCounterclockwise,m.RotateTowardAngle=y.RotateTowardAngle,m.RotateTowardPosition=y.RotateTowardPosition,m.SetTowardPosition=y.SetTowardPosition,g.Angle=y.GetAngle),a&&(h.IsVisible=y.IsVisible,h.CompareOpacity=y.CompareOpacity,m.SetVisible=y.SetVisible,m.SetOpacity=y.SetOpacity,m.SetDefaultColor=y.SetDefaultColor,g.Opacity=y.GetOpacity,g.ColorValue=y.GetColor),l&&(h.IsOnLayer=y.IsOnLayer,h.PickTopBottom=y.PickTopBottom,h.CompareZElevation=y.CompareZElevation,m.MoveToTop=y.MoveToTop,m.MoveToBottom=y.MoveToBottom,m.MoveToLayer=y.MoveToLayer,m.ZMoveToObject=y.ZMoveToObject,m.SetZElevation=y.SetZElevation,g.LayerNumber=y.LayerNumber,g.LayerName=y.LayerName,g.ZIndex=y.ZIndex,g.ZElevation=y.ZElevation,g.TotalZElevation=y.TotalZElevation),c&&(h.IsEffectEnabled=y.IsEffectEnabled,m.SetEffectEnabled=y.SetEffectEnabled,m.SetEffectParam=y.SetEffectParam),G&&(h.OnHierarchyReady=y.OnHierarchyReady,h.HasParent=y.HasParent,h.HasChildren=y.HasChildren,h.PickParent=y.PickParent,h.PickChildren=y.PickChildren,h.PickNthChild=y.PickNthChild,h.CompareChildCount=y.CompareChildCount,m.AddChild=y.AddChild,m.RemoveChild=y.RemoveChild,m.RemoveFromParent=y.RemoveFromParent,g.ParentUID=y.ParentUID,g.ChildCount=y.ChildCount,g.AllChildCount=y.AllChildCount),d&&(m.SetMeshSize=y.SetMeshSize,m.SetMeshPoint=y.SetMeshPoint,g.MeshColumns=y.MeshColumns,g.MeshRows=y.MeshRows),u&&(h.IsVisible=y.IsVisible,m.SetVisible=y.SetElementVisible,m.SetCSSStyle=y.SetElementCSSStyle,m.SetElemAttribute=y.SetElementAttribute,m.RemoveElemAttribute=y.RemoveElementAttribute),S&&(h.IsFocused=y.IsElementFocused,m.SetFocus=y.SetElementFocus,m.SetBlur=y.SetElementBlur),f&&(h.IsEnabled=y.IsElementEnabled,m.SetEnabled=y.SetElementEnabled),I&&(h.OnCollision=y.OnCollision,h.IsOverlapping=y.IsOverlapping,h.IsOverlappingOffset=y.IsOverlappingOffset,e.FinishCollisionCondition=FinishCollisionCondition),o||(h.CompareInstanceVar=y.CompareInstanceVar,h.IsBoolInstanceVarSet=y.IsBoolInstanceVarSet,h.PickInstVarHiLow=y.PickInstVarHiLow,h.PickByUID=y.PickByUID,h.HasTags=y.HasTags,m.SetInstanceVar=y.SetInstanceVar,m.AddInstanceVar=y.AddInstanceVar,m.SubInstanceVar=y.SubInstanceVar,m.SetBoolInstanceVar=y.SetBoolInstanceVar,m.ToggleBoolInstanceVar=y.ToggleBoolInstanceVar,m.ChangeTags=y.ChangeTags,h.OnCreated=y.OnCreated,h.OnDestroyed=y.OnDestroyed,m.Destroy=y.Destroy,m.LoadFromJsonString||(m.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,h.OnInstanceSignal=y.OnInstanceSignal,m.InstanceSignal=y.InstanceSignal,m.InstanceWaitForSignal=y.InstanceWaitForSignal),C&&(g.TemplateName=y.TemplateName)}; } // events/scheduledWait.js { const C3=self.C3;C3.ScheduledWait=class extends C3.DefendedBase{constructor(t){super(),this._eventSheetManager=t,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,C3.clearArray(this._solModifiers),this._dynamicSolModifiers&&(this._dynamicSolModifiers.clear(),this._dynamicSolModifiers=null);for(const t of this._sols.values())t.Release();this._sols.clear(),this._pendingInstances=null}_Init(){const t=this._eventSheetManager,e=t.GetRuntime().GetAllObjectClasses(),s=t.GetCurrentEventStackFrame(),i=(this._event=s.GetCurrentEvent(),this._actIndex=s.GetActionIndex()+1,t.FindFirstFunctionBlockParent(this._event));i&&(this._callingFunctionBlock=i,this._functionParameters=i.CaptureFunctionParameters(),this._functionInnerLocalVars=i._GetAllInnerLocalVariables().map(t=>t.GetValue()),i.IsAsync())&&(this._asyncId=i.PauseCurrentAsyncFunction());for(const a of e){const l=a.GetCurrentSol();l.IsSelectAll()&&!this._event.HasSolModifier(a)||(this._solModifiers.push(a),this._sols.set(a,C3.New(C3.SolState,l)))}const n=t.GetDynamicSolModifiersSet();this._dynamicSolModifiers=0<n.size?n:null}InitTimer(t){this._type="timer",this._Init(),this._time=this._eventSheetManager.GetRuntime().GetGameTime()+t}InitWallTimer(t){this._type="walltimer",this._Init(),this._time=this._eventSheetManager.GetRuntime().GetWallTime()+t}InitSignal(t){this._type="signal",this._Init(),this._signalTag=t.toLowerCase()}InitInstanceSignals(t,e){this._type="instance-signals",this._Init(),this._signalTag=e.toLowerCase(),this._pendingInstances=new Set(t)}InitPromise(t){this._type="promise",this._Init(),t.then(()=>this.SetSignalled()).catch(t=>{console.warn("[C3 runtime] Promise rejected in 'Wait for previous actions to complete': ",t),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(t){this._pendingInstances.delete(t),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(t){t._Restore(this._event,this._actIndex);for(const[s,i]of this._sols.entries()){const n=s.GetCurrentSol();i._Restore(n)}this._dynamicSolModifiers&&t.SetDynamicSolModifiers([...this._dynamicSolModifiers]);const e=this._callingFunctionBlock;e&&(e.SetFunctionParameters(this._functionParameters),e._GetAllInnerLocalVariables().map((t,e)=>t.SetValue(this._functionInnerLocalVars[e])),e.IsAsync())&&e.ResumeAsyncFunction(this._asyncId)}_Run(t){this._RestoreState(t),this._event._ResumeActionsAndSubEvents(t),this._callingFunctionBlock&&this._callingFunctionBlock.IsAsync()&&this._callingFunctionBlock.MaybeFinishAsyncFunctionCall(this._asyncId),this._eventSheetManager.ClearSol(this._solModifiers),this._shouldRelease=!0}async _DebugRun(t){this._RestoreState(t);for(const e of this._event._DebugResumeActionsAndSubEvents(t))await this._eventSheetManager.GetRuntime().DebugBreak(e);this._callingFunctionBlock&&this._callingFunctionBlock.IsAsync()&&this._callingFunctionBlock.MaybeFinishAsyncFunctionCall(this._asyncId),this._eventSheetManager.ClearSol(this._solModifiers),this._shouldRelease=!0}ShouldRelease(){return this._shouldRelease}RemoveInstances(t){for(const e of this._sols.values())e.RemoveInstances(t);if("instance-signals"===this._type){for(const s of t)this._pendingInstances.delete(s);0===this._pendingInstances.size&&this.SetSignalled()}}_SaveToJson(){const t={},e={"wt":this._type,"t":this._time,"st":this._signalTag,"s":this._isSignalled,"ev":this._event.GetSID(),"sm":this._solModifiers.map(t=>t.GetSID()),"dsm":this._dynamicSolModifiers?[...this._dynamicSolModifiers].map(t=>t.GetSID()):null,"sols":t};this._event._HasActionIndex(this._actIndex)&&(e["act"]=this._event.GetActionAt(this._actIndex).GetSID());for(const[s,i]of this._sols)t[s.GetSID().toString()]=i._SaveToJson();return"instance-signals"===this._type&&(e["pi"]=[...this._pendingInstances].map(t=>t.GetUID())),e}static _CreateFromJson(t,e){const s=t.GetRuntime(),i=t.GetEventBlockBySID(e["ev"]);if(!i)return null;let n=0;if(e.hasOwnProperty("act")){const l=t.GetActionBySID(e["act"]);if(!l)return null;n=l.GetIndex()}const a=C3.New(C3.ScheduledWait,t);a._time=e["t"],e.hasOwnProperty("wt")?a._type=e["wt"]:a._type=-1===a._time?"signal":"timer",a._signalTag=e["st"],a._isSignalled=e["s"],a._event=i,a._actIndex=n;for(const o of e["sm"]){const c=s.GetObjectClassBySID(o);c&&a._solModifiers.push(c)}if(Array.isArray(e["dsm"]))for(const r of e["dsm"]){const h=s.GetObjectClassBySID(r);h&&(a._dynamicSolModifiers||(a._dynamicSolModifiers=new Set),a._dynamicSolModifiers.add(h))}for(const[_,d]of Object.entries(e["sols"])){const u=parseInt(_,10),S=s.GetObjectClassBySID(u);if(S){const m=C3.New(C3.SolState,null);m._LoadFromJson(t,d),a._sols.set(S,m)}}if("instance-signals"===a._type){a._pendingInstances=new Set;for(const I of e["pi"]){const g=s.GetInstanceByUID(I);g&&a._pendingInstances.add(g)}}return a}}; } // events/solState.js { const C3=self.C3;C3.SolState=class extends C3.DefendedBase{constructor(s){super(),this._objectClass=null,this._isSelectAll=!0,this._instances=[],s&&(this._objectClass=s.GetObjectClass(),this._isSelectAll=s.IsSelectAll(),C3.shallowAssignArray(this._instances,s._GetOwnInstances()))}Release(){this._objectClass=null,C3.clearArray(this._instances)}_Restore(s){s._SetSelectAll(this._isSelectAll),C3.shallowAssignArray(s._GetOwnInstances(),this._instances)}RemoveInstances(s){C3.arrayRemoveAllInSet(this._instances,s)}_SaveToJson(){return{"sa":this._isSelectAll,"insts":this._instances.map(s=>s.GetUID())}}_LoadFromJson(s,e){const t=s.GetRuntime();this._isSelectAll=!!e["sa"],C3.clearArray(this._instances);for(const n of e["insts"]){const l=t.GetInstanceByUID(n);l&&this._instances.push(l)}}}; } // sdk/sdkPluginBase.js { const C3=self.C3;function GetNextParamMap(e,t){let s=e.get(t);return s||(s=new Map,e.set(t,s)),s}C3.SDKPluginBase=class extends C3.DefendedBase{constructor(e){super(),this._runtime=e.runtime,this._name=e.name??"",this._isSingleGlobal=!!e.isSingleGlobal,this._isWorldType=!!e.isWorld,this._isRotatable=!!e.isRotatable,this._mustPredraw=!!e.mustPredraw,this._hasEffects=!!e.hasEffects,this._supportsSceneGraph=!!e.supportsSceneGraph,this._supportsMesh=!!e.supportsMesh,this._isHTMLElementType=!!e.isHTMLElementType,this._is3d=!!e.is3d,this._sdkVersion=e.sdkVersion,this._singleGlobalObjectClass=null,this._boundACEMethodCache=new Map,this._boundACEMethodCache_1param=new Map,this._boundACEMethodCache_2params=new Map,this._boundACEMethodCache_3params=new Map,this._scriptInterfaceClass=e.scriptInterfaceClass,this._iPlugin=null}Release(){this._runtime=null}GetRuntime(){return this._runtime}GetName(){return this._name}OnCreate(){}GetConstructor(){return(2<=this.GetSdkVersion()?this._iPlugin:this).constructor}GetSdkVersion(){return this._sdkVersion}GetScriptInterfaceClass(e=!1){let t=this._scriptInterfaceClass;return t=e&&"function"!=typeof t&&2<=this.GetSdkVersion()?globalThis.ISDKPluginBase:t}IsSingleGlobal(){return this._isSingleGlobal}IsWorldType(){return this._isWorldType}IsHTMLElementType(){return this._isHTMLElementType}Is3D(){return this._is3d}IsRotatable(){return this._isRotatable}MustPreDraw(){return this._mustPredraw}HasEffects(){return this._hasEffects}SupportsSceneGraph(){return this._supportsSceneGraph}SupportsMesh(){return this._supportsMesh}_GetBoundACEMethod(e,t){if(!t)throw new Error("missing 'this' binding");let s=this._boundACEMethodCache.get(e);return s||(s=e.bind(t),this._boundACEMethodCache.set(e,s)),s}_GetBoundACEMethod_1param(e,t,s){if(!t)throw new Error("missing 'this' binding");const i=GetNextParamMap(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=GetNextParamMap(this._boundACEMethodCache_2params,e),r=GetNextParamMap(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=GetNextParamMap(this._boundACEMethodCache_3params,e),a=GetNextParamMap(r,s),l=GetNextParamMap(a,i);let o=l.get(n);return o||(o=e.bind(t,s,i,n),l.set(n,o)),o}_SetSingleGlobalObjectClass(e){if(!this.IsSingleGlobal())throw new Error("must be single-global plugin");this._singleGlobalObjectClass=e}GetSingleGlobalObjectClass(){if(this.IsSingleGlobal())return this._singleGlobalObjectClass;throw new Error("must be single-global plugin")}GetSingleGlobalInstance(){if(this.IsSingleGlobal())return this._singleGlobalObjectClass.GetSingleGlobalInstance();throw new Error("must be single-global plugin")}_InitScriptInterface(){const e=this.GetSdkVersion(),t=(C3.AddonManager._PushInitObject(this,e),this.GetScriptInterfaceClass(!0));if(t){if(this._iPlugin=new t,!(this._iPlugin instanceof self.IPlugin))throw new TypeError("plugin class must derive from IPlugin")}else this._iPlugin=new self.IPlugin;C3.AddonManager._PopInitObject(e)}GetIPlugin(){return this._iPlugin}}; } // sdk/sdkDOMPluginBase.js { const C3=self.C3;C3.SDKDOMPluginBase=class extends C3.SDKPluginBase{constructor(e,s){super(e),this._domComponentId=s,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 s=this._nextElementId++;return this._instMap.set(s,e),s}_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)})}}; } // sdk/sdkTypeBase.js { const C3=self.C3;C3.SDKTypeBase=class extends C3.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 n=C3.New(C3.Event,e,t);n.objectClass=this,s&&Object.assign(n,s),this.GetObjectClass().DispatchUserScriptEvent(n)}}; } // sdk/sdkInstanceBase.js { const C3=self.C3;C3.SDKInstanceBase=class extends C3.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,i]of e)this.AddDOMMessageHandler(t,i)}PostToDOM(e,t){this._runtime.PostComponentMessageToDOM(this._domComponentId,e,t)}PostToDOMAsync(e,t){return this._runtime.PostComponentMessageToDOMAsync(this._domComponentId,e,t)}_PostToDOMMaybeSync(e,t){if(!this._runtime.IsInWorker())return window["c3_runtimeInterface"]["_OnMessageFromRuntime"]({"type":"event","component":this._domComponentId,"handler":e,"data":t,"responseId":null});this.PostToDOM(e,t)}SetWrapperExtensionComponentId(e){if(!e)throw new Error("cannot set empty component id");this._wrapperComponentId=e}IsWrapperExtensionAvailable(){if(this._wrapperComponentId)return this._runtime.HasWrapperComponentId(this._wrapperComponentId);throw new Error("wrapper extension component id not set")}AddWrapperExtensionMessageHandler(e,t){if(!this._wrapperComponentId)throw new Error("wrapper extension component id not set");this._runtime.AddWrapperExtensionMessageHandler(this._wrapperComponentId,e,t)}AddWrapperExtensionMessageHandlers(e){for(const[t,i]of e)this.AddWrapperExtensionMessageHandler(t,i)}SendWrapperExtensionMessage(e,t){if(!this._wrapperComponentId)throw new Error("wrapper extension component id not set");this._runtime.SendWrapperExtensionMessage(this._wrapperComponentId,e,t)}SendWrapperExtensionMessageAsync(e,t){if(this._wrapperComponentId)return this._runtime.SendWrapperExtensionMessageAsync(this._wrapperComponentId,e,t);throw new Error("wrapper extension component id not set")}Tick(){}Tick2(){}_StartTicking(){if(!this._isTicking){if(!this._tickFunc)if(this._runtime.IsDebug()){const t=globalThis.C3Debugger,i=this.GetPlugin();this._tickFunc=()=>{const e=performance.now();this.Tick(),t.AddIndividualPluginTickTime(i,performance.now()-e)}}else this._tickFunc=()=>this.Tick();this._runtime.Dispatcher().addEventListener("tick",this._tickFunc),this._isTicking=!0}}_StopTicking(){this._isTicking&&(this._runtime.Dispatcher().removeEventListener("tick",this._tickFunc),this._isTicking=!1)}IsTicking(){return this._isTicking}_StartTicking2(){if(!this._isTicking2){if(!this._tick2Func)if(this._runtime.IsDebug()){const t=globalThis.C3Debugger,i=this.GetPlugin();this._tick2Func=()=>{const e=performance.now();this.Tick2(),t.AddIndividualPluginTickTime(i,performance.now()-e)}}else this._tick2Func=()=>this.Tick2();this._runtime.Dispatcher().addEventListener("tick2",this._tick2Func),this._isTicking2=!0}}_StopTicking2(){this._isTicking2&&(this._runtime.Dispatcher().removeEventListener("tick2",this._tick2Func),this._isTicking2=!1)}IsTicking2(){return this._isTicking2}GetDebuggerProperties(){return[]}SaveToJson(){return null}LoadFromJson(e){}GetPropertyValueByIndex(e){}SetPropertyValueByIndex(e,t){}OffsetPropertyValueByIndex(e,t,i){if(0!==t){const n=this.GetPropertyValueByIndex(e);if("number"!=typeof n)throw new Error("expected number");this.SetPropertyValueByIndex(e,n+t,i)}}SetPropertyColorOffsetValueByIndex(e,t,i,n){}CallAction(e,...t){e.call(this,...t)}CallExpression(e,...t){return e.call(this,...t)}GetScriptInterfaceClass(){return null}DispatchScriptEvent(e,t,i){if(this._inst.HasScriptInterface()){const n=this.GetScriptInterface(),s=C3.New(C3.Event,e,t);s.instance=n,i&&Object.assign(s,i),n.dispatchEvent(s)}}MustPreDraw(){return!1}}; } // sdk/sdkWorldInstanceBase.js { const C3=self.C3;C3.SDKWorldInstanceBase=class extends C3.SDKInstanceBase{constructor(e,t){super(e,t),this._worldInfo=e.GetWorldInfo(),this._renderercontextlost_handler=null,this._renderercontextrestored_handler=null}Release(){if(this._renderercontextlost_handler){const e=this._runtime.Dispatcher();e.removeEventListener("renderercontextlost",this._renderercontextlost_handler),e.removeEventListener("renderercontextrestored",this._renderercontextrestored_handler),this._renderercontextlost_handler=null,this._renderercontextrestored_handler=null}this._worldInfo=null,super.Release()}HandleWebGLContextLoss(){this.HandleRendererContextLoss()}OnWebGLContextLost(){}OnWebGLContextRestored(){}HandleRendererContextLoss(){if(!this._renderercontextlost_handler){this._renderercontextlost_handler=()=>this.OnRendererContextLost(),this._renderercontextrestored_handler=()=>this.OnRendererContextRestored();const e=this._runtime.Dispatcher();e.addEventListener("renderercontextlost",this._renderercontextlost_handler),e.addEventListener("renderercontextrestored",this._renderercontextrestored_handler)}}OnRendererContextLost(){this.OnWebGLContextLost()}OnRendererContextRestored(){this.OnWebGLContextRestored()}GetWorldInfo(){return this._worldInfo}IsOriginalSizeKnown(){return!1}GetOriginalWidth(){if(!this.IsOriginalSizeKnown())throw new Error("original size not known");const e=this.GetCurrentImageInfo();if(e)return e.GetWidth()}GetOriginalHeight(){if(!this.IsOriginalSizeKnown())throw new Error("original size not known");const e=this.GetCurrentImageInfo();if(e)return e.GetHeight()}GetCurrentImageInfo(){return null}GetCurrentSurfaceSize(){const e=this.GetCurrentImageInfo();if(e){const t=e.GetTexture();if(t)return[t.GetWidth(),t.GetHeight()]}return[100,100]}GetCurrentTexRect(){const e=this.GetCurrentImageInfo();return e?e.GetTexRect():null}GetCurrentTexQuad(){const e=this.GetCurrentImageInfo();return e?e.GetTexQuad():null}IsCurrentTexRotated(){const e=this.GetCurrentImageInfo();return!!e&&e.IsRotated()}GetImagePoint(e){const t=this._inst.GetWorldInfo();return[t.GetX(),t.GetY(),t.GetTotalZElevation()]}LoadTilemapData(e,t,r){}TestPointOverlapTile(e,t){}RendersToOwnZPlane(){return!0}}; } // sdk/sdkDOMInstanceBase.js { const C3=self.C3,tempRect=C3.New(C3.Rect);C3.SDKDOMInstanceBase=class extends C3.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=C3.New(C3.Rect,0,0,-1,-1);const s=this._runtime.GetCanvasManager();this._lastWindowWidth=s.GetLastWidth(),this._lastWindowHeight=s.GetLastHeight(),this._lastHTMLIndex=-1,this._lastHTMLZIndex=-1,this._isPendingUpdateState=!1,this._StartTicking()}Release(){this.GetPlugin()._RemoveElement(this._elementId),this.PostToDOMElement("destroy"),this._elementId=-1,super.Release()}_GetElementInDOMMode(){if(this._runtime.IsInWorker())throw new Error("not valid in worker mode");return this._PostToDOMElementMaybeSync("get-element")}PostToDOMElement(e,t){(t=t||{})["elementId"]=this._elementId,this.PostToDOM(e,t)}_PostToDOMElementMaybeSync(e,t){return(t=t||{})["elementId"]=this._elementId,this._PostToDOMMaybeSync(e,t)}PostToDOMElementAsync(e,t){return(t=t||{})["elementId"]=this._elementId,this.PostToDOMAsync(e,t)}CreateElement(e){e=e||{};const t=this.GetWorldInfo();e["elementId"]=this._elementId,e["isVisible"]=t.IsVisible(),e["htmlIndex"]=t.GetLayer().GetHTMLIndex(),e["htmlZIndex"]=t.GetHTMLZIndex(),Object.assign(e,this.GetElementState()),this._isElementShowing=!!e["isVisible"],this._PostToDOMMaybeSync("create",e),this._UpdatePosition(!0)}SetElementVisible(e){this._isElementShowing!==(e=!!e)&&(this._isElementShowing=e,this.PostToDOMElement("set-visible",{"isVisible":e}))}Tick(){this._UpdatePosition(!1)}_ShouldPreserveElement(){const e=this._runtime.GetCanvasManager().GetFullscreenMode();return"Android"===C3.Platform.OS&&("scale-inner"===e||"scale-outer"===e||"crop"===e)}_UpdatePosition(n){if(!this.GetInstance().IsDestroyed()){const l=this.GetWorldInfo(),o=l.GetLayer(),h=l.GetBoundingBox();let[e,t]=o.LayerToCanvasCss(h.getLeft(),h.getTop()),[s,i]=o.LayerToCanvasCss(h.getRight(),h.getBottom());const a=this._runtime.GetCanvasManager(),m=a.GetCssWidth(),d=a.GetCssHeight();if(l.IsVisible()&&o.IsVisible())if(!this._ShouldPreserveElement()&&(s<=0||i<=0||m<=e||d<=t))this.SetElementVisible(!1);else{tempRect.set(e,t,s,i);const r=a.GetLastWidth(),_=a.GetLastHeight(),c=o.GetHTMLIndex(),u=l.GetHTMLZIndex();if(!n&&tempRect.equals(this._lastRect)&&this._lastWindowWidth===r&&this._lastWindowHeight===_&&this._lastHTMLIndex===c&&this._lastHTMLZIndex===u)this.SetElementVisible(!0);else{this._lastRect.copy(tempRect),this._lastWindowWidth=r,this._lastWindowHeight=_,this._lastHTMLIndex=c,this._lastHTMLZIndex=u,this.SetElementVisible(!0);let e=null;this._autoFontSize&&(e=o.GetDisplayScale()+this._autoFontSizeOffset),this.PostToDOMElement("update-position",{"left":Math.round(this._lastRect.getLeft()),"top":Math.round(this._lastRect.getTop()),"width":Math.round(this._lastRect.width()),"height":Math.round(this._lastRect.height()),"htmlIndex":c,"htmlZIndex":u,"fontSize":e})}}else this.SetElementVisible(!1)}}FocusElement(){this._PostToDOMElementMaybeSync("focus",{"focus":!0})}BlurElement(){this._PostToDOMElementMaybeSync("focus",{"focus":!1})}_OnElemFocused(){this._elemHasFocus=!0}_OnElemBlurred(){this._elemHasFocus=!1}IsElementFocused(){return this._elemHasFocus}SetElementCSSStyle(e,t){this.PostToDOMElement("set-css-style",{"prop":C3.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}}; } // sdk/sdkBehaviorBase.js { const C3=self.C3,IBehavior=self.IBehavior;C3.SDKBehaviorBase=class extends C3.DefendedBase{constructor(e){super(),this._runtime=e.runtime,this._name=e.name??"",this._myObjectClasses=C3.New(C3.ArraySet),this._myInstances=C3.New(C3.ArraySet),this._sdkVersion=e.sdkVersion,this._scriptInterfaceClass=e.scriptInterfaceClass,this._iBehavior=null}Release(){this._myInstances.Release(),this._myObjectClasses.Release(),this._runtime=null}GetRuntime(){return this._runtime}GetName(){return this._name}OnCreate(){}GetSdkVersion(){return this._sdkVersion}GetScriptInterfaceClass(e=!1){let s=this._scriptInterfaceClass;return s=e&&"function"!=typeof s&&2<=this.GetSdkVersion()?globalThis.ISDKBehaviorBase:s}_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(),s=(C3.AddonManager._PushInitObject(this,e),this.GetScriptInterfaceClass(!0));if(s){if(this._iBehavior=new s,!(this._iBehavior instanceof IBehavior))throw new TypeError("behavior class must derive from IBehavior")}else this._iBehavior=new IBehavior;C3.AddonManager._PopInitObject(e)}GetIBehavior(){return this._iBehavior}}; } // sdk/sdkBehaviorTypeBase.js { const C3=self.C3;C3.SDKBehaviorTypeBase=class extends C3.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}}; } // sdk/sdkBehaviorInstanceBase.js { const C3=self.C3;C3.SDKBehaviorInstanceBase=class extends C3.DefendedBase{constructor(t,i){super(),this._behInst=t,this._domComponentId=i,this._inst=t.GetObjectInstance(),this._runtime=t.GetRuntime(),this._behaviorType=t.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(t){return this._runtime.Trigger(t,this._inst,this._behaviorType)}DebugTrigger(t){return this._runtime.DebugTrigger(t,this._inst,this._behaviorType)}TriggerAsync(t){return this._runtime.TriggerAsync(t,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(t,i){this._runtime.AddDOMComponentMessageHandler(this._domComponentId,t,i)}OnSpriteFrameChanged(t,i){}SaveToJson(){return null}LoadFromJson(t){}GetPropertyValueByIndex(t){}SetPropertyValueByIndex(t,i){}OffsetPropertyValueByIndex(t,i){if(0!==i){const e=this.GetPropertyValueByIndex(t);if("number"!=typeof e)throw new Error("expected number");this.SetPropertyValueByIndex(t,e+i)}}SetPropertyColorOffsetValueByIndex(t,i,e,s){}CallAction(t,...i){t.call(this,...i)}CallExpression(t,...i){return t.call(this,...i)}GetScriptInterfaceClass(){return null}DispatchScriptEvent(t,i,e){if(this._behInst.HasScriptInterface()){const s=this.GetScriptInterface(),n=C3.New(C3.Event,t,i);n.behaviorInstance=s,n.instance=s.instance,e&&Object.assign(n,e),s.dispatchEvent(n)}}}; } // objects/addonManager.js { const C3=self.C3,internalApiToken=(C3.Plugins={},C3.Behaviors={},C3._GetInternalAPIToken());function ValidateInternalAPIToken(t){if(t!==internalApiToken)throw new Error("invalid internal API token")}let initObjectStack=[],initObjectStack2=[],initPropertiesStack=[],originalPushInitObject=null,originalPopInitObject=null,originalGetInitObject=null,originalGetInitObject2=null;const pluginsByCtor=new Map,behaviorsByCtor=new Map;C3.AddonManager=class extends C3.DefendedBase{constructor(t,e){super(),this._runtime=t,this._allPlugins=[],this._systemPlugin=null,this._allBehaviors=[],this._delayCreateBehaviors=new Map,this._solidBehavior=null,this._jumpthruBehavior=null,this._wrapperComponentIds=new Set(e)}CreatePlugin(t){const e=t[19],i=this._runtime.GetObjectReference(t[0]);if(!i)throw new Error("missing plugin");C3.AddCommonACEs(t,i,e);const n=2<=e?C3.SDKPluginBase:i,r=C3.New(n,{runtime:this._runtime,isSingleGlobal:t[1],isWorld:t[2],isRotatable:t[5],hasEffects:t[8],mustPredraw:t[9],supportsSceneGraph:t[13],supportsMesh:t[14],isHTMLElementType:t[17],is3d:t[18],sdkVersion:e,name:t[20],scriptInterfaceClass:2<=e?i:null});r.OnCreate(),this._allPlugins.push(r),pluginsByCtor.set(i,r)}CreateSystemPlugin(){this._systemPlugin=C3.New(C3.Plugins.System,{runtime:this._runtime,isSingleGlobal:!0}),this._systemPlugin.OnCreate()}CreateBehavior(t){const i=t[1],n=t[2],r=this._runtime.GetObjectReference(t[0]);if(!r)throw new Error("missing behavior");this._delayCreateBehaviors.set(r,()=>{const t=2<=i?C3.SDKBehaviorBase:r,e=C3.New(t,{runtime:this._runtime,name:n,sdkVersion:i,scriptInterfaceClass:2<=i?r:null});e.OnCreate(),this._allBehaviors.push(e),behaviorsByCtor.set(r,e),!this._solidBehavior&&C3.Behaviors.solid&&e instanceof C3.Behaviors.solid?this._solidBehavior=e:!this._jumpthruBehavior&&C3.Behaviors.jumpthru&&e instanceof C3.Behaviors.jumpthru&&(this._jumpthruBehavior=e),e._InitScriptInterface()})}_DelayCreateBehavior(t){const e=this._delayCreateBehaviors.get(t);e&&(e(),this._delayCreateBehaviors.delete(t))}static _PushInitObject(t,e=1){if(C3.AddonManager._PushInitObject!==originalPushInitObject)throw new Error("invalid method");1===e&&initObjectStack.push(t),initObjectStack2.push(t)}static _PopInitObject(t=1){if(C3.AddonManager._PopInitObject!==originalPopInitObject)throw new Error("invalid method");1===t&&initObjectStack.pop(),initObjectStack2.pop()}static _GetInitObject(){if(C3.AddonManager._GetInitObject!==originalGetInitObject)throw new Error("invalid method");if(0===initObjectStack.length)throw new Error("no init object set");return initObjectStack.at(-1)}static _GetInitObject2(t){if(C3.AddonManager._GetInitObject2!==originalGetInitObject2)throw new Error("invalid method");if(ValidateInternalAPIToken(t),0===initObjectStack2.length)throw new Error("no init object set");return initObjectStack2.at(-1)}static _PushInitProperties(t){initPropertiesStack.push(t)}static _PopInitProperties(){initPropertiesStack.pop()}static _GetInitProperties(){if(0===initPropertiesStack.length)throw new Error("no init properties set");return initPropertiesStack.at(-1)}_InitAddonScriptInterfaces(){for(const t of this._allPlugins)t._InitScriptInterface()}static GetPluginByConstructorFunction(t){return pluginsByCtor.get(t)||null}static GetBehaviorByConstructorFunction(t){return behaviorsByCtor.get(t)||null}GetSystemPlugin(){return this._systemPlugin}GetSolidBehavior(){return this._solidBehavior}GetJumpthruBehavior(){return this._jumpthruBehavior}HasWrapperComponentId(t){return this._wrapperComponentIds.has(t)}},originalPushInitObject=C3.AddonManager._PushInitObject,originalPopInitObject=C3.AddonManager._PopInitObject,originalGetInitObject=C3.AddonManager._GetInitObject,originalGetInitObject2=C3.AddonManager._GetInitObject2; } // objects/imageInfo.js { const C3=self.C3,allImageInfos=new Set;C3.ImageInfo=class extends C3.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=C3.New(C3.Rect),this._quadTex=C3.New(C3.Quad),this._blobUrl="",this._iImageInfo=new self.IImageInfo(this),allImageInfos.add(this)}Release(){this.ReleaseTexture(),this._imageAsset&&0===this._imageAsset.GetRefCount()&&this._imageAsset.Release(),this._imageAsset=null,allImageInfos.delete(this),this.ReleaseBlobURL()}static OnRendererContextLost(){for(const t of allImageInfos)t._textureState="",t._rcTex.set(0,0,0,0),t._quadTex.setFromRect(t._rcTex)}LoadData(t){this._url=t[0],this._size=t[1],this._offsetX=t[2],this._offsetY=t[3],this._width=t[4],this._height=t[5],this._isRotated=t[6],this._hasMetaData=!0}LoadDynamicAsset(t,e){if(this._imageAsset)throw new Error("already loaded asset");this._url=e;const s={};return C3.IsAbsoluteURL(e)&&(s.loadPolicy="remote"),this.LoadAsset(t,s),this._imageAsset.Load()}LoadDynamicBlobAsset(t,e){if(this._imageAsset)throw new Error("already loaded asset");this._url="",this._size=e.size,this._imageAsset=C3.New(C3.ImageAsset,t.GetAssetManager(),{blob:e,size:this._size,loadPolicy:"local"})}ReplaceWith(t){if(t===this)throw new Error("cannot replace with self");this._generation++,this.ReleaseTexture(),this._url=t._url,this._size=t._size,this._offsetX=t._offsetX,this._offsetY=t._offsetY,this._width=t._width,this._height=t._height,this._isRotated=t._isRotated,this._hasMetaData=t._hasMetaData,this._imageAsset=t._imageAsset,this._textureState=t._textureState,this._rcTex=t._rcTex,this._quadTex=t._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(t,e){if(this._imageAsset)throw new Error("already got asset");e=Object.assign({},e,{url:this.GetURL(),size:this.GetSize()}),this._imageAsset=t.LoadImage(e)}IsLoaded(){return this._imageAsset&&this._imageAsset.IsLoaded()}async LoadStaticTexture(t,e){if(!this._imageAsset)throw new Error("no asset");if(this._textureState)throw new Error("already loaded texture");const s=this._generation,i=(this._textureState="loading",await this._imageAsset.LoadStaticTexture(t,e));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 h=this._isRotated?this._height:this._width,a=this._isRotated?this._width:this._height;return this._rcTex.set(this._offsetX,this._offsetY,this._offsetX+h,this._offsetY+a),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(t){t=t||await this._imageAsset.LoadToDrawable();const e=C3.CreateCanvas(this._width,this._height),s=e.getContext("2d");return this._isRotated?(s.rotate(Math.PI/-2),s.translate(-this._height,0),s.drawImage(t,this._offsetX,this._offsetY,this._height,this._width,0,0,this._height,this._width)):s.drawImage(t,this._offsetX,this._offsetY,this._width,this._height,0,0,this._width,this._height),e}async ExtractImageToBlobURL(t){if(!this._blobUrl){const e=await this.ExtractImageToCanvas(t),s=await C3.CanvasToBlob(e);this._blobUrl=URL.createObjectURL(s)}return this._blobUrl}ReleaseBlobURL(){this._blobUrl&&(URL.revokeObjectURL(this._blobUrl),this._blobUrl="")}}; } // objects/animationInfo.js { const C3=self.C3;C3.AnimationInfo=class extends C3.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=>C3.New(C3.AnimationFrameInfo,e)),this._iAnimation=new self.IAnimation(this)}static CreateDynamic(e,t){const r=C3.New(C3.AnimationInfo,[t,0,!1,0,0,!1,Math.floor(1e15*Math.random()),[]]);return r._frames.push(C3.AnimationFrameInfo.CreateDynamic(e)),r}Release(){for(const e of this._frames)e.Release();C3.clearArray(this._frames)}LoadAllAssets(e){for(const t of this._frames)t.GetImageInfo().LoadAsset(e)}LoadAllTextures(t,r){return Promise.all(this._frames.map(e=>e.GetImageInfo().LoadStaticTexture(t,r)))}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(r){for(let e=0,t=this._frames.length;e<t;++e)if(C3.equalsNoCase(this._frames[e].GetTag(),r))return e;return-1}FrameTagOrIndexToIndex(e){if("string"!=typeof e)return e;{const t=this.GetFrameIndexByTag(e);if(-1===t)throw new Error("cannot find animation frame with tag "+e);return t}}GetSpeed(){return this._speed}IsLooping(){return this._isLooping}GetRepeatCount(){return this._repeatCount}GetRepeatTo(){return this._repeatTo}IsPingPong(){return this._isPingPong}GetIAnimation(){return this._iAnimation}}; } // objects/animationFrameInfo.js { const C3=self.C3,EMPTY_IMAGE_BLOB=(()=>{const e=atob("iVBORw0KGgoAAAANSUhEUgAAAGQAAABkAQMAAABKLAcXAAAAAXNSR0IArs4c6QAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAATSURBVBgZYxgFo2AUjIJRQFcAAAV4AAHcRQIbAAAAAElFTkSuQmCC"),n=new Uint8Array(e.length);for(let t=0,i=e.length;t<i;++t)n[t]=e.charCodeAt(t);return new Blob([n],{type:"image/png"})})();C3.AnimationFrameInfo=class extends C3.DefendedBase{constructor(t){super(),this._imageInfo=C3.New(C3.ImageInfo),this._imageInfo.LoadData(t),this._duration=t[7],this._origin=C3.New(C3.Vector2,t[8],t[9]),this._imagePoints=t[10].map(t=>C3.New(C3.ImagePoint,this,t)),this._imagePointsByName=new Map;for(const e of this._imagePoints)this._imagePointsByName.set(e.GetName().toLowerCase(),e);this._collisionPoly=null;const i=t[11];6<=i.length&&(this._collisionPoly=C3.New(C3.CollisionPoly,i)),this._tag=t[12]||"",this._iAnimationFrame=new self.IAnimationFrame(this)}static CreateDynamic(t){const i=C3.New(C3.AnimationFrameInfo,["",0,0,0,100,100,!1,1,0,0,[],[],""]);return i._imageInfo.LoadDynamicBlobAsset(t,EMPTY_IMAGE_BLOB),i}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(t){return this._imagePointsByName.get(t.toLowerCase())||null}GetImagePointByIndex(t){return(t=Math.floor(t))<0||t>=this._imagePoints.length?null:this._imagePoints[t]}GetImagePointCount(){return this._imagePoints.length}GetTag(){return this._tag}GetIAnimationFrame(){return this._iAnimationFrame}}; } // objects/imagePoint.js { const C3=self.C3;C3.ImagePoint=class extends C3.DefendedBase{constructor(e,t){super(),this._afi=e,this._name=t[0],this._pos=C3.New(C3.Vector2,t[1],t[2])}Release(){}GetName(){return this._name}GetX(){return this._pos.getX()}GetY(){return this._pos.getY()}GetVec2(){return this._pos}}; } // objects/objectClass.js { const C3=self.C3,C3Debugger=self.C3Debugger,IObjectClass=self.IObjectClass,assert=self.assert;C3.ObjectClass=class extends C3.DefendedBase{constructor(e,t,s){super();const i=e.GetObjectReference(s[1]),[n,a]=(this._runtime=e,this._plugin=C3.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=C3.New(C3.Event.Dispatcher),this._effectList=null,e.GetCollisionEngine().GetCollisionCellSize());if(this._collisionGrid=C3.New(C3.SparseGrid,n,a),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(t=>C3.BehaviorType.Create(this,t)),this._behaviorTypesIncludingInherited=[],this._behaviorsByName=new Map,this._behaviorNameToIndex=new Map,this._usedBehaviorCtors=new Set,this._customActionMap=new Map,this._solStack=C3.New(C3.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=C3.New(C3.EffectList,this,s[12])),s[6]&&(this._imageInfo=C3.New(C3.ImageInfo),this._imageInfo.LoadData(s[6])),s[7]){this._animations=s[7].map(t=>C3.New(C3.AnimationInfo,t)),this._animationsByName=new Map,this._animationsBySid=new Map;for(const h of this._animations)this._animationsByName.set(h.GetName().toLowerCase(),h),this._animationsBySid.set(h.GetSID(),h)}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 r=this._plugin.GetSdkVersion();if(r<2&&(this._sdkType=C3.New(i.Type,this,s[15]),!(this._sdkType instanceof C3.SDKTypeBase)))throw new Error("v1 sdk type must derive from SDKTypeBase");this._iObjectClass=null,this._instanceUserScriptClass=null,this._userScriptDispatcher=C3.New(C3.Event.Dispatcher),C3.AddonManager._PushInitObject(this,r);let o;if(o=2<=r?(o=i.Type)||globalThis.ISDKObjectTypeBase:this._sdkType.GetScriptInterfaceClass()){if(this._iObjectClass=new o(r<2?this:null),r<2&&!(this._iObjectClass instanceof IObjectClass))throw new TypeError("script interface class must derive from IObjectClass");if(2<=r&&!(this._iObjectClass instanceof globalThis.ISDKObjectTypeBase))throw new TypeError("script interface class must derive from ISDKObjectTypeBase")}else this._iObjectClass=new IObjectClass;if(C3.AddonManager._PopInitObject(r),s[13]){const l=s[13];if(l){const _=l[0],c=l[1],u=l[2];this._sdkType.LoadTilemapData(_,c,u)}}this._runtime.UsesLoaderLayout()&&!this._isFamily&&!this._isOnLoaderLayout&&this._isWorldType||this.OnCreate(),this._plugin.IsSingleGlobal()&&(this._plugin._SetSingleGlobalObjectClass(this),this._CreateSingleGlobalInstance(s)),this._loadInstancesJson=null}static Create(t,e,s){return C3.New(C3.ObjectClass,t,e,s)}Release(){if(this._dispatcher.Release(),this._dispatcher=null,this._imageInfo&&(this._imageInfo.Release(),this._imageInfo=null),this._animations){for(const t of this._animations)t.Release();C3.clearArray(this._animations),this._animationsByName.clear(),this._animationsBySid.clear()}this._loadInstancesJson=null,this._solStack.Release(),this._solStack=null,this._savedData.clear(),this._unsavedData.clear(),this._container=null,this._runtime=null}_LoadFamily(s){for(let t=1,e=s.length;t<e;++t){const i=this._runtime.GetObjectClassByIndex(s[t]);this._familyMembers.push(i),this._familyMembersSet.add(i),i._families.push(this),i._familiesSet.add(this)}}_SetContainer(t){this._isInContainer=!0,this._container=t}IsInContainer(){return this._isInContainer}GetContainer(){return this._container}_OnAfterCreate(){let t=0;if(!this._isFamily)for(const e of this._families)for(const s of e.GetBehaviorTypes()){const i=s.GetName().toLowerCase();this._behaviorsByName.set(i,s),this._behaviorNameToIndex.set(i,t),this._behaviorTypesIncludingInherited.push(s),++t}for(const n of this.GetBehaviorTypes()){const a=n.GetName().toLowerCase();this._behaviorsByName.set(a,n),this._behaviorNameToIndex.set(a,t),this._behaviorTypesIncludingInherited.push(n),++t}for(const r of this._behaviorTypesIncludingInherited)this._usedBehaviorCtors.add(r.GetBehavior().constructor);if(!this._isFamily&&this._families.length){const o=this._runtime.GetFamilyCount(),h=(C3.extendArray(this._familyInstVarMap,o,0),C3.extendArray(this._familyBehaviorMap,o,0),C3.extendArray(this._familyEffectMap,o,0),[]);let t=0,e=0,s=0;for(const l of this._families){const _=l.GetFamilyIndex(),c=(this._familyInstVarMap[_]=t,t+=l.GetInstanceVariablesCount(),this._familyBehaviorMap[_]=e,e+=l.GetBehaviorTypesCount(),this._familyEffectMap[_]=s,s+=l.GetEffectTypesCount(),l.GetEffectList());if(c&&this._effectList)for(const u of c.GetAllEffectTypes())h.push(u.Clone(this._effectList))}this._effectList&&this._effectList.PrependEffectTypes(h)}}_CreateSingleGlobalInstance(t){const e=this._runtime._GetNewUID(),s=C3.New(C3.Instance,{runtime:this._runtime,objectType:this,uid:e});s._CreateSdkInstance(t[16],[]),this._runtime._MapInstanceByUID(e,s),this._instances.push(s)}GetSdkType(){return this._sdkType}IsOnLoaderLayout(){return this._isOnLoaderLayout}Dispatcher(){return this._dispatcher}OnCreate(){this._isFamily||(this._sdkType?this._sdkType.OnCreate():this._iObjectClass._onCreate())}HasLoadedTextures(){return 0<this._textureRefCount}async LoadTextures(t){this._isFamily||(this._textureRefCount++,1===this._textureRefCount&&(this._sdkType?await this._sdkType.LoadTextures(t):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(t){this._isFamily||(this._sdkType?await this._sdkType.PreloadTexturesWithInstances(t):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(t){return t&&this._usedBehaviorCtors.has(t)}GetInstanceVariablesCount(){return this._instVars.length}GetInstanceVariableSIDs(){return this._instVars.map(t=>t.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(t=>t.name)}_GetAllInstanceVariableJsPropNames(){return this._instVars.map(t=>t.jsPropName)}GetInstanceVariableType(t){if((t=Math.floor(t))<0||t>=this._instVars.length)throw new RangeError("invalid instance variable index");return this._instVars[t].type}GetInstanceVariableName(t){if((t=Math.floor(t))<0||t>=this._instVars.length)throw new RangeError("invalid instance variable index");return this._instVars[t].name}GetEffectTypesCount(){return this._effectsCount}GetBehaviorTypesIncludingInherited(){return this._behaviorTypesIncludingInherited}GetBehaviorTypeByName(t){return this._behaviorsByName.get(t.toLowerCase())||null}GetBehaviorIndexByName(t){const e=this._behaviorNameToIndex.get(t.toLowerCase());return void 0===e?-1:e}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(t){this._defaultInstanceData=t}GetDefaultInstanceData(){return this._defaultInstanceData}_SetDefaultLayerIndex(t){this._defaultLayerIndex=t}GetDefaultLayerIndex(){return this._defaultLayerIndex}GetAnimations(){return this._animations}GetAnimationCount(){return this._animations.length}GetFamilies(){return this._families}BelongsToFamily(t){return this._familiesSet.has(t)}GetFamilyMembers(){return this._familyMembers}FamilyHasMember(t){return this._familyMembersSet.has(t)}GetFamilyBehaviorOffset(t){return this._familyBehaviorMap[t]}GetFamilyInstanceVariableOffset(t){return this._familyInstVarMap[t]}AddCustomAction(t){this._customActionMap.set(t.GetACEName().toLowerCase(),t)}HasOwnCustomActionByName(t){return!!this.GetOwnCustomActionByName(t)}GetOwnCustomActionByName(t){const e=this._customActionMap.get(t.toLowerCase());return e&&e.IsEnabled()?e:null}GetAllAnimations(){return this._animations}GetAnimationByName(t){if(this._animations)return this._animationsByName.get(t.toLowerCase())||null;throw new Error("no animations")}GetAnimationBySID(t){if(this._animations)return this._animationsBySid.get(t)||null;throw new Error("no animations")}AddAnimation(t){if(this.GetAnimationByName(t))throw new Error(`animation name '${t}' already exists`);const e=C3.AnimationInfo.CreateDynamic(this.GetRuntime(),t);return this._animations.push(e),this._animationsByName.set(e.GetName().toLowerCase(),e),this._animationsBySid.set(e.GetSID(),e),e}RemoveAnimation(t){const e=this.GetAnimationByName(t);if(!e)throw new Error(`animation name '${t}' does not exist`);if(1===this._animations.length)throw new Error("cannot remove last animation");const s=this._animations.indexOf(e);this._animations.splice(s,1),this._animationsByName.delete(e.GetName().toLowerCase()),this._animationsBySid.delete(e.GetSID()),e.Release()}GetFirstAnimation(){if(this._animations)return this._animations[0];throw new Error("no animations")}GetFirstAnimationFrame(){return this.GetFirstAnimation().GetFrameAt(0)}GetDefaultInstanceSize(){if(this._animations){const t=this.GetFirstAnimationFrame().GetImageInfo();return[t.GetWidth(),t.GetHeight()]}return this._imageInfo?[this._imageInfo.GetWidth(),this._imageInfo.GetHeight()]:[100,100]}GetSingleGlobalInstance(){if(this._plugin.IsSingleGlobal())return this._instances[0];throw new Error("not a single-global plugin")}GetInstances(){return this._instances}*instances(){yield*this._instances}*instancesIncludingPendingCreate(){yield*this._instances,yield*this._runtime.instancesPendingCreateForObjectClass(this)}GetInstanceCount(){return this._instances.length}_AddInstance(t){this._instances.push(t)}_SetIIDsStale(){this._iidsStale=!0}_UpdateIIDs(){if(this._iidsStale&&!this._isFamily){const s=this._instances;let e=0;for(let t=s.length;e<t;++e)s[e]._SetIID(e);const t=this._runtime._GetInstancesPendingCreate();for(const i of t)i.GetObjectClass()===this&&i._SetIID(e++);this._iidsStale=!1}}GetInstanceByIID(t){const e=this._instances;if(t<e.length)return e[t];t-=e.length;const s=this._runtime._GetInstancesPendingCreate();for(const i of s)if(i.GetObjectClass()===this){if(0===t)return i;--t}return null}GetFirstPicked(t){if(t&&t.IsInContainer()&&t.GetObjectClass()!==this)for(const s of t.siblings())if(s.GetObjectClass()===this)return s;const e=this.GetCurrentSol().GetInstances();return e.length?e[0]:null}GetPairedInstance(t){const e=this.GetCurrentSol().GetInstances();return 0<e.length?e[t.GetIID()%e.length]:null}*allCorrespondingInstances(t,e){const s=this.GetCurrentSol().GetInstances(),i=s.length,n=e.GetCurrentSol(),a=e.GetCurrentSol().GetInstances(),r=a.length;let o=t.GetIID();!e.IsFamily()&&n.IsSelectAll()||(o=a.indexOf(t));const h=Math.ceil(i/r),l=i%r;let _=0,c=0;c=0==l||o<l?(_=o*h,h):(_=l*h+(o-l)*(h-1),h-1);for(let t=_,e=_+c;t<e;++t)yield s[t]}FinishCondition(t){this._sdkType?.FinishCondition(t)}ApplySolToContainer(){if(this._isInContainer&&!this._isFamily){this._UpdateIIDs();const t=this.GetCurrentSol(),e=t._GetOwnInstances(),s=t.IsSelectAll(),i=this._runtime.GetCurrentEventStackFrame(),n=i&&i.GetCurrentEvent()&&i.GetCurrentEvent().IsOrBlock();for(const a of this._container.objectTypes())if(a!==this){a._UpdateIIDs();const r=a.GetCurrentSol();if(r._SetSelectAll(s),!s){const o=r._GetOwnInstances();C3.clearArray(o);for(const h of e)o.push(a.GetInstanceByIID(h.GetIID()));if(n){const l=t._GetOwnElseInstances(),_=r._GetOwnElseInstances();C3.clearArray(_);for(const c of l)_.push(a.GetInstanceByIID(c.GetIID()))}}}}}_TruncateContainerSols(t,e){for(const s of this.GetContainer().objectTypes()){const i=s.GetCurrentSol();t?C3.truncateArray(i._GetOwnElseInstances(),e):C3.truncateArray(i._GetOwnInstances(),e)}}_GetCollisionCellGrid(){return this._collisionGrid}_SetAnyCollisionCellChanged(t){this._anyCollisionCellChanged=!!t}_UpdateAllCollisionCells(){if(this._anyCollisionCellChanged&&this._isWorldType){for(const t of this._instances)t.GetWorldInfo()._UpdateCollisionCell();for(const e of this._runtime._GetInstancesPendingCreate())e.GetObjectClass()===this&&e.GetWorldInfo()._UpdateCollisionCell();this._anyCollisionCellChanged=!1}}_OnWorldInstanceLayerChanged(e,t,s){if(t){const i=this._worldInfosByLayer.get(t);i&&(i.delete(e),0===i.size)&&this._worldInfosByLayer.delete(t)}if(s){let t=this._worldInfosByLayer.get(s);t||(t=new Set,this._worldInfosByLayer.set(s,t)),t.add(e)}}layersHasInstancesOn(){if(this.IsFamily()){const t=new Set;for(const e of this._familyMembers)for(const s of e.layersHasInstancesOn())t.add(s);return t.values()}return this._worldInfosByLayer.keys()}GetSavedDataMap(){return this._savedData||(this._savedData=new Map),this._savedData}GetUnsavedDataMap(){return this._unsavedData||(this._unsavedData=new Map),this._unsavedData}HasSolidBehavior(){return this.UsesBehaviorByCtor(C3.Behaviors.solid)}HasJumpthruBehavior(){return this.UsesBehaviorByCtor(C3.Behaviors.jumpthru)}HasNoSaveBehavior(){return this.UsesBehaviorByCtor(C3.Behaviors.NoSave)}HasPersistBehavior(){return this.UsesBehaviorByCtor(C3.Behaviors.Persist)}_SaveToJson(){const t={"instances":this._instances.map(t=>t.SaveToJson())};return this._savedData&&this._savedData.size&&(t["ex"]=C3.ToSuperJSON(this._savedData)),t}_LoadFromJson(t,s){this._savedData&&(this._savedData.clear(),this._savedData=null);const e=t["ex"],i=(e&&(this._savedData=C3.FromSuperJSON(e)),this._instances),n=t["instances"];for(let t=0,e=Math.min(i.length,n.length);t<e;++t)i[t].LoadFromJson(n[t]);for(let t=n.length,e=i.length;t<e;++t)this._runtime.DestroyInstance(i[t]);for(let e=i.length,t=n.length;e<t;++e){const a=n[e];let t=null;if(!this.IsWorldType()||(t=this._runtime.GetMainRunningLayout().GetLayerBySID(a["w"]["l"]))){const r=this._runtime.CreateInstanceFromData(this._defaultInstanceData||this,t,!1,0,0,!0);r.LoadFromJson(a),s&&s.add(r)}}this._loadInstancesJson=n,this._SetIIDsStale()}_GetLoadInstancesJson(){return this._loadInstancesJson}_ClearLoadInstancesJson(){this._loadInstancesJson=null}_SetupSceneGraphConnectionsOnChangeOfLayout(){for(let t=0,e=this._instances;t<e;++t)this._instances[t]._SetupSceneGraphConnectionsOnChangeOfLayout()}GetIObjectClass(){return this._iObjectClass}UserScriptDispatcher(){return this._userScriptDispatcher}_GetUserScriptInstanceClass(){return this._instanceUserScriptClass}_SetUserScriptInstanceClass(t){this._instanceUserScriptClass=t}DispatchUserScriptEvent(t){const e=this._runtime,s=e.IsDebug()&&!e.GetEventSheetManager().IsInEventEngine();s&&C3Debugger.StartMeasuringScriptTime(),this._userScriptDispatcher.dispatchEvent(t),s&&C3Debugger.AddScriptTime()}}; } // objects/container.js { const C3=self.C3;C3.Container=class extends C3.DefendedBase{constructor(e,t){super(),this._runtime=e,this._objectTypes=t;for(const s of this._objectTypes)s._SetContainer(this)}Release(){this._runtime=null}GetRuntime(){return this._runtime}GetObjectTypes(){return this._objectTypes}objectTypes(){return this._objectTypes}HasAnyWorldType(){return this._objectTypes.some(e=>e.IsWorldType())}}; } // objects/instance.js { const C3=self.C3,C3Debugger=self.C3Debugger,IInstance=self.IInstance,originalAddonManager=C3.AddonManager,EMPTY_ARRAY=[];let nextPuid=0;const savedDataMaps=new WeakMap,unsavedDataMaps=new WeakMap,FLAG_DESTROYED=1,FLAG_TILEMAP=2,FLAG_MUST_PREDRAW=4,FLAG_SOLID_ENABLED=8,FLAG_JUMPTHRU_ENABLED=16,FLAG_MUST_MITIGATE_Z_FIGHTING=32,FLAG_IS_DRAWING_WITH_EFFECTS=64;C3.Instance=class extends C3.DefendedBase{constructor(t){if(C3.AddonManager!==originalAddonManager)throw new Error("invalid addon manager");super(),this._runtime=t.runtime,this._objectType=t.objectType,this._worldInfo=null,this._sdkInst=null,this._iScriptInterface=null,this._iid=0,this._uid=t.uid,this._puid=nextPuid++,this._flags=0,this._tagsSet=null;const e=C3.splitStringAndNormalize(t.tags),s=(0<e.length&&(this._tagsSet=new Set(e)),this._instVarValues=EMPTY_ARRAY,this._behaviorInstances=EMPTY_ARRAY,this._objectType.GetBehaviorTypesIncludingInherited()),n=(0<s.length&&(this._behaviorInstances=s.map((t,e)=>C3.New(C3.BehaviorInstance,{runtime:this._runtime,behaviorType:t,instance:this,index:e}))),this._siblings=this._objectType.IsInContainer()?[]:null,this._timeScale=-1,this._dispatcher=null,this.GetPlugin());if(n.MustPreDraw()&&(this._flags|=FLAG_MUST_PREDRAW),n.IsWorldType())if(this._worldInfo=C3.New(C3.WorldInfo,this,t.layer),t.worldData)this._worldInfo.Init(t.worldData);else{this._worldInfo.InitNoData();const[i,r]=this._objectType.GetDefaultInstanceSize();this._worldInfo.SetSize(i,r),this.GetObjectClass().UsesEffects()&&this._worldInfo.GetInstanceEffectList().LoadDefaultEffectParameters()}t.instVarData?this._LoadInstanceVariableData(t.instVarData):this._LoadDefaultInstanceVariables()}Release(){if(this._iScriptInterface&&(this._iScriptInterface._release(),this._iScriptInterface=null),0<this._behaviorInstances.length){for(const s of this._behaviorInstances)s.Release();C3.clearArray(this._behaviorInstances)}this._sdkInst&&(this._sdkInst.Release(),this._sdkInst=null);const t=savedDataMaps.get(this),e=(t&&(t.clear(),savedDataMaps.delete(this)),unsavedDataMaps.get(this));e&&(e.clear(),unsavedDataMaps.delete(this)),this._siblings&&C3.clearArray(this._siblings),this._dispatcher&&(this._dispatcher.Release(),this._dispatcher=null),this._tagsSet&&this._tagsSet.clear(),this._tagsSet=null,this._runtime=null,this._objectType=null,0<this._instVarValues.length&&C3.clearArray(this._instVarValues),this._worldInfo&&(this._worldInfo.Release(),this._worldInfo=null)}_LoadInstanceVariableData(t){0<t.length&&(this._instVarValues=[],C3.shallowAssignArray(this._instVarValues,t))}_LoadDefaultInstanceVariables(){const e=this._objectType.GetInstanceVariablesCount();if(0!==e){this._instVarValues=[];const s=[0,0,""];for(let t=0;t<e;++t)this._instVarValues.push(s[this._objectType.GetInstanceVariableType(t)])}}_CreateSdkInstance(t,s){if(this._sdkInst)throw new Error("already got sdk instance");for(let t=0,e=this._behaviorInstances.length;t<e;++t){const n=this._behaviorInstances[t];n._CreateSdkInstance(s?s[t]:null)}const e=this.GetPlugin().GetSdkVersion();if(e<2){if(this._sdkInst=C3.New(this._objectType.GetInstanceSdkCtor(),this,t),!(this._sdkInst instanceof C3.SDKInstanceBase))throw new Error("sdk type must derive from SDKInstanceBase");!this.GetPlugin().IsWorldType()&&this._objectType._GetUserScriptInstanceClass()&&this.GetInterfaceClass()}else{const i=this.GetPlugin().GetScriptInterfaceClass();this._InitUserScriptInterface(i.Instance,t)}}GetSdkInstance(){return this._sdkInst??this._iScriptInterface}GetWorldInfo(){return this._worldInfo}GetRuntime(){return this._runtime}GetTimeScale(){return this._timeScale}GetActiveTimeScale(){const t=this._timeScale;return-1===t?this.GetRuntime().GetTimeScale():t}SetTimeScale(t){((t=+t)<0||!isFinite(t))&&(t=0),this._timeScale=t,this.GetObjectClass().UsesEffects()&&this._runtime._SetTrackingInstanceTime(this,!0)}RestoreTimeScale(){this._timeScale=-1,this.GetObjectClass().UsesEffects()&&this._runtime._SetTrackingInstanceTime(this,!1)}GetInstanceGameTime(){return this._runtime._GetInstanceGameTime(this)}Dispatcher(){return this._dispatcher||(this._dispatcher=C3.New(C3.Event.Dispatcher)),this._dispatcher}Draw(t){this._sdkInst?this._sdkInst.Draw(t):this._iScriptInterface._draw(this._runtime.GetCanvasManager().GetIRenderer())}OnCreate(t){this._sdkInst.OnCreate(t)}_SetHasTilemap(){this._flags|=FLAG_TILEMAP}HasTilemap(){return 0!=(this._flags&FLAG_TILEMAP)}_MarkDestroyed(){this._flags|=FLAG_DESTROYED}IsDestroyed(){return 0!=(this._flags&FLAG_DESTROYED)}MustPreDraw(){return 0!=(this._flags&FLAG_MUST_PREDRAW)||this._sdkInst.MustPreDraw()}SetMustMitigateZFighting(){this._flags|=FLAG_MUST_MITIGATE_Z_FIGHTING}MustMitigateZFighting(){return 0!=(this._flags&FLAG_MUST_MITIGATE_Z_FIGHTING)}_IsSolidEnabled(){return 0!=(this._flags&FLAG_SOLID_ENABLED)}_SetSolidEnabled(t){t?this._flags|=FLAG_SOLID_ENABLED:this._flags&=~FLAG_SOLID_ENABLED}_IsJumpthruEnabled(){return 0!=(this._flags&FLAG_JUMPTHRU_ENABLED)}_SetJumpthruEnabled(t){t?this._flags|=FLAG_JUMPTHRU_ENABLED:this._flags&=~FLAG_JUMPTHRU_ENABLED}_IsDrawingWithEffects(){return 0!=(this._flags&FLAG_IS_DRAWING_WITH_EFFECTS)}_SetIsDrawingWithEffects(t){t?this._flags|=FLAG_IS_DRAWING_WITH_EFFECTS:this._flags&=~FLAG_IS_DRAWING_WITH_EFFECTS}SetFlag(t,e){t<<=16,e?this._flags|=t:this._flags&=~t}GetFlag(t){return 0!=(this._flags&t<<16)}GetCurrentImageInfo(){return this._sdkInst.GetCurrentImageInfo()}GetCurrentSurfaceSize(){return this._sdkInst.GetCurrentSurfaceSize()}GetCurrentTexRect(){return this._sdkInst.GetCurrentTexRect()}GetCurrentTexQuad(){return this._sdkInst.GetCurrentTexQuad()}IsCurrentTexRotated(){return this._sdkInst.IsCurrentTexRotated()}GetImagePoint(t){return this._sdkInst.GetImagePoint(t)}GetObjectClass(){return this._objectType}RendersToOwnZPlane(){return this._sdkInst.RendersToOwnZPlane()}BelongsToObjectClass(t){return t.IsFamily()?t.FamilyHasMember(this.GetObjectClass()):this.GetObjectClass()===t}CollectInstancesToPick(i,t,e){const s=(t,e)=>{const s=e||t.GetObjectClass(),n=i.get(s);n?n.add(t):i.set(s,new Set([t]))};if(s(this,t),this.IsInContainer())for(const n of this.siblings())s(n);if(e)for(const r of this.allChildren())s(r)}VerifySupportsSceneGraph(){if(!this.GetPlugin().SupportsSceneGraph())throw new Error("object does not support scene graph")}HasParent(){return null!==this.GetParent()}GetParent(){const t=this.GetWorldInfo();if(!t)return null;const e=t.GetParent();return e?e.GetInstance():null}GetTopParent(){const t=this.GetWorldInfo();if(!t)return null;const e=t.GetTopParent();return e?e.GetInstance():null}*parents(){const t=this.GetWorldInfo();if(t)for(const e of t.parents())yield e.GetInstance()}HasChild(t){if(t)for(const e of this.children())if(e===t)return!0;return!1}HasChildren(){const t=this.GetWorldInfo();return!!t&&t.HasChildren()}GetChildrenOfObjectClass(t){const e=this.GetWorldInfo();if(!e)return[];const s=t.GetName();return e.GetChildren().map(t=>t.GetInstance()).filter(t=>t.GetObjectClass().GetName()===s)}GetChildren(){const t=this.GetWorldInfo();return t?t.GetChildren().map(t=>t.GetInstance()):[]}*children(){const t=this.GetWorldInfo();if(t)for(const e of t.children())yield e.GetInstance()}*allChildren(){const t=this.GetWorldInfo();if(t)for(const e of t.allChildren())yield e.GetInstance()}GetChildCount(){const t=this.GetWorldInfo();return t?t.GetChildCount():0}GetParentCount(){return[...this.parents()].length}GetAllChildCount(){const t=this.GetWorldInfo();return t?t.GetAllChildCount():0}GetChildAt(t){const e=this.GetWorldInfo();if(!e)return null;const s=e.GetChildAt(t);return s?s.GetInstance():null}GetIndexInParent(){const t=this.GetWorldInfo();if(!t)return NaN;const e=t.GetParent();return e?e.GetChildIndex(t):NaN}HasChildWithUID(t){for(const e of this.GetWorldInfo().GetChildren())if(e.GetInstance().GetUID()===t)return!0;return!1}AddChild(t,e){this.VerifySupportsSceneGraph(),t.VerifySupportsSceneGraph(),this.GetWorldInfo().AddChild(t.GetWorldInfo(),e||{})}RemoveChild(t){const e=this.GetWorldInfo();e&&e.RemoveChild(t.GetWorldInfo())}GetDestroyWithParent(){const t=this.GetWorldInfo();return!!t&&t.GetDestroyWithParent()}SetupInitialSceneGraphConnections(){const t=this.GetWorldInfo();if(t){const e=t.GetSceneGraphChildrenExportData();if(e)for(const s of e){const n=this._runtime.GetInstanceByUID(s[2]);if(n){const i=s[3];this.AddChild(n,{transformX:!!(i>>0&1),transformY:!!(i>>1&1),transformWidth:!!(i>>2&1),transformHeight:!!(i>>3&1),transformAngle:!!(i>>4&1),destroyWithParent:!!(i>>5&1),transformZElevation:!!(i>>6&1),transformOpacity:!!(i>>7&1),transformVisibility:!!(i>>8&1)})}}}}SetupPersistedSceneGraphConnections(t,e){const s=t.get(this);if(s)for(const n of s["sceneGraphJson"]["children"]){const i=e.get(n["index"]);if(i){const r=n["flags"];this.AddChild(i,{transformX:!!(r>>0&1),transformY:!!(r>>1&1),transformWidth:!!(r>>2&1),transformHeight:!!(r>>3&1),transformAngle:!!(r>>4&1),destroyWithParent:!!(r>>5&1),transformZElevation:!!(r>>6&1),transformOpacity:!!(r>>7&1),transformVisibility:!!(r>>8&1)})}}}GetTemplateName(){const t=this._runtime.GetTemplateManager();return t?t.GetInstanceTemplateName(this):""}IsInContainer(){return null!==this._siblings}_AddSibling(t){this._siblings.push(t)}GetSiblings(){return this._siblings}HasSibling(t){return!!this.GetSibling(t)}GetSibling(t){const e=this.siblings();if(null===e||0===e.length)return!1;for(const s of e)if(s.GetObjectClass()===t)return s;return null}siblings(){return this._siblings}SetSiblingsSinglePicked(){for(const t of this.siblings())t.GetObjectClass().GetCurrentSol().SetSinglePicked(t)}_PushSiblingsToSolInstances(){for(const t of this.siblings())t.GetObjectClass().GetCurrentSol()._PushInstance(t)}_SetSiblingsToSolInstancesIndex(t){for(const e of this.siblings())e.GetObjectClass().GetCurrentSol()._GetOwnInstances()[t]=e}_PushSiblingsToSolElseInstances(){for(const t of this.siblings())t.GetObjectClass().GetCurrentSol()._PushElseInstance(t)}_SetSiblingsToSolElseInstancesIndex(t){for(const e of this.siblings())e.GetObjectClass().GetCurrentSol()._GetOwnElseInstances()[t]=e}GetPlugin(){return this._objectType.GetPlugin()}_SetIID(t){this._iid=t}GetIID(){return this._objectType._UpdateIIDs(),this._iid}GetUID(){return this._uid}GetPUID(){return this._puid}_SetTagsSetFromJson(t){t?this.SetTagsSet(new Set(t)):this._tagsSet=null}SetTagsSet(t){if(0===t.size)this._tagsSet=null;else{this._tagsSet?this._tagsSet.clear():this._tagsSet=new Set;for(const e of t)this._tagsSet.add(e)}}GetTagsSet(){return this._tagsSet??new Set}GetTagsString(){return Array.from(this.GetTagsSet()).join(" ")}GetTagAt(t){t=Math.floor(t);for(const e of this.GetTagsSet()){if(0===t)return e;--t}return""}GetBehaviorInstances(){return this._behaviorInstances}GetBehaviorInstanceFromCtor(t){if(t)for(const e of this._behaviorInstances)if(e.GetBehavior()instanceof t)return e;return null}GetBehaviorSdkInstanceFromCtor(t){if(!t)return null;const e=this.GetBehaviorInstanceFromCtor(t);return e?e.GetSdkInstance():null}GetBehaviorIndexBySID(s){const n=this._behaviorInstances;for(let t=0,e=n.length;t<e;++t)if(n[t].GetBehaviorType().GetSID()===s)return t;return-1}GetAllInstanceVariableValues(){return this._instVarValues}_GetAllInstanceVariableNames(){return this._objectType._GetAllInstanceVariableNames()}GetInstanceVariableCount(){return this._instVarValues.length}GetInstanceVariableValue(t){const e=this._instVarValues;if((t|=0)<0||t>=e.length)throw new RangeError("invalid instance variable");return e[t]}_GetInstanceVariableValueUnchecked(t){return this._instVarValues[t]}_GetInstanceVariableTypedValue(t){const e=this._instVarValues[t];return 0===this._objectType.GetInstanceVariableType(t)?!!e:e}SetInstanceVariableValue(t,e){const s=this._instVarValues;if((t|=0)<0||t>=s.length)throw new RangeError("invalid instance variable");const n=this._objectType.GetInstanceVariableType(t);switch(n){case 0:s[t]=e?1:0;break;case 1:s[t]="number"==typeof e?e:parseFloat(e);break;case 2:s[t]="string"==typeof e?e:e.toString();break;default:throw new Error("unknown instance variable type")}}SetInstanceVariableOffset(t,e){if(0!==e){const s=this._instVarValues;if((t|=0)<0||t>=s.length)throw new RangeError("invalid instance variable");const n=s[t];if("number"!=typeof n)throw"boolean"==typeof n?new Error("can not set offset of boolean variable"):"string"==typeof n?new Error("can not set offset of string variable"):new Error("unknown instance variable type");s[t]+="number"==typeof e?e:parseFloat(e)}}GetSavedDataMap(){let t=savedDataMaps.get(this);return t||(t=new Map,savedDataMaps.set(this,t)),t}GetUnsavedDataMap(){let t=unsavedDataMaps.get(this);return t||(t=new Map,unsavedDataMaps.set(this,t)),t}_HasAnyCreateDestroyHandler(t){const e=this.GetObjectClass();if(e.UserScriptDispatcher().HasAnyHandlerFor(t))return!0;for(const s of e.GetFamilies())if(s.UserScriptDispatcher().HasAnyHandlerFor(t))return!0;return!!this._runtime.UserScriptDispatcher().HasAnyHandlerFor(t)}_TriggerOnCreatedOnSelfAndRelated(){const t=new Set,e=(t.add(this),this.GetWorldInfo());if(e&&e.HasChildren())for(const s of this.allChildren())if(t.add(s),s.IsInContainer())for(const n of s.siblings())t.add(n);if(this.IsInContainer())for(const i of this.siblings())t.add(i);for(const r of t.values())r._TriggerOnCreated();this._OnHierarchyReady()}_OnCreatedCommon(){this._objectType._GetUserScriptInstanceClass()&&this.GetInterfaceClass();for(const t of this._behaviorInstances)t.PostCreate()}_OnCreatedForLoadingSavegame(){this._OnCreatedCommon()}_TriggerOnCreated(){if(this._OnCreatedCommon(),this._HasAnyCreateDestroyHandler("instancecreate")){const t=this.GetObjectClass(),e=new C3.Event("instancecreate");e.instance=this.GetInterfaceClass(),t.DispatchUserScriptEvent(e);for(const s of t.GetFamilies())s.DispatchUserScriptEvent(e);this._runtime.DispatchUserScriptEvent(e)}this._runtime.Trigger(this.GetPlugin().GetConstructor().Cnds.OnCreated,this,null)}_OnHierarchyReady(){if(this.GetPlugin().SupportsSceneGraph()){if(this.DispatchUserScriptEvent(new C3.Event("hierarchyready")),this._HasAnyCreateDestroyHandler("hierarchyready")){const t=this.GetObjectClass(),e=new C3.Event("hierarchyready");e.instance=this.GetInterfaceClass(),t.DispatchUserScriptEvent(e);for(const s of t.GetFamilies())s.DispatchUserScriptEvent(e);this._runtime.DispatchUserScriptEvent(e)}this._runtime.Trigger(this.GetPlugin().GetConstructor().Cnds.OnHierarchyReady,this,null)}}_TriggerOnDestroyed(){this._runtime.Trigger(this.GetPlugin().GetConstructor().Cnds.OnDestroyed,this,null)}_FireDestroyedScriptEvents(t){if(this._iScriptInterface){const e=new C3.Event("destroy");e.isEndingLayout=t,this.DispatchUserScriptEvent(e)}if(this._HasAnyCreateDestroyHandler("instancedestroy")){const s=this.GetObjectClass(),n=new C3.Event("instancedestroy");n.instance=this.GetInterfaceClass(),n.isEndingLayout=t,s.DispatchUserScriptEvent(n);for(const i of s.GetFamilies())i.DispatchUserScriptEvent(n);this._runtime.DispatchUserScriptEvent(n)}}_GetDebuggerProperties(){return this._sdkInst?this._sdkInst.GetDebuggerProperties():this._iScriptInterface._getDebuggerProperties()}SaveToJson(t="full",e=null){const s={},n=("full"===t?s["uid"]=this.GetUID():s["c3"]=!0,this.GetTagsSet());if(0<n.size&&(s["tags"]=Array.from(n)),"visual-state"!==t){const r=savedDataMaps.get(this);if(r&&r.size&&(s["ex"]=C3.ToSuperJSON(r)),-1!==this.GetTimeScale()&&(s["mts"]=this.GetTimeScale()),0<this._objectType.GetInstanceVariablesCount()){const a={},o=this._objectType.GetInstanceVariableSIDs();for(let t=0,e=this._instVarValues.length;t<e;++t)a[o[t].toString()]=this._instVarValues[t];s["ivs"]=a}if(this._behaviorInstances.length){const l={};for(const h of this._behaviorInstances){const c=h.SaveToJson(t);c&&(l[h.GetBehaviorType().GetSID().toString()]=c)}s["behs"]=l}}this._worldInfo&&(s["w"]=this._worldInfo._SaveToJson(t,e));const i=this._sdkInst?this._sdkInst.SaveToJson():this._iScriptInterface._saveToJson();return i&&(s["data"]=i),s}_OnBeforeLoad(t="full",e){this._worldInfo&&this._worldInfo._OnBeforeLoad(t)}_OnAfterLoad(t,e="full",s=null){this._worldInfo&&this._worldInfo._OnAfterLoad(t,e,s)}_OnAfterLoad2(t,e="full",s=null){this._worldInfo&&this._worldInfo._OnAfterLoad2(t,e,s)}_SetupSceneGraphConnectionsOnChangeOfLayout(){this.GetPlugin().IsWorldType()&&this._worldInfo._SetupSceneGraphConnectionsOnChangeOfLayout()}LoadFromJson(e,t="full",s){if("full"===t)this._uid=e["uid"];else if(!e["c3"])return;if(this._SetTagsSetFromJson(e["tags"]),"visual-state"!==t){let t=savedDataMaps.get(this);t&&(t.clear(),savedDataMaps.delete(this));const i=e["ex"],r=(i&&(t=C3.FromSuperJSON(i),savedDataMaps.set(this,t)),this._timeScale=e.hasOwnProperty("mts")?e["mts"]:-1,e["ivs"]);if(r)for(const[a,o]of Object.entries(r)){const l=parseInt(a,10),h=this._objectType.GetInstanceVariableIndexBySID(l);if(!(h<0||h>=this._instVarValues.length)){let t=o;null===t&&(t=NaN),this._instVarValues[h]=t}}}if(this.GetPlugin().IsWorldType()){const c=e["w"];if(c){const _=c["l"];if(this._worldInfo.GetLayer().GetSID()!==_){const f=this._worldInfo.GetLayer(),d=f.GetLayout().GetLayerBySID(_);d?(this._worldInfo._SetLayer(d),f._RemoveInstance(this,!0),d._AddInstance(this,!0),d.SetZIndicesChanged(this),this._worldInfo.SetBboxChanged()):"full"===t&&this._runtime.DestroyInstance(this)}this._worldInfo._LoadFromJson(c,t)}}if("visual-state"!==t){const I=e["behs"];if(I)for(const[u,G]of Object.entries(I)){const p=parseInt(u,10),S=this.GetBehaviorIndexBySID(p);S<0||S>=this._behaviorInstances.length||this._behaviorInstances[S].LoadFromJson(G,t)}}const n=e["data"];n&&(this._sdkInst?this._sdkInst.LoadFromJson(n,t):this._iScriptInterface._loadFromJson(n))}GetInterfaceClass(){return this._iScriptInterface||this._InitUserScriptInterface()}HasScriptInterface(){return!!this._iScriptInterface}_InitUserScriptInterface(t,e){const s=this._worldInfo?t?self.ISDKWorldInstanceBase:self.IWorldInstance:t?self.ISDKInstanceBase:self.IInstance,n=t||this._sdkInst.GetScriptInterfaceClass(),i=this._objectType._GetUserScriptInstanceClass(),r=i||n||s,a=this.GetPlugin().GetSdkVersion();if(C3.AddonManager._PushInitObject(this,a),C3.AddonManager._PushInitProperties(e),this._iScriptInterface=new r,C3.AddonManager._PopInitProperties(),C3.AddonManager._PopInitObject(a),n&&!(this._iScriptInterface instanceof s))throw new TypeError(`script interface class '${n.name}' does not extend the right base class '${s.name}'`);if(i){const o=n||s;if(!(this._iScriptInterface instanceof o))throw new TypeError(`setInstanceClass(): class '${i.name}' does not extend the right base class - check it extends the right class, e.g. globalThis.InstanceType.MyObjectName`)}return this._iScriptInterface}_GetInstVarsScriptDescriptor(t){if(0!==this._instVarValues.length){const s={},n=this._objectType._GetAllInstanceVariableJsPropNames();for(let t=0,e=n.length;t<e;++t)s[n[t]]={configurable:!1,enumerable:!0,get:C3.Instance.prototype._GetInstanceVariableTypedValue.bind(this,t),set:C3.Instance.prototype.SetInstanceVariableValue.bind(this,t)};const e=Object.create(Object.prototype,s);t.instVars={value:e,writable:!1}}}_GetBehaviorsScriptDescriptor(t){const e=this._behaviorInstances;if(0!==e.length){const s={};for(const i of e)s[i.GetBehaviorType().GetJsPropName()]={value:i.GetScriptInterface(),writable:!1};const n=Object.create(Object.prototype,s);t.behaviors={value:n,writable:!1}}}DispatchUserScriptEvent(t){if(this.HasScriptInterface()){const e=this.GetInterfaceClass(),s=(t.instance=e,this._runtime),n=s.IsDebug()&&!s.GetEventSheetManager().IsInEventEngine();n&&C3Debugger.StartMeasuringScriptTime(),e.dispatchEvent(t),n&&C3Debugger.AddScriptTime()}}}; } // objects/sceneGraphInfo.js { const C3=self.C3;C3.SceneGraphInfo=class extends C3.DefendedBase{constructor(s){super(),this._owner=s,this._parent=null,this._children=[],this._startWidth=s.GetWidth(),this._startHeight=s.GetHeight(),this._startScaleX=1,this._startScaleY=1,this._parentStartAngle=0,this._ownOpacity=1,this._startOpacity=s.GetOpacity(),this._tmpSceneGraphChildren=null,this._tmpSceneGraphChildrenIndexes=null,this._indexInParent=NaN,this._originalSizeKnown=!1,this._originalWidth=NaN,this._originalHeight=NaN,this._on_instance_create=t=>{if(t.instance===this._parent.GetInstance()){const e=s.GetRuntime(),n=(e.Dispatcher().removeEventListener("instancecreate",this._on_instance_create),this._parent.GetInstance().GetSdkInstance());this._originalSizeKnown=!!n.IsOriginalSizeKnown(),this._originalWidth=this._originalSizeKnown?n.GetOriginalWidth():NaN,this._originalHeight=this._originalSizeKnown?n.GetOriginalHeight():NaN}}}Release(){this._parent=null,this._tmpSceneGraphChildren=null,this._tmpSceneGraphChildrenIndexes=null,this._indexInParent=NaN,this._originalSizeKnown=!1,this._originalWidth=NaN,this._originalHeight=NaN,C3.clearArray(this._children)}SetParent(t){if(this._ownOpacity=this._owner.GetOpacity(),this._startOpacity=this._ownOpacity,this._parent=t,this._parentStartAngle=t?t.GetAngle():0,this._parent){const e=this._owner,n=e.GetRuntime(),s=this._parent.GetInstance().GetPlugin().GetSdkVersion();if(s<2){const i=this._parent.GetInstance().GetSdkInstance();i?(this._originalSizeKnown=!!i.IsOriginalSizeKnown(),this._originalWidth=this._originalSizeKnown?i.GetOriginalWidth():NaN,this._originalHeight=this._originalSizeKnown?i.GetOriginalHeight():NaN):this._parent.GetInstance().IsDestroyed()||n.Dispatcher().addEventListener("instancecreate",this._on_instance_create)}else this._originalSizeKnown=!1,this._originalWidth=NaN,this._originalHeight=NaN}else this._originalSizeKnown=!1,this._originalWidth=NaN,this._originalHeight=NaN}GetParent(){return this._parent}HasChildren(){return 0<this._children.length}GetChildren(){return this._children}_MaybeSortChildren(){this.HasChildren()&&1!==this._children.length&&(this._tmpSceneGraphChildrenIndexes?this._children.sort((t,e)=>{const n=this._tmpSceneGraphChildrenIndexes.get(t.GetInstance()),s=this._tmpSceneGraphChildrenIndexes.get(e.GetInstance());return C3.IsFiniteNumber(n)&&C3.IsFiniteNumber(s)?n-s:0}):this._children.sort((t,e)=>{const n=t._GetSceneGraphInfo()._GetIndexInParent(),s=e._GetSceneGraphInfo()._GetIndexInParent();return C3.IsFiniteNumber(n)&&C3.IsFiniteNumber(s)?n-s:0}))}_GetIndexInParent(){return this._indexInParent}GetStartScaleX(){return this._startScaleX}SetStartScaleX(t){this._startScaleX=t}GetStartScaleY(){return this._startScaleY}SetStartScaleY(t){this._startScaleY=t}GetStartOpacity(){return this._startOpacity}GetOwnOpacity(){return this._ownOpacity}SetOwnOpacity(t){this._ownOpacity=t}_GetStartWidth(){return 0===this._startWidth?Number.EPSILON:this._startWidth}_GetStartHeight(){return 0===this._startHeight?Number.EPSILON:this._startHeight}GetParentScaleX(){if(this._owner.GetTransformWithParentWidth()){const n=this._parent;let t=n.GetWidth(),e=n._GetSceneGraphInfo()._GetStartWidth();return 0===t&&(t=Number.EPSILON),e===Number.EPSILON&&t===Number.EPSILON?1:e===Number.EPSILON&&t!==Number.EPSILON&&this._originalSizeKnown?1+t/this._originalWidth:t/e}return 1}GetParentScaleY(){if(this._owner.GetTransformWithParentHeight()){const n=this._parent;let t=n.GetHeight(),e=n._GetSceneGraphInfo()._GetStartHeight();return 0===t&&(t=Number.EPSILON),e===Number.EPSILON&&t===Number.EPSILON?1:e===Number.EPSILON&&t!==Number.EPSILON&&this._originalSizeKnown?1+t/this._originalHeight:t/e}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(t,e=null){const n=this._SaveToJsonProperties();return e&&e["selfOnly"]?Object.assign(n,{"p":null,"c":[]}):Object.assign(n,{"p":this._GetParentJson(t),"c":this._GetChildrenJson(t)})}_GetFlagsString(t){let e="";return t.GetTransformWithParentX()&&(e+="x"),t.GetTransformWithParentY()&&(e+="y"),t.GetTransformWithParentWidth()&&(e+="w"),t.GetTransformWithParentHeight()&&(e+="h"),t.GetTransformWithParentAngle()&&(e+="a"),t.GetTransformWithParentZElevation()&&(e+="z"),t.GetDestroyWithParent()&&(e+="d"),t.GetTransformWithParentOpacity()&&(e+="o"),t.GetTransformWithParentVisibility()&&(e+="v"),e}_GetParentJson(t){return!this._parent||!this._parent.GetInstance()||this._parent.GetInstance().IsDestroyed()?null:this._GetInstanceJson(this._parent,this._owner,t)}_GetChildrenJson(e){return this._children.map(t=>this._GetInstanceJson(t,t,e)).filter(t=>t)}_GetInstanceJson(t,e,n){const s=t.GetInstance();if(s&&s.IsDestroyed())return null;const i={};return i["uid"]=s.GetUID(),i["f"]=this._GetFlagsString(e),i["offsets"]=e._SaveSceneGraphPropertiesToJson(),i["data"]=C3.SceneGraphInfo.GetSceneGraphInstanceDataFromInstance(s),i["oci"]=s.GetObjectClass().GetIndex(),"state"===n?(i["inst"]=s.SaveToJson("full",{"selfOnly":!0}),i["instIndex"]=NaN):(i["instIndex"]=s.GetObjectClass().GetInstances().indexOf(s),i["inst"]=null),i}_LoadFromJson(t){this._startWidth=t["sw"],this._startHeight=t["sh"],this._startScaleX=t["sx"],this._startScaleY=t["sy"],this._parentStartAngle=t["psa"],this._ownOpacity=t["oo"],this._startOpacity=t["so"],this._indexInParent=C3.IsFiniteNumber(t["pi"])?t["pi"]:NaN}_SetTmpSceneGraphChildren(t,e){if(!t&&!e&&this._tmpSceneGraphChildren)for(const n of this._tmpSceneGraphChildren)n.IsDestroyed()||n.HasParent()||n.GetRuntime().DestroyInstance(n);this._tmpSceneGraphChildren=t,this._tmpSceneGraphChildrenIndexes=e}_OnAfterLoad(t,e){const n=this._owner,s=n.GetRuntime(),i=new Set;if(t["p"]&&!this._parent){const h=t["p"]["uid"],o=s.GetInstanceByUID(h);if(e?.setFromJson,o){const c=o.GetWorldInfo();if(o.HasChild(n.GetInstance()))this._parent=c;else{o.HasChildWithUID(n.GetInstance().GetUID())?s.DestroyInstance(n.GetInstance()):o.AddChild(n.GetInstance(),this._GetFlagsObj(t["p"]["f"])),i.has(n)||(n._LoadSceneGraphPropertiesFromJson(t["p"]["offsets"]),this._LoadInstancePropertiesFromJson(o,t["p"],e)),i.add(n);const l=o.GetWorldInfo();l._GetSceneGraphInfo()._MaybeSortChildren()}}else if(C3.IsFiniteNumber(t["p"]["oci"])){const d=s.GetObjectClassByIndex(t["p"]["oci"]),G=(s.GetSystemPlugin(),s.CreateInstance(d,n.GetLayer(),0,0,!0));if(e?.setFromJson,G){const _=this._GetInstanceData(t["p"],s),I=(_&&G.LoadFromJson(_),G.GetWorldInfo()),p=(I.GetLayer().SortAndAddInstancesByZIndex(G),G.AddChild(n.GetInstance(),this._GetFlagsObj(t["p"]["f"])),G.GetWorldInfo());p._GetSceneGraphInfo()._MaybeSortChildren()}}}const r=[];for(const S of t["c"]){const f=S["uid"],u=s.GetInstanceByUID(f);u&&r.push(u)}let a=0;for(const m of t["c"]){const C=m["uid"],N=s.GetInstanceByUID(C);if(e?.setFromJson,N){if(this._tmpSceneGraphChildren){if(this._tmpSceneGraphChildren.includes(N)){const P=N;if(P.GetObjectClass()!==N.GetObjectClass()){a++;continue}if(P.IsDestroyed()){a++;continue}const b=t["c"][a];if(!e?.setFromJson&&this._HasAllChildrenOfType(P,r,n)){this._UpdateInstance(a,b,n,i,e),a++;continue}if(P.HasParent()&&P.GetParent()!==n.GetInstance()){const W=this._CreateNewChildInstance(b,e);this._AddAndSetChildInstance(W,b,i,e),a++;continue}this._AddAndSetChildInstance(P.GetWorldInfo(),b,i,e,!0),a++;continue}if(this._tmpSceneGraphChildren[a]){const w=this._tmpSceneGraphChildren[a];if(w.GetObjectClass()!==N.GetObjectClass()){a++;continue}if(w.IsDestroyed()){a++;continue}const A=t["c"][a];if(!e?.setFromJson&&this._HasAllChildrenOfType(w,r,n)){this._UpdateInstance(a,A,n,i,e),a++;continue}if(w.HasParent()&&w.GetParent()!==n.GetInstance()){const F=this._CreateNewChildInstance(A,e);this._AddAndSetChildInstance(F,A,i,e),a++;continue}this._AddAndSetChildInstance(w.GetWorldInfo(),A,i,e,!0),a++;continue}}const g=N.GetObjectClass(),O=this._GetInstancesOfObjectClassCount(r,g),y=n.GetInstance().GetChildrenOfObjectClass(g).length;if(O===y){const J=n.GetInstance().GetChildAt(a);if(J){const L=J.GetWorldInfo();L&&(i.has(L)||(L._LoadSceneGraphPropertiesFromJson(m["offsets"]),this._LoadInstancePropertiesFromJson(J,m,e)),i.add(L))}a++;continue}if(N.HasParent()&&N.GetParent()!==n.GetInstance()){const x=this._CreateNewChildInstance(m,e);this._AddAndSetChildInstance(x,m,i,e),a++;continue}this._AddAndSetChildInstance(N.GetWorldInfo(),m,i,e)}else if(this._tmpSceneGraphChildren&&this._tmpSceneGraphChildren[a]){const H=this._tmpSceneGraphChildren[a],j=s.GetObjectClassByIndex(this._GetObjectClassIndex(m));if(H.GetObjectClass()!==j){a++;continue}if(H.IsDestroyed()){a++;continue}const D=t["c"][a];if(!e?.setFromJson&&this._HasAllChildrenOfType(H,r,n)){this._UpdateInstance(a,D,n,i,e),a++;continue}if(H.HasParent()&&H.GetParent()!==n.GetInstance()){const T=this._CreateNewChildInstance(D,e);this._AddAndSetChildInstance(T,D,i,e),a++;continue}this._AddAndSetChildInstance(H.GetWorldInfo(),D,i,e)}else{const E=this._CreateNewChildInstance(m,e);this._AddAndSetChildInstance(E,m,i,e)}a++}}_HasAllChildrenOfType(t,e,n){const s=t.GetObjectClass(),i=this._GetInstancesOfObjectClassCount(e,s),r=n.GetInstance().GetChildrenOfObjectClass(s).length;return i===r}_UpdateInstance(t,e,n,s,i){const r=n.GetInstance().GetChildAt(t,e);if(r){const a=r.GetWorldInfo();a&&(s.has(a)||(a._LoadSceneGraphPropertiesFromJson(e["offsets"]),this._LoadInstancePropertiesFromJson(r,e,i)),s.add(a))}}_GetFlagsObj(t){const e={};return e.transformX=t.includes("x"),e.transformY=t.includes("y"),e.transformWidth=t.includes("w"),e.transformHeight=t.includes("h"),e.transformAngle=t.includes("a"),e.transformZElevation=t.includes("z"),e.destroyWithParent=t.includes("d"),e.transformOpacity=t.includes("o"),e.transformVisibility=t.includes("v"),e}_GetObjectClassIndex(t){return C3.IsFiniteNumber(t["oci"])?t["oci"]:t[1]}_CreateNewChildInstance(e,n){if(C3.IsFiniteNumber(e["oci"])){const s=this._owner,i=s.GetRuntime();let t;if(e["data"])t=i.CreateInstanceFromData(e["data"],s.GetLayer(),!1,0,0,!1,!0);else{const r=i.GetObjectClassByIndex(e["oci"]);t=i.CreateInstance(r,s.GetLayer(),0,0,!0)}if(n?.setFromJson,t){const a=this._GetInstanceData(e,i),h=(a&&t.LoadFromJson(a),t.GetWorldInfo());return h.GetLayer().SortAndAddInstancesByZIndex(t,!0),h}}}_AddAndSetChildInstance(t,e,n,s,i=!0){const r=this._owner,a=r.AddChild(t,this._GetFlagsObj(e["f"]));a&&i&&(n.has(t)||(t._LoadSceneGraphPropertiesFromJson(e["offsets"]),this._LoadInstancePropertiesFromJson(t.GetInstance(),e,s)),n.add(t)),this._MaybeSortChildren()}_LoadInstancePropertiesFromJson(t,e,n){let s=this._GetInstanceData(e,this._owner.GetRuntime());s&&((s=JSON.parse(JSON.stringify(s)))["w"]=null,t.LoadFromJson(s))}_GetInstancesOfObjectClassCount(t,e){return t.filter(t=>t.GetObjectClass().GetName()===e.GetName()).length}_GetInstanceData(t,e){if(C3.IsFiniteNumber(t["instIndex"])){const n=e.GetObjectClassByIndex(t["oci"]),s=n._GetLoadInstancesJson();return s?s[t["instIndex"]]:null}return C3.IsString(t["inst"])?JSON.parse(t["inst"]):t["inst"]||void 0}static GetSceneGraphInstanceDataFromInstance(t){let e=t.GetWorldInfo().GetLayer().GetInitialInstanceData(t.GetUID());if(!e)return null;e=JSON.parse(JSON.stringify(e));const n=[];for(const s of[...t.GetChildren()]){const i=s.GetWorldInfo();n.push([i.GetLayout().GetSID(),i.GetLayer().GetIndex(),s.GetUID(),C3.SceneGraphInfo._GetFlagsNumber(i),s.GetObjectClass().IsInContainer()?1:0,i.GetZIndex(),C3.SceneGraphInfo.GetSceneGraphInstanceDataFromInstance(s)])}return C3.IsArray(e[0][14])?e[0][14][1]=n:(e[0][14]=[],e[0][14][0]=C3.SceneGraphInfo._GetDefaultFlagsNumber(),e[0][14][1]=n,e[0][14][2]=t.GetWorldInfo().GetZIndex()),e}static _GetFlagsNumber(t){let e=0;return(e|=Number(t.GetTransformWithParentVisibility())<<8)|Number(t.GetTransformWithParentOpacity())<<7|Number(t.GetTransformWithParentZElevation())<<6|Number(t.GetDestroyWithParent())<<5|Number(t.GetTransformWithParentAngle())<<4|Number(t.GetTransformWithParentHeight())<<3|Number(t.GetTransformWithParentWidth())<<2|Number(t.GetTransformWithParentY())<<1|Number(t.GetTransformWithParentX())<<0}static _GetDefaultFlagsNumber(t){let e=0;return(e|=256)|128|64|32|16|8|4|2|1,511}}; } // objects/worldInfo.js { const C3=self.C3,glMatrix=self.glMatrix,vec3=glMatrix.vec3,vec4=glMatrix.vec4,tempRect=C3.New(C3.Rect),tempQuad=C3.New(C3.Quad),bboxChangeEvent=C3.New(C3.Event,"bboxchange",!1),tempColor=C3.New(C3.Color,0,0,0,0),tempCollisionPoly=C3.New(C3.CollisionPoly),DEFAULT_COLOR=C3.New(C3.Color,1,1,1,1),DEFAULT_RENDER_CELLS=C3.New(C3.Rect,0,0,-1,-1),DEFAULT_COLLISION_CELLS=C3.New(C3.Rect,0,0,-1,-1),VALID_SET_MESH_POINT_MODES=new Set(["absolute","relative"]),EMPTY_ARRAY=[];let enableUpdateRendererStateGroup=!0;const FLAG_IS_VISIBLE=1,FLAG_BBOX_CHANGED=2,FLAG_ENABLE_BBOX_CHANGED_EVENT=4,FLAG_COLLISION_ENABLED=8,FLAG_COLLISION_CELL_CHANGED=16,FLAG_SOLID_FILTER_INCLUSIVE=32,FLAG_HAS_ANY_ACTIVE_EFFECT=64,FLAG_IS_ROTATABLE=128,FLAG_DESTROYED=256,FLAG_DESTROY_WITH_PARENT=512,FLAG_TRANSFORM_WITH_PARENT_X=1024,FLAG_TRANSFORM_WITH_PARENT_Y=2048,FLAG_TRANSFORM_WITH_PARENT_W=4096,FLAG_TRANSFORM_WITH_PARENT_H=8192,FLAG_TRANSFORM_WITH_PARENT_A=16384,FLAG_TRANSFORM_WITH_PARENT_Z_ELEVATION=32768,FLAG_TRANSFORM_WITH_PARENT_OPACITY=1<<22,FLAG_TRANSFORM_WITH_PARENT_VISIBILITY=1<<23,MASK_ALL_SCENE_GRAPH_FLAGS=FLAG_DESTROY_WITH_PARENT|FLAG_TRANSFORM_WITH_PARENT_X|FLAG_TRANSFORM_WITH_PARENT_Y|FLAG_TRANSFORM_WITH_PARENT_W|FLAG_TRANSFORM_WITH_PARENT_H|FLAG_TRANSFORM_WITH_PARENT_A|FLAG_TRANSFORM_WITH_PARENT_Z_ELEVATION|FLAG_TRANSFORM_WITH_PARENT_OPACITY|FLAG_TRANSFORM_WITH_PARENT_VISIBILITY,FLAG_MESH_CHANGED=65536,FLAG_PHYSICS_BODY_CHANGED=1<<17,FLAG_SIN_COS_ANGLE_CHANGED=1<<18,FLAG_USE_POINTS_SHADER_PROGRAM=1<<19,FLAG_DRAW_BACK_FACE_ONLY=1<<20,FLAG_DRAW_NON_BACK_FACES_ONLY=1<<21,FLAG_BLEND_MODE_BIT_OFFSET=26,FLAG_BLEND_MODE_MASK=31<<FLAG_BLEND_MODE_BIT_OFFSET,sceneGraphExportDataMap=new WeakMap,sceneGraphZIndexMap=new WeakMap;C3.WorldInfo=class extends C3.DefendedBase{constructor(t,e){super(),this._inst=t,this._objectClass=t.GetObjectClass(),this._runtime=t.GetRuntime(),this._layer=e,this._objectClass._OnWorldInstanceLayerChanged(this,null,e),this._zIndex=-1,this._htmlZIndex=-1,this._flags=FLAG_IS_VISIBLE|FLAG_BBOX_CHANGED|FLAG_COLLISION_ENABLED|FLAG_COLLISION_CELL_CHANGED|FLAG_MESH_CHANGED|FLAG_PHYSICS_BODY_CHANGED,this._objectClass.GetPlugin().IsRotatable()&&(this._flags|=FLAG_IS_ROTATABLE),this._x=NaN,this._y=NaN,this._zElevation=NaN,this._w=NaN,this._h=NaN,this._depth=NaN,this._a=NaN,this._sinA=NaN,this._cosA=NaN,this._ox=NaN,this._oy=NaN,this._boundingBox=C3.New(C3.Rect),this._boundingQuad=C3.New(C3.Quad),this._collisionCells=DEFAULT_COLLISION_CELLS,this._renderCells=DEFAULT_RENDER_CELLS,this._sourceCollisionPoly=null,this._transformedPolyInfo=null,this._solidFilterTags=null,this._color=DEFAULT_COLOR,this._colorPremultiplied=DEFAULT_COLOR,this._stateGroup=null,this._instanceEffectList=null,this._inst.GetObjectClass().UsesEffects()&&(this._instanceEffectList=C3.New(C3.InstanceEffectList,this._inst,this)),this._sceneGraphInfo=null,this._tmpSceneGraphChildren=null,this._tmpSceneGraphChildrenIndexes=null,this._tmpHierarchyPosition=-1,this._meshInfo=null}_MarkDestroyed(){this._flags|=FLAG_DESTROYED}Release(){if(this._objectClass._OnWorldInstanceLayerChanged(this,this._layer,null),this._stateGroup&&(this._runtime.GetRenderer().ReleaseStateGroup(this._stateGroup),this._stateGroup=null),this._sourceCollisionPoly=null,this._transformedPolyInfo&&(this._transformedPolyInfo.poly.Release(),this._transformedPolyInfo=null),this._solidFilterTags&&(this._solidFilterTags.clear(),this._solidFilterTags=null),this.ReleaseMesh(),this._instanceEffectList&&this._instanceEffectList.Release(),this.HasParent()&&this.GetParent().RemoveChild(this),this.HasChildren()){const t=[...this.GetChildren()];for(const e of t)this.RemoveChild(e)}this._ReleaseSceneGraphInfo(),this._ReleaseTmpSceneGraphInfo(),sceneGraphExportDataMap.delete(this),sceneGraphZIndexMap.delete(this),this._inst=null,this._objectClass=null,this._runtime=null,this._layer=null}Init(t){if(enableUpdateRendererStateGroup=!1,this.SetXY(t[0],t[1]),this.SetZElevation(t[2]),this.SetSize(t[3],t[4]),this._depth=0,this.IsRotatable()?this.SetAngle(t[6]):this._a=0,tempColor.setFromJSON(t[7]),this._SetColor(tempColor),this.SetOriginX(t[8]),this.SetOriginY(t[9]),this.SetBlendMode(t[10]),this._instanceEffectList&&this._instanceEffectList._LoadEffectParameters(t[12]),t[14]&&sceneGraphExportDataMap.set(this,{childrenData:t[14][1],zIndexData:t[14][2]}),t[15]){const e=t[15],i=(this.CreateMesh(e[0],e[1]),this.GetSourceMesh()),n=e[2];for(let s=0,t=n.length;s<t;++s){const r=n[s];for(let t=0,e=r.length;t<e;++t){const h=r[t],a=i.GetMeshPointAt(t,s);a.SetX(h[0]),a.SetY(h[1]),a.SetZElevation(h[2]),a.SetU(h[3]),a.SetV(h[4])}}}if(t[16]){const s=t[16][0],o=t[16][1],l=!!o,_=!l,G=this._runtime.GetTemplateManager();l&&G&&G.MapInstanceToTemplateName(this.GetInstance(),o),_&&G&&G.MapInstanceToTemplateName(this.GetInstance(),s)}enableUpdateRendererStateGroup=!0,this._UpdateRendererStateGroup()}InitNoData(){this._x=0,this._y=0,this._zElevation=0,this._w=0,this._h=0,this._depth=0,this._a=0,this._sinA=0,this._cosA=1,this._ox=0,this._oy=0,this._UpdateRendererStateGroup()}GetRuntime(){return this._runtime}GetObjectClass(){return this._objectClass}GetInstance(){return this._inst}_GetParentOffsetAngle(){return this.GetTransformWithParentAngle()?this._MaybeReflectAngleForMirrorFlip(this.GetParent()._GetAngleNoReflect()-this._sceneGraphInfo.GetParentStartAngle()):0}SetX(t){if(t=+t,this.GetTransformWithParentX()){const e=this._sceneGraphInfo,s=t-this.GetX(),i=-this._GetParentOffsetAngle();0==i?this._x+=s/e.GetParentScaleX():(this._x+=Math.cos(i)*s/e.GetParentScaleX(),this.GetTransformWithParentY()&&(this._y+=Math.sin(i)*s/e.GetParentScaleY()))}else this._x=t}OffsetX(t,e=!1){t=+t,!e&&this.GetTransformWithParentX()?this.SetX(this.GetX()+t):this._x+=t}GetX(){if(this.GetTransformWithParentX()){let t=this._x;const e=this._sceneGraphInfo,s=this.GetParent(),i=this._GetParentOffsetAngle();return 0===i?t*=e.GetParentScaleX():(t=t*e.GetParentScaleX()*Math.cos(i),this.GetTransformWithParentY()&&(t-=this._y*e.GetParentScaleY()*Math.sin(i))),s.GetX()+t}return this._x}SetY(t){if(t=+t,this.GetTransformWithParentY()){const e=this._sceneGraphInfo,s=t-this.GetY(),i=-this._GetParentOffsetAngle();0==i?this._y+=s/e.GetParentScaleY():(this.GetTransformWithParentX()&&(this._x-=Math.sin(i)*s/e.GetParentScaleX()),this._y+=Math.cos(i)*s/e.GetParentScaleY())}else this._y=t}OffsetY(t,e=!1){t=+t,!e&&this.GetTransformWithParentY()?this.SetY(this.GetY()+t):this._y+=t}GetY(){if(this.GetTransformWithParentY()){let t=this._y;const e=this._sceneGraphInfo,s=this.GetParent(),i=this._GetParentOffsetAngle();return 0===i?t*=e.GetParentScaleY():(t=t*e.GetParentScaleY()*Math.cos(i),this.GetTransformWithParentX()&&(t+=this._x*e.GetParentScaleX()*Math.sin(i))),s.GetY()+t}return this._y}SetXY(t,e){if(t=+t,e=+e,this.GetTransformWithParentXOrY()){const s=this.GetTransformWithParentX(),i=this.GetTransformWithParentY(),n=this._sceneGraphInfo,r=t-this.GetX(),h=e-this.GetY(),a=-this._GetParentOffsetAngle();if(0==a)s?this._x+=r/n.GetParentScaleX():this._x=t,i?this._y+=h/n.GetParentScaleY():this._y=e;else{const o=Math.sin(a),l=Math.cos(a);s?this._x+=i?(l*r-o*h)/n.GetParentScaleX():l*r/n.GetParentScaleX():this._x=t,i?this._y+=s?(o*r+l*h)/n.GetParentScaleY():l*h/n.GetParentScaleY():this._y=e}}else this._x=t,this._y=e}GetXY(){return[this.GetX(),this.GetY()]}OffsetXY(t,e){t=+t,e=+e,this.GetTransformWithParentXOrY()?this.SetXY(this.GetX()+t,this.GetY()+e):(this._x+=t,this._y+=e)}EqualsXY(t,e){return this.GetX()===t&&this.GetY()===e}SetZElevation(t){if(t=+t,this.GetTransformWithParentZElevation()&&(t-=this.GetParent().GetZElevation()),this._zElevation!==t){this._zElevation=t,this._UpdateZElevation();const e=this.GetLayer();0!==this._zElevation&&e._SetAnyInstanceZElevated(),e.SetZIndicesChanged(this)}}_UpdateZElevation(){if(this._UpdateRendererStateGroup(),this.HasChildren()){const s=this.GetChildren();for(let t=0,e=s.length;t<e;t++){const i=s[t];i.GetTransformWithParentZElevation()&&i._UpdateZElevation()}}}OffsetZElevation(t){this.SetZElevation(this.GetZElevation()+t)}GetZElevation(){return this.GetTransformWithParentZElevation()?this.GetParent().GetZElevation()+this._zElevation:this._zElevation}GetTotalZElevation(){return this.GetLayer().GetZElevation()+this.GetZElevation()}IsOriginalSizeKnown(){const t=this.GetInstance().GetPlugin().GetSdkVersion();return t<2&&this.GetInstance().GetSdkInstance().IsOriginalSizeKnown()}SetWidth(t){if(t=+t,this.GetTransformWithParentWidth()){const e=this.GetWidth();0===e?this._w=Number.EPSILON:this._w*=t/e}else this._w=t;this._MarkSinCosAngleChanged()}OffsetWidth(t,e){t=+t,!e&&this.GetTransformWithParentWidth()?this.SetWidth(this.GetWidth()+t):this._w+=t,this._MarkSinCosAngleChanged()}GetWidth(){if(this.GetTransformWithParentWidth()){const t=this.GetParent(),e=t.GetWidth(),s=t._GetSceneGraphInfo()._GetStartWidth();return s===Number.EPSILON?(this._GetSceneGraphInfo()._GetStartWidth()+e)*this._w:e*this._w}return this._w}SetHeight(t){if(t=+t,this.GetTransformWithParentHeight()){const e=this.GetHeight();0===e?this._h=Number.EPSILON:this._h*=t/e}else this._h=t;this._MarkSinCosAngleChanged()}OffsetHeight(t,e){t=+t,!e&&this.GetTransformWithParentHeight()?this.SetHeight(this.GetHeight()+t):this._h+=t,this._MarkSinCosAngleChanged()}GetHeight(){if(this.GetTransformWithParentHeight()){const t=this.GetParent(),e=t.GetHeight(),s=t._GetSceneGraphInfo()._GetStartHeight();return s===Number.EPSILON?(this._GetSceneGraphInfo()._GetStartHeight()+e)*this._h:e*this._h}return this._h}SetSize(t,e){if(t=+t,e=+e,this.GetTransformWithParentWidth()){const s=this.GetWidth();0===s?this._w=Number.EPSILON:this._w*=t/s}else this._w=t;if(this.GetTransformWithParentHeight()){const i=this.GetHeight();0===i?this._h=Number.EPSILON:this._h*=e/i}else this._h=e;this._MarkSinCosAngleChanged()}GetSize(){return[this.GetWidth(),this.GetHeight()]}GetDepth(){return this._depth}SetDepth(t){if(t<0)throw new RangeError("invalid depth");this._depth=t}GetSceneGraphScale(){if(this.HasParent()){const t=this._sceneGraphInfo;return Math.min(t.GetParentScaleX(),t.GetParentScaleY())}return 1}IsRotatable(){return 0!=(this._flags&FLAG_IS_ROTATABLE)}SetAngle(t){t=+t,this.IsRotatable()&&(this.GetTransformWithParentAngle()&&(t-=this.GetParent().GetAngle()),t=C3.clampAngle(t),this._a!==t)&&(this._a=t,this._MarkSinCosAngleChanged())}OffsetAngle(t){0!==(t=+t)&&this.IsRotatable()&&(this._a=C3.clampAngle(this._a+t),this._MarkSinCosAngleChanged())}_MarkSinCosAngleChanged(){if(this._flags|=FLAG_SIN_COS_ANGLE_CHANGED,this.HasChildren()){const s=this.GetChildren();for(let t=0,e=s.length;t<e;t++)s[t]._MarkSinCosAngleChanged()}}GetAngle(){return this.GetTransformWithParentAngle()&&this.IsRotatable()?this._MaybeReflectAngleForMirrorFlip(C3.clampAngle(this.GetParent()._GetAngleNoReflect()+this._a)):this._a}_GetAngleNoReflect(){return this.GetTransformWithParentAngle()&&this.IsRotatable()?C3.clampAngle(this.GetParent()._GetAngleNoReflect()+this._a):this._a}_MaybeReflectAngleForMirrorFlip(t){return this.GetTransformWithParentWidth()&&this.GetTopParent().GetWidth()<0&&(t=C3.clampAngle(C3.angleReflect(t,this.GetTopParent().GetAngle()+Math.PI))),t=this.GetTransformWithParentHeight()&&this.GetTopParent().GetHeight()<0?C3.angleReflect(t,this.GetTopParent().GetAngle()):t}_NeedsReflectAngleForMirrorOrFlip(){const t=this.GetParent();return!!(this.GetTransformWithParentWidth()&&t.GetWidth()<0)||!!(this.GetTransformWithParentHeight()&&t.GetHeight()<0)}_NeedsReflectAngleForMirrorAndFlip(){const t=this.GetParent();return!!(this.GetTransformWithParentWidth()&&t.GetWidth()<0&&this.GetTransformWithParentHeight()&&t.GetHeight()<0)}_MaybeUpdateSinCosAngle(){const t=this._flags;if(0!=(t&FLAG_SIN_COS_ANGLE_CHANGED)){const e=this.GetAngle();this._sinA=Math.sin(e),this._cosA=Math.cos(e),this._flags=t&~FLAG_SIN_COS_ANGLE_CHANGED}}GetSinAngle(){return this._MaybeUpdateSinCosAngle(),this._sinA}GetCosAngle(){return this._MaybeUpdateSinCosAngle(),this._cosA}SetOriginX(t){this._ox=+t}OffsetOriginX(t){this._ox+=+t}GetOriginX(){return this._ox}SetOriginY(t){this._oy=+t}OffsetOriginY(t){this._oy+=+t}GetOriginY(){return this._oy}_SetColor(t){this._color.equals(t)||(this._color===DEFAULT_COLOR?(this._color=C3.New(C3.Color,t),this._colorPremultiplied=C3.New(C3.Color,t),this._colorPremultiplied.premultiply()):t.equalsRgba(1,1,1,1)?(this._color=DEFAULT_COLOR,this._colorPremultiplied=DEFAULT_COLOR):(this._color.set(t),this._colorPremultiplied.set(t),this._colorPremultiplied.premultiply()),this._UpdateRendererStateGroup())}SetOpacity(t){if(t=C3.clamp(+t,0,1),this.GetTransformWithParentOpacity()){if(this._GetSceneGraphInfo().GetOwnOpacity()===t)return;this._GetSceneGraphInfo().SetOwnOpacity(t),t=this.GetOpacity()}else if(this._color.a===t)return;this._SetColorWithOpacity(t)}_SetOpacityOfChildren(){if(this.HasChildren()){const s=this.GetChildren();for(let t=0,e=s.length;t<e;t++){const i=s[t];i._SetColorWithOpacity(i.GetOpacity())}}}_SetColorWithOpacity(t){tempColor.copyRgb(this._color),tempColor.a=t,this._SetColor(tempColor),this._SetOpacityOfChildren()}OffsetOpacity(t){this.GetTransformWithParentOpacity()?this.SetOpacity(this._GetSceneGraphInfo().GetOwnOpacity()+t):this.SetOpacity(this.GetOpacity()+t)}GetOpacity(){return this.GetTransformWithParentOpacity()?this.GetParent().GetOpacity()*this._GetSceneGraphInfo().GetOwnOpacity():this._color.a}SetUnpremultipliedColor(t){this._color.equalsIgnoringAlpha(t)||(tempColor.copyRgb(t),tempColor.a=this.GetOpacity(),this._SetColor(tempColor))}SetUnpremultipliedColorRGB(t,e,s){tempColor.setRgb(t,e,s),this.SetUnpremultipliedColor(tempColor)}OffsetUnpremultipliedColorRGB(t,e,s){0===t&&0===e&&0===s||(tempColor.copyRgb(this._color),tempColor.r+=t,tempColor.g+=e,tempColor.b+=s,this.SetUnpremultipliedColor(tempColor))}GetUnpremultipliedColor(){return this._color}GetPremultipliedColor(){return this._colorPremultiplied}GetDestroyWithParent(){return 0!=(this._flags&FLAG_DESTROY_WITH_PARENT)}SetDestroyWithParent(t){this._SetFlag(FLAG_DESTROY_WITH_PARENT,t)}GetTransformWithParentX(){return 0!=(this._flags&FLAG_TRANSFORM_WITH_PARENT_X)}SetTransformWithParentX(t){this._SetFlag(FLAG_TRANSFORM_WITH_PARENT_X,t)}GetTransformWithParentY(){return 0!=(this._flags&FLAG_TRANSFORM_WITH_PARENT_Y)}GetTransformWithParentXOrY(){return 0!=(this._flags&(FLAG_TRANSFORM_WITH_PARENT_X|FLAG_TRANSFORM_WITH_PARENT_Y))}SetTransformWithParentY(t){this._SetFlag(FLAG_TRANSFORM_WITH_PARENT_Y,t)}GetTransformWithParentWidth(){return 0!=(this._flags&FLAG_TRANSFORM_WITH_PARENT_W)}SetTransformWithParentWidth(t){this._SetFlag(FLAG_TRANSFORM_WITH_PARENT_W,t)}GetTransformWithParentHeight(){return 0!=(this._flags&FLAG_TRANSFORM_WITH_PARENT_H)}SetTransformWithParentHeight(t){this._SetFlag(FLAG_TRANSFORM_WITH_PARENT_H,t)}GetTransformWithParentAngle(){return 0!=(this._flags&FLAG_TRANSFORM_WITH_PARENT_A)}SetTransformWithParentAngle(t){this._SetFlag(FLAG_TRANSFORM_WITH_PARENT_A,t)}GetTransformWithParentZElevation(){return 0!=(this._flags&FLAG_TRANSFORM_WITH_PARENT_Z_ELEVATION)}SetTransformWithParentZElevation(t){this._SetFlag(FLAG_TRANSFORM_WITH_PARENT_Z_ELEVATION,t)}GetTransformWithParentOpacity(){return 0!=(this._flags&FLAG_TRANSFORM_WITH_PARENT_OPACITY)}SetTransformWithParentOpacity(t){this._SetFlag(FLAG_TRANSFORM_WITH_PARENT_OPACITY,t)}GetTransformWithParentVisibility(){return 0!=(this._flags&FLAG_TRANSFORM_WITH_PARENT_VISIBILITY)}SetTransformWithParentVisibility(t){this._SetFlag(FLAG_TRANSFORM_WITH_PARENT_VISIBILITY,t)}_ClearAllSceneGraphFlags(){this._flags&=~MASK_ALL_SCENE_GRAPH_FLAGS}AddChild(t,e){if(t===this)return!1;if(t.HasParent())return!1;if(this._HasChildRecursive(t))return!1;if(this._HasAnyParent(t))return!1;const s=t.GetX(),i=t.GetY(),n=t.GetWidth(),r=t.GetHeight(),h=t.GetAngle(),a=t.GetZElevation(),o=t.GetOpacity(),l=(t._SetParent(this),t.SetTransformWithParentX(e.transformX),t.SetTransformWithParentY(e.transformY),t.SetTransformWithParentWidth(e.transformWidth),t.SetTransformWithParentHeight(e.transformHeight),t.SetTransformWithParentAngle(e.transformAngle),t.SetTransformWithParentZElevation(e.transformZElevation),t.SetTransformWithParentOpacity(e.transformOpacity),t.SetTransformWithParentVisibility(e.transformVisibility),t.SetDestroyWithParent(e.destroyWithParent),s-this.GetX()),_=i-this.GetY(),G=-this.GetAngle(),c=Math.cos(G),d=Math.sin(G);if(e.transformX&&(e.transformAngle?t._x=l*c-_*d:t._x=l,e.transformWidth)){const S=this.GetWidth()/this._sceneGraphInfo._GetStartWidth();0!=S&&(t._x/=S)}if(e.transformY&&(e.transformAngle?t._y=l*d+_*c:t._y=_,e.transformHeight)){const f=this.GetHeight()/this._sceneGraphInfo._GetStartHeight();0!=f&&(t._y/=f)}if(e.transformWidth){const p=this.GetWidth();0===p||p===Number.EPSILON?(t._w=1,t._sceneGraphInfo.SetStartScaleX(1)):(t._w=n/this.GetWidth(),t._sceneGraphInfo.SetStartScaleX(t._w))}if(e.transformHeight){const C=this.GetHeight();0===C||C===Number.EPSILON?(t._h=1,t._sceneGraphInfo.SetStartScaleY(1)):(t._h=r/this.GetHeight(),t._sceneGraphInfo.SetStartScaleY(t._h))}return e.transformAngle&&(t._a=h-this.GetAngle()),e.transformZElevation&&(t._zElevation=a-this.GetZElevation()),e.transformOpacity&&t._sceneGraphInfo.SetOwnOpacity(o),e.transformVisibility&&t.SetVisible(this.IsVisible()),this._AddChildToSceneGraphInfo(t),this.SetBboxChanged(),this._SetOpacityOfChildren(),!0}RemoveChild(t){if(t.GetParent()===this){const e=t.GetX(),s=t.GetY(),i=t.GetWidth(),n=t.GetHeight(),r=t.GetAngle(),h=t.GetZElevation(),a=t.GetOpacity();t._SetParent(null),t._ClearAllSceneGraphFlags(),t.SetXY(e,s),t.SetSize(i,n),t.SetAngle(r),t.SetZElevation(h),t.SetOpacity(a),this._RemoveChildFromSceneGraphInfo(t),this.SetBboxChanged()}}GetTmpHierarchyPosition(){return this._tmpHierarchyPosition}_ResetAllSceneGraphState(){this._BuildTmpSceneGraphData();const t=[...this.children()];for(const s of t)this.RemoveChild(s);const e=this.GetParent();e&&e.RemoveChild(this),this._ClearAllSceneGraphFlags()}_BuildTmpSceneGraphData(){if(this._SetTmpHierarchyPosition(),!this._tmpSceneGraphChildren){const e=[...this.children()];e.length&&(this._tmpSceneGraphChildren=[],this._tmpSceneGraphChildrenIndexes=new WeakMap);let t=0;for(const s of e){const i=s.GetInstance();this._tmpSceneGraphChildren.push(i),this._tmpSceneGraphChildrenIndexes.set(i,t),t++}}const t=this.GetParent();t&&t._BuildTmpSceneGraphData()}_SetTmpHierarchyPosition(){if(-1===this._tmpHierarchyPosition){const t=[...this.parents()];this._tmpHierarchyPosition=t.length;for(const s of t)s._SetTmpHierarchyPosition();const e=[...this.children()];for(const i of e)i._SetTmpHierarchyPosition()}}_ReleaseTmpSceneGraphInfo(){this._tmpSceneGraphChildren&&(this._tmpSceneGraphChildren.length=0),this._tmpSceneGraphChildren=null,this._tmpSceneGraphChildrenIndexes=null;const t=this.GetParent();t&&t._ReleaseTmpSceneGraphInfo(),this._tmpHierarchyPosition=-1}HasParent(){return null!==this.GetParent()}GetParent(){const t=this._sceneGraphInfo;return null!==t?t.GetParent():null}GetTopParent(){let t=this;for(;t.HasParent();)t=t.GetParent();return t}*parents(){let t=this.GetParent();for(;t;)yield t,t=t.GetParent()}HasChild(t){return this.GetChildren().includes(t)}HasChildren(){const t=this._sceneGraphInfo;return null!==t&&t.HasChildren()}GetChildren(){const t=this._sceneGraphInfo;return null!==t?t.GetChildren():EMPTY_ARRAY}children(){return this.GetChildren()}*allChildren(){for(const t of this.children())yield t,yield*t.allChildren()}GetChildCount(){return this.GetChildren().length}GetAllChildCount(){return[...this.allChildren()].length}GetChildAt(t){const e=this.GetChildren();return(t=Math.floor(+t))<0||t>=e.length?null:e[t]}GetChildIndex(e){if(e){const s=this.GetChildren();if(s)for(let t=0;t<s.length;t++)if(e===s[t])return t}return NaN}_CreateSceneGraphInfo(t){this._sceneGraphInfo||(this._sceneGraphInfo=C3.New(C3.SceneGraphInfo,this)),t&&this._sceneGraphInfo.SetParent(t)}_GetSceneGraphInfo(){return this._sceneGraphInfo}_ReleaseSceneGraphInfo(){this._sceneGraphInfo&&(this._sceneGraphInfo.Release(),this._sceneGraphInfo=null)}_SetParent(t){t?(t._CreateSceneGraphInfo(null),this._CreateSceneGraphInfo(t)):(this._sceneGraphInfo&&this._sceneGraphInfo.SetParent(null),this.HasChildren()||this._ReleaseSceneGraphInfo())}_HasAnyParent(t){if(!this.HasParent())return!1;const e=this.GetParent();return e===t||e._HasAnyParent(t)}_HasChildRecursive(t){if(this.HasChild(t))return!0;for(const e of this.GetChildren())if(e._HasChildRecursive(t))return!0;return!1}_AddChildToSceneGraphInfo(t){this._sceneGraphInfo.GetChildren().push(t)}_RemoveChildFromSceneGraphInfo(t){const e=this._sceneGraphInfo.GetChildren(),s=e.indexOf(t);-1!==s&&e.splice(s,1),0!==e.length||this.HasParent()||this._ReleaseSceneGraphInfo(),t.HasChildren()||t._ReleaseSceneGraphInfo()}GetSceneGraphChildrenExportData(){const t=sceneGraphExportDataMap.get(this);return t?t.childrenData:null}GetSceneGraphZIndexExportData(){const t=sceneGraphExportDataMap.get(this);return t?t.zIndexData:NaN}GetSceneGraphZIndex(){const t=sceneGraphZIndexMap.get(this);return C3.IsFiniteNumber(t)?t:NaN}SetSceneGraphZIndex(t){sceneGraphZIndexMap.set(this,t)}SetUsePointsShaderProgram(){this._SetFlag(FLAG_USE_POINTS_SHADER_PROGRAM,!0),this._UpdateRendererStateGroup()}_UpdateRendererStateGroup(){if(enableUpdateRendererStateGroup){const e=this._runtime.GetRenderer();this._stateGroup&&e.ReleaseStateGroup(this._stateGroup);let t;t=0!=(this._flags&FLAG_USE_POINTS_SHADER_PROGRAM)?e.GetPointsRenderingProgram()||"<point>":e.GetTextureFillShaderProgram()||"<default>",this._stateGroup=e.AcquireStateGroup(t,this.GetBlendMode(),this._colorPremultiplied,this.GetZElevation())}}GetRendererStateGroup(){return this._stateGroup}HasDefaultColor(){return this._color===DEFAULT_COLOR}SetBlendMode(t){if((t|=0)<0||31<t)throw new RangeError("invalid blend mode");this.GetBlendMode()!==t&&(this._flags=this._flags&~FLAG_BLEND_MODE_MASK|t<<FLAG_BLEND_MODE_BIT_OFFSET,this._UpdateRendererStateGroup())}GetBlendMode(){return(this._flags&FLAG_BLEND_MODE_MASK)>>FLAG_BLEND_MODE_BIT_OFFSET}_SetLayer(t,e){const s=e&&this._layer!==t;s&&this._RemoveFromRenderCells(),this._objectClass._OnWorldInstanceLayerChanged(this,this._layer,t),this._layer=t,s&&this._UpdateRenderCell(),0!==this.GetZElevation()&&this._layer._SetAnyInstanceZElevated()}GetLayer(){return this._layer}GetLayout(){return this.GetLayer().GetLayout()}_SetZIndex(t){this._zIndex=0|t}GetZIndex(){return this._layer._UpdateZIndices(),this._zIndex}_SetHTMLZIndex(t){this._htmlZIndex=0|t}GetHTMLZIndex(){return this._layer._UpdateHTMLZIndices(),this._htmlZIndex}_GetLastCachedZIndex(){return this._zIndex}_SetFlag(t,e){e?this._flags|=t:this._flags&=~t}IsVisible(){return 0!=(this._flags&FLAG_IS_VISIBLE)}SetVisible(t){if(this._SetFlag(FLAG_IS_VISIBLE,t),this.HasChildren())for(const e of this.GetChildren())e.GetTransformWithParentVisibility()&&e.SetVisible(t)}IsCollisionEnabled(){return 0!=(this._flags&FLAG_COLLISION_ENABLED)}SetCollisionEnabled(t){t=!!t,this.IsCollisionEnabled()!==t&&(this._SetFlag(FLAG_COLLISION_ENABLED,t),t?this.SetBboxChanged():this._RemoveFromCollisionCells())}SetSolidCollisionFilter(t,e){if(this._SetFlag(FLAG_SOLID_FILTER_INCLUSIVE,t),this._solidFilterTags&&this._solidFilterTags.clear(),e.trim()){this._solidFilterTags||(this._solidFilterTags=new Set);for(const s of e.split(" "))s&&this._solidFilterTags.add(s.toLowerCase())}else this._solidFilterTags=null}IsSolidCollisionAllowed(t){const e=0!=(this._flags&FLAG_SOLID_FILTER_INCLUSIVE),s=this._solidFilterTags;if(t&&s)for(const i of s)if(t.has(i))return e;return!e}SetBboxChanged(){if(this._flags|=FLAG_BBOX_CHANGED|FLAG_COLLISION_CELL_CHANGED|FLAG_MESH_CHANGED,this._objectClass._SetAnyCollisionCellChanged(!0),this._runtime.UpdateRender(),this._layer.UsesRenderCells()&&(this.CalculateBbox(this._boundingBox,this._boundingQuad,!0),this._flags&=~FLAG_BBOX_CHANGED,this._UpdateRenderCell()),0!=(this._flags&FLAG_ENABLE_BBOX_CHANGED_EVENT)&&this._inst.Dispatcher().dispatchEvent(bboxChangeEvent),null!==this._sceneGraphInfo){const s=this._sceneGraphInfo.GetChildren();for(let t=0,e=s.length;t<e;++t)s[t].SetBboxChanged()}}CalculateBbox(t,e,s){const i=this.GetX(),n=this.GetY(),r=this.GetWidth(),h=this.GetHeight(),a=this.GetAngle();t.setWH(i-this._ox*r,n-this._oy*h,r,h),s&&this.HasMesh()&&this._ExpandBboxForMesh(t),0===a?e.setFromRect(t):(t.offset(-i,-n),e.setFromRotatedRectPrecalc(t,this.GetSinAngle(),this.GetCosAngle()),e.offset(i,n),e.getBoundingBox(t)),t.normalize()}_UpdateBbox(){const t=this._flags;0!=(t&FLAG_BBOX_CHANGED)&&(this.CalculateBbox(this._boundingBox,this._boundingQuad,!0),this._flags=t&~FLAG_BBOX_CHANGED)}GetBoundingBox(){return this._UpdateBbox(),this._boundingBox}GetBoundingQuad(){return this._UpdateBbox(),this._boundingQuad}PixelRoundQuad(t){const e=this.GetX(),s=this.GetY(),i=Math.round(e)-e,n=Math.round(s)-s;return 0==i&&0==n?t:(tempQuad.copy(t),tempQuad.offset(i,n),tempQuad)}OverwriteBoundingBox(t){this._boundingBox.copy(t),this._boundingQuad.setFromRect(this._boundingBox),this._flags&=~FLAG_BBOX_CHANGED,this._UpdateCollisionCell(),this._UpdateRenderCell()}SetBboxChangeEventEnabled(t){this._SetFlag(FLAG_ENABLE_BBOX_CHANGED_EVENT,t)}IsBboxChangeEventEnabled(){return 0!=(this._flags&FLAG_ENABLE_BBOX_CHANGED_EVENT)}IsInViewport(t,e,s){return e&&0!==this.GetDepth()?this.IsInViewport3D(this.GetLayer()._GetViewFrustum()):0===this.GetZElevation()||s?t.intersectsRect(this.GetBoundingBox()):this._IsInViewport_ZElevated()}_IsInViewport_ZElevated(){const t=this.GetLayer(),e=this.GetTotalZElevation();return!(e>=t.Get2DCameraZ())&&(t.GetViewportForZ(e,tempRect),tempRect.intersectsRect(this.GetBoundingBox()))}IsInViewport3D(t){const e=this.GetBoundingBox(),s=e.getLeft(),i=e.getRight(),n=e.getTop(),r=e.getBottom(),h=this.GetTotalZElevation(),a=h+this.GetDepth();return t.ContainsAABB(s,n,h,i,r,a)}IsInViewport2(){const t=this.GetLayer();if(t.Has3DCamera())return this.IsInViewport3D(t._GetViewFrustum());{const e=t.GetLayout();return this.IsInViewport(t.GetViewport(),e.HasVanishingPointOutsideViewport(),e.IsOrthographicProjection())}}_SetDrawBackFaceOnly(t){this._SetFlag(FLAG_DRAW_BACK_FACE_ONLY,t)}_SetDrawNonBackFacesOnly(t){this._SetFlag(FLAG_DRAW_NON_BACK_FACES_ONLY,t)}IsDrawBackFaceOnly(){return 0!=(this._flags&FLAG_DRAW_BACK_FACE_ONLY)}IsDrawNonBackFacesOnly(){return 0!=(this._flags&FLAG_DRAW_NON_BACK_FACES_ONLY)}SetSourceCollisionPoly(t){this._sourceCollisionPoly=t,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(t,e,s){let i=0,n=1;return 0!==s&&(i=Math.sin(s),n=Math.cos(s)),this._GetCustomTransformedCollisionPolyPrecalc(t,e,s,i,n)}_GetCustomTransformedCollisionPolyPrecalc(e,s,t,i,n){let r=this._transformedPolyInfo;null===r&&(r={poly:C3.New(C3.CollisionPoly),width:NaN,height:NaN,angle:NaN},this._transformedPolyInfo=r);const h=r.poly;if(r.width!==e||r.height!==s||r.angle!==t){const a=this._sourceCollisionPoly;if(this.HasMesh()){const o=this.GetOriginX(),l=this.GetOriginY(),_=this.GetSourceMesh();let t=this._meshInfo.meshPoly;t||(a?(tempCollisionPoly.copy(a),tempCollisionPoly.offset(o,l)):tempCollisionPoly.setDefaultPoints(),t=_.InsertPolyMeshVertices(tempCollisionPoly),this._meshInfo.meshPoly=t),_.TransformCollisionPoly(t,h),h.offset(-o,-l),h.transformPrecalc(e,s,i,n)}else a?(h.copy(a),h.transformPrecalc(e,s,i,n)):h.setFromQuad(this.GetBoundingQuad(),-this.GetX(),-this.GetY());r.width=e,r.height=s,r.angle=t}return h}_DiscardTransformedCollisionPoly(){this.SetPhysicsBodyChanged(!0);const t=this._transformedPolyInfo;null!==t&&(t.width=NaN)}CreateMesh(t,e){if(t=Math.floor(t),e=Math.floor(e),!this.GetInstance().GetPlugin().SupportsMesh())throw new Error("object does not support mesh");this.ReleaseMesh(),this._meshInfo={sourceMesh:C3.New(C3.Gfx.Mesh,t,e),transformedMesh:C3.New(C3.Gfx.Mesh,t,e),meshPoly:null}}HasMesh(){return null!==this._meshInfo}GetSourceMesh(){if(this.HasMesh())return this._meshInfo.sourceMesh;throw new Error("no mesh")}GetTransformedMesh(){if(this.HasMesh())return this._meshInfo.transformedMesh;throw new Error("no mesh")}SetMeshChanged(t){this._SetFlag(FLAG_MESH_CHANGED,t)}IsMeshChanged(){return 0!=(this._flags&FLAG_MESH_CHANGED)}SetPhysicsBodyChanged(t){this._SetFlag(FLAG_PHYSICS_BODY_CHANGED,t)}IsPhysicsBodyChanged(){return 0!=(this._flags&FLAG_PHYSICS_BODY_CHANGED)}_ExpandBboxForMesh(t){const e=this._meshInfo.sourceMesh,s=Math.min(e.GetMinX(),0),i=Math.min(e.GetMinY(),0),n=Math.max(e.GetMaxX(),1),r=Math.max(e.GetMaxY(),1),h=t.width(),a=t.height();t.offsetLeft(s*h),t.offsetTop(i*a),t.offsetRight((n-1)*h),t.offsetBottom((r-1)*a),this._depth=e.GetMaxZ()}ReleaseMesh(){this._meshInfo&&(this._meshInfo.sourceMesh.Release(),this._meshInfo.transformedMesh.Release(),this._meshInfo=null,this._DiscardTransformedCollisionPoly())}SetMeshPoint(t,e,s){t=Math.floor(t),e=Math.floor(e);const i=s.mode||"absolute";if(!VALID_SET_MESH_POINT_MODES.has(i))throw new Error("invalid mode");const n="relative"===i;let r=s.x,h=s.y;const a=s.zElevation;let o="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 _=this.GetSourceMesh(),G=_.GetMeshPointAt(t,e);if(null===G)return!1;let c=!1;return"number"==typeof a&&G.GetZElevation()!==a&&(G.SetZElevation(a),c=!0),n&&(r+=t/(_.GetHSize()-1),h+=e/(_.GetVSize()-1)),o=-1!==o||n?(n&&(o+=t/(_.GetHSize()-1)),C3.clamp(o,0,1)):G.GetU(),l=-1!==l||n?(n&&(l+=e/(_.GetVSize()-1)),C3.clamp(l,0,1)):G.GetV(),G.GetX()===r&&G.GetY()===h&&G.GetU()===o&&G.GetV()===l?c:(G.SetX(r),G.SetY(h),G.SetU(o),G.SetV(l),this._DiscardTransformedCollisionPoly(),!0)}HasTilemap(){return this._inst.HasTilemap()}ContainsPoint(t,e){return!!this.GetBoundingBox().containsPoint(t,e)&&!!this.GetBoundingQuad().containsPoint(t,e)&&(this.HasTilemap()?this._inst.GetSdkInstance().TestPointOverlapTile(t,e):!this.HasOwnCollisionPoly()||this.GetTransformedCollisionPoly().containsPoint(t-this.GetX(),e-this.GetY()))}_IsCollisionCellChanged(){return 0!=(this._flags&FLAG_COLLISION_CELL_CHANGED)}_UpdateCollisionCell(){if(this._IsCollisionCellChanged()&&this.IsCollisionEnabled()&&0==(this._flags&FLAG_DESTROYED)){const t=this.GetBoundingBox(),e=this._objectClass._GetCollisionCellGrid(),s=this._collisionCells;if(tempRect.set(e.XToCell(t.getLeft()),e.YToCell(t.getTop()),e.XToCell(t.getRight()),e.YToCell(t.getBottom())),!s.equals(tempRect)){const i=this._inst;s===DEFAULT_COLLISION_CELLS?(e.Update(i,null,tempRect),this._collisionCells=C3.New(C3.Rect,tempRect)):(e.Update(i,s,tempRect),s.copy(tempRect)),this._flags&=~FLAG_COLLISION_CELL_CHANGED}}}_SetCollisionCellChanged(){this._flags|=FLAG_COLLISION_CELL_CHANGED}_RemoveFromCollisionCells(){const t=this._collisionCells;t!==DEFAULT_COLLISION_CELLS&&(this._objectClass._GetCollisionCellGrid().Update(this._inst,t,null),this._collisionCells=DEFAULT_COLLISION_CELLS)}_UpdateRenderCell(){const t=this.GetLayer();if(t.UsesRenderCells()&&0==(this._flags&FLAG_DESTROYED)){const e=t.GetRenderGrid(),s=this.GetBoundingBox(),i=this._renderCells;if(tempRect.set(e.XToCell(s.getLeft()),e.YToCell(s.getTop()),e.XToCell(s.getRight()),e.YToCell(s.getBottom())),!i.equals(tempRect)){const n=this._inst;i===DEFAULT_RENDER_CELLS?(e.Update(n,null,tempRect),this._renderCells=C3.New(C3.Rect,tempRect)):(e.Update(n,i,tempRect),i.copy(tempRect)),t.SetRenderListStale()}}}_RemoveFromRenderCells(){const t=this._renderCells;t!==DEFAULT_RENDER_CELLS&&(this.GetLayer().GetRenderGrid().Update(this._inst,t,null),this._renderCells=DEFAULT_RENDER_CELLS)}GetRenderCellRange(){return this._renderCells}ZOrderMoveToTop(){const t=this._inst,e=this._layer,s=e._GetInstances();s.length&&s.at(-1)===t||(e._RemoveInstance(t,!1),e._AddInstance(t,!1),this._runtime.UpdateRender())}ZOrderMoveToBottom(){const t=this._inst,e=this._layer,s=e._GetInstances();s.length&&s[0]===t||(e._RemoveInstance(t,!1),e._PrependInstance(t,!1),this._runtime.UpdateRender())}ZOrderMoveToLayer(t){const e=this._inst,s=this._layer;if(s.GetLayout()!==t.GetLayout())throw new Error("layer from different layout");t!==s&&(s._RemoveInstance(e,!0),this._SetLayer(t),t._AddInstance(e,!0),this._runtime.UpdateRender())}ZOrderMoveAdjacentToInstance(t,e){const s=this._inst;let i=!1;const n=this._layer;if(t.GetUID()!==s.GetUID()){const r=t.GetWorldInfo();if(!r)throw new Error("expected world instance");const h=r.GetLayer(),a=(n.GetIndex()!==h.GetIndex()&&(n._RemoveInstance(s,!0),this._SetLayer(h),h._AddInstance(s,!0),i=!0),h.MoveInstanceAdjacent(s,t,!!e));(i||a)&&this._runtime.UpdateRender()}}GetInstanceEffectList(){return this._instanceEffectList}_SetHasAnyActiveEffect(t){this._SetFlag(FLAG_HAS_ANY_ACTIVE_EFFECT,t)}HasAnyActiveEffect(){return 0!=(this._flags&FLAG_HAS_ANY_ACTIVE_EFFECT)}_SaveToJson(t,e=null){const s={"x":this.GetX(),"y":this.GetY(),"w":this.GetWidth(),"h":this.GetHeight(),"l":this.GetLayer().GetSID(),"zi":this.GetZIndex()},i=(0!==this.GetZElevation()&&(s["ze"]=this.GetZElevation()),0!==this.GetAngle()&&(s["a"]=this._GetAngleNoReflect()),this.HasDefaultColor()||(s["c"]=this._color.toJSON()),.5!==this.GetOriginX()&&(s["oX"]=this.GetOriginX()),.5!==this.GetOriginY()&&(s["oY"]=this.GetOriginY()),0!==this.GetBlendMode()&&(s["bm"]=this.GetBlendMode()),this.IsVisible()||(s["v"]=this.IsVisible()),this.IsCollisionEnabled()||(s["ce"]=this.IsCollisionEnabled()),this.IsBboxChangeEventEnabled()&&(s["be"]=this.IsBboxChangeEventEnabled()),this._instanceEffectList&&(s["fx"]=this._instanceEffectList._SaveToJson()),0!=(this._flags&FLAG_SOLID_FILTER_INCLUSIVE));return i&&(s["sfi"]=i),this._solidFilterTags&&(s["sft"]=[...this._solidFilterTags].join(" ")),this._sceneGraphInfo&&"visual-state"!==t&&(s["sgi"]=this._sceneGraphInfo._SaveToJson(t,e),sceneGraphExportDataMap.has(this))&&(s["sgcd"]=sceneGraphExportDataMap.get(this).childrenData,s["sgzid"]=sceneGraphExportDataMap.get(this).zIndexData),this.HasMesh()&&(s["mesh"]=this.GetSourceMesh().SaveToJson()),s}_SaveSceneGraphPropertiesToJson(){return{"x":this._x,"y":this._y,"z":this._zElevation,"w":this._w,"h":this._h,"a":this._a,"sgi":this._GetSceneGraphInfo()?this._GetSceneGraphInfo()._SaveToJsonProperties():null}}_LoadSceneGraphPropertiesFromJson(t){t&&(this._x=t["x"],this._y=t["y"],this._zElevation=t["z"],this._w=t["w"],this._h=t["h"],this._a=t["a"],t["sgi"]&&this._GetSceneGraphInfo()&&this._GetSceneGraphInfo()._LoadFromJson(t["sgi"]),this._MarkSinCosAngleChanged(),this.SetBboxChanged())}_SetupSceneGraphConnectionsOnChangeOfLayout(){this._ReleaseTmpSceneGraphInfo(),this._ResetAllSceneGraphState(),this._CreateSceneGraphInfo(null),this._sceneGraphInfo&&this._sceneGraphInfo._SetTmpSceneGraphChildren(this._tmpSceneGraphChildren,this._tmpSceneGraphChildrenIndexes)}_OnBeforeLoad(t){"visual-state"!==t&&this._ResetAllSceneGraphState()}_OnAfterLoad(t,e="full",s=null){t.hasOwnProperty("sgi")&&"visual-state"!==e&&0==(this._flags&FLAG_DESTROYED)&&this._sceneGraphInfo._OnAfterLoad(t["sgi"],s)}_OnAfterLoad2(t,e="full",s){t.hasOwnProperty("sgi")&&"visual-state"!==e&&0==(this._flags&FLAG_DESTROYED)&&(this._sceneGraphInfo._SetTmpSceneGraphChildren(null,null),this._ReleaseTmpSceneGraphInfo(),this.SetBboxChanged())}_LoadFromJson(t,e){if(enableUpdateRendererStateGroup=!1,this.SetX(t["x"]),this.SetY(t["y"]),this.SetWidth(t["w"]),this.SetHeight(t["h"]),this._SetZIndex(t["zi"]),this.SetZElevation(t.hasOwnProperty("ze")?t["ze"]:0),this.SetAngle(t.hasOwnProperty("a")?t["a"]:0),t.hasOwnProperty("c")?tempColor.setFromJSON(t["c"]):t.hasOwnProperty("o")?(tempColor.copyRgb(this._color),tempColor.a=t["o"]):tempColor.setRgba(1,1,1,1),this._SetColor(tempColor),this.SetOriginX(t.hasOwnProperty("oX")?t["oX"]:.5),this.SetOriginY(t.hasOwnProperty("oY")?t["oY"]:.5),this.SetBlendMode(t.hasOwnProperty("bm")?t["bm"]:0),this.SetVisible(!t.hasOwnProperty("v")||t["v"]),this.SetCollisionEnabled(!t.hasOwnProperty("ce")||t["ce"]),this.SetBboxChangeEventEnabled(!!t.hasOwnProperty("be")&&t["be"]),this.SetSolidCollisionFilter(!!t.hasOwnProperty("sfi")&&t["sfi"],t.hasOwnProperty("sft")?t["sft"]:""),this._instanceEffectList&&t.hasOwnProperty("fx")&&this._instanceEffectList._LoadFromJson(t["fx"]),!t.hasOwnProperty("sgi")&&"visual-state"!==e&&this._tmpSceneGraphChildren)for(const s of this._tmpSceneGraphChildren)s.IsDestroyed()||this._runtime.DestroyInstance(s);if(t.hasOwnProperty("sgi")&&"visual-state"!==e){this._CreateSceneGraphInfo(null);const i=this._sceneGraphInfo,n=t["sgi"];i._LoadFromJson(n),i._SetTmpSceneGraphChildren(this._tmpSceneGraphChildren,this._tmpSceneGraphChildrenIndexes),t["sgcd"]&&C3.IsFiniteNumber(t["sgzid"])&&sceneGraphExportDataMap.set(this,{childrenData:t["sgcd"],zIndexData:t["sgzid"]})}if(t.hasOwnProperty("mesh")){const r=t["mesh"];this.CreateMesh(r["cols"],r["rows"]),this.GetSourceMesh().LoadFromJson(r)}else this.ReleaseMesh();this.SetBboxChanged(),enableUpdateRendererStateGroup=!0,this._UpdateRendererStateGroup(),"visual-state"!==e&&this._runtime.AddInstanceNeedingAfterLoad(this.GetInstance(),t)}}; } // objects/behaviorType.js { const C3=self.C3;C3.BehaviorType=class extends C3.DefendedBase{constructor(e,t){super();const s=e.GetRuntime(),i=s.GetObjectReference(t[1]),r=(s.GetAddonManager()._DelayCreateBehavior(i),this._runtime=s,this._objectClass=e,this._behavior=C3.AddonManager.GetBehaviorByConstructorFunction(i),this._sdkType=null,this._iBehaviorType=null,this._instSdkCtor=i.Instance,this._sid=t[2],this._name=t[0],this._jsPropName=this._runtime.GetJsPropName(t[3]),this._behavior.GetSdkVersion());if(r<2&&(this._sdkType=C3.New(i.Type,this),!(this._sdkType instanceof C3.SDKBehaviorTypeBase)))throw new Error("v1 sdk type must derive from SDKBehaviorBase");if(C3.AddonManager._PushInitObject(this,r),2<=r){const a=i.Type??globalThis.ISDKBehaviorTypeBase;if(this._iBehaviorType=new a,!(this._iBehaviorType instanceof globalThis.ISDKBehaviorTypeBase))throw new Error("script interface class must derive from ISDKBehaviorTypeBase")}else this._iBehaviorType=new globalThis.IBehaviorType;C3.AddonManager._PopInitObject(r),this.OnCreate()}static Create(e,t){return C3.New(C3.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}}; } // objects/behaviorInstance.js { const C3=self.C3,IBehaviorInstance=self.IBehaviorInstance;C3.BehaviorInstance=class extends C3.DefendedBase{constructor(t){super(),this._runtime=t.runtime,this._behaviorType=t.behaviorType,this._behavior=this._behaviorType.GetBehavior(),this._inst=t.instance,this._index=t.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(t){if(this._sdkInst)throw new Error("already got sdk instance");const e=this.GetBehavior().GetSdkVersion();if(e<2){if(this._sdkInst=C3.New(this._behaviorType.GetInstanceSdkCtor(),this,t),!(this._sdkInst instanceof C3.SDKBehaviorInstanceBase))throw new Error("v1 sdk type must derive from SDKBehaviorInstanceBase")}else{const s=this.GetBehavior().GetScriptInterfaceClass();this._InitScriptInterface(s.Instance,t)}}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(t,e){this._sdkInst&&this._sdkInst.OnSpriteFrameChanged(t,e)}_GetDebuggerProperties(){return this._sdkInst?this._sdkInst.GetDebuggerProperties():this._iScriptInterface._getDebuggerProperties()}SaveToJson(t="full"){return this._sdkInst?this._sdkInst.SaveToJson(t):this._iScriptInterface._saveToJson(t)}LoadFromJson(t,e="full"){if(this._sdkInst)return this._sdkInst.LoadFromJson(t,e);this._iScriptInterface._loadFromJson(t,e)}static SortByTickSequence(t,e,s){const n=globalThis.ISDKBehaviorInstanceBase;let i,r;i=e instanceof n?t._UnwrapScriptInterface(e):e.GetBehaviorInstance(),r=s instanceof n?t._UnwrapScriptInterface(s):s.GetBehaviorInstance();const a=i.GetObjectInstance(),h=r.GetObjectInstance(),c=a.GetObjectClass().GetIndex(),o=h.GetObjectClass().GetIndex();if(c!==o)return c-o;const I=a.GetPUID(),_=h.GetPUID();return I!==_?I-_:i._GetIndex()-r._GetIndex()}_InitScriptInterface(t,e){const s=IBehaviorInstance,n=t??this._sdkInst.GetScriptInterfaceClass(),i=n||s,r=this.GetBehavior().GetSdkVersion();if(C3.AddonManager._PushInitObject(this,r),C3.AddonManager._PushInitProperties(e),this._iScriptInterface=new i,C3.AddonManager._PopInitProperties(),C3.AddonManager._PopInitObject(r),!n||this._iScriptInterface instanceof s)return this._iScriptInterface;throw new TypeError(`script interface class '${n.name}' does not extend the right base class '${s.name}'`)}GetScriptInterface(){return this._iScriptInterface||this._InitScriptInterface()}HasScriptInterface(){return!!this._iScriptInterface}}; } // objects/effectList.js { const C3=self.C3;C3.EffectList=class extends C3.DefendedBase{constructor(e,t){super(),this._owner=e,this._allEffectTypes=[],this._activeEffectTypes=[],this._effectTypesByName=new Map,this._effectParams=[],this._effectParamBuffers=[],this._allInstanceEffectLists=new Set,this._preservesOpaqueness=!0;for(const s of t){const f=C3.New(C3.EffectType,this,s,this._allEffectTypes.length);this._allEffectTypes.push(f),this._effectTypesByName.set(f.GetName().toLowerCase(),f),3<=s.length&&this._effectParams.push(this._LoadSingleEffectParameters(f,s[2]))}this.GetRuntime()._AddEffectList(this)}Release(){this.GetRuntime()._RemoveEffectList(this);for(const e of this._effectParamBuffers)e.Release();C3.clearArray(this._effectParamBuffers),C3.clearArray(this._allEffectTypes),C3.clearArray(this._activeEffectTypes),this._effectTypesByName.clear(),C3.clearArray(this._effectParams),this._owner=null}_AddInstanceEffectList(e){this._allInstanceEffectLists.add(e)}_RemoveInstanceEffectList(e){this._allInstanceEffectLists.delete(e)}_InitRenderer(e){e.IsWebGPU()&&(this._effectParamBuffers=this._allEffectTypes.map(e=>{const t=e.GetShaderProgram();return 0<t.GetCustomParametersByteSize()?C3.New(C3.Gfx.WebGPUEffectCustomParamsBuffer,t):null}),this._UpdateAllEffectParamBuffers());for(const t of this._allInstanceEffectLists)t._InitRenderer(e)}PrependEffectTypes(e){if(e.length){this._allEffectTypes=e.concat(this._allEffectTypes);for(const t of e)this._effectTypesByName.set(t.GetName().toLowerCase(),t);for(let e=0,t=this._allEffectTypes.length;e<t;++e)this._allEffectTypes[e]._SetIndex(e)}}_LoadSingleEffectParameters(e,t){e.SetActive(t[0]);const s=t.slice(1);for(let e=0,t=s.length;e<t;++e){const f=s[e];if(Array.isArray(f)){const r=C3.New(C3.Color);r.setFromJSON(f),s[e]=r}}return s}GetOwner(){return this._owner}GetRuntime(){return this._owner.GetRuntime()}UpdateActiveEffects(){C3.clearArray(this._activeEffectTypes);let e=!0;for(const t of this._allEffectTypes)t.IsActive()&&(this._activeEffectTypes.push(t),t.GetShaderProgram().PreservesOpaqueness()||(e=!1));this._preservesOpaqueness=e}GetAllEffectTypes(){return this._allEffectTypes}HasAnyEffectType(){return 0<this._allEffectTypes.length}GetEffectTypeByName(e){return this._effectTypesByName.get(e.toLowerCase())||null}GetEffectTypeByIndex(e){if((e=Math.floor(+e))<0||e>=this._allEffectTypes.length)throw new RangeError("invalid effect type index");return this._allEffectTypes[e]}IsEffectIndexActive(e){return this.GetEffectTypeByIndex(e).IsActive()}SetEffectIndexActive(e,t){this.GetEffectTypeByIndex(e).SetActive(t)}GetActiveEffectTypes(){return this._activeEffectTypes}HasAnyActiveEffect(){return 0<this._activeEffectTypes.length}PreservesOpaqueness(){return this._preservesOpaqueness}GetEffectParametersForIndex(e){return this._effectParams[e]}_GetEffectChainShaderParametersForIndex(e){return(e<this._effectParamBuffers.length?this._effectParamBuffers:this._effectParams)[e]}GetEffectParameter(e,t){if(e<0||e>=this._effectParams.length)return null;const s=this._effectParams[e];return t<0||t>=s.length?null:s[t]}SetEffectParameter(e,t,s){if(e<0||e>=this._effectParams.length)return!1;const f=this._effectParams[e];if(t<0||t>=f.length)return!1;const r=f[t];if(r instanceof C3.Color){if(r.equalsIgnoringAlpha(s))return!1;r.copyRgb(s)}else{if(r===s)return!1;f[t]=s}return e<this._effectParamBuffers.length&&this._effectParamBuffers[e].SetParameterValue(t,s),!0}_UpdateAllEffectParamBuffers(){const s=this._effectParams,f=this._effectParamBuffers;for(let e=0,t=Math.min(s.length,f.length);e<t;++e){const r=f[e],a=s[e];for(let e=0,t=a.length;e<t;++e)r.SetParameterValue(e,a[e])}}static SaveFxParamToJson(e){return e&&e instanceof C3.Color?{"t":"color","v":e.toJSON()}:e}static LoadFxParamFromJson(e){if(null===e)return NaN;if("object"!=typeof e)return e;{const t=e["t"];if("color"!==t)throw new Error("invalid effect parameter type");{const s=C3.New(C3.Color);return s.setFromJSON(e["v"]),s}}}static SaveFxParamsToJson(e){return e.map(C3.EffectList.SaveFxParamToJson)}static LoadFxParamsFromJson(e){return e.map(C3.EffectList.LoadFxParamFromJson)}SaveToJson(){return this._allEffectTypes.map(e=>({"name":e.GetName(),"active":e.IsActive(),"params":C3.EffectList.SaveFxParamsToJson(this._effectParams[e.GetIndex()])}))}LoadFromJson(e){for(const t of e){const s=this.GetEffectTypeByName(t["name"]);s&&(s.SetActive(t["active"]),this._effectParams[s.GetIndex()]=C3.EffectList.LoadFxParamsFromJson(t["params"]))}this.UpdateActiveEffects(),this._UpdateAllEffectParamBuffers()}}; } // objects/effectType.js { const C3=self.C3;C3.EffectType=class extends C3.DefendedBase{constructor(e,t,r){super(),this._effectList=e,this._id=t[0],this._name=t[1],this._index=r,this._shaderProgram=null,this._isActive=!0}Release(){this._effectList=null,this._shaderProgram=null}Clone(e){const t=C3.New(C3.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 r=[];for(let e=0,t=this._shaderProgram.GetParameterCount();e<t;++e){const s=this._shaderProgram.GetParameterType(e);if("float"===s||"percent"===s)r.push(0);else{if("color"!==s)throw new TypeError("unknown effect parameter type");r.push(C3.New(C3.Color,1,1,1,1))}}return r}}; } // objects/instanceEffectList.js { const C3=self.C3;C3.InstanceEffectList=class extends C3.DefendedBase{constructor(e,t){super(),this._inst=e,this._wi=t,this._effectList=e.GetObjectClass().GetEffectList(),this._needsRebuildSteps=!0,this._wasDefaultColor=!0,this._was3D=!1,this._wasRotatedOrNegativeSize=!1,this._wasTexRotated=!1,this._wasMustPreDraw=!1,this._effectChain=C3.New(C3.Gfx.EffectChain,e.GetRuntime().GetCanvasManager().GetEffectChainManager(),{drawContent:(e,t)=>{const s=t.GetContentObject(),f=s.GetWorldInfo();e.SetColor(f.GetPremultipliedColor()),e.SetCurrentZ(f.GetTotalZElevation()),s.Draw(e),e.SetCurrentZ(0)},getSourceTextureInfo:e=>{const t=e.GetCurrentTexRect(),[s,f]=e.GetCurrentSurfaceSize();return{srcTexRect:t,srcWidth:s,srcHeight:f}},getShaderParameters:e=>this._GetEffectChainShaderParametersForIndex(e)}),this._activeEffectFlags=[],this._activeEffectTypes=[],this._preservesOpaqueness=!0,this._effectParams=[],this._effectParamBuffers=[],this._InitRenderer(e.GetRuntime().GetRenderer());for(let e=0,t=this._effectList.GetAllEffectTypes().length;e<t;++e)this._activeEffectFlags.push(!0);this.UpdateActiveEffects(),this._effectList._AddInstanceEffectList(this)}Release(){this._effectList._RemoveInstanceEffectList(this);for(const e of this._effectParamBuffers)e&&e.Release();C3.clearArray(this._effectParamBuffers),this._effectChain.Release(),this._effectChain=null,C3.clearArray(this._activeEffectFlags),C3.clearArray(this._activeEffectTypes),C3.clearArray(this._effectParams),this._inst=null,this._effectList=null}_InitRenderer(e){e.IsWebGPU()&&(this._effectParamBuffers=this._effectList.GetAllEffectTypes().map(e=>{const t=e.GetShaderProgram();return 0<t.GetCustomParametersByteSize()?C3.New(C3.Gfx.WebGPUEffectCustomParamsBuffer,t):null}))}_LoadEffectParameters(e){let t=0;for(const s of e)this._effectParams.push(this._LoadSingleEffectParameters(t,s)),++t;this._UpdateAllEffectParamBuffers(),this.UpdateActiveEffects()}_LoadSingleEffectParameters(e,t){this._activeEffectFlags[e]=t[0];const s=t.slice(1);for(let e=0,t=s.length;e<t;++e){const f=s[e];if(Array.isArray(f)){const a=C3.New(C3.Color);a.setFromJSON(f),s[e]=a}}return s}LoadDefaultEffectParameters(){for(const e of this._effectList.GetAllEffectTypes())this._effectParams.push(e.GetDefaultParameterValues());this._UpdateAllEffectParamBuffers()}GetOwner(){return this._owner}GetEffectList(){return this._effectList}GetEffectChain(){return this._MaybeRebuildEffectChainSteps(),this._effectChain}GetRuntime(){return this._inst.GetRuntime()}UpdateActiveEffects(){C3.clearArray(this._activeEffectTypes);const e=this._wi,s=this._effectList.GetAllEffectTypes(),f=this._activeEffectTypes,a=this._activeEffectFlags;let r=!0;for(let e=0,t=s.length;e<t;++e)if(a[e]){const i=s[e];f.push(i),i.GetShaderProgram().PreservesOpaqueness()||(r=!1)}this._preservesOpaqueness=r,e._SetHasAnyActiveEffect(!!f.length),this._needsRebuildSteps=!0}_MaybeRebuildEffectChainSteps(){const e=this._inst,t=this._wi,s=t.HasDefaultColor(),f=e.GetPlugin().Is3D(),a=0!==t.GetAngle()||0!==t.GetLayer().GetAngle()||t.GetWidth()<0||t.GetHeight()<0,r=e.IsCurrentTexRotated(),i=e.MustPreDraw();(this._needsRebuildSteps||s!==this._wasDefaultColor||f!==this._was3D||a!==this._wasRotatedOrNegativeSize||r!==this._wasTexRotated||i!==this._wasMustPreDraw||this._effectChain.NeedsRebuild())&&(this._effectChain.BuildSteps(this._activeEffectTypes.map(e=>e.GetShaderProgram()),{indexMap:this._activeEffectTypes.map(e=>e.GetIndex()),forcePreDraw:!s||i,is3D:f,isSourceTextureRotated:r,isRotatedOrNegativeSizeInstance:a}),this._needsRebuildSteps=!1,this._wasDefaultColor=s,this._was3D=f,this._wasRotatedOrNegativeSize=a,this._wasTexRotated=r,this._wasMustPreDraw=i)}GetActiveEffectTypes(){return this._activeEffectTypes}GetEffectParametersForIndex(e){return this._effectParams[e]}_GetEffectChainShaderParametersForIndex(e){return(e<this._effectParamBuffers.length?this._effectParamBuffers:this._effectParams)[e]}GetEffectParameter(e,t){if(e<0||e>=this._effectParams.length)return null;const s=this._effectParams[e];return t<0||t>=s.length?null:s[t]}SetEffectParameter(e,t,s){if(e<0||e>=this._effectParams.length)return!1;const f=this._effectParams[e];if(t<0||t>=f.length)return!1;const a=f[t];if(a instanceof C3.Color){if(a.equalsIgnoringAlpha(s))return!1;a.copyRgb(s)}else{if(a===s)return!1;f[t]=s}return e<this._effectParamBuffers.length&&this._effectParamBuffers[e].SetParameterValue(t,s),!0}_UpdateAllEffectParamBuffers(){const s=this._effectParams,f=this._effectParamBuffers;for(let e=0,t=f.length;e<t;++e){const a=f[e],r=s[e];for(let e=0,t=r.length;e<t;++e)a.SetParameterValue(e,r[e])}}PreservesOpaqueness(){return this._preservesOpaqueness}HasAnyActiveBackgroundBlendingEffect(){return this._activeEffectTypes.some(e=>e.GetShaderProgram().BlendsBackground())}IsEffectIndexActive(e){return this._activeEffectFlags[e]}SetEffectIndexActive(e,t){this._activeEffectFlags[e]=!!t}GetAllEffectTypes(){return this._effectList.GetAllEffectTypes()}_SaveToJson(){return this._effectList.GetAllEffectTypes().map(e=>({"name":e.GetName(),"active":this._activeEffectFlags[e.GetIndex()],"params":C3.EffectList.SaveFxParamsToJson(this._effectParams[e.GetIndex()])}))}_LoadFromJson(e){for(const t of e){const s=this._effectList.GetEffectTypeByName(t["name"]);s&&(this._activeEffectFlags[s.GetIndex()]=t["active"],this._effectParams[s.GetIndex()]=C3.EffectList.LoadFxParamsFromJson(t["params"]))}this.UpdateActiveEffects(),this._UpdateAllEffectParamBuffers()}}; } // collisions/collisionEngine.js { const C3=self.C3,tempCandidates=[],tileCollRectCandidates=[],tempJumpthruRet=[],tempPolyA=C3.New(C3.CollisionPoly),tempPolyB=C3.New(C3.CollisionPoly),tempQuad=C3.New(C3.Quad),tempRect=C3.New(C3.Rect),tempRect2=C3.New(C3.Rect);let tempPolyC=null,tempRect3=null,tempQuadB=null;C3.CollisionEngine=class extends C3.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(),l=t.GetWorldInfo();s&&l&&s.IsCollisionEnabled()&&l.IsCollisionEnabled()&&this._registeredCollisions.push([e,t])}AddRegisteredCollisionCandidates(t,s,l){for(const[n,o]of this._registeredCollisions){let e=null;if(t===n)e=o;else{if(t!==o)continue;e=n}!e.BelongsToObjectClass(s)||l.includes(e)||l.push(e)}}CheckRegisteredCollision(e,t){if(this._registeredCollisions.length)for(const[s,l]of this._registeredCollisions)if(e===s&&t===l||e===l&&t===s)return!0;return!1}ClearRegisteredCollisions(){C3.clearArray(this._registeredCollisions)}TestOverlap(e,t){if(!e||!t||e===t)return!1;const s=e.GetWorldInfo(),l=t.GetWorldInfo();if(!s.IsCollisionEnabled()||!l.IsCollisionEnabled())return!1;this._collisionCheckCount++;const n=s.GetLayer(),o=l.GetLayer(),i=n.IsTransformCompatibleWith(o);return i?this._TestOverlap_SameLayers(s,l):this._TestOverlap_DifferentLayers(s,l)}_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(),l=t.GetTransformedCollisionPoly();return s.intersectsPoly(l,t.GetX()-e.GetX(),t.GetY()-e.GetY())}_TestOverlap_DifferentLayers(s,l){const e=s.HasTilemap(),t=l.HasTilemap();if(e&&!t)return this.TestTilemapOverlapDifferentLayers(s,l);if(t&&!e)return this.TestTilemapOverlapDifferentLayers(l,s);if(t||e)return!1;{const n=s.GetLayer(),o=l.GetLayer(),i=(tempPolyA.copy(s.GetTransformedCollisionPoly()),tempPolyB.copy(l.GetTransformedCollisionPoly()),tempPolyA.pointsArr());for(let e=0,t=i.length;e<t;e+=2){const a=e+1,c=i[e],C=i[a],[d,u]=n.LayerToCanvasCss(c+s.GetX(),C+s.GetY());i[e]=d,i[a]=u}const r=tempPolyB.pointsArr();for(let e=0,t=r.length;e<t;e+=2){const h=e+1,p=r[e],f=r[h],[G,m]=o.LayerToCanvasCss(p+l.GetX(),f+l.GetY());r[e]=G,r[h]=m}return tempPolyA.setBboxChanged(),tempPolyB.setBboxChanged(),this._polyCheckCount++,tempPolyA.intersectsPoly(tempPolyB,0,0)}}TestTilemapOverlapDifferentLayers(e,t){const s=e.GetLayer(),l=t.GetLayer(),n=(tempPolyC=tempPolyC||C3.New(C3.CollisionPoly),tempRect3=tempRect3||C3.New(C3.Rect),tempQuadB=tempQuadB||C3.New(C3.Quad),t.GetX()),o=t.GetY(),[i,r]=l.LayerToCanvasCss(n,o),[a,c]=s.CanvasCssToLayer(i,r),C=a-n,d=c-o;if(tempRect3.copy(t.GetBoundingBox()),tempRect3.offset(C,d),!e.GetBoundingBox().intersectsRect(tempRect3))return!1;if(tempQuadB.copy(t.GetBoundingQuad()),tempQuadB.offset(C,d),this._polyCheckCount++,!e.GetBoundingQuad().intersectsQuad(tempQuadB))return!1;tempPolyC.copy(t.GetTransformedCollisionPoly());const u=tempPolyC.pointsArr();for(let e=0,t=u.length;e<t;e+=2){const h=e+1;u[e]+=C,u[h]+=d}return tempPolyC.setBboxChanged(),this.TestTilemapOverlap(e,t,a,c,tempPolyC,tempRect3,tempQuadB)}TestTilemapOverlap(e,s,t,l,n,o,i){const r=void 0!==o?o:s.GetBoundingBox(),a=e.GetX(),c=e.GetY(),C=e.GetInstance().GetSdkInstance(),d=void 0!==t?t:s.GetX(),u=void 0!==l?l:s.GetY(),h=s.HasOwnCollisionPoly(),p=void 0!==i?i:s.GetBoundingQuad(),f=tileCollRectCandidates;C.GetCollisionRectCandidates(r,f);for(let e=0,t=f.length;e<t;++e){const G=f[e],m=G.GetRect();if(this._collisionCheckCount++,r.intersectsRectOffset(m,a,c)&&(tempQuad.setFromRect(m),tempQuad.offset(a,c),tempQuad.intersectsQuad(p)))if(h){const y=void 0!==n?n:s.GetTransformedCollisionPoly();let e=d,t=u;void 0!==n&&(e=s.GetX(),t=s.GetY());const g=G.GetPoly();if(g){if(this._polyCheckCount++,g.intersectsPoly(y,e-(a+m.getLeft()),t-(c+m.getTop())))return C3.clearArray(f),!0}else if(tempPolyA.setFromQuad(tempQuad,0,0),tempPolyA.intersectsPoly(y,e,t))return C3.clearArray(f),!0}else{const T=G.GetPoly();if(!T)return C3.clearArray(f),!0;if(tempPolyA.setFromQuad(p,0,0),T.intersectsPoly(tempPolyA,-(a+m.getLeft()),-(c+m.getTop())))return C3.clearArray(f),!0}}return C3.clearArray(f),!1}TestAndSelectCanvasPointOverlap(e,o,i){const r=e.GetCurrentSol(),t=this._runtime.GetCurrentEvent();if(!t)throw new Error("cannot call outside event");const a=t.IsOrBlock(),s=new Map,c=e=>{let t=s.get(e);return void 0===t&&(t=e.IsSelfAndParentsInteractive(),s.set(e,t)),t};if(r.IsSelectAll()){i||(r._SetSelectAll(!1),C3.clearArray(r._GetOwnInstances())),a&&C3.clearArray(r._GetOwnElseInstances());for(const l of e.GetInstances()){const n=l.GetWorldInfo(),C=n.GetLayer();let e=!1;if(e=c(C)&&n.IsInViewport2()?o.some(([e,t])=>{const[s,l]=C.CanvasCssToLayer(e,t,n.GetTotalZElevation());return n.ContainsPoint(s,l)}):e){if(i)return!1;r._PushInstance(l)}else a&&r._PushElseInstance(l)}}else{let s,l=!1,n=(!a||t.IsFirstConditionOfType(this._runtime.GetCurrentCondition())||this._runtime.IsCurrentConditionFirst()&&!r._GetOwnElseInstances().length&&r._GetOwnInstances().length?s=r._GetOwnInstances():(s=r._GetOwnElseInstances(),l=!0),0);for(let t=0,e=s.length;t<e;++t){const d=s[t],u=d.GetWorldInfo(),h=u.GetLayer();let e=!1;if(e=c(h)&&u.IsInViewport2()?o.some(([e,t])=>{const[s,l]=h.CanvasCssToLayer(e,t,u.GetTotalZElevation());return u.ContainsPoint(s,l)}):e){if(i)return!1;l?r._PushInstance(d):s[n++]=d}else l?s[n++]=d:a&&r._PushElseInstance(d)}i||(s.length=n)}return e.ApplySolToContainer(),s.clear(),!!i||r.HasAnyInstances()}_ObjectClassCanUseCollisionCells(e,t){if(e)for(const s of t.layersHasInstancesOn())if(!e.IsTransformCompatibleWith(s))return!1;return!0}GetCollisionCandidates(e,t,s,l){if(t.IsFamily())for(const n of t.GetFamilyMembers())this._ObjectClassCanUseCollisionCells(e,n)?(n._UpdateAllCollisionCells(),n._GetCollisionCellGrid().QueryRange(s,l)):C3.appendArray(l,n.GetInstances());else this._ObjectClassCanUseCollisionCells(e,t)?(t._UpdateAllCollisionCells(),t._GetCollisionCellGrid().QueryRange(s,l)):C3.appendArray(l,t.GetInstances())}GetObjectClassesCollisionCandidates(e,t,s,l){for(const n of t)this.GetCollisionCandidates(e,n,s,l)}GetSolidCollisionCandidates(e,t,s){const l=this._runtime.GetSolidBehavior();l&&this.GetObjectClassesCollisionCandidates(e,l.GetObjectClasses(),t,s)}GetJumpthruCollisionCandidates(e,t,s){const l=this._runtime.GetJumpthruBehavior();l&&this.GetObjectClassesCollisionCandidates(e,l.GetObjectClasses(),t,s)}IsSolidCollisionAllowed(e,t){return e._IsSolidEnabled()&&(!t||t.GetWorldInfo().IsSolidCollisionAllowed(e.GetSavedDataMap().get("solidTags")))}TestOverlapSolid(e){const t=e.GetWorldInfo();this.GetSolidCollisionCandidates(t.GetLayer(),t.GetBoundingBox(),tempCandidates);for(const s of tempCandidates)if(this.IsSolidCollisionAllowed(s,e)&&this.TestOverlap(e,s))return C3.clearArray(tempCandidates),s;return C3.clearArray(tempCandidates),null}TestRectOverlapSolid(e,t){this.GetSolidCollisionCandidates(null,e,tempCandidates);for(const s of tempCandidates)if(this.IsSolidCollisionAllowed(s,t)&&this.TestRectOverlap(e,s))return C3.clearArray(tempCandidates),s;return C3.clearArray(tempCandidates),null}TestOverlapJumpthru(e,t){let s=null;t&&(s=tempJumpthruRet,C3.clearArray(s));const l=e.GetWorldInfo();this.GetJumpthruCollisionCandidates(l.GetLayer(),l.GetBoundingBox(),tempCandidates);for(const n of tempCandidates)if(n._IsJumpthruEnabled()&&this.TestOverlap(e,n)){if(!t)return C3.clearArray(tempCandidates),n;s.push(n)}return C3.clearArray(tempCandidates),s}PushOut(t,s,l,n,o){n=n||50;const i=t.GetWorldInfo(),r=i.GetX(),a=i.GetY();for(let e=0;e<n;++e)if(i.SetXY(r+s*e,a+l*e),i.SetBboxChanged(),!this.TestOverlap(t,o))return!0;return i.SetXY(r,a),i.SetBboxChanged(),!1}PushOutSolid(t,s,l,n,o,i){n=n||50;const r=t.GetWorldInfo(),a=r.GetX(),c=r.GetY();let C=null,d=null;for(let e=0;e<n;++e)if(r.SetXY(a+s*e,c+l*e),r.SetBboxChanged(),!this.TestOverlap(t,C))if(C=this.TestOverlapSolid(t))d=C;else if(o&&(C=i?this.TestOverlap(t,i)?i:null:this.TestOverlapJumpthru(t))&&(d=C),!C)return d&&this.PushInFractional(t,s,l,d,16,!0),!0;return r.SetXY(a,c),r.SetBboxChanged(),!1}PushOutSolidAxis(s,l,n,e){e=e||50;const o=s.GetWorldInfo(),i=o.GetX(),r=o.GetY();let a=null,c=null;for(let t=0;t<e;++t)for(let e=0;e<2;++e){const C=2*e-1;if(o.SetXY(i+l*t*C,r+n*t*C),o.SetBboxChanged(),!this.TestOverlap(s,a)){if(!(a=this.TestOverlapSolid(s)))return c&&this.PushInFractional(s,l*C,n*C,c,16,!0),!0;c=a}}return o.SetXY(i,r),o.SetBboxChanged(),!1}PushInFractional(e,t,s,l,n,o){let i=2,r=!1,a=!1;const c=e.GetWorldInfo();let C=c.GetX(),d=c.GetY();for(;i<=n;){const u=1/i;i*=2,c.OffsetXY(t*u*(r?1:-1),s*u*(r?1:-1)),c.SetBboxChanged(),this.TestOverlap(e,l)||o&&this.TestOverlapSolid(e)?(r=!0,a=!0):(r=!1,a=!1,C=c.GetX(),d=c.GetY())}a&&(c.SetXY(C,d),c.SetBboxChanged())}PushOutSolidNearest(s,e=100){let l=0;const n=s.GetWorldInfo(),o=n.GetX(),i=n.GetY();let r=0,a=this.TestOverlapSolid(s);if(!a)return!0;for(;l<=e;){let e=0,t=0;switch(r){case 0:e=0,t=-1,l++;break;case 1:e=1,t=-1;break;case 2:e=1,t=0;break;case 3:e=1,t=1;break;case 4:e=0,t=1;break;case 5:e=-1,t=1;break;case 6:e=-1,t=0;break;case 7:e=-1,t=-1}if(r=(r+1)%8,n.SetXY(Math.floor(o+e*l),Math.floor(i+t*l)),n.SetBboxChanged(),!this.TestOverlap(s,a)&&!(a=this.TestOverlapSolid(s)))return!0}return n.SetXY(o,i),n.SetBboxChanged(),!1}CalculateBounceAngle(e,t,s,l){const n=e.GetWorldInfo(),o=n.GetX(),i=n.GetY(),r=Math.max(10,C3.distanceTo(t,s,o,i)),a=C3.angleTo(t,s,o,i),c=l||this.TestOverlapSolid(e);if(!c)return C3.clampAngle(a+Math.PI);let C=c,d=0,u=0;const h=C3.toRadians(5);let p;for(p=1;p<36;++p){const P=a-p*h;if(n.SetXY(t+Math.cos(P)*r,s+Math.sin(P)*r),n.SetBboxChanged(),!this.TestOverlap(e,C)&&!(C=l?null:this.TestOverlapSolid(e))){d=P;break}}for(36===p&&(d=C3.clampAngle(a+Math.PI)),C=c,p=1;p<36;++p){const O=a+p*h;if(n.SetXY(t+Math.cos(O)*r,s+Math.sin(O)*r),n.SetBboxChanged(),!this.TestOverlap(e,C)&&!(C=l?null:this.TestOverlapSolid(e))){u=O;break}}if(36===p&&(u=C3.clampAngle(a+Math.PI)),n.SetXY(o,i),n.SetBboxChanged(),u===d)return u;const f=C3.angleDiff(u,d)/2;let G;G=C3.angleClockwise(u,d)?C3.clampAngle(d+f+Math.PI):C3.clampAngle(u+f);const m=Math.cos(a),y=Math.sin(a),g=Math.cos(G),T=Math.sin(G),_=m*g+y*T,I=m-2*_*g,S=y-2*_*T;return C3.angleTo(0,0,I,S)}TestSegmentOverlap(e,t,s,l,n){if(!n)return!1;const o=n.GetWorldInfo();if(!o.IsCollisionEnabled())return!1;if(this._collisionCheckCount++,tempRect.set(Math.min(e,s),Math.min(t,l),Math.max(e,s),Math.max(t,l)),!o.GetBoundingBox().intersectsRect(tempRect))return!1;if(n.HasTilemap())return this._TestSegmentOverlapTilemap(e,t,s,l,n,o);if(this._polyCheckCount++,!o.GetBoundingQuad().intersectsSegment(e,t,s,l))return!1;if(!o.HasOwnCollisionPoly())return!0;const i=o.GetTransformedCollisionPoly();return i.intersectsSegment(o.GetX(),o.GetY(),e,t,s,l)}_TestSegmentOverlapTilemap(s,l,n,o,e,t){const i=t.GetX(),r=t.GetY(),a=e.GetSdkInstance(),c=tileCollRectCandidates;tempRect2.set(s,l,n,o),tempRect2.normalize(),a.GetCollisionRectCandidates(tempRect2,c);for(let e=0,t=c.length;e<t;++e){const C=c[e],d=C.GetRect();if(this._collisionCheckCount++,tempRect.intersectsRectOffset(d,i,r)&&(tempQuad.setFromRect(d),tempQuad.offset(i,r),tempQuad.intersectsSegment(s,l,n,o))){const u=C.GetPoly();if(!u)return C3.clearArray(c),!0;if(this._polyCheckCount++,u.intersectsSegment(i+d.getLeft(),r+d.getTop(),s,l,n,o))return C3.clearArray(c),!0}}return C3.clearArray(c),!1}TestRectOverlap(e,t){if(!t)return!1;const s=t.GetWorldInfo();if(!s.IsCollisionEnabled())return!1;if(this._collisionCheckCount++,!s.GetBoundingBox().intersectsRect(e))return!1;if(t.HasTilemap())return this._TestRectOverlapTilemap(e,t,s);if(this._polyCheckCount++,tempQuad.setFromRect(e),!s.GetBoundingQuad().intersectsQuad(tempQuad))return!1;if(!s.HasOwnCollisionPoly())return!0;const l=tempPolyA,n=(l.setFromRect(e,s.GetX(),s.GetY()),s.GetTransformedCollisionPoly());return l.intersectsPoly(n,0,0)}_TestRectOverlapTilemap(s,e,t){const l=t.GetX(),n=t.GetY(),o=e.GetSdkInstance(),i=tileCollRectCandidates;o.GetCollisionRectCandidates(s,i);for(let e=0,t=i.length;e<t;++e){const r=i[e],a=r.GetRect();if(this._collisionCheckCount++,s.intersectsRectOffset(a,l,n)){const c=r.GetPoly();if(!c)return C3.clearArray(i),!0;if(this._polyCheckCount++,tempPolyA.setFromRect(s,0,0),c.intersectsPoly(tempPolyA,-(l+a.getLeft()),-(n+a.getTop())))return C3.clearArray(i),!0}}return C3.clearArray(i),!1}TestRayIntersectsInstance(e,t){if(e){const s=e.GetWorldInfo();s.IsCollisionEnabled()&&(this._collisionCheckCount++,s.GetBoundingBox().intersectsRect(t.rect))&&(e.HasTilemap()?this._TestRayIntersectsTilemap(e,s,t):(this._polyCheckCount++,s.HasOwnCollisionPoly()?t.TestInstancePoly(e,s.GetX(),s.GetY(),s.GetTransformedCollisionPoly()):t.TestInstanceQuad(e,s.GetBoundingQuad())))}}_TestRayIntersectsTilemap(s,l,n){const o=l.GetX(),i=l.GetY(),r=tileCollRectCandidates;s.GetSdkInstance().GetCollisionRectCandidates(n.rect,r);for(let e=0,t=r.length;e<t;e++){const a=r[e],c=a.GetRect();if(this._collisionCheckCount++,n.rect.intersectsRectOffset(c,o,i)){const C=a.GetPoly();this._polyCheckCount++,C?n.TestInstancePoly(s,o+c.getLeft(),i+c.getTop(),C):n.TestInstanceRect(s,l.GetX(),l.GetY(),c)}}C3.clearArray(r)}SetCollisionCellSize(e,t){if(e!==this._collisionCellWidth||t!==this._collisionCellHeight){this._collisionCellWidth=e,this._collisionCellHeight=t;const s=this._runtime.GetAllObjectClasses();for(const l of s)if(l.IsWorldType()){for(const n of l.instancesIncludingPendingCreate())n.GetWorldInfo()._RemoveFromCollisionCells();l._GetCollisionCellGrid().SetCellSize(e,t),l._SetAnyCollisionCellChanged();for(const o of l.instancesIncludingPendingCreate()){const i=o.GetWorldInfo();i._SetCollisionCellChanged(),i._UpdateCollisionCell()}}}}GetCollisionCellSize(){return[this._collisionCellWidth,this._collisionCellHeight]}_InitCollisionCellSize(e,t){this._collisionCellWidth=e,this._collisionCellHeight=t}}; } // collisions/sparseGrid.js { const C3=self.C3;C3.SparseGrid=class extends C3.DefendedBase{constructor(t,e){super(),this._cellWidth=t,this._cellHeight=e,this._cells=C3.New(C3.PairMap)}Release(){this._cells.Release(),this._cells=null}SetCellSize(t,e){if(!this._cells.IsEmpty())throw new Error("grid not empty");this._cellWidth=t,this._cellHeight=e}GetCell(t,e,l){let i=this._cells.Get(t,e);return i||(l?(i=C3.New(C3.GridCell,this,t,e),this._cells.Set(t,e,i),i):null)}XToCell(t){const e=Math.floor(t/this._cellWidth);return isFinite(e)?e:0}YToCell(t){const e=Math.floor(t/this._cellHeight);return isFinite(e)?e:0}Update(i,s,o){if(s)for(let l=s.getLeft(),t=s.getRight();l<=t;++l)for(let t=s.getTop(),e=s.getBottom();t<=e;++t)if(!o||!o.containsPoint(l,t)){const h=this.GetCell(l,t,!1);h&&(h.Remove(i),h.IsEmpty())&&this._cells.Delete(l,t)}if(o)for(let l=o.getLeft(),t=o.getRight();l<=t;++l)for(let t=o.getTop(),e=o.getBottom();t<=e;++t)s&&s.containsPoint(l,t)||this.GetCell(l,t,!0).Insert(i)}QueryRange(t,e){let l=this.XToCell(t.getLeft());const i=this.YToCell(t.getTop()),s=this.XToCell(t.getRight()),o=this.YToCell(t.getBottom());if(isFinite(s)&&isFinite(o))for(;l<=s;++l)for(let t=i;t<=o;++t){const h=this.GetCell(l,t,!1);h&&h.Dump(e)}}}; } // collisions/gridCell.js { const C3=self.C3;C3.GridCell=class extends C3.DefendedBase{constructor(s,e,t){super(),this._grid=s,this._x=e,this._y=t,this._instances=C3.New(C3.ArraySet)}Release(){this._instances.Release(),this._instances=null,this._grid=null}IsEmpty(){return this._instances.IsEmpty()}Insert(s){this._instances.Add(s)}Remove(s){this._instances.Delete(s)}Dump(s){C3.appendArray(s,this._instances.GetArray())}}; } // collisions/ray.js { const C3=self.C3,PADDING=1e-6,NO_HIT=2;C3.Ray=class{constructor(){this.x1=0,this.y1=0,this.x2=0,this.y2=0,this.dx=0,this.dy=0,this.rect=new C3.Rect,this.hitFraction=NO_HIT,this.hitUid=null,this.hitNormal=0,this.hitNormalDx=0,this.hitNormalDy=0,this.hitX=0,this.hitY=0,this.distance=0,this.normalX=1,this.normalY=0,this.reflectionX=1,this.reflectionY=0}DidCollide(){return this.hitFraction<1+PADDING}Reset(){this.hitFraction=NO_HIT}Set(t,i,s,h){return this.x1=t,this.y1=i,this.x2=s,this.y2=h,this.dx=s-t,this.dy=h-i,this.rect.set(t,i,s,h),this.rect.normalize(),this.hitFraction=NO_HIT,this.hitUid=null,this.hitNormal=0,this.hitNormalDx=0,this.hitNormalDy=0,this.hitX=0,this.hitY=0,this.distance=0,this.normalX=1,this.normalY=0,this.reflectionX=1,this.reflectionY=0,this}Complete(){if(!1!==this.DidCollide()){const t=this.dx*this.hitFraction,i=this.dy*this.hitFraction,s=C3.hypot2DFast(t,i),h=t/s,e=i/s,n=(this.distance=s-PADDING,this.hitX=this.x1+h*this.distance,this.hitY=this.y1+e*this.distance,this.hitNormal=Math.atan2(this.hitNormalDy,this.hitNormalDx)+Math.PI/2,this.normalX=Math.cos(this.hitNormal),this.normalY=Math.sin(this.hitNormal),h*this.normalX+e*this.normalY);if(this.reflectionX=h-2*this.normalX*n,this.reflectionY=e-2*this.normalY*n,0<n){const a=Math.PI;this.hitNormal=C3.clampAngle(this.hitNormal+a),this.normalX=-this.normalX,this.normalY=-this.normalY}}}TestInstanceSegment(t,i,s,h,e){const n=C3.rayIntersect(this.x1,this.y1,this.x2,this.y2,i,s,h,e);0<=n&&n<this.hitFraction&&(this.hitFraction=n,this.hitUid=t.GetUID(),this.hitNormalDx=i-h,this.hitNormalDy=s-e)}TestInstanceRect(t,i,s,h){const e=i+h.getLeft(),n=i+h.getRight(),a=s+h.getTop(),o=s+h.getBottom();this.TestInstanceSegment(t,e,a,n,a),this.TestInstanceSegment(t,n,a,n,o),this.TestInstanceSegment(t,n,o,e,o),this.TestInstanceSegment(t,e,o,e,a)}TestInstanceQuad(t,i){const s=i.getTlx(),h=i.getTly(),e=i.getTrx(),n=i.getTry(),a=i.getBrx(),o=i.getBry(),r=i.getBlx(),l=i.getBly();this.TestInstanceSegment(t,s,h,e,n),this.TestInstanceSegment(t,e,n,a,o),this.TestInstanceSegment(t,a,o,r,l),this.TestInstanceSegment(t,r,l,s,h)}TestInstancePoly(s,h,e,t){const n=t.pointsArr();for(let t=0,i=n.length;t<i;t+=2){const a=(t+2)%i,o=n[t]+h,r=n[t+1]+e,l=n[a]+h,c=n[1+a]+e;this.TestInstanceSegment(s,o,r,l,c)}}}; } // canvasManager.js { const C3=self.C3,VALID_FULLSCREEN_MODES=new Set(["off","crop","scale-inner","scale-outer","letterbox-scale","letterbox-integer-scale"]),VALID_FULLSCREEN_SCALING_QUALITIES=new Set(["high","low"]),glMatrix=self.glMatrix,mat4=glMatrix.mat4,vec3=glMatrix.vec3,tempProjection=mat4.create(),PERCENTTEXT_WIDTH=300,PERCENTTEXT_HEIGHT=200,PROGRESSBAR_WIDTH=120,PROGRESSBAR_HEIGHT=8,tempQuad=C3.New(C3.Quad),tempRect=C3.New(C3.Rect),SPLASH_MIN_DISPLAY_TIME=3e3,SPLASH_AFTER_FADEOUT_WAIT_TIME=200,SPLASH_FADE_DURATION=300;C3.CanvasManager=class extends C3.DefendedBase{constructor(e){super(),this._runtime=e,this._canvasLayers=[],this._isWebGPUEnabled=!1,this._webglRenderer=null,this._webgpuRenderer=null,this._iRenderer=null,this._gpuPreference="high-performance",this._isLimitedToWebGL1=!1,this._multitexturingMode="auto",this._windowInnerWidth=0,this._windowInnerHeight=0,this._cssDisplayMode="",this._canvasCssWidth=0,this._canvasCssHeight=0,this._canvasDeviceWidth=0,this._canvasDeviceHeight=0,this._canvasCssOffsetX=0,this._canvasCssOffsetY=0,this._zAxisScale="normalized",this._initFieldOfView=0,this._zNear=1,this._zFar=1e4,this._enableMipmaps=!0,this._textureAnisotropy=0,this._drawWidth=0,this._drawHeight=0,this._fullscreenMode="letterbox-scale",this._documentFullscreenMode="letterbox-scale",this._deviceTransformOffX=0,this._deviceTransformOffY=0,this._defaultProjectionMatrix=mat4.create(),this._wantFullscreenScalingQuality="high",this._fullscreenScalingQuality=this._wantFullscreenScalingQuality,this._isDocumentFullscreen=!1,this._availableAdditionalRenderTargets=[],this._usedAdditionalRenderTargets=new Set,this._shaderData=self["C3_Shaders"],this._effectChainManager=C3.New(C3.Gfx.EffectChainManager,{getDrawSize:()=>[this.GetDrawWidth(),this.GetDrawHeight()],getRenderTarget:()=>this.GetEffectCompositorRenderTarget(),releaseRenderTarget:e=>this.ReleaseEffectCompositorRenderTarget(e),getTime:()=>this.GetRuntime().GetGameTime(),redraw:()=>this.GetRuntime().UpdateRender()}),this._gpuTimeStartFrame=0,this._gpuTimeEndFrame=0,this._gpuLastUtilisation=NaN,this._gpuFrameTimingsBuffer=null,this._layersGpuProfile=new Map,this._gpuCurUtilisation=NaN,this._webgpuFrameTimings=new Map,this._snapshotFormat="",this._snapshotQuality=1,this._snapshotArea=C3.New(C3.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 a=this.GetRenderer();if(!a)throw new Error("failed to acquire a renderer - check WebGL or WebGPU is supported");a.SetHasMajorPerformanceCaveat(i),this._webgpuRenderer&&(this._webgpuRenderer.ondevicelost=()=>this._OnWebGPUDeviceLost(),this._webgpuRenderer.ondevicerestored=()=>this._OnWebGPUDeviceRestored()),"normalized"===this._zAxisScale?a.SetZAxisScaleNormalized():(a.SetZAxisScaleRegular(),a.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=C3.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=C3.New(C3.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=C3.New(C3.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=C3.Gfx.WebGPUShaderProgram.GetDefaultVertexShaderSource();e.push(this._webgpuRenderer.CreateShaderProgram(Object.assign({vertexSrc:i,name:t},s)))}await Promise.all(e)}}async _InitWebGL(){if(this._shaderData){const t=[];for(const[s,i]of Object.entries(this._shaderData)){let e;if(i.glslWebGL2&&2<=this._webglRenderer.GetWebGLVersionNumber())i.src=i.glslWebGL2,e=C3.Gfx.WebGLShaderProgram.GetDefaultVertexShaderSource_WebGL2();else{if(!i.glsl)throw new Error(`shader '${s}' does not support WebGL 1`);i.src=i.glsl,e=C3.Gfx.WebGLShaderProgram.GetDefaultVertexShaderSource()}t.push(this._webglRenderer.CreateShaderProgram(Object.assign({vertexSrc:e,name:s},i)))}await Promise.all(t),this._webglRenderer.ResetLastProgram(),this._webglRenderer.SetTextureFillMode()}this._webglRenderer.SupportsGPUProfiling()&&(this._gpuFrameTimingsBuffer=C3.New(C3.Gfx.WebGLQueryResultBuffer,this._webglRenderer))}async _InitRenderer(){this._webgpuRenderer?await this._InitWebGPU():this._webglRenderer&&await this._InitWebGL();const e=this.GetRenderer();e.SetMipmapsEnabled(this._enableMipmaps),e.SupportsGPUProfiling()&&(this._gpuLastUtilisation=0);for(const t of this._runtime._GetAllEffectLists()){for(const s of t.GetAllEffectTypes())s._InitRenderer(e);t._InitRenderer(e),t.UpdateActiveEffects()}this._iRenderer=new self.IRenderer(this._runtime,e)}Release(){this._runtime=null,this._webglRenderer=null,this._canvasLayers.length=0}IsInWorker(){return this._runtime.IsInWorker()}_OnWindowResize(e){const t=this._runtime;if(!t.IsExportToVideo()){const s=e["devicePixelRatio"],i=(this.IsInWorker()&&(self.devicePixelRatio=s),t._SetDevicePixelRatio(s),this._isDocumentFullscreen=!!e["isFullscreen"],this._cssDisplayMode=e["cssDisplayMode"],this.SetSize(e["innerWidth"],e["innerHeight"]),t.UpdateRender(),new C3.Event("window-resize")),a=(i.data=e,t.Dispatcher().dispatchEventAndWaitAsyncSequential(i),new C3.Event("resize"));a.cssWidth=this.GetCssWidth(),a.cssHeight=this.GetCssHeight(),a.deviceWidth=this.GetDeviceWidth(),a.deviceHeight=this.GetDeviceHeight(),t.DispatchUserScriptEvent(a),t.IsDebug()&&(t.HitBreakpoint()||self.C3Debugger.IsDebuggerPaused())&&t.Render()}}_OnFullscreenChange(e){this._isDocumentFullscreen=!!e["isFullscreen"],this.SetSize(e["innerWidth"],e["innerHeight"],!0),this._runtime.UpdateRender()}_OnFullscreenError(e){this._isDocumentFullscreen=!!e["isFullscreen"],this.SetSize(e["innerWidth"],e["innerHeight"],!0),this._runtime.UpdateRender()}SetSize(e,t,s=!1){if(e=Math.floor(e),t=Math.floor(t),e<=0||t<=0)throw new Error("invalid size");if(this._windowInnerWidth!==e||this._windowInnerHeight!==t||s){this._windowInnerWidth=e,this._windowInnerHeight=t;const i=this.GetCurrentFullscreenMode();"letterbox-scale"===i?this._CalculateLetterboxScale(e,t):"letterbox-integer-scale"===i?this._CalculateLetterboxIntegerScale(e,t):"off"===i?this._CalculateFixedSizeCanvas(e,t):this._CalculateFullsizeCanvas(e,t),this._UpdateFullscreenScalingQuality(i);for(const{canvas:n}of this._canvasLayers)n.width=this._canvasDeviceWidth,n.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 a=this.GetRenderer();a.SetSize(this._canvasDeviceWidth,this._canvasDeviceHeight,!0);for(const h of this._availableAdditionalRenderTargets)a.DeleteRenderTarget(h);C3.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(),a=this._runtime.GetOriginalViewportHeight(),r=i/a,n=e/t;if(r<n){const h=t*r;this._canvasCssWidth=Math.round(h),this._canvasCssHeight=t,this._canvasCssOffsetX=Math.floor((e-this._canvasCssWidth)/2),this._canvasCssOffsetY=0}else{const o=e/r;this._canvasCssWidth=e,this._canvasCssHeight=Math.round(o),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,a)}_CalculateLetterboxIntegerScale(e,t){const s=this._runtime.GetDevicePixelRatio(),i=(1!==s&&(e+=1,t+=1),this._runtime.GetOriginalViewportWidth()),a=this._runtime.GetOriginalViewportHeight(),r=i/a,n=e/t;let h;if(r<n){const o=t*r;h=o*s/i}else{const l=e/r;h=l*s/a}1<h?h=Math.floor(h):h<1&&(h=1/Math.ceil(1/h)),this._canvasDeviceWidth=Math.round(i*h),this._canvasDeviceHeight=Math.round(a*h),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,a)}_CalculateFullsizeCanvas(e,t){const s=this._runtime.GetDevicePixelRatio(),i=(this._canvasCssWidth=e,this._canvasCssHeight=t,this._canvasDeviceWidth=Math.round(this._canvasCssWidth*s),this._canvasDeviceHeight=Math.round(this._canvasCssHeight*s),this._canvasCssOffsetX=0,this._canvasCssOffsetY=0,this.GetDisplayScale());this._runtime.SetViewportSize(this._canvasCssWidth/i,this._canvasCssHeight/i)}_CalculateFixedSizeCanvas(e,t){const s=this._runtime.GetDevicePixelRatio();this._canvasCssWidth=this._runtime.GetViewportWidth(),this._canvasCssHeight=this._runtime.GetViewportHeight(),this._canvasDeviceWidth=Math.round(this._canvasCssWidth*s),this._canvasDeviceHeight=Math.round(this._canvasCssHeight*s),this.IsDocumentFullscreen()?(this._canvasCssOffsetX=Math.floor((e-this._canvasCssWidth)/2),this._canvasCssOffsetY=Math.floor((t-this._canvasCssHeight)/2)):(this._canvasCssOffsetX=0,this._canvasCssOffsetY=0),this._runtime.SetViewportSize(this._runtime.GetViewportWidth(),this._runtime.GetViewportHeight())}_UpdateFullscreenScalingQuality(s){if("high"===this._wantFullscreenScalingQuality)this._drawWidth=this._canvasDeviceWidth,this._drawHeight=this._canvasDeviceHeight,this._fullscreenScalingQuality="high";else{let e,t;if(t="off"===this.GetCurrentFullscreenMode()?(e=this._runtime.GetViewportWidth(),this._runtime.GetViewportHeight()):(e=this._runtime.GetOriginalViewportWidth(),this._runtime.GetOriginalViewportHeight()),this._canvasDeviceWidth<e||this._canvasDeviceHeight<t)this._drawWidth=this._canvasDeviceWidth,this._drawHeight=this._canvasDeviceHeight,this._fullscreenScalingQuality="high";else if(this._drawWidth=e,this._drawHeight=t,this._fullscreenScalingQuality="low","scale-inner"===s){const i=e/t,a=this._windowInnerWidth/this._windowInnerHeight;a<i?this._drawWidth=this._drawHeight*a:i<a&&(this._drawHeight=this._drawWidth/a)}else if("scale-outer"===s){const r=e/t,n=this._windowInnerWidth/this._windowInnerHeight;r<n?this._drawWidth=this._drawHeight*n:n<r&&(this._drawHeight=this._drawWidth/n)}}}GetRuntime(){return this._runtime}GetMainCanvas(){return this._canvasLayers[0].canvas}GetEffectChainManager(){return this._effectChainManager}IsDocumentFullscreen(){return this._isDocumentFullscreen}GetCssDisplayMode(){return this._cssDisplayMode}SetFullscreenMode(e){if(!VALID_FULLSCREEN_MODES.has(e))throw new Error("invalid fullscreen mode");this._fullscreenMode=e;const t=this._runtime.GetLayoutManager();t.SetAllLayerProjectionChanged(),t.SetAllLayerMVChanged()}GetFullscreenMode(){return this._fullscreenMode}SetDocumentFullscreenMode(e){if(!VALID_FULLSCREEN_MODES.has(e))throw new Error("invalid fullscreen mode");this._documentFullscreenMode=e;const t=this._runtime.GetLayoutManager();t.SetAllLayerProjectionChanged(),t.SetAllLayerMVChanged()}GetDocumentFullscreenMode(){return this._documentFullscreenMode}GetCurrentFullscreenMode(){return this.IsDocumentFullscreen()?this.GetDocumentFullscreenMode():this.GetFullscreenMode()}SetFullscreenScalingQuality(e){if(!VALID_FULLSCREEN_SCALING_QUALITIES.has(e))throw new Error("invalid fullscreen scaling quality");this._wantFullscreenScalingQuality=e,this._runtime.GetLayoutManager().SetAllLayerProjectionChanged()}GetSetFullscreenScalingQuality(){return this._wantFullscreenScalingQuality}GetCurrentFullscreenScalingQuality(){return this._fullscreenScalingQuality}static _FullscreenModeNumberToString(e){switch(e){case 0:return"off";case 1:return"crop";case 2:return"scale-inner";case 3:return"scale-outer";case 4:return"letterbox-scale";case 5:return"letterbox-integer-scale";default:throw new Error("invalid fullscreen mode")}}GetLastWidth(){return this._windowInnerWidth}GetLastHeight(){return this._windowInnerHeight}GetDrawWidth(){return this._drawWidth}GetDrawHeight(){return this._drawHeight}SetMipmapsEnabled(e){this._enableMipmaps=!!e}_SetTextureAnisotropy(e){this._textureAnisotropy=e}GetTextureAnisotropy(){return this._textureAnisotropy}IsRendererContextLost(){return this.GetRenderer().IsContextLost()}_OnWebGLContextLost(e){console.log("[Construct] WebGL context lost"),e.preventDefault(),this._availableAdditionalRenderTargets=[],this._usedAdditionalRenderTargets.clear(),this._effectChainManager.OnContextLost(),this._webglRenderer.OnContextLost(),this._runtime._OnRendererContextLost()}_OnWebGPUDeviceLost(){console.log("[Construct] WebGPU device lost"),this._availableAdditionalRenderTargets=[],this._usedAdditionalRenderTargets.clear(),this._effectChainManager.OnContextLost(),this._runtime._OnRendererContextLost()}async _OnWebGLContextRestored(e){await this._webglRenderer.OnContextRestored(),await this._InitRenderer(),await this._runtime._OnRendererContextRestored(),console.log("[Construct] WebGL context restored")}async _OnWebGPUDeviceRestored(){await this._InitRenderer(),await this._runtime._OnRendererContextRestored(),console.log("[Construct] WebGPU device restored")}GetWebGLRenderer(){return this._webglRenderer}GetWebGPURenderer(){return this._webgpuRenderer}GetRenderer(){return this._webgpuRenderer||this._webglRenderer}GetIRenderer(){return this._iRenderer}GetRendererString(){let e="";return e=this._runtime.GetWebGPURenderer()?"webgpu":"webgl"+this._runtime.GetWebGLRenderer().GetWebGLVersionNumber(),this._runtime.GetRenderer().HasMajorPerformanceCaveat()&&(e+="-software"),e}GetRendererDetailString(){return this._runtime.GetWebGPURenderer()?this._runtime.GetWebGPURenderer().GetAdapterInfoString():this._runtime.GetWebGLRenderer().GetUnmaskedRenderer()}GetRenderScale(){return"low"===this._fullscreenScalingQuality?1/this._runtime.GetDevicePixelRatio():this.GetDisplayScale()}GetDisplayScale(){const e=this.GetCurrentFullscreenMode();if("off"===e||"crop"===e)return 1;const t=this._runtime.GetOriginalViewportWidth(),s=this._runtime.GetOriginalViewportHeight(),i=t/s,a=this._canvasDeviceWidth/this._canvasDeviceHeight;return"scale-inner"!==e&&i<a||"scale-inner"===e&&a<i?this._canvasCssHeight/s:this._canvasCssWidth/t}GetEffectLayerScaleParam(){return"low"===this.GetCurrentFullscreenScalingQuality()?1:this.GetDisplayScale()}GetEffectDevicePixelRatioParam(){return"low"===this.GetCurrentFullscreenScalingQuality()?1:this._runtime.GetDevicePixelRatio()}SetDeviceTransformOffset(e,t){this._deviceTransformOffX=e,this._deviceTransformOffY=t}SetDeviceTransform(t,s,i,e=!0){s=s||this._drawWidth,i=i||this._drawHeight;const a=s/2+this._deviceTransformOffX,r=i/2+this._deviceTransformOffY;if(e){let e=this.GetDefaultProjectionMatrix();s===this._drawWidth&&i===this._drawHeight||(t.CalculatePerspectiveMatrix(tempProjection,s/i),e=tempProjection),t.SetProjectionMatrix(e)}const n=t.CalculateLookAtModelView2(a,r,t.GetDefaultCameraZ(i),a,r,0,i);t.SetModelViewMatrix(n)}SetCssTransform(e,t=!0){const s=this.GetCssWidth(),i=this.GetCssHeight(),a=s/2,r=i/2,n=(t&&e.SetProjectionMatrix(this.GetDefaultProjectionMatrix()),e.CalculateLookAtModelView2(a,r,e.GetDefaultCameraZ(i),a,r,0,i));e.SetModelViewMatrix(n)}GetDeviceWidth(){return this._canvasDeviceWidth}GetDeviceHeight(){return this._canvasDeviceHeight}GetCssWidth(){return this._canvasCssWidth}GetCssHeight(){return this._canvasCssHeight}GetCanvasClientX(){return this._canvasCssOffsetX}GetCanvasClientY(){return this._canvasCssOffsetY}GetHTMLLayerCount(){return this._canvasLayers.length}_CanUseImageBitmapRenderingContext(){return"undefined"!=typeof OffscreenCanvas&&this.GetMainCanvas()instanceof OffscreenCanvas&&("Chromium"!==C3.Platform.BrowserEngine||124<=C3.Platform.BrowserVersionNumber)}async SetHTMLLayerCount(t,s=!1){if(t<1)throw new Error("invalid HTML layer count");if(this._canvasLayers.length!==t){const i=this._runtime.GetLayoutManager().GetMainRunningLayout(),a={"count":t,"layersDomState":i._GetRootLayers().filter(e=>e.IsHTMLElementsLayer()).map(e=>e._GetHTMLLayerDOMState()),"immediate":s,"marginLeft":this._canvasCssOffsetX,"marginTop":this._canvasCssOffsetY,"styleWidth":this._canvasCssWidth,"styleHeight":this._canvasCssHeight};let e;if(e=this.IsInWorker()?await this._runtime.PostComponentMessageToDOMAsync("canvas","set-html-layer-count",a):self["c3_runtimeInterface"]["_OnSetHTMLLayerCount"](a),t<this._canvasLayers.length)this._canvasLayers.length=t;else for(const r of e["addedCanvases"]){r.width=this._canvasDeviceWidth,r.height=this._canvasDeviceHeight;const n=this._CanUseImageBitmapRenderingContext()?"bitmaprenderer":"2d",h=r.getContext(n);if(!h)throw new Error(`failed to acquire '${n}' canvas context`);this._canvasLayers.push({canvas:r,ctx:h})}this._runtime.UpdateRender()}}BlitMainCanvasToHTMLLayerCanvas(e){if(!(e>=this._canvasLayers.length)){const t=this.GetMainCanvas(),s=this._canvasLayers[e].ctx;this._CanUseImageBitmapRenderingContext()?s["transferFromImageBitmap"](t["transferToImageBitmap"]()):(s.globalCompositeOperation="copy",s.drawImage(t,0,0))}}GetAdditionalRenderTarget(t){t.depth=this._runtime.Uses3DFeatures();const e=this._availableAdditionalRenderTargets,s=e.findIndex(e=>e.IsCompatibleWithOptions(t));let i;return-1!==s?(i=e[s],e.splice(s,1)):i=this.GetRenderer().CreateRenderTarget(t),this._usedAdditionalRenderTargets.add(i),i}ReleaseAdditionalRenderTarget(e){if(!this._usedAdditionalRenderTargets.has(e))throw new Error("render target not in use");this._usedAdditionalRenderTargets.delete(e),this._availableAdditionalRenderTargets.push(e)}GetEffectCompositorRenderTarget(){const e={sampling:this._runtime.GetSampling()};return"low"===this.GetCurrentFullscreenScalingQuality()&&(e.width=this.GetDrawWidth(),e.height=this.GetDrawHeight()),this.GetAdditionalRenderTarget(e)}ReleaseEffectCompositorRenderTarget(e){this.ReleaseAdditionalRenderTarget(e)}*activeLayersGpuProfiles(){for(const e of this._runtime.GetLayoutManager().runningLayouts())for(const t of e.GetLayers()){const s=this._layersGpuProfile.get(t);s&&(yield s)}}GetLayerTimingsBuffer(e){if(!this.GetRenderer().SupportsGPUProfiling())return null;let t=this._layersGpuProfile.get(e);return t||(t={layer:e,name:e.GetName(),timingsBuffer:C3.New(C3.Gfx.WebGLQueryResultBuffer,this._webglRenderer),curUtilisation:0,lastTotalUtilisation:0,lastSelfUtilisation:0},this._layersGpuProfile.set(e,t)),t.timingsBuffer}_Update1sFrameRange(){const e=this.GetRenderer();if(e.SupportsGPUProfiling()&&0===this._gpuTimeEndFrame){this._gpuTimeEndFrame=e.GetFrameNumber(),this._gpuCurUtilisation=NaN;for(const t of this.activeLayersGpuProfiles())t.curUtilisation=NaN}}_UpdateTick(){this._webglRenderer&&this._webglRenderer.SupportsGPUProfiling()&&this._UpdateTick_WebGL(),this._webgpuRenderer&&this._webgpuRenderer.SupportsGPUProfiling()&&this._UpdateTick_WebGPU()}_UpdateTick_WebGL(){if(isNaN(this._gpuCurUtilisation)&&(this._gpuCurUtilisation=this._gpuFrameTimingsBuffer.GetFrameRangeResultSum(this._gpuTimeStartFrame,this._gpuTimeEndFrame),!isNaN(this._gpuCurUtilisation))){if(this._runtime.IsDebug())for(const e of this.activeLayersGpuProfiles())if(e.curUtilisation=e.timingsBuffer.GetFrameRangeResultSum(this._gpuTimeStartFrame,this._gpuTimeEndFrame),isNaN(e.curUtilisation))return;if(this._gpuFrameTimingsBuffer.DeleteAllBeforeFrameNumber(this._gpuTimeEndFrame),this._gpuLastUtilisation=Math.min(this._gpuCurUtilisation,1),this._runtime.IsDebug()){const s=new Map;for(const a of this.activeLayersGpuProfiles())a.timingsBuffer.DeleteAllBeforeFrameNumber(this._gpuTimeEndFrame),a.lastTotalUtilisation=Math.min(a.curUtilisation,1),s.set(a.layer,a.lastTotalUtilisation);for(const r of this.activeLayersGpuProfiles()){const n=r.layer,h=s.get(n)||0,o=h-n.GetSubLayers().reduce((e,t)=>e+(s.get(t)||0),0);r.lastSelfUtilisation=C3.clamp(o,0,1)}const t=this._runtime.GetMainRunningLayout(),i=this._gpuLastUtilisation-t._GetRootLayers().reduce((e,t)=>e+(s.get(t)||0),0);self.C3Debugger.UpdateGPUProfile(C3.clamp(i,0,1),this._gpuLastUtilisation,[...this.activeLayersGpuProfiles()])}this._gpuTimeStartFrame=this._gpuTimeEndFrame,this._gpuTimeEndFrame=0}}GetGPUFrameTimingsBuffer(){return this._gpuFrameTimingsBuffer}_UpdateTick_WebGPU(){if(0!==this._gpuTimeEndFrame){for(let e=this._gpuTimeStartFrame;e<this._gpuTimeEndFrame;++e){const s=this._webgpuFrameTimings.get(e);if(s&&!s.HasResult())return}const e=this._runtime.GetMainRunningLayout(),a=C3.MakeFilledArray(e.GetLayerCount()+1,0);let t=0;for(let e=this._gpuTimeStartFrame;e<this._gpuTimeEndFrame;++e){const r=this._webgpuFrameTimings.get(e);if(r){const n=r.GetResult();let s=BigInt(0),i=BigInt(0);const h=BigInt(0);for(let e=0,t=Math.min(a.length,n.length/2);e<t;++e){const c=n[2*e],_=n[2*e+1],d=(c!==h&&(s===h||c<s)&&(s=c),_>i&&(i=_),_-c),u=Number(d)/1e9;a[e]+=u}const o=i-s,l=Number(o)/1e9;t+=l}}if(this._gpuLastUtilisation=C3.clamp(t,0,1),this._runtime.IsDebug()){const i=e.GetLayers(),g=new Map;for(let e=0,t=Math.min(i.length,a.length-1);e<t;++e){const S=a[e+1];g.set(i[e],S)}const m=[],p=new Map;for(const[C,R]of g){const w=[...C.selfAndAllSubLayers()].reduce((e,t)=>e+(g.get(t)||0),0);p.set(C,w),m.push({name:C.GetName(),lastSelfUtilisation:C3.clamp(R,0,1),lastTotalUtilisation:C3.clamp(w,0,1)})}const f=this._gpuLastUtilisation-e._GetRootLayers().reduce((e,t)=>e+(p.get(t)||0),0);self.C3Debugger.UpdateGPUProfile(C3.clamp(f,0,1),this._gpuLastUtilisation,m)}for(let e=this._gpuTimeStartFrame;e<this._gpuTimeEndFrame;++e)this._webgpuFrameTimings.delete(e);this._gpuTimeStartFrame=this._gpuTimeEndFrame,this._gpuTimeEndFrame=0}}_AddWebGPUFrameTiming(e){this._webgpuFrameTimings.set(this._webgpuRenderer.GetFrameNumber(),e)}GetGPUUtilisation(){return this._gpuLastUtilisation}SnapshotCanvas(e,t,s,i,a,r){return this._snapshotFormat=e,this._snapshotQuality=t,this._snapshotArea.setWH(s,i,a,r),this._snapshotPromise||(this._snapshotPromise=new Promise(e=>{this._snapshotResolve=e})),this._snapshotPromise}_MaybeTakeSnapshot(){if(this._snapshotFormat){let e=this.GetMainCanvas();const i=this._snapshotArea,a=C3.clamp(Math.floor(i.getLeft()),0,e.width),r=C3.clamp(Math.floor(i.getTop()),0,e.height);let t=i.width(),s=(t=0===t?e.width-a:C3.clamp(Math.floor(t),0,e.width-a),i.height());if(s=0===s?e.height-r:C3.clamp(Math.floor(s),0,e.height-r),(0!==a||0!==r||t!==e.width||s!==e.height)&&0<t&&0<s){const n=C3.CreateCanvas(t,s),h=n.getContext("2d");h.drawImage(e,a,r,t,s,0,0,t,s),e=n}C3.CanvasToBlob(e,this._snapshotFormat,this._snapshotQuality).then(e=>{this._snapshotUrl&&URL.revokeObjectURL(this._snapshotUrl),this._snapshotUrl=URL.createObjectURL(e),this._snapshotPromise=null,this._snapshotResolve(this._snapshotUrl)}),this._snapshotFormat="",this._snapshotQuality=1}}GetCanvasSnapshotUrl(){return this._snapshotUrl}SetIsPastingToDrawingCanvas(e){e?this._isPastingToDrawingCanvas++:this._isPastingToDrawingCanvas--}IsPastingToDrawingCanvas(){return 0<this._isPastingToDrawingCanvas}InitLoadingScreen(e){const t=this.GetRenderer();if(2===e)this._percentText=C3.New(C3.Gfx.RendererText,this.GetRenderer()),this._percentText.SetFontName("Arial"),this._percentText.SetFontSize(16),this._percentText.SetHorizontalAlignment("center"),this._percentText.SetVerticalAlignment("center"),this._percentText.SetSize(PERCENTTEXT_WIDTH,PERCENTTEXT_HEIGHT);else if(0===e){const s=this._runtime.GetLoadingLogoAsset();s&&s.LoadStaticTexture(t).catch(e=>console.warn("[C3 runtime] Failed to create texture for loading logo: ",e))}else 4===e&&(this._LoadSvgSplashImage("splash-images/splash-logo.svg").then(e=>{"done"===this._splashState?t.DeleteTexture(e):this._splashTextures.logo=e}).catch(e=>console.warn("Failed to load splash image: ",e)),this._LoadBitmapSplashImage("splash-images/splash-poweredby-512.png").then(e=>{"done"===this._splashState?t.DeleteTexture(e):this._splashTextures.powered=e}).catch(e=>console.warn("Failed to load splash image: ",e)),this._LoadBitmapSplashImage("splash-images/splash-website-512.png").then(e=>{"done"===this._splashState?t.DeleteTexture(e):this._splashTextures.website=e}).catch(e=>console.warn("Failed to load splash image: ",e)))}async _LoadSvgSplashImage(e){e=new URL(e,this._runtime.GetRuntimeBaseURL()).toString();const t=await C3.FetchBlob(e),s=await this._runtime.RasterSvgImage(t,2048,2048);return this.GetRenderer().CreateStaticTextureAsync(s,{mipMapQuality:"high"})}async _LoadBitmapSplashImage(e){e=new URL(e,this._runtime.GetRuntimeBaseURL()).toString();const t=await C3.FetchBlob(e);return this.GetRenderer().CreateStaticTextureAsync(t,{mipMapQuality:"high"})}HideCordovaSplashScreen(){this._runtime.PostComponentMessageToDOM("runtime","hide-cordova-splash")}StartLoadingScreen(){this._loaderStartTime=Date.now(),this._runtime.Dispatcher().addEventListener("loadingprogress",this._loadingprogress_handler),this._rafId=requestAnimationFrame(()=>this._DrawLoadingScreen());const e=this._runtime.GetLoaderStyle();3!==e&&this.HideCordovaSplashScreen()}async EndLoadingScreen(){const e=this.GetRenderer(),t=(this._loadingProgress=1,this._runtime.GetLoaderStyle());4===t&&await this._splashDonePromise,this._splashDoneResolve=null,this._splashDonePromise=null,-1!==this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=-1),this._runtime.Dispatcher().removeEventListener("loadingprogress",this._loadingprogress_handler),this._loadingprogress_handler=null,this._percentText&&(this._percentText.Release(),this._percentText=null),this._runtime.ReleaseLoadingLogoAsset(),e.Start(),this._splashTextures.logo&&(e.DeleteTexture(this._splashTextures.logo),this._splashTextures.logo=null),this._splashTextures.powered&&(e.DeleteTexture(this._splashTextures.powered),this._splashTextures.powered=null),this._splashTextures.website&&(e.DeleteTexture(this._splashTextures.website),this._splashTextures.website=null),e.ClearRgba(0,0,0,0),e.Finish(),this._splashState="done",this._gpuTimeStartFrame=e.GetFrameNumber(),3===t&&this.HideCordovaSplashScreen()}_DrawLoadingScreen(){if(-1!==this._rafId){const e=this.GetRenderer(),t=(e.Start(),this._rafId=-1,this._runtime.GetAssetManager().HasHadErrorLoading()),s=this._runtime.GetLoaderStyle();if(3!==s&&(this.SetCssTransform(e),e.ClearRgba(0,0,0,0),e.ResetColor(),e.SetTextureFillMode(),e.SetTexture(null)),0===s)this._DrawProgressBarAndLogoLoadingScreen(t);else if(1===s)this._DrawProgressBarLoadingScreen(t,PROGRESSBAR_WIDTH,0);else if(2===s)this._DrawPercentTextLoadingScreen(t);else if(3===s)C3.noop();else{if(4!==s)throw new Error("invalid loader style");this._DrawSplashLoadingScreen(t)}e.Finish(),this._rafId=requestAnimationFrame(()=>this._DrawLoadingScreen())}}_DrawPercentTextLoadingScreen(e){e?this._percentText.SetColorRgb(1,0,0):this._percentText.SetColorRgb(.6,.6,.6),this._percentText.SetText(Math.round(100*this._loadingProgress)+"%");const t=this._canvasCssWidth/2,s=this._canvasCssHeight/2,i=PERCENTTEXT_WIDTH/2,a=PERCENTTEXT_HEIGHT/2,r=(tempQuad.setRect(t-i,s-a,t+i,s+a),this.GetRenderer());r.SetTexture(this._percentText.GetTexture()),r.Quad3(tempQuad,this._percentText.GetTexRect())}_DrawProgressBarLoadingScreen(e,t,s){const i=this.GetRenderer(),a=PROGRESSBAR_HEIGHT,r=(i.SetColorFillMode(),e?i.SetColorRgba(1,0,0,1):i.SetColorRgba(.118,.565,1,1),this._canvasCssWidth/2),n=this._canvasCssHeight/2,h=t/2,o=a/2;tempRect.setWH(r-h,n-o+s,Math.floor(t*this._loadingProgress),a),i.Rect(tempRect),tempRect.setWH(r-h,n-o+s,t,a),tempRect.offset(-.5,-.5),tempRect.inflate(.5,.5),i.SetColorRgba(0,0,0,1),i.LineRect2(tempRect),tempRect.inflate(1,1),i.SetColorRgba(1,1,1,1),i.LineRect2(tempRect)}_DrawProgressBarAndLogoLoadingScreen(e){const t=this.GetRenderer(),s=this._runtime.GetLoadingLogoAsset();if(s){const i=s.GetTexture();if(i){const a=i.GetWidth(),r=i.GetHeight(),n=this._canvasCssWidth/2,h=this._canvasCssHeight/2,o=a/2,l=r/2;tempQuad.setRect(n-o,h-l,n+o,h+l),t.SetTexture(i),t.Quad(tempQuad),this._DrawProgressBarLoadingScreen(e,a,16+l)}else this._DrawProgressBarLoadingScreen(e,PROGRESSBAR_WIDTH,0)}else this._DrawProgressBarLoadingScreen(e,PROGRESSBAR_WIDTH,0)}_DrawSplashLoadingScreen(e){const t=this.GetRenderer(),s=this._splashTextures.logo,i=this._splashTextures.powered,a=this._splashTextures.website,r=Date.now(),n=(0===this._splashFrameNumber&&(this._loaderStartTime=r),this._runtime.IsPreview()||this._runtime.IsFBInstantAvailable()&&!this._runtime.IsCordova()),h=n?0:SPLASH_AFTER_FADEOUT_WAIT_TIME,o=n?0:SPLASH_MIN_DISPLAY_TIME;let l=1;"fade-in"===this._splashState?l=Math.min((r-this._loaderStartTime)/SPLASH_FADE_DURATION,1):"fade-out"===this._splashState&&(l=Math.max(1-(r-this._splashFadeOutStartTime)/SPLASH_FADE_DURATION,0)),t.SetColorFillMode(),t.SetColorRgba(.231*l,.251*l,.271*l,l),tempRect.set(0,0,this._canvasCssWidth,this._canvasCssHeight),t.Rect(tempRect);const c=Math.ceil(this._canvasCssWidth),_=Math.ceil(this._canvasCssHeight);let d,u;256<this._canvasCssHeight?(t.SetColorRgba(.302*l,.334*l,.365*l,l),d=c,u=Math.max(.005*_,2),tempRect.setWH(0,.8*_-u/2,d,u),t.Rect(tempRect),e?t.SetColorRgba(l,0,0,l):t.SetColorRgba(.161*l,.953*l,.816*l,l),d=c*this._loadingProgress,tempRect.setWH(.5*c-d/2,.8*_-u/2,d,u),t.Rect(tempRect),t.SetColorRgba(l,l,l,l),t.SetTextureFillMode(),i&&(d=1.5*C3.clamp(.22*_,105,.6*c),u=d/8,tempRect.setWH(.5*c-d/2,.2*_-u/2,d,u),t.SetTexture(i),t.Rect(tempRect)),s&&(d=Math.min(.395*_,.95*c),u=d,tempRect.setWH(.5*c-d/2,.485*_-u/2,d,u),t.SetTexture(s),t.Rect(tempRect)),a&&(d=1.5*C3.clamp(.22*_,105,.6*c),u=d/8,tempRect.setWH(.5*c-d/2,.868*_-u/2,d,u),t.SetTexture(a),t.Rect(tempRect))):(t.SetColorRgba(.302*l,.334*l,.365*l,l),d=c,u=Math.max(.005*_,2),tempRect.setWH(0,.85*_-u/2,d,u),t.Rect(tempRect),e?t.SetColorRgba(l,0,0,l):t.SetColorRgba(.161*l,.953*l,.816*l,l),d=c*this._loadingProgress,tempRect.setWH(.5*c-d/2,.85*_-u/2,d,u),t.Rect(tempRect),t.SetColorRgba(l,l,l,l),t.SetTextureFillMode(),s&&(d=.55*_,u=d,tempRect.setWH(.5*c-d/2,.45*_-u/2,d,u),t.SetTexture(s),t.Rect(tempRect))),this._splashFrameNumber++,"fade-in"===this._splashState&&r-this._loaderStartTime>=SPLASH_FADE_DURATION&&2<=this._splashFrameNumber&&(this._splashState="wait",this._splashFadeInFinishTime=r),"wait"===this._splashState&&r-this._splashFadeInFinishTime>=o&&1<=this._loadingProgress&&(this._splashState="fade-out",this._splashFadeOutStartTime=r),("fade-out"===this._splashState&&r-this._splashFadeOutStartTime>=SPLASH_FADE_DURATION+h||n&&1<=this._loadingProgress&&r-this._loaderStartTime<500)&&this._splashDoneResolve()}}; } // runtime.js { const C3=self.C3,C3Debugger=self.C3Debugger,assert=self.assert,ISDKBehaviorInstanceBase=self.ISDKBehaviorInstanceBase,DEFAULT_RUNTIME_OPTS={"messagePort":null,"runtimeBaseUrl":"","headless":!1,"hasDom":!0,"isInWorker":!1,"useAudio":!0,"exportType":""};let ife=!0;C3.Runtime=class extends C3.DefendedBase{constructor(e){e=Object.assign({},DEFAULT_RUNTIME_OPTS,e),super(),this._messagePort=e["messagePort"],this._runtimeBaseUrl=e["runtimeBaseUrl"],this._previewUrl=e["previewUrl"],this._isHeadless=!!e["headless"],this._hasDom=!!e["hasDom"],this._isInWorker=!!e["isInWorker"],ife=e["ife"],this._useAudio=!!e["useAudio"],this._exportType=e["exportType"],this._isNWjs=e["isNWjs"],this._isiOSCordova=!!e["isiOSCordova"],this._isiOSWebView=!!e["isiOSWebView"],this._isWindowsWebView2=!!e["isWindowsWebView2"],this._isAnyWebView2Wrapper=!!e["isAnyWebView2Wrapper"],this._isFBInstantAvailable=!!e["isFBInstantAvailable"],this._isDebug=!("preview"!==this._exportType||!e["isDebug"]),this._breakpointsEnabled=this._isDebug,this._isDebugging=this._isDebug,this._debuggingDisabled=0,this._additionalLoadPromises=[],this._additionalCreatePromises=[],this._isUsingCreatePromises=!1,this._projectName="",this._projectVersion="",this._projectUniqueId="",this._appId="",this._exportTimestamp=0,this._originalViewportWidth=0,this._originalViewportHeight=0,this._devicePixelRatio=self.devicePixelRatio,this._parallaxXorigin=0,this._parallaxYorigin=0,this._viewportWidth=0,this._viewportHeight=0,this._loaderStyle=0,this._usesLoaderLayout=!1,this._isLoading=!0,this._usesAnyBackgroundBlending=!1,this._usesAnyCrossSampling=!1,this._usesAnyDepthSampling=!1,this._loadingLogoAsset=null,this._assetManager=C3.New(C3.AssetManager,this,e),this._layoutManager=C3.New(C3.LayoutManager,this),this._eventSheetManager=C3.New(C3.EventSheetManager,this),this._addonManager=C3.New(C3.AddonManager,this,e["wrapperComponentIds"]),this._collisionEngine=C3.New(C3.CollisionEngine,this),this._timelineManager=C3.New(C3.TimelineManager,this),this._transitionManager=C3.New(C3.TransitionManager,this),this._templateManager=C3.New(C3.TemplateManager,this),this._flowchartManager=C3.New(C3.FlowchartManager,this),this._textIconManager=C3.New(C3.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 C3.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=C3.New(C3.KahanSum),this._gameTimeRaw=C3.New(C3.KahanSum),this._wallTime=C3.New(C3.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=C3.New(C3.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":C3.New(C3.Event,"pretick",!1),"tick":C3.New(C3.Event,"tick",!1),"tick2":C3.New(C3.Event,"tick2",!1),"instancecreate":C3.New(C3.Event,"instancecreate",!1),"instancedestroy":C3.New(C3.Event,"instancedestroy",!1),"beforelayoutchange":C3.New(C3.Event,"beforelayoutchange",!1),"layoutchange":C3.New(C3.Event,"layoutchange",!1)},this._eventObjects["instancecreate"].instance=null,this._eventObjects["instancedestroy"].instance=null,this._userScriptDispatcher=C3.New(C3.Event.Dispatcher),this._userScriptEventObjects=null;const t=(e,t)=>C3.BehaviorInstance.SortByTickSequence(this,e,t);this._behInstsToTick=C3.New(C3.RedBlackSet,t),this._behInstsToPostTick=C3.New(C3.RedBlackSet,t),this._behInstsToTick2=C3.New(C3.RedBlackSet,t),this._jobScheduler=C3.New(C3.JobSchedulerRuntime,this,e["jobScheduler"]),e["canvas"]&&(this._canvasManager=C3.New(C3.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 C3.New(C3.Runtime,e)}Release(){C3.clearArray(this._allObjectClasses),this._objectClassesByName.clear(),this._objectClassesBySid.clear(),this._layoutManager.Release(),this._layoutManager=null,this._eventSheetManager.Release(),this._eventSheetManager=null,this._addonManager.Release(),this._addonManager=null,this._assetManager.Release(),this._assetManager=null,this._collisionEngine.Release(),this._collisionEngine=null,this._timelineManager.Release(),this._timelineManager=null,this._transitionManager.Release(),this._transitionManager=null,this._templateManager.Release(),this._templateManager=null,this._flowchartManager.Release(),this._flowchartManager=null,this._textIconManager.Release(),this._textIconManager=null,this._canvasManager&&(this._canvasManager.Release(),this._canvasManager=null),this._dispatcher.Release(),this._dispatcher=null,this._tickEvent=null}["_OnMessageFromDOM"](e){const t=e["type"];if("event"===t)this._OnEventFromDOM(e);else{if("result"!==t)throw new Error(`unknown message '${t}'`);this._OnResultFromDOM(e)}}_OnEventFromDOM(e){if(this._isReadyToHandleEvents){const t=e["component"],s=e["handler"],i=e["data"],n=e["dispatchOpts"],a=!(!n||!n["dispatchRuntimeEvent"]),r=!(!n||!n["dispatchUserScriptEvent"]),o=e["responseId"];if("runtime"===t){if(a){const l=new C3.Event(s);l.data=i,this._dispatcher.dispatchEventAndWaitAsyncSequential(l)}if(r){const c=new C3.Event(s,!0);for(const[d,_]of Object.entries(i))c[d]=_;this.DispatchUserScriptEvent(c)}}const h=this._domEventHandlers.get(t);if(h){const g=h.get(s);if(g){let e=null;try{e=g(i)}catch(e){return console.error(`Exception in '${t}' handler '${s}':`,e),void(null!==o&&this._PostResultToDOM(o,!1,""+e))}null!==o&&(e&&e.then?e.then(e=>this._PostResultToDOM(o,!0,e)).catch(e=>{console.error(`Rejection from '${t}' handler '${s}':`,e),this._PostResultToDOM(o,!1,""+e)}):this._PostResultToDOM(o,!0,e))}else a||r||console.warn(`[Runtime] No DOM handler '${s}' for component '${t}'`)}else a||r||console.warn(`[Runtime] No DOM event handlers for component '${t}'`)}else this._waitingToHandleEvents.push(e)}_PostResultToDOM(e,t,s){this._messagePort.postMessage({"type":"result","responseId":e,"isOk":t,"result":s})}_OnResultFromDOM(e){const t=e["responseId"],s=e["isOk"],i=e["result"],n=this._pendingResponsePromises.get(t);s?n.resolve(i):n.reject(i),this._pendingResponsePromises.delete(t)}AddDOMComponentMessageHandler(e,t,s){let i=this._domEventHandlers.get(e);if(i||(i=new Map,this._domEventHandlers.set(e,i)),i.has(t))throw new Error(`[Runtime] Component '${e}' already has handler '${t}'`);i.set(t,s)}PostComponentMessageToDOM(e,t,s,i){this._messagePort.postMessage({"type":"event","component":e,"handler":t,"data":s,"responseId":null},i)}PostComponentMessageToDOMAsync(e,t,s,i){const n=this._nextDomResponseId++,a=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),a}SendWrapperExtensionMessage(e,t,s,i=-1){this.PostComponentMessageToDOM("runtime","send-wrapper-extension-message",{"componentId":e,"messageId":t,"params":s,"asyncId":i})}SendWrapperExtensionMessageAsync(e,t,s){const i=this._nextDomResponseId++,n=new Promise((e,t)=>{this._pendingResponsePromises.set(i,{resolve:e,reject:t})});return this.SendWrapperExtensionMessage(e,t,s,i),n}_OnWrapperExtensionMessage(e){if(-1!==e["asyncId"]){const t=e["asyncId"],s=this._pendingResponsePromises.get(t);s.resolve(e["params"]),this._pendingResponsePromises.delete(t)}else this._OnEventFromDOM({"component":"wrapper-extension:"+e["componentId"],"handler":e["messageId"],"data":e["params"],"responseId":null})}AddWrapperExtensionMessageHandler(e,t,s){this.AddDOMComponentMessageHandler("wrapper-extension:"+e,t,s)}HasWrapperComponentId(e){return this._addonManager.HasWrapperComponentId(e)}PostToDebugger(e){if(!this.IsDebug())throw new Error("not in debug mode");this.PostComponentMessageToDOM("runtime","post-to-debugger",e)}async Init(e){C3.CommonACES_SetRuntime(this),this.IsDebug()?await C3Debugger.Init(this):self.C3Debugger&&self.C3Debugger.InitPreview(this);const t=await this._assetManager.FetchJson("data.json");if(await this._LoadDataJson(t),await this._InitialiseCanvas(e),this.IsPreview()||console.info("%cMade with Construct, the game and animation creation tool. Visit: https://www.construct.net","font-weight: bold"),this.GetWebGLRenderer()){const s=this.GetWebGLRenderer();console.info(`[C3 runtime] Hosted in ${this.IsInWorker()?"worker":"DOM"}, rendering with WebGL ${s.GetWebGLVersionNumber()} [${s.GetUnmaskedRenderer()}]`)}else this.GetWebGPURenderer()&&console.info(`[C3 runtime] Hosted in ${this.IsInWorker()?"worker":"DOM"}, rendering with WebGPU [${this.GetWebGPURenderer().GetAdapterInfoString()}]`);this.GetRenderer().HasMajorPerformanceCaveat()&&console.warn("[C3 runtime] The renderer indicates a major performance caveat. Software rendering may be in use. This can result in significantly degraded performance."),this._isReadyToHandleEvents=!0;for(const i of this._waitingToHandleEvents)this._OnEventFromDOM(i);C3.clearArray(this._waitingToHandleEvents),this._canvasManager&&this._canvasManager.StartLoadingScreen();for(const n of e["runOnStartupFunctions"])this._additionalLoadPromises.push(this._RunOnStartupFunction(n));if(await Promise.all([this._assetManager.WaitForAllToLoad(),...this._additionalLoadPromises]),C3.clearArray(this._additionalLoadPromises),!this._assetManager.HasHadErrorLoading())return this._canvasManager&&await this._canvasManager.EndLoadingScreen(),await this._dispatcher.dispatchEventAndWaitAsync(new C3.Event("beforeruntimestart")),await this.Start(),this._messagePort.postMessage({"type":"runtime-ready"}),this;this._canvasManager&&this._canvasManager.HideCordovaSplashScreen()}async _RunOnStartupFunction(e){try{await e(this._iRuntime)}catch(e){console.error("[C3 runtime] Error in runOnStartup function: ",e)}}async _LoadDataJson(e){const t=e["project"],s=(this._projectName=t[0],this._projectVersion=t[16],this._projectUniqueId=t[31],this._appId=t[38],this._exportTimestamp=t[36],t[39]||"loading-logo.png"),i=(this._isPixelRoundingEnabled=!!t[9],this._originalViewportWidth=this._viewportWidth=t[10],this._originalViewportHeight=this._viewportHeight=t[11],this._collisionEngine._InitCollisionCellSize(this._originalViewportWidth,this._originalViewportHeight),this._parallaxXorigin=this._originalViewportWidth/2,this._parallaxYorigin=this._originalViewportHeight/2,this._framerateMode=t[37],this._uses3dFeatures=!!t[40],this._sampling=t[14],this._usesAnyBackgroundBlending=t[15],this._usesAnyCrossSampling=t[42],this._usesAnyDepthSampling=t[17],this._usesLoaderLayout=!!t[18],this._loaderStyle=t[19],this._nextUid=t[21],this._pauseOnBlur=t[22],this._assetManager);if(i._SetFileStructure(t[45]),i._SetAudioFiles(t[7],t[25]),i._SetMediaSubfolder(t[8]),i._SetFontsSubfolder(t[32]),i._SetIconsSubfolder(t[28]),i._SetWebFonts(t[29]),0===this._loaderStyle){let e="";(e="flat"===i.GetFileStructure()?i.GetIconsSubfolder()+s:s)&&(this._loadingLogoAsset=i.LoadImage({url:e}))}this._canvasManager&&(this._canvasManager.SetFullscreenMode(C3.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],a=(n&&await this._LoadExportToVideoData(n),this._InitScriptInterfaces(),this._addonManager.CreateSystemPlugin(),this._objectReferenceTable=self.C3_GetObjectRefTable(),t[2]);for(const l of a[1])this._addonManager.CreateBehavior(l);for(const c of a[0])this._addonManager.CreatePlugin(c);this._objectReferenceTable=self.C3_GetObjectRefTable(),this._LoadJsPropNameTable(),this._addonManager._InitAddonScriptInterfaces();for(const d of t[3]){const _=C3.ObjectClass.Create(this,this._allObjectClasses.length,d);this._allObjectClasses.push(_),this._objectClassesByName.set(_.GetName().toLowerCase(),_),this._objectClassesBySid.set(_.GetSID(),_)}for(const g of t[4]){const u=this._allObjectClasses[g[0]];u._LoadFamily(g)}for(const m of t[27]){const p=m.map(e=>this._allObjectClasses[e]);this._allContainers.push(C3.New(C3.Container,this,p))}this._InitObjectsScriptInterface();for(const f of this._allObjectClasses)f._OnAfterCreate();for(const C of t[5])this._layoutManager.Create(C);const r=t[1];if(r){const S=this._layoutManager.GetLayoutByName(r);S&&this._layoutManager.SetFirstLayout(S)}for(const I of t[35])this._transitionManager.Create(I);for(const v of t[33])this._timelineManager.Create(v);for(const T of t[44])this._templateManager.Create(T);this._templateManager.HasTemplates()||(this._templateManager.Release(),this._templateManager=null);for(const b of t[49])this._flowchartManager.Create(b);this._flowchartManager.HasFlowcharts()||(this._flowchartManager.Release(),this._flowchartManager=null);for(const M of t[6])this._eventSheetManager.Create(M);this._eventSheetManager._PostInit(),this._InitGlobalVariableScriptInterface(),C3.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 t=null;const e=new Promise(e=>t=e);if(this._usesLoaderLayout){for(const n of this._allObjectClasses)n.IsFamily()||n.IsOnLoaderLayout()||!n.IsWorldType()||n.OnCreate();(async()=>{await this._assetManager.WaitForAllToLoad(),await e,this._isLoading=!1,this._OnLoadFinished()})()}else this._isLoading=!1;this._assetManager.SetInitialLoadFinished(),this.IsDebug()&&C3Debugger.RuntimeInit(ife);for(const a of this._layoutManager.GetAllLayouts())a._CreateGlobalNonWorlds();this.IsExportToVideo()&&await this._InitExportToVideo();const s=this._layoutManager.GetFirstLayout(),i=(await s._Load(null,this.GetRenderer()),await s._StartRunning(!0),this._fpsLastTime=performance.now(),t(),this._usesLoaderLayout||this._OnLoadFinished(),await this.PostComponentMessageToDOMAsync("runtime","before-start-ticking"));i["isSuspended"]&&!this.IsExportToVideo()?(this._suspendCount++,this._isPageVisibilitySuspended=!0):this.Tick()}_OnLoadFinished(){this.Trigger(C3.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=C3.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=C3.AddonManager.GetPluginByConstructorFunction(e);return t?t.GetSingleGlobalObjectClass():null}GetAllObjectClasses(){return this._allObjectClasses}*allInstances(){for(const e of this._allObjectClasses)e.IsFamily()||(yield*e.instances())}Dispatcher(){return this._dispatcher}UserScriptDispatcher(){return this._userScriptDispatcher}DispatchUserScriptEvent(e){e.runtime=this.GetIRuntime();const t=this.IsDebug()&&!this._eventSheetManager.IsInEventEngine();t&&C3Debugger.StartMeasuringScriptTime(),this._userScriptDispatcher.dispatchEvent(e),t&&C3Debugger.AddScriptTime()}DispatchUserScriptEventAsyncWait(e){return e.runtime=this.GetIRuntime(),this._userScriptDispatcher.dispatchEventAndWaitAsync(e)}GetOriginalViewportWidth(){return this._originalViewportWidth}GetOriginalViewportHeight(){return this._originalViewportHeight}SetOriginalViewportSize(e,t){if(this._originalViewportWidth!==e||this._originalViewportHeight!==t){this._originalViewportWidth=e,this._originalViewportHeight=t;const s=this.GetLayoutManager();s.SetAllLayerProjectionChanged(),s.SetAllLayerMVChanged()}}GetViewportWidth(){return this._viewportWidth}GetViewportHeight(){return this._viewportHeight}SetViewportSize(e,t){if(this._viewportWidth!==e||this._viewportHeight!==t){this._viewportWidth=e,this._viewportHeight=t;const s=this.GetLayoutManager();s.SetAllLayerProjectionChanged(),s.SetAllLayerMVChanged()}}_SetDevicePixelRatio(e){this.IsExportToVideo()||(this._devicePixelRatio=e)}GetDevicePixelRatio(){return this._devicePixelRatio}GetParallaxXOrigin(){return this._parallaxXorigin}GetParallaxYOrigin(){return this._parallaxYorigin}GetCanvasManager(){return this._canvasManager}GetDrawWidth(){return this._canvasManager?this._canvasManager.GetDrawWidth():this._viewportWidth}GetDrawHeight(){return this._canvasManager?this._canvasManager.GetDrawHeight():this._viewportHeight}GetRenderScale(){return this._canvasManager?this._canvasManager.GetRenderScale():1}GetDisplayScale(){return this._canvasManager?this._canvasManager.GetDisplayScale():1}GetEffectLayerScaleParam(){return this._canvasManager?this._canvasManager.GetEffectLayerScaleParam():1}GetEffectDevicePixelRatioParam(){return this._canvasManager?this._canvasManager.GetEffectDevicePixelRatioParam():1}GetCanvasClientX(){return this._canvasManager?this._canvasManager.GetCanvasClientX():0}GetCanvasClientY(){return this._canvasManager?this._canvasManager.GetCanvasClientY():0}GetCanvasCssWidth(){return this._canvasManager?this._canvasManager.GetCssWidth():0}GetCanvasCssHeight(){return this._canvasManager?this._canvasManager.GetCssHeight():0}GetFullscreenMode(){return this._canvasManager?this._canvasManager.GetFullscreenMode():"off"}GetAdditionalRenderTarget(e){return this._canvasManager?this._canvasManager.GetAdditionalRenderTarget(e):null}ReleaseAdditionalRenderTarget(e){this._canvasManager&&this._canvasManager.ReleaseAdditionalRenderTarget(e)}UsesAnyBackgroundBlending(){return this._usesAnyBackgroundBlending}UsesAnyCrossSampling(){return this._usesAnyCrossSampling}UsesAnyDepthSampling(){return this._usesAnyDepthSampling}GetGPUUtilisation(){return this._canvasManager?this._canvasManager.GetGPUUtilisation():NaN}IsLinearSampling(){return"nearest"!==this.GetSampling()}GetFramerateMode(){return this._framerateMode}_SetFramerateMode(e){this._framerateMode!==e&&(this._framerateMode=e,-1!==this._rafId||-1!==this._ruafId)&&(this._CancelAnimationFrame(),this._RequestAnimationFrame())}GetSampling(){return this._sampling}UsesLoaderLayout(){return this._usesLoaderLayout}GetLoadingLogoAsset(){return this._loadingLogoAsset}ReleaseLoadingLogoAsset(){this._loadingLogoAsset&&(this._loadingLogoAsset.ReleaseTexture(),this._loadingLogoAsset.Release(),this._loadingLogoAsset=null)}GetLayoutManager(){return this._layoutManager}GetMainRunningLayout(){return this._layoutManager.GetMainRunningLayout()}GetTimelineManager(){return this._timelineManager}GetTransitionManager(){return this._transitionManager}GetTemplateManager(){return this._templateManager}GetFlowchartManager(){return this._flowchartManager}GetAssetManager(){return this._assetManager}LoadImage(e){return this._assetManager.LoadImage(e)}CreateInstance(e,t,s,i,n,a){if(a&&this._templateManager){if(e instanceof C3.ObjectClass&&e.IsFamily()){const o=e.GetFamilyMembers(),h=Math.floor(this.Random()*o.length);return this.CreateInstance(o[h],t,s,i,n,a)}const r=this._templateManager.GetTemplateData(e,a);if(r){const l=this.CreateInstanceFromData(r,t,!1,s,i,!1,n,void 0,n);return this._templateManager.MapInstanceToTemplateName(l,a),l}}return this.CreateInstanceFromData(e,t,!1,s,i,!1,n,void 0,n)}CreateInstanceFromData(e,t,s,i,n,a,r,o,h){let l=null,c=null;if(e instanceof C3.ObjectClass){if((c=e).IsFamily()){const I=c.GetFamilyMembers(),v=Math.floor(this.Random()*I.length);c=I[v]}l=c.GetDefaultInstanceData()}else l=e,c=this.GetObjectClassByIndex(l[1]);const d=c.GetPlugin().IsWorldType();if(this._isLoading&&d&&!c.IsOnLoaderLayout())return null;const _=t;d||(t=null);let g;g=s&&!a&&l&&!this._instancesByUid.has(l[2])?l[2]:this._nextUid++;const u=l?l[0]:null,m=C3.New(C3.Instance,{runtime:this,objectType:c,layer:t,worldData:u,instVarData:l?l[3]:null,uid:g,tags:l?l[6]:null});this._instancesByUid.set(g,m);let p=null,f=(d&&(p=m.GetWorldInfo(),void 0!==i&&void 0!==n&&(p.SetX(i),p.SetY(n)),c._SetAnyCollisionCellChanged(!0)),t&&(h||t._AddInstance(m,!0),t.GetLayout().MaybeLoadTexturesFor(c)),this._objectCount++,!0);if(o){const T=o.GetObjectClass();if(T.IsInContainer()&&c.IsInContainer()){const b=c.GetContainer(),M=T.GetContainer();b===M&&(f=!1)}}if(c.IsInContainer()&&!s&&!a&&f){const y=new Set;for(const G of c.GetContainer().objectTypes())if(G!==c){const w=this._MaybeGetChildInstanceForObjectTypeData(G,p,y);if(w){const D=this.CreateInstanceFromData(w,_,!1,p?p.GetX():i,p?p.GetY():n,!0,!1,void 0,h);m._AddSibling(D)}else{const B=this.CreateInstanceFromData(G,_,!1,p?p.GetX():i,p?p.GetY():n,!0,!1,void 0,h);m._AddSibling(B)}}for(const P of m.siblings()){P._AddSibling(m);for(const R of m.siblings())P!==R&&P._AddSibling(R)}}if(d&&!s&&r&&this._CreateChildInstancesFromData(m,u,p,t,i,n,h),c.IsInContainer()&&!s&&!a&&r)for(const L of m.siblings()){const E=L.GetWorldInfo();if(E){const j=L.GetPlugin(),k=L.GetObjectClass().GetDefaultInstanceData()[0];j.IsWorldType()?this._CreateChildInstancesFromData(L,k,E,t,E.GetX(),E.GetY(),h):this._CreateChildInstancesFromData(L,k,E,t,void 0,void 0,h)}}if(!a&&r){void 0===i&&(i=u[0]),void 0===n&&(n=u[1]);const A=p.GetTopParent(),W=i-p.GetX()+A.GetX(),N=n-p.GetY()+A.GetY();A.SetXY(W,N)}c._SetIIDsStale();const F=l?C3.cloneArray(l[5]):null,x=l?l[4].map(e=>C3.cloneArray(e)):null,C=d&&u&&u[13];if(C&&m._SetHasTilemap(),m._CreateSdkInstance(F,x),C){const O=u[13];m.GetSdkInstance().LoadTilemapData(O[2],O[0],O[1])}this._instancesPendingCreate.push(m),this._hasPendingInstances=!0,this.IsDebug()&&C3Debugger.InstanceCreated(m);const S=this._eventObjects["instancecreate"];return S.instance=m,this._dispatcher.dispatchEvent(S),m}_GetInstanceData(e){const t=e[0],s=e[1],i=e[2],n=e[6];if(n)return n;const a=this._layoutManager.GetLayoutBySID(t),r=a.GetLayer(s);return r.GetInitialInstanceData(i)}_MaybeGetChildInstanceForObjectTypeData(e,t,s){const i=t?.GetSceneGraphChildrenExportData()??[];for(const n of i){const a=this._GetInstanceData(n),r=!!n[4],o=this.GetObjectClassByIndex(a[1]);if(!s.has(a)&&(e===o&&r))return s.add(a),a}}_CreateChildInstancesFromData(t,e,s,i,n,a,r){const o=s.GetSceneGraphZIndexExportData(),h=s.GetSceneGraphChildrenExportData();if(t.GetWorldInfo().SetSceneGraphZIndex(o),h){void 0===n&&(n=e[0]),void 0===a&&(a=e[1]);const l=new Set,c=e[0],d=e[1];for(const _ of h){const g=_[0],u=_[1],m=_[2],p=_[3],f=!!_[4],C=_[5],S=_[6];let e;if(S)e=S;else{const b=this._layoutManager.GetLayoutBySID(g),M=b.GetLayer(u);e=M.GetInitialInstanceData(m)}const I=this.GetObjectClassByIndex(e[1]),v=t.HasSibling(I),T=l.has(I);if(v&&!T&&f){const y=t.GetSibling(I),G=(y.GetWorldInfo().Init(e[0]),n+e[0][0]-c),w=a+e[0][1]-d;y.GetWorldInfo().SetXY(G,w),y.GetWorldInfo().SetSceneGraphZIndex(C),t.AddChild(y,{transformX:!!(p>>0&1),transformY:!!(p>>1&1),transformWidth:!!(p>>2&1),transformHeight:!!(p>>3&1),transformAngle:!!(p>>4&1),destroyWithParent:!!(p>>5&1),transformZElevation:!!(p>>6&1),transformOpacity:!!(p>>7&1),transformVisibility:!!(p>>8&1)}),l.add(I)}else{const D=n+e[0][0]-c,P=a+e[0][1]-d,R=this.CreateInstanceFromData(e,i,!1,D,P,!1,!0,t,r);R.GetWorldInfo().SetSceneGraphZIndex(C),t.AddChild(R,{transformX:!!(p>>0&1),transformY:!!(p>>1&1),transformWidth:!!(p>>2&1),transformHeight:!!(p>>3&1),transformAngle:!!(p>>4&1),destroyWithParent:!!(p>>5&1),transformZElevation:!!(p>>6&1),transformOpacity:!!(p>>7&1),transformVisibility:!!(p>>8&1)})}}}}DestroyInstance(t){if(!this._instancesPendingRelease.has(t)){const s=t.GetObjectClass();let e=this._instancesPendingDestroy.get(s);if(e){if(e.has(t))return;e.add(t)}else(e=new Set).add(t),this._instancesPendingDestroy.set(s,e);if(this.IsDebug()&&C3Debugger.InstanceDestroyed(t),t._MarkDestroyed(),this._hasPendingInstances=!0,t.IsInContainer())for(const e of t.siblings())this.DestroyInstance(e);for(const i of t.children())i.GetDestroyWithParent()&&this.DestroyInstance(i);if(!this._layoutManager.IsEndingLayout()&&!this._isLoadingState){const n=this.GetEventSheetManager();n.BlockFlushingInstances(!0),t._TriggerOnDestroyed(),n.BlockFlushingInstances(!1)}t._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()}C3.clearArray(this._instancesPendingCreate)}_FlushInstancesPendingDestroy(){this._dispatcher.SetDelayRemoveEventsEnabled(!0);for(const[e,t]of this._instancesPendingDestroy.entries())this._FlushInstancesPendingDestroyForObjectClass(e,t),t.clear();this._instancesPendingDestroy.clear(),this._dispatcher.SetDelayRemoveEventsEnabled(!1)}_FlushInstancesPendingDestroyForObjectClass(e,t){for(const s of t){const i=this._eventObjects["instancedestroy"],n=(i.instance=s,this._dispatcher.dispatchEvent(i),this._instancesByUid.delete(s.GetUID()),this._instanceTimes.delete(s),s.GetWorldInfo());n&&(n._RemoveFromCollisionCells(),n._RemoveFromRenderCells(),n._MarkDestroyed()),this._instancesPendingRelease.add(s),this._objectCount--}C3.arrayRemoveAllInSet(e.GetInstances(),t),e._SetIIDsStale(),this._instancesPendingReleaseAffectedObjectClasses.add(e);for(const a of e.GetFamilies())C3.arrayRemoveAllInSet(a.GetInstances(),t),a._SetIIDsStale(),this._instancesPendingReleaseAffectedObjectClasses.add(a);if(e.GetPlugin().IsWorldType()){const r=new Set([...t].map(e=>e.GetWorldInfo().GetLayer()));for(const o of r)o._RemoveAllInstancesInSet(t)}}_GetInstancesPendingCreate(){return this._instancesPendingCreate}*instancesPendingCreateForObjectClass(e){for(const t of this._GetInstancesPendingCreate())e.IsFamily()?t.GetObjectClass().BelongsToFamily(e)&&(yield t):t.GetObjectClass()===e&&(yield t)}_GetNewUID(){return this._nextUid++}_MapInstanceByUID(e,t){this._instancesByUid.set(e,t)}_SetAutoSuspendEnabled(e){this._isAutoSuspendEnabled!==(e=!!e)&&(this._isAutoSuspendEnabled=!!e,this._isAutoSuspendEnabled)&&this._isPageVisibilitySuspended&&(this.SetSuspended(!1),this._isPageVisibilitySuspended=!1)}_IsAutoSuspendEnabled(){return this._isAutoSuspendEnabled}_OnRendererContextLost(){this._dispatcher.dispatchEvent(C3.New(C3.Event,"renderercontextlost")),this.SetSuspended(!0);for(const t of this._allObjectClasses)!t.IsFamily()&&t.HasLoadedTextures()&&t.ReleaseTextures();const e=this.GetMainRunningLayout();e&&e._OnRendererContextLost(),C3.ImageInfo.OnRendererContextLost(),C3.ImageAsset.OnRendererContextLost()}async _OnRendererContextRestored(){await this.GetMainRunningLayout()._Load(null,this.GetRenderer()),this._dispatcher.dispatchEvent(C3.New(C3.Event,"renderercontextrestored")),this.SetSuspended(!1),this.UpdateRender()}_OnVisibilityChange(e){if(this._isAutoSuspendEnabled){const t=e["hidden"];this.SetSuspended(t),(this._isPageVisibilitySuspended=t)||this.UpdateRender()}}_OnWindowBlur(e){!this.IsPreview()||!this._pauseOnBlur||C3.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=C3.RequestUnlimitedAnimationFrame(e.tickOnly)),-1===this._rafId&&(this._rafId=self.requestAnimationFrame(e.renderOnly))):-1===this._ruafId&&(this._ruafId=C3.RequestUnlimitedAnimationFrame(e.normal))}_CancelAnimationFrame(){-1!==this._rafId&&(self.cancelAnimationFrame(this._rafId),this._rafId=-1),-1!==this._ruafId&&(C3.CancelUnlimitedAnimationFrame(this._ruafId),this._ruafId=-1)}IsSuspended(){return 0<this._suspendCount}SetSuspended(e){if(!this.IsExportToVideo()){const t=this.IsSuspended(),s=(this._suspendCount+=e?1:-1,this._suspendCount<0&&(this._suspendCount=0),this.IsSuspended());if(!t&&s)console.log("[Construct] Suspending"),this._CancelAnimationFrame(),this._dispatcher.dispatchEvent(C3.New(C3.Event,"suspend")),this.Trigger(C3.Plugins.System.Cnds.OnSuspend,null,null);else if(t&&!s){console.log("[Construct] Resuming");const i=performance.now();this._lastTickTime=i,this._fpsLastTime=i,this._fpsFrameCount=0,this._fps=0,this._tpsTickCount=0,this._tps=0,this._mainThreadTime=0,this._mainThreadTimeCounter=0,this._dispatcher.dispatchEvent(C3.New(C3.Event,"resume")),this.Trigger(C3.Plugins.System.Cnds.OnResume,null,null),this.HitBreakpoint()||this.Tick(i)}}}_AddBehInstToTick(e){this._behInstsToTick.Add(e)}_AddBehInstToPostTick(e){this._behInstsToPostTick.Add(e)}_AddBehInstToTick2(e){this._behInstsToTick2.Add(e)}_RemoveBehInstToTick(e){this._behInstsToTick.Remove(e)}_RemoveBehInstToPostTick(e){this._behInstsToPostTick.Remove(e)}_RemoveBehInstToTick2(e){this._behInstsToTick2.Remove(e)}_CallBehaviorTickMethod(e,t){const s=t?performance.now():0;let i;return e instanceof ISDKBehaviorInstanceBase?(i=e._tick(),t&&C3Debugger.AddIndividualBehaviorTickTime(e.behavior,performance.now()-s)):(i=e.Tick(),t&&C3Debugger.AddIndividualBehaviorTickTime(e.GetBehavior(),performance.now()-s)),i}_BehaviorTick(){const e=this.IsDebug();this._behInstsToTick.SetQueueingEnabled(!0);for(const t of this._behInstsToTick)this._CallBehaviorTickMethod(t,e);this._behInstsToTick.SetQueueingEnabled(!1)}_CallBehaviorPostTickMethod(e,t){const s=t?performance.now():0;let i;return e instanceof ISDKBehaviorInstanceBase?(i=e._postTick(),t&&C3Debugger.AddIndividualBehaviorTickTime(e.behavior,performance.now()-s)):(i=e.PostTick(),t&&C3Debugger.AddIndividualBehaviorTickTime(e.GetBehavior(),performance.now()-s)),i}_BehaviorPostTick(){const e=this.IsDebug();this._behInstsToPostTick.SetQueueingEnabled(!0);for(const t of this._behInstsToPostTick)this._CallBehaviorPostTickMethod(t,e);this._behInstsToPostTick.SetQueueingEnabled(!1)}_CallBehaviorTick2Method(e,t){const s=t?performance.now():0;let i;return e instanceof ISDKBehaviorInstanceBase?(i=e._tick2(),t&&C3Debugger.AddIndividualBehaviorTickTime(e.behavior,performance.now()-s)):(i=e.Tick2(),t&&C3Debugger.AddIndividualBehaviorTickTime(e.GetBehavior(),performance.now()-s)),i}_BehaviorTick2(){const e=this.IsDebug();this._behInstsToTick2.SetQueueingEnabled(!0);for(const t of this._behInstsToTick2)this._CallBehaviorTick2Method(t,e);this._behInstsToTick2.SetQueueingEnabled(!1)}*_DebugBehaviorTick(){const e=this.IsDebug();this._behInstsToTick.SetQueueingEnabled(!0);for(const t of this._behInstsToTick){const s=this._CallBehaviorTickMethod(t,e);C3.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);C3.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);C3.IsIterator(s)&&(yield*s)}this._behInstsToTick2.SetQueueingEnabled(!1)}async Tick(t,e,s){this._hasStartedTicking=!0;const i="background-wake"===s,n="background-wake"!==s&&"skip-render"!==s,a=this.GetLayoutManager(),r=this.GetCanvasManager();if(this._hasStarted&&(!this.IsSuspended()||e||i)){const o=performance.now(),h=(this._isInTick=!0,this._MeasureDt(t||0),this._tpsTickCount++,this._ReleasePendingInstances(),this.Step_BeforePreTick()),l=(this.IsDebugging()&&await h,this._dispatcher.dispatchEventAndWait_AsyncOptional(this._eventObjects["pretick"])),c=(l instanceof Promise&&await l,this.DispatchUserScriptEvent(this._userScriptEventObjects["pretick"]),this.Step_AfterPreTick()),d=(this.IsDebugging()&&await c,this._NeedsHandleSaveOrLoad()&&await this._HandleSaveOrLoad(),a.IsPendingChangeMainLayout()&&await this._MaybeChangeLayout(),this.Step_RunEventsEtc()),_=(this.IsDebugging()&&await d,a.GetMainRunningLayout()),g=_._GetPendingSetHTMLLayerCount();let e=!1;if(-1!==g&&(_._ResetPendingHTMLLayerCount(),r.GetHTMLLayerCount()!==g)){const u=this.GetCanvasManager().SetHTMLLayerCount(g);this.IsInWorker()&&(e=!0,await u)}this.PostComponentMessageToDOM("canvas","update-html-layer-dom-state",{"layersDomState":_._GetRootLayers().filter(e=>e.IsHTMLElementsLayer()).map(e=>e._GetHTMLLayerDOMState())}),n&&this.Render(),e&&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&&C3Debugger.StartMeasuringTime(),this.IsDebugging()?await e.DebugRunScheduledWaits():e.RunScheduledWaits(),t&&C3Debugger.AddEventsTime(),this.PopCurrentLayout(),e.BlockFlushingInstances(!1),this.FlushPendingInstances(),e.BlockFlushingInstances(!0)}async Step_AfterPreTick(){const e=this._eventSheetManager,t=this.IsDebug(),s=this.IsDebugging(),i=this._dispatcher,n=this._eventObjects,a=this._userScriptEventObjects;t&&C3Debugger.StartMeasuringTime(),s?await this.DebugIterateAndBreak(this._DebugBehaviorTick()):this._BehaviorTick(),s?await this.DebugIterateAndBreak(this._DebugBehaviorPostTick()):this._BehaviorPostTick(),t&&C3Debugger.AddBehaviorTotalTickTime(),t&&C3Debugger.StartMeasuringTime(),s?await this.DebugFireGeneratorEventAndBreak(n["tick"]):i.dispatchEvent(n["tick"]),t&&C3Debugger.AddPluginTotalTickTime(),e.BlockFlushingInstances(!1),this.DispatchUserScriptEvent(a["tick"])}async Step_RunEventsEtc(){const e=this._eventSheetManager,t=this._dispatcher,s=this._eventObjects,i=this._userScriptEventObjects,n=this.IsDebug(),a=this.IsDebugging();n&&C3Debugger.StartMeasuringTime(),a?await e.DebugRunEvents(this._layoutManager):e.RunEvents(this._layoutManager),n&&C3Debugger.AddEventsTime(),this._collisionEngine.ClearRegisteredCollisions(),this._ReleasePendingInstances(),this._isLayoutFirstTick=!1,e.BlockFlushingInstances(!0),n&&C3Debugger.StartMeasuringTime(),a?await this.DebugIterateAndBreak(this._DebugBehaviorTick2()):this._BehaviorTick2(),n&&C3Debugger.AddBehaviorTotalTickTime(),n&&C3Debugger.StartMeasuringTime(),a?await this.DebugFireGeneratorEventAndBreak(s["tick2"]):t.dispatchEvent(s["tick2"]),n&&C3Debugger.AddPluginTotalTickTime(),e.BlockFlushingInstances(!1),this.DispatchUserScriptEvent(i["tick2"]),a&&await e.RunQueuedDebugTriggersAsync()}_ReleasePendingInstances(){if(0!==this._instancesPendingRelease.size){const e=this._dispatcher;e.SetDelayRemoveEventsEnabled(!0);for(const t of this._instancesPendingReleaseAffectedObjectClasses)t.GetSolStack().RemoveInstances(this._instancesPendingRelease);this._instancesPendingReleaseAffectedObjectClasses.clear(),this._eventSheetManager._OnInstancesReleased(this._instancesPendingRelease);for(const s of this._instancesPendingRelease)s.Release();this._instancesPendingRelease.clear(),e.SetDelayRemoveEventsEnabled(!1)}}async _MaybeChangeLayout(){const e=this.GetLayoutManager();let t=0;for(;e.IsPendingChangeMainLayout()&&t++<10;)await this._DoChangeLayout(e.GetPendingChangeMainLayout())}_MeasureDt(e){let t=0;if(this.IsExportToVideo())t=1/this.GetExportVideoFramerate(),this._dtRaw=t,this._dt1=t;else if(0!==this._lastTickTime){const s=Math.max(e-this._lastTickTime,0);.5<(t=s/1e3)&&(t=0),this._dtRaw=t,this._dt1=C3.clamp(t,this._minDt,this._maxDt)}this._lastTickTime=e,this._dt=this._dt1*this._timeScale,this._gameTime.Add(this._dt),this._gameTimeRaw.Add(t*this._timeScale),this._wallTime.Add(this._dt1);for(const[i,n]of this._instanceTimes)n.Add(this._dt1*i.GetTimeScale());this._canvasManager&&this._canvasManager._UpdateTick(),1e3<=e-this._fpsLastTime&&(this._fpsLastTime+=1e3,1e3<=e-this._fpsLastTime&&(this._fpsLastTime=e),this._fps=this._fpsFrameCount,this._fpsFrameCount=0,this._tps=this._tpsTickCount,this._tpsTickCount=0,this._mainThreadTime=Math.min(this._mainThreadTimeCounter/1e3,1),this._mainThreadTimeCounter=0,this._canvasManager&&this._canvasManager._Update1sFrameRange(),this._collisionEngine._Update1sStats(),this.IsDebug())&&C3Debugger.Update1sPerfStats()}_SetTrackingInstanceTime(e,t){if(t){if(!this._instanceTimes.has(e)){const s=C3.New(C3.KahanSum);s.Copy(this._gameTime),this._instanceTimes.set(e,s)}}else this._instanceTimes.delete(e)}_GetInstanceGameTime(e){const t=this._instanceTimes.get(e);return t?t.Get():this.GetGameTime()}async _DoChangeLayout(e){const t=this._dispatcher,s=this.GetLayoutManager(),i=s.GetMainRunningLayout();await i._StopRunning(),i._Unload(e,this.GetRenderer()),i===e&&this._eventSheetManager.ClearAllScheduledWaits(),this._collisionEngine.ClearRegisteredCollisions(),this._ReleasePendingInstances(),t.dispatchEvent(this._eventObjects["beforelayoutchange"]),C3.Asyncify.SetHighThroughputMode(!0),await e._Load(i,this.GetRenderer()),C3.Asyncify.SetHighThroughputMode(!1),await e._StartRunning(!1),t.dispatchEvent(this._eventObjects["layoutchange"]),this.UpdateRender(),this._isLayoutFirstTick=!0,this.FlushPendingInstances(),this._ExportToVideoAddKeyframe()}UpdateRender(){this._needRender=!0}GetWebGLRenderer(){return this._canvasManager?this._canvasManager.GetWebGLRenderer():null}GetWebGPURenderer(){return this._canvasManager?this._canvasManager.GetWebGPURenderer():null}GetRenderer(){return this._canvasManager?this._canvasManager.GetRenderer():null}Render(){const s=this._canvasManager;if(s&&!s.IsRendererContextLost()){const i=this.GetRenderer(),e=i.SupportsGPUProfiling(),n=e&&i.IsWebGL(),a=e&&i.IsWebGPU();if(n&&i.CheckForQueryResults(),this._needRender||this.IsExportToVideo()){const r=this._layoutManager.GetMainRunningLayout(),o=(this._fpsFrameCount++,i.Start(),this.IsDebug());o&&C3Debugger.StartMeasuringTime(),this._needRender=!1;let e=null,t=(n&&(e=s.GetGPUFrameTimingsBuffer().AddTimeElapsedQuery(),i.StartQuery(e)),null);a&&(t=i.StartFrameTiming(2*(1+r.GetLayerCount())),i.StartMeasuringRenderPassTime(0,1)),this.Uses3DFeatures()&&"low"===s.GetCurrentFullscreenScalingQuality()?i.SetFixedSizeDepthBuffer(s.GetDrawWidth(),s.GetDrawHeight()):i.SetAutoSizeDepthBuffer(),this._Render(this.GetRenderer(),r),e&&i.EndQuery(e),a&&(i.StopMeasuringRenderPassTime(),this._canvasManager._AddWebGPUFrameTiming(t)),i.Finish(),o&&(C3Debugger.AddDrawCallsTime(),C3Debugger.UpdateInspectHighlight()),s&&s._MaybeTakeSnapshot()}else i.IncrementFrameNumber()}}_NeedsHTMLLayerCompositing(e){return"low"===this.GetCanvasManager().GetCurrentFullscreenScalingQuality()||e.IsWebGL()&&(this.UsesAnyBackgroundBlending()||this.Uses3DFeatures())}_Render(t,s){t.SetTextureFillMode(),t.SetAlphaBlend(),t.SetColorRgba(1,1,1,1),t.SetRenderTarget(null),t.SetTexture(null),t.SetDepthEnabled(this.Uses3DFeatures()),this._NeedsHTMLLayerCompositing(t)&&s._MaybeStartDrawToOwnTexture(t);const i=s.GetHTMLLayerCount();for(let e=1;e<i;++e)s.DrawForHTMLLayerIndex(t,e),t.IsWebGPU()&&t.Restart();this._NeedsHTMLLayerCompositing(t)||s._MaybeStartDrawToOwnTexture(t),s.DrawMain(t)}Trigger(e,t,s){if(!this._hasStarted)return!1;const i=!this._isInTick&&!this._eventSheetManager.IsInTrigger();let n=0;i&&(n=performance.now());const a=this.IsDebug(),r=(a&&this.SetDebuggingEnabled(!1),this._eventSheetManager._Trigger(this._layoutManager,e,t,s));if(i){const o=performance.now()-n;this._mainThreadTimeCounter+=o,a&&C3Debugger.AddTriggersTime(o)}return a&&this.SetDebuggingEnabled(!0),r}DebugTrigger(e,t,s){if(!this.IsDebugging())return this.Trigger(e,t,s);if(this.HitBreakpoint())throw new Error("called DebugTrigger() while stopped on breakpoint");if(this._isInTick||this._eventSheetManager.IsInTrigger())return this._eventSheetManager._DebugTrigger(this._layoutManager,e,t,s);throw new Error("called DebugTrigger() outside of event code - use TriggerAsync() instead")}async TriggerAsync(e,t,s){if(!this.IsDebugging())return this.Trigger(e,t,s);if(!this._hasStarted)return!1;if(this.HitBreakpoint())return this._eventSheetManager.QueueDebugTrigger(e,t,s);if(!this.GetMainRunningLayout())return this._eventSheetManager.QueueTrigger(e,t,s);const i=performance.now(),n=this._eventSheetManager._DebugTrigger(this._layoutManager,e,t,s);let a=n.next();for(;!a.done;)await this.DebugBreak(a.value),a=n.next();return this.IsSuspended()||this._eventSheetManager.IsInTrigger()||(await this._eventSheetManager.RunQueuedDebugTriggersAsync(),this._hasStartedTicking&&!this._isInTick&&this._RequestAnimationFrame()),this._mainThreadTimeCounter+=performance.now()-i,a.value}FastTrigger(e,t,s){const i=this.IsDebug(),n=(i&&this.SetDebuggingEnabled(!1),this._eventSheetManager._FastTrigger(this._layoutManager,e,t,s));return i&&this.SetDebuggingEnabled(!0),n}DebugFastTrigger(e,t,s){return this._eventSheetManager._DebugFastTrigger(this._layoutManager,e,t,s)}ScheduleTriggers(e){return this._scheduleTriggersThrottle.Add(e)}PushCurrentLayout(e){this._currentLayoutStack.push(e)}PopCurrentLayout(){if(!this._currentLayoutStack.length)throw new Error("layout stack empty");this._currentLayoutStack.pop()}GetCurrentLayout(){return this._currentLayoutStack.length?this._currentLayoutStack.at(-1):this.GetMainRunningLayout()}GetDt(e){return e&&-1!==e.GetTimeScale()?this._dt1*e.GetTimeScale():this._dt}_GetDtFast(){return this._dt}GetDt1(){return this._dt1}GetDtRaw(){return this._dtRaw}GetTimeScale(){return this._timeScale}SetTimeScale(e){(isNaN(e)||e<0)&&(e=0),this._timeScale=e}SetMinDt(e){this._minDt=Math.max(e,0)}GetMinDt(){return this._minDt}SetMaxDt(e){this._maxDt=Math.max(e,0)}GetMaxDt(){return this._maxDt}GetFramesPerSecond(){return this._fps}GetTicksPerSecond(){return this._tps}GetMainThreadTime(){return this._mainThreadTime}GetStartTime(){return this._startTime}GetGameTime(){return this._gameTime.Get()}GetGameTimeRaw(){return this._gameTimeRaw.Get()}GetWallTime(){return this._wallTime.Get()}GetTickCount(){return this._tickCount}GetTickCountNoSave(){return this._tickCountNoSave}GetObjectCount(){return this._objectCount}GetProjectName(){return this._projectName}GetProjectVersion(){return this._projectVersion}GetProjectUniqueId(){return this._projectUniqueId}GetAppId(){return this._appId}GetExportTimestamp(){return this._exportTimestamp}GetInstanceByUID(e){if(this._isLoadingState)throw new Error("cannot call while loading state - wait until afterload event");return this._instancesByUid.get(e)||null}_RefreshUidMap(){this._instancesByUid.clear();for(const e of this._allObjectClasses)if(!e.IsFamily())for(const t of e.GetInstances())this._instancesByUid.set(t.GetUID(),t)}IsPreview(){return"preview"===this._exportType}IsDebug(){return this._isDebug}GetExportType(){return this._exportType}IsNWjs(){return"nwjs"===this.GetExportType()||this._isNWjs}IsCordova(){return"cordova"===this._exportType}IsAndroidWebView(){return"Android"===C3.Platform.OS&&("cordova"===this._exportType||"playable-ad-single-file"===this._exportType||"playable-ad-zip"===this._exportType||"instant-games"===this._exportType)}IsiOSCordova(){return this._isiOSCordova}IsiOSWebView(){return this._isiOSWebView}IsWindowsWebView2(){return this._isWindowsWebView2}IsAnyWebView2Wrapper(){return this._isAnyWebView2Wrapper}GetCollisionEngine(){return this._collisionEngine}GetSolidBehavior(){return this._addonManager.GetSolidBehavior()}GetJumpthruBehavior(){return this._addonManager.GetJumpthruBehavior()}Uses3DFeatures(){return this._uses3dFeatures}GetZScaleFactor(){return this.GetRenderer().GetZAxisScaleFactor(this.GetViewportHeight())}GetDefaultCameraZ(e){return this.GetRenderer().GetDefaultCameraZ(e||this.GetViewportHeight())}IsLayoutFirstTick(){return this._isLayoutFirstTick}SetPixelRoundingEnabled(e){this._isPixelRoundingEnabled!==(e=!!e)&&(this._isPixelRoundingEnabled=e,this.GetLayoutManager().SetAllLayerMVChanged(),this.UpdateRender())}IsPixelRoundingEnabled(){return this._isPixelRoundingEnabled}GetTextIconSet(e){if(!this._iconChangeHandlers.has(e)){const s=()=>this.DeleteTextIconSet(e);this._iconChangeHandlers.set(e,s),e.Dispatcher().addEventListener("animationframeimagechange",s)}const t=this._textIconManager.GetIconSet(e);return t.HasLoaded()||t.LoadContent().then(()=>this.UpdateRender()),t}DeleteTextIconSet(e){this._textIconManager.DeleteIconSet(e)}_GetTextIconSetMeta(e){const t=[];for(const s of e.GetAnimations())for(const i of s.GetFrames()){const n=i.GetImageInfo();t.push({source:i,width:n.GetWidth(),height:n.GetHeight(),tag:i.GetTag()})}return{icons:t}}async _GetTextIconSetContent(e){const t=C3.New(C3.PromiseThrottle),s=[],n=new Map;for(const r of e.GetAnimations())for(const o of r.GetFrames()){const h=o.GetImageInfo().GetImageAsset();n.has(h)||(n.set(h,null),s.push(t.Add(async()=>{const e=await h.LoadToDrawable();n.set(h,e)})))}await Promise.all(s);const i=[];for(const l of e.GetAnimations())for(const c of l.GetFrames())i.push(t.Add(async()=>{const e=c.GetImageInfo(),t=n.get(e.GetImageAsset()),s=await e.ExtractImageToCanvas(t),i=await createImageBitmap(s);return{drawable:i}}));const a=await Promise.all(i);for(const d of n.values())d instanceof ImageBitmap&&d["close"]&&d["close"]();return{icons:a}}SaveToSlot(e){this._saveToSlotName=e,this._saveToJsonString=!1}SaveToJsonString(){this._saveToSlotName="",this._saveToJsonString=!0}LoadFromSlot(e){this._loadFromSlotName=e}LoadFromJsonString(e){this._loadFromJson=e}GetLastSaveJsonString(){return this._lastSaveJson}_NeedsHandleSaveOrLoad(){return!!(this._saveToSlotName||this._saveToJsonString||this._loadFromSlotName||null!==this._loadFromJson)}async _HandleSaveOrLoad(){if(this._saveToSlotName&&(this.FlushPendingInstances(),await this._DoSaveToSlot(this._saveToSlotName),this._ClearSaveOrLoad()),this._loadFromSlotName&&(await this._DoLoadFromSlot(this._loadFromSlotName),this._ClearSaveOrLoad(),this.IsDebug())&&C3Debugger.StepIfPausedInDebugger(),this._saveToJsonString){const e=await this._SaveToJsonString();this._lastSaveJson=e,await this.TriggerAsync(C3.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(C3.Plugins.System.Cnds.OnLoadComplete,null),this._lastSaveJson=""}catch(e){console.error("[Construct] Failed to load state from JSON string: ",e),await this.TriggerAsync(C3.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(C3.Plugins.System.Cnds.OnSaveComplete,null),this._lastSaveJson=""}catch(e){console.error("[Construct] Failed to save state to storage: ",e),await this.TriggerAsync(C3.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(C3.Plugins.System.Cnds.OnLoadComplete,null),this._lastSaveJson=""}catch(e){console.error("[Construct] Failed to load state from storage: ",e),await this.TriggerAsync(C3.Plugins.System.Cnds.OnLoadFailed,null)}}async _SaveToJsonString(){const e={"c3save":!0,"version":1,"rt":{"time":this.GetGameTime(),"timeRaw":this.GetGameTimeRaw(),"walltime":this.GetWallTime(),"timescale":this.GetTimeScale(),"tickcount":this.GetTickCount(),"next_uid":this._nextUid,"running_layout":this.GetMainRunningLayout().GetSID(),"start_time_offset":Date.now()-this._startTime},"types":{},"layouts":{},"events":this._eventSheetManager._SaveToJson(),"timelines":this._timelineManager._SaveToJson(),"user_script_data":null};for(const s of this._allObjectClasses)s.IsFamily()||s.HasNoSaveBehavior()||(e["types"][s.GetSID().toString()]=s._SaveToJson());for(const i of this._layoutManager.GetAllLayouts())e["layouts"][i.GetSID().toString()]=i._SaveToJson();const t=this._CreateUserScriptEvent("save");return t.saveData=null,await this.DispatchUserScriptEventAsyncWait(t),e["user_script_data"]=t.saveData,JSON.stringify(e)}IsLoadingState(){return this._isLoadingState}async _DoLoadFromJsonString(e){const t=this.GetLayoutManager(),s=JSON.parse(e);if(s["c2save"])throw new Error("C2 saves are incompatible with C3 runtime");if(!s["c3save"])throw new Error("not valid C3 save data");if(1<s["version"])throw new Error("C3 save data from future version");this.ClearIntancesNeedingAfterLoad(),this._dispatcher.dispatchEvent(C3.New(C3.Event,"beforeload"));for(const h of this.allInstances()){const l=h.GetObjectClass();l.HasNoSaveBehavior()||h._OnBeforeLoad()}const i=s["rt"],n=(this._gameTime.Set(i["time"]),i.hasOwnProperty("timeRaw")&&this._gameTimeRaw.Set(i["timeRaw"]),this._wallTime.Set(i["walltime"]),this._timeScale=i["timescale"],this._tickCount=i["tickcount"],this._startTime=Date.now()-i["start_time_offset"],i["running_layout"]);let a=!(this._isLoadingState=!0);if(n!==this.GetMainRunningLayout().GetSID()){const c=t.GetLayoutBySID(n);if(!c)return;await this._DoChangeLayout(c),a=!0}for(const[d,_]of Object.entries(s["layouts"])){const g=parseInt(d,10),u=t.GetLayoutBySID(g);u&&u._LoadFromJson(_)}const r=new Set;for(const[m,p]of Object.entries(s["types"])){const f=parseInt(m,10),C=this.GetObjectClassBySID(f);!C||C.IsFamily()||C.HasNoSaveBehavior()||C._LoadFromJson(p,r)}for(const S of this._layoutManager.GetAllLayouts())for(const I of S.allLayers())I._LoadFromJsonAfterInstances();if(this.FlushPendingInstances(),this._RefreshUidMap(),this._isLoadingState=!1,a){for(const v of this.allInstances())v.SetupInitialSceneGraphConnections();for(const[T,b]of Object.entries(s["types"])){const M=parseInt(T,10),y=this.GetObjectClassBySID(M);!y||y.IsFamily()||y.HasNoSaveBehavior()||y._SetupSceneGraphConnectionsOnChangeOfLayout(b)}}this._nextUid=i["next_uid"],this._eventSheetManager._LoadFromJson(s["events"]);for(const G of this._allObjectClasses)if(!G.IsFamily()&&G.IsInContainer())for(const w of G.GetInstances()){const D=w.GetIID();for(const P of G.GetContainer().objectTypes())if(P!==G){const R=P.GetInstances();if(D<0||D>=R.length)throw new Error("missing sibling instance");w._AddSibling(R[D])}}this._timelineManager._LoadFromJson(s["timelines"]),t.SetAllLayerProjectionChanged(),t.SetAllLayerMVChanged();for(const L of r)L._OnCreatedForLoadingSavegame();this.DoAfterLoad(),this._dispatcher.dispatchEvent(C3.New(C3.Event,"afterload")),this.DispatchUserScriptEvent(this._CreateUserScriptEvent("afterload"));for(const[E,k]of Object.entries(s["types"])){const A=parseInt(E,10),O=this.GetObjectClassBySID(A);O&&O._ClearLoadInstancesJson()}const o=this._CreateUserScriptEvent("load");o.saveData=s["user_script_data"],await this.DispatchUserScriptEventAsyncWait(o),this.UpdateRender()}SortOnTmpHierarchyPosition(e,t){return e.GetWorldInfo().GetTmpHierarchyPosition()-t.GetWorldInfo().GetTmpHierarchyPosition()}AddInstanceNeedingAfterLoad(e,t){!e.GetWorldInfo()||this._instancesNeedingAfterLoadMap.has(e)||(this._instancesNeedingAfterLoadMap.set(e,t),this._instancesNeedingAfterLoadArray.push(e))}ClearIntancesNeedingAfterLoad(){this._instancesNeedingAfterLoadMap=new WeakMap,C3.clearArray(this._instancesNeedingAfterLoadArray)}DoAfterLoad(e="full",t=null){this._instancesNeedingAfterLoadArray.sort(this.SortOnTmpHierarchyPosition);for(const s of this._instancesNeedingAfterLoadArray)s._OnAfterLoad(this._instancesNeedingAfterLoadMap.get(s),e,t);for(const i of this._instancesNeedingAfterLoadArray)i._OnAfterLoad2(this._instancesNeedingAfterLoadMap.get(i),e,t);this.ClearIntancesNeedingAfterLoad()}async AddJobWorkerScripts(e){const t=await Promise.all(e.map(async e=>{const t=this.IsCordova()&&this._assetManager.IsFileProtocol();if(t||"playable-ad-single-file"===this.GetExportType()){const s=await this._assetManager.FetchBlob(e);return URL.createObjectURL(s)}return new URL(e,location.href).toString()}));this._jobScheduler.ImportScriptsToJobWorkers(t)}AddJobWorkerBlob(e,t){this._jobScheduler.SendBlobToJobWorkers(e,t)}AddJobWorkerBuffer(e,t){this._jobScheduler.SendBufferToJobWorkers(e,t)}AddJob(e,t,s,i){return this._jobScheduler.AddJob(e,t,s,null,null,i)}BroadcastJob(e,t,s,i){return this._jobScheduler.BroadcastJob(e,t,s,i)}GetMaxNumJobWorkers(){return this._jobScheduler.GetMaxNumWorkers()}InvokeDownload(e,t){this.PostComponentMessageToDOM("runtime","invoke-download",{"url":e,"filename":t})}async RasterSvgImage(e,t,s,i,n,a){if(i=i||t,n=n||s,this.IsInWorker()){const r=await this.PostComponentMessageToDOMAsync("runtime","raster-svg-image",{"blob":e,"imageWidth":t,"imageHeight":s,"surfaceWidth":i,"surfaceHeight":n,"imageBitmapOpts":a});return r["imageBitmap"]}{const o=await self["C3_RasterSvgImageBlob"](e,t,s,i,n);return a?self.createImageBitmap(o,a):o}}async GetSvgImageSize(e){return this.IsInWorker()?this.PostComponentMessageToDOMAsync("runtime","get-svg-image-size",{"blob":e}):self["C3_GetSvgImageSize"](e)}RequestDeviceOrientationEvent(){this._didRequestDeviceOrientationEvent||(this._didRequestDeviceOrientationEvent=!0,this.PostComponentMessageToDOM("runtime","enable-device-orientation"))}RequestDeviceMotionEvent(){this._didRequestDeviceMotionEvent||(this._didRequestDeviceMotionEvent=!0,this.PostComponentMessageToDOM("runtime","enable-device-motion"))}Random(){return this._randomNumberCallback()}SetRandomNumberGeneratorCallback(e){this._randomNumberCallback=e}_GetRemotePreviewStatusInfo(){const e=this.GetRenderer();return{"fps":this.GetFramesPerSecond(),"tps":this.GetTicksPerSecond(),"cpu":this.GetMainThreadTime(),"gpu":this.GetGPUUtilisation(),"layout":this.GetMainRunningLayout()?this.GetMainRunningLayout().GetName():"","renderer":e.IsWebGL()?e.GetUnmaskedRenderer():e.GetAdapterInfoString()}}HitBreakpoint(){return!!this.IsDebug()&&C3Debugger.HitBreakpoint()}DebugBreak(e){return this.IsDebugging()?C3Debugger.DebugBreak(e):Promise.resolve()}DebugBreakNext(){return!!this.IsDebugging()&&C3Debugger.BreakNext()}SetDebugBreakpointsEnabled(e){this._breakpointsEnabled=!!e,this._UpdateDebuggingFlag()}AreDebugBreakpointsEnabled(){return this._breakpointsEnabled}IsDebugging(){return this._isDebugging}SetDebuggingEnabled(e){e?this._debuggingDisabled--:this._debuggingDisabled++,this._UpdateDebuggingFlag()}_UpdateDebuggingFlag(){this._isDebugging=this.IsDebug()&&this._breakpointsEnabled&&0===this._debuggingDisabled}IsCPUProfiling(){return this.IsDebug()&&C3Debugger.IsCPUProfiling()}IsGPUProfiling(){return this.IsDebug()&&this.GetRenderer().SupportsGPUProfiling()&&C3Debugger.IsGPUProfiling()}async DebugIterateAndBreak(e){if(e)for(const t of e)await this.DebugBreak(t)}DebugFireGeneratorEventAndBreak(e){return this.DebugIterateAndBreak(this._dispatcher.dispatchGeneratorEvent(e))}_InvokeFunctionFromJS(e){return this._eventSheetManager._InvokeFunctionFromJS(e["name"],e["params"])}_GetHTMLLayerWrapElement(e){if(this.IsInWorker())throw new Error("not supported in worker mode");return self["c3_runtimeInterface"]["_GetHTMLWrapElement"](e)}GetIRuntime(){return this._iRuntime}_CreateUserScriptEvent(e){const t=C3.New(C3.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 C3.ObjectClass)return t;throw new Error("invalid IObjectClass")}_UnwrapIInstance(e){if(!(e instanceof self.IInstance))throw new TypeError("expected IInstance");const t=this._UnwrapScriptInterface(e);if(t&&t instanceof C3.Instance)return t;throw new Error("invalid IInstance")}_UnwrapIWorldInstance(e){if(!(e instanceof self.IWorldInstance))throw new TypeError("expected IWorldInstance");const t=this._UnwrapScriptInterface(e);if(t&&t instanceof C3.Instance)return t;throw new Error("invalid IInstance")}},self["C3_CreateRuntime"]=C3.Runtime.Create,self["C3_InitRuntime"]=(e,t)=>e.Init(t); } // workers/jobSchedulerRuntime.js { const C3=self.C3;C3.JobSchedulerRuntime=class extends C3.DefendedBase{constructor(r,e){super(),this._runtime=r,this._jobPromises=new Map,this._nextJobId=0,this._inputPort=e["inputPort"],e["outputPort"].onmessage=r=>this._OnJobWorkerMessage(r),this._maxNumWorkers=e["maxNumWorkers"],this._jobWorkerCount=1,this._isCreatingWorker=!1,this._hadErrorCreatingWorker=!1}GetMaxNumWorkers(){return this._maxNumWorkers}ImportScriptsToJobWorkers(r){this._inputPort.postMessage({"type":"_import_scripts","scripts":r})}SendBlobToJobWorkers(r,e){this._inputPort.postMessage({"type":"_send_blob","blob":r,"id":e})}SendBufferToJobWorkers(r,e){this._inputPort.postMessage({"type":"_send_buffer","buffer":r,"id":e},[r])}AddJob(r,e,o,s,t,i){if(o=o||[],"number"==typeof i&&(i=Math.floor(i))<=0)throw new Error("invalid maxWorkerNum");const n=this._nextJobId++,a={"type":r,"isBroadcast":!1,"maxWorkerNum":i,"jobId":n,"params":e,"transferables":o},_=new Promise((r,e)=>{this._jobPromises.set(n,{resolve:r,progress:s,reject:e,cancelled:!1,maxWorkerNum:i})});return t&&t.SetAction(()=>this._CancelJob(n)),this._inputPort.postMessage(a,o),this._MaybeCreateExtraWorker(),_}BroadcastJob(r,e,o,s){if(o=o||[],"number"==typeof s&&(s=Math.floor(s))<=0)throw new Error("invalid maxWorkerNum");const t=this._nextJobId++,i={"type":r,"isBroadcast":!0,"maxWorkerNum":s,"jobId":t,"params":e,"transferables":o};this._inputPort.postMessage(i,o)}_CancelJob(r){const e=this._jobPromises.get(r);e&&(e.cancelled=!0,e.resolve=null,e.progress=null,e.reject=null,this._inputPort.postMessage({"type":"_cancel","jobId":r}))}_OnJobWorkerMessage(r){const e=r.data,o=e["type"],s=e["jobId"];switch(o){case"result":this._OnJobResult(s,e["result"]);break;case"progress":this._OnJobProgress(s,e["progress"]);break;case"error":this._OnJobError(s,e["error"]);break;case"ready":this._OnJobWorkerReady();break;default:throw new Error(`unknown message from worker '${o}'`)}}_OnJobResult(r,e){const o=this._jobPromises.get(r);if(!o)throw new Error("invalid job ID");o.cancelled||o.resolve(e),this._jobPromises.delete(r)}_OnJobProgress(r,e){const o=this._jobPromises.get(r);if(!o)throw new Error("invalid job ID");!o.cancelled&&o.progress&&o.progress(e)}_OnJobError(r,e){const o=this._jobPromises.get(r);if(!o)throw new Error("invalid job ID");o.cancelled||o.reject(e),this._jobPromises.delete(r)}_OnJobWorkerReady(){this._isCreatingWorker&&(this._isCreatingWorker=!1,this._jobWorkerCount++,this._jobWorkerCount<this._maxNumWorkers?this._MaybeCreateExtraWorker():this._inputPort.postMessage({"type":"_no_more_workers"}))}_GetWorkerCountNeededForPendingJobs(){let r=0;const e=[...this._jobPromises.values()].sort((r,e)=>{const o=r.maxWorkerNum||1/0,s=e.maxWorkerNum||1/0;return o-s});for(const o of e){const s=o.maxWorkerNum||1/0;r<s&&r++}return r}async _MaybeCreateExtraWorker(){if(!(this._jobWorkerCount>=this._maxNumWorkers||this._isCreatingWorker||this._hadErrorCreatingWorker||this._GetWorkerCountNeededForPendingJobs()<=this._jobWorkerCount))try{this._isCreatingWorker=!0;const r=await this._runtime.PostComponentMessageToDOMAsync("runtime","create-job-worker");r["outputPort"].onmessage=r=>this._OnJobWorkerMessage(r)}catch(r){this._hadErrorCreatingWorker=!0,this._isCreatingWorker=!1,console.error(`[Construct] Failed to create job worker; stopping creating any more (created ${this._jobWorkerCount} so far)`,r)}}}; } // scripts/shaders.js { self["C3_Shaders"] = {}; } // scripts/plugins/system/c3runtime/runtime.js { {const a=self.C3;let r=null,n="",s="",o=[],u="",l="",c="";const i=a.New(a.ArrayStack);function ForEachOrdered_SortInstances(e,t){const r=e[1],n=t[1];if("number"==typeof r&&"number"==typeof n)return r-n;{const a=""+r,i=""+n;return a<i?-1:i<a?1:0}}a.Plugins.System=class extends a.SDKPluginBase{constructor(e){super(e),this._loopStack=this._runtime.GetEventSheetManager().GetLoopStack(),this._eventStack=this._runtime.GetEventSheetManager().GetEventStack(),this._imagesLoadingTotal=0,this._imagesLoadingComplete=0,this._functionMaps=new Map}Release(){super.Release()}UpdateRender(){this._runtime.UpdateRender()}Trigger(e){this._runtime.Trigger(e,null,null)}GetRegex(e,t){return r&&e===n&&t===s||(r=new RegExp(e,t),n=e,s=t),r.lastIndex=0,r}GetRegexMatches(e,t,r){if(e!==u||t!==l||r!==c){const n=this.GetRegex(t,r);o=e.match(n),u=e,l=t,c=r}return o}async _LoadTexturesForObjectClasses(e,t){if(t.length){this._imagesLoadingTotal+=t.length;const r=[];for(const n of t)r.push(e.MaybeLoadTexturesFor(n));await a.PromiseAllWithProgress(r,()=>{this._imagesLoadingComplete++}),this._imagesLoadingComplete++,this._imagesLoadingComplete===this._imagesLoadingTotal&&(this._imagesLoadingComplete=0,this._imagesLoadingTotal=0,this._runtime.Trigger(a.Plugins.System.Cnds.OnImageLoadingComplete,null,null))}}GetImageLoadingProgress(){return 0===this._imagesLoadingTotal?1:this._imagesLoadingComplete/this._imagesLoadingTotal}_UnloadTexturesForObjectClasses(e,t){for(const r of t)0===r.GetInstanceCount()&&e.MaybeUnloadTexturesFor(r)}_GetForEachStack(){return i}_Repeat(t){const r=this._runtime.GetEventSheetManager(),e=r.GetEventStack(),n=e.GetCurrentStackFrame(),a=n.GetCurrentEvent(),i=a.GetSolModifiers(),s=n.IsSolModifierAfterCnds(),o=e.Push(a),u=r.GetLoopStack(),l=u.Push();if(l.SetEnd(t),s)for(let e=0;e<t&&!l.IsStopped();++e)r.PushCopySol(i),l.SetIndex(e),a.Retrigger(n,o),r.PopSol(i);else for(let e=0;e<t&&!l.IsStopped();++e)l.SetIndex(e),a.Retrigger(n,o);return e.Pop(),u.Pop(),!1}*_DebugRepeat(t){const r=this._runtime.GetEventSheetManager(),e=r.GetEventStack(),n=e.GetCurrentStackFrame(),a=n.GetCurrentEvent(),i=a.GetSolModifiers(),s=n.IsSolModifierAfterCnds(),o=e.Push(a),u=r.GetLoopStack(),l=u.Push();if(l.SetEnd(t),s)for(let e=0;e<t&&!l.IsStopped();++e)r.PushCopySol(i),l.SetIndex(e),yield*a.DebugRetrigger(n,o),r.PopSol(i);else for(let e=0;e<t&&!l.IsStopped();++e)l.SetIndex(e),yield*a.DebugRetrigger(n,o);return e.Pop(),u.Pop(),!1}_While(){const t=this._runtime.GetEventSheetManager(),e=t.GetEventStack(),r=e.GetCurrentStackFrame(),n=r.GetCurrentEvent(),a=n.GetSolModifiers(),i=r.IsSolModifierAfterCnds(),s=e.Push(n),o=t.GetLoopStack(),u=o.Push();if(i)for(let e=0;!u.IsStopped();++e)t.PushCopySol(a),u.SetIndex(e),n.Retrigger(r,s)||u.Stop(),t.PopSol(a);else for(let e=0;!u.IsStopped();++e)u.SetIndex(e),n.Retrigger(r,s)||u.Stop();return e.Pop(),o.Pop(),!1}*_DebugWhile(){const t=this._runtime.GetEventSheetManager(),e=t.GetEventStack(),r=e.GetCurrentStackFrame(),n=r.GetCurrentEvent(),a=n.GetSolModifiers(),i=r.IsSolModifierAfterCnds(),s=e.Push(n),o=t.GetLoopStack(),u=o.Push();if(i)for(let e=0;!u.IsStopped();++e){t.PushCopySol(a),u.SetIndex(e);const l=yield*n.DebugRetrigger(r,s);l||u.Stop(),t.PopSol(a)}else for(let e=0;!u.IsStopped();++e){u.SetIndex(e);const c=yield*n.DebugRetrigger(r,s);c||u.Stop()}return e.Pop(),o.Pop(),!1}_For(e,t,r){const n=this._runtime.GetEventSheetManager(),a=n.GetEventStack(),i=a.GetCurrentStackFrame(),s=i.GetCurrentEvent(),o=s.GetSolModifiers(),u=i.IsSolModifierAfterCnds(),l=a.Push(s),c=n.GetLoopStack(),h=c.Push();if(h.SetName(e),h.SetEnd(r),r<t)if(u)for(let e=t;e>=r&&!h.IsStopped();--e)n.PushCopySol(o),h.SetIndex(e),s.Retrigger(i,l),n.PopSol(o);else for(let e=t;e>=r&&!h.IsStopped();--e)h.SetIndex(e),s.Retrigger(i,l);else if(u)for(let e=t;e<=r&&!h.IsStopped();++e)n.PushCopySol(o),h.SetIndex(e),s.Retrigger(i,l),n.PopSol(o);else for(let e=t;e<=r&&!h.IsStopped();++e)h.SetIndex(e),s.Retrigger(i,l);return a.Pop(),c.Pop(),!1}*_DebugFor(e,t,r){const n=this._runtime.GetEventSheetManager(),a=n.GetEventStack(),i=a.GetCurrentStackFrame(),s=i.GetCurrentEvent(),o=s.GetSolModifiers(),u=i.IsSolModifierAfterCnds(),l=a.Push(s),c=n.GetLoopStack(),h=c.Push();if(h.SetName(e),h.SetEnd(r),r<t)if(u)for(let e=t;e>=r&&!h.IsStopped();--e)n.PushCopySol(o),h.SetIndex(e),yield*s.DebugRetrigger(i,l),n.PopSol(o);else for(let e=t;e>=r&&!h.IsStopped();--e)h.SetIndex(e),yield*s.DebugRetrigger(i,l);else if(u)for(let e=t;e<=r&&!h.IsStopped();++e)n.PushCopySol(o),h.SetIndex(e),yield*s.DebugRetrigger(i,l),n.PopSol(o);else for(let e=t;e<=r&&!h.IsStopped();++e)h.SetIndex(e),yield*s.DebugRetrigger(i,l);return a.Pop(),c.Pop(),!1}_ForEach(r){const e=r.GetCurrentSol(),t=e.GetInstances();if(0!==t.length){const n=this._runtime.GetEventSheetManager(),s=n.GetEventStack(),o=s.GetCurrentStackFrame(),u=o.GetCurrentEvent(),l=u.GetSolModifiers(),c=o.IsSolModifierAfterCnds(),h=s.Push(u),g=n.GetLoopStack(),S=g.Push(),d=r.IsInContainer(),p=i.Push();if(a.shallowAssignArray(p,t),S.SetEnd(p.length),c)for(let e=0,t=p.length;e<t&&!S.IsStopped();++e){n.PushCopySol(l);const m=p[e];r.GetCurrentSol().SetSinglePicked(m),d&&m.SetSiblingsSinglePicked(),S.SetIndex(e),u.Retrigger(o,h),n.PopSol(l)}else{e._SetSelectAll(!1);const G=e._GetOwnInstances();a.clearArray(G),G.push(null);for(let e=0,t=p.length;e<t&&!S.IsStopped();++e){const y=p[e];G[0]=y,d&&y.SetSiblingsSinglePicked(),S.SetIndex(e),u.Retrigger(o,h)}}s.Pop(),g.Pop(),a.clearArray(p),i.Pop()}return!1}*_DebugForEach(r){const e=r.GetCurrentSol(),t=e.GetInstances();if(0!==t.length){const n=this._runtime.GetEventSheetManager(),s=n.GetEventStack(),o=s.GetCurrentStackFrame(),u=o.GetCurrentEvent(),l=u.GetSolModifiers(),c=o.IsSolModifierAfterCnds(),h=s.Push(u),g=n.GetLoopStack(),S=g.Push(),d=r.IsInContainer(),p=i.Push();if(a.shallowAssignArray(p,t),S.SetEnd(p.length),c)for(let e=0,t=p.length;e<t&&!S.IsStopped();++e){n.PushCopySol(l);const m=p[e];r.GetCurrentSol().SetSinglePicked(m),d&&m.SetSiblingsSinglePicked(),S.SetIndex(e),yield*u.DebugRetrigger(o,h),n.PopSol(l)}else{e._SetSelectAll(!1);const G=e._GetOwnInstances();a.clearArray(G),G.push(null);for(let e=0,t=p.length;e<t&&!S.IsStopped();++e){const y=p[e];G[0]=y,d&&y.SetSiblingsSinglePicked(),S.SetIndex(e),yield*u.DebugRetrigger(o,h)}}s.Pop(),g.Pop(),a.clearArray(p),i.Pop()}return!1}_ForEachOrdered(r,e){const t=r.GetCurrentSol(),n=t.GetInstances();if(0!==n.length){const s=this._runtime.GetEventSheetManager(),o=s.GetEventStack(),u=s.GetCurrentCondition(),l=o.GetCurrentStackFrame(),c=l.GetCurrentEvent(),h=c.GetSolModifiers(),g=l.IsSolModifierAfterCnds(),S=o.Push(c),d=s.GetLoopStack(),p=d.Push(),m=r.IsInContainer(),G=i.Push();a.clearArray(G),p.SetEnd(n.length);for(let e=0,t=n.length;e<t;++e)G.push([n[e],u.ReevaluateParameter(1,e)]);if(G.sort(ForEachOrdered_SortInstances),1===e&&G.reverse(),g)for(let e=0,t=G.length;e<t&&!p.IsStopped();++e){s.PushCopySol(h);const y=G[e][0];r.GetCurrentSol().SetSinglePicked(y),m&&y.SetSiblingsSinglePicked(),p.SetIndex(e),c.Retrigger(l,S),s.PopSol(h)}else{t._SetSelectAll(!1);const f=t._GetOwnInstances();a.clearArray(f),f.push(null);for(let e=0,t=G.length;e<t&&!p.IsStopped();++e){const C=G[e][0];f[0]=C,m&&C.SetSiblingsSinglePicked(),p.SetIndex(e),c.Retrigger(l,S)}}o.Pop(),d.Pop(),a.clearArray(G),i.Pop()}return!1}*_DebugForEachOrdered(r,e){const t=r.GetCurrentSol(),n=t.GetInstances();if(0!==n.length){const s=this._runtime.GetEventSheetManager(),o=s.GetEventStack(),u=s.GetCurrentCondition(),l=o.GetCurrentStackFrame(),c=l.GetCurrentEvent(),h=c.GetSolModifiers(),g=l.IsSolModifierAfterCnds(),S=o.Push(c),d=s.GetLoopStack(),p=d.Push(),m=r.IsInContainer(),G=i.Push();a.clearArray(G),p.SetEnd(n.length);for(let e=0,t=n.length;e<t;++e)G.push([n[e],u.ReevaluateParameter(1,e)]);if(G.sort(ForEachOrdered_SortInstances),1===e&&G.reverse(),g)for(let e=0,t=G.length;e<t&&!p.IsStopped();++e){s.PushCopySol(h);const y=G[e][0];r.GetCurrentSol().SetSinglePicked(y),m&&y.SetSiblingsSinglePicked(),p.SetIndex(e),yield*c.DebugRetrigger(l,S),s.PopSol(h)}else{t._SetSelectAll(!1);const f=t._GetOwnInstances();a.clearArray(f),f.push(null);for(let e=0,t=G.length;e<t&&!p.IsStopped();++e){const C=G[e][0];f[0]=C,m&&C.SetSiblingsSinglePicked(),p.SetIndex(e),yield*c.DebugRetrigger(l,S)}}o.Pop(),d.Pop(),a.clearArray(G),i.Pop()}return!1}_GetFunctionMap(e,t){let r=this._functionMaps.get(e);if(!r){if(!t)return null;r={defaultFunc:null,strMap:new Map},this._functionMaps.set(e,r)}return r}_DoCallMappedFunction(e,t,r,n,a){t.GetEventBlock().RunAsMappedFunctionCall(r,t.IsCopyPicked()),n&&e.PopSol(a)}*_DebugDoCallMappedFunction(e,t,r,n,a){yield*t.GetEventBlock().DebugRunAsMappedFunctionCall(r,t.IsCopyPicked()),n&&e.PopSol(a)}}}{const a1=self.C3;a1.Plugins.System.Type=class extends a1.DefendedBase{constructor(e){super(),this._objectClass=e,this._runtime=e.GetRuntime(),this._plugin=e.GetPlugin()}OnCreate(){}Release(){this._objectClass=null,this._runtime=null,this._plugin=null}}}{const d1=self.C3;d1.Plugins.System.Instance=class extends d1.DefendedBase{constructor(e,t){super(),this._inst=e,this._objectClass=this._inst.GetObjectClass(),this._sdkType=this._objectClass.GetSdkType(),this._runtime=this._inst.GetRuntime()}Release(){this._inst=null,this._objectClass=null,this._sdkType=null,this._runtime=null}}}{const h1=self.C3,i1=[];h1.Plugins.System.Cnds={EveryTick(){return!0},OnLayoutStart(){return!0},OnLayoutEnd(){return!0},OnSuspend(){return!0},OnResume(){return!0},IsSuspended(){return this._runtime.IsSuspended()},Else(){const e=this._runtime.GetCurrentEventStackFrame();return!e.GetElseBranchRan()&&!e.GetLastEventTrue()},TriggerOnce(){const e=this._runtime.GetCurrentCondition(),t=e.GetSavedDataMap();let r=t.get("TriggerOnce_lastTick");void 0===r&&(r=-1,t.set("TriggerOnce_lastTick",-1));const n=this._runtime.GetTickCount();return t.set("TriggerOnce_lastTick",n),this._runtime.IsLayoutFirstTick()||r!==n-1},Every(e){const t=this._runtime.GetCurrentCondition(),r=t.GetSavedDataMap(),n=r.get("Every_lastTime")||0,a=this._runtime.GetGameTime(),i=(r.has("Every_seconds")||r.set("Every_seconds",e),r.get("Every_seconds"));return n+i<=a?(r.set("Every_lastTime",n+i),a>=r.get("Every_lastTime")+.04&&r.set("Every_lastTime",a),r.set("Every_seconds",e),!0):(a<n-.1&&r.set("Every_lastTime",a),!1)},IsGroupActive(e){const t=this._runtime.GetEventSheetManager().GetEventGroupByName(e);return t&&t.IsGroupActive()},IsPreview(){return this._runtime.IsPreview()},IsMobile(){return h1.Platform.IsMobile},OnLoadFinished(){return!0},OnCanvasSnapshot(){return!0},EffectsSupported(){return!0},OnSaveComplete(){return!0},OnSaveFailed(){return!0},OnLoadComplete(){return!0},OnLoadFailed(){return!0},ObjectUIDExists(e){return!!this._runtime.GetInstanceByUID(e)},IsOnPlatform(e){switch(e){case 0:return"browser"===h1.Platform.Context;case 1:return"iOS"===h1.Platform.OS;case 2:return"Android"===h1.Platform.OS;case 8:return"cordova"===h1.Platform.Context;case 9:return"scirra-arcade"===this._runtime.GetExportType();case 10:return"nwjs"===h1.Platform.Context;case 13:return"windows-uwp"===this._runtime.GetExportType();default:return!1}},RegexTest(e,t,r){const n=this.GetRegex(t,r);return n.test(e)},Compare(e,t,r){return h1.compare(e,t,r)},CompareBetween(e,t,r){return t<=e&&e<=r},CompareVar(e,t,r){return h1.compare(e.GetValue(),t,r)},CompareBoolVar(e){return!!e.GetValue()},CompareTime(e,t){const r=this._runtime.GetGameTime();if(0!==e)return h1.compare(r,e,t);{const n=this._runtime.GetCurrentCondition(),a=n.GetSavedDataMap();return!a.get("CompareTime_executed")&&t<=r?(a.set("CompareTime_executed",!0),!0):!1}},IsNaN(e){return isNaN(e)},AngleWithin(e,t,r){return h1.angleDiff(h1.toRadians(e),h1.toRadians(r))<=h1.toRadians(t)},IsClockwiseFrom(e,t){return h1.angleClockwise(h1.toRadians(e),h1.toRadians(t))},IsBetweenAngles(e,t,r){let n=h1.toRadians(e),a=h1.toRadians(t),i=h1.toRadians(r),s=!h1.angleClockwise(i,a);return s?!(!h1.angleClockwise(n,a)&&h1.angleClockwise(n,i)):h1.angleClockwise(n,a)&&!h1.angleClockwise(n,i)},IsValueType(e,t){return"number"==typeof e?0===t:1===t},EvaluateExpression(e){return!!e},OnSignal(e){return e.toLowerCase()===this._runtime.GetEventSheetManager().GetCurrentSignalTag()},PickByComparison(e,r,n,a){if(!e)return!1;const t=this._GetForEachStack(),i=t.Push(),s=e.GetCurrentSol(),o=(h1.shallowAssignArray(i,s.GetInstances()),s.IsSelectAll()&&h1.clearArray(s._GetOwnElseInstances()),this._runtime.GetCurrentCondition());let u=0;for(let e=0,t=i.length;e<t;++e){const c=i[e];i[u]=c,r=o.ReevaluateParameter(1,e),a=o.ReevaluateParameter(3,e),h1.compare(r,n,a)?++u:s._PushElseInstance(c)}h1.truncateArray(i,u),s.SetArrayPicked(i);const l=!!i.length;return h1.clearArray(i),t.Pop(),e.ApplySolToContainer(),l},PickByEvaluate(e,t){if(!e)return!1;const r=this._GetForEachStack(),n=r.Push(),a=e.GetCurrentSol(),i=(h1.shallowAssignArray(n,a.GetInstances()),a.IsSelectAll()&&h1.clearArray(a._GetOwnElseInstances()),this._runtime.GetCurrentCondition());let s=0;for(let e=0,t=n.length;e<t;++e){const u=n[e];n[s]=u,i.ReevaluateParameter(1,e)?++s:a._PushElseInstance(u)}h1.truncateArray(n,s),a.SetArrayPicked(n);const o=!!n.length;return h1.clearArray(n),r.Pop(),e.ApplySolToContainer(),o},PickByHighestLowestValue(e,r,n){if(!e)return!1;const t=e.GetCurrentSol(),a=t.GetInstances();if(0===a.length)return!1;const i=this._runtime.GetCurrentCondition();let s=null,o=0;for(let e=0,t=a.length;e<t;++e){const u=a[e];n=i.ReevaluateParameter(2,e),(null===s||0===r&&n<o||1===r&&n>o)&&(o=n,s=u)}return t.PickOne(s),e.ApplySolToContainer(),!0},PickNth(e,t){if(!e)return!1;const r=e.GetCurrentSol(),n=r.GetInstances();if((t=Math.floor(t))>=n.length)return!1;const a=n[t];return r.PickOne(a),e.ApplySolToContainer(),!0},PickRandom(e){if(!e)return!1;const t=e.GetCurrentSol(),r=t.GetInstances(),n=Math.floor(this._runtime.Random()*r.length);if(n>=r.length)return!1;const a=r[n];return t.PickOne(a),e.ApplySolToContainer(),!0},PickAll(e){if(!e)return!1;if(!e.GetInstanceCount())return!1;const t=e.GetCurrentSol();return t._SetSelectAll(!0),e.ApplySolToContainer(),!0},PickOverlappingPoint(e,r,n){if(!e)return!1;const a=e.GetCurrentSol(),t=a.GetInstances(),i=this._runtime.GetCurrentEvent(),s=i.IsOrBlock(),o=this._runtime.GetCurrentCondition().IsInverted();a.IsSelectAll()?(h1.shallowAssignArray(i1,t),a.ClearArrays(),a._SetSelectAll(!1)):s?(h1.shallowAssignArray(i1,a._GetOwnElseInstances()),h1.clearArray(a._GetOwnElseInstances())):(h1.shallowAssignArray(i1,a._GetOwnInstances()),h1.clearArray(a._GetOwnInstances()));for(let e=0,t=i1.length;e<t;++e){const u=i1[e];h1.xor(u.GetWorldInfo().ContainsPoint(r,n),o)?a._PushInstance(u):a._PushElseInstance(u)}return e.ApplySolToContainer(),h1.xor(!!a._GetOwnInstances().length,o)},PickLastCreated(t){if(!t)return!1;const r=t.IsFamily();let n=null;const a=this._runtime._GetInstancesPendingCreate();for(let e=a.length-1;0<=e;--e){const i=a[e];if(r){if(i.GetObjectClass().BelongsToFamily(t)){n=i;break}}else if(i.GetObjectClass()===t){n=i;break}}if(!n){const s=t.GetInstances();s.length&&(n=s.at(-1))}if(!n)return!1;const e=t.GetCurrentSol();return e.PickOne(n),t.ApplySolToContainer(),!0},Repeat(e){return this._runtime.IsDebugging()?this._DebugRepeat(e):this._Repeat(e)},While(){return this._runtime.IsDebugging()?this._DebugWhile():this._While()},For(e,t,r){return this._runtime.IsDebugging()?this._DebugFor(e,t,r):this._For(e,t,r)},ForEach(e){return this._runtime.IsDebugging()?this._DebugForEach(e):this._ForEach(e)},ForEachOrdered(e,t,r){return this._runtime.IsDebugging()?this._DebugForEachOrdered(e,r):this._ForEachOrdered(e,r)},LayerVisible(e){return!!e&&e.IsVisible()},LayerInteractive(e){return!!e&&e.IsSelfAndParentsInteractive()},LayerIsHTML(e){return!!e&&e.IsHTMLElementsLayer()},LayerEmpty(e){return!!e&&!e.GetInstanceCount()},LayerCmpOpacity(e,t,r){return!!e&&h1.compare(100*e.GetOpacity(),t,r)},LayerNameExists(e){const t=this._runtime.GetMainRunningLayout();return!!t&&t.HasLayerByName(e)},OnImageLoadingComplete(){return!0},IsLoadingImages(){return 0<this._imagesLoadingTotal},TemplateExists(e,t){const r=this._runtime.GetTemplateManager();return!!r&&!!t&&!!r.GetTemplateData(e,t)}}}{const M2=self.C3;function SortZOrderList(e,t){const r=e[0],n=t[0],a=r-n;if(0!=a)return a;const i=e[1],s=t[1];return i-s}function SortInstancesByValue(e,t){return e[1]-t[1]}const N2=[],O2=[],P2=M2.New(M2.Rect),Q2=M2.New(M2.Color),R2=[];M2.Plugins.System.Acts={SetVar(e,t){e.SetValue(t)},AddVar(e,t){e.IsNumber()&&"number"!=typeof t&&(t=parseFloat(t)),e.SetValue(e.GetValue()+t)},SubVar(e,t){e.IsNumber()&&e.SetValue(e.GetValue()-t)},SetBoolVar(e,t){e.SetValue(!!t)},ToggleBoolVar(e){e.SetValue(!e.GetValue())},ResetEventVar(e){e.SetValue(e.GetInitialValue())},ResetGlobals(e){this._runtime.GetEventSheetManager().ResetAllGlobalsToInitialValue(e)},CreateObject(e,t,r,n,a,i){if(e&&t){const s=this._runtime.CreateInstance(e,t,r,n,a,i);if(s){a&&t.SortAndAddInstancesByZIndex(s);const o=this._runtime.GetEventSheetManager(),u=(o.BlockFlushingInstances(!0),s._TriggerOnCreatedOnSelfAndRelated(),o.BlockFlushingInstances(!1),new Map);s.CollectInstancesToPick(u,e,a);for(const[l,c]of u)l.GetCurrentSol().SetSetPicked(c)}}},CreateObjectByName(e,t,r,n,a,i){if(e&&t){const s=this._runtime.GetObjectClassByName(e);s&&M2.Plugins.System.Acts.CreateObject.call(this,s,t,r,n,a,i)}},RecreateInitialObjects(n,a,i,s,o,e,u,l,c,h,g){if(n){const S=this._runtime.GetCurrentLayout();let t=S;if(e){const d=this._runtime.GetLayoutManager().GetLayoutByName(e);if(!d)return;t=d}let r=null;if(!("number"!=typeof u||0<=u)||(r=t.GetLayer(u))){let e=null;if(!("number"!=typeof l||0<=l)||(e=S.GetLayer(l))){P2.set(a,i,s,o);const p=t.RecreateInitialObjects(n,P2,r,e,c,h,g);n.GetCurrentSol().SetArrayPicked(p),n.ApplySolToContainer()}}}},StopLoop(){const e=this._loopStack;e.IsInLoop()&&e.GetCurrent().Stop()},SetGroupActive(e,t){const r=this._runtime.GetEventSheetManager().GetEventGroupByName(e);r&&(0===t?r.SetGroupActive(!1):1===t?r.SetGroupActive(!0):r.SetGroupActive(!r.IsGroupActive()))},SetTimescale(e){this._runtime.SetTimeScale(e)},SetObjectTimescale(e,t){if(t<0&&(t=0),e){const r=e.GetCurrentSol(),n=r.GetInstances();for(const a of n)a.SetTimeScale(t)}},RestoreObjectTimescale(e){if(e){const t=e.GetCurrentSol(),r=t.GetInstances();for(const n of r)n.RestoreTimeScale()}},Wait(e,t){if(!(e<0)){const r=this._runtime.GetEventSheetManager().AddScheduledWait();return t?r.InitTimer(e):r.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,r,n,a,i){const s=this._runtime.GetCanvasManager();s&&(this.UpdateRender(),await s.SnapshotCanvas(0===e?"image/png":"image/jpeg",t/100,r,n,a,i),await this._runtime.TriggerAsync(M2.Plugins.System.Cnds.OnCanvasSnapshot,null))},SetCanvasSize(e,t){if(!(e<=0||t<=0)){this._runtime.SetViewportSize(e,t),this._runtime.GetCurrentLayout().BoundScrolling();const r=this._runtime.GetCanvasManager();r&&("off"!==r.GetCurrentFullscreenMode()&&this._runtime.SetOriginalViewportSize(e,t),r.SetSize(r.GetLastWidth(),r.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,r){if(e){const t=e.GetCurrentSol(),n=t.GetInstances(),a=N2,i=O2,s=this._runtime.GetCurrentLayout(),o=e.IsFamily(),u=e.GetFamilyIndex();for(let e=0,t=n.length;e<t;++e){const l=n[e],c=l.GetWorldInfo();if(c){let e;e=o?l.GetInstanceVariableValue(r+l.GetObjectClass().GetFamilyInstanceVariableOffset(u)):l.GetInstanceVariableValue(r),a.push([c.GetLayer().GetIndex(),c.GetZIndex()]),i.push([l,e])}}if(a.length){a.sort(SortZOrderList),i.sort(SortInstancesByValue);let r=!1;for(let e=0,t=a.length;e<t;++e){const h=i[e][0],g=s.GetLayerByIndex(a[e][0]),S=a[e][1],d=g._GetInstances();d[S]!==h&&((d[S]=h).GetWorldInfo()._SetLayer(g,!0),g.SetZIndicesChanged(h),r=!0)}r&&this._runtime.UpdateRender(),M2.clearArray(N2),M2.clearArray(O2)}}},SetCollisionCellSize(e,t){e=Math.floor(e),t=Math.floor(t),e<=0||t<=0||!Number.isFinite(e)||!Number.isFinite(t)||this._runtime.GetCollisionEngine().SetCollisionCellSize(e,t)},GoToLayout(e){if(!this._runtime.IsLoading()){const t=this._runtime.GetLayoutManager();t.IsPendingChangeMainLayout()||t.ChangeMainLayout(e)}},GoToLayoutByName(e){if(!this._runtime.IsLoading()){const t=this._runtime.GetLayoutManager();if(!t.IsPendingChangeMainLayout()){const r=t.GetLayoutByName(e);r&&t.ChangeMainLayout(r)}}},NextPrevLayout(e){if(!this._runtime.IsLoading()){const t=this._runtime.GetLayoutManager();if(!t.IsPendingChangeMainLayout()){const r=t.GetAllLayouts(),n=r.indexOf(t.GetMainRunningLayout());if((!e||0!==n)&&(e||n!==r.length-1)){const a=r[n+(e?-1:1)];t.ChangeMainLayout(a)}}}},RestartLayout(){if(!this._runtime.IsLoading()){const e=this._runtime.GetLayoutManager();e.IsPendingChangeMainLayout()||(e.ChangeMainLayout(e.GetMainRunningLayout()),this._runtime.GetEventSheetManager().ResetAllGroupsInitialActivation())}},SetLayerVisible(e,t){e&&e.SetVisible(t)},SetLayerInteractive(e,t){e&&e.SetInteractive(t)},SetLayerHTML(e,t){e&&e.SetIsHTMLElementsLayer(t)},SetLayerOpacity(e,t){e&&e.SetOpacity(t/100)},SetLayerScale(e,t){e&&e.SetOwnScale(t)},SetLayerScaleRate(e,t){e&&e.SetScaleRate(t)},SetLayerAngle(e,t){e&&e.SetAngle(M2.toRadians(+t))},SetLayerScroll(e,t,r){e&&(e.SetOwnScrollPositionEnabled(!0),e.SetScrollX(t),e.SetScrollY(r))},RestoreLayerScroll(e){e&&e.SetOwnScrollPositionEnabled(!1)},SetLayerParallax(e,t,r){e&&e.SetParallax(t/100,r/100)},SetLayerZElevation(e,t){e&&e.SetZElevation(+t)},SetLayerBackground(e,t){if(e){Q2.setFromRgbValue(t),Q2.clamp();const r=e.GetBackgroundColor();r.equalsIgnoringAlpha(Q2)||(r.copyRgb(Q2),this.UpdateRender())}},SetLayerTransparent(e,t){e&&e.SetTransparent(t)},SetLayerBlendMode(e,t){e&&e.SetBlendMode(t)},SetLayerEffectEnabled(e,t,r){if(e){const n=e.GetEffectList(),a=n.GetEffectTypeByName(r);if(a){const i=1===t;a.IsActive()!==i&&(a.SetActive(i),e.UpdateActiveEffects(),this._runtime.UpdateRender())}}},SetLayerEffectParam(e,t,r,n){if(e){const a=e.GetEffectList(),i=a.GetEffectTypeByName(t);if(i){r=Math.floor(r);const s=i.GetShaderProgram().GetParameterType(r);if(s){"color"===s?(Q2.setFromRgbValue(n),n=Q2):"percent"===s&&(n/=100);const o=a.SetEffectParameter(i.GetIndex(),r,n);o&&i.IsActive()&&this._runtime.UpdateRender()}}}},SetLayerForceOwnTexture(e,t){e&&e.SetForceOwnTexture(t)},SetLayoutScale(e){this._runtime.GetCurrentLayout().SetScale(+e)},SetLayoutAngle(e){this._runtime.GetCurrentLayout().SetAngle(M2.toRadians(+e))},SetLayoutEffectEnabled(e,t){const r=this._runtime.GetCurrentLayout(),n=r.GetEffectList(),a=n.GetEffectTypeByName(t);if(a){const i=1===e;a.IsActive()!==i&&(a.SetActive(i),r.UpdateActiveEffects(),this._runtime.UpdateRender())}},SetLayoutEffectParam(e,t,r){const n=this._runtime.GetCurrentLayout(),a=n.GetEffectList(),i=a.GetEffectTypeByName(e);if(i){t=Math.floor(t);const s=i.GetShaderProgram().GetParameterType(t);if(s){"color"===s?(Q2.setFromRgbValue(r),r=Q2):"percent"===s&&(r/=100);const o=a.SetEffectParameter(i.GetIndex(),t,r);o&&i.IsActive()&&this._runtime.UpdateRender()}}},SetLayoutVanishingPoint(e,t){const r=this._runtime.GetCurrentLayout();r.SetVanishingPointXY(e/100,t/100)},SetLayoutProjection(e){const t=this._runtime.GetCurrentLayout();0===e?t.SetPerspectiveProjection():t.SetOrthographicProjection()},ScrollX(e){const t=this._runtime.GetCurrentLayout();t.SetScrollX(e)},ScrollY(e){const t=this._runtime.GetCurrentLayout();t.SetScrollY(e)},Scroll(e,t){const r=this._runtime.GetCurrentLayout();r.SetScrollX(e),r.SetScrollY(t)},ScrollToObject(e){if(e){const t=e.GetFirstPicked();if(t){const r=t.GetWorldInfo();if(r){const n=this._runtime.GetCurrentLayout();n.SetScrollX(r.GetX()),n.SetScrollY(r.GetY())}}}},AddLayer(e,t,r){const n=this._runtime.GetCurrentLayout();try{n.AddLayer(e,t,r)}catch(e){console.warn("[Construct] Cannot add layer: ",e)}},MoveLayer(e,t,r){if(e){const n=this._runtime.GetCurrentLayout();try{n.MoveLayer(e,t,r)}catch(e){console.warn("[Construct] Cannot move layer: ",e)}}},RemoveLayer(e){if(e){const t=this._runtime.GetCurrentLayout();t.RemoveLayer(e)}},RemoveAllDynamicLayers(){this._runtime.GetCurrentLayout().RemoveAllDynamicLayers()},async LoadObjectTextures(e){const t=this._runtime.GetMainRunningLayout();if(t&&e&&!this._runtime.IsLoading()){const r=e.IsFamily()?e.GetFamilyMembers():[e];await this._LoadTexturesForObjectClasses(t,r)}},async LoadObjectTexturesByName(e){await M2.Plugins.System.Acts.LoadObjectTextures.call(this,this._runtime.GetObjectClassByName(e))},UnloadObjectTextures(e){const t=this._runtime.GetMainRunningLayout();if(t&&e){const r=e.IsFamily()?e.GetFamilyMembers():[e];this._UnloadTexturesForObjectClasses(t,r)}},UnloadObjectTexturesByName(e){M2.Plugins.System.Acts.UnloadObjectTextures.call(this,this._runtime.GetObjectClassByName(e))},UnloadUnusedTextures(){const e=this._runtime.GetMainRunningLayout();if(e){const t=e._GetTextureLoadedObjectTypes();this._UnloadTexturesForObjectClasses(e,t)}},async LoadLayoutTextures(e){const t=this._runtime.GetMainRunningLayout();e&&t&&!this._runtime.IsLoading()&&await this._LoadTexturesForObjectClasses(t,e._GetInitialObjectClasses())},async LoadLayoutTexturesByName(e){const t=this._runtime.GetMainRunningLayout(),r=this._runtime.GetLayoutManager().GetLayoutByName(e);r&&t&&!this._runtime.IsLoading()&&await this._LoadTexturesForObjectClasses(t,r._GetInitialObjectClasses())},SetFunctionReturnValue(e){const t=this._eventStack.GetCurrentExpFuncStackFrame();if(t)switch(t.GetFunctionReturnType()){case 1:"number"==typeof e&&t.SetFunctionReturnValue(e);break;case 2:"string"==typeof e&&t.SetFunctionReturnValue(e);break;case 3:t.SetFunctionReturnValue(e)}},MapFunction(e,t,r){const n=this._GetFunctionMap(e.toLowerCase(),!0),a=n.strMap,i=t.toLowerCase(),s=(a.has(i)&&console.warn(`[Construct] Function map '${e}' string '${t}' already in map; overwriting entry`),M2.first(a.values())||n.defaultFunc);if(s){const o=0!==s.GetReturnType(),u=0!==r.GetReturnType();if(o!=u)return void console.error(`[Construct] Function map '${e}' string '${t}' function return type not compatible with other functions in the map; entry ignored`)}a.set(i,r)},MapFunctionDefault(e,t){const r=this._GetFunctionMap(e.toLowerCase(),!0),n=(r.defaultFunc&&console.warn(`[Construct] Function map '${e}' already has a default; overwriting entry`),M2.first(r.strMap.values())||r.defaultFunc);if(n){const a=0!==n.GetReturnType(),i=0!==t.GetReturnType();if(a!=i)return void console.error(`[Construct] Function map '${e}' default: function return type not compatible with other functions in the map; entry ignored`)}r.defaultFunc=t},CallMappedFunction(e,t,r){const n=this._runtime,a=n.IsDebugging()?R2:null,i=(r=Math.floor(r),this._GetFunctionMap(e.toLowerCase(),!1));if(!i)return console.warn(`[Construct] Call mapped function: map name '${e}' not found; call ignored`),a;let s=i.strMap.get(t.toLowerCase());if(!s){if(!i.defaultFunc)return console.warn(`[Construct] Call mapped function: no function associated with map '${e}' string '${t}'; call ignored (consider setting a default)`),a;s=i.defaultFunc,r=0}if(!s.IsEnabled())return a;if(0!==s.GetReturnType())return console.warn(`[Construct] Call mapped function: map '${e}' string '${t}' has a return type so cannot be called`),a;const o=n.GetEventSheetManager(),u=o.GetCurrentEvent(),l=u.GetSolModifiersIncludingParents(),c=0<l.length,h=(c&&(s.IsCopyPicked()?o.PushCopySol(l):o.PushCleanSol(l)),[]),g=o.FindFirstFunctionBlockParent(u);if(g){const d=g.GetFunctionParameters();for(let e=r,t=d.length;e<t;++e)h.push(d[e].GetValue())}const S=s.GetFunctionParameters();for(let e=h.length,t=S.length;e<t;++e)h.push(S[e].GetInitialValue());return n.IsDebugging()?this._DebugDoCallMappedFunction(o,s,h,c,l):this._DoCallMappedFunction(o,s,h,c,l)}}}{const Xf=self.C3;Xf.Plugins.System.Exps={int:function(e){return"string"==typeof e&&(e=parseInt(e,10),isNaN(e))&&(e=0),Math.floor(e)},float:function(e){return e="string"==typeof e&&(e=parseFloat(e),isNaN(e))?0:e},str(e){return e.toString()},len(e){return"string"==typeof e?e.length:0},random(e,t){return void 0===t?this._runtime.Random()*e:this._runtime.Random()*(t-e)+e},choose(...e){const t=Math.floor(this._runtime.Random()*e.length);return e[t]},chooseindex(e,...t){return"number"!=typeof e&&(e=0),t[e=Xf.clamp(Math.floor(e),0,t.length-1)]},pi(){return Math.PI},infinity(){return 1/0},sqrt(e){return Math.sqrt(e)},abs(e){return Math.abs(e)},round(e){return Math.round(e)},roundtodp(e,t){t=Math.max(Math.floor(t),0);const r=Math.pow(10,t);return Math.round((e+Number.EPSILON)*r)/r},floor(e){return Math.floor(e)},ceil(e){return Math.ceil(e)},sign(e){return Math.sign(e)},sin(e){return Math.sin(Xf.toRadians(e))},cos(e){return Math.cos(Xf.toRadians(e))},tan(e){return Math.tan(Xf.toRadians(e))},asin(e){return Xf.toDegrees(Math.asin(e))},acos(e){return Xf.toDegrees(Math.acos(e))},atan(e){return Xf.toDegrees(Math.atan(e))},exp(e){return Math.exp(e)},ln(e){return Math.log(e)},log10(e){return Math.log10(e)},max(...r){let n=r[0];"number"!=typeof n&&(n=0);for(let t=1,e=r.length;t<e;++t){let e=r[t];"number"==typeof e&&n<e&&(n=e)}return n},min(...r){let n=r[0];"number"!=typeof n&&(n=0);for(let t=1,e=r.length;t<e;++t){let e=r[t];"number"==typeof e&&n>e&&(n=e)}return n},clamp(e,t,r){return Xf.clamp(e,t,r)},distance(e,t,r,n){return Xf.distanceTo(e,t,r,n)},angle(e,t,r,n){return Xf.toDegrees(Xf.angleTo(e,t,r,n))},lerp(e,t,r){return Xf.lerp(e,t,r)},unlerp(e,t,r){return Xf.unlerp(e,t,r)},qarp(e,t,r,n){return Xf.qarp(e,t,r,n)},cubic(e,t,r,n,a){return Xf.cubic(e,t,r,n,a)},cosp(e,t,r){return Xf.cosp(e,t,r)},anglediff(e,t){return Xf.toDegrees(Xf.angleDiff(Xf.toRadians(e),Xf.toRadians(t)))},anglelerp(e,t,r){return Xf.toDegrees(Xf.angleLerp(Xf.toRadians(e),Xf.toRadians(t),r))},anglerotate(e,t,r){return Xf.toDegrees(Xf.angleRotate(Xf.toRadians(e),Xf.toRadians(t),Xf.toRadians(r)))},setbit(e,t,r){return(e|=0)&~(1<<(t|=0))|(r=0!==r?1:0)<<t},togglebit(e,t){return(e|=0)^1<<(t|=0)},getbit(e,t){return(e|=0)&1<<(t|=0)?1:0},newline(){return"\n"},uppercase(e){return"string"==typeof e?e.toUpperCase():""},lowercase(e){return"string"==typeof e?e.toLowerCase():""},left(e,t){return"string"==typeof e?e.substr(0,t):""},mid(e,t,r){return"string"!=typeof e?"":r<0?e.substr(t):e.substr(t,r)},right(e,t){return"string"==typeof e?e.substr(Math.max(e.length-t,0)):""},trim(e){return"string"==typeof e?e.trim():""},tokenat(e,t,r){if("string"!=typeof e||"string"!=typeof r)return"";let n=e.split(r);return(t=Math.floor(t))<0||t>=n.length?"":n[t]},tokencount(e,t){return"string"==typeof e&&"string"==typeof t&&e.length?e.split(t).length:0},find(e,t){return"string"==typeof e&&"string"==typeof t?e.search(new RegExp(Xf.EscapeRegex(t),"i")):-1},findcase(e,t){return"string"==typeof e&&"string"==typeof t?e.search(new RegExp(Xf.EscapeRegex(t),"")):-1},replace(e,t,r){return"string"==typeof e&&"string"==typeof t&&"string"==typeof r?e.replace(new RegExp(Xf.EscapeRegex(t),"gi"),r):"string"==typeof e?e:""},stringsub(e,...r){let n=e;for(let e=0,t=r.length;e<t;++e)n=n.replaceAll(`{${e}}`,r[e].toString());return n},regexsearch(e,t,r){const n=this.GetRegex(t,r);return e?e.search(n):-1},regexreplace(e,t,r,n){const a=this.GetRegex(t,r);return e?e.replace(a,n):""},regexmatchcount(e,t,r){const n=this.GetRegexMatches(e.toString(),t,r);return n?n.length:0},regexmatchat(e,t,r,n){n=Math.floor(n);const a=this.GetRegexMatches(e.toString(),t,r);return!a||n<0||n>=a.length?"":a[n]},zeropad(e,t){let r=e<0?"-":"";const n=t-(e=e<0?-e:e).toString().length;return(r+="0".repeat(Math.max(n,0)))+e.toString()},urlencode(e){return encodeURIComponent(e)},urldecode(e){return decodeURIComponent(e)},dt(){return this._runtime._GetDtFast()},wallclockdt(){return this._runtime.GetDt1()},timescale(){return this._runtime.GetTimeScale()},wallclocktime(){return(Date.now()-this._runtime.GetStartTime())/1e3},unixtime(){return Date.now()},time(){return this._runtime.GetGameTime()},tickcount(){return this._runtime.GetTickCount()},objectcount(){return this._runtime.GetObjectCount()},fps(){return this._runtime.GetFramesPerSecond()},cpuutilisation(){return this._runtime.GetMainThreadTime()},gpuutilisation(){return this._runtime.GetGPUUtilisation()},windowwidth(){return this._runtime.GetCanvasManager().GetDeviceWidth()},windowheight(){return this._runtime.GetCanvasManager().GetDeviceHeight()},originalwindowwidth(){return this._runtime.GetOriginalViewportWidth()},originalwindowheight(){return this._runtime.GetOriginalViewportHeight()},originalviewportwidth(){return this._runtime.GetOriginalViewportWidth()},originalviewportheight(){return this._runtime.GetOriginalViewportHeight()},scrollx(){return this._runtime.GetCurrentLayout().GetScrollX()},scrolly(){return this._runtime.GetCurrentLayout().GetScrollY()},layoutname(){return this._runtime.GetCurrentLayout().GetName()},layoutscale(){return this._runtime.GetCurrentLayout().GetScale()},layoutangle(){return Xf.toDegrees(this._runtime.GetCurrentLayout().GetAngle())},layoutwidth(){return this._runtime.GetCurrentLayout().GetWidth()},layoutheight(){return this._runtime.GetCurrentLayout().GetHeight()},vanishingpointx(){return 100*this._runtime.GetCurrentLayout().GetVanishingPointX()},vanishingpointy(){return 100*this._runtime.GetCurrentLayout().GetVanishingPointY()},viewportleft(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetViewport3D().getLeft():0},viewporttop(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetViewport3D().getTop():0},viewportright(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetViewport3D().getRight():0},viewportbottom(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetViewport3D().getBottom():0},viewportwidth(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetViewport3D().width():0},viewportheight(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetViewport3D().height():0},viewportmidx(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);if(t){const r=t.GetViewport3D();return(r.getLeft()+r.getRight())/2}return 0},viewportmidy(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);if(t){const r=t.GetViewport3D();return(r.getTop()+r.getBottom())/2}return 0},canvastolayerx(e,t,r){const n=this._runtime.GetCurrentLayout().GetLayer(e);return n?n.CanvasCssToLayer(t,r)[0]:0},canvastolayery(e,t,r){const n=this._runtime.GetCurrentLayout().GetLayer(e);return n?n.CanvasCssToLayer(t,r)[1]:0},layertocanvasx(e,t,r){const n=this._runtime.GetCurrentLayout().GetLayer(e);return n?n.LayerToCanvasCss(t,r)[0]:0},layertocanvasy(e,t,r){const n=this._runtime.GetCurrentLayout().GetLayer(e);return n?n.LayerToCanvasCss(t,r)[1]:0},layertolayerx(e,t,r,n){const a=this._runtime.GetCurrentLayout(),i=a.GetLayer(e),s=a.GetLayer(t);if(!i||!s||i===s)return r;const[o,u]=i.LayerToCanvasCss(r,n);return s.CanvasCssToLayer(o,u)[0]},layertolayery(e,t,r,n){const a=this._runtime.GetCurrentLayout(),i=a.GetLayer(e),s=a.GetLayer(t);if(!i||!s||i===s)return n;const[o,u]=i.LayerToCanvasCss(r,n);return s.CanvasCssToLayer(o,u)[1]},layerscale(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetOwnScale():0},layerangle(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?Xf.toDegrees(t.GetOwnAngle()):0},layeropacity(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?100*t.GetOpacity():0},layerscalerate(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetScaleRate():0},layerscrollx(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetScrollX():0},layerscrolly(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetScrollY():0},layerparallaxx(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?100*t.GetParallaxX():0},layerparallaxy(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?100*t.GetParallaxY():0},layerzelevation(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetZElevation():0},layerindex(e){const t=this._runtime.GetCurrentLayout().GetLayer(e);return t?t.GetIndex():-1},canvassnapshot(){const e=this._runtime.GetCanvasManager();return e?e.GetCanvasSnapshotUrl():""},loopindex(e){const t=this._loopStack;if(!t.IsInLoop())return 0;if(e){const r=t.FindByName(e);return r?r.GetIndex():0}return t.GetCurrent().GetIndex()},savestatejson(){return this._runtime.GetLastSaveJsonString()},callmapped(e,t,...r){const n=this._GetFunctionMap(e.toLowerCase(),!1);if(!n)return console.warn(`[Construct] Call mapped function: map name '${e}' not found; returning 0`),0;let a=n.strMap.get(t.toLowerCase());if(!a){if(!n.defaultFunc)return console.warn(`[Construct] Call mapped function: no function associated with map '${e}' string '${t}'; returning 0 (consider setting a default)`),0;a=n.defaultFunc}const i=a.GetReturnType(),s=a.GetDefaultReturnValue();if(0===i)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(!a.IsEnabled())return s;const o=this._runtime,u=o.GetEventSheetManager(),l=u.GetCurrentEvent(),c=l.GetSolModifiersIncludingParents(),h=0<c.length,g=(h&&(a.IsCopyPicked()?u.PushCopySol(c):u.PushCleanSol(c)),a.GetFunctionParameters());for(let e=r.length,t=g.length;e<t;++e)r.push(g[e].GetInitialValue());const S=a.GetEventBlock(),d=S.RunAsExpressionFunctionCall(S.GetSolModifiersIncludingParents(),a.IsCopyPicked(),i,s,...r);return h&&u.PopSol(c),d},loadingprogress(){return this._runtime.GetAssetManager().GetLoadProgress()},imageloadingprogress(){return this.GetImageLoadingProgress()},renderer(){return this._runtime.GetWebGPURenderer()?"webgpu":"webgl"},rendererdetail(){return this._runtime.GetWebGPURenderer()?this._runtime.GetWebGPURenderer().GetAdapterInfoString():this._runtime.GetWebGLRenderer().GetUnmaskedRenderer()},imagememoryusage(){let e=this._runtime.GetRenderer().GetEstimatedTextureMemoryUsage();return Math.round(100*e/1048576)/100},rgb(e,t,r){return Xf.PackRGB(e,t,r)},rgbex(e,t,r){return Xf.PackRGBEx(e/100,t/100,r/100)},rgba(e,t,r,n){return Xf.PackRGBAEx(e/100,t/100,r/100,n/100)},rgbex255(e,t,r){return Xf.PackRGBEx(e/255,t/255,r/255)},rgba255(e,t,r,n){return Xf.PackRGBAEx(e/255,t/255,r/255,n/255)},projectname(){return this._runtime.GetProjectName()},projectversion(){return this._runtime.GetProjectVersion()},currenteventsheetname(){return this._runtime.GetCurrentEvent().GetEventSheet().GetName()},currenteventnumber(){return this._runtime.GetCurrentEvent().GetDisplayNumber()}}} } // scripts/plugins/Sprite/c3runtime/runtime.js { {const a=self.C3;a.Plugins.Sprite=class extends a.SDKPluginBase{constructor(t){super(t)}Release(){super.Release()}}}{const d=self.C3,e=self.C3X,f=[],g=(d.Plugins.Sprite.Type=class extends d.SDKTypeBase{constructor(t){super(t),this._animations=t.GetAnimations()}Release(){d.clearArray(this._animations),super.Release()}OnCreate(){for(const t of this._animations)t.LoadAllAssets(this._runtime)}LoadTextures(e){const n={sampling:this._runtime.GetSampling()};return Promise.all(this._animations.map(t=>t.LoadAllTextures(e,n)))}ReleaseTextures(){for(const t of this._animations)t.ReleaseAllTextures()}OnDynamicTextureLoadComplete(){this._UpdateAllCurrentTexture()}_UpdateAllCurrentTexture(){for(const t of this._objectClass.instancesIncludingPendingCreate())t.GetSdkInstance()._UpdateCurrentTexture()}FinishCondition(t){d.Plugins.Sprite.FinishCollisionCondition(this,t)}BeforeRunAction(t){f.push({objectClass:null,createHierarchy:!1,instances:[]})}_SpawnPickInstance(t,e,n){const i=f.at(-1);i.objectClass=t,i.createHierarchy=n,i.instances.push(e)}AfterRunAction(t){const e=f.pop(),n=e.objectClass,i=e.createHierarchy;if(n){const r=new Map;for(const a of e.instances)a.CollectInstancesToPick(r,n,i);for(const[s,o]of r)s.GetCurrentSol().SetSetPicked(o)}}_AddAnimation(t){const e=this.GetObjectClass().AddAnimation(t),n=this.GetRuntime(),i=e.GetFrameAt(0);return i.GetImageInfo().LoadStaticTexture(n.GetRenderer(),{sampling:n.GetSampling()}).then(()=>this._UpdateAllCurrentTexture()),e}_RemoveAnimation(t){for(const e of this._objectClass.instancesIncludingPendingCreate())e.GetSdkInstance()._OnAnimationRemoved(t);this.GetObjectClass().RemoveAnimation(t)}_AddAnimationFrame(t,e){const n=this._objectClass.GetAnimationByName(t);if(!n)throw new Error(`cannot find animation name '${t}'`);let i=n.FrameTagOrIndexToIndex(e);i<0&&(i+=n.GetFrameCount()+1);const r=d.AnimationFrameInfo.CreateDynamic(this.GetRuntime()),a=(n.InsertFrameAt(r,i),this.GetRuntime());r.GetImageInfo().LoadStaticTexture(a.GetRenderer(),{sampling:a.GetSampling()}).then(()=>this._UpdateAllCurrentTexture());for(const s of this._objectClass.instancesIncludingPendingCreate())s.GetSdkInstance()._OnAnimationFramesChanged();return r}_RemoveAnimationFrame(t,e){const n=this._objectClass.GetAnimationByName(t);if(!n)throw new Error(`cannot find animation name '${t}'`);if(1===n.GetFrameCount())throw new Error(`cannot remove last frame from animation '${t}'`);let i=n.FrameTagOrIndexToIndex(e);i<0&&(i+=n.GetFrameCount()),n.RemoveFrameAt(i);for(const r of this._objectClass.instancesIncludingPendingCreate())r.GetSdkInstance()._OnAnimationFramesChanged()}GetScriptInterfaceClass(){return self.ISpriteObjectType}},new WeakMap);self.ISpriteObjectType=class extends self.IObjectClass{constructor(t){super(t),g.set(this,t.GetSdkType())}getAnimation(t){e.RequireString(t);const n=g.get(this).GetObjectClass().GetAnimationByName(t);return n?n.GetIAnimation():null}getAllAnimations(){return g.get(this).GetObjectClass().GetAllAnimations().map(t=>t.GetIAnimation())}addAnimation(t){return e.RequireString(t),g.get(this)._AddAnimation(t).GetIAnimation()}removeAnimation(t){e.RequireString(t),g.get(this)._RemoveAnimation(t)}addAnimationFrame(t,n){if(e.RequireString(t),"number"!=typeof n&&"string"!=typeof n)throw new TypeError("invalid insert location");return g.get(this)._AddAnimationFrame(t,n).GetIAnimationFrame()}removeAnimationFrame(t,n){if(e.RequireString(t),"number"!=typeof n&&"string"!=typeof n)throw new TypeError("invalid insert location");g.get(this)._RemoveAnimationFrame(t,n)}}}{const ea=self.C3,fa=self.C3X,ga=0,ha=1,ia=2,ja=3,ka=ea.New(ea.Rect),la=ea.New(ea.Quad),ma=ea.New(ea.Vector2),na=1,oa=2,pa=4,qa=(ea.Plugins.Sprite.Instance=class extends ea.SDKWorldInstanceBase{constructor(t,e){super(t);let n=!0,i="",r=0,a=!0;e&&(n=!!e[ga],i=e[ha],r=e[ia],a=e[ja]),this._currentAnimation=this._objectClass.GetAnimationByName(i)||this._objectClass.GetAnimations()[0],this._currentFrameIndex=ea.clamp(r,0,this._currentAnimation.GetFrameCount()-1),this._currentAnimationFrame=this._currentAnimation.GetFrameAt(this._currentFrameIndex);const s=this._currentAnimationFrame.GetImageInfo(),o=(this._currentTexture=s.GetTexture(),this._currentRcTex=s.GetTexRect(),this._currentQuadTex=s.GetTexQuad(),this.HandleRendererContextLoss(),t.SetFlag(oa,!0),t.SetFlag(na,0<=this._currentAnimation.GetSpeed()),this._currentAnimationSpeed=Math.abs(this._currentAnimation.GetSpeed()),this._currentAnimationRepeatTo=this._currentAnimation.GetRepeatTo(),this._animationTimer=ea.New(ea.KahanSum),this._frameStartTime=0,this._animationRepeats=0,this._animTriggerName="",this._changeAnimFrameIndex=-1,this._changeAnimationName="",this._changeAnimationFrom=0,this.GetWorldInfo());this._bquadRef=o.GetBoundingQuad(),o.SetVisible(n),o.SetCollisionEnabled(a),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(t){const e=this._currentTexture;if(null!==e){t.SetTexture(e);const n=this.GetWorldInfo();n.HasMesh()?this._DrawMesh(n,t):this._DrawStandard(n,t)}}_DrawStandard(t,e){let n=this._bquadRef;this._runtime.IsPixelRoundingEnabled()&&(n=t.PixelRoundQuad(n)),e.Quad4(n,this._currentQuadTex)}_DrawMesh(e,t){const n=e.GetTransformedMesh();if(e.IsMeshChanged()){e.CalculateBbox(ka,la,!1);let t=la;this._runtime.IsPixelRoundingEnabled()&&(t=e.PixelRoundQuad(t)),n.CalculateTransformedMesh(e.GetSourceMesh(),t,this._currentQuadTex),e.SetMeshChanged(!1)}n.Draw(t)}GetAnimationTime(){return this._animationTimer.Get()}IsAnimationPlaying(){return this._inst.GetFlag(oa)}SetAnimationPlaying(t){this._inst.SetFlag(oa,t)}IsPlayingForwards(){return this._inst.GetFlag(na)}SetPlayingForwards(t){this._inst.SetFlag(na,t)}IsInAnimationTrigger(){return this._inst.GetFlag(pa)}SetInAnimationTrigger(t){this._inst.SetFlag(pa,t)}Tick(){this._changeAnimationName&&this._DoChangeAnimation(),0<=this._changeAnimFrameIndex&&this._DoChangeAnimFrame();const t=this._currentAnimationSpeed;if(this.IsAnimationPlaying()&&0!==t){const e=this._runtime.GetDt(this._inst),n=(this._animationTimer.Add(e),this.GetAnimationTime()),i=this._currentAnimationFrame,r=i.GetDuration()/t;if(!(n<this._frameStartTime+r)){const a=this._currentAnimation,s=this._currentAnimationRepeatTo,o=a.GetFrameCount(),m=a.GetRepeatCount(),h=a.IsLooping(),u=a.IsPingPong(),c=(this.IsPlayingForwards()?this._currentFrameIndex++:this._currentFrameIndex--,this._frameStartTime+=r,this._currentFrameIndex>=o&&(u?(this.SetPlayingForwards(!1),this._currentFrameIndex=o-2):!h&&(this._animationRepeats++,this._animationRepeats>=m)?this._FinishAnimation(!1):this._currentFrameIndex=s),this._currentFrameIndex<0&&(u?(this._currentFrameIndex=1,this.SetPlayingForwards(!0),h||(this._animationRepeats++,this._animationRepeats>=m&&this._FinishAnimation(!0))):!h&&(this._animationRepeats++,this._animationRepeats>=m)?this._FinishAnimation(!0):this._currentFrameIndex=s),this._currentFrameIndex=ea.clamp(this._currentFrameIndex,0,o-1),a.GetFrameAt(this._currentFrameIndex));n>this._frameStartTime+c.GetDuration()/t&&(this._frameStartTime=n),this._OnFrameChanged(i,c)}}else this._StopTicking()}_FinishAnimation(t){this._currentFrameIndex=t?0:this._currentAnimation.GetFrameCount()-1,this.SetAnimationPlaying(!1),this._animTriggerName=this._currentAnimation.GetName(),this.SetInAnimationTrigger(!0),this.DispatchScriptEvent("animationend",!1,{animationName:this._animTriggerName}),this.Trigger(ea.Plugins.Sprite.Cnds.OnAnyAnimFinished),this.Trigger(ea.Plugins.Sprite.Cnds.OnAnimFinished),this.SetInAnimationTrigger(!1),this._animationRepeats=0}_OnFrameChanged(n,i,t){if(n!==i){const e=this.GetWorldInfo(),r=n.GetImageInfo(),a=i.GetImageInfo(),s=r.GetWidth(),o=r.GetHeight(),m=a.GetWidth(),h=a.GetHeight(),u=(t&&t.onFrameChange?t.onFrameChange(e,s,o,m,h):(s!==m&&e.SetWidth(e.GetWidth()*(m/s)),o!==h&&e.SetHeight(e.GetHeight()*(h/o))),e.SetOriginX(i.GetOriginX()),e.SetOriginY(i.GetOriginY()),e.SetSourceCollisionPoly(i.GetCollisionPoly()),e.SetBboxChanged(),this._currentAnimationFrame=i,this._currentTexture=a.GetTexture(),this._currentRcTex=a.GetTexRect(),this._currentQuadTex=a.GetTexQuad(),this.GetInstance().GetBehaviorInstances());for(let t=0,e=u.length;t<e;++t)u[t].OnSpriteFrameChanged(n,i);this.DispatchScriptEvent("framechange",!1,{animationName:this._currentAnimation.GetName(),animationFrame:this._currentFrameIndex}),this.Trigger(ea.Plugins.Sprite.Cnds.OnFrameChanged),this._runtime.UpdateRender()}}_StartAnim(t){this.SetAnimationPlaying(!0),this._frameStartTime=this.GetAnimationTime(),1===t&&0!==this._currentFrameIndex&&(this._changeAnimFrameIndex=0,this.IsInAnimationTrigger()||this._DoChangeAnimFrame()),this._StartTicking()}_SetAnim(t,e,n){this._changeAnimationName=t,this._changeAnimationFrom=e,this._StartTicking(),!n&&this.IsInAnimationTrigger()||this._DoChangeAnimation()}_GetCurrentAnimation(){return this._currentAnimation}_GetCurrentAnimationName(){return this._changeAnimationName||this._currentAnimation.GetName()}_OnAnimationRemoved(t){ea.equalsNoCase(t,this._GetCurrentAnimationName())&&this._SetAnim(this._objectClass.GetFirstAnimation().GetName(),1,!0)}_SetAnimFrame(t){if("string"==typeof t)if(String(Number(t))===t)t=Number(t);else{const e=this._objectClass.GetAnimationByName(this._GetCurrentAnimationName());if(!e)return;if(-1===(t=e.GetFrameIndexByTag(t)))return}isFinite(t)&&(this._changeAnimFrameIndex=t,this.IsInAnimationTrigger()||this._DoChangeAnimFrame())}_OnAnimationFramesChanged(){if(!this._changeAnimationName&&-1===this._changeAnimFrameIndex){const t=this._currentAnimationFrame,e=this._currentAnimation.GetFrameAt(ea.clamp(this._currentFrameIndex,0,this._currentAnimation.GetFrameCount()-1));t!==e&&this._OnFrameChanged(t,e),1<this._currentAnimation.GetFrameCount()&&0<this._currentAnimationSpeed&&this._StartTicking()}}_GetAnimFrame(){return this._currentFrameIndex}_GetAnimFrameTag(){return this._currentAnimationFrame.GetTag()}_SetAnimSpeed(t){this._currentAnimationSpeed=Math.abs(t),this.SetPlayingForwards(0<=t),0<this._currentAnimationSpeed&&this._StartTicking()}_GetAnimSpeed(){return this.IsPlayingForwards()?this._currentAnimationSpeed:-this._currentAnimationSpeed}_SetAnimRepeatToFrame(t){"string"==typeof t&&-1===(t=this._currentAnimation.GetFrameIndexByTag(t))||(t=ea.clamp(Math.floor(t),0,this._currentAnimation.GetFrameCount()-1),this._currentAnimationRepeatTo=t)}_GetAnimRepeatToFrame(){return this._currentAnimationRepeatTo}_DoChangeAnimation(t){const e=this._currentAnimationFrame,n=this._objectClass.GetAnimationByName(this._changeAnimationName);if(this._changeAnimationName="",n&&(n!==this._currentAnimation||!this.IsAnimationPlaying())){this._currentAnimation=n,this.SetPlayingForwards(0<=n.GetSpeed()),this._currentAnimationSpeed=Math.abs(n.GetSpeed()),this._currentAnimationRepeatTo=n.GetRepeatTo(),this._currentFrameIndex=ea.clamp(this._currentFrameIndex,0,this._currentAnimation.GetFrameCount()-1),1===this._changeAnimationFrom&&(this._currentFrameIndex=0),this.SetAnimationPlaying(!0),this._frameStartTime=this.GetAnimationTime();const i=this._currentAnimation.GetFrameAt(this._currentFrameIndex);this._OnFrameChanged(e,i,t)}}_DoChangeAnimFrame(t){const e=this._currentAnimationFrame,n=this._currentFrameIndex;if(this._currentFrameIndex=ea.clamp(Math.floor(this._changeAnimFrameIndex),0,this._currentAnimation.GetFrameCount()-1),this._changeAnimFrameIndex=-1,t||n!==this._currentFrameIndex){const i=this._currentAnimation.GetFrameAt(this._currentFrameIndex);this._OnFrameChanged(e,i),this._frameStartTime=this.GetAnimationTime()}}_UpdateCurrentTexture(){const t=this._currentAnimationFrame.GetImageInfo();this._currentTexture=t.GetTexture(),this._currentRcTex=t.GetTexRect(),this._currentQuadTex=t.GetTexQuad(),this.GetWorldInfo().SetMeshChanged(!0)}GetTexture(){return this._currentTexture}GetTexRect(){return this._currentRcTex}GetTexQuad(){return this._currentQuadTex}GetImagePointCount(){return this._currentAnimationFrame.GetImagePointCount()}GetImagePoint(t){const e=this._currentAnimationFrame,n=this.GetWorldInfo();let i=null;if("string"==typeof t)i=e.GetImagePointByName(t);else{if("number"!=typeof t)throw new TypeError("expected string or number");i=e.GetImagePointByIndex(t-1)}let r=n.GetTotalZElevation();if(!i)return[n.GetX(),n.GetY(),r];if(ma.copy(i.GetVec2()),n.HasMesh()){const[a,s,o]=n.GetSourceMesh().TransformPoint(ma.getX(),ma.getY());ma.set(a,s),r+=o}return ma.offset(-e.GetOriginX(),-e.GetOriginY()),ma.scale(n.GetWidth(),n.GetHeight()),ma.rotate(n.GetAngle()),ma.offset(n.GetX(),n.GetY()),[ma.getX(),ma.getY(),r]}GetCollisionPolyPointCount(){return this.GetWorldInfo().GetTransformedCollisionPoly().pointCount()}GetCollisionPolyPoint(t){t=Math.floor(t);const e=this.GetWorldInfo(),n=e.GetTransformedCollisionPoly(),i=n.pointCount();if((t=t===i?0:t)<0||i<=t)return[0,0];const r=n.pointsArr();return[r[2*t+0]+e.GetX(),r[2*t+1]+e.GetY()]}GetDebuggerProperties(){const e=ea.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:t=>this._animationRepeats=t}]}]}SaveToJson(){const t={"a":this._currentAnimation.GetSID()},e=(0!==this._frameStartTime&&(t["fs"]=this._frameStartTime),this.GetAnimationTime()),n=(0!==e&&(t["at"]=e),0!==this._currentFrameIndex&&(t["f"]=this._currentFrameIndex),0!==this._currentAnimationSpeed&&(t["cas"]=this._currentAnimationSpeed),1!==this._animationRepeats&&(t["ar"]=this._animationRepeats),0!==this._currentAnimationRepeatTo&&(t["rt"]=this._currentAnimationRepeatTo),this.IsAnimationPlaying()||(t["ap"]=this.IsAnimationPlaying()),this.IsPlayingForwards()||(t["af"]=this.IsPlayingForwards()),this.GetWorldInfo());return n.IsCollisionEnabled()&&(t["ce"]=n.IsCollisionEnabled()),t}LoadFromJson(t){const e=this.GetObjectClass().GetAnimationBySID(t["a"]),n=(e&&(this._currentAnimation=e),this._frameStartTime=t.hasOwnProperty("fs")?t["fs"]:0,this._animationTimer.Set(t.hasOwnProperty("at")?t["at"]:0),t.hasOwnProperty("f")?t["f"]:0),i=(this._currentFrameIndex=ea.clamp(n,0,this._currentAnimation.GetFrameCount()-1),this._currentAnimationSpeed=t.hasOwnProperty("cas")?t["cas"]:0,this._animationRepeats=t.hasOwnProperty("ar")?t["ar"]:1,t.hasOwnProperty("rt")?t["rt"]:0),r=(this._currentAnimationRepeatTo=ea.clamp(i,0,this._currentAnimation.GetFrameCount()-1),this.SetAnimationPlaying(!t.hasOwnProperty("ap")||!!t["ap"]),this.SetPlayingForwards(!t.hasOwnProperty("af")||!!t["af"]),this._currentAnimation.GetFrameAt(this._currentFrameIndex)),a=(this._currentAnimationFrame=r,this._UpdateCurrentTexture(),this.GetWorldInfo());a.SetOriginX(r.GetOriginX()),a.SetOriginY(r.GetOriginY()),a.SetSourceCollisionPoly(r.GetCollisionPoly()),a.SetCollisionEnabled(!!t["ce"]),this.IsAnimationPlaying()&&this._StartTicking()}GetPropertyValueByIndex(t){const e=this.GetWorldInfo();switch(t){case ja:return e.IsCollisionEnabled();case ia:return ea.clamp(this._currentFrameIndex,0,this._currentAnimation.GetFrameCount()-1);case ha:return this._currentAnimation.GetName()}}SetPropertyValueByIndex(t,e,n){const i=this.GetWorldInfo();switch(t){case ja:i.SetCollisionEnabled(!!e);break;case ia:{this.SetAnimationPlaying(!1);const r=this._currentAnimation.GetFrameCount()-1,a=e=ea.clamp(e,0,r),s=this._currentAnimation.GetFrameAt(this._currentFrameIndex),o=this._currentAnimation.GetFrameAt(a);this._OnFrameChanged(s,o,n),this._currentFrameIndex=ea.clamp(a,0,r);break}case ha:{this._changeAnimationName=e,this._DoChangeAnimation(n);const m=this._currentAnimation.GetFrameCount();1<m&&0<this._currentAnimation.GetSpeed()?this._StartTicking():this._StopTicking();break}}}GetScriptInterfaceClass(){return self.ISpriteInstance}},new WeakMap),ra=new Map([["current-frame",0],["beginning",1]]);self.ISpriteInstance=class extends self.IWorldInstance{constructor(){super(),qa.set(this,self.IInstance._GetInitInst().GetSdkInstance())}getImagePointCount(){return qa.get(this).GetImagePointCount()}getImagePointX(t){return this.getImagePoint(t)[0]}getImagePointY(t){return this.getImagePoint(t)[1]}getImagePointZ(t){return this.getImagePoint(t)[2]}getImagePoint(t){if("string"!=typeof t&&"number"!=typeof t)throw new TypeError("expected string or number");return qa.get(this).GetImagePoint(t)}getPolyPointCount(){return qa.get(this).GetCollisionPolyPointCount()}getPolyPointX(t){return fa.RequireFiniteNumber(t),qa.get(this).GetCollisionPolyPoint(t)[0]}getPolyPointY(t){return fa.RequireFiniteNumber(t),qa.get(this).GetCollisionPolyPoint(t)[1]}getPolyPoint(t){return fa.RequireFiniteNumber(t),qa.get(this).GetCollisionPolyPoint(t)}stopAnimation(){qa.get(this).SetAnimationPlaying(!1)}startAnimation(t="current-frame"){fa.RequireString(t);const e=ra.get(t);if(void 0===e)throw new Error("invalid mode");qa.get(this)._StartAnim(e)}setAnimation(t,e="beginning"){fa.RequireString(t),fa.RequireString(e);const n=ra.get(e);if(void 0===n)throw new Error("invalid mode");const i=qa.get(this);if(!i.GetObjectClass().GetAnimationByName(t))throw new Error(`animation name "${t}" does not exist`);i._SetAnim(t,n)}getAnimation(t){fa.RequireString(t);const e=qa.get(this).GetObjectClass().GetAnimationByName(t);return e?e.GetIAnimation():null}get animation(){return qa.get(this)._GetCurrentAnimation().GetIAnimation()}get animationName(){return qa.get(this)._GetCurrentAnimationName()}set animationFrame(t){fa.RequireFiniteNumber(t),qa.get(this)._SetAnimFrame(t)}get animationFrame(){return qa.get(this)._GetAnimFrame()}set animationFrameTag(t){fa.RequireString(t),qa.get(this)._SetAnimFrame(t)}get animationFrameTag(){return qa.get(this)._GetAnimFrameTag()}set animationSpeed(t){fa.RequireFiniteNumber(t),qa.get(this)._SetAnimSpeed(t)}get animationSpeed(){return qa.get(this)._GetAnimSpeed()}set animationRepeatToFrame(t){fa.RequireFiniteNumber(t),qa.get(this)._SetAnimRepeatToFrame(t)}get animationRepeatToFrame(){return qa.get(this)._GetAnimRepeatToFrame()}get imageWidth(){return qa.get(this).GetCurrentImageInfo().GetWidth()}get imageHeight(){return qa.get(this).GetCurrentImageInfo().GetHeight()}getImageSize(){const t=qa.get(this).GetCurrentImageInfo();return[t.GetWidth(),t.GetHeight()]}async replaceCurrentAnimationFrame(t){fa.RequireInstanceOf(t,Blob);const e=qa.get(this),n=e.GetRuntime(),i=e.GetCurrentImageInfo(),r=ea.New(ea.ImageInfo);if(r.LoadDynamicBlobAsset(n,t),await r.LoadStaticTexture(n.GetRenderer(),{sampling:n.GetSampling()}),e.WasReleased())r.Release();else{i.ReplaceWith(r);const a=e.GetSdkType();a._UpdateAllCurrentTexture(),a.GetObjectClass().Dispatcher().dispatchEvent(new ea.Event("animationframeimagechange")),n.UpdateRender()}}setSolidCollisionFilter(t,e){fa.RequireString(e),qa.get(this).GetWorldInfo().SetSolidCollisionFilter(!!t,e)}}}{const Vb=self.C3;Vb.Plugins.Sprite.Cnds={IsAnimPlaying(t){return Vb.equalsNoCase(this._GetCurrentAnimationName(),t)},CompareFrame(t,e){return Vb.compare(this._currentFrameIndex,t,e)},CompareFrameTag(t,e){if("string"!=typeof e)return!1;const n=this._currentAnimationFrame.GetTag();return Vb.compare(n.toLowerCase(),t,e.toLowerCase())},CompareAnimSpeed(t,e){return Vb.compare(this._GetAnimSpeed(),t,e)},OnAnimFinished(t){return Vb.equalsNoCase(this._animTriggerName,t)},OnAnyAnimFinished(){return!0},OnFrameChanged(){return!0},IsMirrored(){return this.GetWorldInfo().GetWidth()<0},IsFlipped(){return this.GetWorldInfo().GetHeight()<0},OnURLLoaded(){return!0},OnURLFailed(){return!0},IsCollisionEnabled(){return this.GetWorldInfo().IsCollisionEnabled()}}}{const d1=self.C3;d1.Plugins.Sprite.Acts={Spawn(t,e,n,i,r){if(t&&e){const[a,s]=this.GetImagePoint(n),o=this._runtime.CreateInstance(t,e,a,s,i,r);if(o){if(i&&e.SortAndAddInstancesByZIndex(o),t.GetPlugin().IsRotatable()){const h=o.GetWorldInfo();h.SetAngle(this.GetWorldInfo().GetAngle()),h.SetBboxChanged()}const m=this._runtime.GetEventSheetManager();m.BlockFlushingInstances(!0),o._TriggerOnCreatedOnSelfAndRelated(),m.BlockFlushingInstances(!1),t!==this._runtime.GetCurrentAction().GetObjectClass()&&this._sdkType._SpawnPickInstance(t,o,i)}}},StopAnim(){this.SetAnimationPlaying(!1)},StartAnim(t){this._StartAnim(t)},SetAnim(t,e){this._SetAnim(t,e)},SetAnimFrame(t){this._SetAnimFrame(t)},SetAnimSpeed(t){this._SetAnimSpeed(t)},SetAnimRepeatToFrame(t){this._SetAnimRepeatToFrame(t)},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,n){try{0===e?this.GetSdkType()._AddAnimationFrame(t,n):this.GetSdkType()._RemoveAnimationFrame(t,n)}catch(t){console.error(`[Construct] Error ${0===e?"adding":"removing"} animation frame: `,t)}},SetMirrored(t){const e=this.GetWorldInfo(),n=e.GetWidth(),i=Math.abs(n)*(0===t?-1:1);n!==i&&(e.SetWidth(i),e.SetBboxChanged())},SetFlipped(t){const e=this.GetWorldInfo(),n=e.GetHeight(),i=Math.abs(n)*(0===t?-1:1);n!==i&&(e.SetHeight(i),e.SetBboxChanged())},SetScale(t){const e=this._currentAnimationFrame,n=e.GetImageInfo(),i=this.GetWorldInfo(),r=i.GetWidth()<0?-1:1,a=i.GetHeight()<0?-1:1,s=n.GetWidth()*t*r,o=n.GetHeight()*t*a;i.GetWidth()===s&&i.GetHeight()===o||(i.SetSize(s,o),i.SetBboxChanged())},async LoadURL(t,e,n){const i=this._currentAnimationFrame,r=i.GetImageInfo(),a=this.GetWorldInfo(),s=this._runtime,o=this._sdkType;if(r.GetURL()===t)0===e&&(a.SetSize(r.GetWidth(),r.GetHeight()),a.SetBboxChanged()),this.Trigger(d1.Plugins.Sprite.Cnds.OnURLLoaded);else{const m=d1.New(d1.ImageInfo);try{if(await m.LoadDynamicAsset(s,t),!m.IsLoaded())throw new Error("image failed to load");if(this.WasReleased())return void m.Release();await m.LoadStaticTexture(s.GetRenderer(),{sampling:s.GetSampling()})}catch(t){return console.error("Load image from URL failed: ",t),void(this.WasReleased()||this.Trigger(d1.Plugins.Sprite.Cnds.OnURLFailed))}this.WasReleased()?m.Release():(r.ReplaceWith(m),o._UpdateAllCurrentTexture(),o.GetObjectClass().Dispatcher().dispatchEvent(new d1.Event("animationframeimagechange")),s.UpdateRender(),0===e&&(a.SetSize(r.GetWidth(),r.GetHeight()),a.SetBboxChanged()),await this.TriggerAsync(d1.Plugins.Sprite.Cnds.OnURLLoaded))}},SetCollisions(t){this.GetWorldInfo().SetCollisionEnabled(t)},SetSolidCollisionFilter(t,e){this.GetWorldInfo().SetSolidCollisionFilter(0===t,e)},SetEffect(t){this.GetWorldInfo().SetBlendMode(t),this._runtime.UpdateRender()}}}{const dc=self.C3;dc.Plugins.Sprite.Exps={AnimationFrame(){return this._GetAnimFrame()},AnimationFrameTag(){return this._GetAnimFrameTag()},AnimationFrameCount(){return this._currentAnimation.GetFrameCount()},AnimationName(){return this._currentAnimation.GetName()},AnimationSpeed(){return this._GetAnimSpeed()},OriginalAnimationSpeed(){return this._currentAnimation.GetSpeed()},ImagePointX(t){return this.GetImagePoint(t)[0]},ImagePointY(t){return this.GetImagePoint(t)[1]},ImagePointZ(t){return this.GetImagePoint(t)[2]},ImagePointCount(){return this.GetImagePointCount()},ImageWidth(){return this.GetCurrentImageInfo().GetWidth()},ImageHeight(){return this.GetCurrentImageInfo().GetHeight()},PolyPointXAt(t){return this.GetCollisionPolyPoint(t)[0]},PolyPointYAt(t){return this.GetCollisionPolyPoint(t)[1]},PolyPointCount(){return this.GetCollisionPolyPointCount()}}} } // scripts/plugins/TiledBg/c3runtime/runtime.js { {const a=self.C3;a.Plugins.TiledBg=class extends a.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{const d=self.C3;function WrapModeToStr(e){switch(e){case 0:return"clamp-to-edge";case 1:return"repeat";case 2:return"mirror-repeat"}return"repeat"}d.Plugins.TiledBg.Type=class extends d.SDKTypeBase{constructor(e,t){super(e),this._wrapX="repeat",this._wrapY="repeat",t&&(this._wrapX=WrapModeToStr(t[0]),this._wrapY=WrapModeToStr(t[1]))}Release(){super.Release()}OnCreate(){this.GetImageInfo().LoadAsset(this._runtime)}LoadTextures(e){return this.GetImageInfo().LoadStaticTexture(e,{sampling:this._runtime.GetSampling(),wrapX:this._wrapX,wrapY:this._wrapY})}ReleaseTextures(){this.GetImageInfo().ReleaseTexture()}GetWrapModeX(){return this._wrapX}GetWrapModeY(){return this._wrapY}}}{const j=self.C3,k=self.C3X,l=0,m=1,n=4,o=5,p=6,q=7,r=8,s=9,t=10,u=11,v=12,w=13,x=14,y=j.New(j.Rect),z=j.New(j.Quad),A=j.New(j.Rect),B=j.New(j.Quad),C=(j.Plugins.TiledBg.Instance=class extends j.SDKWorldInstanceBase{constructor(e,i){super(e),this._imageOffsetX=0,this._imageOffsetY=0,this._imageScaleX=1,this._imageScaleY=1,this._imageAngle=0,this._enableTileRandomization=!1,this._tileXRandom=0,this._tileYRandom=0,this._tileAngleRandom=0,this._tileBlendMarginX=0,this._tileBlendMarginY=0,this._ownImageInfo=null,i&&(this.GetWorldInfo().SetVisible(!!i[l]),this._imageOffsetX=i[n],this._imageOffsetY=i[o],this._imageScaleX=i[p],this._imageScaleY=i[q],this._imageAngle=j.toRadians(i[r]),this._enableTileRandomization=!!i[s],this._tileXRandom=i[t],this._tileYRandom=i[u],this._tileAngleRandom=i[v],this._tileBlendMarginX=i[w],this._tileBlendMarginY=i[x])}Release(){this._ReleaseOwnImage(),super.Release()}_ReleaseOwnImage(){this._ownImageInfo&&(this._ownImageInfo.Release(),this._ownImageInfo=null)}CalculateTextureCoordsFor3DFace(e,t,i){const a=this.GetCurrentImageInfo(),n=a.GetWidth(),s=a.GetHeight(),l=this._imageOffsetX/n,r=this._imageOffsetY/s,g=this._imageAngle;A.set(0,0,e/(n*this._imageScaleX),t/(s*this._imageScaleY)),A.offset(-l,-r),0===g?i.setFromRect(A):i.setFromRotatedRect(A,-g)}SetTilingShaderProgram(e,t=!0){if(this._enableTileRandomization){const i=this.GetCurrentImageInfo();e.SetTileRandomizationMode(),e.SetTileRandomizationInfo(i.GetWidth()*this._imageScaleX,i.GetHeight()*this._imageScaleY,this._tileXRandom,this._tileYRandom,this._tileAngleRandom,this._tileBlendMarginX,this._tileBlendMarginY)}else t&&e.SetTextureFillMode()}Draw(e){const t=this.GetCurrentImageInfo(),i=t.GetTexture();if(null!==i){this.SetTilingShaderProgram(e),e.SetTexture(i);const a=t.GetWidth(),n=t.GetHeight(),s=this._imageOffsetX/a,l=this._imageOffsetY/n,r=this.GetWorldInfo();A.set(0,0,r.GetWidth()/(a*this._imageScaleX),r.GetHeight()/(n*this._imageScaleY)),A.offset(-s,-l),r.HasMesh()?this._DrawMesh(r,e):this._DrawStandard(r,e)}}_DrawStandard(e,t){let i=e.GetBoundingQuad();this._runtime.IsPixelRoundingEnabled()&&(i=e.PixelRoundQuad(i)),0===this._imageAngle?t.Quad3(i,A):(B.setFromRotatedRect(A,-this._imageAngle),t.Quad4(i,B))}_DrawMesh(i,e){const a=i.GetTransformedMesh();if(i.IsMeshChanged()){i.CalculateBbox(y,z,!1);let e=z,t=(this._runtime.IsPixelRoundingEnabled()&&(e=i.PixelRoundQuad(e)),A);0!==this._imageAngle&&(B.setFromRotatedRect(A,-this._imageAngle),t=B),a.CalculateTransformedMesh(i.GetSourceMesh(),e,t),i.SetMeshChanged(!1)}a.Draw(e)}GetCurrentImageInfo(){return this._ownImageInfo||this._objectClass.GetImageInfo()}IsOriginalSizeKnown(){return!0}GetTexture(){return this.GetCurrentImageInfo().GetTexture()}_SetMeshChanged(){this.GetWorldInfo().SetMeshChanged(!0)}_SetImageOffsetX(e){this._imageOffsetX!==e&&(this._imageOffsetX=e,this._runtime.UpdateRender(),this._SetMeshChanged())}_GetImageOffsetX(){return this._imageOffsetX}_SetImageOffsetY(e){this._imageOffsetY!==e&&(this._imageOffsetY=e,this._runtime.UpdateRender(),this._SetMeshChanged())}_GetImageOffsetY(){return this._imageOffsetY}_SetImageScaleX(e){this._imageScaleX!==e&&(this._imageScaleX=e,this._runtime.UpdateRender(),this._SetMeshChanged())}_GetImageScaleX(){return this._imageScaleX}_SetImageScaleY(e){this._imageScaleY!==e&&(this._imageScaleY=e,this._runtime.UpdateRender(),this._SetMeshChanged())}_GetImageScaleY(){return this._imageScaleY}_SetImageAngle(e){this._imageAngle!==e&&(this._imageAngle=e,this._runtime.UpdateRender(),this._SetMeshChanged())}_GetImageAngle(){return this._imageAngle}_SetTileRandomizationEnabled(e){this._enableTileRandomization!==(e=!!e)&&(this._enableTileRandomization=e,this._runtime.UpdateRender())}_IsTileRandomizationEnabled(){return this._enableTileRandomization}_SetTileXRandom(e){this._tileXRandom!==e&&(this._tileXRandom=e,this._IsTileRandomizationEnabled())&&this._runtime.UpdateRender()}_GetTileXRandom(){return this._tileXRandom}_SetTileYRandom(e){this._tileYRandom!==e&&(this._tileYRandom=e,this._IsTileRandomizationEnabled())&&this._runtime.UpdateRender()}_GetTileYRandom(){return this._tileYRandom}_SetTileAngleRandom(e){this._tileAngleRandom!==e&&(this._tileAngleRandom=e,this._IsTileRandomizationEnabled())&&this._runtime.UpdateRender()}_GetTileAngleRandom(){return this._tileAngleRandom}_SetTileBlendMarginX(e){this._tileBlendMarginX!==e&&(this._tileBlendMarginX=e,this._IsTileRandomizationEnabled())&&this._runtime.UpdateRender()}_GetTileBlendMarginX(){return this._tileBlendMarginX}_SetTileBlendMarginY(e){this._tileBlendMarginY!==e&&(this._tileBlendMarginY=e,this._IsTileRandomizationEnabled())&&this._runtime.UpdateRender()}_GetTileBlendMarginY(){return this._tileBlendMarginY}SaveToJson(){const e={};return 0!==this._imageOffsetX&&(e["iox"]=this._imageOffsetX),0!==this._imageOffsetY&&(e["ioy"]=this._imageOffsetY),1!==this._imageScaleX&&(e["isx"]=this._imageScaleX),1!==this._imageScaleY&&(e["isy"]=this._imageScaleY),0!==this._imageAngle&&(e["ia"]=this._imageAngle),this._enableTileRandomization&&(e["tr"]=!0),1!==this._tileXRandom&&(e["trx"]=this._tileXRandom),1!==this._tileYRandom&&(e["try"]=this._tileYRandom),1!==this._tileAngleRandom&&(e["tra"]=this._tileAngleRandom),.1!==this._tileBlendMarginX&&(e["trbmx"]=this._tileBlendMarginX),.1!==this._tileBlendMarginY&&(e["trbmy"]=this._tileBlendMarginY),e}LoadFromJson(e){this._imageOffsetX=e["iox"]||0,this._imageOffsetY=e["ioy"]||0,this._imageScaleX=e.hasOwnProperty("isx")?e["isx"]:1,this._imageScaleY=e.hasOwnProperty("isy")?e["isy"]:1,this._imageAngle=e["ia"]||0,this._enableTileRandomization=!!e["tr"],this._tileXRandom=e.hasOwnProperty("trx")?e["trx"]:1,this._tileYRandom=e.hasOwnProperty("try")?e["try"]:1,this._tileAngleRandom=e.hasOwnProperty("tra")?e["tra"]:1,this._tileBlendMarginX=e.hasOwnProperty("trbmx")?e["trbmx"]:.1,this._tileBlendMarginY=e.hasOwnProperty("trbmy")?e["trbmy"]:.1}GetDebuggerProperties(){const e="plugins.tiledbg.properties";return[{title:e+".image-transform.name",properties:[{name:e+".image-offset-x.name",value:this._GetImageOffsetX(),onedit:e=>this._SetImageOffsetX(e)},{name:e+".image-offset-y.name",value:this._GetImageOffsetY(),onedit:e=>this._SetImageOffsetY(e)},{name:e+".image-scale-x.name",value:100*this._GetImageScaleX(),onedit:e=>this._SetImageScaleX(e/100)},{name:e+".image-scale-y.name",value:100*this._GetImageScaleY(),onedit:e=>this._SetImageScaleY(e/100)},{name:e+".image-angle.name",value:j.toDegrees(this._GetImageAngle()),onedit:e=>this._SetImageAngle(j.toRadians(e))}]},{title:e+".tile-randomization.name",properties:[{name:e+".enable-tile-randomization.name",value:this._IsTileRandomizationEnabled(),onedit:e=>this._SetTileRandomizationEnabled(e)},{name:e+".x-random.name",value:100*this._GetTileXRandom(),onedit:e=>this._SetTileXRandom(e/100)},{name:e+".y-random.name",value:100*this._GetTileYRandom(),onedit:e=>this._SetTileYRandom(e/100)},{name:e+".angle-random.name",value:100*this._GetTileAngleRandom(),onedit:e=>this._SetTileAngleRandom(e/100)},{name:e+".blend-margin-x.name",value:100*this._GetTileBlendMarginX(),onedit:e=>this._SetTileBlendMarginX(e/100)},{name:e+".blend-margin-y.name",value:100*this._GetTileBlendMarginY(),onedit:e=>this._SetTileBlendMarginY(e/100)}]}]}GetPropertyValueByIndex(e){switch(e){case n:return this._GetImageOffsetX();case o:return this._GetImageOffsetY();case p:return this._GetImageScaleX();case q:return this._GetImageScaleY();case r:return this._GetImageAngle();case s:return this._IsTileRandomizationEnabled();case t:return this._GetTileXRandom();case u:return this._GetTileYRandom();case v:return this._GetTileAngleRandom();case w:return this._GetTileBlendMarginX();case x:return this._GetTileBlendMarginY()}}SetPropertyValueByIndex(e,i){switch(e){case n:this._SetImageOffsetX(i);break;case o:this._SetImageOffsetY(i);break;case p:this._SetImageScaleX(i);break;case q:this._SetImageScaleY(i);break;case r:this._SetImageAngle(i);break;case s:this._SetTileRandomizationEnabled(!!i);break;case t:this._SetTileXRandom(i);break;case u:this._SetTileYRandom(i);break;case v:this._SetTileAngleRandom(i);break;case w:this._SetTileBlendMarginX(i);break;case x:this._SetTileBlendMarginY(i)}}GetScriptInterfaceClass(){return self.ITiledBackgroundInstance}},new WeakMap);self.ITiledBackgroundInstance=class extends self.IWorldInstance{constructor(){super(),C.set(this,self.IInstance._GetInitInst().GetSdkInstance())}set imageOffsetX(e){k.RequireFiniteNumber(e),C.get(this)._SetImageOffsetX(e)}get imageOffsetX(){return C.get(this)._GetImageOffsetX()}set imageOffsetY(e){k.RequireFiniteNumber(e),C.get(this)._SetImageOffsetY(e)}get imageOffsetY(){return C.get(this)._GetImageOffsetY()}setImageOffset(e,t){k.RequireFiniteNumber(e),k.RequireFiniteNumber(t);const i=C.get(this);i._SetImageOffsetX(e),i._SetImageOffsetY(t)}getImageOffset(){const e=C.get(this);return[e._GetImageOffsetX(),e._GetImageOffsetY()]}set imageScaleX(e){k.RequireFiniteNumber(e),C.get(this)._SetImageScaleX(e)}get imageScaleX(){return C.get(this)._GetImageScaleX()}set imageScaleY(e){k.RequireFiniteNumber(e),C.get(this)._SetImageScaleY(e)}get imageScaleY(){return C.get(this)._GetImageScaleY()}setImageScale(e,t){k.RequireFiniteNumber(e),k.RequireFiniteNumber(t);const i=C.get(this);i._SetImageScaleX(e),i._SetImageScaleY(t)}getImageScale(){const e=C.get(this);return[e._GetImageScaleX(),e._GetImageScaleY()]}set imageAngle(e){k.RequireFiniteNumber(e),C.get(this)._SetImageAngle(e)}get imageAngle(){return C.get(this)._GetImageAngle()}set imageAngleDegrees(e){k.RequireFiniteNumber(e),C.get(this)._SetImageAngle(j.toRadians(e))}get imageAngleDegrees(){return j.toDegrees(C.get(this)._GetImageAngle())}get imageWidth(){return C.get(this).GetCurrentImageInfo().GetWidth()}get imageHeight(){return C.get(this).GetCurrentImageInfo().GetHeight()}getImageSize(){const e=C.get(this).GetCurrentImageInfo();return[e.GetWidth(),e.GetHeight()]}set enableTileRandomization(e){C.get(this)._SetTileRandomizationEnabled(!!e)}get enableTileRandomization(){return C.get(this)._IsTileRandomizationEnabled()}set tileXRandom(e){k.RequireFiniteNumber(e),C.get(this)._SetTileXRandom(e)}get tileXRandom(){return C.get(this)._GetTileXRandom()}set tileYRandom(e){k.RequireFiniteNumber(e),C.get(this)._SetTileYRandom(e)}get tileYRandom(){return C.get(this)._GetTileYRandom()}setTileRandom(e,t){k.RequireFiniteNumber(e),k.RequireFiniteNumber(t);const i=C.get(this);i._SetTileXRandom(e),i._SetTileYRandom(t)}getTileRandom(){const e=C.get(this);return[e._GetTileXRandom(),e._GetTileYRandom()]}set tileAngleRandom(e){k.RequireFiniteNumber(e),C.get(this)._SetTileAngleRandom(e)}get tileAngleRandom(){return C.get(this)._GetTileAngleRandom()}set tileBlendMarginX(e){k.RequireFiniteNumber(e),C.get(this)._SetTileBlendMarginX(e)}get tileBlendMarginX(){return C.get(this)._GetTileBlendMarginX()}set tileBlendMarginY(e){k.RequireFiniteNumber(e),C.get(this)._SetTileBlendMarginY(e)}get tileBlendMarginY(){return C.get(this)._GetTileBlendMarginY()}setTileBlendMargin(e,t){k.RequireFiniteNumber(e),k.RequireFiniteNumber(t);const i=C.get(this);i._SetTileBlendMarginX(e),i._SetTileBlendMarginY(t)}getTileBlendMargin(){const e=C.get(this);return[e._GetTileBlendMarginX(),e._GetTileBlendMarginY()]}async replaceImage(e){k.RequireInstanceOf(e,Blob);const t=C.get(this),i=t.GetRuntime(),a=j.New(j.ImageInfo);a.LoadDynamicBlobAsset(i,e),await a.LoadStaticTexture(i.GetRenderer(),{sampling:i.GetSampling(),wrapX:t.GetSdkType().GetWrapModeX(),wrapY:t.GetSdkType().GetWrapModeY()}),t.WasReleased()?a.Release():(t._ReleaseOwnImage(),t._ownImageInfo=a,i.UpdateRender())}}}{const o0=self.C3;o0.Plugins.TiledBg.Cnds={OnURLLoaded(){return!0},OnURLFailed(){return!0},IsTileRandomizationEnabled(){return this._IsTileRandomizationEnabled()}}}{const p0=self.C3;p0.Plugins.TiledBg.Acts={SetImageOffsetX(e){this._SetImageOffsetX(e)},SetImageOffsetY(e){this._SetImageOffsetY(e)},SetImageScaleX(e){this._SetImageScaleX(e/100)},SetImageScaleY(e){this._SetImageScaleY(e/100)},SetImageAngle(e){this._SetImageAngle(p0.toRadians(e))},SetTileRandomizationEnabled(e){this._SetTileRandomizationEnabled(e)},SetTilePosRandom(e,t){this._SetTileXRandom(e/100),this._SetTileYRandom(t/100)},SetTileAngleRandom(e){this._SetTileAngleRandom(e/100)},SetTileBlendMargin(e,t){this._SetTileBlendMarginX(e/100),this._SetTileBlendMarginY(t/100)},SetEffect(e){this.GetWorldInfo().SetBlendMode(e),this._runtime.UpdateRender()},async LoadURL(e,t){if(!this._ownImageInfo||this._ownImageInfo.GetURL()!==e){const i=this._runtime,a=p0.New(p0.ImageInfo);try{if(await a.LoadDynamicAsset(i,e),!a.IsLoaded())throw new Error("image failed to load");if(this.WasReleased())return a.Release(),null;const n=await a.LoadStaticTexture(i.GetRenderer(),{sampling:i.GetSampling(),wrapX:this.GetSdkType().GetWrapModeX(),wrapY:this.GetSdkType().GetWrapModeY()});if(!n)return}catch(e){return console.error("Load image from URL failed: ",e),void(this.WasReleased()||this.Trigger(p0.Plugins.TiledBg.Cnds.OnURLFailed))}this.WasReleased()?a.Release():(this._ReleaseOwnImage(),this._ownImageInfo=a,i.UpdateRender(),await this.TriggerAsync(p0.Plugins.TiledBg.Cnds.OnURLLoaded))}}}}{const I0=self.C3;I0.Plugins.TiledBg.Exps={ImageWidth(){return this.GetCurrentImageInfo().GetWidth()},ImageHeight(){return this.GetCurrentImageInfo().GetHeight()},ImageOffsetX(){return this._imageOffsetX},ImageOffsetY(){return this._imageOffsetY},ImageScaleX(){return 100*this._imageScaleX},ImageScaleY(){return 100*this._imageScaleY},ImageAngle(){return I0.toDegrees(this._imageAngle)},TileXRandom(){return 100*this._GetTileXRandom()},TileYRandom(){return 100*this._GetTileYRandom()},TileAngleRandom(){return 100*this._GetTileAngleRandom()},TileBlendMarginX(){return 100*this._GetTileBlendMarginX()},TileBlendMarginY(){return 100*this._GetTileBlendMarginY()}}} } // scripts/plugins/Touch/c3runtime/runtime.js { {const a=self.C3;a.Plugins.Touch=class extends a.SDKPluginBase{constructor(t){super(t)}Release(){super.Release()}}}{const d=self.C3,e=self.C3X;d.Plugins.Touch.Type=class extends d.SDKTypeBase{constructor(t){super(t)}Release(){super.Release()}OnCreate(){}GetScriptInterfaceClass(){return self.ITouchObjectType}};let s=null;function GetTouchSdkInstance(){return s.GetSingleGlobalInstance().GetSdkInstance()}self.ITouchObjectType=class extends self.IObjectClass{constructor(t){super(t),(s=t).GetRuntime()._GetCommonScriptInterfaces().touch=this}requestPermission(t){e.RequireString(t);const s=GetTouchSdkInstance();if("orientation"===t)return s._RequestPermission(0);if("motion"===t)return s._RequestPermission(1);throw new Error("invalid type")}}}{const m=self.C3,n="touch";m.Plugins.Touch.Instance=class extends m.SDKInstanceBase{constructor(t,e){super(t,n),this._touches=new Map,this._useMouseInput=!1,this._isMouseDown=!1,this._orientCompassHeading=0,this._orientAlpha=0,this._orientBeta=0,this._orientGamma=0,this._accX=0,this._accY=0,this._accZ=0,this._accWithGX=0,this._accWithGY=0,this._accWithGZ=0,this._triggerIndex=0,this._triggerId=0,this._triggerPermission=0,this._curTouchX=0,this._curTouchY=0,this._getTouchIndex=0,this._triggerType=0,this._permissionPromises=[],e&&(this._useMouseInput=e[0]),this.AddDOMMessageHandler("permission-result",t=>this._OnPermissionResult(t));const s=this.GetRuntime().Dispatcher();this._disposables=new m.CompositeDisposable(m.Disposable.From(s,"pointerdown",t=>this._OnPointerDown(t.data)),m.Disposable.From(s,"pointermove",t=>this._OnPointerMove(t.data)),m.Disposable.From(s,"pointerup",t=>this._OnPointerUp(t.data,!1)),m.Disposable.From(s,"pointercancel",t=>this._OnPointerUp(t.data,!0)),m.Disposable.From(s,"deviceorientation",t=>this._OnDeviceOrientation(t.data)),m.Disposable.From(s,"deviceorientationabsolute",t=>this._OnDeviceOrientationAbsolute(t.data)),m.Disposable.From(s,"devicemotion",t=>this._OnDeviceMotion(t.data)),m.Disposable.From(s,"tick2",t=>this._OnTick2()))}Release(){this._touches.clear(),super.Release()}_OnPointerDown(t){if("mouse"===t["pointerType"]){if(!this._useMouseInput)return;this._isMouseDown=!0}const e=t["pointerId"];if(!this._touches.has(e)){const s=t["pageX"]-this._runtime.GetCanvasClientX(),i=t["pageY"]-this._runtime.GetCanvasClientY(),n=performance.now(),r=this._touches.size,o=(this._triggerIndex=r,this._triggerId=e,m.New(m.Plugins.Touch.TouchInfo));o.Init(n,s,i,e,r),this._touches.set(e,o),this.Trigger(m.Plugins.Touch.Cnds.OnNthTouchStart),this.Trigger(m.Plugins.Touch.Cnds.OnTouchStart),this._curTouchX=s,this._curTouchY=i,this._triggerType=0,this.Trigger(m.Plugins.Touch.Cnds.OnTouchObject)}}_OnPointerMove(t){if("mouse"!==t["pointerType"]||this._isMouseDown){const e=this._touches.get(t["pointerId"]);if(e){const s=performance.now();if(!(s-e.GetTime()<2)){const i=t["pageX"]-this._runtime.GetCanvasClientX(),n=t["pageY"]-this._runtime.GetCanvasClientY();e.Update(s,i,n,t["width"],t["height"],t["pressure"])}}}}_OnPointerUp(t,e){if("mouse"===t["pointerType"]){if(!this._isMouseDown)return;this._isMouseDown=!1}const s=performance.now(),i=t["pointerId"],n=this._touches.get(i);if(n){if(this._triggerIndex=n.GetStartIndex(),this._triggerId=n.GetId(),!e){const r=t["pageX"]-this._runtime.GetCanvasClientX(),o=t["pageY"]-this._runtime.GetCanvasClientY();this._curTouchX=r,this._curTouchY=o,this._triggerType=1,this.Trigger(m.Plugins.Touch.Cnds.OnTouchObject)}if(this.Trigger(m.Plugins.Touch.Cnds.OnNthTouchEnd),this.Trigger(m.Plugins.Touch.Cnds.OnTouchEnd),!e){const u=n.ShouldTriggerTap(s);"single-tap"===u?(this.Trigger(m.Plugins.Touch.Cnds.OnTapGesture),this._curTouchX=n.GetX(),this._curTouchY=n.GetY(),this.Trigger(m.Plugins.Touch.Cnds.OnTapGestureObject)):"double-tap"===u&&(this.Trigger(m.Plugins.Touch.Cnds.OnDoubleTapGesture),this._curTouchX=n.GetX(),this._curTouchY=n.GetY(),this.Trigger(m.Plugins.Touch.Cnds.OnDoubleTapGestureObject))}n.Release(),this._touches.delete(i)}}_RequestPermission(s){return this._PostToDOMMaybeSync("request-permission",{"type":s}),new Promise((t,e)=>{this._permissionPromises.push({type:s,resolve:t,reject:e})})}_OnPermissionResult(t){const e=t["result"],s=t["type"],i=(this._triggerPermission=s,this._permissionPromises.filter(t=>t.type===s));for(const n of i)n.resolve(e?"granted":"denied");this._permissionPromises=this._permissionPromises.filter(t=>t.type!==s),e?(this.Trigger(m.Plugins.Touch.Cnds.OnPermissionGranted),0===s?this._runtime.RequestDeviceOrientationEvent():this._runtime.RequestDeviceMotionEvent()):this.Trigger(m.Plugins.Touch.Cnds.OnPermissionDenied)}_OnDeviceOrientation(t){"number"==typeof t["webkitCompassHeading"]?this._orientCompassHeading=t["webkitCompassHeading"]:t["absolute"]&&(this._orientCompassHeading=t["alpha"]),this._orientAlpha=t["alpha"],this._orientBeta=t["beta"],this._orientGamma=t["gamma"]}_OnDeviceOrientationAbsolute(t){this._orientCompassHeading=t["alpha"]}_OnDeviceMotion(t){const e=t["acceleration"],s=(e&&(this._accX=e["x"],this._accY=e["y"],this._accZ=e["z"]),t["accelerationIncludingGravity"]);s&&(this._accWithGX=s["x"],this._accWithGY=s["y"],this._accWithGZ=s["z"])}_OnTick2(){const t=performance.now();let e=0;for(const s of this._touches.values())s.GetTime()<=t-50&&s._SetLastTime(t),s.ShouldTriggerHold(t)&&(this._triggerIndex=s.GetStartIndex(),this._triggerId=s.GetId(),this._getTouchIndex=e,this.Trigger(m.Plugins.Touch.Cnds.OnHoldGesture),this._curTouchX=s.GetX(),this._curTouchY=s.GetY(),this.Trigger(m.Plugins.Touch.Cnds.OnHoldGestureObject),this._getTouchIndex=0),++e}_GetTouchByIndex(t){t=Math.floor(t);for(const e of this._touches.values()){if(0===t)return e;--t}return null}_IsClientPosOnCanvas(t,e){return 0<=t&&0<=e&&t<this._runtime.GetCanvasCssWidth()&&e<this._runtime.GetCanvasCssHeight()}GetDebuggerProperties(){return[{title:"plugins.touch.debugger.touches",properties:[...this._touches.values()].map(t=>({name:"$"+t.GetId(),value:t.GetX()+", "+t.GetY()}))}]}}}{const ra=self.C3,sa=[];ra.Plugins.Touch.Cnds={OnTouchStart(){return!0},OnTouchEnd(){return!0},IsInTouch(){return 0<this._touches.size},OnTouchObject(t,e){return!!t&&e===this._triggerType&&!!this._IsClientPosOnCanvas(this._curTouchX,this._curTouchY)&&this._runtime.GetCollisionEngine().TestAndSelectCanvasPointOverlap(t,[[this._curTouchX,this._curTouchY]],!1)},IsTouchingObject(t){if(!t)return!1;const e=this._runtime.GetCurrentCondition(),s=e.IsInverted(),i=[...this._touches.values()].filter(t=>this._IsClientPosOnCanvas(t.GetX(),t.GetY())).map(t=>[t.GetX(),t.GetY()]);return ra.xor(this._runtime.GetCollisionEngine().TestAndSelectCanvasPointOverlap(t,i,s),s)},CompareTouchSpeed(t,e,s){const i=this._GetTouchByIndex(t);return!!i&&ra.compare(i.GetSpeed(),e,s)},OrientationSupported(){return!0},MotionSupported(){return!0},CompareOrientation(t,e,s){this._runtime.RequestDeviceOrientationEvent();let i=0;return i=0===t?this._orientAlpha:1===t?this._orientBeta:this._orientGamma,ra.compare(i,e,s)},CompareAcceleration(t,e,s){this._runtime.RequestDeviceMotionEvent();let i=0;return i=0===t?this._accWithGX:1===t?this._accWithGY:2===t?this._accWithGZ:3===t?this._accX:4===t?this._accY:this._accZ,ra.compare(i,e,s)},OnNthTouchStart(t){return(t=Math.floor(t))===this._triggerIndex},OnNthTouchEnd(t){return(t=Math.floor(t))===this._triggerIndex},HasNthTouch(t){return t=Math.floor(t),this._touches.size>=t+1},OnHoldGesture(){return!0},OnTapGesture(){return!0},OnDoubleTapGesture(){return!0},OnHoldGestureObject(t){return!!t&&!!this._IsClientPosOnCanvas(this._curTouchX,this._curTouchY)&&this._runtime.GetCollisionEngine().TestAndSelectCanvasPointOverlap(t,[[this._curTouchX,this._curTouchY]],!1)},OnTapGestureObject(t){return!!t&&!!this._IsClientPosOnCanvas(this._curTouchX,this._curTouchY)&&this._runtime.GetCollisionEngine().TestAndSelectCanvasPointOverlap(t,[[this._curTouchX,this._curTouchY]],!1)},OnDoubleTapGestureObject(t){return!!t&&!!this._IsClientPosOnCanvas(this._curTouchX,this._curTouchY)&&this._runtime.GetCollisionEngine().TestAndSelectCanvasPointOverlap(t,[[this._curTouchX,this._curTouchY]],!1)},OnPermissionGranted(t){return this._triggerPermission===t},OnPermissionDenied(t){return this._triggerPermission===t}}}{const Va=self.C3;Va.Plugins.Touch.Acts={RequestPermission(t){this._RequestPermission(t)}}}{const Xa=self.C3;Xa.Plugins.Touch.Exps={TouchCount(){return this._touches.size},X(t){const e=this._GetTouchByIndex(this._getTouchIndex);return e?e.GetPositionForLayer(this._runtime.GetCurrentLayout(),t,!0):0},Y(t){const e=this._GetTouchByIndex(this._getTouchIndex);return e?e.GetPositionForLayer(this._runtime.GetCurrentLayout(),t,!1):0},XAt(t,e){const s=this._GetTouchByIndex(t);return s?s.GetPositionForLayer(this._runtime.GetCurrentLayout(),e,!0):0},YAt(t,e){const s=this._GetTouchByIndex(t);return s?s.GetPositionForLayer(this._runtime.GetCurrentLayout(),e,!1):0},XForID(t,e){const s=this._touches.get(t);return s?s.GetPositionForLayer(this._runtime.GetCurrentLayout(),e,!0):0},YForID(t,e){const s=this._touches.get(t);return s?s.GetPositionForLayer(this._runtime.GetCurrentLayout(),e,!1):0},AbsoluteX(){const t=this._GetTouchByIndex(0);return t?t.GetX():0},AbsoluteY(){const t=this._GetTouchByIndex(0);return t?t.GetY():0},AbsoluteXAt(t){const e=this._GetTouchByIndex(t);return e?e.GetX():0},AbsoluteYAt(t){const e=this._GetTouchByIndex(t);return e?e.GetY():0},AbsoluteXForID(t){const e=this._touches.get(t);return e?e.GetX():0},AbsoluteYForID(t){const e=this._touches.get(t);return e?e.GetY():0},SpeedAt(t){const e=this._GetTouchByIndex(t);return e?e.GetSpeed():0},SpeedForID(t){const e=this._touches.get(t);return e?e.GetSpeed():0},AngleAt(t){const e=this._GetTouchByIndex(t);return e?Xa.toDegrees(e.GetAngle()):0},AngleForID(t){const e=this._touches.get(t);return e?Xa.toDegrees(e.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(t){const e=this._touches.get(t);return e?e.GetWidth():0},HeightForID(t){const e=this._touches.get(t);return e?e.GetHeight():0},PressureForID(t){const e=this._touches.get(t);return e?e.GetPressure():0}}} } // scripts/plugins/Touch/c3runtime/touchInfo.js { const C3=self.C3,GESTURE_HOLD_THRESHOLD=15,GESTURE_HOLD_TIMEOUT=500,GESTURE_TAP_TIMEOUT=333,GESTURE_DOUBLETAP_THRESHOLD=25;let lastTapX=-1e3,lastTapY=-1e3,lastTapTime=-1e4;C3.Plugins.Touch.TouchInfo=class extends C3.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(t,s,i,e,_){this._pointerId=e,this._startIndex=_,this._time=t,this._lastTime=t,this._startTime=t,this._startX=s,this._startY=i,this._x=s,this._y=i,this._lastX=s,this._lastY=i}Update(t,s,i,e,_,h){this._lastTime=this._time,this._time=t,this._lastX=this._x,this._lastY=this._y,this._x=s,this._y=i,this._width=e,this._height=_,this._pressure=h,!this._isTooFarForHold&&C3.distanceTo(this._startX,this._startY,this._x,this._y)>=GESTURE_HOLD_THRESHOLD&&(this._isTooFarForHold=!0)}GetId(){return this._pointerId}GetStartIndex(){return this._startIndex}GetTime(){return this._time}_SetLastTime(t){this._lastTime=t}GetX(){return this._x}GetY(){return this._y}GetSpeed(){const t=C3.distanceTo(this._x,this._y,this._lastX,this._lastY),s=(this._time-this._lastTime)/1e3;return 0<s?t/s:0}GetAngle(){return C3.angleTo(this._lastX,this._lastY,this._x,this._y)}GetWidth(){return this._width}GetHeight(){return this._height}GetPressure(){return this._pressure}ShouldTriggerHold(t){return!this._hasTriggeredHold&&t-this._startTime>=GESTURE_HOLD_TIMEOUT&&!this._isTooFarForHold&&C3.distanceTo(this._startX,this._startY,this._x,this._y)<GESTURE_HOLD_THRESHOLD&&(this._hasTriggeredHold=!0)}ShouldTriggerTap(t){return!this._hasTriggeredHold&&t-this._startTime<=GESTURE_TAP_TIMEOUT&&!this._isTooFarForHold&&C3.distanceTo(this._startX,this._startY,this._x,this._y)<GESTURE_HOLD_THRESHOLD?t-lastTapTime<=2*GESTURE_TAP_TIMEOUT&&C3.distanceTo(lastTapX,lastTapY,this._x,this._y)<GESTURE_DOUBLETAP_THRESHOLD?(lastTapX=-1e3,lastTapY=-1e3,lastTapTime=-1e4,"double-tap"):(lastTapX=this._x,lastTapY=this._y,lastTapTime=t,"single-tap"):""}GetPositionForLayer(t,s,i){if(void 0===s){const e=t.GetLayerByIndex(0);return e.CanvasCssToLayer_DefaultTransform(this._x,this._y)[i?0:1]}{const _=t.GetLayer(s);return _?_.CanvasCssToLayer(this._x,this._y)[i?0:1]:0}}}; } // scripts/plugins/LocalStorage/c3runtime/runtime.js { {const a=self.C3;a.Plugins.LocalStorage=class extends a.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{const d=self.C3;d.Plugins.LocalStorage.Type=class extends d.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const g=self.C3,h="localstorage";g.Plugins.LocalStorage.Instance=class extends g.SDKInstanceBase{constructor(e,t){super(e,h),this._currentKey="",this._lastValue="",this._keyNamesList=[],this._errorMessage="",this._isPersistent=!1,this._pendingGets=0,this._pendingSets=0,this._isInMemoryOnly=!1,t&&(this._isInMemoryOnly=t[0]);const s=this._runtime._GetProjectStorage();this._storage=null,this._isInMemoryOnly?this._storage=s.createInstance({forceInMemoryFallback:!0}):this._storage=s,this._debugCache=new Map,this._isLoadingDebugCache=!1,this._runtime.AddLoadPromise(this._Init())}async _Init(){const e=await Promise.race([this.PostToDOMAsync("init"),g.Wait(3e3)]);e&&(this._isPersistent=e["isPersistent"])}Release(){super.Release()}async _TriggerStorageError(e){this._errorMessage=this._GetErrorString(e),await this.TriggerAsync(g.Plugins.LocalStorage.Cnds.OnError)}_GetErrorString(e){return e?"string"==typeof e?e:"string"==typeof e.message?e.message:"string"==typeof e.name?e.name:"string"==typeof e.data?e.data:"unknown error":"unknown error"}GetDebuggerProperties(){return this._isLoadingDebugCache||this._DebugCacheStorage(),[{title:"plugins.localstorage.name",properties:[...this._debugCache.entries()].map(t=>({name:"$"+t[0],value:t[1],onedit:e=>this._storage.setItem(t[0],e)}))}]}async _DebugCacheStorage(){this._isLoadingDebugCache=!0;try{const s=await this._storage.keys(),r=(s.sort((e,t)=>{const s=e.toLowerCase(),r=t.toLowerCase();return s<r?-1:r<s?1:0}),await Promise.all(s.map(e=>this._storage.getItem(e))));this._debugCache.clear();for(let e=0,t=s.length;e<t;++e)this._debugCache.set(s[e],r[e])}catch(e){console.warn("[C3 debugger] Error displaying local storage: ",e)}finally{this._isLoadingDebugCache=!1}}}}{const B=self.C3;B.Plugins.LocalStorage.Cnds={OnItemSet(e){return this._currentKey===e},OnAnyItemSet(){return!0},OnItemGet(e){return this._currentKey===e},OnAnyItemGet(){return!0},OnItemRemoved(e){return this._currentKey===e},OnAnyItemRemoved(){return!0},OnCleared(){return!0},OnAllKeyNamesLoaded(){return!0},OnError(){return!0},OnItemExists(e){return this._currentKey===e},OnItemMissing(e){return this._currentKey===e},CompareKey(e,t){return B.compare(this._currentKey,e,t)},CompareValue(e,t){return B.compare(this._lastValue,e,t)},IsProcessingSets(){return 0<this._pendingSets},IsProcessingGets(){return 0<this._pendingGets},OnAllSetsComplete(){return!0},OnAllGetsComplete(){return!0},IsPersistent(){return this._isPersistent}}}{const L=self.C3;function IsExpressionType(e){return"string"==typeof e||"number"==typeof e}L.Plugins.LocalStorage.Acts={async SetItem(e,t){this._pendingSets++;try{const s=await this._storage.setItem(e,t);await this.ScheduleTriggers(async()=>{this._currentKey=e,this._lastValue=s,await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnAnyItemSet),await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnItemSet)})}catch(e){await this._TriggerStorageError(e)}finally{this._pendingSets--,0===this._pendingSets&&await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnAllSetsComplete)}},async SetBinaryItem(e,t){if(t){const s=t.GetFirstPicked(this._inst);if(s){const r=s.GetSdkInstance();if(r){const i=r.GetArrayBufferReadOnly();this._pendingSets++;try{await this._storage.setItem(e,i),await this.ScheduleTriggers(async()=>{this._currentKey=e,this._lastValue="",await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnAnyItemSet),await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnItemSet)})}catch(e){await this._TriggerStorageError(e)}finally{this._pendingSets--,0===this._pendingSets&&await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnAllSetsComplete)}}}}},async GetItem(e){this._pendingGets++;try{const t=await this._storage.getItem(e);await this.ScheduleTriggers(async()=>{this._currentKey=e,this._lastValue=IsExpressionType(t)?t:"",await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnAnyItemGet),await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnItemGet)})}catch(e){await this._TriggerStorageError(e)}finally{this._pendingGets--,0===this._pendingGets&&await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnAllGetsComplete)}},async GetBinaryItem(t,e){if(e){const s=e.GetFirstPicked(this._inst);if(s){const r=s.GetSdkInstance();this._pendingGets++;try{let e=await this._storage.getItem(t);e=e instanceof ArrayBuffer?e:new ArrayBuffer(0),await this.ScheduleTriggers(async()=>{this._lastValue="",this._currentKey=t,r.SetArrayBufferTransfer(e),await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnAnyItemGet),await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnItemGet)})}catch(e){await this._TriggerStorageError(e)}finally{this._pendingGets--,0===this._pendingGets&&await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnAllGetsComplete)}}}},async CheckItemExists(e){try{const t=await this._storage.getItem(e);await this.ScheduleTriggers(async()=>{this._currentKey=e,null==t?(this._lastValue="",await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnItemMissing)):(this._lastValue=IsExpressionType(t)?t:"",await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnItemExists))})}catch(e){await this._TriggerStorageError(e)}},async RemoveItem(e){try{await this._storage.removeItem(e),await this.ScheduleTriggers(async()=>{this._currentKey=e,this._lastValue="",await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnAnyItemRemoved),await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnItemRemoved)})}catch(e){await this._TriggerStorageError(e)}},async ClearStorage(){try{await this._storage.clear(),await this.ScheduleTriggers(async()=>{this._currentKey="",this._lastValue="",L.clearArray(this._keyNamesList),await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnCleared)})}catch(e){await this._TriggerStorageError(e)}},async GetAllKeyNames(){try{const e=await this._storage.keys();await this.ScheduleTriggers(async()=>{this._keyNamesList=e,await this.TriggerAsync(L.Plugins.LocalStorage.Cnds.OnAllKeyNamesLoaded)})}catch(e){await this._TriggerStorageError(e)}},async RequestPersistent(){const e=await this.PostToDOMAsync("request-persistent");e["isOk"]&&(this._isPersistent=e["isPersistent"])},LoadMemoryFromJSON(t){if(this._isInMemoryOnly){let e;try{e=JSON.parse(t)}catch(e){return void console.error("[Local Storage] Failed to parse memory storage JSON: ",e)}e&&e["is-c3-storage"]&&Array.isArray(e["items"])||console.error("[Local Storage] Failed to load memory storage JSON: invalid data"),this._storage.SetMemoryStorage(new Map(e["items"]))}}}}{const qa=self.C3;qa.Plugins.LocalStorage.Exps={ItemValue(){return this._lastValue},Key(){return this._currentKey},KeyCount(){return this._keyNamesList.length},KeyAt(e){return(e=Math.floor(e))<0||e>=this._keyNamesList.length?"":this._keyNamesList[e]},ErrorMessage(){return this._errorMessage},MemoryStorageAsJSON(){return this._isInMemoryOnly?JSON.stringify({"is-c3-storage":!0,"items":[...this._storage.GetMemoryStorage()]}):""}}} } // scripts/plugins/Audio/c3runtime/runtime.js { {const a=self.C3,b=[];a.Plugins.Audio=class extends a.SDKPluginBase{constructor(t){super(t)}_AddActionPromise(t){b.push(t)}static async WaitForAllActionPromises(){await Promise.all(b),a.clearArray(b)}Release(){super.Release()}}}{const f=self.C3,g=self.C3X;f.Plugins.Audio.Type=class extends f.SDKTypeBase{constructor(t){super(t)}Release(){super.Release()}OnCreate(){}GetScriptInterfaceClass(){return self.IAudioObjectType}};let e=null;function GetAudioSdkInstance(){return e.GetSingleGlobalInstance().GetSdkInstance()}function GetAudioDOMInterface(){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")}self.IAudioObjectType=class extends self.IObjectClass{constructor(t){super(t),e=t}get audioContext(){return GetAudioDOMInterface()["GetAudioContextExtern"]()}get destinationNode(){return GetAudioDOMInterface()["GetDestinationNodeExtern"]()}get isSilent(){return GetAudioSdkInstance()._IsSilent()}set isSilent(t){GetAudioSdkInstance()._SetSilent(t)}get masterVolume(){return GetAudioSdkInstance()._GetMasterVolume()}set masterVolume(t){g.RequireFiniteNumber(t),GetAudioSdkInstance()._SetMasterVolume(t)}stopAll(){GetAudioSdkInstance()._StopAll()}}}{const o=self.C3,p="audio",q=["interactive","balanced","playback"];o.Plugins.Audio.Instance=class extends o.SDKInstanceBase{constructor(t,e){super(t,p),this._nextPlayTime=0,this._triggerTags=[],this._enableMultiTags=!0,this._timeScaleMode=0,this._saveLoadMode=0,this._playInBackground=!1,this._panningModel=1,this._distanceModel=1,this._listenerPos=[this._runtime.GetViewportWidth()/2,this._runtime.GetViewportHeight()/2,600],this._listenerForwardVec=[0,0,-1],this._listenerUpVec=[0,1,0],this._referenceDistance=600,this._maxDistance=1e4,this._rolloffFactor=1,this._listenerInst=null,this._loadListenerUid=-1,this._masterVolume=1,this._isSilent=!1,this._sampleRate=0,this._audioContextState="suspended",this._outputLatency=0,this._effectCount=new Map,this._preloadTotal=0,this._preloadCount=0,this._bufferMetadata=new Map,this._remoteUrls=new Map;let s="interactive";e&&(this._timeScaleMode=e[0],this._saveLoadMode=e[1],this._playInBackground=e[2],s=q[e[3]],this._enableMultiTags=e[4],this._panningModel=e[5],this._distanceModel=e[6],this._listenerPos[2]=e[7],this._referenceDistance=e[8],this._maxDistance=e[9],this._rolloffFactor=e[10]),this._lastAIState=[],this._lastFxState=[],this._lastAnalysersData=[],this.AddDOMMessageHandlers([["state",t=>this._OnUpdateState(t)],["audiocontext-state",t=>this._OnAudioContextStateChanged(t)],["fxstate",t=>this._OnUpdateFxState(t)],["trigger",t=>this._OnTrigger(t)],["buffer-metadata",t=>this._OnBufferMetadata(t)]]);const i=this.GetRuntime().Dispatcher(),a=(this._disposables=new o.CompositeDisposable(o.Disposable.From(i,"instancedestroy",t=>this._OnInstanceDestroyed(t.instance)),o.Disposable.From(i,"afterload",()=>this._OnAfterLoad()),o.Disposable.From(i,"suspend",()=>this._OnSuspend()),o.Disposable.From(i,"resume",()=>this._OnResume())),this._runtime.GetExportType()),n="Safari"===o.Platform.Browser,r=this._runtime.IsiOSWebView()||"macos-wkwebview"===a,l=this._runtime.GetAssetManager().IsFileProtocol(),h="playable-ad-single-file"===this._runtime.GetExportType(),u=n||r||l||h;this._runtime.AddLoadPromise(this.PostToDOMAsync("create-audio-context",{"preloadList":this._runtime.GetAssetManager().GetAudioToPreload().map(t=>({"originalUrl":t.originalUrl,"url":t.url,"type":t.type,"fileSize":t.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":u}).then(t=>{this._sampleRate=t["sampleRate"],this._audioContextState=t["audioContextState"],this._outputLatency=t["outputLatency"]})),this._StartTicking()}Release(){this._listenerInst=null,super.Release()}_SplitTags(t){return this._enableMultiTags?t.split(" ").filter(t=>!!t):t?[t]:[]}_MatchTagLists(e,t){for(const s of t){let t=!1;for(const i of e)if(o.equalsNoCase(i,s)){t=!0;break}if(!t)return!1}return!0}_MatchTagListToStr(t,e){return this._MatchTagLists(t,this._SplitTags(e))}_AddActionPromise(t){this.GetPlugin()._AddActionPromise(t)}_OnInstanceDestroyed(t){this._listenerInst===t&&(this._listenerInst=null)}DbToLinearNoCap(t){return Math.pow(10,t/20)}DbToLinear(t){const e=this.DbToLinearNoCap(t);return isFinite(e)?Math.max(Math.min(e,1),0):0}LinearToDbNoCap(t){return Math.log(t)/Math.log(10)*20}LinearToDb(t){return this.LinearToDbNoCap(Math.max(Math.min(t,1),0))}_OnSuspend(){this._playInBackground||this.PostToDOM("set-suspended",{"isSuspended":!0})}_OnResume(){this._playInBackground||this.PostToDOM("set-suspended",{"isSuspended":!1})}_OnUpdateState(t){const e=t["tickCount"],s=(this._outputLatency=t["outputLatency"],this._lastAIState.filter(t=>t.hasOwnProperty("placeholder")&&(t["placeholder"]>e||-1===t["placeholder"])));this._lastAIState=t["audioInstances"],this._lastAnalysersData=t["analysers"],0<s.length&&o.appendArray(this._lastAIState,s)}_OnBufferMetadata(t){this._bufferMetadata.set(t["originalUrl"],{duration:t["duration"]})}_OnAudioContextStateChanged(t){this._audioContextState=t["audioContextState"]}GetAudioContextState(){return this._runtime.IsExportToVideo()?"running":this._audioContextState}_OnUpdateFxState(t){this._lastFxState=t["fxstate"]}_GetFirstAudioStateByTags(t){const e=this._SplitTags(t);for(const s of this._lastAIState)if(this._MatchTagLists(s["tags"],e))return s;return null}_IsTagPlaying(t){const e=this._SplitTags(t);return this._lastAIState.some(t=>this._MatchTagLists(t["tags"],e)&&t["isPlaying"])}_MaybeMarkAsPlaying(t,e,s,i,a){if(this._IsTagPlaying(e))return null;const n=this._bufferMetadata.get(t),o={"tags":this._SplitTags(e),"duration":n?n.duration:0,"volume":a,"isPlaying":!0,"playbackTime":0,"playbackRate":1,"uid":-1,"bufferOriginalUrl":t,"bufferUrl":"","bufferType":"","isMusic":s,"isLooping":i,"isMuted":!1,"resumePosition":0,"pan":null,"placeholder":-1};return this._lastAIState.push(o),o}_MaybeMarkAsStopped(t){const e=this._SplitTags(t);for(const s of this._lastAIState)this._MatchTagLists(s["tags"],e)&&(s["isPlaying"]=!1)}async _OnTrigger(t){const e=t["type"],s=(this._triggerTags=t["tags"],t["aiid"]);if("ended"===e){for(const i of this._lastAIState)if(i["aiid"]===s){i["isPlaying"]=!1;break}await this.TriggerAsync(o.Plugins.Audio.Cnds.OnEnded)}else"fade-ended"===e&&await this.TriggerAsync(o.Plugins.Audio.Cnds.OnFadeEnded)}_MatchTriggerTag(t){return this._MatchTagListToStr(this._triggerTags,t)}Tick(){const t={"timeScale":this._runtime.GetTimeScale(),"gameTime":this._runtime.GetGameTimeRaw(),"instPans":this.GetInstancePans(),"tickCount":this._runtime.GetTickCountNoSave()};if(this._listenerInst){const e=this._listenerInst.GetWorldInfo();this._listenerPos[0]=e.GetX(),this._listenerPos[1]=e.GetY(),t["listenerPos"]=this._listenerPos,t["listenerOrientation"]=[...this._listenerForwardVec,...this._listenerUpVec]}this.PostToDOM("tick",t)}rotatePtAround(t,e,s,i,a){if(0!==s){const n=Math.sin(s),o=Math.cos(s),r=(t-=i)*n,l=(e-=a)*n,h=t*o,u=e*o;t=h-l,e=u+r,t+=i,e+=a}return[t,e]}GetInstancePans(){return this._lastAIState.filter(t=>-1!==t["uid"]).map(t=>this._runtime.GetInstanceByUID(t["uid"])).filter(t=>t).map(t=>{const e=t.GetWorldInfo(),s=e.GetLayer().GetAngle(),[i,a]=this.rotatePtAround(e.GetX(),e.GetY(),-s,this._listenerPos[0],this._listenerPos[1]);return{"uid":t.GetUID(),"x":i,"y":a,"z":e.GetTotalZElevation(),"angle":e.GetAngle()-s}})}GetAnalyserData(t,e){for(const s of this._lastAnalysersData)if(s.index===e&&o.equalsNoCase(s["tag"],t))return s;return null}_IncrementEffectCount(t){for(const e of this._SplitTags(t)){const s=e.toLowerCase();this._effectCount.set(s,(this._effectCount.get(s)||0)+1)}}_IsSilent(){return this._isSilent}_SetSilent(t){this._isSilent!==(t=!!t)&&(this._isSilent=t,this.PostToDOM("set-silent",{"isSilent":t}))}_GetMasterVolume(){return this._masterVolume}_SetMasterVolume(t){this._masterVolume!==t&&(this._masterVolume=t,this.PostToDOM("set-master-volume",{"vol":t}))}_StopAll(){this.PostToDOM("stop-all");for(const t of this._lastAIState)t["isPlaying"]=!1}_ShouldSave(t){return!t.hasOwnProperty("placeholder")&&3!==this._saveLoadMode&&!(t["isMusic"]&&1===this._saveLoadMode||!t["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(t=>this._ShouldSave(t)),"effects":this._lastFxState,"analysers":this._lastAnalysersData}}LoadFromJson(t){if(this._isSilent=t["isSilent"],this._masterVolume=t["masterVolume"],this._listenerPos[2]=t["listenerZ"],this._listenerInst=null,this._loadListenerUid=t["listenerUid"],t.hasOwnProperty("listenerForwardVec")?this._listenerForwardVec=t["listenerForwardVec"]:this._listenerForwardVec=[0,0,-1],t.hasOwnProperty("listenerUpVec")?this._listenerUpVec=t["listenerUpVec"]:this._listenerUpVec=[0,1,0],this._remoteUrls.clear(),t["remoteUrls"])for(const[e,s]of t["remoteUrls"])this._remoteUrls.set(e,s);this._lastAIState=t["playing"];for(const i of this._lastAIState)i.hasOwnProperty("tag")&&!i.hasOwnProperty("tags")&&(i["tags"]=[i["tag"]].filter(t=>!!t));this._lastFxState=t["effects"],this._lastAnalysersData=t["analysers"]}_OnAfterLoad(){if(-1!==this._loadListenerUid&&(this._listenerInst=this._runtime.GetInstanceByUID(this._loadListenerUid),this._loadListenerUid=-1,this._listenerInst)){const t=this._listenerInst.GetWorldInfo();this._listenerPos[0]=t.GetX(),this._listenerPos[1]=t.GetY()}for(const e of this._lastAIState){const s=this._runtime.GetAssetManager().GetProjectAudioFileUrl(e["bufferOriginalUrl"]);s?(e["bufferUrl"]=s.url,e["bufferType"]=s.type):e["bufferUrl"]=null}for(const i of Object.values(this._lastFxState))for(const a of i)if(a.hasOwnProperty("bufferOriginalUrl")){const n=this._runtime.GetAssetManager().GetProjectAudioFileUrl(a["bufferOriginalUrl"]);n&&(a["bufferUrl"]=n.url,a["bufferType"]=n.type)}this.PostToDOM("load-state",{"saveLoadMode":this._saveLoadMode,"timeScale":this._runtime.GetTimeScale(),"gameTime":this._runtime.GetGameTimeRaw(),"listenerPos":this._listenerPos,"listenerOrientation":[...this._listenerForwardVec,...this._listenerUpVec],"isSilent":this._isSilent,"masterVolume":this._masterVolume,"playing":this._lastAIState.filter(t=>null!==t["bufferUrl"]),"effects":this._lastFxState})}GetDebuggerProperties(){const t=[];for(const[s,i]of Object.entries(this._lastFxState))t.push({name:"$"+s,value:i.map(t=>t["type"]).join(", ")});const e="plugins.audio.debugger";return[{title:e+".tag-effects",properties:t},{title:e+".currently-playing",properties:[{name:e+".currently-playing-count",value:this._lastAIState.length},...this._lastAIState.map((t,e)=>({name:"$#"+e,value:`${t["bufferOriginalUrl"]} ("${t["tags"]}") ${Math.round(10*t["playbackTime"])/10} / `+Math.round(10*t["duration"])/10}))]}]}}}{const x0=self.C3;x0.Plugins.Audio.Cnds={OnEnded(t){return this._MatchTriggerTag(t)},OnFadeEnded(t){return this._MatchTriggerTag(t)},PreloadsComplete(){return this._preloadCount===this._preloadTotal},AdvancedAudioSupported(){return!0},IsSilent(){return this._IsSilent()},IsAnyPlaying(){for(const t of this._lastAIState)if(t["isPlaying"])return!0;return!1},IsTagPlaying(t){return this._IsTagPlaying(t)}}}{const C0=self.C3,D0=["lowpass","highpass","bandpass","lowshelf","highshelf","peaking","notch","allpass"];C0.Plugins.Audio.Acts={Play(t,e,s,i,a){const n=C0.Plugins.Audio.Acts._DoPlay.call(this,t,e,s,i,a);return this._AddActionPromise(n),n},PlayFromTimeline(t,e,s,i){C0.Plugins.Audio.Acts._DoPlay.call(this,t,0,e,0,s,i)},async _DoPlay(t,e,s,i,a,n){if(!this._isSilent){const o=t[1],r=this._runtime.GetAssetManager().GetProjectAudioFileUrl(t[0]);if(r){const l=this._nextPlayTime,h=(this._nextPlayTime=0,this._MaybeMarkAsPlaying(t[0],a,o,0!==e,this.DbToLinear(s)));try{await this.PostToDOMAsync("play",{"originalUrl":t[0],"url":r.url,"type":r.type,"isMusic":o,"tags":this._SplitTags(a),"isLooping":0!==e,"vol":this.DbToLinear(s),"stereoPan":C0.clamp(i/100,-1,1),"pos":n||0,"off":l,"trueClock":!!self["C3_GetAudioContextCurrentTime"]})}finally{h&&(h["placeholder"]=this._runtime.GetTickCountNoSave())}}}},async PlayAtPosition(t,e,s,i,a,n,o,r,l,h,u){if(!this._isSilent){const c=t[1],d=this._runtime.GetAssetManager().GetProjectAudioFileUrl(t[0]);if(d){const _=this._nextPlayTime,p=(this._nextPlayTime=0,this._MaybeMarkAsPlaying(t[0],u,c,0!==e,this.DbToLinear(s)));try{await this.PostToDOMAsync("play",{"originalUrl":t[0],"url":d.url,"type":d.type,"isMusic":c,"tags":this._SplitTags(u),"isLooping":0!==e,"vol":this.DbToLinear(s),"pos":0,"off":_,"trueClock":!!self["C3_GetAudioContextCurrentTime"],"panning":{"x":i,"y":a,"z":n,"angle":C0.toRadians(o),"innerAngle":C0.toRadians(r),"outerAngle":C0.toRadians(l),"outerGain":this.DbToLinear(h)}})}finally{p&&(p["placeholder"]=this._runtime.GetTickCountNoSave())}}}},async PlayAtObject(t,e,s,i,a,n,o,r){if(!this._isSilent&&i){const l=i.GetFirstPicked();if(l&&l.GetWorldInfo()){const h=l.GetWorldInfo(),u=h.GetLayer().GetAngle(),[c,d]=this.rotatePtAround(h.GetX(),h.GetY(),-u,this._listenerPos[0],this._listenerPos[1]),_=t[1],p=this._runtime.GetAssetManager().GetProjectAudioFileUrl(t[0]);if(p){const f=this._nextPlayTime,g=(this._nextPlayTime=0,this._MaybeMarkAsPlaying(t[0],r,_,0!==e,this.DbToLinear(s)));try{await this.PostToDOMAsync("play",{"originalUrl":t[0],"url":p.url,"type":p.type,"isMusic":_,"tags":this._SplitTags(r),"isLooping":0!==e,"vol":this.DbToLinear(s),"pos":0,"off":f,"trueClock":!!self["C3_GetAudioContextCurrentTime"],"panning":{"x":c,"y":d,"z":h.GetTotalZElevation(),"angle":h.GetAngle()-u,"innerAngle":C0.toRadians(a),"outerAngle":C0.toRadians(n),"outerGain":this.DbToLinear(o),"uid":l.GetUID()}})}finally{g&&(g["placeholder"]=this._runtime.GetTickCountNoSave())}}}}},async PlayByName(t,e,s,i,a,n){if(!this._isSilent){const o=1===t,r=this._runtime.GetAssetManager().GetProjectAudioFileUrl(e)||this._remoteUrls.get(e.toLowerCase());if(r){const l=this._nextPlayTime,h=(this._nextPlayTime=0,this._MaybeMarkAsPlaying(e,n,o,0!==s,this.DbToLinear(i)));try{await this.PostToDOMAsync("play",{"originalUrl":e,"url":r.url,"type":r.type,"isMusic":o,"tags":this._SplitTags(n),"isLooping":0!==s,"vol":this.DbToLinear(i),"stereoPan":C0.clamp(a/100,-1,1),"pos":0,"off":l,"trueClock":!!self["C3_GetAudioContextCurrentTime"]})}finally{h&&(h["placeholder"]=this._runtime.GetTickCountNoSave())}}}},async PlayAtPositionByName(t,e,s,i,a,n,o,r,l,h,u,c){if(!this._isSilent){const d=1===t,_=this._runtime.GetAssetManager().GetProjectAudioFileUrl(e)||this._remoteUrls.get(e.toLowerCase());if(_){const p=this._nextPlayTime,f=(this._nextPlayTime=0,this._MaybeMarkAsPlaying(e,c,d,0!==s,this.DbToLinear(i)));try{await this.PostToDOMAsync("play",{"originalUrl":e,"url":_.url,"type":_.type,"isMusic":d,"tags":this._SplitTags(c),"isLooping":0!==s,"vol":this.DbToLinear(i),"pos":0,"off":p,"trueClock":!!self["C3_GetAudioContextCurrentTime"],"panning":{"x":a,"y":n,"z":o,"angle":C0.toRadians(r),"innerAngle":C0.toRadians(l),"outerAngle":C0.toRadians(h),"outerGain":this.DbToLinear(u)}})}finally{f&&(f["placeholder"]=this._runtime.GetTickCountNoSave())}}}},async PlayAtObjectByName(t,e,s,i,a,n,o,r,l){if(!this._isSilent&&!this._isSilent&&a){const h=a.GetFirstPicked();if(h&&h.GetWorldInfo()){const u=h.GetWorldInfo(),c=u.GetLayer().GetAngle(),[d,_]=this.rotatePtAround(u.GetX(),u.GetY(),-c,this._listenerPos[0],this._listenerPos[1]),p=1===t,f=this._runtime.GetAssetManager().GetProjectAudioFileUrl(e)||this._remoteUrls.get(e.toLowerCase());if(f){const g=this._nextPlayTime,m=(this._nextPlayTime=0,this._MaybeMarkAsPlaying(e,l,p,0!==s,this.DbToLinear(i)));try{await this.PostToDOMAsync("play",{"originalUrl":e,"url":f.url,"type":f.type,"isMusic":p,"tags":this._SplitTags(l),"isLooping":0!==s,"vol":this.DbToLinear(i),"pos":0,"off":g,"trueClock":!!self["C3_GetAudioContextCurrentTime"],"panning":{"x":d,"y":_,"z":u.GetTotalZElevation(),"angle":u.GetAngle()-c,"innerAngle":C0.toRadians(n),"outerAngle":C0.toRadians(o),"outerGain":this.DbToLinear(r),"uid":h.GetUID()}})}finally{m&&(m["placeholder"]=this._runtime.GetTickCountNoSave())}}}}},SetLooping(t,e){this.PostToDOM("set-looping",{"tags":this._SplitTags(t),"isLooping":0===e})},SetMuted(t,e){this.PostToDOM("set-muted",{"tags":this._SplitTags(t),"isMuted":0===e})},SetVolume(t,e){this.PostToDOM("set-volume",{"tags":this._SplitTags(t),"vol":this.DbToLinear(e)})},FadeVolume(t,e,s,i){this.PostToDOM("fade-volume",{"tags":this._SplitTags(t),"vol":this.DbToLinear(e),"duration":s,"stopOnEnd":0===i})},SetStereoPan(t,e){this.PostToDOM("set-stereo-pan",{"tags":this._SplitTags(t),"p":C0.clamp(e/100,-1,1)})},async Preload(t){const e=t[1],s=this._runtime.GetAssetManager().GetProjectAudioFileUrl(t[0]);s&&(this._preloadTotal++,await this.PostToDOMAsync("preload",{"originalUrl":t[0],"url":s.url,"type":s.type,"isMusic":e}),this._preloadCount++)},async PreloadByName(t,e){const s=1===t,i=this._runtime.GetAssetManager().GetProjectAudioFileUrl(e)||this._remoteUrls.get(e.toLowerCase());i&&(this._preloadTotal++,await this.PostToDOMAsync("preload",{"originalUrl":e,"url":i.url,"type":i.type,"isMusic":s}),this._preloadCount++)},SetPlaybackRate(t,e){this.PostToDOM("set-playback-rate",{"tags":this._SplitTags(t),"rate":Math.max(e,0)})},Stop(t){this._MaybeMarkAsStopped(t),this.PostToDOM("stop",{"tags":this._SplitTags(t)})},StopAll(){this._StopAll()},SetPaused(t,e){this.PostToDOM("set-paused",{"tags":this._SplitTags(t),"paused":0===e})},Seek(t,e){this.PostToDOM("seek",{"tags":this._SplitTags(t),"pos":e})},SetSilent(t){2===t&&(t=this._IsSilent()?1:0),this._SetSilent(0===t)},SetMasterVolume(t){const e=this.DbToLinear(t);this._SetMasterVolume(e)},AddFilterEffect(t,e,s,i,a,n,o){const r=D0[e];this._IncrementEffectCount(t),this.PostToDOM("add-effect",{"type":"filter","tags":this._SplitTags(t),"params":[r,s,i,a,n,C0.clamp(o/100,0,1)]})},AddDelayEffect(t,e,s,i){this._IncrementEffectCount(t),this.PostToDOM("add-effect",{"type":"delay","tags":this._SplitTags(t),"params":[e,this.DbToLinear(s),C0.clamp(i/100,0,1)]})},AddFlangerEffect(t,e,s,i,a,n){this._IncrementEffectCount(t),this.PostToDOM("add-effect",{"type":"flanger","tags":this._SplitTags(t),"params":[e/1e3,s/1e3,i,a/100,C0.clamp(n/100,0,1)]})},AddPhaserEffect(t,e,s,i,a,n,o){this._IncrementEffectCount(t),this.PostToDOM("add-effect",{"type":"phaser","tags":this._SplitTags(t),"params":[e,s,i,a,n,C0.clamp(o/100,0,1)]})},AddConvolutionEffect(t,e,s,i){const a=this._runtime.GetAssetManager().GetProjectAudioFileUrl(e[0]);a&&(this._IncrementEffectCount(t),this.PostToDOM("add-effect",{"type":"convolution","tags":this._SplitTags(t),"bufferOriginalUrl":e[0],"bufferUrl":a.url,"bufferType":a.type,"params":[0===s,C0.clamp(i/100,0,1)]}))},AddGainEffect(t,e){this._IncrementEffectCount(t),this.PostToDOM("add-effect",{"type":"gain","tags":this._SplitTags(t),"params":[this.DbToLinear(e)]})},AddStereoPanEffect(t,e){this._IncrementEffectCount(t),this.PostToDOM("add-effect",{"type":"stereopan","tags":this._SplitTags(t),"params":[C0.clamp(e/100,-1,1)]})},AddMuteEffect(t){this._IncrementEffectCount(t),this.PostToDOM("add-effect",{"type":"gain","tags":this._SplitTags(t),"params":[0]})},AddTremoloEffect(t,e,s){this._IncrementEffectCount(t),this.PostToDOM("add-effect",{"type":"tremolo","tags":this._SplitTags(t),"params":[e,C0.clamp(s/100,0,1)]})},AddRingModEffect(t,e,s){this._IncrementEffectCount(t),this.PostToDOM("add-effect",{"type":"ringmod","tags":this._SplitTags(t),"params":[e,C0.clamp(s/100,0,1)]})},AddDistortionEffect(t,e,s,i,a,n){this._IncrementEffectCount(t),this.PostToDOM("add-effect",{"type":"distortion","tags":this._SplitTags(t),"params":[this.DbToLinearNoCap(e),this.DbToLinearNoCap(s),i,this.DbToLinearNoCap(a),C0.clamp(n/100,0,1)]})},AddCompressorEffect(t,e,s,i,a,n){this._IncrementEffectCount(t),this.PostToDOM("add-effect",{"type":"compressor","tags":this._SplitTags(t),"params":[e,s,i,a/1e3,n/1e3]})},AddAnalyserEffect(t,e,s){this._IncrementEffectCount(t),this.PostToDOM("add-effect",{"type":"analyser","tags":this._SplitTags(t),"params":[e,s]})},RemoveEffects(t){const e=this._SplitTags(t);for(const s of e)this._effectCount.set(s.toLowerCase(),0);this.PostToDOM("remove-effects",{"tags":e}),this._lastFxState={}},SetEffectParameter(t,e,s,i,a,n){this.PostToDOM("set-effect-param",{"tags":this._SplitTags(t),"index":Math.floor(e),"param":s,"value":i,"ramp":a,"time":n})},SetListenerObject(t){if(t){const e=t.GetFirstPicked();e&&e.GetWorldInfo()&&(this._listenerInst=e)}},SetListenerZ(t){this._listenerPos[2]=t},SetListenerOrientation(t,e,s,i,a,n){this._listenerForwardVec[0]=t,this._listenerForwardVec[1]=e,this._listenerForwardVec[2]=-s,this._listenerUpVec[0]=i,this._listenerUpVec[1]=a,this._listenerUpVec[2]=-n},ScheduleNextPlay(t){this._nextPlayTime=Math.max(t,0)},UnloadAudio(t){const e=t[1],s=this._runtime.GetAssetManager().GetProjectAudioFileUrl(t[0]);s&&this.PostToDOM("unload",{"url":s.url,"type":s.type,"isMusic":e})},UnloadAudioByName(t,e){const s=1===t,i=this._runtime.GetAssetManager().GetProjectAudioFileUrl(e)||this._remoteUrls.get(e.toLowerCase());i&&this.PostToDOM("unload",{"url":i.url,"type":i.type,"isMusic":s})},UnloadAll(){this.PostToDOM("unload-all")},AddRemoteURL(t,e,s){this._remoteUrls.set(s.toLowerCase(),{url:t,type:e})}}}{const y2=self.C3;y2.Plugins.Audio.Exps={Duration(t){const e=this._GetFirstAudioStateByTags(t);return e?e["duration"]:0},PlaybackTime(t){const e=this._GetFirstAudioStateByTags(t);return e?e["playbackTime"]:0},PlaybackRate(t){const e=this._GetFirstAudioStateByTags(t);return e?e["playbackRate"]:0},Volume(t){const e=this._GetFirstAudioStateByTags(t);return e?this.LinearToDb(e["volume"]):0},MasterVolume(){return this.LinearToDb(this._GetMasterVolume())},EffectCount(t){return this._effectCount.get(t.toLowerCase())||0},AnalyserFreqBinCount(t,e){const s=this.GetAnalyserData(t,Math.floor(e));return s?s["binCount"]:0},AnalyserFreqBinAt(t,e,s){const i=this.GetAnalyserData(t,Math.floor(e));return!i||(s=Math.floor(s))<0||s>=i["binCount"]?0:i["freqBins"][s]},AnalyserPeakLevel(t,e){const s=this.GetAnalyserData(t,Math.floor(e));return s?s["peak"]:0},AnalyserRMSLevel(t,e){const s=this.GetAnalyserData(t,Math.floor(e));return s?s["rms"]:0},SampleRate(){return this._sampleRate},CurrentTime(){return self["C3_GetAudioContextCurrentTime"]?self["C3_GetAudioContextCurrentTime"]():performance.now()/1e3},OutputLatency(){return this._outputLatency},NormalizedVolume(t,e){return 0===(t=y2.clamp(+t,0,100)/100)?-1/0:t<.1?this.LinearToDb(y2.lerp(0,this.DbToLinear(e),10*t)):y2.lerp(e,0,(t-.1)/.9)}}} } // scripts/plugins/Particles/c3runtime/runtime.js { {const a=self.C3;a.Plugins.Particles=class extends a.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{const d=self.C3;d.Plugins.Particles.Type=class extends d.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){this.GetImageInfo().LoadAsset(this._runtime)}LoadTextures(e){return this.GetImageInfo().LoadStaticTexture(e,{sampling:this._runtime.GetSampling()})}ReleaseTextures(){this.GetImageInfo().ReleaseTexture()}}}{const h=self.C3,i=self.C3X,j=0,k=1,l=2,m=3,n=4,o=5,p=6,q=7,r=8,s=9,t=10,u=11,v=12,w=13,x=14,y=15,z=16,A=17,B=18,C=19,D=20,E=0,F=1,G=h.New(h.Rect),H=(h.Plugins.Particles.Instance=class extends h.SDKWorldInstanceBase{constructor(e,i){super(e),this._isFirstTick=!0;const a=h.New(self.ParticleEngine);(this._particleEngine=a).ononeshotfinish=()=>this._OnOneShotFinish(),this._spawnObjectClass=null,this._particleUpdateCallback=(e,t,i,n,a,r)=>this._OnParticleUpdate(e,t,i,n,a,r),this._particleDestroyCallback=e=>this._OnParticleDestroy(e);let c=this._hasAnyDefaultParticle=!0;i&&(a.SetRate(i[j]),a.SetSprayCone(h.toRadians(i[k])),a.SetSprayType(i[l]?"one-shot":"continuous-spray"),this._SetParticleObjectClass(this._runtime.GetObjectClassBySID(i[m])),c=i[n],a.SetInitSpeed(i[o]),a.SetInitSize(i[p]),a.SetInitOpacity(i[q]/100),a.SetGrowRate(i[r]),a.SetInitXRandom(i[s]),a.SetInitYRandom(i[t]),a.SetInitSpeedRandom(i[u]),a.SetInitSizeRandom(i[v]),a.SetGrowRandom(i[w]),a.SetAcceleration(i[x]),a.SetGravity(i[y]),a.SetLifeAngleRandom(i[z]),a.SetLifeSpeedRandom(i[A]),a.SetLifeOpacityRandom(i[B]),a.SetDestroyModeIndex(i[C]),a.SetTimeout(i[D])),this._UpdateEngineParameters(),this._spawnObjectClass&&(this._hasAnyDefaultParticle=!1),"one-shot"===a.GetSprayType()?a.CreateOneShotSpray():a.SetSpraying(!0);const S=this.GetWorldInfo();S.SetVisible(c),S.SetBboxChangeEventEnabled(!0),this._inst.Dispatcher().addEventListener("bboxchange",()=>{S.OverwriteBoundingBox(this._particleEngine.GetBoundingBox())}),this.GetRuntime().GetRenderer().IsWebGPU()&&S.SetUsePointsShaderProgram(),this._afterLoad=e=>this._OnAfterLoad(e),this.GetRuntime().Dispatcher().addEventListener("afterload",this._afterLoad),this._StartTicking()}Release(){this.GetRuntime().Dispatcher().removeEventListener("afterload",this._afterLoad),this._afterLoad=null,this._particleEngine.Release(),this._particleEngine=null,this._particleUpdateCallback=null,this._particleDestroyCallback=null,super.Release()}GetParticleEngine(){return this._particleEngine}_SetRate(e){this._particleEngine.SetRate(e),"one-shot"===this._particleEngine.GetSprayType()&&this._isFirstTick&&this._particleEngine.SetParticleCount(e)}_SetParticleObjectClass(e){(e=e===this.GetObjectClass()?null:e)===this._spawnObjectClass||(this._spawnObjectClass=e,this._particleEngine.onparticlecreate=e?e=>this._OnParticleCreate(e):null,this._spawnObjectClass)||(this._hasAnyDefaultParticle=!0)}_UpdateEngineParameters(){const e=this._particleEngine,t=this.GetWorldInfo();e.SetMasterOpacity(t.GetOpacity()),e.SetPixelRounding(this._runtime.IsPixelRoundingEnabled()),e.SetSpawnX(t.GetX()),e.SetSpawnY(t.GetY()),e.SetSpawnAngle(t.GetAngle()),e.SetInitSizeScale(Math.abs(t.GetSceneGraphScale()))}_OnOneShotFinish(){this._runtime.DestroyInstance(this._inst)}Draw(e){if(this._hasAnyDefaultParticle){const t=this._objectClass.GetImageInfo(),i=t.GetTexture();if(i){const n=this.GetWorldInfo(),a=n.GetLayer(),r=G,s=(this._runtime.GetCanvasManager().IsPastingToDrawingCanvas()?r.set(-1/0,-1/0,1/0,1/0):a.Has3DCamera()?a.CalculateViewport3D(n.GetTotalZElevation(),r):a.GetViewportForZ(n.GetTotalZElevation(),r),e.SetTexture(i),a.Get2DScaleFactorToZ(n.GetTotalZElevation()));this._particleEngine.SetParticleScale(a.GetRenderScale()*s),this._particleEngine.Draw(e,t.GetTexQuad(),r,a.Has3DCamera())}}}SaveToJson(){const e=this._particleEngine;return{"r":e.GetRate(),"sc":e.GetSprayCone(),"st":e.GetSprayType(),"isp":e.GetInitSpeed(),"isz":e.GetInitSize(),"io":e.GetInitOpacity(),"gr":e.GetGrowRate(),"xr":e.GetInitXRandom(),"yr":e.GetInitYRandom(),"spr":e.GetInitSpeedRandom(),"szr":e.GetInitSizeRandom(),"grnd":e.GetGrowRandom(),"acc":e.GetAcceleration(),"g":e.GetGravity(),"lar":e.GetLifeAngleRandom(),"lsr":e.GetLifeSpeedRandom(),"lor":e.GetLifeOpacityRandom(),"dm":e.GetDestroyModeIndex(),"to":e.GetTimeout(),"s":e.IsSpraying(),"pcc":e._GetCreateCounter(),"ft":this._isFirstTick,"soc":this._spawnObjectClass?this._spawnObjectClass.GetSID():null,"p":e.GetParticles().map(e=>e.toJSON())}}LoadFromJson(e,t){const i=this._particleEngine;if(i.SetRate(e["r"]),i.SetSprayCone(e["sc"]),i.SetSprayType(e["st"]),i.SetInitSpeed(e["isp"]),i.SetInitSize(e["isz"]),i.SetInitOpacity(e["io"]),i.SetGrowRate(e["gr"]),i.SetInitXRandom(e["xr"]),i.SetInitYRandom(e["yr"]),i.SetInitSpeedRandom(e["spr"]),i.SetInitSizeRandom(e["szr"]),i.SetGrowRandom(e["grnd"]),i.SetAcceleration(e["acc"]),i.SetGravity(e["g"]),i.SetLifeAngleRandom(e["lar"]),i.SetLifeSpeedRandom(e["lsr"]),i.SetLifeOpacityRandom(e["lor"]),i.SetDestroyModeIndex(e["dm"]),i.SetTimeout(e["to"]),i.SetSpraying(e["s"]),i._SetCreateCounter(e["pcc"]),this._isFirstTick=e["ft"],e.hasOwnProperty("soc")){const r=this.GetRuntime().GetObjectClassBySID(e["soc"]);r&&this._SetParticleObjectClass(r)}const n=e["p"],a=(i.SetParticleCount(n.length,!1),i.GetParticles());for(let e=0,t=a.length;e<t;++e)a[e].setFromJSON(n[e]);"state"===t&&this._spawnObjectClass&&(i.UpdateAllParticlesUserData(),i.ApplyParticleDataToUserData(this))}_OnAfterLoad(){const e=this._particleEngine,i=(e.UpdateAllParticlesUserData(),e.ApplyParticleDataToUserData(this),e.GetParticles());for(let e=0,t=i.length;e<t;++e){const n=i[e],a=n.GetUserData();if(a){const r=a.GetWorldInfo();if(r){const s=r.GetInstance();if(s){const o=n.GetUserDataUID(),c=s.GetUID();if(("number"!=typeof o||"number"!=typeof c||o!==c)&&"number"==typeof o){const l=this.GetRuntime(),S=l.GetInstanceByUID(o);S&&l.DestroyInstance(S)}}}}}}Tick(){const e=this._runtime.GetDt(this._inst);this._UpdateEngineParameters(),this._isFirstTick&&"one-shot"===this._particleEngine.GetSprayType()&&this._particleEngine.ReInitAllParticles(),this._particleEngine.Tick(e),this._particleEngine.IsSpraying()&&this._runtime.UpdateRender(),this.GetWorldInfo().SetBboxChanged(),this._isFirstTick=!1}_FastForward(e){for(this._isFirstTick&&"one-shot"===this._particleEngine.GetSprayType()&&this._particleEngine.ReInitAllParticles();0<e;)this._particleEngine.Tick(1/60),e-=1/60;this._particleEngine.IsSpraying()&&this._runtime.UpdateRender(),this.GetWorldInfo().SetBboxChanged(),this._isFirstTick=!1}_OnParticleCreate(e,t){let i;const n=(i=(i=(i="number"==typeof t?this._runtime.GetInstanceByUID(t):i)&&i.GetObjectClass()!==this._spawnObjectClass?null:i)||this._runtime.CreateInstance(this._spawnObjectClass,this.GetWorldInfo().GetLayer(),e.GetX(),e.GetY())).GetWorldInfo();return n.SetSize(e.GetSize(),e.GetSize()),n.SetAngle(e.GetAngle()),n.SetOpacity(e.GetOpacity()),n.SetUnpremultipliedColor(this.GetWorldInfo().GetUnpremultipliedColor()),n.SetBboxChanged(),n.ZOrderMoveAdjacentToInstance(this.GetInstance(),!0),i._TriggerOnCreated(),e.SetUpdateCallback(this._particleUpdateCallback),e.SetDestroyCallback(this._particleDestroyCallback),i}_OnParticleUpdate(e,t,i,n,a,r){if(!e.IsDestroyed()){const s=e.GetWorldInfo();s.OffsetXY(t,i),s.SetSize(s.GetWidth()+n,s.GetHeight()+n),s.SetAngle(s.GetAngle()+a),s.SetOpacity(s.GetOpacity()+r),s.SetBboxChanged()}}_OnParticleDestroy(e){e.IsDestroyed()||this._runtime.DestroyInstance(e)}GetPropertyValueByIndex(e){const i=this._particleEngine;switch(e){case j:return i.GetRate();case k:return h.toDegrees(i.GetSprayCone());case l:return"one-shot"===i.GetSprayType()?F:E;case o:return i.GetInitSpeed();case p:return i.GetInitSize();case q:return 100*i.GetInitOpacity();case r:return i.GetGrowRate();case s:return i.GetInitXRandom();case t:return i.GetInitYRandom();case u:return i.GetInitSpeedRandom();case v:return i.GetInitSizeRandom();case w:return i.GetGrowRandom();case x:return i.GetAcceleration();case y:return i.GetGravity();case z:return i.GetLifeAngleRandom();case A:return i.GetLifeSpeedRandom();case B:return i.GetLifeOpacityRandom();case C:return i.GetDestroyModeIndex();case D:return i.GetTimeout()}}SetPropertyValueByIndex(e,i){const n=this._particleEngine;switch(e){case j:n.SetRate(i);break;case k:n.SetSprayCone(h.toRadians(i));break;case l:n.SetSprayType(i?"one-shot":"continuous-spray");break;case o:n.SetInitSpeed(i);break;case p:n.SetInitSize(i);break;case q:n.SetInitOpacity(i/100);break;case r:n.SetGrowRate(i);break;case s:n.SetInitXRandom(i);break;case t:n.SetInitYRandom(i);break;case u:n.SetInitSpeedRandom(i);break;case v:n.SetInitSizeRandom(i);break;case w:n.SetGrowRandom(i);break;case x:n.SetAcceleration(i);break;case y:n.SetGravity(i);break;case z:n.SetLifeAngleRandom(i);break;case A:n.SetLifeSpeedRandom(i);break;case B:n.SetLifeOpacityRandom(i);break;case C:n.SetDestroyModeIndex(i);break;case D:n.SetTimeout(i)}}GetDebuggerProperties(){const e="plugins.particles",t=e+".properties",i=e+".debugger",n=this._particleEngine;return[{title:e+".name",properties:[{name:i+".particle-count",value:n.GetParticleCount()},{name:t+".type.name",value:[t+".type.items."+n.GetSprayType()]},{name:i+".is-spraying",value:n.IsSpraying(),onedit:e=>n.SetSpraying(e)},{name:t+".rate.name",value:n.GetRate(),onedit:e=>n.SetRate(e)},{name:t+".spray-cone.name",value:h.toDegrees(n.GetSprayCone()),onedit:e=>n.SetSprayCone(h.toRadians(e))},{name:t+".speed.name",value:n.GetInitSpeed(),onedit:e=>n.SetInitSpeed(e)},{name:t+".size.name",value:n.GetInitSize(),onedit:e=>n.SetInitSize(e)},{name:t+".opacity.name",value:n.GetInitOpacity(),onedit:e=>n.SetInitOpacity(e)},{name:t+".grow-rate.name",value:n.GetGrowRate(),onedit:e=>n.SetGrowRate(e)},{name:t+".x-randomiser.name",value:n.GetInitXRandom(),onedit:e=>n.SetInitXRandom(e)},{name:t+".y-randomiser.name",value:n.GetInitYRandom(),onedit:e=>n.SetInitYRandom(e)},{name:t+".initial-speed-randomiser.name",value:n.GetInitSpeedRandom(),onedit:e=>n.SetInitSpeedRandom(e)},{name:t+".size-randomiser.name",value:n.GetInitSizeRandom(),onedit:e=>n.SetInitSizeRandom(e)},{name:t+".grow-rate-randomiser.name",value:n.GetGrowRandom(),onedit:e=>n.SetGrowRandom(e)},{name:t+".acceleration.name",value:n.GetAcceleration(),onedit:e=>n.SetAcceleration(e)},{name:t+".gravity.name",value:n.GetGravity(),onedit:e=>n.SetGravity(e)},{name:t+".angle-randomiser.name",value:n.GetLifeAngleRandom(),onedit:e=>n.SetLifeAngleRandom(e)},{name:t+".life-speed-randomiser.name",value:n.GetLifeSpeedRandom(),onedit:e=>n.SetLifeSpeedRandom(e)},{name:t+".opacity-randomiser.name",value:n.GetLifeOpacityRandom(),onedit:e=>n.SetLifeOpacityRandom(e)},{name:t+".timeout.name",value:n.GetTimeout(),onedit:e=>n.SetTimeout(e)}]}]}GetScriptInterfaceClass(){return self.IParticlesInstance}},new WeakMap);function GetParticleEngine(e){return H.get(e).GetParticleEngine()}self.IParticlesInstance=class extends self.IWorldInstance{constructor(){super(),H.set(this,self.IInstance._GetInitInst().GetSdkInstance())}set isSpraying(e){GetParticleEngine(this).SetSpraying(!!e)}get isSpraying(){return GetParticleEngine(this).IsSpraying()}set rate(e){i.RequireFiniteNumber(e),H.get(this)._SetRate(e)}get rate(){return GetParticleEngine(this).GetRate()}set sprayCone(e){i.RequireFiniteNumber(e),GetParticleEngine(this).SetSprayCone(e)}get sprayCone(){return GetParticleEngine(this).GetSprayCone()}set initSpeed(e){i.RequireFiniteNumber(e),GetParticleEngine(this).SetInitSpeed(e)}get initSpeed(){return GetParticleEngine(this).GetInitSpeed()}set initSize(e){i.RequireFiniteNumber(e),GetParticleEngine(this).SetInitSize(e)}get initSize(){return GetParticleEngine(this).GetInitSize()}set initOpacity(e){i.RequireFiniteNumber(e),GetParticleEngine(this).SetInitOpacity(e)}get initOpacity(){return GetParticleEngine(this).GetInitOpacity()}set initXRandom(e){i.RequireFiniteNumber(e),GetParticleEngine(this).SetInitXRandom(e)}get initXRandom(){return GetParticleEngine(this).GetInitXRandom()}set initYRandom(e){i.RequireFiniteNumber(e),GetParticleEngine(this).SetInitYRandom(e)}get initYRandom(){return GetParticleEngine(this).GetInitYRandom()}set initSpeedRandom(e){i.RequireFiniteNumber(e),GetParticleEngine(this).SetInitSpeedRandom(e)}get initSpeedRandom(){return GetParticleEngine(this).GetInitSpeedRandom()}set initSizeRandom(e){i.RequireFiniteNumber(e),GetParticleEngine(this).SetInitSizeRandom(e)}get initSizeRandom(){return GetParticleEngine(this).GetInitSizeRandom()}set initGrowRate(e){i.RequireFiniteNumber(e),GetParticleEngine(this).SetGrowRate(e)}get initGrowRate(){return GetParticleEngine(this).GetGrowRate()}set initGrowRandom(e){i.RequireFiniteNumber(e),GetParticleEngine(this).SetGrowRandom(e)}get initGrowRandom(){return GetParticleEngine(this).GetGrowRandom()}set acceleration(e){i.RequireFiniteNumber(e),GetParticleEngine(this).SetAcceleration(e)}get acceleration(){return GetParticleEngine(this).GetAcceleration()}set gravity(e){i.RequireFiniteNumber(e),GetParticleEngine(this).SetGravity(e)}get gravity(){return GetParticleEngine(this).GetGravity()}set lifeAngleRandom(e){i.RequireFiniteNumber(e),GetParticleEngine(this).SetLifeAngleRandom(e)}get lifeAngleRandom(){return GetParticleEngine(this).GetLifeAngleRandom()}set lifeSpeedRandom(e){i.RequireFiniteNumber(e),GetParticleEngine(this).SetLifeSpeedRandom(e)}get lifeSpeedRandom(){return GetParticleEngine(this).GetLifeSpeedRandom()}set lifeOpacityRandom(e){i.RequireFiniteNumber(e),GetParticleEngine(this).SetLifeOpacityRandom(e)}get lifeOpacityRandom(){return GetParticleEngine(this).GetLifeOpacityRandom()}set timeout(e){i.RequireFiniteNumber(e),GetParticleEngine(this).SetTimeout(e)}get timeout(){return GetParticleEngine(this).GetTimeout()}fastForward(e){i.RequireFiniteNumber(e),H.get(this)._FastForward(e)}setParticleObjectClass(e){const t=H.get(this);e?t._SetParticleObjectClass(t.GetRuntime()._UnwrapIObjectClass(e)):t._SetParticleObjectClass(null)}}}{const N0=self.C3;N0.Plugins.Particles.Cnds={IsSpraying(){return this._particleEngine.IsSpraying()}}}{const O0=self.C3;O0.Plugins.Particles.Acts={SetSpraying(e){this._particleEngine.SetSpraying(0!==e)},SetRate(e){this._SetRate(e)},SetParticleObject(e){this._SetParticleObjectClass(e)},UnsetParticleObject(){this._SetParticleObjectClass(null)},SetSprayCone(e){this._particleEngine.SetSprayCone(O0.toRadians(e))},SetInitSpeed(e){this._particleEngine.SetInitSpeed(e)},SetInitSize(e){this._particleEngine.SetInitSize(e)},SetInitOpacity(e){this._particleEngine.SetInitOpacity(e/100)},SetGrowRate(e){this._particleEngine.SetGrowRate(e)},SetXRandomiser(e){this._particleEngine.SetInitXRandom(e)},SetYRandomiser(e){this._particleEngine.SetInitYRandom(e)},SetSpeedRandomiser(e){this._particleEngine.SetInitSpeedRandom(e)},SetSizeRandomiser(e){this._particleEngine.SetInitSizeRandom(e)},SetGrowRateRandomiser(e){this._particleEngine.SetGrowRandom(e)},SetParticleAcc(e){this._particleEngine.SetAcceleration(e)},SetGravity(e){this._particleEngine.SetGravity(e)},SetAngleRandomiser(e){this._particleEngine.SetLifeAngleRandom(e)},SetLifeSpeedRandomiser(e){this._particleEngine.SetLifeSpeedRandom(e)},SetOpacityRandomiser(e){this._particleEngine.SetLifeOpacityRandom(e)},SetTimeout(e){this._particleEngine.SetTimeout(e)},FastForward(e){this._FastForward(e)},SetEffect(e){this.GetWorldInfo().SetBlendMode(e),this._runtime.UpdateRender()}}}{const ib=self.C3;ib.Plugins.Particles.Exps={ParticleCount(){return this._particleEngine.GetParticleCount()},Rate(){return this._particleEngine.GetRate()},SprayCone(){return ib.toDegrees(this._particleEngine.GetSprayCone())},InitSpeed(){return this._particleEngine.GetInitSpeed()},InitSize(){return this._particleEngine.GetInitSize()},InitOpacity(){return 100*this._particleEngine.GetInitOpacity()},InitGrowRate(){return this._particleEngine.GetGrowRate()},XRandom(){return this._particleEngine.GetInitXRandom()},YRandom(){return this._particleEngine.GetInitYRandom()},InitSizeRandom(){return this._particleEngine.GetInitSizeRandom()},InitSpeedRandom(){return this._particleEngine.GetInitSpeedRandom()},InitGrowRandom(){return this._particleEngine.GetGrowRandom()},ParticleAcceleration(){return this._particleEngine.GetAcceleration()},Gravity(){return this._particleEngine.GetGravity()},ParticleAngleRandom(){return this._particleEngine.GetLifeAngleRandom()},ParticleSpeedRandom(){return this._particleEngine.GetLifeSpeedRandom()},ParticleOpacityRandom(){return this._particleEngine.GetLifeOpacityRandom()},Timeout(){return this._particleEngine.GetTimeout()}}} } // scripts/plugins/Particles/particleEngine.js { const C3=self.C3,inactiveParticles=[],MAX_RECYCLE_PARTICLES=1e3,VALID_SPRAY_TYPES=new Set(["continuous-spray","one-shot"]),DESTROY_MODES=["fade-to-invisible","timeout-expired","particle-stopped"],tempRect=C3.New(C3.Rect);self.ParticleEngine=class{constructor(){this._rate=0,this._sprayCone=0,this._sprayType="continuous-spray",this._isSpraying=!1,this._masterOpacity=0,this._isPixelRounding=!1,this._spawnX=0,this._spawnY=0,this._spawnAngle=0,this._initSpeed=0,this._initSize=0,this._initSizeScale=1,this._initOpacity=0,this._growRate=0,this._xRandom=0,this._yRandom=0,this._initSpeedRandom=0,this._initSizeRandom=0,this._growRandom=0,this._acceleration=0,this._gravity=0,this._lifeAngleRandom=0,this._lifeSpeedRandom=0,this._lifeOpacityRandom=0,this._destroyMode=0,this._timeout=0,this._createCounter=0,this._particleScale=1,this.ononeshotfinish=null,this.onparticlecreate=null,this._particles=[],this._boundingBox=new C3.Rect,this._color=new C3.Color}Release(){this.Cancel(),C3.clearArray(this._particles),this._particles=null,this.ononeshotfinish=null,this.onparticlecreate=null,this._boundingBox=null,this._color=null}Cancel(){const i=this._particles;for(let t=0,e=i.length;t<e;++t)i[t].Destroy();C3.appendArray(inactiveParticles,i),C3.clearArray(i),inactiveParticles.length>MAX_RECYCLE_PARTICLES&&C3.truncateArray(inactiveParticles,MAX_RECYCLE_PARTICLES),this._isSpraying=!1}CreateOneShotSpray(){for(let t=0,e=this._rate;t<e;++t)this._CreateParticle();this._particles.length&&(this._isSpraying=!0)}_CreateParticle(t=!0){let e=null;return inactiveParticles.length?(e=inactiveParticles.pop()).SetEngine(this):e=C3.New(self.Particle,this),this._particles.push(e),t?e.Init(this.onparticlecreate):e.Init(),e}ReInitAllParticles(){const i=this._particles,n=this.onparticlecreate;for(let t=0,e=i.length;t<e;++t)i[t].Init(n)}UpdateAllParticlesUserData(){const i=this._particles,n=this.onparticlecreate;for(let t=0,e=i.length;t<e;++t)i[t].UpdateUserData(n)}ApplyParticleDataToUserData(i){const n=this._particles;for(let t=0,e=n.length;t<e;++t){const s=n[t],r=s.GetUserData();if(r){const a=r.GetWorldInfo();a.SetX(s.GetX()),a.SetY(s.GetY()),a.SetSize(s.GetSize(),s.GetSize()),a.SetOpacity(s.GetOpacity()),a.SetAngle(s.GetAngle()),a.SetUnpremultipliedColor(i.GetWorldInfo().GetUnpremultipliedColor()),a.SetBboxChanged()}}}SetParticleCount(t,e=!0){const i=this._particles;if(t<i.length){const n=i.length-t;for(let t=0;t<n;++t){const s=i.pop();s.Destroy(),inactiveParticles.push(s)}inactiveParticles.length>MAX_RECYCLE_PARTICLES&&C3.truncateArray(inactiveParticles,MAX_RECYCLE_PARTICLES)}else if(t>i.length){const r=t-i.length;for(let t=0;t<r;++t)this._CreateParticle(e)}}GetParticles(){return this._particles}GetParticleCount(){return this._particles.length}Tick(t){this._SpawnContinuous(t),this._TickParticles(t),this._MaybeFinishOneShot()}_SpawnContinuous(t){if("continuous-spray"===this._sprayType&&this._isSpraying){this._createCounter+=t*this._rate;const e=Math.floor(this._createCounter);this._createCounter-=e;for(let t=0;t<e;++t)this._CreateParticle()}}_SetCreateCounter(t){this._createCounter=t}_GetCreateCounter(){return this._createCounter}_TickParticles(i){const n=this._boundingBox,s=(n.set(this._spawnX,this._spawnY,this._spawnX,this._spawnY),this._particles);let r=0;for(let t=0,e=s.length;t<e;++t){const a=s[t];(s[r]=a).Tick(i),a.IsActive()?(++r,n.expandToContain(a.GetBoundingBox())):(a.Destroy(),inactiveParticles.push(a))}C3.truncateArray(s,r),inactiveParticles.length>MAX_RECYCLE_PARTICLES&&C3.truncateArray(inactiveParticles,MAX_RECYCLE_PARTICLES)}_MaybeFinishOneShot(){"one-shot"===this._sprayType&&0===this._particles.length&&this._isSpraying&&(this.ononeshotfinish&&this.ononeshotfinish(),this._isSpraying=!1)}Draw(i,n,s,r){tempRect.set(n.getTlx(),n.getTly(),n.getBrx(),n.getBry()),i.StartRenderingPoints(tempRect),this._color.copy(i.GetColor());const a=this._particles;for(let t=0,e=a.length;t<e;++t){const o=a[t];s.intersectsRect(o.GetBoundingBox())&&o.Draw(i,n,r)}i.FinishRenderingPoints()}GetColor(){return this._color}SetRate(t){this._rate=+t}GetRate(){return this._rate}SetSprayCone(t){this._sprayCone=+t}GetSprayCone(){return this._sprayCone}SetSprayType(t){if(!VALID_SPRAY_TYPES.has(t))throw new Error("invalid spray type");this._sprayType=t}GetSprayType(){return this._sprayType}SetSpraying(t){this._isSpraying=!!t}IsSpraying(){return this._isSpraying}SetMasterOpacity(t){this._masterOpacity=+t}GetMasterOpacity(){return this._masterOpacity}SetPixelRounding(t){this._isPixelRounding=!!t}IsPixelRounding(){return this._isPixelRounding}SetSpawnX(t){this._spawnX=+t}GetSpawnX(){return this._spawnX}SetSpawnY(t){this._spawnY=+t}GetSpawnY(){return this._spawnY}SetSpawnAngle(t){this._spawnAngle=+t}GetInitAngle(){return this._spawnAngle}SetInitSpeed(t){this._initSpeed=+t}GetInitSpeed(){return this._initSpeed}SetInitSize(t){this._initSize=+t}GetInitSize(){return this._initSize}SetInitSizeScale(t){this._initSizeScale=+t}GetInitSizeScale(){return this._initSizeScale}SetInitOpacity(t){this._initOpacity=+t}GetInitOpacity(){return this._initOpacity}SetGrowRate(t){this._growRate=+t}GetGrowRate(){return this._growRate}SetInitXRandom(t){this._xRandom=+t}GetInitXRandom(){return this._xRandom}SetInitYRandom(t){this._yRandom=+t}GetInitYRandom(){return this._yRandom}SetInitSpeedRandom(t){this._initSpeedRandom=+t}GetInitSpeedRandom(){return this._initSpeedRandom}SetInitSizeRandom(t){this._initSizeRandom=+t}GetInitSizeRandom(){return this._initSizeRandom}SetGrowRandom(t){this._growRandom=+t}GetGrowRandom(){return this._growRandom}SetAcceleration(t){this._acceleration=+t}GetAcceleration(){return this._acceleration}SetGravity(t){this._gravity=+t}GetGravity(){return this._gravity}SetLifeAngleRandom(t){this._lifeAngleRandom=+t}GetLifeAngleRandom(){return this._lifeAngleRandom}SetLifeSpeedRandom(t){this._lifeSpeedRandom=+t}GetLifeSpeedRandom(){return this._lifeSpeedRandom}SetLifeOpacityRandom(t){this._lifeOpacityRandom=+t}GetLifeOpacityRandom(){return this._lifeOpacityRandom}SetDestroyMode(t){let e=DESTROY_MODES.indexOf(t);if(-1===e)throw new Error("invalid destroy mode");this._destroyMode=e}SetDestroyModeIndex(t){this.SetDestroyMode(DESTROY_MODES[t])}GetDestroyMode(){return DESTROY_MODES[this._destroyMode]}GetDestroyModeIndex(){return this._destroyMode}SetTimeout(t){this._timeout=+t}GetTimeout(){return this._timeout}SetParticleScale(t){this._particleScale=+t}GetParticleScale(){return this._particleScale}GetBoundingBox(){return this._boundingBox}}; } // scripts/plugins/Particles/particle.js { const C3=self.C3,ParticleEngine=self.ParticleEngine;function randomOffset(t){return Math.random()*t-t/2}const tmpQuad=new C3.Quad,tmpColor=new C3.Color,DPR=self.devicePixelRatio||1;let didChangeColor=!1;self.Particle=class{constructor(t){this._engine=t,this._isActive=!1,this._x=0,this._y=0,this._speed=0,this._angle=0,this._opacity=1,this._lastOpacity=0,this._grow=0,this._size=0,this._halfSize=0,this._gs=0,this._age=0,this._bbox=new C3.Rect,this._userData=null,this._userDataUid=NaN,this._updateCallback=null,this._destroyCallback=null}SetEngine(t){this._engine=t}Init(t){const e=this._engine;this._isActive=!0,this._x=e.GetSpawnX()+randomOffset(e.GetInitXRandom()),this._y=e.GetSpawnY()+randomOffset(e.GetInitYRandom()),this._speed=e.GetInitSpeed()+randomOffset(e.GetInitSpeedRandom()),this._angle=e.GetInitAngle()+randomOffset(e.GetSprayCone()),this._opacity=e.GetInitOpacity(),this._lastOpacity=this._opacity,this._size=(e.GetInitSize()+randomOffset(e.GetInitSizeRandom()))*e.GetInitSizeScale(),this._halfSize=this._size/2,this._grow=e.GetGrowRate()+randomOffset(e.GetGrowRandom()),this._gs=0,this._age=0,this._UpdateBoundingBox(),t?this._userData||(this._userData=t(this)):(this._userData=null,this._updateCallback=null,this._destroyCallback=null)}UpdateUserData(t){t?this._userData&&!this._userData.IsDestroyed()||(this._userData=t(this,this._userDataUid)):(this._userData=null,this._updateCallback=null,this._destroyCallback=null)}SetUpdateCallback(t){this._updateCallback=t}SetDestroyCallback(t){this._destroyCallback=t}Destroy(){const t=this._destroyCallback;t&&t(this._userData),this._userData=null,this._updateCallback=null,this._destroyCallback=null}toJSON(){let t;return this._userData&&this._userData.GetWorldInfo()&&(t=this._userData.GetWorldInfo().GetInstance().GetUID()),[this._x,this._y,this._speed,this._angle,this._opacity,this._grow,this._size,this._gs,this._age,t]}setFromJSON(t){this._x=t[0],this._y=t[1],this._speed=t[2],this._angle=t[3],this._opacity=t[4],this._lastOpacity=this._opacity,this._grow=t[5],this._size=t[6],this._gs=t[7],this._age=t[8],this._userDataUid=t[9],this._halfSize=this._size/2,this._UpdateBoundingBox()}Tick(t){const e=this._engine,i=this._speed*t,s=this._angle,a=Math.cos(s)*i,h=Math.sin(s)*i+this._gs*t,_=(this._x+=a,this._y+=h,this._grow*t),n=(this._size+=_,this._halfSize=this._size/2,this._speed+=e.GetAcceleration()*t,this._gs+=e.GetGravity()*t,this._age+=t,this._UpdateBoundingBox(),e.GetLifeAngleRandom()),o=e.GetLifeSpeedRandom(),l=e.GetLifeOpacityRandom();let r=0;0!==n&&(r=randomOffset(n*t),this._angle+=r),0!==o&&(this._speed+=randomOffset(o*t)),0!==l&&(this._opacity=C3.clamp(this._opacity+randomOffset(l*t),0,1));const d=1<=this._size&&(2===e.GetDestroyModeIndex()?0<this._speed:this._age<e.GetTimeout()),c=this._updateCallback;if(c&&d){let t=e.GetMasterOpacity()*this._opacity;0===e.GetDestroyModeIndex()&&(t*=1-this._age/e.GetTimeout());const u=t-this._lastOpacity;this._lastOpacity=t,c(this._userData,a,h,_,r,u)}this._isActive=d}IsActive(){return this._isActive}GetBoundingBox(){return this._bbox}_UpdateBoundingBox(){const t=this._x,e=this._y,i=this._halfSize;this._bbox.set(t-i,e-i,t+i,e+i)}Draw(s,a,h){if(!this._userData){const _=this._engine;let i=_.GetMasterOpacity()*this._opacity;if(0===_.GetDestroyModeIndex()&&(i*=1-this._age/_.GetTimeout()),!(i<=0)){const n=this._size,o=n*_.GetParticleScale()*DPR;if(!(o<1)){let t=this._x,e=this._y;_.IsPixelRounding()&&(t=t+.5|0,e=e+.5|0),s.IsWebGPU()?s.Point(t,e,n,i):h||o>s.GetMaxPointSize()||o<s.GetMinPointSize()?(tmpColor.copy(_.GetColor()),tmpColor.multiplyAlpha(i),s.SetColor(tmpColor),didChangeColor=!0,tmpQuad.setFromRect(this._bbox),s.Quad4(tmpQuad,a)):(didChangeColor&&(s.SetColor(_.GetColor()),didChangeColor=!1),s.Point(t,e,o,i))}}}}GetUserData(){return this._userData}GetUserDataUID(){return this._userDataUid}GetX(){return this._x}GetY(){return this._y}GetSize(){return this._size}GetAngle(){return this._angle}GetOpacity(){return this._opacity}}; } // scripts/plugins/Text/c3runtime/runtime.js { {const a=self.C3;a.Plugins.Text=class extends a.SDKPluginBase{constructor(e){super(e)}Release(){super.Release()}}}{const d=self.C3;d.Plugins.Text.Type=class extends d.SDKTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}LoadTextures(e){}ReleaseTextures(){}}}{const h=self.C3,i=self.C3X,j=[0,0,0],k=0,l=1,m=2,n=3,o=4,p=5,q=6,r=7,s=8,t=9,u=10,v=11,w=12,x=13,y=14,z=15,A=["left","center","right"],B=["top","center","bottom"],C=["ltr","rtl"],D=["word","cjk","character"],E=new h.Rect,F=new h.Quad,G=new h.Color,H=h.New(h.Vector2),I=new Map([["b","strong"],["i","em"],["s","s"],["u","u"],["iconoffsety",null]]),J=(h.Plugins.Text.Instance=class extends h.SDKWorldInstanceBase{constructor(e,i){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=h.New(h.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=h.New(h.Gfx.RendererText,this._runtime.GetRenderer(),{timeout:5}),this._rendererText.ontextureupdate=()=>this._runtime.UpdateRender(),this._animationframeimagechange_handler=()=>this._OnIconObjectClassImageChanged(),this._pendingUpdateIconSet=!1,i){this._text=i[k],this._enableBBcode=!!i[l],this._faceName=i[m],this._ptSize=i[n],this._lineHeightOffset=i[o],this._isBold=!!i[p],this._isItalic=!!i[q],this._horizontalAlign=i[s],this._verticalAlign=i[t],this._wrapMode=D[i[u]],this._textDirection=i[v],this._SetIconObjectClass(this._runtime.GetObjectClassBySID(i[w]));const a=i[r];this._color.setRgb(a[0],a[1],a[2]),this.GetWorldInfo().SetVisible(i[x]),this._readAloud=!!i[z]}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(A[this._horizontalAlign]),e.SetVerticalAlignment(B[this._verticalAlign]),e.SetWordWrapMode(this._wrapMode),e.SetTextDirection(C[this._textDirection])}_UpdateTextSize(){const e=this.GetWorldInfo(),t=(this._rendererText.SetFontSize(this._ptSize),this._rendererText.SetFontSizeScale(e.GetSceneGraphScale()),e.GetLayer());let i;"auto"===this._resolutionMode?i=t.GetResolutionScaleFactorToZ(e.GetTotalZElevation()):"fixed"===this._resolutionMode&&(i=this._fixedScaleFactor),e.HasMesh()&&i!==this._rendererText.GetZoom()&&e.SetMeshChanged(!0),this._rendererText.SetSize(e.GetWidth(),e.GetHeight(),i)}_SetIconObjectClass(e){e&&(e.IsFamily()||e.GetPlugin().constructor!==h.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=h.BBString.StripAnyTags(e)),this._screenReaderText?this._screenReaderText.SetText(e):this._screenReaderText=h.New(h.ScreenReaderText,this._runtime,e)}else this._screenReaderText&&(this._screenReaderText.Release(),this._screenReaderText=null)}Draw(e){const t=this.GetWorldInfo(),i=(this._UpdateTextSize(),this._pendingUpdateIconSet&&(this._pendingUpdateIconSet=!1,this._rendererText.IsBBCodeEnabled())&&this._iconObjectClass&&this._rendererText.SetIconSet(this.GetRuntime().GetTextIconSet(this._iconObjectClass)),this._rendererText.GetTexture());if(i){const s=t.GetLayer();if(0===t.GetAngle()&&0===s.GetAngle()&&0===t.GetTotalZElevation()&&!t.HasMesh()&&s.RendersIn2DMode()){const r=t.GetBoundingQuad(),[n,a]=s.LayerToDrawSurface(r.getTlx(),r.getTly()),[o,h]=s.LayerToDrawSurface(r.getBrx(),r.getBry()),_=n-Math.round(n),l=a-Math.round(a),[c,d]=(E.set(n,a,o,h),E.offset(-_,-l),F.setFromRect(E),e.GetRenderTargetSize(e.GetRenderTarget()));this._runtime.GetCanvasManager().SetDeviceTransform(e,c,d),e.SetTexture(i),e.Quad3(F,this._rendererText.GetTexRect()),s._SetTransform(e)}else e.SetTexture(i),t.HasMesh()?this._DrawMesh(t,e):this._DrawStandard(t,e)}}_DrawStandard(e,t){let i=e.GetBoundingQuad();this._runtime.IsPixelRoundingEnabled()&&(i=this._PixelRoundQuad(i)),t.Quad3(i,this._rendererText.GetTexRect())}_DrawMesh(t,e){const i=t.GetTransformedMesh();if(t.IsMeshChanged()){t.CalculateBbox(E,F,!1);let e=F;this._runtime.IsPixelRoundingEnabled()&&(e=this._PixelRoundQuad(e)),i.CalculateTransformedMesh(t.GetSourceMesh(),e,this._rendererText.GetTexRect()),t.SetMeshChanged(!1)}i.Draw(e)}_PixelRoundQuad(e){const t=e.getTlx()-Math.round(e.getTlx()),i=e.getTly()-Math.round(e.getTly());return 0==t&&0==i?e:(F.copy(e),F.offset(-t,-i),F)}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 i=e["tw"];this._typewriterStartTime=i["st"],this._typewriterEndTime=i["en"],this._typewriterLength=i["l"]}if(e.hasOwnProperty("ioc")){const s=this.GetRuntime().GetObjectClassBySID(e["ioc"]);s&&this._SetIconObjectClass(s)}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 k:return this.GetText();case l:return this._enableBBcode;case m:return this._GetFontFace();case n:return this._GetFontSize();case o:return this._GetLineHeight();case p:return this._IsBold();case q:return this._IsItalic();case r:return j[0]=this._color.getR(),j[1]=this._color.getG(),j[2]=this._color.getB(),j;case s:return this._GetHAlign();case t:return this._GetVAlign();case u:return this._GetWrapMode();case z:return this._IsReadAloud()}}SetPropertyValueByIndex(e,i){switch(e){case k:this._SetText(i);break;case l:this._enableBBcode!==!!i&&(this._enableBBcode=!!i,this._UpdateTextSettings());break;case m:this._SetFontFace(i);break;case n:this._SetFontSize(i);break;case o:this._SetLineHeight(i);break;case p:this._SetBold(i);break;case q:this._SetItalic(i);break;case r:const a=this._color,h=i;a.getR()===h[0]&&a.getG()===h[1]&&a.getB()===h[2]||(this._color.setRgb(h[0],h[1],h[2]),this._UpdateTextSettings());break;case s:this._SetHAlign(i);break;case t:this._SetVAlign(i);break;case u:this._SetWrapMode(i)}}SetPropertyColorOffsetValueByIndex(e,t,i,s){0===t&&0===i&&0===s||e===r&&(this._color.addRgb(t,i,s),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(h.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){this._isBold!==(e=!!e)&&(this._isBold=e,this._rendererText.SetBold(e),this._runtime.UpdateRender())}_IsBold(){return this._isBold}_SetItalic(e){this._isItalic!==(e=!!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(D[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 i=this.GetWorldInfo(),s=(H.set(e-i.GetX(),t-i.GetY()),H.rotate(-i.GetAngle()),H.offset(i.GetWidth()*i.GetOriginX(),i.GetHeight()*i.GetOriginY()),H.divide(i.GetWidth(),i.GetHeight()),H.scale(this._rendererText.GetWidth(),this._rendererText.GetHeight()),this._rendererText.HitTestFragment(H.getX(),H.getY()));if(s){const r=s.GetStyleTag("tag");if(r)return r.param}return""}_HasTagAtPosition(e,t,i){const s=this._GetTagAtPosition(t,i);return s&&h.equalsNoCase(e,s)}_GetTagPosition(e,t){this._UpdateTextSize(),t=Math.floor(t);const i=this._rendererText.FindFragmentWithTag(e,t);if(!i)return null;const s=this.GetWorldInfo(),r=this._rendererText.GetDrawScale(),n=i.GetPosX(),a=i.GetPosY()-(i.GetHeight()-i.GetFontBoundingBoxDescent())*r,o=i.GetWidth()*r/this._rendererText.GetWidth()*s.GetWidth(),h=i.GetHeight()*r/this._rendererText.GetHeight()*s.GetHeight();return H.set(n,a),H.divide(this._rendererText.GetWidth(),this._rendererText.GetHeight()),H.scale(s.GetWidth(),s.GetHeight()),H.offset(-s.GetWidth()*s.GetOriginX(),-s.GetHeight()*s.GetOriginY()),H.rotate(s.GetAngle()),H.offset(s.GetX(),s.GetY()),{x:H.getX(),y:H.getY(),width:o,height:h}}_GetTagCount(e){return this._UpdateTextSize(),this._rendererText.CountFragmentsWithTag(e)}_GetHTMLCloseTag(e){let t=I.get(e);return null===t?"":`</${(t=t||"span")||"span"}>`}_GetHTMLOpenTag(e,t){let i=I.get(e);if(null===i)return"";switch(i=i||"span",e){case"color":return`<${i} style="color: ${t}">`;case"font":return`<${i} style="font-family: '${t}'">`;case"opacity":return`<${i} style="opacity: ${t}%">`;case"size":return`<${i} style="font-size: ${t}pt">`;case"background":return`<${i} style="background-color: ${t}">`;case"hide":return`<${i} style="visibility: hidden">`;case"class":return`<${i} class="${t}">`;case"tag":return`<${i} data-tag="${t}">`;default:return`<${i}>`}}async _UpdateHTMLString(){if(!this._isHtmlStringUpToDate){const e=new h.BBString(this._text,{noEscape:!0}).toFragmentList(),t=new Map;let i='<span class="c3-text"';const s=[],r=(s.push(`font-family: '${this._GetFontFace()}';`),this._IsBold()&&s.push("font-weight: bold;"),this._IsItalic()&&s.push("font-style: italic;"),"character"===this._GetWrapMode()&&s.push("word-break: break-all;"),i+=` style="${s.join(" ")}">`,this._iconObjectClass?this.GetRuntime().GetTextIconSet(this._iconObjectClass):null);if(this._iconObjectClass){const o=h.New(h.PromiseThrottle),_=[],l=new Map;for(const d of e)if(d.IsIcon()){const g=d.GetTextIcon(r);if(g){const u=g.GetSource(),T=u.GetImageInfo().GetImageAsset();l.has(T)||(l.set(T,null),_.push(o.Add(async()=>{const e=await T.LoadToDrawable();l.set(T,e)})))}}await Promise.all(_);const c=[];for(const S of e)if(S.IsIcon()){const p=S.GetTextIcon(r);if(p){const x=p.GetSource(),G=x.GetImageInfo().GetImageAsset();c.push(o.Add(async()=>{const e=await x.GetImageInfo().ExtractImageToBlobURL(l.get(G));t.set(p,e)}))}}await Promise.all(c);for(const m of l.values())m instanceof ImageBitmap&&m["close"]&&m["close"]()}const n=new Map;for(const f of e){const w=f.GetStyleMap();let e=[...n.keys()];e.reverse();for(const I of e)w.has(I)&&w.get(I)===n.get(I)||(n.delete(I),i+=this._GetHTMLCloseTag(I));for(const[R,y]of w)n.has(R)||(n.set(R,y),i+=this._GetHTMLOpenTag(R,y));if(f.IsText()&&(i+=h.ReplaceAll(h.EscapeHTML(f.GetCharacterArray().join("")),"\n","<br>")),f.IsIcon()&&r){const b=f.GetTextIcon(r);if(b){const C=t.get(b);if(C){const s=[];let t="0.2em";const F=w.get("iconoffsety");if(F){let e=F.trim();t=e.endsWith("%")?parseFloat(e)/100+"em":e+"px"}s.push("top: "+t),"nearest"===this._runtime.GetSampling()&&s.push("image-rendering: pixelated"),i+=`<img class="c3-text-icon" data-icon="${f.GetIconParameter()}" width="${b.GetWidth()}" height="${b.GetHeight()}" style="${s.join(";")}" src="${C}">`}}}}const a=[...n.keys()];a.reverse();for(const A of a)i+=this._GetHTMLCloseTag(A);i+="</span>",this._htmlString=i,this._isHtmlStringUpToDate=!0}return this._htmlString}Tick(){const t=this._runtime.GetWallTime();if(t>=this._typewriterEndTime)this._CancelTypewriter(),this.Trigger(h.Plugins.Text.Cnds.OnTypewriterTextFinished),this._runtime.UpdateRender();else{let e=h.relerp(this._typewriterStartTime,this._typewriterEndTime,t,0,this._typewriterLength);(e=Math.floor(e))!==this._rendererText.GetDrawMaxCharacterCount()&&(this._rendererText.SetDrawMaxCharacterCount(e),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)}]}]}GetScriptInterfaceClass(){return self.ITextInstance}},new WeakMap),K=new Map([["left",0],["center",1],["right",2]]),L=new Map([["top",0],["center",1],["bottom",2]]),M=["ltr","rtl"],N=new Set(["auto","fixed"]);self.ITextInstance=class extends self.IWorldInstance{constructor(){super(),J.set(this,self.IInstance._GetInitInst().GetSdkInstance())}get text(){return J.get(this).GetText()}set text(e){i.RequireString(e);const t=J.get(this);t._CancelTypewriter(),t._SetText(e)}typewriterText(e,t){i.RequireString(e),i.RequireFiniteNumber(t);const s=J.get(this);s._CancelTypewriter(),s._StartTypewriter(e,t)}typewriterFinish(){J.get(this)._FinishTypewriter()}set fontFace(e){i.RequireString(e),J.get(this)._SetFontFace(e)}get fontFace(){return J.get(this)._GetFontFace()}set isBold(e){J.get(this)._SetBold(e)}get isBold(){return J.get(this)._IsBold()}set isItalic(e){J.get(this)._SetItalic(e)}get isItalic(){return J.get(this)._IsItalic()}set sizePt(e){i.RequireFiniteNumber(e),J.get(this)._SetFontSize(e)}get sizePt(){return J.get(this)._GetFontSize()}set fontColor(e){if(i.RequireArray(e),e.length<3)throw new Error("expected 3 elements");G.setRgb(e[0],e[1],e[2]),J.get(this)._SetFontColor(G)}get fontColor(){const e=J.get(this)._GetFontColor();return[e.getR(),e.getG(),e.getB()]}set lineHeight(e){i.RequireFiniteNumber(e),J.get(this)._SetLineHeight(e)}get lineHeight(){return J.get(this)._GetLineHeight()}set horizontalAlign(e){i.RequireString(e);const t=K.get(e);if(void 0===t)throw new Error("invalid mode");J.get(this)._SetHAlign(t)}get horizontalAlign(){return A[J.get(this)._GetHAlign()]}set verticalAlign(e){i.RequireString(e);const t=L.get(e);if(void 0===t)throw new Error("invalid mode");J.get(this)._SetVAlign(t)}get verticalAlign(){return B[J.get(this)._GetVAlign()]}set wordWrapMode(e){if(!D.includes(e))throw new Error("invalid mode");J.get(this)._SetWrapMode(e)}get wordWrapMode(){return J.get(this)._GetWrapMode()}set textDirection(e){i.RequireString(e);const t=M.indexOf(e);if(-1===t)throw new Error("invalid text direction");J.get(this)._SetTextDirection(t)}get textDirection(){return M[J.get(this)._GetTextDirection()]}set readAloud(e){J.get(this)._SetReadAloud(!!e)}get readAloud(){return J.get(this)._IsReadAloud()}setFixedResolutionMode(e){i.RequireFiniteNumber(e);const t=J.get(this);t._SetResolutionMode("fixed"),t._SetFixedScaleFactor(e)}setAutoResolutionMode(){J.get(this)._SetResolutionMode("auto")}get textWidth(){return J.get(this)._GetTextWidth()}get textHeight(){return J.get(this)._GetTextHeight()}getTextSize(){const e=J.get(this);return[e._GetTextWidth(),e._GetTextHeight()]}hasTagAtPosition(e,t,s){return i.RequireString(e),i.RequireFiniteNumber(t),i.RequireFiniteNumber(s),J.get(this)._HasTagAtPosition(e,t,s)}getTagAtPosition(e,t){return i.RequireFiniteNumber(e),i.RequireFiniteNumber(t),J.get(this)._GetTagAtPosition(e,t)}getTagPositionAndSize(e,t=0){return i.RequireString(e),i.RequireFiniteNumber(t),J.get(this)._GetTagPosition(e,t)}getTagCount(e){return i.RequireString(e),J.get(this)._GetTagCount(e)}changeIconSet(e){const t=J.get(this),i=t.GetRuntime()._UnwrapIObjectClass(e);t._SetIconObjectClass(i)}getAsHtmlString(){return J.get(this)._UpdateHTMLString()}}}{const Tb=self.C3;Tb.Plugins.Text.Cnds={CompareText(e,t){return t?this._text===e:Tb.equalsNoCase(this._text,e)},IsRunningTypewriterText(){return-1!==this._typewriterEndTime},OnTypewriterTextFinished(){return!0},HasTagAtPosition(e,t,i){return this._HasTagAtPosition(e,t,i)}}}{const Zb=self.C3,$b=Zb.New(Zb.Color);Zb.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(),(e=(e="number"==typeof e&&e<1e9?Math.round(1e10*e)/1e10:e).toString())&&this._SetText(this._text+e)},TypewriterText(e,t){this._CancelTypewriter(),"number"==typeof e&&e<1e9&&(e=Math.round(1e10*e)/1e10),this._StartTypewriter(e.toString(),t)},SetFontFace(e,t){let i=!1,s=!1;switch(t){case 1:i=!0;break;case 2:s=!0;break;case 3:i=!0,s=!0}e===this._faceName&&i===this._isBold&&s===this._isItalic||(this._SetFontFace(e),this._SetBold(i),this._SetItalic(s))},SetFontSize(e){this._SetFontSize(e)},SetFontColor(e){$b.setFromRgbValue(e),$b.clamp(),this._SetFontColor($b)},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 v1=self.C3;v1.Plugins.Text.Exps={Text(){return this._text},PlainText(){return this._enableBBcode?v1.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 i=this._GetTagPosition(e,t);return i?i.x:0},TagY(e,t){const i=this._GetTagPosition(e,t);return i?i.y:0},TagWidth(e,t){const i=this._GetTagPosition(e,t);return i?i.width:0},TagHeight(e,t){const i=this._GetTagPosition(e,t);return i?i.height:0},AsHTML(){return this._htmlString}}} } // scripts/behaviors/Car/c3runtime/runtime.js { {const a=self.C3;a.Behaviors.Car=class extends a.SDKBehaviorBase{constructor(e){super(e)}Release(){super.Release()}}}{const d=self.C3;d.Behaviors.Car.Type=class extends d.SDKBehaviorTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const g=self.C3,h=self.C3X,i=self.IBehaviorInstance,j=0,k=1,l=2,m=3,n=4,o=5,p=6,q=7,r=8,s=9,t=(g.Behaviors.Car.Instance=class extends g.SDKBehaviorInstanceBase{constructor(e,t){super(e);const i=this.GetWorldInfo(),h=(this._upKey=!1,this._downKey=!1,this._leftKey=!1,this._rightKey=!1,this._ignoreInput=!1,this._simUp=!1,this._simDown=!1,this._simLeft=!1,this._simRight=!1,i.GetAngle());this._s=0,this._a=h,this._m=h,this._lastX=i.GetX(),this._lastY=i.GetY(),this._lastAngle=h,this._maxSpeed=300,this._acc=200,this._dec=300,this._steerSpeed=g.toRadians(225),this._driftRecover=g.toRadians(185),this._friction=.4,this._turnWhileStopped=!1,this._setAngle=!0,this._defaultControls=!0,this._isEnabled=!0,t&&(this._maxSpeed=t[j],this._acc=t[k],this._dec=t[l],this._steerSpeed=g.toRadians(t[m]),this._driftRecover=g.toRadians(t[n]),this._friction=t[o],this._turnWhileStopped=t[p],this._setAngle=!!t[q],this._defaultControls=!!t[r],this._isEnabled=!!t[s]),this._isEnabled&&this._StartTicking(),this._defaultControls&&this._BindEvents()}_BindEvents(){if(!this._disposables){const e=this._runtime.Dispatcher();this._disposables=new g.CompositeDisposable(g.Disposable.From(e,"keydown",e=>this._OnKeyDown(e.data)),g.Disposable.From(e,"keyup",e=>this._OnKeyUp(e.data)),g.Disposable.From(e,"window-blur",()=>this._OnWindowOrKeyboardBlur()),g.Disposable.From(e,"keyboard-blur",()=>this._OnWindowOrKeyboardBlur()))}}_UnBindEvents(){this._disposables&&(this._disposables.Release(),this._disposables=null)}Release(){super.Release()}_OnKeyDown(e){switch(e["key"]){case"ArrowLeft":this._leftKey=!0;break;case"ArrowUp":this._upKey=!0;break;case"ArrowRight":this._rightKey=!0;break;case"ArrowDown":this._downKey=!0}}_OnKeyUp(e){switch(e["key"]){case"ArrowLeft":this._leftKey=!1;break;case"ArrowUp":this._upKey=!1;break;case"ArrowRight":this._rightKey=!1;break;case"ArrowDown":this._downKey=!1}}_OnWindowOrKeyboardBlur(){this._upKey=!1,this._downKey=!1,this._leftKey=!1,this._rightKey=!1}SaveToJson(){return{"ii":this._ignoreInput,"e":this._isEnabled,"s":this._s,"a":this._a,"m":this._m,"ms":this._maxSpeed,"acc":this._acc,"dec":this._dec,"ss":this._steerSpeed,"dr":this._driftRecover,"f":this._friction,"sa":this._setAngle,"dc":this._defaultControls,"lx":this._lastX,"ly":this._lastY,"la":this._lastAngle}}LoadFromJson(e){this._ignoreInput=e["ii"],this._SetEnabled(e["e"]),this._s=e["s"],this._a=e["a"],this._m=e["m"],this._maxSpeed=e["ms"],this._acc=e["acc"],this._dec=e["dec"],this._steerSpeed=e["ss"],this._driftRecover=e["dr"],this._friction=e["f"],this._setAngle=e["sa"],this._defaultControls=e["dc"],this._lastX=e["lx"],this._lastY=e["ly"],this._lastAngle=e["la"],this._upKey=!1,this._downKey=!1,this._leftKey=!1,this._rightKey=!1,this._simUp=!1,this._simDown=!1,this._simLeft=!1,this._simRight=!1,this._defaultControls?this._BindEvents():this._UnBindEvents()}Tick(){const s=this._runtime.GetDt(this._inst),i=this.GetWorldInfo(),r=this._runtime.GetCollisionEngine();let h=this._leftKey||this._simLeft,n=this._rightKey||this._simRight,a=this._upKey||this._simUp,_=this._downKey||this._simDown;if(this._simLeft=!1,this._simRight=!1,this._simUp=!1,this._simDown=!1,this._isEnabled){const e=i.GetAngle(),t=(this._setAngle&&e!==this._lastAngle&&(this._a=e,this._m=e,this._lastAngle=e),r.TestOverlapSolid(this._inst));if(!t||(r.RegisterCollision(this._inst,t),r.PushOutSolidNearest(this._inst))){if(this._ignoreInput&&(h=!1,n=!1,a=!1,_=!1),a&&!_&&(this._s+=this._acc*s,this._s>this._maxSpeed)&&(this._s=this._maxSpeed),_&&!a&&(this._s-=this._dec*s,this._s<-this._maxSpeed)&&(this._s=-this._maxSpeed),_===a&&(0<this._s?(this._s-=this._dec*s*.1,this._s<0&&(this._s=0)):this._s<0&&(this._s+=this._dec*s*.1,0<this._s)&&(this._s=0)),this._s<0&&!this._turnWhileStopped){const l=h;h=n,n=l}let e=1,t=(this._turnWhileStopped||(e=Math.abs(this._s)/this._maxSpeed,Number.isFinite(e))||(e=0),h&&!n&&(this._a=g.clampAngle(this._a-this._steerSpeed*s*e)),n&&!h&&(this._a=g.clampAngle(this._a+this._steerSpeed*s*e)),this._driftRecover*s);const o=g.angleDiff(this._a,this._m);if(o>g.toRadians(90)&&(t+=o-g.toRadians(90)),o<=t?this._m=g.clampAngle(this._a):g.angleClockwise(this._a,this._m)?this._m=g.clampAngle(this._m+t):this._m=g.clampAngle(this._m-t),this._lastX=i.GetX(),this._lastY=i.GetY(),0!==this._s&&0!==s){i.OffsetXY(Math.cos(this._m)*this._s*s,Math.sin(this._m)*this._s*s),this._setAngle&&(i.SetAngle(this._a),this._lastAngle=this._a),i.SetBboxChanged();let e=r.TestOverlapSolid(this._inst);if(e){r.RegisterCollision(this._inst,e),this._s=Math.abs(this._s),this._m=r.CalculateBounceAngle(this._inst,this._lastX,this._lastY,null),i.OffsetXY(Math.cos(this._m)*this._s*s,Math.sin(this._m)*this._s*s),i.SetBboxChanged(),this._s*=1-this._friction,r.PushOutSolid(this._inst,Math.cos(this._m),Math.sin(this._m),Math.max(2.5*this._s*s,30))||r.PushOutSolidNearest(this._inst,100);const d=i.GetX(),c=i.GetY(),p=this._maxSpeed*s,S=g.distanceTo(this._lastX,this._lastY,d,c);if(1.01*p<S){const u=p/S,m=g.lerp(this._lastX,d,u),f=g.lerp(this._lastY,c,u);i.SetXY(m,f),i.SetBboxChanged(),!r.TestOverlapSolid(this._inst)||r.PushOutSolidNearest(this._inst,2)||(i.SetXY(this._lastX,this._lastY),i.SetBboxChanged())}}}else this._setAngle&&i.GetAngle()!==this._a&&(i.SetAngle(this._a),this._lastAngle=this._a,i.SetBboxChanged(),r.TestOverlapSolid(this._inst))&&r.PushOutSolidNearest(this._inst,100)}}}GetPropertyValueByIndex(e){switch(e){case j:return this._GetMaxSpeed();case k:return this._GetAcceleration();case l:return this._GetDeceleration();case m:return g.toDegrees(this._GetSteerSpeed());case n:return g.toDegrees(this._GetDriftRecover());case o:return this._GetFriction();case p:return this._GetTurnWhileStopped();case q:return this._setAngle;case r:return this._IsDefaultControls();case s:return this._IsEnabled()}}SetPropertyValueByIndex(e,t){switch(e){case j:this._SetMaxSpeed(t);break;case k:this._SetAcceleration(t);break;case l:this._SetDeceleration(t);break;case m:this._SetSteerSpeed(g.toRadians(t));break;case n:this._SetDriftRecover(g.toRadians(t));break;case o:this._SetFriction(t);break;case p:this._SetTurnWhileStopped(t);break;case q:this._setAngle=!!t;break;case r:this._SetDefaultControls(!!t);break;case s:this._SetEnabled(!!t)}}_Stop(){this._s=0}_SetSpeed(e){this._s=g.clamp(e,-this._maxSpeed,this._maxSpeed)}_GetSpeed(){return this._s}_SetMaxSpeed(e){this._maxSpeed=Math.max(e,0)}_GetMaxSpeed(){return this._maxSpeed}_SetAcceleration(e){this._acc=Math.max(e,0)}_GetAcceleration(){return this._acc}_SetDeceleration(e){this._dec=Math.max(e,0)}_GetDeceleration(){return this._dec}_GetMovingAngle(){return this._m}_GetVectorX(){return Math.cos(this._m)*this._s}_GetVectorY(){return Math.sin(this._m)*this._s}_SetSteerSpeed(e){this._steerSpeed=e}_GetSteerSpeed(){return this._steerSpeed}_SetDriftRecover(e){this._driftRecover=e}_GetDriftRecover(){return this._driftRecover}_SetFriction(e){this._friction=e}_GetFriction(){return this._friction}_SetTurnWhileStopped(e){this._turnWhileStopped=!!e}_GetTurnWhileStopped(){return this._turnWhileStopped}_SimulateControl(e){if(this._isEnabled)switch(e){case 0:this._simLeft=!0;break;case 1:this._simRight=!0;break;case 2:this._simUp=!0;break;case 3:this._simDown=!0}}_SetIgnoreInput(e){this._ignoreInput=!!e}_IsIgnoreInput(){return this._ignoreInput}_SetDefaultControls(e){this._defaultControls!==(e=!!e)&&(this._defaultControls=e,this._defaultControls?this._BindEvents():(this._UnBindEvents(),this._OnWindowOrKeyboardBlur()))}_IsDefaultControls(){return this._defaultControls}_SetEnabled(e){this._isEnabled=!!e,this._isEnabled?this._StartTicking():(this._simLeft=!1,this._simRight=!1,this._simUp=!1,this._simDown=!1,this._StopTicking())}_IsEnabled(){return this._isEnabled}GetDebuggerProperties(){const e="behaviors.car";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:g.toDegrees(this._GetMovingAngle()),onedit:e=>this._m=g.toRadians(e)},{name:e+".debugger.vector-x",value:this._GetVectorX()},{name:e+".debugger.vector-y",value:this._GetVectorY()},{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.steer-speed.name",value:g.toDegrees(this._GetSteerSpeed()),onedit:e=>this._SetSteerSpeed(g.toRadians(e))},{name:e+".properties.drift-recover.name",value:g.toDegrees(this._GetDriftRecover()),onedit:e=>this._SetDriftRecover(g.toRadians(e))},{name:e+".properties.friction.name",value:this._GetFriction(),onedit:e=>this._SetFriction(e)},{name:e+".properties.turn-while-stopped.name",value:this._GetTurnWhileStopped(),onedit:e=>this._SetTurnWhileStopped(e)},{name:e+".properties.enabled.name",value:this._IsEnabled(),onedit:e=>this._SetEnabled(e)}]}]}GetScriptInterfaceClass(){return self.ICarBehaviorInstance}},new WeakMap),u=new Map([["left",0],["right",1],["up",2],["down",3]]);self.ICarBehaviorInstance=class extends i{constructor(){super(),t.set(this,i._GetInitInst().GetSdkInstance())}stop(){t.get(this)._Stop()}simulateControl(e){h.RequireString(e);const s=u.get(e);if("number"!=typeof s)throw new Error("invalid control");t.get(this)._SimulateControl(s)}get speed(){return t.get(this)._GetSpeed()}set speed(e){h.RequireFiniteNumber(e),t.get(this)._SetSpeed(e)}get maxSpeed(){return t.get(this)._GetMaxSpeed()}set maxSpeed(e){h.RequireFiniteNumber(e),t.get(this)._SetMaxSpeed(e)}get acceleration(){return t.get(this)._GetAcceleration()}set acceleration(e){h.RequireFiniteNumber(e),t.get(this)._SetAcceleration(e)}get deceleration(){return t.get(this)._GetDeceleration()}set deceleration(e){h.RequireFiniteNumber(e),t.get(this)._SetDeceleration(e)}get vectorX(){return t.get(this)._GetVectorX()}get vectorY(){return t.get(this)._GetVectorY()}getVector(){const e=t.get(this);return[e._GetVectorX(),e._GetVectorY()]}get angleOfMotion(){return t.get(this)._GetMovingAngle()}set steerSpeed(e){h.RequireFiniteNumber(e),t.get(this)._SetSteerSpeed(e)}get steerSpeed(){return t.get(this)._GetSteerSpeed()}set driftRecover(e){h.RequireFiniteNumber(e),t.get(this)._SetDriftRecover(e)}get driftRecover(){return t.get(this)._GetDriftRecover()}set friction(e){h.RequireFiniteNumber(e),t.get(this)._SetFriction(e)}get friction(){return t.get(this)._GetFriction()}get turnWhileStopped(){return t.get(this)._GetTurnWhileStopped()}set turnWhileStopped(e){t.get(this)._SetTurnWhileStopped(e)}get isDefaultControls(){return t.get(this)._IsDefaultControls()}set isDefaultControls(e){t.get(this)._SetDefaultControls(!!e)}get isIgnoringInput(){return t.get(this)._IsIgnoreInput()}set isIgnoringInput(e){t.get(this)._SetIgnoreInput(!!e)}get isEnabled(){return t.get(this)._IsEnabled()}set isEnabled(e){t.get(this)._SetEnabled(!!e)}}}{const Oa=self.C3;Oa.Behaviors.Car.Cnds={IsMoving(){return 0!==this._GetSpeed()},CompareSpeed(e,t){return Oa.compare(this._GetSpeed(),e,t)},IsEnabled(){return this._IsEnabled()}}}{const Ra=self.C3;Ra.Behaviors.Car.Acts={Stop(){this._Stop()},SetIgnoreInput(e){this._SetIgnoreInput(0!==e)},SetSpeed(e){this._SetSpeed(e)},SetMaxSpeed(e){this._SetMaxSpeed(e)},SetAcceleration(e){this._SetAcceleration(e)},SetDeceleration(e){this._SetDeceleration(e)},SimulateControl(e){this._SimulateControl(e)},SetEnabled(e){this._SetEnabled(0!==e)},SetSteerSpeed(e){this._SetSteerSpeed(Ra.toRadians(e))},SetDriftRecover(e){this._SetDriftRecover(Ra.toRadians(e))},SetFriction(e){this._SetFriction(e)},SetTurnWhileStopped(e){this._SetTurnWhileStopped(e)},SetDefaultControls(e){this._SetDefaultControls(e)}}}{const c0=self.C3;c0.Behaviors.Car.Exps={Speed(){return this._GetSpeed()},MaxSpeed(){return this._GetMaxSpeed()},Acceleration(){return this._GetAcceleration()},Deceleration(){return this._GetDeceleration()},MovingAngle(){return c0.toDegrees(this._GetMovingAngle())},VectorX(){return this._GetVectorX()},VectorY(){return this._GetVectorY()},SteerSpeed(){return c0.toDegrees(this._GetSteerSpeed())},DriftRecover(){return c0.toDegrees(this._GetDriftRecover())},Friction(){return this._GetFriction()}}} } // scripts/behaviors/Pin/c3runtime/runtime.js { {const a=self.C3;a.Behaviors.Pin=class extends a.SDKBehaviorBase{constructor(t){super(t)}Release(){super.Release()}}}{const d=self.C3;d.Behaviors.Pin.Type=class extends d.SDKBehaviorTypeBase{constructor(t){super(t)}Release(){super.Release()}OnCreate(){}}}{const g=self.C3;g.Behaviors.Pin.Instance=class extends g.SDKBehaviorInstanceBase{constructor(t,s){super(t),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,s&&(this._destroy=s[0]);const e=this._runtime.Dispatcher();this._disposables=new g.CompositeDisposable(g.Disposable.From(e,"instancedestroy",t=>this._OnInstanceDestroyed(t.instance)),g.Disposable.From(e,"afterload",t=>this._OnAfterLoad()))}Release(){this._pinInst=null,super.Release()}_SetPinInst(t){t?(this._pinInst=t,this._StartTicking2()):(this._pinInst=null,this._StopTicking2())}_Pin(t,s,e){if(t){const i=t.GetFirstPicked(this._inst);if(i){this._mode=s,this._SetPinInst(i);const h=this._inst.GetWorldInfo(),n=i.GetWorldInfo();if("properties"===this._mode){const a=this._propSet;a.clear();for(const o of e)a.add(o);this._dx=h.GetX()-n.GetX(),this._dy=h.GetY()-n.GetY(),this._dAngle=h.GetAngle()-n.GetAngle(),this._lastKnownAngle=h.GetAngle(),this._dz=h.GetZElevation()-n.GetZElevation(),a.has("x")&&a.has("y")&&(this._pinAngle=g.angleTo(n.GetX(),n.GetY(),h.GetX(),h.GetY())-n.GetAngle(),this._pinDist=g.distanceTo(n.GetX(),n.GetY(),h.GetX(),h.GetY())),a.has("width-abs")?this._dWidth=h.GetWidth()-n.GetWidth():a.has("width-scale")&&(this._dWidth=h.GetWidth()/n.GetWidth()),a.has("height-abs")?this._dHeight=h.GetHeight()-n.GetHeight():a.has("height-scale")&&(this._dHeight=h.GetHeight()/n.GetHeight())}else this._pinDist=g.distanceTo(n.GetX(),n.GetY(),h.GetX(),h.GetY())}}}SaveToJson(){const t=this._propSet,s=this._mode,e={"uid":this._pinInst&&!this._pinInst.IsDestroyed()?this._pinInst.GetUID():-1,"m":s,"d":this._destroy};return"rope"===s||"bar"===s?e["pd"]=this._pinDist:"properties"===s&&(e["ps"]=[...this._propSet],t.has("imagepoint")?e["ip"]=this._pinImagePoint:t.has("x")&&t.has("y")?(e["pa"]=this._pinAngle,e["pd"]=this._pinDist):(t.has("x")&&(e["dx"]=this._dx),t.has("y")&&(e["dy"]=this._dy)),t.has("angle")&&(e["da"]=this._dAngle,e["lka"]=this._lastKnownAngle),(t.has("width-abs")||t.has("width-scale"))&&(e["dw"]=this._dWidth),(t.has("height-abs")||t.has("height-scale"))&&(e["dh"]=this._dHeight),t.has("z"))&&(e["dz"]=this._dz),e}LoadFromJson(t){const s=t["m"],e=this._propSet;if(e.clear(),this._pinUid=t["uid"],"number"==typeof s)this._LoadFromJson_Legacy(t);else if(this._mode=s,t.hasOwnProperty("d")&&(this._destroy=!!t["d"]),"rope"===s||"bar"===s)this._pinDist=t["pd"];else if("properties"===s){for(const i of t["ps"])e.add(i);e.has("imagepoint")?this._pinImagePoint=t["ip"]:e.has("x")&&e.has("y")?(this._pinAngle=t["pa"],this._pinDist=t["pd"]):(e.has("x")&&(this._dx=t["dx"]),e.has("y")&&(this._dy=t["dy"])),e.has("angle")&&(this._dAngle=t["da"],this._lastKnownAngle=t["lka"]||0),(e.has("width-abs")||e.has("width-scale"))&&(this._dWidth=t["dw"]),(e.has("height-abs")||e.has("height-scale"))&&(this._dHeight=t["dh"]),e.has("z")&&(this._dz=t["dz"])}}_LoadFromJson_Legacy(t){const s=this._propSet,e=t["msa"],i=t["tsa"],h=t["pa"],n=t["pd"],a=t["m"];switch(a){case 0:this._mode="properties",s.add("x").add("y").add("angle"),this._pinAngle=h,this._pinDist=n,this._dAngle=e-i,this._lastKnownAngle=t["lka"];break;case 1:this._mode="properties",s.add("x").add("y"),this._pinAngle=h,this._pinDist=n;break;case 2:this._mode="properties",s.add("angle"),this._dAngle=e-i,this._lastKnownAngle=t["lka"];break;case 3:this._mode="rope",this._pinDist=t["pd"];break;case 4:this._mode="bar",this._pinDist=t["pd"]}}_OnAfterLoad(){-1===this._pinUid?this._SetPinInst(null):(this._SetPinInst(this._runtime.GetInstanceByUID(this._pinUid)),this._pinUid=-1)}_OnInstanceDestroyed(t){this._pinInst===t&&(this._SetPinInst(null),this._destroy)&&this._runtime.DestroyInstance(this._inst)}Tick2(){const e=this._pinInst;if(e&&!e.IsDestroyed()){const i=e.GetWorldInfo(),t=this._inst,h=t.GetWorldInfo(),n=this._mode;let s=!1;if("rope"===n||"bar"===n){const a=g.distanceTo(h.GetX(),h.GetY(),i.GetX(),i.GetY());if(a>this._pinDist||"bar"===n&&a<this._pinDist){const o=g.angleTo(i.GetX(),i.GetY(),h.GetX(),h.GetY());h.SetXY(i.GetX()+Math.cos(o)*this._pinDist,i.GetY()+Math.sin(o)*this._pinDist),s=!0}}else{const d=this._propSet;let t=0;if(d.has("imagepoint")){const[_,p]=e.GetImagePoint(this._pinImagePoint);h.EqualsXY(_,p)||(h.SetXY(_,p),s=!0)}else if(d.has("x")&&d.has("y")){const l=i.GetX()+Math.cos(i.GetAngle()+this._pinAngle)*this._pinDist,r=i.GetY()+Math.sin(i.GetAngle()+this._pinAngle)*this._pinDist;h.EqualsXY(l,r)||(h.SetXY(l,r),s=!0)}else t=i.GetX()+this._dx,d.has("x")&&t!==h.GetX()&&(h.SetX(t),s=!0),t=i.GetY()+this._dy,d.has("y")&&t!==h.GetY()&&(h.SetY(t),s=!0);d.has("angle")&&(this._lastKnownAngle!==h.GetAngle()&&(this._dAngle=g.clampAngle(this._dAngle+(h.GetAngle()-this._lastKnownAngle))),(t=g.clampAngle(i.GetAngle()+this._dAngle))!==h.GetAngle()&&(h.SetAngle(t),s=!0),this._lastKnownAngle=h.GetAngle()),d.has("width-abs")&&(t=i.GetWidth()+this._dWidth)!==h.GetWidth()&&(h.SetWidth(t),s=!0),d.has("width-scale")&&(t=i.GetWidth()*this._dWidth)!==h.GetWidth()&&(h.SetWidth(t),s=!0),d.has("height-abs")&&(t=i.GetHeight()+this._dHeight)!==h.GetHeight()&&(h.SetHeight(t),s=!0),d.has("height-scale")&&(t=i.GetHeight()*this._dHeight)!==h.GetHeight()&&(h.SetHeight(t),s=!0),d.has("z")&&(t=i.GetZElevation()+this._dz)!==h.GetZElevation()&&(h.SetZElevation(t),this._runtime.UpdateRender())}s&&h.SetBboxChanged()}}GetDebuggerProperties(){const t="behaviors.pin.debugger";return[{title:"$"+this.GetBehaviorType().GetName(),properties:[{name:t+".is-pinned",value:!!this._pinInst},{name:t+".pinned-uid",value:this._pinInst?this._pinInst.GetUID():0}]}]}}}{const $=self.C3;$.Behaviors.Pin.Cnds={IsPinned(){return!!this._pinInst},WillDestroy(){return this._destroy}}}{const _=self.C3;_.Behaviors.Pin.Acts={PinByDistance(t,s){this._Pin(t,0===s?"rope":"bar")},PinByProperties(t,s,e,i,h,n,a){const o=[];s&&o.push("x"),e&&o.push("y"),i&&o.push("angle"),a&&o.push("z"),1===h?o.push("width-abs"):2===h&&o.push("width-scale"),1===n?o.push("height-abs"):2===n&&o.push("height-scale"),0!==o.length&&this._Pin(t,"properties",o)},PinByImagePoint(t,s,e,i,h,n){const a=["imagepoint"];e&&a.push("angle"),n&&a.push("z"),1===i?a.push("width-abs"):2===i&&a.push("width-scale"),1===h?a.push("height-abs"):2===h&&a.push("height-scale"),this._pinImagePoint=s,this._Pin(t,"properties",a)},SetPinDistance(t){"rope"!==this._mode&&"bar"!==this._mode||(this._pinDist=Math.max(t,0))},SetDestroy(t){this._destroy=t},Unpin(){this._SetPinInst(null),this._mode="",this._propSet.clear(),this._pinImagePoint=""},Pin(t,s){switch(s){case 0:this._Pin(t,"properties",["x","y","angle"]);break;case 1:this._Pin(t,"properties",["x","y"]);break;case 2:this._Pin(t,"properties",["angle"]);break;case 3:this._Pin(t,"rope");break;case 4:this._Pin(t,"bar")}}}}{const va=self.C3;va.Behaviors.Pin.Exps={PinnedUID(){return this._pinInst?this._pinInst.GetUID():-1}}} } // scripts/behaviors/Tween/c3runtime/runtime.js { {const a=self.C3;a.Behaviors.Tween=class extends a.SDKBehaviorBase{constructor(e){super(e)}Release(){super.Release()}}}{const d=self.C3;d.Behaviors.Tween.Type=class extends d.SDKBehaviorTypeBase{constructor(e){super(e)}Release(){super.Release()}OnCreate(){}}}{const g=self.C3,h=g.Behaviors.Tween,i=0;h.Instance=class extends g.SDKBehaviorInstanceBase{constructor(e,s){super(e),this._allowMultiple=!1,this._enabled=!0,s&&(this._allowMultiple=!1,this._enabled=!!s[i]),this._activeTweens=new Map,this._disabledTweens=[],this._waitingForReleaseTweens=new Map,this._finishingTween=null,this._activeTweensJson=null,this._disabledTweensJson=null,this._waitingForReleaseTweensJson=null,this._finishingTweenName="",this._triggerTweens=[],this._afterLoad=e=>this._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 s of this.AllTweens())e?this.IsInDisabledList(s)&&s.Resume():((s.IsPlaying()||s.IsScheduled())&&this.AddToDisabledList(s),s.Stop());e&&this.ClearDisabledList()}IsEnabled(){return this._enabled}AddToDisabledList(e){this._disabledTweens.push(e)}IsInDisabledList(e){return this._disabledTweens.includes(e)}ClearDisabledList(){g.clearArray(this._disabledTweens)}GetFinishingTween(){return this._finishingTween}IsInstanceValid(){const e=this.GetObjectInstance();return!!e&&!e.IsDestroyed()}GetTween(e,s,t=!1){const n=s?this.PropertyTweens(s,t):this.AllTweens(t);if(n&&n.length)for(const i of n)if(i.HasTags(e))return i}CheckTweensWithTags(e,s){for(const t of this._activeTweens.values())for(const n of t)if(!n.IsReleased()&&n.HasTags(e)&&s(n))return!0;for(const i of this._waitingForReleaseTweens.values())for(const a of i)if(!a.IsReleased()&&a.HasTags(e)&&s(a))return!0;return!1}CheckTweens(e){for(const s of this._activeTweens.values())for(const t of s)if(!t.IsReleased()&&e(t))return!0;for(const n of this._waitingForReleaseTweens.values())for(const i of n)if(!i.IsReleased()&&e(i))return!0;return!1}GetTweenIncludingWaitingForRelease(e,s){return this.GetTween(e,s,!0)}*GetTweens(e,s,t=!1){const n=s?this.PropertyTweens(s,t):this.AllTweens(t);if(n&&n.length)for(const i of n)i.HasTags(e)&&(yield i)}*GetTweensIncludingWaitingForRelease(e,s){yield*this.GetTweens(e,s,!0)}PropertyTweens(t,e){if(e){let e=this._activeTweens.get(t),s=this._waitingForReleaseTweens.get(t);return e=e||[],s=s||[],e.concat(s).filter(e=>e).filter(e=>!e.IsReleased())}{let e=this._activeTweens.get(t);return(e=e||[]).filter(e=>e).filter(e=>!e.IsReleased())}}AllTweens(e){if(e){const s=[...this._activeTweens.values()].flat(),t=[...this._waitingForReleaseTweens.values()].flat();return s.concat(t).filter(e=>e).filter(e=>!e.IsReleased())}{const n=[...this._activeTweens.values()].flat();return n.filter(e=>e).filter(e=>!e.IsReleased())}}AllTweensIncludingWaitingForRelease(){return this.AllTweens(!0)}SaveToJson(e=0){return{"s":!1,"e":!!this._enabled,"at":this._SaveActiveTweensToJson(),"dt":this._SaveDisabledTweensToJson(),"wt":this._SaveWaitingForReleaseTweensToJson(),"ft":this._SaveFinishingTweenToJson()}}LoadFromJson(e,s="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"===s)&&this._OnAfterLoad()}_OnAfterLoad(){const e=this.GetRuntime().GetTimelineManager();if(this._PopulateTweenMap(this._activeTweensJson,this._activeTweens,e),this._disabledTweensJson){g.clearArray(this._disabledTweens);for(const s of this._disabledTweensJson)this._PopulateTweenArray(this._disabledTweens,s,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(s,t,n){if(s)for(const i in s){let e=t.get(i);e?g.clearArray(e):e=[];const a=s[i];for(const r of a){const o=this._PopulateTweenArray(e,r["name"],n);if(o)this._LoadTweenFromJson(r["name"],r,n);else{const l=g.TweenState.Build({runtime:this.GetRuntime(),json:r});g.TweenState.SetInstanceUID(l,this.GetObjectInstance().GetUID()),l.AddCompletedCallback(e=>this._FinishTriggers(e)),n.AddScheduledTimeline(l),this._PopulateTweenArray(e,l,n)}}t.set(i,e)}}_GetTween(e,s){return s.GetScheduledOrPlayingTimelineByName(e)}_PopulateTweenArray(e,s,t){if("string"!=typeof s)return!!e.push(s);{const n=this._GetTween(s,t);if(n)return!!e.push(n)}return!1}_LoadTweenFromJson(e,s,t){if("string"==typeof e){const n=this._GetTween(e,t);n&&(n._LoadFromJson(s),g.TweenState.SetInstanceUID(n,this.GetObjectInstance().GetUID()))}else e._LoadFromJson(s),g.TweenState.SetInstanceUID(e,this.GetObjectInstance().GetUID())}_SaveActiveTweensToJson(){const e={};for(const[s,t]of this._activeTweens)e[s]=t.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[s,t]of this._waitingForReleaseTweens)e[s]=t.map(e=>e._SaveToJson());return e}_SaveFinishingTweenToJson(){return this._finishingTween?this._finishingTween.GetName():""}Tick2(){this._ReleaseWaitingTweens()}CreateTween(e){const s=h.Config.GetPropertyTracksConfig(e.property,e.startValue,e.endValue,e.ease,e.resultMode,this.GetObjectInstance()),t=h.Maps.GetPropertyFromIndex(e.property),n=(h.Maps.IsValueId(t)||this.ReleaseTweens(e.property),g.TweenState.Build({runtime:this.GetRuntime(),id:t,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:s}));return n.AddCompletedCallback(e=>this._FinishTriggers(e)),this._AddTween(n,e.property),n}_MaybeRemoveFromActiveTweenMap(e){const s=e.GetId();if(this._activeTweens.has(s)){const t=this._activeTweens.get(s);if(t){const n=t.indexOf(e);-1!==n&&t.splice(n,1)}}}ReleaseTween(e,s=!1){this._MaybeRemoveFromActiveTweenMap(e),e.IsReleased()||this._IsInWaitingList(e)||(e.Stop(s),this._AddToWaitingList(e))}ReleaseTweens(e,s=!1){if(g.IsFiniteNumber(e)){const t=h.Maps.GetPropertyFromIndex(e);if(this._activeTweens.has(t)){const n=this._activeTweens.get(t),i=this.GetFinishingTween();for(const a of n)a===i||a.IsReleased()||this._IsInWaitingList(a)||(a.Stop(s),a.Release());g.clearArray(n)}}else{const r=this.GetFinishingTween();for(const o of this.AllTweens())o===r||o.IsReleased()||this._IsInWaitingList(o)||(o.Stop(s),o.Release());for(const l of this._activeTweens.keys())g.clearArray(this._activeTweens.get(l)),this._activeTweens.delete(l);this._activeTweens.clear()}}ReleaseAndCompleteTween(e){this.ReleaseTween(e,!0)}ReleaseAndCompleteTweens(){this.ReleaseTweens(NaN,!0)}GetPropertyValueByIndex(e){if(e===i)return this._enabled}SetPropertyValueByIndex(e,s){e===i&&(this._enabled=!!s)}_GetBehaviorType(e){const s=e.GetInstance(),t=s.GetBehaviorInstances();for(const n of t){const i=n.GetBehaviorType();if(i.GetInstanceSdkCtor()===this.constructor)return i}}Trigger(e,s,t,n){return this._runtime?super.Trigger(e):s.Trigger(e,t,n)}_FinishTriggers(e){this._finishingTween=e,h.Cnds.SetFinishingTween(e);let s,t;if(this.GetRuntime())s=this._inst,t=this._runtime,this.Trigger(h.Cnds.OnTweensFinished),this.Trigger(h.Cnds.OnAnyTweensFinished),this.ReleaseTween(e);else{if(!(s=e.GetInstance()))return;if(s&&s.IsDestroyed())return;t=s.GetRuntime();const n=this._GetBehaviorType(e);this.Trigger(h.Cnds.OnTweensFinished,t,s,n),this.Trigger(h.Cnds.OnAnyTweensFinished,t,s,n),e.Stop()}this._finishingTween=null,h.Cnds.SetFinishingTween(null),e.GetDestroyInstanceOnComplete()&&t.DestroyInstance(s)}_AddTween(e,s){const t=h.Maps.GetPropertyFromIndex(s),n=(this._activeTweens.has(t)||this._activeTweens.set(t,[]),this._activeTweens.get(t));n.push(e)}_AddToWaitingList(e){const s=e.GetId();this._waitingForReleaseTweens.has(s)||this._waitingForReleaseTweens.set(s,[]),this._waitingForReleaseTweens.get(s).push(e),this.IsTicking2()||this._StartTicking2()}_IsInWaitingList(e){const s=e.GetId();return!!this._waitingForReleaseTweens.has(s)&&this._waitingForReleaseTweens.get(s).includes(e)}_ReleaseWaitingTweens(){if(this._waitingForReleaseTweens.size){for(const e of this._waitingForReleaseTweens.values()){for(const s of e)s.IsReleased()||s.Release();g.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 M0=self.C3;let s=null;M0.Behaviors.Tween.Cnds={OnAnyTweenLoop(){return!0},OnTweensLoop(e){const s=this.GetTriggerTween();return!!s&&s.HasTags(e)},OnAnyTweenPingPong(e){const s=this.GetTriggerTween();return!!s&&(s.GetPingPongState()===e||2===e)},OnTweensPingPong(e,s){const t=this.GetTriggerTween();return!!t&&(t.GetPingPongState()===s||2===s)&&t.HasTags(e)},SetFinishingTween(e){s=e},OnTweensFinished(e){return s.HasTags(e)},OnAnyTweensFinished(){return!0},IsPlaying(e){return this.CheckTweensWithTags(e,M0.TweenState.IsPlaying)},IsAnyPlaying(){return this.CheckTweens(M0.TweenState.IsPlaying)},IsPaused(e){return this.CheckTweensWithTags(e,M0.TweenState.IsPaused)},IsAnyPaused(){return this.CheckTweens(M0.TweenState.IsPaused)},IsPingPong(e,s){return 0===s?this.CheckTweensWithTags(e,M0.TweenState.IsPing):1===s&&this.CheckTweensWithTags(e,M0.TweenState.IsPong)},IsAnyPingPong(e){return 0===e?this.CheckTweens(M0.TweenState.IsPing):1===e&&this.CheckTweens(M0.TweenState.IsPong)}}}{const ab=self.C3,bb=self.Ease,cb=ab.Behaviors.Tween;cb.Acts={SetEnabled(e){this.SetEnabled(!!e)},async TweenOneProperty(...e){if(this.IsEnabled()&&this.IsInstanceValid()){const s=this.CreateTween(cb.TweenArguments.OneProperty(this,...e));s.Play()&&await s.GetPlayPromise()}},async TweenTwoProperties(...e){if(this.IsEnabled()&&this.IsInstanceValid()){const s=this.CreateTween(cb.TweenArguments.TwoProperties(this,...e));s.Play()&&await s.GetPlayPromise()}},async TweenValue(...e){if(this.IsEnabled()&&this.IsInstanceValid()){const s=this.CreateTween(cb.TweenArguments.ValueProperty(this,...e));s.Play()&&await s.GetPlayPromise()}},PauseTweens(e){if(this.IsEnabled()&&this.IsInstanceValid())for(const s of this.GetTweens(e))s.Stop()},PauseAllTweens(){if(this.IsEnabled()&&this.IsInstanceValid())for(const e of this.AllTweens())e.Stop()},ResumeTweens(e){if(this.IsEnabled()&&this.IsInstanceValid())for(const s of this.GetTweens(e))s.Resume()},ResumeAllTweens(){if(this.IsEnabled()&&this.IsInstanceValid())for(const e of this.AllTweens())e.Resume()},StopTweens(e){if(this.IsEnabled()&&this.IsInstanceValid())for(const s of this.GetTweens(e))this.ReleaseTween(s)},StopAllTweens(){if(this.IsEnabled()&&this.IsInstanceValid())for(const e of this.AllTweens())this.ReleaseTween(e)},SetOnePropertyTweensEndValue(e,s,t){if(this.IsEnabled()&&this.IsInstanceValid()){const n=ab.Behaviors.Tween.Maps.GetSinglePropertyFromIndex(s);for(const i of this.GetTweens(e))i.BeforeSetEndValues([n]),i.SetEndValue(t,n)}},SetTwoPropertiesTweensEndValue(e,s,t,n){if(this.IsEnabled()&&this.IsInstanceValid()){const i=ab.Behaviors.Tween.Maps.GetRealProperties(s);for(const a of this.GetTweens(e))a.BeforeSetEndValues(i),a.SetEndValue(t,i[0]),a.SetEndValue(n,i[1])}},SetValuePropertyTweensStartValue(e,s){if(this.IsEnabled()&&this.IsInstanceValid())for(const t of this.GetTweens(e,"value"))t.SetStartValue(s,"value")},SetValuePropertyTweensEndValue(e,s){if(this.IsEnabled()&&this.IsInstanceValid())for(const t of this.GetTweens(e,"value"))t.BeforeSetEndValues(["value"]),t.SetEndValue(s,"value")},SetTweensEase(e,s){if(this.IsEnabled()&&this.IsInstanceValid()){const t=bb.GetEaseFromIndex(s);for(const n of this.GetTweens(e))n.SetEase(t)}},SetAllTweensEase(e){if(this.IsEnabled()&&this.IsInstanceValid()){const s=bb.GetEaseFromIndex(e);for(const t of this.AllTweens())t.SetEase(s)}},SetTweensTime(e,s){if(this.IsEnabled()&&this.IsInstanceValid())for(const t of this.GetTweens(e))t.SetTime(s)},SetAllTweensTime(e){if(this.IsEnabled()&&this.IsInstanceValid())for(const s of this.AllTweens())s.SetTime(e)},SetTweensPlaybackRate(e,s){if(this.IsEnabled()&&this.IsInstanceValid())for(const t of this.GetTweens(e))t.SetPlaybackRate(s)},SetAllTweensPlaybackRate(e){if(this.IsEnabled()&&this.IsInstanceValid())for(const s of this.AllTweens())s.SetPlaybackRate(e)},SetTweensDestroyOnComplete(e,s){if(this.IsEnabled()&&this.IsInstanceValid())for(const t of this.GetTweens(e))t.SetDestroyInstanceOnComplete(!!s)},SetAllTweensDestroyOnComplete(e){if(this.IsEnabled()&&this.IsInstanceValid())for(const s of this.AllTweens())s.SetDestroyInstanceOnComplete(!!e)}}}{const e1=self.C3;e1.Behaviors.Tween.Exps={Time(e){const s=this.GetTweenIncludingWaitingForRelease(e);return s?s.GetTime():0},Progress(e){const s=this.GetTweenIncludingWaitingForRelease(e);return s?s.GetTime()/s.GetTotalTime():0},PlaybackRate(e){const s=this.GetTweenIncludingWaitingForRelease(e);return s?s.GetPlaybackRate():0},Value(e){const s=this.GetTweenIncludingWaitingForRelease(e,"value");return s?s.GetPropertyTrack("value").GetSourceAdapterValue():0},Tags(){let e=this.GetFinishingTween();return(e=e||this.GetTriggerTween())?e.GetStringTags():""}}} } // scripts/behaviors/Tween/c3runtime/maps.js { const C3=self.C3,Ease=self.Ease,PAIR_PROPERTIES=["position","size","scale"],SINGLE_PROPERTIES=["offsetX","offsetY","offsetWidth","offsetHeight","offsetAngle","offsetOpacity","offsetColor","offsetZElevation","offsetScaleX","offsetScaleY"],VALUE_PROPERTIES=["value"],PROPERTY_INDEX_TO_NAME=[].concat(PAIR_PROPERTIES).concat(SINGLE_PROPERTIES).concat(VALUE_PROPERTIES),PROPERTY_PAIR_TO_REAL_PROPERTIES={"position":["offsetX","offsetY"],"size":["offsetWidth","offsetHeight"],"scale":["offsetScaleX","offsetScaleY"]},ALL_REAL_PROPERTIES=Object.assign({},PROPERTY_INDEX_TO_NAME.reduce((e,t)=>Object.assign({},e,{[t]:[t]}),{}),PROPERTY_PAIR_TO_REAL_PROPERTIES);C3.Behaviors.Tween.Maps=class{constructor(){}static GetEases(){return[...Ease.GetRuntimeEaseNames()]}static GetEaseFromIndex(e){return[...Ease.GetRuntimeEaseNames()][e]}static GetPropertyFromIndex(e){return PROPERTY_INDEX_TO_NAME[e]}static GetPropertyIndexFromName(e){return PROPERTY_INDEX_TO_NAME.indexOf(e)}static GetPairPropertyFromIndex(e){return PAIR_PROPERTIES[e]}static GetSinglePropertyFromIndex(e){return SINGLE_PROPERTIES[e]}static GetValuePropertyFromIndex(e){return VALUE_PROPERTIES[e]}static GetPairProperties(e){return PROPERTY_PAIR_TO_REAL_PROPERTIES[e]}static GetRealProperties(e){return C3.IsString(e)?ALL_REAL_PROPERTIES[e]:ALL_REAL_PROPERTIES[PROPERTY_INDEX_TO_NAME[e]]}static IsPairId(e){return!!PROPERTY_PAIR_TO_REAL_PROPERTIES[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}}; } // scripts/behaviors/Tween/c3runtime/tweenConfig.js { const C3=self.C3,NAMESPACE=C3.Behaviors.Tween,TWEEN_CONFIGURATIONS=new Map;NAMESPACE.Config=class{constructor(){}static GetPropertyTracksConfig(e,t,r,o,a,s){0===TWEEN_CONFIGURATIONS.size&&this._CreateConfigObjects();const n=NAMESPACE.PropertyTypes.Pick(e);let i=TWEEN_CONFIGURATIONS.get(n);return C3.IsFiniteNumber(e)&&(e=NAMESPACE.Maps.GetPropertyFromIndex(e)),this._GetConfig(i,e,t,r,o,a,s)}static TransformValue(e,t){const r=C3.Behaviors.Tween.GetPropertyTracksConfig(e);return r.valueGetter(t)}static _CreateConfigObjects(){const e=NAMESPACE.PropertyTypes,t=NAMESPACE.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,r){TWEEN_CONFIGURATIONS.set(e,this._CreateConfigObject(e,t,r))}static _CreateConfigObject(e,t,r){return{name:e,configFunc:t,valueGetter:r}}static _GetConfig(e,t,r,o,a,s,n){return e.configFunc(t,e.valueGetter(r),e.valueGetter(o),a,s,n)}static _GetPairConfig(e,r,o,a,s,t){const n=NAMESPACE.Maps.GetPairProperties(e);return n.map((e,t)=>({sourceId:"world-instance",property:e,type:"float",valueType:"numeric",startValue:r[t],endValue:o[t],ease:NAMESPACE.Maps.GetEaseFromIndex(a),resultMode:s}))}static _GetColorConfig(e,t,r,o,a,s){return C3.Plugins.Text&&s.GetPlugin()instanceof C3.Plugins.Text?{sourceId:"plugin",sourceArgs:[7],property:"color",type:"color",valueType:"color",startValue:t,endValue:r,ease:NAMESPACE.Maps.GetEaseFromIndex(o),resultMode:a}:{sourceId:"world-instance",property:e,type:"color",valueType:"color",startValue:t,endValue:r,ease:NAMESPACE.Maps.GetEaseFromIndex(o),resultMode:a}}static _GetAngleConfig(e,t,r,o,a,s){return{sourceId:"world-instance",property:e,type:"angle",valueType:"angle",startValue:t,endValue:r,ease:NAMESPACE.Maps.GetEaseFromIndex(o),resultMode:a}}static _GetCommonConfig(e,t,r,o,a,s){return{sourceId:"world-instance",property:e,type:"float",valueType:"numeric",startValue:t,endValue:r,ease:NAMESPACE.Maps.GetEaseFromIndex(o),resultMode:a}}static _GetValueConfig(e,t,r,o,a,s){return{sourceId:"value",property:e,type:"float",valueType:"numeric",startValue:t,endValue:r,ease:NAMESPACE.Maps.GetEaseFromIndex(o),resultMode:a}}}; } // scripts/behaviors/Tween/c3runtime/tweenArguments.js { const C3=self.C3,NAMESPACE=C3.Behaviors.Tween,COMMON_FIXED_ARGS={resultMode:"absolute"},COMMON_VARIABLE_ARGS=Object.assign({},COMMON_FIXED_ARGS,{tags:"",property:"",time:0,ease:0,releaseOnComplete:0,loop:!1,pingPong:!1,repeatCount:1}),ONE_PROPERTY_ARGS=Object.assign({},COMMON_VARIABLE_ARGS,{initialValueMode:"current-state",startValue:0,endValue:0}),TWO_PROPERTIES_ARGS=Object.assign({},COMMON_VARIABLE_ARGS,{initialValueMode:"current-state",startValue:[0,0],endValue:[0,0]}),COLOR_PROPERTY_ARGS=Object.assign({},COMMON_VARIABLE_ARGS,{initialValueMode:"current-state",startValue:[0,0,0],endValue:[0,0,0]}),VALUE_PROPERTY_ARGS=Object.assign({},ONE_PROPERTY_ARGS,{initialValueMode:"start-value"}),X=0,Y=1,R=0,G=1,B=2;NAMESPACE.TweenArguments=class{constructor(){}static _SetCommonProperties(e,t,R,r,P,a,E,O){e.tags=t,e.time=R,e.ease=r,e.releaseOnComplete=P,e.loop=a,e.pingPong=E,e.repeatCount=O}static OneProperty(e,t,r,P,a,E,O,A,_,o){const s="string"==typeof r?r:NAMESPACE.Maps.GetSinglePropertyFromIndex(r),n=NAMESPACE.Maps.IsColorId(s)?COLOR_PROPERTY_ARGS:ONE_PROPERTY_ARGS;return this._SetCommonProperties(n,t,a,E,O,A,_,o),NAMESPACE.Maps.IsColorId(s)?(COLOR_PROPERTY_ARGS.endValue[R]=C3.GetRValue(P),COLOR_PROPERTY_ARGS.endValue[G]=C3.GetGValue(P),COLOR_PROPERTY_ARGS.endValue[B]=C3.GetBValue(P),COLOR_PROPERTY_ARGS.property=NAMESPACE.Maps.GetPropertyIndexFromName(s)):NAMESPACE.Maps.IsOpacityId(s)?ONE_PROPERTY_ARGS.endValue=P/100:ONE_PROPERTY_ARGS.endValue=P,n.property=NAMESPACE.Maps.GetPropertyIndexFromName(s),n}static TwoProperties(e,t,R,r,P,a,E,O,A,_,o){this._SetCommonProperties(TWO_PROPERTIES_ARGS,t,a,E,O,A,_,o);const s="string"==typeof R?R:NAMESPACE.Maps.GetPairPropertyFromIndex(R);return TWO_PROPERTIES_ARGS.endValue[X]=r,TWO_PROPERTIES_ARGS.endValue[Y]=P,TWO_PROPERTIES_ARGS.property=NAMESPACE.Maps.GetPropertyIndexFromName(s),TWO_PROPERTIES_ARGS}static ValueProperty(e,t,R,r,P,a,E,O,A,_){return this._SetCommonProperties(VALUE_PROPERTY_ARGS,t,P,a,E,O,A,_),VALUE_PROPERTY_ARGS.startValue=R,VALUE_PROPERTY_ARGS.endValue=r,VALUE_PROPERTY_ARGS.property=NAMESPACE.Maps.GetPropertyIndexFromName("value"),VALUE_PROPERTY_ARGS}}; } // scripts/behaviors/Tween/c3runtime/propertyTypes.js { const C3=self.C3,NAMESPACE=C3.Behaviors.Tween,TYPE_CHECK_OBJECTS=[];NAMESPACE.PropertyTypes=class{constructor(){}static Pick(t){if(0===TYPE_CHECK_OBJECTS.length){const e=TYPE_CHECK_OBJECTS;e.push({checkFunc:NAMESPACE.Maps.IsPairId,result:this.PAIR}),e.push({checkFunc:NAMESPACE.Maps.IsColorId,result:this.COLOR}),e.push({checkFunc:NAMESPACE.Maps.IsAngleId,result:this.ANGLE}),e.push({checkFunc:NAMESPACE.Maps.IsValueId,result:this.VALUE}),e.push({checkFunc:()=>!0,result:this.OTHER})}C3.IsFiniteNumber(t)&&(t=C3.Behaviors.Tween.Maps.GetPropertyFromIndex(t));for(const s of TYPE_CHECK_OBJECTS)if(s.checkFunc(t))return s.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"}}; } // scripts/behaviors/Tween/c3runtime/valueGetters.js { const C3=self.C3,NAMESPACE=C3.Behaviors.Tween;NAMESPACE.ValueGetters=class{constructor(){}static _GetPropertyAngleValue(e){const t=C3.toRadians(parseFloat(e));return C3.clampAngle(t)}static _GetColorPropertyValue(e){return e.slice(0)}static _GetPropertyValue(e){return e}}; } // scripts/behaviors/Tween/c3runtime/scriptInterface.js { const C3=self.C3,C3X=self.C3X,IBehaviorInstance=self.IBehaviorInstance,Ease=self.Ease,NAMESPACE=C3.Behaviors.Tween,map=new WeakMap,TWEEN_PROPERTIES=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"}]]);function getIndexForEase(e){C3X.RequireString(e);const t=Ease.ToInternal(e);let n;if(-1===(n=t?Ease.GetIndexForEase(t,null):Ease.GetIndexForEase(e,null)))throw new Error(`invalid ease name '${e}'`);return n}const TWEEN_OPTS={tags:"",destroyOnComplete:!1,loop:!1,pingPong:!1,repeatCount:1,startValue:0},I_TWEEN_OPTS={easeToIndexFunc:getIndexForEase};function ValidateTags(e,t=!1){if(!(t&&null==e||"string"==typeof e||Array.isArray(e)))throw new Error("invalid tags")}self.ITweenBehaviorInstance=class extends IBehaviorInstance{constructor(){super(),map.set(this,IBehaviorInstance._GetInitInst().GetSdkInstance())}startTween(e,t,n,a,o){const s=map.get(this);if(!s.IsEnabled()||!s.IsInstanceValid())return null;const r=TWEEN_PROPERTIES.get(e);if(!r)throw new Error("invalid tween property");"one"===r.type||"value"===r.type?C3X.RequireNumber(t):(C3X.RequireArray(t),"two"===r.type?(C3X.RequireNumber(t[0]),C3X.RequireNumber(t[1])):"color"===r.type&&(C3X.RequireNumber(t[0]),C3X.RequireNumber(t[1]),C3X.RequireNumber(t[2]))),"angle"===e?t=C3.toDegrees(t):"opacity"===e?t*=100:"color"===e&&(t=C3.PackRGBEx(t[0],t[1],t[2]));const l=getIndexForEase(a);C3X.RequireFiniteNumber(n),o=Object.assign({},TWEEN_OPTS,o),"value"===r.type&&C3X.RequireNumber(o.startValue),ValidateTags(o.tags,!0);let i;if("one"===r.type||"color"===r.type?i=s.CreateTween(NAMESPACE.TweenArguments.OneProperty(s,o.tags,r.name,t,n,l,!!o.destroyOnComplete,!!o.loop,!!o.pingPong,o.repeatCount)):"two"===r.type?i=s.CreateTween(NAMESPACE.TweenArguments.TwoProperties(s,o.tags,r.name,t[0],t[1],n,l,!!o.destroyOnComplete,!!o.loop,!!o.pingPong,o.repeatCount)):"value"===r.type&&(i=s.CreateTween(NAMESPACE.TweenArguments.ValueProperty(s,o.tags,o.startValue,t,n,l,!!o.destroyOnComplete,!!o.loop,!!o.pingPong,o.repeatCount))),i.Play())return i.GetITweenState(s,I_TWEEN_OPTS);throw new Error("failed to start tween")}*allTweens(){const e=map.get(this);for(const t of e.AllTweens())yield t.GetITweenState(e,I_TWEEN_OPTS)}*tweensByTags(e){ValidateTags(e);const t=map.get(this);for(const n of t.GetTweens(e))yield n.GetITweenState(t,I_TWEEN_OPTS)}get isEnabled(){return map.get(this).IsEnabled()}set isEnabled(e){map.get(this).SetEnabled(e)}}; } // scripts/expTable.js { const C3 = self.C3; function unaryminus(n) { return (typeof n === "number" ? -n : n); } function bothNumbers(a, b) { return typeof a === "number" && typeof b === "number"; } function add(l, r) { if (bothNumbers(l, r)) return l + r; else return l; } function subtract(l, r) { if (bothNumbers(l, r)) return l - r; else return l; } function multiply(l, r) { if (bothNumbers(l, r)) return l * r; else return l; } function divide(l, r) { if (bothNumbers(l, r)) return l / r; else return l; } function mod(l, r) { if (bothNumbers(l, r)) return l % r; else return l; } function pow(l, r) { if (bothNumbers(l, r)) return Math.pow(l, r); else return l; } function and(l, r) { if (typeof l === "string" || typeof r === "string") { // & with either side string does string concatenation let lstr, rstr; if (typeof l === "number") lstr = (Math.round(l * 1e10) / 1e10).toString(); else lstr = l; if (typeof r === "number") rstr = (Math.round(r * 1e10) / 1e10).toString(); else rstr = r; return lstr + rstr; } else { // & with neither side a string does logical AND return (l && r ? 1 : 0); } } function or(l, r) { if (bothNumbers(l, r)) return (l || r ? 1 : 0); else return l; } self.C3_ExpressionFuncs = [ () => "START", p => { const f0 = p._GetNode(0).GetBoundMethod(); const n1 = p._GetNode(1); return () => f0(n1.ExpObject()); }, p => { const n0 = p._GetNode(0); return () => n0.ExpObject(); }, () => 1, () => 0, p => { const f0 = p._GetNode(0).GetBoundMethod(); return () => f0(); }, () => "", () => "menu", () => "game", () => -100, () => 3, () => "lc", () => "level", () => "GAMEPLAY", () => 180, () => 0.25, () => 270, () => 90, p => { const n0 = p._GetNode(0); return () => n0.ExpInstVar(); }, p => { const f0 = p._GetNode(0).GetBoundMethod(); return () => f0(0.5, 1.25); }, p => { const f0 = p._GetNode(0).GetBoundMethod(); return () => f0(0.5, 1); }, () => "LOSE/WIN", p => { const v0 = p._GetNode(0).GetVar(); return () => v0.GetValue(); }, p => { const f0 = p._GetNode(0).GetBoundMethod(); const f1 = p._GetNode(1).GetBoundMethod(); return () => (f0(f1()) + 1); }, () => 80, () => 2, () => 1.05, () => 100, () => 1.25, () => 618, () => 1.1, () => 0.15, () => 40, () => 10, p => { const n0 = p._GetNode(0); return () => and("0", n0.ExpInstVar()); }, p => { const n0 = p._GetNode(0); return () => (n0.ExpObject() - 1088); }, p => { const n0 = p._GetNode(0); return () => (n0.ExpObject() + 1088); }, p => { const n0 = p._GetNode(0); return () => (n0.ExpInstVar()).toString(); }, () => 30, () => "START2", () => 1696, () => "GAMEPLAY2", () => "Take out all the machines in order", () => 2600, () => "LOSE/WIN2" ]; }
| ver. 1.4 |
Github
|
.
| PHP 8.2.29 | Генераци� �траницы: 0.08 |
proxy
|
phpinfo
|
�а�тройка