import{n as e}from"./rolldown-runtime-BG2f4sTM.js";import{Mft as t,O_t as n,evt as r,jft as i,mZ as a,pZ as o}from"./app-initial-BHB6SClA.js";function s(e,t,n){return O.set(t,e),()=>{O.delete(t),queueMicrotask(()=>{for(let t of O.values())if(t===e)return;n?.()})}}function c(){for(let[e,t]of O)if(e.isConnected&&a(e))return t;return null}function l(e=Math.random){return v[Math.floor(e()*v.length)]??`brick-breaker`}function u(e){e.set(k,null)}function d(e){return e.key===T&&e.act===1}function f(e,t){return e?.game===`asteroids`&&d(t)}function p(e){return e==null?null:Array.from({length:D},(t,n)=>({id:n,threadKey:null,title:null,status:e.game===`asteroids`&&n===E?`working`:`off`,selected:!1}))}function m(e,t,n){if(t.distance<y)return{activated:!1,captured:!1,progress:0,state:A};if(e.lastAngle==null||e.lastAt==null||e.startedAt==null||n-e.lastAt>x||n-e.startedAt>S)return{activated:!1,captured:!1,progress:0,state:h(t.angle,n)};let r=_(e.lastAngle,t.angle);if(Math.abs(r)<.002)return{activated:!1,captured:Math.abs(e.accumulatedTurns)>=b,progress:g(e.accumulatedTurns),state:{...e,lastAngle:t.angle,lastAt:n}};let i=r>0?1:-1;if(e.direction!==0&&i!==e.direction&&Math.abs(r)>=C)return{activated:!1,captured:!1,progress:0,state:h(t.angle,n)};let a=e.accumulatedTurns+r;return Math.abs(a)>=w?{activated:!0,captured:!0,progress:1,state:A}:{activated:!1,captured:Math.abs(a)>=b,progress:g(a),state:{accumulatedTurns:a,direction:e.direction===0?i:e.direction,lastAngle:t.angle,lastAt:n,startedAt:e.startedAt}}}function h(e,t){return{accumulatedTurns:0,direction:0,lastAngle:e,lastAt:t,startedAt:t}}function g(e){return Math.min(Math.abs(e)/w,1)}function _(e,t){let n=t-e;return n>.5?n-1:n<-.5?n+1:n}var v,y,b,x,S,C,w,T,E,D,O,k,A,j=e((()=>{n(),o(),t(),v=[`brick-breaker`,`asteroids`,`snake`],y=.2,b=.04,x=1e3,S=6e3,C=.02,w=1.9,T=`AG00`,E=0,D=6,O=new Map,k=r(i,null),A={accumulatedTurns:0,direction:0,lastAngle:null,lastAt:null,startedAt:null}}));export{p as a,A as c,s as d,m as i,d as l,k as n,l as o,c as r,j as s,u as t,f as u};
//# sourceMappingURL=codex-micro-mini-games-ImTY22iQ.js.map