@jeevanand/agent-browserbox-runtime 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +33 -2
  3. package/bin/serve.mjs +74 -0
  4. package/dist/assets/anthropic-S3ckT02t.js +17 -0
  5. package/dist/assets/bridge-DY2WnNx7.js +322 -0
  6. package/dist/assets/build-BNa5TW3M.js +2 -0
  7. package/dist/assets/bundle-8opp8__C.js +1 -0
  8. package/dist/assets/dev-impl-BRiXVAGb.js +4 -0
  9. package/dist/assets/embed-CMbAHE2J.js +3 -0
  10. package/dist/assets/github-Dwhv0h55.js +2 -0
  11. package/dist/assets/html-R2xYS1Rp.js +237 -0
  12. package/dist/assets/instance-CppC8T8t.js +2 -0
  13. package/dist/assets/kcore-COUztiEr.wasm +0 -0
  14. package/dist/assets/lib-aA6_aWm_.js +68 -0
  15. package/dist/assets/main-VEpSfsM_.js +482 -0
  16. package/dist/assets/node.browser-1OJr47If.js +1 -0
  17. package/dist/assets/node.browser-cOXEGsLT.js +1 -0
  18. package/dist/assets/npm-DF8ts_uH.js +1 -0
  19. package/dist/assets/openai-CThAXVqN.js +3 -0
  20. package/dist/assets/pkg-esbuild-BuQjm7dB.js +1 -0
  21. package/dist/assets/pkg-git-jawfIVoq.js +110 -0
  22. package/dist/assets/pkg-python-CoNK0IjJ.js +6 -0
  23. package/dist/assets/pkg-sqlite-BexM5lLo.js +4 -0
  24. package/dist/assets/pkg-zip-BdZ_Lkdk.js +1 -0
  25. package/dist/assets/publish-CHt_Qrq5.js +2 -0
  26. package/dist/assets/publish-impl-BqjdM7Ux.js +7 -0
  27. package/dist/assets/rolldown-runtime-XKyaHtl9.js +1 -0
  28. package/dist/assets/server-C5Sd62CK.js +4 -0
  29. package/dist/assets/sql-wasm-CXIAVl5-.wasm +0 -0
  30. package/dist/assets/webllm-wsrhCAP4.js +11 -0
  31. package/dist/embed/index.html +15 -0
  32. package/dist/icon.svg +1 -0
  33. package/dist/kernel/bridge.html +13 -0
  34. package/dist/kernel/packages.json +1 -0
  35. package/dist/kernel/sandbox-net.html +18 -0
  36. package/dist/kernel/sandbox.html +18 -0
  37. package/dist/manifest.webmanifest +10 -0
  38. package/dist/preview/frame.html +27 -0
  39. package/dist/sw.js +73 -0
  40. package/index.d.ts +5 -0
  41. package/index.js +9 -0
  42. package/package.json +51 -4
