typebulb 0.62.8 → 0.63.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,176 +1,176 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __cr } from 'module'; const require = __cr(import.meta.url);
3
- var px=Object.create;var Gl=Object.defineProperty;var hx=Object.getOwnPropertyDescriptor;var mx=Object.getOwnPropertyNames;var gx=Object.getPrototypeOf,yx=Object.prototype.hasOwnProperty;var Ni=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var S=(t,e)=>()=>(t&&(e=t(t=0)),e);var I=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Li=(t,e)=>{for(var n in e)Gl(t,n,{get:e[n],enumerable:!0})},bx=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of mx(e))!yx.call(t,s)&&s!==n&&Gl(t,s,{get:()=>e[s],enumerable:!(r=hx(e,s))||r.enumerable});return t};var wx=(t,e,n)=>(n=t!=null?px(gx(t)):{},bx(e||!t||!t.__esModule?Gl(n,"default",{value:t,enumerable:!0}):n,t));import*as jp from"fs/promises";import{existsSync as Jn,readFileSync as vx}from"fs";import*as le from"path";import{pathToFileURL as Sx}from"url";import{resolve as Ql}from"resolve.exports";import{init as Fp,parse as Up}from"es-module-lexer";function qp(t,e){let n=le.join(t,"package.json");try{return JSON.parse(vx(n,"utf8"))}catch{throw new Error(`--replace package '${e}' has no readable package.json at ${n}`)}}function Jp(t){let e=t.indexOf("=");if(e===-1)throw new Error(`--replace must be <name>=<path> (got '${t}')`);let n=t.slice(0,e).trim(),r=t.slice(e+1).trim();if(!n)throw new Error(`--replace missing package name (got '${t}')`);if(!r)throw new Error(`--replace missing path for '${n}'`);if(n.startsWith("@"))throw new Error(`--replace does not support scoped names yet; '${n}' is scoped`);return{name:n,dir:le.resolve(r)}}async function Wp(t){let{name:e,dir:n}=t;if(!Jn(n))throw new Error(`--replace path for '${e}' does not exist: ${n}`);let r=qp(n,e),s=kx(r,e),i=le.resolve(n,s);if(!Jn(i))throw new Error(`--replace package '${e}' entry not found on disk: ${i} \u2014 did you build it (e.g. \`pnpm run build\`)?`);let o=le.dirname(i),a=`/local/${e}/${le.basename(i)}`,l=xx(r,n);return await Ex(e,i,o),{name:e,dir:n,entryAbs:i,serveDir:o,entryUrl:a,typesAbs:l}}function kx(t,e){if(t.exports!==void 0){let r;try{r=Ql(t,".",{browser:!0,conditions:Xl})}catch(i){throw new Error(`--replace package '${e}' "exports" does not resolve a browser entry (conditions: ${Xl.join(", ")}): ${i instanceof Error?i.message:i}`)}let s=Zl(r);if(!s)throw new Error(`--replace package '${e}' "exports" did not resolve "." to a single file (conditions: ${Xl.join(", ")}); too complex to override.`);return s}let n=t.module??t.main;if(!n)throw new Error(`--replace package '${e}' has no "exports", "module", or "main" entry to resolve.`);return n}function xx(t,e){if(t.exports!==void 0)try{let r=Ql(t,".",{conditions:["types"]}),s=Zl(r);if(s){let i=le.resolve(e,s);if(Jn(i))return i}}catch{}let n=t.types??t.typings;if(n){let r=le.resolve(e,n);if(Jn(r))return r}}function Zl(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.find(e=>typeof e=="string")}async function Ex(t,e,n){await Fp;let r=le.normalize(n),s=new Set,i=[e];for(;i.length;){let o=i.shift();if(s.has(o))continue;s.add(o);let a;try{a=await jp.readFile(o,"utf8")}catch{continue}let l,c;try{[l,,,c]=Up(a,o)}catch{continue}if(o===e&&!c)throw new Error(`override package '${t}' entry is not an ES module (no import/export syntax); CommonJS or non-module entries aren't supported (esm.sh would have to transform it).`);for(let f of l){if(f.d===-2)continue;let d=f.n;if(d&&!d.startsWith("node:")){if(d.startsWith("./")||d.startsWith("../")||d.startsWith("/")){let u=Ax(o,d,r);u&&!s.has(u)&&i.push(u);continue}throw new Error(`override package must ship self-contained (bundle its dependencies); ${t} externalizes '${d}'`)}}}}function Ax(t,e,n){let r=e.replace(/[?#].*$/,""),s=le.resolve(le.dirname(t),r),i=[s,s+".js",s+".mjs",le.join(s,"index.js"),le.join(s,"index.mjs")];for(let o of i)if(le.normalize(o).startsWith(n)&&Jn(o))return o}function Tx(t,e,n){let r=qp(t,e),s;if(r.exports!==void 0)try{s=Zl(Ql(r,n,{conditions:Bp}))}catch(o){throw new Error(`--replace package '${e}' "exports" does not resolve a node entry for '${n}' (conditions: ${Bp.join(", ")}): ${o instanceof Error?o.message:o}`)}else n==="."&&(s=r.main??r.module);if(!s)throw new Error(`--replace package '${e}' has no node export for '${n}'.`);let i=le.resolve(t,s);if(!Jn(i))throw new Error(`--replace package '${e}' built file not found: ${i} \u2014 did you build it (e.g. \`pnpm run build\`)?`);return Sx(i).href}async function Kp(t,e){await Fp;let n;try{[n]=Up(t)}catch{return t}let r="",s=0;for(let i of n){if(i.d!==-1)continue;let o=i.n;if(!o||o!==e.name&&!o.startsWith(e.name+"/"))continue;let a=o===e.name?".":"."+o.slice(e.name.length),l=Tx(e.dir,e.name,a);r+=t.slice(s,i.s)+l,s=i.e}return r+t.slice(s)}var Xl,Bp,Mi=S(()=>{"use strict";Xl=["browser","import","default"],Bp=["node","import","default"]});function Hp(t){return Ye.find(e=>de[e].path===t)}function Yp(t){return!!t?.startsWith("typebulb")}var de,Ye,zp,Di=S(()=>{de={code:{path:"code.tsx",language:"typescript"},css:{path:"styles.css",language:"css"},html:{path:"index.html",language:"html"},config:{path:"config.json",language:"json"},notes:{path:"notes.md",language:"markdown"},data:{path:"data.txt",language:"text"},infer:{path:"infer.md",language:"markdown"},insight:{path:"insight.json",language:"json"}},Ye=["code","css","html","data","infer","insight","config","notes"];zp="typebulb/v1"});function ec(t){return/[:\n"']/.test(t)||t.startsWith(" ")||t.endsWith(" ")?`"${t.replace(/"/g,'\\"')}"`:t}function tc(t){return t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1).replace(/\\"/g,'"'):t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}var Bi=S(()=>{});function Wn(t){let e=Gp(t);if("reason"in e)throw new Error(`Invalid .bulb.md file format: ${e.reason}`);return e.bulb}function Ve(t){let e=Gp(t);return"bulb"in e?e.bulb:void 0}function Gp(t){try{let e=t.split(`
4
- `),n=0;if(e[n]?.trim()!=="---")return{reason:Ox(t,e)};n++;let r=[];for(;n<e.length&&e[n]?.trim()!=="---";)r.push(e[n]),n++;if(e[n]?.trim()!=="---")return{reason:"the frontmatter opened on line 1 but never closed (no second '---')"};n++;let s=Rx(r);if(!Yp(s.format))return{reason:s.format?`frontmatter 'format: ${s.format}' is not a typebulb format (expected 'format: typebulb/v1')`:"frontmatter has no 'format:' (expected 'format: typebulb/v1')"};if(!s.name)return{reason:"frontmatter has no 'name:'"};let i=s,o=new Map,a=new Map,l=[],c=n;for(;n<e.length;){let d=e[n]?.trim()?.match(Vp);if(d){let u=d[1].trim();for(n++;n<e.length&&e[n]?.trim()==="";)n++;let p=e[n]?.match(ji);if(!p){l.push(`**${u}** has no code fence \u2014 block skipped`);continue}let h=p[1];n++;let m=n+1,g=[],b=nc(h);for(;n<e.length&&!e[n]?.match(b);)g.push(e[n]),n++;let C=n<e.length;n++,l.push(...Px(u,g,C)),o.set(u,g.join(`
5
- `)),a.set(u,m),c=n}else n++}return{bulb:{frontmatter:i,files:o,warnings:l,bodyEndLine:c,starts:a}}}catch(e){return{reason:`unexpected parse error: ${e instanceof Error?e.message:String(e)}`}}}function Ox(t,e){let n=Ix(t)[0];if(n&&n.start>0)return`expected '---' on line 1; the frontmatter starts on line ${n.start+1} instead. Is there content above it?`;let r=e.find(s=>s.trim())?.trim()??"";return r?`expected '---' on line 1, found '${r.length>40?`${r.slice(0,40)}\u2026`:r}'`:"expected '---' on line 1, found an empty file"}function Px(t,e,n){let r=[];for(let s=0;s<e.length;s++){let i=e[s]?.trim().match(Vp);i&&Cx.has(i[1].trim())&&_x(e,s)&&r.push(i[1].trim())}return r.length?r.map(s=>`**${t}** block has an unterminated code fence \u2014 it swallowed the **${s}** block.`):n?[]:[`**${t}** block has an unterminated code fence (it runs to the end of the file).`]}function _x(t,e){let n=e+1;for(;n<t.length&&t[n]?.trim()==="";)n++;return!!t[n]?.match(ji)}function Rx(t){let e={};for(let n of t){let r=n.indexOf(":");if(r===-1)continue;let s=n.slice(0,r).trim(),i=n.slice(r+1).trim();switch(s){case"format":e.format=i;break;case"name":e.name=tc(i);break}}return e}function Xp(t){return Ve(t)?.warnings??[]}function Ix(t){let e=t.split(`
6
- `),n=[],r=0;for(;r<e.length;){if(e[r]?.trim()!=="---"){r++;continue}let s=Ve(e.slice(r).join(`
3
+ var Fx=Object.create;var nl=Object.defineProperty;var Ux=Object.getOwnPropertyDescriptor;var qx=Object.getOwnPropertyNames;var Jx=Object.getPrototypeOf,Wx=Object.prototype.hasOwnProperty;var Ui=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var k=(t,e)=>()=>(t&&(e=t(t=0)),e);var $=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),qi=(t,e)=>{for(var n in e)nl(t,n,{get:e[n],enumerable:!0})},Kx=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of qx(e))!Wx.call(t,s)&&s!==n&&nl(t,s,{get:()=>e[s],enumerable:!(r=Ux(e,s))||r.enumerable});return t};var Hx=(t,e,n)=>(n=t!=null?Fx(Jx(t)):{},Kx(e||!t||!t.__esModule?nl(n,"default",{value:t,enumerable:!0}):n,t));import*as Vp from"fs/promises";import{existsSync as Kn,readFileSync as zx}from"fs";import*as ce from"path";import{pathToFileURL as Yx}from"url";import{resolve as sl}from"resolve.exports";import{init as Gp,parse as Xp}from"es-module-lexer";function Qp(t,e){let n=ce.join(t,"package.json");try{return JSON.parse(zx(n,"utf8"))}catch{throw new Error(`--replace package '${e}' has no readable package.json at ${n}`)}}function Zp(t){let e=t.indexOf("=");if(e===-1)throw new Error(`--replace must be <name>=<path> (got '${t}')`);let n=t.slice(0,e).trim(),r=t.slice(e+1).trim();if(!n)throw new Error(`--replace missing package name (got '${t}')`);if(!r)throw new Error(`--replace missing path for '${n}'`);if(n.startsWith("@"))throw new Error(`--replace does not support scoped names yet; '${n}' is scoped`);return{name:n,dir:ce.resolve(r)}}async function eh(t){let{name:e,dir:n}=t;if(!Kn(n))throw new Error(`--replace path for '${e}' does not exist: ${n}`);let r=Qp(n,e),s=Vx(r,e),i=ce.resolve(n,s);if(!Kn(i))throw new Error(`--replace package '${e}' entry not found on disk: ${i} \u2014 did you build it (e.g. \`pnpm run build\`)?`);let o=ce.dirname(i),a=`/local/${e}/${ce.basename(i)}`,c=Gx(r,n);return await Xx(e,i,o),{name:e,dir:n,entryAbs:i,serveDir:o,entryUrl:a,typesAbs:c}}function Vx(t,e){if(t.exports!==void 0){let r;try{r=sl(t,".",{browser:!0,conditions:rl})}catch(i){throw new Error(`--replace package '${e}' "exports" does not resolve a browser entry (conditions: ${rl.join(", ")}): ${i instanceof Error?i.message:i}`)}let s=il(r);if(!s)throw new Error(`--replace package '${e}' "exports" did not resolve "." to a single file (conditions: ${rl.join(", ")}); too complex to override.`);return s}let n=t.module??t.main;if(!n)throw new Error(`--replace package '${e}' has no "exports", "module", or "main" entry to resolve.`);return n}function Gx(t,e){if(t.exports!==void 0)try{let r=sl(t,".",{conditions:["types"]}),s=il(r);if(s){let i=ce.resolve(e,s);if(Kn(i))return i}}catch{}let n=t.types??t.typings;if(n){let r=ce.resolve(e,n);if(Kn(r))return r}}function il(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.find(e=>typeof e=="string")}async function Xx(t,e,n){await Gp;let r=ce.normalize(n),s=new Set,i=[e];for(;i.length;){let o=i.shift();if(s.has(o))continue;s.add(o);let a;try{a=await Vp.readFile(o,"utf8")}catch{continue}let c,l;try{[c,,,l]=Xp(a,o)}catch{continue}if(o===e&&!l)throw new Error(`override package '${t}' entry is not an ES module (no import/export syntax); CommonJS or non-module entries aren't supported (esm.sh would have to transform it).`);for(let f of c){if(f.d===-2)continue;let u=f.n;if(u&&!u.startsWith("node:")){if(u.startsWith("./")||u.startsWith("../")||u.startsWith("/")){let d=Qx(o,u,r);d&&!s.has(d)&&i.push(d);continue}throw new Error(`override package must ship self-contained (bundle its dependencies); ${t} externalizes '${u}'`)}}}}function Qx(t,e,n){let r=e.replace(/[?#].*$/,""),s=ce.resolve(ce.dirname(t),r),i=[s,s+".js",s+".mjs",ce.join(s,"index.js"),ce.join(s,"index.mjs")];for(let o of i)if(ce.normalize(o).startsWith(n)&&Kn(o))return o}function Zx(t,e,n){let r=Qp(t,e),s;if(r.exports!==void 0)try{s=il(sl(r,n,{conditions:Yp}))}catch(o){throw new Error(`--replace package '${e}' "exports" does not resolve a node entry for '${n}' (conditions: ${Yp.join(", ")}): ${o instanceof Error?o.message:o}`)}else n==="."&&(s=r.main??r.module);if(!s)throw new Error(`--replace package '${e}' has no node export for '${n}'.`);let i=ce.resolve(t,s);if(!Kn(i))throw new Error(`--replace package '${e}' built file not found: ${i} \u2014 did you build it (e.g. \`pnpm run build\`)?`);return Yx(i).href}async function th(t,e){await Gp;let n;try{[n]=Xp(t)}catch{return t}let r="",s=0;for(let i of n){if(i.d!==-1)continue;let o=i.n;if(!o||o!==e.name&&!o.startsWith(e.name+"/"))continue;let a=o===e.name?".":"."+o.slice(e.name.length),c=Zx(e.dir,e.name,a);r+=t.slice(s,i.s)+c,s=i.e}return r+t.slice(s)}var rl,Yp,Ji=k(()=>{"use strict";rl=["browser","import","default"],Yp=["node","import","default"]});function nh(t){return Ve.find(e=>pe[e].path===t)}function sh(t){return!!t?.startsWith("typebulb")}var pe,Ve,rh,Wi=k(()=>{pe={code:{path:"code.tsx",language:"typescript"},css:{path:"styles.css",language:"css"},html:{path:"index.html",language:"html"},config:{path:"config.json",language:"json"},notes:{path:"notes.md",language:"markdown"},data:{path:"data.txt",language:"text"},infer:{path:"infer.md",language:"markdown"},insight:{path:"insight.json",language:"json"}},Ve=["code","css","html","data","infer","insight","config","notes"];rh="typebulb/v1"});function ol(t){return/[:\n"']/.test(t)||t.startsWith(" ")||t.endsWith(" ")?`"${t.replace(/"/g,'\\"')}"`:t}function al(t){return t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1).replace(/\\"/g,'"'):t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}var Ki=k(()=>{});function Hn(t){let e=oh(t);if("reason"in e)throw new Error(`Invalid .bulb.md file format: ${e.reason}`);return e.bulb}function Ge(t){let e=oh(t);return"bulb"in e?e.bulb:void 0}function oh(t){try{let e=t.split(`
4
+ `),n=0;if(e[n]?.trim()!=="---")return{reason:t0(t,e)};n++;let r=[];for(;n<e.length&&e[n]?.trim()!=="---";)r.push(e[n]),n++;if(e[n]?.trim()!=="---")return{reason:"the frontmatter opened on line 1 but never closed (no second '---')"};n++;let s=s0(r);if(!sh(s.format))return{reason:s.format?`frontmatter 'format: ${s.format}' is not a typebulb format (expected 'format: typebulb/v1')`:"frontmatter has no 'format:' (expected 'format: typebulb/v1')"};if(!s.name)return{reason:"frontmatter has no 'name:'"};let i=s,o=new Map,a=new Map,c=[],l=n;for(;n<e.length;){let u=e[n]?.trim()?.match(ih);if(u){let d=u[1].trim();for(n++;n<e.length&&e[n]?.trim()==="";)n++;let p=e[n]?.match(Hi);if(!p){c.push(`**${d}** has no code fence \u2014 block skipped`);continue}let h=p[1];n++;let m=n+1,g=[],b=cl(h);for(;n<e.length&&!e[n]?.match(b);)g.push(e[n]),n++;let C=n<e.length;n++,c.push(...n0(d,g,C)),o.set(d,g.join(`
5
+ `)),a.set(d,m),l=n}else n++}return{bulb:{frontmatter:i,files:o,warnings:c,bodyEndLine:l,starts:a}}}catch(e){return{reason:`unexpected parse error: ${e instanceof Error?e.message:String(e)}`}}}function t0(t,e){let n=i0(t)[0];if(n&&n.start>0)return`expected '---' on line 1; the frontmatter starts on line ${n.start+1} instead. Is there content above it?`;let r=e.find(s=>s.trim())?.trim()??"";return r?`expected '---' on line 1, found '${r.length>40?`${r.slice(0,40)}\u2026`:r}'`:"expected '---' on line 1, found an empty file"}function n0(t,e,n){let r=[];for(let s=0;s<e.length;s++){let i=e[s]?.trim().match(ih);i&&e0.has(i[1].trim())&&r0(e,s)&&r.push(i[1].trim())}return r.length?r.map(s=>`**${t}** block has an unterminated code fence \u2014 it swallowed the **${s}** block.`):n?[]:[`**${t}** block has an unterminated code fence (it runs to the end of the file).`]}function r0(t,e){let n=e+1;for(;n<t.length&&t[n]?.trim()==="";)n++;return!!t[n]?.match(Hi)}function s0(t){let e={};for(let n of t){let r=n.indexOf(":");if(r===-1)continue;let s=n.slice(0,r).trim(),i=n.slice(r+1).trim();switch(s){case"format":e.format=i;break;case"name":e.name=al(i);break}}return e}function ah(t){return Ge(t)?.warnings??[]}function i0(t){let e=t.split(`
6
+ `),n=[],r=0;for(;r<e.length;){if(e[r]?.trim()!=="---"){r++;continue}let s=Ge(e.slice(r).join(`
7
7
  `));if(s&&s.files.size>0){let i=r+s.bodyEndLine;n.push({start:r,end:i,source:e.slice(r,i).join(`
8
- `)}),r=i}else r++}return n}function Qp(t){let e=Object.fromEntries(Ye.map(n=>[n,t.files.get(de[n].path)||""]));return{name:t.frontmatter.name,...e}}var Vp,ji,Cx,nc,rc=S(()=>{Di();Bi();Vp=/^\*\*(.+)\*\*$/,ji=/^(`{3,})(\w*)\s*$/,Cx=new Set(Ye.map(t=>de[t].path)),nc=t=>new RegExp(`^${t}\\s*$`)});function Zp(t){let e=t.match(/^`{3,}/gm),n=e?Math.max(...e.map(r=>r.length)):0;return"`".repeat(Math.max(3,n+1))}function eh(t,e){let{path:n}=de[t],r=n.split(".").pop(),s=Zp(e);return`**${n}**
8
+ `)}),r=i}else r++}return n}function ch(t){let e=Object.fromEntries(Ve.map(n=>[n,t.files.get(pe[n].path)||""]));return{name:t.frontmatter.name,...e}}var ih,Hi,e0,cl,ll=k(()=>{Wi();Ki();ih=/^\*\*(.+)\*\*$/,Hi=/^(`{3,})(\w*)\s*$/,e0=new Set(Ve.map(t=>pe[t].path)),cl=t=>new RegExp(`^${t}\\s*$`)});function lh(t){let e=t.match(/^`{3,}/gm),n=e?Math.max(...e.map(r=>r.length)):0;return"`".repeat(Math.max(3,n+1))}function uh(t,e){let{path:n}=pe[t],r=n.split(".").pop(),s=lh(e);return`**${n}**
9
9
 
10
10
  ${s}${r}
11
11
  ${e}
12
- ${s}`}function th(t){let e=Ye.filter(n=>t[n]).map(n=>eh(n,t[n]));return["---",`format: ${zp}`,`name: ${ec(t.name)}`,"---","",...e].join(`
13
- `)}function nh(t,e){for(let n=0;n<t.length;n++){if(t[n]?.trim()!==`**${e}**`)continue;let r=n+1;for(;r<t.length&&t[r]?.trim()==="";)r++;let s=t[r]?.match(ji);if(!s)continue;let i=nc(s[1]),o=r+1;for(;o<t.length&&!t[o]?.match(i);)o++;return o>=t.length?"unterminated":{header:n,open:r,close:o,fence:s[1],lang:s[2]}}}function zr(t,e,n){let r=t.split(`
14
- `),s=nh(r,de[e].path);if(s==="unterminated")return t;if(!s)return`${t.replace(/\s*$/,"")}
12
+ ${s}`}function dh(t){let e=Ve.filter(n=>t[n]).map(n=>uh(n,t[n]));return["---",`format: ${rh}`,`name: ${ol(t.name)}`,"---","",...e].join(`
13
+ `)}function fh(t,e){for(let n=0;n<t.length;n++){if(t[n]?.trim()!==`**${e}**`)continue;let r=n+1;for(;r<t.length&&t[r]?.trim()==="";)r++;let s=t[r]?.match(Hi);if(!s)continue;let i=cl(s[1]),o=r+1;for(;o<t.length&&!t[o]?.match(i);)o++;return o>=t.length?"unterminated":{header:n,open:r,close:o,fence:s[1],lang:s[2]}}}function Zr(t,e,n){let r=t.split(`
14
+ `),s=fh(r,pe[e].path);if(s==="unterminated")return t;if(!s)return`${t.replace(/\s*$/,"")}
15
15
 
16
- ${eh(e,n)}
17
- `;let i=Zp(n),o=i.length>s.fence.length?i:s.fence;return[...r.slice(0,s.open),o+s.lang,...n.split(`
16
+ ${uh(e,n)}
17
+ `;let i=lh(n),o=i.length>s.fence.length?i:s.fence;return[...r.slice(0,s.open),o+s.lang,...n.split(`
18
18
  `),o,...r.slice(s.close+1)].join(`
19
- `)}function rh(t,e){let n=t.split(`
20
- `),r=nh(n,de[e].path);if(!r||r==="unterminated")return t;let s=r.close+1;for(;s<n.length&&n[s]?.trim()==="";)s++;return[...n.slice(0,r.header),...n.slice(s)].join(`
19
+ `)}function ph(t,e){let n=t.split(`
20
+ `),r=fh(n,pe[e].path);if(!r||r==="unterminated")return t;let s=r.close+1;for(;s<n.length&&n[s]?.trim()==="";)s++;return[...n.slice(0,r.header),...n.slice(s)].join(`
21
21
  `).replace(/\s*$/,"")+`
22
- `}var sh=S(()=>{Di();rc();Bi()});function Yr(t){if(!t.trim())return{};try{return JSON.parse(t)}catch{return{}}}function oh(t){switch(ih(t)){case".js":case".mjs":return"text/javascript";case".wasm":return"application/wasm";case".json":case".map":return"application/json";case".svg":return"image/svg+xml";case".png":return"image/png";case".jpg":case".jpeg":return"image/jpeg";case".gif":return"image/gif";case".webp":return"image/webp";case".avif":return"image/avif";case".ico":return"image/x-icon";case".mp3":return"audio/mpeg";case".wav":return"audio/wav";case".ogg":return"audio/ogg";case".m4a":return"audio/mp4";case".mp4":return"video/mp4";case".webm":return"video/webm";case".woff2":return"font/woff2";case".ttf":return"font/ttf";case".css":return"text/css";case".txt":return"text/plain; charset=utf-8";default:return"application/octet-stream"}}function ah(t){let e=ih(t);return e!==void 0&&Nx.has(e)?e:void 0}function Mx(t){return t.replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\*\*([^*]+)\*\*/g,"$1").replace(/\*([^*]+)\*/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/^#{1,6}\s+/gm,"")}function sc(t){let e=Yr(t??"").description?.trim();if(!e)return Lx;let n=Mx(e);return(n.length>200?n.slice(0,197)+"...":n).replace(/\n/g," ")}var $x,Fi,ih,Nx,Lx,lh=S(()=>{$x="https://assets.typebulb.com",Fi=(t,e)=>`${$x}/u/${encodeURIComponent(t)}/${encodeURIComponent(e)}/`,ih=t=>/\.[^./\\]+$/.exec(t)?.[0]?.toLowerCase();Nx=new Set([".html",".htm",".xhtml",".js",".mjs",".cjs",".ts",".tsx",".css"]);Lx="A Typebulb bulb."});var ch=S(()=>{});function ic(t,e,n){let s=new RegExp(e).exec(t.slice(n));return s?n+s.index:-1}var uh=S(()=>{});function Vr(t,e,n){let s=new RegExp(e).exec(t.slice(n));return s?n+s.index+s[0].length-1:-1}var dh=S(()=>{});function Ui(t,e){let n=new RegExp(e,"g"),r=t.match(n);return r?r.length:0}var fh=S(()=>{});function Gr(t,e,n){let r=n&&n.debug||!1,s=!(n&&typeof n.nested===!1),i=n&&n.startIndex||0;r&&console.log("[xml-utils] starting findTagByName with",e," and ",n);let o=ic(t,`<${e}[
23
- >/]`,i);if(r&&console.log("[xml-utils] start:",o),o===-1)return;let a=t.slice(o+e.length),l=Vr(a,"^[^<]*[ /]>",0),c=l!==-1&&a[l-1]==="/";if(r&&console.log("[xml-utils] selfClosing:",c),c===!1)if(s){let p=0,h=1,m=0;for(;(l=Vr(a,"[ /]"+e+">",p))!==-1;){let g=a.substring(p,l+1);if(h+=Ui(g,"<"+e+`[
24
- >]`),m+=Ui(g,"</"+e+">"),m>=h)break;p=l}}else l=Vr(a,"[ /]"+e+">",0);let f=o+e.length+l+1;if(r&&console.log("[xml-utils] end:",f),f===-1)return;let d=t.slice(o,f),u;return c?u=null:u=d.slice(d.indexOf(">")+1,d.lastIndexOf("<")),{inner:u,outer:d,start:o,end:f}}var oc=S(()=>{uh();dh();fh()});var ac=S(()=>{oc()});var lc=S(()=>{ac()});var ph=S(()=>{lc()});var hh=S(()=>{});var mh=S(()=>{ch();oc();ac();ph();lc();hh()});var W=I(me=>{"use strict";var cc=Symbol.for("yaml.alias"),gh=Symbol.for("yaml.document"),qi=Symbol.for("yaml.map"),yh=Symbol.for("yaml.pair"),uc=Symbol.for("yaml.scalar"),Ji=Symbol.for("yaml.seq"),pt=Symbol.for("yaml.node.type"),jx=t=>!!t&&typeof t=="object"&&t[pt]===cc,Fx=t=>!!t&&typeof t=="object"&&t[pt]===gh,Ux=t=>!!t&&typeof t=="object"&&t[pt]===qi,qx=t=>!!t&&typeof t=="object"&&t[pt]===yh,bh=t=>!!t&&typeof t=="object"&&t[pt]===uc,Jx=t=>!!t&&typeof t=="object"&&t[pt]===Ji;function wh(t){if(t&&typeof t=="object")switch(t[pt]){case qi:case Ji:return!0}return!1}function Wx(t){if(t&&typeof t=="object")switch(t[pt]){case cc:case qi:case uc:case Ji:return!0}return!1}var Kx=t=>(bh(t)||wh(t))&&!!t.anchor;me.ALIAS=cc;me.DOC=gh;me.MAP=qi;me.NODE_TYPE=pt;me.PAIR=yh;me.SCALAR=uc;me.SEQ=Ji;me.hasAnchor=Kx;me.isAlias=jx;me.isCollection=wh;me.isDocument=Fx;me.isMap=Ux;me.isNode=Wx;me.isPair=qx;me.isScalar=bh;me.isSeq=Jx});var Xr=I(dc=>{"use strict";var ce=W(),Ee=Symbol("break visit"),vh=Symbol("skip children"),ot=Symbol("remove node");function Wi(t,e){let n=Sh(e);ce.isDocument(t)?Kn(null,t.contents,n,Object.freeze([t]))===ot&&(t.contents=null):Kn(null,t,n,Object.freeze([]))}Wi.BREAK=Ee;Wi.SKIP=vh;Wi.REMOVE=ot;function Kn(t,e,n,r){let s=kh(t,e,n,r);if(ce.isNode(s)||ce.isPair(s))return xh(t,r,s),Kn(t,s,n,r);if(typeof s!="symbol"){if(ce.isCollection(e)){r=Object.freeze(r.concat(e));for(let i=0;i<e.items.length;++i){let o=Kn(i,e.items[i],n,r);if(typeof o=="number")i=o-1;else{if(o===Ee)return Ee;o===ot&&(e.items.splice(i,1),i-=1)}}}else if(ce.isPair(e)){r=Object.freeze(r.concat(e));let i=Kn("key",e.key,n,r);if(i===Ee)return Ee;i===ot&&(e.key=null);let o=Kn("value",e.value,n,r);if(o===Ee)return Ee;o===ot&&(e.value=null)}}return s}async function Ki(t,e){let n=Sh(e);ce.isDocument(t)?await Hn(null,t.contents,n,Object.freeze([t]))===ot&&(t.contents=null):await Hn(null,t,n,Object.freeze([]))}Ki.BREAK=Ee;Ki.SKIP=vh;Ki.REMOVE=ot;async function Hn(t,e,n,r){let s=await kh(t,e,n,r);if(ce.isNode(s)||ce.isPair(s))return xh(t,r,s),Hn(t,s,n,r);if(typeof s!="symbol"){if(ce.isCollection(e)){r=Object.freeze(r.concat(e));for(let i=0;i<e.items.length;++i){let o=await Hn(i,e.items[i],n,r);if(typeof o=="number")i=o-1;else{if(o===Ee)return Ee;o===ot&&(e.items.splice(i,1),i-=1)}}}else if(ce.isPair(e)){r=Object.freeze(r.concat(e));let i=await Hn("key",e.key,n,r);if(i===Ee)return Ee;i===ot&&(e.key=null);let o=await Hn("value",e.value,n,r);if(o===Ee)return Ee;o===ot&&(e.value=null)}}return s}function Sh(t){return typeof t=="object"&&(t.Collection||t.Node||t.Value)?Object.assign({Alias:t.Node,Map:t.Node,Scalar:t.Node,Seq:t.Node},t.Value&&{Map:t.Value,Scalar:t.Value,Seq:t.Value},t.Collection&&{Map:t.Collection,Seq:t.Collection},t):t}function kh(t,e,n,r){if(typeof n=="function")return n(t,e,r);if(ce.isMap(e))return n.Map?.(t,e,r);if(ce.isSeq(e))return n.Seq?.(t,e,r);if(ce.isPair(e))return n.Pair?.(t,e,r);if(ce.isScalar(e))return n.Scalar?.(t,e,r);if(ce.isAlias(e))return n.Alias?.(t,e,r)}function xh(t,e,n){let r=e[e.length-1];if(ce.isCollection(r))r.items[t]=n;else if(ce.isPair(r))t==="key"?r.key=n:r.value=n;else if(ce.isDocument(r))r.contents=n;else{let s=ce.isAlias(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${s} parent`)}}dc.visit=Wi;dc.visitAsync=Ki});var fc=I(Ah=>{"use strict";var Eh=W(),Hx=Xr(),zx={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Yx=t=>t.replace(/[!,[\]{}]/g,e=>zx[e]),Qr=class t{constructor(e,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},t.defaultYaml,e),this.tags=Object.assign({},t.defaultTags,n)}clone(){let e=new t(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new t(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:t.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},t.defaultTags);break}return e}add(e,n){this.atNextDocument&&(this.yaml={explicit:t.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},t.defaultTags),this.atNextDocument=!1);let r=e.trim().split(/[ \t]+/),s=r.shift();switch(s){case"%TAG":{if(r.length!==2&&(n(0,"%TAG directive should contain exactly two parts"),r.length<2))return!1;let[i,o]=r;return this.tags[i]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,r.length!==1)return n(0,"%YAML directive should contain exactly one part"),!1;let[i]=r;if(i==="1.1"||i==="1.2")return this.yaml.version=i,!0;{let o=/^\d+\.\d+$/.test(i);return n(6,`Unsupported YAML version ${i}`,o),!1}}default:return n(0,`Unknown directive ${s}`,!0),!1}}tagName(e,n){if(e==="!")return"!";if(e[0]!=="!")return n(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let o=e.slice(2,-1);return o==="!"||o==="!!"?(n(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&n("Verbatim tags must end with a >"),o)}let[,r,s]=e.match(/^(.*!)([^!]*)$/s);s||n(`The ${e} tag has no suffix`);let i=this.tags[r];if(i)try{return i+decodeURIComponent(s)}catch(o){return n(String(o)),null}return r==="!"?e:(n(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[n,r]of Object.entries(this.tags))if(e.startsWith(r))return n+Yx(e.substring(r.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let n=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags),s;if(e&&r.length>0&&Eh.isNode(e.contents)){let i={};Hx.visit(e.contents,(o,a)=>{Eh.isNode(a)&&a.tag&&(i[a.tag]=!0)}),s=Object.keys(i)}else s=[];for(let[i,o]of r)i==="!!"&&o==="tag:yaml.org,2002:"||(!e||s.some(a=>a.startsWith(o)))&&n.push(`%TAG ${i} ${o}`);return n.join(`
25
- `)}};Qr.defaultYaml={explicit:!1,version:"1.2"};Qr.defaultTags={"!!":"tag:yaml.org,2002:"};Ah.Directives=Qr});var Hi=I(Zr=>{"use strict";var Th=W(),Vx=Xr();function Gx(t){if(/[\x00-\x19\s,[\]{}]/.test(t)){let n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(t)}`;throw new Error(n)}return!0}function Ch(t){let e=new Set;return Vx.visit(t,{Value(n,r){r.anchor&&e.add(r.anchor)}}),e}function Oh(t,e){for(let n=1;;++n){let r=`${t}${n}`;if(!e.has(r))return r}}function Xx(t,e){let n=[],r=new Map,s=null;return{onAnchor:i=>{n.push(i),s??(s=Ch(t));let o=Oh(e,s);return s.add(o),o},setAnchors:()=>{for(let i of n){let o=r.get(i);if(typeof o=="object"&&o.anchor&&(Th.isScalar(o.node)||Th.isCollection(o.node)))o.node.anchor=o.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=i,a}}},sourceObjects:r}}Zr.anchorIsValid=Gx;Zr.anchorNames=Ch;Zr.createNodeAnchors=Xx;Zr.findNewAnchor=Oh});var pc=I(Ph=>{"use strict";function es(t,e,n,r){if(r&&typeof r=="object")if(Array.isArray(r))for(let s=0,i=r.length;s<i;++s){let o=r[s],a=es(t,r,String(s),o);a===void 0?delete r[s]:a!==o&&(r[s]=a)}else if(r instanceof Map)for(let s of Array.from(r.keys())){let i=r.get(s),o=es(t,r,s,i);o===void 0?r.delete(s):o!==i&&r.set(s,o)}else if(r instanceof Set)for(let s of Array.from(r)){let i=es(t,r,s,s);i===void 0?r.delete(s):i!==s&&(r.delete(s),r.add(i))}else for(let[s,i]of Object.entries(r)){let o=es(t,r,s,i);o===void 0?delete r[s]:o!==i&&(r[s]=o)}return t.call(e,n,r)}Ph.applyReviver=es});var It=I(Rh=>{"use strict";var Qx=W();function _h(t,e,n){if(Array.isArray(t))return t.map((r,s)=>_h(r,String(s),n));if(t&&typeof t.toJSON=="function"){if(!n||!Qx.hasAnchor(t))return t.toJSON(e,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(t,r),n.onCreate=i=>{r.res=i,delete n.onCreate};let s=t.toJSON(e,n);return n.onCreate&&n.onCreate(s),s}return typeof t=="bigint"&&!n?.keep?Number(t):t}Rh.toJS=_h});var zi=I($h=>{"use strict";var Zx=pc(),Ih=W(),e0=It(),hc=class{constructor(e){Object.defineProperty(this,Ih.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:n,maxAliasCount:r,onAnchor:s,reviver:i}={}){if(!Ih.isDocument(e))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:e,keep:!0,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},a=e0.toJS(this,"",o);if(typeof s=="function")for(let{count:l,res:c}of o.anchors.values())s(c,l);return typeof i=="function"?Zx.applyReviver(i,{"":a},"",a):a}};$h.NodeBase=hc});var ts=I(Nh=>{"use strict";var t0=Hi(),n0=Xr(),zn=W(),r0=zi(),s0=It(),mc=class extends r0.NodeBase{constructor(e){super(zn.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,n){let r;n?.aliasResolveCache?r=n.aliasResolveCache:(r=[],n0.visit(e,{Node:(i,o)=>{(zn.isAlias(o)||zn.hasAnchor(o))&&r.push(o)}}),n&&(n.aliasResolveCache=r));let s;for(let i of r){if(i===this)break;i.anchor===this.source&&(s=i)}return s}toJSON(e,n){if(!n)return{source:this.source};let{anchors:r,doc:s,maxAliasCount:i}=n,o=this.resolve(s,n);if(!o){let l=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(l)}let a=r.get(o);if(a||(s0.toJS(o,null,n),a=r.get(o)),a?.res===void 0){let l="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(l)}if(i>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=Yi(s,o,r)),a.count*a.aliasCount>i)){let l="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(l)}return a.res}toString(e,n,r){let s=`*${this.source}`;if(e){if(t0.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let i=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(i)}if(e.implicitKey)return`${s} `}return s}};function Yi(t,e,n){if(zn.isAlias(e)){let r=e.resolve(t),s=n&&r&&n.get(r);return s?s.count*s.aliasCount:0}else if(zn.isCollection(e)){let r=0;for(let s of e.items){let i=Yi(t,s,n);i>r&&(r=i)}return r}else if(zn.isPair(e)){let r=Yi(t,e.key,n),s=Yi(t,e.value,n);return Math.max(r,s)}return 1}Nh.Alias=mc});var re=I(gc=>{"use strict";var i0=W(),o0=zi(),a0=It(),l0=t=>!t||typeof t!="function"&&typeof t!="object",$t=class extends o0.NodeBase{constructor(e){super(i0.SCALAR),this.value=e}toJSON(e,n){return n?.keep?this.value:a0.toJS(this.value,e,n)}toString(){return String(this.value)}};$t.BLOCK_FOLDED="BLOCK_FOLDED";$t.BLOCK_LITERAL="BLOCK_LITERAL";$t.PLAIN="PLAIN";$t.QUOTE_DOUBLE="QUOTE_DOUBLE";$t.QUOTE_SINGLE="QUOTE_SINGLE";gc.Scalar=$t;gc.isScalarValue=l0});var ns=I(Mh=>{"use strict";var c0=ts(),cn=W(),Lh=re(),u0="tag:yaml.org,2002:";function d0(t,e,n){if(e){let r=n.filter(i=>i.tag===e),s=r.find(i=>!i.format)??r[0];if(!s)throw new Error(`Tag ${e} not found`);return s}return n.find(r=>r.identify?.(t)&&!r.format)}function f0(t,e,n){if(cn.isDocument(t)&&(t=t.contents),cn.isNode(t))return t;if(cn.isPair(t)){let d=n.schema[cn.MAP].createNode?.(n.schema,null,n);return d.items.push(t),d}(t instanceof String||t instanceof Number||t instanceof Boolean||typeof BigInt<"u"&&t instanceof BigInt)&&(t=t.valueOf());let{aliasDuplicateObjects:r,onAnchor:s,onTagObj:i,schema:o,sourceObjects:a}=n,l;if(r&&t&&typeof t=="object"){if(l=a.get(t),l)return l.anchor??(l.anchor=s(t)),new c0.Alias(l.anchor);l={anchor:null,node:null},a.set(t,l)}e?.startsWith("!!")&&(e=u0+e.slice(2));let c=d0(t,e,o.tags);if(!c){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let d=new Lh.Scalar(t);return l&&(l.node=d),d}c=t instanceof Map?o[cn.MAP]:Symbol.iterator in Object(t)?o[cn.SEQ]:o[cn.MAP]}i&&(i(c),delete n.onTagObj);let f=c?.createNode?c.createNode(n.schema,t,n):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(n.schema,t,n):new Lh.Scalar(t);return e?f.tag=e:c.default||(f.tag=c.tag),l&&(l.node=f),f}Mh.createNode=f0});var Gi=I(Vi=>{"use strict";var p0=ns(),at=W(),h0=zi();function yc(t,e,n){let r=n;for(let s=e.length-1;s>=0;--s){let i=e[s];if(typeof i=="number"&&Number.isInteger(i)&&i>=0){let o=[];o[i]=r,r=o}else r=new Map([[i,r]])}return p0.createNode(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:t,sourceObjects:new Map})}var Dh=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,bc=class extends h0.NodeBase{constructor(e,n){super(e),Object.defineProperty(this,"schema",{value:n,configurable:!0,enumerable:!1,writable:!0})}clone(e){let n=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(n.schema=e),n.items=n.items.map(r=>at.isNode(r)||at.isPair(r)?r.clone(e):r),this.range&&(n.range=this.range.slice()),n}addIn(e,n){if(Dh(e))this.add(n);else{let[r,...s]=e,i=this.get(r,!0);if(at.isCollection(i))i.addIn(s,n);else if(i===void 0&&this.schema)this.set(r,yc(this.schema,s,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${s}`)}}deleteIn(e){let[n,...r]=e;if(r.length===0)return this.delete(n);let s=this.get(n,!0);if(at.isCollection(s))return s.deleteIn(r);throw new Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}getIn(e,n){let[r,...s]=e,i=this.get(r,!0);return s.length===0?!n&&at.isScalar(i)?i.value:i:at.isCollection(i)?i.getIn(s,n):void 0}hasAllNullValues(e){return this.items.every(n=>{if(!at.isPair(n))return!1;let r=n.value;return r==null||e&&at.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[n,...r]=e;if(r.length===0)return this.has(n);let s=this.get(n,!0);return at.isCollection(s)?s.hasIn(r):!1}setIn(e,n){let[r,...s]=e;if(s.length===0)this.set(r,n);else{let i=this.get(r,!0);if(at.isCollection(i))i.setIn(s,n);else if(i===void 0&&this.schema)this.set(r,yc(this.schema,s,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${s}`)}}};Vi.Collection=bc;Vi.collectionFromPath=yc;Vi.isEmptyPath=Dh});var rs=I(Xi=>{"use strict";var m0=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function wc(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var g0=(t,e,n)=>t.endsWith(`
26
- `)?wc(n,e):n.includes(`
22
+ `}var hh=k(()=>{Wi();ll();Ki()});function es(t){if(!t.trim())return{};try{return JSON.parse(t)}catch{return{}}}function gh(t){switch(mh(t)){case".js":case".mjs":return"text/javascript";case".wasm":return"application/wasm";case".json":case".map":return"application/json";case".svg":return"image/svg+xml";case".png":return"image/png";case".jpg":case".jpeg":return"image/jpeg";case".gif":return"image/gif";case".webp":return"image/webp";case".avif":return"image/avif";case".ico":return"image/x-icon";case".mp3":return"audio/mpeg";case".wav":return"audio/wav";case".ogg":return"audio/ogg";case".m4a":return"audio/mp4";case".mp4":return"video/mp4";case".webm":return"video/webm";case".woff2":return"font/woff2";case".ttf":return"font/ttf";case".css":return"text/css";case".txt":return"text/plain; charset=utf-8";default:return"application/octet-stream"}}function yh(t){let e=mh(t);return e!==void 0&&a0.has(e)?e:void 0}function l0(t){return t.replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\*\*([^*]+)\*\*/g,"$1").replace(/\*([^*]+)\*/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/^#{1,6}\s+/gm,"")}function ul(t){let e=es(t??"").description?.trim();if(!e)return c0;let n=l0(e);return(n.length>200?n.slice(0,197)+"...":n).replace(/\n/g," ")}var o0,zi,mh,a0,c0,bh=k(()=>{o0="https://assets.typebulb.com",zi=(t,e)=>`${o0}/u/${encodeURIComponent(t)}/${encodeURIComponent(e)}/`,mh=t=>/\.[^./\\]+$/.exec(t)?.[0]?.toLowerCase();a0=new Set([".html",".htm",".xhtml",".js",".mjs",".cjs",".ts",".tsx",".css"]);c0="A Typebulb bulb."});var wh=k(()=>{});function dl(t,e,n){let s=new RegExp(e).exec(t.slice(n));return s?n+s.index:-1}var vh=k(()=>{});function ts(t,e,n){let s=new RegExp(e).exec(t.slice(n));return s?n+s.index+s[0].length-1:-1}var Sh=k(()=>{});function Yi(t,e){let n=new RegExp(e,"g"),r=t.match(n);return r?r.length:0}var kh=k(()=>{});function ns(t,e,n){let r=n&&n.debug||!1,s=!(n&&typeof n.nested===!1),i=n&&n.startIndex||0;r&&console.log("[xml-utils] starting findTagByName with",e," and ",n);let o=dl(t,`<${e}[
23
+ >/]`,i);if(r&&console.log("[xml-utils] start:",o),o===-1)return;let a=t.slice(o+e.length),c=ts(a,"^[^<]*[ /]>",0),l=c!==-1&&a[c-1]==="/";if(r&&console.log("[xml-utils] selfClosing:",l),l===!1)if(s){let p=0,h=1,m=0;for(;(c=ts(a,"[ /]"+e+">",p))!==-1;){let g=a.substring(p,c+1);if(h+=Yi(g,"<"+e+`[
24
+ >]`),m+=Yi(g,"</"+e+">"),m>=h)break;p=c}}else c=ts(a,"[ /]"+e+">",0);let f=o+e.length+c+1;if(r&&console.log("[xml-utils] end:",f),f===-1)return;let u=t.slice(o,f),d;return l?d=null:d=u.slice(u.indexOf(">")+1,u.lastIndexOf("<")),{inner:d,outer:u,start:o,end:f}}var fl=k(()=>{vh();Sh();kh()});var pl=k(()=>{fl()});var hl=k(()=>{pl()});var xh=k(()=>{hl()});var Eh=k(()=>{});var Ah=k(()=>{wh();fl();pl();xh();hl();Eh()});var W=$(ge=>{"use strict";var ml=Symbol.for("yaml.alias"),Th=Symbol.for("yaml.document"),Vi=Symbol.for("yaml.map"),Ch=Symbol.for("yaml.pair"),gl=Symbol.for("yaml.scalar"),Gi=Symbol.for("yaml.seq"),ht=Symbol.for("yaml.node.type"),f0=t=>!!t&&typeof t=="object"&&t[ht]===ml,p0=t=>!!t&&typeof t=="object"&&t[ht]===Th,h0=t=>!!t&&typeof t=="object"&&t[ht]===Vi,m0=t=>!!t&&typeof t=="object"&&t[ht]===Ch,Oh=t=>!!t&&typeof t=="object"&&t[ht]===gl,g0=t=>!!t&&typeof t=="object"&&t[ht]===Gi;function Ph(t){if(t&&typeof t=="object")switch(t[ht]){case Vi:case Gi:return!0}return!1}function y0(t){if(t&&typeof t=="object")switch(t[ht]){case ml:case Vi:case gl:case Gi:return!0}return!1}var b0=t=>(Oh(t)||Ph(t))&&!!t.anchor;ge.ALIAS=ml;ge.DOC=Th;ge.MAP=Vi;ge.NODE_TYPE=ht;ge.PAIR=Ch;ge.SCALAR=gl;ge.SEQ=Gi;ge.hasAnchor=b0;ge.isAlias=f0;ge.isCollection=Ph;ge.isDocument=p0;ge.isMap=h0;ge.isNode=y0;ge.isPair=m0;ge.isScalar=Oh;ge.isSeq=g0});var rs=$(yl=>{"use strict";var le=W(),Te=Symbol("break visit"),_h=Symbol("skip children"),at=Symbol("remove node");function Xi(t,e){let n=Rh(e);le.isDocument(t)?zn(null,t.contents,n,Object.freeze([t]))===at&&(t.contents=null):zn(null,t,n,Object.freeze([]))}Xi.BREAK=Te;Xi.SKIP=_h;Xi.REMOVE=at;function zn(t,e,n,r){let s=Ih(t,e,n,r);if(le.isNode(s)||le.isPair(s))return $h(t,r,s),zn(t,s,n,r);if(typeof s!="symbol"){if(le.isCollection(e)){r=Object.freeze(r.concat(e));for(let i=0;i<e.items.length;++i){let o=zn(i,e.items[i],n,r);if(typeof o=="number")i=o-1;else{if(o===Te)return Te;o===at&&(e.items.splice(i,1),i-=1)}}}else if(le.isPair(e)){r=Object.freeze(r.concat(e));let i=zn("key",e.key,n,r);if(i===Te)return Te;i===at&&(e.key=null);let o=zn("value",e.value,n,r);if(o===Te)return Te;o===at&&(e.value=null)}}return s}async function Qi(t,e){let n=Rh(e);le.isDocument(t)?await Yn(null,t.contents,n,Object.freeze([t]))===at&&(t.contents=null):await Yn(null,t,n,Object.freeze([]))}Qi.BREAK=Te;Qi.SKIP=_h;Qi.REMOVE=at;async function Yn(t,e,n,r){let s=await Ih(t,e,n,r);if(le.isNode(s)||le.isPair(s))return $h(t,r,s),Yn(t,s,n,r);if(typeof s!="symbol"){if(le.isCollection(e)){r=Object.freeze(r.concat(e));for(let i=0;i<e.items.length;++i){let o=await Yn(i,e.items[i],n,r);if(typeof o=="number")i=o-1;else{if(o===Te)return Te;o===at&&(e.items.splice(i,1),i-=1)}}}else if(le.isPair(e)){r=Object.freeze(r.concat(e));let i=await Yn("key",e.key,n,r);if(i===Te)return Te;i===at&&(e.key=null);let o=await Yn("value",e.value,n,r);if(o===Te)return Te;o===at&&(e.value=null)}}return s}function Rh(t){return typeof t=="object"&&(t.Collection||t.Node||t.Value)?Object.assign({Alias:t.Node,Map:t.Node,Scalar:t.Node,Seq:t.Node},t.Value&&{Map:t.Value,Scalar:t.Value,Seq:t.Value},t.Collection&&{Map:t.Collection,Seq:t.Collection},t):t}function Ih(t,e,n,r){if(typeof n=="function")return n(t,e,r);if(le.isMap(e))return n.Map?.(t,e,r);if(le.isSeq(e))return n.Seq?.(t,e,r);if(le.isPair(e))return n.Pair?.(t,e,r);if(le.isScalar(e))return n.Scalar?.(t,e,r);if(le.isAlias(e))return n.Alias?.(t,e,r)}function $h(t,e,n){let r=e[e.length-1];if(le.isCollection(r))r.items[t]=n;else if(le.isPair(r))t==="key"?r.key=n:r.value=n;else if(le.isDocument(r))r.contents=n;else{let s=le.isAlias(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${s} parent`)}}yl.visit=Xi;yl.visitAsync=Qi});var bl=$(Lh=>{"use strict";var Nh=W(),w0=rs(),v0={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},S0=t=>t.replace(/[!,[\]{}]/g,e=>v0[e]),ss=class t{constructor(e,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},t.defaultYaml,e),this.tags=Object.assign({},t.defaultTags,n)}clone(){let e=new t(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new t(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:t.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},t.defaultTags);break}return e}add(e,n){this.atNextDocument&&(this.yaml={explicit:t.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},t.defaultTags),this.atNextDocument=!1);let r=e.trim().split(/[ \t]+/),s=r.shift();switch(s){case"%TAG":{if(r.length!==2&&(n(0,"%TAG directive should contain exactly two parts"),r.length<2))return!1;let[i,o]=r;return this.tags[i]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,r.length!==1)return n(0,"%YAML directive should contain exactly one part"),!1;let[i]=r;if(i==="1.1"||i==="1.2")return this.yaml.version=i,!0;{let o=/^\d+\.\d+$/.test(i);return n(6,`Unsupported YAML version ${i}`,o),!1}}default:return n(0,`Unknown directive ${s}`,!0),!1}}tagName(e,n){if(e==="!")return"!";if(e[0]!=="!")return n(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let o=e.slice(2,-1);return o==="!"||o==="!!"?(n(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&n("Verbatim tags must end with a >"),o)}let[,r,s]=e.match(/^(.*!)([^!]*)$/s);s||n(`The ${e} tag has no suffix`);let i=this.tags[r];if(i)try{return i+decodeURIComponent(s)}catch(o){return n(String(o)),null}return r==="!"?e:(n(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[n,r]of Object.entries(this.tags))if(e.startsWith(r))return n+S0(e.substring(r.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let n=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags),s;if(e&&r.length>0&&Nh.isNode(e.contents)){let i={};w0.visit(e.contents,(o,a)=>{Nh.isNode(a)&&a.tag&&(i[a.tag]=!0)}),s=Object.keys(i)}else s=[];for(let[i,o]of r)i==="!!"&&o==="tag:yaml.org,2002:"||(!e||s.some(a=>a.startsWith(o)))&&n.push(`%TAG ${i} ${o}`);return n.join(`
25
+ `)}};ss.defaultYaml={explicit:!1,version:"1.2"};ss.defaultTags={"!!":"tag:yaml.org,2002:"};Lh.Directives=ss});var Zi=$(is=>{"use strict";var Mh=W(),k0=rs();function x0(t){if(/[\x00-\x19\s,[\]{}]/.test(t)){let n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(t)}`;throw new Error(n)}return!0}function Dh(t){let e=new Set;return k0.visit(t,{Value(n,r){r.anchor&&e.add(r.anchor)}}),e}function Bh(t,e){for(let n=1;;++n){let r=`${t}${n}`;if(!e.has(r))return r}}function E0(t,e){let n=[],r=new Map,s=null;return{onAnchor:i=>{n.push(i),s??(s=Dh(t));let o=Bh(e,s);return s.add(o),o},setAnchors:()=>{for(let i of n){let o=r.get(i);if(typeof o=="object"&&o.anchor&&(Mh.isScalar(o.node)||Mh.isCollection(o.node)))o.node.anchor=o.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=i,a}}},sourceObjects:r}}is.anchorIsValid=x0;is.anchorNames=Dh;is.createNodeAnchors=E0;is.findNewAnchor=Bh});var wl=$(jh=>{"use strict";function os(t,e,n,r){if(r&&typeof r=="object")if(Array.isArray(r))for(let s=0,i=r.length;s<i;++s){let o=r[s],a=os(t,r,String(s),o);a===void 0?delete r[s]:a!==o&&(r[s]=a)}else if(r instanceof Map)for(let s of Array.from(r.keys())){let i=r.get(s),o=os(t,r,s,i);o===void 0?r.delete(s):o!==i&&r.set(s,o)}else if(r instanceof Set)for(let s of Array.from(r)){let i=os(t,r,s,s);i===void 0?r.delete(s):i!==s&&(r.delete(s),r.add(i))}else for(let[s,i]of Object.entries(r)){let o=os(t,r,s,i);o===void 0?delete r[s]:o!==i&&(r[s]=o)}return t.call(e,n,r)}jh.applyReviver=os});var Rt=$(Uh=>{"use strict";var A0=W();function Fh(t,e,n){if(Array.isArray(t))return t.map((r,s)=>Fh(r,String(s),n));if(t&&typeof t.toJSON=="function"){if(!n||!A0.hasAnchor(t))return t.toJSON(e,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(t,r),n.onCreate=i=>{r.res=i,delete n.onCreate};let s=t.toJSON(e,n);return n.onCreate&&n.onCreate(s),s}return typeof t=="bigint"&&!n?.keep?Number(t):t}Uh.toJS=Fh});var eo=$(Jh=>{"use strict";var T0=wl(),qh=W(),C0=Rt(),vl=class{constructor(e){Object.defineProperty(this,qh.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:n,maxAliasCount:r,onAnchor:s,reviver:i}={}){if(!qh.isDocument(e))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:e,keep:!0,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},a=C0.toJS(this,"",o);if(typeof s=="function")for(let{count:c,res:l}of o.anchors.values())s(l,c);return typeof i=="function"?T0.applyReviver(i,{"":a},"",a):a}};Jh.NodeBase=vl});var as=$(Wh=>{"use strict";var O0=Zi(),P0=rs(),Vn=W(),_0=eo(),R0=Rt(),Sl=class extends _0.NodeBase{constructor(e){super(Vn.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,n){let r;n?.aliasResolveCache?r=n.aliasResolveCache:(r=[],P0.visit(e,{Node:(i,o)=>{(Vn.isAlias(o)||Vn.hasAnchor(o))&&r.push(o)}}),n&&(n.aliasResolveCache=r));let s;for(let i of r){if(i===this)break;i.anchor===this.source&&(s=i)}return s}toJSON(e,n){if(!n)return{source:this.source};let{anchors:r,doc:s,maxAliasCount:i}=n,o=this.resolve(s,n);if(!o){let c=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(c)}let a=r.get(o);if(a||(R0.toJS(o,null,n),a=r.get(o)),a?.res===void 0){let c="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(c)}if(i>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=to(s,o,r)),a.count*a.aliasCount>i)){let c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}return a.res}toString(e,n,r){let s=`*${this.source}`;if(e){if(O0.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let i=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(i)}if(e.implicitKey)return`${s} `}return s}};function to(t,e,n){if(Vn.isAlias(e)){let r=e.resolve(t),s=n&&r&&n.get(r);return s?s.count*s.aliasCount:0}else if(Vn.isCollection(e)){let r=0;for(let s of e.items){let i=to(t,s,n);i>r&&(r=i)}return r}else if(Vn.isPair(e)){let r=to(t,e.key,n),s=to(t,e.value,n);return Math.max(r,s)}return 1}Wh.Alias=Sl});var oe=$(kl=>{"use strict";var I0=W(),$0=eo(),N0=Rt(),L0=t=>!t||typeof t!="function"&&typeof t!="object",It=class extends $0.NodeBase{constructor(e){super(I0.SCALAR),this.value=e}toJSON(e,n){return n?.keep?this.value:N0.toJS(this.value,e,n)}toString(){return String(this.value)}};It.BLOCK_FOLDED="BLOCK_FOLDED";It.BLOCK_LITERAL="BLOCK_LITERAL";It.PLAIN="PLAIN";It.QUOTE_DOUBLE="QUOTE_DOUBLE";It.QUOTE_SINGLE="QUOTE_SINGLE";kl.Scalar=It;kl.isScalarValue=L0});var cs=$(Hh=>{"use strict";var M0=as(),dn=W(),Kh=oe(),D0="tag:yaml.org,2002:";function B0(t,e,n){if(e){let r=n.filter(i=>i.tag===e),s=r.find(i=>!i.format)??r[0];if(!s)throw new Error(`Tag ${e} not found`);return s}return n.find(r=>r.identify?.(t)&&!r.format)}function j0(t,e,n){if(dn.isDocument(t)&&(t=t.contents),dn.isNode(t))return t;if(dn.isPair(t)){let u=n.schema[dn.MAP].createNode?.(n.schema,null,n);return u.items.push(t),u}(t instanceof String||t instanceof Number||t instanceof Boolean||typeof BigInt<"u"&&t instanceof BigInt)&&(t=t.valueOf());let{aliasDuplicateObjects:r,onAnchor:s,onTagObj:i,schema:o,sourceObjects:a}=n,c;if(r&&t&&typeof t=="object"){if(c=a.get(t),c)return c.anchor??(c.anchor=s(t)),new M0.Alias(c.anchor);c={anchor:null,node:null},a.set(t,c)}e?.startsWith("!!")&&(e=D0+e.slice(2));let l=B0(t,e,o.tags);if(!l){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let u=new Kh.Scalar(t);return c&&(c.node=u),u}l=t instanceof Map?o[dn.MAP]:Symbol.iterator in Object(t)?o[dn.SEQ]:o[dn.MAP]}i&&(i(l),delete n.onTagObj);let f=l?.createNode?l.createNode(n.schema,t,n):typeof l?.nodeClass?.from=="function"?l.nodeClass.from(n.schema,t,n):new Kh.Scalar(t);return e?f.tag=e:l.default||(f.tag=l.tag),c&&(c.node=f),f}Hh.createNode=j0});var ro=$(no=>{"use strict";var F0=cs(),ct=W(),U0=eo();function xl(t,e,n){let r=n;for(let s=e.length-1;s>=0;--s){let i=e[s];if(typeof i=="number"&&Number.isInteger(i)&&i>=0){let o=[];o[i]=r,r=o}else r=new Map([[i,r]])}return F0.createNode(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:t,sourceObjects:new Map})}var zh=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,El=class extends U0.NodeBase{constructor(e,n){super(e),Object.defineProperty(this,"schema",{value:n,configurable:!0,enumerable:!1,writable:!0})}clone(e){let n=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(n.schema=e),n.items=n.items.map(r=>ct.isNode(r)||ct.isPair(r)?r.clone(e):r),this.range&&(n.range=this.range.slice()),n}addIn(e,n){if(zh(e))this.add(n);else{let[r,...s]=e,i=this.get(r,!0);if(ct.isCollection(i))i.addIn(s,n);else if(i===void 0&&this.schema)this.set(r,xl(this.schema,s,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${s}`)}}deleteIn(e){let[n,...r]=e;if(r.length===0)return this.delete(n);let s=this.get(n,!0);if(ct.isCollection(s))return s.deleteIn(r);throw new Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}getIn(e,n){let[r,...s]=e,i=this.get(r,!0);return s.length===0?!n&&ct.isScalar(i)?i.value:i:ct.isCollection(i)?i.getIn(s,n):void 0}hasAllNullValues(e){return this.items.every(n=>{if(!ct.isPair(n))return!1;let r=n.value;return r==null||e&&ct.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[n,...r]=e;if(r.length===0)return this.has(n);let s=this.get(n,!0);return ct.isCollection(s)?s.hasIn(r):!1}setIn(e,n){let[r,...s]=e;if(s.length===0)this.set(r,n);else{let i=this.get(r,!0);if(ct.isCollection(i))i.setIn(s,n);else if(i===void 0&&this.schema)this.set(r,xl(this.schema,s,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${s}`)}}};no.Collection=El;no.collectionFromPath=xl;no.isEmptyPath=zh});var ls=$(so=>{"use strict";var q0=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function Al(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var J0=(t,e,n)=>t.endsWith(`
26
+ `)?Al(n,e):n.includes(`
27
27
  `)?`
28
- `+wc(n,e):(t.endsWith(" ")?"":" ")+n;Xi.indentComment=wc;Xi.lineComment=g0;Xi.stringifyComment=m0});var jh=I(ss=>{"use strict";var y0="flow",vc="block",Qi="quoted";function b0(t,e,n="flow",{indentAtStart:r,lineWidth:s=80,minContentWidth:i=20,onFold:o,onOverflow:a}={}){if(!s||s<0)return t;s<i&&(i=0);let l=Math.max(1+i,1+s-e.length);if(t.length<=l)return t;let c=[],f={},d=s-e.length;typeof r=="number"&&(r>s-Math.max(2,i)?c.push(0):d=s-r);let u,p,h=!1,m=-1,g=-1,b=-1;n===vc&&(m=Bh(t,m,e.length),m!==-1&&(d=m+l));for(let T;T=t[m+=1];){if(n===Qi&&T==="\\"){switch(g=m,t[m+1]){case"x":m+=3;break;case"u":m+=5;break;case"U":m+=9;break;default:m+=1}b=m}if(T===`
29
- `)n===vc&&(m=Bh(t,m,e.length)),d=m+e.length+l,u=void 0;else{if(T===" "&&p&&p!==" "&&p!==`
28
+ `+Al(n,e):(t.endsWith(" ")?"":" ")+n;so.indentComment=Al;so.lineComment=J0;so.stringifyComment=q0});var Vh=$(us=>{"use strict";var W0="flow",Tl="block",io="quoted";function K0(t,e,n="flow",{indentAtStart:r,lineWidth:s=80,minContentWidth:i=20,onFold:o,onOverflow:a}={}){if(!s||s<0)return t;s<i&&(i=0);let c=Math.max(1+i,1+s-e.length);if(t.length<=c)return t;let l=[],f={},u=s-e.length;typeof r=="number"&&(r>s-Math.max(2,i)?l.push(0):u=s-r);let d,p,h=!1,m=-1,g=-1,b=-1;n===Tl&&(m=Yh(t,m,e.length),m!==-1&&(u=m+c));for(let T;T=t[m+=1];){if(n===io&&T==="\\"){switch(g=m,t[m+1]){case"x":m+=3;break;case"u":m+=5;break;case"U":m+=9;break;default:m+=1}b=m}if(T===`
29
+ `)n===Tl&&(m=Yh(t,m,e.length)),u=m+e.length+c,d=void 0;else{if(T===" "&&p&&p!==" "&&p!==`
30
30
  `&&p!==" "){let E=t[m+1];E&&E!==" "&&E!==`
31
- `&&E!==" "&&(u=m)}if(m>=d)if(u)c.push(u),d=u+l,u=void 0;else if(n===Qi){for(;p===" "||p===" ";)p=T,T=t[m+=1],h=!0;let E=m>b+1?m-2:g-1;if(f[E])return t;c.push(E),f[E]=!0,d=E+l,u=void 0}else h=!0}p=T}if(h&&a&&a(),c.length===0)return t;o&&o();let C=t.slice(0,c[0]);for(let T=0;T<c.length;++T){let E=c[T],$=c[T+1]||t.length;E===0?C=`
32
- ${e}${t.slice(0,$)}`:(n===Qi&&f[E]&&(C+=`${t[E]}\\`),C+=`
33
- ${e}${t.slice(E+1,$)}`)}return C}function Bh(t,e,n){let r=e,s=e+1,i=t[s];for(;i===" "||i===" ";)if(e<s+n)i=t[++e];else{do i=t[++e];while(i&&i!==`
34
- `);r=e,s=e+1,i=t[s]}return r}ss.FOLD_BLOCK=vc;ss.FOLD_FLOW=y0;ss.FOLD_QUOTED=Qi;ss.foldFlowLines=b0});var os=I(Fh=>{"use strict";var Ge=re(),Nt=jh(),eo=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),to=t=>/^(%|---|\.\.\.)/m.test(t);function w0(t,e,n){if(!e||e<0)return!1;let r=e-n,s=t.length;if(s<=r)return!1;for(let i=0,o=0;i<s;++i)if(t[i]===`
35
- `){if(i-o>r)return!0;if(o=i+1,s-o<=r)return!1}return!0}function is(t,e){let n=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=e,s=e.options.doubleQuotedMinMultiLineLength,i=e.indent||(to(t)?" ":""),o="",a=0;for(let l=0,c=n[l];c;c=n[++l])if(c===" "&&n[l+1]==="\\"&&n[l+2]==="n"&&(o+=n.slice(a,l)+"\\ ",l+=1,a=l,c="\\"),c==="\\")switch(n[l+1]){case"u":{o+=n.slice(a,l);let f=n.substr(l+2,4);switch(f){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:f.substr(0,2)==="00"?o+="\\x"+f.substr(2):o+=n.substr(l,6)}l+=5,a=l+1}break;case"n":if(r||n[l+2]==='"'||n.length<s)l+=1;else{for(o+=n.slice(a,l)+`
36
-
37
- `;n[l+2]==="\\"&&n[l+3]==="n"&&n[l+4]!=='"';)o+=`
38
- `,l+=2;o+=i,n[l+2]===" "&&(o+="\\"),l+=1,a=l+1}break;default:l+=1}return o=a?o+n.slice(a):n,r?o:Nt.foldFlowLines(o,i,Nt.FOLD_QUOTED,eo(e,!1))}function Sc(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
39
- `)||/[ \t]\n|\n[ \t]/.test(t))return is(t,e);let n=e.indent||(to(t)?" ":""),r="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
40
- ${n}`)+"'";return e.implicitKey?r:Nt.foldFlowLines(r,n,Nt.FOLD_FLOW,eo(e,!1))}function Yn(t,e){let{singleQuote:n}=e.options,r;if(n===!1)r=is;else{let s=t.includes('"'),i=t.includes("'");s&&!i?r=Sc:i&&!s?r=is:r=n?Sc:is}return r(t,e)}var kc;try{kc=new RegExp(`(^|(?<!
31
+ `&&E!==" "&&(d=m)}if(m>=u)if(d)l.push(d),u=d+c,d=void 0;else if(n===io){for(;p===" "||p===" ";)p=T,T=t[m+=1],h=!0;let E=m>b+1?m-2:g-1;if(f[E])return t;l.push(E),f[E]=!0,u=E+c,d=void 0}else h=!0}p=T}if(h&&a&&a(),l.length===0)return t;o&&o();let C=t.slice(0,l[0]);for(let T=0;T<l.length;++T){let E=l[T],R=l[T+1]||t.length;E===0?C=`
32
+ ${e}${t.slice(0,R)}`:(n===io&&f[E]&&(C+=`${t[E]}\\`),C+=`
33
+ ${e}${t.slice(E+1,R)}`)}return C}function Yh(t,e,n){let r=e,s=e+1,i=t[s];for(;i===" "||i===" ";)if(e<s+n)i=t[++e];else{do i=t[++e];while(i&&i!==`
34
+ `);r=e,s=e+1,i=t[s]}return r}us.FOLD_BLOCK=Tl;us.FOLD_FLOW=W0;us.FOLD_QUOTED=io;us.foldFlowLines=K0});var fs=$(Gh=>{"use strict";var Xe=oe(),$t=Vh(),ao=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),co=t=>/^(%|---|\.\.\.)/m.test(t);function H0(t,e,n){if(!e||e<0)return!1;let r=e-n,s=t.length;if(s<=r)return!1;for(let i=0,o=0;i<s;++i)if(t[i]===`
35
+ `){if(i-o>r)return!0;if(o=i+1,s-o<=r)return!1}return!0}function ds(t,e){let n=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=e,s=e.options.doubleQuotedMinMultiLineLength,i=e.indent||(co(t)?" ":""),o="",a=0;for(let c=0,l=n[c];l;l=n[++c])if(l===" "&&n[c+1]==="\\"&&n[c+2]==="n"&&(o+=n.slice(a,c)+"\\ ",c+=1,a=c,l="\\"),l==="\\")switch(n[c+1]){case"u":{o+=n.slice(a,c);let f=n.substr(c+2,4);switch(f){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:f.substr(0,2)==="00"?o+="\\x"+f.substr(2):o+=n.substr(c,6)}c+=5,a=c+1}break;case"n":if(r||n[c+2]==='"'||n.length<s)c+=1;else{for(o+=n.slice(a,c)+`
36
+
37
+ `;n[c+2]==="\\"&&n[c+3]==="n"&&n[c+4]!=='"';)o+=`
38
+ `,c+=2;o+=i,n[c+2]===" "&&(o+="\\"),c+=1,a=c+1}break;default:c+=1}return o=a?o+n.slice(a):n,r?o:$t.foldFlowLines(o,i,$t.FOLD_QUOTED,ao(e,!1))}function Cl(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
39
+ `)||/[ \t]\n|\n[ \t]/.test(t))return ds(t,e);let n=e.indent||(co(t)?" ":""),r="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
40
+ ${n}`)+"'";return e.implicitKey?r:$t.foldFlowLines(r,n,$t.FOLD_FLOW,ao(e,!1))}function Gn(t,e){let{singleQuote:n}=e.options,r;if(n===!1)r=ds;else{let s=t.includes('"'),i=t.includes("'");s&&!i?r=Cl:i&&!s?r=ds:r=n?Cl:ds}return r(t,e)}var Ol;try{Ol=new RegExp(`(^|(?<!
41
41
  ))
42
42
  +(?!
43
- |$)`,"g")}catch{kc=/\n+(?!\n|$)/g}function Zi({comment:t,type:e,value:n},r,s,i){let{blockQuote:o,commentString:a,lineWidth:l}=r.options;if(!o||/\n[\t ]+$/.test(n))return Yn(n,r);let c=r.indent||(r.forceBlockIndent||to(n)?" ":""),f=o==="literal"?!0:o==="folded"||e===Ge.Scalar.BLOCK_FOLDED?!1:e===Ge.Scalar.BLOCK_LITERAL?!0:!w0(n,l,c.length);if(!n)return f?`|
43
+ |$)`,"g")}catch{Ol=/\n+(?!\n|$)/g}function oo({comment:t,type:e,value:n},r,s,i){let{blockQuote:o,commentString:a,lineWidth:c}=r.options;if(!o||/\n[\t ]+$/.test(n))return Gn(n,r);let l=r.indent||(r.forceBlockIndent||co(n)?" ":""),f=o==="literal"?!0:o==="folded"||e===Xe.Scalar.BLOCK_FOLDED?!1:e===Xe.Scalar.BLOCK_LITERAL?!0:!H0(n,c,l.length);if(!n)return f?`|
44
44
  `:`>
45
- `;let d,u;for(u=n.length;u>0;--u){let $=n[u-1];if($!==`
46
- `&&$!==" "&&$!==" ")break}let p=n.substring(u),h=p.indexOf(`
47
- `);h===-1?d="-":n===p||h!==p.length-1?(d="+",i&&i()):d="",p&&(n=n.slice(0,-p.length),p[p.length-1]===`
48
- `&&(p=p.slice(0,-1)),p=p.replace(kc,`$&${c}`));let m=!1,g,b=-1;for(g=0;g<n.length;++g){let $=n[g];if($===" ")m=!0;else if($===`
49
- `)b=g;else break}let C=n.substring(0,b<g?b+1:g);C&&(n=n.substring(C.length),C=C.replace(/\n+/g,`$&${c}`));let E=(m?c?"2":"1":"")+d;if(t&&(E+=" "+a(t.replace(/ ?[\r\n]+/g," ")),s&&s()),!f){let $=n.replace(/\n+/g,`
50
- $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),O=!1,P=eo(r,!0);o!=="folded"&&e!==Ge.Scalar.BLOCK_FOLDED&&(P.onOverflow=()=>{O=!0});let k=Nt.foldFlowLines(`${C}${$}${p}`,c,Nt.FOLD_BLOCK,P);if(!O)return`>${E}
51
- ${c}${k}`}return n=n.replace(/\n+/g,`$&${c}`),`|${E}
52
- ${c}${C}${n}${p}`}function v0(t,e,n,r){let{type:s,value:i}=t,{actualString:o,implicitKey:a,indent:l,indentStep:c,inFlow:f}=e;if(a&&i.includes(`
53
- `)||f&&/[[\]{},]/.test(i))return Yn(i,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(i))return a||f||!i.includes(`
54
- `)?Yn(i,e):Zi(t,e,n,r);if(!a&&!f&&s!==Ge.Scalar.PLAIN&&i.includes(`
55
- `))return Zi(t,e,n,r);if(to(i)){if(l==="")return e.forceBlockIndent=!0,Zi(t,e,n,r);if(a&&l===c)return Yn(i,e)}let d=i.replace(/\n+/g,`$&
56
- ${l}`);if(o){let u=m=>m.default&&m.tag!=="tag:yaml.org,2002:str"&&m.test?.test(d),{compat:p,tags:h}=e.doc.schema;if(h.some(u)||p?.some(u))return Yn(i,e)}return a?d:Nt.foldFlowLines(d,l,Nt.FOLD_FLOW,eo(e,!1))}function S0(t,e,n,r){let{implicitKey:s,inFlow:i}=e,o=typeof t.value=="string"?t:Object.assign({},t,{value:String(t.value)}),{type:a}=t;a!==Ge.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(a=Ge.Scalar.QUOTE_DOUBLE);let l=f=>{switch(f){case Ge.Scalar.BLOCK_FOLDED:case Ge.Scalar.BLOCK_LITERAL:return s||i?Yn(o.value,e):Zi(o,e,n,r);case Ge.Scalar.QUOTE_DOUBLE:return is(o.value,e);case Ge.Scalar.QUOTE_SINGLE:return Sc(o.value,e);case Ge.Scalar.PLAIN:return v0(o,e,n,r);default:return null}},c=l(a);if(c===null){let{defaultKeyType:f,defaultStringType:d}=e.options,u=s&&f||d;if(c=l(u),c===null)throw new Error(`Unsupported default string type ${u}`)}return c}Fh.stringifyString=S0});var as=I(xc=>{"use strict";var k0=Hi(),Lt=W(),x0=rs(),E0=os();function A0(t,e){let n=Object.assign({blockQuote:!0,commentString:x0.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trueStr:"true",verifyAliasOrder:!0},t.schema.toStringOptions,e),r;switch(n.collectionStyle){case"block":r=!1;break;case"flow":r=!0;break;default:r=null}return{anchors:new Set,doc:t,flowCollectionPadding:n.flowCollectionPadding?" ":"",indent:"",indentStep:typeof n.indent=="number"?" ".repeat(n.indent):" ",inFlow:r,options:n}}function T0(t,e){if(e.tag){let s=t.filter(i=>i.tag===e.tag);if(s.length>0)return s.find(i=>i.format===e.format)??s[0]}let n,r;if(Lt.isScalar(e)){r=e.value;let s=t.filter(i=>i.identify?.(r));if(s.length>1){let i=s.filter(o=>o.test);i.length>0&&(s=i)}n=s.find(i=>i.format===e.format)??s.find(i=>!i.format)}else r=e,n=t.find(s=>s.nodeClass&&r instanceof s.nodeClass);if(!n){let s=r?.constructor?.name??(r===null?"null":typeof r);throw new Error(`Tag not resolved for ${s} value`)}return n}function C0(t,e,{anchors:n,doc:r}){if(!r.directives)return"";let s=[],i=(Lt.isScalar(t)||Lt.isCollection(t))&&t.anchor;i&&k0.anchorIsValid(i)&&(n.add(i),s.push(`&${i}`));let o=t.tag??(e.default?null:e.tag);return o&&s.push(r.directives.tagString(o)),s.join(" ")}function O0(t,e,n,r){if(Lt.isPair(t))return t.toString(e,n,r);if(Lt.isAlias(t)){if(e.doc.directives)return t.toString(e);if(e.resolvedAliases?.has(t))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(t):e.resolvedAliases=new Set([t]),t=t.resolve(e.doc)}let s,i=Lt.isNode(t)?t:e.doc.createNode(t,{onTagObj:l=>s=l});s??(s=T0(e.doc.schema.tags,i));let o=C0(i,s,e);o.length>0&&(e.indentAtStart=(e.indentAtStart??0)+o.length+1);let a=typeof s.stringify=="function"?s.stringify(i,e,n,r):Lt.isScalar(i)?E0.stringifyString(i,e,n,r):i.toString(e,n,r);return o?Lt.isScalar(i)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
57
- ${e.indent}${a}`:a}xc.createStringifyContext=A0;xc.stringify=O0});var Wh=I(Jh=>{"use strict";var ht=W(),Uh=re(),qh=as(),ls=rs();function P0({key:t,value:e},n,r,s){let{allNullValues:i,doc:o,indent:a,indentStep:l,options:{commentString:c,indentSeq:f,simpleKeys:d}}=n,u=ht.isNode(t)&&t.comment||null;if(d){if(u)throw new Error("With simple keys, key nodes cannot have comments");if(ht.isCollection(t)||!ht.isNode(t)&&typeof t=="object"){let P="With simple keys, collection cannot be used as a key value";throw new Error(P)}}let p=!d&&(!t||u&&e==null&&!n.inFlow||ht.isCollection(t)||(ht.isScalar(t)?t.type===Uh.Scalar.BLOCK_FOLDED||t.type===Uh.Scalar.BLOCK_LITERAL:typeof t=="object"));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(d||!i),indent:a+l});let h=!1,m=!1,g=qh.stringify(t,n,()=>h=!0,()=>m=!0);if(!p&&!n.inFlow&&g.length>1024){if(d)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");p=!0}if(n.inFlow){if(i||e==null)return h&&r&&r(),g===""?"?":p?`? ${g}`:g}else if(i&&!d||e==null&&p)return g=`? ${g}`,u&&!h?g+=ls.lineComment(g,n.indent,c(u)):m&&s&&s(),g;h&&(u=null),p?(u&&(g+=ls.lineComment(g,n.indent,c(u))),g=`? ${g}
58
- ${a}:`):(g=`${g}:`,u&&(g+=ls.lineComment(g,n.indent,c(u))));let b,C,T;ht.isNode(e)?(b=!!e.spaceBefore,C=e.commentBefore,T=e.comment):(b=!1,C=null,T=null,e&&typeof e=="object"&&(e=o.createNode(e))),n.implicitKey=!1,!p&&!u&&ht.isScalar(e)&&(n.indentAtStart=g.length+1),m=!1,!f&&l.length>=2&&!n.inFlow&&!p&&ht.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(n.indent=n.indent.substring(2));let E=!1,$=qh.stringify(e,n,()=>E=!0,()=>m=!0),O=" ";if(u||b||C){if(O=b?`
59
- `:"",C){let P=c(C);O+=`
60
- ${ls.indentComment(P,n.indent)}`}$===""&&!n.inFlow?O===`
45
+ `;let u,d;for(d=n.length;d>0;--d){let R=n[d-1];if(R!==`
46
+ `&&R!==" "&&R!==" ")break}let p=n.substring(d),h=p.indexOf(`
47
+ `);h===-1?u="-":n===p||h!==p.length-1?(u="+",i&&i()):u="",p&&(n=n.slice(0,-p.length),p[p.length-1]===`
48
+ `&&(p=p.slice(0,-1)),p=p.replace(Ol,`$&${l}`));let m=!1,g,b=-1;for(g=0;g<n.length;++g){let R=n[g];if(R===" ")m=!0;else if(R===`
49
+ `)b=g;else break}let C=n.substring(0,b<g?b+1:g);C&&(n=n.substring(C.length),C=C.replace(/\n+/g,`$&${l}`));let E=(m?l?"2":"1":"")+u;if(t&&(E+=" "+a(t.replace(/ ?[\r\n]+/g," ")),s&&s()),!f){let R=n.replace(/\n+/g,`
50
+ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),O=!1,_=ao(r,!0);o!=="folded"&&e!==Xe.Scalar.BLOCK_FOLDED&&(_.onOverflow=()=>{O=!0});let x=$t.foldFlowLines(`${C}${R}${p}`,l,$t.FOLD_BLOCK,_);if(!O)return`>${E}
51
+ ${l}${x}`}return n=n.replace(/\n+/g,`$&${l}`),`|${E}
52
+ ${l}${C}${n}${p}`}function z0(t,e,n,r){let{type:s,value:i}=t,{actualString:o,implicitKey:a,indent:c,indentStep:l,inFlow:f}=e;if(a&&i.includes(`
53
+ `)||f&&/[[\]{},]/.test(i))return Gn(i,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(i))return a||f||!i.includes(`
54
+ `)?Gn(i,e):oo(t,e,n,r);if(!a&&!f&&s!==Xe.Scalar.PLAIN&&i.includes(`
55
+ `))return oo(t,e,n,r);if(co(i)){if(c==="")return e.forceBlockIndent=!0,oo(t,e,n,r);if(a&&c===l)return Gn(i,e)}let u=i.replace(/\n+/g,`$&
56
+ ${c}`);if(o){let d=m=>m.default&&m.tag!=="tag:yaml.org,2002:str"&&m.test?.test(u),{compat:p,tags:h}=e.doc.schema;if(h.some(d)||p?.some(d))return Gn(i,e)}return a?u:$t.foldFlowLines(u,c,$t.FOLD_FLOW,ao(e,!1))}function Y0(t,e,n,r){let{implicitKey:s,inFlow:i}=e,o=typeof t.value=="string"?t:Object.assign({},t,{value:String(t.value)}),{type:a}=t;a!==Xe.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(a=Xe.Scalar.QUOTE_DOUBLE);let c=f=>{switch(f){case Xe.Scalar.BLOCK_FOLDED:case Xe.Scalar.BLOCK_LITERAL:return s||i?Gn(o.value,e):oo(o,e,n,r);case Xe.Scalar.QUOTE_DOUBLE:return ds(o.value,e);case Xe.Scalar.QUOTE_SINGLE:return Cl(o.value,e);case Xe.Scalar.PLAIN:return z0(o,e,n,r);default:return null}},l=c(a);if(l===null){let{defaultKeyType:f,defaultStringType:u}=e.options,d=s&&f||u;if(l=c(d),l===null)throw new Error(`Unsupported default string type ${d}`)}return l}Gh.stringifyString=Y0});var ps=$(Pl=>{"use strict";var V0=Zi(),Nt=W(),G0=ls(),X0=fs();function Q0(t,e){let n=Object.assign({blockQuote:!0,commentString:G0.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trueStr:"true",verifyAliasOrder:!0},t.schema.toStringOptions,e),r;switch(n.collectionStyle){case"block":r=!1;break;case"flow":r=!0;break;default:r=null}return{anchors:new Set,doc:t,flowCollectionPadding:n.flowCollectionPadding?" ":"",indent:"",indentStep:typeof n.indent=="number"?" ".repeat(n.indent):" ",inFlow:r,options:n}}function Z0(t,e){if(e.tag){let s=t.filter(i=>i.tag===e.tag);if(s.length>0)return s.find(i=>i.format===e.format)??s[0]}let n,r;if(Nt.isScalar(e)){r=e.value;let s=t.filter(i=>i.identify?.(r));if(s.length>1){let i=s.filter(o=>o.test);i.length>0&&(s=i)}n=s.find(i=>i.format===e.format)??s.find(i=>!i.format)}else r=e,n=t.find(s=>s.nodeClass&&r instanceof s.nodeClass);if(!n){let s=r?.constructor?.name??(r===null?"null":typeof r);throw new Error(`Tag not resolved for ${s} value`)}return n}function eE(t,e,{anchors:n,doc:r}){if(!r.directives)return"";let s=[],i=(Nt.isScalar(t)||Nt.isCollection(t))&&t.anchor;i&&V0.anchorIsValid(i)&&(n.add(i),s.push(`&${i}`));let o=t.tag??(e.default?null:e.tag);return o&&s.push(r.directives.tagString(o)),s.join(" ")}function tE(t,e,n,r){if(Nt.isPair(t))return t.toString(e,n,r);if(Nt.isAlias(t)){if(e.doc.directives)return t.toString(e);if(e.resolvedAliases?.has(t))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(t):e.resolvedAliases=new Set([t]),t=t.resolve(e.doc)}let s,i=Nt.isNode(t)?t:e.doc.createNode(t,{onTagObj:c=>s=c});s??(s=Z0(e.doc.schema.tags,i));let o=eE(i,s,e);o.length>0&&(e.indentAtStart=(e.indentAtStart??0)+o.length+1);let a=typeof s.stringify=="function"?s.stringify(i,e,n,r):Nt.isScalar(i)?X0.stringifyString(i,e,n,r):i.toString(e,n,r);return o?Nt.isScalar(i)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
57
+ ${e.indent}${a}`:a}Pl.createStringifyContext=Q0;Pl.stringify=tE});var em=$(Zh=>{"use strict";var mt=W(),Xh=oe(),Qh=ps(),hs=ls();function nE({key:t,value:e},n,r,s){let{allNullValues:i,doc:o,indent:a,indentStep:c,options:{commentString:l,indentSeq:f,simpleKeys:u}}=n,d=mt.isNode(t)&&t.comment||null;if(u){if(d)throw new Error("With simple keys, key nodes cannot have comments");if(mt.isCollection(t)||!mt.isNode(t)&&typeof t=="object"){let _="With simple keys, collection cannot be used as a key value";throw new Error(_)}}let p=!u&&(!t||d&&e==null&&!n.inFlow||mt.isCollection(t)||(mt.isScalar(t)?t.type===Xh.Scalar.BLOCK_FOLDED||t.type===Xh.Scalar.BLOCK_LITERAL:typeof t=="object"));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(u||!i),indent:a+c});let h=!1,m=!1,g=Qh.stringify(t,n,()=>h=!0,()=>m=!0);if(!p&&!n.inFlow&&g.length>1024){if(u)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");p=!0}if(n.inFlow){if(i||e==null)return h&&r&&r(),g===""?"?":p?`? ${g}`:g}else if(i&&!u||e==null&&p)return g=`? ${g}`,d&&!h?g+=hs.lineComment(g,n.indent,l(d)):m&&s&&s(),g;h&&(d=null),p?(d&&(g+=hs.lineComment(g,n.indent,l(d))),g=`? ${g}
58
+ ${a}:`):(g=`${g}:`,d&&(g+=hs.lineComment(g,n.indent,l(d))));let b,C,T;mt.isNode(e)?(b=!!e.spaceBefore,C=e.commentBefore,T=e.comment):(b=!1,C=null,T=null,e&&typeof e=="object"&&(e=o.createNode(e))),n.implicitKey=!1,!p&&!d&&mt.isScalar(e)&&(n.indentAtStart=g.length+1),m=!1,!f&&c.length>=2&&!n.inFlow&&!p&&mt.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(n.indent=n.indent.substring(2));let E=!1,R=Qh.stringify(e,n,()=>E=!0,()=>m=!0),O=" ";if(d||b||C){if(O=b?`
59
+ `:"",C){let _=l(C);O+=`
60
+ ${hs.indentComment(_,n.indent)}`}R===""&&!n.inFlow?O===`
61
61
  `&&T&&(O=`
62
62
 
63
63
  `):O+=`
64
- ${n.indent}`}else if(!p&&ht.isCollection(e)){let P=$[0],k=$.indexOf(`
65
- `),L=k!==-1,j=n.inFlow??e.flow??e.items.length===0;if(L||!j){let Q=!1;if(L&&(P==="&"||P==="!")){let U=$.indexOf(" ");P==="&"&&U!==-1&&U<k&&$[U+1]==="!"&&(U=$.indexOf(" ",U+1)),(U===-1||k<U)&&(Q=!0)}Q||(O=`
66
- ${n.indent}`)}}else($===""||$[0]===`
67
- `)&&(O="");return g+=O+$,n.inFlow?E&&r&&r():T&&!E?g+=ls.lineComment(g,n.indent,c(T)):m&&s&&s(),g}Jh.stringifyPair=P0});var Ac=I(Ec=>{"use strict";var Kh=Ni("process");function _0(t,...e){t==="debug"&&console.log(...e)}function R0(t,e){(t==="debug"||t==="warn")&&(typeof Kh.emitWarning=="function"?Kh.emitWarning(e):console.warn(e))}Ec.debug=_0;Ec.warn=R0});var io=I(so=>{"use strict";var cs=W(),Hh=re(),no="<<",ro={identify:t=>t===no||typeof t=="symbol"&&t.description===no,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Hh.Scalar(Symbol(no)),{addToJSMap:zh}),stringify:()=>no},I0=(t,e)=>(ro.identify(e)||cs.isScalar(e)&&(!e.type||e.type===Hh.Scalar.PLAIN)&&ro.identify(e.value))&&t?.doc.schema.tags.some(n=>n.tag===ro.tag&&n.default);function zh(t,e,n){if(n=t&&cs.isAlias(n)?n.resolve(t.doc):n,cs.isSeq(n))for(let r of n.items)Tc(t,e,r);else if(Array.isArray(n))for(let r of n)Tc(t,e,r);else Tc(t,e,n)}function Tc(t,e,n){let r=t&&cs.isAlias(n)?n.resolve(t.doc):n;if(!cs.isMap(r))throw new Error("Merge sources must be maps or map aliases");let s=r.toJSON(null,t,Map);for(let[i,o]of s)e instanceof Map?e.has(i)||e.set(i,o):e instanceof Set?e.add(i):Object.prototype.hasOwnProperty.call(e,i)||Object.defineProperty(e,i,{value:o,writable:!0,enumerable:!0,configurable:!0});return e}so.addMergeToJSMap=zh;so.isMergeKey=I0;so.merge=ro});var Oc=I(Gh=>{"use strict";var $0=Ac(),Yh=io(),N0=as(),Vh=W(),Cc=It();function L0(t,e,{key:n,value:r}){if(Vh.isNode(n)&&n.addToJSMap)n.addToJSMap(t,e,r);else if(Yh.isMergeKey(t,n))Yh.addMergeToJSMap(t,e,r);else{let s=Cc.toJS(n,"",t);if(e instanceof Map)e.set(s,Cc.toJS(r,s,t));else if(e instanceof Set)e.add(s);else{let i=M0(n,s,t),o=Cc.toJS(r,i,t);i in e?Object.defineProperty(e,i,{value:o,writable:!0,enumerable:!0,configurable:!0}):e[i]=o}}return e}function M0(t,e,n){if(e===null)return"";if(typeof e!="object")return String(e);if(Vh.isNode(t)&&n?.doc){let r=N0.createStringifyContext(n.doc,{});r.anchors=new Set;for(let i of n.anchors.keys())r.anchors.add(i.anchor);r.inFlow=!0,r.inStringifyKey=!0;let s=t.toString(r);if(!n.mapKeyWarned){let i=JSON.stringify(s);i.length>40&&(i=i.substring(0,36)+'..."'),$0.warn(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${i}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return s}return JSON.stringify(e)}Gh.addPairToJSMap=L0});var Mt=I(Pc=>{"use strict";var Xh=ns(),D0=Wh(),B0=Oc(),oo=W();function j0(t,e,n){let r=Xh.createNode(t,void 0,n),s=Xh.createNode(e,void 0,n);return new ao(r,s)}var ao=class t{constructor(e,n=null){Object.defineProperty(this,oo.NODE_TYPE,{value:oo.PAIR}),this.key=e,this.value=n}clone(e){let{key:n,value:r}=this;return oo.isNode(n)&&(n=n.clone(e)),oo.isNode(r)&&(r=r.clone(e)),new t(n,r)}toJSON(e,n){let r=n?.mapAsMap?new Map:{};return B0.addPairToJSMap(n,r,this)}toString(e,n,r){return e?.doc?D0.stringifyPair(this,e,n,r):JSON.stringify(this)}};Pc.Pair=ao;Pc.createPair=j0});var _c=I(Zh=>{"use strict";var un=W(),Qh=as(),lo=rs();function F0(t,e,n){return(e.inFlow??t.flow?q0:U0)(t,e,n)}function U0({comment:t,items:e},n,{blockItemPrefix:r,flowChars:s,itemIndent:i,onChompKeep:o,onComment:a}){let{indent:l,options:{commentString:c}}=n,f=Object.assign({},n,{indent:i,type:null}),d=!1,u=[];for(let h=0;h<e.length;++h){let m=e[h],g=null;if(un.isNode(m))!d&&m.spaceBefore&&u.push(""),co(n,u,m.commentBefore,d),m.comment&&(g=m.comment);else if(un.isPair(m)){let C=un.isNode(m.key)?m.key:null;C&&(!d&&C.spaceBefore&&u.push(""),co(n,u,C.commentBefore,d))}d=!1;let b=Qh.stringify(m,f,()=>g=null,()=>d=!0);g&&(b+=lo.lineComment(b,i,c(g))),d&&g&&(d=!1),u.push(r+b)}let p;if(u.length===0)p=s.start+s.end;else{p=u[0];for(let h=1;h<u.length;++h){let m=u[h];p+=m?`
68
- ${l}${m}`:`
64
+ ${n.indent}`}else if(!p&&mt.isCollection(e)){let _=R[0],x=R.indexOf(`
65
+ `),M=x!==-1,F=n.inFlow??e.flow??e.items.length===0;if(M||!F){let ee=!1;if(M&&(_==="&"||_==="!")){let q=R.indexOf(" ");_==="&"&&q!==-1&&q<x&&R[q+1]==="!"&&(q=R.indexOf(" ",q+1)),(q===-1||x<q)&&(ee=!0)}ee||(O=`
66
+ ${n.indent}`)}}else(R===""||R[0]===`
67
+ `)&&(O="");return g+=O+R,n.inFlow?E&&r&&r():T&&!E?g+=hs.lineComment(g,n.indent,l(T)):m&&s&&s(),g}Zh.stringifyPair=nE});var Rl=$(_l=>{"use strict";var tm=Ui("process");function rE(t,...e){t==="debug"&&console.log(...e)}function sE(t,e){(t==="debug"||t==="warn")&&(typeof tm.emitWarning=="function"?tm.emitWarning(e):console.warn(e))}_l.debug=rE;_l.warn=sE});var po=$(fo=>{"use strict";var ms=W(),nm=oe(),lo="<<",uo={identify:t=>t===lo||typeof t=="symbol"&&t.description===lo,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new nm.Scalar(Symbol(lo)),{addToJSMap:rm}),stringify:()=>lo},iE=(t,e)=>(uo.identify(e)||ms.isScalar(e)&&(!e.type||e.type===nm.Scalar.PLAIN)&&uo.identify(e.value))&&t?.doc.schema.tags.some(n=>n.tag===uo.tag&&n.default);function rm(t,e,n){if(n=t&&ms.isAlias(n)?n.resolve(t.doc):n,ms.isSeq(n))for(let r of n.items)Il(t,e,r);else if(Array.isArray(n))for(let r of n)Il(t,e,r);else Il(t,e,n)}function Il(t,e,n){let r=t&&ms.isAlias(n)?n.resolve(t.doc):n;if(!ms.isMap(r))throw new Error("Merge sources must be maps or map aliases");let s=r.toJSON(null,t,Map);for(let[i,o]of s)e instanceof Map?e.has(i)||e.set(i,o):e instanceof Set?e.add(i):Object.prototype.hasOwnProperty.call(e,i)||Object.defineProperty(e,i,{value:o,writable:!0,enumerable:!0,configurable:!0});return e}fo.addMergeToJSMap=rm;fo.isMergeKey=iE;fo.merge=uo});var Nl=$(om=>{"use strict";var oE=Rl(),sm=po(),aE=ps(),im=W(),$l=Rt();function cE(t,e,{key:n,value:r}){if(im.isNode(n)&&n.addToJSMap)n.addToJSMap(t,e,r);else if(sm.isMergeKey(t,n))sm.addMergeToJSMap(t,e,r);else{let s=$l.toJS(n,"",t);if(e instanceof Map)e.set(s,$l.toJS(r,s,t));else if(e instanceof Set)e.add(s);else{let i=lE(n,s,t),o=$l.toJS(r,i,t);i in e?Object.defineProperty(e,i,{value:o,writable:!0,enumerable:!0,configurable:!0}):e[i]=o}}return e}function lE(t,e,n){if(e===null)return"";if(typeof e!="object")return String(e);if(im.isNode(t)&&n?.doc){let r=aE.createStringifyContext(n.doc,{});r.anchors=new Set;for(let i of n.anchors.keys())r.anchors.add(i.anchor);r.inFlow=!0,r.inStringifyKey=!0;let s=t.toString(r);if(!n.mapKeyWarned){let i=JSON.stringify(s);i.length>40&&(i=i.substring(0,36)+'..."'),oE.warn(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${i}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return s}return JSON.stringify(e)}om.addPairToJSMap=cE});var Lt=$(Ll=>{"use strict";var am=cs(),uE=em(),dE=Nl(),ho=W();function fE(t,e,n){let r=am.createNode(t,void 0,n),s=am.createNode(e,void 0,n);return new mo(r,s)}var mo=class t{constructor(e,n=null){Object.defineProperty(this,ho.NODE_TYPE,{value:ho.PAIR}),this.key=e,this.value=n}clone(e){let{key:n,value:r}=this;return ho.isNode(n)&&(n=n.clone(e)),ho.isNode(r)&&(r=r.clone(e)),new t(n,r)}toJSON(e,n){let r=n?.mapAsMap?new Map:{};return dE.addPairToJSMap(n,r,this)}toString(e,n,r){return e?.doc?uE.stringifyPair(this,e,n,r):JSON.stringify(this)}};Ll.Pair=mo;Ll.createPair=fE});var Ml=$(lm=>{"use strict";var fn=W(),cm=ps(),go=ls();function pE(t,e,n){return(e.inFlow??t.flow?mE:hE)(t,e,n)}function hE({comment:t,items:e},n,{blockItemPrefix:r,flowChars:s,itemIndent:i,onChompKeep:o,onComment:a}){let{indent:c,options:{commentString:l}}=n,f=Object.assign({},n,{indent:i,type:null}),u=!1,d=[];for(let h=0;h<e.length;++h){let m=e[h],g=null;if(fn.isNode(m))!u&&m.spaceBefore&&d.push(""),yo(n,d,m.commentBefore,u),m.comment&&(g=m.comment);else if(fn.isPair(m)){let C=fn.isNode(m.key)?m.key:null;C&&(!u&&C.spaceBefore&&d.push(""),yo(n,d,C.commentBefore,u))}u=!1;let b=cm.stringify(m,f,()=>g=null,()=>u=!0);g&&(b+=go.lineComment(b,i,l(g))),u&&g&&(u=!1),d.push(r+b)}let p;if(d.length===0)p=s.start+s.end;else{p=d[0];for(let h=1;h<d.length;++h){let m=d[h];p+=m?`
68
+ ${c}${m}`:`
69
69
  `}}return t?(p+=`
70
- `+lo.indentComment(c(t),l),a&&a()):d&&o&&o(),p}function q0({items:t},e,{flowChars:n,itemIndent:r}){let{indent:s,indentStep:i,flowCollectionPadding:o,options:{commentString:a}}=e;r+=i;let l=Object.assign({},e,{indent:r,inFlow:!0,type:null}),c=!1,f=0,d=[];for(let h=0;h<t.length;++h){let m=t[h],g=null;if(un.isNode(m))m.spaceBefore&&d.push(""),co(e,d,m.commentBefore,!1),m.comment&&(g=m.comment);else if(un.isPair(m)){let C=un.isNode(m.key)?m.key:null;C&&(C.spaceBefore&&d.push(""),co(e,d,C.commentBefore,!1),C.comment&&(c=!0));let T=un.isNode(m.value)?m.value:null;T?(T.comment&&(g=T.comment),T.commentBefore&&(c=!0)):m.value==null&&C?.comment&&(g=C.comment)}g&&(c=!0);let b=Qh.stringify(m,l,()=>g=null);h<t.length-1&&(b+=","),g&&(b+=lo.lineComment(b,r,a(g))),!c&&(d.length>f||b.includes(`
71
- `))&&(c=!0),d.push(b),f=d.length}let{start:u,end:p}=n;if(d.length===0)return u+p;if(!c){let h=d.reduce((m,g)=>m+g.length+2,2);c=e.options.lineWidth>0&&h>e.options.lineWidth}if(c){let h=u;for(let m of d)h+=m?`
70
+ `+go.indentComment(l(t),c),a&&a()):u&&o&&o(),p}function mE({items:t},e,{flowChars:n,itemIndent:r}){let{indent:s,indentStep:i,flowCollectionPadding:o,options:{commentString:a}}=e;r+=i;let c=Object.assign({},e,{indent:r,inFlow:!0,type:null}),l=!1,f=0,u=[];for(let h=0;h<t.length;++h){let m=t[h],g=null;if(fn.isNode(m))m.spaceBefore&&u.push(""),yo(e,u,m.commentBefore,!1),m.comment&&(g=m.comment);else if(fn.isPair(m)){let C=fn.isNode(m.key)?m.key:null;C&&(C.spaceBefore&&u.push(""),yo(e,u,C.commentBefore,!1),C.comment&&(l=!0));let T=fn.isNode(m.value)?m.value:null;T?(T.comment&&(g=T.comment),T.commentBefore&&(l=!0)):m.value==null&&C?.comment&&(g=C.comment)}g&&(l=!0);let b=cm.stringify(m,c,()=>g=null);h<t.length-1&&(b+=","),g&&(b+=go.lineComment(b,r,a(g))),!l&&(u.length>f||b.includes(`
71
+ `))&&(l=!0),u.push(b),f=u.length}let{start:d,end:p}=n;if(u.length===0)return d+p;if(!l){let h=u.reduce((m,g)=>m+g.length+2,2);l=e.options.lineWidth>0&&h>e.options.lineWidth}if(l){let h=d;for(let m of u)h+=m?`
72
72
  ${i}${s}${m}`:`
73
73
  `;return`${h}
74
- ${s}${p}`}else return`${u}${o}${d.join(" ")}${o}${p}`}function co({indent:t,options:{commentString:e}},n,r,s){if(r&&s&&(r=r.replace(/^\n+/,"")),r){let i=lo.indentComment(e(r),t);n.push(i.trimStart())}}Zh.stringifyCollection=F0});var Bt=I(Ic=>{"use strict";var J0=_c(),W0=Oc(),K0=Gi(),Dt=W(),uo=Mt(),H0=re();function us(t,e){let n=Dt.isScalar(e)?e.value:e;for(let r of t)if(Dt.isPair(r)&&(r.key===e||r.key===n||Dt.isScalar(r.key)&&r.key.value===n))return r}var Rc=class extends K0.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Dt.MAP,e),this.items=[]}static from(e,n,r){let{keepUndefined:s,replacer:i}=r,o=new this(e),a=(l,c)=>{if(typeof i=="function")c=i.call(n,l,c);else if(Array.isArray(i)&&!i.includes(l))return;(c!==void 0||s)&&o.items.push(uo.createPair(l,c,r))};if(n instanceof Map)for(let[l,c]of n)a(l,c);else if(n&&typeof n=="object")for(let l of Object.keys(n))a(l,n[l]);return typeof e.sortMapEntries=="function"&&o.items.sort(e.sortMapEntries),o}add(e,n){let r;Dt.isPair(e)?r=e:!e||typeof e!="object"||!("key"in e)?r=new uo.Pair(e,e?.value):r=new uo.Pair(e.key,e.value);let s=us(this.items,r.key),i=this.schema?.sortMapEntries;if(s){if(!n)throw new Error(`Key ${r.key} already set`);Dt.isScalar(s.value)&&H0.isScalarValue(r.value)?s.value.value=r.value:s.value=r.value}else if(i){let o=this.items.findIndex(a=>i(r,a)<0);o===-1?this.items.push(r):this.items.splice(o,0,r)}else this.items.push(r)}delete(e){let n=us(this.items,e);return n?this.items.splice(this.items.indexOf(n),1).length>0:!1}get(e,n){let s=us(this.items,e)?.value;return(!n&&Dt.isScalar(s)?s.value:s)??void 0}has(e){return!!us(this.items,e)}set(e,n){this.add(new uo.Pair(e,n),!0)}toJSON(e,n,r){let s=r?new r:n?.mapAsMap?new Map:{};n?.onCreate&&n.onCreate(s);for(let i of this.items)W0.addPairToJSMap(n,s,i);return s}toString(e,n,r){if(!e)return JSON.stringify(this);for(let s of this.items)if(!Dt.isPair(s))throw new Error(`Map items must all be pairs; found ${JSON.stringify(s)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),J0.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:n})}};Ic.YAMLMap=Rc;Ic.findPair=us});var Vn=I(tm=>{"use strict";var z0=W(),em=Bt(),Y0={collection:"map",default:!0,nodeClass:em.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(t,e){return z0.isMap(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,n)=>em.YAMLMap.from(t,e,n)};tm.map=Y0});var jt=I(nm=>{"use strict";var V0=ns(),G0=_c(),X0=Gi(),po=W(),Q0=re(),Z0=It(),$c=class extends X0.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(po.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let n=fo(e);return typeof n!="number"?!1:this.items.splice(n,1).length>0}get(e,n){let r=fo(e);if(typeof r!="number")return;let s=this.items[r];return!n&&po.isScalar(s)?s.value:s}has(e){let n=fo(e);return typeof n=="number"&&n<this.items.length}set(e,n){let r=fo(e);if(typeof r!="number")throw new Error(`Expected a valid index, not ${e}.`);let s=this.items[r];po.isScalar(s)&&Q0.isScalarValue(n)?s.value=n:this.items[r]=n}toJSON(e,n){let r=[];n?.onCreate&&n.onCreate(r);let s=0;for(let i of this.items)r.push(Z0.toJS(i,String(s++),n));return r}toString(e,n,r){return e?G0.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:r,onComment:n}):JSON.stringify(this)}static from(e,n,r){let{replacer:s}=r,i=new this(e);if(n&&Symbol.iterator in Object(n)){let o=0;for(let a of n){if(typeof s=="function"){let l=n instanceof Set?a:String(o++);a=s.call(n,l,a)}i.items.push(V0.createNode(a,void 0,r))}}return i}};function fo(t){let e=po.isScalar(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}nm.YAMLSeq=$c});var Gn=I(sm=>{"use strict";var eE=W(),rm=jt(),tE={collection:"seq",default:!0,nodeClass:rm.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(t,e){return eE.isSeq(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,n)=>rm.YAMLSeq.from(t,e,n)};sm.seq=tE});var ds=I(im=>{"use strict";var nE=os(),rE={identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify(t,e,n,r){return e=Object.assign({actualString:!0},e),nE.stringifyString(t,e,n,r)}};im.string=rE});var ho=I(lm=>{"use strict";var om=re(),am={identify:t=>t==null,createNode:()=>new om.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new om.Scalar(null),stringify:({source:t},e)=>typeof t=="string"&&am.test.test(t)?t:e.options.nullStr};lm.nullTag=am});var Nc=I(um=>{"use strict";var sE=re(),cm={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new sE.Scalar(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},n){if(t&&cm.test.test(t)){let r=t[0]==="t"||t[0]==="T";if(e===r)return t}return e?n.options.trueStr:n.options.falseStr}};um.boolTag=cm});var Xn=I(dm=>{"use strict";function iE({format:t,minFractionDigits:e,tag:n,value:r}){if(typeof r=="bigint")return String(r);let s=typeof r=="number"?r:Number(r);if(!isFinite(s))return isNaN(s)?".nan":s<0?"-.inf":".inf";let i=Object.is(r,-0)?"-0":JSON.stringify(r);if(!t&&e&&(!n||n==="tag:yaml.org,2002:float")&&/^\d/.test(i)){let o=i.indexOf(".");o<0&&(o=i.length,i+=".");let a=e-(i.length-o-1);for(;a-- >0;)i+="0"}return i}dm.stringifyNumber=iE});var Mc=I(mo=>{"use strict";var oE=re(),Lc=Xn(),aE={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Lc.stringifyNumber},lE={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():Lc.stringifyNumber(t)}},cE={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(t){let e=new oE.Scalar(parseFloat(t)),n=t.indexOf(".");return n!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-n-1),e},stringify:Lc.stringifyNumber};mo.float=cE;mo.floatExp=lE;mo.floatNaN=aE});var Bc=I(yo=>{"use strict";var fm=Xn(),go=t=>typeof t=="bigint"||Number.isInteger(t),Dc=(t,e,n,{intAsBigInt:r})=>r?BigInt(t):parseInt(t.substring(e),n);function pm(t,e,n){let{value:r}=t;return go(r)&&r>=0?n+r.toString(e):fm.stringifyNumber(t)}var uE={identify:t=>go(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,n)=>Dc(t,2,8,n),stringify:t=>pm(t,8,"0o")},dE={identify:go,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,n)=>Dc(t,0,10,n),stringify:fm.stringifyNumber},fE={identify:t=>go(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,n)=>Dc(t,2,16,n),stringify:t=>pm(t,16,"0x")};yo.int=dE;yo.intHex=fE;yo.intOct=uE});var mm=I(hm=>{"use strict";var pE=Vn(),hE=ho(),mE=Gn(),gE=ds(),yE=Nc(),jc=Mc(),Fc=Bc(),bE=[pE.map,mE.seq,gE.string,hE.nullTag,yE.boolTag,Fc.intOct,Fc.int,Fc.intHex,jc.floatNaN,jc.floatExp,jc.float];hm.schema=bE});var bm=I(ym=>{"use strict";var wE=re(),vE=Vn(),SE=Gn();function gm(t){return typeof t=="bigint"||Number.isInteger(t)}var bo=({value:t})=>JSON.stringify(t),kE=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:bo},{identify:t=>t==null,createNode:()=>new wE.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:bo},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:bo},{identify:gm,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(t,e,{intAsBigInt:n})=>n?BigInt(t):parseInt(t,10),stringify:({value:t})=>gm(t)?t.toString():JSON.stringify(t)},{identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:t=>parseFloat(t),stringify:bo}],xE={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},EE=[vE.map,SE.seq].concat(kE,xE);ym.schema=EE});var qc=I(wm=>{"use strict";var fs=Ni("buffer"),Uc=re(),AE=os(),TE={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof fs.Buffer=="function")return fs.Buffer.from(t,"base64");if(typeof atob=="function"){let n=atob(t.replace(/[\n\r]/g,"")),r=new Uint8Array(n.length);for(let s=0;s<n.length;++s)r[s]=n.charCodeAt(s);return r}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),t},stringify({comment:t,type:e,value:n},r,s,i){if(!n)return"";let o=n,a;if(typeof fs.Buffer=="function")a=o instanceof fs.Buffer?o.toString("base64"):fs.Buffer.from(o.buffer).toString("base64");else if(typeof btoa=="function"){let l="";for(let c=0;c<o.length;++c)l+=String.fromCharCode(o[c]);a=btoa(l)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e??(e=Uc.Scalar.BLOCK_LITERAL),e!==Uc.Scalar.QUOTE_DOUBLE){let l=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),c=Math.ceil(a.length/l),f=new Array(c);for(let d=0,u=0;d<c;++d,u+=l)f[d]=a.substr(u,l);a=f.join(e===Uc.Scalar.BLOCK_LITERAL?`
75
- `:" ")}return AE.stringifyString({comment:t,type:e,value:a},r,s,i)}};wm.binary=TE});var So=I(vo=>{"use strict";var wo=W(),Jc=Mt(),CE=re(),OE=jt();function vm(t,e){if(wo.isSeq(t))for(let n=0;n<t.items.length;++n){let r=t.items[n];if(!wo.isPair(r)){if(wo.isMap(r)){r.items.length>1&&e("Each pair must have its own sequence indicator");let s=r.items[0]||new Jc.Pair(new CE.Scalar(null));if(r.commentBefore&&(s.key.commentBefore=s.key.commentBefore?`${r.commentBefore}
74
+ ${s}${p}`}else return`${d}${o}${u.join(" ")}${o}${p}`}function yo({indent:t,options:{commentString:e}},n,r,s){if(r&&s&&(r=r.replace(/^\n+/,"")),r){let i=go.indentComment(e(r),t);n.push(i.trimStart())}}lm.stringifyCollection=pE});var Dt=$(Bl=>{"use strict";var gE=Ml(),yE=Nl(),bE=ro(),Mt=W(),bo=Lt(),wE=oe();function gs(t,e){let n=Mt.isScalar(e)?e.value:e;for(let r of t)if(Mt.isPair(r)&&(r.key===e||r.key===n||Mt.isScalar(r.key)&&r.key.value===n))return r}var Dl=class extends bE.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Mt.MAP,e),this.items=[]}static from(e,n,r){let{keepUndefined:s,replacer:i}=r,o=new this(e),a=(c,l)=>{if(typeof i=="function")l=i.call(n,c,l);else if(Array.isArray(i)&&!i.includes(c))return;(l!==void 0||s)&&o.items.push(bo.createPair(c,l,r))};if(n instanceof Map)for(let[c,l]of n)a(c,l);else if(n&&typeof n=="object")for(let c of Object.keys(n))a(c,n[c]);return typeof e.sortMapEntries=="function"&&o.items.sort(e.sortMapEntries),o}add(e,n){let r;Mt.isPair(e)?r=e:!e||typeof e!="object"||!("key"in e)?r=new bo.Pair(e,e?.value):r=new bo.Pair(e.key,e.value);let s=gs(this.items,r.key),i=this.schema?.sortMapEntries;if(s){if(!n)throw new Error(`Key ${r.key} already set`);Mt.isScalar(s.value)&&wE.isScalarValue(r.value)?s.value.value=r.value:s.value=r.value}else if(i){let o=this.items.findIndex(a=>i(r,a)<0);o===-1?this.items.push(r):this.items.splice(o,0,r)}else this.items.push(r)}delete(e){let n=gs(this.items,e);return n?this.items.splice(this.items.indexOf(n),1).length>0:!1}get(e,n){let s=gs(this.items,e)?.value;return(!n&&Mt.isScalar(s)?s.value:s)??void 0}has(e){return!!gs(this.items,e)}set(e,n){this.add(new bo.Pair(e,n),!0)}toJSON(e,n,r){let s=r?new r:n?.mapAsMap?new Map:{};n?.onCreate&&n.onCreate(s);for(let i of this.items)yE.addPairToJSMap(n,s,i);return s}toString(e,n,r){if(!e)return JSON.stringify(this);for(let s of this.items)if(!Mt.isPair(s))throw new Error(`Map items must all be pairs; found ${JSON.stringify(s)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),gE.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:n})}};Bl.YAMLMap=Dl;Bl.findPair=gs});var Xn=$(dm=>{"use strict";var vE=W(),um=Dt(),SE={collection:"map",default:!0,nodeClass:um.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(t,e){return vE.isMap(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,n)=>um.YAMLMap.from(t,e,n)};dm.map=SE});var Bt=$(fm=>{"use strict";var kE=cs(),xE=Ml(),EE=ro(),vo=W(),AE=oe(),TE=Rt(),jl=class extends EE.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(vo.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let n=wo(e);return typeof n!="number"?!1:this.items.splice(n,1).length>0}get(e,n){let r=wo(e);if(typeof r!="number")return;let s=this.items[r];return!n&&vo.isScalar(s)?s.value:s}has(e){let n=wo(e);return typeof n=="number"&&n<this.items.length}set(e,n){let r=wo(e);if(typeof r!="number")throw new Error(`Expected a valid index, not ${e}.`);let s=this.items[r];vo.isScalar(s)&&AE.isScalarValue(n)?s.value=n:this.items[r]=n}toJSON(e,n){let r=[];n?.onCreate&&n.onCreate(r);let s=0;for(let i of this.items)r.push(TE.toJS(i,String(s++),n));return r}toString(e,n,r){return e?xE.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:r,onComment:n}):JSON.stringify(this)}static from(e,n,r){let{replacer:s}=r,i=new this(e);if(n&&Symbol.iterator in Object(n)){let o=0;for(let a of n){if(typeof s=="function"){let c=n instanceof Set?a:String(o++);a=s.call(n,c,a)}i.items.push(kE.createNode(a,void 0,r))}}return i}};function wo(t){let e=vo.isScalar(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}fm.YAMLSeq=jl});var Qn=$(hm=>{"use strict";var CE=W(),pm=Bt(),OE={collection:"seq",default:!0,nodeClass:pm.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(t,e){return CE.isSeq(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,n)=>pm.YAMLSeq.from(t,e,n)};hm.seq=OE});var ys=$(mm=>{"use strict";var PE=fs(),_E={identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify(t,e,n,r){return e=Object.assign({actualString:!0},e),PE.stringifyString(t,e,n,r)}};mm.string=_E});var So=$(bm=>{"use strict";var gm=oe(),ym={identify:t=>t==null,createNode:()=>new gm.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new gm.Scalar(null),stringify:({source:t},e)=>typeof t=="string"&&ym.test.test(t)?t:e.options.nullStr};bm.nullTag=ym});var Fl=$(vm=>{"use strict";var RE=oe(),wm={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new RE.Scalar(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},n){if(t&&wm.test.test(t)){let r=t[0]==="t"||t[0]==="T";if(e===r)return t}return e?n.options.trueStr:n.options.falseStr}};vm.boolTag=wm});var Zn=$(Sm=>{"use strict";function IE({format:t,minFractionDigits:e,tag:n,value:r}){if(typeof r=="bigint")return String(r);let s=typeof r=="number"?r:Number(r);if(!isFinite(s))return isNaN(s)?".nan":s<0?"-.inf":".inf";let i=Object.is(r,-0)?"-0":JSON.stringify(r);if(!t&&e&&(!n||n==="tag:yaml.org,2002:float")&&/^\d/.test(i)){let o=i.indexOf(".");o<0&&(o=i.length,i+=".");let a=e-(i.length-o-1);for(;a-- >0;)i+="0"}return i}Sm.stringifyNumber=IE});var ql=$(ko=>{"use strict";var $E=oe(),Ul=Zn(),NE={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Ul.stringifyNumber},LE={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():Ul.stringifyNumber(t)}},ME={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(t){let e=new $E.Scalar(parseFloat(t)),n=t.indexOf(".");return n!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-n-1),e},stringify:Ul.stringifyNumber};ko.float=ME;ko.floatExp=LE;ko.floatNaN=NE});var Wl=$(Eo=>{"use strict";var km=Zn(),xo=t=>typeof t=="bigint"||Number.isInteger(t),Jl=(t,e,n,{intAsBigInt:r})=>r?BigInt(t):parseInt(t.substring(e),n);function xm(t,e,n){let{value:r}=t;return xo(r)&&r>=0?n+r.toString(e):km.stringifyNumber(t)}var DE={identify:t=>xo(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,n)=>Jl(t,2,8,n),stringify:t=>xm(t,8,"0o")},BE={identify:xo,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,n)=>Jl(t,0,10,n),stringify:km.stringifyNumber},jE={identify:t=>xo(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,n)=>Jl(t,2,16,n),stringify:t=>xm(t,16,"0x")};Eo.int=BE;Eo.intHex=jE;Eo.intOct=DE});var Am=$(Em=>{"use strict";var FE=Xn(),UE=So(),qE=Qn(),JE=ys(),WE=Fl(),Kl=ql(),Hl=Wl(),KE=[FE.map,qE.seq,JE.string,UE.nullTag,WE.boolTag,Hl.intOct,Hl.int,Hl.intHex,Kl.floatNaN,Kl.floatExp,Kl.float];Em.schema=KE});var Om=$(Cm=>{"use strict";var HE=oe(),zE=Xn(),YE=Qn();function Tm(t){return typeof t=="bigint"||Number.isInteger(t)}var Ao=({value:t})=>JSON.stringify(t),VE=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:Ao},{identify:t=>t==null,createNode:()=>new HE.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Ao},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:Ao},{identify:Tm,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(t,e,{intAsBigInt:n})=>n?BigInt(t):parseInt(t,10),stringify:({value:t})=>Tm(t)?t.toString():JSON.stringify(t)},{identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:t=>parseFloat(t),stringify:Ao}],GE={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},XE=[zE.map,YE.seq].concat(VE,GE);Cm.schema=XE});var Yl=$(Pm=>{"use strict";var bs=Ui("buffer"),zl=oe(),QE=fs(),ZE={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof bs.Buffer=="function")return bs.Buffer.from(t,"base64");if(typeof atob=="function"){let n=atob(t.replace(/[\n\r]/g,"")),r=new Uint8Array(n.length);for(let s=0;s<n.length;++s)r[s]=n.charCodeAt(s);return r}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),t},stringify({comment:t,type:e,value:n},r,s,i){if(!n)return"";let o=n,a;if(typeof bs.Buffer=="function")a=o instanceof bs.Buffer?o.toString("base64"):bs.Buffer.from(o.buffer).toString("base64");else if(typeof btoa=="function"){let c="";for(let l=0;l<o.length;++l)c+=String.fromCharCode(o[l]);a=btoa(c)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e??(e=zl.Scalar.BLOCK_LITERAL),e!==zl.Scalar.QUOTE_DOUBLE){let c=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),l=Math.ceil(a.length/c),f=new Array(l);for(let u=0,d=0;u<l;++u,d+=c)f[u]=a.substr(d,c);a=f.join(e===zl.Scalar.BLOCK_LITERAL?`
75
+ `:" ")}return QE.stringifyString({comment:t,type:e,value:a},r,s,i)}};Pm.binary=ZE});var Oo=$(Co=>{"use strict";var To=W(),Vl=Lt(),eA=oe(),tA=Bt();function _m(t,e){if(To.isSeq(t))for(let n=0;n<t.items.length;++n){let r=t.items[n];if(!To.isPair(r)){if(To.isMap(r)){r.items.length>1&&e("Each pair must have its own sequence indicator");let s=r.items[0]||new Vl.Pair(new eA.Scalar(null));if(r.commentBefore&&(s.key.commentBefore=s.key.commentBefore?`${r.commentBefore}
76
76
  ${s.key.commentBefore}`:r.commentBefore),r.comment){let i=s.value??s.key;i.comment=i.comment?`${r.comment}
77
- ${i.comment}`:r.comment}r=s}t.items[n]=wo.isPair(r)?r:new Jc.Pair(r)}}else e("Expected a sequence for this tag");return t}function Sm(t,e,n){let{replacer:r}=n,s=new OE.YAMLSeq(t);s.tag="tag:yaml.org,2002:pairs";let i=0;if(e&&Symbol.iterator in Object(e))for(let o of e){typeof r=="function"&&(o=r.call(e,String(i++),o));let a,l;if(Array.isArray(o))if(o.length===2)a=o[0],l=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let c=Object.keys(o);if(c.length===1)a=c[0],l=o[a];else throw new TypeError(`Expected tuple with one key, not ${c.length} keys`)}else a=o;s.items.push(Jc.createPair(a,l,n))}return s}var PE={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:vm,createNode:Sm};vo.createPairs=Sm;vo.pairs=PE;vo.resolvePairs=vm});var Hc=I(Kc=>{"use strict";var km=W(),Wc=It(),ps=Bt(),_E=jt(),xm=So(),dn=class t extends _E.YAMLSeq{constructor(){super(),this.add=ps.YAMLMap.prototype.add.bind(this),this.delete=ps.YAMLMap.prototype.delete.bind(this),this.get=ps.YAMLMap.prototype.get.bind(this),this.has=ps.YAMLMap.prototype.has.bind(this),this.set=ps.YAMLMap.prototype.set.bind(this),this.tag=t.tag}toJSON(e,n){if(!n)return super.toJSON(e);let r=new Map;n?.onCreate&&n.onCreate(r);for(let s of this.items){let i,o;if(km.isPair(s)?(i=Wc.toJS(s.key,"",n),o=Wc.toJS(s.value,i,n)):i=Wc.toJS(s,"",n),r.has(i))throw new Error("Ordered maps must not include duplicate keys");r.set(i,o)}return r}static from(e,n,r){let s=xm.createPairs(e,n,r),i=new this;return i.items=s.items,i}};dn.tag="tag:yaml.org,2002:omap";var RE={collection:"seq",identify:t=>t instanceof Map,nodeClass:dn,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let n=xm.resolvePairs(t,e),r=[];for(let{key:s}of n.items)km.isScalar(s)&&(r.includes(s.value)?e(`Ordered maps must not include duplicate keys: ${s.value}`):r.push(s.value));return Object.assign(new dn,n)},createNode:(t,e,n)=>dn.from(t,e,n)};Kc.YAMLOMap=dn;Kc.omap=RE});var Om=I(zc=>{"use strict";var Em=re();function Am({value:t,source:e},n){return e&&(t?Tm:Cm).test.test(e)?e:t?n.options.trueStr:n.options.falseStr}var Tm={identify:t=>t===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Em.Scalar(!0),stringify:Am},Cm={identify:t=>t===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Em.Scalar(!1),stringify:Am};zc.falseTag=Cm;zc.trueTag=Tm});var Pm=I(ko=>{"use strict";var IE=re(),Yc=Xn(),$E={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Yc.stringifyNumber},NE={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t.replace(/_/g,"")),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():Yc.stringifyNumber(t)}},LE={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(t){let e=new IE.Scalar(parseFloat(t.replace(/_/g,""))),n=t.indexOf(".");if(n!==-1){let r=t.substring(n+1).replace(/_/g,"");r[r.length-1]==="0"&&(e.minFractionDigits=r.length)}return e},stringify:Yc.stringifyNumber};ko.float=LE;ko.floatExp=NE;ko.floatNaN=$E});var Rm=I(ms=>{"use strict";var _m=Xn(),hs=t=>typeof t=="bigint"||Number.isInteger(t);function xo(t,e,n,{intAsBigInt:r}){let s=t[0];if((s==="-"||s==="+")&&(e+=1),t=t.substring(e).replace(/_/g,""),r){switch(n){case 2:t=`0b${t}`;break;case 8:t=`0o${t}`;break;case 16:t=`0x${t}`;break}let o=BigInt(t);return s==="-"?BigInt(-1)*o:o}let i=parseInt(t,n);return s==="-"?-1*i:i}function Vc(t,e,n){let{value:r}=t;if(hs(r)){let s=r.toString(e);return r<0?"-"+n+s.substr(1):n+s}return _m.stringifyNumber(t)}var ME={identify:hs,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,n)=>xo(t,2,2,n),stringify:t=>Vc(t,2,"0b")},DE={identify:hs,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,n)=>xo(t,1,8,n),stringify:t=>Vc(t,8,"0")},BE={identify:hs,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,n)=>xo(t,0,10,n),stringify:_m.stringifyNumber},jE={identify:hs,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,n)=>xo(t,2,16,n),stringify:t=>Vc(t,16,"0x")};ms.int=BE;ms.intBin=ME;ms.intHex=jE;ms.intOct=DE});var Xc=I(Gc=>{"use strict";var To=W(),Eo=Mt(),Ao=Bt(),fn=class t extends Ao.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let n;To.isPair(e)?n=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?n=new Eo.Pair(e.key,null):n=new Eo.Pair(e,null),Ao.findPair(this.items,n.key)||this.items.push(n)}get(e,n){let r=Ao.findPair(this.items,e);return!n&&To.isPair(r)?To.isScalar(r.key)?r.key.value:r.key:r}set(e,n){if(typeof n!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof n}`);let r=Ao.findPair(this.items,e);r&&!n?this.items.splice(this.items.indexOf(r),1):!r&&n&&this.items.push(new Eo.Pair(e))}toJSON(e,n){return super.toJSON(e,n,Set)}toString(e,n,r){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),n,r);throw new Error("Set items must all have null values")}static from(e,n,r){let{replacer:s}=r,i=new this(e);if(n&&Symbol.iterator in Object(n))for(let o of n)typeof s=="function"&&(o=s.call(n,o,o)),i.items.push(Eo.createPair(o,null,r));return i}};fn.tag="tag:yaml.org,2002:set";var FE={collection:"map",identify:t=>t instanceof Set,nodeClass:fn,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,n)=>fn.from(t,e,n),resolve(t,e){if(To.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new fn,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};Gc.YAMLSet=fn;Gc.set=FE});var Zc=I(Co=>{"use strict";var UE=Xn();function Qc(t,e){let n=t[0],r=n==="-"||n==="+"?t.substring(1):t,s=o=>e?BigInt(o):Number(o),i=r.replace(/_/g,"").split(":").reduce((o,a)=>o*s(60)+s(a),s(0));return n==="-"?s(-1)*i:i}function Im(t){let{value:e}=t,n=o=>o;if(typeof e=="bigint")n=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return UE.stringifyNumber(t);let r="";e<0&&(r="-",e*=n(-1));let s=n(60),i=[e%s];return e<60?i.unshift(0):(e=(e-i[0])/s,i.unshift(e%s),e>=60&&(e=(e-i[0])/s,i.unshift(e))),r+i.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var qE={identify:t=>typeof t=="bigint"||Number.isInteger(t),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(t,e,{intAsBigInt:n})=>Qc(t,n),stringify:Im},JE={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:t=>Qc(t,!1),stringify:Im},$m={identify:t=>t instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(t){let e=t.match($m.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,n,r,s,i,o,a]=e.map(Number),l=e[7]?Number((e[7]+"00").substr(1,3)):0,c=Date.UTC(n,r-1,s,i||0,o||0,a||0,l),f=e[8];if(f&&f!=="Z"){let d=Qc(f,!1);Math.abs(d)<30&&(d*=60),c-=6e4*d}return new Date(c)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};Co.floatTime=JE;Co.intTime=qE;Co.timestamp=$m});var Mm=I(Lm=>{"use strict";var WE=Vn(),KE=ho(),HE=Gn(),zE=ds(),YE=qc(),Nm=Om(),eu=Pm(),Oo=Rm(),VE=io(),GE=Hc(),XE=So(),QE=Xc(),tu=Zc(),ZE=[WE.map,HE.seq,zE.string,KE.nullTag,Nm.trueTag,Nm.falseTag,Oo.intBin,Oo.intOct,Oo.int,Oo.intHex,eu.floatNaN,eu.floatExp,eu.float,YE.binary,VE.merge,GE.omap,XE.pairs,QE.set,tu.intTime,tu.floatTime,tu.timestamp];Lm.schema=ZE});var Hm=I(su=>{"use strict";var Fm=Vn(),eA=ho(),Um=Gn(),tA=ds(),nA=Nc(),nu=Mc(),ru=Bc(),rA=mm(),sA=bm(),qm=qc(),gs=io(),Jm=Hc(),Wm=So(),Dm=Mm(),Km=Xc(),Po=Zc(),Bm=new Map([["core",rA.schema],["failsafe",[Fm.map,Um.seq,tA.string]],["json",sA.schema],["yaml11",Dm.schema],["yaml-1.1",Dm.schema]]),jm={binary:qm.binary,bool:nA.boolTag,float:nu.float,floatExp:nu.floatExp,floatNaN:nu.floatNaN,floatTime:Po.floatTime,int:ru.int,intHex:ru.intHex,intOct:ru.intOct,intTime:Po.intTime,map:Fm.map,merge:gs.merge,null:eA.nullTag,omap:Jm.omap,pairs:Wm.pairs,seq:Um.seq,set:Km.set,timestamp:Po.timestamp},iA={"tag:yaml.org,2002:binary":qm.binary,"tag:yaml.org,2002:merge":gs.merge,"tag:yaml.org,2002:omap":Jm.omap,"tag:yaml.org,2002:pairs":Wm.pairs,"tag:yaml.org,2002:set":Km.set,"tag:yaml.org,2002:timestamp":Po.timestamp};function oA(t,e,n){let r=Bm.get(e);if(r&&!t)return n&&!r.includes(gs.merge)?r.concat(gs.merge):r.slice();let s=r;if(!s)if(Array.isArray(t))s=[];else{let i=Array.from(Bm.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${i} or define customTags array`)}if(Array.isArray(t))for(let i of t)s=s.concat(i);else typeof t=="function"&&(s=t(s.slice()));return n&&(s=s.concat(gs.merge)),s.reduce((i,o)=>{let a=typeof o=="string"?jm[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(jm).map(f=>JSON.stringify(f)).join(", ");throw new Error(`Unknown custom tag ${l}; use one of ${c}`)}return i.includes(a)||i.push(a),i},[])}su.coreKnownTags=iA;su.getTags=oA});var au=I(zm=>{"use strict";var iu=W(),aA=Vn(),lA=Gn(),cA=ds(),_o=Hm(),uA=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,ou=class t{constructor({compat:e,customTags:n,merge:r,resolveKnownTags:s,schema:i,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(e)?_o.getTags(e,"compat"):e?_o.getTags(null,e):null,this.name=typeof i=="string"&&i||"core",this.knownTags=s?_o.coreKnownTags:{},this.tags=_o.getTags(n,this.name,r),this.toStringOptions=a??null,Object.defineProperty(this,iu.MAP,{value:aA.map}),Object.defineProperty(this,iu.SCALAR,{value:cA.string}),Object.defineProperty(this,iu.SEQ,{value:lA.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?uA:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};zm.Schema=ou});var Vm=I(Ym=>{"use strict";var dA=W(),lu=as(),ys=rs();function fA(t,e){let n=[],r=e.directives===!0;if(e.directives!==!1&&t.directives){let l=t.directives.toString(t);l?(n.push(l),r=!0):t.directives.docStart&&(r=!0)}r&&n.push("---");let s=lu.createStringifyContext(t,e),{commentString:i}=s.options;if(t.commentBefore){n.length!==1&&n.unshift("");let l=i(t.commentBefore);n.unshift(ys.indentComment(l,""))}let o=!1,a=null;if(t.contents){if(dA.isNode(t.contents)){if(t.contents.spaceBefore&&r&&n.push(""),t.contents.commentBefore){let f=i(t.contents.commentBefore);n.push(ys.indentComment(f,""))}s.forceBlockIndent=!!t.comment,a=t.contents.comment}let l=a?void 0:()=>o=!0,c=lu.stringify(t.contents,s,()=>a=null,l);a&&(c+=ys.lineComment(c,"",i(a))),(c[0]==="|"||c[0]===">")&&n[n.length-1]==="---"?n[n.length-1]=`--- ${c}`:n.push(c)}else n.push(lu.stringify(t.contents,s));if(t.directives?.docEnd)if(t.comment){let l=i(t.comment);l.includes(`
78
- `)?(n.push("..."),n.push(ys.indentComment(l,""))):n.push(`... ${l}`)}else n.push("...");else{let l=t.comment;l&&o&&(l=l.replace(/^\n+/,"")),l&&((!o||a)&&n[n.length-1]!==""&&n.push(""),n.push(ys.indentComment(i(l),"")))}return n.join(`
77
+ ${i.comment}`:r.comment}r=s}t.items[n]=To.isPair(r)?r:new Vl.Pair(r)}}else e("Expected a sequence for this tag");return t}function Rm(t,e,n){let{replacer:r}=n,s=new tA.YAMLSeq(t);s.tag="tag:yaml.org,2002:pairs";let i=0;if(e&&Symbol.iterator in Object(e))for(let o of e){typeof r=="function"&&(o=r.call(e,String(i++),o));let a,c;if(Array.isArray(o))if(o.length===2)a=o[0],c=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let l=Object.keys(o);if(l.length===1)a=l[0],c=o[a];else throw new TypeError(`Expected tuple with one key, not ${l.length} keys`)}else a=o;s.items.push(Vl.createPair(a,c,n))}return s}var nA={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:_m,createNode:Rm};Co.createPairs=Rm;Co.pairs=nA;Co.resolvePairs=_m});var Ql=$(Xl=>{"use strict";var Im=W(),Gl=Rt(),ws=Dt(),rA=Bt(),$m=Oo(),pn=class t extends rA.YAMLSeq{constructor(){super(),this.add=ws.YAMLMap.prototype.add.bind(this),this.delete=ws.YAMLMap.prototype.delete.bind(this),this.get=ws.YAMLMap.prototype.get.bind(this),this.has=ws.YAMLMap.prototype.has.bind(this),this.set=ws.YAMLMap.prototype.set.bind(this),this.tag=t.tag}toJSON(e,n){if(!n)return super.toJSON(e);let r=new Map;n?.onCreate&&n.onCreate(r);for(let s of this.items){let i,o;if(Im.isPair(s)?(i=Gl.toJS(s.key,"",n),o=Gl.toJS(s.value,i,n)):i=Gl.toJS(s,"",n),r.has(i))throw new Error("Ordered maps must not include duplicate keys");r.set(i,o)}return r}static from(e,n,r){let s=$m.createPairs(e,n,r),i=new this;return i.items=s.items,i}};pn.tag="tag:yaml.org,2002:omap";var sA={collection:"seq",identify:t=>t instanceof Map,nodeClass:pn,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let n=$m.resolvePairs(t,e),r=[];for(let{key:s}of n.items)Im.isScalar(s)&&(r.includes(s.value)?e(`Ordered maps must not include duplicate keys: ${s.value}`):r.push(s.value));return Object.assign(new pn,n)},createNode:(t,e,n)=>pn.from(t,e,n)};Xl.YAMLOMap=pn;Xl.omap=sA});var Bm=$(Zl=>{"use strict";var Nm=oe();function Lm({value:t,source:e},n){return e&&(t?Mm:Dm).test.test(e)?e:t?n.options.trueStr:n.options.falseStr}var Mm={identify:t=>t===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Nm.Scalar(!0),stringify:Lm},Dm={identify:t=>t===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Nm.Scalar(!1),stringify:Lm};Zl.falseTag=Dm;Zl.trueTag=Mm});var jm=$(Po=>{"use strict";var iA=oe(),eu=Zn(),oA={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:eu.stringifyNumber},aA={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t.replace(/_/g,"")),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():eu.stringifyNumber(t)}},cA={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(t){let e=new iA.Scalar(parseFloat(t.replace(/_/g,""))),n=t.indexOf(".");if(n!==-1){let r=t.substring(n+1).replace(/_/g,"");r[r.length-1]==="0"&&(e.minFractionDigits=r.length)}return e},stringify:eu.stringifyNumber};Po.float=cA;Po.floatExp=aA;Po.floatNaN=oA});var Um=$(Ss=>{"use strict";var Fm=Zn(),vs=t=>typeof t=="bigint"||Number.isInteger(t);function _o(t,e,n,{intAsBigInt:r}){let s=t[0];if((s==="-"||s==="+")&&(e+=1),t=t.substring(e).replace(/_/g,""),r){switch(n){case 2:t=`0b${t}`;break;case 8:t=`0o${t}`;break;case 16:t=`0x${t}`;break}let o=BigInt(t);return s==="-"?BigInt(-1)*o:o}let i=parseInt(t,n);return s==="-"?-1*i:i}function tu(t,e,n){let{value:r}=t;if(vs(r)){let s=r.toString(e);return r<0?"-"+n+s.substr(1):n+s}return Fm.stringifyNumber(t)}var lA={identify:vs,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,n)=>_o(t,2,2,n),stringify:t=>tu(t,2,"0b")},uA={identify:vs,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,n)=>_o(t,1,8,n),stringify:t=>tu(t,8,"0")},dA={identify:vs,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,n)=>_o(t,0,10,n),stringify:Fm.stringifyNumber},fA={identify:vs,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,n)=>_o(t,2,16,n),stringify:t=>tu(t,16,"0x")};Ss.int=dA;Ss.intBin=lA;Ss.intHex=fA;Ss.intOct=uA});var ru=$(nu=>{"use strict";var $o=W(),Ro=Lt(),Io=Dt(),hn=class t extends Io.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let n;$o.isPair(e)?n=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?n=new Ro.Pair(e.key,null):n=new Ro.Pair(e,null),Io.findPair(this.items,n.key)||this.items.push(n)}get(e,n){let r=Io.findPair(this.items,e);return!n&&$o.isPair(r)?$o.isScalar(r.key)?r.key.value:r.key:r}set(e,n){if(typeof n!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof n}`);let r=Io.findPair(this.items,e);r&&!n?this.items.splice(this.items.indexOf(r),1):!r&&n&&this.items.push(new Ro.Pair(e))}toJSON(e,n){return super.toJSON(e,n,Set)}toString(e,n,r){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),n,r);throw new Error("Set items must all have null values")}static from(e,n,r){let{replacer:s}=r,i=new this(e);if(n&&Symbol.iterator in Object(n))for(let o of n)typeof s=="function"&&(o=s.call(n,o,o)),i.items.push(Ro.createPair(o,null,r));return i}};hn.tag="tag:yaml.org,2002:set";var pA={collection:"map",identify:t=>t instanceof Set,nodeClass:hn,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,n)=>hn.from(t,e,n),resolve(t,e){if($o.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new hn,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};nu.YAMLSet=hn;nu.set=pA});var iu=$(No=>{"use strict";var hA=Zn();function su(t,e){let n=t[0],r=n==="-"||n==="+"?t.substring(1):t,s=o=>e?BigInt(o):Number(o),i=r.replace(/_/g,"").split(":").reduce((o,a)=>o*s(60)+s(a),s(0));return n==="-"?s(-1)*i:i}function qm(t){let{value:e}=t,n=o=>o;if(typeof e=="bigint")n=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return hA.stringifyNumber(t);let r="";e<0&&(r="-",e*=n(-1));let s=n(60),i=[e%s];return e<60?i.unshift(0):(e=(e-i[0])/s,i.unshift(e%s),e>=60&&(e=(e-i[0])/s,i.unshift(e))),r+i.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var mA={identify:t=>typeof t=="bigint"||Number.isInteger(t),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(t,e,{intAsBigInt:n})=>su(t,n),stringify:qm},gA={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:t=>su(t,!1),stringify:qm},Jm={identify:t=>t instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(t){let e=t.match(Jm.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,n,r,s,i,o,a]=e.map(Number),c=e[7]?Number((e[7]+"00").substr(1,3)):0,l=Date.UTC(n,r-1,s,i||0,o||0,a||0,c),f=e[8];if(f&&f!=="Z"){let u=su(f,!1);Math.abs(u)<30&&(u*=60),l-=6e4*u}return new Date(l)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};No.floatTime=gA;No.intTime=mA;No.timestamp=Jm});var Hm=$(Km=>{"use strict";var yA=Xn(),bA=So(),wA=Qn(),vA=ys(),SA=Yl(),Wm=Bm(),ou=jm(),Lo=Um(),kA=po(),xA=Ql(),EA=Oo(),AA=ru(),au=iu(),TA=[yA.map,wA.seq,vA.string,bA.nullTag,Wm.trueTag,Wm.falseTag,Lo.intBin,Lo.intOct,Lo.int,Lo.intHex,ou.floatNaN,ou.floatExp,ou.float,SA.binary,kA.merge,xA.omap,EA.pairs,AA.set,au.intTime,au.floatTime,au.timestamp];Km.schema=TA});var ng=$(uu=>{"use strict";var Gm=Xn(),CA=So(),Xm=Qn(),OA=ys(),PA=Fl(),cu=ql(),lu=Wl(),_A=Am(),RA=Om(),Qm=Yl(),ks=po(),Zm=Ql(),eg=Oo(),zm=Hm(),tg=ru(),Mo=iu(),Ym=new Map([["core",_A.schema],["failsafe",[Gm.map,Xm.seq,OA.string]],["json",RA.schema],["yaml11",zm.schema],["yaml-1.1",zm.schema]]),Vm={binary:Qm.binary,bool:PA.boolTag,float:cu.float,floatExp:cu.floatExp,floatNaN:cu.floatNaN,floatTime:Mo.floatTime,int:lu.int,intHex:lu.intHex,intOct:lu.intOct,intTime:Mo.intTime,map:Gm.map,merge:ks.merge,null:CA.nullTag,omap:Zm.omap,pairs:eg.pairs,seq:Xm.seq,set:tg.set,timestamp:Mo.timestamp},IA={"tag:yaml.org,2002:binary":Qm.binary,"tag:yaml.org,2002:merge":ks.merge,"tag:yaml.org,2002:omap":Zm.omap,"tag:yaml.org,2002:pairs":eg.pairs,"tag:yaml.org,2002:set":tg.set,"tag:yaml.org,2002:timestamp":Mo.timestamp};function $A(t,e,n){let r=Ym.get(e);if(r&&!t)return n&&!r.includes(ks.merge)?r.concat(ks.merge):r.slice();let s=r;if(!s)if(Array.isArray(t))s=[];else{let i=Array.from(Ym.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${i} or define customTags array`)}if(Array.isArray(t))for(let i of t)s=s.concat(i);else typeof t=="function"&&(s=t(s.slice()));return n&&(s=s.concat(ks.merge)),s.reduce((i,o)=>{let a=typeof o=="string"?Vm[o]:o;if(!a){let c=JSON.stringify(o),l=Object.keys(Vm).map(f=>JSON.stringify(f)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${l}`)}return i.includes(a)||i.push(a),i},[])}uu.coreKnownTags=IA;uu.getTags=$A});var pu=$(rg=>{"use strict";var du=W(),NA=Xn(),LA=Qn(),MA=ys(),Do=ng(),DA=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,fu=class t{constructor({compat:e,customTags:n,merge:r,resolveKnownTags:s,schema:i,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(e)?Do.getTags(e,"compat"):e?Do.getTags(null,e):null,this.name=typeof i=="string"&&i||"core",this.knownTags=s?Do.coreKnownTags:{},this.tags=Do.getTags(n,this.name,r),this.toStringOptions=a??null,Object.defineProperty(this,du.MAP,{value:NA.map}),Object.defineProperty(this,du.SCALAR,{value:MA.string}),Object.defineProperty(this,du.SEQ,{value:LA.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?DA:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};rg.Schema=fu});var ig=$(sg=>{"use strict";var BA=W(),hu=ps(),xs=ls();function jA(t,e){let n=[],r=e.directives===!0;if(e.directives!==!1&&t.directives){let c=t.directives.toString(t);c?(n.push(c),r=!0):t.directives.docStart&&(r=!0)}r&&n.push("---");let s=hu.createStringifyContext(t,e),{commentString:i}=s.options;if(t.commentBefore){n.length!==1&&n.unshift("");let c=i(t.commentBefore);n.unshift(xs.indentComment(c,""))}let o=!1,a=null;if(t.contents){if(BA.isNode(t.contents)){if(t.contents.spaceBefore&&r&&n.push(""),t.contents.commentBefore){let f=i(t.contents.commentBefore);n.push(xs.indentComment(f,""))}s.forceBlockIndent=!!t.comment,a=t.contents.comment}let c=a?void 0:()=>o=!0,l=hu.stringify(t.contents,s,()=>a=null,c);a&&(l+=xs.lineComment(l,"",i(a))),(l[0]==="|"||l[0]===">")&&n[n.length-1]==="---"?n[n.length-1]=`--- ${l}`:n.push(l)}else n.push(hu.stringify(t.contents,s));if(t.directives?.docEnd)if(t.comment){let c=i(t.comment);c.includes(`
78
+ `)?(n.push("..."),n.push(xs.indentComment(c,""))):n.push(`... ${c}`)}else n.push("...");else{let c=t.comment;c&&o&&(c=c.replace(/^\n+/,"")),c&&((!o||a)&&n[n.length-1]!==""&&n.push(""),n.push(xs.indentComment(i(c),"")))}return n.join(`
79
79
  `)+`
80
- `}Ym.stringifyDocument=fA});var bs=I(Gm=>{"use strict";var pA=ts(),Qn=Gi(),De=W(),hA=Mt(),mA=It(),gA=au(),yA=Vm(),cu=Hi(),bA=pc(),wA=ns(),uu=fc(),du=class t{constructor(e,n,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,De.NODE_TYPE,{value:De.DOC});let s=null;typeof n=="function"||Array.isArray(n)?s=n:r===void 0&&n&&(r=n,n=void 0);let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},r);this.options=i;let{version:o}=i;r?._directives?(this.directives=r._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new uu.Directives({version:o}),this.setSchema(o,r),this.contents=e===void 0?null:this.createNode(e,s,r)}clone(){let e=Object.create(t.prototype,{[De.NODE_TYPE]:{value:De.DOC}});return e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives&&(e.directives=this.directives.clone()),e.schema=this.schema.clone(),e.contents=De.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){Zn(this.contents)&&this.contents.add(e)}addIn(e,n){Zn(this.contents)&&this.contents.addIn(e,n)}createAlias(e,n){if(!e.anchor){let r=cu.anchorNames(this);e.anchor=!n||r.has(n)?cu.findNewAnchor(n||"a",r):n}return new pA.Alias(e.anchor)}createNode(e,n,r){let s;if(typeof n=="function")e=n.call({"":e},"",e),s=n;else if(Array.isArray(n)){let g=C=>typeof C=="number"||C instanceof String||C instanceof Number,b=n.filter(g).map(String);b.length>0&&(n=n.concat(b)),s=n}else r===void 0&&n&&(r=n,n=void 0);let{aliasDuplicateObjects:i,anchorPrefix:o,flow:a,keepUndefined:l,onTagObj:c,tag:f}=r??{},{onAnchor:d,setAnchors:u,sourceObjects:p}=cu.createNodeAnchors(this,o||"a"),h={aliasDuplicateObjects:i??!0,keepUndefined:l??!1,onAnchor:d,onTagObj:c,replacer:s,schema:this.schema,sourceObjects:p},m=wA.createNode(e,f,h);return a&&De.isCollection(m)&&(m.flow=!0),u(),m}createPair(e,n,r={}){let s=this.createNode(e,null,r),i=this.createNode(n,null,r);return new hA.Pair(s,i)}delete(e){return Zn(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Qn.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):Zn(this.contents)?this.contents.deleteIn(e):!1}get(e,n){return De.isCollection(this.contents)?this.contents.get(e,n):void 0}getIn(e,n){return Qn.isEmptyPath(e)?!n&&De.isScalar(this.contents)?this.contents.value:this.contents:De.isCollection(this.contents)?this.contents.getIn(e,n):void 0}has(e){return De.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return Qn.isEmptyPath(e)?this.contents!==void 0:De.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,n){this.contents==null?this.contents=Qn.collectionFromPath(this.schema,[e],n):Zn(this.contents)&&this.contents.set(e,n)}setIn(e,n){Qn.isEmptyPath(e)?this.contents=n:this.contents==null?this.contents=Qn.collectionFromPath(this.schema,Array.from(e),n):Zn(this.contents)&&this.contents.setIn(e,n)}setSchema(e,n={}){typeof e=="number"&&(e=String(e));let r;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new uu.Directives({version:"1.1"}),r={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new uu.Directives({version:e}),r={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,r=null;break;default:{let s=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${s}`)}}if(n.schema instanceof Object)this.schema=n.schema;else if(r)this.schema=new gA.Schema(Object.assign(r,n));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:n,mapAsMap:r,maxAliasCount:s,onAnchor:i,reviver:o}={}){let a={anchors:new Map,doc:this,keep:!e,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof s=="number"?s:100},l=mA.toJS(this.contents,n??"",a);if(typeof i=="function")for(let{count:c,res:f}of a.anchors.values())i(f,c);return typeof o=="function"?bA.applyReviver(o,{"":l},"",l):l}toJSON(e,n){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:n})}toString(e={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let n=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${n}`)}return yA.stringifyDocument(this,e)}};function Zn(t){if(De.isCollection(t))return!0;throw new Error("Expected a YAML collection as document contents")}Gm.Document=du});var Ss=I(vs=>{"use strict";var ws=class extends Error{constructor(e,n,r,s){super(),this.name=e,this.code=r,this.message=s,this.pos=n}},fu=class extends ws{constructor(e,n,r){super("YAMLParseError",e,n,r)}},pu=class extends ws{constructor(e,n,r){super("YAMLWarning",e,n,r)}},vA=(t,e)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(a=>e.linePos(a));let{line:r,col:s}=n.linePos[0];n.message+=` at line ${r}, column ${s}`;let i=s-1,o=t.substring(e.lineStarts[r-1],e.lineStarts[r]).replace(/[\n\r]+$/,"");if(i>=60&&o.length>80){let a=Math.min(i-39,o.length-79);o="\u2026"+o.substring(a),i-=a-1}if(o.length>80&&(o=o.substring(0,79)+"\u2026"),r>1&&/^ *$/.test(o.substring(0,i))){let a=t.substring(e.lineStarts[r-2],e.lineStarts[r-1]);a.length>80&&(a=a.substring(0,79)+`\u2026
81
- `),o=a+o}if(/[^ ]/.test(o)){let a=1,l=n.linePos[1];l?.line===r&&l.col>s&&(a=Math.max(1,Math.min(l.col-s,80-i)));let c=" ".repeat(i)+"^".repeat(a);n.message+=`:
80
+ `}sg.stringifyDocument=jA});var Es=$(og=>{"use strict";var FA=as(),er=ro(),je=W(),UA=Lt(),qA=Rt(),JA=pu(),WA=ig(),mu=Zi(),KA=wl(),HA=cs(),gu=bl(),yu=class t{constructor(e,n,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,je.NODE_TYPE,{value:je.DOC});let s=null;typeof n=="function"||Array.isArray(n)?s=n:r===void 0&&n&&(r=n,n=void 0);let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},r);this.options=i;let{version:o}=i;r?._directives?(this.directives=r._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new gu.Directives({version:o}),this.setSchema(o,r),this.contents=e===void 0?null:this.createNode(e,s,r)}clone(){let e=Object.create(t.prototype,{[je.NODE_TYPE]:{value:je.DOC}});return e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives&&(e.directives=this.directives.clone()),e.schema=this.schema.clone(),e.contents=je.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){tr(this.contents)&&this.contents.add(e)}addIn(e,n){tr(this.contents)&&this.contents.addIn(e,n)}createAlias(e,n){if(!e.anchor){let r=mu.anchorNames(this);e.anchor=!n||r.has(n)?mu.findNewAnchor(n||"a",r):n}return new FA.Alias(e.anchor)}createNode(e,n,r){let s;if(typeof n=="function")e=n.call({"":e},"",e),s=n;else if(Array.isArray(n)){let g=C=>typeof C=="number"||C instanceof String||C instanceof Number,b=n.filter(g).map(String);b.length>0&&(n=n.concat(b)),s=n}else r===void 0&&n&&(r=n,n=void 0);let{aliasDuplicateObjects:i,anchorPrefix:o,flow:a,keepUndefined:c,onTagObj:l,tag:f}=r??{},{onAnchor:u,setAnchors:d,sourceObjects:p}=mu.createNodeAnchors(this,o||"a"),h={aliasDuplicateObjects:i??!0,keepUndefined:c??!1,onAnchor:u,onTagObj:l,replacer:s,schema:this.schema,sourceObjects:p},m=HA.createNode(e,f,h);return a&&je.isCollection(m)&&(m.flow=!0),d(),m}createPair(e,n,r={}){let s=this.createNode(e,null,r),i=this.createNode(n,null,r);return new UA.Pair(s,i)}delete(e){return tr(this.contents)?this.contents.delete(e):!1}deleteIn(e){return er.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):tr(this.contents)?this.contents.deleteIn(e):!1}get(e,n){return je.isCollection(this.contents)?this.contents.get(e,n):void 0}getIn(e,n){return er.isEmptyPath(e)?!n&&je.isScalar(this.contents)?this.contents.value:this.contents:je.isCollection(this.contents)?this.contents.getIn(e,n):void 0}has(e){return je.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return er.isEmptyPath(e)?this.contents!==void 0:je.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,n){this.contents==null?this.contents=er.collectionFromPath(this.schema,[e],n):tr(this.contents)&&this.contents.set(e,n)}setIn(e,n){er.isEmptyPath(e)?this.contents=n:this.contents==null?this.contents=er.collectionFromPath(this.schema,Array.from(e),n):tr(this.contents)&&this.contents.setIn(e,n)}setSchema(e,n={}){typeof e=="number"&&(e=String(e));let r;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new gu.Directives({version:"1.1"}),r={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new gu.Directives({version:e}),r={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,r=null;break;default:{let s=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${s}`)}}if(n.schema instanceof Object)this.schema=n.schema;else if(r)this.schema=new JA.Schema(Object.assign(r,n));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:n,mapAsMap:r,maxAliasCount:s,onAnchor:i,reviver:o}={}){let a={anchors:new Map,doc:this,keep:!e,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof s=="number"?s:100},c=qA.toJS(this.contents,n??"",a);if(typeof i=="function")for(let{count:l,res:f}of a.anchors.values())i(f,l);return typeof o=="function"?KA.applyReviver(o,{"":c},"",c):c}toJSON(e,n){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:n})}toString(e={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let n=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${n}`)}return WA.stringifyDocument(this,e)}};function tr(t){if(je.isCollection(t))return!0;throw new Error("Expected a YAML collection as document contents")}og.Document=yu});var Cs=$(Ts=>{"use strict";var As=class extends Error{constructor(e,n,r,s){super(),this.name=e,this.code=r,this.message=s,this.pos=n}},bu=class extends As{constructor(e,n,r){super("YAMLParseError",e,n,r)}},wu=class extends As{constructor(e,n,r){super("YAMLWarning",e,n,r)}},zA=(t,e)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(a=>e.linePos(a));let{line:r,col:s}=n.linePos[0];n.message+=` at line ${r}, column ${s}`;let i=s-1,o=t.substring(e.lineStarts[r-1],e.lineStarts[r]).replace(/[\n\r]+$/,"");if(i>=60&&o.length>80){let a=Math.min(i-39,o.length-79);o="\u2026"+o.substring(a),i-=a-1}if(o.length>80&&(o=o.substring(0,79)+"\u2026"),r>1&&/^ *$/.test(o.substring(0,i))){let a=t.substring(e.lineStarts[r-2],e.lineStarts[r-1]);a.length>80&&(a=a.substring(0,79)+`\u2026
81
+ `),o=a+o}if(/[^ ]/.test(o)){let a=1,c=n.linePos[1];c?.line===r&&c.col>s&&(a=Math.max(1,Math.min(c.col-s,80-i)));let l=" ".repeat(i)+"^".repeat(a);n.message+=`:
82
82
 
83
83
  ${o}
84
- ${c}
85
- `}};vs.YAMLError=ws;vs.YAMLParseError=fu;vs.YAMLWarning=pu;vs.prettifyError=vA});var ks=I(Xm=>{"use strict";function SA(t,{flow:e,indicator:n,next:r,offset:s,onError:i,parentIndent:o,startOnNewline:a}){let l=!1,c=a,f=a,d="",u="",p=!1,h=!1,m=null,g=null,b=null,C=null,T=null,E=null,$=null;for(let k of t)switch(h&&(k.type!=="space"&&k.type!=="newline"&&k.type!=="comma"&&i(k.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),h=!1),m&&(c&&k.type!=="comment"&&k.type!=="newline"&&i(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),m=null),k.type){case"space":!e&&(n!=="doc-start"||r?.type!=="flow-collection")&&k.source.includes(" ")&&(m=k),f=!0;break;case"comment":{f||i(k,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let L=k.source.substring(1)||" ";d?d+=u+L:d=L,u="",c=!1;break}case"newline":c?d?d+=k.source:(!E||n!=="seq-item-ind")&&(l=!0):u+=k.source,c=!0,p=!0,(g||b)&&(C=k),f=!0;break;case"anchor":g&&i(k,"MULTIPLE_ANCHORS","A node can have at most one anchor"),k.source.endsWith(":")&&i(k.offset+k.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),g=k,$??($=k.offset),c=!1,f=!1,h=!0;break;case"tag":{b&&i(k,"MULTIPLE_TAGS","A node can have at most one tag"),b=k,$??($=k.offset),c=!1,f=!1,h=!0;break}case n:(g||b)&&i(k,"BAD_PROP_ORDER",`Anchors and tags must be after the ${k.source} indicator`),E&&i(k,"UNEXPECTED_TOKEN",`Unexpected ${k.source} in ${e??"collection"}`),E=k,c=n==="seq-item-ind"||n==="explicit-key-ind",f=!1;break;case"comma":if(e){T&&i(k,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),T=k,c=!1,f=!1;break}default:i(k,"UNEXPECTED_TOKEN",`Unexpected ${k.type} token`),c=!1,f=!1}let O=t[t.length-1],P=O?O.offset+O.source.length:s;return h&&r&&r.type!=="space"&&r.type!=="newline"&&r.type!=="comma"&&(r.type!=="scalar"||r.source!=="")&&i(r.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m&&(c&&m.indent<=o||r?.type==="block-map"||r?.type==="block-seq")&&i(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:T,found:E,spaceBefore:l,comment:d,hasNewline:p,anchor:g,tag:b,newlineAfterProp:C,end:P,start:$??P}}Xm.resolveProps=SA});var Ro=I(Qm=>{"use strict";function hu(t){if(!t)return null;switch(t.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(t.source.includes(`
86
- `))return!0;if(t.end){for(let e of t.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of t.items){for(let n of e.start)if(n.type==="newline")return!0;if(e.sep){for(let n of e.sep)if(n.type==="newline")return!0}if(hu(e.key)||hu(e.value))return!0}return!1;default:return!0}}Qm.containsNewline=hu});var mu=I(Zm=>{"use strict";var kA=Ro();function xA(t,e,n){if(e?.type==="flow-collection"){let r=e.end[0];r.indent===t&&(r.source==="]"||r.source==="}")&&kA.containsNewline(e)&&n(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}Zm.flowIndentCheck=xA});var gu=I(tg=>{"use strict";var eg=W();function EA(t,e,n){let{uniqueKeys:r}=t.options;if(r===!1)return!1;let s=typeof r=="function"?r:(i,o)=>i===o||eg.isScalar(i)&&eg.isScalar(o)&&i.value===o.value;return e.some(i=>s(i.key,n))}tg.mapIncludes=EA});var ag=I(og=>{"use strict";var ng=Mt(),AA=Bt(),rg=ks(),TA=Ro(),sg=mu(),CA=gu(),ig="All mapping items must start at the same column";function OA({composeNode:t,composeEmptyNode:e},n,r,s,i){let o=i?.nodeClass??AA.YAMLMap,a=new o(n.schema);n.atRoot&&(n.atRoot=!1);let l=r.offset,c=null;for(let f of r.items){let{start:d,key:u,sep:p,value:h}=f,m=rg.resolveProps(d,{indicator:"explicit-key-ind",next:u??p?.[0],offset:l,onError:s,parentIndent:r.indent,startOnNewline:!0}),g=!m.found;if(g){if(u&&(u.type==="block-seq"?s(l,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in u&&u.indent!==r.indent&&s(l,"BAD_INDENT",ig)),!m.anchor&&!m.tag&&!p){c=m.end,m.comment&&(a.comment?a.comment+=`
87
- `+m.comment:a.comment=m.comment);continue}(m.newlineAfterProp||TA.containsNewline(u))&&s(u??d[d.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else m.found?.indent!==r.indent&&s(l,"BAD_INDENT",ig);n.atKey=!0;let b=m.end,C=u?t(n,u,m,s):e(n,b,d,null,m,s);n.schema.compat&&sg.flowIndentCheck(r.indent,u,s),n.atKey=!1,CA.mapIncludes(n,a.items,C)&&s(b,"DUPLICATE_KEY","Map keys must be unique");let T=rg.resolveProps(p??[],{indicator:"map-value-ind",next:h,offset:C.range[2],onError:s,parentIndent:r.indent,startOnNewline:!u||u.type==="block-scalar"});if(l=T.end,T.found){g&&(h?.type==="block-map"&&!T.hasNewline&&s(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),n.options.strict&&m.start<T.found.offset-1024&&s(C.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let E=h?t(n,h,T,s):e(n,l,p,null,T,s);n.schema.compat&&sg.flowIndentCheck(r.indent,h,s),l=E.range[2];let $=new ng.Pair(C,E);n.options.keepSourceTokens&&($.srcToken=f),a.items.push($)}else{g&&s(C.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),T.comment&&(C.comment?C.comment+=`
88
- `+T.comment:C.comment=T.comment);let E=new ng.Pair(C);n.options.keepSourceTokens&&(E.srcToken=f),a.items.push(E)}}return c&&c<l&&s(c,"IMPOSSIBLE","Map comment with trailing content"),a.range=[r.offset,l,c??l],a}og.resolveBlockMap=OA});var cg=I(lg=>{"use strict";var PA=jt(),_A=ks(),RA=mu();function IA({composeNode:t,composeEmptyNode:e},n,r,s,i){let o=i?.nodeClass??PA.YAMLSeq,a=new o(n.schema);n.atRoot&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let l=r.offset,c=null;for(let{start:f,value:d}of r.items){let u=_A.resolveProps(f,{indicator:"seq-item-ind",next:d,offset:l,onError:s,parentIndent:r.indent,startOnNewline:!0});if(!u.found)if(u.anchor||u.tag||d)d?.type==="block-seq"?s(u.end,"BAD_INDENT","All sequence items must start at the same column"):s(l,"MISSING_CHAR","Sequence item without - indicator");else{c=u.end,u.comment&&(a.comment=u.comment);continue}let p=d?t(n,d,u,s):e(n,u.end,f,null,u,s);n.schema.compat&&RA.flowIndentCheck(r.indent,d,s),l=p.range[2],a.items.push(p)}return a.range=[r.offset,l,c??l],a}lg.resolveBlockSeq=IA});var er=I(ug=>{"use strict";function $A(t,e,n,r){let s="";if(t){let i=!1,o="";for(let a of t){let{source:l,type:c}=a;switch(c){case"space":i=!0;break;case"comment":{n&&!i&&r(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let f=l.substring(1)||" ";s?s+=o+f:s=f,o="";break}case"newline":s&&(o+=l),i=!0;break;default:r(a,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}e+=l.length}}return{comment:s,offset:e}}ug.resolveEnd=$A});var hg=I(pg=>{"use strict";var NA=W(),LA=Mt(),dg=Bt(),MA=jt(),DA=er(),fg=ks(),BA=Ro(),jA=gu(),yu="Block collections are not allowed within flow collections",bu=t=>t&&(t.type==="block-map"||t.type==="block-seq");function FA({composeNode:t,composeEmptyNode:e},n,r,s,i){let o=r.start.source==="{",a=o?"flow map":"flow sequence",l=i?.nodeClass??(o?dg.YAMLMap:MA.YAMLSeq),c=new l(n.schema);c.flow=!0;let f=n.atRoot;f&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let d=r.offset+r.start.source.length;for(let g=0;g<r.items.length;++g){let b=r.items[g],{start:C,key:T,sep:E,value:$}=b,O=fg.resolveProps(C,{flow:a,indicator:"explicit-key-ind",next:T??E?.[0],offset:d,onError:s,parentIndent:r.indent,startOnNewline:!1});if(!O.found){if(!O.anchor&&!O.tag&&!E&&!$){g===0&&O.comma?s(O.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):g<r.items.length-1&&s(O.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),O.comment&&(c.comment?c.comment+=`
89
- `+O.comment:c.comment=O.comment),d=O.end;continue}!o&&n.options.strict&&BA.containsNewline(T)&&s(T,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(g===0)O.comma&&s(O.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(O.comma||s(O.start,"MISSING_CHAR",`Missing , between ${a} items`),O.comment){let P="";e:for(let k of C)switch(k.type){case"comma":case"space":break;case"comment":P=k.source.substring(1);break e;default:break e}if(P){let k=c.items[c.items.length-1];NA.isPair(k)&&(k=k.value??k.key),k.comment?k.comment+=`
90
- `+P:k.comment=P,O.comment=O.comment.substring(P.length+1)}}if(!o&&!E&&!O.found){let P=$?t(n,$,O,s):e(n,O.end,E,null,O,s);c.items.push(P),d=P.range[2],bu($)&&s(P.range,"BLOCK_IN_FLOW",yu)}else{n.atKey=!0;let P=O.end,k=T?t(n,T,O,s):e(n,P,C,null,O,s);bu(T)&&s(k.range,"BLOCK_IN_FLOW",yu),n.atKey=!1;let L=fg.resolveProps(E??[],{flow:a,indicator:"map-value-ind",next:$,offset:k.range[2],onError:s,parentIndent:r.indent,startOnNewline:!1});if(L.found){if(!o&&!O.found&&n.options.strict){if(E)for(let U of E){if(U===L.found)break;if(U.type==="newline"){s(U,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}O.start<L.found.offset-1024&&s(L.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else $&&("source"in $&&$.source?.[0]===":"?s($,"MISSING_CHAR",`Missing space after : in ${a}`):s(L.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let j=$?t(n,$,L,s):L.found?e(n,L.end,E,null,L,s):null;j?bu($)&&s(j.range,"BLOCK_IN_FLOW",yu):L.comment&&(k.comment?k.comment+=`
91
- `+L.comment:k.comment=L.comment);let Q=new LA.Pair(k,j);if(n.options.keepSourceTokens&&(Q.srcToken=b),o){let U=c;jA.mapIncludes(n,U.items,k)&&s(P,"DUPLICATE_KEY","Map keys must be unique"),U.items.push(Q)}else{let U=new dg.YAMLMap(n.schema);U.flow=!0,U.items.push(Q);let ie=(j??k).range;U.range=[k.range[0],ie[1],ie[2]],c.items.push(U)}d=j?j.range[2]:L.end}}let u=o?"}":"]",[p,...h]=r.end,m=d;if(p?.source===u)m=p.offset+p.source.length;else{let g=a[0].toUpperCase()+a.substring(1),b=f?`${g} must end with a ${u}`:`${g} in block collection must be sufficiently indented and end with a ${u}`;s(d,f?"MISSING_CHAR":"BAD_INDENT",b),p&&p.source.length!==1&&h.unshift(p)}if(h.length>0){let g=DA.resolveEnd(h,m,n.options.strict,s);g.comment&&(c.comment?c.comment+=`
92
- `+g.comment:c.comment=g.comment),c.range=[r.offset,m,g.offset]}else c.range=[r.offset,m,m];return c}pg.resolveFlowCollection=FA});var gg=I(mg=>{"use strict";var UA=W(),qA=re(),JA=Bt(),WA=jt(),KA=ag(),HA=cg(),zA=hg();function wu(t,e,n,r,s,i){let o=n.type==="block-map"?KA.resolveBlockMap(t,e,n,r,i):n.type==="block-seq"?HA.resolveBlockSeq(t,e,n,r,i):zA.resolveFlowCollection(t,e,n,r,i),a=o.constructor;return s==="!"||s===a.tagName?(o.tag=a.tagName,o):(s&&(o.tag=s),o)}function YA(t,e,n,r,s){let i=r.tag,o=i?e.directives.tagName(i.source,u=>s(i,"TAG_RESOLVE_FAILED",u)):null;if(n.type==="block-seq"){let{anchor:u,newlineAfterProp:p}=r,h=u&&i?u.offset>i.offset?u:i:u??i;h&&(!p||p.offset<h.offset)&&s(h,"MISSING_CHAR","Missing newline after block sequence props")}let a=n.type==="block-map"?"map":n.type==="block-seq"?"seq":n.start.source==="{"?"map":"seq";if(!i||!o||o==="!"||o===JA.YAMLMap.tagName&&a==="map"||o===WA.YAMLSeq.tagName&&a==="seq")return wu(t,e,n,s,o);let l=e.schema.tags.find(u=>u.tag===o&&u.collection===a);if(!l){let u=e.schema.knownTags[o];if(u?.collection===a)e.schema.tags.push(Object.assign({},u,{default:!1})),l=u;else return u?s(i,"BAD_COLLECTION_TYPE",`${u.tag} used for ${a} collection, but expects ${u.collection??"scalar"}`,!0):s(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),wu(t,e,n,s,o)}let c=wu(t,e,n,s,o,l),f=l.resolve?.(c,u=>s(i,"TAG_RESOLVE_FAILED",u),e.options)??c,d=UA.isNode(f)?f:new qA.Scalar(f);return d.range=c.range,d.tag=o,l?.format&&(d.format=l.format),d}mg.composeCollection=YA});var Su=I(yg=>{"use strict";var vu=re();function VA(t,e,n){let r=e.offset,s=GA(e,t.options.strict,n);if(!s)return{value:"",type:null,comment:"",range:[r,r,r]};let i=s.mode===">"?vu.Scalar.BLOCK_FOLDED:vu.Scalar.BLOCK_LITERAL,o=e.source?XA(e.source):[],a=o.length;for(let m=o.length-1;m>=0;--m){let g=o[m][1];if(g===""||g==="\r")a=m;else break}if(a===0){let m=s.chomp==="+"&&o.length>0?`
93
- `.repeat(Math.max(1,o.length-1)):"",g=r+s.length;return e.source&&(g+=e.source.length),{value:m,type:i,comment:s.comment,range:[r,g,g]}}let l=e.indent+s.indent,c=e.offset+s.length,f=0;for(let m=0;m<a;++m){let[g,b]=o[m];if(b===""||b==="\r")s.indent===0&&g.length>l&&(l=g.length);else{g.length<l&&n(c+g.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),s.indent===0&&(l=g.length),f=m,l===0&&!t.atRoot&&n(c,"BAD_INDENT","Block scalar values in collections must be indented");break}c+=g.length+b.length+1}for(let m=o.length-1;m>=a;--m)o[m][0].length>l&&(a=m+1);let d="",u="",p=!1;for(let m=0;m<f;++m)d+=o[m][0].slice(l)+`
94
- `;for(let m=f;m<a;++m){let[g,b]=o[m];c+=g.length+b.length+1;let C=b[b.length-1]==="\r";if(C&&(b=b.slice(0,-1)),b&&g.length<l){let E=`Block scalar lines must not be less indented than their ${s.indent?"explicit indentation indicator":"first line"}`;n(c-b.length-(C?2:1),"BAD_INDENT",E),g=""}i===vu.Scalar.BLOCK_LITERAL?(d+=u+g.slice(l)+b,u=`
95
- `):g.length>l||b[0]===" "?(u===" "?u=`
96
- `:!p&&u===`
97
- `&&(u=`
98
-
99
- `),d+=u+g.slice(l)+b,u=`
100
- `,p=!0):b===""?u===`
101
- `?d+=`
102
- `:u=`
103
- `:(d+=u+b,u=" ",p=!1)}switch(s.chomp){case"-":break;case"+":for(let m=a;m<o.length;++m)d+=`
104
- `+o[m][0].slice(l);d[d.length-1]!==`
105
- `&&(d+=`
106
- `);break;default:d+=`
107
- `}let h=r+s.length+e.source.length;return{value:d,type:i,comment:s.comment,range:[r,h,h]}}function GA({offset:t,props:e},n,r){if(e[0].type!=="block-scalar-header")return r(e[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:s}=e[0],i=s[0],o=0,a="",l=-1;for(let u=1;u<s.length;++u){let p=s[u];if(!a&&(p==="-"||p==="+"))a=p;else{let h=Number(p);!o&&h?o=h:l===-1&&(l=t+u)}}l!==-1&&r(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${s}`);let c=!1,f="",d=s.length;for(let u=1;u<e.length;++u){let p=e[u];switch(p.type){case"space":c=!0;case"newline":d+=p.source.length;break;case"comment":n&&!c&&r(p,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),d+=p.source.length,f=p.source.substring(1);break;case"error":r(p,"UNEXPECTED_TOKEN",p.message),d+=p.source.length;break;default:{let h=`Unexpected token in block scalar header: ${p.type}`;r(p,"UNEXPECTED_TOKEN",h);let m=p.source;m&&typeof m=="string"&&(d+=m.length)}}}return{mode:i,indent:o,chomp:a,comment:f,length:d}}function XA(t){let e=t.split(/\n( *)/),n=e[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:["",n]];for(let o=1;o<e.length;o+=2)i.push([e[o],e[o+1]]);return i}yg.resolveBlockScalar=VA});var xu=I(wg=>{"use strict";var ku=re(),QA=er();function ZA(t,e,n){let{offset:r,type:s,source:i,end:o}=t,a,l,c=(u,p,h)=>n(r+u,p,h);switch(s){case"scalar":a=ku.Scalar.PLAIN,l=eT(i,c);break;case"single-quoted-scalar":a=ku.Scalar.QUOTE_SINGLE,l=tT(i,c);break;case"double-quoted-scalar":a=ku.Scalar.QUOTE_DOUBLE,l=nT(i,c);break;default:return n(t,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${s}`),{value:"",type:null,comment:"",range:[r,r+i.length,r+i.length]}}let f=r+i.length,d=QA.resolveEnd(o,f,e,n);return{value:l,type:a,comment:d.comment,range:[r,f,d.offset]}}function eT(t,e){let n="";switch(t[0]){case" ":n="a tab character";break;case",":n="flow indicator character ,";break;case"%":n="directive indicator character %";break;case"|":case">":{n=`block scalar indicator ${t[0]}`;break}case"@":case"`":{n=`reserved character ${t[0]}`;break}}return n&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${n}`),bg(t)}function tT(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),bg(t.slice(1,-1)).replace(/''/g,"'")}function bg(t){let e,n;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
84
+ ${l}
85
+ `}};Ts.YAMLError=As;Ts.YAMLParseError=bu;Ts.YAMLWarning=wu;Ts.prettifyError=zA});var Os=$(ag=>{"use strict";function YA(t,{flow:e,indicator:n,next:r,offset:s,onError:i,parentIndent:o,startOnNewline:a}){let c=!1,l=a,f=a,u="",d="",p=!1,h=!1,m=null,g=null,b=null,C=null,T=null,E=null,R=null;for(let x of t)switch(h&&(x.type!=="space"&&x.type!=="newline"&&x.type!=="comma"&&i(x.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),h=!1),m&&(l&&x.type!=="comment"&&x.type!=="newline"&&i(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),m=null),x.type){case"space":!e&&(n!=="doc-start"||r?.type!=="flow-collection")&&x.source.includes(" ")&&(m=x),f=!0;break;case"comment":{f||i(x,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let M=x.source.substring(1)||" ";u?u+=d+M:u=M,d="",l=!1;break}case"newline":l?u?u+=x.source:(!E||n!=="seq-item-ind")&&(c=!0):d+=x.source,l=!0,p=!0,(g||b)&&(C=x),f=!0;break;case"anchor":g&&i(x,"MULTIPLE_ANCHORS","A node can have at most one anchor"),x.source.endsWith(":")&&i(x.offset+x.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),g=x,R??(R=x.offset),l=!1,f=!1,h=!0;break;case"tag":{b&&i(x,"MULTIPLE_TAGS","A node can have at most one tag"),b=x,R??(R=x.offset),l=!1,f=!1,h=!0;break}case n:(g||b)&&i(x,"BAD_PROP_ORDER",`Anchors and tags must be after the ${x.source} indicator`),E&&i(x,"UNEXPECTED_TOKEN",`Unexpected ${x.source} in ${e??"collection"}`),E=x,l=n==="seq-item-ind"||n==="explicit-key-ind",f=!1;break;case"comma":if(e){T&&i(x,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),T=x,l=!1,f=!1;break}default:i(x,"UNEXPECTED_TOKEN",`Unexpected ${x.type} token`),l=!1,f=!1}let O=t[t.length-1],_=O?O.offset+O.source.length:s;return h&&r&&r.type!=="space"&&r.type!=="newline"&&r.type!=="comma"&&(r.type!=="scalar"||r.source!=="")&&i(r.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m&&(l&&m.indent<=o||r?.type==="block-map"||r?.type==="block-seq")&&i(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:T,found:E,spaceBefore:c,comment:u,hasNewline:p,anchor:g,tag:b,newlineAfterProp:C,end:_,start:R??_}}ag.resolveProps=YA});var Bo=$(cg=>{"use strict";function vu(t){if(!t)return null;switch(t.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(t.source.includes(`
86
+ `))return!0;if(t.end){for(let e of t.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of t.items){for(let n of e.start)if(n.type==="newline")return!0;if(e.sep){for(let n of e.sep)if(n.type==="newline")return!0}if(vu(e.key)||vu(e.value))return!0}return!1;default:return!0}}cg.containsNewline=vu});var Su=$(lg=>{"use strict";var VA=Bo();function GA(t,e,n){if(e?.type==="flow-collection"){let r=e.end[0];r.indent===t&&(r.source==="]"||r.source==="}")&&VA.containsNewline(e)&&n(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}lg.flowIndentCheck=GA});var ku=$(dg=>{"use strict";var ug=W();function XA(t,e,n){let{uniqueKeys:r}=t.options;if(r===!1)return!1;let s=typeof r=="function"?r:(i,o)=>i===o||ug.isScalar(i)&&ug.isScalar(o)&&i.value===o.value;return e.some(i=>s(i.key,n))}dg.mapIncludes=XA});var yg=$(gg=>{"use strict";var fg=Lt(),QA=Dt(),pg=Os(),ZA=Bo(),hg=Su(),eT=ku(),mg="All mapping items must start at the same column";function tT({composeNode:t,composeEmptyNode:e},n,r,s,i){let o=i?.nodeClass??QA.YAMLMap,a=new o(n.schema);n.atRoot&&(n.atRoot=!1);let c=r.offset,l=null;for(let f of r.items){let{start:u,key:d,sep:p,value:h}=f,m=pg.resolveProps(u,{indicator:"explicit-key-ind",next:d??p?.[0],offset:c,onError:s,parentIndent:r.indent,startOnNewline:!0}),g=!m.found;if(g){if(d&&(d.type==="block-seq"?s(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in d&&d.indent!==r.indent&&s(c,"BAD_INDENT",mg)),!m.anchor&&!m.tag&&!p){l=m.end,m.comment&&(a.comment?a.comment+=`
87
+ `+m.comment:a.comment=m.comment);continue}(m.newlineAfterProp||ZA.containsNewline(d))&&s(d??u[u.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else m.found?.indent!==r.indent&&s(c,"BAD_INDENT",mg);n.atKey=!0;let b=m.end,C=d?t(n,d,m,s):e(n,b,u,null,m,s);n.schema.compat&&hg.flowIndentCheck(r.indent,d,s),n.atKey=!1,eT.mapIncludes(n,a.items,C)&&s(b,"DUPLICATE_KEY","Map keys must be unique");let T=pg.resolveProps(p??[],{indicator:"map-value-ind",next:h,offset:C.range[2],onError:s,parentIndent:r.indent,startOnNewline:!d||d.type==="block-scalar"});if(c=T.end,T.found){g&&(h?.type==="block-map"&&!T.hasNewline&&s(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),n.options.strict&&m.start<T.found.offset-1024&&s(C.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let E=h?t(n,h,T,s):e(n,c,p,null,T,s);n.schema.compat&&hg.flowIndentCheck(r.indent,h,s),c=E.range[2];let R=new fg.Pair(C,E);n.options.keepSourceTokens&&(R.srcToken=f),a.items.push(R)}else{g&&s(C.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),T.comment&&(C.comment?C.comment+=`
88
+ `+T.comment:C.comment=T.comment);let E=new fg.Pair(C);n.options.keepSourceTokens&&(E.srcToken=f),a.items.push(E)}}return l&&l<c&&s(l,"IMPOSSIBLE","Map comment with trailing content"),a.range=[r.offset,c,l??c],a}gg.resolveBlockMap=tT});var wg=$(bg=>{"use strict";var nT=Bt(),rT=Os(),sT=Su();function iT({composeNode:t,composeEmptyNode:e},n,r,s,i){let o=i?.nodeClass??nT.YAMLSeq,a=new o(n.schema);n.atRoot&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let c=r.offset,l=null;for(let{start:f,value:u}of r.items){let d=rT.resolveProps(f,{indicator:"seq-item-ind",next:u,offset:c,onError:s,parentIndent:r.indent,startOnNewline:!0});if(!d.found)if(d.anchor||d.tag||u)u?.type==="block-seq"?s(d.end,"BAD_INDENT","All sequence items must start at the same column"):s(c,"MISSING_CHAR","Sequence item without - indicator");else{l=d.end,d.comment&&(a.comment=d.comment);continue}let p=u?t(n,u,d,s):e(n,d.end,f,null,d,s);n.schema.compat&&sT.flowIndentCheck(r.indent,u,s),c=p.range[2],a.items.push(p)}return a.range=[r.offset,c,l??c],a}bg.resolveBlockSeq=iT});var nr=$(vg=>{"use strict";function oT(t,e,n,r){let s="";if(t){let i=!1,o="";for(let a of t){let{source:c,type:l}=a;switch(l){case"space":i=!0;break;case"comment":{n&&!i&&r(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let f=c.substring(1)||" ";s?s+=o+f:s=f,o="";break}case"newline":s&&(o+=c),i=!0;break;default:r(a,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}e+=c.length}}return{comment:s,offset:e}}vg.resolveEnd=oT});var Eg=$(xg=>{"use strict";var aT=W(),cT=Lt(),Sg=Dt(),lT=Bt(),uT=nr(),kg=Os(),dT=Bo(),fT=ku(),xu="Block collections are not allowed within flow collections",Eu=t=>t&&(t.type==="block-map"||t.type==="block-seq");function pT({composeNode:t,composeEmptyNode:e},n,r,s,i){let o=r.start.source==="{",a=o?"flow map":"flow sequence",c=i?.nodeClass??(o?Sg.YAMLMap:lT.YAMLSeq),l=new c(n.schema);l.flow=!0;let f=n.atRoot;f&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let u=r.offset+r.start.source.length;for(let g=0;g<r.items.length;++g){let b=r.items[g],{start:C,key:T,sep:E,value:R}=b,O=kg.resolveProps(C,{flow:a,indicator:"explicit-key-ind",next:T??E?.[0],offset:u,onError:s,parentIndent:r.indent,startOnNewline:!1});if(!O.found){if(!O.anchor&&!O.tag&&!E&&!R){g===0&&O.comma?s(O.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):g<r.items.length-1&&s(O.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),O.comment&&(l.comment?l.comment+=`
89
+ `+O.comment:l.comment=O.comment),u=O.end;continue}!o&&n.options.strict&&dT.containsNewline(T)&&s(T,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(g===0)O.comma&&s(O.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(O.comma||s(O.start,"MISSING_CHAR",`Missing , between ${a} items`),O.comment){let _="";e:for(let x of C)switch(x.type){case"comma":case"space":break;case"comment":_=x.source.substring(1);break e;default:break e}if(_){let x=l.items[l.items.length-1];aT.isPair(x)&&(x=x.value??x.key),x.comment?x.comment+=`
90
+ `+_:x.comment=_,O.comment=O.comment.substring(_.length+1)}}if(!o&&!E&&!O.found){let _=R?t(n,R,O,s):e(n,O.end,E,null,O,s);l.items.push(_),u=_.range[2],Eu(R)&&s(_.range,"BLOCK_IN_FLOW",xu)}else{n.atKey=!0;let _=O.end,x=T?t(n,T,O,s):e(n,_,C,null,O,s);Eu(T)&&s(x.range,"BLOCK_IN_FLOW",xu),n.atKey=!1;let M=kg.resolveProps(E??[],{flow:a,indicator:"map-value-ind",next:R,offset:x.range[2],onError:s,parentIndent:r.indent,startOnNewline:!1});if(M.found){if(!o&&!O.found&&n.options.strict){if(E)for(let q of E){if(q===M.found)break;if(q.type==="newline"){s(q,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}O.start<M.found.offset-1024&&s(M.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else R&&("source"in R&&R.source?.[0]===":"?s(R,"MISSING_CHAR",`Missing space after : in ${a}`):s(M.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let F=R?t(n,R,M,s):M.found?e(n,M.end,E,null,M,s):null;F?Eu(R)&&s(F.range,"BLOCK_IN_FLOW",xu):M.comment&&(x.comment?x.comment+=`
91
+ `+M.comment:x.comment=M.comment);let ee=new cT.Pair(x,F);if(n.options.keepSourceTokens&&(ee.srcToken=b),o){let q=l;fT.mapIncludes(n,q.items,x)&&s(_,"DUPLICATE_KEY","Map keys must be unique"),q.items.push(ee)}else{let q=new Sg.YAMLMap(n.schema);q.flow=!0,q.items.push(ee);let ue=(F??x).range;q.range=[x.range[0],ue[1],ue[2]],l.items.push(q)}u=F?F.range[2]:M.end}}let d=o?"}":"]",[p,...h]=r.end,m=u;if(p?.source===d)m=p.offset+p.source.length;else{let g=a[0].toUpperCase()+a.substring(1),b=f?`${g} must end with a ${d}`:`${g} in block collection must be sufficiently indented and end with a ${d}`;s(u,f?"MISSING_CHAR":"BAD_INDENT",b),p&&p.source.length!==1&&h.unshift(p)}if(h.length>0){let g=uT.resolveEnd(h,m,n.options.strict,s);g.comment&&(l.comment?l.comment+=`
92
+ `+g.comment:l.comment=g.comment),l.range=[r.offset,m,g.offset]}else l.range=[r.offset,m,m];return l}xg.resolveFlowCollection=pT});var Tg=$(Ag=>{"use strict";var hT=W(),mT=oe(),gT=Dt(),yT=Bt(),bT=yg(),wT=wg(),vT=Eg();function Au(t,e,n,r,s,i){let o=n.type==="block-map"?bT.resolveBlockMap(t,e,n,r,i):n.type==="block-seq"?wT.resolveBlockSeq(t,e,n,r,i):vT.resolveFlowCollection(t,e,n,r,i),a=o.constructor;return s==="!"||s===a.tagName?(o.tag=a.tagName,o):(s&&(o.tag=s),o)}function ST(t,e,n,r,s){let i=r.tag,o=i?e.directives.tagName(i.source,d=>s(i,"TAG_RESOLVE_FAILED",d)):null;if(n.type==="block-seq"){let{anchor:d,newlineAfterProp:p}=r,h=d&&i?d.offset>i.offset?d:i:d??i;h&&(!p||p.offset<h.offset)&&s(h,"MISSING_CHAR","Missing newline after block sequence props")}let a=n.type==="block-map"?"map":n.type==="block-seq"?"seq":n.start.source==="{"?"map":"seq";if(!i||!o||o==="!"||o===gT.YAMLMap.tagName&&a==="map"||o===yT.YAMLSeq.tagName&&a==="seq")return Au(t,e,n,s,o);let c=e.schema.tags.find(d=>d.tag===o&&d.collection===a);if(!c){let d=e.schema.knownTags[o];if(d?.collection===a)e.schema.tags.push(Object.assign({},d,{default:!1})),c=d;else return d?s(i,"BAD_COLLECTION_TYPE",`${d.tag} used for ${a} collection, but expects ${d.collection??"scalar"}`,!0):s(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),Au(t,e,n,s,o)}let l=Au(t,e,n,s,o,c),f=c.resolve?.(l,d=>s(i,"TAG_RESOLVE_FAILED",d),e.options)??l,u=hT.isNode(f)?f:new mT.Scalar(f);return u.range=l.range,u.tag=o,c?.format&&(u.format=c.format),u}Ag.composeCollection=ST});var Cu=$(Cg=>{"use strict";var Tu=oe();function kT(t,e,n){let r=e.offset,s=xT(e,t.options.strict,n);if(!s)return{value:"",type:null,comment:"",range:[r,r,r]};let i=s.mode===">"?Tu.Scalar.BLOCK_FOLDED:Tu.Scalar.BLOCK_LITERAL,o=e.source?ET(e.source):[],a=o.length;for(let m=o.length-1;m>=0;--m){let g=o[m][1];if(g===""||g==="\r")a=m;else break}if(a===0){let m=s.chomp==="+"&&o.length>0?`
93
+ `.repeat(Math.max(1,o.length-1)):"",g=r+s.length;return e.source&&(g+=e.source.length),{value:m,type:i,comment:s.comment,range:[r,g,g]}}let c=e.indent+s.indent,l=e.offset+s.length,f=0;for(let m=0;m<a;++m){let[g,b]=o[m];if(b===""||b==="\r")s.indent===0&&g.length>c&&(c=g.length);else{g.length<c&&n(l+g.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),s.indent===0&&(c=g.length),f=m,c===0&&!t.atRoot&&n(l,"BAD_INDENT","Block scalar values in collections must be indented");break}l+=g.length+b.length+1}for(let m=o.length-1;m>=a;--m)o[m][0].length>c&&(a=m+1);let u="",d="",p=!1;for(let m=0;m<f;++m)u+=o[m][0].slice(c)+`
94
+ `;for(let m=f;m<a;++m){let[g,b]=o[m];l+=g.length+b.length+1;let C=b[b.length-1]==="\r";if(C&&(b=b.slice(0,-1)),b&&g.length<c){let E=`Block scalar lines must not be less indented than their ${s.indent?"explicit indentation indicator":"first line"}`;n(l-b.length-(C?2:1),"BAD_INDENT",E),g=""}i===Tu.Scalar.BLOCK_LITERAL?(u+=d+g.slice(c)+b,d=`
95
+ `):g.length>c||b[0]===" "?(d===" "?d=`
96
+ `:!p&&d===`
97
+ `&&(d=`
98
+
99
+ `),u+=d+g.slice(c)+b,d=`
100
+ `,p=!0):b===""?d===`
101
+ `?u+=`
102
+ `:d=`
103
+ `:(u+=d+b,d=" ",p=!1)}switch(s.chomp){case"-":break;case"+":for(let m=a;m<o.length;++m)u+=`
104
+ `+o[m][0].slice(c);u[u.length-1]!==`
105
+ `&&(u+=`
106
+ `);break;default:u+=`
107
+ `}let h=r+s.length+e.source.length;return{value:u,type:i,comment:s.comment,range:[r,h,h]}}function xT({offset:t,props:e},n,r){if(e[0].type!=="block-scalar-header")return r(e[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:s}=e[0],i=s[0],o=0,a="",c=-1;for(let d=1;d<s.length;++d){let p=s[d];if(!a&&(p==="-"||p==="+"))a=p;else{let h=Number(p);!o&&h?o=h:c===-1&&(c=t+d)}}c!==-1&&r(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${s}`);let l=!1,f="",u=s.length;for(let d=1;d<e.length;++d){let p=e[d];switch(p.type){case"space":l=!0;case"newline":u+=p.source.length;break;case"comment":n&&!l&&r(p,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),u+=p.source.length,f=p.source.substring(1);break;case"error":r(p,"UNEXPECTED_TOKEN",p.message),u+=p.source.length;break;default:{let h=`Unexpected token in block scalar header: ${p.type}`;r(p,"UNEXPECTED_TOKEN",h);let m=p.source;m&&typeof m=="string"&&(u+=m.length)}}}return{mode:i,indent:o,chomp:a,comment:f,length:u}}function ET(t){let e=t.split(/\n( *)/),n=e[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:["",n]];for(let o=1;o<e.length;o+=2)i.push([e[o],e[o+1]]);return i}Cg.resolveBlockScalar=kT});var Pu=$(Pg=>{"use strict";var Ou=oe(),AT=nr();function TT(t,e,n){let{offset:r,type:s,source:i,end:o}=t,a,c,l=(d,p,h)=>n(r+d,p,h);switch(s){case"scalar":a=Ou.Scalar.PLAIN,c=CT(i,l);break;case"single-quoted-scalar":a=Ou.Scalar.QUOTE_SINGLE,c=OT(i,l);break;case"double-quoted-scalar":a=Ou.Scalar.QUOTE_DOUBLE,c=PT(i,l);break;default:return n(t,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${s}`),{value:"",type:null,comment:"",range:[r,r+i.length,r+i.length]}}let f=r+i.length,u=AT.resolveEnd(o,f,e,n);return{value:c,type:a,comment:u.comment,range:[r,f,u.offset]}}function CT(t,e){let n="";switch(t[0]){case" ":n="a tab character";break;case",":n="flow indicator character ,";break;case"%":n="directive indicator character %";break;case"|":case">":{n=`block scalar indicator ${t[0]}`;break}case"@":case"`":{n=`reserved character ${t[0]}`;break}}return n&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${n}`),Og(t)}function OT(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),Og(t.slice(1,-1)).replace(/''/g,"'")}function Og(t){let e,n;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
108
108
  `,"sy"),n=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
109
109
  `,"sy")}catch{e=/(.*?)[ \t]*\r?\n/sy,n=/[ \t]*(.*?)[ \t]*\r?\n/sy}let r=e.exec(t);if(!r)return t;let s=r[1],i=" ",o=e.lastIndex;for(n.lastIndex=o;r=n.exec(t);)r[1]===""?i===`
110
110
  `?s+=i:i=`
111
- `:(s+=i+r[1],i=" "),o=n.lastIndex;let a=/[ \t]*(.*)/sy;return a.lastIndex=o,r=a.exec(t),s+i+(r?.[1]??"")}function nT(t,e){let n="";for(let r=1;r<t.length-1;++r){let s=t[r];if(!(s==="\r"&&t[r+1]===`
111
+ `:(s+=i+r[1],i=" "),o=n.lastIndex;let a=/[ \t]*(.*)/sy;return a.lastIndex=o,r=a.exec(t),s+i+(r?.[1]??"")}function PT(t,e){let n="";for(let r=1;r<t.length-1;++r){let s=t[r];if(!(s==="\r"&&t[r+1]===`
112
112
  `))if(s===`
113
- `){let{fold:i,offset:o}=rT(t,r);n+=i,r=o}else if(s==="\\"){let i=t[++r],o=sT[i];if(o)n+=o;else if(i===`
113
+ `){let{fold:i,offset:o}=_T(t,r);n+=i,r=o}else if(s==="\\"){let i=t[++r],o=RT[i];if(o)n+=o;else if(i===`
114
114
  `)for(i=t[r+1];i===" "||i===" ";)i=t[++r+1];else if(i==="\r"&&t[r+1]===`
115
- `)for(i=t[++r+1];i===" "||i===" ";)i=t[++r+1];else if(i==="x"||i==="u"||i==="U"){let a={x:2,u:4,U:8}[i];n+=iT(t,r+1,a,e),r+=a}else{let a=t.substr(r-1,2);e(r-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),n+=a}}else if(s===" "||s===" "){let i=r,o=t[r+1];for(;o===" "||o===" ";)o=t[++r+1];o!==`
115
+ `)for(i=t[++r+1];i===" "||i===" ";)i=t[++r+1];else if(i==="x"||i==="u"||i==="U"){let a={x:2,u:4,U:8}[i];n+=IT(t,r+1,a,e),r+=a}else{let a=t.substr(r-1,2);e(r-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),n+=a}}else if(s===" "||s===" "){let i=r,o=t[r+1];for(;o===" "||o===" ";)o=t[++r+1];o!==`
116
116
  `&&!(o==="\r"&&t[r+2]===`
117
- `)&&(n+=r>i?t.slice(i,r+1):s)}else n+=s}return(t[t.length-1]!=='"'||t.length===1)&&e(t.length,"MISSING_CHAR",'Missing closing "quote'),n}function rT(t,e){let n="",r=t[e+1];for(;(r===" "||r===" "||r===`
117
+ `)&&(n+=r>i?t.slice(i,r+1):s)}else n+=s}return(t[t.length-1]!=='"'||t.length===1)&&e(t.length,"MISSING_CHAR",'Missing closing "quote'),n}function _T(t,e){let n="",r=t[e+1];for(;(r===" "||r===" "||r===`
118
118
  `||r==="\r")&&!(r==="\r"&&t[e+2]!==`
119
119
  `);)r===`
120
120
  `&&(n+=`
121
- `),e+=1,r=t[e+1];return n||(n=" "),{fold:n,offset:e}}var sT={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
122
- `,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function iT(t,e,n,r){let s=t.substr(e,n),o=s.length===n&&/^[0-9a-fA-F]+$/.test(s)?parseInt(s,16):NaN;if(isNaN(o)){let a=t.substr(e-2,n+2);return r(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}return String.fromCodePoint(o)}wg.resolveFlowScalar=ZA});var kg=I(Sg=>{"use strict";var pn=W(),vg=re(),oT=Su(),aT=xu();function lT(t,e,n,r){let{value:s,type:i,comment:o,range:a}=e.type==="block-scalar"?oT.resolveBlockScalar(t,e,r):aT.resolveFlowScalar(e,t.options.strict,r),l=n?t.directives.tagName(n.source,d=>r(n,"TAG_RESOLVE_FAILED",d)):null,c;t.options.stringKeys&&t.atKey?c=t.schema[pn.SCALAR]:l?c=cT(t.schema,s,l,n,r):e.type==="scalar"?c=uT(t,s,e,r):c=t.schema[pn.SCALAR];let f;try{let d=c.resolve(s,u=>r(n??e,"TAG_RESOLVE_FAILED",u),t.options);f=pn.isScalar(d)?d:new vg.Scalar(d)}catch(d){let u=d instanceof Error?d.message:String(d);r(n??e,"TAG_RESOLVE_FAILED",u),f=new vg.Scalar(s)}return f.range=a,f.source=s,i&&(f.type=i),l&&(f.tag=l),c.format&&(f.format=c.format),o&&(f.comment=o),f}function cT(t,e,n,r,s){if(n==="!")return t[pn.SCALAR];let i=[];for(let a of t.tags)if(!a.collection&&a.tag===n)if(a.default&&a.test)i.push(a);else return a;for(let a of i)if(a.test?.test(e))return a;let o=t.knownTags[n];return o&&!o.collection?(t.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(s(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${n}`,n!=="tag:yaml.org,2002:str"),t[pn.SCALAR])}function uT({atKey:t,directives:e,schema:n},r,s,i){let o=n.tags.find(a=>(a.default===!0||t&&a.default==="key")&&a.test?.test(r))||n[pn.SCALAR];if(n.compat){let a=n.compat.find(l=>l.default&&l.test?.test(r))??n[pn.SCALAR];if(o.tag!==a.tag){let l=e.tagString(o.tag),c=e.tagString(a.tag),f=`Value may be parsed as either ${l} or ${c}`;i(s,"TAG_RESOLVE_FAILED",f,!0)}}return o}Sg.composeScalar=lT});var Eg=I(xg=>{"use strict";function dT(t,e,n){if(e){n??(n=e.length);for(let r=n-1;r>=0;--r){let s=e[r];switch(s.type){case"space":case"comment":case"newline":t-=s.source.length;continue}for(s=e[++r];s?.type==="space";)t+=s.source.length,s=e[++r];break}}return t}xg.emptyScalarPosition=dT});var Cg=I(Au=>{"use strict";var fT=ts(),pT=W(),hT=gg(),Ag=kg(),mT=er(),gT=Eg(),yT={composeNode:Tg,composeEmptyNode:Eu};function Tg(t,e,n,r){let s=t.atKey,{spaceBefore:i,comment:o,anchor:a,tag:l}=n,c,f=!0;switch(e.type){case"alias":c=bT(t,e,r),(a||l)&&r(e,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":c=Ag.composeScalar(t,e,l,r),a&&(c.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":c=hT.composeCollection(yT,t,e,n,r),a&&(c.anchor=a.source.substring(1));break;default:{let d=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;r(e,"UNEXPECTED_TOKEN",d),c=Eu(t,e.offset,void 0,null,n,r),f=!1}}return a&&c.anchor===""&&r(a,"BAD_ALIAS","Anchor cannot be an empty string"),s&&t.options.stringKeys&&(!pT.isScalar(c)||typeof c.value!="string"||c.tag&&c.tag!=="tag:yaml.org,2002:str")&&r(l??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),i&&(c.spaceBefore=!0),o&&(e.type==="scalar"&&e.source===""?c.comment=o:c.commentBefore=o),t.options.keepSourceTokens&&f&&(c.srcToken=e),c}function Eu(t,e,n,r,{spaceBefore:s,comment:i,anchor:o,tag:a,end:l},c){let f={type:"scalar",offset:gT.emptyScalarPosition(e,n,r),indent:-1,source:""},d=Ag.composeScalar(t,f,a,c);return o&&(d.anchor=o.source.substring(1),d.anchor===""&&c(o,"BAD_ALIAS","Anchor cannot be an empty string")),s&&(d.spaceBefore=!0),i&&(d.comment=i,d.range[2]=l),d}function bT({options:t},{offset:e,source:n,end:r},s){let i=new fT.Alias(n.substring(1));i.source===""&&s(e,"BAD_ALIAS","Alias cannot be an empty string"),i.source.endsWith(":")&&s(e+n.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=e+n.length,a=mT.resolveEnd(r,o,t.strict,s);return i.range=[e,o,a.offset],a.comment&&(i.comment=a.comment),i}Au.composeEmptyNode=Eu;Au.composeNode=Tg});var _g=I(Pg=>{"use strict";var wT=bs(),Og=Cg(),vT=er(),ST=ks();function kT(t,e,{offset:n,start:r,value:s,end:i},o){let a=Object.assign({_directives:e},t),l=new wT.Document(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},f=ST.resolveProps(r,{indicator:"doc-start",next:s??i?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});f.found&&(l.directives.docStart=!0,s&&(s.type==="block-map"||s.type==="block-seq")&&!f.hasNewline&&o(f.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),l.contents=s?Og.composeNode(c,s,f,o):Og.composeEmptyNode(c,f.end,r,null,f,o);let d=l.contents.range[2],u=vT.resolveEnd(i,d,!1,o);return u.comment&&(l.comment=u.comment),l.range=[n,d,u.offset],l}Pg.composeDoc=kT});var Cu=I($g=>{"use strict";var xT=Ni("process"),ET=fc(),AT=bs(),xs=Ss(),Rg=W(),TT=_g(),CT=er();function Es(t){if(typeof t=="number")return[t,t+1];if(Array.isArray(t))return t.length===2?t:[t[0],t[1]];let{offset:e,source:n}=t;return[e,e+(typeof n=="string"?n.length:1)]}function Ig(t){let e="",n=!1,r=!1;for(let s=0;s<t.length;++s){let i=t[s];switch(i[0]){case"#":e+=(e===""?"":r?`
121
+ `),e+=1,r=t[e+1];return n||(n=" "),{fold:n,offset:e}}var RT={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
122
+ `,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function IT(t,e,n,r){let s=t.substr(e,n),o=s.length===n&&/^[0-9a-fA-F]+$/.test(s)?parseInt(s,16):NaN;if(isNaN(o)){let a=t.substr(e-2,n+2);return r(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}return String.fromCodePoint(o)}Pg.resolveFlowScalar=TT});var Ig=$(Rg=>{"use strict";var mn=W(),_g=oe(),$T=Cu(),NT=Pu();function LT(t,e,n,r){let{value:s,type:i,comment:o,range:a}=e.type==="block-scalar"?$T.resolveBlockScalar(t,e,r):NT.resolveFlowScalar(e,t.options.strict,r),c=n?t.directives.tagName(n.source,u=>r(n,"TAG_RESOLVE_FAILED",u)):null,l;t.options.stringKeys&&t.atKey?l=t.schema[mn.SCALAR]:c?l=MT(t.schema,s,c,n,r):e.type==="scalar"?l=DT(t,s,e,r):l=t.schema[mn.SCALAR];let f;try{let u=l.resolve(s,d=>r(n??e,"TAG_RESOLVE_FAILED",d),t.options);f=mn.isScalar(u)?u:new _g.Scalar(u)}catch(u){let d=u instanceof Error?u.message:String(u);r(n??e,"TAG_RESOLVE_FAILED",d),f=new _g.Scalar(s)}return f.range=a,f.source=s,i&&(f.type=i),c&&(f.tag=c),l.format&&(f.format=l.format),o&&(f.comment=o),f}function MT(t,e,n,r,s){if(n==="!")return t[mn.SCALAR];let i=[];for(let a of t.tags)if(!a.collection&&a.tag===n)if(a.default&&a.test)i.push(a);else return a;for(let a of i)if(a.test?.test(e))return a;let o=t.knownTags[n];return o&&!o.collection?(t.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(s(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${n}`,n!=="tag:yaml.org,2002:str"),t[mn.SCALAR])}function DT({atKey:t,directives:e,schema:n},r,s,i){let o=n.tags.find(a=>(a.default===!0||t&&a.default==="key")&&a.test?.test(r))||n[mn.SCALAR];if(n.compat){let a=n.compat.find(c=>c.default&&c.test?.test(r))??n[mn.SCALAR];if(o.tag!==a.tag){let c=e.tagString(o.tag),l=e.tagString(a.tag),f=`Value may be parsed as either ${c} or ${l}`;i(s,"TAG_RESOLVE_FAILED",f,!0)}}return o}Rg.composeScalar=LT});var Ng=$($g=>{"use strict";function BT(t,e,n){if(e){n??(n=e.length);for(let r=n-1;r>=0;--r){let s=e[r];switch(s.type){case"space":case"comment":case"newline":t-=s.source.length;continue}for(s=e[++r];s?.type==="space";)t+=s.source.length,s=e[++r];break}}return t}$g.emptyScalarPosition=BT});var Dg=$(Ru=>{"use strict";var jT=as(),FT=W(),UT=Tg(),Lg=Ig(),qT=nr(),JT=Ng(),WT={composeNode:Mg,composeEmptyNode:_u};function Mg(t,e,n,r){let s=t.atKey,{spaceBefore:i,comment:o,anchor:a,tag:c}=n,l,f=!0;switch(e.type){case"alias":l=KT(t,e,r),(a||c)&&r(e,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":l=Lg.composeScalar(t,e,c,r),a&&(l.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":l=UT.composeCollection(WT,t,e,n,r),a&&(l.anchor=a.source.substring(1));break;default:{let u=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;r(e,"UNEXPECTED_TOKEN",u),l=_u(t,e.offset,void 0,null,n,r),f=!1}}return a&&l.anchor===""&&r(a,"BAD_ALIAS","Anchor cannot be an empty string"),s&&t.options.stringKeys&&(!FT.isScalar(l)||typeof l.value!="string"||l.tag&&l.tag!=="tag:yaml.org,2002:str")&&r(c??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),i&&(l.spaceBefore=!0),o&&(e.type==="scalar"&&e.source===""?l.comment=o:l.commentBefore=o),t.options.keepSourceTokens&&f&&(l.srcToken=e),l}function _u(t,e,n,r,{spaceBefore:s,comment:i,anchor:o,tag:a,end:c},l){let f={type:"scalar",offset:JT.emptyScalarPosition(e,n,r),indent:-1,source:""},u=Lg.composeScalar(t,f,a,l);return o&&(u.anchor=o.source.substring(1),u.anchor===""&&l(o,"BAD_ALIAS","Anchor cannot be an empty string")),s&&(u.spaceBefore=!0),i&&(u.comment=i,u.range[2]=c),u}function KT({options:t},{offset:e,source:n,end:r},s){let i=new jT.Alias(n.substring(1));i.source===""&&s(e,"BAD_ALIAS","Alias cannot be an empty string"),i.source.endsWith(":")&&s(e+n.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=e+n.length,a=qT.resolveEnd(r,o,t.strict,s);return i.range=[e,o,a.offset],a.comment&&(i.comment=a.comment),i}Ru.composeEmptyNode=_u;Ru.composeNode=Mg});var Fg=$(jg=>{"use strict";var HT=Es(),Bg=Dg(),zT=nr(),YT=Os();function VT(t,e,{offset:n,start:r,value:s,end:i},o){let a=Object.assign({_directives:e},t),c=new HT.Document(void 0,a),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},f=YT.resolveProps(r,{indicator:"doc-start",next:s??i?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});f.found&&(c.directives.docStart=!0,s&&(s.type==="block-map"||s.type==="block-seq")&&!f.hasNewline&&o(f.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=s?Bg.composeNode(l,s,f,o):Bg.composeEmptyNode(l,f.end,r,null,f,o);let u=c.contents.range[2],d=zT.resolveEnd(i,u,!1,o);return d.comment&&(c.comment=d.comment),c.range=[n,u,d.offset],c}jg.composeDoc=VT});var $u=$(Jg=>{"use strict";var GT=Ui("process"),XT=bl(),QT=Es(),Ps=Cs(),Ug=W(),ZT=Fg(),eC=nr();function _s(t){if(typeof t=="number")return[t,t+1];if(Array.isArray(t))return t.length===2?t:[t[0],t[1]];let{offset:e,source:n}=t;return[e,e+(typeof n=="string"?n.length:1)]}function qg(t){let e="",n=!1,r=!1;for(let s=0;s<t.length;++s){let i=t[s];switch(i[0]){case"#":e+=(e===""?"":r?`
123
123
 
124
124
  `:`
125
- `)+(i.substring(1)||" "),n=!0,r=!1;break;case"%":t[s+1]?.[0]!=="#"&&(s+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:e,afterEmptyLine:r}}var Tu=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(n,r,s,i)=>{let o=Es(n);i?this.warnings.push(new xs.YAMLWarning(o,r,s)):this.errors.push(new xs.YAMLParseError(o,r,s))},this.directives=new ET.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,n){let{comment:r,afterEmptyLine:s}=Ig(this.prelude);if(r){let i=e.contents;if(n)e.comment=e.comment?`${e.comment}
126
- ${r}`:r;else if(s||e.directives.docStart||!i)e.commentBefore=r;else if(Rg.isCollection(i)&&!i.flow&&i.items.length>0){let o=i.items[0];Rg.isPair(o)&&(o=o.key);let a=o.commentBefore;o.commentBefore=a?`${r}
125
+ `)+(i.substring(1)||" "),n=!0,r=!1;break;case"%":t[s+1]?.[0]!=="#"&&(s+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:e,afterEmptyLine:r}}var Iu=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(n,r,s,i)=>{let o=_s(n);i?this.warnings.push(new Ps.YAMLWarning(o,r,s)):this.errors.push(new Ps.YAMLParseError(o,r,s))},this.directives=new XT.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,n){let{comment:r,afterEmptyLine:s}=qg(this.prelude);if(r){let i=e.contents;if(n)e.comment=e.comment?`${e.comment}
126
+ ${r}`:r;else if(s||e.directives.docStart||!i)e.commentBefore=r;else if(Ug.isCollection(i)&&!i.flow&&i.items.length>0){let o=i.items[0];Ug.isPair(o)&&(o=o.key);let a=o.commentBefore;o.commentBefore=a?`${r}
127
127
  ${a}`:r}else{let o=i.commentBefore;i.commentBefore=o?`${r}
128
- ${o}`:r}}n?(Array.prototype.push.apply(e.errors,this.errors),Array.prototype.push.apply(e.warnings,this.warnings)):(e.errors=this.errors,e.warnings=this.warnings),this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Ig(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,n=!1,r=-1){for(let s of e)yield*this.next(s);yield*this.end(n,r)}*next(e){switch(xT.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(n,r,s)=>{let i=Es(e);i[0]+=n,this.onError(i,"BAD_DIRECTIVE",r,s)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let n=TT.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!n.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(n,!1),this.doc&&(yield this.doc),this.doc=n,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let n=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,r=new xs.YAMLParseError(Es(e),"UNEXPECTED_TOKEN",n);this.atDirectives||!this.doc?this.errors.push(r):this.doc.errors.push(r);break}case"doc-end":{if(!this.doc){let r="Unexpected doc-end without preceding document";this.errors.push(new xs.YAMLParseError(Es(e),"UNEXPECTED_TOKEN",r));break}this.doc.directives.docEnd=!0;let n=CT.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),n.comment){let r=this.doc.comment;this.doc.comment=r?`${r}
129
- ${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.push(new xs.YAMLParseError(Es(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,n=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let r=Object.assign({_directives:this.directives},this.options),s=new AT.Document(void 0,r);this.atDirectives&&this.onError(n,"MISSING_CHAR","Missing directives-end indicator line"),s.range=[0,n,n],this.decorate(s,!1),yield s}}};$g.Composer=Tu});var Mg=I(Io=>{"use strict";var OT=Su(),PT=xu(),_T=Ss(),Ng=os();function RT(t,e=!0,n){if(t){let r=(s,i,o)=>{let a=typeof s=="number"?s:Array.isArray(s)?s[0]:s.offset;if(n)n(a,i,o);else throw new _T.YAMLParseError([a,a+1],i,o)};switch(t.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return PT.resolveFlowScalar(t,e,r);case"block-scalar":return OT.resolveBlockScalar({options:{strict:e}},t,r)}}return null}function IT(t,e){let{implicitKey:n=!1,indent:r,inFlow:s=!1,offset:i=-1,type:o="PLAIN"}=e,a=Ng.stringifyString({type:o,value:t},{implicitKey:n,indent:r>0?" ".repeat(r):"",inFlow:s,options:{blockQuote:!0,lineWidth:-1}}),l=e.end??[{type:"newline",offset:-1,indent:r,source:`
130
- `}];switch(a[0]){case"|":case">":{let c=a.indexOf(`
131
- `),f=a.substring(0,c),d=a.substring(c+1)+`
132
- `,u=[{type:"block-scalar-header",offset:i,indent:r,source:f}];return Lg(u,l)||u.push({type:"newline",offset:-1,indent:r,source:`
133
- `}),{type:"block-scalar",offset:i,indent:r,props:u,source:d}}case'"':return{type:"double-quoted-scalar",offset:i,indent:r,source:a,end:l};case"'":return{type:"single-quoted-scalar",offset:i,indent:r,source:a,end:l};default:return{type:"scalar",offset:i,indent:r,source:a,end:l}}}function $T(t,e,n={}){let{afterKey:r=!1,implicitKey:s=!1,inFlow:i=!1,type:o}=n,a="indent"in t?t.indent:null;if(r&&typeof a=="number"&&(a+=2),!o)switch(t.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let c=t.props[0];if(c.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o=c.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let l=Ng.stringifyString({type:o,value:e},{implicitKey:s||a===null,indent:a!==null&&a>0?" ".repeat(a):"",inFlow:i,options:{blockQuote:!0,lineWidth:-1}});switch(l[0]){case"|":case">":NT(t,l);break;case'"':Ou(t,l,"double-quoted-scalar");break;case"'":Ou(t,l,"single-quoted-scalar");break;default:Ou(t,l,"scalar")}}function NT(t,e){let n=e.indexOf(`
128
+ ${o}`:r}}n?(Array.prototype.push.apply(e.errors,this.errors),Array.prototype.push.apply(e.warnings,this.warnings)):(e.errors=this.errors,e.warnings=this.warnings),this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:qg(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,n=!1,r=-1){for(let s of e)yield*this.next(s);yield*this.end(n,r)}*next(e){switch(GT.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(n,r,s)=>{let i=_s(e);i[0]+=n,this.onError(i,"BAD_DIRECTIVE",r,s)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let n=ZT.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!n.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(n,!1),this.doc&&(yield this.doc),this.doc=n,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let n=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,r=new Ps.YAMLParseError(_s(e),"UNEXPECTED_TOKEN",n);this.atDirectives||!this.doc?this.errors.push(r):this.doc.errors.push(r);break}case"doc-end":{if(!this.doc){let r="Unexpected doc-end without preceding document";this.errors.push(new Ps.YAMLParseError(_s(e),"UNEXPECTED_TOKEN",r));break}this.doc.directives.docEnd=!0;let n=eC.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),n.comment){let r=this.doc.comment;this.doc.comment=r?`${r}
129
+ ${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.push(new Ps.YAMLParseError(_s(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,n=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let r=Object.assign({_directives:this.directives},this.options),s=new QT.Document(void 0,r);this.atDirectives&&this.onError(n,"MISSING_CHAR","Missing directives-end indicator line"),s.range=[0,n,n],this.decorate(s,!1),yield s}}};Jg.Composer=Iu});var Hg=$(jo=>{"use strict";var tC=Cu(),nC=Pu(),rC=Cs(),Wg=fs();function sC(t,e=!0,n){if(t){let r=(s,i,o)=>{let a=typeof s=="number"?s:Array.isArray(s)?s[0]:s.offset;if(n)n(a,i,o);else throw new rC.YAMLParseError([a,a+1],i,o)};switch(t.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return nC.resolveFlowScalar(t,e,r);case"block-scalar":return tC.resolveBlockScalar({options:{strict:e}},t,r)}}return null}function iC(t,e){let{implicitKey:n=!1,indent:r,inFlow:s=!1,offset:i=-1,type:o="PLAIN"}=e,a=Wg.stringifyString({type:o,value:t},{implicitKey:n,indent:r>0?" ".repeat(r):"",inFlow:s,options:{blockQuote:!0,lineWidth:-1}}),c=e.end??[{type:"newline",offset:-1,indent:r,source:`
130
+ `}];switch(a[0]){case"|":case">":{let l=a.indexOf(`
131
+ `),f=a.substring(0,l),u=a.substring(l+1)+`
132
+ `,d=[{type:"block-scalar-header",offset:i,indent:r,source:f}];return Kg(d,c)||d.push({type:"newline",offset:-1,indent:r,source:`
133
+ `}),{type:"block-scalar",offset:i,indent:r,props:d,source:u}}case'"':return{type:"double-quoted-scalar",offset:i,indent:r,source:a,end:c};case"'":return{type:"single-quoted-scalar",offset:i,indent:r,source:a,end:c};default:return{type:"scalar",offset:i,indent:r,source:a,end:c}}}function oC(t,e,n={}){let{afterKey:r=!1,implicitKey:s=!1,inFlow:i=!1,type:o}=n,a="indent"in t?t.indent:null;if(r&&typeof a=="number"&&(a+=2),!o)switch(t.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let l=t.props[0];if(l.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o=l.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let c=Wg.stringifyString({type:o,value:e},{implicitKey:s||a===null,indent:a!==null&&a>0?" ".repeat(a):"",inFlow:i,options:{blockQuote:!0,lineWidth:-1}});switch(c[0]){case"|":case">":aC(t,c);break;case'"':Nu(t,c,"double-quoted-scalar");break;case"'":Nu(t,c,"single-quoted-scalar");break;default:Nu(t,c,"scalar")}}function aC(t,e){let n=e.indexOf(`
134
134
  `),r=e.substring(0,n),s=e.substring(n+1)+`
135
- `;if(t.type==="block-scalar"){let i=t.props[0];if(i.type!=="block-scalar-header")throw new Error("Invalid block scalar header");i.source=r,t.source=s}else{let{offset:i}=t,o="indent"in t?t.indent:-1,a=[{type:"block-scalar-header",offset:i,indent:o,source:r}];Lg(a,"end"in t?t.end:void 0)||a.push({type:"newline",offset:-1,indent:o,source:`
136
- `});for(let l of Object.keys(t))l!=="type"&&l!=="offset"&&delete t[l];Object.assign(t,{type:"block-scalar",indent:o,props:a,source:s})}}function Lg(t,e){if(e)for(let n of e)switch(n.type){case"space":case"comment":t.push(n);break;case"newline":return t.push(n),!0}return!1}function Ou(t,e,n){switch(t.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":t.type=n,t.source=e;break;case"block-scalar":{let r=t.props.slice(1),s=e.length;t.props[0].type==="block-scalar-header"&&(s-=t.props[0].source.length);for(let i of r)i.offset+=s;delete t.props,Object.assign(t,{type:n,source:e,end:r});break}case"block-map":case"block-seq":{let s={type:"newline",offset:t.offset+e.length,indent:t.indent,source:`
137
- `};delete t.items,Object.assign(t,{type:n,source:e,end:[s]});break}default:{let r="indent"in t?t.indent:-1,s="end"in t&&Array.isArray(t.end)?t.end.filter(i=>i.type==="space"||i.type==="comment"||i.type==="newline"):[];for(let i of Object.keys(t))i!=="type"&&i!=="offset"&&delete t[i];Object.assign(t,{type:n,indent:r,source:e,end:s})}}}Io.createScalarToken=IT;Io.resolveAsScalar=RT;Io.setScalarValue=$T});var Bg=I(Dg=>{"use strict";var LT=t=>"type"in t?No(t):$o(t);function No(t){switch(t.type){case"block-scalar":{let e="";for(let n of t.props)e+=No(n);return e+t.source}case"block-map":case"block-seq":{let e="";for(let n of t.items)e+=$o(n);return e}case"flow-collection":{let e=t.start.source;for(let n of t.items)e+=$o(n);for(let n of t.end)e+=n.source;return e}case"document":{let e=$o(t);if(t.end)for(let n of t.end)e+=n.source;return e}default:{let e=t.source;if("end"in t&&t.end)for(let n of t.end)e+=n.source;return e}}}function $o({start:t,key:e,sep:n,value:r}){let s="";for(let i of t)s+=i.source;if(e&&(s+=No(e)),n)for(let i of n)s+=i.source;return r&&(s+=No(r)),s}Dg.stringify=LT});var qg=I(Ug=>{"use strict";var Pu=Symbol("break visit"),MT=Symbol("skip children"),jg=Symbol("remove item");function hn(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),Fg(Object.freeze([]),t,e)}hn.BREAK=Pu;hn.SKIP=MT;hn.REMOVE=jg;hn.itemAtPath=(t,e)=>{let n=t;for(let[r,s]of e){let i=n?.[r];if(i&&"items"in i)n=i.items[s];else return}return n};hn.parentCollection=(t,e)=>{let n=hn.itemAtPath(t,e.slice(0,-1)),r=e[e.length-1][0],s=n?.[r];if(s&&"items"in s)return s;throw new Error("Parent collection not found")};function Fg(t,e,n){let r=n(e,t);if(typeof r=="symbol")return r;for(let s of["key","value"]){let i=e[s];if(i&&"items"in i){for(let o=0;o<i.items.length;++o){let a=Fg(Object.freeze(t.concat([[s,o]])),i.items[o],n);if(typeof a=="number")o=a-1;else{if(a===Pu)return Pu;a===jg&&(i.items.splice(o,1),o-=1)}}typeof r=="function"&&s==="key"&&(r=r(e,t))}}return typeof r=="function"?r(e,t):r}Ug.visit=hn});var Lo=I(Ae=>{"use strict";var _u=Mg(),DT=Bg(),BT=qg(),Ru="\uFEFF",Iu="",$u="",Nu="",jT=t=>!!t&&"items"in t,FT=t=>!!t&&(t.type==="scalar"||t.type==="single-quoted-scalar"||t.type==="double-quoted-scalar"||t.type==="block-scalar");function UT(t){switch(t){case Ru:return"<BOM>";case Iu:return"<DOC>";case $u:return"<FLOW_END>";case Nu:return"<SCALAR>";default:return JSON.stringify(t)}}function qT(t){switch(t){case Ru:return"byte-order-mark";case Iu:return"doc-mode";case $u:return"flow-error-end";case Nu:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
135
+ `;if(t.type==="block-scalar"){let i=t.props[0];if(i.type!=="block-scalar-header")throw new Error("Invalid block scalar header");i.source=r,t.source=s}else{let{offset:i}=t,o="indent"in t?t.indent:-1,a=[{type:"block-scalar-header",offset:i,indent:o,source:r}];Kg(a,"end"in t?t.end:void 0)||a.push({type:"newline",offset:-1,indent:o,source:`
136
+ `});for(let c of Object.keys(t))c!=="type"&&c!=="offset"&&delete t[c];Object.assign(t,{type:"block-scalar",indent:o,props:a,source:s})}}function Kg(t,e){if(e)for(let n of e)switch(n.type){case"space":case"comment":t.push(n);break;case"newline":return t.push(n),!0}return!1}function Nu(t,e,n){switch(t.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":t.type=n,t.source=e;break;case"block-scalar":{let r=t.props.slice(1),s=e.length;t.props[0].type==="block-scalar-header"&&(s-=t.props[0].source.length);for(let i of r)i.offset+=s;delete t.props,Object.assign(t,{type:n,source:e,end:r});break}case"block-map":case"block-seq":{let s={type:"newline",offset:t.offset+e.length,indent:t.indent,source:`
137
+ `};delete t.items,Object.assign(t,{type:n,source:e,end:[s]});break}default:{let r="indent"in t?t.indent:-1,s="end"in t&&Array.isArray(t.end)?t.end.filter(i=>i.type==="space"||i.type==="comment"||i.type==="newline"):[];for(let i of Object.keys(t))i!=="type"&&i!=="offset"&&delete t[i];Object.assign(t,{type:n,indent:r,source:e,end:s})}}}jo.createScalarToken=iC;jo.resolveAsScalar=sC;jo.setScalarValue=oC});var Yg=$(zg=>{"use strict";var cC=t=>"type"in t?Uo(t):Fo(t);function Uo(t){switch(t.type){case"block-scalar":{let e="";for(let n of t.props)e+=Uo(n);return e+t.source}case"block-map":case"block-seq":{let e="";for(let n of t.items)e+=Fo(n);return e}case"flow-collection":{let e=t.start.source;for(let n of t.items)e+=Fo(n);for(let n of t.end)e+=n.source;return e}case"document":{let e=Fo(t);if(t.end)for(let n of t.end)e+=n.source;return e}default:{let e=t.source;if("end"in t&&t.end)for(let n of t.end)e+=n.source;return e}}}function Fo({start:t,key:e,sep:n,value:r}){let s="";for(let i of t)s+=i.source;if(e&&(s+=Uo(e)),n)for(let i of n)s+=i.source;return r&&(s+=Uo(r)),s}zg.stringify=cC});var Qg=$(Xg=>{"use strict";var Lu=Symbol("break visit"),lC=Symbol("skip children"),Vg=Symbol("remove item");function gn(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),Gg(Object.freeze([]),t,e)}gn.BREAK=Lu;gn.SKIP=lC;gn.REMOVE=Vg;gn.itemAtPath=(t,e)=>{let n=t;for(let[r,s]of e){let i=n?.[r];if(i&&"items"in i)n=i.items[s];else return}return n};gn.parentCollection=(t,e)=>{let n=gn.itemAtPath(t,e.slice(0,-1)),r=e[e.length-1][0],s=n?.[r];if(s&&"items"in s)return s;throw new Error("Parent collection not found")};function Gg(t,e,n){let r=n(e,t);if(typeof r=="symbol")return r;for(let s of["key","value"]){let i=e[s];if(i&&"items"in i){for(let o=0;o<i.items.length;++o){let a=Gg(Object.freeze(t.concat([[s,o]])),i.items[o],n);if(typeof a=="number")o=a-1;else{if(a===Lu)return Lu;a===Vg&&(i.items.splice(o,1),o-=1)}}typeof r=="function"&&s==="key"&&(r=r(e,t))}}return typeof r=="function"?r(e,t):r}Xg.visit=gn});var qo=$(Ce=>{"use strict";var Mu=Hg(),uC=Yg(),dC=Qg(),Du="\uFEFF",Bu="",ju="",Fu="",fC=t=>!!t&&"items"in t,pC=t=>!!t&&(t.type==="scalar"||t.type==="single-quoted-scalar"||t.type==="double-quoted-scalar"||t.type==="block-scalar");function hC(t){switch(t){case Du:return"<BOM>";case Bu:return"<DOC>";case ju:return"<FLOW_END>";case Fu:return"<SCALAR>";default:return JSON.stringify(t)}}function mC(t){switch(t){case Du:return"byte-order-mark";case Bu:return"doc-mode";case ju:return"flow-error-end";case Fu:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
138
138
  `:case`\r
139
- `:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(t[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}Ae.createScalarToken=_u.createScalarToken;Ae.resolveAsScalar=_u.resolveAsScalar;Ae.setScalarValue=_u.setScalarValue;Ae.stringify=DT.stringify;Ae.visit=BT.visit;Ae.BOM=Ru;Ae.DOCUMENT=Iu;Ae.FLOW_END=$u;Ae.SCALAR=Nu;Ae.isCollection=jT;Ae.isScalar=FT;Ae.prettyToken=UT;Ae.tokenType=qT});var Du=I(Wg=>{"use strict";var As=Lo();function Xe(t){switch(t){case void 0:case" ":case`
140
- `:case"\r":case" ":return!0;default:return!1}}var Jg=new Set("0123456789ABCDEFabcdef"),JT=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Mo=new Set(",[]{}"),WT=new Set(` ,[]{}
141
- \r `),Lu=t=>!t||WT.has(t),Mu=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,n=!1){if(e){if(typeof e!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!n;let r=this.next??"stream";for(;r&&(n||this.hasChars(1));)r=yield*this.parseNext(r)}atLineEnd(){let e=this.pos,n=this.buffer[e];for(;n===" "||n===" ";)n=this.buffer[++e];return!n||n==="#"||n===`
139
+ `:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(t[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}Ce.createScalarToken=Mu.createScalarToken;Ce.resolveAsScalar=Mu.resolveAsScalar;Ce.setScalarValue=Mu.setScalarValue;Ce.stringify=uC.stringify;Ce.visit=dC.visit;Ce.BOM=Du;Ce.DOCUMENT=Bu;Ce.FLOW_END=ju;Ce.SCALAR=Fu;Ce.isCollection=fC;Ce.isScalar=pC;Ce.prettyToken=hC;Ce.tokenType=mC});var Ju=$(ey=>{"use strict";var Rs=qo();function Qe(t){switch(t){case void 0:case" ":case`
140
+ `:case"\r":case" ":return!0;default:return!1}}var Zg=new Set("0123456789ABCDEFabcdef"),gC=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Jo=new Set(",[]{}"),yC=new Set(` ,[]{}
141
+ \r `),Uu=t=>!t||yC.has(t),qu=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,n=!1){if(e){if(typeof e!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!n;let r=this.next??"stream";for(;r&&(n||this.hasChars(1));)r=yield*this.parseNext(r)}atLineEnd(){let e=this.pos,n=this.buffer[e];for(;n===" "||n===" ";)n=this.buffer[++e];return!n||n==="#"||n===`
142
142
  `?!0:n==="\r"?this.buffer[e+1]===`
143
143
  `:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let n=this.buffer[e];if(this.indentNext>0){let r=0;for(;n===" ";)n=this.buffer[++r+e];if(n==="\r"){let s=this.buffer[r+e+1];if(s===`
144
144
  `||!s&&!this.atEnd)return e+r+1}return n===`
145
- `||r>=this.indentNext||!n&&!this.atEnd?e+r:-1}if(n==="-"||n==="."){let r=this.buffer.substr(e,3);if((r==="---"||r==="...")&&Xe(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!="number"||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
146
- `,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===As.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let n=e.length,r=e.indexOf("#");for(;r!==-1;){let i=e[r-1];if(i===" "||i===" "){n=r-1;break}else r=e.indexOf("#",r+1)}for(;;){let i=e[n-1];if(i===" "||i===" ")n-=1;else break}let s=(yield*this.pushCount(n))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-s),this.pushNewline(),"stream"}if(this.atLineEnd()){let n=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-n),yield*this.pushNewline(),"stream"}return yield As.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let n=this.peek(3);if((n==="---"||n==="...")&&Xe(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,n==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!Xe(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,n]=this.peek(2);if(!n&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&Xe(n)){let r=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=r,yield*this.parseBlockStart()}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let n=yield*this.pushIndicators();switch(e[n]){case"#":yield*this.pushCount(e.length-n);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(Lu),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return n+=yield*this.parseBlockScalarHeader(),n+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-n),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,n,r=-1;do e=yield*this.pushNewline(),e>0?(n=yield*this.pushSpaces(!1),this.indentValue=r=n):n=0,n+=yield*this.pushSpaces(!0);while(e+n>0);let s=this.getLine();if(s===null)return this.setNext("flow");if((r!==-1&&r<this.indentNext&&s[0]!=="#"||r===0&&(s.startsWith("---")||s.startsWith("..."))&&Xe(s[3]))&&!(r===this.indentNext-1&&this.flowLevel===1&&(s[0]==="]"||s[0]==="}")))return this.flowLevel=0,yield As.FLOW_END,yield*this.parseLineStart();let i=0;for(;s[i]===",";)i+=yield*this.pushCount(1),i+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(i+=yield*this.pushIndicators(),s[i]){case void 0:return"flow";case"#":return yield*this.pushCount(s.length-i),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(Lu),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||Xe(o)||o===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),n=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;n!==-1&&this.buffer[n+1]==="'";)n=this.buffer.indexOf("'",n+2);else for(;n!==-1;){let i=0;for(;this.buffer[n-1-i]==="\\";)i+=1;if(i%2===0)break;n=this.buffer.indexOf('"',n+1)}let r=this.buffer.substring(0,n),s=r.indexOf(`
145
+ `||r>=this.indentNext||!n&&!this.atEnd?e+r:-1}if(n==="-"||n==="."){let r=this.buffer.substr(e,3);if((r==="---"||r==="...")&&Qe(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!="number"||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
146
+ `,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===Rs.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let n=e.length,r=e.indexOf("#");for(;r!==-1;){let i=e[r-1];if(i===" "||i===" "){n=r-1;break}else r=e.indexOf("#",r+1)}for(;;){let i=e[n-1];if(i===" "||i===" ")n-=1;else break}let s=(yield*this.pushCount(n))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-s),this.pushNewline(),"stream"}if(this.atLineEnd()){let n=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-n),yield*this.pushNewline(),"stream"}return yield Rs.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let n=this.peek(3);if((n==="---"||n==="...")&&Qe(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,n==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!Qe(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,n]=this.peek(2);if(!n&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&Qe(n)){let r=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=r,yield*this.parseBlockStart()}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let n=yield*this.pushIndicators();switch(e[n]){case"#":yield*this.pushCount(e.length-n);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(Uu),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return n+=yield*this.parseBlockScalarHeader(),n+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-n),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,n,r=-1;do e=yield*this.pushNewline(),e>0?(n=yield*this.pushSpaces(!1),this.indentValue=r=n):n=0,n+=yield*this.pushSpaces(!0);while(e+n>0);let s=this.getLine();if(s===null)return this.setNext("flow");if((r!==-1&&r<this.indentNext&&s[0]!=="#"||r===0&&(s.startsWith("---")||s.startsWith("..."))&&Qe(s[3]))&&!(r===this.indentNext-1&&this.flowLevel===1&&(s[0]==="]"||s[0]==="}")))return this.flowLevel=0,yield Rs.FLOW_END,yield*this.parseLineStart();let i=0;for(;s[i]===",";)i+=yield*this.pushCount(1),i+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(i+=yield*this.pushIndicators(),s[i]){case void 0:return"flow";case"#":return yield*this.pushCount(s.length-i),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(Uu),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||Qe(o)||o===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),n=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;n!==-1&&this.buffer[n+1]==="'";)n=this.buffer.indexOf("'",n+2);else for(;n!==-1;){let i=0;for(;this.buffer[n-1-i]==="\\";)i+=1;if(i%2===0)break;n=this.buffer.indexOf('"',n+1)}let r=this.buffer.substring(0,n),s=r.indexOf(`
147
147
  `,this.pos);if(s!==-1){for(;s!==-1;){let i=this.continueScalar(s+1);if(i===-1)break;s=r.indexOf(`
148
- `,i)}s!==-1&&(n=s-(r[s-1]==="\r"?2:1))}if(n===-1){if(!this.atEnd)return this.setNext("quoted-scalar");n=this.buffer.length}return yield*this.pushToIndex(n+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let n=this.buffer[++e];if(n==="+")this.blockScalarKeep=!0;else if(n>"0"&&n<="9")this.blockScalarIndent=Number(n)-1;else if(n!=="-")break}return yield*this.pushUntil(n=>Xe(n)||n==="#")}*parseBlockScalar(){let e=this.pos-1,n=0,r;e:for(let i=this.pos;r=this.buffer[i];++i)switch(r){case" ":n+=1;break;case`
148
+ `,i)}s!==-1&&(n=s-(r[s-1]==="\r"?2:1))}if(n===-1){if(!this.atEnd)return this.setNext("quoted-scalar");n=this.buffer.length}return yield*this.pushToIndex(n+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let n=this.buffer[++e];if(n==="+")this.blockScalarKeep=!0;else if(n>"0"&&n<="9")this.blockScalarIndent=Number(n)-1;else if(n!=="-")break}return yield*this.pushUntil(n=>Qe(n)||n==="#")}*parseBlockScalar(){let e=this.pos-1,n=0,r;e:for(let i=this.pos;r=this.buffer[i];++i)switch(r){case" ":n+=1;break;case`
149
149
  `:e=i,n=0;break;case"\r":{let o=this.buffer[i+1];if(!o&&!this.atEnd)return this.setNext("block-scalar");if(o===`
150
150
  `)break}default:break e}if(!r&&!this.atEnd)return this.setNext("block-scalar");if(n>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=n:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let i=this.continueScalar(e+1);if(i===-1)break;e=this.buffer.indexOf(`
151
151
  `,i)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let s=e+1;for(r=this.buffer[s];r===" ";)r=this.buffer[++s];if(r===" "){for(;r===" "||r===" "||r==="\r"||r===`
152
152
  `;)r=this.buffer[++s];e=s-1}else if(!this.blockScalarKeep)do{let i=e-1,o=this.buffer[i];o==="\r"&&(o=this.buffer[--i]);let a=i;for(;o===" ";)o=this.buffer[--i];if(o===`
153
- `&&i>=this.pos&&i+1+n>a)e=i;else break}while(!0);return yield As.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,n=this.pos-1,r=this.pos-1,s;for(;s=this.buffer[++r];)if(s===":"){let i=this.buffer[r+1];if(Xe(i)||e&&Mo.has(i))break;n=r}else if(Xe(s)){let i=this.buffer[r+1];if(s==="\r"&&(i===`
153
+ `&&i>=this.pos&&i+1+n>a)e=i;else break}while(!0);return yield Rs.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,n=this.pos-1,r=this.pos-1,s;for(;s=this.buffer[++r];)if(s===":"){let i=this.buffer[r+1];if(Qe(i)||e&&Jo.has(i))break;n=r}else if(Qe(s)){let i=this.buffer[r+1];if(s==="\r"&&(i===`
154
154
  `?(r+=1,s=`
155
- `,i=this.buffer[r+1]):n=r),i==="#"||e&&Mo.has(i))break;if(s===`
156
- `){let o=this.continueScalar(r+1);if(o===-1)break;r=Math.max(r,o-2)}}else{if(e&&Mo.has(s))break;n=r}return!s&&!this.atEnd?this.setNext("plain-scalar"):(yield As.SCALAR,yield*this.pushToIndex(n+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,n){let r=this.buffer.slice(this.pos,e);return r?(yield r,this.pos+=r.length,r.length):(n&&(yield""),0)}*pushIndicators(){switch(this.charAt(0)){case"!":return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"&":return(yield*this.pushUntil(Lu))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let e=this.flowLevel>0,n=this.charAt(1);if(Xe(n)||e&&Mo.has(n))return e?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,(yield*this.pushCount(1))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators())}}return 0}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,n=this.buffer[e];for(;!Xe(n)&&n!==">";)n=this.buffer[++e];return yield*this.pushToIndex(n===">"?e+1:e,!1)}else{let e=this.pos+1,n=this.buffer[e];for(;n;)if(JT.has(n))n=this.buffer[++e];else if(n==="%"&&Jg.has(this.buffer[e+1])&&Jg.has(this.buffer[e+2]))n=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
155
+ `,i=this.buffer[r+1]):n=r),i==="#"||e&&Jo.has(i))break;if(s===`
156
+ `){let o=this.continueScalar(r+1);if(o===-1)break;r=Math.max(r,o-2)}}else{if(e&&Jo.has(s))break;n=r}return!s&&!this.atEnd?this.setNext("plain-scalar"):(yield Rs.SCALAR,yield*this.pushToIndex(n+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,n){let r=this.buffer.slice(this.pos,e);return r?(yield r,this.pos+=r.length,r.length):(n&&(yield""),0)}*pushIndicators(){switch(this.charAt(0)){case"!":return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"&":return(yield*this.pushUntil(Uu))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let e=this.flowLevel>0,n=this.charAt(1);if(Qe(n)||e&&Jo.has(n))return e?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,(yield*this.pushCount(1))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators())}}return 0}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,n=this.buffer[e];for(;!Qe(n)&&n!==">";)n=this.buffer[++e];return yield*this.pushToIndex(n===">"?e+1:e,!1)}else{let e=this.pos+1,n=this.buffer[e];for(;n;)if(gC.has(n))n=this.buffer[++e];else if(n==="%"&&Zg.has(this.buffer[e+1])&&Zg.has(this.buffer[e+2]))n=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
157
157
  `?yield*this.pushCount(1):e==="\r"&&this.charAt(1)===`
158
- `?yield*this.pushCount(2):0}*pushSpaces(e){let n=this.pos-1,r;do r=this.buffer[++n];while(r===" "||e&&r===" ");let s=n-this.pos;return s>0&&(yield this.buffer.substr(this.pos,s),this.pos=n),s}*pushUntil(e){let n=this.pos,r=this.buffer[n];for(;!e(r);)r=this.buffer[++n];return yield*this.pushToIndex(n,!1)}};Wg.Lexer=Mu});var ju=I(Kg=>{"use strict";var Bu=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let n=0,r=this.lineStarts.length;for(;n<r;){let i=n+r>>1;this.lineStarts[i]<e?n=i+1:r=i}if(this.lineStarts[n]===e)return{line:n+1,col:1};if(n===0)return{line:0,col:e};let s=this.lineStarts[n-1];return{line:n,col:e-s+1}}}};Kg.LineCounter=Bu});var Uu=I(Gg=>{"use strict";var KT=Ni("process"),Hg=Lo(),HT=Du();function Ft(t,e){for(let n=0;n<t.length;++n)if(t[n].type===e)return!0;return!1}function zg(t){for(let e=0;e<t.length;++e)switch(t[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function Vg(t){switch(t?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function Do(t){switch(t.type){case"document":return t.start;case"block-map":{let e=t.items[t.items.length-1];return e.sep??e.start}case"block-seq":return t.items[t.items.length-1].start;default:return[]}}function tr(t){if(t.length===0)return[];let e=t.length;e:for(;--e>=0;)switch(t[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;t[++e]?.type==="space";);return t.splice(e,t.length)}function Yg(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!Ft(e.start,"explicit-key-ind")&&!Ft(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,Vg(e.value)?e.value.end?Array.prototype.push.apply(e.value.end,e.sep):e.value.end=e.sep:Array.prototype.push.apply(e.start,e.sep),delete e.sep)}var Fu=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new HT.Lexer,this.onNewLine=e}*parse(e,n=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let r of this.lexer.lex(e,n))yield*this.next(r);n||(yield*this.end())}*next(e){if(this.source=e,KT.env.LOG_TOKENS&&console.log("|",Hg.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let n=Hg.tokenType(e);if(n)if(n==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=n,yield*this.step(),n){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&e[0]===" "&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{let r=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:r,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type==="doc-end"&&e?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let n=e??this.stack.pop();if(!n)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield n;else{let r=this.peek(1);switch(n.type==="block-scalar"?n.indent="indent"in r?r.indent:0:n.type==="flow-collection"&&r.type==="document"&&(n.indent=0),n.type==="flow-collection"&&Yg(n),r.type){case"document":r.value=n;break;case"block-scalar":r.props.push(n);break;case"block-map":{let s=r.items[r.items.length-1];if(s.value){r.items.push({start:[],key:n,sep:[]}),this.onKeyLine=!0;return}else if(s.sep)s.value=n;else{Object.assign(s,{key:n,sep:[]}),this.onKeyLine=!s.explicitKey;return}break}case"block-seq":{let s=r.items[r.items.length-1];s.value?r.items.push({start:[],value:n}):s.value=n;break}case"flow-collection":{let s=r.items[r.items.length-1];!s||s.value?r.items.push({start:[],key:n,sep:[]}):s.sep?s.value=n:Object.assign(s,{key:n,sep:[]});return}default:yield*this.pop(),yield*this.pop(n)}if((r.type==="document"||r.type==="block-map"||r.type==="block-seq")&&(n.type==="block-map"||n.type==="block-seq")){let s=n.items[n.items.length-1];s&&!s.sep&&!s.value&&s.start.length>0&&zg(s.start)===-1&&(n.indent===0||s.start.every(i=>i.type!=="comment"||i.indent<n.indent))&&(r.type==="document"?r.end=s.start:r.items.push({start:s.start}),n.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let e={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{zg(e.start)!==-1?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){let n=Do(this.peek(2)),r=tr(n),s;e.end?(s=e.end,s.push(this.sourceToken),delete e.end):s=[this.sourceToken];let i={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:s}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let n=this.source.indexOf(`
158
+ `?yield*this.pushCount(2):0}*pushSpaces(e){let n=this.pos-1,r;do r=this.buffer[++n];while(r===" "||e&&r===" ");let s=n-this.pos;return s>0&&(yield this.buffer.substr(this.pos,s),this.pos=n),s}*pushUntil(e){let n=this.pos,r=this.buffer[n];for(;!e(r);)r=this.buffer[++n];return yield*this.pushToIndex(n,!1)}};ey.Lexer=qu});var Ku=$(ty=>{"use strict";var Wu=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let n=0,r=this.lineStarts.length;for(;n<r;){let i=n+r>>1;this.lineStarts[i]<e?n=i+1:r=i}if(this.lineStarts[n]===e)return{line:n+1,col:1};if(n===0)return{line:0,col:e};let s=this.lineStarts[n-1];return{line:n,col:e-s+1}}}};ty.LineCounter=Wu});var zu=$(oy=>{"use strict";var bC=Ui("process"),ny=qo(),wC=Ju();function jt(t,e){for(let n=0;n<t.length;++n)if(t[n].type===e)return!0;return!1}function ry(t){for(let e=0;e<t.length;++e)switch(t[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function iy(t){switch(t?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function Wo(t){switch(t.type){case"document":return t.start;case"block-map":{let e=t.items[t.items.length-1];return e.sep??e.start}case"block-seq":return t.items[t.items.length-1].start;default:return[]}}function rr(t){if(t.length===0)return[];let e=t.length;e:for(;--e>=0;)switch(t[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;t[++e]?.type==="space";);return t.splice(e,t.length)}function sy(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!jt(e.start,"explicit-key-ind")&&!jt(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,iy(e.value)?e.value.end?Array.prototype.push.apply(e.value.end,e.sep):e.value.end=e.sep:Array.prototype.push.apply(e.start,e.sep),delete e.sep)}var Hu=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new wC.Lexer,this.onNewLine=e}*parse(e,n=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let r of this.lexer.lex(e,n))yield*this.next(r);n||(yield*this.end())}*next(e){if(this.source=e,bC.env.LOG_TOKENS&&console.log("|",ny.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let n=ny.tokenType(e);if(n)if(n==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=n,yield*this.step(),n){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&e[0]===" "&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{let r=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:r,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type==="doc-end"&&e?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let n=e??this.stack.pop();if(!n)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield n;else{let r=this.peek(1);switch(n.type==="block-scalar"?n.indent="indent"in r?r.indent:0:n.type==="flow-collection"&&r.type==="document"&&(n.indent=0),n.type==="flow-collection"&&sy(n),r.type){case"document":r.value=n;break;case"block-scalar":r.props.push(n);break;case"block-map":{let s=r.items[r.items.length-1];if(s.value){r.items.push({start:[],key:n,sep:[]}),this.onKeyLine=!0;return}else if(s.sep)s.value=n;else{Object.assign(s,{key:n,sep:[]}),this.onKeyLine=!s.explicitKey;return}break}case"block-seq":{let s=r.items[r.items.length-1];s.value?r.items.push({start:[],value:n}):s.value=n;break}case"flow-collection":{let s=r.items[r.items.length-1];!s||s.value?r.items.push({start:[],key:n,sep:[]}):s.sep?s.value=n:Object.assign(s,{key:n,sep:[]});return}default:yield*this.pop(),yield*this.pop(n)}if((r.type==="document"||r.type==="block-map"||r.type==="block-seq")&&(n.type==="block-map"||n.type==="block-seq")){let s=n.items[n.items.length-1];s&&!s.sep&&!s.value&&s.start.length>0&&ry(s.start)===-1&&(n.indent===0||s.start.every(i=>i.type!=="comment"||i.indent<n.indent))&&(r.type==="document"?r.end=s.start:r.items.push({start:s.start}),n.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let e={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{ry(e.start)!==-1?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){let n=Wo(this.peek(2)),r=rr(n),s;e.end?(s=e.end,s.push(this.sourceToken),delete e.end):s=[this.sourceToken];let i={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:s}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let n=this.source.indexOf(`
159
159
  `)+1;for(;n!==0;)this.onNewLine(this.offset+n),n=this.source.indexOf(`
160
- `,n)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let n=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,n.value){let r="end"in n.value?n.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)e.items.push({start:[this.sourceToken]});else if(n.sep)n.sep.push(this.sourceToken);else{if(this.atIndentedComment(n.start,e.indent)){let s=e.items[e.items.length-2]?.value?.end;if(Array.isArray(s)){Array.prototype.push.apply(s,n.start),s.push(this.sourceToken),e.items.pop();return}}n.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let r=!this.onKeyLine&&this.indent===e.indent,s=r&&(n.sep||n.explicitKey)&&this.type!=="seq-item-ind",i=[];if(s&&n.sep&&!n.value){let o=[];for(let a=0;a<n.sep.length;++a){let l=n.sep[a];switch(l.type){case"newline":o.push(a);break;case"space":break;case"comment":l.indent>e.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(i=n.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":s||n.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"explicit-key-ind":!n.sep&&!n.explicitKey?(n.start.push(this.sourceToken),n.explicitKey=!0):s||n.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(n.explicitKey)if(n.sep)if(n.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Ft(n.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(Vg(n.key)&&!Ft(n.sep,"newline")){let o=tr(n.start),a=n.key,l=n.sep;l.push(this.sourceToken),delete n.key,delete n.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:a,sep:l}]})}else i.length>0?n.sep=n.sep.concat(i,this.sourceToken):n.sep.push(this.sourceToken);else if(Ft(n.start,"newline"))Object.assign(n,{key:null,sep:[this.sourceToken]});else{let o=tr(n.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else n.sep?n.value||s?e.items.push({start:i,key:null,sep:[this.sourceToken]}):Ft(n.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):n.sep.push(this.sourceToken):Object.assign(n,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let o=this.flowScalar(this.type);s||n.value?(e.items.push({start:i,key:o,sep:[]}),this.onKeyLine=!0):n.sep?this.stack.push(o):(Object.assign(n,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{let o=this.startBlockValue(e);if(o){if(o.type==="block-seq"){if(!n.explicitKey&&n.sep&&!Ft(n.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else r&&e.items.push({start:i});this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let n=e.items[e.items.length-1];switch(this.type){case"newline":if(n.value){let r="end"in n.value?n.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(n.start,e.indent)){let s=e.items[e.items.length-2]?.value?.end;if(Array.isArray(s)){Array.prototype.push.apply(s,n.start),s.push(this.sourceToken),e.items.pop();return}}n.start.push(this.sourceToken)}return;case"anchor":case"tag":if(n.value||this.indent<=e.indent)break;n.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;n.value||Ft(n.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return}if(this.indent>e.indent){let r=this.startBlockValue(e);if(r){this.stack.push(r);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let n=e.items[e.items.length-1];if(this.type==="flow-error-end"){let r;do yield*this.pop(),r=this.peek(1);while(r?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!n||n.sep?e.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return;case"map-value-ind":!n||n.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):n.sep?n.sep.push(this.sourceToken):Object.assign(n,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!n||n.value?e.items.push({start:[this.sourceToken]}):n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let s=this.flowScalar(this.type);!n||n.value?e.items.push({start:[],key:s,sep:[]}):n.sep?this.stack.push(s):Object.assign(n,{key:s,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let r=this.startBlockValue(e);r?this.stack.push(r):(yield*this.pop(),yield*this.step())}else{let r=this.peek(2);if(r.type==="block-map"&&(this.type==="map-value-ind"&&r.indent===e.indent||this.type==="newline"&&!r.items[r.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&r.type!=="flow-collection"){let s=Do(r),i=tr(s);Yg(e);let o=e.end.splice(1,e.end.length);o.push(this.sourceToken);let a={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:i,key:e,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let n=this.source.indexOf(`
160
+ `,n)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let n=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,n.value){let r="end"in n.value?n.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)e.items.push({start:[this.sourceToken]});else if(n.sep)n.sep.push(this.sourceToken);else{if(this.atIndentedComment(n.start,e.indent)){let s=e.items[e.items.length-2]?.value?.end;if(Array.isArray(s)){Array.prototype.push.apply(s,n.start),s.push(this.sourceToken),e.items.pop();return}}n.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let r=!this.onKeyLine&&this.indent===e.indent,s=r&&(n.sep||n.explicitKey)&&this.type!=="seq-item-ind",i=[];if(s&&n.sep&&!n.value){let o=[];for(let a=0;a<n.sep.length;++a){let c=n.sep[a];switch(c.type){case"newline":o.push(a);break;case"space":break;case"comment":c.indent>e.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(i=n.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":s||n.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"explicit-key-ind":!n.sep&&!n.explicitKey?(n.start.push(this.sourceToken),n.explicitKey=!0):s||n.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(n.explicitKey)if(n.sep)if(n.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(jt(n.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(iy(n.key)&&!jt(n.sep,"newline")){let o=rr(n.start),a=n.key,c=n.sep;c.push(this.sourceToken),delete n.key,delete n.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:a,sep:c}]})}else i.length>0?n.sep=n.sep.concat(i,this.sourceToken):n.sep.push(this.sourceToken);else if(jt(n.start,"newline"))Object.assign(n,{key:null,sep:[this.sourceToken]});else{let o=rr(n.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else n.sep?n.value||s?e.items.push({start:i,key:null,sep:[this.sourceToken]}):jt(n.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):n.sep.push(this.sourceToken):Object.assign(n,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let o=this.flowScalar(this.type);s||n.value?(e.items.push({start:i,key:o,sep:[]}),this.onKeyLine=!0):n.sep?this.stack.push(o):(Object.assign(n,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{let o=this.startBlockValue(e);if(o){if(o.type==="block-seq"){if(!n.explicitKey&&n.sep&&!jt(n.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else r&&e.items.push({start:i});this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let n=e.items[e.items.length-1];switch(this.type){case"newline":if(n.value){let r="end"in n.value?n.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(n.start,e.indent)){let s=e.items[e.items.length-2]?.value?.end;if(Array.isArray(s)){Array.prototype.push.apply(s,n.start),s.push(this.sourceToken),e.items.pop();return}}n.start.push(this.sourceToken)}return;case"anchor":case"tag":if(n.value||this.indent<=e.indent)break;n.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;n.value||jt(n.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return}if(this.indent>e.indent){let r=this.startBlockValue(e);if(r){this.stack.push(r);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let n=e.items[e.items.length-1];if(this.type==="flow-error-end"){let r;do yield*this.pop(),r=this.peek(1);while(r?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!n||n.sep?e.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return;case"map-value-ind":!n||n.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):n.sep?n.sep.push(this.sourceToken):Object.assign(n,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!n||n.value?e.items.push({start:[this.sourceToken]}):n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let s=this.flowScalar(this.type);!n||n.value?e.items.push({start:[],key:s,sep:[]}):n.sep?this.stack.push(s):Object.assign(n,{key:s,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let r=this.startBlockValue(e);r?this.stack.push(r):(yield*this.pop(),yield*this.step())}else{let r=this.peek(2);if(r.type==="block-map"&&(this.type==="map-value-ind"&&r.indent===e.indent||this.type==="newline"&&!r.items[r.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&r.type!=="flow-collection"){let s=Wo(r),i=rr(s);sy(e);let o=e.end.splice(1,e.end.length);o.push(this.sourceToken);let a={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:i,key:e,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let n=this.source.indexOf(`
161
161
  `)+1;for(;n!==0;)this.onNewLine(this.offset+n),n=this.source.indexOf(`
162
- `,n)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let n=Do(e),r=tr(n);return r.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let n=Do(e),r=tr(n);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,n){return this.type!=="comment"||this.indent<=n?!1:e.every(r=>r.type==="newline"||r.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};Gg.Parser=Fu});var ty=I(Cs=>{"use strict";var Xg=Cu(),zT=bs(),Ts=Ss(),YT=Ac(),VT=W(),GT=ju(),Qg=Uu();function Zg(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new GT.LineCounter||null,prettyErrors:e}}function XT(t,e={}){let{lineCounter:n,prettyErrors:r}=Zg(e),s=new Qg.Parser(n?.addNewLine),i=new Xg.Composer(e),o=Array.from(i.compose(s.parse(t)));if(r&&n)for(let a of o)a.errors.forEach(Ts.prettifyError(t,n)),a.warnings.forEach(Ts.prettifyError(t,n));return o.length>0?o:Object.assign([],{empty:!0},i.streamInfo())}function ey(t,e={}){let{lineCounter:n,prettyErrors:r}=Zg(e),s=new Qg.Parser(n?.addNewLine),i=new Xg.Composer(e),o=null;for(let a of i.compose(s.parse(t),!0,t.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new Ts.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&n&&(o.errors.forEach(Ts.prettifyError(t,n)),o.warnings.forEach(Ts.prettifyError(t,n))),o}function QT(t,e,n){let r;typeof e=="function"?r=e:n===void 0&&e&&typeof e=="object"&&(n=e);let s=ey(t,n);if(!s)return null;if(s.warnings.forEach(i=>YT.warn(s.options.logLevel,i)),s.errors.length>0){if(s.options.logLevel!=="silent")throw s.errors[0];s.errors=[]}return s.toJS(Object.assign({reviver:r},n))}function ZT(t,e,n){let r=null;if(typeof e=="function"||Array.isArray(e)?r=e:n===void 0&&e&&(n=e),typeof n=="string"&&(n=n.length),typeof n=="number"){let s=Math.round(n);n=s<1?void 0:s>8?{indent:8}:{indent:s}}if(t===void 0){let{keepUndefined:s}=n??e??{};if(!s)return}return VT.isDocument(t)&&!r?t.toString(n):new zT.Document(t,r,n).toString(n)}Cs.parse=QT;Cs.parseAllDocuments=XT;Cs.parseDocument=ey;Cs.stringify=ZT});var ry=I(H=>{"use strict";var eC=Cu(),tC=bs(),nC=au(),qu=Ss(),rC=ts(),Ut=W(),sC=Mt(),iC=re(),oC=Bt(),aC=jt(),lC=Lo(),cC=Du(),uC=ju(),dC=Uu(),Bo=ty(),ny=Xr();H.Composer=eC.Composer;H.Document=tC.Document;H.Schema=nC.Schema;H.YAMLError=qu.YAMLError;H.YAMLParseError=qu.YAMLParseError;H.YAMLWarning=qu.YAMLWarning;H.Alias=rC.Alias;H.isAlias=Ut.isAlias;H.isCollection=Ut.isCollection;H.isDocument=Ut.isDocument;H.isMap=Ut.isMap;H.isNode=Ut.isNode;H.isPair=Ut.isPair;H.isScalar=Ut.isScalar;H.isSeq=Ut.isSeq;H.Pair=sC.Pair;H.Scalar=iC.Scalar;H.YAMLMap=oC.YAMLMap;H.YAMLSeq=aC.YAMLSeq;H.CST=lC;H.Lexer=cC.Lexer;H.LineCounter=uC.LineCounter;H.Parser=dC.Parser;H.parse=Bo.parse;H.parseAllDocuments=Bo.parseAllDocuments;H.parseDocument=Bo.parseDocument;H.stringify=Bo.stringify;H.visit=ny.visit;H.visitAsync=ny.visitAsync});function pC(t){try{return JSON.parse(t.trim()),!0}catch{return!1}}function hC(t){let e=t.trim();if(!e.startsWith("<"))return!1;let n=e.match(fC);return n?Gr(e,n[1])!==null:!1}function mC(t){let e=t.trim();if(!e.match(/^(---|#|\w+:|-)/)||"[{<".includes(e[0]))return!1;try{let n=sy.parse(e);return n!==null&&typeof n=="object"}catch{return!1}}function iy(t){return pC(t)||hC(t)||mC(t)}var sy,fC,Ju=S(()=>{mh();sy=wx(ry(),1),fC=/<([a-zA-Z_][\w.-]*)/});function gC(t){if(!t?.trim())return[];let e=t.replace(/\r\n/g,`
163
- `),n=e.trim();if(iy(n))return[{text:n,startLine:1,endLine:e.split(`
162
+ `,n)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let n=Wo(e),r=rr(n);return r.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let n=Wo(e),r=rr(n);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,n){return this.type!=="comment"||this.indent<=n?!1:e.every(r=>r.type==="newline"||r.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};oy.Parser=Hu});var dy=$($s=>{"use strict";var ay=$u(),vC=Es(),Is=Cs(),SC=Rl(),kC=W(),xC=Ku(),cy=zu();function ly(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new xC.LineCounter||null,prettyErrors:e}}function EC(t,e={}){let{lineCounter:n,prettyErrors:r}=ly(e),s=new cy.Parser(n?.addNewLine),i=new ay.Composer(e),o=Array.from(i.compose(s.parse(t)));if(r&&n)for(let a of o)a.errors.forEach(Is.prettifyError(t,n)),a.warnings.forEach(Is.prettifyError(t,n));return o.length>0?o:Object.assign([],{empty:!0},i.streamInfo())}function uy(t,e={}){let{lineCounter:n,prettyErrors:r}=ly(e),s=new cy.Parser(n?.addNewLine),i=new ay.Composer(e),o=null;for(let a of i.compose(s.parse(t),!0,t.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new Is.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&n&&(o.errors.forEach(Is.prettifyError(t,n)),o.warnings.forEach(Is.prettifyError(t,n))),o}function AC(t,e,n){let r;typeof e=="function"?r=e:n===void 0&&e&&typeof e=="object"&&(n=e);let s=uy(t,n);if(!s)return null;if(s.warnings.forEach(i=>SC.warn(s.options.logLevel,i)),s.errors.length>0){if(s.options.logLevel!=="silent")throw s.errors[0];s.errors=[]}return s.toJS(Object.assign({reviver:r},n))}function TC(t,e,n){let r=null;if(typeof e=="function"||Array.isArray(e)?r=e:n===void 0&&e&&(n=e),typeof n=="string"&&(n=n.length),typeof n=="number"){let s=Math.round(n);n=s<1?void 0:s>8?{indent:8}:{indent:s}}if(t===void 0){let{keepUndefined:s}=n??e??{};if(!s)return}return kC.isDocument(t)&&!r?t.toString(n):new vC.Document(t,r,n).toString(n)}$s.parse=AC;$s.parseAllDocuments=EC;$s.parseDocument=uy;$s.stringify=TC});var py=$(z=>{"use strict";var CC=$u(),OC=Es(),PC=pu(),Yu=Cs(),_C=as(),Ft=W(),RC=Lt(),IC=oe(),$C=Dt(),NC=Bt(),LC=qo(),MC=Ju(),DC=Ku(),BC=zu(),Ko=dy(),fy=rs();z.Composer=CC.Composer;z.Document=OC.Document;z.Schema=PC.Schema;z.YAMLError=Yu.YAMLError;z.YAMLParseError=Yu.YAMLParseError;z.YAMLWarning=Yu.YAMLWarning;z.Alias=_C.Alias;z.isAlias=Ft.isAlias;z.isCollection=Ft.isCollection;z.isDocument=Ft.isDocument;z.isMap=Ft.isMap;z.isNode=Ft.isNode;z.isPair=Ft.isPair;z.isScalar=Ft.isScalar;z.isSeq=Ft.isSeq;z.Pair=RC.Pair;z.Scalar=IC.Scalar;z.YAMLMap=$C.YAMLMap;z.YAMLSeq=NC.YAMLSeq;z.CST=LC;z.Lexer=MC.Lexer;z.LineCounter=DC.LineCounter;z.Parser=BC.Parser;z.parse=Ko.parse;z.parseAllDocuments=Ko.parseAllDocuments;z.parseDocument=Ko.parseDocument;z.stringify=Ko.stringify;z.visit=fy.visit;z.visitAsync=fy.visitAsync});function FC(t){try{return JSON.parse(t.trim()),!0}catch{return!1}}function UC(t){let e=t.trim();if(!e.startsWith("<"))return!1;let n=e.match(jC);return n?ns(e,n[1])!==null:!1}function qC(t){let e=t.trim();if(!e.match(/^(---|#|\w+:|-)/)||"[{<".includes(e[0]))return!1;try{let n=hy.parse(e);return n!==null&&typeof n=="object"}catch{return!1}}function my(t){return FC(t)||UC(t)||qC(t)}var hy,jC,Vu=k(()=>{Ah();hy=Hx(py(),1),jC=/<([a-zA-Z_][\w.-]*)/});function JC(t){if(!t?.trim())return[];let e=t.replace(/\r\n/g,`
163
+ `),n=e.trim();if(my(n))return[{text:n,startLine:1,endLine:e.split(`
164
164
  `).length}];let r=e.split(`
165
- `),s=[],i=0,o=-1,a=0,l=()=>{if(o>=i){let c=r.slice(i,o+1).join(`
166
- `).trim();c&&s.push({text:c,startLine:i+1,endLine:o+1})}};for(let c=0;c<r.length;c++)r[c].trim()?(a>=2&&o>=i&&(l(),i=c),a=0,o=c):a++;return l(),s}function jo(t){return gC(t).map(e=>e.text)}var oy,ay=S(()=>{Ju();oy=`
165
+ `),s=[],i=0,o=-1,a=0,c=()=>{if(o>=i){let l=r.slice(i,o+1).join(`
166
+ `).trim();l&&s.push({text:l,startLine:i+1,endLine:o+1})}};for(let l=0;l<r.length;l++)r[l].trim()?(a>=2&&o>=i&&(c(),i=l),a=0,o=l):a++;return c(),s}function Ho(t){return JC(t).map(e=>e.text)}var gy,yy=k(()=>{Vu();gy=`
167
167
 
168
168
 
169
- `});function Fo(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var ly=S(()=>{});var yC,bC,Wu,cy=S(()=>{yC=[["\xDF","ss"],["\u1E9E","Ss"],["\xE4","ae"],["\xC4","Ae"],["\xF6","oe"],["\xD6","Oe"],["\xFC","ue"],["\xDC","Ue"],["\xC0","A"],["\xC1","A"],["\xC2","A"],["\xC3","A"],["\xC4","Ae"],["\xC5","A"],["\xC6","AE"],["\xC7","C"],["\xC8","E"],["\xC9","E"],["\xCA","E"],["\xCB","E"],["\u018F","A"],["\xCC","I"],["\xCD","I"],["\xCE","I"],["\xCF","I"],["\xD0","D"],["\xD1","N"],["\xD2","O"],["\xD3","O"],["\xD4","O"],["\xD5","O"],["\xD6","Oe"],["\u014C","O"],["\u0150","O"],["\xD8","O"],["\u0152","OE"],["\xD9","U"],["\xDA","U"],["\xDB","U"],["\xDC","Ue"],["\u0170","U"],["\xDD","Y"],["\xDE","TH"],["\xDF","ss"],["\xE0","a"],["\xE1","a"],["\xE2","a"],["\xE3","a"],["\xE4","ae"],["\xE5","a"],["\xE6","ae"],["\xE7","c"],["\xE8","e"],["\xE9","e"],["\xEA","e"],["\xEB","e"],["\u0259","a"],["\xEC","i"],["\xED","i"],["\xEE","i"],["\xEF","i"],["\xF0","d"],["\xF1","n"],["\xF2","o"],["\xF3","o"],["\xF4","o"],["\xF5","o"],["\xF6","oe"],["\u014D","o"],["\u0151","o"],["\xF8","o"],["\u0153","oe"],["\xF9","u"],["\xFA","u"],["\xFB","u"],["\xFC","ue"],["\u0171","u"],["\xFD","y"],["\xFE","th"],["\xFF","y"],["\xE0","a"],["\xC0","A"],["\xE1","a"],["\xC1","A"],["\xE2","a"],["\xC2","A"],["\xE3","a"],["\xC3","A"],["\xE8","e"],["\xC8","E"],["\xE9","e"],["\xC9","E"],["\xEA","e"],["\xCA","E"],["\xEC","i"],["\xCC","I"],["\xED","i"],["\xCD","I"],["\xF2","o"],["\xD2","O"],["\xF3","o"],["\xD3","O"],["\xF4","o"],["\xD4","O"],["\xF5","o"],["\xD5","O"],["\xF9","u"],["\xD9","U"],["\xFA","u"],["\xDA","U"],["\xFD","y"],["\xDD","Y"],["\u0103","a"],["\u0102","A"],["\u0110","D"],["\u0111","d"],["\u0129","i"],["\u0128","I"],["\u0169","u"],["\u0168","U"],["\u01A1","o"],["\u01A0","O"],["\u01B0","u"],["\u01AF","U"],["\u1EA1","a"],["\u1EA0","A"],["\u1EA3","a"],["\u1EA2","A"],["\u1EA5","a"],["\u1EA4","A"],["\u1EA7","a"],["\u1EA6","A"],["\u1EA9","a"],["\u1EA8","A"],["\u1EAB","a"],["\u1EAA","A"],["\u1EAD","a"],["\u1EAC","A"],["\u1EAF","a"],["\u1EAE","A"],["\u1EB1","a"],["\u1EB0","A"],["\u1EB3","a"],["\u1EB2","A"],["\u1EB5","a"],["\u1EB4","A"],["\u1EB7","a"],["\u1EB6","A"],["\u1EB9","e"],["\u1EB8","E"],["\u1EBB","e"],["\u1EBA","E"],["\u1EBD","e"],["\u1EBC","E"],["\u1EBF","e"],["\u1EBE","E"],["\u1EC1","e"],["\u1EC0","E"],["\u1EC3","e"],["\u1EC2","E"],["\u1EC5","e"],["\u1EC4","E"],["\u1EC7","e"],["\u1EC6","E"],["\u1EC9","i"],["\u1EC8","I"],["\u1ECB","i"],["\u1ECA","I"],["\u1ECD","o"],["\u1ECC","O"],["\u1ECF","o"],["\u1ECE","O"],["\u1ED1","o"],["\u1ED0","O"],["\u1ED3","o"],["\u1ED2","O"],["\u1ED5","o"],["\u1ED4","O"],["\u1ED7","o"],["\u1ED6","O"],["\u1ED9","o"],["\u1ED8","O"],["\u1EDB","o"],["\u1EDA","O"],["\u1EDD","o"],["\u1EDC","O"],["\u1EDF","o"],["\u1EDE","O"],["\u1EE1","o"],["\u1EE0","O"],["\u1EE3","o"],["\u1EE2","O"],["\u1EE5","u"],["\u1EE4","U"],["\u1EE7","u"],["\u1EE6","U"],["\u1EE9","u"],["\u1EE8","U"],["\u1EEB","u"],["\u1EEA","U"],["\u1EED","u"],["\u1EEC","U"],["\u1EEF","u"],["\u1EEE","U"],["\u1EF1","u"],["\u1EF0","U"],["\u1EF3","y"],["\u1EF2","Y"],["\u1EF5","y"],["\u1EF4","Y"],["\u1EF7","y"],["\u1EF6","Y"],["\u1EF9","y"],["\u1EF8","Y"],["\u0621","e"],["\u0622","a"],["\u0623","a"],["\u0624","w"],["\u0625","a"],["\u0626","y"],["\u0627","a"],["\u0628","b"],["\u0629","t"],["\u062A","t"],["\u062B","th"],["\u062C","j"],["\u062D","h"],["\u062E","kh"],["\u062F","d"],["\u0630","dh"],["\u0631","r"],["\u0632","z"],["\u0633","s"],["\u0634","sh"],["\u0635","s"],["\u0636","d"],["\u0637","t"],["\u0638","z"],["\u0639","e"],["\u063A","gh"],["\u0640","_"],["\u0641","f"],["\u0642","q"],["\u0643","k"],["\u0644","l"],["\u0645","m"],["\u0646","n"],["\u0647","h"],["\u0648","w"],["\u0649","a"],["\u064A","y"],["\u064E\u200E","a"],["\u064F","u"],["\u0650\u200E","i"],["\u0660","0"],["\u0661","1"],["\u0662","2"],["\u0663","3"],["\u0664","4"],["\u0665","5"],["\u0666","6"],["\u0667","7"],["\u0668","8"],["\u0669","9"],["\u0686","ch"],["\u06A9","k"],["\u06AF","g"],["\u067E","p"],["\u0698","zh"],["\u06CC","y"],["\u06F0","0"],["\u06F1","1"],["\u06F2","2"],["\u06F3","3"],["\u06F4","4"],["\u06F5","5"],["\u06F6","6"],["\u06F7","7"],["\u06F8","8"],["\u06F9","9"],["\u067C","p"],["\u0681","z"],["\u0685","c"],["\u0689","d"],["\uFEAB","d"],["\uFEAD","r"],["\u0693","r"],["\uFEAF","z"],["\u0696","g"],["\u069A","x"],["\u06AB","g"],["\u06BC","n"],["\u06C0","e"],["\u06D0","e"],["\u06CD","ai"],["\u0679","t"],["\u0688","d"],["\u0691","r"],["\u06BA","n"],["\u06C1","h"],["\u06BE","h"],["\u06D2","e"],["\u0410","A"],["\u0430","a"],["\u0411","B"],["\u0431","b"],["\u0412","V"],["\u0432","v"],["\u0413","G"],["\u0433","g"],["\u0414","D"],["\u0434","d"],["\u044A\u0435","ye"],["\u042A\u0435","Ye"],["\u044A\u0415","yE"],["\u042A\u0415","YE"],["\u0415","E"],["\u0435","e"],["\u0401","Yo"],["\u0451","yo"],["\u0416","Zh"],["\u0436","zh"],["\u0417","Z"],["\u0437","z"],["\u0418","I"],["\u0438","i"],["\u044B\u0439","iy"],["\u042B\u0439","Iy"],["\u042B\u0419","IY"],["\u044B\u0419","iY"],["\u0419","Y"],["\u0439","y"],["\u041A","K"],["\u043A","k"],["\u041B","L"],["\u043B","l"],["\u041C","M"],["\u043C","m"],["\u041D","N"],["\u043D","n"],["\u041E","O"],["\u043E","o"],["\u041F","P"],["\u043F","p"],["\u0420","R"],["\u0440","r"],["\u0421","S"],["\u0441","s"],["\u0422","T"],["\u0442","t"],["\u0423","U"],["\u0443","u"],["\u0424","F"],["\u0444","f"],["\u0425","Kh"],["\u0445","kh"],["\u0426","Ts"],["\u0446","ts"],["\u0427","Ch"],["\u0447","ch"],["\u0428","Sh"],["\u0448","sh"],["\u0429","Sch"],["\u0449","sch"],["\u042A",""],["\u044A",""],["\u042B","Y"],["\u044B","y"],["\u042C",""],["\u044C",""],["\u042D","E"],["\u044D","e"],["\u042E","Yu"],["\u044E","yu"],["\u042F","Ya"],["\u044F","ya"],["\u0103","a"],["\u0102","A"],["\u0219","s"],["\u0218","S"],["\u021B","t"],["\u021A","T"],["\u0163","t"],["\u0162","T"],["\u015F","s"],["\u015E","S"],["\xE7","c"],["\xC7","C"],["\u011F","g"],["\u011E","G"],["\u0131","i"],["\u0130","I"],["\u0561","a"],["\u0531","A"],["\u0562","b"],["\u0532","B"],["\u0563","g"],["\u0533","G"],["\u0564","d"],["\u0534","D"],["\u0565","ye"],["\u0535","Ye"],["\u0566","z"],["\u0536","Z"],["\u0567","e"],["\u0537","E"],["\u0568","y"],["\u0538","Y"],["\u0569","t"],["\u0539","T"],["\u056A","zh"],["\u053A","Zh"],["\u056B","i"],["\u053B","I"],["\u056C","l"],["\u053C","L"],["\u056D","kh"],["\u053D","Kh"],["\u056E","ts"],["\u053E","Ts"],["\u056F","k"],["\u053F","K"],["\u0570","h"],["\u0540","H"],["\u0571","dz"],["\u0541","Dz"],["\u0572","gh"],["\u0542","Gh"],["\u0573","tch"],["\u0543","Tch"],["\u0574","m"],["\u0544","M"],["\u0575","y"],["\u0545","Y"],["\u0576","n"],["\u0546","N"],["\u0577","sh"],["\u0547","Sh"],["\u0578\u0582","u"],["\u0548\u0552","U"],["\u0548\u0582","U"],["\u0578","vo"],["\u0548","Vo"],["\u0579","ch"],["\u0549","Ch"],["\u057A","p"],["\u054A","P"],["\u057B","j"],["\u054B","J"],["\u057C","r"],["\u054C","R"],["\u057D","s"],["\u054D","S"],["\u057E","v"],["\u054E","V"],["\u057F","t"],["\u054F","T"],["\u0580","r"],["\u0550","R"],["\u0581","c"],["\u0551","C"],["\u0583","p"],["\u0553","P"],["\u0584","q"],["\u0554","Q"],["\u0585","o"],["\u0555","O"],["\u0586","f"],["\u0556","F"],["\u0587","yev"],["\u10D0","a"],["\u10D1","b"],["\u10D2","g"],["\u10D3","d"],["\u10D4","e"],["\u10D5","v"],["\u10D6","z"],["\u10D7","t"],["\u10D8","i"],["\u10D9","k"],["\u10DA","l"],["\u10DB","m"],["\u10DC","n"],["\u10DD","o"],["\u10DE","p"],["\u10DF","zh"],["\u10E0","r"],["\u10E1","s"],["\u10E2","t"],["\u10E3","u"],["\u10E4","ph"],["\u10E5","q"],["\u10E6","gh"],["\u10E7","k"],["\u10E8","sh"],["\u10E9","ch"],["\u10EA","ts"],["\u10EB","dz"],["\u10EC","ts"],["\u10ED","tch"],["\u10EE","kh"],["\u10EF","j"],["\u10F0","h"],["\u010D","c"],["\u010F","d"],["\u011B","e"],["\u0148","n"],["\u0159","r"],["\u0161","s"],["\u0165","t"],["\u016F","u"],["\u017E","z"],["\u010C","C"],["\u010E","D"],["\u011A","E"],["\u0147","N"],["\u0158","R"],["\u0160","S"],["\u0164","T"],["\u016E","U"],["\u017D","Z"],["\u0780","h"],["\u0781","sh"],["\u0782","n"],["\u0783","r"],["\u0784","b"],["\u0785","lh"],["\u0786","k"],["\u0787","a"],["\u0788","v"],["\u0789","m"],["\u078A","f"],["\u078B","dh"],["\u078C","th"],["\u078D","l"],["\u078E","g"],["\u078F","gn"],["\u0790","s"],["\u0791","d"],["\u0792","z"],["\u0793","t"],["\u0794","y"],["\u0795","p"],["\u0796","j"],["\u0797","ch"],["\u0798","tt"],["\u0799","hh"],["\u079A","kh"],["\u079B","th"],["\u079C","z"],["\u079D","sh"],["\u079E","s"],["\u079F","d"],["\u07A0","t"],["\u07A1","z"],["\u07A2","a"],["\u07A3","gh"],["\u07A4","q"],["\u07A5","w"],["\u07A6","a"],["\u07A7","aa"],["\u07A8","i"],["\u07A9","ee"],["\u07AA","u"],["\u07AB","oo"],["\u07AC","e"],["\u07AD","ey"],["\u07AE","o"],["\u07AF","oa"],["\u07B0",""],["\u03B1","a"],["\u03B2","v"],["\u03B3","g"],["\u03B4","d"],["\u03B5","e"],["\u03B6","z"],["\u03B7","i"],["\u03B8","th"],["\u03B9","i"],["\u03BA","k"],["\u03BB","l"],["\u03BC","m"],["\u03BD","n"],["\u03BE","ks"],["\u03BF","o"],["\u03C0","p"],["\u03C1","r"],["\u03C3","s"],["\u03C4","t"],["\u03C5","y"],["\u03C6","f"],["\u03C7","x"],["\u03C8","ps"],["\u03C9","o"],["\u03AC","a"],["\u03AD","e"],["\u03AF","i"],["\u03CC","o"],["\u03CD","y"],["\u03AE","i"],["\u03CE","o"],["\u03C2","s"],["\u03CA","i"],["\u03B0","y"],["\u03CB","y"],["\u0390","i"],["\u0391","A"],["\u0392","B"],["\u0393","G"],["\u0394","D"],["\u0395","E"],["\u0396","Z"],["\u0397","I"],["\u0398","TH"],["\u0399","I"],["\u039A","K"],["\u039B","L"],["\u039C","M"],["\u039D","N"],["\u039E","KS"],["\u039F","O"],["\u03A0","P"],["\u03A1","R"],["\u03A3","S"],["\u03A4","T"],["\u03A5","Y"],["\u03A6","F"],["\u03A7","X"],["\u03A8","PS"],["\u03A9","O"],["\u0386","A"],["\u0388","E"],["\u038A","I"],["\u038C","O"],["\u038E","Y"],["\u0389","I"],["\u038F","O"],["\u03AA","I"],["\u03AB","Y"],["\u0101","a"],["\u0113","e"],["\u0123","g"],["\u012B","i"],["\u0137","k"],["\u013C","l"],["\u0146","n"],["\u016B","u"],["\u0100","A"],["\u0112","E"],["\u0122","G"],["\u012A","I"],["\u0136","K"],["\u013B","L"],["\u0145","N"],["\u016A","U"],["\u010D","c"],["\u0161","s"],["\u017E","z"],["\u010C","C"],["\u0160","S"],["\u017D","Z"],["\u0105","a"],["\u010D","c"],["\u0119","e"],["\u0117","e"],["\u012F","i"],["\u0161","s"],["\u0173","u"],["\u016B","u"],["\u017E","z"],["\u0104","A"],["\u010C","C"],["\u0118","E"],["\u0116","E"],["\u012E","I"],["\u0160","S"],["\u0172","U"],["\u016A","U"],["\u040C","Kj"],["\u045C","kj"],["\u0409","Lj"],["\u0459","lj"],["\u040A","Nj"],["\u045A","nj"],["\u0422\u0441","Ts"],["\u0442\u0441","ts"],["\u0105","a"],["\u0107","c"],["\u0119","e"],["\u0142","l"],["\u0144","n"],["\u015B","s"],["\u017A","z"],["\u017C","z"],["\u0104","A"],["\u0106","C"],["\u0118","E"],["\u0141","L"],["\u0143","N"],["\u015A","S"],["\u0179","Z"],["\u017B","Z"],["\u0404","Ye"],["\u0406","I"],["\u0407","Yi"],["\u0490","G"],["\u0454","ye"],["\u0456","i"],["\u0457","yi"],["\u0491","g"],["\u0132","IJ"],["\u0133","ij"],["\xA2","c"],["\xA5","Y"],["\u07FF","b"],["\u09F3","t"],["\u0AF1","Bo"],["\u0E3F","B"],["\u20A0","CE"],["\u20A1","C"],["\u20A2","Cr"],["\u20A3","F"],["\u20A5","m"],["\u20A6","N"],["\u20A7","Pt"],["\u20A8","Rs"],["\u20A9","W"],["\u20AB","s"],["\u20AC","E"],["\u20AD","K"],["\u20AE","T"],["\u20AF","Dp"],["\u20B0","S"],["\u20B1","P"],["\u20B2","G"],["\u20B3","A"],["\u20B4","S"],["\u20B5","C"],["\u20B6","tt"],["\u20B7","S"],["\u20B8","T"],["\u20B9","R"],["\u20BA","L"],["\u20BD","P"],["\u20BF","B"],["\uFE69","$"],["\uFFE0","c"],["\uFFE5","Y"],["\uFFE6","W"],["\u{1D400}","A"],["\u{1D401}","B"],["\u{1D402}","C"],["\u{1D403}","D"],["\u{1D404}","E"],["\u{1D405}","F"],["\u{1D406}","G"],["\u{1D407}","H"],["\u{1D408}","I"],["\u{1D409}","J"],["\u{1D40A}","K"],["\u{1D40B}","L"],["\u{1D40C}","M"],["\u{1D40D}","N"],["\u{1D40E}","O"],["\u{1D40F}","P"],["\u{1D410}","Q"],["\u{1D411}","R"],["\u{1D412}","S"],["\u{1D413}","T"],["\u{1D414}","U"],["\u{1D415}","V"],["\u{1D416}","W"],["\u{1D417}","X"],["\u{1D418}","Y"],["\u{1D419}","Z"],["\u{1D41A}","a"],["\u{1D41B}","b"],["\u{1D41C}","c"],["\u{1D41D}","d"],["\u{1D41E}","e"],["\u{1D41F}","f"],["\u{1D420}","g"],["\u{1D421}","h"],["\u{1D422}","i"],["\u{1D423}","j"],["\u{1D424}","k"],["\u{1D425}","l"],["\u{1D426}","m"],["\u{1D427}","n"],["\u{1D428}","o"],["\u{1D429}","p"],["\u{1D42A}","q"],["\u{1D42B}","r"],["\u{1D42C}","s"],["\u{1D42D}","t"],["\u{1D42E}","u"],["\u{1D42F}","v"],["\u{1D430}","w"],["\u{1D431}","x"],["\u{1D432}","y"],["\u{1D433}","z"],["\u{1D434}","A"],["\u{1D435}","B"],["\u{1D436}","C"],["\u{1D437}","D"],["\u{1D438}","E"],["\u{1D439}","F"],["\u{1D43A}","G"],["\u{1D43B}","H"],["\u{1D43C}","I"],["\u{1D43D}","J"],["\u{1D43E}","K"],["\u{1D43F}","L"],["\u{1D440}","M"],["\u{1D441}","N"],["\u{1D442}","O"],["\u{1D443}","P"],["\u{1D444}","Q"],["\u{1D445}","R"],["\u{1D446}","S"],["\u{1D447}","T"],["\u{1D448}","U"],["\u{1D449}","V"],["\u{1D44A}","W"],["\u{1D44B}","X"],["\u{1D44C}","Y"],["\u{1D44D}","Z"],["\u{1D44E}","a"],["\u{1D44F}","b"],["\u{1D450}","c"],["\u{1D451}","d"],["\u{1D452}","e"],["\u{1D453}","f"],["\u{1D454}","g"],["\u{1D456}","i"],["\u{1D457}","j"],["\u{1D458}","k"],["\u{1D459}","l"],["\u{1D45A}","m"],["\u{1D45B}","n"],["\u{1D45C}","o"],["\u{1D45D}","p"],["\u{1D45E}","q"],["\u{1D45F}","r"],["\u{1D460}","s"],["\u{1D461}","t"],["\u{1D462}","u"],["\u{1D463}","v"],["\u{1D464}","w"],["\u{1D465}","x"],["\u{1D466}","y"],["\u{1D467}","z"],["\u{1D468}","A"],["\u{1D469}","B"],["\u{1D46A}","C"],["\u{1D46B}","D"],["\u{1D46C}","E"],["\u{1D46D}","F"],["\u{1D46E}","G"],["\u{1D46F}","H"],["\u{1D470}","I"],["\u{1D471}","J"],["\u{1D472}","K"],["\u{1D473}","L"],["\u{1D474}","M"],["\u{1D475}","N"],["\u{1D476}","O"],["\u{1D477}","P"],["\u{1D478}","Q"],["\u{1D479}","R"],["\u{1D47A}","S"],["\u{1D47B}","T"],["\u{1D47C}","U"],["\u{1D47D}","V"],["\u{1D47E}","W"],["\u{1D47F}","X"],["\u{1D480}","Y"],["\u{1D481}","Z"],["\u{1D482}","a"],["\u{1D483}","b"],["\u{1D484}","c"],["\u{1D485}","d"],["\u{1D486}","e"],["\u{1D487}","f"],["\u{1D488}","g"],["\u{1D489}","h"],["\u{1D48A}","i"],["\u{1D48B}","j"],["\u{1D48C}","k"],["\u{1D48D}","l"],["\u{1D48E}","m"],["\u{1D48F}","n"],["\u{1D490}","o"],["\u{1D491}","p"],["\u{1D492}","q"],["\u{1D493}","r"],["\u{1D494}","s"],["\u{1D495}","t"],["\u{1D496}","u"],["\u{1D497}","v"],["\u{1D498}","w"],["\u{1D499}","x"],["\u{1D49A}","y"],["\u{1D49B}","z"],["\u{1D49C}","A"],["\u{1D49E}","C"],["\u{1D49F}","D"],["\u{1D4A2}","g"],["\u{1D4A5}","J"],["\u{1D4A6}","K"],["\u{1D4A9}","N"],["\u{1D4AA}","O"],["\u{1D4AB}","P"],["\u{1D4AC}","Q"],["\u{1D4AE}","S"],["\u{1D4AF}","T"],["\u{1D4B0}","U"],["\u{1D4B1}","V"],["\u{1D4B2}","W"],["\u{1D4B3}","X"],["\u{1D4B4}","Y"],["\u{1D4B5}","Z"],["\u{1D4B6}","a"],["\u{1D4B7}","b"],["\u{1D4B8}","c"],["\u{1D4B9}","d"],["\u{1D4BB}","f"],["\u{1D4BD}","h"],["\u{1D4BE}","i"],["\u{1D4BF}","j"],["\u{1D4C0}","k"],["\u{1D4C1}","l"],["\u{1D4C2}","m"],["\u{1D4C3}","n"],["\u{1D4C5}","p"],["\u{1D4C6}","q"],["\u{1D4C7}","r"],["\u{1D4C8}","s"],["\u{1D4C9}","t"],["\u{1D4CA}","u"],["\u{1D4CB}","v"],["\u{1D4CC}","w"],["\u{1D4CD}","x"],["\u{1D4CE}","y"],["\u{1D4CF}","z"],["\u{1D4D0}","A"],["\u{1D4D1}","B"],["\u{1D4D2}","C"],["\u{1D4D3}","D"],["\u{1D4D4}","E"],["\u{1D4D5}","F"],["\u{1D4D6}","G"],["\u{1D4D7}","H"],["\u{1D4D8}","I"],["\u{1D4D9}","J"],["\u{1D4DA}","K"],["\u{1D4DB}","L"],["\u{1D4DC}","M"],["\u{1D4DD}","N"],["\u{1D4DE}","O"],["\u{1D4DF}","P"],["\u{1D4E0}","Q"],["\u{1D4E1}","R"],["\u{1D4E2}","S"],["\u{1D4E3}","T"],["\u{1D4E4}","U"],["\u{1D4E5}","V"],["\u{1D4E6}","W"],["\u{1D4E7}","X"],["\u{1D4E8}","Y"],["\u{1D4E9}","Z"],["\u{1D4EA}","a"],["\u{1D4EB}","b"],["\u{1D4EC}","c"],["\u{1D4ED}","d"],["\u{1D4EE}","e"],["\u{1D4EF}","f"],["\u{1D4F0}","g"],["\u{1D4F1}","h"],["\u{1D4F2}","i"],["\u{1D4F3}","j"],["\u{1D4F4}","k"],["\u{1D4F5}","l"],["\u{1D4F6}","m"],["\u{1D4F7}","n"],["\u{1D4F8}","o"],["\u{1D4F9}","p"],["\u{1D4FA}","q"],["\u{1D4FB}","r"],["\u{1D4FC}","s"],["\u{1D4FD}","t"],["\u{1D4FE}","u"],["\u{1D4FF}","v"],["\u{1D500}","w"],["\u{1D501}","x"],["\u{1D502}","y"],["\u{1D503}","z"],["\u{1D504}","A"],["\u{1D505}","B"],["\u{1D507}","D"],["\u{1D508}","E"],["\u{1D509}","F"],["\u{1D50A}","G"],["\u{1D50D}","J"],["\u{1D50E}","K"],["\u{1D50F}","L"],["\u{1D510}","M"],["\u{1D511}","N"],["\u{1D512}","O"],["\u{1D513}","P"],["\u{1D514}","Q"],["\u{1D516}","S"],["\u{1D517}","T"],["\u{1D518}","U"],["\u{1D519}","V"],["\u{1D51A}","W"],["\u{1D51B}","X"],["\u{1D51C}","Y"],["\u{1D51E}","a"],["\u{1D51F}","b"],["\u{1D520}","c"],["\u{1D521}","d"],["\u{1D522}","e"],["\u{1D523}","f"],["\u{1D524}","g"],["\u{1D525}","h"],["\u{1D526}","i"],["\u{1D527}","j"],["\u{1D528}","k"],["\u{1D529}","l"],["\u{1D52A}","m"],["\u{1D52B}","n"],["\u{1D52C}","o"],["\u{1D52D}","p"],["\u{1D52E}","q"],["\u{1D52F}","r"],["\u{1D530}","s"],["\u{1D531}","t"],["\u{1D532}","u"],["\u{1D533}","v"],["\u{1D534}","w"],["\u{1D535}","x"],["\u{1D536}","y"],["\u{1D537}","z"],["\u{1D538}","A"],["\u{1D539}","B"],["\u{1D53B}","D"],["\u{1D53C}","E"],["\u{1D53D}","F"],["\u{1D53E}","G"],["\u{1D540}","I"],["\u{1D541}","J"],["\u{1D542}","K"],["\u{1D543}","L"],["\u{1D544}","M"],["\u{1D546}","O"],["\u{1D54A}","S"],["\u{1D54B}","T"],["\u{1D54C}","U"],["\u{1D54D}","V"],["\u{1D54E}","W"],["\u{1D54F}","X"],["\u{1D550}","Y"],["\u{1D552}","a"],["\u{1D553}","b"],["\u{1D554}","c"],["\u{1D555}","d"],["\u{1D556}","e"],["\u{1D557}","f"],["\u{1D558}","g"],["\u{1D559}","h"],["\u{1D55A}","i"],["\u{1D55B}","j"],["\u{1D55C}","k"],["\u{1D55D}","l"],["\u{1D55E}","m"],["\u{1D55F}","n"],["\u{1D560}","o"],["\u{1D561}","p"],["\u{1D562}","q"],["\u{1D563}","r"],["\u{1D564}","s"],["\u{1D565}","t"],["\u{1D566}","u"],["\u{1D567}","v"],["\u{1D568}","w"],["\u{1D569}","x"],["\u{1D56A}","y"],["\u{1D56B}","z"],["\u{1D56C}","A"],["\u{1D56D}","B"],["\u{1D56E}","C"],["\u{1D56F}","D"],["\u{1D570}","E"],["\u{1D571}","F"],["\u{1D572}","G"],["\u{1D573}","H"],["\u{1D574}","I"],["\u{1D575}","J"],["\u{1D576}","K"],["\u{1D577}","L"],["\u{1D578}","M"],["\u{1D579}","N"],["\u{1D57A}","O"],["\u{1D57B}","P"],["\u{1D57C}","Q"],["\u{1D57D}","R"],["\u{1D57E}","S"],["\u{1D57F}","T"],["\u{1D580}","U"],["\u{1D581}","V"],["\u{1D582}","W"],["\u{1D583}","X"],["\u{1D584}","Y"],["\u{1D585}","Z"],["\u{1D586}","a"],["\u{1D587}","b"],["\u{1D588}","c"],["\u{1D589}","d"],["\u{1D58A}","e"],["\u{1D58B}","f"],["\u{1D58C}","g"],["\u{1D58D}","h"],["\u{1D58E}","i"],["\u{1D58F}","j"],["\u{1D590}","k"],["\u{1D591}","l"],["\u{1D592}","m"],["\u{1D593}","n"],["\u{1D594}","o"],["\u{1D595}","p"],["\u{1D596}","q"],["\u{1D597}","r"],["\u{1D598}","s"],["\u{1D599}","t"],["\u{1D59A}","u"],["\u{1D59B}","v"],["\u{1D59C}","w"],["\u{1D59D}","x"],["\u{1D59E}","y"],["\u{1D59F}","z"],["\u{1D5A0}","A"],["\u{1D5A1}","B"],["\u{1D5A2}","C"],["\u{1D5A3}","D"],["\u{1D5A4}","E"],["\u{1D5A5}","F"],["\u{1D5A6}","G"],["\u{1D5A7}","H"],["\u{1D5A8}","I"],["\u{1D5A9}","J"],["\u{1D5AA}","K"],["\u{1D5AB}","L"],["\u{1D5AC}","M"],["\u{1D5AD}","N"],["\u{1D5AE}","O"],["\u{1D5AF}","P"],["\u{1D5B0}","Q"],["\u{1D5B1}","R"],["\u{1D5B2}","S"],["\u{1D5B3}","T"],["\u{1D5B4}","U"],["\u{1D5B5}","V"],["\u{1D5B6}","W"],["\u{1D5B7}","X"],["\u{1D5B8}","Y"],["\u{1D5B9}","Z"],["\u{1D5BA}","a"],["\u{1D5BB}","b"],["\u{1D5BC}","c"],["\u{1D5BD}","d"],["\u{1D5BE}","e"],["\u{1D5BF}","f"],["\u{1D5C0}","g"],["\u{1D5C1}","h"],["\u{1D5C2}","i"],["\u{1D5C3}","j"],["\u{1D5C4}","k"],["\u{1D5C5}","l"],["\u{1D5C6}","m"],["\u{1D5C7}","n"],["\u{1D5C8}","o"],["\u{1D5C9}","p"],["\u{1D5CA}","q"],["\u{1D5CB}","r"],["\u{1D5CC}","s"],["\u{1D5CD}","t"],["\u{1D5CE}","u"],["\u{1D5CF}","v"],["\u{1D5D0}","w"],["\u{1D5D1}","x"],["\u{1D5D2}","y"],["\u{1D5D3}","z"],["\u{1D5D4}","A"],["\u{1D5D5}","B"],["\u{1D5D6}","C"],["\u{1D5D7}","D"],["\u{1D5D8}","E"],["\u{1D5D9}","F"],["\u{1D5DA}","G"],["\u{1D5DB}","H"],["\u{1D5DC}","I"],["\u{1D5DD}","J"],["\u{1D5DE}","K"],["\u{1D5DF}","L"],["\u{1D5E0}","M"],["\u{1D5E1}","N"],["\u{1D5E2}","O"],["\u{1D5E3}","P"],["\u{1D5E4}","Q"],["\u{1D5E5}","R"],["\u{1D5E6}","S"],["\u{1D5E7}","T"],["\u{1D5E8}","U"],["\u{1D5E9}","V"],["\u{1D5EA}","W"],["\u{1D5EB}","X"],["\u{1D5EC}","Y"],["\u{1D5ED}","Z"],["\u{1D5EE}","a"],["\u{1D5EF}","b"],["\u{1D5F0}","c"],["\u{1D5F1}","d"],["\u{1D5F2}","e"],["\u{1D5F3}","f"],["\u{1D5F4}","g"],["\u{1D5F5}","h"],["\u{1D5F6}","i"],["\u{1D5F7}","j"],["\u{1D5F8}","k"],["\u{1D5F9}","l"],["\u{1D5FA}","m"],["\u{1D5FB}","n"],["\u{1D5FC}","o"],["\u{1D5FD}","p"],["\u{1D5FE}","q"],["\u{1D5FF}","r"],["\u{1D600}","s"],["\u{1D601}","t"],["\u{1D602}","u"],["\u{1D603}","v"],["\u{1D604}","w"],["\u{1D605}","x"],["\u{1D606}","y"],["\u{1D607}","z"],["\u{1D608}","A"],["\u{1D609}","B"],["\u{1D60A}","C"],["\u{1D60B}","D"],["\u{1D60C}","E"],["\u{1D60D}","F"],["\u{1D60E}","G"],["\u{1D60F}","H"],["\u{1D610}","I"],["\u{1D611}","J"],["\u{1D612}","K"],["\u{1D613}","L"],["\u{1D614}","M"],["\u{1D615}","N"],["\u{1D616}","O"],["\u{1D617}","P"],["\u{1D618}","Q"],["\u{1D619}","R"],["\u{1D61A}","S"],["\u{1D61B}","T"],["\u{1D61C}","U"],["\u{1D61D}","V"],["\u{1D61E}","W"],["\u{1D61F}","X"],["\u{1D620}","Y"],["\u{1D621}","Z"],["\u{1D622}","a"],["\u{1D623}","b"],["\u{1D624}","c"],["\u{1D625}","d"],["\u{1D626}","e"],["\u{1D627}","f"],["\u{1D628}","g"],["\u{1D629}","h"],["\u{1D62A}","i"],["\u{1D62B}","j"],["\u{1D62C}","k"],["\u{1D62D}","l"],["\u{1D62E}","m"],["\u{1D62F}","n"],["\u{1D630}","o"],["\u{1D631}","p"],["\u{1D632}","q"],["\u{1D633}","r"],["\u{1D634}","s"],["\u{1D635}","t"],["\u{1D636}","u"],["\u{1D637}","v"],["\u{1D638}","w"],["\u{1D639}","x"],["\u{1D63A}","y"],["\u{1D63B}","z"],["\u{1D63C}","A"],["\u{1D63D}","B"],["\u{1D63E}","C"],["\u{1D63F}","D"],["\u{1D640}","E"],["\u{1D641}","F"],["\u{1D642}","G"],["\u{1D643}","H"],["\u{1D644}","I"],["\u{1D645}","J"],["\u{1D646}","K"],["\u{1D647}","L"],["\u{1D648}","M"],["\u{1D649}","N"],["\u{1D64A}","O"],["\u{1D64B}","P"],["\u{1D64C}","Q"],["\u{1D64D}","R"],["\u{1D64E}","S"],["\u{1D64F}","T"],["\u{1D650}","U"],["\u{1D651}","V"],["\u{1D652}","W"],["\u{1D653}","X"],["\u{1D654}","Y"],["\u{1D655}","Z"],["\u{1D656}","a"],["\u{1D657}","b"],["\u{1D658}","c"],["\u{1D659}","d"],["\u{1D65A}","e"],["\u{1D65B}","f"],["\u{1D65C}","g"],["\u{1D65D}","h"],["\u{1D65E}","i"],["\u{1D65F}","j"],["\u{1D660}","k"],["\u{1D661}","l"],["\u{1D662}","m"],["\u{1D663}","n"],["\u{1D664}","o"],["\u{1D665}","p"],["\u{1D666}","q"],["\u{1D667}","r"],["\u{1D668}","s"],["\u{1D669}","t"],["\u{1D66A}","u"],["\u{1D66B}","v"],["\u{1D66C}","w"],["\u{1D66D}","x"],["\u{1D66E}","y"],["\u{1D66F}","z"],["\u{1D670}","A"],["\u{1D671}","B"],["\u{1D672}","C"],["\u{1D673}","D"],["\u{1D674}","E"],["\u{1D675}","F"],["\u{1D676}","G"],["\u{1D677}","H"],["\u{1D678}","I"],["\u{1D679}","J"],["\u{1D67A}","K"],["\u{1D67B}","L"],["\u{1D67C}","M"],["\u{1D67D}","N"],["\u{1D67E}","O"],["\u{1D67F}","P"],["\u{1D680}","Q"],["\u{1D681}","R"],["\u{1D682}","S"],["\u{1D683}","T"],["\u{1D684}","U"],["\u{1D685}","V"],["\u{1D686}","W"],["\u{1D687}","X"],["\u{1D688}","Y"],["\u{1D689}","Z"],["\u{1D68A}","a"],["\u{1D68B}","b"],["\u{1D68C}","c"],["\u{1D68D}","d"],["\u{1D68E}","e"],["\u{1D68F}","f"],["\u{1D690}","g"],["\u{1D691}","h"],["\u{1D692}","i"],["\u{1D693}","j"],["\u{1D694}","k"],["\u{1D695}","l"],["\u{1D696}","m"],["\u{1D697}","n"],["\u{1D698}","o"],["\u{1D699}","p"],["\u{1D69A}","q"],["\u{1D69B}","r"],["\u{1D69C}","s"],["\u{1D69D}","t"],["\u{1D69E}","u"],["\u{1D69F}","v"],["\u{1D6A0}","w"],["\u{1D6A1}","x"],["\u{1D6A2}","y"],["\u{1D6A3}","z"],["\u{1D6A4}","l"],["\u{1D6A5}","j"],["\u{1D6E2}","A"],["\u{1D6E3}","B"],["\u{1D6E4}","G"],["\u{1D6E5}","D"],["\u{1D6E6}","E"],["\u{1D6E7}","Z"],["\u{1D6E8}","I"],["\u{1D6E9}","TH"],["\u{1D6EA}","I"],["\u{1D6EB}","K"],["\u{1D6EC}","L"],["\u{1D6ED}","M"],["\u{1D6EE}","N"],["\u{1D6EF}","KS"],["\u{1D6F0}","O"],["\u{1D6F1}","P"],["\u{1D6F2}","R"],["\u{1D6F3}","TH"],["\u{1D6F4}","S"],["\u{1D6F5}","T"],["\u{1D6F6}","Y"],["\u{1D6F7}","F"],["\u{1D6F8}","x"],["\u{1D6F9}","PS"],["\u{1D6FA}","O"],["\u{1D6FB}","D"],["\u{1D6FC}","a"],["\u{1D6FD}","b"],["\u{1D6FE}","g"],["\u{1D6FF}","d"],["\u{1D700}","e"],["\u{1D701}","z"],["\u{1D702}","i"],["\u{1D703}","th"],["\u{1D704}","i"],["\u{1D705}","k"],["\u{1D706}","l"],["\u{1D707}","m"],["\u{1D708}","n"],["\u{1D709}","ks"],["\u{1D70A}","o"],["\u{1D70B}","p"],["\u{1D70C}","r"],["\u{1D70D}","s"],["\u{1D70E}","s"],["\u{1D70F}","t"],["\u{1D710}","y"],["\u{1D711}","f"],["\u{1D712}","x"],["\u{1D713}","ps"],["\u{1D714}","o"],["\u{1D715}","d"],["\u{1D716}","E"],["\u{1D717}","TH"],["\u{1D718}","K"],["\u{1D719}","f"],["\u{1D71A}","r"],["\u{1D71B}","p"],["\u{1D71C}","A"],["\u{1D71D}","V"],["\u{1D71E}","G"],["\u{1D71F}","D"],["\u{1D720}","E"],["\u{1D721}","Z"],["\u{1D722}","I"],["\u{1D723}","TH"],["\u{1D724}","I"],["\u{1D725}","K"],["\u{1D726}","L"],["\u{1D727}","M"],["\u{1D728}","N"],["\u{1D729}","KS"],["\u{1D72A}","O"],["\u{1D72B}","P"],["\u{1D72C}","S"],["\u{1D72D}","TH"],["\u{1D72E}","S"],["\u{1D72F}","T"],["\u{1D730}","Y"],["\u{1D731}","F"],["\u{1D732}","X"],["\u{1D733}","PS"],["\u{1D734}","O"],["\u{1D735}","D"],["\u{1D736}","a"],["\u{1D737}","v"],["\u{1D738}","g"],["\u{1D739}","d"],["\u{1D73A}","e"],["\u{1D73B}","z"],["\u{1D73C}","i"],["\u{1D73D}","th"],["\u{1D73E}","i"],["\u{1D73F}","k"],["\u{1D740}","l"],["\u{1D741}","m"],["\u{1D742}","n"],["\u{1D743}","ks"],["\u{1D744}","o"],["\u{1D745}","p"],["\u{1D746}","r"],["\u{1D747}","s"],["\u{1D748}","s"],["\u{1D749}","t"],["\u{1D74A}","y"],["\u{1D74B}","f"],["\u{1D74C}","x"],["\u{1D74D}","ps"],["\u{1D74E}","o"],["\u{1D74F}","a"],["\u{1D750}","e"],["\u{1D751}","i"],["\u{1D752}","k"],["\u{1D753}","f"],["\u{1D754}","r"],["\u{1D755}","p"],["\u{1D756}","A"],["\u{1D757}","B"],["\u{1D758}","G"],["\u{1D759}","D"],["\u{1D75A}","E"],["\u{1D75B}","Z"],["\u{1D75C}","I"],["\u{1D75D}","TH"],["\u{1D75E}","I"],["\u{1D75F}","K"],["\u{1D760}","L"],["\u{1D761}","M"],["\u{1D762}","N"],["\u{1D763}","KS"],["\u{1D764}","O"],["\u{1D765}","P"],["\u{1D766}","R"],["\u{1D767}","TH"],["\u{1D768}","S"],["\u{1D769}","T"],["\u{1D76A}","Y"],["\u{1D76B}","F"],["\u{1D76C}","X"],["\u{1D76D}","PS"],["\u{1D76E}","O"],["\u{1D76F}","D"],["\u{1D770}","a"],["\u{1D771}","v"],["\u{1D772}","g"],["\u{1D773}","d"],["\u{1D774}","e"],["\u{1D775}","z"],["\u{1D776}","i"],["\u{1D777}","th"],["\u{1D778}","i"],["\u{1D779}","k"],["\u{1D77A}","l"],["\u{1D77B}","m"],["\u{1D77C}","n"],["\u{1D77D}","ks"],["\u{1D77E}","o"],["\u{1D77F}","p"],["\u{1D780}","r"],["\u{1D781}","s"],["\u{1D782}","s"],["\u{1D783}","t"],["\u{1D784}","y"],["\u{1D785}","f"],["\u{1D786}","x"],["\u{1D787}","ps"],["\u{1D788}","o"],["\u{1D789}","a"],["\u{1D78A}","e"],["\u{1D78B}","i"],["\u{1D78C}","k"],["\u{1D78D}","f"],["\u{1D78E}","r"],["\u{1D78F}","p"],["\u{1D790}","A"],["\u{1D791}","V"],["\u{1D792}","G"],["\u{1D793}","D"],["\u{1D794}","E"],["\u{1D795}","Z"],["\u{1D796}","I"],["\u{1D797}","TH"],["\u{1D798}","I"],["\u{1D799}","K"],["\u{1D79A}","L"],["\u{1D79B}","M"],["\u{1D79C}","N"],["\u{1D79D}","KS"],["\u{1D79E}","O"],["\u{1D79F}","P"],["\u{1D7A0}","S"],["\u{1D7A1}","TH"],["\u{1D7A2}","S"],["\u{1D7A3}","T"],["\u{1D7A4}","Y"],["\u{1D7A5}","F"],["\u{1D7A6}","X"],["\u{1D7A7}","PS"],["\u{1D7A8}","O"],["\u{1D7A9}","D"],["\u{1D7AA}","av"],["\u{1D7AB}","g"],["\u{1D7AC}","d"],["\u{1D7AD}","e"],["\u{1D7AE}","z"],["\u{1D7AF}","i"],["\u{1D7B0}","i"],["\u{1D7B1}","th"],["\u{1D7B2}","i"],["\u{1D7B3}","k"],["\u{1D7B4}","l"],["\u{1D7B5}","m"],["\u{1D7B6}","n"],["\u{1D7B7}","ks"],["\u{1D7B8}","o"],["\u{1D7B9}","p"],["\u{1D7BA}","r"],["\u{1D7BB}","s"],["\u{1D7BC}","s"],["\u{1D7BD}","t"],["\u{1D7BE}","y"],["\u{1D7BF}","f"],["\u{1D7C0}","x"],["\u{1D7C1}","ps"],["\u{1D7C2}","o"],["\u{1D7C3}","a"],["\u{1D7C4}","e"],["\u{1D7C5}","i"],["\u{1D7C6}","k"],["\u{1D7C7}","f"],["\u{1D7C8}","r"],["\u{1D7C9}","p"],["\u{1D7CA}","F"],["\u{1D7CB}","f"],["\u249C","(a)"],["\u249D","(b)"],["\u249E","(c)"],["\u249F","(d)"],["\u24A0","(e)"],["\u24A1","(f)"],["\u24A2","(g)"],["\u24A3","(h)"],["\u24A4","(i)"],["\u24A5","(j)"],["\u24A6","(k)"],["\u24A7","(l)"],["\u24A8","(m)"],["\u24A9","(n)"],["\u24AA","(o)"],["\u24AB","(p)"],["\u24AC","(q)"],["\u24AD","(r)"],["\u24AE","(s)"],["\u24AF","(t)"],["\u24B0","(u)"],["\u24B1","(v)"],["\u24B2","(w)"],["\u24B3","(x)"],["\u24B4","(y)"],["\u24B5","(z)"],["\u24B6","(A)"],["\u24B7","(B)"],["\u24B8","(C)"],["\u24B9","(D)"],["\u24BA","(E)"],["\u24BB","(F)"],["\u24BC","(G)"],["\u24BD","(H)"],["\u24BE","(I)"],["\u24BF","(J)"],["\u24C0","(K)"],["\u24C1","(L)"],["\u24C3","(N)"],["\u24C4","(O)"],["\u24C5","(P)"],["\u24C6","(Q)"],["\u24C7","(R)"],["\u24C8","(S)"],["\u24C9","(T)"],["\u24CA","(U)"],["\u24CB","(V)"],["\u24CC","(W)"],["\u24CD","(X)"],["\u24CE","(Y)"],["\u24CF","(Z)"],["\u24D0","(a)"],["\u24D1","(b)"],["\u24D2","(c)"],["\u24D3","(d)"],["\u24D4","(e)"],["\u24D5","(f)"],["\u24D6","(g)"],["\u24D7","(h)"],["\u24D8","(i)"],["\u24D9","(j)"],["\u24DA","(k)"],["\u24DB","(l)"],["\u24DC","(m)"],["\u24DD","(n)"],["\u24DE","(o)"],["\u24DF","(p)"],["\u24E0","(q)"],["\u24E1","(r)"],["\u24E2","(s)"],["\u24E3","(t)"],["\u24E4","(u)"],["\u24E5","(v)"],["\u24E6","(w)"],["\u24E7","(x)"],["\u24E8","(y)"],["\u24E9","(z)"],["\u010A","C"],["\u010B","c"],["\u0120","G"],["\u0121","g"],["\u0126","H"],["\u0127","h"],["\u017B","Z"],["\u017C","z"],["\u{1D7CE}","0"],["\u{1D7CF}","1"],["\u{1D7D0}","2"],["\u{1D7D1}","3"],["\u{1D7D2}","4"],["\u{1D7D3}","5"],["\u{1D7D4}","6"],["\u{1D7D5}","7"],["\u{1D7D6}","8"],["\u{1D7D7}","9"],["\u{1D7D8}","0"],["\u{1D7D9}","1"],["\u{1D7DA}","2"],["\u{1D7DB}","3"],["\u{1D7DC}","4"],["\u{1D7DD}","5"],["\u{1D7DE}","6"],["\u{1D7DF}","7"],["\u{1D7E0}","8"],["\u{1D7E1}","9"],["\u{1D7E2}","0"],["\u{1D7E3}","1"],["\u{1D7E4}","2"],["\u{1D7E5}","3"],["\u{1D7E6}","4"],["\u{1D7E7}","5"],["\u{1D7E8}","6"],["\u{1D7E9}","7"],["\u{1D7EA}","8"],["\u{1D7EB}","9"],["\u{1D7EC}","0"],["\u{1D7ED}","1"],["\u{1D7EE}","2"],["\u{1D7EF}","3"],["\u{1D7F0}","4"],["\u{1D7F1}","5"],["\u{1D7F2}","6"],["\u{1D7F3}","7"],["\u{1D7F4}","8"],["\u{1D7F5}","9"],["\u{1D7F6}","0"],["\u{1D7F7}","1"],["\u{1D7F8}","2"],["\u{1D7F9}","3"],["\u{1D7FA}","4"],["\u{1D7FB}","5"],["\u{1D7FC}","6"],["\u{1D7FD}","7"],["\u{1D7FE}","8"],["\u{1D7FF}","9"],["\u2460","1"],["\u2461","2"],["\u2462","3"],["\u2463","4"],["\u2464","5"],["\u2465","6"],["\u2466","7"],["\u2467","8"],["\u2468","9"],["\u2469","10"],["\u246A","11"],["\u246B","12"],["\u246C","13"],["\u246D","14"],["\u246E","15"],["\u246F","16"],["\u2470","17"],["\u2471","18"],["\u2472","19"],["\u2473","20"],["\u2474","1"],["\u2475","2"],["\u2476","3"],["\u2477","4"],["\u2478","5"],["\u2479","6"],["\u247A","7"],["\u247B","8"],["\u247C","9"],["\u247D","10"],["\u247E","11"],["\u247F","12"],["\u2480","13"],["\u2481","14"],["\u2482","15"],["\u2483","16"],["\u2484","17"],["\u2485","18"],["\u2486","19"],["\u2487","20"],["\u2488","1."],["\u2489","2."],["\u248A","3."],["\u248B","4."],["\u248C","5."],["\u248D","6."],["\u248E","7."],["\u248F","8."],["\u2490","9."],["\u2491","10."],["\u2492","11."],["\u2493","12."],["\u2494","13."],["\u2495","14."],["\u2496","15."],["\u2497","16."],["\u2498","17."],["\u2499","18."],["\u249A","19."],["\u249B","20."],["\u24EA","0"],["\u24EB","11"],["\u24EC","12"],["\u24ED","13"],["\u24EE","14"],["\u24EF","15"],["\u24F0","16"],["\u24F1","17"],["\u24F2","18"],["\u24F3","19"],["\u24F4","20"],["\u24F5","1"],["\u24F6","2"],["\u24F7","3"],["\u24F8","4"],["\u24F9","5"],["\u24FA","6"],["\u24FB","7"],["\u24FC","8"],["\u24FD","9"],["\u24FE","10"],["\u24FF","0"],["\u{1F670}","&"],["\u{1F671}","&"],["\u{1F672}","&"],["\u{1F673}","&"],["\u{1F674}","&"],["\u{1F675}","&"],["\u{1F676}",'"'],["\u{1F677}",'"'],["\u{1F678}",'"'],["\u203D","?!"],["\u{1F679}","?!"],["\u{1F67A}","?!"],["\u{1F67B}","?!"],["\u{1F67C}","/"],["\u{1F67D}","\\"],["\u{1F707}","AR"],["\u{1F708}","V"],["\u{1F709}","V"],["\u{1F706}","VR"],["\u{1F705}","VF"],["\u{1F729}","2"],["\u{1F72A}","5"],["\u{1F761}","f"],["\u{1F762}","W"],["\u{1F763}","U"],["\u{1F767}","V"],["\u{1F768}","T"],["\u{1F76A}","V"],["\u{1F76B}","MB"],["\u{1F76C}","VB"],["\u{1F772}","3B"],["\u{1F773}","3B"],["\u{1F4AF}","100"],["\u{1F519}","BACK"],["\u{1F51A}","END"],["\u{1F51B}","ON!"],["\u{1F51C}","SOON"],["\u{1F51D}","TOP"],["\u{1F51E}","18"],["\u{1F524}","abc"],["\u{1F520}","ABCD"],["\u{1F521}","abcd"],["\u{1F522}","1234"],["\u{1F523}","T&@%"],["#\uFE0F\u20E3","#"],["*\uFE0F\u20E3","*"],["0\uFE0F\u20E3","0"],["1\uFE0F\u20E3","1"],["2\uFE0F\u20E3","2"],["3\uFE0F\u20E3","3"],["4\uFE0F\u20E3","4"],["5\uFE0F\u20E3","5"],["6\uFE0F\u20E3","6"],["7\uFE0F\u20E3","7"],["8\uFE0F\u20E3","8"],["9\uFE0F\u20E3","9"],["\u{1F51F}","10"],["\u{1F170}\uFE0F","A"],["\u{1F171}\uFE0F","B"],["\u{1F18E}","AB"],["\u{1F191}","CL"],["\u{1F17E}\uFE0F","O"],["\u{1F17F}","P"],["\u{1F198}","SOS"],["\u{1F172}","C"],["\u{1F173}","D"],["\u{1F174}","E"],["\u{1F175}","F"],["\u{1F176}","G"],["\u{1F177}","H"],["\u{1F178}","I"],["\u{1F179}","J"],["\u{1F17A}","K"],["\u{1F17B}","L"],["\u{1F17C}","M"],["\u{1F17D}","N"],["\u{1F180}","Q"],["\u{1F181}","R"],["\u{1F182}","S"],["\u{1F183}","T"],["\u{1F184}","U"],["\u{1F185}","V"],["\u{1F186}","W"],["\u{1F187}","X"],["\u{1F188}","Y"],["\u{1F189}","Z"],["\u2212","-"],["\u2053","-"]],bC=new Map(yC),Wu=bC});var uy,Uo,Ku,dy=S(()=>{uy=[["\xE6","ae"],["\xC6","Ae"],["\xF8","oe"],["\xD8","Oe"],["\xE5","aa"],["\xC5","Aa"]],Uo={sv:[["\xE4","a"],["\xC4","A"],["\xF6","o"],["\xD6","O"],["\xE5","a"],["\xC5","A"]],da:uy,nb:uy,de:[["\xE4","ae"],["\xC4","Ae"],["\xF6","oe"],["\xD6","Oe"],["\xFC","ue"],["\xDC","Ue"],["\xDF","ss"],["\u1E9E","Ss"]],tr:[["\xE2","a"],["\xC2","A"],["\xF6","o"],["\xD6","O"],["\xFC","u"],["\xDC","U"]],hu:[["\u0171","u"],["\u0170","U"],["\xF6","o"],["\xD6","O"],["\xFC","u"],["\xDC","U"],["\xE1","a"],["\xC1","A"],["\xE9","e"],["\xC9","E"],["\xED","i"],["\xCD","I"],["\xF3","o"],["\xD3","O"],["\xFA","u"],["\xDA","U"]],sr:[["\u0452","dj"],["\u0402","Dj"],["\u045F","dz"],["\u040F","Dz"],["\u0459","lj"],["\u0409","Lj"],["\u045A","nj"],["\u040A","Nj"],["\u045B","c"],["\u040B","C"],["\u0447","ch"],["\u0427","Ch"],["\u0448","sh"],["\u0428","Sh"],["\u0436","zh"],["\u0416","Zh"]]};for(let t of Object.keys(Uo))Uo[t]=new Map(Uo[t]);Ku=Uo});function Hu(t,e){if(typeof t!="string")throw new TypeError(`Expected a string, got \`${typeof t}\``);e={customReplacements:[],...e};let n=vC(e.locale),r=Wu,s=e.customReplacements.length>0||e.customReplacements.size>0;if(n||s){if(r=new Map(Wu),n)for(let[i,o]of n)r.set(i,o);for(let[i,o]of e.customReplacements)r.set(i,o)}return t=t.normalize(),t=wC(t,r),t=t.normalize("NFD").replaceAll(/\p{Diacritic}/gu,"").normalize(),t=t.replaceAll(/\p{Dash_Punctuation}/gu,"-"),t}var wC,vC,fy=S(()=>{cy();dy();wC=(t,e)=>{for(let[n,r]of e)t=t.replaceAll(n,r);return t},vC=t=>{if(!t)return;let e=t.toLowerCase().replace(/^no(-|$)/,"nb$1");return Ku[e]||Ku[e.split("-")[0]]||void 0}});var SC,py,hy=S(()=>{SC=[["&"," and "],["\u{1F984}"," unicorn "],["\u2665"," love "]],py=SC});function zu(t,e){if(typeof t!="string")throw new TypeError(`Expected a string, got \`${typeof t}\``);e={separator:"-",lowercase:!0,decamelize:!0,customReplacements:[],preserveLeadingUnderscore:!1,preserveTrailingDash:!1,preserveCharacters:[],transliterate:!0,...e};let n=e.preserveLeadingUnderscore&&t.startsWith("_"),r=e.preserveTrailingDash&&t.endsWith("-");if(e.transliterate){let i=new Map([...py,...e.customReplacements]);t=Hu(t,{customReplacements:i,locale:e.locale})}else if(e.customReplacements.length>0)for(let[i,o]of e.customReplacements)t=t.replaceAll(i,o);e.decamelize&&(t=kC(t));let s=EC(e);return e.lowercase&&(t=e.locale?t.toLocaleLowerCase(e.locale):t.toLowerCase()),t=t.replaceAll(/([a-zA-Z\d]+)['\u2019]([ts])(\s|$)/g,"$1$2$3"),t=t.replace(s,e.separator),t=t.replaceAll("\\",""),e.separator&&(t=xC(t,e.separator)),n&&(t=`_${t}`),r&&(t=`${t}-`),t}var kC,xC,EC,my=S(()=>{ly();fy();hy();kC=t=>t.replaceAll(/([A-Z]{2,})(\d+)/g,"$1 $2").replaceAll(/([a-z\d]+)([A-Z]{2,})/g,"$1 $2").replaceAll(/([a-z\d])([A-Z])/g,"$1 $2").replaceAll(/([A-Z]+)([A-Z][a-rt-z\d]+)/g,"$1 $2"),xC=(t,e)=>{let n=Fo(e);return t.replaceAll(new RegExp(`(?:${n}){2,}`,"g"),e).replaceAll(new RegExp(`^(?:${n})|(?:${n})$`,"g"),"")},EC=t=>{let e=String.raw`a-z\d`;if(e+=t.lowercase?"":"A-Z",t.transliterate===!1&&(e+=String.raw`\p{L}\p{N}`),t.preserveCharacters.length>0)for(let r of t.preserveCharacters){if(r===t.separator)throw new Error(`The separator character \`${t.separator}\` cannot be included in preserved characters: ${t.preserveCharacters}`);e+=Fo(r)}let n=t.transliterate?"g":"gu";return new RegExp(`[^${e}]+`,n)}});function nr(t){return zu(t)}var gy=S(()=>{my()});var rr,yy,by=S(()=>{rr={local:"local",ide:"ide",published:"published",inline:"inline"},yy=Object.values(rr).map(t=>`'${t}'`).join(" | ")});var Os,Yu,wy=S(()=>{Os=` *, *::before, *::after { box-sizing: border-box; }
169
+ `});function zo(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var by=k(()=>{});var WC,KC,Gu,wy=k(()=>{WC=[["\xDF","ss"],["\u1E9E","Ss"],["\xE4","ae"],["\xC4","Ae"],["\xF6","oe"],["\xD6","Oe"],["\xFC","ue"],["\xDC","Ue"],["\xC0","A"],["\xC1","A"],["\xC2","A"],["\xC3","A"],["\xC4","Ae"],["\xC5","A"],["\xC6","AE"],["\xC7","C"],["\xC8","E"],["\xC9","E"],["\xCA","E"],["\xCB","E"],["\u018F","A"],["\xCC","I"],["\xCD","I"],["\xCE","I"],["\xCF","I"],["\xD0","D"],["\xD1","N"],["\xD2","O"],["\xD3","O"],["\xD4","O"],["\xD5","O"],["\xD6","Oe"],["\u014C","O"],["\u0150","O"],["\xD8","O"],["\u0152","OE"],["\xD9","U"],["\xDA","U"],["\xDB","U"],["\xDC","Ue"],["\u0170","U"],["\xDD","Y"],["\xDE","TH"],["\xDF","ss"],["\xE0","a"],["\xE1","a"],["\xE2","a"],["\xE3","a"],["\xE4","ae"],["\xE5","a"],["\xE6","ae"],["\xE7","c"],["\xE8","e"],["\xE9","e"],["\xEA","e"],["\xEB","e"],["\u0259","a"],["\xEC","i"],["\xED","i"],["\xEE","i"],["\xEF","i"],["\xF0","d"],["\xF1","n"],["\xF2","o"],["\xF3","o"],["\xF4","o"],["\xF5","o"],["\xF6","oe"],["\u014D","o"],["\u0151","o"],["\xF8","o"],["\u0153","oe"],["\xF9","u"],["\xFA","u"],["\xFB","u"],["\xFC","ue"],["\u0171","u"],["\xFD","y"],["\xFE","th"],["\xFF","y"],["\xE0","a"],["\xC0","A"],["\xE1","a"],["\xC1","A"],["\xE2","a"],["\xC2","A"],["\xE3","a"],["\xC3","A"],["\xE8","e"],["\xC8","E"],["\xE9","e"],["\xC9","E"],["\xEA","e"],["\xCA","E"],["\xEC","i"],["\xCC","I"],["\xED","i"],["\xCD","I"],["\xF2","o"],["\xD2","O"],["\xF3","o"],["\xD3","O"],["\xF4","o"],["\xD4","O"],["\xF5","o"],["\xD5","O"],["\xF9","u"],["\xD9","U"],["\xFA","u"],["\xDA","U"],["\xFD","y"],["\xDD","Y"],["\u0103","a"],["\u0102","A"],["\u0110","D"],["\u0111","d"],["\u0129","i"],["\u0128","I"],["\u0169","u"],["\u0168","U"],["\u01A1","o"],["\u01A0","O"],["\u01B0","u"],["\u01AF","U"],["\u1EA1","a"],["\u1EA0","A"],["\u1EA3","a"],["\u1EA2","A"],["\u1EA5","a"],["\u1EA4","A"],["\u1EA7","a"],["\u1EA6","A"],["\u1EA9","a"],["\u1EA8","A"],["\u1EAB","a"],["\u1EAA","A"],["\u1EAD","a"],["\u1EAC","A"],["\u1EAF","a"],["\u1EAE","A"],["\u1EB1","a"],["\u1EB0","A"],["\u1EB3","a"],["\u1EB2","A"],["\u1EB5","a"],["\u1EB4","A"],["\u1EB7","a"],["\u1EB6","A"],["\u1EB9","e"],["\u1EB8","E"],["\u1EBB","e"],["\u1EBA","E"],["\u1EBD","e"],["\u1EBC","E"],["\u1EBF","e"],["\u1EBE","E"],["\u1EC1","e"],["\u1EC0","E"],["\u1EC3","e"],["\u1EC2","E"],["\u1EC5","e"],["\u1EC4","E"],["\u1EC7","e"],["\u1EC6","E"],["\u1EC9","i"],["\u1EC8","I"],["\u1ECB","i"],["\u1ECA","I"],["\u1ECD","o"],["\u1ECC","O"],["\u1ECF","o"],["\u1ECE","O"],["\u1ED1","o"],["\u1ED0","O"],["\u1ED3","o"],["\u1ED2","O"],["\u1ED5","o"],["\u1ED4","O"],["\u1ED7","o"],["\u1ED6","O"],["\u1ED9","o"],["\u1ED8","O"],["\u1EDB","o"],["\u1EDA","O"],["\u1EDD","o"],["\u1EDC","O"],["\u1EDF","o"],["\u1EDE","O"],["\u1EE1","o"],["\u1EE0","O"],["\u1EE3","o"],["\u1EE2","O"],["\u1EE5","u"],["\u1EE4","U"],["\u1EE7","u"],["\u1EE6","U"],["\u1EE9","u"],["\u1EE8","U"],["\u1EEB","u"],["\u1EEA","U"],["\u1EED","u"],["\u1EEC","U"],["\u1EEF","u"],["\u1EEE","U"],["\u1EF1","u"],["\u1EF0","U"],["\u1EF3","y"],["\u1EF2","Y"],["\u1EF5","y"],["\u1EF4","Y"],["\u1EF7","y"],["\u1EF6","Y"],["\u1EF9","y"],["\u1EF8","Y"],["\u0621","e"],["\u0622","a"],["\u0623","a"],["\u0624","w"],["\u0625","a"],["\u0626","y"],["\u0627","a"],["\u0628","b"],["\u0629","t"],["\u062A","t"],["\u062B","th"],["\u062C","j"],["\u062D","h"],["\u062E","kh"],["\u062F","d"],["\u0630","dh"],["\u0631","r"],["\u0632","z"],["\u0633","s"],["\u0634","sh"],["\u0635","s"],["\u0636","d"],["\u0637","t"],["\u0638","z"],["\u0639","e"],["\u063A","gh"],["\u0640","_"],["\u0641","f"],["\u0642","q"],["\u0643","k"],["\u0644","l"],["\u0645","m"],["\u0646","n"],["\u0647","h"],["\u0648","w"],["\u0649","a"],["\u064A","y"],["\u064E\u200E","a"],["\u064F","u"],["\u0650\u200E","i"],["\u0660","0"],["\u0661","1"],["\u0662","2"],["\u0663","3"],["\u0664","4"],["\u0665","5"],["\u0666","6"],["\u0667","7"],["\u0668","8"],["\u0669","9"],["\u0686","ch"],["\u06A9","k"],["\u06AF","g"],["\u067E","p"],["\u0698","zh"],["\u06CC","y"],["\u06F0","0"],["\u06F1","1"],["\u06F2","2"],["\u06F3","3"],["\u06F4","4"],["\u06F5","5"],["\u06F6","6"],["\u06F7","7"],["\u06F8","8"],["\u06F9","9"],["\u067C","p"],["\u0681","z"],["\u0685","c"],["\u0689","d"],["\uFEAB","d"],["\uFEAD","r"],["\u0693","r"],["\uFEAF","z"],["\u0696","g"],["\u069A","x"],["\u06AB","g"],["\u06BC","n"],["\u06C0","e"],["\u06D0","e"],["\u06CD","ai"],["\u0679","t"],["\u0688","d"],["\u0691","r"],["\u06BA","n"],["\u06C1","h"],["\u06BE","h"],["\u06D2","e"],["\u0410","A"],["\u0430","a"],["\u0411","B"],["\u0431","b"],["\u0412","V"],["\u0432","v"],["\u0413","G"],["\u0433","g"],["\u0414","D"],["\u0434","d"],["\u044A\u0435","ye"],["\u042A\u0435","Ye"],["\u044A\u0415","yE"],["\u042A\u0415","YE"],["\u0415","E"],["\u0435","e"],["\u0401","Yo"],["\u0451","yo"],["\u0416","Zh"],["\u0436","zh"],["\u0417","Z"],["\u0437","z"],["\u0418","I"],["\u0438","i"],["\u044B\u0439","iy"],["\u042B\u0439","Iy"],["\u042B\u0419","IY"],["\u044B\u0419","iY"],["\u0419","Y"],["\u0439","y"],["\u041A","K"],["\u043A","k"],["\u041B","L"],["\u043B","l"],["\u041C","M"],["\u043C","m"],["\u041D","N"],["\u043D","n"],["\u041E","O"],["\u043E","o"],["\u041F","P"],["\u043F","p"],["\u0420","R"],["\u0440","r"],["\u0421","S"],["\u0441","s"],["\u0422","T"],["\u0442","t"],["\u0423","U"],["\u0443","u"],["\u0424","F"],["\u0444","f"],["\u0425","Kh"],["\u0445","kh"],["\u0426","Ts"],["\u0446","ts"],["\u0427","Ch"],["\u0447","ch"],["\u0428","Sh"],["\u0448","sh"],["\u0429","Sch"],["\u0449","sch"],["\u042A",""],["\u044A",""],["\u042B","Y"],["\u044B","y"],["\u042C",""],["\u044C",""],["\u042D","E"],["\u044D","e"],["\u042E","Yu"],["\u044E","yu"],["\u042F","Ya"],["\u044F","ya"],["\u0103","a"],["\u0102","A"],["\u0219","s"],["\u0218","S"],["\u021B","t"],["\u021A","T"],["\u0163","t"],["\u0162","T"],["\u015F","s"],["\u015E","S"],["\xE7","c"],["\xC7","C"],["\u011F","g"],["\u011E","G"],["\u0131","i"],["\u0130","I"],["\u0561","a"],["\u0531","A"],["\u0562","b"],["\u0532","B"],["\u0563","g"],["\u0533","G"],["\u0564","d"],["\u0534","D"],["\u0565","ye"],["\u0535","Ye"],["\u0566","z"],["\u0536","Z"],["\u0567","e"],["\u0537","E"],["\u0568","y"],["\u0538","Y"],["\u0569","t"],["\u0539","T"],["\u056A","zh"],["\u053A","Zh"],["\u056B","i"],["\u053B","I"],["\u056C","l"],["\u053C","L"],["\u056D","kh"],["\u053D","Kh"],["\u056E","ts"],["\u053E","Ts"],["\u056F","k"],["\u053F","K"],["\u0570","h"],["\u0540","H"],["\u0571","dz"],["\u0541","Dz"],["\u0572","gh"],["\u0542","Gh"],["\u0573","tch"],["\u0543","Tch"],["\u0574","m"],["\u0544","M"],["\u0575","y"],["\u0545","Y"],["\u0576","n"],["\u0546","N"],["\u0577","sh"],["\u0547","Sh"],["\u0578\u0582","u"],["\u0548\u0552","U"],["\u0548\u0582","U"],["\u0578","vo"],["\u0548","Vo"],["\u0579","ch"],["\u0549","Ch"],["\u057A","p"],["\u054A","P"],["\u057B","j"],["\u054B","J"],["\u057C","r"],["\u054C","R"],["\u057D","s"],["\u054D","S"],["\u057E","v"],["\u054E","V"],["\u057F","t"],["\u054F","T"],["\u0580","r"],["\u0550","R"],["\u0581","c"],["\u0551","C"],["\u0583","p"],["\u0553","P"],["\u0584","q"],["\u0554","Q"],["\u0585","o"],["\u0555","O"],["\u0586","f"],["\u0556","F"],["\u0587","yev"],["\u10D0","a"],["\u10D1","b"],["\u10D2","g"],["\u10D3","d"],["\u10D4","e"],["\u10D5","v"],["\u10D6","z"],["\u10D7","t"],["\u10D8","i"],["\u10D9","k"],["\u10DA","l"],["\u10DB","m"],["\u10DC","n"],["\u10DD","o"],["\u10DE","p"],["\u10DF","zh"],["\u10E0","r"],["\u10E1","s"],["\u10E2","t"],["\u10E3","u"],["\u10E4","ph"],["\u10E5","q"],["\u10E6","gh"],["\u10E7","k"],["\u10E8","sh"],["\u10E9","ch"],["\u10EA","ts"],["\u10EB","dz"],["\u10EC","ts"],["\u10ED","tch"],["\u10EE","kh"],["\u10EF","j"],["\u10F0","h"],["\u010D","c"],["\u010F","d"],["\u011B","e"],["\u0148","n"],["\u0159","r"],["\u0161","s"],["\u0165","t"],["\u016F","u"],["\u017E","z"],["\u010C","C"],["\u010E","D"],["\u011A","E"],["\u0147","N"],["\u0158","R"],["\u0160","S"],["\u0164","T"],["\u016E","U"],["\u017D","Z"],["\u0780","h"],["\u0781","sh"],["\u0782","n"],["\u0783","r"],["\u0784","b"],["\u0785","lh"],["\u0786","k"],["\u0787","a"],["\u0788","v"],["\u0789","m"],["\u078A","f"],["\u078B","dh"],["\u078C","th"],["\u078D","l"],["\u078E","g"],["\u078F","gn"],["\u0790","s"],["\u0791","d"],["\u0792","z"],["\u0793","t"],["\u0794","y"],["\u0795","p"],["\u0796","j"],["\u0797","ch"],["\u0798","tt"],["\u0799","hh"],["\u079A","kh"],["\u079B","th"],["\u079C","z"],["\u079D","sh"],["\u079E","s"],["\u079F","d"],["\u07A0","t"],["\u07A1","z"],["\u07A2","a"],["\u07A3","gh"],["\u07A4","q"],["\u07A5","w"],["\u07A6","a"],["\u07A7","aa"],["\u07A8","i"],["\u07A9","ee"],["\u07AA","u"],["\u07AB","oo"],["\u07AC","e"],["\u07AD","ey"],["\u07AE","o"],["\u07AF","oa"],["\u07B0",""],["\u03B1","a"],["\u03B2","v"],["\u03B3","g"],["\u03B4","d"],["\u03B5","e"],["\u03B6","z"],["\u03B7","i"],["\u03B8","th"],["\u03B9","i"],["\u03BA","k"],["\u03BB","l"],["\u03BC","m"],["\u03BD","n"],["\u03BE","ks"],["\u03BF","o"],["\u03C0","p"],["\u03C1","r"],["\u03C3","s"],["\u03C4","t"],["\u03C5","y"],["\u03C6","f"],["\u03C7","x"],["\u03C8","ps"],["\u03C9","o"],["\u03AC","a"],["\u03AD","e"],["\u03AF","i"],["\u03CC","o"],["\u03CD","y"],["\u03AE","i"],["\u03CE","o"],["\u03C2","s"],["\u03CA","i"],["\u03B0","y"],["\u03CB","y"],["\u0390","i"],["\u0391","A"],["\u0392","B"],["\u0393","G"],["\u0394","D"],["\u0395","E"],["\u0396","Z"],["\u0397","I"],["\u0398","TH"],["\u0399","I"],["\u039A","K"],["\u039B","L"],["\u039C","M"],["\u039D","N"],["\u039E","KS"],["\u039F","O"],["\u03A0","P"],["\u03A1","R"],["\u03A3","S"],["\u03A4","T"],["\u03A5","Y"],["\u03A6","F"],["\u03A7","X"],["\u03A8","PS"],["\u03A9","O"],["\u0386","A"],["\u0388","E"],["\u038A","I"],["\u038C","O"],["\u038E","Y"],["\u0389","I"],["\u038F","O"],["\u03AA","I"],["\u03AB","Y"],["\u0101","a"],["\u0113","e"],["\u0123","g"],["\u012B","i"],["\u0137","k"],["\u013C","l"],["\u0146","n"],["\u016B","u"],["\u0100","A"],["\u0112","E"],["\u0122","G"],["\u012A","I"],["\u0136","K"],["\u013B","L"],["\u0145","N"],["\u016A","U"],["\u010D","c"],["\u0161","s"],["\u017E","z"],["\u010C","C"],["\u0160","S"],["\u017D","Z"],["\u0105","a"],["\u010D","c"],["\u0119","e"],["\u0117","e"],["\u012F","i"],["\u0161","s"],["\u0173","u"],["\u016B","u"],["\u017E","z"],["\u0104","A"],["\u010C","C"],["\u0118","E"],["\u0116","E"],["\u012E","I"],["\u0160","S"],["\u0172","U"],["\u016A","U"],["\u040C","Kj"],["\u045C","kj"],["\u0409","Lj"],["\u0459","lj"],["\u040A","Nj"],["\u045A","nj"],["\u0422\u0441","Ts"],["\u0442\u0441","ts"],["\u0105","a"],["\u0107","c"],["\u0119","e"],["\u0142","l"],["\u0144","n"],["\u015B","s"],["\u017A","z"],["\u017C","z"],["\u0104","A"],["\u0106","C"],["\u0118","E"],["\u0141","L"],["\u0143","N"],["\u015A","S"],["\u0179","Z"],["\u017B","Z"],["\u0404","Ye"],["\u0406","I"],["\u0407","Yi"],["\u0490","G"],["\u0454","ye"],["\u0456","i"],["\u0457","yi"],["\u0491","g"],["\u0132","IJ"],["\u0133","ij"],["\xA2","c"],["\xA5","Y"],["\u07FF","b"],["\u09F3","t"],["\u0AF1","Bo"],["\u0E3F","B"],["\u20A0","CE"],["\u20A1","C"],["\u20A2","Cr"],["\u20A3","F"],["\u20A5","m"],["\u20A6","N"],["\u20A7","Pt"],["\u20A8","Rs"],["\u20A9","W"],["\u20AB","s"],["\u20AC","E"],["\u20AD","K"],["\u20AE","T"],["\u20AF","Dp"],["\u20B0","S"],["\u20B1","P"],["\u20B2","G"],["\u20B3","A"],["\u20B4","S"],["\u20B5","C"],["\u20B6","tt"],["\u20B7","S"],["\u20B8","T"],["\u20B9","R"],["\u20BA","L"],["\u20BD","P"],["\u20BF","B"],["\uFE69","$"],["\uFFE0","c"],["\uFFE5","Y"],["\uFFE6","W"],["\u{1D400}","A"],["\u{1D401}","B"],["\u{1D402}","C"],["\u{1D403}","D"],["\u{1D404}","E"],["\u{1D405}","F"],["\u{1D406}","G"],["\u{1D407}","H"],["\u{1D408}","I"],["\u{1D409}","J"],["\u{1D40A}","K"],["\u{1D40B}","L"],["\u{1D40C}","M"],["\u{1D40D}","N"],["\u{1D40E}","O"],["\u{1D40F}","P"],["\u{1D410}","Q"],["\u{1D411}","R"],["\u{1D412}","S"],["\u{1D413}","T"],["\u{1D414}","U"],["\u{1D415}","V"],["\u{1D416}","W"],["\u{1D417}","X"],["\u{1D418}","Y"],["\u{1D419}","Z"],["\u{1D41A}","a"],["\u{1D41B}","b"],["\u{1D41C}","c"],["\u{1D41D}","d"],["\u{1D41E}","e"],["\u{1D41F}","f"],["\u{1D420}","g"],["\u{1D421}","h"],["\u{1D422}","i"],["\u{1D423}","j"],["\u{1D424}","k"],["\u{1D425}","l"],["\u{1D426}","m"],["\u{1D427}","n"],["\u{1D428}","o"],["\u{1D429}","p"],["\u{1D42A}","q"],["\u{1D42B}","r"],["\u{1D42C}","s"],["\u{1D42D}","t"],["\u{1D42E}","u"],["\u{1D42F}","v"],["\u{1D430}","w"],["\u{1D431}","x"],["\u{1D432}","y"],["\u{1D433}","z"],["\u{1D434}","A"],["\u{1D435}","B"],["\u{1D436}","C"],["\u{1D437}","D"],["\u{1D438}","E"],["\u{1D439}","F"],["\u{1D43A}","G"],["\u{1D43B}","H"],["\u{1D43C}","I"],["\u{1D43D}","J"],["\u{1D43E}","K"],["\u{1D43F}","L"],["\u{1D440}","M"],["\u{1D441}","N"],["\u{1D442}","O"],["\u{1D443}","P"],["\u{1D444}","Q"],["\u{1D445}","R"],["\u{1D446}","S"],["\u{1D447}","T"],["\u{1D448}","U"],["\u{1D449}","V"],["\u{1D44A}","W"],["\u{1D44B}","X"],["\u{1D44C}","Y"],["\u{1D44D}","Z"],["\u{1D44E}","a"],["\u{1D44F}","b"],["\u{1D450}","c"],["\u{1D451}","d"],["\u{1D452}","e"],["\u{1D453}","f"],["\u{1D454}","g"],["\u{1D456}","i"],["\u{1D457}","j"],["\u{1D458}","k"],["\u{1D459}","l"],["\u{1D45A}","m"],["\u{1D45B}","n"],["\u{1D45C}","o"],["\u{1D45D}","p"],["\u{1D45E}","q"],["\u{1D45F}","r"],["\u{1D460}","s"],["\u{1D461}","t"],["\u{1D462}","u"],["\u{1D463}","v"],["\u{1D464}","w"],["\u{1D465}","x"],["\u{1D466}","y"],["\u{1D467}","z"],["\u{1D468}","A"],["\u{1D469}","B"],["\u{1D46A}","C"],["\u{1D46B}","D"],["\u{1D46C}","E"],["\u{1D46D}","F"],["\u{1D46E}","G"],["\u{1D46F}","H"],["\u{1D470}","I"],["\u{1D471}","J"],["\u{1D472}","K"],["\u{1D473}","L"],["\u{1D474}","M"],["\u{1D475}","N"],["\u{1D476}","O"],["\u{1D477}","P"],["\u{1D478}","Q"],["\u{1D479}","R"],["\u{1D47A}","S"],["\u{1D47B}","T"],["\u{1D47C}","U"],["\u{1D47D}","V"],["\u{1D47E}","W"],["\u{1D47F}","X"],["\u{1D480}","Y"],["\u{1D481}","Z"],["\u{1D482}","a"],["\u{1D483}","b"],["\u{1D484}","c"],["\u{1D485}","d"],["\u{1D486}","e"],["\u{1D487}","f"],["\u{1D488}","g"],["\u{1D489}","h"],["\u{1D48A}","i"],["\u{1D48B}","j"],["\u{1D48C}","k"],["\u{1D48D}","l"],["\u{1D48E}","m"],["\u{1D48F}","n"],["\u{1D490}","o"],["\u{1D491}","p"],["\u{1D492}","q"],["\u{1D493}","r"],["\u{1D494}","s"],["\u{1D495}","t"],["\u{1D496}","u"],["\u{1D497}","v"],["\u{1D498}","w"],["\u{1D499}","x"],["\u{1D49A}","y"],["\u{1D49B}","z"],["\u{1D49C}","A"],["\u{1D49E}","C"],["\u{1D49F}","D"],["\u{1D4A2}","g"],["\u{1D4A5}","J"],["\u{1D4A6}","K"],["\u{1D4A9}","N"],["\u{1D4AA}","O"],["\u{1D4AB}","P"],["\u{1D4AC}","Q"],["\u{1D4AE}","S"],["\u{1D4AF}","T"],["\u{1D4B0}","U"],["\u{1D4B1}","V"],["\u{1D4B2}","W"],["\u{1D4B3}","X"],["\u{1D4B4}","Y"],["\u{1D4B5}","Z"],["\u{1D4B6}","a"],["\u{1D4B7}","b"],["\u{1D4B8}","c"],["\u{1D4B9}","d"],["\u{1D4BB}","f"],["\u{1D4BD}","h"],["\u{1D4BE}","i"],["\u{1D4BF}","j"],["\u{1D4C0}","k"],["\u{1D4C1}","l"],["\u{1D4C2}","m"],["\u{1D4C3}","n"],["\u{1D4C5}","p"],["\u{1D4C6}","q"],["\u{1D4C7}","r"],["\u{1D4C8}","s"],["\u{1D4C9}","t"],["\u{1D4CA}","u"],["\u{1D4CB}","v"],["\u{1D4CC}","w"],["\u{1D4CD}","x"],["\u{1D4CE}","y"],["\u{1D4CF}","z"],["\u{1D4D0}","A"],["\u{1D4D1}","B"],["\u{1D4D2}","C"],["\u{1D4D3}","D"],["\u{1D4D4}","E"],["\u{1D4D5}","F"],["\u{1D4D6}","G"],["\u{1D4D7}","H"],["\u{1D4D8}","I"],["\u{1D4D9}","J"],["\u{1D4DA}","K"],["\u{1D4DB}","L"],["\u{1D4DC}","M"],["\u{1D4DD}","N"],["\u{1D4DE}","O"],["\u{1D4DF}","P"],["\u{1D4E0}","Q"],["\u{1D4E1}","R"],["\u{1D4E2}","S"],["\u{1D4E3}","T"],["\u{1D4E4}","U"],["\u{1D4E5}","V"],["\u{1D4E6}","W"],["\u{1D4E7}","X"],["\u{1D4E8}","Y"],["\u{1D4E9}","Z"],["\u{1D4EA}","a"],["\u{1D4EB}","b"],["\u{1D4EC}","c"],["\u{1D4ED}","d"],["\u{1D4EE}","e"],["\u{1D4EF}","f"],["\u{1D4F0}","g"],["\u{1D4F1}","h"],["\u{1D4F2}","i"],["\u{1D4F3}","j"],["\u{1D4F4}","k"],["\u{1D4F5}","l"],["\u{1D4F6}","m"],["\u{1D4F7}","n"],["\u{1D4F8}","o"],["\u{1D4F9}","p"],["\u{1D4FA}","q"],["\u{1D4FB}","r"],["\u{1D4FC}","s"],["\u{1D4FD}","t"],["\u{1D4FE}","u"],["\u{1D4FF}","v"],["\u{1D500}","w"],["\u{1D501}","x"],["\u{1D502}","y"],["\u{1D503}","z"],["\u{1D504}","A"],["\u{1D505}","B"],["\u{1D507}","D"],["\u{1D508}","E"],["\u{1D509}","F"],["\u{1D50A}","G"],["\u{1D50D}","J"],["\u{1D50E}","K"],["\u{1D50F}","L"],["\u{1D510}","M"],["\u{1D511}","N"],["\u{1D512}","O"],["\u{1D513}","P"],["\u{1D514}","Q"],["\u{1D516}","S"],["\u{1D517}","T"],["\u{1D518}","U"],["\u{1D519}","V"],["\u{1D51A}","W"],["\u{1D51B}","X"],["\u{1D51C}","Y"],["\u{1D51E}","a"],["\u{1D51F}","b"],["\u{1D520}","c"],["\u{1D521}","d"],["\u{1D522}","e"],["\u{1D523}","f"],["\u{1D524}","g"],["\u{1D525}","h"],["\u{1D526}","i"],["\u{1D527}","j"],["\u{1D528}","k"],["\u{1D529}","l"],["\u{1D52A}","m"],["\u{1D52B}","n"],["\u{1D52C}","o"],["\u{1D52D}","p"],["\u{1D52E}","q"],["\u{1D52F}","r"],["\u{1D530}","s"],["\u{1D531}","t"],["\u{1D532}","u"],["\u{1D533}","v"],["\u{1D534}","w"],["\u{1D535}","x"],["\u{1D536}","y"],["\u{1D537}","z"],["\u{1D538}","A"],["\u{1D539}","B"],["\u{1D53B}","D"],["\u{1D53C}","E"],["\u{1D53D}","F"],["\u{1D53E}","G"],["\u{1D540}","I"],["\u{1D541}","J"],["\u{1D542}","K"],["\u{1D543}","L"],["\u{1D544}","M"],["\u{1D546}","O"],["\u{1D54A}","S"],["\u{1D54B}","T"],["\u{1D54C}","U"],["\u{1D54D}","V"],["\u{1D54E}","W"],["\u{1D54F}","X"],["\u{1D550}","Y"],["\u{1D552}","a"],["\u{1D553}","b"],["\u{1D554}","c"],["\u{1D555}","d"],["\u{1D556}","e"],["\u{1D557}","f"],["\u{1D558}","g"],["\u{1D559}","h"],["\u{1D55A}","i"],["\u{1D55B}","j"],["\u{1D55C}","k"],["\u{1D55D}","l"],["\u{1D55E}","m"],["\u{1D55F}","n"],["\u{1D560}","o"],["\u{1D561}","p"],["\u{1D562}","q"],["\u{1D563}","r"],["\u{1D564}","s"],["\u{1D565}","t"],["\u{1D566}","u"],["\u{1D567}","v"],["\u{1D568}","w"],["\u{1D569}","x"],["\u{1D56A}","y"],["\u{1D56B}","z"],["\u{1D56C}","A"],["\u{1D56D}","B"],["\u{1D56E}","C"],["\u{1D56F}","D"],["\u{1D570}","E"],["\u{1D571}","F"],["\u{1D572}","G"],["\u{1D573}","H"],["\u{1D574}","I"],["\u{1D575}","J"],["\u{1D576}","K"],["\u{1D577}","L"],["\u{1D578}","M"],["\u{1D579}","N"],["\u{1D57A}","O"],["\u{1D57B}","P"],["\u{1D57C}","Q"],["\u{1D57D}","R"],["\u{1D57E}","S"],["\u{1D57F}","T"],["\u{1D580}","U"],["\u{1D581}","V"],["\u{1D582}","W"],["\u{1D583}","X"],["\u{1D584}","Y"],["\u{1D585}","Z"],["\u{1D586}","a"],["\u{1D587}","b"],["\u{1D588}","c"],["\u{1D589}","d"],["\u{1D58A}","e"],["\u{1D58B}","f"],["\u{1D58C}","g"],["\u{1D58D}","h"],["\u{1D58E}","i"],["\u{1D58F}","j"],["\u{1D590}","k"],["\u{1D591}","l"],["\u{1D592}","m"],["\u{1D593}","n"],["\u{1D594}","o"],["\u{1D595}","p"],["\u{1D596}","q"],["\u{1D597}","r"],["\u{1D598}","s"],["\u{1D599}","t"],["\u{1D59A}","u"],["\u{1D59B}","v"],["\u{1D59C}","w"],["\u{1D59D}","x"],["\u{1D59E}","y"],["\u{1D59F}","z"],["\u{1D5A0}","A"],["\u{1D5A1}","B"],["\u{1D5A2}","C"],["\u{1D5A3}","D"],["\u{1D5A4}","E"],["\u{1D5A5}","F"],["\u{1D5A6}","G"],["\u{1D5A7}","H"],["\u{1D5A8}","I"],["\u{1D5A9}","J"],["\u{1D5AA}","K"],["\u{1D5AB}","L"],["\u{1D5AC}","M"],["\u{1D5AD}","N"],["\u{1D5AE}","O"],["\u{1D5AF}","P"],["\u{1D5B0}","Q"],["\u{1D5B1}","R"],["\u{1D5B2}","S"],["\u{1D5B3}","T"],["\u{1D5B4}","U"],["\u{1D5B5}","V"],["\u{1D5B6}","W"],["\u{1D5B7}","X"],["\u{1D5B8}","Y"],["\u{1D5B9}","Z"],["\u{1D5BA}","a"],["\u{1D5BB}","b"],["\u{1D5BC}","c"],["\u{1D5BD}","d"],["\u{1D5BE}","e"],["\u{1D5BF}","f"],["\u{1D5C0}","g"],["\u{1D5C1}","h"],["\u{1D5C2}","i"],["\u{1D5C3}","j"],["\u{1D5C4}","k"],["\u{1D5C5}","l"],["\u{1D5C6}","m"],["\u{1D5C7}","n"],["\u{1D5C8}","o"],["\u{1D5C9}","p"],["\u{1D5CA}","q"],["\u{1D5CB}","r"],["\u{1D5CC}","s"],["\u{1D5CD}","t"],["\u{1D5CE}","u"],["\u{1D5CF}","v"],["\u{1D5D0}","w"],["\u{1D5D1}","x"],["\u{1D5D2}","y"],["\u{1D5D3}","z"],["\u{1D5D4}","A"],["\u{1D5D5}","B"],["\u{1D5D6}","C"],["\u{1D5D7}","D"],["\u{1D5D8}","E"],["\u{1D5D9}","F"],["\u{1D5DA}","G"],["\u{1D5DB}","H"],["\u{1D5DC}","I"],["\u{1D5DD}","J"],["\u{1D5DE}","K"],["\u{1D5DF}","L"],["\u{1D5E0}","M"],["\u{1D5E1}","N"],["\u{1D5E2}","O"],["\u{1D5E3}","P"],["\u{1D5E4}","Q"],["\u{1D5E5}","R"],["\u{1D5E6}","S"],["\u{1D5E7}","T"],["\u{1D5E8}","U"],["\u{1D5E9}","V"],["\u{1D5EA}","W"],["\u{1D5EB}","X"],["\u{1D5EC}","Y"],["\u{1D5ED}","Z"],["\u{1D5EE}","a"],["\u{1D5EF}","b"],["\u{1D5F0}","c"],["\u{1D5F1}","d"],["\u{1D5F2}","e"],["\u{1D5F3}","f"],["\u{1D5F4}","g"],["\u{1D5F5}","h"],["\u{1D5F6}","i"],["\u{1D5F7}","j"],["\u{1D5F8}","k"],["\u{1D5F9}","l"],["\u{1D5FA}","m"],["\u{1D5FB}","n"],["\u{1D5FC}","o"],["\u{1D5FD}","p"],["\u{1D5FE}","q"],["\u{1D5FF}","r"],["\u{1D600}","s"],["\u{1D601}","t"],["\u{1D602}","u"],["\u{1D603}","v"],["\u{1D604}","w"],["\u{1D605}","x"],["\u{1D606}","y"],["\u{1D607}","z"],["\u{1D608}","A"],["\u{1D609}","B"],["\u{1D60A}","C"],["\u{1D60B}","D"],["\u{1D60C}","E"],["\u{1D60D}","F"],["\u{1D60E}","G"],["\u{1D60F}","H"],["\u{1D610}","I"],["\u{1D611}","J"],["\u{1D612}","K"],["\u{1D613}","L"],["\u{1D614}","M"],["\u{1D615}","N"],["\u{1D616}","O"],["\u{1D617}","P"],["\u{1D618}","Q"],["\u{1D619}","R"],["\u{1D61A}","S"],["\u{1D61B}","T"],["\u{1D61C}","U"],["\u{1D61D}","V"],["\u{1D61E}","W"],["\u{1D61F}","X"],["\u{1D620}","Y"],["\u{1D621}","Z"],["\u{1D622}","a"],["\u{1D623}","b"],["\u{1D624}","c"],["\u{1D625}","d"],["\u{1D626}","e"],["\u{1D627}","f"],["\u{1D628}","g"],["\u{1D629}","h"],["\u{1D62A}","i"],["\u{1D62B}","j"],["\u{1D62C}","k"],["\u{1D62D}","l"],["\u{1D62E}","m"],["\u{1D62F}","n"],["\u{1D630}","o"],["\u{1D631}","p"],["\u{1D632}","q"],["\u{1D633}","r"],["\u{1D634}","s"],["\u{1D635}","t"],["\u{1D636}","u"],["\u{1D637}","v"],["\u{1D638}","w"],["\u{1D639}","x"],["\u{1D63A}","y"],["\u{1D63B}","z"],["\u{1D63C}","A"],["\u{1D63D}","B"],["\u{1D63E}","C"],["\u{1D63F}","D"],["\u{1D640}","E"],["\u{1D641}","F"],["\u{1D642}","G"],["\u{1D643}","H"],["\u{1D644}","I"],["\u{1D645}","J"],["\u{1D646}","K"],["\u{1D647}","L"],["\u{1D648}","M"],["\u{1D649}","N"],["\u{1D64A}","O"],["\u{1D64B}","P"],["\u{1D64C}","Q"],["\u{1D64D}","R"],["\u{1D64E}","S"],["\u{1D64F}","T"],["\u{1D650}","U"],["\u{1D651}","V"],["\u{1D652}","W"],["\u{1D653}","X"],["\u{1D654}","Y"],["\u{1D655}","Z"],["\u{1D656}","a"],["\u{1D657}","b"],["\u{1D658}","c"],["\u{1D659}","d"],["\u{1D65A}","e"],["\u{1D65B}","f"],["\u{1D65C}","g"],["\u{1D65D}","h"],["\u{1D65E}","i"],["\u{1D65F}","j"],["\u{1D660}","k"],["\u{1D661}","l"],["\u{1D662}","m"],["\u{1D663}","n"],["\u{1D664}","o"],["\u{1D665}","p"],["\u{1D666}","q"],["\u{1D667}","r"],["\u{1D668}","s"],["\u{1D669}","t"],["\u{1D66A}","u"],["\u{1D66B}","v"],["\u{1D66C}","w"],["\u{1D66D}","x"],["\u{1D66E}","y"],["\u{1D66F}","z"],["\u{1D670}","A"],["\u{1D671}","B"],["\u{1D672}","C"],["\u{1D673}","D"],["\u{1D674}","E"],["\u{1D675}","F"],["\u{1D676}","G"],["\u{1D677}","H"],["\u{1D678}","I"],["\u{1D679}","J"],["\u{1D67A}","K"],["\u{1D67B}","L"],["\u{1D67C}","M"],["\u{1D67D}","N"],["\u{1D67E}","O"],["\u{1D67F}","P"],["\u{1D680}","Q"],["\u{1D681}","R"],["\u{1D682}","S"],["\u{1D683}","T"],["\u{1D684}","U"],["\u{1D685}","V"],["\u{1D686}","W"],["\u{1D687}","X"],["\u{1D688}","Y"],["\u{1D689}","Z"],["\u{1D68A}","a"],["\u{1D68B}","b"],["\u{1D68C}","c"],["\u{1D68D}","d"],["\u{1D68E}","e"],["\u{1D68F}","f"],["\u{1D690}","g"],["\u{1D691}","h"],["\u{1D692}","i"],["\u{1D693}","j"],["\u{1D694}","k"],["\u{1D695}","l"],["\u{1D696}","m"],["\u{1D697}","n"],["\u{1D698}","o"],["\u{1D699}","p"],["\u{1D69A}","q"],["\u{1D69B}","r"],["\u{1D69C}","s"],["\u{1D69D}","t"],["\u{1D69E}","u"],["\u{1D69F}","v"],["\u{1D6A0}","w"],["\u{1D6A1}","x"],["\u{1D6A2}","y"],["\u{1D6A3}","z"],["\u{1D6A4}","l"],["\u{1D6A5}","j"],["\u{1D6E2}","A"],["\u{1D6E3}","B"],["\u{1D6E4}","G"],["\u{1D6E5}","D"],["\u{1D6E6}","E"],["\u{1D6E7}","Z"],["\u{1D6E8}","I"],["\u{1D6E9}","TH"],["\u{1D6EA}","I"],["\u{1D6EB}","K"],["\u{1D6EC}","L"],["\u{1D6ED}","M"],["\u{1D6EE}","N"],["\u{1D6EF}","KS"],["\u{1D6F0}","O"],["\u{1D6F1}","P"],["\u{1D6F2}","R"],["\u{1D6F3}","TH"],["\u{1D6F4}","S"],["\u{1D6F5}","T"],["\u{1D6F6}","Y"],["\u{1D6F7}","F"],["\u{1D6F8}","x"],["\u{1D6F9}","PS"],["\u{1D6FA}","O"],["\u{1D6FB}","D"],["\u{1D6FC}","a"],["\u{1D6FD}","b"],["\u{1D6FE}","g"],["\u{1D6FF}","d"],["\u{1D700}","e"],["\u{1D701}","z"],["\u{1D702}","i"],["\u{1D703}","th"],["\u{1D704}","i"],["\u{1D705}","k"],["\u{1D706}","l"],["\u{1D707}","m"],["\u{1D708}","n"],["\u{1D709}","ks"],["\u{1D70A}","o"],["\u{1D70B}","p"],["\u{1D70C}","r"],["\u{1D70D}","s"],["\u{1D70E}","s"],["\u{1D70F}","t"],["\u{1D710}","y"],["\u{1D711}","f"],["\u{1D712}","x"],["\u{1D713}","ps"],["\u{1D714}","o"],["\u{1D715}","d"],["\u{1D716}","E"],["\u{1D717}","TH"],["\u{1D718}","K"],["\u{1D719}","f"],["\u{1D71A}","r"],["\u{1D71B}","p"],["\u{1D71C}","A"],["\u{1D71D}","V"],["\u{1D71E}","G"],["\u{1D71F}","D"],["\u{1D720}","E"],["\u{1D721}","Z"],["\u{1D722}","I"],["\u{1D723}","TH"],["\u{1D724}","I"],["\u{1D725}","K"],["\u{1D726}","L"],["\u{1D727}","M"],["\u{1D728}","N"],["\u{1D729}","KS"],["\u{1D72A}","O"],["\u{1D72B}","P"],["\u{1D72C}","S"],["\u{1D72D}","TH"],["\u{1D72E}","S"],["\u{1D72F}","T"],["\u{1D730}","Y"],["\u{1D731}","F"],["\u{1D732}","X"],["\u{1D733}","PS"],["\u{1D734}","O"],["\u{1D735}","D"],["\u{1D736}","a"],["\u{1D737}","v"],["\u{1D738}","g"],["\u{1D739}","d"],["\u{1D73A}","e"],["\u{1D73B}","z"],["\u{1D73C}","i"],["\u{1D73D}","th"],["\u{1D73E}","i"],["\u{1D73F}","k"],["\u{1D740}","l"],["\u{1D741}","m"],["\u{1D742}","n"],["\u{1D743}","ks"],["\u{1D744}","o"],["\u{1D745}","p"],["\u{1D746}","r"],["\u{1D747}","s"],["\u{1D748}","s"],["\u{1D749}","t"],["\u{1D74A}","y"],["\u{1D74B}","f"],["\u{1D74C}","x"],["\u{1D74D}","ps"],["\u{1D74E}","o"],["\u{1D74F}","a"],["\u{1D750}","e"],["\u{1D751}","i"],["\u{1D752}","k"],["\u{1D753}","f"],["\u{1D754}","r"],["\u{1D755}","p"],["\u{1D756}","A"],["\u{1D757}","B"],["\u{1D758}","G"],["\u{1D759}","D"],["\u{1D75A}","E"],["\u{1D75B}","Z"],["\u{1D75C}","I"],["\u{1D75D}","TH"],["\u{1D75E}","I"],["\u{1D75F}","K"],["\u{1D760}","L"],["\u{1D761}","M"],["\u{1D762}","N"],["\u{1D763}","KS"],["\u{1D764}","O"],["\u{1D765}","P"],["\u{1D766}","R"],["\u{1D767}","TH"],["\u{1D768}","S"],["\u{1D769}","T"],["\u{1D76A}","Y"],["\u{1D76B}","F"],["\u{1D76C}","X"],["\u{1D76D}","PS"],["\u{1D76E}","O"],["\u{1D76F}","D"],["\u{1D770}","a"],["\u{1D771}","v"],["\u{1D772}","g"],["\u{1D773}","d"],["\u{1D774}","e"],["\u{1D775}","z"],["\u{1D776}","i"],["\u{1D777}","th"],["\u{1D778}","i"],["\u{1D779}","k"],["\u{1D77A}","l"],["\u{1D77B}","m"],["\u{1D77C}","n"],["\u{1D77D}","ks"],["\u{1D77E}","o"],["\u{1D77F}","p"],["\u{1D780}","r"],["\u{1D781}","s"],["\u{1D782}","s"],["\u{1D783}","t"],["\u{1D784}","y"],["\u{1D785}","f"],["\u{1D786}","x"],["\u{1D787}","ps"],["\u{1D788}","o"],["\u{1D789}","a"],["\u{1D78A}","e"],["\u{1D78B}","i"],["\u{1D78C}","k"],["\u{1D78D}","f"],["\u{1D78E}","r"],["\u{1D78F}","p"],["\u{1D790}","A"],["\u{1D791}","V"],["\u{1D792}","G"],["\u{1D793}","D"],["\u{1D794}","E"],["\u{1D795}","Z"],["\u{1D796}","I"],["\u{1D797}","TH"],["\u{1D798}","I"],["\u{1D799}","K"],["\u{1D79A}","L"],["\u{1D79B}","M"],["\u{1D79C}","N"],["\u{1D79D}","KS"],["\u{1D79E}","O"],["\u{1D79F}","P"],["\u{1D7A0}","S"],["\u{1D7A1}","TH"],["\u{1D7A2}","S"],["\u{1D7A3}","T"],["\u{1D7A4}","Y"],["\u{1D7A5}","F"],["\u{1D7A6}","X"],["\u{1D7A7}","PS"],["\u{1D7A8}","O"],["\u{1D7A9}","D"],["\u{1D7AA}","av"],["\u{1D7AB}","g"],["\u{1D7AC}","d"],["\u{1D7AD}","e"],["\u{1D7AE}","z"],["\u{1D7AF}","i"],["\u{1D7B0}","i"],["\u{1D7B1}","th"],["\u{1D7B2}","i"],["\u{1D7B3}","k"],["\u{1D7B4}","l"],["\u{1D7B5}","m"],["\u{1D7B6}","n"],["\u{1D7B7}","ks"],["\u{1D7B8}","o"],["\u{1D7B9}","p"],["\u{1D7BA}","r"],["\u{1D7BB}","s"],["\u{1D7BC}","s"],["\u{1D7BD}","t"],["\u{1D7BE}","y"],["\u{1D7BF}","f"],["\u{1D7C0}","x"],["\u{1D7C1}","ps"],["\u{1D7C2}","o"],["\u{1D7C3}","a"],["\u{1D7C4}","e"],["\u{1D7C5}","i"],["\u{1D7C6}","k"],["\u{1D7C7}","f"],["\u{1D7C8}","r"],["\u{1D7C9}","p"],["\u{1D7CA}","F"],["\u{1D7CB}","f"],["\u249C","(a)"],["\u249D","(b)"],["\u249E","(c)"],["\u249F","(d)"],["\u24A0","(e)"],["\u24A1","(f)"],["\u24A2","(g)"],["\u24A3","(h)"],["\u24A4","(i)"],["\u24A5","(j)"],["\u24A6","(k)"],["\u24A7","(l)"],["\u24A8","(m)"],["\u24A9","(n)"],["\u24AA","(o)"],["\u24AB","(p)"],["\u24AC","(q)"],["\u24AD","(r)"],["\u24AE","(s)"],["\u24AF","(t)"],["\u24B0","(u)"],["\u24B1","(v)"],["\u24B2","(w)"],["\u24B3","(x)"],["\u24B4","(y)"],["\u24B5","(z)"],["\u24B6","(A)"],["\u24B7","(B)"],["\u24B8","(C)"],["\u24B9","(D)"],["\u24BA","(E)"],["\u24BB","(F)"],["\u24BC","(G)"],["\u24BD","(H)"],["\u24BE","(I)"],["\u24BF","(J)"],["\u24C0","(K)"],["\u24C1","(L)"],["\u24C3","(N)"],["\u24C4","(O)"],["\u24C5","(P)"],["\u24C6","(Q)"],["\u24C7","(R)"],["\u24C8","(S)"],["\u24C9","(T)"],["\u24CA","(U)"],["\u24CB","(V)"],["\u24CC","(W)"],["\u24CD","(X)"],["\u24CE","(Y)"],["\u24CF","(Z)"],["\u24D0","(a)"],["\u24D1","(b)"],["\u24D2","(c)"],["\u24D3","(d)"],["\u24D4","(e)"],["\u24D5","(f)"],["\u24D6","(g)"],["\u24D7","(h)"],["\u24D8","(i)"],["\u24D9","(j)"],["\u24DA","(k)"],["\u24DB","(l)"],["\u24DC","(m)"],["\u24DD","(n)"],["\u24DE","(o)"],["\u24DF","(p)"],["\u24E0","(q)"],["\u24E1","(r)"],["\u24E2","(s)"],["\u24E3","(t)"],["\u24E4","(u)"],["\u24E5","(v)"],["\u24E6","(w)"],["\u24E7","(x)"],["\u24E8","(y)"],["\u24E9","(z)"],["\u010A","C"],["\u010B","c"],["\u0120","G"],["\u0121","g"],["\u0126","H"],["\u0127","h"],["\u017B","Z"],["\u017C","z"],["\u{1D7CE}","0"],["\u{1D7CF}","1"],["\u{1D7D0}","2"],["\u{1D7D1}","3"],["\u{1D7D2}","4"],["\u{1D7D3}","5"],["\u{1D7D4}","6"],["\u{1D7D5}","7"],["\u{1D7D6}","8"],["\u{1D7D7}","9"],["\u{1D7D8}","0"],["\u{1D7D9}","1"],["\u{1D7DA}","2"],["\u{1D7DB}","3"],["\u{1D7DC}","4"],["\u{1D7DD}","5"],["\u{1D7DE}","6"],["\u{1D7DF}","7"],["\u{1D7E0}","8"],["\u{1D7E1}","9"],["\u{1D7E2}","0"],["\u{1D7E3}","1"],["\u{1D7E4}","2"],["\u{1D7E5}","3"],["\u{1D7E6}","4"],["\u{1D7E7}","5"],["\u{1D7E8}","6"],["\u{1D7E9}","7"],["\u{1D7EA}","8"],["\u{1D7EB}","9"],["\u{1D7EC}","0"],["\u{1D7ED}","1"],["\u{1D7EE}","2"],["\u{1D7EF}","3"],["\u{1D7F0}","4"],["\u{1D7F1}","5"],["\u{1D7F2}","6"],["\u{1D7F3}","7"],["\u{1D7F4}","8"],["\u{1D7F5}","9"],["\u{1D7F6}","0"],["\u{1D7F7}","1"],["\u{1D7F8}","2"],["\u{1D7F9}","3"],["\u{1D7FA}","4"],["\u{1D7FB}","5"],["\u{1D7FC}","6"],["\u{1D7FD}","7"],["\u{1D7FE}","8"],["\u{1D7FF}","9"],["\u2460","1"],["\u2461","2"],["\u2462","3"],["\u2463","4"],["\u2464","5"],["\u2465","6"],["\u2466","7"],["\u2467","8"],["\u2468","9"],["\u2469","10"],["\u246A","11"],["\u246B","12"],["\u246C","13"],["\u246D","14"],["\u246E","15"],["\u246F","16"],["\u2470","17"],["\u2471","18"],["\u2472","19"],["\u2473","20"],["\u2474","1"],["\u2475","2"],["\u2476","3"],["\u2477","4"],["\u2478","5"],["\u2479","6"],["\u247A","7"],["\u247B","8"],["\u247C","9"],["\u247D","10"],["\u247E","11"],["\u247F","12"],["\u2480","13"],["\u2481","14"],["\u2482","15"],["\u2483","16"],["\u2484","17"],["\u2485","18"],["\u2486","19"],["\u2487","20"],["\u2488","1."],["\u2489","2."],["\u248A","3."],["\u248B","4."],["\u248C","5."],["\u248D","6."],["\u248E","7."],["\u248F","8."],["\u2490","9."],["\u2491","10."],["\u2492","11."],["\u2493","12."],["\u2494","13."],["\u2495","14."],["\u2496","15."],["\u2497","16."],["\u2498","17."],["\u2499","18."],["\u249A","19."],["\u249B","20."],["\u24EA","0"],["\u24EB","11"],["\u24EC","12"],["\u24ED","13"],["\u24EE","14"],["\u24EF","15"],["\u24F0","16"],["\u24F1","17"],["\u24F2","18"],["\u24F3","19"],["\u24F4","20"],["\u24F5","1"],["\u24F6","2"],["\u24F7","3"],["\u24F8","4"],["\u24F9","5"],["\u24FA","6"],["\u24FB","7"],["\u24FC","8"],["\u24FD","9"],["\u24FE","10"],["\u24FF","0"],["\u{1F670}","&"],["\u{1F671}","&"],["\u{1F672}","&"],["\u{1F673}","&"],["\u{1F674}","&"],["\u{1F675}","&"],["\u{1F676}",'"'],["\u{1F677}",'"'],["\u{1F678}",'"'],["\u203D","?!"],["\u{1F679}","?!"],["\u{1F67A}","?!"],["\u{1F67B}","?!"],["\u{1F67C}","/"],["\u{1F67D}","\\"],["\u{1F707}","AR"],["\u{1F708}","V"],["\u{1F709}","V"],["\u{1F706}","VR"],["\u{1F705}","VF"],["\u{1F729}","2"],["\u{1F72A}","5"],["\u{1F761}","f"],["\u{1F762}","W"],["\u{1F763}","U"],["\u{1F767}","V"],["\u{1F768}","T"],["\u{1F76A}","V"],["\u{1F76B}","MB"],["\u{1F76C}","VB"],["\u{1F772}","3B"],["\u{1F773}","3B"],["\u{1F4AF}","100"],["\u{1F519}","BACK"],["\u{1F51A}","END"],["\u{1F51B}","ON!"],["\u{1F51C}","SOON"],["\u{1F51D}","TOP"],["\u{1F51E}","18"],["\u{1F524}","abc"],["\u{1F520}","ABCD"],["\u{1F521}","abcd"],["\u{1F522}","1234"],["\u{1F523}","T&@%"],["#\uFE0F\u20E3","#"],["*\uFE0F\u20E3","*"],["0\uFE0F\u20E3","0"],["1\uFE0F\u20E3","1"],["2\uFE0F\u20E3","2"],["3\uFE0F\u20E3","3"],["4\uFE0F\u20E3","4"],["5\uFE0F\u20E3","5"],["6\uFE0F\u20E3","6"],["7\uFE0F\u20E3","7"],["8\uFE0F\u20E3","8"],["9\uFE0F\u20E3","9"],["\u{1F51F}","10"],["\u{1F170}\uFE0F","A"],["\u{1F171}\uFE0F","B"],["\u{1F18E}","AB"],["\u{1F191}","CL"],["\u{1F17E}\uFE0F","O"],["\u{1F17F}","P"],["\u{1F198}","SOS"],["\u{1F172}","C"],["\u{1F173}","D"],["\u{1F174}","E"],["\u{1F175}","F"],["\u{1F176}","G"],["\u{1F177}","H"],["\u{1F178}","I"],["\u{1F179}","J"],["\u{1F17A}","K"],["\u{1F17B}","L"],["\u{1F17C}","M"],["\u{1F17D}","N"],["\u{1F180}","Q"],["\u{1F181}","R"],["\u{1F182}","S"],["\u{1F183}","T"],["\u{1F184}","U"],["\u{1F185}","V"],["\u{1F186}","W"],["\u{1F187}","X"],["\u{1F188}","Y"],["\u{1F189}","Z"],["\u2212","-"],["\u2053","-"]],KC=new Map(WC),Gu=KC});var vy,Yo,Xu,Sy=k(()=>{vy=[["\xE6","ae"],["\xC6","Ae"],["\xF8","oe"],["\xD8","Oe"],["\xE5","aa"],["\xC5","Aa"]],Yo={sv:[["\xE4","a"],["\xC4","A"],["\xF6","o"],["\xD6","O"],["\xE5","a"],["\xC5","A"]],da:vy,nb:vy,de:[["\xE4","ae"],["\xC4","Ae"],["\xF6","oe"],["\xD6","Oe"],["\xFC","ue"],["\xDC","Ue"],["\xDF","ss"],["\u1E9E","Ss"]],tr:[["\xE2","a"],["\xC2","A"],["\xF6","o"],["\xD6","O"],["\xFC","u"],["\xDC","U"]],hu:[["\u0171","u"],["\u0170","U"],["\xF6","o"],["\xD6","O"],["\xFC","u"],["\xDC","U"],["\xE1","a"],["\xC1","A"],["\xE9","e"],["\xC9","E"],["\xED","i"],["\xCD","I"],["\xF3","o"],["\xD3","O"],["\xFA","u"],["\xDA","U"]],sr:[["\u0452","dj"],["\u0402","Dj"],["\u045F","dz"],["\u040F","Dz"],["\u0459","lj"],["\u0409","Lj"],["\u045A","nj"],["\u040A","Nj"],["\u045B","c"],["\u040B","C"],["\u0447","ch"],["\u0427","Ch"],["\u0448","sh"],["\u0428","Sh"],["\u0436","zh"],["\u0416","Zh"]]};for(let t of Object.keys(Yo))Yo[t]=new Map(Yo[t]);Xu=Yo});function Qu(t,e){if(typeof t!="string")throw new TypeError(`Expected a string, got \`${typeof t}\``);e={customReplacements:[],...e};let n=zC(e.locale),r=Gu,s=e.customReplacements.length>0||e.customReplacements.size>0;if(n||s){if(r=new Map(Gu),n)for(let[i,o]of n)r.set(i,o);for(let[i,o]of e.customReplacements)r.set(i,o)}return t=t.normalize(),t=HC(t,r),t=t.normalize("NFD").replaceAll(/\p{Diacritic}/gu,"").normalize(),t=t.replaceAll(/\p{Dash_Punctuation}/gu,"-"),t}var HC,zC,ky=k(()=>{wy();Sy();HC=(t,e)=>{for(let[n,r]of e)t=t.replaceAll(n,r);return t},zC=t=>{if(!t)return;let e=t.toLowerCase().replace(/^no(-|$)/,"nb$1");return Xu[e]||Xu[e.split("-")[0]]||void 0}});var YC,xy,Ey=k(()=>{YC=[["&"," and "],["\u{1F984}"," unicorn "],["\u2665"," love "]],xy=YC});function Zu(t,e){if(typeof t!="string")throw new TypeError(`Expected a string, got \`${typeof t}\``);e={separator:"-",lowercase:!0,decamelize:!0,customReplacements:[],preserveLeadingUnderscore:!1,preserveTrailingDash:!1,preserveCharacters:[],transliterate:!0,...e};let n=e.preserveLeadingUnderscore&&t.startsWith("_"),r=e.preserveTrailingDash&&t.endsWith("-");if(e.transliterate){let i=new Map([...xy,...e.customReplacements]);t=Qu(t,{customReplacements:i,locale:e.locale})}else if(e.customReplacements.length>0)for(let[i,o]of e.customReplacements)t=t.replaceAll(i,o);e.decamelize&&(t=VC(t));let s=XC(e);return e.lowercase&&(t=e.locale?t.toLocaleLowerCase(e.locale):t.toLowerCase()),t=t.replaceAll(/([a-zA-Z\d]+)['\u2019]([ts])(\s|$)/g,"$1$2$3"),t=t.replace(s,e.separator),t=t.replaceAll("\\",""),e.separator&&(t=GC(t,e.separator)),n&&(t=`_${t}`),r&&(t=`${t}-`),t}var VC,GC,XC,Ay=k(()=>{by();ky();Ey();VC=t=>t.replaceAll(/([A-Z]{2,})(\d+)/g,"$1 $2").replaceAll(/([a-z\d]+)([A-Z]{2,})/g,"$1 $2").replaceAll(/([a-z\d])([A-Z])/g,"$1 $2").replaceAll(/([A-Z]+)([A-Z][a-rt-z\d]+)/g,"$1 $2"),GC=(t,e)=>{let n=zo(e);return t.replaceAll(new RegExp(`(?:${n}){2,}`,"g"),e).replaceAll(new RegExp(`^(?:${n})|(?:${n})$`,"g"),"")},XC=t=>{let e=String.raw`a-z\d`;if(e+=t.lowercase?"":"A-Z",t.transliterate===!1&&(e+=String.raw`\p{L}\p{N}`),t.preserveCharacters.length>0)for(let r of t.preserveCharacters){if(r===t.separator)throw new Error(`The separator character \`${t.separator}\` cannot be included in preserved characters: ${t.preserveCharacters}`);e+=zo(r)}let n=t.transliterate?"g":"gu";return new RegExp(`[^${e}]+`,n)}});function sr(t){return Zu(t)}var Ty=k(()=>{Ay()});var ir,Cy,Oy=k(()=>{ir={local:"local",ide:"ide",published:"published",inline:"inline"},Cy=Object.values(ir).map(t=>`'${t}'`).join(" | ")});var Ns,ed,Py=k(()=>{Ns=` *, *::before, *::after { box-sizing: border-box; }
170
170
  canvas { max-width: 100%; }
171
171
  body { margin: 0; display: flow-root; font-family: system-ui, -apple-system, sans-serif; }
172
172
  html[data-theme="dark"] { color-scheme: dark; }
173
- html[data-theme="light"] { color-scheme: light; }`,Yu=" html, body { height: 100%; }"});var vy,Sy=S(()=>{vy=`(function () {
173
+ html[data-theme="light"] { color-scheme: light; }`,ed=" html, body { height: 100%; }"});var _y,Ry=k(()=>{_y=`(function () {
174
174
  var W = window, D = document;
175
175
  var TAIL_MS = 1500, TOL = 2, THROTTLE_MS = 200;
176
176
  var SCROLL_KEYS = { ' ': 1, ArrowUp: 1, ArrowDown: 1, PageUp: 1, PageDown: 1, Home: 1, End: 1 };
@@ -238,7 +238,7 @@ ${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.pus
238
238
  top: function () { disarm(); write(0); report(0); },
239
239
  flush: flush
240
240
  };
241
- })();`});var ky,xy=S(()=>{ky=`(function () {
241
+ })();`});var Iy,$y=k(()=>{Iy=`(function () {
242
242
  var W = window;
243
243
  var rtData, rtInsight, rtHasInsight = false;
244
244
  var applyData, applyInsight, send;
@@ -292,51 +292,51 @@ ${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.pus
292
292
  return publish();
293
293
  }
294
294
  };
295
- })();`});var te=S(()=>{Di();rc();sh();lh();Ju();ay();gy();by();wy();Sy();xy();Bi()});function fe(t){let e=Math.max(0,Math.round(t/1e3));if(e<60)return`${e}s`;let n=Math.floor(e/60);return n<60?`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}function Ty(t,e){if(!e)return t;let n=t.replace(/\\/g,"/"),r=e.replace(/\\/g,"/").replace(/\/+$/,"");return n.toLowerCase().startsWith(r.toLowerCase()+"/")?n.slice(r.length+1):t}function Cy(t){return t.replace(/[/\\]+$/,"").split(/[/\\]/).pop()??""}function Oy(t){return!t||typeof t!="object"?"":Z(t.command)??Z(t.file_path)??Z(t.filePath)??Z(t.path)??Z(t.pattern)??Z(t.query)??Z(t.url)??Z(t.skill)??Z(t.description)??""}function Gu(t){let e=/^mcp__(.+?)__(.+)$/.exec(t);return e?`${e[1][0].toUpperCase()}${e[1].slice(1)} [${e[2]}]`:t}var Z,Ps,Ay,_s=S(()=>{"use strict";Z=t=>typeof t=="string"?t:void 0,Ps=t=>t.replace(/\u001b\[[0-9;]*m/g,""),Ay=t=>` (+${t} line${t===1?"":"s"})`});function _e(t){return t.length>Xu?t.slice(0,Xu)+`
296
- \u2026[${t.length-Xu} more characters truncated]`:t}function Be(t){let e=Ps(t).split(`
297
- `).map(i=>i.trim()).filter(Boolean),n=e[0];if(!n)return"";let r=n.length>300?n.slice(0,300).trimEnd()+"\u2026":n,s=e.length-1;return s>0?r+Ay(s):r}var Xu,Te,qo,Rs=S(()=>{"use strict";_s();Xu=5e4,Te=(t,e,n=e+"s")=>`${t} ${t===1?e:n}`;qo=(t,e)=>`![pasted image](data:${e||"image/png"};base64,${t})`});import{closeSync as Py,existsSync as AC,fstatSync as TC,openSync as _y,readdirSync as CC,readSync as Ry,statSync as OC}from"fs";import{join as PC}from"path";function sr(t,e){let n;try{n=_y(t,"r")}catch{return}try{let r=Buffer.alloc(e),s=Ry(n,r,0,e,0);return{text:r.subarray(0,s).toString("utf8"),bytes:s}}finally{Py(n)}}function Jo(t,e){let n;try{n=_y(t,"r")}catch{return}try{let r=TC(n).size,s=Math.min(e,r),i=Buffer.alloc(s),o=Ry(n,i,0,s,r-s);return{text:i.subarray(0,o).toString("utf8"),partial:r>s}}finally{Py(n)}}function Wo(t){if(!AC(t))return[];let e;try{e=CC(t)}catch{return[]}let n=[];for(let r of e){if(!r.endsWith(".jsonl"))continue;let s=PC(t,r);try{let i=OC(s);i.isFile()&&n.push({sessionId:r.slice(0,-6),file:s,mtime:i.mtimeMs})}catch{}}return n}var Ko=S(()=>{"use strict"});var qt,Ho=S(()=>{"use strict";qt=class{ensureHarnessSupport(){}forRead(){return this}linker(){return{link(){}}}}});import{openSync as _C,readSync as RC,closeSync as IC,statSync as My,readdirSync as Dy,readFileSync as By,existsSync as $C}from"fs";import{join as mn}from"path";import{homedir as NC}from"os";function LC(t){return t.replace(/[^a-zA-Z0-9]/g,"-")}function DC(t,e,n){let r=mn(Qu(t,e),n,MC),s;try{s=Dy(r)}catch{return[]}let i=oO(t,n),o=[];for(let a of s){if(!a.endsWith(".jsonl"))continue;let l=mn(r,a),c;try{c=My(l)}catch{continue}let f=a.slice(0,-6),d={};try{d=JSON.parse(By(mn(r,`${f}.meta.json`),"utf8"))}catch{}let u=FC(l,c.size,c.mtimeMs);o.push({id:f.startsWith("agent-")?f.slice(6):f,file:l,mtime:c.mtimeMs,started:c.birthtimeMs||void 0,tokens:u.tokens,failing:u.failing,running:!!u.running&&(i===void 0||c.mtimeMs>=i),liveSince:i,label:d.description??"",kind:d.agentType===BC?void 0:d.agentType,model:u.model?.replace(/^claude-/,"").replace(/-\d{8}$/,"")??d.model,effort:u.effort,spawnId:d.toolUseId,parentId:d.parentAgentId,depth:d.spawnDepth??1,stopped:!!d.stoppedByUser||!!u.stopped})}return o}function FC(t,e,n){let r=Iy.get(t);if(r&&r.size===e&&r.mtime===n)return r;let s={};for(let i of jC){let o=Jo(t,i);if(!o)break;let a=o.text.split(`
298
- `);o.partial&&a.shift();let l=[];for(let u of a)if(u.trim())try{l.push(JSON.parse(u))}catch{}if(o.partial&&!l.some(u=>u.type==="user"||u.type==="assistant"))continue;let c,f;for(let u=l.length-1;u>=0&&!f;u--){let p=l[u];p?.type==="assistant"&&(c??=p,!p.isApiErrorMessage&&p.message?.usage&&(f=p))}let d=f?.message?.usage;if(s={tokens:d?(d.input_tokens??0)+(d.output_tokens??0)+(d.cache_read_input_tokens??0)+(d.cache_creation_input_tokens??0):r?.tokens,model:f?.message?.model??r?.model,effort:f?.effort??r?.effort,running:jy(l),failing:!!c?.isApiErrorMessage,stopped:qC(l)},!(s.tokens===void 0&&o.partial))break}return s.model??=UC(t),Iy.set(t,{size:e,mtime:n,...s}),s}function UC(t){for(let e of(sr(t,256*1024)?.text??"").split(`
299
- `))if(e.includes('"modelId"'))try{let n=JSON.parse(e).attachment?.identity?.modelId;if(n)return n}catch{}}function jy(t){let e;for(let i of t)(i.type==="user"||i.type==="assistant")&&(e=i);if(!e)return!1;if(e.type==="user"){try{if(JC(e,t))return!1;let i=e.message?.content,o=typeof i=="string"?i:Array.isArray(i)?i.filter(a=>a&&a.type==="text").map(a=>a.text??"").join(""):"";if(!ed(e)&&o.trim()&&Jt(o)==="")return!1}catch{}return!0}let r=(Array.isArray(e.message?.content)?e.message.content:[]).filter(i=>i.type==="tool_use").map(i=>i.id);if(r.length===0)return!e.message?.stop_reason||e.message.stop_reason==="tool_use";let s=new Set;for(let i of t){let o=i.message?.content;if(Array.isArray(o))for(let a of o)a.type==="tool_result"&&a.tool_use_id&&s.add(a.tool_use_id)}return r.some(i=>i&&!s.has(i))}function qC(t){let e;for(let s of t)(s.type==="user"||s.type==="assistant")&&(e=s);let n=e?.type==="user"&&!ed(e)?e.message?.content:void 0,r=typeof n=="string"?n:Array.isArray(n)?n.filter(s=>s?.type==="text").map(s=>s.text??"").join(""):"";return/^\[Request interrupted by user\b/.test(r.trim())}function JC(t,e){let n=t.message?.content,r=Array.isArray(n)?n.filter(i=>i?.type==="tool_result").map(i=>i.tool_use_id):[];if(r.length===0)return!1;let s=new Set;for(let i of e){let o=i.type==="assistant"?i.message?.content:void 0;if(Array.isArray(o))for(let a of o)a?.type==="tool_use"&&a.name==="SubagentHandback"&&s.add(a.id)}return r.every(i=>s.has(i))}function Yo(t){let e=t?.type==="image"?t.source:void 0;return e?.type==="base64"&&e.data?qo(e.data,e.media_type):""}function Is(t){return typeof t=="string"?_e(t):Array.isArray(t)?t.map(e=>{if(typeof e=="string")return _e(e);let n=e;return typeof n?.text=="string"?_e(n.text):n?.content!=null?Is(n.content):Yo(n)}).join(`
300
- `):t==null?"":_e(JSON.stringify(t))}function Fy(t){let e=t.trim();return!!e&&WC.some(n=>n.exec(e)?.index===0)}function KC(t){return!t.trim()||Fy(t)}function zC(t){return t.replace(HC,"")}function YC(t){let e=/^<command-name>([\s\S]*?)<\/command-name>/.exec(t)?.[1]?.trim();if(!e)return;let n=/<command-args>([\s\S]*?)<\/command-args>/.exec(t)?.[1]?.trim();return n?`${e} ${n}`:e}function Jt(t){let e=zC(t).trim();return e?YC(e)??(Fy(e)?"":e):""}function Vo(t){let e=VC.exec(t.trim());if(e)return{from:e[1],body:XC(e[2].replace(GC,""))}}function XC(t){let e=t.split(`
295
+ })();`});var re=k(()=>{Wi();ll();hh();bh();Vu();yy();Ty();Oy();Py();Ry();$y();Ki()});function ne(t){let e=Math.max(0,Math.round(t/1e3));if(e<60)return`${e}s`;let n=Math.floor(e/60);return n<60?`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}function My(t,e){if(!e)return t;let n=t.replace(/\\/g,"/"),r=e.replace(/\\/g,"/").replace(/\/+$/,"");return n.toLowerCase().startsWith(r.toLowerCase()+"/")?n.slice(r.length+1):t}function Dy(t){return t.replace(/[/\\]+$/,"").split(/[/\\]/).pop()??""}function By(t){return!t||typeof t!="object"?"":te(t.command)??te(t.file_path)??te(t.filePath)??te(t.path)??te(t.pattern)??te(t.query)??te(t.url)??te(t.skill)??te(t.description)??""}function nd(t){let e=/^mcp__(.+?)__(.+)$/.exec(t);return e?`${e[1][0].toUpperCase()}${e[1].slice(1)} [${e[2]}]`:t}var te,Ls,Ly,or=k(()=>{"use strict";te=t=>typeof t=="string"?t:void 0,Ls=t=>t.replace(/\u001b\[[0-9;]*m/g,""),Ly=t=>` (+${t} line${t===1?"":"s"})`});function Ie(t){return t.length>rd?t.slice(0,rd)+`
296
+ \u2026[${t.length-rd} more characters truncated]`:t}function Fe(t){let e=Ls(t).split(`
297
+ `).map(i=>i.trim()).filter(Boolean),n=e[0];if(!n)return"";let r=n.length>300?n.slice(0,300).trimEnd()+"\u2026":n,s=e.length-1;return s>0?r+Ly(s):r}var rd,Oe,Vo,Ms=k(()=>{"use strict";or();rd=5e4,Oe=(t,e,n=e+"s")=>`${t} ${t===1?e:n}`;Vo=(t,e)=>`![pasted image](data:${e||"image/png"};base64,${t})`});import{closeSync as jy,existsSync as QC,fstatSync as ZC,openSync as Fy,readdirSync as eO,readSync as Uy,statSync as tO}from"fs";import{join as nO}from"path";function ar(t,e){let n;try{n=Fy(t,"r")}catch{return}try{let r=Buffer.alloc(e),s=Uy(n,r,0,e,0);return{text:r.subarray(0,s).toString("utf8"),bytes:s}}finally{jy(n)}}function Go(t,e){let n;try{n=Fy(t,"r")}catch{return}try{let r=ZC(n).size,s=Math.min(e,r),i=Buffer.alloc(s),o=Uy(n,i,0,s,r-s);return{text:i.subarray(0,o).toString("utf8"),partial:r>s}}finally{jy(n)}}function Xo(t){if(!QC(t))return[];let e;try{e=eO(t)}catch{return[]}let n=[];for(let r of e){if(!r.endsWith(".jsonl"))continue;let s=nO(t,r);try{let i=tO(s);i.isFile()&&n.push({sessionId:r.slice(0,-6),file:s,mtime:i.mtimeMs})}catch{}}return n}var Qo=k(()=>{"use strict"});var Ut,Zo=k(()=>{"use strict";Ut=class{ensureHarnessSupport(){}forRead(){return this}linker(){return{link(){}}}}});import{openSync as rO,readSync as sO,closeSync as iO,statSync as Hy,readdirSync as zy,readFileSync as Yy,existsSync as oO}from"fs";import{join as yn}from"path";import{homedir as aO}from"os";function cO(t){return t.replace(/[^a-zA-Z0-9]/g,"-")}function uO(t,e,n){let r=yn(sd(t,e),n,lO),s;try{s=zy(r)}catch{return[]}let i=$O(t,n),o=[];for(let a of s){if(!a.endsWith(".jsonl"))continue;let c=yn(r,a),l;try{l=Hy(c)}catch{continue}let f=a.slice(0,-6),u={};try{u=JSON.parse(Yy(yn(r,`${f}.meta.json`),"utf8"))}catch{}let d=pO(c,l.size,l.mtimeMs);o.push({id:f.startsWith("agent-")?f.slice(6):f,file:c,mtime:l.mtimeMs,started:l.birthtimeMs||void 0,tokens:d.tokens,failing:d.failing,running:!!d.running&&(i===void 0||l.mtimeMs>=i),liveSince:i,label:u.description??"",kind:u.agentType===dO?void 0:u.agentType,model:d.model?.replace(/^claude-/,"").replace(/-\d{8}$/,"")??u.model,effort:d.effort,spawnId:u.toolUseId,parentId:u.parentAgentId,depth:u.spawnDepth??1,stopped:!!u.stoppedByUser||!!d.stopped})}return o}function pO(t,e,n){let r=qy.get(t);if(r&&r.size===e&&r.mtime===n)return r;let s={};for(let i of fO){let o=Go(t,i);if(!o)break;let a=o.text.split(`
298
+ `);o.partial&&a.shift();let c=[];for(let d of a)if(d.trim())try{c.push(JSON.parse(d))}catch{}if(o.partial&&!c.some(d=>d.type==="user"||d.type==="assistant"))continue;let l,f;for(let d=c.length-1;d>=0&&!f;d--){let p=c[d];p?.type==="assistant"&&(l??=p,!p.isApiErrorMessage&&p.message?.usage&&(f=p))}let u=f?.message?.usage;if(s={tokens:u?(u.input_tokens??0)+(u.output_tokens??0)+(u.cache_read_input_tokens??0)+(u.cache_creation_input_tokens??0):r?.tokens,model:f?.message?.model??r?.model,effort:f?.effort??r?.effort,running:Vy(c),failing:!!l?.isApiErrorMessage,stopped:mO(c)},!(s.tokens===void 0&&o.partial))break}return s.model??=hO(t),qy.set(t,{size:e,mtime:n,...s}),s}function hO(t){for(let e of(ar(t,256*1024)?.text??"").split(`
299
+ `))if(e.includes('"modelId"'))try{let n=JSON.parse(e).attachment?.identity?.modelId;if(n)return n}catch{}}function Vy(t){let e;for(let i of t)(i.type==="user"||i.type==="assistant")&&(e=i);if(!e)return!1;if(e.type==="user"){try{if(gO(e,t))return!1;let i=e.message?.content,o=typeof i=="string"?i:Array.isArray(i)?i.filter(a=>a&&a.type==="text").map(a=>a.text??"").join(""):"";if(!od(e)&&o.trim()&&qt(o)==="")return!1}catch{}return!0}let r=(Array.isArray(e.message?.content)?e.message.content:[]).filter(i=>i.type==="tool_use").map(i=>i.id);if(r.length===0)return!e.message?.stop_reason||e.message.stop_reason==="tool_use";let s=new Set;for(let i of t){let o=i.message?.content;if(Array.isArray(o))for(let a of o)a.type==="tool_result"&&a.tool_use_id&&s.add(a.tool_use_id)}return r.some(i=>i&&!s.has(i))}function mO(t){let e;for(let s of t)(s.type==="user"||s.type==="assistant")&&(e=s);let n=e?.type==="user"&&!od(e)?e.message?.content:void 0,r=typeof n=="string"?n:Array.isArray(n)?n.filter(s=>s?.type==="text").map(s=>s.text??"").join(""):"";return/^\[Request interrupted by user\b/.test(r.trim())}function gO(t,e){let n=t.message?.content,r=Array.isArray(n)?n.filter(i=>i?.type==="tool_result").map(i=>i.tool_use_id):[];if(r.length===0)return!1;let s=new Set;for(let i of e){let o=i.type==="assistant"?i.message?.content:void 0;if(Array.isArray(o))for(let a of o)a?.type==="tool_use"&&a.name==="SubagentHandback"&&s.add(a.id)}return r.every(i=>s.has(i))}function ta(t){let e=t?.type==="image"?t.source:void 0;return e?.type==="base64"&&e.data?Vo(e.data,e.media_type):""}function Ds(t){return typeof t=="string"?Ie(t):Array.isArray(t)?t.map(e=>{if(typeof e=="string")return Ie(e);let n=e;return typeof n?.text=="string"?Ie(n.text):n?.content!=null?Ds(n.content):ta(n)}).join(`
300
+ `):t==null?"":Ie(JSON.stringify(t))}function Gy(t){let e=t.trim();return!!e&&yO.some(n=>n.exec(e)?.index===0)}function bO(t){return!t.trim()||Gy(t)}function vO(t){return t.replace(wO,"")}function SO(t){let e=/^<command-name>([\s\S]*?)<\/command-name>/.exec(t)?.[1]?.trim();if(!e)return;let n=/<command-args>([\s\S]*?)<\/command-args>/.exec(t)?.[1]?.trim();return n?`${e} ${n}`:e}function qt(t){let e=vO(t).trim();return e?SO(e)??(Gy(e)?"":e):""}function na(t){let e=kO.exec(t.trim());if(e)return{from:e[1],body:EO(e[2].replace(xO,""))}}function EO(t){let e=t.split(`
301
301
  `).filter(r=>r.trim()).map(r=>r.length-r.trimStart().length),n=e.length?Math.min(...e):0;return n?t.split(`
302
302
  `).map(r=>r.slice(n)).join(`
303
- `):t}function zo(t){let e=Vo(t);return e?{type:"user",text:e.body,agent:{from:e.from}}:{type:"user",text:t}}function QC(t){let e=t.message?.content;return typeof e=="string"&&!!Vo(e)}function ZC(t){let e=t.message?.content;return typeof e=="string"&&e.startsWith($y)?e.slice($y.length).trim():void 0}function Zu(t){return t?.type==="text"&&typeof t.text=="string"?Jt(t.text):""}function tO(t){let e=t.message?.content,n=t.type==="attachment"&&t.attachment?.type==="queued_command"?Is(t.attachment.prompt):t.type==="user"&&t.isMeta&&!(Array.isArray(e)&&e.some(s=>s?.type==="tool_result"))?Is(e):"";if(!n.includes("<task-notification>"))return[];let r=[];for(let[,s]of n.matchAll(eO)){let i=/<tool-use-id>([^<]+)<\/tool-use-id>/.exec(s)?.[1],o=/<status>([^<]+)<\/status>/.exec(s)?.[1];if(!i||!o||o==="running")continue;let a=/\bexit(?: code)? (\d+)/.exec(/<summary>([\s\S]*?)<\/summary>/.exec(s)?.[1]??"")?.[1],l=/<output-file>([^<]+)<\/output-file>/.exec(s)?.[1];r.push({type:"task_done",id:i,outcome:o,exit:a===void 0?void 0:Number(a),output:l})}return r}function td(t,e){if(typeof t=="string")return Be(t);if(!t||typeof t!="object")return Be(e);let n=t;if(n.type==="text"&&typeof n.file?.numLines=="number")return Te(n.file.numLines,"line");if(n.type==="image"){let r=Ny(n.file?.originalSize);return r?`image (${r})`:"image"}if(n.type==="pdf"){let r=Ny(n.file?.originalSize);return r?`PDF (${r})`:"PDF"}if(n.type==="parts"&&typeof n.file?.count=="number")return Te(n.file.count,"page");if(n.type==="file_unchanged")return"unchanged since last read";if(n.type==="create"&&typeof n.content=="string")return`created, ${Te(n.content.split(`
304
- `).length,"line")}`;if(n.mode==="content")return Te(n.numLines??0,"line");if(n.mode==="count")return`${Te(n.numMatches??0,"match","matches")} (${Te(n.numFiles??0,"file")})`;if(n.mode==="files_with_matches")return Te(n.numFiles??0,"file");if(Array.isArray(n.structuredPatch)){let r=0,s=0;for(let i of n.structuredPatch)for(let o of i?.lines??[])typeof o=="string"&&(o.startsWith("+")?r++:o.startsWith("-")&&s++);return`+${r} \u2212${s}`}return typeof n.stdout=="string"||typeof n.stderr=="string"?n.backgroundTaskId?"running in background":n.interrupted?"interrupted":Be(n.stdout||n.stderr||"")||"no output":typeof n.code=="number"&&typeof n.codeText=="string"?`${n.code} ${n.codeText}`:typeof n.searchCount=="number"?Te(n.searchCount,"search","searches"):Array.isArray(n.matches)&&typeof n.total_deferred_tools=="number"?Te(n.matches.length,"tool"):Array.isArray(n.newTodos)?Te(n.newTodos.length,"todo"):typeof n.numFiles=="number"?Te(n.numFiles,"file"):Be(e)}function $s(t){return!!t.isMeta}function iO(t){let e;try{e=_C(t,"r")}catch{return""}try{let r=65536;try{r=My(t).size}catch{}let s=(c,f)=>{if(f<=0)return"";let d=Buffer.alloc(f),u=RC(e,d,0,f,c);return d.subarray(0,u).toString("utf8")},i=(c,f,d)=>{let u="";for(let p of c.split(`
305
- `)){if(!p.includes(`"${f}"`))continue;let h;try{h=JSON.parse(p)}catch{continue}let m=h?.[d];h?.type===f&&typeof m=="string"&&m&&(u=m)}return u},o=s(0,Math.min(65536,r)),a=r>65536?s(r-65536,65536):"",l=i(a,"custom-title","customTitle")||i(o,"custom-title","customTitle")||i(a,"ai-title","aiTitle")||i(o,"ai-title","aiTitle");if(l)return l.replace(/\s+/g," ").trim().slice(0,200);for(let c of o.split(`
306
- `)){if(!c.trim())continue;let f;try{f=JSON.parse(c)}catch{continue}if(!f||$s(f)||f.type!=="user")continue;let d=f.message?.content,u="";typeof d=="string"?u=Jt(d):Array.isArray(d)&&(u=d.map(Zu).filter(Boolean).join(" "));let p=u.replace(/\s+/g," ").trim();if(p)return(p.replace(/^Continuing from a prior session\. Here is the summary of our work so far:\s*/i,"").trim()||p).slice(0,200)}return""}finally{IC(e)}}function Ns(t){let e=mn(t,"sessions"),n;try{n=Dy(e)}catch{return[]}let r=[];for(let s of n)if(s.endsWith(".json"))try{let i=JSON.parse(By(mn(e,s),"utf8"));if(!i?.sessionId)continue;process.kill(i.pid,0),r.push(i)}catch{}return r}function Ly(t,e){return Ns(t).some(n=>n.sessionId===e)}function oO(t,e){let n=Ns(t).filter(r=>r.sessionId===e).map(r=>r.startedAt);return n.length&&n.every(r=>typeof r=="number")?Math.min(...n):void 0}function aO(t){return new Set(Ns(t).filter(e=>e.status==="busy").map(e=>e.sessionId))}var ed,Qu,MC,BC,jC,Iy,WC,HC,VC,GC,$y,eO,nO,rO,sO,Ny,ir,Go=S(()=>{"use strict";Rs();Ko();Ho();_s();ed=t=>t.type==="user"&&Array.isArray(t.message?.content)&&t.message.content.some(e=>e?.type==="tool_result");Qu=(t,e)=>mn(t,"projects",LC(e)),MC="subagents";BC="general-purpose",jC=[256*1024,4*1024*1024,64*1024*1024],Iy=new Map;WC=[/\[Request interrupted by user\b/i,/\[Tool use was interrupted\]/i,/Claude Code returned an error/i,/\[ede_diagnostic\]/i,/^No response requested\.?$/i,/^<task-notification\b/i,/^<system-reminder\b/i,/^<local-command-stdout\b/i,/^<local-command-stderr\b/i];HC=/<ide_[a-z_]+>[\s\S]*?<\/ide_[a-z_]+>/gi;VC=/^(?:[^\n<][^\n]*\n)?<agent-message from="([^"]+)">\n([\s\S]*?)(?:\n?<\/agent-message>[\s\S]*)?$/,GC=/^\[[^\]\n]+\][\s\S]*?The report follows:\n/;$y=`The coordinator sent a message while you were working:
307
- `;eO=/<task-notification>([\s\S]*?)<\/task-notification>/g;nO=/^(Command running in background with ID|Command did not complete within its \d+s timeout and was moved to the background|Async agent launched)/,rO=/\bID: ([A-Za-z0-9]+)/,sO=new Set(["TaskStop","KillShell"]),Ny=t=>typeof t!="number"?"":t<1024?`${t}B`:t<1048576?`${Math.round(t/1024)}KB`:`${(t/1048576).toFixed(1)}MB`;ir=class extends qt{constructor(n=mn(NC(),".claude")){super();this.root=n}displayName="Claude Mirror";detectsSelf(){return process.env.CLAUDECODE==="1"}detectsInstalled(){return $C(this.root)}sessionsDir(n){return Qu(this.root,n)}listSessionFiles(n){return Wo(Qu(this.root,n))}listChildren(n,r){return DC(this.root,n,r)}callerSessionId(){return process.env.CLAUDE_CODE_SESSION_ID||void 0}sessionCwd(n){return Ns(this.root).find(r=>r.sessionId===n)?.cwd}parseEntry(n){try{return JSON.parse(n)}catch{return null}}idOf(n){return n.uuid}parentOf(n){return n.parentUuid}linker(){let n=new Map,r=new Map;return{link(s){if(!s.uuid||n.has(s.uuid))return;let i=s.parentUuid===void 0?void 0:n.get(s.parentUuid),o=s.type==="assistant"?s.message?.id:ed(s)?i:void 0;o&&(i===o&&(s.parentUuid=r.get(o)),n.set(s.uuid,o),r.set(o,s.uuid))}}}timestampOf(n){return n.timestamp}isSidechain(n,r){return!!n.isSidechain!=(r==="child")}isLeafType(n){return n.type==="user"||n.type==="assistant"}isRecoveryNoise(n){return!!n.isApiErrorMessage}apply(n,r){let s=ZC(n);if(s)return{events:[zo(s)]};let i=tO(n);if(i.length)return{events:i};if($s(n)&&!QC(n))return{events:[]};let o=[];if(n.type==="user"){let a=n.message?.content;if(typeof a=="string"){let l=Jt(a);l&&o.push(zo(l))}else if(Array.isArray(a))for(let l of a)if(l?.type==="tool_result"){let c=Is(l.content),f=l.is_error?/^Exit code (\d+)/.exec(c)?.[1]:void 0,d=n.toolUseResult,u=nO.test(c)||!!d&&typeof d=="object"&&!!d.backgroundTaskId;o.push({type:"tool_result",id:l.tool_use_id??"",content:c,isError:!!l.is_error,digest:td(n.toolUseResult,c),exit:f===void 0?void 0:Number(f),background:u||void 0,task:u?rO.exec(c)?.[1]??Z(d?.backgroundTaskId):void 0,output:u?/Output is being written to: (\S.*?)\.?\s*$/m.exec(c)?.[1]:void 0,refused:!!l.is_error&&f===void 0||void 0})}else{let c=Zu(l)||Yo(l);c&&o.push(zo(c))}return{events:o}}if(n.type==="attachment"&&n.attachment?.type==="queued_command"){let a=Jt(Is(n.attachment.prompt));return a&&o.push(zo(a)),{events:o}}if(n.type==="assistant"){let a=n.message?.content,l=Array.isArray(a)?a:[],c=l.filter(h=>h.type==="text").map(h=>h.text??"").filter(h=>!KC(h)).join(""),f=l.filter(h=>h.type==="thinking").map(h=>h.thinking??"").join(`
308
- `),d=l.filter(h=>h.type==="tool_use").map(h=>({id:h.id??"",name:h.name??"",input:h.input??{}}));if(c||f||d.length){let h=Date.parse(n.timestamp??""),m=!isNaN(h)&&h>=r;o.push({type:"assistant",text:c,thinking:f,tools:d,live:m,error:n.isApiErrorMessage||void 0})}(n.message?.stop_reason==="end_turn"||d.some(h=>h.name==="SubagentHandback"))&&o.push({type:"turn_end"});for(let h of d)if(sO.has(h.name)){let m=Z(h.input.task_id)??Z(h.input.shell_id);m&&o.push({type:"task_done",task:m,outcome:"stopped"})}let u=n.message?.usage??n.usage,p=u&&{in:u.input_tokens??0,out:u.output_tokens??0,cached:u.cache_read_input_tokens??0,cacheCreate:u.cache_creation_input_tokens??0};return{events:o,usage:p,model:n.message?.model}}return{events:o}}chainWorking(n){return jy(n)}sessionAlive(n){return Ly(this.root,n)}sessionEnded(n){return!Ly(this.root,n)}sessionsWorking(n){return aO(this.root)}sessionNames(){return new Map(Ns(this.root).filter(n=>n.name).map(n=>[n.sessionId,n.name]))}readPreview(n){return iO(n)}searchText(n){if(!n||$s(n)||n.type!=="user"&&n.type!=="assistant")return"";let r=n.message?.content,s="";if(typeof r=="string")s=Jt(r);else if(Array.isArray(r)){let i=r;s=n.type==="user"?i.map(Zu).filter(Boolean).join(" "):i.filter(o=>o.type==="text"&&typeof o.text=="string").map(o=>o.text).join(" ")}return s.replace(/\s+/g," ").trim()}}});function mt(t,e=!0){let n=[],r=0;for(let s of Ls(t).matchAll(e?/&&|\|\||[;|\n]/g:/&&|\|\||[;\n]/g))n.push({text:t.slice(r,s.index),at:r}),r=s.index+s[0].length;return n.push({text:t.slice(r),at:r}),n.filter(s=>s.text.trim())}function Xo(t){let e=[],n;for(;n=lO.exec(t);)n[1]&&e.push(n[1]),t=t.slice(n[0].length);return{dirs:e,rest:t}}function nd(t){if(/>|\btee\b/.test(Ls(t).replace(/\d?>&\d|\d?>\s*(\/dev\/null|\$null|NUL)\b/gi,"")))return!1;let e=Ms(t);for(;e.length&&(fO.has(e[0])||/^\w+=/.test(e[0]));)e=/^\w+=\$\(/.test(e[0])?[]:e.slice(1);if(!e.length)return!0;let[n,...r]=[e[0].replace(/^["'(]+/,"").toLowerCase(),...e.slice(1)];return n==="npx"&&(r=r.filter(s=>!s.startsWith("-")),n=(r.shift()??"").replace(/@.*$/,"").toLowerCase()),n==="for"?!0:n==="typebulb"?dO.has(r.find(s=>!s.startsWith("-"))??""):n==="git"?uO.has(r.find((s,i)=>!s.startsWith("-")&&!/^-[Cc]$/.test(r[i-1]??""))??""):n==="sed"?!r.some(s=>/^-[a-z]*i|^--in-place/.test(s)):n==="find"?!r.some(s=>/^-(delete|exec|execdir|ok)$/.test(s)):cO.has(n)||/^get-/.test(n)}function Uy(t){let e=[...t.matchAll(/\$\(|`/g)].map(n=>t.slice(n.index+n[0].length));return mt(t).every(n=>nd(n.text))&&e.every(n=>nd(mt(n)[0]?.text??""))}function Jy(t){if(/\bset\s+-\w*o\s+pipefail\b/.test(Ls(t)))return!1;let e=mt(mt(t,!1).at(-1)?.text??"");return e.length>1&&hO.has(Ms(e.at(-1).text)[0]?.toLowerCase()??"")}function rd(t){t=t.replace(mO,(s,i,o,a)=>`<<${i}${o}${i}${a} \u2026 ${o}`);let e=mt(t),n=e.findIndex(s=>!nd(s.text));if(/^\s*(do|then|else|elif)\b/.test(e[n]?.text??""))for(;n>0&&!/^\s*(while|until|for|if)\b/.test(e[n].text);)n--;let r=e[n]?.at??0;return r?`\u2026${t.slice(r).trim()}`:t}function Wy(t){let e=[];for(let n of mt(t)){let r=Ms(n.text),s=r.indexOf("git"),i=r[s+1];if(s<0||i!=="rm"&&i!=="mv"||r.includes("--cached"))continue;let o=r.slice(s+2).filter(l=>!l.startsWith("-"));if(i==="rm"){for(let l of o)e.push({from:l});continue}let a=o.pop();if(a)for(let l of o)e.push({from:l,to:o.length>1?`${a.replace(/\/+$/,"")}/${Cy(l)}`:a})}return e}function Ky(t){let e=zy(t),n=e.map(Yy);return e.length&&n.every(r=>r!==void 0)?n:void 0}function Hy(t){let e=new Map,n=[];for(let r of zy(t)){let s=/^\$([\w:]+)\s*=\s*(['"])([^'"]*)\2$/.exec(r);if(s){e.set(s[1].toLowerCase(),s[3]);continue}let i=Yy(r.replace(/^\$[\w:]+\s*=\s*/,"")),o=i&&/^\$([\w:]+)$/.exec(i),a=o?e.get(o[1].toLowerCase()):i;a&&!/[*?$]/.test(a)&&n.push(a)}return n}function Yy(t){let[e,...n]=mt(t).map(i=>i.text.trim());if(!e||!n.every(i=>wO.test(i)))return;let r=Ms(e);if(!gO.test(r[0]??""))return;let s=[];for(let i=1;i<r.length;i++){let o=r[i];if(yO.test(o)){i+1<r.length&&s.push(r[++i]);continue}if(bO.test(o)){i++;continue}o.startsWith("-")||/^\d+(,\d+)?p?$/.test(o)||s.push(o)}return s.length===1?s[0]:void 0}var Ls,Ms,lO,cO,uO,dO,fO,pO,qy,hO,mO,gO,yO,bO,wO,zy,sd=S(()=>{"use strict";_s();Ls=t=>t.replace(/'[^']*'|"(?:\\.|[^"\\])*"/g,e=>"_".repeat(e.length));Ms=t=>(t.trim().match(/"[^"]*"|'[^']*'|\S+/g)??[]).map(e=>/^(['"])(.*)\1$/.exec(e)?.[2]??e),lO=/^\s*(?:(?:cd|set-location)\s+(?:-(?:literal)?path\s+)?("[^"]*"|'[^']*'|[^\s;&]+)|export\s+PATH=\S+)\s*(?:;|&&)\s*/i;cO=new Set(["grep","egrep","fgrep","rg","cat","head","tail","less","ls","wc","find","date","echo","printf","pwd","which","sort","uniq","cut","tr","awk","jq","stat","file","diff","basename","dirname","realpath","cd","pushd","popd","export","set","true","test","[","seq","ps","tasklist","time","select-string","test-path","measure-object","select-object","where-object","sort-object","format-table","format-list","write-output","write-host"]),uO=new Set(["log","status","diff","show","blame","rev-parse","ls-files","grep","branch","remote"]),dO=new Set(["status","logs","get","models","slug","predict"]),fO=new Set(["if","then","else","elif","fi","do","done","while","until","!","{","}","(",")"]);pO=new Set(["grep","egrep","fgrep","rg","findstr","select-string"]),qy=t=>pO.has(Ms(mt(t).at(-1)?.text??"")[0]?.toLowerCase()??""),hO=new Set(["tail","head","grep","egrep","fgrep","rg","sed","awk","sort","uniq","wc","cut","tr","tee","cat","less","findstr"]);mO=/<<-?\s*(['"]?)(\w+)\1([^\n]*)\n[\s\S]*?\n\s*\2\b/g;gO=/^(Get-Content|gc|cat|type|nl|bat|sed|head|tail)$/i,yO=/^-(Path|LiteralPath)$/i,bO=/^-(Encoding|TotalCount|Head|Tail|ReadCount|Delimiter)$/i,wO=/^(sed -n|head|tail|Select-Object|select)(\s|$)/i;zy=t=>mt(t,!1).map(e=>e.text.trim())});import{spawn as vO,execFile as SO}from"child_process";import{promisify as kO}from"util";import{randomBytes as Gy}from"crypto";async function EO(){let t;try{t=(await xO("codex",["app-server","daemon","version"],{shell:!0,timeout:Xy})).stdout}catch(n){let r=n,s=(r.stderr||r.message||"").trim().split(`
309
- `).at(-1);throw new Error(r.code==="ENOENT"?"the codex CLI is not on PATH":`the codex CLI could not report its app server (${s})`)}let e;try{e=JSON.parse(t)}catch{throw new Error(`the codex CLI's daemon report was not JSON: ${t.trim().slice(0,120)}`)}if(e.status!=="running")throw new Error(`no shared Codex app server is running (daemon status: ${e.status??"unknown"})`);if(!e.managedCodexPath||!e.socketPath)throw new Error("the codex CLI named no daemon binary or socket");return{exe:e.managedCodexPath,socket:e.socketPath}}function Vy(t){let e=Buffer.from(t),n=Gy(4),r=e.length,s=r<126?Buffer.from([129,128|r]):r<65536?Buffer.from([129,254,r>>8,r&255]):Buffer.concat([Buffer.from([129,255]),(()=>{let i=Buffer.alloc(8);return i.writeBigUInt64BE(BigInt(r)),i})()]);return Buffer.concat([s,n,Buffer.from(e.map((i,o)=>i^n[o%4]))])}async function Qy(){let t=await EO(),e=new id(vO(t.exe,["app-server","proxy","--sock",t.socket],{stdio:["pipe","pipe","pipe"]}));return await e.call("initialize",{clientInfo:{name:"typebulb",version:"1"}}),e.notify("initialized"),e}async function od(){let t=await Qy();try{return(await t.call("thread/loaded/list",{})).data??[]}finally{t.close()}}async function Zy(t,e,n){let r=await Qy();try{await r.call("turn/start",{threadId:t,input:[],toolOutput:{name:e,output:n},turnTrigger:"typebulb"})}finally{r.close()}}var xO,Xy,id,eb=S(()=>{"use strict";xO=kO(SO),Xy=15e3;id=class{constructor(e){this.proc=e;let n,r;this.#u=new Promise((s,i)=>{n=s,r=i}),e.stderr.on("data",s=>{this.#n+=s}),e.stdout.on("data",s=>this.#c(s,n,r)),e.on("error",s=>{r(new Error(`could not reach the Codex app server socket: ${s.message}`));for(let i of this.#t.values())i({error:{message:"connection closed"}})}),e.stdin.on("error",()=>{}),e.on("exit",()=>{let s=this.#n.trim().split(`
303
+ `):t}function ea(t){let e=na(t);return e?{type:"user",text:e.body,agent:{from:e.from}}:{type:"user",text:t}}function AO(t){let e=t.message?.content;return typeof e=="string"&&!!na(e)}function TO(t){let e=t.message?.content;return typeof e=="string"&&e.startsWith(Jy)?e.slice(Jy.length).trim():void 0}function id(t){return t?.type==="text"&&typeof t.text=="string"?qt(t.text):""}function OO(t){let e=t.message?.content,n=t.type==="attachment"&&t.attachment?.type==="queued_command"?Ds(t.attachment.prompt):t.type==="user"&&t.isMeta&&!(Array.isArray(e)&&e.some(s=>s?.type==="tool_result"))?Ds(e):"";if(!n.includes("<task-notification>"))return[];let r=[];for(let[,s]of n.matchAll(CO)){let i=/<tool-use-id>([^<]+)<\/tool-use-id>/.exec(s)?.[1],o=/<status>([^<]+)<\/status>/.exec(s)?.[1];if(!i||!o||o==="running")continue;let a=/\bexit(?: code)? (\d+)/.exec(/<summary>([\s\S]*?)<\/summary>/.exec(s)?.[1]??"")?.[1],c=/<output-file>([^<]+)<\/output-file>/.exec(s)?.[1];r.push({type:"task_done",id:i,outcome:o,exit:a===void 0?void 0:Number(a),output:c})}return r}function ad(t,e){if(typeof t=="string")return Fe(t);if(!t||typeof t!="object")return Fe(e);let n=t;if(n.type==="text"&&typeof n.file?.numLines=="number")return Oe(n.file.numLines,"line");if(n.type==="image"){let r=Wy(n.file?.originalSize);return r?`image (${r})`:"image"}if(n.type==="pdf"){let r=Wy(n.file?.originalSize);return r?`PDF (${r})`:"PDF"}if(n.type==="parts"&&typeof n.file?.count=="number")return Oe(n.file.count,"page");if(n.type==="file_unchanged")return"unchanged since last read";if(n.type==="create"&&typeof n.content=="string")return`created, ${Oe(n.content.split(`
304
+ `).length,"line")}`;if(n.mode==="content")return Oe(n.numLines??0,"line");if(n.mode==="count")return`${Oe(n.numMatches??0,"match","matches")} (${Oe(n.numFiles??0,"file")})`;if(n.mode==="files_with_matches")return Oe(n.numFiles??0,"file");if(Array.isArray(n.structuredPatch)){let r=0,s=0;for(let i of n.structuredPatch)for(let o of i?.lines??[])typeof o=="string"&&(o.startsWith("+")?r++:o.startsWith("-")&&s++);return`+${r} \u2212${s}`}return typeof n.stdout=="string"||typeof n.stderr=="string"?n.backgroundTaskId?"running in background":n.interrupted?"interrupted":Fe(n.stdout||n.stderr||"")||"no output":typeof n.code=="number"&&typeof n.codeText=="string"?`${n.code} ${n.codeText}`:typeof n.searchCount=="number"?Oe(n.searchCount,"search","searches"):Array.isArray(n.matches)&&typeof n.total_deferred_tools=="number"?Oe(n.matches.length,"tool"):Array.isArray(n.newTodos)?Oe(n.newTodos.length,"todo"):typeof n.numFiles=="number"?Oe(n.numFiles,"file"):Fe(e)}function Bs(t){return!!t.isMeta}function IO(t){let e;try{e=rO(t,"r")}catch{return""}try{let r=65536;try{r=Hy(t).size}catch{}let s=(l,f)=>{if(f<=0)return"";let u=Buffer.alloc(f),d=sO(e,u,0,f,l);return u.subarray(0,d).toString("utf8")},i=(l,f,u)=>{let d="";for(let p of l.split(`
305
+ `)){if(!p.includes(`"${f}"`))continue;let h;try{h=JSON.parse(p)}catch{continue}let m=h?.[u];h?.type===f&&typeof m=="string"&&m&&(d=m)}return d},o=s(0,Math.min(65536,r)),a=r>65536?s(r-65536,65536):"",c=i(a,"custom-title","customTitle")||i(o,"custom-title","customTitle")||i(a,"ai-title","aiTitle")||i(o,"ai-title","aiTitle");if(c)return c.replace(/\s+/g," ").trim().slice(0,200);for(let l of o.split(`
306
+ `)){if(!l.trim())continue;let f;try{f=JSON.parse(l)}catch{continue}if(!f||Bs(f)||f.type!=="user")continue;let u=f.message?.content,d="";typeof u=="string"?d=qt(u):Array.isArray(u)&&(d=u.map(id).filter(Boolean).join(" "));let p=d.replace(/\s+/g," ").trim();if(p)return(p.replace(/^Continuing from a prior session\. Here is the summary of our work so far:\s*/i,"").trim()||p).slice(0,200)}return""}finally{iO(e)}}function js(t){let e=yn(t,"sessions"),n;try{n=zy(e)}catch{return[]}let r=[];for(let s of n)if(s.endsWith(".json"))try{let i=JSON.parse(Yy(yn(e,s),"utf8"));if(!i?.sessionId)continue;process.kill(i.pid,0),r.push(i)}catch{}return r}function Ky(t,e){return js(t).some(n=>n.sessionId===e)}function $O(t,e){let n=js(t).filter(r=>r.sessionId===e).map(r=>r.startedAt);return n.length&&n.every(r=>typeof r=="number")?Math.min(...n):void 0}function NO(t){return new Set(js(t).filter(e=>e.status==="busy").map(e=>e.sessionId))}var od,sd,lO,dO,fO,qy,yO,wO,kO,xO,Jy,CO,PO,_O,RO,Wy,cr,ra=k(()=>{"use strict";Ms();Qo();Zo();or();od=t=>t.type==="user"&&Array.isArray(t.message?.content)&&t.message.content.some(e=>e?.type==="tool_result");sd=(t,e)=>yn(t,"projects",cO(e)),lO="subagents";dO="general-purpose",fO=[256*1024,4*1024*1024,64*1024*1024],qy=new Map;yO=[/\[Request interrupted by user\b/i,/\[Tool use was interrupted\]/i,/Claude Code returned an error/i,/\[ede_diagnostic\]/i,/^No response requested\.?$/i,/^<task-notification\b/i,/^<system-reminder\b/i,/^<local-command-stdout\b/i,/^<local-command-stderr\b/i];wO=/<ide_[a-z_]+>[\s\S]*?<\/ide_[a-z_]+>/gi;kO=/^(?:[^\n<][^\n]*\n)?<agent-message from="([^"]+)">\n([\s\S]*?)(?:\n?<\/agent-message>[\s\S]*)?$/,xO=/^\[[^\]\n]+\][\s\S]*?The report follows:\n/;Jy=`The coordinator sent a message while you were working:
307
+ `;CO=/<task-notification>([\s\S]*?)<\/task-notification>/g;PO=/^(Command running in background with ID|Command did not complete within its \d+s timeout and was moved to the background|Async agent launched)/,_O=/\bID: ([A-Za-z0-9]+)/,RO=new Set(["TaskStop","KillShell"]),Wy=t=>typeof t!="number"?"":t<1024?`${t}B`:t<1048576?`${Math.round(t/1024)}KB`:`${(t/1048576).toFixed(1)}MB`;cr=class extends Ut{constructor(n=yn(aO(),".claude")){super();this.root=n}displayName="Claude Mirror";detectsSelf(){return process.env.CLAUDECODE==="1"}detectsInstalled(){return oO(this.root)}sessionsDir(n){return sd(this.root,n)}listSessionFiles(n){return Xo(sd(this.root,n))}listChildren(n,r){return uO(this.root,n,r)}callerSessionId(){return process.env.CLAUDE_CODE_SESSION_ID||void 0}sessionCwd(n){return js(this.root).find(r=>r.sessionId===n)?.cwd}parseEntry(n){try{return JSON.parse(n)}catch{return null}}idOf(n){return n.uuid}parentOf(n){return n.parentUuid}logicalParentOf(n){return n.logicalParentUuid}linker(){let n=new Map,r=new Map;return{link(s){if(!s.uuid||n.has(s.uuid))return;let i=s.parentUuid===void 0?void 0:n.get(s.parentUuid),o=s.type==="assistant"?s.message?.id:od(s)?i:void 0;o&&(i===o&&(s.parentUuid=r.get(o)),n.set(s.uuid,o),r.set(o,s.uuid))}}}timestampOf(n){return n.timestamp}isSidechain(n,r){return!!n.isSidechain!=(r==="child")}isLeafType(n){return n.type==="user"||n.type==="assistant"}isRecoveryNoise(n){return!!n.isApiErrorMessage}apply(n,r){let s=TO(n);if(s)return{events:[ea(s)]};let i=OO(n);if(i.length)return{events:i};if(Bs(n)&&!AO(n))return{events:[]};let o=[];if(n.type==="user"){let a=n.message?.content;if(typeof a=="string"){let c=qt(a);c&&o.push(ea(c))}else if(Array.isArray(a))for(let c of a)if(c?.type==="tool_result"){let l=Ds(c.content),f=c.is_error?/^Exit code (\d+)/.exec(l)?.[1]:void 0,u=n.toolUseResult,d=PO.test(l)||!!u&&typeof u=="object"&&!!u.backgroundTaskId;o.push({type:"tool_result",id:c.tool_use_id??"",content:l,isError:!!c.is_error,digest:ad(n.toolUseResult,l),exit:f===void 0?void 0:Number(f),background:d||void 0,task:d?_O.exec(l)?.[1]??te(u?.backgroundTaskId):void 0,output:d?/Output is being written to: (\S.*?)\.?\s*$/m.exec(l)?.[1]:void 0,refused:!!c.is_error&&f===void 0||void 0})}else{let l=id(c)||ta(c);l&&o.push(ea(l))}return{events:o}}if(n.type==="attachment"&&n.attachment?.type==="queued_command"){let a=qt(Ds(n.attachment.prompt));return a&&o.push(ea(a)),{events:o}}if(n.type==="assistant"){let a=n.message?.content,c=Array.isArray(a)?a:[],l=c.filter(h=>h.type==="text").map(h=>h.text??"").filter(h=>!bO(h)).join(""),f=c.filter(h=>h.type==="thinking").map(h=>h.thinking??"").join(`
308
+ `),u=c.filter(h=>h.type==="tool_use").map(h=>({id:h.id??"",name:h.name??"",input:h.input??{}}));if(l||f||u.length){let h=Date.parse(n.timestamp??""),m=!isNaN(h)&&h>=r;o.push({type:"assistant",text:l,thinking:f,tools:u,live:m,error:n.isApiErrorMessage||void 0})}(n.message?.stop_reason==="end_turn"||u.some(h=>h.name==="SubagentHandback"))&&o.push({type:"turn_end"});for(let h of u)if(RO.has(h.name)){let m=te(h.input.task_id)??te(h.input.shell_id);m&&o.push({type:"task_done",task:m,outcome:"stopped"})}let d=n.message?.usage??n.usage,p=d&&{in:d.input_tokens??0,out:d.output_tokens??0,cached:d.cache_read_input_tokens??0,cacheCreate:d.cache_creation_input_tokens??0};return{events:o,usage:p,model:n.message?.model}}return{events:o}}chainWorking(n){return Vy(n)}sessionAlive(n){return Ky(this.root,n)}sessionEnded(n){return!Ky(this.root,n)}sessionsWorking(n){return NO(this.root)}sessionNames(){return new Map(js(this.root).filter(n=>n.name).map(n=>[n.sessionId,n.name]))}readPreview(n){return IO(n)}searchText(n){if(!n||Bs(n)||n.type!=="user"&&n.type!=="assistant")return"";let r=n.message?.content,s="";if(typeof r=="string")s=qt(r);else if(Array.isArray(r)){let i=r;s=n.type==="user"?i.map(id).filter(Boolean).join(" "):i.filter(o=>o.type==="text"&&typeof o.text=="string").map(o=>o.text).join(" ")}return s.replace(/\s+/g," ").trim()}}});function gt(t,e=!0){let n=[],r=0;for(let s of Fs(t).matchAll(e?/&&|\|\||[;|\n]/g:/&&|\|\||[;\n]/g))n.push({text:t.slice(r,s.index),at:r}),r=s.index+s[0].length;return n.push({text:t.slice(r),at:r}),n.filter(s=>s.text.trim())}function sa(t){let e=[],n;for(;n=LO.exec(t);)n[1]&&e.push(n[1]),t=t.slice(n[0].length);return{dirs:e,rest:t}}function cd(t){if(/>|\btee\b/.test(Fs(t).replace(/\d?>&\d|\d?>\s*(\/dev\/null|\$null|NUL)\b/gi,"")))return!1;let e=Us(t);for(;e.length&&(jO.has(e[0])||/^\w+=/.test(e[0]));)e=/^\w+=\$\(/.test(e[0])?[]:e.slice(1);if(!e.length)return!0;let[n,...r]=[e[0].replace(/^["'(]+/,"").toLowerCase(),...e.slice(1)];return n==="npx"&&(r=r.filter(s=>!s.startsWith("-")),n=(r.shift()??"").replace(/@.*$/,"").toLowerCase()),n==="for"?!0:n==="typebulb"?BO.has(r.find(s=>!s.startsWith("-"))??""):n==="git"?DO.has(r.find((s,i)=>!s.startsWith("-")&&!/^-[Cc]$/.test(r[i-1]??""))??""):n==="sed"?!r.some(s=>/^-[a-z]*i|^--in-place/.test(s)):n==="find"?!r.some(s=>/^-(delete|exec|execdir|ok)$/.test(s)):MO.has(n)||/^get-/.test(n)}function Xy(t){let e=[...t.matchAll(/\$\(|`/g)].map(n=>t.slice(n.index+n[0].length));return gt(t).every(n=>cd(n.text))&&e.every(n=>cd(gt(n)[0]?.text??""))}function Zy(t){if(/\bset\s+-\w*o\s+pipefail\b/.test(Fs(t)))return!1;let e=gt(gt(t,!1).at(-1)?.text??"");return e.length>1&&UO.has(Us(e.at(-1).text)[0]?.toLowerCase()??"")}function ld(t){t=t.replace(qO,(s,i,o,a)=>`<<${i}${o}${i}${a} \u2026 ${o}`);let e=gt(t),n=e.findIndex(s=>!cd(s.text));if(/^\s*(do|then|else|elif)\b/.test(e[n]?.text??""))for(;n>0&&!/^\s*(while|until|for|if)\b/.test(e[n].text);)n--;let r=e[n]?.at??0;return r?`\u2026${t.slice(r).trim()}`:t}function eb(t){let e=[];for(let n of gt(t)){let r=Us(n.text),s=r.indexOf("git"),i=r[s+1];if(s<0||i!=="rm"&&i!=="mv"||r.includes("--cached"))continue;let o=r.slice(s+2).filter(c=>!c.startsWith("-"));if(i==="rm"){for(let c of o)e.push({from:c});continue}let a=o.pop();if(a)for(let c of o)e.push({from:c,to:o.length>1?`${a.replace(/\/+$/,"")}/${Dy(c)}`:a})}return e}function tb(t){let e=rb(t),n=e.map(sb);return e.length&&n.every(r=>r!==void 0)?n:void 0}function nb(t){let e=new Map,n=[];for(let r of rb(t)){let s=/^\$([\w:]+)\s*=\s*(['"])([^'"]*)\2$/.exec(r);if(s){e.set(s[1].toLowerCase(),s[3]);continue}let i=sb(r.replace(/^\$[\w:]+\s*=\s*/,"")),o=i&&/^\$([\w:]+)$/.exec(i),a=o?e.get(o[1].toLowerCase()):i;a&&!/[*?$]/.test(a)&&n.push(a)}return n}function sb(t){let[e,...n]=gt(t).map(i=>i.text.trim());if(!e||!n.every(i=>HO.test(i)))return;let r=Us(e);if(!JO.test(r[0]??""))return;let s=[];for(let i=1;i<r.length;i++){let o=r[i];if(WO.test(o)){i+1<r.length&&s.push(r[++i]);continue}if(KO.test(o)){i++;continue}o.startsWith("-")||/^\d+(,\d+)?p?$/.test(o)||s.push(o)}return s.length===1?s[0]:void 0}var Fs,Us,LO,MO,DO,BO,jO,FO,Qy,UO,qO,JO,WO,KO,HO,rb,ud=k(()=>{"use strict";or();Fs=t=>t.replace(/'[^']*'|"(?:\\.|[^"\\])*"/g,e=>"_".repeat(e.length));Us=t=>(t.trim().match(/"[^"]*"|'[^']*'|\S+/g)??[]).map(e=>/^(['"])(.*)\1$/.exec(e)?.[2]??e),LO=/^\s*(?:(?:cd|set-location)\s+(?:-(?:literal)?path\s+)?("[^"]*"|'[^']*'|[^\s;&]+)|export\s+PATH=\S+)\s*(?:;|&&)\s*/i;MO=new Set(["grep","egrep","fgrep","rg","cat","head","tail","less","ls","wc","find","date","echo","printf","pwd","which","sort","uniq","cut","tr","awk","jq","stat","file","diff","basename","dirname","realpath","cd","pushd","popd","export","set","true","test","[","seq","ps","tasklist","time","select-string","test-path","measure-object","select-object","where-object","sort-object","format-table","format-list","write-output","write-host"]),DO=new Set(["log","status","diff","show","blame","rev-parse","ls-files","grep","branch","remote"]),BO=new Set(["status","logs","get","models","slug","predict"]),jO=new Set(["if","then","else","elif","fi","do","done","while","until","!","{","}","(",")"]);FO=new Set(["grep","egrep","fgrep","rg","findstr","select-string"]),Qy=t=>FO.has(Us(gt(t).at(-1)?.text??"")[0]?.toLowerCase()??""),UO=new Set(["tail","head","grep","egrep","fgrep","rg","sed","awk","sort","uniq","wc","cut","tr","tee","cat","less","findstr"]);qO=/<<-?\s*(['"]?)(\w+)\1([^\n]*)\n[\s\S]*?\n\s*\2\b/g;JO=/^(Get-Content|gc|cat|type|nl|bat|sed|head|tail)$/i,WO=/^-(Path|LiteralPath)$/i,KO=/^-(Encoding|TotalCount|Head|Tail|ReadCount|Delimiter)$/i,HO=/^(sed -n|head|tail|Select-Object|select)(\s|$)/i;rb=t=>gt(t,!1).map(e=>e.text.trim())});import{spawn as zO,execFile as YO}from"child_process";import{promisify as VO}from"util";import{randomBytes as ob}from"crypto";async function XO(){let t;try{t=(await GO("codex",["app-server","daemon","version"],{shell:!0,timeout:ab})).stdout}catch(n){let r=n,s=(r.stderr||r.message||"").trim().split(`
309
+ `).at(-1);throw new Error(r.code==="ENOENT"?"the codex CLI is not on PATH":`the codex CLI could not report its app server (${s})`)}let e;try{e=JSON.parse(t)}catch{throw new Error(`the codex CLI's daemon report was not JSON: ${t.trim().slice(0,120)}`)}if(e.status!=="running")throw new Error(`no shared Codex app server is running (daemon status: ${e.status??"unknown"})`);if(!e.managedCodexPath||!e.socketPath)throw new Error("the codex CLI named no daemon binary or socket");return{exe:e.managedCodexPath,socket:e.socketPath}}function ib(t){let e=Buffer.from(t),n=ob(4),r=e.length,s=r<126?Buffer.from([129,128|r]):r<65536?Buffer.from([129,254,r>>8,r&255]):Buffer.concat([Buffer.from([129,255]),(()=>{let i=Buffer.alloc(8);return i.writeBigUInt64BE(BigInt(r)),i})()]);return Buffer.concat([s,n,Buffer.from(e.map((i,o)=>i^n[o%4]))])}async function cb(){let t=await XO(),e=new dd(zO(t.exe,["app-server","proxy","--sock",t.socket],{stdio:["pipe","pipe","pipe"]}));return await e.call("initialize",{clientInfo:{name:"typebulb",version:"1"}}),e.notify("initialized"),e}async function fd(){let t=await cb();try{return(await t.call("thread/loaded/list",{})).data??[]}finally{t.close()}}async function lb(t,e,n){let r=await cb();try{await r.call("turn/start",{threadId:t,input:[],toolOutput:{name:e,output:n},turnTrigger:"typebulb"})}finally{r.close()}}var GO,ab,dd,ub=k(()=>{"use strict";GO=VO(YO),ab=15e3;dd=class{constructor(e){this.proc=e;let n,r;this.#c=new Promise((s,i)=>{n=s,r=i}),e.stderr.on("data",s=>{this.#n+=s}),e.stdout.on("data",s=>this.#o(s,n,r)),e.on("error",s=>{r(new Error(`could not reach the Codex app server socket: ${s.message}`));for(let i of this.#t.values())i({error:{message:"connection closed"}})}),e.stdin.on("error",()=>{}),e.on("exit",()=>{let s=this.#n.trim().split(`
310
310
  `).filter(i=>i.trim()).join(" ").slice(0,300);r(new Error(`could not reach the Codex app server socket${s?`: ${s}`:""}`));for(let i of this.#t.values())i({error:{message:"connection closed"}})}),e.stdin.write(`GET / HTTP/1.1\r
311
311
  Host: localhost\r
312
312
  Upgrade: websocket\r
313
313
  Connection: Upgrade\r
314
- Sec-WebSocket-Key: ${Gy(16).toString("base64")}\r
314
+ Sec-WebSocket-Key: ${ob(16).toString("base64")}\r
315
315
  Sec-WebSocket-Version: 13\r
316
316
  \r
317
- `)}#t=new Map;#o=1;#e=Buffer.alloc(0);#s=!1;#u;#n="";#c(e,n,r){if(this.#e=Buffer.concat([this.#e,e]),!this.#s){let s=this.#e.indexOf(`\r
317
+ `)}#t=new Map;#s=1;#e=Buffer.alloc(0);#r=!1;#c;#n="";#o(e,n,r){if(this.#e=Buffer.concat([this.#e,e]),!this.#r){let s=this.#e.indexOf(`\r
318
318
  \r
319
319
  `);if(s<0)return;let i=this.#e.subarray(0,s).toString().split(`\r
320
- `)[0]??"";if(!/^HTTP\/1\.[01] 101\b/.test(i)){r(new Error(`the Codex app server refused the connection: ${i}`)),this.proc.kill();return}this.#s=!0,this.#e=this.#e.subarray(s+4),n()}for(;;){if(this.#e.length<2)return;let s=this.#e[1]&127,i=2;if(s===126){if(this.#e.length<4)return;s=this.#e.readUInt16BE(2),i=4}else if(s===127){if(this.#e.length<10)return;s=Number(this.#e.readBigUInt64BE(2)),i=10}if(this.#e.length<i+s)return;let o=this.#e[0]&15,a=this.#e.subarray(i,i+s).toString();if(this.#e=this.#e.subarray(i+s),o===1)try{let l=JSON.parse(a);l.id!==void 0&&!l.method&&this.#t.has(l.id)&&(this.#t.get(l.id)(l),this.#t.delete(l.id))}catch{}}}async call(e,n){await this.#u;let r=this.#o++,s=await new Promise((i,o)=>{let a=setTimeout(()=>{this.#t.delete(r),o(new Error(`no reply to ${e}`))},Xy);this.#t.set(r,l=>{clearTimeout(a),i(l)}),this.proc.stdin.write(Vy(JSON.stringify({jsonrpc:"2.0",id:r,method:e,params:n})))});if(s.error)throw new Error(s.error.message??`${e} failed`);return s.result}notify(e){this.proc.stdin.write(Vy(JSON.stringify({jsonrpc:"2.0",method:e})))}close(){this.proc.kill()}}});import{statSync as Qo,readdirSync as AO,existsSync as TO}from"fs";import{basename as tb,join as ad,resolve as CO}from"path";import{homedir as nb}from"os";function PO(t){let e=t.trimStart();return OO.some(n=>e.startsWith(n))}function or(t,e){return Array.isArray(t)?t.map(n=>typeof n?.text=="string"?e&&PO(n.text)?"":_e(n.text):n?.type==="input_image"&&typeof n.image_url=="string"&&n.image_url.startsWith("data:")?`![image](${n.image_url})`:"").filter(Boolean).join(`
321
- `):""}function _O(t){return typeof t=="string"?_e(t):or(t,!1)}function RO(t,e){let n=e??"",r=LO(n);if(!r.length)return{name:t,input:{script:n}};let s=r.map(i=>ld(i.fn)&&Ds(i.arg)?Ky(String(i.arg.cmd??i.arg.command??"")):void 0);if(s.every(i=>i!==void 0))return{name:"read",input:rb(s.flat().map(i=>["path",i])),pending:{kind:"read"}};if(r.length===1){let{fn:i,arg:o}=r[0];if(i==="apply_patch"&&typeof o=="string"){let{files:a,diff:l}=sb(o);return{name:i,input:new Set(a).size===1?{path:a[0],patch:l}:{patch:l},pending:{kind:"patch",digest:NO(l)}}}return Ds(o)?ld(i)?{name:t,input:$O(o)}:{name:i,input:o}:typeof o=="string"?{name:i,input:{arg:o}}:{name:t,input:{script:n}}}return{name:t,input:rb(r.map(({fn:i,arg:o})=>i==="apply_patch"&&typeof o=="string"?["patch",sb(o).diff]:ld(i)&&Ds(o)?["command",o.cmd??o.command]:[i,o]))}}function $O(t){let e=Object.fromEntries(Object.entries(t).filter(([r])=>r!=="cmd"&&r!=="command"&&!IO.has(r))),n=t.command??t.cmd;return n===void 0?e:{command:n,...e}}function rb(t){let e={};for(let[n,r]of t){let s=n;for(let i=2;s in e;i++)s=`${n} (${i})`;e[s]=r}return e}function NO(t){let e=0,n=0;for(let r of t.split(`
322
- `))r.startsWith("+")&&!r.startsWith("+++")?e++:r.startsWith("-")&&!r.startsWith("---")&&n++;return`+${e} \u2212${n}`}function LO(t){let e=[],n=/tools\.([A-Za-z_$][\w$]*)\s*\(/g;for(let r=n.exec(t);r;r=n.exec(t)){let s=r.index+r[0].length-1,i=ub(t,s);if(i<0)break;e.push({fn:r[1],arg:cb(t.slice(s+1,i).trim(),t)}),n.lastIndex=i+1}return e}function cb(t,e){let n=t[0];if(n==='"'||n==="'"||n==="`")return ea(t,0)===t.length-1?db(t.slice(1,-1)):t;if(n==="{"){for(let r of[t,DO(t)])try{let s=JSON.parse(r);if(Ds(s))return s}catch{}return t}if(/^[A-Za-z_$][\w$]*$/.test(t)){let r=new RegExp(`\\b(?:const|let|var)\\s+${t.replace(/\$/g,"\\$")}\\s*=\\s*`).exec(e);if(r){let s=r.index+r[0].length,i=e[s],o=i==='"'||i==="'"||i==="`"?ea(e,s):i==="{"?ub(e,s):-1;if(o>s)return cb(e.slice(s,o+1),"")}}return t}function ub(t,e){let n=0;for(let r=e;r<t.length;r++){let s=t[r];if(s==='"'||s==="'"||s==="`"){if(r=ea(t,r),r<0)return-1}else if(s==="("||s==="["||s==="{")n++;else if((s===")"||s==="]"||s==="}")&&--n===0)return r}return-1}function ea(t,e){let n=t[e];for(let r=e+1;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===n)return r;return-1}function db(t){return t.replace(/\\(?:u\{([0-9a-fA-F]+)\}|u([0-9a-fA-F]{4})|x([0-9a-fA-F]{2})|([\s\S]))/g,(e,n,r,s,i)=>n||r||s?String.fromCodePoint(parseInt(n||r||s,16)):MO[i]??i)}function DO(t){let e=/[A-Za-z_$][\w$]*(?=\s*:)/y,n=/,(?=\s*[}\]])/y,r="",s="";for(let i=0;i<t.length;i++){let o=t[i];if(o==='"'||o==="'"||o==="`"){let l=ea(t,i);if(l<0)return t;r+=JSON.stringify(db(t.slice(i+1,l))),i=l,s=o;continue}e.lastIndex=i;let a=s==="{"||s===","?e.exec(t):null;if(a){r+=`"${a[0]}"`,i+=a[0].length-1,s='"';continue}n.lastIndex=i,!n.test(t)&&(r+=o,/\s/.test(o)||(s=o))}return r}function sb(t){let e=[],n=[],r=!1;for(let s of t.split(/\r?\n/)){let i=/^\*\*\* (Update|Add|Delete) File: (.+)$/.exec(s);if(i){let o=i[2].trim();e.push(o),n.push(`--- ${i[1]==="Add"?"/dev/null":`a/${o}`}`,`+++ ${i[1]==="Delete"?"/dev/null":`b/${o}`}`),r=!0;continue}if(!/^\*\*\* (Begin|End) Patch$/.test(s)){if(s.startsWith("*** Move to:")){n.push(s);continue}r&&!s.startsWith("@@")&&n.push("@@"),r=!1,n.push(s)}}return r&&n.push("@@"),{files:e,diff:n.join(`
323
- `)}}function BO(t,e){let n=/^Script (completed|failed|running with cell ID (\d+))\nWall time [^\n]*\nOutput:\n([\s\S]*)$/.exec(t);if(!n)return{content:t,isError:!1,digest:Be(t)};let r=n[3].replace(/^\n+/,"").replace(/^Script error:\n/,""),s=n[1]==="failed",i=jO(r),o=i?.exit_code;return i&&(r=i.output,i.exit_code&&(s=!0)),n[2]?{content:r,isError:s,digest:`running (cell ${n[2]})`}:e?.kind==="read"&&!s?{content:r,isError:s,digest:Te(FO(r),"line")}:e?.kind==="patch"&&!s?{content:e.digest,isError:s,digest:e.digest}:{content:r,isError:s,digest:Be(r),exit:o}}function jO(t){if(t.startsWith("{"))try{let e=JSON.parse(t);if(Ds(e)&&typeof e.output=="string")return{output:e.output,exit_code:typeof e.exit_code=="number"?e.exit_code:void 0}}catch{}}function UO(t){if(typeof t=="string"&&t)try{let e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e))return e}catch{}return{arguments:t??""}}function JO(t){let e,n,r;for(let s of qO){let i=Jo(t,s);if(i===void 0)return{};let o=i.text.split(`
324
- `);i.partial&&o.shift();let a;for(let l=o.length-1;l>=0;l--){if(!o[l].trim())continue;let c;try{c=JSON.parse(o[l])}catch{continue}if(a===void 0){let f=Date.parse(c.timestamp??"");Number.isNaN(f)||(a=f)}if(e===void 0&&c.type==="event_msg"){let f=c.payload?.type;f==="task_started"?e=!0:(f==="task_complete"||f==="turn_aborted")&&(e=!1)}if(n===void 0&&c.type==="event_msg"&&c.payload?.type==="token_count"&&c.payload.info?.last_token_usage){let f=fb(c.payload.info.last_token_usage);n=f.in+f.out+f.cached+f.cacheCreate}if(r===void 0&&c.type==="turn_context"&&(r={model:c.payload?.model,effort:c.payload?.effort}),a!==void 0&&e!==void 0&&n!==void 0&&r!==void 0)break}if(a!==void 0)return{ms:a,running:e??!0,tokens:n,turn:r};if(!i.partial)break}return{running:e??!0,tokens:n,turn:r}}function fb(t){return{in:Math.max(0,(t.input_tokens??0)-(t.cached_input_tokens??0)),out:t.output_tokens??0,cached:t.cached_input_tokens??0,cacheCreate:t.cache_write_input_tokens??0}}function ob(t){let n=sr(t,65536);if(n===void 0)return;let r=n.text.indexOf(`
325
- `);if(r<0)return n.bytes>=65536?{cwd:"",subagent:!1}:void 0;try{let s=JSON.parse(n.text.slice(0,r)),i=s?.type==="session_meta"?s.payload:void 0;if(typeof i?.cwd!="string")return{cwd:"",subagent:!1};let o=typeof i.source=="object"?i.source?.subagent:void 0,a=WO(i,o),l=lb(n.text,r),c=a&&!l&&n.bytes>=65536?sr(t,ab):void 0,f=l??(c&&lb(c.text,r)),d=!!a&&!f&&(c??n).bytes<(c?ab:65536);return{cwd:i.cwd,subagent:!!o,id:i.id,spawn:a,turn:f,modelPending:d}}catch{return{cwd:"",subagent:!1}}}function WO(t,e){let n=e?.thread_spawn;if(!n)return;let r=n.parent_thread_id??t.parent_thread_id;if(!(!t.id||!r))return{id:t.id,parent:r,path:n.agent_path??"",role:n.agent_role??void 0,depth:n.depth??1}}function lb(t,e){for(let n of t.slice(e+1).split(`
326
- `))if(n.trim())try{let r=JSON.parse(n);if(r.type==="turn_context"&&typeof r.payload?.model=="string")return{model:r.payload.model,effort:r.payload.effort}}catch{}}var OO,Ds,ld,IO,MO,FO,Zo,ib,cd,ar,qO,ab,ud=S(()=>{"use strict";Rs();Ho();Ko();sd();eb();OO=["<permissions instructions>","<apps_instructions>","<plugins_instructions>","<skills_instructions>","<recommended_plugins>","<environment_context>","<node_repl_review_evidence>","# AGENTS.md instructions for "];Ds=t=>!!t&&typeof t=="object"&&!Array.isArray(t),ld=t=>t==="shell_command"||t==="exec_command",IO=new Set(["max_output_tokens","yield_time_ms","timeout_ms"]);MO={n:`
327
- `,t:" ",r:"\r",b:"\b",f:"\f",v:"\v",0:"\0"};FO=t=>t?t.replace(/\r?\n$/,"").split(`
328
- `).length:0;Zo=t=>{let e=CO(t);return process.platform==="win32"?e.toLowerCase():e},ib=12e4,cd=t=>t.slice(-36),ar=class t extends qt{constructor(n=ad(nb(),".codex","sessions")){super();this.root=n}displayName="Codex Mirror";#t=0;#o;#e=!1;#s;#u=0;#n=new Map;#c=new Map;#a=new Map;#d=new Map;detectsSelf(){return!!process.env.CODEX_THREAD_ID}forRead(){return new t(this.root)}callerSessionId(n){let r=process.env.CODEX_THREAD_ID;return r?this.listSessionFiles(n).find(s=>s.sessionId.endsWith(r))?.sessionId:void 0}async wakeRoute(n){try{return(await od()).includes(cd(n))?{hosted:!0}:{hosted:!1,error:"this Codex session is not hosted by the shared app server, so nothing can wake it"}}catch(r){return{error:r instanceof Error?r.message:String(r)}}}async wake(n,r,s){if(!(await od()).includes(cd(n)))throw new Error("the Codex session is not loaded by its app server now");await Zy(cd(n),r,s)}detectsInstalled(){return TO(ad(nb(),".codex"))}sessionsDir(n){return this.root}listSessionFiles(n){let r=Zo(n),s=[];for(let i of this.#f()){let o=0,a=0;try{let f=Qo(i);if(!f.isFile())continue;o=f.size,a=f.mtimeMs}catch{continue}let l=this.#n.get(i);if(l===void 0){if(l=ob(i),l===void 0)continue;this.#n.set(i,l)}if(l.subagent||Zo(l.cwd)!==r)continue;let c=tb(i,".jsonl");this.#a.set(c,i),s.push({sessionId:c,file:i,mtime:this.#r(i,o,a)})}return s}listChildren(n,r){let s=Zo(n),i=new Map,o;for(let c of this.#f()){let f=0,d=0,u;try{let b=Qo(c);if(!b.isFile())continue;f=b.size,d=b.mtimeMs,u=b.birthtimeMs||void 0}catch{continue}let p=this.#n.get(c);if(p===void 0||p.modelPending){if(p=ob(c),p===void 0)continue;this.#n.set(c,p)}if(tb(c,".jsonl")===r&&(o=p.id),!p.spawn||Zo(p.cwd)!==s)continue;let{running:h,tokens:m,turn:g}=this.#i(c,f,d);i.set(p.spawn.id,{file:c,mtime:this.#r(c,f,d),started:u,running:h,tokens:m,spawn:p.spawn,turn:g??p.turn})}if(!o)return[];let a=(c,f=new Set)=>{if(c.parent===o)return!0;if(f.has(c.id))return!1;f.add(c.id);let d=i.get(c.parent);return d?a(d.spawn,f):!1},l=[];for(let{file:c,mtime:f,started:d,running:u,tokens:p,spawn:h,turn:m}of i.values())a(h)&&l.push({id:h.id,file:c,mtime:f,started:d,tokens:p,label:h.path.split("/").filter(Boolean).pop()??h.path,kind:h.role||void 0,model:m?.model,effort:m?.effort,parentId:i.has(h.parent)?h.parent:void 0,depth:h.depth,stopped:!1,running:u});return l}sessionsWorking(n){let r=new Set,s=Date.now();for(let{sessionId:i,file:o,mtime:a}of this.listSessionFiles(n)){if(s-a>=ib)continue;let l;try{let c=Qo(o);l=this.#i(o,c.size,c.mtimeMs)}catch{continue}l.running&&r.add(i)}return r}#r(n,r,s){return Math.max(s,this.#i(n,r,s).ms??0)}#i(n,r,s){let i=this.#c.get(n);if(i&&i.size===r&&i.mtime===s)return i;let o=JO(n),a={size:r,mtime:s,...o,turn:o.turn??i?.turn};return this.#c.set(n,a),a}#f(){let n=[],r=s=>{try{return AO(s).map(i=>ad(s,i))}catch{return[]}};for(let s of r(this.root))for(let i of r(s))for(let o of r(i))for(let a of r(o))a.endsWith(".jsonl")&&n.push(a);return n}parseEntry(n){let r;try{r=JSON.parse(n)}catch{return null}return!r||typeof r.type!="string"?null:r}idOf(n){return n.ord===void 0&&(this.#l(n),n.ord=String(this.#t++),n.parent=this.#o,this.#o=n.ord),n.ord}#l(n){let r=n.payload;if(n.type==="session_meta"){if(++this.#u===1){let s=typeof r?.source=="object"?r.source?.subagent?.thread_spawn:void 0;this.#s=s?.agent_path,this.#e=!!s}}else this.#u=0,this.#e&&r?.type==="agent_message"&&r.recipient===this.#s&&(this.#e=!1);n.inherited=this.#e}parentOf(n){return n.parent}timestampOf(n){return n.timestamp}isSidechain(n,r){return r==="child"&&!!n.inherited}isLeafType(n){return!0}isRecoveryNoise(n){return!1}apply(n,r){let s=[],i=n.payload;if(!i)return{events:s};let o=()=>{let a=Date.parse(n.timestamp??"");return!isNaN(a)&&a>=r};if(n.type==="response_item"){if(i.type==="message"){if(i.role==="user"){let a=or(i.content,!0).trim();a&&s.push({type:"user",text:a})}else if(i.role==="assistant"){let a=or(i.content,!1);a&&s.push({type:"assistant",text:a,thinking:"",tools:[],live:o()})}return{events:s}}if(i.type==="reasoning"){let a=or(i.summary,!1);return a&&s.push({type:"assistant",text:"",thinking:a,tools:[],live:o()}),{events:s}}if(i.type==="custom_tool_call"||i.type==="function_call"){let a=i.call_id??"",{pending:l,...c}=i.type==="custom_tool_call"?RO(i.name??"",i.input):{name:i.name??"",input:UO(i.arguments)};return l&&this.#d.set(a,l),s.push({type:"assistant",text:"",thinking:"",tools:[{id:a,...c}],live:o()}),{events:s}}if(i.type==="custom_tool_call_output"||i.type==="function_call_output"){let a=i.call_id??"",l=this.#d.get(a);return this.#d.delete(a),s.push({type:"tool_result",id:a,...BO(_O(i.output),l)}),{events:s}}return{events:s}}if(n.type==="event_msg"){if(i.type==="token_count"){let a=i.info?.last_token_usage;return a?{events:s,usage:fb(a)}:{events:s}}return i.type==="task_complete"&&s.push({type:"turn_end"}),{events:s}}return n.type==="turn_context"?{events:s,model:i.model}:{events:s}}chainWorking(n){let r=!1;for(let s of n){if(s.type!=="event_msg")continue;let i=s.payload?.type;i==="task_started"?r=!0:(i==="task_complete"||i==="turn_aborted")&&(r=!1)}return r}sessionAlive(n){let r=this.#a.get(n);if(!r)return;let s;try{let i=Qo(r);s=this.#r(r,i.size,i.mtimeMs)}catch{return}return Date.now()-s<ib}readPreview(n){for(let r of(sr(n,256*1024)?.text??"").split(`
329
- `))if(!(!r.includes('"user_message"')&&!r.includes('"UserMessage"')))try{let s=JSON.parse(r);if(s?.type!=="event_msg")continue;let i=s.payload,a=((i?.type==="user_message"?i.message:i?.type==="item_completed"&&i.item?.type==="UserMessage"?or(i.item.content,!0):void 0)??"").replace(/\s+/g," ").trim();if(a)return a.slice(0,200)}catch{}return""}searchText(n){if(n?.type!=="response_item"||n.payload?.type!=="message")return"";let r=n.payload.role;return r!=="user"&&r!=="assistant"?"":or(n.payload.content,r==="user").replace(/\s+/g," ").trim()}},qO=[64*1024,1024*1024];ab=512*1024});import{realpathSync as KO}from"fs";import{createHash as HO}from"crypto";import{join as ta,resolve as zO}from"path";import{homedir as YO}from"os";function Re(){let t=process.env.TYPEBULB_SERVERS_DIR;return t?ta(t,".."):ta(YO(),".typebulb")}function gt(){pb||(pb=!0,console.error(`${Re()} not writable \u2014 continuing stateless: ports won't stick, caches stay cold, and typebulb logs/wait/send/stop may not see this run`))}function yt(){return process.env.TYPEBULB_SERVERS_DIR||ta(Re(),"servers")}function hb(t){let e=se(t),n=e.slice(e.lastIndexOf("/")+1).replace(/\.bulb\.md$/,"");return ta(Re(),"canvas",`${n}-${Bs(t)}.png`)}function Bs(t){return HO("sha1").update(se(t)).digest("hex").slice(0,8)}function se(t){let e=zO(t),n=e;try{n=KO.native(e)}catch{}return(process.platform==="win32"?n.toLowerCase():n).replace(/\\/g,"/")}function mb(t,e){let n=se(t),r=se(e);return n.startsWith(r.endsWith("/")?r:r+"/")?!n.includes("/node_modules/"):!1}var pb,je=S(()=>{"use strict";pb=!1});import*as bb from"net";import{mkdir as VO,readFile as GO,writeFile as wb}from"fs/promises";import{existsSync as XO}from"fs";import{join as vb}from"path";function xb(){return vb(Re(),"blocks")}function dd(t){return vb(xb(),`${t}.json`)}function ra(t){return new Promise(e=>{let n=bb.createServer();n.once("error",()=>e(!1)),n.listen(t,"127.0.0.1",()=>n.close(()=>e(!0)))})}async function tP(t){for(let e=t;e<65535;e++)if(await ra(e))return e;throw new Error(`No free port found above ${t}`)}async function fd(t){let{listBulbServers:e}=await Promise.resolve().then(()=>(Ie(),Eb)),n=(await e()).find(s=>s.port===t),r=n?` (pid ${n.pid}, ${n.agent?`agent:${n.agent}`:n.file})`:"";console.error(`port ${t} in use${r}`),process.exit(1)}async function sa(t){try{let e=JSON.parse(await GO(dd(t),"utf8"));return e&&typeof e.cwd=="string"?{cwd:e.cwd,slots:e.slots??{},mirrors:e.mirrors??{}}:void 0}catch{return}}async function ia(t,e){try{return await wb(dd(t),JSON.stringify(e,null,2)),!0}catch{return gt(),!1}}async function nP(t){let e=se(t);try{await VO(xb(),{recursive:!0})}catch{return}let n=[];for(let o=0;o<kb;o++)n.push(Sb+o*gn);let r=await Promise.all(n.map(async o=>({base:o,block:await sa(o)})));for(let{base:o,block:a}of r)if(a?.cwd===e)return o;let s={cwd:e,slots:{},mirrors:{}};for(let{base:o,block:a}of r){if(!a)try{return await wb(dd(o),JSON.stringify(s,null,2),{flag:"wx"}),o}catch(l){if((await sa(o))?.cwd===e)return o;l.code!=="EEXIST"&&gt();continue}if(!XO(a.cwd))return await ia(o,s)?o:void 0}let i=r.filter(o=>!!o.block).sort((o,a)=>gb(o.block)-gb(a.block))[0];if(i)return await ia(i.base,s)?i.base:void 0}function gb(t){return Object.values(t.slots).reduce((e,n)=>Math.max(e,n.usedAt??0),0)}async function rP(t,e){let n=await sa(t)??{cwd:"",slots:{},mirrors:{}};if(e.kind==="mirror"){let i=n.mirrors[e.agent];if(i!==void 0)return i;let o=yb(n),a=o.has(0)?ZO:0;for(;a>na&&o.has(a);)a--;return n.mirrors[e.agent]=a,await ia(t,n),a}let r=se(e.file),s=n.slots[r]?.offset;if(s===void 0){let i=yb(n);for(s=na;s<gn&&i.has(s);)s++;if(s>=gn){let o=Object.entries(n.slots).sort((a,l)=>(a[1].usedAt??0)-(l[1].usedAt??0))[0];s=o?o[1].offset:na,o&&delete n.slots[o[0]]}}return n.slots[r]={offset:s,usedAt:Date.now()},await ia(t,n),s}function yb(t){return new Set([...Object.values(t.mirrors),...Object.values(t.slots).map(e=>e.offset)])}async function lr(t,e){let n=await nP(e);return n===void 0?void 0:n+await rP(n,t)}async function yn(t){let e=se(t);for(let n=0;n<kb;n++){let r=await sa(Sb+n*gn);if(r?.cwd===e)return s=>r.slots[se(s)]?.usedAt??0}return()=>0}async function oa(t){if(t.explicit!==void 0)return await ra(t.explicit)||await fd(t.explicit),t.target.kind==="bulb"&&await lr(t.target,t.cwd),{port:t.explicit};let e=await lr(t.target,t.cwd);if(e!==void 0){let r=e-e%gn,s=Date.now()+eP;do{if(await ra(e))return{port:e};await new Promise(i=>setTimeout(i,150))}while(Date.now()<s);for(let i=na;i<gn;i++){let o=r+i;if(o!==e&&await ra(o))return{port:o,note:`(slot ${e} was busy)`}}}return{port:await tP(QO),note:e===void 0?"(no port block available)":"(this project's block was full)"}}var Sb,gn,kb,QO,na,ZO,eP,bn=S(()=>{"use strict";je();Sb=20100,gn=100,kb=19,QO=23e3,na=1,ZO=gn-1,eP=3e3});var Ce,aa=S(()=>{"use strict";Ce="0.62.8"});var Eb={};Li(Eb,{agentViewerCommand:()=>Nb,bulbServerCommand:()=>$b,clearServerLog:()=>yd,findProjectViewer:()=>ua,isAlive:()=>Wt,isMirror:()=>ye,isProjectBulb:()=>kd,isProjectMirror:()=>dr,launchAgentViewer:()=>Us,launchBulbServer:()=>Sn,listBulbServers:()=>G,probePageCount:()=>Ed,readServerLog:()=>Qe,readWaitCursor:()=>ca,recordDenial:()=>Sd,registerServer:()=>vd,relayOpen:()=>xd,runMarker:()=>bd,serverLogPath:()=>ur,serversForBulb:()=>vn,sliceRunLog:()=>wd,startServerLog:()=>Fs,stopBulbServer:()=>cr,stopServer:()=>bt,stopServersForBulb:()=>da,typebulbBinPath:()=>fr,unregisterServer:()=>wn,writeWaitCursor:()=>js});import{spawn as Ab}from"child_process";import{readdir as sP,readFile as Ob,writeFile as Pb,unlink as pd,mkdir as iP}from"fs/promises";import{mkdirSync as _b,writeFileSync as la,appendFileSync as oP,readFileSync as hd}from"fs";import*as $e from"path";import{fileURLToPath as aP}from"url";function md(t){return $e.join(yt(),`${t}.json`)}function ur(t){return $e.join(yt(),`${t}.log`)}function gd(t){return $e.join(yt(),`${t}.wait.json`)}function Rb(t){try{let e=JSON.parse(hd(gd(t),"utf8"));return e.cursors&&typeof e.cursors=="object"?e.cursors:{}}catch{return{}}}function ca(t,e=""){let n=Rb(t)[e];return typeof n=="number"&&Number.isFinite(n)&&n>=0?n:void 0}function js(t,e,n=""){try{_b(yt(),{recursive:!0});let r=Rb(t);r[n]=e,la(gd(t),JSON.stringify({cursors:r}))}catch{}}function Fs(t){let e=ur(t);try{_b(yt(),{recursive:!0}),la(e,"")}catch{return()=>{}}let n=process.stdout.write.bind(process.stdout),r=process.stderr.write.bind(process.stderr),s=0,i=!1,o=a=>{if(!i)try{let l=typeof a=="string"?Buffer.from(a,"utf8"):Buffer.from(a);if(oP(e,l),s+=l.length,s>2*Tb){let c=hd(e),f=c.subarray(Math.max(0,c.length-Tb));la(e,f),s=f.length}}catch{i=!0}};return process.stdout.write=((a,...l)=>(o(a),n(a,...l))),process.stderr.write=((a,...l)=>(o(a),r(a,...l))),()=>{process.stdout.write=n,process.stderr.write=r}}function yd(t){try{la(ur(t),"")}catch{}}function Qe(t,e=0){try{let n=hd(ur(t)),r=e>=0&&e<=n.length?e:0;return{text:n.subarray(r).toString("utf8"),offset:n.length}}catch{return{text:"",offset:0}}}function bd(t){return`\u2500\u2500 run ${t} \u2500\u2500 ${new Date().toTimeString().slice(0,8)}`}function cP(t){let e=lP.exec(t);return e?Number(e[1]):void 0}function wd(t,e){let n=t.split(`
330
- `),r=[];if(n.forEach((o,a)=>{let l=cP(o);l!==void 0&&r.push({id:l,idx:a})}),!r.length)return e==="latest"?t:"";let s=e==="latest"?r[r.length-1]:r.find(o=>o.id===e);if(!s)return"";let i=r.find(o=>o.idx>s.idx);return n.slice(s.idx,i?i.idx:n.length).join(`
331
- `)}function Wt(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}async function vd(t){try{await iP(yt(),{recursive:!0}),await Pb(md(t.pid),JSON.stringify({version:Ce,...t}))}catch{gt()}}async function Sd(t,e){let n=md(t);try{let r=JSON.parse(await Ob(n,"utf8"));if(r.denied===e)return;r.denied=e,await Pb(n,JSON.stringify(r))}catch{}}async function wn(t){await pd(md(t)).catch(()=>{}),await pd(ur(t)).catch(()=>{}),await pd(gd(t)).catch(()=>{})}function ye(t){return t.agent!=null}function dr(t,e){return ye(t)&&t.cwd!=null&&se(t.cwd)===se(e)}function kd(t,e){return!ye(t)&&mb(t.file,e)}async function G(t){let e;try{e=await sP(yt())}catch{return[]}let n=[];return await Promise.all(e.map(async s=>{if(!/^\d+\.json$/.test(s))return;let i=parseInt(s,10),o;try{o=JSON.parse(await Ob($e.join(yt(),s),"utf8"))}catch{await wn(i);return}o&&typeof o.pid=="number"&&Wt(o.pid)?n.push(o):await wn(i)})),(t?n.filter(s=>kd(s,t)):n).sort((s,i)=>s.startedAt-i.startedAt)}async function ua(t,e){return(await G()).find(n=>dr(n,t)&&(e?n.agent===e:!0))}async function xd(t,e){let n=new URL(t).port,r=(await G()).filter(a=>String(a.port)!==n),s=r.filter(a=>dr(a,e)),i=r.filter(a=>kd(a,e)),o=0;for(let a of[...s,...i])try{let l=await fetch(`${a.url}/__open`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:t}),signal:AbortSignal.timeout(2e3)});if(!l.ok)continue;let{opened:c,pages:f}=await l.json();if(c)return{where:"editor",via:a.agent?"the agent mirror":`${$e.basename(a.file)}'s page`};ye(a)&&(o+=f??0)}catch{}return o>0?{where:"external"}:void 0}async function cr(t){try{process.kill(t,"SIGTERM")}catch{}await wn(t)}async function Ed(t){try{let e=await fetch(`${t.url}/__pages`,{signal:AbortSignal.timeout(uP)});if(!e.ok)return;let{pages:n}=await e.json();return typeof n=="number"?n:void 0}catch{return}}async function bt(t,e=ye(t)?"keep":"close"){try{let n=await fetch(`${t.url}/__stop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pages:e}),signal:AbortSignal.timeout(Cb)});if(!n.ok)throw new Error(`/__stop ${n.status}`);let{closed:r=0,stuck:s=0}=await n.json(),i=Date.now()+Cb;for(;Wt(t.pid)&&Date.now()<i;)await Ib(100);return Wt(t.pid)?(await cr(t.pid),"killed"):(await wn(t.pid),{closed:r,stuck:s})}catch{return await cr(t.pid),"killed"}}function vn(t,e){let n=se(e);return t.filter(r=>!ye(r)&&r.pid!==process.pid&&se(r.file)===n)}async function da(t,e){let n=vn(await G(),t);for(let r of n)await bt(r,e!==void 0&&r.port===e?"keep":"close");return n}function dP(t,e,n){(process.platform==="win32"?Ab("cmd",["/c","start","","/b",t,...e],{cwd:n,stdio:"ignore",windowsHide:!0}):Ab(t,e,{cwd:n,detached:!0,stdio:"ignore"})).unref()}function fr(){return $e.join($e.dirname(aP(import.meta.url)),"index.js")}function $b(t,e={}){return{command:process.execPath,args:[fr(),...e.trust?["--trust"]:[],...e.noTrust?["--no-trust"]:[],...e.mode?["--mode",e.mode]:[],...e.watch===!1?["--no-watch"]:[],...e.replace?["--replace",e.replace]:[],t,...e.open===!1?["--no-open"]:[]]}}function Nb(t){return{command:process.execPath,args:[fr(),`agent:${t}`,"--no-open"]}}async function Lb(t,e,n,r){let s=await t();if(s)return s;dP(e.command,e.args,n);let i=Date.now()+2e4;for(;Date.now()<i;){await Ib(150);let o=await t();if(o)return o}throw new Error(`Launched ${r} but it did not register within 20s.`)}async function Sn(t,e={}){let n=e.cwd??process.cwd(),r=$e.resolve(n,t),s=await lr({kind:"bulb",file:r},n),[i]=await da(r,s),o={...e,mode:e.mode??i?.mode};return Lb(async()=>vn(await G(),r)[0],$b(t,o),n,$e.basename(t))}async function Us(t,e=process.cwd()){return Lb(()=>ua(e,t),Nb(t),e,`the ${t} mirror`)}var Tb,lP,Cb,uP,Ib,Ie=S(()=>{"use strict";je();bn();aa();Tb=1e6;lP=/^── run (\d+) ── /;Cb=6e3,uP=500;Ib=t=>new Promise(e=>setTimeout(e,t))});function pr(t){return{...Qp(t),server:t.files.get("server.ts")??""}}function fa(t){return!!t.server&&!t.code}var qs=S(()=>{"use strict";te();te()});function pa(t){let e=/^---[^\n]*\n([\s\S]*?)\n---/.exec(t),n=e?/^\s*name:\s*(.+?)\s*$/m.exec(e[1]):null;return n?n[1].replace(/^["']|["']$/g,""):void 0}function Ad(t){return nr(pa(t)??"bulb")||"bulb"}var Td=S(()=>{"use strict";te()});import{readdirSync as fP,readFileSync as pP,statSync as hP}from"fs";import{join as Mb,basename as mP}from"path";function Bb(t,e,n){if(e>8)return n;let r;try{r=fP(t,{withFileTypes:!0})}catch{return n}for(let s of r)if(s.isDirectory()){if(s.name.startsWith(".")||s.name==="node_modules")continue;Bb(Mb(t,s.name),e+1,n)}else s.isFile()&&s.name.endsWith(".bulb.md")&&n.push(Mb(t,s.name));return n}function gP(t,e){let n,r=!1;try{let s=pP(t,"utf8");n=pa(s.slice(0,1024));let i=Ve(s);r=!!i&&fa(pr(i))}catch{}return{mtime:e,name:n??mP(t).replace(/\.bulb\.md$/,""),serverOnly:r}}function ha(t){let e=new Map,n=Bb(t,0,[]).map(r=>{let s=0;try{s=hP(r).mtimeMs}catch{}let i=s?Db.get(r):void 0,o=i?.mtime===s?i:gP(r,s);return s&&e.set(r,o),{path:r,...o}});return Db=e,n}var Db,jb=S(()=>{"use strict";te();qs();Td();Db=new Map});function hr(t){if(t.server.trim())return"server-side code (server.ts)";let e=t.code;if(/\btb\s*\.\s*fs\b/.test(e)||e.includes("/__fs"))return"the filesystem";if(/\btb\s*\.\s*ai\b/.test(e)||e.includes("/__ai")||t.infer.trim()||/\btb\s*\.\s*infer\b/.test(e))return"AI (your API keys)";if(/\btb\s*\.\s*server\s*\.\s*\w/.test(e)||e.includes("/__api"))return"server-side code (server.ts)"}var ma=S(()=>{"use strict"});import{readFile as yP}from"fs/promises";async function Cd(t){try{let e=Ve(await yP(t,"utf-8"));return e?hr(pr(e)):void 0}catch{return}}var Fb=S(()=>{"use strict";qs();ma()});function Od(t){let e=t.split(""),n=(i,o)=>{for(let a=i;a<o&&a<e.length;a++)e[a]!==`
320
+ `)[0]??"";if(!/^HTTP\/1\.[01] 101\b/.test(i)){r(new Error(`the Codex app server refused the connection: ${i}`)),this.proc.kill();return}this.#r=!0,this.#e=this.#e.subarray(s+4),n()}for(;;){if(this.#e.length<2)return;let s=this.#e[1]&127,i=2;if(s===126){if(this.#e.length<4)return;s=this.#e.readUInt16BE(2),i=4}else if(s===127){if(this.#e.length<10)return;s=Number(this.#e.readBigUInt64BE(2)),i=10}if(this.#e.length<i+s)return;let o=this.#e[0]&15,a=this.#e.subarray(i,i+s).toString();if(this.#e=this.#e.subarray(i+s),o===1)try{let c=JSON.parse(a);c.id!==void 0&&!c.method&&this.#t.has(c.id)&&(this.#t.get(c.id)(c),this.#t.delete(c.id))}catch{}}}async call(e,n){await this.#c;let r=this.#s++,s=await new Promise((i,o)=>{let a=setTimeout(()=>{this.#t.delete(r),o(new Error(`no reply to ${e}`))},ab);this.#t.set(r,c=>{clearTimeout(a),i(c)}),this.proc.stdin.write(ib(JSON.stringify({jsonrpc:"2.0",id:r,method:e,params:n})))});if(s.error)throw new Error(s.error.message??`${e} failed`);return s.result}notify(e){this.proc.stdin.write(ib(JSON.stringify({jsonrpc:"2.0",method:e})))}close(){this.proc.kill()}}});import{statSync as ia,readdirSync as QO,existsSync as ZO}from"fs";import{basename as db,join as pd,resolve as eP}from"path";import{homedir as fb}from"os";function nP(t){let e=t.trimStart();return tP.some(n=>e.startsWith(n))}function lr(t,e){return Array.isArray(t)?t.map(n=>typeof n?.text=="string"?e&&nP(n.text)?"":Ie(n.text):n?.type==="input_image"&&typeof n.image_url=="string"&&n.image_url.startsWith("data:")?`![image](${n.image_url})`:"").filter(Boolean).join(`
321
+ `):""}function rP(t){return typeof t=="string"?Ie(t):lr(t,!1)}function sP(t,e){let n=e??"",r=cP(n);if(!r.length)return{name:t,input:{script:n}};let s=r.map(i=>hd(i.fn)&&qs(i.arg)?tb(String(i.arg.cmd??i.arg.command??"")):void 0);if(s.every(i=>i!==void 0))return{name:"read",input:pb(s.flat().map(i=>["path",i])),pending:{kind:"read"}};if(r.length===1){let{fn:i,arg:o}=r[0];if(i==="apply_patch"&&typeof o=="string"){let{files:a,diff:c}=hb(o);return{name:i,input:new Set(a).size===1?{path:a[0],patch:c}:{patch:c},pending:{kind:"patch",digest:aP(c)}}}return qs(o)?hd(i)?{name:t,input:oP(o)}:{name:i,input:o}:typeof o=="string"?{name:i,input:{arg:o}}:{name:t,input:{script:n}}}return{name:t,input:pb(r.map(({fn:i,arg:o})=>i==="apply_patch"&&typeof o=="string"?["patch",hb(o).diff]:hd(i)&&qs(o)?["command",o.cmd??o.command]:[i,o]))}}function oP(t){let e=Object.fromEntries(Object.entries(t).filter(([r])=>r!=="cmd"&&r!=="command"&&!iP.has(r))),n=t.command??t.cmd;return n===void 0?e:{command:n,...e}}function pb(t){let e={};for(let[n,r]of t){let s=n;for(let i=2;s in e;i++)s=`${n} (${i})`;e[s]=r}return e}function aP(t){let e=0,n=0;for(let r of t.split(`
322
+ `))r.startsWith("+")&&!r.startsWith("+++")?e++:r.startsWith("-")&&!r.startsWith("---")&&n++;return`+${e} \u2212${n}`}function cP(t){let e=[],n=/tools\.([A-Za-z_$][\w$]*)\s*\(/g;for(let r=n.exec(t);r;r=n.exec(t)){let s=r.index+r[0].length-1,i=vb(t,s);if(i<0)break;e.push({fn:r[1],arg:wb(t.slice(s+1,i).trim(),t)}),n.lastIndex=i+1}return e}function wb(t,e){let n=t[0];if(n==='"'||n==="'"||n==="`")return aa(t,0)===t.length-1?Sb(t.slice(1,-1)):t;if(n==="{"){for(let r of[t,uP(t)])try{let s=JSON.parse(r);if(qs(s))return s}catch{}return t}if(/^[A-Za-z_$][\w$]*$/.test(t)){let r=new RegExp(`\\b(?:const|let|var)\\s+${t.replace(/\$/g,"\\$")}\\s*=\\s*`).exec(e);if(r){let s=r.index+r[0].length,i=e[s],o=i==='"'||i==="'"||i==="`"?aa(e,s):i==="{"?vb(e,s):-1;if(o>s)return wb(e.slice(s,o+1),"")}}return t}function vb(t,e){let n=0;for(let r=e;r<t.length;r++){let s=t[r];if(s==='"'||s==="'"||s==="`"){if(r=aa(t,r),r<0)return-1}else if(s==="("||s==="["||s==="{")n++;else if((s===")"||s==="]"||s==="}")&&--n===0)return r}return-1}function aa(t,e){let n=t[e];for(let r=e+1;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===n)return r;return-1}function Sb(t){return t.replace(/\\(?:u\{([0-9a-fA-F]+)\}|u([0-9a-fA-F]{4})|x([0-9a-fA-F]{2})|([\s\S]))/g,(e,n,r,s,i)=>n||r||s?String.fromCodePoint(parseInt(n||r||s,16)):lP[i]??i)}function uP(t){let e=/[A-Za-z_$][\w$]*(?=\s*:)/y,n=/,(?=\s*[}\]])/y,r="",s="";for(let i=0;i<t.length;i++){let o=t[i];if(o==='"'||o==="'"||o==="`"){let c=aa(t,i);if(c<0)return t;r+=JSON.stringify(Sb(t.slice(i+1,c))),i=c,s=o;continue}e.lastIndex=i;let a=s==="{"||s===","?e.exec(t):null;if(a){r+=`"${a[0]}"`,i+=a[0].length-1,s='"';continue}n.lastIndex=i,!n.test(t)&&(r+=o,/\s/.test(o)||(s=o))}return r}function hb(t){let e=[],n=[],r=!1;for(let s of t.split(/\r?\n/)){let i=/^\*\*\* (Update|Add|Delete) File: (.+)$/.exec(s);if(i){let o=i[2].trim();e.push(o),n.push(`--- ${i[1]==="Add"?"/dev/null":`a/${o}`}`,`+++ ${i[1]==="Delete"?"/dev/null":`b/${o}`}`),r=!0;continue}if(!/^\*\*\* (Begin|End) Patch$/.test(s)){if(s.startsWith("*** Move to:")){n.push(s);continue}r&&!s.startsWith("@@")&&n.push("@@"),r=!1,n.push(s)}}return r&&n.push("@@"),{files:e,diff:n.join(`
323
+ `)}}function dP(t,e){let n=/^Script (completed|failed|running with cell ID (\d+))\nWall time [^\n]*\nOutput:\n([\s\S]*)$/.exec(t);if(!n)return{content:t,isError:!1,digest:Fe(t)};let r=n[3].replace(/^\n+/,"").replace(/^Script error:\n/,""),s=n[1]==="failed",i=fP(r),o=i?.exit_code;return i&&(r=i.output,i.exit_code&&(s=!0)),n[2]?{content:r,isError:s,digest:`running (cell ${n[2]})`}:e?.kind==="read"&&!s?{content:r,isError:s,digest:Oe(pP(r),"line")}:e?.kind==="patch"&&!s?{content:e.digest,isError:s,digest:e.digest}:{content:r,isError:s,digest:Fe(r),exit:o}}function fP(t){if(t.startsWith("{"))try{let e=JSON.parse(t);if(qs(e)&&typeof e.output=="string")return{output:e.output,exit_code:typeof e.exit_code=="number"?e.exit_code:void 0}}catch{}}function hP(t){if(typeof t=="string"&&t)try{let e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e))return e}catch{}return{arguments:t??""}}function gP(t){let e,n,r;for(let s of mP){let i=Go(t,s);if(i===void 0)return{};let o=i.text.split(`
324
+ `);i.partial&&o.shift();let a;for(let c=o.length-1;c>=0;c--){if(!o[c].trim())continue;let l;try{l=JSON.parse(o[c])}catch{continue}if(a===void 0){let f=Date.parse(l.timestamp??"");Number.isNaN(f)||(a=f)}if(e===void 0&&l.type==="event_msg"){let f=l.payload?.type;f==="task_started"?e=!0:(f==="task_complete"||f==="turn_aborted")&&(e=!1)}if(n===void 0&&l.type==="event_msg"&&l.payload?.type==="token_count"&&l.payload.info?.last_token_usage){let f=kb(l.payload.info.last_token_usage);n=f.in+f.out+f.cached+f.cacheCreate}if(r===void 0&&l.type==="turn_context"&&(r={model:l.payload?.model,effort:l.payload?.effort}),a!==void 0&&e!==void 0&&n!==void 0&&r!==void 0)break}if(a!==void 0)return{ms:a,running:e??!0,tokens:n,turn:r};if(!i.partial)break}return{running:e??!0,tokens:n,turn:r}}function kb(t){return{in:Math.max(0,(t.input_tokens??0)-(t.cached_input_tokens??0)),out:t.output_tokens??0,cached:t.cached_input_tokens??0,cacheCreate:t.cache_write_input_tokens??0}}function gb(t){let n=ar(t,65536);if(n===void 0)return;let r=n.text.indexOf(`
325
+ `);if(r<0)return n.bytes>=65536?{cwd:"",subagent:!1}:void 0;try{let s=JSON.parse(n.text.slice(0,r)),i=s?.type==="session_meta"?s.payload:void 0;if(typeof i?.cwd!="string")return{cwd:"",subagent:!1};let o=typeof i.source=="object"?i.source?.subagent:void 0,a=yP(i,o),c=bb(n.text,r),l=a&&!c&&n.bytes>=65536?ar(t,yb):void 0,f=c??(l&&bb(l.text,r)),u=!!a&&!f&&(l??n).bytes<(l?yb:65536);return{cwd:i.cwd,subagent:!!o,id:i.id,spawn:a,turn:f,modelPending:u}}catch{return{cwd:"",subagent:!1}}}function yP(t,e){let n=e?.thread_spawn;if(!n)return;let r=n.parent_thread_id??t.parent_thread_id;if(!(!t.id||!r))return{id:t.id,parent:r,path:n.agent_path??"",role:n.agent_role??void 0,depth:n.depth??1}}function bb(t,e){for(let n of t.slice(e+1).split(`
326
+ `))if(n.trim())try{let r=JSON.parse(n);if(r.type==="turn_context"&&typeof r.payload?.model=="string")return{model:r.payload.model,effort:r.payload.effort}}catch{}}var tP,qs,hd,iP,lP,pP,oa,mb,md,ur,mP,yb,gd=k(()=>{"use strict";Ms();Zo();Qo();ud();ub();tP=["<permissions instructions>","<apps_instructions>","<plugins_instructions>","<skills_instructions>","<recommended_plugins>","<environment_context>","<node_repl_review_evidence>","# AGENTS.md instructions for "];qs=t=>!!t&&typeof t=="object"&&!Array.isArray(t),hd=t=>t==="shell_command"||t==="exec_command",iP=new Set(["max_output_tokens","yield_time_ms","timeout_ms"]);lP={n:`
327
+ `,t:" ",r:"\r",b:"\b",f:"\f",v:"\v",0:"\0"};pP=t=>t?t.replace(/\r?\n$/,"").split(`
328
+ `).length:0;oa=t=>{let e=eP(t);return process.platform==="win32"?e.toLowerCase():e},mb=12e4,md=t=>t.slice(-36),ur=class t extends Ut{constructor(n=pd(fb(),".codex","sessions")){super();this.root=n}displayName="Codex Mirror";#t=0;#s;#e=!1;#r;#c=0;#n=new Map;#o=new Map;#l=new Map;#u=new Map;detectsSelf(){return!!process.env.CODEX_THREAD_ID}forRead(){return new t(this.root)}callerSessionId(n){let r=process.env.CODEX_THREAD_ID;return r?this.listSessionFiles(n).find(s=>s.sessionId.endsWith(r))?.sessionId:void 0}async wakeRoute(n){try{return(await fd()).includes(md(n))?{hosted:!0}:{hosted:!1,error:"this Codex session is not hosted by the shared app server, so nothing can wake it"}}catch(r){return{error:r instanceof Error?r.message:String(r)}}}async wake(n,r,s){if(!(await fd()).includes(md(n)))throw new Error("the Codex session is not loaded by its app server now");await lb(md(n),r,s)}detectsInstalled(){return ZO(pd(fb(),".codex"))}sessionsDir(n){return this.root}listSessionFiles(n){let r=oa(n),s=[];for(let i of this.#f()){let o=0,a=0;try{let f=ia(i);if(!f.isFile())continue;o=f.size,a=f.mtimeMs}catch{continue}let c=this.#n.get(i);if(c===void 0){if(c=gb(i),c===void 0)continue;this.#n.set(i,c)}if(c.subagent||oa(c.cwd)!==r)continue;let l=db(i,".jsonl");this.#l.set(l,i),s.push({sessionId:l,file:i,mtime:this.#i(i,o,a)})}return s}listChildren(n,r){let s=oa(n),i=new Map,o;for(let l of this.#f()){let f=0,u=0,d;try{let b=ia(l);if(!b.isFile())continue;f=b.size,u=b.mtimeMs,d=b.birthtimeMs||void 0}catch{continue}let p=this.#n.get(l);if(p===void 0||p.modelPending){if(p=gb(l),p===void 0)continue;this.#n.set(l,p)}if(db(l,".jsonl")===r&&(o=p.id),!p.spawn||oa(p.cwd)!==s)continue;let{running:h,tokens:m,turn:g}=this.#a(l,f,u);i.set(p.spawn.id,{file:l,mtime:this.#i(l,f,u),started:d,running:h,tokens:m,spawn:p.spawn,turn:g??p.turn})}if(!o)return[];let a=(l,f=new Set)=>{if(l.parent===o)return!0;if(f.has(l.id))return!1;f.add(l.id);let u=i.get(l.parent);return u?a(u.spawn,f):!1},c=[];for(let{file:l,mtime:f,started:u,running:d,tokens:p,spawn:h,turn:m}of i.values())a(h)&&c.push({id:h.id,file:l,mtime:f,started:u,tokens:p,label:h.path.split("/").filter(Boolean).pop()??h.path,kind:h.role||void 0,model:m?.model,effort:m?.effort,parentId:i.has(h.parent)?h.parent:void 0,depth:h.depth,stopped:!1,running:d});return c}sessionsWorking(n){let r=new Set,s=Date.now();for(let{sessionId:i,file:o,mtime:a}of this.listSessionFiles(n)){if(s-a>=mb)continue;let c;try{let l=ia(o);c=this.#a(o,l.size,l.mtimeMs)}catch{continue}c.running&&r.add(i)}return r}#i(n,r,s){return Math.max(s,this.#a(n,r,s).ms??0)}#a(n,r,s){let i=this.#o.get(n);if(i&&i.size===r&&i.mtime===s)return i;let o=gP(n),a={size:r,mtime:s,...o,turn:o.turn??i?.turn};return this.#o.set(n,a),a}#f(){let n=[],r=s=>{try{return QO(s).map(i=>pd(s,i))}catch{return[]}};for(let s of r(this.root))for(let i of r(s))for(let o of r(i))for(let a of r(o))a.endsWith(".jsonl")&&n.push(a);return n}parseEntry(n){let r;try{r=JSON.parse(n)}catch{return null}return!r||typeof r.type!="string"?null:r}idOf(n){return n.ord===void 0&&(this.#d(n),n.ord=String(this.#t++),n.parent=this.#s,this.#s=n.ord),n.ord}#d(n){let r=n.payload;if(n.type==="session_meta"){if(++this.#c===1){let s=typeof r?.source=="object"?r.source?.subagent?.thread_spawn:void 0;this.#r=s?.agent_path,this.#e=!!s}}else this.#c=0,this.#e&&r?.type==="agent_message"&&r.recipient===this.#r&&(this.#e=!1);n.inherited=this.#e}parentOf(n){return n.parent}timestampOf(n){return n.timestamp}isSidechain(n,r){return r==="child"&&!!n.inherited}isLeafType(n){return!0}isRecoveryNoise(n){return!1}apply(n,r){let s=[],i=n.payload;if(!i)return{events:s};let o=()=>{let a=Date.parse(n.timestamp??"");return!isNaN(a)&&a>=r};if(n.type==="response_item"){if(i.type==="message"){if(i.role==="user"){let a=lr(i.content,!0).trim();a&&s.push({type:"user",text:a})}else if(i.role==="assistant"){let a=lr(i.content,!1);a&&s.push({type:"assistant",text:a,thinking:"",tools:[],live:o()})}return{events:s}}if(i.type==="reasoning"){let a=lr(i.summary,!1);return a&&s.push({type:"assistant",text:"",thinking:a,tools:[],live:o()}),{events:s}}if(i.type==="custom_tool_call"||i.type==="function_call"){let a=i.call_id??"",{pending:c,...l}=i.type==="custom_tool_call"?sP(i.name??"",i.input):{name:i.name??"",input:hP(i.arguments)};return c&&this.#u.set(a,c),s.push({type:"assistant",text:"",thinking:"",tools:[{id:a,...l}],live:o()}),{events:s}}if(i.type==="custom_tool_call_output"||i.type==="function_call_output"){let a=i.call_id??"",c=this.#u.get(a);return this.#u.delete(a),s.push({type:"tool_result",id:a,...dP(rP(i.output),c)}),{events:s}}return{events:s}}if(n.type==="event_msg"){if(i.type==="token_count"){let a=i.info?.last_token_usage;return a?{events:s,usage:kb(a)}:{events:s}}return i.type==="task_complete"&&s.push({type:"turn_end"}),{events:s}}return n.type==="turn_context"?{events:s,model:i.model}:{events:s}}chainWorking(n){let r=!1;for(let s of n){if(s.type!=="event_msg")continue;let i=s.payload?.type;i==="task_started"?r=!0:(i==="task_complete"||i==="turn_aborted")&&(r=!1)}return r}sessionAlive(n){let r=this.#l.get(n);if(!r)return;let s;try{let i=ia(r);s=this.#i(r,i.size,i.mtimeMs)}catch{return}return Date.now()-s<mb}readPreview(n){for(let r of(ar(n,256*1024)?.text??"").split(`
329
+ `))if(!(!r.includes('"user_message"')&&!r.includes('"UserMessage"')))try{let s=JSON.parse(r);if(s?.type!=="event_msg")continue;let i=s.payload,a=((i?.type==="user_message"?i.message:i?.type==="item_completed"&&i.item?.type==="UserMessage"?lr(i.item.content,!0):void 0)??"").replace(/\s+/g," ").trim();if(a)return a.slice(0,200)}catch{}return""}searchText(n){if(n?.type!=="response_item"||n.payload?.type!=="message")return"";let r=n.payload.role;return r!=="user"&&r!=="assistant"?"":lr(n.payload.content,r==="user").replace(/\s+/g," ").trim()}},mP=[64*1024,1024*1024];yb=512*1024});import{realpathSync as bP}from"fs";import{createHash as wP}from"crypto";import{join as ca,resolve as vP}from"path";import{homedir as SP}from"os";function Ee(){let t=process.env.TYPEBULB_SERVERS_DIR;return t?ca(t,".."):ca(SP(),".typebulb")}function yt(){xb||(xb=!0,console.error(`${Ee()} not writable \u2014 continuing stateless: ports won't stick, caches stay cold, and typebulb logs/wait/send/stop may not see this run`))}function bt(){return process.env.TYPEBULB_SERVERS_DIR||ca(Ee(),"servers")}function Eb(t){let e=ae(t),n=e.slice(e.lastIndexOf("/")+1).replace(/\.bulb\.md$/,"");return ca(Ee(),"canvas",`${n}-${Js(t)}.png`)}function Js(t){return wP("sha1").update(ae(t)).digest("hex").slice(0,8)}function ae(t){let e=vP(t),n=e;try{n=bP.native(e)}catch{}return(process.platform==="win32"?n.toLowerCase():n).replace(/\\/g,"/")}function Ab(t,e){let n=ae(t),r=ae(e);return n.startsWith(r.endsWith("/")?r:r+"/")?!n.includes("/node_modules/"):!1}var xb,Ue=k(()=>{"use strict";xb=!1});import*as Ob from"net";import{mkdir as kP,readFile as xP,writeFile as Pb}from"fs/promises";import{existsSync as EP}from"fs";import{join as _b}from"path";function $b(){return _b(Ee(),"blocks")}function yd(t){return _b($b(),`${t}.json`)}function ua(t){return new Promise(e=>{let n=Ob.createServer();n.once("error",()=>e(!1)),n.listen(t,"127.0.0.1",()=>n.close(()=>e(!0)))})}async function OP(t){for(let e=t;e<65535;e++)if(await ua(e))return e;throw new Error(`No free port found above ${t}`)}async function bd(t){let{listBulbServers:e}=await Promise.resolve().then(()=>($e(),Nb)),n=(await e()).find(s=>s.port===t),r=n?` (pid ${n.pid}, ${n.agent?`agent:${n.agent}`:n.file})`:"";console.error(`port ${t} in use${r}`),process.exit(1)}async function da(t){try{let e=JSON.parse(await xP(yd(t),"utf8"));return e&&typeof e.cwd=="string"?{cwd:e.cwd,slots:e.slots??{},mirrors:e.mirrors??{}}:void 0}catch{return}}async function fa(t,e){try{return await Pb(yd(t),JSON.stringify(e,null,2)),!0}catch{return yt(),!1}}async function PP(t){let e=ae(t);try{await kP($b(),{recursive:!0})}catch{return}let n=[];for(let o=0;o<Ib;o++)n.push(Rb+o*bn);let r=await Promise.all(n.map(async o=>({base:o,block:await da(o)})));for(let{base:o,block:a}of r)if(a?.cwd===e)return o;let s={cwd:e,slots:{},mirrors:{}};for(let{base:o,block:a}of r){if(!a)try{return await Pb(yd(o),JSON.stringify(s,null,2),{flag:"wx"}),o}catch(c){if((await da(o))?.cwd===e)return o;c.code!=="EEXIST"&&yt();continue}if(!EP(a.cwd))return await fa(o,s)?o:void 0}let i=r.filter(o=>!!o.block).sort((o,a)=>Tb(o.block)-Tb(a.block))[0];if(i)return await fa(i.base,s)?i.base:void 0}function Tb(t){return Object.values(t.slots).reduce((e,n)=>Math.max(e,n.usedAt??0),0)}async function _P(t,e){let n=await da(t)??{cwd:"",slots:{},mirrors:{}};if(e.kind==="mirror"){let i=n.mirrors[e.agent];if(i!==void 0)return i;let o=Cb(n),a=o.has(0)?TP:0;for(;a>la&&o.has(a);)a--;return n.mirrors[e.agent]=a,await fa(t,n),a}let r=ae(e.file),s=n.slots[r]?.offset;if(s===void 0){let i=Cb(n);for(s=la;s<bn&&i.has(s);)s++;if(s>=bn){let o=Object.entries(n.slots).sort((a,c)=>(a[1].usedAt??0)-(c[1].usedAt??0))[0];s=o?o[1].offset:la,o&&delete n.slots[o[0]]}}return n.slots[r]={offset:s,usedAt:Date.now()},await fa(t,n),s}function Cb(t){return new Set([...Object.values(t.mirrors),...Object.values(t.slots).map(e=>e.offset)])}async function dr(t,e){let n=await PP(e);return n===void 0?void 0:n+await _P(n,t)}async function wn(t){let e=ae(t);for(let n=0;n<Ib;n++){let r=await da(Rb+n*bn);if(r?.cwd===e)return s=>r.slots[ae(s)]?.usedAt??0}return()=>0}async function pa(t){if(t.explicit!==void 0)return await ua(t.explicit)||await bd(t.explicit),t.target.kind==="bulb"&&await dr(t.target,t.cwd),{port:t.explicit};let e=await dr(t.target,t.cwd);if(e!==void 0){let r=e-e%bn,s=Date.now()+CP;do{if(await ua(e))return{port:e};await new Promise(i=>setTimeout(i,150))}while(Date.now()<s);for(let i=la;i<bn;i++){let o=r+i;if(o!==e&&await ua(o))return{port:o,note:`(slot ${e} was busy)`}}}return{port:await OP(AP),note:e===void 0?"(no port block available)":"(this project's block was full)"}}var Rb,bn,Ib,AP,la,TP,CP,vn=k(()=>{"use strict";Ue();Rb=20100,bn=100,Ib=19,AP=23e3,la=1,TP=bn-1,CP=3e3});var Pe,ha=k(()=>{"use strict";Pe="0.63.1"});var Nb={};qi(Nb,{agentViewerCommand:()=>Wb,bulbServerCommand:()=>Jb,clearServerLog:()=>xd,findProjectViewer:()=>ya,isAlive:()=>Jt,isMirror:()=>we,isProjectBulb:()=>Od,isProjectMirror:()=>hr,launchAgentViewer:()=>Hs,launchBulbServer:()=>xn,listBulbServers:()=>Q,probePageCount:()=>_d,readServerLog:()=>Ze,readWaitCursor:()=>ga,recordDenial:()=>Cd,registerServer:()=>Td,relayOpen:()=>Pd,runMarker:()=>Ed,serverLogPath:()=>pr,serversForBulb:()=>kn,sliceRunLog:()=>Ad,startServerLog:()=>Ks,stopBulbServer:()=>fr,stopServer:()=>wt,stopServersForBulb:()=>ba,typebulbBinPath:()=>mr,unregisterServer:()=>Sn,writeWaitCursor:()=>Ws});import{spawn as Lb}from"child_process";import{readdir as RP,readFile as Bb,writeFile as jb,unlink as wd,mkdir as IP}from"fs/promises";import{mkdirSync as Fb,writeFileSync as ma,appendFileSync as $P,readFileSync as vd}from"fs";import*as Ne from"path";import{fileURLToPath as NP}from"url";function Sd(t){return Ne.join(bt(),`${t}.json`)}function pr(t){return Ne.join(bt(),`${t}.log`)}function kd(t){return Ne.join(bt(),`${t}.wait.json`)}function Ub(t){try{let e=JSON.parse(vd(kd(t),"utf8"));return e.cursors&&typeof e.cursors=="object"?e.cursors:{}}catch{return{}}}function ga(t,e=""){let n=Ub(t)[e];return typeof n=="number"&&Number.isFinite(n)&&n>=0?n:void 0}function Ws(t,e,n=""){try{Fb(bt(),{recursive:!0});let r=Ub(t);r[n]=e,ma(kd(t),JSON.stringify({cursors:r}))}catch{}}function Ks(t){let e=pr(t);try{Fb(bt(),{recursive:!0}),ma(e,"")}catch{return()=>{}}let n=process.stdout.write.bind(process.stdout),r=process.stderr.write.bind(process.stderr),s=0,i=!1,o=a=>{if(!i)try{let c=typeof a=="string"?Buffer.from(a,"utf8"):Buffer.from(a);if($P(e,c),s+=c.length,s>2*Mb){let l=vd(e),f=l.subarray(Math.max(0,l.length-Mb));ma(e,f),s=f.length}}catch{i=!0}};return process.stdout.write=((a,...c)=>(o(a),n(a,...c))),process.stderr.write=((a,...c)=>(o(a),r(a,...c))),()=>{process.stdout.write=n,process.stderr.write=r}}function xd(t){try{ma(pr(t),"")}catch{}}function Ze(t,e=0){try{let n=vd(pr(t)),r=e>=0&&e<=n.length?e:0;return{text:n.subarray(r).toString("utf8"),offset:n.length}}catch{return{text:"",offset:0}}}function Ed(t){return`\u2500\u2500 run ${t} \u2500\u2500 ${new Date().toTimeString().slice(0,8)}`}function MP(t){let e=LP.exec(t);return e?Number(e[1]):void 0}function Ad(t,e){let n=t.split(`
330
+ `),r=[];if(n.forEach((o,a)=>{let c=MP(o);c!==void 0&&r.push({id:c,idx:a})}),!r.length)return e==="latest"?t:"";let s=e==="latest"?r[r.length-1]:r.find(o=>o.id===e);if(!s)return"";let i=r.find(o=>o.idx>s.idx);return n.slice(s.idx,i?i.idx:n.length).join(`
331
+ `)}function Jt(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}async function Td(t){try{await IP(bt(),{recursive:!0}),await jb(Sd(t.pid),JSON.stringify({version:Pe,...t}))}catch{yt()}}async function Cd(t,e){let n=Sd(t);try{let r=JSON.parse(await Bb(n,"utf8"));if(r.denied===e)return;r.denied=e,await jb(n,JSON.stringify(r))}catch{}}async function Sn(t){await wd(Sd(t)).catch(()=>{}),await wd(pr(t)).catch(()=>{}),await wd(kd(t)).catch(()=>{})}function we(t){return t.agent!=null}function hr(t,e){return we(t)&&t.cwd!=null&&ae(t.cwd)===ae(e)}function Od(t,e){return!we(t)&&Ab(t.file,e)}async function Q(t){let e;try{e=await RP(bt())}catch{return[]}let n=[];return await Promise.all(e.map(async s=>{if(!/^\d+\.json$/.test(s))return;let i=parseInt(s,10),o;try{o=JSON.parse(await Bb(Ne.join(bt(),s),"utf8"))}catch{await Sn(i);return}o&&typeof o.pid=="number"&&Jt(o.pid)?n.push(o):await Sn(i)})),(t?n.filter(s=>Od(s,t)):n).sort((s,i)=>s.startedAt-i.startedAt)}async function ya(t,e){return(await Q()).find(n=>hr(n,t)&&(e?n.agent===e:!0))}async function Pd(t,e){let n=new URL(t).port,r=(await Q()).filter(a=>String(a.port)!==n),s=r.filter(a=>hr(a,e)),i=r.filter(a=>Od(a,e)),o=0;for(let a of[...s,...i])try{let c=await fetch(`${a.url}/__open`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:t}),signal:AbortSignal.timeout(2e3)});if(!c.ok)continue;let{opened:l,pages:f}=await c.json();if(l)return{where:"editor",via:a.agent?"the agent mirror":`${Ne.basename(a.file)}'s page`};we(a)&&(o+=f??0)}catch{}return o>0?{where:"external"}:void 0}async function fr(t){try{process.kill(t,"SIGTERM")}catch{}await Sn(t)}async function _d(t){try{let e=await fetch(`${t.url}/__pages`,{signal:AbortSignal.timeout(DP)});if(!e.ok)return;let{pages:n}=await e.json();return typeof n=="number"?n:void 0}catch{return}}async function wt(t,e=we(t)?"keep":"close"){try{let n=await fetch(`${t.url}/__stop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pages:e}),signal:AbortSignal.timeout(Db)});if(!n.ok)throw new Error(`/__stop ${n.status}`);let{closed:r=0,stuck:s=0}=await n.json(),i=Date.now()+Db;for(;Jt(t.pid)&&Date.now()<i;)await qb(100);return Jt(t.pid)?(await fr(t.pid),"killed"):(await Sn(t.pid),{closed:r,stuck:s})}catch{return await fr(t.pid),"killed"}}function kn(t,e){let n=ae(e);return t.filter(r=>!we(r)&&r.pid!==process.pid&&ae(r.file)===n)}async function ba(t,e){let n=kn(await Q(),t);for(let r of n)await wt(r,e!==void 0&&r.port===e?"keep":"close");return n}function BP(t,e,n){(process.platform==="win32"?Lb("cmd",["/c","start","","/b",t,...e],{cwd:n,stdio:"ignore",windowsHide:!0}):Lb(t,e,{cwd:n,detached:!0,stdio:"ignore"})).unref()}function mr(){return Ne.join(Ne.dirname(NP(import.meta.url)),"index.js")}function Jb(t,e={}){return{command:process.execPath,args:[mr(),...e.trust?["--trust"]:[],...e.noTrust?["--no-trust"]:[],...e.mode?["--mode",e.mode]:[],...e.watch===!1?["--no-watch"]:[],...e.replace?["--replace",e.replace]:[],t,...e.open===!1?["--no-open"]:[]]}}function Wb(t){return{command:process.execPath,args:[mr(),`agent:${t}`,"--no-open"]}}async function Kb(t,e,n,r){let s=await t();if(s)return s;BP(e.command,e.args,n);let i=Date.now()+2e4;for(;Date.now()<i;){await qb(150);let o=await t();if(o)return o}throw new Error(`Launched ${r} but it did not register within 20s.`)}async function xn(t,e={}){let n=e.cwd??process.cwd(),r=Ne.resolve(n,t),s=await dr({kind:"bulb",file:r},n),[i]=await ba(r,s),o={...e,mode:e.mode??i?.mode};return Kb(async()=>kn(await Q(),r)[0],Jb(t,o),n,Ne.basename(t))}async function Hs(t,e=process.cwd()){return Kb(()=>ya(e,t),Wb(t),e,`the ${t} mirror`)}var Mb,LP,Db,DP,qb,$e=k(()=>{"use strict";Ue();vn();ha();Mb=1e6;LP=/^── run (\d+) ── /;Db=6e3,DP=500;qb=t=>new Promise(e=>setTimeout(e,t))});function gr(t){return{...ch(t),server:t.files.get("server.ts")??""}}function wa(t){return!!t.server&&!t.code}var zs=k(()=>{"use strict";re();re()});function va(t){let e=/^---[^\n]*\n([\s\S]*?)\n---/.exec(t),n=e?/^\s*name:\s*(.+?)\s*$/m.exec(e[1]):null;return n?n[1].replace(/^["']|["']$/g,""):void 0}function Rd(t){return sr(va(t)??"bulb")||"bulb"}var Id=k(()=>{"use strict";re()});import{readdirSync as jP,readFileSync as FP,statSync as UP}from"fs";import{join as Hb,basename as qP}from"path";function Yb(t,e,n){if(e>8)return n;let r;try{r=jP(t,{withFileTypes:!0})}catch{return n}for(let s of r)if(s.isDirectory()){if(s.name.startsWith(".")||s.name==="node_modules")continue;Yb(Hb(t,s.name),e+1,n)}else s.isFile()&&s.name.endsWith(".bulb.md")&&n.push(Hb(t,s.name));return n}function JP(t,e){let n,r=!1;try{let s=FP(t,"utf8");n=va(s.slice(0,1024));let i=Ge(s);r=!!i&&wa(gr(i))}catch{}return{mtime:e,name:n??qP(t).replace(/\.bulb\.md$/,""),serverOnly:r}}function Sa(t){let e=new Map,n=Yb(t,0,[]).map(r=>{let s=0;try{s=UP(r).mtimeMs}catch{}let i=s?zb.get(r):void 0,o=i?.mtime===s?i:JP(r,s);return s&&e.set(r,o),{path:r,...o}});return zb=e,n}var zb,Vb=k(()=>{"use strict";re();zs();Id();zb=new Map});function yr(t){if(t.server.trim())return"server-side code (server.ts)";let e=t.code;if(/\btb\s*\.\s*fs\b/.test(e)||e.includes("/__fs"))return"the filesystem";if(/\btb\s*\.\s*ai\b/.test(e)||e.includes("/__ai")||t.infer.trim()||/\btb\s*\.\s*infer\b/.test(e))return"AI (your API keys)";if(/\btb\s*\.\s*server\s*\.\s*\w/.test(e)||e.includes("/__api"))return"server-side code (server.ts)"}var ka=k(()=>{"use strict"});import{readFile as WP}from"fs/promises";async function $d(t){try{let e=Ge(await WP(t,"utf-8"));return e?yr(gr(e)):void 0}catch{return}}var Gb=k(()=>{"use strict";zs();ka()});function Nd(t){let e=t.split(""),n=(i,o)=>{for(let a=i;a<o&&a<e.length;a++)e[a]!==`
332
332
  `&&(e[a]=" ")},r=0,s="";for(;r<t.length;){let i=t[r],o=t[r+1];if(i==="/"&&o==="/"){let a=r;for(;a<t.length&&t[a]!==`
333
- `;)a++;n(r,a),r=a}else if(i==="/"&&o==="*"){let a=r+2;for(;a<t.length&&!(t[a]==="*"&&t[a+1]==="/");)a++;n(r,Math.min(a+2,t.length)),r=a+2}else if(i==="/"&&bP.has(s)){let a=r+1,l=!1;for(;a<t.length&&t[a]!==`
334
- `;){let c=t[a];if(c==="\\")a++;else if(c==="[")l=!0;else if(c==="]")l=!1;else if(c==="/"&&!l)break;a++}r=a+1,s="/"}else if(i==='"'||i==="'"){let a=r+1;for(;a<t.length&&t[a]!==i&&t[a]!==`
335
- `;)t[a]==="\\"&&a++,a++;r=a+1,s=i}else if(i==="`"){let a=Ub(t,r);n(r,a),r=a,s="`"}else/\s/.test(i)||(s=i),r++}return e.join("")}function Ub(t,e){let n=e+1,r=0;for(;n<t.length;){let s=t[n];if(s==="\\"){n+=2;continue}if(s==="`"){if(r===0)return n+1;n=Ub(t,n);continue}if(s==="$"&&t[n+1]==="{"){r++,n+=2;continue}if(s==="}"&&r>0){r--,n++;continue}n++}return t.length}var bP,qb=S(()=>{bP=new Set(["","(",",","=",":","[","!","&","|","?",";","{"])});function SP(t){if(/^[./]/.test(t)||/^[a-z][a-z0-9+.-]*:/i.test(t))return;let e=t.split("/");return t.startsWith("@")?e.slice(0,2).join("/"):e[0]}function Jb(t){let e=[];for(let s of vP)for(let i of t.matchAll(s)){let o=SP(i[1]);o&&e.push({root:o,index:i.index??0})}e.sort((s,i)=>s.index-i.index);let n=new Set,r=[];for(let{root:s,index:i}of e)n.has(s)||(n.add(s),r.push({root:s,lineIndex:t.slice(0,i).split(`
336
- `).length-1}));return r}function Wb(t){return Jb(Od(t)).map(e=>e.root)}function Js(t,e){if(!t)return[];let{target:n,dependencies:r}=e,s=(e.lineOffset??1)-1,i=[],o=t.split(`
337
- `),a=Od(t).split(`
338
- `);for(let l=0;l<o.length;l++){let c=a[l],f=l+1+s;for(let d of wP)d.targets.includes(n)&&d.pattern.test(c)&&i.push({type:d.type,severity:"error",message:EP(d.type,f),lineNumber:f,lineContent:o[l]})}return n==="client"&&r&&i.push(...kP(a,o,r,s)),i}function kP(t,e,n,r){let s=new Set(Object.keys(n));return Jb(t.join(`
339
- `)).filter(({root:i})=>!s.has(i)).map(({root:i,lineIndex:o})=>{let a=o+1+r;return{type:"UNDECLARED_IMPORT",severity:"error",message:xP(i,a),lineNumber:a,lineContent:e[o]}})}function xP(t,e){return`Import "${t}" is not declared in config.json dependencies! Found on line ${e}.
333
+ `;)a++;n(r,a),r=a}else if(i==="/"&&o==="*"){let a=r+2;for(;a<t.length&&!(t[a]==="*"&&t[a+1]==="/");)a++;n(r,Math.min(a+2,t.length)),r=a+2}else if(i==="/"&&KP.has(s)){let a=r+1,c=!1;for(;a<t.length&&t[a]!==`
334
+ `;){let l=t[a];if(l==="\\")a++;else if(l==="[")c=!0;else if(l==="]")c=!1;else if(l==="/"&&!c)break;a++}r=a+1,s="/"}else if(i==='"'||i==="'"){let a=r+1;for(;a<t.length&&t[a]!==i&&t[a]!==`
335
+ `;)t[a]==="\\"&&a++,a++;r=a+1,s=i}else if(i==="`"){let a=Xb(t,r);n(r,a),r=a,s="`"}else/\s/.test(i)||(s=i),r++}return e.join("")}function Xb(t,e){let n=e+1,r=0;for(;n<t.length;){let s=t[n];if(s==="\\"){n+=2;continue}if(s==="`"){if(r===0)return n+1;n=Xb(t,n);continue}if(s==="$"&&t[n+1]==="{"){r++,n+=2;continue}if(s==="}"&&r>0){r--,n++;continue}n++}return t.length}var KP,Qb=k(()=>{KP=new Set(["","(",",","=",":","[","!","&","|","?",";","{"])});function YP(t){if(/^[./]/.test(t)||/^[a-z][a-z0-9+.-]*:/i.test(t))return;let e=t.split("/");return t.startsWith("@")?e.slice(0,2).join("/"):e[0]}function Zb(t){let e=[];for(let s of zP)for(let i of t.matchAll(s)){let o=YP(i[1]);o&&e.push({root:o,index:i.index??0})}e.sort((s,i)=>s.index-i.index);let n=new Set,r=[];for(let{root:s,index:i}of e)n.has(s)||(n.add(s),r.push({root:s,lineIndex:t.slice(0,i).split(`
336
+ `).length-1}));return r}function ew(t){return Zb(Nd(t)).map(e=>e.root)}function Ys(t,e){if(!t)return[];let{target:n,dependencies:r}=e,s=(e.lineOffset??1)-1,i=[],o=t.split(`
337
+ `),a=Nd(t).split(`
338
+ `);for(let c=0;c<o.length;c++){let l=a[c],f=c+1+s;for(let u of HP)u.targets.includes(n)&&u.pattern.test(l)&&i.push({type:u.type,severity:"error",message:XP(u.type,f),lineNumber:f,lineContent:o[c]})}return n==="client"&&r&&i.push(...VP(a,o,r,s)),i}function VP(t,e,n,r){let s=new Set(Object.keys(n));return Zb(t.join(`
339
+ `)).filter(({root:i})=>!s.has(i)).map(({root:i,lineIndex:o})=>{let a=o+1+r;return{type:"UNDECLARED_IMPORT",severity:"error",message:GP(i,a),lineNumber:a,lineContent:e[o]}})}function GP(t,e){return`Import "${t}" is not declared in config.json dependencies! Found on line ${e}.
340
340
 
341
341
  **CRITICAL**: Every bare import in code.tsx must be declared in the **config.json** "dependencies" block. A bulb that imports a package it doesn't declare is incomplete \u2014 it won't type-check, its versions aren't pinned, and it can't be reliably re-run or ported to typebulb.com.
342
342
 
@@ -350,7 +350,7 @@ Sec-WebSocket-Version: 13\r
350
350
  }
351
351
  \`\`\`
352
352
 
353
- **Fix:** Add a **config.json** block (or extend the existing one) with a "dependencies" entry for "${t}" \u2014 and for every other bare import in code.tsx. Pin a real version where you can (e.g. "react": "^19.2.7").`}function EP(t,e){return t==="URL_IMPORT"?`Direct URL imports are not supported! Found on line ${e}.
353
+ **Fix:** Add a **config.json** block (or extend the existing one) with a "dependencies" entry for "${t}" \u2014 and for every other bare import in code.tsx. Pin a real version where you can (e.g. "react": "^19.2.7").`}function XP(t,e){return t==="URL_IMPORT"?`Direct URL imports are not supported! Found on line ${e}.
354
354
 
355
355
  **CRITICAL**: Import packages by name only. Do NOT use CDN URLs:
356
356
 
@@ -504,22 +504,22 @@ import { something } from 'module-name'
504
504
  const something = require('module-name') // NOT SUPPORTED!
505
505
  \`\`\`
506
506
 
507
- **Fix:** Replace all \`require()\` calls with ES6 \`import\` statements at the top of the file.`}var kn,xn,wP,vP,ga=S(()=>{qb();kn=["client"],xn=["client","server"],wP=[{type:"DYNAMIC_IMPORT",pattern:/\bimport\s*\(\s*['"`]/,targets:kn},{type:"COMMONJS_REQUIRE",pattern:/\brequire\s*\(\s*['"`]/,targets:xn},{type:"JS_EXTENSION_IMPORT",pattern:/from\s+['"][^'"]*\/[^'"]*\.js['"]/,targets:kn},{type:"URL_IMPORT",pattern:/from\s+['"]https?:\/\//,targets:kn},{type:"VERSION_SPECIFIER_IMPORT",pattern:/from\s+['"][^'"]*@[\d^~]/,targets:kn},{type:"REDUNDANT_TB_DECLARATION",pattern:/declare\s+(const|var|let)\s+tb\b/,targets:xn},{type:"CONST_ENUM",pattern:/\bconst\s+enum\b/,targets:xn},{type:"NAMESPACE_DECLARATION",pattern:/\bnamespace\s+\w+/,targets:xn},{type:"COMMONJS_EXPORT_EQUALS",pattern:/\bexport\s*=/,targets:xn},{type:"COMMONJS_IMPORT_EQUALS",pattern:/\bimport\s+\w+\s*=/,targets:xn},{type:"MODULE_DECLARATION",pattern:/\bmodule\s+\w+\s*\{/,targets:xn},{type:"CSS_FILE_IMPORT",pattern:/(?:from|import)\s+['"][^'"]*\.css['"]/,targets:kn},{type:"NAVIGATION",pattern:/window\.(location\.(reload|assign|replace)\s*\(|open\s*\()/,targets:kn},{type:"NAVIGATION",pattern:/window\.location(\.href)?\s*=[^=]/,targets:kn}],vP=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g]});function Pd(t){let e=Ve(t);if(!e)return t;let n=e.files.get("code.tsx");if(!n)return t;let r=Wb(n);if(!r.length)return t;let s=e.files.get("config.json"),i={};if(s)try{let c=JSON.parse(s);c&&typeof c=="object"&&(i=c)}catch{}let o=i.dependencies&&typeof i.dependencies=="object"?{...i.dependencies}:{},a=r.filter(c=>!(c in o));if(!a.length)return t;for(let c of a)o[c]="latest";i.dependencies=o;let l={name:e.frontmatter.name};for(let[c,f]of e.files){let d=Hp(c);d&&(l[d]=f)}return l.config=JSON.stringify(i,null,2),th(l)}var Kb=S(()=>{"use strict";te();ga()});import{spawn as Hb}from"child_process";import{basename as AP}from"path";function TP(){return process.env.TYPEBULB_EDITOR||"code"}function OP(t,e,n){return n==null?[e]:CP.test(AP(t))?["-g",`${e}:${n}`]:[`+${n}`,e]}function PP(t,e){let n=TP();return{command:n,args:OP(n,t,e)}}function _d(t,e){let{command:n,args:r}=PP(t,e),s=process.platform==="win32"?Hb("cmd.exe",["/d","/s","/c",n,...r],{detached:!0,stdio:"ignore",windowsHide:!0}):Hb(n,r,{detached:!0,stdio:"ignore"});s.on("error",i=>console.error("[typebulb] editor launch failed:",i?.message??i)),s.unref()}var CP,zb=S(()=>{"use strict";CP=/^(code|code-insiders|codium|vscodium|cursor|windsurf)(\.cmd|\.exe)?$/i});import{readFileSync as _P,writeFileSync as RP,mkdirSync as IP,statSync as $P}from"fs";import{join as NP}from"path";function Rd(){return NP(Re(),"trust.json")}function Id(){try{let t=Rd(),e=$P(t).mtimeMs;if(Ws?.mtime!==e){let n=JSON.parse(_P(t,"utf8"));Ws={mtime:e,set:new Set(Array.isArray(n)?n:[])}}return Ws.set}catch{return Ws=void 0,new Set}}function LP(t){try{IP(Re(),{recursive:!0}),RP(Rd(),JSON.stringify([...t])),Ws=void 0}catch(e){throw new Error(`can't write ${Rd()} \u2014 trust not remembered (unwritable home; sandboxed shell?): ${e.message}`)}}function En(t){return Id().has(se(t))}function mr(t,e){let n=new Set(Id()),r=se(t);(e?n.has(r):!n.has(r))||(e?n.add(r):n.delete(r),LP(n))}function $d(){return[...Id()]}var Ws,Ks=S(()=>{"use strict";je()});function yr(t){return(t.includes("://")?t:`http://${t}`).replace(/\/+$/,"")}function Nd(){return zs}async function wt(){let[t,e]=await Promise.all([Vb(),qP()]);return UP([...JP(e),...t],process.env.TB_AI_PROVIDER,process.env.TB_AI_MODEL)}function UP(t,e,n){return!e||!n?t:t.map(r=>r.provider===e&&r.name===n?{...r,default:!0}:r)}async function Yb(){let t;try{t=await fetch(MP,{signal:AbortSignal.timeout(BP)})}catch(e){zs=`catalog fetch failed: ${e?.message??e}`;return}if(!t.ok){zs=`catalog fetch failed: HTTP ${t.status}`;return}try{return await t.json()}catch(e){zs=`catalog returned an unreadable body: ${e?.message??e}`;return}}async function qP(){if(Hs&&Date.now()-Hs.fetchedAt<=DP)return Hs.models;let t=await Yb()??await Yb();return t?(Hs={models:t,fetchedAt:Date.now()},zs=void 0,t):Hs?.models??[]}async function Vb(){if(ya&&Date.now()-ya.fetchedAt<=jP)return ya.models;let t=yr(process.env.OLLAMA_HOST??"http://localhost:11434"),e=[];try{let n=await fetch(new URL("/api/tags",t).toString(),{signal:AbortSignal.timeout(FP)});n.ok&&(e=((await n.json()).models??[]).map(s=>s.name).filter(s=>!!s).map(s=>({provider:"ollama",name:s,friendlyName:s,providerName:"Ollama"})))}catch{}return ya={models:e,fetchedAt:Date.now()},e}function JP(t){let e=new Set(Object.entries(gr).filter(([,n])=>!!process.env[n]).map(([n])=>n));return t.filter(n=>e.has(n.provider))}function Ld(){return Object.values(gr).some(t=>!!process.env[t])}async function ba(){return Ld()||process.env.TB_AI_BASE_URL||(await Vb()).length>0?"own":"none"}function Gb(t,e,n){let r=Math.max(...t.map(o=>o.name.length)),s=Math.max(...t.map(o=>o.friendlyName.length)),i=["Models available to tb.ai (filtered by your .env keys):",""];for(let o of t)i.push(` ${o.name.padEnd(r)} ${o.friendlyName.padEnd(s)} (${o.provider})`);return i.push("","Pass an id as the `model` in tb.ai({ provider, model })."),e&&n&&i.push(`Default (from .env): ${e} / ${n}`),i.join(`
508
- `)}var gr,MP,DP,BP,jP,FP,Hs,ya,zs,An=S(()=>{"use strict";gr={anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY",gemini:"GOOGLE_API_KEY",openrouter:"OPENROUTER_API_KEY"};MP="https://api.typebulb.com/api/models",DP=1440*60*1e3,BP=5e3,jP=60*1e3,FP=1500});var Xb,Qb,lt,Tn=S(()=>{Xb=t=>t!=null&&t>=0&&t<=4?t:void 0,Qb=(t,e)=>{let n={...t};for(let r of["input","output","reasoning","cacheRead"])e[r]!==void 0&&(n[r]=e[r]);return n},lt=t=>t===void 0||t.input===void 0&&t.output===void 0?void 0:{input:t.input??0,output:t.output??0,reasoning:t.reasoning,cacheRead:t.cacheRead}});var Ne,Ze,br=S(()=>{Ne=class extends Error{constructor(e,n="unknown",r=!1){super(e),this.code=n,this.retryable=r}},Ze=class{getPath(e,n){return this.path}parseError(e,n){return this.parseJsonError(e,n)}parseStreamChunk(e){return this.checkAndThrowError(e),this.parseProviderStreamChunk(e)}extractSystemMessages(e,n=`
507
+ **Fix:** Replace all \`require()\` calls with ES6 \`import\` statements at the top of the file.`}var En,An,HP,zP,xa=k(()=>{Qb();En=["client"],An=["client","server"],HP=[{type:"DYNAMIC_IMPORT",pattern:/\bimport\s*\(\s*['"`]/,targets:En},{type:"COMMONJS_REQUIRE",pattern:/\brequire\s*\(\s*['"`]/,targets:An},{type:"JS_EXTENSION_IMPORT",pattern:/from\s+['"][^'"]*\/[^'"]*\.js['"]/,targets:En},{type:"URL_IMPORT",pattern:/from\s+['"]https?:\/\//,targets:En},{type:"VERSION_SPECIFIER_IMPORT",pattern:/from\s+['"][^'"]*@[\d^~]/,targets:En},{type:"REDUNDANT_TB_DECLARATION",pattern:/declare\s+(const|var|let)\s+tb\b/,targets:An},{type:"CONST_ENUM",pattern:/\bconst\s+enum\b/,targets:An},{type:"NAMESPACE_DECLARATION",pattern:/\bnamespace\s+\w+/,targets:An},{type:"COMMONJS_EXPORT_EQUALS",pattern:/\bexport\s*=/,targets:An},{type:"COMMONJS_IMPORT_EQUALS",pattern:/\bimport\s+\w+\s*=/,targets:An},{type:"MODULE_DECLARATION",pattern:/\bmodule\s+\w+\s*\{/,targets:An},{type:"CSS_FILE_IMPORT",pattern:/(?:from|import)\s+['"][^'"]*\.css['"]/,targets:En},{type:"NAVIGATION",pattern:/window\.(location\.(reload|assign|replace)\s*\(|open\s*\()/,targets:En},{type:"NAVIGATION",pattern:/window\.location(\.href)?\s*=[^=]/,targets:En}],zP=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g]});function Ld(t){let e=Ge(t);if(!e)return t;let n=e.files.get("code.tsx");if(!n)return t;let r=ew(n);if(!r.length)return t;let s=e.files.get("config.json"),i={};if(s)try{let l=JSON.parse(s);l&&typeof l=="object"&&(i=l)}catch{}let o=i.dependencies&&typeof i.dependencies=="object"?{...i.dependencies}:{},a=r.filter(l=>!(l in o));if(!a.length)return t;for(let l of a)o[l]="latest";i.dependencies=o;let c={name:e.frontmatter.name};for(let[l,f]of e.files){let u=nh(l);u&&(c[u]=f)}return c.config=JSON.stringify(i,null,2),dh(c)}var tw=k(()=>{"use strict";re();xa()});import{spawn as nw}from"child_process";import{basename as QP}from"path";function ZP(){return process.env.TYPEBULB_EDITOR||"code"}function t_(t,e,n){return n==null?[e]:e_.test(QP(t))?["-g",`${e}:${n}`]:[`+${n}`,e]}function n_(t,e){let n=ZP();return{command:n,args:t_(n,t,e)}}function Md(t,e){let{command:n,args:r}=n_(t,e),s=process.platform==="win32"?nw("cmd.exe",["/d","/s","/c",n,...r],{detached:!0,stdio:"ignore",windowsHide:!0}):nw(n,r,{detached:!0,stdio:"ignore"});s.on("error",i=>console.error("[typebulb] editor launch failed:",i?.message??i)),s.unref()}var e_,rw=k(()=>{"use strict";e_=/^(code|code-insiders|codium|vscodium|cursor|windsurf)(\.cmd|\.exe)?$/i});import{readFileSync as r_,writeFileSync as s_,mkdirSync as i_,statSync as o_}from"fs";import{join as a_}from"path";function Dd(){return a_(Ee(),"trust.json")}function Bd(){try{let t=Dd(),e=o_(t).mtimeMs;if(Vs?.mtime!==e){let n=JSON.parse(r_(t,"utf8"));Vs={mtime:e,set:new Set(Array.isArray(n)?n:[])}}return Vs.set}catch{return Vs=void 0,new Set}}function c_(t){try{i_(Ee(),{recursive:!0}),s_(Dd(),JSON.stringify([...t])),Vs=void 0}catch(e){throw new Error(`can't write ${Dd()} \u2014 trust not remembered (unwritable home; sandboxed shell?): ${e.message}`)}}function Tn(t){return Bd().has(ae(t))}function br(t,e){let n=new Set(Bd()),r=ae(t);(e?n.has(r):!n.has(r))||(e?n.add(r):n.delete(r),c_(n))}function jd(){return[...Bd()]}var Vs,Gs=k(()=>{"use strict";Ue()});function vr(t){return(t.includes("://")?t:`http://${t}`).replace(/\/+$/,"")}function Fd(){return Qs}async function vt(){let[t,e]=await Promise.all([iw(),m_()]);return h_([...g_(e),...t],process.env.TB_AI_PROVIDER,process.env.TB_AI_MODEL)}function h_(t,e,n){return!e||!n?t:t.map(r=>r.provider===e&&r.name===n?{...r,default:!0}:r)}async function sw(){let t;try{t=await fetch(l_,{signal:AbortSignal.timeout(d_)})}catch(e){Qs=`catalog fetch failed: ${e?.message??e}`;return}if(!t.ok){Qs=`catalog fetch failed: HTTP ${t.status}`;return}try{return await t.json()}catch(e){Qs=`catalog returned an unreadable body: ${e?.message??e}`;return}}async function m_(){if(Xs&&Date.now()-Xs.fetchedAt<=u_)return Xs.models;let t=await sw()??await sw();return t?(Xs={models:t,fetchedAt:Date.now()},Qs=void 0,t):Xs?.models??[]}async function iw(){if(Ea&&Date.now()-Ea.fetchedAt<=f_)return Ea.models;let t=vr(process.env.OLLAMA_HOST??"http://localhost:11434"),e=[];try{let n=await fetch(new URL("/api/tags",t).toString(),{signal:AbortSignal.timeout(p_)});n.ok&&(e=((await n.json()).models??[]).map(s=>s.name).filter(s=>!!s).map(s=>({provider:"ollama",name:s,friendlyName:s,providerName:"Ollama"})))}catch{}return Ea={models:e,fetchedAt:Date.now()},e}function g_(t){let e=new Set(Object.entries(wr).filter(([,n])=>!!process.env[n]).map(([n])=>n));return t.filter(n=>e.has(n.provider))}function Ud(){return Object.values(wr).some(t=>!!process.env[t])}async function Aa(){return Ud()||process.env.TB_AI_BASE_URL||(await iw()).length>0?"own":"none"}function ow(t,e,n){let r=Math.max(...t.map(o=>o.name.length)),s=Math.max(...t.map(o=>o.friendlyName.length)),i=["Models available to tb.ai (filtered by your .env keys):",""];for(let o of t)i.push(` ${o.name.padEnd(r)} ${o.friendlyName.padEnd(s)} (${o.provider})`);return i.push("","Pass an id as the `model` in tb.ai({ provider, model })."),e&&n&&i.push(`Default (from .env): ${e} / ${n}`),i.join(`
508
+ `)}var wr,l_,u_,d_,f_,p_,Xs,Ea,Qs,Cn=k(()=>{"use strict";wr={anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY",gemini:"GOOGLE_API_KEY",openrouter:"OPENROUTER_API_KEY"};l_="https://api.typebulb.com/api/models",u_=1440*60*1e3,d_=5e3,f_=60*1e3,p_=1500});var aw,cw,lt,On=k(()=>{aw=t=>t!=null&&t>=0&&t<=4?t:void 0,cw=(t,e)=>{let n={...t};for(let r of["input","output","reasoning","cacheRead"])e[r]!==void 0&&(n[r]=e[r]);return n},lt=t=>t===void 0||t.input===void 0&&t.output===void 0?void 0:{input:t.input??0,output:t.output??0,reasoning:t.reasoning,cacheRead:t.cacheRead}});var Le,et,Sr=k(()=>{Le=class extends Error{constructor(e,n="unknown",r=!1){super(e),this.code=n,this.retryable=r}},et=class{getPath(e,n){return this.path}parseError(e,n){return this.parseJsonError(e,n)}parseStreamChunk(e){return this.checkAndThrowError(e),this.parseProviderStreamChunk(e)}extractSystemMessages(e,n=`
509
509
 
510
- `){let r=e.filter(s=>s.role==="system").map(s=>s.content);return{system:r.length?r.join(n):void 0,conversationMessages:e.filter(s=>s.role!=="system")}}parseJsonError(e,n){if(!e)return{message:`HTTP ${n}`};try{let r=JSON.parse(e);return r.error&&typeof r.error=="object"?{message:r.error.message||`HTTP ${n}`,type:r.error.type}:r.message?{message:r.message}:{message:e}}catch{return{message:e}}}checkAndThrowError(e){if(typeof e!="object"||e===null)return;let n=e;if(n.type==="error"&&"message"in n){let r=n.code||"unknown";throw new Ne(n.message,r,!!n.retryable)}if(n.error){let r=n.error,s=typeof r=="object"&&r!==null?String(r.type??r.code??""):"",i=/rate_limit|too_many_requests/i.test(s),o=/overloaded|server_error|unavailable/i.test(s),a=/context_length/i.test(s);throw new Ne(this.extractErrorMessage(n.error),i?"rate_limit":a?"context_exceeded":"unknown",i||o)}}extractErrorMessage(e){if(typeof e=="string")try{let n=JSON.parse(e);return n.error?.message||n.message||e}catch{return e}return typeof e=="object"&&e!==null?e.message||JSON.stringify(e):`${this.providerName} returned an error`}}});var wa,Md=S(()=>{Tn();br();wa=class extends Ze{constructor(){super(...arguments),this.providerName="OpenAI",this.defaultBaseUrl="https://api.openai.com",this.path="/v1/responses",this.effortMap={0:"none",1:"low",2:"medium",3:"high",4:"xhigh"}}buildHeaders(e){return{Authorization:`Bearer ${e}`,"Content-Type":"application/json",Accept:"application/json"}}buildPayload(e,n,r,s){let i=this.convertMessagesToInput(e),o={model:n,input:i,stream:s};if(r?.webSearch===!0&&(o.tools=[{type:"web_search"}]),r?.effort!==void 0){let a=this.effortMap[r.effort];o.reasoning=a==="none"?{effort:a}:{effort:a,summary:"auto"}}return r?.maxOutputTokens!==void 0&&(o.max_output_tokens=r.maxOutputTokens),o}parseNonStreamingResponse(e){if(!this.isResponsesApiResponse(e))return{text:""};let n=e.output_text||"",r;if(e.output&&Array.isArray(e.output))for(let s of e.output)s.type==="reasoning"&&s.summary&&(r=s.summary.map(i=>i.text).join(`
511
- `)),!n&&s.type==="message"&&s.content&&(n=s.content.filter(i=>i.type==="output_text").map(i=>i.text).join(""));return{text:n,reasoning:r,usage:this.mapUsage(e.usage)}}parseProviderStreamChunk(e){if(this.isResponsesApiEvent(e))switch(e.type){case"response.failed":{let r=e.response?.error,s=r?.message||"Response failed",i=r?.code==="insufficient_quota"||r?.code==="rate_limit_exceeded";throw new Ne(s,i?"rate_limit":"unknown",i)}case"response.output_text.delta":return{text:e.delta};case"response.reasoning_summary_text.delta":return{reasoning:e.delta};case"response.completed":{let n=this.mapUsage(e.response?.usage);return n?{usage:n}:void 0}default:return}}mapUsage(e){if(e)return lt({input:e.input_tokens,output:e.output_tokens,reasoning:e.output_tokens_details?.reasoning_tokens,cacheRead:e.input_tokens_details?.cached_tokens})}convertMessagesToInput(e){return e.map(n=>n.role==="system"?`System: ${n.content}`:n.role==="user"?`User: ${n.content}`:n.role==="assistant"?`Assistant: ${n.content}`:n.content).join(`
510
+ `){let r=e.filter(s=>s.role==="system").map(s=>s.content);return{system:r.length?r.join(n):void 0,conversationMessages:e.filter(s=>s.role!=="system")}}parseJsonError(e,n){if(!e)return{message:`HTTP ${n}`};try{let r=JSON.parse(e);return r.error&&typeof r.error=="object"?{message:r.error.message||`HTTP ${n}`,type:r.error.type}:r.message?{message:r.message}:{message:e}}catch{return{message:e}}}checkAndThrowError(e){if(typeof e!="object"||e===null)return;let n=e;if(n.type==="error"&&"message"in n){let r=n.code||"unknown";throw new Le(n.message,r,!!n.retryable)}if(n.error){let r=n.error,s=typeof r=="object"&&r!==null?String(r.type??r.code??""):"",i=/rate_limit|too_many_requests/i.test(s),o=/overloaded|server_error|unavailable/i.test(s),a=/context_length/i.test(s);throw new Le(this.extractErrorMessage(n.error),i?"rate_limit":a?"context_exceeded":"unknown",i||o)}}extractErrorMessage(e){if(typeof e=="string")try{let n=JSON.parse(e);return n.error?.message||n.message||e}catch{return e}return typeof e=="object"&&e!==null?e.message||JSON.stringify(e):`${this.providerName} returned an error`}}});var Ta,qd=k(()=>{On();Sr();Ta=class extends et{constructor(){super(...arguments),this.providerName="OpenAI",this.defaultBaseUrl="https://api.openai.com",this.path="/v1/responses",this.effortMap={0:"none",1:"low",2:"medium",3:"high",4:"xhigh"}}buildHeaders(e){return{Authorization:`Bearer ${e}`,"Content-Type":"application/json",Accept:"application/json"}}buildPayload(e,n,r,s){let i=this.convertMessagesToInput(e),o={model:n,input:i,stream:s};if(r?.webSearch===!0&&(o.tools=[{type:"web_search"}]),r?.effort!==void 0){let a=this.effortMap[r.effort];o.reasoning=a==="none"?{effort:a}:{effort:a,summary:"auto"}}return r?.maxOutputTokens!==void 0&&(o.max_output_tokens=r.maxOutputTokens),o}parseNonStreamingResponse(e){if(!this.isResponsesApiResponse(e))return{text:""};let n=e.output_text||"",r;if(e.output&&Array.isArray(e.output))for(let s of e.output)s.type==="reasoning"&&s.summary&&(r=s.summary.map(i=>i.text).join(`
511
+ `)),!n&&s.type==="message"&&s.content&&(n=s.content.filter(i=>i.type==="output_text").map(i=>i.text).join(""));return{text:n,reasoning:r,usage:this.mapUsage(e.usage)}}parseProviderStreamChunk(e){if(this.isResponsesApiEvent(e))switch(e.type){case"response.failed":{let r=e.response?.error,s=r?.message||"Response failed",i=r?.code==="insufficient_quota"||r?.code==="rate_limit_exceeded";throw new Le(s,i?"rate_limit":"unknown",i)}case"response.output_text.delta":return{text:e.delta};case"response.reasoning_summary_text.delta":return{reasoning:e.delta};case"response.completed":{let n=this.mapUsage(e.response?.usage);return n?{usage:n}:void 0}default:return}}mapUsage(e){if(e)return lt({input:e.input_tokens,output:e.output_tokens,reasoning:e.output_tokens_details?.reasoning_tokens,cacheRead:e.input_tokens_details?.cached_tokens})}convertMessagesToInput(e){return e.map(n=>n.role==="system"?`System: ${n.content}`:n.role==="user"?`User: ${n.content}`:n.role==="assistant"?`Assistant: ${n.content}`:n.content).join(`
512
512
 
513
- `)}isResponsesApiEvent(e){return typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string"}isResponsesApiResponse(e){return typeof e=="object"&&e!==null&&e.object==="response"}}});var wr,va=S(()=>{Tn();br();wr=class extends Ze{parseNonStreamingResponse(e){if(!this.hasChoices(e))return{text:""};let n=e,r=n.choices[0],s=r?.message,i=s?.content??r?.text??"",o=s?.reasoning??s?.reasoning_content??n.reasoning;return{text:i,reasoning:o,usage:this.mapUsage(n.usage)}}parseProviderStreamChunk(e){if(!this.hasChoices(e))return;let n=e,r=this.mapUsage(n.usage),s=n.choices[0]?.delta||n.choices[0]?.message,i=s?.content||void 0,o=s?.reasoning||s?.reasoning_content||void 0;if(!(!i&&!o&&!r))return{text:i,reasoning:o,usage:r}}hasChoices(e){return typeof e=="object"&&e!==null&&"choices"in e&&Array.isArray(e.choices)}mapUsage(e){if(e)return lt({input:e.prompt_tokens,output:e.completion_tokens,reasoning:e.completion_tokens_details?.reasoning_tokens,cacheRead:e.prompt_tokens_details?.cached_tokens})}}});var Dd,Sa,Bd=S(()=>{va();Dd={"HTTP-Referer":"https://typebulb.com","X-OpenRouter-Title":"Typebulb"},Sa=class extends wr{constructor(){super(...arguments),this.providerName="OpenRouter",this.defaultBaseUrl="https://openrouter.ai",this.path="/api/v1/chat/completions",this.effortMap={0:"none",1:"low",2:"medium",3:"high",4:"xhigh"}}buildHeaders(e){return{Authorization:`Bearer ${e}`,"x-api-key":e,"Content-Type":"application/json",Accept:"application/json",...Dd}}buildPayload(e,n,r,s){let i={model:n,messages:e,stream:s};s&&(i.stream_options={include_usage:!0}),r?.webSearch===!0&&(i.plugins=[{id:"web"}]);let o=r?.effort;return o!==void 0&&(i.reasoning={effort:this.effortMap[o]}),r?.maxOutputTokens!==void 0&&(i.max_tokens=r.maxOutputTokens),i}}});var ka,jd=S(()=>{Tn();br();ka=class extends Ze{constructor(){super(...arguments),this.providerName="Anthropic",this.defaultBaseUrl="https://api.anthropic.com",this.path="/v1/messages"}buildHeaders(e){return{"x-api-key":e,"anthropic-version":"2023-06-01","Content-Type":"application/json",Accept:"application/json"}}buildPayload(e,n,r,s){let{system:i,conversationMessages:o}=this.extractSystemMessages(e),a={model:n,max_tokens:Math.min(this.getMaxTokens(n),r?.maxOutputTokens??1/0),messages:this.withTailMessagesCached(o),stream:s};r?.webSearch===!0&&(a.tools=[{type:"web_search_20250305",name:"web_search"}]),i&&(a.system=[{type:"text",text:i,cache_control:{type:"ephemeral"}}]);let l=r?.effort;if(l!==void 0){if(this.isModernModel(n))if(l===0)this.alwaysThinks(n)||(a.thinking={type:"disabled"}),a.output_config={effort:"low"};else{let c={1:"low",2:"medium",3:"high",4:"max"};a.thinking={type:"adaptive",display:"summarized"},a.output_config={effort:c[l]}}else if(l!==0){let c={1:2048,2:4096,3:8192,4:16384};a.thinking={type:"enabled",budget_tokens:c[l]}}}return a}parseNonStreamingResponse(e){if(!this.isAnthropicResponse(e))return{text:""};let n=e.content.filter(s=>s.type==="text").map(s=>s.text).join(""),r=e.content.filter(s=>s.type==="thinking").map(s=>s.thinking).join(`
513
+ `)}isResponsesApiEvent(e){return typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string"}isResponsesApiResponse(e){return typeof e=="object"&&e!==null&&e.object==="response"}}});var kr,Ca=k(()=>{On();Sr();kr=class extends et{parseNonStreamingResponse(e){if(!this.hasChoices(e))return{text:""};let n=e,r=n.choices[0],s=r?.message,i=s?.content??r?.text??"",o=s?.reasoning??s?.reasoning_content??n.reasoning;return{text:i,reasoning:o,usage:this.mapUsage(n.usage)}}parseProviderStreamChunk(e){if(!this.hasChoices(e))return;let n=e,r=this.mapUsage(n.usage),s=n.choices[0]?.delta||n.choices[0]?.message,i=s?.content||void 0,o=s?.reasoning||s?.reasoning_content||void 0;if(!(!i&&!o&&!r))return{text:i,reasoning:o,usage:r}}hasChoices(e){return typeof e=="object"&&e!==null&&"choices"in e&&Array.isArray(e.choices)}mapUsage(e){if(e)return lt({input:e.prompt_tokens,output:e.completion_tokens,reasoning:e.completion_tokens_details?.reasoning_tokens,cacheRead:e.prompt_tokens_details?.cached_tokens})}}});var Jd,Oa,Wd=k(()=>{Ca();Jd={"HTTP-Referer":"https://typebulb.com","X-OpenRouter-Title":"Typebulb"},Oa=class extends kr{constructor(){super(...arguments),this.providerName="OpenRouter",this.defaultBaseUrl="https://openrouter.ai",this.path="/api/v1/chat/completions",this.effortMap={0:"none",1:"low",2:"medium",3:"high",4:"xhigh"}}buildHeaders(e){return{Authorization:`Bearer ${e}`,"x-api-key":e,"Content-Type":"application/json",Accept:"application/json",...Jd}}buildPayload(e,n,r,s){let i={model:n,messages:e,stream:s};s&&(i.stream_options={include_usage:!0}),r?.webSearch===!0&&(i.plugins=[{id:"web"}]);let o=r?.effort;return o!==void 0&&(i.reasoning={effort:this.effortMap[o]}),r?.maxOutputTokens!==void 0&&(i.max_tokens=r.maxOutputTokens),i}}});var Pa,Kd=k(()=>{On();Sr();Pa=class extends et{constructor(){super(...arguments),this.providerName="Anthropic",this.defaultBaseUrl="https://api.anthropic.com",this.path="/v1/messages"}buildHeaders(e){return{"x-api-key":e,"anthropic-version":"2023-06-01","Content-Type":"application/json",Accept:"application/json"}}buildPayload(e,n,r,s){let{system:i,conversationMessages:o}=this.extractSystemMessages(e),a={model:n,max_tokens:Math.min(this.getMaxTokens(n),r?.maxOutputTokens??1/0),messages:this.withTailMessagesCached(o),stream:s};r?.webSearch===!0&&(a.tools=[{type:"web_search_20250305",name:"web_search"}]),i&&(a.system=[{type:"text",text:i,cache_control:{type:"ephemeral"}}]);let c=r?.effort;if(c!==void 0){if(this.isModernModel(n))if(c===0)this.alwaysThinks(n)||(a.thinking={type:"disabled"}),a.output_config={effort:"low"};else{let l={1:"low",2:"medium",3:"high",4:"max"};a.thinking={type:"adaptive",display:"summarized"},a.output_config={effort:l[c]}}else if(c!==0){let l={1:2048,2:4096,3:8192,4:16384};a.thinking={type:"enabled",budget_tokens:l[c]}}}return a}parseNonStreamingResponse(e){if(!this.isAnthropicResponse(e))return{text:""};let n=e.content.filter(s=>s.type==="text").map(s=>s.text).join(""),r=e.content.filter(s=>s.type==="thinking").map(s=>s.thinking).join(`
514
514
 
515
- `);return{text:n,reasoning:r||void 0,usage:lt(this.mapUsage(e.usage))}}parseProviderStreamChunk(e){if(this.isAnthropicEvent(e))switch(e.type){case"content_block_delta":return e.delta.type==="text_delta"?{text:e.delta.text||""}:e.delta.type==="thinking_delta"?{reasoning:e.delta.thinking||""}:void 0;case"message_start":{let n=this.mapUsage(e.message?.usage);return n?{usage:n}:void 0}case"message_delta":{let n=this.mapUsage(e.usage);return n?{usage:n}:void 0}default:return}}mapUsage(e){if(typeof e!="object"||e===null)return;let n=e,r=c=>typeof c=="number"?c:void 0,s=r(n.input_tokens),i=r(n.cache_read_input_tokens),o=r(n.cache_creation_input_tokens),a=r(n.output_tokens),l=s!==void 0||i!==void 0||o!==void 0?(s??0)+(i??0)+(o??0):void 0;if(!(l===void 0&&a===void 0))return{input:l,output:a,cacheRead:i}}withTailMessagesCached(e){let n=Math.max(0,e.length-2);return e.map((r,s)=>s>=n?{role:r.role,content:[{type:"text",text:r.content,cache_control:{type:"ephemeral"}}]}:r)}isAnthropicResponse(e){return typeof e=="object"&&e!==null&&e.type==="message"&&Array.isArray(e.content)}isAnthropicEvent(e){return typeof e=="object"&&e!==null&&"type"in e}isModernModel(e){let n=e.match(/^claude-[a-z]+-(\d+)(?:-(\d+))?/i);if(!n)return!1;let r=+n[1],s=n[2]?+n[2]:0;return r>4||r===4&&s>=6}alwaysThinks(e){return/^claude-(fable|mythos)\b/i.test(e)}getMaxTokens(e){return this.isModernModel(e)?64e3:32e3}}});var xa,Fd=S(()=>{Tn();br();xa=class extends Ze{constructor(){super(...arguments),this.providerName="Gemini",this.defaultBaseUrl="https://generativelanguage.googleapis.com",this.path="/v1beta/models",this.budgetMap={0:0,1:1024,2:8192,3:-1,4:-1}}getPath(e,n){return`/v1beta/models/${e}:${n?"streamGenerateContent":"generateContent"}${n?"?alt=sse":""}`}buildHeaders(e){return{"Content-Type":"application/json","x-goog-api-key":e}}buildPayload(e,n,r,s){let{system:i,conversationMessages:o}=this.extractSystemMessages(e,`
516
- `),l={contents:o.map(f=>({role:f.role==="assistant"?"model":"user",parts:[{text:f.content}]}))};r?.webSearch===!0&&(l.tools=[{google_search:{}}]),i&&(l.systemInstruction={role:"system",parts:[{text:i}]});let c=r?.effort;if(c!==void 0){let f=this.geminiVersion(n),d=f!==void 0&&f>=3?{thinkingLevel:this.thinkingLevelFor(f,c)}:{thinkingBudget:this.budgetMap[c]};l.generationConfig={thinkingConfig:c===0?d:{includeThoughts:!0,...d}}}return r?.maxOutputTokens!==void 0&&(l.generationConfig={...l.generationConfig,maxOutputTokens:r.maxOutputTokens}),l}parseError(e,n){if(!e)return{message:`HTTP ${n}`};try{let r=JSON.parse(e),s=Array.isArray(r)?r[0]?.error:r?.error;return s&&typeof s=="object"?{message:(s.message||`HTTP ${n}`).split(`
517
- `)[0],type:s.status,code:s.code?.toString()}:r.message?{message:r.message}:{message:e}}catch{return{message:e}}}parseNonStreamingResponse(e){if(this.checkAndThrowError(e),this.checkGeminiError(e),!this.isGeminiResponse(e))return{text:"",status:"failed",error:"Invalid response format"};let n=this.extractParts(e).text||"",r=e.candidates?.[0]?.finishReason,s="complete";return r==="MAX_TOKENS"?s="interrupted":(r==="SAFETY"||r==="RECITATION")&&(s="failed"),{text:n,status:s,usage:this.mapUsage(e.usageMetadata)}}parseProviderStreamChunk(e){if(this.checkGeminiError(e),!this.isGeminiResponse(e))return;let n=this.extractParts(e),r=this.mapUsage(e.usageMetadata);return r&&(n.usage=r),n.text||n.reasoning||n.usage?n:void 0}mapUsage(e){if(!e)return;let n=e.candidatesTokenCount!==void 0||e.thoughtsTokenCount!==void 0;return lt({input:e.promptTokenCount,output:n?(e.candidatesTokenCount??0)+(e.thoughtsTokenCount??0):void 0,reasoning:e.thoughtsTokenCount,cacheRead:e.cachedContentTokenCount})}geminiVersion(e){let n=e.match(/^gemini-(\d+(?:\.\d+)?)/);return n?Number(n[1]):void 0}thinkingLevelFor(e,n){let r=["minimal","low","medium","high","high"][n];return r==="minimal"&&e<3.5?"low":r}isGeminiResponse(e){return typeof e=="object"&&e!==null&&"candidates"in e&&Array.isArray(e.candidates)}extractParts(e){let n=e.candidates?.[0]?.content?.parts;if(!n)return{};let r="",s="";for(let i of n)i.text&&(i.thought?s+=i.text:r+=i.text);return{text:r||void 0,reasoning:s||void 0}}checkGeminiError(e){if(this.isGeminiResponse(e)&&e.promptFeedback?.blockReason){let n=e.promptFeedback.blockReason;throw new Ne(`Prompt blocked: ${n}`)}}}});var Ea,Ud=S(()=>{va();Ea=class extends wr{constructor(){super(...arguments),this.providerName="Ollama",this.defaultBaseUrl="http://localhost:11434",this.path="/chat/completions"}buildHeaders(e){let n={"Content-Type":"application/json",Accept:"application/json"};return e&&(n.Authorization=`Bearer ${e}`),n}buildPayload(e,n,r,s){return s?{model:n,messages:e,stream:s,stream_options:{include_usage:!0}}:{model:n,messages:e,stream:s}}}});function Cn(t){let e=WP.get(t);if(!e)throw new Error(`Unsupported protocol: ${t}`);return e}function KP(t,e){return t.replace(/\/+$/,"")+(e.startsWith("/")?e:`/${e}`)}async function qd(t,e){let n=Cn(t.protocol),r=n.getPath(t.model,e.stream),s=KP(t.baseUrl,r),i=n.buildHeaders(t.apiKey),o=n.buildPayload(e.messages,t.model,{effort:e.effort,webSearch:e.webSearch,maxOutputTokens:e.maxOutputTokens},e.stream);return fetch(s,{method:"POST",headers:i,body:JSON.stringify(o),signal:e.signal})}function HP(t){return/prompt is too long|context[_ ](length|window)|maximum context|token count exceeds|too many tokens/i.test(t)}async function vr(t,e){let n=Cn(e),r=await t.text().catch(()=>""),{message:s}=n.parseError(r,t.status),i=t.status,o="unknown";return i===429?o="rate_limit":(i===413||HP(s))&&(o="context_exceeded"),{code:o,message:s,retryable:i===429||i>=500}}var Zb,WP,Jd=S(()=>{Md();Bd();jd();Fd();Ud();Zb=new Ea,WP=new Map([["openai",new wa],["openrouter",new Sa],["anthropic",new ka],["gemini",new xa],["ollama",Zb],["openai-compat",Zb]])});function ew(t){let e=t.indexOf(`\r
515
+ `);return{text:n,reasoning:r||void 0,usage:lt(this.mapUsage(e.usage))}}parseProviderStreamChunk(e){if(this.isAnthropicEvent(e))switch(e.type){case"content_block_delta":return e.delta.type==="text_delta"?{text:e.delta.text||""}:e.delta.type==="thinking_delta"?{reasoning:e.delta.thinking||""}:void 0;case"message_start":{let n=this.mapUsage(e.message?.usage);return n?{usage:n}:void 0}case"message_delta":{let n=this.mapUsage(e.usage);return n?{usage:n}:void 0}default:return}}mapUsage(e){if(typeof e!="object"||e===null)return;let n=e,r=l=>typeof l=="number"?l:void 0,s=r(n.input_tokens),i=r(n.cache_read_input_tokens),o=r(n.cache_creation_input_tokens),a=r(n.output_tokens),c=s!==void 0||i!==void 0||o!==void 0?(s??0)+(i??0)+(o??0):void 0;if(!(c===void 0&&a===void 0))return{input:c,output:a,cacheRead:i}}withTailMessagesCached(e){let n=Math.max(0,e.length-2);return e.map((r,s)=>s>=n?{role:r.role,content:[{type:"text",text:r.content,cache_control:{type:"ephemeral"}}]}:r)}isAnthropicResponse(e){return typeof e=="object"&&e!==null&&e.type==="message"&&Array.isArray(e.content)}isAnthropicEvent(e){return typeof e=="object"&&e!==null&&"type"in e}isModernModel(e){let n=e.match(/^claude-[a-z]+-(\d+)(?:-(\d+))?/i);if(!n)return!1;let r=+n[1],s=n[2]?+n[2]:0;return r>4||r===4&&s>=6}alwaysThinks(e){return/^claude-(fable|mythos)\b/i.test(e)}getMaxTokens(e){return this.isModernModel(e)?64e3:32e3}}});var _a,Hd=k(()=>{On();Sr();_a=class extends et{constructor(){super(...arguments),this.providerName="Gemini",this.defaultBaseUrl="https://generativelanguage.googleapis.com",this.path="/v1beta/models",this.budgetMap={0:0,1:1024,2:8192,3:-1,4:-1}}getPath(e,n){return`/v1beta/models/${e}:${n?"streamGenerateContent":"generateContent"}${n?"?alt=sse":""}`}buildHeaders(e){return{"Content-Type":"application/json","x-goog-api-key":e}}buildPayload(e,n,r,s){let{system:i,conversationMessages:o}=this.extractSystemMessages(e,`
516
+ `),c={contents:o.map(f=>({role:f.role==="assistant"?"model":"user",parts:[{text:f.content}]}))};r?.webSearch===!0&&(c.tools=[{google_search:{}}]),i&&(c.systemInstruction={role:"system",parts:[{text:i}]});let l=r?.effort;if(l!==void 0){let f=this.geminiVersion(n),u=f!==void 0&&f>=3?{thinkingLevel:this.thinkingLevelFor(f,l)}:{thinkingBudget:this.budgetMap[l]};c.generationConfig={thinkingConfig:l===0?u:{includeThoughts:!0,...u}}}return r?.maxOutputTokens!==void 0&&(c.generationConfig={...c.generationConfig,maxOutputTokens:r.maxOutputTokens}),c}parseError(e,n){if(!e)return{message:`HTTP ${n}`};try{let r=JSON.parse(e),s=Array.isArray(r)?r[0]?.error:r?.error;return s&&typeof s=="object"?{message:(s.message||`HTTP ${n}`).split(`
517
+ `)[0],type:s.status,code:s.code?.toString()}:r.message?{message:r.message}:{message:e}}catch{return{message:e}}}parseNonStreamingResponse(e){if(this.checkAndThrowError(e),this.checkGeminiError(e),!this.isGeminiResponse(e))return{text:"",status:"failed",error:"Invalid response format"};let n=this.extractParts(e).text||"",r=e.candidates?.[0]?.finishReason,s="complete";return r==="MAX_TOKENS"?s="interrupted":(r==="SAFETY"||r==="RECITATION")&&(s="failed"),{text:n,status:s,usage:this.mapUsage(e.usageMetadata)}}parseProviderStreamChunk(e){if(this.checkGeminiError(e),!this.isGeminiResponse(e))return;let n=this.extractParts(e),r=this.mapUsage(e.usageMetadata);return r&&(n.usage=r),n.text||n.reasoning||n.usage?n:void 0}mapUsage(e){if(!e)return;let n=e.candidatesTokenCount!==void 0||e.thoughtsTokenCount!==void 0;return lt({input:e.promptTokenCount,output:n?(e.candidatesTokenCount??0)+(e.thoughtsTokenCount??0):void 0,reasoning:e.thoughtsTokenCount,cacheRead:e.cachedContentTokenCount})}geminiVersion(e){let n=e.match(/^gemini-(\d+(?:\.\d+)?)/);return n?Number(n[1]):void 0}thinkingLevelFor(e,n){let r=["minimal","low","medium","high","high"][n];return r==="minimal"&&e<3.5?"low":r}isGeminiResponse(e){return typeof e=="object"&&e!==null&&"candidates"in e&&Array.isArray(e.candidates)}extractParts(e){let n=e.candidates?.[0]?.content?.parts;if(!n)return{};let r="",s="";for(let i of n)i.text&&(i.thought?s+=i.text:r+=i.text);return{text:r||void 0,reasoning:s||void 0}}checkGeminiError(e){if(this.isGeminiResponse(e)&&e.promptFeedback?.blockReason){let n=e.promptFeedback.blockReason;throw new Le(`Prompt blocked: ${n}`)}}}});var Ra,zd=k(()=>{Ca();Ra=class extends kr{constructor(){super(...arguments),this.providerName="Ollama",this.defaultBaseUrl="http://localhost:11434",this.path="/chat/completions"}buildHeaders(e){let n={"Content-Type":"application/json",Accept:"application/json"};return e&&(n.Authorization=`Bearer ${e}`),n}buildPayload(e,n,r,s){return s?{model:n,messages:e,stream:s,stream_options:{include_usage:!0}}:{model:n,messages:e,stream:s}}}});function Pn(t){let e=y_.get(t);if(!e)throw new Error(`Unsupported protocol: ${t}`);return e}function b_(t,e){return t.replace(/\/+$/,"")+(e.startsWith("/")?e:`/${e}`)}async function Yd(t,e){let n=Pn(t.protocol),r=n.getPath(t.model,e.stream),s=b_(t.baseUrl,r),i=n.buildHeaders(t.apiKey),o=n.buildPayload(e.messages,t.model,{effort:e.effort,webSearch:e.webSearch,maxOutputTokens:e.maxOutputTokens},e.stream);return fetch(s,{method:"POST",headers:i,body:JSON.stringify(o),signal:e.signal})}function w_(t){return/prompt is too long|context[_ ](length|window)|maximum context|token count exceeds|too many tokens/i.test(t)}async function xr(t,e){let n=Pn(e),r=await t.text().catch(()=>""),{message:s}=n.parseError(r,t.status),i=t.status,o="unknown";return i===429?o="rate_limit":(i===413||w_(s))&&(o="context_exceeded"),{code:o,message:s,retryable:i===429||i>=500}}var lw,y_,Vd=k(()=>{qd();Wd();Kd();Hd();zd();lw=new Ra,y_=new Map([["openai",new Ta],["openrouter",new Oa],["anthropic",new Pa],["gemini",new _a],["ollama",lw],["openai-compat",lw]])});function uw(t){let e=t.indexOf(`\r
518
518
  \r
519
519
  `),n=t.indexOf(`
520
520
 
521
- `);return e!==-1&&(n===-1||e<n)?{pos:e,len:4}:n!==-1?{pos:n,len:2}:{pos:-1,len:0}}function Wd(t){let n=t.split(/\r?\n/).filter(s=>s.startsWith("data:"));if(!n.length)return;let r=n.map(s=>s.replace(/^data:\s?/,"")).join(`
522
- `).trim();if(r){if(r==="[DONE]")return"done";try{return JSON.parse(r)}catch{return}}}async function*tw(t,e,n){let r=new TextDecoder,s="",i,o=e?new Promise((a,l)=>{e.aborted&&l(new Error("Aborted")),i=()=>l(new Error("Aborted")),e.addEventListener("abort",i,{once:!0})}):void 0;o?.catch(()=>{});try{for(;;){let{done:a,value:l}=o?await Promise.race([t.read(),o]):await t.read();if(a){if(s.trim()){let d=Wd(s);d!==void 0&&d!=="done"&&(yield d)}return}n?.(),s+=r.decode(l,{stream:!0});let{pos:c,len:f}=ew(s);for(;c!==-1;){let d=s.slice(0,c);s=s.slice(c+f);let u=Wd(d);if(u==="done")return;u!==void 0&&(yield u),{pos:c,len:f}=ew(s)}}}finally{i&&e?.removeEventListener("abort",i);try{await t.cancel()}catch{}}}async function Kd(t,e){return(await Sr(t,e)).text}async function Sr(t,e){if(!t.body)throw new Error("Response body is missing");let n="",r;for await(let s of On(t,e))s.kind==="text"?n+=s.text:s.kind==="usage"&&(r=s.usage);return{text:n,usage:r}}async function*On(t,e){let n=e??(t.headers.get("X-Provider-Protocol")||"openai"),r=Cn(n);if(!t.body)return;let s=t.body.getReader(),i;for await(let a of tw(s)){let l=r.parseStreamChunk(a);l?.reasoning&&(yield{kind:"reasoning",text:l.reasoning}),l?.text&&(yield{kind:"text",text:l.text}),l?.usage&&(i=Qb(i,l.usage))}let o=lt(i);o&&(yield{kind:"usage",usage:o})}var nw=S(()=>{Tn();Jd()});import{strToU8 as zP,strFromU8 as YP,deflateSync as VP,inflateSync as GP}from"fflate";function zd(t,e){let n=[];if(n.push(`You are a data processor. Follow the instructions to analyze the provided data. Output valid JSON that the code can consume.
521
+ `);return e!==-1&&(n===-1||e<n)?{pos:e,len:4}:n!==-1?{pos:n,len:2}:{pos:-1,len:0}}function Gd(t){let n=t.split(/\r?\n/).filter(s=>s.startsWith("data:"));if(!n.length)return;let r=n.map(s=>s.replace(/^data:\s?/,"")).join(`
522
+ `).trim();if(r){if(r==="[DONE]")return"done";try{return JSON.parse(r)}catch{return}}}async function*dw(t,e,n){let r=new TextDecoder,s="",i,o=e?new Promise((a,c)=>{e.aborted&&c(new Error("Aborted")),i=()=>c(new Error("Aborted")),e.addEventListener("abort",i,{once:!0})}):void 0;o?.catch(()=>{});try{for(;;){let{done:a,value:c}=o?await Promise.race([t.read(),o]):await t.read();if(a){if(s.trim()){let u=Gd(s);u!==void 0&&u!=="done"&&(yield u)}return}n?.(),s+=r.decode(c,{stream:!0});let{pos:l,len:f}=uw(s);for(;l!==-1;){let u=s.slice(0,l);s=s.slice(l+f);let d=Gd(u);if(d==="done")return;d!==void 0&&(yield d),{pos:l,len:f}=uw(s)}}}finally{i&&e?.removeEventListener("abort",i);try{await t.cancel()}catch{}}}async function Xd(t,e){return(await Er(t,e)).text}async function Er(t,e){if(!t.body)throw new Error("Response body is missing");let n="",r;for await(let s of _n(t,e))s.kind==="text"?n+=s.text:s.kind==="usage"&&(r=s.usage);return{text:n,usage:r}}async function*_n(t,e){let n=e??(t.headers.get("X-Provider-Protocol")||"openai"),r=Pn(n);if(!t.body)return;let s=t.body.getReader(),i;for await(let a of dw(s)){let c=r.parseStreamChunk(a);c?.reasoning&&(yield{kind:"reasoning",text:c.reasoning}),c?.text&&(yield{kind:"text",text:c.text}),c?.usage&&(i=cw(i,c.usage))}let o=lt(i);o&&(yield{kind:"usage",usage:o})}var fw=k(()=>{On();Vd()});import{strToU8 as v_,strFromU8 as S_,deflateSync as k_,inflateSync as x_}from"fflate";function Zd(t,e){let n=[];if(n.push(`You are a data processor. Follow the instructions to analyze the provided data. Output valid JSON that the code can consume.
523
523
 
524
524
  ---
525
525
  Instructions:
@@ -537,13 +537,13 @@ ${r}
537
537
  </data>`)}return n.push(`
538
538
  Output only valid JSON. No explanation, no markdown fences, just the JSON object. Every number must be a JSON literal \u2014 never an expression like 2 * pi; write the computed decimal instead.`),n.join(`
539
539
 
540
- `)}function Ys(t){try{return JSON.parse(t)}catch{return}}function rw(t,e){let n="",r=0,s=!1,i=!1;for(let o=0;o<t.length;o++){let a=t[o];if(i){i=!1;continue}if(a==="\\"){i=!0;continue}a==='"'&&(s?(n+=t.slice(r,o+1),r=o+1):(n+=e(t.slice(r,o))+'"',r=o+1),s=!s)}return n+=s?t.slice(r):e(t.slice(r)),n}function QP(t){let e=rw(t,n=>n.replace(/,(\s*[}\]])/g,"$1"));return e!==t?e:void 0}function ZP(t){let e=rw(t,n=>n.replace(/\bpi\b/g,"3.141592653589793").replace(/\be\b/g,"2.718281828459045").replace(/-?\d[\d.\s+\-*/()]*\d|\(-?\d[\d.\s+\-*/()]*\d\)/g,r=>{if(!/[+\-*/]/.test(r.replace(/^-/,""))||r.length>64||!/^[\d\s.+\-*/()]+$/.test(r))return r;try{let s=Function(`"use strict"; return (${r})`)();return typeof s=="number"&&Number.isFinite(s)?String(s):r}catch{return r}}));return e!==t?e:void 0}function e_(t,e){let n=0,r=!1,s=!1;for(let i=e;i<t.length;i++){let o=t[i];if(s){s=!1;continue}if(o==="\\"){s=!0;continue}if(o==='"'){r=!r;continue}if(!r){if(o==="{"||o==="[")n++;else if((o==="}"||o==="]")&&(n--,n===0))return i}}return-1}function t_(t){let e,n=0;for(;n<t.length;){let r=t[n];if(r==="{"||r==="["){let s=e_(t,n);if(s!==-1){let i=t.slice(n,s+1),o=Ys(i);o!==void 0&&(e={parsed:o,json:i}),n=s+1;continue}}n++}return e}function Yd(t){let e=[],n=t.trim();n.startsWith("```")&&(n=n.replace(/^```(?:json)?\s*\n?/,"").replace(/\n?```\s*$/,""),e.push("markdown fences"));let r=Ys(n);if(r!==void 0)return{parsed:r,json:n,fixesApplied:e};let s=n.match(/```(?:json)?\s*\n([\s\S]*?)\n?```\s*$/);if(s&&(n=s[1].trim(),e.push("preamble before fenced JSON"),r=Ys(n),r!==void 0))return{parsed:r,json:n,fixesApplied:e};if(!n.startsWith("{")&&!n.startsWith("[")){let o=n.indexOf("{"),a=n.indexOf("["),l=o>=0&&a>=0?Math.min(o,a):o>=0?o:a;if(l>0&&(n=n.slice(l),e.push("preamble text"),r=Ys(n),r!==void 0))return{parsed:r,json:n,fixesApplied:e}}for(let[o,a]of XP){let l=a(n);if(l!==void 0){let c=Ys(l);if(c!==void 0)return{parsed:c,json:l,fixesApplied:[...e,o]}}}let i=t_(t);return i!==void 0?{...i,fixesApplied:[...e,"extracted last JSON value"]}:{parsed:void 0,json:n,fixesApplied:e}}function Vd(t){try{let e={};if(t.insight!==void 0&&(e.i=t.insight),t.data!==void 0&&(e.d=t.data),e.i===void 0&&e.d===void 0)return"";let n=JSON.stringify(e),r=VP(zP(n),{level:9}),s=r_(r),i=`${sw}:${s}`;return i.length>n_?"":"#"+Hd+i}catch{return""}}function Gd(t){try{let e=t.startsWith("#")?t.slice(1):t;if(!e.startsWith(Hd))return;let n=e.slice(Hd.length),r=n.indexOf(":");if(r===-1||n.slice(0,r)!==sw)return;let s=s_(n.slice(r+1)),i=JSON.parse(YP(GP(s)));if(!i||typeof i!="object")return;let o=i.i!==void 0,a=Array.isArray(i.d);if(!o&&!a)return;let l={};return o&&(l.insight=i.i,l.insightJson=JSON.stringify(i.i,null,2)),a&&(l.data=i.d),l}catch{return}}function r_(t){let e="";for(let n=0;n<t.length;n+=32768)e+=String.fromCharCode(...t.subarray(n,n+32768));return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function s_(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");for(;e.length%4;)e+="=";let n=atob(e),r=new Uint8Array(n.length);for(let s=0;s<n.length;s++)r[s]=n.charCodeAt(s);return r}var XP,Hd,sw,n_,iw=S(()=>{XP=[["orphan quote",t=>{let e=t.replace(/^[ \t]*"[ \t]*\r?\n/gm,"");return e!==t?e:void 0}],["trailing }",t=>t.endsWith("}}")?t.slice(0,-1):void 0],["trailing ]",t=>t.endsWith("]]")?t.slice(0,-1):void 0],["trailing },",t=>t.endsWith("},")?t.slice(0,-1):void 0],["trailing ],",t=>t.endsWith("],")?t.slice(0,-1):void 0],["trailing commas",QP],["arithmetic constants",ZP]];Hd="tb=",sw="1",n_=6e4});var Kt=S(()=>{Tn();br();Jd();nw();iw();va();jd();Fd();Md();Bd();Ud()});import{readFileSync as ow,existsSync as i_}from"fs";import*as ct from"path";function aw(t){return[...t?[`.env.${t}.local`,`.env.${t}`]:[],".env.local",".env"]}function be(t,e=process.cwd()){let n={},r=[];for(let s of aw(t)){let i;try{i=ow(ct.resolve(e,s),"utf-8")}catch{continue}r.push(s);for(let[o,a]of lw(i))process.env[o]===void 0&&(process.env[o]=a,n[o]=s)}return{mode:t,sources:n,loaded:r}}function*lw(t){for(let e of t.split(`
541
- `)){let n=e.trim();if(!n||n.startsWith("#"))continue;let r=n.indexOf("=");if(r===-1)continue;let s=n.slice(0,r).trim(),i=n.slice(r+1).trim();(i.startsWith('"')&&i.endsWith('"')||i.startsWith("'")&&i.endsWith("'"))&&(i=i.slice(1,-1)),yield[s,i]}}function Aa(t,e=process.cwd()){for(let n of aw()){let r;try{r=ow(ct.resolve(e,n),"utf-8")}catch{continue}for(let[s,i]of lw(r))if(s===t)return i}return process.env[t]}function o_(t){let e=new Set,n=/process\.env\.([A-Za-z_$][\w$]*)|process\.env\[\s*['"]([^'"]+)['"]\s*\]/g;for(let r;r=n.exec(t);)e.add(r[1]??r[2]);return[...e]}function cw(){return`.env loads from ${process.cwd()} (the directory you ran from, not the bulb's)`}function Ht(t,e,n){let{sources:r,mode:s,loaded:i}=t,o=process.cwd(),a=ct.dirname(e),l=`(mode: ${s??"none"})`,c=n?o_(n):[],f=c.filter(p=>r[p]).map(p=>`${p} \u2190 ${r[p]}`);f.length?console.log(`env: ${f.join(", ")} ${l}`):i.length&&console.log(`env: loaded ${i.join(", ")} ${l}`),s&&!i.some(p=>p===`.env.${s}`||p===`.env.${s}.local`)&&console.log(`env: mode=${s} \u2014 no .env.${s} found; using .env`);let d=ct.resolve(a)!==ct.resolve(o);if(d)for(let p of[".env.local",".env"])i_(ct.join(a,p))&&console.log(`env: ${ct.join(a,p)} present but not loaded (cwd is ${o})`);let u=c.filter(p=>process.env[p]===void 0);if(u.length){let p=d?` \u2014 try running from ${a}`:"";console.log(`env: server.ts reads ${u.join(", ")} but ${u.length>1?"they are":"it's"} unset${p}`)}}var et=S(()=>{"use strict"});function vt(t,e){let n=t??process.env.TB_AI_PROVIDER,r=e??process.env.TB_AI_MODEL;if(!n)return"No provider specified. Set TB_AI_PROVIDER in your .env file or pass provider in the tb.ai() call.";if(!r)return"No model specified. Set TB_AI_MODEL in your .env file or pass model in the tb.ai() call.";let s;try{s=Cn(n)}catch{return`Unknown provider '${n}'.`}if(n==="ollama")return{apiKey:"",baseUrl:`${yr(process.env.OLLAMA_HOST??s.defaultBaseUrl)}/v1`,protocol:n,model:r,isFreeModel:!1};if(n==="openai-compat"){let a=process.env.TB_AI_BASE_URL;return a?{apiKey:process.env.TB_AI_API_KEY??"",baseUrl:a,protocol:n,model:r,isFreeModel:!1}:"No base URL for openai-compat. Set TB_AI_BASE_URL (the OpenAI-style base ending in /v1, e.g. http://localhost:1234/v1) in your .env file."}let i=gr[n];if(!i)return`Unknown provider '${n}'.`;let o=process.env[i];return o?{apiKey:o,baseUrl:s.defaultBaseUrl,protocol:n,model:r,isFreeModel:!1}:`No API key for '${n}'. Set ${i} \u2014 ${cw()}.`}function zt(t,e){let n=[...e.system?[{role:"system",content:e.system}]:[],...e.messages.map(r=>({role:r.role,content:r.content}))];return qd(t,{messages:n,stream:!0,effort:Xb(e.effort),webSearch:e.webSearch,signal:e.signal})}var Ta=S(()=>{"use strict";Kt();Kt();et();An()});import{readFileSync as RF,existsSync as a_}from"fs";import*as kr from"path";import{fileURLToPath as l_}from"url";function c_(){let t=kr.dirname(l_(import.meta.url));for(;!a_(kr.join(t,"package.json"));){let e=kr.dirname(t);if(e===t)break;t=e}return t}function Vs(){return kr.join(c_(),"SKILL.md")}var Xd=S(()=>{"use strict"});import{transform as u_}from"sucrase";function Qd(t,e={}){let n=e.serverOnly?["typescript"]:["typescript","jsx"];try{let{code:r}=u_(t,{transforms:n,jsxRuntime:"automatic",jsxImportSource:e.jsxImportSource||"react",production:!0});return{code:r}}catch(r){return{code:"",error:String(r)}}}var uw=S(()=>{});function d_(t){return t.map(e=>`${e.type} (line ${e.lineNumber}): ${e.message.split(`
540
+ `)}function Zs(t){try{return JSON.parse(t)}catch{return}}function pw(t,e){let n="",r=0,s=!1,i=!1;for(let o=0;o<t.length;o++){let a=t[o];if(i){i=!1;continue}if(a==="\\"){i=!0;continue}a==='"'&&(s?(n+=t.slice(r,o+1),r=o+1):(n+=e(t.slice(r,o))+'"',r=o+1),s=!s)}return n+=s?t.slice(r):e(t.slice(r)),n}function A_(t){let e=pw(t,n=>n.replace(/,(\s*[}\]])/g,"$1"));return e!==t?e:void 0}function T_(t){let e=pw(t,n=>n.replace(/\bpi\b/g,"3.141592653589793").replace(/\be\b/g,"2.718281828459045").replace(/-?\d[\d.\s+\-*/()]*\d|\(-?\d[\d.\s+\-*/()]*\d\)/g,r=>{if(!/[+\-*/]/.test(r.replace(/^-/,""))||r.length>64||!/^[\d\s.+\-*/()]+$/.test(r))return r;try{let s=Function(`"use strict"; return (${r})`)();return typeof s=="number"&&Number.isFinite(s)?String(s):r}catch{return r}}));return e!==t?e:void 0}function C_(t,e){let n=0,r=!1,s=!1;for(let i=e;i<t.length;i++){let o=t[i];if(s){s=!1;continue}if(o==="\\"){s=!0;continue}if(o==='"'){r=!r;continue}if(!r){if(o==="{"||o==="[")n++;else if((o==="}"||o==="]")&&(n--,n===0))return i}}return-1}function O_(t){let e,n=0;for(;n<t.length;){let r=t[n];if(r==="{"||r==="["){let s=C_(t,n);if(s!==-1){let i=t.slice(n,s+1),o=Zs(i);o!==void 0&&(e={parsed:o,json:i}),n=s+1;continue}}n++}return e}function ef(t){let e=[],n=t.trim();n.startsWith("```")&&(n=n.replace(/^```(?:json)?\s*\n?/,"").replace(/\n?```\s*$/,""),e.push("markdown fences"));let r=Zs(n);if(r!==void 0)return{parsed:r,json:n,fixesApplied:e};let s=n.match(/```(?:json)?\s*\n([\s\S]*?)\n?```\s*$/);if(s&&(n=s[1].trim(),e.push("preamble before fenced JSON"),r=Zs(n),r!==void 0))return{parsed:r,json:n,fixesApplied:e};if(!n.startsWith("{")&&!n.startsWith("[")){let o=n.indexOf("{"),a=n.indexOf("["),c=o>=0&&a>=0?Math.min(o,a):o>=0?o:a;if(c>0&&(n=n.slice(c),e.push("preamble text"),r=Zs(n),r!==void 0))return{parsed:r,json:n,fixesApplied:e}}for(let[o,a]of E_){let c=a(n);if(c!==void 0){let l=Zs(c);if(l!==void 0)return{parsed:l,json:c,fixesApplied:[...e,o]}}}let i=O_(t);return i!==void 0?{...i,fixesApplied:[...e,"extracted last JSON value"]}:{parsed:void 0,json:n,fixesApplied:e}}function tf(t){try{let e={};if(t.insight!==void 0&&(e.i=t.insight),t.data!==void 0&&(e.d=t.data),e.i===void 0&&e.d===void 0)return"";let n=JSON.stringify(e),r=k_(v_(n),{level:9}),s=__(r),i=`${hw}:${s}`;return i.length>P_?"":"#"+Qd+i}catch{return""}}function nf(t){try{let e=t.startsWith("#")?t.slice(1):t;if(!e.startsWith(Qd))return;let n=e.slice(Qd.length),r=n.indexOf(":");if(r===-1||n.slice(0,r)!==hw)return;let s=R_(n.slice(r+1)),i=JSON.parse(S_(x_(s)));if(!i||typeof i!="object")return;let o=i.i!==void 0,a=Array.isArray(i.d);if(!o&&!a)return;let c={};return o&&(c.insight=i.i,c.insightJson=JSON.stringify(i.i,null,2)),a&&(c.data=i.d),c}catch{return}}function __(t){let e="";for(let n=0;n<t.length;n+=32768)e+=String.fromCharCode(...t.subarray(n,n+32768));return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function R_(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");for(;e.length%4;)e+="=";let n=atob(e),r=new Uint8Array(n.length);for(let s=0;s<n.length;s++)r[s]=n.charCodeAt(s);return r}var E_,Qd,hw,P_,mw=k(()=>{E_=[["orphan quote",t=>{let e=t.replace(/^[ \t]*"[ \t]*\r?\n/gm,"");return e!==t?e:void 0}],["trailing }",t=>t.endsWith("}}")?t.slice(0,-1):void 0],["trailing ]",t=>t.endsWith("]]")?t.slice(0,-1):void 0],["trailing },",t=>t.endsWith("},")?t.slice(0,-1):void 0],["trailing ],",t=>t.endsWith("],")?t.slice(0,-1):void 0],["trailing commas",A_],["arithmetic constants",T_]];Qd="tb=",hw="1",P_=6e4});var Wt=k(()=>{On();Sr();Vd();fw();mw();Ca();Kd();Hd();qd();Wd();zd()});import{readFileSync as gw,existsSync as I_}from"fs";import*as ut from"path";function yw(t){return[...t?[`.env.${t}.local`,`.env.${t}`]:[],".env.local",".env"]}function ve(t,e=process.cwd()){let n={},r=[];for(let s of yw(t)){let i;try{i=gw(ut.resolve(e,s),"utf-8")}catch{continue}r.push(s);for(let[o,a]of bw(i))process.env[o]===void 0&&(process.env[o]=a,n[o]=s)}return{mode:t,sources:n,loaded:r}}function*bw(t){for(let e of t.split(`
541
+ `)){let n=e.trim();if(!n||n.startsWith("#"))continue;let r=n.indexOf("=");if(r===-1)continue;let s=n.slice(0,r).trim(),i=n.slice(r+1).trim();(i.startsWith('"')&&i.endsWith('"')||i.startsWith("'")&&i.endsWith("'"))&&(i=i.slice(1,-1)),yield[s,i]}}function Ia(t,e=process.cwd()){for(let n of yw()){let r;try{r=gw(ut.resolve(e,n),"utf-8")}catch{continue}for(let[s,i]of bw(r))if(s===t)return i}return process.env[t]}function $_(t){let e=new Set,n=/process\.env\.([A-Za-z_$][\w$]*)|process\.env\[\s*['"]([^'"]+)['"]\s*\]/g;for(let r;r=n.exec(t);)e.add(r[1]??r[2]);return[...e]}function ww(){return`.env loads from ${process.cwd()} (the directory you ran from, not the bulb's)`}function Kt(t,e,n){let{sources:r,mode:s,loaded:i}=t,o=process.cwd(),a=ut.dirname(e),c=`(mode: ${s??"none"})`,l=n?$_(n):[],f=l.filter(p=>r[p]).map(p=>`${p} \u2190 ${r[p]}`);f.length?console.log(`env: ${f.join(", ")} ${c}`):i.length&&console.log(`env: loaded ${i.join(", ")} ${c}`),s&&!i.some(p=>p===`.env.${s}`||p===`.env.${s}.local`)&&console.log(`env: mode=${s} \u2014 no .env.${s} found; using .env`);let u=ut.resolve(a)!==ut.resolve(o);if(u)for(let p of[".env.local",".env"])I_(ut.join(a,p))&&console.log(`env: ${ut.join(a,p)} present but not loaded (cwd is ${o})`);let d=l.filter(p=>process.env[p]===void 0);if(d.length){let p=u?` \u2014 try running from ${a}`:"";console.log(`env: server.ts reads ${d.join(", ")} but ${d.length>1?"they are":"it's"} unset${p}`)}}var tt=k(()=>{"use strict"});function St(t,e){let n=t??process.env.TB_AI_PROVIDER,r=e??process.env.TB_AI_MODEL;if(!n)return"No provider specified. Set TB_AI_PROVIDER in your .env file or pass provider in the tb.ai() call.";if(!r)return"No model specified. Set TB_AI_MODEL in your .env file or pass model in the tb.ai() call.";let s;try{s=Pn(n)}catch{return`Unknown provider '${n}'.`}if(n==="ollama")return{apiKey:"",baseUrl:`${vr(process.env.OLLAMA_HOST??s.defaultBaseUrl)}/v1`,protocol:n,model:r,isFreeModel:!1};if(n==="openai-compat"){let a=process.env.TB_AI_BASE_URL;return a?{apiKey:process.env.TB_AI_API_KEY??"",baseUrl:a,protocol:n,model:r,isFreeModel:!1}:"No base URL for openai-compat. Set TB_AI_BASE_URL (the OpenAI-style base ending in /v1, e.g. http://localhost:1234/v1) in your .env file."}let i=wr[n];if(!i)return`Unknown provider '${n}'.`;let o=process.env[i];return o?{apiKey:o,baseUrl:s.defaultBaseUrl,protocol:n,model:r,isFreeModel:!1}:`No API key for '${n}'. Set ${i} \u2014 ${ww()}.`}function Ht(t,e){let n=[...e.system?[{role:"system",content:e.system}]:[],...e.messages.map(r=>({role:r.role,content:r.content}))];return Yd(t,{messages:n,stream:!0,effort:aw(e.effort),webSearch:e.webSearch,signal:e.signal})}var $a=k(()=>{"use strict";Wt();Wt();tt();Cn()});import{readFileSync as T2,existsSync as N_}from"fs";import*as Ar from"path";import{fileURLToPath as L_}from"url";function M_(){let t=Ar.dirname(L_(import.meta.url));for(;!N_(Ar.join(t,"package.json"));){let e=Ar.dirname(t);if(e===t)break;t=e}return t}function ei(){return Ar.join(M_(),"SKILL.md")}var rf=k(()=>{"use strict"});import{transform as D_}from"sucrase";function sf(t,e={}){let n=e.serverOnly?["typescript"]:["typescript","jsx"];try{let{code:r}=D_(t,{transforms:n,jsxRuntime:"automatic",jsxImportSource:e.jsxImportSource||"react",production:!0});return{code:r}}catch(r){return{code:"",error:String(r)}}}var vw=k(()=>{});function B_(t){return t.map(e=>`${e.type} (line ${e.lineNumber}): ${e.message.split(`
542
542
  `)[0]}`).join(`
543
- `)}function dw(t,e){let n=Js(t,{target:"client",dependencies:e}).filter(r=>r.type==="UNDECLARED_IMPORT");if(n.length)throw new Error(`Lint failed:
544
- ${d_(n)}`)}var fw=S(()=>{"use strict";ga()});var Yt,Gs,Zd,Xs=S(()=>{Yt="https://esm.sh",Gs="https://cdn.jsdelivr.net/npm/",Zd="https://data.jsdelivr.com/v1/package/npm/"});function pw(t){let e=(t||"").replace(/^\/+/,"").replace(/\/+$/,"");return e?e.split("/"):[]}var F,xr,hw,Qs=S(()=>{Xs();F=class t{constructor(e,n,r){let s=typeof e=="string"?t.parse(e):e;this.name=s.name,this.version=xr(n??s.version),this.subpath=xr(r??s.subpath)}static parse(e){let n=pw(e||"");if(!n.length)return new t({name:""});if(n[0].startsWith("@")){let s=n[0],[i,o]=hw(n[1]??""),a=xr(n.slice(2).join("/"));return new t({name:`${s}/${i}`,version:o,subpath:a})}else{let[s,i]=hw(n[0]),o=xr(n.slice(1).join("/"));return new t({name:s,version:i,subpath:o})}}static fromUrl(e){try{let n=new URL(e),r=new URL(Yt).host,s=new URL(Gs).host;if(n.host===r){let i=pw(n.pathname.replace(/^\/v\d+\//,"/"));if(!i.length)return;let o=i[0].startsWith("@")?`${i[0]}/${i[1]??""}`:i[0];return t.parse(o)}if(n.host===s){let i=n.pathname.split("/npm/")[1];if(!i)return;let o=i.split("/")[0]||"";return t.parse(o)}return}catch{return}}format(){let e=this.version?`${this.name}@${this.version}`:this.name;return this.subpath?`${e}/${this.subpath}`:e}root(){return this.name}static rootOf(e){return t.parse(e).name}withVersion(e){return new t({name:this.name,version:xr(e),subpath:this.subpath})}static isBare(e){return!e||e.startsWith(".")||e.startsWith("/")?!1:!/^[a-z][a-z0-9+.-]*:/i.test(e)}},xr=t=>t&&t.length?t:void 0,hw=t=>{let e=t.indexOf("@");return e<0?[t,void 0]:[t.slice(0,e),xr(t.slice(e+1))]}});async function Oe(t){try{return await t()}catch{return}}var Ca=S(()=>{});function Pn(t){let e=t||"";return e.startsWith("./")?e.slice(2):e.replace(/^\/+/,"")}function ef(t){return t.startsWith("./")?t:`./${t}`}var Zs,tf=S(()=>{Qs();Ca();Xs();Zs=class{constructor(e,n){this.cache=e,this.http=n,this.pinMs=1e4,this.versionsIndexMs=1440*60*1e3,this.metaTtlMs=10080*60*1e3,this.pinCache=new Map}baseDir(e){let n=typeof e=="string"?new F(e):e;return`${Gs}${n.name}${n.version?`@${n.version}`:""}/`}file(e,n){return new URL(Pn(n),this.baseDir(e)).toString()}packageJson(e){return this.file(e,"package.json")}buildEsmUrl(e,n={}){let{target:r="es2022",bundle:s=!1,external:i}=n,o=new URLSearchParams({target:r});return s&&o.append("bundle",""),i?.length&&o.append("external",i.join(",")),`${Yt}/${e}?${o.toString()}`}async resolveExactVersion(e){let n=Date.now(),r=this.pinCache.get(e);if(r&&n-r.ts<this.pinMs)return r.value;let s=await this.tryResolveFromUrls([this.buildEsmUrl(e),`${Yt}/${e}`]);return this.pinCache.set(e,{value:s,ts:n}),s}async tryResolveFromUrls(e){for(let n of e){let r=await Oe(()=>this.http.head(n)),s=this.parseVersionFromUrl(r?.url||n);if(s)return s}}async fetchVersionsIndex(e){if(await this.cache.isNegative(e))return;let n=await this.cache.getIndex(e);if(n&&Date.now()-n.updatedAt<this.versionsIndexMs)return{versions:n.versions,distTags:n.distTags};let r=await Oe(()=>this.http.getJson(`${Zd}${encodeURIComponent(e)}`));if(!r?.versions?.length){await this.cache.recordNegative(e);return}await this.cache.clearNegative(e);let s=r.tags&&Object.keys(r.tags).length?r.tags:void 0;return await this.cache.setIndex(e,r.versions,s),{versions:r.versions,distTags:s}}parseVersionFromUrl(e){let n=F.fromUrl(e)?.version;return n&&/\d+\.\d+\.\d+/.test(n)?n:void 0}async fetchPackageMeta(e,n){let r=await this.cache.getMeta(e,n);if(r&&Date.now()-r.updatedAt<this.metaTtlMs){let{dependencies:f,peerDependencies:d,peerDependenciesMeta:u}=r;return{name:e,version:n,dependencies:f,peerDependencies:d,peerDependenciesMeta:u}}let s=this.packageJson(new F(`${e}@${n}`)),i=await Oe(()=>this.http.getJson(s));if(!i)return;let o=f=>f&&Object.keys(f).length?f:void 0,a=o(i.dependencies),l=o(i.peerDependencies),c=o(i.peerDependenciesMeta);return await this.cache.setMeta(e,n,a,l,c),{name:e,version:n,dependencies:a,peerDependencies:l,peerDependenciesMeta:c}}}});var mw,ei,nf,f_,ti,Oa=S(()=>{mw=t=>t.startsWith("@types/"),ei=t=>Object.keys(t?.peerDependencies||{}).filter(e=>!mw(e)),nf=t=>Object.keys(t?.dependencies||{}).filter(e=>!mw(e)),f_=t=>ei(t).filter(e=>!t?.peerDependenciesMeta?.[e]?.optional),ti=class{constructor(e){this.cdn=e}async resolve(e,n){let r=await this.fetchMeta(e),{allRoots:s,autoAddedPeers:i}=await this.expandWithPeers(r,n),o=this.computeFlags(s);return{allRoots:s,flags:o,autoAddedPeers:i}}async fetchMeta(e){return Promise.all(e.map(async({name:n,version:r})=>({name:n,version:r,meta:await this.cdn.fetchPackageMeta(n,r)})))}async expandWithPeers(e,n){let r=new Map(e.map(i=>[i.name,i])),s=[];for(let i of e)for(let o of f_(i.meta))!r.has(o)&&!s.some(a=>a.name===o)&&s.push({name:o,requiredBy:i.name});for(let{name:i,requiredBy:o}of s)try{let a=await n(i),l=await this.cdn.fetchPackageMeta(i,a);r.set(i,{name:i,version:a,meta:l})}catch(a){console.warn(`[typebulb] Failed to resolve peer "${i}" for "${o}":`,a)}return{allRoots:[...r.values()],autoAddedPeers:s.filter(i=>r.has(i.name))}}computeFlags(e){let n=new Set(e.flatMap(i=>ei(i.meta))),r=new Map;for(let i of e)for(let o of nf(i.meta))r.set(o,(r.get(o)||0)+1);let s=new Set([...r.entries()].filter(([,i])=>i>=2).map(([i])=>i));return new Map(e.map(i=>[i.name,{isPeerRoot:n.has(i.name),hasPeers:ei(i.meta).length>0,isSharedDep:s.has(i.name)}]))}}});var ni,rf=S(()=>{Qs();Ca();ni=class{constructor(e,n,r){this.cache=e,this.cdn=n,this.semver=r}async learnExactVersion(e){let n=await Oe(()=>this.cdn.fetchVersionsIndex(e));if(n?.versions?.length){let r=this.semver.selectBestVersion(n.versions,{distTags:n.distTags});if(r)return r}return this.cdn.resolveExactVersion(e)}async resolveExactForRoot(e,n){if(!n)return this.learnExactVersion(e);let r=a=>!this.semver.isRange(n)||this.semver.satisfies(n,a),s=await this.cache.getPinnedExact(e,n);if(s){if(this.semver.isExactVersion(s)&&r(s))return s;console.debug("[typebulb] cached version for",e,"is not exact or not in",n,"(",s,"); re-resolving from registry")}let i=async a=>{if(a&&this.semver.isExactVersion(a)&&r(a))return await this.cache.setPinnedExact(e,n,a),a},o=await Oe(()=>this.cdn.fetchVersionsIndex(e));if(o?.versions?.length){let a=this.semver.selectBestVersion(o.versions,{range:n,distTags:o.distTags});if(a){let l=await i(a);if(l)return l}else{console.debug("[typebulb] refreshing version cache for",e,"(",n,"not in cached set \u2014 likely a new release)"),await this.cache.invalidateVersionsCache(e);let l=await Oe(()=>this.cdn.fetchVersionsIndex(e));if(l?.versions?.length){let c=await i(this.semver.selectBestVersion(l.versions,{range:n,distTags:l.distTags}));if(c)return c}}}return i(await this.cdn.resolveExactVersion(`${e}@${n}`))}async effectivePackage(e,n){let r=new F(e),s=r.root(),i=n[s],o=i?await Oe(()=>this.resolveExactForRoot(s,i)):void 0;return{effectivePackage:o?r.withVersion(o).format():e,root:s,range:i,pinned:o}}}});import{init as p_,parse as h_}from"es-module-lexer";var Er,sf=S(()=>{Qs();Xs();Oa();Er=class t{constructor(e,n,r){this.version=e,this.cdn=n,this.peer=r}extractImportsSync(e){let n=new Set;for(let r of t.importPatterns){r.lastIndex=0;for(let s of e.matchAll(r))F.isBare(s[1])&&n.add(s[1])}return Array.from(n)}async extractImports(e){let n=new Set,r=s=>{F.isBare(s)&&n.add(s)};try{await p_;let[s]=h_(e);s.forEach(i=>r(e.slice(i.s,i.e).trim()))}catch{return this.extractImportsSync(e)}return Array.from(n)}async buildImportMap(e,n,r){let s=(await this.extractImports(e)).filter(d=>!r?.has(F.rootOf(d))),i=[...new Set(s.map(F.rootOf))],o=await Promise.all(i.map(async d=>({name:d,version:await this.resolveVersion(d,n)}))),{allRoots:a,flags:l,autoAddedPeers:c}=await this.peer.resolve(o,d=>this.resolveVersion(d,n)),f=this.buildEntries([...s,...c.map(d=>d.name)],a,l);return{importMap:{imports:Object.fromEntries(f)},prefetchUrls:f.map(([,d])=>d)}}async resolveVersion(e,n){let r=n[e],s=await this.version.resolveExactForRoot(e,r);if(!s)throw new Error(`Cannot resolve ${r?`${e}@${r}`:e}: no matching version is published (the package or version may not exist, or the registry was unreachable).`);return s}buildEntries(e,n,r){let s=new Map(n.map(p=>[p.name,p])),i=p=>{let h=s.get(F.rootOf(p));return new F(p).withVersion(h.version).format()},o=new Set([...r.entries()].filter(([,p])=>p.isPeerRoot||p.isSharedDep).map(([p])=>p)),a=new Set(e.filter(p=>p!==F.rootOf(p)).map(F.rootOf)),l=[],c=new Set,f=new Set(e.filter(p=>p===F.rootOf(p))),d=new Set;for(let p of e){let h=F.rootOf(p),m=s.get(h),{isPeerRoot:g,hasPeers:b,isSharedDep:C}=r.get(h),T=a.has(h),E=p!==h,O=!(g||C)&&(T||!b),P=this.singletonDepsOf(m,o),k=E&&f.has(h);k&&d.add(h);let L=k?[...P,h]:P.length?P:void 0;l.push([p,this.cdn.buildEsmUrl(i(p),{bundle:O,external:L})]),c.add(p)}let u=new Set([...o,...d]);for(let p of u)s.has(p)&&(c.has(p)||l.push([p,this.cdn.buildEsmUrl(i(p),{})]),l.push([`${p}/`,`${Yt}/${i(p)}/`]));return l}singletonDepsOf(e,n){return[...new Set([...ei(e.meta),...nf(e.meta)])].filter(r=>n.has(r))}};Er.importPatterns=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g]});import{gt as gw,satisfies as m_,maxSatisfying as yw,major as g_,valid as y_,validRange as b_}from"semver";var Pa,_n,of=S(()=>{Pa=class{cmp(e,n){return e===n?0:gw(e,n)?1:gw(n,e)?-1:0}satisfies(e,n){return!e||!e.trim()?!0:!!m_(n,e,{includePrerelease:!0})}selectBestVersion(e,n){if(!e?.length)return;let r=n?.range?.trim()||"*",s=n?.preferStable??!0,i=n?.distTags?.latest;if(i&&e.includes(i)&&this.satisfies(r,i))return i;if(s){let a=yw(e,r,{includePrerelease:!1});if(a)return a}return yw(e,r,{includePrerelease:!0})??void 0}majorOf(e){return g_(e)}isExactVersion(e){return y_(e)!==null}isRange(e){return b_(e)!==null}},_n=new Pa});function w_(t){return Math.min(9e5*Math.pow(2,Math.max(0,t-1)),864e5)}var Rn,bw=S(()=>{Ca();Rn=class{constructor(e){this.store=e}async isNegative(e){let n=await Oe(()=>this.store.get(e));return!!n&&n.until>Date.now()}async recordNegative(e){let r=((await Oe(()=>this.store.get(e)))?.attempts||0)+1;await Oe(()=>this.store.set(e,{until:Date.now()+w_(r),attempts:r}))}async clearNegative(e){await Oe(()=>this.store.delete(e))}}});function ww(t,e){let n=new Zs(t,e),r=new ti(n),s=new ni(t,n,_n);return{packageService:new Er(s,n,r),versionResolver:s,cdnClient:n,peerResolver:r}}var St=S(()=>{tf();Oa();rf();sf();of();Qs();of();Xs();tf();Oa();rf();sf();bw()});import*as af from"fs/promises";import*as vw from"crypto";function tt(t){return vw.createHash("sha1").update(t).digest("hex")}async function kt(t){try{return JSON.parse(await af.readFile(t,"utf8"))}catch{return}}async function _a(t){try{return await af.readFile(t,"utf8")}catch{return}}var Ar=S(()=>{"use strict"});import*as Gt from"fs/promises";import*as xt from"path";import*as kw from"os";function ne(){return lf||(lf=S_().catch(()=>gt())),lf}function Ia(t,e){return xt.join(v_,tt(t),e)}async function S_(){await Gt.mkdir(Vt,{recursive:!0});let t=xt.join(Vt,"version.json");if((await kt(t))?.version===Sw)return;let n=await Gt.readdir(Vt).catch(()=>[]);await Promise.all(n.map(r=>Gt.rm(xt.join(Vt,r),{recursive:!0,force:!0}))),await Gt.writeFile(t,JSON.stringify({version:Sw})+`
545
- `,"utf8")}var Sw,Vt,ri,si,Ra,v_,lf,Tr=S(()=>{"use strict";Ar();je();Sw=1,Vt=xt.join(kw.homedir(),".typebulb","cache"),ri=xt.join(Vt,"packages"),si=xt.join(Vt,"proxy"),Ra=xt.join(Vt,"dts"),v_=xt.join(Vt,"emit")});import*as Xt from"fs/promises";import*as xw from"path";async function Fe(t,e){let n=`${t}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;try{await Xt.mkdir(xw.dirname(t),{recursive:!0}),await Xt.writeFile(n,e,"utf8")}catch{gt();return}await Xt.rename(n,t).catch(async()=>{await Xt.rm(n,{force:!0}).catch(()=>{})})}var ii=S(()=>{"use strict";je()});var Cr,cf=S(()=>{"use strict";ii();Ar();Cr=class{constructor(e){this.filePath=e}mem;loadPromise;load(){return this.mem?Promise.resolve(this.mem):(this.loadPromise||(this.loadPromise=kt(this.filePath).then(e=>(this.mem=new Map(Object.entries(e??{})),this.mem))),this.loadPromise)}async get(e){return(await this.load()).get(e)}async set(e,n){let r=await this.load();r.set(e,n),await this.persist(r)}async delete(e){let n=await this.load();n.delete(e)&&await this.persist(n)}async persist(e){await Fe(this.filePath,JSON.stringify(Object.fromEntries(e)))}}});import*as Tw from"fs/promises";import*as nt from"path";function Aw(t,e){return nt.join(k_,$a(t),encodeURIComponent(e)+".json")}function $a(t){return t.replace(/\//g,"__")}var uf,Ew,k_,x_,Na,Cw=S(()=>{"use strict";St();Tr();ii();cf();Ar();uf=nt.join(ri,"indexes"),Ew=nt.join(ri,"pinned"),k_=nt.join(ri,"meta"),x_=nt.join(ri,"negative.json"),Na=class{pinnedMem=new Map;indexMem=new Map;metaMem=new Map;negativeCache=new Rn(new Cr(x_));async getPinnedExact(e,n){let r=`${e}@${n}`;if(this.pinnedMem.has(r))return this.pinnedMem.get(r);await ne();let s=await _a(nt.join(Ew,tt(r)+".txt"));return this.pinnedMem.set(r,s),s}async setPinnedExact(e,n,r){let s=`${e}@${n}`;this.pinnedMem.set(s,r),await ne(),await Fe(nt.join(Ew,tt(s)+".txt"),r)}async getIndex(e){if(this.indexMem.has(e))return this.indexMem.get(e);await ne();let n=await kt(nt.join(uf,$a(e)+".json"));return this.indexMem.set(e,n),n}async setIndex(e,n,r){let s={versions:n,distTags:r,updatedAt:Date.now()};this.indexMem.set(e,s),await ne(),await Fe(nt.join(uf,$a(e)+".json"),JSON.stringify(s))}async invalidateVersionsCache(e){this.indexMem.delete(e),await Tw.rm(nt.join(uf,$a(e)+".json"),{force:!0}).catch(()=>{})}async isNegative(e){return await ne(),this.negativeCache.isNegative(e)}async recordNegative(e){await ne(),await this.negativeCache.recordNegative(e)}async clearNegative(e){await this.negativeCache.clearNegative(e)}async getMeta(e,n){let r=`${e}@${n}`;if(this.metaMem.has(r))return this.metaMem.get(r);await ne();let s=await kt(Aw(e,n));return this.metaMem.set(r,s),s}async setMeta(e,n,r,s,i){let o={dependencies:r,peerDependencies:s,peerDependenciesMeta:i,updatedAt:Date.now()};this.metaMem.set(`${e}@${n}`,o),await ne(),await Fe(Aw(e,n),JSON.stringify(o))}}});var Ow,Pw=S(()=>{"use strict";Ow={async getJson(t){try{let e=await fetch(t,{redirect:"follow"});return e.ok?await e.json():void 0}catch{return}},async head(t){try{let e=await fetch(t,{method:"HEAD",redirect:"follow"});return{ok:e.ok,url:e.url}}catch{return}}}});var E_,La,_w,Rw,B2,df=S(()=>{"use strict";St();Cw();Pw();E_=new Na,{packageService:La,versionResolver:_w,cdnClient:Rw,peerResolver:B2}=ww(E_,Ow)});function Ma(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Iw(){return` <script>
546
- ${vy}
543
+ `)}function Sw(t,e){let n=Ys(t,{target:"client",dependencies:e}).filter(r=>r.type==="UNDECLARED_IMPORT");if(n.length)throw new Error(`Lint failed:
544
+ ${B_(n)}`)}var kw=k(()=>{"use strict";xa()});var zt,ti,of,ni=k(()=>{zt="https://esm.sh",ti="https://cdn.jsdelivr.net/npm/",of="https://data.jsdelivr.com/v1/package/npm/"});function xw(t){let e=(t||"").replace(/^\/+/,"").replace(/\/+$/,"");return e?e.split("/"):[]}var U,Tr,Ew,ri=k(()=>{ni();U=class t{constructor(e,n,r){let s=typeof e=="string"?t.parse(e):e;this.name=s.name,this.version=Tr(n??s.version),this.subpath=Tr(r??s.subpath)}static parse(e){let n=xw(e||"");if(!n.length)return new t({name:""});if(n[0].startsWith("@")){let s=n[0],[i,o]=Ew(n[1]??""),a=Tr(n.slice(2).join("/"));return new t({name:`${s}/${i}`,version:o,subpath:a})}else{let[s,i]=Ew(n[0]),o=Tr(n.slice(1).join("/"));return new t({name:s,version:i,subpath:o})}}static fromUrl(e){try{let n=new URL(e),r=new URL(zt).host,s=new URL(ti).host;if(n.host===r){let i=xw(n.pathname.replace(/^\/v\d+\//,"/"));if(!i.length)return;let o=i[0].startsWith("@")?`${i[0]}/${i[1]??""}`:i[0];return t.parse(o)}if(n.host===s){let i=n.pathname.split("/npm/")[1];if(!i)return;let o=i.split("/")[0]||"";return t.parse(o)}return}catch{return}}format(){let e=this.version?`${this.name}@${this.version}`:this.name;return this.subpath?`${e}/${this.subpath}`:e}root(){return this.name}static rootOf(e){return t.parse(e).name}withVersion(e){return new t({name:this.name,version:Tr(e),subpath:this.subpath})}static isBare(e){return!e||e.startsWith(".")||e.startsWith("/")?!1:!/^[a-z][a-z0-9+.-]*:/i.test(e)}},Tr=t=>t&&t.length?t:void 0,Ew=t=>{let e=t.indexOf("@");return e<0?[t,void 0]:[t.slice(0,e),Tr(t.slice(e+1))]}});async function _e(t){try{return await t()}catch{return}}var Na=k(()=>{});function Rn(t){let e=t||"";return e.startsWith("./")?e.slice(2):e.replace(/^\/+/,"")}function af(t){return t.startsWith("./")?t:`./${t}`}var si,cf=k(()=>{ri();Na();ni();si=class{constructor(e,n){this.cache=e,this.http=n,this.pinMs=1e4,this.versionsIndexMs=1440*60*1e3,this.metaTtlMs=10080*60*1e3,this.pinCache=new Map}baseDir(e){let n=typeof e=="string"?new U(e):e;return`${ti}${n.name}${n.version?`@${n.version}`:""}/`}file(e,n){return new URL(Rn(n),this.baseDir(e)).toString()}packageJson(e){return this.file(e,"package.json")}buildEsmUrl(e,n={}){let{target:r="es2022",bundle:s=!1,external:i}=n,o=new URLSearchParams({target:r});return s&&o.append("bundle",""),i?.length&&o.append("external",i.join(",")),`${zt}/${e}?${o.toString()}`}async resolveExactVersion(e){let n=Date.now(),r=this.pinCache.get(e);if(r&&n-r.ts<this.pinMs)return r.value;let s=await this.tryResolveFromUrls([this.buildEsmUrl(e),`${zt}/${e}`]);return this.pinCache.set(e,{value:s,ts:n}),s}async tryResolveFromUrls(e){for(let n of e){let r=await _e(()=>this.http.head(n)),s=this.parseVersionFromUrl(r?.url||n);if(s)return s}}async fetchVersionsIndex(e){if(await this.cache.isNegative(e))return;let n=await this.cache.getIndex(e);if(n&&Date.now()-n.updatedAt<this.versionsIndexMs)return{versions:n.versions,distTags:n.distTags};let r=await _e(()=>this.http.getJson(`${of}${encodeURIComponent(e)}`));if(!r?.versions?.length){await this.cache.recordNegative(e);return}await this.cache.clearNegative(e);let s=r.tags&&Object.keys(r.tags).length?r.tags:void 0;return await this.cache.setIndex(e,r.versions,s),{versions:r.versions,distTags:s}}parseVersionFromUrl(e){let n=U.fromUrl(e)?.version;return n&&/\d+\.\d+\.\d+/.test(n)?n:void 0}async fetchPackageMeta(e,n){let r=await this.cache.getMeta(e,n);if(r&&Date.now()-r.updatedAt<this.metaTtlMs){let{dependencies:f,peerDependencies:u,peerDependenciesMeta:d}=r;return{name:e,version:n,dependencies:f,peerDependencies:u,peerDependenciesMeta:d}}let s=this.packageJson(new U(`${e}@${n}`)),i=await _e(()=>this.http.getJson(s));if(!i)return;let o=f=>f&&Object.keys(f).length?f:void 0,a=o(i.dependencies),c=o(i.peerDependencies),l=o(i.peerDependenciesMeta);return await this.cache.setMeta(e,n,a,c,l),{name:e,version:n,dependencies:a,peerDependencies:c,peerDependenciesMeta:l}}}});var Aw,ii,lf,j_,oi,La=k(()=>{Aw=t=>t.startsWith("@types/"),ii=t=>Object.keys(t?.peerDependencies||{}).filter(e=>!Aw(e)),lf=t=>Object.keys(t?.dependencies||{}).filter(e=>!Aw(e)),j_=t=>ii(t).filter(e=>!t?.peerDependenciesMeta?.[e]?.optional),oi=class{constructor(e){this.cdn=e}async resolve(e,n){let r=await this.fetchMeta(e),{allRoots:s,autoAddedPeers:i}=await this.expandWithPeers(r,n),o=this.computeFlags(s);return{allRoots:s,flags:o,autoAddedPeers:i}}async fetchMeta(e){return Promise.all(e.map(async({name:n,version:r})=>({name:n,version:r,meta:await this.cdn.fetchPackageMeta(n,r)})))}async expandWithPeers(e,n){let r=new Map(e.map(i=>[i.name,i])),s=[];for(let i of e)for(let o of j_(i.meta))!r.has(o)&&!s.some(a=>a.name===o)&&s.push({name:o,requiredBy:i.name});for(let{name:i,requiredBy:o}of s)try{let a=await n(i),c=await this.cdn.fetchPackageMeta(i,a);r.set(i,{name:i,version:a,meta:c})}catch(a){console.warn(`[typebulb] Failed to resolve peer "${i}" for "${o}":`,a)}return{allRoots:[...r.values()],autoAddedPeers:s.filter(i=>r.has(i.name))}}computeFlags(e){let n=new Set(e.flatMap(i=>ii(i.meta))),r=new Map;for(let i of e)for(let o of lf(i.meta))r.set(o,(r.get(o)||0)+1);let s=new Set([...r.entries()].filter(([,i])=>i>=2).map(([i])=>i));return new Map(e.map(i=>[i.name,{isPeerRoot:n.has(i.name),hasPeers:ii(i.meta).length>0,isSharedDep:s.has(i.name)}]))}}});var ai,uf=k(()=>{ri();Na();ai=class{constructor(e,n,r){this.cache=e,this.cdn=n,this.semver=r}async learnExactVersion(e){let n=await _e(()=>this.cdn.fetchVersionsIndex(e));if(n?.versions?.length){let r=this.semver.selectBestVersion(n.versions,{distTags:n.distTags});if(r)return r}return this.cdn.resolveExactVersion(e)}async resolveExactForRoot(e,n){if(!n)return this.learnExactVersion(e);let r=a=>!this.semver.isRange(n)||this.semver.satisfies(n,a),s=await this.cache.getPinnedExact(e,n);if(s){if(this.semver.isExactVersion(s)&&r(s))return s;console.debug("[typebulb] cached version for",e,"is not exact or not in",n,"(",s,"); re-resolving from registry")}let i=async a=>{if(a&&this.semver.isExactVersion(a)&&r(a))return await this.cache.setPinnedExact(e,n,a),a},o=await _e(()=>this.cdn.fetchVersionsIndex(e));if(o?.versions?.length){let a=this.semver.selectBestVersion(o.versions,{range:n,distTags:o.distTags});if(a){let c=await i(a);if(c)return c}else{console.debug("[typebulb] refreshing version cache for",e,"(",n,"not in cached set \u2014 likely a new release)"),await this.cache.invalidateVersionsCache(e);let c=await _e(()=>this.cdn.fetchVersionsIndex(e));if(c?.versions?.length){let l=await i(this.semver.selectBestVersion(c.versions,{range:n,distTags:c.distTags}));if(l)return l}}}return i(await this.cdn.resolveExactVersion(`${e}@${n}`))}async effectivePackage(e,n){let r=new U(e),s=r.root(),i=n[s],o=i?await _e(()=>this.resolveExactForRoot(s,i)):void 0;return{effectivePackage:o?r.withVersion(o).format():e,root:s,range:i,pinned:o}}}});import{init as F_,parse as U_}from"es-module-lexer";var Cr,df=k(()=>{ri();ni();La();Cr=class t{constructor(e,n,r){this.version=e,this.cdn=n,this.peer=r}extractImportsSync(e){let n=new Set;for(let r of t.importPatterns){r.lastIndex=0;for(let s of e.matchAll(r))U.isBare(s[1])&&n.add(s[1])}return Array.from(n)}async extractImports(e){let n=new Set,r=s=>{U.isBare(s)&&n.add(s)};try{await F_;let[s]=U_(e);s.forEach(i=>r(e.slice(i.s,i.e).trim()))}catch{return this.extractImportsSync(e)}return Array.from(n)}async buildImportMap(e,n,r){let s=(await this.extractImports(e)).filter(u=>!r?.has(U.rootOf(u))),i=[...new Set(s.map(U.rootOf))],o=await Promise.all(i.map(async u=>({name:u,version:await this.resolveVersion(u,n)}))),{allRoots:a,flags:c,autoAddedPeers:l}=await this.peer.resolve(o,u=>this.resolveVersion(u,n)),f=this.buildEntries([...s,...l.map(u=>u.name)],a,c);return{importMap:{imports:Object.fromEntries(f)},prefetchUrls:f.map(([,u])=>u)}}async resolveVersion(e,n){let r=n[e],s=await this.version.resolveExactForRoot(e,r);if(!s)throw new Error(`Cannot resolve ${r?`${e}@${r}`:e}: no matching version is published (the package or version may not exist, or the registry was unreachable).`);return s}buildEntries(e,n,r){let s=new Map(n.map(p=>[p.name,p])),i=p=>{let h=s.get(U.rootOf(p));return new U(p).withVersion(h.version).format()},o=new Set([...r.entries()].filter(([,p])=>p.isPeerRoot||p.isSharedDep).map(([p])=>p)),a=new Set(e.filter(p=>p!==U.rootOf(p)).map(U.rootOf)),c=[],l=new Set,f=new Set(e.filter(p=>p===U.rootOf(p))),u=new Set;for(let p of e){let h=U.rootOf(p),m=s.get(h),{isPeerRoot:g,hasPeers:b,isSharedDep:C}=r.get(h),T=a.has(h),E=p!==h,O=!(g||C)&&(T||!b),_=this.singletonDepsOf(m,o),x=E&&f.has(h);x&&u.add(h);let M=x?[..._,h]:_.length?_:void 0;c.push([p,this.cdn.buildEsmUrl(i(p),{bundle:O,external:M})]),l.add(p)}let d=new Set([...o,...u]);for(let p of d)s.has(p)&&(l.has(p)||c.push([p,this.cdn.buildEsmUrl(i(p),{})]),c.push([`${p}/`,`${zt}/${i(p)}/`]));return c}singletonDepsOf(e,n){return[...new Set([...ii(e.meta),...lf(e.meta)])].filter(r=>n.has(r))}};Cr.importPatterns=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g]});import{gt as Tw,satisfies as q_,maxSatisfying as Cw,major as J_,valid as W_,validRange as K_}from"semver";var Ma,In,ff=k(()=>{Ma=class{cmp(e,n){return e===n?0:Tw(e,n)?1:Tw(n,e)?-1:0}satisfies(e,n){return!e||!e.trim()?!0:!!q_(n,e,{includePrerelease:!0})}selectBestVersion(e,n){if(!e?.length)return;let r=n?.range?.trim()||"*",s=n?.preferStable??!0,i=n?.distTags?.latest;if(i&&e.includes(i)&&this.satisfies(r,i))return i;if(s){let a=Cw(e,r,{includePrerelease:!1});if(a)return a}return Cw(e,r,{includePrerelease:!0})??void 0}majorOf(e){return J_(e)}isExactVersion(e){return W_(e)!==null}isRange(e){return K_(e)!==null}},In=new Ma});function H_(t){return Math.min(9e5*Math.pow(2,Math.max(0,t-1)),864e5)}var $n,Ow=k(()=>{Na();$n=class{constructor(e){this.store=e}async isNegative(e){let n=await _e(()=>this.store.get(e));return!!n&&n.until>Date.now()}async recordNegative(e){let r=((await _e(()=>this.store.get(e)))?.attempts||0)+1;await _e(()=>this.store.set(e,{until:Date.now()+H_(r),attempts:r}))}async clearNegative(e){await _e(()=>this.store.delete(e))}}});function Pw(t,e){let n=new si(t,e),r=new oi(n),s=new ai(t,n,In);return{packageService:new Cr(s,n,r),versionResolver:s,cdnClient:n,peerResolver:r}}var kt=k(()=>{cf();La();uf();df();ff();ri();ff();ni();cf();La();uf();df();Ow()});import*as pf from"fs/promises";import*as _w from"crypto";function nt(t){return _w.createHash("sha1").update(t).digest("hex")}async function xt(t){try{return JSON.parse(await pf.readFile(t,"utf8"))}catch{return}}async function Da(t){try{return await pf.readFile(t,"utf8")}catch{return}}var Or=k(()=>{"use strict"});import*as Vt from"fs/promises";import*as Et from"path";import*as Iw from"os";function se(){return hf||(hf=Y_().catch(()=>yt())),hf}function ja(t,e){return Et.join(z_,nt(t),e)}async function Y_(){await Vt.mkdir(Yt,{recursive:!0});let t=Et.join(Yt,"version.json");if((await xt(t))?.version===Rw)return;let n=await Vt.readdir(Yt).catch(()=>[]);await Promise.all(n.map(r=>Vt.rm(Et.join(Yt,r),{recursive:!0,force:!0}))),await Vt.writeFile(t,JSON.stringify({version:Rw})+`
545
+ `,"utf8")}var Rw,Yt,ci,li,Ba,z_,hf,Pr=k(()=>{"use strict";Or();Ue();Rw=1,Yt=Et.join(Iw.homedir(),".typebulb","cache"),ci=Et.join(Yt,"packages"),li=Et.join(Yt,"proxy"),Ba=Et.join(Yt,"dts"),z_=Et.join(Yt,"emit")});import*as Gt from"fs/promises";import*as $w from"path";async function qe(t,e){let n=`${t}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;try{await Gt.mkdir($w.dirname(t),{recursive:!0}),await Gt.writeFile(n,e,"utf8")}catch{yt();return}await Gt.rename(n,t).catch(async()=>{await Gt.rm(n,{force:!0}).catch(()=>{})})}var ui=k(()=>{"use strict";Ue()});var _r,mf=k(()=>{"use strict";ui();Or();_r=class{constructor(e){this.filePath=e}mem;loadPromise;load(){return this.mem?Promise.resolve(this.mem):(this.loadPromise||(this.loadPromise=xt(this.filePath).then(e=>(this.mem=new Map(Object.entries(e??{})),this.mem))),this.loadPromise)}async get(e){return(await this.load()).get(e)}async set(e,n){let r=await this.load();r.set(e,n),await this.persist(r)}async delete(e){let n=await this.load();n.delete(e)&&await this.persist(n)}async persist(e){await qe(this.filePath,JSON.stringify(Object.fromEntries(e)))}}});import*as Mw from"fs/promises";import*as rt from"path";function Lw(t,e){return rt.join(V_,Fa(t),encodeURIComponent(e)+".json")}function Fa(t){return t.replace(/\//g,"__")}var gf,Nw,V_,G_,Ua,Dw=k(()=>{"use strict";kt();Pr();ui();mf();Or();gf=rt.join(ci,"indexes"),Nw=rt.join(ci,"pinned"),V_=rt.join(ci,"meta"),G_=rt.join(ci,"negative.json"),Ua=class{pinnedMem=new Map;indexMem=new Map;metaMem=new Map;negativeCache=new $n(new _r(G_));async getPinnedExact(e,n){let r=`${e}@${n}`;if(this.pinnedMem.has(r))return this.pinnedMem.get(r);await se();let s=await Da(rt.join(Nw,nt(r)+".txt"));return this.pinnedMem.set(r,s),s}async setPinnedExact(e,n,r){let s=`${e}@${n}`;this.pinnedMem.set(s,r),await se(),await qe(rt.join(Nw,nt(s)+".txt"),r)}async getIndex(e){if(this.indexMem.has(e))return this.indexMem.get(e);await se();let n=await xt(rt.join(gf,Fa(e)+".json"));return this.indexMem.set(e,n),n}async setIndex(e,n,r){let s={versions:n,distTags:r,updatedAt:Date.now()};this.indexMem.set(e,s),await se(),await qe(rt.join(gf,Fa(e)+".json"),JSON.stringify(s))}async invalidateVersionsCache(e){this.indexMem.delete(e),await Mw.rm(rt.join(gf,Fa(e)+".json"),{force:!0}).catch(()=>{})}async isNegative(e){return await se(),this.negativeCache.isNegative(e)}async recordNegative(e){await se(),await this.negativeCache.recordNegative(e)}async clearNegative(e){await this.negativeCache.clearNegative(e)}async getMeta(e,n){let r=`${e}@${n}`;if(this.metaMem.has(r))return this.metaMem.get(r);await se();let s=await xt(Lw(e,n));return this.metaMem.set(r,s),s}async setMeta(e,n,r,s,i){let o={dependencies:r,peerDependencies:s,peerDependenciesMeta:i,updatedAt:Date.now()};this.metaMem.set(`${e}@${n}`,o),await se(),await qe(Lw(e,n),JSON.stringify(o))}}});var Bw,jw=k(()=>{"use strict";Bw={async getJson(t){try{let e=await fetch(t,{redirect:"follow"});return e.ok?await e.json():void 0}catch{return}},async head(t){try{let e=await fetch(t,{method:"HEAD",redirect:"follow"});return{ok:e.ok,url:e.url}}catch{return}}}});var X_,qa,Fw,Uw,$U,yf=k(()=>{"use strict";kt();Dw();jw();X_=new Ua,{packageService:qa,versionResolver:Fw,cdnClient:Uw,peerResolver:$U}=Pw(X_,Bw)});function Ja(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function qw(){return` <script>
546
+ ${_y}
547
547
  (function () {
548
548
  try {
549
549
  var key = function () { return 'tb-scroll:' + location.pathname + location.search; };
@@ -556,14 +556,14 @@ ${vy}
556
556
  });
557
557
  } catch (e) {}
558
558
  })();
559
- </script>`}function Da(t,e){return` <script>
559
+ </script>`}function Wa(t,e){return` <script>
560
560
  (function() {
561
561
  try {
562
- var KEY = ${Et(JSON.stringify("tb-theme:"+t))};
562
+ var KEY = ${At(JSON.stringify("tb-theme:"+t))};
563
563
  var doc = document.documentElement;
564
564
  var mq = window.matchMedia('(prefers-color-scheme: dark)');
565
565
  var os = function() { return mq.matches ? 'dark' : 'light'; };
566
- var FORCED = ${Et(JSON.stringify(e??null))};
566
+ var FORCED = ${At(JSON.stringify(e??null))};
567
567
  var stored = function() {
568
568
  try { var v = localStorage.getItem(KEY); return (v === 'dark' || v === 'light') ? v : undefined; }
569
569
  catch (e) { return undefined; }
@@ -601,7 +601,7 @@ ${vy}
601
601
  });
602
602
  } catch (e) {}
603
603
  })();
604
- </script>`}var Et,$w,ff,A_,T_,Ba,Or=S(()=>{"use strict";te();te();Et=t=>t.replace(/<\/script/gi,"<\\/script");$w=30*6e4,ff=1e3,A_=6e4,T_=3e4,Ba=(t="'/__reload'")=>`
604
+ </script>`}var At,Jw,bf,Q_,Z_,Ka,Rr=k(()=>{"use strict";re();re();At=t=>t.replace(/<\/script/gi,"<\\/script");Jw=30*6e4,bf=1e3,Q_=6e4,Z_=3e4,Ka=(t="'/__reload'")=>`
605
605
  let es = null;
606
606
  let bootId = null;
607
607
  let firstErrorAt = 0;
@@ -616,9 +616,9 @@ ${vy}
616
616
  es.onerror = () => {
617
617
  if (!firstErrorAt) firstErrorAt = Date.now();
618
618
  // Inside the replace window, EventSource's own retry is faster than anything we'd schedule.
619
- if (Date.now() - firstErrorAt <= ${A_}) return;
619
+ if (Date.now() - firstErrorAt <= ${Q_}) return;
620
620
  es.close();
621
- backoff = Math.min(${T_}, backoff ? backoff * 2 : ${ff} * 2);
621
+ backoff = Math.min(${Z_}, backoff ? backoff * 2 : ${bf} * 2);
622
622
  setTimeout(tbConnect, backoff);
623
623
  };
624
624
  };
@@ -634,7 +634,7 @@ ${vy}
634
634
  // A relay open (TB-VSCode-Browser.md): the CLI asks a page of ours inside VS Code to open a URL,
635
635
  // since its integrated browser honors a gesture-less window.open and keeps the new tab in-editor.
636
636
  tbOn('open-url', (e) => { window.open(e.data, '_blank', 'noopener'); });
637
- tbConnect();`});var Nw,Lw=S(()=>{"use strict";Or();te();Nw=`
637
+ tbConnect();`});var Ww,Kw=k(()=>{"use strict";Rr();re();Ww=`
638
638
  (() => {
639
639
  // Inline (bulb-in-a-bulb): runs inside a sandboxed iframe with no parent
640
640
  // bridge, so privileged tb.* (AI, fs, server RPC) can't reach a host and would
@@ -1078,7 +1078,7 @@ ${vy}
1078
1078
  },
1079
1079
 
1080
1080
  // Environment ('inline' when running as a bulb-in-a-bulb)
1081
- mode: isFramed ? '${rr.inline}' : '${rr.local}',
1081
+ mode: isFramed ? '${ir.inline}' : '${ir.local}',
1082
1082
 
1083
1083
  // Theme accessor - delegates to the head-script engine (window.__tbTheme).
1084
1084
  // Get: override slot ('dark'|'light'|undefined). Set applies + persists
@@ -1507,7 +1507,7 @@ ${vy}
1507
1507
  if (relayed) history.replaceState(null, '', location.pathname + location.search);
1508
1508
  const tbStreamUrl = '/__reload?bulb=' + encodeURIComponent(window.__TB_BULB__ || '')
1509
1509
  + (relayed ? '&relay=' + Math.random().toString(36).slice(2) : '');
1510
- ${Ba("tbStreamUrl")}
1510
+ ${Ka("tbStreamUrl")}
1511
1511
  // Told to go, the page goes: it closes the tab, and where the browser refuses a script the close
1512
1512
  // (a tab that wasn't script-opened and has history) it replaces itself with a note naming the
1513
1513
  // reason. The note is a blob document, never a served route \u2014 a note that needs the server
@@ -1594,20 +1594,20 @@ ${Ba("tbStreamUrl")}
1594
1594
  });
1595
1595
  }
1596
1596
  })();
1597
- `});function Mw(t){let{name:e,code:n,css:r,html:s,data:i,insight:o,importMap:a,theme:l,inline:c,dir:f,source:d,bulbKey:u,compileError:p}=t,h=s.trim()||'<div id="app"></div>',m=c?"":`
1598
- `+Yu,g={imports:R_(a.imports)};return`<!DOCTYPE html>
1597
+ `});function Hw(t){let{name:e,code:n,css:r,html:s,data:i,insight:o,importMap:a,theme:c,inline:l,dir:f,source:u,bulbKey:d,compileError:p}=t,h=s.trim()||'<div id="app"></div>',m=l?"":`
1598
+ `+ed,g={imports:sR(a.imports)};return`<!DOCTYPE html>
1599
1599
  <html>
1600
1600
  <head>
1601
1601
  <meta charset="utf-8">
1602
1602
  <meta name="viewport" content="width=device-width, initial-scale=1">
1603
- <title>${Ma(e)} - typebulb</title>
1604
- ${Da(e,l)}
1605
- ${c?"":Iw()}
1603
+ <title>${Ja(e)} - typebulb</title>
1604
+ ${Wa(e,c)}
1605
+ ${l?"":qw()}
1606
1606
  <script type="importmap">
1607
1607
  ${JSON.stringify(g,null,2)}
1608
1608
  </script>
1609
1609
  <style>
1610
- ${Os}${m}
1610
+ ${Ns}${m}
1611
1611
  </style>
1612
1612
  <style>
1613
1613
  ${r}
@@ -1616,27 +1616,27 @@ ${r}
1616
1616
  <body>
1617
1617
  ${h}
1618
1618
 
1619
- ${i.length>0?`<script>window.__TB_DATA__ = ${Et(JSON.stringify(i))};</script>`:""}
1620
- ${o?`<script>window.__TB_INSIGHT__ = ${Et(JSON.stringify(o))};</script>`:""}
1621
- ${f?`<script>window.__TB_DIR__ = ${Et(JSON.stringify(f))};</script>`:""}
1622
- ${u?`<script>window.__TB_BULB__ = ${Et(JSON.stringify(u))};</script>`:""}
1623
- ${p?`<script>window.__TB_COMPILE_ERROR__ = ${Et(JSON.stringify(p))};</script>`:""}
1619
+ ${i.length>0?`<script>window.__TB_DATA__ = ${At(JSON.stringify(i))};</script>`:""}
1620
+ ${o?`<script>window.__TB_INSIGHT__ = ${At(JSON.stringify(o))};</script>`:""}
1621
+ ${f?`<script>window.__TB_DIR__ = ${At(JSON.stringify(f))};</script>`:""}
1622
+ ${d?`<script>window.__TB_BULB__ = ${At(JSON.stringify(d))};</script>`:""}
1623
+ ${p?`<script>window.__TB_COMPILE_ERROR__ = ${At(JSON.stringify(p))};</script>`:""}
1624
1624
 
1625
1625
  <script>
1626
- ${ky}
1627
- ${Nw}
1626
+ ${Iy}
1627
+ ${Ww}
1628
1628
  </script>
1629
1629
 
1630
- ${__}
1630
+ ${rR}
1631
1631
 
1632
- ${O_(n,d)}
1632
+ ${tR(n,u)}
1633
1633
  </body>
1634
- </html>`}function O_(t,e){let n=["",...C_],r=e?Array(Math.max(0,e.codeLine-n.length-1)).fill(""):[],s=[...n,...r,Et(t)].join(`
1635
- `);return`<script type="module">${s}${P_(e,s)}
1636
- </script>`}function P_(t,e){if(!t)return"";let n=e.split(`
1634
+ </html>`}function tR(t,e){let n=["",...eR],r=e?Array(Math.max(0,e.codeLine-n.length-1)).fill(""):[],s=[...n,...r,At(t)].join(`
1635
+ `);return`<script type="module">${s}${nR(e,s)}
1636
+ </script>`}function nR(t,e){if(!t)return"";let n=e.split(`
1637
1637
  `).length,r={version:3,file:t.file,sources:[`/__source/${t.file}`],names:[],mappings:["AAAA",...Array(Math.max(0,n-1)).fill("AACA")].join(";")};return`
1638
1638
  //# sourceURL=${t.file.replace(/\s/g,"%20")}
1639
- //# sourceMappingURL=data:application/json;charset=utf-8,${encodeURIComponent(JSON.stringify(r))}`}function R_(t){let e={};for(let[n,r]of Object.entries(t))e[n]=r.startsWith("https://")?"/proxy/"+r:r;return e}var C_,__,Dw=S(()=>{"use strict";te();Lw();Or();C_=["globalThis.__tbEntryRan = true; /* import graph resolved \u2014 the load-failure backstop's signal (imports hoist above this line) */","await globalThis.__tbBoot; /* #tb= fragment restore, set by the shim when present (TB-Inference.md) */"];__=`<script>
1639
+ //# sourceMappingURL=data:application/json;charset=utf-8,${encodeURIComponent(JSON.stringify(r))}`}function sR(t){let e={};for(let[n,r]of Object.entries(t))e[n]=r.startsWith("https://")?"/proxy/"+r:r;return e}var eR,rR,zw=k(()=>{"use strict";re();Kw();Rr();eR=["globalThis.__tbEntryRan = true; /* import graph resolved \u2014 the load-failure backstop's signal (imports hoist above this line) */","await globalThis.__tbBoot; /* #tb= fragment restore, set by the shim when present (TB-Inference.md) */"];rR=`<script>
1640
1640
  (function () {
1641
1641
  var framed = window.parent !== window;
1642
1642
  var post = function (m) { try { parent.postMessage(m, '*'); } catch (e) {} }; /* framed only */
@@ -1735,20 +1735,20 @@ ${O_(n,d)}
1735
1735
  }
1736
1736
  });
1737
1737
  })();
1738
- </script>`});import*as Fa from"fs/promises";import*as ja from"path";import{existsSync as Bw,readFileSync as I_}from"fs";import{execFile as $_}from"child_process";import{promisify as N_}from"util";import{builtinModules as L_}from"node:module";import{satisfies as M_}from"semver";async function Ua(t,e,n,r){let i=t.map(c=>F_(c,n)).filter(c=>!U_(c,e));if(i.length===0)return;let o=i.filter(c=>!j_.test(c));if(o.length)throw new Error(`Refusing to install npm spec(s) with unsupported characters: ${o.join(", ")}
1739
- Use a plain name with an exact / caret / tilde range (e.g. three@^0.160.0).`);await Fa.mkdir(e,{recursive:!0});let a=ja.join(e,"package.json");Bw(a)||await Fa.writeFile(a,JSON.stringify({name:"typebulb-server",private:!0})),console.log(` Installing: ${i.join(", ")}`);let l=["--no-audit","--no-fund",...r?.ignoreScripts?["--ignore-scripts"]:[]];await D_("npm",["install",...l,...i],{cwd:e,shell:!0})}function F_(t,e){if(!e||F.parse(t).version)return t;let n=e[t];return n?`${t}@${n}`:t}function U_(t,e){let{name:n,version:r}=F.parse(t),s=ja.join(e,"node_modules",n);if(!Bw(s))return!1;if(!r)return!0;try{let i=JSON.parse(I_(ja.join(s,"package.json"),"utf-8")).version;return M_(i,r)}catch{return!1}}function qa(t){let e=new Set,n=/\bimport\s+(?:[\s\S]*?\s+from\s+)?['"]([^./][^'"]*)['"]/g,r;for(;r=n.exec(t);){let s=r[1];if(s.includes(":"))continue;let i=F.rootOf(s);B_.has(i)||e.add(i)}return[...e]}var D_,B_,j_,pf=S(()=>{"use strict";St();D_=N_($_),B_=new Set(L_),j_=/^(@[a-z0-9._-]+\/)?[a-z0-9._-]+(@[a-zA-Z0-9.^~*x-]+)?$/i});import*as Ue from"fs/promises";import*as Le from"path";function Pr(t,e){let n=Le.resolve(e,t),r=Le.normalize(e),s=Le.normalize(n);if(s!==r&&!s.startsWith(r+Le.sep))throw new Error("Path traversal detected - access denied");return n}async function oi(t,e){return Ue.readFile(Pr(t,e))}async function Ja(t,e,n){let r=Pr(t,n);await Ue.mkdir(Le.dirname(r),{recursive:!0}),await Ue.writeFile(r,typeof e=="string"?e:Buffer.from(e))}async function Wa(t,e){let n=Pr(t,e),r=await Ue.readdir(n,{withFileTypes:!0});return Promise.all(r.map(async s=>{let i=await Ue.stat(Le.join(n,s.name)).then(o=>o.mtimeMs).catch(()=>0);return{name:s.name,dir:s.isDirectory(),mtime:i}}))}async function Ka(t,e){let n=Pr(t,e);if(Le.normalize(n)===Le.normalize(e))throw new Error("Cannot remove the bulb's folder itself: remove its contents instead");await Ue.rm(n,{recursive:!0})}var hf=S(()=>{"use strict"});async function jw(t){let e=vt(t.provider,t.model);if(typeof e=="string")throw new Error(e);let n=await zt(e,t);if(!n.ok){let r=await vr(n,e.protocol);throw new Error(r.message)}return{response:n,protocol:e.protocol}}async function q_(t){let{response:e,protocol:n}=await jw(t);return Sr(e,n)}async function*J_(t){let{response:e,protocol:n}=await jw(t);yield*On(e,n)}function Fw(t){let e=Object.assign(q_,{stream:J_}),n={read:async r=>{let s=await oi(r,t);try{return new TextDecoder("utf-8",{fatal:!0}).decode(s)}catch{throw new Error(`File is not valid UTF-8 text: ${r} \u2014 use tb.fs.readBytes() for binary files.`)}},readBytes:async r=>new Uint8Array(await oi(r,t)),write:async(r,s)=>(await Ja(r,s,t),!0),list:async(r=".")=>Wa(r,t),remove:async r=>(await Ka(r,t),!0)};globalThis.tb=Object.freeze({log:(...r)=>{console.log(...r)},ai:e,fs:n,dir:t,models:()=>wt(),aiAccess:ba,mode:rr.local})}var Uw=S(()=>{"use strict";Kt();te();Ta();An();hf()});import*as Qt from"fs/promises";import*as pe from"path";import{pathToFileURL as W_}from"url";async function qw(t){let n=(await Qt.readdir(t)).find(r=>r.endsWith(".bulb.md"));return n?pe.join(t,n):void 0}function _r(t){let e=pe.resolve(t);return pe.join(pe.dirname(e),pe.basename(e).replace(/\.bulb\.md$/,""))}function Rr(t){let[e,n,r,s]=t.split(pe.sep).slice(-4);if(!(e!=="typebulbs"||n!=="u"||!r||!s?.endsWith(".bulb.md")))return{userSlug:r,slug:s.slice(0,-8)}}async function rt(t){let e=await Qt.readFile(t,"utf-8"),n=Wn(e),r=pr(n);return{bulb:r,config:Yr(r.config),warnings:Xp(e),starts:n.starts}}function mf(t){let e=pe.basename(t).replace(/\.bulb\.md$/i,"");return pe.join(pe.dirname(t),".typebulb",`${e}.server.mjs`)}async function ai(t,e,n,r){let s=Qd(t,{serverOnly:!0});if(s.error)throw new Error(`Server compilation error: ${s.error}`);let i=s.code;n&&(i=await Kp(i,n));let o=pe.join(pe.dirname(e),".typebulb");await Qt.mkdir(o,{recursive:!0});let a=qa(i);a.length>0&&await Ua(a,o,r);let l=mf(e);return await Qt.writeFile(l,i,"utf-8"),Fw(_r(e)),await import(`${W_(l).href}?t=${Date.now()}`)}async function gf(t,e,n,r){let{bulb:s,config:i,starts:o}=await rt(t),a=jo(s.data),l,c=h=>{l??=h instanceof Error?h.message:String(h)};try{dw(s.code,i.dependencies??{})}catch(h){c(h)}let f=Qd(s.code,{jsxImportSource:i.ts?.jsxImportSource});f.error&&c(f.error);let d={imports:{}};if(!l)try{({importMap:d}=await La.buildImportMap(f.code,i.dependencies??{},r?new Set([r.name]):void 0))}catch(h){c(`Dependency resolution failed: ${h instanceof Error?h.message:String(h)}`)}l&&console.error("Build error:",l),r&&(d.imports[r.name]=r.entryUrl);let u=Mw({name:s.name,code:l?"":f.code,css:s.css,html:s.html,data:a,insight:s.insight,importMap:d,dir:_r(t),watch:e,source:{file:pe.basename(t),codeLine:o.get("code.tsx")??1},bulbKey:Bs(t),compileError:l}),p;return s.server&&n&&(p=await ai(s.server,t,r,i.dependencies)),{html:u,bulb:s,serverExports:p,buildError:l}}var In,At=S(()=>{"use strict";qs();uw();fw();df();Dw();pf();Mi();je();Uw();In=t=>pe.join(_r(t),"assets")});import*as Me from"fs/promises";import*as qe from"path";import{createHash as K_}from"crypto";async function bf(t,e,n){let r=[...t],s=async()=>{for(let i=r.shift();i!==void 0;i=r.shift())await n(i)};await Promise.all(Array.from({length:Math.min(e,t.length)},s))}function Ir(t){try{return JSON.parse(t).error||t}catch{return t}}async function vf(t,e){try{let n=await fetch(li(t),{headers:e.token?{Authorization:`Bearer ${e.token}`}:{},signal:e.timeoutMs?AbortSignal.timeout(e.timeoutMs):void 0});return n.ok?n.headers.get("content-type")?.includes("json")?{entries:await n.json()}:{error:"manifest response is not JSON \u2014 wrong origin?"}:{error:`manifest request failed (${n.status}): ${Ir(await n.text())}`}}catch(n){return{error:n instanceof Error?n.message:String(n)}}}function Sf(t,e){be(e);let n=process.env.TYPEBULB_ORIGIN||H_;try{return Ya(t,process.cwd(),n)}catch(r){console.error(r instanceof Error?r.message:String(r)),process.exit(1)}}function Ya(t,e,n){if(/^https?:\/\//i.test(t)){let i=new URL(t),o=i.pathname.split("/").filter(Boolean).map(decodeURIComponent),a=o[0]==="api"&&o[1]==="scripts"?o.slice(2):o;if(a[0]!=="u"||!a[1]||!a[2])throw new Error(`Not a bulb URL: ${t}
1740
- Expected <origin>/u/<user>/<slug>`);let l=a[1],c=a[2].replace(/(\.bulb)?\.md$/,"");return{origin:i.origin,userSlug:l,slug:c,dest:qe.join(e,Ha(l,c))}}let r=qe.resolve(e,t),s=Rr(r);if(!s)throw new Error(`Not a conventional bulb path: ${t}
1741
- A pull target must be a bulb URL, or a local file at typebulbs/u/<user>/<slug>.bulb.md \u2014 the path is its remote identity.`);return{origin:n,...s,dest:r}}async function z_(t,e){let n=await vf(t,e);if("error"in n||!n.entries.length)return{kind:"none"};let r=n.entries,s=In(t.dest),i=[],o=[],a=0;for(let l of r){let c=await Me.readFile(qe.join(s,...l.path.split("/"))).catch(()=>{});c===void 0?i.push(l.path):wf(c)===l.md5?a++:e.force?i.push(l.path):o.push(l.path)}return o.length?{kind:"conflict",paths:o}:{kind:"plan",toGet:i,unchanged:a}}async function Y_(t,e,n){let r=In(t.dest),s=[],i=0;return await bf(e.toGet,4,async o=>{try{let a=await fetch(`${li(t)}/${za(o)}`,{headers:n.token?{Authorization:`Bearer ${n.token}`}:{},signal:AbortSignal.timeout(n.timeoutMs??3e4)});if(!a.ok){s.push(`${o}: HTTP ${a.status}`);return}let l=qe.join(r,...o.split("/"));await Me.mkdir(qe.dirname(l),{recursive:!0}),await Me.writeFile(l,new Uint8Array(await a.arrayBuffer())),i++}catch(a){s.push(`${o}: ${a instanceof Error?a.message:String(a)}`)}}),{downloaded:i,unchanged:e.unchanged,errors:s}}async function Va(t,e={}){let n=await fetch(yf(t),{headers:e.token?{Authorization:`Bearer ${e.token}`}:{},signal:e.timeoutMs?AbortSignal.timeout(e.timeoutMs):void 0});if(!n.ok)return{kind:"http-error",status:n.status};let r=n.headers.get("content-type");if(!r?.includes("text/markdown"))return{kind:"not-markdown",contentType:r??void 0};let s=await n.text(),i;try{i=await Me.readFile(t.dest,"utf-8")}catch{}let o=i!==void 0&&V_(i,s);if(i!==void 0&&!o&&!e.force){let{mtime:c}=await Me.stat(t.dest);return{kind:"conflict",dest:t.dest,localMtime:c,remoteLastModified:n.headers.get("last-modified")??void 0}}let a=await z_(t,e);if(a.kind==="conflict")return{kind:"asset-conflict",dest:t.dest,paths:a.paths};if(!o){await Me.mkdir(qe.dirname(t.dest),{recursive:!0}),await Me.writeFile(t.dest,s);let c=new Date(n.headers.get("last-modified")??"");isNaN(c.getTime())||await Me.utimes(t.dest,new Date,c)}let l=a.kind==="plan"?await Y_(t,a,e):void 0;return o?{kind:"up-to-date",dest:t.dest,assets:l}:{kind:"written",dest:t.dest,created:i===void 0,assets:l}}function V_(t,e){let n=i=>i.replace(/\r\n/g,`
1742
- `),r=Ve(n(t)),s=Ve(n(e));return!r||!s?n(t)===n(e):r.frontmatter.name===s.frontmatter.name&&Ye.every(i=>(r.files.get(de[i].path)||"")===(s.files.get(de[i].path)||""))}async function Ww(t,e){t||(console.error("Usage: typebulb pull <bulb url | typebulbs/u/<user>/<slug>.bulb.md>"),process.exit(1));let n=Sf(t,e.mode),r=`${n.origin}/u/${n.userSlug}/${n.slug}`,s;try{s=await Va(n,{force:e.force,token:process.env.TYPEBULB_TOKEN})}catch(o){console.error(`Could not reach ${n.origin}: ${o instanceof Error?o.message:String(o)}`),process.exitCode=1;return}let i=qe.relative(process.cwd(),n.dest)||n.dest;switch(s.kind){case"written":console.log(`pulled ${r} \u2192 ${i}${s.created?"":" (overwritten)"}`),Jw(s.assets);return;case"up-to-date":console.log(`up to date: ${i}`),Jw(s.assets);return;case"conflict":console.error(`Refusing to overwrite ${i} \u2014 it differs from ${r}
1738
+ </script>`});import*as za from"fs/promises";import*as Ha from"path";import{existsSync as Yw,readFileSync as iR}from"fs";import{execFile as oR}from"child_process";import{promisify as aR}from"util";import{builtinModules as cR}from"node:module";import{satisfies as lR}from"semver";async function Ya(t,e,n,r){let i=t.map(l=>pR(l,n)).filter(l=>!hR(l,e));if(i.length===0)return;let o=i.filter(l=>!fR.test(l));if(o.length)throw new Error(`Refusing to install npm spec(s) with unsupported characters: ${o.join(", ")}
1739
+ Use a plain name with an exact / caret / tilde range (e.g. three@^0.160.0).`);await za.mkdir(e,{recursive:!0});let a=Ha.join(e,"package.json");Yw(a)||await za.writeFile(a,JSON.stringify({name:"typebulb-server",private:!0})),console.log(` Installing: ${i.join(", ")}`);let c=["--no-audit","--no-fund",...r?.ignoreScripts?["--ignore-scripts"]:[]];await uR("npm",["install",...c,...i],{cwd:e,shell:!0})}function pR(t,e){if(!e||U.parse(t).version)return t;let n=e[t];return n?`${t}@${n}`:t}function hR(t,e){let{name:n,version:r}=U.parse(t),s=Ha.join(e,"node_modules",n);if(!Yw(s))return!1;if(!r)return!0;try{let i=JSON.parse(iR(Ha.join(s,"package.json"),"utf-8")).version;return lR(i,r)}catch{return!1}}function Va(t){let e=new Set,n=/\bimport\s+(?:[\s\S]*?\s+from\s+)?['"]([^./][^'"]*)['"]/g,r;for(;r=n.exec(t);){let s=r[1];if(s.includes(":"))continue;let i=U.rootOf(s);dR.has(i)||e.add(i)}return[...e]}var uR,dR,fR,wf=k(()=>{"use strict";kt();uR=aR(oR),dR=new Set(cR),fR=/^(@[a-z0-9._-]+\/)?[a-z0-9._-]+(@[a-zA-Z0-9.^~*x-]+)?$/i});import*as Je from"fs/promises";import*as Me from"path";function Ir(t,e){let n=Me.resolve(e,t),r=Me.normalize(e),s=Me.normalize(n);if(s!==r&&!s.startsWith(r+Me.sep))throw new Error("Path traversal detected - access denied");return n}async function di(t,e){return Je.readFile(Ir(t,e))}async function Ga(t,e,n){let r=Ir(t,n);await Je.mkdir(Me.dirname(r),{recursive:!0}),await Je.writeFile(r,typeof e=="string"?e:Buffer.from(e))}async function Xa(t,e){let n=Ir(t,e),r=await Je.readdir(n,{withFileTypes:!0});return Promise.all(r.map(async s=>{let i=await Je.stat(Me.join(n,s.name)).then(o=>o.mtimeMs).catch(()=>0);return{name:s.name,dir:s.isDirectory(),mtime:i}}))}async function Qa(t,e){let n=Ir(t,e);if(Me.normalize(n)===Me.normalize(e))throw new Error("Cannot remove the bulb's folder itself: remove its contents instead");await Je.rm(n,{recursive:!0})}var vf=k(()=>{"use strict"});async function Vw(t){let e=St(t.provider,t.model);if(typeof e=="string")throw new Error(e);let n=await Ht(e,t);if(!n.ok){let r=await xr(n,e.protocol);throw new Error(r.message)}return{response:n,protocol:e.protocol}}async function mR(t){let{response:e,protocol:n}=await Vw(t);return Er(e,n)}async function*gR(t){let{response:e,protocol:n}=await Vw(t);yield*_n(e,n)}function Gw(t){let e=Object.assign(mR,{stream:gR}),n={read:async r=>{let s=await di(r,t);try{return new TextDecoder("utf-8",{fatal:!0}).decode(s)}catch{throw new Error(`File is not valid UTF-8 text: ${r} \u2014 use tb.fs.readBytes() for binary files.`)}},readBytes:async r=>new Uint8Array(await di(r,t)),write:async(r,s)=>(await Ga(r,s,t),!0),list:async(r=".")=>Xa(r,t),remove:async r=>(await Qa(r,t),!0)};globalThis.tb=Object.freeze({log:(...r)=>{console.log(...r)},ai:e,fs:n,dir:t,models:()=>vt(),aiAccess:Aa,mode:ir.local})}var Xw=k(()=>{"use strict";Wt();re();$a();Cn();vf()});import*as Xt from"fs/promises";import*as he from"path";import{pathToFileURL as yR}from"url";async function Qw(t){let n=(await Xt.readdir(t)).find(r=>r.endsWith(".bulb.md"));return n?he.join(t,n):void 0}function $r(t){let e=he.resolve(t);return he.join(he.dirname(e),he.basename(e).replace(/\.bulb\.md$/,""))}function Nr(t){let[e,n,r,s]=t.split(he.sep).slice(-4);if(!(e!=="typebulbs"||n!=="u"||!r||!s?.endsWith(".bulb.md")))return{userSlug:r,slug:s.slice(0,-8)}}async function st(t){let e=await Xt.readFile(t,"utf-8"),n=Hn(e),r=gr(n);return{bulb:r,config:es(r.config),warnings:ah(e),starts:n.starts}}function Sf(t){let e=he.basename(t).replace(/\.bulb\.md$/i,"");return he.join(he.dirname(t),".typebulb",`${e}.server.mjs`)}async function fi(t,e,n,r){let s=sf(t,{serverOnly:!0});if(s.error)throw new Error(`Server compilation error: ${s.error}`);let i=s.code;n&&(i=await th(i,n));let o=he.join(he.dirname(e),".typebulb");await Xt.mkdir(o,{recursive:!0});let a=Va(i);a.length>0&&await Ya(a,o,r);let c=Sf(e);return await Xt.writeFile(c,i,"utf-8"),Gw($r(e)),await import(`${yR(c).href}?t=${Date.now()}`)}async function kf(t,e,n,r){let{bulb:s,config:i,starts:o}=await st(t),a=Ho(s.data),c,l=h=>{c??=h instanceof Error?h.message:String(h)};try{Sw(s.code,i.dependencies??{})}catch(h){l(h)}let f=sf(s.code,{jsxImportSource:i.ts?.jsxImportSource});f.error&&l(f.error);let u={imports:{}};if(!c)try{({importMap:u}=await qa.buildImportMap(f.code,i.dependencies??{},r?new Set([r.name]):void 0))}catch(h){l(`Dependency resolution failed: ${h instanceof Error?h.message:String(h)}`)}c&&console.error("Build error:",c),r&&(u.imports[r.name]=r.entryUrl);let d=Hw({name:s.name,code:c?"":f.code,css:s.css,html:s.html,data:a,insight:s.insight,importMap:u,dir:$r(t),watch:e,source:{file:he.basename(t),codeLine:o.get("code.tsx")??1},bulbKey:Js(t),compileError:c}),p;return s.server&&n&&(p=await fi(s.server,t,r,i.dependencies)),{html:d,bulb:s,serverExports:p,buildError:c}}var Nn,Tt=k(()=>{"use strict";zs();vw();kw();yf();zw();wf();Ji();Ue();Xw();Nn=t=>he.join($r(t),"assets")});import*as De from"fs/promises";import*as We from"path";import{createHash as bR}from"crypto";async function Ef(t,e,n){let r=[...t],s=async()=>{for(let i=r.shift();i!==void 0;i=r.shift())await n(i)};await Promise.all(Array.from({length:Math.min(e,t.length)},s))}function Lr(t){try{return JSON.parse(t).error||t}catch{return t}}async function Tf(t,e){try{let n=await fetch(pi(t),{headers:e.token?{Authorization:`Bearer ${e.token}`}:{},signal:e.timeoutMs?AbortSignal.timeout(e.timeoutMs):void 0});return n.ok?n.headers.get("content-type")?.includes("json")?{entries:await n.json()}:{error:"manifest response is not JSON \u2014 wrong origin?"}:{error:`manifest request failed (${n.status}): ${Lr(await n.text())}`}}catch(n){return{error:n instanceof Error?n.message:String(n)}}}function Cf(t,e){ve(e);let n=process.env.TYPEBULB_ORIGIN||wR;try{return tc(t,process.cwd(),n)}catch(r){console.error(r instanceof Error?r.message:String(r)),process.exit(1)}}function tc(t,e,n){if(/^https?:\/\//i.test(t)){let i=new URL(t),o=i.pathname.split("/").filter(Boolean).map(decodeURIComponent),a=o[0]==="api"&&o[1]==="scripts"?o.slice(2):o;if(a[0]!=="u"||!a[1]||!a[2])throw new Error(`Not a bulb URL: ${t}
1740
+ Expected <origin>/u/<user>/<slug>`);let c=a[1],l=a[2].replace(/(\.bulb)?\.md$/,"");return{origin:i.origin,userSlug:c,slug:l,dest:We.join(e,Za(c,l))}}let r=We.resolve(e,t),s=Nr(r);if(!s)throw new Error(`Not a conventional bulb path: ${t}
1741
+ A pull target must be a bulb URL, or a local file at typebulbs/u/<user>/<slug>.bulb.md \u2014 the path is its remote identity.`);return{origin:n,...s,dest:r}}async function vR(t,e){let n=await Tf(t,e);if("error"in n||!n.entries.length)return{kind:"none"};let r=n.entries,s=Nn(t.dest),i=[],o=[],a=0;for(let c of r){let l=await De.readFile(We.join(s,...c.path.split("/"))).catch(()=>{});l===void 0?i.push(c.path):Af(l)===c.md5?a++:e.force?i.push(c.path):o.push(c.path)}return o.length?{kind:"conflict",paths:o}:{kind:"plan",toGet:i,unchanged:a}}async function SR(t,e,n){let r=Nn(t.dest),s=[],i=0;return await Ef(e.toGet,4,async o=>{try{let a=await fetch(`${pi(t)}/${ec(o)}`,{headers:n.token?{Authorization:`Bearer ${n.token}`}:{},signal:AbortSignal.timeout(n.timeoutMs??3e4)});if(!a.ok){s.push(`${o}: HTTP ${a.status}`);return}let c=We.join(r,...o.split("/"));await De.mkdir(We.dirname(c),{recursive:!0}),await De.writeFile(c,new Uint8Array(await a.arrayBuffer())),i++}catch(a){s.push(`${o}: ${a instanceof Error?a.message:String(a)}`)}}),{downloaded:i,unchanged:e.unchanged,errors:s}}async function nc(t,e={}){let n=await fetch(xf(t),{headers:e.token?{Authorization:`Bearer ${e.token}`}:{},signal:e.timeoutMs?AbortSignal.timeout(e.timeoutMs):void 0});if(!n.ok)return{kind:"http-error",status:n.status};let r=n.headers.get("content-type");if(!r?.includes("text/markdown"))return{kind:"not-markdown",contentType:r??void 0};let s=await n.text(),i;try{i=await De.readFile(t.dest,"utf-8")}catch{}let o=i!==void 0&&kR(i,s);if(i!==void 0&&!o&&!e.force){let{mtime:l}=await De.stat(t.dest);return{kind:"conflict",dest:t.dest,localMtime:l,remoteLastModified:n.headers.get("last-modified")??void 0}}let a=await vR(t,e);if(a.kind==="conflict")return{kind:"asset-conflict",dest:t.dest,paths:a.paths};if(!o){await De.mkdir(We.dirname(t.dest),{recursive:!0}),await De.writeFile(t.dest,s);let l=new Date(n.headers.get("last-modified")??"");isNaN(l.getTime())||await De.utimes(t.dest,new Date,l)}let c=a.kind==="plan"?await SR(t,a,e):void 0;return o?{kind:"up-to-date",dest:t.dest,assets:c}:{kind:"written",dest:t.dest,created:i===void 0,assets:c}}function kR(t,e){let n=i=>i.replace(/\r\n/g,`
1742
+ `),r=Ge(n(t)),s=Ge(n(e));return!r||!s?n(t)===n(e):r.frontmatter.name===s.frontmatter.name&&Ve.every(i=>(r.files.get(pe[i].path)||"")===(s.files.get(pe[i].path)||""))}async function ev(t,e){t||(console.error("Usage: typebulb pull <bulb url | typebulbs/u/<user>/<slug>.bulb.md>"),process.exit(1));let n=Cf(t,e.mode),r=`${n.origin}/u/${n.userSlug}/${n.slug}`,s;try{s=await nc(n,{force:e.force,token:process.env.TYPEBULB_TOKEN})}catch(o){console.error(`Could not reach ${n.origin}: ${o instanceof Error?o.message:String(o)}`),process.exitCode=1;return}let i=We.relative(process.cwd(),n.dest)||n.dest;switch(s.kind){case"written":console.log(`pulled ${r} \u2192 ${i}${s.created?"":" (overwritten)"}`),Zw(s.assets);return;case"up-to-date":console.log(`up to date: ${i}`),Zw(s.assets);return;case"conflict":console.error(`Refusing to overwrite ${i} \u2014 it differs from ${r}
1743
1743
  local file modified ${s.localMtime.toISOString()}
1744
1744
  remote last saved ${s.remoteLastModified??"unknown"}
1745
1745
  Re-run with --force to overwrite the local file.`),process.exitCode=1;return;case"asset-conflict":console.error(`Refusing to overwrite local assets that differ from the hosted copies:
1746
1746
  `+s.paths.map(o=>` assets/${o}`).join(`
1747
1747
  `)+`
1748
- Re-run with --force to overwrite them.`),process.exitCode=1;return;case"http-error":s.status===404?console.error(`Bulb not found: ${r}`):s.status===401||s.status===403?console.error(`This bulb is private (${s.status}) \u2014 pulling it needs a TYPEBULB_TOKEN for its owner.`):console.error(`Pull failed: ${n.origin} responded ${s.status}`),process.exitCode=1;return;case"not-markdown":console.error(`${r}.md did not return bulb markdown (got ${s.contentType??"no content-type"}) \u2014 is ${n.origin} a typebulb host?`),process.exitCode=1}}function Jw(t){if(!(!t||!t.downloaded&&!t.errors.length)){console.log(`assets: ${t.downloaded} downloaded${t.unchanged?`, ${t.unchanged} unchanged`:""}`);for(let e of t.errors)console.error(` asset failed \u2014 ${e} (a re-pull retries just the missing ones)`);t.errors.length&&(process.exitCode=1)}}var H_,Ha,yf,za,li,wf,Ga=S(()=>{"use strict";et();te();At();H_="https://typebulb.com",Ha=(t,e)=>qe.join("typebulbs","u",t,`${e}.bulb.md`),yf=t=>`${t.origin}/u/${encodeURIComponent(t.userSlug)}/${encodeURIComponent(t.slug)}.md`,za=t=>t.split("/").map(encodeURIComponent).join("/"),li=t=>`${t.origin}/u/${encodeURIComponent(t.userSlug)}/${encodeURIComponent(t.slug)}/assets`;wf=t=>K_("md5").update(t).digest("hex")});import*as ut from"fs/promises";import*as ci from"path";async function Kw(t,e=""){let n=await ut.readdir(t,{withFileTypes:!0}).catch(()=>[]),r=[];for(let s of n)s.isDirectory()?r.push(...await Kw(ci.join(t,s.name),`${e}${s.name}/`)):s.isFile()&&r.push(e+s.name);return r}async function G_(t,e){let n=e.timeoutMs??3e4,r=li(t),s={Authorization:`Bearer ${e.token}`},i=In(t.dest);if(!await ut.stat(i).then(h=>h.isDirectory()).catch(()=>!1))return{kind:"skipped"};let o=await Kw(i),a=await vf(t,{token:e.token,timeoutMs:n});if("error"in a)return{kind:"sync-error",message:a.error};let l=a.entries;if(!o.length&&!l.length)return{kind:"skipped"};let c=new Map(l.map(h=>[h.path,h.md5])),f=new Set(o),d=l.map(h=>h.path).filter(h=>!f.has(h)),u=0,p=0;try{await bf(o,4,async h=>{let m=await ut.readFile(ci.join(i,...h.split("/")));if(c.get(h)===wf(m)){p++;return}let g=await fetch(`${r}/${za(h)}`,{method:"PUT",body:new Uint8Array(m),headers:s,signal:AbortSignal.timeout(n)});if(!g.ok)throw new Error(`upload of '${h}' refused (${g.status}): ${Ir(await g.text())}`);u++})}catch(h){return{kind:"sync-error",message:h instanceof Error?h.message:String(h)}}return{kind:"synced",uploaded:u,unchanged:p,toDelete:d,base:Fi(t.userSlug,t.slug)}}async function X_(t,e,n){let r=n.timeoutMs??3e4,s=li(t),i=[];for(let o of e)try{let a=await fetch(`${s}/${za(o)}`,{method:"DELETE",headers:{Authorization:`Bearer ${n.token}`},signal:AbortSignal.timeout(r)});if(!a.ok)return{deleted:i,error:`delete of '${o}' refused (${a.status}): ${Ir(await a.text())}`};i.push(o)}catch(a){return{deleted:i,error:a instanceof Error?a.message:String(a)}}return{deleted:i}}async function Xa(t,e){let n=await ut.readFile(t.dest,"utf-8"),{mtime:r}=await ut.stat(t.dest),s=await G_(t,{token:e.token,timeoutMs:e.timeoutMs});if(s.kind==="sync-error")return{kind:"asset-error",message:s.message};let i=s.kind==="synced"?{uploaded:s.uploaded,unchanged:s.unchanged,deleted:[],base:s.base}:void 0,o={Authorization:`Bearer ${e.token}`,"Content-Type":"text/markdown; charset=utf-8"};e.force||(o["If-Unmodified-Since"]=r.toUTCString());let a=await fetch(yf(t),{method:"PUT",body:n,headers:o,signal:e.timeoutMs?AbortSignal.timeout(e.timeoutMs):void 0}),l=await a.text();if(a.status===409)return{kind:"conflict",message:Ir(l),assets:i};if(!a.ok)return{kind:"http-error",status:a.status,message:Ir(l),assets:i};let c=JSON.parse(l);if(await ut.utimes(t.dest,new Date,new Date(c.updatedAt)),i&&s.kind==="synced"&&s.toDelete.length){let f=await X_(t,s.toDelete,{token:e.token,timeoutMs:e.timeoutMs});i.deleted=f.deleted,f.error&&(i.pruneError=f.error)}return{kind:"pushed",created:c.created,serverStripped:c.serverStripped,updatedAt:c.updatedAt,assets:i}}async function Hw(t,e){t||(console.error("Usage: typebulb push <typebulbs/u/<user>/<slug>.bulb.md>"),process.exit(1)),/^https?:\/\//i.test(t)&&(console.error("push takes a local .bulb.md file, not a URL (the path is its remote identity)"),process.exit(1));let n=Sf(t,e.mode),r=process.env.TYPEBULB_TOKEN;r||(console.error("push needs TYPEBULB_TOKEN in your .env \u2014 create one on your typebulb.com settings page."),process.exit(1));let s=`${n.origin}/u/${n.userSlug}/${n.slug}`,i=ci.relative(process.cwd(),n.dest)||n.dest,o;try{o=await Xa(n,{token:r,force:e.force})}catch(a){let l=a instanceof Error?a.message:String(a);console.error(a?.code==="ENOENT"?`File not found: ${i}`:`Could not push to ${n.origin}: ${l}`),process.exitCode=1;return}switch(o.kind!=="asset-error"&&o.assets&&console.log(`assets: ${o.assets.uploaded} uploaded, ${o.assets.unchanged} unchanged \u2192 ${o.assets.base}`),o.kind){case"asset-error":console.error(`assets sync failed: ${o.message}
1748
+ Re-run with --force to overwrite them.`),process.exitCode=1;return;case"http-error":s.status===404?console.error(`Bulb not found: ${r}`):s.status===401||s.status===403?console.error(`This bulb is private (${s.status}) \u2014 pulling it needs a TYPEBULB_TOKEN for its owner.`):console.error(`Pull failed: ${n.origin} responded ${s.status}`),process.exitCode=1;return;case"not-markdown":console.error(`${r}.md did not return bulb markdown (got ${s.contentType??"no content-type"}) \u2014 is ${n.origin} a typebulb host?`),process.exitCode=1}}function Zw(t){if(!(!t||!t.downloaded&&!t.errors.length)){console.log(`assets: ${t.downloaded} downloaded${t.unchanged?`, ${t.unchanged} unchanged`:""}`);for(let e of t.errors)console.error(` asset failed \u2014 ${e} (a re-pull retries just the missing ones)`);t.errors.length&&(process.exitCode=1)}}var wR,Za,xf,ec,pi,Af,rc=k(()=>{"use strict";tt();re();Tt();wR="https://typebulb.com",Za=(t,e)=>We.join("typebulbs","u",t,`${e}.bulb.md`),xf=t=>`${t.origin}/u/${encodeURIComponent(t.userSlug)}/${encodeURIComponent(t.slug)}.md`,ec=t=>t.split("/").map(encodeURIComponent).join("/"),pi=t=>`${t.origin}/u/${encodeURIComponent(t.userSlug)}/${encodeURIComponent(t.slug)}/assets`;Af=t=>bR("md5").update(t).digest("hex")});import*as dt from"fs/promises";import*as hi from"path";async function tv(t,e=""){let n=await dt.readdir(t,{withFileTypes:!0}).catch(()=>[]),r=[];for(let s of n)s.isDirectory()?r.push(...await tv(hi.join(t,s.name),`${e}${s.name}/`)):s.isFile()&&r.push(e+s.name);return r}async function xR(t,e){let n=e.timeoutMs??3e4,r=pi(t),s={Authorization:`Bearer ${e.token}`},i=Nn(t.dest);if(!await dt.stat(i).then(h=>h.isDirectory()).catch(()=>!1))return{kind:"skipped"};let o=await tv(i),a=await Tf(t,{token:e.token,timeoutMs:n});if("error"in a)return{kind:"sync-error",message:a.error};let c=a.entries;if(!o.length&&!c.length)return{kind:"skipped"};let l=new Map(c.map(h=>[h.path,h.md5])),f=new Set(o),u=c.map(h=>h.path).filter(h=>!f.has(h)),d=0,p=0;try{await Ef(o,4,async h=>{let m=await dt.readFile(hi.join(i,...h.split("/")));if(l.get(h)===Af(m)){p++;return}let g=await fetch(`${r}/${ec(h)}`,{method:"PUT",body:new Uint8Array(m),headers:s,signal:AbortSignal.timeout(n)});if(!g.ok)throw new Error(`upload of '${h}' refused (${g.status}): ${Lr(await g.text())}`);d++})}catch(h){return{kind:"sync-error",message:h instanceof Error?h.message:String(h)}}return{kind:"synced",uploaded:d,unchanged:p,toDelete:u,base:zi(t.userSlug,t.slug)}}async function ER(t,e,n){let r=n.timeoutMs??3e4,s=pi(t),i=[];for(let o of e)try{let a=await fetch(`${s}/${ec(o)}`,{method:"DELETE",headers:{Authorization:`Bearer ${n.token}`},signal:AbortSignal.timeout(r)});if(!a.ok)return{deleted:i,error:`delete of '${o}' refused (${a.status}): ${Lr(await a.text())}`};i.push(o)}catch(a){return{deleted:i,error:a instanceof Error?a.message:String(a)}}return{deleted:i}}async function sc(t,e){let n=await dt.readFile(t.dest,"utf-8"),{mtime:r}=await dt.stat(t.dest),s=await xR(t,{token:e.token,timeoutMs:e.timeoutMs});if(s.kind==="sync-error")return{kind:"asset-error",message:s.message};let i=s.kind==="synced"?{uploaded:s.uploaded,unchanged:s.unchanged,deleted:[],base:s.base}:void 0,o={Authorization:`Bearer ${e.token}`,"Content-Type":"text/markdown; charset=utf-8"};e.force||(o["If-Unmodified-Since"]=r.toUTCString());let a=await fetch(xf(t),{method:"PUT",body:n,headers:o,signal:e.timeoutMs?AbortSignal.timeout(e.timeoutMs):void 0}),c=await a.text();if(a.status===409)return{kind:"conflict",message:Lr(c),assets:i};if(!a.ok)return{kind:"http-error",status:a.status,message:Lr(c),assets:i};let l=JSON.parse(c);if(await dt.utimes(t.dest,new Date,new Date(l.updatedAt)),i&&s.kind==="synced"&&s.toDelete.length){let f=await ER(t,s.toDelete,{token:e.token,timeoutMs:e.timeoutMs});i.deleted=f.deleted,f.error&&(i.pruneError=f.error)}return{kind:"pushed",created:l.created,serverStripped:l.serverStripped,updatedAt:l.updatedAt,assets:i}}async function nv(t,e){t||(console.error("Usage: typebulb push <typebulbs/u/<user>/<slug>.bulb.md>"),process.exit(1)),/^https?:\/\//i.test(t)&&(console.error("push takes a local .bulb.md file, not a URL (the path is its remote identity)"),process.exit(1));let n=Cf(t,e.mode),r=process.env.TYPEBULB_TOKEN;r||(console.error("push needs TYPEBULB_TOKEN in your .env \u2014 create one on your typebulb.com settings page."),process.exit(1));let s=`${n.origin}/u/${n.userSlug}/${n.slug}`,i=hi.relative(process.cwd(),n.dest)||n.dest,o;try{o=await sc(n,{token:r,force:e.force})}catch(a){let c=a instanceof Error?a.message:String(a);console.error(a?.code==="ENOENT"?`File not found: ${i}`:`Could not push to ${n.origin}: ${c}`),process.exitCode=1;return}switch(o.kind!=="asset-error"&&o.assets&&console.log(`assets: ${o.assets.uploaded} uploaded, ${o.assets.unchanged} unchanged \u2192 ${o.assets.base}`),o.kind){case"asset-error":console.error(`assets sync failed: ${o.message}
1749
1749
  push refused: the bulb text was not pushed.`),process.exitCode=1;return;case"pushed":{console.log(`pushed ${i} \u2192 ${s}/full`),o.created&&(console.log(" created a new bulb, unlisted \u2014 nothing existed at this URL before"),console.log(" if you renamed this file, its previous bulb is still live at the old URL")),o.serverStripped&&console.log("note: the server.ts block was stripped on the server copy (CLI-only); your local file is untouched.");for(let a of o.assets?.deleted??[])console.log(` deleted ${a} (no longer in assets/)`);o.assets?.pruneError&&console.log(`note: asset cleanup incomplete \u2014 ${o.assets.pruneError}; the next push will retry.`);return}case"conflict":console.error(`${o.message}
1750
1750
  pull to see the remote: typebulb pull ${i}
1751
- or overwrite it: typebulb push ${i} --force`),process.exitCode=1;return;case"http-error":o.status===401?console.error("The server rejected TYPEBULB_TOKEN (401) \u2014 it may be revoked; mint a new one on the settings page."):console.error(`Push failed: ${n.origin} responded ${o.status}${o.message?` \u2014 ${o.message}`:""}`),process.exitCode=1}}var kf=S(()=>{"use strict";te();Ga();At()});var $n=S(()=>{"use strict";Ie();jb();bn();Fb();Td();Kb();zb();Ks();An();An();Ta();Xd();Ie();Ga();kf();et();je()});import{existsSync as Q_,mkdirSync as Z_,readFileSync as eR,rmSync as tR,writeFileSync as nR}from"fs";import{homedir as rR}from"os";import*as $r from"path";function aR(){return oR.replace('"__TB_SKILL_PATH__"',JSON.stringify(Vs())).replace('"__TB_BIN_PATH__"',JSON.stringify(fr()))}function zw(){try{if(!Q_(xf()))return}catch{return}try{let t=sR(),e=aR(),n;try{n=eR(t,"utf8")}catch{}n!==e&&(Z_($r.dirname(t),{recursive:!0}),nR(t,e))}catch{}for(let t of iR())try{tR(t,{force:!0})}catch{}}var xf,sR,iR,oR,Yw=S(()=>{"use strict";$n();xf=()=>$r.join(rR(),".pi","agent"),sR=()=>$r.join(xf(),"extensions","typebulb.ts"),iR=()=>["typebulb-wait.ts","matchu-patchu.ts"].map(t=>$r.join(xf(),"extensions",t)),oR=String.raw`// Generated by typebulb — do not edit; overwritten on each run.
1751
+ or overwrite it: typebulb push ${i} --force`),process.exitCode=1;return;case"http-error":o.status===401?console.error("The server rejected TYPEBULB_TOKEN (401) \u2014 it may be revoked; mint a new one on the settings page."):console.error(`Push failed: ${n.origin} responded ${o.status}${o.message?` \u2014 ${o.message}`:""}`),process.exitCode=1}}var Of=k(()=>{"use strict";re();rc();Tt()});var Qt=k(()=>{"use strict";$e();Vb();vn();Gb();Id();tw();rw();Gs();Cn();Cn();$a();rf();$e();rc();Of();tt();Ue()});import{existsSync as AR,mkdirSync as TR,readFileSync as CR,rmSync as OR,writeFileSync as PR}from"fs";import{homedir as _R}from"os";import*as Mr from"path";function NR(){return $R.replace('"__TB_SKILL_PATH__"',JSON.stringify(ei())).replace('"__TB_BIN_PATH__"',JSON.stringify(mr()))}function rv(){try{if(!AR(Pf()))return}catch{return}try{let t=RR(),e=NR(),n;try{n=CR(t,"utf8")}catch{}n!==e&&(TR(Mr.dirname(t),{recursive:!0}),PR(t,e))}catch{}for(let t of IR())try{OR(t,{force:!0})}catch{}}var Pf,RR,IR,$R,sv=k(()=>{"use strict";Qt();Pf=()=>Mr.join(_R(),".pi","agent"),RR=()=>Mr.join(Pf(),"extensions","typebulb.ts"),IR=()=>["typebulb-wait.ts","matchu-patchu.ts"].map(t=>Mr.join(Pf(),"extensions",t)),$R=String.raw`// Generated by typebulb — do not edit; overwritten on each run.
1752
1752
  import { spawn } from "node:child_process";
1753
1753
  import { existsSync } from "node:fs";
1754
1754
 
@@ -2016,23 +2016,23 @@ export default function (pi) {
2016
2016
  try { pi.on("session_shutdown", () => { stopping = true; if (watcher) { try { watcher.kill(); } catch (e) {} watcher = null; } for (const c of pending) { try { c.kill(); } catch (e) {} } pending.clear(); }); } catch (e) {}
2017
2017
  } catch (e) { logErr("load", e && e.message); }
2018
2018
  }
2019
- `});function V(t){return t?.message??String(t)}var X,Zt=S(()=>{"use strict";X=process.cwd()});import{spawn as Vw}from"child_process";import{StringDecoder as lR}from"string_decoder";function hR(t,e){let n=new lR("utf8"),r="";t.on("data",s=>{r+=typeof s=="string"?s:n.write(s);let i;for(;(i=r.indexOf(`
2020
- `))>=0;){let o=r.slice(0,i);r=r.slice(i+1),o.endsWith("\r")&&(o=o.slice(0,-1)),o&&e(o)}})}var cR,Gw,Xw,Ef,Qw,uR,dR,fR,Zw,pR,Qa,Za,ev,tv=S(()=>{"use strict";Zt();cR=3e4,Gw=18e4,Xw="starting pi\u2026",Ef=5e3,Qw=2e3,uR=2e3,dR=12e4,fR=8e3,Zw=15e3,pR=new Set(["get_state","get_commands","get_available_models","set_model","set_thinking_level","cycle_thinking_level","get_session_stats","compact","set_auto_compaction","get_fork_messages","fork","clone","set_session_name","export_html","bash","abort_bash"]),Qa=new Set;process.on("exit",()=>{for(let t of Qa)try{t.kill()}catch{}});Za=class{#t;#o=!1;#e=0;#s=!1;#u=0;#n=!1;#c=null;#a=[];#d=null;#r=null;#i=null;#f=new Map;#l=[];#b=null;#k=null;#w=null;#m;#g;#v="";#_=1;#p=new Map;#x;#S;constructor(e,n,r=(s,i)=>Vw(s,{cwd:i,shell:!0,stdio:["pipe","pipe","pipe"],env:{...process.env,TYPEBULB_MIRROR:"1"}})){if(this.#x=new Promise(o=>{this.#S=o}),n?.includes('"')){this.#g="session path contains a quote \u2014 cannot drive it",this.#S();return}let s=n?`pi --mode rpc --session "${n}"`:"pi --mode rpc",i;try{i=r(s,e)}catch(o){this.#g=`could not start pi: ${V(o)}`,this.#S();return}this.#t=i,this.#m=n,this.#s=!0,this.#u=Date.now()+Gw,this.#r={text:Xw,kind:"info"},Qa.add(i),i.stdout&&hR(i.stdout,o=>this.#I(o)),i.stderr&&i.stderr.on("data",o=>{this.#v=(this.#v+o.toString()).slice(-uR)}),i.on("error",o=>this.#O(`could not start pi: ${o.message}`)),i.on("exit",o=>{this.#t===i&&this.#O(o?`pi exited (code ${o})${this.#v.trim()?`: ${this.#v.trim()}`:""}`:"pi exited"),Qa.delete(i),this.#S()}),this.#h({type:"get_state"}).then(o=>{let a=o.data?.sessionFile;typeof a=="string"&&a&&(this.#m=a);let l=o.data?.model;l&&typeof l.id=="string"&&l.id&&(this.#w=l.id)}).catch(()=>{}).finally(()=>this.#R())}#R(){this.#s&&(this.#s=!1,this.#r?.text===Xw&&(this.#r=null),this.#i&&(this.#i.until=Date.now()+Zw),!this.#o&&Date.now()<this.#e&&(this.#e=Date.now()+Ef),this.#T())}get streaming(){return this.#o||Date.now()<this.#e}get draft(){return this.#c}get echo(){return this.#d}get queue(){return this.#b}get stats(){return this.#k}get model(){return this.#w}get sessionFile(){return this.#m}get error(){return this.#g}get status(){if(this.#r)return this.#r;if(this.#i){if(Date.now()<this.#i.until)return{text:this.#i.text,kind:this.#i.kind};this.#i=null}return this.#f.size?{text:[...this.#f.values()].join(" \xB7 "),kind:"info"}:null}get dialog(){let e=Date.now();for(;this.#l.length;){let n=this.#l[0];if(e<n.until)return n.req;this.#l.shift(),n.ownTimeout||this.#E({type:"extension_ui_response",id:n.req.id,cancelled:!0})}return null}notice(e,n){this.#y(e,n)}respondUi(e,n){let r=this.#l.findIndex(o=>o.req.id===e);if(r<0)return{ok:!1,error:"dialog expired or already answered"};let[s]=this.#l.splice(r,1),i={type:"extension_ui_response",id:e};return n.cancelled?i.cancelled=!0:s.req.method==="confirm"?i.confirmed=!!n.confirmed:i.value=n.value??"",this.#E(i),{ok:!0}}async rpc(e){if(!pR.has(e.type))return{ok:!1,error:`command not allowed: ${e.type}`};try{let n=await this.#h(e);if(n.success&&e.type==="set_model"){let r=n.data?.id;typeof r=="string"&&r&&(this.#w=r)}if(n.success&&(e.type==="fork"||e.type==="clone")){try{let s=(await this.#h({type:"get_state"})).data?.sessionFile;typeof s=="string"&&s&&(this.#m=s)}catch{}return{ok:!0,data:{...n.data??{},sessionFile:this.#m}}}return n.success?{ok:!0,data:n.data}:{ok:!1,error:n.error??`pi rejected ${e.type}`}}catch(n){return{ok:!1,error:V(n)}}}async send(e,n){let r=this.streaming,s=e.trimStart().startsWith("/"),i=r?s?{type:"prompt",message:e,streamingBehavior:n?.followUp?"followUp":"steer"}:{type:n?.followUp?"follow_up":"steer",message:e}:{type:"prompt",message:e},o=l=>{r||(this.#e=l,s||(this.#d=e))};if(this.#s)return this.#h(i).catch(()=>{}),o(this.#u+Ef),{ok:!0};let a;try{a=await this.#h(i)}catch(l){return{ok:!1,error:V(l)}}return a.success&&o(Date.now()+Ef),a.success?{ok:!0}:{ok:!1,error:a.error??"pi rejected the message"}}async stop(){if(this.#t){if(this.#s){this.#E({type:"abort"}),this.#e=0;return}try{await this.#h({type:"abort"})}catch{}}}clearCompletedDraft(){this.#n||(this.#c=null)}clearEcho(){this.#d=null}async dispose(){let e=this.#t;if(e){if(this.#t=void 0,this.#s=!1,this.#o){try{e.stdin?.write(JSON.stringify({type:"abort"})+`
2021
- `)}catch{}await Promise.race([this.#x,ev(Qw)])}try{e.stdin?.end()}catch{}if(await Promise.race([this.#x,ev(Qw)]),e.exitCode===null&&!e.killed)if(process.platform==="win32"&&e.pid)try{Vw("taskkill",["/pid",String(e.pid),"/T","/F"],{stdio:"ignore"})}catch{}else try{e.kill("SIGKILL")}catch{}Qa.delete(e),this.#l=[],this.#P("pi was shut down")}}#E(e){try{this.#t?.stdin?.write(JSON.stringify(e)+`
2022
- `)}catch{}}#C(){let e=this.#a[this.#a.length-1];this.#c={text:this.#a.filter(n=>n?.kind==="text").map(n=>n.text).join(""),thinking:this.#a.filter(n=>n?.kind==="thinking").map(n=>n.text).join(`
2023
- `),tool:e?.kind==="tool"?e.name:void 0}}#A(e){let n=Array.isArray(e?.content)?e.content:[];this.#a=n.map(r=>({kind:r.type==="thinking"?"thinking":r.type==="toolCall"?"tool":"text",text:(r.type==="thinking"?r.thinking:r.text)??"",name:r.name})),this.#C()}#y(e,n){let r=e.length>200?e.slice(0,200)+"\u2026":e;r&&(this.#i={text:r,kind:n,until:Date.now()+(n==="info"?fR:Zw)})}#T(){this.#h({type:"get_session_stats"}).then(e=>{if(!e.success||!e.data)return;let n=e.data;this.#k={cost:typeof n.cost=="number"?n.cost:0,contextTokens:typeof n.contextUsage?.tokens=="number"?n.contextUsage.tokens:null,contextPercent:typeof n.contextUsage?.percent=="number"?n.contextUsage.percent:null}}).catch(()=>{})}#h(e){let n=this.#t;if(!n?.stdin?.writable)return Promise.reject(new Error(this.#g??"pi is not running"));let r=this.#s?Gw:cR,s=`tb-${this.#_++}`;return new Promise((i,o)=>{let a=setTimeout(()=>{this.#p.delete(s),o(new Error(`pi did not respond (${Math.round(r/1e3)}s)`))},r);a.unref?.(),this.#p.set(s,{resolve:i,timer:a});try{n.stdin.write(JSON.stringify({id:s,...e})+`
2024
- `)}catch(l){clearTimeout(a),this.#p.delete(s),o(new Error(V(l)))}})}#I(e){let n;try{n=JSON.parse(e)}catch{return}switch(n.type){case"response":{let r=n,s=r.id?this.#p.get(r.id):void 0;s&&(this.#p.delete(r.id),clearTimeout(s.timer),s.resolve(r));return}case"agent_start":this.#o=!0,this.#e=0;return;case"agent_end":this.#o=!1,this.#e=0,this.#n=!1,this.#r=null,this.#b=null,this.#T();return;case"message_start":{let r=n.message;if(r?.role!=="assistant")return;this.#n=!0,this.#A(r);return}case"message_update":{if(!this.#n)return;if(n.message){this.#A(n.message);return}let r=n.assistantMessageEvent;if(!r||typeof r.contentIndex!="number")return;let s=r.type.startsWith("thinking")?"thinking":r.type.startsWith("toolcall")?"tool":"text",i=this.#a[r.contentIndex]??={kind:s,text:""};i.kind=s,typeof r.delta=="string"&&s!=="tool"&&(i.text+=r.delta),typeof r.content=="string"&&(i.text=r.content),r.toolCall?.name&&(i.name=r.toolCall.name),this.#C();return}case"message_end":if(!this.#n)return;n.message&&this.#A(n.message),this.#n=!1;return;case"auto_retry_start":this.#r={text:`retrying after a transient error (attempt ${Number(n.attempt)||1}/${Number(n.maxAttempts)||"?"})\u2026`,kind:"warning"};return;case"auto_retry_end":this.#r=null,n.success===!1&&this.#y(`retries exhausted: ${String(n.finalError??"unknown error")}`,"error");return;case"compaction_start":this.#r={text:"compacting context\u2026",kind:"info"};return;case"compaction_end":{this.#r=null;let r=n.result;typeof n.errorMessage=="string"&&n.errorMessage?this.#y(`compaction failed: ${n.errorMessage}`,"error"):r?.tokensBefore&&this.#y(`compacted: ~${Math.round(r.tokensBefore/1e3)}k \u2192 ~${Math.round((r.estimatedTokensAfter??0)/1e3)}k tokens`,"info"),this.#T();return}case"queue_update":{let r=Array.isArray(n.steering)?n.steering.map(String):[],s=Array.isArray(n.followUp)?n.followUp.map(String):[];this.#b=r.length||s.length?{steering:r,followUp:s}:null;return}case"extension_ui_request":{let r=String(n.method??"");if(r==="select"||r==="confirm"||r==="input"||r==="editor"){let s=typeof n.timeout=="number"&&n.timeout>0?n.timeout:void 0;this.#l.push({req:{id:String(n.id??""),method:r,title:typeof n.title=="string"?n.title:void 0,message:typeof n.message=="string"?n.message:void 0,options:Array.isArray(n.options)?n.options.map(String):void 0,placeholder:typeof n.placeholder=="string"?n.placeholder:void 0,prefill:typeof n.prefill=="string"?n.prefill:void 0},until:Date.now()+(s??dR),ownTimeout:s!==void 0})}else if(r==="notify"){let s=n.notifyType==="warning"?"warning":n.notifyType==="error"?"error":"info";this.#y(String(n.message??""),s),console.log(`[composer] pi extension: ${String(n.message??"")}`)}else if(r==="setStatus"){let s=String(n.statusKey??"");typeof n.statusText=="string"&&n.statusText?this.#f.set(s,n.statusText):this.#f.delete(s)}return}default:return}}#O(e){this.#g=e,this.#s=!1,this.#o=!1,this.#e=0,this.#n=!1,this.#c=null,this.#a=[],this.#d=null,this.#r=null,this.#i=null,this.#f.clear(),this.#l=[],this.#b=null,this.#k=null,this.#w=null,this.#t=void 0,this.#P(e)}#P(e){for(let[,n]of this.#p)clearTimeout(n.timer),n.resolve({type:"response",success:!1,error:e});this.#p.clear()}},ev=t=>new Promise(e=>{setTimeout(e,t).unref?.()})});import{existsSync as nv,readFileSync as mR,realpathSync as gR}from"fs";import{join as Nn,dirname as ov,resolve as yR}from"path";import{homedir as rv}from"os";function wR(t,e){let n=Nn(t,".pi");if(bR.some(s=>nv(Nn(n,s))))return!0;let r=Nn(e,".agents","skills");for(let s=t;;){let i=Nn(s,".agents","skills");if(i!==r&&nv(i))return!0;let o=ov(s);if(o===s)return!1;s=o}}function vR(t,e){for(let n=e;;){if(t[n]===!0||t[n]===!1)return!0;let r=ov(n);if(r===n)return!1;n=r}}function av(t,e){try{let n=e?.agentDir??Nn(rv(),".pi","agent"),r=sv(e?.home??process.env.HOME??rv()),s=sv(yR(t));if(!wR(s,r))return null;let i=iv(Nn(n,"settings.json")).defaultProjectTrust;return i==="always"||i==="never"||vR(iv(Nn(n,"trust.json")),s)?null:"pi has no trust decision for this project \u2014 running untrusted; run `pi` once in a terminal to grant it"}catch{return null}}var bR,sv,iv,lv=S(()=>{"use strict";bR=["settings.json","extensions","skills","prompts","themes","SYSTEM.md","APPEND_SYSTEM.md"],sv=t=>{try{return gR(t)}catch{return t}},iv=t=>{try{return JSON.parse(mR(t,"utf8"))}catch{return{}}}});import{statSync as SR,openSync as kR,readSync as xR,closeSync as ER,existsSync as uv}from"fs";import{join as el}from"path";import{homedir as Af}from"os";import{execFile as AR}from"child_process";async function CR(t){let e=el(Af(),".pi","agent","bin",process.platform==="win32"?"fd.exe":"fd");for(let n of["fd","fdfind",...uv(e)?[e]:[]]){let r=await new Promise(s=>{AR(n,["--base-directory",t,"--type","f","--follow","--hidden","--exclude",".git"],{maxBuffer:67108864},(i,o)=>s(i?null:o))});if(r!==null)return r.split(`
2025
- `).filter(Boolean).map(s=>s.replace(/\\/g,"/"))}return null}function OR(t){return`--${t.replace(/^[/\\]/,"").replace(/[/\\:]/g,"-")}--`}function cv(t){return t.type==="message"?PR(t.message?.role):t.type==="custom_message"?t.display!==!1:!1}var TR,PR,Nr,Tf=S(()=>{"use strict";Rs();Ko();Ho();Yw();tv();lv();TR=el(Af(),".pi","agent","sessions");PR=t=>t==="user"||t==="assistant"||t==="toolResult"||t==="bashExecution";Nr=class extends qt{displayName="Pi Mirror";detectsSelf(){return process.env.PI_CODING_AGENT==="true"}detectsInstalled(){return uv(el(Af(),".pi","agent"))}ensureHarnessSupport(){zw()}createDriver(e,n){let r=new Za(e,n),s=av(e);return s&&r.notice(s,"warning"),r}walkFiles(e){return CR(e)}sessionsDir(e){return el(TR,OR(e))}listSessionFiles(e){return Wo(this.sessionsDir(e))}parseEntry(e){let n;try{n=JSON.parse(e)}catch{return null}return!n||n.type==="session"||!n.id?null:n}idOf(e){return e.id}parentOf(e){return e.parentId??void 0}timestampOf(e){return e.timestamp}isSidechain(e){return!1}isLeafType(e){return cv(e)}isRecoveryNoise(e){return!1}apply(e,n){let r=[];if(e.type==="custom_message"){if(e.display===!1)return{events:r};let i=this.contentText(e.content).trim();return i&&r.push({type:"user",text:i}),{events:r}}if(e.type!=="message"||!e.message)return{events:r};let s=e.message;if(s.role==="user"){let i=this.contentText(s.content).trim();return i&&r.push({type:"user",text:i}),{events:r}}if(s.role==="toolResult"){let i=this.contentText(s.content);return r.push({type:"tool_result",id:s.toolCallId??"",content:i,isError:!!s.isError,digest:Be(i)}),{events:r}}if(s.role==="bashExecution")return s.command&&!s.excludeFromContext&&r.push({type:"user",text:`$ ${s.command}`}),{events:r};if(s.role==="assistant"){let i=Array.isArray(s.content)?s.content:[],o=i.filter(u=>u.type==="text").map(u=>u.text??"").join(""),a=i.filter(u=>u.type==="thinking").map(u=>u.thinking??"").join(`
2026
- `),l=i.filter(u=>u.type==="toolCall").map(u=>({id:u.id??"",name:u.name??"",input:u.arguments??{}}));if(o||a||l.length){let u=Date.parse(e.timestamp??""),p=!isNaN(u)&&u>=n;r.push({type:"assistant",text:o,thinking:a,tools:l,live:p})}let c=s.usage,f=c?(c.input??0)+(c.output??0)+(c.cacheRead??0)+(c.cacheWrite??0):0,d=c&&f>0&&s.stopReason!=="aborted"&&s.stopReason!=="error"?{in:c.input??0,out:c.output??0,cached:c.cacheRead??0,cacheCreate:c.cacheWrite??0}:void 0;return{events:r,usage:d,model:s.model,cost:c?.cost?.total}}return{events:r}}chainWorking(e){let n;for(let a of e)cv(a)&&(n=a);if(!n||n.type==="custom_message")return!1;let r=n.message.role;if(r==="user"||r==="toolResult"||r==="bashExecution")return!0;if(r!=="assistant")return!1;let i=(Array.isArray(n.message.content)?n.message.content:[]).filter(a=>a.type==="toolCall").map(a=>a.id);if(!i.length)return!1;let o=new Set;for(let a of e)a.type==="message"&&a.message?.role==="toolResult"&&a.message.toolCallId&&o.add(a.message.toolCallId);return i.some(a=>a&&!o.has(a))}sessionAlive(){}readPreview(e){let n;try{n=kR(e,"r")}catch{return""}try{let s=65536;try{s=SR(e).size}catch{}let i=(d,u)=>{let p=Buffer.alloc(u),h=xR(n,p,0,u,d);return p.subarray(0,h).toString("utf8")},o=i(0,Math.min(65536,s)),a=s>65536?i(s-65536,65536):"",l=d=>{let u="";for(let p of d.split(`
2027
- `))if(p.includes('"session_info"'))try{let h=JSON.parse(p);h?.type==="session_info"&&typeof h.name=="string"&&h.name&&(u=h.name)}catch{}return u},c="";for(let d of o.split(`
2028
- `))if(!(c||!d.includes('"type"')))try{let u=JSON.parse(d);u?.type==="message"&&u.message?.role==="user"&&(c=this.contentText(u.message.content).replace(/\s+/g," ").trim())}catch{}let f=l(a)||l(o)||c;return f?f.slice(0,200):""}finally{ER(n)}}searchText(e){if(e?.type!=="message")return"";let n=e.message?.role;if(n!=="user"&&n!=="assistant")return"";let r=e.message?.content,s="";return typeof r=="string"?s=r:Array.isArray(r)&&(s=r.filter(i=>i.type==="text"&&typeof i.text=="string").map(i=>i.text).join(" ")),s.replace(/\s+/g," ").trim()}contentText(e){return typeof e=="string"?_e(e):Array.isArray(e)?e.map(n=>typeof n?.text=="string"?_e(n.text):n?.type==="image"&&n.data?qo(n.data,n.mimeType):"").filter(Boolean).join(`
2029
- `):""}}});var tl,dv=S(()=>{"use strict";tl=class{#t=new Map;accept(e,n){return this.#t.get(e)===n?!1:(this.#t.set(e,n),!0)}}});import{execFile as _R}from"child_process";import{promisify as RR}from"util";import{readFile as IR}from"fs/promises";import{resolve as fv,sep as $R}from"path";async function we(t,e){let{stdout:n}=await NR("git",t,{cwd:e,maxBuffer:67108864});return n}async function Ln(){if(nl)return nl;try{nl=(await we(["rev-parse","--show-toplevel"],X)).trim()}catch{}return nl}function LR(t,e){let n=e===" "?t:e;return n==="?"?"U":n}async function Of(){let t=await Ln();if(!t)return{repo:!1,root:"",files:[]};try{let e=await we(["status","--porcelain","-z"],t),n=[],r=e.split("\0");for(let s=0;s<r.length;s++){let i=r[s];i.length<4||((i[0]==="R"||i[0]==="C")&&s++,n.push({path:i.slice(3),status:LR(i[0],i[1])}))}try{let s=await we(["diff","--numstat","-z","HEAD"],t),i=new Map,o=s.split("\0");for(let a=0;a<o.length;a++){let l=/^(\d+|-)\t(\d+|-)\t(.*)$/.exec(o[a]);if(!l)continue;let c=l[3]||o[a+=2];c&&i.set(c,{add:+l[1]||0,del:+l[2]||0,binary:l[1]==="-"})}for(let a of n){let l=i.get(a.path);l&&(l.binary?a.binary=!0:(a.add=l.add,a.del=l.del))}}catch{}return n.sort((s,i)=>s.path.localeCompare(i.path)),{repo:!0,root:t,files:n}}catch(e){return{repo:!1,root:"",files:[],error:V(e)}}}async function Pf(t){let e=await Ln();if(!e)return{ok:!1,error:"not a git repository"};try{if((await we(["status","--porcelain","-z","--",t],e)).startsWith("??")){let s=fv(e,t);if(!s.startsWith(fv(e)+$R))return{ok:!1,error:"outside repository"};let i=await IR(s);return i.includes(0)?Cf("Binary file (not shown)",!1):Cf(i.toString("utf8"),!0)}let r;try{r=await we(["diff","--no-color","--unified=999999","HEAD","--",t],e)}catch{r=await we(["diff","--no-color","--unified=999999","--",t],e)}return Cf(r,!1)}catch(n){return{ok:!1,error:V(n)}}}var NR,pv,nl,Cf,Lr=S(()=>{"use strict";Zt();NR=RR(_R),pv=2e6;Cf=(t,e)=>({ok:!0,text:t.slice(0,pv),untracked:e,truncated:t.length>pv})});function ui(t,e){let n=0,r="";for(let s of t){let i=s.lower.indexOf(e);if(!(i<0)&&(n++,!r)){let o=Math.max(0,i-110),a=Math.min(s.text.length,i+e.length+110);r=(o>0?"\u2026":"")+s.text.slice(o,a)+(a<s.text.length?"\u2026":"")}}return{hitCount:n,snippet:r}}var _f=S(()=>{"use strict"});function hv(){return MR.map(([t,e])=>vt(t,e)).filter(t=>typeof t!="string")}function mv(){return hv().length>0}async function rl(t,e,n=0){let r=AbortSignal.timeout(e);for(let s of hv()){try{let i=await zt(s,{messages:[{role:"user",content:t}],effort:n,webSearch:!1,signal:r});if(i.ok){let o=(await Kd(i,s.protocol)).trim();if(o)return o}}catch{}if(r.aborted)return}}var MR,Rf=S(()=>{"use strict";Kt();$n();MR=[["openrouter","anthropic/claude-haiku-5.5"],["anthropic","claude-haiku-5-5"],["openai","gpt-6-luna"]]});var sl,il,Tt,ol,Mr=S(()=>{"use strict";sl=".typebulb/paste",il={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",bmp:"image/bmp"},Tt=t=>t.label||t.kind||"agent",ol=t=>t.failing&&t.state!=="stopped"?"failing":t.state});import{existsSync as DR,mkdirSync as BR,writeFileSync as jR,readFileSync as FR}from"fs";import{join as al}from"path";function gv(){let t=new Date,e=n=>String(n).padStart(2,"0");return`${t.getFullYear()}${e(t.getMonth()+1)}${e(t.getDate())}-${e(t.getHours())}${e(t.getMinutes())}${e(t.getSeconds())}`}function JR(t){return t.trim().toLowerCase().replace(/\.[a-z0-9]{1,4}$/,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)}async function WR(t){let e=await rl(`Reply with ONLY a short kebab-case filename (2-5 words, lowercase, no extension) describing this text:
2030
-
2031
- ${t.slice(0,qR)}`,UR);return e&&JR(e)||void 0}async function yv(t,e){if(!e||e.kind!=="image"&&e.kind!=="text")return{ok:!1,error:"bad paste kind"};if(typeof e.data!="string"||!e.data)return{ok:!1,error:"empty paste"};let n=al(t,sl);try{BR(n,{recursive:!0})}catch(a){return{ok:!1,error:V(a)}}let r,s,i;if(e.kind==="image"){if(r=`img-${gv()}`,s=Object.keys(il).find(a=>il[a]===e.mime)??"png",i=Buffer.from(e.data,"base64"),!i.length)return{ok:!1,error:"empty image data"}}else r=await WR(e.data)??`paste-${gv()}`,s="md",i=e.data;let o=`${r}.${s}`;for(let a=2;DR(al(n,o));a++)o=`${r}-${a}.${s}`;try{jR(al(n,o),i)}catch(a){return{ok:!1,error:V(a)}}return{ok:!0,path:`${sl}/${o}`}}function bv(t,e){if(!/^[\w-]+(\.[\w-]+)*$/.test(e))return{ok:!1,error:"bad name"};let n=e.slice(e.lastIndexOf(".")+1).toLowerCase(),r=il[n];if(!r)return{ok:!1,error:"not an image"};try{return{ok:!0,mime:r,base64:FR(al(t,sl,e)).toString("base64")}}catch{return{ok:!1,error:"not found"}}}var UR,qR,wv=S(()=>{"use strict";Rf();Zt();Mr();UR=4e3,qR=4e3});async function kv(t,e=""){let n=t.trim();if(!n)return{ok:!1,error:"nothing to summarize"};if(!mv())return zR;let r=e.trim()?Sv+`CONTEXT \u2014 the user message this reply answers. It is context only: never summarize it, and never report it as the reply's content.
2032
- `+HR(e.trim())+`
2019
+ `});function X(t){return t?.message??String(t)}var Z,Zt=k(()=>{"use strict";Z=process.cwd()});import{spawn as iv}from"child_process";import{StringDecoder as LR}from"string_decoder";function UR(t,e){let n=new LR("utf8"),r="";t.on("data",s=>{r+=typeof s=="string"?s:n.write(s);let i;for(;(i=r.indexOf(`
2020
+ `))>=0;){let o=r.slice(0,i);r=r.slice(i+1),o.endsWith("\r")&&(o=o.slice(0,-1)),o&&e(o)}})}var MR,ov,av,_f,cv,DR,BR,jR,lv,FR,ic,oc,uv,dv=k(()=>{"use strict";Zt();MR=3e4,ov=18e4,av="starting pi\u2026",_f=5e3,cv=2e3,DR=2e3,BR=12e4,jR=8e3,lv=15e3,FR=new Set(["get_state","get_commands","get_available_models","set_model","set_thinking_level","cycle_thinking_level","get_session_stats","compact","set_auto_compaction","get_fork_messages","fork","clone","set_session_name","export_html","bash","abort_bash"]),ic=new Set;process.on("exit",()=>{for(let t of ic)try{t.kill()}catch{}});oc=class{#t;#s=!1;#e=0;#r=!1;#c=0;#n=!1;#o=null;#l=[];#u=null;#i=null;#a=null;#f=new Map;#d=[];#b=null;#k=null;#w=null;#m;#g;#v="";#_=1;#p=new Map;#x;#S;constructor(e,n,r=(s,i)=>iv(s,{cwd:i,shell:!0,stdio:["pipe","pipe","pipe"],env:{...process.env,TYPEBULB_MIRROR:"1"}})){if(this.#x=new Promise(o=>{this.#S=o}),n?.includes('"')){this.#g="session path contains a quote \u2014 cannot drive it",this.#S();return}let s=n?`pi --mode rpc --session "${n}"`:"pi --mode rpc",i;try{i=r(s,e)}catch(o){this.#g=`could not start pi: ${X(o)}`,this.#S();return}this.#t=i,this.#m=n,this.#r=!0,this.#c=Date.now()+ov,this.#i={text:av,kind:"info"},ic.add(i),i.stdout&&UR(i.stdout,o=>this.#I(o)),i.stderr&&i.stderr.on("data",o=>{this.#v=(this.#v+o.toString()).slice(-DR)}),i.on("error",o=>this.#O(`could not start pi: ${o.message}`)),i.on("exit",o=>{this.#t===i&&this.#O(o?`pi exited (code ${o})${this.#v.trim()?`: ${this.#v.trim()}`:""}`:"pi exited"),ic.delete(i),this.#S()}),this.#h({type:"get_state"}).then(o=>{let a=o.data?.sessionFile;typeof a=="string"&&a&&(this.#m=a);let c=o.data?.model;c&&typeof c.id=="string"&&c.id&&(this.#w=c.id)}).catch(()=>{}).finally(()=>this.#R())}#R(){this.#r&&(this.#r=!1,this.#i?.text===av&&(this.#i=null),this.#a&&(this.#a.until=Date.now()+lv),!this.#s&&Date.now()<this.#e&&(this.#e=Date.now()+_f),this.#T())}get streaming(){return this.#s||Date.now()<this.#e}get draft(){return this.#o}get echo(){return this.#u}get queue(){return this.#b}get stats(){return this.#k}get model(){return this.#w}get sessionFile(){return this.#m}get error(){return this.#g}get status(){if(this.#i)return this.#i;if(this.#a){if(Date.now()<this.#a.until)return{text:this.#a.text,kind:this.#a.kind};this.#a=null}return this.#f.size?{text:[...this.#f.values()].join(" \xB7 "),kind:"info"}:null}get dialog(){let e=Date.now();for(;this.#d.length;){let n=this.#d[0];if(e<n.until)return n.req;this.#d.shift(),n.ownTimeout||this.#E({type:"extension_ui_response",id:n.req.id,cancelled:!0})}return null}notice(e,n){this.#y(e,n)}respondUi(e,n){let r=this.#d.findIndex(o=>o.req.id===e);if(r<0)return{ok:!1,error:"dialog expired or already answered"};let[s]=this.#d.splice(r,1),i={type:"extension_ui_response",id:e};return n.cancelled?i.cancelled=!0:s.req.method==="confirm"?i.confirmed=!!n.confirmed:i.value=n.value??"",this.#E(i),{ok:!0}}async rpc(e){if(!FR.has(e.type))return{ok:!1,error:`command not allowed: ${e.type}`};try{let n=await this.#h(e);if(n.success&&e.type==="set_model"){let r=n.data?.id;typeof r=="string"&&r&&(this.#w=r)}if(n.success&&(e.type==="fork"||e.type==="clone")){try{let s=(await this.#h({type:"get_state"})).data?.sessionFile;typeof s=="string"&&s&&(this.#m=s)}catch{}return{ok:!0,data:{...n.data??{},sessionFile:this.#m}}}return n.success?{ok:!0,data:n.data}:{ok:!1,error:n.error??`pi rejected ${e.type}`}}catch(n){return{ok:!1,error:X(n)}}}async send(e,n){let r=this.streaming,s=e.trimStart().startsWith("/"),i=r?s?{type:"prompt",message:e,streamingBehavior:n?.followUp?"followUp":"steer"}:{type:n?.followUp?"follow_up":"steer",message:e}:{type:"prompt",message:e},o=c=>{r||(this.#e=c,s||(this.#u=e))};if(this.#r)return this.#h(i).catch(()=>{}),o(this.#c+_f),{ok:!0};let a;try{a=await this.#h(i)}catch(c){return{ok:!1,error:X(c)}}return a.success&&o(Date.now()+_f),a.success?{ok:!0}:{ok:!1,error:a.error??"pi rejected the message"}}async stop(){if(this.#t){if(this.#r){this.#E({type:"abort"}),this.#e=0;return}try{await this.#h({type:"abort"})}catch{}}}clearCompletedDraft(){this.#n||(this.#o=null)}clearEcho(){this.#u=null}async dispose(){let e=this.#t;if(e){if(this.#t=void 0,this.#r=!1,this.#s){try{e.stdin?.write(JSON.stringify({type:"abort"})+`
2021
+ `)}catch{}await Promise.race([this.#x,uv(cv)])}try{e.stdin?.end()}catch{}if(await Promise.race([this.#x,uv(cv)]),e.exitCode===null&&!e.killed)if(process.platform==="win32"&&e.pid)try{iv("taskkill",["/pid",String(e.pid),"/T","/F"],{stdio:"ignore"})}catch{}else try{e.kill("SIGKILL")}catch{}ic.delete(e),this.#d=[],this.#P("pi was shut down")}}#E(e){try{this.#t?.stdin?.write(JSON.stringify(e)+`
2022
+ `)}catch{}}#C(){let e=this.#l[this.#l.length-1];this.#o={text:this.#l.filter(n=>n?.kind==="text").map(n=>n.text).join(""),thinking:this.#l.filter(n=>n?.kind==="thinking").map(n=>n.text).join(`
2023
+ `),tool:e?.kind==="tool"?e.name:void 0}}#A(e){let n=Array.isArray(e?.content)?e.content:[];this.#l=n.map(r=>({kind:r.type==="thinking"?"thinking":r.type==="toolCall"?"tool":"text",text:(r.type==="thinking"?r.thinking:r.text)??"",name:r.name})),this.#C()}#y(e,n){let r=e.length>200?e.slice(0,200)+"\u2026":e;r&&(this.#a={text:r,kind:n,until:Date.now()+(n==="info"?jR:lv)})}#T(){this.#h({type:"get_session_stats"}).then(e=>{if(!e.success||!e.data)return;let n=e.data;this.#k={cost:typeof n.cost=="number"?n.cost:0,contextTokens:typeof n.contextUsage?.tokens=="number"?n.contextUsage.tokens:null,contextPercent:typeof n.contextUsage?.percent=="number"?n.contextUsage.percent:null}}).catch(()=>{})}#h(e){let n=this.#t;if(!n?.stdin?.writable)return Promise.reject(new Error(this.#g??"pi is not running"));let r=this.#r?ov:MR,s=`tb-${this.#_++}`;return new Promise((i,o)=>{let a=setTimeout(()=>{this.#p.delete(s),o(new Error(`pi did not respond (${Math.round(r/1e3)}s)`))},r);a.unref?.(),this.#p.set(s,{resolve:i,timer:a});try{n.stdin.write(JSON.stringify({id:s,...e})+`
2024
+ `)}catch(c){clearTimeout(a),this.#p.delete(s),o(new Error(X(c)))}})}#I(e){let n;try{n=JSON.parse(e)}catch{return}switch(n.type){case"response":{let r=n,s=r.id?this.#p.get(r.id):void 0;s&&(this.#p.delete(r.id),clearTimeout(s.timer),s.resolve(r));return}case"agent_start":this.#s=!0,this.#e=0;return;case"agent_end":this.#s=!1,this.#e=0,this.#n=!1,this.#i=null,this.#b=null,this.#T();return;case"message_start":{let r=n.message;if(r?.role!=="assistant")return;this.#n=!0,this.#A(r);return}case"message_update":{if(!this.#n)return;if(n.message){this.#A(n.message);return}let r=n.assistantMessageEvent;if(!r||typeof r.contentIndex!="number")return;let s=r.type.startsWith("thinking")?"thinking":r.type.startsWith("toolcall")?"tool":"text",i=this.#l[r.contentIndex]??={kind:s,text:""};i.kind=s,typeof r.delta=="string"&&s!=="tool"&&(i.text+=r.delta),typeof r.content=="string"&&(i.text=r.content),r.toolCall?.name&&(i.name=r.toolCall.name),this.#C();return}case"message_end":if(!this.#n)return;n.message&&this.#A(n.message),this.#n=!1;return;case"auto_retry_start":this.#i={text:`retrying after a transient error (attempt ${Number(n.attempt)||1}/${Number(n.maxAttempts)||"?"})\u2026`,kind:"warning"};return;case"auto_retry_end":this.#i=null,n.success===!1&&this.#y(`retries exhausted: ${String(n.finalError??"unknown error")}`,"error");return;case"compaction_start":this.#i={text:"compacting context\u2026",kind:"info"};return;case"compaction_end":{this.#i=null;let r=n.result;typeof n.errorMessage=="string"&&n.errorMessage?this.#y(`compaction failed: ${n.errorMessage}`,"error"):r?.tokensBefore&&this.#y(`compacted: ~${Math.round(r.tokensBefore/1e3)}k \u2192 ~${Math.round((r.estimatedTokensAfter??0)/1e3)}k tokens`,"info"),this.#T();return}case"queue_update":{let r=Array.isArray(n.steering)?n.steering.map(String):[],s=Array.isArray(n.followUp)?n.followUp.map(String):[];this.#b=r.length||s.length?{steering:r,followUp:s}:null;return}case"extension_ui_request":{let r=String(n.method??"");if(r==="select"||r==="confirm"||r==="input"||r==="editor"){let s=typeof n.timeout=="number"&&n.timeout>0?n.timeout:void 0;this.#d.push({req:{id:String(n.id??""),method:r,title:typeof n.title=="string"?n.title:void 0,message:typeof n.message=="string"?n.message:void 0,options:Array.isArray(n.options)?n.options.map(String):void 0,placeholder:typeof n.placeholder=="string"?n.placeholder:void 0,prefill:typeof n.prefill=="string"?n.prefill:void 0},until:Date.now()+(s??BR),ownTimeout:s!==void 0})}else if(r==="notify"){let s=n.notifyType==="warning"?"warning":n.notifyType==="error"?"error":"info";this.#y(String(n.message??""),s),console.log(`[composer] pi extension: ${String(n.message??"")}`)}else if(r==="setStatus"){let s=String(n.statusKey??"");typeof n.statusText=="string"&&n.statusText?this.#f.set(s,n.statusText):this.#f.delete(s)}return}default:return}}#O(e){this.#g=e,this.#r=!1,this.#s=!1,this.#e=0,this.#n=!1,this.#o=null,this.#l=[],this.#u=null,this.#i=null,this.#a=null,this.#f.clear(),this.#d=[],this.#b=null,this.#k=null,this.#w=null,this.#t=void 0,this.#P(e)}#P(e){for(let[,n]of this.#p)clearTimeout(n.timer),n.resolve({type:"response",success:!1,error:e});this.#p.clear()}},uv=t=>new Promise(e=>{setTimeout(e,t).unref?.()})});import{existsSync as fv,readFileSync as qR,realpathSync as JR}from"fs";import{join as Ln,dirname as gv,resolve as WR}from"path";import{homedir as pv}from"os";function HR(t,e){let n=Ln(t,".pi");if(KR.some(s=>fv(Ln(n,s))))return!0;let r=Ln(e,".agents","skills");for(let s=t;;){let i=Ln(s,".agents","skills");if(i!==r&&fv(i))return!0;let o=gv(s);if(o===s)return!1;s=o}}function zR(t,e){for(let n=e;;){if(t[n]===!0||t[n]===!1)return!0;let r=gv(n);if(r===n)return!1;n=r}}function yv(t,e){try{let n=e?.agentDir??Ln(pv(),".pi","agent"),r=hv(e?.home??process.env.HOME??pv()),s=hv(WR(t));if(!HR(s,r))return null;let i=mv(Ln(n,"settings.json")).defaultProjectTrust;return i==="always"||i==="never"||zR(mv(Ln(n,"trust.json")),s)?null:"pi has no trust decision for this project \u2014 running untrusted; run `pi` once in a terminal to grant it"}catch{return null}}var KR,hv,mv,bv=k(()=>{"use strict";KR=["settings.json","extensions","skills","prompts","themes","SYSTEM.md","APPEND_SYSTEM.md"],hv=t=>{try{return JR(t)}catch{return t}},mv=t=>{try{return JSON.parse(qR(t,"utf8"))}catch{return{}}}});import{statSync as YR,openSync as VR,readSync as GR,closeSync as XR,existsSync as vv}from"fs";import{join as ac}from"path";import{homedir as Rf}from"os";import{execFile as QR}from"child_process";async function eI(t){let e=ac(Rf(),".pi","agent","bin",process.platform==="win32"?"fd.exe":"fd");for(let n of["fd","fdfind",...vv(e)?[e]:[]]){let r=await new Promise(s=>{QR(n,["--base-directory",t,"--type","f","--follow","--hidden","--exclude",".git"],{maxBuffer:67108864},(i,o)=>s(i?null:o))});if(r!==null)return r.split(`
2025
+ `).filter(Boolean).map(s=>s.replace(/\\/g,"/"))}return null}function tI(t){return`--${t.replace(/^[/\\]/,"").replace(/[/\\:]/g,"-")}--`}function wv(t){return t.type==="message"?nI(t.message?.role):t.type==="custom_message"?t.display!==!1:!1}var ZR,nI,Dr,If=k(()=>{"use strict";Ms();Qo();Zo();sv();dv();bv();ZR=ac(Rf(),".pi","agent","sessions");nI=t=>t==="user"||t==="assistant"||t==="toolResult"||t==="bashExecution";Dr=class extends Ut{displayName="Pi Mirror";detectsSelf(){return process.env.PI_CODING_AGENT==="true"}detectsInstalled(){return vv(ac(Rf(),".pi","agent"))}ensureHarnessSupport(){rv()}createDriver(e,n){let r=new oc(e,n),s=yv(e);return s&&r.notice(s,"warning"),r}walkFiles(e){return eI(e)}sessionsDir(e){return ac(ZR,tI(e))}listSessionFiles(e){return Xo(this.sessionsDir(e))}parseEntry(e){let n;try{n=JSON.parse(e)}catch{return null}return!n||n.type==="session"||!n.id?null:n}idOf(e){return e.id}parentOf(e){return e.parentId??void 0}timestampOf(e){return e.timestamp}isSidechain(e){return!1}isLeafType(e){return wv(e)}isRecoveryNoise(e){return!1}apply(e,n){let r=[];if(e.type==="custom_message"){if(e.display===!1)return{events:r};let i=this.contentText(e.content).trim();return i&&r.push({type:"user",text:i}),{events:r}}if(e.type!=="message"||!e.message)return{events:r};let s=e.message;if(s.role==="user"){let i=this.contentText(s.content).trim();return i&&r.push({type:"user",text:i}),{events:r}}if(s.role==="toolResult"){let i=this.contentText(s.content);return r.push({type:"tool_result",id:s.toolCallId??"",content:i,isError:!!s.isError,digest:Fe(i)}),{events:r}}if(s.role==="bashExecution")return s.command&&!s.excludeFromContext&&r.push({type:"user",text:`$ ${s.command}`}),{events:r};if(s.role==="assistant"){let i=Array.isArray(s.content)?s.content:[],o=i.filter(d=>d.type==="text").map(d=>d.text??"").join(""),a=i.filter(d=>d.type==="thinking").map(d=>d.thinking??"").join(`
2026
+ `),c=i.filter(d=>d.type==="toolCall").map(d=>({id:d.id??"",name:d.name??"",input:d.arguments??{}}));if(o||a||c.length){let d=Date.parse(e.timestamp??""),p=!isNaN(d)&&d>=n;r.push({type:"assistant",text:o,thinking:a,tools:c,live:p})}let l=s.usage,f=l?(l.input??0)+(l.output??0)+(l.cacheRead??0)+(l.cacheWrite??0):0,u=l&&f>0&&s.stopReason!=="aborted"&&s.stopReason!=="error"?{in:l.input??0,out:l.output??0,cached:l.cacheRead??0,cacheCreate:l.cacheWrite??0}:void 0;return{events:r,usage:u,model:s.model,cost:l?.cost?.total}}return{events:r}}chainWorking(e){let n;for(let a of e)wv(a)&&(n=a);if(!n||n.type==="custom_message")return!1;let r=n.message.role;if(r==="user"||r==="toolResult"||r==="bashExecution")return!0;if(r!=="assistant")return!1;let i=(Array.isArray(n.message.content)?n.message.content:[]).filter(a=>a.type==="toolCall").map(a=>a.id);if(!i.length)return!1;let o=new Set;for(let a of e)a.type==="message"&&a.message?.role==="toolResult"&&a.message.toolCallId&&o.add(a.message.toolCallId);return i.some(a=>a&&!o.has(a))}sessionAlive(){}readPreview(e){let n;try{n=VR(e,"r")}catch{return""}try{let s=65536;try{s=YR(e).size}catch{}let i=(u,d)=>{let p=Buffer.alloc(d),h=GR(n,p,0,d,u);return p.subarray(0,h).toString("utf8")},o=i(0,Math.min(65536,s)),a=s>65536?i(s-65536,65536):"",c=u=>{let d="";for(let p of u.split(`
2027
+ `))if(p.includes('"session_info"'))try{let h=JSON.parse(p);h?.type==="session_info"&&typeof h.name=="string"&&h.name&&(d=h.name)}catch{}return d},l="";for(let u of o.split(`
2028
+ `))if(!(l||!u.includes('"type"')))try{let d=JSON.parse(u);d?.type==="message"&&d.message?.role==="user"&&(l=this.contentText(d.message.content).replace(/\s+/g," ").trim())}catch{}let f=c(a)||c(o)||l;return f?f.slice(0,200):""}finally{XR(n)}}searchText(e){if(e?.type!=="message")return"";let n=e.message?.role;if(n!=="user"&&n!=="assistant")return"";let r=e.message?.content,s="";return typeof r=="string"?s=r:Array.isArray(r)&&(s=r.filter(i=>i.type==="text"&&typeof i.text=="string").map(i=>i.text).join(" ")),s.replace(/\s+/g," ").trim()}contentText(e){return typeof e=="string"?Ie(e):Array.isArray(e)?e.map(n=>typeof n?.text=="string"?Ie(n.text):n?.type==="image"&&n.data?Vo(n.data,n.mimeType):"").filter(Boolean).join(`
2029
+ `):""}}});var cc,Sv=k(()=>{"use strict";cc=class{#t=new Map;accept(e,n){return this.#t.get(e)===n?!1:(this.#t.set(e,n),!0)}}});import{execFile as rI}from"child_process";import{promisify as sI}from"util";import{readFile as iI}from"fs/promises";import{resolve as kv,sep as oI}from"path";async function Se(t,e){let{stdout:n}=await aI("git",t,{cwd:e,maxBuffer:67108864});return n}async function Mn(){if(lc)return lc;try{lc=(await Se(["rev-parse","--show-toplevel"],Z)).trim()}catch{}return lc}function cI(t,e){let n=e===" "?t:e;return n==="?"?"U":n}async function Nf(){let t=await Mn();if(!t)return{repo:!1,root:"",files:[]};try{let e=await Se(["status","--porcelain","-z"],t),n=[],r=e.split("\0");for(let s=0;s<r.length;s++){let i=r[s];i.length<4||((i[0]==="R"||i[0]==="C")&&s++,n.push({path:i.slice(3),status:cI(i[0],i[1])}))}try{let s=await Se(["diff","--numstat","-z","HEAD"],t),i=new Map,o=s.split("\0");for(let a=0;a<o.length;a++){let c=/^(\d+|-)\t(\d+|-)\t(.*)$/.exec(o[a]);if(!c)continue;let l=c[3]||o[a+=2];l&&i.set(l,{add:+c[1]||0,del:+c[2]||0,binary:c[1]==="-"})}for(let a of n){let c=i.get(a.path);c&&(c.binary?a.binary=!0:(a.add=c.add,a.del=c.del))}}catch{}return n.sort((s,i)=>s.path.localeCompare(i.path)),{repo:!0,root:t,files:n}}catch(e){return{repo:!1,root:"",files:[],error:X(e)}}}async function Lf(t){let e=await Mn();if(!e)return{ok:!1,error:"not a git repository"};try{if((await Se(["status","--porcelain","-z","--",t],e)).startsWith("??")){let s=kv(e,t);if(!s.startsWith(kv(e)+oI))return{ok:!1,error:"outside repository"};let i=await iI(s);return i.includes(0)?$f("Binary file (not shown)",!1):$f(i.toString("utf8"),!0)}let r;try{r=await Se(["diff","--no-color","--unified=999999","HEAD","--",t],e)}catch{r=await Se(["diff","--no-color","--unified=999999","--",t],e)}return $f(r,!1)}catch(n){return{ok:!1,error:X(n)}}}var aI,xv,lc,$f,Br=k(()=>{"use strict";Zt();aI=sI(rI),xv=2e6;$f=(t,e)=>({ok:!0,text:t.slice(0,xv),untracked:e,truncated:t.length>xv})});function mi(t,e){let n=0,r="";for(let s of t){let i=s.lower.indexOf(e);if(!(i<0)&&(n++,!r)){let o=Math.max(0,i-110),a=Math.min(s.text.length,i+e.length+110);r=(o>0?"\u2026":"")+s.text.slice(o,a)+(a<s.text.length?"\u2026":"")}}return{hitCount:n,snippet:r}}var Mf=k(()=>{"use strict"});function Ev(){return lI.map(([t,e])=>St(t,e)).filter(t=>typeof t!="string")}function Av(){return Ev().length>0}async function uc(t,e,n=0){let r=AbortSignal.timeout(e);for(let s of Ev()){try{let i=await Ht(s,{messages:[{role:"user",content:t}],effort:n,webSearch:!1,signal:r});if(i.ok){let o=(await Xd(i,s.protocol)).trim();if(o)return o}}catch{}if(r.aborted)return}}var lI,Df=k(()=>{"use strict";Wt();Qt();lI=[["openrouter","anthropic/claude-haiku-5.5"],["anthropic","claude-haiku-5-5"],["openai","gpt-6-luna"]]});var dc,fc,ft,pc,jr=k(()=>{"use strict";dc=".typebulb/paste",fc={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",bmp:"image/bmp"},ft=t=>t.label||t.kind||"agent",pc=t=>t.failing&&t.state!=="stopped"?"failing":t.state});import{existsSync as uI,mkdirSync as dI,writeFileSync as fI,readFileSync as pI}from"fs";import{join as hc}from"path";function Tv(){let t=new Date,e=n=>String(n).padStart(2,"0");return`${t.getFullYear()}${e(t.getMonth()+1)}${e(t.getDate())}-${e(t.getHours())}${e(t.getMinutes())}${e(t.getSeconds())}`}function gI(t){return t.trim().toLowerCase().replace(/\.[a-z0-9]{1,4}$/,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)}async function yI(t){let e=await uc(`Reply with ONLY a short kebab-case filename (2-5 words, lowercase, no extension) describing this text:
2030
+
2031
+ ${t.slice(0,mI)}`,hI);return e&&gI(e)||void 0}async function Cv(t,e){if(!e||e.kind!=="image"&&e.kind!=="text")return{ok:!1,error:"bad paste kind"};if(typeof e.data!="string"||!e.data)return{ok:!1,error:"empty paste"};let n=hc(t,dc);try{dI(n,{recursive:!0})}catch(a){return{ok:!1,error:X(a)}}let r,s,i;if(e.kind==="image"){if(r=`img-${Tv()}`,s=Object.keys(fc).find(a=>fc[a]===e.mime)??"png",i=Buffer.from(e.data,"base64"),!i.length)return{ok:!1,error:"empty image data"}}else r=await yI(e.data)??`paste-${Tv()}`,s="md",i=e.data;let o=`${r}.${s}`;for(let a=2;uI(hc(n,o));a++)o=`${r}-${a}.${s}`;try{fI(hc(n,o),i)}catch(a){return{ok:!1,error:X(a)}}return{ok:!0,path:`${dc}/${o}`}}function Ov(t,e){if(!/^[\w-]+(\.[\w-]+)*$/.test(e))return{ok:!1,error:"bad name"};let n=e.slice(e.lastIndexOf(".")+1).toLowerCase(),r=fc[n];if(!r)return{ok:!1,error:"not an image"};try{return{ok:!0,mime:r,base64:pI(hc(t,dc,e)).toString("base64")}}catch{return{ok:!1,error:"not found"}}}var hI,mI,Pv=k(()=>{"use strict";Df();Zt();jr();hI=4e3,mI=4e3});async function Iv(t,e=""){let n=t.trim();if(!n)return{ok:!1,error:"nothing to summarize"};if(!Av())return vI;let r=e.trim()?Rv+`CONTEXT \u2014 the user message this reply answers. It is context only: never summarize it, and never report it as the reply's content.
2032
+ `+wI(e.trim())+`
2033
2033
 
2034
2034
  REPLY TO SUMMARIZE:
2035
- `+n.slice(0,vv):Sv+n.slice(0,vv),s=await rl(r,KR,1);return s?{ok:!0,text:s}:YR}var KR,vv,Sv,HR,zR,YR,xv=S(()=>{"use strict";Rf();KR=2e4,vv=24e3,Sv=`Summarize this assistant reply for someone who wants its substance without the prose.
2035
+ `+n.slice(0,_v):Rv+n.slice(0,_v),s=await uc(r,bI,1);return s?{ok:!0,text:s}:SI}var bI,_v,Rv,wI,vI,SI,$v=k(()=>{"use strict";Df();bI=2e4,_v=24e3,Rv=`Summarize this assistant reply for someone who wants its substance without the prose.
2036
2036
 
2037
2037
  - Markdown. Start with the direct answer, recommendation, result, or status. If it is qualified, put the qualification in that same opening sentence; do not make the reader infer it from later bullets.
2038
2038
  - Preserve material limits and conditions that change the answer: exceptions, tradeoffs, prerequisites, uncertainty, incomplete validation, and clauses such as but, only when, unless, or if. Cut only filler hedges (for example, "I think" or "arguably") that change nothing.
@@ -2047,46 +2047,51 @@ Reply with the summary alone.
2047
2047
 
2048
2048
  ---
2049
2049
 
2050
- `,HR=(t,e=4e3)=>{if(t.length<=e)return t;let n=Math.floor(e/2)-20;return t.slice(0,n)+`
2050
+ `,wI=(t,e=4e3)=>{if(t.length<=e)return t;let n=Math.floor(e/2)-20;return t.slice(0,n)+`
2051
2051
 
2052
2052
  [snipped for brevity]
2053
2053
 
2054
- `+t.slice(t.length-n)},zR={ok:!1,error:"Summary needs OPENROUTER_API_KEY or OPENAI_API_KEY in this project\u2019s .env.",setup:!0},YR={ok:!1,error:"the model call failed or timed out"}});import{readFileSync as VR,statSync as GR}from"fs";function ll(t,e,n,r){let s=t.apply(e,r),i=Date.parse(t.timestampOf(e)??""),o=s.events.map(a=>{let l=n==="child"&&a.type==="user"?{...a,authored:!0}:a;return!isNaN(i)&&(l.type==="user"||l.type==="assistant"||l.type==="tool_result"||l.type==="task_done"||l.type==="turn_end")&&(l.at=i),l});return{...s,events:o}}function cl(t){let e=new Map,n=t.linker();return{entries:e,add(r,s){let i;for(let o of r){if(!o.trim())continue;let a=t.parseEntry(o);if(!a)continue;n.link(a);let l=t.idOf(a);l&&(e.set(l,a),!t.isSidechain(a,s)&&t.isLeafType(a)&&(i=l))}return i}}}function Ev(t,e,n){let r=t.forRead(),s;try{s=VR(e,"utf8")}catch{return[]}let{entries:i,add:o}=cl(r),a=o(s.split(`
2055
- `),n),l=[],c=new Set;for(let u=a;u&&!c.has(u);){let p=i.get(u);if(!p)break;c.add(u),l.push(p),u=r.parentOf(p)}let f=[],d=Date.now();for(let u of l.reverse())if(!r.isSidechain(u,n))try{f.push(...ll(r,u,n,d).events)}catch{}return f}function ul(t,e,n,r){let s=t.sessionAlive(e,n);if(s!==void 0)return s;if(!r)return!1;try{return Date.now()-GR(r).mtimeMs<1e4}catch{return!1}}function di(t,e){return t.stopped?"stopped":t.running&&e?"running":"done"}var If=S(()=>{"use strict"});function XR(t,...e){return t.slice().sort((n,r)=>{for(let{key:s,desc:i}of e){let o=s(n),a=s(r);if(o!==a)return o==null?i?-1:1:a==null||o<a?i?1:-1:i?-1:1}return 0})}function Av(t){let e=new Set(t.map(o=>o.id)),n=new Map;for(let o of t){let a=o.parentId&&e.has(o.parentId)?o.parentId:"",l=n.get(a);l?l.push(o):n.set(a,[o])}let r=[],s=new Set,i=o=>{for(let a of n.get(o)??[])s.has(a.id)||(s.add(a.id),r.push(a),i(a.id))};i("");for(let o of t)s.has(o.id)||r.push(o);return r}var fi,$f=S(()=>{"use strict";fi=(t,e)=>XR(t,{key:e,desc:!0})});function _v(t){let e=[],n=new Map,r=new Map,s=[],i=[],o=[],a=[],l,c=!1,f=0;for(let d of t){if(d.type==="cleared"){e=[],n=new Map,r=new Map,s=[],i=[],o=[],a=[],l=void 0,c=!1;continue}let u="at"in d?d.at:void 0;if(u!==void 0&&(f=Math.max(f,u)),d.type==="user")l===void 0&&!d.agent?l=u:u!==void 0&&s.push(u),c=!1;else if(d.type==="assistant"){u!==void 0&&i.push(u);let p=d.error?void 0:d.text.split(`
2056
- `).find(h=>h.trim());p&&a.push({text:Mn(p,200),calls:e.length});for(let h of d.tools){let m={id:h.id,name:h.name,input:h.input,at:u,isError:!1};e.push(m),n.set(h.id,m)}}else if(d.type==="tool_result"){let p=n.get(d.id);if(!p)continue;Object.assign(p,{result:d.content,isError:d.isError,exit:d.exit,background:d.background,refused:d.refused,doneAt:u}),d.output&&(p.output=d.output),d.task&&r.set(d.task,p),u!==void 0&&i.push(u)}else if(d.type==="task_done"){let p=d.id?n.get(d.id):d.task?r.get(d.task):void 0;if(!p?.background||p.endAt!==void 0)continue;Object.assign(p,{endAt:u??f,outcome:d.outcome,output:d.output??p.output}),d.exit!==void 0&&(p.exit=d.exit),c&&u!==void 0&&(s.push(u),c=!1)}else d.type==="turn_end"&&(!c&&u!==void 0&&o.push(u),c=!0)}return{calls:e,turnEnds:o,narration:a,lastAt:f,...ZR(e,s,i,l,f)}}function ZR(t,e,n,r,s){let i=r??t[0]?.at??s,o=[];for(let f of e){let d=-1/0;for(let p of n)p<=f&&p>d&&(d=p);let u=t.some(p=>p.at!==void 0&&p.at<f&&(p.doneAt??1/0)>f);d>-1/0&&!u&&f-d>=QR&&o.push([d,f])}let a=o.reduce((f,[d,u])=>f+Math.max(0,Math.min(s,u)-d),0),l=0,c=-1/0;for(let f of t.filter(d=>d.at!==void 0).sort((d,u)=>d.at-u.at)){let d=f.doneAt??s;d>c&&(l+=d-Math.max(f.at,c),c=d)}return{span:Math.max(0,s-i-a),idle:a,toolMs:l}}function Mf(t,e){if(Lf(t))return;let n=Rv(t),r=t.background?t.endAt:t.doneAt,s=mi(t),i=!n&&(t.exit!==void 0?t.exit!==0&&!(t.exit===1&&s&&qy(Xo(s).rest)):t.background?t.outcome==="failed":t.isError),o=t.background?t.output?e?.(t.output)??"":"":t.result??"";return{id:t.id,at:t.at,open:n,failed:i,hidden:!n&&!i&&!!s&&Jy(s)||void 0,exit:t.exit,outcome:t.background?t.outcome:void 0,ms:t.at!==void 0&&r!==void 0?r-t.at:void 0,...eI(o)}}function eI(t){let e=Ps(t).split(`
2057
- `).map(n=>n.trim()).filter(n=>/[\p{L}\p{N}]/u.test(n));return/^exit(?: code)?:? \d+$/i.test(e[0]??"")&&e.shift(),{first:Mn(e[0]??"",120),last:e.length>1?Mn(e.at(-1),120):""}}function rI(t,e,n=hi){let r=new Map,s=0;for(let o of t.calls){let a=mi(o),l=a&&Mf(o,e);if(!l)continue;let c=Pv(a).trim();if(Uy(c)){s++;continue}r.set(c,[...r.get(c)??[],l])}let i=[...r].map(([o,a])=>{let l=0;for(let d of a.filter(u=>!u.open&&!u.hidden).reverse()){if(!d.failed)break;l++}let c=Ls(o),f=[tI.test(c)?"stops a process":"",nI.test(c)?"git write":""].filter(Boolean);return{cmd:Mn(rd(o),100),runs:a.length,open:a.filter(d=>d.open).length,failed:a.filter(d=>d.failed).length,hidden:a.filter(d=>d.hidden).length,streak:l,long:a.some(d=>(d.ms??0)>n)?`over ${n%6e4?`${Math.round(n/1e3)}s`:fe(n)}`:"",ms:a.reduce((d,u)=>d+(u.ms??0),0),tags:f,latest:a.at(-1)}}).sort((o,a)=>(a.latest.at??0)-(o.latest.at??0));return{runs:i.reduce((o,a)=>o+a.runs,0),failed:i.reduce((o,a)=>o+a.failed,0),lookups:s,groups:i}}function lI(t){let e=t.filter(Boolean),n=e.slice(Math.max(0,e.map(aI).lastIndexOf(!0)));if(n.some(s=>s.includes("$")||/^~|^-$/.test(s)))return;let r=[];for(let s of n.join("/").split("/"))s===".."&&r.length&&!/^(\.\.|[a-zA-Z]:)?$/.test(r.at(-1))?r.pop():s!=="."&&(s||!r.length)&&r.push(s);return r.join("/")}function Iv(t,e){let n=new Map,r=[],s=[],i=[],o=c=>c.trim().replace(/^["']|["']$/g,"").replace(/\\/g,"/").replace(/^\/([a-zA-Z])\//,"$1:/"),a=c=>{let f=Ty(o(c),e).replace(/^\.\//,"");return!f||/^([a-zA-Z]:)?\//.test(f)?void 0:f},l=c=>a(c)??(o(c)||void 0);for(let c of t.calls){if(c.isError||c.result===void 0)continue;let f=c.doneAt??c.at??0,d=(O,P={},k=!1)=>{let L=a(O);if(!L)return;let j=n.get(L)??{path:L};j.deleted=P.deleted,P.from&&(j.from=P.from),n.set(L,j),r.push({path:L,at:f,whole:k})},u=(O,P)=>{let k=a(O),L=k?n.get(k):void 0;k&&(n.delete(k),r.push({path:k,at:f})),d(P,{from:L?.from??k})},p=c.input??{},h=!1;for(let[O,P]of Object.entries(p)){if(O==="command"||O==="cmd"||typeof P!="string"||!/^(---|\+\+\+) /m.test(P))continue;let k;for(let L of P.split(`
2058
- `)){let j=/^(---|\+\+\+) (?:[ab]\/)?(.+?)\s*$/.exec(L);if(j?.[1]==="---"){k=j[2];continue}if(j?.[1]==="+++"){h=!0,j[2]==="/dev/null"?k&&k!=="/dev/null"&&d(k,{deleted:!0}):d(j[2]);continue}let Q=/^\*\*\* Move to: (.+?)\s*$/.exec(L);Q&&k&&u(k,Q[1])}}let m=Z(p.file_path)??Z(p.filePath)??Z(p.path),g=oI.some(O=>O in p);!h&&m&&g&&d(m,{},typeof p.content=="string");let b=Z(p.file_path)??Z(p.filePath);if(b&&!g&&!h){let O=l(b);O&&s.push({path:O,at:f})}let C=O=>Object.entries(p).filter(([P,k])=>typeof k=="string"&&(P===O||P.startsWith(`${O} (`))).map(([,P])=>P);if(c.name==="read")for(let O of C("path")){let P=l(O);P&&s.push({path:P,at:f})}let T=Z(p.workdir),E=O=>{let{dirs:P,rest:k}=Xo(O);return{rest:k,at:L=>lI([e,T??"",...P,L].map(o))}};for(let O of[...C("command"),...C("cmd")]){let P=E(O);for(let k of Hy(P.rest)){let L=P.at(k),j=L&&l(L);j&&i.push({path:j,at:f})}}let $=mi(c);if($){let O=E($);for(let P of Wy(O.rest)){let k=O.at(P.from),L=P.to&&O.at(P.to);k&&L?u(k,L):k&&!P.to&&d(k,{deleted:!0})}}}return{edited:[...n.values()],writes:r,reads:s,shellReads:i}}function $v(t){let e=new Map;for(let s of t)for(let i of s.writes)e.set(i.path,[...e.get(i.path)??[],{id:s.id,at:i.at,whole:i.whole}]);let n=new Map,r=new Map;for(let[s,i]of e){i.sort((a,l)=>a.at-l.at);let o=new Map;for(let a of i)o.set(a.id,a.at);n.set(s,[...o].map(([a,l])=>({id:a,at:l})).sort((a,l)=>a.at-l.at)),i.forEach((a,l)=>{if(!a.whole)return;let c=i.slice(0,l).reverse().find(u=>u.id!==a.id);if(!c)return;let f=t.find(u=>u.id===a.id);[...f.reads,...f.writes].some(u=>u.path===s&&u.at>c.at&&u.at<a.at)||r.set(`${s}
2054
+ `+t.slice(t.length-n)},vI={ok:!1,error:"Summary needs OPENROUTER_API_KEY or OPENAI_API_KEY in this project\u2019s .env.",setup:!0},SI={ok:!1,error:"the model call failed or timed out"}});import{readFileSync as kI,statSync as xI}from"fs";function Fr(t,e,n,r){let s=t.apply(e,r),i=Date.parse(t.timestampOf(e)??""),o=s.events.map(a=>{let c=n==="child"&&a.type==="user"?{...a,authored:!0}:a;return!isNaN(i)&&(c.type==="user"||c.type==="assistant"||c.type==="tool_result"||c.type==="task_done"||c.type==="turn_end")&&(c.at=i),c});return{...s,events:o}}function mc(t){let e=new Map,n=t.linker();return{entries:e,add(r,s){let i;for(let o of r){if(!o.trim())continue;let a=t.parseEntry(o);if(!a)continue;n.link(a);let c=t.idOf(a);c&&(e.set(c,a),!t.isSidechain(a,s)&&t.isLeafType(a)&&(i=c))}return i}}}function Nv(t,e,n){let r=t.forRead(),s;try{s=kI(e,"utf8")}catch{return[]}let{entries:i,add:o}=mc(r),a=o(s.split(`
2055
+ `),n),c=[],l=new Set;for(let d=a;d&&!l.has(d);){let p=i.get(d);if(!p)break;l.add(d),c.push(p),d=r.parentOf(p)}let f=[],u=Date.now();for(let d of c.reverse())if(!r.isSidechain(d,n))try{f.push(...Fr(r,d,n,u).events)}catch{}return f}function gc(t,e,n,r){let s=t.sessionAlive(e,n);if(s!==void 0)return s;if(!r)return!1;try{return Date.now()-xI(r).mtimeMs<1e4}catch{return!1}}function Ur(t,e){return t.stopped?"stopped":t.running&&e?"running":"done"}var yc=k(()=>{"use strict"});function EI(t,...e){return t.slice().sort((n,r)=>{for(let{key:s,desc:i}of e){let o=s(n),a=s(r);if(o!==a)return o==null?i?-1:1:a==null||o<a?i?1:-1:i?-1:1}return 0})}function Lv(t){let e=new Set(t.map(o=>o.id)),n=new Map;for(let o of t){let a=o.parentId&&e.has(o.parentId)?o.parentId:"",c=n.get(a);c?c.push(o):n.set(a,[o])}let r=[],s=new Set,i=o=>{for(let a of n.get(o)??[])s.has(a.id)||(s.add(a.id),r.push(a),i(a.id))};i("");for(let o of t)s.has(o.id)||r.push(o);return r}var gi,Bf=k(()=>{"use strict";gi=(t,e)=>EI(t,{key:e,desc:!0})});function _I(t){let e=[],n="",r,s=o=>{if(!r)return;let a=r.lines.join(`
2056
+ `).trim(),c={kind:r.kind,id:r.id,text:a};if(r.kind==="Ask"){let[l,f]=a.split(CI);c.question=l.trim(),f?.trim()&&(c.recommend=f.trim())}e.push({tag:c,end:o}),r=void 0},i=t.split(`
2057
+ `);for(let o=0;o<i.length;o++){let a=i[o],c=OI.exec(a)?.[1];if(n){c&&c[0]===n[0]&&c.length>=n.length&&(n="");continue}if(c){s(o),n=c;continue}let l=TI.exec(a.trimStart());if(l){s(o),r={kind:l[1],id:l[2],lines:[a.trimStart().slice(l[0].length)]};continue}if(r){if(!a.trim()||PI.test(a)){s(o);continue}r.lines.push(a.trim())}}return s(i.length),e}function Mv(t,e){let n=[],r=0;for(let s of t)s.type==="cleared"?(n.length=0,r=0):s.type==="user"?r++:s.type==="assistant"&&!s.error&&s.text&&n.push(...jf(s.text).map(i=>({...i,turn:r,at:s.at,from:e})));return n}function Dv(t,e={}){let n=new Map;for(let r of t){let s=n.get(r.id)??{id:r.id,state:"open",latest:r,version:0,first:r.at};r.kind==="Ask"&&s.ask?.text!==r.text&&s.version++,r.kind==="Ask"&&(s.ask=r),s.latest=r,n.set(r.id,s)}for(let r of n.values()){let s=e[r.id];r.answer=r.ask&&s&&s.version===r.version?s:void 0,r.latest.kind==="Ask"?r.state=r.answer?"answered":"open":r.state=r.latest.kind.toLowerCase()}return[...n.values()]}function RI(t){return[t.choice==="accept"?`accept: ${t.recommend??""}`:t.choice==="todo"?"leave as todo":t.choice==="discuss"?"discuss":"",t.note?`note: "${t.note}"`:""].filter(Boolean).join(" \xB7 ")}function Bv(t,e){let n=t.filter(i=>i.state==="open"),r=t.filter(i=>i.state==="answered");if(!n.length&&!r.length)return[];let s=Math.min(...n.map(i=>i.ask?.at??e));return[n.length?`Asks: ${n.length} waiting on the owner, the oldest for ${ne(e-s)}.`:"Asks: none waiting on the owner.",...r.map(i=>` ${yi(i.id,i.answer)} (answered, not acknowledged)`)]}function Ff(t){let e=t.split(`
2058
+ `).find(r=>r.trim())?.trim()??"",n=II.exec(t)?.[1];return{line:e.length>200?e.slice(0,200)+"\u2026":e,boxMs:n?$I(n):void 0}}function $I(t){let e=/^(\d+(?:\.\d+)?)([smh]?)$/.exec(t),n=e?Number(e[1])*{s:1e3,m:6e4,h:36e5,"":6e4}[e[2]]:0;return n>0?n:void 0}var AI,TI,CI,OI,PI,jf,yi,II,Dn=k(()=>{"use strict";or();AI=["Ask","Decided","Todo","Done","Finding"],TI=new RegExp(`^(?:[-*+]\\s+|\\d+[.)]\\s+)?\\*\\*(${AI.join("|")}) \\[([a-z0-9][a-z0-9-]*)\\]:?\\*\\*:?[ \\t]*`),CI=/\*{1,2}Recommend:\*{1,2}\s*/,OI=/^\s*(`{3,}|~{3,})/,PI=/^\s*(?:[-*+]|\d+[.)])\s+/,jf=t=>_I(t).map(e=>e.tag);yi=(t,e)=>`[answer ${t} v${e.version}] ${RI(e)}`;II=/^\s*\*\*Time box:\*\*\s*(\S+)\s*$/m});function Wv(t){let e=[],n=new Map,r=new Map,s=[],i=[],o=[],a=[],c,l={},f,u=!1,d=0;for(let h of t){if(h.type==="cleared"){e=[],n=new Map,r=new Map,s=[],i=[],o=[],a=[],c=void 0,l={},f=void 0,u=!1;continue}let m="at"in h?h.at:void 0;if(m!==void 0&&(d=Math.max(d,m)),h.type==="user"){if(f===void 0&&!h.agent)f=m,c??=Ff(h.text),l={start:m,boxMs:c.boxMs};else{m!==void 0&&s.push(m);let g=h.agent?void 0:Ff(h.text).boxMs;(g!==void 0||u&&!h.agent)&&(l={start:m,boxMs:g})}u=!1}else if(h.type==="assistant"){m!==void 0&&i.push(m);let g=h.error?void 0:h.text.split(`
2059
+ `).find(b=>b.trim());g&&a.push({text:Bn(g,200),calls:e.length});for(let b of h.tools){let C={id:b.id,name:b.name,input:b.input,at:m,isError:!1};e.push(C),n.set(b.id,C)}}else if(h.type==="tool_result"){let g=n.get(h.id);if(!g)continue;Object.assign(g,{result:h.content,isError:h.isError,exit:h.exit,background:h.background,refused:h.refused,doneAt:m}),h.output&&(g.output=h.output),h.task&&r.set(h.task,g),m!==void 0&&i.push(m)}else if(h.type==="task_done"){let g=h.id?n.get(h.id):h.task?r.get(h.task):void 0;if(!g?.background||g.endAt!==void 0)continue;Object.assign(g,{endAt:m??d,outcome:h.outcome,output:h.output??g.output}),h.exit!==void 0&&(g.exit=h.exit),u&&m!==void 0&&(s.push(m),u=!1)}else h.type==="turn_end"&&(!u&&m!==void 0&&o.push(m),u=!0)}let p=l.start??f;return{calls:e,turnEnds:o,narration:a,lastAt:d,brief:c,boxMs:l.boxMs,runMs:Uv(e,s.filter(h=>h>(p??-1/0)),i,p,d).span,...Uv(e,s,i,f,d)}}function Uv(t,e,n,r,s){let i=r??t[0]?.at??s,o=[];for(let f of e){let u=-1/0;for(let p of n)p<=f&&p>u&&(u=p);let d=t.some(p=>p.at!==void 0&&p.at<f&&(p.doneAt??1/0)>f);u>-1/0&&!d&&f-u>=NI&&o.push([u,f])}let a=o.reduce((f,[u,d])=>f+Math.max(0,Math.min(s,d)-u),0),c=0,l=-1/0;for(let f of t.filter(u=>u.at!==void 0).sort((u,d)=>u.at-d.at)){let u=f.doneAt??s;u>l&&(c+=u-Math.max(f.at,l),l=u)}return{span:Math.max(0,s-i-a),idle:a,toolMs:c}}function Jf(t,e){if(qf(t))return;let n=Kv(t),r=t.background?t.endAt:t.doneAt,s=vi(t),i=!n&&(t.exit!==void 0?t.exit!==0&&!(t.exit===1&&s&&Qy(sa(s).rest)):t.background?t.outcome==="failed":t.isError),o=t.background?t.output?e?.(t.output)??"":"":t.result??"";return{id:t.id,at:t.at,open:n,failed:i,hidden:!n&&!i&&!!s&&Zy(s)||void 0,exit:t.exit,outcome:t.background?t.outcome:void 0,ms:t.at!==void 0&&r!==void 0?r-t.at:void 0,...LI(o)}}function LI(t){let e=Ls(t).split(`
2060
+ `).map(n=>n.trim()).filter(n=>/[\p{L}\p{N}]/u.test(n));return/^exit(?: code)?:? \d+$/i.test(e[0]??"")&&e.shift(),{first:Bn(e[0]??"",120),last:e.length>1?Bn(e.at(-1),120):""}}function BI(t,e,n=wi){let r=new Map,s=0;for(let o of t.calls){let a=vi(o),c=a&&Jf(o,e);if(!c)continue;let l=Jv(a).trim();if(Xy(l)){s++;continue}r.set(l,[...r.get(l)??[],c])}let i=[...r].map(([o,a])=>{let c=0;for(let u of a.filter(d=>!d.open&&!d.hidden).reverse()){if(!u.failed)break;c++}let l=Fs(o),f=[MI.test(l)?"stops a process":"",DI.test(l)?"git write":""].filter(Boolean);return{cmd:Bn(ld(o),100),runs:a.length,open:a.filter(u=>u.open).length,failed:a.filter(u=>u.failed).length,hidden:a.filter(u=>u.hidden).length,streak:c,long:a.some(u=>(u.ms??0)>n)?`over ${n%6e4?`${Math.round(n/1e3)}s`:ne(n)}`:"",ms:a.reduce((u,d)=>u+(d.ms??0),0),tags:f,latest:a.at(-1)}}).sort((o,a)=>(a.latest.at??0)-(o.latest.at??0));return{runs:i.reduce((o,a)=>o+a.runs,0),failed:i.reduce((o,a)=>o+a.failed,0),lookups:s,groups:i}}function JI(t){let e=t.filter(Boolean),n=e.slice(Math.max(0,e.map(qI).lastIndexOf(!0)));if(n.some(s=>s.includes("$")||/^~|^-$/.test(s)))return;let r=[];for(let s of n.join("/").split("/"))s===".."&&r.length&&!/^(\.\.|[a-zA-Z]:)?$/.test(r.at(-1))?r.pop():s!=="."&&(s||!r.length)&&r.push(s);return r.join("/")}function Hv(t,e){let n=new Map,r=[],s=[],i=[],o=l=>l.trim().replace(/^["']|["']$/g,"").replace(/\\/g,"/").replace(/^\/([a-zA-Z])\//,"$1:/"),a=l=>{let f=My(o(l),e).replace(/^\.\//,"");return!f||/^([a-zA-Z]:)?\//.test(f)?void 0:f},c=l=>a(l)??(o(l)||void 0);for(let l of t.calls){if(l.isError||l.result===void 0)continue;let f=l.doneAt??l.at??0,u=(O,_={},x=!1)=>{let M=a(O);if(!M)return;let F=n.get(M)??{path:M};F.deleted=_.deleted,_.from&&(F.from=_.from),n.set(M,F),r.push({path:M,at:f,whole:x})},d=(O,_)=>{let x=a(O),M=x?n.get(x):void 0;x&&(n.delete(x),r.push({path:x,at:f})),u(_,{from:M?.from??x})},p=l.input??{},h=!1;for(let[O,_]of Object.entries(p)){if(O==="command"||O==="cmd"||typeof _!="string"||!/^(---|\+\+\+) /m.test(_))continue;let x;for(let M of _.split(`
2061
+ `)){let F=/^(---|\+\+\+) (?:[ab]\/)?(.+?)\s*$/.exec(M);if(F?.[1]==="---"){x=F[2];continue}if(F?.[1]==="+++"){h=!0,F[2]==="/dev/null"?x&&x!=="/dev/null"&&u(x,{deleted:!0}):u(F[2]);continue}let ee=/^\*\*\* Move to: (.+?)\s*$/.exec(M);ee&&x&&d(x,ee[1])}}let m=te(p.file_path)??te(p.filePath)??te(p.path),g=UI.some(O=>O in p);!h&&m&&g&&u(m,{},typeof p.content=="string");let b=te(p.file_path)??te(p.filePath);if(b&&!g&&!h){let O=c(b);O&&s.push({path:O,at:f})}let C=O=>Object.entries(p).filter(([_,x])=>typeof x=="string"&&(_===O||_.startsWith(`${O} (`))).map(([,_])=>_);if(l.name==="read")for(let O of C("path")){let _=c(O);_&&s.push({path:_,at:f})}let T=te(p.workdir),E=O=>{let{dirs:_,rest:x}=sa(O);return{rest:x,at:M=>JI([e,T??"",..._,M].map(o))}};for(let O of[...C("command"),...C("cmd")]){let _=E(O);for(let x of nb(_.rest)){let M=_.at(x),F=M&&c(M);F&&i.push({path:F,at:f})}}let R=vi(l);if(R){let O=E(R);for(let _ of eb(O.rest)){let x=O.at(_.from),M=_.to&&O.at(_.to);x&&M?d(x,M):x&&!_.to&&u(x,{deleted:!0})}}}return{edited:[...n.values()],writes:r,reads:s,shellReads:i}}function zv(t){let e=new Map;for(let s of t)for(let i of s.writes)e.set(i.path,[...e.get(i.path)??[],{id:s.id,at:i.at,whole:i.whole}]);let n=new Map,r=new Map;for(let[s,i]of e){i.sort((a,c)=>a.at-c.at);let o=new Map;for(let a of i)o.set(a.id,a.at);n.set(s,[...o].map(([a,c])=>({id:a,at:c})).sort((a,c)=>a.at-c.at)),i.forEach((a,c)=>{if(!a.whole)return;let l=i.slice(0,c).reverse().find(d=>d.id!==a.id);if(!l)return;let f=t.find(d=>d.id===a.id);[...f.reads,...f.writes].some(d=>d.path===s&&d.at>l.at&&d.at<a.at)||r.set(`${s}
2059
2062
  ${a.id}
2060
- ${c.id}`,{path:s,by:a.id,over:c.id,at:a.at,overAt:c.at})})}return{writers:n,blind:[...r.values()]}}function Nv(t,e,n,r,s,i,o,a=Df,l=hi){let c=b=>`"${s.get(b)??b}"`,f=e.calls.filter(b=>!Lf(b)&&Rv(b)).map(b=>({id:b.id,label:Nf(b),short:Mn(Z(b.input?.description)??"",80)||Nf(b),at:b.at,background:!!b.background,interrupted:!i||t.liveSince!==void 0&&(b.at??0)<t.liveSince,said:EI(Mf(b,o))})),d=new Map;for(let b of[...n.reads,...n.shellReads].sort((C,T)=>C.at-T.at)){let C=d.get(b.path)??{path:b.path,times:0,at:0};d.delete(b.path),d.set(b.path,{...C,times:C.times+1,at:Math.max(C.at,b.at)})}let u=t.state==="running"&&!f.length?e.calls.filter(b=>!Lf(b)).at(-1):void 0,p=u&&Mf(u),h=ol(t),m=h==="done"?"finished":h,g=m==="finished"&&e.narration.at(-1)?.calls===e.calls.length;return{id:t.id,name:Tt(t),state:m,asOf:e.lastAt,activeMs:e.span,idleMs:e.idle,toolMs:e.toolMs,open:f,commands:cI(rI(e,o,l),f),files:n.edited.map(b=>{let C=a.since(b.path);return{...b,committed:!a.ignored(b.path)&&!a.uncommitted(b.path),ignored:a.ignored(b.path),also:(r.writers.get(b.path)??[]).filter(T=>T.id!==t.id&&T.at>C).map(T=>({name:s.get(T.id)??T.id,at:T.at})),blind:r.blind.filter(T=>T.path===b.path&&(T.by===t.id||T.over===t.id)&&T.overAt>C).map(T=>T.by===t.id?`\u26A0 written at ${Dr(T.at)} over ${c(T.over)}'s ${Dr(T.overAt)} write without reading it`:`\u26A0 ${c(T.by)} wrote over this agent's ${Dr(T.overAt)} write at ${Dr(T.at)} without reading it`)}}),read:[...d.values()].sort((b,C)=>b.at-C.at),narration:(g?e.narration.slice(0,-1):e.narration).map(b=>b.text),latest:u&&p?{id:u.id,label:Nf(u),run:p}:void 0}}function cI(t,e){let n=new Set(e.filter(r=>r.interrupted).map(r=>r.id));return{...t,groups:t.groups.map(r=>n.has(r.latest.id)?{...r,latest:{...r.latest,interrupted:!0}}:r)}}function Mv(t,e){let n=t.state==="finished"?Br(t).filter(r=>r.background):[];return n.length?`finished, background call running ${fe(e-(n[0].at??e))}${n.length>1?` (+${n.length-1} more)`:""}`:t.state}function hI(t,e){if(!t.open.length)return[`Now: ${pI(t,e)}`,...t.latest?[`Latest: ${t.latest.label} \xB7 ${Fv(t.latest.run)}${t.latest.run.ms!==void 0?` after ${fe(t.latest.run.ms)}`:""}`]:[]];let n=(r,s)=>r.said?[`${s}"${r.said}"`]:[];return t.open.length===1?[`Now: ${Ov(t.open[0],e)}`,...n(t.open[0]," ")]:["Now:",...t.open.flatMap(r=>[` ${Ov(r,e)}`,...n(r," ")])]}function mI(t,e){let n=t.latest;return`latest: ${n.interrupted?"interrupted":n.open?`running ${fe(e-(n.at??e))}`:`${Fv(n)}${n.ms!==void 0?` after ${fe(n.ms)}`:""}`}${t.streak>=2?`, failed ${t.streak} in a row`:""}`}function Dv(t,e){let n=[`Sub-agent "${t.name}" (${t.id}): ${fI(t,e)}${t.asOf?` \xB7 as of ${Dr(t.asOf)}`:""}`,""];n.push(...hI(t,e));let r=t.commands;n.push(`Commands: ${sI(r)}`);let{shown:s,more:i}=vI(r);for(let l of s){let c=xI(l);n.push(` ${l.cmd} \xD7${l.runs}${l.failed?`, ${l.failed} failed`:""}${c?` \xB7 ${c}`:""}`,` ${mI(l,e)}`);let f=[l.latest.first,l.latest.last].filter(Boolean).map(d=>`"${d}"`).join(" \u2026 ");f&&n.push(` ${f}`)}i&&n.push(` ${SI(i)}`),jv(r).runs&&n.push(` ${kI(r)}`),t.activeMs&&n.push(`Time: ${bI(t,e)}`),t.narration.length&&n.push("Narration:",...t.narration.map(l=>` ${l}`)),n.push(`Files written: ${gI(t)}`);for(let l of t.files){let c=l.also.length?` also ${wI(l)}`:"";n.push(` ${AI(l)}${l.ignored?" (ignored)":l.committed?" (committed)":""}${c}`,...l.blind.map(f=>` ${f}`))}let{shown:o,earlier:a}=CI(t);return n.push(`Files read: ${t.read.length||"none"}`,...a?[` +${a} earlier`]:[],...o.map(l=>` ${TI(l)}`)),n.join(`
2061
- `)}function yI(t,e){let n=t.toolMs+(Br(t).some(r=>!r.background)?Lv(t,e):0);return{tools:n,model:Math.max(0,Bf(t,e)-n)}}function Uv(t,e,n,r){let s=e.filter(pi).length,i=Math.max(0,...e.map(u=>u.asOf)),o=[s?`Session ${t}: ${s} of ${e.length} agents running.`:`Session ${t}: No agent running for ${fe(r-i)} (${e.length} agents).`];if(n.length){o.push("","Files to check before git add:");for(let u of n)o.push(` ${u.path} ${u.writers.map(p=>`"${p.name}"${p.running?" (running)":p.stopped?" (stopped)":""}`).join(", ")}${u.blind.length?" \u26A0":""}`)}o.push("","Agents:");let a=e.filter(u=>pi(u)||u.state==="failing"||n.some(p=>p.writers.some(h=>h.id===u.id))),l=new Set(a.map(u=>u.id));for(let u of a){let p=Br(u)[0],h=u.state==="finished"?Br(u).filter(E=>E.background):[],m=Mv(u,r).padEnd(8),g=h.length?h[0].short:p?`waiting ${fe(r-(p.at??r))} on ${p.short}`:"",b=uI(u),C=[g,b>=2?`failed ${b} in a row`:"",n.some(E=>E.blind.includes(u.id))?"\u26A0":""].filter(Boolean),T=u.parentId&&l.has(u.parentId)?" ".repeat(Math.max(0,u.depth-1)):"";o.push(` ${T}${u.id} ${m} ${`${fe(Bf(u,r))} active`.padStart(10)} ${u.name}${C.length?` \xB7 ${C.join(" \xB7 ")}`:""}`)}let c=e.filter(u=>!l.has(u.id)),f=c.filter(u=>u.state==="stopped").length,d=[c.length-f?`${c.length-f} finished`:"",f?`${f} stopped`:""].filter(Boolean).join(", ");return c.length&&o.push(` ${a.length?"+":""}${d}, nothing to check`),o.push("","Run `typebulb status <id>` for one agent's report, or `typebulb babysit` in the background to be woken when an agent needs attention."),o.join(`
2062
- `)}function qv(t,e,n=!1,r=hi){let s=new Map,i=a=>`"${t.find(l=>l.id===a)?.name??a}"`,o=Math.max(0,...t.map(a=>a.asOf));t.length&&!n&&!t.some(pi)&&e-o>=OI&&s.set("idle",`No agent running for ${fe(e-o)} (${t.length} agents).`);for(let a of t){for(let l of Br(a).filter(c=>e-(c.at??e)>=r)){let c=a.state==="finished"&&l.background;s.set(`${c?"background":"slow"}:${l.id}`,`${i(a.id)}: ${c?"finished, background call":"call"} running ${fe(e-(l.at??e))}: ${l.short}`)}for(let l of a.commands.groups.filter(c=>c.streak>=2))s.set(`streak:${a.id}:${l.cmd}`,`${i(a.id)}: failed ${l.streak} in a row: ${l.cmd}`)}return s}var QR,Tv,Cv,hi,Mn,Pv,mi,Dr,Nf,Rv,Lf,tI,nI,sI,iI,oI,aI,Df,Br,pi,uI,Lv,Bf,dI,fI,Ov,pI,gI,bI,wI,Bv,vI,SI,jv,kI,xI,EI,Fv,AI,TI,CI,OI,dl=S(()=>{"use strict";Mr();_s();sd();QR=6e4,Tv=8,Cv=30,hi=3*6e4,Mn=(t,e)=>(t=Ps(t).replace(/\s+/g," ").trim(),t.length>e?t.slice(0,e)+"\u2026":t),Pv=t=>Xo(t).rest,mi=t=>Z(t.input?.command)??Z(t.input?.cmd),Dr=t=>new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),Nf=t=>{let e=mi(t);if(e)return Mn(rd(Pv(e).trim()),100);let n=Mn(Oy(t.input),80);return n?`${Gu(t.name)}: ${n}`:Gu(t.name)};Rv=t=>t.result===void 0||!!t.background&&t.endAt===void 0,Lf=t=>!!t.refused&&mi(t)!==void 0;tI=/(^|[\s;|&(])(kill|pkill|killall|taskkill|stop-process)\b/i,nI=/\bgit\s+(-C\s+\S+\s+)?(commit|stash|checkout|reset|push|clean|restore|rebase|merge|cherry-pick|revert)(?![\w-])/;sI=t=>[t.runs?`${t.runs} run, ${t.failed} failed`:"",iI(t)].filter(Boolean).join(", ")||"none",iI=t=>t.lookups?`${t.lookups} ${t.lookups===1?"lookup":"lookups"}`:"",oI=["content","diff","new_string","new_source","edits"],aI=t=>/^([a-zA-Z]:)?\//.test(t);Df={uncommitted:()=>!0,ignored:()=>!1,since:()=>0};Br=t=>t.open.filter(e=>!e.interrupted),pi=t=>t.state==="running"||Br(t).length>0,uI=t=>Math.max(0,...t.commands.groups.map(e=>e.streak)),Lv=(t,e)=>t.state==="running"?Math.max(0,e-t.asOf):0,Bf=(t,e)=>t.activeMs+Lv(t,e);dI=(t,e)=>({state:Mv(t,e),active:`${fe(Bf(t,e))} active`,idle:t.idleMs?`${fe(t.idleMs)} idle`:""}),fI=(t,e)=>{let n=dI(t,e);return[n.state,n.active,n.idle].filter(Boolean).join(" \xB7 ")},Ov=(t,e)=>t.interrupted?`${t.label}: interrupted, its process has ended`:`${t.label}, ${fe(e-(t.at??e))}${t.background?" (background)":""}`,pI=(t,e)=>`nothing open, last entry ${fe(e-t.asOf)} ago`;gI=t=>{let e=t.files.filter(n=>!n.committed&&!n.ignored).length;return t.files.length?`${t.files.length} (${e} uncommitted)`:"none"};bI=(t,e)=>{let n=yI(t,e);return`${fe(n.tools)} in tools, ${fe(n.model)} in the model`},wI=t=>t.also.map(e=>`"${e.name}" ${Dr(e.at)}`).join(", "),Bv=t=>t.failed>0||!!t.long||t.runs>=3||t.tags.length>0,vI=t=>{let e=t.groups.filter(Bv);return{shown:e.slice(0,Tv),more:Math.max(0,e.length-Tv)}},SI=t=>`+${t} more like these`,jv=t=>{let e=t.groups.filter(n=>!Bv(n));return{runs:e.reduce((n,r)=>n+r.runs-r.open,0),hidden:e.reduce((n,r)=>n+r.hidden,0),ms:e.reduce((n,r)=>n+r.ms,0)}},kI=(t,e=!0)=>{let n=jv(t),r=n.runs-n.hidden,s=e?" other":"",i=l=>l===1?"run":"runs",o=`with ${n.hidden===1?"its":"their"} exit hidden by a pipe`;return`${r?`${r}${s} ${i(r)} passed${n.hidden?`, ${n.hidden} ${o}`:""}`:`${n.hidden}${s} ${i(n.hidden)} ${o}`}, ${fe(n.ms)} in all`},xI=t=>[...t.tags,t.long].filter(Boolean).join(", "),EI=t=>t?t.last||t.first:"",Fv=t=>t.hidden?"exit hidden":t.outcome&&t.outcome!=="completed"&&t.outcome!=="failed"&&t.exit===void 0?t.outcome:t.exit!==void 0?`exit ${t.exit}`:t.failed?"error":"ok",AI=t=>t.deleted?`${t.path} (deleted)`:t.from?`${t.path} (moved from ${t.from})`:t.path,TI=t=>t.times>1?`${t.path} \xD7${t.times}`:t.path,CI=t=>({shown:t.read.slice(-Cv),earlier:Math.max(0,t.read.length-Cv)});OI=5*6e4});import{openSync as PI,readSync as _I,closeSync as RI,fstatSync as II,statSync as $I,readFileSync as NI,writeFileSync as LI,mkdirSync as MI}from"fs";import{join as Jv}from"path";function*hl(t,e){if(!t.listChildren)return;let n=t.callerSessionId?.(e),r=fi(t.listSessionFiles(e),s=>s.mtime).sort((s,i)=>+(i.sessionId===n)-+(s.sessionId===n));for(let s of r){let i=t.listChildren(e,s.sessionId);i.length&&(yield Wv(t,e,s.sessionId,s.file,i))}}function Wv(t,e,n,r,s){let i=ul(t,n,e,r);return{sessionId:n,live:i,children:s.map(o=>({...o,state:di(o,i)}))}}function gi(t,e){let n=t.callerSessionId?.(e);return{sessionId:n,cwd:n&&t.sessionCwd?.(n)||e}}function Kv(t,e){let n=gi(t,e);return n.sessionId?n:{sessionId:hl(t,e).next().value?.sessionId,cwd:e}}function ml(t,e,n){let r=t.listSessionFiles(e).find(s=>s.sessionId===n)?.file;return Wv(t,e,n,r,t.listChildren?.(e,n)??[])}function Hv(t,e){let n=e.trim().toLowerCase(),r=t.children.filter(s=>s.id.toLowerCase()===n);return r.length?r:t.children.filter(s=>s.id.toLowerCase().startsWith(n)||Tt(s).toLowerCase().includes(n))}function en(t,e){let n=Jv(Re(),"slow",t);if(e)try{MI(Jv(n,".."),{recursive:!0}),LI(n,String(e))}catch{}let r=0;try{r=Number(NI(n,"utf8"))}catch{}return e||r||hi}function DI(t,e,n){let r={size:-1,mtimeMs:-1};try{r=$I(e)}catch{}let s=pl.get(e);if(s&&s.size===r.size&&s.mtime===r.mtimeMs&&s.cwd===n)return s;let i=_v(Ev(t,e,"child")),o={size:r.size,mtime:r.mtimeMs,cwd:n,d:i,touches:Iv(i,n)};return pl.set(e,o),o}function BI(t){let e;try{e=PI(t,"r")}catch{return}try{let n=II(e).size,r=(s,i)=>{let o=Buffer.alloc(i);return o.subarray(0,_I(e,o,0,i,s)).toString("utf8")};return n<=2*fl?r(0,n):`${r(0,fl)}
2063
- ${r(n-fl,fl)}`}catch{return}finally{RI(e)}}async function Dn(t,e,n,r){let s=Av([...n.children].sort((u,p)=>(u.started??u.mtime)-(p.started??p.mtime))),i=en(n.sessionId),o=s.map(u=>DI(t,u.file,e)),a=new Set(s.map(u=>u.file));for(let u of pl.keys())a.has(u)||pl.delete(u);let l=$v(s.map((u,p)=>({id:u.id,writes:o[p].touches.writes,reads:o[p].touches.reads}))),c=await FI(e,Math.min(1/0,...[...l.writers.values()].flat().map(u=>u.at)),[...l.writers.keys()]),f=new Map(s.map(u=>[u.id,Tt(u)])),d=s.flatMap((u,p)=>r&&u.id!==r?[]:[{...Nv(u,o[p].d,o[p].touches,l,f,n.live,BI,c,i),depth:u.depth,parentId:u.parentId}]);return{reports:d,files:r?[]:jI(d,l,c)}}function jI(t,e,n){let r=new Set(t.filter(pi).map(a=>a.id)),s=new Set(t.filter(a=>a.state==="stopped").map(a=>a.id)),i=new Map(t.map(a=>[a.id,a.name]));return[...e.writers].filter(([a])=>n.uncommitted(a)).map(([a,l])=>{let c=n.since(a),f=l.filter(u=>u.at>c);if(f.length<2&&!f.some(u=>r.has(u.id)||s.has(u.id)))return;let d=e.blind.filter(u=>u.path===a&&u.overAt>c).flatMap(u=>[u.by,u.over]);return{path:a,writers:f.map(u=>({id:u.id,name:i.get(u.id)??u.id,running:r.has(u.id),stopped:s.has(u.id)})),blind:[...new Set(d)]}}).filter(a=>!!a).sort((a,l)=>a.path.localeCompare(l.path))}async function FI(t,e,n){let r=s=>process.platform==="win32"?s.toLowerCase():s;try{let s=(await we(["rev-parse","--show-prefix"],t)).trim(),i=d=>d.startsWith(s)?r(d.slice(s.length)):void 0,o=await we(["status","--porcelain","-z","--untracked-files=all"],t),a=new Set,l=o.split("\0");for(let d=0;d<l.length;d++){let u=l[d];if(u.length<4)continue;(u[0]==="R"||u[0]==="C")&&d++;let p=i(u.slice(3));p&&a.add(p)}let c=new Map;if(Number.isFinite(e)){let d=0;for(let u of(await we(["log",`--since=${new Date(e).toISOString()}`,"--format=@%ct","--name-only","--","."],t)).split(`
2064
- `)){if(u.startsWith("@")){d=Number(u.slice(1))*1e3;continue}let p=u.trim()&&i(u.trim());p&&!c.has(p)&&c.set(p,d)}}let f=new Set(n.length?(await we(["check-ignore","--",...n],t).catch(()=>"")).split(`
2065
- `).map(d=>r(d.trim())).filter(Boolean):[]);return{uncommitted:d=>a.has(r(d)),ignored:d=>f.has(r(d)),since:d=>c.get(r(d))??0}}catch{return Df}}var pl,fl,gl=S(()=>{"use strict";Lr();If();Mr();$f();dl();$n();pl=new Map;fl=4096});import{existsSync as zv,openSync as UI,readSync as qI,closeSync as JI,statSync as yi,readdirSync as Yv,watchFile as WI,unwatchFile as Vv,mkdirSync as KI,writeFileSync as HI,readFileSync as jf,unlinkSync as zI,rmSync as YI}from"fs";import{stat as VI}from"fs/promises";import{dirname as GI,join as Bn,resolve as Gv}from"path";function e$(t){if(!Number.isInteger(t))return!0;try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}function jr(t){let e={cwd:X,sessionId:"",sessionStartMs:Date.now(),buffer:[],partial:"",offset:0,latest:{in:0,out:0,cached:0,cacheCreate:0},latestModel:null,everAttached:!1,index:cl(t),thread:"main"},n;function r(y,x){let v={offset:x,text:""},_;try{_=yi(y).size}catch{return v}if(_<=x)return v;let N;try{N=UI(y,"r")}catch{return v}try{let q=_-x,B=Buffer.alloc(q),z=0;for(;z<q;){let ee=qI(N,B,z,q-z,x+z);if(!ee)break;z+=ee}return{offset:x+z,text:B.subarray(0,z).toString("utf8")}}finally{JI(N)}}let s=new Set,i,o=0;function a(){if(e.file){for(let y of s)if(y.file===e.file)return y;return}return i}function l(y){let x={d:t.createDriver(e.cwd,y),file:y,id:`new:${++o}`,startedAt:Date.now()};return s.add(x),e.file||(i=x),x}function c(){let y=[...s].filter(v=>v.file);if(!y.length)return[];let x=new Map(t.listSessionFiles(e.cwd).map(v=>[v.file,v.sessionId]));return y.map(v=>{let _=x.get(v.file);return{rec:v,sessionId:_??v.id,pending:_===void 0}})}let f=()=>c().filter(y=>y.pending&&y.rec.prompt!==void 0);async function d(y){s.delete(y),i===y&&(i=void 0);try{await y.d.dispose()}catch(x){console.error("[composer] dispose:",V(x))}}function u(){let y=a(),x=new Set(f().map(v=>v.rec));for(let v of[...s])v!==y&&(x.has(v)||v.d.streaming||v.d.queue||v.d.error||d(v))}function p(){for(let y of s)y.d.sessionFile&&y.file!==y.d.sessionFile&&(y.file=y.d.sessionFile);if(i&&!e.file&&i.file){let y=t.listSessionFiles(e.cwd).find(x=>x.file===i.file);y&&j(y)}i&&!e.file&&i.prompt!==void 0&&e.sessionId!==i.id&&(L(void 0,i.id),e.everAttached=!0)}let h=y=>Bn(y,QI),m=(y,x)=>Bn(h(y),`${x}.lock`);function g(y,x){try{let v=m(y,x);if(Date.now()-yi(v).mtimeMs>=Xv)return!1;try{let _=parseInt(jf(v,"utf8").trim(),10);if(_===process.pid||!e$(_))return!1}catch{}return!0}catch{return!1}}function b(y,x){if(x)try{KI(h(y),{recursive:!0}),HI(m(y,x),String(process.pid))}catch(v){console.error("[lock] claim failed:",V(v))}}function C(y){try{YI(Bn(y,".claude-bulb"),{recursive:!0,force:!0})}catch{}}function T(y){let x=h(y);if(!zv(x))return;let v;try{v=Yv(x)}catch{return}let _=Date.now();for(let N of v){if(!N.endsWith(".lock"))continue;let q=Bn(x,N);try{let B=yi(q);_-B.mtimeMs>ZI&&zI(q)}catch{}}}function E(y){try{return yi(y),!1}catch(x){return x.code==="ENOENT"}}function $(){let y=e;if(y.file&&!E(y.file)){b(y.cwd,y.sessionId);return}let x=O(y);x&&j(x)}function O(y){if(!y.everAttached)return P(y.cwd)??k(y.cwd,()=>!0)}function P(y){let x=h(y);if(!zv(x))return;let v;try{v=Yv(x)}catch{return}let _;for(let q of v)if(q.endsWith(".lock"))try{let B=yi(Bn(x,q));if(Date.now()-B.mtimeMs>=Xv||parseInt(jf(Bn(x,q),"utf8").trim(),10)!==process.pid)continue;(!_||B.mtimeMs>_.mtime)&&(_={sessionId:q.slice(0,-5),mtime:B.mtimeMs})}catch{}if(!_)return;let N=t.listSessionFiles(y).find(q=>q.sessionId===_.sessionId);if(!(!N||E(N.file)))return N}function k(y,x){return t.listSessionFiles(y).sort((v,_)=>_.mtime-v.mtime).find(v=>!g(y,v.sessionId)&&x(v))}function L(y,x){let v=e;if(v.file)try{Vv(v.file)}catch{}v.file=y,v.sessionId=x,v.partial="",v.offset=0,v.latest={in:0,out:0,cached:0,cacheCreate:0},v.latestModel=null,v.index=cl(t),v.chainLastId=void 0,v.buffer.push({type:"cleared"}),v.buffer.push({type:"session",sessionId:x})}function j(y){let x=e;i=void 0,$i(),n=y.file,L(y.file,y.sessionId),x.everAttached=!0,b(x.cwd,y.sessionId),Q(y.file)}function Q(y){if(ie(),!!y){try{Vv(y)}catch{}WI(y,{interval:200},()=>ie())}}function U(){$i(),n=void 0,L(void 0,"")}function ie(){let y=e;if(!y.file)return;let x=r(y.file,y.offset);if(!x.text)return;y.offset=x.offset,y.partial+=x.text;let v=y.partial.lastIndexOf(`
2066
- `);if(v<0)return;let _=y.index.add(y.partial.slice(0,v).split(`
2067
- `),y.thread);if(y.partial=y.partial.slice(v+1),!_)return;let N=[],{entries:q}=y.index,B=q.get(_),z=!1;for(;B;){if(N.push(B),t.idOf(B)===y.chainLastId){z=!0;break}let ee=t.parentOf(B);B=ee?q.get(ee):void 0}if(z)for(let ee=N.length-2;ee>=0;ee--)ae(N[ee]);else{y.chainLastId!==void 0&&(y.buffer.push({type:"cleared"}),y.buffer.push({type:"session",sessionId:y.sessionId}),y.latest={in:0,out:0,cached:0,cacheCreate:0});let ee=new Set(N.map(He=>t.idOf(He))),ft=oe(q);for(let He=N.length-1;He>=0;He--)ae(N[He]),ge(t.idOf(N[He]),ft,ee)}y.chainLastId=_}function oe(y){let x=new Map;for(let v of y.values()){let _=t.parentOf(v);if(!_)continue;let N=x.get(_);N?N.push(v):x.set(_,[v])}return x}function ge(y,x,v){if(!y)return;let _=x.get(y);if(!_)return;let N=_.filter(ee=>!t.isSidechain(ee,e.thread));if(N.length<2)return;let q=N.filter(ee=>!v.has(t.idOf(ee)));if(!q.length)return;let B=[],z=0;for(let ee of q){let ft=Se(ee,x);B.push(...ft.events),z+=ft.count}z>0&&e.buffer.push({type:"fork",atId:y,count:z,events:B})}function Se(y,x){let v=[],_=[y];for(;_.length;){let B=_.pop();if(t.isSidechain(B,e.thread))continue;v.push(B);let z=x.get(t.idOf(B)??"");if(z)for(let ee of z)_.push(ee)}v.sort((B,z)=>(Date.parse(t.timestampOf(B)??"")||0)-(Date.parse(t.timestampOf(z)??"")||0));let N=[];for(let B of v)t.isRecoveryNoise(B)||N.push(...ll(t,B,e.thread,e.sessionStartMs).events);return{count:N.reduce((B,z)=>B+(z.type==="user"||z.type==="assistant"?1:0),0),events:N}}function ae(y){if(!t.isSidechain(y,e.thread))try{let{events:x,usage:v,model:_,cost:N}=ll(t,y,e.thread,e.sessionStartMs);for(let q of x)e.buffer.push(q);x.some(q=>q.type==="assistant")&&a()?.d.clearCompletedDraft(),x.some(q=>q.type==="user")&&a()?.d.clearEcho(),_&&(e.latestModel=_),v&&(e.latest=v),(v||N)&&e.buffer.push({type:"usage",...e.latest,cost:N})}catch(x){console.error("[mirror] skipped malformed entry:",V(x))}}async function ke(){return{cwd:e.cwd,pid:process.pid,composer:!!t.createDriver,children:!!t.listChildren,elsewhere:await _t()}}async function _t(){if(t.listSessionFiles(e.cwd).length)return;let y=await Ln();if(!y)return;let x=Gv(y).toLowerCase();for(let v=Gv(e.cwd);v.toLowerCase()!==x;){let _=GI(v);if(_===v)return;v=_;let N=t.listSessionFiles(v).length;if(N)return{dir:v,count:N}}}_t().then(y=>{y&&console.log(`No sessions for ${e.cwd} \u2014 ${y.count} exist for ${y.dir}. Launched from a subfolder? Relaunch from the project root.`)}).catch(()=>{});let w=new tl;async function A(y,x){e.thread!=="child"&&w.accept(y,x)&&console.log(x)}function R(){return ul(t,e.sessionId,e.cwd,e.file)}function M(){return t.chainWorking([...e.index.entries.values()])&&R()}function D(){!t.createDriver||a()||e.latestModel||M()||l(e.file)}async function K(y){let x=e;$(),p(),D(),u();let v=a();for(let B of s)B!==v&&B.d.dialog;let _=c().filter(B=>B.rec.d.streaming).map(B=>B.sessionId),N=M(),q=t.createDriver?{streaming:!!v?.d.streaming,foreign:!v&&N,draft:v?.d.draft??null,echo:v?.d.echo??null,status:v?.d.status??null,dialog:v?.d.dialog??null,queue:v?.d.queue??null,stats:v?.d.stats??null,model:v?.d.model??null,error:v?.d.error}:void 0;return{events:x.buffer.slice(y),cursor:x.buffer.length,working:!!v?.d.streaming||N,latestModel:x.latestModel,child:x.child?.id??null,composer:q,busy:_}}async function J(){$(),p();let y=a();if(y?.d.error&&!y.d.streaming&&(await d(y),y=void 0),!y){if(M())return{ok:!1,error:"the agent is mid-turn in a terminal \u2014 watch only"};y=l(e.file)}let x=y;return{ok:!0,d:x.d,markSent:v=>{x.prompt===void 0&&(x.prompt=v)}}}async function Ke(y,x){if(!t.createDriver)return{ok:!1,error:"not supported"};let v=String(y??"").trim();if(!v)return{ok:!1,error:"empty message"};let _=await J();if(!_.ok)return _;let N=await _.d.send(v,x);return N.ok&&_.markSent(v),N}async function Y(y,x){let v=a();return v?v.d.respondUi(String(y??""),x??{}):{ok:!1,error:"no dialog pending"}}async function ue(y,x){if(!t.createDriver)return{ok:!1,error:"not supported"};if(!y||typeof y.type!="string")return{ok:!1,error:"bad command"};if(x?.spawn){let _=await J();return _.ok?_.d.rpc(y):_}let v=a();return!v||v.d.error?{ok:!1,error:"not running"}:v.d.rpc(y)}async function Pe(){let y=a();if(y)try{await y.d.stop()}catch(x){console.error("[composer] stop:",V(x))}return{ok:!0}}async function Hr(){return t.createDriver?(p(),!e.file&&i&&i.prompt===void 0&&!i.d.streaming&&!i.d.error?{ok:!0}:(i?.d.error&&await d(i),i=void 0,U(),l(void 0),u(),{ok:!0})):{ok:!1,error:"not supported"}}async function ln(){if(!t.createDriver)return[];let y=await we(["ls-files","--cached","--others","--exclude-standard"],e.cwd).catch(()=>null),x=y!==null?y.split(`
2068
- `).filter(Boolean):await t.walkFiles?.(e.cwd)??[];return(await Promise.all(x.map(async _=>{try{return{f:_,m:(await VI(Bn(e.cwd,_))).mtimeMs}}catch{return{f:_,m:0}}}))).sort((_,N)=>N.m-_.m).map(_=>_.f)}function Rt(){for(let y of[...s])d(y)}async function Yl(y){return t.createDriver?yv(e.cwd,y):{ok:!1,error:"not supported"}}async function Vl(y){return bv(e.cwd,String(y??""))}async function rx(y,x){return kv(String(y??""),String(x??""))}async function sx(y){let x=t.listChildren?.(e.cwd,e.sessionId)??[],v=R(),{reports:[_]}=await Dn(t,e.cwd,{sessionId:e.sessionId,live:v,children:x.map(N=>({...N,state:di(N,v)}))},y);return _?{ok:!0,report:_}:{ok:!1,error:"child not found"}}async function ix(){let y=t.sessionsWorking?.(e.cwd),x=t.sessionNames?.(),v=t.listSessionFiles(e.cwd).map(({sessionId:N,file:q,mtime:B})=>({sessionId:N,mtime:B,preview:t.readPreview(q),working:y?.has(N),name:x?.get(N)})),_=f().map(N=>({sessionId:N.sessionId,mtime:N.rec.startedAt,preview:N.rec.prompt??"",pending:!0}));return fi([...v,..._],N=>N.mtime)}let Mp=new Map;function Dp(y,x){let v=Mp.get(y);if(v&&v.mtime===x)return v.turns;let _=[],N="";try{N=jf(y,"utf8")}catch{return[]}for(let q of N.split(`
2069
- `)){if(!q.trim())continue;let B=t.parseEntry(q);if(!B)continue;let z=t.searchText(B);z&&_.push({text:z,lower:z.toLowerCase()})}return Mp.set(y,{mtime:x,turns:_}),_}async function ox(y){let x=y.toLowerCase(),v=[],_=0,N=t.sessionsWorking?.(e.cwd),q=t.sessionNames?.();for(let{sessionId:B,file:z,mtime:ee}of t.listSessionFiles(e.cwd).sort((ft,He)=>He.mtime-ft.mtime)){let ft=ui(Dp(z,ee),x),He=(t.listChildren?.(e.cwd,B)??[]).map(ze=>({c:ze,hit:ui(Dp(ze.file,ze.mtime),x)})).filter(ze=>ze.hit.hitCount);if(!(!ft.hitCount&&!He.length)){for(let{c:ze,hit:dx}of fi(He,fx=>fx.c.mtime))v.push({sessionId:B,mtime:ze.mtime,preview:Tt(ze),...dx,child:{id:ze.id,kind:ze.kind,depth:ze.depth}});if(v.push({sessionId:B,mtime:ee,preview:t.readPreview(z),working:N?.has(B),name:q?.get(B),...ft}),++_>=t$)break}}return v}async function ax(y){let x=e,v=t.listSessionFiles(x.cwd).find(_=>_.sessionId===y);if(!v){let _=f().find(N=>N.sessionId===y)?.rec;return _?((i!==_||x.sessionId!==_.id)&&(i=_,$i(),n=void 0,L(void 0,_.id),x.everAttached=!0,u()),{ok:!0}):{ok:!1,error:"session not found"}}return v.file===x.file?{ok:!0}:(j(v),p(),u(),{ok:!0})}async function lx(){if(!t.listChildren||!e.sessionId)return[];let y=R();return t.listChildren(e.cwd,e.sessionId).map(x=>({...x,state:di(x,y)}))}async function cx(y){let x=e;if(!t.listChildren)return{ok:!1,error:"this harness has no child transcripts"};let v=t.listChildren(x.cwd,x.sessionId).find(_=>_.id===y);return v?(x.thread="child",x.child=v,L(v.file,x.sessionId),Q(v.file),{ok:!0}):{ok:!1,error:"child not found"}}async function ux(){let y=n;return!$i()||!y?{ok:!0}:(L(y,e.sessionId),Q(y),{ok:!0})}function $i(){let y=e;return y.thread==="main"?!1:(y.thread="main",y.child=void 0,!0)}return C(e.cwd),T(e.cwd),$(),{info:ke,poll:K,logInlineStatus:A,listSessions:ix,searchSessions:ox,attach:ax,listChildren:lx,openChild:cx,closeChild:ux,composerSend:Ke,composerStop:Pe,composerNew:Hr,composerFiles:ln,composerUiRespond:Y,composerRpc:ue,composerPaste:Yl,composerPasteRead:Vl,summarizeTurn:rx,childStatus:sx,shutdownComposer:Rt}}var XI,QI,Xv,ZI,t$,yl=S(()=>{"use strict";Zt();dv();Lr();_f();wv();xv();If();gl();$f();Mr();XI=".typebulb",QI=`${XI}/locks`,Xv=5e3,ZI=6e4;t$=50});import{existsSync as Jf,mkdirSync as n$,readFileSync as Qv,writeFileSync as r$}from"fs";import{join as jn,isAbsolute as s$}from"path";async function Kf(t,e){let n=s$(t)?t:jn(X,t);return Jf(n)?(_d(n,e),{ok:!0}):{ok:!1,error:"file not found"}}async function Hf(t){let e=X,n=Pd(t),r=jn(e,"typebulbs");n$(r,{recursive:!0});let s=Ad(n),i=`${s}.bulb.md`;for(let c=2;Jf(jn(r,i))&&Qv(jn(r,i),"utf8")!==n;c++)i=`${s}-${c}.bulb.md`;let o=jn(r,i);Jf(o)||r$(o,n);let a=jn("typebulbs",i),l=await Sn(a,{cwd:e,open:!1});return{ok:!0,file:a,pid:l.pid,url:l.url}}async function zf(){return G(X)}async function Yf(t){let e=(await G()).find(n=>n.pid===t);return e?{ok:!0,outcome:await bt(e)}:(await cr(t),{ok:!0})}async function Vf(){let t=await yn(X);return ha(X).filter(e=>!e.serverOnly).map(e=>({...e,trusted:En(e.path),lastRunAt:t(e.path)}))}async function Gf(t){let e=t.toLowerCase(),n=[];for(let r of ha(X).filter(s=>!s.serverOnly).sort((s,i)=>i.mtime-s.mtime)){let s="";try{s=Qv(r.path,"utf8")}catch{continue}let i=[];for(let l of s.split(`
2070
- `)){let c=l.replace(/\s+/g," ").trim();c&&i.push({text:c,lower:c.toLowerCase()})}let{hitCount:o,snippet:a}=ui(i,e);o&&n.push({path:r.path,hitCount:o,snippet:a})}return n}async function Xf(t,e){let n=X;e!=null&&mr(t,e);let r=await Sn(t,{cwd:n,open:!1,trust:e});return{ok:!0,file:r.file,pid:r.pid,url:r.url,trust:!!r.trust}}async function Qf(t){return{cap:await Cd(t)}}async function Zf(t,e){return mr(t,e),{ok:!0}}async function ep(t,e){return Qe(t,e)}async function tp(){return bi&&Date.now()-bi.fetchedAt<=o$?bi.samples:(Ff??=a$().finally(()=>{Ff=null}),Ff)}async function a$(){try{let t=await fetch(`${i$}/api/scripts/u/samples?stubs`,{signal:AbortSignal.timeout(eS)});if(!t.ok)throw new Error(`HTTP ${t.status}`);let e=await t.json(),n=i=>i.order??Number.MAX_SAFE_INTEGER,r=i=>Date.parse(i.createdAt??"")||0,s=e.filter(i=>i.slug!=="welcome").sort((i,o)=>n(i)-n(o)||r(o)-r(i)).map(i=>({slug:i.slug,name:i.name,description:sc(i.config)}));return bi={samples:s,fetchedAt:Date.now()},s}catch{return bi?.samples??[]}}async function np(t){return Wf.test(t)?nS(Zv,"samples",t,!0):{ok:!1,error:"bad slug"}}async function sp(){let t=rp();if(!t)return{bulbs:[]};let e=`${bl()}
2071
- ${t}`;return tn?.key===e&&Date.now()-tn.fetchedAt<=l$?{user:tn.user,bulbs:tn.bulbs}:(Uf??=c$(e,t).finally(()=>{Uf=null}),Uf)}async function qf(t,e,n){let r=await fetch(`${t}${e}`,{headers:n,signal:AbortSignal.timeout(eS)});if(!r.ok)throw new Error(`HTTP ${r.status}`);if(!r.headers.get("content-type")?.includes("json"))throw new Error("not json");return r.json()}async function c$(t,e){let n={Authorization:`Bearer ${e}`};try{let r=bl(),s;try{s=await qf(r,"/api/me",n)}catch{let a=new URL(r);r=`${a.protocol}//api.${a.host}`,s=await qf(r,"/api/me",n)}let o=(await qf(r,"/api/scripts/list",n)).filter(a=>a.userSlug===s.slug&&!a.isTemplate).map(a=>({slug:a.slug,name:a.name,description:sc(a.config)}));return tn={key:t,user:s.slug,bulbs:o,fetchedAt:Date.now()},{user:s.slug,bulbs:o}}catch{return tn?.key===t?{user:tn.user,bulbs:tn.bulbs}:{bulbs:[]}}}async function ip(t,e,n=!1){return!Wf.test(e)||!Wf.test(t)?{ok:!1,error:"bad slug"}:nS(bl(),t,e,n)}async function nS(t,e,n,r){let s=Ha(e,n);try{let i=await Va({origin:t,userSlug:e,slug:n,dest:jn(X,s)},{force:r,token:rp(),timeoutMs:tS});return i.kind==="conflict"?{ok:!1,conflict:!0,error:"local file differs from the site copy"}:i.kind==="asset-conflict"?{ok:!1,conflict:!0,error:`local assets differ from the site copies (${i.paths.join(", ")})`}:i.kind==="http-error"?{ok:!1,error:`HTTP ${i.status}`}:i.kind==="not-markdown"?{ok:!1,error:`not a bulb (${i.contentType??"no content-type"})`}:{ok:!0,file:s,upToDate:i.kind==="up-to-date"}}catch(i){return{ok:!1,error:i?.message??String(i)}}}async function op(t,e=!1){let n=rp();if(!n)return{ok:!1,error:"no TYPEBULB_TOKEN in .env"};try{let r=Ya(t,X,bl()),s=await Xa(r,{token:n,force:e,timeoutMs:tS});return s.kind==="conflict"?{ok:!1,conflict:!0,error:s.message}:s.kind==="asset-error"?{ok:!1,error:`assets sync failed: ${s.message}`}:s.kind==="http-error"?{ok:!1,error:`HTTP ${s.status}: ${s.message}`}:{ok:!0,created:s.created,serverStripped:s.serverStripped}}catch(r){return{ok:!1,error:r?.message??String(r)}}}var i$,Zv,o$,eS,tS,bi,Ff,Wf,l$,tn,Uf,bl,rp,wl=S(()=>{"use strict";$n();Zt();_f();te();i$="https://api.typebulb.com",Zv="https://typebulb.com",o$=3600*1e3,eS=5e3,tS=15e3,bi=null,Ff=null;Wf=/^[a-z0-9][a-z0-9-]*$/,l$=300*1e3,tn=null,Uf=null,bl=()=>Aa("TYPEBULB_ORIGIN",X)||Zv,rp=()=>Aa("TYPEBULB_TOKEN",X)});import{readFileSync as cp,writeFileSync as sS,mkdirSync as u$,appendFileSync as iS,rmSync as rS}from"fs";import{join as kl,dirname as d$}from"path";import{createServer as f$}from"http";function nn(t){try{return JSON.parse(cp(t,"utf8"))}catch{return null}}function Sl(t,e){u$(d$(t),{recursive:!0}),sS(t,JSON.stringify(e,null,2)+`
2072
- `)}function aS(t,e,n){let r=kl(t,".gitignore"),s="";try{s=cp(r,"utf8")}catch{}let i=new Set(s.split(/\r?\n/).map(l=>l.trim())),o=e.filter(l=>!i.has(l));if(!o.length)return;let a=s&&!s.endsWith(`
2063
+ ${l.id}`,{path:s,by:a.id,over:l.id,at:a.at,overAt:l.at})})}return{writers:n,blind:[...r.values()]}}function Yv(t,e,n,r,s,i,o,a=Wf,c=wi){let l=b=>`"${s.get(b)??b}"`,f=e.calls.filter(b=>!qf(b)&&Kv(b)).map(b=>({id:b.id,label:Uf(b),short:Bn(te(b.input?.description)??"",80)||Uf(b),at:b.at,background:!!b.background,interrupted:!i||t.liveSince!==void 0&&(b.at??0)<t.liveSince,said:s$(Jf(b,o))})),u=new Map;for(let b of[...n.reads,...n.shellReads].sort((C,T)=>C.at-T.at)){let C=u.get(b.path)??{path:b.path,times:0,at:0};u.delete(b.path),u.set(b.path,{...C,times:C.times+1,at:Math.max(C.at,b.at)})}let d=t.state==="running"&&!f.length?e.calls.filter(b=>!qf(b)).at(-1):void 0,p=d&&Jf(d),h=pc(t),m=h==="done"?"finished":h,g=m==="finished"&&e.narration.at(-1)?.calls===e.calls.length;return{id:t.id,name:ft(t),state:m,asOf:e.lastAt,activeMs:e.span,idleMs:e.idle,toolMs:e.toolMs,open:f,commands:WI(BI(e,o,c),f),files:n.edited.map(b=>{let C=a.since(b.path);return{...b,committed:!a.ignored(b.path)&&!a.uncommitted(b.path),ignored:a.ignored(b.path),also:(r.writers.get(b.path)??[]).filter(T=>T.id!==t.id&&T.at>C).map(T=>({name:s.get(T.id)??T.id,at:T.at})),blind:r.blind.filter(T=>T.path===b.path&&(T.by===t.id||T.over===t.id)&&T.overAt>C).map(T=>T.by===t.id?`\u26A0 written at ${qr(T.at)} over ${l(T.over)}'s ${qr(T.overAt)} write without reading it`:`\u26A0 ${l(T.by)} wrote over this agent's ${qr(T.overAt)} write at ${qr(T.at)} without reading it`)}}),read:[...u.values()].sort((b,C)=>b.at-C.at),narration:(g?e.narration.slice(0,-1):e.narration).map(b=>b.text),latest:d&&p?{id:d.id,label:Uf(d),run:p}:void 0,brief:e.brief?.line??"",boxMs:e.boxMs,runMs:e.runMs}}function WI(t,e){let n=new Set(e.filter(r=>r.interrupted).map(r=>r.id));return{...t,groups:t.groups.map(r=>n.has(r.latest.id)?{...r,latest:{...r.latest,interrupted:!0}}:r)}}function Gv(t,e){let n=t.state==="finished"?Jr(t).filter(r=>r.background):[];return n.length?`finished, background call running ${ne(e-(n[0].at??e))}${n.length>1?` (+${n.length-1} more)`:""}`:t.state}function YI(t,e){if(!t.open.length)return[`Now: ${zI(t,e)}`,...t.latest?[`Latest: ${t.latest.label} \xB7 ${tS(t.latest.run)}${t.latest.run.ms!==void 0?` after ${ne(t.latest.run.ms)}`:""}`]:[]];let n=(r,s)=>r.said?[`${s}"${r.said}"`]:[];return t.open.length===1?[`Now: ${qv(t.open[0],e)}`,...n(t.open[0]," ")]:["Now:",...t.open.flatMap(r=>[` ${qv(r,e)}`,...n(r," ")])]}function VI(t,e){let n=t.latest;return`latest: ${n.interrupted?"interrupted":n.open?`running ${ne(e-(n.at??e))}`:`${tS(n)}${n.ms!==void 0?` after ${ne(n.ms)}`:""}`}${t.streak>=2?`, failed ${t.streak} in a row`:""}`}function Qv(t,e){let n=[`Sub-agent "${t.name}" (${t.id}): ${HI(t,e)}${t.asOf?` \xB7 as of ${qr(t.asOf)}`:""}`,""];n.push(...YI(t,e));let r=t.commands;n.push(`Commands: ${jI(r)}`);let{shown:s,more:i}=e$(r);for(let c of s){let l=r$(c);n.push(` ${c.cmd} \xD7${c.runs}${c.failed?`, ${c.failed} failed`:""}${l?` \xB7 ${l}`:""}`,` ${VI(c,e)}`);let f=[c.latest.first,c.latest.last].filter(Boolean).map(u=>`"${u}"`).join(" \u2026 ");f&&n.push(` ${f}`)}i&&n.push(` ${t$(i)}`),eS(r).runs&&n.push(` ${n$(r)}`),t.activeMs&&n.push(`Time: ${QI(t,e)}`),t.narration.length&&n.push("Narration:",...t.narration.map(c=>` ${c}`)),n.push(`Files written: ${GI(t)}`);for(let c of t.files){let l=c.also.length?` also ${ZI(c)}`:"";n.push(` ${i$(c)}${c.ignored?" (ignored)":c.committed?" (committed)":""}${l}`,...c.blind.map(f=>` ${f}`))}let{shown:o,earlier:a}=a$(t);return n.push(`Files read: ${t.read.length||"none"}`,...a?[` +${a} earlier`]:[],...o.map(c=>` ${o$(c)}`)),n.join(`
2064
+ `)}function XI(t,e){let n=t.toolMs+(Jr(t).some(r=>!r.background)?Kf(t,e):0);return{tools:n,model:Math.max(0,Hf(t,e)-n)}}function nS(t,e,n,r,s=[]){let i=e.filter(bi).length,o=Math.max(0,...e.map(p=>p.asOf)),a=[i?`Session ${t}: ${i} of ${e.length} agents running.`:`Session ${t}: No agent running for ${ne(r-o)} (${e.length} agents).`];if(s.length&&a.push("",...s),n.length){a.push("","Files to check before git add:");for(let p of n)a.push(` ${p.path} ${p.writers.map(h=>`"${h.name}"${h.running?" (running)":h.stopped?" (stopped)":""}`).join(", ")}${p.blind.length?" \u26A0":""}`)}a.push("","Agents:");let c=e.filter(p=>bi(p)||p.state==="failing"||n.some(h=>h.writers.some(m=>m.id===p.id))),l=new Set(c.map(p=>p.id));for(let p of c){let h=Jr(p)[0],m=p.state==="finished"?Jr(p).filter(R=>R.background):[],g=Gv(p,r).padEnd(8),b=m.length?m[0].short:h?`waiting ${ne(r-(h.at??r))} on ${h.short}`:"",C=KI(p),T=[b,zf(p,r)?Yf:"",C>=2?`failed ${C} in a row`:"",n.some(R=>R.blind.includes(p.id))?"\u26A0":""].filter(Boolean),E=p.parentId&&l.has(p.parentId)?" ".repeat(Math.max(0,p.depth-1)):"";a.push(` ${E}${p.id} ${g} ${`${ne(Hf(p,r))} active`.padStart(10)} ${p.name}${T.length?` \xB7 ${T.join(" \xB7 ")}`:""}`)}let f=e.filter(p=>!l.has(p.id)),u=f.filter(p=>p.state==="stopped").length,d=[f.length-u?`${f.length-u} finished`:"",u?`${u} stopped`:""].filter(Boolean).join(", ");return f.length&&a.push(` ${c.length?"+":""}${d}, nothing to check`),a.push("","Run `typebulb status <id>` for one agent's report, or `typebulb babysit` in the background to be woken when an agent or the user's answer needs you."),a.join(`
2065
+ `)}function rS(t,e,n=!1,r=wi,s=[]){let i=new Map,o=c=>`"${t.find(l=>l.id===c)?.name??c}"`,a=Math.max(0,...t.map(c=>c.asOf));t.length&&!n&&!t.some(bi)&&!s.some(c=>c.state==="open")&&e-a>=c$&&i.set("idle",`No agent running for ${ne(e-a)} (${t.length} agents).`);for(let c of s)c.state==="answered"&&i.set(`answer:${c.id}:v${c.version}:${c.answer.at}`,yi(c.id,c.answer));for(let c of t){zf(c,e)&&i.set(`late:${c.id}`,`${o(c.id)}: ${Yf}, ${Xv(c,e).active}`);for(let l of Jr(c).filter(f=>e-(f.at??e)>=r)){let f=c.state==="finished"&&l.background;i.set(`${f?"background":"slow"}:${l.id}`,`${o(c.id)}: ${f?"finished, background call":"call"} running ${ne(e-(l.at??e))}: ${l.short}`)}for(let l of c.commands.groups.filter(f=>f.streak>=2))i.set(`streak:${c.id}:${l.cmd}`,`${o(c.id)}: failed ${l.streak} in a row: ${l.cmd}`)}return i}var NI,jv,Fv,wi,Bn,Jv,vi,qr,Uf,Kv,qf,MI,DI,jI,FI,UI,qI,Wf,Jr,bi,KI,Kf,Hf,Vv,zf,Yf,Xv,HI,qv,zI,GI,QI,ZI,Zv,e$,t$,eS,n$,r$,s$,tS,i$,o$,a$,c$,bc=k(()=>{"use strict";jr();or();ud();Dn();NI=6e4,jv=8,Fv=30,wi=3*6e4,Bn=(t,e)=>(t=Ls(t).replace(/\s+/g," ").trim(),t.length>e?t.slice(0,e)+"\u2026":t),Jv=t=>sa(t).rest,vi=t=>te(t.input?.command)??te(t.input?.cmd),qr=t=>new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),Uf=t=>{let e=vi(t);if(e)return Bn(ld(Jv(e).trim()),100);let n=Bn(By(t.input),80);return n?`${nd(t.name)}: ${n}`:nd(t.name)};Kv=t=>t.result===void 0||!!t.background&&t.endAt===void 0,qf=t=>!!t.refused&&vi(t)!==void 0;MI=/(^|[\s;|&(])(kill|pkill|killall|taskkill|stop-process)\b/i,DI=/\bgit\s+(-C\s+\S+\s+)?(commit|stash|checkout|reset|push|clean|restore|rebase|merge|cherry-pick|revert)(?![\w-])/;jI=t=>[t.runs?`${t.runs} run, ${t.failed} failed`:"",FI(t)].filter(Boolean).join(", ")||"none",FI=t=>t.lookups?`${t.lookups} ${t.lookups===1?"lookup":"lookups"}`:"",UI=["content","diff","new_string","new_source","edits"],qI=t=>/^([a-zA-Z]:)?\//.test(t);Wf={uncommitted:()=>!0,ignored:()=>!1,since:()=>0};Jr=t=>t.open.filter(e=>!e.interrupted),bi=t=>t.state==="running"||Jr(t).length>0,KI=t=>Math.max(0,...t.commands.groups.map(e=>e.streak)),Kf=(t,e)=>t.state==="running"?Math.max(0,e-t.asOf):0,Hf=(t,e)=>t.activeMs+Kf(t,e),Vv=(t,e)=>t.runMs+Kf(t,e),zf=(t,e)=>t.state==="running"&&t.boxMs!==void 0&&Vv(t,e)>t.boxMs,Yf="past its time box";Xv=(t,e)=>({state:Gv(t,e),active:`${ne(Hf(t,e))} active${t.boxMs?t.runMs<t.activeMs?`, ${ne(Vv(t,e))} of a ${ne(t.boxMs)} box this run`:` of a ${ne(t.boxMs)} box`:""}`,late:zf(t,e)?Yf:"",idle:t.idleMs?`${ne(t.idleMs)} idle`:""}),HI=(t,e)=>{let n=Xv(t,e);return[n.state,n.active,n.late,n.idle].filter(Boolean).join(" \xB7 ")},qv=(t,e)=>t.interrupted?`${t.label}: interrupted, its process has ended`:`${t.label}, ${ne(e-(t.at??e))}${t.background?" (background)":""}`,zI=(t,e)=>`nothing open, last entry ${ne(e-t.asOf)} ago`;GI=t=>{let e=t.files.filter(n=>!n.committed&&!n.ignored).length;return t.files.length?`${t.files.length} (${e} uncommitted)`:"none"};QI=(t,e)=>{let n=XI(t,e);return`${ne(n.tools)} in tools, ${ne(n.model)} in the model`},ZI=t=>t.also.map(e=>`"${e.name}" ${qr(e.at)}`).join(", "),Zv=t=>t.failed>0||!!t.long||t.runs>=3||t.tags.length>0,e$=t=>{let e=t.groups.filter(Zv);return{shown:e.slice(0,jv),more:Math.max(0,e.length-jv)}},t$=t=>`+${t} more like these`,eS=t=>{let e=t.groups.filter(n=>!Zv(n));return{runs:e.reduce((n,r)=>n+r.runs-r.open,0),hidden:e.reduce((n,r)=>n+r.hidden,0),ms:e.reduce((n,r)=>n+r.ms,0)}},n$=(t,e=!0)=>{let n=eS(t),r=n.runs-n.hidden,s=e?" other":"",i=c=>c===1?"run":"runs",o=`with ${n.hidden===1?"its":"their"} exit hidden by a pipe`;return`${r?`${r}${s} ${i(r)} passed${n.hidden?`, ${n.hidden} ${o}`:""}`:`${n.hidden}${s} ${i(n.hidden)} ${o}`}, ${ne(n.ms)} in all`},r$=t=>[...t.tags,t.long].filter(Boolean).join(", "),s$=t=>t?t.last||t.first:"",tS=t=>t.hidden?"exit hidden":t.outcome&&t.outcome!=="completed"&&t.outcome!=="failed"&&t.exit===void 0?t.outcome:t.exit!==void 0?`exit ${t.exit}`:t.failed?"error":"ok",i$=t=>t.deleted?`${t.path} (deleted)`:t.from?`${t.path} (moved from ${t.from})`:t.path,o$=t=>t.times>1?`${t.path} \xD7${t.times}`:t.path,a$=t=>({shown:t.read.slice(-Fv),earlier:Math.max(0,t.read.length-Fv)});c$=5*6e4});import{openSync as l$,readSync as u$,closeSync as d$,fstatSync as f$,statSync as p$,readFileSync as h$,writeFileSync as m$,mkdirSync as g$}from"fs";import{join as sS}from"path";function*Sc(t,e){if(!t.listChildren)return;let n=t.callerSessionId?.(e),r=gi(t.listSessionFiles(e),s=>s.mtime).sort((s,i)=>+(i.sessionId===n)-+(s.sessionId===n));for(let s of r){let i=t.listChildren(e,s.sessionId);i.length&&(yield iS(t,e,s.sessionId,s.file,i))}}function iS(t,e,n,r,s){let i=gc(t,n,e,r);return{sessionId:n,live:i,file:r,children:s.map(o=>({...o,state:Ur(o,i)}))}}function Si(t,e){let n=t.callerSessionId?.(e);return{sessionId:n,cwd:n&&t.sessionCwd?.(n)||e}}function oS(t,e){let n=Si(t,e);return n.sessionId?n:{sessionId:Sc(t,e).next().value?.sessionId,cwd:e}}function kc(t,e,n){let r=t.listSessionFiles(e).find(s=>s.sessionId===n)?.file;return iS(t,e,n,r,t.listChildren?.(e,n)??[])}function aS(t,e){let n=e.trim().toLowerCase(),r=t.children.filter(s=>s.id.toLowerCase()===n);return r.length?r:t.children.filter(s=>s.id.toLowerCase().startsWith(n)||ft(s).toLowerCase().includes(n))}function en(t,e){let n=sS(Ee(),"slow",t);if(e)try{g$(sS(n,".."),{recursive:!0}),m$(n,String(e))}catch{}let r=0;try{r=Number(h$(n,"utf8"))}catch{}return e||r||wi}function cS(t,e,n,r){let s={size:-1,mtimeMs:-1};try{s=p$(e)}catch{}let i=vc.get(e);if(i&&i.size===s.size&&i.mtime===s.mtimeMs&&i.cwd===n)return i;let o=Nv(t,e,"child"),a=Wv(o),c={size:s.size,mtime:s.mtimeMs,cwd:n,d:a,touches:Hv(a,n),tags:Mv(o,r)};return vc.set(e,c),c}function lS(t,e,n){let r=n.map(s=>({c:s,x:cS(t,s.file,e,s.id)}));return{tags:r.flatMap(s=>s.x.tags),briefs:new Map(r.map(s=>[s.c.id,s.x.d.brief?.line??""]))}}function y$(t){let e;try{e=l$(t,"r")}catch{return}try{let n=f$(e).size,r=(s,i)=>{let o=Buffer.alloc(i);return o.subarray(0,u$(e,o,0,i,s)).toString("utf8")};return n<=2*wc?r(0,n):`${r(0,wc)}
2066
+ ${r(n-wc,wc)}`}catch{return}finally{d$(e)}}async function tn(t,e,n,r){let s=Lv([...n.children].sort((p,h)=>(p.started??p.mtime)-(h.started??h.mtime))),i=en(n.sessionId),o=s.map(p=>cS(t,p.file,e,p.id)),a=new Set(s.map(p=>p.file));for(let p of vc.keys())a.has(p)||vc.delete(p);let c=zv(s.map((p,h)=>({id:p.id,writes:o[h].touches.writes,reads:o[h].touches.reads}))),l=await w$(e,Math.min(1/0,...[...c.writers.values()].flat().map(p=>p.at)),[...c.writers.keys()]),f=new Map(s.map(p=>[p.id,ft(p)])),u=p=>r!==void 0&&(typeof r=="string"?p!==r:!r.has(p)),d=s.flatMap((p,h)=>u(p.id)?[]:[{...Yv(p,o[h].d,o[h].touches,c,f,n.live,y$,l,i),depth:p.depth,parentId:p.parentId}]);return{reports:d,files:r!==void 0?[]:b$(d,c,l)}}function b$(t,e,n){let r=new Set(t.filter(bi).map(a=>a.id)),s=new Set(t.filter(a=>a.state==="stopped").map(a=>a.id)),i=new Map(t.map(a=>[a.id,a.name]));return[...e.writers].filter(([a])=>n.uncommitted(a)).map(([a,c])=>{let l=n.since(a),f=c.filter(d=>d.at>l);if(f.length<2&&!f.some(d=>r.has(d.id)||s.has(d.id)))return;let u=e.blind.filter(d=>d.path===a&&d.overAt>l).flatMap(d=>[d.by,d.over]);return{path:a,writers:f.map(d=>({id:d.id,name:i.get(d.id)??d.id,running:r.has(d.id),stopped:s.has(d.id)})),blind:[...new Set(u)]}}).filter(a=>!!a).sort((a,c)=>a.path.localeCompare(c.path))}async function w$(t,e,n){let r=s=>process.platform==="win32"?s.toLowerCase():s;try{let s=(await Se(["rev-parse","--show-prefix"],t)).trim(),i=u=>u.startsWith(s)?r(u.slice(s.length)):void 0,o=await Se(["status","--porcelain","-z","--untracked-files=all"],t),a=new Set,c=o.split("\0");for(let u=0;u<c.length;u++){let d=c[u];if(d.length<4)continue;(d[0]==="R"||d[0]==="C")&&u++;let p=i(d.slice(3));p&&a.add(p)}let l=new Map;if(Number.isFinite(e)){let u=0;for(let d of(await Se(["log",`--since=${new Date(e).toISOString()}`,"--format=@%ct","--name-only","--","."],t)).split(`
2067
+ `)){if(d.startsWith("@")){u=Number(d.slice(1))*1e3;continue}let p=d.trim()&&i(d.trim());p&&!l.has(p)&&l.set(p,u)}}let f=new Set(n.length?(await Se(["check-ignore","--",...n],t).catch(()=>"")).split(`
2068
+ `).map(u=>r(u.trim())).filter(Boolean):[]);return{uncommitted:u=>a.has(r(u)),ignored:u=>f.has(r(u)),since:u=>l.get(r(u))??0}}catch{return Wf}}var vc,wc,ki=k(()=>{"use strict";Br();yc();jr();Bf();bc();Dn();Qt();vc=new Map;wc=4096});import{closeSync as v$,openSync as S$,readSync as k$,statSync as x$}from"fs";function uS(t,e){if(!e)return[];let n=Wr.get(e);Wr.delete(e),n??=new Vf(t,e),Wr.set(e,n);for(let r of[...Wr.keys()].slice(0,Math.max(0,Wr.size-A$)))Wr.delete(r);return n.tags()}var E$,Vf,A$,Wr,dS=k(()=>{"use strict";yc();Dn();E$=8<<20,Vf=class{constructor(e,n){this.file=n;this.#t=e.forRead(),this.#s=this.#t.linker()}#t;#s;#e=0;#r=Buffer.alloc(0);#c=new Map;#n;#o;tags(){let e=this.#l();if(this.#o&&!e)return this.#o;let n=[],r=new Set;for(let o=this.#n;o&&!r.has(o);){let a=this.#c.get(o);if(!a)break;r.add(o),n.push(a),o=a.parent??a.logical}let s=[],i=0;for(let o of n.reverse()){o.user&&i++;for(let a of o.tags)s.push({...a,turn:i})}return this.#o=s}#l(){let e=0;try{e=x$(this.file).size}catch{return!1}if(e<this.#e&&(this.#e=0,this.#r=Buffer.alloc(0),this.#c.clear(),this.#n=void 0,this.#s=this.#t.linker()),e===this.#e)return!1;let n;try{n=S$(this.file,"r")}catch{return!1}try{let r=Buffer.alloc(Math.min(E$,e-this.#e));for(;this.#e<e;){let s=k$(n,r,0,Math.min(r.length,e-this.#e),this.#e);if(!s)break;this.#e+=s;let i=Buffer.concat([this.#r,r.subarray(0,s)]),o=i.lastIndexOf(10);this.#r=Buffer.from(i.subarray(o+1)),o>=0&&this.#u(i.subarray(0,o).toString("utf8"))}}finally{v$(n)}return!0}#u(e){let n=this.#t,r=Date.now();for(let s of e.split(`
2069
+ `)){if(!s.trim())continue;let i=n.parseEntry(s);if(!i)continue;this.#s.link(i);let o=n.idOf(i);if(!o)continue;let a=[];try{a=Fr(n,i,"main",r).events}catch{}let c=a.flatMap(l=>l.type==="assistant"&&!l.error&&l.text?jf(l.text).map(f=>({...f,at:l.at})):[]);this.#c.set(o,{parent:n.parentOf(i),logical:n.logicalParentOf?.(i),user:a.some(l=>l.type==="user"),tags:c}),!n.isSidechain(i,"main")&&n.isLeafType(i)&&(this.#n=o)}}},A$=4,Wr=new Map});import{mkdirSync as T$,readFileSync as C$,writeFileSync as O$}from"fs";import{join as fS}from"path";function hS(t){try{return JSON.parse(C$(pS(t),"utf8"))}catch{return{}}}function mS(t,e,n){let r=pS(t),s={...hS(t),[e]:n};T$(fS(r,".."),{recursive:!0}),O$(r,JSON.stringify(s,null,2)+`
2070
+ `)}function jn(t,e,n,r,s){let{tags:i,briefs:o}=lS(t,e,s),a=[...uS(t,r),...i].sort((c,l)=>(c.at??0)-(l.at??0));return{threads:Dv(a,hS(n)),briefs:o}}var pS,xc=k(()=>{"use strict";dS();ki();Dn();Qt();pS=t=>fS(Ee(),"answers",`${t}.json`)});import{existsSync as gS,openSync as P$,readSync as _$,closeSync as R$,statSync as xi,readdirSync as yS,watchFile as I$,unwatchFile as bS,mkdirSync as $$,writeFileSync as N$,readFileSync as Gf,unlinkSync as L$,rmSync as M$}from"fs";import{stat as D$}from"fs/promises";import{dirname as B$,join as Fn,resolve as wS}from"path";function q$(t){if(!Number.isInteger(t))return!0;try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}function Kr(t){let e={cwd:Z,sessionId:"",sessionStartMs:Date.now(),buffer:[],base:0,partial:"",offset:0,latest:{in:0,out:0,cached:0,cacheCreate:0},latestModel:null,everAttached:!1,index:mc(t),thread:"main"},n;function r(y,S){let v={offset:S,text:""},P;try{P=xi(y).size}catch{return v}if(P<=S)return v;let N;try{N=P$(y,"r")}catch{return v}try{let j=P-S,D=Buffer.alloc(j),J=0;for(;J<j;){let V=_$(N,D,J,j-J,S+J);if(!V)break;J+=V}return{offset:S+J,text:D.subarray(0,J).toString("utf8")}}finally{R$(N)}}let s=new Set,i,o=0;function a(){if(e.file){for(let y of s)if(y.file===e.file)return y;return}return i}function c(y){let S={d:t.createDriver(e.cwd,y),file:y,id:`new:${++o}`,startedAt:Date.now()};return s.add(S),e.file||(i=S),S}function l(){let y=[...s].filter(v=>v.file);if(!y.length)return[];let S=new Map(t.listSessionFiles(e.cwd).map(v=>[v.file,v.sessionId]));return y.map(v=>{let P=S.get(v.file);return{rec:v,sessionId:P??v.id,pending:P===void 0}})}let f=()=>l().filter(y=>y.pending&&y.rec.prompt!==void 0);async function u(y){s.delete(y),i===y&&(i=void 0);try{await y.d.dispose()}catch(S){console.error("[composer] dispose:",X(S))}}function d(){let y=a(),S=new Set(f().map(v=>v.rec));for(let v of[...s])v!==y&&(S.has(v)||v.d.streaming||v.d.queue||v.d.error||u(v))}function p(){for(let y of s)y.d.sessionFile&&y.file!==y.d.sessionFile&&(y.file=y.d.sessionFile);if(i&&!e.file&&i.file){let y=t.listSessionFiles(e.cwd).find(S=>S.file===i.file);y&&ee(y)}i&&!e.file&&i.prompt!==void 0&&e.sessionId!==i.id&&(M(void 0,i.id),e.everAttached=!0)}let h=y=>Fn(y,F$),m=(y,S)=>Fn(h(y),`${S}.lock`);function g(y,S){try{let v=m(y,S);if(Date.now()-xi(v).mtimeMs>=vS)return!1;try{let P=parseInt(Gf(v,"utf8").trim(),10);if(P===process.pid||!q$(P))return!1}catch{}return!0}catch{return!1}}function b(y,S){if(S)try{$$(h(y),{recursive:!0}),N$(m(y,S),String(process.pid))}catch(v){console.error("[lock] claim failed:",X(v))}}function C(y){try{M$(Fn(y,".claude-bulb"),{recursive:!0,force:!0})}catch{}}function T(y){let S=h(y);if(!gS(S))return;let v;try{v=yS(S)}catch{return}let P=Date.now();for(let N of v){if(!N.endsWith(".lock"))continue;let j=Fn(S,N);try{let D=xi(j);P-D.mtimeMs>U$&&L$(j)}catch{}}}function E(y){try{return xi(y),!1}catch(S){return S.code==="ENOENT"}}function R(){let y=e;if(y.file&&!E(y.file)){b(y.cwd,y.sessionId);return}let S=O(y);S&&ee(S)}function O(y){if(!y.everAttached)return _(y.cwd)??x(y.cwd,()=>!0)}function _(y){let S=h(y);if(!gS(S))return;let v;try{v=yS(S)}catch{return}let P;for(let j of v)if(j.endsWith(".lock"))try{let D=xi(Fn(S,j));if(Date.now()-D.mtimeMs>=vS||parseInt(Gf(Fn(S,j),"utf8").trim(),10)!==process.pid)continue;(!P||D.mtimeMs>P.mtime)&&(P={sessionId:j.slice(0,-5),mtime:D.mtimeMs})}catch{}if(!P)return;let N=t.listSessionFiles(y).find(j=>j.sessionId===P.sessionId);if(!(!N||E(N.file)))return N}function x(y,S){return t.listSessionFiles(y).sort((v,P)=>P.mtime-v.mtime).find(v=>!g(y,v.sessionId)&&S(v))}function M(y,S){let v=e;if(v.file)try{bS(v.file)}catch{}v.file=y,v.sessionId=S,v.partial="",v.offset=0,v.latest={in:0,out:0,cached:0,cacheCreate:0},v.latestModel=null,v.index=mc(t),v.chainLastId=void 0,F(S)}function F(y){e.base+=e.buffer.length,e.buffer=[{type:"cleared"},{type:"session",sessionId:y}]}function ee(y){let S=e;i=void 0,Fi(),n=y.file,M(y.file,y.sessionId),S.everAttached=!0,b(S.cwd,y.sessionId),q(y.file)}function q(y){if(ie(),!!y){try{bS(y)}catch{}I$(y,{interval:200},()=>ie())}}function ue(){Fi(),n=void 0,M(void 0,"")}function ie(){let y=e;if(!y.file)return;let S=r(y.file,y.offset);if(!S.text)return;y.offset=S.offset,y.partial+=S.text;let v=y.partial.lastIndexOf(`
2071
+ `);if(v<0)return;let P=y.index.add(y.partial.slice(0,v).split(`
2072
+ `),y.thread);if(y.partial=y.partial.slice(v+1),!P)return;let N=[],{entries:j}=y.index,D=j.get(P),J=!1;for(;D;){if(N.push(D),t.idOf(D)===y.chainLastId){J=!0;break}let V=t.parentOf(D);D=V?j.get(V):void 0}if(J)for(let V=N.length-2;V>=0;V--)be(N[V]);else{y.chainLastId!==void 0&&(F(y.sessionId),y.latest={in:0,out:0,cached:0,cacheCreate:0});let V=new Set(N.map(ze=>t.idOf(ze))),G=ye(j);for(let ze=N.length-1;ze>=0;ze--)be(N[ze]),xe(t.idOf(N[ze]),G,V)}y.chainLastId=P}function ye(y){let S=new Map;for(let v of y.values()){let P=t.parentOf(v);if(!P)continue;let N=S.get(P);N?N.push(v):S.set(P,[v])}return S}function xe(y,S,v){if(!y)return;let P=S.get(y);if(!P)return;let N=P.filter(V=>!t.isSidechain(V,e.thread));if(N.length<2)return;let j=N.filter(V=>!v.has(t.idOf(V)));if(!j.length)return;let D=[],J=0;for(let V of j){let G=de(V,S);D.push(...G.events),J+=G.count}J>0&&e.buffer.push({type:"fork",atId:y,count:J,events:D})}function de(y,S){let v=[],P=[y];for(;P.length;){let D=P.pop();if(t.isSidechain(D,e.thread))continue;v.push(D);let J=S.get(t.idOf(D)??"");if(J)for(let V of J)P.push(V)}v.sort((D,J)=>(Date.parse(t.timestampOf(D)??"")||0)-(Date.parse(t.timestampOf(J)??"")||0));let N=[];for(let D of v)t.isRecoveryNoise(D)||N.push(...Fr(t,D,e.thread,e.sessionStartMs).events);return{count:N.reduce((D,J)=>D+(J.type==="user"||J.type==="assistant"?1:0),0),events:N}}function be(y){if(!t.isSidechain(y,e.thread))try{let{events:S,usage:v,model:P,cost:N}=Fr(t,y,e.thread,e.sessionStartMs);for(let j of S)e.buffer.push(j);S.some(j=>j.type==="assistant")&&a()?.d.clearCompletedDraft(),S.some(j=>j.type==="user")&&a()?.d.clearEcho(),P&&(e.latestModel=P),v&&(e.latest=v),(v||N)&&e.buffer.push({type:"usage",...e.latest,cost:N})}catch(S){console.error("[mirror] skipped malformed entry:",X(S))}}async function ln(){return{cwd:e.cwd,pid:process.pid,composer:!!t.createDriver,children:!!t.listChildren,elsewhere:await w()}}async function w(){if(t.listSessionFiles(e.cwd).length)return;let y=await Mn();if(!y)return;let S=wS(y).toLowerCase();for(let v=wS(e.cwd);v.toLowerCase()!==S;){let P=B$(v);if(P===v)return;v=P;let N=t.listSessionFiles(v).length;if(N)return{dir:v,count:N}}}w().then(y=>{y&&console.log(`No sessions for ${e.cwd} \u2014 ${y.count} exist for ${y.dir}. Launched from a subfolder? Relaunch from the project root.`)}).catch(()=>{});let A=new cc;async function I(y,S){e.thread!=="child"&&A.accept(y,S)&&console.log(S)}function L(){return gc(t,e.sessionId,e.cwd,e.file)}function B(){return t.chainWorking([...e.index.entries.values()])&&L()}function K(){!t.createDriver||a()||e.latestModel||B()||c(e.file)}async function H(y){let S=e;R(),p(),K(),d();let v=a();for(let D of s)D!==v&&D.d.dialog;let P=l().filter(D=>D.rec.d.streaming).map(D=>D.sessionId),N=B(),j=t.createDriver?{streaming:!!v?.d.streaming,foreign:!v&&N,draft:v?.d.draft??null,echo:v?.d.echo??null,status:v?.d.status??null,dialog:v?.d.dialog??null,queue:v?.d.queue??null,stats:v?.d.stats??null,model:v?.d.model??null,error:v?.d.error}:void 0;return{events:S.buffer.slice(Math.max(0,y-S.base)),cursor:S.base+S.buffer.length,working:!!v?.d.streaming||N,latestModel:S.latestModel,child:S.child?.id??null,composer:j,busy:P}}async function Be(){R(),p();let y=a();if(y?.d.error&&!y.d.streaming&&(await u(y),y=void 0),!y){if(B())return{ok:!1,error:"the agent is mid-turn in a terminal \u2014 watch only"};y=c(e.file)}let S=y;return{ok:!0,d:S.d,markSent:v=>{S.prompt===void 0&&(S.prompt=v)}}}async function Y(y,S){if(!t.createDriver)return{ok:!1,error:"not supported"};let v=String(y??"").trim();if(!v)return{ok:!1,error:"empty message"};let P=await Be();if(!P.ok)return P;let N=await P.d.send(v,S);return N.ok&&P.markSent(v),N}async function fe(y,S){let v=a();return v?v.d.respondUi(String(y??""),S??{}):{ok:!1,error:"no dialog pending"}}async function Re(y,S){if(!t.createDriver)return{ok:!1,error:"not supported"};if(!y||typeof y.type!="string")return{ok:!1,error:"bad command"};if(S?.spawn){let P=await Be();return P.ok?P.d.rpc(y):P}let v=a();return!v||v.d.error?{ok:!1,error:"not running"}:v.d.rpc(y)}async function Qr(){let y=a();if(y)try{await y.d.stop()}catch(S){console.error("[composer] stop:",X(S))}return{ok:!0}}async function un(){return t.createDriver?(p(),!e.file&&i&&i.prompt===void 0&&!i.d.streaming&&!i.d.error?{ok:!0}:(i?.d.error&&await u(i),i=void 0,ue(),c(void 0),d(),{ok:!0})):{ok:!1,error:"not supported"}}async function _t(){if(!t.createDriver)return[];let y=await Se(["ls-files","--cached","--others","--exclude-standard"],e.cwd).catch(()=>null),S=y!==null?y.split(`
2073
+ `).filter(Boolean):await t.walkFiles?.(e.cwd)??[];return(await Promise.all(S.map(async P=>{try{return{f:P,m:(await D$(Fn(e.cwd,P))).mtimeMs}}catch{return{f:P,m:0}}}))).sort((P,N)=>N.m-P.m).map(P=>P.f)}function el(){for(let y of[...s])u(y)}async function tl(y){return t.createDriver?Cv(e.cwd,y):{ok:!1,error:"not supported"}}async function Cx(y){return Ov(e.cwd,String(y??""))}async function Ox(y,S){return Iv(String(y??""),String(S??""))}async function Px(y){let S=t.listChildren?.(e.cwd,e.sessionId)??[],v=L(),{reports:[P]}=await tn(t,e.cwd,{sessionId:e.sessionId,live:v,children:S.map(N=>({...N,state:Ur(N,v)}))},y);return P?{ok:!0,report:P}:{ok:!1,error:"child not found"}}async function _x(y=!1){if(!e.sessionId||!n)return{threads:[],agents:[],others:[]};let S=t.listChildren?.(e.cwd,e.sessionId)??[],{threads:v,briefs:P}=jn(t,e.cwd,e.sessionId,n,S);if(!y)return{threads:v,agents:[],others:[]};let N=L(),j=S.map(G=>({...G,state:Ur(G,N)})),D=new Set(j.filter(G=>G.state==="running"||G.failing&&G.state!=="stopped").map(G=>G.id)),{reports:J}=D.size?await tn(t,e.cwd,{sessionId:e.sessionId,live:N,children:j},D):{reports:[]},V=j.filter(G=>!D.has(G.id)).map(G=>({id:G.id,name:ft(G),state:G.state,at:G.mtime,brief:P.get(G.id)??""}));return{threads:v,agents:J,others:V}}async function Rx(y,S,v,P){if(!e.sessionId||!n)return{ok:!1,error:"no session attached"};let N=t.listChildren?.(e.cwd,e.sessionId)??[],j=jn(t,e.cwd,e.sessionId,n,N).threads.find(V=>V.id===y);if(!j?.ask)return{ok:!1,error:"no such ask"};if(j.latest.kind!=="Ask")return{ok:!1,error:`already ${j.state}`};if(j.version!==S)return{ok:!1,error:"this ask has been asked again since; read it again"};let D=String(P??"").replace(/\s+/g," ").trim();if(!["accept","todo","discuss","note"].includes(v))return{ok:!1,error:"bad choice"};if(v==="accept"&&!j.ask.recommend)return{ok:!1,error:"this ask has no recommendation"};if(v==="note"&&!D)return{ok:!1,error:"empty note"};let J={version:S,choice:v,at:Date.now(),...v==="accept"?{recommend:j.ask.recommend}:{},...D?{note:D}:{}};return mS(e.sessionId,y,J),console.log(yi(y,J)),{ok:!0,answer:J}}async function Ix(){let y=t.sessionsWorking?.(e.cwd),S=t.sessionNames?.(),v=t.listSessionFiles(e.cwd).map(({sessionId:N,file:j,mtime:D})=>({sessionId:N,mtime:D,preview:t.readPreview(j),working:y?.has(N),name:S?.get(N)})),P=f().map(N=>({sessionId:N.sessionId,mtime:N.rec.startedAt,preview:N.rec.prompt??"",pending:!0}));return gi([...v,...P],N=>N.mtime)}let Hp=new Map;function zp(y,S){let v=Hp.get(y);if(v&&v.mtime===S)return v.turns;let P=[],N="";try{N=Gf(y,"utf8")}catch{return[]}for(let j of N.split(`
2074
+ `)){if(!j.trim())continue;let D=t.parseEntry(j);if(!D)continue;let J=t.searchText(D);J&&P.push({text:J,lower:J.toLowerCase()})}return Hp.set(y,{mtime:S,turns:P}),P}async function $x(y){let S=y.toLowerCase(),v=[],P=0,N=t.sessionsWorking?.(e.cwd),j=t.sessionNames?.();for(let{sessionId:D,file:J,mtime:V}of t.listSessionFiles(e.cwd).sort((G,ze)=>ze.mtime-G.mtime)){let G=mi(zp(J,V),S),ze=(t.listChildren?.(e.cwd,D)??[]).map(Ye=>({c:Ye,hit:mi(zp(Ye.file,Ye.mtime),S)})).filter(Ye=>Ye.hit.hitCount);if(!(!G.hitCount&&!ze.length)){for(let{c:Ye,hit:Bx}of gi(ze,jx=>jx.c.mtime))v.push({sessionId:D,mtime:Ye.mtime,preview:ft(Ye),...Bx,child:{id:Ye.id,kind:Ye.kind,depth:Ye.depth}});if(v.push({sessionId:D,mtime:V,preview:t.readPreview(J),working:N?.has(D),name:j?.get(D),...G}),++P>=J$)break}}return v}async function Nx(y){let S=e,v=t.listSessionFiles(S.cwd).find(P=>P.sessionId===y);if(!v){let P=f().find(N=>N.sessionId===y)?.rec;return P?((i!==P||S.sessionId!==P.id)&&(i=P,Fi(),n=void 0,M(void 0,P.id),S.everAttached=!0,d()),{ok:!0}):{ok:!1,error:"session not found"}}return v.file===S.file?{ok:!0}:(ee(v),p(),d(),{ok:!0})}async function Lx(){if(!t.listChildren||!e.sessionId)return[];let y=L();return t.listChildren(e.cwd,e.sessionId).map(S=>({...S,state:Ur(S,y)}))}async function Mx(y){let S=e;if(!t.listChildren)return{ok:!1,error:"this harness has no child transcripts"};let v=t.listChildren(S.cwd,S.sessionId).find(P=>P.id===y);return v?(S.thread="child",S.child=v,M(v.file,S.sessionId),q(v.file),{ok:!0}):{ok:!1,error:"child not found"}}async function Dx(){let y=n;return!Fi()||!y?{ok:!0}:(M(y,e.sessionId),q(y),{ok:!0})}function Fi(){let y=e;return y.thread==="main"?!1:(y.thread="main",y.child=void 0,!0)}return C(e.cwd),T(e.cwd),R(),{info:ln,poll:H,logInlineStatus:I,listSessions:Ix,searchSessions:$x,attach:Nx,listChildren:Lx,openChild:Mx,closeChild:Dx,composerSend:Y,composerStop:Qr,composerNew:un,composerFiles:_t,composerUiRespond:fe,composerRpc:Re,composerPaste:tl,composerPasteRead:Cx,summarizeTurn:Ox,childStatus:Px,board:_x,answerAsk:Rx,shutdownComposer:el}}var j$,F$,vS,U$,J$,Ec=k(()=>{"use strict";Zt();Sv();Br();Mf();Pv();$v();yc();ki();xc();Dn();Bf();jr();j$=".typebulb",F$=`${j$}/locks`,vS=5e3,U$=6e4;J$=50});import{existsSync as ep,mkdirSync as W$,readFileSync as SS,writeFileSync as K$}from"fs";import{join as Un,isAbsolute as H$}from"path";async function np(t,e){let n=H$(t)?t:Un(Z,t);return ep(n)?(Md(n,e),{ok:!0}):{ok:!1,error:"file not found"}}async function rp(t){let e=Z,n=Ld(t),r=Un(e,"typebulbs");W$(r,{recursive:!0});let s=Rd(n),i=`${s}.bulb.md`;for(let l=2;ep(Un(r,i))&&SS(Un(r,i),"utf8")!==n;l++)i=`${s}-${l}.bulb.md`;let o=Un(r,i);ep(o)||K$(o,n);let a=Un("typebulbs",i),c=await xn(a,{cwd:e,open:!1});return{ok:!0,file:a,pid:c.pid,url:c.url}}async function sp(){return Q(Z)}async function ip(t){let e=(await Q()).find(n=>n.pid===t);return e?{ok:!0,outcome:await wt(e)}:(await fr(t),{ok:!0})}async function op(){let t=await wn(Z);return Sa(Z).filter(e=>!e.serverOnly).map(e=>({...e,trusted:Tn(e.path),lastRunAt:t(e.path)}))}async function ap(t){let e=t.toLowerCase(),n=[];for(let r of Sa(Z).filter(s=>!s.serverOnly).sort((s,i)=>i.mtime-s.mtime)){let s="";try{s=SS(r.path,"utf8")}catch{continue}let i=[];for(let c of s.split(`
2075
+ `)){let l=c.replace(/\s+/g," ").trim();l&&i.push({text:l,lower:l.toLowerCase()})}let{hitCount:o,snippet:a}=mi(i,e);o&&n.push({path:r.path,hitCount:o,snippet:a})}return n}async function cp(t,e){let n=Z;e!=null&&br(t,e);let r=await xn(t,{cwd:n,open:!1,trust:e});return{ok:!0,file:r.file,pid:r.pid,url:r.url,trust:!!r.trust}}async function lp(t){return{cap:await $d(t)}}async function up(t,e){return br(t,e),{ok:!0}}async function dp(t,e){return Ze(t,e)}async function fp(){return Ei&&Date.now()-Ei.fetchedAt<=Y$?Ei.samples:(Xf??=V$().finally(()=>{Xf=null}),Xf)}async function V$(){try{let t=await fetch(`${z$}/api/scripts/u/samples?stubs`,{signal:AbortSignal.timeout(xS)});if(!t.ok)throw new Error(`HTTP ${t.status}`);let e=await t.json(),n=i=>i.order??Number.MAX_SAFE_INTEGER,r=i=>Date.parse(i.createdAt??"")||0,s=e.filter(i=>i.slug!=="welcome").sort((i,o)=>n(i)-n(o)||r(o)-r(i)).map(i=>({slug:i.slug,name:i.name,description:ul(i.config)}));return Ei={samples:s,fetchedAt:Date.now()},s}catch{return Ei?.samples??[]}}async function pp(t){return tp.test(t)?AS(kS,"samples",t,!0):{ok:!1,error:"bad slug"}}async function mp(){let t=hp();if(!t)return{bulbs:[]};let e=`${Ac()}
2076
+ ${t}`;return nn?.key===e&&Date.now()-nn.fetchedAt<=G$?{user:nn.user,bulbs:nn.bulbs}:(Qf??=X$(e,t).finally(()=>{Qf=null}),Qf)}async function Zf(t,e,n){let r=await fetch(`${t}${e}`,{headers:n,signal:AbortSignal.timeout(xS)});if(!r.ok)throw new Error(`HTTP ${r.status}`);if(!r.headers.get("content-type")?.includes("json"))throw new Error("not json");return r.json()}async function X$(t,e){let n={Authorization:`Bearer ${e}`};try{let r=Ac(),s;try{s=await Zf(r,"/api/me",n)}catch{let a=new URL(r);r=`${a.protocol}//api.${a.host}`,s=await Zf(r,"/api/me",n)}let o=(await Zf(r,"/api/scripts/list",n)).filter(a=>a.userSlug===s.slug&&!a.isTemplate).map(a=>({slug:a.slug,name:a.name,description:ul(a.config)}));return nn={key:t,user:s.slug,bulbs:o,fetchedAt:Date.now()},{user:s.slug,bulbs:o}}catch{return nn?.key===t?{user:nn.user,bulbs:nn.bulbs}:{bulbs:[]}}}async function gp(t,e,n=!1){return!tp.test(e)||!tp.test(t)?{ok:!1,error:"bad slug"}:AS(Ac(),t,e,n)}async function AS(t,e,n,r){let s=Za(e,n);try{let i=await nc({origin:t,userSlug:e,slug:n,dest:Un(Z,s)},{force:r,token:hp(),timeoutMs:ES});return i.kind==="conflict"?{ok:!1,conflict:!0,error:"local file differs from the site copy"}:i.kind==="asset-conflict"?{ok:!1,conflict:!0,error:`local assets differ from the site copies (${i.paths.join(", ")})`}:i.kind==="http-error"?{ok:!1,error:`HTTP ${i.status}`}:i.kind==="not-markdown"?{ok:!1,error:`not a bulb (${i.contentType??"no content-type"})`}:{ok:!0,file:s,upToDate:i.kind==="up-to-date"}}catch(i){return{ok:!1,error:i?.message??String(i)}}}async function yp(t,e=!1){let n=hp();if(!n)return{ok:!1,error:"no TYPEBULB_TOKEN in .env"};try{let r=tc(t,Z,Ac()),s=await sc(r,{token:n,force:e,timeoutMs:ES});return s.kind==="conflict"?{ok:!1,conflict:!0,error:s.message}:s.kind==="asset-error"?{ok:!1,error:`assets sync failed: ${s.message}`}:s.kind==="http-error"?{ok:!1,error:`HTTP ${s.status}: ${s.message}`}:{ok:!0,created:s.created,serverStripped:s.serverStripped}}catch(r){return{ok:!1,error:r?.message??String(r)}}}var z$,kS,Y$,xS,ES,Ei,Xf,tp,G$,nn,Qf,Ac,hp,Tc=k(()=>{"use strict";Qt();Zt();Mf();re();z$="https://api.typebulb.com",kS="https://typebulb.com",Y$=3600*1e3,xS=5e3,ES=15e3,Ei=null,Xf=null;tp=/^[a-z0-9][a-z0-9-]*$/,G$=300*1e3,nn=null,Qf=null,Ac=()=>Ia("TYPEBULB_ORIGIN",Z)||kS,hp=()=>Ia("TYPEBULB_TOKEN",Z)});import{readFileSync as vp,writeFileSync as CS,mkdirSync as Q$,appendFileSync as OS,rmSync as TS}from"fs";import{join as Pc,dirname as Z$}from"path";import{createServer as e1}from"http";function rn(t){try{return JSON.parse(vp(t,"utf8"))}catch{return null}}function Oc(t,e){Q$(Z$(t),{recursive:!0}),CS(t,JSON.stringify(e,null,2)+`
2077
+ `)}function _S(t,e,n){let r=Pc(t,".gitignore"),s="";try{s=vp(r,"utf8")}catch{}let i=new Set(s.split(/\r?\n/).map(c=>c.trim())),o=e.filter(c=>!i.has(c));if(!o.length)return;let a=s&&!s.endsWith(`
2073
2078
  `)?`
2074
- `:"";try{iS(r,a+n+`
2079
+ `:"";try{OS(r,a+n+`
2075
2080
  `+o.join(`
2076
2081
  `)+`
2077
- `)}catch(l){console.error("[switcher] .gitignore update failed",V(l))}}function y$(t){let e=i=>{let o=i.exec(t);return o?Number(o[1]):0},n=e(/"cache_read_input_tokens":\s*(\d+)/),r=e(/"cache_creation_input_tokens":\s*(\d+)/),s=e(/"input_tokens":\s*(\d+)/);n>0||r>0?Si="live":s>g$&&(Si="uncached")}function cS(t,e){let n={"content-type":"application/json",authorization:`Bearer ${e}`,"anthropic-version":t.headers["anthropic-version"]||"2023-06-01",...Dd},r=t.headers["anthropic-beta"];return typeof r=="string"&&(n["anthropic-beta"]=r),n}function b$(t){if(Array.isArray(t?.messages))for(let e of t.messages){if(!Array.isArray(e?.content))continue;let n=e.content.filter(r=>r?.type!=="thinking"&&r?.type!=="redacted_thinking");n.length&&n.length!==e.content.length&&(e.content=n)}}function uS(t){let e;try{e=JSON.parse(t)}catch{return t}vi=typeof e?.model=="string"?e.model:null,dt&&(e.model=dt),Un&&(e.provider=lS(Un));let n=/haiku/i.test(vi||"");return ki!=null&&!n&&(e.reasoning={effort:ap[ki]}),delete e.thinking,e.output_config&&delete e.output_config.effort,b$(e),JSON.stringify(e)}function w$(){let t="",e=0,n=new Map,r=new Set(["thinking","redacted_thinking"]),s=i=>{let o=/^data: (.*)$/m.exec(i);if(!o)return i;let a;try{a=JSON.parse(o[1])}catch{return i}switch(a.type){case"message_start":return n.clear(),e=0,i;case"content_block_start":{if(r.has(a.content_block?.type))return n.set(a.index,null),null;let l=e++;return n.set(a.index,l),a.index=l,`event: ${a.type}
2082
+ `)}catch(c){console.error("[switcher] .gitignore update failed",X(c))}}function i1(t){let e=i=>{let o=i.exec(t);return o?Number(o[1]):0},n=e(/"cache_read_input_tokens":\s*(\d+)/),r=e(/"cache_creation_input_tokens":\s*(\d+)/),s=e(/"input_tokens":\s*(\d+)/);n>0||r>0?Ci="live":s>s1&&(Ci="uncached")}function IS(t,e){let n={"content-type":"application/json",authorization:`Bearer ${e}`,"anthropic-version":t.headers["anthropic-version"]||"2023-06-01",...Jd},r=t.headers["anthropic-beta"];return typeof r=="string"&&(n["anthropic-beta"]=r),n}function o1(t){if(Array.isArray(t?.messages))for(let e of t.messages){if(!Array.isArray(e?.content))continue;let n=e.content.filter(r=>r?.type!=="thinking"&&r?.type!=="redacted_thinking");n.length&&n.length!==e.content.length&&(e.content=n)}}function $S(t){let e;try{e=JSON.parse(t)}catch{return t}Ti=typeof e?.model=="string"?e.model:null,pt&&(e.model=pt),Jn&&(e.provider=RS(Jn));let n=/haiku/i.test(Ti||"");return Oi!=null&&!n&&(e.reasoning={effort:bp[Oi]}),delete e.thinking,e.output_config&&delete e.output_config.effort,o1(e),JSON.stringify(e)}function a1(){let t="",e=0,n=new Map,r=new Set(["thinking","redacted_thinking"]),s=i=>{let o=/^data: (.*)$/m.exec(i);if(!o)return i;let a;try{a=JSON.parse(o[1])}catch{return i}switch(a.type){case"message_start":return n.clear(),e=0,i;case"content_block_start":{if(r.has(a.content_block?.type))return n.set(a.index,null),null;let c=e++;return n.set(a.index,c),a.index=c,`event: ${a.type}
2078
2083
  data: ${JSON.stringify(a)}
2079
2084
 
2080
- `}case"content_block_delta":case"content_block_stop":{let l=n.get(a.index);return l==null?null:(a.index=l,`event: ${a.type}
2085
+ `}case"content_block_delta":case"content_block_stop":{let c=n.get(a.index);return c==null?null:(a.index=c,`event: ${a.type}
2081
2086
  data: ${JSON.stringify(a)}
2082
2087
 
2083
2088
  `)}default:return i}};return i=>{t+=i;let o="",a;for(;(a=t.indexOf(`
2084
2089
 
2085
- `))!==-1;){let l=t.slice(0,a);if(t=t.slice(a+2),!l.trim())continue;let c=s(l);c!==null&&(o+=c)}return o}}function v$(t){return new Promise(e=>{let n=[];t.on("data",r=>n.push(r)),t.on("end",()=>e(Buffer.concat(n).toString("utf8"))),t.on("error",()=>e(Buffer.concat(n).toString("utf8")))})}function wi(t,e,n,r){t.writableEnded||(t.writeHead(e,{"content-type":"application/json"}),t.end(JSON.stringify({type:"error",error:{type:n,message:r}})))}async function S$(t,e,n){if(!dt){wi(e,400,"invalid_request_error",m$);return}let r=process.env.OPENROUTER_API_KEY;if(!r){wi(e,401,"authentication_error","OPENROUTER_API_KEY not set in the typebulb proxy");return}let s=new AbortController;e.on("close",()=>{e.writableEnded||s.abort()});let i;try{i=await fetch(up,{method:"POST",headers:cS(t,r),body:uS(n),signal:s.signal})}catch(d){wi(e,502,"api_error",`proxy upstream failed: ${V(d)}`);return}let o=i.headers.get("content-type")||"application/json";if(e.writeHead(i.status,{"content-type":o}),!i.body){e.end();return}let a=o.includes("event-stream"),l=i.body.getReader(),c=new TextDecoder,f=a?w$():null;try{for(;;){let{done:d,value:u}=await l.read();if(d)break;if(u)if(f){let p=c.decode(u,{stream:!0});y$(p);let h=f(p);h&&e.write(h)}else e.write(Buffer.from(u))}}catch{}finally{e.writableEnded||e.end()}}async function k$(t,e,n){let r=process.env.OPENROUTER_API_KEY,s=()=>{e.writeHead(200,{"content-type":"application/json"}),e.end(JSON.stringify({input_tokens:Math.max(1,Math.ceil(n.length/4))}))};if(!dt||!r)return s();try{let i=await fetch(`${up}/count_tokens`,{method:"POST",headers:cS(t,r),body:uS(n)});if(!i.ok)return s();let o=await i.text();e.writeHead(200,{"content-type":"application/json"}),e.end(o)}catch{s()}}function x$(t,e){let n=t.url||"/";if(t.method==="HEAD"){e.writeHead(200),e.end();return}if(t.method!=="POST"){wi(e,404,"not_found_error",n);return}v$(t).then(r=>{if(n.includes("count_tokens"))return k$(t,e,r);if(n.includes("/v1/messages"))return S$(t,e,r);wi(e,404,"not_found_error",n)})}function E$(){return Fr&&Fn?Promise.resolve(Fn):new Promise((t,e)=>{let n=f$(x$);n.on("error",e),n.listen(0,"127.0.0.1",()=>{Fr=n,Fn=n.address().port,console.log(`[switcher] wire proxy listening on ${vl(Fn)}`),t(Fn)})})}function A$(){try{Fr?.close()}catch{}Fr=null,Fn=null}function T$(t,e){let n=xl(t),r=nn(n),s=r||{};if((!s.env||typeof s.env!="object")&&(s.env={}),s.env.ANTHROPIC_BASE_URL===vl(e)&&s.env.ANTHROPIC_AUTH_TOKEN)return;let i=El(t);if(!nn(i)){let a={};for(let l of oS)a[l]=l in s.env?s.env[l]:null;Sl(i,{managedBy:"agent-switcher",fileExisted:r!==null,snapshot:a,active:null})}s.env.ANTHROPIC_BASE_URL=vl(e),s.env.ANTHROPIC_AUTH_TOKEN=h$,Sl(n,s),aS(t,[".claude/settings.local.json",".claude/.cc-switcher.json"],"# agent switcher (local Claude Code model override)")}function C$(t,e,n){let r=El(t),s=nn(r)||{managedBy:"agent-switcher",fileExisted:!1,snapshot:{}};s.active={model:e,provider:n},Sl(r,s)}function dS(t){let e=xl(t),n=El(t),r=nn(n),s=nn(e);if(s?.env){let i=r?.snapshot||{};for(let o of oS){let a=i[o];a==null?delete s.env[o]:s.env[o]=a}if(Object.keys(s.env).length===0&&delete s.env,r?.fileExisted===!1&&Object.keys(s).length===0)try{rS(e,{force:!0})}catch{}else Sl(e,s)}try{rS(n,{force:!0})}catch{}}async function O$(){let t=!!process.env.OPENROUTER_API_KEY,e=[];try{e=(await wt()).filter(r=>r.provider==="openrouter"&&!dp(r.name)).map(r=>({id:r.name,label:r.friendlyName||r.name}))}catch(r){console.error("[switcher] model list failed",V(r))}let n=e.length?void 0:Nd()??void 0;return{hasKey:t,models:e,error:n}}async function P$(){if(Fr&&dt)return{active:!0,managed:!0,model:dt,port:Fn,provider:Un,routedModel:vi,caching:Si,reasoning:ki,externalBaseUrl:null};let t=nn(xl(X))?.env||{};return{active:!1,managed:!1,model:null,port:null,provider:null,routedModel:null,caching:"unknown",reasoning:ki,externalBaseUrl:t.ANTHROPIC_BASE_URL||null}}async function fS(t,e){let n=await E$();return dt=t,Un=e,T$(X,n),n}async function _$({model:t}){if(!process.env.OPENROUTER_API_KEY)return{ok:!1,error:"OPENROUTER_API_KEY not set \u2014 add a key first"};if(!t)return{ok:!1,error:"no model given"};if(dp(t))return{ok:!1,error:"Refusing to route an Anthropic model through OpenRouter \u2014 that bills full API rate with no caching. Use it on your Anthropic subscription instead."};try{await fS(t,fp[t]??null),vi=null,Si="unknown",C$(X,t,Un)}catch(e){return{ok:!1,error:`failed to start the wire proxy: ${V(e)}`}}return{ok:!0}}async function R$({level:t}){return t!=null&&(!Number.isInteger(t)||t<0||t>=ap.length)?{ok:!1,error:`reasoning level must be 0\u2013${ap.length-1} or null`}:(ki=t,{ok:!0,level:t})}async function I$(){return dS(X),dt=null,Un=null,vi=null,Si="unknown",{ok:!0}}async function $$({key:t}){let e=(t||"").trim();if(!e)return{ok:!1,error:"empty key"};let n=X,r=kl(n,".env"),s="";try{s=cp(r,"utf8")}catch{}try{if(/^\s*OPENROUTER_API_KEY\s*=/m.test(s))sS(r,s.replace(/^\s*OPENROUTER_API_KEY\s*=.*$/m,`OPENROUTER_API_KEY=${e}`));else{let i=s&&!s.endsWith(`
2090
+ `))!==-1;){let c=t.slice(0,a);if(t=t.slice(a+2),!c.trim())continue;let l=s(c);l!==null&&(o+=l)}return o}}function c1(t){return new Promise(e=>{let n=[];t.on("data",r=>n.push(r)),t.on("end",()=>e(Buffer.concat(n).toString("utf8"))),t.on("error",()=>e(Buffer.concat(n).toString("utf8")))})}function Ai(t,e,n,r){t.writableEnded||(t.writeHead(e,{"content-type":"application/json"}),t.end(JSON.stringify({type:"error",error:{type:n,message:r}})))}async function l1(t,e,n){if(!pt){Ai(e,400,"invalid_request_error",r1);return}let r=process.env.OPENROUTER_API_KEY;if(!r){Ai(e,401,"authentication_error","OPENROUTER_API_KEY not set in the typebulb proxy");return}let s=new AbortController;e.on("close",()=>{e.writableEnded||s.abort()});let i;try{i=await fetch(Sp,{method:"POST",headers:IS(t,r),body:$S(n),signal:s.signal})}catch(u){Ai(e,502,"api_error",`proxy upstream failed: ${X(u)}`);return}let o=i.headers.get("content-type")||"application/json";if(e.writeHead(i.status,{"content-type":o}),!i.body){e.end();return}let a=o.includes("event-stream"),c=i.body.getReader(),l=new TextDecoder,f=a?a1():null;try{for(;;){let{done:u,value:d}=await c.read();if(u)break;if(d)if(f){let p=l.decode(d,{stream:!0});i1(p);let h=f(p);h&&e.write(h)}else e.write(Buffer.from(d))}}catch{}finally{e.writableEnded||e.end()}}async function u1(t,e,n){let r=process.env.OPENROUTER_API_KEY,s=()=>{e.writeHead(200,{"content-type":"application/json"}),e.end(JSON.stringify({input_tokens:Math.max(1,Math.ceil(n.length/4))}))};if(!pt||!r)return s();try{let i=await fetch(`${Sp}/count_tokens`,{method:"POST",headers:IS(t,r),body:$S(n)});if(!i.ok)return s();let o=await i.text();e.writeHead(200,{"content-type":"application/json"}),e.end(o)}catch{s()}}function d1(t,e){let n=t.url||"/";if(t.method==="HEAD"){e.writeHead(200),e.end();return}if(t.method!=="POST"){Ai(e,404,"not_found_error",n);return}c1(t).then(r=>{if(n.includes("count_tokens"))return u1(t,e,r);if(n.includes("/v1/messages"))return l1(t,e,r);Ai(e,404,"not_found_error",n)})}function f1(){return Hr&&qn?Promise.resolve(qn):new Promise((t,e)=>{let n=e1(d1);n.on("error",e),n.listen(0,"127.0.0.1",()=>{Hr=n,qn=n.address().port,console.log(`[switcher] wire proxy listening on ${Cc(qn)}`),t(qn)})})}function p1(){try{Hr?.close()}catch{}Hr=null,qn=null}function h1(t,e){let n=_c(t),r=rn(n),s=r||{};if((!s.env||typeof s.env!="object")&&(s.env={}),s.env.ANTHROPIC_BASE_URL===Cc(e)&&s.env.ANTHROPIC_AUTH_TOKEN)return;let i=Rc(t);if(!rn(i)){let a={};for(let c of PS)a[c]=c in s.env?s.env[c]:null;Oc(i,{managedBy:"agent-switcher",fileExisted:r!==null,snapshot:a,active:null})}s.env.ANTHROPIC_BASE_URL=Cc(e),s.env.ANTHROPIC_AUTH_TOKEN=n1,Oc(n,s),_S(t,[".claude/settings.local.json",".claude/.cc-switcher.json"],"# agent switcher (local Claude Code model override)")}function m1(t,e,n){let r=Rc(t),s=rn(r)||{managedBy:"agent-switcher",fileExisted:!1,snapshot:{}};s.active={model:e,provider:n},Oc(r,s)}function NS(t){let e=_c(t),n=Rc(t),r=rn(n),s=rn(e);if(s?.env){let i=r?.snapshot||{};for(let o of PS){let a=i[o];a==null?delete s.env[o]:s.env[o]=a}if(Object.keys(s.env).length===0&&delete s.env,r?.fileExisted===!1&&Object.keys(s).length===0)try{TS(e,{force:!0})}catch{}else Oc(e,s)}try{TS(n,{force:!0})}catch{}}async function g1(){let t=!!process.env.OPENROUTER_API_KEY,e=[];try{e=(await vt()).filter(r=>r.provider==="openrouter"&&!kp(r.name)).map(r=>({id:r.name,label:r.friendlyName||r.name}))}catch(r){console.error("[switcher] model list failed",X(r))}let n=e.length?void 0:Fd()??void 0;return{hasKey:t,models:e,error:n}}async function y1(){if(Hr&&pt)return{active:!0,managed:!0,model:pt,port:qn,provider:Jn,routedModel:Ti,caching:Ci,reasoning:Oi,externalBaseUrl:null};let t=rn(_c(Z))?.env||{};return{active:!1,managed:!1,model:null,port:null,provider:null,routedModel:null,caching:"unknown",reasoning:Oi,externalBaseUrl:t.ANTHROPIC_BASE_URL||null}}async function LS(t,e){let n=await f1();return pt=t,Jn=e,h1(Z,n),n}async function b1({model:t}){if(!process.env.OPENROUTER_API_KEY)return{ok:!1,error:"OPENROUTER_API_KEY not set \u2014 add a key first"};if(!t)return{ok:!1,error:"no model given"};if(kp(t))return{ok:!1,error:"Refusing to route an Anthropic model through OpenRouter \u2014 that bills full API rate with no caching. Use it on your Anthropic subscription instead."};try{await LS(t,xp[t]??null),Ti=null,Ci="unknown",m1(Z,t,Jn)}catch(e){return{ok:!1,error:`failed to start the wire proxy: ${X(e)}`}}return{ok:!0}}async function w1({level:t}){return t!=null&&(!Number.isInteger(t)||t<0||t>=bp.length)?{ok:!1,error:`reasoning level must be 0\u2013${bp.length-1} or null`}:(Oi=t,{ok:!0,level:t})}async function v1(){return NS(Z),pt=null,Jn=null,Ti=null,Ci="unknown",{ok:!0}}async function S1({key:t}){let e=(t||"").trim();if(!e)return{ok:!1,error:"empty key"};let n=Z,r=Pc(n,".env"),s="";try{s=vp(r,"utf8")}catch{}try{if(/^\s*OPENROUTER_API_KEY\s*=/m.test(s))CS(r,s.replace(/^\s*OPENROUTER_API_KEY\s*=.*$/m,`OPENROUTER_API_KEY=${e}`));else{let i=s&&!s.endsWith(`
2086
2091
  `)?`
2087
- `:"";iS(r,i+`OPENROUTER_API_KEY=${e}
2088
- `)}}catch(i){return{ok:!1,error:V(i)}}return process.env.OPENROUTER_API_KEY=e,aS(n,[".env"],"# secrets"),{ok:!0}}function N$(){if(!(!Fr&&!dt)){try{dS(X)}catch{}A$()}}function L$(t,e){return pS.test(e)?"blocked by your OpenRouter data policy":t===401||t===403||/unauthor|invalid api key|no auth|forbidden/i.test(e)?"auth rejected \u2014 check your OpenRouter key":t===404||/not a valid model|no such model|unknown model|model not found/i.test(e)?"model not found on this route":t===429||/rate limit/i.test(e)?"rate limited":t===402||/insufficient|credit|quota|balance/i.test(e)?"out of credits / quota":e.slice(0,160)}function M$(t){if(pS.test(t))return"This model's only provider(s) require prompt logging/training, which your OpenRouter account disallows by default. Allow it (or that provider) at openrouter.ai/settings/privacy, then probe again."}function D$(t,e,n){if(!t)return{works:null,read:0,note:n?`couldn't re-test on ${n} \u2014 caching unconfirmed`:"caching unconfirmed"};let r=lp(e?.cache_read_input_tokens)||lp(e?.prompt_tokens_details?.cached_tokens),s=e?.cache_read_input_tokens!==void 0||e?.cache_creation_input_tokens!==void 0||e?.prompt_tokens_details!==void 0;return r>0?{works:!0,read:r,note:`${r} tokens read from cache on the 2nd call`}:s?{works:!1,read:r,note:"no cache reads after a warm call \u2014 every turn re-bills the full context"}:{works:null,read:r,note:"route doesn't report cache usage \u2014 caching almost certainly not honored"}}async function B$({model:t}){let e=process.env.OPENROUTER_API_KEY;if(!e)return{ok:!1,error:"OPENROUTER_API_KEY not set \u2014 add a key first"};if(!t)return{ok:!1,error:"no model given"};if(dp(t))return{ok:!1,error:"Anthropic model \u2014 not offered or probed via OpenRouter"};let n=Date.now(),r=Array(350).fill("Caching probe filler sentence; its only purpose is to exceed the prompt-cache minimum token threshold.").join(" "),s={"content-type":"application/json",authorization:`Bearer ${e}`,"anthropic-version":"2023-06-01"},i={model:t,max_tokens:64,system:[{type:"text",text:r,cache_control:{type:"ephemeral"}}],messages:[{role:"user",content:"Reply with exactly: ok"}]},o=async a=>{let l=new AbortController,c=setTimeout(()=>l.abort(),2e4);try{let f=JSON.stringify(a?{...i,provider:lS(a)}:i),d=await fetch(up,{method:"POST",signal:l.signal,headers:s,body:f}),u=await d.json().catch(()=>({}));return{r:d,j:u}}finally{clearTimeout(c)}};try{let{r:a,j:l}=await o();if(!a.ok){let b=l?.error?.message||l?.message||JSON.stringify(l).slice(0,300);return{ok:!0,callable:!1,status:a.status,ms:Date.now()-n,error:L$(a.status,b),restriction:M$(b)}}let c=typeof l?.provider=="string"?l.provider:void 0,f=l?.content?.find?.(b=>b.type==="text")?.text??l?.content?.[0]?.text??"ok",d=lp(l?.usage?.cache_creation_input_tokens),{r:u,j:p}=await o(c),{works:h,read:m,note:g}=D$(u.ok,p?.usage,c);return h===!0&&c&&(fp[t]=c,dt===t&&(Un=c)),{ok:!0,callable:!0,status:a.status,ms:Date.now()-n,provider:c,sample:String(f).trim().slice(0,60),cache:{works:h,created:d,read:m,note:g}}}catch(a){let l=V(a);return{ok:!0,callable:!1,ms:Date.now()-n,error:/abort/i.test(l)?"timed out (20s)":l}}}var p$,up,h$,m$,oS,g$,ap,xl,El,vl,dp,Fr,Fn,dt,Un,vi,Si,ki,fp,lp,lS,pS,hS=S(()=>{"use strict";$n();Zt();Kt();p$="https://openrouter.ai/api",up=`${p$}/v1/messages`,h$="typebulb-proxy-managed",m$="The typebulb model override was reverted to Anthropic, but this Claude Code session still points at the now-idle proxy. Reload the window (VS Code/Cursor: \u201CDeveloper: Reload Window\u201D) or relaunch `claude` in a terminal to return to your Anthropic subscription.",oS=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"],g$=5e3,ap=["low","medium","high"],xl=t=>kl(t,".claude","settings.local.json"),El=t=>kl(t,".claude",".cc-switcher.json"),vl=t=>`http://127.0.0.1:${t}`;dp=t=>/^anthropic\//i.test(t)||/claude/i.test(t),Fr=null,Fn=null,dt=null,Un=null,vi=null,Si="unknown",ki=1,fp={},lp=t=>typeof t=="number"?t:0,lS=t=>({order:[t],allow_fallbacks:!1});pS=/data policy|no endpoints|no allowed providers|privacy|requires.*(training|logging|data)/i;(async function(){try{let e=nn(El(X)),n=e?.active?.model;if(!n)return;let s=(nn(xl(X))?.env||{}).ANTHROPIC_BASE_URL||"";if(!/127\.0\.0\.1|localhost/.test(s))return;let i=await fS(n,e.active.provider??fp[n]??null);console.log(`[switcher] re-adopted override after restart: ${n} via ${vl(i)}`)}catch(e){console.error("[switcher] boot reconcile failed",V(e))}})()});var gS={};Li(gS,{agentMessage:()=>Vo,attach:()=>K$,blockToMarkdown:()=>Yo,breakout:()=>Hf,capText:()=>_e,childStatus:()=>X$,cleanUserText:()=>Jt,clearSwitchModel:()=>I$,closeChild:()=>Y$,composerPasteRead:()=>V$,displayName:()=>j$,downloadSample:()=>np,firstLineDigest:()=>Be,git:()=>we,gitChangedFiles:()=>Of,gitDiff:()=>Pf,info:()=>F$,isHiddenTurn:()=>$s,launchBulb:()=>Xf,listBreakouts:()=>zf,listBulbFiles:()=>Vf,listChildren:()=>H$,listMyBulbs:()=>sp,listSamples:()=>tp,listSessions:()=>J$,listSwitchModels:()=>O$,logInlineStatus:()=>q$,openChild:()=>z$,openFile:()=>Kf,poll:()=>U$,predictTrustOf:()=>Qf,probeModel:()=>B$,pullRemoteBulb:()=>ip,pushLocalBulb:()=>op,readBulbLog:()=>ep,repoRoot:()=>Ln,saveOpenRouterKey:()=>$$,searchBulbs:()=>Gf,searchSessions:()=>W$,setBulbTrust:()=>Zf,setReasoning:()=>R$,setSwitchModel:()=>_$,shutdownSwitcher:()=>N$,stopBreakout:()=>Yf,summarizeTurn:()=>G$,switchState:()=>P$,toolResultDigest:()=>td});var mS,j$,F$,U$,q$,J$,W$,K$,H$,z$,Y$,V$,G$,X$,yS=S(()=>{"use strict";yl();Go();wl();Lr();hS();Go();Rs();mS=new ir,j$=mS.displayName,{info:F$,poll:U$,logInlineStatus:q$,listSessions:J$,searchSessions:W$,attach:K$,listChildren:H$,openChild:z$,closeChild:Y$,composerPasteRead:V$,summarizeTurn:G$,childStatus:X$}=jr(mS)});var wS={};Li(wS,{attach:()=>s1,breakout:()=>Hf,childStatus:()=>u1,closeChild:()=>a1,composerPasteRead:()=>l1,displayName:()=>Q$,downloadSample:()=>np,git:()=>we,gitChangedFiles:()=>Of,gitDiff:()=>Pf,info:()=>Z$,launchBulb:()=>Xf,listBreakouts:()=>zf,listBulbFiles:()=>Vf,listChildren:()=>i1,listMyBulbs:()=>sp,listSamples:()=>tp,listSessions:()=>n1,logInlineStatus:()=>t1,openChild:()=>o1,openFile:()=>Kf,poll:()=>e1,predictTrustOf:()=>Qf,pullRemoteBulb:()=>ip,pushLocalBulb:()=>op,readBulbLog:()=>ep,repoRoot:()=>Ln,searchBulbs:()=>Gf,searchSessions:()=>r1,setBulbTrust:()=>Zf,stopBreakout:()=>Yf,summarizeTurn:()=>c1});var bS,Q$,Z$,e1,t1,n1,r1,s1,i1,o1,a1,l1,c1,u1,vS=S(()=>{"use strict";yl();ud();wl();Lr();bS=new ar,Q$=bS.displayName,{info:Z$,poll:e1,logInlineStatus:t1,listSessions:n1,searchSessions:r1,attach:s1,listChildren:i1,openChild:o1,closeChild:a1,composerPasteRead:l1,summarizeTurn:c1,childStatus:u1}=jr(bS)});import{readFileSync as d1,writeFileSync as f1,mkdirSync as p1}from"fs";import{homedir as h1}from"os";import*as Al from"path";async function xS(){try{let t=await fetch(new URL("/api/tags",kS()).toString(),{signal:AbortSignal.timeout(m1)});return t.ok?((await t.json()).models??[]).map(n=>n.name).filter(n=>!!n):[]}catch{return[]}}function ES(t){let e;try{e=d1(t,"utf-8")}catch{return{json:void 0,unreadable:!1}}try{let n=JSON.parse(e);if(n&&typeof n=="object"&&!Array.isArray(n)){let r=n;return{json:r,unreadable:"providers"in r&&!pp(r)}}}catch{}return{json:void 0,unreadable:!0}}function pp(t){let e=t?.providers;return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function g1(t){let e=pp(t);if(!e||!("ollama"in e))return null;let n=e.ollama?.models;return Array.isArray(n)?n.map(r=>r?.id).filter(r=>typeof r=="string"):[]}async function AS(){let{json:t,unreadable:e}=ES(SS());return e?{installed:[],configured:null}:{installed:await xS(),configured:g1(t)}}async function TS(){let t=await xS();return t.length?y1(SS(),t,kS()):{ok:!1,error:"Ollama is not running (or has no models installed)"}}function y1(t,e,n){let{json:r,unreadable:s}=ES(t);if(s)return{ok:!1,error:`could not parse ${t} \u2014 edit the ollama provider there yourself`};let i={...r??{},providers:{...pp(r)??{},ollama:{baseUrl:`${n}/v1`,api:"openai-completions",apiKey:"ollama",models:e.map(o=>({id:o}))}}};try{p1(Al.dirname(t),{recursive:!0}),f1(t,JSON.stringify(i,null,2)+`
2089
- `)}catch(o){return{ok:!1,error:`could not write ${t}: ${V(o)}`}}return{ok:!0,count:e.length}}var m1,SS,kS,CS=S(()=>{"use strict";Zt();$n();m1=1500,SS=()=>Al.join(h1(),".pi","agent","models.json"),kS=()=>yr(process.env.OLLAMA_HOST??"http://localhost:11434")});var PS={};Li(PS,{attach:()=>E1,breakout:()=>Hf,closeChild:()=>C1,composerFiles:()=>R1,composerNew:()=>_1,composerPaste:()=>N1,composerPasteRead:()=>L1,composerRpc:()=>$1,composerSend:()=>O1,composerStop:()=>P1,composerUiRespond:()=>I1,displayName:()=>b1,downloadSample:()=>np,git:()=>we,gitChangedFiles:()=>Of,gitDiff:()=>Pf,info:()=>w1,launchBulb:()=>Xf,listBreakouts:()=>zf,listBulbFiles:()=>Vf,listChildren:()=>A1,listMyBulbs:()=>sp,listSamples:()=>tp,listSessions:()=>k1,logInlineStatus:()=>S1,ollamaOffer:()=>AS,ollamaSync:()=>TS,openChild:()=>T1,openFile:()=>Kf,poll:()=>v1,predictTrustOf:()=>Qf,pullRemoteBulb:()=>ip,pushLocalBulb:()=>op,readBulbLog:()=>ep,repoRoot:()=>Ln,searchBulbs:()=>Gf,searchSessions:()=>x1,setBulbTrust:()=>Zf,shutdownComposer:()=>D1,stopBreakout:()=>Yf,summarizeTurn:()=>M1});var OS,b1,w1,v1,S1,k1,x1,E1,A1,T1,C1,O1,P1,_1,R1,I1,$1,N1,L1,M1,D1,_S=S(()=>{"use strict";yl();Tf();wl();Lr();CS();OS=new Nr,b1=OS.displayName,{info:w1,poll:v1,logInlineStatus:S1,listSessions:k1,searchSessions:x1,attach:E1,listChildren:A1,openChild:T1,closeChild:C1,composerSend:O1,composerStop:P1,composerNew:_1,composerFiles:R1,composerUiRespond:I1,composerRpc:$1,composerPaste:N1,composerPasteRead:L1,summarizeTurn:M1,shutdownComposer:D1}=jr(OS)});import*as nx from"fs/promises";import*as Pt from"path";Mi();te();function Vu(t){if(!Ye.includes(t))throw new Error(`Unknown block kind '${t}' (one of: ${Ye.join(", ")})`);return t}function Ey(t){let e=[];for(let n of t){let r=n.indexOf("=");if(r<=0||r===n.length-1)throw new Error(`Expected <kind>=<source>, got '${n}' (e.g. data=results.json, or data=- for stdin)`);let s=Vu(n.slice(0,r));if(e.some(i=>i.kind===s))throw new Error(`Duplicate block kind '${s}' \u2014 each block can be written once per invocation`);e.push({kind:s,source:n.slice(r+1)})}if(e.filter(n=>n.source==="-").length>1)throw new Error("Only one <kind>=- can read stdin");return e}Go();ud();Tf();var Tl={claude:{adapter:()=>new ir,server:()=>Promise.resolve().then(()=>(yS(),gS))},codex:{adapter:()=>new ar,server:()=>Promise.resolve().then(()=>(vS(),wS))},pi:{adapter:()=>new Nr,server:()=>Promise.resolve().then(()=>(_S(),PS))}};function RS(t){return t in Tl}function Ur(){return Object.keys(Tl)}function qr(){return Object.fromEntries(Object.entries(Tl).map(([t,e])=>[t,e.adapter]))}function IS(t){return Tl[t].server()}var xi=qr();function $S(){for(let t of Object.values(xi))try{t().ensureHarnessSupport()}catch{}}function st(){for(let t of Object.keys(xi))try{if(xi[t]().detectsSelf())return t}catch{}}function NS(t){let e=Ur(),n=new Map(e.filter(i=>xi[i]).map(i=>[i,xi[i]()]));for(let[i,o]of n)if(o.detectsSelf())return{name:i};let r=[...n].filter(([,i])=>i.detectsInstalled()).map(([i])=>i);if(r.length===0)return{name:e[0]};if(r.length===1)return{name:r[0]};let s=i=>n.get(i).listSessionFiles(t).length>0;return{ambiguous:[...r].sort((i,o)=>Number(s(o))-Number(s(i)))}}var mp=5e3;function hp(t){try{return t()}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exit(1)}}function B1(t){let e=/^(\d+(?:\.\d+)?)([smh]?)$/.exec(t??""),n=e?Number(e[1])*{s:1e3,m:6e4,h:36e5,"":6e4}[e[2]]:0;return n>0?n:void 0}function LS(t){let n={subcommand:"run",file:"",watch:!0,open:process.env.TERM_PROGRAM==="vscode"||st()!==void 0?"link":"window",server:!1,trust:!1,noTrust:!1,force:!1,follow:!1,clear:!1,help:!1,version:!1,callArgs:[],hasArgsFlag:!1},r=["call","check","predict","logs","wait","stop","restart","trust","untrust","models","slug","send","pull","push","get","put","status","babysit"],s=t[0];if(s==="agent"||s?.startsWith("agent:")){n.subcommand="agent";let o=s.indexOf(":");if(o!==-1){let a=s.slice(o+1);a&&(n.agentTarget=a)}t=t.slice(1)}else s&&r.includes(s)&&(n.subcommand=s,t=t.slice(1));let i=[];for(let o=0;o<t.length;o++){let a=t[o];if(a==="--help"||a==="-h")n.help=!0;else if(a==="--version"||a==="-V")n.version=!0;else if(a==="--no-watch")n.watch=!1;else if(a==="--open")n.open="window";else if(a==="--no-open")n.open="none";else if(a==="--server")n.server=!0;else if(a==="--trust")n.trust=!0;else if(a==="--no-trust")n.noTrust=!0;else if(a==="--force")n.force=!0;else if(a==="--mode"){let l=t[++o];(!l||l.startsWith("-"))&&(console.error("Missing value for --mode (e.g. --mode staging)"),process.exit(1)),n.mode=l}else if(a==="--follow"||a==="-f")n.follow=!0;else if(a==="--clear")n.clear=!0;else if(a==="--run"){let l=t[++o];if(l==="latest")n.run="latest";else{let c=parseInt(l,10);(isNaN(c)||c<1)&&(console.error(`Invalid --run value: ${l} (a run number, or 'latest')`),process.exit(1)),n.run=c}}else if(a==="--bulbs")n.stopScope="bulbs";else if(a==="--agent")n.stopScope="agent";else if(a==="--global")n.stopScope="global";else if(a==="--wake")n.wake=!0;else if(a==="--match"){let l=t[++o];l===void 0&&(console.error("Missing value for --match (a literal substring new log lines must contain)"),process.exit(1)),n.match=l}else if(a==="--timeout"){let l=parseInt(t[++o],10);(isNaN(l)||l<=0)&&(console.error(`Invalid --timeout value: ${t[o]} (seconds)`),process.exit(1)),n.timeoutSec=l}else if(a==="--slow"){let l=B1(t[++o]);l===void 0&&(console.error(`Invalid --slow value: ${t[o]} (a duration, e.g. 90s, 8m, 1h)`),process.exit(1)),n.slowMs=l}else if(a==="--wait"||a.startsWith("--wait="))if(a.startsWith("--wait=")){let l=parseInt(a.slice(7),10);(isNaN(l)||l<=0)&&(console.error(`Invalid --wait value: ${a.slice(7)} (milliseconds)`),process.exit(1)),n.sendWaitMs=l}else n.sendWaitMs=mp;else if(a==="--lines"||a==="-n"){let l=parseInt(t[++o],10);(isNaN(l)||l<0)&&(console.error(`Invalid --lines value: ${t[o]}`),process.exit(1)),n.lines=l}else if(a==="--port"||a==="-p"){let l=t[++o],c=parseInt(l,10);isNaN(c)&&(console.error(`Invalid port: ${l}`),process.exit(1)),n.port=c}else if(a==="--replace"||a.startsWith("--replace=")){let l=a.startsWith("--replace=")?a.slice(10):t[++o]??"",c=hp(()=>Jp(l));n.local&&(console.error(`--replace can only be used once (got '${n.local.name}' and '${c.name}')`),process.exit(1)),n.local=c}else if(a==="--args"||a.startsWith("--args=")){n.hasArgsFlag=!0;let l=a.startsWith("--args=")?a.slice(7):t[++o];l===void 0&&(console.error("Missing value for --args (a JSON array, or - to read it from stdin)"),process.exit(1)),n.argsJson=l}else if(!a.startsWith("-")||a==="-"&&n.subcommand==="send")["call","send","get","put","slug","status"].includes(n.subcommand)?i.push(a):n.file=a;else{let l=n.subcommand==="call"?" (for a negative or dash-leading argument, use --args '<json-array>')":"";console.error(`Unknown option: ${a}${l}`),process.exit(1)}}return n.subcommand==="call"&&(i.length<2&&(console.error("Usage: typebulb call <file> <fn> [arg\u2026]"),process.exit(1)),n.file=i[0],n.fn=i[1],n.callArgs=i.slice(2)),n.subcommand==="send"&&(i.length<1&&(console.error("Usage: typebulb send <file> [message]"),process.exit(1)),n.file=i[0],n.sendMessage=i[1]),n.subcommand==="slug"&&(i.length||(console.error("Usage: typebulb slug <bulb name>"),process.exit(1)),n.slugName=i.join(" ")),n.subcommand==="status"&&i.length&&(n.statusQuery=i.join(" ")),n.subcommand==="get"&&(i.length!==2&&(console.error("Usage: typebulb get <file> <kind>"),process.exit(1)),n.file=i[0],n.blockKind=hp(()=>Vu(i[1]))),n.subcommand==="put"&&(i.length<2&&(console.error("Usage: typebulb put <file> <kind>=<source> [<kind>=<source> \u2026]"),process.exit(1)),n.file=i[0],n.blockPairs=hp(()=>Ey(i.slice(1)))),n}function MS(){console.log(`
2092
+ `:"";OS(r,i+`OPENROUTER_API_KEY=${e}
2093
+ `)}}catch(i){return{ok:!1,error:X(i)}}return process.env.OPENROUTER_API_KEY=e,_S(n,[".env"],"# secrets"),{ok:!0}}function k1(){if(!(!Hr&&!pt)){try{NS(Z)}catch{}p1()}}function x1(t,e){return MS.test(e)?"blocked by your OpenRouter data policy":t===401||t===403||/unauthor|invalid api key|no auth|forbidden/i.test(e)?"auth rejected \u2014 check your OpenRouter key":t===404||/not a valid model|no such model|unknown model|model not found/i.test(e)?"model not found on this route":t===429||/rate limit/i.test(e)?"rate limited":t===402||/insufficient|credit|quota|balance/i.test(e)?"out of credits / quota":e.slice(0,160)}function E1(t){if(MS.test(t))return"This model's only provider(s) require prompt logging/training, which your OpenRouter account disallows by default. Allow it (or that provider) at openrouter.ai/settings/privacy, then probe again."}function A1(t,e,n){if(!t)return{works:null,read:0,note:n?`couldn't re-test on ${n} \u2014 caching unconfirmed`:"caching unconfirmed"};let r=wp(e?.cache_read_input_tokens)||wp(e?.prompt_tokens_details?.cached_tokens),s=e?.cache_read_input_tokens!==void 0||e?.cache_creation_input_tokens!==void 0||e?.prompt_tokens_details!==void 0;return r>0?{works:!0,read:r,note:`${r} tokens read from cache on the 2nd call`}:s?{works:!1,read:r,note:"no cache reads after a warm call \u2014 every turn re-bills the full context"}:{works:null,read:r,note:"route doesn't report cache usage \u2014 caching almost certainly not honored"}}async function T1({model:t}){let e=process.env.OPENROUTER_API_KEY;if(!e)return{ok:!1,error:"OPENROUTER_API_KEY not set \u2014 add a key first"};if(!t)return{ok:!1,error:"no model given"};if(kp(t))return{ok:!1,error:"Anthropic model \u2014 not offered or probed via OpenRouter"};let n=Date.now(),r=Array(350).fill("Caching probe filler sentence; its only purpose is to exceed the prompt-cache minimum token threshold.").join(" "),s={"content-type":"application/json",authorization:`Bearer ${e}`,"anthropic-version":"2023-06-01"},i={model:t,max_tokens:64,system:[{type:"text",text:r,cache_control:{type:"ephemeral"}}],messages:[{role:"user",content:"Reply with exactly: ok"}]},o=async a=>{let c=new AbortController,l=setTimeout(()=>c.abort(),2e4);try{let f=JSON.stringify(a?{...i,provider:RS(a)}:i),u=await fetch(Sp,{method:"POST",signal:c.signal,headers:s,body:f}),d=await u.json().catch(()=>({}));return{r:u,j:d}}finally{clearTimeout(l)}};try{let{r:a,j:c}=await o();if(!a.ok){let b=c?.error?.message||c?.message||JSON.stringify(c).slice(0,300);return{ok:!0,callable:!1,status:a.status,ms:Date.now()-n,error:x1(a.status,b),restriction:E1(b)}}let l=typeof c?.provider=="string"?c.provider:void 0,f=c?.content?.find?.(b=>b.type==="text")?.text??c?.content?.[0]?.text??"ok",u=wp(c?.usage?.cache_creation_input_tokens),{r:d,j:p}=await o(l),{works:h,read:m,note:g}=A1(d.ok,p?.usage,l);return h===!0&&l&&(xp[t]=l,pt===t&&(Jn=l)),{ok:!0,callable:!0,status:a.status,ms:Date.now()-n,provider:l,sample:String(f).trim().slice(0,60),cache:{works:h,created:u,read:m,note:g}}}catch(a){let c=X(a);return{ok:!0,callable:!1,ms:Date.now()-n,error:/abort/i.test(c)?"timed out (20s)":c}}}var t1,Sp,n1,r1,PS,s1,bp,_c,Rc,Cc,kp,Hr,qn,pt,Jn,Ti,Ci,Oi,xp,wp,RS,MS,DS=k(()=>{"use strict";Qt();Zt();Wt();t1="https://openrouter.ai/api",Sp=`${t1}/v1/messages`,n1="typebulb-proxy-managed",r1="The typebulb model override was reverted to Anthropic, but this Claude Code session still points at the now-idle proxy. Reload the window (VS Code/Cursor: \u201CDeveloper: Reload Window\u201D) or relaunch `claude` in a terminal to return to your Anthropic subscription.",PS=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"],s1=5e3,bp=["low","medium","high"],_c=t=>Pc(t,".claude","settings.local.json"),Rc=t=>Pc(t,".claude",".cc-switcher.json"),Cc=t=>`http://127.0.0.1:${t}`;kp=t=>/^anthropic\//i.test(t)||/claude/i.test(t),Hr=null,qn=null,pt=null,Jn=null,Ti=null,Ci="unknown",Oi=1,xp={},wp=t=>typeof t=="number"?t:0,RS=t=>({order:[t],allow_fallbacks:!1});MS=/data policy|no endpoints|no allowed providers|privacy|requires.*(training|logging|data)/i;(async function(){try{let e=rn(Rc(Z)),n=e?.active?.model;if(!n)return;let s=(rn(_c(Z))?.env||{}).ANTHROPIC_BASE_URL||"";if(!/127\.0\.0\.1|localhost/.test(s))return;let i=await LS(n,e.active.provider??xp[n]??null);console.log(`[switcher] re-adopted override after restart: ${n} via ${Cc(i)}`)}catch(e){console.error("[switcher] boot reconcile failed",X(e))}})()});var jS={};qi(jS,{agentMessage:()=>na,answerAsk:()=>U1,attach:()=>$1,blockToMarkdown:()=>ta,board:()=>F1,breakout:()=>rp,capText:()=>Ie,childStatus:()=>j1,cleanUserText:()=>qt,clearSwitchModel:()=>v1,closeChild:()=>M1,composerPasteRead:()=>D1,displayName:()=>C1,downloadSample:()=>pp,firstLineDigest:()=>Fe,git:()=>Se,gitChangedFiles:()=>Nf,gitDiff:()=>Lf,info:()=>O1,isHiddenTurn:()=>Bs,launchBulb:()=>cp,listBreakouts:()=>sp,listBulbFiles:()=>op,listChildren:()=>N1,listMyBulbs:()=>mp,listSamples:()=>fp,listSessions:()=>R1,listSwitchModels:()=>g1,logInlineStatus:()=>_1,openChild:()=>L1,openFile:()=>np,poll:()=>P1,predictTrustOf:()=>lp,probeModel:()=>T1,pullRemoteBulb:()=>gp,pushLocalBulb:()=>yp,readBulbLog:()=>dp,repoRoot:()=>Mn,saveOpenRouterKey:()=>S1,searchBulbs:()=>ap,searchSessions:()=>I1,setBulbTrust:()=>up,setReasoning:()=>w1,setSwitchModel:()=>b1,shutdownSwitcher:()=>k1,stopBreakout:()=>ip,summarizeTurn:()=>B1,switchState:()=>y1,toolResultDigest:()=>ad});var BS,C1,O1,P1,_1,R1,I1,$1,N1,L1,M1,D1,B1,j1,F1,U1,FS=k(()=>{"use strict";Ec();ra();Tc();Br();DS();ra();Ms();BS=new cr,C1=BS.displayName,{info:O1,poll:P1,logInlineStatus:_1,listSessions:R1,searchSessions:I1,attach:$1,listChildren:N1,openChild:L1,closeChild:M1,composerPasteRead:D1,summarizeTurn:B1,childStatus:j1,board:F1,answerAsk:U1}=Kr(BS)});var qS={};qi(qS,{answerAsk:()=>nN,attach:()=>Y1,board:()=>tN,breakout:()=>rp,childStatus:()=>eN,closeChild:()=>X1,composerPasteRead:()=>Q1,displayName:()=>q1,downloadSample:()=>pp,git:()=>Se,gitChangedFiles:()=>Nf,gitDiff:()=>Lf,info:()=>J1,launchBulb:()=>cp,listBreakouts:()=>sp,listBulbFiles:()=>op,listChildren:()=>V1,listMyBulbs:()=>mp,listSamples:()=>fp,listSessions:()=>H1,logInlineStatus:()=>K1,openChild:()=>G1,openFile:()=>np,poll:()=>W1,predictTrustOf:()=>lp,pullRemoteBulb:()=>gp,pushLocalBulb:()=>yp,readBulbLog:()=>dp,repoRoot:()=>Mn,searchBulbs:()=>ap,searchSessions:()=>z1,setBulbTrust:()=>up,stopBreakout:()=>ip,summarizeTurn:()=>Z1});var US,q1,J1,W1,K1,H1,z1,Y1,V1,G1,X1,Q1,Z1,eN,tN,nN,JS=k(()=>{"use strict";Ec();gd();Tc();Br();US=new ur,q1=US.displayName,{info:J1,poll:W1,logInlineStatus:K1,listSessions:H1,searchSessions:z1,attach:Y1,listChildren:V1,openChild:G1,closeChild:X1,composerPasteRead:Q1,summarizeTurn:Z1,childStatus:eN,board:tN,answerAsk:nN}=Kr(US)});import{readFileSync as rN,writeFileSync as sN,mkdirSync as iN}from"fs";import{homedir as oN}from"os";import*as Ic from"path";async function HS(){try{let t=await fetch(new URL("/api/tags",KS()).toString(),{signal:AbortSignal.timeout(aN)});return t.ok?((await t.json()).models??[]).map(n=>n.name).filter(n=>!!n):[]}catch{return[]}}function zS(t){let e;try{e=rN(t,"utf-8")}catch{return{json:void 0,unreadable:!1}}try{let n=JSON.parse(e);if(n&&typeof n=="object"&&!Array.isArray(n)){let r=n;return{json:r,unreadable:"providers"in r&&!Ep(r)}}}catch{}return{json:void 0,unreadable:!0}}function Ep(t){let e=t?.providers;return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function cN(t){let e=Ep(t);if(!e||!("ollama"in e))return null;let n=e.ollama?.models;return Array.isArray(n)?n.map(r=>r?.id).filter(r=>typeof r=="string"):[]}async function YS(){let{json:t,unreadable:e}=zS(WS());return e?{installed:[],configured:null}:{installed:await HS(),configured:cN(t)}}async function VS(){let t=await HS();return t.length?lN(WS(),t,KS()):{ok:!1,error:"Ollama is not running (or has no models installed)"}}function lN(t,e,n){let{json:r,unreadable:s}=zS(t);if(s)return{ok:!1,error:`could not parse ${t} \u2014 edit the ollama provider there yourself`};let i={...r??{},providers:{...Ep(r)??{},ollama:{baseUrl:`${n}/v1`,api:"openai-completions",apiKey:"ollama",models:e.map(o=>({id:o}))}}};try{iN(Ic.dirname(t),{recursive:!0}),sN(t,JSON.stringify(i,null,2)+`
2094
+ `)}catch(o){return{ok:!1,error:`could not write ${t}: ${X(o)}`}}return{ok:!0,count:e.length}}var aN,WS,KS,GS=k(()=>{"use strict";Zt();Qt();aN=1500,WS=()=>Ic.join(oN(),".pi","agent","models.json"),KS=()=>vr(process.env.OLLAMA_HOST??"http://localhost:11434")});var QS={};qi(QS,{answerAsk:()=>_N,attach:()=>gN,board:()=>PN,breakout:()=>rp,closeChild:()=>wN,composerFiles:()=>xN,composerNew:()=>kN,composerPaste:()=>TN,composerPasteRead:()=>CN,composerRpc:()=>AN,composerSend:()=>vN,composerStop:()=>SN,composerUiRespond:()=>EN,displayName:()=>uN,downloadSample:()=>pp,git:()=>Se,gitChangedFiles:()=>Nf,gitDiff:()=>Lf,info:()=>dN,launchBulb:()=>cp,listBreakouts:()=>sp,listBulbFiles:()=>op,listChildren:()=>yN,listMyBulbs:()=>mp,listSamples:()=>fp,listSessions:()=>hN,logInlineStatus:()=>pN,ollamaOffer:()=>YS,ollamaSync:()=>VS,openChild:()=>bN,openFile:()=>np,poll:()=>fN,predictTrustOf:()=>lp,pullRemoteBulb:()=>gp,pushLocalBulb:()=>yp,readBulbLog:()=>dp,repoRoot:()=>Mn,searchBulbs:()=>ap,searchSessions:()=>mN,setBulbTrust:()=>up,shutdownComposer:()=>RN,stopBreakout:()=>ip,summarizeTurn:()=>ON});var XS,uN,dN,fN,pN,hN,mN,gN,yN,bN,wN,vN,SN,kN,xN,EN,AN,TN,CN,ON,PN,_N,RN,ZS=k(()=>{"use strict";Ec();If();Tc();Br();GS();XS=new Dr,uN=XS.displayName,{info:dN,poll:fN,logInlineStatus:pN,listSessions:hN,searchSessions:mN,attach:gN,listChildren:yN,openChild:bN,closeChild:wN,composerSend:vN,composerStop:SN,composerNew:kN,composerFiles:xN,composerUiRespond:EN,composerRpc:AN,composerPaste:TN,composerPasteRead:CN,summarizeTurn:ON,board:PN,answerAsk:_N,shutdownComposer:RN}=Kr(XS)});import*as Tx from"fs/promises";import*as Pt from"path";Ji();re();function td(t){if(!Ve.includes(t))throw new Error(`Unknown block kind '${t}' (one of: ${Ve.join(", ")})`);return t}function Ny(t){let e=[];for(let n of t){let r=n.indexOf("=");if(r<=0||r===n.length-1)throw new Error(`Expected <kind>=<source>, got '${n}' (e.g. data=results.json, or data=- for stdin)`);let s=td(n.slice(0,r));if(e.some(i=>i.kind===s))throw new Error(`Duplicate block kind '${s}' \u2014 each block can be written once per invocation`);e.push({kind:s,source:n.slice(r+1)})}if(e.filter(n=>n.source==="-").length>1)throw new Error("Only one <kind>=- can read stdin");return e}ra();gd();If();var $c={claude:{adapter:()=>new cr,server:()=>Promise.resolve().then(()=>(FS(),jS))},codex:{adapter:()=>new ur,server:()=>Promise.resolve().then(()=>(JS(),qS))},pi:{adapter:()=>new Dr,server:()=>Promise.resolve().then(()=>(ZS(),QS))}};function ek(t){return t in $c}function zr(){return Object.keys($c)}function Yr(){return Object.fromEntries(Object.entries($c).map(([t,e])=>[t,e.adapter]))}function tk(t){return $c[t].server()}var Pi=Yr();function nk(){for(let t of Object.values(Pi))try{t().ensureHarnessSupport()}catch{}}function it(){for(let t of Object.keys(Pi))try{if(Pi[t]().detectsSelf())return t}catch{}}function rk(t){let e=zr(),n=new Map(e.filter(i=>Pi[i]).map(i=>[i,Pi[i]()]));for(let[i,o]of n)if(o.detectsSelf())return{name:i};let r=[...n].filter(([,i])=>i.detectsInstalled()).map(([i])=>i);if(r.length===0)return{name:e[0]};if(r.length===1)return{name:r[0]};let s=i=>n.get(i).listSessionFiles(t).length>0;return{ambiguous:[...r].sort((i,o)=>Number(s(o))-Number(s(i)))}}var Tp=5e3;function Ap(t){try{return t()}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exit(1)}}function IN(t){let e=/^(\d+(?:\.\d+)?)([smh]?)$/.exec(t??""),n=e?Number(e[1])*{s:1e3,m:6e4,h:36e5,"":6e4}[e[2]]:0;return n>0?n:void 0}function sk(t){let n={subcommand:"run",file:"",watch:!0,open:process.env.TERM_PROGRAM==="vscode"||it()!==void 0?"link":"window",server:!1,trust:!1,noTrust:!1,force:!1,follow:!1,clear:!1,help:!1,version:!1,callArgs:[],hasArgsFlag:!1},r=["call","check","predict","logs","wait","stop","restart","trust","untrust","models","slug","send","pull","push","get","put","status","babysit"],s=t[0];if(s==="agent"||s?.startsWith("agent:")){n.subcommand="agent";let o=s.indexOf(":");if(o!==-1){let a=s.slice(o+1);a&&(n.agentTarget=a)}t=t.slice(1)}else s&&r.includes(s)&&(n.subcommand=s,t=t.slice(1));let i=[];for(let o=0;o<t.length;o++){let a=t[o];if(a==="--help"||a==="-h")n.help=!0;else if(a==="--version"||a==="-V")n.version=!0;else if(a==="--no-watch")n.watch=!1;else if(a==="--open")n.open="window";else if(a==="--no-open")n.open="none";else if(a==="--server")n.server=!0;else if(a==="--trust")n.trust=!0;else if(a==="--no-trust")n.noTrust=!0;else if(a==="--force")n.force=!0;else if(a==="--mode"){let c=t[++o];(!c||c.startsWith("-"))&&(console.error("Missing value for --mode (e.g. --mode staging)"),process.exit(1)),n.mode=c}else if(a==="--follow"||a==="-f")n.follow=!0;else if(a==="--clear")n.clear=!0;else if(a==="--run"){let c=t[++o];if(c==="latest")n.run="latest";else{let l=parseInt(c,10);(isNaN(l)||l<1)&&(console.error(`Invalid --run value: ${c} (a run number, or 'latest')`),process.exit(1)),n.run=l}}else if(a==="--bulbs")n.stopScope="bulbs";else if(a==="--agent")n.stopScope="agent";else if(a==="--global")n.stopScope="global";else if(a==="--wake")n.wake=!0;else if(a==="--match"){let c=t[++o];c===void 0&&(console.error("Missing value for --match (a literal substring new log lines must contain)"),process.exit(1)),n.match=c}else if(a==="--timeout"){let c=parseInt(t[++o],10);(isNaN(c)||c<=0)&&(console.error(`Invalid --timeout value: ${t[o]} (seconds)`),process.exit(1)),n.timeoutSec=c}else if(a==="--slow"){let c=IN(t[++o]);c===void 0&&(console.error(`Invalid --slow value: ${t[o]} (a duration, e.g. 90s, 8m, 1h)`),process.exit(1)),n.slowMs=c}else if(a==="--wait"||a.startsWith("--wait="))if(a.startsWith("--wait=")){let c=parseInt(a.slice(7),10);(isNaN(c)||c<=0)&&(console.error(`Invalid --wait value: ${a.slice(7)} (milliseconds)`),process.exit(1)),n.sendWaitMs=c}else n.sendWaitMs=Tp;else if(a==="--lines"||a==="-n"){let c=parseInt(t[++o],10);(isNaN(c)||c<0)&&(console.error(`Invalid --lines value: ${t[o]}`),process.exit(1)),n.lines=c}else if(a==="--port"||a==="-p"){let c=t[++o],l=parseInt(c,10);isNaN(l)&&(console.error(`Invalid port: ${c}`),process.exit(1)),n.port=l}else if(a==="--replace"||a.startsWith("--replace=")){let c=a.startsWith("--replace=")?a.slice(10):t[++o]??"",l=Ap(()=>Zp(c));n.local&&(console.error(`--replace can only be used once (got '${n.local.name}' and '${l.name}')`),process.exit(1)),n.local=l}else if(a==="--args"||a.startsWith("--args=")){n.hasArgsFlag=!0;let c=a.startsWith("--args=")?a.slice(7):t[++o];c===void 0&&(console.error("Missing value for --args (a JSON array, or - to read it from stdin)"),process.exit(1)),n.argsJson=c}else if(!a.startsWith("-")||a==="-"&&n.subcommand==="send")["call","send","get","put","slug","status"].includes(n.subcommand)?i.push(a):n.file=a;else{let c=n.subcommand==="call"?" (for a negative or dash-leading argument, use --args '<json-array>')":"";console.error(`Unknown option: ${a}${c}`),process.exit(1)}}return n.subcommand==="call"&&(i.length<2&&(console.error("Usage: typebulb call <file> <fn> [arg\u2026]"),process.exit(1)),n.file=i[0],n.fn=i[1],n.callArgs=i.slice(2)),n.subcommand==="send"&&(i.length<1&&(console.error("Usage: typebulb send <file> [message]"),process.exit(1)),n.file=i[0],n.sendMessage=i[1]),n.subcommand==="slug"&&(i.length||(console.error("Usage: typebulb slug <bulb name>"),process.exit(1)),n.slugName=i.join(" ")),n.subcommand==="status"&&i.length&&(n.statusQuery=i.join(" ")),n.subcommand==="get"&&(i.length!==2&&(console.error("Usage: typebulb get <file> <kind>"),process.exit(1)),n.file=i[0],n.blockKind=Ap(()=>td(i[1]))),n.subcommand==="put"&&(i.length<2&&(console.error("Usage: typebulb put <file> <kind>=<source> [<kind>=<source> \u2026]"),process.exit(1)),n.file=i[0],n.blockPairs=Ap(()=>Ny(i.slice(1)))),n}function ik(){console.log(`
2090
2095
  typebulb - Local bulb runner for Typebulb
2091
2096
 
2092
2097
  Usage:
@@ -2181,10 +2186,11 @@ Usage:
2181
2186
  failing repeatedly, uncommitted files. Name it by
2182
2187
  id or a piece of its description; no arg: the
2183
2188
  session's overview. Claude Code, Codex.
2184
- typebulb babysit Watch your sub-agents and stay silent until one
2185
- needs you (an idle stall, a slow call, a
2186
- background call left running, a failure streak),
2187
- then print it and exit.
2189
+ typebulb babysit Watch your session and stay silent until it
2190
+ needs you (a sub-agent's idle stall, slow call,
2191
+ background call left running, failure streak or
2192
+ overrun time box; or the user's answer on the
2193
+ mirror's board), then print it and exit.
2188
2194
  Run it in the background; the exit is your
2189
2195
  wake-up. Run it again after handling it:
2190
2196
  what came up meanwhile fires at once.
@@ -2279,7 +2285,7 @@ Examples:
2279
2285
  typebulb my-editor.bulb.md
2280
2286
  typebulb --no-watch my-editor.bulb.md
2281
2287
  typebulb .
2282
- `)}At();qs();Mi();Ks();At();import*as We from"path";import{spawn as fN,execSync as pN}from"child_process";import{createRequire as hN}from"module";import{existsSync as mN}from"fs";import*as xe from"fs/promises";import*as ve from"path";var gp=[{name:"es5"},{name:"es2015.core"},{name:"es2015.collection"},{name:"es2015.promise"},{name:"es2015.iterable"},{name:"es2015.symbol"},{name:"es2015.symbol.wellknown"},{name:"es2015.generator"},{name:"es2015.proxy"},{name:"es2015.reflect"},{name:"es2016.array.include"},{name:"es2016.intl"},{name:"es2017.object"},{name:"es2017.string"},{name:"es2017.sharedmemory"},{name:"es2017.typedarrays"},{name:"es2017.date"},{name:"es2017.intl"},{name:"es2018.asynciterable"},{name:"es2018.asyncgenerator"},{name:"es2018.promise"},{name:"es2018.regexp"},{name:"es2018.intl"},{name:"es2019.array"},{name:"es2019.object"},{name:"es2019.string"},{name:"es2019.symbol"},{name:"es2019.intl"},{name:"es2020.bigint"},{name:"es2020.promise"},{name:"es2020.string"},{name:"es2020.sharedmemory"},{name:"es2020.date"},{name:"es2020.number"},{name:"es2020.symbol.wellknown"},{name:"es2020.intl"},{name:"es2021.promise"},{name:"es2021.string"},{name:"es2021.weakref"},{name:"es2021.intl"},{name:"es2022.array"},{name:"es2022.object"},{name:"es2022.error"},{name:"es2022.string"},{name:"es2022.regexp"},{name:"es2022.intl"},{name:"es2023.array"},{name:"es2023.collection"},{name:"es2023.intl",since:"5.5"},{name:"es2024.arraybuffer",since:"5.5"},{name:"es2024.collection",since:"5.5"},{name:"es2024.object",since:"5.5"},{name:"es2024.promise",since:"5.5"},{name:"es2024.regexp",since:"5.5"},{name:"es2024.sharedmemory",since:"5.5"},{name:"es2024.string",since:"5.5"},{name:"esnext.array",since:"5.5"},{name:"esnext.collection"},{name:"esnext.decorators"},{name:"esnext.disposable"},{name:"esnext.error",since:"5.5"},{name:"esnext.float16",since:"5.5"},{name:"esnext.iterator",since:"5.5"},{name:"esnext.object"},{name:"esnext.promise"},{name:"esnext.sharedmemory",since:"5.5"},{name:"esnext.intl"}],yp=[{name:"dom"},{name:"dom.iterable"},{name:"dom.asynciterable"}];function bp(t,e){if(!e)return t.filter(s=>!s.since);let n={"5.0":0,"5.5":1},r=n[e];return t.filter(s=>!s.since||n[s.since]<=r)}te();var j1=`
2288
+ `)}Tt();zs();Ji();Gs();Tt();import*as He from"path";import{spawn as oL,execSync as aL}from"child_process";import{createRequire as cL}from"module";import{existsSync as lL}from"fs";import*as Ae from"fs/promises";import*as ke from"path";var Cp=[{name:"es5"},{name:"es2015.core"},{name:"es2015.collection"},{name:"es2015.promise"},{name:"es2015.iterable"},{name:"es2015.symbol"},{name:"es2015.symbol.wellknown"},{name:"es2015.generator"},{name:"es2015.proxy"},{name:"es2015.reflect"},{name:"es2016.array.include"},{name:"es2016.intl"},{name:"es2017.object"},{name:"es2017.string"},{name:"es2017.sharedmemory"},{name:"es2017.typedarrays"},{name:"es2017.date"},{name:"es2017.intl"},{name:"es2018.asynciterable"},{name:"es2018.asyncgenerator"},{name:"es2018.promise"},{name:"es2018.regexp"},{name:"es2018.intl"},{name:"es2019.array"},{name:"es2019.object"},{name:"es2019.string"},{name:"es2019.symbol"},{name:"es2019.intl"},{name:"es2020.bigint"},{name:"es2020.promise"},{name:"es2020.string"},{name:"es2020.sharedmemory"},{name:"es2020.date"},{name:"es2020.number"},{name:"es2020.symbol.wellknown"},{name:"es2020.intl"},{name:"es2021.promise"},{name:"es2021.string"},{name:"es2021.weakref"},{name:"es2021.intl"},{name:"es2022.array"},{name:"es2022.object"},{name:"es2022.error"},{name:"es2022.string"},{name:"es2022.regexp"},{name:"es2022.intl"},{name:"es2023.array"},{name:"es2023.collection"},{name:"es2023.intl",since:"5.5"},{name:"es2024.arraybuffer",since:"5.5"},{name:"es2024.collection",since:"5.5"},{name:"es2024.object",since:"5.5"},{name:"es2024.promise",since:"5.5"},{name:"es2024.regexp",since:"5.5"},{name:"es2024.sharedmemory",since:"5.5"},{name:"es2024.string",since:"5.5"},{name:"esnext.array",since:"5.5"},{name:"esnext.collection"},{name:"esnext.decorators"},{name:"esnext.disposable"},{name:"esnext.error",since:"5.5"},{name:"esnext.float16",since:"5.5"},{name:"esnext.iterator",since:"5.5"},{name:"esnext.object"},{name:"esnext.promise"},{name:"esnext.sharedmemory",since:"5.5"},{name:"esnext.intl"}],Op=[{name:"dom"},{name:"dom.iterable"},{name:"dom.asynciterable"}];function Pp(t,e){if(!e)return t.filter(s=>!s.since);let n={"5.0":0,"5.5":1},r=n[e];return t.filter(s=>!s.since||n[s.since]<=r)}re();var $N=`
2283
2289
  /**
2284
2290
  * Get raw data chunk from the Data tab.
2285
2291
  * @param index - Chunk index (0-based). Separate chunks with 2 blank lines.
@@ -2290,7 +2296,7 @@ Examples:
2290
2296
  * @param index - Chunk index (0-based)
2291
2297
  * @throws If chunk is not valid JSON/JSON-ish
2292
2298
  */
2293
- json<T = unknown>(index: number): T;`,F1=`
2299
+ json<T = unknown>(index: number): T;`,NN=`
2294
2300
  /**
2295
2301
  * Get the insight data produced by the inference layer.
2296
2302
  *
@@ -2299,7 +2305,7 @@ Examples:
2299
2305
  *
2300
2306
  * @returns The parsed insight JSON, or undefined if no insight is available
2301
2307
  */
2302
- insight<T = unknown>(): T | undefined;`,U1=`
2308
+ insight<T = unknown>(): T | undefined;`,LN=`
2303
2309
  /**
2304
2310
  * Replace the data this run is working on.
2305
2311
  *
@@ -2322,7 +2328,7 @@ Examples:
2322
2328
  *
2323
2329
  * @param value - Any JSON-serializable value
2324
2330
  */
2325
- setInsight(value: unknown): Promise<void>;`,DS=`options: {
2331
+ setInsight(value: unknown): Promise<void>;`,ok=`options: {
2326
2332
  messages: Array<{ role: "user" | "assistant"; content: string }>;
2327
2333
  system?: string;
2328
2334
  /** Reasoning effort: 0=minimal, 1=low, 2=med, 3=high, 4=xhigh. Mapped to each provider's native mechanism (OpenAI/OpenRouter reasoning effort, Gemini thinking level, Anthropic adaptive thinking). 0 reaches the vendor's explicit off switch, and floors to a little thinking only on always-thinking models. 4 reaches the rung above high where the vendor has one (OpenAI/OpenRouter xhigh, Anthropic max) and clamps to high where it doesn't (Gemini) \u2014 never an error. Pin 1 (low) for most work; pick 0 deliberately, when you want the raw model or latency is the constraint. Omitting is NOT off \u2014 it buys the model's own default (medium on GPT-5.6), which reasons and bills invisibly. Ignored on the courtesy model, which runs at the level Typebulb sets. */
@@ -2333,7 +2339,7 @@ Examples:
2333
2339
  webSearch?: boolean;
2334
2340
  /** Abort the request. On abort the promise rejects / the stream ends. */
2335
2341
  signal?: AbortSignal;
2336
- }`,BS=`
2342
+ }`,ak=`
2337
2343
  /** Provider-reported token counts for one call \u2014 real usage from the API, never an estimate.
2338
2344
  * \`output\` is total billed output (reasoning included); \`reasoning\` is the itemized subset where
2339
2345
  * the provider splits it (OpenAI, Gemini, OpenRouter \u2014 Anthropic doesn't); \`cacheRead\` is the
@@ -2345,10 +2351,10 @@ type AiChunk =
2345
2351
  | { kind: "text"; text: string }
2346
2352
  | { kind: "reasoning"; text: string }
2347
2353
  | { kind: "usage"; usage: AiUsage };
2348
- `,jS=`
2354
+ `,ck=`
2349
2355
  /** What backs \`tb.ai\`: the user's own keys, the quota-limited courtesy model, or nothing. */
2350
2356
  type AiAccess = "own" | "courtesy" | "none";
2351
- `,FS=`
2357
+ `,lk=`
2352
2358
  /**
2353
2359
  * General-purpose AI call. \`tb.ai(opts)\` resolves with the full text; \`tb.ai.stream(opts)\`
2354
2360
  * returns an async iterable of {@link AiChunk} deltas you consume with \`for await\`.
@@ -2358,7 +2364,7 @@ type AiAccess = "own" | "courtesy" | "none";
2358
2364
  * @throws On rate limit, network error, or provider error
2359
2365
  */
2360
2366
  ai: {
2361
- (${DS}): Promise<{ text: string; usage?: AiUsage }>;
2367
+ (${ok}): Promise<{ text: string; usage?: AiUsage }>;
2362
2368
  /**
2363
2369
  * Streaming counterpart of \`tb.ai()\`. Yields \`{ kind: "text" | "reasoning", text }\` deltas
2364
2370
  * as they arrive, then one final \`{ kind: "usage", usage }\` chunk with the call's token
@@ -2375,8 +2381,8 @@ type AiAccess = "own" | "courtesy" | "none";
2375
2381
  * if (c.kind === "text") answer += c.text;
2376
2382
  * }
2377
2383
  */
2378
- stream(${DS}): AsyncIterable<AiChunk>;
2379
- };`,US=`
2384
+ stream(${ok}): AsyncIterable<AiChunk>;
2385
+ };`,uk=`
2380
2386
  /**
2381
2387
  * Returns AI models available to the current user.
2382
2388
  * Models are filtered by the user's configured API keys.
@@ -2406,7 +2412,7 @@ type AiAccess = "own" | "courtesy" | "none";
2406
2412
  * \`tb.mode\` or the length of \`tb.models()\` \u2014 which hosts offer a courtesy
2407
2413
  * model is the host's business and changes without your bulb changing.
2408
2414
  */
2409
- aiAccess(): Promise<AiAccess>;`,q1="\n /**\n * The bulb's theme override (`<html data-theme>`).\n *\n * - Get: the current override \u2014 `'dark'` | `'light'`, or `undefined` when\n * following the OS preference.\n * - Set `'dark'`/`'light'` to force and persist it (per-bulb); set\n * `undefined` to clear the override and follow the OS again.\n *\n * Drives `<html data-theme>`, so render off `html[data-theme=\"\u2026\"]` selectors\n * (or observe the attribute) rather than reading `tb.theme`.\n */\n theme: 'light' | 'dark' | undefined;",qS=`
2415
+ aiAccess(): Promise<AiAccess>;`,MN="\n /**\n * The bulb's theme override (`<html data-theme>`).\n *\n * - Get: the current override \u2014 `'dark'` | `'light'`, or `undefined` when\n * following the OS preference.\n * - Set `'dark'`/`'light'` to force and persist it (per-bulb); set\n * `undefined` to clear the override and follow the OS again.\n *\n * Drives `<html data-theme>`, so render off `html[data-theme=\"\u2026\"]` selectors\n * (or observe the attribute) rather than reading `tb.theme`.\n */\n theme: 'light' | 'dark' | undefined;",dk=`
2410
2416
  /**
2411
2417
  * The mode this bulb is running in.
2412
2418
  *
@@ -2416,7 +2422,7 @@ type AiAccess = "own" | "courtesy" | "none";
2416
2422
  * - \`'inline'\` \u2014 Running inline in an agent's transcript, rendered by the mirror
2417
2423
  * (sandboxed, client-only: AI, filesystem, and server RPC are unavailable)
2418
2424
  */
2419
- mode: ${yy};`,JS=`
2425
+ mode: ${Cy};`,fk=`
2420
2426
  /**
2421
2427
  * Local filesystem access (CLI only).
2422
2428
  *
@@ -2437,7 +2443,7 @@ type AiAccess = "own" | "courtesy" | "none";
2437
2443
  list(path?: string): Promise<Array<{ name: string; dir: boolean; mtime: number }>>;
2438
2444
  /** Remove a file, or a folder and everything in it. Throws if the path does not exist; the bulb's folder itself cannot be removed. */
2439
2445
  remove(path: string): Promise<boolean>;
2440
- };`,WS=`
2446
+ };`,pk=`
2441
2447
  /**
2442
2448
  * The bulb's folder \u2014 absolute path to \`<bulb-dir>/<filename-stem>/\`
2443
2449
  *
@@ -2445,7 +2451,7 @@ type AiAccess = "own" | "courtesy" | "none";
2445
2451
  * \`tb.fs\` already resolves relative paths against it, so bulb code writing
2446
2452
  * its own files never needs it. CLI only \u2014 throws in ide/published/inline mode.
2447
2453
  */
2448
- readonly dir: string;`,J1=`
2454
+ readonly dir: string;`,DN=`
2449
2455
  /**
2450
2456
  * Async value inspector for tensor-like objects.
2451
2457
  *
@@ -2498,49 +2504,50 @@ type AiAccess = "own" | "courtesy" | "none";
2498
2504
  *
2499
2505
  * @returns The full canonical URL
2500
2506
  */
2501
- url(): Promise<string>;`,W1="\n /**\n * Subscribe to a value pushed from the terminal via `typebulb send <file> [message]`.\n *\n * The dual of `tb.log` (data out): a value sent *in* from the CLI, no `--trust` required.\n * Use it to start expensive work on demand instead of on load \u2014 e.g. `tb.onMessage(() => start())`\n * \u2014 so hot reloads don't re-trigger it while you edit, and an agent kicks off one run when ready.\n *\n * The message is the JSON-parsed value of what `send` was given (or the raw string if it isn't\n * JSON; `undefined` for a bare `typebulb send <file>`). A non-`undefined` return value (awaited)\n * becomes the reply `send --wait` prints on stdout \u2014 JSON-serializable, at most one handler\n * replying \u2014 the structured read-back for self-tests. Returns an unsubscribe function. Inert in\n * an inline bulb (no sender) \u2014 the handler is registered but never fires.\n *\n * @param handler - Called with each pushed message; may return a JSON-serializable reply.\n * @returns An unsubscribe function.\n */\n onMessage(handler: (message: any) => unknown): () => void;",K1="\n /**\n * Print to the CLI's stdout \u2014 the bulb's log channel, read back with `typebulb logs <file>`.\n *\n * Ungated: needs no `server.ts` block and no `--trust`, so a Restricted client-only bulb can\n * instrument itself. Args cross to the CLI as JSON; where no CLI serves the page (web, inline,\n * or a transport failure) it falls back to the browser console. Works in `server.ts` too (same\n * as `console.log` there).\n */\n log(...args: any[]): void;",H1="\n /**\n * Server-side function proxy.\n *\n * In the CLI, calls exported functions from the `**server.ts**` section.\n *\n * A normal export is awaited for its result (`await tb.server.fn()`). An `async function*`\n * export streams: `for await (const chunk of tb.server.gen())`. The call object supports both;\n * break the `for await` to cancel and tear down the server generator.\n */\n server: Record<string, (...args: any[]) => Promise<any> & AsyncIterable<any>>;",wp=`${BS}${jS}
2507
+ url(): Promise<string>;`,BN="\n /**\n * Subscribe to a value pushed from the terminal via `typebulb send <file> [message]`.\n *\n * The dual of `tb.log` (data out): a value sent *in* from the CLI, no `--trust` required.\n * Use it to start expensive work on demand instead of on load \u2014 e.g. `tb.onMessage(() => start())`\n * \u2014 so hot reloads don't re-trigger it while you edit, and an agent kicks off one run when ready.\n *\n * The message is the JSON-parsed value of what `send` was given (or the raw string if it isn't\n * JSON; `undefined` for a bare `typebulb send <file>`). A non-`undefined` return value (awaited)\n * becomes the reply `send --wait` prints on stdout \u2014 JSON-serializable, at most one handler\n * replying \u2014 the structured read-back for self-tests. Returns an unsubscribe function. Inert in\n * an inline bulb (no sender) \u2014 the handler is registered but never fires.\n *\n * @param handler - Called with each pushed message; may return a JSON-serializable reply.\n * @returns An unsubscribe function.\n */\n onMessage(handler: (message: any) => unknown): () => void;",jN="\n /**\n * Print to the CLI's stdout \u2014 the bulb's log channel, read back with `typebulb logs <file>`.\n *\n * Ungated: needs no `server.ts` block and no `--trust`, so a Restricted client-only bulb can\n * instrument itself. Args cross to the CLI as JSON; where no CLI serves the page (web, inline,\n * or a transport failure) it falls back to the browser console. Works in `server.ts` too (same\n * as `console.log` there).\n */\n log(...args: any[]): void;",FN="\n /**\n * Server-side function proxy.\n *\n * In the CLI, calls exported functions from the `**server.ts**` section.\n *\n * A normal export is awaited for its result (`await tb.server.fn()`). An `async function*`\n * export streams: `for await (const chunk of tb.server.gen())`. The call object supports both;\n * break the `for await` to cancel and tear down the server generator.\n */\n server: Record<string, (...args: any[]) => Promise<any> & AsyncIterable<any>>;",_p=`${ak}${ck}
2502
2508
  /**
2503
2509
  * Typebulb utilities namespace.
2504
2510
  * Type \`tb.\` to discover available helpers.
2505
2511
  */
2506
- declare const tb: {${j1}${J1}${F1}${U1}${K1}${H1}${W1}${FS}${JS}${WS}${US}${q1}${qS}
2512
+ declare const tb: {${$N}${DN}${NN}${LN}${jN}${FN}${BN}${lk}${fk}${pk}${uk}${MN}${dk}
2507
2513
  };
2508
- `,z1=`
2514
+ `,UN=`
2509
2515
  /**
2510
2516
  * Print to the CLI's stdout \u2014 the same channel as \`console.log\` here (the server's console IS
2511
2517
  * the bulb's log). One log verb across blocks: page-side \`tb.log\` reaches this same stdout.
2512
2518
  */
2513
- log(...args: any[]): void;`,vp=`${BS}${jS}
2519
+ log(...args: any[]): void;`,Rp=`${ak}${ck}
2514
2520
  /**
2515
2521
  * Typebulb utilities namespace (server-side).
2516
2522
  * Type \`tb.\` to discover available helpers.
2517
2523
  */
2518
- declare const tb: {${z1}${FS}${JS}${WS}${US}${qS}
2524
+ declare const tb: {${UN}${lk}${fk}${pk}${uk}${dk}
2519
2525
  };
2520
- `;St();import X1 from"p-limit";St();import{resolve as HS}from"resolve.exports";var Ct={maxRelativeTypeRefs:500,maxBareDeps:8,maxBareDepth:3,prefetchConcurrency:4,negativeTtlMs:1e4},Ei=["index.d.ts","index.d.mts"],Sp=/\.d\.(ts|mts|cts)$/i;function Cl(t){return/\.d\.(ts|mts|cts)(?:[?#].*)?$/i.test(t)||/[?&]dts(?:[&#]|$)/i.test(t)}function KS(t){return[`${t}.d.ts`,`${t}.d.mts`]}function rn(t){if(!t||t==="./"||t==="/")return[...Ei];let e=t.replace(/\.(mjs|cjs|js|mts|cts|ts)$/i,""),n=KS(e),r=e.endsWith("/")?e:`${e}/`;return n.push(...KS(`${r}index`)),n}async function Jr(t,{retries:e=2,timeoutMs:n=15e3,init:r}={}){for(let s=0;s<=e;s++){let i=new AbortController,o=setTimeout(()=>i.abort(),n);try{let a=await fetch(t,{...r,signal:i.signal});if(Y1(a.status)&&s<e)continue;return a}catch{if(s<e)continue;return}finally{clearTimeout(o)}}}function Y1(t){return t===408||t===429||t>=500&&t<600}var Ol=class{constructor(e,n){this.fetchDts=e,this.cdnClient=n}async tryUrls(e){for(let n of e){let r=await this.fetchDts(n);if(r&&(this.looksLikeDts(r.dts)||Cl(r.url)))return r}}looksLikeDts(e){return/^\s*export\s*\{\s*\}\s*;?\s*$/m.test(e)?!0:/declare\s+(module|namespace|class|interface|function|const|var|let)/.test(e)||/interface\s+\w+/.test(e)||/type\s+\w+\s*=/.test(e)}async loadPackageAtVersionedRoot(e,n){let r=this.cdnClient.packageJson(new F({name:e,version:n})),s=await Jr(r);if(!s?.ok)return;let i;try{i=await s.json()}catch{return}if(i)return{pkg:i,baseDir:this.cdnClient.baseDir(new F({name:e,version:n??i.version})),version:n}}extractPathFromResult(e){if(typeof e=="string")return e;if(Array.isArray(e))return e.find(n=>typeof n=="string")}async tryUntilSuccess(e,n){for(let r of e){let s=await n(r);if(s)return s}}async resolveFromSelected(e,n,r){if(e.kind==="types"){let o=Pn(e.path);if(!o||o==="/"||o===".")return this.tryUntilSuccess([...Ei],n);if(!Sp.test(o)){let a=await this.tryUntilSuccess(rn(o),n);if(a)return a}return n(o)}let s=rn(e.path),i=r?.subpath?[...s,...Ei]:[...Ei,...s];return this.tryUntilSuccess(i,n)}toResolutionResult(e){return{kind:Sp.test(e)?"types":"probe",path:e}}resolveExportsPath(e,n){let r=n||".",s=e;try{let i=this.extractPathFromResult(HS(s,r,{conditions:["types"]}));if(i)return i}catch{}try{return this.extractPathFromResult(HS(s,r,{browser:!0,conditions:["import","default","module","browser","node"]}))}catch{return}}async resolve(e){try{let n=F.parse(e),{pkg:r,baseDir:s}=await this.loadPackageAtVersionedRoot(n.name,n.version)||{};if(!r||!s)return;let i={name:n.name,version:n.version},o=new F(i).format(),a=new F({...i,subpath:n.subpath}).format(),l=d=>this.fetchCandidateFrom(s,n.name,d);if(n.subpath){let d=ef(n.subpath),u=this.resolveExportsPath(r,d);if(u){let h=await this.resolveFromSelected(this.toResolutionResult(u),l,{subpath:!0});if(h)return{...h,resolvedPkg:a}}let p=await this.tryUntilSuccess(rn(d),l);if(p)return{...p,resolvedPkg:a}}let c=r.types??r.typings;if(c){let d=await this.resolveFromSelected({kind:"types",path:c},l);if(d)return{...d,resolvedPkg:o}}let f=this.resolveExportsPath(r,".");if(f){let d=await this.resolveFromSelected(this.toResolutionResult(f),l);if(d)return{...d,resolvedPkg:o}}return}catch{return}}async fetchCandidateFrom(e,n,r){let s=Pn(r),i=new URL(s,e).toString(),o=await this.tryUrls([i]);return o?{dts:o.dts,url:o.url,resolvedPkg:n}:void 0}};St();import{gunzipSync as V1}from"fflate";var Pl=class{async fetchAndExtract(e,n){let r=this.getTarballUrl(e,n),s=await Jr(r,{timeoutMs:3e4});if(!s?.ok)return new Map;let i=new Uint8Array(await s.arrayBuffer());return this.extractDtsFiles(i)}getTarballUrl(e,n){return`https://registry.npmjs.org/${e.replace("/","%2F")}/-/${e.split("/").pop()}-${n}.tgz`}normalizeTarPath(e){let n=e.replace(/^package\//,""),r=n.indexOf("/");return r>0?n.substring(r+1):n}extractDtsFiles(e){let n=new Map;try{let r=V1(e),s=new TextDecoder("utf-8"),i=0;for(;i<r.length-512;){let o=r.slice(i,i+512);if(o[0]===0)break;let a=o.slice(0,100),l=a.indexOf(0),c=s.decode(a.slice(0,l>0?l:100)).trim(),f=o.slice(124,136),d=s.decode(f).trim().replace(/\0/g,""),u=parseInt(d,8)||0,p=String.fromCharCode(o[156]);if(i+=512,(p==="0"||p==="\0")&&(c.endsWith(".d.ts")||c.endsWith(".d.mts"))){let h=r.slice(i,i+u);n.set(this.normalizeTarPath(c),s.decode(h))}i+=Math.ceil(u/512)*512}}catch{}return n}};var _l=class{constructor(e,n,r=new Pl){this.cdnClient=e,this.cache=n,this.tarballFetcher=r}typesNameCandidates(e){let n=e.startsWith("@")?e.slice(1).replace("/","__"):e;return n.includes(".")?[n,n.split(".").join("-"),n.split(".").join("")]:[n]}selectTypesVersion(e,n,r){try{if(r){let i=_n.majorOf(r),o=e.filter(a=>_n.majorOf(a)===i);if(o.length)return o.sort((a,l)=>_n.cmp(l,a))[0]}let s=n?.latest;return s&&e.includes(s)?s:e[0]}catch{return e[0]}}subpathCandidates(e){let n=e.replace(/\.(mjs|cjs|js|mts|cts|ts)$/i,""),r=rn(e);return n!==e&&r.push(`${e}.d.ts`,`${e}/index.d.ts`),r}async fetchFromVersionedRoot(e,n){let r=new F(e),s=r.version;if(!s)return;let i;try{i=await this.tarballFetcher.fetchAndExtract(r.name,s)}catch{return}if(!i||i.size===0)return;for(let[a,l]of i.entries()){let c=this.cdnClient.file(e,a);try{await this.cache.setCachedFile(c,l)}catch{}}let o=n.subpath?this.subpathCandidates(n.subpath):["index.d.ts"];for(let a of o){let l=i.get(a);if(l)return{dts:l,url:this.cdnClient.file(e,a),resolvedPkg:n.subpath?new F(n).format():n.name}}}async resolve(e){let n=F.parse(e);if(n.name)for(let r of this.typesNameCandidates(n.name)){let s=`@types/${r}`,i;try{i=await this.cdnClient.fetchVersionsIndex(s)}catch{continue}if(!i?.versions?.length)continue;let o=this.selectTypesVersion(i.versions,i.distTags,n.version),a=await this.fetchFromVersionedRoot(`${s}@${o}`,n);if(a)return a}}};var Rl=class{collectRelativeTypeRefs(e){return this.collectRefs(e).filter(n=>n.startsWith("./")||n.startsWith("../"))}collectBareModuleRefs(e){return this.collectRefs(e).filter(n=>this.isBare(n))}collectRefs(e){let n=e.split(`
2526
+ `;kt();import KN from"p-limit";kt();import{resolve as mk}from"resolve.exports";var Ct={maxRelativeTypeRefs:500,maxBareDeps:8,maxBareDepth:3,prefetchConcurrency:4,negativeTtlMs:1e4},_i=["index.d.ts","index.d.mts"],Ip=/\.d\.(ts|mts|cts)$/i;function Nc(t){return/\.d\.(ts|mts|cts)(?:[?#].*)?$/i.test(t)||/[?&]dts(?:[&#]|$)/i.test(t)}function hk(t){return[`${t}.d.ts`,`${t}.d.mts`]}function sn(t){if(!t||t==="./"||t==="/")return[..._i];let e=t.replace(/\.(mjs|cjs|js|mts|cts|ts)$/i,""),n=hk(e),r=e.endsWith("/")?e:`${e}/`;return n.push(...hk(`${r}index`)),n}async function Vr(t,{retries:e=2,timeoutMs:n=15e3,init:r}={}){for(let s=0;s<=e;s++){let i=new AbortController,o=setTimeout(()=>i.abort(),n);try{let a=await fetch(t,{...r,signal:i.signal});if(qN(a.status)&&s<e)continue;return a}catch{if(s<e)continue;return}finally{clearTimeout(o)}}}function qN(t){return t===408||t===429||t>=500&&t<600}var Lc=class{constructor(e,n){this.fetchDts=e,this.cdnClient=n}async tryUrls(e){for(let n of e){let r=await this.fetchDts(n);if(r&&(this.looksLikeDts(r.dts)||Nc(r.url)))return r}}looksLikeDts(e){return/^\s*export\s*\{\s*\}\s*;?\s*$/m.test(e)?!0:/declare\s+(module|namespace|class|interface|function|const|var|let)/.test(e)||/interface\s+\w+/.test(e)||/type\s+\w+\s*=/.test(e)}async loadPackageAtVersionedRoot(e,n){let r=this.cdnClient.packageJson(new U({name:e,version:n})),s=await Vr(r);if(!s?.ok)return;let i;try{i=await s.json()}catch{return}if(i)return{pkg:i,baseDir:this.cdnClient.baseDir(new U({name:e,version:n??i.version})),version:n}}extractPathFromResult(e){if(typeof e=="string")return e;if(Array.isArray(e))return e.find(n=>typeof n=="string")}async tryUntilSuccess(e,n){for(let r of e){let s=await n(r);if(s)return s}}async resolveFromSelected(e,n,r){if(e.kind==="types"){let o=Rn(e.path);if(!o||o==="/"||o===".")return this.tryUntilSuccess([..._i],n);if(!Ip.test(o)){let a=await this.tryUntilSuccess(sn(o),n);if(a)return a}return n(o)}let s=sn(e.path),i=r?.subpath?[...s,..._i]:[..._i,...s];return this.tryUntilSuccess(i,n)}toResolutionResult(e){return{kind:Ip.test(e)?"types":"probe",path:e}}resolveExportsPath(e,n){let r=n||".",s=e;try{let i=this.extractPathFromResult(mk(s,r,{conditions:["types"]}));if(i)return i}catch{}try{return this.extractPathFromResult(mk(s,r,{browser:!0,conditions:["import","default","module","browser","node"]}))}catch{return}}async resolve(e){try{let n=U.parse(e),{pkg:r,baseDir:s}=await this.loadPackageAtVersionedRoot(n.name,n.version)||{};if(!r||!s)return;let i={name:n.name,version:n.version},o=new U(i).format(),a=new U({...i,subpath:n.subpath}).format(),c=u=>this.fetchCandidateFrom(s,n.name,u);if(n.subpath){let u=af(n.subpath),d=this.resolveExportsPath(r,u);if(d){let h=await this.resolveFromSelected(this.toResolutionResult(d),c,{subpath:!0});if(h)return{...h,resolvedPkg:a}}let p=await this.tryUntilSuccess(sn(u),c);if(p)return{...p,resolvedPkg:a}}let l=r.types??r.typings;if(l){let u=await this.resolveFromSelected({kind:"types",path:l},c);if(u)return{...u,resolvedPkg:o}}let f=this.resolveExportsPath(r,".");if(f){let u=await this.resolveFromSelected(this.toResolutionResult(f),c);if(u)return{...u,resolvedPkg:o}}return}catch{return}}async fetchCandidateFrom(e,n,r){let s=Rn(r),i=new URL(s,e).toString(),o=await this.tryUrls([i]);return o?{dts:o.dts,url:o.url,resolvedPkg:n}:void 0}};kt();import{gunzipSync as JN}from"fflate";var Mc=class{async fetchAndExtract(e,n){let r=this.getTarballUrl(e,n),s=await Vr(r,{timeoutMs:3e4});if(!s?.ok)return new Map;let i=new Uint8Array(await s.arrayBuffer());return this.extractDtsFiles(i)}getTarballUrl(e,n){return`https://registry.npmjs.org/${e.replace("/","%2F")}/-/${e.split("/").pop()}-${n}.tgz`}normalizeTarPath(e){let n=e.replace(/^package\//,""),r=n.indexOf("/");return r>0?n.substring(r+1):n}extractDtsFiles(e){let n=new Map;try{let r=JN(e),s=new TextDecoder("utf-8"),i=0;for(;i<r.length-512;){let o=r.slice(i,i+512);if(o[0]===0)break;let a=o.slice(0,100),c=a.indexOf(0),l=s.decode(a.slice(0,c>0?c:100)).trim(),f=o.slice(124,136),u=s.decode(f).trim().replace(/\0/g,""),d=parseInt(u,8)||0,p=String.fromCharCode(o[156]);if(i+=512,(p==="0"||p==="\0")&&(l.endsWith(".d.ts")||l.endsWith(".d.mts"))){let h=r.slice(i,i+d);n.set(this.normalizeTarPath(l),s.decode(h))}i+=Math.ceil(d/512)*512}}catch{}return n}};var Dc=class{constructor(e,n,r=new Mc){this.cdnClient=e,this.cache=n,this.tarballFetcher=r}typesNameCandidates(e){let n=e.startsWith("@")?e.slice(1).replace("/","__"):e;return n.includes(".")?[n,n.split(".").join("-"),n.split(".").join("")]:[n]}selectTypesVersion(e,n,r){try{if(r){let i=In.majorOf(r),o=e.filter(a=>In.majorOf(a)===i);if(o.length)return o.sort((a,c)=>In.cmp(c,a))[0]}let s=n?.latest;return s&&e.includes(s)?s:e[0]}catch{return e[0]}}subpathCandidates(e){let n=e.replace(/\.(mjs|cjs|js|mts|cts|ts)$/i,""),r=sn(e);return n!==e&&r.push(`${e}.d.ts`,`${e}/index.d.ts`),r}async fetchFromVersionedRoot(e,n){let r=new U(e),s=r.version;if(!s)return;let i;try{i=await this.tarballFetcher.fetchAndExtract(r.name,s)}catch{return}if(!i||i.size===0)return;for(let[a,c]of i.entries()){let l=this.cdnClient.file(e,a);try{await this.cache.setCachedFile(l,c)}catch{}}let o=n.subpath?this.subpathCandidates(n.subpath):["index.d.ts"];for(let a of o){let c=i.get(a);if(c)return{dts:c,url:this.cdnClient.file(e,a),resolvedPkg:n.subpath?new U(n).format():n.name}}}async resolve(e){let n=U.parse(e);if(n.name)for(let r of this.typesNameCandidates(n.name)){let s=`@types/${r}`,i;try{i=await this.cdnClient.fetchVersionsIndex(s)}catch{continue}if(!i?.versions?.length)continue;let o=this.selectTypesVersion(i.versions,i.distTags,n.version),a=await this.fetchFromVersionedRoot(`${s}@${o}`,n);if(a)return a}}};var Bc=class{collectRelativeTypeRefs(e){return this.collectRefs(e).filter(n=>n.startsWith("./")||n.startsWith("../"))}collectBareModuleRefs(e){return this.collectRefs(e).filter(n=>this.isBare(n))}collectRefs(e){let n=e.split(`
2521
2527
  `).filter(s=>{let i=s.trimStart();return!(i.startsWith("*")||i.startsWith("//")||i.startsWith("/*"))}).join(`
2522
- `),r=new Set;for(let s of n.matchAll(/(import|export)\s+[^'"\n]*from\s*['"]([^'"\n]+)['"]/g))r.add(s[2]);for(let s of n.matchAll(/export\s*\*\s*from\s*['"]([^'"\n]+)['"]/g))r.add(s[1]);return Array.from(r)}isBare(e){return!(e.startsWith("./")||e.startsWith("../")||e.startsWith("file:")||e.startsWith("http://")||e.startsWith("https://"))}};St();var zS="file:///node_modules",Il=class{constructor(){this.epoch=0}bumpEpoch(){this.epoch+=1}epochDir(){return`__tsepoch_${this.epoch}`}pathForMain(e){return`${zS}/${this.epochDir()}/${e}/index.d.ts`}pathFor(e,n){let r=Pn(n);return`${zS}/${this.epochDir()}/${e}/${r}`}};import{LRUCache as G1}from"lru-cache";function YS(t){let e=new G1({ttl:Ct.negativeTtlMs,max:500}),n=new Map;return async function(s){try{if(await t.isNegative(s)||e.has(s))return;let i=await t.getCachedFile(s);if(i)return{dts:i,url:s};let o=n.get(s);if(o)return o;let a=(async()=>{let l=await Jr(s,{init:{cache:"no-store"}});if(!l?.ok){l?.status===404&&(e.set(s,!0),await t.recordNegative(s));return}let c=await l.text(),f=l.url||s;return await t.clearNegative(s),await t.setCachedFile(f,c),{dts:c,url:f}})();return n.set(s,a),await a.finally(()=>n.delete(s))}catch{return}}}var Ai=class{constructor(e){this.inFlight=new Map,this.scanner=new Rl,this.cache=e.cache,this.cdnClient=e.cdnClient,this.versionResolver=e.versionResolver,this.packageService=e.packageService,this.fetchDts=YS(e.cache),this.typescriptProvider=new Ol(this.fetchDts,e.cdnClient),this.definitelyTypedProvider=new _l(e.cdnClient,e.cache),this.virtualFs=new Il}withInFlight(e,n){let r=this.inFlight.get(e);if(r)return r;let s=n().finally(()=>this.inFlight.delete(e));return this.inFlight.set(e,s),s}invalidate(){this.virtualFs.bumpEpoch(),this.inFlight.clear()}pushFileIfNew(e,n,r){e.some(s=>s.path===n)||e.push({path:n,content:r})}createStubDef(e){let n=this.virtualFs.pathForMain(e);return{pkg:e,mainPath:n,files:[{path:n,content:"export const _shim: any; export default _shim;"}],shims:[{module:e,path:n}]}}async fetchViaProviders(e){for(let n of[this.typescriptProvider,this.definitelyTypedProvider])try{let r=await n.resolve(e);if(r?.dts)return r}catch{}}async fetchRootDts(e,n){let{effectivePackage:r,root:s,pinned:i}=await this.versionResolver.effectivePackage(e,n),o=await this.cache.getCachedDts(r);if(o?.content){let l=o.url??this.cdnClient.file(i?`${s}@${i}`:s,"index.d.ts");return{dts:o.content,url:l,resolvedPkg:r}}let a;try{a=await this.fetchViaProviders(r)}catch{return}if(!(!a?.dts||!a.url)&&new F(r).subpath===new F(a.resolvedPkg||r).subpath){try{await this.cache.setCachedDts(r,a.dts,a.url)}catch{}return a}}extractPackageRootUrl(e){let n=e.pathname.match(/^(.+@[^/]+\/)/);return n?new URL(n[1],e.origin):new URL("./",e)}toVirtualPath(e,n,r){let s=n.pathname.startsWith(e.pathname)?n.pathname.slice(e.pathname.length):`__deps__/${encodeURIComponent(n.toString()).replace(/%/g,"_")}.d.ts`;return this.virtualFs.pathFor(r,s)}computeEntryPath(e,n){if(!e)return{mainPath:this.virtualFs.pathForMain(n),packageRootUrl:void 0};let r=new URL(e),s=this.extractPackageRootUrl(r);return{mainPath:this.toVirtualPath(s,r,n),packageRootUrl:s}}async expandRelativeRefs(e,n,r,s,i=new Set,o){if(!i.has(n)&&(i.add(n),!(i.size>Ct.maxRelativeTypeRefs)))try{let a=new URL(n),l=new URL("./",a);o??(o=this.extractPackageRootUrl(a));let c=this.scanner.collectRelativeTypeRefs(e).slice(0,Ct.maxRelativeTypeRefs);for(let f of c)await this.tryRelativeRef(f,l,o,r,s,i)}catch{}}async tryRelativeRef(e,n,r,s,i,o){try{let a=new URL(e,n),l=a.pathname+a.search,c=Cl(l)?[l]:rn(l);for(let f of c){let u=new URL(f,a).toString();if(o.has(u))return;let p=await this.fetchDts(u);if(p?.dts){let h=this.toVirtualPath(r,new URL(p.url),s);this.pushFileIfNew(i,h,p.dts),await this.expandRelativeRefs(p.dts,p.url,s,i,o,r);return}}}catch{}}isDifferentPackage(e,n){return e===n?!1:new F(e).name!==new F(n).name}ambientlyDeclares(e,n){if(/^(?:import|export)\b/m.test(e))return!1;for(let r of e.matchAll(/declare\s+module\s+['"]([^'"]+)['"]/g)){let s=r[1];if(s===n||s.endsWith("/*")&&n.startsWith(s.slice(0,-1)))return!0}return!1}markFileAmbient(e,n){let r=e.find(s=>s.path===n);r&&(r.ambient=!0)}async prefetchBareDeps(e,n,r,s,i){try{let o=this.scanner.collectBareModuleRefs(e).slice(0,Ct.maxBareDeps).filter(c=>this.isDifferentPackage(c,n));if(!o.length)return;let a=new Set([n]),l=X1(Ct.prefetchConcurrency);await Promise.all(o.map(c=>l(()=>this.prefetchBareDepsRecursive(c,r,s,Ct.maxBareDepth,a,i).catch(()=>{}))))}catch{}}async prefetchBareDepsRecursive(e,n,r,s,i,o){if(s<=0||i.has(e))return;i.add(e);let a=await this.fetchRootDts(e,o);if(!a?.dts)return;let l=a.resolvedPkg||e,c=this.virtualFs.pathForMain(l);this.pushFileIfNew(n,c,a.dts),this.ambientlyDeclares(a.dts,e)?this.markFileAmbient(n,c):r.push({module:e,path:c}),a.url&&await this.expandRelativeRefs(a.dts,a.url,l,n);let f=this.scanner.collectBareModuleRefs(a.dts).slice(0,Ct.maxBareDeps).filter(d=>!i.has(d));for(let d of f)await this.prefetchBareDepsRecursive(d,n,r,s-1,i,o)}async resolve(e,n,r){let s=await this.packageService.extractImports(e),i=r?[...s,...r]:s;return(await Promise.all(i.map(a=>this.resolveOne(a,n)))).filter(a=>!!a)}async resolveOne(e,n){let{effectivePackage:r}=await this.versionResolver.effectivePackage(e,n);return this.withInFlight(r,async()=>{let s=new F(e),i=await this.fetchRootDts(e,n)??(s.subpath?await this.fetchRootDts(s.name,n):void 0);return i?this.buildDefFromContent(e,i,i.resolvedPkg||e,n):this.createStubDef(e)})}async buildDefFromContent(e,n,r,s){let{dts:i,url:o,resolvedPkg:a}=n,l=new F(a||r),c=l.version?`${l.name}@${l.version}`:l.name,{mainPath:f,packageRootUrl:d}=this.computeEntryPath(o,c),u=[{path:f,content:i}],p=[];o&&await this.expandRelativeRefs(i,o,c,u,void 0,d);let h=u.map(C=>C.content).join(`
2523
- `);await this.prefetchBareDeps(h,c,u,p,s);let m=l.format(),g=e===m?[e]:[e,m],b=g.some(C=>this.ambientlyDeclares(i,C));return b?this.markFileAmbient(u,f):p.push(...g.map(C=>({module:C,path:f}))),{pkg:e,mainPath:f,files:u,shims:p,ambient:b}}};df();St();Tr();ii();cf();Ar();import*as Wr from"path";var Q1=Wr.join(Ra,"pkg"),Z1=Wr.join(Ra,"files"),eN=Wr.join(Ra,"negative.json"),Nl=class{pkgMem=new Map;fileMem=new Map;negativeCache=new Rn(new Cr(eN));async getCachedDts(e){if(this.pkgMem.has(e))return this.pkgMem.get(e);await ne();let n=await kt(VS(e));return this.pkgMem.set(e,n),n}async setCachedDts(e,n,r){let s={content:n,url:r};this.pkgMem.set(e,s),await $l(async()=>{await ne(),await Fe(VS(e),JSON.stringify(s))})}async getCachedFile(e){if(this.fileMem.has(e))return this.fileMem.get(e);await ne();let n=await _a(GS(e));return this.fileMem.set(e,n),n}async setCachedFile(e,n){this.fileMem.set(e,n),await $l(async()=>{await ne(),await Fe(GS(e),n)})}isNegative(e){return this.negativeCache.isNegative(e)}async recordNegative(e){await $l(async()=>{await ne(),await this.negativeCache.recordNegative(e)})}clearNegative(e){return $l(()=>this.negativeCache.clearNegative(e))}};async function $l(t){try{await t()}catch{}}function VS(t){return Wr.join(Q1,tt(t)+".json")}function GS(t){return Wr.join(Z1,tt(t)+".txt")}Tr();var kp;function tN(){return kp||(kp=new Ai({cache:new Nl,cdnClient:Rw,packageService:La,versionResolver:_w})),kp}var XS="file:///node_modules/";async function QS(t){let e=Ia(t.emitKey,"typecheck");await ne(),await xe.rm(e,{recursive:!0,force:!0}),await xe.mkdir(e,{recursive:!0});let n=iN(t.jsxImportSource,t.dependencies),r=await tN().resolve(t.code,t.dependencies,n),s=t.local?.name,i=s?r.filter(f=>f.pkg!==s):r,o=new Set;for(let f of i)for(let d of f.files){let u=Ll(d.path);if(!u||o.has(u))continue;o.add(u);let p=ve.join(e,"node_modules",u);await xe.mkdir(ve.dirname(p),{recursive:!0}),await xe.writeFile(p,d.content,"utf8")}let a={};for(let f of i)for(let d of f.shims){let u=Ll(d.path);u&&(a[d.module]=[`./node_modules/${u}`])}for(let f of i){if(f.ambient)continue;let d=Ll(f.mainPath);d&&(a[f.pkg]=[`./node_modules/${d}`])}let l=new Set;for(let f of i)for(let d of f.files){if(!d.ambient)continue;let u=Ll(d.path);u&&l.add(`node_modules/${u}`)}if(t.local){delete a[t.local.name];let f=await oN(t.local,e);f?a[t.local.name]=[`./node_modules/${t.local.name}/${f}`]:console.warn(` local: '${t.local.name}' ships no type defs; check cannot type against it.`)}let c=nN(t.jsxImportSource,a,[...l]);return await xe.writeFile(ve.join(e,"tsconfig.json"),JSON.stringify(c,null,2)+`
2524
- `,"utf8"),await xe.writeFile(ve.join(e,"code.tsx"),t.code,"utf8"),await xe.writeFile(ve.join(e,"tb.d.ts"),wp,"utf8"),{dir:e}}var xp={target:"es2023",module:"esnext",moduleResolution:"bundler",strict:!0,noEmit:!0,skipLibCheck:!0,esModuleInterop:!0,allowSyntheticDefaultImports:!0,forceConsistentCasingInFileNames:!0};function nN(t,e,n=[]){return{compilerOptions:{...xp,lib:rN([...gp,...yp]),jsx:"react-jsx",jsxImportSource:t??"react",paths:e},include:["code.tsx","tb.d.ts",...n]}}function rN(t){return bp(t).map(e=>sN(e.name))}function sN(t){return t.split(".").map(e=>/^es\d+$/i.test(e)?e.toUpperCase():e==="dom"?"DOM":e==="esnext"?"ESNext":e.charAt(0).toUpperCase()+e.slice(1)).join(".")}function iN(t,e){let n=t??("react"in e?"react":void 0);return n?[`${n}/jsx-runtime`,`${n}/jsx-dev-runtime`]:[]}function Ll(t){if(!t.startsWith(XS))return;let e=t.slice(XS.length),n=e.indexOf("/");if(!(n<0))return e.slice(n+1)}async function oN(t,e){if(!t.typesAbs)return;let n=ve.dirname(t.typesAbs),r=ve.join(e,"node_modules",t.name);for(let s of await aN(n)){let i=ve.join(r,ve.relative(n,s));await xe.mkdir(ve.dirname(i),{recursive:!0}),await xe.copyFile(s,i)}return ve.basename(t.typesAbs)}async function aN(t){let e=[];async function n(r){let s=await xe.readdir(r,{withFileTypes:!0});for(let i of s){let o=ve.join(r,i.name);i.isDirectory()?await n(o):/\.d\.ts(\.map)?$/.test(i.name)&&e.push(o)}}return await n(t),e}import*as Je from"fs/promises";import*as Ot from"path";import{existsSync as lN}from"fs";Tr();pf();var cN="^22";async function ZS(t){let e=Ia(t.emitKey,"typecheck-server");await ne(),await Je.rm(e,{recursive:!0,force:!0}),await Je.mkdir(e,{recursive:!0});let n=Ot.join(t.bulbDir,".typebulb"),r=qa(t.server).filter(o=>o!==t.local?.name);await Ua([`@types/node@${cN}`,...r],n,t.dependencies,{ignoreScripts:!0});let s=Ot.join(n,"node_modules"),i=Ot.join(e,"node_modules");return await dN(s,i),await Je.writeFile(Ot.join(e,"server.ts"),t.server,"utf8"),await Je.writeFile(Ot.join(e,"tb.d.ts"),vp,"utf8"),await Je.writeFile(Ot.join(e,"tsconfig.json"),JSON.stringify(uN(t.local),null,2)+`
2525
- `,"utf8"),{dir:e}}function uN(t){let e={...xp,lib:["ES2023"],types:["node"]};if(t?.typesAbs){let n=i=>i.replace(/\\/g,"/"),r=n(Ot.dirname(t.typesAbs)),s=n(t.typesAbs).replace(/\.d\.ts$/,"");e.paths={[t.name]:[s],[`${t.name}/*`]:[`${r}/*`]}}return{compilerOptions:e,include:["server.ts","tb.d.ts"]}}async function dN(t,e){if(!lN(t)){await Je.mkdir(e,{recursive:!0});return}await Je.rm(e,{recursive:!0,force:!0});let n=process.platform==="win32"?"junction":"dir";await Je.symlink(t,e,n)}ga();te();async function tk(t,e){let{bulb:n,config:r,warnings:s,starts:i}=await rt(t),o=We.basename(t),a=m=>i.get(m)??1;!n.code&&!n.server&&(console.error("Bulb has neither **code.tsx** nor **server.ts**; nothing to check."),process.exit(1));let l=!1,c=!1;for(let m of s)console.log(`structure ${m}`);s.length&&(l=!0);let f=Rr(We.resolve(t)),d=f?nr(n.name):"";f&&d&&d!==f.slug&&(console.log(`naming filename '${f.slug}.bulb.md' doesn't match the title '${n.name}' \u2014 its slug derives to '${d}'. Rename the file to '${d}.bulb.md', or change name: to suit the filename.`),c=!0),n.code&&(l=ek(Js(n.code,{target:"client",dependencies:r.dependencies??{},lineOffset:a("code.tsx")}),"client")||l),n.server&&(l=ek(Js(n.server,{target:"server",lineOffset:a("server.ts")}),"server")||l);let u=wN([process.cwd(),We.dirname(t)]);if(!u){let m=We.relative(process.cwd(),t)||t;console.error("check: TypeScript not found \u2014 install it once, then re-run:"),console.error(" npm i -g typescript"),console.error(` typebulb check ${m}`),process.exit(2)}let p=[];if(n.code){let{dir:m}=await QS({code:n.code,dependencies:r.dependencies??{},jsxImportSource:r.ts?.jsxImportSource,emitKey:t,local:e});p.push({role:"client",dir:m})}if(n.server){let{dir:m}=await ZS({server:n.server,bulbDir:We.dirname(t),emitKey:t,local:e?{name:e.name,typesAbs:e.typesAbs}:void 0,dependencies:r.dependencies});p.push({role:"server",dir:m})}for(let{role:m,dir:g}of p){let{stdout:b,exitCode:C}=await yN(u,g);for(let T of b.split(/\r?\n/))T.trim()&&console.log(`${m} ${gN(T,o,a)}`);C!==0&&(l=!0)}l&&process.exit(1);let h=[n.code&&"code.tsx",n.server&&"server.ts"].filter(Boolean).join(", ");console.error(c?`\u2713 type-checks (${h}) \u2014 see the naming warning above`:`\u2713 no issues (${h})`)}function ek(t,e){for(let n of t)for(let r of n.message.split(`
2526
- `))console.log(`${e} ${r}`);return t.length>0}function gN(t,e,n){return t.replace(/\b(code\.tsx|server\.ts)\((\d+),(\d+)\)/g,(r,s,i,o)=>`${e}(${Number(i)+n(s)-1},${o})`)}function yN(t,e){return new Promise(n=>{let r=fN(process.execPath,[t,"--noEmit"],{cwd:e}),s="";r.stdout?.on("data",i=>{s+=i.toString()}),r.stderr?.on("data",i=>{s+=i.toString()}),r.on("close",i=>n({stdout:s,exitCode:i??1}))})}var bN=hN(import.meta.url);function wN(t){let e=r=>{try{let s=bN.resolve("typescript/package.json",{paths:r}),i=We.join(We.dirname(s),"lib","tsc.js");return mN(i)?i:void 0}catch{return}},n=e(t);if(n)return n;try{let r=pN("npm root -g",{encoding:"utf8"}).trim();return e([r])}catch{return}}At();ma();Ks();async function nk(t,e){let{bulb:n}=await rt(t),r=hr(n);if(En(t)){console.log("remembered-trusted \u2014 runs with filesystem / AI / server.ts automatically (`typebulb untrust` to revoke)."),r&&console.log(` (it uses ${r})`);return}r?(console.log(`This bulb appears to use ${r}; it runs Restricted unless you grant trust:`),console.log(` ${e}`)):console.log("No privileged capability detected \u2014 runs Restricted by default. (A clean scan is a hint, not a guarantee.)")}Ks();import*as Ti from"path";async function rk(t,e){if(!t){e||(console.error("Usage: typebulb untrust <file.bulb.md>"),process.exit(1));let r=$d();if(!r.length){console.log("No bulbs are remembered as trusted.");return}console.log("Trusted bulbs (run with fs/AI/server.ts without --trust):");for(let s of r)console.log(` ${s}`);return}let n=Ti.resolve(t);n.endsWith(".bulb.md")||(console.error("File must have .bulb.md extension"),process.exit(1));try{mr(n,e)}catch(r){console.error(r.message),process.exit(1)}console.log(e?`Trusted ${Ti.basename(n)} \u2014 runs with fs / AI / server.ts (no --trust needed).`:`Untrusted ${Ti.basename(n)} \u2014 runs Restricted.`),console.log(` ${n}`)}Ie();import*as ok from"readline";Xd();function Ep(t){let e=n=>r=>t?`\x1B[${n}m${r}\x1B[0m`:r;return{lit:e("38;5;70"),litLink:e("4;38;5;70"),brand:e("38;5;135")}}var vN=5e3,Ml=()=>Math.round(performance.now()),sk=t=>t>=1e3?`${(t/1e3).toFixed(1)}s`:`${t}ms`;async function ak(t){let e=NS(process.cwd()),n=Ml();if("ambiguous"in e){let r=await SN(t,e.ambiguous);return r?ik(t,r,{boot:n,from:Ml()}):kN(t,e.ambiguous)}return ik(t,e.name,{boot:n,from:Ml()})}async function ik(t,e,n){let r,s;try{r=await Us(e)}catch(p){s=p instanceof Error?p.message:String(p)}let i=Ml()-n.from,{lit:o,litLink:a,brand:l}=Ep(process.stdout.isTTY===!0),c=[" Read the authoring skill before writing a bulb:",` \u2022 ${o(Vs())}`],f=r?[` Agent mirror (${e}) is live\u{1F4A1}`,` ${o("\u25CF")} ${a(r.url)}`," Inline bulbs render live here."," Agents:",` Reusable app/tool \u2192 write a ${o(".bulb.md")}`," Show something inline \u2192 emit an inline bulb"," emit it with no .bulb.md draft first",...e==="codex"?[" verify it this turn \u2014 foreground-wait, bounded:",` \u2022 ${o('typebulb wait agent --match "[inline <name>" --timeout 120')}`," via exec_command; while it still runs,"," poll it with write_stdin until it exits"]:[e==="pi"?" arm a wait for its render verdict \u2014 run it plainly:":" background a wait for its render verdict:",` \u2022 ${o('typebulb wait agent --match "[inline <name>"')}`],...c," End this reply with the mirror link above"," \u2022 easy to miss the link mid-message"]:[` The mirror did not start (${s})`,` \u25CF Start it manually: ${o(`npx typebulb agent:${e}`)}`," Agents:",...c],d=n.boot+i>vN?[` slow launch: boot ${sk(n.boot)} \xB7 mirror ${sk(i)}`]:[],u=[` ${l(`typebulb v${t}`)}`,...d,...f,""];process.stdout.write(u.join(`
2528
+ `),r=new Set;for(let s of n.matchAll(/(import|export)\s+[^'"\n]*from\s*['"]([^'"\n]+)['"]/g))r.add(s[2]);for(let s of n.matchAll(/export\s*\*\s*from\s*['"]([^'"\n]+)['"]/g))r.add(s[1]);return Array.from(r)}isBare(e){return!(e.startsWith("./")||e.startsWith("../")||e.startsWith("file:")||e.startsWith("http://")||e.startsWith("https://"))}};kt();var gk="file:///node_modules",jc=class{constructor(){this.epoch=0}bumpEpoch(){this.epoch+=1}epochDir(){return`__tsepoch_${this.epoch}`}pathForMain(e){return`${gk}/${this.epochDir()}/${e}/index.d.ts`}pathFor(e,n){let r=Rn(n);return`${gk}/${this.epochDir()}/${e}/${r}`}};import{LRUCache as WN}from"lru-cache";function yk(t){let e=new WN({ttl:Ct.negativeTtlMs,max:500}),n=new Map;return async function(s){try{if(await t.isNegative(s)||e.has(s))return;let i=await t.getCachedFile(s);if(i)return{dts:i,url:s};let o=n.get(s);if(o)return o;let a=(async()=>{let c=await Vr(s,{init:{cache:"no-store"}});if(!c?.ok){c?.status===404&&(e.set(s,!0),await t.recordNegative(s));return}let l=await c.text(),f=c.url||s;return await t.clearNegative(s),await t.setCachedFile(f,l),{dts:l,url:f}})();return n.set(s,a),await a.finally(()=>n.delete(s))}catch{return}}}var Ri=class{constructor(e){this.inFlight=new Map,this.scanner=new Bc,this.cache=e.cache,this.cdnClient=e.cdnClient,this.versionResolver=e.versionResolver,this.packageService=e.packageService,this.fetchDts=yk(e.cache),this.typescriptProvider=new Lc(this.fetchDts,e.cdnClient),this.definitelyTypedProvider=new Dc(e.cdnClient,e.cache),this.virtualFs=new jc}withInFlight(e,n){let r=this.inFlight.get(e);if(r)return r;let s=n().finally(()=>this.inFlight.delete(e));return this.inFlight.set(e,s),s}invalidate(){this.virtualFs.bumpEpoch(),this.inFlight.clear()}pushFileIfNew(e,n,r){e.some(s=>s.path===n)||e.push({path:n,content:r})}createStubDef(e){let n=this.virtualFs.pathForMain(e);return{pkg:e,mainPath:n,files:[{path:n,content:"export const _shim: any; export default _shim;"}],shims:[{module:e,path:n}]}}async fetchViaProviders(e){for(let n of[this.typescriptProvider,this.definitelyTypedProvider])try{let r=await n.resolve(e);if(r?.dts)return r}catch{}}async fetchRootDts(e,n){let{effectivePackage:r,root:s,pinned:i}=await this.versionResolver.effectivePackage(e,n),o=await this.cache.getCachedDts(r);if(o?.content){let c=o.url??this.cdnClient.file(i?`${s}@${i}`:s,"index.d.ts");return{dts:o.content,url:c,resolvedPkg:r}}let a;try{a=await this.fetchViaProviders(r)}catch{return}if(!(!a?.dts||!a.url)&&new U(r).subpath===new U(a.resolvedPkg||r).subpath){try{await this.cache.setCachedDts(r,a.dts,a.url)}catch{}return a}}extractPackageRootUrl(e){let n=e.pathname.match(/^(.+@[^/]+\/)/);return n?new URL(n[1],e.origin):new URL("./",e)}toVirtualPath(e,n,r){let s=n.pathname.startsWith(e.pathname)?n.pathname.slice(e.pathname.length):`__deps__/${encodeURIComponent(n.toString()).replace(/%/g,"_")}.d.ts`;return this.virtualFs.pathFor(r,s)}computeEntryPath(e,n){if(!e)return{mainPath:this.virtualFs.pathForMain(n),packageRootUrl:void 0};let r=new URL(e),s=this.extractPackageRootUrl(r);return{mainPath:this.toVirtualPath(s,r,n),packageRootUrl:s}}async expandRelativeRefs(e,n,r,s,i=new Set,o){if(!i.has(n)&&(i.add(n),!(i.size>Ct.maxRelativeTypeRefs)))try{let a=new URL(n),c=new URL("./",a);o??(o=this.extractPackageRootUrl(a));let l=this.scanner.collectRelativeTypeRefs(e).slice(0,Ct.maxRelativeTypeRefs);for(let f of l)await this.tryRelativeRef(f,c,o,r,s,i)}catch{}}async tryRelativeRef(e,n,r,s,i,o){try{let a=new URL(e,n),c=a.pathname+a.search,l=Nc(c)?[c]:sn(c);for(let f of l){let d=new URL(f,a).toString();if(o.has(d))return;let p=await this.fetchDts(d);if(p?.dts){let h=this.toVirtualPath(r,new URL(p.url),s);this.pushFileIfNew(i,h,p.dts),await this.expandRelativeRefs(p.dts,p.url,s,i,o,r);return}}}catch{}}isDifferentPackage(e,n){return e===n?!1:new U(e).name!==new U(n).name}ambientlyDeclares(e,n){if(/^(?:import|export)\b/m.test(e))return!1;for(let r of e.matchAll(/declare\s+module\s+['"]([^'"]+)['"]/g)){let s=r[1];if(s===n||s.endsWith("/*")&&n.startsWith(s.slice(0,-1)))return!0}return!1}markFileAmbient(e,n){let r=e.find(s=>s.path===n);r&&(r.ambient=!0)}async prefetchBareDeps(e,n,r,s,i){try{let o=this.scanner.collectBareModuleRefs(e).slice(0,Ct.maxBareDeps).filter(l=>this.isDifferentPackage(l,n));if(!o.length)return;let a=new Set([n]),c=KN(Ct.prefetchConcurrency);await Promise.all(o.map(l=>c(()=>this.prefetchBareDepsRecursive(l,r,s,Ct.maxBareDepth,a,i).catch(()=>{}))))}catch{}}async prefetchBareDepsRecursive(e,n,r,s,i,o){if(s<=0||i.has(e))return;i.add(e);let a=await this.fetchRootDts(e,o);if(!a?.dts)return;let c=a.resolvedPkg||e,l=this.virtualFs.pathForMain(c);this.pushFileIfNew(n,l,a.dts),this.ambientlyDeclares(a.dts,e)?this.markFileAmbient(n,l):r.push({module:e,path:l}),a.url&&await this.expandRelativeRefs(a.dts,a.url,c,n);let f=this.scanner.collectBareModuleRefs(a.dts).slice(0,Ct.maxBareDeps).filter(u=>!i.has(u));for(let u of f)await this.prefetchBareDepsRecursive(u,n,r,s-1,i,o)}async resolve(e,n,r){let s=await this.packageService.extractImports(e),i=r?[...s,...r]:s;return(await Promise.all(i.map(a=>this.resolveOne(a,n)))).filter(a=>!!a)}async resolveOne(e,n){let{effectivePackage:r}=await this.versionResolver.effectivePackage(e,n);return this.withInFlight(r,async()=>{let s=new U(e),i=await this.fetchRootDts(e,n)??(s.subpath?await this.fetchRootDts(s.name,n):void 0);return i?this.buildDefFromContent(e,i,i.resolvedPkg||e,n):this.createStubDef(e)})}async buildDefFromContent(e,n,r,s){let{dts:i,url:o,resolvedPkg:a}=n,c=new U(a||r),l=c.version?`${c.name}@${c.version}`:c.name,{mainPath:f,packageRootUrl:u}=this.computeEntryPath(o,l),d=[{path:f,content:i}],p=[];o&&await this.expandRelativeRefs(i,o,l,d,void 0,u);let h=d.map(C=>C.content).join(`
2529
+ `);await this.prefetchBareDeps(h,l,d,p,s);let m=c.format(),g=e===m?[e]:[e,m],b=g.some(C=>this.ambientlyDeclares(i,C));return b?this.markFileAmbient(d,f):p.push(...g.map(C=>({module:C,path:f}))),{pkg:e,mainPath:f,files:d,shims:p,ambient:b}}};yf();kt();Pr();ui();mf();Or();import*as Gr from"path";var HN=Gr.join(Ba,"pkg"),zN=Gr.join(Ba,"files"),YN=Gr.join(Ba,"negative.json"),Uc=class{pkgMem=new Map;fileMem=new Map;negativeCache=new $n(new _r(YN));async getCachedDts(e){if(this.pkgMem.has(e))return this.pkgMem.get(e);await se();let n=await xt(bk(e));return this.pkgMem.set(e,n),n}async setCachedDts(e,n,r){let s={content:n,url:r};this.pkgMem.set(e,s),await Fc(async()=>{await se(),await qe(bk(e),JSON.stringify(s))})}async getCachedFile(e){if(this.fileMem.has(e))return this.fileMem.get(e);await se();let n=await Da(wk(e));return this.fileMem.set(e,n),n}async setCachedFile(e,n){this.fileMem.set(e,n),await Fc(async()=>{await se(),await qe(wk(e),n)})}isNegative(e){return this.negativeCache.isNegative(e)}async recordNegative(e){await Fc(async()=>{await se(),await this.negativeCache.recordNegative(e)})}clearNegative(e){return Fc(()=>this.negativeCache.clearNegative(e))}};async function Fc(t){try{await t()}catch{}}function bk(t){return Gr.join(HN,nt(t)+".json")}function wk(t){return Gr.join(zN,nt(t)+".txt")}Pr();var $p;function VN(){return $p||($p=new Ri({cache:new Uc,cdnClient:Uw,packageService:qa,versionResolver:Fw})),$p}var vk="file:///node_modules/";async function Sk(t){let e=ja(t.emitKey,"typecheck");await se(),await Ae.rm(e,{recursive:!0,force:!0}),await Ae.mkdir(e,{recursive:!0});let n=ZN(t.jsxImportSource,t.dependencies),r=await VN().resolve(t.code,t.dependencies,n),s=t.local?.name,i=s?r.filter(f=>f.pkg!==s):r,o=new Set;for(let f of i)for(let u of f.files){let d=qc(u.path);if(!d||o.has(d))continue;o.add(d);let p=ke.join(e,"node_modules",d);await Ae.mkdir(ke.dirname(p),{recursive:!0}),await Ae.writeFile(p,u.content,"utf8")}let a={};for(let f of i)for(let u of f.shims){let d=qc(u.path);d&&(a[u.module]=[`./node_modules/${d}`])}for(let f of i){if(f.ambient)continue;let u=qc(f.mainPath);u&&(a[f.pkg]=[`./node_modules/${u}`])}let c=new Set;for(let f of i)for(let u of f.files){if(!u.ambient)continue;let d=qc(u.path);d&&c.add(`node_modules/${d}`)}if(t.local){delete a[t.local.name];let f=await eL(t.local,e);f?a[t.local.name]=[`./node_modules/${t.local.name}/${f}`]:console.warn(` local: '${t.local.name}' ships no type defs; check cannot type against it.`)}let l=GN(t.jsxImportSource,a,[...c]);return await Ae.writeFile(ke.join(e,"tsconfig.json"),JSON.stringify(l,null,2)+`
2530
+ `,"utf8"),await Ae.writeFile(ke.join(e,"code.tsx"),t.code,"utf8"),await Ae.writeFile(ke.join(e,"tb.d.ts"),_p,"utf8"),{dir:e}}var Np={target:"es2023",module:"esnext",moduleResolution:"bundler",strict:!0,noEmit:!0,skipLibCheck:!0,esModuleInterop:!0,allowSyntheticDefaultImports:!0,forceConsistentCasingInFileNames:!0};function GN(t,e,n=[]){return{compilerOptions:{...Np,lib:XN([...Cp,...Op]),jsx:"react-jsx",jsxImportSource:t??"react",paths:e},include:["code.tsx","tb.d.ts",...n]}}function XN(t){return Pp(t).map(e=>QN(e.name))}function QN(t){return t.split(".").map(e=>/^es\d+$/i.test(e)?e.toUpperCase():e==="dom"?"DOM":e==="esnext"?"ESNext":e.charAt(0).toUpperCase()+e.slice(1)).join(".")}function ZN(t,e){let n=t??("react"in e?"react":void 0);return n?[`${n}/jsx-runtime`,`${n}/jsx-dev-runtime`]:[]}function qc(t){if(!t.startsWith(vk))return;let e=t.slice(vk.length),n=e.indexOf("/");if(!(n<0))return e.slice(n+1)}async function eL(t,e){if(!t.typesAbs)return;let n=ke.dirname(t.typesAbs),r=ke.join(e,"node_modules",t.name);for(let s of await tL(n)){let i=ke.join(r,ke.relative(n,s));await Ae.mkdir(ke.dirname(i),{recursive:!0}),await Ae.copyFile(s,i)}return ke.basename(t.typesAbs)}async function tL(t){let e=[];async function n(r){let s=await Ae.readdir(r,{withFileTypes:!0});for(let i of s){let o=ke.join(r,i.name);i.isDirectory()?await n(o):/\.d\.ts(\.map)?$/.test(i.name)&&e.push(o)}}return await n(t),e}import*as Ke from"fs/promises";import*as Ot from"path";import{existsSync as nL}from"fs";Pr();wf();var rL="^22";async function kk(t){let e=ja(t.emitKey,"typecheck-server");await se(),await Ke.rm(e,{recursive:!0,force:!0}),await Ke.mkdir(e,{recursive:!0});let n=Ot.join(t.bulbDir,".typebulb"),r=Va(t.server).filter(o=>o!==t.local?.name);await Ya([`@types/node@${rL}`,...r],n,t.dependencies,{ignoreScripts:!0});let s=Ot.join(n,"node_modules"),i=Ot.join(e,"node_modules");return await iL(s,i),await Ke.writeFile(Ot.join(e,"server.ts"),t.server,"utf8"),await Ke.writeFile(Ot.join(e,"tb.d.ts"),Rp,"utf8"),await Ke.writeFile(Ot.join(e,"tsconfig.json"),JSON.stringify(sL(t.local),null,2)+`
2531
+ `,"utf8"),{dir:e}}function sL(t){let e={...Np,lib:["ES2023"],types:["node"]};if(t?.typesAbs){let n=i=>i.replace(/\\/g,"/"),r=n(Ot.dirname(t.typesAbs)),s=n(t.typesAbs).replace(/\.d\.ts$/,"");e.paths={[t.name]:[s],[`${t.name}/*`]:[`${r}/*`]}}return{compilerOptions:e,include:["server.ts","tb.d.ts"]}}async function iL(t,e){if(!nL(t)){await Ke.mkdir(e,{recursive:!0});return}await Ke.rm(e,{recursive:!0,force:!0});let n=process.platform==="win32"?"junction":"dir";await Ke.symlink(t,e,n)}xa();re();async function Ek(t,e){let{bulb:n,config:r,warnings:s,starts:i}=await st(t),o=He.basename(t),a=m=>i.get(m)??1;!n.code&&!n.server&&(console.error("Bulb has neither **code.tsx** nor **server.ts**; nothing to check."),process.exit(1));let c=!1,l=!1;for(let m of s)console.log(`structure ${m}`);s.length&&(c=!0);let f=Nr(He.resolve(t)),u=f?sr(n.name):"";f&&u&&u!==f.slug&&(console.log(`naming filename '${f.slug}.bulb.md' doesn't match the title '${n.name}' \u2014 its slug derives to '${u}'. Rename the file to '${u}.bulb.md', or change name: to suit the filename.`),l=!0),n.code&&(c=xk(Ys(n.code,{target:"client",dependencies:r.dependencies??{},lineOffset:a("code.tsx")}),"client")||c),n.server&&(c=xk(Ys(n.server,{target:"server",lineOffset:a("server.ts")}),"server")||c);let d=pL([process.cwd(),He.dirname(t)]);if(!d){let m=He.relative(process.cwd(),t)||t;console.error("check: TypeScript not found \u2014 install it once, then re-run:"),console.error(" npm i -g typescript"),console.error(` typebulb check ${m}`),process.exit(2)}let p=[];if(n.code){let{dir:m}=await Sk({code:n.code,dependencies:r.dependencies??{},jsxImportSource:r.ts?.jsxImportSource,emitKey:t,local:e});p.push({role:"client",dir:m})}if(n.server){let{dir:m}=await kk({server:n.server,bulbDir:He.dirname(t),emitKey:t,local:e?{name:e.name,typesAbs:e.typesAbs}:void 0,dependencies:r.dependencies});p.push({role:"server",dir:m})}for(let{role:m,dir:g}of p){let{stdout:b,exitCode:C}=await dL(d,g);for(let T of b.split(/\r?\n/))T.trim()&&console.log(`${m} ${uL(T,o,a)}`);C!==0&&(c=!0)}c&&process.exit(1);let h=[n.code&&"code.tsx",n.server&&"server.ts"].filter(Boolean).join(", ");console.error(l?`\u2713 type-checks (${h}) \u2014 see the naming warning above`:`\u2713 no issues (${h})`)}function xk(t,e){for(let n of t)for(let r of n.message.split(`
2532
+ `))console.log(`${e} ${r}`);return t.length>0}function uL(t,e,n){return t.replace(/\b(code\.tsx|server\.ts)\((\d+),(\d+)\)/g,(r,s,i,o)=>`${e}(${Number(i)+n(s)-1},${o})`)}function dL(t,e){return new Promise(n=>{let r=oL(process.execPath,[t,"--noEmit"],{cwd:e}),s="";r.stdout?.on("data",i=>{s+=i.toString()}),r.stderr?.on("data",i=>{s+=i.toString()}),r.on("close",i=>n({stdout:s,exitCode:i??1}))})}var fL=cL(import.meta.url);function pL(t){let e=r=>{try{let s=fL.resolve("typescript/package.json",{paths:r}),i=He.join(He.dirname(s),"lib","tsc.js");return lL(i)?i:void 0}catch{return}},n=e(t);if(n)return n;try{let r=aL("npm root -g",{encoding:"utf8"}).trim();return e([r])}catch{return}}Tt();ka();Gs();async function Ak(t,e){let{bulb:n}=await st(t),r=yr(n);if(Tn(t)){console.log("remembered-trusted \u2014 runs with filesystem / AI / server.ts automatically (`typebulb untrust` to revoke)."),r&&console.log(` (it uses ${r})`);return}r?(console.log(`This bulb appears to use ${r}; it runs Restricted unless you grant trust:`),console.log(` ${e}`)):console.log("No privileged capability detected \u2014 runs Restricted by default. (A clean scan is a hint, not a guarantee.)")}Gs();import*as Ii from"path";async function Tk(t,e){if(!t){e||(console.error("Usage: typebulb untrust <file.bulb.md>"),process.exit(1));let r=jd();if(!r.length){console.log("No bulbs are remembered as trusted.");return}console.log("Trusted bulbs (run with fs/AI/server.ts without --trust):");for(let s of r)console.log(` ${s}`);return}let n=Ii.resolve(t);n.endsWith(".bulb.md")||(console.error("File must have .bulb.md extension"),process.exit(1));try{br(n,e)}catch(r){console.error(r.message),process.exit(1)}console.log(e?`Trusted ${Ii.basename(n)} \u2014 runs with fs / AI / server.ts (no --trust needed).`:`Untrusted ${Ii.basename(n)} \u2014 runs Restricted.`),console.log(` ${n}`)}$e();import*as Pk from"readline";rf();function Lp(t){let e=n=>r=>t?`\x1B[${n}m${r}\x1B[0m`:r;return{lit:e("38;5;70"),litLink:e("4;38;5;70"),brand:e("38;5;135")}}var hL=5e3,Jc=()=>Math.round(performance.now()),Ck=t=>t>=1e3?`${(t/1e3).toFixed(1)}s`:`${t}ms`;async function _k(t){let e=rk(process.cwd()),n=Jc();if("ambiguous"in e){let r=await mL(t,e.ambiguous);return r?Ok(t,r,{boot:n,from:Jc()}):gL(t,e.ambiguous)}return Ok(t,e.name,{boot:n,from:Jc()})}async function Ok(t,e,n){let r,s;try{r=await Hs(e)}catch(p){s=p instanceof Error?p.message:String(p)}let i=Jc()-n.from,{lit:o,litLink:a,brand:c}=Lp(process.stdout.isTTY===!0),l=[" Read the authoring skill before writing a bulb:",` \u2022 ${o(ei())}`],f=r?[` Agent mirror (${e}) is live\u{1F4A1}`,` ${o("\u25CF")} ${a(r.url)}`," Inline bulbs render live here."," Agents:",` Reusable app/tool \u2192 write a ${o(".bulb.md")}`," Show something inline \u2192 emit an inline bulb"," emit it with no .bulb.md draft first",...e==="codex"?[" verify it this turn \u2014 foreground-wait, bounded:",` \u2022 ${o('typebulb wait agent --match "[inline <name>" --timeout 120')}`," via exec_command; while it still runs,"," poll it with write_stdin until it exits"]:[e==="pi"?" arm a wait for its render verdict \u2014 run it plainly:":" background a wait for its render verdict:",` \u2022 ${o('typebulb wait agent --match "[inline <name>"')}`],...l," End this reply with the mirror link above"," \u2022 easy to miss the link mid-message"]:[` The mirror did not start (${s})`,` \u25CF Start it manually: ${o(`npx typebulb agent:${e}`)}`," Agents:",...l],u=n.boot+i>hL?[` slow launch: boot ${Ck(n.boot)} \xB7 mirror ${Ck(i)}`]:[],d=[` ${c(`typebulb v${t}`)}`,...u,...f,""];process.stdout.write(d.join(`
2527
2533
  `)+`
2528
- `)}async function SN(t,e){if(!process.stdin.isTTY||!process.stdout.isTTY)return;let{lit:n,brand:r}=Ep(!0),s=[` ${r(`typebulb v${t}`)}`," More than one agent harness is available here.",...e.map((o,a)=>` ${n(String(a+1))}) ${o}`),""];process.stdout.write(s.join(`
2534
+ `)}async function mL(t,e){if(!process.stdin.isTTY||!process.stdout.isTTY)return;let{lit:n,brand:r}=Lp(!0),s=[` ${r(`typebulb v${t}`)}`," More than one agent harness is available here.",...e.map((o,a)=>` ${n(String(a+1))}) ${o}`),""];process.stdout.write(s.join(`
2529
2535
  `)+`
2530
- `);let i=ok.createInterface({input:process.stdin,output:process.stdout});try{let o=(await new Promise(l=>i.question(" Open which? [1]: ",l))).trim();if(o==="")return e[0];let a=Number(o);return Number.isInteger(a)&&a>=1&&a<=e.length?e[a-1]:e.find(l=>l===o.toLowerCase())}finally{i.close()}}function kN(t,e){let{lit:n,brand:r}=Ep(process.stdout.isTTY===!0),s=[` ${r(`typebulb v${t}`)}`," More than one agent harness is available here."," Open the mirror for the one you want:",...e.map(i=>` \u2022 ${n(`npx typebulb agent:${i}`)}`),""];process.stdout.write(s.join(`
2536
+ `);let i=Pk.createInterface({input:process.stdin,output:process.stdout});try{let o=(await new Promise(c=>i.question(" Open which? [1]: ",c))).trim();if(o==="")return e[0];let a=Number(o);return Number.isInteger(a)&&a>=1&&a<=e.length?e[a-1]:e.find(c=>c===o.toLowerCase())}finally{i.close()}}function gL(t,e){let{lit:n,brand:r}=Lp(process.stdout.isTTY===!0),s=[` ${r(`typebulb v${t}`)}`," More than one agent harness is available here."," Open the mirror for the one you want:",...e.map(i=>` \u2022 ${n(`npx typebulb agent:${i}`)}`),""];process.stdout.write(s.join(`
2531
2537
  `)+`
2532
- `)}et();An();async function lk(t){be(t);let e=await wt();if(e.length>0){console.log(Gb(e,process.env.TB_AI_PROVIDER,process.env.TB_AI_MODEL));return}if(!Ld()){console.log("No AI provider keys found in this directory's .env, and no local Ollama server detected."),console.log("Set one of these to use a cloud model with tb.ai:");for(let[n,r]of Object.entries(gr))console.log(` ${r.padEnd(20)} (${n})`);console.log("\u2026or start Ollama (http://localhost:11434, or set OLLAMA_HOST) for local models. Then re-run `typebulb models`.");return}console.log("Couldn't fetch the model catalog (offline?). tb.ai still works with any valid provider/model id for your keys.")}te();function ck(t){t?.trim()||(console.error("Usage: typebulb slug <bulb name>"),process.exit(1));let e=nr(t);e||(console.error(`'${t}' has no slug \u2014 a bulb name needs at least one letter or digit.`),process.exit(1)),console.log(e)}je();import*as fk from"path";import{valid as dk,lt as EN}from"semver";Ie();var it={connected:"[page] connected",disconnected:"[page] disconnected",closed:t=>`[page] closed: ${t}`},Ap=3e3,uk=1e4,xN=2500,Dl=class{attached=new Set;leaving=new Set;arrivalWaiters=new Set;goneWaiters=new Set;arrivalSubs=[];settledEmpty;dropAt=0;get count(){return this.attached.size}get lastDropAt(){return this.dropAt}[Symbol.iterator](){return this.attached[Symbol.iterator]()}add(e,n){this.attached.add(e);for(let s of[...this.arrivalWaiters])s(!0);let r={page:e,firstAttach:n,count:this.attached.size};for(let s of this.arrivalSubs)s(r)}closing(e){this.attached.delete(e)&&this.leaving.add(e)}dropped(e){if(this.leaving.delete(e)){this.drainIfGone();return}if(!this.attached.delete(e))return;let n=this.dropAt=Date.now();setTimeout(()=>{this.attached.size===0&&this.dropAt===n&&this.settledEmpty?.()},Ap).unref()}async closeAll(e){let n=[...this.attached];if(!n.length)return{told:0,gone:0};await Promise.all(n.map(s=>s.close(e).catch(()=>{}))),await this.whenGone(n,xN);let r=n.filter(s=>!this.leaving.has(s)).length;for(let s of n)this.leaving.delete(s);return{told:n.length,gone:r}}whenArrives(e){return this.attached.size>0?Promise.resolve(!0):e>0?new Promise(n=>{let r=i=>{clearTimeout(s),this.arrivalWaiters.delete(r),n(i)},s=setTimeout(()=>r(!1),e);s.unref(),this.arrivalWaiters.add(r)}):Promise.resolve(!1)}onArrival(e){this.arrivalSubs.push(e)}onSettledEmpty(e){this.settledEmpty=e}whenGone(e,n){return e.some(r=>this.leaving.has(r))?new Promise(r=>{let s=()=>{e.some(o=>this.leaving.has(o))||(clearTimeout(i),this.goneWaiters.delete(s),r())},i=setTimeout(()=>{this.goneWaiters.delete(s),r()},n);i.unref(),this.goneWaiters.add(s)}):Promise.resolve()}drainIfGone(){for(let e of[...this.goneWaiters])e()}};aa();function AN(t,e,n,r){if(/^\d+$/.test(e))return t.find(i=>i.pid===parseInt(e,10));let s=e==="agent"?t.filter(ye):t.filter(i=>i.agent===e);if(s.length){if(!n)return s[0];let i=s.filter(o=>dr(o,n));return r&&i.find(o=>o.agent===r)||i[0]}return t.find(i=>se(i.file)===se(e))}var sn=t=>t.agent??fk.basename(t.file);function pk(t){return t===Ce?!1:t&&dk(t)&&dk(Ce)?EN(t,Ce):!0}function TN(t){return t===Ce?"":t?pk(t)?` STALE runtime v${t} (this CLI is v${Ce} \u2014 relaunch to update)`:` runtime v${t} (newer than this CLI's v${Ce})`:" STALE runtime (predates the version stamp \u2014 relaunch to update)"}function CN(t,e){return e===void 0?" pages ?":e>0?` ${e} page${e===1?"":"s"}`:ye(t)?" NO PAGE (no tab open on it)":" NO PAGE (nothing of it is running)"}function hk(t,e,n){t.forEach((r,s)=>e(` ${r.url} pid ${r.pid} ${r.trust?"trusted":"restricted"}${n?CN(r,n[s]):""}${TN(r.version)} ${r.file}`))}async function Cp(t,e){if(!t.length){console.log("No running bulb servers.");return}let n=await Promise.all(t.map(Ed));console.log("Running bulb servers:"),hk(t,r=>console.log(r),n),console.log(`
2533
- `+e)}function Bl(t,e,n,r,s){let i=AN(t,e,r,s);if(i)return i;console.error(`No running server for '${e}'.`),t.length?(console.error(`Running servers (try \`typebulb ${n} <file|pid>\`):`),hk(t,o=>console.error(o))):console.error("No bulb servers are running."),process.exit(1)}async function mk(t,e){if(!t){e.clear&&(console.error("Specify which server to clear: typebulb logs --clear <file|pid>"),process.exit(1)),await Cp(await G(process.cwd()),"Run `typebulb logs <file|pid>` to print one server's console.");return}let n=Bl(await G(),t,"logs",process.cwd(),st());if(e.clear){yd(n.pid),console.log(`Cleared log for ${sn(n)} (pid ${n.pid}).`);return}let r=Qe(n.pid),s=r.text;if(e.run!==void 0?(s=wd(s,e.run),s||console.error(e.run==="latest"?"No output in the latest run yet (the server has logged nothing since its last reload).":`No output for run ${e.run} (it hasn't started, or was trimmed from the log).`)):!s&&!e.follow&&console.error("Log is empty \u2014 this server has logged nothing yet."),e.lines&&e.lines>0){let i=s.split(`
2538
+ `)}tt();Cn();async function Rk(t){ve(t);let e=await vt();if(e.length>0){console.log(ow(e,process.env.TB_AI_PROVIDER,process.env.TB_AI_MODEL));return}if(!Ud()){console.log("No AI provider keys found in this directory's .env, and no local Ollama server detected."),console.log("Set one of these to use a cloud model with tb.ai:");for(let[n,r]of Object.entries(wr))console.log(` ${r.padEnd(20)} (${n})`);console.log("\u2026or start Ollama (http://localhost:11434, or set OLLAMA_HOST) for local models. Then re-run `typebulb models`.");return}console.log("Couldn't fetch the model catalog (offline?). tb.ai still works with any valid provider/model id for your keys.")}re();function Ik(t){t?.trim()||(console.error("Usage: typebulb slug <bulb name>"),process.exit(1));let e=sr(t);e||(console.error(`'${t}' has no slug \u2014 a bulb name needs at least one letter or digit.`),process.exit(1)),console.log(e)}Ue();import*as Lk from"path";import{valid as Nk,lt as bL}from"semver";$e();var ot={connected:"[page] connected",disconnected:"[page] disconnected",closed:t=>`[page] closed: ${t}`},Mp=3e3,$k=1e4,yL=2500,Wc=class{attached=new Set;leaving=new Set;arrivalWaiters=new Set;goneWaiters=new Set;arrivalSubs=[];settledEmpty;dropAt=0;get count(){return this.attached.size}get lastDropAt(){return this.dropAt}[Symbol.iterator](){return this.attached[Symbol.iterator]()}add(e,n){this.attached.add(e);for(let s of[...this.arrivalWaiters])s(!0);let r={page:e,firstAttach:n,count:this.attached.size};for(let s of this.arrivalSubs)s(r)}closing(e){this.attached.delete(e)&&this.leaving.add(e)}dropped(e){if(this.leaving.delete(e)){this.drainIfGone();return}if(!this.attached.delete(e))return;let n=this.dropAt=Date.now();setTimeout(()=>{this.attached.size===0&&this.dropAt===n&&this.settledEmpty?.()},Mp).unref()}async closeAll(e){let n=[...this.attached];if(!n.length)return{told:0,gone:0};await Promise.all(n.map(s=>s.close(e).catch(()=>{}))),await this.whenGone(n,yL);let r=n.filter(s=>!this.leaving.has(s)).length;for(let s of n)this.leaving.delete(s);return{told:n.length,gone:r}}whenArrives(e){return this.attached.size>0?Promise.resolve(!0):e>0?new Promise(n=>{let r=i=>{clearTimeout(s),this.arrivalWaiters.delete(r),n(i)},s=setTimeout(()=>r(!1),e);s.unref(),this.arrivalWaiters.add(r)}):Promise.resolve(!1)}onArrival(e){this.arrivalSubs.push(e)}onSettledEmpty(e){this.settledEmpty=e}whenGone(e,n){return e.some(r=>this.leaving.has(r))?new Promise(r=>{let s=()=>{e.some(o=>this.leaving.has(o))||(clearTimeout(i),this.goneWaiters.delete(s),r())},i=setTimeout(()=>{this.goneWaiters.delete(s),r()},n);i.unref(),this.goneWaiters.add(s)}):Promise.resolve()}drainIfGone(){for(let e of[...this.goneWaiters])e()}};ha();function wL(t,e,n,r){if(/^\d+$/.test(e))return t.find(i=>i.pid===parseInt(e,10));let s=e==="agent"?t.filter(we):t.filter(i=>i.agent===e);if(s.length){if(!n)return s[0];let i=s.filter(o=>hr(o,n));return r&&i.find(o=>o.agent===r)||i[0]}return t.find(i=>ae(i.file)===ae(e))}var on=t=>t.agent??Lk.basename(t.file);function Mk(t){return t===Pe?!1:t&&Nk(t)&&Nk(Pe)?bL(t,Pe):!0}function vL(t){return t===Pe?"":t?Mk(t)?` STALE runtime v${t} (this CLI is v${Pe} \u2014 relaunch to update)`:` runtime v${t} (newer than this CLI's v${Pe})`:" STALE runtime (predates the version stamp \u2014 relaunch to update)"}function SL(t,e){return e===void 0?" pages ?":e>0?` ${e} page${e===1?"":"s"}`:we(t)?" NO PAGE (no tab open on it)":" NO PAGE (nothing of it is running)"}function Dk(t,e,n){t.forEach((r,s)=>e(` ${r.url} pid ${r.pid} ${r.trust?"trusted":"restricted"}${n?SL(r,n[s]):""}${vL(r.version)} ${r.file}`))}async function Bp(t,e){if(!t.length){console.log("No running bulb servers.");return}let n=await Promise.all(t.map(_d));console.log("Running bulb servers:"),Dk(t,r=>console.log(r),n),console.log(`
2539
+ `+e)}function Kc(t,e,n,r,s){let i=wL(t,e,r,s);if(i)return i;console.error(`No running server for '${e}'.`),t.length?(console.error(`Running servers (try \`typebulb ${n} <file|pid>\`):`),Dk(t,o=>console.error(o))):console.error("No bulb servers are running."),process.exit(1)}async function Bk(t,e){if(!t){e.clear&&(console.error("Specify which server to clear: typebulb logs --clear <file|pid>"),process.exit(1)),await Bp(await Q(process.cwd()),"Run `typebulb logs <file|pid>` to print one server's console.");return}let n=Kc(await Q(),t,"logs",process.cwd(),it());if(e.clear){xd(n.pid),console.log(`Cleared log for ${on(n)} (pid ${n.pid}).`);return}let r=Ze(n.pid),s=r.text;if(e.run!==void 0?(s=Ad(s,e.run),s||console.error(e.run==="latest"?"No output in the latest run yet (the server has logged nothing since its last reload).":`No output for run ${e.run} (it hasn't started, or was trimmed from the log).`)):!s&&!e.follow&&console.error("Log is empty \u2014 this server has logged nothing yet."),e.lines&&e.lines>0){let i=s.split(`
2534
2540
  `);i.length&&i[i.length-1]===""&&i.pop(),s=i.slice(-e.lines).join(`
2535
2541
  `)}if(process.stdout.write(s),s&&!s.endsWith(`
2536
2542
  `)&&process.stdout.write(`
2537
- `),e.follow&&e.run===void 0){let i=r.offset,o=setInterval(()=>{let l=Qe(n.pid,i);i=l.offset,l.text&&process.stdout.write(l.text)},500),a=()=>{clearInterval(o),process.exit(0)};process.on("SIGINT",a),process.on("SIGTERM",a),await new Promise(()=>{})}}var ON=t=>new Promise(e=>setTimeout(e,t));async function gk(t,e){if(!t){Cp(await G(process.cwd()),"Run `typebulb wait <file|pid>` to block until one logs a new line.");return}let n=Bl(await G(),t,"wait",process.cwd(),st()),r=e.wake?await PN():void 0,s=process.env.TYPEBULB_WAIT_SHIM==="1",i=process.env.TYPEBULB_WAIT_FOLLOW==="1",o=s||i,a=e.timeoutSec??1800,l=e.match??"",c=Qe(n.pid).offset,f=i?void 0:ca(n.pid,l)??(l?ca(n.pid):void 0),d=i?c:f!==void 0&&f<=c?f:l?0:c,u=Date.now()+a*1e3,p=ye(n)?1e4:1e3,h=2e3,m=!ye(n)&&!i,g,b="",C=[],T="",E=0,$=!1;for(;;){let O=d>=c,P=Qe(n.pid,d);if(d=P.offset,P.text){b+=P.text;let k=b.split(`
2538
- `);b=k.pop()??"";let L=!1;for(let j of k)j.trim()&&(m&&O&&j.startsWith(it.disconnected)&&(L=!0),!(e.match&&!j.includes(e.match))&&(console.log(j),C.push(j),!i&&(g??=Date.now()+p,ye(n)&&(j.includes("] compile error")||j.includes("] runtime error"))&&(g=Math.min(g,Date.now()+h)))));if(L&&!g){T=`the last page of ${sn(n)} closed while waiting \u2014 a bulb runs in its page, so nothing can log ${e.match?`'${e.match}'`:"anything"} now`,console.error(T),E=3;break}}if(g&&Date.now()>=g)break;if(!o&&!g&&Date.now()>=u){T=`timeout: no ${e.match?`line matching '${e.match}'`:"new output"} from ${sn(n)} within ${a}s`,console.error(T),E=2;break}if(!Wt(n.pid)){g||(T=`server ${sn(n)} (pid ${n.pid}) exited while waiting`,console.error(T),E=3,$=!0);break}await ON(400)}if(r){console.error(`detected ${new Date().toISOString()}`);try{await r.adapter.wake(r.sessionId,"typebulb_wait",C.length?C.join(`
2539
- `):T)}catch(O){console.error(`Not delivered: ${O instanceof Error?O.message:O}`),process.exit(4)}console.error(`accepted ${new Date().toISOString()}`)}$&&process.exit(3),i||js(n.pid,d,l),process.exit(E)}async function PN(){let t=st(),e=t?qr()[t]?.():void 0,n=e?.wake?e.callerSessionId?.(process.cwd()):void 0;(!e||!n)&&(console.error(e?.wake?"Can't --wake: your own session couldn't be identified in this project, and a wake goes to no other.":`--wake needs a harness that wakes through its host (here: ${t??"none detected"}); on Claude Code, a background wait already wakes you.`),process.exit(1));let r=await e.wakeRoute(n);return r.error&&(console.error(`Can't --wake: ${r.error}.`),process.exit(1)),{adapter:e,sessionId:n}}function yk(t,e){if(e==="killed")return` \u2014 forced (${pk(t.version)?`its runtime ${t.version?`v${t.version} `:""}predates the stop route`:"it did not answer"}); a page it opened may still be open`;let n=[];return e.closed&&n.push(`closed ${e.closed} page${e.closed===1?"":"s"}`),e.stuck&&n.push(`${e.stuck} did not close`),n.length?` \u2014 ${n.join(", ")}`:""}async function bk(t){if(!t){await Cp(await G(process.cwd()),"Run `typebulb stop <file|pid>` to stop one.");return}let e=Bl(await G(),t,"stop",process.cwd(),st()),n=await bt(e);console.log(`Stopped ${sn(e)} (pid ${e.pid}, ${e.url}).${yk(e,n)}`)}async function wk(t){let e=await Tp(t),n=t==="global"?"server":t==="agent"?"mirror":"bulb";if(!e.length){console.log(t==="global"?"No running bulb servers.":`No running ${n}s for this project.`);return}let r=await Promise.all(e.map(s=>bt(s)));console.log(`Stopped ${e.length} ${n}${e.length===1?"":"s"}:`),e.forEach((s,i)=>console.log(` ${s.url} pid ${s.pid} ${sn(s)}${yk(s,r[i])}`))}async function Tp(t){let e=process.cwd(),n=t==="agent"?st():void 0;return t==="global"?await G():t==="bulbs"?await G(e):(await G()).filter(r=>dr(r,e)&&(!n||r.agent===n))}async function vk(t,e){let n=process.cwd(),r=t?[Bl(await G(),t,"restart",n,st())]:e?await Tp(e):[...await G(n),...await Tp("agent")];if(!r.length){console.log(e==="global"?"No running bulb servers.":"No running bulbs or mirrors for this project.");return}console.log(`Restarting on v${Ce}:`);for(let s of r){let i=s.version?`v${s.version}`:"unknown version";try{let o=ye(s)?(await bt(s,"keep"),await Us(s.agent,s.cwd??n)):await Sn(s.file,{cwd:s.cwd??n,open:!1,trust:s.trust,noTrust:!s.trust,mode:s.mode,watch:s.watch,replace:s.replace});console.log(` ${o.url} ${sn(s)} ${i} \u2192 v${Ce}`)}catch(o){console.log(` ${s.url} ${sn(s)} failed: ${o instanceof Error?o.message:o}`),process.exitCode=1}}}Ie();je();bn();import*as jl from"path";import*as Sk from"http";import{mkdir as _N,writeFile as RN}from"fs/promises";async function Kr(){let t=[];for await(let e of process.stdin)t.push(e);return Buffer.concat(t).toString("utf-8")}function Ci(t){return(t.charCodeAt(0)===65279?t.slice(1):t).replace(/\r\n/g,`
2540
- `).trimEnd()}function IN(t,e){return new Promise((n,r)=>{let s=new URL(t),i=Sk.request({hostname:s.hostname,port:s.port,path:s.pathname+s.search,method:"POST",headers:{"Content-Type":"text/plain","Content-Length":Buffer.byteLength(e)}},o=>{let a="";o.setEncoding("utf8"),o.on("data",l=>{a+=l}),o.on("end",()=>n({status:o.statusCode??0,text:a}))});i.setTimeout(0),i.on("error",r),i.end(e)})}var $N=t=>{let e=Math.round((Date.now()-t)/6e4);return e<1?"moments ago":e<60?`${e}m ago`:`${Math.round(e/60)}h ago`};async function kk(t,e,n=0){e==="-"&&(e=Ci(await Kr()));let r=e!==void 0&&e.startsWith("tb:");r&&n<=0&&(n=mp);let s=e!==void 0&&/^tb:(click|set)( |$)/.test(e),i=jl.resolve(t),o=vn(await G(),i)[0];if(!o){let h=(await yn(process.cwd()))(i);console.error(h?`No running server for '${t}' \u2014 it last ran ${$N(h)}. Relaunching reuses the same URL (a stale tab is one reload from live): npx typebulb ${t}`:`No running server for '${t}'. Start it first: npx typebulb ${t}`),process.exit(1)}let a=async h=>{let m=[h>0?`reply=${h}`:"",s?"solo=1":"","open=1"].filter(Boolean).join("&"),g=await IN(`${o.url}/__send${m?`?${m}`:""}`,e??"");(g.status<200||g.status>=300)&&(console.error(`send failed: HTTP ${g.status} from ${o.url}/__send`),process.exit(1));try{return JSON.parse(g.text)}catch{return{}}},l={},c=Date.now();try{l=await a(n)}catch(h){console.error(`send failed: ${h instanceof Error?h.message:String(h)}`),process.exit(1)}let f=l.clients??0,d=`${f} page${f===1?"":"s"}`;if(l.refused&&(console.error(`Actuation needs exactly one connected page; ${d} are open on ${o.url} \u2014 the reset is \`typebulb stop ${t}\` then relaunch.`),process.exit(1)),f===0){let h=l.droppedMsAgo,m=l.opening==="none"?" and no agent mirror page is open to open one through":"",g=l.opening==="unreached"?` \u2014 the page was opened ${l.via?`in VS Code via ${l.via}`:"in your browser"} and never attached; is the browser it opened in still there?`:h!==void 0?` \u2014 a page disconnected ${Math.round(h/1e3)}s ago and hasn't reconnected${m}; reload it, or open ${o.url}`:` \u2014 no page has ever connected${m}; share ${o.url} and arm: typebulb wait ${t} --match "${it.connected}"`;console.error(`No page connected after ${((Date.now()-c)/1e3).toFixed(1)}s, so nothing was delivered${g}`),process.exit(1)}l.opening==="editor"?console.error(`Opened in VS Code via ${l.via}.`):l.opening==="external"&&console.error("Opened in your browser, where the agent mirror is."),console.error(`Sent to ${d}.`);let u=l.results??[],p=l.errors??[];for(let h of p)console.error(`handler error: ${h}`);if(p.length&&process.exit(1),u.length>1&&(console.error(`${u.length} replies from ${d} \u2014 one reply owns stdout: at most one tb.onMessage handler, in one page, may return a value.`),process.exit(1)),u.length===1){if(e!==void 0&&/^tb:png( |$)/.test(e)){let m={};try{m=JSON.parse(u[0])}catch{}typeof m.png!="string"&&(console.error("tb:png replied with an unexpected shape \u2014 an older runtime? (`typebulb logs` lists server versions)"),process.exit(1));let g=hb(i);await _N(jl.dirname(g),{recursive:!0}),await RN(g,Buffer.from(m.png,"base64"));let b=[m.via?`inside "${m.via}"`:"",m.backdrop?`backdrop ${m.backdrop}`:""].filter(Boolean);console.error(`canvas ${m.width}\xD7${m.height} \u2192 PNG${b.length?` (${b.join("; ")})`:""}`),console.log(g);return}let h;try{h=JSON.parse(u[0])}catch{h=void 0}console.log(typeof h=="string"?h:u[0])}else l.timedOut&&(r&&(console.error(`No reply to '${e}' within ${n/1e3}s \u2014 reload the page and retry.`),process.exit(1)),console.error(`(no reply within ${n/1e3}s \u2014 slow work needs a larger --wait=ms; a reply that NEVER comes is a done-promise that missed an exit, or a blocked main thread: tb:snapshot runs no page code, so its silence too means blocked)`))}Ga();kf();te();import*as xk from"fs/promises";async function Ek(t,e){let n=await xk.readFile(t,"utf-8"),r=Wn(n),s=de[e].path,i=r.files.get(s);i||(console.error(i===void 0?`No **${s}** block in ${t}`:`The **${s}** block in ${t} is empty`),process.exit(2)),process.stdout.write(i.endsWith(`
2543
+ `),e.follow&&e.run===void 0){let i=r.offset,o=setInterval(()=>{let c=Ze(n.pid,i);i=c.offset,c.text&&process.stdout.write(c.text)},500),a=()=>{clearInterval(o),process.exit(0)};process.on("SIGINT",a),process.on("SIGTERM",a),await new Promise(()=>{})}}var kL=t=>new Promise(e=>setTimeout(e,t));async function jk(t,e){if(!t){Bp(await Q(process.cwd()),"Run `typebulb wait <file|pid>` to block until one logs a new line.");return}let n=Kc(await Q(),t,"wait",process.cwd(),it()),r=e.wake?await xL():void 0,s=process.env.TYPEBULB_WAIT_SHIM==="1",i=process.env.TYPEBULB_WAIT_FOLLOW==="1",o=s||i,a=e.timeoutSec??1800,c=e.match??"",l=Ze(n.pid).offset,f=i?void 0:ga(n.pid,c)??(c?ga(n.pid):void 0),u=i?l:f!==void 0&&f<=l?f:c?0:l,d=Date.now()+a*1e3,p=we(n)?1e4:1e3,h=2e3,m=!we(n)&&!i,g,b="",C=[],T="",E=0,R=!1;for(;;){let O=u>=l,_=Ze(n.pid,u);if(u=_.offset,_.text){b+=_.text;let x=b.split(`
2544
+ `);b=x.pop()??"";let M=!1;for(let F of x)F.trim()&&(m&&O&&F.startsWith(ot.disconnected)&&(M=!0),!(e.match&&!F.includes(e.match))&&(console.log(F),C.push(F),!i&&(g??=Date.now()+p,we(n)&&(F.includes("] compile error")||F.includes("] runtime error"))&&(g=Math.min(g,Date.now()+h)))));if(M&&!g){T=`the last page of ${on(n)} closed while waiting \u2014 a bulb runs in its page, so nothing can log ${e.match?`'${e.match}'`:"anything"} now`,console.error(T),E=3;break}}if(g&&Date.now()>=g)break;if(!o&&!g&&Date.now()>=d){T=`timeout: no ${e.match?`line matching '${e.match}'`:"new output"} from ${on(n)} within ${a}s`,console.error(T),E=2;break}if(!Jt(n.pid)){g||(T=`server ${on(n)} (pid ${n.pid}) exited while waiting`,console.error(T),E=3,R=!0);break}await kL(400)}if(r){console.error(`detected ${new Date().toISOString()}`);try{await r.adapter.wake(r.sessionId,"typebulb_wait",C.length?C.join(`
2545
+ `):T)}catch(O){console.error(`Not delivered: ${O instanceof Error?O.message:O}`),process.exit(4)}console.error(`accepted ${new Date().toISOString()}`)}R&&process.exit(3),i||Ws(n.pid,u,c),process.exit(E)}async function xL(){let t=it(),e=t?Yr()[t]?.():void 0,n=e?.wake?e.callerSessionId?.(process.cwd()):void 0;(!e||!n)&&(console.error(e?.wake?"Can't --wake: your own session couldn't be identified in this project, and a wake goes to no other.":`--wake needs a harness that wakes through its host (here: ${t??"none detected"}); on Claude Code, a background wait already wakes you.`),process.exit(1));let r=await e.wakeRoute(n);return r.error&&(console.error(`Can't --wake: ${r.error}.`),process.exit(1)),{adapter:e,sessionId:n}}function Fk(t,e){if(e==="killed")return` \u2014 forced (${Mk(t.version)?`its runtime ${t.version?`v${t.version} `:""}predates the stop route`:"it did not answer"}); a page it opened may still be open`;let n=[];return e.closed&&n.push(`closed ${e.closed} page${e.closed===1?"":"s"}`),e.stuck&&n.push(`${e.stuck} did not close`),n.length?` \u2014 ${n.join(", ")}`:""}async function Uk(t){if(!t){await Bp(await Q(process.cwd()),"Run `typebulb stop <file|pid>` to stop one.");return}let e=Kc(await Q(),t,"stop",process.cwd(),it()),n=await wt(e);console.log(`Stopped ${on(e)} (pid ${e.pid}, ${e.url}).${Fk(e,n)}`)}async function qk(t){let e=await Dp(t),n=t==="global"?"server":t==="agent"?"mirror":"bulb";if(!e.length){console.log(t==="global"?"No running bulb servers.":`No running ${n}s for this project.`);return}let r=await Promise.all(e.map(s=>wt(s)));console.log(`Stopped ${e.length} ${n}${e.length===1?"":"s"}:`),e.forEach((s,i)=>console.log(` ${s.url} pid ${s.pid} ${on(s)}${Fk(s,r[i])}`))}async function Dp(t){let e=process.cwd(),n=t==="agent"?it():void 0;return t==="global"?await Q():t==="bulbs"?await Q(e):(await Q()).filter(r=>hr(r,e)&&(!n||r.agent===n))}async function Jk(t,e){let n=process.cwd(),r=t?[Kc(await Q(),t,"restart",n,it())]:e?await Dp(e):[...await Q(n),...await Dp("agent")];if(!r.length){console.log(e==="global"?"No running bulb servers.":"No running bulbs or mirrors for this project.");return}console.log(`Restarting on v${Pe}:`);for(let s of r){let i=s.version?`v${s.version}`:"unknown version";try{let o=we(s)?(await wt(s,"keep"),await Hs(s.agent,s.cwd??n)):await xn(s.file,{cwd:s.cwd??n,open:!1,trust:s.trust,noTrust:!s.trust,mode:s.mode,watch:s.watch,replace:s.replace});console.log(` ${o.url} ${on(s)} ${i} \u2192 v${Pe}`)}catch(o){console.log(` ${s.url} ${on(s)} failed: ${o instanceof Error?o.message:o}`),process.exitCode=1}}}$e();Ue();vn();import*as Hc from"path";import*as Wk from"http";import{mkdir as EL,writeFile as AL}from"fs/promises";async function Xr(){let t=[];for await(let e of process.stdin)t.push(e);return Buffer.concat(t).toString("utf-8")}function $i(t){return(t.charCodeAt(0)===65279?t.slice(1):t).replace(/\r\n/g,`
2546
+ `).trimEnd()}function TL(t,e){return new Promise((n,r)=>{let s=new URL(t),i=Wk.request({hostname:s.hostname,port:s.port,path:s.pathname+s.search,method:"POST",headers:{"Content-Type":"text/plain","Content-Length":Buffer.byteLength(e)}},o=>{let a="";o.setEncoding("utf8"),o.on("data",c=>{a+=c}),o.on("end",()=>n({status:o.statusCode??0,text:a}))});i.setTimeout(0),i.on("error",r),i.end(e)})}var CL=t=>{let e=Math.round((Date.now()-t)/6e4);return e<1?"moments ago":e<60?`${e}m ago`:`${Math.round(e/60)}h ago`};async function Kk(t,e,n=0){e==="-"&&(e=$i(await Xr()));let r=e!==void 0&&e.startsWith("tb:");r&&n<=0&&(n=Tp);let s=e!==void 0&&/^tb:(click|set)( |$)/.test(e),i=Hc.resolve(t),o=kn(await Q(),i)[0];if(!o){let h=(await wn(process.cwd()))(i);console.error(h?`No running server for '${t}' \u2014 it last ran ${CL(h)}. Relaunching reuses the same URL (a stale tab is one reload from live): npx typebulb ${t}`:`No running server for '${t}'. Start it first: npx typebulb ${t}`),process.exit(1)}let a=async h=>{let m=[h>0?`reply=${h}`:"",s?"solo=1":"","open=1"].filter(Boolean).join("&"),g=await TL(`${o.url}/__send${m?`?${m}`:""}`,e??"");(g.status<200||g.status>=300)&&(console.error(`send failed: HTTP ${g.status} from ${o.url}/__send`),process.exit(1));try{return JSON.parse(g.text)}catch{return{}}},c={},l=Date.now();try{c=await a(n)}catch(h){console.error(`send failed: ${h instanceof Error?h.message:String(h)}`),process.exit(1)}let f=c.clients??0,u=`${f} page${f===1?"":"s"}`;if(c.refused&&(console.error(`Actuation needs exactly one connected page; ${u} are open on ${o.url} \u2014 the reset is \`typebulb stop ${t}\` then relaunch.`),process.exit(1)),f===0){let h=c.droppedMsAgo,m=c.opening==="none"?" and no agent mirror page is open to open one through":"",g=c.opening==="unreached"?` \u2014 the page was opened ${c.via?`in VS Code via ${c.via}`:"in your browser"} and never attached; is the browser it opened in still there?`:h!==void 0?` \u2014 a page disconnected ${Math.round(h/1e3)}s ago and hasn't reconnected${m}; reload it, or open ${o.url}`:` \u2014 no page has ever connected${m}; share ${o.url} and arm: typebulb wait ${t} --match "${ot.connected}"`;console.error(`No page connected after ${((Date.now()-l)/1e3).toFixed(1)}s, so nothing was delivered${g}`),process.exit(1)}c.opening==="editor"?console.error(`Opened in VS Code via ${c.via}.`):c.opening==="external"&&console.error("Opened in your browser, where the agent mirror is."),console.error(`Sent to ${u}.`);let d=c.results??[],p=c.errors??[];for(let h of p)console.error(`handler error: ${h}`);if(p.length&&process.exit(1),d.length>1&&(console.error(`${d.length} replies from ${u} \u2014 one reply owns stdout: at most one tb.onMessage handler, in one page, may return a value.`),process.exit(1)),d.length===1){if(e!==void 0&&/^tb:png( |$)/.test(e)){let m={};try{m=JSON.parse(d[0])}catch{}typeof m.png!="string"&&(console.error("tb:png replied with an unexpected shape \u2014 an older runtime? (`typebulb logs` lists server versions)"),process.exit(1));let g=Eb(i);await EL(Hc.dirname(g),{recursive:!0}),await AL(g,Buffer.from(m.png,"base64"));let b=[m.via?`inside "${m.via}"`:"",m.backdrop?`backdrop ${m.backdrop}`:""].filter(Boolean);console.error(`canvas ${m.width}\xD7${m.height} \u2192 PNG${b.length?` (${b.join("; ")})`:""}`),console.log(g);return}let h;try{h=JSON.parse(d[0])}catch{h=void 0}console.log(typeof h=="string"?h:d[0])}else c.timedOut&&(r&&(console.error(`No reply to '${e}' within ${n/1e3}s \u2014 reload the page and retry.`),process.exit(1)),console.error(`(no reply within ${n/1e3}s \u2014 slow work needs a larger --wait=ms; a reply that NEVER comes is a done-promise that missed an exit, or a blocked main thread: tb:snapshot runs no page code, so its silence too means blocked)`))}rc();Of();re();import*as Hk from"fs/promises";async function zk(t,e){let n=await Hk.readFile(t,"utf-8"),r=Hn(n),s=pe[e].path,i=r.files.get(s);i||(console.error(i===void 0?`No **${s}** block in ${t}`:`The **${s}** block in ${t} is empty`),process.exit(2)),process.stdout.write(i.endsWith(`
2541
2547
  `)?i:i+`
2542
- `)}te();import*as Oi from"fs/promises";async function Ck(t,e){let n=await Oi.readFile(t,"utf-8"),r=[];for(let{kind:i,source:o}of e){let a;try{a=o==="-"?await Kr():await Oi.readFile(o,"utf-8")}catch(l){Tk(`Cannot read ${i}'s source: ${l instanceof Error?l.message:String(l)}`)}r.push({kind:i,content:Ci(a),label:o==="-"?"stdin":o})}let s;try{s=NN(n,r)}catch(i){Tk(`${t}: ${i instanceof Error?i.message:String(i)}`)}for(let i of s.upToDate)console.log(`${de[i].path}: already up to date`);if(s.written.length){await Oi.writeFile(t,s.text);for(let i of s.written)console.log(i.action==="removed"?`${de[i.kind].path}: removed (${i.label} is empty)`:`${de[i.kind].path}: ${i.action} from ${i.label} (${i.chars.toLocaleString()} chars)`)}}function NN(t,e){let n=Wn(t),r=t,s=[],i=[];for(let{kind:o,content:a,label:l}of e){let c=de[o].path,f=n.files.get(c);if(!a){if(f===void 0){i.push(o);continue}r=Ak(rh(r,o),r,c),s.push({kind:o,action:"removed",chars:0,label:l});continue}if(f!==void 0&&Ci(f)===a){i.push(o);continue}r=Ak(zr(r,o,a),r,c),s.push({kind:o,action:f===void 0?"created":"replaced",chars:a.length,label:l})}return{text:r,written:s,upToDate:i}}function Ak(t,e,n){if(t===e)throw new Error(`the **${n}** block's fence is unterminated; refusing to rewrite inside it`);return t}function Tk(t){console.error(t),process.exit(1)}et();gl();dl();Mr();function Op(){let t=qr(),e=st();return{caller:e,adapters:(e?[e]:Object.keys(t)).map(n=>t[n]()).filter(n=>n.listChildren)}}async function Pk(t,e,n){be(e);let{caller:r,adapters:s}=Op();if(!s.length){console.error(`Sub-agent status isn't supported for ${r} sessions.`),process.exitCode=1;return}let i;for(let o of s){let{sessionId:a,cwd:l}=gi(o,process.cwd());if(!t){let c=a?ml(o,l,a):hl(o,l).next().value;if(!c?.children.length){if(a){en(a,n),console.log("No sub-agents in this session yet.");return}continue}en(a??c.sessionId,n);let{reports:f,files:d}=await Dn(o,l,c);console.log(Uv(c.sessionId,f,d,Date.now()));return}for(let c of hl(o,l)){i??=c;let f=Hv(c,t);if(f.length){if(f.length>1){console.error(`Several agents match "${t}"; name one by its id:`);for(let d of f)console.error(` ${Ok(d)}`);process.exitCode=1;return}en(a??c.sessionId,n),console.log(Dv((await Dn(o,l,c,f[0].id)).reports[0],Date.now()));return}}}if(!i){console.log("No sub-agents in this project's sessions.");return}console.error(`No agent matches "${t}". The agents of session ${i.sessionId}:`);for(let o of i.children)console.error(` ${Ok(o)}`);process.exitCode=1}var Ok=t=>`${t.id} ${ol(t).padEnd(7)} ${Tt(t)}`;et();je();Ie();gl();dl();import{mkdirSync as LN,readFileSync as _p,writeFileSync as Ik,rmSync as _k}from"fs";import{join as Ul}from"path";var MN=1e4,DN=720*6e4,Rk="typebulb_babysit";async function $k(t,e){be(t);let{caller:n,adapters:r}=Op(),s=r.map(p=>({adapter:p,...(p.wake?gi:Kv)(p,process.cwd())})).find(p=>p.sessionId);if(!s?.sessionId)return Pp(r.length?r.some(p=>p.wake)?"Can't babysit: your own session couldn't be identified in this project, and a wake goes to no other.":"No session to babysit in this project.":`Babysitting sub-agents isn't supported for ${n} sessions.`);let{adapter:i,sessionId:o,cwd:a}=s;if(en(o,e),i.wake){let p=await i.wakeRoute(o);if(p.error)return Pp(`Can't babysit: ${p.error}.`)}let l=Ul(Re(),"babysit"),c=Ul(l,`${o}.json`);if(!BN(Ul(l,`${o}.lock`)))return Pp("A babysit is already watching this session.");let f=[];try{f=JSON.parse(_p(c,"utf8"))}catch{}let d=p=>{try{Ik(c,JSON.stringify(p))}catch{}};console.error(`Babysitting the sub-agents of session ${o}: this exits with a line when one needs attention; run it again after handling that.`);let u=Date.now()+DN;for(;Date.now()<u;){i.sessionEnded?.(o,a)&&Fl(3,"The session this babysits has ended.");let{reports:p}=await Dn(i,a,ml(i,a,o)),h=qv(p,Date.now(),!!i.sessionsWorking?.(a)?.has(o),en(o)),m=[...h].filter(([g])=>!f.includes(g));if(!m.length)f=[...h.keys()],d(f);else{let g=m.map(([,b])=>b).join(`
2543
- `);if(i.wake){console.error(`detected ${new Date().toISOString()}`);try{await i.wake(o,Rk,g)}catch(b){d([...h.keys()].filter(C=>!m.some(([T])=>T===C))),console.log(g),Fl(4,`Not delivered: ${b instanceof Error?b.message:b}`)}console.error(`accepted ${new Date().toISOString()}`)}d([...h.keys()]),console.log(g),Fl(0)}await new Promise(g=>setTimeout(g,MN))}i.wake&&await i.wake(o,Rk,"typebulb babysit stopped after 12 hours with nothing to report; run it again to keep watching.").catch(()=>{}),Fl(2,"Nothing needed attention; gave up.")}function Pp(t){console.error(t),process.exitCode=1}function Fl(t,e){e&&console.error(e),process.exit(t)}function BN(t){try{LN(Ul(t,".."),{recursive:!0})}catch{}for(let e=0;e<2;e++)try{return Ik(t,String(process.pid),{flag:"wx"}),process.on("exit",()=>{try{Number(_p(t,"utf8"))===process.pid&&_k(t)}catch{}}),!0}catch(n){if(n.code!=="EEXIST")return!0;let r=0;try{r=Number(_p(t,"utf8"))}catch{}if(r&&r!==process.pid&&Wt(r))return!1;try{_k(t)}catch{}}return!1}et();At();te();ma();import*as an from"fs/promises";import*as qn from"path";import{EventEmitter as oL}from"events";Kt();te();import{Hono as WN}from"hono";import{serve as KN}from"@hono/node-server";import{streamSSE as HN}from"hono/streaming";import*as $p from"fs/promises";import zN from"open";Tr();ii();Ar();import*as Rp from"fs/promises";import*as Pi from"path";var ql=class{async get(e){let n=tt(e),r=Pi.join(si,n+".bin"),s=Pi.join(si,n+".json");try{let[i,o]=await Promise.all([Rp.readFile(r),Rp.readFile(s,"utf8")]),a=JSON.parse(o);return{body:i,contentType:a.contentType,cacheControl:a.cacheControl}}catch{return}}async set(e,n){await ne();let r=tt(e),s=Pi.join(si,r+".bin"),i=Pi.join(si,r+".json"),o={url:e,contentType:n.contentType,cacheControl:n.cacheControl};await Promise.all([Fe(s,n.body),Fe(i,JSON.stringify(o))])}};var Nk=`
2548
+ `)}re();import*as Ni from"fs/promises";async function Gk(t,e){let n=await Ni.readFile(t,"utf-8"),r=[];for(let{kind:i,source:o}of e){let a;try{a=o==="-"?await Xr():await Ni.readFile(o,"utf-8")}catch(c){Vk(`Cannot read ${i}'s source: ${c instanceof Error?c.message:String(c)}`)}r.push({kind:i,content:$i(a),label:o==="-"?"stdin":o})}let s;try{s=OL(n,r)}catch(i){Vk(`${t}: ${i instanceof Error?i.message:String(i)}`)}for(let i of s.upToDate)console.log(`${pe[i].path}: already up to date`);if(s.written.length){await Ni.writeFile(t,s.text);for(let i of s.written)console.log(i.action==="removed"?`${pe[i.kind].path}: removed (${i.label} is empty)`:`${pe[i.kind].path}: ${i.action} from ${i.label} (${i.chars.toLocaleString()} chars)`)}}function OL(t,e){let n=Hn(t),r=t,s=[],i=[];for(let{kind:o,content:a,label:c}of e){let l=pe[o].path,f=n.files.get(l);if(!a){if(f===void 0){i.push(o);continue}r=Yk(ph(r,o),r,l),s.push({kind:o,action:"removed",chars:0,label:c});continue}if(f!==void 0&&$i(f)===a){i.push(o);continue}r=Yk(Zr(r,o,a),r,l),s.push({kind:o,action:f===void 0?"created":"replaced",chars:a.length,label:c})}return{text:r,written:s,upToDate:i}}function Yk(t,e,n){if(t===e)throw new Error(`the **${n}** block's fence is unterminated; refusing to rewrite inside it`);return t}function Vk(t){console.error(t),process.exit(1)}tt();ki();xc();bc();Dn();jr();function jp(){let t=Yr(),e=it();return{caller:e,adapters:(e?[e]:Object.keys(t)).map(n=>t[n]()).filter(n=>n.listChildren)}}async function Qk(t,e,n){ve(e);let{caller:r,adapters:s}=jp();if(!s.length){console.error(`Sub-agent status isn't supported for ${r} sessions.`),process.exitCode=1;return}let i;for(let o of s){let{sessionId:a,cwd:c}=Si(o,process.cwd());if(!t){let l=a?kc(o,c,a):Sc(o,c).next().value,f=l?Bv(jn(o,c,l.sessionId,l.file,l.children).threads,Date.now()):[];if(!l?.children.length){if(a){en(a,n),console.log([...f,...f.length?[""]:[],"No sub-agents in this session yet."].join(`
2549
+ `));return}continue}en(a??l.sessionId,n);let{reports:u,files:d}=await tn(o,c,l);console.log(nS(l.sessionId,u,d,Date.now(),f));return}for(let l of Sc(o,c)){i??=l;let f=aS(l,t);if(f.length){if(f.length>1){console.error(`Several agents match "${t}"; name one by its id:`);for(let u of f)console.error(` ${Xk(u)}`);process.exitCode=1;return}en(a??l.sessionId,n),console.log(Qv((await tn(o,c,l,f[0].id)).reports[0],Date.now()));return}}}if(!i){console.log("No sub-agents in this project's sessions.");return}console.error(`No agent matches "${t}". The agents of session ${i.sessionId}:`);for(let o of i.children)console.error(` ${Xk(o)}`);process.exitCode=1}var Xk=t=>`${t.id} ${pc(t).padEnd(7)} ${ft(t)}`;tt();Ue();$e();ki();xc();bc();import{mkdirSync as PL,readFileSync as tx,writeFileSync as nx,rmSync as _L}from"fs";import{join as zc}from"path";var RL=1e4,IL=720*6e4,Zk="typebulb_babysit";async function rx(t,e){ve(t);let{caller:n,adapters:r}=jp(),s=r.map(m=>({adapter:m,...(m.wake?Si:oS)(m,process.cwd())})).find(m=>m.sessionId);if(!s?.sessionId)return ex(r.length?r.some(m=>m.wake)?"Can't babysit: your own session couldn't be identified in this project, and a wake goes to no other.":"No session to babysit in this project.":`Babysit isn't supported for ${n} sessions.`);let{adapter:i,sessionId:o,cwd:a}=s;if(en(o,e),i.wake){let m=await i.wakeRoute(o);if(m.error)return ex(`Can't babysit: ${m.error}.`)}let c=zc(Ee(),"babysit"),l=zc(c,`${o}.json`),f=zc(c,`${o}.lock`),u=$L(f),d=[];try{d=JSON.parse(tx(l,"utf8"))}catch{}let p=m=>{try{nx(l,JSON.stringify(m))}catch{}};u&&console.error(`Took over from the babysit already watching this session (pid ${u}), which stops at its next check.`),console.error(`Babysitting session ${o}: this exits with a line when a sub-agent or the user's answer needs you; run it again after handling that.`);let h=Date.now()+IL;for(;Date.now()<h;){let m=Fp(f);m!==void 0&&m!==process.pid&&Li(5,"A newer babysit took over this session."),i.sessionEnded?.(o,a)&&Li(3,"The session this babysits has ended.");let g=kc(i,a,o),{reports:b}=await tn(i,a,g),{threads:C}=jn(i,a,o,g.file,g.children),T=rS(b,Date.now(),!!i.sessionsWorking?.(a)?.has(o),en(o),C),E=[...T].filter(([R])=>!d.includes(R));if(!E.length)d=[...T.keys()],p(d);else{let R=E.map(([,O])=>O).join(`
2550
+ `);if(i.wake){console.error(`detected ${new Date().toISOString()}`);try{await i.wake(o,Zk,R)}catch(O){p([...T.keys()].filter(_=>!E.some(([x])=>x===_))),console.log(R),Li(4,`Not delivered: ${O instanceof Error?O.message:O}`)}console.error(`accepted ${new Date().toISOString()}`)}p([...T.keys()]),console.log(R),Li(0)}await new Promise(R=>setTimeout(R,RL))}i.wake&&await i.wake(o,Zk,"typebulb babysit stopped after 12 hours with nothing to report; run it again to keep watching.").catch(()=>{}),Li(2,"Nothing needed attention; gave up.")}function ex(t){console.error(t),process.exitCode=1}function Li(t,e){e&&console.error(e),process.exit(t)}function $L(t){try{PL(zc(t,".."),{recursive:!0})}catch{}let e=Fp(t);try{nx(t,String(process.pid))}catch{}return process.on("exit",()=>{try{Fp(t)===process.pid&&_L(t)}catch{}}),e&&e!==process.pid&&Jt(e)?e:void 0}function Fp(t){try{return Number(tx(t,"utf8"))||void 0}catch{return}}tt();Tt();re();ka();import*as cn from"fs/promises";import*as Wn from"path";import{EventEmitter as tM}from"events";Wt();re();import{Hono as jL}from"hono";import{serve as FL}from"@hono/node-server";import{streamSSE as UL}from"hono/streaming";import*as Jp from"fs/promises";import qL from"open";Pr();ui();Or();import*as Up from"fs/promises";import*as Mi from"path";var Yc=class{async get(e){let n=nt(e),r=Mi.join(li,n+".bin"),s=Mi.join(li,n+".json");try{let[i,o]=await Promise.all([Up.readFile(r),Up.readFile(s,"utf8")]),a=JSON.parse(o);return{body:i,contentType:a.contentType,cacheControl:a.cacheControl}}catch{return}}async set(e,n){await se();let r=nt(e),s=Mi.join(li,r+".bin"),i=Mi.join(li,r+".json"),o={url:e,contentType:n.contentType,cacheControl:n.cacheControl};await Promise.all([qe(s,n.body),qe(i,JSON.stringify(o))])}};var sx=`
2544
2551
  const CSS = '\\n' +
2545
2552
  /* The agent mirror's token set, verbatim (agents/core/client/styles.css) \u2014 one system across CLI
2546
2553
  chrome: app chrome sits on --panel, content wells paint --veil, grays ride one neutral tint.
@@ -2923,22 +2930,22 @@ export function runInference(ctx) {
2923
2930
  showConfirm();
2924
2931
  document.body.appendChild(host);
2925
2932
  }
2926
- `;Or();Ie();An();Ta();Kt();import{stream as jN}from"hono/streaming";var FN="X-TB-Stream";function _i(t){return t instanceof Ne?{message:t.message,code:t.code,retryable:t.retryable}:{message:t instanceof Error?t.message:"Unknown error",code:"unknown",retryable:!1}}function Jl(t,e){return t.header("Content-Type","application/x-ndjson; charset=utf-8"),t.header("Cache-Control","no-cache"),t.header(FN,"1"),jN(t,async n=>{let r=e[Symbol.asyncIterator]();n.onAbort(()=>{r.return?.()});try{for(;;){let{done:s,value:i}=await r.next();if(s)break;await n.writeln(JSON.stringify({type:"chunk",value:i}))}}catch(s){await n.writeln(JSON.stringify({type:"error",error:_i(s)}))}finally{try{await r.return?.()}catch{}}})}var Wl={log:(...t)=>console.log(...t)};function Kl(t,e){let n=t?.[e]??(Object.hasOwn(Wl,e)?Wl[e]:void 0);return typeof n=="function"?n:void 0}function Hl(t){return t.constructor?.name==="AsyncGeneratorFunction"}hf();var UN=/^\/(v\d+\/|stable\/|node\/|gh\/|@[^/]+\/[^@/]+@|[^@/]+@)/,qN=/[?&]target=/,JN=/^\/(?:@[^/]+\/)?[^/@]+\/[^/]+/;function Lk(t,e=""){return UN.test(t)?!0:JN.test(t)&&qN.test(e)}var YN="127.0.0.1",VN=new Set(["localhost","127.0.0.1","::1"]),Fk=(t,e)=>!!t&&typeof t=="object"&&e in t,Mk=t=>{let e={};return Array.isArray(t.data)&&(e.data=t.data),Fk(t,"insight")&&(e.insight=t.insight),e},Dk=8*1024*1024,GN=0;function XN(t){if(t)try{return new URL(t.includes("://")?t:`http://${t}`).hostname}catch{return}}function Uk(t){let e=XN(t);return!!e&&VN.has(e)}function QN(t){try{let e=new URL(t);return(e.protocol==="http:"||e.protocol==="https:")&&Uk(e.host)}catch{return!1}}function ZN(t){return!!t&&/\bCode\/\d/.test(t)&&/\bElectron\//.test(t)}function eL(t,e){if(!e)return!1;try{return new URL(t).host===e}catch{return!1}}function Ri(t){return t instanceof Error?t.message:"Unknown error"}var Bk=t=>t.how==="editor"||t.how==="unreached"?t.via:void 0,tL=2e3;async function qk(t){let{getHtml:e,basePath:n,fsBase:r,port:s,reloadEmitter:i,sendChannel:o,getServerExports:a,getBulbBlocks:l,saveInferenceResult:c,localOverride:f,trusted:d=!1,trustHint:u,staticAssets:p,bulbAssets:h,sourceFile:m,bulbKey:g,onStop:b}=t,C=`${process.pid}-${++GN}-${Date.now()}`,T=r??n,E=new WN;E.use("*",async(w,A)=>{if(!Uk(w.req.header("host")))return w.text("Forbidden: untrusted Host",403);await A()}),E.use("*",async(w,A)=>{await A(),w.res.headers.set("Cross-Origin-Opener-Policy","same-origin"),w.res.headers.set("Cross-Origin-Embedder-Policy","credentialless")});let $=[["/__fs/*","the filesystem"],["/__api/*","server-side code (server.ts)"],["/__ai","AI (your API keys)"],["/__infer","AI (your API keys)"],["/__infer-save","the filesystem"]],O=async(w,A)=>{if(!d){let R=new URL(w.req.url).pathname,M=$.find(([K])=>K.endsWith("/*")?R.startsWith(K.slice(0,-2)):R===K)?.[1]??"server-side code (server.ts)";Sd(process.pid,M);let D=u?`
2927
- ${u}`:"";return w.text(`Forbidden: this capability requires --trust.${D}`,403)}await A()},P=async(w,A)=>{let R=w.req.header("sec-fetch-site");if(R){if(R!=="same-origin")return w.text(`Forbidden: ${R} request`,403)}else{let M=w.req.header("origin");if(M&&!eL(M,w.req.header("host")))return w.text("Forbidden: cross-origin request",403)}await A()};for(let[w]of $)E.use(w,O),E.use(w,P);E.use("/__log",P),E.post("/__log",async w=>{try{let{args:A}=await w.req.json();console.log(...A||[])}catch{}return w.json({ok:!0})});let k=new Dl,L=new Set,j=new Set,Q=Date.now();k.onArrival(({page:w,firstAttach:A,count:R})=>{o&&R===1&&console.log(it.connected),A&&R>1&&w.close("yielded").catch(()=>{})}),o&&k.onSettledEmpty(()=>console.log(it.disconnected));let U,ie=0,oe=async w=>{let A=Math.max(w.fresh?0:Q,k.lastDropAt);if(await k.whenArrives(Ap-(Date.now()-A)))return{how:"attached"};if(Date.now()-ie<tL)return{how:"none"};let R=`http://localhost:${s}#tb-relay`,M=await xd(R,n),D;return M?.where==="editor"?D={how:"editor",via:M.via}:(w.external==="force"||w.external==="follow"&&M?.where==="external")&&(await zN(R),D={how:"external"}),D?await k.whenArrives(uk)?D:{how:"unreached",via:Bk(D)}:(ie=Date.now(),{how:"none"})},ge=w=>k.count>0?Promise.resolve({how:"attached"}):U??=oe(w).finally(()=>{U=void 0});if(o){let w=0,A=new Map;E.use("/__send",P),E.post("/__send",async R=>{let M="";try{M=await R.req.text()}catch{}let D=Number(R.req.query("reply"))||0,K=k.count===0&&R.req.query("open")!==void 0?await ge({external:"follow",fresh:!1}):void 0,J=k.count,Ke=J===0&&k.lastDropAt?Date.now()-k.lastDropAt:void 0,Y={clients:J,droppedMsAgo:Ke,...K?{opening:K.how,via:Bk(K)}:{}};if(R.req.query("solo")!==void 0&&J!==1)return R.json({...Y,refused:J>1});if(J===0)return R.json(Y);let ue=ln=>{for(let Rt of k)Rt.send(ln).catch(()=>{})};if(D<=0)return ue({payload:M}),R.json(Y);let Pe=++w,Hr=await new Promise(ln=>{let Rt={expected:J,received:0,results:[],errors:[],finish:Vl=>{clearTimeout(Yl),A.delete(Pe),ln({results:Rt.results,errors:Rt.errors,timedOut:Vl})}},Yl=setTimeout(()=>Rt.finish(!0),D);A.set(Pe,Rt),ue({id:Pe,payload:M})});return R.json({...Y,...Hr})}),E.use("/__send-reply",P),E.post("/__send-reply",async R=>{try{let{id:M,results:D,errors:K}=await R.req.json(),J=A.get(M);J&&(J.results.push(...D??[]),J.errors.push(...K??[]),++J.received>=J.expected&&J.finish(!1))}catch{}return R.json({ok:!0})})}E.get("/",w=>w.html(e())),E.post("/__fs/read",async w=>{try{let{path:A}=await w.req.json(),R=await oi(A,T);return new Response(new Uint8Array(R),{headers:{"Content-Type":"application/octet-stream"}})}catch(A){let R=Ri(A);return w.json({error:R},400)}}),E.post("/__fs/write",async w=>{try{let A=w.req.query("path");return A?(await Ja(A,new Uint8Array(await w.req.arrayBuffer()),T),w.json({success:!0})):w.json({error:"Missing path"},400)}catch(A){let R=Ri(A);return w.json({error:R},400)}}),E.post("/__fs/list",async w=>{try{let{path:A}=await w.req.json();return w.json(await Wa(A??".",T))}catch(A){return w.json({error:Ri(A)},400)}}),E.post("/__fs/remove",async w=>{try{let{path:A}=await w.req.json();return await Ka(A,T),w.json({success:!0})}catch(A){return w.json({error:Ri(A)},400)}}),E.post("/__api/:name",async w=>{try{let A=w.req.param("name"),R=Kl(a?.(),A);if(!R)return w.json({error:`API function '${A}' not found`},404);let{args:M}=await w.req.json();if(Hl(R))return Jl(w,R(...M||[]));let D=await R(...M||[]);return w.json({result:D})}catch(A){let R=Ri(A);return w.json({error:R},500)}}),E.post("/__ai",async w=>{try{let{messages:A,system:R,effort:M,provider:D,model:K,webSearch:J,stream:Ke}=await w.req.json();if(!A||!Array.isArray(A)||A.length===0)return w.json({message:"messages array is required",code:"unknown",retryable:!1},400);let Y=vt(D,K);if(typeof Y=="string")return w.json({message:Y,code:"unknown",retryable:!1},400);let ue=await zt(Y,{messages:A,system:R,effort:M,webSearch:J,signal:w.req.raw.signal});if(!ue.ok){let ln=await vr(ue,Y.protocol);return w.json(ln,ue.status)}if(Ke)return Jl(w,On(ue,Y.protocol));let{text:Pe,usage:Hr}=await Sr(ue,Y.protocol);return Pe||console.warn("[tb.ai] Empty response from provider"),w.json({text:Pe,usage:Hr})}catch(A){return w.json(_i(A),500)}}),E.post("/__infer",async w=>{try{let{data:A}=await w.req.json().catch(()=>({})),R=l?.();if(!R?.infer.trim())return w.json({message:"This bulb has no infer.md block.",code:"unknown",retryable:!1},400);let M=vt();if(typeof M=="string")return w.json({message:M,code:"unknown",retryable:!1},400);let D=Array.isArray(A)?A.map(String):[],K=zd(R,D),J=await zt(M,{messages:[{role:"user",content:K}],signal:w.req.raw.signal});if(!J.ok){let Y=await vr(J,M.protocol);return w.json(Y,J.status)}let Ke=(async function*(){let Y="";for await(let Pe of On(J,M.protocol))Pe.kind!=="text"||!Pe.text||(Y+=Pe.text,yield{kind:"delta",text:Pe.text});let ue=Yd(Y);if(ue.parsed===void 0)throw console.warn(`[tb.infer] output not valid JSON after sanitize; raw output (last 4000 chars):
2928
- `+Y.slice(-4e3)),new Ne("LLM output is not valid JSON","parse_error",!0);ue.fixesApplied.length&&console.warn("[tb.infer] sanitized output, fixes applied:",ue.fixesApplied.join(", ")),yield{kind:"complete",insight:ue.parsed,data:D,fixesApplied:ue.fixesApplied}})();return Jl(w,Ke)}catch(A){return w.json(_i(A),500)}}),E.post("/__infer-save",async w=>{try{if(!c)return w.json({message:"Save is not available for this server.",code:"unknown",retryable:!1},400);let A=Mk(await w.req.json().catch(()=>({})));return Object.keys(A).length?(await c(A.data,Fk(A,"insight")?JSON.stringify(A.insight,null,2):void 0),w.json({ok:!0})):w.json({message:"Nothing to save \u2014 this page holds no runtime state.",code:"unknown",retryable:!1},400)}catch(A){return w.json(_i(A),500)}}),E.get("/__infer-info",w=>{let A=l?.(),R=Yr(A?.config??"").inference,M=jo(A?.data??""),D=!!A?.infer.trim(),K=vt();return typeof K=="string"?w.json({error:K,inference:R,data:M,hasInfer:D}):w.json({provider:K.protocol,model:K.model,inference:R,data:M,hasInfer:D})}),E.use("/__tb-decode",P),E.post("/__tb-decode",async w=>{let{hash:A}=await w.req.json().catch(()=>({})),R=typeof A=="string"?Gd(A):void 0;return w.json(R??{error:"invalid fragment"})}),E.use("/__tb-encode",P),E.post("/__tb-encode",async w=>{let A=Number(w.req.header("content-length"));if(Number.isFinite(A)&&A>Dk)return w.json({hash:""});let R=await w.req.text().catch(()=>"");if(R.length>Dk)return w.json({hash:""});let M;try{M=JSON.parse(R)}catch{return w.json({hash:""})}return w.json({hash:Vd(Mk(M))})}),E.get("/__infer-ui.js",w=>w.body(Nk,200,{"Content-Type":"text/javascript; charset=utf-8"})),E.get("/__models",async w=>{try{let A=await wt();return w.json(A)}catch{return w.json([],200)}}),E.get("/__ai-access",async w=>{try{return w.json(await ba())}catch{return w.json("none",200)}}),m&&E.get("/__source/*",async w=>{let A=await $p.readFile(m,"utf-8").catch(()=>{});return A===void 0?w.text("Not Found",404):new Response(A,{headers:{"Content-Type":"text/plain; charset=utf-8"}})});let Se=["esm.sh","unpkg.com","cdn.jsdelivr.net","cdnjs.cloudflare.com"],ae=new ql;E.get("/proxy/*",async w=>{let A=new URL(w.req.url),M=(A.pathname+A.search).slice(7),D=M.lastIndexOf("https://");return D===-1?w.text("Invalid proxy URL",400):ke(w,M.slice(D))}),f&&jk(E,`/local/${f.name}/`,f.serveDir),p&&jk(E,p.mount,p.dir),h&&E.get("/assets/*",async w=>{let{pathname:A}=new URL(w.req.url),R=A.slice(8),M;try{M=decodeURIComponent(R)}catch{return w.text("Not Found",404)}let D=ah(M);if(D)return w.text(`${D} is not an asset type: a bulb's code and markup live in the bulb; assets are media and data`,403);try{let J=await Jk(M,h.dir,{"Cache-Control":"no-cache"});if(J)return J}catch{return w.text("Not Found",404)}let K=h.remoteBase;return K?w.redirect(K+R,302):w.text("Not Found",404)});async function ke(w,A){let R;try{R=new URL(A)}catch{return w.text("Invalid URL",400)}if(R.protocol!=="https:")return w.text("HTTPS only",400);if(!Se.includes(R.hostname))return w.text("Host not allowed",403);let M=await ae.get(A);if(M)return new Response(M.body,{status:200,headers:Ip(M.contentType,M.cacheControl)});try{let D=await fetch(A,{headers:{Accept:w.req.header("Accept")||"*/*"},redirect:"follow"});if(!D.ok)return w.text(`Upstream ${D.status}`,D.status);let K=D.headers.get("Content-Type")||void 0,J=D.headers.get("Cache-Control")||void 0;if(D.body){let[Ke,Y]=D.body.tee();return(async()=>{try{let ue=await new Response(Y).arrayBuffer();await ae.set(A,{body:Buffer.from(ue),contentType:K,cacheControl:J})}catch{}})(),new Response(Ke,{status:D.status,headers:Ip(K,J)})}return new Response(null,{status:D.status,headers:Ip(K,J)})}catch(D){return w.text(`Proxy fetch failed: ${D instanceof Error?D.message:D}`,502)}}(i||o)&&(E.get("/__reload",w=>HN(w,async A=>{let R=w.req.query("bulb")||void 0;if(g&&R&&R!==g){L.has(R)||(L.add(R),console.log(it.closed("foreign"))),await A.writeSSE({event:"close",data:"foreign"});return}let M=()=>{A.writeSSE({event:"reload",data:""})};i?.on("reload",M);let D=()=>i?.removeListener("reload",M),K=w.req.query("relay")||void 0,J={inEditor:ZN(w.req.header("user-agent")),doc:K,open:Y=>A.writeSSE({event:"open-url",data:Y}),send:Y=>A.writeSSE({event:"message",data:JSON.stringify(Y)}),close:Y=>(D(),k.closing(J),console.log(it.closed(Y)),A.writeSSE({event:"close",data:Y}))},Ke=!!K&&!j.has(K);for(K&&j.add(K),k.add(J,Ke),A.onAbort(()=>{D(),k.dropped(J)}),await A.writeSSE({event:"hello",data:C,retry:ff});!A.aborted;)await A.sleep(3e4)})),E.use("/__open",P),E.post("/__open",async w=>{let A="";try{A=String((await w.req.json()).url??"")}catch{}if(!QN(A))return w.json({error:"a local http URL is required"},400);let R=[...k].find(M=>M.inEditor);return await R?.open(A),w.json({opened:!!R,pages:k.count})})),E.use("/__stop",P),E.post("/__stop",async w=>{if(w.req.header("sec-fetch-site")||w.req.header("origin"))return w.text("Forbidden: browser request",403);let A="close";try{let M=await w.req.json();(M?.pages==="keep"||M?.pages==="close")&&(A=M.pages)}catch{}let R=A==="close"?await k.closeAll("stopped"):{told:0,gone:0};return b&&setTimeout(()=>{b({pages:A})},50),w.json({closed:R.gone,stuck:R.told-R.gone,exiting:!!b})}),E.get("/__pages",w=>w.json({pages:k.count})),E.notFound(async w=>{if(w.req.method!=="GET")return w.text("Not Found",404);let A=new URL(w.req.url);return Lk(A.pathname,A.search)?ke(w,"https://esm.sh"+A.pathname+A.search):w.text("Not Found",404)});let _t=KN({fetch:E.fetch,port:s,hostname:YN});return _t.listening||await new Promise((w,A)=>{let R=M=>A(M);_t.once("error",R),_t.once("listening",()=>{_t.removeListener("error",R),w()})}),{port:s,close:()=>_t.close(),requestPage:ge,closePages:w=>k.closeAll(w),pageCount:()=>k.count}}function Ip(t,e){let n=new Headers;return t&&n.set("Content-Type",t),e&&n.set("Cache-Control",e),n.set("Access-Control-Allow-Origin","*"),n.set("Cross-Origin-Resource-Policy","cross-origin"),n}function jk(t,e,n){t.get(`${e}*`,async r=>{let{pathname:s}=new URL(r.req.url);if(!s.startsWith(e))return r.text("Not Found",404);try{return await Jk(decodeURIComponent(s.slice(e.length)),n)??r.text("Not Found",404)}catch{return r.text("Not Found",404)}})}async function Jk(t,e,n={}){let r=Pr(t,e),s=await $p.readFile(r).catch(()=>{});if(s)return new Response(s,{headers:{"Content-Type":oh(r),...n}})}Ie();bn();async function zl(t){let{port:e,portNote:n,makeServerOptions:r,makeEntry:s,displayName:i,waitTarget:o,stopLog:a}=t,l=`http://localhost:${e}`,c=s(e,l),f=[],d,u=!1,p=async m=>{if(!u){u=!0,console.log(`
2929
- Shutting down...`),(m?.pages??(ye(c)?"keep":"close"))==="close"&&await d?.closePages("stopped"),d?.close();for(let g of f)try{await g()}catch{}a(),await wn(process.pid),process.exit(0)}},h=await qk({...r(e),onStop:p}).catch(async m=>{if(m?.code!=="EADDRINUSE")throw m;return fd(e)});return d=h,await vd(c),console.log(`
2930
- ${i}`),console.log(` ${l}`),n&&console.log(` ${n}`),process.on("SIGINT",()=>{p()}),process.on("SIGTERM",()=>{p()}),{port:e,url:l,pageCount:()=>h.pageCount(),async handOver({mode:m,fresh:g,replacedLive:b}){if(m==="none")return;let C={fresh:g,external:b?"never":m==="window"?"force":"follow"},T=await h.requestPage(C);T.how==="attached"?console.log(` Reusing the open browser tab.
2933
+ `;Rr();$e();Cn();$a();Wt();import{stream as NL}from"hono/streaming";var LL="X-TB-Stream";function Di(t){return t instanceof Le?{message:t.message,code:t.code,retryable:t.retryable}:{message:t instanceof Error?t.message:"Unknown error",code:"unknown",retryable:!1}}function Vc(t,e){return t.header("Content-Type","application/x-ndjson; charset=utf-8"),t.header("Cache-Control","no-cache"),t.header(LL,"1"),NL(t,async n=>{let r=e[Symbol.asyncIterator]();n.onAbort(()=>{r.return?.()});try{for(;;){let{done:s,value:i}=await r.next();if(s)break;await n.writeln(JSON.stringify({type:"chunk",value:i}))}}catch(s){await n.writeln(JSON.stringify({type:"error",error:Di(s)}))}finally{try{await r.return?.()}catch{}}})}var Gc={log:(...t)=>console.log(...t)};function Xc(t,e){let n=t?.[e]??(Object.hasOwn(Gc,e)?Gc[e]:void 0);return typeof n=="function"?n:void 0}function Qc(t){return t.constructor?.name==="AsyncGeneratorFunction"}vf();var ML=/^\/(v\d+\/|stable\/|node\/|gh\/|@[^/]+\/[^@/]+@|[^@/]+@)/,DL=/[?&]target=/,BL=/^\/(?:@[^/]+\/)?[^/@]+\/[^/]+/;function ix(t,e=""){return ML.test(t)?!0:BL.test(t)&&DL.test(e)}var JL="127.0.0.1",WL=new Set(["localhost","127.0.0.1","::1"]),ux=(t,e)=>!!t&&typeof t=="object"&&e in t,ox=t=>{let e={};return Array.isArray(t.data)&&(e.data=t.data),ux(t,"insight")&&(e.insight=t.insight),e},ax=8*1024*1024,KL=0;function HL(t){if(t)try{return new URL(t.includes("://")?t:`http://${t}`).hostname}catch{return}}function dx(t){let e=HL(t);return!!e&&WL.has(e)}function zL(t){try{let e=new URL(t);return(e.protocol==="http:"||e.protocol==="https:")&&dx(e.host)}catch{return!1}}function YL(t){return!!t&&/\bCode\/\d/.test(t)&&/\bElectron\//.test(t)}function VL(t,e){if(!e)return!1;try{return new URL(t).host===e}catch{return!1}}function Bi(t){return t instanceof Error?t.message:"Unknown error"}var cx=t=>t.how==="editor"||t.how==="unreached"?t.via:void 0,GL=2e3;async function fx(t){let{getHtml:e,basePath:n,fsBase:r,port:s,reloadEmitter:i,sendChannel:o,getServerExports:a,getBulbBlocks:c,saveInferenceResult:l,localOverride:f,trusted:u=!1,trustHint:d,staticAssets:p,bulbAssets:h,sourceFile:m,bulbKey:g,onStop:b}=t,C=`${process.pid}-${++KL}-${Date.now()}`,T=r??n,E=new jL;E.use("*",async(w,A)=>{if(!dx(w.req.header("host")))return w.text("Forbidden: untrusted Host",403);await A()}),E.use("*",async(w,A)=>{await A(),w.res.headers.set("Cross-Origin-Opener-Policy","same-origin"),w.res.headers.set("Cross-Origin-Embedder-Policy","credentialless")});let R=[["/__fs/*","the filesystem"],["/__api/*","server-side code (server.ts)"],["/__ai","AI (your API keys)"],["/__infer","AI (your API keys)"],["/__infer-save","the filesystem"]],O=async(w,A)=>{if(!u){let I=new URL(w.req.url).pathname,L=R.find(([K])=>K.endsWith("/*")?I.startsWith(K.slice(0,-2)):I===K)?.[1]??"server-side code (server.ts)";Cd(process.pid,L);let B=d?`
2934
+ ${d}`:"";return w.text(`Forbidden: this capability requires --trust.${B}`,403)}await A()},_=async(w,A)=>{let I=w.req.header("sec-fetch-site");if(I){if(I!=="same-origin")return w.text(`Forbidden: ${I} request`,403)}else{let L=w.req.header("origin");if(L&&!VL(L,w.req.header("host")))return w.text("Forbidden: cross-origin request",403)}await A()};for(let[w]of R)E.use(w,O),E.use(w,_);E.use("/__log",_),E.post("/__log",async w=>{try{let{args:A}=await w.req.json();console.log(...A||[])}catch{}return w.json({ok:!0})});let x=new Wc,M=new Set,F=new Set,ee=Date.now();x.onArrival(({page:w,firstAttach:A,count:I})=>{o&&I===1&&console.log(ot.connected),A&&I>1&&w.close("yielded").catch(()=>{})}),o&&x.onSettledEmpty(()=>console.log(ot.disconnected));let q,ue=0,ie=async w=>{let A=Math.max(w.fresh?0:ee,x.lastDropAt);if(await x.whenArrives(Mp-(Date.now()-A)))return{how:"attached"};if(Date.now()-ue<GL)return{how:"none"};let I=`http://localhost:${s}#tb-relay`,L=await Pd(I,n),B;return L?.where==="editor"?B={how:"editor",via:L.via}:(w.external==="force"||w.external==="follow"&&L?.where==="external")&&(await qL(I),B={how:"external"}),B?await x.whenArrives($k)?B:{how:"unreached",via:cx(B)}:(ue=Date.now(),{how:"none"})},ye=w=>x.count>0?Promise.resolve({how:"attached"}):q??=ie(w).finally(()=>{q=void 0});if(o){let w=0,A=new Map;E.use("/__send",_),E.post("/__send",async I=>{let L="";try{L=await I.req.text()}catch{}let B=Number(I.req.query("reply"))||0,K=x.count===0&&I.req.query("open")!==void 0?await ye({external:"follow",fresh:!1}):void 0,H=x.count,Be=H===0&&x.lastDropAt?Date.now()-x.lastDropAt:void 0,Y={clients:H,droppedMsAgo:Be,...K?{opening:K.how,via:cx(K)}:{}};if(I.req.query("solo")!==void 0&&H!==1)return I.json({...Y,refused:H>1});if(H===0)return I.json(Y);let fe=un=>{for(let _t of x)_t.send(un).catch(()=>{})};if(B<=0)return fe({payload:L}),I.json(Y);let Re=++w,Qr=await new Promise(un=>{let _t={expected:H,received:0,results:[],errors:[],finish:tl=>{clearTimeout(el),A.delete(Re),un({results:_t.results,errors:_t.errors,timedOut:tl})}},el=setTimeout(()=>_t.finish(!0),B);A.set(Re,_t),fe({id:Re,payload:L})});return I.json({...Y,...Qr})}),E.use("/__send-reply",_),E.post("/__send-reply",async I=>{try{let{id:L,results:B,errors:K}=await I.req.json(),H=A.get(L);H&&(H.results.push(...B??[]),H.errors.push(...K??[]),++H.received>=H.expected&&H.finish(!1))}catch{}return I.json({ok:!0})})}E.get("/",w=>w.html(e())),E.post("/__fs/read",async w=>{try{let{path:A}=await w.req.json(),I=await di(A,T);return new Response(new Uint8Array(I),{headers:{"Content-Type":"application/octet-stream"}})}catch(A){let I=Bi(A);return w.json({error:I},400)}}),E.post("/__fs/write",async w=>{try{let A=w.req.query("path");return A?(await Ga(A,new Uint8Array(await w.req.arrayBuffer()),T),w.json({success:!0})):w.json({error:"Missing path"},400)}catch(A){let I=Bi(A);return w.json({error:I},400)}}),E.post("/__fs/list",async w=>{try{let{path:A}=await w.req.json();return w.json(await Xa(A??".",T))}catch(A){return w.json({error:Bi(A)},400)}}),E.post("/__fs/remove",async w=>{try{let{path:A}=await w.req.json();return await Qa(A,T),w.json({success:!0})}catch(A){return w.json({error:Bi(A)},400)}}),E.post("/__api/:name",async w=>{try{let A=w.req.param("name"),I=Xc(a?.(),A);if(!I)return w.json({error:`API function '${A}' not found`},404);let{args:L}=await w.req.json();if(Qc(I))return Vc(w,I(...L||[]));let B=await I(...L||[]);return w.json({result:B})}catch(A){let I=Bi(A);return w.json({error:I},500)}}),E.post("/__ai",async w=>{try{let{messages:A,system:I,effort:L,provider:B,model:K,webSearch:H,stream:Be}=await w.req.json();if(!A||!Array.isArray(A)||A.length===0)return w.json({message:"messages array is required",code:"unknown",retryable:!1},400);let Y=St(B,K);if(typeof Y=="string")return w.json({message:Y,code:"unknown",retryable:!1},400);let fe=await Ht(Y,{messages:A,system:I,effort:L,webSearch:H,signal:w.req.raw.signal});if(!fe.ok){let un=await xr(fe,Y.protocol);return w.json(un,fe.status)}if(Be)return Vc(w,_n(fe,Y.protocol));let{text:Re,usage:Qr}=await Er(fe,Y.protocol);return Re||console.warn("[tb.ai] Empty response from provider"),w.json({text:Re,usage:Qr})}catch(A){return w.json(Di(A),500)}}),E.post("/__infer",async w=>{try{let{data:A}=await w.req.json().catch(()=>({})),I=c?.();if(!I?.infer.trim())return w.json({message:"This bulb has no infer.md block.",code:"unknown",retryable:!1},400);let L=St();if(typeof L=="string")return w.json({message:L,code:"unknown",retryable:!1},400);let B=Array.isArray(A)?A.map(String):[],K=Zd(I,B),H=await Ht(L,{messages:[{role:"user",content:K}],signal:w.req.raw.signal});if(!H.ok){let Y=await xr(H,L.protocol);return w.json(Y,H.status)}let Be=(async function*(){let Y="";for await(let Re of _n(H,L.protocol))Re.kind!=="text"||!Re.text||(Y+=Re.text,yield{kind:"delta",text:Re.text});let fe=ef(Y);if(fe.parsed===void 0)throw console.warn(`[tb.infer] output not valid JSON after sanitize; raw output (last 4000 chars):
2935
+ `+Y.slice(-4e3)),new Le("LLM output is not valid JSON","parse_error",!0);fe.fixesApplied.length&&console.warn("[tb.infer] sanitized output, fixes applied:",fe.fixesApplied.join(", ")),yield{kind:"complete",insight:fe.parsed,data:B,fixesApplied:fe.fixesApplied}})();return Vc(w,Be)}catch(A){return w.json(Di(A),500)}}),E.post("/__infer-save",async w=>{try{if(!l)return w.json({message:"Save is not available for this server.",code:"unknown",retryable:!1},400);let A=ox(await w.req.json().catch(()=>({})));return Object.keys(A).length?(await l(A.data,ux(A,"insight")?JSON.stringify(A.insight,null,2):void 0),w.json({ok:!0})):w.json({message:"Nothing to save \u2014 this page holds no runtime state.",code:"unknown",retryable:!1},400)}catch(A){return w.json(Di(A),500)}}),E.get("/__infer-info",w=>{let A=c?.(),I=es(A?.config??"").inference,L=Ho(A?.data??""),B=!!A?.infer.trim(),K=St();return typeof K=="string"?w.json({error:K,inference:I,data:L,hasInfer:B}):w.json({provider:K.protocol,model:K.model,inference:I,data:L,hasInfer:B})}),E.use("/__tb-decode",_),E.post("/__tb-decode",async w=>{let{hash:A}=await w.req.json().catch(()=>({})),I=typeof A=="string"?nf(A):void 0;return w.json(I??{error:"invalid fragment"})}),E.use("/__tb-encode",_),E.post("/__tb-encode",async w=>{let A=Number(w.req.header("content-length"));if(Number.isFinite(A)&&A>ax)return w.json({hash:""});let I=await w.req.text().catch(()=>"");if(I.length>ax)return w.json({hash:""});let L;try{L=JSON.parse(I)}catch{return w.json({hash:""})}return w.json({hash:tf(ox(L))})}),E.get("/__infer-ui.js",w=>w.body(sx,200,{"Content-Type":"text/javascript; charset=utf-8"})),E.get("/__models",async w=>{try{let A=await vt();return w.json(A)}catch{return w.json([],200)}}),E.get("/__ai-access",async w=>{try{return w.json(await Aa())}catch{return w.json("none",200)}}),m&&E.get("/__source/*",async w=>{let A=await Jp.readFile(m,"utf-8").catch(()=>{});return A===void 0?w.text("Not Found",404):new Response(A,{headers:{"Content-Type":"text/plain; charset=utf-8"}})});let xe=["esm.sh","unpkg.com","cdn.jsdelivr.net","cdnjs.cloudflare.com"],de=new Yc;E.get("/proxy/*",async w=>{let A=new URL(w.req.url),L=(A.pathname+A.search).slice(7),B=L.lastIndexOf("https://");return B===-1?w.text("Invalid proxy URL",400):be(w,L.slice(B))}),f&&lx(E,`/local/${f.name}/`,f.serveDir),p&&lx(E,p.mount,p.dir),h&&E.get("/assets/*",async w=>{let{pathname:A}=new URL(w.req.url),I=A.slice(8),L;try{L=decodeURIComponent(I)}catch{return w.text("Not Found",404)}let B=yh(L);if(B)return w.text(`${B} is not an asset type: a bulb's code and markup live in the bulb; assets are media and data`,403);try{let H=await px(L,h.dir,{"Cache-Control":"no-cache"});if(H)return H}catch{return w.text("Not Found",404)}let K=h.remoteBase;return K?w.redirect(K+I,302):w.text("Not Found",404)});async function be(w,A){let I;try{I=new URL(A)}catch{return w.text("Invalid URL",400)}if(I.protocol!=="https:")return w.text("HTTPS only",400);if(!xe.includes(I.hostname))return w.text("Host not allowed",403);let L=await de.get(A);if(L)return new Response(L.body,{status:200,headers:qp(L.contentType,L.cacheControl)});try{let B=await fetch(A,{headers:{Accept:w.req.header("Accept")||"*/*"},redirect:"follow"});if(!B.ok)return w.text(`Upstream ${B.status}`,B.status);let K=B.headers.get("Content-Type")||void 0,H=B.headers.get("Cache-Control")||void 0;if(B.body){let[Be,Y]=B.body.tee();return(async()=>{try{let fe=await new Response(Y).arrayBuffer();await de.set(A,{body:Buffer.from(fe),contentType:K,cacheControl:H})}catch{}})(),new Response(Be,{status:B.status,headers:qp(K,H)})}return new Response(null,{status:B.status,headers:qp(K,H)})}catch(B){return w.text(`Proxy fetch failed: ${B instanceof Error?B.message:B}`,502)}}(i||o)&&(E.get("/__reload",w=>UL(w,async A=>{let I=w.req.query("bulb")||void 0;if(g&&I&&I!==g){M.has(I)||(M.add(I),console.log(ot.closed("foreign"))),await A.writeSSE({event:"close",data:"foreign"});return}let L=()=>{A.writeSSE({event:"reload",data:""})};i?.on("reload",L);let B=()=>i?.removeListener("reload",L),K=w.req.query("relay")||void 0,H={inEditor:YL(w.req.header("user-agent")),doc:K,open:Y=>A.writeSSE({event:"open-url",data:Y}),send:Y=>A.writeSSE({event:"message",data:JSON.stringify(Y)}),close:Y=>(B(),x.closing(H),console.log(ot.closed(Y)),A.writeSSE({event:"close",data:Y}))},Be=!!K&&!F.has(K);for(K&&F.add(K),x.add(H,Be),A.onAbort(()=>{B(),x.dropped(H)}),await A.writeSSE({event:"hello",data:C,retry:bf});!A.aborted;)await A.sleep(3e4)})),E.use("/__open",_),E.post("/__open",async w=>{let A="";try{A=String((await w.req.json()).url??"")}catch{}if(!zL(A))return w.json({error:"a local http URL is required"},400);let I=[...x].find(L=>L.inEditor);return await I?.open(A),w.json({opened:!!I,pages:x.count})})),E.use("/__stop",_),E.post("/__stop",async w=>{if(w.req.header("sec-fetch-site")||w.req.header("origin"))return w.text("Forbidden: browser request",403);let A="close";try{let L=await w.req.json();(L?.pages==="keep"||L?.pages==="close")&&(A=L.pages)}catch{}let I=A==="close"?await x.closeAll("stopped"):{told:0,gone:0};return b&&setTimeout(()=>{b({pages:A})},50),w.json({closed:I.gone,stuck:I.told-I.gone,exiting:!!b})}),E.get("/__pages",w=>w.json({pages:x.count})),E.notFound(async w=>{if(w.req.method!=="GET")return w.text("Not Found",404);let A=new URL(w.req.url);return ix(A.pathname,A.search)?be(w,"https://esm.sh"+A.pathname+A.search):w.text("Not Found",404)});let ln=FL({fetch:E.fetch,port:s,hostname:JL});return ln.listening||await new Promise((w,A)=>{let I=L=>A(L);ln.once("error",I),ln.once("listening",()=>{ln.removeListener("error",I),w()})}),{port:s,close:()=>ln.close(),requestPage:ye,closePages:w=>x.closeAll(w),pageCount:()=>x.count}}function qp(t,e){let n=new Headers;return t&&n.set("Content-Type",t),e&&n.set("Cache-Control",e),n.set("Access-Control-Allow-Origin","*"),n.set("Cross-Origin-Resource-Policy","cross-origin"),n}function lx(t,e,n){t.get(`${e}*`,async r=>{let{pathname:s}=new URL(r.req.url);if(!s.startsWith(e))return r.text("Not Found",404);try{return await px(decodeURIComponent(s.slice(e.length)),n)??r.text("Not Found",404)}catch{return r.text("Not Found",404)}})}async function px(t,e,n={}){let r=Ir(t,e),s=await Jp.readFile(r).catch(()=>{});if(s)return new Response(s,{headers:{"Content-Type":gh(r),...n}})}$e();vn();async function Zc(t){let{port:e,portNote:n,makeServerOptions:r,makeEntry:s,displayName:i,waitTarget:o,stopLog:a}=t,c=`http://localhost:${e}`,l=s(e,c),f=[],u,d=!1,p=async m=>{if(!d){d=!0,console.log(`
2936
+ Shutting down...`),(m?.pages??(we(l)?"keep":"close"))==="close"&&await u?.closePages("stopped"),u?.close();for(let g of f)try{await g()}catch{}a(),await Sn(process.pid),process.exit(0)}},h=await fx({...r(e),onStop:p}).catch(async m=>{if(m?.code!=="EADDRINUSE")throw m;return bd(e)});return u=h,await Td(l),console.log(`
2937
+ ${i}`),console.log(` ${c}`),n&&console.log(` ${n}`),process.on("SIGINT",()=>{p()}),process.on("SIGTERM",()=>{p()}),{port:e,url:c,pageCount:()=>h.pageCount(),async handOver({mode:m,fresh:g,replacedLive:b}){if(m==="none")return;let C={fresh:g,external:b?"never":m==="window"?"force":"follow"},T=await h.requestPage(C);T.how==="attached"?console.log(` Reusing the open browser tab.
2931
2938
  `):T.how==="editor"?console.log(` Opened in VS Code via ${T.via}.
2932
2939
  `):T.how==="external"?console.log(` Opened in your browser.
2933
- `):console.log(` ${T.how==="unreached"?`Opened ${T.via?`in VS Code via ${T.via}`:"in your browser"}, but no page attached \u2014 is the browser it opened in still there?`:ye(c)?"No page opened \u2014 nothing is reading this mirror until someone opens it.":"No page opened \u2014 no agent mirror page to open one through, and a bulb runs in its page."}
2934
- Share ${l}, and wake on the arrival:
2935
- typebulb wait ${o} --match "${it.connected}"
2936
- `)},onCleanup(m){f.push(m)}}}bn();import nL from"chokidar";import Wk from"node:fs";import rL from"node:path";var sL={persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}};function on(t){let{target:e,onChange:n,events:r="change",debounceMs:s=150}=t,i,o=nL.watch(e,sL);o.on("error",l=>console.warn(`watch: ${l instanceof Error?l.message:l} \u2014 continuing`));let a=()=>{i&&clearTimeout(i),i=setTimeout(n,s)};return r==="all"?o.on("all",a):o.on("change",a),()=>{i&&clearTimeout(i),o.close()}}var iL=t=>process.platform==="win32"||process.platform==="darwin"?t.toLowerCase()==="assets":t==="assets";function Kk(t,e,n=150){let r,s=()=>{r&&clearTimeout(r),r=setTimeout(e,n)};try{let i=Wk.watch(t,{recursive:!0},(o,a)=>{a&&iL(a.split(/[\\/]/)[0])&&s()});return i.on("error",o=>console.warn(`watch: ${o instanceof Error?o.message:o} \u2014 continuing`)),()=>{r&&clearTimeout(r),i.close()}}catch{let i=rL.join(t,"assets");return Wk.existsSync(i)?on({target:i,onChange:e,events:"all",debounceMs:n}):()=>{}}}Ie();je();Or();async function Hk(t,e,n,r){e.port!==void 0&&(console.error("--port isn't supported when running a bulb: a bulb keeps its assigned project port across runs, and moving it strands the open tab."),console.error("It applies to `typebulb agent`. Run the bulb with no --port; `typebulb logs` prints the URL it kept."),process.exit(1));let s=process.cwd(),i=Fs(process.pid),o=e.watch?new oL:void 0,a=be(e.mode),l=(await yn(process.cwd()))(t),c=await lr({kind:"bulb",file:t},process.cwd()),f=await da(t,c);f.length&&console.log(`Replacing the running server for this bulb (pid ${f.map(oe=>oe.pid).join(", ")})`);let d=f.length>0||Date.now()-l<$w,{port:u,note:p}=await oa({target:{kind:"bulb",file:t},cwd:process.cwd()});c!==void 0&&u!==c&&d&&(console.error(`
2937
- Port ${c} is this bulb's, and a page of it may be waiting there, but something else took it.`),console.error("Free that port and relaunch; starting elsewhere would leave that page running with no way to reach it."),process.exit(1));let h=0,m=()=>console.log(bd(++h));m(),console.log(`Loading ${qn.basename(t)}...`);let{html:g,bulb:b,serverExports:C}=await gf(t,e.watch,e.trust,r);Ht(a,t,b.server);let T=In(t),E=Rr(qn.resolve(t)),$=e.trust?void 0:hr(b),{port:O,onCleanup:P,handOver:k,pageCount:L}=await zl({port:u,portNote:p,displayName:b.name,stopLog:i,makeServerOptions:oe=>({getHtml:()=>g,basePath:s,fsBase:_r(t),port:oe,reloadEmitter:o,sendChannel:!0,getServerExports:()=>C,getBulbBlocks:()=>({infer:b.infer,insight:b.insight,code:b.code,config:b.config,data:b.data}),saveInferenceResult:async(ge,Se)=>{let ae=await an.readFile(t,"utf-8");ge!==void 0&&(ae=zr(ae,"data",ge.join(oy))),Se!==void 0&&(ae=zr(ae,"insight",Se)),await an.writeFile(t,ae)},localOverride:r?{name:r.name,serveDir:r.serveDir}:void 0,bulbAssets:{dir:T,remoteBase:E&&Fi(E.userSlug,E.slug)},sourceFile:t,bulbKey:Bs(t),trusted:e.trust,trustHint:n}),makeEntry:(oe,ge)=>({pid:process.pid,port:oe,url:ge,file:t,cwd:process.cwd(),startedAt:Date.now(),trust:e.trust,mode:e.mode,predicted:$,watch:e.watch?void 0:!1,replace:e.local?`${e.local.name}=${e.local.dir}`:void 0}),waitTarget:qn.relative(process.cwd(),t)||qn.basename(t)});e.trust?console.log(" trust: granted (filesystem, AI, server.ts enabled)"):console.log($?` trust: restricted \u2014 this bulb appears to use ${$}; re-run with --trust to enable it:
2940
+ `):console.log(` ${T.how==="unreached"?`Opened ${T.via?`in VS Code via ${T.via}`:"in your browser"}, but no page attached \u2014 is the browser it opened in still there?`:we(l)?"No page opened \u2014 nothing is reading this mirror until someone opens it.":"No page opened \u2014 no agent mirror page to open one through, and a bulb runs in its page."}
2941
+ Share ${c}, and wake on the arrival:
2942
+ typebulb wait ${o} --match "${ot.connected}"
2943
+ `)},onCleanup(m){f.push(m)}}}vn();import XL from"chokidar";import hx from"node:fs";import QL from"node:path";var ZL={persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}};function an(t){let{target:e,onChange:n,events:r="change",debounceMs:s=150}=t,i,o=XL.watch(e,ZL);o.on("error",c=>console.warn(`watch: ${c instanceof Error?c.message:c} \u2014 continuing`));let a=()=>{i&&clearTimeout(i),i=setTimeout(n,s)};return r==="all"?o.on("all",a):o.on("change",a),()=>{i&&clearTimeout(i),o.close()}}var eM=t=>process.platform==="win32"||process.platform==="darwin"?t.toLowerCase()==="assets":t==="assets";function mx(t,e,n=150){let r,s=()=>{r&&clearTimeout(r),r=setTimeout(e,n)};try{let i=hx.watch(t,{recursive:!0},(o,a)=>{a&&eM(a.split(/[\\/]/)[0])&&s()});return i.on("error",o=>console.warn(`watch: ${o instanceof Error?o.message:o} \u2014 continuing`)),()=>{r&&clearTimeout(r),i.close()}}catch{let i=QL.join(t,"assets");return hx.existsSync(i)?an({target:i,onChange:e,events:"all",debounceMs:n}):()=>{}}}$e();Ue();Rr();async function gx(t,e,n,r){e.port!==void 0&&(console.error("--port isn't supported when running a bulb: a bulb keeps its assigned project port across runs, and moving it strands the open tab."),console.error("It applies to `typebulb agent`. Run the bulb with no --port; `typebulb logs` prints the URL it kept."),process.exit(1));let s=process.cwd(),i=Ks(process.pid),o=e.watch?new tM:void 0,a=ve(e.mode),c=(await wn(process.cwd()))(t),l=await dr({kind:"bulb",file:t},process.cwd()),f=await ba(t,l);f.length&&console.log(`Replacing the running server for this bulb (pid ${f.map(ie=>ie.pid).join(", ")})`);let u=f.length>0||Date.now()-c<Jw,{port:d,note:p}=await pa({target:{kind:"bulb",file:t},cwd:process.cwd()});l!==void 0&&d!==l&&u&&(console.error(`
2944
+ Port ${l} is this bulb's, and a page of it may be waiting there, but something else took it.`),console.error("Free that port and relaunch; starting elsewhere would leave that page running with no way to reach it."),process.exit(1));let h=0,m=()=>console.log(Ed(++h));m(),console.log(`Loading ${Wn.basename(t)}...`);let{html:g,bulb:b,serverExports:C}=await kf(t,e.watch,e.trust,r);Kt(a,t,b.server);let T=Nn(t),E=Nr(Wn.resolve(t)),R=e.trust?void 0:yr(b),{port:O,onCleanup:_,handOver:x,pageCount:M}=await Zc({port:d,portNote:p,displayName:b.name,stopLog:i,makeServerOptions:ie=>({getHtml:()=>g,basePath:s,fsBase:$r(t),port:ie,reloadEmitter:o,sendChannel:!0,getServerExports:()=>C,getBulbBlocks:()=>({infer:b.infer,insight:b.insight,code:b.code,config:b.config,data:b.data}),saveInferenceResult:async(ye,xe)=>{let de=await cn.readFile(t,"utf-8");ye!==void 0&&(de=Zr(de,"data",ye.join(gy))),xe!==void 0&&(de=Zr(de,"insight",xe)),await cn.writeFile(t,de)},localOverride:r?{name:r.name,serveDir:r.serveDir}:void 0,bulbAssets:{dir:T,remoteBase:E&&zi(E.userSlug,E.slug)},sourceFile:t,bulbKey:Js(t),trusted:e.trust,trustHint:n}),makeEntry:(ie,ye)=>({pid:process.pid,port:ie,url:ye,file:t,cwd:process.cwd(),startedAt:Date.now(),trust:e.trust,mode:e.mode,predicted:R,watch:e.watch?void 0:!1,replace:e.local?`${e.local.name}=${e.local.dir}`:void 0}),waitTarget:Wn.relative(process.cwd(),t)||Wn.basename(t)});e.trust?console.log(" trust: granted (filesystem, AI, server.ts enabled)"):console.log(R?` trust: restricted \u2014 this bulb appears to use ${R}; re-run with --trust to enable it:
2938
2945
  ${n}
2939
2946
  `:` trust: restricted \u2014 re-run with --trust to enable filesystem / AI / server.ts
2940
2947
  `),e.watch&&console.log(` Watching for changes...
2941
- `);let j,Q,U=()=>{L()===0&&console.log(" No page attached \u2014 nothing reloaded; this change is not live."),o?.emit("reload")},ie=oe=>{console.log(oe),m(),U()};if(e.watch&&o){let oe=0,ge=Promise.resolve();if(j=on({target:t,onChange:()=>{let ae=++oe;ge=ge.then(async()=>{if(ae===oe)try{console.log("Recompiling...");let ke=await gf(t,!0,e.trust,r);g=ke.html,C=ke.serverExports,b=ke.bulb,ke.buildError||m(),U()}catch(ke){console.error("Recompile failed:",ke)}})}}),r){let{name:ae,serveDir:ke}=r;Q=on({target:ke,events:"all",onChange:()=>ie(`Local package '${ae}' changed.`)})}let Se=_r(t);await an.stat(Se).then(ae=>ae.isDirectory()).catch(()=>!1)&&P(Kk(Se,()=>ie("Assets changed.")))}j&&P(j),Q&&P(Q),P(()=>an.rm(mf(t),{force:!0})),await k({mode:e.open,fresh:!d,replacedLive:f.some(oe=>oe.port===O)})}et();import{readFileSync as Lp,copyFileSync as lL,existsSync as cL,writeFileSync as uL,renameSync as dL,rmSync as fL}from"fs";import*as he from"path";import{fileURLToPath as pL}from"url";import{EventEmitter as hL}from"events";import mL from"open";bn();Ie();Or();var Np=t=>`/agents/${t}/client.js`,aL=`
2948
+ `);let F,ee,q=()=>{M()===0&&console.log(" No page attached \u2014 nothing reloaded; this change is not live."),o?.emit("reload")},ue=ie=>{console.log(ie),m(),q()};if(e.watch&&o){let ie=0,ye=Promise.resolve();if(F=an({target:t,onChange:()=>{let de=++ie;ye=ye.then(async()=>{if(de===ie)try{console.log("Recompiling...");let be=await kf(t,!0,e.trust,r);g=be.html,C=be.serverExports,b=be.bulb,be.buildError||m(),q()}catch(be){console.error("Recompile failed:",be)}})}}),r){let{name:de,serveDir:be}=r;ee=an({target:be,events:"all",onChange:()=>ue(`Local package '${de}' changed.`)})}let xe=$r(t);await cn.stat(xe).then(de=>de.isDirectory()).catch(()=>!1)&&_(mx(xe,()=>ue("Assets changed.")))}F&&_(F),ee&&_(ee),_(()=>cn.rm(Sf(t),{force:!0})),await x({mode:e.open,fresh:!u,replacedLive:f.some(ie=>ie.port===O)})}tt();import{readFileSync as Kp,copyFileSync as rM,existsSync as sM,writeFileSync as iM,renameSync as oM,rmSync as aM}from"fs";import*as me from"path";import{fileURLToPath as cM}from"url";import{EventEmitter as lM}from"events";import uM from"open";vn();$e();Rr();var Wp=t=>`/agents/${t}/client.js`,nM=`
2942
2949
  (() => {
2943
2950
  const api = async (name, ...args) => {
2944
2951
  const resp = await fetch('/__api/' + name, {
@@ -2967,18 +2974,18 @@ Port ${c} is this bulb's, and a page of it may be waiting there, but something e
2967
2974
  })
2968
2975
  });
2969
2976
  if (window.__TYPEBULB_WATCH__) {
2970
- ${Ba()}
2977
+ ${Ka()}
2971
2978
  }
2972
2979
  })();
2973
- `;function zk(t){let{name:e,agent:n,styles:r,katex:s,mountHtml:i,watch:o,theme:a}=t,l=Np(n);return`<!DOCTYPE html>
2980
+ `;function yx(t){let{name:e,agent:n,styles:r,katex:s,mountHtml:i,watch:o,theme:a}=t,c=Wp(n);return`<!DOCTYPE html>
2974
2981
  <html>
2975
2982
  <head>
2976
2983
  <meta charset="utf-8">
2977
2984
  <meta name="viewport" content="width=device-width, initial-scale=1">
2978
- <title>${Ma(e)} - typebulb</title>
2979
- ${Da(e,a)}
2985
+ <title>${Ja(e)} - typebulb</title>
2986
+ ${Wa(e,a)}
2980
2987
  <style>
2981
- ${Os}
2988
+ ${Ns}
2982
2989
  </style>
2983
2990
  <style>
2984
2991
  ${r}
@@ -2993,18 +3000,18 @@ ${i}
2993
3000
  ${o?"<script>window.__TYPEBULB_WATCH__ = true;</script>":""}
2994
3001
 
2995
3002
  <script>
2996
- ${aL}
3003
+ ${nM}
2997
3004
  </script>
2998
3005
 
2999
- <script type="module" src="${l}"></script>
3006
+ <script type="module" src="${c}"></script>
3000
3007
  </body>
3001
- </html>`}async function Yk(t){let e=process.cwd(),n=t.agentTarget;RS(n)||(console.error(`Unknown agent '${n}'. Known: ${Ur().join(", ")}.`),process.exit(1));let r=await ua(e,n);if(r){console.log(`Mirror '${n}' is already running for this project:
3002
- ${r.url}`),t.open==="window"&&await mL(r.url);return}let s=Fs(process.pid),i=t.watch?new hL:void 0,o=be(t.mode),a=await IS(n),l=a.displayName||`${n} mirror`;Ht(o,he.join(e,"mirror"));let c=he.dirname(pL(import.meta.url)),f=he.join(c,"agents",n),d=he.join(c,"..","cli","agents"),u=he.join(f,"styles.css"),p=he.join(f,"katex.min.css"),h=he.join(f,"index.html"),m=()=>zk({name:l,agent:n,styles:Lp(u,"utf8"),katex:Lp(p,"utf8"),mountHtml:Lp(h,"utf8"),watch:t.watch}),{port:g,note:b}=await oa({explicit:t.port,target:{kind:"mirror",agent:n},cwd:e}),{port:C,url:T,onCleanup:E,handOver:$,pageCount:O}=await zl({port:g,portNote:b,displayName:l,stopLog:s,waitTarget:"agent",makeServerOptions:U=>({getHtml:m,basePath:e,port:U,reloadEmitter:i,getServerExports:()=>a,trusted:!0,staticAssets:{mount:`${he.posix.dirname(Np(n))}/`,dir:f}}),makeEntry:(U,ie)=>({pid:process.pid,port:U,url:ie,file:`agent:${n}`,cwd:e,startedAt:Date.now(),trust:!0,agent:n})}),P=he.join(d,n,"client"),k=he.join(d,"core","client"),L=cL(P);t.watch&&L&&console.log(` Watching for changes...
3003
- `);async function j(){let U=await import("esbuild"),{outputFiles:ie}=await U.build({entryPoints:[he.join(P,"index.ts")],bundle:!0,platform:"browser",format:"esm",outfile:he.join(f,"client.js"),write:!1}),oe=he.join(f,"client.js"),ge=`${oe}.${process.pid}.tmp`;uL(ge,ie[0].contents);for(let Se=1;;Se++)try{dL(ge,oe);break}catch(ae){if(Se===10)throw fL(ge,{force:!0}),ae;await new Promise(ke=>setTimeout(ke,50))}for(let Se of["styles.css","index.html","typebulb.png","typebulb-inv.png"])lL(he.join(k,Se),he.join(f,Se))}let Q;if(t.watch&&L&&i){let U=!1;Q=on({target:d,events:"all",onChange:async()=>{if(!U){U=!0;try{await j(),console.log(O()?`Mirror rebuilt. Reloading.
3008
+ </html>`}async function bx(t){let e=process.cwd(),n=t.agentTarget;ek(n)||(console.error(`Unknown agent '${n}'. Known: ${zr().join(", ")}.`),process.exit(1));let r=await ya(e,n);if(r){console.log(`Mirror '${n}' is already running for this project:
3009
+ ${r.url}`),t.open==="window"&&await uM(r.url);return}let s=Ks(process.pid),i=t.watch?new lM:void 0,o=ve(t.mode),a=await tk(n),c=a.displayName||`${n} mirror`;Kt(o,me.join(e,"mirror"));let l=me.dirname(cM(import.meta.url)),f=me.join(l,"agents",n),u=me.join(l,"..","cli","agents"),d=me.join(f,"styles.css"),p=me.join(f,"katex.min.css"),h=me.join(f,"index.html"),m=()=>yx({name:c,agent:n,styles:Kp(d,"utf8"),katex:Kp(p,"utf8"),mountHtml:Kp(h,"utf8"),watch:t.watch}),{port:g,note:b}=await pa({explicit:t.port,target:{kind:"mirror",agent:n},cwd:e}),{port:C,url:T,onCleanup:E,handOver:R,pageCount:O}=await Zc({port:g,portNote:b,displayName:c,stopLog:s,waitTarget:"agent",makeServerOptions:q=>({getHtml:m,basePath:e,port:q,reloadEmitter:i,getServerExports:()=>a,trusted:!0,staticAssets:{mount:`${me.posix.dirname(Wp(n))}/`,dir:f}}),makeEntry:(q,ue)=>({pid:process.pid,port:q,url:ue,file:`agent:${n}`,cwd:e,startedAt:Date.now(),trust:!0,agent:n})}),_=me.join(u,n,"client"),x=me.join(u,"core","client"),M=sM(_);t.watch&&M&&console.log(` Watching for changes...
3010
+ `);async function F(){let q=await import("esbuild"),{outputFiles:ue}=await q.build({entryPoints:[me.join(_,"index.ts")],bundle:!0,platform:"browser",format:"esm",outfile:me.join(f,"client.js"),write:!1}),ie=me.join(f,"client.js"),ye=`${ie}.${process.pid}.tmp`;iM(ye,ue[0].contents);for(let xe=1;;xe++)try{oM(ye,ie);break}catch(de){if(xe===10)throw aM(ye,{force:!0}),de;await new Promise(be=>setTimeout(be,50))}for(let xe of["styles.css","index.html","typebulb.png","typebulb-inv.png"])rM(me.join(x,xe),me.join(f,xe))}let ee;if(t.watch&&M&&i){let q=!1;ee=an({target:u,events:"all",onChange:async()=>{if(!q){q=!0;try{await F(),console.log(O()?`Mirror rebuilt. Reloading.
3004
3011
  `:`Mirror rebuilt. No tab open on it \u2014 nobody is reading this.
3005
- `),i.emit("reload")}catch(ie){console.error("Mirror rebuild failed:",ie instanceof Error?ie.message:ie)}finally{U=!1}}}})}await $({mode:t.open,fresh:!1,replacedLive:!1}),E(()=>a.shutdownSwitcher?.()),E(()=>a.shutdownComposer?.()),Q&&E(Q)}et();At();import*as Vk from"path";async function Gk(t,e,n,r){let s=be(n),i=!1,o=async()=>{let{bulb:a,config:l}=await rt(t);i||(Ht(s,t,a.server),i=!0),await ai(a.server,t,r,l.dependencies)};if(console.log(`Running ${Vk.basename(t)}...`),await o(),e){console.log(`Watching for changes...
3006
- `);let a=0,l=Promise.resolve();on({target:t,onChange:()=>{let c=++a;l=l.then(async()=>{if(c===a)try{console.log("Re-running..."),await o()}catch(f){console.error("Error:",f)}})}})}}et();At();import{Console as gL}from"node:console";Ie();async function Zk(t,e,n,r){SL();try{let u=vn(await G(),t)[0];u&&(js(u.pid,Qe(u.pid).offset),console.error(`note: 'call' boots a fresh server.ts instance; the running server (${u.url}) is not contacted \u2014 state shared with it must live on disk.`))}catch{}let s=be(n),{bulb:i,config:o}=await rt(t);i.server||Ii("This bulb has no **server.ts** block; nothing to call."),Ht(s,t,i.server);let a;try{a=await ai(i.server,t,r,o.dependencies)}catch(u){Ii(u instanceof Error?u.message:String(u))}let l=Kl(a,e.fn);if(!l){let u=[...Object.keys(a).filter(p=>typeof a[p]=="function"),...Object.keys(Wl)];Ii(`Function '${e.fn}' not found. Available: ${u.length?u.join(", "):"(none)"}.`)}let c=await yL(e);if(Hl(l)){try{for await(let u of l(...c))await Qk(JSON.stringify(u,ex)+`
3007
- `)}catch(u){Ii(u instanceof Error?u.stack??u.message:String(u))}return Xk(0)}let f;try{f=await l(...c)}catch(u){Ii(u instanceof Error?u.stack??u.message:String(u))}let d=vL(f);d!==void 0&&await Qk(d+`
3008
- `),Xk(0)}function Xk(t){process.exitCode=t,setTimeout(()=>process.exit(t),2e3).unref?.()}async function yL(t){if(t.hasArgsFlag){let e=t.argsJson??"";return e==="-"&&(e=await Kr()),wL(e)}return bL(t.positional)}function bL(t){return t.map(e=>{try{return JSON.parse(e)}catch{return e}})}function wL(t){let e;try{e=JSON.parse(t)}catch(n){throw new Error(`--args must be a JSON array: ${n instanceof Error?n.message:String(n)}`)}if(!Array.isArray(e))throw new Error(`--args must be a JSON array, got ${e===null?"null":typeof e}`);return e}function vL(t){if(t!==void 0)return JSON.stringify(t,ex,2)}function ex(t,e){return typeof e=="bigint"?e.toString():e}function Ii(t){process.stderr.write(t+`
3009
- `),process.exit(1)}function SL(){let t=new gL(process.stderr,process.stderr);console.log=t.log.bind(t),console.info=t.info.bind(t),console.debug=t.debug.bind(t),console.dir=t.dir.bind(t)}function Qk(t){return new Promise((e,n)=>{process.stdout.write(t,r=>r?n(r):e())})}aa();for(let t of[process.stdout,process.stderr])t.on("error",e=>{if(e?.code!=="EPIPE")throw e});function tx(t,e){t||(console.error(`This bulb runs server-side Node code (server.ts), which --trust must authorize:
3010
- ${e}`),process.exit(1))}async function kL(){let t=LS(process.argv.slice(2));if(t.version&&(console.log(`typebulb ${Ce}`),process.exit(0)),t.help&&(MS(),process.exit(0)),$S(),t.subcommand==="logs"){await mk(t.file||void 0,{follow:t.follow,clear:t.clear,run:t.run,lines:t.lines});return}if(t.subcommand==="wait"){await gk(t.file||void 0,{match:t.match,timeoutSec:t.timeoutSec,wake:t.wake});return}if(t.subcommand==="stop"){t.stopScope?await wk(t.stopScope):await bk(t.file||void 0);return}if(t.subcommand==="restart"){await vk(t.file||void 0,t.stopScope);return}if(t.subcommand==="babysit"){await $k(t.mode,t.slowMs);return}if(t.subcommand==="send"){await kk(t.file,t.sendMessage,t.sendWaitMs??0);return}if(t.subcommand==="models"){await lk(t.mode);return}if(t.subcommand==="slug"){ck(t.slugName);return}if(t.subcommand==="status"){await Pk(t.statusQuery,t.mode,t.slowMs);return}if(t.subcommand==="pull"){await Ww(t.file||void 0,{force:t.force,mode:t.mode});return}if(t.subcommand==="push"){await Hw(t.file||void 0,{force:t.force,mode:t.mode});return}if(t.subcommand==="agent"){await(t.agentTarget?Yk(t):ak(Ce));return}if(t.subcommand==="trust"||t.subcommand==="untrust"){await rk(t.file||void 0,t.subcommand==="trust");return}let e;if(!t.file||t.file==="."){let l=await qw(process.cwd());l||(console.error("No .bulb.md file found in current directory"),process.exit(1)),e=l}else e=Pt.resolve(t.file);if(await nx.access(e).then(()=>!0,()=>!1)||(Ur().includes(t.file)&&(console.error(`To open the ${t.file} agent mirror, run: npx typebulb agent:${t.file}`),process.exit(1)),console.error(`File not found: ${e}`+(Pt.isAbsolute(t.file)?"":` (resolved from cwd ${process.cwd()})`)),process.exit(1)),e.endsWith(".bulb.md")||(console.error("File must have .bulb.md extension"),process.exit(1)),t.subcommand==="get"){await Ek(e,t.blockKind);return}if(t.subcommand==="put"){await Ck(e,t.blockPairs);return}let r=t.file&&t.file!=="."?t.file:Pt.relative(process.cwd(),e)||Pt.basename(e),s=`npx typebulb --trust ${r.includes(" ")?`"${r}"`:r}`;if(t.subcommand==="predict"){await nk(e,s);return}let i=!t.noTrust&&En(e);i&&!t.trust&&console.error("trust: granted from memory (run `typebulb untrust` to revoke)"),t.trust=t.noTrust?!1:t.trust||i;let o;try{o=await rt(e)}catch{}let a;if(t.local){o&&!(t.local.name in(o.config.dependencies??{}))&&(console.error(`--replace: '${t.local.name}' is not a dependency in this bulb's config.json; nothing to replace.`),process.exit(1)),o&&t.subcommand!=="call"&&(!o.bulb.code||t.server)&&console.warn("warning: --replace has no effect in server mode (the override is client-only).");try{a=await Wp(t.local)}catch(l){console.error(l instanceof Error?l.message:String(l)),process.exit(1)}console.error(`replace: ${a.name} \u2192 ${Pt.relative(process.cwd(),a.dir)||"."}`)}if(t.subcommand==="check"){await tk(e,a);return}if(t.subcommand==="call"){tx(t.trust,s),await Zk(e,{fn:t.fn,positional:t.callArgs,argsJson:t.argsJson,hasArgsFlag:t.hasArgsFlag},t.mode,a);return}if(o&&o.bulb.server&&(fa(o.bulb)||t.server)){tx(t.trust,s),await Gk(e,t.watch,t.mode,a);return}await Hk(e,t,s,a)}kL().catch(t=>{console.error("Error:",t.message),process.exit(1)});
3012
+ `),i.emit("reload")}catch(ue){console.error("Mirror rebuild failed:",ue instanceof Error?ue.message:ue)}finally{q=!1}}}})}await R({mode:t.open,fresh:!1,replacedLive:!1}),E(()=>a.shutdownSwitcher?.()),E(()=>a.shutdownComposer?.()),ee&&E(ee)}tt();Tt();import*as wx from"path";async function vx(t,e,n,r){let s=ve(n),i=!1,o=async()=>{let{bulb:a,config:c}=await st(t);i||(Kt(s,t,a.server),i=!0),await fi(a.server,t,r,c.dependencies)};if(console.log(`Running ${wx.basename(t)}...`),await o(),e){console.log(`Watching for changes...
3013
+ `);let a=0,c=Promise.resolve();an({target:t,onChange:()=>{let l=++a;c=c.then(async()=>{if(l===a)try{console.log("Re-running..."),await o()}catch(f){console.error("Error:",f)}})}})}}tt();Tt();import{Console as dM}from"node:console";$e();async function xx(t,e,n,r){gM();try{let d=kn(await Q(),t)[0];d&&(Ws(d.pid,Ze(d.pid).offset),console.error(`note: 'call' boots a fresh server.ts instance; the running server (${d.url}) is not contacted \u2014 state shared with it must live on disk.`))}catch{}let s=ve(n),{bulb:i,config:o}=await st(t);i.server||ji("This bulb has no **server.ts** block; nothing to call."),Kt(s,t,i.server);let a;try{a=await fi(i.server,t,r,o.dependencies)}catch(d){ji(d instanceof Error?d.message:String(d))}let c=Xc(a,e.fn);if(!c){let d=[...Object.keys(a).filter(p=>typeof a[p]=="function"),...Object.keys(Gc)];ji(`Function '${e.fn}' not found. Available: ${d.length?d.join(", "):"(none)"}.`)}let l=await fM(e);if(Qc(c)){try{for await(let d of c(...l))await kx(JSON.stringify(d,Ex)+`
3014
+ `)}catch(d){ji(d instanceof Error?d.stack??d.message:String(d))}return Sx(0)}let f;try{f=await c(...l)}catch(d){ji(d instanceof Error?d.stack??d.message:String(d))}let u=mM(f);u!==void 0&&await kx(u+`
3015
+ `),Sx(0)}function Sx(t){process.exitCode=t,setTimeout(()=>process.exit(t),2e3).unref?.()}async function fM(t){if(t.hasArgsFlag){let e=t.argsJson??"";return e==="-"&&(e=await Xr()),hM(e)}return pM(t.positional)}function pM(t){return t.map(e=>{try{return JSON.parse(e)}catch{return e}})}function hM(t){let e;try{e=JSON.parse(t)}catch(n){throw new Error(`--args must be a JSON array: ${n instanceof Error?n.message:String(n)}`)}if(!Array.isArray(e))throw new Error(`--args must be a JSON array, got ${e===null?"null":typeof e}`);return e}function mM(t){if(t!==void 0)return JSON.stringify(t,Ex,2)}function Ex(t,e){return typeof e=="bigint"?e.toString():e}function ji(t){process.stderr.write(t+`
3016
+ `),process.exit(1)}function gM(){let t=new dM(process.stderr,process.stderr);console.log=t.log.bind(t),console.info=t.info.bind(t),console.debug=t.debug.bind(t),console.dir=t.dir.bind(t)}function kx(t){return new Promise((e,n)=>{process.stdout.write(t,r=>r?n(r):e())})}ha();for(let t of[process.stdout,process.stderr])t.on("error",e=>{if(e?.code!=="EPIPE")throw e});function Ax(t,e){t||(console.error(`This bulb runs server-side Node code (server.ts), which --trust must authorize:
3017
+ ${e}`),process.exit(1))}async function yM(){let t=sk(process.argv.slice(2));if(t.version&&(console.log(`typebulb ${Pe}`),process.exit(0)),t.help&&(ik(),process.exit(0)),nk(),t.subcommand==="logs"){await Bk(t.file||void 0,{follow:t.follow,clear:t.clear,run:t.run,lines:t.lines});return}if(t.subcommand==="wait"){await jk(t.file||void 0,{match:t.match,timeoutSec:t.timeoutSec,wake:t.wake});return}if(t.subcommand==="stop"){t.stopScope?await qk(t.stopScope):await Uk(t.file||void 0);return}if(t.subcommand==="restart"){await Jk(t.file||void 0,t.stopScope);return}if(t.subcommand==="babysit"){await rx(t.mode,t.slowMs);return}if(t.subcommand==="send"){await Kk(t.file,t.sendMessage,t.sendWaitMs??0);return}if(t.subcommand==="models"){await Rk(t.mode);return}if(t.subcommand==="slug"){Ik(t.slugName);return}if(t.subcommand==="status"){await Qk(t.statusQuery,t.mode,t.slowMs);return}if(t.subcommand==="pull"){await ev(t.file||void 0,{force:t.force,mode:t.mode});return}if(t.subcommand==="push"){await nv(t.file||void 0,{force:t.force,mode:t.mode});return}if(t.subcommand==="agent"){await(t.agentTarget?bx(t):_k(Pe));return}if(t.subcommand==="trust"||t.subcommand==="untrust"){await Tk(t.file||void 0,t.subcommand==="trust");return}let e;if(!t.file||t.file==="."){let c=await Qw(process.cwd());c||(console.error("No .bulb.md file found in current directory"),process.exit(1)),e=c}else e=Pt.resolve(t.file);if(await Tx.access(e).then(()=>!0,()=>!1)||(zr().includes(t.file)&&(console.error(`To open the ${t.file} agent mirror, run: npx typebulb agent:${t.file}`),process.exit(1)),console.error(`File not found: ${e}`+(Pt.isAbsolute(t.file)?"":` (resolved from cwd ${process.cwd()})`)),process.exit(1)),e.endsWith(".bulb.md")||(console.error("File must have .bulb.md extension"),process.exit(1)),t.subcommand==="get"){await zk(e,t.blockKind);return}if(t.subcommand==="put"){await Gk(e,t.blockPairs);return}let r=t.file&&t.file!=="."?t.file:Pt.relative(process.cwd(),e)||Pt.basename(e),s=`npx typebulb --trust ${r.includes(" ")?`"${r}"`:r}`;if(t.subcommand==="predict"){await Ak(e,s);return}let i=!t.noTrust&&Tn(e);i&&!t.trust&&console.error("trust: granted from memory (run `typebulb untrust` to revoke)"),t.trust=t.noTrust?!1:t.trust||i;let o;try{o=await st(e)}catch{}let a;if(t.local){o&&!(t.local.name in(o.config.dependencies??{}))&&(console.error(`--replace: '${t.local.name}' is not a dependency in this bulb's config.json; nothing to replace.`),process.exit(1)),o&&t.subcommand!=="call"&&(!o.bulb.code||t.server)&&console.warn("warning: --replace has no effect in server mode (the override is client-only).");try{a=await eh(t.local)}catch(c){console.error(c instanceof Error?c.message:String(c)),process.exit(1)}console.error(`replace: ${a.name} \u2192 ${Pt.relative(process.cwd(),a.dir)||"."}`)}if(t.subcommand==="check"){await Ek(e,a);return}if(t.subcommand==="call"){Ax(t.trust,s),await xx(e,{fn:t.fn,positional:t.callArgs,argsJson:t.argsJson,hasArgsFlag:t.hasArgsFlag},t.mode,a);return}if(o&&o.bulb.server&&(wa(o.bulb)||t.server)){Ax(t.trust,s),await vx(e,t.watch,t.mode,a);return}await gx(e,t,s,a)}yM().catch(t=>{console.error("Error:",t.message),process.exit(1)});