Mid-Simulator/node_modules/kaboom/dist/kaboom.js

60 lines
162 KiB
JavaScript
Raw Normal View History

2022-04-18 01:14:39 +00:00
var kaboom=(()=>{var Ve=Object.defineProperty,zi=Object.defineProperties,Ji=Object.getOwnPropertyDescriptor,Qi=Object.getOwnPropertyDescriptors,Zi=Object.getOwnPropertyNames,ir=Object.getOwnPropertySymbols;var sr=Object.prototype.hasOwnProperty,es=Object.prototype.propertyIsEnumerable;var jt=(i,t,l)=>t in i?Ve(i,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):i[t]=l,P=(i,t)=>{for(var l in t||(t={}))sr.call(t,l)&&jt(i,l,t[l]);if(ir)for(var l of ir(t))es.call(t,l)&&jt(i,l,t[l]);return i},D=(i,t)=>zi(i,Qi(t)),ts=i=>Ve(i,"__esModule",{value:!0}),a=(i,t)=>Ve(i,"name",{value:t,configurable:!0});var ns=(i,t)=>{for(var l in t)Ve(i,l,{get:t[l],enumerable:!0})},rs=(i,t,l,w)=>{if(t&&typeof t=="object"||typeof t=="function")for(let U of Zi(t))!sr.call(i,U)&&(l||U!=="default")&&Ve(i,U,{get:()=>t[U],enumerable:!(w=Ji(t,U))||w.enumerable});return i};var is=(i=>(t,l)=>i&&i.get(t)||(l=rs(ts({}),t,1),i&&i.set(t,l),l))(typeof WeakMap!="undefined"?new WeakMap:0);var b=(i,t,l)=>(jt(i,typeof t!="symbol"?t+"":t,l),l);var or=(i,t,l)=>new Promise((w,U)=>{var p=q=>{try{A(l.next(q))}catch(V){U(V)}},S=q=>{try{A(l.throw(q))}catch(V){U(V)}},A=q=>q.done?w(q.value):Promise.resolve(q.value).then(p,S);A((l=l.apply(i,t)).next())});var ar=(()=>{for(var i=new Uint8Array(128),t=0;t<64;t++)i[t<26?t+65:t<52?t+71:t<62?t-4:t*4-205]=t;return l=>{for(var w=l.length,U=new Uint8Array((w-(l[w-1]=="=")-(l[w-2]=="="))*3/4|0),p=0,S=0;p<w;){var A=i[l.charCodeAt(p++)],q=i[l.charCodeAt(p++)],V=i[l.charCodeAt(p++)],j=i[l.charCodeAt(p++)];U[S++]=A<<2|q>>4,U[S++]=q<<4|V>>2,U[S++]=V<<6|j}return U}})();var qs={};ns(qs,{default:()=>Ls});var $=class extends Map{constructor(...t){super(...t);b(this,"_lastID");this._lastID=0}push(t){let l=this._lastID;return this.set(l,t),this._lastID++,l}pushd(t){let l=this.push(t);return()=>this.delete(l)}};a($,"IDList");function Yt(i,t){let l=typeof i,w=typeof t;if(l!==w)return!1;if(l==="object"&&w==="object"){let U=Object.keys(i),p=Object.keys(t);if(U.length!==p.length)return!1;for(let S of U){let A=i[S],q=t[S];if(!(typeof A=="function"&&typeof q=="function")&&!Yt(A,q))return!1}return!0}return i===t}a(Yt,"deepEq");function $t(i,t){let l=document.createElement("a");document.body.appendChild(l),l.setAttribute("style","display: none"),l.href=i,l.download=t,l.click(),document.body.removeChild(l)}a($t,"downloadURL");function cr(i,t){let l=URL.createObjectURL(i);$t(l,t),URL.revokeObjectURL(l)}a(cr,"downloadBlob");function lr(i){return i.match(/^data:\w+\/\w+;base64,.+/)}a(lr,"isDataURL");var hr=(()=>{let i=0;return()=>i++})(),ur=new Set;function B(i,t){ur.has(i)||(ur.add(i),console.warn(`${i} is deprecated. Use ${t} instead.`))}a(B,"deprecateMsg");var T=a((i,t,l)=>(...w)=>(B(i,t),l(...w)),"deprecate");function he(i){return i*Math.PI/180}a(he,"deg2rad");function Kt(i){return i*180/Math.PI}a(Kt,"rad2deg");function z(i,t,l){return t>l?z(i,l,t):Math.min(Math.max(i,t),l)}a(z,"clamp");function Fe(i,t,l){return i+(t-i)*l}a(Fe,"lerp");function ft(i,t,l,w,U){return w+(i-t)/(l-t)*(U-w)}a(ft,"map");function fr(i,t,l,w,U){return z(ft(i,t,l,w,U),w,U)}a(fr,"mapc");var N=class{constructor(t=0,l=t){b(this,"x",0);b(this,"y",0);this.x=t,this.y=l}static fromAngle(t){let l=he(t);return new N(Math.cos(l),Math.sin(l))}clone(){return new N(this.x,this.y)}add(...t){let l=f(...t);return new N(this.x+l.x,this.y+l.y)}sub(...t){let l=f(...t);return new N(this.x-l.x,this.y-l.y)}scale(...t){let l=f(...t);return new N(this.x*l.x,this.y*l.y)}dist(...t){let l=f(...t);return Math.sqrt((this.x-l.x)*(this.x-l.x)+(this.y-l.y)*(this.y-l.y))}len(){return this.dist(new N(0,0))}unit(){return this.scale(1/this.len())}normal(){return new N(this.y,-this.x)}dot(t){return this.x*t.x+this.y*t.y}angle(...t){let l=f(...t);return Kt(Math.atan2(this.y-l.y,this.x-l.x))}lerp(t,l){return new N(Fe(this.x,t.x,l),Fe(this.y,t.y,l))}toFixed(t){return new N(Number(this.x.toFixed(t)),Number(this.y.toFixed(t)))}eq(t){return this.x===t.x&&this.y===t.y}toString(){return`(${this.x.toFixed(2)}, ${this.y.toFixed(2)})`}str(){return this.toString()}},L=N;a(L,"Vec2"),b(L,"LEFT",new N(-1,0)),b(L,"RIGHT",new N(1,
attribute vec3 a_pos;
attribute vec2 a_uv;
attribute vec4 a_color;
varying vec3 v_pos;
varying vec2 v_uv;
varying vec4 v_color;
vec4 def_vert() {
return vec4(a_pos, 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;
}
`,Ts=`
precision mediump float;
varying vec3 v_pos;
varying vec2 v_uv;
varying vec4 v_color;
uniform sampler2D u_tex;
vec4 def_frag() {
return v_color * texture2D(u_tex, v_uv);
}
{{user}}
void main() {
gl_FragColor = frag(v_pos, v_uv, v_color, u_tex);
if (gl_FragColor.a == 0.0) {
discard;
}
}
`,on=`
vec4 vert(vec3 pos, vec2 uv, vec4 color) {
return def_vert();
}
`,an=`
vec4 frag(vec3 pos, vec2 uv, vec4 color, sampler2D tex) {
return def_frag();
}
`,Ss=new Set(["id","require"]),Cs=new Set(["add","load","update","draw","destroy","inspect"]);function Gr(i){return i==="pressed"||i==="rpressed"?"down":i==="released"?"up":i}a(Gr,"processButtonState");function Rs(i){i.requestFullscreen?i.requestFullscreen():i.webkitRequestFullscreen&&i.webkitRequestFullscreen()}a(Rs,"enterFullscreen");function Ws(){document.exitFullscreen?document.exitFullscreen():document.webkitExitFullScreen&&document.webkitExitFullScreen()}a(Ws,"exitFullscreen");function Ms(){return document.fullscreenElement||document.webkitFullscreenElement}a(Ms,"getFullscreenElement");function $e(i){switch(i){case"topleft":return f(-1,-1);case"top":return f(0,-1);case"topright":return f(1,-1);case"left":return f(-1,0);case"center":return f(0,0);case"right":return f(1,0);case"botleft":return f(-1,1);case"bot":return f(0,1);case"botright":return f(1,1);default:return i}}a($e,"originPt");function _r(){return new AudioBuffer({length:1,numberOfChannels:1,sampleRate:44100})}a(_r,"createEmptyAudioBuffer");var Ls=a((i={})=>{let t=(()=>{var s,o,d;let e=(s=i.root)!=null?s: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 n=(o=i.canvas)!=null?o:(()=>{let h=document.createElement("canvas");return e.appendChild(h),h})(),r=(d=i.scale)!=null?d:1;i.width&&i.height&&!i.stretch&&!i.letterbox?(n.width=i.width*r,n.height=i.height*r):(n.width=n.parentElement.offsetWidth,n.height=n.parentElement.offsetHeight);let u=["outline: none","cursor: default"];i.crisp&&(u.push("image-rendering: pixelated"),u.push("image-rendering: crisp-edges")),n.style=u.join(";"),n.setAttribute("tabindex","0");let c=n.getContext("webgl",{antialias:!0,depth:!0,stencil:!0,alpha:!0,preserveDrawingBuffer:!0});return{canvas:n,scale:r,gl:c,keyStates:{},mouseStates:{},charInputted:[],isMouseMoved:!1,isKeyPressed:!1,isKeyPressedRepeat:!1,isKeyReleased:!1,mousePos:f(0,0),mouseDeltaPos:f(0,0),time:0,realTime:0,skipTime:!1,dt:0,numFrames:0,isTouch:"ontouchstart"in window||navigator.maxTouchPoints>0,loopID:null,stopped:!1,paused:!1,fpsCounter:new Ne,loaded:!1}})(),l=(()=>{var d;let e=t.gl,n=ln(on,an),r=He(new ImageData(new Uint8ClampedArray([255,255,255,255]),1,1)),u=(d=i.background)!=null?d:E(0,0,0);if(i.background){let h=v.fromArray(i.background);e.clearColor(h.r/255,h.g/255,h.b/255,1)}e.enable(e.BLEND),e.enable(e.SCISSOR_TEST),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);let c=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,c),e.vertexAttribPointer(0,3,e.FLOAT,!1,Ye*4,0),e.enableVertexAttribArray(0),e.vertexAttribPointer(1,2,e.FLOAT,!1,Ye*4,12),e.enableVertexAttribArray(1),e.vertexAttribPointer(2,4,e.FLOAT,!1,Ye*4,20),e.enableVertexAttribArray(2),e.bufferData(e.ARRAY_BUFFER,xt*4,e.DYNAMIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,null);let s=e.createBuffer();e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,s),e.bufferData(e.ELEMENT_ARRAY_BUFFER,xt*2,e.DYNAMIC_DRAW),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null);let o=He(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{drawCalls:0,lastDrawCalls:0,defShader:n,curShader:n,defTex:r,curTex:r,curUniform:{},vbuf:c,ibuf:s,vqueue:[],iqueue:[],transform:new R,transformStack:[],bgTex:o,width:i.width,height:i.height,viewport:{x:0,y:0,width:e.drawingBufferWidth,height:e.drawingBufferHeight}}})();yn();let w=(()=>{let e=new(window.AudioContext||window.webkitAudioContext),n=e.createGain();n.connect(e.destination);let r={buf:_r()};return e.decodeAudioData(Lr.buffer.slice(0),u=>{r.buf=u},()=>{throw new Error("Failed to load burp.")}),{ctx:e,masterNode:n,burpSnd:r}})(),U={numLoading:0,numLoaded:0,urlPrefix:"",sprites:{},sounds:{},shaders:{},fonts:{}},p={events:{},objEvents:{},root:Tn([]),timers:new $,layers:{},defLayer:null,gravity:Fr,on(e,n){return this.events[e]||(this.events[e]=new $),this.events[e].pushd(n)},trigger(e,...n){this.events[e]&&this.events
`)throw new Error(u);return{bind(){r.useProgram(h)},unbind(){r.useProgram(null)},send(m){this.bind();for(let g in m){let y=m[g],x=r.getUniformLocation(h,g);typeof y=="number"?r.uniform1f(x,y):y instanceof R?r.uniformMatrix4fv(x,!1,new Float32Array(y.m)):y instanceof v?r.uniform4f(x,y.r,y.g,y.b,y.a):y instanceof ke?r.uniform3f(x,y.x,y.y,y.z):y instanceof L&&r.uniform2f(x,y.x,y.y)}this.unbind()}}}a(ln,"makeShader");function jr(e,n,r,u){let c=e.width/n,s=e.height/r,o=1/c,d=1/s,h={},m=u.split("").entries();for(let[g,y]of m)h[y]=f(g%c*o,Math.floor(g/c)*d);return{tex:e,map:h,qw:o,qh:d}}a(jr,"makeFont");function St(e,n,r,u=l.defTex,c=l.defShader,s={}){u=u!=null?u:l.defTex,c=c!=null?c:l.defShader,(u!==l.curTex||c!==l.curShader||!Yt(l.curUniform,s)||l.vqueue.length+e.length*Ye>xt||l.iqueue.length+n.length>xt)&&hn();for(let o of e){let d=r?l.transform:p.cam.transform.mult(l.transform),h=Yr(d.multVec2(o.pos.xy()));l.vqueue.push(h.x,h.y,o.pos.z,o.uv.x,o.uv.y,o.color.r/255,o.color.g/255,o.color.b/255,o.opacity)}for(let o of n)l.iqueue.push(o+l.vqueue.length/Ye-e.length);l.curTex=u,l.curShader=c,l.curUniform=s}a(St,"drawRaw");function hn(){if(!l.curTex||!l.curShader||l.vqueue.length===0||l.iqueue.length===0)return;let e=t.gl;l.curShader.send(l.curUniform),e.bindBuffer(e.ARRAY_BUFFER,l.vbuf),e.bufferSubData(e.ARRAY_BUFFER,0,new Float32Array(l.vqueue)),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,l.ibuf),e.bufferSubData(e.ELEMENT_ARRAY_BUFFER,0,new Uint16Array(l.iqueue)),l.curShader.bind(),l.curTex.bind(),e.drawElements(e.TRIANGLES,l.iqueue.length,e.UNSIGNED_SHORT,0),l.curTex.unbind(),l.curShader.unbind(),e.bindBuffer(e.ARRAY_BUFFER,null),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),l.iqueue=[],l.vqueue=[],l.drawCalls++}a(hn,"flush");function ze(){t.gl.clear(t.gl.COLOR_BUFFER_BIT),i.background||pe({width:F(),height:G(),quad:new k(0,0,F()*t.scale/kr,G()*t.scale/kr),tex:l.bgTex,fixed:!0}),l.drawCalls=0,l.transformStack=[],l.transform=new R}a(ze,"frameStart");function Je(){hn(),l.lastDrawCalls=l.drawCalls}a(Je,"frameEnd");function Ps(){return l.lastDrawCalls}a(Ps,"drawCalls");function Yr(e){return f(e.x/F()*2-1,-e.y/G()*2+1)}a(Yr,"screen2ndc");function Ds(e){return f((e.x+1)/2*F(),-(e.y-1)/2*G())}a(Ds,"ndc2screen");function As(e){l.transform=e.clone()}a(As,"applyMatrix");function I(...e){if(e[0]===void 0)return;let n=f(...e);n.x===0&&n.y===0||(l.transform=l.transform.translate(n))}a(I,"pushTranslate");function ne(...e){if(e[0]===void 0)return;let n=f(...e);n.x===1&&n.y===1||(l.transform=l.transform.scale(n))}a(ne,"pushScale");function Os(e){!e||(l.transform=l.transform.rotateX(e))}a(Os,"pushRotateX");function Is(e){!e||(l.transform=l.transform.rotateY(e))}a(Is,"pushRotateY");function Qe(e){!e||(l.transform=l.transform.rotateZ(e))}a(Qe,"pushRotateZ");function re(){l.transformStack.push(l.transform.clone())}a(re,"pushTransform");function ie(){l.transformStack.length>0&&(l.transform=l.transformStack.pop())}a(ie,"popTransform");function pe(e){var h;if(e.width===void 0||e.height===void 0)throw new Error('drawUVQuad() requires property "width" and "height".');if(e.width<=0||e.height<=0)return;let n=e.width,r=e.height,c=$e(e.origin||je).scale(f(n,r).scale(-.5)),s=e.quad||new k(0,0,1,1),o=e.color||E(255,255,255),d=(h=e.opacity)!=null?h:1;re(),I(e.pos),Qe(e.angle),ne(e.scale),I(c),St([{pos:de(-n/2,r/2,0),uv:f(e.flipX?s.x+s.w:s.x,e.flipY?s.y:s.y+s.h),color:o,opacity:d},{pos:de(-n/2,-r/2,0),uv:f(e.flipX?s.x+s.w:s.x,e.flipY?s.y+s.h:s.y),color:o,opacity:d},{pos:de(n/2,-r/2,0),uv:f(e.flipX?s.x:s.x+s.w,e.flipY?s.y+s.h:s.y),color:o,opacity:d},{pos:de(n/2,r/2,0),uv:f(e.flipX?s.x:s.x+s.w,e.flipY?s.y:s.y+s.h),color:o,opacity:d}],[0,1,3,1,2,3],e.fixed,e.tex,e.shader,e.uniform),ie()}a(pe,"drawUVQuad");function $r(e){var s;if(!e.tex)throw new Error('drawTexture() requires property "tex".');let n=(s=e.quad)!=null?s:new k(0,0,1,1),r=e.tex.width*n.w,u=e.tex.height*n.h,c=f(1);if(e.tiled){let o=Math.ceil((e.width||r)/r),d=Math.ceil((e.height||u)/u),m=$e(e.origin||je).add(f(1,1)).scale(.5).scale(o*r,d*u);for(let g=0;g<o;g++)for(let y=0;y<d;y++)pe(D(P({},e),{pos:(e.pos||f(0)).ad
`?(x+=g,y=0,ee=null,M.push(oe),O.push(M),M=[]):(e.width?y+m>e.width:!1)&&(x+=g,y=0,ee!=null&&(te-=M.length-ee,oe=c[te],M=M.slice(0,ee)),ee=null,O.push(M),M=[]),oe!==`
`&&(M.push(oe),y+=m,oe===" "&&(ee=M.length)),W=Math.max(W,y),te++}O.push(M),e.width&&(W=e.width);let Ae=[],Oe=f(e.pos||0),_=$e(e.origin||je).scale(.5),se=-_.x*m-(_.x+.5)*(W-m),Ie=-_.y*g-(_.y+.5)*(x-g),ct=0;return O.forEach((oe,Ni)=>{let ji=(W-oe.length*m)*(_.x+.5);oe.forEach((lt,Yi)=>{var nr;let _t=n.map[lt],$i=Yi*m,Xi=Ni*g;if(_t){let Bt={tex:n.tex,quad:new k(_t.x,_t.y,n.qw,n.qh),ch:lt,pos:f(Oe.x+$i+se+ji,Oe.y+Xi+Ie),opacity:e.opacity,color:(nr=e.color)!=null?nr:E(255,255,255),scale:h,angle:0,uniform:e.uniform,fixed:e.fixed};if(e.transform){let ht=typeof e.transform=="function"?e.transform(ct,lt):e.transform;ht&&wn(Bt,ht)}if(r[ct]){let{styles:ht,localIdx:Ki}=r[ct];for(let Hi of ht){let Nt=e.styles[Hi],rr=typeof Nt=="function"?Nt(Ki,lt):Nt;rr&&wn(Bt,rr)}}Ae.push(Bt)}ct+=1})}),{width:W,height:x,chars:Ae}}a(me,"formatText");function Kr(e){we(me(e))}a(Kr,"drawText");function we(e){for(let n of e.chars)pe({tex:n.tex,width:n.tex.width*n.quad.w,height:n.tex.height*n.quad.h,pos:n.pos,scale:n.scale,angle:n.angle,color:n.color,opacity:n.opacity,quad:n.quad,origin:"center",uniform:n.uniform,fixed:n.fixed})}a(we,"drawFormattedText");function yn(){let e=t.gl,n=e.drawingBufferWidth,r=e.drawingBufferHeight,u=F(),c=G();if(En()){let s=window.innerWidth,o=window.innerHeight,d=s/o,h=n/r;if(d>h){let m=window.innerHeight*h;l.viewport={x:(s-m)/2,y:0,width:m,height:o}}else{let m=window.innerWidth/h;l.viewport={x:0,y:(o-m)/2,width:s,height:m}}return}if(i.letterbox){if(!i.width||!i.height)throw new Error("Letterboxing requires width and height defined.");let s=n/r,o=i.width/i.height;if(s>o){i.stretch||(l.width=r*o,l.height=r);let d=r*o,h=r,m=(n-d)/2;e.scissor(m,0,d,h),e.viewport(m,0,d,r),l.viewport={x:m,y:0,width:d,height:r}}else{i.stretch||(l.width=n,l.height=n/o);let d=n,h=n/o,m=(r-h)/2;e.scissor(0,m,d,h),e.viewport(0,m,n,h),l.viewport={x:0,y:m,width:n,height:h}}return}if(i.stretch){if(!i.width||!i.height)throw new Error("Stretching requires width and height defined.");e.viewport(0,0,n,r),l.viewport={x:0,y:0,width:n,height:r};return}l.width=n/t.scale,l.height=r/t.scale,e.viewport(0,0,n,r),l.viewport={x:0,y:0,width:n,height:r}}a(yn,"updateViewport");function F(){return l.width}a(F,"width");function G(){return l.height}a(G,"height"),t.canvas.addEventListener("mousemove",e=>{t.mousePos=f((e.offsetX-l.viewport.x)*F()/l.viewport.width,(e.offsetY-l.viewport.y)*G()/l.viewport.height),t.mouseDeltaPos=f(e.movementX,e.movementY).scale(1/t.scale),t.isMouseMoved=!0}),t.canvas.addEventListener("mousedown",e=>{let n=Ar[e.button];n&&(t.mouseStates[n]="pressed")}),t.canvas.addEventListener("mouseup",e=>{let n=Ar[e.button];n&&(t.mouseStates[n]="released")}),t.canvas.addEventListener("keydown",e=>{let n=Dr[e.key]||e.key.toLowerCase();ws.includes(n)&&e.preventDefault(),n.length===1&&t.charInputted.push(e.key),n==="space"&&t.charInputted.push(" "),e.repeat?(t.isKeyPressedRepeat=!0,t.keyStates[n]="rpressed"):(t.isKeyPressed=!0,t.keyStates[n]="pressed")}),t.canvas.addEventListener("keyup",e=>{let n=Dr[e.key]||e.key.toLowerCase();t.keyStates[n]="released",t.isKeyReleased=!0}),t.canvas.addEventListener("touchstart",e=>{if(!i.touchToMouse)return;e.preventDefault();let n=e.touches[0];t.mousePos=f(n.clientX,n.clientY).scale(1/t.scale),t.mouseStates.left="pressed"}),t.canvas.addEventListener("touchmove",e=>{if(!i.touchToMouse)return;e.preventDefault();let n=e.touches[0];t.mousePos=f(n.clientX,n.clientY).scale(1/t.scale),t.isMouseMoved=!0}),t.canvas.addEventListener("touchend",e=>{!i.touchToMouse||(t.mouseStates.left="released")}),t.canvas.addEventListener("touchcancel",e=>{!i.touchToMouse||(t.mouseStates.left="released")}),t.canvas.addEventListener("touchstart",e=>{[...e.changedTouches].forEach(n=>{p.trigger("onTouchStart",n.identifier,f(n.clientX,n.clientY).scale(1/t.scale))})}),t.canvas.addEventListener("touchmove",e=>{[...e.changedTouches].forEach(n=>{p.trigger("onTouchMove",n.identifier,f(n.clientX,n.clientY).scale(1/t.scale))})}),t.canvas.addEventListener("touchend",e=>{[...e.changedTouches].forEach(n=>{p.trigger("onTouchEnd",n.identifier,f(n.clientX,n.clientY).sca
`))}zn(f(8/t.scale),`FPS: ${C.fps()}`)}if(C.paused){re(),I(F(),0),ne(1/t.scale),I(-8,8);let r=32;Q({width:r,height:r,origin:"topright",color:E(0,0,0),opacity:.8,radius:4,fixed:!0});for(let u=1;u<=2;u++)Q({width:4,height:r*.6,origin:"center",pos:f(-r/3*u,r*.5),color:E(255,255,255),radius:2,fixed:!0});ie()}if(C.timeScale!==1){re(),I(F(),G()),ne(1/t.scale),I(-8,-8);let r=8,u=me({text:C.timeScale.toFixed(1),font:U.fonts[sn],size:16,color:E(255,255,255),pos:f(-r),origin:"botright",fixed:!0});Q({width:u.width+r*2+r*4,height:u.height+r*2,origin:"botright",color:E(0,0,0),opacity:.8,radius:4,fixed:!0});for(let c=0;c<2;c++){let s=C.timeScale<1;pn({p1:f(-u.width-r*(s?2:3.5),-r),p2:f(-u.width-r*(s?2:3.5),-r-u.height),p3:f(-u.width-r*(s?3.5:2),-r-u.height/2),pos:f(-c*r*1+(s?-r*.5:0),0),color:E(255,255,255),fixed:!0})}we(u),ie()}if(C.curRecording&&(re(),I(0,G()),ne(1/t.scale),I(24,-24),Rt({radius:12,color:E(255,0,0),opacity:Ht(0,1,rt()*4),fixed:!0}),ie()),C.showLog&&p.logs.length>0){re(),I(0,G()),ne(1/t.scale),I(8,-8);let r=8,u=(n=i.logMax)!=null?n:1;p.logs.length>u&&(p.logs=p.logs.slice(0,u));let c=me({text:p.logs.join(`
`),font:U.fonts[sn],pos:f(r,-r),origin:"botleft",size:16,width:F()*t.scale*.6,lineSpacing:r/2,fixed:!0,styles:{time:{color:E(127,127,127)},info:{color:E(255,255,255)},error:{color:E(255,0,127)}}});Q({width:c.width+r*2,height:c.height+r*2,origin:"botleft",color:E(0,0,0),radius:4,opacity:.8,fixed:!0}),we(c),ie()}}a(Jn,"drawDebug"),i.debug!==!1&&Vn(),i.burp&&Fn(),window.addEventListener("error",e=>{C.error(`Error: ${e.error.message}`),Jr(),Qn(()=>{A()===1&&(ze(),Jn(),Je())})});function Qn(e){let n=a(r=>{if(document.visibilityState!=="visible"){t.loopID=requestAnimationFrame(n);return}let u=r/1e3,c=u-t.realTime;t.realTime=u,t.skipTime||(t.dt=c,t.time+=t.dt,t.fpsCounter.tick(t.dt)),t.skipTime=!1,t.numFrames++,e();for(let s in t.keyStates)t.keyStates[s]=Gr(t.keyStates[s]);for(let s in t.mouseStates)t.mouseStates[s]=Gr(t.mouseStates[s]);t.charInputted=[],t.isMouseMoved=!1,t.isKeyPressed=!1,t.isKeyPressedRepeat=!1,t.isKeyReleased=!1,t.loopID=requestAnimationFrame(n)},"frame");t.stopped=!1,t.loopID=requestAnimationFrame(n)}a(Qn,"run"),Qn(()=>{yn(),t.loaded?(p.trigger("input"),C.paused||Hn(),ze(),_i(),i.debug!==!1&&Jn(),Je()):(ze(),Bi(),Je())}),X("apl386",Sr,45,74),X("apl386o",Cr,45,74),X("sink",Rr,6,8,{chars:"\u2588\u263A\u263B\u2665\u2666\u2663\u2660\u25CF\u25CB\u25AA\u25A1\u25A0\u25D8\u266A\u266B\u2261\u25BA\u25C4\u2302\xDE\xC0\xDF\xD7\xA5\u2191\u2193\u2192\u2190\u25CC\u25CF\u25BC\u25B2 !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u03A7\u2591\u2592\u2593\u1E00\u1E01\u1E02\u2502\u252C\u2524\u250C\u2510\u1E03\u1E04\u253C\u1E05\u1E06\u1E07\u1E08\u1E09\u1E0A\u1E0B\u1E0C\u2500\u251C\u2534\u2514\u2518\u1E0D\u1E0E\u205E\u1E0F\u1E10\u1E11\u1E12\u1E13\u1E14\u1E15\u1E16\u1E17\u1E18\u2584\u1E19\u1E1A\u1E1B\u1E1C\u2026\u1E1D\u1E1E\u1E1F\u1E20\u1E21\u1E22\u1E23\u1E24\u1E25\u1E26\u258C\u2590\u1E27\u1E28\u1E29\u1E2A\u1E2B\u1E2C\u1E2D\u1E2E\u1E2F\u1E30\u1E31\u1E32\u1E33\u1E34\u1E35\u1E36\u1E37\u1E38\u1E39\u1E3A\u1E3B\u1E3C\u1E3D\u1E3E\u1E3F\u1E40\u1E41\u1E42\u1E43\u1E44\u1E45\u1E46\u1E47\u1E48\u1E49\u1E4A\u1E4B\u1E4C\u1E4D\u1E4E\u1E4F\u1E50\u1E51\u1E52\u1E53\u1E54\u1E55\u1E56\u1E57\u1E58\u1E59\u1E5A\u1E5B\u1E5C\u1E5D\u1E5E\u1E5F\u1E60\u1E61\u1E62\u1E63\u1E64\u1E65\u1E66\u1E67\u1E68\u1E69\u1E6A\u1E6B\u1E6C\u1E6D\u1E6E\u1E6F\u1E70\u1E71\u1E72\u1E73\u1E74\u1E75\u1E76\u1E77\u1E78\u1E79\u1E7A\u1E7B\u1E7C"}),X("sinko",Wr,8,10),ze(),Je();let ye={loadRoot:q,loadSprite:J,loadSpriteAtlas:Ee,loadSound:Ce,loadFont:X,loadShader:Se,loadAseprite:Tt,loadPedit:Xe,loadBean:Br,load:S,width:F,height:G,center:at,dt:Z,time:rt,screenshot:xn,record:jn,isFocused:Yn,focus:Ai,cursor:vn,regCursor:si,fullscreen:zr,isFullscreen:En,onLoad:Ue,isTouch:()=>t.isTouch,layers:Zr,camPos:ei,camScale:ti,camRot:ni,shake:ri,toScreen:it,toWorld:qt,gravity:kn,add:Gt,readd:Oi,destroy:ut,destroyAll:Ii,get:Vi,every:Fi,revery:ki,pos:st,scale:ot,rotate:oi,color:ai,opacity:ui,origin:It,layer:ci,area:pi,sprite:Ft,text:mi,rect:wi,circle:Ui,uvquad:gi,outline:yi,body:vi,shader:Ei,timer:_n,solid:Ti,fixed:Si,stay:kt,health:Ci,lifespan:Ri,z:li,move:di,outview:Vt,cleanup:fi,follow:hi,state:Wi,on:qe,onUpdate:Pe,onDraw:Sn,onCollide:Cn,onClick:Rn,onHover:Wn,onKeyDown:Pt,onKeyPress:H,onKeyPressRepeat:Dt,onKeyRelease:At,onMouseDown:Ln,onMousePress:Ot,onMouseRelease:qn,onMouseMove:Pn,onCharInput:Dn,onTouchStart:An,onTouchMove:On,onTouchEnd:In,mousePos:K,mouseWorldPos:Qr,mouseDeltaPos:bn,isKeyDown:Lt,isKeyPressed:Le,isKeyPressedRepeat:Mt,isKeyReleased:nt,isMouseDown:et,isMousePressed:Me,isMouseReleased:tt,isMouseMoved:Wt,loop:ii,wait:Mn,play:Ke,volume:Nr,burp:cn,audioCtx:w.ctx,Timer:fe,Line:le,Rect:Ge,Circle:dt,Vec2:L,Color:v,Mat4:R,Quad:k,RNG:be,rng:wr,rand:_e,randi:zt,randSeed:gr,vec2:f,rgb:E,hsl2rgb:pr,quad:mr,choose:yr,chance:Ur,lerp:Fe,map:ft,mapc:fr,wave:Ht,deg2rad:he,rad2deg:Kt,testAreaRect:Ut,testAreaLine:en,testAreaCircle:tn,testAreaPolygon:nn,testAreaPoint:yt,testAreaArea:rn,testLineLine:ce,testRectRect:Jt,testRectLine:pt,testRectPoint:ae,testPolygonPoint:xe,testLinePolygon:Be,testPolygonPolygon:gt,testCircleCircle:Zt,testCirclePoint:wt,testRect
window.kaboom = kaboom.default;
//# sourceMappingURL=kaboom.js.map