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