Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

polyscript

Package Overview
Dependencies
Maintainers
2
Versions
157
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

polyscript - npm Package Compare versions

Comparing version 0.3.4 to 0.3.5

9

cjs/utils.js

@@ -21,4 +21,11 @@ 'use strict';

/**
* Notify the main thread about element "readiness".
* @param {HTMLScriptElement | HTMLElement} target the script or custom-type element
* @param {string} type the custom/type as event prefix
* @param {boolean} worker `true` if dispatched form a worker, `false` if in main
* @param {globalThis.CustomEvent} CustomEvent the right global to use
*/
const dispatch = (target, type, worker, CustomEvent) => {
if (target) target.dispatchEvent(
target.dispatchEvent(
new CustomEvent(`${type}:ready`, {

@@ -25,0 +32,0 @@ bubbles: true,

2

cjs/worker/xworker.js
'use strict';
/* c8 ignore next */
module.exports = () => new Worker(URL.createObjectURL(new Blob(["const e=\"object\"==typeof self?self:globalThis,t=t=>((t,r)=>{const n=(e,r)=>(t.set(r,e),e),s=o=>{if(t.has(o))return t.get(o);const[a,i]=r[o];switch(a){case 0:case-1:return n(i,o);case 1:{const e=n([],o);for(const t of i)e.push(s(t));return e}case 2:{const e=n({},o);for(const[t,r]of i)e[s(t)]=s(r);return e}case 3:return n(new Date(i),o);case 4:{const{source:e,flags:t}=i;return n(new RegExp(e,t),o)}case 5:{const e=n(new Map,o);for(const[t,r]of i)e.set(s(t),s(r));return e}case 6:{const e=n(new Set,o);for(const t of i)e.add(s(t));return e}case 7:{const{name:t,message:r}=i;return n(new e[t](r),o)}case 8:return n(BigInt(i),o);case\"BigInt\":return n(Object(BigInt(i)),o)}return n(new e[a](i),o)};return s})(new Map,t)(0),r=\"\",{toString:n}={},{keys:s}=Object,o=e=>{const t=typeof e;if(\"object\"!==t||!e)return[0,t];const s=n.call(e).slice(8,-1);switch(s){case\"Array\":return[1,r];case\"Object\":return[2,r];case\"Date\":return[3,r];case\"RegExp\":return[4,r];case\"Map\":return[5,r];case\"Set\":return[6,r]}return s.includes(\"Array\")?[1,s]:s.includes(\"Error\")?[7,s]:[2,s]},a=([e,t])=>0===e&&(\"function\"===t||\"symbol\"===t),i=(e,{json:t,lossy:r}={})=>{const n=[];return((e,t,r,n)=>{const i=(e,t)=>{const s=n.push(e)-1;return r.set(t,s),s},c=n=>{if(r.has(n))return r.get(n);let[l,u]=o(n);switch(l){case 0:{let t=n;switch(u){case\"bigint\":l=8,t=n.toString();break;case\"function\":case\"symbol\":if(e)throw new TypeError(\"unable to serialize \"+u);t=null;break;case\"undefined\":return i([-1],n)}return i([l,t],n)}case 1:{if(u)return i([u,[...n]],n);const e=[],t=i([l,e],n);for(const t of n)e.push(c(t));return t}case 2:{if(u)switch(u){case\"BigInt\":return i([u,n.toString()],n);case\"Boolean\":case\"Number\":case\"String\":return i([u,n.valueOf()],n)}if(t&&\"toJSON\"in n)return c(n.toJSON());const r=[],f=i([l,r],n);for(const t of s(n))!e&&a(o(n[t]))||r.push([c(t),c(n[t])]);return f}case 3:return i([l,n.toISOString()],n);case 4:{const{source:e,flags:t}=n;return i([l,{source:e,flags:t}],n)}case 5:{const t=[],r=i([l,t],n);for(const[r,s]of n)(e||!a(o(r))&&!a(o(s)))&&t.push([c(r),c(s)]);return r}case 6:{const t=[],r=i([l,t],n);for(const r of n)!e&&a(o(r))||t.push(c(r));return r}}const{message:f}=n;return i([l,{name:u,message:f}],n)};return c})(!(t||r),!!t,new Map,n)(e),n},{parse:c,stringify:l}=JSON,u={json:!0,lossy:!0};var f=Object.freeze({__proto__:null,parse:e=>t(c(e)),stringify:e=>l(i(e,u))});const p=\"891249cd-eb53-4bc8-ae48-b0a5a277d24a\",d=\"M\"+p,g=\"T\"+p;var y=e=>({value:new Promise((t=>{let r=new Worker(\"data:application/javascript,onmessage%3D(%7Bdata%3Ab%7D)%3D%3E(Atomics.wait(b%2C0)%2CpostMessage(0))\");r.onmessage=t,r.postMessage(e)}))})\n/*! (c) Andrea Giammarchi - ISC */;const{Int32Array:h,Map:w,SharedArrayBuffer:m,Uint16Array:b}=globalThis,{BYTES_PER_ELEMENT:v}=h,{BYTES_PER_ELEMENT:S}=b,{isArray:E}=Array,{notify:P,wait:A,waitAsync:M}=Atomics,{fromCharCode:$}=String,j=(e,t)=>e?(M||y)(t,0):(A(t,0),{value:{then:e=>e()}}),k=new WeakSet,x=new WeakMap;let T=0;const _=(e,{parse:t,stringify:r,transform:n}=JSON)=>{if(!x.has(e)){const s=(t,...r)=>e.postMessage({[p]:r},{transfer:t});let o=!1;x.set(e,new Proxy(new w,{has:(e,t)=>\"string\"==typeof t&&!t.startsWith(\"_\"),get:(r,a)=>\"then\"===a?null:(...r)=>{const i=T++;let c=new h(new m(v)),l=[];k.has(r.at(-1)||l)&&k.delete(l=r.pop()),s(l,i,c,a,n?r.map(n):r);const u=e!==globalThis;let f=0;return o&&u&&(f=setTimeout(console.warn,1e3,`💀🔒 - Possible deadlock if proxy.${a}(...args) is awaited`)),j(u,c).value.then((()=>{clearTimeout(f);const e=c[0];if(!e)return;const r=S*e;return c=new h(new m(r+r%v)),s([],i,c),j(u,c).value.then((()=>t($(...new b(c.buffer).slice(0,e)))))}))},set(t,n,s){if(!t.size){const n=new w;e.addEventListener(\"message\",(async e=>{const s=e.data?.[p];if(E(s)){e.stopImmediatePropagation();const[a,i,...c]=s;if(c.length){const[e,s]=c;if(!t.has(e))throw new Error(`Unsupported action: ${e}`);o=!0;try{const o=await t.get(e)(...s);if(void 0!==o){const e=r(o);n.set(a,e),i[0]=e.length}}finally{o=!1}}else{const e=n.get(a);n.delete(a);for(let t=new b(i.buffer),r=0;r<e.length;r++)t[r]=e.charCodeAt(r)}P(i,0)}}))}return!!t.set(n,s)}}))}return x.get(e)};_.transfer=(...e)=>(k.add(e),e);const O=\"object\",F=\"function\",W=\"number\",R=\"string\",B=\"undefined\",J=\"symbol\",{defineProperty:I,getOwnPropertyDescriptor:L,getPrototypeOf:C,isExtensible:H,ownKeys:D,preventExtensions:N,set:U,setPrototypeOf:z}=Reflect,{assign:q,create:K}=Object,Y=C(Int8Array),G=\"isArray\",V=(e,t)=>{const{get:r,set:n,value:s}=e;return r&&(e.get=t(r)),n&&(e.set=t(n)),s&&(e.value=t(s)),e},Q=(e,t)=>[e,t],X=e=>t=>{const r=typeof t;switch(r){case O:if(null==t)return Q(\"null\",t);if(t===globalThis)return Q(O,null);case F:return e(r,t);case\"boolean\":case W:case R:case B:case\"bigint\":return Q(r,t);case J:if(Z.has(t))return Q(r,Z.get(t))}throw new Error(`Unable to handle this ${r} type`)},Z=new Map(D(Symbol).filter((e=>typeof Symbol[e]===J)).map((e=>[Symbol[e],e]))),ee=e=>{for(const[t,r]of Z)if(r===e)return t};function te(){return this}const re=\"apply\",ne=\"construct\",se=\"defineProperty\",oe=\"deleteProperty\",ae=\"get\",ie=\"getOwnPropertyDescriptor\",ce=\"getPrototypeOf\",le=\"has\",ue=\"isExtensible\",fe=\"ownKeys\",pe=\"preventExtensions\",de=\"set\",ge=\"setPrototypeOf\",ye=\"delete\";var he=((e,t)=>{const r=t&&new WeakMap;if(t){const{addEventListener:e}=EventTarget.prototype;I(EventTarget.prototype,\"addEventListener\",{value(t,n,...s){return s.at(0)?.invoke&&(r.has(this)||r.set(this,new Map),r.get(this).set(t,[].concat(s[0].invoke)),delete s[0].invoke),e.call(this,t,n,...s)}})}const n=t&&(e=>{const{currentTarget:t,target:n,type:s}=e;for(const o of r.get(t||n)?.get(s)||[])e[o]()});return(r,s,o,...a)=>{let i=0;const c=new Map,l=new Map,{[o]:u}=r,f=a.length?q(K(globalThis),...a):globalThis,p=X(((e,t)=>{if(!c.has(t)){let e;for(;l.has(e=i++););c.set(t,e),l.set(e,t)}return Q(e,c.get(t))})),d=new FinalizationRegistry((e=>{u(ye,Q(R,e))})),g=([e,r])=>{switch(e){case O:if(null==r)return f;if(typeof r===W)return l.get(r);if(!(r instanceof Y))for(const e in r)r[e]=g(r[e]);return r;case F:if(typeof r===R){if(!l.has(r)){const e=function(...e){return t&&e.at(0)instanceof Event&&n(...e),u(re,Q(F,r),p(this),e.map(p))},s=new WeakRef(e);l.set(r,s),d.register(e,r,s)}return l.get(r).deref()}return l.get(r);case J:return ee(r)}return r},y={[re]:(e,t,r)=>p(e.apply(t,r)),[ne]:(e,t)=>p(new e(...t)),[se]:(e,t,r)=>p(I(e,t,r)),[oe]:(e,t)=>p(delete e[t]),[ce]:e=>p(C(e)),[ae]:(e,t)=>p(e[t]),[ie]:(e,t)=>{const r=L(e,t);return r?Q(O,V(r,p)):Q(B,r)},[le]:(e,t)=>p(t in e),[ue]:e=>p(H(e)),[fe]:e=>Q(O,D(e).map(p)),[pe]:e=>p(N(e)),[de]:(e,t,r)=>p(U(e,t,r)),[ge]:(e,t)=>p(z(e,t)),[ye](e){c.delete(l.get(e)),l.delete(e)}};return r[s]=(e,t,...r)=>{switch(e){case re:r[0]=g(r[0]),r[1]=r[1].map(g);break;case ne:r[0]=r[0].map(g);break;case se:{const[e,t]=r;r[0]=g(e);const{get:n,set:s,value:o}=t;n&&(t.get=g(n)),s&&(t.set=g(s)),o&&(t.value=g(o));break}default:r=r.map(g)}return y[e](g(t),...r)},{proxy:r,[e.toLowerCase()]:f,[`is${e}Proxy`]:()=>!1}}})(\"Window\",!0),we=(e=>{let t=0;const r=new Map,n=new Map,s=Symbol(),o=e=>typeof e===F?e():e,a=e=>typeof e===O&&!!e&&s in e,i=Array[G],c=X(((e,a)=>{if(s in a)return o(a[s]);if(e===F){if(!n.has(a)){let e;for(;n.has(e=String(t++)););r.set(a,e),n.set(e,a)}return Q(e,r.get(a))}if(!(a instanceof Y))for(const e in a)a[e]=c(a[e]);return Q(e,a)}));return(t,l,u)=>{const{[l]:f}=t,p=new Map,d=new FinalizationRegistry((e=>{p.delete(e),f(ye,c(e))})),g=e=>{const[t,r]=e;if(!p.has(r)){const n=t===F?te.bind(e):e,s=new Proxy(n,w),o=new WeakRef(s);p.set(r,o),d.register(s,r,o)}return p.get(r).deref()},y=e=>{const[t,r]=e;switch(t){case O:return null===r?globalThis:typeof r===W?g(e):r;case F:return typeof r===R?n.get(r):g(e);case J:return ee(r)}return r},h=(e,t,...r)=>y(f(e,o(t),...r)),w={[re]:(e,t,r)=>h(re,e,c(t),r.map(c)),[ne]:(e,t)=>h(ne,e,t.map(c)),[se]:(e,t,r)=>{const{get:n,set:s,value:o}=r;return typeof n===F&&(r.get=c(n)),typeof s===F&&(r.set=c(s)),typeof o===F&&(r.value=c(o)),h(se,e,c(t),r)},[oe]:(e,t)=>h(oe,e,c(t)),[ce]:e=>h(ce,e),[ae]:(e,t)=>t===s?e:h(ae,e,c(t)),[ie]:(e,t)=>{const r=h(ie,e,c(t));return r&&V(r,y)},[le]:(e,t)=>t===s||h(le,e,c(t)),[ue]:e=>h(ue,e),[fe]:e=>h(fe,e).map(y),[pe]:e=>h(pe,e),[de]:(e,t,r)=>h(de,e,c(t),c(r)),[ge]:(e,t)=>h(ge,e,c(t))};t[u]=(e,t,s,o)=>{switch(e){case re:return y(t).apply(y(s),o.map(y));case ye:{const e=y(t);r.delete(n.get(e)),n.delete(e)}}};const m=new Proxy([O,null],w),b=m.Array[G];return I(Array,G,{value:e=>a(e)?b(e):i(e)}),{[e.toLowerCase()]:m,[`is${e}Proxy`]:a,proxy:t}}})(\"Window\"),me=\"function\"==typeof Worker?Worker:class{};const be=new WeakMap,ve=(e,...t)=>{const r=_(e,...t);if(!be.has(r)){const t=e instanceof me?he:we;be.set(r,t(r,d,g))}return be.get(r)};ve.transfer=_.transfer;const Se={object(...e){return this.string(function(e){for(var t=e[0],r=1,n=arguments.length;r<n;r++)t+=arguments[r]+e[r];return t}(...e))},string(e){for(const t of e.split(/[\\r\\n]+/))if(t.trim().length){/^(\\s+)/.test(t)&&(e=e.replace(new RegExp(\"^\"+RegExp.$1,\"gm\"),\"\"));break}return e}},Ee=(e,...t)=>Se[typeof e](e,...t),{isArray:Pe}=Array,{assign:Ae,create:Me,defineProperties:$e,defineProperty:je,entries:ke}=Object,{all:xe,resolve:Te}=new Proxy(Promise,{get:(e,t)=>e[t].bind(e)}),_e=(e,t=location.href)=>new URL(e,t).href;Promise.withResolvers||(Promise.withResolvers=function(){var e,t,r=new this((function(r,n){e=r,t=n}));return{resolve:e,reject:t,promise:r}});const Oe=e=>e.arrayBuffer(),Fe=e=>e.json(),We=e=>e.text(),Re=new WeakMap,Be=e=>{const t=e||console,r={stderr:(t.stderr||console.error).bind(t),stdout:(t.stdout||console.log).bind(t)};return{stderr:(...e)=>r.stderr(...e),stdout:(...e)=>r.stdout(...e),async get(e){const t=await e;return Re.set(t,r),t}}},Je=({FS:e,PATH:t,PATH_FS:r},n,s)=>{const o=r.resolve(n);return e.mkdirTree(t.dirname(o)),e.writeFile(o,new Uint8Array(s),{canOwn:!0})},Ie=e=>{const t=e.split(\"/\");return t.pop(),t.join(\"/\")},Le=(e,t)=>{const r=[];for(const n of t.split(\"/\"))\".\"!==n&&(r.push(n),n&&e.mkdir(r.join(\"/\")))},Ce=(e,t)=>{const r=[];for(const e of t.split(\"/\"))switch(e){case\"\":case\".\":break;case\"..\":r.pop();break;default:r.push(e)}return[e.cwd()].concat(r).join(\"/\").replace(/^\\/+/,\"/\")},He=e=>{const t=e.map((e=>e.trim().replace(/(^[/]*|[/]*$)/g,\"\"))).filter((e=>\"\"!==e&&\".\"!==e)).join(\"/\");return e[0].startsWith(\"/\")?`/${t}`:t},De=new WeakMap,Ne=(e,t,r)=>xe((e=>{for(const{files:t,to_file:r,from:n=\"\"}of e){if(void 0!==t&&void 0!==r)throw new Error(\"Cannot use 'to_file' and 'files' parameters together!\");if(void 0===t&&void 0===r&&n.endsWith(\"/\"))throw new Error(`Couldn't determine the filename from the path ${n}, please supply 'to_file' parameter.`)}return e.flatMap((({from:e=\"\",to_folder:t=\".\",to_file:r,files:n})=>{if(Pe(n))return n.map((r=>({url:He([e,r]),path:He([t,r])})));const s=r||e.slice(1+e.lastIndexOf(\"/\"));return[{url:e,path:He([t,s])}]}))})(r).map((({url:n,path:s})=>((e,t)=>fetch(_e(t,De.get(e))))(r,n).then(Oe).then((r=>e.writeFile(t,s,r)))))),Ue=(e,t,r)=>{e.registerJsModule(t,r)},ze=(e,t,...r)=>{try{return e.runPython(Ee(t),...r)}catch(t){Re.get(e).stderr(t)}},qe=async(e,t,...r)=>{try{return await e.runPythonAsync(Ee(t),...r)}catch(t){Re.get(e).stderr(t)}},Ke=async(e,t,r)=>{const[n,...s]=t.split(\".\");let o,a=e.globals.get(n);for(const e of s)[o,a]=[a,a[e]];try{await a.call(o,r)}catch(t){Re.get(e).stderr(t)}};var Ye={type:\"micropython\",module:(e=\"1.20.0-297\")=>`https://cdn.jsdelivr.net/npm/@micropython/micropython-webassembly-pyscript@${e}/micropython.mjs`,async engine({loadMicroPython:e},t,r){const{stderr:n,stdout:s,get:o}=Be();r=r.replace(/\\.m?js$/,\".wasm\");const a=await o(e({stderr:n,stdout:s,url:r}));return t.fetch&&await Ne(this,a,t.fetch),a},registerJSModule:Ue,run:ze,runAsync:qe,runEvent:Ke,transform:(e,t)=>t,writeFile:({FS:e,_module:{PATH:t,PATH_FS:r}},n,s)=>Je({FS:e,PATH:t,PATH_FS:r},n,s)};const Ge={dict_converter:Object.fromEntries};var Ve={type:\"pyodide\",module:(e=\"0.23.4\")=>`https://cdn.jsdelivr.net/pyodide/v${e}/full/pyodide.mjs`,async engine({loadPyodide:e},t,r){const{stderr:n,stdout:s,get:o}=Be(),a=r.slice(0,r.lastIndexOf(\"/\")),i=await o(e({stderr:n,stdout:s,indexURL:a}));if(t.fetch&&await Ne(this,i,t.fetch),t.packages){await i.loadPackage(\"micropip\");const e=await i.pyimport(\"micropip\");await e.install(t.packages),e.destroy()}return i},registerJSModule:Ue,run:ze,runAsync:qe,runEvent:Ke,transform:(e,t)=>t instanceof e.ffi.PyProxy?t.toJs(Ge):t,writeFile:({FS:e,PATH:t,_module:{PATH_FS:r}},n,s)=>Je({FS:e,PATH:t,PATH_FS:r},n,s)};const Qe=\"ruby-wasm-wasi\",Xe=Qe.replace(/\\W+/g,\"_\");var Ze={type:Qe,experimental:!0,module:(e=\"2.0.0\")=>`https://cdn.jsdelivr.net/npm/ruby-3_2-wasm-wasi@${e}/dist/browser.esm.js`,async engine({DefaultRubyVM:e},t,r){const n=await fetch(`${r.slice(0,r.lastIndexOf(\"/\"))}/ruby.wasm`),s=await WebAssembly.compile(await n.arrayBuffer()),{vm:o}=await e(s);return t.fetch&&await Ne(this,o,t.fetch),o},registerJSModule(e,t,r){const n=`__module_${Xe}_${t}`;globalThis[n]=r,this.run(e,`require \"js\";$${t}=JS.global[:${n}]`),delete globalThis[n]},run:(e,t,...r)=>e.eval(Ee(t),...r),runAsync:(e,t,...r)=>e.evalAsync(Ee(t),...r),async runEvent(e,t,r){if(/^xworker\\.(on\\w+)$/.test(t)){const{$1:t}=RegExp,n=`__module_${Xe}_event`;globalThis[n]=r,this.run(e,`require \"js\";$xworker.call(\"${t}\",JS.global[:${n}])`),delete globalThis[n]}else{const n=this.run(e,`method(:${t})`);await n.call(t,e.wrap(r))}},transform:(e,t)=>t,writeFile:()=>{throw new Error(`writeFile is not supported in ${Qe}`)}};var et={type:\"wasmoon\",module:(e=\"1.15.0\")=>`https://cdn.jsdelivr.net/npm/wasmoon@${e}/+esm`,async engine({LuaFactory:e,LuaLibraries:t},r){const{stderr:n,stdout:s,get:o}=Be(),a=await o((new e).createEngine());return a.global.getTable(t.Base,(e=>{a.global.setField(e,\"print\",s),a.global.setField(e,\"printErr\",n)})),r.fetch&&await Ne(this,a,r.fetch),a},registerJSModule:(e,t,r)=>{e.global.set(t,r)},run:(e,t,...r)=>{try{return e.doStringSync(Ee(t),...r)}catch(t){Re.get(e).stderr(t)}},runAsync:async(e,t,...r)=>{try{return await e.doString(Ee(t),...r)}catch(t){Re.get(e).stderr(t)}},runEvent:async(e,t,r)=>{const[n,...s]=t.split(\".\");let o,a=e.global.get(n);for(const e of s)[o,a]=[a,a[e]];try{await a.call(o,r)}catch(t){Re.get(e).stderr(t)}},transform:(e,t)=>t,writeFile:({cmodule:{module:{FS:e}}},t,r)=>((e,t,r)=>(Le(e,Ie(t)),t=Ce(e,t),e.writeFile(t,new Uint8Array(r),{canOwn:!0})))(e,t,r)};const tt=new Map,rt=new Map,nt=new Proxy(new Map,{get(e,t){if(!e.has(t)){const[r,...n]=t.split(\"@\"),s=tt.get(r),o=/^https?:\\/\\//i.test(n)?n.join(\"@\"):s.module(...n);e.set(t,{url:o,module:import(o),engine:s.engine.bind(s)})}const{url:r,module:n,engine:s}=e.get(t);return(e,o)=>n.then((n=>{rt.set(t,e);const a=e?.fetch;return a&&De.set(a,o),s(n,e,r)}))}}),st=e=>{for(const t of[].concat(e.type))tt.set(t,e)};for(const e of[Ye,Ve,Ze,et])st(e);const ot=async e=>(await import(\"https://cdn.jsdelivr.net/npm/basic-toml@0.3.1/es.js\")).parse(e);try{new SharedArrayBuffer(4)}catch(e){throw new Error([\"Unable to use SharedArrayBuffer due insecure environment.\",\"Please read requirements in MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer#security_requirements\"].join(\"\\n\"))}let at,it,ct;const lt=(e,t)=>{addEventListener(e,t||(async t=>{try{await at,it(`xworker.on${e}`,t)}catch(e){postMessage(e)}}),!!t&&{once:!0})},{parse:ut,stringify:ft}=f,{proxy:pt,window:dt,isWindowProxy:gt}=ve(self,{parse:ut,stringify:ft,transform:e=>ct?ct(e):e}),yt={sync:pt,window:dt,isWindowProxy:gt,onmessage:console.info,onerror:console.error,onmessageerror:console.warn,postMessage:postMessage.bind(self)};lt(\"message\",(({data:{options:e,config:t,code:r,hooks:n}})=>{at=(async()=>{try{const{id:s,tag:o,type:a,custom:i,version:c,config:l,async:u}=e,f=await((e,t,r={})=>{if(t)if(t.endsWith(\".json\"))r=fetch(t).then(Fe),t=_e(t);else if(t.endsWith(\".toml\"))r=fetch(t).then(We).then(ot),t=_e(t);else if(!t.endsWith(\".txt\")){try{r=JSON.parse(t)}catch(e){r=ot(t)}t=_e(\"./config.txt\")}return Te(r).then((r=>nt[e](r,t)))})(((e,t=\"\")=>`${e}@${t}`.replace(/@$/,\"\"))(a,c),t,l),p=Me(tt.get(a)),d=\"run\"+(u?\"Async\":\"\");if(n){const{beforeRun:e,beforeRunAsync:t,afterRun:r,afterRunAsync:s}=n,o=r||s,a=e||t;if(o){const e=p[d].bind(p);p[d]=(t,r,...n)=>e(t,`${r}\\n${o}`,...n)}if(a){const e=p[d].bind(p);p[d]=(t,r,...n)=>e(t,`${a}\\n${r}`,...n)}}const{CustomEvent:g,document:y}=dt,h=y.getElementById(s);let w=\"\";return p.registerJSModule(f,\"polyscript\",{xworker:yt,get target(){return w||(\"SCRIPT\"===o?h.after(Ae(y.createElement(`script-${i||a}`),{id:w=`${s}-target`})):(w=s,h.replaceChildren(),h.style.display=\"block\")),w}}),it=p.runEvent.bind(p,f),ct=p.transform.bind(p,f),((e,t,r,n)=>{e&&e.dispatchEvent(new n(`${t}:ready`,{bubbles:!0,detail:{worker:r}}))})(h,i||a,!0,g),await p[d](f,r),f}catch(e){postMessage(e)}})(),lt(\"error\"),lt(\"message\"),lt(\"messageerror\")}));\n"],{type:'application/javascript'})),{type:'module'});
module.exports = () => new Worker(URL.createObjectURL(new Blob(["const e=\"object\"==typeof self?self:globalThis,t=t=>((t,r)=>{const n=(e,r)=>(t.set(r,e),e),s=o=>{if(t.has(o))return t.get(o);const[a,i]=r[o];switch(a){case 0:case-1:return n(i,o);case 1:{const e=n([],o);for(const t of i)e.push(s(t));return e}case 2:{const e=n({},o);for(const[t,r]of i)e[s(t)]=s(r);return e}case 3:return n(new Date(i),o);case 4:{const{source:e,flags:t}=i;return n(new RegExp(e,t),o)}case 5:{const e=n(new Map,o);for(const[t,r]of i)e.set(s(t),s(r));return e}case 6:{const e=n(new Set,o);for(const t of i)e.add(s(t));return e}case 7:{const{name:t,message:r}=i;return n(new e[t](r),o)}case 8:return n(BigInt(i),o);case\"BigInt\":return n(Object(BigInt(i)),o)}return n(new e[a](i),o)};return s})(new Map,t)(0),r=\"\",{toString:n}={},{keys:s}=Object,o=e=>{const t=typeof e;if(\"object\"!==t||!e)return[0,t];const s=n.call(e).slice(8,-1);switch(s){case\"Array\":return[1,r];case\"Object\":return[2,r];case\"Date\":return[3,r];case\"RegExp\":return[4,r];case\"Map\":return[5,r];case\"Set\":return[6,r]}return s.includes(\"Array\")?[1,s]:s.includes(\"Error\")?[7,s]:[2,s]},a=([e,t])=>0===e&&(\"function\"===t||\"symbol\"===t),i=(e,{json:t,lossy:r}={})=>{const n=[];return((e,t,r,n)=>{const i=(e,t)=>{const s=n.push(e)-1;return r.set(t,s),s},c=n=>{if(r.has(n))return r.get(n);let[l,u]=o(n);switch(l){case 0:{let t=n;switch(u){case\"bigint\":l=8,t=n.toString();break;case\"function\":case\"symbol\":if(e)throw new TypeError(\"unable to serialize \"+u);t=null;break;case\"undefined\":return i([-1],n)}return i([l,t],n)}case 1:{if(u)return i([u,[...n]],n);const e=[],t=i([l,e],n);for(const t of n)e.push(c(t));return t}case 2:{if(u)switch(u){case\"BigInt\":return i([u,n.toString()],n);case\"Boolean\":case\"Number\":case\"String\":return i([u,n.valueOf()],n)}if(t&&\"toJSON\"in n)return c(n.toJSON());const r=[],f=i([l,r],n);for(const t of s(n))!e&&a(o(n[t]))||r.push([c(t),c(n[t])]);return f}case 3:return i([l,n.toISOString()],n);case 4:{const{source:e,flags:t}=n;return i([l,{source:e,flags:t}],n)}case 5:{const t=[],r=i([l,t],n);for(const[r,s]of n)(e||!a(o(r))&&!a(o(s)))&&t.push([c(r),c(s)]);return r}case 6:{const t=[],r=i([l,t],n);for(const r of n)!e&&a(o(r))||t.push(c(r));return r}}const{message:f}=n;return i([l,{name:u,message:f}],n)};return c})(!(t||r),!!t,new Map,n)(e),n},{parse:c,stringify:l}=JSON,u={json:!0,lossy:!0};var f=Object.freeze({__proto__:null,parse:e=>t(c(e)),stringify:e=>l(i(e,u))});const p=\"3099687a-04a9-4406-a08e-fd1602cb2a81\",d=\"M\"+p,g=\"T\"+p;var y=e=>({value:new Promise((t=>{let r=new Worker(\"data:application/javascript,onmessage%3D(%7Bdata%3Ab%7D)%3D%3E(Atomics.wait(b%2C0)%2CpostMessage(0))\");r.onmessage=t,r.postMessage(e)}))})\n/*! (c) Andrea Giammarchi - ISC */;const{Int32Array:h,Map:w,SharedArrayBuffer:m,Uint16Array:b}=globalThis,{BYTES_PER_ELEMENT:v}=h,{BYTES_PER_ELEMENT:S}=b,{isArray:E}=Array,{notify:P,wait:A,waitAsync:M}=Atomics,{fromCharCode:$}=String,j=(e,t)=>e?(M||y)(t,0):(A(t,0),{value:{then:e=>e()}}),k=new WeakSet,x=new WeakMap;let T=0;const _=(e,{parse:t,stringify:r,transform:n}=JSON)=>{if(!x.has(e)){const s=(t,...r)=>e.postMessage({[p]:r},{transfer:t});let o=!1;x.set(e,new Proxy(new w,{has:(e,t)=>\"string\"==typeof t&&!t.startsWith(\"_\"),get:(r,a)=>\"then\"===a?null:(...r)=>{const i=T++;let c=new h(new m(v)),l=[];k.has(r.at(-1)||l)&&k.delete(l=r.pop()),s(l,i,c,a,n?r.map(n):r);const u=e!==globalThis;let f=0;return o&&u&&(f=setTimeout(console.warn,1e3,`💀🔒 - Possible deadlock if proxy.${a}(...args) is awaited`)),j(u,c).value.then((()=>{clearTimeout(f);const e=c[0];if(!e)return;const r=S*e;return c=new h(new m(r+r%v)),s([],i,c),j(u,c).value.then((()=>t($(...new b(c.buffer).slice(0,e)))))}))},set(t,s,a){if(!t.size){const s=new w;e.addEventListener(\"message\",(async e=>{const a=e.data?.[p];if(E(a)){e.stopImmediatePropagation();const[i,c,...l]=a;if(l.length){const[e,a]=l;if(!t.has(e))throw new Error(`Unsupported action: ${e}`);o=!0;try{const o=await t.get(e)(...a);if(void 0!==o){const e=r(n?n(o):o);s.set(i,e),c[0]=e.length}}finally{o=!1}}else{const e=s.get(i);s.delete(i);for(let t=new b(c.buffer),r=0;r<e.length;r++)t[r]=e.charCodeAt(r)}P(c,0)}}))}return!!t.set(s,a)}}))}return x.get(e)};_.transfer=(...e)=>(k.add(e),e);const O=\"object\",F=\"function\",W=\"number\",R=\"string\",B=\"undefined\",J=\"symbol\",{defineProperty:I,getOwnPropertyDescriptor:L,getPrototypeOf:C,isExtensible:H,ownKeys:D,preventExtensions:N,set:U,setPrototypeOf:z}=Reflect,{assign:q,create:K}=Object,Y=C(Int8Array),G=\"isArray\",V=(e,t)=>{const{get:r,set:n,value:s}=e;return r&&(e.get=t(r)),n&&(e.set=t(n)),s&&(e.value=t(s)),e},Q=(e,t)=>[e,t],X=e=>t=>{const r=typeof t;switch(r){case O:if(null==t)return Q(\"null\",t);if(t===globalThis)return Q(O,null);case F:return e(r,t);case\"boolean\":case W:case R:case B:case\"bigint\":return Q(r,t);case J:if(Z.has(t))return Q(r,Z.get(t))}throw new Error(`Unable to handle this ${r} type`)},Z=new Map(D(Symbol).filter((e=>typeof Symbol[e]===J)).map((e=>[Symbol[e],e]))),ee=e=>{for(const[t,r]of Z)if(r===e)return t};function te(){return this}const re=\"apply\",ne=\"construct\",se=\"defineProperty\",oe=\"deleteProperty\",ae=\"get\",ie=\"getOwnPropertyDescriptor\",ce=\"getPrototypeOf\",le=\"has\",ue=\"isExtensible\",fe=\"ownKeys\",pe=\"preventExtensions\",de=\"set\",ge=\"setPrototypeOf\",ye=\"delete\";var he=((e,t)=>{const r=t&&new WeakMap;if(t){const{addEventListener:e}=EventTarget.prototype;I(EventTarget.prototype,\"addEventListener\",{value(t,n,...s){return s.at(0)?.invoke&&(r.has(this)||r.set(this,new Map),r.get(this).set(t,[].concat(s[0].invoke)),delete s[0].invoke),e.call(this,t,n,...s)}})}const n=t&&(e=>{const{currentTarget:t,target:n,type:s}=e;for(const o of r.get(t||n)?.get(s)||[])e[o]()});return(r,s,o,...a)=>{let i=0;const c=new Map,l=new Map,{[o]:u}=r,f=a.length?q(K(globalThis),...a):globalThis,p=X(((e,t)=>{if(!c.has(t)){let e;for(;l.has(e=i++););c.set(t,e),l.set(e,t)}return Q(e,c.get(t))})),d=new FinalizationRegistry((e=>{u(ye,Q(R,e))})),g=([e,r])=>{switch(e){case O:if(null==r)return f;if(typeof r===W)return l.get(r);if(!(r instanceof Y))for(const e in r)r[e]=g(r[e]);return r;case F:if(typeof r===R){if(!l.has(r)){const e=function(...e){return t&&e.at(0)instanceof Event&&n(...e),u(re,Q(F,r),p(this),e.map(p))},s=new WeakRef(e);l.set(r,s),d.register(e,r,s)}return l.get(r).deref()}return l.get(r);case J:return ee(r)}return r},y={[re]:(e,t,r)=>p(e.apply(t,r)),[ne]:(e,t)=>p(new e(...t)),[se]:(e,t,r)=>p(I(e,t,r)),[oe]:(e,t)=>p(delete e[t]),[ce]:e=>p(C(e)),[ae]:(e,t)=>p(e[t]),[ie]:(e,t)=>{const r=L(e,t);return r?Q(O,V(r,p)):Q(B,r)},[le]:(e,t)=>p(t in e),[ue]:e=>p(H(e)),[fe]:e=>Q(O,D(e).map(p)),[pe]:e=>p(N(e)),[de]:(e,t,r)=>p(U(e,t,r)),[ge]:(e,t)=>p(z(e,t)),[ye](e){c.delete(l.get(e)),l.delete(e)}};return r[s]=(e,t,...r)=>{switch(e){case re:r[0]=g(r[0]),r[1]=r[1].map(g);break;case ne:r[0]=r[0].map(g);break;case se:{const[e,t]=r;r[0]=g(e);const{get:n,set:s,value:o}=t;n&&(t.get=g(n)),s&&(t.set=g(s)),o&&(t.value=g(o));break}default:r=r.map(g)}return y[e](g(t),...r)},{proxy:r,[e.toLowerCase()]:f,[`is${e}Proxy`]:()=>!1}}})(\"Window\",!0),we=(e=>{let t=0;const r=new Map,n=new Map,s=Symbol(),o=e=>typeof e===F?e():e,a=e=>typeof e===O&&!!e&&s in e,i=Array[G],c=X(((e,a)=>{if(s in a)return o(a[s]);if(e===F){if(!n.has(a)){let e;for(;n.has(e=String(t++)););r.set(a,e),n.set(e,a)}return Q(e,r.get(a))}if(!(a instanceof Y))for(const e in a)a[e]=c(a[e]);return Q(e,a)}));return(t,l,u)=>{const{[l]:f}=t,p=new Map,d=new FinalizationRegistry((e=>{p.delete(e),f(ye,c(e))})),g=e=>{const[t,r]=e;if(!p.has(r)){const n=t===F?te.bind(e):e,s=new Proxy(n,w),o=new WeakRef(s);p.set(r,o),d.register(s,r,o)}return p.get(r).deref()},y=e=>{const[t,r]=e;switch(t){case O:return null===r?globalThis:typeof r===W?g(e):r;case F:return typeof r===R?n.get(r):g(e);case J:return ee(r)}return r},h=(e,t,...r)=>y(f(e,o(t),...r)),w={[re]:(e,t,r)=>h(re,e,c(t),r.map(c)),[ne]:(e,t)=>h(ne,e,t.map(c)),[se]:(e,t,r)=>{const{get:n,set:s,value:o}=r;return typeof n===F&&(r.get=c(n)),typeof s===F&&(r.set=c(s)),typeof o===F&&(r.value=c(o)),h(se,e,c(t),r)},[oe]:(e,t)=>h(oe,e,c(t)),[ce]:e=>h(ce,e),[ae]:(e,t)=>t===s?e:h(ae,e,c(t)),[ie]:(e,t)=>{const r=h(ie,e,c(t));return r&&V(r,y)},[le]:(e,t)=>t===s||h(le,e,c(t)),[ue]:e=>h(ue,e),[fe]:e=>h(fe,e).map(y),[pe]:e=>h(pe,e),[de]:(e,t,r)=>h(de,e,c(t),c(r)),[ge]:(e,t)=>h(ge,e,c(t))};t[u]=(e,t,s,o)=>{switch(e){case re:return y(t).apply(y(s),o.map(y));case ye:{const e=y(t);r.delete(n.get(e)),n.delete(e)}}};const m=new Proxy([O,null],w),b=m.Array[G];return I(Array,G,{value:e=>a(e)?b(e):i(e)}),{[e.toLowerCase()]:m,[`is${e}Proxy`]:a,proxy:t}}})(\"Window\"),me=\"function\"==typeof Worker?Worker:class{};const be=new WeakMap,ve=(e,...t)=>{const r=_(e,...t);if(!be.has(r)){const t=e instanceof me?he:we;be.set(r,t(r,d,g))}return be.get(r)};ve.transfer=_.transfer;const Se={object(...e){return this.string(function(e){for(var t=e[0],r=1,n=arguments.length;r<n;r++)t+=arguments[r]+e[r];return t}(...e))},string(e){for(const t of e.split(/[\\r\\n]+/))if(t.trim().length){/^(\\s+)/.test(t)&&(e=e.replace(new RegExp(\"^\"+RegExp.$1,\"gm\"),\"\"));break}return e}},Ee=(e,...t)=>Se[typeof e](e,...t),{isArray:Pe}=Array,{assign:Ae,create:Me,defineProperties:$e,defineProperty:je,entries:ke}=Object,{all:xe,resolve:Te}=new Proxy(Promise,{get:(e,t)=>e[t].bind(e)}),_e=(e,t=location.href)=>new URL(e,t).href;Promise.withResolvers||(Promise.withResolvers=function(){var e,t,r=new this((function(r,n){e=r,t=n}));return{resolve:e,reject:t,promise:r}});const Oe=e=>e.arrayBuffer(),Fe=e=>e.json(),We=e=>e.text(),Re=new WeakMap,Be=e=>{const t=e||console,r={stderr:(t.stderr||console.error).bind(t),stdout:(t.stdout||console.log).bind(t)};return{stderr:(...e)=>r.stderr(...e),stdout:(...e)=>r.stdout(...e),async get(e){const t=await e;return Re.set(t,r),t}}},Je=({FS:e,PATH:t,PATH_FS:r},n,s)=>{const o=r.resolve(n);return e.mkdirTree(t.dirname(o)),e.writeFile(o,new Uint8Array(s),{canOwn:!0})},Ie=e=>{const t=e.split(\"/\");return t.pop(),t.join(\"/\")},Le=(e,t)=>{const r=[];for(const n of t.split(\"/\"))\".\"!==n&&(r.push(n),n&&e.mkdir(r.join(\"/\")))},Ce=(e,t)=>{const r=[];for(const e of t.split(\"/\"))switch(e){case\"\":case\".\":break;case\"..\":r.pop();break;default:r.push(e)}return[e.cwd()].concat(r).join(\"/\").replace(/^\\/+/,\"/\")},He=e=>{const t=e.map((e=>e.trim().replace(/(^[/]*|[/]*$)/g,\"\"))).filter((e=>\"\"!==e&&\".\"!==e)).join(\"/\");return e[0].startsWith(\"/\")?`/${t}`:t},De=new WeakMap,Ne=(e,t,r)=>xe((e=>{for(const{files:t,to_file:r,from:n=\"\"}of e){if(void 0!==t&&void 0!==r)throw new Error(\"Cannot use 'to_file' and 'files' parameters together!\");if(void 0===t&&void 0===r&&n.endsWith(\"/\"))throw new Error(`Couldn't determine the filename from the path ${n}, please supply 'to_file' parameter.`)}return e.flatMap((({from:e=\"\",to_folder:t=\".\",to_file:r,files:n})=>{if(Pe(n))return n.map((r=>({url:He([e,r]),path:He([t,r])})));const s=r||e.slice(1+e.lastIndexOf(\"/\"));return[{url:e,path:He([t,s])}]}))})(r).map((({url:n,path:s})=>((e,t)=>fetch(_e(t,De.get(e))))(r,n).then(Oe).then((r=>e.writeFile(t,s,r)))))),Ue=(e,t,r)=>{e.registerJsModule(t,r)},ze=(e,t,...r)=>{try{return e.runPython(Ee(t),...r)}catch(t){Re.get(e).stderr(t)}},qe=async(e,t,...r)=>{try{return await e.runPythonAsync(Ee(t),...r)}catch(t){Re.get(e).stderr(t)}},Ke=async(e,t,r)=>{const[n,...s]=t.split(\".\");let o,a=e.globals.get(n);for(const e of s)[o,a]=[a,a[e]];try{await a.call(o,r)}catch(t){Re.get(e).stderr(t)}};var Ye={type:\"micropython\",module:(e=\"1.20.0-297\")=>`https://cdn.jsdelivr.net/npm/@micropython/micropython-webassembly-pyscript@${e}/micropython.mjs`,async engine({loadMicroPython:e},t,r){const{stderr:n,stdout:s,get:o}=Be();r=r.replace(/\\.m?js$/,\".wasm\");const a=await o(e({stderr:n,stdout:s,url:r}));return t.fetch&&await Ne(this,a,t.fetch),a},registerJSModule:Ue,run:ze,runAsync:qe,runEvent:Ke,transform:(e,t)=>t,writeFile:({FS:e,_module:{PATH:t,PATH_FS:r}},n,s)=>Je({FS:e,PATH:t,PATH_FS:r},n,s)};const Ge={dict_converter:Object.fromEntries};var Ve={type:\"pyodide\",module:(e=\"0.23.4\")=>`https://cdn.jsdelivr.net/pyodide/v${e}/full/pyodide.mjs`,async engine({loadPyodide:e},t,r){const{stderr:n,stdout:s,get:o}=Be(),a=r.slice(0,r.lastIndexOf(\"/\")),i=await o(e({stderr:n,stdout:s,indexURL:a}));if(t.fetch&&await Ne(this,i,t.fetch),t.packages){await i.loadPackage(\"micropip\");const e=await i.pyimport(\"micropip\");await e.install(t.packages),e.destroy()}return i},registerJSModule:Ue,run:ze,runAsync:qe,runEvent:Ke,transform:(e,t)=>t instanceof e.ffi.PyProxy?t.toJs(Ge):t,writeFile:({FS:e,PATH:t,_module:{PATH_FS:r}},n,s)=>Je({FS:e,PATH:t,PATH_FS:r},n,s)};const Qe=\"ruby-wasm-wasi\",Xe=Qe.replace(/\\W+/g,\"_\");var Ze={type:Qe,experimental:!0,module:(e=\"2.0.0\")=>`https://cdn.jsdelivr.net/npm/ruby-3_2-wasm-wasi@${e}/dist/browser.esm.js`,async engine({DefaultRubyVM:e},t,r){const n=await fetch(`${r.slice(0,r.lastIndexOf(\"/\"))}/ruby.wasm`),s=await WebAssembly.compile(await n.arrayBuffer()),{vm:o}=await e(s);return t.fetch&&await Ne(this,o,t.fetch),o},registerJSModule(e,t,r){const n=`__module_${Xe}_${t}`;globalThis[n]=r,this.run(e,`require \"js\";$${t}=JS.global[:${n}]`),delete globalThis[n]},run:(e,t,...r)=>e.eval(Ee(t),...r),runAsync:(e,t,...r)=>e.evalAsync(Ee(t),...r),async runEvent(e,t,r){if(/^xworker\\.(on\\w+)$/.test(t)){const{$1:t}=RegExp,n=`__module_${Xe}_event`;globalThis[n]=r,this.run(e,`require \"js\";$xworker.call(\"${t}\",JS.global[:${n}])`),delete globalThis[n]}else{const n=this.run(e,`method(:${t})`);await n.call(t,e.wrap(r))}},transform:(e,t)=>t,writeFile:()=>{throw new Error(`writeFile is not supported in ${Qe}`)}};var et={type:\"wasmoon\",module:(e=\"1.15.0\")=>`https://cdn.jsdelivr.net/npm/wasmoon@${e}/+esm`,async engine({LuaFactory:e,LuaLibraries:t},r){const{stderr:n,stdout:s,get:o}=Be(),a=await o((new e).createEngine());return a.global.getTable(t.Base,(e=>{a.global.setField(e,\"print\",s),a.global.setField(e,\"printErr\",n)})),r.fetch&&await Ne(this,a,r.fetch),a},registerJSModule:(e,t,r)=>{e.global.set(t,r)},run:(e,t,...r)=>{try{return e.doStringSync(Ee(t),...r)}catch(t){Re.get(e).stderr(t)}},runAsync:async(e,t,...r)=>{try{return await e.doString(Ee(t),...r)}catch(t){Re.get(e).stderr(t)}},runEvent:async(e,t,r)=>{const[n,...s]=t.split(\".\");let o,a=e.global.get(n);for(const e of s)[o,a]=[a,a[e]];try{await a.call(o,r)}catch(t){Re.get(e).stderr(t)}},transform:(e,t)=>t,writeFile:({cmodule:{module:{FS:e}}},t,r)=>((e,t,r)=>(Le(e,Ie(t)),t=Ce(e,t),e.writeFile(t,new Uint8Array(r),{canOwn:!0})))(e,t,r)};const tt=new Map,rt=new Map,nt=new Proxy(new Map,{get(e,t){if(!e.has(t)){const[r,...n]=t.split(\"@\"),s=tt.get(r),o=/^https?:\\/\\//i.test(n)?n.join(\"@\"):s.module(...n);e.set(t,{url:o,module:import(o),engine:s.engine.bind(s)})}const{url:r,module:n,engine:s}=e.get(t);return(e,o)=>n.then((n=>{rt.set(t,e);const a=e?.fetch;return a&&De.set(a,o),s(n,e,r)}))}}),st=e=>{for(const t of[].concat(e.type))tt.set(t,e)};for(const e of[Ye,Ve,Ze,et])st(e);const ot=async e=>(await import(\"https://cdn.jsdelivr.net/npm/basic-toml@0.3.1/es.js\")).parse(e);try{new SharedArrayBuffer(4)}catch(e){throw new Error([\"Unable to use SharedArrayBuffer due insecure environment.\",\"Please read requirements in MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer#security_requirements\"].join(\"\\n\"))}let at,it,ct;const lt=(e,t)=>{addEventListener(e,t||(async t=>{try{await at,it(`xworker.on${e}`,t)}catch(e){postMessage(e)}}),!!t&&{once:!0})},{parse:ut,stringify:ft}=f,{proxy:pt,window:dt,isWindowProxy:gt}=ve(self,{parse:ut,stringify:ft,transform:e=>ct?ct(e):e}),yt={sync:pt,window:dt,isWindowProxy:gt,onmessage:console.info,onerror:console.error,onmessageerror:console.warn,postMessage:postMessage.bind(self)};lt(\"message\",(({data:{options:e,config:t,code:r,hooks:n}})=>{at=(async()=>{try{const{id:s,tag:o,type:a,custom:i,version:c,config:l,async:u}=e,f=await((e,t,r={})=>{if(t)if(t.endsWith(\".json\"))r=fetch(t).then(Fe),t=_e(t);else if(t.endsWith(\".toml\"))r=fetch(t).then(We).then(ot),t=_e(t);else if(!t.endsWith(\".txt\")){try{r=JSON.parse(t)}catch(e){r=ot(t)}t=_e(\"./config.txt\")}return Te(r).then((r=>nt[e](r,t)))})(((e,t=\"\")=>`${e}@${t}`.replace(/@$/,\"\"))(a,c),t,l),p=Me(tt.get(a)),d=\"run\"+(u?\"Async\":\"\");if(n){const{beforeRun:e,beforeRunAsync:t,afterRun:r,afterRunAsync:s}=n,o=r||s,a=e||t;if(o){const e=p[d].bind(p);p[d]=(t,r,...n)=>e(t,`${r}\\n${o}`,...n)}if(a){const e=p[d].bind(p);p[d]=(t,r,...n)=>e(t,`${a}\\n${r}`,...n)}}const{CustomEvent:g,document:y}=dt,h=s&&y.getElementById(s)||null;let w=\"\";return p.registerJSModule(f,\"polyscript\",{xworker:yt,get target(){return!w&&h&&(\"SCRIPT\"===o?h.after(Ae(y.createElement(`script-${i||a}`),{id:w=`${s}-target`})):(w=s,h.replaceChildren(),h.style.display=\"block\")),w}}),it=p.runEvent.bind(p,f),ct=p.transform.bind(p,f),h&&((e,t,r,n)=>{e.dispatchEvent(new n(`${t}:ready`,{bubbles:!0,detail:{worker:r}}))})(h,i||a,!0,g),await p[d](f,r),f}catch(e){postMessage(e)}})(),lt(\"error\"),lt(\"message\"),lt(\"messageerror\")}));\n"],{type:'application/javascript'})),{type:'module'});

@@ -1,3 +0,3 @@

const e=(e,t=document)=>[...t.querySelectorAll(e)],t=(e,t=document)=>{const r=(new XPathEvaluator).createExpression(e).evaluate(t,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE),n=[];for(let e=0,{snapshotLength:t}=r;e<t;e++)n.push(r.snapshotItem(e));return n},r="object"==typeof self?self:globalThis,n=e=>((e,t)=>{const n=(t,r)=>(e.set(r,t),t),s=o=>{if(e.has(o))return e.get(o);const[a,i]=t[o];switch(a){case 0:case-1:return n(i,o);case 1:{const e=n([],o);for(const t of i)e.push(s(t));return e}case 2:{const e=n({},o);for(const[t,r]of i)e[s(t)]=s(r);return e}case 3:return n(new Date(i),o);case 4:{const{source:e,flags:t}=i;return n(new RegExp(e,t),o)}case 5:{const e=n(new Map,o);for(const[t,r]of i)e.set(s(t),s(r));return e}case 6:{const e=n(new Set,o);for(const t of i)e.add(s(t));return e}case 7:{const{name:e,message:t}=i;return n(new r[e](t),o)}case 8:return n(BigInt(i),o);case"BigInt":return n(Object(BigInt(i)),o)}return n(new r[a](i),o)};return s})(new Map,e)(0),s="",{toString:o}={},{keys:a}=Object,i=e=>{const t=typeof e;if("object"!==t||!e)return[0,t];const r=o.call(e).slice(8,-1);switch(r){case"Array":return[1,s];case"Object":return[2,s];case"Date":return[3,s];case"RegExp":return[4,s];case"Map":return[5,s];case"Set":return[6,s]}return r.includes("Array")?[1,r]:r.includes("Error")?[7,r]:[2,r]},c=([e,t])=>0===e&&("function"===t||"symbol"===t),l=(e,{json:t,lossy:r}={})=>{const n=[];return((e,t,r,n)=>{const s=(e,t)=>{const s=n.push(e)-1;return r.set(t,s),s},o=n=>{if(r.has(n))return r.get(n);let[l,u]=i(n);switch(l){case 0:{let t=n;switch(u){case"bigint":l=8,t=n.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+u);t=null;break;case"undefined":return s([-1],n)}return s([l,t],n)}case 1:{if(u)return s([u,[...n]],n);const e=[],t=s([l,e],n);for(const t of n)e.push(o(t));return t}case 2:{if(u)switch(u){case"BigInt":return s([u,n.toString()],n);case"Boolean":case"Number":case"String":return s([u,n.valueOf()],n)}if(t&&"toJSON"in n)return o(n.toJSON());const r=[],f=s([l,r],n);for(const t of a(n))!e&&c(i(n[t]))||r.push([o(t),o(n[t])]);return f}case 3:return s([l,n.toISOString()],n);case 4:{const{source:e,flags:t}=n;return s([l,{source:e,flags:t}],n)}case 5:{const t=[],r=s([l,t],n);for(const[r,s]of n)(e||!c(i(r))&&!c(i(s)))&&t.push([o(r),o(s)]);return r}case 6:{const t=[],r=s([l,t],n);for(const r of n)!e&&c(i(r))||t.push(o(r));return r}}const{message:f}=n;return s([l,{name:u,message:f}],n)};return o})(!(t||r),!!t,new Map,n)(e),n},{parse:u,stringify:f}=JSON,p={json:!0,lossy:!0};var d=Object.freeze({__proto__:null,parse:e=>n(u(e)),stringify:e=>f(l(e,p))});const h="891249cd-eb53-4bc8-ae48-b0a5a277d24a",g="M"+h,y="T"+h;var w=e=>({value:new Promise((t=>{let r=new Worker("data:application/javascript,onmessage%3D(%7Bdata%3Ab%7D)%3D%3E(Atomics.wait(b%2C0)%2CpostMessage(0))");r.onmessage=t,r.postMessage(e)}))})
/*! (c) Andrea Giammarchi - ISC */;const{Int32Array:m,Map:b,SharedArrayBuffer:v,Uint16Array:E}=globalThis,{BYTES_PER_ELEMENT:S}=m,{BYTES_PER_ELEMENT:A}=E,{isArray:k}=Array,{notify:$,wait:P,waitAsync:M}=Atomics,{fromCharCode:x}=String,j=(e,t)=>e?(M||w)(t,0):(P(t,0),{value:{then:e=>e()}}),T=new WeakSet,R=new WeakMap;let _=0;const O=(e,{parse:t,stringify:r,transform:n}=JSON)=>{if(!R.has(e)){const s=(t,...r)=>e.postMessage({[h]:r},{transfer:t});let o=!1;R.set(e,new Proxy(new b,{has:(e,t)=>"string"==typeof t&&!t.startsWith("_"),get:(r,a)=>"then"===a?null:(...r)=>{const i=_++;let c=new m(new v(S)),l=[];T.has(r.at(-1)||l)&&T.delete(l=r.pop()),s(l,i,c,a,n?r.map(n):r);const u=e!==globalThis;let f=0;return o&&u&&(f=setTimeout(console.warn,1e3,`💀🔒 - Possible deadlock if proxy.${a}(...args) is awaited`)),j(u,c).value.then((()=>{clearTimeout(f);const e=c[0];if(!e)return;const r=A*e;return c=new m(new v(r+r%S)),s([],i,c),j(u,c).value.then((()=>t(x(...new E(c.buffer).slice(0,e)))))}))},set(t,n,s){if(!t.size){const n=new b;e.addEventListener("message",(async e=>{const s=e.data?.[h];if(k(s)){e.stopImmediatePropagation();const[a,i,...c]=s;if(c.length){const[e,s]=c;if(!t.has(e))throw new Error(`Unsupported action: ${e}`);o=!0;try{const o=await t.get(e)(...s);if(void 0!==o){const e=r(o);n.set(a,e),i[0]=e.length}}finally{o=!1}}else{const e=n.get(a);n.delete(a);for(let t=new E(i.buffer),r=0;r<e.length;r++)t[r]=e.charCodeAt(r)}$(i,0)}}))}return!!t.set(n,s)}}))}return R.get(e)};O.transfer=(...e)=>(T.add(e),e);const W="object",F="function",B="number",I="string",L="undefined",J="symbol",{defineProperty:C,getOwnPropertyDescriptor:N,getPrototypeOf:H,isExtensible:D,ownKeys:U,preventExtensions:q,set:z,setPrototypeOf:Q}=Reflect,{assign:X,create:Y}=Object,K=H(Int8Array),G="isArray",V=(e,t)=>{const{get:r,set:n,value:s}=e;return r&&(e.get=t(r)),n&&(e.set=t(n)),s&&(e.value=t(s)),e},Z=(e,t)=>[e,t],ee=e=>t=>{const r=typeof t;switch(r){case W:if(null==t)return Z("null",t);if(t===globalThis)return Z(W,null);case F:return e(r,t);case"boolean":case B:case I:case L:case"bigint":return Z(r,t);case J:if(te.has(t))return Z(r,te.get(t))}throw new Error(`Unable to handle this ${r} type`)},te=new Map(U(Symbol).filter((e=>typeof Symbol[e]===J)).map((e=>[Symbol[e],e]))),re=e=>{for(const[t,r]of te)if(r===e)return t};function ne(){return this}const se="apply",oe="construct",ae="defineProperty",ie="deleteProperty",ce="get",le="getOwnPropertyDescriptor",ue="getPrototypeOf",fe="has",pe="isExtensible",de="ownKeys",he="preventExtensions",ge="set",ye="setPrototypeOf",we="delete";var me=((e,t)=>{const r=t&&new WeakMap;if(t){const{addEventListener:e}=EventTarget.prototype;C(EventTarget.prototype,"addEventListener",{value(t,n,...s){return s.at(0)?.invoke&&(r.has(this)||r.set(this,new Map),r.get(this).set(t,[].concat(s[0].invoke)),delete s[0].invoke),e.call(this,t,n,...s)}})}const n=t&&(e=>{const{currentTarget:t,target:n,type:s}=e;for(const o of r.get(t||n)?.get(s)||[])e[o]()});return(r,s,o,...a)=>{let i=0;const c=new Map,l=new Map,{[o]:u}=r,f=a.length?X(Y(globalThis),...a):globalThis,p=ee(((e,t)=>{if(!c.has(t)){let e;for(;l.has(e=i++););c.set(t,e),l.set(e,t)}return Z(e,c.get(t))})),d=new FinalizationRegistry((e=>{u(we,Z(I,e))})),h=([e,r])=>{switch(e){case W:if(null==r)return f;if(typeof r===B)return l.get(r);if(!(r instanceof K))for(const e in r)r[e]=h(r[e]);return r;case F:if(typeof r===I){if(!l.has(r)){const e=function(...e){return t&&e.at(0)instanceof Event&&n(...e),u(se,Z(F,r),p(this),e.map(p))},s=new WeakRef(e);l.set(r,s),d.register(e,r,s)}return l.get(r).deref()}return l.get(r);case J:return re(r)}return r},g={[se]:(e,t,r)=>p(e.apply(t,r)),[oe]:(e,t)=>p(new e(...t)),[ae]:(e,t,r)=>p(C(e,t,r)),[ie]:(e,t)=>p(delete e[t]),[ue]:e=>p(H(e)),[ce]:(e,t)=>p(e[t]),[le]:(e,t)=>{const r=N(e,t);return r?Z(W,V(r,p)):Z(L,r)},[fe]:(e,t)=>p(t in e),[pe]:e=>p(D(e)),[de]:e=>Z(W,U(e).map(p)),[he]:e=>p(q(e)),[ge]:(e,t,r)=>p(z(e,t,r)),[ye]:(e,t)=>p(Q(e,t)),[we](e){c.delete(l.get(e)),l.delete(e)}};return r[s]=(e,t,...r)=>{switch(e){case se:r[0]=h(r[0]),r[1]=r[1].map(h);break;case oe:r[0]=r[0].map(h);break;case ae:{const[e,t]=r;r[0]=h(e);const{get:n,set:s,value:o}=t;n&&(t.get=h(n)),s&&(t.set=h(s)),o&&(t.value=h(o));break}default:r=r.map(h)}return g[e](h(t),...r)},{proxy:r,[e.toLowerCase()]:f,[`is${e}Proxy`]:()=>!1}}})("Window",!0),be=(e=>{let t=0;const r=new Map,n=new Map,s=Symbol(),o=e=>typeof e===F?e():e,a=e=>typeof e===W&&!!e&&s in e,i=Array[G],c=ee(((e,a)=>{if(s in a)return o(a[s]);if(e===F){if(!n.has(a)){let e;for(;n.has(e=String(t++)););r.set(a,e),n.set(e,a)}return Z(e,r.get(a))}if(!(a instanceof K))for(const e in a)a[e]=c(a[e]);return Z(e,a)}));return(t,l,u)=>{const{[l]:f}=t,p=new Map,d=new FinalizationRegistry((e=>{p.delete(e),f(we,c(e))})),h=e=>{const[t,r]=e;if(!p.has(r)){const n=t===F?ne.bind(e):e,s=new Proxy(n,w),o=new WeakRef(s);p.set(r,o),d.register(s,r,o)}return p.get(r).deref()},g=e=>{const[t,r]=e;switch(t){case W:return null===r?globalThis:typeof r===B?h(e):r;case F:return typeof r===I?n.get(r):h(e);case J:return re(r)}return r},y=(e,t,...r)=>g(f(e,o(t),...r)),w={[se]:(e,t,r)=>y(se,e,c(t),r.map(c)),[oe]:(e,t)=>y(oe,e,t.map(c)),[ae]:(e,t,r)=>{const{get:n,set:s,value:o}=r;return typeof n===F&&(r.get=c(n)),typeof s===F&&(r.set=c(s)),typeof o===F&&(r.value=c(o)),y(ae,e,c(t),r)},[ie]:(e,t)=>y(ie,e,c(t)),[ue]:e=>y(ue,e),[ce]:(e,t)=>t===s?e:y(ce,e,c(t)),[le]:(e,t)=>{const r=y(le,e,c(t));return r&&V(r,g)},[fe]:(e,t)=>t===s||y(fe,e,c(t)),[pe]:e=>y(pe,e),[de]:e=>y(de,e).map(g),[he]:e=>y(he,e),[ge]:(e,t,r)=>y(ge,e,c(t),c(r)),[ye]:(e,t)=>y(ye,e,c(t))};t[u]=(e,t,s,o)=>{switch(e){case se:return g(t).apply(g(s),o.map(g));case we:{const e=g(t);r.delete(n.get(e)),n.delete(e)}}};const m=new Proxy([W,null],w),b=m.Array[G];return C(Array,G,{value:e=>a(e)?b(e):i(e)}),{[e.toLowerCase()]:m,[`is${e}Proxy`]:a,proxy:t}}})("Window"),ve="function"==typeof Worker?Worker:class{};const Ee=new WeakMap,Se=(e,...t)=>{const r=O(e,...t);if(!Ee.has(r)){const t=e instanceof ve?me:be;Ee.set(r,t(r,g,y))}return Ee.get(r)};Se.transfer=O.transfer;const Ae={object(...e){return this.string(function(e){for(var t=e[0],r=1,n=arguments.length;r<n;r++)t+=arguments[r]+e[r];return t}(...e))},string(e){for(const t of e.split(/[\r\n]+/))if(t.trim().length){/^(\s+)/.test(t)&&(e=e.replace(new RegExp("^"+RegExp.$1,"gm"),""));break}return e}},ke=(e,...t)=>Ae[typeof e](e,...t),{isArray:$e}=Array,{assign:Pe,create:Me,defineProperties:xe,defineProperty:je,entries:Te}=Object,{all:Re,resolve:_e}=new Proxy(Promise,{get:(e,t)=>e[t].bind(e)}),Oe=(e,t=location.href)=>new URL(e,t).href;let We=0;const Fe=(e,t)=>({id:e.id||(e.id=`${t}-w${We++}`),tag:e.tagName}),Be=e=>e.arrayBuffer(),Ie=e=>e.json(),Le=e=>e.text(),Je=[["beforeRun","codeBeforeRunWorker"],["beforeRunAsync","codeBeforeRunWorkerAsync"],["afterRun","codeAfterRunWorker"],["afterRunAsync","codeAfterRunWorkerAsync"]];class Ce{constructor(e,t){this.interpreter=e,this.onWorkerReady=t.onWorkerReady;for(const[e,r]of Je)this[e]=t[r]?.()}get stringHooks(){const e={};for(const[t]of Je)this[t]&&(e[t]=ke(this[t]));return e}}var Ne=(...e)=>function(t,r){const n=new Worker(URL.createObjectURL(new Blob(['const e="object"==typeof self?self:globalThis,t=t=>((t,r)=>{const n=(e,r)=>(t.set(r,e),e),s=o=>{if(t.has(o))return t.get(o);const[a,i]=r[o];switch(a){case 0:case-1:return n(i,o);case 1:{const e=n([],o);for(const t of i)e.push(s(t));return e}case 2:{const e=n({},o);for(const[t,r]of i)e[s(t)]=s(r);return e}case 3:return n(new Date(i),o);case 4:{const{source:e,flags:t}=i;return n(new RegExp(e,t),o)}case 5:{const e=n(new Map,o);for(const[t,r]of i)e.set(s(t),s(r));return e}case 6:{const e=n(new Set,o);for(const t of i)e.add(s(t));return e}case 7:{const{name:t,message:r}=i;return n(new e[t](r),o)}case 8:return n(BigInt(i),o);case"BigInt":return n(Object(BigInt(i)),o)}return n(new e[a](i),o)};return s})(new Map,t)(0),r="",{toString:n}={},{keys:s}=Object,o=e=>{const t=typeof e;if("object"!==t||!e)return[0,t];const s=n.call(e).slice(8,-1);switch(s){case"Array":return[1,r];case"Object":return[2,r];case"Date":return[3,r];case"RegExp":return[4,r];case"Map":return[5,r];case"Set":return[6,r]}return s.includes("Array")?[1,s]:s.includes("Error")?[7,s]:[2,s]},a=([e,t])=>0===e&&("function"===t||"symbol"===t),i=(e,{json:t,lossy:r}={})=>{const n=[];return((e,t,r,n)=>{const i=(e,t)=>{const s=n.push(e)-1;return r.set(t,s),s},c=n=>{if(r.has(n))return r.get(n);let[l,u]=o(n);switch(l){case 0:{let t=n;switch(u){case"bigint":l=8,t=n.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+u);t=null;break;case"undefined":return i([-1],n)}return i([l,t],n)}case 1:{if(u)return i([u,[...n]],n);const e=[],t=i([l,e],n);for(const t of n)e.push(c(t));return t}case 2:{if(u)switch(u){case"BigInt":return i([u,n.toString()],n);case"Boolean":case"Number":case"String":return i([u,n.valueOf()],n)}if(t&&"toJSON"in n)return c(n.toJSON());const r=[],f=i([l,r],n);for(const t of s(n))!e&&a(o(n[t]))||r.push([c(t),c(n[t])]);return f}case 3:return i([l,n.toISOString()],n);case 4:{const{source:e,flags:t}=n;return i([l,{source:e,flags:t}],n)}case 5:{const t=[],r=i([l,t],n);for(const[r,s]of n)(e||!a(o(r))&&!a(o(s)))&&t.push([c(r),c(s)]);return r}case 6:{const t=[],r=i([l,t],n);for(const r of n)!e&&a(o(r))||t.push(c(r));return r}}const{message:f}=n;return i([l,{name:u,message:f}],n)};return c})(!(t||r),!!t,new Map,n)(e),n},{parse:c,stringify:l}=JSON,u={json:!0,lossy:!0};var f=Object.freeze({__proto__:null,parse:e=>t(c(e)),stringify:e=>l(i(e,u))});const p="891249cd-eb53-4bc8-ae48-b0a5a277d24a",d="M"+p,g="T"+p;var y=e=>({value:new Promise((t=>{let r=new Worker("data:application/javascript,onmessage%3D(%7Bdata%3Ab%7D)%3D%3E(Atomics.wait(b%2C0)%2CpostMessage(0))");r.onmessage=t,r.postMessage(e)}))})\n/*! (c) Andrea Giammarchi - ISC */;const{Int32Array:h,Map:w,SharedArrayBuffer:m,Uint16Array:b}=globalThis,{BYTES_PER_ELEMENT:v}=h,{BYTES_PER_ELEMENT:S}=b,{isArray:E}=Array,{notify:P,wait:A,waitAsync:M}=Atomics,{fromCharCode:$}=String,j=(e,t)=>e?(M||y)(t,0):(A(t,0),{value:{then:e=>e()}}),k=new WeakSet,x=new WeakMap;let T=0;const _=(e,{parse:t,stringify:r,transform:n}=JSON)=>{if(!x.has(e)){const s=(t,...r)=>e.postMessage({[p]:r},{transfer:t});let o=!1;x.set(e,new Proxy(new w,{has:(e,t)=>"string"==typeof t&&!t.startsWith("_"),get:(r,a)=>"then"===a?null:(...r)=>{const i=T++;let c=new h(new m(v)),l=[];k.has(r.at(-1)||l)&&k.delete(l=r.pop()),s(l,i,c,a,n?r.map(n):r);const u=e!==globalThis;let f=0;return o&&u&&(f=setTimeout(console.warn,1e3,`💀🔒 - Possible deadlock if proxy.${a}(...args) is awaited`)),j(u,c).value.then((()=>{clearTimeout(f);const e=c[0];if(!e)return;const r=S*e;return c=new h(new m(r+r%v)),s([],i,c),j(u,c).value.then((()=>t($(...new b(c.buffer).slice(0,e)))))}))},set(t,n,s){if(!t.size){const n=new w;e.addEventListener("message",(async e=>{const s=e.data?.[p];if(E(s)){e.stopImmediatePropagation();const[a,i,...c]=s;if(c.length){const[e,s]=c;if(!t.has(e))throw new Error(`Unsupported action: ${e}`);o=!0;try{const o=await t.get(e)(...s);if(void 0!==o){const e=r(o);n.set(a,e),i[0]=e.length}}finally{o=!1}}else{const e=n.get(a);n.delete(a);for(let t=new b(i.buffer),r=0;r<e.length;r++)t[r]=e.charCodeAt(r)}P(i,0)}}))}return!!t.set(n,s)}}))}return x.get(e)};_.transfer=(...e)=>(k.add(e),e);const O="object",F="function",W="number",R="string",B="undefined",J="symbol",{defineProperty:I,getOwnPropertyDescriptor:L,getPrototypeOf:C,isExtensible:H,ownKeys:D,preventExtensions:N,set:U,setPrototypeOf:z}=Reflect,{assign:q,create:K}=Object,Y=C(Int8Array),G="isArray",V=(e,t)=>{const{get:r,set:n,value:s}=e;return r&&(e.get=t(r)),n&&(e.set=t(n)),s&&(e.value=t(s)),e},Q=(e,t)=>[e,t],X=e=>t=>{const r=typeof t;switch(r){case O:if(null==t)return Q("null",t);if(t===globalThis)return Q(O,null);case F:return e(r,t);case"boolean":case W:case R:case B:case"bigint":return Q(r,t);case J:if(Z.has(t))return Q(r,Z.get(t))}throw new Error(`Unable to handle this ${r} type`)},Z=new Map(D(Symbol).filter((e=>typeof Symbol[e]===J)).map((e=>[Symbol[e],e]))),ee=e=>{for(const[t,r]of Z)if(r===e)return t};function te(){return this}const re="apply",ne="construct",se="defineProperty",oe="deleteProperty",ae="get",ie="getOwnPropertyDescriptor",ce="getPrototypeOf",le="has",ue="isExtensible",fe="ownKeys",pe="preventExtensions",de="set",ge="setPrototypeOf",ye="delete";var he=((e,t)=>{const r=t&&new WeakMap;if(t){const{addEventListener:e}=EventTarget.prototype;I(EventTarget.prototype,"addEventListener",{value(t,n,...s){return s.at(0)?.invoke&&(r.has(this)||r.set(this,new Map),r.get(this).set(t,[].concat(s[0].invoke)),delete s[0].invoke),e.call(this,t,n,...s)}})}const n=t&&(e=>{const{currentTarget:t,target:n,type:s}=e;for(const o of r.get(t||n)?.get(s)||[])e[o]()});return(r,s,o,...a)=>{let i=0;const c=new Map,l=new Map,{[o]:u}=r,f=a.length?q(K(globalThis),...a):globalThis,p=X(((e,t)=>{if(!c.has(t)){let e;for(;l.has(e=i++););c.set(t,e),l.set(e,t)}return Q(e,c.get(t))})),d=new FinalizationRegistry((e=>{u(ye,Q(R,e))})),g=([e,r])=>{switch(e){case O:if(null==r)return f;if(typeof r===W)return l.get(r);if(!(r instanceof Y))for(const e in r)r[e]=g(r[e]);return r;case F:if(typeof r===R){if(!l.has(r)){const e=function(...e){return t&&e.at(0)instanceof Event&&n(...e),u(re,Q(F,r),p(this),e.map(p))},s=new WeakRef(e);l.set(r,s),d.register(e,r,s)}return l.get(r).deref()}return l.get(r);case J:return ee(r)}return r},y={[re]:(e,t,r)=>p(e.apply(t,r)),[ne]:(e,t)=>p(new e(...t)),[se]:(e,t,r)=>p(I(e,t,r)),[oe]:(e,t)=>p(delete e[t]),[ce]:e=>p(C(e)),[ae]:(e,t)=>p(e[t]),[ie]:(e,t)=>{const r=L(e,t);return r?Q(O,V(r,p)):Q(B,r)},[le]:(e,t)=>p(t in e),[ue]:e=>p(H(e)),[fe]:e=>Q(O,D(e).map(p)),[pe]:e=>p(N(e)),[de]:(e,t,r)=>p(U(e,t,r)),[ge]:(e,t)=>p(z(e,t)),[ye](e){c.delete(l.get(e)),l.delete(e)}};return r[s]=(e,t,...r)=>{switch(e){case re:r[0]=g(r[0]),r[1]=r[1].map(g);break;case ne:r[0]=r[0].map(g);break;case se:{const[e,t]=r;r[0]=g(e);const{get:n,set:s,value:o}=t;n&&(t.get=g(n)),s&&(t.set=g(s)),o&&(t.value=g(o));break}default:r=r.map(g)}return y[e](g(t),...r)},{proxy:r,[e.toLowerCase()]:f,[`is${e}Proxy`]:()=>!1}}})("Window",!0),we=(e=>{let t=0;const r=new Map,n=new Map,s=Symbol(),o=e=>typeof e===F?e():e,a=e=>typeof e===O&&!!e&&s in e,i=Array[G],c=X(((e,a)=>{if(s in a)return o(a[s]);if(e===F){if(!n.has(a)){let e;for(;n.has(e=String(t++)););r.set(a,e),n.set(e,a)}return Q(e,r.get(a))}if(!(a instanceof Y))for(const e in a)a[e]=c(a[e]);return Q(e,a)}));return(t,l,u)=>{const{[l]:f}=t,p=new Map,d=new FinalizationRegistry((e=>{p.delete(e),f(ye,c(e))})),g=e=>{const[t,r]=e;if(!p.has(r)){const n=t===F?te.bind(e):e,s=new Proxy(n,w),o=new WeakRef(s);p.set(r,o),d.register(s,r,o)}return p.get(r).deref()},y=e=>{const[t,r]=e;switch(t){case O:return null===r?globalThis:typeof r===W?g(e):r;case F:return typeof r===R?n.get(r):g(e);case J:return ee(r)}return r},h=(e,t,...r)=>y(f(e,o(t),...r)),w={[re]:(e,t,r)=>h(re,e,c(t),r.map(c)),[ne]:(e,t)=>h(ne,e,t.map(c)),[se]:(e,t,r)=>{const{get:n,set:s,value:o}=r;return typeof n===F&&(r.get=c(n)),typeof s===F&&(r.set=c(s)),typeof o===F&&(r.value=c(o)),h(se,e,c(t),r)},[oe]:(e,t)=>h(oe,e,c(t)),[ce]:e=>h(ce,e),[ae]:(e,t)=>t===s?e:h(ae,e,c(t)),[ie]:(e,t)=>{const r=h(ie,e,c(t));return r&&V(r,y)},[le]:(e,t)=>t===s||h(le,e,c(t)),[ue]:e=>h(ue,e),[fe]:e=>h(fe,e).map(y),[pe]:e=>h(pe,e),[de]:(e,t,r)=>h(de,e,c(t),c(r)),[ge]:(e,t)=>h(ge,e,c(t))};t[u]=(e,t,s,o)=>{switch(e){case re:return y(t).apply(y(s),o.map(y));case ye:{const e=y(t);r.delete(n.get(e)),n.delete(e)}}};const m=new Proxy([O,null],w),b=m.Array[G];return I(Array,G,{value:e=>a(e)?b(e):i(e)}),{[e.toLowerCase()]:m,[`is${e}Proxy`]:a,proxy:t}}})("Window"),me="function"==typeof Worker?Worker:class{};const be=new WeakMap,ve=(e,...t)=>{const r=_(e,...t);if(!be.has(r)){const t=e instanceof me?he:we;be.set(r,t(r,d,g))}return be.get(r)};ve.transfer=_.transfer;const Se={object(...e){return this.string(function(e){for(var t=e[0],r=1,n=arguments.length;r<n;r++)t+=arguments[r]+e[r];return t}(...e))},string(e){for(const t of e.split(/[\\r\\n]+/))if(t.trim().length){/^(\\s+)/.test(t)&&(e=e.replace(new RegExp("^"+RegExp.$1,"gm"),""));break}return e}},Ee=(e,...t)=>Se[typeof e](e,...t),{isArray:Pe}=Array,{assign:Ae,create:Me,defineProperties:$e,defineProperty:je,entries:ke}=Object,{all:xe,resolve:Te}=new Proxy(Promise,{get:(e,t)=>e[t].bind(e)}),_e=(e,t=location.href)=>new URL(e,t).href;Promise.withResolvers||(Promise.withResolvers=function(){var e,t,r=new this((function(r,n){e=r,t=n}));return{resolve:e,reject:t,promise:r}});const Oe=e=>e.arrayBuffer(),Fe=e=>e.json(),We=e=>e.text(),Re=new WeakMap,Be=e=>{const t=e||console,r={stderr:(t.stderr||console.error).bind(t),stdout:(t.stdout||console.log).bind(t)};return{stderr:(...e)=>r.stderr(...e),stdout:(...e)=>r.stdout(...e),async get(e){const t=await e;return Re.set(t,r),t}}},Je=({FS:e,PATH:t,PATH_FS:r},n,s)=>{const o=r.resolve(n);return e.mkdirTree(t.dirname(o)),e.writeFile(o,new Uint8Array(s),{canOwn:!0})},Ie=e=>{const t=e.split("/");return t.pop(),t.join("/")},Le=(e,t)=>{const r=[];for(const n of t.split("/"))"."!==n&&(r.push(n),n&&e.mkdir(r.join("/")))},Ce=(e,t)=>{const r=[];for(const e of t.split("/"))switch(e){case"":case".":break;case"..":r.pop();break;default:r.push(e)}return[e.cwd()].concat(r).join("/").replace(/^\\/+/,"/")},He=e=>{const t=e.map((e=>e.trim().replace(/(^[/]*|[/]*$)/g,""))).filter((e=>""!==e&&"."!==e)).join("/");return e[0].startsWith("/")?`/${t}`:t},De=new WeakMap,Ne=(e,t,r)=>xe((e=>{for(const{files:t,to_file:r,from:n=""}of e){if(void 0!==t&&void 0!==r)throw new Error("Cannot use \'to_file\' and \'files\' parameters together!");if(void 0===t&&void 0===r&&n.endsWith("/"))throw new Error(`Couldn\'t determine the filename from the path ${n}, please supply \'to_file\' parameter.`)}return e.flatMap((({from:e="",to_folder:t=".",to_file:r,files:n})=>{if(Pe(n))return n.map((r=>({url:He([e,r]),path:He([t,r])})));const s=r||e.slice(1+e.lastIndexOf("/"));return[{url:e,path:He([t,s])}]}))})(r).map((({url:n,path:s})=>((e,t)=>fetch(_e(t,De.get(e))))(r,n).then(Oe).then((r=>e.writeFile(t,s,r)))))),Ue=(e,t,r)=>{e.registerJsModule(t,r)},ze=(e,t,...r)=>{try{return e.runPython(Ee(t),...r)}catch(t){Re.get(e).stderr(t)}},qe=async(e,t,...r)=>{try{return await e.runPythonAsync(Ee(t),...r)}catch(t){Re.get(e).stderr(t)}},Ke=async(e,t,r)=>{const[n,...s]=t.split(".");let o,a=e.globals.get(n);for(const e of s)[o,a]=[a,a[e]];try{await a.call(o,r)}catch(t){Re.get(e).stderr(t)}};var Ye={type:"micropython",module:(e="1.20.0-297")=>`https://cdn.jsdelivr.net/npm/@micropython/micropython-webassembly-pyscript@${e}/micropython.mjs`,async engine({loadMicroPython:e},t,r){const{stderr:n,stdout:s,get:o}=Be();r=r.replace(/\\.m?js$/,".wasm");const a=await o(e({stderr:n,stdout:s,url:r}));return t.fetch&&await Ne(this,a,t.fetch),a},registerJSModule:Ue,run:ze,runAsync:qe,runEvent:Ke,transform:(e,t)=>t,writeFile:({FS:e,_module:{PATH:t,PATH_FS:r}},n,s)=>Je({FS:e,PATH:t,PATH_FS:r},n,s)};const Ge={dict_converter:Object.fromEntries};var Ve={type:"pyodide",module:(e="0.23.4")=>`https://cdn.jsdelivr.net/pyodide/v${e}/full/pyodide.mjs`,async engine({loadPyodide:e},t,r){const{stderr:n,stdout:s,get:o}=Be(),a=r.slice(0,r.lastIndexOf("/")),i=await o(e({stderr:n,stdout:s,indexURL:a}));if(t.fetch&&await Ne(this,i,t.fetch),t.packages){await i.loadPackage("micropip");const e=await i.pyimport("micropip");await e.install(t.packages),e.destroy()}return i},registerJSModule:Ue,run:ze,runAsync:qe,runEvent:Ke,transform:(e,t)=>t instanceof e.ffi.PyProxy?t.toJs(Ge):t,writeFile:({FS:e,PATH:t,_module:{PATH_FS:r}},n,s)=>Je({FS:e,PATH:t,PATH_FS:r},n,s)};const Qe="ruby-wasm-wasi",Xe=Qe.replace(/\\W+/g,"_");var Ze={type:Qe,experimental:!0,module:(e="2.0.0")=>`https://cdn.jsdelivr.net/npm/ruby-3_2-wasm-wasi@${e}/dist/browser.esm.js`,async engine({DefaultRubyVM:e},t,r){const n=await fetch(`${r.slice(0,r.lastIndexOf("/"))}/ruby.wasm`),s=await WebAssembly.compile(await n.arrayBuffer()),{vm:o}=await e(s);return t.fetch&&await Ne(this,o,t.fetch),o},registerJSModule(e,t,r){const n=`__module_${Xe}_${t}`;globalThis[n]=r,this.run(e,`require "js";$${t}=JS.global[:${n}]`),delete globalThis[n]},run:(e,t,...r)=>e.eval(Ee(t),...r),runAsync:(e,t,...r)=>e.evalAsync(Ee(t),...r),async runEvent(e,t,r){if(/^xworker\\.(on\\w+)$/.test(t)){const{$1:t}=RegExp,n=`__module_${Xe}_event`;globalThis[n]=r,this.run(e,`require "js";$xworker.call("${t}",JS.global[:${n}])`),delete globalThis[n]}else{const n=this.run(e,`method(:${t})`);await n.call(t,e.wrap(r))}},transform:(e,t)=>t,writeFile:()=>{throw new Error(`writeFile is not supported in ${Qe}`)}};var et={type:"wasmoon",module:(e="1.15.0")=>`https://cdn.jsdelivr.net/npm/wasmoon@${e}/+esm`,async engine({LuaFactory:e,LuaLibraries:t},r){const{stderr:n,stdout:s,get:o}=Be(),a=await o((new e).createEngine());return a.global.getTable(t.Base,(e=>{a.global.setField(e,"print",s),a.global.setField(e,"printErr",n)})),r.fetch&&await Ne(this,a,r.fetch),a},registerJSModule:(e,t,r)=>{e.global.set(t,r)},run:(e,t,...r)=>{try{return e.doStringSync(Ee(t),...r)}catch(t){Re.get(e).stderr(t)}},runAsync:async(e,t,...r)=>{try{return await e.doString(Ee(t),...r)}catch(t){Re.get(e).stderr(t)}},runEvent:async(e,t,r)=>{const[n,...s]=t.split(".");let o,a=e.global.get(n);for(const e of s)[o,a]=[a,a[e]];try{await a.call(o,r)}catch(t){Re.get(e).stderr(t)}},transform:(e,t)=>t,writeFile:({cmodule:{module:{FS:e}}},t,r)=>((e,t,r)=>(Le(e,Ie(t)),t=Ce(e,t),e.writeFile(t,new Uint8Array(r),{canOwn:!0})))(e,t,r)};const tt=new Map,rt=new Map,nt=new Proxy(new Map,{get(e,t){if(!e.has(t)){const[r,...n]=t.split("@"),s=tt.get(r),o=/^https?:\\/\\//i.test(n)?n.join("@"):s.module(...n);e.set(t,{url:o,module:import(o),engine:s.engine.bind(s)})}const{url:r,module:n,engine:s}=e.get(t);return(e,o)=>n.then((n=>{rt.set(t,e);const a=e?.fetch;return a&&De.set(a,o),s(n,e,r)}))}}),st=e=>{for(const t of[].concat(e.type))tt.set(t,e)};for(const e of[Ye,Ve,Ze,et])st(e);const ot=async e=>(await import("https://cdn.jsdelivr.net/npm/basic-toml@0.3.1/es.js")).parse(e);try{new SharedArrayBuffer(4)}catch(e){throw new Error(["Unable to use SharedArrayBuffer due insecure environment.","Please read requirements in MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer#security_requirements"].join("\\n"))}let at,it,ct;const lt=(e,t)=>{addEventListener(e,t||(async t=>{try{await at,it(`xworker.on${e}`,t)}catch(e){postMessage(e)}}),!!t&&{once:!0})},{parse:ut,stringify:ft}=f,{proxy:pt,window:dt,isWindowProxy:gt}=ve(self,{parse:ut,stringify:ft,transform:e=>ct?ct(e):e}),yt={sync:pt,window:dt,isWindowProxy:gt,onmessage:console.info,onerror:console.error,onmessageerror:console.warn,postMessage:postMessage.bind(self)};lt("message",(({data:{options:e,config:t,code:r,hooks:n}})=>{at=(async()=>{try{const{id:s,tag:o,type:a,custom:i,version:c,config:l,async:u}=e,f=await((e,t,r={})=>{if(t)if(t.endsWith(".json"))r=fetch(t).then(Fe),t=_e(t);else if(t.endsWith(".toml"))r=fetch(t).then(We).then(ot),t=_e(t);else if(!t.endsWith(".txt")){try{r=JSON.parse(t)}catch(e){r=ot(t)}t=_e("./config.txt")}return Te(r).then((r=>nt[e](r,t)))})(((e,t="")=>`${e}@${t}`.replace(/@$/,""))(a,c),t,l),p=Me(tt.get(a)),d="run"+(u?"Async":"");if(n){const{beforeRun:e,beforeRunAsync:t,afterRun:r,afterRunAsync:s}=n,o=r||s,a=e||t;if(o){const e=p[d].bind(p);p[d]=(t,r,...n)=>e(t,`${r}\\n${o}`,...n)}if(a){const e=p[d].bind(p);p[d]=(t,r,...n)=>e(t,`${a}\\n${r}`,...n)}}const{CustomEvent:g,document:y}=dt,h=y.getElementById(s);let w="";return p.registerJSModule(f,"polyscript",{xworker:yt,get target(){return w||("SCRIPT"===o?h.after(Ae(y.createElement(`script-${i||a}`),{id:w=`${s}-target`})):(w=s,h.replaceChildren(),h.style.display="block")),w}}),it=p.runEvent.bind(p,f),ct=p.transform.bind(p,f),((e,t,r,n)=>{e&&e.dispatchEvent(new n(`${t}:ready`,{bubbles:!0,detail:{worker:r}}))})(h,i||a,!0,g),await p[d](f,r),f}catch(e){postMessage(e)}})(),lt("error"),lt("message"),lt("messageerror")}));\n'],{type:"application/javascript"})),{type:"module"}),{postMessage:s}=n,o=this instanceof Ce;if(e.length){const[t,n]=e;(r=Pe({},r||{type:t,version:n})).type||(r.type=t)}const{config:a}=r,i=Oe(a&&"string"==typeof a?a:"./config.txt"),c=fetch(t).then(Le).then((e=>{const t=o?this.stringHooks:void 0;s.call(n,{options:r,config:i,code:e,hooks:t})}));return xe(n,{postMessage:{value:(e,...t)=>c.then((()=>s.call(n,e,...t)))},sync:{value:Se(n,d).proxy},onerror:{writable:!0,configurable:!0,value:console.error}}),o&&this.onWorkerReady?.(this.interpreter,n),n.addEventListener("message",(e=>{const{data:t}=e;t instanceof Error&&(e.stopImmediatePropagation(),n.onerror(Object.create(e,{type:{value:"error"},error:{value:t}})))})),n},He=e=>{const{worker:t}=e.attributes;if(t){let{value:r}=t;if(!r){if(e.childElementCount){const{innerHTML:t,localName:n,type:s}=e,o=s||n.replace(/-script$/,"");console.warn(`Deprecated: use <script type="${o}"> for an always safe content parsing:\n`,t),r=t}else r=e.textContent;return URL.createObjectURL(new Blob([ke(r)],{type:"text/plain"}))}return r}};Promise.withResolvers||(Promise.withResolvers=function(){var e,t,r=new this((function(r,n){e=r,t=n}));return{resolve:e,reject:t,promise:r}});const De=new WeakMap,Ue=e=>{const t=e||console,r={stderr:(t.stderr||console.error).bind(t),stdout:(t.stdout||console.log).bind(t)};return{stderr:(...e)=>r.stderr(...e),stdout:(...e)=>r.stdout(...e),async get(e){const t=await e;return De.set(t,r),t}}},qe=({FS:e,PATH:t,PATH_FS:r},n,s)=>{const o=r.resolve(n);return e.mkdirTree(t.dirname(o)),e.writeFile(o,new Uint8Array(s),{canOwn:!0})},ze=e=>{const t=e.split("/");return t.pop(),t.join("/")},Qe=(e,t)=>{const r=[];for(const n of t.split("/"))"."!==n&&(r.push(n),n&&e.mkdir(r.join("/")))},Xe=(e,t)=>{const r=[];for(const e of t.split("/"))switch(e){case"":case".":break;case"..":r.pop();break;default:r.push(e)}return[e.cwd()].concat(r).join("/").replace(/^\/+/,"/")},Ye=e=>{const t=e.map((e=>e.trim().replace(/(^[/]*|[/]*$)/g,""))).filter((e=>""!==e&&"."!==e)).join("/");return e[0].startsWith("/")?`/${t}`:t},Ke=new WeakMap,Ge=(e,t,r)=>Re((e=>{for(const{files:t,to_file:r,from:n=""}of e){if(void 0!==t&&void 0!==r)throw new Error("Cannot use 'to_file' and 'files' parameters together!");if(void 0===t&&void 0===r&&n.endsWith("/"))throw new Error(`Couldn't determine the filename from the path ${n}, please supply 'to_file' parameter.`)}return e.flatMap((({from:e="",to_folder:t=".",to_file:r,files:n})=>{if($e(n))return n.map((r=>({url:Ye([e,r]),path:Ye([t,r])})));const s=r||e.slice(1+e.lastIndexOf("/"));return[{url:e,path:Ye([t,s])}]}))})(r).map((({url:n,path:s})=>((e,t)=>fetch(Oe(t,Ke.get(e))))(r,n).then(Be).then((r=>e.writeFile(t,s,r)))))),Ve=(e,t,r)=>{e.registerJsModule(t,r)},Ze=(e,t,...r)=>{try{return e.runPython(ke(t),...r)}catch(t){De.get(e).stderr(t)}},et=async(e,t,...r)=>{try{return await e.runPythonAsync(ke(t),...r)}catch(t){De.get(e).stderr(t)}},tt=async(e,t,r)=>{const[n,...s]=t.split(".");let o,a=e.globals.get(n);for(const e of s)[o,a]=[a,a[e]];try{await a.call(o,r)}catch(t){De.get(e).stderr(t)}};var rt={type:"micropython",module:(e="1.20.0-297")=>`https://cdn.jsdelivr.net/npm/@micropython/micropython-webassembly-pyscript@${e}/micropython.mjs`,async engine({loadMicroPython:e},t,r){const{stderr:n,stdout:s,get:o}=Ue();r=r.replace(/\.m?js$/,".wasm");const a=await o(e({stderr:n,stdout:s,url:r}));return t.fetch&&await Ge(this,a,t.fetch),a},registerJSModule:Ve,run:Ze,runAsync:et,runEvent:tt,transform:(e,t)=>t,writeFile:({FS:e,_module:{PATH:t,PATH_FS:r}},n,s)=>qe({FS:e,PATH:t,PATH_FS:r},n,s)};const nt={dict_converter:Object.fromEntries};var st={type:"pyodide",module:(e="0.23.4")=>`https://cdn.jsdelivr.net/pyodide/v${e}/full/pyodide.mjs`,async engine({loadPyodide:e},t,r){const{stderr:n,stdout:s,get:o}=Ue(),a=r.slice(0,r.lastIndexOf("/")),i=await o(e({stderr:n,stdout:s,indexURL:a}));if(t.fetch&&await Ge(this,i,t.fetch),t.packages){await i.loadPackage("micropip");const e=await i.pyimport("micropip");await e.install(t.packages),e.destroy()}return i},registerJSModule:Ve,run:Ze,runAsync:et,runEvent:tt,transform:(e,t)=>t instanceof e.ffi.PyProxy?t.toJs(nt):t,writeFile:({FS:e,PATH:t,_module:{PATH_FS:r}},n,s)=>qe({FS:e,PATH:t,PATH_FS:r},n,s)};const ot="ruby-wasm-wasi",at=ot.replace(/\W+/g,"_");var it={type:ot,experimental:!0,module:(e="2.0.0")=>`https://cdn.jsdelivr.net/npm/ruby-3_2-wasm-wasi@${e}/dist/browser.esm.js`,async engine({DefaultRubyVM:e},t,r){const n=await fetch(`${r.slice(0,r.lastIndexOf("/"))}/ruby.wasm`),s=await WebAssembly.compile(await n.arrayBuffer()),{vm:o}=await e(s);return t.fetch&&await Ge(this,o,t.fetch),o},registerJSModule(e,t,r){const n=`__module_${at}_${t}`;globalThis[n]=r,this.run(e,`require "js";$${t}=JS.global[:${n}]`),delete globalThis[n]},run:(e,t,...r)=>e.eval(ke(t),...r),runAsync:(e,t,...r)=>e.evalAsync(ke(t),...r),async runEvent(e,t,r){if(/^xworker\.(on\w+)$/.test(t)){const{$1:t}=RegExp,n=`__module_${at}_event`;globalThis[n]=r,this.run(e,`require "js";$xworker.call("${t}",JS.global[:${n}])`),delete globalThis[n]}else{const n=this.run(e,`method(:${t})`);await n.call(t,e.wrap(r))}},transform:(e,t)=>t,writeFile:()=>{throw new Error(`writeFile is not supported in ${ot}`)}};var ct={type:"wasmoon",module:(e="1.15.0")=>`https://cdn.jsdelivr.net/npm/wasmoon@${e}/+esm`,async engine({LuaFactory:e,LuaLibraries:t},r){const{stderr:n,stdout:s,get:o}=Ue(),a=await o((new e).createEngine());return a.global.getTable(t.Base,(e=>{a.global.setField(e,"print",s),a.global.setField(e,"printErr",n)})),r.fetch&&await Ge(this,a,r.fetch),a},registerJSModule:(e,t,r)=>{e.global.set(t,r)},run:(e,t,...r)=>{try{return e.doStringSync(ke(t),...r)}catch(t){De.get(e).stderr(t)}},runAsync:async(e,t,...r)=>{try{return await e.doString(ke(t),...r)}catch(t){De.get(e).stderr(t)}},runEvent:async(e,t,r)=>{const[n,...s]=t.split(".");let o,a=e.global.get(n);for(const e of s)[o,a]=[a,a[e]];try{await a.call(o,r)}catch(t){De.get(e).stderr(t)}},transform:(e,t)=>t,writeFile:({cmodule:{module:{FS:e}}},t,r)=>((e,t,r)=>(Qe(e,ze(t)),t=Xe(e,t),e.writeFile(t,new Uint8Array(r),{canOwn:!0})))(e,t,r)};const lt=new Map,ut=new Map,ft=[],pt=[],dt=new Proxy(new Map,{get(e,t){if(!e.has(t)){const[r,...n]=t.split("@"),s=lt.get(r),o=/^https?:\/\//i.test(n)?n.join("@"):s.module(...n);e.set(t,{url:o,module:import(o),engine:s.engine.bind(s)})}const{url:r,module:n,engine:s}=e.get(t);return(e,o)=>n.then((n=>{ut.set(t,e);const a=e?.fetch;return a&&Ke.set(a,o),s(n,e,r)}))}}),ht=e=>{for(const t of[].concat(e.type))lt.set(t,e),ft.push(`script[type="${t}"]`),pt.push(`${t}-`)};for(const e of[rt,st,it,ct])ht(e);const gt=async e=>(await import("https://cdn.jsdelivr.net/npm/basic-toml@0.3.1/es.js")).parse(e),yt=(e,t,r={})=>{if(t)if(t.endsWith(".json"))r=fetch(t).then(Ie),t=Oe(t);else if(t.endsWith(".toml"))r=fetch(t).then(Le).then(gt),t=Oe(t);else if(!t.endsWith(".txt")){try{r=JSON.parse(t)}catch(e){r=gt(t)}t=Oe("./config.txt")}return _e(r).then((r=>dt[e](r,t)))},wt=(e,t="")=>`${e}@${t}`.replace(/@$/,""),mt=(e,t)=>{const r=(e=>{let t=e;for(;t.parentNode;)t=t.parentNode;return t})(e);return r.getElementById(t)||((e,t=document)=>t.querySelector(e))(t,r)},bt=new WeakMap,vt={get(){let e=bt.get(this);return e||(e=document.createElement(`${this.type}-script`),bt.set(this,e),$t(this)),e},set(e){"string"==typeof e?bt.set(this,mt(this,e)):(bt.set(this,e),$t(this))}},Et=new WeakMap,St=new Map,At=(e,t)=>{const r=e?.value;return r?t+r:""},kt=(e,t,r,n,s,o=e)=>{if(!St.has(t)){const a={interpreter:yt(r,s),queue:_e(),XWorker:Ne(e,n)};St.set(t,a),St.has(e)||St.set(e,a),St.has(o)||St.set(o,a)}return St.get(t)},$t=async e=>{if(Et.has(e)){const{target:t}=e;t&&(e.closest("head")?document.body.append(t):e.after(t))}else{const{attributes:{async:t,config:r,env:n,target:s,version:o},src:a,type:i}=e,c=o?.value,l=wt(i,c);let u=At(r,"|");const f=At(n,"")||`${l}${u}`;u=u.slice(1);const p=He(e);if(p){const r=new(Ne(i,c))(p,{...Fe(e,i),async:!!t,config:u});return void Et.set(je(e,"xworker",{value:r}),{xworker:r})}const d=At(s,""),h=kt(i,f,l,c,u);Et.set(je(e,"target",vt),h),d&&bt.set(e,mt(e,d));const g=a?fetch(a).then(Le):e.textContent;h.queue=h.queue.then((()=>(async(e,t,r,n)=>{const{type:s}=e,o=lt.get(s);o.experimental&&console.warn(`The ${s} interpreter is experimental`);const[a,i]=await Re([Et.get(e).interpreter,t]);try{return je(document,"currentScript",{configurable:!0,get:()=>e}),o.registerJSModule(a,"polyscript",{XWorker:r}),((e,t,r,n)=>{e&&e.dispatchEvent(new n(`${t}:ready`,{bubbles:!0,detail:{worker:r}}))})(e,s,!1,CustomEvent),o[n?"runAsync":"run"](a,i)}finally{delete document.currentScript}})(e,g,h.XWorker,!!t)))}},Pt=new Proxy(Me(null),{get:(e,t)=>Mt(t)}),Mt=async e=>{if(St.has(e)){const{interpreter:t,queue:r}=St.get(e);return(await Re([t,r]))[0]}const t=St.size?`Available interpreters are: ${[...St.keys()].map((e=>`"${e}"`)).join(", ")}.`:"There are no interpreters in this page.";throw new Error(`The interpreter "${e}" was not found. ${t}`)},xt=async e=>{const{type:r,currentTarget:n}=e;for(let{name:s,value:o,ownerElement:a}of t(`./@*[${pt.map((e=>`name()="${e}${r}"`)).join(" or ")}]`,n)){s=s.slice(0,-(r.length+1));const t=await Mt(a.getAttribute(`${s}-env`)||s);lt.get(s).runEvent(t,o,e)}},jt=e=>{for(let{name:r,ownerElement:n}of t(`.//@*[${pt.map((e=>`starts-with(name(),"${e}")`)).join(" or ")}]`,e))r=r.slice(r.lastIndexOf("-")+1),"env"!==r&&n.addEventListener(r,xt)},Tt=[],Rt=new Map,_t=new Map,Ot=e=>{for(const t of Tt)if(e.matches(t)){const r=Rt.get(t),{resolve:n}=_t.get(r),{options:s,known:o}=Wt.get(r);if(!o.has(e)){o.add(e);const{interpreter:t,config:a,version:i,env:c,onInterpreterReady:l}=s,u=He(e);if(u){const o=Lt.call(new Ce(null,s),u,{...Fe(e,r),version:i,type:t,custom:r,config:a||{},async:e.hasAttribute("async")});return je(e,"xworker",{value:o}),void n({type:r,xworker:o})}const f=wt(t,i),p=c||`${f}${a?`|${a}`:""}`,{interpreter:d,XWorker:h}=kt(r,p,f,i,a,t);d.then((o=>{const a=Me(lt.get(t)),{onBeforeRun:i,onBeforeRunAsync:c,onAfterRun:u,onAfterRunAsync:p}=s,d=new Ce(o,s),g=function(...e){return h.apply(d,e)};for(const[t,[r,n]]of[["run",[i,u]]]){const s=a[t];a[t]=function(t,o,...a){r&&r.call(this,y,e);const i=s.call(this,t,o,...a);return n&&n.call(this,y,e),i}}for(const[t,[r,n]]of[["runAsync",[c,p]]]){const s=a[t];a[t]=async function(t,o,...a){r&&await r.call(this,y,e);const i=await s.call(this,t,o,...a);return n&&await n.call(this,y,e),i}}a.registerJSModule(o,"polyscript",{XWorker:g});const y={type:r,interpreter:o,XWorker:g,io:De.get(o),config:structuredClone(ut.get(f)),run:a.run.bind(a,o),runAsync:a.runAsync.bind(a,o),runEvent:a.runEvent.bind(a,o)};n(y),l?.(y,e)}))}}},Wt=new Map;let Ft=0;const Bt=(t,r)=>{let n=null==t;if(n)t="_ps"+Ft++;else if(lt.has(t)||Wt.has(t))throw new Error(`<script type="${t}"> already registered`);if(!lt.has(r?.interpreter))throw new Error("Unspecified interpreter");lt.set(t,lt.get(r.interpreter));const s=[`script[type="${t}"]`];if(It(t),n){const{onInterpreterReady:e}=r;r={...r,onInterpreterReady(r,n){Tt.splice(Tt.indexOf(t),1),lt.delete(t),Wt.delete(t),_t.delete(t),n.remove(),e?.(r)}},document.head.append(Pe(document.createElement("script"),{type:t}))}else s.push(`${t}-script`),pt.push(`${t}-`);for(const e of s)Rt.set(e,t);Tt.push(...s),Wt.set(t,{options:Pe({env:t},r),known:new WeakSet}),n||jt(document),e(s.join(",")).forEach(Ot)},It=e=>(_t.has(e)||_t.set(e,Promise.withResolvers()),_t.get(e).promise),Lt=Ne(),Jt=ft.join(","),Ct=new MutationObserver((t=>{for(const{type:r,target:n,attributeName:s,addedNodes:o}of t)if("attributes"!==r){for(const t of o)if(1===t.nodeType)if(jt(t),t.matches(Jt))$t(t);else{if(e(Jt,t).forEach($t),!Tt.length)continue;Ot(t),e(Tt.join(","),t).forEach(Ot)}}else{const e=s.lastIndexOf("-")+1;if(e){const t=s.slice(0,e);for(const r of pt)if(t===r){const t=s.slice(e);if("env"!==t){const e=n.hasAttribute(s)?"add":"remove";n[`${e}EventListener`](t,xt)}break}}}})),Nt=e=>(Ct.observe(e,{childList:!0,subtree:!0,attributes:!0}),e),{attachShadow:Ht}=Element.prototype;Pe(Element.prototype,{attachShadow(e){return Nt(Ht.call(this,e))}}),jt(Nt(document)),e(Jt,document).forEach($t);export{Lt as XWorker,Bt as define,Pt as env,It as whenDefined};
const e=(e,t=document)=>[...t.querySelectorAll(e)],t=(e,t=document)=>{const r=(new XPathEvaluator).createExpression(e).evaluate(t,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE),n=[];for(let e=0,{snapshotLength:t}=r;e<t;e++)n.push(r.snapshotItem(e));return n},r="object"==typeof self?self:globalThis,n=e=>((e,t)=>{const n=(t,r)=>(e.set(r,t),t),s=o=>{if(e.has(o))return e.get(o);const[a,i]=t[o];switch(a){case 0:case-1:return n(i,o);case 1:{const e=n([],o);for(const t of i)e.push(s(t));return e}case 2:{const e=n({},o);for(const[t,r]of i)e[s(t)]=s(r);return e}case 3:return n(new Date(i),o);case 4:{const{source:e,flags:t}=i;return n(new RegExp(e,t),o)}case 5:{const e=n(new Map,o);for(const[t,r]of i)e.set(s(t),s(r));return e}case 6:{const e=n(new Set,o);for(const t of i)e.add(s(t));return e}case 7:{const{name:e,message:t}=i;return n(new r[e](t),o)}case 8:return n(BigInt(i),o);case"BigInt":return n(Object(BigInt(i)),o)}return n(new r[a](i),o)};return s})(new Map,e)(0),s="",{toString:o}={},{keys:a}=Object,i=e=>{const t=typeof e;if("object"!==t||!e)return[0,t];const r=o.call(e).slice(8,-1);switch(r){case"Array":return[1,s];case"Object":return[2,s];case"Date":return[3,s];case"RegExp":return[4,s];case"Map":return[5,s];case"Set":return[6,s]}return r.includes("Array")?[1,r]:r.includes("Error")?[7,r]:[2,r]},c=([e,t])=>0===e&&("function"===t||"symbol"===t),l=(e,{json:t,lossy:r}={})=>{const n=[];return((e,t,r,n)=>{const s=(e,t)=>{const s=n.push(e)-1;return r.set(t,s),s},o=n=>{if(r.has(n))return r.get(n);let[l,u]=i(n);switch(l){case 0:{let t=n;switch(u){case"bigint":l=8,t=n.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+u);t=null;break;case"undefined":return s([-1],n)}return s([l,t],n)}case 1:{if(u)return s([u,[...n]],n);const e=[],t=s([l,e],n);for(const t of n)e.push(o(t));return t}case 2:{if(u)switch(u){case"BigInt":return s([u,n.toString()],n);case"Boolean":case"Number":case"String":return s([u,n.valueOf()],n)}if(t&&"toJSON"in n)return o(n.toJSON());const r=[],f=s([l,r],n);for(const t of a(n))!e&&c(i(n[t]))||r.push([o(t),o(n[t])]);return f}case 3:return s([l,n.toISOString()],n);case 4:{const{source:e,flags:t}=n;return s([l,{source:e,flags:t}],n)}case 5:{const t=[],r=s([l,t],n);for(const[r,s]of n)(e||!c(i(r))&&!c(i(s)))&&t.push([o(r),o(s)]);return r}case 6:{const t=[],r=s([l,t],n);for(const r of n)!e&&c(i(r))||t.push(o(r));return r}}const{message:f}=n;return s([l,{name:u,message:f}],n)};return o})(!(t||r),!!t,new Map,n)(e),n},{parse:u,stringify:f}=JSON,p={json:!0,lossy:!0};var d=Object.freeze({__proto__:null,parse:e=>n(u(e)),stringify:e=>f(l(e,p))});const h="3099687a-04a9-4406-a08e-fd1602cb2a81",g="M"+h,y="T"+h;var w=e=>({value:new Promise((t=>{let r=new Worker("data:application/javascript,onmessage%3D(%7Bdata%3Ab%7D)%3D%3E(Atomics.wait(b%2C0)%2CpostMessage(0))");r.onmessage=t,r.postMessage(e)}))})
/*! (c) Andrea Giammarchi - ISC */;const{Int32Array:m,Map:b,SharedArrayBuffer:v,Uint16Array:E}=globalThis,{BYTES_PER_ELEMENT:S}=m,{BYTES_PER_ELEMENT:A}=E,{isArray:k}=Array,{notify:$,wait:P,waitAsync:M}=Atomics,{fromCharCode:x}=String,j=(e,t)=>e?(M||w)(t,0):(P(t,0),{value:{then:e=>e()}}),T=new WeakSet,R=new WeakMap;let _=0;const O=(e,{parse:t,stringify:r,transform:n}=JSON)=>{if(!R.has(e)){const s=(t,...r)=>e.postMessage({[h]:r},{transfer:t});let o=!1;R.set(e,new Proxy(new b,{has:(e,t)=>"string"==typeof t&&!t.startsWith("_"),get:(r,a)=>"then"===a?null:(...r)=>{const i=_++;let c=new m(new v(S)),l=[];T.has(r.at(-1)||l)&&T.delete(l=r.pop()),s(l,i,c,a,n?r.map(n):r);const u=e!==globalThis;let f=0;return o&&u&&(f=setTimeout(console.warn,1e3,`💀🔒 - Possible deadlock if proxy.${a}(...args) is awaited`)),j(u,c).value.then((()=>{clearTimeout(f);const e=c[0];if(!e)return;const r=A*e;return c=new m(new v(r+r%S)),s([],i,c),j(u,c).value.then((()=>t(x(...new E(c.buffer).slice(0,e)))))}))},set(t,s,a){if(!t.size){const s=new b;e.addEventListener("message",(async e=>{const a=e.data?.[h];if(k(a)){e.stopImmediatePropagation();const[i,c,...l]=a;if(l.length){const[e,a]=l;if(!t.has(e))throw new Error(`Unsupported action: ${e}`);o=!0;try{const o=await t.get(e)(...a);if(void 0!==o){const e=r(n?n(o):o);s.set(i,e),c[0]=e.length}}finally{o=!1}}else{const e=s.get(i);s.delete(i);for(let t=new E(c.buffer),r=0;r<e.length;r++)t[r]=e.charCodeAt(r)}$(c,0)}}))}return!!t.set(s,a)}}))}return R.get(e)};O.transfer=(...e)=>(T.add(e),e);const W="object",F="function",B="number",I="string",L="undefined",J="symbol",{defineProperty:C,getOwnPropertyDescriptor:N,getPrototypeOf:H,isExtensible:D,ownKeys:U,preventExtensions:q,set:z,setPrototypeOf:Q}=Reflect,{assign:X,create:Y}=Object,K=H(Int8Array),G="isArray",V=(e,t)=>{const{get:r,set:n,value:s}=e;return r&&(e.get=t(r)),n&&(e.set=t(n)),s&&(e.value=t(s)),e},Z=(e,t)=>[e,t],ee=e=>t=>{const r=typeof t;switch(r){case W:if(null==t)return Z("null",t);if(t===globalThis)return Z(W,null);case F:return e(r,t);case"boolean":case B:case I:case L:case"bigint":return Z(r,t);case J:if(te.has(t))return Z(r,te.get(t))}throw new Error(`Unable to handle this ${r} type`)},te=new Map(U(Symbol).filter((e=>typeof Symbol[e]===J)).map((e=>[Symbol[e],e]))),re=e=>{for(const[t,r]of te)if(r===e)return t};function ne(){return this}const se="apply",oe="construct",ae="defineProperty",ie="deleteProperty",ce="get",le="getOwnPropertyDescriptor",ue="getPrototypeOf",fe="has",pe="isExtensible",de="ownKeys",he="preventExtensions",ge="set",ye="setPrototypeOf",we="delete";var me=((e,t)=>{const r=t&&new WeakMap;if(t){const{addEventListener:e}=EventTarget.prototype;C(EventTarget.prototype,"addEventListener",{value(t,n,...s){return s.at(0)?.invoke&&(r.has(this)||r.set(this,new Map),r.get(this).set(t,[].concat(s[0].invoke)),delete s[0].invoke),e.call(this,t,n,...s)}})}const n=t&&(e=>{const{currentTarget:t,target:n,type:s}=e;for(const o of r.get(t||n)?.get(s)||[])e[o]()});return(r,s,o,...a)=>{let i=0;const c=new Map,l=new Map,{[o]:u}=r,f=a.length?X(Y(globalThis),...a):globalThis,p=ee(((e,t)=>{if(!c.has(t)){let e;for(;l.has(e=i++););c.set(t,e),l.set(e,t)}return Z(e,c.get(t))})),d=new FinalizationRegistry((e=>{u(we,Z(I,e))})),h=([e,r])=>{switch(e){case W:if(null==r)return f;if(typeof r===B)return l.get(r);if(!(r instanceof K))for(const e in r)r[e]=h(r[e]);return r;case F:if(typeof r===I){if(!l.has(r)){const e=function(...e){return t&&e.at(0)instanceof Event&&n(...e),u(se,Z(F,r),p(this),e.map(p))},s=new WeakRef(e);l.set(r,s),d.register(e,r,s)}return l.get(r).deref()}return l.get(r);case J:return re(r)}return r},g={[se]:(e,t,r)=>p(e.apply(t,r)),[oe]:(e,t)=>p(new e(...t)),[ae]:(e,t,r)=>p(C(e,t,r)),[ie]:(e,t)=>p(delete e[t]),[ue]:e=>p(H(e)),[ce]:(e,t)=>p(e[t]),[le]:(e,t)=>{const r=N(e,t);return r?Z(W,V(r,p)):Z(L,r)},[fe]:(e,t)=>p(t in e),[pe]:e=>p(D(e)),[de]:e=>Z(W,U(e).map(p)),[he]:e=>p(q(e)),[ge]:(e,t,r)=>p(z(e,t,r)),[ye]:(e,t)=>p(Q(e,t)),[we](e){c.delete(l.get(e)),l.delete(e)}};return r[s]=(e,t,...r)=>{switch(e){case se:r[0]=h(r[0]),r[1]=r[1].map(h);break;case oe:r[0]=r[0].map(h);break;case ae:{const[e,t]=r;r[0]=h(e);const{get:n,set:s,value:o}=t;n&&(t.get=h(n)),s&&(t.set=h(s)),o&&(t.value=h(o));break}default:r=r.map(h)}return g[e](h(t),...r)},{proxy:r,[e.toLowerCase()]:f,[`is${e}Proxy`]:()=>!1}}})("Window",!0),be=(e=>{let t=0;const r=new Map,n=new Map,s=Symbol(),o=e=>typeof e===F?e():e,a=e=>typeof e===W&&!!e&&s in e,i=Array[G],c=ee(((e,a)=>{if(s in a)return o(a[s]);if(e===F){if(!n.has(a)){let e;for(;n.has(e=String(t++)););r.set(a,e),n.set(e,a)}return Z(e,r.get(a))}if(!(a instanceof K))for(const e in a)a[e]=c(a[e]);return Z(e,a)}));return(t,l,u)=>{const{[l]:f}=t,p=new Map,d=new FinalizationRegistry((e=>{p.delete(e),f(we,c(e))})),h=e=>{const[t,r]=e;if(!p.has(r)){const n=t===F?ne.bind(e):e,s=new Proxy(n,w),o=new WeakRef(s);p.set(r,o),d.register(s,r,o)}return p.get(r).deref()},g=e=>{const[t,r]=e;switch(t){case W:return null===r?globalThis:typeof r===B?h(e):r;case F:return typeof r===I?n.get(r):h(e);case J:return re(r)}return r},y=(e,t,...r)=>g(f(e,o(t),...r)),w={[se]:(e,t,r)=>y(se,e,c(t),r.map(c)),[oe]:(e,t)=>y(oe,e,t.map(c)),[ae]:(e,t,r)=>{const{get:n,set:s,value:o}=r;return typeof n===F&&(r.get=c(n)),typeof s===F&&(r.set=c(s)),typeof o===F&&(r.value=c(o)),y(ae,e,c(t),r)},[ie]:(e,t)=>y(ie,e,c(t)),[ue]:e=>y(ue,e),[ce]:(e,t)=>t===s?e:y(ce,e,c(t)),[le]:(e,t)=>{const r=y(le,e,c(t));return r&&V(r,g)},[fe]:(e,t)=>t===s||y(fe,e,c(t)),[pe]:e=>y(pe,e),[de]:e=>y(de,e).map(g),[he]:e=>y(he,e),[ge]:(e,t,r)=>y(ge,e,c(t),c(r)),[ye]:(e,t)=>y(ye,e,c(t))};t[u]=(e,t,s,o)=>{switch(e){case se:return g(t).apply(g(s),o.map(g));case we:{const e=g(t);r.delete(n.get(e)),n.delete(e)}}};const m=new Proxy([W,null],w),b=m.Array[G];return C(Array,G,{value:e=>a(e)?b(e):i(e)}),{[e.toLowerCase()]:m,[`is${e}Proxy`]:a,proxy:t}}})("Window"),ve="function"==typeof Worker?Worker:class{};const Ee=new WeakMap,Se=(e,...t)=>{const r=O(e,...t);if(!Ee.has(r)){const t=e instanceof ve?me:be;Ee.set(r,t(r,g,y))}return Ee.get(r)};Se.transfer=O.transfer;const Ae={object(...e){return this.string(function(e){for(var t=e[0],r=1,n=arguments.length;r<n;r++)t+=arguments[r]+e[r];return t}(...e))},string(e){for(const t of e.split(/[\r\n]+/))if(t.trim().length){/^(\s+)/.test(t)&&(e=e.replace(new RegExp("^"+RegExp.$1,"gm"),""));break}return e}},ke=(e,...t)=>Ae[typeof e](e,...t),{isArray:$e}=Array,{assign:Pe,create:Me,defineProperties:xe,defineProperty:je,entries:Te}=Object,{all:Re,resolve:_e}=new Proxy(Promise,{get:(e,t)=>e[t].bind(e)}),Oe=(e,t=location.href)=>new URL(e,t).href;let We=0;const Fe=(e,t)=>({id:e.id||(e.id=`${t}-w${We++}`),tag:e.tagName}),Be=e=>e.arrayBuffer(),Ie=e=>e.json(),Le=e=>e.text(),Je=[["beforeRun","codeBeforeRunWorker"],["beforeRunAsync","codeBeforeRunWorkerAsync"],["afterRun","codeAfterRunWorker"],["afterRunAsync","codeAfterRunWorkerAsync"]];class Ce{constructor(e,t){this.interpreter=e,this.onWorkerReady=t.onWorkerReady;for(const[e,r]of Je)this[e]=t[r]?.()}get stringHooks(){const e={};for(const[t]of Je)this[t]&&(e[t]=ke(this[t]));return e}}var Ne=(...e)=>function(t,r){const n=new Worker(URL.createObjectURL(new Blob(['const e="object"==typeof self?self:globalThis,t=t=>((t,r)=>{const n=(e,r)=>(t.set(r,e),e),s=o=>{if(t.has(o))return t.get(o);const[a,i]=r[o];switch(a){case 0:case-1:return n(i,o);case 1:{const e=n([],o);for(const t of i)e.push(s(t));return e}case 2:{const e=n({},o);for(const[t,r]of i)e[s(t)]=s(r);return e}case 3:return n(new Date(i),o);case 4:{const{source:e,flags:t}=i;return n(new RegExp(e,t),o)}case 5:{const e=n(new Map,o);for(const[t,r]of i)e.set(s(t),s(r));return e}case 6:{const e=n(new Set,o);for(const t of i)e.add(s(t));return e}case 7:{const{name:t,message:r}=i;return n(new e[t](r),o)}case 8:return n(BigInt(i),o);case"BigInt":return n(Object(BigInt(i)),o)}return n(new e[a](i),o)};return s})(new Map,t)(0),r="",{toString:n}={},{keys:s}=Object,o=e=>{const t=typeof e;if("object"!==t||!e)return[0,t];const s=n.call(e).slice(8,-1);switch(s){case"Array":return[1,r];case"Object":return[2,r];case"Date":return[3,r];case"RegExp":return[4,r];case"Map":return[5,r];case"Set":return[6,r]}return s.includes("Array")?[1,s]:s.includes("Error")?[7,s]:[2,s]},a=([e,t])=>0===e&&("function"===t||"symbol"===t),i=(e,{json:t,lossy:r}={})=>{const n=[];return((e,t,r,n)=>{const i=(e,t)=>{const s=n.push(e)-1;return r.set(t,s),s},c=n=>{if(r.has(n))return r.get(n);let[l,u]=o(n);switch(l){case 0:{let t=n;switch(u){case"bigint":l=8,t=n.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+u);t=null;break;case"undefined":return i([-1],n)}return i([l,t],n)}case 1:{if(u)return i([u,[...n]],n);const e=[],t=i([l,e],n);for(const t of n)e.push(c(t));return t}case 2:{if(u)switch(u){case"BigInt":return i([u,n.toString()],n);case"Boolean":case"Number":case"String":return i([u,n.valueOf()],n)}if(t&&"toJSON"in n)return c(n.toJSON());const r=[],f=i([l,r],n);for(const t of s(n))!e&&a(o(n[t]))||r.push([c(t),c(n[t])]);return f}case 3:return i([l,n.toISOString()],n);case 4:{const{source:e,flags:t}=n;return i([l,{source:e,flags:t}],n)}case 5:{const t=[],r=i([l,t],n);for(const[r,s]of n)(e||!a(o(r))&&!a(o(s)))&&t.push([c(r),c(s)]);return r}case 6:{const t=[],r=i([l,t],n);for(const r of n)!e&&a(o(r))||t.push(c(r));return r}}const{message:f}=n;return i([l,{name:u,message:f}],n)};return c})(!(t||r),!!t,new Map,n)(e),n},{parse:c,stringify:l}=JSON,u={json:!0,lossy:!0};var f=Object.freeze({__proto__:null,parse:e=>t(c(e)),stringify:e=>l(i(e,u))});const p="3099687a-04a9-4406-a08e-fd1602cb2a81",d="M"+p,g="T"+p;var y=e=>({value:new Promise((t=>{let r=new Worker("data:application/javascript,onmessage%3D(%7Bdata%3Ab%7D)%3D%3E(Atomics.wait(b%2C0)%2CpostMessage(0))");r.onmessage=t,r.postMessage(e)}))})\n/*! (c) Andrea Giammarchi - ISC */;const{Int32Array:h,Map:w,SharedArrayBuffer:m,Uint16Array:b}=globalThis,{BYTES_PER_ELEMENT:v}=h,{BYTES_PER_ELEMENT:S}=b,{isArray:E}=Array,{notify:P,wait:A,waitAsync:M}=Atomics,{fromCharCode:$}=String,j=(e,t)=>e?(M||y)(t,0):(A(t,0),{value:{then:e=>e()}}),k=new WeakSet,x=new WeakMap;let T=0;const _=(e,{parse:t,stringify:r,transform:n}=JSON)=>{if(!x.has(e)){const s=(t,...r)=>e.postMessage({[p]:r},{transfer:t});let o=!1;x.set(e,new Proxy(new w,{has:(e,t)=>"string"==typeof t&&!t.startsWith("_"),get:(r,a)=>"then"===a?null:(...r)=>{const i=T++;let c=new h(new m(v)),l=[];k.has(r.at(-1)||l)&&k.delete(l=r.pop()),s(l,i,c,a,n?r.map(n):r);const u=e!==globalThis;let f=0;return o&&u&&(f=setTimeout(console.warn,1e3,`💀🔒 - Possible deadlock if proxy.${a}(...args) is awaited`)),j(u,c).value.then((()=>{clearTimeout(f);const e=c[0];if(!e)return;const r=S*e;return c=new h(new m(r+r%v)),s([],i,c),j(u,c).value.then((()=>t($(...new b(c.buffer).slice(0,e)))))}))},set(t,s,a){if(!t.size){const s=new w;e.addEventListener("message",(async e=>{const a=e.data?.[p];if(E(a)){e.stopImmediatePropagation();const[i,c,...l]=a;if(l.length){const[e,a]=l;if(!t.has(e))throw new Error(`Unsupported action: ${e}`);o=!0;try{const o=await t.get(e)(...a);if(void 0!==o){const e=r(n?n(o):o);s.set(i,e),c[0]=e.length}}finally{o=!1}}else{const e=s.get(i);s.delete(i);for(let t=new b(c.buffer),r=0;r<e.length;r++)t[r]=e.charCodeAt(r)}P(c,0)}}))}return!!t.set(s,a)}}))}return x.get(e)};_.transfer=(...e)=>(k.add(e),e);const O="object",F="function",W="number",R="string",B="undefined",J="symbol",{defineProperty:I,getOwnPropertyDescriptor:L,getPrototypeOf:C,isExtensible:H,ownKeys:D,preventExtensions:N,set:U,setPrototypeOf:z}=Reflect,{assign:q,create:K}=Object,Y=C(Int8Array),G="isArray",V=(e,t)=>{const{get:r,set:n,value:s}=e;return r&&(e.get=t(r)),n&&(e.set=t(n)),s&&(e.value=t(s)),e},Q=(e,t)=>[e,t],X=e=>t=>{const r=typeof t;switch(r){case O:if(null==t)return Q("null",t);if(t===globalThis)return Q(O,null);case F:return e(r,t);case"boolean":case W:case R:case B:case"bigint":return Q(r,t);case J:if(Z.has(t))return Q(r,Z.get(t))}throw new Error(`Unable to handle this ${r} type`)},Z=new Map(D(Symbol).filter((e=>typeof Symbol[e]===J)).map((e=>[Symbol[e],e]))),ee=e=>{for(const[t,r]of Z)if(r===e)return t};function te(){return this}const re="apply",ne="construct",se="defineProperty",oe="deleteProperty",ae="get",ie="getOwnPropertyDescriptor",ce="getPrototypeOf",le="has",ue="isExtensible",fe="ownKeys",pe="preventExtensions",de="set",ge="setPrototypeOf",ye="delete";var he=((e,t)=>{const r=t&&new WeakMap;if(t){const{addEventListener:e}=EventTarget.prototype;I(EventTarget.prototype,"addEventListener",{value(t,n,...s){return s.at(0)?.invoke&&(r.has(this)||r.set(this,new Map),r.get(this).set(t,[].concat(s[0].invoke)),delete s[0].invoke),e.call(this,t,n,...s)}})}const n=t&&(e=>{const{currentTarget:t,target:n,type:s}=e;for(const o of r.get(t||n)?.get(s)||[])e[o]()});return(r,s,o,...a)=>{let i=0;const c=new Map,l=new Map,{[o]:u}=r,f=a.length?q(K(globalThis),...a):globalThis,p=X(((e,t)=>{if(!c.has(t)){let e;for(;l.has(e=i++););c.set(t,e),l.set(e,t)}return Q(e,c.get(t))})),d=new FinalizationRegistry((e=>{u(ye,Q(R,e))})),g=([e,r])=>{switch(e){case O:if(null==r)return f;if(typeof r===W)return l.get(r);if(!(r instanceof Y))for(const e in r)r[e]=g(r[e]);return r;case F:if(typeof r===R){if(!l.has(r)){const e=function(...e){return t&&e.at(0)instanceof Event&&n(...e),u(re,Q(F,r),p(this),e.map(p))},s=new WeakRef(e);l.set(r,s),d.register(e,r,s)}return l.get(r).deref()}return l.get(r);case J:return ee(r)}return r},y={[re]:(e,t,r)=>p(e.apply(t,r)),[ne]:(e,t)=>p(new e(...t)),[se]:(e,t,r)=>p(I(e,t,r)),[oe]:(e,t)=>p(delete e[t]),[ce]:e=>p(C(e)),[ae]:(e,t)=>p(e[t]),[ie]:(e,t)=>{const r=L(e,t);return r?Q(O,V(r,p)):Q(B,r)},[le]:(e,t)=>p(t in e),[ue]:e=>p(H(e)),[fe]:e=>Q(O,D(e).map(p)),[pe]:e=>p(N(e)),[de]:(e,t,r)=>p(U(e,t,r)),[ge]:(e,t)=>p(z(e,t)),[ye](e){c.delete(l.get(e)),l.delete(e)}};return r[s]=(e,t,...r)=>{switch(e){case re:r[0]=g(r[0]),r[1]=r[1].map(g);break;case ne:r[0]=r[0].map(g);break;case se:{const[e,t]=r;r[0]=g(e);const{get:n,set:s,value:o}=t;n&&(t.get=g(n)),s&&(t.set=g(s)),o&&(t.value=g(o));break}default:r=r.map(g)}return y[e](g(t),...r)},{proxy:r,[e.toLowerCase()]:f,[`is${e}Proxy`]:()=>!1}}})("Window",!0),we=(e=>{let t=0;const r=new Map,n=new Map,s=Symbol(),o=e=>typeof e===F?e():e,a=e=>typeof e===O&&!!e&&s in e,i=Array[G],c=X(((e,a)=>{if(s in a)return o(a[s]);if(e===F){if(!n.has(a)){let e;for(;n.has(e=String(t++)););r.set(a,e),n.set(e,a)}return Q(e,r.get(a))}if(!(a instanceof Y))for(const e in a)a[e]=c(a[e]);return Q(e,a)}));return(t,l,u)=>{const{[l]:f}=t,p=new Map,d=new FinalizationRegistry((e=>{p.delete(e),f(ye,c(e))})),g=e=>{const[t,r]=e;if(!p.has(r)){const n=t===F?te.bind(e):e,s=new Proxy(n,w),o=new WeakRef(s);p.set(r,o),d.register(s,r,o)}return p.get(r).deref()},y=e=>{const[t,r]=e;switch(t){case O:return null===r?globalThis:typeof r===W?g(e):r;case F:return typeof r===R?n.get(r):g(e);case J:return ee(r)}return r},h=(e,t,...r)=>y(f(e,o(t),...r)),w={[re]:(e,t,r)=>h(re,e,c(t),r.map(c)),[ne]:(e,t)=>h(ne,e,t.map(c)),[se]:(e,t,r)=>{const{get:n,set:s,value:o}=r;return typeof n===F&&(r.get=c(n)),typeof s===F&&(r.set=c(s)),typeof o===F&&(r.value=c(o)),h(se,e,c(t),r)},[oe]:(e,t)=>h(oe,e,c(t)),[ce]:e=>h(ce,e),[ae]:(e,t)=>t===s?e:h(ae,e,c(t)),[ie]:(e,t)=>{const r=h(ie,e,c(t));return r&&V(r,y)},[le]:(e,t)=>t===s||h(le,e,c(t)),[ue]:e=>h(ue,e),[fe]:e=>h(fe,e).map(y),[pe]:e=>h(pe,e),[de]:(e,t,r)=>h(de,e,c(t),c(r)),[ge]:(e,t)=>h(ge,e,c(t))};t[u]=(e,t,s,o)=>{switch(e){case re:return y(t).apply(y(s),o.map(y));case ye:{const e=y(t);r.delete(n.get(e)),n.delete(e)}}};const m=new Proxy([O,null],w),b=m.Array[G];return I(Array,G,{value:e=>a(e)?b(e):i(e)}),{[e.toLowerCase()]:m,[`is${e}Proxy`]:a,proxy:t}}})("Window"),me="function"==typeof Worker?Worker:class{};const be=new WeakMap,ve=(e,...t)=>{const r=_(e,...t);if(!be.has(r)){const t=e instanceof me?he:we;be.set(r,t(r,d,g))}return be.get(r)};ve.transfer=_.transfer;const Se={object(...e){return this.string(function(e){for(var t=e[0],r=1,n=arguments.length;r<n;r++)t+=arguments[r]+e[r];return t}(...e))},string(e){for(const t of e.split(/[\\r\\n]+/))if(t.trim().length){/^(\\s+)/.test(t)&&(e=e.replace(new RegExp("^"+RegExp.$1,"gm"),""));break}return e}},Ee=(e,...t)=>Se[typeof e](e,...t),{isArray:Pe}=Array,{assign:Ae,create:Me,defineProperties:$e,defineProperty:je,entries:ke}=Object,{all:xe,resolve:Te}=new Proxy(Promise,{get:(e,t)=>e[t].bind(e)}),_e=(e,t=location.href)=>new URL(e,t).href;Promise.withResolvers||(Promise.withResolvers=function(){var e,t,r=new this((function(r,n){e=r,t=n}));return{resolve:e,reject:t,promise:r}});const Oe=e=>e.arrayBuffer(),Fe=e=>e.json(),We=e=>e.text(),Re=new WeakMap,Be=e=>{const t=e||console,r={stderr:(t.stderr||console.error).bind(t),stdout:(t.stdout||console.log).bind(t)};return{stderr:(...e)=>r.stderr(...e),stdout:(...e)=>r.stdout(...e),async get(e){const t=await e;return Re.set(t,r),t}}},Je=({FS:e,PATH:t,PATH_FS:r},n,s)=>{const o=r.resolve(n);return e.mkdirTree(t.dirname(o)),e.writeFile(o,new Uint8Array(s),{canOwn:!0})},Ie=e=>{const t=e.split("/");return t.pop(),t.join("/")},Le=(e,t)=>{const r=[];for(const n of t.split("/"))"."!==n&&(r.push(n),n&&e.mkdir(r.join("/")))},Ce=(e,t)=>{const r=[];for(const e of t.split("/"))switch(e){case"":case".":break;case"..":r.pop();break;default:r.push(e)}return[e.cwd()].concat(r).join("/").replace(/^\\/+/,"/")},He=e=>{const t=e.map((e=>e.trim().replace(/(^[/]*|[/]*$)/g,""))).filter((e=>""!==e&&"."!==e)).join("/");return e[0].startsWith("/")?`/${t}`:t},De=new WeakMap,Ne=(e,t,r)=>xe((e=>{for(const{files:t,to_file:r,from:n=""}of e){if(void 0!==t&&void 0!==r)throw new Error("Cannot use \'to_file\' and \'files\' parameters together!");if(void 0===t&&void 0===r&&n.endsWith("/"))throw new Error(`Couldn\'t determine the filename from the path ${n}, please supply \'to_file\' parameter.`)}return e.flatMap((({from:e="",to_folder:t=".",to_file:r,files:n})=>{if(Pe(n))return n.map((r=>({url:He([e,r]),path:He([t,r])})));const s=r||e.slice(1+e.lastIndexOf("/"));return[{url:e,path:He([t,s])}]}))})(r).map((({url:n,path:s})=>((e,t)=>fetch(_e(t,De.get(e))))(r,n).then(Oe).then((r=>e.writeFile(t,s,r)))))),Ue=(e,t,r)=>{e.registerJsModule(t,r)},ze=(e,t,...r)=>{try{return e.runPython(Ee(t),...r)}catch(t){Re.get(e).stderr(t)}},qe=async(e,t,...r)=>{try{return await e.runPythonAsync(Ee(t),...r)}catch(t){Re.get(e).stderr(t)}},Ke=async(e,t,r)=>{const[n,...s]=t.split(".");let o,a=e.globals.get(n);for(const e of s)[o,a]=[a,a[e]];try{await a.call(o,r)}catch(t){Re.get(e).stderr(t)}};var Ye={type:"micropython",module:(e="1.20.0-297")=>`https://cdn.jsdelivr.net/npm/@micropython/micropython-webassembly-pyscript@${e}/micropython.mjs`,async engine({loadMicroPython:e},t,r){const{stderr:n,stdout:s,get:o}=Be();r=r.replace(/\\.m?js$/,".wasm");const a=await o(e({stderr:n,stdout:s,url:r}));return t.fetch&&await Ne(this,a,t.fetch),a},registerJSModule:Ue,run:ze,runAsync:qe,runEvent:Ke,transform:(e,t)=>t,writeFile:({FS:e,_module:{PATH:t,PATH_FS:r}},n,s)=>Je({FS:e,PATH:t,PATH_FS:r},n,s)};const Ge={dict_converter:Object.fromEntries};var Ve={type:"pyodide",module:(e="0.23.4")=>`https://cdn.jsdelivr.net/pyodide/v${e}/full/pyodide.mjs`,async engine({loadPyodide:e},t,r){const{stderr:n,stdout:s,get:o}=Be(),a=r.slice(0,r.lastIndexOf("/")),i=await o(e({stderr:n,stdout:s,indexURL:a}));if(t.fetch&&await Ne(this,i,t.fetch),t.packages){await i.loadPackage("micropip");const e=await i.pyimport("micropip");await e.install(t.packages),e.destroy()}return i},registerJSModule:Ue,run:ze,runAsync:qe,runEvent:Ke,transform:(e,t)=>t instanceof e.ffi.PyProxy?t.toJs(Ge):t,writeFile:({FS:e,PATH:t,_module:{PATH_FS:r}},n,s)=>Je({FS:e,PATH:t,PATH_FS:r},n,s)};const Qe="ruby-wasm-wasi",Xe=Qe.replace(/\\W+/g,"_");var Ze={type:Qe,experimental:!0,module:(e="2.0.0")=>`https://cdn.jsdelivr.net/npm/ruby-3_2-wasm-wasi@${e}/dist/browser.esm.js`,async engine({DefaultRubyVM:e},t,r){const n=await fetch(`${r.slice(0,r.lastIndexOf("/"))}/ruby.wasm`),s=await WebAssembly.compile(await n.arrayBuffer()),{vm:o}=await e(s);return t.fetch&&await Ne(this,o,t.fetch),o},registerJSModule(e,t,r){const n=`__module_${Xe}_${t}`;globalThis[n]=r,this.run(e,`require "js";$${t}=JS.global[:${n}]`),delete globalThis[n]},run:(e,t,...r)=>e.eval(Ee(t),...r),runAsync:(e,t,...r)=>e.evalAsync(Ee(t),...r),async runEvent(e,t,r){if(/^xworker\\.(on\\w+)$/.test(t)){const{$1:t}=RegExp,n=`__module_${Xe}_event`;globalThis[n]=r,this.run(e,`require "js";$xworker.call("${t}",JS.global[:${n}])`),delete globalThis[n]}else{const n=this.run(e,`method(:${t})`);await n.call(t,e.wrap(r))}},transform:(e,t)=>t,writeFile:()=>{throw new Error(`writeFile is not supported in ${Qe}`)}};var et={type:"wasmoon",module:(e="1.15.0")=>`https://cdn.jsdelivr.net/npm/wasmoon@${e}/+esm`,async engine({LuaFactory:e,LuaLibraries:t},r){const{stderr:n,stdout:s,get:o}=Be(),a=await o((new e).createEngine());return a.global.getTable(t.Base,(e=>{a.global.setField(e,"print",s),a.global.setField(e,"printErr",n)})),r.fetch&&await Ne(this,a,r.fetch),a},registerJSModule:(e,t,r)=>{e.global.set(t,r)},run:(e,t,...r)=>{try{return e.doStringSync(Ee(t),...r)}catch(t){Re.get(e).stderr(t)}},runAsync:async(e,t,...r)=>{try{return await e.doString(Ee(t),...r)}catch(t){Re.get(e).stderr(t)}},runEvent:async(e,t,r)=>{const[n,...s]=t.split(".");let o,a=e.global.get(n);for(const e of s)[o,a]=[a,a[e]];try{await a.call(o,r)}catch(t){Re.get(e).stderr(t)}},transform:(e,t)=>t,writeFile:({cmodule:{module:{FS:e}}},t,r)=>((e,t,r)=>(Le(e,Ie(t)),t=Ce(e,t),e.writeFile(t,new Uint8Array(r),{canOwn:!0})))(e,t,r)};const tt=new Map,rt=new Map,nt=new Proxy(new Map,{get(e,t){if(!e.has(t)){const[r,...n]=t.split("@"),s=tt.get(r),o=/^https?:\\/\\//i.test(n)?n.join("@"):s.module(...n);e.set(t,{url:o,module:import(o),engine:s.engine.bind(s)})}const{url:r,module:n,engine:s}=e.get(t);return(e,o)=>n.then((n=>{rt.set(t,e);const a=e?.fetch;return a&&De.set(a,o),s(n,e,r)}))}}),st=e=>{for(const t of[].concat(e.type))tt.set(t,e)};for(const e of[Ye,Ve,Ze,et])st(e);const ot=async e=>(await import("https://cdn.jsdelivr.net/npm/basic-toml@0.3.1/es.js")).parse(e);try{new SharedArrayBuffer(4)}catch(e){throw new Error(["Unable to use SharedArrayBuffer due insecure environment.","Please read requirements in MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer#security_requirements"].join("\\n"))}let at,it,ct;const lt=(e,t)=>{addEventListener(e,t||(async t=>{try{await at,it(`xworker.on${e}`,t)}catch(e){postMessage(e)}}),!!t&&{once:!0})},{parse:ut,stringify:ft}=f,{proxy:pt,window:dt,isWindowProxy:gt}=ve(self,{parse:ut,stringify:ft,transform:e=>ct?ct(e):e}),yt={sync:pt,window:dt,isWindowProxy:gt,onmessage:console.info,onerror:console.error,onmessageerror:console.warn,postMessage:postMessage.bind(self)};lt("message",(({data:{options:e,config:t,code:r,hooks:n}})=>{at=(async()=>{try{const{id:s,tag:o,type:a,custom:i,version:c,config:l,async:u}=e,f=await((e,t,r={})=>{if(t)if(t.endsWith(".json"))r=fetch(t).then(Fe),t=_e(t);else if(t.endsWith(".toml"))r=fetch(t).then(We).then(ot),t=_e(t);else if(!t.endsWith(".txt")){try{r=JSON.parse(t)}catch(e){r=ot(t)}t=_e("./config.txt")}return Te(r).then((r=>nt[e](r,t)))})(((e,t="")=>`${e}@${t}`.replace(/@$/,""))(a,c),t,l),p=Me(tt.get(a)),d="run"+(u?"Async":"");if(n){const{beforeRun:e,beforeRunAsync:t,afterRun:r,afterRunAsync:s}=n,o=r||s,a=e||t;if(o){const e=p[d].bind(p);p[d]=(t,r,...n)=>e(t,`${r}\\n${o}`,...n)}if(a){const e=p[d].bind(p);p[d]=(t,r,...n)=>e(t,`${a}\\n${r}`,...n)}}const{CustomEvent:g,document:y}=dt,h=s&&y.getElementById(s)||null;let w="";return p.registerJSModule(f,"polyscript",{xworker:yt,get target(){return!w&&h&&("SCRIPT"===o?h.after(Ae(y.createElement(`script-${i||a}`),{id:w=`${s}-target`})):(w=s,h.replaceChildren(),h.style.display="block")),w}}),it=p.runEvent.bind(p,f),ct=p.transform.bind(p,f),h&&((e,t,r,n)=>{e.dispatchEvent(new n(`${t}:ready`,{bubbles:!0,detail:{worker:r}}))})(h,i||a,!0,g),await p[d](f,r),f}catch(e){postMessage(e)}})(),lt("error"),lt("message"),lt("messageerror")}));\n'],{type:"application/javascript"})),{type:"module"}),{postMessage:s}=n,o=this instanceof Ce;if(e.length){const[t,n]=e;(r=Pe({},r||{type:t,version:n})).type||(r.type=t)}const{config:a}=r,i=Oe(a&&"string"==typeof a?a:"./config.txt"),c=fetch(t).then(Le).then((e=>{const t=o?this.stringHooks:void 0;s.call(n,{options:r,config:i,code:e,hooks:t})}));return xe(n,{postMessage:{value:(e,...t)=>c.then((()=>s.call(n,e,...t)))},sync:{value:Se(n,d).proxy},onerror:{writable:!0,configurable:!0,value:console.error}}),o&&this.onWorkerReady?.(this.interpreter,n),n.addEventListener("message",(e=>{const{data:t}=e;t instanceof Error&&(e.stopImmediatePropagation(),n.onerror(Object.create(e,{type:{value:"error"},error:{value:t}})))})),n},He=e=>{const{worker:t}=e.attributes;if(t){let{value:r}=t;if(!r){if(e.childElementCount){const{innerHTML:t,localName:n,type:s}=e,o=s||n.replace(/-script$/,"");console.warn(`Deprecated: use <script type="${o}"> for an always safe content parsing:\n`,t),r=t}else r=e.textContent;return URL.createObjectURL(new Blob([ke(r)],{type:"text/plain"}))}return r}};Promise.withResolvers||(Promise.withResolvers=function(){var e,t,r=new this((function(r,n){e=r,t=n}));return{resolve:e,reject:t,promise:r}});const De=new WeakMap,Ue=e=>{const t=e||console,r={stderr:(t.stderr||console.error).bind(t),stdout:(t.stdout||console.log).bind(t)};return{stderr:(...e)=>r.stderr(...e),stdout:(...e)=>r.stdout(...e),async get(e){const t=await e;return De.set(t,r),t}}},qe=({FS:e,PATH:t,PATH_FS:r},n,s)=>{const o=r.resolve(n);return e.mkdirTree(t.dirname(o)),e.writeFile(o,new Uint8Array(s),{canOwn:!0})},ze=e=>{const t=e.split("/");return t.pop(),t.join("/")},Qe=(e,t)=>{const r=[];for(const n of t.split("/"))"."!==n&&(r.push(n),n&&e.mkdir(r.join("/")))},Xe=(e,t)=>{const r=[];for(const e of t.split("/"))switch(e){case"":case".":break;case"..":r.pop();break;default:r.push(e)}return[e.cwd()].concat(r).join("/").replace(/^\/+/,"/")},Ye=e=>{const t=e.map((e=>e.trim().replace(/(^[/]*|[/]*$)/g,""))).filter((e=>""!==e&&"."!==e)).join("/");return e[0].startsWith("/")?`/${t}`:t},Ke=new WeakMap,Ge=(e,t,r)=>Re((e=>{for(const{files:t,to_file:r,from:n=""}of e){if(void 0!==t&&void 0!==r)throw new Error("Cannot use 'to_file' and 'files' parameters together!");if(void 0===t&&void 0===r&&n.endsWith("/"))throw new Error(`Couldn't determine the filename from the path ${n}, please supply 'to_file' parameter.`)}return e.flatMap((({from:e="",to_folder:t=".",to_file:r,files:n})=>{if($e(n))return n.map((r=>({url:Ye([e,r]),path:Ye([t,r])})));const s=r||e.slice(1+e.lastIndexOf("/"));return[{url:e,path:Ye([t,s])}]}))})(r).map((({url:n,path:s})=>((e,t)=>fetch(Oe(t,Ke.get(e))))(r,n).then(Be).then((r=>e.writeFile(t,s,r)))))),Ve=(e,t,r)=>{e.registerJsModule(t,r)},Ze=(e,t,...r)=>{try{return e.runPython(ke(t),...r)}catch(t){De.get(e).stderr(t)}},et=async(e,t,...r)=>{try{return await e.runPythonAsync(ke(t),...r)}catch(t){De.get(e).stderr(t)}},tt=async(e,t,r)=>{const[n,...s]=t.split(".");let o,a=e.globals.get(n);for(const e of s)[o,a]=[a,a[e]];try{await a.call(o,r)}catch(t){De.get(e).stderr(t)}};var rt={type:"micropython",module:(e="1.20.0-297")=>`https://cdn.jsdelivr.net/npm/@micropython/micropython-webassembly-pyscript@${e}/micropython.mjs`,async engine({loadMicroPython:e},t,r){const{stderr:n,stdout:s,get:o}=Ue();r=r.replace(/\.m?js$/,".wasm");const a=await o(e({stderr:n,stdout:s,url:r}));return t.fetch&&await Ge(this,a,t.fetch),a},registerJSModule:Ve,run:Ze,runAsync:et,runEvent:tt,transform:(e,t)=>t,writeFile:({FS:e,_module:{PATH:t,PATH_FS:r}},n,s)=>qe({FS:e,PATH:t,PATH_FS:r},n,s)};const nt={dict_converter:Object.fromEntries};var st={type:"pyodide",module:(e="0.23.4")=>`https://cdn.jsdelivr.net/pyodide/v${e}/full/pyodide.mjs`,async engine({loadPyodide:e},t,r){const{stderr:n,stdout:s,get:o}=Ue(),a=r.slice(0,r.lastIndexOf("/")),i=await o(e({stderr:n,stdout:s,indexURL:a}));if(t.fetch&&await Ge(this,i,t.fetch),t.packages){await i.loadPackage("micropip");const e=await i.pyimport("micropip");await e.install(t.packages),e.destroy()}return i},registerJSModule:Ve,run:Ze,runAsync:et,runEvent:tt,transform:(e,t)=>t instanceof e.ffi.PyProxy?t.toJs(nt):t,writeFile:({FS:e,PATH:t,_module:{PATH_FS:r}},n,s)=>qe({FS:e,PATH:t,PATH_FS:r},n,s)};const ot="ruby-wasm-wasi",at=ot.replace(/\W+/g,"_");var it={type:ot,experimental:!0,module:(e="2.0.0")=>`https://cdn.jsdelivr.net/npm/ruby-3_2-wasm-wasi@${e}/dist/browser.esm.js`,async engine({DefaultRubyVM:e},t,r){const n=await fetch(`${r.slice(0,r.lastIndexOf("/"))}/ruby.wasm`),s=await WebAssembly.compile(await n.arrayBuffer()),{vm:o}=await e(s);return t.fetch&&await Ge(this,o,t.fetch),o},registerJSModule(e,t,r){const n=`__module_${at}_${t}`;globalThis[n]=r,this.run(e,`require "js";$${t}=JS.global[:${n}]`),delete globalThis[n]},run:(e,t,...r)=>e.eval(ke(t),...r),runAsync:(e,t,...r)=>e.evalAsync(ke(t),...r),async runEvent(e,t,r){if(/^xworker\.(on\w+)$/.test(t)){const{$1:t}=RegExp,n=`__module_${at}_event`;globalThis[n]=r,this.run(e,`require "js";$xworker.call("${t}",JS.global[:${n}])`),delete globalThis[n]}else{const n=this.run(e,`method(:${t})`);await n.call(t,e.wrap(r))}},transform:(e,t)=>t,writeFile:()=>{throw new Error(`writeFile is not supported in ${ot}`)}};var ct={type:"wasmoon",module:(e="1.15.0")=>`https://cdn.jsdelivr.net/npm/wasmoon@${e}/+esm`,async engine({LuaFactory:e,LuaLibraries:t},r){const{stderr:n,stdout:s,get:o}=Ue(),a=await o((new e).createEngine());return a.global.getTable(t.Base,(e=>{a.global.setField(e,"print",s),a.global.setField(e,"printErr",n)})),r.fetch&&await Ge(this,a,r.fetch),a},registerJSModule:(e,t,r)=>{e.global.set(t,r)},run:(e,t,...r)=>{try{return e.doStringSync(ke(t),...r)}catch(t){De.get(e).stderr(t)}},runAsync:async(e,t,...r)=>{try{return await e.doString(ke(t),...r)}catch(t){De.get(e).stderr(t)}},runEvent:async(e,t,r)=>{const[n,...s]=t.split(".");let o,a=e.global.get(n);for(const e of s)[o,a]=[a,a[e]];try{await a.call(o,r)}catch(t){De.get(e).stderr(t)}},transform:(e,t)=>t,writeFile:({cmodule:{module:{FS:e}}},t,r)=>((e,t,r)=>(Qe(e,ze(t)),t=Xe(e,t),e.writeFile(t,new Uint8Array(r),{canOwn:!0})))(e,t,r)};const lt=new Map,ut=new Map,ft=[],pt=[],dt=new Proxy(new Map,{get(e,t){if(!e.has(t)){const[r,...n]=t.split("@"),s=lt.get(r),o=/^https?:\/\//i.test(n)?n.join("@"):s.module(...n);e.set(t,{url:o,module:import(o),engine:s.engine.bind(s)})}const{url:r,module:n,engine:s}=e.get(t);return(e,o)=>n.then((n=>{ut.set(t,e);const a=e?.fetch;return a&&Ke.set(a,o),s(n,e,r)}))}}),ht=e=>{for(const t of[].concat(e.type))lt.set(t,e),ft.push(`script[type="${t}"]`),pt.push(`${t}-`)};for(const e of[rt,st,it,ct])ht(e);const gt=async e=>(await import("https://cdn.jsdelivr.net/npm/basic-toml@0.3.1/es.js")).parse(e),yt=(e,t,r={})=>{if(t)if(t.endsWith(".json"))r=fetch(t).then(Ie),t=Oe(t);else if(t.endsWith(".toml"))r=fetch(t).then(Le).then(gt),t=Oe(t);else if(!t.endsWith(".txt")){try{r=JSON.parse(t)}catch(e){r=gt(t)}t=Oe("./config.txt")}return _e(r).then((r=>dt[e](r,t)))},wt=(e,t="")=>`${e}@${t}`.replace(/@$/,""),mt=(e,t)=>{const r=(e=>{let t=e;for(;t.parentNode;)t=t.parentNode;return t})(e);return r.getElementById(t)||((e,t=document)=>t.querySelector(e))(t,r)},bt=new WeakMap,vt={get(){let e=bt.get(this);return e||(e=document.createElement(`${this.type}-script`),bt.set(this,e),$t(this)),e},set(e){"string"==typeof e?bt.set(this,mt(this,e)):(bt.set(this,e),$t(this))}},Et=new WeakMap,St=new Map,At=(e,t)=>{const r=e?.value;return r?t+r:""},kt=(e,t,r,n,s,o=e)=>{if(!St.has(t)){const a={interpreter:yt(r,s),queue:_e(),XWorker:Ne(e,n)};St.set(t,a),St.has(e)||St.set(e,a),St.has(o)||St.set(o,a)}return St.get(t)},$t=async e=>{if(Et.has(e)){const{target:t}=e;t&&(e.closest("head")?document.body.append(t):e.after(t))}else{const{attributes:{async:t,config:r,env:n,target:s,version:o},src:a,type:i}=e,c=o?.value,l=wt(i,c);let u=At(r,"|");const f=At(n,"")||`${l}${u}`;u=u.slice(1);const p=He(e);if(p){const r=new(Ne(i,c))(p,{...Fe(e,i),async:!!t,config:u});return void Et.set(je(e,"xworker",{value:r}),{xworker:r})}const d=At(s,""),h=kt(i,f,l,c,u);Et.set(je(e,"target",vt),h),d&&bt.set(e,mt(e,d));const g=a?fetch(a).then(Le):e.textContent;h.queue=h.queue.then((()=>(async(e,t,r,n)=>{const{type:s}=e,o=lt.get(s);o.experimental&&console.warn(`The ${s} interpreter is experimental`);const[a,i]=await Re([Et.get(e).interpreter,t]);try{return je(document,"currentScript",{configurable:!0,get:()=>e}),o.registerJSModule(a,"polyscript",{XWorker:r}),((e,t,r,n)=>{e.dispatchEvent(new n(`${t}:ready`,{bubbles:!0,detail:{worker:r}}))})(e,s,!1,CustomEvent),o[n?"runAsync":"run"](a,i)}finally{delete document.currentScript}})(e,g,h.XWorker,!!t)))}},Pt=new Proxy(Me(null),{get:(e,t)=>Mt(t)}),Mt=async e=>{if(St.has(e)){const{interpreter:t,queue:r}=St.get(e);return(await Re([t,r]))[0]}const t=St.size?`Available interpreters are: ${[...St.keys()].map((e=>`"${e}"`)).join(", ")}.`:"There are no interpreters in this page.";throw new Error(`The interpreter "${e}" was not found. ${t}`)},xt=async e=>{const{type:r,currentTarget:n}=e;for(let{name:s,value:o,ownerElement:a}of t(`./@*[${pt.map((e=>`name()="${e}${r}"`)).join(" or ")}]`,n)){s=s.slice(0,-(r.length+1));const t=await Mt(a.getAttribute(`${s}-env`)||s);lt.get(s).runEvent(t,o,e)}},jt=e=>{for(let{name:r,ownerElement:n}of t(`.//@*[${pt.map((e=>`starts-with(name(),"${e}")`)).join(" or ")}]`,e))r=r.slice(r.lastIndexOf("-")+1),"env"!==r&&n.addEventListener(r,xt)},Tt=[],Rt=new Map,_t=new Map,Ot=e=>{for(const t of Tt)if(e.matches(t)){const r=Rt.get(t),{resolve:n}=_t.get(r),{options:s,known:o}=Wt.get(r);if(!o.has(e)){o.add(e);const{interpreter:t,config:a,version:i,env:c,onInterpreterReady:l}=s,u=He(e);if(u){const o=Lt.call(new Ce(null,s),u,{...Fe(e,r),version:i,type:t,custom:r,config:a||{},async:e.hasAttribute("async")});return je(e,"xworker",{value:o}),void n({type:r,xworker:o})}const f=wt(t,i),p=c||`${f}${a?`|${a}`:""}`,{interpreter:d,XWorker:h}=kt(r,p,f,i,a,t);d.then((o=>{const a=Me(lt.get(t)),{onBeforeRun:i,onBeforeRunAsync:c,onAfterRun:u,onAfterRunAsync:p}=s,d=new Ce(o,s),g=function(...e){return h.apply(d,e)};for(const[t,[r,n]]of[["run",[i,u]]]){const s=a[t];a[t]=function(t,o,...a){r&&r.call(this,y,e);const i=s.call(this,t,o,...a);return n&&n.call(this,y,e),i}}for(const[t,[r,n]]of[["runAsync",[c,p]]]){const s=a[t];a[t]=async function(t,o,...a){r&&await r.call(this,y,e);const i=await s.call(this,t,o,...a);return n&&await n.call(this,y,e),i}}a.registerJSModule(o,"polyscript",{XWorker:g});const y={type:r,interpreter:o,XWorker:g,io:De.get(o),config:structuredClone(ut.get(f)),run:a.run.bind(a,o),runAsync:a.runAsync.bind(a,o),runEvent:a.runEvent.bind(a,o)};n(y),l?.(y,e)}))}}},Wt=new Map;let Ft=0;const Bt=(t,r)=>{let n=null==t;if(n)t="_ps"+Ft++;else if(lt.has(t)||Wt.has(t))throw new Error(`<script type="${t}"> already registered`);if(!lt.has(r?.interpreter))throw new Error("Unspecified interpreter");lt.set(t,lt.get(r.interpreter));const s=[`script[type="${t}"]`];if(It(t),n){const{onInterpreterReady:e}=r;r={...r,onInterpreterReady(r,n){Tt.splice(Tt.indexOf(t),1),lt.delete(t),Wt.delete(t),_t.delete(t),n.remove(),e?.(r)}},document.head.append(Pe(document.createElement("script"),{type:t}))}else s.push(`${t}-script`),pt.push(`${t}-`);for(const e of s)Rt.set(e,t);Tt.push(...s),Wt.set(t,{options:Pe({env:t},r),known:new WeakSet}),n||jt(document),e(s.join(",")).forEach(Ot)},It=e=>(_t.has(e)||_t.set(e,Promise.withResolvers()),_t.get(e).promise),Lt=Ne(),Jt=ft.join(","),Ct=new MutationObserver((t=>{for(const{type:r,target:n,attributeName:s,addedNodes:o}of t)if("attributes"!==r){for(const t of o)if(1===t.nodeType)if(jt(t),t.matches(Jt))$t(t);else{if(e(Jt,t).forEach($t),!Tt.length)continue;Ot(t),e(Tt.join(","),t).forEach(Ot)}}else{const e=s.lastIndexOf("-")+1;if(e){const t=s.slice(0,e);for(const r of pt)if(t===r){const t=s.slice(e);if("env"!==t){const e=n.hasAttribute(s)?"add":"remove";n[`${e}EventListener`](t,xt)}break}}}})),Nt=e=>(Ct.observe(e,{childList:!0,subtree:!0,attributes:!0}),e),{attachShadow:Ht}=Element.prototype;Pe(Element.prototype,{attachShadow(e){return Nt(Ht.call(this,e))}}),jt(Nt(document)),e(Jt,document).forEach($t);export{Lt as XWorker,Bt as define,Pt as env,It as whenDefined};
//# sourceMappingURL=core.js.map

@@ -20,4 +20,11 @@ import dedent from 'codedent';

/**
* Notify the main thread about element "readiness".
* @param {HTMLScriptElement | HTMLElement} target the script or custom-type element
* @param {string} type the custom/type as event prefix
* @param {boolean} worker `true` if dispatched form a worker, `false` if in main
* @param {globalThis.CustomEvent} CustomEvent the right global to use
*/
const dispatch = (target, type, worker, CustomEvent) => {
if (target) target.dispatchEvent(
target.dispatchEvent(
new CustomEvent(`${type}:ready`, {

@@ -24,0 +31,0 @@ bubbles: true,

/* c8 ignore next */
export default () => new Worker(URL.createObjectURL(new Blob(["const e=\"object\"==typeof self?self:globalThis,t=t=>((t,r)=>{const n=(e,r)=>(t.set(r,e),e),s=o=>{if(t.has(o))return t.get(o);const[a,i]=r[o];switch(a){case 0:case-1:return n(i,o);case 1:{const e=n([],o);for(const t of i)e.push(s(t));return e}case 2:{const e=n({},o);for(const[t,r]of i)e[s(t)]=s(r);return e}case 3:return n(new Date(i),o);case 4:{const{source:e,flags:t}=i;return n(new RegExp(e,t),o)}case 5:{const e=n(new Map,o);for(const[t,r]of i)e.set(s(t),s(r));return e}case 6:{const e=n(new Set,o);for(const t of i)e.add(s(t));return e}case 7:{const{name:t,message:r}=i;return n(new e[t](r),o)}case 8:return n(BigInt(i),o);case\"BigInt\":return n(Object(BigInt(i)),o)}return n(new e[a](i),o)};return s})(new Map,t)(0),r=\"\",{toString:n}={},{keys:s}=Object,o=e=>{const t=typeof e;if(\"object\"!==t||!e)return[0,t];const s=n.call(e).slice(8,-1);switch(s){case\"Array\":return[1,r];case\"Object\":return[2,r];case\"Date\":return[3,r];case\"RegExp\":return[4,r];case\"Map\":return[5,r];case\"Set\":return[6,r]}return s.includes(\"Array\")?[1,s]:s.includes(\"Error\")?[7,s]:[2,s]},a=([e,t])=>0===e&&(\"function\"===t||\"symbol\"===t),i=(e,{json:t,lossy:r}={})=>{const n=[];return((e,t,r,n)=>{const i=(e,t)=>{const s=n.push(e)-1;return r.set(t,s),s},c=n=>{if(r.has(n))return r.get(n);let[l,u]=o(n);switch(l){case 0:{let t=n;switch(u){case\"bigint\":l=8,t=n.toString();break;case\"function\":case\"symbol\":if(e)throw new TypeError(\"unable to serialize \"+u);t=null;break;case\"undefined\":return i([-1],n)}return i([l,t],n)}case 1:{if(u)return i([u,[...n]],n);const e=[],t=i([l,e],n);for(const t of n)e.push(c(t));return t}case 2:{if(u)switch(u){case\"BigInt\":return i([u,n.toString()],n);case\"Boolean\":case\"Number\":case\"String\":return i([u,n.valueOf()],n)}if(t&&\"toJSON\"in n)return c(n.toJSON());const r=[],f=i([l,r],n);for(const t of s(n))!e&&a(o(n[t]))||r.push([c(t),c(n[t])]);return f}case 3:return i([l,n.toISOString()],n);case 4:{const{source:e,flags:t}=n;return i([l,{source:e,flags:t}],n)}case 5:{const t=[],r=i([l,t],n);for(const[r,s]of n)(e||!a(o(r))&&!a(o(s)))&&t.push([c(r),c(s)]);return r}case 6:{const t=[],r=i([l,t],n);for(const r of n)!e&&a(o(r))||t.push(c(r));return r}}const{message:f}=n;return i([l,{name:u,message:f}],n)};return c})(!(t||r),!!t,new Map,n)(e),n},{parse:c,stringify:l}=JSON,u={json:!0,lossy:!0};var f=Object.freeze({__proto__:null,parse:e=>t(c(e)),stringify:e=>l(i(e,u))});const p=\"891249cd-eb53-4bc8-ae48-b0a5a277d24a\",d=\"M\"+p,g=\"T\"+p;var y=e=>({value:new Promise((t=>{let r=new Worker(\"data:application/javascript,onmessage%3D(%7Bdata%3Ab%7D)%3D%3E(Atomics.wait(b%2C0)%2CpostMessage(0))\");r.onmessage=t,r.postMessage(e)}))})\n/*! (c) Andrea Giammarchi - ISC */;const{Int32Array:h,Map:w,SharedArrayBuffer:m,Uint16Array:b}=globalThis,{BYTES_PER_ELEMENT:v}=h,{BYTES_PER_ELEMENT:S}=b,{isArray:E}=Array,{notify:P,wait:A,waitAsync:M}=Atomics,{fromCharCode:$}=String,j=(e,t)=>e?(M||y)(t,0):(A(t,0),{value:{then:e=>e()}}),k=new WeakSet,x=new WeakMap;let T=0;const _=(e,{parse:t,stringify:r,transform:n}=JSON)=>{if(!x.has(e)){const s=(t,...r)=>e.postMessage({[p]:r},{transfer:t});let o=!1;x.set(e,new Proxy(new w,{has:(e,t)=>\"string\"==typeof t&&!t.startsWith(\"_\"),get:(r,a)=>\"then\"===a?null:(...r)=>{const i=T++;let c=new h(new m(v)),l=[];k.has(r.at(-1)||l)&&k.delete(l=r.pop()),s(l,i,c,a,n?r.map(n):r);const u=e!==globalThis;let f=0;return o&&u&&(f=setTimeout(console.warn,1e3,`💀🔒 - Possible deadlock if proxy.${a}(...args) is awaited`)),j(u,c).value.then((()=>{clearTimeout(f);const e=c[0];if(!e)return;const r=S*e;return c=new h(new m(r+r%v)),s([],i,c),j(u,c).value.then((()=>t($(...new b(c.buffer).slice(0,e)))))}))},set(t,n,s){if(!t.size){const n=new w;e.addEventListener(\"message\",(async e=>{const s=e.data?.[p];if(E(s)){e.stopImmediatePropagation();const[a,i,...c]=s;if(c.length){const[e,s]=c;if(!t.has(e))throw new Error(`Unsupported action: ${e}`);o=!0;try{const o=await t.get(e)(...s);if(void 0!==o){const e=r(o);n.set(a,e),i[0]=e.length}}finally{o=!1}}else{const e=n.get(a);n.delete(a);for(let t=new b(i.buffer),r=0;r<e.length;r++)t[r]=e.charCodeAt(r)}P(i,0)}}))}return!!t.set(n,s)}}))}return x.get(e)};_.transfer=(...e)=>(k.add(e),e);const O=\"object\",F=\"function\",W=\"number\",R=\"string\",B=\"undefined\",J=\"symbol\",{defineProperty:I,getOwnPropertyDescriptor:L,getPrototypeOf:C,isExtensible:H,ownKeys:D,preventExtensions:N,set:U,setPrototypeOf:z}=Reflect,{assign:q,create:K}=Object,Y=C(Int8Array),G=\"isArray\",V=(e,t)=>{const{get:r,set:n,value:s}=e;return r&&(e.get=t(r)),n&&(e.set=t(n)),s&&(e.value=t(s)),e},Q=(e,t)=>[e,t],X=e=>t=>{const r=typeof t;switch(r){case O:if(null==t)return Q(\"null\",t);if(t===globalThis)return Q(O,null);case F:return e(r,t);case\"boolean\":case W:case R:case B:case\"bigint\":return Q(r,t);case J:if(Z.has(t))return Q(r,Z.get(t))}throw new Error(`Unable to handle this ${r} type`)},Z=new Map(D(Symbol).filter((e=>typeof Symbol[e]===J)).map((e=>[Symbol[e],e]))),ee=e=>{for(const[t,r]of Z)if(r===e)return t};function te(){return this}const re=\"apply\",ne=\"construct\",se=\"defineProperty\",oe=\"deleteProperty\",ae=\"get\",ie=\"getOwnPropertyDescriptor\",ce=\"getPrototypeOf\",le=\"has\",ue=\"isExtensible\",fe=\"ownKeys\",pe=\"preventExtensions\",de=\"set\",ge=\"setPrototypeOf\",ye=\"delete\";var he=((e,t)=>{const r=t&&new WeakMap;if(t){const{addEventListener:e}=EventTarget.prototype;I(EventTarget.prototype,\"addEventListener\",{value(t,n,...s){return s.at(0)?.invoke&&(r.has(this)||r.set(this,new Map),r.get(this).set(t,[].concat(s[0].invoke)),delete s[0].invoke),e.call(this,t,n,...s)}})}const n=t&&(e=>{const{currentTarget:t,target:n,type:s}=e;for(const o of r.get(t||n)?.get(s)||[])e[o]()});return(r,s,o,...a)=>{let i=0;const c=new Map,l=new Map,{[o]:u}=r,f=a.length?q(K(globalThis),...a):globalThis,p=X(((e,t)=>{if(!c.has(t)){let e;for(;l.has(e=i++););c.set(t,e),l.set(e,t)}return Q(e,c.get(t))})),d=new FinalizationRegistry((e=>{u(ye,Q(R,e))})),g=([e,r])=>{switch(e){case O:if(null==r)return f;if(typeof r===W)return l.get(r);if(!(r instanceof Y))for(const e in r)r[e]=g(r[e]);return r;case F:if(typeof r===R){if(!l.has(r)){const e=function(...e){return t&&e.at(0)instanceof Event&&n(...e),u(re,Q(F,r),p(this),e.map(p))},s=new WeakRef(e);l.set(r,s),d.register(e,r,s)}return l.get(r).deref()}return l.get(r);case J:return ee(r)}return r},y={[re]:(e,t,r)=>p(e.apply(t,r)),[ne]:(e,t)=>p(new e(...t)),[se]:(e,t,r)=>p(I(e,t,r)),[oe]:(e,t)=>p(delete e[t]),[ce]:e=>p(C(e)),[ae]:(e,t)=>p(e[t]),[ie]:(e,t)=>{const r=L(e,t);return r?Q(O,V(r,p)):Q(B,r)},[le]:(e,t)=>p(t in e),[ue]:e=>p(H(e)),[fe]:e=>Q(O,D(e).map(p)),[pe]:e=>p(N(e)),[de]:(e,t,r)=>p(U(e,t,r)),[ge]:(e,t)=>p(z(e,t)),[ye](e){c.delete(l.get(e)),l.delete(e)}};return r[s]=(e,t,...r)=>{switch(e){case re:r[0]=g(r[0]),r[1]=r[1].map(g);break;case ne:r[0]=r[0].map(g);break;case se:{const[e,t]=r;r[0]=g(e);const{get:n,set:s,value:o}=t;n&&(t.get=g(n)),s&&(t.set=g(s)),o&&(t.value=g(o));break}default:r=r.map(g)}return y[e](g(t),...r)},{proxy:r,[e.toLowerCase()]:f,[`is${e}Proxy`]:()=>!1}}})(\"Window\",!0),we=(e=>{let t=0;const r=new Map,n=new Map,s=Symbol(),o=e=>typeof e===F?e():e,a=e=>typeof e===O&&!!e&&s in e,i=Array[G],c=X(((e,a)=>{if(s in a)return o(a[s]);if(e===F){if(!n.has(a)){let e;for(;n.has(e=String(t++)););r.set(a,e),n.set(e,a)}return Q(e,r.get(a))}if(!(a instanceof Y))for(const e in a)a[e]=c(a[e]);return Q(e,a)}));return(t,l,u)=>{const{[l]:f}=t,p=new Map,d=new FinalizationRegistry((e=>{p.delete(e),f(ye,c(e))})),g=e=>{const[t,r]=e;if(!p.has(r)){const n=t===F?te.bind(e):e,s=new Proxy(n,w),o=new WeakRef(s);p.set(r,o),d.register(s,r,o)}return p.get(r).deref()},y=e=>{const[t,r]=e;switch(t){case O:return null===r?globalThis:typeof r===W?g(e):r;case F:return typeof r===R?n.get(r):g(e);case J:return ee(r)}return r},h=(e,t,...r)=>y(f(e,o(t),...r)),w={[re]:(e,t,r)=>h(re,e,c(t),r.map(c)),[ne]:(e,t)=>h(ne,e,t.map(c)),[se]:(e,t,r)=>{const{get:n,set:s,value:o}=r;return typeof n===F&&(r.get=c(n)),typeof s===F&&(r.set=c(s)),typeof o===F&&(r.value=c(o)),h(se,e,c(t),r)},[oe]:(e,t)=>h(oe,e,c(t)),[ce]:e=>h(ce,e),[ae]:(e,t)=>t===s?e:h(ae,e,c(t)),[ie]:(e,t)=>{const r=h(ie,e,c(t));return r&&V(r,y)},[le]:(e,t)=>t===s||h(le,e,c(t)),[ue]:e=>h(ue,e),[fe]:e=>h(fe,e).map(y),[pe]:e=>h(pe,e),[de]:(e,t,r)=>h(de,e,c(t),c(r)),[ge]:(e,t)=>h(ge,e,c(t))};t[u]=(e,t,s,o)=>{switch(e){case re:return y(t).apply(y(s),o.map(y));case ye:{const e=y(t);r.delete(n.get(e)),n.delete(e)}}};const m=new Proxy([O,null],w),b=m.Array[G];return I(Array,G,{value:e=>a(e)?b(e):i(e)}),{[e.toLowerCase()]:m,[`is${e}Proxy`]:a,proxy:t}}})(\"Window\"),me=\"function\"==typeof Worker?Worker:class{};const be=new WeakMap,ve=(e,...t)=>{const r=_(e,...t);if(!be.has(r)){const t=e instanceof me?he:we;be.set(r,t(r,d,g))}return be.get(r)};ve.transfer=_.transfer;const Se={object(...e){return this.string(function(e){for(var t=e[0],r=1,n=arguments.length;r<n;r++)t+=arguments[r]+e[r];return t}(...e))},string(e){for(const t of e.split(/[\\r\\n]+/))if(t.trim().length){/^(\\s+)/.test(t)&&(e=e.replace(new RegExp(\"^\"+RegExp.$1,\"gm\"),\"\"));break}return e}},Ee=(e,...t)=>Se[typeof e](e,...t),{isArray:Pe}=Array,{assign:Ae,create:Me,defineProperties:$e,defineProperty:je,entries:ke}=Object,{all:xe,resolve:Te}=new Proxy(Promise,{get:(e,t)=>e[t].bind(e)}),_e=(e,t=location.href)=>new URL(e,t).href;Promise.withResolvers||(Promise.withResolvers=function(){var e,t,r=new this((function(r,n){e=r,t=n}));return{resolve:e,reject:t,promise:r}});const Oe=e=>e.arrayBuffer(),Fe=e=>e.json(),We=e=>e.text(),Re=new WeakMap,Be=e=>{const t=e||console,r={stderr:(t.stderr||console.error).bind(t),stdout:(t.stdout||console.log).bind(t)};return{stderr:(...e)=>r.stderr(...e),stdout:(...e)=>r.stdout(...e),async get(e){const t=await e;return Re.set(t,r),t}}},Je=({FS:e,PATH:t,PATH_FS:r},n,s)=>{const o=r.resolve(n);return e.mkdirTree(t.dirname(o)),e.writeFile(o,new Uint8Array(s),{canOwn:!0})},Ie=e=>{const t=e.split(\"/\");return t.pop(),t.join(\"/\")},Le=(e,t)=>{const r=[];for(const n of t.split(\"/\"))\".\"!==n&&(r.push(n),n&&e.mkdir(r.join(\"/\")))},Ce=(e,t)=>{const r=[];for(const e of t.split(\"/\"))switch(e){case\"\":case\".\":break;case\"..\":r.pop();break;default:r.push(e)}return[e.cwd()].concat(r).join(\"/\").replace(/^\\/+/,\"/\")},He=e=>{const t=e.map((e=>e.trim().replace(/(^[/]*|[/]*$)/g,\"\"))).filter((e=>\"\"!==e&&\".\"!==e)).join(\"/\");return e[0].startsWith(\"/\")?`/${t}`:t},De=new WeakMap,Ne=(e,t,r)=>xe((e=>{for(const{files:t,to_file:r,from:n=\"\"}of e){if(void 0!==t&&void 0!==r)throw new Error(\"Cannot use 'to_file' and 'files' parameters together!\");if(void 0===t&&void 0===r&&n.endsWith(\"/\"))throw new Error(`Couldn't determine the filename from the path ${n}, please supply 'to_file' parameter.`)}return e.flatMap((({from:e=\"\",to_folder:t=\".\",to_file:r,files:n})=>{if(Pe(n))return n.map((r=>({url:He([e,r]),path:He([t,r])})));const s=r||e.slice(1+e.lastIndexOf(\"/\"));return[{url:e,path:He([t,s])}]}))})(r).map((({url:n,path:s})=>((e,t)=>fetch(_e(t,De.get(e))))(r,n).then(Oe).then((r=>e.writeFile(t,s,r)))))),Ue=(e,t,r)=>{e.registerJsModule(t,r)},ze=(e,t,...r)=>{try{return e.runPython(Ee(t),...r)}catch(t){Re.get(e).stderr(t)}},qe=async(e,t,...r)=>{try{return await e.runPythonAsync(Ee(t),...r)}catch(t){Re.get(e).stderr(t)}},Ke=async(e,t,r)=>{const[n,...s]=t.split(\".\");let o,a=e.globals.get(n);for(const e of s)[o,a]=[a,a[e]];try{await a.call(o,r)}catch(t){Re.get(e).stderr(t)}};var Ye={type:\"micropython\",module:(e=\"1.20.0-297\")=>`https://cdn.jsdelivr.net/npm/@micropython/micropython-webassembly-pyscript@${e}/micropython.mjs`,async engine({loadMicroPython:e},t,r){const{stderr:n,stdout:s,get:o}=Be();r=r.replace(/\\.m?js$/,\".wasm\");const a=await o(e({stderr:n,stdout:s,url:r}));return t.fetch&&await Ne(this,a,t.fetch),a},registerJSModule:Ue,run:ze,runAsync:qe,runEvent:Ke,transform:(e,t)=>t,writeFile:({FS:e,_module:{PATH:t,PATH_FS:r}},n,s)=>Je({FS:e,PATH:t,PATH_FS:r},n,s)};const Ge={dict_converter:Object.fromEntries};var Ve={type:\"pyodide\",module:(e=\"0.23.4\")=>`https://cdn.jsdelivr.net/pyodide/v${e}/full/pyodide.mjs`,async engine({loadPyodide:e},t,r){const{stderr:n,stdout:s,get:o}=Be(),a=r.slice(0,r.lastIndexOf(\"/\")),i=await o(e({stderr:n,stdout:s,indexURL:a}));if(t.fetch&&await Ne(this,i,t.fetch),t.packages){await i.loadPackage(\"micropip\");const e=await i.pyimport(\"micropip\");await e.install(t.packages),e.destroy()}return i},registerJSModule:Ue,run:ze,runAsync:qe,runEvent:Ke,transform:(e,t)=>t instanceof e.ffi.PyProxy?t.toJs(Ge):t,writeFile:({FS:e,PATH:t,_module:{PATH_FS:r}},n,s)=>Je({FS:e,PATH:t,PATH_FS:r},n,s)};const Qe=\"ruby-wasm-wasi\",Xe=Qe.replace(/\\W+/g,\"_\");var Ze={type:Qe,experimental:!0,module:(e=\"2.0.0\")=>`https://cdn.jsdelivr.net/npm/ruby-3_2-wasm-wasi@${e}/dist/browser.esm.js`,async engine({DefaultRubyVM:e},t,r){const n=await fetch(`${r.slice(0,r.lastIndexOf(\"/\"))}/ruby.wasm`),s=await WebAssembly.compile(await n.arrayBuffer()),{vm:o}=await e(s);return t.fetch&&await Ne(this,o,t.fetch),o},registerJSModule(e,t,r){const n=`__module_${Xe}_${t}`;globalThis[n]=r,this.run(e,`require \"js\";$${t}=JS.global[:${n}]`),delete globalThis[n]},run:(e,t,...r)=>e.eval(Ee(t),...r),runAsync:(e,t,...r)=>e.evalAsync(Ee(t),...r),async runEvent(e,t,r){if(/^xworker\\.(on\\w+)$/.test(t)){const{$1:t}=RegExp,n=`__module_${Xe}_event`;globalThis[n]=r,this.run(e,`require \"js\";$xworker.call(\"${t}\",JS.global[:${n}])`),delete globalThis[n]}else{const n=this.run(e,`method(:${t})`);await n.call(t,e.wrap(r))}},transform:(e,t)=>t,writeFile:()=>{throw new Error(`writeFile is not supported in ${Qe}`)}};var et={type:\"wasmoon\",module:(e=\"1.15.0\")=>`https://cdn.jsdelivr.net/npm/wasmoon@${e}/+esm`,async engine({LuaFactory:e,LuaLibraries:t},r){const{stderr:n,stdout:s,get:o}=Be(),a=await o((new e).createEngine());return a.global.getTable(t.Base,(e=>{a.global.setField(e,\"print\",s),a.global.setField(e,\"printErr\",n)})),r.fetch&&await Ne(this,a,r.fetch),a},registerJSModule:(e,t,r)=>{e.global.set(t,r)},run:(e,t,...r)=>{try{return e.doStringSync(Ee(t),...r)}catch(t){Re.get(e).stderr(t)}},runAsync:async(e,t,...r)=>{try{return await e.doString(Ee(t),...r)}catch(t){Re.get(e).stderr(t)}},runEvent:async(e,t,r)=>{const[n,...s]=t.split(\".\");let o,a=e.global.get(n);for(const e of s)[o,a]=[a,a[e]];try{await a.call(o,r)}catch(t){Re.get(e).stderr(t)}},transform:(e,t)=>t,writeFile:({cmodule:{module:{FS:e}}},t,r)=>((e,t,r)=>(Le(e,Ie(t)),t=Ce(e,t),e.writeFile(t,new Uint8Array(r),{canOwn:!0})))(e,t,r)};const tt=new Map,rt=new Map,nt=new Proxy(new Map,{get(e,t){if(!e.has(t)){const[r,...n]=t.split(\"@\"),s=tt.get(r),o=/^https?:\\/\\//i.test(n)?n.join(\"@\"):s.module(...n);e.set(t,{url:o,module:import(o),engine:s.engine.bind(s)})}const{url:r,module:n,engine:s}=e.get(t);return(e,o)=>n.then((n=>{rt.set(t,e);const a=e?.fetch;return a&&De.set(a,o),s(n,e,r)}))}}),st=e=>{for(const t of[].concat(e.type))tt.set(t,e)};for(const e of[Ye,Ve,Ze,et])st(e);const ot=async e=>(await import(\"https://cdn.jsdelivr.net/npm/basic-toml@0.3.1/es.js\")).parse(e);try{new SharedArrayBuffer(4)}catch(e){throw new Error([\"Unable to use SharedArrayBuffer due insecure environment.\",\"Please read requirements in MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer#security_requirements\"].join(\"\\n\"))}let at,it,ct;const lt=(e,t)=>{addEventListener(e,t||(async t=>{try{await at,it(`xworker.on${e}`,t)}catch(e){postMessage(e)}}),!!t&&{once:!0})},{parse:ut,stringify:ft}=f,{proxy:pt,window:dt,isWindowProxy:gt}=ve(self,{parse:ut,stringify:ft,transform:e=>ct?ct(e):e}),yt={sync:pt,window:dt,isWindowProxy:gt,onmessage:console.info,onerror:console.error,onmessageerror:console.warn,postMessage:postMessage.bind(self)};lt(\"message\",(({data:{options:e,config:t,code:r,hooks:n}})=>{at=(async()=>{try{const{id:s,tag:o,type:a,custom:i,version:c,config:l,async:u}=e,f=await((e,t,r={})=>{if(t)if(t.endsWith(\".json\"))r=fetch(t).then(Fe),t=_e(t);else if(t.endsWith(\".toml\"))r=fetch(t).then(We).then(ot),t=_e(t);else if(!t.endsWith(\".txt\")){try{r=JSON.parse(t)}catch(e){r=ot(t)}t=_e(\"./config.txt\")}return Te(r).then((r=>nt[e](r,t)))})(((e,t=\"\")=>`${e}@${t}`.replace(/@$/,\"\"))(a,c),t,l),p=Me(tt.get(a)),d=\"run\"+(u?\"Async\":\"\");if(n){const{beforeRun:e,beforeRunAsync:t,afterRun:r,afterRunAsync:s}=n,o=r||s,a=e||t;if(o){const e=p[d].bind(p);p[d]=(t,r,...n)=>e(t,`${r}\\n${o}`,...n)}if(a){const e=p[d].bind(p);p[d]=(t,r,...n)=>e(t,`${a}\\n${r}`,...n)}}const{CustomEvent:g,document:y}=dt,h=y.getElementById(s);let w=\"\";return p.registerJSModule(f,\"polyscript\",{xworker:yt,get target(){return w||(\"SCRIPT\"===o?h.after(Ae(y.createElement(`script-${i||a}`),{id:w=`${s}-target`})):(w=s,h.replaceChildren(),h.style.display=\"block\")),w}}),it=p.runEvent.bind(p,f),ct=p.transform.bind(p,f),((e,t,r,n)=>{e&&e.dispatchEvent(new n(`${t}:ready`,{bubbles:!0,detail:{worker:r}}))})(h,i||a,!0,g),await p[d](f,r),f}catch(e){postMessage(e)}})(),lt(\"error\"),lt(\"message\"),lt(\"messageerror\")}));\n"],{type:'application/javascript'})),{type:'module'});
export default () => new Worker(URL.createObjectURL(new Blob(["const e=\"object\"==typeof self?self:globalThis,t=t=>((t,r)=>{const n=(e,r)=>(t.set(r,e),e),s=o=>{if(t.has(o))return t.get(o);const[a,i]=r[o];switch(a){case 0:case-1:return n(i,o);case 1:{const e=n([],o);for(const t of i)e.push(s(t));return e}case 2:{const e=n({},o);for(const[t,r]of i)e[s(t)]=s(r);return e}case 3:return n(new Date(i),o);case 4:{const{source:e,flags:t}=i;return n(new RegExp(e,t),o)}case 5:{const e=n(new Map,o);for(const[t,r]of i)e.set(s(t),s(r));return e}case 6:{const e=n(new Set,o);for(const t of i)e.add(s(t));return e}case 7:{const{name:t,message:r}=i;return n(new e[t](r),o)}case 8:return n(BigInt(i),o);case\"BigInt\":return n(Object(BigInt(i)),o)}return n(new e[a](i),o)};return s})(new Map,t)(0),r=\"\",{toString:n}={},{keys:s}=Object,o=e=>{const t=typeof e;if(\"object\"!==t||!e)return[0,t];const s=n.call(e).slice(8,-1);switch(s){case\"Array\":return[1,r];case\"Object\":return[2,r];case\"Date\":return[3,r];case\"RegExp\":return[4,r];case\"Map\":return[5,r];case\"Set\":return[6,r]}return s.includes(\"Array\")?[1,s]:s.includes(\"Error\")?[7,s]:[2,s]},a=([e,t])=>0===e&&(\"function\"===t||\"symbol\"===t),i=(e,{json:t,lossy:r}={})=>{const n=[];return((e,t,r,n)=>{const i=(e,t)=>{const s=n.push(e)-1;return r.set(t,s),s},c=n=>{if(r.has(n))return r.get(n);let[l,u]=o(n);switch(l){case 0:{let t=n;switch(u){case\"bigint\":l=8,t=n.toString();break;case\"function\":case\"symbol\":if(e)throw new TypeError(\"unable to serialize \"+u);t=null;break;case\"undefined\":return i([-1],n)}return i([l,t],n)}case 1:{if(u)return i([u,[...n]],n);const e=[],t=i([l,e],n);for(const t of n)e.push(c(t));return t}case 2:{if(u)switch(u){case\"BigInt\":return i([u,n.toString()],n);case\"Boolean\":case\"Number\":case\"String\":return i([u,n.valueOf()],n)}if(t&&\"toJSON\"in n)return c(n.toJSON());const r=[],f=i([l,r],n);for(const t of s(n))!e&&a(o(n[t]))||r.push([c(t),c(n[t])]);return f}case 3:return i([l,n.toISOString()],n);case 4:{const{source:e,flags:t}=n;return i([l,{source:e,flags:t}],n)}case 5:{const t=[],r=i([l,t],n);for(const[r,s]of n)(e||!a(o(r))&&!a(o(s)))&&t.push([c(r),c(s)]);return r}case 6:{const t=[],r=i([l,t],n);for(const r of n)!e&&a(o(r))||t.push(c(r));return r}}const{message:f}=n;return i([l,{name:u,message:f}],n)};return c})(!(t||r),!!t,new Map,n)(e),n},{parse:c,stringify:l}=JSON,u={json:!0,lossy:!0};var f=Object.freeze({__proto__:null,parse:e=>t(c(e)),stringify:e=>l(i(e,u))});const p=\"3099687a-04a9-4406-a08e-fd1602cb2a81\",d=\"M\"+p,g=\"T\"+p;var y=e=>({value:new Promise((t=>{let r=new Worker(\"data:application/javascript,onmessage%3D(%7Bdata%3Ab%7D)%3D%3E(Atomics.wait(b%2C0)%2CpostMessage(0))\");r.onmessage=t,r.postMessage(e)}))})\n/*! (c) Andrea Giammarchi - ISC */;const{Int32Array:h,Map:w,SharedArrayBuffer:m,Uint16Array:b}=globalThis,{BYTES_PER_ELEMENT:v}=h,{BYTES_PER_ELEMENT:S}=b,{isArray:E}=Array,{notify:P,wait:A,waitAsync:M}=Atomics,{fromCharCode:$}=String,j=(e,t)=>e?(M||y)(t,0):(A(t,0),{value:{then:e=>e()}}),k=new WeakSet,x=new WeakMap;let T=0;const _=(e,{parse:t,stringify:r,transform:n}=JSON)=>{if(!x.has(e)){const s=(t,...r)=>e.postMessage({[p]:r},{transfer:t});let o=!1;x.set(e,new Proxy(new w,{has:(e,t)=>\"string\"==typeof t&&!t.startsWith(\"_\"),get:(r,a)=>\"then\"===a?null:(...r)=>{const i=T++;let c=new h(new m(v)),l=[];k.has(r.at(-1)||l)&&k.delete(l=r.pop()),s(l,i,c,a,n?r.map(n):r);const u=e!==globalThis;let f=0;return o&&u&&(f=setTimeout(console.warn,1e3,`💀🔒 - Possible deadlock if proxy.${a}(...args) is awaited`)),j(u,c).value.then((()=>{clearTimeout(f);const e=c[0];if(!e)return;const r=S*e;return c=new h(new m(r+r%v)),s([],i,c),j(u,c).value.then((()=>t($(...new b(c.buffer).slice(0,e)))))}))},set(t,s,a){if(!t.size){const s=new w;e.addEventListener(\"message\",(async e=>{const a=e.data?.[p];if(E(a)){e.stopImmediatePropagation();const[i,c,...l]=a;if(l.length){const[e,a]=l;if(!t.has(e))throw new Error(`Unsupported action: ${e}`);o=!0;try{const o=await t.get(e)(...a);if(void 0!==o){const e=r(n?n(o):o);s.set(i,e),c[0]=e.length}}finally{o=!1}}else{const e=s.get(i);s.delete(i);for(let t=new b(c.buffer),r=0;r<e.length;r++)t[r]=e.charCodeAt(r)}P(c,0)}}))}return!!t.set(s,a)}}))}return x.get(e)};_.transfer=(...e)=>(k.add(e),e);const O=\"object\",F=\"function\",W=\"number\",R=\"string\",B=\"undefined\",J=\"symbol\",{defineProperty:I,getOwnPropertyDescriptor:L,getPrototypeOf:C,isExtensible:H,ownKeys:D,preventExtensions:N,set:U,setPrototypeOf:z}=Reflect,{assign:q,create:K}=Object,Y=C(Int8Array),G=\"isArray\",V=(e,t)=>{const{get:r,set:n,value:s}=e;return r&&(e.get=t(r)),n&&(e.set=t(n)),s&&(e.value=t(s)),e},Q=(e,t)=>[e,t],X=e=>t=>{const r=typeof t;switch(r){case O:if(null==t)return Q(\"null\",t);if(t===globalThis)return Q(O,null);case F:return e(r,t);case\"boolean\":case W:case R:case B:case\"bigint\":return Q(r,t);case J:if(Z.has(t))return Q(r,Z.get(t))}throw new Error(`Unable to handle this ${r} type`)},Z=new Map(D(Symbol).filter((e=>typeof Symbol[e]===J)).map((e=>[Symbol[e],e]))),ee=e=>{for(const[t,r]of Z)if(r===e)return t};function te(){return this}const re=\"apply\",ne=\"construct\",se=\"defineProperty\",oe=\"deleteProperty\",ae=\"get\",ie=\"getOwnPropertyDescriptor\",ce=\"getPrototypeOf\",le=\"has\",ue=\"isExtensible\",fe=\"ownKeys\",pe=\"preventExtensions\",de=\"set\",ge=\"setPrototypeOf\",ye=\"delete\";var he=((e,t)=>{const r=t&&new WeakMap;if(t){const{addEventListener:e}=EventTarget.prototype;I(EventTarget.prototype,\"addEventListener\",{value(t,n,...s){return s.at(0)?.invoke&&(r.has(this)||r.set(this,new Map),r.get(this).set(t,[].concat(s[0].invoke)),delete s[0].invoke),e.call(this,t,n,...s)}})}const n=t&&(e=>{const{currentTarget:t,target:n,type:s}=e;for(const o of r.get(t||n)?.get(s)||[])e[o]()});return(r,s,o,...a)=>{let i=0;const c=new Map,l=new Map,{[o]:u}=r,f=a.length?q(K(globalThis),...a):globalThis,p=X(((e,t)=>{if(!c.has(t)){let e;for(;l.has(e=i++););c.set(t,e),l.set(e,t)}return Q(e,c.get(t))})),d=new FinalizationRegistry((e=>{u(ye,Q(R,e))})),g=([e,r])=>{switch(e){case O:if(null==r)return f;if(typeof r===W)return l.get(r);if(!(r instanceof Y))for(const e in r)r[e]=g(r[e]);return r;case F:if(typeof r===R){if(!l.has(r)){const e=function(...e){return t&&e.at(0)instanceof Event&&n(...e),u(re,Q(F,r),p(this),e.map(p))},s=new WeakRef(e);l.set(r,s),d.register(e,r,s)}return l.get(r).deref()}return l.get(r);case J:return ee(r)}return r},y={[re]:(e,t,r)=>p(e.apply(t,r)),[ne]:(e,t)=>p(new e(...t)),[se]:(e,t,r)=>p(I(e,t,r)),[oe]:(e,t)=>p(delete e[t]),[ce]:e=>p(C(e)),[ae]:(e,t)=>p(e[t]),[ie]:(e,t)=>{const r=L(e,t);return r?Q(O,V(r,p)):Q(B,r)},[le]:(e,t)=>p(t in e),[ue]:e=>p(H(e)),[fe]:e=>Q(O,D(e).map(p)),[pe]:e=>p(N(e)),[de]:(e,t,r)=>p(U(e,t,r)),[ge]:(e,t)=>p(z(e,t)),[ye](e){c.delete(l.get(e)),l.delete(e)}};return r[s]=(e,t,...r)=>{switch(e){case re:r[0]=g(r[0]),r[1]=r[1].map(g);break;case ne:r[0]=r[0].map(g);break;case se:{const[e,t]=r;r[0]=g(e);const{get:n,set:s,value:o}=t;n&&(t.get=g(n)),s&&(t.set=g(s)),o&&(t.value=g(o));break}default:r=r.map(g)}return y[e](g(t),...r)},{proxy:r,[e.toLowerCase()]:f,[`is${e}Proxy`]:()=>!1}}})(\"Window\",!0),we=(e=>{let t=0;const r=new Map,n=new Map,s=Symbol(),o=e=>typeof e===F?e():e,a=e=>typeof e===O&&!!e&&s in e,i=Array[G],c=X(((e,a)=>{if(s in a)return o(a[s]);if(e===F){if(!n.has(a)){let e;for(;n.has(e=String(t++)););r.set(a,e),n.set(e,a)}return Q(e,r.get(a))}if(!(a instanceof Y))for(const e in a)a[e]=c(a[e]);return Q(e,a)}));return(t,l,u)=>{const{[l]:f}=t,p=new Map,d=new FinalizationRegistry((e=>{p.delete(e),f(ye,c(e))})),g=e=>{const[t,r]=e;if(!p.has(r)){const n=t===F?te.bind(e):e,s=new Proxy(n,w),o=new WeakRef(s);p.set(r,o),d.register(s,r,o)}return p.get(r).deref()},y=e=>{const[t,r]=e;switch(t){case O:return null===r?globalThis:typeof r===W?g(e):r;case F:return typeof r===R?n.get(r):g(e);case J:return ee(r)}return r},h=(e,t,...r)=>y(f(e,o(t),...r)),w={[re]:(e,t,r)=>h(re,e,c(t),r.map(c)),[ne]:(e,t)=>h(ne,e,t.map(c)),[se]:(e,t,r)=>{const{get:n,set:s,value:o}=r;return typeof n===F&&(r.get=c(n)),typeof s===F&&(r.set=c(s)),typeof o===F&&(r.value=c(o)),h(se,e,c(t),r)},[oe]:(e,t)=>h(oe,e,c(t)),[ce]:e=>h(ce,e),[ae]:(e,t)=>t===s?e:h(ae,e,c(t)),[ie]:(e,t)=>{const r=h(ie,e,c(t));return r&&V(r,y)},[le]:(e,t)=>t===s||h(le,e,c(t)),[ue]:e=>h(ue,e),[fe]:e=>h(fe,e).map(y),[pe]:e=>h(pe,e),[de]:(e,t,r)=>h(de,e,c(t),c(r)),[ge]:(e,t)=>h(ge,e,c(t))};t[u]=(e,t,s,o)=>{switch(e){case re:return y(t).apply(y(s),o.map(y));case ye:{const e=y(t);r.delete(n.get(e)),n.delete(e)}}};const m=new Proxy([O,null],w),b=m.Array[G];return I(Array,G,{value:e=>a(e)?b(e):i(e)}),{[e.toLowerCase()]:m,[`is${e}Proxy`]:a,proxy:t}}})(\"Window\"),me=\"function\"==typeof Worker?Worker:class{};const be=new WeakMap,ve=(e,...t)=>{const r=_(e,...t);if(!be.has(r)){const t=e instanceof me?he:we;be.set(r,t(r,d,g))}return be.get(r)};ve.transfer=_.transfer;const Se={object(...e){return this.string(function(e){for(var t=e[0],r=1,n=arguments.length;r<n;r++)t+=arguments[r]+e[r];return t}(...e))},string(e){for(const t of e.split(/[\\r\\n]+/))if(t.trim().length){/^(\\s+)/.test(t)&&(e=e.replace(new RegExp(\"^\"+RegExp.$1,\"gm\"),\"\"));break}return e}},Ee=(e,...t)=>Se[typeof e](e,...t),{isArray:Pe}=Array,{assign:Ae,create:Me,defineProperties:$e,defineProperty:je,entries:ke}=Object,{all:xe,resolve:Te}=new Proxy(Promise,{get:(e,t)=>e[t].bind(e)}),_e=(e,t=location.href)=>new URL(e,t).href;Promise.withResolvers||(Promise.withResolvers=function(){var e,t,r=new this((function(r,n){e=r,t=n}));return{resolve:e,reject:t,promise:r}});const Oe=e=>e.arrayBuffer(),Fe=e=>e.json(),We=e=>e.text(),Re=new WeakMap,Be=e=>{const t=e||console,r={stderr:(t.stderr||console.error).bind(t),stdout:(t.stdout||console.log).bind(t)};return{stderr:(...e)=>r.stderr(...e),stdout:(...e)=>r.stdout(...e),async get(e){const t=await e;return Re.set(t,r),t}}},Je=({FS:e,PATH:t,PATH_FS:r},n,s)=>{const o=r.resolve(n);return e.mkdirTree(t.dirname(o)),e.writeFile(o,new Uint8Array(s),{canOwn:!0})},Ie=e=>{const t=e.split(\"/\");return t.pop(),t.join(\"/\")},Le=(e,t)=>{const r=[];for(const n of t.split(\"/\"))\".\"!==n&&(r.push(n),n&&e.mkdir(r.join(\"/\")))},Ce=(e,t)=>{const r=[];for(const e of t.split(\"/\"))switch(e){case\"\":case\".\":break;case\"..\":r.pop();break;default:r.push(e)}return[e.cwd()].concat(r).join(\"/\").replace(/^\\/+/,\"/\")},He=e=>{const t=e.map((e=>e.trim().replace(/(^[/]*|[/]*$)/g,\"\"))).filter((e=>\"\"!==e&&\".\"!==e)).join(\"/\");return e[0].startsWith(\"/\")?`/${t}`:t},De=new WeakMap,Ne=(e,t,r)=>xe((e=>{for(const{files:t,to_file:r,from:n=\"\"}of e){if(void 0!==t&&void 0!==r)throw new Error(\"Cannot use 'to_file' and 'files' parameters together!\");if(void 0===t&&void 0===r&&n.endsWith(\"/\"))throw new Error(`Couldn't determine the filename from the path ${n}, please supply 'to_file' parameter.`)}return e.flatMap((({from:e=\"\",to_folder:t=\".\",to_file:r,files:n})=>{if(Pe(n))return n.map((r=>({url:He([e,r]),path:He([t,r])})));const s=r||e.slice(1+e.lastIndexOf(\"/\"));return[{url:e,path:He([t,s])}]}))})(r).map((({url:n,path:s})=>((e,t)=>fetch(_e(t,De.get(e))))(r,n).then(Oe).then((r=>e.writeFile(t,s,r)))))),Ue=(e,t,r)=>{e.registerJsModule(t,r)},ze=(e,t,...r)=>{try{return e.runPython(Ee(t),...r)}catch(t){Re.get(e).stderr(t)}},qe=async(e,t,...r)=>{try{return await e.runPythonAsync(Ee(t),...r)}catch(t){Re.get(e).stderr(t)}},Ke=async(e,t,r)=>{const[n,...s]=t.split(\".\");let o,a=e.globals.get(n);for(const e of s)[o,a]=[a,a[e]];try{await a.call(o,r)}catch(t){Re.get(e).stderr(t)}};var Ye={type:\"micropython\",module:(e=\"1.20.0-297\")=>`https://cdn.jsdelivr.net/npm/@micropython/micropython-webassembly-pyscript@${e}/micropython.mjs`,async engine({loadMicroPython:e},t,r){const{stderr:n,stdout:s,get:o}=Be();r=r.replace(/\\.m?js$/,\".wasm\");const a=await o(e({stderr:n,stdout:s,url:r}));return t.fetch&&await Ne(this,a,t.fetch),a},registerJSModule:Ue,run:ze,runAsync:qe,runEvent:Ke,transform:(e,t)=>t,writeFile:({FS:e,_module:{PATH:t,PATH_FS:r}},n,s)=>Je({FS:e,PATH:t,PATH_FS:r},n,s)};const Ge={dict_converter:Object.fromEntries};var Ve={type:\"pyodide\",module:(e=\"0.23.4\")=>`https://cdn.jsdelivr.net/pyodide/v${e}/full/pyodide.mjs`,async engine({loadPyodide:e},t,r){const{stderr:n,stdout:s,get:o}=Be(),a=r.slice(0,r.lastIndexOf(\"/\")),i=await o(e({stderr:n,stdout:s,indexURL:a}));if(t.fetch&&await Ne(this,i,t.fetch),t.packages){await i.loadPackage(\"micropip\");const e=await i.pyimport(\"micropip\");await e.install(t.packages),e.destroy()}return i},registerJSModule:Ue,run:ze,runAsync:qe,runEvent:Ke,transform:(e,t)=>t instanceof e.ffi.PyProxy?t.toJs(Ge):t,writeFile:({FS:e,PATH:t,_module:{PATH_FS:r}},n,s)=>Je({FS:e,PATH:t,PATH_FS:r},n,s)};const Qe=\"ruby-wasm-wasi\",Xe=Qe.replace(/\\W+/g,\"_\");var Ze={type:Qe,experimental:!0,module:(e=\"2.0.0\")=>`https://cdn.jsdelivr.net/npm/ruby-3_2-wasm-wasi@${e}/dist/browser.esm.js`,async engine({DefaultRubyVM:e},t,r){const n=await fetch(`${r.slice(0,r.lastIndexOf(\"/\"))}/ruby.wasm`),s=await WebAssembly.compile(await n.arrayBuffer()),{vm:o}=await e(s);return t.fetch&&await Ne(this,o,t.fetch),o},registerJSModule(e,t,r){const n=`__module_${Xe}_${t}`;globalThis[n]=r,this.run(e,`require \"js\";$${t}=JS.global[:${n}]`),delete globalThis[n]},run:(e,t,...r)=>e.eval(Ee(t),...r),runAsync:(e,t,...r)=>e.evalAsync(Ee(t),...r),async runEvent(e,t,r){if(/^xworker\\.(on\\w+)$/.test(t)){const{$1:t}=RegExp,n=`__module_${Xe}_event`;globalThis[n]=r,this.run(e,`require \"js\";$xworker.call(\"${t}\",JS.global[:${n}])`),delete globalThis[n]}else{const n=this.run(e,`method(:${t})`);await n.call(t,e.wrap(r))}},transform:(e,t)=>t,writeFile:()=>{throw new Error(`writeFile is not supported in ${Qe}`)}};var et={type:\"wasmoon\",module:(e=\"1.15.0\")=>`https://cdn.jsdelivr.net/npm/wasmoon@${e}/+esm`,async engine({LuaFactory:e,LuaLibraries:t},r){const{stderr:n,stdout:s,get:o}=Be(),a=await o((new e).createEngine());return a.global.getTable(t.Base,(e=>{a.global.setField(e,\"print\",s),a.global.setField(e,\"printErr\",n)})),r.fetch&&await Ne(this,a,r.fetch),a},registerJSModule:(e,t,r)=>{e.global.set(t,r)},run:(e,t,...r)=>{try{return e.doStringSync(Ee(t),...r)}catch(t){Re.get(e).stderr(t)}},runAsync:async(e,t,...r)=>{try{return await e.doString(Ee(t),...r)}catch(t){Re.get(e).stderr(t)}},runEvent:async(e,t,r)=>{const[n,...s]=t.split(\".\");let o,a=e.global.get(n);for(const e of s)[o,a]=[a,a[e]];try{await a.call(o,r)}catch(t){Re.get(e).stderr(t)}},transform:(e,t)=>t,writeFile:({cmodule:{module:{FS:e}}},t,r)=>((e,t,r)=>(Le(e,Ie(t)),t=Ce(e,t),e.writeFile(t,new Uint8Array(r),{canOwn:!0})))(e,t,r)};const tt=new Map,rt=new Map,nt=new Proxy(new Map,{get(e,t){if(!e.has(t)){const[r,...n]=t.split(\"@\"),s=tt.get(r),o=/^https?:\\/\\//i.test(n)?n.join(\"@\"):s.module(...n);e.set(t,{url:o,module:import(o),engine:s.engine.bind(s)})}const{url:r,module:n,engine:s}=e.get(t);return(e,o)=>n.then((n=>{rt.set(t,e);const a=e?.fetch;return a&&De.set(a,o),s(n,e,r)}))}}),st=e=>{for(const t of[].concat(e.type))tt.set(t,e)};for(const e of[Ye,Ve,Ze,et])st(e);const ot=async e=>(await import(\"https://cdn.jsdelivr.net/npm/basic-toml@0.3.1/es.js\")).parse(e);try{new SharedArrayBuffer(4)}catch(e){throw new Error([\"Unable to use SharedArrayBuffer due insecure environment.\",\"Please read requirements in MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer#security_requirements\"].join(\"\\n\"))}let at,it,ct;const lt=(e,t)=>{addEventListener(e,t||(async t=>{try{await at,it(`xworker.on${e}`,t)}catch(e){postMessage(e)}}),!!t&&{once:!0})},{parse:ut,stringify:ft}=f,{proxy:pt,window:dt,isWindowProxy:gt}=ve(self,{parse:ut,stringify:ft,transform:e=>ct?ct(e):e}),yt={sync:pt,window:dt,isWindowProxy:gt,onmessage:console.info,onerror:console.error,onmessageerror:console.warn,postMessage:postMessage.bind(self)};lt(\"message\",(({data:{options:e,config:t,code:r,hooks:n}})=>{at=(async()=>{try{const{id:s,tag:o,type:a,custom:i,version:c,config:l,async:u}=e,f=await((e,t,r={})=>{if(t)if(t.endsWith(\".json\"))r=fetch(t).then(Fe),t=_e(t);else if(t.endsWith(\".toml\"))r=fetch(t).then(We).then(ot),t=_e(t);else if(!t.endsWith(\".txt\")){try{r=JSON.parse(t)}catch(e){r=ot(t)}t=_e(\"./config.txt\")}return Te(r).then((r=>nt[e](r,t)))})(((e,t=\"\")=>`${e}@${t}`.replace(/@$/,\"\"))(a,c),t,l),p=Me(tt.get(a)),d=\"run\"+(u?\"Async\":\"\");if(n){const{beforeRun:e,beforeRunAsync:t,afterRun:r,afterRunAsync:s}=n,o=r||s,a=e||t;if(o){const e=p[d].bind(p);p[d]=(t,r,...n)=>e(t,`${r}\\n${o}`,...n)}if(a){const e=p[d].bind(p);p[d]=(t,r,...n)=>e(t,`${a}\\n${r}`,...n)}}const{CustomEvent:g,document:y}=dt,h=s&&y.getElementById(s)||null;let w=\"\";return p.registerJSModule(f,\"polyscript\",{xworker:yt,get target(){return!w&&h&&(\"SCRIPT\"===o?h.after(Ae(y.createElement(`script-${i||a}`),{id:w=`${s}-target`})):(w=s,h.replaceChildren(),h.style.display=\"block\")),w}}),it=p.runEvent.bind(p,f),ct=p.transform.bind(p,f),h&&((e,t,r,n)=>{e.dispatchEvent(new n(`${t}:ready`,{bubbles:!0,detail:{worker:r}}))})(h,i||a,!0,g),await p[d](f,r),f}catch(e){postMessage(e)}})(),lt(\"error\"),lt(\"message\"),lt(\"messageerror\")}));\n"],{type:'application/javascript'})),{type:'module'});
{
"name": "polyscript",
"version": "0.3.4",
"version": "0.3.5",
"description": "PyScript single core to rule them all",

@@ -70,7 +70,7 @@ "main": "./cjs/index.js",

"codedent": "^0.1.2",
"coincident": "^0.11.5"
"coincident": "^0.11.6"
},
"worker": {
"blob": "sha256-DIHUuInfI4tdn+DpgcTAEaslvvsvwq51ZU18P3a6bnk="
"blob": "sha256-YCjLBQpKRjsu6QAzGWRouTXHL9/8bvDnOFrZ2RIb6lM="
}
}

@@ -1,2 +0,9 @@

export function dispatch(target: any, type: any, worker: any, CustomEvent: any): void;
/**
* Notify the main thread about element "readiness".
* @param {HTMLScriptElement | HTMLElement} target the script or custom-type element
* @param {string} type the custom/type as event prefix
* @param {boolean} worker `true` if dispatched form a worker, `false` if in main
* @param {globalThis.CustomEvent} CustomEvent the right global to use
*/
export function dispatch(target: HTMLScriptElement | HTMLElement, type: string, worker: boolean, CustomEvent: globalThis.CustomEvent): void;
export const isArray: (arg: any) => arg is any[];

@@ -3,0 +10,0 @@ export const assign: {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc