import{l as e,h as t,j as a,k as r,s as n,a as i,m as o,n as s}from"./core-BYpFXVc-.js";const c=s("py-game");let p=!0;const g={main:{onReady:async(a,s)=>{p&&(p=!1,console.warn("⚠️ EXPERIMENTAL `py-game` FEATURE"));let g={};if(s.hasAttribute("config")){const n=s.getAttribute("config"),{json:i,toml:o,text:p,url:m}=await r(n);if(i)g=JSON.parse(p);else if(o){const{parse:e}=await import("./toml-BLBSZ43A.js");g=e(p)}if(g.packages){await a.interpreter.loadPackage("micropip");const e=a.interpreter.pyimport("micropip");await e.install(g.packages,{keep_going:!0}),e.destroy()}await((a,...r)=>e(t.get(a),...r))("py-game",c,a.interpreter,g,m||location.href)}a.interpreter.registerJsModule("_pyscript",{PyWorker(){throw new Error("Unable to use PyWorker in py-game scripts")},js_import:(...e)=>Promise.all(e.map((e=>import(e)))),get target(){return s.id}}),await a.interpreter.runPythonAsync(n);let m=i(s.textContent);s.src&&(m=await fetch(s.src).then(o));const l=s.getAttribute("target")||"canvas",y=document.getElementById(l);a.interpreter.canvas.setCanvas2D(y);const f=new CustomEvent("py-game",{bubbles:!0,cancelable:!0,detail:{canvas:y,code:m,config:g,wrap:a}});s.dispatchEvent(f),f.defaultPrevented||await a.interpreter.runPythonAsync(m)}}};a("py-game",{config:{packages:["pygame-ce"]},configURL:new URL("./config.txt",location.href).href,interpreter:"pyodide",env:"py-game",hooks:g});
//# sourceMappingURL=py-game-Cu1UY3qC.js.map