@@ -0,0 +1,6 @@
1
+ import{c as e,f as t,g as n,m as r,p as i,r as a,s as o}from"./main-VEpSfsM_.js";function s(e,t){return t.value!==void 0&&t.value!==`None`&&e.out(t.value+`
2
+ `),t.error&&e.err(t.error+`
3
+ `),+!t.ok}const c=(e,r)=>n(e.os,r,{cwd:e.shell.cwd,env:t(e.shell.env),signal:e.signal,onStdout:e.out,onStderr:e.err}),l={name:`python`,summary:`run Python 3.13 (CPython on WebAssembly, via Pyodide)`,usage:`python file.py | python -c "code" | python -m pip install <pkg> | python -V (files in the cwd are visible; changes are written back)`,async run(e){let{opts:t,rest:n}=i(e.args);if(t.has(`V`)||t.has(`version`))return s(e,await c(e,`import sys, pyodide
4
+ print(f"Python {sys.version.split()[0]} (Pyodide {pyodide.__version__})")`));if(t.has(`m`))return n[0]===`pip`?u.run({...e,args:n.slice(1)}):s(e,await c(e,`import runpy, sys\nsys.argv = ${JSON.stringify(n)}\nrunpy.run_module(${JSON.stringify(n[0]??``)}, run_name="__main__")`));let r=t.has(`c`)?n[0]??``:n[0]?await e.os.fs.readText(e.path(n[0])):e.stdin;if(!r.trim())throw Error(`nothing to run: pass a file, -c "code", or pipe code in`);return s(e,await c(e,r))}},u={name:`pip`,summary:`install Python packages (PyPI pure-Python wheels and Pyodide builds) with micropip`,usage:`pip install <pkg>… | pip install -r requirements.txt | pip uninstall <pkg>… | pip list | pip show <pkg> | pip freeze`,async run(e){let[t=`help`,...n]=e.args,i=()=>e.os.settings.get(r,[]),a=e=>e.split(/[<>=!~\[; ]/)[0].toLowerCase();if(t===`install`){let t=[];for(let r=0;r<n.length;r++){let i=n[r];if(i===`-r`||i===`--requirement`){let i=await e.os.fs.readText(e.path(n[++r]??``));t.push(...i.split(`
5
+ `).map(e=>e.replace(/#.*/,``).trim()).filter(e=>e&&!e.startsWith(`-`)))}else i.startsWith(`-`)||t.push(i)}if(!t.length)throw Error(`usage: pip install <pkg>… | pip install -r requirements.txt`);e.out(`Installing ${t.join(`, `)}…\n`);let o=await c(e,`import micropip\nawait micropip.install(${JSON.stringify(t)}, keep_going=True)\ninstalled = micropip.list()\nfor s in ${JSON.stringify(t.map(a))}:\n p = installed.get(s) or installed.get(s.replace("_", "-"))\n print(f"Successfully installed {s}-{p.version}" if p else f"{s}: installed")`);if(!o.ok)return s(e,o);let l=i().filter(e=>!t.some(t=>a(t)===a(e)));return e.os.settings.set(r,[...l,...t]),s(e,o)}if(t===`uninstall`){let t=n.filter(e=>!e.startsWith(`-`));return e.os.settings.set(r,i().filter(e=>!t.some(t=>a(t)===a(e)))),s(e,await c(e,`import micropip\nfor n in ${JSON.stringify(t)}:\n try:\n micropip.uninstall(n); print(f"Successfully uninstalled {n}")\n except Exception as e:\n print(f"{n}: {e}")`))}return t===`list`||t===`freeze`?s(e,await c(e,`import micropip\n${t===`list`?`print(f"{'Package':<32} {'Version':<14} Source")
6
+ `:``}for name, p in sorted(micropip.list().items()):\n ${t===`freeze`?`print(f"{name}=={p.version}")`:`print(f"{name:<32} {p.version:<14} {p.source}")`}`)):t===`show`?s(e,await c(e,`import micropip\nfrom importlib import metadata\nfor n in ${JSON.stringify(n)}:\n try:\n m = metadata.metadata(n)\n print(f"Name: {m['Name']}\\nVersion: {m['Version']}\\nSummary: {m.get('Summary', '')}\\nRequires: {', '.join(metadata.requires(n) or [])}\\n")\n except metadata.PackageNotFoundError:\n print(f"WARNING: Package(s) not found: {n}")`)):(e.out(`${u.usage}\n\nRuns micropip in the Python sandbox: pure-Python wheels from PyPI and Pyodide's WebAssembly builds (numpy, pandas, scipy, matplotlib, scikit-learn…). Packages with other C extensions cannot install. Installed packages are reinstalled in each new interpreter.\n`),t===`help`?0:1)}};var d={commands:[l,{...l,name:`python3`},u,{...u,name:`pip3`}],tools:[e({name:`run_python`,description:"Run Python 3 (CPython compiled to WebAssembly via Pyodide) in an isolated sandbox. Files in the working directory are visible to the script and files it writes are saved back. Imports of bundled scientific packages (numpy, pandas, matplotlib, scipy, sympy…) load automatically; list pure-Python PyPI packages in `packages`. The interpreter persists between calls. No sockets or subprocesses.",input_schema:o({code:{type:`string`},packages:{type:`array`,items:{type:`string`},description:`extra PyPI packages to install with micropip`}},[`code`]),cap:()=>`exec`,describe:e=>e.code,async run(e,r){return a(await n(r.os,e.code,{cwd:r.shell.cwd,env:t(r.shell.env),packages:e.packages,signal:r.signal,onStdout:r.progress,onStderr:r.progress}))}})]};export{d as default};
@@ -0,0 +1,4 @@
1
+ import{r as e,t}from"./rolldown-runtime-XKyaHtl9.js";var n=/* @__PURE__ */ e((/* @__PURE__ */ t(((e,t)=>{var n=void 0,r=function(e){return n||(n=new Promise(function(n,r){var i=e===void 0?{}:e,a=i.onAbort;i.onAbort=function(e){r(Error(e)),a&&a(e)},i.postRun=i.postRun||[],i.postRun.push(function(){n(i)}),t=void 0;var o;o||=i===void 0?{}:i;var s=!!globalThis.window,c=!!globalThis.WorkerGlobalScope;o.onRuntimeInitialized=function(){function e(e,t){Ee(e,t instanceof Error?t.message:String(t),-1)}function t(e,t){switch(typeof t){case`boolean`:Te(e,+!!t);break;case`number`:xe(e,t);break;case`string`:Ce(e,t,T(t),-1);break;case`object`:if(t===null)Se(e);else if(t.length!=null){var n=jt(t.length);b.set(t,n),we(e,n,t.length,-1),X(n)}else Ee(e,`Wrong API use : tried to return a value of an unknown type (`+t+`).`,-1);break;default:Se(e)}}function n(e,t){for(var n=[],r=0;r<e;r+=1){var i=G(t+4*r,`i32`),a=_e(i);if(a===1||a===2)i=be(i);else if(a===3)a=D(i),i=ve(i),i=C(i,a,!0);else if(a===4){a=i,i=D(a),a=ye(a);for(var o=new Uint8Array(i),s=0;s<i;s+=1)o[s]=b[a+s];i=o}else i=null;n.push(i)}return n}function r(e,t){this.Va=e,this.db=t,this.Ta=1,this.Eb=[]}function i(e,t){if(this.db=t,this.tb=K(e),this.tb===null)throw Error(`Unable to allocate memory for the SQL string`);this.zb=this.tb,this.fb=this.Kb=null}function a(e){this.filename=`dbfile_`+(4294967295*Math.random()>>>0),e!=null&&ct(this.filename,e),this.handleError(f(this.filename,u)),this.db=G(u,`i32`),l&&De(this.db),this.Bb={},this.ab=/* @__PURE__ */ new Map}function s(e,t){return e.replace(/[A-Z]/g,function(e){return e.toLowerCase()})+`:`+t}function c(e){e.forEach(Dt)}var l=o.useOldExtensionFunctions!==!1,u=Z(4),d=o.cwrap,f=d(`sqlite3_open`,`number`,[`string`,`number`]),p=d(`sqlite3_close_v2`,`number`,[`number`]),m=d(`sqlite3_backup_init`,`number`,[`number`,`string`,`number`,`string`]),h=d(`sqlite3_backup_step`,`number`,[`number`,`number`]),g=d(`sqlite3_backup_finish`,`number`,[`number`]),_=d(`sqlite3_exec`,`number`,[`number`,`number`,`number`,`number`,`number`]),ee=d(`sqlite3_changes`,`number`,[`number`]),te=d(`sqlite3_sql`,`string`,[`number`]),ne=d(`sqlite3_normalized_sql`,`string`,[`number`]),re=d(`sqlite3_prepare_v2`,`number`,[`number`,`number`,`number`,`number`,`number`]),v=d(`sqlite3_bind_text`,`number`,[`number`,`number`,`number`,`number`,`number`]),y=d(`sqlite3_bind_blob`,`number`,[`number`,`number`,`number`,`number`,`number`]),ie=d(`sqlite3_bind_double`,`number`,[`number`,`number`,`number`]),ae=d(`sqlite3_bind_int`,`number`,[`number`,`number`,`number`]),oe=d(`sqlite3_bind_parameter_index`,`number`,[`number`,`string`]),se=d(`sqlite3_step`,`number`,[`number`]),ce=d(`sqlite3_errmsg`,`string`,[`number`]),le=d(`sqlite3_column_count`,`number`,[`number`]),x=d(`sqlite3_data_count`,`number`,[`number`]),S=d(`sqlite3_column_double`,`number`,[`number`,`number`]),ue=d(`sqlite3_column_text`,`number`,[`number`,`number`]),de=d(`sqlite3_column_blob`,`number`,[`number`,`number`]),fe=d(`sqlite3_column_bytes`,`number`,[`number`,`number`]),pe=d(`sqlite3_column_type`,`number`,[`number`,`number`]),me=d(`sqlite3_column_name`,`string`,[`number`,`number`]),w=d(`sqlite3_reset`,`number`,[`number`]),he=d(`sqlite3_clear_bindings`,`number`,[`number`]),E=d(`sqlite3_finalize`,`number`,[`number`]),ge=d(`sqlite3_create_function_v2`,`number`,`number string number number number number number number number`.split(` `)),_e=d(`sqlite3_value_type`,`number`,[`number`]),D=d(`sqlite3_value_bytes`,`number`,[`number`]),ve=d(`sqlite3_value_text`,`number`,[`number`]),ye=d(`sqlite3_value_blob`,`number`,[`number`]),be=d(`sqlite3_value_double`,`number`,[`number`]),xe=d(`sqlite3_result_double`,``,[`number`,`number`]),Se=d(`sqlite3_result_null`,``,[`number`]),Ce=d(`sqlite3_result_text`,``,[`number`,`string`,`number`,`number`]),we=d(`sqlite3_result_blob`,``,[`number`,`number`,`number`,`number`]),Te=d(`sqlite3_result_int`,``,[`number`,`number`]),Ee=d(`sqlite3_result_error`,``,[`number`,`string`,`number`]),O=d(`sqlite3_aggregate_context`,`number`,[`number`,`number`]),De=d(`RegisterExtensionFunctions`,`number`,[`number`]),k=d(`sqlite3_update_hook`,`number`,[`number`,`number`,`number`]);r.prototype.bind=function(e){if(!this.Va)throw`Statement closed`;return this.reset(),Array.isArray(e)?this.bc(e):typeof e==`object`&&e?this.cc(e):!0},r.prototype.step=function(){if(!this.Va)throw`Statement closed`;this.Ta=1;var e=se(this.Va);switch(e){case 100:return!0;case 101:return!1;default:throw this.db.handleError(e)}},r.prototype.Ub=function(e){return e??(e=this.Ta,this.Ta+=1),S(this.Va,e)},r.prototype.oc=function(e){if(e??(e=this.Ta,this.Ta+=1),typeof BigInt!=`function`)throw Error(`BigInt is not supported`);return BigInt(this.Vb(e))},r.prototype.Vb=function(e){e??(e=this.Ta,this.Ta+=1);var t=ue(this.Va,e);return e=fe(this.Va,e),C(t,e,!0)},r.prototype.getBlob=function(e){e??(e=this.Ta,this.Ta+=1);var t=fe(this.Va,e);e=de(this.Va,e);for(var n=new Uint8Array(t),r=0;r<t;r+=1)n[r]=b[e+r];return n},r.prototype.get=function(e,t){t||={},e!=null&&this.bind(e)&&this.step(),e=[];for(var n=x(this.Va),r=0;r<n;r+=1)switch(pe(this.Va,r)){case 1:var i=t.useBigInt?this.oc(r):this.Ub(r);e.push(i);break;case 2:e.push(this.Ub(r));break;case 3:e.push(this.Vb(r));break;case 4:e.push(this.getBlob(r));break;default:e.push(null)}return e},r.prototype.Ib=function(){for(var e=[],t=le(this.Va),n=0;n<t;n+=1)e.push(me(this.Va,n));return e},r.prototype.Tb=function(e,t){var n=this.get(e,t);return e=this.Ib(),Object.fromEntries(e.map(function(e,t){return[e,n[t]]}))},r.prototype.tc=function(){return te(this.Va)},r.prototype.qc=function(){return ne(this.Va)},r.prototype.run=function(e){return e!=null&&this.bind(e),this.step(),this.reset()},r.prototype.Pb=function(e,t){t??(t=this.Ta,this.Ta+=1);var n=K(e);this.Eb.push(n),this.db.handleError(v(this.Va,t,n,T(e),0))},r.prototype.ac=function(e,t){t??(t=this.Ta,this.Ta+=1);var n=jt(e.length);b.set(e,n),this.Eb.push(n),this.db.handleError(y(this.Va,t,n,e.length,0))},r.prototype.Ob=function(e,t){t??(t=this.Ta,this.Ta+=1),this.db.handleError((e===(e|0)?ae:ie)(this.Va,t,e))},r.prototype.dc=function(e){e??(e=this.Ta,this.Ta+=1),y(this.Va,e,0,0,0)},r.prototype.Qb=function(e,t){switch(t??(t=this.Ta,this.Ta+=1),typeof e){case`string`:this.Pb(e,t);return;case`number`:this.Ob(e,t);return;case`bigint`:this.Pb(e.toString(),t);return;case`boolean`:this.Ob(e+0,t);return;case`object`:if(e===null){this.dc(t);return}if(e.length!=null){this.ac(e,t);return}}throw`Wrong API use : tried to bind a value of an unknown type (`+e+`).`},r.prototype.cc=function(e){var t=this;return Object.keys(e).forEach(function(n){var r=oe(t.Va,n);r!==0&&t.Qb(e[n],r)}),!0},r.prototype.bc=function(e){for(var t=0;t<e.length;t+=1)this.Qb(e[t],t+1);return!0},r.prototype.reset=function(){return this.Hb(),he(this.Va)===0&&w(this.Va)===0},r.prototype.Hb=function(){for(var e;(e=this.Eb.pop())!==void 0;)X(e)},r.prototype.jb=function(){this.Hb();var e=E(this.Va)===0;return delete this.db.Bb[this.Va],this.Va=0,e},i.prototype.next=function(){if(this.tb===null)return{done:!0};if(this.fb!==null&&(this.fb.jb(),this.fb=null),!this.db.db)throw this.ub(),Error(`Database closed`);var e=Q(),t=Z(4);wt(u),wt(t);try{this.db.handleError(re(this.db.db,this.zb,-1,u,t)),this.zb=G(t,`i32`);var n=G(u,`i32`);return n===0?(this.ub(),{done:!0}):(this.fb=new r(n,this.db),this.db.Bb[n]=this.fb,{value:this.fb,done:!1})}catch(e){throw this.Kb=C(this.zb),this.ub(),e}finally{Pt(e)}},i.prototype.ub=function(){X(this.tb),this.tb=null},i.prototype.return=function(){return this.fb!==null&&(this.fb.jb(),this.fb=null),this.ub(),{done:!0}},i.prototype.rc=function(){return this.Kb===null?C(this.zb):this.Kb},typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`&&(i.prototype[Symbol.iterator]=function(){return this}),a.prototype.run=function(e,t){if(!this.db)throw`Database closed`;if(t){e=this.Lb(e,t);try{e.step()}finally{e.jb()}}else{e=K(e);try{this.handleError(_(this.db,e,0,0,u))}finally{X(e)}}return this},a.prototype.exec=function(e,t,n){if(!this.db)throw`Database closed`;var i=Q(),a=null,o=null,s=null;try{s=o=K(e);var c=Z(4);for(e=[];G(s,`i8`)!==0;){wt(u),wt(c),this.handleError(re(this.db,s,-1,u,c));var l=G(u,`i32`);if(s=G(c,`i32`),l!==0){var d=null;for(a=new r(l,this),t!=null&&a.bind(t);a.step();)d===null&&(d={columns:a.Ib(),values:[]},e.push(d)),d.values.push(a.get(null,n));a.jb()}}return e}catch(e){throw a&&a.jb(),e}finally{o&&X(o),Pt(i)}},a.prototype.lc=function(e,t,n,r,i){typeof t==`function`&&(r=n,n=t,t=void 0),e=this.Lb(e,t);try{for(;e.step();)n(e.Tb(null,i))}finally{e.jb()}if(typeof r==`function`)return r()},a.prototype.Lb=function(e,t){e=K(e);try{wt(u),this.handleError(re(this.db,e,-1,u,0))}finally{X(e)}if(e=G(u,`i32`),e===0)throw`Nothing to prepare`;var n=new r(e,this);return t!=null&&n.bind(t),this.Bb[e]=n},a.prototype.wc=function(e){return new i(e,this)},a.prototype.nc=function(){if(!this.db)throw Error(`Database closed`);var e=this.filename+`_export`;ct(e,[]);var t=0,n=0;try{var r=M(e).node,i=null,a=r.Qa.write;r.Qa=Object.create(r.Qa),r.Qa.write=function(e,t,n,o,s){return i===null?a(e,t,n,o,s):(r.Ua.set(t.subarray(n,n+o),s),r.Wa=Math.max(r.Wa,s+o),o)};var o=f(e,u);if(t=G(u,`i32`),o!==0||(n=m(t,`main`,this.db,`main`),n===0))throw Error(ce(t));if(o=h(n,0),o===0){var s=this.exec(`PRAGMA main.page_count; PRAGMA main.page_size`);i=new Uint8Array(s[0].values[0][0]*s[1].values[0][0]),r.Ua=i,o=h(n,-1)}if(o===5||o===6)throw Error(`Unable to export: SQLite is busy or locked. Finish active write transactions before exporting.`);if(o!==101||(o=g(n),n=0,o!==0)||(o=p(t),o!==0))throw Error(ce(t));return t=0,i=new Uint8Array(r.Ua.buffer,r.Ua.byteOffset,r.Wa),i.length>0&&(i[18]=1,i[19]=1),i}finally{n!==0&&g(n),t!==0&&p(t),Qe(`/`+e)}},a.prototype.close=function(){this.db!==null&&(Object.values(this.Bb).forEach(function(e){e.jb()}),this.ab.forEach(c),this.ab.clear(),this.lb&&=(Dt(this.lb),void 0),this.handleError(p(this.db)),Qe(`/`+this.filename),this.db=null)},a.prototype.handleError=function(e){if(e===0)return null;throw e=ce(this.db),Error(e)},a.prototype.sc=function(){return ee(this.db)},a.prototype.jc=function(r,i){var a=s(r,i.length);this.ab.has(a)&&(c(this.ab.get(a)),this.ab.delete(a));var o=J(function(r,a,o){a=n(a,o);try{var s=i.apply(null,a)}catch(t){e(r,t);return}t(r,s)},`viii`);return this.ab.set(a,[o]),this.handleError(ge(this.db,r,i.length,1,0,o,0,0,0)),this},a.prototype.hc=function(r,i){function a(e){return d.has(e)||d.set(e,o()),d.get(e)}var o=i.init||function(){return null},l=i.finalize||function(e){return e},u=i.step;if(!u)throw`An aggregate function must have a step function in `+r;var d=/* @__PURE__ */ new Map;i=s(r,u.length-1),this.ab.has(i)&&(c(this.ab.get(i)),this.ab.delete(i));var f=J(function(t,r,i){var o=O(t,1),s=a(o);r=n(r,i),s=[s].concat(r);try{d.set(o,u.apply(null,s))}catch(n){d.delete(o),e(t,n)}},`viii`),p=J(function(n){var r=O(n,1);try{var i=l(a(r))}catch(t){d.delete(r),e(n,t);return}t(n,i),d.delete(r)},`vi`);return this.ab.set(i,[f,p]),this.handleError(ge(this.db,r,u.length-1,1,0,0,f,p,0)),this},a.prototype.Dc=function(e){return this.lb&&=(k(this.db,0,0),Dt(this.lb),void 0),e&&(this.lb=J(function(t,n,r,i,a){switch(n){case 18:t=`insert`;break;case 23:t=`update`;break;case 9:t=`delete`;break;default:throw`unknown operationCode in updateHook callback: `+n}if(r=C(r),i=C(i),a>2**53-1)throw`rowId too big to fit inside a Number`;e(t,r,i,Number(a))},`viiiij`),k(this.db,this.lb,0)),this},r.prototype.bind=r.prototype.bind,r.prototype.step=r.prototype.step,r.prototype.get=r.prototype.get,r.prototype.getColumnNames=r.prototype.Ib,r.prototype.getAsObject=r.prototype.Tb,r.prototype.getSQL=r.prototype.tc,r.prototype.getNormalizedSQL=r.prototype.qc,r.prototype.run=r.prototype.run,r.prototype.reset=r.prototype.reset,r.prototype.freemem=r.prototype.Hb,r.prototype.free=r.prototype.jb,i.prototype.next=i.prototype.next,i.prototype.getRemainingSQL=i.prototype.rc,a.prototype.run=a.prototype.run,a.prototype.exec=a.prototype.exec,a.prototype.each=a.prototype.lc,a.prototype.prepare=a.prototype.Lb,a.prototype.iterateStatements=a.prototype.wc,a.prototype.export=a.prototype.nc,a.prototype.close=a.prototype.close,a.prototype.handleError=a.prototype.handleError,a.prototype.getRowsModified=a.prototype.sc,a.prototype.create_function=a.prototype.jc,a.prototype.create_aggregate=a.prototype.hc,a.prototype.updateHook=a.prototype.Dc,o.Database=a};var l=`./this.program`,u=globalThis.document?.currentScript?.src;c&&(u=self.location.href);var d=``,f,p;if(s||c){try{d=new URL(`.`,u).href}catch{}c&&(p=e=>{var t=new XMLHttpRequest;return t.open(`GET`,e,!1),t.responseType=`arraybuffer`,t.send(null),new Uint8Array(t.response)}),f=async e=>{if(e=await fetch(e,{credentials:`same-origin`}),e.ok)return e.arrayBuffer();throw Error(e.status+` : `+e.url)}}var m=console.log.bind(console),h=console.error.bind(console),g,_=!1,ee;function te(){if(!b?.buffer?.resizable){var e=Ft.buffer;b=new Int8Array(e),dt=new Int16Array(e),S=new Uint8Array(e),V=new Int32Array(e),U=new Uint32Array(e),St=new Float32Array(e),Ct=new Float64Array(e),H=new BigInt64Array(e)}}function ne(){var e=o.preRun;for(e&&(typeof e==`function`&&(e=[e]),le.push(...e)),e=le;e.length>0;)e.shift()(o)}function re(){var e=o.postRun;for(e&&(typeof e==`function`&&(e=[e]),ce.push(...e)),e=ce;e.length>0;)e.shift()(o)}function v(e){throw o.onAbort?.(e),e=`Aborted(${e})`,h(e),_=!0,new WebAssembly.RuntimeError(e+`. Build with -sASSERTIONS for more info.`)}var y;async function ie(e){if(!g)try{return await f(e)}catch{}if(e==y&&g)e=new Uint8Array(g);else if(p)e=p(e);else throw`both async and sync fetching of the wasm failed`;return e}async function ae(e,t){try{var n=await ie(e);return await WebAssembly.instantiate(n,t)}catch(e){h(`failed to asynchronously prepare wasm: ${e}`),v(e)}}async function oe(e){var t=y;if(!g)try{var n=fetch(t,{credentials:`same-origin`});return await WebAssembly.instantiateStreaming(n,e)}catch(e){h(`wasm streaming compile failed: ${e}`),h(`falling back to ArrayBuffer instantiation`)}return ae(t,e)}class se{name=`ExitStatus`;constructor(e){this.message=`Program terminated with exit(${e})`,this.status=e}}var b,ce=[],le=[],x=!0,S,ue=new TextDecoder,de=(e,t,n,r)=>{if(n=t+n,r)return n;for(;e[t]&&!(t>=n);)++t;return t},C=(e,t,n)=>e?ue.decode(S.subarray(e,de(S,e,t,n))):``,fe=(e,t)=>{for(var n=0,r=e.length-1;r>=0;r--){var i=e[r];i===`.`?e.splice(r,1):i===`..`?(e.splice(r,1),n++):n&&(e.splice(r,1),n--)}if(t)for(;n;n--)e.unshift(`..`);return e},pe=e=>{var t=e.charAt(0)===`/`,n=e.slice(-1)===`/`;return(e=fe(e.split(`/`).filter(e=>!!e),!t).join(`/`))||t||(e=`.`),e&&n&&(e+=`/`),(t?`/`:``)+e},me=e=>{var t=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1);return e=t[0],t=t[1],!e&&!t?`.`:(t&&=t.slice(0,-1),e+t)},w=e=>e&&e.match(/([^\/]+|\/)\/*$/)[1],he=(...e)=>{for(var t=``,n=!1,r=e.length-1;r>=-1&&!n;r--){if(n=r>=0?e[r]:`/`,typeof n!=`string`)throw TypeError(`Arguments to path.resolve must be strings`);if(!n)return``;t=n+`/`+t,n=n.charAt(0)===`/`}return t=fe(t.split(`/`).filter(e=>!!e),!n).join(`/`),(n?`/`:``)+t||`.`},T=e=>{for(var t=0,n=0;n<e.length;++n){var r=e.codePointAt(n);r<=127?t++:r<=2047?t+=2:r<=65535?t+=3:(t+=4,n++)}return t},E=(e,t,n,r)=>{if(!(r>0))return 0;var i=n;r=n+r-1;for(var a=0;a<e.length;++a){var o=e.codePointAt(a);if(o<=127){if(n>=r)break;t[n++]=o}else if(o<=2047){if(n+1>=r)break;t[n++]=192|o>>6,t[n++]=128|o&63}else if(o<=65535){if(n+2>=r)break;t[n++]=224|o>>12,t[n++]=128|o>>6&63,t[n++]=128|o&63}else{if(n+3>=r)break;t[n++]=240|o>>18,t[n++]=128|o>>12&63,t[n++]=128|o>>6&63,t[n++]=128|o&63,a++}}return t[n]=0,n-i},ge=e=>{var t=Array(T(e)+1);return e=E(e,t,0,t.length),t.length=e,t},_e=(e,t)=>{var n=0;return e&&(n|=365),t&&(n|=146),n},D={cb:null,hb(){return D.createNode(null,`/`,16895,0)},createNode(e,t,n,r){if((n&61440)==24576||(n&61440)==4096)throw new j(63);return D.cb||={dir:{node:{$a:D.Ra.$a,eb:D.Ra.eb,rb:D.Ra.rb,wb:D.Ra.wb,Zb:D.Ra.Zb,Db:D.Ra.Db,Ab:D.Ra.Ab,Nb:D.Ra.Nb,Cb:D.Ra.Cb},stream:{bb:D.Qa.bb}},file:{node:{$a:D.Ra.$a,eb:D.Ra.eb},stream:{bb:D.Qa.bb,read:D.Qa.read,write:D.Qa.write,xb:D.Qa.xb,yb:D.Qa.yb}},link:{node:{$a:D.Ra.$a,eb:D.Ra.eb,kb:D.Ra.kb},stream:{}},Rb:{node:{$a:D.Ra.$a,eb:D.Ra.eb},stream:We}},n=Le(e,t,n,r),P(n.mode)?(n.Ra=D.cb.dir.node,n.Qa=D.cb.dir.stream,n.Ua={}):(n.mode&61440)==32768?(n.Ra=D.cb.file.node,n.Qa=D.cb.file.stream,n.Wa=0,n.Ua=D.mc??=/* @__PURE__ */ new Uint8Array):(n.mode&61440)==40960?(n.Ra=D.cb.link.node,n.Qa=D.cb.link.stream):(n.mode&61440)==8192&&(n.Ra=D.cb.Rb.node,n.Qa=D.cb.Rb.stream),n.gb=n.Ya=n.Xa=Date.now(),e&&(e.Ua[t]=n,e.gb=e.Ya=e.Xa=n.gb),n},Ra:{$a(e){var t={};return t.kc=(e.mode&61440)==8192?e.id:1,t.vc=e.id,t.mode=e.mode,t.yc=1,t.uid=0,t.uc=0,t.sb=e.sb,t.size=P(e.mode)?4096:(e.mode&61440)==32768?e.Wa:(e.mode&61440)==40960?e.link.length:0,t.gb=new Date(e.gb),t.Ya=new Date(e.Ya),t.Xa=new Date(e.Xa),t.ec=4096,t.fc=Math.ceil(t.size/t.ec),t},eb(e,t){for(var n of[`mode`,`atime`,`mtime`,`ctime`])t[n]!=null&&(e[n]=t[n]);t.size!==void 0&&(t=t.size,e.Wa!=t&&(n=e.Ua,e.Ua=new Uint8Array(t),e.Ua.set(n.subarray(0,Math.min(t,e.Wa))),e.Wa=t))},rb(){throw D.Fb||(D.Fb=new j(44),D.Fb.stack=`<generic error, no stack>`),D.Fb},wb(e,t,n,r){return D.createNode(e,t,n,r)},Zb(e,t,n){try{var r=N(t,n)}catch{}if(r&&P(e.mode))for(var i in r.Ua)throw new j(55);delete e.parent.Ua[e.name],t.Ua[n]=e,e.name=n,t.Xa=t.Ya=e.parent.Xa=e.parent.Ya=Date.now()},Db(e,t){delete e.Ua[t],e.Xa=e.Ya=Date.now()},Ab(e,t){var n=N(e,t),r;for(r in n.Ua)throw new j(55);delete e.Ua[t],e.Xa=e.Ya=Date.now()},Nb(e){return[`.`,`..`,...Object.keys(e.Ua)]},Cb(e,t,n){return e=D.createNode(e,t,41471,0),e.link=n,e},kb(e){if((e.mode&61440)!=40960)throw new j(28);return e.link}},Qa:{read(e,t,n,r,i){return i>=e.node.Wa?0:(r=Math.min(e.node.Wa-i,r),t.set(e.node.Ua.subarray(i,i+r),n),r)},write(e,t,n,r,i,a){if(t.buffer===b.buffer&&(a=!1),!r)return 0;if(e=e.node,e.Ya=e.Xa=Date.now(),a)e.Ua=t.subarray(n,n+r),e.Wa=r;else if(e.Wa||i){a=i+r;var o=e.Ua.length;o>=a||(a=Math.max(a,o*(o<1048576?2:1.125)>>>0),o&&(a=Math.max(a,256)),o=e.Ua.subarray(0,e.Wa),e.Ua=new Uint8Array(a),e.Ua.set(o)),e.Ua.set(t.subarray(n,n+r),i),e.Wa=Math.max(e.Wa,i+r)}else e.Ua=t.slice(n,n+r),e.Wa=r;return r},bb(e,t,n){if(n===1?t+=e.position:n===2&&(e.node.mode&61440)==32768&&(t+=e.node.Wa),t<0)throw new j(28);return t},xb(e,t,n,r,i){if((e.node.mode&61440)!=32768)throw new j(43);if(e=e.node.Ua,i&2||e.buffer!==b.buffer){i=!0,r=Math.ceil(t/65536)*65536;var a=Mt(65536,r);if(a&&S.fill(0,a,a+r),r=a,!r)throw new j(48);e&&((n>0||n+t<e.length)&&(e=e.subarray?e.subarray(n,n+t):e.slice(n,n+t)),b.set(e,r))}else i=!1,r=e.byteOffset;return{Bc:r,$b:i}},yb(e,t,n,r){return D.Qa.write(e,t,0,r,n,!1),0}}},ve=[],ye=e=>{var t=de(e,0);return ue.decode(e.buffer?e.subarray(0,t):new Uint8Array(e.slice(0,t)))},be=[];function xe(e,t){be[e]={input:[],output:[],pb:t},Ge(e,Se)}var Se={open(e){var t=be[e.node.sb];if(!t)throw new j(43);e.Za=t,e.seekable=!1},close(e){e.Za.pb.qb(e.Za)},qb(e){e.Za.pb.qb(e.Za)},read(e,t,n,r){if(!e.Za||!e.Za.pb.Wb)throw new j(60);for(var i=0,a=0;a<r;a++){try{var o=e.Za.pb.Wb(e.Za)}catch{throw new j(29)}if(o===void 0&&!i)throw new j(6);if(o==null||(i++,t[n+a]=o,o===10))break}return i&&(e.node.gb=Date.now()),i},write(e,t,n,r){if(!e.Za||!e.Za.pb.Mb)throw new j(60);try{for(var i=0;i<r;i++)e.Za.pb.Mb(e.Za,t[n+i])}catch{throw new j(29)}return r&&(e.node.Ya=e.node.Xa=Date.now()),i}},Ce={Wb(){a:{if(!ve.length){var e=null;if(globalThis.window?.prompt&&(e=window.prompt(`Input: `),e!==null&&(e+=`
2
+ `)),!e){e=null;break a}ve=ge(e)}e=ve.shift()}return e},Mb(e,t){t===null||t===10?(m(ye(e.output)),e.output=[]):t!=0&&e.output.push(t)},qb(e){e.output?.length>0&&(m(ye(e.output)),e.output=[])},Kc(){return{Gc:25856,Ic:5,Fc:191,Hc:35387,Ec:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},Lc(){return 0},Mc(){return[24,80]}},we={Mb(e,t){t===null||t===10?(h(ye(e.output)),e.output=[]):t!=0&&e.output.push(t)},qb(e){e.output?.length>0&&(h(ye(e.output)),e.output=[])}},Te=()=>e=>(crypto.getRandomValues(e),0),Ee=e=>(Ee=Te())(e),O=null,De={},k=[],Oe=1,A=[],ke=!1,Ae=!0,je={},j=class{name=`ErrnoError`;constructor(e){this.Sa=e}},Me=class{shared={};node=null;get flags(){return this.shared.flags}set flags(e){this.shared.flags=e}get position(){return this.shared.position}set position(e){this.shared.position=e}},Ne=class{Ra={};Qa={};nb=null;constructor(e,t,n,r){e||=this,this.parent=e,this.hb=e.hb,this.id=Oe++,this.name=t,this.mode=n,this.sb=r,this.gb=this.Ya=this.Xa=Date.now()}get read(){return(this.mode&365)==365}set read(e){e?this.mode|=365:this.mode&=-366}get write(){return(this.mode&146)==146}set write(e){e?this.mode|=146:this.mode&=-147}Ac(){}};function M(e,t={}){if(!e)throw new j(44);t.Gb??=!0,e.charAt(0)===`/`||(e=`//`+e);var n=0;a:for(;n<40;n++){e=e.split(`/`).filter(e=>!!e);for(var r=O,i=`/`,a=0;a<e.length;a++){var o=a===e.length-1;if(o&&t.parent)break;if(e[a]!==`.`){if(e[a]===`..`){if(i=me(i),r===r.parent){e=i+`/`+e.slice(a+1).join(`/`),n--;continue a}r=r.parent}else{i=pe(i+`/`+e[a]);try{r=N(r,e[a])}catch(e){if(e?.Sa===44&&o&&t.zc)return{path:i};throw e}if(!r.nb||o&&!t.Gb||(r=r.nb.root),(r.mode&61440)==40960&&(!o||t.mb)){if(!r.Ra.kb)throw new j(52);r=r.Ra.kb(r),r.charAt(0)===`/`||(r=me(i)+`/`+r),e=r+`/`+e.slice(a+1).join(`/`);continue a}}}}return{path:i,node:r}}throw new j(32)}function Pe(e){for(var t;;){if(e===e.parent)return e=e.hb.Yb,t?e[e.length-1]===`/`?e+t:`${e}/${t}`:e;t=t?`${e.name}/${t}`:e.name,e=e.parent}}function Fe(e,t){for(var n=0,r=0;r<t.length;r++)n=(n<<5)-n+t.charCodeAt(r)|0;return(e+n>>>0)%A.length}function Ie(e){var t=Fe(e.parent.id,e.name);if(A[t]===e)A[t]=e.ob;else for(t=A[t];t;){if(t.ob===e){t.ob=e.ob;break}t=t.ob}}function N(e,t){var n=P(e.mode)?(n=F(e,`x`))?n:e.Ra.rb?0:2:54;if(n)throw new j(n);for(n=A[Fe(e.id,t)];n;n=n.ob){var r=n.name;if(n.parent.id===e.id&&r===t)return n}return e.Ra.rb(e,t)}function Le(e,t,n,r){return e=new Ne(e,t,n,r),t=Fe(e.parent.id,e.name),e.ob=A[t],A[t]=e}function P(e){return(e&61440)==16384}function F(e,t){return Ae?0:t.includes(`r`)&&!(e.mode&292)||t.includes(`w`)&&!(e.mode&146)||t.includes(`x`)&&!(e.mode&73)?2:0}function Re(e,t){if(!P(e.mode))return 54;try{return N(e,t),20}catch{}return F(e,`wx`)}function ze(e,t,n){try{var r=N(e,t)}catch(e){return e.Sa}if(e=F(e,`wx`))return e;if(n){if(!P(r.mode))return 54;if(r===r.parent||Pe(r)===`/`)return 10}else if(P(r.mode))return 31;return 0}function Be(e){if(!e)throw new j(63);return e}function I(e){if(e=k[e],!e)throw new j(8);return e}function Ve(e,t=-1){if(e=Object.assign(new Me,e),t==-1)a:{for(t=0;t<=4096;t++)if(!k[t])break a;throw new j(33)}return e.ib=t,k[t]=e}function He(e,t=-1){return e=Ve(e,t),e.Qa?.Jc?.(e),e}function Ue(e,t,n){var r=e?.Qa.eb;e=r?e:t,r??=t.Ra.eb,Be(r);try{r(e,n)}catch(e){throw e instanceof RangeError?new j(22):e}}var We={open(e){e.Qa=De[e.node.sb].Qa,e.Qa.open?.(e)},bb(){throw new j(70)}};function Ge(e,t){De[e]={Qa:t}}function Ke(e,t){var n=t===`/`;if(n&&O)throw new j(10);if(!n&&t){var r=M(t,{Gb:!1});if(t=r.path,r=r.node,r.nb)throw new j(10);if(!P(r.mode))throw new j(54)}t={type:e,Nc:{},Yb:t,xc:[]},e=e.hb(t),e.hb=t,t.root=e,n?O=e:r&&(r.nb=t,r.hb&&r.hb.xc.push(t))}function qe(e,t,n){var r=M(e,{parent:!0}).node;if(e=w(e),!e)throw new j(28);if(e===`.`||e===`..`)throw new j(20);var i=Re(r,e);if(i)throw new j(i);if(!r.Ra.wb)throw new j(63);return r.Ra.wb(r,e,t,n)}function Je(e,t=438){return qe(e,t&4095|32768,0)}function L(e,t=511){return qe(e,t&1023|16384,0)}function Ye(e,t,n){n===void 0&&(n=t,t=438),qe(e,t|8192,n)}function Xe(e,t){if(!he(e))throw new j(44);var n=M(t,{parent:!0}).node;if(!n)throw new j(44);t=w(t);var r=Re(n,t);if(r)throw new j(r);if(!n.Ra.Cb)throw new j(63);n.Ra.Cb(n,t,e)}function Ze(e){var t=M(e,{parent:!0}).node;e=w(e);var n=N(t,e),r=ze(t,e,!0);if(r)throw new j(r);if(!t.Ra.Ab)throw new j(63);if(n.nb)throw new j(10);t.Ra.Ab(t,e),Ie(n)}function Qe(e){var t=M(e,{parent:!0}).node;if(!t)throw new j(44);e=w(e);var n=N(t,e),r=ze(t,e,!1);if(r)throw new j(r);if(!t.Ra.Db)throw new j(63);if(n.nb)throw new j(10);t.Ra.Db(t,e),Ie(n)}function $e(e,t=!1){return e=M(e,{mb:!t}).node,Be(e.Ra.$a)(e)}function et(e,t,n){Ue(e,t,{mode:n&4095|t.mode&-4096,Xa:Date.now(),Sb:!1})}function tt(e,t){e=typeof e==`string`?M(e,{mb:!0}).node:e,et(null,e,t)}function nt(e,t,n){if(P(t.mode))throw new j(31);if((t.mode&61440)!=32768)throw new j(28);var r=F(t,`w`);if(r)throw new j(r);Ue(e,t,{size:n,timestamp:Date.now()})}function rt(e,t,n,r=!1){e=M(e,{mb:!r}),Ue(null,e.node,{gb:t,Ya:n,Sb:r})}function R(e,t,n=438){if(e===``)throw new j(44);if(typeof t==`string`){var r={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090}[t];if(r===void 0)throw Error(`Unknown file open mode: ${t}`);t=r}if(n=t&64?n&4095|32768:0,typeof e==`object`)r=e;else{var i=e.endsWith(`/`);e=M(e,{mb:!(t&131072),zc:!0}),r=e.node,e=e.path}var a=!1;if(t&64){if(r){if(t&128)throw new j(20)}else{if(i)throw new j(31);r=qe(e,n|511,0),a=!0}}if(!r)throw new j(44);if((r.mode&61440)==8192&&(t&=-513),t&65536&&!P(r.mode))throw new j(54);if(!a&&(r?(r.mode&61440)==40960?i=32:(i=[`r`,`w`,`rw`][t&3],t&512&&(i+=`w`),i=P(r.mode)&&(i!==`r`||t&576)?31:F(r,i)):i=44,i))throw new j(i);return t&512&&!a&&(i=r,i=typeof i==`string`?M(i,{mb:!0}).node:i,nt(null,i,0)),t&=-131713,i=Ve({node:r,path:Pe(r),flags:t,seekable:!0,position:0,Qa:r.Qa,Cc:[],error:!1}),i.Qa.open&&i.Qa.open(i),a&&tt(r,n&511),!o.logReadFiles||t&1||e in je||(je[e]=1,h(`read file: ${e}`)),i}function it(e){if(e.ib===null)throw new j(8);e.Jb&&=null,e.node?.Ac();try{e.Qa.close&&e.Qa.close(e)}catch(e){throw e}finally{k[e.ib]=null}e.ib=null}function at(e,t,n){if(e.ib===null)throw new j(8);if(!e.seekable||!e.Qa.bb)throw new j(70);if(n!=0&&n!=1&&n!=2)throw new j(28);e.position=e.Qa.bb(e,t,n),e.Cc=[]}function ot(e,t,n,r,i){if(r<0||i<0)throw new j(28);if(e.ib===null||!(e.flags&2097155))throw new j(8);if(P(e.node.mode))throw new j(31);if(!e.Qa.write)throw new j(28);e.seekable&&e.flags&1024&&at(e,0,2);var a=i!==void 0;if(!a)i=e.position;else if(!e.seekable)throw new j(70);return t=e.Qa.write(e,t,n,r,i,void 0),a||(e.position+=t),t}function st(){var e,t,n;ke=!0,e??=o.stdin,t??=o.stdout,n??=o.stderr,e?z(`stdin`,e):Xe(`/dev/tty`,`/dev/stdin`),t?z(`stdout`,null,t):Xe(`/dev/tty`,`/dev/stdout`),n?z(`stderr`,null,n):Xe(`/dev/tty1`,`/dev/stderr`),R(`/dev/stdin`,0),R(`/dev/stdout`,1),R(`/dev/stderr`,1)}function ct(e,t){var n=`/`,r=e;n&&(n=typeof n==`string`?n:Pe(n),r=e?pe(n+`/`+e):n),e=_e(!0,!0),r=Je(r,e),t&&(typeof t==`string`&&(t=ge(t)),t.subarray||(t=new Uint8Array(t)),tt(r,e|146),n=R(r,577),ot(n,t,0,t.length,0),it(n),tt(r,e))}function z(e,t,n){e=pe(`/dev/`+e);var r=_e(!!t,!!n);z.Xb??=64;var i=z.Xb++<<8;Ge(i,{open(e){e.seekable=!1},close(){n?.buffer?.length&&n(10)},read(e,n,r,i){for(var a=0,o=0;o<i;o++){try{var s=t()}catch{throw new j(29)}if(s===void 0&&!a)throw new j(6);if(s==null)break;a++,n[r+o]=s}return a&&(e.node.gb=Date.now()),a},write(e,t,r,i){for(var a=0;a<i;a++)try{n(t[r+a])}catch{throw new j(29)}return i&&(e.node.Ya=e.node.Xa=Date.now()),a}}),Ye(e,r,i)}var B={},V,H,U;function W(e,t,n=!1){if(t.charAt(0)===`/`)return t;if(e=e===-100?`/`:I(e).path,t.length==0){if(!n)throw new j(44);return e}return e+`/`+t}function lt(e,t){U[e>>2]=t.kc,U[e+4>>2]=t.mode,U[e+8>>2]=t.yc,U[e+12>>2]=t.uid,U[e+16>>2]=t.uc,U[e+20>>2]=t.sb,H[e+24>>3]=BigInt(t.size),V[e+32>>2]=4096,V[e+36>>2]=t.fc;var n=t.gb.getTime(),r=t.Ya.getTime(),i=t.Xa.getTime();return H[e+40>>3]=BigInt(Math.floor(n/1e3)),U[e+48>>2]=n%1e3*1e3*1e3,H[e+56>>3]=BigInt(Math.floor(r/1e3)),U[e+64>>2]=r%1e3*1e3*1e3,H[e+72>>3]=BigInt(Math.floor(i/1e3)),U[e+80>>2]=i%1e3*1e3*1e3,H[e+88>>3]=BigInt(t.vc),0}var ut=void 0,dt,ft=()=>{var e=V[ut>>2];return ut+=4,e},pt=0,mt=[0,31,60,91,121,152,182,213,244,274,305,335],ht=[0,31,59,90,120,151,181,212,243,273,304,334],gt=e=>{if(!(e instanceof se||e==`unwind`))throw e},_t=e=>{throw ee=e,x||pt>0||(o.onExit?.(e),_=!0),new se(e)},vt={},yt={},bt=()=>{if(!xt){var e={USER:`web_user`,LOGNAME:`web_user`,PATH:`/`,PWD:`/`,HOME:`/home/web_user`,LANG:(globalThis.navigator?.language??`C`).replace(`-`,`_`)+`.UTF-8`,_:l},t;for(t in yt)yt[t]===void 0?delete e[t]:e[t]=yt[t];var n=[];for(t in e)n.push(`${t}=${e[t]}`);xt=n}return xt},xt,St,Ct;function wt(e){var t=`i32`;switch(t.endsWith(`*`)&&(t=`*`),t){case`i1`:b[e]=0;break;case`i8`:b[e]=0;break;case`i16`:dt[e>>1]=0;break;case`i32`:V[e>>2]=0;break;case`i64`:H[e>>3]=BigInt(0);break;case`float`:St[e>>2]=0;break;case`double`:Ct[e>>3]=0;break;case`*`:U[e>>2]=0;break;default:v(`invalid type for setValue: ${t}`)}}function G(e,t=`i8`){switch(t.endsWith(`*`)&&(t=`*`),t){case`i1`:return b[e];case`i8`:return b[e];case`i16`:return dt[e>>1];case`i32`:return V[e>>2];case`i64`:return H[e>>3];case`float`:return St[e>>2];case`double`:return Ct[e>>3];case`*`:return U[e>>2];default:v(`invalid type for getValue: ${t}`)}}var Tt=(e,t,n,r)=>{var i={string:e=>{var t=0;if(e!=null&&e!==0){t=T(e)+1;var n=Z(t);E(e,S,n,t),t=n}return t},array:e=>{var t=Z(e.length);return b.set(e,t),t}};e=o[`_`+e];var a=[],s=0;if(r)for(var c=0;c<r.length;c++){var l=i[n[c]];l?(s||=Q(),a[c]=l(r[c])):a[c]=r[c]}return n=e(...a),n=function(e){return s&&Pt(s),t===`string`?C(e):t===`boolean`?!!e:e}(n)},K=e=>{var t=T(e)+1,n=jt(t);return n&&E(e,S,n,t),n},Et=[],q,Dt=e=>{q.delete($.get(e)),$.set(e,null),Et.push(e)},Ot=e=>{var t=e.length;return[t%128|128,t>>7,...e]},kt={i:127,p:127,j:126,f:125,d:124,e:111},At=e=>Ot(Array.from(e,e=>kt[e])),J=(e,t)=>{if(!q){q=/* @__PURE__ */ new WeakMap;var n=$.length;if(q)for(var r=0;r<0+n;r++){var i=$.get(r);i&&q.set(i,r)}}if(n=q.get(e)||0)return n;n=Et.length?Et.pop():$.grow(1);try{$.set(n,e)}catch(r){if(!(r instanceof TypeError))throw r;t=Uint8Array.of(0,97,115,109,1,0,0,0,1,...Ot([1,96,...At(t.slice(1)),...At(t[0]===`v`?``:t[0])]),2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0),t=new WebAssembly.Module(t),t=new WebAssembly.Instance(t,{e:{f:e}}).exports.f,$.set(n,t)}return q.set(e,n),n};A.length=4096,Ke(D,`/`),L(`/tmp`),L(`/home`),L(`/home/web_user`),(function(){L(`/dev`),Ge(259,{read:()=>0,write:(e,t,n,r)=>r,bb:()=>0}),Ye(`/dev/null`,259),xe(1280,Ce),xe(1536,we),Ye(`/dev/tty`,1280),Ye(`/dev/tty1`,1536);var e=/* @__PURE__ */ new Uint8Array(1024),t=0,n=()=>(t||=(Ee(e),e.byteLength),e[--t]);z(`random`,n),z(`urandom`,n),L(`/dev/shm`),L(`/dev/shm/tmp`)})(),(function(){L(`/proc`);var e=L(`/proc/self`);L(`/proc/self/fd`),Ke({hb(){var t=Le(e,`fd`,16895,73);return t.Qa={bb:D.Qa.bb},t.Ra={rb(e,t){e=+t;var n=I(e);return e={parent:null,hb:{Yb:`fake`},Ra:{kb:()=>n.path},id:e+1},e.parent=e},Nb(){return Array.from(k.entries()).filter(([,e])=>e).map(([e])=>e.toString())}},t}},`/proc/self/fd`)})(),o.noExitRuntime&&(x=o.noExitRuntime),o.print&&(m=o.print),o.printErr&&(h=o.printErr),o.wasmBinary&&(g=o.wasmBinary),o.thisProgram&&(l=o.thisProgram);var Y=o.preInit;if(Y)for(typeof Y==`function`&&(o.preInit=Y=[Y]);Y.length>0;)Y.shift()();o.stackSave=()=>Q(),o.stackRestore=e=>Pt(e),o.stackAlloc=e=>Z(e),o.cwrap=(e,t,n,r)=>{var i=!n||n.every(e=>e===`number`||e===`boolean`);return t!==`string`&&i&&!r?o[`_`+e]:(...r)=>Tt(e,t,n,r)},o.addFunction=J,o.removeFunction=Dt,o.UTF8ToString=C,o.lengthBytesUTF8=T,o.stringToNewUTF8=K,o.writeArrayToMemory=(e,t)=>{b.set(e,t)};var jt,X,Mt,Nt,Pt,Z,Q,Ft,$,It={a:(e,t,n,r)=>v(`Assertion failed: ${C(e)}, at: `+[t?C(t):`unknown filename`,n,r?C(r):`unknown function`]),i:function(e,t){try{return e=C(e),tt(e,t),0}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},D:function(e,t,n){try{if(t=C(t),t=W(e,t),n&-8)return-28;var r=M(t,{mb:!0}).node;return r?(e=``,n&4&&(e+=`r`),n&2&&(e+=`w`),n&1&&(e+=`x`),e&&F(r,e)?-2:0):-44}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},j:function(e,t){try{var n=I(e);return et(n,n.node,t),0}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},h:function(e){try{var t=I(e);return Ue(t,t.node,{timestamp:Date.now(),Sb:!1}),0}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},b:function(e,t,n){ut=n;try{var r=I(e);switch(t){case 0:var i=ft();if(i<0)break;for(;k[i];)i++;return He(r,i).ib;case 1:case 2:return 0;case 3:return r.flags;case 4:return i=ft(),r.flags=r.flags&-289793|i&289792,0;case 12:return i=ft(),dt[i+0>>1]=2,0;case 13:case 14:return 0}return-28}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},g:function(e,t){try{var n=I(e),r=n.node,i=n.Qa.$a;return e=i?n:r,i??=r.Ra.$a,Be(i),lt(t,i(e))}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},J:function(e,t){t=t<-9007199254740992||t>9007199254740992?NaN:Number(t);try{if(isNaN(t))return-22;var n=I(e);if(t<0||!(n.flags&2097155))throw new j(28);return nt(n,n.node,t),0}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},I:function(e,t){try{if(!t)return-28;var n=T(`/`)+1;return t<n?-68:(E(`/`,S,e,t),n)}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},F:()=>0,M:function(e,t){try{return e=C(e),lt(t,$e(e,!0))}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},C:function(e,t,n){try{return t=C(t),t=W(e,t),L(t,n&-19),0}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},L:function(e,t,n,r){try{t=C(t);var i=r&256;return t=W(e,t,r&4096),lt(n,i?$e(t,!0):$e(t))}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},x:function(e,t,n,r){ut=r;try{t=C(t),t=W(e,t);var i=r?ft():0;return n&64&&(i&=-19),R(t,n,i).ib}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},s:function(e,t,n,r){try{if(t=C(t),t=W(e,t),r<=0)return-28;var i=M(t).node;if(!i)throw new j(44);if(!i.Ra.kb)throw new j(28);var a=i.Ra.kb(i),o=Math.min(r,T(a)),s=b[n+o];return E(a,S,n,r+1),b[n+o]=s,o}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},r:function(e){try{return e=C(e),Ze(e),0}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},N:function(e,t){try{return e=C(e),lt(t,$e(e))}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},o:function(e,t,n){try{if(t=C(t),t=W(e,t),n){if(n===512)Ze(t);else return-28}else Qe(t);return 0}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},n:function(e,t,n,r){try{r&=256,t=C(t),t=W(e,t,!0);var i=Date.now();if(n){function e(e){var t=V[e+8>>2];return t==1073741823?i:t==1073741822?null:(U[e>>2]+V[e+4>>2]*4294967296)*1e3+Math.floor(t/1e6)}var a=e(n),o=e(n+16)}else o=a=i;return(o??a)!==null&&rt(t,a,o,r),0}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},w:()=>v(``),v:()=>{x=!1,pt=0},A:function(e,t){if(e=e<-9007199254740992||e>9007199254740992?NaN:Number(e),e=/* @__PURE__ */ new Date(e*1e3),isNaN(e.getTime()))return 1;V[t>>2]=e.getSeconds(),V[t+4>>2]=e.getMinutes(),V[t+8>>2]=e.getHours(),V[t+12>>2]=e.getDate(),V[t+16>>2]=e.getMonth(),V[t+20>>2]=e.getFullYear()-1900,V[t+24>>2]=e.getDay();var n=e.getFullYear();V[t+28>>2]=(n%4!=0||n%100==0&&n%400!=0?ht:mt)[e.getMonth()]+e.getDate()-1|0,V[t+36>>2]=-(e.getTimezoneOffset()*60),n=new Date(e.getFullYear(),6,1).getTimezoneOffset();var r=new Date(e.getFullYear(),0,1).getTimezoneOffset();return V[t+32>>2]=(n!=r&&e.getTimezoneOffset()==Math.min(r,n))|0,0},y:function(e,t,n,r,i,a,o){i=i<-9007199254740992||i>9007199254740992?NaN:Number(i);try{var s=I(r);if(t&2&&!(n&2)&&(s.flags&2097155)!=2||(s.flags&2097155)==1)throw new j(2);if(!s.Qa.xb)throw new j(43);if(!e)throw new j(28);var c=s.Qa.xb(s,e,i,t,n),l=c.Bc;return V[a>>2]=c.$b,U[o>>2]=l,0}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},z:function(e,t,n,r,i,a){a=a<-9007199254740992||a>9007199254740992?NaN:Number(a);try{var o=I(i);if(n&2){if((o.node.mode&61440)!=32768)throw new j(43);r&2||o.Qa.yb&&o.Qa.yb(o,S.subarray(e,e+t),a,t,r)}}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return-e.Sa}},k:(e,t)=>(vt[e]&&(clearTimeout(vt[e].id),delete vt[e]),t&&(vt[e]={id:setTimeout(()=>{delete vt[e];var t=[e,performance.now()],n=Nt;if(!_)try{n(...t)}catch(e){gt(e)}finally{if(!(x||pt>0))try{ee=t=ee,_t(t)}catch(e){gt(e)}}},t),Oc:t}),0),B:(e,t,n,r)=>{var i=(/* @__PURE__ */ new Date()).getFullYear(),a=new Date(i,0,1).getTimezoneOffset();i=new Date(i,6,1).getTimezoneOffset(),U[e>>2]=Math.max(a,i)*60,V[t>>2]=Number(a!=i),t=e=>{var t=Math.abs(e);return`UTC${e>=0?`-`:`+`}${String(Math.floor(t/60)).padStart(2,`0`)}${String(t%60).padStart(2,`0`)}`},e=t(a),t=t(i),i<a?(E(e,S,n,17),E(t,S,r,17)):(E(e,S,r,17),E(t,S,n,17))},d:()=>Date.now(),p:()=>2147483648,c:()=>performance.now(),l:e=>{var t=S.length;if(e>>>=0,e>2147483648)return!1;for(var n=1;n<=4;n*=2){var r=t*(1+.2/n);r=Math.min(r,e+100663296);a:{r=(Math.min(2147483648,Math.ceil(Math.max(e,r)/65536)*65536)-Ft.buffer.byteLength+65535)/65536|0;try{Ft.grow(r),te();var i=1;break a}catch{}i=void 0}if(i)return!0}return!1},G:(e,t)=>{var n=0,r=0,i;for(i of bt()){var a=t+n;U[e+r>>2]=a,n+=E(i,S,a,1/0)+1,r+=4}return 0},H:(e,t)=>{var n=bt();U[e>>2]=n.length,e=0;for(var r of n)e+=T(r)+1;return U[t>>2]=e,0},e:function(e){try{return it(I(e)),0}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return e.Sa}},m:function(e,t){try{var n=I(e);return b[t]=n.Za?2:P(n.mode)?3:(n.mode&61440)==40960?7:4,dt[t+2>>1]=0,H[t+8>>3]=BigInt(0),H[t+16>>3]=BigInt(0),0}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return e.Sa}},t:function(e,t,n,r){try{a:{var i=I(e);e=t;for(var a,o=t=0;o<n;o++){var s=U[e>>2],c=U[e+4>>2];e+=8;try{var l=i,u=s,d=c,f=a,p=b;if(d<0||f<0)throw new j(28);if(l.ib===null||(l.flags&2097155)==1)throw new j(8);if(P(l.node.mode))throw new j(31);if(!l.Qa.read)throw new j(28);var m=f!==void 0;if(!m)f=l.position;else if(!l.seekable)throw new j(70);var h=l.Qa.read(l,p,u,d,f);m||(l.position+=h);var g=h}catch(e){if(t>0&&e instanceof j&&(e.Sa==6||e.Sa==6))break;throw e}if(g<0){var _=-1;break a}if(t+=g,g<c)break;a!==void 0&&(a+=g)}_=t}return U[r>>2]=_,0}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return e.Sa}},E:function(e,t,n,r){t=t<-9007199254740992||t>9007199254740992?NaN:Number(t);try{if(isNaN(t))return 22;var i=I(e);return at(i,t,n),H[r>>3]=BigInt(i.position),i.Jb&&!t&&n===0&&(i.Jb=null),0}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return e.Sa}},K:function(e){try{var t=I(e);return t.Qa?.qb?.(t)}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return e.Sa}},q:function(e,t,n,r){try{var i=I(e);if(e=t,n==1)var a=ot(i,b,U[e>>2],U[e+4>>2]);else{for(var o=t=0,s=e;o<n;o++,s+=8)t+=U[s+4>>2];var c=new Uint8Array(t);for(o=s=0;o<n;o++,e+=8){var l=U[e>>2],u=U[e+4>>2];c.set(S.subarray(l,l+u),s),s+=u}a=ot(i,c,0,t)}return U[r>>2]=a,0}catch(e){if(B===void 0||e.name!==`ErrnoError`)throw e;return e.Sa}},u:_t,f:function(e){console.warn(`sql.js: legacy function `+C(e)+`() is deprecated and will be disabled by default in the next major version. Initialize with useOldExtensionFunctions: false to use native SQLite functions. See https://github.com/sql-js/sql.js/pull/647`)}};async function Lt(){ne();var e=o.setStatus;e&&(e(`Running...`),await new Promise(e=>setTimeout(e,1)),setTimeout(e,1,``)),_||(o.noFSInit||ke||st(),Rt.P(),Ae=!1,o.onRuntimeInitialized?.(),re())}var Rt;return(async function(){function e(e){return e=Rt=e.exports,o._sqlite3_free=e.R,o._sqlite3_value_text=e.S,o._sqlite3_prepare_v2=e.T,o._sqlite3_step=e.U,o._sqlite3_reset=e.V,o._sqlite3_exec=e.W,o._sqlite3_finalize=e.X,o._sqlite3_column_name=e.Y,o._sqlite3_column_text=e.Z,o._sqlite3_column_type=e._,o._sqlite3_errmsg=e.$,o._sqlite3_backup_init=e.aa,o._sqlite3_backup_step=e.ba,o._sqlite3_backup_finish=e.ca,o._sqlite3_clear_bindings=e.da,o._sqlite3_value_blob=e.ea,o._sqlite3_value_bytes=e.fa,o._sqlite3_value_double=e.ga,o._sqlite3_value_int=e.ha,o._sqlite3_value_type=e.ia,o._sqlite3_result_blob=e.ja,o._sqlite3_result_double=e.ka,o._sqlite3_result_error=e.la,o._sqlite3_result_int=e.ma,o._sqlite3_result_int64=e.na,o._sqlite3_result_null=e.oa,o._sqlite3_result_text=e.pa,o._sqlite3_aggregate_context=e.qa,o._sqlite3_column_count=e.ra,o._sqlite3_data_count=e.sa,o._sqlite3_column_blob=e.ta,o._sqlite3_column_bytes=e.ua,o._sqlite3_column_double=e.va,o._sqlite3_bind_blob=e.wa,o._sqlite3_bind_double=e.xa,o._sqlite3_bind_int=e.ya,o._sqlite3_bind_text=e.za,o._sqlite3_bind_parameter_index=e.Aa,o._sqlite3_sql=e.Ba,o._sqlite3_normalized_sql=e.Ca,o._sqlite3_changes=e.Da,o._sqlite3_close_v2=e.Ea,o._sqlite3_create_function_v2=e.Fa,o._sqlite3_update_hook=e.Ga,o._sqlite3_open=e.Ha,jt=o._malloc=e.Ia,X=o._free=e.Ja,o._RegisterExtensionFunctions=e.Ka,Mt=e.La,Nt=e.Ma,Pt=e.Na,Z=e.Oa,Q=e.Pa,Ft=e.O,$=e.Q,te(),Rt}var t={a:It},n=o.instantiateWasm;return n?new Promise(r=>{n(t,t=>r(e(t)))}):(y??=o.locateFile?o.locateFile(`sql-wasm-browser.wasm`,d):d+`sql-wasm-browser.wasm`,function(t){return e(t.instance)}(await oe(t)))})().then(()=>Lt()),i}),n)};typeof e==`object`&&typeof t==`object`?(t.exports=r,t.exports.default=r):typeof define==`function`&&define.amd?define([],function(){return r}):typeof e==`object`&&(e.Module=r)})))(),1),r=new URL(`sql-wasm-CXIAVl5-.wasm`,import.meta.url).href,i={commands:[{name:`sqlite3`,summary:`query a SQLite database file`,usage:`sqlite3 [-header] file.db "SQL" (or pipe SQL in; .tables and .schema work)`,async run(e){let t=e.args.includes(`-header`),i=e.args.filter(e=>e!==`-header`),a=i[0],o=(i.slice(1).join(` `)||e.stdin).trim();if(!a||!o)throw Error(`usage: sqlite3 [-header] file.db "SQL"`);if(o===`.tables`)o=`SELECT name FROM sqlite_master WHERE type IN ('table','view') ORDER BY name`;else if(o.startsWith(`.schema`))o=`SELECT sql FROM sqlite_master WHERE sql IS NOT NULL ORDER BY name`;else if(o.startsWith(`.`))throw Error(`unsupported dot-command: ${o.split(` `)[0]}`);let s=await(0,n.default)({locateFile:()=>r}),c=e.path(a),l=await e.os.fs.readFile(c).catch(()=>null),u=new s.Database(l??void 0);try{for(let n of u.exec(o)){t&&e.out(n.columns.join(`|`)+`
3
+ `);for(let t of n.values)e.out(t.map(e=>e===null?``:e instanceof Uint8Array?`<blob ${e.length}>`:String(e)).join(`|`)+`
4
+ `)}(u.getRowsModified()>0||!l||/^\s*(create|drop|alter|insert|update|delete|replace|vacuum)/i.test(o))&&await e.os.fs.writeFile(c,u.export())}finally{u.close()}}}]};export{i as default};
@@ -0,0 +1 @@
1
+ import{S as e,d as t,p as n,v as r}from"./main-VEpSfsM_.js";var i=Uint8Array,a=Uint16Array,o=Int32Array,s=new i([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),c=new i([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),l=new i([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),u=function(e,t){for(var n=new a(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new o(n[30]),r=1;r<30;++r)for(var s=n[r];s<n[r+1];++s)i[s]=s-n[r]<<5|r;return{b:n,r:i}},d=u(s,2),f=d.b,p=d.r;f[28]=258,p[258]=28;for(var m=u(c,0),h=m.b,g=m.r,_=new a(32768),v=0;v<32768;++v){var y=(v&43690)>>1|(v&21845)<<1;y=(y&52428)>>2|(y&13107)<<2,y=(y&61680)>>4|(y&3855)<<4,_[v]=((y&65280)>>8|(y&255)<<8)>>1}for(var b=(function(e,t,n){for(var r=e.length,i=0,o=new a(t);i<r;++i)e[i]&&++o[e[i]-1];var s=new a(t);for(i=1;i<t;++i)s[i]=s[i-1]+o[i-1]<<1;var c;if(n){c=new a(1<<t);var l=15-t;for(i=0;i<r;++i)if(e[i])for(var u=i<<4|e[i],d=t-e[i],f=s[e[i]-1]++<<d,p=f|(1<<d)-1;f<=p;++f)c[_[f]>>l]=u}else for(c=new a(r),i=0;i<r;++i)e[i]&&(c[i]=_[s[e[i]-1]++]>>15-e[i]);return c}),x=new i(288),v=0;v<144;++v)x[v]=8;for(var v=144;v<256;++v)x[v]=9;for(var v=256;v<280;++v)x[v]=7;for(var v=280;v<288;++v)x[v]=8;for(var S=new i(32),v=0;v<32;++v)S[v]=5;var C=/*#__PURE__*/ b(x,9,0),w=/*#__PURE__*/ b(x,9,1),T=/*#__PURE__*/ b(S,5,0),ee=/*#__PURE__*/ b(S,5,1),E=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},D=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},O=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},te=function(e){return(e+7)/8|0},ne=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new i(e.subarray(t,n))},k=[`unexpected EOF`,`invalid block type`,`invalid length/literal`,`invalid distance`,`stream finished`,`no stream handler`,,`no callback`,`invalid UTF-8 data`,`extra field too long`,`date not in range 1980-2099`,`filename too long`,`stream finishing`,`invalid zip data`],A=function(e,t,n){var r=Error(t||k[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,A),!n)throw r;return r},j=function(e,t,n,r){var a=e.length,o=r?r.length:0;if(!a||t.f&&!t.l)return n||new i(0);var u=!n,d=u||t.i!=2,p=t.i;u&&(n=new i(a*3));var m=function(e){var t=n.length;if(e>t){var r=new i(Math.max(t*2,e));r.set(n),n=r}},g=t.f||0,_=t.p||0,v=t.b||0,y=t.l,x=t.d,S=t.m,C=t.n,T=a*8;do{if(!y){g=D(e,_,1);var k=D(e,_+1,3);if(_+=3,!k){var j=te(_)+4,M=e[j-4]|e[j-3]<<8,N=j+M;if(N>a){p&&A(0);break}d&&m(v+M),n.set(e.subarray(j,N),v),t.b=v+=M,t.p=_=N*8,t.f=g;continue}if(k==1)y=w,x=ee,S=9,C=5;else if(k==2){var P=D(e,_,31)+257,F=D(e,_+10,15)+4,I=P+D(e,_+5,31)+1;_+=14;for(var L=new i(I),re=new i(19),R=0;R<F;++R)re[l[R]]=D(e,_+R*3,7);_+=F*3;for(var z=E(re),B=(1<<z)-1,V=b(re,z,1),R=0;R<I;){var H=V[D(e,_,B)];_+=H&15;var j=H>>4;if(j<16)L[R++]=j;else{var U=0,W=0;for(j==16?(W=3+D(e,_,3),_+=2,U=L[R-1]):j==17?(W=3+D(e,_,7),_+=3):j==18&&(W=11+D(e,_,127),_+=7);W--;)L[R++]=U}}var G=L.subarray(0,P),K=L.subarray(P);S=E(G),C=E(K),y=b(G,S,1),x=b(K,C,1)}else A(1);if(_>T){p&&A(0);break}}d&&m(v+131072);for(var q=(1<<S)-1,ie=(1<<C)-1,J=_;;J=_){var U=y[O(e,_)&q],Y=U>>4;if(_+=U&15,_>T){p&&A(0);break}if(U||A(2),Y<256)n[v++]=Y;else if(Y==256){J=_,y=null;break}else{var X=Y-254;if(Y>264){var R=Y-257,Z=s[R];X=D(e,_,(1<<Z)-1)+f[R],_+=Z}var Q=x[O(e,_)&ie],$=Q>>4;Q||A(3),_+=Q&15;var K=h[$];if($>3){var Z=c[$];K+=O(e,_)&(1<<Z)-1,_+=Z}if(_>T){p&&A(0);break}d&&m(v+131072);var ae=v+X;if(v<K){var oe=o-K,se=Math.min(K,ae);for(oe+v<0&&A(3);v<se;++v)n[v]=r[oe+v]}for(;v<ae;++v)n[v]=n[v-K]}}t.l=y,t.p=J,t.b=v,t.f=g,y&&(g=1,t.m=S,t.d=x,t.n=C)}while(!g);return v!=n.length&&u?ne(n,0,v):n.subarray(0,v)},M=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8},N=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8,e[r+2]|=n>>16},P=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var o=n.length,s=n.slice();if(!o)return{t:B,l:0};if(o==1){var c=new i(n[0].s+1);return c[n[0].s]=1,{t:c,l:1}}n.sort(function(e,t){return e.f-t.f}),n.push({s:-1,f:25001});var l=n[0],u=n[1],d=0,f=1,p=2;for(n[0]={s:-1,f:l.f+u.f,l,r:u};f!=o-1;)l=n[n[d].f<n[p].f?d++:p++],u=n[d!=f&&n[d].f<n[p].f?d++:p++],n[f++]={s:-1,f:l.f+u.f,l,r:u};for(var m=s[0].s,r=1;r<o;++r)s[r].s>m&&(m=s[r].s);var h=new a(m+1),g=F(n[f-1],h,0);if(g>t){var r=0,_=0,v=g-t,y=1<<v;for(s.sort(function(e,t){return h[t.s]-h[e.s]||e.f-t.f});r<o;++r){var b=s[r].s;if(h[b]>t)_+=y-(1<<g-h[b]),h[b]=t;else break}for(_>>=v;_>0;){var x=s[r].s;h[x]<t?_-=1<<t-h[x]++-1:++r}for(;r>=0&&_;--r){var S=s[r].s;h[S]==t&&(--h[S],++_)}g=t}return{t:new i(h),l:g}},F=function(e,t,n){return e.s==-1?Math.max(F(e.l,t,n+1),F(e.r,t,n+1)):t[e.s]=n},I=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new a(++t),r=0,i=e[0],o=1,s=function(e){n[r++]=e},c=1;c<=t;++c)if(e[c]==i&&c!=t)++o;else{if(!i&&o>2){for(;o>138;o-=138)s(32754);o>2&&(s(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(s(i),--o;o>6;o-=6)s(8304);o>2&&(s(o-3<<5|8208),o=0)}for(;o--;)s(i);o=1,i=e[c]}return{c:n.subarray(0,r),n:t}},L=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},re=function(e,t,n){var r=n.length,i=te(t+2);e[i]=r&255,e[i+1]=r>>8,e[i+2]=e[i]^255,e[i+3]=e[i+1]^255;for(var a=0;a<r;++a)e[i+a+4]=n[a];return(i+4+r)*8},R=function(e,t,n,r,i,o,u,d,f,p,m){M(t,m++,n),++i[256];for(var h=P(i,15),g=h.t,_=h.l,v=P(o,15),y=v.t,w=v.l,ee=I(g),E=ee.c,D=ee.n,O=I(y),te=O.c,ne=O.n,k=new a(19),A=0;A<E.length;++A)++k[E[A]&31];for(var A=0;A<te.length;++A)++k[te[A]&31];for(var j=P(k,7),F=j.t,R=j.l,z=19;z>4&&!F[l[z-1]];--z);var B=p+5<<3,V=L(i,x)+L(o,S)+u,H=L(i,g)+L(o,y)+u+14+3*z+L(k,F)+2*k[16]+3*k[17]+7*k[18];if(f>=0&&B<=V&&B<=H)return re(t,m,e.subarray(f,f+p));var U,W,G,K;if(M(t,m,1+(H<V)),m+=2,H<V){U=b(g,_,0),W=g,G=b(y,w,0),K=y;var q=b(F,R,0);M(t,m,D-257),M(t,m+5,ne-1),M(t,m+10,z-4),m+=14;for(var A=0;A<z;++A)M(t,m+3*A,F[l[A]]);m+=3*z;for(var ie=[E,te],J=0;J<2;++J)for(var Y=ie[J],A=0;A<Y.length;++A){var X=Y[A]&31;M(t,m,q[X]),m+=F[X],X>15&&(M(t,m,Y[A]>>5&127),m+=Y[A]>>12)}}else U=C,W=x,G=T,K=S;for(var A=0;A<d;++A){var Z=r[A];if(Z>255){var X=Z>>18&31;N(t,m,U[X+257]),m+=W[X+257],X>7&&(M(t,m,Z>>23&31),m+=s[X]);var Q=Z&31;N(t,m,G[Q]),m+=K[Q],Q>3&&(N(t,m,Z>>5&8191),m+=c[Q])}else N(t,m,U[Z]),m+=W[Z]}return N(t,m,U[256]),m+W[256]},z=/*#__PURE__*/ new o([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),B=/*#__PURE__*/ new i(0),V=function(e,t,n,r,l,u){var d=u.z||e.length,f=new i(r+d+5*(1+Math.ceil(d/7e3))+l),m=f.subarray(r,f.length-l),h=u.l,_=(u.r||0)&7;if(t){_&&(m[0]=u.r>>3);for(var v=z[t-1],y=v>>13,b=v&8191,x=(1<<n)-1,S=u.p||new a(32768),C=u.h||new a(x+1),w=Math.ceil(n/3),T=2*w,ee=function(t){return(e[t]^e[t+1]<<w^e[t+2]<<T)&x},E=new o(25e3),D=new a(288),O=new a(32),k=0,A=0,j=u.i||0,M=0,N=u.w||0,P=0;j+2<d;++j){var F=ee(j),I=j&32767,L=C[F];if(S[I]=L,C[F]=I,N<=j){var B=d-j;if((k>7e3||M>24576)&&(B>423||!h)){_=R(e,m,0,E,D,O,A,M,P,j-P,_),M=k=A=0,P=j;for(var V=0;V<286;++V)D[V]=0;for(var V=0;V<30;++V)O[V]=0}var H=2,U=0,W=b,G=I-L&32767;if(B>2&&F==ee(j-G))for(var K=Math.min(y,B)-1,q=Math.min(32767,j),ie=Math.min(258,B);G<=q&&--W&&I!=L;){if(e[j+H]==e[j+H-G]){for(var J=0;J<ie&&e[j+J]==e[j+J-G];++J);if(J>H){if(H=J,U=G,J>K)break;for(var Y=Math.min(G,J-2),X=0,V=0;V<Y;++V){var Z=j-G+V&32767,Q=Z-S[Z]&32767;Q>X&&(X=Q,L=Z)}}}I=L,L=S[I],G+=I-L&32767}if(U){E[M++]=268435456|p[H]<<18|g[U];var $=p[H]&31,ae=g[U]&31;A+=s[$]+c[ae],++D[257+$],++O[ae],N=j+H,++k}else E[M++]=e[j],++D[e[j]]}}for(j=Math.max(j,N);j<d;++j)E[M++]=e[j],++D[e[j]];_=R(e,m,h,E,D,O,A,M,P,j-P,_),h||(u.r=_&7|m[_/8|0]<<3,_-=7,u.h=C,u.p=S,u.i=j,u.w=N)}else{for(var j=u.w||0;j<d+h;j+=65535){var oe=j+65535;oe>=d&&(m[_/8|0]=h,oe=d),_=re(m,_+1,e.subarray(j,oe))}u.i=d}return ne(f,0,r+te(_)+l)},H=/*#__PURE__*/ (function(){for(var e=/* @__PURE__ */ new Int32Array(256),t=0;t<256;++t){for(var n=t,r=9;--r;)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e})(),U=function(){var e=-1;return{p:function(t){for(var n=e,r=0;r<t.length;++r)n=H[n&255^t[r]]^n>>>8;e=n},d:function(){return~e}}},W=function(e,t,n,r,a){if(!a&&(a={l:1},t.dictionary)){var o=t.dictionary.subarray(-32768),s=new i(o.length+e.length);s.set(o),s.set(e,o.length),e=s,a.w=o.length}return V(e,t.level==null?6:t.level,t.mem==null?a.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,r,a)},G=function(e,t){var n={};for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n},K=function(e,t){return e[t]|e[t+1]<<8},q=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},ie=function(e,t){return q(e,t)+q(e,t+4)*4294967296},J=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function Y(e,t){return W(e,t||{},0,0)}function X(e,t){return j(e,{i:2},t&&t.out,t&&t.dictionary)}var Z=function(e,t,n,r){for(var a in e){var o=e[a],s=t+a,c=r;Array.isArray(o)&&(c=G(r,o[1]),o=o[0]),ArrayBuffer.isView(o)?n[s]=[o,c]:(n[s+=`/`]=[new i(0),c],Z(o,s,n,r))}},Q=typeof TextEncoder<`u`&&/*#__PURE__*/ new TextEncoder,$=typeof TextDecoder<`u`&&/*#__PURE__*/ new TextDecoder;try{$.decode(B,{stream:!0})}catch{}var ae=function(e){for(var t=``,n=0;;){var r=e[n++],i=(r>127)+(r>223)+(r>239);if(n+i>e.length)return{s:t,r:ne(e,n-1)};i?i==3?(r=((r&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,t+=String.fromCharCode(55296|r>>10,56320|r&1023)):i&1?t+=String.fromCharCode((r&31)<<6|e[n++]&63):t+=String.fromCharCode((r&15)<<12|(e[n++]&63)<<6|e[n++]&63):t+=String.fromCharCode(r)}};function oe(e,t){if(t){for(var n=new i(e.length),r=0;r<e.length;++r)n[r]=e.charCodeAt(r);return n}if(Q)return Q.encode(e);for(var a=e.length,o=new i(e.length+(e.length>>1)),s=0,c=function(e){o[s++]=e},r=0;r<a;++r){if(s+5>o.length){var l=new i(s+8+(a-r<<1));l.set(o),o=l}var u=e.charCodeAt(r);u<128||t?c(u):u<2048?(c(192|u>>6),c(128|u&63)):u>55295&&u<57344?(u=65536+(u&1047552)|e.charCodeAt(++r)&1023,c(240|u>>18),c(128|u>>12&63),c(128|u>>6&63),c(128|u&63)):(c(224|u>>12),c(128|u>>6&63),c(128|u&63))}return ne(o,0,s)}function se(e,t){if(t){for(var n=``,r=0;r<e.length;r+=16384)n+=String.fromCharCode.apply(null,e.subarray(r,r+16384));return n}if($)return $.decode(e);var i=ae(e),a=i.s,n=i.r;return n.length&&A(8),a}var ce=function(e,t){return t+30+K(e,t+26)+K(e,t+28)},le=function(e,t,n){var r=K(e,t+28),i=K(e,t+30),a=se(e.subarray(t+46,t+46+r),!(K(e,t+8)&2048)),o=t+46+r,s=ue(e,o,i,n,q(e,t+20),q(e,t+24),q(e,t+42)),c=s[0],l=s[1],u=s[2];return[K(e,t+10),c,l,a,o+i+K(e,t+32),u]},ue=function(e,t,n,r,i,a,o){var s=i==4294967295,c=a==4294967295,l=o==4294967295,u=t+n,d=s+c+l;if(r&&d){for(;t+4<u;t+=4+K(e,t+2))if(K(e,t)==1)return[s?ie(e,t+4+8*c):i,c?ie(e,t+4):a,l?ie(e,t+4+8*(c+s)):o,1];r<2&&A(13)}return[i,a,o,0]},de=function(e){var t=0;if(e)for(var n in e){var r=e[n].length;r>65535&&A(9),t+=r+4}return t},fe=function(e,t,n,r,i,a,o,s){var c=r.length,l=n.extra,u=s&&s.length,d=de(l);J(e,t,o==null?67324752:33639248),t+=4,o!=null&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(a<0&&8),e[t++]=i&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var f=new Date(n.mtime==null?Date.now():n.mtime),p=f.getFullYear()-1980;if((p<0||p>119)&&A(10),J(e,t,p<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>1),t+=4,a!=-1&&(J(e,t,n.crc),J(e,t+4,a<0?-a-2:a),J(e,t+8,n.size)),J(e,t+12,c),J(e,t+14,d),t+=16,o!=null&&(J(e,t,u),J(e,t+6,n.attrs),J(e,t+10,o),t+=14),e.set(r,t),t+=c,d)for(var m in l){var h=l[m],g=h.length;J(e,t,+m),J(e,t+2,g),e.set(h,t+4),t+=4+g}return u&&(e.set(s,t),t+=u),t},pe=function(e,t,n,r,i){J(e,t,101010256),J(e,t+8,n),J(e,t+10,n),J(e,t+12,r),J(e,t+16,i)};function me(e,t){t||={};var n={},r=[];Z(e,``,n,t);var a=0,o=0;for(var s in n){var c=n[s],l=c[0],u=c[1],d=u.level==0?0:8,f=oe(s),p=f.length,m=u.comment,h=m&&oe(m),g=h&&h.length,_=de(u.extra);p>65535&&A(11);var v=d?Y(l,u):l,y=v.length,b=U();b.p(l),r.push(G(u,{size:l.length,crc:b.d(),c:v,f,m:h,u:p!=s.length||h&&m.length!=g,o:a,compression:d})),a+=30+p+_+y,o+=76+2*(p+_)+(g||0)+y}for(var x=new i(o+22),S=a,C=o-a,w=0;w<r.length;++w){var f=r[w];fe(x,f.o,f,f.f,f.u,f.c.length);var T=30+f.f.length+de(f.extra);x.set(f.c,f.o+T),fe(x,a,f,f.f,f.u,f.c.length,f.o,f.m),a+=16+T+(f.m?f.m.length:0)}return pe(x,a,r.length,C,S),x}function he(e,t){for(var n={},r=e.length-22;q(e,r)!=101010256;--r)(!r||e.length-r>65558)&&A(13);var a=K(e,r+8);if(!a)return{};var o=q(e,r+16),s=q(e,r-20)==117853008;if(s){var c=q(e,r-12);s=q(e,c)==101075792,s&&(a=q(e,c+32),o=q(e,c+48))}for(var l=t&&t.filter,u=0;u<a;++u){var d=le(e,o,s),f=d[0],p=d[1],m=d[2],h=d[3],g=d[4],_=d[5],v=ce(e,_);o=g,(!l||l({name:h,size:p,originalSize:m,compression:f}))&&(f?f==8?n[h]=X(e.subarray(v,v+p),{out:new i(m)}):A(14,`unknown compression type `+f):n[h]=ne(e,v,v+p))}return n}var ge={commands:[{name:`zip`,summary:`create a zip archive`,usage:`zip [-r] archive.zip path…`,async run(e){let{rest:i}=n(e.args),a=i.shift();if(!a||!i.length)throw Error(`usage: zip [-r] archive.zip path…`);let o={};for(let t of i){let n=e.path(t),i=await e.os.fs.stat(n);if(!i)throw Error(`${t}: no such file or directory`);let a=r(n)===`/`?`/`:r(n)+`/`;if(i.kind===`file`)o[n.slice(a.length)]=await e.os.fs.readFile(n);else for await(let t of e.os.fs.walk(n,{signal:e.signal}))t.kind===`file`&&(o[t.path.slice(a.length)]=await e.os.fs.readFile(t.path))}let s=me(o);await e.os.fs.writeFile(e.path(a),s),e.out(`${Object.keys(o).length} files → ${a} (${t(s.length)})\n`)}},{name:`unzip`,summary:`list or extract a zip archive`,usage:`unzip [-l] archive.zip [-d dir]`,async run(t){let n=t.args.indexOf(`-d`),r=t.path(n>=0?t.args[n+1]??`.`:`.`),i=t.args.filter((e,t)=>e!==`-l`&&t!==n&&t!==n+1);if(!i[0])throw Error(`usage: unzip [-l] archive.zip [-d dir]`);let a=he(await t.os.fs.readFile(t.path(i[0]))),o=0;for(let[n,i]of Object.entries(a))n.endsWith(`/`)||(o++,t.args.includes(`-l`)?t.out(`${String(i.length).padStart(10)} ${n}\n`):await t.os.fs.writeFile(e(r,e(`/`,n)),i));t.out(`${o} file${o===1?``:`s`}${t.args.includes(`-l`)?``:` extracted to ${r}`}\n`)}}]};export{ge as default};
@@ -0,0 +1,2 @@
1
+ import{C as e,S as t,_ as n}from"./main-VEpSfsM_.js";import{buildSite as r}from"./build-BNa5TW3M.js";import{GitHub as i,n as a,r as o,t as s}from"./github-Dwhv0h55.js";async function c(e,t,n,r){let i;try{i=await e(t,n)}catch{throw Error(`could not reach ${r} (offline?)`)}let a=await i.json().catch(()=>({}));if(!i.ok){let e=typeof a.error==`string`?a.error:a.error?.message??a.message??i.statusText;throw Error(`${r}: ${e}${i.status===401||i.status===403?` (check the token in Settings → Accounts)`:``}`)}return a}const l=e=>new Promise(t=>setTimeout(t,e));async function u(e,t,n){let r=n.fetcher??fetch,i=`https://api.netlify.com/api/v1`,s={authorization:`Bearer ${e}`},u=n.siteId;u||=(await c(r,`${i}/sites`,{method:`POST`,headers:{...s,"content-type":`application/json`},body:JSON.stringify(n.name?{name:n.name}:{})},`Netlify`)).id;let d=/* @__PURE__ */ new Map;for(let[e,n]of t)d.set(e,await o(n));let f=await c(r,`${i}/sites/${u}/deploys`,{method:`POST`,headers:{...s,"content-type":`application/json`},body:JSON.stringify({files:Object.fromEntries(d)})},`Netlify`),p=new Set(f.required??[]),m=[...t].filter(([e])=>p.has(d.get(e))),h=0;await a(m,4,async([e,t])=>{await c(r,`${i}/deploys/${f.id}/files${e.split(`/`).map(encodeURIComponent).join(`/`)}`,{method:`PUT`,headers:{...s,"content-type":`application/octet-stream`},body:t},`Netlify`),n.progress?.(`uploaded ${++h}/${m.length} ${e}`)});for(let e=0;e<60;e++){let e=await c(r,`${i}/deploys/${f.id}`,{headers:s},`Netlify`);if(e.state===`ready`)return{url:e.ssl_url??e.url,siteId:u,adminUrl:e.admin_url};if(e.state===`error`)throw Error(`Netlify: ${e.error_message??`the deploy failed`}`);n.progress?.(`Netlify: ${e.state}…`),await l(2e3)}throw Error(`Netlify: the deploy did not finish within two minutes; check the Netlify dashboard`)}async function d(e,t,n){let r=n.fetcher??fetch,i=n.team?`?teamId=${encodeURIComponent(n.team)}`:``,s={authorization:`Bearer ${e}`},u=await Promise.all([...t].map(async([e,t])=>({file:e.replace(/^\//,``),data:t,sha:await o(t)}))),d=0;await a(u,4,async e=>{await c(r,`https://api.vercel.com/v2/files${i}`,{method:`POST`,headers:{...s,"content-type":`application/octet-stream`,"x-vercel-digest":e.sha},body:e.data},`Vercel`),n.progress?.(`uploaded ${++d}/${u.length} ${e.file}`)});let f=await c(r,`https://api.vercel.com/v13/deployments${i}`,{method:`POST`,headers:{...s,"content-type":`application/json`},body:JSON.stringify({name:n.name,target:`production`,files:u.map(e=>({file:e.file,sha:e.sha,size:e.data.length})),projectSettings:{framework:null,buildCommand:null,outputDirectory:null}})},`Vercel`);for(let e=0;e<60;e++){let e=await c(r,`https://api.vercel.com/v13/deployments/${f.id}${i}`,{headers:s},`Vercel`);if(e.readyState===`READY`)return{url:`https://${e.alias?.[0]??e.url}`};if(e.readyState===`ERROR`||e.readyState===`CANCELED`)throw Error(`Vercel: ${e.errorMessage??e.readyState.toLowerCase()}`);n.progress?.(`Vercel: ${e.readyState.toLowerCase()}…`),await l(2e3)}throw Error(`Vercel: the deployment did not finish within two minutes; check the Vercel dashboard`)}const f={github:`github.token`,netlify:`netlify.token`,vercel:`vercel.token`},p=[`netlify`,`vercel`,`github-pages`],m=`publish.links`,h=(t,n)=>t.settings.get(m,{})[e(n)]??{};function g(t,n,r){let i=t.settings.get(m,{});i[e(n)]={...i[e(n)],...r},t.settings.set(m,i)}const _={github:`Create a fine-grained token at github.com/settings/personal-access-tokens (Contents, Pull requests, Pages and Administration: read and write, for the repositories you want) and add it in Settings → Accounts, or run gh auth login.`,netlify:`Create a personal access token at app.netlify.com/user/applications and add it in Settings → Accounts.`,vercel:`Create a token at vercel.com/account/tokens and add it in Settings → Accounts.`};async function v(e,t){let n=await e.secrets.get(f[t]);if(!n)throw Error(`No ${t===`github`?`GitHub`:t===`netlify`?`Netlify`:`Vercel`} token yet. ${_[t]}`);return n}const y=async(e,t)=>new i(await v(e,`github`),t);async function b(e,t){let n=/github\.com[/:]([^/]+\/[^/.]+)/.exec(t);return n?n[1]:t.includes(`/`)?t:`${(await e.user()).login}/${t}`}async function x(e,t,r,i=()=>void 0){let a=await y(e,r.fetcher),o=h(e,t).github,c=await b(a,r.repo??o?.repo??n(t));try{await a.repo(c)}catch{let[e,t]=c.split(`/`),n=(await a.user()).login;i(`creating ${c} on GitHub…`),await a.createRepo(t,{private:r.private??!0,org:e===n?void 0:e})}let l=r.branch??o?.branch??(await a.repo(c)).default_branch,u=await s(e.fs,t);i(`${u.size} files in ${t}`);let d=await a.push(c,l,u,r.message??`Update from BrowserBox`,i);return g(e,t,{github:{repo:c,branch:l}}),d?`Pushed to ${c} (${l}): ${d.added} added, ${d.changed} changed, ${d.removed} removed. ${d.url}`:`Nothing to push: ${c} (${l}) already has these files. https://github.com/${c}/tree/${l}`}async function S(e,n,r,i,a={},o=()=>void 0){let s=await y(e,a.fetcher),c=await b(s,n),l=r??t(i,c.split(`/`)[1]);if((await e.fs.readdir(l).catch(()=>[])).length)throw Error(`${l} is not empty`);let{files:u,branch:d}=await s.clone(c,a.branch,o);for(let[n,r]of u)await e.fs.writeFile(t(l,n),r);return g(e,l,{github:{repo:c,branch:d}}),`Cloned ${c} (${d}, ${u.size} files) into ${l}. gh push sends changes back as a commit.`}async function C(e,t,i,a=()=>void 0){let o=h(e,t),s=i.target??o.last;if(!s)throw Error(`Where to? Pass a target: ${p.join(`, `)}.`);a(`building for production…`);let c=await r(e.fs,t);if(c.errors.length)throw Error(`The build failed:\n${c.errors.join(`
2
+ `)}`);let l=c.files;a(`built ${l.size} files`);let f=(i.name??n(t)).toLowerCase().replace(/[^a-z0-9-]+/g,`-`).replace(/^-+|-+$/g,``)||`site`,m;if(s===`netlify`){let n=await u(await v(e,`netlify`),l,{siteId:o.netlify?.siteId,name:o.netlify?void 0:f,fetcher:i.fetcher,progress:a});m=n.url,g(e,t,{netlify:{siteId:n.siteId,url:m},last:s})}else if(s===`vercel`)m=(await d(await v(e,`vercel`),l,{name:o.vercel?.name??f,fetcher:i.fetcher,progress:a})).url,g(e,t,{vercel:{name:o.vercel?.name??f,url:m},last:s});else{let n=await y(e,i.fetcher),r=await b(n,i.repo??o.pages?.repo??o.github?.repo??f);try{await n.repo(r)}catch{a(`creating ${r} on GitHub…`),await n.createRepo(r.split(`/`)[1],{private:!1})}let c=new Map([...l].map(([e,t])=>[e.replace(/^\//,``),t]));c.set(`.nojekyll`,/* @__PURE__ */ new Uint8Array),await n.push(r,`gh-pages`,c,`Deploy from BrowserBox`,a),m=await n.enablePages(r,`gh-pages`),g(e,t,{pages:{repo:r,url:m},last:s})}let _=c.backend?` Note: ${c.backend} (the backend) is not deployed: these hosts serve the static site only.`:``;return{url:m,target:s,files:l.size,note:_}}export{p as DEPLOY_TARGETS,f as TOKENS,S as cloneRepo,C as deployFolder,y as github,h as linksFor,x as pushFolder,b as repoName};
@@ -0,0 +1,7 @@
1
+ import{S as e,u as t}from"./main-VEpSfsM_.js";function n(e){let t=/* @__PURE__ */ new Map,n=[];for(let r=0;r<e.length;r++){let i=e[r],a=/^--?([\w-]+)(?:=(.*))?$/.exec(i);a?a[2]===void 0?e[r+1]!==void 0&&!e[r+1].startsWith(`-`)&&![`private`,`public`,`draft`,`yes`].includes(a[1])?t.set(a[1],e[++r]):t.set(a[1],!0):t.set(a[1],a[2]):n.push(i)}return{opt:t,rest:n}}const r=e=>typeof e==`string`?e:void 0,i=e=>e.os,a=e=>n=>e.out(`${t.dim}${n}${t.reset}\n`),o={name:`gh`,summary:`GitHub: sign in, create and clone repositories, push a folder, open pull requests`,usage:`gh auth login|status|logout · gh repo create <name> [--public] · gh repo clone <owner/repo> [dir] · gh push [dir] [--repo owner/name] [--branch b] [-m msg] · gh pr create --head <branch> --title <t> [--body b] [--base main] [--repo owner/name]`,async run(e){let s=i(e),c=await import(`./publish-CHt_Qrq5.js`),{opt:l,rest:u}=n(e.args),[d=`help`,f,p]=u;if(d===`auth`){if(f===`login`){if(!e.tty)throw Error(`gh auth login needs a terminal; or add the token in Settings → Accounts`);e.out(`Create a fine-grained token at https://github.com/settings/personal-access-tokens
2
+ with Contents, Pull requests, Pages and Administration (read and write) for your repositories.
3
+ `);let n=(await e.tty.readLine(`GitHub token (hidden): `,{secret:!0}))?.trim();if(!n)return 1;let r=await new(await(import(`./github-Dwhv0h55.js`))).GitHub(n).user();return await s.secrets.set(c.TOKENS.github,n),e.out(`${t.green}✓${t.reset} signed in as ${r.login}; the token is stored encrypted\n`)}if(f===`logout`)return await s.secrets.delete(c.TOKENS.github),e.out(`signed out of GitHub
4
+ `);let n=await(await c.github(s)).user();return e.out(`signed in to GitHub as ${t.bold}${n.login}${t.reset}${n.name?` (${n.name})`:``}\n`)}if(d===`repo`&&f===`create`){if(!p)throw Error(`usage: gh repo create <name> [--public] [--description text]`);let t=await(await c.github(s)).createRepo(p.includes(`/`)?p.split(`/`)[1]:p,{private:!l.has(`public`),description:r(l.get(`description`)),org:p.includes(`/`)?p.split(`/`)[0]:void 0});return e.out(`created ${t.full_name}: ${t.html_url}\n`)}if(d===`repo`&&f===`clone`){if(!p)throw Error(`usage: gh repo clone <owner/repo> [dir]`);e.out(await c.cloneRepo(s,p,u[3]?e.path(u[3]):null,e.shell.cwd,{branch:r(l.get(`branch`))},a(e))+`
5
+ `)}else if(d===`push`){let t=e.path(f??`.`);e.out(await c.pushFolder(s,t,{repo:r(l.get(`repo`)),branch:r(l.get(`branch`)),message:r(l.get(`m`)??l.get(`message`)),private:!l.has(`public`)},a(e))+`
6
+ `)}else{if(d===`pr`&&f===`create`){let t=await c.github(s),n=await c.repoName(t,r(l.get(`repo`))??c.linksFor(s,e.shell.cwd).github?.repo??``),i=r(l.get(`head`)),a=r(l.get(`title`));if(!n.includes(`/`)||!i||!a)throw Error(`usage: gh pr create --head <branch> --title <title> [--body text] [--base main] [--repo owner/name] [--draft]`);let o=await t.createPr(n,{head:i,title:a,base:r(l.get(`base`)),body:r(l.get(`body`)),draft:l.has(`draft`)});return e.out(`opened pull request #${o.number}: ${o.html_url}\n`)}return e.out(`${o.usage.split(` · `).join(`
7
+ `)}\n${t.dim}Uses GitHub's REST API, which works from the browser (git's own protocol does not). A push is one commit with the folder's current files.${t.reset}\n`),d===`help`?0:1}}},s={name:`deploy`,summary:`build a project for production and publish it to Netlify, Vercel or GitHub Pages`,usage:`deploy [dir] --to netlify|vercel|github-pages [--name site-name] [--repo owner/name]`,async run(e){let o=await import(`./publish-CHt_Qrq5.js`),{opt:s,rest:c}=n(e.args),l=r(s.get(`to`)??s.get(`target`));if(l&&!o.DEPLOY_TARGETS.includes(l))throw Error(`--to must be one of: ${o.DEPLOY_TARGETS.join(`, `)}`);let u=await o.deployFolder(i(e),e.path(c[0]??`.`),{target:l,name:r(s.get(`name`)),repo:r(s.get(`repo`))},a(e));e.out(`\n ${t.green}${t.bold}live${t.reset} ${t.cyan}${u.url}${t.reset} ${t.dim}(${u.target}, ${u.files} files)${t.reset}\n${u.note?`${t.yellow}${u.note.trim()}${t.reset}\n`:``}`)}},c={name:`build`,summary:`production build of a project: bundled, minified, ready for any static host`,usage:`build [dir] [--out dist]`,async run(i){let{buildSite:a}=await import(`./build-BNa5TW3M.js`),{opt:o,rest:s}=n(i.args),c=i.path(s[0]??`.`),l=i.path(r(o.get(`out`))??e(c,`dist`)),u=performance.now(),d=await a(i.os.fs,c);if(d.errors.length){for(let e of d.errors)i.err(`error: ${e}\n`);return 1}await i.os.fs.rm(l,{recursive:!0}).catch(()=>void 0);let f=0;for(let[t,n]of d.files)await i.os.fs.writeFile(e(l,t),n),f+=n.length;i.out(`built ${d.files.size} files (${(f/1024).toFixed(1)} KB) into ${l} in ${Math.round(performance.now()-u)} ms\n${d.backend?`${t.yellow}${d.backend} is a backend: static hosts do not run it.${t.reset}\n`:``}`)}};export{c as buildCommand,s as deployCommand,o as ghCommand};
@@ -0,0 +1 @@
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,o)=>(o=n==null?{}:e(i(n)),c(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));export{s as n,l as r,o as t};
@@ -0,0 +1,4 @@
1
+ import{n as e,t}from"./html-R2xYS1Rp.js";import{C as n,S as r,_ as i,h as a,x as o,y as s}from"./main-VEpSfsM_.js";import{t as c}from"./bundle-8opp8__C.js";const l=[`server.ts`,`server.js`,`server.mjs`,`api/index.ts`,`api/index.js`];function u(e){let t=e.replace(/("(?:\\.|[^"\\])*")|\/\/[^\n]*|\/\*[\s\S]*?\*\//g,(e,t)=>t??``).replace(/,(\s*[}\]])/g,`$1`);return JSON.parse(t)}function d(e){let t={};for(let n of e.split(`
2
+ `)){let e=/^\s*(?:export\s+)?([\w.]+)\s*=\s*(.*?)\s*$/.exec(n);e&&!n.trim().startsWith(`#`)&&(t[e[1]]=e[2].replace(/^(['"])(.*)\1$/,`$2`))}return t}const f=(e,t,n=`text/plain; charset=utf-8`)=>({status:e,headers:[[`content-type`,n]],body:new TextEncoder().encode(t)});var p=class{os;#e=/* @__PURE__ */ new Map;constructor(e){this.os=e,e.bus.on(`proc:exit`,({proc:t})=>{for(let[n,r]of this.#e)r.info.pid===t.pid&&(this.#e.delete(n),a(e,`stop`,String(n),{}),this.#t())}),e.bus.on(`fs:change`,({path:e})=>{for(let t of this.#e.values()){if(!o(t.info.root,e))continue;let n=e.slice(t.info.root.length+1);(t.backendInputs.has(e)||l.includes(n)||n===`package.json`||n.startsWith(`.env`))&&(t.backendReady=!1)}})}#t(){this.os.bus.emit(`dev:update`,[...this.#e.values()].map(e=>({...e.info})))}#n(e){let t=this.#e.get(e);if(!t)throw Error(`nothing is serving on port ${e} (see: serve list)`);return t}async start(e){let t=n(e.root);if((await this.os.fs.stat(t))?.kind!==`dir`)throw Error(`${t} is not a folder`);for(let e of this.#e.values())if(e.info.root===t)return{...e.info};let r=e.port??3e3;if(e.port!==void 0&&this.#e.has(r))throw Error(`port ${r} is in use by ${this.#e.get(r).info.root}`);for(;this.#e.has(r);)r++;let i=this.os.procs.spawn({name:`serve :${r}`,kind:`service`,ppid:e.ppid,detail:t});this.os.procs.update(i.pid,{state:`idle`});let a={port:r,root:t,pid:i.pid,url:`http://localhost:${r}/`,backend:await this.#a(t),network:!!e.network};return this.#e.set(r,{info:a,logs:[],seq:0,backendReady:!1,backendInputs:/* @__PURE__ */ new Set,queue:Promise.resolve()}),this.os.log(`dev`,`serving ${t} on :${r}${a.backend?` (backend ${a.backend})`:``}`),this.#t(),{...a}}async stop(e){let t=this.#e.get(e);return t?(this.os.procs.kill(t.info.pid,`stopped`),this.#e.delete(e),a(this.os,`stop`,String(e),{}),this.#t(),!0):!1}async list(){return[...this.#e.values()].map(e=>({...e.info}))}log(e,t){let n=this.#e.get(e);if(n)for(let r of t){let t={seq:++n.seq,t:Date.now(),level:r.level,source:r.source,text:String(r.text).slice(0,8e3)};n.logs.push(t),n.logs.length>500&&n.logs.shift(),this.os.bus.emit(`dev:log`,{port:e,entry:t})}}async logs(e,t={}){let n=this.#n(e).logs.filter(e=>e.seq>(t.after??0));return t.limit?n.slice(-t.limit):n}async#r(e){let t=t=>this.os.fs.readText(r(e,t)).catch(()=>null),[n,i,a,...o]=await Promise.all([t(`package.json`),t(`tsconfig.json`),t(`jsconfig.json`),t(`.env`),t(`.env.development`),t(`.env.local`)]),s=(e,t)=>{if(!e)return null;try{return u(e)}catch(e){throw Error(`${t} is not valid JSON: ${e.message}`)}},c={...this.os.settings.get(`env.vars`,{})};for(let e of o)e&&Object.assign(c,d(e));return{pkg:s(n,`package.json`),tsconfig:s(i??a,i?`tsconfig.json`:`jsconfig.json`),env:c}}async#i(e){return(await this.os.fs.stat(e).catch(()=>null))?.kind===`file`}async#a(e){for(let t of l)if(await this.#i(r(e,t)))return t;return null}async page(a,o=`/`){let s=this.#n(a),l=s.info.root,u=n(decodeURIComponent(o.split(/[?#]/)[0]||`/`)),d=r(l,u),f=null,p=await this.os.fs.stat(d).catch(()=>null);if(p?.kind===`dir`&&await this.#i(r(d,`index.html`)))f=r(d,`index.html`);else if(p?.kind===`file`&&/\.html?$/i.test(d))f=d;else if(await this.#i(`${d}.html`))f=`${d}.html`;else if(p?.kind===`file`){let n=e(d).startsWith(`image/`)?`<img src="${u}" alt="" style="max-width:100%">`:`<pre id="t" style="white-space:pre-wrap;font:13px ui-monospace,monospace"></pre><script>fetch(${JSON.stringify(u)}).then(r=>r.text()).then(t=>document.getElementById('t').textContent=t)<\/script>`,r=`<!doctype html><html><head><meta charset="utf-8"><title>${i(d)}</title></head><body style="margin:0;padding:12px">${n}</body></html>`;return t(this.os.fs,{root:l,htmlPath:null,html:r,path:u,port:a,bundle:async()=>({js:``,css:``,errors:[],warnings:[],inputs:[]})})}!f&&p?.kind!==`file`&&await this.#i(r(l,`index.html`))&&(f=r(l,`index.html`));let m;try{m=await this.#r(l)}catch(e){m={pkg:null,tsconfig:null,env:{}},this.log(a,[{level:`error`,source:`build`,text:e.message}])}let h=Object.fromEntries(Object.entries(m.env).filter(([e])=>/^(VITE_|PUBLIC_)/.test(e))),g=performance.now(),_=await t(this.os.fs,{root:l,htmlPath:f,path:u+(o.includes(`?`)?o.slice(o.indexOf(`?`)):``),port:a,bundle:e=>c({fs:this.os.fs,root:l,entry:e,target:`browser`,env:h,pkg:m.pkg,tsconfig:m.tsconfig})});return this.os.procs.account(s.info.pid,performance.now()-g),_.errors.length&&this.log(a,_.errors.map(e=>({level:`error`,source:`build`,text:e}))),{html:_.html,errors:_.errors}}async request(t,n){let i=this.#n(t),a=i.info.root,c=new URL(n.url,`http://localhost`),l;try{l=decodeURIComponent(c.pathname)}catch{return f(400,`Bad request`)}let u=r(a,l),d=u.slice(a.length).split(`/`).some(e=>e.startsWith(`.`));if(o(a,u)&&!d&&/^(GET|HEAD)$/i.test(n.method)){let t=u;if((await this.os.fs.stat(t).catch(()=>null))?.kind===`dir`&&(t=r(t,`index.html`)),await this.#i(t)){let r=n.method.toUpperCase()===`HEAD`?null:await this.os.fs.readFile(t);return{status:200,headers:[[`content-type`,e(t)+(/^text\/|json|javascript|xml/.test(e(t))?`; charset=utf-8`:``)]],body:r}}}if(i.backendReady||(i.info.backend=await this.#a(a)),i.info.backend){let e=i.queue.then(()=>this.#c(i,n,c));return i.queue=e.catch(()=>void 0),e}return this.log(t,[{level:`warn`,source:`network`,text:`${n.method} ${n.url} → 404 (no such file${s(l)?``:`, and no backend: add server.ts to answer requests`})`}]),f(404,`Not found: ${l}`)}async#o(e){let{root:t,port:n,pid:i,network:o}=e.info,s=await this.#r(t),l=await c({fs:this.os.fs,root:t,entry:r(t,e.info.backend),target:`server`,env:s.env,pkg:s.pkg,tsconfig:s.tsconfig});if(e.backendInputs=new Set(l.inputs),l.errors.length)return`The backend (${e.info.backend}) failed to build:\n\n${l.errors.join(`
3
+
4
+ `)}`;let u=await a(this.os,`load`,String(n),{code:l.js,env:s.env,network:o,ppid:i},{cwd:t,onStdout:e=>this.#s(n,`log`,e),onStderr:e=>this.#s(n,`error`,e)});return u.ok?(e.backendReady=!0,this.os.log(`dev`,`:${n} backend ${e.info.backend} loaded`),null):`The backend (${e.info.backend}) failed to start: ${u.error??u.stderr}`}#s(e,t,n){let r=n.replace(/\n$/,``);r&&this.log(e,[{level:t,source:`server`,text:r}])}async#c(e,t,n){let{port:r,root:i}=e.info,o=e=>(this.log(r,[{level:`error`,source:`server`,text:e}]),f(500,e));for(let s=0;s<2;s++){if(!e.backendReady){let t=await this.#o(e);if(t)return o(t)}let s=performance.now(),c=await a(this.os,`request`,String(r),{req:t,origin:`http://localhost:${r}`},{cwd:i,onStdout:e=>this.#s(r,`log`,e),onStderr:e=>this.#s(r,`error`,e)});if(this.os.procs.account(e.info.pid,performance.now()-s),c.error===`backend not loaded`){e.backendReady=!1;continue}if(c.error)return o(`${t.method} ${n.pathname}: ${c.error}`);let l=c.response;return l?(l.status>=400&&this.log(r,[{level:l.status>=500?`error`:`warn`,source:`network`,text:`${t.method} ${t.url} → ${l.status}`}]),l):(this.log(r,[{level:`warn`,source:`network`,text:`${t.method} ${t.url} → 404 (no file, and the backend did not answer)`}]),f(404,`Not found: ${n.pathname}`))}return o(`the backend could not be started`)}};export{p as DevServers};
@@ -0,0 +1,11 @@
1
+ import{i as e}from"./main-VEpSfsM_.js";async function t(e){let{prebuiltAppConfig:t}=await import(`./lib-aA6_aWm_.js`),n=e.get(`webllm.custom`,[]),r=new Set(n.map(e=>e.model_id));return{...t,model_list:[...n,...t.model_list.filter(e=>!r.has(e.model_id))]}}let n=null,r=null;async function i(i,a,o){return n?.model===a?n.engine:(r&&await r.catch(()=>void 0),n&&n.model!==a&&i.procs.kill(n.pid),r=(async()=>{let{CreateMLCEngine:s}=await import(`./lib-aA6_aWm_.js`),c=null,l=i.procs.spawn({name:`webllm`,kind:`service`,detail:`${a} · WebGPU`,onKill:()=>{c?.unload().catch(()=>void 0),n?.pid===l.pid&&(n=null)}});try{let e=c=await s(a,{appConfig:await t(i.settings),initProgressCallback:e=>o(`Loading ${a}: ${e.text}`)});return n={model:a,engine:e,pid:l.pid},i.procs.update(l.pid,{state:`idle`}),e}catch(t){throw i.procs.kill(l.pid),new e(`Could not load ${a} on WebGPU: ${t.message}`)}finally{r=null}})())}function a(e){if(!e.tools.length)return e.system;let t=e.tools.map(e=>`- ${e.name}(${Object.keys(e.input_schema.properties??{}).join(`, `)}): ${e.description.split(/(?<=\.)\s/)[0]}`).join(`
2
+ `);return`${e.system}
3
+
4
+ # Tools (only when needed)
5
+ Most messages need no tool: just answer them. Never ask the user which tool to use. Only when the request needs files, shell commands or running JavaScript, call one of these:
6
+ ${t}
7
+
8
+ To call a tool, reply with only this line:
9
+ <tool_call>{"name": "tool_name", "arguments": {"key": "value"}}</tool_call>
10
+ The result comes back in a <tool_result> block; then continue, and answer normally when done.`}function o(e){let t=0;for(let n=0;n<e.length;n++)e.charCodeAt(n)<128&&t++;return Math.ceil(t/3.4+(e.length-t)*1.2)+6}function s(e,t=4096,n=768,r=1){let i={role:`system`,content:a(e)},s=[],c=(e,t)=>{let n=s.at(-1);n?.role===e?n.content+=`
11
+ `+t:s.push({role:e,content:t})};for(let t of e.messages)for(let e of t.content)e.type===`text`&&e.text?c(t.role,e.text):e.type===`tool_use`?c(`assistant`,`<tool_call>${JSON.stringify({name:e.name,arguments:e.input})}</tool_call>`):e.type===`tool_result`&&c(`user`,`<tool_result>${e.is_error?`ERROR: `:``}${e.content.slice(0,2e3)}</tool_result>`);let l=Math.floor((t-n)*r)-o(i.content),u=s.reduce((e,t)=>e+o(t.content),0);for(;u>l&&s.length>1;){let e=s.shift();u-=o(e.content),s[0]?.role===`assistant`&&(u-=o(s.shift().content))}for(;u>l&&s[0]&&s[0].content.length>200;)s[0].content=s[0].content.slice(Math.ceil(s[0].content.length/4)),u=o(s[0].content);return[i,...s]}function c(e){let t=e.match(/^\s*<think>/);if(!t)return{thinking:``,answer:e,open:!1};let n=e.slice(t[0].length),r=n.indexOf(`</think>`);return r<0?{thinking:n,answer:``,open:!0}:{thinking:n.slice(0,r),answer:n.slice(r+8).replace(/^\s+/,``),open:!1}}function l(e,t){try{let n=JSON.parse(e);if(typeof n?.name!=`string`||t&&!t.has(n.name))return null;let r=n.arguments??n.parameters??{};return{name:n.name,input:typeof r==`string`?JSON.parse(r):r}}catch{return`invalid`}}function u(e,t){let{thinking:n,answer:r}=c(e),i=new Set(t),a=/<tool_call>\s*([\s\S]*?)\s*(?:<\/tool_call>|$)/.exec(r);if(a){let e=l(a[1],null);return{thinking:n,text:r.slice(0,a.index).trim(),call:e===`invalid`||e===null?{name:`unknown`,input:{},invalid:a[1]}:e,at:a.index}}for(let e of r.matchAll(/```(?:json|tool_call|tool)?\s*\n?([\s\S]*?)```/g)){let t=l(e[1].trim(),i);if(t&&t!==`invalid`)return{thinking:n,text:r.slice(0,e.index).trim(),call:t,at:e.index}}let o=r.trim();if(o.startsWith(`{`)&&o.endsWith(`}`)){let e=l(o,i);if(e&&e!==`invalid`)return{thinking:n,text:``,call:e,at:r.indexOf(`{`)}}return{thinking:n,text:r.trim(),call:null,at:-1}}function d(e){if(/^\s*\{/.test(e))return 0;let t=[e.indexOf(`<tool_call`),e.indexOf("```")].filter(e=>e>=0);return Math.min(...t,Math.max(0,e.length-10))}async function f(r,a){let l=(await t(r.settings)).model_list.find(e=>e.model_id===a.webllmModel)?.overrides?.context_window_size??4096,f=Math.min(768,Math.floor(l/4));return{id:`webllm`,contextBudget:0,contextWindow:l,async turn(t){if(!r.hasCap(`webgpu`))throw new e(`This browser has no WebGPU, which the in-browser model needs. Choose another provider in Settings → Model.`);let p=await i(r,a.webllmModel,t.onStatus);t.onStatus(``);let m=n?.pid??0;r.procs.update(m,{state:`running`});let h=performance.now(),g=()=>p.interruptGenerate();t.signal.addEventListener(`abort`,g);let _=``,v=0,y=0,b=``,x,S={input:0,output:0,cacheRead:0},C=s(t,l,f),w=/^qwen3/i.test(a.webllmModel);try{for(let e=0;;e++)try{let e=await p.chat.completions.create({messages:C,stream:!0,stream_options:{include_usage:!0},temperature:.2,max_tokens:f,...w?{extra_body:{enable_thinking:!1}}:{}});for await(let n of e){let e=n.choices[0];if(_+=e?.delta?.content??``,e?.finish_reason&&(b=e.finish_reason),n.usage){Object.assign(S,{input:n.usage.prompt_tokens,output:n.usage.completion_tokens});let e=n.usage.extra;e?.decode_tokens_per_s!==void 0&&(x={tps:e.decode_tokens_per_s,ttft:(e.time_to_first_token_s??0)*1e3})}let{thinking:r,answer:i}=c(_);r.length>v&&(t.onThinking(r.slice(v)),v=r.length);let a=d(i);a>y&&(t.onText(i.slice(y,a)),y=a)}break}catch(n){if(e===0&&!_&&!t.signal.aborted&&/context|exceed|too long|kv/i.test(n.message)){C=s(t,l,f,.6);continue}throw n}}catch(n){throw t.signal.aborted?t.signal.reason??n:new e(`The in-browser model failed: ${n.message}`)}finally{t.signal.removeEventListener(`abort`,g),r.procs.account(m,performance.now()-h),r.procs.update(m,{state:`idle`})}t.signal.throwIfAborted();let T=C.reduce((e,t)=>e+o(t.content),0);S.cacheRead=S.input<T*.8?T-S.input:0;let E=u(_,t.tools.map(e=>e.name)),{answer:D}=c(_),O=E.call?E.at:D.length;O>y&&t.onText(D.slice(y,O));let k=[];return E.thinking.trim()&&k.push({type:`thinking`,text:E.thinking.trim()}),E.text&&k.push({type:`text`,text:E.text}),E.call&&k.push({type:`tool_use`,id:`local_${Date.now()}`,name:E.call.name,input:E.call.input,invalid:E.call.invalid}),{content:k,stop:b===`length`?`max_tokens`:E.call?`tool_use`:`end`,usage:S,model:a.webllmModel,speed:x}}}}export{f as createWebLlmProvider};
@@ -0,0 +1,15 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title>BrowserBox runtime</title>
7
+ <script type="module" crossorigin src="../assets/embed-CMbAHE2J.js"></script>
8
+ <link rel="modulepreload" crossorigin href="../assets/instance-CppC8T8t.js">
9
+ <link rel="modulepreload" href="../assets/bridge-DY2WnNx7.js" />
10
+ <link rel="modulepreload" href="../assets/instance-CppC8T8t.js" />
11
+ <link rel="modulepreload" href="../assets/main-VEpSfsM_.js" />
12
+ </head>
13
+ <body>
14
+ </body>
15
+ </html>
package/dist/icon.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" rx="14" fill="#1a1a19"/><g transform="translate(12 12) scale(1.25)" color="#4fb89c"><path d="M16 3l12 6.5-12 6.5L4 9.5z" fill="currentColor" opacity="1"/><path d="M4 12.5l11 6v10.5L4 23z" fill="currentColor" opacity="0.72"/><path d="M28 12.5l-11 6v10.5L28 23z" fill="currentColor" opacity="0.45"/></g></svg>
@@ -0,0 +1,13 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'wasm-unsafe-eval'; connect-src *; frame-src 'self'; worker-src 'self' blob:; object-src 'none'; base-uri 'self'" />
6
+ <title>BrowserBox kernel bridge</title>
7
+ <script type="module" crossorigin src="../assets/bridge-DY2WnNx7.js"></script>
8
+ <link rel="modulepreload" crossorigin href="../assets/instance-CppC8T8t.js">
9
+ </head>
10
+ <body>
11
+ <!-- No UI. Embedded as a hidden frame by every BrowserBox window; see src/kernel-host/bridge.ts. -->
12
+ </body>
13
+ </html>
@@ -0,0 +1 @@
1
+ {"esbuild":[{"url":"assets/pkg-esbuild-BuQjm7dB.js","bytes":1164},{"url":"assets/bundle-8opp8__C.js","bytes":4265},{"url":"assets/npm-DF8ts_uH.js","bytes":1459}],"git":[{"url":"assets/pkg-git-jawfIVoq.js","bytes":219526}],"python":[{"url":"assets/pkg-python-CoNK0IjJ.js","bytes":4488}],"sqlite":[{"url":"assets/pkg-sqlite-BexM5lLo.js","bytes":41858},{"url":"assets/sql-wasm-CXIAVl5-.wasm","bytes":688197}],"zip":[{"url":"assets/pkg-zip-BdZ_Lkdk.js","bytes":13845}]}
@@ -0,0 +1,18 @@
1
+ <!doctype html>
2
+ <meta charset="utf-8">
3
+ <meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' 'wasm-unsafe-eval' blob: https://cdn.jsdelivr.net; worker-src blob:; connect-src *">
4
+ <title>BrowserBox sandbox</title>
5
+ <script>
6
+ // Runs in an opaque origin (iframe sandbox="allow-scripts"): no cookies, storage,
7
+ // OPFS or IndexedDB of the host. It only spawns the worker the host sends.
8
+ let worker;
9
+ addEventListener("message", (e) => {
10
+ if (e.source !== parent || !e.data) return;
11
+ if (e.data.type === "boot" && !worker) {
12
+ worker = new Worker(URL.createObjectURL(new Blob([e.data.src], { type: "text/javascript" })));
13
+ worker.onerror = (ev) => parent.postMessage({ type: "crash", error: String(ev.message || ev) }, "*");
14
+ worker.postMessage({ type: "port" }, [e.ports[0]]);
15
+ }
16
+ });
17
+ parent.postMessage({ type: "hello" }, "*");
18
+ </script>
@@ -0,0 +1,18 @@
1
+ <!doctype html>
2
+ <meta charset="utf-8">
3
+ <meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' 'wasm-unsafe-eval' blob: https://cdn.jsdelivr.net; worker-src blob:; connect-src https://cdn.jsdelivr.net https://pypi.org https://files.pythonhosted.org">
4
+ <title>BrowserBox sandbox</title>
5
+ <script>
6
+ // Runs in an opaque origin (iframe sandbox="allow-scripts"): no cookies, storage,
7
+ // OPFS or IndexedDB of the host. It only spawns the worker the host sends.
8
+ let worker;
9
+ addEventListener("message", (e) => {
10
+ if (e.source !== parent || !e.data) return;
11
+ if (e.data.type === "boot" && !worker) {
12
+ worker = new Worker(URL.createObjectURL(new Blob([e.data.src], { type: "text/javascript" })));
13
+ worker.onerror = (ev) => parent.postMessage({ type: "crash", error: String(ev.message || ev) }, "*");
14
+ worker.postMessage({ type: "port" }, [e.ports[0]]);
15
+ }
16
+ });
17
+ parent.postMessage({ type: "hello" }, "*");
18
+ </script>
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "BrowserBox — Agent OS",
3
+ "short_name": "BrowserBox",
4
+ "description": "A sandboxed operating system for AI agents that runs entirely in your browser.",
5
+ "start_url": "./agent/",
6
+ "display": "standalone",
7
+ "background_color": "#131312",
8
+ "theme_color": "#1a1a19",
9
+ "icons": [{ "src": "./icon.svg", "sizes": "any", "type": "image/svg+xml", "purpose": "any" }]
10
+ }
@@ -0,0 +1,27 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <!--
7
+ BrowserBox preview frame. Embedded with sandbox="allow-scripts …" and no
8
+ allow-same-origin, so whatever runs here has an opaque origin: it cannot
9
+ reach BrowserBox's storage, files or keys. Pages arrive by postMessage from
10
+ the parent and are written into this document, so they get this policy
11
+ (scripts allowed) instead of the agent window's stricter one.
12
+ -->
13
+ <meta http-equiv="Content-Security-Policy" content="default-src * data: blob: 'unsafe-inline' 'unsafe-eval' 'wasm-unsafe-eval'; form-action 'none'">
14
+ <title>Preview</title>
15
+ <script>
16
+ addEventListener('message', function boot(e) {
17
+ if (e.source !== parent || !e.data || e.data.type !== 'bbx-preview:doc') return;
18
+ removeEventListener('message', boot);
19
+ document.open();
20
+ document.write(e.data.html);
21
+ document.close();
22
+ });
23
+ parent.postMessage({ type: 'bbx-preview:ready' }, '*');
24
+ </script>
25
+ </head>
26
+ <body></body>
27
+ </html>
package/dist/sw.js ADDED
@@ -0,0 +1,73 @@
1
+ // BrowserBox service worker: makes the OS boot instantly and work offline.
2
+ // Hashed build assets are immutable → cache-first. The HTML shell is
3
+ // stale-while-revalidate so updates arrive on the next launch.
4
+ //
5
+ // It can also make every page cross-origin isolated (Settings → Environment):
6
+ // static hosts such as GitHub Pages cannot send the COOP/COEP headers that
7
+ // SharedArrayBuffer, WebAssembly threads and in-browser Node.js need, so the
8
+ // worker adds them to the responses it serves.
9
+ const CACHE = 'bbx-v3';
10
+ // Only the app's own old caches are cleared on update. Installed packages
11
+ // (bbx-packs), npm modules (bbx-npm), in-browser models (webllm/*) and flags stay.
12
+ const OWN = /^bbx-v\d+$/;
13
+ const FLAGS = 'bbx-flags';
14
+ // The same absolute key from every page and from here (relative keys resolve differently).
15
+ const COI_KEY = 'https://flags.browserbox.local/coi';
16
+
17
+ self.addEventListener('install', (e) => {
18
+ e.waitUntil(caches.open(CACHE).then((c) => c.addAll(['./', './agent/', './os/', './docs/', './kernel/bridge.html', './kernel/sandbox.html', './kernel/sandbox-net.html', './preview/frame.html'])).then(() => self.skipWaiting()));
19
+ });
20
+
21
+ self.addEventListener('activate', (e) => {
22
+ e.waitUntil(
23
+ caches.keys().then((keys) => Promise.all(keys.filter((k) => OWN.test(k) && k !== CACHE).map((k) => caches.delete(k)))).then(() => self.clients.claim()),
24
+ );
25
+ });
26
+
27
+ // Whether to isolate, re-read at most every few seconds (the setting writes it to Cache Storage).
28
+ let isolate = false;
29
+ let checked = 0;
30
+ async function isolated() {
31
+ if (Date.now() - checked > 3000) {
32
+ checked = Date.now();
33
+ isolate = !!(await caches.open(FLAGS).then((c) => c.match(COI_KEY)).catch(() => null));
34
+ }
35
+ return isolate;
36
+ }
37
+
38
+ /** Adds the cross-origin isolation headers to a same-origin response. */
39
+ function withIsolation(res) {
40
+ if (!res || res.status === 0 || res.type === 'opaque' || res.type === 'opaqueredirect') return res;
41
+ const headers = new Headers(res.headers);
42
+ headers.set('Cross-Origin-Opener-Policy', 'same-origin');
43
+ // credentialless: cross-origin resources (CDNs, esm.sh, model weights) load without needing CORP headers.
44
+ headers.set('Cross-Origin-Embedder-Policy', 'credentialless');
45
+ headers.set('Cross-Origin-Resource-Policy', 'cross-origin');
46
+ return new Response(res.body, { status: res.status, statusText: res.statusText, headers });
47
+ }
48
+
49
+ self.addEventListener('fetch', (e) => {
50
+ const req = e.request;
51
+ const url = new URL(req.url);
52
+ if (req.method !== 'GET' || url.origin !== self.location.origin) return; // never touch LLM / network calls
53
+ const immutable = url.pathname.includes('/assets/');
54
+ e.respondWith(
55
+ (async () => {
56
+ const cache = await caches.open(CACHE);
57
+ const hit = (await cache.match(req)) ?? (await caches.open('bbx-packs').then((c) => c.match(req)));
58
+ const refresh = fetch(req)
59
+ .then((res) => {
60
+ if (res.ok) cache.put(req, res.clone());
61
+ return res;
62
+ })
63
+ .catch(() => hit);
64
+ let res;
65
+ if (hit && immutable) res = hit;
66
+ else if (hit) {
67
+ e.waitUntil(refresh);
68
+ res = hit;
69
+ } else res = (await refresh) ?? Response.error();
70
+ return (await isolated()) ? withIsolation(res) : res;
71
+ })(),
72
+ );
73
+ });
package/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Absolute path of the built runtime (embed/, kernel/, assets/, …). Serve this
3
+ * folder as static files and pass its URL to the SDK's `runtimeUrl`.
4
+ */
5
+ export declare const runtimeDir: string;
package/index.js ADDED
@@ -0,0 +1,9 @@
1
+ import { dirname, join } from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
+
4
+ /**
5
+ * Absolute path of the built runtime (embed/, kernel/, assets/, …). Serve this
6
+ * folder as static files, e.g. copy it to your site's public/browserbox/, and
7
+ * pass its URL to the SDK: BrowserBox.boot({ runtimeUrl: '/browserbox/' }).
8
+ */
9
+ export const runtimeDir = join(dirname(fileURLToPath(import.meta.url)), 'dist');
package/package.json CHANGED
@@ -1,6 +1,53 @@
1
1
  {
2
2
  "name": "@jeevanand/agent-browserbox-runtime",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "The self-hostable runtime for @jeevanand/agent-browserbox-sdk: static files (kernel, filesystem, shell, sandboxes) to serve from your own origin.",
5
+ "type": "module",
6
+ "main": "./index.js",
7
+ "types": "./index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./index.d.ts",
11
+ "import": "./index.js"
12
+ }
13
+ },
14
+ "bin": {
15
+ "agent-browserbox-runtime": "bin/serve.mjs"
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "bin",
20
+ "index.js",
21
+ "index.d.ts",
22
+ "README.md"
23
+ ],
24
+ "keywords": [
25
+ "sandbox",
26
+ "ai-agent",
27
+ "browser",
28
+ "vm",
29
+ "runtime",
30
+ "wasm"
31
+ ],
32
+ "homepage": "https://github.com/jeevanandmaurya/agent-browserbox/tree/main/packages/runtime#readme",
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "git+https://github.com/jeevanandmaurya/agent-browserbox.git",
36
+ "directory": "packages/runtime"
37
+ },
38
+ "bugs": {
39
+ "url": "https://github.com/jeevanandmaurya/agent-browserbox/issues"
40
+ },
41
+ "author": "Jeevanand Maurya",
42
+ "license": "MIT",
43
+ "publishConfig": {
44
+ "access": "public"
45
+ },
46
+ "engines": {
47
+ "node": ">=18"
48
+ },
49
+ "scripts": {
50
+ "build": "cd ../.. && BBX_TARGET=runtime vite build",
51
+ "prepack": "npm run build"
52
+ }
53
+ }