sliccy 2.45.4 → 2.46.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/{adobe-avKwr7Dm.js → adobe-CEkMgLY6.js} +1 -1
- package/dist/ui/assets/{adobe-tvf67GRq.js → adobe-pfo8dkS1.js} +1 -1
- package/dist/ui/assets/{agent-bridge-DiVkgwz-.js → agent-bridge-FKQ_SiYR.js} +1 -1
- package/dist/ui/assets/{agent-message-to-chat-Cbt_9_fN.js → agent-message-to-chat-BlIs6e4u.js} +1 -1
- package/dist/ui/assets/{anthropic-CWEVurmr.js → anthropic-DS0SZslL.js} +1 -1
- package/dist/ui/assets/{anthropic-CJwUhBlX.js → anthropic-DcwLBACY.js} +1 -1
- package/dist/ui/assets/{azure-openai-BdX0RC5r.js → azure-openai-Ci_Th3ev.js} +1 -1
- package/dist/ui/assets/{azure-openai-tDQwCw_S.js → azure-openai-X30Lthb4.js} +1 -1
- package/dist/ui/assets/{azure-openai-responses-DJ9LbDv9.js → azure-openai-responses-BIgSJwWG.js} +1 -1
- package/dist/ui/assets/{azure-openai-responses-BDfegDRI.js → azure-openai-responses-Vz3Rt_gC.js} +1 -1
- package/dist/ui/assets/{bedrock-camp-DZoSTfJa.js → bedrock-camp-oMWjq1w0.js} +3 -3
- package/dist/ui/assets/{bedrock-camp-BTPbdI5P.js → bedrock-camp-sX3SaGD9.js} +2 -2
- package/dist/ui/assets/{cdp-B-G1EOxs.js → cdp-DkqC8PpG.js} +2 -2
- package/dist/ui/assets/cost-command-CZ_FIZsh.js +1 -0
- package/dist/ui/assets/{es-a26K4k4j.js → es-4JXw-ziF.js} +1 -1
- package/dist/ui/assets/{fs-C5Bh6SAK.js → fs-CVxR5_ux.js} +3 -3
- package/dist/ui/assets/{fs-BxaZxvu8.js → fs-ChJuGWFt.js} +2 -2
- package/dist/ui/assets/{github-BdUQG7nB.js → github-C9rZzPwm.js} +1 -1
- package/dist/ui/assets/{github-CXH07t6L.js → github-whKRO7V4.js} +2 -2
- package/dist/ui/assets/{google-BAax5yWz.js → google-CRylOWk0.js} +1 -1
- package/dist/ui/assets/{google-DtE60DkT.js → google-DLIE-XI-.js} +1 -1
- package/dist/ui/assets/{index-C59z0nlR.js → index-DC0yFifh.js} +5 -5
- package/dist/ui/assets/js-realm-worker-Dh5NKB0f.js +1 -0
- package/dist/ui/assets/{kernel-worker-Cpe3B5AZ.js → kernel-worker-CfrmOaHB.js} +14 -14
- package/dist/ui/assets/{local-llm-Cz-Egtek.js → local-llm-CJzFL4ih.js} +1 -1
- package/dist/ui/assets/{local-llm-D6PNDXul.js → local-llm-COoR-MZW.js} +1 -1
- package/dist/ui/assets/{magick-wasm-C0UYrNr8.js → magick-wasm-CJevWwoW.js} +1 -1
- package/dist/ui/assets/{mistral-B5chjbWN.js → mistral-DKksTMIW.js} +1 -1
- package/dist/ui/assets/{mistral-Bm7Flw3U.js → mistral-DNyQLocj.js} +1 -1
- package/dist/ui/assets/{mount-CeV8nQDH.js → mount-0SSqBEqr.js} +2 -2
- package/dist/ui/assets/{mount-BtuRh1GY.js → mount-C7lbbYhG.js} +1 -1
- package/dist/ui/assets/{nuke-command-Kwh9fpJ-.js → nuke-command-bVxp1Hc_.js} +1 -1
- package/dist/ui/assets/{oauth-bootstrap-CJU0rioR.js → oauth-bootstrap-Csp1r2Bf.js} +1 -1
- package/dist/ui/assets/{oauth-service-OzjrJhvT.js → oauth-service-B5C1N2fh.js} +1 -1
- package/dist/ui/assets/{offscreen-client-BU_msuje.js → offscreen-client-A0eZR46g.js} +1 -1
- package/dist/ui/assets/{onboarding-orchestrator-BK2UqVst.js → onboarding-orchestrator-j6kwLNC7.js} +1 -1
- package/dist/ui/assets/{openai-codex-responses-CZWGyVjG.js → openai-codex-responses-9ApV86q4.js} +1 -1
- package/dist/ui/assets/{openai-codex-responses-C7dp_KxL.js → openai-codex-responses-AbjYRHz6.js} +1 -1
- package/dist/ui/assets/{openai-completions-D9Ykqp6l.js → openai-completions-CONoOlAn.js} +1 -1
- package/dist/ui/assets/{openai-completions-COqqEP8O.js → openai-completions-D8pTAy_A.js} +1 -1
- package/dist/ui/assets/{openai-responses-trulc-Fw.js → openai-responses-BDdpB0oy.js} +1 -1
- package/dist/ui/assets/{openai-responses-rs7x-URy.js → openai-responses-BoWKpVRR.js} +1 -1
- package/dist/ui/assets/{openai-responses-shared-B_MOgAN_.js → openai-responses-shared-CNoKazjO.js} +1 -1
- package/dist/ui/assets/{openai-responses-shared-BbssLGOF.js → openai-responses-shared-CkOZ1DXy.js} +1 -1
- package/dist/ui/assets/{provider-settings-BzJrOSG3.js → provider-settings-BJiQwAz7.js} +2 -2
- package/dist/ui/assets/{provider-settings-BdZH5Wj1.js → provider-settings-CpChAEwc.js} +1 -1
- package/dist/ui/assets/{providers-BEE1lB4a.js → providers-zTkMw2SC.js} +1 -1
- package/dist/ui/assets/{spawn-DCVh5mXD.js → spawn-D3Rr5or4.js} +1 -1
- package/dist/ui/assets/{upgrade-detection-Ce7X_CBC.js → upgrade-detection-CEFruYPw.js} +1 -1
- package/dist/ui/index.html +6 -6
- package/dist/ui/packages/webapp/index.html +6 -6
- package/package.json +1 -1
- package/dist/ui/assets/cost-command-BtV9Fq05.js +0 -1
- package/dist/ui/assets/js-realm-worker-CqCu-yXu.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=class{nextId=1;pending=new Map;handler;disposed=!1;constructor(e){this.port=e,this.handler=e=>{if(e.data?.type!==`realm-rpc-res`)return;let t=e.data,n=this.pending.get(t.id);n&&(this.pending.delete(t.id),typeof t.error==`string`?n.reject(Error(t.error)):n.resolve(t.result))},e.addEventListener(`message`,this.handler),e.start?.()}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)})}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()}};const t=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`]),n={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 r(e,t){let r=n[t]??``;return Error(`require('${e}'): '${t}' is a Node native module (C++ bindings) — it cannot run in the browser sandbox.${r}`)}function i(e,t,n){return new Promise((r,i)=>{let a=setTimeout(()=>{i(Error(`Timed out after ${t/1e3}s loading ${n}`))},t);e.then(e=>{clearTimeout(a),r(e)},e=>{clearTimeout(a),i(e)})})}const a=new Set([`http`,`https`,`net`,`tls`,`dgram`,`dns`,`cluster`,`worker_threads`,`child_process`,`crypto`,`os`,`stream`,`zlib`,`vm`,`v8`,`perf_hooks`,`readline`,`repl`,`tty`,`inspector`]),o=new Set([`fs`,`process`,`buffer`]);var s=class extends Error{constructor(e){super(`Process exited with code ${e}`),this.code=e,this.name=`NodeExitError`}};function c(e){let t=/\brequire\s*\(\s*(['"`])([^'"`\s]+)\1\s*\)/g,n=new Set,r;for(;(r=t.exec(e))!==null;)n.add(r[2]);return[...n]}function l(e){if(typeof e==`string`)return e;if(e==null)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}async function u(n,u,p=f){let m=[],h=[],g=e=>{m.push(typeof e==`string`?e:String(e))},_=e=>{h.push(typeof e==`string`?e:String(e))},v={log:(...e)=>g(`${e.map(l).join(` `)}\n`),info:(...e)=>g(`${e.map(l).join(` `)}\n`),warn:(...e)=>_(`${e.map(l).join(` `)}\n`),error:(...e)=>_(`${e.map(l).join(` `)}\n`)},y=n.stdin??``,b=!1,x={isTTY:!1,read(){return b?null:(b=!0,y)},toString(){return y},[Symbol.asyncIterator](){return{async next(){return b?{value:void 0,done:!0}:(b=!0,{value:y,done:!1})}}}},S={argv:n.argv,env:n.env,cwd:()=>n.cwd,exit:e=>{throw new s(Number.isFinite(e)?Number(e):0)},stdin:x,stdout:{write:g},stderr:{write:_}},C=new e(u),w={readFile:e=>C.call(`vfs`,`readFile`,[e]),readFileBinary:e=>C.call(`vfs`,`readFileBinary`,[e]),writeFile:(e,t)=>C.call(`vfs`,`writeFile`,[e,t]),writeFileBinary:(e,t)=>C.call(`vfs`,`writeFileBinary`,[e,t]),readDir:e=>C.call(`vfs`,`readDir`,[e]),exists:e=>C.call(`vfs`,`exists`,[e]),stat:e=>C.call(`vfs`,`stat`,[e]),mkdir:e=>C.call(`vfs`,`mkdir`,[e]),rm:e=>C.call(`vfs`,`rm`,[e]),fetchToFile:async(e,t)=>{let n=await E(e);if(!n.ok)throw Error(`fetch ${n.status} ${n.statusText}`);let r=new Uint8Array(await n.arrayBuffer());return await C.call(`vfs`,`writeFileBinary`,[t,r]),r.byteLength}},T=e=>C.call(`exec`,`run`,[e]);async function E(e,t){let n=e instanceof Request?e.url:e instanceof URL?e.toString():String(e),r=await C.call(`fetch`,`request`,[n,d(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 D=c(n.code).map(e=>e.startsWith(`node:`)?e.slice(5):e).filter(e=>!o.has(e)&&!a.has(e)),O=D.filter(e=>t.has(e)),k=D.filter(e=>!t.has(e));for(let e of O)_(`Warning: ${r(e,e).message}\n`);let A=Object.create(null);if(k.length>0){let e=await Promise.allSettled(k.map(async e=>{let t=await i(p(e),15e3,`require('${e}')`);A[e]=t&&`default`in t?t.default:t}));for(let t=0;t<e.length;t++){let n=e[t];if(n.status===`rejected`){let e=n.reason instanceof Error?n.reason.message:String(n.reason);_(`Warning: failed to pre-load require('${k[t]}'): ${e}\n`)}}}let j=e=>{let n=e.startsWith(`node:`)?e.slice(5):e;if(n===`fs`)return w;if(n===`process`)return S;if(n===`buffer`)return{Buffer:globalThis.Buffer};if(n===`path`){if(`path`in A)return A.path;if(e in A)return A[e];throw Error(`require('${e}'): path module not pre-loaded. Add require('path') as a static import.`)}if(t.has(n))throw r(e,n);if(a.has(n))throw Error(`require('${e}'): Node built-in '${n}' is not available in the browser environment.${{http:` Use fetch() instead.`,https:` Use fetch() instead.`,child_process:` Use exec() which is available as a shell bridge.`,crypto:` Use globalThis.crypto (Web Crypto API) instead.`}[n]||``}`);if(e in A)return A[e];if(n in A)return A[n];throw Error(`require('${e}'): module not pre-loaded. Use a string literal so it can be pre-fetched, or use \`await import('https://esm.sh/${e}')\` directly.`)},M={exports:{},filename:n.filename},N=0;try{let e=Object.getPrototypeOf(async function(){}).constructor;await new e(`fs`,`process`,`console`,`require`,`module`,`exports`,`exec`,`fetch`,`"use strict";\n${n.code}`)(w,S,v,j,M,M.exports,T,E)}catch(e){e instanceof s?N=e.code:(_(`${e instanceof Error?e.stack??e.message:String(e)}\n`),N=1)}C.dispose();let P={type:`realm-done`,stdout:m.join(``),stderr:h.join(``),exitCode:N};u.postMessage(P)}function d(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}}async function f(e){return await import(`https://esm.sh/`+e)}const p={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`&&u(t,p).catch(e=>{let t={type:`realm-error`,message:e instanceof Error?e.message:String(e)};self.postMessage(t)})});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e,o as t,r as n,t as r}from"./chunk-jRWAZmH_.js";import{t as i}from"./logger-BHrAkMIS.js";import{_ as a,a as o,b as s,c,d as l,f as u,g as d,h as f,i as p,l as m,m as h,n as g,o as _,p as v,r as y,s as b,t as x,u as S,v as C,x as w,y as T}from"./db-Cdoacmjm.js";import{C as E,S as D,_ as O,b as ee,c as te,d as ne,g as k,h as re,m as ie,n as ae,p as oe,r as se,u as ce,v as le,x as ue,y as de}from"./provider-settings-
|
|
1
|
+
import{i as e,o as t,r as n,t as r}from"./chunk-jRWAZmH_.js";import{t as i}from"./logger-BHrAkMIS.js";import{_ as a,a as o,b as s,c,d as l,f as u,g as d,h as f,i as p,l as m,m as h,n as g,o as _,p as v,r as y,s as b,t as x,u as S,v as C,x as w,y as T}from"./db-Cdoacmjm.js";import{C as E,S as D,_ as O,b as ee,c as te,d as ne,g as k,h as re,m as ie,n as ae,p as oe,r as se,u as ce,v as le,x as ue,y as de}from"./provider-settings-CpChAEwc.js";import{i as fe,n as A,r as pe}from"./fs-ChJuGWFt.js";import{n as me,t as he}from"./path-utils-B73K5PBp.js";import{t as ge}from"./mount-id-BBl3dJu8.js";import{a as _e,i as ve,r as ye,t as be}from"./git-config-DZUguBxI.js";import{n as xe,t as j}from"./mime-types-CtECiBq5.js";import{_ as Se,a as Ce,c as we,d as Te,f as Ee,g as M,h as De,i as N,l as P,m as Oe,o as ke,p as Ae,r as je,s as F,t as Me,u as Ne,v as Pe}from"./magick-wasm-DwA3cs4T.js";import{c as Fe,o as Ie}from"./bedrock-camp-sX3SaGD9.js";import{t as Le}from"./__vite-browser-external-BvI1wG2f.js";import{f as Re}from"./transform-messages-DlZklr1h.js";import{i as ze}from"./providers-zTkMw2SC.js";import{t as Be}from"./local-llm-CJzFL4ih.js";import{a as Ve,i as He,n as Ue,r as We}from"./mount-C7lbbYhG.js";import{t as Ge}from"./remote-cache-BdYCICnT.js";const Ke=i(`cdp`);var qe=class{ws=null;nextId=1;pending=new Map;listeners=new Map;_state=`disconnected`;get state(){return this._state}async connect(e){if(this._state!==`disconnected`)throw Error(`Cannot connect: state is ${this._state}`);if(!e?.url)throw Error(`CDPClient.connect() requires a WebSocket URL`);let{url:t,timeout:n=5e3}=e;return this._state=`connecting`,new Promise((e,r)=>{let i=setTimeout(()=>{this.cleanup(),r(Error(`CDP connection timed out after ${n}ms`))},n);try{this.ws=new WebSocket(t)}catch(e){clearTimeout(i),this._state=`disconnected`,r(e);return}this.ws.onopen=()=>{clearTimeout(i),this._state=`connected`,Ke.info(`Connected`,{url:t}),e()},this.ws.onerror=e=>{clearTimeout(i),this._state===`connecting`&&(Ke.error(`Connection failed`,{url:t}),this.cleanup(),r(Error(`CDP WebSocket connection failed`)))},this.ws.onmessage=e=>{this.handleMessage(e.data)},this.ws.onclose=()=>{this.handleClose()}})}disconnect(){this.ws&&(this.ws.onclose=null,this.ws.close()),this.cleanup(),Ke.info(`Disconnected`)}async send(e,t,n,r=3e4){if(this._state!==`connected`||!this.ws)throw Error(`CDP client is not connected`);let i=this.nextId++,a={id:i,method:e};return t&&(a.params=t),n&&(a.sessionId=n),Ke.debug(`Send`,{method:e,id:i,sessionId:n}),new Promise((t,n)=>{let o=setTimeout(()=>{this.pending.delete(i),n(Error(`CDP command timed out after ${r}ms: ${e}`))},r);this.pending.set(i,{resolve:e=>{clearTimeout(o),t(e)},reject:e=>{clearTimeout(o),n(e)}}),this.ws.send(JSON.stringify(a))})}on(e,t){let n=this.listeners.get(e);n||(n=new Set,this.listeners.set(e,n)),n.add(t)}off(e,t){let n=this.listeners.get(e);n&&(n.delete(t),n.size===0&&this.listeners.delete(e))}once(e,t=3e4){return new Promise((n,r)=>{let i=setTimeout(()=>{this.off(e,a),r(Error(`Timed out waiting for event: ${e}`))},t),a=t=>{clearTimeout(i),this.off(e,a),n(t)};this.on(e,a)})}handleMessage(e){let t;try{t=JSON.parse(e)}catch{return}if(`id`in t&&typeof t.id==`number`){let e=t;Ke.debug(`Response`,{id:e.id,hasError:!!e.error});let n=this.pending.get(e.id);n&&(this.pending.delete(e.id),e.error?(Ke.error(`Command error`,{id:e.id,code:e.error.code,message:e.error.message}),n.reject(Error(`CDP error: ${e.error.message} (${e.error.code})`))):n.resolve(e.result??{}));return}if(`method`in t){let e=t;Ke.debug(`Event`,{method:e.method,sessionId:e.sessionId});let n=this.listeners.get(e.method);if(n){let t=e.sessionId?{...e.params,sessionId:e.sessionId}:e.params??{};for(let e of n)try{e(t)}catch{}}}}handleClose(){Ke.error(`Connection closed unexpectedly`,{pendingCommands:this.pending.size});for(let[,e]of this.pending)e.reject(Error(`CDP connection closed`));this.cleanup()}cleanup(){this.ws=null,this._state=`disconnected`,this.pending.clear()}};function Je(e,t=``){if(e==null)return t;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e);try{return JSON.stringify(e)??t}catch{return String(e)}}const Ye=`(function() {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
// ===== DOM Utilities =====
|
|
@@ -876,7 +876,7 @@ import{i as e,o as t,r as n,t as r}from"./chunk-jRWAZmH_.js";import{t as i}from"
|
|
|
876
876
|
this.scrollIntoView({ block: 'center', inline: 'center' });
|
|
877
877
|
const r = this.getBoundingClientRect();
|
|
878
878
|
return { x: r.x, y: r.y, width: r.width, height: r.height };
|
|
879
|
-
}`,returnByValue:!0},this.sessionId)).result?.value;if(!n||n.width===0||n.height===0)throw Error(`Element with backend node ${e} has no dimensions`);return{x:n.x+n.width/2,y:n.y+n.height/2}}async ensureLocalConnected(){this.localClient.state===`disconnected`&&await this.localClient.connect({url:Ze()})}async ensureConnected(){this.client.state===`disconnected`&&(this.remoteTargetInfo&&this.trayTargetProvider?.removeRemoteTransport&&(this.trayTargetProvider.removeRemoteTransport(this.remoteTargetInfo.runtimeId,this.remoteTargetInfo.localTargetId),this.setClient(this.localClient),this.remoteTargetInfo=null),this.sessionId=null,this.attachedTargetId=null,this.client.state===`disconnected`&&await this.connect())}ensureAttached(){if(!this.sessionId)throw Error(`Not attached to a page. Call attachToPage(targetId) first.`)}addDialogListener(e){e.on(`Page.javascriptDialogOpening`,this.handleJavaScriptDialogOpening)}removeDialogListener(e){e.off(`Page.javascriptDialogOpening`,this.handleJavaScriptDialogOpening)}setClient(e){this.client!==e&&(this.removeDialogListener(this.client),this.client=e,this.addDialogListener(this.client))}async boundingBox(e){await this.client.send(`DOM.enable`,{},this.sessionId);let t=(await this.client.send(`DOM.getDocument`,{depth:0},this.sessionId)).root.nodeId,n;try{n=(await this.client.send(`DOM.querySelector`,{nodeId:t,selector:e},this.sessionId)).nodeId}catch{return null}if(!n)return null;let r=(await this.client.send(`DOM.getBoxModel`,{nodeId:n},this.sessionId)).model;if(!r)return null;let i=r.content;return{x:i[0],y:i[1],width:r.width,height:r.height}}};function $e(e){let t={role:Je(e.role,`unknown`),name:Je(e.name)},n=Je(e.value);n!==``&&(t.value=n);let r=Je(e.description);return r!==``&&(t.description=r),Array.isArray(e.children)&&e.children.length>0&&(t.children=e.children.map(e=>$e(e)).filter(e=>e.role!==`unknown`)),t}function et(e){return e.headers.get(`x-proxy-error`)===`1`}async function tt(e){let t=`Proxy error ${e.status}`,n;try{n=await e.text()}catch{return t}return nt(n,t)}function nt(e,t){let n;try{n=JSON.parse(e)}catch{return t}if(!n||typeof n!=`object`)return t;let r=n.error;if(typeof r==`string`&&r.length>0)return r;if(r&&typeof r==`object`){let e=r.message;if(typeof e==`string`&&e.length>0)return e;try{return JSON.stringify(r)}catch{return t}}return t}i(`tray-leader`);let rt={state:`inactive`,session:null,error:null};function it(){return{...rt,session:rt.session?{...rt.session}:null}}const at=new Set;function ot(e){return at.add(e),()=>{at.delete(e)}}const st=new Set([`send_message`,`list_scoops`,`list_tasks`]),ct=`sessions`;function lt(){return new Promise((e,t)=>{let n=indexedDB.open(`browser-coding-agent`,1);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(ct)||e.createObjectStore(ct,{keyPath:`id`})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}var ut=class{db=null;async init(){this.db=await lt()}ensureDb(){if(!this.db)throw Error(`SessionStore not initialized. Call init() first.`);return this.db}async save(e){let t=this.ensureDb();return new Promise((n,r)=>{let i=t.transaction(ct,`readwrite`);i.objectStore(ct).put(e),i.oncomplete=()=>n(),i.onerror=()=>r(i.error)})}async load(e){let t=this.ensureDb();return new Promise((n,r)=>{let i=t.transaction(ct,`readonly`).objectStore(ct).get(e);i.onsuccess=()=>n(i.result??null),i.onerror=()=>r(i.error)})}async list(){let e=this.ensureDb();return new Promise((t,n)=>{let r=e.transaction(ct,`readonly`).objectStore(ct).getAll();r.onsuccess=()=>{t(r.result.sort((e,t)=>t.updatedAt-e.updatedAt).map(e=>e.id))},r.onerror=()=>n(r.error)})}async delete(e){let t=this.ensureDb();return new Promise((n,r)=>{let i=t.transaction(ct,`readwrite`);i.objectStore(ct).delete(e),i.oncomplete=()=>n(),i.onerror=()=>r(i.error)})}async saveMessages(e,t){let n=await this.load(e),r=n?{...n,messages:t,updatedAt:Date.now()}:{id:e,messages:t,createdAt:Date.now(),updatedAt:Date.now()};await this.save(r)}};const dt=i(`tool-ui`),ft=new class{pending=new Map;idCounter=0;generateId(){return`tool-ui-${++this.idCounter}-${Date.now().toString(36)}`}register(e,t,n,r){this.pending.set(e,{request:t,resolve:n,reject:r}),dt.info(`Tool UI registered`,{id:e})}async handleAction(e,t){let n=this.pending.get(e);if(!n){dt.warn(`Action for unknown tool UI`,{id:e,action:t.action});return}dt.info(`Tool UI action`,{id:e,action:t.action});try{let e;e=n.request.onAction?await n.request.onAction(t.action,t.data):t,n.resolve(e)}catch(e){n.reject(e instanceof Error?e:Error(String(e)))}finally{this.pending.delete(e)}}cancel(e,t=`cancelled`){let n=this.pending.get(e);n&&(n.reject(Error(t)),this.pending.delete(e),dt.info(`Tool UI cancelled`,{id:e,reason:t}))}cancelAll(e=`cancelled`){let t=this.pending.size;for(let[t,n]of this.pending)n.reject(Error(e));this.pending.clear(),t>0&&dt.info(`All tool UIs cancelled`,{reason:e,count:t})}isPending(e){return this.pending.has(e)}getPendingIds(){return[...this.pending.keys()]}};async function pt(e,t){let n=e.id??ft.generateId(),r,i,a=new Promise((e,t)=>{r=e,i=t});return ft.register(n,e,r,i),t?t({content:[{type:`tool_ui`,requestId:n,html:e.html}]}):dt.warn(`showToolUI called without onUpdate callback — UI may not render`),a.finally(()=>{t&&t({content:[{type:`tool_ui_done`,requestId:n}]})})}const mt=[];function ht(e){return mt.push(e),e}function gt(e){let t=mt.lastIndexOf(e);t!==-1&&mt.splice(t,1)}function _t(){return mt.length>0?mt[mt.length-1]:null}async function vt(e){let t=_t();return t?pt(e,t.onUpdate):(dt.warn(`showToolUIFromContext called without execution context`),null)}i(`panel-transport`);function yt(e){return typeof e==`object`&&!!e&&`source`in e&&`payload`in e}function bt(){return{onMessage:e=>{let t=(t,n,r)=>(yt(t)&&e(t),!1);return chrome.runtime.onMessage.addListener(t),()=>chrome.runtime.onMessage.removeListener(t)},send:e=>{chrome.runtime.sendMessage({source:`offscreen`,payload:e}).catch(()=>{})}}}var xt=class{orchestrator=null;browserAPI=null;messageBuffers=new Map;currentMessageId=new Map;scoopStatuses=new Map;sessionStore=null;followerSync=null;_transport;transportUnsubscribe=null;constructor(e){this._transport=e??null}get transport(){return this._transport||=bt(),this._transport}async bind(e,t){this.orchestrator=e,this.browserAPI=t??null,this.transportUnsubscribe?.(),this.transportUnsubscribe=this.setupMessageListener();let n=new ut;await n.init(),this.sessionStore=n}static createCallbacks(e){return{onResponse:(t,n,r)=>{let i=e.getOrCreateAssistantMsg(t);r?i.content+=n:(i.content=n,i.isStreaming=!1),e.emit({type:`agent-event`,scoopJid:t,eventType:`text_delta`,text:n})},onResponseDone:t=>{let n=e.currentMessageId.get(t);if(n){let r=e.getBuffer(t).find(e=>e.id===n);r&&(r.isStreaming=!1),e.currentMessageId.delete(t)}e.persistScoop(t),e.emit({type:`agent-event`,scoopJid:t,eventType:`response_done`})},onSendMessage:(t,n)=>{let r=e.getBuffer(t),i=`msg-${St()}`;r.push({id:i,role:`assistant`,content:n,timestamp:Date.now()}),e.persistScoop(t),e.emit({type:`agent-event`,scoopJid:t,eventType:`text_delta`,text:n}),e.emit({type:`agent-event`,scoopJid:t,eventType:`response_done`})},onStatusChange:(t,n)=>{e.scoopStatuses.set(t,n),n===`ready`&&e.currentMessageId.delete(t),e.emit({type:`scoop-status`,scoopJid:t,status:n}),e.emitScoopList()},onError:(t,n)=>{e.emit({type:`error`,scoopJid:t,error:n})},onToolStart:(t,n,r)=>{if(st.has(n))return;let i=e.getOrCreateAssistantMsg(t);i.toolCalls||=[],i.toolCalls.push({id:St(),name:n,input:r}),e.emit({type:`agent-event`,scoopJid:t,eventType:`tool_start`,toolName:n,toolInput:r})},onToolEnd:(t,n,r,i)=>{if(st.has(n))return;let a=e.currentMessageId.get(t);if(a){let o=e.getBuffer(t).find(e=>e.id===a);if(o?.toolCalls){let e=[...o.toolCalls].reverse().find(e=>e.name===n&&e.result===void 0);e&&(e.result=r,e.isError=i)}}e.persistScoop(t),e.emit({type:`agent-event`,scoopJid:t,eventType:`tool_end`,toolName:n,toolResult:r,isError:i})},onToolUI:(t,n,r,i)=>{e.emit({type:`agent-event`,scoopJid:t,eventType:`tool_ui`,toolName:n,requestId:r,html:i})},onToolUIDone:(t,n)=>{e.emit({type:`agent-event`,scoopJid:t,eventType:`tool_ui_done`,requestId:n})},onIncomingMessage:(t,n)=>{let r={id:n.id,role:`user`,content:n.channel===`delegation`?`**[Instructions from sliccy]**\n\n${n.content}`:n.content,attachments:n.attachments,timestamp:new Date(n.timestamp).getTime(),source:n.channel===`delegation`?`delegation`:void 0,channel:n.channel};e.getBuffer(t).push(r),e.persistScoop(t),e.emit({type:`incoming-message`,scoopJid:t,message:{id:n.id,content:n.content,attachments:n.attachments,channel:n.channel,senderName:n.senderName,fromAssistant:n.fromAssistant,timestamp:n.timestamp}})}}}toScoopSnapshot(e){let t=e.config&&(e.config.modelId!==void 0||e.config.thinkingLevel!==void 0)?{...e.config.modelId===void 0?{}:{modelId:e.config.modelId},...e.config.thinkingLevel===void 0?{}:{thinkingLevel:e.config.thinkingLevel}}:void 0;return{jid:e.jid,name:e.name,folder:e.folder,isCone:e.isCone,assistantLabel:e.assistantLabel,status:this.scoopStatuses.get(e.jid)??`ready`,...t?{config:t}:{}}}buildStateSnapshot(){let e=this.orchestrator?.getScoops().map(e=>this.toScoopSnapshot(e))??[];return{type:`state-snapshot`,scoops:e,activeScoopJid:e.find(e=>e.isCone)?.jid??null,trayRuntimeStatus:this.buildTrayRuntimeStatus()}}emitTrayRuntimeStatus(){let e=this.buildTrayRuntimeStatus(),t={type:`tray-runtime-status`,leader:e.leader,follower:e.follower};this.emit(t)}buildTrayRuntimeStatus(){let e=it(),t=D();return{leader:{state:e.state,session:e.session,error:e.error??null,reconnectAttempts:e.reconnectAttempts??0},follower:{state:t.state,joinUrl:t.joinUrl,trayId:t.trayId,error:t.error,lastError:t.lastError,reconnectAttempts:t.reconnectAttempts,attachAttempts:t.attachAttempts,lastAttachCode:t.lastAttachCode,connectingSince:t.connectingSince,lastPingTime:t.lastPingTime}}}setFollowerSync(e){this.followerSync=e}applyFollowerSnapshot(e){if(!this.orchestrator)return;let t=this.orchestrator.getScoops().find(e=>e.isCone);if(!t)return;let n=e.map(e=>({id:e.id,role:e.role,content:e.content,attachments:e.attachments,timestamp:e.timestamp,source:e.source,channel:e.channel,toolCalls:e.toolCalls?.map(e=>({id:e.id,name:e.name,input:e.input,result:e.result,isError:e.isError})),isStreaming:e.isStreaming}));if(this.messageBuffers.set(t.jid,n),this.currentMessageId.delete(t.jid),this.sessionStore){let n=t.isCone?`session-cone`:`session-${t.folder}`;this.sessionStore.saveMessages(n,e).catch(e=>{console.warn(`[offscreen-bridge] applyFollowerSnapshot persist failed:`,e)})}this.emit({type:`scoop-messages-replaced`,scoopJid:t.jid,messages:n})}getConeJid(){return this.orchestrator?.getScoops().find(e=>e.isCone)?.jid??null}emitFollowerAgentEvent(e){let t=this.getConeJid();if(t)switch(e.type){case`content_delta`:this.emit({type:`agent-event`,scoopJid:t,eventType:`text_delta`,text:e.text});break;case`content_done`:this.emit({type:`agent-event`,scoopJid:t,eventType:`response_done`});break;case`tool_use_start`:this.emit({type:`agent-event`,scoopJid:t,eventType:`tool_start`,toolName:e.toolName,toolInput:e.toolInput});break;case`tool_result`:this.emit({type:`agent-event`,scoopJid:t,eventType:`tool_end`,toolName:e.toolName,toolResult:e.result,isError:e.isError});break;case`turn_end`:this.emit({type:`agent-event`,scoopJid:t,eventType:`turn_end`});break;case`error`:this.emit({type:`error`,scoopJid:t,error:e.error});break}}emitFollowerIncomingMessage(e,t){let n=this.getConeJid();n&&this.emit({type:`incoming-message`,scoopJid:n,message:{id:e,content:t,channel:`web`,senderName:`User`,fromAssistant:!1,timestamp:new Date().toISOString()}})}emitFollowerStatus(e){let t=this.getConeJid();if(!t)return;let n=e===`processing`?`processing`:`ready`;this.scoopStatuses.set(t,n),this.emit({type:`scoop-status`,scoopJid:t,status:n})}async handleRequestScoopMessages(e){if(!this.orchestrator)return;let t=this.orchestrator.getScoops().find(t=>t.jid===e);if(!t)return;let n=this.messageBuffers.get(e);if(n&&n.length>0){this.emit({type:`scoop-messages-replaced`,scoopJid:e,messages:n});return}let r=this.orchestrator.getScoopContext(e);if(r){let{agentMessagesToChatMessages:n}=await import(`./agent-message-to-chat-Cbt_9_fN.js`),i=r.getAgentMessages();if(i.length>0){let r=n(i,{source:t.isCone?`cone`:t.name??t.folder}).map(e=>({id:e.id,role:e.role,content:e.content,attachments:e.attachments,timestamp:e.timestamp,source:e.source,channel:e.channel,toolCalls:e.toolCalls?.map(e=>({id:e.id,name:e.name,input:e.input,result:e.result,isError:e.isError})),isStreaming:!1}));this.messageBuffers.set(e,r),this.currentMessageId.delete(e),this.persistScoop(e),this.emit({type:`scoop-messages-replaced`,scoopJid:e,messages:r});return}}if(this.sessionStore){let n=t.isCone?`session-cone`:`session-${t.folder}`;try{let t=(await this.sessionStore.load(n))?.messages??[];t.length>0&&(this.messageBuffers.set(e,t),this.currentMessageId.delete(e),this.emit({type:`scoop-messages-replaced`,scoopJid:e,messages:t}))}catch(e){console.warn(`[offscreen-bridge] sessionStore load failed:`,n,e)}}}persistScoop(e){if(!this.sessionStore||!this.orchestrator)return;let t=this.orchestrator.getScoops().find(t=>t.jid===e);if(!t)return;let n=t.isCone?`session-cone`:`session-${t.folder}`,r=this.messageBuffers.get(e);!r||r.length===0||this.sessionStore.saveMessages(n,r).catch(e=>{console.warn(`[offscreen-bridge] persistScoop failed:`,n,e)})}getBuffer(e){let t=this.messageBuffers.get(e);return t||(t=[],this.messageBuffers.set(e,t)),t}getOrCreateAssistantMsg(e){let t=this.getBuffer(e),n=this.currentMessageId.get(e);if(n){let e=t.find(e=>e.id===n);if(e)return e}n=`scoop-${e}-${St()}`,this.currentMessageId.set(e,n);let r=(this.orchestrator?.getScoops()??[]).find(t=>t.jid===e),i=r?.isCone?`cone`:r?.name??`unknown`,a={id:n,role:`assistant`,content:``,timestamp:Date.now(),toolCalls:[],isStreaming:!0,source:i};return t.push(a),a}setupMessageListener(){return this.transport.onMessage(e=>{if(e.source===`panel`){if(e.payload?.type===`sprinkle-op-response`){import(`./sprinkle-proxy-Ci8JPwa_.js`).then(({handleSprinkleOpResponse:t})=>{t(e.payload)});return}this.handlePanelMessage(e.payload).catch(t=>{console.error(`[offscreen-bridge] handlePanelMessage error:`,t);let n=e.payload.scoopJid;n&&this.emit({type:`error`,scoopJid:n,error:t instanceof Error?t.message:String(t)})})}})}async handlePanelMessage(e){if(this.orchestrator)switch(e.type){case`user-message`:{if(this.followerSync){this.getBuffer(e.scoopJid).push({id:e.messageId,role:`user`,content:e.text,attachments:e.attachments,timestamp:Date.now()}),this.persistScoop(e.scoopJid),this.followerSync.sendMessage(e.text,e.messageId,e.attachments);break}let t={id:e.messageId,chatJid:e.scoopJid,senderId:`user`,senderName:`User`,content:e.text,attachments:e.attachments,timestamp:new Date().toISOString(),fromAssistant:!1,channel:`web`};this.getBuffer(e.scoopJid).push({id:e.messageId,role:`user`,content:e.text,attachments:e.attachments,timestamp:Date.now()}),this.persistScoop(e.scoopJid),await this.orchestrator.handleMessage(t),this.orchestrator.createScoopTab(e.scoopJid);break}case`cone-create`:{let t={jid:`cone_${Date.now()}`,name:e.name,folder:`cone`,isCone:!0,type:`cone`,requiresTrigger:!1,assistantLabel:`sliccy`,addedAt:new Date().toISOString()};await this.orchestrator.registerScoop(t),this.emit({type:`scoop-created`,scoop:this.toScoopSnapshot(t)});break}case`scoop-feed`:await this.orchestrator.delegateToScoop(e.scoopJid,e.prompt,`sliccy`);break;case`scoop-drop`:{let t=this.orchestrator.getScoops().find(t=>t.jid===e.scoopJid);if(await this.orchestrator.unregisterScoop(e.scoopJid),this.messageBuffers.delete(e.scoopJid),this.currentMessageId.delete(e.scoopJid),this.scoopStatuses.delete(e.scoopJid),t&&this.sessionStore){let e=t.isCone?`session-cone`:`session-${t.folder}`;this.sessionStore.delete(e).catch(t=>{console.warn(`[offscreen-bridge] Failed to delete session on scoop drop:`,e,t)})}this.emitScoopList();break}case`abort`:this.orchestrator.stopScoop(e.scoopJid),this.orchestrator.clearQueuedMessages(e.scoopJid).catch(e=>{console.warn(`[offscreen-bridge] Failed to clear queued messages on abort:`,e)});break;case`set-model`:this.orchestrator.updateModel();break;case`request-state`:this.emit(this.buildStateSnapshot());break;case`request-scoop-messages`:await this.handleRequestScoopMessages(e.scoopJid);break;case`clear-chat`:if(await this.orchestrator.clearAllMessages(),this.sessionStore){let e=this.orchestrator.getScoops();await Promise.all(e.map(e=>{let t=e.isCone?`session-cone`:`session-${e.folder}`;return this.sessionStore.delete(t)}))}this.messageBuffers.clear(),this.currentMessageId.clear();break;case`clear-filesystem`:try{await this.orchestrator.resetFilesystem()}catch(e){console.error(`[offscreen-bridge] clear-filesystem failed:`,e)}break;case`refresh-model`:this.orchestrator.updateModel();break;case`set-thinking-level`:{let t=e;try{await this.orchestrator.setScoopThinkingLevel(t.scoopJid,t.level)}catch(e){console.error(`[offscreen-bridge] set-thinking-level failed:`,e)}break}case`sprinkle-lick`:{let t=this.orchestrator.getScoops(),n=e,r=n.targetScoop?t.find(e=>e.name===n.targetScoop||e.folder===n.targetScoop||e.folder===`${n.targetScoop}-scoop`):void 0;if(r||=t.find(e=>e.isCone),r){let e=`sprinkle-${n.sprinkleName}-${Date.now()}`,t=`[Sprinkle Event: ${n.sprinkleName}]\n\`\`\`json\n${JSON.stringify(n.body,null,2)}\n\`\`\``,i={id:e,chatJid:r.jid,senderId:`sprinkle`,senderName:`sprinkle:${n.sprinkleName}`,content:t,timestamp:new Date().toISOString(),fromAssistant:!1,channel:`sprinkle`};this.getBuffer(r.jid).push({id:e,role:`user`,content:t,timestamp:Date.now(),source:`lick`,channel:`sprinkle`}),this.persistScoop(r.jid),await this.orchestrator.handleMessage(i)}break}case`reload-skills`:this.orchestrator.reloadAllSkills().catch(e=>{console.warn(`[offscreen-bridge] Skill reload failed:`,e)});break;case`panel-cdp-command`:{let{id:t,method:n,params:r,sessionId:i}=e;if(!this.browserAPI){console.warn(`[offscreen-bridge] Panel CDP command received but BrowserAPI is null`),this.emit({type:`panel-cdp-response`,id:t,error:`BrowserAPI not available`});break}try{let e=await this.browserAPI.getTransport().send(n,r,i);this.emit({type:`panel-cdp-response`,id:t,result:e})}catch(e){this.emit({type:`panel-cdp-response`,id:t,error:e instanceof Error?e.message:String(e)})}break}case`tool-ui-action`:{let{requestId:t,action:n,data:r}=e;try{await ft.handleAction(t,{action:n,data:r})}catch(e){let r=e instanceof Error?e.message:String(e);console.error(`[offscreen-bridge] Tool UI action failed`,{requestId:t,action:n,error:r}),ft.cancel(t,`Action failed: ${r}`)}break}case`local-storage-set`:try{globalThis.localStorage?.setItem(e.key,e.value)}catch(e){console.warn(`[offscreen-bridge] local-storage-set failed:`,e)}break;case`local-storage-remove`:try{globalThis.localStorage?.removeItem(e.key)}catch(e){console.warn(`[offscreen-bridge] local-storage-remove failed:`,e)}break;case`local-storage-clear`:try{globalThis.localStorage?.clear()}catch(e){console.warn(`[offscreen-bridge] local-storage-clear failed:`,e)}break}}emitScoopList(){let e=this.orchestrator?.getScoops().map(e=>this.toScoopSnapshot(e))??[];this.emit({type:`scoop-list`,scoops:e})}emit(e){this.transport.send(e)}};function St(){return Date.now().toString(36)+Math.random().toString(36).slice(2,8)}const Ct=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`];function wt(e){return typeof e==`string`&&Ct.includes(e)}var Tt=r((e=>{(function(){var t={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function n(e){return i(o(e),arguments)}function r(e,t){return n.apply(null,[e].concat(t||[]))}function i(e,r){var i=1,a=e.length,o,s=``,c,l,u,d,f,p,m,h;for(c=0;c<a;c++)if(typeof e[c]==`string`)s+=e[c];else if(typeof e[c]==`object`){if(u=e[c],u.keys)for(o=r[i],l=0;l<u.keys.length;l++){if(o==null)throw Error(n(`[sprintf] Cannot access property "%s" of undefined value "%s"`,u.keys[l],u.keys[l-1]));o=o[u.keys[l]]}else o=u.param_no?r[u.param_no]:r[i++];if(t.not_type.test(u.type)&&t.not_primitive.test(u.type)&&o instanceof Function&&(o=o()),t.numeric_arg.test(u.type)&&typeof o!=`number`&&isNaN(o))throw TypeError(n(`[sprintf] expecting number but found %T`,o));switch(t.number.test(u.type)&&(m=o>=0),u.type){case`b`:o=parseInt(o,10).toString(2);break;case`c`:o=String.fromCharCode(parseInt(o,10));break;case`d`:case`i`:o=parseInt(o,10);break;case`j`:o=JSON.stringify(o,null,u.width?parseInt(u.width):0);break;case`e`:o=u.precision?parseFloat(o).toExponential(u.precision):parseFloat(o).toExponential();break;case`f`:o=u.precision?parseFloat(o).toFixed(u.precision):parseFloat(o);break;case`g`:o=u.precision?String(Number(o.toPrecision(u.precision))):parseFloat(o);break;case`o`:o=(parseInt(o,10)>>>0).toString(8);break;case`s`:o=String(o),o=u.precision?o.substring(0,u.precision):o;break;case`t`:o=String(!!o),o=u.precision?o.substring(0,u.precision):o;break;case`T`:o=Object.prototype.toString.call(o).slice(8,-1).toLowerCase(),o=u.precision?o.substring(0,u.precision):o;break;case`u`:o=parseInt(o,10)>>>0;break;case`v`:o=o.valueOf(),o=u.precision?o.substring(0,u.precision):o;break;case`x`:o=(parseInt(o,10)>>>0).toString(16);break;case`X`:o=(parseInt(o,10)>>>0).toString(16).toUpperCase();break}t.json.test(u.type)?s+=o:(t.number.test(u.type)&&(!m||u.sign)?(h=m?`+`:`-`,o=o.toString().replace(t.sign,``)):h=``,f=u.pad_char?u.pad_char===`0`?`0`:u.pad_char.charAt(1):` `,p=u.width-(h+o).length,d=u.width&&p>0?f.repeat(p):``,s+=u.align?h+o+d:f===`0`?h+d+o:d+h+o)}return s}var a=Object.create(null);function o(e){if(a[e])return a[e];for(var n=e,r,i=[],o=0;n;){if((r=t.text.exec(n))!==null)i.push(r[0]);else if((r=t.modulo.exec(n))!==null)i.push(`%`);else if((r=t.placeholder.exec(n))!==null){if(r[2]){o|=1;var s=[],c=r[2],l=[];if((l=t.key.exec(c))!==null)for(s.push(l[1]);(c=c.substring(l[0].length))!==``;)if((l=t.key_access.exec(c))!==null)s.push(l[1]);else if((l=t.index_access.exec(c))!==null)s.push(l[1]);else throw SyntaxError(`[sprintf] failed to parse named argument key`);else throw SyntaxError(`[sprintf] failed to parse named argument key`);r[2]=s}else o|=2;if(o===3)throw Error(`[sprintf] mixing positional and named placeholders is not (yet) supported`);i.push({placeholder:r[0],param_no:r[1],keys:r[2],sign:r[3],pad_char:r[4],align:r[5],width:r[6],precision:r[7],type:r[8]})}else throw SyntaxError(`[sprintf] unexpected placeholder`);n=n.substring(r[0].length)}return a[e]=i}e!==void 0&&(e.sprintf=n,e.vsprintf=r),typeof window<`u`&&(window.sprintf=n,window.vsprintf=r,typeof define==`function`&&define.amd&&define(function(){return{sprintf:n,vsprintf:r}}))})()}))();const Et=(e,t,n)=>{let r=e instanceof RegExp?Dt(e,n):e,i=t instanceof RegExp?Dt(t,n):t,a=r!==null&&i!=null&&Ot(r,i,n);return a&&{start:a[0],end:a[1],pre:n.slice(0,a[0]),body:n.slice(a[0]+r.length,a[1]),post:n.slice(a[1]+i.length)}},Dt=(e,t)=>{let n=t.match(e);return n?n[0]:null},Ot=(e,t,n)=>{let r,i,a,o,s,c=n.indexOf(e),l=n.indexOf(t,c+1),u=c;if(c>=0&&l>0){if(e===t)return[c,l];for(r=[],a=n.length;u>=0&&!s;){if(u===c)r.push(u),c=n.indexOf(e,u+1);else if(r.length===1){let e=r.pop();e!==void 0&&(s=[e,l])}else i=r.pop(),i!==void 0&&i<a&&(a=i,o=l),l=n.indexOf(t,u+1);u=c<l&&c>=0?c:l}r.length&&o!==void 0&&(s=[a,o])}return s},kt=`\0SLASH`+Math.random()+`\0`,At=`\0OPEN`+Math.random()+`\0`,jt=`\0CLOSE`+Math.random()+`\0`,Mt=`\0COMMA`+Math.random()+`\0`,Nt=`\0PERIOD`+Math.random()+`\0`,Pt=new RegExp(kt,`g`),Ft=new RegExp(At,`g`),It=new RegExp(jt,`g`),Lt=new RegExp(Mt,`g`),Rt=new RegExp(Nt,`g`),zt=/\\\\/g,Bt=/\\{/g,Vt=/\\}/g,Ht=/\\,/g,Ut=/\\\./g;function Wt(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function Gt(e){return e.replace(zt,kt).replace(Bt,At).replace(Vt,jt).replace(Ht,Mt).replace(Ut,Nt)}function Kt(e){return e.replace(Pt,`\\`).replace(Ft,`{`).replace(It,`}`).replace(Lt,`,`).replace(Rt,`.`)}function qt(e){if(!e)return[``];let t=[],n=Et(`{`,`}`,e);if(!n)return e.split(`,`);let{pre:r,body:i,post:a}=n,o=r.split(`,`);o[o.length-1]+=`{`+i+`}`;let s=qt(a);return a.length&&(o[o.length-1]+=s.shift(),o.push.apply(o,s)),t.push.apply(t,o),t}function Jt(e,t={}){if(!e)return[];let{max:n=1e5}=t;return e.slice(0,2)===`{}`&&(e=`\\{\\}`+e.slice(2)),$t(Gt(e),n,!0).map(Kt)}function Yt(e){return`{`+e+`}`}function Xt(e){return/^-?0\d/.test(e)}function Zt(e,t){return e<=t}function Qt(e,t){return e>=t}function $t(e,t,n){let r=[],i=Et(`{`,`}`,e);if(!i)return[e];let a=i.pre,o=i.post.length?$t(i.post,t,!1):[``];if(/\$$/.test(i.pre))for(let e=0;e<o.length&&e<t;e++){let t=a+`{`+i.body+`}`+o[e];r.push(t)}else{let s=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body),c=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body),l=s||c,u=i.body.indexOf(`,`)>=0;if(!l&&!u)return i.post.match(/,(?!,).*\}/)?(e=i.pre+`{`+i.body+jt+i.post,$t(e,t,!0)):[e];let d;if(l)d=i.body.split(/\.\./);else if(d=qt(i.body),d.length===1&&d[0]!==void 0&&(d=$t(d[0],t,!1).map(Yt),d.length===1))return o.map(e=>i.pre+d[0]+e);let f;if(l&&d[0]!==void 0&&d[1]!==void 0){let e=Wt(d[0]),t=Wt(d[1]),n=Math.max(d[0].length,d[1].length),r=d.length===3&&d[2]!==void 0?Math.abs(Wt(d[2])):1,i=Zt;t<e&&(r*=-1,i=Qt);let a=d.some(Xt);f=[];for(let o=e;i(o,t);o+=r){let e;if(c)e=String.fromCharCode(o),e===`\\`&&(e=``);else if(e=String(o),a){let t=n-e.length;if(t>0){let n=Array(t+1).join(`0`);e=o<0?`-`+n+e.slice(1):n+e}}f.push(e)}}else{f=[];for(let e=0;e<d.length;e++)f.push.apply(f,$t(d[e],t,!1))}for(let e=0;e<f.length;e++)for(let i=0;i<o.length&&r.length<t;i++){let t=a+f[e]+o[i];(!n||l||t)&&r.push(t)}}return r}const en=e=>{if(typeof e!=`string`)throw TypeError(`invalid pattern`);if(e.length>65536)throw TypeError(`pattern is too long`)},tn={"[:alnum:]":[`\\p{L}\\p{Nl}\\p{Nd}`,!0],"[:alpha:]":[`\\p{L}\\p{Nl}`,!0],"[:ascii:]":[`\\x00-\\x7f`,!1],"[:blank:]":[`\\p{Zs}\\t`,!0],"[:cntrl:]":[`\\p{Cc}`,!0],"[:digit:]":[`\\p{Nd}`,!0],"[:graph:]":[`\\p{Z}\\p{C}`,!0,!0],"[:lower:]":[`\\p{Ll}`,!0],"[:print:]":[`\\p{C}`,!0],"[:punct:]":[`\\p{P}`,!0],"[:space:]":[`\\p{Z}\\t\\r\\n\\v\\f`,!0],"[:upper:]":[`\\p{Lu}`,!0],"[:word:]":[`\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}`,!0],"[:xdigit:]":[`A-Fa-f0-9`,!1]},nn=e=>e.replace(/[[\]\\-]/g,`\\$&`),rn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),an=e=>e.join(``),on=(e,t)=>{let n=t;if(e.charAt(n)!==`[`)throw Error(`not in a brace expression`);let r=[],i=[],a=n+1,o=!1,s=!1,c=!1,l=!1,u=n,d=``;WHILE:for(;a<e.length;){let t=e.charAt(a);if((t===`!`||t===`^`)&&a===n+1){l=!0,a++;continue}if(t===`]`&&o&&!c){u=a+1;break}if(o=!0,t===`\\`&&!c){c=!0,a++;continue}if(t===`[`&&!c){for(let[t,[o,c,l]]of Object.entries(tn))if(e.startsWith(t,a)){if(d)return[`$.`,!1,e.length-n,!0];a+=t.length,l?i.push(o):r.push(o),s||=c;continue WHILE}}if(c=!1,d){t>d?r.push(nn(d)+`-`+nn(t)):t===d&&r.push(nn(t)),d=``,a++;continue}if(e.startsWith(`-]`,a+1)){r.push(nn(t+`-`)),a+=2;continue}if(e.startsWith(`-`,a+1)){d=t,a+=2;continue}r.push(nn(t)),a++}if(u<a)return[``,!1,0,!1];if(!r.length&&!i.length)return[`$.`,!1,e.length-n,!0];if(i.length===0&&r.length===1&&/^\\?.$/.test(r[0])&&!l)return[rn(r[0].length===2?r[0].slice(-1):r[0]),!1,u-n,!1];let f=`[`+(l?`^`:``)+an(r)+`]`,p=`[`+(l?``:`^`)+an(i)+`]`;return[r.length&&i.length?`(`+f+`|`+p+`)`:r.length?f:p,s,u-n,!0]},sn=(e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!0}={})=>n?t?e.replace(/\[([^\/\\])\]/g,`$1`):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,`$1$2`).replace(/\\([^\/])/g,`$1`):t?e.replace(/\[([^\/\\{}])\]/g,`$1`):e.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,`$1$2`).replace(/\\([^\/{}])/g,`$1`);var cn;const ln=new Set([`!`,`?`,`+`,`*`,`@`]),un=e=>ln.has(e),dn=e=>un(e.type),fn=new Map([[`!`,[`@`]],[`?`,[`?`,`@`]],[`@`,[`@`]],[`*`,[`*`,`+`,`?`,`@`]],[`+`,[`+`,`@`]]]),pn=new Map([[`!`,[`?`]],[`@`,[`?`]],[`+`,[`?`,`*`]]]),mn=new Map([[`!`,[`?`,`@`]],[`?`,[`?`,`@`]],[`@`,[`?`,`@`]],[`*`,[`*`,`+`,`?`,`@`]],[`+`,[`+`,`@`,`?`,`*`]]]),hn=new Map([[`!`,new Map([[`!`,`@`]])],[`?`,new Map([[`*`,`*`],[`+`,`*`]])],[`@`,new Map([[`!`,`!`],[`?`,`?`],[`@`,`@`],[`*`,`*`],[`+`,`+`]])],[`+`,new Map([[`?`,`*`],[`*`,`*`]])]]),gn=`(?!\\.)`,_n=new Set([`[`,`.`]),vn=new Set([`..`,`.`]),yn=new Set(`().*{}+?[]^$\\!`),bn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),xn=`[^/]`,Sn=xn+`*?`,Cn=xn+`+?`;let wn=0;var Tn=class{type;#e;#t;#n=!1;#r=[];#i;#a;#o;#s=!1;#c;#l;#u=!1;id=++wn;get depth(){return(this.#i?.depth??-1)+1}[Symbol.for(`nodejs.util.inspect.custom`)](){return{"@@type":`AST`,id:this.id,type:this.type,root:this.#e.id,parent:this.#i?.id,depth:this.depth,partsLength:this.#r.length,parts:this.#r}}constructor(e,t,n={}){this.type=e,e&&(this.#t=!0),this.#i=t,this.#e=this.#i?this.#i.#e:this,this.#c=this.#e===this?n:this.#e.#c,this.#o=this.#e===this?[]:this.#e.#o,e===`!`&&!this.#e.#s&&this.#o.push(this),this.#a=this.#i?this.#i.#r.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let e of this.#r)if(typeof e!=`string`&&(e.type||e.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#l===void 0?this.type?this.#l=this.type+`(`+this.#r.map(e=>String(e)).join(`|`)+`)`:this.#l=this.#r.map(e=>String(e)).join(``):this.#l}#d(){if(this!==this.#e)throw Error(`should only call on root`);if(this.#s)return this;this.toString(),this.#s=!0;let e;for(;e=this.#o.pop();){if(e.type!==`!`)continue;let t=e,n=t.#i;for(;n;){for(let r=t.#a+1;!n.type&&r<n.#r.length;r++)for(let t of e.#r){if(typeof t==`string`)throw Error(`string part in extglob AST??`);t.copyIn(n.#r[r])}t=n,n=t.#i}}return this}push(...e){for(let t of e)if(t!==``){if(typeof t!=`string`&&!(t instanceof cn&&t.#i===this))throw Error(`invalid part: `+t);this.#r.push(t)}}toJSON(){let e=this.type===null?this.#r.slice().map(e=>typeof e==`string`?e:e.toJSON()):[this.type,...this.#r.map(e=>e.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#s&&this.#i?.type===`!`)&&e.push({}),e}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#a===0)return!0;let e=this.#i;for(let t=0;t<this.#a;t++){let n=e.#r[t];if(!(n instanceof cn&&n.type===`!`))return!1}return!0}isEnd(){if(this.#e===this||this.#i?.type===`!`)return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let e=this.#i?this.#i.#r.length:0;return this.#a===e-1}copyIn(e){typeof e==`string`?this.push(e):this.push(e.clone(this))}clone(e){let t=new cn(this.type,e);for(let e of this.#r)t.copyIn(e);return t}static#f(e,t,n,r,i){let a=r.maxExtglobRecursion??2,o=!1,s=!1,c=-1,l=!1;if(t.type===null){let u=n,d=``;for(;u<e.length;){let n=e.charAt(u++);if(o||n===`\\`){o=!o,d+=n;continue}if(s){u===c+1?(n===`^`||n===`!`)&&(l=!0):n===`]`&&!(u===c+2&&l)&&(s=!1),d+=n;continue}else if(n===`[`){s=!0,c=u,l=!1,d+=n;continue}if(!r.noext&&un(n)&&e.charAt(u)===`(`&&i<=a){t.push(d),d=``;let a=new cn(n,t);u=cn.#f(e,a,u,r,i+1),t.push(a);continue}d+=n}return t.push(d),u}let u=n+1,d=new cn(null,t),f=[],p=``;for(;u<e.length;){let n=e.charAt(u++);if(o||n===`\\`){o=!o,p+=n;continue}if(s){u===c+1?(n===`^`||n===`!`)&&(l=!0):n===`]`&&!(u===c+2&&l)&&(s=!1),p+=n;continue}else if(n===`[`){s=!0,c=u,l=!1,p+=n;continue}if(!r.noext&&un(n)&&e.charAt(u)===`(`&&(i<=a||t&&t.#h(n))){let a=t&&t.#h(n)?0:1;d.push(p),p=``;let o=new cn(n,d);d.push(o),u=cn.#f(e,o,u,r,i+a);continue}if(n===`|`){d.push(p),p=``,f.push(d),d=new cn(null,t);continue}if(n===`)`)return p===``&&t.#r.length===0&&(t.#u=!0),d.push(p),p=``,t.push(...f,d),u;p+=n}return t.type=null,t.#t=void 0,t.#r=[e.substring(n-1)],u}#p(e){return this.#m(e,pn)}#m(e,t=fn){if(!e||typeof e!=`object`||e.type!==null||e.#r.length!==1||this.type===null)return!1;let n=e.#r[0];return!n||typeof n!=`object`||n.type===null?!1:this.#h(n.type,t)}#h(e,t=mn){return!!t.get(this.type)?.includes(e)}#g(e,t){let n=e.#r[0],r=new cn(null,n,this.options);r.#r.push(``),n.push(r),this.#_(e,t)}#_(e,t){let n=e.#r[0];this.#r.splice(t,1,...n.#r);for(let e of n.#r)typeof e==`object`&&(e.#i=this);this.#l=void 0}#v(e){return!!hn.get(this.type)?.has(e)}#y(e){if(!e||typeof e!=`object`||e.type!==null||e.#r.length!==1||this.type===null||this.#r.length!==1)return!1;let t=e.#r[0];return!t||typeof t!=`object`||t.type===null?!1:this.#v(t.type)}#b(e){let t=hn.get(this.type),n=e.#r[0],r=t?.get(n.type);if(!r)return!1;this.#r=n.#r;for(let e of this.#r)typeof e==`object`&&(e.#i=this);this.type=r,this.#l=void 0,this.#u=!1}static fromGlob(e,t={}){let n=new cn(null,void 0,t);return cn.#f(e,n,0,t,0),n}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let e=this.toString(),[t,n,r,i]=this.toRegExpSource();if(!(r||this.#t||this.#c.nocase&&!this.#c.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return n;let a=(this.#c.nocase?`i`:``)+(i?`u`:``);return Object.assign(RegExp(`^${t}$`,a),{_src:t,_glob:e})}get options(){return this.#c}toRegExpSource(e){let t=e??!!this.#c.dot;if(this.#e===this&&(this.#x(),this.#d()),!dn(this)){let n=this.isStart()&&this.isEnd()&&!this.#r.some(e=>typeof e!=`string`),r=this.#r.map(t=>{let[r,i,a,o]=typeof t==`string`?cn.#C(t,this.#t,n):t.toRegExpSource(e);return this.#t=this.#t||a,this.#n=this.#n||o,r}).join(``),i=``;if(this.isStart()&&typeof this.#r[0]==`string`&&!(this.#r.length===1&&vn.has(this.#r[0]))){let n=_n,a=t&&n.has(r.charAt(0))||r.startsWith(`\\.`)&&n.has(r.charAt(2))||r.startsWith(`\\.\\.`)&&n.has(r.charAt(4)),o=!t&&!e&&n.has(r.charAt(0));i=a?`(?!(?:^|/)\\.\\.?(?:$|/))`:o?gn:``}let a=``;return this.isEnd()&&this.#e.#s&&this.#i?.type===`!`&&(a=`(?:$|\\/)`),[i+r+a,sn(r),this.#t=!!this.#t,this.#n]}let n=this.type===`*`||this.type===`+`,r=this.type===`!`?`(?:(?!(?:`:`(?:`,i=this.#S(t);if(this.isStart()&&this.isEnd()&&!i&&this.type!==`!`){let e=this.toString(),t=this;return t.#r=[e],t.type=null,t.#t=void 0,[e,sn(this.toString()),!1,!1]}let a=!n||e||t?``:this.#S(!0);a===i&&(a=``),a&&(i=`(?:${i})(?:${a})*?`);let o=``;if(this.type===`!`&&this.#u)o=(this.isStart()&&!t?gn:``)+Cn;else{let n=this.type===`!`?`))`+(this.isStart()&&!t&&!e?gn:``)+Sn+`)`:this.type===`@`?`)`:this.type===`?`?`)?`:this.type===`+`&&a?`)`:this.type===`*`&&a?`)?`:`)${this.type}`;o=r+i+n}return[o,sn(i),this.#t=!!this.#t,this.#n]}#x(){if(dn(this)){let e=0,t=!1;do{t=!0;for(let e=0;e<this.#r.length;e++){let n=this.#r[e];typeof n==`object`&&(n.#x(),this.#m(n)?(t=!1,this.#_(n,e)):this.#p(n)?(t=!1,this.#g(n,e)):this.#y(n)&&(t=!1,this.#b(n)))}}while(!t&&++e<10)}else for(let e of this.#r)typeof e==`object`&&e.#x();this.#l=void 0}#S(e){return this.#r.map(t=>{if(typeof t==`string`)throw Error(`string type in extglob ast??`);let[n,r,i,a]=t.toRegExpSource(e);return this.#n=this.#n||a,n}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join(`|`)}static#C(e,t,n=!1){let r=!1,i=``,a=!1,o=!1;for(let s=0;s<e.length;s++){let c=e.charAt(s);if(r){r=!1,i+=(yn.has(c)?`\\`:``)+c;continue}if(c===`*`){if(o)continue;o=!0,i+=n&&/^[*]+$/.test(e)?Cn:Sn,t=!0;continue}else o=!1;if(c===`\\`){s===e.length-1?i+=`\\\\`:r=!0;continue}if(c===`[`){let[n,r,o,c]=on(e,s);if(o){i+=n,a||=r,s+=o-1,t||=c;continue}}if(c===`?`){i+=xn,t=!0;continue}i+=bn(c)}return[i,sn(e),!!t,a]}};cn=Tn;const En=(e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!1}={})=>n?t?e.replace(/[?*()[\]{}]/g,`[$&]`):e.replace(/[?*()[\]\\{}]/g,`\\$&`):t?e.replace(/[?*()[\]]/g,`[$&]`):e.replace(/[?*()[\]\\]/g,`\\$&`),Dn=(e,t,n={})=>(en(t),!n.nocomment&&t.charAt(0)===`#`?!1:new tr(t,n).match(e)),On=/^\*+([^+@!?\*\[\(]*)$/,kn=e=>t=>!t.startsWith(`.`)&&t.endsWith(e),An=e=>t=>t.endsWith(e),jn=e=>(e=e.toLowerCase(),t=>!t.startsWith(`.`)&&t.toLowerCase().endsWith(e)),Mn=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Nn=/^\*+\.\*+$/,Pn=e=>!e.startsWith(`.`)&&e.includes(`.`),Fn=e=>e!==`.`&&e!==`..`&&e.includes(`.`),In=/^\.\*+$/,Ln=e=>e!==`.`&&e!==`..`&&e.startsWith(`.`),Rn=/^\*+$/,zn=e=>e.length!==0&&!e.startsWith(`.`),Bn=e=>e.length!==0&&e!==`.`&&e!==`..`,Vn=/^\?+([^+@!?\*\[\(]*)?$/,Hn=([e,t=``])=>{let n=Kn([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},Un=([e,t=``])=>{let n=qn([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},Wn=([e,t=``])=>{let n=qn([e]);return t?e=>n(e)&&e.endsWith(t):n},Gn=([e,t=``])=>{let n=Kn([e]);return t?e=>n(e)&&e.endsWith(t):n},Kn=([e])=>{let t=e.length;return e=>e.length===t&&!e.startsWith(`.`)},qn=([e])=>{let t=e.length;return e=>e.length===t&&e!==`.`&&e!==`..`},Jn=typeof process==`object`&&process?{}.__MINIMATCH_TESTING_PLATFORM__||process.platform:`posix`,Yn={win32:{sep:`\\`},posix:{sep:`/`}};Dn.sep=Jn===`win32`?Yn.win32.sep:Yn.posix.sep;const Xn=Symbol(`globstar **`);Dn.GLOBSTAR=Xn,Dn.filter=(e,t={})=>n=>Dn(n,e,t);const Zn=(e,t={})=>Object.assign({},e,t);Dn.defaults=e=>{if(!e||typeof e!=`object`||!Object.keys(e).length)return Dn;let t=Dn;return Object.assign((n,r,i={})=>t(n,r,Zn(e,i)),{Minimatch:class extends t.Minimatch{constructor(t,n={}){super(t,Zn(e,n))}static defaults(n){return t.defaults(Zn(e,n)).Minimatch}},AST:class extends t.AST{constructor(t,n,r={}){super(t,n,Zn(e,r))}static fromGlob(n,r={}){return t.AST.fromGlob(n,Zn(e,r))}},unescape:(n,r={})=>t.unescape(n,Zn(e,r)),escape:(n,r={})=>t.escape(n,Zn(e,r)),filter:(n,r={})=>t.filter(n,Zn(e,r)),defaults:n=>t.defaults(Zn(e,n)),makeRe:(n,r={})=>t.makeRe(n,Zn(e,r)),braceExpand:(n,r={})=>t.braceExpand(n,Zn(e,r)),match:(n,r,i={})=>t.match(n,r,Zn(e,i)),sep:t.sep,GLOBSTAR:Xn})};const Qn=(e,t={})=>(en(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Jt(e,{max:t.braceExpandMax}));Dn.braceExpand=Qn,Dn.makeRe=(e,t={})=>new tr(e,t).makeRe(),Dn.match=(e,t,n={})=>{let r=new tr(t,n);return e=e.filter(e=>r.match(e)),r.options.nonull&&!e.length&&e.push(t),e};const $n=/[?*]|[+@!]\(.*?\)|\[|\]/,er=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`);var tr=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,t={}){en(e),t||={},this.options=t,this.maxGlobstarRecursion=t.maxGlobstarRecursion??200,this.pattern=e,this.platform=t.platform||Jn,this.isWindows=this.platform===`win32`,this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,`/`)),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!t.nonegate,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot===void 0?!!(this.isWindows&&this.nocase):t.windowsNoMagicRoot,this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let e of this.set)for(let t of e)if(typeof t!=`string`)return!0;return!1}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)===`#`){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...e)=>console.error(...e)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(e=>this.slashSplit(e));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let r=this.globParts.map((e,t,n)=>{if(this.isWindows&&this.windowsNoMagicRoot){let t=e[0]===``&&e[1]===``&&(e[2]===`?`||!$n.test(e[2]))&&!$n.test(e[3]),n=/^[a-z]:/i.test(e[0]);if(t)return[...e.slice(0,4),...e.slice(4).map(e=>this.parse(e))];if(n)return[e[0],...e.slice(1).map(e=>this.parse(e))]}return e.map(e=>this.parse(e))});if(this.debug(this.pattern,r),this.set=r.filter(e=>e.indexOf(!1)===-1),this.isWindows)for(let e=0;e<this.set.length;e++){let t=this.set[e];t[0]===``&&t[1]===``&&this.globParts[e][2]===`?`&&typeof t[3]==`string`&&/^[a-z]:$/i.test(t[3])&&(t[2]=`?`)}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let t=0;t<e.length;t++)for(let n=0;n<e[t].length;n++)e[t][n]===`**`&&(e[t][n]=`*`);let{optimizationLevel:t=1}=this.options;return t>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):e=t>=1?this.levelOneOptimize(e):this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(e=>{let t=-1;for(;(t=e.indexOf(`**`,t+1))!==-1;){let n=t;for(;e[n+1]===`**`;)n++;n!==t&&e.splice(t,n-t)}return e})}levelOneOptimize(e){return e.map(e=>(e=e.reduce((e,t)=>{let n=e[e.length-1];return t===`**`&&n===`**`?e:t===`..`&&n&&n!==`..`&&n!==`.`&&n!==`**`?(e.pop(),e):(e.push(t),e)},[]),e.length===0?[``]:e))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let t=!1;do{if(t=!1,!this.preserveMultipleSlashes){for(let n=1;n<e.length-1;n++){let r=e[n];n===1&&r===``&&e[0]===``||(r===`.`||r===``)&&(t=!0,e.splice(n,1),n--)}e[0]===`.`&&e.length===2&&(e[1]===`.`||e[1]===``)&&(t=!0,e.pop())}let n=0;for(;(n=e.indexOf(`..`,n+1))!==-1;){let r=e[n-1];r&&r!==`.`&&r!==`..`&&r!==`**`&&(t=!0,e.splice(n-1,2),n-=2)}}while(t);return e.length===0?[``]:e}firstPhasePreProcess(e){let t=!1;do{t=!1;for(let n of e){let r=-1;for(;(r=n.indexOf(`**`,r+1))!==-1;){let i=r;for(;n[i+1]===`**`;)i++;i>r&&n.splice(r+1,i-r);let a=n[r+1],o=n[r+2],s=n[r+3];if(a!==`..`||!o||o===`.`||o===`..`||!s||s===`.`||s===`..`)continue;t=!0,n.splice(r,1);let c=n.slice(0);c[r]=`**`,e.push(c),r--}if(!this.preserveMultipleSlashes){for(let e=1;e<n.length-1;e++){let r=n[e];e===1&&r===``&&n[0]===``||(r===`.`||r===``)&&(t=!0,n.splice(e,1),e--)}n[0]===`.`&&n.length===2&&(n[1]===`.`||n[1]===``)&&(t=!0,n.pop())}let i=0;for(;(i=n.indexOf(`..`,i+1))!==-1;){let e=n[i-1];if(e&&e!==`.`&&e!==`..`&&e!==`**`){t=!0;let e=i===1&&n[i+1]===`**`?[`.`]:[];n.splice(i-1,2,...e),n.length===0&&n.push(``),i-=2}}}}while(t);return e}secondPhasePreProcess(e){for(let t=0;t<e.length-1;t++)for(let n=t+1;n<e.length;n++){let r=this.partsMatch(e[t],e[n],!this.preserveMultipleSlashes);if(r){e[t]=[],e[n]=r;break}}return e.filter(e=>e.length)}partsMatch(e,t,n=!1){let r=0,i=0,a=[],o=``;for(;r<e.length&&i<t.length;)if(e[r]===t[i])a.push(o===`b`?t[i]:e[r]),r++,i++;else if(n&&e[r]===`**`&&t[i]===e[r+1])a.push(e[r]),r++;else if(n&&t[i]===`**`&&e[r]===t[i+1])a.push(t[i]),i++;else if(e[r]===`*`&&t[i]&&(this.options.dot||!t[i].startsWith(`.`))&&t[i]!==`**`){if(o===`b`)return!1;o=`a`,a.push(e[r]),r++,i++}else if(t[i]===`*`&&e[r]&&(this.options.dot||!e[r].startsWith(`.`))&&e[r]!==`**`){if(o===`a`)return!1;o=`b`,a.push(t[i]),r++,i++}else return!1;return e.length===t.length&&a}parseNegate(){if(this.nonegate)return;let e=this.pattern,t=!1,n=0;for(let r=0;r<e.length&&e.charAt(r)===`!`;r++)t=!t,n++;n&&(this.pattern=e.slice(n)),this.negate=t}matchOne(e,t,n=!1){let r=0,i=0;if(this.isWindows){let n=typeof e[0]==`string`&&/^[a-z]:$/i.test(e[0]),a=!n&&e[0]===``&&e[1]===``&&e[2]===`?`&&/^[a-z]:$/i.test(e[3]),o=typeof t[0]==`string`&&/^[a-z]:$/i.test(t[0]),s=!o&&t[0]===``&&t[1]===``&&t[2]===`?`&&typeof t[3]==`string`&&/^[a-z]:$/i.test(t[3]),c=a?3:n?0:void 0,l=s?3:o?0:void 0;if(typeof c==`number`&&typeof l==`number`){let[n,a]=[e[c],t[l]];n.toLowerCase()===a.toLowerCase()&&(t[l]=n,i=l,r=c)}}let{optimizationLevel:a=1}=this.options;return a>=2&&(e=this.levelTwoFileOptimize(e)),t.includes(Xn)?this.#e(e,t,n,r,i):this.#n(e,t,n,r,i)}#e(e,t,n,r,i){let a=t.indexOf(Xn,i),o=t.lastIndexOf(Xn),[s,c,l]=n?[t.slice(i,a),t.slice(a+1),[]]:[t.slice(i,a),t.slice(a+1,o),t.slice(o+1)];if(s.length){let t=e.slice(r,r+s.length);if(!this.#n(t,s,n,0,0))return!1;r+=s.length,i+=s.length}let u=0;if(l.length){if(l.length+r>e.length)return!1;let t=e.length-l.length;if(this.#n(e,l,n,t,0))u=l.length;else{if(e[e.length-1]!==``||r+l.length===e.length||(t--,!this.#n(e,l,n,t,0)))return!1;u=l.length+1}}if(!c.length){let t=!!u;for(let n=r;n<e.length-u;n++){let r=String(e[n]);if(t=!0,r===`.`||r===`..`||!this.options.dot&&r.startsWith(`.`))return!1}return n||t}let d=[[[],0]],f=d[0],p=0,m=[0];for(let e of c)e===Xn?(m.push(p),f=[[],0],d.push(f)):(f[0].push(e),p++);let h=d.length-1,g=e.length-u;for(let e of d)e[1]=g-(m[h--]+e[0].length);return!!this.#t(e,d,r,0,n,0,!!u)}#t(e,t,n,r,i,a,o){let s=t[r];if(!s){for(let t=n;t<e.length;t++){o=!0;let n=e[t];if(n===`.`||n===`..`||!this.options.dot&&n.startsWith(`.`))return!1}return o}let[c,l]=s;for(;n<=l;){if(this.#n(e.slice(0,n+c.length),c,i,n,0)&&a<this.maxGlobstarRecursion){let s=this.#t(e,t,n+c.length,r+1,i,a+1,o);if(s!==!1)return s}let s=e[n];if(s===`.`||s===`..`||!this.options.dot&&s.startsWith(`.`))return!1;n++}return i||null}#n(e,t,n,r,i){let a,o,s,c;for(a=r,o=i,c=e.length,s=t.length;a<c&&o<s;a++,o++){this.debug(`matchOne loop`);let n=t[o],r=e[a];if(this.debug(t,n,r),n===!1||n===Xn)return!1;let i;if(typeof n==`string`?(i=r===n,this.debug(`string match`,n,r,i)):(i=n.test(r),this.debug(`pattern match`,n,r,i)),!i)return!1}if(a===c&&o===s)return!0;if(a===c)return n;if(o===s)return a===c-1&&e[a]===``;throw Error(`wtf?`)}braceExpand(){return Qn(this.pattern,this.options)}parse(e){en(e);let t=this.options;if(e===`**`)return Xn;if(e===``)return``;let n,r=null;(n=e.match(Rn))?r=t.dot?Bn:zn:(n=e.match(On))?r=(t.nocase?t.dot?Mn:jn:t.dot?An:kn)(n[1]):(n=e.match(Vn))?r=(t.nocase?t.dot?Un:Hn:t.dot?Wn:Gn)(n):(n=e.match(Nn))?r=t.dot?Fn:Pn:(n=e.match(In))&&(r=Ln);let i=Tn.fromGlob(e,this.options).toMMPattern();return r&&typeof i==`object`&&Reflect.defineProperty(i,`test`,{value:r}),i}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let t=this.options,n=t.noglobstar?`[^/]*?`:t.dot?`(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?`:`(?:(?!(?:\\/|^)\\.).)*?`,r=new Set(t.nocase?[`i`]:[]),i=e.map(e=>{let t=e.map(e=>{if(e instanceof RegExp)for(let t of e.flags.split(``))r.add(t);return typeof e==`string`?er(e):e===Xn?Xn:e._src});t.forEach((e,r)=>{let i=t[r+1],a=t[r-1];e!==Xn||a===Xn||(a===void 0?i!==void 0&&i!==Xn?t[r+1]=`(?:\\/|`+n+`\\/)?`+i:t[r]=n:i===void 0?t[r-1]=a+`(?:\\/|\\/`+n+`)?`:i!==Xn&&(t[r-1]=a+`(?:\\/|\\/`+n+`\\/)`+i,t[r+1]=Xn))});let i=t.filter(e=>e!==Xn);if(this.partial&&i.length>=1){let e=[];for(let t=1;t<=i.length;t++)e.push(i.slice(0,t).join(`/`));return`(?:`+e.join(`|`)+`)`}return i.join(`/`)}).join(`|`),[a,o]=e.length>1?[`(?:`,`)`]:[``,``];i=`^`+a+i+o+`$`,this.partial&&(i=`^(?:\\/|`+a+i.slice(1,-1)+o+`)$`),this.negate&&(i=`^(?!`+i+`).+$`);try{this.regexp=new RegExp(i,[...r].join(``))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split(`/`):this.isWindows&&/^\/\/[^\/]+/.test(e)?[``,...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.debug(`match`,e,this.pattern),this.comment)return!1;if(this.empty)return e===``;if(e===`/`&&t)return!0;let n=this.options;this.isWindows&&(e=e.split(`\\`).join(`/`));let r=this.slashSplit(e);this.debug(this.pattern,`split`,r);let i=this.set;this.debug(this.pattern,`set`,i);let a=r[r.length-1];if(!a)for(let e=r.length-2;!a&&e>=0;e--)a=r[e];for(let e=0;e<i.length;e++){let o=i[e],s=r;if(n.matchBase&&o.length===1&&(s=[a]),this.matchOne(s,o,t))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(e){return Dn.defaults(e).Minimatch}};Dn.AST=Tn,Dn.Minimatch=tr,Dn.escape=En,Dn.unescape=sn;const nr={};function rr(){throw Error(`gunzipSync is not available in the browser`)}function ir(){throw Error(`gzipSync is not available in the browser`)}var ar=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r){setTimeout(function(){r(e)},0);return}else return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h){d[r]=void 0;continue}if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}};new class extends ar{};function or(e,t){let n;for(n=0;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function sr(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function cr(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function lr(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function ur(e,t){return cr(e,t,``)}function dr(e,t){return lr(e,t,``)}function fr(e,t){return t.slice(0,pr(e,t))}function pr(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function mr(e){let t;for(t=e.length-1;t>=0&&e[t].match(/\s/);t--);return e.substring(t+1)}function hr(e){let t=e.match(/^\s*/);return t?t[0]:``}const gr=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,_r=RegExp(`[${gr}]+|\\s+|[^${gr}]`,`ug`);new class extends ar{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=[];for(let t of Array.from(r.segment(e))){let e=t.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}}else n=e.match(_r)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&vr(n,i,r,e),n=e,r=null,i=null)}),(r||i)&&vr(n,i,r,null),e}};function vr(e,t,n,r){if(t&&n){let i=hr(t.value),a=mr(t.value),o=hr(n.value),s=mr(n.value);if(e){let r=or(i,o);e.value=lr(e.value,o,r),t.value=ur(t.value,r),n.value=ur(n.value,r)}if(r){let e=sr(a,s);r.value=cr(r.value,s,e),t.value=dr(t.value,e),n.value=dr(n.value,e)}}else if(n){if(e){let e=hr(n.value);n.value=n.value.substring(e.length)}if(r){let e=hr(r.value);r.value=r.value.substring(e.length)}}else if(e&&r){let n=hr(r.value),i=hr(t.value),a=mr(t.value),o=or(n,i);t.value=ur(t.value,o);let s=sr(ur(n,o),a);t.value=dr(t.value,s),r.value=cr(r.value,n,s),e.value=lr(e.value,n,n.slice(0,n.length-s.length))}else if(r){let e=hr(r.value),n=fr(mr(t.value),e);t.value=dr(t.value,n)}else if(e){let n=fr(mr(e.value),hr(t.value));t.value=ur(t.value,n)}}new class extends ar{tokenize(e){let t=RegExp(`(\\r?\\n)|[${gr}]+|[^\\S\\n\\r]+|[^${gr}]`,`ug`);return e.match(t)||[]}};const yr=new class extends ar{constructor(){super(...arguments),this.tokenize=xr}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
|
|
879
|
+
}`,returnByValue:!0},this.sessionId)).result?.value;if(!n||n.width===0||n.height===0)throw Error(`Element with backend node ${e} has no dimensions`);return{x:n.x+n.width/2,y:n.y+n.height/2}}async ensureLocalConnected(){this.localClient.state===`disconnected`&&await this.localClient.connect({url:Ze()})}async ensureConnected(){this.client.state===`disconnected`&&(this.remoteTargetInfo&&this.trayTargetProvider?.removeRemoteTransport&&(this.trayTargetProvider.removeRemoteTransport(this.remoteTargetInfo.runtimeId,this.remoteTargetInfo.localTargetId),this.setClient(this.localClient),this.remoteTargetInfo=null),this.sessionId=null,this.attachedTargetId=null,this.client.state===`disconnected`&&await this.connect())}ensureAttached(){if(!this.sessionId)throw Error(`Not attached to a page. Call attachToPage(targetId) first.`)}addDialogListener(e){e.on(`Page.javascriptDialogOpening`,this.handleJavaScriptDialogOpening)}removeDialogListener(e){e.off(`Page.javascriptDialogOpening`,this.handleJavaScriptDialogOpening)}setClient(e){this.client!==e&&(this.removeDialogListener(this.client),this.client=e,this.addDialogListener(this.client))}async boundingBox(e){await this.client.send(`DOM.enable`,{},this.sessionId);let t=(await this.client.send(`DOM.getDocument`,{depth:0},this.sessionId)).root.nodeId,n;try{n=(await this.client.send(`DOM.querySelector`,{nodeId:t,selector:e},this.sessionId)).nodeId}catch{return null}if(!n)return null;let r=(await this.client.send(`DOM.getBoxModel`,{nodeId:n},this.sessionId)).model;if(!r)return null;let i=r.content;return{x:i[0],y:i[1],width:r.width,height:r.height}}};function $e(e){let t={role:Je(e.role,`unknown`),name:Je(e.name)},n=Je(e.value);n!==``&&(t.value=n);let r=Je(e.description);return r!==``&&(t.description=r),Array.isArray(e.children)&&e.children.length>0&&(t.children=e.children.map(e=>$e(e)).filter(e=>e.role!==`unknown`)),t}function et(e){return e.headers.get(`x-proxy-error`)===`1`}async function tt(e){let t=`Proxy error ${e.status}`,n;try{n=await e.text()}catch{return t}return nt(n,t)}function nt(e,t){let n;try{n=JSON.parse(e)}catch{return t}if(!n||typeof n!=`object`)return t;let r=n.error;if(typeof r==`string`&&r.length>0)return r;if(r&&typeof r==`object`){let e=r.message;if(typeof e==`string`&&e.length>0)return e;try{return JSON.stringify(r)}catch{return t}}return t}i(`tray-leader`);let rt={state:`inactive`,session:null,error:null};function it(){return{...rt,session:rt.session?{...rt.session}:null}}const at=new Set;function ot(e){return at.add(e),()=>{at.delete(e)}}const st=new Set([`send_message`,`list_scoops`,`list_tasks`]),ct=`sessions`;function lt(){return new Promise((e,t)=>{let n=indexedDB.open(`browser-coding-agent`,1);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(ct)||e.createObjectStore(ct,{keyPath:`id`})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}var ut=class{db=null;async init(){this.db=await lt()}ensureDb(){if(!this.db)throw Error(`SessionStore not initialized. Call init() first.`);return this.db}async save(e){let t=this.ensureDb();return new Promise((n,r)=>{let i=t.transaction(ct,`readwrite`);i.objectStore(ct).put(e),i.oncomplete=()=>n(),i.onerror=()=>r(i.error)})}async load(e){let t=this.ensureDb();return new Promise((n,r)=>{let i=t.transaction(ct,`readonly`).objectStore(ct).get(e);i.onsuccess=()=>n(i.result??null),i.onerror=()=>r(i.error)})}async list(){let e=this.ensureDb();return new Promise((t,n)=>{let r=e.transaction(ct,`readonly`).objectStore(ct).getAll();r.onsuccess=()=>{t(r.result.sort((e,t)=>t.updatedAt-e.updatedAt).map(e=>e.id))},r.onerror=()=>n(r.error)})}async delete(e){let t=this.ensureDb();return new Promise((n,r)=>{let i=t.transaction(ct,`readwrite`);i.objectStore(ct).delete(e),i.oncomplete=()=>n(),i.onerror=()=>r(i.error)})}async saveMessages(e,t){let n=await this.load(e),r=n?{...n,messages:t,updatedAt:Date.now()}:{id:e,messages:t,createdAt:Date.now(),updatedAt:Date.now()};await this.save(r)}};const dt=i(`tool-ui`),ft=new class{pending=new Map;idCounter=0;generateId(){return`tool-ui-${++this.idCounter}-${Date.now().toString(36)}`}register(e,t,n,r){this.pending.set(e,{request:t,resolve:n,reject:r}),dt.info(`Tool UI registered`,{id:e})}async handleAction(e,t){let n=this.pending.get(e);if(!n){dt.warn(`Action for unknown tool UI`,{id:e,action:t.action});return}dt.info(`Tool UI action`,{id:e,action:t.action});try{let e;e=n.request.onAction?await n.request.onAction(t.action,t.data):t,n.resolve(e)}catch(e){n.reject(e instanceof Error?e:Error(String(e)))}finally{this.pending.delete(e)}}cancel(e,t=`cancelled`){let n=this.pending.get(e);n&&(n.reject(Error(t)),this.pending.delete(e),dt.info(`Tool UI cancelled`,{id:e,reason:t}))}cancelAll(e=`cancelled`){let t=this.pending.size;for(let[t,n]of this.pending)n.reject(Error(e));this.pending.clear(),t>0&&dt.info(`All tool UIs cancelled`,{reason:e,count:t})}isPending(e){return this.pending.has(e)}getPendingIds(){return[...this.pending.keys()]}};async function pt(e,t){let n=e.id??ft.generateId(),r,i,a=new Promise((e,t)=>{r=e,i=t});return ft.register(n,e,r,i),t?t({content:[{type:`tool_ui`,requestId:n,html:e.html}]}):dt.warn(`showToolUI called without onUpdate callback — UI may not render`),a.finally(()=>{t&&t({content:[{type:`tool_ui_done`,requestId:n}]})})}const mt=[];function ht(e){return mt.push(e),e}function gt(e){let t=mt.lastIndexOf(e);t!==-1&&mt.splice(t,1)}function _t(){return mt.length>0?mt[mt.length-1]:null}async function vt(e){let t=_t();return t?pt(e,t.onUpdate):(dt.warn(`showToolUIFromContext called without execution context`),null)}i(`panel-transport`);function yt(e){return typeof e==`object`&&!!e&&`source`in e&&`payload`in e}function bt(){return{onMessage:e=>{let t=(t,n,r)=>(yt(t)&&e(t),!1);return chrome.runtime.onMessage.addListener(t),()=>chrome.runtime.onMessage.removeListener(t)},send:e=>{chrome.runtime.sendMessage({source:`offscreen`,payload:e}).catch(()=>{})}}}var xt=class{orchestrator=null;browserAPI=null;messageBuffers=new Map;currentMessageId=new Map;scoopStatuses=new Map;sessionStore=null;followerSync=null;_transport;transportUnsubscribe=null;constructor(e){this._transport=e??null}get transport(){return this._transport||=bt(),this._transport}async bind(e,t){this.orchestrator=e,this.browserAPI=t??null,this.transportUnsubscribe?.(),this.transportUnsubscribe=this.setupMessageListener();let n=new ut;await n.init(),this.sessionStore=n}static createCallbacks(e){return{onResponse:(t,n,r)=>{let i=e.getOrCreateAssistantMsg(t);r?i.content+=n:(i.content=n,i.isStreaming=!1),e.emit({type:`agent-event`,scoopJid:t,eventType:`text_delta`,text:n})},onResponseDone:t=>{let n=e.currentMessageId.get(t);if(n){let r=e.getBuffer(t).find(e=>e.id===n);r&&(r.isStreaming=!1),e.currentMessageId.delete(t)}e.persistScoop(t),e.emit({type:`agent-event`,scoopJid:t,eventType:`response_done`})},onSendMessage:(t,n)=>{let r=e.getBuffer(t),i=`msg-${St()}`;r.push({id:i,role:`assistant`,content:n,timestamp:Date.now()}),e.persistScoop(t),e.emit({type:`agent-event`,scoopJid:t,eventType:`text_delta`,text:n}),e.emit({type:`agent-event`,scoopJid:t,eventType:`response_done`})},onStatusChange:(t,n)=>{e.scoopStatuses.set(t,n),n===`ready`&&e.currentMessageId.delete(t),e.emit({type:`scoop-status`,scoopJid:t,status:n}),e.emitScoopList()},onError:(t,n)=>{e.emit({type:`error`,scoopJid:t,error:n})},onToolStart:(t,n,r)=>{if(st.has(n))return;let i=e.getOrCreateAssistantMsg(t);i.toolCalls||=[],i.toolCalls.push({id:St(),name:n,input:r}),e.emit({type:`agent-event`,scoopJid:t,eventType:`tool_start`,toolName:n,toolInput:r})},onToolEnd:(t,n,r,i)=>{if(st.has(n))return;let a=e.currentMessageId.get(t);if(a){let o=e.getBuffer(t).find(e=>e.id===a);if(o?.toolCalls){let e=[...o.toolCalls].reverse().find(e=>e.name===n&&e.result===void 0);e&&(e.result=r,e.isError=i)}}e.persistScoop(t),e.emit({type:`agent-event`,scoopJid:t,eventType:`tool_end`,toolName:n,toolResult:r,isError:i})},onToolUI:(t,n,r,i)=>{e.emit({type:`agent-event`,scoopJid:t,eventType:`tool_ui`,toolName:n,requestId:r,html:i})},onToolUIDone:(t,n)=>{e.emit({type:`agent-event`,scoopJid:t,eventType:`tool_ui_done`,requestId:n})},onIncomingMessage:(t,n)=>{let r={id:n.id,role:`user`,content:n.channel===`delegation`?`**[Instructions from sliccy]**\n\n${n.content}`:n.content,attachments:n.attachments,timestamp:new Date(n.timestamp).getTime(),source:n.channel===`delegation`?`delegation`:void 0,channel:n.channel};e.getBuffer(t).push(r),e.persistScoop(t),e.emit({type:`incoming-message`,scoopJid:t,message:{id:n.id,content:n.content,attachments:n.attachments,channel:n.channel,senderName:n.senderName,fromAssistant:n.fromAssistant,timestamp:n.timestamp}})}}}toScoopSnapshot(e){let t=e.config&&(e.config.modelId!==void 0||e.config.thinkingLevel!==void 0)?{...e.config.modelId===void 0?{}:{modelId:e.config.modelId},...e.config.thinkingLevel===void 0?{}:{thinkingLevel:e.config.thinkingLevel}}:void 0;return{jid:e.jid,name:e.name,folder:e.folder,isCone:e.isCone,assistantLabel:e.assistantLabel,status:this.scoopStatuses.get(e.jid)??`ready`,...t?{config:t}:{}}}buildStateSnapshot(){let e=this.orchestrator?.getScoops().map(e=>this.toScoopSnapshot(e))??[];return{type:`state-snapshot`,scoops:e,activeScoopJid:e.find(e=>e.isCone)?.jid??null,trayRuntimeStatus:this.buildTrayRuntimeStatus()}}emitTrayRuntimeStatus(){let e=this.buildTrayRuntimeStatus(),t={type:`tray-runtime-status`,leader:e.leader,follower:e.follower};this.emit(t)}buildTrayRuntimeStatus(){let e=it(),t=D();return{leader:{state:e.state,session:e.session,error:e.error??null,reconnectAttempts:e.reconnectAttempts??0},follower:{state:t.state,joinUrl:t.joinUrl,trayId:t.trayId,error:t.error,lastError:t.lastError,reconnectAttempts:t.reconnectAttempts,attachAttempts:t.attachAttempts,lastAttachCode:t.lastAttachCode,connectingSince:t.connectingSince,lastPingTime:t.lastPingTime}}}setFollowerSync(e){this.followerSync=e}applyFollowerSnapshot(e){if(!this.orchestrator)return;let t=this.orchestrator.getScoops().find(e=>e.isCone);if(!t)return;let n=e.map(e=>({id:e.id,role:e.role,content:e.content,attachments:e.attachments,timestamp:e.timestamp,source:e.source,channel:e.channel,toolCalls:e.toolCalls?.map(e=>({id:e.id,name:e.name,input:e.input,result:e.result,isError:e.isError})),isStreaming:e.isStreaming}));if(this.messageBuffers.set(t.jid,n),this.currentMessageId.delete(t.jid),this.sessionStore){let n=t.isCone?`session-cone`:`session-${t.folder}`;this.sessionStore.saveMessages(n,e).catch(e=>{console.warn(`[offscreen-bridge] applyFollowerSnapshot persist failed:`,e)})}this.emit({type:`scoop-messages-replaced`,scoopJid:t.jid,messages:n})}getConeJid(){return this.orchestrator?.getScoops().find(e=>e.isCone)?.jid??null}emitFollowerAgentEvent(e){let t=this.getConeJid();if(t)switch(e.type){case`content_delta`:this.emit({type:`agent-event`,scoopJid:t,eventType:`text_delta`,text:e.text});break;case`content_done`:this.emit({type:`agent-event`,scoopJid:t,eventType:`response_done`});break;case`tool_use_start`:this.emit({type:`agent-event`,scoopJid:t,eventType:`tool_start`,toolName:e.toolName,toolInput:e.toolInput});break;case`tool_result`:this.emit({type:`agent-event`,scoopJid:t,eventType:`tool_end`,toolName:e.toolName,toolResult:e.result,isError:e.isError});break;case`turn_end`:this.emit({type:`agent-event`,scoopJid:t,eventType:`turn_end`});break;case`error`:this.emit({type:`error`,scoopJid:t,error:e.error});break}}emitFollowerIncomingMessage(e,t){let n=this.getConeJid();n&&this.emit({type:`incoming-message`,scoopJid:n,message:{id:e,content:t,channel:`web`,senderName:`User`,fromAssistant:!1,timestamp:new Date().toISOString()}})}emitFollowerStatus(e){let t=this.getConeJid();if(!t)return;let n=e===`processing`?`processing`:`ready`;this.scoopStatuses.set(t,n),this.emit({type:`scoop-status`,scoopJid:t,status:n})}async handleRequestScoopMessages(e){if(!this.orchestrator)return;let t=this.orchestrator.getScoops().find(t=>t.jid===e);if(!t)return;let n=this.messageBuffers.get(e);if(n&&n.length>0){this.emit({type:`scoop-messages-replaced`,scoopJid:e,messages:n});return}let r=this.orchestrator.getScoopContext(e);if(r){let{agentMessagesToChatMessages:n}=await import(`./agent-message-to-chat-BlIs6e4u.js`),i=r.getAgentMessages();if(i.length>0){let r=n(i,{source:t.isCone?`cone`:t.name??t.folder}).map(e=>({id:e.id,role:e.role,content:e.content,attachments:e.attachments,timestamp:e.timestamp,source:e.source,channel:e.channel,toolCalls:e.toolCalls?.map(e=>({id:e.id,name:e.name,input:e.input,result:e.result,isError:e.isError})),isStreaming:!1}));this.messageBuffers.set(e,r),this.currentMessageId.delete(e),this.persistScoop(e),this.emit({type:`scoop-messages-replaced`,scoopJid:e,messages:r});return}}if(this.sessionStore){let n=t.isCone?`session-cone`:`session-${t.folder}`;try{let t=(await this.sessionStore.load(n))?.messages??[];t.length>0&&(this.messageBuffers.set(e,t),this.currentMessageId.delete(e),this.emit({type:`scoop-messages-replaced`,scoopJid:e,messages:t}))}catch(e){console.warn(`[offscreen-bridge] sessionStore load failed:`,n,e)}}}persistScoop(e){if(!this.sessionStore||!this.orchestrator)return;let t=this.orchestrator.getScoops().find(t=>t.jid===e);if(!t)return;let n=t.isCone?`session-cone`:`session-${t.folder}`,r=this.messageBuffers.get(e);!r||r.length===0||this.sessionStore.saveMessages(n,r).catch(e=>{console.warn(`[offscreen-bridge] persistScoop failed:`,n,e)})}getBuffer(e){let t=this.messageBuffers.get(e);return t||(t=[],this.messageBuffers.set(e,t)),t}getOrCreateAssistantMsg(e){let t=this.getBuffer(e),n=this.currentMessageId.get(e);if(n){let e=t.find(e=>e.id===n);if(e)return e}n=`scoop-${e}-${St()}`,this.currentMessageId.set(e,n);let r=(this.orchestrator?.getScoops()??[]).find(t=>t.jid===e),i=r?.isCone?`cone`:r?.name??`unknown`,a={id:n,role:`assistant`,content:``,timestamp:Date.now(),toolCalls:[],isStreaming:!0,source:i};return t.push(a),a}setupMessageListener(){return this.transport.onMessage(e=>{if(e.source===`panel`){if(e.payload?.type===`sprinkle-op-response`){import(`./sprinkle-proxy-Ci8JPwa_.js`).then(({handleSprinkleOpResponse:t})=>{t(e.payload)});return}this.handlePanelMessage(e.payload).catch(t=>{console.error(`[offscreen-bridge] handlePanelMessage error:`,t);let n=e.payload.scoopJid;n&&this.emit({type:`error`,scoopJid:n,error:t instanceof Error?t.message:String(t)})})}})}async handlePanelMessage(e){if(this.orchestrator)switch(e.type){case`user-message`:{if(this.followerSync){this.getBuffer(e.scoopJid).push({id:e.messageId,role:`user`,content:e.text,attachments:e.attachments,timestamp:Date.now()}),this.persistScoop(e.scoopJid),this.followerSync.sendMessage(e.text,e.messageId,e.attachments);break}let t={id:e.messageId,chatJid:e.scoopJid,senderId:`user`,senderName:`User`,content:e.text,attachments:e.attachments,timestamp:new Date().toISOString(),fromAssistant:!1,channel:`web`};this.getBuffer(e.scoopJid).push({id:e.messageId,role:`user`,content:e.text,attachments:e.attachments,timestamp:Date.now()}),this.persistScoop(e.scoopJid),await this.orchestrator.handleMessage(t),this.orchestrator.createScoopTab(e.scoopJid);break}case`cone-create`:{let t={jid:`cone_${Date.now()}`,name:e.name,folder:`cone`,isCone:!0,type:`cone`,requiresTrigger:!1,assistantLabel:`sliccy`,addedAt:new Date().toISOString()};await this.orchestrator.registerScoop(t),this.emit({type:`scoop-created`,scoop:this.toScoopSnapshot(t)});break}case`scoop-feed`:await this.orchestrator.delegateToScoop(e.scoopJid,e.prompt,`sliccy`);break;case`scoop-drop`:{let t=this.orchestrator.getScoops().find(t=>t.jid===e.scoopJid);if(await this.orchestrator.unregisterScoop(e.scoopJid),this.messageBuffers.delete(e.scoopJid),this.currentMessageId.delete(e.scoopJid),this.scoopStatuses.delete(e.scoopJid),t&&this.sessionStore){let e=t.isCone?`session-cone`:`session-${t.folder}`;this.sessionStore.delete(e).catch(t=>{console.warn(`[offscreen-bridge] Failed to delete session on scoop drop:`,e,t)})}this.emitScoopList();break}case`abort`:this.orchestrator.stopScoop(e.scoopJid),this.orchestrator.clearQueuedMessages(e.scoopJid).catch(e=>{console.warn(`[offscreen-bridge] Failed to clear queued messages on abort:`,e)});break;case`set-model`:this.orchestrator.updateModel();break;case`request-state`:this.emit(this.buildStateSnapshot());break;case`request-scoop-messages`:await this.handleRequestScoopMessages(e.scoopJid);break;case`clear-chat`:if(await this.orchestrator.clearAllMessages(),this.sessionStore){let e=this.orchestrator.getScoops();await Promise.all(e.map(e=>{let t=e.isCone?`session-cone`:`session-${e.folder}`;return this.sessionStore.delete(t)}))}this.messageBuffers.clear(),this.currentMessageId.clear();break;case`clear-filesystem`:try{await this.orchestrator.resetFilesystem()}catch(e){console.error(`[offscreen-bridge] clear-filesystem failed:`,e)}break;case`refresh-model`:this.orchestrator.updateModel();break;case`set-thinking-level`:{let t=e;try{await this.orchestrator.setScoopThinkingLevel(t.scoopJid,t.level)}catch(e){console.error(`[offscreen-bridge] set-thinking-level failed:`,e)}break}case`sprinkle-lick`:{let t=this.orchestrator.getScoops(),n=e,r=n.targetScoop?t.find(e=>e.name===n.targetScoop||e.folder===n.targetScoop||e.folder===`${n.targetScoop}-scoop`):void 0;if(r||=t.find(e=>e.isCone),r){let e=`sprinkle-${n.sprinkleName}-${Date.now()}`,t=`[Sprinkle Event: ${n.sprinkleName}]\n\`\`\`json\n${JSON.stringify(n.body,null,2)}\n\`\`\``,i={id:e,chatJid:r.jid,senderId:`sprinkle`,senderName:`sprinkle:${n.sprinkleName}`,content:t,timestamp:new Date().toISOString(),fromAssistant:!1,channel:`sprinkle`};this.getBuffer(r.jid).push({id:e,role:`user`,content:t,timestamp:Date.now(),source:`lick`,channel:`sprinkle`}),this.persistScoop(r.jid),await this.orchestrator.handleMessage(i)}break}case`reload-skills`:this.orchestrator.reloadAllSkills().catch(e=>{console.warn(`[offscreen-bridge] Skill reload failed:`,e)});break;case`panel-cdp-command`:{let{id:t,method:n,params:r,sessionId:i}=e;if(!this.browserAPI){console.warn(`[offscreen-bridge] Panel CDP command received but BrowserAPI is null`),this.emit({type:`panel-cdp-response`,id:t,error:`BrowserAPI not available`});break}try{let e=await this.browserAPI.getTransport().send(n,r,i);this.emit({type:`panel-cdp-response`,id:t,result:e})}catch(e){this.emit({type:`panel-cdp-response`,id:t,error:e instanceof Error?e.message:String(e)})}break}case`tool-ui-action`:{let{requestId:t,action:n,data:r}=e;try{await ft.handleAction(t,{action:n,data:r})}catch(e){let r=e instanceof Error?e.message:String(e);console.error(`[offscreen-bridge] Tool UI action failed`,{requestId:t,action:n,error:r}),ft.cancel(t,`Action failed: ${r}`)}break}case`local-storage-set`:try{globalThis.localStorage?.setItem(e.key,e.value)}catch(e){console.warn(`[offscreen-bridge] local-storage-set failed:`,e)}break;case`local-storage-remove`:try{globalThis.localStorage?.removeItem(e.key)}catch(e){console.warn(`[offscreen-bridge] local-storage-remove failed:`,e)}break;case`local-storage-clear`:try{globalThis.localStorage?.clear()}catch(e){console.warn(`[offscreen-bridge] local-storage-clear failed:`,e)}break}}emitScoopList(){let e=this.orchestrator?.getScoops().map(e=>this.toScoopSnapshot(e))??[];this.emit({type:`scoop-list`,scoops:e})}emit(e){this.transport.send(e)}};function St(){return Date.now().toString(36)+Math.random().toString(36).slice(2,8)}const Ct=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`];function wt(e){return typeof e==`string`&&Ct.includes(e)}var Tt=r((e=>{(function(){var t={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function n(e){return i(o(e),arguments)}function r(e,t){return n.apply(null,[e].concat(t||[]))}function i(e,r){var i=1,a=e.length,o,s=``,c,l,u,d,f,p,m,h;for(c=0;c<a;c++)if(typeof e[c]==`string`)s+=e[c];else if(typeof e[c]==`object`){if(u=e[c],u.keys)for(o=r[i],l=0;l<u.keys.length;l++){if(o==null)throw Error(n(`[sprintf] Cannot access property "%s" of undefined value "%s"`,u.keys[l],u.keys[l-1]));o=o[u.keys[l]]}else o=u.param_no?r[u.param_no]:r[i++];if(t.not_type.test(u.type)&&t.not_primitive.test(u.type)&&o instanceof Function&&(o=o()),t.numeric_arg.test(u.type)&&typeof o!=`number`&&isNaN(o))throw TypeError(n(`[sprintf] expecting number but found %T`,o));switch(t.number.test(u.type)&&(m=o>=0),u.type){case`b`:o=parseInt(o,10).toString(2);break;case`c`:o=String.fromCharCode(parseInt(o,10));break;case`d`:case`i`:o=parseInt(o,10);break;case`j`:o=JSON.stringify(o,null,u.width?parseInt(u.width):0);break;case`e`:o=u.precision?parseFloat(o).toExponential(u.precision):parseFloat(o).toExponential();break;case`f`:o=u.precision?parseFloat(o).toFixed(u.precision):parseFloat(o);break;case`g`:o=u.precision?String(Number(o.toPrecision(u.precision))):parseFloat(o);break;case`o`:o=(parseInt(o,10)>>>0).toString(8);break;case`s`:o=String(o),o=u.precision?o.substring(0,u.precision):o;break;case`t`:o=String(!!o),o=u.precision?o.substring(0,u.precision):o;break;case`T`:o=Object.prototype.toString.call(o).slice(8,-1).toLowerCase(),o=u.precision?o.substring(0,u.precision):o;break;case`u`:o=parseInt(o,10)>>>0;break;case`v`:o=o.valueOf(),o=u.precision?o.substring(0,u.precision):o;break;case`x`:o=(parseInt(o,10)>>>0).toString(16);break;case`X`:o=(parseInt(o,10)>>>0).toString(16).toUpperCase();break}t.json.test(u.type)?s+=o:(t.number.test(u.type)&&(!m||u.sign)?(h=m?`+`:`-`,o=o.toString().replace(t.sign,``)):h=``,f=u.pad_char?u.pad_char===`0`?`0`:u.pad_char.charAt(1):` `,p=u.width-(h+o).length,d=u.width&&p>0?f.repeat(p):``,s+=u.align?h+o+d:f===`0`?h+d+o:d+h+o)}return s}var a=Object.create(null);function o(e){if(a[e])return a[e];for(var n=e,r,i=[],o=0;n;){if((r=t.text.exec(n))!==null)i.push(r[0]);else if((r=t.modulo.exec(n))!==null)i.push(`%`);else if((r=t.placeholder.exec(n))!==null){if(r[2]){o|=1;var s=[],c=r[2],l=[];if((l=t.key.exec(c))!==null)for(s.push(l[1]);(c=c.substring(l[0].length))!==``;)if((l=t.key_access.exec(c))!==null)s.push(l[1]);else if((l=t.index_access.exec(c))!==null)s.push(l[1]);else throw SyntaxError(`[sprintf] failed to parse named argument key`);else throw SyntaxError(`[sprintf] failed to parse named argument key`);r[2]=s}else o|=2;if(o===3)throw Error(`[sprintf] mixing positional and named placeholders is not (yet) supported`);i.push({placeholder:r[0],param_no:r[1],keys:r[2],sign:r[3],pad_char:r[4],align:r[5],width:r[6],precision:r[7],type:r[8]})}else throw SyntaxError(`[sprintf] unexpected placeholder`);n=n.substring(r[0].length)}return a[e]=i}e!==void 0&&(e.sprintf=n,e.vsprintf=r),typeof window<`u`&&(window.sprintf=n,window.vsprintf=r,typeof define==`function`&&define.amd&&define(function(){return{sprintf:n,vsprintf:r}}))})()}))();const Et=(e,t,n)=>{let r=e instanceof RegExp?Dt(e,n):e,i=t instanceof RegExp?Dt(t,n):t,a=r!==null&&i!=null&&Ot(r,i,n);return a&&{start:a[0],end:a[1],pre:n.slice(0,a[0]),body:n.slice(a[0]+r.length,a[1]),post:n.slice(a[1]+i.length)}},Dt=(e,t)=>{let n=t.match(e);return n?n[0]:null},Ot=(e,t,n)=>{let r,i,a,o,s,c=n.indexOf(e),l=n.indexOf(t,c+1),u=c;if(c>=0&&l>0){if(e===t)return[c,l];for(r=[],a=n.length;u>=0&&!s;){if(u===c)r.push(u),c=n.indexOf(e,u+1);else if(r.length===1){let e=r.pop();e!==void 0&&(s=[e,l])}else i=r.pop(),i!==void 0&&i<a&&(a=i,o=l),l=n.indexOf(t,u+1);u=c<l&&c>=0?c:l}r.length&&o!==void 0&&(s=[a,o])}return s},kt=`\0SLASH`+Math.random()+`\0`,At=`\0OPEN`+Math.random()+`\0`,jt=`\0CLOSE`+Math.random()+`\0`,Mt=`\0COMMA`+Math.random()+`\0`,Nt=`\0PERIOD`+Math.random()+`\0`,Pt=new RegExp(kt,`g`),Ft=new RegExp(At,`g`),It=new RegExp(jt,`g`),Lt=new RegExp(Mt,`g`),Rt=new RegExp(Nt,`g`),zt=/\\\\/g,Bt=/\\{/g,Vt=/\\}/g,Ht=/\\,/g,Ut=/\\\./g;function Wt(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function Gt(e){return e.replace(zt,kt).replace(Bt,At).replace(Vt,jt).replace(Ht,Mt).replace(Ut,Nt)}function Kt(e){return e.replace(Pt,`\\`).replace(Ft,`{`).replace(It,`}`).replace(Lt,`,`).replace(Rt,`.`)}function qt(e){if(!e)return[``];let t=[],n=Et(`{`,`}`,e);if(!n)return e.split(`,`);let{pre:r,body:i,post:a}=n,o=r.split(`,`);o[o.length-1]+=`{`+i+`}`;let s=qt(a);return a.length&&(o[o.length-1]+=s.shift(),o.push.apply(o,s)),t.push.apply(t,o),t}function Jt(e,t={}){if(!e)return[];let{max:n=1e5}=t;return e.slice(0,2)===`{}`&&(e=`\\{\\}`+e.slice(2)),$t(Gt(e),n,!0).map(Kt)}function Yt(e){return`{`+e+`}`}function Xt(e){return/^-?0\d/.test(e)}function Zt(e,t){return e<=t}function Qt(e,t){return e>=t}function $t(e,t,n){let r=[],i=Et(`{`,`}`,e);if(!i)return[e];let a=i.pre,o=i.post.length?$t(i.post,t,!1):[``];if(/\$$/.test(i.pre))for(let e=0;e<o.length&&e<t;e++){let t=a+`{`+i.body+`}`+o[e];r.push(t)}else{let s=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body),c=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body),l=s||c,u=i.body.indexOf(`,`)>=0;if(!l&&!u)return i.post.match(/,(?!,).*\}/)?(e=i.pre+`{`+i.body+jt+i.post,$t(e,t,!0)):[e];let d;if(l)d=i.body.split(/\.\./);else if(d=qt(i.body),d.length===1&&d[0]!==void 0&&(d=$t(d[0],t,!1).map(Yt),d.length===1))return o.map(e=>i.pre+d[0]+e);let f;if(l&&d[0]!==void 0&&d[1]!==void 0){let e=Wt(d[0]),t=Wt(d[1]),n=Math.max(d[0].length,d[1].length),r=d.length===3&&d[2]!==void 0?Math.abs(Wt(d[2])):1,i=Zt;t<e&&(r*=-1,i=Qt);let a=d.some(Xt);f=[];for(let o=e;i(o,t);o+=r){let e;if(c)e=String.fromCharCode(o),e===`\\`&&(e=``);else if(e=String(o),a){let t=n-e.length;if(t>0){let n=Array(t+1).join(`0`);e=o<0?`-`+n+e.slice(1):n+e}}f.push(e)}}else{f=[];for(let e=0;e<d.length;e++)f.push.apply(f,$t(d[e],t,!1))}for(let e=0;e<f.length;e++)for(let i=0;i<o.length&&r.length<t;i++){let t=a+f[e]+o[i];(!n||l||t)&&r.push(t)}}return r}const en=e=>{if(typeof e!=`string`)throw TypeError(`invalid pattern`);if(e.length>65536)throw TypeError(`pattern is too long`)},tn={"[:alnum:]":[`\\p{L}\\p{Nl}\\p{Nd}`,!0],"[:alpha:]":[`\\p{L}\\p{Nl}`,!0],"[:ascii:]":[`\\x00-\\x7f`,!1],"[:blank:]":[`\\p{Zs}\\t`,!0],"[:cntrl:]":[`\\p{Cc}`,!0],"[:digit:]":[`\\p{Nd}`,!0],"[:graph:]":[`\\p{Z}\\p{C}`,!0,!0],"[:lower:]":[`\\p{Ll}`,!0],"[:print:]":[`\\p{C}`,!0],"[:punct:]":[`\\p{P}`,!0],"[:space:]":[`\\p{Z}\\t\\r\\n\\v\\f`,!0],"[:upper:]":[`\\p{Lu}`,!0],"[:word:]":[`\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}`,!0],"[:xdigit:]":[`A-Fa-f0-9`,!1]},nn=e=>e.replace(/[[\]\\-]/g,`\\$&`),rn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),an=e=>e.join(``),on=(e,t)=>{let n=t;if(e.charAt(n)!==`[`)throw Error(`not in a brace expression`);let r=[],i=[],a=n+1,o=!1,s=!1,c=!1,l=!1,u=n,d=``;WHILE:for(;a<e.length;){let t=e.charAt(a);if((t===`!`||t===`^`)&&a===n+1){l=!0,a++;continue}if(t===`]`&&o&&!c){u=a+1;break}if(o=!0,t===`\\`&&!c){c=!0,a++;continue}if(t===`[`&&!c){for(let[t,[o,c,l]]of Object.entries(tn))if(e.startsWith(t,a)){if(d)return[`$.`,!1,e.length-n,!0];a+=t.length,l?i.push(o):r.push(o),s||=c;continue WHILE}}if(c=!1,d){t>d?r.push(nn(d)+`-`+nn(t)):t===d&&r.push(nn(t)),d=``,a++;continue}if(e.startsWith(`-]`,a+1)){r.push(nn(t+`-`)),a+=2;continue}if(e.startsWith(`-`,a+1)){d=t,a+=2;continue}r.push(nn(t)),a++}if(u<a)return[``,!1,0,!1];if(!r.length&&!i.length)return[`$.`,!1,e.length-n,!0];if(i.length===0&&r.length===1&&/^\\?.$/.test(r[0])&&!l)return[rn(r[0].length===2?r[0].slice(-1):r[0]),!1,u-n,!1];let f=`[`+(l?`^`:``)+an(r)+`]`,p=`[`+(l?``:`^`)+an(i)+`]`;return[r.length&&i.length?`(`+f+`|`+p+`)`:r.length?f:p,s,u-n,!0]},sn=(e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!0}={})=>n?t?e.replace(/\[([^\/\\])\]/g,`$1`):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,`$1$2`).replace(/\\([^\/])/g,`$1`):t?e.replace(/\[([^\/\\{}])\]/g,`$1`):e.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,`$1$2`).replace(/\\([^\/{}])/g,`$1`);var cn;const ln=new Set([`!`,`?`,`+`,`*`,`@`]),un=e=>ln.has(e),dn=e=>un(e.type),fn=new Map([[`!`,[`@`]],[`?`,[`?`,`@`]],[`@`,[`@`]],[`*`,[`*`,`+`,`?`,`@`]],[`+`,[`+`,`@`]]]),pn=new Map([[`!`,[`?`]],[`@`,[`?`]],[`+`,[`?`,`*`]]]),mn=new Map([[`!`,[`?`,`@`]],[`?`,[`?`,`@`]],[`@`,[`?`,`@`]],[`*`,[`*`,`+`,`?`,`@`]],[`+`,[`+`,`@`,`?`,`*`]]]),hn=new Map([[`!`,new Map([[`!`,`@`]])],[`?`,new Map([[`*`,`*`],[`+`,`*`]])],[`@`,new Map([[`!`,`!`],[`?`,`?`],[`@`,`@`],[`*`,`*`],[`+`,`+`]])],[`+`,new Map([[`?`,`*`],[`*`,`*`]])]]),gn=`(?!\\.)`,_n=new Set([`[`,`.`]),vn=new Set([`..`,`.`]),yn=new Set(`().*{}+?[]^$\\!`),bn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),xn=`[^/]`,Sn=xn+`*?`,Cn=xn+`+?`;let wn=0;var Tn=class{type;#e;#t;#n=!1;#r=[];#i;#a;#o;#s=!1;#c;#l;#u=!1;id=++wn;get depth(){return(this.#i?.depth??-1)+1}[Symbol.for(`nodejs.util.inspect.custom`)](){return{"@@type":`AST`,id:this.id,type:this.type,root:this.#e.id,parent:this.#i?.id,depth:this.depth,partsLength:this.#r.length,parts:this.#r}}constructor(e,t,n={}){this.type=e,e&&(this.#t=!0),this.#i=t,this.#e=this.#i?this.#i.#e:this,this.#c=this.#e===this?n:this.#e.#c,this.#o=this.#e===this?[]:this.#e.#o,e===`!`&&!this.#e.#s&&this.#o.push(this),this.#a=this.#i?this.#i.#r.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let e of this.#r)if(typeof e!=`string`&&(e.type||e.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#l===void 0?this.type?this.#l=this.type+`(`+this.#r.map(e=>String(e)).join(`|`)+`)`:this.#l=this.#r.map(e=>String(e)).join(``):this.#l}#d(){if(this!==this.#e)throw Error(`should only call on root`);if(this.#s)return this;this.toString(),this.#s=!0;let e;for(;e=this.#o.pop();){if(e.type!==`!`)continue;let t=e,n=t.#i;for(;n;){for(let r=t.#a+1;!n.type&&r<n.#r.length;r++)for(let t of e.#r){if(typeof t==`string`)throw Error(`string part in extglob AST??`);t.copyIn(n.#r[r])}t=n,n=t.#i}}return this}push(...e){for(let t of e)if(t!==``){if(typeof t!=`string`&&!(t instanceof cn&&t.#i===this))throw Error(`invalid part: `+t);this.#r.push(t)}}toJSON(){let e=this.type===null?this.#r.slice().map(e=>typeof e==`string`?e:e.toJSON()):[this.type,...this.#r.map(e=>e.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#s&&this.#i?.type===`!`)&&e.push({}),e}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#a===0)return!0;let e=this.#i;for(let t=0;t<this.#a;t++){let n=e.#r[t];if(!(n instanceof cn&&n.type===`!`))return!1}return!0}isEnd(){if(this.#e===this||this.#i?.type===`!`)return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let e=this.#i?this.#i.#r.length:0;return this.#a===e-1}copyIn(e){typeof e==`string`?this.push(e):this.push(e.clone(this))}clone(e){let t=new cn(this.type,e);for(let e of this.#r)t.copyIn(e);return t}static#f(e,t,n,r,i){let a=r.maxExtglobRecursion??2,o=!1,s=!1,c=-1,l=!1;if(t.type===null){let u=n,d=``;for(;u<e.length;){let n=e.charAt(u++);if(o||n===`\\`){o=!o,d+=n;continue}if(s){u===c+1?(n===`^`||n===`!`)&&(l=!0):n===`]`&&!(u===c+2&&l)&&(s=!1),d+=n;continue}else if(n===`[`){s=!0,c=u,l=!1,d+=n;continue}if(!r.noext&&un(n)&&e.charAt(u)===`(`&&i<=a){t.push(d),d=``;let a=new cn(n,t);u=cn.#f(e,a,u,r,i+1),t.push(a);continue}d+=n}return t.push(d),u}let u=n+1,d=new cn(null,t),f=[],p=``;for(;u<e.length;){let n=e.charAt(u++);if(o||n===`\\`){o=!o,p+=n;continue}if(s){u===c+1?(n===`^`||n===`!`)&&(l=!0):n===`]`&&!(u===c+2&&l)&&(s=!1),p+=n;continue}else if(n===`[`){s=!0,c=u,l=!1,p+=n;continue}if(!r.noext&&un(n)&&e.charAt(u)===`(`&&(i<=a||t&&t.#h(n))){let a=t&&t.#h(n)?0:1;d.push(p),p=``;let o=new cn(n,d);d.push(o),u=cn.#f(e,o,u,r,i+a);continue}if(n===`|`){d.push(p),p=``,f.push(d),d=new cn(null,t);continue}if(n===`)`)return p===``&&t.#r.length===0&&(t.#u=!0),d.push(p),p=``,t.push(...f,d),u;p+=n}return t.type=null,t.#t=void 0,t.#r=[e.substring(n-1)],u}#p(e){return this.#m(e,pn)}#m(e,t=fn){if(!e||typeof e!=`object`||e.type!==null||e.#r.length!==1||this.type===null)return!1;let n=e.#r[0];return!n||typeof n!=`object`||n.type===null?!1:this.#h(n.type,t)}#h(e,t=mn){return!!t.get(this.type)?.includes(e)}#g(e,t){let n=e.#r[0],r=new cn(null,n,this.options);r.#r.push(``),n.push(r),this.#_(e,t)}#_(e,t){let n=e.#r[0];this.#r.splice(t,1,...n.#r);for(let e of n.#r)typeof e==`object`&&(e.#i=this);this.#l=void 0}#v(e){return!!hn.get(this.type)?.has(e)}#y(e){if(!e||typeof e!=`object`||e.type!==null||e.#r.length!==1||this.type===null||this.#r.length!==1)return!1;let t=e.#r[0];return!t||typeof t!=`object`||t.type===null?!1:this.#v(t.type)}#b(e){let t=hn.get(this.type),n=e.#r[0],r=t?.get(n.type);if(!r)return!1;this.#r=n.#r;for(let e of this.#r)typeof e==`object`&&(e.#i=this);this.type=r,this.#l=void 0,this.#u=!1}static fromGlob(e,t={}){let n=new cn(null,void 0,t);return cn.#f(e,n,0,t,0),n}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let e=this.toString(),[t,n,r,i]=this.toRegExpSource();if(!(r||this.#t||this.#c.nocase&&!this.#c.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return n;let a=(this.#c.nocase?`i`:``)+(i?`u`:``);return Object.assign(RegExp(`^${t}$`,a),{_src:t,_glob:e})}get options(){return this.#c}toRegExpSource(e){let t=e??!!this.#c.dot;if(this.#e===this&&(this.#x(),this.#d()),!dn(this)){let n=this.isStart()&&this.isEnd()&&!this.#r.some(e=>typeof e!=`string`),r=this.#r.map(t=>{let[r,i,a,o]=typeof t==`string`?cn.#C(t,this.#t,n):t.toRegExpSource(e);return this.#t=this.#t||a,this.#n=this.#n||o,r}).join(``),i=``;if(this.isStart()&&typeof this.#r[0]==`string`&&!(this.#r.length===1&&vn.has(this.#r[0]))){let n=_n,a=t&&n.has(r.charAt(0))||r.startsWith(`\\.`)&&n.has(r.charAt(2))||r.startsWith(`\\.\\.`)&&n.has(r.charAt(4)),o=!t&&!e&&n.has(r.charAt(0));i=a?`(?!(?:^|/)\\.\\.?(?:$|/))`:o?gn:``}let a=``;return this.isEnd()&&this.#e.#s&&this.#i?.type===`!`&&(a=`(?:$|\\/)`),[i+r+a,sn(r),this.#t=!!this.#t,this.#n]}let n=this.type===`*`||this.type===`+`,r=this.type===`!`?`(?:(?!(?:`:`(?:`,i=this.#S(t);if(this.isStart()&&this.isEnd()&&!i&&this.type!==`!`){let e=this.toString(),t=this;return t.#r=[e],t.type=null,t.#t=void 0,[e,sn(this.toString()),!1,!1]}let a=!n||e||t?``:this.#S(!0);a===i&&(a=``),a&&(i=`(?:${i})(?:${a})*?`);let o=``;if(this.type===`!`&&this.#u)o=(this.isStart()&&!t?gn:``)+Cn;else{let n=this.type===`!`?`))`+(this.isStart()&&!t&&!e?gn:``)+Sn+`)`:this.type===`@`?`)`:this.type===`?`?`)?`:this.type===`+`&&a?`)`:this.type===`*`&&a?`)?`:`)${this.type}`;o=r+i+n}return[o,sn(i),this.#t=!!this.#t,this.#n]}#x(){if(dn(this)){let e=0,t=!1;do{t=!0;for(let e=0;e<this.#r.length;e++){let n=this.#r[e];typeof n==`object`&&(n.#x(),this.#m(n)?(t=!1,this.#_(n,e)):this.#p(n)?(t=!1,this.#g(n,e)):this.#y(n)&&(t=!1,this.#b(n)))}}while(!t&&++e<10)}else for(let e of this.#r)typeof e==`object`&&e.#x();this.#l=void 0}#S(e){return this.#r.map(t=>{if(typeof t==`string`)throw Error(`string type in extglob ast??`);let[n,r,i,a]=t.toRegExpSource(e);return this.#n=this.#n||a,n}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join(`|`)}static#C(e,t,n=!1){let r=!1,i=``,a=!1,o=!1;for(let s=0;s<e.length;s++){let c=e.charAt(s);if(r){r=!1,i+=(yn.has(c)?`\\`:``)+c;continue}if(c===`*`){if(o)continue;o=!0,i+=n&&/^[*]+$/.test(e)?Cn:Sn,t=!0;continue}else o=!1;if(c===`\\`){s===e.length-1?i+=`\\\\`:r=!0;continue}if(c===`[`){let[n,r,o,c]=on(e,s);if(o){i+=n,a||=r,s+=o-1,t||=c;continue}}if(c===`?`){i+=xn,t=!0;continue}i+=bn(c)}return[i,sn(e),!!t,a]}};cn=Tn;const En=(e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!1}={})=>n?t?e.replace(/[?*()[\]{}]/g,`[$&]`):e.replace(/[?*()[\]\\{}]/g,`\\$&`):t?e.replace(/[?*()[\]]/g,`[$&]`):e.replace(/[?*()[\]\\]/g,`\\$&`),Dn=(e,t,n={})=>(en(t),!n.nocomment&&t.charAt(0)===`#`?!1:new tr(t,n).match(e)),On=/^\*+([^+@!?\*\[\(]*)$/,kn=e=>t=>!t.startsWith(`.`)&&t.endsWith(e),An=e=>t=>t.endsWith(e),jn=e=>(e=e.toLowerCase(),t=>!t.startsWith(`.`)&&t.toLowerCase().endsWith(e)),Mn=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Nn=/^\*+\.\*+$/,Pn=e=>!e.startsWith(`.`)&&e.includes(`.`),Fn=e=>e!==`.`&&e!==`..`&&e.includes(`.`),In=/^\.\*+$/,Ln=e=>e!==`.`&&e!==`..`&&e.startsWith(`.`),Rn=/^\*+$/,zn=e=>e.length!==0&&!e.startsWith(`.`),Bn=e=>e.length!==0&&e!==`.`&&e!==`..`,Vn=/^\?+([^+@!?\*\[\(]*)?$/,Hn=([e,t=``])=>{let n=Kn([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},Un=([e,t=``])=>{let n=qn([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},Wn=([e,t=``])=>{let n=qn([e]);return t?e=>n(e)&&e.endsWith(t):n},Gn=([e,t=``])=>{let n=Kn([e]);return t?e=>n(e)&&e.endsWith(t):n},Kn=([e])=>{let t=e.length;return e=>e.length===t&&!e.startsWith(`.`)},qn=([e])=>{let t=e.length;return e=>e.length===t&&e!==`.`&&e!==`..`},Jn=typeof process==`object`&&process?{}.__MINIMATCH_TESTING_PLATFORM__||process.platform:`posix`,Yn={win32:{sep:`\\`},posix:{sep:`/`}};Dn.sep=Jn===`win32`?Yn.win32.sep:Yn.posix.sep;const Xn=Symbol(`globstar **`);Dn.GLOBSTAR=Xn,Dn.filter=(e,t={})=>n=>Dn(n,e,t);const Zn=(e,t={})=>Object.assign({},e,t);Dn.defaults=e=>{if(!e||typeof e!=`object`||!Object.keys(e).length)return Dn;let t=Dn;return Object.assign((n,r,i={})=>t(n,r,Zn(e,i)),{Minimatch:class extends t.Minimatch{constructor(t,n={}){super(t,Zn(e,n))}static defaults(n){return t.defaults(Zn(e,n)).Minimatch}},AST:class extends t.AST{constructor(t,n,r={}){super(t,n,Zn(e,r))}static fromGlob(n,r={}){return t.AST.fromGlob(n,Zn(e,r))}},unescape:(n,r={})=>t.unescape(n,Zn(e,r)),escape:(n,r={})=>t.escape(n,Zn(e,r)),filter:(n,r={})=>t.filter(n,Zn(e,r)),defaults:n=>t.defaults(Zn(e,n)),makeRe:(n,r={})=>t.makeRe(n,Zn(e,r)),braceExpand:(n,r={})=>t.braceExpand(n,Zn(e,r)),match:(n,r,i={})=>t.match(n,r,Zn(e,i)),sep:t.sep,GLOBSTAR:Xn})};const Qn=(e,t={})=>(en(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Jt(e,{max:t.braceExpandMax}));Dn.braceExpand=Qn,Dn.makeRe=(e,t={})=>new tr(e,t).makeRe(),Dn.match=(e,t,n={})=>{let r=new tr(t,n);return e=e.filter(e=>r.match(e)),r.options.nonull&&!e.length&&e.push(t),e};const $n=/[?*]|[+@!]\(.*?\)|\[|\]/,er=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`);var tr=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,t={}){en(e),t||={},this.options=t,this.maxGlobstarRecursion=t.maxGlobstarRecursion??200,this.pattern=e,this.platform=t.platform||Jn,this.isWindows=this.platform===`win32`,this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,`/`)),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!t.nonegate,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot===void 0?!!(this.isWindows&&this.nocase):t.windowsNoMagicRoot,this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let e of this.set)for(let t of e)if(typeof t!=`string`)return!0;return!1}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)===`#`){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...e)=>console.error(...e)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(e=>this.slashSplit(e));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let r=this.globParts.map((e,t,n)=>{if(this.isWindows&&this.windowsNoMagicRoot){let t=e[0]===``&&e[1]===``&&(e[2]===`?`||!$n.test(e[2]))&&!$n.test(e[3]),n=/^[a-z]:/i.test(e[0]);if(t)return[...e.slice(0,4),...e.slice(4).map(e=>this.parse(e))];if(n)return[e[0],...e.slice(1).map(e=>this.parse(e))]}return e.map(e=>this.parse(e))});if(this.debug(this.pattern,r),this.set=r.filter(e=>e.indexOf(!1)===-1),this.isWindows)for(let e=0;e<this.set.length;e++){let t=this.set[e];t[0]===``&&t[1]===``&&this.globParts[e][2]===`?`&&typeof t[3]==`string`&&/^[a-z]:$/i.test(t[3])&&(t[2]=`?`)}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let t=0;t<e.length;t++)for(let n=0;n<e[t].length;n++)e[t][n]===`**`&&(e[t][n]=`*`);let{optimizationLevel:t=1}=this.options;return t>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):e=t>=1?this.levelOneOptimize(e):this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(e=>{let t=-1;for(;(t=e.indexOf(`**`,t+1))!==-1;){let n=t;for(;e[n+1]===`**`;)n++;n!==t&&e.splice(t,n-t)}return e})}levelOneOptimize(e){return e.map(e=>(e=e.reduce((e,t)=>{let n=e[e.length-1];return t===`**`&&n===`**`?e:t===`..`&&n&&n!==`..`&&n!==`.`&&n!==`**`?(e.pop(),e):(e.push(t),e)},[]),e.length===0?[``]:e))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let t=!1;do{if(t=!1,!this.preserveMultipleSlashes){for(let n=1;n<e.length-1;n++){let r=e[n];n===1&&r===``&&e[0]===``||(r===`.`||r===``)&&(t=!0,e.splice(n,1),n--)}e[0]===`.`&&e.length===2&&(e[1]===`.`||e[1]===``)&&(t=!0,e.pop())}let n=0;for(;(n=e.indexOf(`..`,n+1))!==-1;){let r=e[n-1];r&&r!==`.`&&r!==`..`&&r!==`**`&&(t=!0,e.splice(n-1,2),n-=2)}}while(t);return e.length===0?[``]:e}firstPhasePreProcess(e){let t=!1;do{t=!1;for(let n of e){let r=-1;for(;(r=n.indexOf(`**`,r+1))!==-1;){let i=r;for(;n[i+1]===`**`;)i++;i>r&&n.splice(r+1,i-r);let a=n[r+1],o=n[r+2],s=n[r+3];if(a!==`..`||!o||o===`.`||o===`..`||!s||s===`.`||s===`..`)continue;t=!0,n.splice(r,1);let c=n.slice(0);c[r]=`**`,e.push(c),r--}if(!this.preserveMultipleSlashes){for(let e=1;e<n.length-1;e++){let r=n[e];e===1&&r===``&&n[0]===``||(r===`.`||r===``)&&(t=!0,n.splice(e,1),e--)}n[0]===`.`&&n.length===2&&(n[1]===`.`||n[1]===``)&&(t=!0,n.pop())}let i=0;for(;(i=n.indexOf(`..`,i+1))!==-1;){let e=n[i-1];if(e&&e!==`.`&&e!==`..`&&e!==`**`){t=!0;let e=i===1&&n[i+1]===`**`?[`.`]:[];n.splice(i-1,2,...e),n.length===0&&n.push(``),i-=2}}}}while(t);return e}secondPhasePreProcess(e){for(let t=0;t<e.length-1;t++)for(let n=t+1;n<e.length;n++){let r=this.partsMatch(e[t],e[n],!this.preserveMultipleSlashes);if(r){e[t]=[],e[n]=r;break}}return e.filter(e=>e.length)}partsMatch(e,t,n=!1){let r=0,i=0,a=[],o=``;for(;r<e.length&&i<t.length;)if(e[r]===t[i])a.push(o===`b`?t[i]:e[r]),r++,i++;else if(n&&e[r]===`**`&&t[i]===e[r+1])a.push(e[r]),r++;else if(n&&t[i]===`**`&&e[r]===t[i+1])a.push(t[i]),i++;else if(e[r]===`*`&&t[i]&&(this.options.dot||!t[i].startsWith(`.`))&&t[i]!==`**`){if(o===`b`)return!1;o=`a`,a.push(e[r]),r++,i++}else if(t[i]===`*`&&e[r]&&(this.options.dot||!e[r].startsWith(`.`))&&e[r]!==`**`){if(o===`a`)return!1;o=`b`,a.push(t[i]),r++,i++}else return!1;return e.length===t.length&&a}parseNegate(){if(this.nonegate)return;let e=this.pattern,t=!1,n=0;for(let r=0;r<e.length&&e.charAt(r)===`!`;r++)t=!t,n++;n&&(this.pattern=e.slice(n)),this.negate=t}matchOne(e,t,n=!1){let r=0,i=0;if(this.isWindows){let n=typeof e[0]==`string`&&/^[a-z]:$/i.test(e[0]),a=!n&&e[0]===``&&e[1]===``&&e[2]===`?`&&/^[a-z]:$/i.test(e[3]),o=typeof t[0]==`string`&&/^[a-z]:$/i.test(t[0]),s=!o&&t[0]===``&&t[1]===``&&t[2]===`?`&&typeof t[3]==`string`&&/^[a-z]:$/i.test(t[3]),c=a?3:n?0:void 0,l=s?3:o?0:void 0;if(typeof c==`number`&&typeof l==`number`){let[n,a]=[e[c],t[l]];n.toLowerCase()===a.toLowerCase()&&(t[l]=n,i=l,r=c)}}let{optimizationLevel:a=1}=this.options;return a>=2&&(e=this.levelTwoFileOptimize(e)),t.includes(Xn)?this.#e(e,t,n,r,i):this.#n(e,t,n,r,i)}#e(e,t,n,r,i){let a=t.indexOf(Xn,i),o=t.lastIndexOf(Xn),[s,c,l]=n?[t.slice(i,a),t.slice(a+1),[]]:[t.slice(i,a),t.slice(a+1,o),t.slice(o+1)];if(s.length){let t=e.slice(r,r+s.length);if(!this.#n(t,s,n,0,0))return!1;r+=s.length,i+=s.length}let u=0;if(l.length){if(l.length+r>e.length)return!1;let t=e.length-l.length;if(this.#n(e,l,n,t,0))u=l.length;else{if(e[e.length-1]!==``||r+l.length===e.length||(t--,!this.#n(e,l,n,t,0)))return!1;u=l.length+1}}if(!c.length){let t=!!u;for(let n=r;n<e.length-u;n++){let r=String(e[n]);if(t=!0,r===`.`||r===`..`||!this.options.dot&&r.startsWith(`.`))return!1}return n||t}let d=[[[],0]],f=d[0],p=0,m=[0];for(let e of c)e===Xn?(m.push(p),f=[[],0],d.push(f)):(f[0].push(e),p++);let h=d.length-1,g=e.length-u;for(let e of d)e[1]=g-(m[h--]+e[0].length);return!!this.#t(e,d,r,0,n,0,!!u)}#t(e,t,n,r,i,a,o){let s=t[r];if(!s){for(let t=n;t<e.length;t++){o=!0;let n=e[t];if(n===`.`||n===`..`||!this.options.dot&&n.startsWith(`.`))return!1}return o}let[c,l]=s;for(;n<=l;){if(this.#n(e.slice(0,n+c.length),c,i,n,0)&&a<this.maxGlobstarRecursion){let s=this.#t(e,t,n+c.length,r+1,i,a+1,o);if(s!==!1)return s}let s=e[n];if(s===`.`||s===`..`||!this.options.dot&&s.startsWith(`.`))return!1;n++}return i||null}#n(e,t,n,r,i){let a,o,s,c;for(a=r,o=i,c=e.length,s=t.length;a<c&&o<s;a++,o++){this.debug(`matchOne loop`);let n=t[o],r=e[a];if(this.debug(t,n,r),n===!1||n===Xn)return!1;let i;if(typeof n==`string`?(i=r===n,this.debug(`string match`,n,r,i)):(i=n.test(r),this.debug(`pattern match`,n,r,i)),!i)return!1}if(a===c&&o===s)return!0;if(a===c)return n;if(o===s)return a===c-1&&e[a]===``;throw Error(`wtf?`)}braceExpand(){return Qn(this.pattern,this.options)}parse(e){en(e);let t=this.options;if(e===`**`)return Xn;if(e===``)return``;let n,r=null;(n=e.match(Rn))?r=t.dot?Bn:zn:(n=e.match(On))?r=(t.nocase?t.dot?Mn:jn:t.dot?An:kn)(n[1]):(n=e.match(Vn))?r=(t.nocase?t.dot?Un:Hn:t.dot?Wn:Gn)(n):(n=e.match(Nn))?r=t.dot?Fn:Pn:(n=e.match(In))&&(r=Ln);let i=Tn.fromGlob(e,this.options).toMMPattern();return r&&typeof i==`object`&&Reflect.defineProperty(i,`test`,{value:r}),i}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let t=this.options,n=t.noglobstar?`[^/]*?`:t.dot?`(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?`:`(?:(?!(?:\\/|^)\\.).)*?`,r=new Set(t.nocase?[`i`]:[]),i=e.map(e=>{let t=e.map(e=>{if(e instanceof RegExp)for(let t of e.flags.split(``))r.add(t);return typeof e==`string`?er(e):e===Xn?Xn:e._src});t.forEach((e,r)=>{let i=t[r+1],a=t[r-1];e!==Xn||a===Xn||(a===void 0?i!==void 0&&i!==Xn?t[r+1]=`(?:\\/|`+n+`\\/)?`+i:t[r]=n:i===void 0?t[r-1]=a+`(?:\\/|\\/`+n+`)?`:i!==Xn&&(t[r-1]=a+`(?:\\/|\\/`+n+`\\/)`+i,t[r+1]=Xn))});let i=t.filter(e=>e!==Xn);if(this.partial&&i.length>=1){let e=[];for(let t=1;t<=i.length;t++)e.push(i.slice(0,t).join(`/`));return`(?:`+e.join(`|`)+`)`}return i.join(`/`)}).join(`|`),[a,o]=e.length>1?[`(?:`,`)`]:[``,``];i=`^`+a+i+o+`$`,this.partial&&(i=`^(?:\\/|`+a+i.slice(1,-1)+o+`)$`),this.negate&&(i=`^(?!`+i+`).+$`);try{this.regexp=new RegExp(i,[...r].join(``))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split(`/`):this.isWindows&&/^\/\/[^\/]+/.test(e)?[``,...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.debug(`match`,e,this.pattern),this.comment)return!1;if(this.empty)return e===``;if(e===`/`&&t)return!0;let n=this.options;this.isWindows&&(e=e.split(`\\`).join(`/`));let r=this.slashSplit(e);this.debug(this.pattern,`split`,r);let i=this.set;this.debug(this.pattern,`set`,i);let a=r[r.length-1];if(!a)for(let e=r.length-2;!a&&e>=0;e--)a=r[e];for(let e=0;e<i.length;e++){let o=i[e],s=r;if(n.matchBase&&o.length===1&&(s=[a]),this.matchOne(s,o,t))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(e){return Dn.defaults(e).Minimatch}};Dn.AST=Tn,Dn.Minimatch=tr,Dn.escape=En,Dn.unescape=sn;const nr={};function rr(){throw Error(`gunzipSync is not available in the browser`)}function ir(){throw Error(`gzipSync is not available in the browser`)}var ar=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r){setTimeout(function(){r(e)},0);return}else return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h){d[r]=void 0;continue}if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}};new class extends ar{};function or(e,t){let n;for(n=0;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function sr(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function cr(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function lr(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function ur(e,t){return cr(e,t,``)}function dr(e,t){return lr(e,t,``)}function fr(e,t){return t.slice(0,pr(e,t))}function pr(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function mr(e){let t;for(t=e.length-1;t>=0&&e[t].match(/\s/);t--);return e.substring(t+1)}function hr(e){let t=e.match(/^\s*/);return t?t[0]:``}const gr=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,_r=RegExp(`[${gr}]+|\\s+|[^${gr}]`,`ug`);new class extends ar{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=[];for(let t of Array.from(r.segment(e))){let e=t.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}}else n=e.match(_r)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&vr(n,i,r,e),n=e,r=null,i=null)}),(r||i)&&vr(n,i,r,null),e}};function vr(e,t,n,r){if(t&&n){let i=hr(t.value),a=mr(t.value),o=hr(n.value),s=mr(n.value);if(e){let r=or(i,o);e.value=lr(e.value,o,r),t.value=ur(t.value,r),n.value=ur(n.value,r)}if(r){let e=sr(a,s);r.value=cr(r.value,s,e),t.value=dr(t.value,e),n.value=dr(n.value,e)}}else if(n){if(e){let e=hr(n.value);n.value=n.value.substring(e.length)}if(r){let e=hr(r.value);r.value=r.value.substring(e.length)}}else if(e&&r){let n=hr(r.value),i=hr(t.value),a=mr(t.value),o=or(n,i);t.value=ur(t.value,o);let s=sr(ur(n,o),a);t.value=dr(t.value,s),r.value=cr(r.value,n,s),e.value=lr(e.value,n,n.slice(0,n.length-s.length))}else if(r){let e=hr(r.value),n=fr(mr(t.value),e);t.value=dr(t.value,n)}else if(e){let n=fr(mr(e.value),hr(t.value));t.value=ur(t.value,n)}}new class extends ar{tokenize(e){let t=RegExp(`(\\r?\\n)|[${gr}]+|[^\\S\\n\\r]+|[^${gr}]`,`ug`);return e.match(t)||[]}};const yr=new class extends ar{constructor(){super(...arguments),this.tokenize=xr}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
|
|
880
880
|
`))&&(e=e.trim()),(!n.newlineIsToken||!t.includes(`
|
|
881
881
|
`))&&(t=t.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(e.endsWith(`
|
|
882
882
|
`)&&(e=e.slice(0,-1)),t.endsWith(`
|
|
@@ -2995,7 +2995,7 @@ Options:
|
|
|
2995
2995
|
`,exitCode:1};if(!e.onMediaPreview)return{stdout:``,stderr:`imgcat: terminal preview is unavailable
|
|
2996
2996
|
`,exitCode:1};let r=[];for(let e of t){let t=n.fs.resolvePath(n.cwd,e);if(!(await n.fs.stat(t)).isFile)return{stdout:``,stderr:`imgcat: not a file: ${e}\n`,exitCode:1};let i=j(t);if(!xe(i))return{stdout:``,stderr:`imgcat: unsupported media type: ${e}\n`,exitCode:1};let a=await n.fs.readFileBuffer(t),o=new Uint8Array(a.byteLength);o.set(a),r.push({path:t,mimeType:i,bytes:o})}try{return await e.onMediaPreview(r),{stdout:``,stderr:``,exitCode:0}}catch(e){return{stdout:``,stderr:`imgcat: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}})}var mJ=n({Gate:()=>hJ,ProcessManager:()=>yJ}),hJ=class{paused=!1;resumePromise=null;resumeResolve=null;released=!1;pause(){this.released||this.paused||(this.paused=!0,this.resumePromise=new Promise(e=>{this.resumeResolve=e}))}resume(){if(!this.paused)return;this.paused=!1;let e=this.resumeResolve;this.resumePromise=null,this.resumeResolve=null,e?.()}wait(){return!this.paused||this.released?Promise.resolve():this.resumePromise}release(){if(this.released)return;this.released=!0,this.paused=!1;let e=this.resumeResolve;this.resumePromise=null,this.resumeResolve=null,e?.()}isPaused(){return this.paused}};const gJ=1024,_J=4294967295,vJ={SIGINT:130,SIGTERM:143,SIGKILL:137,SIGSTOP:147,SIGCONT:146};var yJ=class{processes=new Map;nextPid=gJ;listeners={spawn:new Set,exit:new Set};signalListeners=new Set;spawn(e){let t=this.allocatePid(),n=e.adoptAbort??new AbortController,r={pid:t,ppid:e.ppid??1,kind:e.kind,argv:e.argv.slice(),cwd:e.cwd??`/`,env:{...e.env??{}},owner:{...e.owner},abort:n,gate:new hJ,startedAt:Date.now(),status:`running`,exitCode:null,terminatedBy:null,finishedAt:null};return this.processes.set(t,r),this.fire(`spawn`,r),r}exit(e,t){let n=this.processes.get(e);n&&(n.status===`exited`||n.status===`killed`||(n.finishedAt=Date.now(),t===null?n.terminatedBy?(n.exitCode=vJ[n.terminatedBy],n.status=`killed`):(n.exitCode=0,n.status=`exited`):(n.exitCode=t,n.status=n.terminatedBy?`killed`:`exited`),n.gate.release(),this.fire(`exit`,n)))}signal(e,t){let n=this.processes.get(e);return!n||n.status===`exited`||n.status===`killed`?!1:t===`SIGSTOP`?(n.gate.pause(),this.fireSignal(n,t),!0):t===`SIGCONT`?(n.gate.resume(),this.fireSignal(n,t),!0):(t===`SIGKILL`?n.terminatedBy=`SIGKILL`:n.terminatedBy===null&&(n.terminatedBy=t),n.abort.signal.aborted||n.abort.abort(),n.gate.release(),this.fireSignal(n,t),!0)}list(){return Array.from(this.processes.values())}get(e){return this.processes.get(e)??null}wait(e){let t=this.processes.get(e);return t?t.status===`exited`||t.status===`killed`?Promise.resolve(t):new Promise(t=>{let n=r=>{r.pid===e&&(this.listeners.exit.delete(n),t(r))};this.listeners.exit.add(n)}):Promise.reject(Error(`pm: no such process: ${e}`))}on(e,t){return this.listeners[e].add(t),()=>{this.listeners[e].delete(t)}}onSignal(e){return this.signalListeners.add(e),()=>{this.signalListeners.delete(e)}}allocatePid(){let e=this.nextPid,t=this.processes.size+1,n=e,r=0;for(;r<=t;){if(!this.processes.has(n))return this.nextPid=n+1>_J?gJ:n+1,n;if(n=n+1>_J?gJ:n+1,r++,n===e)throw Error(`pm: pid space exhausted`)}throw Error(`pm: pid allocation gave up after ${r} probes (table size=${this.processes.size}); the process table is likely corrupt`)}fire(e,t){let n=Array.from(this.listeners[e]);for(let e of n)try{e(t)}catch(e){console.warn(`[pm] listener error`,e)}}fireSignal(e,t){let n=Array.from(this.signalListeners);for(let r of n)try{r(e,t)}catch(e){console.warn(`[pm] signal listener error`,e)}}};function bJ(e){return async function(t,n){let r=t instanceof Request?t:null,i=xJ(t),a=(n?.method??r?.method??`GET`).toUpperCase(),o=CJ(r?.headers,n?.headers),s,c;if(n&&`body`in n&&n.body!==void 0)s=TJ(n.body,a),c=n.body;else if(r&&a!==`GET`&&a!==`HEAD`){let e=await r.arrayBuffer();s=e.byteLength===0?void 0:new TextDecoder(`utf-8`).decode(new Uint8Array(e)),c=void 0}else s=void 0,c=void 0;c instanceof URLSearchParams&&o&&!wJ(o,`content-type`)&&(o[`Content-Type`]=`application/x-www-form-urlencoded;charset=UTF-8`);let l=await e(i,{method:a,headers:o,body:s}),u=new Headers;for(let[e,t]of Object.entries(l.headers))try{u.set(e,t)}catch{}let d=l.status===204||l.status===205||l.status===304||!l.body||l.body.byteLength===0?null:l.body,f=new Response(d,{status:l.status,statusText:l.statusText,headers:u});try{Object.defineProperty(f,`url`,{value:l.url||i,writable:!1,configurable:!0,enumerable:!1})}catch{}return f}}function xJ(e){return typeof e==`string`?e:e instanceof URL?e.toString():e.url}function SJ(e){if(e){if(e instanceof Headers){let t={};return e.forEach((e,n)=>{t[n]=e}),t}if(Array.isArray(e)){let t={};for(let[n,r]of e)t[n]=r;return t}return{...e}}}function CJ(e,t){let n={};e&&e.forEach((e,t)=>{n[t]=e});let r=SJ(t);if(r)for(let[e,t]of Object.entries(r))n[e]=t;return n}function wJ(e,t){let n=t.toLowerCase();for(let t of Object.keys(e))if(t.toLowerCase()===n)return!0;return!1}function TJ(e,t){if(e!=null&&!(t===`GET`||t===`HEAD`)){if(typeof e==`string`)return e;if(e instanceof URLSearchParams)return e.toString();if(e instanceof Uint8Array)return new TextDecoder(`utf-8`).decode(e);if(e instanceof ArrayBuffer)return new TextDecoder(`utf-8`).decode(new Uint8Array(e));if(ArrayBuffer.isView(e)){let t=e;return new TextDecoder(`utf-8`).decode(new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}throw typeof Blob<`u`&&e instanceof Blob?Error(`node fetch shim: Blob request bodies are not supported (use a string, Uint8Array, or URLSearchParams)`):typeof FormData<`u`&&e instanceof FormData?Error(`node fetch shim: FormData request bodies are not supported (post raw application/x-www-form-urlencoded with URLSearchParams instead)`):typeof ReadableStream<`u`&&e instanceof ReadableStream?Error(`node fetch shim: ReadableStream request bodies are not supported (collect into a Uint8Array or string before calling fetch)`):Error(`node fetch shim: unsupported request body type (${Object.prototype.toString.call(e)}); use a string, Uint8Array, ArrayBuffer, or URLSearchParams`)}}function EJ(e,t){let n=n=>{if(n.data?.type!==`realm-rpc-req`)return;let r=n.data;DJ(e,r,t)};e.addEventListener(`message`,n),e.start?.();let r=!1;return{dispose:()=>{r||(r=!0,e.removeEventListener(`message`,n))}}}async function DJ(e,t,n){try{let r=await OJ(t,n),i={type:`realm-rpc-res`,id:t.id,result:r},a=NJ(r);e.postMessage(i,a)}catch(n){let r=n instanceof Error?n.message:String(n),i={type:`realm-rpc-res`,id:t.id,error:r};e.postMessage(i)}}async function OJ(e,t){switch(e.channel){case`vfs`:return kJ(e.op,e.args,t);case`exec`:return jJ(e.op,e.args,t);case`fetch`:return MJ(e.op,e.args,t);default:throw Error(`realm-host: unknown channel '${e.channel}'`)}}async function kJ(e,t,n){let r=typeof t[0]==`string`?t[0]:null,i=r===null?null:n.fs.resolvePath(n.cwd,r);switch(e){case`readFile`:return n.fs.readFile(i);case`readFileBinary`:return n.fs.readFileBuffer(i);case`writeFile`:return await n.fs.writeFile(i,t[1]),!0;case`writeFileBinary`:return await n.fs.writeFile(i,t[1]),!0;case`readDir`:return n.fs.readdir(i);case`exists`:return n.fs.exists(i);case`stat`:{let e=await n.fs.stat(i);return{isDirectory:e.isDirectory,isFile:e.isFile,size:e.size}}case`mkdir`:return await n.fs.mkdir(i,{recursive:!0}),!0;case`rm`:return await n.fs.rm(i,{recursive:!0}),!0;case`resolvePath`:return n.fs.resolvePath(n.cwd,t[0]);case`walkTree`:{let e=t[1]??{},r=typeof e.maxFileBytes==`number`?e.maxFileBytes:1/0,a=[];return await AJ(n,i,r,a),a}case`writeBatch`:{let e=t[0]??{},r=[],i=[];for(let t of e.mkdirs??[]){let e=n.fs.resolvePath(n.cwd,t);try{await n.fs.mkdir(e,{recursive:!0})}catch(e){let n=e instanceof Error?e.message:String(e);/EEXIST/i.test(n)||r.push({path:t,error:n})}}for(let t of e.files??[]){let e=n.fs.resolvePath(n.cwd,t.path);try{await n.fs.writeFile(e,t.content)}catch(e){i.push({path:t.path,error:e instanceof Error?e.message:String(e)})}}return{ok:!0,failedMkdirs:r,failedFiles:i}}default:throw Error(`realm-host: unknown vfs op '${e}'`)}}async function AJ(e,t,n,r){let i;try{i=await e.fs.readdir(t)}catch{return}for(let a of i){let i=t===`/`?`/${a}`:`${t}/${a}`,o;try{o=await e.fs.stat(i)}catch{continue}if(o.isDirectory)r.push({path:i,isDir:!0}),await AJ(e,i,n,r);else if(o.isFile){if(o.size<=n)try{let t=await e.fs.readFileBuffer(i);r.push({path:i,isDir:!1,size:o.size,content:t});continue}catch{}r.push({path:i,isDir:!1,size:o.size})}}}async function jJ(e,t,n){if(e!==`run`)throw Error(`realm-host: unknown exec op '${e}'`);if(!n.exec)throw Error(`exec is not available in this runtime`);let r=t[0],i=await n.exec(r,{cwd:n.cwd});return{stdout:i.stdout,stderr:i.stderr,exitCode:i.exitCode}}async function MJ(e,t,n){if(e!==`request`)throw Error(`realm-host: unknown fetch op '${e}'`);let[r,i]=t,a=await(n.fetch?bJ(n.fetch):globalThis.fetch.bind(globalThis))(r,i),o={};a.headers.forEach((e,t)=>{o[t]=e});let s=new Uint8Array(await a.arrayBuffer());return{status:a.status,statusText:a.statusText,headers:o,body:s,url:a.url}}function NJ(e){return e instanceof Uint8Array?[e.buffer]:e&&typeof e==`object`&&`body`in e&&e.body instanceof Uint8Array?[e.body.buffer]:[]}async function PJ(e){let t=e.procKind??`jsh`,n=e.pm.spawn({kind:t,argv:e.argv,cwd:e.cwd,env:e.env,owner:e.owner,ppid:e.ppid}),r;try{r=await e.realmFactory({kind:e.kind,ctx:e.ctx})}catch(t){let r=t instanceof Error?t.message:String(t);return e.pm.exit(n.pid,1),{stdout:``,stderr:`realm-runner: ${r}\n`,exitCode:1}}let i=EJ(r.controlPort,e.ctx);return new Promise(t=>{let a=!1,o=null,s=null,c=null,l=()=>{s&&r.controlPort.removeEventListener(`message`,s),c&&r.removeEventListener&&r.removeEventListener(`error`,c),o?.(),i.dispose()},u=(i,o)=>{if(!a){a=!0,l();try{r.terminate()}catch{}e.pm.exit(n.pid,o),t(i)}};s=e=>{let t=e.data;if(t?.type===`realm-done`){let t=e.data;u({stdout:t.stdout,stderr:t.stderr,exitCode:t.exitCode},t.exitCode)}else if(t?.type===`realm-error`){let t=e.data;u({stdout:``,stderr:t.message+`
|
|
2997
2997
|
`,exitCode:1},1)}},c=e=>{u({stdout:``,stderr:(e.message??`realm error`)+`
|
|
2998
|
-
`,exitCode:1},1)},o=e.pm.onSignal((e,t)=>{e.pid===n.pid&&t===`SIGKILL`&&u({stdout:``,stderr:``,exitCode:137},137)}),r.controlPort.addEventListener(`message`,s),r.addEventListener&&r.addEventListener(`error`,c);let d={type:`realm-init`,kind:e.kind,code:e.code,argv:e.realmArgv??e.argv,env:e.env,cwd:e.cwd,filename:e.filename,stdin:e.stdin,pyodideIndexURL:e.pyodideIndexURL,pyodideSyncDirs:e.pyodideSyncDirs};r.controlPort.postMessage(d)})}async function FJ(e,t,n={}){if(typeof document>`u`)throw Error(`createIframeRealm: document is not available in this runtime`);let r=n.sandboxUrl??IJ();if(!r)throw Error(`createIframeRealm: sandbox URL not available (extension API missing)`);let i=n.container??document.body,a=n.messageChannelCtor??globalThis.MessageChannel;if(typeof a!=`function`)throw Error(`createIframeRealm: MessageChannel is not available`);let o=new a,s=document.createElement(`iframe`);s.style.display=`none`,s.dataset.realm=`js`,s.src=r,i.appendChild(s),n.onIframeCreated?.(s),await new Promise((e,t)=>{let n=!1,r=r=>{n||(n=!0,window.removeEventListener(`message`,i),r?t(r):e())},i=e=>{e.source===s.contentWindow&&e.data?.type===`realm-iframe-ready`&&(s.contentWindow.postMessage({type:`realm-port-init`},`*`,[o.port2]),r())};window.addEventListener(`message`,i),s.addEventListener(`error`,()=>r(Error(`realm-iframe: iframe failed to load`)),{once:!0})});let c=!1;return{controlPort:o.port1,terminate(){if(!c){c=!0;try{s.remove()}catch{}try{o.port1.close()}catch{}}}}}function IJ(){let e=globalThis.chrome;return e?.runtime?.getURL?e.runtime.getURL(`sandbox.html`):null}var LJ=class{nextId=1;pending=new Map;handler;disposed=!1;constructor(e){this.port=e,this.handler=e=>{if(e.data?.type!==`realm-rpc-res`)return;let t=e.data,n=this.pending.get(t.id);n&&(this.pending.delete(t.id),typeof t.error==`string`?n.reject(Error(t.error)):n.resolve(t.result))},e.addEventListener(`message`,this.handler),e.start?.()}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)})}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()}};const RJ=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`]),zJ={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 BJ(e,t){let n=zJ[t]??``;return Error(`require('${e}'): '${t}' is a Node native module (C++ bindings) — it cannot run in the browser sandbox.${n}`)}function VJ(e,t,n){return new Promise((r,i)=>{let a=setTimeout(()=>{i(Error(`Timed out after ${t/1e3}s loading ${n}`))},t);e.then(e=>{clearTimeout(a),r(e)},e=>{clearTimeout(a),i(e)})})}const HJ=new Set([`http`,`https`,`net`,`tls`,`dgram`,`dns`,`cluster`,`worker_threads`,`child_process`,`crypto`,`os`,`stream`,`zlib`,`vm`,`v8`,`perf_hooks`,`readline`,`repl`,`tty`,`inspector`]),UJ=new Set([`fs`,`process`,`buffer`]);var WJ=class extends Error{constructor(e){super(`Process exited with code ${e}`),this.code=e,this.name=`NodeExitError`}};function GJ(e){let t=/\brequire\s*\(\s*(['"`])([^'"`\s]+)\1\s*\)/g,n=new Set,r;for(;(r=t.exec(e))!==null;)n.add(r[2]);return[...n]}function KJ(e){if(typeof e==`string`)return e;if(e==null)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}async function qJ(e,t,n=YJ){let r=[],i=[],a=e=>{r.push(typeof e==`string`?e:String(e))},o=e=>{i.push(typeof e==`string`?e:String(e))},s={log:(...e)=>a(`${e.map(KJ).join(` `)}\n`),info:(...e)=>a(`${e.map(KJ).join(` `)}\n`),warn:(...e)=>o(`${e.map(KJ).join(` `)}\n`),error:(...e)=>o(`${e.map(KJ).join(` `)}\n`)},c={argv:e.argv,env:e.env,cwd:()=>e.cwd,exit:e=>{throw new WJ(Number.isFinite(e)?Number(e):0)},stdout:{write:a},stderr:{write:o}},
|
|
2998
|
+
`,exitCode:1},1)},o=e.pm.onSignal((e,t)=>{e.pid===n.pid&&t===`SIGKILL`&&u({stdout:``,stderr:``,exitCode:137},137)}),r.controlPort.addEventListener(`message`,s),r.addEventListener&&r.addEventListener(`error`,c);let d={type:`realm-init`,kind:e.kind,code:e.code,argv:e.realmArgv??e.argv,env:e.env,cwd:e.cwd,filename:e.filename,stdin:e.stdin,pyodideIndexURL:e.pyodideIndexURL,pyodideSyncDirs:e.pyodideSyncDirs};r.controlPort.postMessage(d)})}async function FJ(e,t,n={}){if(typeof document>`u`)throw Error(`createIframeRealm: document is not available in this runtime`);let r=n.sandboxUrl??IJ();if(!r)throw Error(`createIframeRealm: sandbox URL not available (extension API missing)`);let i=n.container??document.body,a=n.messageChannelCtor??globalThis.MessageChannel;if(typeof a!=`function`)throw Error(`createIframeRealm: MessageChannel is not available`);let o=new a,s=document.createElement(`iframe`);s.style.display=`none`,s.dataset.realm=`js`,s.src=r,i.appendChild(s),n.onIframeCreated?.(s),await new Promise((e,t)=>{let n=!1,r=r=>{n||(n=!0,window.removeEventListener(`message`,i),r?t(r):e())},i=e=>{e.source===s.contentWindow&&e.data?.type===`realm-iframe-ready`&&(s.contentWindow.postMessage({type:`realm-port-init`},`*`,[o.port2]),r())};window.addEventListener(`message`,i),s.addEventListener(`error`,()=>r(Error(`realm-iframe: iframe failed to load`)),{once:!0})});let c=!1;return{controlPort:o.port1,terminate(){if(!c){c=!0;try{s.remove()}catch{}try{o.port1.close()}catch{}}}}}function IJ(){let e=globalThis.chrome;return e?.runtime?.getURL?e.runtime.getURL(`sandbox.html`):null}var LJ=class{nextId=1;pending=new Map;handler;disposed=!1;constructor(e){this.port=e,this.handler=e=>{if(e.data?.type!==`realm-rpc-res`)return;let t=e.data,n=this.pending.get(t.id);n&&(this.pending.delete(t.id),typeof t.error==`string`?n.reject(Error(t.error)):n.resolve(t.result))},e.addEventListener(`message`,this.handler),e.start?.()}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)})}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()}};const RJ=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`]),zJ={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 BJ(e,t){let n=zJ[t]??``;return Error(`require('${e}'): '${t}' is a Node native module (C++ bindings) — it cannot run in the browser sandbox.${n}`)}function VJ(e,t,n){return new Promise((r,i)=>{let a=setTimeout(()=>{i(Error(`Timed out after ${t/1e3}s loading ${n}`))},t);e.then(e=>{clearTimeout(a),r(e)},e=>{clearTimeout(a),i(e)})})}const HJ=new Set([`http`,`https`,`net`,`tls`,`dgram`,`dns`,`cluster`,`worker_threads`,`child_process`,`crypto`,`os`,`stream`,`zlib`,`vm`,`v8`,`perf_hooks`,`readline`,`repl`,`tty`,`inspector`]),UJ=new Set([`fs`,`process`,`buffer`]);var WJ=class extends Error{constructor(e){super(`Process exited with code ${e}`),this.code=e,this.name=`NodeExitError`}};function GJ(e){let t=/\brequire\s*\(\s*(['"`])([^'"`\s]+)\1\s*\)/g,n=new Set,r;for(;(r=t.exec(e))!==null;)n.add(r[2]);return[...n]}function KJ(e){if(typeof e==`string`)return e;if(e==null)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}async function qJ(e,t,n=YJ){let r=[],i=[],a=e=>{r.push(typeof e==`string`?e:String(e))},o=e=>{i.push(typeof e==`string`?e:String(e))},s={log:(...e)=>a(`${e.map(KJ).join(` `)}\n`),info:(...e)=>a(`${e.map(KJ).join(` `)}\n`),warn:(...e)=>o(`${e.map(KJ).join(` `)}\n`),error:(...e)=>o(`${e.map(KJ).join(` `)}\n`)},c=e.stdin??``,l=!1,u={isTTY:!1,read(){return l?null:(l=!0,c)},toString(){return c},[Symbol.asyncIterator](){return{async next(){return l?{value:void 0,done:!0}:(l=!0,{value:c,done:!1})}}}},d={argv:e.argv,env:e.env,cwd:()=>e.cwd,exit:e=>{throw new WJ(Number.isFinite(e)?Number(e):0)},stdin:u,stdout:{write:a},stderr:{write:o}},f=new LJ(t),p={readFile:e=>f.call(`vfs`,`readFile`,[e]),readFileBinary:e=>f.call(`vfs`,`readFileBinary`,[e]),writeFile:(e,t)=>f.call(`vfs`,`writeFile`,[e,t]),writeFileBinary:(e,t)=>f.call(`vfs`,`writeFileBinary`,[e,t]),readDir:e=>f.call(`vfs`,`readDir`,[e]),exists:e=>f.call(`vfs`,`exists`,[e]),stat:e=>f.call(`vfs`,`stat`,[e]),mkdir:e=>f.call(`vfs`,`mkdir`,[e]),rm:e=>f.call(`vfs`,`rm`,[e]),fetchToFile:async(e,t)=>{let n=await h(e);if(!n.ok)throw Error(`fetch ${n.status} ${n.statusText}`);let r=new Uint8Array(await n.arrayBuffer());return await f.call(`vfs`,`writeFileBinary`,[t,r]),r.byteLength}},m=e=>f.call(`exec`,`run`,[e]);async function h(e,t){let n=e instanceof Request?e.url:e instanceof URL?e.toString():String(e),r=await f.call(`fetch`,`request`,[n,JJ(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 g=GJ(e.code).map(e=>e.startsWith(`node:`)?e.slice(5):e).filter(e=>!UJ.has(e)&&!HJ.has(e)),_=g.filter(e=>RJ.has(e)),v=g.filter(e=>!RJ.has(e));for(let e of _)o(`Warning: ${BJ(e,e).message}\n`);let y=Object.create(null);if(v.length>0){let e=await Promise.allSettled(v.map(async e=>{let t=await VJ(n(e),15e3,`require('${e}')`);y[e]=t&&`default`in t?t.default:t}));for(let t=0;t<e.length;t++){let n=e[t];if(n.status===`rejected`){let e=n.reason instanceof Error?n.reason.message:String(n.reason);o(`Warning: failed to pre-load require('${v[t]}'): ${e}\n`)}}}let b=e=>{let t=e.startsWith(`node:`)?e.slice(5):e;if(t===`fs`)return p;if(t===`process`)return d;if(t===`buffer`)return{Buffer:globalThis.Buffer};if(t===`path`){if(`path`in y)return y.path;if(e in y)return y[e];throw Error(`require('${e}'): path module not pre-loaded. Add require('path') as a static import.`)}if(RJ.has(t))throw BJ(e,t);if(HJ.has(t))throw Error(`require('${e}'): Node built-in '${t}' is not available in the browser environment.${{http:` Use fetch() instead.`,https:` Use fetch() instead.`,child_process:` Use exec() which is available as a shell bridge.`,crypto:` Use globalThis.crypto (Web Crypto API) instead.`}[t]||``}`);if(e in y)return y[e];if(t in y)return y[t];throw Error(`require('${e}'): module not pre-loaded. Use a string literal so it can be pre-fetched, or use \`await import('https://esm.sh/${e}')\` directly.`)},x={exports:{},filename:e.filename},S=0;try{let t=Object.getPrototypeOf(async function(){}).constructor;await new t(`fs`,`process`,`console`,`require`,`module`,`exports`,`exec`,`fetch`,`"use strict";\n${e.code}`)(p,d,s,b,x,x.exports,m,h)}catch(e){e instanceof WJ?S=e.code:(o(`${e instanceof Error?e.stack??e.message:String(e)}\n`),S=1)}f.dispose();let C={type:`realm-done`,stdout:r.join(``),stderr:i.join(``),exitCode:S};t.postMessage(C)}function JJ(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}}async function YJ(e){return await import(`https://esm.sh/`+e)}const XJ=`https://cdn.jsdelivr.net/pyodide/v${M(`pyodide`,`0.29.3`)}/full/`;async function ZJ(e,t,n=()=>import(`./pyodide-DM3gAwss.js`)){let r=[],i=[],a=new LJ(t),o;try{o=await(await n()).loadPyodide({indexURL:e.pyodideIndexURL,fullStdLib:!1})}catch(e){a.dispose();let n={type:`realm-error`,message:`loadPyodide: ${e instanceof Error?e.message:String(e)}`};t.postMessage(n);return}let s=e.pyodideSyncDirs??[e.cwd,`/tmp`],c=e=>{i.push(`Warning: ${e}\n`)},l={files:new Map,dirs:new Set};try{l=await $J(a,o,s,c)}catch(e){c(`VFS→Pyodide sync failed: ${e instanceof Error?e.message:String(e)}`)}try{o.FS.chdir(e.cwd)}catch{}o.setStdout({batched:e=>r.push(e+`
|
|
2999
2999
|
`)}),o.setStderr({batched:e=>i.push(e+`
|
|
3000
3000
|
`)});let u=!1;o.setStdin({stdin:()=>u||!e.stdin?null:(u=!0,e.stdin)}),o.globals.set(`__slicc_code`,e.code),o.globals.set(`__slicc_filename`,e.filename),o.globals.set(`__slicc_argv`,e.argv);let d;try{await o.runPythonAsync(`
|
|
3001
3001
|
import sys
|
|
@@ -3017,10 +3017,10 @@ except SystemExit as exc:
|
|
|
3017
3017
|
except BaseException:
|
|
3018
3018
|
traceback.print_exc()
|
|
3019
3019
|
__slicc_exit_code = 1
|
|
3020
|
-
`);let e=o.globals.get(`__slicc_exit_code`);d=typeof e==`number`?e:Number(e??1)}catch(e){let t=e instanceof Error?e.message:String(e);i.push(`${t}\n`),d=1}try{o.runPython(`del __slicc_code, __slicc_filename, __slicc_argv, __slicc_exit_code`)}catch{}try{await eY(a,o,s,l,c)}catch(e){c(`Pyodide→VFS sync failed: ${e instanceof Error?e.message:String(e)}`)}a.dispose();let f={type:`realm-done`,stdout:r.join(``),stderr:i.join(``),exitCode:d};t.postMessage(f)}const QJ=10*1024*1024;async function $J(e,t,n,r=()=>{}){let i=t.FS,a={files:new Map,dirs:new Set};function o(e){try{i.stat(e)}catch{i.mkdirTree(e)}a.dirs.add(e)}function s(e){let t;try{t=i.stat(e)}catch{return}if(i.isDir(t.mode)){a.dirs.add(e);let t;try{t=i.readdir(e).filter(e=>e!==`.`&&e!==`..`)}catch{return}for(let n of t)s(e===`/`?`/${n}`:`${e}/${n}`)}else i.isFile(t.mode)&&a.files.set(e,t.size)}for(let t of n){o(t),s(t);let n;try{n=await e.call(`vfs`,`walkTree`,[t,{maxFileBytes:QJ}])}catch(e){r(`VFS→Pyodide sync skipped '${t}': ${e instanceof Error?e.message:String(e)}`);continue}for(let e of n)try{if(e.isDir){o(e.path);continue}if(e.content===void 0){e.size<=QJ&&r(`VFS→Pyodide skipped '${e.path}': unreadable from VFS`);continue}let t=e.path.lastIndexOf(`/`);t>0&&o(e.path.slice(0,t)),i.writeFile(e.path,e.content),a.files.set(e.path,e.size)}catch(t){let n=t instanceof Error?t.message:String(t);r(`VFS→Pyodide entry '${e.path}' failed: ${n}`)}}return a}async function eY(e,t,n,r,i=()=>{}){let a=t.FS,o=new Set,s=[];function c(e){let t;try{t=a.readdir(e).filter(e=>e!==`.`&&e!==`..`)}catch{return}for(let n of t){let t=e===`/`?`/${n}`:`${e}/${n}`,l;try{l=a.stat(t)}catch{continue}if(a.isDir(l.mode))r.dirs.has(t)||o.add(t),c(t);else if(a.isFile(l.mode)){let e=r.files.get(t);if(e===void 0||e!==l.size)try{let e=a.readFile(t);s.push({path:t,content:new Uint8Array(e)})}catch(e){i(`Pyodide→VFS read '${t}' failed: ${e instanceof Error?e.message:String(e)}`)}}}}for(let e of n)c(e);if(o.size===0&&s.length===0)return;let l;try{l=await e.call(`vfs`,`writeBatch`,[{mkdirs:[...o],files:s}])}catch(e){i(`Pyodide→VFS writeBatch RPC failed: ${e instanceof Error?e.message:String(e)}`);return}for(let e of l.failedFiles)i(`Pyodide→VFS write '${e.path}' failed: ${e.error}`);for(let e of l.failedMkdirs)i(`Pyodide→VFS mkdir '${e.path}' failed: ${e.error}`)}function tY(){let e=new Set,t=new Set;return{realmSide:{postMessage:e=>{queueMicrotask(()=>{for(let n of[...t])n({data:e})})},addEventListener:(t,n)=>{e.add(n)},removeEventListener:(t,n)=>{e.delete(n)}},hostSide:{postMessage:t=>{queueMicrotask(()=>{for(let n of[...e])n({data:t})})},addEventListener:(e,n)=>{t.add(n)},removeEventListener:(e,n)=>{t.delete(n)}}}}function nY(){return async({kind:e})=>{if(e!==`js`)throw Error(`createInProcessJsRealmFactory: only kind:js is supported`);let{realmSide:t,hostSide:n}=tY(),r=e=>{if(e.data?.type!==`realm-init`)return;t.removeEventListener(`message`,r);let n=e.data;n.kind===`js`&&qJ(n,t,e=>Promise.reject(Error(`in-process realm: require('${e}') is not pre-loaded`))).catch(e=>{let n={type:`realm-error`,message:e instanceof Error?e.message:String(e)};t.postMessage(n)})};return t.addEventListener(`message`,r),{controlPort:n,terminate(){t.removeEventListener(`message`,r)}}}}function rY(){return async({kind:e})=>{if(e!==`py`)throw Error(`createInProcessPyRealmFactory: only kind:py is supported`);let{realmSide:t,hostSide:n}=tY(),r=e=>{if(e.data?.type!==`realm-init`)return;t.removeEventListener(`message`,r);let n=e.data;n.kind===`py`&&ZJ(n,t).catch(e=>{let n={type:`realm-error`,message:e instanceof Error?e.message:String(e)};t.postMessage(n)})};return t.addEventListener(`message`,r),{controlPort:n,terminate(){t.removeEventListener(`message`,r)}}}}const iY=nY(),aY=rY();function oY(){return async({kind:e,ctx:t})=>e===`py`?typeof Worker<`u`?cY():aY({kind:e,ctx:t}):Ne()&&typeof document<`u`?FJ(e,t):typeof Worker<`u`?sY():iY({kind:e,ctx:t})}function sY(){if(typeof Worker>`u`)throw Error(`realm-factory: Worker is not available in this runtime`);return lY(new Worker(new URL(`/assets/js-realm-worker-
|
|
3021
|
-
`,stderr:``,exitCode:0}}function vY(){return{stdout:`${je}\n`,stderr:``,exitCode:0}}function yY(){return wM(`node`,async(e,t)=>{if(e.includes(`--help`)||e.includes(`-h`))return _Y();if(e.includes(`--version`)||e.includes(`-v`))return vY();let n=``,r=`<stdin>`,i=[`node`];if(e.length>0&&(e[0]===`-e`||e[0]===`--eval`)){if(!e[1])return{stdout:``,stderr:`node: option requires an argument -- eval
|
|
3022
|
-
`,exitCode:9};n=e[1],r=`[eval]`,i=[`node`,...e.slice(2)]}else if(e.length>0&&!e[0].startsWith(`-`)){let a=e[0],o=t.fs.resolvePath(t.cwd,a);if(!await t.fs.exists(o))return{stdout:``,stderr:`node: cannot find module '${a}'\n`,exitCode:1};n=await t.fs.readFile(o),r=a,i=[`node`,a,...e.slice(1)]}else if(t.stdin.trim().length>0)n=t.stdin,r=`<stdin>`,i=[`node`];else if(e.length>0)return{stdout:``,stderr:`node: unsupported option '${e[0]}'\n`,exitCode:9};else return{stdout:``,stderr:`node: REPL mode is not supported in this environment; use node -e "code"
|
|
3023
|
-
`,exitCode:9};return fY(n,i,
|
|
3020
|
+
`);let e=o.globals.get(`__slicc_exit_code`);d=typeof e==`number`?e:Number(e??1)}catch(e){let t=e instanceof Error?e.message:String(e);i.push(`${t}\n`),d=1}try{o.runPython(`del __slicc_code, __slicc_filename, __slicc_argv, __slicc_exit_code`)}catch{}try{await eY(a,o,s,l,c)}catch(e){c(`Pyodide→VFS sync failed: ${e instanceof Error?e.message:String(e)}`)}a.dispose();let f={type:`realm-done`,stdout:r.join(``),stderr:i.join(``),exitCode:d};t.postMessage(f)}const QJ=10*1024*1024;async function $J(e,t,n,r=()=>{}){let i=t.FS,a={files:new Map,dirs:new Set};function o(e){try{i.stat(e)}catch{i.mkdirTree(e)}a.dirs.add(e)}function s(e){let t;try{t=i.stat(e)}catch{return}if(i.isDir(t.mode)){a.dirs.add(e);let t;try{t=i.readdir(e).filter(e=>e!==`.`&&e!==`..`)}catch{return}for(let n of t)s(e===`/`?`/${n}`:`${e}/${n}`)}else i.isFile(t.mode)&&a.files.set(e,t.size)}for(let t of n){o(t),s(t);let n;try{n=await e.call(`vfs`,`walkTree`,[t,{maxFileBytes:QJ}])}catch(e){r(`VFS→Pyodide sync skipped '${t}': ${e instanceof Error?e.message:String(e)}`);continue}for(let e of n)try{if(e.isDir){o(e.path);continue}if(e.content===void 0){e.size<=QJ&&r(`VFS→Pyodide skipped '${e.path}': unreadable from VFS`);continue}let t=e.path.lastIndexOf(`/`);t>0&&o(e.path.slice(0,t)),i.writeFile(e.path,e.content),a.files.set(e.path,e.size)}catch(t){let n=t instanceof Error?t.message:String(t);r(`VFS→Pyodide entry '${e.path}' failed: ${n}`)}}return a}async function eY(e,t,n,r,i=()=>{}){let a=t.FS,o=new Set,s=[];function c(e){let t;try{t=a.readdir(e).filter(e=>e!==`.`&&e!==`..`)}catch{return}for(let n of t){let t=e===`/`?`/${n}`:`${e}/${n}`,l;try{l=a.stat(t)}catch{continue}if(a.isDir(l.mode))r.dirs.has(t)||o.add(t),c(t);else if(a.isFile(l.mode)){let e=r.files.get(t);if(e===void 0||e!==l.size)try{let e=a.readFile(t);s.push({path:t,content:new Uint8Array(e)})}catch(e){i(`Pyodide→VFS read '${t}' failed: ${e instanceof Error?e.message:String(e)}`)}}}}for(let e of n)c(e);if(o.size===0&&s.length===0)return;let l;try{l=await e.call(`vfs`,`writeBatch`,[{mkdirs:[...o],files:s}])}catch(e){i(`Pyodide→VFS writeBatch RPC failed: ${e instanceof Error?e.message:String(e)}`);return}for(let e of l.failedFiles)i(`Pyodide→VFS write '${e.path}' failed: ${e.error}`);for(let e of l.failedMkdirs)i(`Pyodide→VFS mkdir '${e.path}' failed: ${e.error}`)}function tY(){let e=new Set,t=new Set;return{realmSide:{postMessage:e=>{queueMicrotask(()=>{for(let n of[...t])n({data:e})})},addEventListener:(t,n)=>{e.add(n)},removeEventListener:(t,n)=>{e.delete(n)}},hostSide:{postMessage:t=>{queueMicrotask(()=>{for(let n of[...e])n({data:t})})},addEventListener:(e,n)=>{t.add(n)},removeEventListener:(e,n)=>{t.delete(n)}}}}function nY(){return async({kind:e})=>{if(e!==`js`)throw Error(`createInProcessJsRealmFactory: only kind:js is supported`);let{realmSide:t,hostSide:n}=tY(),r=e=>{if(e.data?.type!==`realm-init`)return;t.removeEventListener(`message`,r);let n=e.data;n.kind===`js`&&qJ(n,t,e=>Promise.reject(Error(`in-process realm: require('${e}') is not pre-loaded`))).catch(e=>{let n={type:`realm-error`,message:e instanceof Error?e.message:String(e)};t.postMessage(n)})};return t.addEventListener(`message`,r),{controlPort:n,terminate(){t.removeEventListener(`message`,r)}}}}function rY(){return async({kind:e})=>{if(e!==`py`)throw Error(`createInProcessPyRealmFactory: only kind:py is supported`);let{realmSide:t,hostSide:n}=tY(),r=e=>{if(e.data?.type!==`realm-init`)return;t.removeEventListener(`message`,r);let n=e.data;n.kind===`py`&&ZJ(n,t).catch(e=>{let n={type:`realm-error`,message:e instanceof Error?e.message:String(e)};t.postMessage(n)})};return t.addEventListener(`message`,r),{controlPort:n,terminate(){t.removeEventListener(`message`,r)}}}}const iY=nY(),aY=rY();function oY(){return async({kind:e,ctx:t})=>e===`py`?typeof Worker<`u`?cY():aY({kind:e,ctx:t}):Ne()&&typeof document<`u`?FJ(e,t):typeof Worker<`u`?sY():iY({kind:e,ctx:t})}function sY(){if(typeof Worker>`u`)throw Error(`realm-factory: Worker is not available in this runtime`);return lY(new Worker(new URL(`/assets/js-realm-worker-Dh5NKB0f.js`,``+import.meta.url),{type:`module`}))}function cY(){if(typeof Worker>`u`)throw Error(`realm-factory: Worker is not available in this runtime`);return lY(new Worker(new URL(`/assets/py-realm-worker-CiPbLFx2.js`,``+import.meta.url),{type:`module`}))}function lY(e){let t={postMessage:(t,n)=>n?e.postMessage(t,n):e.postMessage(t),addEventListener:(t,n)=>e.addEventListener(t,n),removeEventListener:(t,n)=>e.removeEventListener(t,n)},n=!1;return{controlPort:t,addEventListener:(t,n,r)=>e.addEventListener(t,n,r),removeEventListener:(t,n)=>e.removeEventListener(t,n),terminate(){if(!n){n=!0;try{e.terminate()}catch{}}}}}function uY(){if(Ne()){let e=globalThis.chrome;if(e?.runtime?.getURL)return e.runtime.getURL(`pyodide/`)}return Ee()?decodeURIComponent(De(`pyodide/pyodide.mjs`,`../../../../../node_modules/pyodide/`).pathname):XJ}async function dY(e,t,n,r,i={}){return await n.fs.exists(e)?fY(await n.fs.readFile(e),[`node`,e,...t],n,r,{...i,filename:e}):{stdout:``,stderr:`jsh: cannot find script '${e}'\n`,exitCode:127}}async function fY(e,t,n,r,i={}){let a=i.realmFactory??pY(),o=r?.processManager??gY()??hY(),s=r?.owner??{kind:`system`},c=i.filename??t[1]??`<eval>`;return await PJ({pm:o,realmFactory:a,owner:s,kind:`js`,code:e,argv:t,env:Object.fromEntries(n.env.entries()),cwd:n.cwd,filename:c,stdin:n.stdin,ctx:n,ppid:r?.getParentPid?.()})}function pY(){return typeof Worker<`u`||typeof document<`u`?oY():nY()}let mY=null;function hY(){return mY||=new yJ,mY}function gY(){let e=globalThis.__slicc_pm;return e&&typeof e==`object`&&typeof e.spawn==`function`&&typeof e.onSignal==`function`?e:null}function _Y(){return{stdout:`usage: node -e <code> [args...]
|
|
3021
|
+
`,stderr:``,exitCode:0}}function vY(){return{stdout:`${je}\n`,stderr:``,exitCode:0}}function yY(){return wM(`node`,async(e,t)=>{if(e.includes(`--help`)||e.includes(`-h`))return _Y();if(e.includes(`--version`)||e.includes(`-v`))return vY();let n=``,r=`<stdin>`,i=[`node`],a=t;if(e.length>0&&(e[0]===`-e`||e[0]===`--eval`)){if(!e[1])return{stdout:``,stderr:`node: option requires an argument -- eval
|
|
3022
|
+
`,exitCode:9};n=e[1],r=`[eval]`,i=[`node`,...e.slice(2)]}else if(e.length>0&&!e[0].startsWith(`-`)){let a=e[0],o=t.fs.resolvePath(t.cwd,a);if(!await t.fs.exists(o))return{stdout:``,stderr:`node: cannot find module '${a}'\n`,exitCode:1};n=await t.fs.readFile(o),r=a,i=[`node`,a,...e.slice(1)]}else if(t.stdin.trim().length>0)n=t.stdin,r=`<stdin>`,i=[`node`],a={...t,stdin:``};else if(e.length>0)return{stdout:``,stderr:`node: unsupported option '${e[0]}'\n`,exitCode:9};else return{stdout:``,stderr:`node: REPL mode is not supported in this environment; use node -e "code"
|
|
3023
|
+
`,exitCode:9};return fY(n,i,a,void 0,{filename:r})})}const bY=[`--download`,`-d`,`--view`,`-v`];function xY(){return{stdout:`usage: open [--download|-d] [--view|-v] <url|path> [url|path...]
|
|
3024
3024
|
|
|
3025
3025
|
VFS paths are served in a new browser tab via the preview service worker.
|
|
3026
3026
|
URLs (http/https/etc.) are opened directly in a new tab.
|
|
@@ -3034,7 +3034,7 @@ except BaseException:
|
|
|
3034
3034
|
`,exitCode:1};let n;try{n=await t.fs.stat(i)}catch{return{stdout:``,stderr:`open: no such file: ${e}\n`,exitCode:1}}if(!n.isFile)return{stdout:``,stderr:`open: not a file: ${e}\n`,exitCode:1};let r;try{r=await t.fs.readFileBuffer(i)}catch{return{stdout:``,stderr:`open: failed to read: ${e}\n`,exitCode:1}}let a=new Uint8Array(r.byteLength);a.set(r);let s=new Blob([a.buffer],{type:Ce(i)}),c=URL.createObjectURL(s),l=document.createElement(`a`);l.href=c,l.download=N(i)||`download`,l.style.display=`none`,document.body.appendChild(l),l.click(),document.body.removeChild(l),setTimeout(()=>URL.revokeObjectURL(c),0),u.push(`downloaded ${i}`)}else{if(!c)return{stdout:``,stderr:`open: browser APIs are unavailable in this environment
|
|
3035
3035
|
`,exitCode:1};let e=Pe(i);try{await l(e)}catch(e){return{stdout:``,stderr:`${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}u.push(`opened ${i} → ${e}`)}}return{stdout:u.join(`
|
|
3036
3036
|
`)+`
|
|
3037
|
-
`,stderr:``,exitCode:0}})}let wY=null,TY=null;async function EY(){return wY||=import(`./es-
|
|
3037
|
+
`,stderr:``,exitCode:0}})}let wY=null,TY=null;async function EY(){return wY||=import(`./es-4JXw-ziF.js`),wY}async function DY(){return TY||=import(`./dist-USoe4ZIh.js`),TY}function OY(e){return e.endsWith(`right`)?{range:e.slice(0,-5),rotation:90}:e.endsWith(`left`)?{range:e.slice(0,-4),rotation:270}:e.endsWith(`down`)?{range:e.slice(0,-4),rotation:180}:{range:e}}function kY(e){let{range:t,rotation:n}=OY(e);if(/^\d+$/.test(t)){let e=parseInt(t,10);return{start:e,end:e,rotation:n}}let r=t.match(/^(\d+)-(\d+|end)$/);if(r)return{start:parseInt(r[1],10),end:r[2]===`end`?`end`:parseInt(r[2],10),rotation:n};throw Error(`Invalid page range: ${e}`)}function AY(e,t){let n=e.start,r=e.end;if(n<1||n>t)throw Error(`Page ${n} out of range (1-${t})`);let i=r===`end`?t:r;if(i<1||i>t)throw Error(`Page ${i} out of range (1-${t})`);if(i<n)throw Error(`Invalid range: ${n}-${i}`);let a=[];for(let e=n;e<=i;e++)a.push(e);return a}function jY(){return{stdout:`usage: pdftk <input.pdf> <operation> [args...]
|
|
3038
3038
|
|
|
3039
3039
|
Operations:
|
|
3040
3040
|
dump_data Print metadata (page count, title, author, etc.)
|
|
@@ -3273,10 +3273,10 @@ Examples:
|
|
|
3273
3273
|
oauth-token adobe
|
|
3274
3274
|
oauth-token github --scope "repo,models:read"
|
|
3275
3275
|
curl -H "Authorization: Bearer $(oauth-token github)" https://api.github.com/user
|
|
3276
|
-
`}function HZ(){return wM(`oauth-token`,async e=>{let{getOAuthAccountInfo:t,getSelectedProvider:n,getAccounts:r}=await import(`./provider-settings-
|
|
3276
|
+
`}function HZ(){return wM(`oauth-token`,async e=>{let{getOAuthAccountInfo:t,getSelectedProvider:n,getAccounts:r}=await import(`./provider-settings-CpChAEwc.js`).then(e=>e.l),{getRegisteredProviderConfig:i,getRegisteredProviderIds:a}=await import(`./providers-zTkMw2SC.js`).then(e=>e.r);if(e.includes(`--help`)||e.includes(`-h`))return{stdout:VZ(),stderr:``,exitCode:0};if(e.includes(`--list`))return UZ(r,a,i,t);let o,s=e.indexOf(`--scope`);if(s>=0){if(o=e[s+1]?.trim(),!o||o.startsWith(`-`))return{stdout:``,stderr:`oauth-token: --scope requires a value
|
|
3277
3277
|
`,exitCode:1};e.splice(s,2)}let c,l=e.indexOf(`--provider`);if(l>=0){if(c=e[l+1],!c)return{stdout:``,stderr:`oauth-token: --provider requires a value
|
|
3278
3278
|
`,exitCode:1}}else if(e.length>0)c=e[0];else{let e=n(),t=i(e);if(t?.isOAuth&&t.onOAuthLogin)c=e;else if(c=a().find(e=>{let t=i(e);return t?.isOAuth&&t.onOAuthLogin}),!c)return{stdout:``,stderr:`oauth-token: no OAuth providers configured
|
|
3279
|
-
`,exitCode:1}}let u=i(c);if(!u)return{stdout:``,stderr:`oauth-token: unknown provider "${c}"\n`,exitCode:1};if(!u.isOAuth||!u.onOAuthLogin)return{stdout:``,stderr:`oauth-token: provider "${c}" is not an OAuth provider\n`,exitCode:1};if(!o){let e=t(c);if(e&&!e.expired){let t=e.maskedValue;return t?{stdout:`${t}\n`,stderr:``,exitCode:0}:{stdout:``,stderr:`oauth-token: no masked value for ${c} (try logging in again)\n`,exitCode:1}}}try{let{createOAuthLauncher:e}=await import(`./oauth-service-
|
|
3279
|
+
`,exitCode:1}}let u=i(c);if(!u)return{stdout:``,stderr:`oauth-token: unknown provider "${c}"\n`,exitCode:1};if(!u.isOAuth||!u.onOAuthLogin)return{stdout:``,stderr:`oauth-token: provider "${c}" is not an OAuth provider\n`,exitCode:1};if(!o){let e=t(c);if(e&&!e.expired){let t=e.maskedValue;return t?{stdout:`${t}\n`,stderr:``,exitCode:0}:{stdout:``,stderr:`oauth-token: no masked value for ${c} (try logging in again)\n`,exitCode:1}}}try{let{createOAuthLauncher:e}=await import(`./oauth-service-B5C1N2fh.js`),n=e();await u.onOAuthLogin(n,()=>{},o?{scopes:o}:void 0);let r=t(c);if(r&&r.token){let e=r.maskedValue;return e?{stdout:`${e}\n`,stderr:``,exitCode:0}:{stdout:``,stderr:`oauth-token: no masked value for ${c} (try logging in again)\n`,exitCode:1}}return console.error(`[oauth-token] Provider ${c}: login completed but no token was saved`),{stdout:``,stderr:`oauth-token: login completed but no token was saved
|
|
3280
3280
|
`,exitCode:1}}catch(e){let t=e instanceof Error?e.message:String(e);return console.error(`[oauth-token] Provider ${c}: login failed:`,t),{stdout:``,stderr:`oauth-token: login failed: ${t}\n`,exitCode:1}}})}function UZ(e,t,n,r){let i=t().filter(e=>n(e)?.isOAuth);if(i.length===0)return{stdout:`No OAuth providers configured.
|
|
3281
3281
|
`,stderr:``,exitCode:0};let a=[];for(let e of i){let t=r(e);if(!t)a.push(`${e} (no token)`);else if(t.expired){let n=t.userName?` as ${t.userName}`:``;a.push(`${e} (expired${n})`)}else{let n=[];if(t.userName?n.push(`logged in as ${t.userName}`):n.push(`logged in`),t.expiresAt){let e=t.expiresAt-Date.now();if(e>0){let t=Math.floor(e/36e5),r=Math.floor(e%36e5/6e4);t>0?n.push(`expires in ${t}h`):n.push(`expires in ${r}m`)}}a.push(`${e} (${n.join(`, `)})`)}}return{stdout:a.join(`
|
|
3282
3282
|
`)+`
|
|
@@ -3301,7 +3301,7 @@ Common base URLs:
|
|
|
3301
3301
|
llama.cpp http://localhost:8080/v1
|
|
3302
3302
|
vLLM http://localhost:8000/v1
|
|
3303
3303
|
Jan http://localhost:1337/v1
|
|
3304
|
-
`}function dQ(){return wM(lQ,async e=>{if(e.includes(`--help`)||e.includes(`-h`))return{stdout:uQ(),stderr:``,exitCode:0};let{getApiKeyForProvider:t,getRawApiKeyForProvider:n,getBaseUrlForProvider:r,addAccount:i}=await import(`./provider-settings-
|
|
3304
|
+
`}function dQ(){return wM(lQ,async e=>{if(e.includes(`--help`)||e.includes(`-h`))return{stdout:uQ(),stderr:``,exitCode:0};let{getApiKeyForProvider:t,getRawApiKeyForProvider:n,getBaseUrlForProvider:r,addAccount:i}=await import(`./provider-settings-CpChAEwc.js`).then(e=>e.l),{verifyConnection:a}=await import(`./local-llm-CJzFL4ih.js`).then(e=>e.n),o=e[0]??`status`;if(o!==`status`&&o!==`discover`)return{stdout:``,stderr:`Unknown subcommand: ${o}. See \`local-llm --help\`.\n`,exitCode:2};let s=r(lQ);if(!s)return{stdout:``,stderr:`Local LLM is not configured. Open Settings → Providers → Local LLM and set a base URL.
|
|
3305
3305
|
`,exitCode:1};let c=await a(s,t(lQ)??void 0);if(!c.ok){let e=[`✗ Could not reach ${s}`,` runtime: ${c.runtime.kind}${c.runtime.version?` (${c.runtime.version})`:``}`,` error: ${c.error?.message??`unknown`}`];return c.error?.hint&&e.push(` hint: ${c.error.hint}`),{stdout:``,stderr:e.join(`
|
|
3306
3306
|
`)+`
|
|
3307
3307
|
`,exitCode:1}}return o===`discover`?(i(lQ,n(lQ)??``,s,c.models.join(`, `)),{stdout:[`✓ ${s} (${c.runtime.kind}${c.runtime.version?` ${c.runtime.version}`:``})`,` Saved ${c.models.length} model${c.models.length===1?``:`s`} to Settings:`,...c.models.map(e=>` • ${e}`)].join(`
|
|
@@ -3378,7 +3378,7 @@ Examples:
|
|
|
3378
3378
|
oauth-domain add adobe '*.da.live'
|
|
3379
3379
|
oauth-domain list adobe
|
|
3380
3380
|
oauth-domain remove adobe admin.da.live
|
|
3381
|
-
`}function CQ(){return wM(`oauth-domain`,async e=>{if(e.length===0||e.includes(`--help`)||e.includes(`-h`))return{stdout:SQ(),stderr:``,exitCode:0};let{getExtraOAuthDomains:t,setExtraOAuthDomains:n,getAllExtraOAuthDomains:r}=await import(`./provider-settings-
|
|
3381
|
+
`}function CQ(){return wM(`oauth-domain`,async e=>{if(e.length===0||e.includes(`--help`)||e.includes(`-h`))return{stdout:SQ(),stderr:``,exitCode:0};let{getExtraOAuthDomains:t,setExtraOAuthDomains:n,getAllExtraOAuthDomains:r}=await import(`./provider-settings-CpChAEwc.js`).then(e=>e.l),[i,a,o]=e;try{switch(i){case`list`:{if(a){let e=t(a);return e.length===0?{stdout:`(no extra domains configured for ${a})\n`,stderr:``,exitCode:0}:{stdout:e.join(`
|
|
3382
3382
|
`)+`
|
|
3383
3383
|
`,stderr:``,exitCode:0}}let e=r(),n=Object.entries(e).filter(([,e])=>e.length>0);return n.length===0?{stdout:`(no extra OAuth domains configured)
|
|
3384
3384
|
`,stderr:``,exitCode:0}:{stdout:n.map(([e,t])=>`${e}: ${t.join(`, `)}`).join(`
|
|
@@ -3513,7 +3513,7 @@ Options:
|
|
|
3513
3513
|
-h, --help Show this help message
|
|
3514
3514
|
`}function E$(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`.replace(`.0M`,`M`):e>=1e3?`${(e/1e3).toFixed(0)}K`:`${e}`}function D$(e){return`$${e.toFixed(2)}`}const O$=/\b(embedding|embed|tts|whisper|dall-e|image-gen|audio|vision-preview)\b/i;function k$(e){let t=`${e.id} ${e.name??``}`;return!O$.test(t)}function A$(e){let t=e.toLowerCase();t=t.replace(/-\d{8}$/,``),t=t.replace(/-\d{4}$/,``),t=t.replace(/-(preview|latest)$/,``);let n=t.match(/^(claude-(?:opus|sonnet|haiku))/);if(n)return n[1];let r=t.match(/^(gpt-\d+)(?:\.\d+)?(-[a-z][-a-z]*)?$/);if(r)return r[1]+(r[2]??``);let i=t.match(/^gemini-[\d.]+-(.+)$/);if(i)return`gemini-${i[1]}`;let a=t.match(/^gemini-(\d+)-(.+)$/);if(a)return`gemini-${a[2]}`;let o=t.match(/^grok-[\d.]+-([\w-]+)$/);if(o)return`grok-${o[1]}`;if(t.match(/^(grok)-[\d.]+$/))return`grok`;let s=t.match(/^(o\d+(?:-[a-z]+)?)(?:-\d.*)?$/);return s?s[1]:t.replace(/-[\d.]+$/,``)}function j$(e){let t=new Map;for(let n of e){let e=A$(n.id);t.has(e)||t.set(e,n)}return[...t.values()]}function M$(e,t,n,r,i){let a=i?w$(e.id,i):void 0,o={id:e.id,name:e.name,provider:t,cost:e.cost??{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:e.contextWindow??0,maxTokens:e.maxTokens??0,reasoning:!!e.reasoning,input:e.input??[`text`],selected:e.id===n&&t===r};return a?.intelligence_index!=null&&(o.intelligence=a.intelligence_index),a?.coding_index!=null&&(o.codingScore=a.coding_index),a?.speed_tps!=null&&(o.speed=a.speed_tps),o}function N$(e,t,n,r){let i=[];i.push(`Models for "${e}" (${t}):\n`);for(let e of n){let t=e.selected?` ► `:` `,n=e.id.padEnd(30),r=`${D$(e.cost.input)} / ${D$(e.cost.output)}`,a=`${E$(e.contextWindow)} ctx`,o=e.intelligence==null?``:`IQ:${e.intelligence}`,s=e.speed==null?``:`${Math.round(e.speed)} t/s`,c=e.reasoning?`reasoning`:``,l=o||s?`${o.padEnd(6)} ${s.padEnd(8)}`:``;i.push(`${t}${n} ${r.padEnd(16)} ${a.padEnd(10)} ${l} ${c}`)}let a=n.find(e=>e.selected);return i.push(`\n ${n.length} model${n.length===1?``:`s`} available.${a?` Currently using: ${a.id}`:``}`),r&&i.push(` Intelligence data: artificialanalysis.ai`),i.join(`
|
|
3515
3515
|
`)+`
|
|
3516
|
-
`}function P$(e){return wM(`models`,async t=>{let{getAccounts:n,getAvailableProviders:r,getProviderConfig:i,getProviderModels:a,getSelectedProvider:o,getSelectedModelId:s}=await import(`./provider-settings-
|
|
3516
|
+
`}function P$(e){return wM(`models`,async t=>{let{getAccounts:n,getAvailableProviders:r,getProviderConfig:i,getProviderModels:a,getSelectedProvider:o,getSelectedModelId:s}=await import(`./provider-settings-CpChAEwc.js`).then(e=>e.l);if(t.includes(`--help`)||t.includes(`-h`))return{stdout:T$(),stderr:``,exitCode:0};let c=t.includes(`--json`),l=t.includes(`--all`),u=t.includes(`--all-versions`),d=t.includes(`--refresh`),f=t.includes(`--no-benchmarks`),p=t.indexOf(`--provider`),m=p>=0?t[p+1]:void 0,h=o(),g=s(),_=n();if(_.length===0)return{stdout:``,stderr:`No provider accounts configured. Run the provider settings to add one.
|
|
3517
3517
|
`,exitCode:1};let v;f||(v=await S$(e,d),v.length===0&&(v=void 0));let y;if(m){let e=r();if(!e.includes(m))return{stdout:``,stderr:`Unknown provider: ${m}. Available: ${e.join(`, `)}\n`,exitCode:1};y=[m]}else y=l?[...new Set(_.map(e=>e.providerId))]:[h];let b=[],x=[];for(let e of y){let t=a(e).filter(k$);if(t.length===0){if(!l)return{stdout:``,stderr:`No models available for provider ${e}.\n`,exitCode:1};continue}let n=t.map(t=>M$(t,e,g,h,v)).sort((e,t)=>t.cost.input-e.cost.input);if(u||(n=j$(n)),b.push(...n),!c){let t=i(e);x.push(N$(t.name,e,n,!!v))}}return c?{stdout:JSON.stringify(b,null,2)+`
|
|
3518
3518
|
`,stderr:``,exitCode:0}:(!u&&!c&&x.push(`Showing latest versions only. Use --all-versions to see all.
|
|
3519
3519
|
`),{stdout:x.join(`
|
|
@@ -7043,4 +7043,4 @@ ${t}
|
|
|
7043
7043
|
`;case`cmdline`:return`kernel-host\0`;case`cwd`:return`/
|
|
7044
7044
|
`;case`stat`:return`1 (kernel-host) R 0 - 0 -
|
|
7045
7045
|
`}}var n3=n({formatMountRecoveryPrompt:()=>o3,mdInlineCode:()=>a3,recoverMounts:()=>r3,shellQuote:()=>i3});async function r3(e,t,n){let r=[],i=[];for(let a of e){let{targetPath:e,descriptor:o}=a;if(o.kind===`local`){let a=await UR(o.idbHandleKey),s=typeof a?.name==`string`?a.name:``;if(!a||!(`queryPermission`in a)){i.push({kind:`local`,path:e,dirName:s});continue}let c;try{c=await a.queryPermission({mode:`readwrite`})}catch(t){n?.warn?.(`queryPermission threw on persisted handle`,{path:e,error:t instanceof Error?t.message:String(t)}),i.push({kind:`local`,path:e,dirName:s});continue}if(c!==`granted`){i.push({kind:`local`,path:e,dirName:s});continue}try{let i=ZR.fromHandle(a,{mountId:o.mountId});await t.mount(e,i),n?.info?.(`Restored mount from previous session`,{path:e,name:s}),r.push({kind:`local`,path:e,dirName:s})}catch(t){n?.warn?.(`Failed to re-mount persisted handle`,{path:e,error:t instanceof Error?t.message:String(t)}),i.push({kind:`local`,path:e,dirName:s})}continue}if(o.kind===`s3`){try{let i=new Ge({mountId:o.mountId,ttlMs:3e4}),a=new Ve({source:o.source,profile:o.profile,cache:i,mountId:o.mountId,signedFetch:We(o.profile)});await t.mount(e,a),n?.info?.(`Restored S3 mount from previous session`,{path:e,source:o.source}),r.push({kind:`s3`,path:e,source:o.source,profile:o.profile,reason:``})}catch(t){let r=t instanceof Error?t.message:String(t);n?.warn?.(`Failed to restore S3 mount`,{path:e,error:r}),i.push({kind:`s3`,path:e,source:o.source,profile:o.profile,reason:r})}continue}if(o.kind===`da`){try{let i=new Ge({mountId:o.mountId,ttlMs:3e4}),a=new He({source:o.source,profile:o.profile,cache:i,mountId:o.mountId,signedFetch:Ue()});await t.mount(e,a),n?.info?.(`Restored DA mount from previous session`,{path:e,source:o.source}),r.push({kind:`da`,path:e,source:o.source,profile:o.profile,reason:``})}catch(t){let r=t instanceof Error?t.message:String(t);n?.warn?.(`Failed to restore DA mount`,{path:e,error:r}),i.push({kind:`da`,path:e,source:o.source,profile:o.profile,reason:r})}continue}}return{restored:r,needsRecovery:i}}function i3(e){return`'${e.replace(/'/g,`'\\''`)}'`}function a3(e){let t=e.replace(/\r\n|[\r\n]/g,` `),n=t.match(/`+/g),r=n?Math.max(...n.map(e=>e.length))+1:1,i="`".repeat(r);return`${i}${t.startsWith("`")||t.endsWith("`")?` ${t} `:t}${i}`}function o3(e){if(!Array.isArray(e)||e.length===0)return null;let t=e.length===1?`mount point`:`mount points`,n=e.length===1?`it`:`them`,r=e.filter(e=>e.kind===`local`),i=e.filter(e=>e.kind===`s3`||e.kind===`da`),a=[`[Session Reload] Mount recovery required for ${e.length} ${t}.`,``];if(r.length>0){let e=r.map(({path:e,dirName:t})=>{let n=t?` (previously mounted from ${a3(t)})`:``;return`- ${a3(e)}${n}`}),i=r.map(({path:e})=>` mount ${i3(e)}`);a.push(`The page was reloaded and the following local ${t} lost filesystem permission. The browser cannot restore access without a fresh user gesture, so ${n} cannot be used until the user re-authorizes:`,``,...e,``,`Please tell the user what happened and ask whether they want to re-mount. If yes, run the corresponding command(s) so the folder picker opens and they can re-select the same directory:`,``,...i,``)}if(i.length>0){let e=i.map(({path:e,source:t,profile:n,reason:r})=>{let i=n===`default`?``:` --profile ${i3(n)}`,a=`mount --source ${i3(t)}${i} ${i3(e)}`;return`- ${a3(e)} (${a3(t)}, profile ${a3(n)}) — ${r}\n Retry: ${a3(a)}`});a.push(`The following remote ${t} could not be auto-restored:`,``,...e,``)}return a.push("If the user no longer needs a mount, run `mount unmount <path>` (with the path shell-quoted the same way) to clear the stale entry instead."),a.join(`
|
|
7046
|
-
`)}function s3(e){let t=e.type===`webhook`,n=e.type===`sprinkle`,r=e.type===`fswatch`,i=e.type===`session-reload`,a=e.type===`navigate`,o=e.type===`upgrade`,s=t?e.webhookName:n?e.sprinkleName:r?e.fswatchName:i?`mount-recovery`:a?e.navigateUrl:o?`${e.upgradeFromVersion??`unknown`}→${e.upgradeToVersion??`unknown`}`:e.cronName,c=t?`Webhook Event`:n?`Sprinkle Event`:r?`File Watch Event`:i?`Session Reload`:a?`Navigate Event`:o?`Upgrade Event`:`Cron Event`;if(i){let t=e.body;if(t?.reason===`mount-recovery`){let e=o3(t.mounts??[]);return e===null?null:{label:c,content:e}}}if(o){let t=e.upgradeFromVersion??`unknown`,n=e.upgradeToVersion??`unknown`,r=e.body?.releasedAt??null;return{label:c,content:`[${c}: ${t}→${n}]\n\nSLICC was upgraded from \`${t}\` to \`${n}\`.${r?`\nReleased: ${r}`:``}\n\nUse the **upgrade** skill (\`/workspace/skills/upgrade/SKILL.md\`) to:\n- Show the user the changelog between these tags from GitHub\n- Offer to merge new bundled vfs-root content into their workspace (three-way merge: bundled snapshot vs user's VFS, reconciled with the GitHub tag-to-tag diff).`}}return{label:c,content:`[${c}: ${s}]\n\`\`\`json\n${JSON.stringify(e.body,null,2)}\n\`\`\``}}function c3(e,{orchestrator:t,log:n}){let r=s3(e);if(r===null){n.debug?.(`dropping lick event with no renderable content`,{type:e.type});return}let i=e.type===`webhook`,a=e.type===`sprinkle`,o=e.type===`fswatch`,s=e.type===`navigate`,c=e.type===`upgrade`,l=e.type===`session-reload`,u=i?e.webhookName:a?e.sprinkleName:o?e.fswatchName:s?e.navigateUrl:c?`${e.upgradeFromVersion??`unknown`}→${e.upgradeToVersion??`unknown`}`:l?`mount-recovery`:e.cronName,d=i?e.webhookId:a?e.sprinkleName:o?e.fswatchId:s?e.navigateUrl:c?`upgrade-${e.upgradeToVersion??`unknown`}`:l?`session-reload-${e.timestamp}`:e.cronId,f=e.type,p=t.getScoops(),m;if(m=e.targetScoop?p.find(t=>t.name===e.targetScoop||t.folder===e.targetScoop||t.folder===`${e.targetScoop}-scoop`):p.find(e=>e.isCone),!m){n.warn(`Lick target scoop not found`,e.targetScoop);return}let h={id:`${f}-${d}-${Date.now()}`,chatJid:m.jid,senderId:f,senderName:`${f}:${u}`,content:r.content,timestamp:e.timestamp,fromAssistant:!1,channel:f};t.handleMessage(h)}async function l3(e){let{container:t,browser:n,bridge:r,callbacks:i,skipConeBootstrap:a=!1}=e,o=e.logger??console,s=new yJ,c=new A4(t,{...i,getBrowserAPI:()=>n});c.setProcessManager(s),globalThis.__slicc_pm=s,await r.bind(c,n);let l=ot(()=>r.emitTrayRuntimeStatus()),u=E(()=>r.emitTrayRuntimeStatus());await c.init();let d=c.getSharedFS();if(d?N4(c,d,c.getSessionStore()):o.warn(`AgentBridge not published — orchestrator.getSharedFS() returned null`),d)try{await d.mountInternal(`/proc`,new G4(s))}catch(e){o.warn(`Failed to mount /proc`,e)}let{registerSessionCostsProvider:f}=await Promise.resolve().then(()=>F$);f(()=>c.getSessionCosts());let{getLickManager:p}=await Promise.resolve().then(()=>x4),m=p();await m.init(),c.setLickManager(m);let h=e.lickEventHandler??c3,g={orchestrator:c,lickManager:m,log:o};m.setEventHandler(e=>h(e,g)),globalThis.__slicc_lickManager=m,d&&(async()=>{try{let{getAllMountEntries:e}=await Promise.resolve().then(()=>IR),{recoverMounts:t}=await Promise.resolve().then(()=>n3),n=await e();if(n.length===0)return;let{needsRecovery:r}=await t(n,d,o);if(r.length===0)return;m.emitEvent({type:`session-reload`,targetScoop:void 0,timestamp:new Date().toISOString(),body:{reason:`mount-recovery`,mounts:r}})}catch(e){o.warn(`mount recovery failed`,e)}})(),a||c.getScoops().some(e=>e.isCone)||await c.registerScoop({jid:`cone_${Date.now()}`,name:`Cone`,folder:`cone`,isCone:!0,type:`cone`,requiresTrigger:!1,assistantLabel:`sliccy`,addedAt:new Date().toISOString()}),d&&(async()=>{try{let{detectUpgrade:e,recordVersionSeen:t}=await import(`./upgrade-detection-Ce7X_CBC.js`),n=await e();if(!n.isUpgrade||n.lastSeen===null)return;m.emitEvent({type:`upgrade`,targetScoop:void 0,timestamp:new Date().toISOString(),upgradeFromVersion:n.lastSeen,upgradeToVersion:n.bundled.version,body:{from:n.lastSeen,to:n.bundled.version,releasedAt:n.bundled.releasedAt}}),await t(n.bundled.version)}catch(e){o.warn(`Upgrade detection failed`,e)}})();let _=null,v=null;if(d)try{let{BshWatchdog:e}=await import(`./bsh-watchdog-DEvn8Q9x.js`),{ScriptCatalog:t}=await Promise.resolve().then(()=>N0),r=new t({jshFs:d,bshFs:d,watcher:d.getWatcher()}),i=new e({browserAPI:n,scriptCatalog:r,fs:d});i.start(),_=()=>i.stop(),v=()=>r.dispose()}catch(e){o.warn(`Failed to start BSH watchdog`,e)}let y=!1;return{orchestrator:c,browser:n,bridge:r,lickManager:m,sharedFs:d??null,processManager:s,async dispose(){if(!y){if(y=!0,l?.(),u?.(),_?.(),v?.(),d)try{await d.unmountInternal(`/proc`)}catch{}u3({processManager:s,lickManager:m})}}}}function u3(e){let t=globalThis;t.__slicc_pm===e.processManager&&delete t.__slicc_pm,t.__slicc_lickManager===e.lickManager&&delete t.__slicc_lickManager}function d3(e){let t=!1,n=()=>{t||(t=!0,typeof e.start==`function`&&e.start())};return{onMessage:t=>{let r=e=>{t(e.data)};return e.addEventListener(`message`,r),n(),()=>{e.removeEventListener(`message`,r)}},send:t=>{e.postMessage(t)}}}function f3(e){let t=d3(e);return{onMessage:e=>t.onMessage(e),send:e=>{t.send({source:`offscreen`,payload:e})}}}var p3=class extends qK{constructor(e){let t=d3(e);super({label:`WorkerCdpProxy`,buildCommandEnvelope:(e,t,n,r)=>({type:`cdp-cmd`,id:e,method:t,params:n,sessionId:r}),sendEnvelope:e=>(t.send(e),Promise.resolve()),subscribeIncoming:e=>t.onMessage(e),parseResponse:e=>{let t=e;if(t?.type!==`cdp-response`)return null;if(typeof t.id!=`number`||!Number.isFinite(t.id))return console.warn(`[WorkerCdpProxy] dropping cdp-response with invalid id`,t),null;let n=e;return{id:n.id,result:n.result,error:n.error}},parseEvent:e=>{let t=e;if(t?.type!==`cdp-event`)return null;if(typeof t.method!=`string`)return console.warn(`[WorkerCdpProxy] dropping cdp-event with invalid method`,t),null;let n=e;return{method:n.method,params:n.params}},onSubscribeEvent:e=>{t.send({type:`cdp-subscribe`,event:e})},onUnsubscribeEvent:e=>{t.send({type:`cdp-unsubscribe`,event:e})}})}},m3=class{transport;createShell;log;pm;defaultOwner;sessions=new Map;unsubscribe=null;constructor(e){this.transport=e.transport,this.createShell=e.createShell,this.log=e.logger??console,this.pm=e.processManager??null,this.defaultOwner=e.defaultOwner??{kind:`system`}}start(){return this.unsubscribe||=this.transport.onMessage(e=>{if(!h3(e)||e.source!==`panel`)return;let t=e.payload;_3(t)&&this.handleControl(t).catch(e=>{this.log.warn(`[terminal-session-host] handler error`,e)})}),()=>this.dispose()}dispose(){this.unsubscribe?.(),this.unsubscribe=null;for(let[,e]of this.sessions)e.currentProcess&&this.pm?(this.pm.signal(e.currentProcess.pid,`SIGTERM`),this.pm.exit(e.currentProcess.pid,null)):e.currentExec?.abort(),e.shell.dispose?.();this.sessions.clear()}async handleControl(e){switch(e.type){case`terminal-open`:return this.handleOpen(e);case`terminal-close`:return this.handleClose(e);case`terminal-exec`:return this.handleExec(e);case`terminal-signal`:return this.handleSignal(e);case`terminal-stdin`:case`terminal-resize`:return}}async handleOpen(e){if(this.sessions.has(e.sid)){this.emitStatus(e.sid,`error`,`session already open`);return}try{let t=this.createShell(e.sid,{cwd:e.cwd,env:e.env});this.sessions.set(e.sid,{shell:t,currentExec:null,currentProcess:null}),this.emitStatus(e.sid,`opened`)}catch(t){this.emitStatus(e.sid,`error`,t instanceof Error?t.message:String(t))}}async handleClose(e){let t=this.sessions.get(e.sid);t&&(t.currentProcess&&this.pm?(this.pm.signal(t.currentProcess.pid,`SIGTERM`),this.pm.exit(t.currentProcess.pid,null)):t.currentExec?.abort(),t.shell.dispose?.(),this.sessions.delete(e.sid),this.emitStatus(e.sid,`closed`))}async handleExec(e){let t=this.sessions.get(e.sid);if(!t){this.emit({type:`terminal-exit`,sid:e.sid,execId:e.execId,exitCode:127}),this.log.warn(`[terminal-session-host] exec on unknown session`,e.sid);return}if(t.currentExec){this.emit({type:`terminal-exit`,sid:e.sid,execId:e.execId,exitCode:130});return}let n=new AbortController;t.currentExec=n;let r=this.pm?this.pm.spawn({kind:`shell`,argv:[e.command],cwd:t.shell.getCwd?.()??void 0,owner:this.defaultOwner,adoptAbort:n}):null;t.currentProcess=r;try{let i=await t.shell.executeCommand(e.command,n.signal),a=n.signal.aborted?130:i.exitCode;n.signal.aborted||(r&&await r.gate.wait(),i.stdout&&this.emit({type:`terminal-output`,sid:e.sid,execId:e.execId,stream:`stdout`,data:i.stdout}),i.stderr&&this.emit({type:`terminal-output`,sid:e.sid,execId:e.execId,stream:`stderr`,data:i.stderr})),this.emit({type:`terminal-exit`,sid:e.sid,execId:e.execId,exitCode:a}),r&&this.pm&&this.pm.exit(r.pid,n.signal.aborted?null:i.exitCode)}catch(t){if(n.signal.aborted){let t=g3(r?.terminatedBy??`SIGINT`);this.emit({type:`terminal-exit`,sid:e.sid,execId:e.execId,exitCode:t}),r&&this.pm&&this.pm.exit(r.pid,null)}else{let n=t instanceof Error?t.message:String(t);this.emit({type:`terminal-output`,sid:e.sid,execId:e.execId,stream:`stderr`,data:`Error: ${n}\n`}),this.emit({type:`terminal-exit`,sid:e.sid,execId:e.execId,exitCode:1}),r&&this.pm&&this.pm.exit(r.pid,1)}}finally{t.currentExec===n&&(t.currentExec=null,t.currentProcess=null)}}async handleSignal(e){let t=this.sessions.get(e.sid);if(!t){this.log.warn(`[terminal-session-host] signal on unknown session`,e.sid);return}(e.signal===`SIGINT`||e.signal===`SIGTERM`||e.signal===`SIGKILL`)&&(t.currentProcess&&this.pm?this.pm.signal(t.currentProcess.pid,e.signal):t.currentExec?.abort())}emit(e){this.transport.send(e)}emitStatus(e,t,n){let r=n?{type:`terminal-status`,sid:e,state:t,error:n}:{type:`terminal-status`,sid:e,state:t};this.emit(r)}};function h3(e){return typeof e==`object`&&!!e&&`source`in e&&`payload`in e}function g3(e){switch(e){case`SIGINT`:return 130;case`SIGTERM`:return 143;case`SIGKILL`:return 137;case`SIGSTOP`:case`SIGCONT`:return 130}}function _3(e){if(typeof e!=`object`||!e)return!1;let t=e.type;return t===`terminal-open`||t===`terminal-close`||t===`terminal-exec`||t===`terminal-signal`||t===`terminal-stdin`||t===`terminal-resize`}function v3(e){let{transport:t,fs:n,browser:r,processManager:i}=e,a=new m3({transport:t,processManager:i,createShell:(e,t)=>new H0({fs:n,cwd:t.cwd,env:t.env,browserAPI:r,processManager:i,processOwner:{kind:`system`}}),logger:e.logger??console});return{host:a,stop:a.start()}}function y3(e,t={}){let n=t.onError??(e=>console.error(`[kernel-worker] boot failed`,e)),r=t.onDuplicate??(()=>console.warn(`[kernel-worker] received duplicate kernel-worker-init; ignoring`)),i=!1;return{handle(t){if(i){r();return}i=!0,e(t).catch(e=>{i=!1,n(e)})},isInitialized(){return i}}}const b3=`x-bypass-llm-proxy`;function x3(e,t){return t?(n,r)=>{if(!S3(n,t))return e(n,r);let i=new Headers(r?.headers);return i.has(b3)||i.set(b3,`1`),e(n,{...r,headers:i})}:e}function S3(e,t){let n;n=typeof e==`string`?e:e instanceof URL?e.href:e.url;try{return new URL(n,t).origin===t}catch{return!0}}function C3(){let e=globalThis.fetch;if(!e)return;let t=typeof self<`u`&&self.location?self.location.origin:void 0;globalThis.fetch=x3(e.bind(globalThis),t)}function w3(e){let t=new Map(Object.entries(e));Object.defineProperty(globalThis,`localStorage`,{value:{get length(){return t.size},key(e){return Array.from(t.keys())[e]??null},getItem(e){return t.has(e)?t.get(e):null},setItem(e,n){t.set(e,n)},removeItem(e){t.delete(e)},clear(){t.clear()}},configurable:!0,writable:!0})}let T3=null,E3=null,D3=null;const O3=y3(e=>k3(e));self.addEventListener(`message`,e=>{e.data?.type===`kernel-worker-init`&&O3.handle(e.data)});async function k3(e){C3(),w3(e.localStorageSeed??{}),await ze();let t=f3(e.kernelPort),n=new xt(t),r=xt.createCallbacks(n),i=new p3(e.cdpPort);await i.connect();let a=new Qe(i);T3=await l3({container:{},browser:a,bridge:n,callbacks:r,logger:console});let{createSprinkleManagerProxyOverChannel:o}=await import(`./sprinkle-bridge-channel-DhKQ_srk.js`);globalThis.__slicc_sprinkleManager=o({instanceId:e.instanceId});let{createPanelRpcClient:s}=await Promise.resolve().then(()=>XK);D3=s({instanceId:e.instanceId}),globalThis.__slicc_panelRpc=D3;let c=T3.processManager,l=T3.sharedFs;l?E3=v3({transport:t,fs:l,browser:a,processManager:c,logger:console}).stop:console.warn(`[kernel-worker] shared FS unavailable; terminal sessions will fail to open`),e.kernelPort.postMessage({type:`kernel-worker-ready`})}self.addEventListener(`message`,e=>{e.data?.type===`kernel-worker-shutdown`&&(E3?.(),E3=null,D3?.dispose(),D3=null,T3?.dispose())});export{vK as a,WR as c,BR as d,FR as f,st as h,tq as i,UR as l,ht as m,cQ as n,OB as o,gt as p,eQ as r,ZR as s,sQ as t,VR as u};
|
|
7046
|
+
`)}function s3(e){let t=e.type===`webhook`,n=e.type===`sprinkle`,r=e.type===`fswatch`,i=e.type===`session-reload`,a=e.type===`navigate`,o=e.type===`upgrade`,s=t?e.webhookName:n?e.sprinkleName:r?e.fswatchName:i?`mount-recovery`:a?e.navigateUrl:o?`${e.upgradeFromVersion??`unknown`}→${e.upgradeToVersion??`unknown`}`:e.cronName,c=t?`Webhook Event`:n?`Sprinkle Event`:r?`File Watch Event`:i?`Session Reload`:a?`Navigate Event`:o?`Upgrade Event`:`Cron Event`;if(i){let t=e.body;if(t?.reason===`mount-recovery`){let e=o3(t.mounts??[]);return e===null?null:{label:c,content:e}}}if(o){let t=e.upgradeFromVersion??`unknown`,n=e.upgradeToVersion??`unknown`,r=e.body?.releasedAt??null;return{label:c,content:`[${c}: ${t}→${n}]\n\nSLICC was upgraded from \`${t}\` to \`${n}\`.${r?`\nReleased: ${r}`:``}\n\nUse the **upgrade** skill (\`/workspace/skills/upgrade/SKILL.md\`) to:\n- Show the user the changelog between these tags from GitHub\n- Offer to merge new bundled vfs-root content into their workspace (three-way merge: bundled snapshot vs user's VFS, reconciled with the GitHub tag-to-tag diff).`}}return{label:c,content:`[${c}: ${s}]\n\`\`\`json\n${JSON.stringify(e.body,null,2)}\n\`\`\``}}function c3(e,{orchestrator:t,log:n}){let r=s3(e);if(r===null){n.debug?.(`dropping lick event with no renderable content`,{type:e.type});return}let i=e.type===`webhook`,a=e.type===`sprinkle`,o=e.type===`fswatch`,s=e.type===`navigate`,c=e.type===`upgrade`,l=e.type===`session-reload`,u=i?e.webhookName:a?e.sprinkleName:o?e.fswatchName:s?e.navigateUrl:c?`${e.upgradeFromVersion??`unknown`}→${e.upgradeToVersion??`unknown`}`:l?`mount-recovery`:e.cronName,d=i?e.webhookId:a?e.sprinkleName:o?e.fswatchId:s?e.navigateUrl:c?`upgrade-${e.upgradeToVersion??`unknown`}`:l?`session-reload-${e.timestamp}`:e.cronId,f=e.type,p=t.getScoops(),m;if(m=e.targetScoop?p.find(t=>t.name===e.targetScoop||t.folder===e.targetScoop||t.folder===`${e.targetScoop}-scoop`):p.find(e=>e.isCone),!m){n.warn(`Lick target scoop not found`,e.targetScoop);return}let h={id:`${f}-${d}-${Date.now()}`,chatJid:m.jid,senderId:f,senderName:`${f}:${u}`,content:r.content,timestamp:e.timestamp,fromAssistant:!1,channel:f};t.handleMessage(h)}async function l3(e){let{container:t,browser:n,bridge:r,callbacks:i,skipConeBootstrap:a=!1}=e,o=e.logger??console,s=new yJ,c=new A4(t,{...i,getBrowserAPI:()=>n});c.setProcessManager(s),globalThis.__slicc_pm=s,await r.bind(c,n);let l=ot(()=>r.emitTrayRuntimeStatus()),u=E(()=>r.emitTrayRuntimeStatus());await c.init();let d=c.getSharedFS();if(d?N4(c,d,c.getSessionStore()):o.warn(`AgentBridge not published — orchestrator.getSharedFS() returned null`),d)try{await d.mountInternal(`/proc`,new G4(s))}catch(e){o.warn(`Failed to mount /proc`,e)}let{registerSessionCostsProvider:f}=await Promise.resolve().then(()=>F$);f(()=>c.getSessionCosts());let{getLickManager:p}=await Promise.resolve().then(()=>x4),m=p();await m.init(),c.setLickManager(m);let h=e.lickEventHandler??c3,g={orchestrator:c,lickManager:m,log:o};m.setEventHandler(e=>h(e,g)),globalThis.__slicc_lickManager=m,d&&(async()=>{try{let{getAllMountEntries:e}=await Promise.resolve().then(()=>IR),{recoverMounts:t}=await Promise.resolve().then(()=>n3),n=await e();if(n.length===0)return;let{needsRecovery:r}=await t(n,d,o);if(r.length===0)return;m.emitEvent({type:`session-reload`,targetScoop:void 0,timestamp:new Date().toISOString(),body:{reason:`mount-recovery`,mounts:r}})}catch(e){o.warn(`mount recovery failed`,e)}})(),a||c.getScoops().some(e=>e.isCone)||await c.registerScoop({jid:`cone_${Date.now()}`,name:`Cone`,folder:`cone`,isCone:!0,type:`cone`,requiresTrigger:!1,assistantLabel:`sliccy`,addedAt:new Date().toISOString()}),d&&(async()=>{try{let{detectUpgrade:e,recordVersionSeen:t}=await import(`./upgrade-detection-CEFruYPw.js`),n=await e();if(!n.isUpgrade||n.lastSeen===null)return;m.emitEvent({type:`upgrade`,targetScoop:void 0,timestamp:new Date().toISOString(),upgradeFromVersion:n.lastSeen,upgradeToVersion:n.bundled.version,body:{from:n.lastSeen,to:n.bundled.version,releasedAt:n.bundled.releasedAt}}),await t(n.bundled.version)}catch(e){o.warn(`Upgrade detection failed`,e)}})();let _=null,v=null;if(d)try{let{BshWatchdog:e}=await import(`./bsh-watchdog-DEvn8Q9x.js`),{ScriptCatalog:t}=await Promise.resolve().then(()=>N0),r=new t({jshFs:d,bshFs:d,watcher:d.getWatcher()}),i=new e({browserAPI:n,scriptCatalog:r,fs:d});i.start(),_=()=>i.stop(),v=()=>r.dispose()}catch(e){o.warn(`Failed to start BSH watchdog`,e)}let y=!1;return{orchestrator:c,browser:n,bridge:r,lickManager:m,sharedFs:d??null,processManager:s,async dispose(){if(!y){if(y=!0,l?.(),u?.(),_?.(),v?.(),d)try{await d.unmountInternal(`/proc`)}catch{}u3({processManager:s,lickManager:m})}}}}function u3(e){let t=globalThis;t.__slicc_pm===e.processManager&&delete t.__slicc_pm,t.__slicc_lickManager===e.lickManager&&delete t.__slicc_lickManager}function d3(e){let t=!1,n=()=>{t||(t=!0,typeof e.start==`function`&&e.start())};return{onMessage:t=>{let r=e=>{t(e.data)};return e.addEventListener(`message`,r),n(),()=>{e.removeEventListener(`message`,r)}},send:t=>{e.postMessage(t)}}}function f3(e){let t=d3(e);return{onMessage:e=>t.onMessage(e),send:e=>{t.send({source:`offscreen`,payload:e})}}}var p3=class extends qK{constructor(e){let t=d3(e);super({label:`WorkerCdpProxy`,buildCommandEnvelope:(e,t,n,r)=>({type:`cdp-cmd`,id:e,method:t,params:n,sessionId:r}),sendEnvelope:e=>(t.send(e),Promise.resolve()),subscribeIncoming:e=>t.onMessage(e),parseResponse:e=>{let t=e;if(t?.type!==`cdp-response`)return null;if(typeof t.id!=`number`||!Number.isFinite(t.id))return console.warn(`[WorkerCdpProxy] dropping cdp-response with invalid id`,t),null;let n=e;return{id:n.id,result:n.result,error:n.error}},parseEvent:e=>{let t=e;if(t?.type!==`cdp-event`)return null;if(typeof t.method!=`string`)return console.warn(`[WorkerCdpProxy] dropping cdp-event with invalid method`,t),null;let n=e;return{method:n.method,params:n.params}},onSubscribeEvent:e=>{t.send({type:`cdp-subscribe`,event:e})},onUnsubscribeEvent:e=>{t.send({type:`cdp-unsubscribe`,event:e})}})}},m3=class{transport;createShell;log;pm;defaultOwner;sessions=new Map;unsubscribe=null;constructor(e){this.transport=e.transport,this.createShell=e.createShell,this.log=e.logger??console,this.pm=e.processManager??null,this.defaultOwner=e.defaultOwner??{kind:`system`}}start(){return this.unsubscribe||=this.transport.onMessage(e=>{if(!h3(e)||e.source!==`panel`)return;let t=e.payload;_3(t)&&this.handleControl(t).catch(e=>{this.log.warn(`[terminal-session-host] handler error`,e)})}),()=>this.dispose()}dispose(){this.unsubscribe?.(),this.unsubscribe=null;for(let[,e]of this.sessions)e.currentProcess&&this.pm?(this.pm.signal(e.currentProcess.pid,`SIGTERM`),this.pm.exit(e.currentProcess.pid,null)):e.currentExec?.abort(),e.shell.dispose?.();this.sessions.clear()}async handleControl(e){switch(e.type){case`terminal-open`:return this.handleOpen(e);case`terminal-close`:return this.handleClose(e);case`terminal-exec`:return this.handleExec(e);case`terminal-signal`:return this.handleSignal(e);case`terminal-stdin`:case`terminal-resize`:return}}async handleOpen(e){if(this.sessions.has(e.sid)){this.emitStatus(e.sid,`error`,`session already open`);return}try{let t=this.createShell(e.sid,{cwd:e.cwd,env:e.env});this.sessions.set(e.sid,{shell:t,currentExec:null,currentProcess:null}),this.emitStatus(e.sid,`opened`)}catch(t){this.emitStatus(e.sid,`error`,t instanceof Error?t.message:String(t))}}async handleClose(e){let t=this.sessions.get(e.sid);t&&(t.currentProcess&&this.pm?(this.pm.signal(t.currentProcess.pid,`SIGTERM`),this.pm.exit(t.currentProcess.pid,null)):t.currentExec?.abort(),t.shell.dispose?.(),this.sessions.delete(e.sid),this.emitStatus(e.sid,`closed`))}async handleExec(e){let t=this.sessions.get(e.sid);if(!t){this.emit({type:`terminal-exit`,sid:e.sid,execId:e.execId,exitCode:127}),this.log.warn(`[terminal-session-host] exec on unknown session`,e.sid);return}if(t.currentExec){this.emit({type:`terminal-exit`,sid:e.sid,execId:e.execId,exitCode:130});return}let n=new AbortController;t.currentExec=n;let r=this.pm?this.pm.spawn({kind:`shell`,argv:[e.command],cwd:t.shell.getCwd?.()??void 0,owner:this.defaultOwner,adoptAbort:n}):null;t.currentProcess=r;try{let i=await t.shell.executeCommand(e.command,n.signal),a=n.signal.aborted?130:i.exitCode;n.signal.aborted||(r&&await r.gate.wait(),i.stdout&&this.emit({type:`terminal-output`,sid:e.sid,execId:e.execId,stream:`stdout`,data:i.stdout}),i.stderr&&this.emit({type:`terminal-output`,sid:e.sid,execId:e.execId,stream:`stderr`,data:i.stderr})),this.emit({type:`terminal-exit`,sid:e.sid,execId:e.execId,exitCode:a}),r&&this.pm&&this.pm.exit(r.pid,n.signal.aborted?null:i.exitCode)}catch(t){if(n.signal.aborted){let t=g3(r?.terminatedBy??`SIGINT`);this.emit({type:`terminal-exit`,sid:e.sid,execId:e.execId,exitCode:t}),r&&this.pm&&this.pm.exit(r.pid,null)}else{let n=t instanceof Error?t.message:String(t);this.emit({type:`terminal-output`,sid:e.sid,execId:e.execId,stream:`stderr`,data:`Error: ${n}\n`}),this.emit({type:`terminal-exit`,sid:e.sid,execId:e.execId,exitCode:1}),r&&this.pm&&this.pm.exit(r.pid,1)}}finally{t.currentExec===n&&(t.currentExec=null,t.currentProcess=null)}}async handleSignal(e){let t=this.sessions.get(e.sid);if(!t){this.log.warn(`[terminal-session-host] signal on unknown session`,e.sid);return}(e.signal===`SIGINT`||e.signal===`SIGTERM`||e.signal===`SIGKILL`)&&(t.currentProcess&&this.pm?this.pm.signal(t.currentProcess.pid,e.signal):t.currentExec?.abort())}emit(e){this.transport.send(e)}emitStatus(e,t,n){let r=n?{type:`terminal-status`,sid:e,state:t,error:n}:{type:`terminal-status`,sid:e,state:t};this.emit(r)}};function h3(e){return typeof e==`object`&&!!e&&`source`in e&&`payload`in e}function g3(e){switch(e){case`SIGINT`:return 130;case`SIGTERM`:return 143;case`SIGKILL`:return 137;case`SIGSTOP`:case`SIGCONT`:return 130}}function _3(e){if(typeof e!=`object`||!e)return!1;let t=e.type;return t===`terminal-open`||t===`terminal-close`||t===`terminal-exec`||t===`terminal-signal`||t===`terminal-stdin`||t===`terminal-resize`}function v3(e){let{transport:t,fs:n,browser:r,processManager:i}=e,a=new m3({transport:t,processManager:i,createShell:(e,t)=>new H0({fs:n,cwd:t.cwd,env:t.env,browserAPI:r,processManager:i,processOwner:{kind:`system`}}),logger:e.logger??console});return{host:a,stop:a.start()}}function y3(e,t={}){let n=t.onError??(e=>console.error(`[kernel-worker] boot failed`,e)),r=t.onDuplicate??(()=>console.warn(`[kernel-worker] received duplicate kernel-worker-init; ignoring`)),i=!1;return{handle(t){if(i){r();return}i=!0,e(t).catch(e=>{i=!1,n(e)})},isInitialized(){return i}}}const b3=`x-bypass-llm-proxy`;function x3(e,t){return t?(n,r)=>{if(!S3(n,t))return e(n,r);let i=new Headers(r?.headers);return i.has(b3)||i.set(b3,`1`),e(n,{...r,headers:i})}:e}function S3(e,t){let n;n=typeof e==`string`?e:e instanceof URL?e.href:e.url;try{return new URL(n,t).origin===t}catch{return!0}}function C3(){let e=globalThis.fetch;if(!e)return;let t=typeof self<`u`&&self.location?self.location.origin:void 0;globalThis.fetch=x3(e.bind(globalThis),t)}function w3(e){let t=new Map(Object.entries(e));Object.defineProperty(globalThis,`localStorage`,{value:{get length(){return t.size},key(e){return Array.from(t.keys())[e]??null},getItem(e){return t.has(e)?t.get(e):null},setItem(e,n){t.set(e,n)},removeItem(e){t.delete(e)},clear(){t.clear()}},configurable:!0,writable:!0})}let T3=null,E3=null,D3=null;const O3=y3(e=>k3(e));self.addEventListener(`message`,e=>{e.data?.type===`kernel-worker-init`&&O3.handle(e.data)});async function k3(e){C3(),w3(e.localStorageSeed??{}),await ze();let t=f3(e.kernelPort),n=new xt(t),r=xt.createCallbacks(n),i=new p3(e.cdpPort);await i.connect();let a=new Qe(i);T3=await l3({container:{},browser:a,bridge:n,callbacks:r,logger:console});let{createSprinkleManagerProxyOverChannel:o}=await import(`./sprinkle-bridge-channel-DhKQ_srk.js`);globalThis.__slicc_sprinkleManager=o({instanceId:e.instanceId});let{createPanelRpcClient:s}=await Promise.resolve().then(()=>XK);D3=s({instanceId:e.instanceId}),globalThis.__slicc_panelRpc=D3;let c=T3.processManager,l=T3.sharedFs;l?E3=v3({transport:t,fs:l,browser:a,processManager:c,logger:console}).stop:console.warn(`[kernel-worker] shared FS unavailable; terminal sessions will fail to open`),e.kernelPort.postMessage({type:`kernel-worker-ready`})}self.addEventListener(`message`,e=>{e.data?.type===`kernel-worker-shutdown`&&(E3?.(),E3=null,D3?.dispose(),D3=null,T3?.dispose())});export{vK as a,WR as c,BR as d,FR as f,st as h,tq as i,UR as l,ht as m,cQ as n,OB as o,gt as p,eQ as r,ZR as s,sQ as t,VR as u};
|