@kayelaa/canvas 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -19,21 +19,24 @@ Made by **Kayelaa Cagara** (@LianeKayee39 on X / GitHub) in Calamba, Philippines
19
19
 
20
20
  ```ts
21
21
  // main.ts
22
- import { Kayla } from '@kayelaa/canvas';
23
- const {
24
- createGame,
25
- createScene,
26
- createRenderer,
27
- useSelf,
28
- useTick,
29
- usePaint,
22
+ /** @jsxImportSource @kayelaa/canvas */
23
+ import {
24
+ createGame,
25
+ createScene,
26
+ createRenderer,
27
+ useSelf,
28
+ useTick,
29
+ usePaint,
30
30
  useEntity,
31
31
  FC,
32
32
  FCProps,
33
- Vector2
34
33
  useEffect,
35
34
  useRef,
36
- } = Kayla;
35
+ Kayla,
36
+ FCExports,
37
+ useExports,
38
+ } from "@kayelaa/canvas/kayla";
39
+ import { Vector2 } from "@kayelaa/canvas/lea";
37
40
 
38
41
  // Define typed props (optional but recommended)
39
42
  interface PlayerProps extends FCProps {
@@ -42,22 +45,25 @@ interface PlayerProps extends FCProps {
42
45
  }
43
46
 
44
47
  // Optional: expose methods to parent
45
- interface PlayerExports {
48
+ interface PlayerExports extends FCExports {
46
49
  jump(): void;
47
50
  getHealth(): number;
48
51
  }
49
52
 
50
53
  // Typed component
51
- const Player: FC<PlayerProps, PlayerExports> = ({ initialX = 0, initialY = 0 }) => {
54
+ const Player: FC<PlayerProps, PlayerExports> = ({
55
+ initialX = 0,
56
+ initialY = 0,
57
+ }) => {
52
58
  const entity = useEntity();
53
59
  const mounted = useRef(false);
54
60
 
55
61
  useEffect(() => {
56
62
  if (mounted.current === true) return;
57
63
  mounted.current = true;
58
- entity.x = initialX;
59
- entity.y = initialY;
60
- })
64
+ entity.current.x = initialX;
65
+ entity.current.y = initialY;
66
+ });
61
67
 
62
68
  const self = useSelf(() => ({
63
69
  speed: 300,
@@ -65,38 +71,38 @@ const Player: FC<PlayerProps, PlayerExports> = ({ initialX = 0, initialY = 0 })
65
71
 
66
72
  tick(delta: number) {
67
73
  const mouse = renderer.getMousePos();
68
- const dx = mouse.x - entity.x;
69
- const dy = mouse.y - entity.y;
74
+ const dx = mouse.x - entity.current.x;
75
+ const dy = mouse.y - entity.current.y;
70
76
  const dist = Math.hypot(dx, dy);
71
77
  if (dist > 5) {
72
- entity.x += (dx / dist) * this.speed * delta;
73
- entity.y += (dy / dist) * this.speed * delta;
78
+ entity.current.x += (dx / dist) * this.speed * delta;
79
+ entity.current.y += (dy / dist) * this.speed * delta;
74
80
  }
75
81
  },
76
82
 
77
83
  jump() {
78
- entity.y -= 100; // simple jump example
79
- }
84
+ entity.current.y -= 100; // simple jump example
85
+ },
80
86
  }));
81
87
 
82
88
  useTick((delta) => self.tick(delta));
83
89
 
84
90
  usePaint((ctx) => {
85
91
  ctx.fillStyle = self.health > 50 ? "#00aaff" : "#ff4444";
86
- ctx.fillRect(entity.x - 20, entity.y - 20, 40, 40);
92
+ ctx.fillRect(entity.current.x - 20, entity.current.y - 20, 40, 40);
87
93
  });
88
94
 
89
95
  // Expose public API to parent (optional)
90
96
  useExports(Player, () => ({
91
97
  jump: self.jump,
92
- getHealth: () => self.health
98
+ getHealth: () => self.health,
93
99
  }));
94
100
 
95
- return null;
101
+ return [];
96
102
  };
97
103
 
98
104
  // Setup (run once)
99
- const canvas = document.getElementById('game') as HTMLCanvasElement;
105
+ const canvas = document.getElementById("game") as HTMLCanvasElement;
100
106
  const renderer = createRenderer(canvas);
101
107
  renderer.listenPointerUpdates();
102
108
 
package/dist/index.d.cts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { L as LEA } from './lea-DvxsutSf.cjs';
2
- import { K as Kayla } from './kayla-SPtfCppr.cjs';
2
+ import { K as Kayla } from './kayla-eZdx9UI6.cjs';
3
+ import './kayla-internals-DvV9K1wf.cjs';
3
4
 
4
5
  declare const _default: {
5
6
  LEA: typeof LEA;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { L as LEA } from './lea-DvxsutSf.js';
2
- import { K as Kayla } from './kayla-CiWP5no4.js';
2
+ import { K as Kayla } from './kayla-DmdtbuQf.js';
3
+ import './kayla-internals-ClSuOWZb.js';
3
4
 
4
5
  declare const _default: {
5
6
  LEA: typeof LEA;
@@ -0,0 +1 @@
1
+ "use strict";var G=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var ee=Object.prototype.hasOwnProperty;var $=(n,e)=>{for(var t in e)G(n,t,{get:e[t],enumerable:!0})},te=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Z(e))!ee.call(n,i)&&i!==t&&G(n,i,{get:()=>e[i],enumerable:!(r=J(e,i))||r.enumerable});return n};var ne=n=>te(G({},"__esModule",{value:!0}),n);var ve={};$(ve,{Fragment:()=>ge,jsx:()=>be,jsxDEV:()=>xe,jsxs:()=>Q});module.exports=ne(ve);var B={};$(B,{KaylaFragment:()=>q,KaylaInternals:()=>T,createElement:()=>L,createGame:()=>ue,createRenderer:()=>ce,createScene:()=>le,self:()=>P,useDisposableRef:()=>me,useEffect:()=>X,useEntity:()=>de,useExports:()=>pe,useNextStack:()=>Y,usePaint:()=>U,useRef:()=>k,useSelf:()=>fe,useState:()=>H,useTick:()=>he});var w=class{#e=new Map;constructor(){this.#e=new Map}on(e,t){let r=this.#e.get(e)||[];return r.push(t),this.#e.set(e,r),this}once(e,t){let r=(...i)=>{this.off(e,r),t(...i)};return this.on(e,r),this}off(e,t){let r=this.#e.get(e);if(!r)return this;let i=r.indexOf(t);return i>=0&&r.splice(i,1),this}emit(e,...t){let r=this.#e.get(e);if(!r||r.length===0){if(e==="error")throw t[0];return!1}return r.slice().forEach(i=>i(...t)),!0}removeAllListeners(e){return e?this.#e.delete(e):this.#e.clear(),this}listenerCount(e){return this.#e.get(e)?.length??0}},F=class extends w{canvas;ctx;running;_rafId;_fps;_frameCount;_fpsTimer;_lastFrameTime;constructor(e,{viewportWidth:t,viewportHeight:r,cameraWidth:i,cameraHeight:o}={}){if(!v)throw new Error("Web-Only");super(),this.canvas=e,this.ctx=e.getContext("2d"),this.automatic=!0,this.#e=t??e.width,this.#t=r??e.height,this.#n=i??e.width,this.#r=o??e.height,this.running=!1,this._rafId=null,this._loop=this._loop.bind(this),this.updateCanvasResolution(),this._fps=60,this._frameCount=0,this._fpsTimer=0}automatic;retransform(){this.ctx.setTransform(1,0,0,1,0,0);let e=this.#n/this.#e,t=this.#r/this.#t;this.ctx.translate(this.#n/2,this.#r/2),this.ctx.scale(e,t),this.ctx.translate(-this.#e/2,-this.#t/2)}#e=0;#t=0;#n=0;#r=0;get viewportWidth(){return this.#e}set viewportWidth(e){this.#e=e,this.retransform()}get width(){return this.#e}get height(){return this.#t}get centerX(){return this.#e/2}get centerY(){return this.#t/2}get left(){return 0}get top(){return 0}get right(){return this.#e}get bottom(){return this.#t}get viewportHeight(){return this.#t}set viewportHeight(e){this.#t=e,this.retransform()}get cameraWidth(){return this.#n}set cameraWidth(e){this.#n=e,this.updateCanvasResolution(),this.retransform()}get cameraHeight(){return this.#r}set cameraHeight(e){this.#r=e,this.updateCanvasResolution(),this.retransform()}updateCanvasResolution(){this.canvas.width=this.#n,this.canvas.height=this.#r}applyTransform(){this.retransform()}get FPS(){return this._fps}_loop(){this.automatic&&this.update(),this._rafId=requestAnimationFrame(this._loop)}update(){if(!this.running||!v)return;let e=performance.now(),t=(e-(this._lastFrameTime??e))/1e3;this._lastFrameTime=e,this._frameCount++,this._fpsTimer+=t,this._fpsTimer>=1&&(this._fps=Math.round(this._frameCount/this._fpsTimer),this._frameCount=0,this._fpsTimer=0),this.ctx.clearRect(0,0,this.#n,this.#r),this.emit("draw",this.ctx)}start(){if(!this.running){if(!v||typeof globalThis.requestAnimationFrame>"u")throw new Error("Raf is not supported");this.running=!0,this._rafId=requestAnimationFrame(this._loop)}}stop(){if(!v||typeof globalThis.requestAnimationFrame>"u")throw new Error("Raf is not supported");this.running=!1,this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null)}},N=class extends w{setNow(e){this.#e=e}#e=0;__intervalId=null;__lastTime=0;constructor(e=16){super(),this.#t=e,this.speedHackDT=1}speedHackDT;get isRaf(){return this.tickInterval===1/0}#t=15;get tickInterval(){return this.#t}set tickInterval(e){this.#t=e,this.__intervalId&&(this.stop(),this.start())}now(){return this.#e}__tick(){let e=performance.now(),t=(e-this.__lastTime)/1e3*this.speedHackDT;this.__lastTime=e,this.#e+=t*1e3,this.emit("tick",t)}createTimeout(e){return new O(e,this)}createTween(e,t=()=>{}){let r=new z(e),i=(o=0)=>{if(r.finished){this.off("tick",i);return}r.update(o)};return r.on("finish",()=>{this.off("tick",i)}),r.on("delta",o=>{t(o)}),this.on("tick",i),r}start(){this.__intervalId===null&&(this.__lastTime=performance.now(),this.__intervalId=v&&!isFinite(this.tickInterval)?ae(()=>this.__tick()).clear:setInterval(()=>this.__tick(),this.tickInterval))}stop(){this.__intervalId!==null&&(typeof this.__intervalId=="function"?this.__intervalId():clearInterval(this.__intervalId)),this.__intervalId=null}getSineMod(e,t=0){return .5+.5*Math.sin((this.now()%e/e+t)*2*Math.PI)}},re;(a=>{function n(h){return h===!0?1:0}a.booleanExport=n;function e(h){return h===0?!1:h===1}a.booleanImport=e;function t(h){return`${h.x}|${h.y}`}a.vec2Export=t;function r(h){let[m,b]=h.split("|"),E=parseFloat(m),M=parseFloat(b);if(isNaN(E)||isNaN(M))throw new Error(`Invalid Vector2 string: ${h}`);return new S(E,M)}a.vec2Import=r,a.booleanMap={mapExport:n,mapImport:e};function o(h){return m=>Number(m.toFixed(h))}a.createRounder=o;function p(h=10){return{mapExport(m){return Math.round(m/h)},mapImport(m){return m*h}}}a.createLowPrecision=p;function f(h){return Math.round(h)}a.lightWeightRounder=f;function l(h=100){return{mapExport(m){return Math.round(m*h)},mapImport(m){return m/h}}}a.createPercent=l;function u(h){let m=new Map(Object.entries(h));return{mapExport:b=>m.get(b)??null,mapImport:b=>Array.from(m.entries()).find(([E,M])=>M===b)?.[0]??null}}a.createLookup=u;function d(h){let m=h*(180/Math.PI);return Math.round((m%360+360)%360)}a.radToDeg=d;function y(h){return h*(Math.PI/180)}a.degToRad=y,a.angleRadToDeg={mapExport:d,mapImport:y};function c(h=10){let m=p(h);return{mapExport(b){return m.mapExport(d(b))},mapImport(b){return m.mapImport(y(b))}}}a.createLowPrecisionRadToDeg=c})(re||={});var K=class n extends w{name="";scaleRotate=0;scale=1;constructor(e,t=0,r=0){super(),this.autoTranslate=!1,this.name=e,this.z=0,this.___pos=new S(t,r),this.nonSerializableProperties=[],this.nonSerializableProperties.push("___pos","autoTranslate","arraySerializeMap"),this.forceSerializableProperties=[],this.forceSerializableProperties.push("x","y")}arraySerializeMap;autoTranslate;z;___pos;nonSerializableProperties;forceSerializableProperties;get pos(){return this.___pos}get x(){return this.pos.x}get y(){return this.pos.y}set x(e){this.pos.x=e}set y(e){this.pos.y=e}handleUpdate(e){if(this.update)try{this.emit("update",e),this.update(e)}catch(t){this.emit("error",t)}}handleDraw(e){if(!(D||!this.draw)){e.save(),this.autoTranslate&&e.translate(this.x,this.y);try{this.emit("draw",e),this.draw(e)}catch(t){this.emit("error",t)}e.restore()}}serialize(){if(Array.isArray(this.arraySerializeMap))return this.arraySerializeMap.map(([i,{mapExport:o}])=>{let p=Reflect.get(this,i);return o?o(p):p});let e=["_events","_eventsCount","_maxListeners","nonSerializableProperties","forceSerializableProperties"],t=[...Reflect.ownKeys(this),...this.forceSerializableProperties].filter(i=>!this.nonSerializableProperties.includes(i)&&!e.includes(i.toString())),r=Object.fromEntries(t.map(i=>{let o=Reflect.get(this,i);if(D&&typeof o=="number"){let p=o.toString().split("."),l=(p[1]?p[1].length:0)>2?Number(o.toFixed(2)):o;return[i,l]}return[i,o]}));return JSON.parse(JSON.stringify(r))}toLocal(e){return e.subtract(this.pos)}toWorld(e){return e.add(this.pos)}deserializeArray(e){return n.deserializeArray(this.arraySerializeMap,e)}static deserializeArray(e,t){if(!e||!Array.isArray(t))return t;let r={};for(let i=0;i<t.length;i++){let o=e[i];if(!o)break;let[p,{mapImport:f}]=o,l=t[i];if(f&&(l=f(l)),typeof p!="string")break;try{Reflect.set(r,p,l)}catch(u){console.error(u)}}return r}},_=class extends w{name="";entities=new Map;paused=!0;constructor(e){super(),this.name=e}handleUpdate(e){if(!this.paused){this.emit("update",e);for(let t of this.entities.values())t.handleUpdate(e)}}handleDraw(e){if(!D&&!this.paused){this.emit("draw",e);for(let t of[...this.entities.values()].sort((r,i)=>r.z-i.z))t.handleDraw(e)}}addEntity(e){if(!(e instanceof K))throw new Error("invalid entity");if(!e.name)throw new Error("Entity must have a name.");this.entities.set(e.name,e)}removeEntity(e){if(!(e instanceof K))throw new Error("invalid entity");this.entities.delete(e.name)}getEntity(e){return this.entities.get(e)}},A=class{scenes;ticker;get centerX(){return this.width/2}get centerY(){return this.height/2}get left(){return 0}get top(){return 0}get right(){return this.width}get bottom(){return this.height}width;height;constructor(e,t,r=16){this.ticker=new N(r),this.scenes=new Map,this.width=e,this.height=t,this.ticker.on("tick",i=>{for(let o of this.scenes.values())o.paused||o.handleUpdate(i)})}addScene(e){if(!e.name)throw new Error("Scene must have a name.");e.paused=!1,this.scenes.set(e.name,e)}removeScene(e){e&&(e.paused=!0),this.scenes.delete(e.name)}now(){return this.ticker.now()}start(){this.ticker.start()}stop(){this.ticker.stop()}},g={lerp(n,e,t){return n+(e-n)*t},clamp(n,e,t){return Math.min(t,Math.max(e,n))},clamp01(n){return Math.min(1,Math.max(0,n))},easeLinear(n){return n},easeInQuad(n){return n*n},easeOutQuad(n){return 1-(1-n)*(1-n)},easeInOutQuad(n){return n<.5?2*n*n:1-Math.pow(-2*n+2,2)/2},easeInSine(n){return 1-Math.cos(n*Math.PI/2)},easeOutSine(n){return Math.sin(n*Math.PI/2)},easeInOutSine(n){return-(Math.cos(Math.PI*n)-1)/2},easeInExpo(n){return n===0?0:Math.pow(2,10*n-10)},easeOutExpo(n){return n===1?1:1-Math.pow(2,-10*n)},easeInOutExpo(n){return n===0?0:n===1?1:n<.5?Math.pow(2,20*n-10)/2:(2-Math.pow(2,-20*n+10))/2},smoothstep(n){return n=g.clamp(n,0,1),n*n*(3-2*n)},randomLerp(n,e){return g.lerp(n,e,Math.random())},randomInt(n,e){return Math.floor(Math.random()*(e-n+1))+n},randomArrayValue(n){return n[g.randomInt(0,n.length-1)]},createBezier(n,e,t,r){function i(f,l,u,d,y){let s=1-f;return s*s*s*l+3*s*s*f*u+3*s*f*f*d+f*f*f*y}function o(f,l,u,d,y){let s=1-f;return 3*s*s*(u-l)+6*s*f*(d-u)+3*f*f*(y-d)}function p(f){let l=f;for(let u=0;u<6;u++){let d=i(l,0,n,t,1),y=o(l,0,n,t,1);if(y===0)break;l-=(d-f)/y}return g.clamp(l,0,1)}return function(l){l=g.clamp(l,0,1);let u=p(l);return i(u,0,e,r,1)}},lengthSquared(...n){return n.reduce((e,t)=>e+t*t,0)},normalizeRad(n){let e=2*Math.PI;return n=n%e,n<0&&(n+=e),n},angleInvertY(n){return g.normalizeRad(-n)},degToRadFlipY(n){return g.angleInvertY(n*Math.PI/180)},minimalAngularDirection(n,e){n=g.normalizeRad(n),e=g.normalizeRad(e);let t=g.normalizeRad(e-n),r=g.normalizeRad(n-e);return t<=r?1:-1}},z=class extends w{constructor({delta:e,ms:t,easing:r}){super(),this.delta=e,this.duration=t,this.elapsed=0,this.easing=r??(i=>i),this.lastValue=0,this.finished=!1}delta;duration;elapsed;lastValue;finished;easing;update(e){this.elapsed+=e*1e3;let t=g.clamp(this.elapsed/this.duration,0,1),r=this.easing(t),i=this.delta*r,o=i-this.lastValue;this.lastValue=i,this.emit("delta",o),t>=1&&(this.finished=!0,this.emit("finish",void 0))}},V=class extends K{constructor(e,t=0,r=0,i=50,o=50){super(e,t,r),this.width=i,this.height=o}width;height;get left(){return this.x-this.width/2}set left(e){this.x=e+this.width/2}get right(){return this.x+this.width/2}set right(e){this.x=e-this.width/2}get top(){return this.y-this.height/2}set top(e){this.y=e+this.height/2}get bottom(){return this.y+this.height/2}set bottom(e){this.y=e-this.height/2}get lx(){return 0}get ly(){return 0}get lleft(){return-this.width/2}get lright(){return this.width/2}get ltop(){return-this.height/2}get lbottom(){return this.height/2}isCollidingWith(e){return!(this.right<e.left||this.left>e.right||this.bottom<e.top||this.top>e.bottom)}color="rgba(0, 0, 255, 0.3)";draw(e){e.translate(this.x,this.y),e.rotate(this.scaleRotate),e.fillStyle=this.color,e.fillRect(-this.width/2,-this.height/2,this.width,this.height)}},O=class extends w{duration;ticker;elapsed;finished;_resolve;promise;_timeoutId;constructor(e,t=null){super(),this.duration=e,this.ticker=t,this.elapsed=0,this.finished=!1,this._resolve=null,this.promise=new Promise(r=>this._resolve=r),this.update=this.update.bind(this),this.ticker&&this.ticker.on("tick",this.update)}update(e=0){this.finished||(this.elapsed+=e*1e3,this.elapsed>=this.duration&&this.finish())}finish(){this.finished||(this.finished=!0,this.emit("finish",void 0),this._resolve&&this._resolve(),this.ticker&&this.ticker.off("tick",this.update))}start(){return this.ticker||(this._timeoutId=setTimeout(()=>this.finish(),this.duration)),this}cancel(){this.finished||(this.finished=!0,!this.ticker&&this._timeoutId!=null&&clearTimeout(this._timeoutId),this.ticker&&this.ticker.off("tick",this.update))}then(e,t){return this.promise.then(e,t)}after(e,t){return this.promise.then(e,t)}},S=class n{constructor(e=0,t=0){this.x=e,this.y=t}x;y;toJSON(){return{x:this.x,y:this.y,vec2:!0}}static isVec2(e){return e&&typeof e=="object"&&"x"in e&&"y"in e&&e.vec2===!0}static fromSerialized(e){return this.isVec2(e)?new this(e.x,e.y):null}rotate(e){let t=Math.cos(e),r=Math.sin(e);return new n(this.x*t-this.y*r,this.x*r+this.y*t)}static from(e){return new n(Math.cos(e),Math.sin(e))}get angle(){return Math.atan2(this.y,this.x)}get length(){return Math.hypot(this.x,this.y)}get lengthSquared(){return this.x*this.x+this.y*this.y}normalized(){let e=this.length;return e===0?new n(0,0):new n(this.x/e,this.y/e)}project(e){return e.scale(this.dotNormalized(e))}reflect(e){let t=this.dot(e);return this.subtract(e.scale(2*t))}dotNormalized(e){let t=this.normalized(),r=e.normalized();return t.x*r.x+t.y*r.y}lengthSquaredTo(e){let t=this.x-e.x,r=this.y-e.y;return t*t+r*r}dot(e){return this.x*e.x+this.y*e.y}distanceTo(e){return Math.hypot(this.x-e.x,this.y-e.y)}distanceToCheap(e){let t=this.x-e.x,r=this.y-e.y;return t*t+r*r}directionTo(e){return new n(e.x-this.x,e.y-this.y).normalized()}add(e){return new n(this.x+e.x,this.y+e.y)}addRaw(e){return new n(this.x+e,this.y+e)}overwite(e){this.x=e.x,this.y=e.y}subtract(e){return new n(this.x-e.x,this.y-e.y)}scale(e){return new n(this.x*e,this.y*e)}toString(){return`Vector2(${this.x}, ${this.y})`}clone(){return new n(this.x,this.y)}};function se(){return typeof process<"u"&&process.release?.name==="node"?"node":typeof window<"u"||typeof self<"u"?"web":"unknown"}var W=se(),D=W==="node",v=W==="web",R=class n{static unlock(){v&&this.audioCtx.state!=="running"&&this.audioCtx.resume()}static audioCtx=v?new AudioContext:null;static masterGain=v?this.audioCtx.createGain():null;static musicGain=v?this.audioCtx.createGain():null;static sfxGain=v?this.audioCtx.createGain():null;static{v&&(this.masterGain.gain.value=1,this.musicGain.gain.value=1,this.sfxGain.gain.value=1,this.sfxGain.connect(this.masterGain),this.musicGain.connect(this.masterGain),this.masterGain.connect(this.audioCtx.destination))}static get SFX_VOLUME(){return this.sfxGain.gain.value}static get MUSIC_VOLUME(){return this.musicGain.gain.value}static get VOLUME(){return this.masterGain.gain.value}static set SFX_VOLUME(e){this.sfxGain.gain.value=e}static set MUSIC_VOLUME(e){this.musicGain.gain.value=e}static set VOLUME(e){this.masterGain.gain.value=e}static noteToHz(e){return this.tuningFreq*Math.pow(2,(e-9)/12)}static tuningFreq=440;static audioBufferCache=new Map;static loops=new Map;static sfsx=new Map;static loopIdCounter=0;static CACHE_NAME="lia-audio-cache-v1";static async preLoad(e){if(this.audioBufferCache.has(e))return this.audioBufferCache.get(e);let t=n.CACHE_NAME,r,i;if(typeof caches<"u"&&(i=await caches.open(t),r=await i.match(e)),!r){if(r=await fetch(e),!r.ok)throw new Error(`Failed to fetch ${e}`);i&&await i.put(e,r.clone())}let o=await r.arrayBuffer(),p=await this.audioCtx.decodeAudioData(o);return this.audioBufferCache.set(e,p),p}static async getOnlyDownloadedCache(e){let t=n.CACHE_NAME;return await(await caches.open(t)).match(e)}static getCached(e){return this.audioBufferCache.get(e)||null}static async playSound(e,t=.2,r=1,i=!0){try{this.sfsx.has(e)&&this.sfsx.get(e).source.stop(),this.audioBufferCache.has(e)||await this.preLoad(e);let o=this.getCached(e);if(!o)return;let p=new I(o);p.buffer=o;let f=1-.12,l=1+.12;p.playbackRate=r??f+Math.random()*(l-f);let u=this.audioCtx.createGain();u.gain.value=t,p.tempGain=u,p.connect(u),u.connect(this.sfxGain),p.onended=()=>{p.disconnect(),u.disconnect()},p.start(),i&&this.sfsx.set(e,{source:p,gain:u})}catch(o){console.error(o)}}static async playLoop(e,t=1,{loopStart:r=0,loopEnd:i=null,exclusive:o=!0,skipMS:p=0}={}){if(o)for(let y of this.loops.keys())this.stopLoop(y);this.audioBufferCache.has(e)||await this.preLoad(e);let f=this.getCached(e);if(!f)return;let l=new I(f);l.buffer=f,l.loop=!0,typeof r=="number"&&(l.loopStart=r),typeof i=="number"&&(l.loopEnd=i);let u=this.audioCtx.createGain();u.gain.value=t,l.tempGain=u,l.playbackRate=1,l.onended=()=>{l.disconnect(),u.disconnect()},l.connect(u),u.connect(this.musicGain),l.start(0,p/1e3);let d=++this.loopIdCounter;return this.loops.set(d,{source:l,gain:u}),d}static stopLoop(e){let t=this.loops.get(e);t&&(t.source.stop(),t.source.notIndependent||(t.source.disconnect(),t.gain.disconnect()),this.loops.delete(e))}static async createLiaSource(e,{volume:t=1,speed:r=1,loop:i=!1,loopStart:o=0,loopEnd:p=null,isMusic:f=!1,gain:l=null}={}){try{this.audioBufferCache.has(e)||await this.preLoad(e);let u=this.getCached(e);if(!u)return null;let d=new I(u);d.loop=i,d.loopStart=o,d.loopEnd=typeof p=="number"?p:u.duration,d.playbackRate=r;let y=this.audioCtx.createGain();return y.gain.value=t,d.connect(y),d.tempGain=y,y.connect(l||(f?this.musicGain:this.sfxGain)),d.onended=()=>{d.disconnect(),y.disconnect()},d}catch(u){return console.error("Failed to create LiaAudioSrc:",u),null}}};var I=class{numberOfInputs;numberOfOutputs;constructor(e,t=R.audioCtx){this.context=t,this.buffer=e,this.source=null,this.startTime=0,this.pauseTime=0,this.playbackRate=1,this.isPlaying=!1,this.loop=!1,this.output=v?t.createGain():null,this.output.gain.value=1,this.channelCount=2,this.channelCountMode="max",this.channelInterpretation="speakers",this.numberOfInputs=0,this.numberOfOutputs=1,this.onended=null}channelCount;channelCountMode;channelInterpretation;onended;source;buffer;context;_createSource(){this.source&&(this.source.onended=null);let e=this.context.createBufferSource();return e.buffer=this.buffer,e.playbackRate.value=this.playbackRate,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd>0?this.loopEnd:this.buffer.duration,e.connect(this.output),this.source=e,e.onended=()=>{this.source===e&&(this.isPlaying&&!this.loop&&(this.isPlaying=!1,this.pauseTime=0),typeof this.onended=="function"&&this.onended())},e}play({fadeIn:e=0,offset:t=null}={}){let r=t!==null?t:this.pauseTime;if(this.source){this.source.onended=null;try{this.source.stop()}catch{}}this.source=this._createSource(),this.startTime=this.context.currentTime-r/this.playbackRate,this.source.start(0,r),e>0?(this.output.gain.setValueAtTime(0,this.context.currentTime),this.output.gain.linearRampToValueAtTime(1,this.context.currentTime+e)):this.output.gain.setValueAtTime(1,this.context.currentTime),this.isPlaying=!0}start(e=0,t=0,r){this.isPlaying||(this.source=this._createSource(),this.startTime=this.context.currentTime+e-t/this.playbackRate,r!==void 0?this.source.start(this.context.currentTime+e,t,r):this.source.start(this.context.currentTime+e,t),this.pauseTime=t,this.isPlaying=!0)}pause({fadeOut:e=0}={}){if(!this.isPlaying)return;let t=this.getElapsed()/1e3;if(this.loop&&this.loopEnd>this.loopStart){let r=this.loopEnd-this.loopStart;t=this.loopStart+(t-this.loopStart)%r}if(this.isPlaying=!1,e>0){let r=this.context.currentTime;this.output.gain.setValueAtTime(this.output.gain.value,r),this.output.gain.linearRampToValueAtTime(0,r+e),setTimeout(()=>{if(this.source){this.source.onended=null;try{this.source.stop()}catch{}}this.pauseTime=t,this.output.gain.setValueAtTime(1,this.context.currentTime)},e*1e3)}else{if(this.source){this.source.onended=null;try{this.source.stop()}catch{}}this.pauseTime=t}}getElapsed(){return this.isPlaying?(this.context.currentTime-this.startTime)*this.playbackRate*1e3:this.pauseTime*1e3}setSpeed(e){if(e<=0)throw new Error("Playback rate must be positive");let t=this.getElapsed()/1e3;this.playbackRate=e,this.isPlaying&&(this.pause(),this.pauseTime=t,this.play())}setLoop(e=!0){this.loop=e,this.source&&(this.source.loop=e)}loop;playbackRate;startTime;tempGain=null;connect(e,t=0,r=0){if("value"in e)this.output.connect(e,t);else return this.output.connect(e,t,r),e}disconnect(e,t,r){e===void 0?this.output.disconnect():this.output.disconnect(e,t,r)}output;stop(e=0){if(this.notIndependent)return this.pause();if(!this.source)return;let t=this.context.currentTime+e;this.source.stop(t),this.isPlaying=!1,this.notIndependent||(this.pauseTime=0)}pauseTime;isPlaying;notIndependent=!1;loopStart=0;loopEnd=0},ie={osc:{enabled:!0,type:"sine",freq:440,detune:0},noise:{enabled:!1,level:.5},ampEnv:{attack:.005,decay:.1,sustain:0,release:.1,volume:.3},pitchEnv:{amount:0,decay:.2},filter:{enabled:!1,type:"lowpass",freq:1200,Q:1,envAmount:0,decay:.2},lfo:{enabled:!1,target:"freq",rate:8,depth:20},duration:.4},C=class n{constructor(e={}){this.ctx=R.audioCtx,this.cfg=structuredClone(ie),Object.assign(this.cfg,e)}ctx;cfg;play(e=R.sfxGain){let t=this.ctx,r=t.currentTime,i=this.cfg,o=t.createGain();o.gain.setValueAtTime(1e-4,r);let p=i.ampEnv;o.gain.exponentialRampToValueAtTime(p.volume,r+p.attack),o.gain.exponentialRampToValueAtTime(Math.max(1e-4,p.sustain*p.volume),r+p.attack+p.decay),o.gain.exponentialRampToValueAtTime(1e-4,r+i.duration+p.release);let f=o,l;i.filter.enabled&&(l=t.createBiquadFilter(),l.type=i.filter.type,l.frequency.value=i.filter.freq,l.Q.value=i.filter.Q,l.connect(o),f=l);let u;if(i.osc.enabled){if(u=t.createOscillator(),u.type=i.osc.type,u.frequency.value=i.osc.freq,u.detune.value=i.osc.detune,i.pitchEnv.amount!==0){let h=Math.pow(2,i.pitchEnv.amount/12);u.frequency.exponentialRampToValueAtTime(i.osc.freq*h,r+i.pitchEnv.decay)}u.connect(f),u.start(r),u.stop(r+i.duration+p.release)}let d;if(i.noise.enabled){let h=t.sampleRate*i.duration,m=t.createBuffer(1,h,t.sampleRate),b=m.getChannelData(0);for(let E=0;E<h;E++)b[E]=(Math.random()*2-1)*i.noise.level;d=t.createBufferSource(),d.buffer=m,d.connect(f),d.start(r),d.stop(r+i.duration+p.release)}let y,s;i.lfo.enabled&&u&&(y=t.createOscillator(),y.frequency.value=i.lfo.rate,s=t.createGain(),s.gain.value=i.lfo.depth,y.connect(s),i.lfo.target==="freq"?s.connect(u.frequency):i.lfo.target==="gain"?s.connect(o.gain):i.lfo.target==="filter"&&l&&s.connect(l.frequency),y.start(r),y.stop(r+i.duration)),o.connect(e);let c=[u,d,y,s,l,o],a=r+i.duration+p.release;setTimeout(()=>{c.forEach(h=>h?.disconnect())},(a-t.currentTime)*1e3)}getConfig(){return structuredClone(this.cfg)}setConfig(e){return Object.assign(this.cfg,e),this}getKey(e){return this.cfg[e]}setKey(e,t){return Object.assign(this.cfg[e],t),this}setFreq(e){return this.cfg.osc.freq=e,this}setWave(e){return this.cfg.osc.type=e,this}setVolume(e){return this.cfg.ampEnv.volume=e,this}setAmpEnv(e,t,r,i){return Object.assign(this.cfg.ampEnv,{attack:e,decay:t,sustain:r,release:i}),this}setPitchEnv(e,t){return Object.assign(this.cfg.pitchEnv,{amount:e,decay:t}),this}setNoiseEnabled(e){return this.cfg.noise.enabled=e,this}setNoiseLevel(e){return this.cfg.noise.level=e,this}setFilterEnabled(e){return this.cfg.filter.enabled=e,this}setFilter(e,t,r){return Object.assign(this.cfg.filter,{type:e,freq:t,Q:r,enabled:!0}),this}setLFOEnabled(e){return this.cfg.lfo.enabled=e,this}setLFO(e,t,r){return Object.assign(this.cfg.lfo,{target:e,rate:t,depth:r,enabled:!0}),this}setDuration(e){return this.cfg.duration=e,this}clone(){return new n(structuredClone(this.cfg))}},we=new C({osc:{enabled:!0,type:"square",freq:900,detune:0},ampEnv:{attack:.002,decay:.04,sustain:0,release:.02,volume:.15},duration:.05}),Ce=new C({osc:{enabled:!0,type:"sine",freq:600,detune:0},ampEnv:{attack:.01,decay:.08,sustain:0,release:.04,volume:.12},duration:.1}),Te=new C({osc:{enabled:!0,type:"triangle",freq:500,detune:0},pitchEnv:{amount:12,decay:.15},ampEnv:{attack:.01,decay:.12,sustain:0,release:.05,volume:.25},duration:.18}),Se=new C({osc:{enabled:!0,type:"sawtooth",freq:1200,detune:0},pitchEnv:{amount:-24,decay:.3},ampEnv:{attack:.005,decay:.25,sustain:0,release:.05,volume:.3},duration:.35}),Ie=new C({osc:{enabled:!0,type:"square",freq:180,detune:0},noise:{enabled:!0,level:.4},ampEnv:{attack:.002,decay:.15,sustain:0,release:.05,volume:.35},duration:.2});function j(n=12){let e=Date.now().toString(36),t=crypto.getRandomValues(new Uint8Array(4)),r=Array.from(t).map(i=>i.toString(36).padStart(2,"0")).join("");return(e+r).slice(0,n)}function ae(n){let e=!0;function t(){e&&(n(),requestAnimationFrame(t))}return requestAnimationFrame(t),{clear:()=>e=!1}}function oe(){return D?!1:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}var Ke=oe();function ue({width:n,height:e,updateHz:t="frames"}){return new T.KaylaGame(n,e,t==="frames"?1/0:t)}function le(n){let e=new _(n);return new T.KaylaScene(e)}function ce(n){return new T.KaylaRenderer(n)}function L(n,e){return{type:n,props:e}}var T;(d=>{class n extends A{#e;#t;constructor(s,c,a){super(s,c,a),this.#e=new Set,this.#t=!1}get started(){return this.#t}start(){if(!this.#t){for(let s of this.#e)s.start();this.#t=!0,super.start()}}stop(){if(this.#t){for(let s of this.#e)s.stop();this.#t=!1,super.stop()}}addRenderer(s){this.#e.has(s)||(this.#e.add(s),this.#t&&s.start(),s.game=this)}deleteRenderer(s){this.#e.has(s)&&(this.#e.delete(s),this.#t&&s.stop(),delete s.game)}}d.KaylaGame=n;class e extends F{game;pointerX;pointerY;#e;constructor(s){super(s),this.useDraw=this.useDraw.bind(this),this.on("draw",c=>{if(this.game)for(let a of this.game.scenes.values())a.handleDraw(c)}),this.pointerX=0,this.pointerY=0,this.#e=this.#t.bind(this)}#t(s){this.pointerX=s.clientX,this.pointerY=s.clientY}listenPointerUpdates(){this.canvas.addEventListener("pointermove",this.#e)}unlistenPointerUpdates(){this.canvas.removeEventListener("pointermove",this.#e)}pointerPosToWorldPos(s,c){let a=this.canvas.getBoundingClientRect(),h=(s-a.left)/a.width,m=(c-a.top)/a.height,b=h*this.viewportWidth*this.cameraWidth/a.width,E=m*this.viewportHeight*this.cameraHeight/a.height;return new S(b,E)}getMousePos(){return this.pointerPosToWorldPos(this.pointerX,this.pointerY)}useDraw(s){let c=a=>{s(a,new r)};return this.on("draw",c),()=>{this.off("draw",c)}}attachTo(s){s.addRenderer(this),this.game=s}detach(){this.game&&this.game.deleteRenderer(this)}}d.KaylaRenderer=e;class t{current;saves;constructor(){this.saves=[]}useTick(s){if(!this.current)throw new Error("Hook 'useTick' must be executed in the top level scope of a component.");this.current.onTick[this.current.useStepCallIndex]=s,this.current.useStepCallIndex++}usePaint(s){if(!this.current)throw new Error("Hook 'usePaint' must be executed in the top level scope of a component.");this.current.onPaint[this.current.useDrawCallIndex]=s,this.current.useDrawCallIndex++}useEntity(){return k(P)}useSelf(s){let c=k(null);return(c.current===null||c.current===void 0)&&(c.current=s()),c.current}useState(s,{alwaysRecall:c=!1}={}){if(!this.current)throw new Error("Hook 'useState' must be executed in the top level scope of a component.");let h=this.current.state[this.current.useStateCallIndex]??new i(this.current,s,{alwaysRecall:c});return this.current.state[this.current.useStateCallIndex]=h,this.current.useStateCallIndex++,h}useRef(s){if(!this.current)throw new Error("Hook 'useRef' must be executed in the top level scope of a component.");let a=this.current.refs[this.current.useRefCallIndex]??new o(this.current,s??null);return this.current.refs[this.current.useRefCallIndex]=a,this.current.useRefCallIndex++,a}useEffect(s){if(!this.current)throw new Error("Hook 'useEffect' must be executed in the top level scope of a component.");this.current.onEffect[this.current.useEffectCallIndex]=s,this.current.useEffectCallIndex++}useExports(s,c){if(!this.current)throw new Error("Hook 'useExports' must be executed in the top level scope of a component.");this.current.onExport=c}save(){this.saves.push({current:this.current})}restore(){let s=this.saves.pop();if(!s)throw new Error("Cannot restore without saving.");this.current=s.current}}d.GlobalKayla=t;class r{preventDefault(){this.#e=!0}#e=!1;isPrevented(){return this.#e}}d.KaylaEvent=r;class i{#e;#t;#n;alwaysRecall;constructor(s,c,{alwaysRecall:a=!1}={}){this.#t=s,this.#e=c??void 0,this.#n=Date.now(),this.alwaysRecall=a}get(){return this.#e}add(s,{recall:c}={}){this.set(this.get()+s,{recall:c})}multiply(s,{recall:c}={}){this.set(this.get()*s,{recall:c})}set(s,{recall:c=!1}={}){let a=this.#e;s!==a&&(this.#e=s,(c||this.alwaysRecall)&&this.#t.refresh(),this.#n=Date.now())}get value(){return this.#e}get lastChanged(){return this.#n}}d.KaylaState=i;class o{#e;#t;constructor(s,c){this.#t=s,this.#e=c??void 0}get current(){return this.#e}set current(s){this.#e=s}}d.KaylaRef=o;class p{state;refs;global;callProps;scene;exports;constructor(s,c,a){if(!a)throw new Error("Empty element");this.scene=c,this.state=[],this.refs=[],this.fc=a.type,this.callProps=a.props??{},this.global=s,this.lastStateDeps=[],this.entity=null,this.lastChildren=[],this.onEffect=[],this.onUnEffect=[],this.onPaint=[],this.onTick=[]}get key(){return this.callProps.key}set key(s){this.callProps.key=s}get children(){return this.callProps.children}set children(s){this.callProps.children=s}entity;onExport=()=>({});onEffect;onUnEffect;onEffectDeps;onPaint;onTick;fc;useStateCallIndex=0;useEffectCallIndex=0;useDrawCallIndex=0;useStepCallIndex=0;useRefCallIndex=0;lastStateDeps;refresh(){let s;this.global.save(),this.global.current=this,this.useStateCallIndex=0,this.useRefCallIndex=0;let c=[];try{let a=this.fc(this.callProps)??[];if(a&&!Array.isArray(a)&&(a=[a]),!Array.isArray(a))throw new Error("Non array or non undefined children received.");c=a}catch(a){s=a}this.useStateCallIndex=0,this.useRefCallIndex=0,this.useDrawCallIndex=0,this.useStepCallIndex=0,this.useEffectCallIndex=0,this.global.restore();try{let a=0,h=[];for(let m of c){let b=this.lastChildren.at(a)??new p(this.global,this.scene,m);this.lastChildren[a]=b,h.push(b),a++}for(let m of this.lastChildren.filter(b=>!h.includes(b))){let b=this.lastChildren.indexOf(m);b!==1&&this.lastChildren.splice(b,1),m.unuse()}for(let m of this.lastChildren)try{m.refresh()}catch(b){console.error(b)}Y(()=>{this.use()})}catch(a){console.error(a)}if(s)throw s}lastChildren;isFirstUse=!0;use(){try{let s=!0;if(this.lastStateDeps??=[],Array.isArray(this.onEffectDeps)&&(s=this.onEffectDeps.some((c,a)=>{let h=this.lastStateDeps.at(a);if(h){let m=c.lastChanged,b=h.stamp;return m>b}})),s||this.isFirstUse){this.isFirstUse=!1,Array.isArray(this.onEffectDeps)&&(this.lastStateDeps=this.onEffectDeps.map(a=>({stamp:a.lastChanged,stateRef:a}))),this.key??=this.fc.name+"_"+j(),this.entity&&this.scene.getScene().removeEntity(this.entity),this.entity&&this.entity.name!==this.key&&(this.entity=null),this.entity=this.entity??new f(this,this.key);for(let a of this.refs)a.current===P&&(a.current=this.entity);this.callProps.ref instanceof o&&(this.callProps.ref.current=this.entity),this.exports=this.onExport(),this.callProps.exportsRef instanceof o&&(this.callProps.exportsRef.current=this.exports),this.scene.getScene().addEntity(this.entity);let c=this.onEffect.map(a=>a()).filter(a=>a!==void 0);this.onUnEffect=c}}catch(s){throw s}}unuse(){try{for(let s of this.onUnEffect)s()}catch(s){console.error(s)}this.scene.getScene().removeEntity(this.entity)}}d.KaylaInternalComponent=p;class f extends V{#e;constructor(s,c){super(c,0,0,0,0),this.#e=s}update(s){let c=new r;if(this.#e.onTick)for(let a of this.#e.onTick)a(s,c);c.isPrevented()}draw(s){let c=new r;if(this.#e.onPaint)for(let a of this.#e.onPaint)a(s,c);c.isPrevented()||super.draw(s)}}d.KaylaRectEntity=f;class l{constructor(s){this.#t=s,this.#e=null,s.on("update",this.tickHandler.bind(this)),this.drawHandler=this.drawHandler.bind(this)}#e;#t;getScene(){return this.#t}drawHandler(s){return this.#t.handleDraw(s)}attachTo(s){s.addScene(this.#t),this.#e=s}spawn(s){new p(d.singleGlobalInstance,this,s).refresh()}detach(){this.#e&&this.#e.removeScene(this.#t)}tickHandler(){}}d.KaylaScene=l,d.singleGlobalInstance=new d.GlobalKayla})(T||={});var x=T.singleGlobalInstance,H=x.useState.bind(x),k=x.useRef.bind(x),X=x.useEffect.bind(x),he=x.useTick.bind(x),U=x.usePaint.bind(x),pe=x.useExports.bind(x),fe=x.useSelf.bind(x),de=x.useEntity.bind(x),P=Symbol("self_ref");var Y=n=>{Promise.resolve(1).then(()=>n())},q=({children:n})=>Array.isArray(n)?[...n]:n;function me(n){return new T.KaylaRef(null,n)}Reflect.set(globalThis,"Kayla",B);var ye;(e=>e.UIComponent=({x:t,y:r,width:i,height:o,children:p})=>{let f=k(P),l=H(!1);return X(()=>{if(l.get()===!0)return;l.set(!0);let u=f.current;u.width=i,u.height=o,u.x=t,u.y=r}),U(u=>{u.fillStyle="rgba(0, 0, 0, 0.5)",u.fillRect(t,r,i,o)}),p??[]})(ye||={});function be(n,e,...t){if(typeof n=="string")throw new Error("Cannot use intrinsic elements.");return L(n,{...e,children:e.children??t})}function Q(n,e,...t){if(typeof n=="string")throw new Error("Cannot use intrinsic elements.");return L(n,{...e,children:e.children??t})}function xe(n,e){return Q(n,e)}var ge=q;0&&(module.exports={Fragment,jsx,jsxDEV,jsxs});
@@ -0,0 +1,3 @@
1
+ export { Fragment, jsx, jsxDEV, jsxs } from './jsx-runtime.cjs';
2
+ import './kayla-internals-DvV9K1wf.cjs';
3
+ import './lea-DvxsutSf.cjs';
@@ -0,0 +1,3 @@
1
+ export { Fragment, jsx, jsxDEV, jsxs } from './jsx-runtime.js';
2
+ import './kayla-internals-ClSuOWZb.js';
3
+ import './lea-DvxsutSf.js';
@@ -0,0 +1 @@
1
+ var j=Object.defineProperty;var Y=(n,e)=>{for(var t in e)j(n,t,{get:e[t],enumerable:!0})};var q={};Y(q,{KaylaFragment:()=>U,KaylaInternals:()=>T,createElement:()=>L,createGame:()=>ne,createRenderer:()=>se,createScene:()=>re,self:()=>P,useDisposableRef:()=>le,useEffect:()=>H,useEntity:()=>ue,useExports:()=>ae,useNextStack:()=>W,usePaint:()=>X,useRef:()=>k,useSelf:()=>oe,useState:()=>O,useTick:()=>ie});var w=class{#e=new Map;constructor(){this.#e=new Map}on(e,t){let r=this.#e.get(e)||[];return r.push(t),this.#e.set(e,r),this}once(e,t){let r=(...i)=>{this.off(e,r),t(...i)};return this.on(e,r),this}off(e,t){let r=this.#e.get(e);if(!r)return this;let i=r.indexOf(t);return i>=0&&r.splice(i,1),this}emit(e,...t){let r=this.#e.get(e);if(!r||r.length===0){if(e==="error")throw t[0];return!1}return r.slice().forEach(i=>i(...t)),!0}removeAllListeners(e){return e?this.#e.delete(e):this.#e.clear(),this}listenerCount(e){return this.#e.get(e)?.length??0}},F=class extends w{canvas;ctx;running;_rafId;_fps;_frameCount;_fpsTimer;_lastFrameTime;constructor(e,{viewportWidth:t,viewportHeight:r,cameraWidth:i,cameraHeight:o}={}){if(!v)throw new Error("Web-Only");super(),this.canvas=e,this.ctx=e.getContext("2d"),this.automatic=!0,this.#e=t??e.width,this.#t=r??e.height,this.#n=i??e.width,this.#r=o??e.height,this.running=!1,this._rafId=null,this._loop=this._loop.bind(this),this.updateCanvasResolution(),this._fps=60,this._frameCount=0,this._fpsTimer=0}automatic;retransform(){this.ctx.setTransform(1,0,0,1,0,0);let e=this.#n/this.#e,t=this.#r/this.#t;this.ctx.translate(this.#n/2,this.#r/2),this.ctx.scale(e,t),this.ctx.translate(-this.#e/2,-this.#t/2)}#e=0;#t=0;#n=0;#r=0;get viewportWidth(){return this.#e}set viewportWidth(e){this.#e=e,this.retransform()}get width(){return this.#e}get height(){return this.#t}get centerX(){return this.#e/2}get centerY(){return this.#t/2}get left(){return 0}get top(){return 0}get right(){return this.#e}get bottom(){return this.#t}get viewportHeight(){return this.#t}set viewportHeight(e){this.#t=e,this.retransform()}get cameraWidth(){return this.#n}set cameraWidth(e){this.#n=e,this.updateCanvasResolution(),this.retransform()}get cameraHeight(){return this.#r}set cameraHeight(e){this.#r=e,this.updateCanvasResolution(),this.retransform()}updateCanvasResolution(){this.canvas.width=this.#n,this.canvas.height=this.#r}applyTransform(){this.retransform()}get FPS(){return this._fps}_loop(){this.automatic&&this.update(),this._rafId=requestAnimationFrame(this._loop)}update(){if(!this.running||!v)return;let e=performance.now(),t=(e-(this._lastFrameTime??e))/1e3;this._lastFrameTime=e,this._frameCount++,this._fpsTimer+=t,this._fpsTimer>=1&&(this._fps=Math.round(this._frameCount/this._fpsTimer),this._frameCount=0,this._fpsTimer=0),this.ctx.clearRect(0,0,this.#n,this.#r),this.emit("draw",this.ctx)}start(){if(!this.running){if(!v||typeof globalThis.requestAnimationFrame>"u")throw new Error("Raf is not supported");this.running=!0,this._rafId=requestAnimationFrame(this._loop)}}stop(){if(!v||typeof globalThis.requestAnimationFrame>"u")throw new Error("Raf is not supported");this.running=!1,this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null)}},G=class extends w{setNow(e){this.#e=e}#e=0;__intervalId=null;__lastTime=0;constructor(e=16){super(),this.#t=e,this.speedHackDT=1}speedHackDT;get isRaf(){return this.tickInterval===1/0}#t=15;get tickInterval(){return this.#t}set tickInterval(e){this.#t=e,this.__intervalId&&(this.stop(),this.start())}now(){return this.#e}__tick(){let e=performance.now(),t=(e-this.__lastTime)/1e3*this.speedHackDT;this.__lastTime=e,this.#e+=t*1e3,this.emit("tick",t)}createTimeout(e){return new z(e,this)}createTween(e,t=()=>{}){let r=new N(e),i=(o=0)=>{if(r.finished){this.off("tick",i);return}r.update(o)};return r.on("finish",()=>{this.off("tick",i)}),r.on("delta",o=>{t(o)}),this.on("tick",i),r}start(){this.__intervalId===null&&(this.__lastTime=performance.now(),this.__intervalId=v&&!isFinite(this.tickInterval)?ee(()=>this.__tick()).clear:setInterval(()=>this.__tick(),this.tickInterval))}stop(){this.__intervalId!==null&&(typeof this.__intervalId=="function"?this.__intervalId():clearInterval(this.__intervalId)),this.__intervalId=null}getSineMod(e,t=0){return .5+.5*Math.sin((this.now()%e/e+t)*2*Math.PI)}},Q;(a=>{function n(h){return h===!0?1:0}a.booleanExport=n;function e(h){return h===0?!1:h===1}a.booleanImport=e;function t(h){return`${h.x}|${h.y}`}a.vec2Export=t;function r(h){let[m,b]=h.split("|"),E=parseFloat(m),M=parseFloat(b);if(isNaN(E)||isNaN(M))throw new Error(`Invalid Vector2 string: ${h}`);return new S(E,M)}a.vec2Import=r,a.booleanMap={mapExport:n,mapImport:e};function o(h){return m=>Number(m.toFixed(h))}a.createRounder=o;function p(h=10){return{mapExport(m){return Math.round(m/h)},mapImport(m){return m*h}}}a.createLowPrecision=p;function f(h){return Math.round(h)}a.lightWeightRounder=f;function l(h=100){return{mapExport(m){return Math.round(m*h)},mapImport(m){return m/h}}}a.createPercent=l;function u(h){let m=new Map(Object.entries(h));return{mapExport:b=>m.get(b)??null,mapImport:b=>Array.from(m.entries()).find(([E,M])=>M===b)?.[0]??null}}a.createLookup=u;function d(h){let m=h*(180/Math.PI);return Math.round((m%360+360)%360)}a.radToDeg=d;function y(h){return h*(Math.PI/180)}a.degToRad=y,a.angleRadToDeg={mapExport:d,mapImport:y};function c(h=10){let m=p(h);return{mapExport(b){return m.mapExport(d(b))},mapImport(b){return m.mapImport(y(b))}}}a.createLowPrecisionRadToDeg=c})(Q||={});var K=class n extends w{name="";scaleRotate=0;scale=1;constructor(e,t=0,r=0){super(),this.autoTranslate=!1,this.name=e,this.z=0,this.___pos=new S(t,r),this.nonSerializableProperties=[],this.nonSerializableProperties.push("___pos","autoTranslate","arraySerializeMap"),this.forceSerializableProperties=[],this.forceSerializableProperties.push("x","y")}arraySerializeMap;autoTranslate;z;___pos;nonSerializableProperties;forceSerializableProperties;get pos(){return this.___pos}get x(){return this.pos.x}get y(){return this.pos.y}set x(e){this.pos.x=e}set y(e){this.pos.y=e}handleUpdate(e){if(this.update)try{this.emit("update",e),this.update(e)}catch(t){this.emit("error",t)}}handleDraw(e){if(!(D||!this.draw)){e.save(),this.autoTranslate&&e.translate(this.x,this.y);try{this.emit("draw",e),this.draw(e)}catch(t){this.emit("error",t)}e.restore()}}serialize(){if(Array.isArray(this.arraySerializeMap))return this.arraySerializeMap.map(([i,{mapExport:o}])=>{let p=Reflect.get(this,i);return o?o(p):p});let e=["_events","_eventsCount","_maxListeners","nonSerializableProperties","forceSerializableProperties"],t=[...Reflect.ownKeys(this),...this.forceSerializableProperties].filter(i=>!this.nonSerializableProperties.includes(i)&&!e.includes(i.toString())),r=Object.fromEntries(t.map(i=>{let o=Reflect.get(this,i);if(D&&typeof o=="number"){let p=o.toString().split("."),l=(p[1]?p[1].length:0)>2?Number(o.toFixed(2)):o;return[i,l]}return[i,o]}));return JSON.parse(JSON.stringify(r))}toLocal(e){return e.subtract(this.pos)}toWorld(e){return e.add(this.pos)}deserializeArray(e){return n.deserializeArray(this.arraySerializeMap,e)}static deserializeArray(e,t){if(!e||!Array.isArray(t))return t;let r={};for(let i=0;i<t.length;i++){let o=e[i];if(!o)break;let[p,{mapImport:f}]=o,l=t[i];if(f&&(l=f(l)),typeof p!="string")break;try{Reflect.set(r,p,l)}catch(u){console.error(u)}}return r}},_=class extends w{name="";entities=new Map;paused=!0;constructor(e){super(),this.name=e}handleUpdate(e){if(!this.paused){this.emit("update",e);for(let t of this.entities.values())t.handleUpdate(e)}}handleDraw(e){if(!D&&!this.paused){this.emit("draw",e);for(let t of[...this.entities.values()].sort((r,i)=>r.z-i.z))t.handleDraw(e)}}addEntity(e){if(!(e instanceof K))throw new Error("invalid entity");if(!e.name)throw new Error("Entity must have a name.");this.entities.set(e.name,e)}removeEntity(e){if(!(e instanceof K))throw new Error("invalid entity");this.entities.delete(e.name)}getEntity(e){return this.entities.get(e)}},A=class{scenes;ticker;get centerX(){return this.width/2}get centerY(){return this.height/2}get left(){return 0}get top(){return 0}get right(){return this.width}get bottom(){return this.height}width;height;constructor(e,t,r=16){this.ticker=new G(r),this.scenes=new Map,this.width=e,this.height=t,this.ticker.on("tick",i=>{for(let o of this.scenes.values())o.paused||o.handleUpdate(i)})}addScene(e){if(!e.name)throw new Error("Scene must have a name.");e.paused=!1,this.scenes.set(e.name,e)}removeScene(e){e&&(e.paused=!0),this.scenes.delete(e.name)}now(){return this.ticker.now()}start(){this.ticker.start()}stop(){this.ticker.stop()}},g={lerp(n,e,t){return n+(e-n)*t},clamp(n,e,t){return Math.min(t,Math.max(e,n))},clamp01(n){return Math.min(1,Math.max(0,n))},easeLinear(n){return n},easeInQuad(n){return n*n},easeOutQuad(n){return 1-(1-n)*(1-n)},easeInOutQuad(n){return n<.5?2*n*n:1-Math.pow(-2*n+2,2)/2},easeInSine(n){return 1-Math.cos(n*Math.PI/2)},easeOutSine(n){return Math.sin(n*Math.PI/2)},easeInOutSine(n){return-(Math.cos(Math.PI*n)-1)/2},easeInExpo(n){return n===0?0:Math.pow(2,10*n-10)},easeOutExpo(n){return n===1?1:1-Math.pow(2,-10*n)},easeInOutExpo(n){return n===0?0:n===1?1:n<.5?Math.pow(2,20*n-10)/2:(2-Math.pow(2,-20*n+10))/2},smoothstep(n){return n=g.clamp(n,0,1),n*n*(3-2*n)},randomLerp(n,e){return g.lerp(n,e,Math.random())},randomInt(n,e){return Math.floor(Math.random()*(e-n+1))+n},randomArrayValue(n){return n[g.randomInt(0,n.length-1)]},createBezier(n,e,t,r){function i(f,l,u,d,y){let s=1-f;return s*s*s*l+3*s*s*f*u+3*s*f*f*d+f*f*f*y}function o(f,l,u,d,y){let s=1-f;return 3*s*s*(u-l)+6*s*f*(d-u)+3*f*f*(y-d)}function p(f){let l=f;for(let u=0;u<6;u++){let d=i(l,0,n,t,1),y=o(l,0,n,t,1);if(y===0)break;l-=(d-f)/y}return g.clamp(l,0,1)}return function(l){l=g.clamp(l,0,1);let u=p(l);return i(u,0,e,r,1)}},lengthSquared(...n){return n.reduce((e,t)=>e+t*t,0)},normalizeRad(n){let e=2*Math.PI;return n=n%e,n<0&&(n+=e),n},angleInvertY(n){return g.normalizeRad(-n)},degToRadFlipY(n){return g.angleInvertY(n*Math.PI/180)},minimalAngularDirection(n,e){n=g.normalizeRad(n),e=g.normalizeRad(e);let t=g.normalizeRad(e-n),r=g.normalizeRad(n-e);return t<=r?1:-1}},N=class extends w{constructor({delta:e,ms:t,easing:r}){super(),this.delta=e,this.duration=t,this.elapsed=0,this.easing=r??(i=>i),this.lastValue=0,this.finished=!1}delta;duration;elapsed;lastValue;finished;easing;update(e){this.elapsed+=e*1e3;let t=g.clamp(this.elapsed/this.duration,0,1),r=this.easing(t),i=this.delta*r,o=i-this.lastValue;this.lastValue=i,this.emit("delta",o),t>=1&&(this.finished=!0,this.emit("finish",void 0))}},V=class extends K{constructor(e,t=0,r=0,i=50,o=50){super(e,t,r),this.width=i,this.height=o}width;height;get left(){return this.x-this.width/2}set left(e){this.x=e+this.width/2}get right(){return this.x+this.width/2}set right(e){this.x=e-this.width/2}get top(){return this.y-this.height/2}set top(e){this.y=e+this.height/2}get bottom(){return this.y+this.height/2}set bottom(e){this.y=e-this.height/2}get lx(){return 0}get ly(){return 0}get lleft(){return-this.width/2}get lright(){return this.width/2}get ltop(){return-this.height/2}get lbottom(){return this.height/2}isCollidingWith(e){return!(this.right<e.left||this.left>e.right||this.bottom<e.top||this.top>e.bottom)}color="rgba(0, 0, 255, 0.3)";draw(e){e.translate(this.x,this.y),e.rotate(this.scaleRotate),e.fillStyle=this.color,e.fillRect(-this.width/2,-this.height/2,this.width,this.height)}},z=class extends w{duration;ticker;elapsed;finished;_resolve;promise;_timeoutId;constructor(e,t=null){super(),this.duration=e,this.ticker=t,this.elapsed=0,this.finished=!1,this._resolve=null,this.promise=new Promise(r=>this._resolve=r),this.update=this.update.bind(this),this.ticker&&this.ticker.on("tick",this.update)}update(e=0){this.finished||(this.elapsed+=e*1e3,this.elapsed>=this.duration&&this.finish())}finish(){this.finished||(this.finished=!0,this.emit("finish",void 0),this._resolve&&this._resolve(),this.ticker&&this.ticker.off("tick",this.update))}start(){return this.ticker||(this._timeoutId=setTimeout(()=>this.finish(),this.duration)),this}cancel(){this.finished||(this.finished=!0,!this.ticker&&this._timeoutId!=null&&clearTimeout(this._timeoutId),this.ticker&&this.ticker.off("tick",this.update))}then(e,t){return this.promise.then(e,t)}after(e,t){return this.promise.then(e,t)}},S=class n{constructor(e=0,t=0){this.x=e,this.y=t}x;y;toJSON(){return{x:this.x,y:this.y,vec2:!0}}static isVec2(e){return e&&typeof e=="object"&&"x"in e&&"y"in e&&e.vec2===!0}static fromSerialized(e){return this.isVec2(e)?new this(e.x,e.y):null}rotate(e){let t=Math.cos(e),r=Math.sin(e);return new n(this.x*t-this.y*r,this.x*r+this.y*t)}static from(e){return new n(Math.cos(e),Math.sin(e))}get angle(){return Math.atan2(this.y,this.x)}get length(){return Math.hypot(this.x,this.y)}get lengthSquared(){return this.x*this.x+this.y*this.y}normalized(){let e=this.length;return e===0?new n(0,0):new n(this.x/e,this.y/e)}project(e){return e.scale(this.dotNormalized(e))}reflect(e){let t=this.dot(e);return this.subtract(e.scale(2*t))}dotNormalized(e){let t=this.normalized(),r=e.normalized();return t.x*r.x+t.y*r.y}lengthSquaredTo(e){let t=this.x-e.x,r=this.y-e.y;return t*t+r*r}dot(e){return this.x*e.x+this.y*e.y}distanceTo(e){return Math.hypot(this.x-e.x,this.y-e.y)}distanceToCheap(e){let t=this.x-e.x,r=this.y-e.y;return t*t+r*r}directionTo(e){return new n(e.x-this.x,e.y-this.y).normalized()}add(e){return new n(this.x+e.x,this.y+e.y)}addRaw(e){return new n(this.x+e,this.y+e)}overwite(e){this.x=e.x,this.y=e.y}subtract(e){return new n(this.x-e.x,this.y-e.y)}scale(e){return new n(this.x*e,this.y*e)}toString(){return`Vector2(${this.x}, ${this.y})`}clone(){return new n(this.x,this.y)}};function J(){return typeof process<"u"&&process.release?.name==="node"?"node":typeof window<"u"||typeof self<"u"?"web":"unknown"}var B=J(),D=B==="node",v=B==="web",R=class n{static unlock(){v&&this.audioCtx.state!=="running"&&this.audioCtx.resume()}static audioCtx=v?new AudioContext:null;static masterGain=v?this.audioCtx.createGain():null;static musicGain=v?this.audioCtx.createGain():null;static sfxGain=v?this.audioCtx.createGain():null;static{v&&(this.masterGain.gain.value=1,this.musicGain.gain.value=1,this.sfxGain.gain.value=1,this.sfxGain.connect(this.masterGain),this.musicGain.connect(this.masterGain),this.masterGain.connect(this.audioCtx.destination))}static get SFX_VOLUME(){return this.sfxGain.gain.value}static get MUSIC_VOLUME(){return this.musicGain.gain.value}static get VOLUME(){return this.masterGain.gain.value}static set SFX_VOLUME(e){this.sfxGain.gain.value=e}static set MUSIC_VOLUME(e){this.musicGain.gain.value=e}static set VOLUME(e){this.masterGain.gain.value=e}static noteToHz(e){return this.tuningFreq*Math.pow(2,(e-9)/12)}static tuningFreq=440;static audioBufferCache=new Map;static loops=new Map;static sfsx=new Map;static loopIdCounter=0;static CACHE_NAME="lia-audio-cache-v1";static async preLoad(e){if(this.audioBufferCache.has(e))return this.audioBufferCache.get(e);let t=n.CACHE_NAME,r,i;if(typeof caches<"u"&&(i=await caches.open(t),r=await i.match(e)),!r){if(r=await fetch(e),!r.ok)throw new Error(`Failed to fetch ${e}`);i&&await i.put(e,r.clone())}let o=await r.arrayBuffer(),p=await this.audioCtx.decodeAudioData(o);return this.audioBufferCache.set(e,p),p}static async getOnlyDownloadedCache(e){let t=n.CACHE_NAME;return await(await caches.open(t)).match(e)}static getCached(e){return this.audioBufferCache.get(e)||null}static async playSound(e,t=.2,r=1,i=!0){try{this.sfsx.has(e)&&this.sfsx.get(e).source.stop(),this.audioBufferCache.has(e)||await this.preLoad(e);let o=this.getCached(e);if(!o)return;let p=new I(o);p.buffer=o;let f=1-.12,l=1+.12;p.playbackRate=r??f+Math.random()*(l-f);let u=this.audioCtx.createGain();u.gain.value=t,p.tempGain=u,p.connect(u),u.connect(this.sfxGain),p.onended=()=>{p.disconnect(),u.disconnect()},p.start(),i&&this.sfsx.set(e,{source:p,gain:u})}catch(o){console.error(o)}}static async playLoop(e,t=1,{loopStart:r=0,loopEnd:i=null,exclusive:o=!0,skipMS:p=0}={}){if(o)for(let y of this.loops.keys())this.stopLoop(y);this.audioBufferCache.has(e)||await this.preLoad(e);let f=this.getCached(e);if(!f)return;let l=new I(f);l.buffer=f,l.loop=!0,typeof r=="number"&&(l.loopStart=r),typeof i=="number"&&(l.loopEnd=i);let u=this.audioCtx.createGain();u.gain.value=t,l.tempGain=u,l.playbackRate=1,l.onended=()=>{l.disconnect(),u.disconnect()},l.connect(u),u.connect(this.musicGain),l.start(0,p/1e3);let d=++this.loopIdCounter;return this.loops.set(d,{source:l,gain:u}),d}static stopLoop(e){let t=this.loops.get(e);t&&(t.source.stop(),t.source.notIndependent||(t.source.disconnect(),t.gain.disconnect()),this.loops.delete(e))}static async createLiaSource(e,{volume:t=1,speed:r=1,loop:i=!1,loopStart:o=0,loopEnd:p=null,isMusic:f=!1,gain:l=null}={}){try{this.audioBufferCache.has(e)||await this.preLoad(e);let u=this.getCached(e);if(!u)return null;let d=new I(u);d.loop=i,d.loopStart=o,d.loopEnd=typeof p=="number"?p:u.duration,d.playbackRate=r;let y=this.audioCtx.createGain();return y.gain.value=t,d.connect(y),d.tempGain=y,y.connect(l||(f?this.musicGain:this.sfxGain)),d.onended=()=>{d.disconnect(),y.disconnect()},d}catch(u){return console.error("Failed to create LiaAudioSrc:",u),null}}};var I=class{numberOfInputs;numberOfOutputs;constructor(e,t=R.audioCtx){this.context=t,this.buffer=e,this.source=null,this.startTime=0,this.pauseTime=0,this.playbackRate=1,this.isPlaying=!1,this.loop=!1,this.output=v?t.createGain():null,this.output.gain.value=1,this.channelCount=2,this.channelCountMode="max",this.channelInterpretation="speakers",this.numberOfInputs=0,this.numberOfOutputs=1,this.onended=null}channelCount;channelCountMode;channelInterpretation;onended;source;buffer;context;_createSource(){this.source&&(this.source.onended=null);let e=this.context.createBufferSource();return e.buffer=this.buffer,e.playbackRate.value=this.playbackRate,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd>0?this.loopEnd:this.buffer.duration,e.connect(this.output),this.source=e,e.onended=()=>{this.source===e&&(this.isPlaying&&!this.loop&&(this.isPlaying=!1,this.pauseTime=0),typeof this.onended=="function"&&this.onended())},e}play({fadeIn:e=0,offset:t=null}={}){let r=t!==null?t:this.pauseTime;if(this.source){this.source.onended=null;try{this.source.stop()}catch{}}this.source=this._createSource(),this.startTime=this.context.currentTime-r/this.playbackRate,this.source.start(0,r),e>0?(this.output.gain.setValueAtTime(0,this.context.currentTime),this.output.gain.linearRampToValueAtTime(1,this.context.currentTime+e)):this.output.gain.setValueAtTime(1,this.context.currentTime),this.isPlaying=!0}start(e=0,t=0,r){this.isPlaying||(this.source=this._createSource(),this.startTime=this.context.currentTime+e-t/this.playbackRate,r!==void 0?this.source.start(this.context.currentTime+e,t,r):this.source.start(this.context.currentTime+e,t),this.pauseTime=t,this.isPlaying=!0)}pause({fadeOut:e=0}={}){if(!this.isPlaying)return;let t=this.getElapsed()/1e3;if(this.loop&&this.loopEnd>this.loopStart){let r=this.loopEnd-this.loopStart;t=this.loopStart+(t-this.loopStart)%r}if(this.isPlaying=!1,e>0){let r=this.context.currentTime;this.output.gain.setValueAtTime(this.output.gain.value,r),this.output.gain.linearRampToValueAtTime(0,r+e),setTimeout(()=>{if(this.source){this.source.onended=null;try{this.source.stop()}catch{}}this.pauseTime=t,this.output.gain.setValueAtTime(1,this.context.currentTime)},e*1e3)}else{if(this.source){this.source.onended=null;try{this.source.stop()}catch{}}this.pauseTime=t}}getElapsed(){return this.isPlaying?(this.context.currentTime-this.startTime)*this.playbackRate*1e3:this.pauseTime*1e3}setSpeed(e){if(e<=0)throw new Error("Playback rate must be positive");let t=this.getElapsed()/1e3;this.playbackRate=e,this.isPlaying&&(this.pause(),this.pauseTime=t,this.play())}setLoop(e=!0){this.loop=e,this.source&&(this.source.loop=e)}loop;playbackRate;startTime;tempGain=null;connect(e,t=0,r=0){if("value"in e)this.output.connect(e,t);else return this.output.connect(e,t,r),e}disconnect(e,t,r){e===void 0?this.output.disconnect():this.output.disconnect(e,t,r)}output;stop(e=0){if(this.notIndependent)return this.pause();if(!this.source)return;let t=this.context.currentTime+e;this.source.stop(t),this.isPlaying=!1,this.notIndependent||(this.pauseTime=0)}pauseTime;isPlaying;notIndependent=!1;loopStart=0;loopEnd=0},Z={osc:{enabled:!0,type:"sine",freq:440,detune:0},noise:{enabled:!1,level:.5},ampEnv:{attack:.005,decay:.1,sustain:0,release:.1,volume:.3},pitchEnv:{amount:0,decay:.2},filter:{enabled:!1,type:"lowpass",freq:1200,Q:1,envAmount:0,decay:.2},lfo:{enabled:!1,target:"freq",rate:8,depth:20},duration:.4},C=class n{constructor(e={}){this.ctx=R.audioCtx,this.cfg=structuredClone(Z),Object.assign(this.cfg,e)}ctx;cfg;play(e=R.sfxGain){let t=this.ctx,r=t.currentTime,i=this.cfg,o=t.createGain();o.gain.setValueAtTime(1e-4,r);let p=i.ampEnv;o.gain.exponentialRampToValueAtTime(p.volume,r+p.attack),o.gain.exponentialRampToValueAtTime(Math.max(1e-4,p.sustain*p.volume),r+p.attack+p.decay),o.gain.exponentialRampToValueAtTime(1e-4,r+i.duration+p.release);let f=o,l;i.filter.enabled&&(l=t.createBiquadFilter(),l.type=i.filter.type,l.frequency.value=i.filter.freq,l.Q.value=i.filter.Q,l.connect(o),f=l);let u;if(i.osc.enabled){if(u=t.createOscillator(),u.type=i.osc.type,u.frequency.value=i.osc.freq,u.detune.value=i.osc.detune,i.pitchEnv.amount!==0){let h=Math.pow(2,i.pitchEnv.amount/12);u.frequency.exponentialRampToValueAtTime(i.osc.freq*h,r+i.pitchEnv.decay)}u.connect(f),u.start(r),u.stop(r+i.duration+p.release)}let d;if(i.noise.enabled){let h=t.sampleRate*i.duration,m=t.createBuffer(1,h,t.sampleRate),b=m.getChannelData(0);for(let E=0;E<h;E++)b[E]=(Math.random()*2-1)*i.noise.level;d=t.createBufferSource(),d.buffer=m,d.connect(f),d.start(r),d.stop(r+i.duration+p.release)}let y,s;i.lfo.enabled&&u&&(y=t.createOscillator(),y.frequency.value=i.lfo.rate,s=t.createGain(),s.gain.value=i.lfo.depth,y.connect(s),i.lfo.target==="freq"?s.connect(u.frequency):i.lfo.target==="gain"?s.connect(o.gain):i.lfo.target==="filter"&&l&&s.connect(l.frequency),y.start(r),y.stop(r+i.duration)),o.connect(e);let c=[u,d,y,s,l,o],a=r+i.duration+p.release;setTimeout(()=>{c.forEach(h=>h?.disconnect())},(a-t.currentTime)*1e3)}getConfig(){return structuredClone(this.cfg)}setConfig(e){return Object.assign(this.cfg,e),this}getKey(e){return this.cfg[e]}setKey(e,t){return Object.assign(this.cfg[e],t),this}setFreq(e){return this.cfg.osc.freq=e,this}setWave(e){return this.cfg.osc.type=e,this}setVolume(e){return this.cfg.ampEnv.volume=e,this}setAmpEnv(e,t,r,i){return Object.assign(this.cfg.ampEnv,{attack:e,decay:t,sustain:r,release:i}),this}setPitchEnv(e,t){return Object.assign(this.cfg.pitchEnv,{amount:e,decay:t}),this}setNoiseEnabled(e){return this.cfg.noise.enabled=e,this}setNoiseLevel(e){return this.cfg.noise.level=e,this}setFilterEnabled(e){return this.cfg.filter.enabled=e,this}setFilter(e,t,r){return Object.assign(this.cfg.filter,{type:e,freq:t,Q:r,enabled:!0}),this}setLFOEnabled(e){return this.cfg.lfo.enabled=e,this}setLFO(e,t,r){return Object.assign(this.cfg.lfo,{target:e,rate:t,depth:r,enabled:!0}),this}setDuration(e){return this.cfg.duration=e,this}clone(){return new n(structuredClone(this.cfg))}},fe=new C({osc:{enabled:!0,type:"square",freq:900,detune:0},ampEnv:{attack:.002,decay:.04,sustain:0,release:.02,volume:.15},duration:.05}),de=new C({osc:{enabled:!0,type:"sine",freq:600,detune:0},ampEnv:{attack:.01,decay:.08,sustain:0,release:.04,volume:.12},duration:.1}),me=new C({osc:{enabled:!0,type:"triangle",freq:500,detune:0},pitchEnv:{amount:12,decay:.15},ampEnv:{attack:.01,decay:.12,sustain:0,release:.05,volume:.25},duration:.18}),ye=new C({osc:{enabled:!0,type:"sawtooth",freq:1200,detune:0},pitchEnv:{amount:-24,decay:.3},ampEnv:{attack:.005,decay:.25,sustain:0,release:.05,volume:.3},duration:.35}),be=new C({osc:{enabled:!0,type:"square",freq:180,detune:0},noise:{enabled:!0,level:.4},ampEnv:{attack:.002,decay:.15,sustain:0,release:.05,volume:.35},duration:.2});function $(n=12){let e=Date.now().toString(36),t=crypto.getRandomValues(new Uint8Array(4)),r=Array.from(t).map(i=>i.toString(36).padStart(2,"0")).join("");return(e+r).slice(0,n)}function ee(n){let e=!0;function t(){e&&(n(),requestAnimationFrame(t))}return requestAnimationFrame(t),{clear:()=>e=!1}}function te(){return D?!1:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}var xe=te();function ne({width:n,height:e,updateHz:t="frames"}){return new T.KaylaGame(n,e,t==="frames"?1/0:t)}function re(n){let e=new _(n);return new T.KaylaScene(e)}function se(n){return new T.KaylaRenderer(n)}function L(n,e){return{type:n,props:e}}var T;(d=>{class n extends A{#e;#t;constructor(s,c,a){super(s,c,a),this.#e=new Set,this.#t=!1}get started(){return this.#t}start(){if(!this.#t){for(let s of this.#e)s.start();this.#t=!0,super.start()}}stop(){if(this.#t){for(let s of this.#e)s.stop();this.#t=!1,super.stop()}}addRenderer(s){this.#e.has(s)||(this.#e.add(s),this.#t&&s.start(),s.game=this)}deleteRenderer(s){this.#e.has(s)&&(this.#e.delete(s),this.#t&&s.stop(),delete s.game)}}d.KaylaGame=n;class e extends F{game;pointerX;pointerY;#e;constructor(s){super(s),this.useDraw=this.useDraw.bind(this),this.on("draw",c=>{if(this.game)for(let a of this.game.scenes.values())a.handleDraw(c)}),this.pointerX=0,this.pointerY=0,this.#e=this.#t.bind(this)}#t(s){this.pointerX=s.clientX,this.pointerY=s.clientY}listenPointerUpdates(){this.canvas.addEventListener("pointermove",this.#e)}unlistenPointerUpdates(){this.canvas.removeEventListener("pointermove",this.#e)}pointerPosToWorldPos(s,c){let a=this.canvas.getBoundingClientRect(),h=(s-a.left)/a.width,m=(c-a.top)/a.height,b=h*this.viewportWidth*this.cameraWidth/a.width,E=m*this.viewportHeight*this.cameraHeight/a.height;return new S(b,E)}getMousePos(){return this.pointerPosToWorldPos(this.pointerX,this.pointerY)}useDraw(s){let c=a=>{s(a,new r)};return this.on("draw",c),()=>{this.off("draw",c)}}attachTo(s){s.addRenderer(this),this.game=s}detach(){this.game&&this.game.deleteRenderer(this)}}d.KaylaRenderer=e;class t{current;saves;constructor(){this.saves=[]}useTick(s){if(!this.current)throw new Error("Hook 'useTick' must be executed in the top level scope of a component.");this.current.onTick[this.current.useStepCallIndex]=s,this.current.useStepCallIndex++}usePaint(s){if(!this.current)throw new Error("Hook 'usePaint' must be executed in the top level scope of a component.");this.current.onPaint[this.current.useDrawCallIndex]=s,this.current.useDrawCallIndex++}useEntity(){return k(P)}useSelf(s){let c=k(null);return(c.current===null||c.current===void 0)&&(c.current=s()),c.current}useState(s,{alwaysRecall:c=!1}={}){if(!this.current)throw new Error("Hook 'useState' must be executed in the top level scope of a component.");let h=this.current.state[this.current.useStateCallIndex]??new i(this.current,s,{alwaysRecall:c});return this.current.state[this.current.useStateCallIndex]=h,this.current.useStateCallIndex++,h}useRef(s){if(!this.current)throw new Error("Hook 'useRef' must be executed in the top level scope of a component.");let a=this.current.refs[this.current.useRefCallIndex]??new o(this.current,s??null);return this.current.refs[this.current.useRefCallIndex]=a,this.current.useRefCallIndex++,a}useEffect(s){if(!this.current)throw new Error("Hook 'useEffect' must be executed in the top level scope of a component.");this.current.onEffect[this.current.useEffectCallIndex]=s,this.current.useEffectCallIndex++}useExports(s,c){if(!this.current)throw new Error("Hook 'useExports' must be executed in the top level scope of a component.");this.current.onExport=c}save(){this.saves.push({current:this.current})}restore(){let s=this.saves.pop();if(!s)throw new Error("Cannot restore without saving.");this.current=s.current}}d.GlobalKayla=t;class r{preventDefault(){this.#e=!0}#e=!1;isPrevented(){return this.#e}}d.KaylaEvent=r;class i{#e;#t;#n;alwaysRecall;constructor(s,c,{alwaysRecall:a=!1}={}){this.#t=s,this.#e=c??void 0,this.#n=Date.now(),this.alwaysRecall=a}get(){return this.#e}add(s,{recall:c}={}){this.set(this.get()+s,{recall:c})}multiply(s,{recall:c}={}){this.set(this.get()*s,{recall:c})}set(s,{recall:c=!1}={}){let a=this.#e;s!==a&&(this.#e=s,(c||this.alwaysRecall)&&this.#t.refresh(),this.#n=Date.now())}get value(){return this.#e}get lastChanged(){return this.#n}}d.KaylaState=i;class o{#e;#t;constructor(s,c){this.#t=s,this.#e=c??void 0}get current(){return this.#e}set current(s){this.#e=s}}d.KaylaRef=o;class p{state;refs;global;callProps;scene;exports;constructor(s,c,a){if(!a)throw new Error("Empty element");this.scene=c,this.state=[],this.refs=[],this.fc=a.type,this.callProps=a.props??{},this.global=s,this.lastStateDeps=[],this.entity=null,this.lastChildren=[],this.onEffect=[],this.onUnEffect=[],this.onPaint=[],this.onTick=[]}get key(){return this.callProps.key}set key(s){this.callProps.key=s}get children(){return this.callProps.children}set children(s){this.callProps.children=s}entity;onExport=()=>({});onEffect;onUnEffect;onEffectDeps;onPaint;onTick;fc;useStateCallIndex=0;useEffectCallIndex=0;useDrawCallIndex=0;useStepCallIndex=0;useRefCallIndex=0;lastStateDeps;refresh(){let s;this.global.save(),this.global.current=this,this.useStateCallIndex=0,this.useRefCallIndex=0;let c=[];try{let a=this.fc(this.callProps)??[];if(a&&!Array.isArray(a)&&(a=[a]),!Array.isArray(a))throw new Error("Non array or non undefined children received.");c=a}catch(a){s=a}this.useStateCallIndex=0,this.useRefCallIndex=0,this.useDrawCallIndex=0,this.useStepCallIndex=0,this.useEffectCallIndex=0,this.global.restore();try{let a=0,h=[];for(let m of c){let b=this.lastChildren.at(a)??new p(this.global,this.scene,m);this.lastChildren[a]=b,h.push(b),a++}for(let m of this.lastChildren.filter(b=>!h.includes(b))){let b=this.lastChildren.indexOf(m);b!==1&&this.lastChildren.splice(b,1),m.unuse()}for(let m of this.lastChildren)try{m.refresh()}catch(b){console.error(b)}W(()=>{this.use()})}catch(a){console.error(a)}if(s)throw s}lastChildren;isFirstUse=!0;use(){try{let s=!0;if(this.lastStateDeps??=[],Array.isArray(this.onEffectDeps)&&(s=this.onEffectDeps.some((c,a)=>{let h=this.lastStateDeps.at(a);if(h){let m=c.lastChanged,b=h.stamp;return m>b}})),s||this.isFirstUse){this.isFirstUse=!1,Array.isArray(this.onEffectDeps)&&(this.lastStateDeps=this.onEffectDeps.map(a=>({stamp:a.lastChanged,stateRef:a}))),this.key??=this.fc.name+"_"+$(),this.entity&&this.scene.getScene().removeEntity(this.entity),this.entity&&this.entity.name!==this.key&&(this.entity=null),this.entity=this.entity??new f(this,this.key);for(let a of this.refs)a.current===P&&(a.current=this.entity);this.callProps.ref instanceof o&&(this.callProps.ref.current=this.entity),this.exports=this.onExport(),this.callProps.exportsRef instanceof o&&(this.callProps.exportsRef.current=this.exports),this.scene.getScene().addEntity(this.entity);let c=this.onEffect.map(a=>a()).filter(a=>a!==void 0);this.onUnEffect=c}}catch(s){throw s}}unuse(){try{for(let s of this.onUnEffect)s()}catch(s){console.error(s)}this.scene.getScene().removeEntity(this.entity)}}d.KaylaInternalComponent=p;class f extends V{#e;constructor(s,c){super(c,0,0,0,0),this.#e=s}update(s){let c=new r;if(this.#e.onTick)for(let a of this.#e.onTick)a(s,c);c.isPrevented()}draw(s){let c=new r;if(this.#e.onPaint)for(let a of this.#e.onPaint)a(s,c);c.isPrevented()||super.draw(s)}}d.KaylaRectEntity=f;class l{constructor(s){this.#t=s,this.#e=null,s.on("update",this.tickHandler.bind(this)),this.drawHandler=this.drawHandler.bind(this)}#e;#t;getScene(){return this.#t}drawHandler(s){return this.#t.handleDraw(s)}attachTo(s){s.addScene(this.#t),this.#e=s}spawn(s){new p(d.singleGlobalInstance,this,s).refresh()}detach(){this.#e&&this.#e.removeScene(this.#t)}tickHandler(){}}d.KaylaScene=l,d.singleGlobalInstance=new d.GlobalKayla})(T||={});var x=T.singleGlobalInstance,O=x.useState.bind(x),k=x.useRef.bind(x),H=x.useEffect.bind(x),ie=x.useTick.bind(x),X=x.usePaint.bind(x),ae=x.useExports.bind(x),oe=x.useSelf.bind(x),ue=x.useEntity.bind(x),P=Symbol("self_ref");var W=n=>{Promise.resolve(1).then(()=>n())},U=({children:n})=>Array.isArray(n)?[...n]:n;function le(n){return new T.KaylaRef(null,n)}Reflect.set(globalThis,"Kayla",q);var ce;(e=>e.UIComponent=({x:t,y:r,width:i,height:o,children:p})=>{let f=k(P),l=O(!1);return H(()=>{if(l.get()===!0)return;l.set(!0);let u=f.current;u.width=i,u.height=o,u.x=t,u.y=r}),X(u=>{u.fillStyle="rgba(0, 0, 0, 0.5)",u.fillRect(t,r,i,o)}),p??[]})(ce||={});function Ke(n,e,...t){if(typeof n=="string")throw new Error("Cannot use intrinsic elements.");return L(n,{...e,children:e.children??t})}function he(n,e,...t){if(typeof n=="string")throw new Error("Cannot use intrinsic elements.");return L(n,{...e,children:e.children??t})}function Re(n,e){return he(n,e)}var ke=U;export{ke as Fragment,Ke as jsx,Re as jsxDEV,he as jsxs};
@@ -0,0 +1 @@
1
+ "use strict";var G=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var ee=Object.prototype.hasOwnProperty;var $=(n,e)=>{for(var t in e)G(n,t,{get:e[t],enumerable:!0})},te=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Z(e))!ee.call(n,i)&&i!==t&&G(n,i,{get:()=>e[i],enumerable:!(r=J(e,i))||r.enumerable});return n};var ne=n=>te(G({},"__esModule",{value:!0}),n);var ve={};$(ve,{Fragment:()=>ge,jsx:()=>be,jsxDEV:()=>xe,jsxs:()=>Q});module.exports=ne(ve);var B={};$(B,{KaylaFragment:()=>q,KaylaInternals:()=>T,createElement:()=>L,createGame:()=>ue,createRenderer:()=>ce,createScene:()=>le,self:()=>P,useDisposableRef:()=>me,useEffect:()=>X,useEntity:()=>de,useExports:()=>pe,useNextStack:()=>Y,usePaint:()=>U,useRef:()=>k,useSelf:()=>fe,useState:()=>H,useTick:()=>he});var w=class{#e=new Map;constructor(){this.#e=new Map}on(e,t){let r=this.#e.get(e)||[];return r.push(t),this.#e.set(e,r),this}once(e,t){let r=(...i)=>{this.off(e,r),t(...i)};return this.on(e,r),this}off(e,t){let r=this.#e.get(e);if(!r)return this;let i=r.indexOf(t);return i>=0&&r.splice(i,1),this}emit(e,...t){let r=this.#e.get(e);if(!r||r.length===0){if(e==="error")throw t[0];return!1}return r.slice().forEach(i=>i(...t)),!0}removeAllListeners(e){return e?this.#e.delete(e):this.#e.clear(),this}listenerCount(e){return this.#e.get(e)?.length??0}},F=class extends w{canvas;ctx;running;_rafId;_fps;_frameCount;_fpsTimer;_lastFrameTime;constructor(e,{viewportWidth:t,viewportHeight:r,cameraWidth:i,cameraHeight:o}={}){if(!v)throw new Error("Web-Only");super(),this.canvas=e,this.ctx=e.getContext("2d"),this.automatic=!0,this.#e=t??e.width,this.#t=r??e.height,this.#n=i??e.width,this.#r=o??e.height,this.running=!1,this._rafId=null,this._loop=this._loop.bind(this),this.updateCanvasResolution(),this._fps=60,this._frameCount=0,this._fpsTimer=0}automatic;retransform(){this.ctx.setTransform(1,0,0,1,0,0);let e=this.#n/this.#e,t=this.#r/this.#t;this.ctx.translate(this.#n/2,this.#r/2),this.ctx.scale(e,t),this.ctx.translate(-this.#e/2,-this.#t/2)}#e=0;#t=0;#n=0;#r=0;get viewportWidth(){return this.#e}set viewportWidth(e){this.#e=e,this.retransform()}get width(){return this.#e}get height(){return this.#t}get centerX(){return this.#e/2}get centerY(){return this.#t/2}get left(){return 0}get top(){return 0}get right(){return this.#e}get bottom(){return this.#t}get viewportHeight(){return this.#t}set viewportHeight(e){this.#t=e,this.retransform()}get cameraWidth(){return this.#n}set cameraWidth(e){this.#n=e,this.updateCanvasResolution(),this.retransform()}get cameraHeight(){return this.#r}set cameraHeight(e){this.#r=e,this.updateCanvasResolution(),this.retransform()}updateCanvasResolution(){this.canvas.width=this.#n,this.canvas.height=this.#r}applyTransform(){this.retransform()}get FPS(){return this._fps}_loop(){this.automatic&&this.update(),this._rafId=requestAnimationFrame(this._loop)}update(){if(!this.running||!v)return;let e=performance.now(),t=(e-(this._lastFrameTime??e))/1e3;this._lastFrameTime=e,this._frameCount++,this._fpsTimer+=t,this._fpsTimer>=1&&(this._fps=Math.round(this._frameCount/this._fpsTimer),this._frameCount=0,this._fpsTimer=0),this.ctx.clearRect(0,0,this.#n,this.#r),this.emit("draw",this.ctx)}start(){if(!this.running){if(!v||typeof globalThis.requestAnimationFrame>"u")throw new Error("Raf is not supported");this.running=!0,this._rafId=requestAnimationFrame(this._loop)}}stop(){if(!v||typeof globalThis.requestAnimationFrame>"u")throw new Error("Raf is not supported");this.running=!1,this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null)}},N=class extends w{setNow(e){this.#e=e}#e=0;__intervalId=null;__lastTime=0;constructor(e=16){super(),this.#t=e,this.speedHackDT=1}speedHackDT;get isRaf(){return this.tickInterval===1/0}#t=15;get tickInterval(){return this.#t}set tickInterval(e){this.#t=e,this.__intervalId&&(this.stop(),this.start())}now(){return this.#e}__tick(){let e=performance.now(),t=(e-this.__lastTime)/1e3*this.speedHackDT;this.__lastTime=e,this.#e+=t*1e3,this.emit("tick",t)}createTimeout(e){return new O(e,this)}createTween(e,t=()=>{}){let r=new z(e),i=(o=0)=>{if(r.finished){this.off("tick",i);return}r.update(o)};return r.on("finish",()=>{this.off("tick",i)}),r.on("delta",o=>{t(o)}),this.on("tick",i),r}start(){this.__intervalId===null&&(this.__lastTime=performance.now(),this.__intervalId=v&&!isFinite(this.tickInterval)?ae(()=>this.__tick()).clear:setInterval(()=>this.__tick(),this.tickInterval))}stop(){this.__intervalId!==null&&(typeof this.__intervalId=="function"?this.__intervalId():clearInterval(this.__intervalId)),this.__intervalId=null}getSineMod(e,t=0){return .5+.5*Math.sin((this.now()%e/e+t)*2*Math.PI)}},re;(a=>{function n(h){return h===!0?1:0}a.booleanExport=n;function e(h){return h===0?!1:h===1}a.booleanImport=e;function t(h){return`${h.x}|${h.y}`}a.vec2Export=t;function r(h){let[m,b]=h.split("|"),E=parseFloat(m),M=parseFloat(b);if(isNaN(E)||isNaN(M))throw new Error(`Invalid Vector2 string: ${h}`);return new S(E,M)}a.vec2Import=r,a.booleanMap={mapExport:n,mapImport:e};function o(h){return m=>Number(m.toFixed(h))}a.createRounder=o;function p(h=10){return{mapExport(m){return Math.round(m/h)},mapImport(m){return m*h}}}a.createLowPrecision=p;function f(h){return Math.round(h)}a.lightWeightRounder=f;function l(h=100){return{mapExport(m){return Math.round(m*h)},mapImport(m){return m/h}}}a.createPercent=l;function u(h){let m=new Map(Object.entries(h));return{mapExport:b=>m.get(b)??null,mapImport:b=>Array.from(m.entries()).find(([E,M])=>M===b)?.[0]??null}}a.createLookup=u;function d(h){let m=h*(180/Math.PI);return Math.round((m%360+360)%360)}a.radToDeg=d;function y(h){return h*(Math.PI/180)}a.degToRad=y,a.angleRadToDeg={mapExport:d,mapImport:y};function c(h=10){let m=p(h);return{mapExport(b){return m.mapExport(d(b))},mapImport(b){return m.mapImport(y(b))}}}a.createLowPrecisionRadToDeg=c})(re||={});var K=class n extends w{name="";scaleRotate=0;scale=1;constructor(e,t=0,r=0){super(),this.autoTranslate=!1,this.name=e,this.z=0,this.___pos=new S(t,r),this.nonSerializableProperties=[],this.nonSerializableProperties.push("___pos","autoTranslate","arraySerializeMap"),this.forceSerializableProperties=[],this.forceSerializableProperties.push("x","y")}arraySerializeMap;autoTranslate;z;___pos;nonSerializableProperties;forceSerializableProperties;get pos(){return this.___pos}get x(){return this.pos.x}get y(){return this.pos.y}set x(e){this.pos.x=e}set y(e){this.pos.y=e}handleUpdate(e){if(this.update)try{this.emit("update",e),this.update(e)}catch(t){this.emit("error",t)}}handleDraw(e){if(!(D||!this.draw)){e.save(),this.autoTranslate&&e.translate(this.x,this.y);try{this.emit("draw",e),this.draw(e)}catch(t){this.emit("error",t)}e.restore()}}serialize(){if(Array.isArray(this.arraySerializeMap))return this.arraySerializeMap.map(([i,{mapExport:o}])=>{let p=Reflect.get(this,i);return o?o(p):p});let e=["_events","_eventsCount","_maxListeners","nonSerializableProperties","forceSerializableProperties"],t=[...Reflect.ownKeys(this),...this.forceSerializableProperties].filter(i=>!this.nonSerializableProperties.includes(i)&&!e.includes(i.toString())),r=Object.fromEntries(t.map(i=>{let o=Reflect.get(this,i);if(D&&typeof o=="number"){let p=o.toString().split("."),l=(p[1]?p[1].length:0)>2?Number(o.toFixed(2)):o;return[i,l]}return[i,o]}));return JSON.parse(JSON.stringify(r))}toLocal(e){return e.subtract(this.pos)}toWorld(e){return e.add(this.pos)}deserializeArray(e){return n.deserializeArray(this.arraySerializeMap,e)}static deserializeArray(e,t){if(!e||!Array.isArray(t))return t;let r={};for(let i=0;i<t.length;i++){let o=e[i];if(!o)break;let[p,{mapImport:f}]=o,l=t[i];if(f&&(l=f(l)),typeof p!="string")break;try{Reflect.set(r,p,l)}catch(u){console.error(u)}}return r}},_=class extends w{name="";entities=new Map;paused=!0;constructor(e){super(),this.name=e}handleUpdate(e){if(!this.paused){this.emit("update",e);for(let t of this.entities.values())t.handleUpdate(e)}}handleDraw(e){if(!D&&!this.paused){this.emit("draw",e);for(let t of[...this.entities.values()].sort((r,i)=>r.z-i.z))t.handleDraw(e)}}addEntity(e){if(!(e instanceof K))throw new Error("invalid entity");if(!e.name)throw new Error("Entity must have a name.");this.entities.set(e.name,e)}removeEntity(e){if(!(e instanceof K))throw new Error("invalid entity");this.entities.delete(e.name)}getEntity(e){return this.entities.get(e)}},A=class{scenes;ticker;get centerX(){return this.width/2}get centerY(){return this.height/2}get left(){return 0}get top(){return 0}get right(){return this.width}get bottom(){return this.height}width;height;constructor(e,t,r=16){this.ticker=new N(r),this.scenes=new Map,this.width=e,this.height=t,this.ticker.on("tick",i=>{for(let o of this.scenes.values())o.paused||o.handleUpdate(i)})}addScene(e){if(!e.name)throw new Error("Scene must have a name.");e.paused=!1,this.scenes.set(e.name,e)}removeScene(e){e&&(e.paused=!0),this.scenes.delete(e.name)}now(){return this.ticker.now()}start(){this.ticker.start()}stop(){this.ticker.stop()}},g={lerp(n,e,t){return n+(e-n)*t},clamp(n,e,t){return Math.min(t,Math.max(e,n))},clamp01(n){return Math.min(1,Math.max(0,n))},easeLinear(n){return n},easeInQuad(n){return n*n},easeOutQuad(n){return 1-(1-n)*(1-n)},easeInOutQuad(n){return n<.5?2*n*n:1-Math.pow(-2*n+2,2)/2},easeInSine(n){return 1-Math.cos(n*Math.PI/2)},easeOutSine(n){return Math.sin(n*Math.PI/2)},easeInOutSine(n){return-(Math.cos(Math.PI*n)-1)/2},easeInExpo(n){return n===0?0:Math.pow(2,10*n-10)},easeOutExpo(n){return n===1?1:1-Math.pow(2,-10*n)},easeInOutExpo(n){return n===0?0:n===1?1:n<.5?Math.pow(2,20*n-10)/2:(2-Math.pow(2,-20*n+10))/2},smoothstep(n){return n=g.clamp(n,0,1),n*n*(3-2*n)},randomLerp(n,e){return g.lerp(n,e,Math.random())},randomInt(n,e){return Math.floor(Math.random()*(e-n+1))+n},randomArrayValue(n){return n[g.randomInt(0,n.length-1)]},createBezier(n,e,t,r){function i(f,l,u,d,y){let s=1-f;return s*s*s*l+3*s*s*f*u+3*s*f*f*d+f*f*f*y}function o(f,l,u,d,y){let s=1-f;return 3*s*s*(u-l)+6*s*f*(d-u)+3*f*f*(y-d)}function p(f){let l=f;for(let u=0;u<6;u++){let d=i(l,0,n,t,1),y=o(l,0,n,t,1);if(y===0)break;l-=(d-f)/y}return g.clamp(l,0,1)}return function(l){l=g.clamp(l,0,1);let u=p(l);return i(u,0,e,r,1)}},lengthSquared(...n){return n.reduce((e,t)=>e+t*t,0)},normalizeRad(n){let e=2*Math.PI;return n=n%e,n<0&&(n+=e),n},angleInvertY(n){return g.normalizeRad(-n)},degToRadFlipY(n){return g.angleInvertY(n*Math.PI/180)},minimalAngularDirection(n,e){n=g.normalizeRad(n),e=g.normalizeRad(e);let t=g.normalizeRad(e-n),r=g.normalizeRad(n-e);return t<=r?1:-1}},z=class extends w{constructor({delta:e,ms:t,easing:r}){super(),this.delta=e,this.duration=t,this.elapsed=0,this.easing=r??(i=>i),this.lastValue=0,this.finished=!1}delta;duration;elapsed;lastValue;finished;easing;update(e){this.elapsed+=e*1e3;let t=g.clamp(this.elapsed/this.duration,0,1),r=this.easing(t),i=this.delta*r,o=i-this.lastValue;this.lastValue=i,this.emit("delta",o),t>=1&&(this.finished=!0,this.emit("finish",void 0))}},V=class extends K{constructor(e,t=0,r=0,i=50,o=50){super(e,t,r),this.width=i,this.height=o}width;height;get left(){return this.x-this.width/2}set left(e){this.x=e+this.width/2}get right(){return this.x+this.width/2}set right(e){this.x=e-this.width/2}get top(){return this.y-this.height/2}set top(e){this.y=e+this.height/2}get bottom(){return this.y+this.height/2}set bottom(e){this.y=e-this.height/2}get lx(){return 0}get ly(){return 0}get lleft(){return-this.width/2}get lright(){return this.width/2}get ltop(){return-this.height/2}get lbottom(){return this.height/2}isCollidingWith(e){return!(this.right<e.left||this.left>e.right||this.bottom<e.top||this.top>e.bottom)}color="rgba(0, 0, 255, 0.3)";draw(e){e.translate(this.x,this.y),e.rotate(this.scaleRotate),e.fillStyle=this.color,e.fillRect(-this.width/2,-this.height/2,this.width,this.height)}},O=class extends w{duration;ticker;elapsed;finished;_resolve;promise;_timeoutId;constructor(e,t=null){super(),this.duration=e,this.ticker=t,this.elapsed=0,this.finished=!1,this._resolve=null,this.promise=new Promise(r=>this._resolve=r),this.update=this.update.bind(this),this.ticker&&this.ticker.on("tick",this.update)}update(e=0){this.finished||(this.elapsed+=e*1e3,this.elapsed>=this.duration&&this.finish())}finish(){this.finished||(this.finished=!0,this.emit("finish",void 0),this._resolve&&this._resolve(),this.ticker&&this.ticker.off("tick",this.update))}start(){return this.ticker||(this._timeoutId=setTimeout(()=>this.finish(),this.duration)),this}cancel(){this.finished||(this.finished=!0,!this.ticker&&this._timeoutId!=null&&clearTimeout(this._timeoutId),this.ticker&&this.ticker.off("tick",this.update))}then(e,t){return this.promise.then(e,t)}after(e,t){return this.promise.then(e,t)}},S=class n{constructor(e=0,t=0){this.x=e,this.y=t}x;y;toJSON(){return{x:this.x,y:this.y,vec2:!0}}static isVec2(e){return e&&typeof e=="object"&&"x"in e&&"y"in e&&e.vec2===!0}static fromSerialized(e){return this.isVec2(e)?new this(e.x,e.y):null}rotate(e){let t=Math.cos(e),r=Math.sin(e);return new n(this.x*t-this.y*r,this.x*r+this.y*t)}static from(e){return new n(Math.cos(e),Math.sin(e))}get angle(){return Math.atan2(this.y,this.x)}get length(){return Math.hypot(this.x,this.y)}get lengthSquared(){return this.x*this.x+this.y*this.y}normalized(){let e=this.length;return e===0?new n(0,0):new n(this.x/e,this.y/e)}project(e){return e.scale(this.dotNormalized(e))}reflect(e){let t=this.dot(e);return this.subtract(e.scale(2*t))}dotNormalized(e){let t=this.normalized(),r=e.normalized();return t.x*r.x+t.y*r.y}lengthSquaredTo(e){let t=this.x-e.x,r=this.y-e.y;return t*t+r*r}dot(e){return this.x*e.x+this.y*e.y}distanceTo(e){return Math.hypot(this.x-e.x,this.y-e.y)}distanceToCheap(e){let t=this.x-e.x,r=this.y-e.y;return t*t+r*r}directionTo(e){return new n(e.x-this.x,e.y-this.y).normalized()}add(e){return new n(this.x+e.x,this.y+e.y)}addRaw(e){return new n(this.x+e,this.y+e)}overwite(e){this.x=e.x,this.y=e.y}subtract(e){return new n(this.x-e.x,this.y-e.y)}scale(e){return new n(this.x*e,this.y*e)}toString(){return`Vector2(${this.x}, ${this.y})`}clone(){return new n(this.x,this.y)}};function se(){return typeof process<"u"&&process.release?.name==="node"?"node":typeof window<"u"||typeof self<"u"?"web":"unknown"}var W=se(),D=W==="node",v=W==="web",R=class n{static unlock(){v&&this.audioCtx.state!=="running"&&this.audioCtx.resume()}static audioCtx=v?new AudioContext:null;static masterGain=v?this.audioCtx.createGain():null;static musicGain=v?this.audioCtx.createGain():null;static sfxGain=v?this.audioCtx.createGain():null;static{v&&(this.masterGain.gain.value=1,this.musicGain.gain.value=1,this.sfxGain.gain.value=1,this.sfxGain.connect(this.masterGain),this.musicGain.connect(this.masterGain),this.masterGain.connect(this.audioCtx.destination))}static get SFX_VOLUME(){return this.sfxGain.gain.value}static get MUSIC_VOLUME(){return this.musicGain.gain.value}static get VOLUME(){return this.masterGain.gain.value}static set SFX_VOLUME(e){this.sfxGain.gain.value=e}static set MUSIC_VOLUME(e){this.musicGain.gain.value=e}static set VOLUME(e){this.masterGain.gain.value=e}static noteToHz(e){return this.tuningFreq*Math.pow(2,(e-9)/12)}static tuningFreq=440;static audioBufferCache=new Map;static loops=new Map;static sfsx=new Map;static loopIdCounter=0;static CACHE_NAME="lia-audio-cache-v1";static async preLoad(e){if(this.audioBufferCache.has(e))return this.audioBufferCache.get(e);let t=n.CACHE_NAME,r,i;if(typeof caches<"u"&&(i=await caches.open(t),r=await i.match(e)),!r){if(r=await fetch(e),!r.ok)throw new Error(`Failed to fetch ${e}`);i&&await i.put(e,r.clone())}let o=await r.arrayBuffer(),p=await this.audioCtx.decodeAudioData(o);return this.audioBufferCache.set(e,p),p}static async getOnlyDownloadedCache(e){let t=n.CACHE_NAME;return await(await caches.open(t)).match(e)}static getCached(e){return this.audioBufferCache.get(e)||null}static async playSound(e,t=.2,r=1,i=!0){try{this.sfsx.has(e)&&this.sfsx.get(e).source.stop(),this.audioBufferCache.has(e)||await this.preLoad(e);let o=this.getCached(e);if(!o)return;let p=new I(o);p.buffer=o;let f=1-.12,l=1+.12;p.playbackRate=r??f+Math.random()*(l-f);let u=this.audioCtx.createGain();u.gain.value=t,p.tempGain=u,p.connect(u),u.connect(this.sfxGain),p.onended=()=>{p.disconnect(),u.disconnect()},p.start(),i&&this.sfsx.set(e,{source:p,gain:u})}catch(o){console.error(o)}}static async playLoop(e,t=1,{loopStart:r=0,loopEnd:i=null,exclusive:o=!0,skipMS:p=0}={}){if(o)for(let y of this.loops.keys())this.stopLoop(y);this.audioBufferCache.has(e)||await this.preLoad(e);let f=this.getCached(e);if(!f)return;let l=new I(f);l.buffer=f,l.loop=!0,typeof r=="number"&&(l.loopStart=r),typeof i=="number"&&(l.loopEnd=i);let u=this.audioCtx.createGain();u.gain.value=t,l.tempGain=u,l.playbackRate=1,l.onended=()=>{l.disconnect(),u.disconnect()},l.connect(u),u.connect(this.musicGain),l.start(0,p/1e3);let d=++this.loopIdCounter;return this.loops.set(d,{source:l,gain:u}),d}static stopLoop(e){let t=this.loops.get(e);t&&(t.source.stop(),t.source.notIndependent||(t.source.disconnect(),t.gain.disconnect()),this.loops.delete(e))}static async createLiaSource(e,{volume:t=1,speed:r=1,loop:i=!1,loopStart:o=0,loopEnd:p=null,isMusic:f=!1,gain:l=null}={}){try{this.audioBufferCache.has(e)||await this.preLoad(e);let u=this.getCached(e);if(!u)return null;let d=new I(u);d.loop=i,d.loopStart=o,d.loopEnd=typeof p=="number"?p:u.duration,d.playbackRate=r;let y=this.audioCtx.createGain();return y.gain.value=t,d.connect(y),d.tempGain=y,y.connect(l||(f?this.musicGain:this.sfxGain)),d.onended=()=>{d.disconnect(),y.disconnect()},d}catch(u){return console.error("Failed to create LiaAudioSrc:",u),null}}};var I=class{numberOfInputs;numberOfOutputs;constructor(e,t=R.audioCtx){this.context=t,this.buffer=e,this.source=null,this.startTime=0,this.pauseTime=0,this.playbackRate=1,this.isPlaying=!1,this.loop=!1,this.output=v?t.createGain():null,this.output.gain.value=1,this.channelCount=2,this.channelCountMode="max",this.channelInterpretation="speakers",this.numberOfInputs=0,this.numberOfOutputs=1,this.onended=null}channelCount;channelCountMode;channelInterpretation;onended;source;buffer;context;_createSource(){this.source&&(this.source.onended=null);let e=this.context.createBufferSource();return e.buffer=this.buffer,e.playbackRate.value=this.playbackRate,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd>0?this.loopEnd:this.buffer.duration,e.connect(this.output),this.source=e,e.onended=()=>{this.source===e&&(this.isPlaying&&!this.loop&&(this.isPlaying=!1,this.pauseTime=0),typeof this.onended=="function"&&this.onended())},e}play({fadeIn:e=0,offset:t=null}={}){let r=t!==null?t:this.pauseTime;if(this.source){this.source.onended=null;try{this.source.stop()}catch{}}this.source=this._createSource(),this.startTime=this.context.currentTime-r/this.playbackRate,this.source.start(0,r),e>0?(this.output.gain.setValueAtTime(0,this.context.currentTime),this.output.gain.linearRampToValueAtTime(1,this.context.currentTime+e)):this.output.gain.setValueAtTime(1,this.context.currentTime),this.isPlaying=!0}start(e=0,t=0,r){this.isPlaying||(this.source=this._createSource(),this.startTime=this.context.currentTime+e-t/this.playbackRate,r!==void 0?this.source.start(this.context.currentTime+e,t,r):this.source.start(this.context.currentTime+e,t),this.pauseTime=t,this.isPlaying=!0)}pause({fadeOut:e=0}={}){if(!this.isPlaying)return;let t=this.getElapsed()/1e3;if(this.loop&&this.loopEnd>this.loopStart){let r=this.loopEnd-this.loopStart;t=this.loopStart+(t-this.loopStart)%r}if(this.isPlaying=!1,e>0){let r=this.context.currentTime;this.output.gain.setValueAtTime(this.output.gain.value,r),this.output.gain.linearRampToValueAtTime(0,r+e),setTimeout(()=>{if(this.source){this.source.onended=null;try{this.source.stop()}catch{}}this.pauseTime=t,this.output.gain.setValueAtTime(1,this.context.currentTime)},e*1e3)}else{if(this.source){this.source.onended=null;try{this.source.stop()}catch{}}this.pauseTime=t}}getElapsed(){return this.isPlaying?(this.context.currentTime-this.startTime)*this.playbackRate*1e3:this.pauseTime*1e3}setSpeed(e){if(e<=0)throw new Error("Playback rate must be positive");let t=this.getElapsed()/1e3;this.playbackRate=e,this.isPlaying&&(this.pause(),this.pauseTime=t,this.play())}setLoop(e=!0){this.loop=e,this.source&&(this.source.loop=e)}loop;playbackRate;startTime;tempGain=null;connect(e,t=0,r=0){if("value"in e)this.output.connect(e,t);else return this.output.connect(e,t,r),e}disconnect(e,t,r){e===void 0?this.output.disconnect():this.output.disconnect(e,t,r)}output;stop(e=0){if(this.notIndependent)return this.pause();if(!this.source)return;let t=this.context.currentTime+e;this.source.stop(t),this.isPlaying=!1,this.notIndependent||(this.pauseTime=0)}pauseTime;isPlaying;notIndependent=!1;loopStart=0;loopEnd=0},ie={osc:{enabled:!0,type:"sine",freq:440,detune:0},noise:{enabled:!1,level:.5},ampEnv:{attack:.005,decay:.1,sustain:0,release:.1,volume:.3},pitchEnv:{amount:0,decay:.2},filter:{enabled:!1,type:"lowpass",freq:1200,Q:1,envAmount:0,decay:.2},lfo:{enabled:!1,target:"freq",rate:8,depth:20},duration:.4},C=class n{constructor(e={}){this.ctx=R.audioCtx,this.cfg=structuredClone(ie),Object.assign(this.cfg,e)}ctx;cfg;play(e=R.sfxGain){let t=this.ctx,r=t.currentTime,i=this.cfg,o=t.createGain();o.gain.setValueAtTime(1e-4,r);let p=i.ampEnv;o.gain.exponentialRampToValueAtTime(p.volume,r+p.attack),o.gain.exponentialRampToValueAtTime(Math.max(1e-4,p.sustain*p.volume),r+p.attack+p.decay),o.gain.exponentialRampToValueAtTime(1e-4,r+i.duration+p.release);let f=o,l;i.filter.enabled&&(l=t.createBiquadFilter(),l.type=i.filter.type,l.frequency.value=i.filter.freq,l.Q.value=i.filter.Q,l.connect(o),f=l);let u;if(i.osc.enabled){if(u=t.createOscillator(),u.type=i.osc.type,u.frequency.value=i.osc.freq,u.detune.value=i.osc.detune,i.pitchEnv.amount!==0){let h=Math.pow(2,i.pitchEnv.amount/12);u.frequency.exponentialRampToValueAtTime(i.osc.freq*h,r+i.pitchEnv.decay)}u.connect(f),u.start(r),u.stop(r+i.duration+p.release)}let d;if(i.noise.enabled){let h=t.sampleRate*i.duration,m=t.createBuffer(1,h,t.sampleRate),b=m.getChannelData(0);for(let E=0;E<h;E++)b[E]=(Math.random()*2-1)*i.noise.level;d=t.createBufferSource(),d.buffer=m,d.connect(f),d.start(r),d.stop(r+i.duration+p.release)}let y,s;i.lfo.enabled&&u&&(y=t.createOscillator(),y.frequency.value=i.lfo.rate,s=t.createGain(),s.gain.value=i.lfo.depth,y.connect(s),i.lfo.target==="freq"?s.connect(u.frequency):i.lfo.target==="gain"?s.connect(o.gain):i.lfo.target==="filter"&&l&&s.connect(l.frequency),y.start(r),y.stop(r+i.duration)),o.connect(e);let c=[u,d,y,s,l,o],a=r+i.duration+p.release;setTimeout(()=>{c.forEach(h=>h?.disconnect())},(a-t.currentTime)*1e3)}getConfig(){return structuredClone(this.cfg)}setConfig(e){return Object.assign(this.cfg,e),this}getKey(e){return this.cfg[e]}setKey(e,t){return Object.assign(this.cfg[e],t),this}setFreq(e){return this.cfg.osc.freq=e,this}setWave(e){return this.cfg.osc.type=e,this}setVolume(e){return this.cfg.ampEnv.volume=e,this}setAmpEnv(e,t,r,i){return Object.assign(this.cfg.ampEnv,{attack:e,decay:t,sustain:r,release:i}),this}setPitchEnv(e,t){return Object.assign(this.cfg.pitchEnv,{amount:e,decay:t}),this}setNoiseEnabled(e){return this.cfg.noise.enabled=e,this}setNoiseLevel(e){return this.cfg.noise.level=e,this}setFilterEnabled(e){return this.cfg.filter.enabled=e,this}setFilter(e,t,r){return Object.assign(this.cfg.filter,{type:e,freq:t,Q:r,enabled:!0}),this}setLFOEnabled(e){return this.cfg.lfo.enabled=e,this}setLFO(e,t,r){return Object.assign(this.cfg.lfo,{target:e,rate:t,depth:r,enabled:!0}),this}setDuration(e){return this.cfg.duration=e,this}clone(){return new n(structuredClone(this.cfg))}},we=new C({osc:{enabled:!0,type:"square",freq:900,detune:0},ampEnv:{attack:.002,decay:.04,sustain:0,release:.02,volume:.15},duration:.05}),Ce=new C({osc:{enabled:!0,type:"sine",freq:600,detune:0},ampEnv:{attack:.01,decay:.08,sustain:0,release:.04,volume:.12},duration:.1}),Te=new C({osc:{enabled:!0,type:"triangle",freq:500,detune:0},pitchEnv:{amount:12,decay:.15},ampEnv:{attack:.01,decay:.12,sustain:0,release:.05,volume:.25},duration:.18}),Se=new C({osc:{enabled:!0,type:"sawtooth",freq:1200,detune:0},pitchEnv:{amount:-24,decay:.3},ampEnv:{attack:.005,decay:.25,sustain:0,release:.05,volume:.3},duration:.35}),Ie=new C({osc:{enabled:!0,type:"square",freq:180,detune:0},noise:{enabled:!0,level:.4},ampEnv:{attack:.002,decay:.15,sustain:0,release:.05,volume:.35},duration:.2});function j(n=12){let e=Date.now().toString(36),t=crypto.getRandomValues(new Uint8Array(4)),r=Array.from(t).map(i=>i.toString(36).padStart(2,"0")).join("");return(e+r).slice(0,n)}function ae(n){let e=!0;function t(){e&&(n(),requestAnimationFrame(t))}return requestAnimationFrame(t),{clear:()=>e=!1}}function oe(){return D?!1:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}var Ke=oe();function ue({width:n,height:e,updateHz:t="frames"}){return new T.KaylaGame(n,e,t==="frames"?1/0:t)}function le(n){let e=new _(n);return new T.KaylaScene(e)}function ce(n){return new T.KaylaRenderer(n)}function L(n,e){return{type:n,props:e}}var T;(d=>{class n extends A{#e;#t;constructor(s,c,a){super(s,c,a),this.#e=new Set,this.#t=!1}get started(){return this.#t}start(){if(!this.#t){for(let s of this.#e)s.start();this.#t=!0,super.start()}}stop(){if(this.#t){for(let s of this.#e)s.stop();this.#t=!1,super.stop()}}addRenderer(s){this.#e.has(s)||(this.#e.add(s),this.#t&&s.start(),s.game=this)}deleteRenderer(s){this.#e.has(s)&&(this.#e.delete(s),this.#t&&s.stop(),delete s.game)}}d.KaylaGame=n;class e extends F{game;pointerX;pointerY;#e;constructor(s){super(s),this.useDraw=this.useDraw.bind(this),this.on("draw",c=>{if(this.game)for(let a of this.game.scenes.values())a.handleDraw(c)}),this.pointerX=0,this.pointerY=0,this.#e=this.#t.bind(this)}#t(s){this.pointerX=s.clientX,this.pointerY=s.clientY}listenPointerUpdates(){this.canvas.addEventListener("pointermove",this.#e)}unlistenPointerUpdates(){this.canvas.removeEventListener("pointermove",this.#e)}pointerPosToWorldPos(s,c){let a=this.canvas.getBoundingClientRect(),h=(s-a.left)/a.width,m=(c-a.top)/a.height,b=h*this.viewportWidth*this.cameraWidth/a.width,E=m*this.viewportHeight*this.cameraHeight/a.height;return new S(b,E)}getMousePos(){return this.pointerPosToWorldPos(this.pointerX,this.pointerY)}useDraw(s){let c=a=>{s(a,new r)};return this.on("draw",c),()=>{this.off("draw",c)}}attachTo(s){s.addRenderer(this),this.game=s}detach(){this.game&&this.game.deleteRenderer(this)}}d.KaylaRenderer=e;class t{current;saves;constructor(){this.saves=[]}useTick(s){if(!this.current)throw new Error("Hook 'useTick' must be executed in the top level scope of a component.");this.current.onTick[this.current.useStepCallIndex]=s,this.current.useStepCallIndex++}usePaint(s){if(!this.current)throw new Error("Hook 'usePaint' must be executed in the top level scope of a component.");this.current.onPaint[this.current.useDrawCallIndex]=s,this.current.useDrawCallIndex++}useEntity(){return k(P)}useSelf(s){let c=k(null);return(c.current===null||c.current===void 0)&&(c.current=s()),c.current}useState(s,{alwaysRecall:c=!1}={}){if(!this.current)throw new Error("Hook 'useState' must be executed in the top level scope of a component.");let h=this.current.state[this.current.useStateCallIndex]??new i(this.current,s,{alwaysRecall:c});return this.current.state[this.current.useStateCallIndex]=h,this.current.useStateCallIndex++,h}useRef(s){if(!this.current)throw new Error("Hook 'useRef' must be executed in the top level scope of a component.");let a=this.current.refs[this.current.useRefCallIndex]??new o(this.current,s??null);return this.current.refs[this.current.useRefCallIndex]=a,this.current.useRefCallIndex++,a}useEffect(s){if(!this.current)throw new Error("Hook 'useEffect' must be executed in the top level scope of a component.");this.current.onEffect[this.current.useEffectCallIndex]=s,this.current.useEffectCallIndex++}useExports(s,c){if(!this.current)throw new Error("Hook 'useExports' must be executed in the top level scope of a component.");this.current.onExport=c}save(){this.saves.push({current:this.current})}restore(){let s=this.saves.pop();if(!s)throw new Error("Cannot restore without saving.");this.current=s.current}}d.GlobalKayla=t;class r{preventDefault(){this.#e=!0}#e=!1;isPrevented(){return this.#e}}d.KaylaEvent=r;class i{#e;#t;#n;alwaysRecall;constructor(s,c,{alwaysRecall:a=!1}={}){this.#t=s,this.#e=c??void 0,this.#n=Date.now(),this.alwaysRecall=a}get(){return this.#e}add(s,{recall:c}={}){this.set(this.get()+s,{recall:c})}multiply(s,{recall:c}={}){this.set(this.get()*s,{recall:c})}set(s,{recall:c=!1}={}){let a=this.#e;s!==a&&(this.#e=s,(c||this.alwaysRecall)&&this.#t.refresh(),this.#n=Date.now())}get value(){return this.#e}get lastChanged(){return this.#n}}d.KaylaState=i;class o{#e;#t;constructor(s,c){this.#t=s,this.#e=c??void 0}get current(){return this.#e}set current(s){this.#e=s}}d.KaylaRef=o;class p{state;refs;global;callProps;scene;exports;constructor(s,c,a){if(!a)throw new Error("Empty element");this.scene=c,this.state=[],this.refs=[],this.fc=a.type,this.callProps=a.props??{},this.global=s,this.lastStateDeps=[],this.entity=null,this.lastChildren=[],this.onEffect=[],this.onUnEffect=[],this.onPaint=[],this.onTick=[]}get key(){return this.callProps.key}set key(s){this.callProps.key=s}get children(){return this.callProps.children}set children(s){this.callProps.children=s}entity;onExport=()=>({});onEffect;onUnEffect;onEffectDeps;onPaint;onTick;fc;useStateCallIndex=0;useEffectCallIndex=0;useDrawCallIndex=0;useStepCallIndex=0;useRefCallIndex=0;lastStateDeps;refresh(){let s;this.global.save(),this.global.current=this,this.useStateCallIndex=0,this.useRefCallIndex=0;let c=[];try{let a=this.fc(this.callProps)??[];if(a&&!Array.isArray(a)&&(a=[a]),!Array.isArray(a))throw new Error("Non array or non undefined children received.");c=a}catch(a){s=a}this.useStateCallIndex=0,this.useRefCallIndex=0,this.useDrawCallIndex=0,this.useStepCallIndex=0,this.useEffectCallIndex=0,this.global.restore();try{let a=0,h=[];for(let m of c){let b=this.lastChildren.at(a)??new p(this.global,this.scene,m);this.lastChildren[a]=b,h.push(b),a++}for(let m of this.lastChildren.filter(b=>!h.includes(b))){let b=this.lastChildren.indexOf(m);b!==1&&this.lastChildren.splice(b,1),m.unuse()}for(let m of this.lastChildren)try{m.refresh()}catch(b){console.error(b)}Y(()=>{this.use()})}catch(a){console.error(a)}if(s)throw s}lastChildren;isFirstUse=!0;use(){try{let s=!0;if(this.lastStateDeps??=[],Array.isArray(this.onEffectDeps)&&(s=this.onEffectDeps.some((c,a)=>{let h=this.lastStateDeps.at(a);if(h){let m=c.lastChanged,b=h.stamp;return m>b}})),s||this.isFirstUse){this.isFirstUse=!1,Array.isArray(this.onEffectDeps)&&(this.lastStateDeps=this.onEffectDeps.map(a=>({stamp:a.lastChanged,stateRef:a}))),this.key??=this.fc.name+"_"+j(),this.entity&&this.scene.getScene().removeEntity(this.entity),this.entity&&this.entity.name!==this.key&&(this.entity=null),this.entity=this.entity??new f(this,this.key);for(let a of this.refs)a.current===P&&(a.current=this.entity);this.callProps.ref instanceof o&&(this.callProps.ref.current=this.entity),this.exports=this.onExport(),this.callProps.exportsRef instanceof o&&(this.callProps.exportsRef.current=this.exports),this.scene.getScene().addEntity(this.entity);let c=this.onEffect.map(a=>a()).filter(a=>a!==void 0);this.onUnEffect=c}}catch(s){throw s}}unuse(){try{for(let s of this.onUnEffect)s()}catch(s){console.error(s)}this.scene.getScene().removeEntity(this.entity)}}d.KaylaInternalComponent=p;class f extends V{#e;constructor(s,c){super(c,0,0,0,0),this.#e=s}update(s){let c=new r;if(this.#e.onTick)for(let a of this.#e.onTick)a(s,c);c.isPrevented()}draw(s){let c=new r;if(this.#e.onPaint)for(let a of this.#e.onPaint)a(s,c);c.isPrevented()||super.draw(s)}}d.KaylaRectEntity=f;class l{constructor(s){this.#t=s,this.#e=null,s.on("update",this.tickHandler.bind(this)),this.drawHandler=this.drawHandler.bind(this)}#e;#t;getScene(){return this.#t}drawHandler(s){return this.#t.handleDraw(s)}attachTo(s){s.addScene(this.#t),this.#e=s}spawn(s){new p(d.singleGlobalInstance,this,s).refresh()}detach(){this.#e&&this.#e.removeScene(this.#t)}tickHandler(){}}d.KaylaScene=l,d.singleGlobalInstance=new d.GlobalKayla})(T||={});var x=T.singleGlobalInstance,H=x.useState.bind(x),k=x.useRef.bind(x),X=x.useEffect.bind(x),he=x.useTick.bind(x),U=x.usePaint.bind(x),pe=x.useExports.bind(x),fe=x.useSelf.bind(x),de=x.useEntity.bind(x),P=Symbol("self_ref");var Y=n=>{Promise.resolve(1).then(()=>n())},q=({children:n})=>Array.isArray(n)?[...n]:n;function me(n){return new T.KaylaRef(null,n)}Reflect.set(globalThis,"Kayla",B);var ye;(e=>e.UIComponent=({x:t,y:r,width:i,height:o,children:p})=>{let f=k(P),l=H(!1);return X(()=>{if(l.get()===!0)return;l.set(!0);let u=f.current;u.width=i,u.height=o,u.x=t,u.y=r}),U(u=>{u.fillStyle="rgba(0, 0, 0, 0.5)",u.fillRect(t,r,i,o)}),p??[]})(ye||={});function be(n,e,...t){if(typeof n=="string")throw new Error("Cannot use intrinsic elements.");return L(n,{...e,children:e.children??t})}function Q(n,e,...t){if(typeof n=="string")throw new Error("Cannot use intrinsic elements.");return L(n,{...e,children:e.children??t})}function xe(n,e){return Q(n,e)}var ge=q;0&&(module.exports={Fragment,jsx,jsxDEV,jsxs});
@@ -0,0 +1,15 @@
1
+ import { a as FC, F as FCProps, d as KaylaExportables, K as KaylaElement } from './kayla-internals-DvV9K1wf.cjs';
2
+ import './lea-DvxsutSf.cjs';
3
+
4
+ /**
5
+ * jsx stuff
6
+ */
7
+ declare function jsx(type: string | FC, props: any, ...children: any[]): KaylaElement<any>;
8
+ /**
9
+ * jsx stuff
10
+ */
11
+ declare function jsxs(type: string | FC, props: any, ...children: any[]): KaylaElement<any>;
12
+ declare function jsxDEV(type: string | FC, props: any): KaylaElement<any>;
13
+ declare const Fragment: FC<FCProps, Record<string, KaylaExportables>>;
14
+
15
+ export { Fragment, jsx, jsxDEV, jsxs };
@@ -0,0 +1,15 @@
1
+ import { a as FC, F as FCProps, d as KaylaExportables, K as KaylaElement } from './kayla-internals-ClSuOWZb.js';
2
+ import './lea-DvxsutSf.js';
3
+
4
+ /**
5
+ * jsx stuff
6
+ */
7
+ declare function jsx(type: string | FC, props: any, ...children: any[]): KaylaElement<any>;
8
+ /**
9
+ * jsx stuff
10
+ */
11
+ declare function jsxs(type: string | FC, props: any, ...children: any[]): KaylaElement<any>;
12
+ declare function jsxDEV(type: string | FC, props: any): KaylaElement<any>;
13
+ declare const Fragment: FC<FCProps, Record<string, KaylaExportables>>;
14
+
15
+ export { Fragment, jsx, jsxDEV, jsxs };
@@ -0,0 +1 @@
1
+ var j=Object.defineProperty;var Y=(n,e)=>{for(var t in e)j(n,t,{get:e[t],enumerable:!0})};var q={};Y(q,{KaylaFragment:()=>U,KaylaInternals:()=>T,createElement:()=>L,createGame:()=>ne,createRenderer:()=>se,createScene:()=>re,self:()=>P,useDisposableRef:()=>le,useEffect:()=>H,useEntity:()=>ue,useExports:()=>ae,useNextStack:()=>W,usePaint:()=>X,useRef:()=>k,useSelf:()=>oe,useState:()=>O,useTick:()=>ie});var w=class{#e=new Map;constructor(){this.#e=new Map}on(e,t){let r=this.#e.get(e)||[];return r.push(t),this.#e.set(e,r),this}once(e,t){let r=(...i)=>{this.off(e,r),t(...i)};return this.on(e,r),this}off(e,t){let r=this.#e.get(e);if(!r)return this;let i=r.indexOf(t);return i>=0&&r.splice(i,1),this}emit(e,...t){let r=this.#e.get(e);if(!r||r.length===0){if(e==="error")throw t[0];return!1}return r.slice().forEach(i=>i(...t)),!0}removeAllListeners(e){return e?this.#e.delete(e):this.#e.clear(),this}listenerCount(e){return this.#e.get(e)?.length??0}},F=class extends w{canvas;ctx;running;_rafId;_fps;_frameCount;_fpsTimer;_lastFrameTime;constructor(e,{viewportWidth:t,viewportHeight:r,cameraWidth:i,cameraHeight:o}={}){if(!v)throw new Error("Web-Only");super(),this.canvas=e,this.ctx=e.getContext("2d"),this.automatic=!0,this.#e=t??e.width,this.#t=r??e.height,this.#n=i??e.width,this.#r=o??e.height,this.running=!1,this._rafId=null,this._loop=this._loop.bind(this),this.updateCanvasResolution(),this._fps=60,this._frameCount=0,this._fpsTimer=0}automatic;retransform(){this.ctx.setTransform(1,0,0,1,0,0);let e=this.#n/this.#e,t=this.#r/this.#t;this.ctx.translate(this.#n/2,this.#r/2),this.ctx.scale(e,t),this.ctx.translate(-this.#e/2,-this.#t/2)}#e=0;#t=0;#n=0;#r=0;get viewportWidth(){return this.#e}set viewportWidth(e){this.#e=e,this.retransform()}get width(){return this.#e}get height(){return this.#t}get centerX(){return this.#e/2}get centerY(){return this.#t/2}get left(){return 0}get top(){return 0}get right(){return this.#e}get bottom(){return this.#t}get viewportHeight(){return this.#t}set viewportHeight(e){this.#t=e,this.retransform()}get cameraWidth(){return this.#n}set cameraWidth(e){this.#n=e,this.updateCanvasResolution(),this.retransform()}get cameraHeight(){return this.#r}set cameraHeight(e){this.#r=e,this.updateCanvasResolution(),this.retransform()}updateCanvasResolution(){this.canvas.width=this.#n,this.canvas.height=this.#r}applyTransform(){this.retransform()}get FPS(){return this._fps}_loop(){this.automatic&&this.update(),this._rafId=requestAnimationFrame(this._loop)}update(){if(!this.running||!v)return;let e=performance.now(),t=(e-(this._lastFrameTime??e))/1e3;this._lastFrameTime=e,this._frameCount++,this._fpsTimer+=t,this._fpsTimer>=1&&(this._fps=Math.round(this._frameCount/this._fpsTimer),this._frameCount=0,this._fpsTimer=0),this.ctx.clearRect(0,0,this.#n,this.#r),this.emit("draw",this.ctx)}start(){if(!this.running){if(!v||typeof globalThis.requestAnimationFrame>"u")throw new Error("Raf is not supported");this.running=!0,this._rafId=requestAnimationFrame(this._loop)}}stop(){if(!v||typeof globalThis.requestAnimationFrame>"u")throw new Error("Raf is not supported");this.running=!1,this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null)}},G=class extends w{setNow(e){this.#e=e}#e=0;__intervalId=null;__lastTime=0;constructor(e=16){super(),this.#t=e,this.speedHackDT=1}speedHackDT;get isRaf(){return this.tickInterval===1/0}#t=15;get tickInterval(){return this.#t}set tickInterval(e){this.#t=e,this.__intervalId&&(this.stop(),this.start())}now(){return this.#e}__tick(){let e=performance.now(),t=(e-this.__lastTime)/1e3*this.speedHackDT;this.__lastTime=e,this.#e+=t*1e3,this.emit("tick",t)}createTimeout(e){return new z(e,this)}createTween(e,t=()=>{}){let r=new N(e),i=(o=0)=>{if(r.finished){this.off("tick",i);return}r.update(o)};return r.on("finish",()=>{this.off("tick",i)}),r.on("delta",o=>{t(o)}),this.on("tick",i),r}start(){this.__intervalId===null&&(this.__lastTime=performance.now(),this.__intervalId=v&&!isFinite(this.tickInterval)?ee(()=>this.__tick()).clear:setInterval(()=>this.__tick(),this.tickInterval))}stop(){this.__intervalId!==null&&(typeof this.__intervalId=="function"?this.__intervalId():clearInterval(this.__intervalId)),this.__intervalId=null}getSineMod(e,t=0){return .5+.5*Math.sin((this.now()%e/e+t)*2*Math.PI)}},Q;(a=>{function n(h){return h===!0?1:0}a.booleanExport=n;function e(h){return h===0?!1:h===1}a.booleanImport=e;function t(h){return`${h.x}|${h.y}`}a.vec2Export=t;function r(h){let[m,b]=h.split("|"),E=parseFloat(m),M=parseFloat(b);if(isNaN(E)||isNaN(M))throw new Error(`Invalid Vector2 string: ${h}`);return new S(E,M)}a.vec2Import=r,a.booleanMap={mapExport:n,mapImport:e};function o(h){return m=>Number(m.toFixed(h))}a.createRounder=o;function p(h=10){return{mapExport(m){return Math.round(m/h)},mapImport(m){return m*h}}}a.createLowPrecision=p;function f(h){return Math.round(h)}a.lightWeightRounder=f;function l(h=100){return{mapExport(m){return Math.round(m*h)},mapImport(m){return m/h}}}a.createPercent=l;function u(h){let m=new Map(Object.entries(h));return{mapExport:b=>m.get(b)??null,mapImport:b=>Array.from(m.entries()).find(([E,M])=>M===b)?.[0]??null}}a.createLookup=u;function d(h){let m=h*(180/Math.PI);return Math.round((m%360+360)%360)}a.radToDeg=d;function y(h){return h*(Math.PI/180)}a.degToRad=y,a.angleRadToDeg={mapExport:d,mapImport:y};function c(h=10){let m=p(h);return{mapExport(b){return m.mapExport(d(b))},mapImport(b){return m.mapImport(y(b))}}}a.createLowPrecisionRadToDeg=c})(Q||={});var K=class n extends w{name="";scaleRotate=0;scale=1;constructor(e,t=0,r=0){super(),this.autoTranslate=!1,this.name=e,this.z=0,this.___pos=new S(t,r),this.nonSerializableProperties=[],this.nonSerializableProperties.push("___pos","autoTranslate","arraySerializeMap"),this.forceSerializableProperties=[],this.forceSerializableProperties.push("x","y")}arraySerializeMap;autoTranslate;z;___pos;nonSerializableProperties;forceSerializableProperties;get pos(){return this.___pos}get x(){return this.pos.x}get y(){return this.pos.y}set x(e){this.pos.x=e}set y(e){this.pos.y=e}handleUpdate(e){if(this.update)try{this.emit("update",e),this.update(e)}catch(t){this.emit("error",t)}}handleDraw(e){if(!(D||!this.draw)){e.save(),this.autoTranslate&&e.translate(this.x,this.y);try{this.emit("draw",e),this.draw(e)}catch(t){this.emit("error",t)}e.restore()}}serialize(){if(Array.isArray(this.arraySerializeMap))return this.arraySerializeMap.map(([i,{mapExport:o}])=>{let p=Reflect.get(this,i);return o?o(p):p});let e=["_events","_eventsCount","_maxListeners","nonSerializableProperties","forceSerializableProperties"],t=[...Reflect.ownKeys(this),...this.forceSerializableProperties].filter(i=>!this.nonSerializableProperties.includes(i)&&!e.includes(i.toString())),r=Object.fromEntries(t.map(i=>{let o=Reflect.get(this,i);if(D&&typeof o=="number"){let p=o.toString().split("."),l=(p[1]?p[1].length:0)>2?Number(o.toFixed(2)):o;return[i,l]}return[i,o]}));return JSON.parse(JSON.stringify(r))}toLocal(e){return e.subtract(this.pos)}toWorld(e){return e.add(this.pos)}deserializeArray(e){return n.deserializeArray(this.arraySerializeMap,e)}static deserializeArray(e,t){if(!e||!Array.isArray(t))return t;let r={};for(let i=0;i<t.length;i++){let o=e[i];if(!o)break;let[p,{mapImport:f}]=o,l=t[i];if(f&&(l=f(l)),typeof p!="string")break;try{Reflect.set(r,p,l)}catch(u){console.error(u)}}return r}},_=class extends w{name="";entities=new Map;paused=!0;constructor(e){super(),this.name=e}handleUpdate(e){if(!this.paused){this.emit("update",e);for(let t of this.entities.values())t.handleUpdate(e)}}handleDraw(e){if(!D&&!this.paused){this.emit("draw",e);for(let t of[...this.entities.values()].sort((r,i)=>r.z-i.z))t.handleDraw(e)}}addEntity(e){if(!(e instanceof K))throw new Error("invalid entity");if(!e.name)throw new Error("Entity must have a name.");this.entities.set(e.name,e)}removeEntity(e){if(!(e instanceof K))throw new Error("invalid entity");this.entities.delete(e.name)}getEntity(e){return this.entities.get(e)}},A=class{scenes;ticker;get centerX(){return this.width/2}get centerY(){return this.height/2}get left(){return 0}get top(){return 0}get right(){return this.width}get bottom(){return this.height}width;height;constructor(e,t,r=16){this.ticker=new G(r),this.scenes=new Map,this.width=e,this.height=t,this.ticker.on("tick",i=>{for(let o of this.scenes.values())o.paused||o.handleUpdate(i)})}addScene(e){if(!e.name)throw new Error("Scene must have a name.");e.paused=!1,this.scenes.set(e.name,e)}removeScene(e){e&&(e.paused=!0),this.scenes.delete(e.name)}now(){return this.ticker.now()}start(){this.ticker.start()}stop(){this.ticker.stop()}},g={lerp(n,e,t){return n+(e-n)*t},clamp(n,e,t){return Math.min(t,Math.max(e,n))},clamp01(n){return Math.min(1,Math.max(0,n))},easeLinear(n){return n},easeInQuad(n){return n*n},easeOutQuad(n){return 1-(1-n)*(1-n)},easeInOutQuad(n){return n<.5?2*n*n:1-Math.pow(-2*n+2,2)/2},easeInSine(n){return 1-Math.cos(n*Math.PI/2)},easeOutSine(n){return Math.sin(n*Math.PI/2)},easeInOutSine(n){return-(Math.cos(Math.PI*n)-1)/2},easeInExpo(n){return n===0?0:Math.pow(2,10*n-10)},easeOutExpo(n){return n===1?1:1-Math.pow(2,-10*n)},easeInOutExpo(n){return n===0?0:n===1?1:n<.5?Math.pow(2,20*n-10)/2:(2-Math.pow(2,-20*n+10))/2},smoothstep(n){return n=g.clamp(n,0,1),n*n*(3-2*n)},randomLerp(n,e){return g.lerp(n,e,Math.random())},randomInt(n,e){return Math.floor(Math.random()*(e-n+1))+n},randomArrayValue(n){return n[g.randomInt(0,n.length-1)]},createBezier(n,e,t,r){function i(f,l,u,d,y){let s=1-f;return s*s*s*l+3*s*s*f*u+3*s*f*f*d+f*f*f*y}function o(f,l,u,d,y){let s=1-f;return 3*s*s*(u-l)+6*s*f*(d-u)+3*f*f*(y-d)}function p(f){let l=f;for(let u=0;u<6;u++){let d=i(l,0,n,t,1),y=o(l,0,n,t,1);if(y===0)break;l-=(d-f)/y}return g.clamp(l,0,1)}return function(l){l=g.clamp(l,0,1);let u=p(l);return i(u,0,e,r,1)}},lengthSquared(...n){return n.reduce((e,t)=>e+t*t,0)},normalizeRad(n){let e=2*Math.PI;return n=n%e,n<0&&(n+=e),n},angleInvertY(n){return g.normalizeRad(-n)},degToRadFlipY(n){return g.angleInvertY(n*Math.PI/180)},minimalAngularDirection(n,e){n=g.normalizeRad(n),e=g.normalizeRad(e);let t=g.normalizeRad(e-n),r=g.normalizeRad(n-e);return t<=r?1:-1}},N=class extends w{constructor({delta:e,ms:t,easing:r}){super(),this.delta=e,this.duration=t,this.elapsed=0,this.easing=r??(i=>i),this.lastValue=0,this.finished=!1}delta;duration;elapsed;lastValue;finished;easing;update(e){this.elapsed+=e*1e3;let t=g.clamp(this.elapsed/this.duration,0,1),r=this.easing(t),i=this.delta*r,o=i-this.lastValue;this.lastValue=i,this.emit("delta",o),t>=1&&(this.finished=!0,this.emit("finish",void 0))}},V=class extends K{constructor(e,t=0,r=0,i=50,o=50){super(e,t,r),this.width=i,this.height=o}width;height;get left(){return this.x-this.width/2}set left(e){this.x=e+this.width/2}get right(){return this.x+this.width/2}set right(e){this.x=e-this.width/2}get top(){return this.y-this.height/2}set top(e){this.y=e+this.height/2}get bottom(){return this.y+this.height/2}set bottom(e){this.y=e-this.height/2}get lx(){return 0}get ly(){return 0}get lleft(){return-this.width/2}get lright(){return this.width/2}get ltop(){return-this.height/2}get lbottom(){return this.height/2}isCollidingWith(e){return!(this.right<e.left||this.left>e.right||this.bottom<e.top||this.top>e.bottom)}color="rgba(0, 0, 255, 0.3)";draw(e){e.translate(this.x,this.y),e.rotate(this.scaleRotate),e.fillStyle=this.color,e.fillRect(-this.width/2,-this.height/2,this.width,this.height)}},z=class extends w{duration;ticker;elapsed;finished;_resolve;promise;_timeoutId;constructor(e,t=null){super(),this.duration=e,this.ticker=t,this.elapsed=0,this.finished=!1,this._resolve=null,this.promise=new Promise(r=>this._resolve=r),this.update=this.update.bind(this),this.ticker&&this.ticker.on("tick",this.update)}update(e=0){this.finished||(this.elapsed+=e*1e3,this.elapsed>=this.duration&&this.finish())}finish(){this.finished||(this.finished=!0,this.emit("finish",void 0),this._resolve&&this._resolve(),this.ticker&&this.ticker.off("tick",this.update))}start(){return this.ticker||(this._timeoutId=setTimeout(()=>this.finish(),this.duration)),this}cancel(){this.finished||(this.finished=!0,!this.ticker&&this._timeoutId!=null&&clearTimeout(this._timeoutId),this.ticker&&this.ticker.off("tick",this.update))}then(e,t){return this.promise.then(e,t)}after(e,t){return this.promise.then(e,t)}},S=class n{constructor(e=0,t=0){this.x=e,this.y=t}x;y;toJSON(){return{x:this.x,y:this.y,vec2:!0}}static isVec2(e){return e&&typeof e=="object"&&"x"in e&&"y"in e&&e.vec2===!0}static fromSerialized(e){return this.isVec2(e)?new this(e.x,e.y):null}rotate(e){let t=Math.cos(e),r=Math.sin(e);return new n(this.x*t-this.y*r,this.x*r+this.y*t)}static from(e){return new n(Math.cos(e),Math.sin(e))}get angle(){return Math.atan2(this.y,this.x)}get length(){return Math.hypot(this.x,this.y)}get lengthSquared(){return this.x*this.x+this.y*this.y}normalized(){let e=this.length;return e===0?new n(0,0):new n(this.x/e,this.y/e)}project(e){return e.scale(this.dotNormalized(e))}reflect(e){let t=this.dot(e);return this.subtract(e.scale(2*t))}dotNormalized(e){let t=this.normalized(),r=e.normalized();return t.x*r.x+t.y*r.y}lengthSquaredTo(e){let t=this.x-e.x,r=this.y-e.y;return t*t+r*r}dot(e){return this.x*e.x+this.y*e.y}distanceTo(e){return Math.hypot(this.x-e.x,this.y-e.y)}distanceToCheap(e){let t=this.x-e.x,r=this.y-e.y;return t*t+r*r}directionTo(e){return new n(e.x-this.x,e.y-this.y).normalized()}add(e){return new n(this.x+e.x,this.y+e.y)}addRaw(e){return new n(this.x+e,this.y+e)}overwite(e){this.x=e.x,this.y=e.y}subtract(e){return new n(this.x-e.x,this.y-e.y)}scale(e){return new n(this.x*e,this.y*e)}toString(){return`Vector2(${this.x}, ${this.y})`}clone(){return new n(this.x,this.y)}};function J(){return typeof process<"u"&&process.release?.name==="node"?"node":typeof window<"u"||typeof self<"u"?"web":"unknown"}var B=J(),D=B==="node",v=B==="web",R=class n{static unlock(){v&&this.audioCtx.state!=="running"&&this.audioCtx.resume()}static audioCtx=v?new AudioContext:null;static masterGain=v?this.audioCtx.createGain():null;static musicGain=v?this.audioCtx.createGain():null;static sfxGain=v?this.audioCtx.createGain():null;static{v&&(this.masterGain.gain.value=1,this.musicGain.gain.value=1,this.sfxGain.gain.value=1,this.sfxGain.connect(this.masterGain),this.musicGain.connect(this.masterGain),this.masterGain.connect(this.audioCtx.destination))}static get SFX_VOLUME(){return this.sfxGain.gain.value}static get MUSIC_VOLUME(){return this.musicGain.gain.value}static get VOLUME(){return this.masterGain.gain.value}static set SFX_VOLUME(e){this.sfxGain.gain.value=e}static set MUSIC_VOLUME(e){this.musicGain.gain.value=e}static set VOLUME(e){this.masterGain.gain.value=e}static noteToHz(e){return this.tuningFreq*Math.pow(2,(e-9)/12)}static tuningFreq=440;static audioBufferCache=new Map;static loops=new Map;static sfsx=new Map;static loopIdCounter=0;static CACHE_NAME="lia-audio-cache-v1";static async preLoad(e){if(this.audioBufferCache.has(e))return this.audioBufferCache.get(e);let t=n.CACHE_NAME,r,i;if(typeof caches<"u"&&(i=await caches.open(t),r=await i.match(e)),!r){if(r=await fetch(e),!r.ok)throw new Error(`Failed to fetch ${e}`);i&&await i.put(e,r.clone())}let o=await r.arrayBuffer(),p=await this.audioCtx.decodeAudioData(o);return this.audioBufferCache.set(e,p),p}static async getOnlyDownloadedCache(e){let t=n.CACHE_NAME;return await(await caches.open(t)).match(e)}static getCached(e){return this.audioBufferCache.get(e)||null}static async playSound(e,t=.2,r=1,i=!0){try{this.sfsx.has(e)&&this.sfsx.get(e).source.stop(),this.audioBufferCache.has(e)||await this.preLoad(e);let o=this.getCached(e);if(!o)return;let p=new I(o);p.buffer=o;let f=1-.12,l=1+.12;p.playbackRate=r??f+Math.random()*(l-f);let u=this.audioCtx.createGain();u.gain.value=t,p.tempGain=u,p.connect(u),u.connect(this.sfxGain),p.onended=()=>{p.disconnect(),u.disconnect()},p.start(),i&&this.sfsx.set(e,{source:p,gain:u})}catch(o){console.error(o)}}static async playLoop(e,t=1,{loopStart:r=0,loopEnd:i=null,exclusive:o=!0,skipMS:p=0}={}){if(o)for(let y of this.loops.keys())this.stopLoop(y);this.audioBufferCache.has(e)||await this.preLoad(e);let f=this.getCached(e);if(!f)return;let l=new I(f);l.buffer=f,l.loop=!0,typeof r=="number"&&(l.loopStart=r),typeof i=="number"&&(l.loopEnd=i);let u=this.audioCtx.createGain();u.gain.value=t,l.tempGain=u,l.playbackRate=1,l.onended=()=>{l.disconnect(),u.disconnect()},l.connect(u),u.connect(this.musicGain),l.start(0,p/1e3);let d=++this.loopIdCounter;return this.loops.set(d,{source:l,gain:u}),d}static stopLoop(e){let t=this.loops.get(e);t&&(t.source.stop(),t.source.notIndependent||(t.source.disconnect(),t.gain.disconnect()),this.loops.delete(e))}static async createLiaSource(e,{volume:t=1,speed:r=1,loop:i=!1,loopStart:o=0,loopEnd:p=null,isMusic:f=!1,gain:l=null}={}){try{this.audioBufferCache.has(e)||await this.preLoad(e);let u=this.getCached(e);if(!u)return null;let d=new I(u);d.loop=i,d.loopStart=o,d.loopEnd=typeof p=="number"?p:u.duration,d.playbackRate=r;let y=this.audioCtx.createGain();return y.gain.value=t,d.connect(y),d.tempGain=y,y.connect(l||(f?this.musicGain:this.sfxGain)),d.onended=()=>{d.disconnect(),y.disconnect()},d}catch(u){return console.error("Failed to create LiaAudioSrc:",u),null}}};var I=class{numberOfInputs;numberOfOutputs;constructor(e,t=R.audioCtx){this.context=t,this.buffer=e,this.source=null,this.startTime=0,this.pauseTime=0,this.playbackRate=1,this.isPlaying=!1,this.loop=!1,this.output=v?t.createGain():null,this.output.gain.value=1,this.channelCount=2,this.channelCountMode="max",this.channelInterpretation="speakers",this.numberOfInputs=0,this.numberOfOutputs=1,this.onended=null}channelCount;channelCountMode;channelInterpretation;onended;source;buffer;context;_createSource(){this.source&&(this.source.onended=null);let e=this.context.createBufferSource();return e.buffer=this.buffer,e.playbackRate.value=this.playbackRate,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd>0?this.loopEnd:this.buffer.duration,e.connect(this.output),this.source=e,e.onended=()=>{this.source===e&&(this.isPlaying&&!this.loop&&(this.isPlaying=!1,this.pauseTime=0),typeof this.onended=="function"&&this.onended())},e}play({fadeIn:e=0,offset:t=null}={}){let r=t!==null?t:this.pauseTime;if(this.source){this.source.onended=null;try{this.source.stop()}catch{}}this.source=this._createSource(),this.startTime=this.context.currentTime-r/this.playbackRate,this.source.start(0,r),e>0?(this.output.gain.setValueAtTime(0,this.context.currentTime),this.output.gain.linearRampToValueAtTime(1,this.context.currentTime+e)):this.output.gain.setValueAtTime(1,this.context.currentTime),this.isPlaying=!0}start(e=0,t=0,r){this.isPlaying||(this.source=this._createSource(),this.startTime=this.context.currentTime+e-t/this.playbackRate,r!==void 0?this.source.start(this.context.currentTime+e,t,r):this.source.start(this.context.currentTime+e,t),this.pauseTime=t,this.isPlaying=!0)}pause({fadeOut:e=0}={}){if(!this.isPlaying)return;let t=this.getElapsed()/1e3;if(this.loop&&this.loopEnd>this.loopStart){let r=this.loopEnd-this.loopStart;t=this.loopStart+(t-this.loopStart)%r}if(this.isPlaying=!1,e>0){let r=this.context.currentTime;this.output.gain.setValueAtTime(this.output.gain.value,r),this.output.gain.linearRampToValueAtTime(0,r+e),setTimeout(()=>{if(this.source){this.source.onended=null;try{this.source.stop()}catch{}}this.pauseTime=t,this.output.gain.setValueAtTime(1,this.context.currentTime)},e*1e3)}else{if(this.source){this.source.onended=null;try{this.source.stop()}catch{}}this.pauseTime=t}}getElapsed(){return this.isPlaying?(this.context.currentTime-this.startTime)*this.playbackRate*1e3:this.pauseTime*1e3}setSpeed(e){if(e<=0)throw new Error("Playback rate must be positive");let t=this.getElapsed()/1e3;this.playbackRate=e,this.isPlaying&&(this.pause(),this.pauseTime=t,this.play())}setLoop(e=!0){this.loop=e,this.source&&(this.source.loop=e)}loop;playbackRate;startTime;tempGain=null;connect(e,t=0,r=0){if("value"in e)this.output.connect(e,t);else return this.output.connect(e,t,r),e}disconnect(e,t,r){e===void 0?this.output.disconnect():this.output.disconnect(e,t,r)}output;stop(e=0){if(this.notIndependent)return this.pause();if(!this.source)return;let t=this.context.currentTime+e;this.source.stop(t),this.isPlaying=!1,this.notIndependent||(this.pauseTime=0)}pauseTime;isPlaying;notIndependent=!1;loopStart=0;loopEnd=0},Z={osc:{enabled:!0,type:"sine",freq:440,detune:0},noise:{enabled:!1,level:.5},ampEnv:{attack:.005,decay:.1,sustain:0,release:.1,volume:.3},pitchEnv:{amount:0,decay:.2},filter:{enabled:!1,type:"lowpass",freq:1200,Q:1,envAmount:0,decay:.2},lfo:{enabled:!1,target:"freq",rate:8,depth:20},duration:.4},C=class n{constructor(e={}){this.ctx=R.audioCtx,this.cfg=structuredClone(Z),Object.assign(this.cfg,e)}ctx;cfg;play(e=R.sfxGain){let t=this.ctx,r=t.currentTime,i=this.cfg,o=t.createGain();o.gain.setValueAtTime(1e-4,r);let p=i.ampEnv;o.gain.exponentialRampToValueAtTime(p.volume,r+p.attack),o.gain.exponentialRampToValueAtTime(Math.max(1e-4,p.sustain*p.volume),r+p.attack+p.decay),o.gain.exponentialRampToValueAtTime(1e-4,r+i.duration+p.release);let f=o,l;i.filter.enabled&&(l=t.createBiquadFilter(),l.type=i.filter.type,l.frequency.value=i.filter.freq,l.Q.value=i.filter.Q,l.connect(o),f=l);let u;if(i.osc.enabled){if(u=t.createOscillator(),u.type=i.osc.type,u.frequency.value=i.osc.freq,u.detune.value=i.osc.detune,i.pitchEnv.amount!==0){let h=Math.pow(2,i.pitchEnv.amount/12);u.frequency.exponentialRampToValueAtTime(i.osc.freq*h,r+i.pitchEnv.decay)}u.connect(f),u.start(r),u.stop(r+i.duration+p.release)}let d;if(i.noise.enabled){let h=t.sampleRate*i.duration,m=t.createBuffer(1,h,t.sampleRate),b=m.getChannelData(0);for(let E=0;E<h;E++)b[E]=(Math.random()*2-1)*i.noise.level;d=t.createBufferSource(),d.buffer=m,d.connect(f),d.start(r),d.stop(r+i.duration+p.release)}let y,s;i.lfo.enabled&&u&&(y=t.createOscillator(),y.frequency.value=i.lfo.rate,s=t.createGain(),s.gain.value=i.lfo.depth,y.connect(s),i.lfo.target==="freq"?s.connect(u.frequency):i.lfo.target==="gain"?s.connect(o.gain):i.lfo.target==="filter"&&l&&s.connect(l.frequency),y.start(r),y.stop(r+i.duration)),o.connect(e);let c=[u,d,y,s,l,o],a=r+i.duration+p.release;setTimeout(()=>{c.forEach(h=>h?.disconnect())},(a-t.currentTime)*1e3)}getConfig(){return structuredClone(this.cfg)}setConfig(e){return Object.assign(this.cfg,e),this}getKey(e){return this.cfg[e]}setKey(e,t){return Object.assign(this.cfg[e],t),this}setFreq(e){return this.cfg.osc.freq=e,this}setWave(e){return this.cfg.osc.type=e,this}setVolume(e){return this.cfg.ampEnv.volume=e,this}setAmpEnv(e,t,r,i){return Object.assign(this.cfg.ampEnv,{attack:e,decay:t,sustain:r,release:i}),this}setPitchEnv(e,t){return Object.assign(this.cfg.pitchEnv,{amount:e,decay:t}),this}setNoiseEnabled(e){return this.cfg.noise.enabled=e,this}setNoiseLevel(e){return this.cfg.noise.level=e,this}setFilterEnabled(e){return this.cfg.filter.enabled=e,this}setFilter(e,t,r){return Object.assign(this.cfg.filter,{type:e,freq:t,Q:r,enabled:!0}),this}setLFOEnabled(e){return this.cfg.lfo.enabled=e,this}setLFO(e,t,r){return Object.assign(this.cfg.lfo,{target:e,rate:t,depth:r,enabled:!0}),this}setDuration(e){return this.cfg.duration=e,this}clone(){return new n(structuredClone(this.cfg))}},fe=new C({osc:{enabled:!0,type:"square",freq:900,detune:0},ampEnv:{attack:.002,decay:.04,sustain:0,release:.02,volume:.15},duration:.05}),de=new C({osc:{enabled:!0,type:"sine",freq:600,detune:0},ampEnv:{attack:.01,decay:.08,sustain:0,release:.04,volume:.12},duration:.1}),me=new C({osc:{enabled:!0,type:"triangle",freq:500,detune:0},pitchEnv:{amount:12,decay:.15},ampEnv:{attack:.01,decay:.12,sustain:0,release:.05,volume:.25},duration:.18}),ye=new C({osc:{enabled:!0,type:"sawtooth",freq:1200,detune:0},pitchEnv:{amount:-24,decay:.3},ampEnv:{attack:.005,decay:.25,sustain:0,release:.05,volume:.3},duration:.35}),be=new C({osc:{enabled:!0,type:"square",freq:180,detune:0},noise:{enabled:!0,level:.4},ampEnv:{attack:.002,decay:.15,sustain:0,release:.05,volume:.35},duration:.2});function $(n=12){let e=Date.now().toString(36),t=crypto.getRandomValues(new Uint8Array(4)),r=Array.from(t).map(i=>i.toString(36).padStart(2,"0")).join("");return(e+r).slice(0,n)}function ee(n){let e=!0;function t(){e&&(n(),requestAnimationFrame(t))}return requestAnimationFrame(t),{clear:()=>e=!1}}function te(){return D?!1:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}var xe=te();function ne({width:n,height:e,updateHz:t="frames"}){return new T.KaylaGame(n,e,t==="frames"?1/0:t)}function re(n){let e=new _(n);return new T.KaylaScene(e)}function se(n){return new T.KaylaRenderer(n)}function L(n,e){return{type:n,props:e}}var T;(d=>{class n extends A{#e;#t;constructor(s,c,a){super(s,c,a),this.#e=new Set,this.#t=!1}get started(){return this.#t}start(){if(!this.#t){for(let s of this.#e)s.start();this.#t=!0,super.start()}}stop(){if(this.#t){for(let s of this.#e)s.stop();this.#t=!1,super.stop()}}addRenderer(s){this.#e.has(s)||(this.#e.add(s),this.#t&&s.start(),s.game=this)}deleteRenderer(s){this.#e.has(s)&&(this.#e.delete(s),this.#t&&s.stop(),delete s.game)}}d.KaylaGame=n;class e extends F{game;pointerX;pointerY;#e;constructor(s){super(s),this.useDraw=this.useDraw.bind(this),this.on("draw",c=>{if(this.game)for(let a of this.game.scenes.values())a.handleDraw(c)}),this.pointerX=0,this.pointerY=0,this.#e=this.#t.bind(this)}#t(s){this.pointerX=s.clientX,this.pointerY=s.clientY}listenPointerUpdates(){this.canvas.addEventListener("pointermove",this.#e)}unlistenPointerUpdates(){this.canvas.removeEventListener("pointermove",this.#e)}pointerPosToWorldPos(s,c){let a=this.canvas.getBoundingClientRect(),h=(s-a.left)/a.width,m=(c-a.top)/a.height,b=h*this.viewportWidth*this.cameraWidth/a.width,E=m*this.viewportHeight*this.cameraHeight/a.height;return new S(b,E)}getMousePos(){return this.pointerPosToWorldPos(this.pointerX,this.pointerY)}useDraw(s){let c=a=>{s(a,new r)};return this.on("draw",c),()=>{this.off("draw",c)}}attachTo(s){s.addRenderer(this),this.game=s}detach(){this.game&&this.game.deleteRenderer(this)}}d.KaylaRenderer=e;class t{current;saves;constructor(){this.saves=[]}useTick(s){if(!this.current)throw new Error("Hook 'useTick' must be executed in the top level scope of a component.");this.current.onTick[this.current.useStepCallIndex]=s,this.current.useStepCallIndex++}usePaint(s){if(!this.current)throw new Error("Hook 'usePaint' must be executed in the top level scope of a component.");this.current.onPaint[this.current.useDrawCallIndex]=s,this.current.useDrawCallIndex++}useEntity(){return k(P)}useSelf(s){let c=k(null);return(c.current===null||c.current===void 0)&&(c.current=s()),c.current}useState(s,{alwaysRecall:c=!1}={}){if(!this.current)throw new Error("Hook 'useState' must be executed in the top level scope of a component.");let h=this.current.state[this.current.useStateCallIndex]??new i(this.current,s,{alwaysRecall:c});return this.current.state[this.current.useStateCallIndex]=h,this.current.useStateCallIndex++,h}useRef(s){if(!this.current)throw new Error("Hook 'useRef' must be executed in the top level scope of a component.");let a=this.current.refs[this.current.useRefCallIndex]??new o(this.current,s??null);return this.current.refs[this.current.useRefCallIndex]=a,this.current.useRefCallIndex++,a}useEffect(s){if(!this.current)throw new Error("Hook 'useEffect' must be executed in the top level scope of a component.");this.current.onEffect[this.current.useEffectCallIndex]=s,this.current.useEffectCallIndex++}useExports(s,c){if(!this.current)throw new Error("Hook 'useExports' must be executed in the top level scope of a component.");this.current.onExport=c}save(){this.saves.push({current:this.current})}restore(){let s=this.saves.pop();if(!s)throw new Error("Cannot restore without saving.");this.current=s.current}}d.GlobalKayla=t;class r{preventDefault(){this.#e=!0}#e=!1;isPrevented(){return this.#e}}d.KaylaEvent=r;class i{#e;#t;#n;alwaysRecall;constructor(s,c,{alwaysRecall:a=!1}={}){this.#t=s,this.#e=c??void 0,this.#n=Date.now(),this.alwaysRecall=a}get(){return this.#e}add(s,{recall:c}={}){this.set(this.get()+s,{recall:c})}multiply(s,{recall:c}={}){this.set(this.get()*s,{recall:c})}set(s,{recall:c=!1}={}){let a=this.#e;s!==a&&(this.#e=s,(c||this.alwaysRecall)&&this.#t.refresh(),this.#n=Date.now())}get value(){return this.#e}get lastChanged(){return this.#n}}d.KaylaState=i;class o{#e;#t;constructor(s,c){this.#t=s,this.#e=c??void 0}get current(){return this.#e}set current(s){this.#e=s}}d.KaylaRef=o;class p{state;refs;global;callProps;scene;exports;constructor(s,c,a){if(!a)throw new Error("Empty element");this.scene=c,this.state=[],this.refs=[],this.fc=a.type,this.callProps=a.props??{},this.global=s,this.lastStateDeps=[],this.entity=null,this.lastChildren=[],this.onEffect=[],this.onUnEffect=[],this.onPaint=[],this.onTick=[]}get key(){return this.callProps.key}set key(s){this.callProps.key=s}get children(){return this.callProps.children}set children(s){this.callProps.children=s}entity;onExport=()=>({});onEffect;onUnEffect;onEffectDeps;onPaint;onTick;fc;useStateCallIndex=0;useEffectCallIndex=0;useDrawCallIndex=0;useStepCallIndex=0;useRefCallIndex=0;lastStateDeps;refresh(){let s;this.global.save(),this.global.current=this,this.useStateCallIndex=0,this.useRefCallIndex=0;let c=[];try{let a=this.fc(this.callProps)??[];if(a&&!Array.isArray(a)&&(a=[a]),!Array.isArray(a))throw new Error("Non array or non undefined children received.");c=a}catch(a){s=a}this.useStateCallIndex=0,this.useRefCallIndex=0,this.useDrawCallIndex=0,this.useStepCallIndex=0,this.useEffectCallIndex=0,this.global.restore();try{let a=0,h=[];for(let m of c){let b=this.lastChildren.at(a)??new p(this.global,this.scene,m);this.lastChildren[a]=b,h.push(b),a++}for(let m of this.lastChildren.filter(b=>!h.includes(b))){let b=this.lastChildren.indexOf(m);b!==1&&this.lastChildren.splice(b,1),m.unuse()}for(let m of this.lastChildren)try{m.refresh()}catch(b){console.error(b)}W(()=>{this.use()})}catch(a){console.error(a)}if(s)throw s}lastChildren;isFirstUse=!0;use(){try{let s=!0;if(this.lastStateDeps??=[],Array.isArray(this.onEffectDeps)&&(s=this.onEffectDeps.some((c,a)=>{let h=this.lastStateDeps.at(a);if(h){let m=c.lastChanged,b=h.stamp;return m>b}})),s||this.isFirstUse){this.isFirstUse=!1,Array.isArray(this.onEffectDeps)&&(this.lastStateDeps=this.onEffectDeps.map(a=>({stamp:a.lastChanged,stateRef:a}))),this.key??=this.fc.name+"_"+$(),this.entity&&this.scene.getScene().removeEntity(this.entity),this.entity&&this.entity.name!==this.key&&(this.entity=null),this.entity=this.entity??new f(this,this.key);for(let a of this.refs)a.current===P&&(a.current=this.entity);this.callProps.ref instanceof o&&(this.callProps.ref.current=this.entity),this.exports=this.onExport(),this.callProps.exportsRef instanceof o&&(this.callProps.exportsRef.current=this.exports),this.scene.getScene().addEntity(this.entity);let c=this.onEffect.map(a=>a()).filter(a=>a!==void 0);this.onUnEffect=c}}catch(s){throw s}}unuse(){try{for(let s of this.onUnEffect)s()}catch(s){console.error(s)}this.scene.getScene().removeEntity(this.entity)}}d.KaylaInternalComponent=p;class f extends V{#e;constructor(s,c){super(c,0,0,0,0),this.#e=s}update(s){let c=new r;if(this.#e.onTick)for(let a of this.#e.onTick)a(s,c);c.isPrevented()}draw(s){let c=new r;if(this.#e.onPaint)for(let a of this.#e.onPaint)a(s,c);c.isPrevented()||super.draw(s)}}d.KaylaRectEntity=f;class l{constructor(s){this.#t=s,this.#e=null,s.on("update",this.tickHandler.bind(this)),this.drawHandler=this.drawHandler.bind(this)}#e;#t;getScene(){return this.#t}drawHandler(s){return this.#t.handleDraw(s)}attachTo(s){s.addScene(this.#t),this.#e=s}spawn(s){new p(d.singleGlobalInstance,this,s).refresh()}detach(){this.#e&&this.#e.removeScene(this.#t)}tickHandler(){}}d.KaylaScene=l,d.singleGlobalInstance=new d.GlobalKayla})(T||={});var x=T.singleGlobalInstance,O=x.useState.bind(x),k=x.useRef.bind(x),H=x.useEffect.bind(x),ie=x.useTick.bind(x),X=x.usePaint.bind(x),ae=x.useExports.bind(x),oe=x.useSelf.bind(x),ue=x.useEntity.bind(x),P=Symbol("self_ref");var W=n=>{Promise.resolve(1).then(()=>n())},U=({children:n})=>Array.isArray(n)?[...n]:n;function le(n){return new T.KaylaRef(null,n)}Reflect.set(globalThis,"Kayla",q);var ce;(e=>e.UIComponent=({x:t,y:r,width:i,height:o,children:p})=>{let f=k(P),l=O(!1);return H(()=>{if(l.get()===!0)return;l.set(!0);let u=f.current;u.width=i,u.height=o,u.x=t,u.y=r}),X(u=>{u.fillStyle="rgba(0, 0, 0, 0.5)",u.fillRect(t,r,i,o)}),p??[]})(ce||={});function Ke(n,e,...t){if(typeof n=="string")throw new Error("Cannot use intrinsic elements.");return L(n,{...e,children:e.children??t})}function he(n,e,...t){if(typeof n=="string")throw new Error("Cannot use intrinsic elements.");return L(n,{...e,children:e.children??t})}function Re(n,e){return he(n,e)}var ke=U;export{ke as Fragment,Ke as jsx,Re as jsxDEV,he as jsxs};
@@ -0,0 +1,50 @@
1
+ import { F as FCProps, a as FC, E as ExportsOfFC, b as FCExports, J as JSX, k as kaylaInternals, K as KaylaElement, c as KaylaElementRef, d as KaylaExportables, e as KaylaExports, f as KaylaFragment, g as KaylaGame, h as KaylaInternals, i as KaylaRef, j as KaylaRenderer, l as KaylaScene, m as KaylaState, P as PropOfFC, n as createElement, o as createGame, p as createRenderer, q as createScene, s as selfSym, u as useDisposableRef, r as useEffect, t as useEntity, v as useExports, w as useNextStack, x as usePaint, y as useRef, z as useSelf, A as useState, B as useTick } from './kayla-internals-ClSuOWZb.js';
2
+
3
+ declare namespace UI {
4
+ interface UIProps extends FCProps {
5
+ x: number;
6
+ y: number;
7
+ width: number;
8
+ height: number;
9
+ onClick?: () => void;
10
+ }
11
+ const UIComponent: FC<UIProps>;
12
+ }
13
+
14
+ declare const Kayla_ExportsOfFC: typeof ExportsOfFC;
15
+ declare const Kayla_FC: typeof FC;
16
+ declare const Kayla_FCExports: typeof FCExports;
17
+ declare const Kayla_FCProps: typeof FCProps;
18
+ declare const Kayla_JSX: typeof JSX;
19
+ declare const Kayla_KaylaElement: typeof KaylaElement;
20
+ declare const Kayla_KaylaElementRef: typeof KaylaElementRef;
21
+ declare const Kayla_KaylaExportables: typeof KaylaExportables;
22
+ declare const Kayla_KaylaExports: typeof KaylaExports;
23
+ declare const Kayla_KaylaFragment: typeof KaylaFragment;
24
+ declare const Kayla_KaylaGame: typeof KaylaGame;
25
+ declare const Kayla_KaylaInternals: typeof KaylaInternals;
26
+ declare const Kayla_KaylaRef: typeof KaylaRef;
27
+ declare const Kayla_KaylaRenderer: typeof KaylaRenderer;
28
+ declare const Kayla_KaylaScene: typeof KaylaScene;
29
+ declare const Kayla_KaylaState: typeof KaylaState;
30
+ declare const Kayla_PropOfFC: typeof PropOfFC;
31
+ declare const Kayla_UI: typeof UI;
32
+ declare const Kayla_createElement: typeof createElement;
33
+ declare const Kayla_createGame: typeof createGame;
34
+ declare const Kayla_createRenderer: typeof createRenderer;
35
+ declare const Kayla_createScene: typeof createScene;
36
+ declare const Kayla_useDisposableRef: typeof useDisposableRef;
37
+ declare const Kayla_useEffect: typeof useEffect;
38
+ declare const Kayla_useEntity: typeof useEntity;
39
+ declare const Kayla_useExports: typeof useExports;
40
+ declare const Kayla_useNextStack: typeof useNextStack;
41
+ declare const Kayla_usePaint: typeof usePaint;
42
+ declare const Kayla_useRef: typeof useRef;
43
+ declare const Kayla_useSelf: typeof useSelf;
44
+ declare const Kayla_useState: typeof useState;
45
+ declare const Kayla_useTick: typeof useTick;
46
+ declare namespace Kayla {
47
+ export { Kayla_ExportsOfFC as ExportsOfFC, Kayla_FC as FC, Kayla_FCExports as FCExports, Kayla_FCProps as FCProps, Kayla_JSX as JSX, kaylaInternals as Kayla, Kayla_KaylaElement as KaylaElement, Kayla_KaylaElementRef as KaylaElementRef, Kayla_KaylaExportables as KaylaExportables, Kayla_KaylaExports as KaylaExports, Kayla_KaylaFragment as KaylaFragment, Kayla_KaylaGame as KaylaGame, Kayla_KaylaInternals as KaylaInternals, Kayla_KaylaRef as KaylaRef, Kayla_KaylaRenderer as KaylaRenderer, Kayla_KaylaScene as KaylaScene, Kayla_KaylaState as KaylaState, Kayla_PropOfFC as PropOfFC, Kayla_UI as UI, Kayla_createElement as createElement, Kayla_createGame as createGame, Kayla_createRenderer as createRenderer, Kayla_createScene as createScene, selfSym as self, Kayla_useDisposableRef as useDisposableRef, Kayla_useEffect as useEffect, Kayla_useEntity as useEntity, Kayla_useExports as useExports, Kayla_useNextStack as useNextStack, Kayla_usePaint as usePaint, Kayla_useRef as useRef, Kayla_useSelf as useSelf, Kayla_useState as useState, Kayla_useTick as useTick };
48
+ }
49
+
50
+ export { Kayla as K, UI as U };
@@ -0,0 +1,50 @@
1
+ import { F as FCProps, a as FC, E as ExportsOfFC, b as FCExports, J as JSX, k as kaylaInternals, K as KaylaElement, c as KaylaElementRef, d as KaylaExportables, e as KaylaExports, f as KaylaFragment, g as KaylaGame, h as KaylaInternals, i as KaylaRef, j as KaylaRenderer, l as KaylaScene, m as KaylaState, P as PropOfFC, n as createElement, o as createGame, p as createRenderer, q as createScene, s as selfSym, u as useDisposableRef, r as useEffect, t as useEntity, v as useExports, w as useNextStack, x as usePaint, y as useRef, z as useSelf, A as useState, B as useTick } from './kayla-internals-DvV9K1wf.cjs';
2
+
3
+ declare namespace UI {
4
+ interface UIProps extends FCProps {
5
+ x: number;
6
+ y: number;
7
+ width: number;
8
+ height: number;
9
+ onClick?: () => void;
10
+ }
11
+ const UIComponent: FC<UIProps>;
12
+ }
13
+
14
+ declare const Kayla_ExportsOfFC: typeof ExportsOfFC;
15
+ declare const Kayla_FC: typeof FC;
16
+ declare const Kayla_FCExports: typeof FCExports;
17
+ declare const Kayla_FCProps: typeof FCProps;
18
+ declare const Kayla_JSX: typeof JSX;
19
+ declare const Kayla_KaylaElement: typeof KaylaElement;
20
+ declare const Kayla_KaylaElementRef: typeof KaylaElementRef;
21
+ declare const Kayla_KaylaExportables: typeof KaylaExportables;
22
+ declare const Kayla_KaylaExports: typeof KaylaExports;
23
+ declare const Kayla_KaylaFragment: typeof KaylaFragment;
24
+ declare const Kayla_KaylaGame: typeof KaylaGame;
25
+ declare const Kayla_KaylaInternals: typeof KaylaInternals;
26
+ declare const Kayla_KaylaRef: typeof KaylaRef;
27
+ declare const Kayla_KaylaRenderer: typeof KaylaRenderer;
28
+ declare const Kayla_KaylaScene: typeof KaylaScene;
29
+ declare const Kayla_KaylaState: typeof KaylaState;
30
+ declare const Kayla_PropOfFC: typeof PropOfFC;
31
+ declare const Kayla_UI: typeof UI;
32
+ declare const Kayla_createElement: typeof createElement;
33
+ declare const Kayla_createGame: typeof createGame;
34
+ declare const Kayla_createRenderer: typeof createRenderer;
35
+ declare const Kayla_createScene: typeof createScene;
36
+ declare const Kayla_useDisposableRef: typeof useDisposableRef;
37
+ declare const Kayla_useEffect: typeof useEffect;
38
+ declare const Kayla_useEntity: typeof useEntity;
39
+ declare const Kayla_useExports: typeof useExports;
40
+ declare const Kayla_useNextStack: typeof useNextStack;
41
+ declare const Kayla_usePaint: typeof usePaint;
42
+ declare const Kayla_useRef: typeof useRef;
43
+ declare const Kayla_useSelf: typeof useSelf;
44
+ declare const Kayla_useState: typeof useState;
45
+ declare const Kayla_useTick: typeof useTick;
46
+ declare namespace Kayla {
47
+ export { Kayla_ExportsOfFC as ExportsOfFC, Kayla_FC as FC, Kayla_FCExports as FCExports, Kayla_FCProps as FCProps, Kayla_JSX as JSX, kaylaInternals as Kayla, Kayla_KaylaElement as KaylaElement, Kayla_KaylaElementRef as KaylaElementRef, Kayla_KaylaExportables as KaylaExportables, Kayla_KaylaExports as KaylaExports, Kayla_KaylaFragment as KaylaFragment, Kayla_KaylaGame as KaylaGame, Kayla_KaylaInternals as KaylaInternals, Kayla_KaylaRef as KaylaRef, Kayla_KaylaRenderer as KaylaRenderer, Kayla_KaylaScene as KaylaScene, Kayla_KaylaState as KaylaState, Kayla_PropOfFC as PropOfFC, Kayla_UI as UI, Kayla_createElement as createElement, Kayla_createGame as createGame, Kayla_createRenderer as createRenderer, Kayla_createScene as createScene, selfSym as self, Kayla_useDisposableRef as useDisposableRef, Kayla_useEffect as useEffect, Kayla_useEntity as useEntity, Kayla_useExports as useExports, Kayla_useNextStack as useNextStack, Kayla_usePaint as usePaint, Kayla_useRef as useRef, Kayla_useSelf as useSelf, Kayla_useState as useState, Kayla_useTick as useTick };
48
+ }
49
+
50
+ export { Kayla as K, UI as U };
@@ -664,7 +664,7 @@ declare namespace JSX {
664
664
  *
665
665
  * Currently supports `KaylaState` or `KaylaRef` instances.
666
666
  */
667
- type KaylaExportables = KaylaState<any> | KaylaRef<any>;
667
+ type KaylaExportables = KaylaState<any> | KaylaRef<any> | Record<any, any> | string | number | boolean;
668
668
  /**
669
669
  * Shape of the object returned by a component's `useExports` callback.
670
670
  *
@@ -733,51 +733,4 @@ declare namespace kaylaInternals {
733
733
  export { type kaylaInternals_ExportsOfFC as ExportsOfFC, type kaylaInternals_FC as FC, type kaylaInternals_FCExports as FCExports, type kaylaInternals_FCProps as FCProps, kaylaInternals_JSX as JSX, type kaylaInternals_KaylaElement as KaylaElement, type kaylaInternals_KaylaElementRef as KaylaElementRef, type kaylaInternals_KaylaExportables as KaylaExportables, type kaylaInternals_KaylaExports as KaylaExports, kaylaInternals_KaylaFragment as KaylaFragment, type kaylaInternals_KaylaGame as KaylaGame, kaylaInternals_KaylaInternals as KaylaInternals, type kaylaInternals_KaylaRef as KaylaRef, type kaylaInternals_KaylaRenderer as KaylaRenderer, type kaylaInternals_KaylaScene as KaylaScene, type kaylaInternals_KaylaState as KaylaState, type kaylaInternals_PropOfFC as PropOfFC, kaylaInternals_createElement as createElement, kaylaInternals_createGame as createGame, kaylaInternals_createRenderer as createRenderer, kaylaInternals_createScene as createScene, selfSym as self, kaylaInternals_useDisposableRef as useDisposableRef, kaylaInternals_useEffect as useEffect, kaylaInternals_useEntity as useEntity, kaylaInternals_useExports as useExports, kaylaInternals_useNextStack as useNextStack, kaylaInternals_usePaint as usePaint, kaylaInternals_useRef as useRef, kaylaInternals_useSelf as useSelf, kaylaInternals_useState as useState, kaylaInternals_useTick as useTick };
734
734
  }
735
735
 
736
- declare namespace UI {
737
- interface UIProps extends FCProps {
738
- x: number;
739
- y: number;
740
- width: number;
741
- height: number;
742
- onClick?: () => void;
743
- }
744
- const UIComponent: FC<UIProps>;
745
- }
746
-
747
- type Kayla_ExportsOfFC<T extends FC<any, any>> = ExportsOfFC<T>;
748
- type Kayla_FC<Props extends FCProps = FCProps, Exports extends FCExports = FCExports> = FC<Props, Exports>;
749
- type Kayla_FCExports = FCExports;
750
- type Kayla_FCProps = FCProps;
751
- declare const Kayla_JSX: typeof JSX;
752
- type Kayla_KaylaElement<Props extends FCProps> = KaylaElement<Props>;
753
- type Kayla_KaylaElementRef = KaylaElementRef;
754
- type Kayla_KaylaExportables = KaylaExportables;
755
- type Kayla_KaylaExports<StateMap extends Record<string, KaylaExportables>> = KaylaExports<StateMap>;
756
- declare const Kayla_KaylaFragment: typeof KaylaFragment;
757
- type Kayla_KaylaGame = KaylaGame;
758
- declare const Kayla_KaylaInternals: typeof KaylaInternals;
759
- type Kayla_KaylaRef<T> = KaylaRef<T>;
760
- type Kayla_KaylaRenderer = KaylaRenderer;
761
- type Kayla_KaylaScene = KaylaScene;
762
- type Kayla_KaylaState<T> = KaylaState<T>;
763
- type Kayla_PropOfFC<T extends FC<any, any>> = PropOfFC<T>;
764
- declare const Kayla_UI: typeof UI;
765
- declare const Kayla_createElement: typeof createElement;
766
- declare const Kayla_createGame: typeof createGame;
767
- declare const Kayla_createRenderer: typeof createRenderer;
768
- declare const Kayla_createScene: typeof createScene;
769
- declare const Kayla_useDisposableRef: typeof useDisposableRef;
770
- declare const Kayla_useEffect: typeof useEffect;
771
- declare const Kayla_useEntity: typeof useEntity;
772
- declare const Kayla_useExports: typeof useExports;
773
- declare const Kayla_useNextStack: typeof useNextStack;
774
- declare const Kayla_usePaint: typeof usePaint;
775
- declare const Kayla_useRef: typeof useRef;
776
- declare const Kayla_useSelf: typeof useSelf;
777
- declare const Kayla_useState: typeof useState;
778
- declare const Kayla_useTick: typeof useTick;
779
- declare namespace Kayla {
780
- export { type Kayla_ExportsOfFC as ExportsOfFC, type Kayla_FC as FC, type Kayla_FCExports as FCExports, type Kayla_FCProps as FCProps, Kayla_JSX as JSX, kaylaInternals as Kayla, type Kayla_KaylaElement as KaylaElement, type Kayla_KaylaElementRef as KaylaElementRef, type Kayla_KaylaExportables as KaylaExportables, type Kayla_KaylaExports as KaylaExports, Kayla_KaylaFragment as KaylaFragment, type Kayla_KaylaGame as KaylaGame, Kayla_KaylaInternals as KaylaInternals, type Kayla_KaylaRef as KaylaRef, type Kayla_KaylaRenderer as KaylaRenderer, type Kayla_KaylaScene as KaylaScene, type Kayla_KaylaState as KaylaState, type Kayla_PropOfFC as PropOfFC, Kayla_UI as UI, Kayla_createElement as createElement, Kayla_createGame as createGame, Kayla_createRenderer as createRenderer, Kayla_createScene as createScene, selfSym as self, Kayla_useDisposableRef as useDisposableRef, Kayla_useEffect as useEffect, Kayla_useEntity as useEntity, Kayla_useExports as useExports, Kayla_useNextStack as useNextStack, Kayla_usePaint as usePaint, Kayla_useRef as useRef, Kayla_useSelf as useSelf, Kayla_useState as useState, Kayla_useTick as useTick };
781
- }
782
-
783
- export { useSelf as A, useState as B, useTick as C, type ExportsOfFC as E, type FC as F, JSX as J, Kayla as K, type PropOfFC as P, UI as U, type FCExports as a, type FCProps as b, type KaylaElement as c, type KaylaElementRef as d, type KaylaExportables as e, type KaylaExports as f, KaylaFragment as g, KaylaGame as h, KaylaInternals as i, KaylaRef as j, kaylaInternals as k, KaylaRenderer as l, KaylaScene as m, KaylaState as n, createElement as o, createGame as p, createRenderer as q, createScene as r, selfSym as s, useEffect as t, useDisposableRef as u, useEntity as v, useExports as w, useNextStack as x, usePaint as y, useRef as z };
736
+ export { useState as A, useTick as B, type ExportsOfFC as E, type FCProps as F, JSX as J, type KaylaElement as K, type PropOfFC as P, type FC as a, type FCExports as b, type KaylaElementRef as c, type KaylaExportables as d, type KaylaExports as e, KaylaFragment as f, KaylaGame as g, KaylaInternals as h, KaylaRef as i, KaylaRenderer as j, kaylaInternals as k, KaylaScene as l, KaylaState as m, createElement as n, createGame as o, createRenderer as p, createScene as q, useEffect as r, selfSym as s, useEntity as t, useDisposableRef as u, useExports as v, useNextStack as w, usePaint as x, useRef as y, useSelf as z };
@@ -664,7 +664,7 @@ declare namespace JSX {
664
664
  *
665
665
  * Currently supports `KaylaState` or `KaylaRef` instances.
666
666
  */
667
- type KaylaExportables = KaylaState<any> | KaylaRef<any>;
667
+ type KaylaExportables = KaylaState<any> | KaylaRef<any> | Record<any, any> | string | number | boolean;
668
668
  /**
669
669
  * Shape of the object returned by a component's `useExports` callback.
670
670
  *
@@ -733,51 +733,4 @@ declare namespace kaylaInternals {
733
733
  export { type kaylaInternals_ExportsOfFC as ExportsOfFC, type kaylaInternals_FC as FC, type kaylaInternals_FCExports as FCExports, type kaylaInternals_FCProps as FCProps, kaylaInternals_JSX as JSX, type kaylaInternals_KaylaElement as KaylaElement, type kaylaInternals_KaylaElementRef as KaylaElementRef, type kaylaInternals_KaylaExportables as KaylaExportables, type kaylaInternals_KaylaExports as KaylaExports, kaylaInternals_KaylaFragment as KaylaFragment, type kaylaInternals_KaylaGame as KaylaGame, kaylaInternals_KaylaInternals as KaylaInternals, type kaylaInternals_KaylaRef as KaylaRef, type kaylaInternals_KaylaRenderer as KaylaRenderer, type kaylaInternals_KaylaScene as KaylaScene, type kaylaInternals_KaylaState as KaylaState, type kaylaInternals_PropOfFC as PropOfFC, kaylaInternals_createElement as createElement, kaylaInternals_createGame as createGame, kaylaInternals_createRenderer as createRenderer, kaylaInternals_createScene as createScene, selfSym as self, kaylaInternals_useDisposableRef as useDisposableRef, kaylaInternals_useEffect as useEffect, kaylaInternals_useEntity as useEntity, kaylaInternals_useExports as useExports, kaylaInternals_useNextStack as useNextStack, kaylaInternals_usePaint as usePaint, kaylaInternals_useRef as useRef, kaylaInternals_useSelf as useSelf, kaylaInternals_useState as useState, kaylaInternals_useTick as useTick };
734
734
  }
735
735
 
736
- declare namespace UI {
737
- interface UIProps extends FCProps {
738
- x: number;
739
- y: number;
740
- width: number;
741
- height: number;
742
- onClick?: () => void;
743
- }
744
- const UIComponent: FC<UIProps>;
745
- }
746
-
747
- type Kayla_ExportsOfFC<T extends FC<any, any>> = ExportsOfFC<T>;
748
- type Kayla_FC<Props extends FCProps = FCProps, Exports extends FCExports = FCExports> = FC<Props, Exports>;
749
- type Kayla_FCExports = FCExports;
750
- type Kayla_FCProps = FCProps;
751
- declare const Kayla_JSX: typeof JSX;
752
- type Kayla_KaylaElement<Props extends FCProps> = KaylaElement<Props>;
753
- type Kayla_KaylaElementRef = KaylaElementRef;
754
- type Kayla_KaylaExportables = KaylaExportables;
755
- type Kayla_KaylaExports<StateMap extends Record<string, KaylaExportables>> = KaylaExports<StateMap>;
756
- declare const Kayla_KaylaFragment: typeof KaylaFragment;
757
- type Kayla_KaylaGame = KaylaGame;
758
- declare const Kayla_KaylaInternals: typeof KaylaInternals;
759
- type Kayla_KaylaRef<T> = KaylaRef<T>;
760
- type Kayla_KaylaRenderer = KaylaRenderer;
761
- type Kayla_KaylaScene = KaylaScene;
762
- type Kayla_KaylaState<T> = KaylaState<T>;
763
- type Kayla_PropOfFC<T extends FC<any, any>> = PropOfFC<T>;
764
- declare const Kayla_UI: typeof UI;
765
- declare const Kayla_createElement: typeof createElement;
766
- declare const Kayla_createGame: typeof createGame;
767
- declare const Kayla_createRenderer: typeof createRenderer;
768
- declare const Kayla_createScene: typeof createScene;
769
- declare const Kayla_useDisposableRef: typeof useDisposableRef;
770
- declare const Kayla_useEffect: typeof useEffect;
771
- declare const Kayla_useEntity: typeof useEntity;
772
- declare const Kayla_useExports: typeof useExports;
773
- declare const Kayla_useNextStack: typeof useNextStack;
774
- declare const Kayla_usePaint: typeof usePaint;
775
- declare const Kayla_useRef: typeof useRef;
776
- declare const Kayla_useSelf: typeof useSelf;
777
- declare const Kayla_useState: typeof useState;
778
- declare const Kayla_useTick: typeof useTick;
779
- declare namespace Kayla {
780
- export { type Kayla_ExportsOfFC as ExportsOfFC, type Kayla_FC as FC, type Kayla_FCExports as FCExports, type Kayla_FCProps as FCProps, Kayla_JSX as JSX, kaylaInternals as Kayla, type Kayla_KaylaElement as KaylaElement, type Kayla_KaylaElementRef as KaylaElementRef, type Kayla_KaylaExportables as KaylaExportables, type Kayla_KaylaExports as KaylaExports, Kayla_KaylaFragment as KaylaFragment, type Kayla_KaylaGame as KaylaGame, Kayla_KaylaInternals as KaylaInternals, type Kayla_KaylaRef as KaylaRef, type Kayla_KaylaRenderer as KaylaRenderer, type Kayla_KaylaScene as KaylaScene, type Kayla_KaylaState as KaylaState, type Kayla_PropOfFC as PropOfFC, Kayla_UI as UI, Kayla_createElement as createElement, Kayla_createGame as createGame, Kayla_createRenderer as createRenderer, Kayla_createScene as createScene, selfSym as self, Kayla_useDisposableRef as useDisposableRef, Kayla_useEffect as useEffect, Kayla_useEntity as useEntity, Kayla_useExports as useExports, Kayla_useNextStack as useNextStack, Kayla_usePaint as usePaint, Kayla_useRef as useRef, Kayla_useSelf as useSelf, Kayla_useState as useState, Kayla_useTick as useTick };
781
- }
782
-
783
- export { useSelf as A, useState as B, useTick as C, type ExportsOfFC as E, type FC as F, JSX as J, Kayla as K, type PropOfFC as P, UI as U, type FCExports as a, type FCProps as b, type KaylaElement as c, type KaylaElementRef as d, type KaylaExportables as e, type KaylaExports as f, KaylaFragment as g, KaylaGame as h, KaylaInternals as i, KaylaRef as j, kaylaInternals as k, KaylaRenderer as l, KaylaScene as m, KaylaState as n, createElement as o, createGame as p, createRenderer as q, createScene as r, selfSym as s, useEffect as t, useDisposableRef as u, useEntity as v, useExports as w, useNextStack as x, usePaint as y, useRef as z };
736
+ export { useState as A, useTick as B, type ExportsOfFC as E, type FCProps as F, JSX as J, type KaylaElement as K, type PropOfFC as P, type FC as a, type FCExports as b, type KaylaElementRef as c, type KaylaExportables as d, type KaylaExports as e, KaylaFragment as f, KaylaGame as g, KaylaInternals as h, KaylaRef as i, KaylaRenderer as j, kaylaInternals as k, KaylaScene as l, KaylaState as m, createElement as n, createGame as o, createRenderer as p, createScene as q, useEffect as r, selfSym as s, useEntity as t, useDisposableRef as u, useExports as v, useNextStack as w, usePaint as x, useRef as y, useSelf as z };
package/dist/kayla.d.cts CHANGED
@@ -1,2 +1,3 @@
1
- export { E as ExportsOfFC, F as FC, a as FCExports, b as FCProps, J as JSX, k as Kayla, c as KaylaElement, d as KaylaElementRef, e as KaylaExportables, f as KaylaExports, g as KaylaFragment, h as KaylaGame, i as KaylaInternals, j as KaylaRef, l as KaylaRenderer, m as KaylaScene, n as KaylaState, P as PropOfFC, U as UI, o as createElement, p as createGame, q as createRenderer, r as createScene, s as self, u as useDisposableRef, t as useEffect, v as useEntity, w as useExports, x as useNextStack, y as usePaint, z as useRef, A as useSelf, B as useState, C as useTick } from './kayla-SPtfCppr.cjs';
1
+ export { E as ExportsOfFC, a as FC, b as FCExports, F as FCProps, J as JSX, k as Kayla, K as KaylaElement, c as KaylaElementRef, d as KaylaExportables, e as KaylaExports, f as KaylaFragment, g as KaylaGame, h as KaylaInternals, i as KaylaRef, j as KaylaRenderer, l as KaylaScene, m as KaylaState, P as PropOfFC, n as createElement, o as createGame, p as createRenderer, q as createScene, s as self, u as useDisposableRef, r as useEffect, t as useEntity, v as useExports, w as useNextStack, x as usePaint, y as useRef, z as useSelf, A as useState, B as useTick } from './kayla-internals-DvV9K1wf.cjs';
2
+ export { U as UI } from './kayla-eZdx9UI6.cjs';
2
3
  import './lea-DvxsutSf.cjs';
package/dist/kayla.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- export { E as ExportsOfFC, F as FC, a as FCExports, b as FCProps, J as JSX, k as Kayla, c as KaylaElement, d as KaylaElementRef, e as KaylaExportables, f as KaylaExports, g as KaylaFragment, h as KaylaGame, i as KaylaInternals, j as KaylaRef, l as KaylaRenderer, m as KaylaScene, n as KaylaState, P as PropOfFC, U as UI, o as createElement, p as createGame, q as createRenderer, r as createScene, s as self, u as useDisposableRef, t as useEffect, v as useEntity, w as useExports, x as useNextStack, y as usePaint, z as useRef, A as useSelf, B as useState, C as useTick } from './kayla-CiWP5no4.js';
1
+ export { E as ExportsOfFC, a as FC, b as FCExports, F as FCProps, J as JSX, k as Kayla, K as KaylaElement, c as KaylaElementRef, d as KaylaExportables, e as KaylaExports, f as KaylaFragment, g as KaylaGame, h as KaylaInternals, i as KaylaRef, j as KaylaRenderer, l as KaylaScene, m as KaylaState, P as PropOfFC, n as createElement, o as createGame, p as createRenderer, q as createScene, s as self, u as useDisposableRef, r as useEffect, t as useEntity, v as useExports, w as useNextStack, x as usePaint, y as useRef, z as useSelf, A as useState, B as useTick } from './kayla-internals-ClSuOWZb.js';
2
+ export { U as UI } from './kayla-DmdtbuQf.js';
2
3
  import './lea-DvxsutSf.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kayelaa/canvas",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Declarative entity composition hooks + canvas utilities for LEA-based 2D games",
5
5
  "license": "MIT",
6
6
  "author": "Kayelaa Cagara",
@@ -20,6 +20,14 @@
20
20
  "./lea": {
21
21
  "import": "./dist/lea.js",
22
22
  "require": "./dist/lea.cjs"
23
+ },
24
+ "./jsx-runtime": {
25
+ "import": "./dist/jsx-runtime.js",
26
+ "require": "./dist/jsx-runtime.cjs"
27
+ },
28
+ "./jsx-dev-runtime": {
29
+ "import": "./dist/jsx-dev-runtime.js",
30
+ "require": "./dist/jsx-dev-runtime.cjs"
23
31
  }
24
32
  },
25
33
  "files": [