sliccy 5.57.2 → 5.58.0
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.
- package/dist/ui/assets/{account-store-EkiJZvDb.js → account-store-DeH3wiFo.js} +1 -1
- package/dist/ui/assets/{account-store-BYbcAgX7.js → account-store-vuw_HYi3.js} +2 -2
- package/dist/ui/assets/{adobe-igqMI1_L.js → adobe-DNQRukss.js} +1 -1
- package/dist/ui/assets/{adobe-DMuIRBCQ.js → adobe-DvNOyoXS.js} +1 -1
- package/dist/ui/assets/{adobe-oauth-state-eyWQK3Db.js → adobe-oauth-state-DVHpvwZF.js} +1 -1
- package/dist/ui/assets/{agent-message-to-chat-CdGdh6Me.js → agent-message-to-chat-C1KU3v3M.js} +1 -1
- package/dist/ui/assets/{apps-Emj7UfBa.js → apps-BK6JupOo.js} +1 -1
- package/dist/ui/assets/{azure-openai-CEn91GJx.js → azure-openai-B2QtYE4i.js} +1 -1
- package/dist/ui/assets/{azure-openai-DQWYUC5j.js → azure-openai-iKx1U0sg.js} +1 -1
- package/dist/ui/assets/{cerebras-DjKubgMp.js → cerebras-BKzAvJCs.js} +1 -1
- package/dist/ui/assets/{cerebras-DLspT9p8.js → cerebras-xBxjmrc-.js} +1 -1
- package/dist/ui/assets/clipboard-tweg-07U.js +1 -0
- package/dist/ui/assets/{connect-surface-x3n9svUp.js → connect-surface-dlct_w-J.js} +1 -1
- package/dist/ui/assets/dip-CfZnFlBK.js +1 -0
- package/dist/ui/assets/{dist-BraUFRGP.js → dist-0NnHP0j4.js} +1 -1
- package/dist/ui/assets/{dist-C0XFYJFy.js → dist-CONhOaPx.js} +1 -1
- package/dist/ui/assets/{ensure-speech-assets-B7Ss5vVA.js → ensure-speech-assets-BHJG5H3M.js} +1 -1
- package/dist/ui/assets/{fs-VHevPF88.js → fs-BP1ycbTv.js} +2 -2
- package/dist/ui/assets/{fs-BnnBRngY.js → fs-CZLyw6X8.js} +1 -1
- package/dist/ui/assets/{github-ut2NnHeQ.js → github-BXXTJfnG.js} +1 -1
- package/dist/ui/assets/{github-Bko-qYFj.js → github-C97Vqbxa.js} +2 -2
- package/dist/ui/assets/{github-copilot-xTbOqOvQ.js → github-copilot-BITa1j16.js} +1 -1
- package/dist/ui/assets/{github-copilot-B5DGMnJQ.js → github-copilot-DFz_D79x.js} +1 -1
- package/dist/ui/assets/{hear-C2OS428l.js → hear-DK3SE9UZ.js} +1 -1
- package/dist/ui/assets/{js-realm-worker-Bi5UIEMG.js → js-realm-worker-CeYHBMC5.js} +7 -7
- package/dist/ui/assets/{kernel-worker-BcsAuImy.js → kernel-worker-Rrx0aK7m.js} +983 -983
- package/dist/ui/assets/{kokoro-engine-CNvfDdFE.js → kokoro-engine-DYUZ5mft.js} +1 -1
- package/dist/ui/assets/{lick-ws-bridge-rLyxnHzf.js → lick-ws-bridge-BXfKVz1B.js} +1 -1
- package/dist/ui/assets/{lick-ws-bridge-DZSVTsLH.js → lick-ws-bridge-CEw7zXWb.js} +1 -1
- package/dist/ui/assets/{local-llm-BwofnZP_.js → local-llm-DEpCPL3N.js} +1 -1
- package/dist/ui/assets/{main-Dn8bgiA6.js → main-DLz5qyR7.js} +4 -4
- package/dist/ui/assets/{mount-B2oKVbNo.js → mount-0ZiASF_5.js} +1 -1
- package/dist/ui/assets/{mount-DnReidtr.js → mount-C1swqkaU.js} +2 -2
- package/dist/ui/assets/{new-session-BMIV1D1R.js → new-session-BQx4lnyb.js} +2 -2
- package/dist/ui/assets/{oauth-bootstrap-rk54U1XV.js → oauth-bootstrap-B9vY-BRE.js} +2 -2
- package/dist/ui/assets/{openai-codex-Wx21S4UT.js → openai-codex-D4UsQa8g.js} +1 -1
- package/dist/ui/assets/{openai-codex-BgAN6_Qw.js → openai-codex-zTDkFxq_.js} +1 -1
- package/dist/ui/assets/{page-follower-tray-Df7PCTWs.js → page-follower-tray-DmAd_GWW.js} +1 -1
- package/dist/ui/assets/{panel-rpc-handlers-DYskdWzQ.js → panel-rpc-handlers-NhfnH6G9.js} +2 -2
- package/dist/ui/assets/{provider-C1hd8MrJ.js → provider-Cu28qTkm.js} +2 -2
- package/dist/ui/assets/{provider-lwmBuH_H.js → provider-NTQuGPsR.js} +1 -1
- package/dist/ui/assets/{provider-settings-c9dGiKca.js → provider-settings-CYYH3vDR.js} +1 -1
- package/dist/ui/assets/provider-store-access-BGuwAmCa.js +1 -0
- package/dist/ui/assets/provider-store-access-C_AVf_E8.js +1 -0
- package/dist/ui/assets/{providers-CsEVgN3c.js → providers-B9nw-ePd.js} +1 -1
- package/dist/ui/assets/{providers-6RSF12nO.js → providers-BRleMLiy.js} +2 -2
- package/dist/ui/assets/{quick-llm-Dc_7dVli.js → quick-llm-D69J7_RA.js} +1 -1
- package/dist/ui/assets/session-freezer-CDMn8WnP.js +1 -0
- package/dist/ui/assets/{speak-DC8ptVJL.js → speak-DvAyaogi.js} +1 -1
- package/dist/ui/assets/{sprinkle-manager-DoYhlu8O.js → sprinkle-manager-rpkrbAvW.js} +1 -1
- package/dist/ui/assets/{store-DGSI1qzi.js → store-vSe4KiU_.js} +1 -1
- package/dist/ui/assets/{sudo-wMWKNcpq.js → sudo-Cm3hirW9.js} +1 -1
- package/dist/ui/assets/{transformers-env-dWV6LRaJ.js → transformers-env-B3kpk97f.js} +1 -1
- package/dist/ui/assets/{tray-leader-X9_I01bE.js → tray-leader-DdBEL_nf.js} +1 -1
- package/dist/ui/assets/{tray-leave-runtime-Dmyhw5vM.js → tray-leave-runtime-BLySFWqC.js} +1 -1
- package/dist/ui/assets/{upgrade-detection-DfVhb93y.js → upgrade-detection-CaN4us1y.js} +1 -1
- package/dist/ui/assets/{voice-reply-Dkrp4bDM.js → voice-reply-Cd2cQZ1O.js} +1 -1
- package/dist/ui/assets/{wc-attach-BUJpM91I.js → wc-attach-B_sJtvrP.js} +2 -2
- package/dist/ui/assets/{wc-extension-Vn2_Lt9D.js → wc-extension-BA8Trhas.js} +2 -2
- package/dist/ui/assets/{wc-follower-C9lTIhGW.js → wc-follower-JCOA6Od2.js} +3 -3
- package/dist/ui/assets/{wc-live-TXJxtPKc.js → wc-live-Hbl4Ji2P.js} +5 -5
- package/dist/ui/assets/{wc-nav-XMX7q2dM.js → wc-nav-vGWYhcSN.js} +2 -2
- package/dist/ui/assets/{wc-onboarding-DbGx3EvO.js → wc-onboarding-BAq8GkX1.js} +2 -2
- package/dist/ui/assets/{wc-placeholder-BjPMYGhP.js → wc-placeholder-pJKktrh8.js} +3 -3
- package/dist/ui/assets/{wc-settings-BW0hO_kO.js → wc-settings-4_1h_265.js} +3 -3
- package/dist/ui/assets/{wc-shell-D1_4xP-C.js → wc-shell-OJSz86We.js} +3 -3
- package/dist/ui/assets/{wc-sprinkles-B_2bqTmh.js → wc-sprinkles-DMgKUvY4.js} +2 -2
- package/dist/ui/assets/{wc-tray-DKOXOmlH.js → wc-tray-BdeVxo6d.js} +2 -2
- package/dist/ui/assets/{whisper-engine-GZAusomQ.js → whisper-engine-De27HbRj.js} +1 -1
- package/dist/ui/assets/{xai-grok-DqdH-Jr1.js → xai-grok-19HQKb_w.js} +1 -1
- package/dist/ui/assets/{xai-grok-C1FhJfKh.js → xai-grok-CRjHls8r.js} +1 -1
- package/dist/ui/index.html +3 -3
- package/dist/ui/packages/webapp/index.html +3 -3
- package/package.json +1 -1
- package/dist/ui/assets/clipboard-DFF1k7iL.js +0 -1
- package/dist/ui/assets/dip-Ew0wNwe6.js +0 -1
- package/dist/ui/assets/provider-store-access-CkEGo_9g.js +0 -1
- package/dist/ui/assets/provider-store-access-D-x4-dcp.js +0 -1
- package/dist/ui/assets/session-freezer-IBnu6nM1.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./logger-LESFN7Hj.js";import{t}from"./wc-permissions-registry-C7PhTX3c.js";import{i as n,n as r,r as i}from"./whisper-engine-
|
|
1
|
+
import{t as e}from"./logger-LESFN7Hj.js";import{t}from"./wc-permissions-registry-C7PhTX3c.js";import{i as n,n as r,r as i}from"./whisper-engine-De27HbRj.js";const a=16e3;async function o(e){if(typeof AudioContext>`u`||typeof OfflineAudioContext>`u`)throw Error(`audio decoding requires a window/page realm (AudioContext unavailable)`);let t=new AudioContext,n;try{n=await t.decodeAudioData(e.slice(0))}finally{await t.close().catch(()=>{})}let r=Math.max(1,Math.ceil(n.duration*a)),i=new OfflineAudioContext(1,r,a),o=i.createBufferSource();return o.buffer=n,o.connect(i.destination),o.start(),(await i.startRendering()).getChannelData(0).slice(0)}e(`speech:whisper-session`);function s(e){return e?.split(`-`)[0]?.toLowerCase()||void 0}const c=e(`speech:hear`);let l={};function u(){return l.getPermissionSurface?l.getPermissionSurface():t()||null}function d(){if(typeof window>`u`)return null;let e=window;return e.SpeechRecognition??e.webkitSpeechRecognition??null}var f=class extends Error{code;constructor(e){super(p(e)),this.name=`SpeechRecognitionError`,this.code=e}};function p(e){switch(e){case`network`:case`service-not-allowed`:return"builtin speech recognition is unsupported in this browser (no Web Speech cloud backend) — use `hear --engine enhanced`";case`not-allowed`:return`microphone permission denied for builtin speech recognition`;case`audio-capture`:return`no microphone available for builtin speech recognition`;case`no-speech`:return`no speech detected`;case`aborted`:return`speech recognition aborted`;default:return`speech recognition error: ${e}`}}function m(e){return e instanceof f&&(e.code===`network`||e.code===`service-not-allowed`)}function h(e,t){let n=d();return n?new Promise((r,i)=>{let a=Date.now(),o=()=>Date.now()-a,s=new n;s.continuous=!1,s.interimResults=!1,e&&(s.lang=e),c.debug(`builtinOnce: recognizer constructed`,{lang:e??`(browser default)`,timeoutMs:t});let l=``,u=!1,d=setTimeout(()=>{c.debug(`builtinOnce: timeout reached — stopping recognizer`,{elapsedMs:o()});try{s.stop()}catch{}},t);s.onstart=()=>c.debug(`builtinOnce: onstart (recognition service active)`,{elapsedMs:o()}),s.onaudiostart=()=>c.debug(`builtinOnce: onaudiostart (capturing audio)`,{elapsedMs:o()}),s.onspeechstart=()=>c.debug(`builtinOnce: onspeechstart (speech detected)`,{elapsedMs:o()}),s.onspeechend=()=>c.debug(`builtinOnce: onspeechend (speech ended)`,{elapsedMs:o()}),s.onnomatch=()=>c.debug(`builtinOnce: onnomatch (no recognizable speech)`,{elapsedMs:o()}),s.onresult=e=>{let t=[];for(let n=0;n<e.results.length;n++)t.push(e.results[n][0]?.transcript??``);l=t.join(` `).trim(),c.debug(`builtinOnce: onresult`,{elapsedMs:o(),resultCount:e.results.length,transcriptLength:l.length})},s.onerror=e=>{if(e.error===`no-speech`||e.error===`aborted`){c.debug(`builtinOnce: onerror (non-fatal — ends with empty transcript)`,{elapsedMs:o(),code:e.error});return}u=!0,clearTimeout(d),c.error(`builtinOnce: onerror (fatal)`,{elapsedMs:o(),code:e.error}),i(new f(e.error))},s.onend=()=>{clearTimeout(d),u?c.debug(`builtinOnce: onend after fatal error (already rejected)`,{elapsedMs:o()}):(c.debug(`builtinOnce: onend — resolving`,{elapsedMs:o(),transcriptLength:l.length,empty:l.length===0}),r(l))},c.debug(`builtinOnce: calling recognizer.start()`,{elapsedMs:o()}),s.start()}):Promise.reject(Error(`speech recognition unavailable in this environment`))}async function g(e){let t={audio:e?{deviceId:{exact:e}}:!0},n=u();if(n){c.debug(`acquireMicrophoneStream: requesting microphone via permission surface`,{hasDeviceId:!!e});let r=await n.prompt({kinds:[`microphone`],description:`The hear command needs your microphone to transcribe speech.`,requestOptions:{microphone:{constraints:t}},skipIfGranted:!0});if(r.status!==`granted`){c.error(`acquireMicrophoneStream: microphone permission not granted`,{status:r.status,reason:r.reason});let e=r.message?`: ${r.message}`:``;throw Error(`microphone permission ${r.reason??r.status}${e}`)}let i=r.grants.find(e=>e.kind===`microphone`);if(!i)throw c.error(`acquireMicrophoneStream: permission granted without a microphone stream`),Error(`microphone permission granted without a stream`);return c.debug(`acquireMicrophoneStream: microphone stream acquired via surface`),i.stream}if(!navigator.mediaDevices?.getUserMedia)throw c.error(`acquireMicrophoneStream: getUserMedia unavailable in this realm`),Error(`microphone capture unavailable in this realm`);c.debug(`acquireMicrophoneStream: no permission surface; calling getUserMedia directly`);try{let e=await navigator.mediaDevices.getUserMedia(t);return c.debug(`acquireMicrophoneStream: getUserMedia succeeded (direct)`),e}catch(e){throw c.error(`acquireMicrophoneStream: getUserMedia failed (direct)`,e),e}}async function _(e){let t=await g(e),n=new MediaRecorder(t),r=[];n.ondataavailable=e=>{e.data.size>0&&r.push(e.data)},n.start(500);let i=()=>{for(let e of t.getTracks())e.stop()};return{stop:()=>new Promise(e=>{n.onstop=()=>{i(),e(r.length?new Blob(r,{type:n.mimeType||`audio/webm`}):null)};try{n.stop()}catch{i(),e(null)}}),cancel:()=>{try{n.stop()}catch{}i()}}}async function v(e){if(!u())return c.debug(`primeBuiltinPermission: no permission surface; recognizer drives its own prompt`),null;c.debug(`primeBuiltinPermission: priming microphone grant via permission surface`,{hasDeviceId:!!e});let t=await g(e);return c.debug(`primeBuiltinPermission: microphone primed; holding stream open for recognizer`),t}function y(e){if(e){for(let t of e.getTracks())t.stop();c.debug(`primeBuiltinPermission: released primed microphone stream`)}}async function b(e,t){let n=await _(e.deviceId),i=``;try{i=await h(e.lang,t)}catch(e){c.warn(`builtin endpointing failed; transcribing captured audio anyway`,e)}let a=await n.stop();if(!a)return{transcript:i,engine:`builtin`};try{let t=await r(),n=await o(await a.arrayBuffer()),i=await t.transcribe(n,{language:s(e.lang)});if(i)return{transcript:i,engine:`enhanced`}}catch(e){c.warn(`whisper transcription failed; falling back to builtin text`,e)}return{transcript:i,engine:`builtin`}}async function x(e={}){let t=e.timeoutMs??3e4,r=e.engine??`auto`,i=n()===`ready`;if(r===`enhanced`&&!i)throw c.error(`hearCapture: enhanced engine requested but whisper is not ready`),Error("enhanced engine not ready — run `hear --warmup` (check progress with `hear --status`)");let a=r!==`builtin`&&i;if(c.debug(`hearCapture: engine dispatch`,{requested:r,enhancedReady:i,resolved:a?`enhanced`:`builtin`}),a)return b(e,t);let o=await v(e.deviceId);try{let n=await h(e.lang,t);return c.debug(`hearCapture: builtin recognition produced a transcript`),{transcript:n,engine:`builtin`}}catch(n){if(!m(n))throw c.error(`hearCapture: builtin recognition failed`,n),n;if(i)return c.debug(`hearCapture: builtin unsupported in this browser; falling back to enhanced whisper`),y(o),o=null,b(e,t);throw c.error(`hearCapture: builtin unsupported and whisper not ready`,{code:n.code}),n}finally{y(o)}}async function S(e,t){let n=await r(),i=await o(e);return{transcript:await n.transcribe(i,{language:s(t)}),engine:`enhanced`}}function C(){let e=i();return{state:n(),...e?{loaded:e.loaded,total:e.total,etaSeconds:e.etaSeconds}:{}}}function w(){return r().catch(()=>{}),C()}export{x as hearCapture,C as hearStatus,S as hearTranscribe,w as hearWarmup};
|
|
@@ -39,10 +39,10 @@ let r=t(),i=n(),a=typeof Symbol==`function`&&typeof Symbol.for==`function`?Symbo
|
|
|
39
39
|
`)?t:`${t}\n`);return}try{e.writeStdout(`${JSON.stringify(t,null,2)}\n`)}catch{e.writeStdout(`${String(t)}\n`)}},warn(n,i){let a=typeof i==`object`&&i&&`prefix`in i?i.prefix:void 0;e.writeStderr(r(a,t(n)))},help(t){throw e.writeStdout(t.endsWith(`
|
|
40
40
|
`)?t:`${t}\n`),e.exit(0),Error(`unreachable`)}}}const cr={reset:`\x1B[0m`,green:`\x1B[32m`,red:`\x1B[31m`,yellow:`\x1B[33m`,gray:`\x1B[90m`,bold:`\x1B[1m`,cyan:`\x1B[36m`,dim:`\x1B[2m`};function lr(e){let t=e.isTTY&&!e.noColor,n=e=>n=>t?`${e}${n}${cr.reset}`:String(n);return{enabled:t,green:n(cr.green),red:n(cr.red),yellow:n(cr.yellow),gray:n(cr.gray),bold:n(cr.bold),cyan:n(cr.cyan),dim:n(cr.dim)}}const ur={ms:1,s:1e3,m:6e4,h:36e5,d:864e5,w:6048e5,M:26298e5,y:315576e5};function dr(e){if(typeof e==`number`&&Number.isFinite(e))return Math.trunc(e);if(typeof e!=`string`)throw TypeError(`time.parseDuration: spec must be string or number`);let t=e.trim(),n=/^([0-9]+(?:\.[0-9]+)?)\s*(ms|s|m|h|d|w|M|y)?$/.exec(t);if(!n)throw RangeError(`time.parseDuration: unrecognized spec "${e}"`);let r=Number(n[1]),i=n[2]??`ms`;return Math.trunc(r*ur[i])}function fr(e){return e<10?`0${e}`:String(e)}const pr={parseDuration:dr,ago(e,t=new Date){return new Date(t.getTime()-dr(e))},range(e,t=new Date){let n=new Date(t.getTime());return{start:new Date(n.getTime()-dr(e)),end:n}},future(e,t=new Date){let n=new Date(t.getTime());return{start:n,end:new Date(n.getTime()+dr(e))}},gmailDate(e,t=new Date){let n=new Date(t.getTime()-dr(e));return`${n.getFullYear()}/${fr(n.getMonth()+1)}/${fr(n.getDate())}`}},mr=/\u001b\[[0-9;]*m/g;function hr(e){return e.replace(mr,``)}function gr(e){return hr(e).length}function _r(e,t){let n=String(e??``);return t<=0?``:gr(n)<=t?n:t<=1?n.slice(0,t):`${hr(n).slice(0,t-1)}…`}function vr(e,t){let n=String(e??``),r=gr(n);return r===t?n:r>t?_r(n,t):n+` `.repeat(t-r)}function yr(e,t){if(!e.length)return``;let n=Math.max(...e.map(e=>e.length)),r=[];for(let i=0;i<n;i++)if(t&&t[i]!==void 0)r[i]=t[i];else{let t=0;for(let n of e){let e=i<n.length?String(n[i]??``):``;t=Math.max(t,gr(e))}r[i]=t}return e.map(e=>r.map((t,n)=>vr(n<e.length?String(e[n]??``):``,t)).join(` `).replace(/\s+$/,``)).join(`
|
|
41
41
|
`)}function br(e){return e instanceof Date?e:new Date(e)}function xr(e,t=`short`){let n=br(e);if(Number.isNaN(n.getTime()))return String(e);if(t===`iso`)return n.toISOString();if(t===`locale`)return new Intl.DateTimeFormat(void 0,{dateStyle:`medium`}).format(n);if(t===`human`){let e=Date.now()-n.getTime(),t=Math.abs(e);if(t<6e4)return e>=0?`just now`:`in a moment`;let r=(t,n)=>e>=0?`${t} ${n}${t===1?``:`s`} ago`:`in ${t} ${n}${t===1?``:`s`}`;return t<36e5?r(Math.round(t/6e4),`minute`):t<864e5?r(Math.round(t/36e5),`hour`):t<26298e5?r(Math.round(t/864e5),`day`):t<315576e5?r(Math.round(t/26298e5),`month`):r(Math.round(t/315576e5),`year`)}return`${n.getFullYear()}-${fr(n.getMonth()+1)}-${fr(n.getDate())}`}const Sr={trunc:_r,col:vr,table:yr,date:xr},Cr=async(e,t,n)=>{let r=Math.max(1,Math.trunc(e)||1),i=Array(t.length),a=0,o=[],s=async()=>{for(;;){let e=a++;if(e>=t.length)return;i[e]=await n(t[e],e)}};for(let e=0;e<Math.min(r,t.length);e++)o.push(s());return await Promise.all(o),i};function wr(e,t){let n=[];for(let r of e)r===``||r===`.`||(r===`..`?n.length>0&&n[n.length-1]!==`..`?n.pop():t&&n.push(`..`):n.push(r));return n}function Tr(e){if(e.length===0)return`.`;let t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47,r=wr(e.split(`/`),!t).join(`/`);return r.length===0&&!t&&(r=`.`),r.length>0&&n&&(r+=`/`),(t?`/`:``)+r}function Er(...e){let t=e.filter(e=>typeof e==`string`&&e.length>0).join(`/`);return t.length===0?`.`:Tr(t)}function Dr(e){if(e.length===0)return`.`;let t=e.charCodeAt(0)===47,n=-1,r=!0;for(let t=e.length-1;t>=1;t--)if(e.charCodeAt(t)===47){if(!r){n=t;break}}else r=!1;return n===-1?t?`/`:`.`:t&&n===1?`//`:e.slice(0,n)}function Or(e,t){let n=0,r=-1,i=!0;for(let t=e.length-1;t>=0;t--)if(e.charCodeAt(t)===47){if(!i){n=t+1;break}}else r===-1&&(i=!1,r=t+1);let a=r===-1?``:e.slice(n,r);return t&&a.endsWith(t)&&a!==t?a.slice(0,a.length-t.length):a}function kr(e){let t=Or(e),n=t.lastIndexOf(`.`);return n<=0?``:t.slice(n)}function Ar(...e){let t=``,n=!1;for(let r=e.length-1;r>=0&&!n;r--){let i=e[r];typeof i!=`string`||i.length===0||(t=t.length>0?`${i}/${t}`:i,n=i.charCodeAt(0)===47)}n||(t=t.length>0?`/${t}`:`/`);let r=wr(t.split(`/`),!1).join(`/`);return r.length>0?`/${r}`:`/`}function jr(e,t){let n=Ar(e),r=Ar(t);if(n===r)return``;let i=n.split(`/`).filter(Boolean),a=r.split(`/`).filter(Boolean),o=0;for(;o<i.length&&o<a.length&&i[o]===a[o];)o++;return[...i.slice(o).map(()=>`..`),...a.slice(o)].join(`/`)}function Mr(e){let t=e.charCodeAt(0)===47?`/`:``,n=Or(e),r=kr(e),i=r?n.slice(0,n.length-r.length):n,a=Dr(e);return a===`.`&&t===``&&(a=``),{root:t,dir:a,base:n,ext:r,name:i}}function Nr(e){let t=e.dir||e.root||``,n=e.base||`${e.name||``}${e.ext||``}`;return t?t===e.root?`${t}${n}`:`${t}/${n}`:n}const Pr={sep:`/`,delimiter:`:`,basename:Or,dirname:Dr,extname:kr,isAbsolute:e=>e.length>0&&e.charCodeAt(0)===47,join:Er,normalize:Tr,resolve:Ar,relative:jr,parse:Mr,format:Nr},Fr=65536,Ir={md5:y.md5,sha1:b.sha1,sha256:x.sha256};function Lr(e,t){let n=globalThis.Buffer;if(!n)throw Error(`crypto.createHash: Buffer is unavailable in this environment`);return t?n.from(e,t):n.from(e)}function Rr(e,t){return typeof e==`string`?t===`hex`||t===`base64`||t===`base64url`||t===`latin1`||t===`binary`?new Uint8Array(Lr(e,t===`binary`?`latin1`:t)):e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function zr(e){let t=Ir[String(e).toLowerCase().replace(`-`,``)];if(!t)throw Error(`Digest method not supported: ${e}`);let n=t.create(),r=!1,i={update(e,t){if(r)throw Error(`Digest already called`);return n.update(Rr(e,t)),i},digest(e){r=!0;let t=Lr(n.array());return e?t.toString(e):t}};return i}function Br(){let e=globalThis.crypto;if(!e||typeof e.getRandomValues!=`function`)throw Error(`crypto: globalThis.crypto is unavailable in this environment`);return e}function Vr(e){return Br().getRandomValues(e)}function Hr(e){for(let t=0;t<e.length;t+=Fr){let n=Math.min(t+Fr,e.length);Vr(e.subarray(t,n))}}function Ur(e){return e instanceof Uint8Array?e:new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}const X=Array.from({length:256},(e,t)=>(t+256).toString(16).slice(1));function Wr(){let e=Br();if(typeof e.randomUUID==`function`)return e.randomUUID();let t=Vr(new Uint8Array(16));return t[6]=t[6]&15|64,t[8]=t[8]&63|128,`${X[t[0]]}${X[t[1]]}${X[t[2]]}${X[t[3]]}-${X[t[4]]}${X[t[5]]}-${X[t[6]]}${X[t[7]]}-${X[t[8]]}${X[t[9]]}-${X[t[10]]}${X[t[11]]}${X[t[12]]}${X[t[13]]}${X[t[14]]}${X[t[15]]}`}const Gr={randomFillSync(e,t=0,n){let r=Ur(e),i=t,a=n===void 0?r.length:i+n;return Hr(r.subarray(i,a)),e},randomBytes(e){let t=globalThis.Buffer,n=t&&typeof t.allocUnsafe==`function`?t.allocUnsafe(e):new Uint8Array(e);return Hr(Ur(n)),n},randomUUID:Wr,getRandomValues(e){return Vr(e)},createHash:zr,get webcrypto(){return Br()},get subtle(){return Br().subtle}};var Z=class extends Error{actual;expected;operator;generatedMessage;code;constructor(e={}){let t=!e.message;super(e.message||`${Kr(e.actual)} ${e.operator||`!=`} ${Kr(e.expected)}`),this.name=`AssertionError`,this.actual=e.actual,this.expected=e.expected,this.operator=e.operator||``,this.generatedMessage=t,this.code=`ERR_ASSERTION`}};function Kr(e){if(typeof e==`string`)return JSON.stringify(e);if(e==null)return String(e);if(typeof e==`object`)try{return JSON.stringify(e)}catch{return String(e)}return String(e)}function Q(e,t){return e instanceof Error?e:typeof e==`string`?new Z({message:e}):t()}function qr(e,t,n,r){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!Yr(e[i],t[i],n,r))return!1;return!0}function Jr(e,t,n,r){let i=Object.keys(e);if(i.length!==Object.keys(t).length)return!1;for(let a of i){if(!Object.prototype.hasOwnProperty.call(t,a))return!1;let i=e[a],o=t[a];if(!Yr(i,o,n,r))return!1}return!0}function Yr(e,t,n,r){if((n?Object.is(e,t):e===t)||!n&&e==t)return!0;if(typeof e!=`object`||typeof t!=`object`||e===null||t===null)return!1;let i=e,a=t;return n&&Object.getPrototypeOf(i)!==Object.getPrototypeOf(a)?!1:r.get(i)===a?!0:(r.set(i,a),Array.isArray(e)===Array.isArray(t)?Array.isArray(e)&&Array.isArray(t)?qr(e,t,n,r):Jr(i,a,n,r):!1)}function Xr(e,t){try{if(e instanceof t)return!0}catch{}try{return!!t(e)}catch{return!1}}function Zr(e,t){for(let[n,r]of Object.entries(t)){let t=e[n];if(r instanceof RegExp){if(typeof t!=`string`||!r.test(t))return!1}else if(t!==r)return!1}return!0}function Qr(e,t){if(t===void 0)return!0;if(t instanceof RegExp){let n=e instanceof Error?e.message:String(e);return t.test(n)}return typeof t==`function`?Xr(e,t):t&&typeof t==`object`?!e||typeof e!=`object`?!1:Zr(e,t):!1}function $r(e){let t=(e,t)=>{if(!e)throw Q(t,()=>new Z({message:`The expression evaluated to a falsy value`,actual:e,expected:!0,operator:`==`}))},n=((e,n)=>t(e,n)),r=(e,t,n)=>{if(!Object.is(e,t))throw Q(n,()=>new Z({actual:e,expected:t,operator:`strictEqual`}))},i=(t,n,i)=>{if(e){r(t,n,i);return}if(t!=n)throw Q(i,()=>new Z({actual:t,expected:n,operator:`==`}))},a=(e,t,n)=>{if(Object.is(e,t))throw Q(n,()=>new Z({actual:e,expected:t,operator:`notStrictEqual`}))},o=(t,n,r)=>{if(e){a(t,n,r);return}if(t==n)throw Q(r,()=>new Z({actual:t,expected:n,operator:`!=`}))},s=(e,t,n)=>{if(!Yr(e,t,!0,new WeakMap))throw Q(n,()=>new Z({actual:e,expected:t,operator:`deepStrictEqual`}))},c=(t,n,r)=>{if(e){s(t,n,r);return}if(!Yr(t,n,!1,new WeakMap))throw Q(r,()=>new Z({actual:t,expected:n,operator:`deepEqual`}))},l=(e,t,n)=>{if(Yr(e,t,!0,new WeakMap))throw Q(n,()=>new Z({actual:e,expected:t,operator:`notDeepStrictEqual`}))};return n.ok=t,n.equal=i,n.notEqual=o,n.strictEqual=r,n.notStrictEqual=a,n.deepEqual=c,n.deepStrictEqual=s,n.notDeepEqual=(t,n,r)=>{if(e){l(t,n,r);return}if(Yr(t,n,!1,new WeakMap))throw Q(r,()=>new Z({actual:t,expected:n,operator:`notDeepEqual`}))},n.notDeepStrictEqual=l,n.throws=(e,t,n)=>{let r,i=!1;try{e()}catch(e){r=e,i=!0}if(!i)throw Q(typeof t==`string`?t:n,()=>new Z({message:`Missing expected exception`,operator:`throws`}));if(!(typeof t==`string`||t instanceof Error)&&!Qr(r,t))throw Q(n,()=>new Z({message:`Got unwanted exception`,actual:r,operator:`throws`}))},n.doesNotThrow=(e,t)=>{try{e()}catch(e){throw Q(t,()=>new Z({message:`Got unwanted exception`,actual:e,operator:`doesNotThrow`}))}},n.fail=e=>{throw Q(e,()=>new Z({message:`Failed`,operator:`fail`}))},n.AssertionError=Z,n}const ei=$r(!0);ei.strict=ei;const ti=$r(!1);ti.strict=ei;const ni=Symbol.for(`nodejs.util.inspect.custom`),ri=Symbol.for(`nodejs.util.promisify.custom`);function ii(e){return`'${e.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`).replace(/\n/g,`\\n`)}'`}function ai(e){if(e===null)return`null`;let t=typeof e;if(t===`string`)return ii(e);if(t===`number`)return Object.is(e,-0)?`-0`:String(e);if(t===`bigint`)return`${String(e)}n`;if(t===`boolean`||t===`undefined`)return String(e);if(t===`symbol`)return e.toString();if(t===`function`){let t=e.name;return t?`[Function: ${t}]`:`[Function (anonymous)]`}return null}function oi(e){return e instanceof RegExp?e.toString():e instanceof Date?Number.isNaN(e.getTime())?`Invalid Date`:e.toISOString():e instanceof Error?e.stack||`${e.name}: ${e.message}`:null}function si(e,t,n){if(Array.isArray(e))return e.length===0?`[]`:`[ ${e.map(e=>ci(e,t+1,n)).join(`, `)} ]`;if(e instanceof Map){let r=[...e].map(([e,r])=>`${ci(e,t+1,n)} => ${ci(r,t+1,n)}`);return`Map(${e.size}) {${r.length?` ${r.join(`, `)} `:``}}`}if(e instanceof Set){let r=[...e].map(e=>ci(e,t+1,n));return`Set(${e.size}) {${r.length?` ${r.join(`, `)} `:``}}`}let r=Object.keys(e),i=e.constructor?e.constructor.name:``,a=i&&i!==`Object`?`${i} `:``;return r.length===0?`${a}{}`:`${a}{ ${r.map(r=>`${/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(r)?r:ii(r)}: ${ci(e[r],t+1,n)}`).join(`, `)} }`}function ci(e,t,n){let r=ai(e);if(r!==null)return r;let i=e,a=oi(i);if(a!==null)return a;let o=i[ni];if(typeof o==`function`)try{return String(o.call(i,n.maxDepth,n.opts))}catch{}if(n.seen.has(e))return`[Circular *1]`;if(n.maxDepth!==null&&t>n.maxDepth)return Array.isArray(e)?`[Array]`:`[Object]`;n.seen.add(e);try{return si(i,t,n)}finally{n.seen.delete(e)}}function li(e,t={}){let n=t.depth===void 0?2:t.depth;return ci(e,0,{seen:new Set,maxDepth:n,opts:t})}function ui(e,t,n,r){if(e===`%%`)return`%`;if(n.i>=t.length)return e;let i=t[n.i];switch(e){case`%s`:return n.i++,typeof i==`string`?i:typeof i==`bigint`?`${String(i)}n`:i==null||typeof i==`number`||typeof i==`boolean`?String(i):li(i,{depth:r.depth===void 0?2:r.depth});case`%d`:return n.i++,typeof i==`bigint`?`${String(i)}n`:Number.isNaN(Number(i))?`NaN`:String(Number(i));case`%i`:return n.i++,typeof i==`bigint`?`${String(i)}n`:String(Number.parseInt(i,10));case`%f`:return n.i++,String(typeof i==`bigint`?i:Number.parseFloat(i));case`%j`:n.i++;try{return JSON.stringify(i)??`undefined`}catch{return`[Circular]`}case`%o`:return n.i++,li(i,{depth:4});case`%O`:return n.i++,li(i,{depth:null});case`%c`:return n.i++,``;default:return e}}function di(e,...t){let n=t[0];if(typeof n!=`string`)return t.map(e=>typeof e==`string`?e:li(e)).join(` `);let r={i:1},i=n.replace(/%[sdifjoOc%]/g,n=>ui(n,t,r,e));for(;r.i<t.length;r.i++){let e=t[r.i];i+=` ${typeof e==`string`?e:li(e)}`}return i}function fi(...e){return di({},...e)}function pi(e,t){if(e==null)throw TypeError(`The constructor to "inherits" must not be null or undefined`);if(t==null)throw TypeError(`The super constructor to "inherits" must not be null or undefined`);if(t.prototype===void 0)throw TypeError(`The super constructor to "inherits" must have a prototype`);e.super_=t,Object.setPrototypeOf(e.prototype,t.prototype)}function mi(e){if(typeof e!=`function`)throw TypeError(`The "original" argument must be of type function`);let t=e[ri];if(t){if(typeof t!=`function`)throw TypeError(`The [util.promisify.custom] property must be of type function`);return t}function n(...t){return new Promise((n,r)=>{e.call(this,...t,(e,...t)=>{if(e){r(e);return}n(t.length>1?t:t[0])})})}return Object.setPrototypeOf(n,Object.getPrototypeOf(e)),Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)),n}const hi=li;hi.custom=ni;const gi=mi;gi.custom=ri;const _i={format:fi,formatWithOptions:di,inspect:hi,inherits:pi,promisify:gi};function vi(e){return typeof e==`string`?new Uint8Array(Lr(e,`utf8`)):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}function yi(e){let t={};return e&&(typeof e.level==`number`&&(t.level=e.level),typeof e.windowBits==`number`&&(t.windowBits=e.windowBits),typeof e.memLevel==`number`&&(t.memLevel=e.memLevel),typeof e.strategy==`number`&&(t.strategy=e.strategy)),t}function bi(e,t,n){return Lr(e(vi(t),yi(n)))}function xi(e,t,n,r){let i=typeof n==`function`?n:r,a=typeof n==`function`?void 0:n;if(typeof i!=`function`)throw TypeError(`zlib: callback is required`);let o;try{o=bi(e,t,a)}catch(e){queueMicrotask(()=>i(e instanceof Error?e:Error(String(e))));return}queueMicrotask(()=>i(null,o))}const Si={gzipSync:(e,t)=>bi($n,e,t),gunzipSync:(e,t)=>bi(rr,e,t),deflateSync:(e,t)=>bi(Zn,e,t),inflateSync:(e,t)=>bi(rr,e,t),deflateRawSync:(e,t)=>bi(Qn,e,t),inflateRawSync:(e,t)=>bi(ir,e,t),gzip:(e,t,n)=>xi($n,e,t,n),gunzip:(e,t,n)=>xi(rr,e,t,n),deflate:(e,t,n)=>xi(Zn,e,t,n),inflate:(e,t,n)=>xi(rr,e,t,n),deflateRaw:(e,t,n)=>xi(Qn,e,t,n),inflateRaw:(e,t,n)=>xi(ir,e,t,n),constants:{Z_NO_FLUSH:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1}},Ci={tmpdir:()=>`/tmp`,homedir:()=>`/home/user`,platform:()=>`linux`,arch:()=>`x64`,EOL:`
|
|
42
|
-
`,cpus:()=>[{model:`virtual`,speed:0}],hostname:()=>`slicc`,type:()=>`Linux`,release:()=>`0.0.0`};function wi(e){let t=typeof e==`string`?e:e.href;if(!t.startsWith(`file://`))throw TypeError(`fileURLToPath: not a file URL`);let n=t.slice(7);return decodeURIComponent(n)}function Ti(e){let t=e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`);return new URL(`file://${t}`)}const Ei={URL:globalThis.URL,URLSearchParams:globalThis.URLSearchParams,fileURLToPath:wi,pathToFileURL:Ti};var Di=class{_events=new Map;on(e,t){let n=this._events.get(e);return n?n.push(t):this._events.set(e,[t]),this}addListener(e,t){return this.on(e,t)}off(e,t){let n=this._events.get(e);if(n){let r=n.indexOf(t);r!==-1&&n.splice(r,1),n.length===0&&this._events.delete(e)}return this}removeListener(e,t){return this.off(e,t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};return this.on(e,n)}emit(e,...t){let n=this._events.get(e);if(!n||n.length===0)return!1;for(let e of[...n])e(...t);return!0}removeAllListeners(e){return e===void 0?this._events.clear():this._events.delete(e),this}listenerCount(e){return this._events.get(e)?.length??0}listeners(e){return[...this._events.get(e)??[]]}};const Oi=Object.assign(Di,{EventEmitter:Di,default:Di});var ki=class{_events=new Map;writable=!0;readable=!0;on(e,t){let n=this._events.get(e);return n?n.push(t):this._events.set(e,[t]),this}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};return this.on(e,n)}off(e,t){let n=this._events.get(e);if(n){let e=n.indexOf(t);e!==-1&&n.splice(e,1)}return this}emit(e,...t){let n=this._events.get(e);if(!n||n.length===0)return!1;for(let e of[...n])e(...t);return!0}pipe(e){return e}removeListener(e,t){return this.off(e,t)}removeAllListeners(){return this._events.clear(),this}},Ai=class extends ki{read(){return null}destroy(){return this}},ji=class extends ki{write(e,t,n){return n&&queueMicrotask(n),!0}end(e){return e&&queueMicrotask(e),this}destroy(){return this}},Mi=class extends ki{write(e,t,n){return n&&queueMicrotask(n),!0}end(e){return e&&queueMicrotask(e),this}read(){return null}destroy(){return this}};const Ni={Readable:Ai,Writable:ji,Transform:Mi,PassThrough:class extends Mi{},Stream:ki};let Pi=1;function Fi(e){if(typeof e==`string`)return e;if(ArrayBuffer.isView(e)){let t=e;return new TextDecoder().decode(new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}return e==null?``:String(e)}function Ii(e,t){return t===void 0||t===`utf8`||t===`utf-8`?e:t===`buffer`||t===null?Lr(e):Lr(e).toString(t)}function Li(e,t){if(e.length===0)return Ii(``,t);if(typeof e[0]==`string`)return e.join(``);let n=globalThis.Buffer;return n?n.concat(e):e[0]}function Ri(e,t,n){t.length>0&&e.emit(`data`,Ii(t,n)),e.readable=!1,e.emit(`end`)}function zi(e){let t=e=>{typeof e==`function`&&queueMicrotask(e)};return{writable:!0,write(n,r,i){return e.stdin.write(Fi(n)),t(typeof r==`function`?r:i),!0},end(n,r,i){n!==void 0&&typeof n!=`function`&&e.stdin.write(Fi(n)),e.stdin.end(),this.writable=!1,t(typeof n==`function`?n:typeof r==`function`?r:i)}}}var Bi=class extends Di{stdout;stderr;stdin;pid;exitCode=null;signalCode=null;killed=!1;spawnfile;spawnargs;handle;constructor(e,t,n,r){super(),this.handle=e,this.pid=Pi++,this.spawnfile=n,this.spawnargs=r,this.stdout=new Ai,this.stderr=new Ai,this.stdin=zi(e),e.done.then(e=>this.finish(e,t),e=>this.emit(`error`,e instanceof Error?e:Error(String(e))))}finish(e,t){Ri(this.stdout,e.stdout,t),Ri(this.stderr,e.stderr,t),this.exitCode=e.exitCode;let n=this.killed?null:e.exitCode,r=this.killed?this.signalCode:null;this.emit(`exit`,n,r),this.emit(`close`,n,r)}kill(e=`SIGTERM`){return this.killed=!0,this.signalCode=e,this.handle.kill(e).catch(()=>{}),!0}};function Vi(e){let t=(t,n,r,i,a)=>{let o=e.start(t),s=new Bi(o,r,i,a);return n.input!==void 0&&s.stdin.write(Fi(n.input)),queueMicrotask(()=>o.stdin.end()),s},n=(e,t,n,r)=>{if(typeof r!=`function`)return;let i=[],a=[];e.stdout.on(`data`,e=>i.push(e)),e.stderr.on(`data`,e=>a.push(e)),e.once(`error`,e=>r(e,Li(i,t),Li(a,t))),e.once(`close`,(o,s)=>{let c=Li(i,t),l=Li(a,t);if(o===0){r(null,c,l);return}r(Object.assign(Error(`Command failed: ${n}\n${Fi(l)}`),{code:o===null?void 0:o,killed:e.killed,signal:s??null,cmd:n}),c,l)})},r=(e,r,i)=>{let a=typeof r==`function`?r:i,o=r&&typeof r==`object`?r:{},s=o.encoding===void 0?`utf8`:o.encoding,c=t(e,o,s,e,[]);return n(c,s,e,a),c},i=(e,r,i,a)=>{let o=[],s={},c;Array.isArray(r)?(o=r,typeof i==`function`?c=i:(s=i??{},c=typeof a==`function`?a:void 0)):typeof r==`function`?c=r:r&&typeof r==`object`&&(s=r,c=typeof i==`function`?i:void 0);let l=s.encoding===void 0?`utf8`:s.encoding,u=[e,...o],d=t(u,s,l,e,o);return n(d,l,u.join(` `),c),d},a=(e,n,r)=>{let i=[],a={};Array.isArray(n)?(i=n,a=r??{}):n&&typeof n==`object`&&(a=n);let o=a.encoding===void 0?`buffer`:a.encoding;return t(a.shell?`${e}${i.length?` ${i.join(` `)}`:``}`:[e,...i],a,o,e,i)},o=(e,t)=>new Promise((n,i)=>{r(e,t,(e,t,r)=>{if(e){i(Object.assign(e,{stdout:t,stderr:r}));return}n({stdout:t,stderr:r})})}),s=(e,t,n)=>new Promise((r,a)=>{i(e,Array.isArray(t)?t:[],Array.isArray(t)?n:t,(e,t,n)=>{if(e){a(Object.assign(e,{stdout:t,stderr:n}));return}r({stdout:t,stderr:n})})}),c=e=>()=>{throw Error(`child_process.${e} is not available in the browser realm`)},l=(e,t)=>{Object.defineProperty(e,ri,{value:t,enumerable:!1,configurable:!0})};return l(r,o),l(i,s),{exec:r,execFile:i,spawn:a,execSync:c(`execSync`),spawnSync:c(`spawnSync`),execFileSync:c(`execFileSync`),fork:c(`fork`),ChildProcess:Bi}}const Hi=new Set([`child_process`,`events`,`fs`,`fs/promises`,`os`,`path`,`stream`,`url`,`crypto`,`process`,`buffer`,`assert`,`assert/strict`,`util`]),Ui=new Set([...new Set(`assert.assert/strict.async_hooks.buffer.child_process.cluster.console.constants.crypto.dgram.diagnostics_channel.dns.dns/promises.domain.events.fs.fs/promises.http.http2.https.inspector.inspector/promises.module.net.os.path.path/posix.path/win32.perf_hooks.process.punycode.querystring.readline.readline/promises.repl.stream.stream/consumers.stream/promises.stream/web.string_decoder.sys.timers.timers/promises.tls.trace_events.tty.url.util.util/types.v8.vm.wasi.worker_threads.zlib`.split(`.`))].filter(e=>!Hi.has(e)));function Wi(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}var Gi=class{rpc;targetId;selector;index;constructor(e,t,n,r){this.rpc=e,this.targetId=t,this.selector=n,this.index=r}evalOnElement(e){let t=`(() => { const els = document.querySelectorAll(${JSON.stringify(this.selector)}); const el = els[${this.index}]; ${e} })()`;return this.rpc.call(`browser`,`evalAsync`,[this.targetId,t])}async textContent(){return this.evalOnElement(`return el ? el.textContent : null;`)}async getAttribute(e){return this.evalOnElement(`return el ? el.getAttribute(${JSON.stringify(e)}) : null;`)}async isVisible(){return this.evalOnElement(`if (!el) return false; const s = getComputedStyle(el); if (s.display === 'none' || s.visibility === 'hidden' || s.opacity === '0') return false; const r = el.getBoundingClientRect(); return r.width > 0 && r.height > 0;`)}async boundingBox(){return this.evalOnElement(`if (!el) return null; const r = el.getBoundingClientRect(); return { x: r.x, y: r.y, width: r.width, height: r.height };`)}},Ki=class{rpc;targetId;onClose;constructor(e,t,n){this.rpc=e,this.targetId=t,this.onClose=n}async goto(e,t){await this.rpc.call(`browser`,`navigateTab`,[this.targetId,e])}async waitForLoadState(e){await this.rpc.call(`browser`,`waitForLoadState`,[this.targetId,e??`load`])}async evaluate(e,...t){let n=typeof e==`string`?e:`(${e.toString()}).apply(null, JSON.parse(${JSON.stringify(JSON.stringify(t))}))`;return this.rpc.call(`browser`,`evalAsync`,[this.targetId,n])}async screenshot(e){let t={};e?.fullPage!==void 0&&(t.fullPage=e.fullPage);let n=Wi(await this.rpc.call(`browser`,`screenshotTab`,[this.targetId,t]));return e?.path&&await this.rpc.call(`vfs`,`writeFileBinary`,[e.path,n]),n}async $(e){return await this.rpc.call(`browser`,`evalAsync`,[this.targetId,`!!document.querySelector(${JSON.stringify(e)})`])?new Gi(this.rpc,this.targetId,e,0):null}async $$(e){let t=await this.rpc.call(`browser`,`evalAsync`,[this.targetId,`document.querySelectorAll(${JSON.stringify(e)}).length`]),n=[];for(let r=0;r<t;r++)n.push(new Gi(this.rpc,this.targetId,e,r));return n}async content(){return this.rpc.call(`browser`,`evalAsync`,[this.targetId,`document.documentElement.outerHTML`])}async setViewportSize(e){await this.rpc.call(`browser`,`setViewport`,[this.targetId,e.width,e.height])}async close(){await this.rpc.call(`browser`,`closeTab`,[this.targetId]),this.onClose?.(this.targetId)}},qi=class{rpc;pageTargetIds=[];constructor(e){this.rpc=e}async newPage(e){let t=await this.rpc.call(`browser`,`createTab`,[`about:blank`]);return this.pageTargetIds.push(t),e?.viewport&&await this.rpc.call(`browser`,`setViewport`,[t,e.viewport.width,e.viewport.height]),new Ki(this.rpc,t,e=>{let t=this.pageTargetIds.indexOf(e);t!==-1&&this.pageTargetIds.splice(t,1)})}async close(){let e=this.pageTargetIds.splice(0,this.pageTargetIds.length);for(let t of e)await this.rpc.call(`browser`,`closeTab`,[t])}};function Ji(e){let t=async t=>new qi(e);return{chromium:{launch:t},firefox:{launch:t},webkit:{launch:t}}}var Yi=class{port;nextId=1;pending=new Map;eventSubscribers=new Map;handler;disposed=!1;constructor(e){this.port=e,this.handler=e=>{let t=e.data;if(t?.type===`realm-rpc-res`){let t=e.data,n=this.pending.get(t.id);if(!n)return;this.pending.delete(t.id),typeof t.error==`string`?n.reject(Error(t.error)):n.resolve(t.result);return}if(t?.type===`realm-event`){let t=e.data,n=this.eventSubscribers.get(t.channel);if(!n)return;for(let e of[...n])try{e(t.payload)}catch{}}},e.addEventListener(`message`,this.handler),e.start?.()}get pendingCount(){return this.pending.size}call(e,t,n=[]){if(this.disposed)return Promise.reject(Error(`realm-rpc: client disposed`));let r=this.nextId++,i={type:`realm-rpc-req`,id:r,channel:e,op:t,args:n};return new Promise((e,t)=>{this.pending.set(r,{resolve:e,reject:t}),this.port.postMessage(i)})}onEvent(e,t){if(this.disposed)return()=>{};let n=this.eventSubscribers.get(e);return n||(n=new Set,this.eventSubscribers.set(e,n)),n.add(t),()=>{let n=this.eventSubscribers.get(e);n&&(n.delete(t),n.size===0&&this.eventSubscribers.delete(e))}}dispose(){if(this.disposed)return;this.disposed=!0,this.port.removeEventListener(`message`,this.handler);let e=Error(`realm-rpc: client disposed`);for(let t of this.pending.values())t.reject(e);this.pending.clear(),this.eventSubscribers.clear()}};const Xi=new Set([`bcrypt`,`better-sqlite3`,`canvas`,`cpu-features`,`fsevents`,`leveldown`,`libxmljs`,`libxmljs2`,`node-gyp-build`,`node-sass`,`puppeteer`,`robotjs`,`sass-embedded`,`sharp`,`snappy`,`sqlite3`,`tree-sitter`,`usb`]),Zi={sharp:` Use the built-in 'convert' shell command for image work.`,canvas:` Use the built-in 'convert' / OffscreenCanvas for image work.`,"better-sqlite3":` Use the built-in 'sqlite3' shell command (sql.js WASM).`,sqlite3:` Use the built-in 'sqlite3' shell command (sql.js WASM).`,bcrypt:` Use crypto.subtle.digest() with PBKDF2 / Argon2 in pure JS.`,puppeteer:` Use the built-in browser-automation shell commands.`};function Qi(e,t){let n=Zi[t]??``;return Error(`require('${e}'): '${t}' is a Node native module (C++ bindings) — it cannot run in the browser sandbox.${n}`)}function $i(e){if(!e)return``;let t=e.lastIndexOf(`/`);return t<0?``:t===0?`/`:e.substring(0,t)}function ea(e){return/^[A-Za-z0-9_\-./:@]+$/.test(e)?e:`'`+e.replace(/'/g,`'\\''`)+`'`}function ta(e,t){return e===``?t:e===`/`?`/${t}`:`${e}/${t}`}function na(e){let t=$i(e.argv[1]??``),n=ta(t,`references`),r=ta(t,`assets`),i=ta(t,`.config`);async function a(){let t;try{t=await e.fs.exists(i)}catch{return null}if(!t)return null;let n;try{n=await e.fs.readFile(i)}catch{return null}let r=typeof n==`string`?n:String(n);if(!r.trim())return null;let a;try{a=JSON.parse(r)}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`skill.config(): failed to parse ${i}: ${t}`)}if(a&&typeof a==`object`&&!Array.isArray(a))return a;throw Error(`skill.config(): ${i} must contain a JSON object`)}async function o(t){let n=await a();if(t===void 0)return n;if(typeof t!=`object`||!t||Array.isArray(t))throw TypeError(`skill.config(updates): updates must be a plain object`);let r={...n??{},...t};return await e.fs.writeFile(i,JSON.stringify(r,null,2)+`
|
|
43
|
-
`),r}async function s(t){if(typeof t!=`string`||!t.trim())throw TypeError(`skill.token(providerId): providerId must be a non-empty string`);let n=`oauth-token ${
|
|
44
|
-
`),info:(...t)=>e(`${t.map(
|
|
45
|
-
`),warn:(...e)=>t(`${e.map(
|
|
46
|
-
`),error:(...e)=>t(`${e.map(
|
|
47
|
-
`)}}function
|
|
48
|
-
`:``}${e}`);try{return await s(...a),0}catch(e){return e instanceof
|
|
42
|
+
`,cpus:()=>[{model:`virtual`,speed:0}],hostname:()=>`slicc`,type:()=>`Linux`,release:()=>`0.0.0`};function wi(e){let t=typeof e==`string`?e:e.href;if(!t.startsWith(`file://`))throw TypeError(`fileURLToPath: not a file URL`);let n=t.slice(7);return decodeURIComponent(n)}function Ti(e){let t=e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`);return new URL(`file://${t}`)}const Ei={URL:globalThis.URL,URLSearchParams:globalThis.URLSearchParams,fileURLToPath:wi,pathToFileURL:Ti};var Di=class{_events=new Map;on(e,t){let n=this._events.get(e);return n?n.push(t):this._events.set(e,[t]),this}addListener(e,t){return this.on(e,t)}off(e,t){let n=this._events.get(e);if(n){let r=n.indexOf(t);r!==-1&&n.splice(r,1),n.length===0&&this._events.delete(e)}return this}removeListener(e,t){return this.off(e,t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};return this.on(e,n)}emit(e,...t){let n=this._events.get(e);if(!n||n.length===0)return!1;for(let e of[...n])e(...t);return!0}removeAllListeners(e){return e===void 0?this._events.clear():this._events.delete(e),this}listenerCount(e){return this._events.get(e)?.length??0}listeners(e){return[...this._events.get(e)??[]]}};const Oi=Object.assign(Di,{EventEmitter:Di,default:Di});var ki=class{_events=new Map;writable=!0;readable=!0;on(e,t){let n=this._events.get(e);return n?n.push(t):this._events.set(e,[t]),this}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};return this.on(e,n)}off(e,t){let n=this._events.get(e);if(n){let e=n.indexOf(t);e!==-1&&n.splice(e,1)}return this}emit(e,...t){let n=this._events.get(e);if(!n||n.length===0)return!1;for(let e of[...n])e(...t);return!0}pipe(e){return e}removeListener(e,t){return this.off(e,t)}removeAllListeners(){return this._events.clear(),this}},Ai=class extends ki{read(){return null}destroy(){return this}},ji=class extends ki{write(e,t,n){return n&&queueMicrotask(n),!0}end(e){return e&&queueMicrotask(e),this}destroy(){return this}},Mi=class extends ki{write(e,t,n){return n&&queueMicrotask(n),!0}end(e){return e&&queueMicrotask(e),this}read(){return null}destroy(){return this}};const Ni={Readable:Ai,Writable:ji,Transform:Mi,PassThrough:class extends Mi{},Stream:ki};let Pi=1;function Fi(e){if(typeof e==`string`)return e;if(ArrayBuffer.isView(e)){let t=e;return new TextDecoder().decode(new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}return e==null?``:String(e)}function Ii(e,t){return t===void 0||t===`utf8`||t===`utf-8`?e:t===`buffer`||t===null?Lr(e):Lr(e).toString(t)}function Li(e,t){if(e.length===0)return Ii(``,t);if(typeof e[0]==`string`)return e.join(``);let n=globalThis.Buffer;return n?n.concat(e):e[0]}function Ri(e,t,n){t.length>0&&e.emit(`data`,Ii(t,n)),e.readable=!1,e.emit(`end`)}function zi(e){let t=e=>{typeof e==`function`&&queueMicrotask(e)};return{writable:!0,write(n,r,i){return e.stdin.write(Fi(n)),t(typeof r==`function`?r:i),!0},end(n,r,i){n!==void 0&&typeof n!=`function`&&e.stdin.write(Fi(n)),e.stdin.end(),this.writable=!1,t(typeof n==`function`?n:typeof r==`function`?r:i)}}}var Bi=class extends Di{stdout;stderr;stdin;pid;exitCode=null;signalCode=null;killed=!1;spawnfile;spawnargs;handle;constructor(e,t,n,r){super(),this.handle=e,this.pid=Pi++,this.spawnfile=n,this.spawnargs=r,this.stdout=new Ai,this.stderr=new Ai,this.stdin=zi(e),e.done.then(e=>this.finish(e,t),e=>this.emit(`error`,e instanceof Error?e:Error(String(e))))}finish(e,t){Ri(this.stdout,e.stdout,t),Ri(this.stderr,e.stderr,t),this.exitCode=e.exitCode;let n=this.killed?null:e.exitCode,r=this.killed?this.signalCode:null;this.emit(`exit`,n,r),this.emit(`close`,n,r)}kill(e=`SIGTERM`){return this.killed=!0,this.signalCode=e,this.handle.kill(e).catch(()=>{}),!0}};function Vi(e){let t=(t,n,r,i,a)=>{let o=e.start(t),s=new Bi(o,r,i,a);return n.input!==void 0&&s.stdin.write(Fi(n.input)),queueMicrotask(()=>o.stdin.end()),s},n=(e,t,n,r)=>{if(typeof r!=`function`)return;let i=[],a=[];e.stdout.on(`data`,e=>i.push(e)),e.stderr.on(`data`,e=>a.push(e)),e.once(`error`,e=>r(e,Li(i,t),Li(a,t))),e.once(`close`,(o,s)=>{let c=Li(i,t),l=Li(a,t);if(o===0){r(null,c,l);return}r(Object.assign(Error(`Command failed: ${n}\n${Fi(l)}`),{code:o===null?void 0:o,killed:e.killed,signal:s??null,cmd:n}),c,l)})},r=(e,r,i)=>{let a=typeof r==`function`?r:i,o=r&&typeof r==`object`?r:{},s=o.encoding===void 0?`utf8`:o.encoding,c=t(e,o,s,e,[]);return n(c,s,e,a),c},i=(e,r,i,a)=>{let o=[],s={},c;Array.isArray(r)?(o=r,typeof i==`function`?c=i:(s=i??{},c=typeof a==`function`?a:void 0)):typeof r==`function`?c=r:r&&typeof r==`object`&&(s=r,c=typeof i==`function`?i:void 0);let l=s.encoding===void 0?`utf8`:s.encoding,u=[e,...o],d=t(u,s,l,e,o);return n(d,l,u.join(` `),c),d},a=(e,n,r)=>{let i=[],a={};Array.isArray(n)?(i=n,a=r??{}):n&&typeof n==`object`&&(a=n);let o=a.encoding===void 0?`buffer`:a.encoding;return t(a.shell?`${e}${i.length?` ${i.join(` `)}`:``}`:[e,...i],a,o,e,i)},o=(e,t)=>new Promise((n,i)=>{r(e,t,(e,t,r)=>{if(e){i(Object.assign(e,{stdout:t,stderr:r}));return}n({stdout:t,stderr:r})})}),s=(e,t,n)=>new Promise((r,a)=>{i(e,Array.isArray(t)?t:[],Array.isArray(t)?n:t,(e,t,n)=>{if(e){a(Object.assign(e,{stdout:t,stderr:n}));return}r({stdout:t,stderr:n})})}),c=e=>()=>{throw Error(`child_process.${e} is not available in the browser realm`)},l=(e,t)=>{Object.defineProperty(e,ri,{value:t,enumerable:!1,configurable:!0})};return l(r,o),l(i,s),{exec:r,execFile:i,spawn:a,execSync:c(`execSync`),spawnSync:c(`spawnSync`),execFileSync:c(`execFileSync`),fork:c(`fork`),ChildProcess:Bi}}const Hi=new Set([`child_process`,`events`,`fs`,`fs/promises`,`os`,`path`,`stream`,`url`,`crypto`,`process`,`buffer`,`assert`,`assert/strict`,`util`]),Ui=new Set([...new Set(`assert.assert/strict.async_hooks.buffer.child_process.cluster.console.constants.crypto.dgram.diagnostics_channel.dns.dns/promises.domain.events.fs.fs/promises.http.http2.https.inspector.inspector/promises.module.net.os.path.path/posix.path/win32.perf_hooks.process.punycode.querystring.readline.readline/promises.repl.stream.stream/consumers.stream/promises.stream/web.string_decoder.sys.timers.timers/promises.tls.trace_events.tty.url.util.util/types.v8.vm.wasi.worker_threads.zlib`.split(`.`))].filter(e=>!Hi.has(e)));function Wi(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}var Gi=class{rpc;targetId;selector;index;constructor(e,t,n,r){this.rpc=e,this.targetId=t,this.selector=n,this.index=r}evalOnElement(e){let t=`(() => { const els = document.querySelectorAll(${JSON.stringify(this.selector)}); const el = els[${this.index}]; ${e} })()`;return this.rpc.call(`browser`,`evalAsync`,[this.targetId,t])}async textContent(){return this.evalOnElement(`return el ? el.textContent : null;`)}async getAttribute(e){return this.evalOnElement(`return el ? el.getAttribute(${JSON.stringify(e)}) : null;`)}async isVisible(){return this.evalOnElement(`if (!el) return false; const s = getComputedStyle(el); if (s.display === 'none' || s.visibility === 'hidden' || s.opacity === '0') return false; const r = el.getBoundingClientRect(); return r.width > 0 && r.height > 0;`)}async boundingBox(){return this.evalOnElement(`if (!el) return null; const r = el.getBoundingClientRect(); return { x: r.x, y: r.y, width: r.width, height: r.height };`)}},Ki=class{rpc;targetId;onClose;closed=!1;constructor(e,t,n){this.rpc=e,this.targetId=t,this.onClose=n}async goto(e,t){await this.rpc.call(`browser`,`navigateTab`,[this.targetId,e])}async waitForLoadState(e){await this.rpc.call(`browser`,`waitForLoadState`,[this.targetId,e??`load`])}async waitForTimeout(e){await new Promise(t=>setTimeout(t,e))}async evaluate(e,...t){let n=typeof e==`string`?e:`(${e.toString()}).apply(null, JSON.parse(${JSON.stringify(JSON.stringify(t))}))`;return this.rpc.call(`browser`,`evalAsync`,[this.targetId,n])}async screenshot(e){let t={};e?.fullPage!==void 0&&(t.fullPage=e.fullPage);let n=Wi(await this.rpc.call(`browser`,`screenshotTab`,[this.targetId,t]));return e?.path&&await this.rpc.call(`vfs`,`writeFileBinary`,[e.path,n]),n}async $(e){return await this.rpc.call(`browser`,`evalAsync`,[this.targetId,`!!document.querySelector(${JSON.stringify(e)})`])?new Gi(this.rpc,this.targetId,e,0):null}async $$(e){let t=await this.rpc.call(`browser`,`evalAsync`,[this.targetId,`document.querySelectorAll(${JSON.stringify(e)}).length`]),n=[];for(let r=0;r<t;r++)n.push(new Gi(this.rpc,this.targetId,e,r));return n}async $$eval(e,t,...n){if(typeof t==`string`)return this.rpc.call(`browser`,`evalAsync`,[this.targetId,t]);let r=`(${t.toString()}).apply(null, [Array.from(document.querySelectorAll(${JSON.stringify(e)}))].concat(JSON.parse(${JSON.stringify(JSON.stringify(n))})))`;return this.rpc.call(`browser`,`evalAsync`,[this.targetId,r])}async content(){return this.rpc.call(`browser`,`evalAsync`,[this.targetId,`document.documentElement.outerHTML`])}async setViewportSize(e){await this.rpc.call(`browser`,`setViewport`,[this.targetId,e.width,e.height])}async close(){this.closed||(this.closed=!0,await this.rpc.call(`browser`,`closeTab`,[this.targetId]),this.onClose?.())}},qi=class{rpc;openPages=[];constructor(e){this.rpc=e}async newPage(e){let t=await this.rpc.call(`browser`,`createTab`,[`about:blank`]);e?.viewport&&await this.rpc.call(`browser`,`setViewport`,[t,e.viewport.width,e.viewport.height]);let n=new Ki(this.rpc,t,()=>{let e=this.openPages.indexOf(n);e!==-1&&this.openPages.splice(e,1)});return this.openPages.push(n),n}pages(){return[...this.openPages]}async close(){let e=this.openPages.splice(0,this.openPages.length);for(let t of e)await t.close()}},Ji=class{rpc;openPages=[];openContexts=[];constructor(e){this.rpc=e}async newPage(e){let t=await this.rpc.call(`browser`,`createTab`,[`about:blank`]);e?.viewport&&await this.rpc.call(`browser`,`setViewport`,[t,e.viewport.width,e.viewport.height]);let n=new Ki(this.rpc,t,()=>{let e=this.openPages.indexOf(n);e!==-1&&this.openPages.splice(e,1)});return this.openPages.push(n),n}async newContext(e){let t=new qi(this.rpc);return this.openContexts.push(t),t}contexts(){return[...this.openContexts]}async close(){let e=this.openPages.splice(0,this.openPages.length);for(let t of e)await t.close();let t=this.openContexts.splice(0,this.openContexts.length);for(let e of t)await e.close()}};function Yi(e){let t=async t=>new Ji(e),n=async(t,n)=>new Ji(e);return{chromium:{launch:t,connect:n,connectOverCDP:n},firefox:{launch:t,connect:n},webkit:{launch:t,connect:n}}}var Xi=class{port;nextId=1;pending=new Map;eventSubscribers=new Map;handler;disposed=!1;constructor(e){this.port=e,this.handler=e=>{let t=e.data;if(t?.type===`realm-rpc-res`){let t=e.data,n=this.pending.get(t.id);if(!n)return;this.pending.delete(t.id),typeof t.error==`string`?n.reject(Error(t.error)):n.resolve(t.result);return}if(t?.type===`realm-event`){let t=e.data,n=this.eventSubscribers.get(t.channel);if(!n)return;for(let e of[...n])try{e(t.payload)}catch{}}},e.addEventListener(`message`,this.handler),e.start?.()}get pendingCount(){return this.pending.size}call(e,t,n=[]){if(this.disposed)return Promise.reject(Error(`realm-rpc: client disposed`));let r=this.nextId++,i={type:`realm-rpc-req`,id:r,channel:e,op:t,args:n};return new Promise((e,t)=>{this.pending.set(r,{resolve:e,reject:t}),this.port.postMessage(i)})}onEvent(e,t){if(this.disposed)return()=>{};let n=this.eventSubscribers.get(e);return n||(n=new Set,this.eventSubscribers.set(e,n)),n.add(t),()=>{let n=this.eventSubscribers.get(e);n&&(n.delete(t),n.size===0&&this.eventSubscribers.delete(e))}}dispose(){if(this.disposed)return;this.disposed=!0,this.port.removeEventListener(`message`,this.handler);let e=Error(`realm-rpc: client disposed`);for(let t of this.pending.values())t.reject(e);this.pending.clear(),this.eventSubscribers.clear()}};const Zi=new Set([`bcrypt`,`better-sqlite3`,`canvas`,`cpu-features`,`fsevents`,`leveldown`,`libxmljs`,`libxmljs2`,`node-gyp-build`,`node-sass`,`puppeteer`,`robotjs`,`sass-embedded`,`sharp`,`snappy`,`sqlite3`,`tree-sitter`,`usb`]),Qi={sharp:` Use the built-in 'convert' shell command for image work.`,canvas:` Use the built-in 'convert' / OffscreenCanvas for image work.`,"better-sqlite3":` Use the built-in 'sqlite3' shell command (sql.js WASM).`,sqlite3:` Use the built-in 'sqlite3' shell command (sql.js WASM).`,bcrypt:` Use crypto.subtle.digest() with PBKDF2 / Argon2 in pure JS.`,puppeteer:` Use the built-in browser-automation shell commands.`};function $i(e,t){let n=Qi[t]??``;return Error(`require('${e}'): '${t}' is a Node native module (C++ bindings) — it cannot run in the browser sandbox.${n}`)}function ea(e){if(!e)return``;let t=e.lastIndexOf(`/`);return t<0?``:t===0?`/`:e.substring(0,t)}function ta(e){return/^[A-Za-z0-9_\-./:@]+$/.test(e)?e:`'`+e.replace(/'/g,`'\\''`)+`'`}function na(e,t){return e===``?t:e===`/`?`/${t}`:`${e}/${t}`}function ra(e){let t=ea(e.argv[1]??``),n=na(t,`references`),r=na(t,`assets`),i=na(t,`.config`);async function a(){let t;try{t=await e.fs.exists(i)}catch{return null}if(!t)return null;let n;try{n=await e.fs.readFile(i)}catch{return null}let r=typeof n==`string`?n:String(n);if(!r.trim())return null;let a;try{a=JSON.parse(r)}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`skill.config(): failed to parse ${i}: ${t}`)}if(a&&typeof a==`object`&&!Array.isArray(a))return a;throw Error(`skill.config(): ${i} must contain a JSON object`)}async function o(t){let n=await a();if(t===void 0)return n;if(typeof t!=`object`||!t||Array.isArray(t))throw TypeError(`skill.config(updates): updates must be a plain object`);let r={...n??{},...t};return await e.fs.writeFile(i,JSON.stringify(r,null,2)+`
|
|
43
|
+
`),r}async function s(t){if(typeof t!=`string`||!t.trim())throw TypeError(`skill.token(providerId): providerId must be a non-empty string`);let n=`oauth-token ${ta(t)}`,{stdout:r,stderr:i,exitCode:a}=await e.exec(n);if(a!==0){let e=i.trim()||`oauth-token exited with code ${a}`;throw Error(`skill.token('${t}'): ${e}`)}return r.replace(/\r?\n+$/,``)}return Object.freeze({dir:t,refs:n,assets:r,config:o,token:s})}function $(e){if(!e||e===`/`)return`/`;e.startsWith(`/`)||(e=`/`+e);let t=e.split(`/`),n=[];for(let e of t)e===``||e===`.`||(e===`..`?n.pop():n.push(e));return`/`+n.join(`/`)}function ia(e){let t=$(e);if(t===`/`)return`/`;let n=t.lastIndexOf(`/`);return n===0?`/`:t.slice(0,n)}function aa(e){return Object.assign(Error(`ENOENT: no such file or directory, '${e}'`),{code:`ENOENT`})}function oa(e){return Object.assign(Error(`ENOSYNC: file too large for sync access, '${e}' — use async readFile() instead`),{code:`ENOSYNC`})}function sa(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}var ca=class{tree=new Map;initialPaths=new Set;initialContent=new Map;initialIsDirectory=new Map;mkdtempCounter=0;touched=!1;constructor(e){this.loadSnapshot(e)}loadSnapshot(e){this.tree=new Map,this.initialPaths=new Set,this.initialContent=new Map,this.initialIsDirectory=new Map,this.tree.set(`/`,{content:new Uint8Array,isDirectory:!0}),this.initialPaths.add(`/`),this.initialIsDirectory.set(`/`,!0);for(let t of e.entries){let e=$(t.path);this.tree.set(e,{content:t.content,isDirectory:t.isDirectory,truncated:t.truncated}),this.initialPaths.add(e),this.initialIsDirectory.set(e,t.isDirectory),t.isDirectory||this.initialContent.set(e,t.content)}for(let t of e.entries){let e=ia($(t.path));for(;e!==`/`&&!this.tree.has(e);)this.tree.set(e,{content:new Uint8Array,isDirectory:!0}),this.initialPaths.add(e),this.initialIsDirectory.set(e,!0),e=ia(e)}}wasUsed(){return this.touched}applySnapshot(e){this.loadSnapshot(e)}applySnapshotPreservingMutations(e){let t=this.getMutations();this.loadSnapshot(e);for(let e of t.deleted){if(this.tree.get(e)?.isDirectory){let t=e===`/`?`/`:e+`/`;for(let n of Array.from(this.tree.keys()))n!==e&&n.startsWith(t)&&this.tree.delete(n)}this.tree.delete(e)}for(let e of t.created)this.ensureParentDirs(e.path),this.tree.set(e.path,{content:e.content,isDirectory:e.isDirectory});for(let e of t.modified)this.ensureParentDirs(e.path),this.tree.set(e.path,{content:e.content,isDirectory:!1})}resetBaseline(){this.initialPaths=new Set,this.initialContent=new Map,this.initialIsDirectory=new Map;for(let[e,t]of this.tree.entries())this.initialPaths.add(e),this.initialIsDirectory.set(e,t.isDirectory),t.isDirectory||this.initialContent.set(e,t.content)}ensureParentDirs(e){let t=ia(e);t!==`/`&&(this.tree.has(t)||this.mkdir(t,!0))}readFile(e){this.touched=!0;let t=$(e),n=this.tree.get(t);if(!n||n.isDirectory)throw aa(t);if(n.truncated)throw oa(t);return n.content}writeFile(e,t){this.touched=!0;let n=$(e);this.ensureParentDirs(n),this.tree.set(n,{content:t,isDirectory:!1})}exists(e){this.touched=!0;let t=$(e);return this.tree.has(t)}stat(e){this.touched=!0;let t=$(e),n=this.tree.get(t);if(!n)throw aa(t);return{isFile:!n.isDirectory,isDirectory:n.isDirectory,size:n.isDirectory?0:n.content.byteLength}}readdir(e){this.touched=!0;let t=$(e);if(!this.tree.get(t)?.isDirectory)throw aa(t);let n=t===`/`?`/`:t+`/`,r=new Set;for(let e of this.tree.keys()){if(e===t||e===`/`||!e.startsWith(n))continue;let i=e.slice(n.length).split(`/`)[0];i&&r.add(i)}return Array.from(r)}mkdir(e,t){this.touched=!0;let n=$(e);if(this.tree.has(n)){if(this.tree.get(n).isDirectory)return;throw Object.assign(Error(`EEXIST: file already exists, '${n}'`),{code:`EEXIST`})}let r=ia(n);if(r!==`/`&&!this.tree.has(r)){if(!t)throw aa(n);this.mkdir(r,!0)}this.tree.set(n,{content:new Uint8Array,isDirectory:!0})}rm(e,t){this.touched=!0;let n=$(e),r=this.tree.get(n);if(!r)throw aa(n);if(r.isDirectory){let e=n===`/`?`/`:n+`/`,r=Array.from(this.tree.keys()).filter(t=>t!==n&&t.startsWith(e));if(r.length>0&&!t)throw Object.assign(Error(`ENOTEMPTY: directory not empty, '${n}'`),{code:`ENOTEMPTY`});for(let e of r)this.tree.delete(e)}this.tree.delete(n)}copyFile(e,t){this.touched=!0;let n=$(e),r=this.tree.get(n);if(!r||r.isDirectory)throw aa(n);let i=$(t);this.ensureParentDirs(i),this.tree.set(i,{content:r.content.slice(),isDirectory:!1})}rename(e,t){this.touched=!0;let n=$(e),r=this.tree.get(n);if(!r)throw aa(n);let i=$(t);if(r.isDirectory){let e=n===`/`?`/`:n+`/`,t=Array.from(this.tree.keys()).filter(t=>t!==n&&t.startsWith(e));this.ensureParentDirs(i),this.tree.set(i,r),this.tree.delete(n);for(let e of t){let t=this.tree.get(e),r=i+e.slice(n.length);this.tree.set(r,t),this.tree.delete(e)}return}this.ensureParentDirs(i),this.tree.set(i,r),this.tree.delete(n)}unlink(e){this.touched=!0;let t=$(e),n=this.tree.get(t);if(!n)throw aa(t);if(n.isDirectory)throw Object.assign(Error(`EISDIR: illegal operation on a directory, unlink '${t}'`),{code:`EISDIR`});this.tree.delete(t)}mkdtemp(e){this.touched=!0;for(let t=0;t<100;t++){let t=`_${String(this.mkdtempCounter).padStart(6,`0`)}`;this.mkdtempCounter++;let n=$(e+t);if(!this.tree.has(n))return this.mkdir(n,!0),n}throw Error(`mkdtemp: failed to create unique directory after 100 attempts`)}getMutations(){let e=[],t=[],n=[];for(let[r,i]of this.tree.entries()){if(r===`/`)continue;if(!this.initialPaths.has(r)){e.push({path:r,content:i.content,isDirectory:i.isDirectory});continue}let a=this.initialIsDirectory.get(r);if(a!==void 0&&a!==i.isDirectory){n.push(r),e.push({path:r,content:i.content,isDirectory:i.isDirectory});continue}if(!i.isDirectory){let e=this.initialContent.get(r);e&&!sa(e,i.content)&&t.push({path:r,content:i.content})}}for(let e of this.initialPaths)e!==`/`&&(this.tree.has(e)||n.push(e));return{created:e,modified:t,deleted:n}}};function la(e){if(!e)return``;let t=e.lastIndexOf(`/`);return t<0?``:t===0?`/`:e.substring(0,t)}var ua=class extends Error{code;constructor(e){super(`Process exited with code ${e}`),this.code=e,this.name=`NodeExitError`}};function da(e){if(typeof e==`string`)return e;if(e==null)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}async function fa(e,t){let n;try{n=await e.call(`vfs`,`snapshot`,[t])}catch{n={entries:[]}}return new ca(n)}function pa(e){return{usbBridge:ro(e),serialBridge:ao(e),hidBridge:so(e)}}async function ma(e,t){let n=[],r=[],i=e=>{n.push(typeof e==`string`?e:String(e))},a=e=>{r.push(typeof e==`string`?e:String(e))},o=_a(i,a),{processShim:s,getDidCallProcessExit:c}=va(e,i,a),l=!!e.env?.NO_COLOR,u=lr({isTTY:!l,noColor:l}),d=sr({writeStdout:i,writeStderr:a,exit:e=>{throw new ua(e)},color:u}),f=new Xi(t),p=Ea(f,w),h=await fa(f,e.cwd);Object.assign(p,Da(h,e.cwd));let g=ba(f,h,e.cwd),_=Ca(g,{cwd:e.cwd}),v=ra({argv:e.argv,fs:p,exec:g}),y=Va(f),{usbBridge:b,serialBridge:x,hidBridge:S}=pa(f),C=m({fetch:w});async function w(e,t){let n=e instanceof Request?e.url:e instanceof URL?e.toString():String(e),r=await f.call(`fetch`,`request`,[n,Ba(t,e)]),i=r.body.byteLength===0?null:r.body.buffer.slice(r.body.byteOffset,r.body.byteOffset+r.body.byteLength),a=new Response(i,{status:r.status,statusText:r.statusText,headers:r.headers});return Object.defineProperty(a,"url",{value:r.url||n}),a}let T=wa({exec:g,agent:_,skill:v,http:C,browser:y,usb:b,serial:x,hid:S,cli:d,color:u}),E=e.filename,D=la(E),O=await Aa(f,e.code,e.cwd,E),k=Na({graph:O,fsBridge:p,processShim:s,childProcess:Vi(g),nodeConsole:o,sliccyModules:T,shimmedPackages:Ma(f)}).require,A={exports:{},filename:e.filename},j=O.entrySource!==void 0,ee=O.entrySource??e.code,M=globalThis;M.__slicc_compileWasm=e=>f.call(`wasm`,`compile`,[e]);let te=await za(ee,{process:s,console:o,require:k,module:A,exports:A.exports,fetch:w,__dirname:D,__filename:E},a,j);await ha(f,h,a),c()||await ga(f),delete M.__slicc_compileWasm,f.dispose(),t.postMessage({type:`realm-done`,stdout:n.join(``),stderr:r.join(``),exitCode:te})}async function ha(e,t,n){let r=t.getMutations();if(r.created.length||r.modified.length||r.deleted.length)try{await e.call(`vfs`,`flushWrites`,[r])}catch(e){n(`[sync-fs] flush failed: ${e instanceof Error?e.message:String(e)}\n`)}}async function ga(e){let t=Date.now()+1e3,n=0;do await new Promise(e=>setTimeout(e,0)),n++;while(e.pendingCount>0&&n<50&&Date.now()<t)}function _a(e,t){return{log:(...t)=>e(`${t.map(da).join(` `)}
|
|
44
|
+
`),info:(...t)=>e(`${t.map(da).join(` `)}
|
|
45
|
+
`),warn:(...e)=>t(`${e.map(da).join(` `)}
|
|
46
|
+
`),error:(...e)=>t(`${e.map(da).join(` `)}
|
|
47
|
+
`)}}function va(e,t,n){let r=!!e.env?.NO_COLOR,i=Ta(e.stdin??``),a=or(e.argv),o=!1;return{processShim:{argv:a,env:e.env,cwd:()=>e.cwd,exit:e=>{throw o=!0,new ua(Number.isFinite(e)?Number(e):0)},stdin:i,stdout:{write:t,isTTY:!r},stderr:{write:n,isTTY:!r}},getDidCallProcessExit:()=>o}}function ya(e){return e===`SIGKILL`?137:e===`SIGINT`?130:143}function ba(e,t,n){let r=async()=>{if(!t?.wasUsed())return;let n=t.getMutations();(n.created.length||n.modified.length||n.deleted.length)&&await e.call(`vfs`,`flushWrites`,[n]),t.resetBaseline()},i=async(r=!1)=>{if(t?.wasUsed())try{let i=await e.call(`vfs`,`snapshot`,[n]);r?t.applySnapshotPreservingMutations(i):t.applySnapshot(i)}catch{}},a=async t=>{await r();try{return await e.call(`exec`,`run`,[t])}finally{await i()}},o=async t=>{await r();try{return await e.call(`exec`,`spawn`,[t])}finally{await i()}},s=1,c=Object.assign(a,{spawn:o,start:(t,n)=>{let a=s++,o=[],c=!1,l=!1,u=!1,d,f,p=new Promise((e,t)=>{d=e,f=t}),m=()=>{if(c||u||l)return;l=!0;let s=o.length>0?o.join(``):n?.stdin,p={};s!==void 0&&(p.stdin=s),n?.stdinKind!==void 0&&(p.stdinKind=n.stdinKind),n?.args!==void 0&&(p.args=n.args),(async()=>{try{if(await r(),u){await i(!0);return}c=!0;let n=await e.call(`exec`,`start`,[a,t,p]);await i(!0),d(n)}catch(e){await i(!0),f(e)}})()};return{kill:t=>c?e.call(`exec`,`kill`,[a,t]):(u=!0,d({stdout:``,stderr:``,exitCode:ya(t)}),Promise.resolve(!0)),stdin:{write:e=>{!c&&!u&&o.push(e)},end:()=>m()},done:p}}});return c.exec=c,c}function xa(e){let t=new TextEncoder().encode(e),n=``;for(let e=0;e<t.length;e++)n+=String.fromCharCode(t[e]);return btoa(n)}function Sa(e,t,n){let r=[];t.model&&r.push(`--model`,String(t.model)),t.thinking&&r.push(`--thinking`,String(t.thinking)),t.schema&&r.push(`--schema-b64`,xa(JSON.stringify(t.schema)));let i=t.readOnly===void 0?`/workspace/`:Array.isArray(t.readOnly)?t.readOnly.join(`,`):String(t.readOnly),a=t.cwd===void 0?n||`.`:String(t.cwd),o=t.allowedCommands===void 0?`*`:String(t.allowedCommands);return[`agent`,...r,`--read-only`,i,a,o,String(e)]}function Ca(e,t){let n=t.cwd,r=async(t,r)=>{let i=r??{},a=await e.spawn(Sa(t,i,n)),o=typeof a.exitCode==`number`?a.exitCode:0;return{finalText:String(a.stdout??``).replace(/\n+$/,``),exitCode:o,stderr:String(a.stderr??``).replace(/\n+$/,``)}},i=(async(e,t)=>{let n=t??{},i=await r(e,n);if(i.exitCode!==0)throw Error(`agent: exited with code ${i.exitCode}${i.stderr?`: ${i.stderr}`:``}`);if(n.schema)try{return JSON.parse(i.finalText)}catch{throw Error(`agent: schema response was not valid JSON (exit ${i.exitCode}): ${i.finalText.slice(0,200)}`)}return i.finalText});return i.spawn=r,i}function wa(e){return{...e,time:pr,fmt:Sr,pool:Cr}}function Ta(e){let t=!1;return{isTTY:!1,read(){return t?null:(t=!0,e)},toString(){return e},[Symbol.asyncIterator](){return{async next(){return t?{value:void 0,done:!0}:(t=!0,{value:e,done:!1})}}}}}function Ea(e,t){function n(e){if(e instanceof Uint8Array)return e;if(ArrayBuffer.isView(e)){let t=e;return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}return e instanceof ArrayBuffer?new Uint8Array(e):new TextEncoder().encode(typeof e==`string`?e:String(e))}async function r(t,n){let r=typeof n==`string`?n:n?.encoding;if(r===null||r===`buffer`){let n=await e.call(`vfs`,`readFileBinary`,[t]),r=globalThis.Buffer;return r?r.from(n instanceof Uint8Array?n:new Uint8Array(n)):n}return e.call(`vfs`,`readFile`,[t])}async function i(t,r){return typeof r==`string`?e.call(`vfs`,`writeFile`,[t,r]):e.call(`vfs`,`writeFileBinary`,[t,n(r)])}async function a(t,r){let i=new Uint8Array;if(await e.call(`vfs`,`exists`,[t])){let n=await e.call(`vfs`,`readFileBinary`,[t]);i=n instanceof Uint8Array?n:new Uint8Array(n)}let a=n(r),o=new Uint8Array(i.byteLength+a.byteLength);o.set(i),o.set(a,i.byteLength),await e.call(`vfs`,`writeFileBinary`,[t,o])}async function o(t,n,r){let i=await e.call(`vfs`,`stat`,[t]);if(i.isFile){let r=await e.call(`vfs`,`readFileBinary`,[t]);await e.call(`vfs`,`writeFileBinary`,[n,r]);return}if(!i.isDirectory||!r?.recursive)throw Error(`cp: '${t}' is a directory (use {recursive: true})`);await c(n);let a=await e.call(`vfs`,`readDir`,[t]);for(let e of a)await o(`${t}/${e}`,`${n}/${e}`,r)}async function s(t,n){if(n?.force&&!await e.call(`vfs`,`exists`,[t]))return!0;if((await e.call(`vfs`,`stat`,[t])).isFile)return e.call(`vfs`,`rm`,[t]);if(!n?.recursive)throw Error(`rm: '${t}' is a directory (use {recursive: true})`);let r=await e.call(`vfs`,`readDir`,[t]);for(let e of r)await s(`${t}/${e}`,n);return e.call(`vfs`,`rm`,[t])}async function c(t){await e.call(`vfs`,`mkdir`,[t])}async function l(t){for(let n=0;n<5;n++){let n=`${t}${Math.random().toString(36).slice(2,10)+Math.random().toString(36).slice(2,6)}`;if(!await e.call(`vfs`,`exists`,[n]))return await e.call(`vfs`,`mkdir`,[n]),n}throw Error(`mkdtemp: failed to create unique directory after 5 attempts`)}async function u(t,n){try{await e.call(`vfs`,`rename`,[t,n])}catch{let r=await e.call(`vfs`,`readFileBinary`,[t]);await e.call(`vfs`,`writeFileBinary`,[n,r]),await e.call(`vfs`,`rm`,[t])}}async function d(t){if(!await e.call(`vfs`,`exists`,[t]))throw Object.assign(Error(`ENOENT: no such file or directory, access '${t}'`),{code:`ENOENT`})}let f={readFile:r,readFileBinary:t=>e.call(`vfs`,`readFileBinary`,[t]),writeFile:i,writeFileBinary:(t,n)=>e.call(`vfs`,`writeFileBinary`,[t,n]),appendFile:a,cp:o,rm:s,readDir:t=>e.call(`vfs`,`readDir`,[t]),readdir:t=>e.call(`vfs`,`readDir`,[t]),exists:t=>e.call(`vfs`,`exists`,[t]),stat:t=>e.call(`vfs`,`stat`,[t]),mkdir:(t,n)=>e.call(`vfs`,`mkdir`,[t]),mkdtemp:l,rename:u,access:d,unlink:t=>e.call(`vfs`,`rm`,[t]),rmdir:t=>e.call(`vfs`,`rm`,[t]),copyFile:async(t,n)=>{let r=await e.call(`vfs`,`readFileBinary`,[t]);await e.call(`vfs`,`writeFileBinary`,[n,r])},fetchToFile:async(n,r)=>{let i=await t(n);if(!i.ok)throw Error(`fetch ${i.status} ${i.statusText}`);let a=new Uint8Array(await i.arrayBuffer());return await e.call(`vfs`,`writeFileBinary`,[r,a]),a.byteLength},promises:null};return f.promises=f,f}function Da(e,t){function n(e){return e.startsWith(`/`)?e:t+(t.endsWith(`/`)?``:`/`)+e}return{readFileSync(t,r){let i=typeof r==`string`?r:r?.encoding,a=e.readFile(n(t));if(i===`utf8`||i===`utf-8`)return new TextDecoder().decode(a);let o=globalThis.Buffer;return o?o.from(a):a},writeFileSync(t,r){let i;i=typeof r==`string`?new TextEncoder().encode(r):r instanceof Uint8Array?r:ArrayBuffer.isView(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new TextEncoder().encode(String(r)),e.writeFile(n(t),i)},existsSync(t){return e.exists(n(t))},mkdirSync(t,r){e.mkdir(n(t),r?.recursive)},statSync(t){let r=e.stat(n(t));return{isFile:()=>r.isFile,isDirectory:()=>r.isDirectory,size:r.size}},readdirSync(t){return e.readdir(n(t))},rmSync(t,r){let i=n(t);r?.force&&!e.exists(i)||e.rm(i,r?.recursive)},copyFileSync(t,r){e.copyFile(n(t),n(r))},mkdtempSync(t){return e.mkdtemp(n(t))},unlinkSync(t){e.unlink(n(t))},renameSync(t,r){e.rename(n(t),n(r))}}}function Oa(e,t){return e?.startsWith(`/`)?la(e):t}function ka(e){return e.includes(`require`)||e.includes(`import`)}async function Aa(e,t,n,r){return ka(t)?e.call(`module`,`buildGraph`,[t,Oa(r,n),r]):{files:[],entryMap:{},edges:{},errors:{}}}function ja(e){if(typeof e!=`object`||!e)return;let t=e;if(t.__esModule&&!Object.prototype.hasOwnProperty.call(t,`default`)&&Object.isExtensible(t))try{Object.defineProperty(t,"default",{value:t,enumerable:!1,configurable:!0})}catch{}}function Ma(e){return{playwright:Yi(e)}}function Na(e){let{graph:t,fsBridge:n,processShim:r,childProcess:i,nodeConsole:a,sliccyModules:o,shimmedPackages:s={}}=e,c=new Map(t.files.map(e=>[e.path,e.cjsSource])),l=new Map(t.files.map(e=>[e.path,e.kind])),u=new Map,d=e=>{if(typeof e==`string`&&e.startsWith(`sliccy:`))return{hit:!0,value:Ia(e,o)};let t=e.startsWith(`node:`)?e.slice(5):e,a=Pa(t,n,r,i);if(a.hit)return a;if(Zi.has(t))throw $i(e,t);if(Ui.has(t))throw Ra(e,t);return t in s?{hit:!0,value:s[t]}:{hit:!1}},f=(e,n)=>{let r=d(n);if(r.hit)return r.value;let i=e?.[n];if(i)return p(i);throw n in t.errors?Error(t.errors[n]):Fa(n)};function p(e){let n=u.get(e);if(n)return n.exports;let i=c.get(e);if(i===void 0)throw Error(`Cannot find module '${e}'`);let o={exports:{}};u.set(e,o);let s=n=>f(t.edges[e],n),d=la(e);return Function(`module`,`exports`,`require`,`__dirname`,`__filename`,`process`,`console`,`Buffer`,`global`,i)(o,o.exports,s,d,e,r,a,globalThis.Buffer,globalThis),l.get(e)===`cjs`&&ja(o.exports),o.exports}return{require:e=>f(t.entryMap,e)}}function Pa(e,t,n,r){return e===`fs`||e===`fs/promises`?{hit:!0,value:t}:e===`path`?{hit:!0,value:Pr}:e===`crypto`?{hit:!0,value:Gr}:e===`child_process`?{hit:!0,value:r}:e===`process`?{hit:!0,value:n}:e===`buffer`?{hit:!0,value:{Buffer:globalThis.Buffer}}:e===`assert`?{hit:!0,value:ti}:e===`assert/strict`?{hit:!0,value:ei}:e===`util`?{hit:!0,value:_i}:e===`events`?{hit:!0,value:Oi}:e===`os`?{hit:!0,value:Ci}:e===`stream`?{hit:!0,value:Ni}:e===`url`?{hit:!0,value:Ei}:e===`zlib`?{hit:!0,value:Si}:{hit:!1}}function Fa(e){if(e.startsWith(`.`)||e.startsWith(`/`)||e.startsWith(`node:`))return Error(`Cannot find module '${e}'`);let t=e.startsWith(`@`)?e.split(`/`).slice(0,2).join(`/`):e.split(`/`)[0];return Error(`Cannot find module '${e}' (run: ipk install ${t})`)}function Ia(e,t){let n=e.slice(7);if(n===``)throw Error(`require('sliccy:'): empty sliccy: module name`);if(!Object.prototype.hasOwnProperty.call(t,n))throw Error(`require('${e}'): unknown sliccy: module '${n}'. Known names: ${Object.keys(t).sort().join(`, `)}`);return t[n]}const La={http:` Use fetch() instead.`,https:` Use fetch() instead.`,crypto:` Use globalThis.crypto (Web Crypto API) instead.`};function Ra(e,t){return Error(`require('${e}'): Node built-in '${t}' is not available in the browser environment.${La[t]||``}`)}async function za(e,t,n,r){let i=Object.keys(t),a=i.map(e=>t[e]),o=Object.getPrototypeOf(async function(){}).constructor,s=new o(...i,`${r?`"use strict";
|
|
48
|
+
`:``}${e}`);try{return await s(...a),0}catch(e){return e instanceof ua?e.code:(n(`${e instanceof Error?e.stack??e.message:String(e)}\n`),1)}}function Ba(e,t){if(!e&&!(t instanceof Request))return;let n=t instanceof Request?t:null,r=(e?.method??n?.method??`GET`).toUpperCase(),i={};if(e?.headers)if(e.headers instanceof Headers)e.headers.forEach((e,t)=>{i[t]=e});else if(Array.isArray(e.headers))for(let[t,n]of e.headers)i[t]=n;else Object.assign(i,e.headers);else n&&n.headers.forEach((e,t)=>{i[t]=e});let a;return e?.body!==void 0&&e?.body!==null&&e?.body!==``&&(a=typeof e.body==`string`?e.body:String(e.body)),{method:r,headers:i,body:a}}function Va(e){return{findTab:t=>e.call(`browser`,`findTab`,[Xa(t)]),ensureTab:(t,n={})=>e.call(`browser`,`ensureTab`,[t,Za(n)]),eval:(t,n)=>e.call(`browser`,`eval`,[Ha(t),Ua(n,!1)]),evalAsync:(t,n)=>e.call(`browser`,`evalAsync`,[Ha(t),Ua(n,!0)]),cookie:(t,n)=>e.call(`browser`,`cookie`,[Ha(t),n]),localStorage:(t,n)=>e.call(`browser`,`localStorage`,[Ha(t),n]),fetch:(t,n,r={})=>Ya(n,r).then(n=>e.call(`browser`,`evalAsync`,[Ha(t),n])),websocket:Qa(e)}}function Ha(e){if(typeof e==`string`)return e;if(e&&typeof e==`object`&&typeof e.targetId==`string`)return e.targetId;throw TypeError(`browser: expected a tab handle or targetId string`)}function Ua(e,t){if(typeof e==`function`)return`(${e.toString()})()`;if(typeof e==`string`)return e;throw TypeError(`browser.eval/evalAsync: source must be a function or string`)}function Wa(e){let t=``,n=32768;for(let r=0;r<e.length;r+=n)t+=String.fromCharCode(...Array.from(e.subarray(r,r+n)));return btoa(t)}async function Ga(e){let t=[];for(let[n,r]of e.entries()){if(typeof r==`string`){t.push({name:n,value:r});continue}let e=new Uint8Array(await r.arrayBuffer());t.push({name:n,file:{data:Wa(e),filename:typeof r.name==`string`?r.name:`blob`,type:r.type||``}})}return{kind:`formdata`,entries:t}}async function Ka(e,t){let n=()=>Object.keys(t).some(e=>e.toLowerCase()===`content-type`);return typeof e==`string`?{body:e}:e instanceof URLSearchParams?(n()||(t[`Content-Type`]=`application/x-www-form-urlencoded;charset=UTF-8`),{body:e.toString()}):e instanceof Blob?{descriptor:{kind:`blob`,data:Wa(new Uint8Array(await e.arrayBuffer())),type:e.type||``}}:e instanceof ArrayBuffer?{descriptor:{kind:`bytes`,data:Wa(new Uint8Array(e))}}:ArrayBuffer.isView(e)?{descriptor:{kind:`bytes`,data:Wa(new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}}:e instanceof FormData?{descriptor:await Ga(e)}:(n()||(t[`Content-Type`]=`application/json`),{body:JSON.stringify(e)})}function qa(e){return e?`const __b64 = (s) => { const bin = atob(s); const n = bin.length; const u = new Uint8Array(n); for (let i = 0; i < n; i++) u[i] = bin.charCodeAt(i); return u; };const __body = `+JSON.stringify(e)+`;if (__body.kind === 'bytes') { __init.body = __b64(__body.data); }else if (__body.kind === 'blob') { __init.body = new Blob([__b64(__body.data)], { type: __body.type }); }else if (__body.kind === 'formdata') { const __fd = new FormData(); for (const e of __body.entries) { if (e.file) { __fd.append(e.name, new Blob([__b64(e.file.data)], { type: e.file.type }), e.file.filename); } else { __fd.append(e.name, e.value); } } __init.body = __fd; }`:``}function Ja(e){return`const h = {};r.headers.forEach((v, k) => { h[k] = v; });const ct = r.headers.get('content-type') || '';const __rt = `+JSON.stringify(e??null)+`;const __ctl = ct.toLowerCase();const __binPrefixes = ['image/','audio/','video/','application/octet-stream','application/pdf','application/protobuf','application/x-protobuf','application/wasm','application/zip'];const __isXml = __ctl.indexOf('+xml') !== -1 || __ctl.indexOf('application/xml') === 0 || __ctl.indexOf('text/xml') === 0;const __isBinary = __rt === 'binary' || (__rt !== 'text' && __rt !== 'json' && !__isXml && __binPrefixes.some((p) => __ctl.indexOf(p) === 0));if (__isBinary) {const __u = new Uint8Array(await r.arrayBuffer());let __s = ''; const __cs = 0x8000;for (let __i = 0; __i < __u.length; __i += __cs) { __s += String.fromCharCode.apply(null, __u.subarray(__i, __i + __cs)); }return { ok: r.ok, status: r.status, headers: h, body: btoa(__s), bodyEncoding: 'base64' };}const t = await r.text();let b;const __jsonWanted = __rt === 'json' || (__rt !== 'text' && ct.indexOf('application/json') !== -1);if (__jsonWanted) { if (!t) { b = null; } else { try { b = JSON.parse(t); } catch (e) { b = t; } } }else { b = t; }return { ok: r.ok, status: r.status, headers: h, body: b };`}async function Ya(e,t={}){let n={},r=t.headers??{};for(let[e,t]of Object.entries(r))typeof t==`string`&&(n[e]=t);let i=typeof t.method==`string`?t.method:`GET`,a=t.credentials===`same-origin`||t.credentials===`omit`?t.credentials:`include`,o=t.body,{body:s,descriptor:c}=o==null?{}:await Ka(o,n),l={method:i,credentials:a,headers:n};s!==void 0&&(l.body=s);for(let e of[`mode`,`cache`,`redirect`,`referrer`,`referrerPolicy`,`integrity`,`keepalive`]){let n=t[e];n!==void 0&&(l[e]=n)}let u=qa(c),d=Ja(t.responseType);return`(async () => {const __init = `+JSON.stringify(l)+`;`+u+`const r = await fetch(`+JSON.stringify(e)+`, __init);`+d+`})()`}function Xa(e){let t={};return e.domain!==void 0&&(t.domain=e.domain),e.urlMatch!==void 0&&(t.urlMatch=e.urlMatch instanceof RegExp?e.urlMatch.source:e.urlMatch),t}function Za(e){return e.matchUrl===void 0?{}:{matchUrl:e.matchUrl instanceof RegExp?e.matchUrl.source:e.matchUrl}}function Qa(e){function t(t){return{...t,async update(n){let r={};return n.urlMatch!==void 0&&(r.urlMatch=n.urlMatch===null?null:n.urlMatch instanceof RegExp?n.urlMatch.source:n.urlMatch),n.filter!==void 0&&(r.filter=n.filter),e.call(`browser`,`wsUpdate`,[t.id,r])},async close(){return e.call(`browser`,`wsClose`,[t.id])}}}return{on(n,r={}){let i=Ha(n),a=r.urlMatch===void 0?void 0:r.urlMatch instanceof RegExp?r.urlMatch.source:r.urlMatch,o,s={filter(e){if(typeof e==`function`||typeof e==`string`)throw TypeError(`browser.websocket: filter must be a declarative JSON object, not a function or string`);return o=e,s},async forward(n){return t(await e.call(`browser`,`wsObserve`,[{targetId:i,urlMatch:a,filter:o,forward:n}]))}};return s},async list(){return e.call(`browser`,`wsList`,[])}}}function $a(e){if(e instanceof Uint8Array)return e;if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(e instanceof ArrayBuffer)return new Uint8Array(e);throw TypeError(`expected an ArrayBuffer or typed array`)}function eo(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function to(e){return e==null?[]:Array.isArray(e)?e:[e]}function no(e,t){let n=t.handle,r=e=>({status:e.status,data:eo(e.bytes)});return{...t,open:()=>e.call(`usb`,`open`,[n]),close:()=>e.call(`usb`,`close`,[n]),reset:()=>e.call(`usb`,`reset`,[n]),selectConfiguration:t=>e.call(`usb`,`selectConfig`,[n,t]),claimInterface:t=>e.call(`usb`,`claim`,[n,t]),releaseInterface:t=>e.call(`usb`,`release`,[n,t]),controlTransferIn:async(t,i)=>r(await e.call(`usb`,`controlIn`,[n,t,i])),controlTransferOut:(t,r)=>e.call(`usb`,`controlOut`,[n,t,$a(r)]),transferIn:async(t,i)=>r(await e.call(`usb`,`transferIn`,[n,t,i])),transferOut:(t,r)=>e.call(`usb`,`transferOut`,[n,t,$a(r)])}}function ro(e){return{list:async()=>(await e.call(`usb`,`list`,[])).map(t=>no(e,t)),request:async t=>no(e,await e.call(`usb`,`request`,[to(t)]))}}function io(e,t){let n=t.handle;return{...t,open:t=>e.call(`serial`,`open`,[n,t]),close:()=>e.call(`serial`,`close`,[n]),read:(t={})=>e.call(`serial`,`read`,[n,{maxBytes:t.maxBytes??t.bytes,until:t.until?$a(t.until):void 0,timeoutMs:t.timeoutMs}]),write:t=>e.call(`serial`,`write`,[n,$a(t)]),getSignals:()=>e.call(`serial`,`getSignals`,[n]),setSignals:t=>e.call(`serial`,`setSignals`,[n,t])}}function ao(e){return{list:async()=>(await e.call(`serial`,`list`,[])).map(t=>io(e,t)),request:async t=>io(e,await e.call(`serial`,`request`,[to(t)]))}}function oo(e,t){let n=t.handle,r=new Set,i=new Set,a=!1,o=null,s=e=>{let t=e;if(!t||t.handle!==n)return;let i={reportId:t.reportId,data:eo(t.bytes)};for(let e of[...r])try{e(i)}catch{}},c=()=>{a||(a=!0,o=e.onEvent?e.onEvent(`hid-input-report`,s):null,e.call(`hid`,`subscribeInputReports`,[n]).catch(()=>{a=!1,o?.(),o=null}))},l=()=>{!a||r.size>0||(a=!1,o?.(),o=null,e.call(`hid`,`unsubscribeInputReports`,[n]).catch(()=>{}))};return{...t,open:()=>e.call(`hid`,`open`,[n]),close:()=>e.call(`hid`,`close`,[n]),sendReport:(t,r)=>e.call(`hid`,`sendReport`,[n,t,$a(r)]),sendFeatureReport:(t,r)=>e.call(`hid`,`sendFeatureReport`,[n,t,$a(r)]),receiveFeatureReport:async t=>eo((await e.call(`hid`,`receiveFeatureReport`,[n,t])).bytes),addEventListener(e,t){if(e===`inputreport`)r.add(t),c();else if(e===`disconnect`)i.add(t);else throw TypeError(`hid device: unknown event type '${String(e)}'`)},removeEventListener(e,t){e===`inputreport`?(r.delete(t),l()):e===`disconnect`&&i.delete(t)},onInputReport(e){r.add(e),c()}}}function so(e){return{list:async()=>(await e.call(`hid`,`list`,[])).map(t=>oo(e,t)),request:async t=>{let n=(await e.call(`hid`,`request`,[to(t)]))[0];if(!n)throw Error(`No device selected.`);return oo(e,n)}}}const co={postMessage:(e,t)=>t?self.postMessage(e,t):self.postMessage(e),addEventListener:(e,t)=>self.addEventListener(e,t),removeEventListener:(e,t)=>self.removeEventListener(e,t)};self.addEventListener(`message`,e=>{if(e.data?.type!==`realm-init`)return;let t=e.data;t.kind===`js`&&ma(t,co).catch(e=>{let t={type:`realm-error`,message:e instanceof Error?e.message:String(e)};self.postMessage(t)})});
|