diff --git a/assets/index-C1Pva28f.css b/assets/index-C1Pva28f.css new file mode 100644 index 0000000..faafd26 --- /dev/null +++ b/assets/index-C1Pva28f.css @@ -0,0 +1 @@ +*{border:0;margin:0;padding:0}html,body{width:100%;height:100%;overflow:hidden}body{background-image:url(/bubble-gun/backgrounds/tile.png);background-repeat:repeat} diff --git a/assets/index-RbE3Z0Sr.js b/assets/index-RbE3Z0Sr.js new file mode 100644 index 0000000..74e9ed4 --- /dev/null +++ b/assets/index-RbE3Z0Sr.js @@ -0,0 +1,56 @@ +var Yl=Object.defineProperty;var zl=(t,e,r)=>e in t?Yl(t,e,{enumerable:true,configurable:true,writable:true,value:r}):t[e]=r;var b=(t,e,r)=>zl(t,typeof e!=="symbol"?e+"":e,r);(function t(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload")){return}for(const n of document.querySelectorAll('link[rel="modulepreload"]')){s(n)}new MutationObserver(n=>{for(const i of n){if(i.type!=="childList"){continue}for(const o of i.addedNodes){if(o.tagName==="LINK"&&o.rel==="modulepreload")s(o)}}}).observe(document,{childList:true,subtree:true});function r(n){const i={};if(n.integrity)i.integrity=n.integrity;if(n.referrerPolicy)i.referrerPolicy=n.referrerPolicy;if(n.crossOrigin==="use-credentials")i.credentials="include";else if(n.crossOrigin==="anonymous")i.credentials="omit";else i.credentials="same-origin";return i}function s(n){if(n.ep)return;n.ep=true;const i=r(n);fetch(n.href,i)}})();var Xl=Object.defineProperty;var a=(t,e)=>Xl(t,"name",{value:e,configurable:true});var Ql=(()=>{for(var t=new Uint8Array(128),e=0;e<64;e++)t[e<26?e+65:e<52?e+71:e<62?e-4:e*4-205]=e;return r=>{for(var s=r.length,n=new Uint8Array((s-(r[s-1]=="=")-(r[s-2]=="="))*3/4|0),i=0,o=0;i>4,n[o++]=l<<4|u>>2,n[o++]=u<<6|f}return n}})();var _;var Z=(_=class{constructor(e,r,s){b(this,"r",255);b(this,"g",255);b(this,"b",255);this.r=Xe(e,0,255),this.g=Xe(r,0,255),this.b=Xe(s,0,255)}static fromArray(e){return new _(e[0],e[1],e[2])}static fromHex(e){if(typeof e=="number")return new _(e>>16&255,e>>8&255,e>>0&255);if(typeof e=="string"){let r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!r)throw new Error("Invalid hex color format");return new _(parseInt(r[1],16),parseInt(r[2],16),parseInt(r[3],16))}else throw new Error("Invalid hex color format")}static fromHSL(e,r,s){if(r==0)return new _(255*s,255*s,255*s);let n=a((f,x,h)=>(h<0&&(h+=1),h>1&&(h-=1),h<1/6?f+(x-f)*6*h:h<1/2?x:h<2/3?f+(x-f)*(2/3-h)*6:f),"hue2rgb"),i=s<.5?s*(1+r):s+r-s*r,o=2*s-i,d=n(o,i,e+1/3),l=n(o,i,e),u=n(o,i,e-1/3);return new _(Math.round(d*255),Math.round(l*255),Math.round(u*255))}clone(){return new _(this.r,this.g,this.b)}lighten(e){return new _(this.r+e,this.g+e,this.b+e)}darken(e){return this.lighten(-e)}invert(){return new _(255-this.r,255-this.g,255-this.b)}mult(e){return new _(this.r*e.r/255,this.g*e.g/255,this.b*e.b/255)}lerp(e,r){return new _(Ce(this.r,e.r,r),Ce(this.g,e.g,r),Ce(this.b,e.b,r))}toHSL(){let e=this.r/255,r=this.g/255,s=this.b/255,n=Math.max(e,r,s),i=Math.min(e,r,s),o=(n+i)/2,d=o,l=o;if(n==i)o=d=0;else{let u=n-i;switch(d=l>.5?u/(2-n-i):u/(n+i),n){case e:o=(r-s)/u+(rZ.fromHSL(t,e,r),"hsl2rgb");function me(t){return t*Math.PI/180}a(me,"deg2rad");function bt(t){return t*180/Math.PI}a(bt,"rad2deg");function Xe(t,e,r){return e>r?Xe(t,r,e):Math.min(Math.max(t,e),r)}a(Xe,"clamp");function Ce(t,e,r){if(typeof t=="number"&&typeof e=="number")return t+(e-t)*r;if(t instanceof B&&e instanceof B)return t.lerp(e,r);if(t instanceof Z&&e instanceof Z)return t.lerp(e,r);throw new Error(`Bad value for lerp(): ${t}, ${e}. Only number, Vec2 and Color is supported.`)}a(Ce,"lerp");function ze(t,e,r,s,n){return s+(t-e)/(r-e)*(n-s)}a(ze,"map");function Bi(t,e,r,s,n){return Xe(ze(t,e,r,s,n),s,n)}a(Bi,"mapc");var ne;var B=(ne=class{constructor(e=0,r=e){b(this,"x",0);b(this,"y",0);this.x=e,this.y=r}static fromAngle(e){let r=me(e);return new ne(Math.cos(r),Math.sin(r))}static fromArray(e){return new ne(e[0],e[1])}clone(){return new ne(this.x,this.y)}add(...e){let r=E(...e);return new ne(this.x+r.x,this.y+r.y)}sub(...e){let r=E(...e);return new ne(this.x-r.x,this.y-r.y)}scale(...e){let r=E(...e);return new ne(this.x*r.x,this.y*r.y)}dist(...e){let r=E(...e);return this.sub(r).len()}sdist(...e){let r=E(...e);return this.sub(r).slen()}static sdist(e,r){let s=e.x-r.x,n=e.y-r.y;return s*s+n*n}len(){return Math.sqrt(this.dot(this))}slen(){return this.dot(this)}unit(){let e=this.len();return e===0?new ne(0):this.scale(1/e)}normal(){return new ne(this.y,-this.x)}reflect(e){return this.sub(e.scale(2*this.dot(e)))}project(e){return e.scale(e.dot(this)/e.len())}reject(e){return this.sub(this.project(e))}dot(e){return this.x*e.x+this.y*e.y}static dot(e,r){return e.x*e.x+e.y*e.y}cross(e){return this.x*e.y-this.y*e.x}static cross(e,r){return e.x*r.y-e.y*r.x}angle(...e){let r=E(...e);return bt(Math.atan2(this.y-r.y,this.x-r.x))}angleBetween(...e){let r=E(...e);return bt(Math.atan2(this.cross(r),this.dot(r)))}lerp(e,r){return new ne(Ce(this.x,e.x,r),Ce(this.y,e.y,r))}slerp(e,r){let s=this.dot(e),n=this.cross(e),i=Math.atan2(n,s);return this.scale(Math.sin((1-r)*i)).add(e.scale(Math.sin(r*i))).scale(1/n)}isZero(){return this.x===0&&this.y===0}toFixed(e){return new ne(Number(this.x.toFixed(e)),Number(this.y.toFixed(e)))}transform(e){return e.multVec2(this)}eq(e){return this.x===e.x&&this.y===e.y}bbox(){return new he(this,0,0)}toString(){return`vec2(${this.x.toFixed(2)}, ${this.y.toFixed(2)})`}toArray(){return[this.x,this.y]}},a(ne,"Vec2"),b(ne,"ZERO",new ne(0,0)),b(ne,"ONE",new ne(1,1)),b(ne,"LEFT",new ne(-1,0)),b(ne,"RIGHT",new ne(1,0)),b(ne,"UP",new ne(0,-1)),b(ne,"DOWN",new ne(0,1)),ne);function E(...t){if(t.length===1){if(t[0]instanceof B)return new B(t[0].x,t[0].y);if(Array.isArray(t[0])&&t[0].length===2)return new B(...t[0])}return new B(...t)}a(E,"vec2");var wt;var ce=(wt=class{constructor(e,r,s,n){b(this,"x",0);b(this,"y",0);b(this,"w",1);b(this,"h",1);this.x=e,this.y=r,this.w=s,this.h=n}scale(e){return new wt(this.x+this.w*e.x,this.y+this.h*e.y,this.w*e.w,this.h*e.h)}pos(){return new B(this.x,this.y)}clone(){return new wt(this.x,this.y,this.w,this.h)}eq(e){return this.x===e.x&&this.y===e.y&&this.w===e.w&&this.h===e.h}toString(){return`quad(${this.x}, ${this.y}, ${this.w}, ${this.h})`}},a(wt,"Quad"),wt);function ge(t,e,r,s){return new ce(t,e,r,s)}a(ge,"quad");var Ke;var os=(Ke=class{constructor(e,r,s,n){b(this,"a");b(this,"b");b(this,"c");b(this,"d");this.a=e,this.b=r,this.c=s,this.d=n}mul(e){return new Ke(this.a*e.a+this.b*e.c,this.a*e.b+this.b*e.d,this.c*e.a+this.d*e.c,this.c*e.b+this.d*e.d)}transform(e){return E(this.a*e.x+this.b*e.y,this.c*e.x+this.d*e.y)}get inverse(){let e=this.det;return new Ke(this.d/e,-this.b/e,-this.c/e,this.a/e)}get transpose(){return new Ke(this.a,this.c,this.b,this.d)}get eigenvalues(){let e=this.trace/2,r=this.det,s=e+Math.sqrt(e*e-r),n=e-Math.sqrt(e*e-r);return[s,n]}eigenvectors(e,r){return this.c!=0?[[e-this.d,this.c],[r-this.d,this.c]]:this.b!=0?[[this.b,e-this.a],[this.b,r-this.a]]:Math.abs(this.transform(E(1,0)).x-e)0?Math.acos(this.m[0]/e):-Math.acos(this.m[0]/e))}else if(this.m[4]!=0||this.m[5]!=0){let e=Math.sqrt(this.m[4]*this.m[4]+this.m[5]*this.m[5]);return bt(Math.PI/2-(this.m[5]>0?Math.acos(-this.m[4]/e):-Math.acos(this.m[4]/e)))}else return 0}getSkew(){if(this.m[0]!=0||this.m[1]!=0){let e=Math.sqrt(this.m[0]*this.m[0]+this.m[1]*this.m[1]);return new B(Math.atan(this.m[0]*this.m[4]+this.m[1]*this.m[5])/(e*e),0)}else if(this.m[4]!=0||this.m[5]!=0){let e=Math.sqrt(this.m[4]*this.m[4]+this.m[5]*this.m[5]);return new B(0,Math.atan(this.m[0]*this.m[4]+this.m[1]*this.m[5])/(e*e))}else return new B(0,0)}invert(){let e=[],r=this.m[10]*this.m[15]-this.m[14]*this.m[11],s=this.m[9]*this.m[15]-this.m[13]*this.m[11],n=this.m[9]*this.m[14]-this.m[13]*this.m[10],i=this.m[8]*this.m[15]-this.m[12]*this.m[11],o=this.m[8]*this.m[14]-this.m[12]*this.m[10],d=this.m[8]*this.m[13]-this.m[12]*this.m[9],l=this.m[6]*this.m[15]-this.m[14]*this.m[7],u=this.m[5]*this.m[15]-this.m[13]*this.m[7],f=this.m[5]*this.m[14]-this.m[13]*this.m[6],x=this.m[4]*this.m[15]-this.m[12]*this.m[7],h=this.m[4]*this.m[14]-this.m[12]*this.m[6],w=this.m[5]*this.m[15]-this.m[13]*this.m[7],g=this.m[4]*this.m[13]-this.m[12]*this.m[5],M=this.m[6]*this.m[11]-this.m[10]*this.m[7],p=this.m[5]*this.m[11]-this.m[9]*this.m[7],y=this.m[5]*this.m[10]-this.m[9]*this.m[6],P=this.m[4]*this.m[11]-this.m[8]*this.m[7],R=this.m[4]*this.m[10]-this.m[8]*this.m[6],O=this.m[4]*this.m[9]-this.m[8]*this.m[5];e[0]=this.m[5]*r-this.m[6]*s+this.m[7]*n,e[4]=-(this.m[4]*r-this.m[6]*i+this.m[7]*o),e[8]=this.m[4]*s-this.m[5]*i+this.m[7]*d,e[12]=-(this.m[4]*n-this.m[5]*o+this.m[6]*d),e[1]=-(this.m[1]*r-this.m[2]*s+this.m[3]*n),e[5]=this.m[0]*r-this.m[2]*i+this.m[3]*o,e[9]=-(this.m[0]*s-this.m[1]*i+this.m[3]*d),e[13]=this.m[0]*n-this.m[1]*o+this.m[2]*d,e[2]=this.m[1]*l-this.m[2]*u+this.m[3]*f,e[6]=-(this.m[0]*l-this.m[2]*x+this.m[3]*h),e[10]=this.m[0]*w-this.m[1]*x+this.m[3]*g,e[14]=-(this.m[0]*f-this.m[1]*h+this.m[2]*g),e[3]=-(this.m[1]*M-this.m[2]*p+this.m[3]*y),e[7]=this.m[0]*M-this.m[2]*P+this.m[3]*R,e[11]=-(this.m[0]*p-this.m[1]*P+this.m[3]*O),e[15]=this.m[0]*y-this.m[1]*R+this.m[2]*O;let T=this.m[0]*e[0]+this.m[1]*e[4]+this.m[2]*e[8]+this.m[3]*e[12];for(let A=0;A<4;A++)for(let v=0;v<4;v++)e[A*4+v]*=1/T;return new Me(e)}clone(){return new Me([...this.m])}toString(){return this.m.toString()}},a(Me,"Mat4"),Me);function on(t,e,r,s=n=>-Math.cos(n)){return t+(s(r)+1)/2*(e-t)}a(on,"wave");var Zl=1103515245;var Jl=12345;var wi=2147483648;var _t;var Ci=(_t=class{constructor(e){b(this,"seed");this.seed=e}gen(){return this.seed=(Zl*this.seed+Jl)%wi,this.seed/wi}genNumber(e,r){return e+this.gen()*(r-e)}genVec2(e,r){return new B(this.genNumber(e.x,r.x),this.genNumber(e.y,r.y))}genColor(e,r){return new Z(this.genNumber(e.r,r.r),this.genNumber(e.g,r.g),this.genNumber(e.b,r.b))}genAny(...e){if(e.length===0)return this.gen();if(e.length===1){if(typeof e[0]=="number")return this.genNumber(0,e[0]);if(e[0]instanceof B)return this.genVec2(E(0,0),e[0]);if(e[0]instanceof Z)return this.genColor(re(0,0,0),e[0])}else if(e.length===2){if(typeof e[0]=="number"&&typeof e[1]=="number")return this.genNumber(e[0],e[1]);if(e[0]instanceof B&&e[1]instanceof B)return this.genVec2(e[0],e[1]);if(e[0]instanceof Z&&e[1]instanceof Z)return this.genColor(e[0],e[1])}throw new Error("More than 2 arguments not supported")}},a(_t,"RNG"),_t);var zs=new Ci(Date.now());function Pi(t){return t!=null&&(zs.seed=t),zs.seed}a(Pi,"randSeed");function Ae(...t){return zs.genAny(...t)}a(Ae,"rand");function ln(...t){return Math.floor(Ae(...t.length>0?t:[2]))}a(ln,"randi");function Ri(t){return Ae()<=t}a(Ri,"chance");function un(t){for(let e=t.length-1;e>0;e--){let r=Math.floor(Math.random()*(e+1));[t[e],t[r]]=[t[r],t[e]]}return t}a(un,"shuffle");function ki(t,e){return t.length<=e?t.slice():un(t.slice()).slice(0,e)}a(ki,"chooseMultiple");function Ii(t){return t[ln(t.length)]}a(Ii,"choose");function hn(t,e){return t.pos.x+t.width>e.pos.x&&t.pos.xe.pos.y&&t.pos.y1||n<0||n>1?null:s}a(Di,"testLineLineT");function bs(t,e){let r=Di(t,e);return r?E(t.p1.x+r*(t.p2.x-t.p1.x),t.p1.y+r*(t.p2.y-t.p1.y)):null}a(bs,"testLineLine");function Es(t,e){let r=e.p2.sub(e.p1),s=Number.NEGATIVE_INFINITY,n=Number.POSITIVE_INFINITY;if(r.x!=0){let i=(t.pos.x-e.p1.x)/r.x,o=(t.pos.x+t.width-e.p1.x)/r.x;s=Math.max(s,Math.min(i,o)),n=Math.min(n,Math.max(i,o))}if(r.y!=0){let i=(t.pos.y-e.p1.y)/r.y,o=(t.pos.y+t.height-e.p1.y)/r.y;s=Math.max(s,Math.min(i,o)),n=Math.min(n,Math.max(i,o))}return n>=s&&n>=0&&s<=1}a(Es,"testRectLine");function Vr(t,e){return e.x>t.pos.x&&e.xt.pos.y&&e.yNumber.EPSILON)return false;let n=r.dot(s)/s.dot(s);return n>=0&&n<=1}a(Ss,"testLinePoint");function Er(t,e){let r=t.p2.sub(t.p1),s=r.dot(r),n=t.p1.sub(e.center),i=2*r.dot(n),o=n.dot(n)-e.radius*e.radius,d=i*i-4*s*o;if(s<=Number.EPSILON||d<0)return false;if(d==0){let l=-i/(2*s);if(l>=0&&l<=1)return true}else{let l=(-i+Math.sqrt(d))/(2*s),u=(-i-Math.sqrt(d))/(2*s);if(l>=0&&l<=1||u>=0&&u<=1)return true}return Kr(e,t.p1)}a(Er,"testLineCircle");function Ms(t,e){if(ht(e,t.p1)||ht(e,t.p2))return true;for(let r=0;rht(e,r))||e.pts.some(r=>ht(t,r)))}a(fn,"testPolygonPolygon");function ht(t,e){let r=false,s=t.pts;for(let n=0,i=s.length-1;ne.y!=s[i].y>e.y&&e.x<(s[i].x-s[n].x)*(e.y-s[n].y)/(s[i].y-s[n].y)+s[n].x&&(r=!r);return r}a(ht,"testPolygonPoint");function qs(t,e){e=e.sub(t.center);let r=me(t.angle),s=Math.cos(r),n=Math.sin(r),i=e.x*s+e.y*n,o=-e.x*n+e.y*s;return i*i/(t.radiusX*t.radiusX)+o*o/(t.radiusY*t.radiusY)<1}a(qs,"testEllipsePoint");function Dr(t,e){let r=e.center.sub(t.center),s=me(t.angle),n=Math.cos(s),i=Math.sin(s),o=r.x*n+r.y*i,d=-r.x*i+r.y*n;return qs(new dt(E(),t.radiusX+e.radius,t.radiusY+e.radius,0),E(o,d))}a(Dr,"testEllipseCircle");function pn(t,e){let r=t.toMat2().inverse;return e=new Le(r.transform(e.p1.sub(t.center)),r.transform(e.p2.sub(t.center))),Er(e,new Oe(E(),1))}a(pn,"testEllipseLine");function Fi(t,e){if(t.radiusX===t.radiusY)return Dr(e,new Oe(t.center,t.radiusX));if(e.radiusX===e.radiusY)return Dr(t,new Oe(e.center,e.radiusX));let r=new Rr(1/t.radiusX**2,0,0,0,1/t.radiusY**2,0,0,0,-1),s=new Rr(1/e.radiusX**2,0,0,0,1/e.radiusY**2,0,0,0,-1),n=t.center.x,i=t.center.y,o=e.center.x,d=e.center.y,l=me(t.angle),u=me(e.angle),f=new Rr(Math.cos(l),-Math.sin(l),n,Math.sin(l),Math.cos(l),i,0,0,1),x=new Rr(Math.cos(u),-Math.sin(u),o,Math.sin(u),Math.cos(u),d,0,0,1),h=f.inverse,w=x.inverse,g=h.transpose.mul(r).mul(h),M=w.transpose.mul(s).mul(w),p=g.m11,y=g.m12,P=g.m13,R=g.m21,O=g.m22,T=g.m23,A=g.m31,v=g.m32,S=g.m33,k=M.m11,I=M.m12,F=M.m13,U=M.m21,H=M.m22,j=M.m23,J=M.m31,V=M.m32,X=M.m33,se=p*O*S-p*T*v-y*R*S+y*T*A+P*R*v-P*O*A,ee=(p*O*X-p*T*V-p*v*j+p*S*H-y*R*X+y*T*J+y*A*j-y*S*U+P*R*V-P*O*J-P*A*H+P*v*U+R*v*F-R*S*I-O*A*F+O*S*k+T*A*I-T*v*k)/se,$=(p*H*X-p*j*V-y*U*X+y*j*J+P*U*V-P*H*J-R*I*X+R*F*V+O*k*X-O*F*J-T*k*V+T*I*J+A*I*j-A*F*H-v*k*j+v*F*U+S*k*H-S*I*U)/se,fe=(k*H*X-k*j*V-I*U*X+I*j*J+F*U*V-F*H*J)/se;if(ee>=0){let N=-3*$+ee**2,tt=3*ee*fe+$*ee**2-4*$**2,ft=-27*fe**2+18*fe*ee*$+ee**2*$**2-4*ee**3*fe-4*$**3;return!(N>0&&tt<0&&ft>0)}else{let N=-3*$+ee**2,tt=-27*fe**2+18*fe*ee*$+ee**2*$**2-4*ee**3*fe-4*$**3;return!(N>0&&tt>0)}}a(Fi,"testEllipseEllipse");function gn(t,e){return Bs(t,new Pe(e.points()))}a(gn,"testEllipseRect");function Bs(t,e){let r=t.toMat2().inverse;return e=new Pe(e.pts.map(s=>r.transform(s.sub(t.center)))),Yr(new Oe(E(),1),e)}a(Bs,"testEllipsePolygon");function Oi(t,e){return t.x===e.x&&t.y===e.y}a(Oi,"testPointPoint");function Ui(t,e){return e instanceof B?Oi(e,t.pt):e instanceof Oe?Kr(e,t.pt):e instanceof Le?Ss(e,t.pt):e instanceof he?Vr(e,t.pt):e instanceof Pe?ht(e,t.pt):e instanceof dt?qs(e,t.pt):false}a(Ui,"testPointShape");function Li(t,e){return e instanceof B?Ss(t,e):e instanceof Oe?Er(t,e):e instanceof Le?bs(t,e)!=null:e instanceof he?Es(e,t):e instanceof Pe?Ms(t,e):e instanceof dt?pn(e,t):false}a(Li,"testLineShape");function Hi(t,e){return e instanceof B?Kr(t,e):e instanceof Oe?Ti(t,e):e instanceof Le?Er(e,t):e instanceof he?dn(e,t):e instanceof Pe?Yr(t,e):e instanceof dt?Dr(e,t):false}a(Hi,"testCircleShape");function Ni(t,e){return e instanceof B?Vr(t,e):e instanceof Oe?dn(t,e):e instanceof Le?Es(t,e):e instanceof he?hn(t,e):e instanceof Pe?cn(t,e):e instanceof dt?gn(e,t):false}a(Ni,"testRectShape");function Gi(t,e){return e instanceof B?ht(t,e):e instanceof Oe?Yr(e,t):e instanceof Le?Ms(e,t):e instanceof he?cn(e,t):e instanceof Pe?fn(e,t):e instanceof dt?Bs(e,t):false}a(Gi,"testPolygonShape");function ji(t,e){return e instanceof B?qs(t,e):e instanceof Oe?Dr(t,e):e instanceof Le?pn(t,e):e instanceof he?gn(t,e):e instanceof Pe?Bs(t,e):e instanceof dt?Fi(e,t):false}a(ji,"testEllipseShape");function mn(t,e,r){let s=t,n=r.p1,i=r.p2,o=e,d=i.sub(n),l=o.cross(d);if(Math.abs(l)=1)return null;let x=u.cross(o)/l;if(x<=0||x>=1)return null;let h=d.normal().unit();return e.dot(h)>0&&(h.x*=-1,h.y*=-1),{point:s.add(o.scale(f)),normal:h,fraction:f}}a(mn,"raycastLine");function Vi(t,e,r){let s=Number.NEGATIVE_INFINITY,n=Number.POSITIVE_INFINITY,i;if(t.x!=0){let o=(r.pos.x-t.x)/e.x,d=(r.pos.x+r.width-t.x)/e.x;i=E(-Math.sign(e.x),0),s=Math.max(s,Math.min(o,d)),n=Math.min(n,Math.max(o,d))}if(t.y!=0){let o=(r.pos.y-t.y)/e.y,d=(r.pos.y+r.height-t.y)/e.y;Math.min(o,d)>s&&(i=E(0,-Math.sign(e.y))),s=Math.max(s,Math.min(o,d)),n=Math.min(n,Math.max(o,d))}return n>=s&&s>=0&&s<=1?{point:t.add(e.scale(s)),normal:i,fraction:s}:null}a(Vi,"raycastRect");function yn(t,e,r){let s=t,n=r.center,i=e,o=i.dot(i),d=s.sub(n),l=2*i.dot(d),u=d.dot(d)-r.radius*r.radius,f=l*l-4*o*u;if(o<=Number.EPSILON||f<0)return null;if(f==0){let x=-l/(2*o);if(x>=0&&x<=1){let h=s.add(i.scale(x));return{point:h,normal:h.sub(n),fraction:x}}}else{let x=(-l+Math.sqrt(f))/(2*o),h=(-l-Math.sqrt(f))/(2*o),w=null;if(x>=0&&x<=1&&(w=x),h>=0&&h<=1&&(w=Math.min(h,w??h)),w!=null){let g=s.add(i.scale(w));return{point:g,normal:g.sub(n).unit(),fraction:w}}}return null}a(yn,"raycastCircle");function Ki(t,e,r){let s=r.pts,n=null,i=s[s.length-1];for(let o=0;ol.fraction)&&(n=l),i=d}return n}a(Ki,"raycastPolygon");function Yi(t,e,r){let s=r.toMat2(),n=s.inverse,i=n.transform(t.sub(r.center)),o=n.transform(e),d=yn(i,o,new Oe(E(),1));if(d){let l=os.rotation(me(-r.angle)),u=os.scale(r.radiusX,r.radiusY).transform(d.point),f=s.transform(d.point).add(r.center),x=f.dist(t)/e.len();return{point:f,normal:l.transform(E(r.radiusY**2*u.x,r.radiusX**2*u.y)).unit(),fraction:x}}return d}a(Yi,"raycastEllipse");function zi(t,e,r,s=64){let n=t,i=e.len(),o=e.scale(1/i),d=0,l=E(Math.floor(t.x),Math.floor(t.y)),u=E(o.x>0?1:-1,o.y>0?1:-1),f=E(Math.abs(1/o.x),Math.abs(1/o.y)),x=E(u.x>0?l.x+1-t.x:t.x-l.x,u.y>0?l.y+1-t.y:t.y-l.y),h=E(f.x<1/0?f.x*x.x:1/0,f.y<1/0?f.y*x.y:1/0),w=-1;for(;d<=s;){let g=r(l);if(g===true)return{point:n.add(o.scale(d)),normal:E(w===0?-u.x:0,w===1?-u.y:0),fraction:d/i,gridPos:l};if(g)return g;h.xe.multVec2(r)))}bbox(){return this.clone()}area(){return this.width*this.height}clone(){return new vt(this.pos.clone(),this.width,this.height)}distToPoint(e){return Math.sqrt(this.sdistToPoint(e))}sdistToPoint(e){let r=this.pos,s=this.pos.add(this.width,this.height),n=Math.max(r.x-e.x,0,e.x-s.x),i=Math.max(r.y-e.y,0,e.y-s.y);return n*n+i*i}collides(e){return Ni(this,e)}contains(e){return this.collides(e)}raycast(e,r){return Vi(e,r,this)}random(){return this.pos.add(Ae(this.width),Ae(this.height))}},a(vt,"Rect"),vt);var kt;var Oe=(kt=class{constructor(e,r){b(this,"center");b(this,"radius");this.center=e.clone(),this.radius=r}transform(e){return new dt(this.center,this.radius,this.radius).transform(e)}bbox(){return he.fromPoints(this.center.sub(E(this.radius)),this.center.add(E(this.radius)))}area(){return this.radius*this.radius*Math.PI}clone(){return new kt(this.center,this.radius)}collides(e){return Hi(this,e)}contains(e){return this.collides(e)}raycast(e,r){return yn(e,r,this)}random(){return this.center.add(B.fromAngle(Ae(360)).scale(Ae(this.radius)))}},a(kt,"Circle"),kt);var Ye;var dt=(Ye=class{constructor(e,r,s,n=0){b(this,"center");b(this,"radiusX");b(this,"radiusY");b(this,"angle");this.center=e.clone(),this.radiusX=r,this.radiusY=s,this.angle=n}static fromMat2(e){let r=e.inverse,s=r.transpose.mul(r),[n,i]=s.eigenvalues,[o,d]=s.eigenvectors(n,i),[l,u]=[1/Math.sqrt(n),1/Math.sqrt(i)];return l>u?new Ye(E(),l,u,bt(Math.atan2(-o[1],o[0]))):new Ye(E(),u,l,bt(Math.atan2(-d[1],d[0])))}toMat2(){let e=me(this.angle),r=Math.cos(e),s=Math.sin(e);return new os(r*this.radiusX,-s*this.radiusY,s*this.radiusX,r*this.radiusY)}transform(e){if(this.angle==0&&e.getRotation()==0)return new Ye(e.multVec2(this.center),e.m[0]*this.radiusX,e.m[5]*this.radiusY);{let r=this.toMat2(),s=e.getRotation(),n=e.getScale();r=Rr.fromMat2(r).scale(n.x,n.y).rotate(s).toMat2();let i=Ye.fromMat2(r);return i.center=e.multVec2(this.center),i}}bbox(){if(this.angle==0)return he.fromPoints(this.center.sub(E(this.radiusX,this.radiusY)),this.center.add(E(this.radiusX,this.radiusY)));{let e=me(this.angle),r=Math.cos(e),s=Math.sin(e),n=this.radiusX*r,i=this.radiusX*s,o=this.radiusY*s,d=this.radiusY*r,l=Math.sqrt(n*n+o*o),u=Math.sqrt(i*i+d*d);return he.fromPoints(this.center.sub(E(l,u)),this.center.add(E(l,u)))}}area(){return this.radiusX*this.radiusY*Math.PI}clone(){return new Ye(this.center,this.radiusX,this.radiusY,this.angle)}collides(e){return ji(this,e)}contains(e){e=e.sub(this.center);let r=me(this.angle),s=Math.cos(r),n=Math.sin(r),i=e.x*s+e.y*n,o=-e.x*n+e.y*s;return i*i/(this.radiusX*this.radiusX)+o*o/(this.radiusY*this.radiusY)<1}raycast(e,r){return Yi(e,r,this)}random(){return this.center}},a(Ye,"Ellipse"),Ye);function Xi(t,e,r,s){let n=e.sub(t),i=s.sub(r),o=n.cross(i);return o<1e-5&&o>-1e-5||(o=r.sub(t).cross(i)/o,o<0||o>1)?null:t.add(n.scale(o))}a(Xi,"segmentLineIntersection");var $e;var Pe=($e=class{constructor(e){b(this,"pts");if(e.length<3)throw new Error("Polygons should have at least 3 vertices");this.pts=e}transform(e){return new $e(this.pts.map(r=>e.multVec2(r)))}bbox(){let e=E(Number.MAX_VALUE),r=E(-Number.MAX_VALUE);for(let s of this.pts)e.x=Math.min(e.x,s.x),r.x=Math.max(r.x,s.x),e.y=Math.min(e.y,s.y),r.y=Math.max(r.y,s.y);return he.fromPoints(e,r)}area(){let e=0,r=this.pts.length;for(let s=0;se.clone()))}collides(e){return Gi(this,e)}contains(e){return this.collides(e)}raycast(e,r){return Ki(e,r,this)}random(){return E()}cut(e,r){new Le(e,r);let s=[],n=[],i=r.sub(e),o=this.pts[this.pts.length-1],d=o.sub(e),l=i.cross(d)>0;return this.pts.forEach(u=>{d=u.sub(e);let f=i.cross(d)>0;if(l!=f){let x=Xi(o,u,e,r);s.push(x),n.push(x),l=f}(f?s:n).push(u),o=u}),[s.length?new $e(s):null,n.length?new $e(n):null]}},a($e,"Polygon"),$e);function Qi(t,e,r,s){let n=s*s,i=1-s,o=i*i;return t.scale(o).add(e.scale(2*i*s)).add(r.scale(n))}a(Qi,"evaluateQuadratic");function Wi(t,e,r,s){let n=1-s;return e.sub(t).scale(2*n).add(r.sub(e).scale(2*s))}a(Wi,"evaluateQuadraticFirstDerivative");function Zi(t,e,r,s){return r.sub(e.scale(2)).add(t).scale(2)}a(Zi,"evaluateQuadraticSecondDerivative");function Cs(t,e,r,s,n){let i=n*n,o=i*n,d=1-n,l=d*d,u=l*d;return t.scale(u).add(e.scale(3*l*n)).add(r.scale(3*d*i)).add(s.scale(o))}a(Cs,"evaluateBezier");function Ji(t,e,r,s,n){let i=n*n,o=1-n,d=o*o;return e.sub(t).scale(3*d).add(r.sub(e).scale(6*o*n)).add(s.sub(r).scale(3*i))}a(Ji,"evaluateBezierFirstDerivative");function $i(t,e,r,s,n){let i=1-n;return r.sub(e.scale(2)).add(t).scale(6*i).add(s.sub(r.scale(2)).add(e).scale(6*n))}a($i,"evaluateBezierSecondDerivative");function _i(t,e,r,s,n){let i=.5*(((-n+2)*n-1)*n),o=.5*((3*n-5)*n*n+2),d=.5*(((-3*n+4)*n+1)*n),l=.5*((n-1)*n*n);return t.scale(i).add(e.scale(o)).add(r.scale(d)).add(s.scale(l))}a(_i,"evaluateCatmullRom");function ea(t,e,r,s,n){let i=.5*((-3*n+4)*n-1),o=.5*((9*n-10)*n),d=.5*((-9*n+8)*n+1),l=.5*((3*n-2)*n);return t.scale(i).add(e.scale(o)).add(r.scale(d)).add(s.scale(l))}a(ea,"evaluateCatmullRomFirstDerivative");function ta(t){let e=wn(t),r=e(1);return s=>{let n=s*r,i=e(n,true);return t(i)}}a(ta,"normalizedCurve");function wn(t,e=10,r=10){let s=[0],n=[0],i=1/(e-1)/r,o=0,d=t(0),l=0;for(let u=1;u{if(f){let x=u;if(x<=0)return 0;if(x>=o)return 1;let h=0;for(;s[h+1]=1)return s[e-1];let x=0;for(;n[x+1]{let u=l*l,f=u*l;return n*f+i*u+o*l+d}}a(Sr,"hermite");function An(t,e,r,s,n,i=Sr){let o=i(e.x,(1-n)*(r.x-t.x),(1-n)*(s.x-e.x),r.x),d=i(e.y,(1-n)*(r.y-t.y),(1-n)*(s.y-e.y),r.y);return l=>new B(o(l),d(l))}a(An,"cardinal");function Tr(t,e,r,s,n=Sr){return An(t,e,r,s,.5,n)}a(Tr,"catmullRom");function ra(t,e,r,s,n=Sr){return Tr(s.add(t.sub(e).scale(6)),t,s,t.add(s.sub(r).scale(6)),n)}a(ra,"bezier");function sa(t,e,r,s,n,i,o,d=Sr){let l=d(e.x,.5*(1-n)*(1+o)*(1+i)*(e.x-t.x)+.5*(1-n)*(1-o)*(1-i)*(r.x-e.x),.5*(1-n)*(1+o)*(1-i)*(r.x-e.x)+.5*(1-n)*(1-o)*(1+i)*(s.x-r.x),r.x),u=d(e.y,.5*(1-n)*(1+o)*(1+i)*(e.y-t.y)+.5*(1-n)*(1-o)*(1-i)*(r.y-e.y),.5*(1-n)*(1+o)*(1-i)*(r.y-e.y)+.5*(1-n)*(1-o)*(1+i)*(s.y-r.y),r.y);return f=>new B(l(f),u(f))}a(sa,"kochanekBartels");function na(t,e,r,s){let n=2*t+e-2*s+r,i=-3*t+3*s-2*e+r,o=e;return d=>{let l=d*d;return 3*n*l+2*i*d+o}}a(na,"hermiteFirstDerivative");function Yt(t){return 0<=t&&t<=1}a(Yt,"inZeroOneDomain");function ss(t,e){return Math.abs(t-e)<=Number.EPSILON}a(ss,"approximately");function zt(t){return t<0?-Math.pow(-t,1/3):Math.pow(t,1/3)}a(zt,"cubeRoot");function ia(t,e,r,s){let n=3*t-6*e+3*r,i=-3*t+3*e,o=t,d=-t+3*e-3*r+s;if(ss(d,0)){if(ss(n,0))return ss(i,0)?[]:[-o/i].filter(Yt);let p=Math.sqrt(i*i-4*n*o),y=2*n;return[(p-i)/y,(-i-p)/y].filter(Yt)}n/=d,i/=d,o/=d;let l=(3*i-n*n)/3,u=l/3,f=(2*n*n*n-9*n*i+27*o)/27,x=f/2,h=x*x+u*u*u;if(h<0){let p=-l/3,y=p*p*p,P=Math.sqrt(y),R=-f/(2*P),O=R<-1?-1:R>1?1:R,T=Math.acos(O),A=2*zt(P),v=A*Math.cos(T/3)-n/3,S=A*Math.cos((T+2*Math.PI)/3)-n/3,k=A*Math.cos((T+4*Math.PI)/3)-n/3;return[v,S,k].filter(Yt)}if(h===0){let p=x<0?zt(-x):-zt(x),y=2*p-n/3,P=-p-n/3;return[y,P].filter(Yt)}let w=Math.sqrt(h),g=zt(w-x),M=zt(w+x);return[g-M-n/3].filter(Yt)}a(ia,"getCubicRoots");function aa(t,e,r,s,n){let i=ia(t.x-n,e.x-n,r.x-n,s.x-n);return i.length>0?Cs(t,e,r,s,i[0]).y:NaN}a(aa,"cubicBezierYforX");function oa(t){if(!t||t.length==0)throw new Error("Need at least one point for easingLinear.");let e=t.length;return r=>{if(r<=0||t.length==1||r<=t[0].x)return t[0].y;for(let s=0;s=r)return ze(r,t[s-1].x,t[s].x,t[s-1].y,t[s].y);return t[t.length-1].y}}a(oa,"easingLinear");function la(t,e){return r=>aa(E(0,0),t,e,E(1,1),r)}a(la,"easingCubicBezier");function ua(t,e="jump-end"){let r=1/t,s=e=="jump-start"||e=="jump-both",n=e=="jump-end"||e=="jump-both",i=1/(t+(n?1:0)),o=s?i:0;return d=>{let l=Math.floor(d/r);return o+l*i}}a(ua,"easingSteps");function ha(t,e){let r=Number.MAX_VALUE,s={normal:E(0),distance:0};for(let n of[t,e])for(let i=0;i=0}a(xn,"isOrientedCcw");function da(t){let e=0,r=t[t.length-1];for(let s=0;s=0}a(ns,"onSameSide");function ca(t,e,r,s){return ns(t,e,r,s)&&ns(t,r,e,s)&&ns(t,s,e,r)}a(ca,"pointInTriangle");function fa(t,e,r,s){for(let n of t)if(n!==e&&n!==r&&n!==s&&ca(n,e,r,s))return true;return false}a(fa,"someInTriangle");function pa(t,e,r,s){return xn(t,e,r)&&!fa(s,t,e,r)}a(pa,"isEar");function vn(t){if(t.length<3)return[];if(t.length==3)return[t];let e=[],r=[],s=0;for(let x=0;x3;){u=e[d],f=r[d];let x=t[f],h=t[d],w=t[u];if(pa(x,h,w,n))i.push([x,h,w]),e[f]=u,r[u]=f,n.splice(n.indexOf(h),1),--o,l=0;else if(++l>o)return[];d=u}return u=e[d],f=r[d],i.push([t[f],t[d],t[u]]),i}a(vn,"triangulate");function ga(t){if(t.length<3)return false;let e=t.length-2,r=t.length-1,s=0,n=t[r].sub(t[e]),i=t[s].sub(t[r]),o=n.cross(i);for(;s+1?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";var Ps="topleft";var _l="monospace";var ls="monospace";var Xs="linear";var bn=[{name:"a_pos",size:2},{name:"a_uv",size:2},{name:"a_color",size:4}];var eu=bn.reduce((t,e)=>t+e.size,0);var ya=2048;var tu=ya*4*eu;var ru=ya*6;var su=` +attribute vec2 a_pos; +attribute vec2 a_uv; +attribute vec4 a_color; + +varying vec2 v_pos; +varying vec2 v_uv; +varying vec4 v_color; + +vec4 def_vert() { + return vec4(a_pos, 0.0, 1.0); +} + +{{user}} + +void main() { + vec4 pos = vert(a_pos, a_uv, a_color); + v_pos = a_pos; + v_uv = a_uv; + v_color = a_color; + gl_Position = pos; +} +`;var nu=` +precision mediump float; + +varying vec2 v_pos; +varying vec2 v_uv; +varying vec4 v_color; + +uniform sampler2D u_tex; + +vec4 def_frag() { + vec4 texColor = texture2D(u_tex, v_uv); + return vec4((v_color.rgb * texColor.rgb), texColor.a) * v_color.a; +} + +{{user}} + +void main() { + gl_FragColor = frag(v_pos, v_uv, v_color, u_tex); + if (gl_FragColor.a == 0.0) { + discard; + } +} +`;var Qs=` +vec4 vert(vec2 pos, vec2 uv, vec4 color) { + return def_vert(); +} +`;var Ws=` +vec4 frag(vec2 pos, vec2 uv, vec4 color, sampler2D tex) { + return def_frag(); +} +`;var iu=new Set(["id","require"]);var au=new Set(["add","fixedUpdate","update","draw","destroy","inspect","drawInspect"]);var ou=200;var lu=640;var uu=65536;var wa=Symbol.for("kaplay.cancel");var er;var Aa=(er=class extends Map{constructor(){super(...arguments);b(this,"lastID",0)}push(r){let s=this.lastID;return this.set(s,r),this.lastID++,s}pushd(r){let s=this.push(r);return()=>this.delete(s)}},a(er,"Registry"),er);var It;var Ut=(It=class{constructor(e){b(this,"paused",false);b(this,"cancel");this.cancel=e}static join(e){let r=new It(()=>e.forEach(s=>s.cancel()));return Object.defineProperty(r,"paused",{get:a(()=>e[0].paused,"get"),set:a(s=>e.forEach(n=>n.paused=s),"set")}),r.paused=false,r}static replace(e,r){return e.cancel=()=>r.cancel(),r.paused=e.paused,Object.defineProperty(e,"paused",{get:a(()=>r.paused,"get"),set:a(s=>r.paused=s,"set")}),e}},a(It,"KEventController"),It);var tr;var qe=(tr=class{constructor(){b(this,"cancellers",new WeakMap);b(this,"handlers",new Aa)}add(e){function r(...i){if(!n.paused)return e(...i)}a(r,"handler");let s=this.handlers.pushd(r),n=new Ut(s);return this.cancellers.set(r,s),n}addOnce(e){let r=this.add((...s)=>{r.cancel(),e(...s)});return r}next(){return new Promise(e=>this.addOnce(e))}trigger(...e){this.handlers.forEach(r=>{let s=r(...e),n;s===wa&&(n=this.cancellers.get(r))&&n()})}numListeners(){return this.handlers.size}clear(){this.handlers.clear()}},a(tr,"KEvent"),tr);var rr;var Fr=(rr=class{constructor(){b(this,"handlers",{});b(this,"registers",{})}on(e,r){return this.handlers[e]||(this.handlers[e]=new qe),this.handlers[e].add(r)}onOnce(e,r){let s=this.on(e,(...n)=>{s.cancel(),r(...n)});return s}next(e){return new Promise(r=>{this.onOnce(e,(...s)=>r(s[0]))})}trigger(e,...r){this.handlers[e]&&this.handlers[e].trigger(...r)}remove(e){delete this.handlers[e]}clear(){this.handlers={}}numListeners(e){var r;return((r=this.handlers[e])==null?void 0:r.numListeners())??0}},a(rr,"KEventHandler"),rr);var hu=a(t=>t[0]instanceof Z,"arrayIsColor");var du=a(t=>t[0]instanceof B,"arrayIsVec2");var cu=a(t=>typeof t[0]=="number","arrayIsNumber");var sr;var xa=(sr=class{constructor(e=(r,s)=>r0;){let r=Math.floor((e-1)/2);if(!this._compareFn(this._items[e],this._items[r])&&this._items[e]>=this._items[r])break;this.swap(e,r),e=r}}moveDown(e){for(;et.match(/^data:\w+\/\w+;base64,.+/),"isDataURL");var fu=a(t=>t.split(".").slice(0,-1).join("."),"getFileName");function ks(t,e){if(t===e)return true;let r=typeof t,s=typeof e;if(r!==s)return false;if(r==="object"&&s==="object"&&t!==null&&e!==null){if(Array.isArray(t)!==Array.isArray(e))return false;let n=Object.keys(t),i=Object.keys(e);if(n.length!==i.length)return false;for(let o of n){let d=t[o],l=e[o];if(!ks(d,l))return false}return true}return false}a(ks,"deepEq");var Ai=new Set;var pu=a(t=>t instanceof Error?t.message:String(t),"getErrorMessage");function Ma(t){Ai.has(t)||(Ai.add(t),console.warn(t))}a(Ma,"warn");function Lt(t,e){Ma(`${t} is deprecated. Use ${e} instead.`)}a(Lt,"deprecateMsg");function us(t,e){return Number(t.toFixed(e))}a(us,"toFixed");function ue(t,e){return(...r)=>{let s=r.length;if(s===t.length)return t(...r);if(s===e.length)return e(...r)}}a(ue,"overload2");var gu=Object.freeze([776,2359,2367,2984,3007,3021,3633,3635,3648,3657,4352,4449,4520]);function qa(t){if(typeof t!="string")throw new TypeError("string cannot be undefined or null");let e=[],r=0,s=0;for(;r=e&&t<=r}a(Ct,"betweenInclusive");var Ne=a((t,e)=>Array.isArray(t)?t==null?void 0:t.includes(e):t===e,"isEqOrIncludes");var Ze=a((t,e)=>Array.isArray(e)?e.some(r=>t.has(r)):t.has(e),"setHasOrIncludes");var ts=a((t,e,r)=>{var s;t.has(e)?(s=t.get(e))==null?void 0:s.push(r):t.set(e,[r])},"mapAddOrPush");var mu=(()=>{let t=0;return()=>t++})();var yu={"Joy-Con L+R (STANDARD GAMEPAD Vendor: 057e Product: 200e)":{buttons:{"0":"south","1":"east","2":"west","3":"north","4":"lshoulder","5":"rshoulder","6":"ltrigger","7":"rtrigger","8":"select","9":"start","10":"lstick","11":"rstick","12":"dpad-up","13":"dpad-down","14":"dpad-left","15":"dpad-right","16":"home","17":"capture"},sticks:{left:{x:0,y:1},right:{x:2,y:3}}},"Joy-Con (L) (STANDARD GAMEPAD Vendor: 057e Product: 2006)":{buttons:{"0":"south","1":"east","2":"west","3":"north","4":"lshoulder","5":"rshoulder","9":"select","10":"lstick","16":"start"},sticks:{left:{x:0,y:1}}},"Joy-Con (R) (STANDARD GAMEPAD Vendor: 057e Product: 2007)":{buttons:{"0":"south","1":"east","2":"west","3":"north","4":"lshoulder","5":"rshoulder","9":"start","10":"lstick","16":"select"},sticks:{left:{x:0,y:1}}},"Pro Controller (STANDARD GAMEPAD Vendor: 057e Product: 2009)":{buttons:{"0":"south","1":"east","2":"west","3":"north","4":"lshoulder","5":"rshoulder","6":"ltrigger","7":"rtrigger","8":"select","9":"start","10":"lstick","11":"rstick","12":"dpad-up","13":"dpad-down","14":"dpad-left","15":"dpad-right","16":"home","17":"capture"},sticks:{left:{x:0,y:1},right:{x:2,y:3}}},default:{buttons:{"0":"south","1":"east","2":"west","3":"north","4":"lshoulder","5":"rshoulder","6":"ltrigger","7":"rtrigger","8":"select","9":"start","10":"lstick","11":"rstick","12":"dpad-up","13":"dpad-down","14":"dpad-left","15":"dpad-right","16":"home"},sticks:{left:{x:0,y:1},right:{x:2,y:3}}}};var wu=a(()=>Rt.lastInputDevice,"getLastInputDeviceType");var Au=a(()=>{let t=Rt.buttons;for(let e in t){let r=t[e].keyboard&&[t[e].keyboard].flat(),s=t[e].keyboardCode&&[t[e].keyboardCode].flat(),n=t[e].gamepad&&[t[e].gamepad].flat(),i=t[e].mouse&&[t[e].mouse].flat();r&&r.forEach(o=>{ts(Rt.buttonsByKey,o,e)}),s&&s.forEach(o=>{ts(Rt.buttonsByKeyCode,o,e)}),n&&n.forEach(o=>{ts(Rt.buttonsByGamepad,o,e)}),i&&i.forEach(o=>{ts(Rt.buttonsByMouse,o,e)})}},"parseButtonBindings");var nr;var kr=(nr=class{constructor(){b(this,"pressed",new Set([]));b(this,"pressedRepeat",new Set([]));b(this,"released",new Set([]));b(this,"down",new Set([]))}update(){this.pressed.clear(),this.released.clear(),this.pressedRepeat.clear()}press(e){this.pressed.add(e),this.pressedRepeat.add(e),this.down.add(e)}pressRepeat(e){this.pressedRepeat.add(e)}release(e){this.down.delete(e),this.pressed.delete(e),this.released.add(e)}},a(nr,"ButtonState"),nr);var ir;var xu=(ir=class{constructor(){b(this,"buttonState",new kr);b(this,"stickState",new Map)}},a(ir,"GamepadState"),ir);var ar;var vu=(ar=class{constructor(){b(this,"dts",[]);b(this,"timer",0);b(this,"fps",0)}tick(e){this.dts.push(e),this.timer+=e,this.timer>=1&&(this.timer=0,this.fps=Math.round(1/(this.dts.reduce((r,s)=>r+s)/this.dts.length)),this.dts=[])}},a(ar,"FPSCounter"),ar);var Rt;var xi=yu;var bu=a(t=>{let e=t.buttons??{};return{canvas:t.canvas,buttons:e,buttonsByKey:new Map,buttonsByMouse:new Map,buttonsByGamepad:new Map,buttonsByKeyCode:new Map,loopID:null,stopped:false,dt:0,fixedDt:1/50,restDt:0,time:0,realTime:0,fpsCounter:new vu,timeScale:1,skipTime:false,isHidden:false,numFrames:0,mousePos:new B(0),mouseDeltaPos:new B(0),keyState:new kr,mouseState:new kr,mergedGamepadState:new xu,gamepadStates:new Map,lastInputDevice:null,buttonState:new kr,gamepads:[],charInputted:[],isMouseMoved:false,lastWidth:t.canvas.offsetWidth,lastHeight:t.canvas.offsetHeight,events:new Fr}},"initAppState");var Eu=a(t=>{if(!t.canvas)throw new Error("Please provide a canvas");let e=bu(t);Rt=e,Au();function r(){return e.dt*e.timeScale}a(r,"dt");function s(){return e.fixedDt*e.timeScale}a(s,"fixedDt");function n(){return e.restDt*e.timeScale}a(n,"restDt");function i(){return e.isHidden}a(i,"isHidden");function o(){return e.time}a(o,"time");function d(){return e.fpsCounter.fps}a(d,"fps");function l(){return e.numFrames}a(l,"numFrames");function u(){return e.canvas.toDataURL()}a(u,"screenshot");function f(m){e.canvas.style.cursor=m}a(f,"setCursor");function x(){return e.canvas.style.cursor}a(x,"getCursor");function h(m){if(m)try{let q=e.canvas.requestPointerLock();q.catch&&q.catch(C=>console.error(C))}catch(q){console.error(q)}else document.exitPointerLock()}a(h,"setCursorLocked");function w(){return!!document.pointerLockElement}a(w,"isCursorLocked");function g(m){m.requestFullscreen?m.requestFullscreen():m.webkitRequestFullscreen&&m.webkitRequestFullscreen()}a(g,"enterFullscreen");function M(){document.exitFullscreen?document.exitFullscreen():document.webkitExitFullScreen&&document.webkitExitFullScreen()}a(M,"exitFullscreen");function p(m=true){m?g(e.canvas):M()}a(p,"setFullscreen");function y(){return document.fullscreenElement===e.canvas||document.webkitFullscreenElement===e.canvas}a(y,"isFullscreen");function P(){e.stopped=true;let m=Object.entries(ke),q=Object.entries(Vs),C=Object.entries(es);for(let[D,G]of m)e.canvas.removeEventListener(D,G);for(let[D,G]of q)document.removeEventListener(D,G);for(let[D,G]of C)window.removeEventListener(D,G);yi.disconnect()}a(P,"quit");function R(m,q){e.loopID!==null&&cancelAnimationFrame(e.loopID);let C=0,D=0,G=a(le=>{if(e.stopped)return;if(document.visibilityState!=="visible"){e.loopID=requestAnimationFrame(G);return}let be=le/1e3,pe=Math.min(be-e.realTime,.25),nt=t.maxFPS?1/t.maxFPS:0;if(e.realTime=be,D+=pe,D>nt){if(!e.skipTime){for(C+=D,e.dt=e.fixedDt,e.restDt=0;C>e.fixedDt;)C-=e.fixedDt,C0}a(O,"isTouchscreen");function T(){return e.mousePos.clone()}a(T,"mousePos");function A(){return e.mouseDeltaPos.clone()}a(A,"mouseDeltaPos");function v(m="left"){return e.mouseState.pressed.has(m)}a(v,"isMousePressed");function S(m="left"){return e.mouseState.down.has(m)}a(S,"isMouseDown");function k(m="left"){return e.mouseState.released.has(m)}a(k,"isMouseReleased");function I(){return e.isMouseMoved}a(I,"isMouseMoved");function F(m){return m===void 0?e.keyState.pressed.size>0:Ze(e.keyState.pressed,m)}a(F,"isKeyPressed");function U(m){return m===void 0?e.keyState.pressedRepeat.size>0:Ze(e.keyState.pressedRepeat,m)}a(U,"isKeyPressedRepeat");function H(m){return m===void 0?e.keyState.down.size>0:Ze(e.keyState.down,m)}a(H,"isKeyDown");function j(m){return m===void 0?e.keyState.released.size>0:Ze(e.keyState.released,m)}a(j,"isKeyReleased");function J(m){return m===void 0?e.mergedGamepadState.buttonState.pressed.size>0:Ze(e.mergedGamepadState.buttonState.pressed,m)}a(J,"isGamepadButtonPressed");function V(m){return m===void 0?e.mergedGamepadState.buttonState.down.size>0:Ze(e.mergedGamepadState.buttonState.down,m)}a(V,"isGamepadButtonDown");function X(m){return m===void 0?e.mergedGamepadState.buttonState.released.size>0:Ze(e.mergedGamepadState.buttonState.released,m)}a(X,"isGamepadButtonReleased");function se(m){return m===void 0?e.buttonState.pressed.size>0:Ze(e.buttonState.pressed,m)}a(se,"isButtonPressed");function ee(m){return m===void 0?e.buttonState.down.size>0:Ze(e.buttonState.down,m)}a(ee,"isButtonDown");function $(m){return m===void 0?e.buttonState.released.size>0:Ze(e.buttonState.released,m)}a($,"isButtonReleased");function fe(m){var q;return(q=e.buttons)==null?void 0:q[m]}a(fe,"getButton");function N(m,q){e.buttons[m]={...e.buttons[m],...q}}a(N,"setButton");function tt(m){e.buttonState.press(m),e.events.trigger("buttonPress",m)}a(tt,"pressButton");function ft(m){e.buttonState.release(m),e.events.trigger("buttonRelease",m)}a(ft,"releaseButton");function Gt(m){return e.events.on("resize",m)}a(Gt,"onResize");let Mr=ue(m=>e.events.on("keyDown",m),(m,q)=>e.events.on("keyDown",C=>Ne(m,C)&&q(C))),qr=ue(m=>e.events.on("keyPress",q=>m(q)),(m,q)=>e.events.on("keyPress",C=>Ne(m,C)&&q(C))),Wr=ue(m=>e.events.on("keyPressRepeat",m),(m,q)=>e.events.on("keyPressRepeat",C=>Ne(m,C)&&q(C))),Zr=ue(m=>e.events.on("keyRelease",m),(m,q)=>e.events.on("keyRelease",C=>Ne(m,C)&&q(C))),jt=ue(m=>e.events.on("mouseDown",q=>m(q)),(m,q)=>e.events.on("mouseDown",C=>Ne(m,C)&&q(C))),Qe=ue(m=>e.events.on("mousePress",q=>m(q)),(m,q)=>e.events.on("mousePress",C=>Ne(m,C)&&q(C))),Jr=ue(m=>e.events.on("mouseRelease",q=>m(q)),(m,q)=>e.events.on("mouseRelease",C=>C===m&&q(C)));function Pt(m){return e.events.on("mouseMove",()=>m(T(),A()))}a(Pt,"onMouseMove");function L(m){return e.events.on("charInput",m)}a(L,"onCharInput");function K(m){return e.events.on("touchStart",m)}a(K,"onTouchStart");function Q(m){return e.events.on("touchMove",m)}a(Q,"onTouchMove");function oe(m){return e.events.on("touchEnd",m)}a(oe,"onTouchEnd");function ye(m){return e.events.on("scroll",m)}a(ye,"onScroll");function te(m){return e.events.on("hide",m)}a(te,"onHide");function Se(m){return e.events.on("show",m)}a(Se,"onShow");let pt=ue(m=>e.events.on("gamepadButtonPress",(q,C)=>m(q,C)),(m,q)=>e.events.on("gamepadButtonPress",(C,D)=>Ne(m,C)&&q(C,D))),Ns=ue(m=>e.events.on("gamepadButtonDown",(q,C)=>m(q,C)),(m,q)=>e.events.on("gamepadButtonDown",(C,D)=>Ne(m,C)&&q(C,D))),Gs=ue(m=>e.events.on("gamepadButtonRelease",(q,C)=>m(q,C)),(m,q)=>e.events.on("gamepadButtonRelease",(C,D)=>Ne(m,C)&&q(C,D)));function $r(m,q){return e.events.on("gamepadStick",(C,D,G)=>C===m&&q(D,G))}a($r,"onGamepadStick");function _r(m){e.events.on("gamepadConnect",m)}a(_r,"onGamepadConnect");function Br(m){e.events.on("gamepadDisconnect",m)}a(Br,"onGamepadDisconnect");function Ve(m){return e.mergedGamepadState.stickState.get(m)||new B(0)}a(Ve,"getGamepadStick");function rt(){return[...e.charInputted]}a(rt,"charInputted");function Vt(){return[...e.gamepads]}a(Vt,"getGamepads");let He=ue(m=>e.events.on("buttonPress",q=>m(q)),(m,q)=>e.events.on("buttonPress",C=>Ne(m,C)&&q(C))),Cr=ue(m=>e.events.on("buttonDown",q=>m(q)),(m,q)=>e.events.on("buttonDown",C=>Ne(m,C)&&q(C))),st=ue(m=>e.events.on("buttonRelease",q=>m(q)),(m,q)=>e.events.on("buttonRelease",C=>Ne(m,C)&&q(C)));function Pr(){e.events.trigger("input"),e.keyState.down.forEach(m=>e.events.trigger("keyDown",m)),e.mouseState.down.forEach(m=>e.events.trigger("mouseDown",m)),e.buttonState.down.forEach(m=>{e.events.trigger("buttonDown",m)}),fi()}a(Pr,"processInput");function di(){e.keyState.update(),e.mouseState.update(),e.buttonState.update(),e.mergedGamepadState.buttonState.update(),e.mergedGamepadState.stickState.forEach((m,q)=>{e.mergedGamepadState.stickState.set(q,new B(0))}),e.charInputted=[],e.isMouseMoved=false,e.mouseDeltaPos=new B(0),e.gamepadStates.forEach(m=>{m.buttonState.update(),m.stickState.forEach((q,C)=>{m.stickState.set(C,new B(0))})})}a(di,"resetInput");function js(m){let q={index:m.index,isPressed:a(C=>{var D;return((D=e.gamepadStates.get(m.index))==null?void 0:D.buttonState.pressed.has(C))||false},"isPressed"),isDown:a(C=>{var D;return((D=e.gamepadStates.get(m.index))==null?void 0:D.buttonState.down.has(C))||false},"isDown"),isReleased:a(C=>{var D;return((D=e.gamepadStates.get(m.index))==null?void 0:D.buttonState.released.has(C))||false},"isReleased"),getStick:a(C=>{var D;return((D=e.gamepadStates.get(m.index))==null?void 0:D.stickState.get(C))||E()},"getStick")};return e.gamepads.push(q),e.gamepadStates.set(m.index,{buttonState:new kr,stickState:new Map([["left",new B(0)],["right",new B(0)]])}),q}a(js,"registerGamepad");function ci(m){e.gamepads=e.gamepads.filter(q=>q.index!==m.index),e.gamepadStates.delete(m.index)}a(ci,"removeGamepad");function fi(){var m,q;for(let C of navigator.getGamepads())C&&!e.gamepadStates.has(C.index)&&js(C);for(let C of e.gamepads){let D=navigator.getGamepads()[C.index];if(!D)continue;let G=(t.gamepads??{})[D.id]||xi[D.id]||xi.default,le=e.gamepadStates.get(C.index);if(le){for(let be=0;be{e.buttonState.press(it),e.events.trigger("buttonPress",it)})),e.mergedGamepadState.buttonState.press(pe),le.buttonState.press(pe),e.events.trigger("gamepadButtonPress",pe,C)}else le.buttonState.down.has(pe)&&(We&&((q=e.buttonsByGamepad.get(pe))==null?void 0:q.forEach(it=>{e.buttonState.release(it),e.events.trigger("buttonRelease",it)})),e.mergedGamepadState.buttonState.release(pe),le.buttonState.release(pe),e.events.trigger("gamepadButtonRelease",pe,C))}for(let be in G.sticks){let pe=G.sticks[be];if(!pe)continue;let nt=new B(D.axes[pe.x],D.axes[pe.y]);le.stickState.set(be,nt),e.mergedGamepadState.stickState.set(be,nt),e.events.trigger("gamepadStick",be,nt,C)}}}}a(fi,"processGamepad");let ke={},Vs={},es={},pi=t.pixelDensity||1;ke.mousemove=m=>{let q=new B(m.offsetX,m.offsetY),C=new B(m.movementX,m.movementY);if(y()){let D=e.canvas.width/pi,G=e.canvas.height/pi,le=window.innerWidth,be=window.innerHeight,pe=le/be,nt=D/G;if(pe>nt){let We=be/G,it=(le-D*We)/2;q.x=ze(m.offsetX-it,0,D*We,0,D),q.y=ze(m.offsetY,0,G*We,0,G)}else{let We=le/D,it=(be-G*We)/2;q.x=ze(m.offsetX,0,D*We,0,D),q.y=ze(m.offsetY-it,0,G*We,0,G)}}e.events.onOnce("input",()=>{e.isMouseMoved=true,e.mousePos=q,e.mouseDeltaPos=C,e.events.trigger("mouseMove")})};let gi=["left","middle","right","back","forward"];ke.mousedown=m=>{e.events.onOnce("input",()=>{var C;let q=gi[m.button];q&&(e.lastInputDevice="mouse",e.buttonsByMouse.has(q)&&((C=e.buttonsByMouse.get(q))==null?void 0:C.forEach(D=>{e.buttonState.press(D),e.events.trigger("buttonPress",D)})),e.mouseState.press(q),e.events.trigger("mousePress",q))})},ke.mouseup=m=>{e.events.onOnce("input",()=>{var C;let q=gi[m.button];q&&(e.buttonsByMouse.has(q)&&((C=e.buttonsByMouse.get(q))==null?void 0:C.forEach(D=>{e.buttonState.release(D),e.events.trigger("buttonRelease",D)})),e.mouseState.release(q),e.events.trigger("mouseRelease",q))})};let Kl=new Set([" ","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab"]),mi={ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up",ArrowDown:"down"," ":"space"};ke.keydown=m=>{Kl.has(m.key)&&m.preventDefault(),e.events.onOnce("input",()=>{var D,G;let q=mi[m.key]||m.key.toLowerCase(),C=m.code;if(q===void 0)throw new Error(`Unknown key: ${m.key}`);q.length===1?(e.events.trigger("charInput",q),e.charInputted.push(q)):q==="space"&&(e.events.trigger("charInput"," "),e.charInputted.push(" ")),m.repeat?(e.keyState.pressRepeat(q),e.events.trigger("keyPressRepeat",q)):(e.lastInputDevice="keyboard",e.buttonsByKey.has(q)&&((D=e.buttonsByKey.get(q))==null?void 0:D.forEach(le=>{e.buttonState.press(le),e.events.trigger("buttonPress",le)})),e.buttonsByKeyCode.has(C)&&((G=e.buttonsByKeyCode.get(C))==null?void 0:G.forEach(le=>{e.buttonState.press(le),e.events.trigger("buttonPress",le)})),e.keyState.press(q),e.events.trigger("keyPressRepeat",q),e.events.trigger("keyPress",q))})},ke.keyup=m=>{e.events.onOnce("input",()=>{var D,G;let q=mi[m.key]||m.key.toLowerCase(),C=m.code;e.buttonsByKey.has(q)&&((D=e.buttonsByKey.get(q))==null?void 0:D.forEach(le=>{e.buttonState.release(le),e.events.trigger("buttonRelease",le)})),e.buttonsByKeyCode.has(C)&&((G=e.buttonsByKeyCode.get(C))==null?void 0:G.forEach(le=>{e.buttonState.release(le),e.events.trigger("buttonRelease",le)})),e.keyState.release(q),e.events.trigger("keyRelease",q)})},ke.touchstart=m=>{m.preventDefault(),e.events.onOnce("input",()=>{var D;let q=[...m.changedTouches],C=e.canvas.getBoundingClientRect();t.touchToMouse!==false&&(e.mousePos=new B(q[0].clientX-C.x,q[0].clientY-C.y),e.lastInputDevice="mouse",e.buttonsByMouse.has("left")&&((D=e.buttonsByMouse.get("left"))==null?void 0:D.forEach(G=>{e.buttonState.press(G),e.events.trigger("buttonPress",G)})),e.mouseState.press("left"),e.events.trigger("mousePress","left")),q.forEach(G=>{e.events.trigger("touchStart",new B(G.clientX-C.x,G.clientY-C.y),G)})})},ke.touchmove=m=>{m.preventDefault(),e.events.onOnce("input",()=>{let q=[...m.changedTouches],C=e.canvas.getBoundingClientRect();if(t.touchToMouse!==false){let D=e.mousePos;e.mousePos=new B(q[0].clientX-C.x,q[0].clientY-C.y),e.mouseDeltaPos=e.mousePos.sub(D),e.events.trigger("mouseMove")}q.forEach(D=>{e.events.trigger("touchMove",new B(D.clientX-C.x,D.clientY-C.y),D)})})},ke.touchend=m=>{e.events.onOnce("input",()=>{var D;let q=[...m.changedTouches],C=e.canvas.getBoundingClientRect();t.touchToMouse!==false&&(e.mousePos=new B(q[0].clientX-C.x,q[0].clientY-C.y),e.mouseDeltaPos=new B(0,0),e.buttonsByMouse.has("left")&&((D=e.buttonsByMouse.get("left"))==null?void 0:D.forEach(G=>{e.buttonState.release(G),e.events.trigger("buttonRelease",G)})),e.mouseState.release("left"),e.events.trigger("mouseRelease","left")),q.forEach(G=>{e.events.trigger("touchEnd",new B(G.clientX-C.x,G.clientY-C.y),G)})})},ke.touchcancel=m=>{e.events.onOnce("input",()=>{let q=[...m.changedTouches],C=e.canvas.getBoundingClientRect();t.touchToMouse!==false&&(e.mousePos=new B(q[0].clientX-C.x,q[0].clientY-C.y),e.mouseState.release("left"),e.events.trigger("mouseRelease","left")),q.forEach(D=>{e.events.trigger("touchEnd",new B(D.clientX-C.x,D.clientY-C.y),D)})})},ke.wheel=m=>{m.preventDefault(),e.events.onOnce("input",()=>{e.events.trigger("scroll",new B(m.deltaX,m.deltaY))})},ke.contextmenu=m=>m.preventDefault(),Vs.visibilitychange=()=>{document.visibilityState==="visible"?(e.skipTime=true,e.isHidden=false,e.events.trigger("show")):(e.isHidden=true,e.events.trigger("hide"))},es.gamepadconnected=m=>{let q=js(m.gamepad);e.events.onOnce("input",()=>{e.events.trigger("gamepadConnect",q)})},es.gamepaddisconnected=m=>{let q=Vt().filter(C=>C.index===m.gamepad.index)[0];ci(m.gamepad),e.events.onOnce("input",()=>{e.events.trigger("gamepadDisconnect",q)})};for(let[m,q]of Object.entries(ke))e.canvas.addEventListener(m,q);for(let[m,q]of Object.entries(Vs))document.addEventListener(m,q);for(let[m,q]of Object.entries(es))window.addEventListener(m,q);let yi=new ResizeObserver(m=>{for(let q of m)if(q.target===e.canvas){if(e.lastWidth===e.canvas.offsetWidth&&e.lastHeight===e.canvas.offsetHeight)return;e.lastWidth=e.canvas.offsetWidth,e.lastHeight=e.canvas.offsetHeight,e.events.onOnce("input",()=>{e.events.trigger("resize")})}});return yi.observe(e.canvas),{state:e,dt:r,fixedDt:s,restDt:n,time:o,run:R,canvas:e.canvas,fps:d,numFrames:l,quit:P,isHidden:i,setFullscreen:p,isFullscreen:y,setCursor:f,screenshot:u,getGamepads:Vt,getCursor:x,setCursorLocked:h,isCursorLocked:w,isTouchscreen:O,mousePos:T,mouseDeltaPos:A,isKeyDown:H,isKeyPressed:F,isKeyPressedRepeat:U,isKeyReleased:j,isMouseDown:S,isMousePressed:v,isMouseReleased:k,isMouseMoved:I,isGamepadButtonPressed:J,isGamepadButtonDown:V,isGamepadButtonReleased:X,getGamepadStick:Ve,isButtonPressed:se,isButtonDown:ee,isButtonReleased:$,setButton:N,getButton:fe,pressButton:tt,releaseButton:ft,charInputted:rt,onResize:Gt,onKeyDown:Mr,onKeyPress:qr,onKeyPressRepeat:Wr,onKeyRelease:Zr,onMouseDown:jt,onMousePress:Qe,onMouseRelease:Jr,onMouseMove:Pt,onCharInput:L,onTouchStart:K,onTouchMove:Q,onTouchEnd:oe,onScroll:ye,onHide:te,onShow:Se,onGamepadButtonDown:Ns,onGamepadButtonPress:pt,onGamepadButtonRelease:Gs,onGamepadStick:$r,onGamepadConnect:_r,onGamepadDisconnect:Br,onButtonPress:He,onButtonDown:Cr,onButtonRelease:st,getLastInputDeviceType:wu,events:e.events}},"initApp");function xe(){return c.app.dt()}a(xe,"dt");function hs(){return c.app.fixedDt()}a(hs,"fixedDt");function ds(){return c.app.restDt()}a(ds,"restDt");var Su=new B(-1,-1);var Mu=new B(0,-1);var qu=new B(1,-1);var Bu=new B(-1,0);var Cu=new B(0,0);var Pu=new B(1,0);var Ru=new B(-1,1);var ku=new B(0,1);var Iu=new B(1,1);function Ht(t){switch(t){case"topleft":return Su;case"top":return Mu;case"topright":return qu;case"left":return Bu;case"center":return Cu;case"right":return Pu;case"botleft":return Ru;case"bot":return ku;case"botright":return Iu;default:return t}}a(Ht,"anchorPt");function Oa(t){switch(t){case"left":return 0;case"center":return .5;case"right":return 1;default:return 0}}a(Oa,"alignPt");function Ua(t){return t.createBuffer(1,1,44100)}a(Ua,"createEmptyAudioBuffer");var rs=2.5949095;var vi=1.70158+1;var bi=2*Math.PI/3;var Ei=2*Math.PI/4.5;var is={linear:a(t=>t,"linear"),easeInSine:a(t=>1-Math.cos(t*Math.PI/2),"easeInSine"),easeOutSine:a(t=>Math.sin(t*Math.PI/2),"easeOutSine"),easeInOutSine:a(t=>-(Math.cos(Math.PI*t)-1)/2,"easeInOutSine"),easeInQuad:a(t=>t*t,"easeInQuad"),easeOutQuad:a(t=>1-(1-t)*(1-t),"easeOutQuad"),easeInOutQuad:a(t=>t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2,"easeInOutQuad"),easeInCubic:a(t=>t*t*t,"easeInCubic"),easeOutCubic:a(t=>1-Math.pow(1-t,3),"easeOutCubic"),easeInOutCubic:a(t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,"easeInOutCubic"),easeInQuart:a(t=>t*t*t*t,"easeInQuart"),easeOutQuart:a(t=>1-Math.pow(1-t,4),"easeOutQuart"),easeInOutQuart:a(t=>t<.5?8*t*t*t*t:1-Math.pow(-2*t+2,4)/2,"easeInOutQuart"),easeInQuint:a(t=>t*t*t*t*t,"easeInQuint"),easeOutQuint:a(t=>1-Math.pow(1-t,5),"easeOutQuint"),easeInOutQuint:a(t=>t<.5?16*t*t*t*t*t:1-Math.pow(-2*t+2,5)/2,"easeInOutQuint"),easeInExpo:a(t=>t===0?0:Math.pow(2,10*t-10),"easeInExpo"),easeOutExpo:a(t=>t===1?1:1-Math.pow(2,-10*t),"easeOutExpo"),easeInOutExpo:a(t=>t===0?0:t===1?1:t<.5?Math.pow(2,20*t-10)/2:(2-Math.pow(2,-20*t+10))/2,"easeInOutExpo"),easeInCirc:a(t=>1-Math.sqrt(1-Math.pow(t,2)),"easeInCirc"),easeOutCirc:a(t=>Math.sqrt(1-Math.pow(t-1,2)),"easeOutCirc"),easeInOutCirc:a(t=>t<.5?(1-Math.sqrt(1-Math.pow(2*t,2)))/2:(Math.sqrt(1-Math.pow(-2*t+2,2))+1)/2,"easeInOutCirc"),easeInBack:a(t=>vi*t*t*t-1.70158*t*t,"easeInBack"),easeOutBack:a(t=>1+vi*Math.pow(t-1,3)+1.70158*Math.pow(t-1,2),"easeOutBack"),easeInOutBack:a(t=>t<.5?Math.pow(2*t,2)*((rs+1)*2*t-rs)/2:(Math.pow(2*t-2,2)*((rs+1)*(t*2-2)+rs)+2)/2,"easeInOutBack"),easeInElastic:a(t=>t===0?0:t===1?1:-Math.pow(2,10*t-10)*Math.sin((t*10-10.75)*bi),"easeInElastic"),easeOutElastic:a(t=>t===0?0:t===1?1:Math.pow(2,-10*t)*Math.sin((t*10-.75)*bi)+1,"easeOutElastic"),easeInOutElastic:a(t=>t===0?0:t===1?1:t<.5?-(Math.pow(2,20*t-10)*Math.sin((20*t-11.125)*Ei))/2:Math.pow(2,-20*t+10)*Math.sin((20*t-11.125)*Ei)/2+1,"easeInOutElastic"),easeInBounce:a(t=>1-is.easeOutBounce(1-t),"easeInBounce"),easeOutBounce:a(t=>t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375,"easeOutBounce"),easeInOutBounce:a(t=>t<.5?(1-is.easeOutBounce(1-2*t))/2:(1+is.easeOutBounce(2*t-1))/2,"easeInOutBounce")};var Or=is;function La(t,e,r){let s=[],n=e;for(s.push(n);n!==t;){if(n=r.get(n),n==null)return null;s.push(n)}return s.reverse()}a(La,"buildPath");function Ha(t,e,r){var o;let s=new xa((d,l)=>d.coste.y!=s.a.y>e.y&&e.x<(s.a.x-s.b.x)*(e.y-s.b.y)/(s.a.y-s.b.y)+s.b.x&&(r=!r);return r}},a(lr,"NavPolygon"),lr);var ur;var Fu=(ur=class{constructor(){b(this,"_polygons");b(this,"_pointCache");b(this,"_edgeCache");this._polygons=[],this._pointCache={},this._edgeCache={}}_addPoint(e){let r=this._pointCache[`${e.x}_${e.y}`];return r||(r=e.clone(),this._pointCache[`${e.x}_${e.y}`]=r,r)}_addEdge(e){let r=`${e.a.x}_${e.a.y}-${e.b.x}_${e.b.y}`;return this._edgeCache[r]=e,e}_findEdge(e,r){let s=`${e.x}_${e.y}-${r.x}_${r.y}`;return this._edgeCache[s]}_findCommonEdge(e,r){for(let s of e.edges){let n=this._findEdge(s.b,s.a);if(n&&n.polygon.deref().id===r.id)return n}return null}addPolygon(e){let r=new Tu(this._polygons.length),s=e.map((n,i)=>new Du(n,e[(i+1)%e.length],r));r.edges=s,this._polygons.push(r);for(let n of r.edges)this._addEdge(n);return r}addRect(e,r){let s=this._addPoint(e),n=this._addPoint(e.add(r.x,0)),i=this._addPoint(e.add(r)),o=this._addPoint(e.add(0,r.y));return this.addPolygon([s,n,i,o])}_getLocation(e){for(let r of this._polygons)if(r.contains(e))return r;return null}getNeighbours(e){let r=[];for(let s of this._polygons[e].edges){let n=this._findEdge(s.b,s.a);if(n){let i=n.polygon.deref();i&&r.push(i.id)}}return r}getCost(e,r){return 1}getHeuristic(e,r){let s=this._polygons[e],n=this._polygons[r],i=s.centroid.x-n.centroid.x,o=s.centroid.y-n.centroid.y;return Math.sqrt(i*i+o*o)}getPath(e,r){return e===void 0||r===void 0?[]:e===r?[e,r]:Ha(this,e,r)}getWaypointPath(e,r,s){let n=(s==null?void 0:s.type)||"centroids",i=this._getLocation(e),o=this._getLocation(r);if(i===void 0||o===void 0)return[];let d=this.getPath(i.id,o.id);if(!d)return[];if(n==="edges"){let l=[];for(let u=1;uthis._polygons[l].centroid),r]}},a(ur,"NavMesh"),ur);function Wt(t){let e=new et;return t.pos&&e.translate(t.pos),t.scale&&e.scale(t.scale),t.angle&&e.rotate(t.angle),t.parent?e.mult(t.parent.transform):e}a(Wt,"calcTransform");function Na(t){return new B(t.x/ve()*2-1,-t.y/Ee()*2+1)}a(Na,"screen2ndc");function Xt(t,e,r,s,n,i=1){s=me(s%360),n=me(n%360),n<=s&&(n+=Math.PI*2);let o=[],d=Math.ceil((n-s)/me(8)*i),l=(n-s)/d,u=E(Math.cos(s),Math.sin(s)),f=E(Math.cos(l),Math.sin(l));for(let x=0;x<=d;x++)o.push(t.add(e*u.x,r*u.y)),u=E(u.x*f.x-u.y*f.y,u.x*f.y+u.y*f.x);return o}a(Xt,"getArcPts");function Ga(...t){let e=re(...t),r=t[3]??1;c.gfx.bgColor=e,c.gfx.bgAlpha=r,c.gfx.ggl.gl.clearColor(e.r/255,e.g/255,e.b/255,r)}a(Ga,"setBackground");function ja(){var t,e;return((e=(t=c.gfx.bgColor)==null?void 0:t.clone)==null?void 0:e.call(t))??null}a(ja,"getBackground");function de(...t){if(t[0]===void 0)return;let e=E(...t);e.x===0&&e.y===0||c.gfx.transform.translate(e)}a(de,"pushTranslate");function Ie(){c.gfx.transformStack.push(c.gfx.transform.clone())}a(Ie,"pushTransform");function Va(t){c.gfx.transform=t.clone()}a(Va,"pushMatrix");function vr(...t){if(t[0]===void 0)return;let e=E(...t);e.x===1&&e.y===1||c.gfx.transform.scale(e)}a(vr,"pushScale");function Ft(t){t&&c.gfx.transform.rotate(t)}a(Ft,"pushRotate");function Be(){c.gfx.transformStack.length>0&&(c.gfx.transform=c.gfx.transformStack.pop())}a(Be,"popTransform");function De(){c.gfx.renderer.flush()}a(De,"flush");function ve(){return c.gfx.width}a(ve,"width");function Ee(){return c.gfx.height}a(Ee,"height");function Sn(){return(c.gfx.viewport.width+c.gfx.viewport.height)/(c.gfx.width+c.gfx.height)}a(Sn,"getViewportScale");function Ka(t){return new B(t.x*c.gfx.viewport.width/c.gfx.width,t.y*c.gfx.viewport.height/c.gfx.height)}a(Ka,"contentToView");function Ya(t){return new B((t.x-c.gfx.viewport.x)*ve()/c.gfx.viewport.width,(t.y-c.gfx.viewport.y)*Ee()/c.gfx.viewport.height)}a(Ya,"windowToContent");function Mn(){return Ya(c.app.mousePos())}a(Mn,"mousePos");function Ur(){return E(ve()/2,Ee()/2)}a(Ur,"center");var hr;var Ou=(hr=class{constructor(e,r,s,n){b(this,"lastTextureId",0);b(this,"textures",[]);b(this,"bigTextures",[]);b(this,"texturesPosition",new Map);b(this,"canvas");b(this,"c2d");b(this,"x",0);b(this,"y",0);b(this,"curHeight",0);b(this,"gfx");b(this,"padding");this.gfx=e,this.canvas=document.createElement("canvas"),this.canvas.width=r,this.canvas.height=s,this.textures=[mt.fromImage(e,this.canvas)],this.bigTextures=[],this.padding=n;let i=this.canvas.getContext("2d");if(!i)throw new Error("Failed to get 2d context");this.c2d=i}add(e){let r=e.width+this.padding*2,s=e.height+this.padding*2;if(r>this.canvas.width||s>this.canvas.height){let o=mt.fromImage(this.gfx,e);return this.bigTextures.push(o),[o,new ce(0,0,1,1),0]}this.x+r>this.canvas.width&&(this.x=0,this.y+=this.curHeight,this.curHeight=0),this.y+s>this.canvas.height&&(this.c2d.clearRect(0,0,this.canvas.width,this.canvas.height),this.textures.push(mt.fromImage(this.gfx,this.canvas)),this.x=0,this.y=0,this.curHeight=0);let n=this.textures[this.textures.length-1],i=new B(this.x+this.padding,this.y+this.padding);return this.x+=r,s>this.curHeight&&(this.curHeight=s),e instanceof ImageData?this.c2d.putImageData(e,i.x,i.y):this.c2d.drawImage(e,i.x,i.y),n.update(this.canvas),this.texturesPosition.set(this.lastTextureId,{position:i,size:new B(e.width,e.height),texture:n}),this.lastTextureId++,[n,new ce(i.x/this.canvas.width,i.y/this.canvas.height,e.width/this.canvas.width,e.height/this.canvas.height),this.lastTextureId-1]}free(){for(let e of this.textures)e.free();for(let e of this.bigTextures)e.free()}},a(hr,"TexPacker"),hr);function Ue(t){return typeof t!="string"||Sa(t)?t:c.assets.urlPrefix+t}a(Ue,"fixURL");var Dt;var je=(Dt=class{constructor(e){b(this,"loaded",false);b(this,"data",null);b(this,"error",null);b(this,"onLoadEvents",new qe);b(this,"onErrorEvents",new qe);b(this,"onFinishEvents",new qe);e.then(r=>{this.loaded=true,this.data=r,this.onLoadEvents.trigger(r)}).catch(r=>{if(this.error=r,this.onErrorEvents.numListeners()>0)this.onErrorEvents.trigger(r);else throw r}).finally(()=>{this.onFinishEvents.trigger(),this.loaded=true})}static loaded(e){let r=new Dt(Promise.resolve(e));return r.data=e,r.loaded=true,r}onLoad(e){return this.loaded&&this.data?e(this.data):this.onLoadEvents.add(e),this}onError(e){return this.loaded&&this.error?e(this.error):this.onErrorEvents.add(e),this}onFinish(e){return this.loaded?e():this.onFinishEvents.add(e),this}then(e){return this.onLoad(e)}catch(e){return this.onError(e)}finally(e){return this.onFinish(e)}},a(Dt,"Asset"),Dt);var dr;var Kt=(dr=class{constructor(){b(this,"assets",new Map);b(this,"lastUID",0)}add(e,r){let s=e??this.lastUID+++"",n=new je(r);return this.assets.set(s,n),n}addLoaded(e,r){let s=e??this.lastUID+++"",n=je.loaded(r);return this.assets.set(s,n),n}get(e){return this.assets.get(e)}progress(){if(this.assets.size===0)return 1;let e=0;return this.assets.forEach(r=>{r.loaded&&e++}),e/this.assets.size}getFailedAssets(){return Array.from(this.assets.keys()).filter(e=>this.assets.get(e).error!==null).map(e=>[e,this.assets.get(e)])}},a(dr,"AssetBucket"),dr);function Ds(t){return fetch(t).then(e=>{if(!e.ok)throw new Error(`Failed to fetch "${t}"`);return e})}a(Ds,"fetchURL");function zr(t){return Ds(t).then(e=>e.json())}a(zr,"fetchJSON");function za(t){return Ds(t).then(e=>e.text())}a(za,"fetchText");function Xa(t){return Ds(t).then(e=>e.arrayBuffer())}a(Xa,"fetchArrayBuffer");function Qa(t){return t!==void 0&&(c.assets.urlPrefix=t),c.assets.urlPrefix}a(Qa,"loadRoot");function Wa(t,e){return c.assets.custom.add(t,zr(Ue(e)))}a(Wa,"loadJSON");function Xr(t){let e=new Image;return e.crossOrigin="anonymous",e.src=t,new Promise((r,s)=>{e.onload=()=>r(e),e.onerror=()=>s(new Error(`Failed to load image from "${t}"`))})}a(Xr,"loadImg");function Et(){let t=[c.assets.sprites,c.assets.sounds,c.assets.shaders,c.assets.fonts,c.assets.bitmapFonts,c.assets.custom];return t.reduce((e,r)=>e+r.progress(),0)/t.length}a(Et,"loadProgress");function qn(){return[c.assets.sprites,c.assets.sounds,c.assets.shaders,c.assets.fonts,c.assets.bitmapFonts,c.assets.custom].reduce((t,e)=>t.concat(e.getFailedAssets()),[])}a(qn,"getFailedAssets");function Za(t){return c.assets.custom.get(t)??null}a(Za,"getAsset");function cs(t){return c.assets.custom.add(null,t)}a(cs,"load");var Uu=a((t,e)=>({urlPrefix:"",sprites:new Kt,fonts:new Kt,bitmapFonts:new Kt,sounds:new Kt,shaders:new Kt,custom:new Kt,music:{},packer:new Ou(t,2048,2048,e),loaded:false}),"initAssets");var Lu="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAD0AAAA1CAYAAADyMeOEAAAAAXNSR0IArs4c6QAAAoVJREFUaIHdm7txwkAQhheGAqACiCHzOKQDQrqgILpwSAeEDBnEUAF0gCMxZ7G72qce/mec2Lpf9+3unaS78wgSNZ8uX5729+d1FNWXUuGmXlBOUUEIMckEpeQJgBu6C+BSFngztBR2vd+ovY+7g+p6LbgaWgJrAeUkDYIUXgXdBBwNi6kpABJwMTQH3AZsXRR8GHTfgEth8E3gjdAUcNewpbTgY85sCMCUuOokozE0YM0YRzM9NGAAXd8+omAF5h4lnmBRvpSnZHyLoLEbaN+aKB9KWv/KWw0tAbbANnlG+UvB2dm77NxxdwgBpjrF/d7rW9cbmpvio2A5z8iAYpVU8pGZlo6/2+MSco2lHfd3rv9jAP038e1xef9o2mjvYb2OqpqKE81028/jeietlSEVO5FRWsxWsJit1G3aFpW8iWe5RwpiCZAk25QvV6nz6fIlynRGuTd5WqpJ4guAlDfVKBK87hXljflgv1ON6fV+4+5gVlA17SfeG0heKqQd4l4jI/wrmaA9N9R4ar+wpHJDZyrrfcH0nB66PqAzPi76pn+faSyJk/vzOorYhGurQrzj/P68jtBMawHaHBIR9xoD5O34dy0qQOSYHvqExq2TpT2nf76+w7y251OYF0CRaU+J920TwLUa6inx6OxE6g80lu2ux7Y2eJLF/rCXE6zEPdnenk9o+4ih9AEdnW2q81HXl5LuU6OTl2fXUhqganbXAGq3g6jJOWV/OnoesO6YqqEB/GdNsjf7uHtwj2DzmRNpp7iOZfm6D9oAxB6Yi1gC4oIYeo4MIPdopEQRB+cAko5J1tW386HpB2Kz1eop4Epdwls/kgZ1sh8gZsEjdcWkr//D8Qu3Z3l5Nl1NtAAAAABJRU5ErkJggg==";var _e;var St=(_e=class{constructor(e,r,s={},n=null){b(this,"tex");b(this,"frames",[new ce(0,0,1,1)]);b(this,"anims",{});b(this,"slice9",null);this.tex=e,r&&(this.frames=r),this.anims=s,this.slice9=n}get width(){return this.tex.width*this.frames[0].w}get height(){return this.tex.height*this.frames[0].h}static from(e,r={}){return typeof e=="string"?_e.fromURL(e,r):Promise.resolve(_e.fromImage(e,r))}static fromImage(e,r={}){let[s,n]=c.assets.packer.add(e),i=r.frames?r.frames.map(o=>new ce(n.x+o.x*n.w,n.y+o.y*n.h,o.w*n.w,o.h*n.h)):Cn(r.sliceX||1,r.sliceY||1,n.x,n.y,n.w,n.h);return new _e(s,i,r.anims,r.slice9)}static fromURL(e,r={}){return Xr(e).then(s=>_e.fromImage(s,r))}},a(_e,"SpriteData"),_e);function Ir(t){if(typeof t=="string"){let e=Bn(t);if(e)return e;if(Et()<1)return null;throw new Error(`Sprite not found: ${t}`)}else{if(t instanceof St)return je.loaded(t);if(t instanceof je)return t;throw new Error(`Invalid sprite: ${t}`)}}a(Ir,"resolveSprite");function Bn(t){return c.assets.sprites.get(t)??null}a(Bn,"getSprite");function Zt(t,e,r={sliceX:1,sliceY:1,anims:{}}){return e=Ue(e),Array.isArray(e)?e.some(s=>typeof s=="string")?c.assets.sprites.add(t,Promise.all(e.map(s=>typeof s=="string"?Xr(s):Promise.resolve(s))).then(s=>$s(s,r))):c.assets.sprites.addLoaded(t,$s(e,r)):typeof e=="string"?c.assets.sprites.add(t,St.from(e,r)):c.assets.sprites.addLoaded(t,St.fromImage(e,r))}a(Zt,"loadSprite");function Cn(t=1,e=1,r=0,s=0,n=1,i=1){let o=[],d=n/t,l=i/e;for(let u=0;u{d instanceof ImageData?i.putImageData(d,l*s,0):i.drawImage(d,l*s,0)});let o=i.getImageData(0,0,t.length*s,n);return St.fromImage(o,{...e,sliceX:t.length,sliceY:1})}a($s,"createSpriteSheet");function Ja(t="bean"){return Zt(t,Lu)}a(Ja,"loadBean");function $a(t,e,r){e=Ue(e),r=Ue(r),typeof e=="string"&&!r&&(r=fu(e)+".json");let s=typeof r=="string"?zr(r):Promise.resolve(r);return c.assets.sprites.add(t,s.then(n=>{let i=n.meta.size,o=n.frames.map(l=>new ce(l.frame.x/i.w,l.frame.y/i.h,l.frame.w/i.w,l.frame.h/i.h)),d={};for(let l of n.meta.frameTags)l.from===l.to?d[l.name]=l.from:d[l.name]={from:l.from,to:l.to,speed:10,loop:true,pingpong:l.direction==="pingpong"};return St.from(e,{frames:o,anims:d})}))}a($a,"loadAseprite");var cr;var as=(cr=class{constructor(e,r={}){b(this,"fontface");b(this,"filter",Xs);b(this,"outline",null);b(this,"size",64);if(this.fontface=e,this.filter=r.filter??Xs,this.size=r.size??64,this.size>256)throw new Error(`Max font size: ${256}`);r.outline&&(this.outline={width:1,color:re(0,0,0)},typeof r.outline=="number"?this.outline.width=r.outline:typeof r.outline=="object"&&(r.outline.width&&(this.outline.width=r.outline.width),r.outline.color&&(this.outline.color=r.outline.color)))}},a(cr,"FontData"),cr);function Pn(t){if(!t)return Pn(c.globalOpt.font??_l);if(typeof t=="string"){let e=kn(t),r=Rn(t);if(e)return e.data??e;if(r)return r.data??r;if(document.fonts.check(`${64}px ${t}`))return t;if(Et()<1)return null;throw new Error(`Font not found: ${t}`)}else if(t instanceof je)return t.data?t.data:t;return t}a(Pn,"resolveFont");function Rn(t){return c.assets.fonts.get(t)??null}a(Rn,"getFont");function _a(t,e,r={}){let s=Ue(e),n=new FontFace(t,typeof e=="string"?`url(${s})`:s);return document.fonts.add(n),c.assets.fonts.add(t,n.load().catch(i=>{throw new Error(`Failed to load font from "${s}": ${i}`)}).then(i=>new as(i,r)))}a(_a,"loadFont");function eo(t,e,r,s){let n=t.width/e,i={},o=s.split("").entries();for(let[d,l]of o)i[l]=new ce(d%n*e,Math.floor(d/n)*r,e,r);return{tex:t,map:i,size:r}}a(eo,"makeFont");function kn(t){return c.assets.bitmapFonts.get(t)??null}a(kn,"getBitmapFont");function to(t,e,r,s,n={}){let i=Ue(e);return c.assets.bitmapFonts.add(t,Xr(i).then(o=>eo(mt.fromImage(c.gfx.ggl,o,n),r,s,n.chars??ma)))}a(to,"loadBitmapFont");function ro(t,e){return e=Ue(e),c.assets.sprites.add(t,new Promise(async r=>{let s=typeof e=="string"?await zr(e):e,n=await Promise.all(s.frames.map(Xr)),i=document.createElement("canvas");i.width=s.width,i.height=s.height*s.frames.length;let o=i.getContext("2d");if(!o)throw new Error("Failed to create canvas context");n.forEach((l,u)=>{o.drawImage(l,0,u*s.height)});let d=await Zt(null,i,{sliceY:s.frames.length,anims:s.anims});r(d)}))}a(ro,"loadPedit");var fr;var Hu=(fr=class{constructor(e,r,s,n){b(this,"ctx");b(this,"glProgram");this.ctx=e,e.onDestroy(()=>this.free());let i=e.gl,o=i.createShader(i.VERTEX_SHADER),d=i.createShader(i.FRAGMENT_SHADER);if(!o||!d)throw new Error("Failed to create shader");i.shaderSource(o,r),i.shaderSource(d,s),i.compileShader(o),i.compileShader(d);let l=i.createProgram();if(this.glProgram=l,i.attachShader(l,o),i.attachShader(l,d),n.forEach((u,f)=>i.bindAttribLocation(l,f,u)),i.linkProgram(l),!i.getProgramParameter(l,i.LINK_STATUS)){let u=i.getShaderInfoLog(o);if(u)throw new Error("VERTEX SHADER "+u);let f=i.getShaderInfoLog(d);if(f)throw new Error("FRAGMENT SHADER "+f)}i.deleteShader(o),i.deleteShader(d)}bind(){this.ctx.pushProgram(this.glProgram)}unbind(){this.ctx.popProgram()}send(e){let r=this.ctx.gl;for(let s in e){let n=e[s],i=r.getUniformLocation(this.glProgram,s);if(typeof n=="number")r.uniform1f(i,n);else if(n instanceof et)r.uniformMatrix4fv(i,false,new Float32Array(n.m));else if(n instanceof Z)r.uniform3f(i,n.r,n.g,n.b);else if(n instanceof B)r.uniform2f(i,n.x,n.y);else if(Array.isArray(n)){n[0];cu(n)?r.uniform1fv(i,n):du(n)?r.uniform2fv(i,n.map(o=>[o.x,o.y]).flat()):hu(n)&&r.uniform3fv(i,n.map(o=>[o.r,o.g,o.b]).flat())}else throw new Error("Unsupported uniform data type")}}free(){this.ctx.gl.deleteProgram(this.glProgram)}},a(fr,"Shader"),fr);function Ts(t,e=Qs,r=Ws){let s=su.replace("{{user}}",e??Qs),n=nu.replace("{{user}}",r??Ws);try{return new Hu(t,s,n,bn.map(i=>i.name))}catch(i){let o=/(?^\w+) SHADER ERROR: 0:(?\d+): (?.+)/,d=pu(i).match(o);if(!(d==null?void 0:d.groups))throw i;let l=Number(d.groups.line)-14,u=d.groups.msg.trim(),f=d.groups.type.toLowerCase();throw new Error(`${f} shader line ${l}: ${u}`)}}a(Ts,"makeShader");function so(t){if(!t)return c.gfx.defShader;if(typeof t=="string"){let e=In(t);if(e)return e.data??e;if(Et()<1)return null;throw new Error(`Shader not found: ${t}`)}else if(t instanceof je)return t.data?t.data:t;return t}a(so,"resolveShader");function In(t){return c.assets.shaders.get(t)??null}a(In,"getShader");function no(t,e,r){return c.assets.shaders.addLoaded(t,Ts(c.gfx.ggl,e,r))}a(no,"loadShader");function io(t,e,r){e=Ue(e),r=Ue(r);let s=a(i=>i?za(i):Promise.resolve(null),"resolveUrl"),n=Promise.all([s(e),s(r)]).then(([i,o])=>Ts(c.gfx.ggl,i,o));return c.assets.shaders.add(t,n)}a(io,"loadShaderURL");var lt;var Lr=(lt=class{constructor(e){b(this,"buf");this.buf=e}static fromArrayBuffer(e){return new Promise((r,s)=>c.audio.ctx.decodeAudioData(e,r,s)).then(r=>new lt(r))}static fromURL(e){return Sa(e)?lt.fromArrayBuffer(ba(e)):Xa(e).then(r=>lt.fromArrayBuffer(r))}},a(lt,"SoundData"),lt);function ao(t){if(typeof t=="string"){let e=Dn(t);if(e)return e;if(Et()<1)return null;throw new Error(`Sound not found: ${t}`)}else{if(t instanceof Lr)return je.loaded(t);if(t instanceof je)return t;throw new Error(`Invalid sound: ${t}`)}}a(ao,"resolveSound");function Dn(t){return c.assets.sounds.get(t)??null}a(Dn,"getSound");function oo(t,e){return e=Ue(e),c.assets.sounds.add(t,typeof e=="string"?Lr.fromURL(e):Lr.fromArrayBuffer(e))}a(oo,"loadSound");function lo(t,e){let r=Ue(e),s=new Audio(r);return s.preload="auto",c.assets.music[t]=r}a(lo,"loadMusic");function Tn(t,e){return t=Ue(t),typeof e=="string"?cs(new Promise((r,s)=>{zr(e).then(n=>{Tn(t,n).then(r).catch(s)})})):cs(St.from(t).then(r=>{let s={};for(let n in e){let i=e[n],o=r.frames[0],d=2048*o.w,l=2048*o.h,u=i.frames?i.frames.map(x=>new ce(o.x+(i.x+x.x)/d*o.w,o.y+(i.y+x.y)/l*o.h,x.w/d*o.w,x.h/l*o.h)):Cn(i.sliceX||1,i.sliceY||1,o.x+i.x/d*o.w,o.y+i.y/l*o.h,i.width/d*o.w,i.height/l*o.h),f=new St(r.tex,u,i.anims);c.assets.sprites.addLoaded(n,f),s[n]=f}return s}))}a(Tn,"loadSpriteAtlas");function ct(t,e,r=false,s,n,i={}){let o=s??c.gfx.defTex,d=n??c.gfx.defShader,l=so(d);if(!l||l instanceof je)return;let u=c.gfx.fixed||r?c.gfx.transform:c.game.cam.transform.mult(c.gfx.transform),f=[];for(let x of t){let h=Na(u.multVec2(x.pos));f.push(h.x,h.y,x.uv.x,x.uv.y,x.color.r/255,x.color.g/255,x.color.b/255,x.opacity)}c.gfx.renderer.push(c.gfx.ggl.gl.TRIANGLES,f,e,l,o,i)}a(ct,"drawRaw");function ut(t){if(!t.pts)throw new Error('drawPolygon() requires property "pts".');let e=t.pts.length;if(!(e<3)){if(Ie(),de(t.pos),vr(t.scale),Ft(t.angle),de(t.offset),t.fill!==false){let r=t.color??Z.WHITE,s=t.pts.map((i,o)=>({pos:new B(i.x,i.y),uv:t.uv?t.uv[o]:new B(0,0),color:t.colors&&t.colors[o]?t.colors[o].mult(r):r,opacity:t.opacity??1})),n;t.triangulate?n=vn(t.pts).map(i=>i.map(o=>t.pts.indexOf(o))).flat():n=[...Array(e-2).keys()].map(i=>[0,i+1,i+2]).flat(),ct(s,t.indices??n,t.fixed,t.uv?t.tex:c.gfx.defTex,t.shader,t.uniform??void 0)}t.outline&&Fs({pts:[...t.pts,t.pts[0]],radius:t.radius,width:t.outline.width,color:t.outline.color,join:t.outline.join,uniform:t.uniform,fixed:t.fixed,opacity:t.opacity??t.outline.opacity}),Be()}}a(ut,"drawPolygon");function Fn(t){if(t.radiusX===void 0||t.radiusY===void 0)throw new Error('drawEllipse() requires properties "radiusX" and "radiusY".');if(t.radiusX===0||t.radiusY===0)return;let e=t.start??0,r=t.end??360,s=Ht(t.anchor??"center").scale(new B(-t.radiusX,-t.radiusY)),n=Xt(s,t.radiusX,t.radiusY,e,r,t.resolution);n.unshift(s);let i=Object.assign({},t,{pts:n,radius:0,...t.gradient?{colors:[t.gradient[0],...Array(n.length-1).fill(t.gradient[1])]}:{}});if(r-e>=360&&t.outline){t.fill!==false&&ut(Object.assign({},i,{outline:null})),ut(Object.assign({},i,{pts:n.slice(1),fill:false}));return}ut(i)}a(Fn,"drawEllipse");function Nt(t){if(typeof t.radius!="number")throw new Error('drawCircle() requires property "radius".');t.radius!==0&&Fn(Object.assign({},t,{radiusX:t.radius,radiusY:t.radius,angle:0}))}a(Nt,"drawCircle");function Qt(t){let{p1:e,p2:r}=t;if(!e||!r)throw new Error('drawLine() requires properties "p1" and "p2".');let s=t.width||1,n=r.sub(e).unit().normal().scale(s*.5),i=[e.sub(n),e.add(n),r.add(n),r.sub(n)].map(o=>({pos:new B(o.x,o.y),uv:new B(0),color:t.color??Z.WHITE,opacity:t.opacity??1}));ct(i,[0,1,3,1,2,3],t.fixed,c.gfx.defTex,t.shader,t.uniform??void 0)}a(Qt,"drawLine");function uo(t){let e=t.pts,r=[],s=(t.width||1)*.5,n=e[0]===e[e.length-1]||e[0].eq(e[e.length-1]),i=t.pos||E(0,0),o;n?o=e[0].sub(e[e.length-2]):o=e[1].sub(e[0]);let d=o.len(),l=o.normal().scale(-s/d),u,f=e[0];if(!n)switch(t.cap){case"square":{let g=o.scale(-s/d);r.push(f.add(g).add(l)),r.push(f.add(g).sub(l));break}case"round":{let g=Math.max(s,10),M=Math.PI/g,p=l.scale(-1),y=Math.cos(M),P=Math.sin(M);for(let R=0;R0?(r.push(u.add(O)),r.push(u.sub(l)),r.push(u.add(O)),r.push(u.sub(y))):(r.push(u.add(l)),r.push(u.sub(O)),r.push(u.add(y)),r.push(u.sub(O))),o=M,d=p,l=y}if(!n)switch(r.push(f.add(l)),r.push(f.sub(l)),t.cap){case"square":{let g=o.scale(s/d);r.push(f.add(g).add(l)),r.push(f.add(g).sub(l));break}case"round":{let g=Math.max(s,10),M=Math.PI/g,p=l.scale(1),y=Math.cos(M),P=Math.sin(M);for(let R=0;R({pos:i.add(g),uv:E(),color:t.color||Z.WHITE,opacity:t.opacity??1})),h=[],w=0;for(let g=0;g0){let T=u.add(O),A=Math.max(s,10),v=me(l.angleBetween(y)/A),S=l,k=Math.cos(v),I=Math.sin(v);for(let F=0;F({pos:i.add(g),uv:E(),color:t.color||Z.WHITE,opacity:t.opacity??1})),h=[],w=0;for(let g=0;g({pos:i.add(g),uv:E(),color:t.color||Z.WHITE,opacity:t.opacity??1})),h=[],w=0;for(let g=0;g2)switch(t.join){case"bevel":return uo(t);case"round":return ho(t);case"miter":return co(t)}if(t.radius&&e.length>=3){Qt(Object.assign({},t,{p1:e[0],p2:e[1]}));for(let s=1;sCs(t.pt1,t.pt2,t.pt3,t.pt4,e),t)}a(fo,"drawBezier");var Tt;var mt=(Tt=class{constructor(e,r,s,n={}){b(this,"ctx");b(this,"src",null);b(this,"glTex");b(this,"width");b(this,"height");this.ctx=e;let i=e.gl,o=e.gl.createTexture();if(!o)throw new Error("Failed to create texture");this.glTex=o,e.onDestroy(()=>this.free()),this.width=r,this.height=s;let d={linear:i.LINEAR,nearest:i.NEAREST}[n.filter??e.opts.texFilter??"nearest"],l={repeat:i.REPEAT,clampToEdge:i.CLAMP_TO_EDGE}[n.wrap??"clampToEdge"];this.bind(),r&&s&&i.texImage2D(i.TEXTURE_2D,0,i.RGBA,r,s,0,i.RGBA,i.UNSIGNED_BYTE,null),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,d),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,d),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,l),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,l),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,true),this.unbind()}static fromImage(e,r,s={}){let n=new Tt(e,r.width,r.height,s);return n.update(r),n.src=r,n}update(e,r=0,s=0){let n=this.ctx.gl;this.bind(),n.texSubImage2D(n.TEXTURE_2D,0,r,s,n.RGBA,n.UNSIGNED_BYTE,e),this.unbind()}bind(){this.ctx.pushTexture2D(this.glTex)}unbind(){this.ctx.popTexture2D()}free(){this.ctx.gl.deleteTexture(this.glTex)}},a(Tt,"Texture"),Tt);var pr;var fs=(pr=class{constructor(e,r,s,n={}){b(this,"ctx");b(this,"tex");b(this,"glFramebuffer");b(this,"glRenderbuffer");this.ctx=e;let i=e.gl;e.onDestroy(()=>this.free()),this.tex=new mt(e,r,s,n);let o=i.createFramebuffer(),d=i.createRenderbuffer();if(!o||!d)throw new Error("Failed to create framebuffer");this.glFramebuffer=o,this.glRenderbuffer=d,this.bind(),i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,r,s),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,this.tex.glTex,0),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,this.glRenderbuffer),this.unbind()}get width(){return this.tex.width}get height(){return this.tex.height}toImageData(){let e=this.ctx.gl,r=new Uint8ClampedArray(this.width*this.height*4);this.bind(),e.readPixels(0,0,this.width,this.height,e.RGBA,e.UNSIGNED_BYTE,r),this.unbind();let s=this.width*4,n=new Uint8Array(s);for(let i=0;i<(this.height/2|0);i++){let o=i*s,d=(this.height-i-1)*s;n.set(r.subarray(o,o+s)),r.copyWithin(o,d,d+s),r.set(n,d)}return new ImageData(r,this.width,this.height)}toDataURL(){let e=document.createElement("canvas"),r=e.getContext("2d");if(e.width=this.width,e.height=this.height,!r)throw new Error("Failed to get 2d context");return r.putImageData(this.toImageData(),0,0),e.toDataURL()}clear(){let e=this.ctx.gl;e.clear(e.COLOR_BUFFER_BIT)}draw(e){this.bind(),e(),this.unbind()}bind(){this.ctx.pushFramebuffer(this.glFramebuffer),this.ctx.pushRenderbuffer(this.glRenderbuffer),this.ctx.pushViewport({x:0,y:0,w:this.width,h:this.height})}unbind(){this.ctx.popFramebuffer(),this.ctx.popRenderbuffer(),this.ctx.popViewport()}free(){let e=this.ctx.gl;e.deleteFramebuffer(this.glFramebuffer),e.deleteRenderbuffer(this.glRenderbuffer),this.tex.free()}},a(pr,"FrameBuffer"),pr);var gr;var Nu=(gr=class{constructor(e,r,s,n){b(this,"ctx");b(this,"glVBuf");b(this,"glIBuf");b(this,"vqueue",[]);b(this,"iqueue",[]);b(this,"stride");b(this,"maxVertices");b(this,"maxIndices");b(this,"vertexFormat");b(this,"numDraws",0);b(this,"curPrimitive",null);b(this,"curTex",null);b(this,"curShader",null);b(this,"curUniform",{});let i=e.gl;this.vertexFormat=r,this.ctx=e,this.stride=r.reduce((d,l)=>d+l.size,0),this.maxVertices=s,this.maxIndices=n;let o=i.createBuffer();if(!o)throw new Error("Failed to create vertex buffer");this.glVBuf=o,e.pushArrayBuffer(this.glVBuf),i.bufferData(i.ARRAY_BUFFER,s*4,i.DYNAMIC_DRAW),e.popArrayBuffer(),this.glIBuf=i.createBuffer(),e.pushElementArrayBuffer(this.glIBuf),i.bufferData(i.ELEMENT_ARRAY_BUFFER,n*4,i.DYNAMIC_DRAW),e.popElementArrayBuffer()}push(e,r,s,n,i=null,o={}){(e!==this.curPrimitive||i!==this.curTex||n!==this.curShader||!ks(this.curUniform,o)||this.vqueue.length+r.length*this.stride>this.maxVertices||this.iqueue.length+s.length>this.maxIndices)&&this.flush();let d=this.vqueue.length/this.stride;for(let l of r)this.vqueue.push(l);for(let l of s)this.iqueue.push(l+d);this.curPrimitive=e,this.curShader=n,this.curTex=i,this.curUniform=o}flush(){var r,s;if(!this.curPrimitive||!this.curShader||this.vqueue.length===0||this.iqueue.length===0)return;let e=this.ctx.gl;this.ctx.pushArrayBuffer(this.glVBuf),e.bufferSubData(e.ARRAY_BUFFER,0,new Float32Array(this.vqueue)),this.ctx.pushElementArrayBuffer(this.glIBuf),e.bufferSubData(e.ELEMENT_ARRAY_BUFFER,0,new Uint16Array(this.iqueue)),this.ctx.setVertexFormat(this.vertexFormat),this.curShader.bind(),this.curShader.send(this.curUniform),(r=this.curTex)==null?void 0:r.bind(),e.drawElements(this.curPrimitive,this.iqueue.length,e.UNSIGNED_SHORT,0),(s=this.curTex)==null?void 0:s.unbind(),this.curShader.unbind(),this.ctx.popArrayBuffer(),this.ctx.popElementArrayBuffer(),this.vqueue=[],this.iqueue=[],this.numDraws++}free(){let e=this.ctx.gl;e.deleteBuffer(this.glVBuf),e.deleteBuffer(this.glIBuf)}},a(gr,"BatchRenderer"),gr);function gt(t){let e=[],r=a(i=>{e.push(i),t(i)},"push"),s=a(()=>{e.pop(),t(n()??null)},"pop"),n=a(()=>e[e.length-1],"cur");return[r,s,n]}a(gt,"genStack");function po(t,e={}){let r=[];function s(T){r.push(T)}a(s,"onDestroy");function n(){r.forEach(A=>A());let T=t.getExtension("WEBGL_lose_context");T&&T.loseContext()}a(n,"destroy");let i=null;function o(T){if(ks(T,i))return;i=T;let A=T.reduce((v,S)=>v+S.size,0);T.reduce((v,S,k)=>(t.vertexAttribPointer(k,S.size,t.FLOAT,false,A*4,v),t.enableVertexAttribArray(k),v+S.size*4),0)}a(o,"setVertexFormat");let[d,l]=gt(T=>t.bindTexture(t.TEXTURE_2D,T)),[u,f]=gt(T=>t.bindBuffer(t.ARRAY_BUFFER,T)),[x,h]=gt(T=>t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,T)),[w,g]=gt(T=>t.bindFramebuffer(t.FRAMEBUFFER,T)),[M,p]=gt(T=>t.bindRenderbuffer(t.RENDERBUFFER,T)),[y,P]=gt(T=>{if(!T)return;let{x:A,y:v,w:S,h:k}=T;t.viewport(A,v,S,k)}),[R,O]=gt(T=>t.useProgram(T));return y({x:0,y:0,w:t.drawingBufferWidth,h:t.drawingBufferHeight}),{gl:t,opts:e,onDestroy:s,destroy:n,pushTexture2D:d,popTexture2D:l,pushArrayBuffer:u,popArrayBuffer:f,pushElementArrayBuffer:x,popElementArrayBuffer:h,pushFramebuffer:w,popFramebuffer:g,pushRenderbuffer:M,popRenderbuffer:p,pushViewport:y,popViewport:P,pushProgram:R,popProgram:O,setVertexFormat:o}}a(po,"initGfx");var Ks={};function _s(t,e){if(e.override){Object.assign(t,e);return}e.pos&&(t.pos=t.pos.add(e.pos)),e.scale&&(t.scale=t.scale.scale(E(e.scale))),e.angle&&(t.angle+=e.angle),e.color&&t.ch.length===1&&(t.color=t.color.mult(e.color)),e.opacity!=null&&(t.opacity*=e.opacity)}a(_s,"applyCharTransform");function ps(t){let e={},r="",s=[],n=String(t),i=a(o=>{s.length>0&&(e[r.length]=s.slice()),r+=o},"emit");for(;n!=="";){if(n[0]==="\\"){if(n.length===1)throw new Error("Styled text error: \\ at end of string");i(n[1]),n=n.slice(2);continue}if(n[0]==="["){let o=/^\[(\/)?(\w+?)\]/.exec(n);if(!o){i(n[0]),n=n.slice(1);continue}let[d,l,u]=o;if(l!==void 0){let f=s.pop();if(f!==u)throw f!==void 0?new Error(`Styled text error: mismatched tags. Expected [/${f}], got [/${u}]`):new Error(`Styled text error: stray end tag [/${u}]`)}else s.push(u);n=n.slice(d.length);continue}i(n[0]),n=n.slice(1)}if(s.length>0)throw new Error(`Styled text error: unclosed tags ${s}`);return{charStyleMap:e,text:r}}a(ps,"compileStyledText");function Mt(t){var R,O,T;if(t.text===void 0)throw new Error('formatText() requires property "text".');let e=Pn(t.font);if(!t.text||t.text===""||e instanceof je||!e)return{width:0,height:0,chars:[],opt:t,renderedText:""};let{charStyleMap:r,text:s}=ps(t.text+""),n=qa(s);if(e instanceof as||typeof e=="string"){let A=e instanceof as?e.fontface.family:e,v=e instanceof as?{outline:e.outline,filter:e.filter}:{outline:null,filter:Xs},S=Ks[A]??{font:{tex:new mt(c.gfx.ggl,2048,2048,{filter:v.filter}),map:{},size:64},cursor:new B(0),maxHeight:0,outline:v.outline};Ks[A]||(Ks[A]=S),e=S.font;for(let k of n)if(!S.font.map[k]){let I=c.fontCacheC2d;if(!I)throw new Error("fontCacheC2d is not defined.");if(!c.fontCacheCanvas)throw new Error("fontCacheCanvas is not defined.");I.clearRect(0,0,c.fontCacheCanvas.width,c.fontCacheCanvas.height),I.font=`${e.size}px ${A}`,I.textBaseline="top",I.textAlign="left",I.fillStyle="#ffffff";let F=I.measureText(k),U=Math.ceil(F.width);if(!U)continue;let H=Math.ceil(Math.abs(F.actualBoundingBoxAscent))+Math.ceil(Math.abs(F.actualBoundingBoxDescent));S.outline&&S.outline.width&&S.outline.color&&(I.lineJoin="round",I.lineWidth=S.outline.width*2,I.strokeStyle=S.outline.color.toHex(),I.strokeText(k,S.outline.width,S.outline.width),U+=S.outline.width*2,H+=S.outline.width*3),I.fillText(k,((R=S.outline)==null?void 0:R.width)??0,((O=S.outline)==null?void 0:O.width)??0);let j=I.getImageData(0,0,U,H);if(S.cursor.x+U>2048&&(S.cursor.x=0,S.cursor.y+=S.maxHeight,S.maxHeight=0,S.cursor.y>2048))throw new Error("Font atlas exceeds character limit");e.tex.update(j,S.cursor.x,S.cursor.y),e.map[k]=new ce(S.cursor.x,S.cursor.y,U,H),S.cursor.x+=U+1,S.maxHeight=Math.max(S.maxHeight,H)}}let i=t.size||e.size,o=E(t.scale??1).scale(i/e.size),d=t.lineSpacing??0,l=t.letterSpacing??0,u=0,f=0,x=0,h=[],w=[],g=0,M=null,p=0,y;for(;gt.width&&(x+=i+d,M!=null&&(g-=w.length-M,A=n[g],v=e.map[A],S=v.w*o.x,w=w.slice(0,M-1),u=p),M=null,p=0,h.push({width:u-l,chars:w}),u=y??0,w=[]),w.push({tex:e.tex,width:v.w,height:v.h,quad:new ce(v.x/e.tex.width,v.y/e.tex.height,v.w/e.tex.width,v.h/e.tex.height),ch:A,pos:new B(u,x),opacity:t.opacity??1,color:t.color??Z.WHITE,scale:E(o),angle:0}),A===" "&&(M=w.length,p=u),t.indentAll&&y===void 0&&/\S/.test(A)&&(y=u),u+=S,f=Math.max(f,u),u+=l}}g++}h.push({width:u-l,chars:w}),x+=i,t.width&&(f=t.width);let P=[];for(let A=0;A{br({tex:e.tex,width:e.width,height:e.height,pos:e.pos,scale:e.scale,angle:e.angle,color:e.color,opacity:e.opacity,quad:e.quad,anchor:"center",uniform:t.opt.uniform,shader:t.opt.shader,fixed:t.opt.fixed})}),Be()}a(qt,"drawFormattedText");function Te(t){if(t.width===void 0||t.height===void 0)throw new Error('drawRect() requires property "width" and "height".');if(t.width<=0||t.height<=0)return;let e=t.width,r=t.height,s=Ht(t.anchor||Ps).add(1,1).scale(new B(e,r).scale(-.5)),n=[new B(0,0),new B(e,0),new B(e,r),new B(0,r)];if(t.radius){let i=Math.min(e,r)/2,o=Array.isArray(t.radius)?t.radius.map(d=>Math.min(i,d)):new Array(4).fill(Math.min(i,t.radius));n=[new B(o[0],0),...o[1]?Xt(new B(e-o[1],o[1]),o[1],o[1],270,360):[E(e,0)],...o[2]?Xt(new B(e-o[2],r-o[2]),o[2],o[2],0,90):[E(e,r)],...o[3]?Xt(new B(o[3],r-o[3]),o[3],o[3],90,180):[E(0,r)],...o[0]?Xt(new B(o[0],o[0]),o[0],o[0],180,270):[]]}ut(Object.assign({},t,{offset:s,pts:n,...t.gradient?{colors:t.horizontal?[t.gradient[0],t.gradient[1],t.gradient[1],t.gradient[0]]:[t.gradient[0],t.gradient[0],t.gradient[1],t.gradient[1]]}:{}}))}a(Te,"drawRect");function ot(t){De();let e=c.gfx.width,r=c.gfx.height;c.gfx.width=c.gfx.viewport.width,c.gfx.height=c.gfx.viewport.height,t(),De(),c.gfx.width=e,c.gfx.height=r}a(ot,"drawUnscaled");function en(t,e){ot(()=>{let r=E(8);Ie(),de(t);let s=Mt({text:e,font:ls,size:16,pos:r,color:re(255,255,255),fixed:true}),n=s.width+r.x*2,i=s.height+r.x*2;t.x+n>=ve()&&de(E(-n,0)),t.y+i>=Ee()&&de(E(0,-i)),Te({width:n,height:i,color:re(0,0,0),radius:4,opacity:.8,fixed:true}),qt(s),Be()})}a(en,"drawInspectText");function Un(t){if(!t.p1||!t.p2||!t.p3)throw new Error('drawTriangle() requires properties "p1", "p2" and "p3".');return ut(Object.assign({},t,{pts:[t.p1,t.p2,t.p3]}))}a(Un,"drawTriangle");function mo(){if(c.debug.inspect){let t=null;for(let e of c.game.root.get("*",{recursive:true}))if(e.c("area")&&e.isHovering()){t=e;break}if(c.game.root.drawInspect(),t){let e=[],r=t.inspect();for(let s in r)r[s]?e.push(`${r[s]}`):e.push(`${s}`);en(Ka(Mn()),e.join(` +`))}en(E(8),`FPS: ${c.debug.fps()}`)}c.debug.paused&&ot(()=>{Ie(),de(ve(),0),de(-8,8);let t=32;Te({width:t,height:t,anchor:"topright",color:re(0,0,0),opacity:.8,radius:4,fixed:true});for(let e=1;e<=2;e++)Te({width:4,height:t*.6,anchor:"center",pos:E(-t/3*e,t*.5),color:re(255,255,255),radius:2,fixed:true});Be()}),c.debug.timeScale!==1&&ot(()=>{Ie(),de(ve(),Ee()),de(-8,-8);let t=8,e=Mt({text:c.debug.timeScale.toFixed(1),font:ls,size:16,color:re(255,255,255),pos:E(-t),anchor:"botright",fixed:true});Te({width:e.width+t*2+t*4,height:e.height+t*2,anchor:"botright",color:re(0,0,0),opacity:.8,radius:4,fixed:true});for(let r=0;r<2;r++){let s=c.debug.timeScale<1;Un({p1:E(-e.width-t*(s?2:3.5),-t),p2:E(-e.width-t*(s?2:3.5),-t-e.height),p3:E(-e.width-t*(s?3.5:2),-t-e.height/2),pos:E(-r*t*1+(s?-t*.5:0),0),color:re(255,255,255),fixed:true})}qt(e),Be()}),c.debug.curRecording&&ot(()=>{Ie(),de(0,Ee()),de(24,-24),Nt({radius:12,color:re(255,0,0),opacity:on(0,1,c.app.time()*4),fixed:true}),Be()}),c.debug.showLog&&c.game.logs.length>0&&ot(()=>{Ie(),de(0,Ee()),de(8,-8);let t=8,e=[];for(let s of c.game.logs){let n="",i=s.msg instanceof Error?"error":"info";n+=`[time]${s.time.toFixed(2)}[/time]`,n+=" ",n+=`[${i}]${gs(s.msg)}[/${i}]`,e.push(n)}c.game.logs=c.game.logs.filter(s=>c.app.time()-s.time<(c.globalOpt.logTime||4));let r=Mt({text:e.join(` +`),font:ls,pos:E(t,-t),anchor:"botleft",size:16,width:ve()*.6,lineSpacing:t/2,fixed:true,styles:{time:{color:re(127,127,127)},info:{color:re(255,255,255)},error:{color:re(255,0,127)}}});Te({width:r.width+t*2,height:r.height+t*2,anchor:"botleft",color:re(0,0,0),radius:4,opacity:.8,fixed:true}),qt(r),Be()})}a(mo,"drawDebug");function gs(t,e=false,r=new Set){if(r.has(t))return"";var s="",n;return e&&typeof t=="string"&&(t=JSON.stringify(t)),Array.isArray(t)&&(s=["[",t.map(i=>gs(i,true,r.union(new Set([t])))).join(", "),"]"].join(""),t=s),t===null?"null":(typeof t=="object"&&t.toString===Object.prototype.toString&&(t.constructor!==Object&&(s+=t.constructor.name+" "),s+=["{",(n=Object.getOwnPropertyNames(t).map(i=>`${/^\w+$/.test(i)?i:JSON.stringify(i)}: ${gs(t[i],true,r.union(new Set([t])))}`).join(", "))?` ${n} `:"","}"].join(""),t=s),String(t).replaceAll(new RegExp("(?0?c.game.events.trigger("loading",t):ot(()=>{let e=ve()/2,r=24,s=E(ve()/2,Ee()/2).sub(E(e/2,r/2));Te({pos:E(0),width:ve(),height:Ee(),color:re(0,0,0)}),Te({pos:s,width:e,height:r,fill:false,outline:{width:4}}),Te({pos:s,width:e*t,height:r})})}a(wo,"drawLoadScreen");function Ln(t,e,r){let s=c.gfx.ggl.gl;De(),s.clear(s.STENCIL_BUFFER_BIT),s.enable(s.STENCIL_TEST),s.stencilFunc(s.NEVER,1,255),s.stencilOp(s.REPLACE,s.REPLACE,s.REPLACE),e(),De(),s.stencilFunc(r,1,255),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),t(),De(),s.disable(s.STENCIL_TEST)}a(Ln,"drawStenciled");function Ao(t,e){let r=c.gfx.ggl.gl;Ln(t,e,r.EQUAL)}a(Ao,"drawMasked");function Hr(t){var i,o;if(!t.tex)throw new Error('drawTexture() requires property "tex".');let e=t.quad??new ce(0,0,1,1),r=t.tex.width*e.w,s=t.tex.height*e.h,n=new B(1);if(t.tiled){let d=Ht(t.anchor||Ps);(((i=t.pos)==null?void 0:i.x)||0)-(d.x+1)*.5*(t.width||r);(((o=t.pos)==null?void 0:o.y)||0)-(d.y+1)*.5*(t.height||s);let l=(t.width||r)/r,u=(t.height||s)/s,f=Math.floor(l),x=Math.floor(u),h=l-f,w=u-x,g=(f+h?1:0)*(x+w?1:0),M=new Array(g*6),p=new Array(g*4),y=0,P=a((R,O,T,A,v)=>{M[y*6+0]=y*4+0,M[y*6+1]=y*4+1,M[y*6+2]=y*4+3,M[y*6+3]=y*4+1,M[y*6+4]=y*4+2,M[y*6+5]=y*4+3,p[y*4+0]={pos:new B(R-d.x,O-d.y),uv:new B(v.x,v.y),color:t.color||Z.WHITE,opacity:t.opacity||1},p[y*4+1]={pos:new B(R+T-d.x,O-d.y),uv:new B(v.x+v.w,v.y),color:t.color||Z.WHITE,opacity:t.opacity||1},p[y*4+2]={pos:new B(R+T-d.x,O+A-d.y),uv:new B(v.x+v.w,v.y+v.h),color:t.color||Z.WHITE,opacity:t.opacity||1},p[y*4+3]={pos:new B(R-d.x,O+A-d.y),uv:new B(v.x,v.y+v.h),color:t.color||Z.WHITE,opacity:t.opacity||1},y++},"addQuad");for(let R=0;R{let r=Ts(e,Qs,Ws),s=t.pixelDensity??1,n=t.scale??1,{gl:i}=e,o=mt.fromImage(e,new ImageData(new Uint8ClampedArray([255,255,255,255]),1,1)),d=t.width&&t.height?new fs(e,t.width*s*n,t.height*s*n):new fs(e,i.drawingBufferWidth,i.drawingBufferHeight),l=null,u=1;t.background&&(typeof t.background=="string"?l=re(t.background):(l=re(...t.background),u=t.background[3]??1),i.clearColor(l.r/255,l.g/255,l.b/255,u??1)),i.enable(i.BLEND),i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);let f=new Nu(e,bn,tu,ru),x=mt.fromImage(e,new ImageData(new Uint8ClampedArray([128,128,128,255,190,190,190,255,190,190,190,255,128,128,128,255]),2,2),{wrap:"repeat",filter:"nearest"});return{lastDrawCalls:0,ggl:e,defShader:r,defTex:o,frameBuffer:d,postShader:null,postShaderUniform:null,renderer:f,transform:new et,transformStack:[],bgTex:x,bgColor:l,bgAlpha:u,width:t.width??i.drawingBufferWidth/s/n,height:t.height??i.drawingBufferHeight/s/n,viewport:{x:0,y:0,width:i.drawingBufferWidth,height:i.drawingBufferHeight},fixed:false}},"initAppGfx");function Hn(){let t=c.pixelDensity,e=c.gfx.ggl.gl.drawingBufferWidth/t,r=c.gfx.ggl.gl.drawingBufferHeight/t;if(c.globalOpt.letterbox){if(!c.globalOpt.width||!c.globalOpt.height)throw new Error("Letterboxing requires width and height defined.");let s=e/r,n=c.globalOpt.width/c.globalOpt.height;if(s>n){let i=r*n,o=(e-i)/2;c.gfx.viewport={x:o,y:0,width:i,height:r}}else{let i=e/n,o=(r-i)/2;c.gfx.viewport={x:0,y:o,width:e,height:i}}return}if(c.globalOpt.stretch&&(!c.globalOpt.width||!c.globalOpt.height))throw new Error("Stretching requires width and height defined.");c.gfx.viewport={x:0,y:0,width:e,height:r}}a(Hn,"updateViewport");function yt(t){return t.fixed?true:t.parent?yt(t.parent):false}a(yt,"isFixed");function Bt(t){return{color:t.color,opacity:t.opacity,anchor:t.anchor,outline:t.outline,shader:t.shader,uniform:t.uniform}}a(Bt,"getRenderProps");function bo(t,e={}){return{id:"circle",radius:t,draw(){Nt(Object.assign(Bt(this),{radius:this.radius,fill:e.fill}))},renderArea(){return new he(new B(this.anchor?0:-this.radius),this.radius*2,this.radius*2)},inspect(){return`radius: ${Math.ceil(this.radius)}`}}}a(bo,"circle");function Nn(...t){return{id:"color",color:re(...t),inspect(){return`color: ${this.color.toString()}`}}}a(Nn,"color");function Eo(t){return{add(){this.canvas=t}}}a(Eo,"drawon");function So(t=1){let e,r=0,s=false;return{require:["opacity"],add(){e=this.opacity,this.opacity=0},update(){s||(r+=xe(),this.opacity=ze(r,0,t,0,e),r>=t&&(this.opacity=e,s=true))}}}a(So,"fadeIn");function Mo(t="intersect"){return{id:"mask",mask:t}}a(Mo,"mask");function Gn(t){return{id:"opacity",opacity:t??1,fadeIn(e=1,r=c.k.easings.linear){return c.game.root.tween(0,this.opacity,e,s=>this.opacity=s,r)},fadeOut(e=1,r=c.k.easings.linear){return c.game.root.tween(this.opacity,0,e,s=>this.opacity=s,r)},inspect(){return`opacity: ${us(this.opacity,1)}`}}}a(Gn,"opacity");function qo(t=1,e=re(0,0,0),r=1,s="miter",n=10,i="butt"){return{id:"outline",outline:{width:t,color:e,opacity:r,join:s,miterLimit:n,cap:i},inspect(){return`outline: ${this.outline.width}px, ${this.outline.color}`}}}a(qo,"outline");var mr;var ju=(mr=class{constructor(){b(this,"pos",E(0));b(this,"vel",E(0));b(this,"acc",E(0));b(this,"angle",0);b(this,"angularVelocity",0);b(this,"damping",0);b(this,"t");b(this,"lt",null);b(this,"gc");this.t=0,this.gc=true}get progress(){return this.lt?this.t/this.lt:this.t}},a(mr,"Particle"),mr);function Bo(t,e){let r=e.lifetime,s=[],n=t.colors||[Z.WHITE],i=t.opacities||[1],o=t.quads||[new ce(0,0,1,1)],d=t.scales||[1],l=t.lifeTime,u=e.direction,f=e.spread,x=t.speed||[0,0],h=t.angle||[0,0],w=t.angularVelocity||[0,0],g=t.acceleration||[E(0),E(0)],M=t.damping||[0,0],p=[],y=new Array(t.max),P=0,R=0;for(let A=0;A=v.lt){v.gc=true,P--;continue}v.vel=v.vel.add(v.acc.scale(A)).scale(1-v.damping*A),v.pos=v.pos.add(v.vel.scale(A)),v.angle+=v.angularVelocity*A}for(r!==void 0&&(r-=A,r<=0&&O.trigger()),R+=A;Pe.rate;)this.emit(1),P++,R-=e.rate},draw(){if(!(r!==void 0&&r<=0)){for(let A=0;A`[${r.x},${r.y}]`).join(",")}`}}}a(Co,"polygon");function jn(t,e,r){let s;return c.game.root.get("area").forEach(n=>{if(r&&r.some(o=>n.is(o)))return;let i=n.worldArea().raycast(t,e);i&&(s?i.fractionA.x+A.y*n,"tile2Hash"),f=a(A=>E(Math.floor(A%n),Math.floor(A/n)),"hash2Tile"),x=a(()=>{i=[];for(let A of r.children)h(A)},"createSpatialMap"),h=a(A=>{let v=u(A.tilePos);i[v]?i[v].push(A):i[v]=[A]},"insertIntoSpatialMap"),w=a(A=>{let v=u(A.tilePos);if(i[v]){let S=i[v].indexOf(A);S>=0&&i[v].splice(S,1)}},"removeFromSpatialMap"),g=a(()=>{let A=false;for(let v of r.children){let S=r.pos2Tile(v.pos);(v.tilePos.x!=S.x||v.tilePos.y!=S.y)&&(A=true,w(v),v.tilePos.x=S.x,v.tilePos.y=S.y,h(v))}A&&r.trigger("spatialMapChanged")},"updateSpatialMap"),M=a(()=>{let A=r.getSpatialMap(),v=r.numRows()*r.numColumns();o?o.length=v:o=new Array(v),o.fill(1,0,v);for(let S=0;S{let A=r.getSpatialMap(),v=r.numRows()*r.numColumns();d?d.length=v:d=new Array(v),d.fill(15,0,v);for(let S=0;S{let A=r.numRows()*r.numColumns(),v=a((k,I)=>{let F=[];for(F.push(k);F.length>0;){let U=F.pop();O(U).forEach(H=>{l[H]<0&&(l[H]=I,F.push(H))})}},"traverse");l?l.length=A:l=new Array(A),l.fill(-1,0,A);let S=0;for(let k=0;k=0){S++;continue}v(k,S),S++}},"createConnectivityMap"),P=a((A,v)=>o[v],"getCost"),R=a((A,v)=>{let S=f(A),k=f(v);return S.dist(k)},"getHeuristic"),O=a((A,v)=>{let S=[],k=Math.floor(A%n),I=k>0&&d[A]&1&&o[A-1]!==1/0,F=A>=n&&d[A]&2&&o[A-n]!==1/0,U=k{if(typeof A=="string"){if(e.tiles[A]){if(typeof e.tiles[A]!="function")throw new Error("Level symbol def must be a function returning a component list");return e.tiles[A](S)}else if(e.wildcardTile)return e.wildcardTile(A,S)}else{if(Array.isArray(A))return A;throw new Error("Expected a symbol or a component list")}})();if(!k)return null;let I=false,F=false;for(let H of k)H.id==="tile"&&(F=true),H.id==="pos"&&(I=true);I||k.push(Nr(this.tile2Pos(S))),F||k.push(ni());let U=r.add(k);return I&&(U.tilePosOffset=U.pos.clone()),U.tilePos=S,U.transform=Wt(U),i&&(h(U),this.trigger("spatialMapChanged"),this.trigger("navigationMapInvalid")),U},numColumns(){return n},numRows(){return s},levelWidth(){return n*this.tileWidth()},levelHeight(){return s*this.tileHeight()},tile2Pos(...A){return E(...A).scale(this.tileWidth(),this.tileHeight())},pos2Tile(...A){let v=E(...A);return E(Math.floor(v.x/this.tileWidth()),Math.floor(v.y/this.tileHeight()))},getSpatialMap(){return i||x(),i},removeFromSpatialMap:w,insertIntoSpatialMap:h,onSpatialMapChanged(A){return this.on("spatialMapChanged",A)},onNavigationMapInvalid(A){return this.on("navigationMapInvalid",A)},getAt(A){i||x();let v=u(A);return i[v]||[]},raycast(A,v){let S=this.toWorld(A),k=this.toWorld(A.add(v)).sub(S),I=1/this.tileWidth(),F=A.scale(I),U=zi(F,v,H=>{let j=this.getAt(H);if(j.some(V=>V.isObstacle))return true;let J=null;for(let V of j)if(V.has("area")){let X=V.worldArea().raycast(S,k);X&&(J?X.fraction=n||A.y<0||A.y>=s||v.x<0||v.x>=n||v.y<0||v.y>=s)return null;let k=u(A),I=u(v);if(o[I]===1/0)return null;if(k===I)return[];if(l[k]!=-1&&l[k]!==l[I])return null;let F=new xa((se,ee)=>se.costU.scale(k,I).add(k/2,I/2)),v]:null}};return r.use(T),r.onNavigationMapInvalid(()=>{r.invalidateNavigationMap(),r.trigger("navigationMapChanged")}),t.forEach((A,v)=>{let S=A.split("");n=Math.max(S.length,n),S.forEach((k,I)=>{r.spawn(k,E(I,v))})}),r}a(Ro,"addLevel");function Re(t,e,r){return c.game.objEvents.registers[t]||(c.game.objEvents.registers[t]=new Aa),c.game.objEvents.on(t,(s,...n)=>{s.is(e)&&r(s,...n)})}a(Re,"on");var Vu=a((t,e,...r)=>{for(let s of c.game.root.children)s.is(e)&&s.trigger(t)},"trigger");var Ku=ue(t=>{let e=c.game.root.add([{fixedUpdate:t}]);return{get paused(){return e.paused},set paused(r){e.paused=r},cancel:a(()=>e.destroy(),"cancel")}},(t,e)=>Re("fixedUpdate",t,e));var Yu=ue(t=>{let e=c.game.root.add([{update:t}]);return{get paused(){return e.paused},set paused(r){e.paused=r},cancel:a(()=>e.destroy(),"cancel")}},(t,e)=>Re("update",t,e));var zu=ue(t=>{let e=c.game.root.add([{draw:t}]);return{get paused(){return e.hidden},set paused(r){e.hidden=r},cancel:a(()=>e.destroy(),"cancel")}},(t,e)=>Re("draw",t,e));var ko=ue(t=>c.game.events.on("add",t),(t,e)=>Re("add",t,e));var Xu=ue(t=>c.game.events.on("destroy",t),(t,e)=>Re("destroy",t,e));var Qu=ue(t=>c.game.events.on("use",t),(t,e)=>Re("use",t,e));var Wu=ue(t=>c.game.events.on("unuse",t),(t,e)=>Re("unuse",t,e));var Io=ue(t=>c.game.events.on("tag",t),(t,e)=>Re("tag",t,e));var Zu=ue(t=>c.game.events.on("untag",t),(t,e)=>Re("untag",t,e));function Do(t,e,r){return Re("collide",t,(s,n,i)=>n.is(e)&&r(s,n,i))}a(Do,"onCollide");function To(t,e,r){return Re("collideUpdate",t,(s,n,i)=>n.is(e)&&r(s,n,i))}a(To,"onCollideUpdate");function Fo(t,e,r){return Re("collideEnd",t,(s,n,i)=>n.is(e)&&r(s,n,i))}a(Fo,"onCollideEnd");function Qr(t,e){c.game.root.get(t,{recursive:true}).forEach(e),ko(t,e),Io((r,s)=>{s===t&&e(r)})}a(Qr,"forAllCurrentAndFuture");var Ju=ue(t=>c.app.onMousePress(t),(t,e)=>{let r=[];return Qr(t,s=>{if(!s.area)throw new Error("onClick() requires the object to have area() component");r.push(s.onClick(()=>e(s)))}),Ut.join(r)});function Oo(t,e){let r=[];return Qr(t,s=>{if(!s.area)throw new Error("onHover() requires the object to have area() component");r.push(s.onHover(()=>e(s)))}),Ut.join(r)}a(Oo,"onHover");function Uo(t,e){let r=[];return Qr(t,s=>{if(!s.area)throw new Error("onHoverUpdate() requires the object to have area() component");r.push(s.onHoverUpdate(()=>e(s)))}),Ut.join(r)}a(Uo,"onHoverUpdate");function Lo(t,e){let r=[];return Qr(t,s=>{if(!s.area)throw new Error("onHoverEnd() requires the object to have area() component");r.push(s.onHoverEnd(()=>e(s)))}),Ut.join(r)}a(Lo,"onHoverEnd");function Ho(t){c.game.events.on("loading",t)}a(Ho,"onLoading");function No(t){c.app.onResize(t)}a(No,"onResize");function Go(t){c.game.events.on("error",t)}a(Go,"onError");function Os(t){c.assets.loaded?t():c.game.events.on("load",t)}a(Os,"onLoad");function jo(t){if(c.assets.loaded)qn().forEach(e=>t(...e));else return c.game.events.on("loadError",t)}a(jo,"onLoadError");function Kn(...t){c.game.cam.pos=E(...t)}a(Kn,"setCamPos");function Yn(){return c.game.cam.pos?c.game.cam.pos.clone():Ur()}a(Yn,"getCamPos");function zn(...t){c.game.cam.scale=E(...t)}a(zn,"setCamScale");function Xn(){return c.game.cam.scale.clone()}a(Xn,"getCamScale");function Qn(t){c.game.cam.angle=t}a(Qn,"setCamRot");function Wn(){return c.game.cam.angle}a(Wn,"getCamRot");function Vo(){return c.game.cam.transform.clone()}a(Vo,"getCamTransform");function Zn(t=re(255,255,255),e=1){let r=c.game.root.add([Vn(ve(),Ee()),Nn(t),Gn(1),li()]),s=r.fadeOut(e);return s.onEnd(()=>si(r)),s}a(Zn,"flash");function Ko(){return c.game.cam.transform.clone()}a(Ko,"camTransform");function Yo(t=12){c.game.cam.shake+=t}a(Yo,"shake");function ms(t){return c.game.cam.transform.multVec2(t)}a(ms,"toScreen");function Jn(t){return c.game.cam.transform.invert().multVec2(t)}a(Jn,"toWorld");function zo(...t){return Lt("camPos","setCamPos / getCamPos"),t.length>0&&Kn(...t),Yn()}a(zo,"camPos");function Xo(...t){return Lt("camScale","setCamScale / getCamScale"),t.length>0&&zn(...t),Xn()}a(Xo,"camScale");function Qo(t){return Lt("camRot","setCamRot / getCamRot"),t!==void 0&&Qn(t),Wn()}a(Qo,"camRot");function Wo(t=re(255,255,255),e=1){return Lt("camFlash","flash"),Zn(t,e)}a(Wo,"camFlash");function Us(t=[]){let e=new Map,r=[],s={},n=new Fr,i=[],o=new Set("*"),d=c.globalOpt.tagsAsComponents,l=null,u=false,f={id:mu(),hidden:false,transform:new et,children:[],parent:null,set paused(h){if(h!==u){u=h;for(let w of i)w.paused=h}},get paused(){return u},get tags(){return Array.from(o)},add(h){let w=Array.isArray(h)?Us(h):h;if(w.parent)throw new Error("Cannot add a game obj that already has a parent.");return w.parent=this,w.transform=Wt(w),this.children.push(w),w.trigger("add",w),c.game.events.trigger("add",w),w},readd(h){let w=this.children.indexOf(h);return w!==-1&&(this.children.splice(w,1),this.children.push(h)),h},remove(h){let w=this.children.indexOf(h);if(w!==-1){h.parent=null,this.children.splice(w,1);let g=a(M=>{M.trigger("destroy"),c.game.events.trigger("destroy",M),M.children.forEach(p=>g(p))},"trigger");g(h)}},removeAll(h){if(h)this.get(h).forEach(w=>this.remove(w));else for(let w of[...this.children])this.remove(w)},fixedUpdate(){this.paused||(this.children.forEach(h=>h.fixedUpdate()),this.trigger("fixedUpdate"))},update(){this.paused||(this.children.forEach(h=>h.update()),this.trigger("update"))},draw(){if(this.hidden)return;this.canvas&&(De(),this.canvas.bind());let h=c.gfx.fixed;this.fixed&&(c.gfx.fixed=true),Ie(),de(this.pos),vr(this.scale),Ft(this.angle);let w=this.children.sort((g,M)=>{let p=g.layerIndex??c.game.defaultLayerIndex,y=M.layerIndex??c.game.defaultLayerIndex;return p-y||(g.z??0)-(M.z??0)});if(this.mask){let g={intersect:c.k.drawMasked,subtract:c.k.drawSubtracted}[this.mask];if(!g)throw new Error(`Invalid mask func: "${this.mask}"`);g(()=>{w.forEach(M=>M.draw())},()=>{this.trigger("draw")})}else this.trigger("draw"),w.forEach(g=>g.draw());Be(),c.gfx.fixed=h,this.canvas&&(De(),this.canvas.unbind())},drawInspect(){this.hidden||(Ie(),de(this.pos),vr(this.scale),Ft(this.angle),this.children.forEach(h=>h.drawInspect()),this.trigger("drawInspect"),Be())},use(h){var M;if(typeof h=="string")return o.add(h);if(!h||typeof h!="object")throw new Error(`You can only pass a component or a string to .use(), you passed a "${typeof h}"`);let w=[];h.id?(this.unuse(h.id),s[h.id]=[],w=s[h.id],e.set(h.id,h),d&&o.add(h.id)):r.push(h);for(let p in h){if(iu.has(p))continue;let y=Object.getOwnPropertyDescriptor(h,p);if(y)if(typeof y.value=="function"&&(h[p]=h[p].bind(this)),y.set&&Object.defineProperty(h,p,{set:y.set.bind(this)}),y.get&&Object.defineProperty(h,p,{get:y.get.bind(this)}),au.has(p)){let P=p==="add"?()=>{var R;l=a(O=>w.push(O),"onCurCompCleanup"),(R=h[p])==null?void 0:R.call(h),l=null}:h[p];w.push(this.on(p,P).cancel)}else if(this[p]===void 0)Object.defineProperty(this,p,{get:a(()=>h[p],"get"),set:a(P=>h[p]=P,"set"),configurable:true,enumerable:true}),w.push(()=>delete this[p]);else{let P=(M=e.values().find(R=>R[p]!==void 0))==null?void 0:M.id;throw new Error(`Duplicate component property: "${p}" while adding component "${h.id}"`+(P?` (originally added by "${P}")`:""))}}let g=a(()=>{if(h.require){for(let p of h.require)if(!this.c(p))throw new Error(`Component "${h.id}" requires component "${p}"`)}},"checkDeps");h.destroy&&w.push(h.destroy.bind(this)),this.exists()?(g(),h.add&&(l=a(p=>w.push(p),"onCurCompCleanup"),h.add.call(this),l=null),h.id&&(this.trigger("use",h.id),c.game.events.trigger("use",this,h.id))):h.require&&w.push(this.on("add",g).cancel)},unuse(h){if(e.has(h)){for(let w of e.values())if(w.require&&w.require.includes(h))throw new Error(`Can't unuse. Component "${w.id}" requires component "${h}"`);e.delete(h),this.trigger("unuse",h),c.game.events.trigger("unuse",this,h)}else d&&o.has(h)&&o.delete(h);s[h]&&(s[h].forEach(w=>w()),delete s[h])},c(h){return e.get(h)??null},get(h,w={}){let g=a((p,y)=>w.only==="comps"?p.has(y):w.only==="tags"?p.is(y):p.is(y)||p.has(y),"checkTagsOrComps"),M=w.recursive?this.children.flatMap(a(function p(y){return[y,...y.children.flatMap(p)]},"recurse")):this.children;if(M=M.filter(p=>h?g(p,h):true),w.liveUpdate){let p=a(P=>w.recursive?this.isAncestorOf(P):P.parent===this,"isChild"),y=[];y.push(c.k.onAdd(P=>{p(P)&&g(P,h)&&M.push(P)})),y.push(c.k.onDestroy(P=>{if(p(P)&&g(P,h)){let R=M.findIndex(O=>O.id===P.id);R!==-1&&M.splice(R,1)}})),this.onDestroy(()=>{for(let P of y)P.cancel()})}return M},query(h){let w=h.hierarchy||"children",g=h.include,M=h.exclude,p=[];switch(w){case"children":p=this.children;break;case"siblings":p=this.parent?this.parent.children.filter(P=>P!==this):[];break;case"ancestors":let y=this.parent;for(;y;)p.push(y),y=y.parent;break;case"descendants":p=this.children.flatMap(a(function P(R){return[R,...R.children.flatMap(P)]},"recurse"));break}if(g&&((h.includeOp||"and")==="and"||!Array.isArray(h.include)?p=p.filter(y=>y.is(g)):p=p.filter(y=>h.include.some(P=>y.is(P)))),M&&((h.includeOp||"and")==="and"||!Array.isArray(h.include)?p=p.filter(y=>!y.is(M)):p=p.filter(y=>!h.exclude.some(P=>y.is(P)))),h.visible===true&&(p=p.filter(y=>y.visible)),h.distance){if(!this.pos)throw Error("Can't do a distance query from an object without pos");let y=h.distanceOp||"near",P=h.distance*h.distance;y==="near"?p=p.filter(R=>R.pos&&this.pos.sdist(R.pos)<=P):p=p.filter(R=>R.pos&&this.pos.sdist(R.pos)>P)}return h.name&&(p=p.filter(y=>y.name===h.name)),p},isAncestorOf(h){return h.parent?h.parent===this||this.isAncestorOf(h.parent):false},exists(){return c.game.root.isAncestorOf(this)},is(h,w="and"){return Array.isArray(h)?w==="and"?h.every(g=>o.has(g)):h.some(g=>o.has(g)):o.has(h)},tag(h){if(Array.isArray(h))for(let w of h)o.add(w),this.trigger("tag",w),c.game.events.trigger("tag",this,w);else o.add(h),this.trigger("tag",h),c.game.events.trigger("tag",this,h)},untag(h){if(Array.isArray(h))for(let w of h)o.delete(w),this.trigger("untag",w),c.game.events.trigger("untag",this,w);else o.delete(h),this.trigger("untag",h),c.game.events.trigger("untag",this,h)},has(h,w="and"){return Array.isArray(h)?w==="and"?h.every(g=>e.has(g)):h.some(g=>e.has(g)):e.has(h)},on(h,w){let g=n.on(h,w.bind(this));return l&&l(()=>g.cancel()),g},trigger(h,...w){n.trigger(h,...w),c.game.objEvents.trigger(h,this,...w)},destroy(){this.parent&&this.parent.remove(this)},inspect(){var w;let h={};for(let[g,M]of e)h[g]=((w=M.inspect)==null?void 0:w.call(M))??null;for(let[g,M]of r.entries()){if(M.inspect){h[g]=M.inspect();continue}for(let[p,y]of Object.entries(M))typeof y!="function"&&(h[p]=`${p}: ${y}`)}return h},onAdd(h){return this.on("add",h)},onFixedUpdate(h){return this.on("fixedUpdate",h)},onUpdate(h){return this.on("update",h)},onDraw(h){return this.on("draw",h)},onDestroy(h){return this.on("destroy",h)},onUse(h){return this.on("use",h)},onUnuse(h){return this.on("unuse",h)},clearEvents(){n.clear()}},x=["onKeyPress","onKeyPressRepeat","onKeyDown","onKeyRelease","onMousePress","onMouseDown","onMouseRelease","onMouseMove","onCharInput","onMouseMove","onTouchStart","onTouchMove","onTouchEnd","onScroll","onGamepadButtonPress","onGamepadButtonDown","onGamepadButtonRelease","onGamepadStick","onButtonPress","onButtonDown","onButtonRelease"];for(let h of x)f[h]=(...w)=>{var M,p;let g=(p=(M=c.app)[h])==null?void 0:p.call(M,...w);return i.push(g),f.onDestroy(()=>g.cancel()),f.on("sceneEnter",()=>{var P,R;i.splice(i.indexOf(g),1);let y=(R=(P=c.app)[h])==null?void 0:R.call(P,...w);Ut.replace(g,y),i.push(g)}),g};for(let h of t)f.use(h);return f}a(Us,"make");var $u=a(()=>({events:new Fr,objEvents:new Fr,root:Us([]),gravity:null,scenes:{},currentScene:null,layers:null,defaultLayerIndex:0,logs:[],cam:{pos:null,scale:new B(1),angle:0,shake:0,transform:new et}}),"initGame");function Zo(t){c.game.gravity=t?(c.game.gravity||E(0,1)).unit().scale(t):null}a(Zo,"setGravity");function Jo(){return c.game.gravity?c.game.gravity.len():0}a(Jo,"getGravity");function $o(t){c.game.gravity=t.unit().scale(c.game.gravity?c.game.gravity.len():1)}a($o,"setGravityDirection");function Jt(){return c.game.gravity?c.game.gravity.unit():E(0,1)}a(Jt,"getGravityDirection");var _u=Ql("//uUBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAASW5mbwAAAA8AAAATAAAeAAANDQ0NDRoaGhoaKCgoKCg1NTU1NTVDQ0NDQ1BQUFBQXl5eXl5ra2tra2t5eXl5eYaGhoaGlJSUlJShoaGhoaGvr6+vr7y8vLy8ysrKysrX19fX19fl5eXl5fLy8vLy//////8AAAA5TEFNRTMuMTAwAaoAAAAAAAAAABSAJAOPhgAAgAAAHgBaqIlmAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//uUBAAP8h1kPIABR4BEDGeQAEbkSb2RAACBFMEyMiAAASJw4xjgwAGyRvfIoZT2QKGV5YNw/tKID9+X93qXtBQUFBQ/e+EFKTQUT/dy3f5dK/3d04rkXHpufCClDAaH7jDMgFAQEGfPt+j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XmRGbwXaEFZGvWIpZLWEizxltQ9uELQV7E73d3HESrONG7w3dTdpF6Skf/zNT3I6rIKxJy1oKCtGGjj5FDxcKB+HpYd/3//i3rZFOT0N05+QpgWZYZ3pi5biJNCj4fRQQwYK8p48BQUTWPDTbNjkPn8+1VXKvJ7dJ5Gb2mESWLjnHOYNH07r6//////////icK81KXqTXuvQEteLGdY0DKwrjQVTIMKbgE0b41Egi1KxtuNwUpf9X+bNqTUlXbDClWgIlS4wMVc1F0QZc3/N/yto/7eUShjGUstRgIUZXKUrFYwU5SgKOxgYE+krfVkf6St/VpnMaYwpwoCjoZwoCZwqFC4LH//uUBD+P4jNjPwAjN8I7THfwAEnqR8mAugCAcQkHsheEERr40LUwj//hIzL//9k/9rJZ9lks+yyVDL/////81YHZUMj//yZZLHIy7/5qwMHHIyZZL/sslQyNWt/I1DBQYRxPYaxS/////5kn///6on0VEVP/6on/7OVFVO5QwUGEOzyhgaoqKhQwMGCUjt////8qaLdr/qTiyzLxaJxpRTt6RBhIhDZMQU1FMy4xMDCqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq");var eh=a(()=>(()=>{let t=new(window.AudioContext||window.webkitAudioContext),e=t.createGain();e.connect(t.destination);let r=new Lr(Ua(t));return t.decodeAudioData(_u.buffer.slice(0)).then(s=>{r.buf=s}).catch(s=>{console.error("Failed to load burp: ",s)}),{ctx:t,masterNode:e,burpSnd:r}})(),"initAudio");function _o(t,e={}){let r=new qe,s=new Audio(t);s.crossOrigin="anonymous",s.loop=!!e.loop,c.audio.ctx.createMediaElementSource(s).connect(c.audio.masterNode);function n(){c.debug.paused||c.app.isHidden()&&!c.globalOpt.backgroundAudio||c.audio.ctx.resume()}a(n,"resumeAudioCtx");function i(){n(),s.play()}return a(i,"play"),e.paused||i(),s.onended=()=>r.trigger(),{play(){i()},seek(o){s.currentTime=o},stop(){s.pause(),this.seek(0)},set loop(o){s.loop=o},get loop(){return s.loop},set paused(o){o?s.pause():i()},get paused(){return s.paused},time(){return s.currentTime},duration(){return s.duration},set volume(o){s.volume=Xe(o,0,1)},get volume(){return s.volume},set speed(o){s.playbackRate=Math.max(o,0)},get speed(){return s.playbackRate},set detune(o){},get detune(){return 0},onEnd(o){return r.add(o)},then(o){return this.onEnd(o)}}}a(_o,"playMusic");function el(t,e={}){if(typeof t=="string"&&c.assets.music[t])return _o(c.assets.music[t],e);let r=c.audio.ctx,s=e.paused??false,n=r.createBufferSource(),i=new qe,o=r.createGain(),d=r.createStereoPanner(),l=e.seek??0,u=0,f=0,x=false;n.loop=!!e.loop,n.detune.value=e.detune??0,n.playbackRate.value=e.speed??1,n.connect(d),n.onended=()=>{var p;g()>=(((p=n.buffer)==null?void 0:p.duration)??Number.POSITIVE_INFINITY)&&i.trigger()},d.pan.value=e.pan??0,d.connect(o),o.connect(c.audio.masterNode),o.gain.value=e.volume??1;let h=a(p=>{n.buffer=p.buf,s||(u=r.currentTime,n.start(0,l),x=true)},"start"),w=ao(t);w instanceof je&&w.onLoad(h);let g=a(()=>{if(!n.buffer)return 0;let p=s?f-u:r.currentTime-u,y=n.buffer.duration;return n.loop?p%y:Math.min(p,y)},"getTime"),M=a(p=>{let y=r.createBufferSource();return y.buffer=p.buffer,y.loop=p.loop,y.playbackRate.value=p.playbackRate.value,y.detune.value=p.detune.value,y.onended=p.onended,y.connect(d),y},"cloneNode");return{stop(){this.paused=true,this.seek(0)},set paused(p){if(s!==p)if(s=p,p)x&&(n.stop(),x=false),f=r.currentTime;else{n=M(n);let y=f-u;n.start(0,y),x=true,u=r.currentTime-y,f=0}},get paused(){return s},play(p=0){this.seek(p),this.paused=false},seek(p){var y;((y=n.buffer)==null?void 0:y.duration)&&(p>n.buffer.duration||(s?(n=M(n),u=f-p):(n.stop(),n=M(n),u=r.currentTime-p,n.start(0,p),x=true,f=0)))},set speed(p){n.playbackRate.value=p},get speed(){return n.playbackRate.value},set detune(p){n.detune.value=p},get detune(){return n.detune.value},set volume(p){o.gain.value=Math.max(p,0)},get volume(){return o.gain.value},set pan(p){d.pan.value=p},get pan(){return d.pan.value},set loop(p){n.loop=p},get loop(){return n.loop},duration(){var p;return((p=n.buffer)==null?void 0:p.duration)??0},time(){return g()%this.duration()},onEnd(p){return i.add(p)},then(p){return this.onEnd(p)}}}a(el,"play");function $n(t){return c.k.play(c.audio.burpSnd,t)}a($n,"burp");function _n(t){c.audio.masterNode.gain.value=t}a(_n,"setVolume");function ei(){return c.audio.masterNode.gain.value}a(ei,"getVolume");function tl(t){return Lt("volume","setVolume / getVolume"),t!==void 0&&_n(t),ei()}a(tl,"volume");function ti(){c.app.onHide(()=>{c.globalOpt.backgroundAudio||c.audio.ctx.suspend()}),c.app.onShow(()=>{!c.globalOpt.backgroundAudio&&!c.debug.paused&&c.audio.ctx.resume()}),c.app.onResize(()=>{if(c.app.isFullscreen())return;let t=c.globalOpt.width&&c.globalOpt.height;t&&!c.globalOpt.stretch&&!c.globalOpt.letterbox||(c.canvas.width=c.canvas.offsetWidth*c.pixelDensity,c.canvas.height=c.canvas.offsetHeight*c.pixelDensity,Hn(),t||(c.gfx.frameBuffer.free(),c.gfx.frameBuffer=new fs(c.gfx.ggl,c.gfx.ggl.gl.drawingBufferWidth,c.gfx.ggl.gl.drawingBufferHeight),c.gfx.width=c.gfx.ggl.gl.drawingBufferWidth/c.pixelDensity/c.gscale,c.gfx.height=c.gfx.ggl.gl.drawingBufferHeight/c.pixelDensity/c.gscale))}),c.globalOpt.debug!==false&&(c.app.onKeyPress(c.globalOpt.debugKey??"f1",()=>c.debug.inspect=!c.debug.inspect),c.app.onKeyPress("f2",()=>c.debug.clearLog()),c.app.onKeyPress("f8",()=>c.debug.paused=!c.debug.paused),c.app.onKeyPress("f7",()=>{c.debug.timeScale=us(Xe(c.debug.timeScale-.2,0,2),1)}),c.app.onKeyPress("f9",()=>{c.debug.timeScale=us(Xe(c.debug.timeScale+.2,0,2),1)}),c.app.onKeyPress("f10",()=>c.debug.stepFrame())),c.globalOpt.burp&&c.app.onKeyPress("b",()=>$n())}a(ti,"initEvents");function rl(t,e={}){let r=c.game.root.add([Nr(t),oi()]),s=(e.speed||1)*5,n=e.scale||1;r.add([ys(c.boomSprite),Gr(0),As("center"),sn(s,n),...e.comps??[]]);let i=r.add([ys(c.kaSprite),Gr(0),As("center"),ws(),...e.comps??[]]);return i.wait(.4/s,()=>i.use(sn(s,n))),i.onDestroy(()=>r.destroy()),r}a(rl,"addKaboom");function ri(t,e){if(c.game.layers)throw Error("Layers can only be assigned once.");let r=t.indexOf(e);if(r==-1)throw Error("The default layer name should be present in the layers list.");c.game.layers=t,c.game.defaultLayerIndex=r}a(ri,"setLayers");function sl(){return c.game.layers}a(sl,"getLayers");function nl(){var t;return((t=c.game.layers)==null?void 0:t[c.game.defaultLayerIndex])??null}a(nl,"getDefaultLayer");function il(t,e){Lt("layers","setLayers"),ri(t,e)}a(il,"layers");function si(t){t.destroy()}a(si,"destroy");function al(){return c.game.root}a(al,"getTreeRoot");function ol(t,e){c.game.scenes[t]=e}a(ol,"scene");function ll(t,...e){if(!c.game.scenes[t])throw new Error(`Scene not found: ${t}`);c.game.events.onOnce("frameEnd",()=>{c.game.events.trigger("sceneLeave",t),c.app.events.clear(),c.game.events.clear(),c.game.objEvents.clear(),[...c.game.root.children].forEach(r=>{!r.stay||r.scenesToStay&&!r.scenesToStay.includes(t)?c.game.root.remove(r):r.trigger("sceneEnter",t)}),c.game.root.clearEvents(),ti(),c.game.cam={pos:null,scale:E(1),angle:0,shake:0,transform:new et},c.game.scenes[t](...e)}),c.game.currentScene=t}a(ll,"go");function ul(t){return c.game.events.on("sceneLeave",t)}a(ul,"onSceneLeave");function hl(){return c.game.currentScene}a(hl,"getSceneName");function ys(t,e={}){let r=null,s=null,n=null,i=new qe;if(!t)throw new Error("Please pass the resource name or data to sprite()");let o=a((l,u,f,x)=>{let h=E(1,1);return f&&x?(h.x=f/(l.width*u.w),h.y=x/(l.height*u.h)):f?(h.x=f/(l.width*u.w),h.y=h.x):x&&(h.y=x/(l.height*u.h),h.x=h.y),h},"calcTexScale"),d=a((l,u)=>{if(!u)return;let f=u.frames[0].clone();e.quad&&(f=f.scale(e.quad));let x=o(u.tex,f,e.width,e.height);l.width=u.tex.width*f.w*x.x,l.height=u.tex.height*f.h*x.y,e.anim&&l.play(e.anim),r=u,i.trigger(r)},"setSpriteData");return{id:"sprite",width:0,height:0,frame:e.frame||0,quad:e.quad||new ce(0,0,1,1),animSpeed:e.animSpeed??1,flipX:e.flipX??false,flipY:e.flipY??false,get sprite(){return t.toString()},set sprite(l){let u=Ir(l);u&&u.onLoad(f=>d(this,f))},get animFrame(){if(!r||!s||n===null)return this.frame;let l=r.anims[s.name];return typeof l=="number"?l:this.frame-Math.min(l.from,l.to)},draw(){if(!r)return;let l=r.frames[this.frame??0];if(!l)throw new Error(`Frame not found: ${this.frame??0}`);if(r.slice9){let{left:u,right:f,top:x,bottom:h}=r.slice9,w=r.tex.width*l.w,g=r.tex.height*l.h,M=this.width-u-f,p=this.height-x-h,y=u/w,P=f/w,R=1-y-P,O=x/g,T=h/g,A=1-O-T,v=[ge(0,0,y,O),ge(y,0,R,O),ge(y+R,0,P,O),ge(0,O,y,A),ge(y,O,R,A),ge(y+R,O,P,A),ge(0,O+A,y,T),ge(y,O+A,R,T),ge(y+R,O+A,P,T),ge(0,0,u,x),ge(u,0,M,x),ge(u+M,0,f,x),ge(0,x,u,p),ge(u,x,M,p),ge(u+M,x,f,p),ge(0,x+p,u,h),ge(u,x+p,M,h),ge(u+M,x+p,f,h)];for(let S=0;S<9;S++){let k=v[S],I=v[S+9];Hr(Object.assign(Bt(this),{pos:I.pos(),tex:r.tex,quad:l.scale(k),flipX:this.flipX,flipY:this.flipY,tiled:e.tiled,width:I.w,height:I.h}))}}else Hr(Object.assign(Bt(this),{tex:r.tex,quad:l.scale(this.quad??new ce(0,0,1,1)),flipX:this.flipX,flipY:this.flipY,tiled:e.tiled,width:this.width,height:this.height}))},add(){let l=Ir(t);l?l.onLoad(u=>d(this,u)):Os(()=>d(this,Ir(t).data))},update(){if(!r||!s||n===null)return;let l=r.anims[s.name];if(typeof l=="number"){this.frame=l;return}if(l.speed===0)throw new Error("Sprite anim speed cannot be 0");s.timer+=xe()*this.animSpeed,s.timer>=1/s.speed&&(s.timer=0,this.frame+=n,(this.frameMath.max(l.from,l.to))&&(s.loop?s.pingpong?(this.frame-=n,n*=-1,this.frame+=n):this.frame=l.from:s.pingpong?n===Math.sign(l.to-l.from)?(this.frame=l.to,n*=-1,this.frame+=n):(this.frame=l.from,s.onEnd(),this.stop()):(this.frame=l.to,s.onEnd(),this.stop())))},play(l,u={}){if(!r){i.add(()=>this.play(l,u));return}let f=r.anims[l];if(f===void 0)throw new Error(`Anim not found: ${l}`);s&&this.stop(),s=typeof f=="number"?{name:l,timer:0,loop:false,pingpong:false,speed:0,onEnd:a(()=>{},"onEnd")}:{name:l,timer:0,loop:u.loop??f.loop??false,pingpong:u.pingpong??f.pingpong??false,speed:u.speed??f.speed??10,onEnd:u.onEnd??(()=>{})},n=typeof f=="number"?null:f.fromr(this))},draw(){qt(r(this))},renderArea(){return new he(E(0),this.width,this.height)}};return r(s),s}a(dl,"text");function cl(t,e){return{id:"rect",width:t,height:e,draw(){br(Object.assign(Bt(this),{width:this.width,height:this.height}))},renderArea(){return new he(E(0),this.width,this.height)},inspect(){return`uvquad: (${Math.ceil(this.width)}w, ${Math.ceil(this.height)})h`}}}a(cl,"uvquad");function fl(t={}){let e=null,r=null,s=null,n=null;return{id:"agent",require:["pos","tile"],agentSpeed:t.speed??100,allowDiagonals:t.allowDiagonals??true,getDistanceToTarget(){return e?this.pos.dist(e):0},getNextLocation(){return r&&s?r[s]:null},getPath(){return r?r.slice():null},getTarget(){return e},isNavigationFinished(){return r?s===null:true},isTargetReachable(){return r!==null},isTargetReached(){return e?this.pos.eq(e):true},setTarget(i){e=i,r=this.getLevel().getPath(this.pos,e,{allowDiagonals:this.allowDiagonals}),s=r?0:null,r&&s!==null?(n||(n=this.getLevel().onNavigationMapChanged(()=>{e&&r&&s!==null&&(r=this.getLevel().getPath(this.pos,e,{allowDiagonals:this.allowDiagonals}),r?(s=0,this.trigger("navigationNext",this,r[s])):(s=null,this.trigger("navigationEnded",this)))}),this.onDestroy(()=>n==null?void 0:n.cancel())),this.trigger("navigationStarted",this),this.trigger("navigationNext",this,r[s])):this.trigger("navigationEnded",this)},update(){if(e&&r&&s!==null){if(this.pos.sdist(r[s])<2)if(s===r.length-1){this.pos=e.clone(),s=null,this.trigger("navigationEnded",this),this.trigger("targetReached",this);return}else s++,this.trigger("navigationNext",this,r[s]);this.moveTo(r[s],this.agentSpeed)}},onNavigationStarted(i){return this.on("navigationStarted",i)},onNavigationNext(i){return this.on("navigationNext",i)},onNavigationEnded(i){return this.on("navigationEnded",i)},onTargetReached(i){return this.on("targetReached",i)},inspect(){return"agent: "+JSON.stringify({target:JSON.stringify(e),path:JSON.stringify(r)})}}}a(fl,"agent");function pl(t){let e=t.graph;return{id:"pathfinder",require:["pos"],navigateTo(r){var s;return(s=this.graph)==null?void 0:s.getWaypointPath(this.pos,r,t.navigationOpt)},get graph(){if(e)return e;let r=this.parent;for(;r;){if(r.has("pathfinderMap"))return r.graph;r=r.parent}},set graph(r){e=r}}}a(pl,"pathfinder");function gl(t={}){let e=t.waypoints,r=t.speed||100,s=t.endBehavior||"stop",n=0,i=e!=null;return{id:"patrol",require:["pos"],get patrolSpeed(){return r},set patrolSpeed(o){r=o},get waypoints(){return e},set waypoints(o){e=o,n=0,i=false},get nextLocation(){return e?e[n]:void 0},update(){let o=this.nextLocation;if(!(!e||!o||i)&&(this.moveTo(o,r),this.pos.sdist(o)<9))switch(s){case"loop":n=(n+1)%e.length;break;case"ping-pong":n=n+1,n==e.length&&(e.reverse(),n=0);break;case"stop":n=Math.min(n+1,e.length-1),n==e.length-1&&(i=true,this.trigger("patrolFinished"));break}},onPatrolFinished(o){return this.on("patrolFinished",o)}}}a(gl,"patrol");function ml(t,e={}){let r=typeof t=="function"?t:()=>c.game.root.query(t),s=e.checkFrequency||1,n=typeof e.direction=="number"?B.fromAngle(e.direction):e.direction,i=0;return{id:"sentry",require:["pos"],direction:typeof e.direction=="number"?B.fromAngle(e.direction):e.direction,spotted:[],set directionAngle(o){this.direction=o!==void 0?B.fromAngle(o):void 0},get directionAngle(){return this.direction?this.direction.angle():void 0},fieldOfView:e.fieldOfView||200,isWithinFieldOfView(o,d,l){let u=(typeof d=="number"?B.fromAngle(d):d)||n,f=l||e.fieldOfView;if(!u||!f||f>=360)return true;let x=f/2;return o.pos&&u.angleBetween(o.pos.sub(this.pos))<=x},hasLineOfSight(o){let d=jn(this.pos,o.pos.sub(this.pos),e.raycastExclude);return d!=null&&d.object===o},update(){if(i+=xe(),i>s){i-=s;let o=r();if(o.length&&n&&this.fieldOfView&&this.fieldOfView<360){let d=this.fieldOfView/2;o=o.filter(l=>l.pos&&n.angleBetween(l.pos.sub(this.pos))<=d)}o.length&&e.lineOfSight&&(o=o.filter(d=>d.pos&&this.hasLineOfSight(d))),o.length>0&&(this.spotted=o,this.trigger("objectSpotted",o))}},onObjectsSpotted(o){return this.on("objectSpotted",o)}}}a(ml,"sentry");function ni(t={}){let e=E(0),r=t.isObstacle??false,s=t.cost??0,n=t.edges??[],i=a(()=>{let d={left:1,top:2,right:4,bottom:8};return n.map(l=>d[l]||0).reduce((l,u)=>l|u,0)},"getEdgeMask"),o=i();return{id:"tile",tilePosOffset:t.offset??E(0),set tilePos(d){let l=this.getLevel();e=d.clone(),this.pos=E(this.tilePos.x*l.tileWidth(),this.tilePos.y*l.tileHeight()).add(this.tilePosOffset)},get tilePos(){return e},set isObstacle(d){r!==d&&(r=d,this.getLevel().invalidateNavigationMap())},get isObstacle(){return r},set cost(d){s!==d&&(s=d,this.getLevel().invalidateNavigationMap())},get cost(){return s},set edges(d){n=d,o=i(),this.getLevel().invalidateNavigationMap()},get edges(){return n},get edgeMask(){return o},getLevel(){return this.parent},tileMove(d){let l=this.getLevel();l.removeFromSpatialMap(this),this.tilePos=this.tilePos.add(d),l.insertIntoSpatialMap(this),l.trigger("spatialMapChanged")},moveLeft(){this.tileMove(E(-1,0))},moveRight(){this.tileMove(E(1,0))},moveUp(){this.tileMove(E(0,-1))},moveDown(){this.tileMove(E(0,1))}}}a(ni,"tile");var yr;var ii=(yr=class{constructor(e,r,s){b(this,"name");b(this,"duration");b(this,"loops");b(this,"direction");b(this,"easing");b(this,"interpolation");b(this,"isFinished");b(this,"timing");b(this,"easings");b(this,"relative");this.name=e,this.duration=r.duration,this.loops=r.loops||0,this.direction=r.direction||"forward",this.easing=r.easing||Or.linear,this.interpolation=r.interpolation||"linear",this.isFinished=false,this.timing=r.timing,this.easings=r.easings,this.relative=s}update(e,r){return true}getLowerKeyIndexAndRelativeTime(e,r,s){let n=r-1,i=e/this.duration;if(this.loops!==0&&i>=this.loops)return[n,0,true];let o=Math.trunc(i);if(i-=o,(this.direction=="reverse"||this.direction=="ping-pong"&&o&1)&&(i=1-i),s){let d=0;for(;s[d+1]!==void 0&&s[d+1]=n?[n,0,true]:[d,(i-s[d])/(s[d+1]-s[d]),false]}else{let d=Math.floor((r-1)*i);return[d,(i-d/n)*n,false]}}setValue(e,r,s){if(this.relative)switch(r){case"pos":e.pos=e.base.pos.add(s);break;case"angle":e.angle=e.base.angle+s;break;case"scale":e.scale=e.base.scale.scale(s);break;case"opacity":e.opacity=e.base.opacity*s;break;default:e[r]=s}else e[r]=s}serialize(){let e={duration:this.duration,keys:[]};return this.loops&&(e.loops=this.loops),this.direction!=="forward"&&(e.direction=this.direction),this.easing!=Or.linear&&(e.easing=this.easing.name),this.interpolation!=="linear"&&(e.interpolation=this.interpolation),this.timing&&(e.timing=this.timing),this.easings&&(e.easings=this.easings.map(r=>this.easing.name)),e}},a(yr,"AnimateChannel"),yr);function rn(t,e){return e.add(e.sub(t))}a(rn,"reflect");var wr;var th=(wr=class extends ii{constructor(r,s,n,i){super(r,n,i);b(this,"keys");this.keys=s}update(r,s){let[n,i,o]=this.getLowerKeyIndexAndRelativeTime(s,this.keys.length,this.timing);if(i==0||this.interpolation==="none")this.setValue(r,this.name,this.keys[n]);else{let d=this.easings?this.easings[n]:this.easing;this.setValue(r,this.name,Ce(this.keys[n],this.keys[n+1],d(i)))}return o}serialize(){return Object.assign(super.serialize(),{keys:this.keys})}},a(wr,"AnimateChannelNumber"),wr);var Ar;var rh=(Ar=class extends ii{constructor(r,s,n,i,o){var d;super(r,n,i);b(this,"keys");b(this,"curves");b(this,"dcurves");if(this.keys=s,this.interpolation==="spline"){this.curves=[],o&&(this.dcurves=[]);for(let l=0;l0?this.keys[l-1]:rn(x,u),w=f[r.x,r.y])})}},a(Ar,"AnimateChannelVec2"),Ar);var xr;var sh=(xr=class extends ii{constructor(r,s,n,i){super(r,n,i);b(this,"keys");this.keys=s}update(r,s){let[n,i,o]=this.getLowerKeyIndexAndRelativeTime(s,this.keys.length,this.timing);if(i==0||this.interpolation=="none")this.setValue(r,this.name,this.keys[n]);else{let d=this.easings?this.easings[n]:this.easing;this.setValue(r,this.name,this.keys[n].lerp(this.keys[n+1],d(i)))}return o}serialize(){return Object.assign(super.serialize(),{keys:this.keys})}},a(xr,"AnimateChannelColor"),xr);function yl(t={}){let e=[],r=0,s=false;return{id:"animate",require:t.followMotion?["rotate"]:void 0,base:{pos:E(0,0),angle:0,scale:E(1,1),opacity:1},animation:{paused:false,seek(n){r=Xe(n,0,this.duration),e.forEach(i=>{i.isFinished=false}),s=false},get duration(){return e.reduce((n,i)=>Math.max(i.duration,n),0)}},add(){t.relative&&(this.has("pos")&&(this.base.pos=this.pos.clone()),this.has("rotate")&&(this.base.angle=this.angle),this.has("scale")&&(this.base.scale=this.scale),this.has("opacity")&&(this.base.opacity=this.opacity))},update(){if(this.animation.paused)return;let n=true,i;r+=xe();for(let o of e)i=o.update(this,r),i&&!o.isFinished&&(o.isFinished=true,this.trigger("animateChannelFinished",o.name)),n&&(n=i);n&&!s&&(s=true,this.trigger("animateFinished"))},animate(n,i,o){s=false,this.unanimate(n),typeof i[0]=="number"?e.push(new th(n,i,o,t.relative||false)):i[0]instanceof B?e.push(new rh(n,i,o,t.relative||false,n==="pos"&&(t.followMotion||false))):i[0]instanceof Z&&e.push(new sh(n,i,o,t.relative||false))},unanimate(n){let i=e.findIndex(o=>o.name===n);i>=0&&e.splice(i,1)},unanimateAll(){e.splice(0,e.length)},onAnimateFinished(n){return this.on("animateFinished",n)},onAnimateChannelFinished(n){return this.on("animateChannelFinished",n)},serializeAnimationChannels(){return e.reduce((n,i)=>(n[i.name]=i.serialize(),n),{})},serializeAnimationOptions(){let n={};return t.followMotion&&(n.followMotion=true),t.relative&&(n.relative=true),n}}}a(yl,"animate");function ai(t,e){let r={name:t.name};return t.has("animate")&&(r.channels=t.serializeAnimationChannels(),Object.assign(r,t.serializeAnimationOptions())),t.children.length>0&&(r.children=t.children.filter(s=>s.has("named")).map(s=>ai(s,s.name))),r}a(ai,"serializeAnimation");function sn(t=2,e=1){let r=0;return{require:["scale"],update(){let s=Math.sin(r*t)*e;s<0&&this.destroy(),this.scale=E(s),r+=xe()}}}a(sn,"boom");function wl(t,e){if(t==null)throw new Error("health() requires the initial amount of hp");return{id:"health",hurt(r=1){this.setHP(t-r),this.trigger("hurt",r)},heal(r=1){let s=t;this.setHP(t+r),this.trigger("heal",t-s)},hp(){return t},maxHP(){return e??null},setMaxHP(r){e=r},setHP(r){t=e?Math.min(e,r):r,t<=0&&this.trigger("death")},onHurt(r){return this.on("hurt",r)},onHeal(r){return this.on("heal",r)},onDeath(r){return this.on("death",r)},inspect(){return`health: ${t}`}}}a(wl,"health");function Al(t,e={}){if(t==null)throw new Error("lifespan() requires time");let r=e.fade??0;return{id:"lifespan",require:["opacity"],add(){c.game.root.wait(t,()=>{this.opacity=this.opacity??1,r>0?c.game.root.tween(this.opacity,0,r,s=>this.opacity=s,Or.linear).onEnd(()=>{this.destroy()}):this.destroy()})}}}a(Al,"lifespan");function xl(t){return{id:"named",name:t}}a(xl,"named");function vl(t,e,r){if(!t)throw new Error("state() requires an initial state");let s={};function n(l){s[l]||(s[l]={enter:new qe,end:new qe,update:new qe,draw:new qe})}a(n,"initStateEvents");function i(l,u,f){return n(u),s[u][l].add(f)}a(i,"on");function o(l,u,...f){n(u),s[u][l].trigger(...f)}a(o,"trigger");let d=false;return{id:"state",state:t,enterState(l,...u){if(d=true,e&&!e.includes(l))throw new Error(`State not found: ${l}`);let f=this.state;if(r){if(!(r==null?void 0:r[f]))return;let x=typeof r[f]=="string"?[r[f]]:r[f];if(!x.includes(l))throw new Error(`Cannot transition state from "${f}" to "${l}". Available transitions: ${x.map(h=>`"${h}"`).join(", ")}`)}o("end",f,...u),this.state=l,o("enter",l,...u),o("enter",`${f} -> ${l}`,...u)},onStateTransition(l,u,f){return i("enter",`${l} -> ${u}`,f)},onStateEnter(l,u){return i("enter",l,u)},onStateUpdate(l,u){return i("update",l,u)},onStateDraw(l,u){return i("draw",l,u)},onStateEnd(l,u){return i("end",l,u)},update(){d||(o("enter",t),d=true),o("update",this.state)},draw(){o("draw",this.state)},inspect(){return`state: ${this.state}`}}}a(vl,"state");function oi(t){return{id:"stay",stay:true,scenesToStay:t}}a(oi,"stay");function bl(t=true,e){let r,s;return{id:"textInput",hasFocus:t,require:["text"],typedText:"",add(){let n=a(()=>{this.text=this.typedText.replace(/([\[\\])/g,"\\$1")},"flip");r=c.k.onCharInput(i=>{this.hasFocus&&(!e||this.typedText.length{this.hasFocus&&(this.typedText=this.typedText.slice(0,-1)),n()})},destroy(){r.cancel(),s.cancel()}}}a(bl,"textInput");function ws(t=1e3){return{id:"timer",maxLoopsPerFrame:t,loop(e,r,s=-1,n=false){let i=n?0:e,o=new qe,d=this.onUpdate(()=>{i+=c.app.state.dt;for(let l=0;i>=e&&l{}),1,true)},tween(e,r,s,n,i=Or.linear){let o=0,d=[],l=this.onUpdate(()=>{o+=c.app.state.dt;let u=Math.min(o/s,1);n(Ce(e,r,i(u))),u===1&&(l.cancel(),n(r),d.forEach(f=>f()))});return{get paused(){return l.paused},set paused(u){l.paused=u},onEnd(u){d.push(u)},then(u){return this.onEnd(u),this},cancel(){l.cancel()},finish(){l.cancel(),n(r),d.forEach(u=>u())}}}}}a(ws,"timer");var nn=0;function El(){return nn>0}a(El,"usesArea");function Sl(t={}){let e={},r=new Set,s=[];return{id:"area",collisionIgnore:t.collisionIgnore??[],add(){nn++,this.area.cursor&&s.push(this.onHover(()=>c.app.setCursor(this.area.cursor))),s.push(this.onCollideUpdate((n,i)=>{if(!n.id)throw new Error("area() requires the object to have an id");e[n.id]||this.trigger("collide",n,i),i&&(e[n.id]=i,r.add(n.id))}))},destroy(){nn--;for(let n of s)n.cancel()},fixedUpdate(){for(let n in e)r.has(Number(n))||(this.trigger("collideEnd",e[n].target),delete e[n]);r.clear()},drawInspect(){let n=this.localArea();Ie(),de(this.area.offset);let i={outline:{width:4/Sn(),color:re(0,0,255)},anchor:this.anchor,fill:false,fixed:yt(this)};n instanceof he?Te({...i,pos:n.pos,width:n.width*this.area.scale.x,height:n.height*this.area.scale.y}):n instanceof Pe?ut({...i,pts:n.pts,scale:this.area.scale}):n instanceof Oe&&Nt({...i,pos:n.center,radius:n.radius}),Be()},area:{shape:t.shape??null,scale:t.scale?E(t.scale):E(1),offset:t.offset??E(0),cursor:t.cursor??null},isClicked(){return c.app.isMousePressed()&&this.isHovering()},isHovering(){let n=yt(this)?c.k.mousePos():c.k.toWorld(c.k.mousePos());return this.hasPoint(n)},checkCollision(n){if(!n.id)throw new Error("checkCollision() requires the object to have an id");return e[n.id]??null},getCollisions(){return Object.values(e)},isColliding(n){if(!n.id)throw new Error("isColliding() requires the object to have an id");return!!e[n.id]},isOverlapping(n){if(!n.id)throw new Error("isOverlapping() requires the object to have an id");let i=e[n.id];return i&&i.hasOverlap()},onClick(n,i="left"){let o=c.app.onMousePress(i,()=>{this.isHovering()&&n()});return s.push(o),o},onHover(n){let i=false;return this.onUpdate(()=>{i?i=this.isHovering():this.isHovering()&&(i=true,n())})},onHoverUpdate(n){return this.onUpdate(()=>{this.isHovering()&&n()})},onHoverEnd(n){let i=false;return this.onUpdate(()=>{i?this.isHovering()||(i=false,n()):i=this.isHovering()})},onCollide(n,i){if(typeof n=="function"&&i===void 0)return this.on("collide",n);if(typeof n=="string")return this.onCollide((o,d)=>{o.is(n)&&(i==null?void 0:i(o,d))});throw new Error("onCollide() requires either a function or a tag")},onCollideUpdate(n,i){if(typeof n=="function"&&i===void 0)return this.on("collideUpdate",n);if(typeof n=="string")return this.on("collideUpdate",(o,d)=>o.is(n)&&(i==null?void 0:i(o,d)));throw new Error("onCollideUpdate() requires either a function or a tag")},onCollideEnd(n,i){if(typeof n=="function"&&i===void 0)return this.on("collideEnd",n);if(typeof n=="string")return this.on("collideEnd",o=>o.is(n)&&(i==null?void 0:i(o)));throw new Error("onCollideEnd() requires either a function or a tag")},hasPoint(n){return ht(this.worldArea(),n)},resolveCollision(n){let i=this.checkCollision(n);i&&!i.resolved&&(this.pos=this.pos.add(i.displacement),i.resolved=true)},localArea(){return this.area.shape?this.area.shape:this.renderArea()},worldArea(){let n=this.localArea();if(!(n instanceof Pe||n instanceof he))throw new Error("Only support polygon and rect shapes for now");let i=this.transform.clone().translate(this.area.offset).scale(E(this.area.scale??1));if(n instanceof he){let o=Ht(this.anchor||Ps).add(1,1).scale(-.5).scale(n.width,n.height);i.translate(o)}return n.transform(i)},screenArea(){let n=this.worldArea();return yt(this)?n:n.transform(c.game.cam.transform)},inspect(){var n,i,o,d,l,u,f;return((n=this.area.scale)==null?void 0:n.x)==((i=this.area.scale)==null?void 0:i.y)?`area: ${(d=(o=this.area.scale)==null?void 0:o.x)==null?void 0:d.toFixed(1)}x`:`area: (${(u=(l=this.area.scale)==null?void 0:l.x)==null?void 0:u.toFixed(1)}x, ${(f=this.area.scale.y)==null?void 0:f.toFixed(1)}y)`}}}a(Sl,"area");function Ml(t={}){let e=null,r=null,s=false,n=E(0),i=null,o=null,d;return{id:"body",require:["pos"],vel:E(0),drag:t.drag??0,jumpForce:t.jumpForce??lu,gravityScale:t.gravityScale??1,isStatic:t.isStatic??false,mass:t.mass??1,add(){if(i=this.pos.clone(),o=this.pos.clone(),d=this.pos.clone(),this.mass===0)throw new Error("Can't set body mass to 0");this.has("area")&&(this.onCollideUpdate((l,u)=>{if(!u||!l.has("body")||u.resolved)return;this.trigger("beforePhysicsResolve",u);let f=u.reverse();if(l.trigger("beforePhysicsResolve",f),!(u.resolved||f.resolved)&&!(this.isStatic&&l.isStatic)){if(!this.isStatic&&!l.isStatic){let x=this.mass+l.mass;this.pos=this.pos.add(u.displacement.scale(l.mass/x)),l.pos=l.pos.add(u.displacement.scale(-this.mass/x)),this.transform=Wt(this),l.transform=Wt(l)}else{let x=!this.isStatic&&l.isStatic?u:u.reverse();x.source.pos=x.source.pos.add(x.displacement),x.source.transform=Wt(x.source)}u.resolved=true,this.trigger("physicsResolve",u),l.trigger("physicsResolve",u.reverse())}}),this.onPhysicsResolve(l=>{if(c.game.gravity)if(l.isBottom()&&this.isFalling()){this.vel=this.vel.reject(c.game.gravity.unit());let u=e;e=l.target,u!=e&&(r=l.target.pos),s?s=false:u||(this.trigger("ground",e),l.target.trigger("land",this))}else l.isTop()&&this.isJumping()&&(this.vel=this.vel.reject(c.game.gravity.unit()),this.trigger("headbutt",l.target),l.target.trigger("headbutted",this))}))},update(){e&&this.isColliding(e)&&e.exists()&&e.has("body")&&(r&&!e.pos.eq(r)&&t.stickToPlatform!==false&&this.moveBy(e.pos.sub(r)),r=e.pos);let l=ds();l&&(this.pos.x==d.x&&(this.pos.x=Ce(i.x,o.x,l/hs()),d.x=this.pos.x),this.pos.y==d.y&&(this.pos.y=Ce(i.y,o.y,l/hs()),d.y=this.pos.y))},fixedUpdate(){if(i&&(this.pos.x==d.x&&(this.pos.x=i.x),this.pos.y==d.y&&(this.pos.y=i.y),i=null),c.game.gravity&&!this.isStatic){s&&(e=null,r=null,this.trigger("fallOff"),s=false),e&&(!this.isColliding(e)||!e.exists()||!e.has("body"))&&(s=true);let l=this.vel.clone();this.vel=this.vel.add(c.game.gravity.scale(this.gravityScale*xe()));let u=t.maxVelocity??uu;this.vel.slen()>u*u&&(this.vel=this.vel.unit().scale(u)),l.dot(c.game.gravity)<0&&this.vel.dot(c.game.gravity)>=0&&this.trigger("fall")}if(this.vel.x+=n.x*xe(),this.vel.y+=n.y*xe(),this.vel.x*=1-this.drag*xe(),this.vel.y*=1-this.drag*xe(),this.move(this.vel),ds()){i=this.pos.clone();let l=this.vel.add(n.scale(xe()));o=this.pos.add(l.scale(xe())),d=this.pos.clone()}n.x=0,n.y=0},onPhysicsResolve(l){return this.on("physicsResolve",l)},onBeforePhysicsResolve(l){return this.on("beforePhysicsResolve",l)},curPlatform(){return e},isGrounded(){return e!==null},isFalling(){return this.vel.dot(Jt())>0},isJumping(){return this.vel.dot(Jt())<0},applyImpulse(l){this.isStatic||(this.vel=this.vel.add(l))},addForce(l){this.isStatic||(n.x+=l.x/this.mass,n.y+=l.y/this.mass)},jump(l){this.isStatic||(e=null,r=null,this.vel=Jt().scale(-l||-this.jumpForce))},onGround(l){return this.on("ground",l)},onFall(l){return this.on("fall",l)},onFallOff(l){return this.on("fallOff",l)},onHeadbutt(l){return this.on("headbutt",l)},onLand(l){return this.on("land",l)},onHeadbutted(l){return this.on("headbutted",l)},inspect(){return`gravityScale: ${this.gravityScale}x`}}}a(Ml,"body");function ql(t=2){let e=t;return{id:"doubleJump",require:["body"],numJumps:t,add(){this.onGround(()=>{e=this.numJumps})},doubleJump(r){e<=0||(e{var o;let s=r==null?void 0:r.normal.normal(),n=e.vel.project(s),i=(o=s==null?void 0:s.scale(this.speed))==null?void 0:o.sub(n);e.addForce(i==null?void 0:i.scale(e.mass*this.forceScale))})}}}a(Bl,"surfaceEffector");function Cl(t){return{id:"areaEffector",require:["area"],useGlobalAngle:t.useGlobalAngle||false,forceAngle:t.forceAngle,forceMagnitude:t.forceMagnitude,forceVariation:t.forceVariation??0,linearDrag:t.linearDrag??0,add(){this.onCollideUpdate("body",(e,r)=>{if(!e.has("body"))return;let s=B.fromAngle(this.forceAngle).scale(this.forceMagnitude);e.addForce(s),this.linearDrag&&e.addForce(e.vel.scale(-this.linearDrag))})}}}a(Cl,"areaEffector");function Pl(t){return{id:"pointEffector",require:["area","pos"],forceMagnitude:t.forceMagnitude,forceVariation:t.forceVariation??0,distanceScale:t.distanceScale??1,forceMode:t.forceMode||"inverseLinear",linearDrag:t.linearDrag??0,add(){this.onCollideUpdate("body",(e,r)=>{let s=this.pos.sub(e.pos),n=s.len(),i=n*this.distanceScale/10,o=this.forceMode==="constant"?1:this.forceMode==="inverseLinear"?1/i:1/i**2,d=s.scale(this.forceMagnitude*o/n);e.addForce(d),this.linearDrag&&e.addForce(e.vel.scale(-this.linearDrag))})}}}a(Pl,"pointEffector");function Rl(t){return{id:"constantForce",require:["body"],force:t.force,update(){this.force&&this.addForce(this.force)}}}a(Rl,"constantForce");function kl(t){return{id:"platformEffector",require:["area","body"],surfaceArc:t.surfaceArc??180,useOneWay:t.useOneWay??false,add(){this.onBeforePhysicsResolve(e=>{let r=e.target.vel,s=Jt().scale(-1).angleBetween(r);Math.abs(s)>this.surfaceArc/2&&e.preventResolution()})}}}a(kl,"platformEffector");function Il(t){return{id:"buoyancyEffector",require:["area"],surfaceLevel:t.surfaceLevel,density:t.density??1,linearDrag:t.linearDrag??1,angularDrag:t.angularDrag??.2,flowAngle:t.flowAngle??0,flowMagnitude:t.flowMagnitude??0,flowVariation:t.flowVariation??0,add(){this.onCollideUpdate("body",(e,r)=>{let s=e,n=s.worldArea(),[i,o]=n.cut(E(-100,this.surfaceLevel),E(100,this.surfaceLevel));i&&(this.applyBuoyancy(s,i),this.applyDrag(s,i)),this.flowMagnitude&&s.addForce(B.fromAngle(this.flowAngle).scale(this.flowMagnitude))})},applyBuoyancy(e,r){let s=this.density*r.area(),n=E(0,1).scale(-s);e.addForce(n)},applyDrag(e,r){let s=e.vel,n=this.density*this.linearDrag,i=s.scale(-n);e.addForce(i)}}}a(Il,"buoyancyEffector");function As(t){if(!t)throw new Error("Please define an anchor");return{id:"anchor",anchor:t,inspect(){return typeof this.anchor=="string"?"anchor: "+this.anchor:"anchor: "+this.anchor.toString()}}}a(As,"anchor");function li(){return{id:"fixed",fixed:true}}a(li,"fixed");function Dl(t,e){return{id:"follow",require:["pos"],follow:{obj:t,offset:e??E(0)},add(){t.exists()&&(this.pos=this.follow.obj.pos.add(this.follow.offset))},update(){t.exists()&&(this.pos=this.follow.obj.pos.add(this.follow.offset))}}}a(Dl,"follow");function Tl(t){var r;let e=(r=c.game.layers)==null?void 0:r.indexOf(t);return{id:"layer",get layerIndex(){return e??null},get layer(){var s;return e?((s=c.game.layers)==null?void 0:s[e])??null:null},set layer(s){var n;if(e=(n=c.game.layers)==null?void 0:n.indexOf(s),e==-1)throw Error("Invalid layer name")},inspect(){return`layer: ${this.layer}`}}}a(Tl,"layer");function Fl(t,e){let r=typeof t=="number"?B.fromAngle(t):t.unit();return{id:"move",require:["pos"],update(){this.move(r.scale(e))}}}a(Fl,"move");function Ol(t={}){let e=t.distance??ou,r=false;return{id:"offscreen",require:["pos"],isOffScreen(){let s=this.screenPos();if(!s)return false;let n=new he(E(0),ve(),Ee());return!Vr(n,s)&&n.sdistToPoint(s)>e*e},onExitScreen(s){return this.on("exitView",s)},onEnterScreen(s){return this.on("enterView",s)},update(){this.isOffScreen()?(r||(this.trigger("exitView"),r=true),t.hide&&(this.hidden=true),t.pause&&(this.paused=true),t.destroy&&this.destroy()):(r&&(this.trigger("enterView"),r=false),t.hide&&(this.hidden=false),t.pause&&(this.paused=false))}}}a(Ol,"offscreen");function Nr(...t){return{id:"pos",pos:E(...t),moveBy(...e){this.pos=this.pos.add(E(...e))},move(...e){this.moveBy(E(...e).scale(xe()))},moveTo(...e){if(typeof e[0]=="number"&&typeof e[1]=="number")return this.moveTo(E(e[0],e[1]),e[2]);let r=e[0],s=e[1];if(s===void 0){this.pos=E(r);return}let n=r.sub(this.pos);if(n.len()<=s*xe()){this.pos=E(r);return}this.move(n.unit().scale(s))},worldPos(e=null){return e?(this.pos=this.pos.add(this.fromWorld(e)),null):this.parent?this.parent.transform.multVec2(this.pos):this.pos},toWorld(e){return this.parent?this.parent.transform.multVec2(this.pos.add(e)):this.pos.add(e)},fromWorld(e){return this.parent?this.parent.transform.invert().multVec2(e).sub(this.pos):e.sub(this.pos)},screenPos(e=null){if(e)return this.pos=this.pos.add(this.fromScreen(e)),null;{let r=this.worldPos();return r?yt(this)?r:ms(r):null}},toScreen(e){let r=this.toWorld(e);return yt(this)?r:ms(r)},fromScreen(e){return yt(this)?this.fromWorld(e):this.fromWorld(Jn(e))},toOther(e,r){return e.fromWorld(this.toWorld(r))},fromOther(e,r){return e.toOther(this,r)},inspect(){return`pos: (${Math.round(this.pos.x)}x, ${Math.round(this.pos.y)}y)`},drawInspect(){Nt({color:re(255,0,0),radius:4/Sn()})}}}a(Nr,"pos");function Ul(t){return{id:"rotate",angle:t??0,rotateBy(e){this.angle+=e},rotateTo(e){this.angle=e},inspect(){return`angle: ${Math.round(this.angle)}`}}}a(Ul,"rotate");function Gr(...t){if(t.length===0)return Gr(1);let e=E(...t);return{id:"scale",set scale(r){if(!(r instanceof B))throw Error("The scale property on scale is a vector. Use scaleTo or scaleBy to set the scale with a number.");e=E(r)},get scale(){return e},scaleTo(...r){e=E(...r)},scaleBy(...r){e=e.scale(E(...r))},inspect(){return e.x==e.y?`scale: ${e.x.toFixed(1)}x`:`scale: (${e.x.toFixed(1)}x, ${e.y.toFixed(1)}y)`}}}a(Gr,"scale");function Ll(t){return{id:"z",z:t,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pE5AkGxh9f2nLO/QOetytIwAnMf6SfS2ns+jaZ6B4i2sWvSvF0HWOAj/aRGNFAaPXbw2rS2Rzr0T/ChshKNM3qd4135BCaqK9VAKy+lAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/4DBC0k0jFtF9wAAAAASUVORK5CYII=";var ah="3001.0.0";var c={k:null,globalOpt:null,gfx:null,game:null,app:null,assets:null,fontCacheCanvas:null,fontCacheC2d:null,debug:null,audio:null,pixelDensity:null,canvas:null,gscale:null,kaSprite:null,boomSprite:null};var oh=a((t={tagsAsComponents:true})=>{c.k&&(console.warn("KAPLAY already initialized, you are calling kaplay() multiple times, it may lead bugs!"),c.k.quit()),c.globalOpt=t;let e=t.root??document.body;e===document.body&&(document.body.style.width="100%",document.body.style.height="100%",document.body.style.margin="0px",document.documentElement.style.width="100%",document.documentElement.style.height="100%");let r=t.canvas??e.appendChild(document.createElement("canvas"));c.canvas=r;let s=t.scale??1;c.gscale=s;let n=t.width&&t.height&&!t.stretch&&!t.letterbox;n?(r.width=t.width*s,r.height=t.height*s):(r.width=r.parentElement.offsetWidth,r.height=r.parentElement.offsetHeight);let i=["outline: none","cursor: default"];if(n){let L=r.width,K=r.height;i.push(`width: ${L}px`),i.push(`height: ${K}px`)}else i.push("width: 100%"),i.push("height: 100%");t.crisp&&(i.push("image-rendering: pixelated"),i.push("image-rendering: crisp-edges")),r.style.cssText=i.join(";");let o=t.pixelDensity||1;c.pixelDensity=o,r.width*=o,r.height*=o,r.tabIndex=0;let d=document.createElement("canvas");d.width=256,d.height=256,c.fontCacheCanvas=d;let l=d.getContext("2d",{willReadFrequently:true});c.fontCacheC2d=l;let u=Eu({canvas:r,touchToMouse:t.touchToMouse,gamepads:t.gamepads,pixelDensity:t.pixelDensity,maxFPS:t.maxFPS,buttons:t.buttons});c.app=u;let f=[],x=u.canvas.getContext("webgl",{antialias:true,depth:true,stencil:true,alpha:true,preserveDrawingBuffer:true});if(!x)throw new Error("WebGL not supported");let h=x,w=po(h,{texFilter:t.texFilter}),g=Gu(t,w);c.gfx=g;let M=eh();c.audio=M;let p=Uu(w,t.spriteAtlasPadding??0);c.assets=p;let y=$u();c.game=y,y.root.use(ws());function P(L,K){let Q=new fs(w,L,K);return{clear:a(()=>Q.clear(),"clear"),free:a(()=>Q.free(),"free"),toDataURL:a(()=>Q.toDataURL(),"toDataURL"),toImageData:a(()=>Q.toImageData(),"toImageData"),width:Q.width,height:Q.height,draw:a(oe=>{De(),Q.bind(),oe(),De(),Q.unbind()},"draw"),get fb(){return Q}}}a(P,"makeCanvas");function R(){h.clear(h.COLOR_BUFFER_BIT),g.frameBuffer.bind(),h.clear(h.COLOR_BUFFER_BIT),g.bgColor||ot(()=>{br({width:ve(),height:Ee(),quad:new ce(0,0,ve()/64,Ee()/64),tex:g.bgTex,fixed:true})}),g.renderer.numDraws=0,g.fixed=false,g.transformStack.length=0,g.transform=new et}a(R,"frameStart");function O(L,K){g.postShader=L,g.postShaderUniform=K??null}a(O,"usePostEffect");function T(){De(),g.lastDrawCalls=g.renderer.numDraws,g.frameBuffer.unbind(),h.viewport(0,0,h.drawingBufferWidth,h.drawingBufferHeight);let L=g.width,K=g.height;g.width=h.drawingBufferWidth/o,g.height=h.drawingBufferHeight/o,Hr({flipY:true,tex:g.frameBuffer.tex,pos:new B(g.viewport.x,g.viewport.y),width:g.viewport.width,height:g.viewport.height,shader:g.postShader,uniform:typeof g.postShaderUniform=="function"?g.postShaderUniform():g.postShaderUniform,fixed:true}),De(),g.width=L,g.height=K}a(T,"frameEnd");let A=false,v={inspect:false,timeScale:1,showLog:true,fps:a(()=>u.fps(),"fps"),numFrames:a(()=>u.numFrames(),"numFrames"),stepFrame:ft,drawCalls:a(()=>g.lastDrawCalls,"drawCalls"),clearLog:a(()=>y.logs=[],"clearLog"),log:a((...L)=>{let K=t.logMax??8,Q=L.length>1?L.concat(" ").join(" "):L[0];y.logs.unshift({msg:Q,time:u.time()}),y.logs.length>K&&(y.logs=y.logs.slice(0,K))},"log"),error:a(L=>v.log(new Error(L.toString?L.toString():L)),"error"),curRecording:null,numObjects:a(()=>V("*",{recursive:true}).length,"numObjects"),get paused(){return A},set paused(L){A=L,L?M.ctx.suspend():M.ctx.resume()}};c.debug=v;function S(L,K){try{return JSON.parse(window.localStorage[L])}catch{return K?(k(L,K),K):null}}a(S,"getData");function k(L,K){window.localStorage[L]=JSON.stringify(K)}a(k,"setData");function I(L,...K){let Q=L(Qe),oe;typeof Q=="function"?oe=Q(...K)(Qe):oe=Q;for(let ye in oe)Qe[ye]=oe[ye],t.global!==false&&(window[ye]=oe[ye]);return Qe}a(I,"plug");function F(L){let K=u.canvas.captureStream(L),Q=M.ctx.createMediaStreamDestination();M.masterNode.connect(Q);let oe=new MediaRecorder(K),ye=[];return oe.ondataavailable=te=>{te.data.size>0&&ye.push(te.data)},oe.onerror=()=>{M.masterNode.disconnect(Q),K.getTracks().forEach(te=>te.stop())},oe.start(),{resume(){oe.resume()},pause(){oe.pause()},stop(){return oe.stop(),M.masterNode.disconnect(Q),K.getTracks().forEach(te=>te.stop()),new Promise(te=>{oe.onstop=()=>{te(new Blob(ye,{type:"video/mp4"}))}})},download(te="kaboom.mp4"){this.stop().then(Se=>Zs(te,Se))}}}a(F,"record");function U(){return document.activeElement===u.canvas}a(U,"isFocused");let H=y.root.add.bind(y.root),j=y.root.readd.bind(y.root),J=y.root.removeAll.bind(y.root),V=y.root.get.bind(y.root),X=y.root.wait.bind(y.root),se=y.root.loop.bind(y.root),ee=y.root.query.bind(y.root),$=y.root.tween.bind(y.root),fe=Zt(null,ih),N=Zt(null,nh);c.kaSprite=fe,c.boomSprite=N;function tt(){y.root.fixedUpdate()}a(tt,"fixedUpdateFrame");function ft(){y.root.update()}a(ft,"updateFrame");const Pt=class Pt{constructor(K,Q,oe,ye,te=false){b(this,"source");b(this,"target");b(this,"normal");b(this,"distance");b(this,"resolved",false);this.source=K,this.target=Q,this.normal=oe,this.distance=ye,this.resolved=te}get displacement(){return this.normal.scale(this.distance)}reverse(){return new Pt(this.target,this.source,this.normal.scale(-1),this.distance,this.resolved)}hasOverlap(){return!this.displacement.isZero()}isLeft(){return this.displacement.cross(y.gravity||E(0,1))>0}isRight(){return this.displacement.cross(y.gravity||E(0,1))<0}isTop(){return this.displacement.dot(y.gravity||E(0,1))>0}isBottom(){return this.displacement.dot(y.gravity||E(0,1))<0}preventResolution(){this.resolved=true}};a(Pt,"Collision");let Gt=Pt;function Mr(){if(!El())return;let L={},K=t.hashGridSize||64,Q=new et,oe=[];function ye(te){if(oe.push(Q.clone()),te.pos&&Q.translate(te.pos),te.scale&&Q.scale(te.scale),te.angle&&Q.rotate(te.angle),te.transform=Q.clone(),te.c("area")&&!te.paused){let Se=te,pt=Se.worldArea().bbox(),Ns=Math.floor(pt.pos.x/K),Gs=Math.floor(pt.pos.y/K),$r=Math.ceil((pt.pos.x+pt.width)/K),_r=Math.ceil((pt.pos.y+pt.height)/K),Br=new Set;for(let Ve=Ns;Ve<=$r;Ve++)for(let rt=Gs;rt<=_r;rt++)if(!L[Ve])L[Ve]={},L[Ve][rt]=[Se];else if(!L[Ve][rt])L[Ve][rt]=[Se];else{let Vt=L[Ve][rt];e:for(let He of Vt){if(He.paused||!He.exists()||Br.has(He.id))continue;for(let st of Se.collisionIgnore)if(He.is(st))continue e;for(let st of He.collisionIgnore)if(Se.is(st))continue e;let Cr=ha(Se.worldArea(),He.worldArea());if(Cr){let st=new Gt(Se,He,Cr.normal,Cr.distance);Se.trigger("collideUpdate",He,st);let Pr=st.reverse();Pr.resolved=st.resolved,He.trigger("collideUpdate",Se,Pr)}Br.add(He.id)}Vt.push(Se)}}te.children.forEach(ye),Q=oe.pop()}a(ye,"checkObj"),ye(y.root)}a(Mr,"checkFrame");function qr(L){console.error(L),M.ctx.suspend();let K=L.message??String(L)??"Unknown error, check console for more info";u.run(()=>{},()=>{R(),ot(()=>{let Q=ve(),oe=Ee(),ye={size:36,width:Q-32*2,letterSpacing:4,lineSpacing:4,font:ls,fixed:true};Te({width:Q,height:oe,color:re(0,0,255),fixed:true});let te=Mt({...ye,text:"Error",pos:E(32),color:re(255,128,0),fixed:true});qt(te),tn({...ye,text:K,pos:E(32,32+te.height+16),fixed:true}),Be(),y.events.trigger("error",L)}),T()})}a(qr,"handleErr");function Wr(L){f.push(L)}a(Wr,"onCleanup");function Zr(){y.events.onOnce("frameEnd",()=>{u.quit(),h.clear(h.COLOR_BUFFER_BIT|h.DEPTH_BUFFER_BIT|h.STENCIL_BUFFER_BIT);let L=h.getParameter(h.MAX_TEXTURE_IMAGE_UNITS);for(let K=0;KK())})}a(Zr,"quit");let jt=true;u.run(()=>{try{p.loaded&&(v.paused||tt(),Mr())}catch(L){qr(L)}},(L,K)=>{try{L(),p.loaded||Et()===1&&!jt&&(p.loaded=true,qn().forEach(Q=>y.events.trigger("loadError",...Q)),y.events.trigger("load")),!p.loaded&&t.loadingScreen!==false||jt?(R(),wo(),T()):(v.paused||ft(),Mr(),R(),yo(),t.debug!==false&&mo(),T()),jt&&(jt=false),y.events.trigger("frameEnd"),K()}catch(Q){qr(Q)}}),Hn(),ti();let Qe={_k:c,VERSION:ah,loadRoot:Qa,loadProgress:Et,loadSprite:Zt,loadSpriteAtlas:Tn,loadSound:oo,loadMusic:lo,loadBitmapFont:to,loadFont:_a,loadShader:no,loadShaderURL:io,loadAseprite:$a,loadPedit:ro,loadBean:Ja,loadJSON:Wa,load:cs,getSound:Dn,getFont:Rn,getBitmapFont:kn,getSprite:Bn,getShader:In,getAsset:Za,Asset:je,SpriteData:St,SoundData:Lr,width:ve,height:Ee,center:Ur,dt:xe,fixedDt:hs,restDt:ds,time:u.time,screenshot:u.screenshot,record:F,isFocused:U,setCursor:u.setCursor,getCursor:u.getCursor,setCursorLocked:u.setCursorLocked,isCursorLocked:u.isCursorLocked,setFullscreen:u.setFullscreen,isFullscreen:u.isFullscreen,isTouchscreen:u.isTouchscreen,onLoad:Os,onLoadError:jo,onLoading:Ho,onResize:No,onGamepadConnect:u.onGamepadConnect,onGamepadDisconnect:u.onGamepadDisconnect,onError:Go,onCleanup:Wr,flash:Zn,setCamPos:Kn,getCamPos:Yn,setCamRot:Qn,getCamRot:Wn,setCamScale:zn,getCamScale:Xn,getCamTransform:Vo,camPos:zo,camScale:Xo,camFlash:Wo,camRot:Qo,camTransform:Ko,shake:Yo,toScreen:ms,toWorld:Jn,setGravity:Zo,getGravity:Jo,setGravityDirection:$o,getGravityDirection:Jt,setBackground:Ga,getBackground:ja,getGamepads:u.getGamepads,getTreeRoot:al,add:H,make:Us,destroy:si,destroyAll:J,get:V,query:ee,readd:j,pos:Nr,scale:Gr,rotate:Ul,color:Nn,opacity:Gn,anchor:As,area:Sl,sprite:ys,text:dl,polygon:Co,rect:Vn,circle:bo,uvquad:cl,outline:qo,particles:Bo,body:Ml,platformEffector:kl,surfaceEffector:Bl,areaEffector:Cl,pointEffector:Pl,buoyancyEffector:Il,constantForce:Rl,doubleJump:ql,shader:Po,textInput:bl,timer:ws,fixed:li,stay:oi,health:wl,lifespan:Al,named:xl,state:vl,z:Ll,layer:Tl,move:Fl,offscreen:Ol,follow:Dl,fadeIn:So,mask:Mo,drawon:Eo,raycast:jn,tile:ni,animate:yl,serializeAnimation:ai,agent:fl,sentry:ml,patrol:gl,pathfinder:pl,trigger:Vu,on:Re,onFixedUpdate:Ku,onUpdate:Yu,onDraw:zu,onAdd:ko,onDestroy:Xu,onTag:Io,onUntag:Zu,onUse:Qu,onUnuse:Wu,onClick:Ju,onCollide:Do,onCollideUpdate:To,onCollideEnd:Fo,onHover:Oo,onHoverUpdate:Uo,onHoverEnd:Lo,onKeyDown:u.onKeyDown,onKeyPress:u.onKeyPress,onKeyPressRepeat:u.onKeyPressRepeat,onKeyRelease:u.onKeyRelease,onMouseDown:u.onMouseDown,onMousePress:u.onMousePress,onMouseRelease:u.onMouseRelease,onMouseMove:u.onMouseMove,onCharInput:u.onCharInput,onTouchStart:u.onTouchStart,onTouchMove:u.onTouchMove,onTouchEnd:u.onTouchEnd,onScroll:u.onScroll,onHide:u.onHide,onShow:u.onShow,onGamepadButtonDown:u.onGamepadButtonDown,onGamepadButtonPress:u.onGamepadButtonPress,onGamepadButtonRelease:u.onGamepadButtonRelease,onGamepadStick:u.onGamepadStick,onButtonPress:u.onButtonPress,onButtonDown:u.onButtonDown,onButtonRelease:u.onButtonRelease,mousePos:Mn,mouseDeltaPos:u.mouseDeltaPos,isKeyDown:u.isKeyDown,isKeyPressed:u.isKeyPressed,isKeyPressedRepeat:u.isKeyPressedRepeat,isKeyReleased:u.isKeyReleased,isMouseDown:u.isMouseDown,isMousePressed:u.isMousePressed,isMouseReleased:u.isMouseReleased,isMouseMoved:u.isMouseMoved,isGamepadButtonPressed:u.isGamepadButtonPressed,isGamepadButtonDown:u.isGamepadButtonDown,isGamepadButtonReleased:u.isGamepadButtonReleased,getGamepadStick:u.getGamepadStick,isButtonPressed:u.isButtonPressed,isButtonDown:u.isButtonDown,isButtonReleased:u.isButtonReleased,setButton:u.setButton,getButton:u.getButton,pressButton:u.pressButton,releaseButton:u.releaseButton,getLastInputDeviceType:u.getLastInputDeviceType,charInputted:u.charInputted,loop:se,wait:X,play:el,setVolume:_n,getVolume:ei,volume:tl,burp:$n,audioCtx:M.ctx,Line:Le,Rect:he,Circle:Oe,Ellipse:dt,Point:$l,Polygon:Pe,Vec2:B,Color:Z,Mat4:et,Quad:ce,RNG:Ci,rand:Ae,randi:ln,randSeed:Pi,vec2:E,rgb:re,hsl2rgb:Wl,quad:ge,choose:Ii,chooseMultiple:ki,shuffle:un,chance:Ri,lerp:Ce,tween:$,easings:Or,map:ze,mapc:Bi,wave:on,deg2rad:me,rad2deg:bt,clamp:Xe,evaluateQuadratic:Qi,evaluateQuadraticFirstDerivative:Wi,evaluateQuadraticSecondDerivative:Zi,evaluateBezier:Cs,evaluateBezierFirstDerivative:Ji,evaluateBezierSecondDerivative:$i,evaluateCatmullRom:_i,evaluateCatmullRomFirstDerivative:ea,curveLengthApproximation:wn,normalizedCurve:ta,hermite:Sr,cardinal:An,catmullRom:Tr,bezier:ra,kochanekBartels:sa,easingSteps:ua,easingLinear:oa,easingCubicBezier:la,testLineLine:bs,testRectRect:hn,testRectLine:Es,testRectPoint:Vr,testCirclePolygon:Yr,testLinePoint:Ss,testLineCircle:Er,isConvex:ga,triangulate:vn,NavMesh:Fu,drawSprite:xo,drawText:tn,formatText:Mt,drawRect:Te,drawLine:Qt,drawLines:Fs,drawTriangle:Un,drawCircle:Nt,drawEllipse:Fn,drawUVQuad:br,drawPolygon:ut,drawCurve:On,drawBezier:fo,drawFormattedText:qt,drawMasked:Ao,drawSubtracted:vo,pushTransform:Ie,popTransform:Be,pushTranslate:de,pushScale:vr,pushRotate:Ft,pushMatrix:Va,usePostEffect:O,makeCanvas:P,debug:v,scene:ol,getSceneName:hl,go:ll,onSceneLeave:ul,layers:il,getLayers:sl,setLayers:ri,getDefaultLayer:nl,addLevel:Ro,getData:S,setData:k,download:Rs,downloadJSON:Ea,downloadText:En,downloadBlob:Zs,plug:I,ASCII_CHARS:ma,canvas:u.canvas,addKaboom:rl,LEFT:B.LEFT,RIGHT:B.RIGHT,UP:B.UP,DOWN:B.DOWN,RED:Z.RED,GREEN:Z.GREEN,BLUE:Z.BLUE,YELLOW:Z.YELLOW,MAGENTA:Z.MAGENTA,CYAN:Z.CYAN,WHITE:Z.WHITE,BLACK:Z.BLACK,quit:Zr,KEvent:qe,KEventHandler:Fr,KEventController:Ut,cancel:a(()=>wa,"cancel")};c.k=Qe;let Jr=t.plugins;if(Jr&&Jr.forEach(I),t.global!==false)for(let L in Qe)window[L]=Qe[L];return t.focus!==false&&u.canvas.focus(),Qe},"kaplay");var lh=oh;lh({background:[0,0,0,0]});var W=(t=>{t["Attack"]="Attack";t["Cooldown"]="Cooldown";t["Idle"]="Idle";t["Move"]="Move";t["Stunned"]="Stunned";return t})(W||{});var we=(t=>{t["Dead"]="Dead";t["Hit"]="Hit";t["Hurt"]="Hurt";t["Normal"]="Normal";t["Smug"]="Smug";t["Sus"]="Sus";return t})(we||{});var Ls=(t=>{t[t["Foreground"]=1]="Foreground";return t})(Ls||{});var ui=(t=>{t["Background"]="Background";return t})(ui||{});var Fe=(t=>{t["Game"]="Game";t["Lose"]="Lose";t["Preload"]="Preload";t["Title"]="Title";t["Tutorial"]="Tutorial";return t})(Fe||{});var ie=(t=>{t["Explode"]="Explode";t["Hit"]="Hit";t["Pop"]="Pop";t["Shoot"]="Shoot";t["Sneeze"]="Sneeze";t["Splash"]="Splash";t["Whoosh"]="Whoosh";return t})(ie||{});var Y=(t=>{t["Avatar"]="Avatar";t["BadBubble"]="BadBubble";t["Bubbie"]="Bubbie";t["Bubble"]="Bubble";t["Drain"]="Drain";t["Gooba"]="Gooba";t["Kiki"]="Kiki";t["Pokey"]="Pokey";t["Projectile"]="Projectile";t["Shellie"]="Shellie";t["Spiny"]="Spiny";return t})(Y||{});var ae=(t=>{t["BadBubble"]="BadBubble";t["Bubble"]="Bubble";t["ChildBubble"]="ChildBubble";t["Drain"]="Drain";t["Enemy"]="Enemy";t["Player"]="Player";t["Projectile"]="Projectile";return t})(ae||{});let Hl;function uh(){const t=add([sprite(Y.Avatar),pos(125,height()-185),anchor("center"),scale(.5),fixed(),z(Ls.Foreground)]);hh(t);return t}function hh(t){Hl=t}function Nl(){return Hl}function Gl(){return Boolean(randi(2))}function dh(){const t=Ot();if(!t){return vec2()}const e=width()/2;const r=height()/2;const s=Gl()?1:-1;return vec2(t.pos.x+e*s,t.pos.y+r*s)}function ch(){const t=Ot();if(!t){return vec2()}const e=rand(0,width()/2);const r=rand(0,height()/2);const s=Gl()?1:-1;return vec2(t.pos.x+e*s,t.pos.y+r*s)}function hi(t,e){return e.sub(t).unit()}class fh{constructor(){this.enemyDamageMultiplier=1;this.enemyHealthMultiplier=1;this.enemySpeedMultiplier=1;this.enemySprites=[]}init(){this.enemyDamageMultiplier=1;this.enemyHealthMultiplier=1;this.enemySpeedMultiplier=1;this.enemySprites=[]}}const at=new fh;const Ge=60;const ph=[{start:0,end:.5*Ge,loop:{enemy:4,drain:10},enemies:[Y.Shellie,Y.Spiny],multiplier:{damage:1,health:1,speed:1}},{start:.5*Ge,end:2*Ge,loop:{enemy:3,drain:10},enemies:[Y.Gooba],multiplier:{damage:1,health:1,speed:1}},{start:1*Ge,end:2*Ge,loop:{enemy:3,drain:10},enemies:[Y.Gooba,Y.Shellie,Y.Spiny],multiplier:{damage:1,health:1,speed:1}},{start:2*Ge,end:3*Ge,loop:{enemy:3,drain:15},enemies:[Y.Bubbie],multiplier:{damage:1,health:1,speed:1}},{start:3*Ge,end:4*Ge,loop:{enemy:3,drain:15},enemies:[Y.Pokey],multiplier:{damage:1.5,health:1.5,speed:1.5}},{start:4*Ge,end:5*Ge,loop:{enemy:3,drain:20},enemies:[Y.Gooba,Y.Bubbie,Y.Pokey],multiplier:{damage:1.5,health:1.5,speed:1.5}},{start:5*Ge,end:void 0,loop:{enemy:1,drain:30},enemies:[Y.Bubbie,Y.Gooba,Y.Shellie,Y.Spiny,Y.Pokey],multiplier:{damage:2,health:2,speed:2}}];class gh{constructor(e=1){this.createdAt=time();this.delay=e}setUpdatedAt(e=time()){this.updatedAt=e}passedDelay(){if(this.updatedAt){return time()-this.updatedAt-this.delay>0}else{return true}}}const mh=200;function yh(t){play(ie.Shoot,{detune:rand(-100,100)});const e=add([sprite(Y.BadBubble),pos(t.pos),move(hi(t.screenPos(),Ot().screenPos()),mh),area({scale:.7}),offscreen({destroy:true}),anchor("center"),scale(.1),ae.BadBubble,{damage:5}]);e.onCollide(ae.Player,r=>{play(ie.Pop,{detune:rand(-100,100)});e.destroy();vs(e.damage);const s=r;s.bubble+=1;const n=Hs(s);if(n){n.scaleBy(1.1)}else{s.add([sprite(Y.BadBubble),anchor("center"),scale(.18),ae.ChildBubble])}});e.onCollide(ae.BadBubble,r=>{let s;if(e.scale.x>=r.scale.x){s=e;r.destroy()}else{s=r;e.destroy()}if(s.scale.x>.2){s.destroy()}else{s.scaleBy(1.1);s.damage*=1.5}});e.onCollide(ae.Projectile,()=>{play(ie.Pop,{detune:rand(-100,100)});e.destroy()});e.onCollide(ae.Bubble,r=>{play(ie.Pop,{detune:rand(-100,100)});e.destroy();r.destroy()});return e}const wh=200;function Ah(t){const e=add([sprite(Y.Bubble),pos(t.pos),move(hi(t.screenPos(),mousePos()),wh),area({scale:.7}),offscreen({destroy:true}),anchor("center"),scale(.1),ae.Bubble,{damage:20}]);e.onCollide(ae.Enemy,r=>{play(ie.Pop,{detune:rand(-100,100)});e.destroy();const s=r;s.hurt(e.damage);s.bubble+=1;const n=Hs(s);if(n){n.scaleBy(1.1)}else{s.add([sprite(Y.Bubble),anchor("center"),scale(.18),ae.ChildBubble])}});e.onCollide(ae.Bubble,r=>{let s;if(e.scale.x>=r.scale.x){s=e;r.destroy()}else{s=r;e.destroy()}if(s.scale.x>.2){s.destroy()}else{s.scaleBy(1.1);s.damage*=1.5}});e.onCollide(ae.Projectile,()=>{play(ie.Pop,{detune:rand(-100,100)});e.destroy()});return e}function Hs(t){return t.get(ae.ChildBubble)[0]}function xs(t){const e=add([rect(t.width,t.height,{radius:t.radius}),pos(t.x,t.y),area(),scale(1),anchor("center"),outline(4),color(255,255,255)]);if(t.fixed){e.use(fixed())}e.add([text(t.text),anchor("center"),color(0,0,0)]);e.onHover(()=>{e.scaleTo(1.1)});e.onHoverEnd(()=>{e.scaleTo(1)});e.onClick(t.onClick);return e}function xh(){const t=add([sprite(Y.Drain),pos(ch()),area({scale:.7}),body({isStatic:true}),anchor("center"),scale(.7),lifespan(rand(5,15),{fade:.5}),opacity(1),ae.Drain]);t.onCollide(ae.Enemy,e=>{const r=e;if(r.bubble){r.hurt(9999)}});return t}function vh(t){const e=new gh;onClick(()=>{if(e.passedDelay()){play(ie.Hit,{detune:rand(-100,100)});Ah(t);e.setUpdatedAt()}})}function bh(t){onKeyDown(e=>{const r=t.speed-t.bubble*20;switch(e){case"left":case"a":t.move(-r,0);break;case"right":case"d":t.move(r,0);break;case"up":case"w":t.move(0,-r);break;case"down":case"s":t.move(0,r);break}})}function Eh(t){t.onStateEnter(W.Idle,()=>{t.play(W.Idle);wait(rand(.3,1),()=>t.enterState(W.Move))});t.onStateEnter(W.Move,()=>{t.play(W.Move)});t.onStateEnter(W.Attack,()=>{const e=Ot();if(!(e==null?void 0:e.exists())){return}t.play(W.Attack);switch(t.sprite){case Y.Bubbie:yh(t);break;case Y.Pokey:Dh(t);break}wait(.2,()=>t.enterState(W.Cooldown))});t.onStateEnter(W.Cooldown,()=>{t.play(W.Cooldown);wait(rand(1,3),()=>t.enterState(W.Move))});t.onStateEnter(W.Stunned,()=>{t.play(W.Stunned);wait(rand(.3,1),()=>t.enterState(W.Move))});t.onStateUpdate(W.Move,()=>{const e=Ot();if(!(e==null?void 0:e.exists())){return}if([Y.Bubbie,Y.Pokey].includes(t.sprite)&&Number(rand())<.005){return t.enterState(W.Attack)}const r=e.pos.sub(t.pos).unit();t.move(r.scale(t.speed-t.bubble*20))})}let an;function Sh(){const t=add([rect(70,70),pos(50,50),anchor("center"),color(255,255,255),fixed(),z(Ls.Foreground)]);const e=t.add([text("0",{size:48}),anchor("center"),color(0,0,0)]);Mh(e);return e}function Mh(t){an=t}function qh(t=1){an.text=String(parseInt(an.text,10)+t)}function Bh(){const t=randi(1,10);const e=randi(20,100)*at.enemyHealthMultiplier;const r=randi(100,300)*at.enemySpeedMultiplier;const{enemySprites:s}=at;const n=add([sprite(s[randi(s.length)]),pos(dh()),anchor("center"),health(e,e),area({scale:.7}),body(),scale(.75),state(W.Move),ae.Enemy,{bubble:0,damage:t,speed:r}]);if(n.sprite===Y.Gooba){play(ie.Splash)}Eh(n);n.onCollide(ae.Player,()=>{var i;if(n.bubble){(i=Hs(n))==null?void 0:i.destroy();n.bubble=0;return}n.enterState(W.Attack);vs(n.damage)});n.onCollideUpdate(ae.Player,()=>{if(n.bubble){return}vs(n.damage/1e3)});n.onHurt(()=>{n.enterState(W.Stunned)});n.onDeath(()=>{n.enterState(W.Stunned);qh();play(ie.Explode,{volume:.2});n.destroy();addKaboom(n.pos)});return n}const Ys=300;const Si=30;function Ch(t){const e=add([rect(Ys,Si),pos(30,height()-60),color(0,0,0),fixed(),z(Ls.Foreground)]);const r=e.add([rect(Ys,Si),pos(0,0),color(255,0,0)]);function s(){r.width=t.hp()/t.maxHP()*Ys}t.onHurt(s);t.onHeal(s);return r}let $t;function jl(){if($t){return $t.play()}const t=play(ui.Background,{loop:true,paused:true});t.volume=.5;Ph(t);jl()}function Ph(t){$t=t}function Rh(){$t==null?void 0:$t.stop()}const Mi=100;function Vl(t=center().x,e=center().y){const r=add([sprite(Y.Kiki),pos(t,e),anchor("center"),area({scale:.7}),body(),scale(.75),health(Mi,Mi),ae.Player,{bubble:0,speed:320}]);bh(r);vh(r);r.onUpdate(()=>{setCamPos(r.worldPos());r.flipX=!(mousePos().x>r.screenPos().x)});r.onCollide(ae.Enemy,qi(r));r.onCollide(ae.Projectile,qi(r));r.onDeath(()=>{Nl().play(we.Hurt);const s=add([sprite(Y.Kiki),pos(r.pos),anchor("center"),scale(.75),lifespan(1,{fade:1}),opacity(1)]);s.play(we.Dead);r.destroy();wait(3,()=>{Rh();play(ie.Whoosh);go(Fe.Lose)})});return r}function Ot(){return get(ae.Player)[0]}function vs(t){var e;(e=Ot())==null?void 0:e.hurt(t*at.enemyDamageMultiplier)}function qi(t){return()=>{var r;play(ie.Hit,{detune:rand(-100,100)});if(t.bubble){(r=Hs(t))==null?void 0:r.destroy();t.bubble=0}const e=Nl();if(t.hp(){if(t.exists()){t.play(we.Normal);e.play(we.Normal)}})}}const kh=500;const Ih=5;function Dh(t){play(ie.Sneeze,{detune:rand(-100,100)});const e=hi(t.screenPos(),Ot().screenPos());const r=add([sprite(Y.Projectile),pos(t.pos),move(e,kh),area(),offscreen({destroy:true}),anchor("center"),scale(.2),rotate(e.angle()),ae.Projectile]);r.onCollide(ae.Player,()=>{play(ie.Pop,{detune:rand(-100,100)});r.destroy();vs(Ih)});r.onCollide(ae.Enemy,s=>{play(ie.Pop,{detune:rand(-100,100)});s.removeAll(ae.ChildBubble);s.bubble=false});return r}function jr(t){const e=add([rect(t.width,t.height),pos(t.x,t.y),anchor("center"),color(255,255,255)]);return e.add([text(t.text,{size:t.fontSize}),anchor("center"),color(0,0,0)])}scene(Fe.Game,()=>{at.init();jr({width:600,height:100,x:center().x,y:80,text:"WASD or arrow keys to move\nLeft click to shoot"});Sh();jl();const t=Vl();Ch(t);uh();ph.forEach(e=>{wait(e.start,()=>{at.enemyDamageMultiplier=e.multiplier.damage;at.enemyHealthMultiplier=e.multiplier.health;at.enemySpeedMultiplier=e.multiplier.speed;at.enemySprites=e.enemies;const r=e.end&&e.end-e.start;loop(e.loop.enemy,Bh,r&&r/e.loop.enemy,true);loop(e.loop.enemy,xh,r&&r/e.loop.drain,true)})})});scene(Fe.Lose,()=>{const{x:t,y:e}=center();const r=100;jr({width:400,height:100,x:t,y:e-r,text:"Game Over",fontSize:48});xs({width:220,height:80,radius:8,x:t,y:e+r,text:"Restart",onClick(){play(ie.Hit);go(Fe.Game)}})});scene(Fe.Preload,()=>{const t=[[Y.Bubbie,"sprites/bubbie.png"],[Y.Shellie,"sprites/shellie.png"],[Y.Spiny,"sprites/spiny.png"]];t.forEach(([n,i])=>{loadSprite(n,i,{sliceX:4,anims:{[W.Idle]:0,[W.Move]:0,[W.Attack]:1,[W.Cooldown]:2,[W.Stunned]:3}})});loadSprite(Y.Pokey,"sprites/pokey.png",{sliceX:5,anims:{[W.Idle]:3,[W.Move]:0,[W.Attack]:{from:1,to:2},[W.Cooldown]:0,[W.Stunned]:4}});loadSprite(Y.Gooba,"sprites/gooba.png",{sliceX:6,anims:{[W.Idle]:0,[W.Move]:5,[W.Attack]:{from:1,to:2},[W.Cooldown]:3,[W.Stunned]:4}});const e=[[Y.BadBubble,"sprites/badbubble.png"],[Y.Bubble,"sprites/bubble.png"],[Y.Drain,"sprites/drain.png"],[Y.Projectile,"sprites/projectile.png"]];e.forEach(([n,i])=>{loadSprite(n,i)});loadSprite(Y.Kiki,"sprites/kiki.png",{sliceX:6,anims:{[we.Normal]:0,[we.Smug]:1,[we.Sus]:2,[we.Hit]:3,[we.Hurt]:4,[we.Dead]:5}});loadSprite(Y.Avatar,"sprites/avatar.png",{sliceX:3,anims:{[we.Normal]:0,[we.Hit]:1,[we.Hurt]:2}});const r=[[ie.Explode,"sounds/explode.mp3"],[ie.Hit,"sounds/hit.mp3"],[ie.Pop,"sounds/pop.mp3"],[ie.Shoot,"sounds/shoot.mp3"],[ie.Sneeze,"sounds/sneeze.mp3"],[ie.Splash,"sounds/splash.mp3"],[ie.Whoosh,"sounds/whoosh.mp3"]];r.forEach(([n,i])=>{loadSound(n,i)});const s=[[ui.Background,"music/background.mp3"]];s.forEach(([n,i])=>{loadMusic(n,i)});go(Fe.Title)});scene(Fe.Title,()=>{const{x:t,y:e}=center();const r=80;jr({width:400,height:100,x:t,y:e-r*2,text:"Bubble Gun",fontSize:48});xs({width:220,height:r,radius:8,x:t,y:e+r,text:"Play",onClick(){play(ie.Hit);go(Fe.Game)}});xs({width:220,height:r,radius:8,x:t,y:e+r*2+20,text:"Tutorial",onClick(){play(ie.Hit);go(Fe.Tutorial)}})});scene(Fe.Tutorial,()=>{const{x:t}=center();xs({width:220,height:80,radius:8,x:t,y:height()-80,text:"Play",onClick(){play(ie.Hit);go(Fe.Game)},fixed:true});jr({width:600,height:60,x:t,y:80,text:"WASD or arrow keys to move"});jr({width:600,height:60,x:t,y:160,text:"Left click to shoot"});Vl()});function Th(){go(Fe.Preload)}Th(); diff --git a/backgrounds/tile.png b/backgrounds/tile.png new file mode 100644 index 0000000..f575705 Binary files /dev/null and b/backgrounds/tile.png differ diff --git a/images/cover.png b/images/cover.png new file mode 100644 index 0000000..d666656 Binary files /dev/null and b/images/cover.png differ diff --git a/images/screenshot1.png b/images/screenshot1.png new file mode 100644 index 0000000..7b469b0 Binary files /dev/null and b/images/screenshot1.png differ diff --git a/images/screenshot2.png b/images/screenshot2.png new file mode 100644 index 0000000..a873aa5 Binary files /dev/null and b/images/screenshot2.png differ diff --git a/images/screenshot3.png b/images/screenshot3.png new file mode 100644 index 0000000..a8aa690 Binary files /dev/null and b/images/screenshot3.png differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..0ca08bf --- /dev/null +++ b/index.html @@ -0,0 +1,7 @@ +Bubble Gun | remarkablegames \ No newline at end of file diff --git a/logo.png b/logo.png new file mode 100644 index 0000000..975b79f Binary files /dev/null and b/logo.png differ diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..6ba9395 --- /dev/null +++ b/manifest.json @@ -0,0 +1,15 @@ +{ + "short_name": "Bubble Gun", + "name": "Bubble Gun", + "icons": [ + { + "src": "logo.png", + "type": "image/png", + "sizes": "72x72" + } + ], + "start_url": ".", + "display": "standalone", + "theme_color": "#000000", + "background_color": "#ffffff" +} diff --git a/music/background.mp3 b/music/background.mp3 new file mode 100644 index 0000000..95c170e Binary files /dev/null and b/music/background.mp3 differ diff --git a/sounds/explode.mp3 b/sounds/explode.mp3 new file mode 100644 index 0000000..e0d8d6a Binary files /dev/null and b/sounds/explode.mp3 differ diff --git a/sounds/hit.mp3 b/sounds/hit.mp3 new file mode 100644 index 0000000..5c882d9 Binary files /dev/null and b/sounds/hit.mp3 differ diff --git a/sounds/pop.mp3 b/sounds/pop.mp3 new file mode 100644 index 0000000..399f4a6 Binary files /dev/null and b/sounds/pop.mp3 differ diff --git a/sounds/shoot.mp3 b/sounds/shoot.mp3 new file mode 100644 index 0000000..e068db0 Binary files /dev/null and b/sounds/shoot.mp3 differ diff --git a/sounds/sneeze.mp3 b/sounds/sneeze.mp3 new file mode 100644 index 0000000..60388e8 Binary files /dev/null and b/sounds/sneeze.mp3 differ diff --git a/sounds/splash.mp3 b/sounds/splash.mp3 new file mode 100644 index 0000000..64d729f Binary files /dev/null and b/sounds/splash.mp3 differ diff --git a/sounds/whoosh.mp3 b/sounds/whoosh.mp3 new file mode 100644 index 0000000..e3b4c1e Binary files /dev/null and b/sounds/whoosh.mp3 differ diff --git a/sprites/avatar.png b/sprites/avatar.png new file mode 100644 index 0000000..c9dba79 Binary files /dev/null and b/sprites/avatar.png differ diff --git a/sprites/badbubble.png b/sprites/badbubble.png new file mode 100644 index 0000000..b29d7f8 Binary files /dev/null and b/sprites/badbubble.png differ diff --git a/sprites/bouba.png b/sprites/bouba.png new file mode 100644 index 0000000..626cd24 Binary files /dev/null and b/sprites/bouba.png differ diff --git a/sprites/bubbie.png b/sprites/bubbie.png new file mode 100644 index 0000000..6e0fb8a Binary files /dev/null and b/sprites/bubbie.png differ diff --git a/sprites/bubble.png b/sprites/bubble.png new file mode 100644 index 0000000..bdb4962 Binary files /dev/null and b/sprites/bubble.png differ diff --git a/sprites/drain.png b/sprites/drain.png new file mode 100644 index 0000000..a0c7437 Binary files /dev/null and b/sprites/drain.png differ diff --git a/sprites/gooba.png b/sprites/gooba.png new file mode 100644 index 0000000..8182b3e Binary files /dev/null and b/sprites/gooba.png differ diff --git a/sprites/kiki.png b/sprites/kiki.png new file mode 100644 index 0000000..2438c33 Binary files /dev/null and b/sprites/kiki.png differ diff --git a/sprites/pokey.png b/sprites/pokey.png new file mode 100644 index 0000000..5ccb8b2 Binary files /dev/null and b/sprites/pokey.png differ diff --git a/sprites/projectile.png b/sprites/projectile.png new file mode 100644 index 0000000..5835475 Binary files /dev/null and b/sprites/projectile.png differ diff --git a/sprites/shellie.png b/sprites/shellie.png new file mode 100644 index 0000000..78736e3 Binary files /dev/null and b/sprites/shellie.png differ diff --git a/sprites/spiny.png b/sprites/spiny.png new file mode 100644 index 0000000..356c852 Binary files /dev/null and b/sprites/spiny.png differ