typebulb 0.62.1 → 0.62.2

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,144 +1,144 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __cr } from 'module'; const require = __cr(import.meta.url);
3
- var qk=Object.create;var Bl=Object.defineProperty;var Jk=Object.getOwnPropertyDescriptor;var Wk=Object.getOwnPropertyNames;var Kk=Object.getPrototypeOf,Hk=Object.prototype.hasOwnProperty;var Ei=(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 _=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Ai=(t,e)=>{for(var n in e)Bl(t,n,{get:e[n],enumerable:!0})},zk=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Wk(e))!Hk.call(t,s)&&s!==n&&Bl(t,s,{get:()=>e[s],enumerable:!(r=Jk(e,s))||r.enumerable});return t};var Yk=(t,e,n)=>(n=t!=null?qk(Kk(t)):{},zk(e||!t||!t.__esModule?Bl(n,"default",{value:t,enumerable:!0}):n,t));import*as Ap from"fs/promises";import{existsSync as Fn,readFileSync as Vk}from"fs";import*as ae from"path";import{pathToFileURL as Gk}from"url";import{resolve as Fl}from"resolve.exports";import{init as Tp,parse as Cp}from"es-module-lexer";function Op(t,e){let n=ae.join(t,"package.json");try{return JSON.parse(Vk(n,"utf8"))}catch{throw new Error(`--replace package '${e}' has no readable package.json at ${n}`)}}function Pp(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:ae.resolve(r)}}async function _p(t){let{name:e,dir:n}=t;if(!Fn(n))throw new Error(`--replace path for '${e}' does not exist: ${n}`);let r=Op(n,e),s=Xk(r,e),i=ae.resolve(n,s);if(!Fn(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=ae.dirname(i),a=`/local/${e}/${ae.basename(i)}`,l=Qk(r,n);return await Zk(e,i,o),{name:e,dir:n,entryAbs:i,serveDir:o,entryUrl:a,typesAbs:l}}function Xk(t,e){if(t.exports!==void 0){let r;try{r=Fl(t,".",{browser:!0,conditions:jl})}catch(i){throw new Error(`--replace package '${e}' "exports" does not resolve a browser entry (conditions: ${jl.join(", ")}): ${i instanceof Error?i.message:i}`)}let s=Ul(r);if(!s)throw new Error(`--replace package '${e}' "exports" did not resolve "." to a single file (conditions: ${jl.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 Qk(t,e){if(t.exports!==void 0)try{let r=Fl(t,".",{conditions:["types"]}),s=Ul(r);if(s){let i=ae.resolve(e,s);if(Fn(i))return i}}catch{}let n=t.types??t.typings;if(n){let r=ae.resolve(e,n);if(Fn(r))return r}}function Ul(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.find(e=>typeof e=="string")}async function Zk(t,e,n){await Tp;let r=ae.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 Ap.readFile(o,"utf8")}catch{continue}let l,c;try{[l,,,c]=Cp(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 u of l){if(u.d===-2)continue;let d=u.n;if(d&&!d.startsWith("node:")){if(d.startsWith("./")||d.startsWith("../")||d.startsWith("/")){let f=ex(o,d,r);f&&!s.has(f)&&i.push(f);continue}throw new Error(`override package must ship self-contained (bundle its dependencies); ${t} externalizes '${d}'`)}}}}function ex(t,e,n){let r=e.replace(/[?#].*$/,""),s=ae.resolve(ae.dirname(t),r),i=[s,s+".js",s+".mjs",ae.join(s,"index.js"),ae.join(s,"index.mjs")];for(let o of i)if(ae.normalize(o).startsWith(n)&&Fn(o))return o}function tx(t,e,n){let r=Op(t,e),s;if(r.exports!==void 0)try{s=Ul(Fl(r,n,{conditions:Ep}))}catch(o){throw new Error(`--replace package '${e}' "exports" does not resolve a node entry for '${n}' (conditions: ${Ep.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=ae.resolve(t,s);if(!Fn(i))throw new Error(`--replace package '${e}' built file not found: ${i} \u2014 did you build it (e.g. \`pnpm run build\`)?`);return Gk(i).href}async function Rp(t,e){await Tp;let n;try{[n]=Cp(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 jl,Ep,Ti=S(()=>{"use strict";jl=["browser","import","default"],Ep=["node","import","default"]});function Ip(t){return He.find(e=>de[e].path===t)}function Np(t){return!!t?.startsWith("typebulb")}var de,He,$p,Ci=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"}},He=["code","css","html","data","infer","insight","config","notes"];$p="typebulb/v1"});function ql(t){return/[:\n"']/.test(t)||t.startsWith(" ")||t.endsWith(" ")?`"${t.replace(/"/g,'\\"')}"`:t}function Jl(t){return t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1).replace(/\\"/g,'"'):t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}var Oi=S(()=>{});function Un(t){let e=Mp(t);if("reason"in e)throw new Error(`Invalid .bulb.md file format: ${e.reason}`);return e.bulb}function ze(t){let e=Mp(t);return"bulb"in e?e.bulb:void 0}function Mp(t){try{let e=t.split(`
4
- `),n=0;if(e[n]?.trim()!=="---")return{reason:rx(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=ox(r);if(!Np(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(Lp);if(d){let f=d[1].trim();for(n++;n<e.length&&e[n]?.trim()==="";)n++;let p=e[n]?.match(Pi);if(!p){l.push(`**${f}** has no code fence \u2014 block skipped`);continue}let h=p[1];n++;let m=n+1,g=[],v=Wl(h);for(;n<e.length&&!e[n]?.match(v);)g.push(e[n]),n++;let A=n<e.length;n++,l.push(...sx(f,g,A)),o.set(f,g.join(`
5
- `)),a.set(f,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 rx(t,e){let n=ax(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 sx(t,e,n){let r=[];for(let s=0;s<e.length;s++){let i=e[s]?.trim().match(Lp);i&&nx.has(i[1].trim())&&ix(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 ix(t,e){let n=e+1;for(;n<t.length&&t[n]?.trim()==="";)n++;return!!t[n]?.match(Pi)}function ox(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=Jl(i);break}}return e}function Dp(t){return ze(t)?.warnings??[]}function ax(t){let e=t.split(`
3
+ var Vk=Object.create;var Bl=Object.defineProperty;var Gk=Object.getOwnPropertyDescriptor;var Xk=Object.getOwnPropertyNames;var Qk=Object.getPrototypeOf,Zk=Object.prototype.hasOwnProperty;var Ei=(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 v=(t,e)=>()=>(t&&(e=t(t=0)),e);var $=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Ai=(t,e)=>{for(var n in e)Bl(t,n,{get:e[n],enumerable:!0})},ex=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Xk(e))!Zk.call(t,s)&&s!==n&&Bl(t,s,{get:()=>e[s],enumerable:!(r=Gk(e,s))||r.enumerable});return t};var tx=(t,e,n)=>(n=t!=null?Vk(Qk(t)):{},ex(e||!t||!t.__esModule?Bl(n,"default",{value:t,enumerable:!0}):n,t));import*as Cp from"fs/promises";import{existsSync as jn,readFileSync as nx}from"fs";import*as ae from"path";import{pathToFileURL as rx}from"url";import{resolve as Fl}from"resolve.exports";import{init as Op,parse as Pp}from"es-module-lexer";function _p(t,e){let n=ae.join(t,"package.json");try{return JSON.parse(nx(n,"utf8"))}catch{throw new Error(`--replace package '${e}' has no readable package.json at ${n}`)}}function Rp(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:ae.resolve(r)}}async function Ip(t){let{name:e,dir:n}=t;if(!jn(n))throw new Error(`--replace path for '${e}' does not exist: ${n}`);let r=_p(n,e),s=sx(r,e),i=ae.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=ae.dirname(i),a=`/local/${e}/${ae.basename(i)}`,l=ix(r,n);return await ox(e,i,o),{name:e,dir:n,entryAbs:i,serveDir:o,entryUrl:a,typesAbs:l}}function sx(t,e){if(t.exports!==void 0){let r;try{r=Fl(t,".",{browser:!0,conditions:jl})}catch(i){throw new Error(`--replace package '${e}' "exports" does not resolve a browser entry (conditions: ${jl.join(", ")}): ${i instanceof Error?i.message:i}`)}let s=Ul(r);if(!s)throw new Error(`--replace package '${e}' "exports" did not resolve "." to a single file (conditions: ${jl.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 ix(t,e){if(t.exports!==void 0)try{let r=Fl(t,".",{conditions:["types"]}),s=Ul(r);if(s){let i=ae.resolve(e,s);if(jn(i))return i}}catch{}let n=t.types??t.typings;if(n){let r=ae.resolve(e,n);if(jn(r))return r}}function Ul(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.find(e=>typeof e=="string")}async function ox(t,e,n){await Op;let r=ae.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 Cp.readFile(o,"utf8")}catch{continue}let l,c;try{[l,,,c]=Pp(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 u of l){if(u.d===-2)continue;let d=u.n;if(d&&!d.startsWith("node:")){if(d.startsWith("./")||d.startsWith("../")||d.startsWith("/")){let f=ax(o,d,r);f&&!s.has(f)&&i.push(f);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=ae.resolve(ae.dirname(t),r),i=[s,s+".js",s+".mjs",ae.join(s,"index.js"),ae.join(s,"index.mjs")];for(let o of i)if(ae.normalize(o).startsWith(n)&&jn(o))return o}function lx(t,e,n){let r=_p(t,e),s;if(r.exports!==void 0)try{s=Ul(Fl(r,n,{conditions:Tp}))}catch(o){throw new Error(`--replace package '${e}' "exports" does not resolve a node entry for '${n}' (conditions: ${Tp.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=ae.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 rx(i).href}async function $p(t,e){await Op;let n;try{[n]=Pp(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=lx(e.dir,e.name,a);r+=t.slice(s,i.s)+l,s=i.e}return r+t.slice(s)}var jl,Tp,Ti=v(()=>{"use strict";jl=["browser","import","default"],Tp=["node","import","default"]});function Np(t){return He.find(e=>de[e].path===t)}function Mp(t){return!!t?.startsWith("typebulb")}var de,He,Lp,Ci=v(()=>{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"}},He=["code","css","html","data","infer","insight","config","notes"];Lp="typebulb/v1"});function ql(t){return/[:\n"']/.test(t)||t.startsWith(" ")||t.endsWith(" ")?`"${t.replace(/"/g,'\\"')}"`:t}function Jl(t){return t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1).replace(/\\"/g,'"'):t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}var Oi=v(()=>{});function Fn(t){let e=Bp(t);if("reason"in e)throw new Error(`Invalid .bulb.md file format: ${e.reason}`);return e.bulb}function ze(t){let e=Bp(t);return"bulb"in e?e.bulb:void 0}function Bp(t){try{let e=t.split(`
4
+ `),n=0;if(e[n]?.trim()!=="---")return{reason:ux(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=px(r);if(!Mp(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(Dp);if(d){let f=d[1].trim();for(n++;n<e.length&&e[n]?.trim()==="";)n++;let p=e[n]?.match(Pi);if(!p){l.push(`**${f}** has no code fence \u2014 block skipped`);continue}let m=p[1];n++;let h=n+1,y=[],k=Wl(m);for(;n<e.length&&!e[n]?.match(k);)y.push(e[n]),n++;let T=n<e.length;n++,l.push(...dx(f,y,T)),o.set(f,y.join(`
5
+ `)),a.set(f,h),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 ux(t,e){let n=hx(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 dx(t,e,n){let r=[];for(let s=0;s<e.length;s++){let i=e[s]?.trim().match(Dp);i&&cx.has(i[1].trim())&&fx(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 fx(t,e){let n=e+1;for(;n<t.length&&t[n]?.trim()==="";)n++;return!!t[n]?.match(Pi)}function px(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=Jl(i);break}}return e}function jp(t){return ze(t)?.warnings??[]}function hx(t){let e=t.split(`
6
6
  `),n=[],r=0;for(;r<e.length;){if(e[r]?.trim()!=="---"){r++;continue}let s=ze(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 Bp(t){let e=Object.fromEntries(He.map(n=>[n,t.files.get(de[n].path)||""]));return{name:t.frontmatter.name,...e}}var Lp,Pi,nx,Wl,Kl=S(()=>{Ci();Oi();Lp=/^\*\*(.+)\*\*$/,Pi=/^(`{3,})(\w*)\s*$/,nx=new Set(He.map(t=>de[t].path)),Wl=t=>new RegExp(`^${t}\\s*$`)});function jp(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 Fp(t,e){let{path:n}=de[t],r=n.split(".").pop(),s=jp(e);return`**${n}**
8
+ `)}),r=i}else r++}return n}function Fp(t){let e=Object.fromEntries(He.map(n=>[n,t.files.get(de[n].path)||""]));return{name:t.frontmatter.name,...e}}var Dp,Pi,cx,Wl,Kl=v(()=>{Ci();Oi();Dp=/^\*\*(.+)\*\*$/,Pi=/^(`{3,})(\w*)\s*$/,cx=new Set(He.map(t=>de[t].path)),Wl=t=>new RegExp(`^${t}\\s*$`)});function Up(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 qp(t,e){let{path:n}=de[t],r=n.split(".").pop(),s=Up(e);return`**${n}**
9
9
 
10
10
  ${s}${r}
11
11
  ${e}
12
- ${s}`}function Up(t){let e=He.filter(n=>t[n]).map(n=>Fp(n,t[n]));return["---",`format: ${$p}`,`name: ${ql(t.name)}`,"---","",...e].join(`
13
- `)}function qp(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(Pi);if(!s)continue;let i=Wl(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 Wr(t,e,n){let r=t.split(`
14
- `),s=qp(r,de[e].path);if(s==="unterminated")return t;if(!s)return`${t.replace(/\s*$/,"")}
12
+ ${s}`}function Jp(t){let e=He.filter(n=>t[n]).map(n=>qp(n,t[n]));return["---",`format: ${Lp}`,`name: ${ql(t.name)}`,"---","",...e].join(`
13
+ `)}function Wp(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(Pi);if(!s)continue;let i=Wl(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 Wr(t,e,n){let r=t.split(`
14
+ `),s=Wp(r,de[e].path);if(s==="unterminated")return t;if(!s)return`${t.replace(/\s*$/,"")}
15
15
 
16
- ${Fp(e,n)}
17
- `;let i=jp(n),o=i.length>s.fence.length?i:s.fence;return[...r.slice(0,s.open),o+s.lang,...n.split(`
16
+ ${qp(e,n)}
17
+ `;let i=Up(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 Jp(t,e){let n=t.split(`
20
- `),r=qp(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 Kp(t,e){let n=t.split(`
20
+ `),r=Wp(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(`
21
21
  `).replace(/\s*$/,"")+`
22
- `}var Wp=S(()=>{Ci();Kl();Oi()});function Kr(t){if(!t.trim())return{};try{return JSON.parse(t)}catch{return{}}}function Hp(t){switch(Kp(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 zp(t){let e=Kp(t);return e!==void 0&&cx.has(e)?e:void 0}function dx(t){return t.replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\*\*([^*]+)\*\*/g,"$1").replace(/\*([^*]+)\*/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/^#{1,6}\s+/gm,"")}function Hl(t){let e=Kr(t??"").description?.trim();if(!e)return ux;let n=dx(e);return(n.length>200?n.slice(0,197)+"...":n).replace(/\n/g," ")}var lx,_i,Kp,cx,ux,Yp=S(()=>{lx="https://assets.typebulb.com",_i=(t,e)=>`${lx}/u/${encodeURIComponent(t)}/${encodeURIComponent(e)}/`,Kp=t=>/\.[^./\\]+$/.exec(t)?.[0]?.toLowerCase();cx=new Set([".html",".htm",".xhtml",".js",".mjs",".cjs",".ts",".tsx",".css"]);ux="A Typebulb bulb."});var Vp=S(()=>{});function zl(t,e,n){let s=new RegExp(e).exec(t.slice(n));return s?n+s.index:-1}var Gp=S(()=>{});function Hr(t,e,n){let s=new RegExp(e).exec(t.slice(n));return s?n+s.index+s[0].length-1:-1}var Xp=S(()=>{});function Ri(t,e){let n=new RegExp(e,"g"),r=t.match(n);return r?r.length:0}var Qp=S(()=>{});function zr(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=zl(t,`<${e}[
23
- >/]`,i);if(r&&console.log("[xml-utils] start:",o),o===-1)return;let a=t.slice(o+e.length),l=Hr(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=Hr(a,"[ /]"+e+">",p))!==-1;){let g=a.substring(p,l+1);if(h+=Ri(g,"<"+e+`[
24
- >]`),m+=Ri(g,"</"+e+">"),m>=h)break;p=l}}else l=Hr(a,"[ /]"+e+">",0);let u=o+e.length+l+1;if(r&&console.log("[xml-utils] end:",u),u===-1)return;let d=t.slice(o,u),f;return c?f=null:f=d.slice(d.indexOf(">")+1,d.lastIndexOf("<")),{inner:f,outer:d,start:o,end:u}}var Yl=S(()=>{Gp();Xp();Qp()});var Vl=S(()=>{Yl()});var Gl=S(()=>{Vl()});var Zp=S(()=>{Gl()});var eh=S(()=>{});var th=S(()=>{Vp();Yl();Vl();Zp();Gl();eh()});var J=_(he=>{"use strict";var Xl=Symbol.for("yaml.alias"),nh=Symbol.for("yaml.document"),Ii=Symbol.for("yaml.map"),rh=Symbol.for("yaml.pair"),Ql=Symbol.for("yaml.scalar"),$i=Symbol.for("yaml.seq"),ft=Symbol.for("yaml.node.type"),hx=t=>!!t&&typeof t=="object"&&t[ft]===Xl,mx=t=>!!t&&typeof t=="object"&&t[ft]===nh,gx=t=>!!t&&typeof t=="object"&&t[ft]===Ii,yx=t=>!!t&&typeof t=="object"&&t[ft]===rh,sh=t=>!!t&&typeof t=="object"&&t[ft]===Ql,bx=t=>!!t&&typeof t=="object"&&t[ft]===$i;function ih(t){if(t&&typeof t=="object")switch(t[ft]){case Ii:case $i:return!0}return!1}function wx(t){if(t&&typeof t=="object")switch(t[ft]){case Xl:case Ii:case Ql:case $i:return!0}return!1}var vx=t=>(sh(t)||ih(t))&&!!t.anchor;he.ALIAS=Xl;he.DOC=nh;he.MAP=Ii;he.NODE_TYPE=ft;he.PAIR=rh;he.SCALAR=Ql;he.SEQ=$i;he.hasAnchor=vx;he.isAlias=hx;he.isCollection=ih;he.isDocument=mx;he.isMap=gx;he.isNode=wx;he.isPair=yx;he.isScalar=sh;he.isSeq=bx});var Yr=_(Zl=>{"use strict";var le=J(),ke=Symbol("break visit"),oh=Symbol("skip children"),st=Symbol("remove node");function Ni(t,e){let n=ah(e);le.isDocument(t)?qn(null,t.contents,n,Object.freeze([t]))===st&&(t.contents=null):qn(null,t,n,Object.freeze([]))}Ni.BREAK=ke;Ni.SKIP=oh;Ni.REMOVE=st;function qn(t,e,n,r){let s=lh(t,e,n,r);if(le.isNode(s)||le.isPair(s))return ch(t,r,s),qn(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=qn(i,e.items[i],n,r);if(typeof o=="number")i=o-1;else{if(o===ke)return ke;o===st&&(e.items.splice(i,1),i-=1)}}}else if(le.isPair(e)){r=Object.freeze(r.concat(e));let i=qn("key",e.key,n,r);if(i===ke)return ke;i===st&&(e.key=null);let o=qn("value",e.value,n,r);if(o===ke)return ke;o===st&&(e.value=null)}}return s}async function Li(t,e){let n=ah(e);le.isDocument(t)?await Jn(null,t.contents,n,Object.freeze([t]))===st&&(t.contents=null):await Jn(null,t,n,Object.freeze([]))}Li.BREAK=ke;Li.SKIP=oh;Li.REMOVE=st;async function Jn(t,e,n,r){let s=await lh(t,e,n,r);if(le.isNode(s)||le.isPair(s))return ch(t,r,s),Jn(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 Jn(i,e.items[i],n,r);if(typeof o=="number")i=o-1;else{if(o===ke)return ke;o===st&&(e.items.splice(i,1),i-=1)}}}else if(le.isPair(e)){r=Object.freeze(r.concat(e));let i=await Jn("key",e.key,n,r);if(i===ke)return ke;i===st&&(e.key=null);let o=await Jn("value",e.value,n,r);if(o===ke)return ke;o===st&&(e.value=null)}}return s}function ah(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 lh(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 ch(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`)}}Zl.visit=Ni;Zl.visitAsync=Li});var ec=_(dh=>{"use strict";var uh=J(),Sx=Yr(),kx={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},xx=t=>t.replace(/[!,[\]{}]/g,e=>kx[e]),Vr=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+xx(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&&uh.isNode(e.contents)){let i={};Sx.visit(e.contents,(o,a)=>{uh.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
- `)}};Vr.defaultYaml={explicit:!1,version:"1.2"};Vr.defaultTags={"!!":"tag:yaml.org,2002:"};dh.Directives=Vr});var Mi=_(Gr=>{"use strict";var fh=J(),Ex=Yr();function Ax(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 ph(t){let e=new Set;return Ex.visit(t,{Value(n,r){r.anchor&&e.add(r.anchor)}}),e}function hh(t,e){for(let n=1;;++n){let r=`${t}${n}`;if(!e.has(r))return r}}function Tx(t,e){let n=[],r=new Map,s=null;return{onAnchor:i=>{n.push(i),s??(s=ph(t));let o=hh(e,s);return s.add(o),o},setAnchors:()=>{for(let i of n){let o=r.get(i);if(typeof o=="object"&&o.anchor&&(fh.isScalar(o.node)||fh.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}}Gr.anchorIsValid=Ax;Gr.anchorNames=ph;Gr.createNodeAnchors=Tx;Gr.findNewAnchor=hh});var tc=_(mh=>{"use strict";function Xr(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=Xr(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=Xr(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=Xr(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=Xr(t,r,s,i);o===void 0?delete r[s]:o!==i&&(r[s]=o)}return t.call(e,n,r)}mh.applyReviver=Xr});var _t=_(yh=>{"use strict";var Cx=J();function gh(t,e,n){if(Array.isArray(t))return t.map((r,s)=>gh(r,String(s),n));if(t&&typeof t.toJSON=="function"){if(!n||!Cx.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}yh.toJS=gh});var Di=_(wh=>{"use strict";var Ox=tc(),bh=J(),Px=_t(),nc=class{constructor(e){Object.defineProperty(this,bh.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(!bh.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=Px.toJS(this,"",o);if(typeof s=="function")for(let{count:l,res:c}of o.anchors.values())s(c,l);return typeof i=="function"?Ox.applyReviver(i,{"":a},"",a):a}};wh.NodeBase=nc});var Qr=_(vh=>{"use strict";var _x=Mi(),Rx=Yr(),Wn=J(),Ix=Di(),$x=_t(),rc=class extends Ix.NodeBase{constructor(e){super(Wn.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=[],Rx.visit(e,{Node:(i,o)=>{(Wn.isAlias(o)||Wn.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||($x.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=Bi(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(_x.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 Bi(t,e,n){if(Wn.isAlias(e)){let r=e.resolve(t),s=n&&r&&n.get(r);return s?s.count*s.aliasCount:0}else if(Wn.isCollection(e)){let r=0;for(let s of e.items){let i=Bi(t,s,n);i>r&&(r=i)}return r}else if(Wn.isPair(e)){let r=Bi(t,e.key,n),s=Bi(t,e.value,n);return Math.max(r,s)}return 1}vh.Alias=rc});var se=_(sc=>{"use strict";var Nx=J(),Lx=Di(),Mx=_t(),Dx=t=>!t||typeof t!="function"&&typeof t!="object",Rt=class extends Lx.NodeBase{constructor(e){super(Nx.SCALAR),this.value=e}toJSON(e,n){return n?.keep?this.value:Mx.toJS(this.value,e,n)}toString(){return String(this.value)}};Rt.BLOCK_FOLDED="BLOCK_FOLDED";Rt.BLOCK_LITERAL="BLOCK_LITERAL";Rt.PLAIN="PLAIN";Rt.QUOTE_DOUBLE="QUOTE_DOUBLE";Rt.QUOTE_SINGLE="QUOTE_SINGLE";sc.Scalar=Rt;sc.isScalarValue=Dx});var Zr=_(kh=>{"use strict";var Bx=Qr(),on=J(),Sh=se(),jx="tag:yaml.org,2002:";function Fx(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 Ux(t,e,n){if(on.isDocument(t)&&(t=t.contents),on.isNode(t))return t;if(on.isPair(t)){let d=n.schema[on.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 Bx.Alias(l.anchor);l={anchor:null,node:null},a.set(t,l)}e?.startsWith("!!")&&(e=jx+e.slice(2));let c=Fx(t,e,o.tags);if(!c){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let d=new Sh.Scalar(t);return l&&(l.node=d),d}c=t instanceof Map?o[on.MAP]:Symbol.iterator in Object(t)?o[on.SEQ]:o[on.MAP]}i&&(i(c),delete n.onTagObj);let u=c?.createNode?c.createNode(n.schema,t,n):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(n.schema,t,n):new Sh.Scalar(t);return e?u.tag=e:c.default||(u.tag=c.tag),l&&(l.node=u),u}kh.createNode=Ux});var Fi=_(ji=>{"use strict";var qx=Zr(),it=J(),Jx=Di();function ic(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 qx.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 xh=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,oc=class extends Jx.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=>it.isNode(r)||it.isPair(r)?r.clone(e):r),this.range&&(n.range=this.range.slice()),n}addIn(e,n){if(xh(e))this.add(n);else{let[r,...s]=e,i=this.get(r,!0);if(it.isCollection(i))i.addIn(s,n);else if(i===void 0&&this.schema)this.set(r,ic(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(it.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&&it.isScalar(i)?i.value:i:it.isCollection(i)?i.getIn(s,n):void 0}hasAllNullValues(e){return this.items.every(n=>{if(!it.isPair(n))return!1;let r=n.value;return r==null||e&&it.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 it.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(it.isCollection(i))i.setIn(s,n);else if(i===void 0&&this.schema)this.set(r,ic(this.schema,s,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${s}`)}}};ji.Collection=oc;ji.collectionFromPath=ic;ji.isEmptyPath=xh});var es=_(Ui=>{"use strict";var Wx=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function ac(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var Kx=(t,e,n)=>t.endsWith(`
22
+ `}var Hp=v(()=>{Ci();Kl();Oi()});function Kr(t){if(!t.trim())return{};try{return JSON.parse(t)}catch{return{}}}function Yp(t){switch(zp(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 Vp(t){let e=zp(t);return e!==void 0&&gx.has(e)?e:void 0}function bx(t){return t.replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\*\*([^*]+)\*\*/g,"$1").replace(/\*([^*]+)\*/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/^#{1,6}\s+/gm,"")}function Hl(t){let e=Kr(t??"").description?.trim();if(!e)return yx;let n=bx(e);return(n.length>200?n.slice(0,197)+"...":n).replace(/\n/g," ")}var mx,_i,zp,gx,yx,Gp=v(()=>{mx="https://assets.typebulb.com",_i=(t,e)=>`${mx}/u/${encodeURIComponent(t)}/${encodeURIComponent(e)}/`,zp=t=>/\.[^./\\]+$/.exec(t)?.[0]?.toLowerCase();gx=new Set([".html",".htm",".xhtml",".js",".mjs",".cjs",".ts",".tsx",".css"]);yx="A Typebulb bulb."});var Xp=v(()=>{});function zl(t,e,n){let s=new RegExp(e).exec(t.slice(n));return s?n+s.index:-1}var Qp=v(()=>{});function Hr(t,e,n){let s=new RegExp(e).exec(t.slice(n));return s?n+s.index+s[0].length-1:-1}var Zp=v(()=>{});function Ri(t,e){let n=new RegExp(e,"g"),r=t.match(n);return r?r.length:0}var eh=v(()=>{});function zr(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=zl(t,`<${e}[
23
+ >/]`,i);if(r&&console.log("[xml-utils] start:",o),o===-1)return;let a=t.slice(o+e.length),l=Hr(a,"^[^<]*[ /]>",0),c=l!==-1&&a[l-1]==="/";if(r&&console.log("[xml-utils] selfClosing:",c),c===!1)if(s){let p=0,m=1,h=0;for(;(l=Hr(a,"[ /]"+e+">",p))!==-1;){let y=a.substring(p,l+1);if(m+=Ri(y,"<"+e+`[
24
+ >]`),h+=Ri(y,"</"+e+">"),h>=m)break;p=l}}else l=Hr(a,"[ /]"+e+">",0);let u=o+e.length+l+1;if(r&&console.log("[xml-utils] end:",u),u===-1)return;let d=t.slice(o,u),f;return c?f=null:f=d.slice(d.indexOf(">")+1,d.lastIndexOf("<")),{inner:f,outer:d,start:o,end:u}}var Yl=v(()=>{Qp();Zp();eh()});var Vl=v(()=>{Yl()});var Gl=v(()=>{Vl()});var th=v(()=>{Gl()});var nh=v(()=>{});var rh=v(()=>{Xp();Yl();Vl();th();Gl();nh()});var J=$(he=>{"use strict";var Xl=Symbol.for("yaml.alias"),sh=Symbol.for("yaml.document"),Ii=Symbol.for("yaml.map"),ih=Symbol.for("yaml.pair"),Ql=Symbol.for("yaml.scalar"),$i=Symbol.for("yaml.seq"),ft=Symbol.for("yaml.node.type"),Sx=t=>!!t&&typeof t=="object"&&t[ft]===Xl,kx=t=>!!t&&typeof t=="object"&&t[ft]===sh,xx=t=>!!t&&typeof t=="object"&&t[ft]===Ii,Ex=t=>!!t&&typeof t=="object"&&t[ft]===ih,oh=t=>!!t&&typeof t=="object"&&t[ft]===Ql,Ax=t=>!!t&&typeof t=="object"&&t[ft]===$i;function ah(t){if(t&&typeof t=="object")switch(t[ft]){case Ii:case $i:return!0}return!1}function Tx(t){if(t&&typeof t=="object")switch(t[ft]){case Xl:case Ii:case Ql:case $i:return!0}return!1}var Cx=t=>(oh(t)||ah(t))&&!!t.anchor;he.ALIAS=Xl;he.DOC=sh;he.MAP=Ii;he.NODE_TYPE=ft;he.PAIR=ih;he.SCALAR=Ql;he.SEQ=$i;he.hasAnchor=Cx;he.isAlias=Sx;he.isCollection=ah;he.isDocument=kx;he.isMap=xx;he.isNode=Tx;he.isPair=Ex;he.isScalar=oh;he.isSeq=Ax});var Yr=$(Zl=>{"use strict";var le=J(),ke=Symbol("break visit"),lh=Symbol("skip children"),st=Symbol("remove node");function Ni(t,e){let n=ch(e);le.isDocument(t)?Un(null,t.contents,n,Object.freeze([t]))===st&&(t.contents=null):Un(null,t,n,Object.freeze([]))}Ni.BREAK=ke;Ni.SKIP=lh;Ni.REMOVE=st;function Un(t,e,n,r){let s=uh(t,e,n,r);if(le.isNode(s)||le.isPair(s))return dh(t,r,s),Un(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=Un(i,e.items[i],n,r);if(typeof o=="number")i=o-1;else{if(o===ke)return ke;o===st&&(e.items.splice(i,1),i-=1)}}}else if(le.isPair(e)){r=Object.freeze(r.concat(e));let i=Un("key",e.key,n,r);if(i===ke)return ke;i===st&&(e.key=null);let o=Un("value",e.value,n,r);if(o===ke)return ke;o===st&&(e.value=null)}}return s}async function Li(t,e){let n=ch(e);le.isDocument(t)?await qn(null,t.contents,n,Object.freeze([t]))===st&&(t.contents=null):await qn(null,t,n,Object.freeze([]))}Li.BREAK=ke;Li.SKIP=lh;Li.REMOVE=st;async function qn(t,e,n,r){let s=await uh(t,e,n,r);if(le.isNode(s)||le.isPair(s))return dh(t,r,s),qn(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 qn(i,e.items[i],n,r);if(typeof o=="number")i=o-1;else{if(o===ke)return ke;o===st&&(e.items.splice(i,1),i-=1)}}}else if(le.isPair(e)){r=Object.freeze(r.concat(e));let i=await qn("key",e.key,n,r);if(i===ke)return ke;i===st&&(e.key=null);let o=await qn("value",e.value,n,r);if(o===ke)return ke;o===st&&(e.value=null)}}return s}function ch(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 uh(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 dh(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`)}}Zl.visit=Ni;Zl.visitAsync=Li});var ec=$(ph=>{"use strict";var fh=J(),Ox=Yr(),Px={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},_x=t=>t.replace(/[!,[\]{}]/g,e=>Px[e]),Vr=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+_x(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&&fh.isNode(e.contents)){let i={};Ox.visit(e.contents,(o,a)=>{fh.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
+ `)}};Vr.defaultYaml={explicit:!1,version:"1.2"};Vr.defaultTags={"!!":"tag:yaml.org,2002:"};ph.Directives=Vr});var Mi=$(Gr=>{"use strict";var hh=J(),Rx=Yr();function Ix(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 mh(t){let e=new Set;return Rx.visit(t,{Value(n,r){r.anchor&&e.add(r.anchor)}}),e}function gh(t,e){for(let n=1;;++n){let r=`${t}${n}`;if(!e.has(r))return r}}function $x(t,e){let n=[],r=new Map,s=null;return{onAnchor:i=>{n.push(i),s??(s=mh(t));let o=gh(e,s);return s.add(o),o},setAnchors:()=>{for(let i of n){let o=r.get(i);if(typeof o=="object"&&o.anchor&&(hh.isScalar(o.node)||hh.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}}Gr.anchorIsValid=Ix;Gr.anchorNames=mh;Gr.createNodeAnchors=$x;Gr.findNewAnchor=gh});var tc=$(yh=>{"use strict";function Xr(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=Xr(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=Xr(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=Xr(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=Xr(t,r,s,i);o===void 0?delete r[s]:o!==i&&(r[s]=o)}return t.call(e,n,r)}yh.applyReviver=Xr});var _t=$(wh=>{"use strict";var Nx=J();function bh(t,e,n){if(Array.isArray(t))return t.map((r,s)=>bh(r,String(s),n));if(t&&typeof t.toJSON=="function"){if(!n||!Nx.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}wh.toJS=bh});var Di=$(Sh=>{"use strict";var Lx=tc(),vh=J(),Mx=_t(),nc=class{constructor(e){Object.defineProperty(this,vh.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(!vh.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=Mx.toJS(this,"",o);if(typeof s=="function")for(let{count:l,res:c}of o.anchors.values())s(c,l);return typeof i=="function"?Lx.applyReviver(i,{"":a},"",a):a}};Sh.NodeBase=nc});var Qr=$(kh=>{"use strict";var Dx=Mi(),Bx=Yr(),Jn=J(),jx=Di(),Fx=_t(),rc=class extends jx.NodeBase{constructor(e){super(Jn.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=[],Bx.visit(e,{Node:(i,o)=>{(Jn.isAlias(o)||Jn.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||(Fx.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=Bi(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(Dx.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 Bi(t,e,n){if(Jn.isAlias(e)){let r=e.resolve(t),s=n&&r&&n.get(r);return s?s.count*s.aliasCount:0}else if(Jn.isCollection(e)){let r=0;for(let s of e.items){let i=Bi(t,s,n);i>r&&(r=i)}return r}else if(Jn.isPair(e)){let r=Bi(t,e.key,n),s=Bi(t,e.value,n);return Math.max(r,s)}return 1}kh.Alias=rc});var se=$(sc=>{"use strict";var Ux=J(),qx=Di(),Jx=_t(),Wx=t=>!t||typeof t!="function"&&typeof t!="object",Rt=class extends qx.NodeBase{constructor(e){super(Ux.SCALAR),this.value=e}toJSON(e,n){return n?.keep?this.value:Jx.toJS(this.value,e,n)}toString(){return String(this.value)}};Rt.BLOCK_FOLDED="BLOCK_FOLDED";Rt.BLOCK_LITERAL="BLOCK_LITERAL";Rt.PLAIN="PLAIN";Rt.QUOTE_DOUBLE="QUOTE_DOUBLE";Rt.QUOTE_SINGLE="QUOTE_SINGLE";sc.Scalar=Rt;sc.isScalarValue=Wx});var Zr=$(Eh=>{"use strict";var Kx=Qr(),on=J(),xh=se(),Hx="tag:yaml.org,2002:";function zx(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 Yx(t,e,n){if(on.isDocument(t)&&(t=t.contents),on.isNode(t))return t;if(on.isPair(t)){let d=n.schema[on.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 Kx.Alias(l.anchor);l={anchor:null,node:null},a.set(t,l)}e?.startsWith("!!")&&(e=Hx+e.slice(2));let c=zx(t,e,o.tags);if(!c){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let d=new xh.Scalar(t);return l&&(l.node=d),d}c=t instanceof Map?o[on.MAP]:Symbol.iterator in Object(t)?o[on.SEQ]:o[on.MAP]}i&&(i(c),delete n.onTagObj);let u=c?.createNode?c.createNode(n.schema,t,n):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(n.schema,t,n):new xh.Scalar(t);return e?u.tag=e:c.default||(u.tag=c.tag),l&&(l.node=u),u}Eh.createNode=Yx});var Fi=$(ji=>{"use strict";var Vx=Zr(),it=J(),Gx=Di();function ic(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 Vx.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 Ah=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,oc=class extends Gx.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=>it.isNode(r)||it.isPair(r)?r.clone(e):r),this.range&&(n.range=this.range.slice()),n}addIn(e,n){if(Ah(e))this.add(n);else{let[r,...s]=e,i=this.get(r,!0);if(it.isCollection(i))i.addIn(s,n);else if(i===void 0&&this.schema)this.set(r,ic(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(it.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&&it.isScalar(i)?i.value:i:it.isCollection(i)?i.getIn(s,n):void 0}hasAllNullValues(e){return this.items.every(n=>{if(!it.isPair(n))return!1;let r=n.value;return r==null||e&&it.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 it.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(it.isCollection(i))i.setIn(s,n);else if(i===void 0&&this.schema)this.set(r,ic(this.schema,s,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${s}`)}}};ji.Collection=oc;ji.collectionFromPath=ic;ji.isEmptyPath=Ah});var es=$(Ui=>{"use strict";var Xx=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function ac(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var Qx=(t,e,n)=>t.endsWith(`
26
26
  `)?ac(n,e):n.includes(`
27
27
  `)?`
28
- `+ac(n,e):(t.endsWith(" ")?"":" ")+n;Ui.indentComment=ac;Ui.lineComment=Kx;Ui.stringifyComment=Wx});var Ah=_(ts=>{"use strict";var Hx="flow",lc="block",qi="quoted";function zx(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=[],u={},d=s-e.length;typeof r=="number"&&(r>s-Math.max(2,i)?c.push(0):d=s-r);let f,p,h=!1,m=-1,g=-1,v=-1;n===lc&&(m=Eh(t,m,e.length),m!==-1&&(d=m+l));for(let C;C=t[m+=1];){if(n===qi&&C==="\\"){switch(g=m,t[m+1]){case"x":m+=3;break;case"u":m+=5;break;case"U":m+=9;break;default:m+=1}v=m}if(C===`
29
- `)n===lc&&(m=Eh(t,m,e.length)),d=m+e.length+l,f=void 0;else{if(C===" "&&p&&p!==" "&&p!==`
30
- `&&p!==" "){let x=t[m+1];x&&x!==" "&&x!==`
31
- `&&x!==" "&&(f=m)}if(m>=d)if(f)c.push(f),d=f+l,f=void 0;else if(n===qi){for(;p===" "||p===" ";)p=C,C=t[m+=1],h=!0;let x=m>v+1?m-2:g-1;if(u[x])return t;c.push(x),u[x]=!0,d=x+l,f=void 0}else h=!0}p=C}if(h&&a&&a(),c.length===0)return t;o&&o();let A=t.slice(0,c[0]);for(let C=0;C<c.length;++C){let x=c[C],R=c[C+1]||t.length;x===0?A=`
32
- ${e}${t.slice(0,R)}`:(n===qi&&u[x]&&(A+=`${t[x]}\\`),A+=`
33
- ${e}${t.slice(x+1,R)}`)}return A}function Eh(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}ts.FOLD_BLOCK=lc;ts.FOLD_FLOW=Hx;ts.FOLD_QUOTED=qi;ts.foldFlowLines=zx});var rs=_(Th=>{"use strict";var Ye=se(),It=Ah(),Wi=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),Ki=t=>/^(%|---|\.\.\.)/m.test(t);function Yx(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]===`
28
+ `+ac(n,e):(t.endsWith(" ")?"":" ")+n;Ui.indentComment=ac;Ui.lineComment=Qx;Ui.stringifyComment=Xx});var Ch=$(ts=>{"use strict";var Zx="flow",lc="block",qi="quoted";function e0(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=[],u={},d=s-e.length;typeof r=="number"&&(r>s-Math.max(2,i)?c.push(0):d=s-r);let f,p,m=!1,h=-1,y=-1,k=-1;n===lc&&(h=Th(t,h,e.length),h!==-1&&(d=h+l));for(let P;P=t[h+=1];){if(n===qi&&P==="\\"){switch(y=h,t[h+1]){case"x":h+=3;break;case"u":h+=5;break;case"U":h+=9;break;default:h+=1}k=h}if(P===`
29
+ `)n===lc&&(h=Th(t,h,e.length)),d=h+e.length+l,f=void 0;else{if(P===" "&&p&&p!==" "&&p!==`
30
+ `&&p!==" "){let E=t[h+1];E&&E!==" "&&E!==`
31
+ `&&E!==" "&&(f=h)}if(h>=d)if(f)c.push(f),d=f+l,f=void 0;else if(n===qi){for(;p===" "||p===" ";)p=P,P=t[h+=1],m=!0;let E=h>k+1?h-2:y-1;if(u[E])return t;c.push(E),u[E]=!0,d=E+l,f=void 0}else m=!0}p=P}if(m&&a&&a(),c.length===0)return t;o&&o();let T=t.slice(0,c[0]);for(let P=0;P<c.length;++P){let E=c[P],O=c[P+1]||t.length;E===0?T=`
32
+ ${e}${t.slice(0,O)}`:(n===qi&&u[E]&&(T+=`${t[E]}\\`),T+=`
33
+ ${e}${t.slice(E+1,O)}`)}return T}function Th(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}ts.FOLD_BLOCK=lc;ts.FOLD_FLOW=Zx;ts.FOLD_QUOTED=qi;ts.foldFlowLines=e0});var rs=$(Oh=>{"use strict";var Ye=se(),It=Ch(),Wi=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),Ki=t=>/^(%|---|\.\.\.)/m.test(t);function t0(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
35
  `){if(i-o>r)return!0;if(o=i+1,s-o<=r)return!1}return!0}function ns(t,e){let n=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=e,s=e.options.doubleQuotedMinMultiLineLength,i=e.indent||(Ki(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 u=n.substr(l+2,4);switch(u){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:u.substr(0,2)==="00"?o+="\\x"+u.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
36
 
37
37
  `;n[l+2]==="\\"&&n[l+3]==="n"&&n[l+4]!=='"';)o+=`
38
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:It.foldFlowLines(o,i,It.FOLD_QUOTED,Wi(e,!1))}function cc(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
39
39
  `)||/[ \t]\n|\n[ \t]/.test(t))return ns(t,e);let n=e.indent||(Ki(t)?" ":""),r="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
40
- ${n}`)+"'";return e.implicitKey?r:It.foldFlowLines(r,n,It.FOLD_FLOW,Wi(e,!1))}function Kn(t,e){let{singleQuote:n}=e.options,r;if(n===!1)r=ns;else{let s=t.includes('"'),i=t.includes("'");s&&!i?r=cc:i&&!s?r=ns:r=n?cc:ns}return r(t,e)}var uc;try{uc=new RegExp(`(^|(?<!
40
+ ${n}`)+"'";return e.implicitKey?r:It.foldFlowLines(r,n,It.FOLD_FLOW,Wi(e,!1))}function Wn(t,e){let{singleQuote:n}=e.options,r;if(n===!1)r=ns;else{let s=t.includes('"'),i=t.includes("'");s&&!i?r=cc:i&&!s?r=ns:r=n?cc:ns}return r(t,e)}var uc;try{uc=new RegExp(`(^|(?<!
41
41
  ))
42
42
  +(?!
43
- |$)`,"g")}catch{uc=/\n+(?!\n|$)/g}function Ji({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 Kn(n,r);let c=r.indent||(r.forceBlockIndent||Ki(n)?" ":""),u=o==="literal"?!0:o==="folded"||e===Ye.Scalar.BLOCK_FOLDED?!1:e===Ye.Scalar.BLOCK_LITERAL?!0:!Yx(n,l,c.length);if(!n)return u?`|
43
+ |$)`,"g")}catch{uc=/\n+(?!\n|$)/g}function Ji({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 Wn(n,r);let c=r.indent||(r.forceBlockIndent||Ki(n)?" ":""),u=o==="literal"?!0:o==="folded"||e===Ye.Scalar.BLOCK_FOLDED?!1:e===Ye.Scalar.BLOCK_LITERAL?!0:!t0(n,l,c.length);if(!n)return u?`|
44
44
  `:`>
45
- `;let d,f;for(f=n.length;f>0;--f){let R=n[f-1];if(R!==`
46
- `&&R!==" "&&R!==" ")break}let p=n.substring(f),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(uc,`$&${c}`));let m=!1,g,v=-1;for(g=0;g<n.length;++g){let R=n[g];if(R===" ")m=!0;else if(R===`
49
- `)v=g;else break}let A=n.substring(0,v<g?v+1:g);A&&(n=n.substring(A.length),A=A.replace(/\n+/g,`$&${c}`));let x=(m?c?"2":"1":"")+d;if(t&&(x+=" "+a(t.replace(/ ?[\r\n]+/g," ")),s&&s()),!u){let R=n.replace(/\n+/g,`
50
- $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),I=!1,L=Wi(r,!0);o!=="folded"&&e!==Ye.Scalar.BLOCK_FOLDED&&(L.onOverflow=()=>{I=!0});let T=It.foldFlowLines(`${A}${R}${p}`,c,It.FOLD_BLOCK,L);if(!I)return`>${x}
51
- ${c}${T}`}return n=n.replace(/\n+/g,`$&${c}`),`|${x}
52
- ${c}${A}${n}${p}`}function Vx(t,e,n,r){let{type:s,value:i}=t,{actualString:o,implicitKey:a,indent:l,indentStep:c,inFlow:u}=e;if(a&&i.includes(`
53
- `)||u&&/[[\]{},]/.test(i))return Kn(i,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(i))return a||u||!i.includes(`
54
- `)?Kn(i,e):Ji(t,e,n,r);if(!a&&!u&&s!==Ye.Scalar.PLAIN&&i.includes(`
55
- `))return Ji(t,e,n,r);if(Ki(i)){if(l==="")return e.forceBlockIndent=!0,Ji(t,e,n,r);if(a&&l===c)return Kn(i,e)}let d=i.replace(/\n+/g,`$&
56
- ${l}`);if(o){let f=m=>m.default&&m.tag!=="tag:yaml.org,2002:str"&&m.test?.test(d),{compat:p,tags:h}=e.doc.schema;if(h.some(f)||p?.some(f))return Kn(i,e)}return a?d:It.foldFlowLines(d,l,It.FOLD_FLOW,Wi(e,!1))}function Gx(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!==Ye.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(a=Ye.Scalar.QUOTE_DOUBLE);let l=u=>{switch(u){case Ye.Scalar.BLOCK_FOLDED:case Ye.Scalar.BLOCK_LITERAL:return s||i?Kn(o.value,e):Ji(o,e,n,r);case Ye.Scalar.QUOTE_DOUBLE:return ns(o.value,e);case Ye.Scalar.QUOTE_SINGLE:return cc(o.value,e);case Ye.Scalar.PLAIN:return Vx(o,e,n,r);default:return null}},c=l(a);if(c===null){let{defaultKeyType:u,defaultStringType:d}=e.options,f=s&&u||d;if(c=l(f),c===null)throw new Error(`Unsupported default string type ${f}`)}return c}Th.stringifyString=Gx});var ss=_(dc=>{"use strict";var Xx=Mi(),$t=J(),Qx=es(),Zx=rs();function e0(t,e){let n=Object.assign({blockQuote:!0,commentString:Qx.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($t.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 n0(t,e,{anchors:n,doc:r}){if(!r.directives)return"";let s=[],i=($t.isScalar(t)||$t.isCollection(t))&&t.anchor;i&&Xx.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 r0(t,e,n,r){if($t.isPair(t))return t.toString(e,n,r);if($t.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=$t.isNode(t)?t:e.doc.createNode(t,{onTagObj:l=>s=l});s??(s=t0(e.doc.schema.tags,i));let o=n0(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):$t.isScalar(i)?Zx.stringifyString(i,e,n,r):i.toString(e,n,r);return o?$t.isScalar(i)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
57
- ${e.indent}${a}`:a}dc.createStringifyContext=e0;dc.stringify=r0});var _h=_(Ph=>{"use strict";var pt=J(),Ch=se(),Oh=ss(),is=es();function s0({key:t,value:e},n,r,s){let{allNullValues:i,doc:o,indent:a,indentStep:l,options:{commentString:c,indentSeq:u,simpleKeys:d}}=n,f=pt.isNode(t)&&t.comment||null;if(d){if(f)throw new Error("With simple keys, key nodes cannot have comments");if(pt.isCollection(t)||!pt.isNode(t)&&typeof t=="object"){let L="With simple keys, collection cannot be used as a key value";throw new Error(L)}}let p=!d&&(!t||f&&e==null&&!n.inFlow||pt.isCollection(t)||(pt.isScalar(t)?t.type===Ch.Scalar.BLOCK_FOLDED||t.type===Ch.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=Oh.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}`,f&&!h?g+=is.lineComment(g,n.indent,c(f)):m&&s&&s(),g;h&&(f=null),p?(f&&(g+=is.lineComment(g,n.indent,c(f))),g=`? ${g}
58
- ${a}:`):(g=`${g}:`,f&&(g+=is.lineComment(g,n.indent,c(f))));let v,A,C;pt.isNode(e)?(v=!!e.spaceBefore,A=e.commentBefore,C=e.comment):(v=!1,A=null,C=null,e&&typeof e=="object"&&(e=o.createNode(e))),n.implicitKey=!1,!p&&!f&&pt.isScalar(e)&&(n.indentAtStart=g.length+1),m=!1,!u&&l.length>=2&&!n.inFlow&&!p&&pt.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(n.indent=n.indent.substring(2));let x=!1,R=Oh.stringify(e,n,()=>x=!0,()=>m=!0),I=" ";if(f||v||A){if(I=v?`
59
- `:"",A){let L=c(A);I+=`
60
- ${is.indentComment(L,n.indent)}`}R===""&&!n.inFlow?I===`
61
- `&&C&&(I=`
62
-
63
- `):I+=`
64
- ${n.indent}`}else if(!p&&pt.isCollection(e)){let L=R[0],T=R.indexOf(`
65
- `),F=T!==-1,H=n.inFlow??e.flow??e.items.length===0;if(F||!H){let ne=!1;if(F&&(L==="&"||L==="!")){let U=R.indexOf(" ");L==="&"&&U!==-1&&U<T&&R[U+1]==="!"&&(U=R.indexOf(" ",U+1)),(U===-1||T<U)&&(ne=!0)}ne||(I=`
66
- ${n.indent}`)}}else(R===""||R[0]===`
67
- `)&&(I="");return g+=I+R,n.inFlow?x&&r&&r():C&&!x?g+=is.lineComment(g,n.indent,c(C)):m&&s&&s(),g}Ph.stringifyPair=s0});var pc=_(fc=>{"use strict";var Rh=Ei("process");function i0(t,...e){t==="debug"&&console.log(...e)}function o0(t,e){(t==="debug"||t==="warn")&&(typeof Rh.emitWarning=="function"?Rh.emitWarning(e):console.warn(e))}fc.debug=i0;fc.warn=o0});var Vi=_(Yi=>{"use strict";var os=J(),Ih=se(),Hi="<<",zi={identify:t=>t===Hi||typeof t=="symbol"&&t.description===Hi,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Ih.Scalar(Symbol(Hi)),{addToJSMap:$h}),stringify:()=>Hi},a0=(t,e)=>(zi.identify(e)||os.isScalar(e)&&(!e.type||e.type===Ih.Scalar.PLAIN)&&zi.identify(e.value))&&t?.doc.schema.tags.some(n=>n.tag===zi.tag&&n.default);function $h(t,e,n){if(n=t&&os.isAlias(n)?n.resolve(t.doc):n,os.isSeq(n))for(let r of n.items)hc(t,e,r);else if(Array.isArray(n))for(let r of n)hc(t,e,r);else hc(t,e,n)}function hc(t,e,n){let r=t&&os.isAlias(n)?n.resolve(t.doc):n;if(!os.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}Yi.addMergeToJSMap=$h;Yi.isMergeKey=a0;Yi.merge=zi});var gc=_(Mh=>{"use strict";var l0=pc(),Nh=Vi(),c0=ss(),Lh=J(),mc=_t();function u0(t,e,{key:n,value:r}){if(Lh.isNode(n)&&n.addToJSMap)n.addToJSMap(t,e,r);else if(Nh.isMergeKey(t,n))Nh.addMergeToJSMap(t,e,r);else{let s=mc.toJS(n,"",t);if(e instanceof Map)e.set(s,mc.toJS(r,s,t));else if(e instanceof Set)e.add(s);else{let i=d0(n,s,t),o=mc.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 d0(t,e,n){if(e===null)return"";if(typeof e!="object")return String(e);if(Lh.isNode(t)&&n?.doc){let r=c0.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)+'..."'),l0.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)}Mh.addPairToJSMap=u0});var Nt=_(yc=>{"use strict";var Dh=Zr(),f0=_h(),p0=gc(),Gi=J();function h0(t,e,n){let r=Dh.createNode(t,void 0,n),s=Dh.createNode(e,void 0,n);return new Xi(r,s)}var Xi=class t{constructor(e,n=null){Object.defineProperty(this,Gi.NODE_TYPE,{value:Gi.PAIR}),this.key=e,this.value=n}clone(e){let{key:n,value:r}=this;return Gi.isNode(n)&&(n=n.clone(e)),Gi.isNode(r)&&(r=r.clone(e)),new t(n,r)}toJSON(e,n){let r=n?.mapAsMap?new Map:{};return p0.addPairToJSMap(n,r,this)}toString(e,n,r){return e?.doc?f0.stringifyPair(this,e,n,r):JSON.stringify(this)}};yc.Pair=Xi;yc.createPair=h0});var bc=_(jh=>{"use strict";var an=J(),Bh=ss(),Qi=es();function m0(t,e,n){return(e.inFlow??t.flow?y0:g0)(t,e,n)}function g0({comment:t,items:e},n,{blockItemPrefix:r,flowChars:s,itemIndent:i,onChompKeep:o,onComment:a}){let{indent:l,options:{commentString:c}}=n,u=Object.assign({},n,{indent:i,type:null}),d=!1,f=[];for(let h=0;h<e.length;++h){let m=e[h],g=null;if(an.isNode(m))!d&&m.spaceBefore&&f.push(""),Zi(n,f,m.commentBefore,d),m.comment&&(g=m.comment);else if(an.isPair(m)){let A=an.isNode(m.key)?m.key:null;A&&(!d&&A.spaceBefore&&f.push(""),Zi(n,f,A.commentBefore,d))}d=!1;let v=Bh.stringify(m,u,()=>g=null,()=>d=!0);g&&(v+=Qi.lineComment(v,i,c(g))),d&&g&&(d=!1),f.push(r+v)}let p;if(f.length===0)p=s.start+s.end;else{p=f[0];for(let h=1;h<f.length;++h){let m=f[h];p+=m?`
68
- ${l}${m}`:`
45
+ `;let d,f;for(f=n.length;f>0;--f){let O=n[f-1];if(O!==`
46
+ `&&O!==" "&&O!==" ")break}let p=n.substring(f),m=p.indexOf(`
47
+ `);m===-1?d="-":n===p||m!==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(uc,`$&${c}`));let h=!1,y,k=-1;for(y=0;y<n.length;++y){let O=n[y];if(O===" ")h=!0;else if(O===`
49
+ `)k=y;else break}let T=n.substring(0,k<y?k+1:y);T&&(n=n.substring(T.length),T=T.replace(/\n+/g,`$&${c}`));let E=(h?c?"2":"1":"")+d;if(t&&(E+=" "+a(t.replace(/ ?[\r\n]+/g," ")),s&&s()),!u){let O=n.replace(/\n+/g,`
50
+ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),_=!1,I=Wi(r,!0);o!=="folded"&&e!==Ye.Scalar.BLOCK_FOLDED&&(I.onOverflow=()=>{_=!0});let A=It.foldFlowLines(`${T}${O}${p}`,c,It.FOLD_BLOCK,I);if(!_)return`>${E}
51
+ ${c}${A}`}return n=n.replace(/\n+/g,`$&${c}`),`|${E}
52
+ ${c}${T}${n}${p}`}function n0(t,e,n,r){let{type:s,value:i}=t,{actualString:o,implicitKey:a,indent:l,indentStep:c,inFlow:u}=e;if(a&&i.includes(`
53
+ `)||u&&/[[\]{},]/.test(i))return Wn(i,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(i))return a||u||!i.includes(`
54
+ `)?Wn(i,e):Ji(t,e,n,r);if(!a&&!u&&s!==Ye.Scalar.PLAIN&&i.includes(`
55
+ `))return Ji(t,e,n,r);if(Ki(i)){if(l==="")return e.forceBlockIndent=!0,Ji(t,e,n,r);if(a&&l===c)return Wn(i,e)}let d=i.replace(/\n+/g,`$&
56
+ ${l}`);if(o){let f=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(d),{compat:p,tags:m}=e.doc.schema;if(m.some(f)||p?.some(f))return Wn(i,e)}return a?d:It.foldFlowLines(d,l,It.FOLD_FLOW,Wi(e,!1))}function r0(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!==Ye.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(a=Ye.Scalar.QUOTE_DOUBLE);let l=u=>{switch(u){case Ye.Scalar.BLOCK_FOLDED:case Ye.Scalar.BLOCK_LITERAL:return s||i?Wn(o.value,e):Ji(o,e,n,r);case Ye.Scalar.QUOTE_DOUBLE:return ns(o.value,e);case Ye.Scalar.QUOTE_SINGLE:return cc(o.value,e);case Ye.Scalar.PLAIN:return n0(o,e,n,r);default:return null}},c=l(a);if(c===null){let{defaultKeyType:u,defaultStringType:d}=e.options,f=s&&u||d;if(c=l(f),c===null)throw new Error(`Unsupported default string type ${f}`)}return c}Oh.stringifyString=r0});var ss=$(dc=>{"use strict";var s0=Mi(),$t=J(),i0=es(),o0=rs();function a0(t,e){let n=Object.assign({blockQuote:!0,commentString:i0.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 l0(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($t.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=($t.isScalar(t)||$t.isCollection(t))&&t.anchor;i&&s0.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 u0(t,e,n,r){if($t.isPair(t))return t.toString(e,n,r);if($t.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=$t.isNode(t)?t:e.doc.createNode(t,{onTagObj:l=>s=l});s??(s=l0(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):$t.isScalar(i)?o0.stringifyString(i,e,n,r):i.toString(e,n,r);return o?$t.isScalar(i)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
57
+ ${e.indent}${a}`:a}dc.createStringifyContext=a0;dc.stringify=u0});var Ih=$(Rh=>{"use strict";var pt=J(),Ph=se(),_h=ss(),is=es();function d0({key:t,value:e},n,r,s){let{allNullValues:i,doc:o,indent:a,indentStep:l,options:{commentString:c,indentSeq:u,simpleKeys:d}}=n,f=pt.isNode(t)&&t.comment||null;if(d){if(f)throw new Error("With simple keys, key nodes cannot have comments");if(pt.isCollection(t)||!pt.isNode(t)&&typeof t=="object"){let I="With simple keys, collection cannot be used as a key value";throw new Error(I)}}let p=!d&&(!t||f&&e==null&&!n.inFlow||pt.isCollection(t)||(pt.isScalar(t)?t.type===Ph.Scalar.BLOCK_FOLDED||t.type===Ph.Scalar.BLOCK_LITERAL:typeof t=="object"));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(d||!i),indent:a+l});let m=!1,h=!1,y=_h.stringify(t,n,()=>m=!0,()=>h=!0);if(!p&&!n.inFlow&&y.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 m&&r&&r(),y===""?"?":p?`? ${y}`:y}else if(i&&!d||e==null&&p)return y=`? ${y}`,f&&!m?y+=is.lineComment(y,n.indent,c(f)):h&&s&&s(),y;m&&(f=null),p?(f&&(y+=is.lineComment(y,n.indent,c(f))),y=`? ${y}
58
+ ${a}:`):(y=`${y}:`,f&&(y+=is.lineComment(y,n.indent,c(f))));let k,T,P;pt.isNode(e)?(k=!!e.spaceBefore,T=e.commentBefore,P=e.comment):(k=!1,T=null,P=null,e&&typeof e=="object"&&(e=o.createNode(e))),n.implicitKey=!1,!p&&!f&&pt.isScalar(e)&&(n.indentAtStart=y.length+1),h=!1,!u&&l.length>=2&&!n.inFlow&&!p&&pt.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(n.indent=n.indent.substring(2));let E=!1,O=_h.stringify(e,n,()=>E=!0,()=>h=!0),_=" ";if(f||k||T){if(_=k?`
59
+ `:"",T){let I=c(T);_+=`
60
+ ${is.indentComment(I,n.indent)}`}O===""&&!n.inFlow?_===`
61
+ `&&P&&(_=`
62
+
63
+ `):_+=`
64
+ ${n.indent}`}else if(!p&&pt.isCollection(e)){let I=O[0],A=O.indexOf(`
65
+ `),M=A!==-1,K=n.inFlow??e.flow??e.items.length===0;if(M||!K){let ne=!1;if(M&&(I==="&"||I==="!")){let U=O.indexOf(" ");I==="&"&&U!==-1&&U<A&&O[U+1]==="!"&&(U=O.indexOf(" ",U+1)),(U===-1||A<U)&&(ne=!0)}ne||(_=`
66
+ ${n.indent}`)}}else(O===""||O[0]===`
67
+ `)&&(_="");return y+=_+O,n.inFlow?E&&r&&r():P&&!E?y+=is.lineComment(y,n.indent,c(P)):h&&s&&s(),y}Rh.stringifyPair=d0});var pc=$(fc=>{"use strict";var $h=Ei("process");function f0(t,...e){t==="debug"&&console.log(...e)}function p0(t,e){(t==="debug"||t==="warn")&&(typeof $h.emitWarning=="function"?$h.emitWarning(e):console.warn(e))}fc.debug=f0;fc.warn=p0});var Vi=$(Yi=>{"use strict";var os=J(),Nh=se(),Hi="<<",zi={identify:t=>t===Hi||typeof t=="symbol"&&t.description===Hi,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Nh.Scalar(Symbol(Hi)),{addToJSMap:Lh}),stringify:()=>Hi},h0=(t,e)=>(zi.identify(e)||os.isScalar(e)&&(!e.type||e.type===Nh.Scalar.PLAIN)&&zi.identify(e.value))&&t?.doc.schema.tags.some(n=>n.tag===zi.tag&&n.default);function Lh(t,e,n){if(n=t&&os.isAlias(n)?n.resolve(t.doc):n,os.isSeq(n))for(let r of n.items)hc(t,e,r);else if(Array.isArray(n))for(let r of n)hc(t,e,r);else hc(t,e,n)}function hc(t,e,n){let r=t&&os.isAlias(n)?n.resolve(t.doc):n;if(!os.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}Yi.addMergeToJSMap=Lh;Yi.isMergeKey=h0;Yi.merge=zi});var gc=$(Bh=>{"use strict";var m0=pc(),Mh=Vi(),g0=ss(),Dh=J(),mc=_t();function y0(t,e,{key:n,value:r}){if(Dh.isNode(n)&&n.addToJSMap)n.addToJSMap(t,e,r);else if(Mh.isMergeKey(t,n))Mh.addMergeToJSMap(t,e,r);else{let s=mc.toJS(n,"",t);if(e instanceof Map)e.set(s,mc.toJS(r,s,t));else if(e instanceof Set)e.add(s);else{let i=b0(n,s,t),o=mc.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 b0(t,e,n){if(e===null)return"";if(typeof e!="object")return String(e);if(Dh.isNode(t)&&n?.doc){let r=g0.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)+'..."'),m0.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)}Bh.addPairToJSMap=y0});var Nt=$(yc=>{"use strict";var jh=Zr(),w0=Ih(),v0=gc(),Gi=J();function S0(t,e,n){let r=jh.createNode(t,void 0,n),s=jh.createNode(e,void 0,n);return new Xi(r,s)}var Xi=class t{constructor(e,n=null){Object.defineProperty(this,Gi.NODE_TYPE,{value:Gi.PAIR}),this.key=e,this.value=n}clone(e){let{key:n,value:r}=this;return Gi.isNode(n)&&(n=n.clone(e)),Gi.isNode(r)&&(r=r.clone(e)),new t(n,r)}toJSON(e,n){let r=n?.mapAsMap?new Map:{};return v0.addPairToJSMap(n,r,this)}toString(e,n,r){return e?.doc?w0.stringifyPair(this,e,n,r):JSON.stringify(this)}};yc.Pair=Xi;yc.createPair=S0});var bc=$(Uh=>{"use strict";var an=J(),Fh=ss(),Qi=es();function k0(t,e,n){return(e.inFlow??t.flow?E0:x0)(t,e,n)}function x0({comment:t,items:e},n,{blockItemPrefix:r,flowChars:s,itemIndent:i,onChompKeep:o,onComment:a}){let{indent:l,options:{commentString:c}}=n,u=Object.assign({},n,{indent:i,type:null}),d=!1,f=[];for(let m=0;m<e.length;++m){let h=e[m],y=null;if(an.isNode(h))!d&&h.spaceBefore&&f.push(""),Zi(n,f,h.commentBefore,d),h.comment&&(y=h.comment);else if(an.isPair(h)){let T=an.isNode(h.key)?h.key:null;T&&(!d&&T.spaceBefore&&f.push(""),Zi(n,f,T.commentBefore,d))}d=!1;let k=Fh.stringify(h,u,()=>y=null,()=>d=!0);y&&(k+=Qi.lineComment(k,i,c(y))),d&&y&&(d=!1),f.push(r+k)}let p;if(f.length===0)p=s.start+s.end;else{p=f[0];for(let m=1;m<f.length;++m){let h=f[m];p+=h?`
68
+ ${l}${h}`:`
69
69
  `}}return t?(p+=`
70
- `+Qi.indentComment(c(t),l),a&&a()):d&&o&&o(),p}function y0({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,u=0,d=[];for(let h=0;h<t.length;++h){let m=t[h],g=null;if(an.isNode(m))m.spaceBefore&&d.push(""),Zi(e,d,m.commentBefore,!1),m.comment&&(g=m.comment);else if(an.isPair(m)){let A=an.isNode(m.key)?m.key:null;A&&(A.spaceBefore&&d.push(""),Zi(e,d,A.commentBefore,!1),A.comment&&(c=!0));let C=an.isNode(m.value)?m.value:null;C?(C.comment&&(g=C.comment),C.commentBefore&&(c=!0)):m.value==null&&A?.comment&&(g=A.comment)}g&&(c=!0);let v=Bh.stringify(m,l,()=>g=null);h<t.length-1&&(v+=","),g&&(v+=Qi.lineComment(v,r,a(g))),!c&&(d.length>u||v.includes(`
71
- `))&&(c=!0),d.push(v),u=d.length}let{start:f,end:p}=n;if(d.length===0)return f+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=f;for(let m of d)h+=m?`
72
- ${i}${s}${m}`:`
73
- `;return`${h}
74
- ${s}${p}`}else return`${f}${o}${d.join(" ")}${o}${p}`}function Zi({indent:t,options:{commentString:e}},n,r,s){if(r&&s&&(r=r.replace(/^\n+/,"")),r){let i=Qi.indentComment(e(r),t);n.push(i.trimStart())}}jh.stringifyCollection=m0});var Mt=_(vc=>{"use strict";var b0=bc(),w0=gc(),v0=Fi(),Lt=J(),eo=Nt(),S0=se();function as(t,e){let n=Lt.isScalar(e)?e.value:e;for(let r of t)if(Lt.isPair(r)&&(r.key===e||r.key===n||Lt.isScalar(r.key)&&r.key.value===n))return r}var wc=class extends v0.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Lt.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(eo.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;Lt.isPair(e)?r=e:!e||typeof e!="object"||!("key"in e)?r=new eo.Pair(e,e?.value):r=new eo.Pair(e.key,e.value);let s=as(this.items,r.key),i=this.schema?.sortMapEntries;if(s){if(!n)throw new Error(`Key ${r.key} already set`);Lt.isScalar(s.value)&&S0.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=as(this.items,e);return n?this.items.splice(this.items.indexOf(n),1).length>0:!1}get(e,n){let s=as(this.items,e)?.value;return(!n&&Lt.isScalar(s)?s.value:s)??void 0}has(e){return!!as(this.items,e)}set(e,n){this.add(new eo.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(!Lt.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})),b0.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:n})}};vc.YAMLMap=wc;vc.findPair=as});var Hn=_(Uh=>{"use strict";var k0=J(),Fh=Mt(),x0={collection:"map",default:!0,nodeClass:Fh.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(t,e){return k0.isMap(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,n)=>Fh.YAMLMap.from(t,e,n)};Uh.map=x0});var Dt=_(qh=>{"use strict";var E0=Zr(),A0=bc(),T0=Fi(),no=J(),C0=se(),O0=_t(),Sc=class extends T0.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(no.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let n=to(e);return typeof n!="number"?!1:this.items.splice(n,1).length>0}get(e,n){let r=to(e);if(typeof r!="number")return;let s=this.items[r];return!n&&no.isScalar(s)?s.value:s}has(e){let n=to(e);return typeof n=="number"&&n<this.items.length}set(e,n){let r=to(e);if(typeof r!="number")throw new Error(`Expected a valid index, not ${e}.`);let s=this.items[r];no.isScalar(s)&&C0.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(O0.toJS(i,String(s++),n));return r}toString(e,n,r){return e?A0.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(E0.createNode(a,void 0,r))}}return i}};function to(t){let e=no.isScalar(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}qh.YAMLSeq=Sc});var zn=_(Wh=>{"use strict";var P0=J(),Jh=Dt(),_0={collection:"seq",default:!0,nodeClass:Jh.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(t,e){return P0.isSeq(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,n)=>Jh.YAMLSeq.from(t,e,n)};Wh.seq=_0});var ls=_(Kh=>{"use strict";var R0=rs(),I0={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),R0.stringifyString(t,e,n,r)}};Kh.string=I0});var ro=_(Yh=>{"use strict";var Hh=se(),zh={identify:t=>t==null,createNode:()=>new Hh.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Hh.Scalar(null),stringify:({source:t},e)=>typeof t=="string"&&zh.test.test(t)?t:e.options.nullStr};Yh.nullTag=zh});var kc=_(Gh=>{"use strict";var $0=se(),Vh={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new $0.Scalar(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},n){if(t&&Vh.test.test(t)){let r=t[0]==="t"||t[0]==="T";if(e===r)return t}return e?n.options.trueStr:n.options.falseStr}};Gh.boolTag=Vh});var Yn=_(Xh=>{"use strict";function N0({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}Xh.stringifyNumber=N0});var Ec=_(so=>{"use strict";var L0=se(),xc=Yn(),M0={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:xc.stringifyNumber},D0={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():xc.stringifyNumber(t)}},B0={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 L0.Scalar(parseFloat(t)),n=t.indexOf(".");return n!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-n-1),e},stringify:xc.stringifyNumber};so.float=B0;so.floatExp=D0;so.floatNaN=M0});var Tc=_(oo=>{"use strict";var Qh=Yn(),io=t=>typeof t=="bigint"||Number.isInteger(t),Ac=(t,e,n,{intAsBigInt:r})=>r?BigInt(t):parseInt(t.substring(e),n);function Zh(t,e,n){let{value:r}=t;return io(r)&&r>=0?n+r.toString(e):Qh.stringifyNumber(t)}var j0={identify:t=>io(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,n)=>Ac(t,2,8,n),stringify:t=>Zh(t,8,"0o")},F0={identify:io,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,n)=>Ac(t,0,10,n),stringify:Qh.stringifyNumber},U0={identify:t=>io(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,n)=>Ac(t,2,16,n),stringify:t=>Zh(t,16,"0x")};oo.int=F0;oo.intHex=U0;oo.intOct=j0});var tm=_(em=>{"use strict";var q0=Hn(),J0=ro(),W0=zn(),K0=ls(),H0=kc(),Cc=Ec(),Oc=Tc(),z0=[q0.map,W0.seq,K0.string,J0.nullTag,H0.boolTag,Oc.intOct,Oc.int,Oc.intHex,Cc.floatNaN,Cc.floatExp,Cc.float];em.schema=z0});var sm=_(rm=>{"use strict";var Y0=se(),V0=Hn(),G0=zn();function nm(t){return typeof t=="bigint"||Number.isInteger(t)}var ao=({value:t})=>JSON.stringify(t),X0=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:ao},{identify:t=>t==null,createNode:()=>new Y0.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:nm,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})=>nm(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}],Q0={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},Z0=[V0.map,G0.seq].concat(X0,Q0);rm.schema=Z0});var _c=_(im=>{"use strict";var cs=Ei("buffer"),Pc=se(),eE=rs(),tE={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof cs.Buffer=="function")return cs.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 cs.Buffer=="function")a=o instanceof cs.Buffer?o.toString("base64"):cs.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=Pc.Scalar.BLOCK_LITERAL),e!==Pc.Scalar.QUOTE_DOUBLE){let l=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),c=Math.ceil(a.length/l),u=new Array(c);for(let d=0,f=0;d<c;++d,f+=l)u[d]=a.substr(f,l);a=u.join(e===Pc.Scalar.BLOCK_LITERAL?`
75
- `:" ")}return eE.stringifyString({comment:t,type:e,value:a},r,s,i)}};im.binary=tE});var uo=_(co=>{"use strict";var lo=J(),Rc=Nt(),nE=se(),rE=Dt();function om(t,e){if(lo.isSeq(t))for(let n=0;n<t.items.length;++n){let r=t.items[n];if(!lo.isPair(r)){if(lo.isMap(r)){r.items.length>1&&e("Each pair must have its own sequence indicator");let s=r.items[0]||new Rc.Pair(new nE.Scalar(null));if(r.commentBefore&&(s.key.commentBefore=s.key.commentBefore?`${r.commentBefore}
70
+ `+Qi.indentComment(c(t),l),a&&a()):d&&o&&o(),p}function E0({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,u=0,d=[];for(let m=0;m<t.length;++m){let h=t[m],y=null;if(an.isNode(h))h.spaceBefore&&d.push(""),Zi(e,d,h.commentBefore,!1),h.comment&&(y=h.comment);else if(an.isPair(h)){let T=an.isNode(h.key)?h.key:null;T&&(T.spaceBefore&&d.push(""),Zi(e,d,T.commentBefore,!1),T.comment&&(c=!0));let P=an.isNode(h.value)?h.value:null;P?(P.comment&&(y=P.comment),P.commentBefore&&(c=!0)):h.value==null&&T?.comment&&(y=T.comment)}y&&(c=!0);let k=Fh.stringify(h,l,()=>y=null);m<t.length-1&&(k+=","),y&&(k+=Qi.lineComment(k,r,a(y))),!c&&(d.length>u||k.includes(`
71
+ `))&&(c=!0),d.push(k),u=d.length}let{start:f,end:p}=n;if(d.length===0)return f+p;if(!c){let m=d.reduce((h,y)=>h+y.length+2,2);c=e.options.lineWidth>0&&m>e.options.lineWidth}if(c){let m=f;for(let h of d)m+=h?`
72
+ ${i}${s}${h}`:`
73
+ `;return`${m}
74
+ ${s}${p}`}else return`${f}${o}${d.join(" ")}${o}${p}`}function Zi({indent:t,options:{commentString:e}},n,r,s){if(r&&s&&(r=r.replace(/^\n+/,"")),r){let i=Qi.indentComment(e(r),t);n.push(i.trimStart())}}Uh.stringifyCollection=k0});var Mt=$(vc=>{"use strict";var A0=bc(),T0=gc(),C0=Fi(),Lt=J(),eo=Nt(),O0=se();function as(t,e){let n=Lt.isScalar(e)?e.value:e;for(let r of t)if(Lt.isPair(r)&&(r.key===e||r.key===n||Lt.isScalar(r.key)&&r.key.value===n))return r}var wc=class extends C0.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Lt.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(eo.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;Lt.isPair(e)?r=e:!e||typeof e!="object"||!("key"in e)?r=new eo.Pair(e,e?.value):r=new eo.Pair(e.key,e.value);let s=as(this.items,r.key),i=this.schema?.sortMapEntries;if(s){if(!n)throw new Error(`Key ${r.key} already set`);Lt.isScalar(s.value)&&O0.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=as(this.items,e);return n?this.items.splice(this.items.indexOf(n),1).length>0:!1}get(e,n){let s=as(this.items,e)?.value;return(!n&&Lt.isScalar(s)?s.value:s)??void 0}has(e){return!!as(this.items,e)}set(e,n){this.add(new eo.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)T0.addPairToJSMap(n,s,i);return s}toString(e,n,r){if(!e)return JSON.stringify(this);for(let s of this.items)if(!Lt.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})),A0.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:n})}};vc.YAMLMap=wc;vc.findPair=as});var Kn=$(Jh=>{"use strict";var P0=J(),qh=Mt(),_0={collection:"map",default:!0,nodeClass:qh.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(t,e){return P0.isMap(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,n)=>qh.YAMLMap.from(t,e,n)};Jh.map=_0});var Dt=$(Wh=>{"use strict";var R0=Zr(),I0=bc(),$0=Fi(),no=J(),N0=se(),L0=_t(),Sc=class extends $0.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(no.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let n=to(e);return typeof n!="number"?!1:this.items.splice(n,1).length>0}get(e,n){let r=to(e);if(typeof r!="number")return;let s=this.items[r];return!n&&no.isScalar(s)?s.value:s}has(e){let n=to(e);return typeof n=="number"&&n<this.items.length}set(e,n){let r=to(e);if(typeof r!="number")throw new Error(`Expected a valid index, not ${e}.`);let s=this.items[r];no.isScalar(s)&&N0.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(L0.toJS(i,String(s++),n));return r}toString(e,n,r){return e?I0.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(R0.createNode(a,void 0,r))}}return i}};function to(t){let e=no.isScalar(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}Wh.YAMLSeq=Sc});var Hn=$(Hh=>{"use strict";var M0=J(),Kh=Dt(),D0={collection:"seq",default:!0,nodeClass:Kh.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(t,e){return M0.isSeq(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,n)=>Kh.YAMLSeq.from(t,e,n)};Hh.seq=D0});var ls=$(zh=>{"use strict";var B0=rs(),j0={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),B0.stringifyString(t,e,n,r)}};zh.string=j0});var ro=$(Gh=>{"use strict";var Yh=se(),Vh={identify:t=>t==null,createNode:()=>new Yh.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Yh.Scalar(null),stringify:({source:t},e)=>typeof t=="string"&&Vh.test.test(t)?t:e.options.nullStr};Gh.nullTag=Vh});var kc=$(Qh=>{"use strict";var F0=se(),Xh={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new F0.Scalar(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},n){if(t&&Xh.test.test(t)){let r=t[0]==="t"||t[0]==="T";if(e===r)return t}return e?n.options.trueStr:n.options.falseStr}};Qh.boolTag=Xh});var zn=$(Zh=>{"use strict";function U0({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}Zh.stringifyNumber=U0});var Ec=$(so=>{"use strict";var q0=se(),xc=zn(),J0={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:xc.stringifyNumber},W0={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():xc.stringifyNumber(t)}},K0={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 q0.Scalar(parseFloat(t)),n=t.indexOf(".");return n!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-n-1),e},stringify:xc.stringifyNumber};so.float=K0;so.floatExp=W0;so.floatNaN=J0});var Tc=$(oo=>{"use strict";var em=zn(),io=t=>typeof t=="bigint"||Number.isInteger(t),Ac=(t,e,n,{intAsBigInt:r})=>r?BigInt(t):parseInt(t.substring(e),n);function tm(t,e,n){let{value:r}=t;return io(r)&&r>=0?n+r.toString(e):em.stringifyNumber(t)}var H0={identify:t=>io(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,n)=>Ac(t,2,8,n),stringify:t=>tm(t,8,"0o")},z0={identify:io,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,n)=>Ac(t,0,10,n),stringify:em.stringifyNumber},Y0={identify:t=>io(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,n)=>Ac(t,2,16,n),stringify:t=>tm(t,16,"0x")};oo.int=z0;oo.intHex=Y0;oo.intOct=H0});var rm=$(nm=>{"use strict";var V0=Kn(),G0=ro(),X0=Hn(),Q0=ls(),Z0=kc(),Cc=Ec(),Oc=Tc(),eE=[V0.map,X0.seq,Q0.string,G0.nullTag,Z0.boolTag,Oc.intOct,Oc.int,Oc.intHex,Cc.floatNaN,Cc.floatExp,Cc.float];nm.schema=eE});var om=$(im=>{"use strict";var tE=se(),nE=Kn(),rE=Hn();function sm(t){return typeof t=="bigint"||Number.isInteger(t)}var ao=({value:t})=>JSON.stringify(t),sE=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:ao},{identify:t=>t==null,createNode:()=>new tE.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:sm,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})=>sm(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}],iE={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},oE=[nE.map,rE.seq].concat(sE,iE);im.schema=oE});var _c=$(am=>{"use strict";var cs=Ei("buffer"),Pc=se(),aE=rs(),lE={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof cs.Buffer=="function")return cs.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 cs.Buffer=="function")a=o instanceof cs.Buffer?o.toString("base64"):cs.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=Pc.Scalar.BLOCK_LITERAL),e!==Pc.Scalar.QUOTE_DOUBLE){let l=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),c=Math.ceil(a.length/l),u=new Array(c);for(let d=0,f=0;d<c;++d,f+=l)u[d]=a.substr(f,l);a=u.join(e===Pc.Scalar.BLOCK_LITERAL?`
75
+ `:" ")}return aE.stringifyString({comment:t,type:e,value:a},r,s,i)}};am.binary=lE});var uo=$(co=>{"use strict";var lo=J(),Rc=Nt(),cE=se(),uE=Dt();function lm(t,e){if(lo.isSeq(t))for(let n=0;n<t.items.length;++n){let r=t.items[n];if(!lo.isPair(r)){if(lo.isMap(r)){r.items.length>1&&e("Each pair must have its own sequence indicator");let s=r.items[0]||new Rc.Pair(new cE.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]=lo.isPair(r)?r:new Rc.Pair(r)}}else e("Expected a sequence for this tag");return t}function am(t,e,n){let{replacer:r}=n,s=new rE.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(Rc.createPair(a,l,n))}return s}var sE={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:om,createNode:am};co.createPairs=am;co.pairs=sE;co.resolvePairs=om});var Nc=_($c=>{"use strict";var lm=J(),Ic=_t(),us=Mt(),iE=Dt(),cm=uo(),ln=class t extends iE.YAMLSeq{constructor(){super(),this.add=us.YAMLMap.prototype.add.bind(this),this.delete=us.YAMLMap.prototype.delete.bind(this),this.get=us.YAMLMap.prototype.get.bind(this),this.has=us.YAMLMap.prototype.has.bind(this),this.set=us.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(lm.isPair(s)?(i=Ic.toJS(s.key,"",n),o=Ic.toJS(s.value,i,n)):i=Ic.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=cm.createPairs(e,n,r),i=new this;return i.items=s.items,i}};ln.tag="tag:yaml.org,2002:omap";var oE={collection:"seq",identify:t=>t instanceof Map,nodeClass:ln,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let n=cm.resolvePairs(t,e),r=[];for(let{key:s}of n.items)lm.isScalar(s)&&(r.includes(s.value)?e(`Ordered maps must not include duplicate keys: ${s.value}`):r.push(s.value));return Object.assign(new ln,n)},createNode:(t,e,n)=>ln.from(t,e,n)};$c.YAMLOMap=ln;$c.omap=oE});var hm=_(Lc=>{"use strict";var um=se();function dm({value:t,source:e},n){return e&&(t?fm:pm).test.test(e)?e:t?n.options.trueStr:n.options.falseStr}var fm={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 um.Scalar(!0),stringify:dm},pm={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 um.Scalar(!1),stringify:dm};Lc.falseTag=pm;Lc.trueTag=fm});var mm=_(fo=>{"use strict";var aE=se(),Mc=Yn(),lE={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:Mc.stringifyNumber},cE={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():Mc.stringifyNumber(t)}},uE={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 aE.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:Mc.stringifyNumber};fo.float=uE;fo.floatExp=cE;fo.floatNaN=lE});var ym=_(fs=>{"use strict";var gm=Yn(),ds=t=>typeof t=="bigint"||Number.isInteger(t);function po(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 Dc(t,e,n){let{value:r}=t;if(ds(r)){let s=r.toString(e);return r<0?"-"+n+s.substr(1):n+s}return gm.stringifyNumber(t)}var dE={identify:ds,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,n)=>po(t,2,2,n),stringify:t=>Dc(t,2,"0b")},fE={identify:ds,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,n)=>po(t,1,8,n),stringify:t=>Dc(t,8,"0")},pE={identify:ds,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,n)=>po(t,0,10,n),stringify:gm.stringifyNumber},hE={identify:ds,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,n)=>po(t,2,16,n),stringify:t=>Dc(t,16,"0x")};fs.int=pE;fs.intBin=dE;fs.intHex=hE;fs.intOct=fE});var jc=_(Bc=>{"use strict";var go=J(),ho=Nt(),mo=Mt(),cn=class t extends mo.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let n;go.isPair(e)?n=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?n=new ho.Pair(e.key,null):n=new ho.Pair(e,null),mo.findPair(this.items,n.key)||this.items.push(n)}get(e,n){let r=mo.findPair(this.items,e);return!n&&go.isPair(r)?go.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=mo.findPair(this.items,e);r&&!n?this.items.splice(this.items.indexOf(r),1):!r&&n&&this.items.push(new ho.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(ho.createPair(o,null,r));return i}};cn.tag="tag:yaml.org,2002:set";var mE={collection:"map",identify:t=>t instanceof Set,nodeClass:cn,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,n)=>cn.from(t,e,n),resolve(t,e){if(go.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new cn,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};Bc.YAMLSet=cn;Bc.set=mE});var Uc=_(yo=>{"use strict";var gE=Yn();function Fc(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 bm(t){let{value:e}=t,n=o=>o;if(typeof e=="bigint")n=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return gE.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 yE={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})=>Fc(t,n),stringify:bm},bE={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=>Fc(t,!1),stringify:bm},wm={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(wm.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),u=e[8];if(u&&u!=="Z"){let d=Fc(u,!1);Math.abs(d)<30&&(d*=60),c-=6e4*d}return new Date(c)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};yo.floatTime=bE;yo.intTime=yE;yo.timestamp=wm});var km=_(Sm=>{"use strict";var wE=Hn(),vE=ro(),SE=zn(),kE=ls(),xE=_c(),vm=hm(),qc=mm(),bo=ym(),EE=Vi(),AE=Nc(),TE=uo(),CE=jc(),Jc=Uc(),OE=[wE.map,SE.seq,kE.string,vE.nullTag,vm.trueTag,vm.falseTag,bo.intBin,bo.intOct,bo.int,bo.intHex,qc.floatNaN,qc.floatExp,qc.float,xE.binary,EE.merge,AE.omap,TE.pairs,CE.set,Jc.intTime,Jc.floatTime,Jc.timestamp];Sm.schema=OE});var Im=_(Hc=>{"use strict";var Tm=Hn(),PE=ro(),Cm=zn(),_E=ls(),RE=kc(),Wc=Ec(),Kc=Tc(),IE=tm(),$E=sm(),Om=_c(),ps=Vi(),Pm=Nc(),_m=uo(),xm=km(),Rm=jc(),wo=Uc(),Em=new Map([["core",IE.schema],["failsafe",[Tm.map,Cm.seq,_E.string]],["json",$E.schema],["yaml11",xm.schema],["yaml-1.1",xm.schema]]),Am={binary:Om.binary,bool:RE.boolTag,float:Wc.float,floatExp:Wc.floatExp,floatNaN:Wc.floatNaN,floatTime:wo.floatTime,int:Kc.int,intHex:Kc.intHex,intOct:Kc.intOct,intTime:wo.intTime,map:Tm.map,merge:ps.merge,null:PE.nullTag,omap:Pm.omap,pairs:_m.pairs,seq:Cm.seq,set:Rm.set,timestamp:wo.timestamp},NE={"tag:yaml.org,2002:binary":Om.binary,"tag:yaml.org,2002:merge":ps.merge,"tag:yaml.org,2002:omap":Pm.omap,"tag:yaml.org,2002:pairs":_m.pairs,"tag:yaml.org,2002:set":Rm.set,"tag:yaml.org,2002:timestamp":wo.timestamp};function LE(t,e,n){let r=Em.get(e);if(r&&!t)return n&&!r.includes(ps.merge)?r.concat(ps.merge):r.slice();let s=r;if(!s)if(Array.isArray(t))s=[];else{let i=Array.from(Em.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(ps.merge)),s.reduce((i,o)=>{let a=typeof o=="string"?Am[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(Am).map(u=>JSON.stringify(u)).join(", ");throw new Error(`Unknown custom tag ${l}; use one of ${c}`)}return i.includes(a)||i.push(a),i},[])}Hc.coreKnownTags=NE;Hc.getTags=LE});var Vc=_($m=>{"use strict";var zc=J(),ME=Hn(),DE=zn(),BE=ls(),vo=Im(),jE=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,Yc=class t{constructor({compat:e,customTags:n,merge:r,resolveKnownTags:s,schema:i,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(e)?vo.getTags(e,"compat"):e?vo.getTags(null,e):null,this.name=typeof i=="string"&&i||"core",this.knownTags=s?vo.coreKnownTags:{},this.tags=vo.getTags(n,this.name,r),this.toStringOptions=a??null,Object.defineProperty(this,zc.MAP,{value:ME.map}),Object.defineProperty(this,zc.SCALAR,{value:BE.string}),Object.defineProperty(this,zc.SEQ,{value:DE.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?jE:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};$m.Schema=Yc});var Lm=_(Nm=>{"use strict";var FE=J(),Gc=ss(),hs=es();function UE(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=Gc.createStringifyContext(t,e),{commentString:i}=s.options;if(t.commentBefore){n.length!==1&&n.unshift("");let l=i(t.commentBefore);n.unshift(hs.indentComment(l,""))}let o=!1,a=null;if(t.contents){if(FE.isNode(t.contents)){if(t.contents.spaceBefore&&r&&n.push(""),t.contents.commentBefore){let u=i(t.contents.commentBefore);n.push(hs.indentComment(u,""))}s.forceBlockIndent=!!t.comment,a=t.contents.comment}let l=a?void 0:()=>o=!0,c=Gc.stringify(t.contents,s,()=>a=null,l);a&&(c+=hs.lineComment(c,"",i(a))),(c[0]==="|"||c[0]===">")&&n[n.length-1]==="---"?n[n.length-1]=`--- ${c}`:n.push(c)}else n.push(Gc.stringify(t.contents,s));if(t.directives?.docEnd)if(t.comment){let l=i(t.comment);l.includes(`
77
+ ${i.comment}`:r.comment}r=s}t.items[n]=lo.isPair(r)?r:new Rc.Pair(r)}}else e("Expected a sequence for this tag");return t}function cm(t,e,n){let{replacer:r}=n,s=new uE.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(Rc.createPair(a,l,n))}return s}var dE={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:lm,createNode:cm};co.createPairs=cm;co.pairs=dE;co.resolvePairs=lm});var Nc=$($c=>{"use strict";var um=J(),Ic=_t(),us=Mt(),fE=Dt(),dm=uo(),ln=class t extends fE.YAMLSeq{constructor(){super(),this.add=us.YAMLMap.prototype.add.bind(this),this.delete=us.YAMLMap.prototype.delete.bind(this),this.get=us.YAMLMap.prototype.get.bind(this),this.has=us.YAMLMap.prototype.has.bind(this),this.set=us.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(um.isPair(s)?(i=Ic.toJS(s.key,"",n),o=Ic.toJS(s.value,i,n)):i=Ic.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=dm.createPairs(e,n,r),i=new this;return i.items=s.items,i}};ln.tag="tag:yaml.org,2002:omap";var pE={collection:"seq",identify:t=>t instanceof Map,nodeClass:ln,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let n=dm.resolvePairs(t,e),r=[];for(let{key:s}of n.items)um.isScalar(s)&&(r.includes(s.value)?e(`Ordered maps must not include duplicate keys: ${s.value}`):r.push(s.value));return Object.assign(new ln,n)},createNode:(t,e,n)=>ln.from(t,e,n)};$c.YAMLOMap=ln;$c.omap=pE});var gm=$(Lc=>{"use strict";var fm=se();function pm({value:t,source:e},n){return e&&(t?hm:mm).test.test(e)?e:t?n.options.trueStr:n.options.falseStr}var hm={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 fm.Scalar(!0),stringify:pm},mm={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 fm.Scalar(!1),stringify:pm};Lc.falseTag=mm;Lc.trueTag=hm});var ym=$(fo=>{"use strict";var hE=se(),Mc=zn(),mE={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:Mc.stringifyNumber},gE={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():Mc.stringifyNumber(t)}},yE={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 hE.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:Mc.stringifyNumber};fo.float=yE;fo.floatExp=gE;fo.floatNaN=mE});var wm=$(fs=>{"use strict";var bm=zn(),ds=t=>typeof t=="bigint"||Number.isInteger(t);function po(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 Dc(t,e,n){let{value:r}=t;if(ds(r)){let s=r.toString(e);return r<0?"-"+n+s.substr(1):n+s}return bm.stringifyNumber(t)}var bE={identify:ds,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,n)=>po(t,2,2,n),stringify:t=>Dc(t,2,"0b")},wE={identify:ds,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,n)=>po(t,1,8,n),stringify:t=>Dc(t,8,"0")},vE={identify:ds,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,n)=>po(t,0,10,n),stringify:bm.stringifyNumber},SE={identify:ds,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,n)=>po(t,2,16,n),stringify:t=>Dc(t,16,"0x")};fs.int=vE;fs.intBin=bE;fs.intHex=SE;fs.intOct=wE});var jc=$(Bc=>{"use strict";var go=J(),ho=Nt(),mo=Mt(),cn=class t extends mo.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let n;go.isPair(e)?n=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?n=new ho.Pair(e.key,null):n=new ho.Pair(e,null),mo.findPair(this.items,n.key)||this.items.push(n)}get(e,n){let r=mo.findPair(this.items,e);return!n&&go.isPair(r)?go.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=mo.findPair(this.items,e);r&&!n?this.items.splice(this.items.indexOf(r),1):!r&&n&&this.items.push(new ho.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(ho.createPair(o,null,r));return i}};cn.tag="tag:yaml.org,2002:set";var kE={collection:"map",identify:t=>t instanceof Set,nodeClass:cn,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,n)=>cn.from(t,e,n),resolve(t,e){if(go.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new cn,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};Bc.YAMLSet=cn;Bc.set=kE});var Uc=$(yo=>{"use strict";var xE=zn();function Fc(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 vm(t){let{value:e}=t,n=o=>o;if(typeof e=="bigint")n=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return xE.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 EE={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})=>Fc(t,n),stringify:vm},AE={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=>Fc(t,!1),stringify:vm},Sm={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(Sm.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),u=e[8];if(u&&u!=="Z"){let d=Fc(u,!1);Math.abs(d)<30&&(d*=60),c-=6e4*d}return new Date(c)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};yo.floatTime=AE;yo.intTime=EE;yo.timestamp=Sm});var Em=$(xm=>{"use strict";var TE=Kn(),CE=ro(),OE=Hn(),PE=ls(),_E=_c(),km=gm(),qc=ym(),bo=wm(),RE=Vi(),IE=Nc(),$E=uo(),NE=jc(),Jc=Uc(),LE=[TE.map,OE.seq,PE.string,CE.nullTag,km.trueTag,km.falseTag,bo.intBin,bo.intOct,bo.int,bo.intHex,qc.floatNaN,qc.floatExp,qc.float,_E.binary,RE.merge,IE.omap,$E.pairs,NE.set,Jc.intTime,Jc.floatTime,Jc.timestamp];xm.schema=LE});var Nm=$(Hc=>{"use strict";var Om=Kn(),ME=ro(),Pm=Hn(),DE=ls(),BE=kc(),Wc=Ec(),Kc=Tc(),jE=rm(),FE=om(),_m=_c(),ps=Vi(),Rm=Nc(),Im=uo(),Am=Em(),$m=jc(),wo=Uc(),Tm=new Map([["core",jE.schema],["failsafe",[Om.map,Pm.seq,DE.string]],["json",FE.schema],["yaml11",Am.schema],["yaml-1.1",Am.schema]]),Cm={binary:_m.binary,bool:BE.boolTag,float:Wc.float,floatExp:Wc.floatExp,floatNaN:Wc.floatNaN,floatTime:wo.floatTime,int:Kc.int,intHex:Kc.intHex,intOct:Kc.intOct,intTime:wo.intTime,map:Om.map,merge:ps.merge,null:ME.nullTag,omap:Rm.omap,pairs:Im.pairs,seq:Pm.seq,set:$m.set,timestamp:wo.timestamp},UE={"tag:yaml.org,2002:binary":_m.binary,"tag:yaml.org,2002:merge":ps.merge,"tag:yaml.org,2002:omap":Rm.omap,"tag:yaml.org,2002:pairs":Im.pairs,"tag:yaml.org,2002:set":$m.set,"tag:yaml.org,2002:timestamp":wo.timestamp};function qE(t,e,n){let r=Tm.get(e);if(r&&!t)return n&&!r.includes(ps.merge)?r.concat(ps.merge):r.slice();let s=r;if(!s)if(Array.isArray(t))s=[];else{let i=Array.from(Tm.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(ps.merge)),s.reduce((i,o)=>{let a=typeof o=="string"?Cm[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(Cm).map(u=>JSON.stringify(u)).join(", ");throw new Error(`Unknown custom tag ${l}; use one of ${c}`)}return i.includes(a)||i.push(a),i},[])}Hc.coreKnownTags=UE;Hc.getTags=qE});var Vc=$(Lm=>{"use strict";var zc=J(),JE=Kn(),WE=Hn(),KE=ls(),vo=Nm(),HE=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,Yc=class t{constructor({compat:e,customTags:n,merge:r,resolveKnownTags:s,schema:i,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(e)?vo.getTags(e,"compat"):e?vo.getTags(null,e):null,this.name=typeof i=="string"&&i||"core",this.knownTags=s?vo.coreKnownTags:{},this.tags=vo.getTags(n,this.name,r),this.toStringOptions=a??null,Object.defineProperty(this,zc.MAP,{value:JE.map}),Object.defineProperty(this,zc.SCALAR,{value:KE.string}),Object.defineProperty(this,zc.SEQ,{value:WE.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?HE:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};Lm.Schema=Yc});var Dm=$(Mm=>{"use strict";var zE=J(),Gc=ss(),hs=es();function YE(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=Gc.createStringifyContext(t,e),{commentString:i}=s.options;if(t.commentBefore){n.length!==1&&n.unshift("");let l=i(t.commentBefore);n.unshift(hs.indentComment(l,""))}let o=!1,a=null;if(t.contents){if(zE.isNode(t.contents)){if(t.contents.spaceBefore&&r&&n.push(""),t.contents.commentBefore){let u=i(t.contents.commentBefore);n.push(hs.indentComment(u,""))}s.forceBlockIndent=!!t.comment,a=t.contents.comment}let l=a?void 0:()=>o=!0,c=Gc.stringify(t.contents,s,()=>a=null,l);a&&(c+=hs.lineComment(c,"",i(a))),(c[0]==="|"||c[0]===">")&&n[n.length-1]==="---"?n[n.length-1]=`--- ${c}`:n.push(c)}else n.push(Gc.stringify(t.contents,s));if(t.directives?.docEnd)if(t.comment){let l=i(t.comment);l.includes(`
78
78
  `)?(n.push("..."),n.push(hs.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(hs.indentComment(i(l),"")))}return n.join(`
79
79
  `)+`
80
- `}Nm.stringifyDocument=UE});var ms=_(Mm=>{"use strict";var qE=Qr(),Vn=Fi(),Me=J(),JE=Nt(),WE=_t(),KE=Vc(),HE=Lm(),Xc=Mi(),zE=tc(),YE=Zr(),Qc=ec(),Zc=class t{constructor(e,n,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Me.NODE_TYPE,{value:Me.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 Qc.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,{[Me.NODE_TYPE]:{value:Me.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=Me.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){Gn(this.contents)&&this.contents.add(e)}addIn(e,n){Gn(this.contents)&&this.contents.addIn(e,n)}createAlias(e,n){if(!e.anchor){let r=Xc.anchorNames(this);e.anchor=!n||r.has(n)?Xc.findNewAnchor(n||"a",r):n}return new qE.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=A=>typeof A=="number"||A instanceof String||A instanceof Number,v=n.filter(g).map(String);v.length>0&&(n=n.concat(v)),s=n}else r===void 0&&n&&(r=n,n=void 0);let{aliasDuplicateObjects:i,anchorPrefix:o,flow:a,keepUndefined:l,onTagObj:c,tag:u}=r??{},{onAnchor:d,setAnchors:f,sourceObjects:p}=Xc.createNodeAnchors(this,o||"a"),h={aliasDuplicateObjects:i??!0,keepUndefined:l??!1,onAnchor:d,onTagObj:c,replacer:s,schema:this.schema,sourceObjects:p},m=YE.createNode(e,u,h);return a&&Me.isCollection(m)&&(m.flow=!0),f(),m}createPair(e,n,r={}){let s=this.createNode(e,null,r),i=this.createNode(n,null,r);return new JE.Pair(s,i)}delete(e){return Gn(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Vn.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):Gn(this.contents)?this.contents.deleteIn(e):!1}get(e,n){return Me.isCollection(this.contents)?this.contents.get(e,n):void 0}getIn(e,n){return Vn.isEmptyPath(e)?!n&&Me.isScalar(this.contents)?this.contents.value:this.contents:Me.isCollection(this.contents)?this.contents.getIn(e,n):void 0}has(e){return Me.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return Vn.isEmptyPath(e)?this.contents!==void 0:Me.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,n){this.contents==null?this.contents=Vn.collectionFromPath(this.schema,[e],n):Gn(this.contents)&&this.contents.set(e,n)}setIn(e,n){Vn.isEmptyPath(e)?this.contents=n:this.contents==null?this.contents=Vn.collectionFromPath(this.schema,Array.from(e),n):Gn(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 Qc.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 Qc.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 KE.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=WE.toJS(this.contents,n??"",a);if(typeof i=="function")for(let{count:c,res:u}of a.anchors.values())i(u,c);return typeof o=="function"?zE.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 HE.stringifyDocument(this,e)}};function Gn(t){if(Me.isCollection(t))return!0;throw new Error("Expected a YAML collection as document contents")}Mm.Document=Zc});var bs=_(ys=>{"use strict";var gs=class extends Error{constructor(e,n,r,s){super(),this.name=e,this.code=r,this.message=s,this.pos=n}},eu=class extends gs{constructor(e,n,r){super("YAMLParseError",e,n,r)}},tu=class extends gs{constructor(e,n,r){super("YAMLWarning",e,n,r)}},VE=(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
80
+ `}Mm.stringifyDocument=YE});var ms=$(Bm=>{"use strict";var VE=Qr(),Yn=Fi(),Me=J(),GE=Nt(),XE=_t(),QE=Vc(),ZE=Dm(),Xc=Mi(),eA=tc(),tA=Zr(),Qc=ec(),Zc=class t{constructor(e,n,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Me.NODE_TYPE,{value:Me.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 Qc.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,{[Me.NODE_TYPE]:{value:Me.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=Me.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){Vn(this.contents)&&this.contents.add(e)}addIn(e,n){Vn(this.contents)&&this.contents.addIn(e,n)}createAlias(e,n){if(!e.anchor){let r=Xc.anchorNames(this);e.anchor=!n||r.has(n)?Xc.findNewAnchor(n||"a",r):n}return new VE.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 y=T=>typeof T=="number"||T instanceof String||T instanceof Number,k=n.filter(y).map(String);k.length>0&&(n=n.concat(k)),s=n}else r===void 0&&n&&(r=n,n=void 0);let{aliasDuplicateObjects:i,anchorPrefix:o,flow:a,keepUndefined:l,onTagObj:c,tag:u}=r??{},{onAnchor:d,setAnchors:f,sourceObjects:p}=Xc.createNodeAnchors(this,o||"a"),m={aliasDuplicateObjects:i??!0,keepUndefined:l??!1,onAnchor:d,onTagObj:c,replacer:s,schema:this.schema,sourceObjects:p},h=tA.createNode(e,u,m);return a&&Me.isCollection(h)&&(h.flow=!0),f(),h}createPair(e,n,r={}){let s=this.createNode(e,null,r),i=this.createNode(n,null,r);return new GE.Pair(s,i)}delete(e){return Vn(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Yn.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):Vn(this.contents)?this.contents.deleteIn(e):!1}get(e,n){return Me.isCollection(this.contents)?this.contents.get(e,n):void 0}getIn(e,n){return Yn.isEmptyPath(e)?!n&&Me.isScalar(this.contents)?this.contents.value:this.contents:Me.isCollection(this.contents)?this.contents.getIn(e,n):void 0}has(e){return Me.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return Yn.isEmptyPath(e)?this.contents!==void 0:Me.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,n){this.contents==null?this.contents=Yn.collectionFromPath(this.schema,[e],n):Vn(this.contents)&&this.contents.set(e,n)}setIn(e,n){Yn.isEmptyPath(e)?this.contents=n:this.contents==null?this.contents=Yn.collectionFromPath(this.schema,Array.from(e),n):Vn(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 Qc.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 Qc.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 QE.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=XE.toJS(this.contents,n??"",a);if(typeof i=="function")for(let{count:c,res:u}of a.anchors.values())i(u,c);return typeof o=="function"?eA.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 ZE.stringifyDocument(this,e)}};function Vn(t){if(Me.isCollection(t))return!0;throw new Error("Expected a YAML collection as document contents")}Bm.Document=Zc});var bs=$(ys=>{"use strict";var gs=class extends Error{constructor(e,n,r,s){super(),this.name=e,this.code=r,this.message=s,this.pos=n}},eu=class extends gs{constructor(e,n,r){super("YAMLParseError",e,n,r)}},tu=class extends gs{constructor(e,n,r){super("YAMLWarning",e,n,r)}},nA=(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
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+=`:
82
82
 
83
83
  ${o}
84
84
  ${c}
85
- `}};ys.YAMLError=gs;ys.YAMLParseError=eu;ys.YAMLWarning=tu;ys.prettifyError=VE});var ws=_(Dm=>{"use strict";function GE(t,{flow:e,indicator:n,next:r,offset:s,onError:i,parentIndent:o,startOnNewline:a}){let l=!1,c=a,u=a,d="",f="",p=!1,h=!1,m=null,g=null,v=null,A=null,C=null,x=null,R=null;for(let T of t)switch(h&&(T.type!=="space"&&T.type!=="newline"&&T.type!=="comma"&&i(T.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),h=!1),m&&(c&&T.type!=="comment"&&T.type!=="newline"&&i(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),m=null),T.type){case"space":!e&&(n!=="doc-start"||r?.type!=="flow-collection")&&T.source.includes(" ")&&(m=T),u=!0;break;case"comment":{u||i(T,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let F=T.source.substring(1)||" ";d?d+=f+F:d=F,f="",c=!1;break}case"newline":c?d?d+=T.source:(!x||n!=="seq-item-ind")&&(l=!0):f+=T.source,c=!0,p=!0,(g||v)&&(A=T),u=!0;break;case"anchor":g&&i(T,"MULTIPLE_ANCHORS","A node can have at most one anchor"),T.source.endsWith(":")&&i(T.offset+T.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),g=T,R??(R=T.offset),c=!1,u=!1,h=!0;break;case"tag":{v&&i(T,"MULTIPLE_TAGS","A node can have at most one tag"),v=T,R??(R=T.offset),c=!1,u=!1,h=!0;break}case n:(g||v)&&i(T,"BAD_PROP_ORDER",`Anchors and tags must be after the ${T.source} indicator`),x&&i(T,"UNEXPECTED_TOKEN",`Unexpected ${T.source} in ${e??"collection"}`),x=T,c=n==="seq-item-ind"||n==="explicit-key-ind",u=!1;break;case"comma":if(e){C&&i(T,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),C=T,c=!1,u=!1;break}default:i(T,"UNEXPECTED_TOKEN",`Unexpected ${T.type} token`),c=!1,u=!1}let I=t[t.length-1],L=I?I.offset+I.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:C,found:x,spaceBefore:l,comment:d,hasNewline:p,anchor:g,tag:v,newlineAfterProp:A,end:L,start:R??L}}Dm.resolveProps=GE});var So=_(Bm=>{"use strict";function nu(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(nu(e.key)||nu(e.value))return!0}return!1;default:return!0}}Bm.containsNewline=nu});var ru=_(jm=>{"use strict";var XE=So();function QE(t,e,n){if(e?.type==="flow-collection"){let r=e.end[0];r.indent===t&&(r.source==="]"||r.source==="}")&&XE.containsNewline(e)&&n(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}jm.flowIndentCheck=QE});var su=_(Um=>{"use strict";var Fm=J();function ZE(t,e,n){let{uniqueKeys:r}=t.options;if(r===!1)return!1;let s=typeof r=="function"?r:(i,o)=>i===o||Fm.isScalar(i)&&Fm.isScalar(o)&&i.value===o.value;return e.some(i=>s(i.key,n))}Um.mapIncludes=ZE});var zm=_(Hm=>{"use strict";var qm=Nt(),eA=Mt(),Jm=ws(),tA=So(),Wm=ru(),nA=su(),Km="All mapping items must start at the same column";function rA({composeNode:t,composeEmptyNode:e},n,r,s,i){let o=i?.nodeClass??eA.YAMLMap,a=new o(n.schema);n.atRoot&&(n.atRoot=!1);let l=r.offset,c=null;for(let u of r.items){let{start:d,key:f,sep:p,value:h}=u,m=Jm.resolveProps(d,{indicator:"explicit-key-ind",next:f??p?.[0],offset:l,onError:s,parentIndent:r.indent,startOnNewline:!0}),g=!m.found;if(g){if(f&&(f.type==="block-seq"?s(l,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in f&&f.indent!==r.indent&&s(l,"BAD_INDENT",Km)),!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(f))&&s(f??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",Km);n.atKey=!0;let v=m.end,A=f?t(n,f,m,s):e(n,v,d,null,m,s);n.schema.compat&&Wm.flowIndentCheck(r.indent,f,s),n.atKey=!1,nA.mapIncludes(n,a.items,A)&&s(v,"DUPLICATE_KEY","Map keys must be unique");let C=Jm.resolveProps(p??[],{indicator:"map-value-ind",next:h,offset:A.range[2],onError:s,parentIndent:r.indent,startOnNewline:!f||f.type==="block-scalar"});if(l=C.end,C.found){g&&(h?.type==="block-map"&&!C.hasNewline&&s(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),n.options.strict&&m.start<C.found.offset-1024&&s(A.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let x=h?t(n,h,C,s):e(n,l,p,null,C,s);n.schema.compat&&Wm.flowIndentCheck(r.indent,h,s),l=x.range[2];let R=new qm.Pair(A,x);n.options.keepSourceTokens&&(R.srcToken=u),a.items.push(R)}else{g&&s(A.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),C.comment&&(A.comment?A.comment+=`
88
- `+C.comment:A.comment=C.comment);let x=new qm.Pair(A);n.options.keepSourceTokens&&(x.srcToken=u),a.items.push(x)}}return c&&c<l&&s(c,"IMPOSSIBLE","Map comment with trailing content"),a.range=[r.offset,l,c??l],a}Hm.resolveBlockMap=rA});var Vm=_(Ym=>{"use strict";var sA=Dt(),iA=ws(),oA=ru();function aA({composeNode:t,composeEmptyNode:e},n,r,s,i){let o=i?.nodeClass??sA.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:u,value:d}of r.items){let f=iA.resolveProps(u,{indicator:"seq-item-ind",next:d,offset:l,onError:s,parentIndent:r.indent,startOnNewline:!0});if(!f.found)if(f.anchor||f.tag||d)d?.type==="block-seq"?s(f.end,"BAD_INDENT","All sequence items must start at the same column"):s(l,"MISSING_CHAR","Sequence item without - indicator");else{c=f.end,f.comment&&(a.comment=f.comment);continue}let p=d?t(n,d,f,s):e(n,f.end,u,null,f,s);n.schema.compat&&oA.flowIndentCheck(r.indent,d,s),l=p.range[2],a.items.push(p)}return a.range=[r.offset,l,c??l],a}Ym.resolveBlockSeq=aA});var Xn=_(Gm=>{"use strict";function lA(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 u=l.substring(1)||" ";s?s+=o+u:s=u,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}}Gm.resolveEnd=lA});var eg=_(Zm=>{"use strict";var cA=J(),uA=Nt(),Xm=Mt(),dA=Dt(),fA=Xn(),Qm=ws(),pA=So(),hA=su(),iu="Block collections are not allowed within flow collections",ou=t=>t&&(t.type==="block-map"||t.type==="block-seq");function mA({composeNode:t,composeEmptyNode:e},n,r,s,i){let o=r.start.source==="{",a=o?"flow map":"flow sequence",l=i?.nodeClass??(o?Xm.YAMLMap:dA.YAMLSeq),c=new l(n.schema);c.flow=!0;let u=n.atRoot;u&&(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 v=r.items[g],{start:A,key:C,sep:x,value:R}=v,I=Qm.resolveProps(A,{flow:a,indicator:"explicit-key-ind",next:C??x?.[0],offset:d,onError:s,parentIndent:r.indent,startOnNewline:!1});if(!I.found){if(!I.anchor&&!I.tag&&!x&&!R){g===0&&I.comma?s(I.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):g<r.items.length-1&&s(I.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),I.comment&&(c.comment?c.comment+=`
89
- `+I.comment:c.comment=I.comment),d=I.end;continue}!o&&n.options.strict&&pA.containsNewline(C)&&s(C,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(g===0)I.comma&&s(I.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(I.comma||s(I.start,"MISSING_CHAR",`Missing , between ${a} items`),I.comment){let L="";e:for(let T of A)switch(T.type){case"comma":case"space":break;case"comment":L=T.source.substring(1);break e;default:break e}if(L){let T=c.items[c.items.length-1];cA.isPair(T)&&(T=T.value??T.key),T.comment?T.comment+=`
90
- `+L:T.comment=L,I.comment=I.comment.substring(L.length+1)}}if(!o&&!x&&!I.found){let L=R?t(n,R,I,s):e(n,I.end,x,null,I,s);c.items.push(L),d=L.range[2],ou(R)&&s(L.range,"BLOCK_IN_FLOW",iu)}else{n.atKey=!0;let L=I.end,T=C?t(n,C,I,s):e(n,L,A,null,I,s);ou(C)&&s(T.range,"BLOCK_IN_FLOW",iu),n.atKey=!1;let F=Qm.resolveProps(x??[],{flow:a,indicator:"map-value-ind",next:R,offset:T.range[2],onError:s,parentIndent:r.indent,startOnNewline:!1});if(F.found){if(!o&&!I.found&&n.options.strict){if(x)for(let U of x){if(U===F.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}}I.start<F.found.offset-1024&&s(F.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(F.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let H=R?t(n,R,F,s):F.found?e(n,F.end,x,null,F,s):null;H?ou(R)&&s(H.range,"BLOCK_IN_FLOW",iu):F.comment&&(T.comment?T.comment+=`
91
- `+F.comment:T.comment=F.comment);let ne=new uA.Pair(T,H);if(n.options.keepSourceTokens&&(ne.srcToken=v),o){let U=c;hA.mapIncludes(n,U.items,T)&&s(L,"DUPLICATE_KEY","Map keys must be unique"),U.items.push(ne)}else{let U=new Xm.YAMLMap(n.schema);U.flow=!0,U.items.push(ne);let re=(H??T).range;U.range=[T.range[0],re[1],re[2]],c.items.push(U)}d=H?H.range[2]:F.end}}let f=o?"}":"]",[p,...h]=r.end,m=d;if(p?.source===f)m=p.offset+p.source.length;else{let g=a[0].toUpperCase()+a.substring(1),v=u?`${g} must end with a ${f}`:`${g} in block collection must be sufficiently indented and end with a ${f}`;s(d,u?"MISSING_CHAR":"BAD_INDENT",v),p&&p.source.length!==1&&h.unshift(p)}if(h.length>0){let g=fA.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}Zm.resolveFlowCollection=mA});var ng=_(tg=>{"use strict";var gA=J(),yA=se(),bA=Mt(),wA=Dt(),vA=zm(),SA=Vm(),kA=eg();function au(t,e,n,r,s,i){let o=n.type==="block-map"?vA.resolveBlockMap(t,e,n,r,i):n.type==="block-seq"?SA.resolveBlockSeq(t,e,n,r,i):kA.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 xA(t,e,n,r,s){let i=r.tag,o=i?e.directives.tagName(i.source,f=>s(i,"TAG_RESOLVE_FAILED",f)):null;if(n.type==="block-seq"){let{anchor:f,newlineAfterProp:p}=r,h=f&&i?f.offset>i.offset?f:i:f??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===bA.YAMLMap.tagName&&a==="map"||o===wA.YAMLSeq.tagName&&a==="seq")return au(t,e,n,s,o);let l=e.schema.tags.find(f=>f.tag===o&&f.collection===a);if(!l){let f=e.schema.knownTags[o];if(f?.collection===a)e.schema.tags.push(Object.assign({},f,{default:!1})),l=f;else return f?s(i,"BAD_COLLECTION_TYPE",`${f.tag} used for ${a} collection, but expects ${f.collection??"scalar"}`,!0):s(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),au(t,e,n,s,o)}let c=au(t,e,n,s,o,l),u=l.resolve?.(c,f=>s(i,"TAG_RESOLVE_FAILED",f),e.options)??c,d=gA.isNode(u)?u:new yA.Scalar(u);return d.range=c.range,d.tag=o,l?.format&&(d.format=l.format),d}tg.composeCollection=xA});var cu=_(rg=>{"use strict";var lu=se();function EA(t,e,n){let r=e.offset,s=AA(e,t.options.strict,n);if(!s)return{value:"",type:null,comment:"",range:[r,r,r]};let i=s.mode===">"?lu.Scalar.BLOCK_FOLDED:lu.Scalar.BLOCK_LITERAL,o=e.source?TA(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,u=0;for(let m=0;m<a;++m){let[g,v]=o[m];if(v===""||v==="\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),u=m,l===0&&!t.atRoot&&n(c,"BAD_INDENT","Block scalar values in collections must be indented");break}c+=g.length+v.length+1}for(let m=o.length-1;m>=a;--m)o[m][0].length>l&&(a=m+1);let d="",f="",p=!1;for(let m=0;m<u;++m)d+=o[m][0].slice(l)+`
94
- `;for(let m=u;m<a;++m){let[g,v]=o[m];c+=g.length+v.length+1;let A=v[v.length-1]==="\r";if(A&&(v=v.slice(0,-1)),v&&g.length<l){let x=`Block scalar lines must not be less indented than their ${s.indent?"explicit indentation indicator":"first line"}`;n(c-v.length-(A?2:1),"BAD_INDENT",x),g=""}i===lu.Scalar.BLOCK_LITERAL?(d+=f+g.slice(l)+v,f=`
95
- `):g.length>l||v[0]===" "?(f===" "?f=`
85
+ `}};ys.YAMLError=gs;ys.YAMLParseError=eu;ys.YAMLWarning=tu;ys.prettifyError=nA});var ws=$(jm=>{"use strict";function rA(t,{flow:e,indicator:n,next:r,offset:s,onError:i,parentIndent:o,startOnNewline:a}){let l=!1,c=a,u=a,d="",f="",p=!1,m=!1,h=null,y=null,k=null,T=null,P=null,E=null,O=null;for(let A of t)switch(m&&(A.type!=="space"&&A.type!=="newline"&&A.type!=="comma"&&i(A.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m=!1),h&&(c&&A.type!=="comment"&&A.type!=="newline"&&i(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),h=null),A.type){case"space":!e&&(n!=="doc-start"||r?.type!=="flow-collection")&&A.source.includes(" ")&&(h=A),u=!0;break;case"comment":{u||i(A,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let M=A.source.substring(1)||" ";d?d+=f+M:d=M,f="",c=!1;break}case"newline":c?d?d+=A.source:(!E||n!=="seq-item-ind")&&(l=!0):f+=A.source,c=!0,p=!0,(y||k)&&(T=A),u=!0;break;case"anchor":y&&i(A,"MULTIPLE_ANCHORS","A node can have at most one anchor"),A.source.endsWith(":")&&i(A.offset+A.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),y=A,O??(O=A.offset),c=!1,u=!1,m=!0;break;case"tag":{k&&i(A,"MULTIPLE_TAGS","A node can have at most one tag"),k=A,O??(O=A.offset),c=!1,u=!1,m=!0;break}case n:(y||k)&&i(A,"BAD_PROP_ORDER",`Anchors and tags must be after the ${A.source} indicator`),E&&i(A,"UNEXPECTED_TOKEN",`Unexpected ${A.source} in ${e??"collection"}`),E=A,c=n==="seq-item-ind"||n==="explicit-key-ind",u=!1;break;case"comma":if(e){P&&i(A,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),P=A,c=!1,u=!1;break}default:i(A,"UNEXPECTED_TOKEN",`Unexpected ${A.type} token`),c=!1,u=!1}let _=t[t.length-1],I=_?_.offset+_.source.length:s;return m&&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"),h&&(c&&h.indent<=o||r?.type==="block-map"||r?.type==="block-seq")&&i(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:P,found:E,spaceBefore:l,comment:d,hasNewline:p,anchor:y,tag:k,newlineAfterProp:T,end:I,start:O??I}}jm.resolveProps=rA});var So=$(Fm=>{"use strict";function nu(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(nu(e.key)||nu(e.value))return!0}return!1;default:return!0}}Fm.containsNewline=nu});var ru=$(Um=>{"use strict";var sA=So();function iA(t,e,n){if(e?.type==="flow-collection"){let r=e.end[0];r.indent===t&&(r.source==="]"||r.source==="}")&&sA.containsNewline(e)&&n(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}Um.flowIndentCheck=iA});var su=$(Jm=>{"use strict";var qm=J();function oA(t,e,n){let{uniqueKeys:r}=t.options;if(r===!1)return!1;let s=typeof r=="function"?r:(i,o)=>i===o||qm.isScalar(i)&&qm.isScalar(o)&&i.value===o.value;return e.some(i=>s(i.key,n))}Jm.mapIncludes=oA});var Vm=$(Ym=>{"use strict";var Wm=Nt(),aA=Mt(),Km=ws(),lA=So(),Hm=ru(),cA=su(),zm="All mapping items must start at the same column";function uA({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 u of r.items){let{start:d,key:f,sep:p,value:m}=u,h=Km.resolveProps(d,{indicator:"explicit-key-ind",next:f??p?.[0],offset:l,onError:s,parentIndent:r.indent,startOnNewline:!0}),y=!h.found;if(y){if(f&&(f.type==="block-seq"?s(l,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in f&&f.indent!==r.indent&&s(l,"BAD_INDENT",zm)),!h.anchor&&!h.tag&&!p){c=h.end,h.comment&&(a.comment?a.comment+=`
87
+ `+h.comment:a.comment=h.comment);continue}(h.newlineAfterProp||lA.containsNewline(f))&&s(f??d[d.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else h.found?.indent!==r.indent&&s(l,"BAD_INDENT",zm);n.atKey=!0;let k=h.end,T=f?t(n,f,h,s):e(n,k,d,null,h,s);n.schema.compat&&Hm.flowIndentCheck(r.indent,f,s),n.atKey=!1,cA.mapIncludes(n,a.items,T)&&s(k,"DUPLICATE_KEY","Map keys must be unique");let P=Km.resolveProps(p??[],{indicator:"map-value-ind",next:m,offset:T.range[2],onError:s,parentIndent:r.indent,startOnNewline:!f||f.type==="block-scalar"});if(l=P.end,P.found){y&&(m?.type==="block-map"&&!P.hasNewline&&s(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),n.options.strict&&h.start<P.found.offset-1024&&s(T.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let E=m?t(n,m,P,s):e(n,l,p,null,P,s);n.schema.compat&&Hm.flowIndentCheck(r.indent,m,s),l=E.range[2];let O=new Wm.Pair(T,E);n.options.keepSourceTokens&&(O.srcToken=u),a.items.push(O)}else{y&&s(T.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),P.comment&&(T.comment?T.comment+=`
88
+ `+P.comment:T.comment=P.comment);let E=new Wm.Pair(T);n.options.keepSourceTokens&&(E.srcToken=u),a.items.push(E)}}return c&&c<l&&s(c,"IMPOSSIBLE","Map comment with trailing content"),a.range=[r.offset,l,c??l],a}Ym.resolveBlockMap=uA});var Xm=$(Gm=>{"use strict";var dA=Dt(),fA=ws(),pA=ru();function hA({composeNode:t,composeEmptyNode:e},n,r,s,i){let o=i?.nodeClass??dA.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:u,value:d}of r.items){let f=fA.resolveProps(u,{indicator:"seq-item-ind",next:d,offset:l,onError:s,parentIndent:r.indent,startOnNewline:!0});if(!f.found)if(f.anchor||f.tag||d)d?.type==="block-seq"?s(f.end,"BAD_INDENT","All sequence items must start at the same column"):s(l,"MISSING_CHAR","Sequence item without - indicator");else{c=f.end,f.comment&&(a.comment=f.comment);continue}let p=d?t(n,d,f,s):e(n,f.end,u,null,f,s);n.schema.compat&&pA.flowIndentCheck(r.indent,d,s),l=p.range[2],a.items.push(p)}return a.range=[r.offset,l,c??l],a}Gm.resolveBlockSeq=hA});var Gn=$(Qm=>{"use strict";function mA(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 u=l.substring(1)||" ";s?s+=o+u:s=u,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}}Qm.resolveEnd=mA});var ng=$(tg=>{"use strict";var gA=J(),yA=Nt(),Zm=Mt(),bA=Dt(),wA=Gn(),eg=ws(),vA=So(),SA=su(),iu="Block collections are not allowed within flow collections",ou=t=>t&&(t.type==="block-map"||t.type==="block-seq");function kA({composeNode:t,composeEmptyNode:e},n,r,s,i){let o=r.start.source==="{",a=o?"flow map":"flow sequence",l=i?.nodeClass??(o?Zm.YAMLMap:bA.YAMLSeq),c=new l(n.schema);c.flow=!0;let u=n.atRoot;u&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let d=r.offset+r.start.source.length;for(let y=0;y<r.items.length;++y){let k=r.items[y],{start:T,key:P,sep:E,value:O}=k,_=eg.resolveProps(T,{flow:a,indicator:"explicit-key-ind",next:P??E?.[0],offset:d,onError:s,parentIndent:r.indent,startOnNewline:!1});if(!_.found){if(!_.anchor&&!_.tag&&!E&&!O){y===0&&_.comma?s(_.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):y<r.items.length-1&&s(_.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),_.comment&&(c.comment?c.comment+=`
89
+ `+_.comment:c.comment=_.comment),d=_.end;continue}!o&&n.options.strict&&vA.containsNewline(P)&&s(P,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(y===0)_.comma&&s(_.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(_.comma||s(_.start,"MISSING_CHAR",`Missing , between ${a} items`),_.comment){let I="";e:for(let A of T)switch(A.type){case"comma":case"space":break;case"comment":I=A.source.substring(1);break e;default:break e}if(I){let A=c.items[c.items.length-1];gA.isPair(A)&&(A=A.value??A.key),A.comment?A.comment+=`
90
+ `+I:A.comment=I,_.comment=_.comment.substring(I.length+1)}}if(!o&&!E&&!_.found){let I=O?t(n,O,_,s):e(n,_.end,E,null,_,s);c.items.push(I),d=I.range[2],ou(O)&&s(I.range,"BLOCK_IN_FLOW",iu)}else{n.atKey=!0;let I=_.end,A=P?t(n,P,_,s):e(n,I,T,null,_,s);ou(P)&&s(A.range,"BLOCK_IN_FLOW",iu),n.atKey=!1;let M=eg.resolveProps(E??[],{flow:a,indicator:"map-value-ind",next:O,offset:A.range[2],onError:s,parentIndent:r.indent,startOnNewline:!1});if(M.found){if(!o&&!_.found&&n.options.strict){if(E)for(let U of E){if(U===M.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}}_.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 O&&("source"in O&&O.source?.[0]===":"?s(O,"MISSING_CHAR",`Missing space after : in ${a}`):s(M.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let K=O?t(n,O,M,s):M.found?e(n,M.end,E,null,M,s):null;K?ou(O)&&s(K.range,"BLOCK_IN_FLOW",iu):M.comment&&(A.comment?A.comment+=`
91
+ `+M.comment:A.comment=M.comment);let ne=new yA.Pair(A,K);if(n.options.keepSourceTokens&&(ne.srcToken=k),o){let U=c;SA.mapIncludes(n,U.items,A)&&s(I,"DUPLICATE_KEY","Map keys must be unique"),U.items.push(ne)}else{let U=new Zm.YAMLMap(n.schema);U.flow=!0,U.items.push(ne);let re=(K??A).range;U.range=[A.range[0],re[1],re[2]],c.items.push(U)}d=K?K.range[2]:M.end}}let f=o?"}":"]",[p,...m]=r.end,h=d;if(p?.source===f)h=p.offset+p.source.length;else{let y=a[0].toUpperCase()+a.substring(1),k=u?`${y} must end with a ${f}`:`${y} in block collection must be sufficiently indented and end with a ${f}`;s(d,u?"MISSING_CHAR":"BAD_INDENT",k),p&&p.source.length!==1&&m.unshift(p)}if(m.length>0){let y=wA.resolveEnd(m,h,n.options.strict,s);y.comment&&(c.comment?c.comment+=`
92
+ `+y.comment:c.comment=y.comment),c.range=[r.offset,h,y.offset]}else c.range=[r.offset,h,h];return c}tg.resolveFlowCollection=kA});var sg=$(rg=>{"use strict";var xA=J(),EA=se(),AA=Mt(),TA=Dt(),CA=Vm(),OA=Xm(),PA=ng();function au(t,e,n,r,s,i){let o=n.type==="block-map"?CA.resolveBlockMap(t,e,n,r,i):n.type==="block-seq"?OA.resolveBlockSeq(t,e,n,r,i):PA.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 _A(t,e,n,r,s){let i=r.tag,o=i?e.directives.tagName(i.source,f=>s(i,"TAG_RESOLVE_FAILED",f)):null;if(n.type==="block-seq"){let{anchor:f,newlineAfterProp:p}=r,m=f&&i?f.offset>i.offset?f:i:f??i;m&&(!p||p.offset<m.offset)&&s(m,"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===AA.YAMLMap.tagName&&a==="map"||o===TA.YAMLSeq.tagName&&a==="seq")return au(t,e,n,s,o);let l=e.schema.tags.find(f=>f.tag===o&&f.collection===a);if(!l){let f=e.schema.knownTags[o];if(f?.collection===a)e.schema.tags.push(Object.assign({},f,{default:!1})),l=f;else return f?s(i,"BAD_COLLECTION_TYPE",`${f.tag} used for ${a} collection, but expects ${f.collection??"scalar"}`,!0):s(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),au(t,e,n,s,o)}let c=au(t,e,n,s,o,l),u=l.resolve?.(c,f=>s(i,"TAG_RESOLVE_FAILED",f),e.options)??c,d=xA.isNode(u)?u:new EA.Scalar(u);return d.range=c.range,d.tag=o,l?.format&&(d.format=l.format),d}rg.composeCollection=_A});var cu=$(ig=>{"use strict";var lu=se();function RA(t,e,n){let r=e.offset,s=IA(e,t.options.strict,n);if(!s)return{value:"",type:null,comment:"",range:[r,r,r]};let i=s.mode===">"?lu.Scalar.BLOCK_FOLDED:lu.Scalar.BLOCK_LITERAL,o=e.source?$A(e.source):[],a=o.length;for(let h=o.length-1;h>=0;--h){let y=o[h][1];if(y===""||y==="\r")a=h;else break}if(a===0){let h=s.chomp==="+"&&o.length>0?`
93
+ `.repeat(Math.max(1,o.length-1)):"",y=r+s.length;return e.source&&(y+=e.source.length),{value:h,type:i,comment:s.comment,range:[r,y,y]}}let l=e.indent+s.indent,c=e.offset+s.length,u=0;for(let h=0;h<a;++h){let[y,k]=o[h];if(k===""||k==="\r")s.indent===0&&y.length>l&&(l=y.length);else{y.length<l&&n(c+y.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),s.indent===0&&(l=y.length),u=h,l===0&&!t.atRoot&&n(c,"BAD_INDENT","Block scalar values in collections must be indented");break}c+=y.length+k.length+1}for(let h=o.length-1;h>=a;--h)o[h][0].length>l&&(a=h+1);let d="",f="",p=!1;for(let h=0;h<u;++h)d+=o[h][0].slice(l)+`
94
+ `;for(let h=u;h<a;++h){let[y,k]=o[h];c+=y.length+k.length+1;let T=k[k.length-1]==="\r";if(T&&(k=k.slice(0,-1)),k&&y.length<l){let E=`Block scalar lines must not be less indented than their ${s.indent?"explicit indentation indicator":"first line"}`;n(c-k.length-(T?2:1),"BAD_INDENT",E),y=""}i===lu.Scalar.BLOCK_LITERAL?(d+=f+y.slice(l)+k,f=`
95
+ `):y.length>l||k[0]===" "?(f===" "?f=`
96
96
  `:!p&&f===`
97
97
  `&&(f=`
98
98
 
99
- `),d+=f+g.slice(l)+v,f=`
100
- `,p=!0):v===""?f===`
99
+ `),d+=f+y.slice(l)+k,f=`
100
+ `,p=!0):k===""?f===`
101
101
  `?d+=`
102
102
  `:f=`
103
- `:(d+=f+v,f=" ",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]!==`
103
+ `:(d+=f+k,f=" ",p=!1)}switch(s.chomp){case"-":break;case"+":for(let h=a;h<o.length;++h)d+=`
104
+ `+o[h][0].slice(l);d[d.length-1]!==`
105
105
  `&&(d+=`
106
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 AA({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 f=1;f<s.length;++f){let p=s[f];if(!a&&(p==="-"||p==="+"))a=p;else{let h=Number(p);!o&&h?o=h:l===-1&&(l=t+f)}}l!==-1&&r(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${s}`);let c=!1,u="",d=s.length;for(let f=1;f<e.length;++f){let p=e[f];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,u=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:u,length:d}}function TA(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}rg.resolveBlockScalar=EA});var du=_(ig=>{"use strict";var uu=se(),CA=Xn();function OA(t,e,n){let{offset:r,type:s,source:i,end:o}=t,a,l,c=(f,p,h)=>n(r+f,p,h);switch(s){case"scalar":a=uu.Scalar.PLAIN,l=PA(i,c);break;case"single-quoted-scalar":a=uu.Scalar.QUOTE_SINGLE,l=_A(i,c);break;case"double-quoted-scalar":a=uu.Scalar.QUOTE_DOUBLE,l=RA(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 u=r+i.length,d=CA.resolveEnd(o,u,e,n);return{value:l,type:a,comment:d.comment,range:[r,u,d.offset]}}function PA(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}`),sg(t)}function _A(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),sg(t.slice(1,-1)).replace(/''/g,"'")}function sg(t){let e,n;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
107
+ `}let m=r+s.length+e.source.length;return{value:d,type:i,comment:s.comment,range:[r,m,m]}}function IA({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 f=1;f<s.length;++f){let p=s[f];if(!a&&(p==="-"||p==="+"))a=p;else{let m=Number(p);!o&&m?o=m:l===-1&&(l=t+f)}}l!==-1&&r(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${s}`);let c=!1,u="",d=s.length;for(let f=1;f<e.length;++f){let p=e[f];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,u=p.source.substring(1);break;case"error":r(p,"UNEXPECTED_TOKEN",p.message),d+=p.source.length;break;default:{let m=`Unexpected token in block scalar header: ${p.type}`;r(p,"UNEXPECTED_TOKEN",m);let h=p.source;h&&typeof h=="string"&&(d+=h.length)}}}return{mode:i,indent:o,chomp:a,comment:u,length:d}}function $A(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}ig.resolveBlockScalar=RA});var du=$(ag=>{"use strict";var uu=se(),NA=Gn();function LA(t,e,n){let{offset:r,type:s,source:i,end:o}=t,a,l,c=(f,p,m)=>n(r+f,p,m);switch(s){case"scalar":a=uu.Scalar.PLAIN,l=MA(i,c);break;case"single-quoted-scalar":a=uu.Scalar.QUOTE_SINGLE,l=DA(i,c);break;case"double-quoted-scalar":a=uu.Scalar.QUOTE_DOUBLE,l=BA(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 u=r+i.length,d=NA.resolveEnd(o,u,e,n);return{value:l,type:a,comment:d.comment,range:[r,u,d.offset]}}function MA(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 DA(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 RA(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 BA(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}=IA(t,r);n+=i,r=o}else if(s==="\\"){let i=t[++r],o=$A[i];if(o)n+=o;else if(i===`
113
+ `){let{fold:i,offset:o}=jA(t,r);n+=i,r=o}else if(s==="\\"){let i=t[++r],o=FA[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+=NA(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+=UA(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 IA(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 jA(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 $A={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 NA(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)}ig.resolveFlowScalar=OA});var lg=_(ag=>{"use strict";var un=J(),og=se(),LA=cu(),MA=du();function DA(t,e,n,r){let{value:s,type:i,comment:o,range:a}=e.type==="block-scalar"?LA.resolveBlockScalar(t,e,r):MA.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[un.SCALAR]:l?c=BA(t.schema,s,l,n,r):e.type==="scalar"?c=jA(t,s,e,r):c=t.schema[un.SCALAR];let u;try{let d=c.resolve(s,f=>r(n??e,"TAG_RESOLVE_FAILED",f),t.options);u=un.isScalar(d)?d:new og.Scalar(d)}catch(d){let f=d instanceof Error?d.message:String(d);r(n??e,"TAG_RESOLVE_FAILED",f),u=new og.Scalar(s)}return u.range=a,u.source=s,i&&(u.type=i),l&&(u.tag=l),c.format&&(u.format=c.format),o&&(u.comment=o),u}function BA(t,e,n,r,s){if(n==="!")return t[un.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[un.SCALAR])}function jA({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[un.SCALAR];if(n.compat){let a=n.compat.find(l=>l.default&&l.test?.test(r))??n[un.SCALAR];if(o.tag!==a.tag){let l=e.tagString(o.tag),c=e.tagString(a.tag),u=`Value may be parsed as either ${l} or ${c}`;i(s,"TAG_RESOLVE_FAILED",u,!0)}}return o}ag.composeScalar=DA});var ug=_(cg=>{"use strict";function FA(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}cg.emptyScalarPosition=FA});var pg=_(pu=>{"use strict";var UA=Qr(),qA=J(),JA=ng(),dg=lg(),WA=Xn(),KA=ug(),HA={composeNode:fg,composeEmptyNode:fu};function fg(t,e,n,r){let s=t.atKey,{spaceBefore:i,comment:o,anchor:a,tag:l}=n,c,u=!0;switch(e.type){case"alias":c=zA(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=dg.composeScalar(t,e,l,r),a&&(c.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":c=JA.composeCollection(HA,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=fu(t,e.offset,void 0,null,n,r),u=!1}}return a&&c.anchor===""&&r(a,"BAD_ALIAS","Anchor cannot be an empty string"),s&&t.options.stringKeys&&(!qA.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&&u&&(c.srcToken=e),c}function fu(t,e,n,r,{spaceBefore:s,comment:i,anchor:o,tag:a,end:l},c){let u={type:"scalar",offset:KA.emptyScalarPosition(e,n,r),indent:-1,source:""},d=dg.composeScalar(t,u,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 zA({options:t},{offset:e,source:n,end:r},s){let i=new UA.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=WA.resolveEnd(r,o,t.strict,s);return i.range=[e,o,a.offset],a.comment&&(i.comment=a.comment),i}pu.composeEmptyNode=fu;pu.composeNode=fg});var gg=_(mg=>{"use strict";var YA=ms(),hg=pg(),VA=Xn(),GA=ws();function XA(t,e,{offset:n,start:r,value:s,end:i},o){let a=Object.assign({_directives:e},t),l=new YA.Document(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},u=GA.resolveProps(r,{indicator:"doc-start",next:s??i?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});u.found&&(l.directives.docStart=!0,s&&(s.type==="block-map"||s.type==="block-seq")&&!u.hasNewline&&o(u.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),l.contents=s?hg.composeNode(c,s,u,o):hg.composeEmptyNode(c,u.end,r,null,u,o);let d=l.contents.range[2],f=VA.resolveEnd(i,d,!1,o);return f.comment&&(l.comment=f.comment),l.range=[n,d,f.offset],l}mg.composeDoc=XA});var mu=_(wg=>{"use strict";var QA=Ei("process"),ZA=ec(),eT=ms(),vs=bs(),yg=J(),tT=gg(),nT=Xn();function Ss(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 bg(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 FA={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 UA(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)}ag.resolveFlowScalar=LA});var ug=$(cg=>{"use strict";var un=J(),lg=se(),qA=cu(),JA=du();function WA(t,e,n,r){let{value:s,type:i,comment:o,range:a}=e.type==="block-scalar"?qA.resolveBlockScalar(t,e,r):JA.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[un.SCALAR]:l?c=KA(t.schema,s,l,n,r):e.type==="scalar"?c=HA(t,s,e,r):c=t.schema[un.SCALAR];let u;try{let d=c.resolve(s,f=>r(n??e,"TAG_RESOLVE_FAILED",f),t.options);u=un.isScalar(d)?d:new lg.Scalar(d)}catch(d){let f=d instanceof Error?d.message:String(d);r(n??e,"TAG_RESOLVE_FAILED",f),u=new lg.Scalar(s)}return u.range=a,u.source=s,i&&(u.type=i),l&&(u.tag=l),c.format&&(u.format=c.format),o&&(u.comment=o),u}function KA(t,e,n,r,s){if(n==="!")return t[un.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[un.SCALAR])}function HA({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[un.SCALAR];if(n.compat){let a=n.compat.find(l=>l.default&&l.test?.test(r))??n[un.SCALAR];if(o.tag!==a.tag){let l=e.tagString(o.tag),c=e.tagString(a.tag),u=`Value may be parsed as either ${l} or ${c}`;i(s,"TAG_RESOLVE_FAILED",u,!0)}}return o}cg.composeScalar=WA});var fg=$(dg=>{"use strict";function zA(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}dg.emptyScalarPosition=zA});var mg=$(pu=>{"use strict";var YA=Qr(),VA=J(),GA=sg(),pg=ug(),XA=Gn(),QA=fg(),ZA={composeNode:hg,composeEmptyNode:fu};function hg(t,e,n,r){let s=t.atKey,{spaceBefore:i,comment:o,anchor:a,tag:l}=n,c,u=!0;switch(e.type){case"alias":c=eT(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=pg.composeScalar(t,e,l,r),a&&(c.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":c=GA.composeCollection(ZA,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=fu(t,e.offset,void 0,null,n,r),u=!1}}return a&&c.anchor===""&&r(a,"BAD_ALIAS","Anchor cannot be an empty string"),s&&t.options.stringKeys&&(!VA.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&&u&&(c.srcToken=e),c}function fu(t,e,n,r,{spaceBefore:s,comment:i,anchor:o,tag:a,end:l},c){let u={type:"scalar",offset:QA.emptyScalarPosition(e,n,r),indent:-1,source:""},d=pg.composeScalar(t,u,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 eT({options:t},{offset:e,source:n,end:r},s){let i=new YA.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=XA.resolveEnd(r,o,t.strict,s);return i.range=[e,o,a.offset],a.comment&&(i.comment=a.comment),i}pu.composeEmptyNode=fu;pu.composeNode=hg});var bg=$(yg=>{"use strict";var tT=ms(),gg=mg(),nT=Gn(),rT=ws();function sT(t,e,{offset:n,start:r,value:s,end:i},o){let a=Object.assign({_directives:e},t),l=new tT.Document(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},u=rT.resolveProps(r,{indicator:"doc-start",next:s??i?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});u.found&&(l.directives.docStart=!0,s&&(s.type==="block-map"||s.type==="block-seq")&&!u.hasNewline&&o(u.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),l.contents=s?gg.composeNode(c,s,u,o):gg.composeEmptyNode(c,u.end,r,null,u,o);let d=l.contents.range[2],f=nT.resolveEnd(i,d,!1,o);return f.comment&&(l.comment=f.comment),l.range=[n,d,f.offset],l}yg.composeDoc=sT});var mu=$(Sg=>{"use strict";var iT=Ei("process"),oT=ec(),aT=ms(),vs=bs(),wg=J(),lT=bg(),cT=Gn();function Ss(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 vg(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 hu=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(n,r,s,i)=>{let o=Ss(n);i?this.warnings.push(new vs.YAMLWarning(o,r,s)):this.errors.push(new vs.YAMLParseError(o,r,s))},this.directives=new ZA.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,n){let{comment:r,afterEmptyLine:s}=bg(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(yg.isCollection(i)&&!i.flow&&i.items.length>0){let o=i.items[0];yg.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 hu=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(n,r,s,i)=>{let o=Ss(n);i?this.warnings.push(new vs.YAMLWarning(o,r,s)):this.errors.push(new vs.YAMLParseError(o,r,s))},this.directives=new oT.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,n){let{comment:r,afterEmptyLine:s}=vg(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(wg.isCollection(i)&&!i.flow&&i.items.length>0){let o=i.items[0];wg.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:bg(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(QA.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(n,r,s)=>{let i=Ss(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 vs.YAMLParseError(Ss(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 vs.YAMLParseError(Ss(e),"UNEXPECTED_TOKEN",r));break}this.doc.directives.docEnd=!0;let n=nT.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 vs.YAMLParseError(Ss(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 eT.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}}};wg.Composer=hu});var kg=_(ko=>{"use strict";var rT=cu(),sT=du(),iT=bs(),vg=rs();function oT(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 iT.YAMLParseError([a,a+1],i,o)};switch(t.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return sT.resolveFlowScalar(t,e,r);case"block-scalar":return rT.resolveBlockScalar({options:{strict:e}},t,r)}}return null}function aT(t,e){let{implicitKey:n=!1,indent:r,inFlow:s=!1,offset:i=-1,type:o="PLAIN"}=e,a=vg.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:`
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:vg(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(iT.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(n,r,s)=>{let i=Ss(e);i[0]+=n,this.onError(i,"BAD_DIRECTIVE",r,s)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let n=lT.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 vs.YAMLParseError(Ss(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 vs.YAMLParseError(Ss(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 vs.YAMLParseError(Ss(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}}};Sg.Composer=hu});var Eg=$(ko=>{"use strict";var uT=cu(),dT=du(),fT=bs(),kg=rs();function pT(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 fT.YAMLParseError([a,a+1],i,o)};switch(t.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return dT.resolveFlowScalar(t,e,r);case"block-scalar":return uT.resolveBlockScalar({options:{strict:e}},t,r)}}return null}function hT(t,e){let{implicitKey:n=!1,indent:r,inFlow:s=!1,offset:i=-1,type:o="PLAIN"}=e,a=kg.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
130
  `}];switch(a[0]){case"|":case">":{let c=a.indexOf(`
131
131
  `),u=a.substring(0,c),d=a.substring(c+1)+`
132
- `,f=[{type:"block-scalar-header",offset:i,indent:r,source:u}];return Sg(f,l)||f.push({type:"newline",offset:-1,indent:r,source:`
133
- `}),{type:"block-scalar",offset:i,indent:r,props:f,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 lT(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=vg.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">":cT(t,l);break;case'"':gu(t,l,"double-quoted-scalar");break;case"'":gu(t,l,"single-quoted-scalar");break;default:gu(t,l,"scalar")}}function cT(t,e){let n=e.indexOf(`
132
+ `,f=[{type:"block-scalar-header",offset:i,indent:r,source:u}];return xg(f,l)||f.push({type:"newline",offset:-1,indent:r,source:`
133
+ `}),{type:"block-scalar",offset:i,indent:r,props:f,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 mT(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=kg.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">":gT(t,l);break;case'"':gu(t,l,"double-quoted-scalar");break;case"'":gu(t,l,"single-quoted-scalar");break;default:gu(t,l,"scalar")}}function gT(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}];Sg(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 Sg(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 gu(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})}}}ko.createScalarToken=aT;ko.resolveAsScalar=oT;ko.setScalarValue=lT});var Eg=_(xg=>{"use strict";var uT=t=>"type"in t?Eo(t):xo(t);function Eo(t){switch(t.type){case"block-scalar":{let e="";for(let n of t.props)e+=Eo(n);return e+t.source}case"block-map":case"block-seq":{let e="";for(let n of t.items)e+=xo(n);return e}case"flow-collection":{let e=t.start.source;for(let n of t.items)e+=xo(n);for(let n of t.end)e+=n.source;return e}case"document":{let e=xo(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 xo({start:t,key:e,sep:n,value:r}){let s="";for(let i of t)s+=i.source;if(e&&(s+=Eo(e)),n)for(let i of n)s+=i.source;return r&&(s+=Eo(r)),s}xg.stringify=uT});var Og=_(Cg=>{"use strict";var yu=Symbol("break visit"),dT=Symbol("skip children"),Ag=Symbol("remove item");function dn(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),Tg(Object.freeze([]),t,e)}dn.BREAK=yu;dn.SKIP=dT;dn.REMOVE=Ag;dn.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};dn.parentCollection=(t,e)=>{let n=dn.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 Tg(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=Tg(Object.freeze(t.concat([[s,o]])),i.items[o],n);if(typeof a=="number")o=a-1;else{if(a===yu)return yu;a===Ag&&(i.items.splice(o,1),o-=1)}}typeof r=="function"&&s==="key"&&(r=r(e,t))}}return typeof r=="function"?r(e,t):r}Cg.visit=dn});var Ao=_(xe=>{"use strict";var bu=kg(),fT=Eg(),pT=Og(),wu="\uFEFF",vu="",Su="",ku="",hT=t=>!!t&&"items"in t,mT=t=>!!t&&(t.type==="scalar"||t.type==="single-quoted-scalar"||t.type==="double-quoted-scalar"||t.type==="block-scalar");function gT(t){switch(t){case wu:return"<BOM>";case vu:return"<DOC>";case Su:return"<FLOW_END>";case ku:return"<SCALAR>";default:return JSON.stringify(t)}}function yT(t){switch(t){case wu:return"byte-order-mark";case vu:return"doc-mode";case Su:return"flow-error-end";case ku: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}];xg(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 xg(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 gu(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})}}}ko.createScalarToken=hT;ko.resolveAsScalar=pT;ko.setScalarValue=mT});var Tg=$(Ag=>{"use strict";var yT=t=>"type"in t?Eo(t):xo(t);function Eo(t){switch(t.type){case"block-scalar":{let e="";for(let n of t.props)e+=Eo(n);return e+t.source}case"block-map":case"block-seq":{let e="";for(let n of t.items)e+=xo(n);return e}case"flow-collection":{let e=t.start.source;for(let n of t.items)e+=xo(n);for(let n of t.end)e+=n.source;return e}case"document":{let e=xo(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 xo({start:t,key:e,sep:n,value:r}){let s="";for(let i of t)s+=i.source;if(e&&(s+=Eo(e)),n)for(let i of n)s+=i.source;return r&&(s+=Eo(r)),s}Ag.stringify=yT});var _g=$(Pg=>{"use strict";var yu=Symbol("break visit"),bT=Symbol("skip children"),Cg=Symbol("remove item");function dn(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),Og(Object.freeze([]),t,e)}dn.BREAK=yu;dn.SKIP=bT;dn.REMOVE=Cg;dn.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};dn.parentCollection=(t,e)=>{let n=dn.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 Og(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=Og(Object.freeze(t.concat([[s,o]])),i.items[o],n);if(typeof a=="number")o=a-1;else{if(a===yu)return yu;a===Cg&&(i.items.splice(o,1),o-=1)}}typeof r=="function"&&s==="key"&&(r=r(e,t))}}return typeof r=="function"?r(e,t):r}Pg.visit=dn});var Ao=$(xe=>{"use strict";var bu=Eg(),wT=Tg(),vT=_g(),wu="\uFEFF",vu="",Su="",ku="",ST=t=>!!t&&"items"in t,kT=t=>!!t&&(t.type==="scalar"||t.type==="single-quoted-scalar"||t.type==="double-quoted-scalar"||t.type==="block-scalar");function xT(t){switch(t){case wu:return"<BOM>";case vu:return"<DOC>";case Su:return"<FLOW_END>";case ku:return"<SCALAR>";default:return JSON.stringify(t)}}function ET(t){switch(t){case wu:return"byte-order-mark";case vu:return"doc-mode";case Su:return"flow-error-end";case ku: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}xe.createScalarToken=bu.createScalarToken;xe.resolveAsScalar=bu.resolveAsScalar;xe.setScalarValue=bu.setScalarValue;xe.stringify=fT.stringify;xe.visit=pT.visit;xe.BOM=wu;xe.DOCUMENT=vu;xe.FLOW_END=Su;xe.SCALAR=ku;xe.isCollection=hT;xe.isScalar=mT;xe.prettyToken=gT;xe.tokenType=yT});var Au=_(_g=>{"use strict";var ks=Ao();function Ve(t){switch(t){case void 0:case" ":case`
140
- `:case"\r":case" ":return!0;default:return!1}}var Pg=new Set("0123456789ABCDEFabcdef"),bT=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),To=new Set(",[]{}"),wT=new Set(` ,[]{}
141
- \r `),xu=t=>!t||wT.has(t),Eu=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}xe.createScalarToken=bu.createScalarToken;xe.resolveAsScalar=bu.resolveAsScalar;xe.setScalarValue=bu.setScalarValue;xe.stringify=wT.stringify;xe.visit=vT.visit;xe.BOM=wu;xe.DOCUMENT=vu;xe.FLOW_END=Su;xe.SCALAR=ku;xe.isCollection=ST;xe.isScalar=kT;xe.prettyToken=xT;xe.tokenType=ET});var Au=$(Ig=>{"use strict";var ks=Ao();function Ve(t){switch(t){case void 0:case" ":case`
140
+ `:case"\r":case" ":return!0;default:return!1}}var Rg=new Set("0123456789ABCDEFabcdef"),AT=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),To=new Set(",[]{}"),TT=new Set(` ,[]{}
141
+ \r `),xu=t=>!t||TT.has(t),Eu=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===`
@@ -153,24 +153,24 @@ ${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.pus
153
153
  `&&i>=this.pos&&i+1+n>a)e=i;else break}while(!0);return yield ks.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(Ve(i)||e&&To.has(i))break;n=r}else if(Ve(s)){let i=this.buffer[r+1];if(s==="\r"&&(i===`
154
154
  `?(r+=1,s=`
155
155
  `,i=this.buffer[r+1]):n=r),i==="#"||e&&To.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&&To.has(s))break;n=r}return!s&&!this.atEnd?this.setNext("plain-scalar"):(yield ks.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(xu))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let e=this.flowLevel>0,n=this.charAt(1);if(Ve(n)||e&&To.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(;!Ve(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(bT.has(n))n=this.buffer[++e];else if(n==="%"&&Pg.has(this.buffer[e+1])&&Pg.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===`
156
+ `){let o=this.continueScalar(r+1);if(o===-1)break;r=Math.max(r,o-2)}}else{if(e&&To.has(s))break;n=r}return!s&&!this.atEnd?this.setNext("plain-scalar"):(yield ks.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(xu))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let e=this.flowLevel>0,n=this.charAt(1);if(Ve(n)||e&&To.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(;!Ve(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(AT.has(n))n=this.buffer[++e];else if(n==="%"&&Rg.has(this.buffer[e+1])&&Rg.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)}};_g.Lexer=Eu});var Cu=_(Rg=>{"use strict";var Tu=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}}}};Rg.LineCounter=Tu});var Pu=_(Mg=>{"use strict";var vT=Ei("process"),Ig=Ao(),ST=Au();function Bt(t,e){for(let n=0;n<t.length;++n)if(t[n].type===e)return!0;return!1}function $g(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 Lg(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 Co(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 Qn(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 Ng(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!Bt(e.start,"explicit-key-ind")&&!Bt(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,Lg(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 Ou=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 ST.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,vT.env.LOG_TOKENS&&console.log("|",Ig.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let n=Ig.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"&&Ng(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&&$g(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":{$g(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=Co(this.peek(2)),r=Qn(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)}};Ig.Lexer=Eu});var Cu=$($g=>{"use strict";var Tu=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}}}};$g.LineCounter=Tu});var Pu=$(Bg=>{"use strict";var CT=Ei("process"),Ng=Ao(),OT=Au();function Bt(t,e){for(let n=0;n<t.length;++n)if(t[n].type===e)return!0;return!1}function Lg(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 Dg(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 Co(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 Xn(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 Mg(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!Bt(e.start,"explicit-key-ind")&&!Bt(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,Dg(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 Ou=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 OT.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,CT.env.LOG_TOKENS&&console.log("|",Ng.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let n=Ng.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"&&Mg(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&&Lg(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":{Lg(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=Co(this.peek(2)),r=Xn(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(Bt(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(Lg(n.key)&&!Bt(n.sep,"newline")){let o=Qn(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(Bt(n.start,"newline"))Object.assign(n,{key:null,sep:[this.sourceToken]});else{let o=Qn(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]}):Bt(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&&!Bt(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||Bt(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=Co(r),i=Qn(s);Ng(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 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(Bt(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(Dg(n.key)&&!Bt(n.sep,"newline")){let o=Xn(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(Bt(n.start,"newline"))Object.assign(n,{key:null,sep:[this.sourceToken]});else{let o=Xn(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]}):Bt(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&&!Bt(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||Bt(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=Co(r),i=Xn(s);Mg(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=Co(e),r=Qn(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=Co(e),r=Qn(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())}}};Mg.Parser=Ou});var Ug=_(Es=>{"use strict";var Dg=mu(),kT=ms(),xs=bs(),xT=pc(),ET=J(),AT=Cu(),Bg=Pu();function jg(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new AT.LineCounter||null,prettyErrors:e}}function TT(t,e={}){let{lineCounter:n,prettyErrors:r}=jg(e),s=new Bg.Parser(n?.addNewLine),i=new Dg.Composer(e),o=Array.from(i.compose(s.parse(t)));if(r&&n)for(let a of o)a.errors.forEach(xs.prettifyError(t,n)),a.warnings.forEach(xs.prettifyError(t,n));return o.length>0?o:Object.assign([],{empty:!0},i.streamInfo())}function Fg(t,e={}){let{lineCounter:n,prettyErrors:r}=jg(e),s=new Bg.Parser(n?.addNewLine),i=new Dg.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 xs.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&n&&(o.errors.forEach(xs.prettifyError(t,n)),o.warnings.forEach(xs.prettifyError(t,n))),o}function CT(t,e,n){let r;typeof e=="function"?r=e:n===void 0&&e&&typeof e=="object"&&(n=e);let s=Fg(t,n);if(!s)return null;if(s.warnings.forEach(i=>xT.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 OT(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 ET.isDocument(t)&&!r?t.toString(n):new kT.Document(t,r,n).toString(n)}Es.parse=CT;Es.parseAllDocuments=TT;Es.parseDocument=Fg;Es.stringify=OT});var Jg=_(K=>{"use strict";var PT=mu(),_T=ms(),RT=Vc(),_u=bs(),IT=Qr(),jt=J(),$T=Nt(),NT=se(),LT=Mt(),MT=Dt(),DT=Ao(),BT=Au(),jT=Cu(),FT=Pu(),Oo=Ug(),qg=Yr();K.Composer=PT.Composer;K.Document=_T.Document;K.Schema=RT.Schema;K.YAMLError=_u.YAMLError;K.YAMLParseError=_u.YAMLParseError;K.YAMLWarning=_u.YAMLWarning;K.Alias=IT.Alias;K.isAlias=jt.isAlias;K.isCollection=jt.isCollection;K.isDocument=jt.isDocument;K.isMap=jt.isMap;K.isNode=jt.isNode;K.isPair=jt.isPair;K.isScalar=jt.isScalar;K.isSeq=jt.isSeq;K.Pair=$T.Pair;K.Scalar=NT.Scalar;K.YAMLMap=LT.YAMLMap;K.YAMLSeq=MT.YAMLSeq;K.CST=DT;K.Lexer=BT.Lexer;K.LineCounter=jT.LineCounter;K.Parser=FT.Parser;K.parse=Oo.parse;K.parseAllDocuments=Oo.parseAllDocuments;K.parseDocument=Oo.parseDocument;K.stringify=Oo.stringify;K.visit=qg.visit;K.visitAsync=qg.visitAsync});function qT(t){try{return JSON.parse(t.trim()),!0}catch{return!1}}function JT(t){let e=t.trim();if(!e.startsWith("<"))return!1;let n=e.match(UT);return n?zr(e,n[1])!==null:!1}function WT(t){let e=t.trim();if(!e.match(/^(---|#|\w+:|-)/)||"[{<".includes(e[0]))return!1;try{let n=Wg.parse(e);return n!==null&&typeof n=="object"}catch{return!1}}function Kg(t){return qT(t)||JT(t)||WT(t)}var Wg,UT,Ru=S(()=>{th();Wg=Yk(Jg(),1),UT=/<([a-zA-Z_][\w.-]*)/});function KT(t){if(!t?.trim())return[];let e=t.replace(/\r\n/g,`
163
- `),n=e.trim();if(Kg(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=Co(e),r=Xn(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=Co(e),r=Xn(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())}}};Bg.Parser=Ou});var Jg=$(Es=>{"use strict";var jg=mu(),PT=ms(),xs=bs(),_T=pc(),RT=J(),IT=Cu(),Fg=Pu();function Ug(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new IT.LineCounter||null,prettyErrors:e}}function $T(t,e={}){let{lineCounter:n,prettyErrors:r}=Ug(e),s=new Fg.Parser(n?.addNewLine),i=new jg.Composer(e),o=Array.from(i.compose(s.parse(t)));if(r&&n)for(let a of o)a.errors.forEach(xs.prettifyError(t,n)),a.warnings.forEach(xs.prettifyError(t,n));return o.length>0?o:Object.assign([],{empty:!0},i.streamInfo())}function qg(t,e={}){let{lineCounter:n,prettyErrors:r}=Ug(e),s=new Fg.Parser(n?.addNewLine),i=new jg.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 xs.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&n&&(o.errors.forEach(xs.prettifyError(t,n)),o.warnings.forEach(xs.prettifyError(t,n))),o}function NT(t,e,n){let r;typeof e=="function"?r=e:n===void 0&&e&&typeof e=="object"&&(n=e);let s=qg(t,n);if(!s)return null;if(s.warnings.forEach(i=>_T.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 LT(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 RT.isDocument(t)&&!r?t.toString(n):new PT.Document(t,r,n).toString(n)}Es.parse=NT;Es.parseAllDocuments=$T;Es.parseDocument=qg;Es.stringify=LT});var Kg=$(H=>{"use strict";var MT=mu(),DT=ms(),BT=Vc(),_u=bs(),jT=Qr(),jt=J(),FT=Nt(),UT=se(),qT=Mt(),JT=Dt(),WT=Ao(),KT=Au(),HT=Cu(),zT=Pu(),Oo=Jg(),Wg=Yr();H.Composer=MT.Composer;H.Document=DT.Document;H.Schema=BT.Schema;H.YAMLError=_u.YAMLError;H.YAMLParseError=_u.YAMLParseError;H.YAMLWarning=_u.YAMLWarning;H.Alias=jT.Alias;H.isAlias=jt.isAlias;H.isCollection=jt.isCollection;H.isDocument=jt.isDocument;H.isMap=jt.isMap;H.isNode=jt.isNode;H.isPair=jt.isPair;H.isScalar=jt.isScalar;H.isSeq=jt.isSeq;H.Pair=FT.Pair;H.Scalar=UT.Scalar;H.YAMLMap=qT.YAMLMap;H.YAMLSeq=JT.YAMLSeq;H.CST=WT;H.Lexer=KT.Lexer;H.LineCounter=HT.LineCounter;H.Parser=zT.Parser;H.parse=Oo.parse;H.parseAllDocuments=Oo.parseAllDocuments;H.parseDocument=Oo.parseDocument;H.stringify=Oo.stringify;H.visit=Wg.visit;H.visitAsync=Wg.visitAsync});function VT(t){try{return JSON.parse(t.trim()),!0}catch{return!1}}function GT(t){let e=t.trim();if(!e.startsWith("<"))return!1;let n=e.match(YT);return n?zr(e,n[1])!==null:!1}function XT(t){let e=t.trim();if(!e.match(/^(---|#|\w+:|-)/)||"[{<".includes(e[0]))return!1;try{let n=Hg.parse(e);return n!==null&&typeof n=="object"}catch{return!1}}function zg(t){return VT(t)||GT(t)||XT(t)}var Hg,YT,Ru=v(()=>{rh();Hg=tx(Kg(),1),YT=/<([a-zA-Z_][\w.-]*)/});function QT(t){if(!t?.trim())return[];let e=t.replace(/\r\n/g,`
163
+ `),n=e.trim();if(zg(n))return[{text:n,startLine:1,endLine:e.split(`
164
164
  `).length}];let r=e.split(`
165
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 Po(t){return KT(t).map(e=>e.text)}var Hg,zg=S(()=>{Ru();Hg=`
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 Po(t){return QT(t).map(e=>e.text)}var Yg,Vg=v(()=>{Ru();Yg=`
167
167
 
168
168
 
169
- `});function _o(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var Yg=S(()=>{});var HT,zT,Iu,Vg=S(()=>{HT=[["\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","-"]],zT=new Map(HT),Iu=zT});var Gg,Ro,$u,Xg=S(()=>{Gg=[["\xE6","ae"],["\xC6","Ae"],["\xF8","oe"],["\xD8","Oe"],["\xE5","aa"],["\xC5","Aa"]],Ro={sv:[["\xE4","a"],["\xC4","A"],["\xF6","o"],["\xD6","O"],["\xE5","a"],["\xC5","A"]],da:Gg,nb:Gg,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(Ro))Ro[t]=new Map(Ro[t]);$u=Ro});function Nu(t,e){if(typeof t!="string")throw new TypeError(`Expected a string, got \`${typeof t}\``);e={customReplacements:[],...e};let n=VT(e.locale),r=Iu,s=e.customReplacements.length>0||e.customReplacements.size>0;if(n||s){if(r=new Map(Iu),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=YT(t,r),t=t.normalize("NFD").replaceAll(/\p{Diacritic}/gu,"").normalize(),t=t.replaceAll(/\p{Dash_Punctuation}/gu,"-"),t}var YT,VT,Qg=S(()=>{Vg();Xg();YT=(t,e)=>{for(let[n,r]of e)t=t.replaceAll(n,r);return t},VT=t=>{if(!t)return;let e=t.toLowerCase().replace(/^no(-|$)/,"nb$1");return $u[e]||$u[e.split("-")[0]]||void 0}});var GT,Zg,ey=S(()=>{GT=[["&"," and "],["\u{1F984}"," unicorn "],["\u2665"," love "]],Zg=GT});function Lu(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([...Zg,...e.customReplacements]);t=Nu(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=XT(t));let s=ZT(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=QT(t,e.separator)),n&&(t=`_${t}`),r&&(t=`${t}-`),t}var XT,QT,ZT,ty=S(()=>{Yg();Qg();ey();XT=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"),QT=(t,e)=>{let n=_o(e);return t.replaceAll(new RegExp(`(?:${n}){2,}`,"g"),e).replaceAll(new RegExp(`^(?:${n})|(?:${n})$`,"g"),"")},ZT=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+=_o(r)}let n=t.transliterate?"g":"gu";return new RegExp(`[^${e}]+`,n)}});function Zn(t){return Lu(t)}var ny=S(()=>{ty()});var er,ry,sy=S(()=>{er={local:"local",ide:"ide",published:"published",inline:"inline"},ry=Object.values(er).map(t=>`'${t}'`).join(" | ")});var As,Mu,iy=S(()=>{As=` *, *::before, *::after { box-sizing: border-box; }
169
+ `});function _o(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var Gg=v(()=>{});var ZT,eC,Iu,Xg=v(()=>{ZT=[["\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","-"]],eC=new Map(ZT),Iu=eC});var Qg,Ro,$u,Zg=v(()=>{Qg=[["\xE6","ae"],["\xC6","Ae"],["\xF8","oe"],["\xD8","Oe"],["\xE5","aa"],["\xC5","Aa"]],Ro={sv:[["\xE4","a"],["\xC4","A"],["\xF6","o"],["\xD6","O"],["\xE5","a"],["\xC5","A"]],da:Qg,nb:Qg,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(Ro))Ro[t]=new Map(Ro[t]);$u=Ro});function Nu(t,e){if(typeof t!="string")throw new TypeError(`Expected a string, got \`${typeof t}\``);e={customReplacements:[],...e};let n=nC(e.locale),r=Iu,s=e.customReplacements.length>0||e.customReplacements.size>0;if(n||s){if(r=new Map(Iu),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=tC(t,r),t=t.normalize("NFD").replaceAll(/\p{Diacritic}/gu,"").normalize(),t=t.replaceAll(/\p{Dash_Punctuation}/gu,"-"),t}var tC,nC,ey=v(()=>{Xg();Zg();tC=(t,e)=>{for(let[n,r]of e)t=t.replaceAll(n,r);return t},nC=t=>{if(!t)return;let e=t.toLowerCase().replace(/^no(-|$)/,"nb$1");return $u[e]||$u[e.split("-")[0]]||void 0}});var rC,ty,ny=v(()=>{rC=[["&"," and "],["\u{1F984}"," unicorn "],["\u2665"," love "]],ty=rC});function Lu(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([...ty,...e.customReplacements]);t=Nu(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=sC(t));let s=oC(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=iC(t,e.separator)),n&&(t=`_${t}`),r&&(t=`${t}-`),t}var sC,iC,oC,ry=v(()=>{Gg();ey();ny();sC=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"),iC=(t,e)=>{let n=_o(e);return t.replaceAll(new RegExp(`(?:${n}){2,}`,"g"),e).replaceAll(new RegExp(`^(?:${n})|(?:${n})$`,"g"),"")},oC=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+=_o(r)}let n=t.transliterate?"g":"gu";return new RegExp(`[^${e}]+`,n)}});function Qn(t){return Lu(t)}var sy=v(()=>{ry()});var Zn,iy,oy=v(()=>{Zn={local:"local",ide:"ide",published:"published",inline:"inline"},iy=Object.values(Zn).map(t=>`'${t}'`).join(" | ")});var As,Mu,ay=v(()=>{As=` *, *::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; }`,Mu=" html, body { height: 100%; }"});var oy,ay=S(()=>{oy=`(function () {
173
+ html[data-theme="light"] { color-scheme: light; }`,Mu=" html, body { height: 100%; }"});var ly,cy=v(()=>{ly=`(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 ly,cy=S(()=>{ly=`(function () {
241
+ })();`});var uy,dy=v(()=>{uy=`(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 Z=S(()=>{Ci();Kl();Wp();Yp();Ru();zg();ny();sy();iy();ay();cy();Oi()});function ie(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 fy(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 py(t){return t.replace(/[/\\]+$/,"").split(/[/\\]/).pop()??""}function hy(t){return!t||typeof t!="object"?"":ee(t.command)??ee(t.file_path)??ee(t.filePath)??ee(t.path)??ee(t.pattern)??ee(t.query)??ee(t.url)??ee(t.skill)??ee(t.description)??""}function Bu(t){let e=/^mcp__(.+?)__(.+)$/.exec(t);return e?`${e[1][0].toUpperCase()}${e[1].slice(1)} [${e[2]}]`:t}var ee,Ts,dy,Io=S(()=>{"use strict";ee=t=>typeof t=="string"?t:void 0,Ts=t=>t.replace(/\u001b\[[0-9;]*m/g,""),dy=t=>` (+${t} line${t===1?"":"s"})`});function Pe(t){return t.length>ju?t.slice(0,ju)+`
295
+ })();`});var ee=v(()=>{Ci();Kl();Hp();Gp();Ru();Vg();sy();oy();ay();cy();dy();Oi()});function ie(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 hy(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 my(t){return t.replace(/[/\\]+$/,"").split(/[/\\]/).pop()??""}function gy(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 Bu(t){let e=/^mcp__(.+?)__(.+)$/.exec(t);return e?`${e[1][0].toUpperCase()}${e[1].slice(1)} [${e[2]}]`:t}var Z,Ts,py,Io=v(()=>{"use strict";Z=t=>typeof t=="string"?t:void 0,Ts=t=>t.replace(/\u001b\[[0-9;]*m/g,""),py=t=>` (+${t} line${t===1?"":"s"})`});function Pe(t){return t.length>ju?t.slice(0,ju)+`
296
296
  \u2026[${t.length-ju} more characters truncated]`:t}function De(t){let e=Ts(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+dy(s):r}var ju,Ee,$o,Cs=S(()=>{"use strict";Io();ju=5e4,Ee=(t,e,n=e+"s")=>`${t} ${t===1?e:n}`;$o=(t,e)=>`![pasted image](data:${e||"image/png"};base64,${t})`});import{closeSync as my,existsSync as eC,fstatSync as tC,openSync as gy,readdirSync as nC,readSync as yy,statSync as rC}from"fs";import{join as sC}from"path";function tr(t,e){let n;try{n=gy(t,"r")}catch{return}try{let r=Buffer.alloc(e),s=yy(n,r,0,e,0);return{text:r.subarray(0,s).toString("utf8"),bytes:s}}finally{my(n)}}function No(t,e){let n;try{n=gy(t,"r")}catch{return}try{let r=tC(n).size,s=Math.min(e,r),i=Buffer.alloc(s),o=yy(n,i,0,s,r-s);return{text:i.subarray(0,o).toString("utf8"),partial:r>s}}finally{my(n)}}function Lo(t){if(!eC(t))return[];let e;try{e=nC(t)}catch{return[]}let n=[];for(let r of e){if(!r.endsWith(".jsonl"))continue;let s=sC(t,r);try{let i=rC(s);i.isFile()&&n.push({sessionId:r.slice(0,-6),file:s,mtime:i.mtimeMs})}catch{}}return n}var Mo=S(()=>{"use strict"});var Ft,Do=S(()=>{"use strict";Ft=class{ensureHarnessSupport(){}forRead(){return this}linker(){return{link(){}}}}});import{openSync as iC,readSync as oC,closeSync as aC,statSync as ky,readdirSync as xy,readFileSync as Ey,existsSync as lC}from"fs";import{join as fn}from"path";import{homedir as cC}from"os";function uC(t){return t.replace(/[^a-zA-Z0-9]/g,"-")}function fC(t,e,n){let r=fn(Fu(t,e),n,dC),s;try{s=xy(r)}catch{return[]}let i=NC(t,n),o=[];for(let a of s){if(!a.endsWith(".jsonl"))continue;let l=fn(r,a),c;try{c=ky(l)}catch{continue}let u=a.slice(0,-6),d={};try{d=JSON.parse(Ey(fn(r,`${u}.meta.json`),"utf8"))}catch{}let f=mC(l,c.size,c.mtimeMs);o.push({id:u.startsWith("agent-")?u.slice(6):u,file:l,mtime:c.mtimeMs,started:c.birthtimeMs||void 0,tokens:f.tokens,failing:f.failing,running:!!f.running&&(i===void 0||c.mtimeMs>=i),liveSince:i,label:d.description??"",kind:d.agentType===pC?void 0:d.agentType,model:f.model?.replace(/^claude-/,"").replace(/-\d{8}$/,"")??d.model,effort:f.effort,spawnId:d.toolUseId,parentId:d.parentAgentId,depth:d.spawnDepth??1,stopped:!!d.stoppedByUser})}return o}function mC(t,e,n){let r=by.get(t);if(r&&r.size===e&&r.mtime===n)return r;let s={};for(let i of hC){let o=No(t,i);if(!o)break;let a=o.text.split(`
298
- `);o.partial&&a.shift();let l=[];for(let f of a)if(f.trim())try{l.push(JSON.parse(f))}catch{}if(o.partial&&!l.some(f=>f.type==="user"||f.type==="assistant"))continue;let c,u;for(let f=l.length-1;f>=0&&!u;f--){let p=l[f];p?.type==="assistant"&&(c??=p,!p.isApiErrorMessage&&p.message?.usage&&(u=p))}let d=u?.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:u?.message?.model??r?.model,effort:u?.effort??r?.effort,running:Ty(l),failing:!!c?.isApiErrorMessage},!(s.tokens===void 0&&o.partial))break}return s.model??=gC(t),by.set(t,{size:e,mtime:n,...s}),s}function gC(t){for(let e of(tr(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 Ty(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(yC(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(!Ay(e)&&o.trim()&&Ut(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 yC(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 jo(t){let e=t?.type==="image"?t.source:void 0;return e?.type==="base64"&&e.data?$o(e.data,e.media_type):""}function Os(t){return typeof t=="string"?Pe(t):Array.isArray(t)?t.map(e=>{if(typeof e=="string")return Pe(e);let n=e;return typeof n?.text=="string"?Pe(n.text):n?.content!=null?Os(n.content):jo(n)}).join(`
300
- `):t==null?"":Pe(JSON.stringify(t))}function bC(t){let e=t.trim();return!!e&&Cy.some(n=>n.test(e))}function wC(t){let e=t.trim();return e?Cy.some(n=>{let r=n.exec(e);return!!r&&r.index===0}):!0}function SC(t){return t.replace(vC,"")}function kC(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 Ut(t){let e=SC(t).trim();return e?kC(e)??(bC(e)?"":e):""}function Fo(t){let e=xC.exec(t.trim());if(e)return{from:e[1],body:AC(e[2].replace(EC,""))}}function AC(t){let e=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+py(s):r}var ju,Ee,$o,Cs=v(()=>{"use strict";Io();ju=5e4,Ee=(t,e,n=e+"s")=>`${t} ${t===1?e:n}`;$o=(t,e)=>`![pasted image](data:${e||"image/png"};base64,${t})`});import{closeSync as yy,existsSync as aC,fstatSync as lC,openSync as by,readdirSync as cC,readSync as wy,statSync as uC}from"fs";import{join as dC}from"path";function er(t,e){let n;try{n=by(t,"r")}catch{return}try{let r=Buffer.alloc(e),s=wy(n,r,0,e,0);return{text:r.subarray(0,s).toString("utf8"),bytes:s}}finally{yy(n)}}function No(t,e){let n;try{n=by(t,"r")}catch{return}try{let r=lC(n).size,s=Math.min(e,r),i=Buffer.alloc(s),o=wy(n,i,0,s,r-s);return{text:i.subarray(0,o).toString("utf8"),partial:r>s}}finally{yy(n)}}function Lo(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=dC(t,r);try{let i=uC(s);i.isFile()&&n.push({sessionId:r.slice(0,-6),file:s,mtime:i.mtimeMs})}catch{}}return n}var Mo=v(()=>{"use strict"});var Ft,Do=v(()=>{"use strict";Ft=class{ensureHarnessSupport(){}forRead(){return this}linker(){return{link(){}}}}});import{openSync as fC,readSync as pC,closeSync as hC,statSync as Ey,readdirSync as Ay,readFileSync as Ty,existsSync as mC}from"fs";import{join as fn}from"path";import{homedir as gC}from"os";function yC(t){return t.replace(/[^a-zA-Z0-9]/g,"-")}function wC(t,e,n){let r=fn(Fu(t,e),n,bC),s;try{s=Ay(r)}catch{return[]}let i=UC(t,n),o=[];for(let a of s){if(!a.endsWith(".jsonl"))continue;let l=fn(r,a),c;try{c=Ey(l)}catch{continue}let u=a.slice(0,-6),d={};try{d=JSON.parse(Ty(fn(r,`${u}.meta.json`),"utf8"))}catch{}let f=kC(l,c.size,c.mtimeMs);o.push({id:u.startsWith("agent-")?u.slice(6):u,file:l,mtime:c.mtimeMs,started:c.birthtimeMs||void 0,tokens:f.tokens,failing:f.failing,running:!!f.running&&(i===void 0||c.mtimeMs>=i),liveSince:i,label:d.description??"",kind:d.agentType===vC?void 0:d.agentType,model:f.model?.replace(/^claude-/,"").replace(/-\d{8}$/,"")??d.model,effort:f.effort,spawnId:d.toolUseId,parentId:d.parentAgentId,depth:d.spawnDepth??1,stopped:!!d.stoppedByUser})}return o}function kC(t,e,n){let r=vy.get(t);if(r&&r.size===e&&r.mtime===n)return r;let s={};for(let i of SC){let o=No(t,i);if(!o)break;let a=o.text.split(`
298
+ `);o.partial&&a.shift();let l=[];for(let f of a)if(f.trim())try{l.push(JSON.parse(f))}catch{}if(o.partial&&!l.some(f=>f.type==="user"||f.type==="assistant"))continue;let c,u;for(let f=l.length-1;f>=0&&!u;f--){let p=l[f];p?.type==="assistant"&&(c??=p,!p.isApiErrorMessage&&p.message?.usage&&(u=p))}let d=u?.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:u?.message?.model??r?.model,effort:u?.effort??r?.effort,running:Oy(l),failing:!!c?.isApiErrorMessage},!(s.tokens===void 0&&o.partial))break}return s.model??=xC(t),vy.set(t,{size:e,mtime:n,...s}),s}function xC(t){for(let e of(er(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 Oy(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(EC(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(!Cy(e)&&o.trim()&&Ut(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 EC(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 jo(t){let e=t?.type==="image"?t.source:void 0;return e?.type==="base64"&&e.data?$o(e.data,e.media_type):""}function Os(t){return typeof t=="string"?Pe(t):Array.isArray(t)?t.map(e=>{if(typeof e=="string")return Pe(e);let n=e;return typeof n?.text=="string"?Pe(n.text):n?.content!=null?Os(n.content):jo(n)}).join(`
300
+ `):t==null?"":Pe(JSON.stringify(t))}function AC(t){let e=t.trim();return!!e&&Py.some(n=>n.test(e))}function TC(t){let e=t.trim();return e?Py.some(n=>{let r=n.exec(e);return!!r&&r.index===0}):!0}function OC(t){return t.replace(CC,"")}function PC(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 Ut(t){let e=OC(t).trim();return e?PC(e)??(AC(e)?"":e):""}function Fo(t){let e=_C.exec(t.trim());if(e)return{from:e[1],body:IC(e[2].replace(RC,""))}}function IC(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 Bo(t){let e=Fo(t);return e?{type:"user",text:e.body,agent:{from:e.from}}:{type:"user",text:t}}function TC(t){let e=t.message?.content;return typeof e=="string"&&!!Fo(e)}function CC(t){let e=t.message?.content;return typeof e=="string"&&e.startsWith(wy)?e.slice(wy.length).trim():void 0}function Uu(t){return t?.type==="text"&&typeof t.text=="string"?Ut(t.text):""}function PC(t){let e=t.message?.content,n=t.type==="attachment"&&t.attachment?.type==="queued_command"?Os(t.attachment.prompt):t.type==="user"&&t.isMeta&&!(Array.isArray(e)&&e.some(s=>s?.type==="tool_result"))?Os(e):"";if(!n.includes("<task-notification>"))return[];let r=[];for(let[,s]of n.matchAll(OC)){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 qu(t,e){if(typeof t=="string")return De(t);if(!t||typeof t!="object")return De(e);let n=t;if(n.type==="text"&&typeof n.file?.numLines=="number")return Ee(n.file.numLines,"line");if(n.type==="image"){let r=vy(n.file?.originalSize);return r?`image (${r})`:"image"}if(n.type==="pdf"){let r=vy(n.file?.originalSize);return r?`PDF (${r})`:"PDF"}if(n.type==="parts"&&typeof n.file?.count=="number")return Ee(n.file.count,"page");if(n.type==="file_unchanged")return"unchanged since last read";if(n.type==="create"&&typeof n.content=="string")return`created, ${Ee(n.content.split(`
304
- `).length,"line")}`;if(n.mode==="content")return Ee(n.numLines??0,"line");if(n.mode==="count")return`${Ee(n.numMatches??0,"match","matches")} (${Ee(n.numFiles??0,"file")})`;if(n.mode==="files_with_matches")return Ee(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":De(n.stdout||n.stderr||"")||"no output":typeof n.code=="number"&&typeof n.codeText=="string"?`${n.code} ${n.codeText}`:typeof n.searchCount=="number"?Ee(n.searchCount,"search","searches"):Array.isArray(n.matches)&&typeof n.total_deferred_tools=="number"?Ee(n.matches.length,"tool"):Array.isArray(n.newTodos)?Ee(n.newTodos.length,"todo"):typeof n.numFiles=="number"?Ee(n.numFiles,"file"):De(e)}function Ps(t){return!!t.isMeta}function $C(t){let e;try{e=iC(t,"r")}catch{return""}try{let r=65536;try{r=ky(t).size}catch{}let s=(c,u)=>{if(u<=0)return"";let d=Buffer.alloc(u),f=oC(e,d,0,u,c);return d.subarray(0,f).toString("utf8")},i=(c,u,d)=>{let f="";for(let p of c.split(`
305
- `)){if(!p.includes(`"${u}"`))continue;let h;try{h=JSON.parse(p)}catch{continue}let m=h?.[d];h?.type===u&&typeof m=="string"&&m&&(f=m)}return f},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 u;try{u=JSON.parse(c)}catch{continue}if(!u||Ps(u)||u.type!=="user")continue;let d=u.message?.content,f="";typeof d=="string"?f=Ut(d):Array.isArray(d)&&(f=d.map(Uu).filter(Boolean).join(" "));let p=f.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{aC(e)}}function Ju(t){let e=fn(t,"sessions"),n;try{n=xy(e)}catch{return[]}let r=[];for(let s of n)if(s.endsWith(".json"))try{let i=JSON.parse(Ey(fn(e,s),"utf8"));if(!i?.sessionId)continue;process.kill(i.pid,0),r.push(i)}catch{}return r}function Sy(t,e){return Ju(t).some(n=>n.sessionId===e)}function NC(t,e){let n=Ju(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 LC(t){return new Set(Ju(t).filter(e=>e.status==="busy").map(e=>e.sessionId))}var Ay,Fu,dC,pC,hC,by,Cy,vC,xC,EC,wy,OC,_C,RC,IC,vy,nr,Uo=S(()=>{"use strict";Cs();Mo();Do();Io();Ay=t=>t.type==="user"&&Array.isArray(t.message?.content)&&t.message.content.some(e=>e?.type==="tool_result");Fu=(t,e)=>fn(t,"projects",uC(e)),dC="subagents";pC="general-purpose",hC=[256*1024,4*1024*1024,64*1024*1024],by=new Map;Cy=[/\[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];vC=/<ide_[a-z_]+>[\s\S]*?<\/ide_[a-z_]+>/gi;xC=/^(?:[^\n<][^\n]*\n)?<agent-message from="([^"]+)">\n([\s\S]*?)(?:\n?<\/agent-message>[\s\S]*)?$/,EC=/^\[[^\]\n]+\][\s\S]*?The report follows:\n/;wy=`The coordinator sent a message while you were working:
307
- `;OC=/<task-notification>([\s\S]*?)<\/task-notification>/g;_C=/^(Command running in background with ID|Command did not complete within its \d+s timeout and was moved to the background|Async agent launched)/,RC=/\bID: ([A-Za-z0-9]+)/,IC=new Set(["TaskStop","KillShell"]),vy=t=>typeof t!="number"?"":t<1024?`${t}B`:t<1048576?`${Math.round(t/1024)}KB`:`${(t/1048576).toFixed(1)}MB`;nr=class extends Ft{constructor(n=fn(cC(),".claude")){super();this.root=n}displayName="Claude Mirror";detectsSelf(){return process.env.CLAUDECODE==="1"}detectsInstalled(){return lC(this.root)}sessionsDir(n){return Fu(this.root,n)}listSessionFiles(n){return Lo(Fu(this.root,n))}listChildren(n,r){return fC(this.root,n,r)}callerSessionId(){return process.env.CLAUDE_CODE_SESSION_ID||void 0}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:Ay(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=CC(n);if(s)return{events:[Bo(s)]};let i=PC(n);if(i.length)return{events:i};if(Ps(n)&&!TC(n))return{events:[]};let o=[];if(n.type==="user"){let a=n.message?.content;if(typeof a=="string"){let l=Ut(a);l&&o.push(Bo(l))}else if(Array.isArray(a))for(let l of a)if(l?.type==="tool_result"){let c=Os(l.content),u=l.is_error?/^Exit code (\d+)/.exec(c)?.[1]:void 0,d=n.toolUseResult,f=_C.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:qu(n.toolUseResult,c),exit:u===void 0?void 0:Number(u),background:f||void 0,task:f?RC.exec(c)?.[1]??ee(d?.backgroundTaskId):void 0,output:f?/Output is being written to: (\S.*?)\.?\s*$/m.exec(c)?.[1]:void 0,refused:!!l.is_error&&u===void 0||void 0})}else{let c=Uu(l)||jo(l);c&&o.push(Bo(c))}return{events:o}}if(n.type==="attachment"&&n.attachment?.type==="queued_command"){let a=Ut(Os(n.attachment.prompt));return a&&o.push(Bo(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=>!wC(h)).join(""),u=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||u||d.length){let h=Date.parse(n.timestamp??""),m=!isNaN(h)&&h>=r;o.push({type:"assistant",text:c,thinking:u,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(IC.has(h.name)){let m=ee(h.input.task_id)??ee(h.input.shell_id);m&&o.push({type:"task_done",task:m,outcome:"stopped"})}let f=n.message?.usage??n.usage,p=f&&{in:f.input_tokens??0,out:f.output_tokens??0,cached:f.cache_read_input_tokens??0,cacheCreate:f.cache_creation_input_tokens??0};return{events:o,usage:p,model:n.message?.model}}return{events:o}}chainWorking(n){return Ty(n)}sessionAlive(n){return Sy(this.root,n)}sessionEnded(n){return!Sy(this.root,n)}sessionsWorking(n){return LC(this.root)}readPreview(n){return $C(n)}searchText(n){if(!n||Ps(n)||n.type!=="user"&&n.type!=="assistant")return"";let r=n.message?.content,s="";if(typeof r=="string")s=Ut(r);else if(Array.isArray(r)){let i=r;s=n.type==="user"?i.map(Uu).filter(Boolean).join(" "):i.filter(o=>o.type==="text"&&typeof o.text=="string").map(o=>o.text).join(" ")}return s.replace(/\s+/g," ").trim()}}});import{spawn as MC,execFile as DC}from"child_process";import{promisify as BC}from"util";import{randomBytes as Py}from"crypto";async function FC(){let t;try{t=(await jC("codex",["app-server","daemon","version"],{shell:!0,timeout:_y})).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 Oy(t){let e=Buffer.from(t),n=Py(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 Ry(){let t=await FC(),e=new Wu(MC(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 Ku(){let t=await Ry();try{return(await t.call("thread/loaded/list",{})).data??[]}finally{t.close()}}async function Iy(t,e,n){let r=await Ry();try{await r.call("turn/start",{threadId:t,input:[],toolOutput:{name:e,output:n},turnTrigger:"typebulb"})}finally{r.close()}}var jC,_y,Wu,$y=S(()=>{"use strict";jC=BC(DC),_y=15e3;Wu=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)),e.on("exit",()=>{let s=this.#n.trim().split(`
303
+ `):t}function Bo(t){let e=Fo(t);return e?{type:"user",text:e.body,agent:{from:e.from}}:{type:"user",text:t}}function $C(t){let e=t.message?.content;return typeof e=="string"&&!!Fo(e)}function NC(t){let e=t.message?.content;return typeof e=="string"&&e.startsWith(Sy)?e.slice(Sy.length).trim():void 0}function Uu(t){return t?.type==="text"&&typeof t.text=="string"?Ut(t.text):""}function MC(t){let e=t.message?.content,n=t.type==="attachment"&&t.attachment?.type==="queued_command"?Os(t.attachment.prompt):t.type==="user"&&t.isMeta&&!(Array.isArray(e)&&e.some(s=>s?.type==="tool_result"))?Os(e):"";if(!n.includes("<task-notification>"))return[];let r=[];for(let[,s]of n.matchAll(LC)){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 qu(t,e){if(typeof t=="string")return De(t);if(!t||typeof t!="object")return De(e);let n=t;if(n.type==="text"&&typeof n.file?.numLines=="number")return Ee(n.file.numLines,"line");if(n.type==="image"){let r=ky(n.file?.originalSize);return r?`image (${r})`:"image"}if(n.type==="pdf"){let r=ky(n.file?.originalSize);return r?`PDF (${r})`:"PDF"}if(n.type==="parts"&&typeof n.file?.count=="number")return Ee(n.file.count,"page");if(n.type==="file_unchanged")return"unchanged since last read";if(n.type==="create"&&typeof n.content=="string")return`created, ${Ee(n.content.split(`
304
+ `).length,"line")}`;if(n.mode==="content")return Ee(n.numLines??0,"line");if(n.mode==="count")return`${Ee(n.numMatches??0,"match","matches")} (${Ee(n.numFiles??0,"file")})`;if(n.mode==="files_with_matches")return Ee(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":De(n.stdout||n.stderr||"")||"no output":typeof n.code=="number"&&typeof n.codeText=="string"?`${n.code} ${n.codeText}`:typeof n.searchCount=="number"?Ee(n.searchCount,"search","searches"):Array.isArray(n.matches)&&typeof n.total_deferred_tools=="number"?Ee(n.matches.length,"tool"):Array.isArray(n.newTodos)?Ee(n.newTodos.length,"todo"):typeof n.numFiles=="number"?Ee(n.numFiles,"file"):De(e)}function Ps(t){return!!t.isMeta}function FC(t){let e;try{e=fC(t,"r")}catch{return""}try{let r=65536;try{r=Ey(t).size}catch{}let s=(c,u)=>{if(u<=0)return"";let d=Buffer.alloc(u),f=pC(e,d,0,u,c);return d.subarray(0,f).toString("utf8")},i=(c,u,d)=>{let f="";for(let p of c.split(`
305
+ `)){if(!p.includes(`"${u}"`))continue;let m;try{m=JSON.parse(p)}catch{continue}let h=m?.[d];m?.type===u&&typeof h=="string"&&h&&(f=h)}return f},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 u;try{u=JSON.parse(c)}catch{continue}if(!u||Ps(u)||u.type!=="user")continue;let d=u.message?.content,f="";typeof d=="string"?f=Ut(d):Array.isArray(d)&&(f=d.map(Uu).filter(Boolean).join(" "));let p=f.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{hC(e)}}function Ju(t){let e=fn(t,"sessions"),n;try{n=Ay(e)}catch{return[]}let r=[];for(let s of n)if(s.endsWith(".json"))try{let i=JSON.parse(Ty(fn(e,s),"utf8"));if(!i?.sessionId)continue;process.kill(i.pid,0),r.push(i)}catch{}return r}function xy(t,e){return Ju(t).some(n=>n.sessionId===e)}function UC(t,e){let n=Ju(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 qC(t){return new Set(Ju(t).filter(e=>e.status==="busy").map(e=>e.sessionId))}var Cy,Fu,bC,vC,SC,vy,Py,CC,_C,RC,Sy,LC,DC,BC,jC,ky,tr,Uo=v(()=>{"use strict";Cs();Mo();Do();Io();Cy=t=>t.type==="user"&&Array.isArray(t.message?.content)&&t.message.content.some(e=>e?.type==="tool_result");Fu=(t,e)=>fn(t,"projects",yC(e)),bC="subagents";vC="general-purpose",SC=[256*1024,4*1024*1024,64*1024*1024],vy=new Map;Py=[/\[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];CC=/<ide_[a-z_]+>[\s\S]*?<\/ide_[a-z_]+>/gi;_C=/^(?:[^\n<][^\n]*\n)?<agent-message from="([^"]+)">\n([\s\S]*?)(?:\n?<\/agent-message>[\s\S]*)?$/,RC=/^\[[^\]\n]+\][\s\S]*?The report follows:\n/;Sy=`The coordinator sent a message while you were working:
307
+ `;LC=/<task-notification>([\s\S]*?)<\/task-notification>/g;DC=/^(Command running in background with ID|Command did not complete within its \d+s timeout and was moved to the background|Async agent launched)/,BC=/\bID: ([A-Za-z0-9]+)/,jC=new Set(["TaskStop","KillShell"]),ky=t=>typeof t!="number"?"":t<1024?`${t}B`:t<1048576?`${Math.round(t/1024)}KB`:`${(t/1048576).toFixed(1)}MB`;tr=class extends Ft{constructor(n=fn(gC(),".claude")){super();this.root=n}displayName="Claude Mirror";detectsSelf(){return process.env.CLAUDECODE==="1"}detectsInstalled(){return mC(this.root)}sessionsDir(n){return Fu(this.root,n)}listSessionFiles(n){return Lo(Fu(this.root,n))}listChildren(n,r){return wC(this.root,n,r)}callerSessionId(){return process.env.CLAUDE_CODE_SESSION_ID||void 0}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:Cy(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=NC(n);if(s)return{events:[Bo(s)]};let i=MC(n);if(i.length)return{events:i};if(Ps(n)&&!$C(n))return{events:[]};let o=[];if(n.type==="user"){let a=n.message?.content;if(typeof a=="string"){let l=Ut(a);l&&o.push(Bo(l))}else if(Array.isArray(a))for(let l of a)if(l?.type==="tool_result"){let c=Os(l.content),u=l.is_error?/^Exit code (\d+)/.exec(c)?.[1]:void 0,d=n.toolUseResult,f=DC.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:qu(n.toolUseResult,c),exit:u===void 0?void 0:Number(u),background:f||void 0,task:f?BC.exec(c)?.[1]??Z(d?.backgroundTaskId):void 0,output:f?/Output is being written to: (\S.*?)\.?\s*$/m.exec(c)?.[1]:void 0,refused:!!l.is_error&&u===void 0||void 0})}else{let c=Uu(l)||jo(l);c&&o.push(Bo(c))}return{events:o}}if(n.type==="attachment"&&n.attachment?.type==="queued_command"){let a=Ut(Os(n.attachment.prompt));return a&&o.push(Bo(a)),{events:o}}if(n.type==="assistant"){let a=n.message?.content,l=Array.isArray(a)?a:[],c=l.filter(m=>m.type==="text").map(m=>m.text??"").filter(m=>!TC(m)).join(""),u=l.filter(m=>m.type==="thinking").map(m=>m.thinking??"").join(`
308
+ `),d=l.filter(m=>m.type==="tool_use").map(m=>({id:m.id??"",name:m.name??"",input:m.input??{}}));if(c||u||d.length){let m=Date.parse(n.timestamp??""),h=!isNaN(m)&&m>=r;o.push({type:"assistant",text:c,thinking:u,tools:d,live:h,error:n.isApiErrorMessage||void 0})}(n.message?.stop_reason==="end_turn"||d.some(m=>m.name==="SubagentHandback"))&&o.push({type:"turn_end"});for(let m of d)if(jC.has(m.name)){let h=Z(m.input.task_id)??Z(m.input.shell_id);h&&o.push({type:"task_done",task:h,outcome:"stopped"})}let f=n.message?.usage??n.usage,p=f&&{in:f.input_tokens??0,out:f.output_tokens??0,cached:f.cache_read_input_tokens??0,cacheCreate:f.cache_creation_input_tokens??0};return{events:o,usage:p,model:n.message?.model}}return{events:o}}chainWorking(n){return Oy(n)}sessionAlive(n){return xy(this.root,n)}sessionEnded(n){return!xy(this.root,n)}sessionsWorking(n){return qC(this.root)}readPreview(n){return FC(n)}searchText(n){if(!n||Ps(n)||n.type!=="user"&&n.type!=="assistant")return"";let r=n.message?.content,s="";if(typeof r=="string")s=Ut(r);else if(Array.isArray(r)){let i=r;s=n.type==="user"?i.map(Uu).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 _y(t){let e=$y(t),n=e.map(Iy);return e.length&&n.every(r=>r!==void 0)?n:void 0}function Ry(t){let e=new Map,n=[];for(let r of $y(t)){let s=/^\$([\w:]+)\s*=\s*(['"])([^'"]*)\2$/.exec(r);if(s){e.set(s[1].toLowerCase(),s[3]);continue}let i=Iy(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 Iy(t){let[e,...n]=t.split("|");if(!n.every(i=>HC.test(i.trim())))return;let r=zC(e);if(!JC.test(r[0]??""))return;let s=[];for(let i=1;i<r.length;i++){let o=r[i];if(WC.test(o)){i+1<r.length&&s.push(r[++i]);continue}if(KC.test(o)){i++;continue}o.startsWith("-")||/^\d+(,\d+)?p?$/.test(o)||s.push(o)}return s.length===1?s[0]:void 0}function $y(t){let e=[],n=0;for(let r=0;r<t.length;r++){let s=t[r];if(s==='"'||s==="'"){let o=t.indexOf(s,r+1);if(o<0)break;r=o;continue}let i=t.slice(r,r+2);(s===";"||s===`
309
+ `||i==="&&"||i==="||")&&(e.push(t.slice(n,r)),(i==="&&"||i==="||")&&r++,n=r+1)}return e.push(t.slice(n)),e.map(r=>r.trim()).filter(Boolean)}function zC(t){return(t.match(/'[^']*'|"[^"]*"|\S+/g)??[]).map(e=>/^(['"])(.*)\1$/.exec(e)?.[2]??e)}var JC,WC,KC,HC,Wu=v(()=>{"use strict";JC=/^(Get-Content|gc|cat|type|nl|bat|sed|head|tail)$/i,WC=/^-(Path|LiteralPath)$/i,KC=/^-(Encoding|TotalCount|Head|Tail|ReadCount|Delimiter)$/i,HC=/^(sed -n|head|tail|Select-Object|select)(\s|$)/i});import{spawn as YC,execFile as VC}from"child_process";import{promisify as GC}from"util";import{randomBytes as Ly}from"crypto";async function QC(){let t;try{t=(await XC("codex",["app-server","daemon","version"],{shell:!0,timeout:My})).stdout}catch(n){let r=n,s=(r.stderr||r.message||"").trim().split(`
310
+ `).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 Ny(t){let e=Buffer.from(t),n=Ly(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 Dy(){let t=await QC(),e=new Ku(YC(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 Hu(){let t=await Dy();try{return(await t.call("thread/loaded/list",{})).data??[]}finally{t.close()}}async function By(t,e,n){let r=await Dy();try{await r.call("turn/start",{threadId:t,input:[],toolOutput:{name:e,output:n},turnTrigger:"typebulb"})}finally{r.close()}}var XC,My,Ku,jy=v(()=>{"use strict";XC=GC(VC),My=15e3;Ku=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)),e.on("exit",()=>{let s=this.#n.trim().split(`
310
311
  `).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
312
  Host: localhost\r
312
313
  Upgrade: websocket\r
313
314
  Connection: Upgrade\r
314
- Sec-WebSocket-Key: ${Py(16).toString("base64")}\r
315
+ Sec-WebSocket-Key: ${Ly(16).toString("base64")}\r
315
316
  Sec-WebSocket-Version: 13\r
316
317
  \r
317
318
  `)}#t=new Map;#o=1;#e=Buffer.alloc(0);#s=!1;#u;#n="";#c(e,n){if(this.#e=Buffer.concat([this.#e,e]),!this.#s){let r=this.#e.indexOf(`\r
318
319
  \r
319
- `);if(r<0)return;this.#s=!0,this.#e=this.#e.subarray(r+4),n()}for(;;){if(this.#e.length<2)return;let r=this.#e[1]&127,s=2;if(r===126){if(this.#e.length<4)return;r=this.#e.readUInt16BE(2),s=4}else if(r===127){if(this.#e.length<10)return;r=Number(this.#e.readBigUInt64BE(2)),s=10}if(this.#e.length<s+r)return;let i=this.#e[0]&15,o=this.#e.subarray(s,s+r).toString();if(this.#e=this.#e.subarray(s+r),i===1)try{let a=JSON.parse(o);a.id!==void 0&&!a.method&&this.#t.has(a.id)&&(this.#t.get(a.id)(a),this.#t.delete(a.id))}catch{}}}async call(e,n){await this.#u;let r=this.#o++,s=await new Promise((i,o)=>{this.#t.set(r,i),setTimeout(()=>o(new Error(`no reply to ${e}`)),_y),this.proc.stdin.write(Oy(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(Oy(JSON.stringify({jsonrpc:"2.0",method:e})))}close(){this.proc.kill()}}});import{statSync as qo,readdirSync as UC,existsSync as qC}from"fs";import{basename as Ny,join as Hu,resolve as JC}from"path";import{homedir as Ly}from"os";function KC(t){let e=t.trimStart();return WC.some(n=>e.startsWith(n))}function rr(t,e){return Array.isArray(t)?t.map(n=>typeof n?.text=="string"?e&&KC(n.text)?"":Pe(n.text):n?.type==="input_image"&&typeof n.image_url=="string"&&n.image_url.startsWith("data:")?`![image](${n.image_url})`:"").filter(Boolean).join(`
320
- `):""}function HC(t){return typeof t=="string"?Pe(t):rr(t,!1)}function zC(t,e){let n=e??"",r=iO(n);if(!r.length)return{name:t,input:{script:n}};let s=r.map(i=>zu(i.fn)&&_s(i.arg)?tO(String(i.arg.cmd??i.arg.command??"")):void 0);if(s.every(i=>i!==void 0))return{name:"read",input:My(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}=Dy(o);return{name:i,input:new Set(a).size===1?{path:a[0],patch:l}:{patch:l},pending:{kind:"patch",digest:GC(l)}}}return _s(o)?zu(i)?{name:t,input:VC(o)}:{name:i,input:o}:typeof o=="string"?{name:i,input:{arg:o}}:{name:t,input:{script:n}}}return{name:t,input:My(r.map(({fn:i,arg:o})=>i==="apply_patch"&&typeof o=="string"?["patch",Dy(o).diff]:zu(i)&&_s(o)?["command",o.cmd??o.command]:[i,o]))}}function VC(t){let e=Object.fromEntries(Object.entries(t).filter(([r])=>r!=="cmd"&&r!=="command"&&!YC.has(r))),n=t.command??t.cmd;return n===void 0?e:{command:n,...e}}function My(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 GC(t){let e=0,n=0;for(let r of t.split(`
321
- `))r.startsWith("+")&&!r.startsWith("+++")?e++:r.startsWith("-")&&!r.startsWith("---")&&n++;return`+${e} \u2212${n}`}function tO(t){let e=rO(t),n=e.map(nO);return e.length&&n.every(r=>r!==void 0)?n:void 0}function nO(t){let[e,...n]=t.split("|");if(!n.every(i=>eO.test(i.trim())))return;let r=sO(e);if(!XC.test(r[0]??""))return;let s=[];for(let i=1;i<r.length;i++){let o=r[i];if(QC.test(o)){i+1<r.length&&s.push(r[++i]);continue}if(ZC.test(o)){i++;continue}o.startsWith("-")||/^\d+(,\d+)?p?$/.test(o)||s.push(o)}return s.length===1?s[0]:void 0}function rO(t){let e=[],n=0;for(let r=0;r<t.length;r++){let s=t[r];if(s==='"'||s==="'"){let o=t.indexOf(s,r+1);if(o<0)break;r=o;continue}let i=t.slice(r,r+2);(s===";"||s===`
322
- `||i==="&&"||i==="||")&&(e.push(t.slice(n,r)),(i==="&&"||i==="||")&&r++,n=r+1)}return e.push(t.slice(n)),e.map(r=>r.trim()).filter(Boolean)}function sO(t){return(t.match(/'[^']*'|"[^"]*"|\S+/g)??[]).map(e=>/^(['"])(.*)\1$/.exec(e)?.[2]??e)}function iO(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=Jy(t,s);if(i<0)break;e.push({fn:r[1],arg:qy(t.slice(s+1,i).trim(),t)}),n.lastIndex=i+1}return e}function qy(t,e){let n=t[0];if(n==='"'||n==="'"||n==="`")return Wo(t,0)===t.length-1?Wy(t.slice(1,-1)):t;if(n==="{"){for(let r of[t,aO(t)])try{let s=JSON.parse(r);if(_s(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==="`"?Wo(e,s):i==="{"?Jy(e,s):-1;if(o>s)return qy(e.slice(s,o+1),"")}}return t}function Jy(t,e){let n=0;for(let r=e;r<t.length;r++){let s=t[r];if(s==='"'||s==="'"||s==="`"){if(r=Wo(t,r),r<0)return-1}else if(s==="("||s==="["||s==="{")n++;else if((s===")"||s==="]"||s==="}")&&--n===0)return r}return-1}function Wo(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 Wy(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)):oO[i]??i)}function aO(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=Wo(t,i);if(l<0)return t;r+=JSON.stringify(Wy(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 Dy(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 lO(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:De(t)};let r=n[3].replace(/^\n+/,"").replace(/^Script error:\n/,""),s=n[1]==="failed",i=cO(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:Ee(uO(r),"line")}:e?.kind==="patch"&&!s?{content:e.digest,isError:s,digest:e.digest}:{content:r,isError:s,digest:De(r),exit:o}}function cO(t){if(t.startsWith("{"))try{let e=JSON.parse(t);if(_s(e)&&typeof e.output=="string")return{output:e.output,exit_code:typeof e.exit_code=="number"?e.exit_code:void 0}}catch{}}function dO(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 pO(t){let e,n,r;for(let s of fO){let i=No(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 u=Date.parse(c.timestamp??"");Number.isNaN(u)||(a=u)}if(e===void 0&&c.type==="event_msg"){let u=c.payload?.type;u==="task_started"?e=!0:(u==="task_complete"||u==="turn_aborted")&&(e=!1)}if(n===void 0&&c.type==="event_msg"&&c.payload?.type==="token_count"&&c.payload.info?.last_token_usage){let u=Ky(c.payload.info.last_token_usage);n=u.in+u.out+u.cached+u.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 Ky(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 jy(t){let n=tr(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=hO(i,o),l=Uy(n.text,r),c=a&&!l&&n.bytes>=65536?tr(t,Fy):void 0,u=l??(c&&Uy(c.text,r)),d=!!a&&!u&&(c??n).bytes<(c?Fy:65536);return{cwd:i.cwd,subagent:!!o,id:i.id,spawn:a,turn:u,modelPending:d}}catch{return{cwd:"",subagent:!1}}}function hO(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 Uy(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 WC,_s,zu,YC,XC,QC,ZC,eO,oO,uO,Jo,By,Yu,sr,fO,Fy,Vu=S(()=>{"use strict";Cs();Do();Mo();$y();WC=["<permissions instructions>","<apps_instructions>","<plugins_instructions>","<skills_instructions>","<recommended_plugins>","<environment_context>","<node_repl_review_evidence>","# AGENTS.md instructions for "];_s=t=>!!t&&typeof t=="object"&&!Array.isArray(t),zu=t=>t==="shell_command"||t==="exec_command",YC=new Set(["max_output_tokens","yield_time_ms","timeout_ms"]);XC=/^(Get-Content|gc|cat|type|nl|bat|sed|head|tail)$/i,QC=/^-(Path|LiteralPath)$/i,ZC=/^-(Encoding|TotalCount|Head|Tail|ReadCount|Delimiter)$/i,eO=/^(sed -n|head|tail|Select-Object|select)(\s|$)/i;oO={n:`
327
- `,t:" ",r:"\r",b:"\b",f:"\f",v:"\v",0:"\0"};uO=t=>t?t.replace(/\r?\n$/,"").split(`
328
- `).length:0;Jo=t=>{let e=JC(t);return process.platform==="win32"?e.toLowerCase():e},By=12e4,Yu=t=>t.slice(-36),sr=class t extends Ft{constructor(n=Hu(Ly(),".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 Ku()).includes(Yu(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 Ku()).includes(Yu(n)))throw new Error("the Codex session is not loaded by its app server now");await Iy(Yu(n),r,s)}detectsInstalled(){return qC(Hu(Ly(),".codex"))}sessionsDir(n){return this.root}listSessionFiles(n){let r=Jo(n),s=[];for(let i of this.#f()){let o=0,a=0;try{let u=qo(i);if(!u.isFile())continue;o=u.size,a=u.mtimeMs}catch{continue}let l=this.#n.get(i);if(l===void 0){if(l=jy(i),l===void 0)continue;this.#n.set(i,l)}if(l.subagent||Jo(l.cwd)!==r)continue;let c=Ny(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=Jo(n),i=new Map,o;for(let c of this.#f()){let u=0,d=0,f;try{let v=qo(c);if(!v.isFile())continue;u=v.size,d=v.mtimeMs,f=v.birthtimeMs||void 0}catch{continue}let p=this.#n.get(c);if(p===void 0||p.modelPending){if(p=jy(c),p===void 0)continue;this.#n.set(c,p)}if(Ny(c,".jsonl")===r&&(o=p.id),!p.spawn||Jo(p.cwd)!==s)continue;let{running:h,tokens:m,turn:g}=this.#i(c,u,d);i.set(p.spawn.id,{file:c,mtime:this.#r(c,u,d),started:f,running:h,tokens:m,spawn:p.spawn,turn:g??p.turn})}if(!o)return[];let a=(c,u=new Set)=>{if(c.parent===o)return!0;if(u.has(c.id))return!1;u.add(c.id);let d=i.get(c.parent);return d?a(d.spawn,u):!1},l=[];for(let{file:c,mtime:u,started:d,running:f,tokens:p,spawn:h,turn:m}of i.values())a(h)&&l.push({id:h.id,file:c,mtime:u,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:f});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>=By)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=pO(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 UC(s).map(i=>Hu(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=rr(i.content,!0).trim();a&&s.push({type:"user",text:a})}else if(i.role==="assistant"){let a=rr(i.content,!1);a&&s.push({type:"assistant",text:a,thinking:"",tools:[],live:o()})}return{events:s}}if(i.type==="reasoning"){let a=rr(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"?zC(i.name??"",i.input):{name:i.name??"",input:dO(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,...lO(HC(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:Ky(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<By}readPreview(n){for(let r of(tr(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"?rr(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"?"":rr(n.payload.content,r==="user").replace(/\s+/g," ").trim()}},fO=[64*1024,1024*1024];Fy=512*1024});import{realpathSync as mO}from"fs";import{createHash as gO}from"crypto";import{join as Ko,resolve as yO}from"path";import{homedir as bO}from"os";function Ge(){let t=process.env.TYPEBULB_SERVERS_DIR;return t?Ko(t,".."):Ko(bO(),".typebulb")}function ht(){Hy||(Hy=!0,console.error(`${Ge()} not writable \u2014 continuing stateless: ports won't stick, caches stay cold, and typebulb logs/wait/send/stop may not see this run`))}function mt(){return process.env.TYPEBULB_SERVERS_DIR||Ko(Ge(),"servers")}function zy(t){let e=oe(t),n=e.slice(e.lastIndexOf("/")+1).replace(/\.bulb\.md$/,"");return Ko(Ge(),"canvas",`${n}-${Rs(t)}.png`)}function Rs(t){return gO("sha1").update(oe(t)).digest("hex").slice(0,8)}function oe(t){let e=yO(t),n=e;try{n=mO.native(e)}catch{}return(process.platform==="win32"?n.toLowerCase():n).replace(/\\/g,"/")}function Yy(t,e){let n=oe(t),r=oe(e);return n.startsWith(r.endsWith("/")?r:r+"/")?!n.includes("/node_modules/"):!1}var Hy,Be=S(()=>{"use strict";Hy=!1});import*as Xy from"net";import{mkdir as wO,readFile as vO,writeFile as Qy}from"fs/promises";import{existsSync as SO}from"fs";import{join as Zy}from"path";function nb(){return Zy(Ge(),"blocks")}function Gu(t){return Zy(nb(),`${t}.json`)}function zo(t){return new Promise(e=>{let n=Xy.createServer();n.once("error",()=>e(!1)),n.listen(t,"127.0.0.1",()=>n.close(()=>e(!0)))})}async function AO(t){for(let e=t;e<65535;e++)if(await zo(e))return e;throw new Error(`No free port found above ${t}`)}async function Xu(t){let{listBulbServers:e}=await Promise.resolve().then(()=>(je(),rb)),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 Yo(t){try{let e=JSON.parse(await vO(Gu(t),"utf8"));return e&&typeof e.cwd=="string"?{cwd:e.cwd,slots:e.slots??{},mirrors:e.mirrors??{}}:void 0}catch{return}}async function Vo(t,e){try{return await Qy(Gu(t),JSON.stringify(e,null,2)),!0}catch{return ht(),!1}}async function TO(t){let e=oe(t);try{await wO(nb(),{recursive:!0})}catch{return}let n=[];for(let o=0;o<tb;o++)n.push(eb+o*pn);let r=await Promise.all(n.map(async o=>({base:o,block:await Yo(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 Qy(Gu(o),JSON.stringify(s,null,2),{flag:"wx"}),o}catch(l){if((await Yo(o))?.cwd===e)return o;l.code!=="EEXIST"&&ht();continue}if(!SO(a.cwd))return await Vo(o,s)?o:void 0}let i=r.filter(o=>!!o.block).sort((o,a)=>Vy(o.block)-Vy(a.block))[0];if(i)return await Vo(i.base,s)?i.base:void 0}function Vy(t){return Object.values(t.slots).reduce((e,n)=>Math.max(e,n.usedAt??0),0)}async function CO(t,e){let n=await Yo(t)??{cwd:"",slots:{},mirrors:{}};if(e.kind==="mirror"){let i=n.mirrors[e.agent];if(i!==void 0)return i;let o=Gy(n),a=o.has(0)?xO:0;for(;a>Ho&&o.has(a);)a--;return n.mirrors[e.agent]=a,await Vo(t,n),a}let r=oe(e.file),s=n.slots[r]?.offset;if(s===void 0){let i=Gy(n);for(s=Ho;s<pn&&i.has(s);)s++;if(s>=pn){let o=Object.entries(n.slots).sort((a,l)=>(a[1].usedAt??0)-(l[1].usedAt??0))[0];s=o?o[1].offset:Ho,o&&delete n.slots[o[0]]}}return n.slots[r]={offset:s,usedAt:Date.now()},await Vo(t,n),s}function Gy(t){return new Set([...Object.values(t.mirrors),...Object.values(t.slots).map(e=>e.offset)])}async function ir(t,e){let n=await TO(e);return n===void 0?void 0:n+await CO(n,t)}async function hn(t){let e=oe(t);for(let n=0;n<tb;n++){let r=await Yo(eb+n*pn);if(r?.cwd===e)return s=>r.slots[oe(s)]?.usedAt??0}return()=>0}async function Go(t){if(t.explicit!==void 0)return await zo(t.explicit)||await Xu(t.explicit),t.target.kind==="bulb"&&await ir(t.target,t.cwd),{port:t.explicit};let e=await ir(t.target,t.cwd);if(e!==void 0){let r=e-e%pn,s=Date.now()+EO;do{if(await zo(e))return{port:e};await new Promise(i=>setTimeout(i,150))}while(Date.now()<s);for(let i=Ho;i<pn;i++){let o=r+i;if(o!==e&&await zo(o))return{port:o,note:`(slot ${e} was busy)`}}}return{port:await AO(kO),note:e===void 0?"(no port block available)":"(this project's block was full)"}}var eb,pn,tb,kO,Ho,xO,EO,mn=S(()=>{"use strict";Be();eb=20100,pn=100,tb=19,kO=23e3,Ho=1,xO=pn-1,EO=3e3});var Ae,Xo=S(()=>{"use strict";Ae="0.62.1"});var rb={};Ai(rb,{agentViewerCommand:()=>pb,bulbServerCommand:()=>fb,clearServerLog:()=>nd,findProjectViewer:()=>ea,isAlive:()=>or,isMirror:()=>ye,isProjectBulb:()=>ad,isProjectMirror:()=>cr,launchAgentViewer:()=>Ns,launchBulbServer:()=>bn,listBulbServers:()=>G,probePageCount:()=>cd,readServerLog:()=>Xe,readWaitCursor:()=>Zo,recordDenial:()=>od,registerServer:()=>id,relayOpen:()=>ld,runMarker:()=>rd,serverLogPath:()=>lr,serversForBulb:()=>yn,sliceRunLog:()=>sd,startServerLog:()=>$s,stopBulbServer:()=>ar,stopServer:()=>gt,stopServersForBulb:()=>ta,typebulbBinPath:()=>ur,unregisterServer:()=>gn,writeWaitCursor:()=>Is});import{spawn as sb}from"child_process";import{readdir as OO,readFile as ab,writeFile as lb,unlink as Qu,mkdir as PO}from"fs/promises";import{mkdirSync as cb,writeFileSync as Qo,appendFileSync as _O,readFileSync as Zu}from"fs";import*as _e from"path";import{fileURLToPath as RO}from"url";function ed(t){return _e.join(mt(),`${t}.json`)}function lr(t){return _e.join(mt(),`${t}.log`)}function td(t){return _e.join(mt(),`${t}.wait.json`)}function ub(t){try{let e=JSON.parse(Zu(td(t),"utf8"));return e.cursors&&typeof e.cursors=="object"?e.cursors:{}}catch{return{}}}function Zo(t,e=""){let n=ub(t)[e];return typeof n=="number"&&Number.isFinite(n)&&n>=0?n:void 0}function Is(t,e,n=""){try{cb(mt(),{recursive:!0});let r=ub(t);r[n]=e,Qo(td(t),JSON.stringify({cursors:r}))}catch{}}function $s(t){let e=lr(t);try{cb(mt(),{recursive:!0}),Qo(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(_O(e,l),s+=l.length,s>2*ib){let c=Zu(e),u=c.subarray(Math.max(0,c.length-ib));Qo(e,u),s=u.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 nd(t){try{Qo(lr(t),"")}catch{}}function Xe(t,e=0){try{let n=Zu(lr(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 rd(t){return`\u2500\u2500 run ${t} \u2500\u2500 ${new Date().toTimeString().slice(0,8)}`}function $O(t){let e=IO.exec(t);return e?Number(e[1]):void 0}function sd(t,e){let n=t.split(`
330
- `),r=[];if(n.forEach((o,a)=>{let l=$O(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 or(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}async function id(t){try{await PO(mt(),{recursive:!0}),await lb(ed(t.pid),JSON.stringify({version:Ae,...t}))}catch{ht()}}async function od(t,e){let n=ed(t);try{let r=JSON.parse(await ab(n,"utf8"));if(r.denied===e)return;r.denied=e,await lb(n,JSON.stringify(r))}catch{}}async function gn(t){await Qu(ed(t)).catch(()=>{}),await Qu(lr(t)).catch(()=>{}),await Qu(td(t)).catch(()=>{})}function ye(t){return t.agent!=null}function cr(t,e){return ye(t)&&t.cwd!=null&&oe(t.cwd)===oe(e)}function ad(t,e){return!ye(t)&&Yy(t.file,e)}async function G(t){let e;try{e=await OO(mt())}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 ab(_e.join(mt(),s),"utf8"))}catch{await gn(i);return}o&&typeof o.pid=="number"&&or(o.pid)?n.push(o):await gn(i)})),(t?n.filter(s=>ad(s,t)):n).sort((s,i)=>s.startedAt-i.startedAt)}async function ea(t,e){return(await G()).find(n=>cr(n,t)&&(e?n.agent===e:!0))}async function ld(t,e){let n=new URL(t).port,r=(await G()).filter(a=>String(a.port)!==n),s=r.filter(a=>cr(a,e)),i=r.filter(a=>ad(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:u}=await l.json();if(c)return{where:"editor",via:a.agent?"the agent mirror":`${_e.basename(a.file)}'s page`};ye(a)&&(o+=u??0)}catch{}return o>0?{where:"external"}:void 0}async function ar(t){try{process.kill(t,"SIGTERM")}catch{}await gn(t)}async function cd(t){try{let e=await fetch(`${t.url}/__pages`,{signal:AbortSignal.timeout(NO)});if(!e.ok)return;let{pages:n}=await e.json();return typeof n=="number"?n:void 0}catch{return}}async function gt(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(ob)});if(!n.ok)throw new Error(`/__stop ${n.status}`);let{closed:r=0,stuck:s=0}=await n.json(),i=Date.now()+ob;for(;or(t.pid)&&Date.now()<i;)await db(100);return or(t.pid)?(await ar(t.pid),"killed"):(await gn(t.pid),{closed:r,stuck:s})}catch{return await ar(t.pid),"killed"}}function yn(t,e){let n=oe(e);return t.filter(r=>!ye(r)&&r.pid!==process.pid&&oe(r.file)===n)}async function ta(t,e){let n=yn(await G(),t);for(let r of n)await gt(r,e!==void 0&&r.port===e?"keep":"close");return n}function LO(t,e,n){(process.platform==="win32"?sb("cmd",["/c","start","","/b",t,...e],{cwd:n,stdio:"ignore",windowsHide:!0}):sb(t,e,{cwd:n,detached:!0,stdio:"ignore"})).unref()}function ur(){return _e.join(_e.dirname(RO(import.meta.url)),"index.js")}function fb(t,e={}){return{command:process.execPath,args:[ur(),...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 pb(t){return{command:process.execPath,args:[ur(),`agent:${t}`,"--no-open"]}}async function hb(t,e,n,r){let s=await t();if(s)return s;LO(e.command,e.args,n);let i=Date.now()+2e4;for(;Date.now()<i;){await db(150);let o=await t();if(o)return o}throw new Error(`Launched ${r} but it did not register within 20s.`)}async function bn(t,e={}){let n=e.cwd??process.cwd(),r=_e.resolve(n,t),s=await ir({kind:"bulb",file:r},n),[i]=await ta(r,s),o={...e,mode:e.mode??i?.mode};return hb(async()=>yn(await G(),r)[0],fb(t,o),n,_e.basename(t))}async function Ns(t,e=process.cwd()){return hb(()=>ea(e,t),pb(t),e,`the ${t} mirror`)}var ib,IO,ob,NO,db,je=S(()=>{"use strict";Be();mn();Xo();ib=1e6;IO=/^── run (\d+) ── /;ob=6e3,NO=500;db=t=>new Promise(e=>setTimeout(e,t))});function dr(t){return{...Bp(t),server:t.files.get("server.ts")??""}}function na(t){return!!t.server&&!t.code}var Ls=S(()=>{"use strict";Z();Z()});function ra(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 ud(t){return Zn(ra(t)??"bulb")||"bulb"}var dd=S(()=>{"use strict";Z()});import{readdirSync as MO,readFileSync as DO,statSync as BO}from"fs";import{join as mb,basename as jO}from"path";function yb(t,e,n){if(e>8)return n;let r;try{r=MO(t,{withFileTypes:!0})}catch{return n}for(let s of r)if(s.isDirectory()){if(s.name.startsWith(".")||s.name==="node_modules")continue;yb(mb(t,s.name),e+1,n)}else s.isFile()&&s.name.endsWith(".bulb.md")&&n.push(mb(t,s.name));return n}function FO(t,e){let n,r=!1;try{let s=DO(t,"utf8");n=ra(s.slice(0,1024));let i=ze(s);r=!!i&&na(dr(i))}catch{}return{mtime:e,name:n??jO(t).replace(/\.bulb\.md$/,""),serverOnly:r}}function sa(t){let e=new Map,n=yb(t,0,[]).map(r=>{let s=0;try{s=BO(r).mtimeMs}catch{}let i=s?gb.get(r):void 0,o=i?.mtime===s?i:FO(r,s);return s&&e.set(r,o),{path:r,...o}});return gb=e,n}var gb,bb=S(()=>{"use strict";Z();Ls();dd();gb=new Map});function fr(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 ia=S(()=>{"use strict"});import{readFile as UO}from"fs/promises";async function fd(t){try{let e=ze(await UO(t,"utf-8"));return e?fr(dr(e)):void 0}catch{return}}var wb=S(()=>{"use strict";Ls();ia()});function pd(t){let e=t.split(""),n=(i,o)=>{for(let a=i;a<o&&a<e.length;a++)e[a]!==`
320
+ `);if(r<0)return;this.#s=!0,this.#e=this.#e.subarray(r+4),n()}for(;;){if(this.#e.length<2)return;let r=this.#e[1]&127,s=2;if(r===126){if(this.#e.length<4)return;r=this.#e.readUInt16BE(2),s=4}else if(r===127){if(this.#e.length<10)return;r=Number(this.#e.readBigUInt64BE(2)),s=10}if(this.#e.length<s+r)return;let i=this.#e[0]&15,o=this.#e.subarray(s,s+r).toString();if(this.#e=this.#e.subarray(s+r),i===1)try{let a=JSON.parse(o);a.id!==void 0&&!a.method&&this.#t.has(a.id)&&(this.#t.get(a.id)(a),this.#t.delete(a.id))}catch{}}}async call(e,n){await this.#u;let r=this.#o++,s=await new Promise((i,o)=>{this.#t.set(r,i),setTimeout(()=>o(new Error(`no reply to ${e}`)),My),this.proc.stdin.write(Ny(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(Ny(JSON.stringify({jsonrpc:"2.0",method:e})))}close(){this.proc.kill()}}});import{statSync as qo,readdirSync as ZC,existsSync as eO}from"fs";import{basename as Fy,join as zu,resolve as tO}from"path";import{homedir as Uy}from"os";function rO(t){let e=t.trimStart();return nO.some(n=>e.startsWith(n))}function nr(t,e){return Array.isArray(t)?t.map(n=>typeof n?.text=="string"?e&&rO(n.text)?"":Pe(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 sO(t){return typeof t=="string"?Pe(t):nr(t,!1)}function iO(t,e){let n=e??"",r=cO(n);if(!r.length)return{name:t,input:{script:n}};let s=r.map(i=>Yu(i.fn)&&_s(i.arg)?_y(String(i.arg.cmd??i.arg.command??"")):void 0);if(s.every(i=>i!==void 0))return{name:"read",input:qy(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}=Jy(o);return{name:i,input:new Set(a).size===1?{path:a[0],patch:l}:{patch:l},pending:{kind:"patch",digest:lO(l)}}}return _s(o)?Yu(i)?{name:t,input:aO(o)}:{name:i,input:o}:typeof o=="string"?{name:i,input:{arg:o}}:{name:t,input:{script:n}}}return{name:t,input:qy(r.map(({fn:i,arg:o})=>i==="apply_patch"&&typeof o=="string"?["patch",Jy(o).diff]:Yu(i)&&_s(o)?["command",o.cmd??o.command]:[i,o]))}}function aO(t){let e=Object.fromEntries(Object.entries(t).filter(([r])=>r!=="cmd"&&r!=="command"&&!oO.has(r))),n=t.command??t.cmd;return n===void 0?e:{command:n,...e}}function qy(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 lO(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 cO(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=Vy(t,s);if(i<0)break;e.push({fn:r[1],arg:Yy(t.slice(s+1,i).trim(),t)}),n.lastIndex=i+1}return e}function Yy(t,e){let n=t[0];if(n==='"'||n==="'"||n==="`")return Wo(t,0)===t.length-1?Gy(t.slice(1,-1)):t;if(n==="{"){for(let r of[t,dO(t)])try{let s=JSON.parse(r);if(_s(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==="`"?Wo(e,s):i==="{"?Vy(e,s):-1;if(o>s)return Yy(e.slice(s,o+1),"")}}return t}function Vy(t,e){let n=0;for(let r=e;r<t.length;r++){let s=t[r];if(s==='"'||s==="'"||s==="`"){if(r=Wo(t,r),r<0)return-1}else if(s==="("||s==="["||s==="{")n++;else if((s===")"||s==="]"||s==="}")&&--n===0)return r}return-1}function Wo(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 Gy(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)):uO[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=Wo(t,i);if(l<0)return t;r+=JSON.stringify(Gy(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 Jy(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 fO(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:De(t)};let r=n[3].replace(/^\n+/,"").replace(/^Script error:\n/,""),s=n[1]==="failed",i=pO(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:Ee(hO(r),"line")}:e?.kind==="patch"&&!s?{content:e.digest,isError:s,digest:e.digest}:{content:r,isError:s,digest:De(r),exit:o}}function pO(t){if(t.startsWith("{"))try{let e=JSON.parse(t);if(_s(e)&&typeof e.output=="string")return{output:e.output,exit_code:typeof e.exit_code=="number"?e.exit_code:void 0}}catch{}}function mO(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 yO(t){let e,n,r;for(let s of gO){let i=No(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 u=Date.parse(c.timestamp??"");Number.isNaN(u)||(a=u)}if(e===void 0&&c.type==="event_msg"){let u=c.payload?.type;u==="task_started"?e=!0:(u==="task_complete"||u==="turn_aborted")&&(e=!1)}if(n===void 0&&c.type==="event_msg"&&c.payload?.type==="token_count"&&c.payload.info?.last_token_usage){let u=Xy(c.payload.info.last_token_usage);n=u.in+u.out+u.cached+u.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 Xy(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 Ky(t){let n=er(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=bO(i,o),l=zy(n.text,r),c=a&&!l&&n.bytes>=65536?er(t,Hy):void 0,u=l??(c&&zy(c.text,r)),d=!!a&&!u&&(c??n).bytes<(c?Hy:65536);return{cwd:i.cwd,subagent:!!o,id:i.id,spawn:a,turn:u,modelPending:d}}catch{return{cwd:"",subagent:!1}}}function bO(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 zy(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 nO,_s,Yu,oO,uO,hO,Jo,Wy,Vu,rr,gO,Hy,Gu=v(()=>{"use strict";Cs();Do();Mo();Wu();jy();nO=["<permissions instructions>","<apps_instructions>","<plugins_instructions>","<skills_instructions>","<recommended_plugins>","<environment_context>","<node_repl_review_evidence>","# AGENTS.md instructions for "];_s=t=>!!t&&typeof t=="object"&&!Array.isArray(t),Yu=t=>t==="shell_command"||t==="exec_command",oO=new Set(["max_output_tokens","yield_time_ms","timeout_ms"]);uO={n:`
327
+ `,t:" ",r:"\r",b:"\b",f:"\f",v:"\v",0:"\0"};hO=t=>t?t.replace(/\r?\n$/,"").split(`
328
+ `).length:0;Jo=t=>{let e=tO(t);return process.platform==="win32"?e.toLowerCase():e},Wy=12e4,Vu=t=>t.slice(-36),rr=class t extends Ft{constructor(n=zu(Uy(),".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 Hu()).includes(Vu(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 Hu()).includes(Vu(n)))throw new Error("the Codex session is not loaded by its app server now");await By(Vu(n),r,s)}detectsInstalled(){return eO(zu(Uy(),".codex"))}sessionsDir(n){return this.root}listSessionFiles(n){let r=Jo(n),s=[];for(let i of this.#f()){let o=0,a=0;try{let u=qo(i);if(!u.isFile())continue;o=u.size,a=u.mtimeMs}catch{continue}let l=this.#n.get(i);if(l===void 0){if(l=Ky(i),l===void 0)continue;this.#n.set(i,l)}if(l.subagent||Jo(l.cwd)!==r)continue;let c=Fy(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=Jo(n),i=new Map,o;for(let c of this.#f()){let u=0,d=0,f;try{let k=qo(c);if(!k.isFile())continue;u=k.size,d=k.mtimeMs,f=k.birthtimeMs||void 0}catch{continue}let p=this.#n.get(c);if(p===void 0||p.modelPending){if(p=Ky(c),p===void 0)continue;this.#n.set(c,p)}if(Fy(c,".jsonl")===r&&(o=p.id),!p.spawn||Jo(p.cwd)!==s)continue;let{running:m,tokens:h,turn:y}=this.#i(c,u,d);i.set(p.spawn.id,{file:c,mtime:this.#r(c,u,d),started:f,running:m,tokens:h,spawn:p.spawn,turn:y??p.turn})}if(!o)return[];let a=(c,u=new Set)=>{if(c.parent===o)return!0;if(u.has(c.id))return!1;u.add(c.id);let d=i.get(c.parent);return d?a(d.spawn,u):!1},l=[];for(let{file:c,mtime:u,started:d,running:f,tokens:p,spawn:m,turn:h}of i.values())a(m)&&l.push({id:m.id,file:c,mtime:u,started:d,tokens:p,label:m.path.split("/").filter(Boolean).pop()??m.path,kind:m.role||void 0,model:h?.model,effort:h?.effort,parentId:i.has(m.parent)?m.parent:void 0,depth:m.depth,stopped:!1,running:f});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>=Wy)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=yO(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 ZC(s).map(i=>zu(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=nr(i.content,!0).trim();a&&s.push({type:"user",text:a})}else if(i.role==="assistant"){let a=nr(i.content,!1);a&&s.push({type:"assistant",text:a,thinking:"",tools:[],live:o()})}return{events:s}}if(i.type==="reasoning"){let a=nr(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"?iO(i.name??"",i.input):{name:i.name??"",input:mO(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,...fO(sO(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:Xy(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<Wy}readPreview(n){for(let r of(er(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"?nr(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"?"":nr(n.payload.content,r==="user").replace(/\s+/g," ").trim()}},gO=[64*1024,1024*1024];Hy=512*1024});import{realpathSync as wO}from"fs";import{createHash as vO}from"crypto";import{join as Ko,resolve as SO}from"path";import{homedir as kO}from"os";function Ge(){let t=process.env.TYPEBULB_SERVERS_DIR;return t?Ko(t,".."):Ko(kO(),".typebulb")}function ht(){Qy||(Qy=!0,console.error(`${Ge()} not writable \u2014 continuing stateless: ports won't stick, caches stay cold, and typebulb logs/wait/send/stop may not see this run`))}function mt(){return process.env.TYPEBULB_SERVERS_DIR||Ko(Ge(),"servers")}function Zy(t){let e=oe(t),n=e.slice(e.lastIndexOf("/")+1).replace(/\.bulb\.md$/,"");return Ko(Ge(),"canvas",`${n}-${Rs(t)}.png`)}function Rs(t){return vO("sha1").update(oe(t)).digest("hex").slice(0,8)}function oe(t){let e=SO(t),n=e;try{n=wO.native(e)}catch{}return(process.platform==="win32"?n.toLowerCase():n).replace(/\\/g,"/")}function eb(t,e){let n=oe(t),r=oe(e);return n.startsWith(r.endsWith("/")?r:r+"/")?!n.includes("/node_modules/"):!1}var Qy,Be=v(()=>{"use strict";Qy=!1});import*as rb from"net";import{mkdir as xO,readFile as EO,writeFile as sb}from"fs/promises";import{existsSync as AO}from"fs";import{join as ib}from"path";function lb(){return ib(Ge(),"blocks")}function Xu(t){return ib(lb(),`${t}.json`)}function zo(t){return new Promise(e=>{let n=rb.createServer();n.once("error",()=>e(!1)),n.listen(t,"127.0.0.1",()=>n.close(()=>e(!0)))})}async function PO(t){for(let e=t;e<65535;e++)if(await zo(e))return e;throw new Error(`No free port found above ${t}`)}async function Qu(t){let{listBulbServers:e}=await Promise.resolve().then(()=>(je(),cb)),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 Yo(t){try{let e=JSON.parse(await EO(Xu(t),"utf8"));return e&&typeof e.cwd=="string"?{cwd:e.cwd,slots:e.slots??{},mirrors:e.mirrors??{}}:void 0}catch{return}}async function Vo(t,e){try{return await sb(Xu(t),JSON.stringify(e,null,2)),!0}catch{return ht(),!1}}async function _O(t){let e=oe(t);try{await xO(lb(),{recursive:!0})}catch{return}let n=[];for(let o=0;o<ab;o++)n.push(ob+o*pn);let r=await Promise.all(n.map(async o=>({base:o,block:await Yo(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 sb(Xu(o),JSON.stringify(s,null,2),{flag:"wx"}),o}catch(l){if((await Yo(o))?.cwd===e)return o;l.code!=="EEXIST"&&ht();continue}if(!AO(a.cwd))return await Vo(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 Vo(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 RO(t,e){let n=await Yo(t)??{cwd:"",slots:{},mirrors:{}};if(e.kind==="mirror"){let i=n.mirrors[e.agent];if(i!==void 0)return i;let o=nb(n),a=o.has(0)?CO:0;for(;a>Ho&&o.has(a);)a--;return n.mirrors[e.agent]=a,await Vo(t,n),a}let r=oe(e.file),s=n.slots[r]?.offset;if(s===void 0){let i=nb(n);for(s=Ho;s<pn&&i.has(s);)s++;if(s>=pn){let o=Object.entries(n.slots).sort((a,l)=>(a[1].usedAt??0)-(l[1].usedAt??0))[0];s=o?o[1].offset:Ho,o&&delete n.slots[o[0]]}}return n.slots[r]={offset:s,usedAt:Date.now()},await Vo(t,n),s}function nb(t){return new Set([...Object.values(t.mirrors),...Object.values(t.slots).map(e=>e.offset)])}async function sr(t,e){let n=await _O(e);return n===void 0?void 0:n+await RO(n,t)}async function hn(t){let e=oe(t);for(let n=0;n<ab;n++){let r=await Yo(ob+n*pn);if(r?.cwd===e)return s=>r.slots[oe(s)]?.usedAt??0}return()=>0}async function Go(t){if(t.explicit!==void 0)return await zo(t.explicit)||await Qu(t.explicit),t.target.kind==="bulb"&&await sr(t.target,t.cwd),{port:t.explicit};let e=await sr(t.target,t.cwd);if(e!==void 0){let r=e-e%pn,s=Date.now()+OO;do{if(await zo(e))return{port:e};await new Promise(i=>setTimeout(i,150))}while(Date.now()<s);for(let i=Ho;i<pn;i++){let o=r+i;if(o!==e&&await zo(o))return{port:o,note:`(slot ${e} was busy)`}}}return{port:await PO(TO),note:e===void 0?"(no port block available)":"(this project's block was full)"}}var ob,pn,ab,TO,Ho,CO,OO,mn=v(()=>{"use strict";Be();ob=20100,pn=100,ab=19,TO=23e3,Ho=1,CO=pn-1,OO=3e3});var Ae,Xo=v(()=>{"use strict";Ae="0.62.2"});var cb={};Ai(cb,{agentViewerCommand:()=>wb,bulbServerCommand:()=>bb,clearServerLog:()=>rd,findProjectViewer:()=>ea,isAlive:()=>ir,isMirror:()=>ye,isProjectBulb:()=>ld,isProjectMirror:()=>lr,launchAgentViewer:()=>Ns,launchBulbServer:()=>bn,listBulbServers:()=>G,probePageCount:()=>ud,readServerLog:()=>Xe,readWaitCursor:()=>Zo,recordDenial:()=>ad,registerServer:()=>od,relayOpen:()=>cd,runMarker:()=>sd,serverLogPath:()=>ar,serversForBulb:()=>yn,sliceRunLog:()=>id,startServerLog:()=>$s,stopBulbServer:()=>or,stopServer:()=>gt,stopServersForBulb:()=>ta,typebulbBinPath:()=>cr,unregisterServer:()=>gn,writeWaitCursor:()=>Is});import{spawn as ub}from"child_process";import{readdir as IO,readFile as pb,writeFile as hb,unlink as Zu,mkdir as $O}from"fs/promises";import{mkdirSync as mb,writeFileSync as Qo,appendFileSync as NO,readFileSync as ed}from"fs";import*as _e from"path";import{fileURLToPath as LO}from"url";function td(t){return _e.join(mt(),`${t}.json`)}function ar(t){return _e.join(mt(),`${t}.log`)}function nd(t){return _e.join(mt(),`${t}.wait.json`)}function gb(t){try{let e=JSON.parse(ed(nd(t),"utf8"));return e.cursors&&typeof e.cursors=="object"?e.cursors:{}}catch{return{}}}function Zo(t,e=""){let n=gb(t)[e];return typeof n=="number"&&Number.isFinite(n)&&n>=0?n:void 0}function Is(t,e,n=""){try{mb(mt(),{recursive:!0});let r=gb(t);r[n]=e,Qo(nd(t),JSON.stringify({cursors:r}))}catch{}}function $s(t){let e=ar(t);try{mb(mt(),{recursive:!0}),Qo(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(NO(e,l),s+=l.length,s>2*db){let c=ed(e),u=c.subarray(Math.max(0,c.length-db));Qo(e,u),s=u.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 rd(t){try{Qo(ar(t),"")}catch{}}function Xe(t,e=0){try{let n=ed(ar(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 sd(t){return`\u2500\u2500 run ${t} \u2500\u2500 ${new Date().toTimeString().slice(0,8)}`}function DO(t){let e=MO.exec(t);return e?Number(e[1]):void 0}function id(t,e){let n=t.split(`
330
+ `),r=[];if(n.forEach((o,a)=>{let l=DO(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 ir(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}async function od(t){try{await $O(mt(),{recursive:!0}),await hb(td(t.pid),JSON.stringify({version:Ae,...t}))}catch{ht()}}async function ad(t,e){let n=td(t);try{let r=JSON.parse(await pb(n,"utf8"));if(r.denied===e)return;r.denied=e,await hb(n,JSON.stringify(r))}catch{}}async function gn(t){await Zu(td(t)).catch(()=>{}),await Zu(ar(t)).catch(()=>{}),await Zu(nd(t)).catch(()=>{})}function ye(t){return t.agent!=null}function lr(t,e){return ye(t)&&t.cwd!=null&&oe(t.cwd)===oe(e)}function ld(t,e){return!ye(t)&&eb(t.file,e)}async function G(t){let e;try{e=await IO(mt())}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 pb(_e.join(mt(),s),"utf8"))}catch{await gn(i);return}o&&typeof o.pid=="number"&&ir(o.pid)?n.push(o):await gn(i)})),(t?n.filter(s=>ld(s,t)):n).sort((s,i)=>s.startedAt-i.startedAt)}async function ea(t,e){return(await G()).find(n=>lr(n,t)&&(e?n.agent===e:!0))}async function cd(t,e){let n=new URL(t).port,r=(await G()).filter(a=>String(a.port)!==n),s=r.filter(a=>lr(a,e)),i=r.filter(a=>ld(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:u}=await l.json();if(c)return{where:"editor",via:a.agent?"the agent mirror":`${_e.basename(a.file)}'s page`};ye(a)&&(o+=u??0)}catch{}return o>0?{where:"external"}:void 0}async function or(t){try{process.kill(t,"SIGTERM")}catch{}await gn(t)}async function ud(t){try{let e=await fetch(`${t.url}/__pages`,{signal:AbortSignal.timeout(BO)});if(!e.ok)return;let{pages:n}=await e.json();return typeof n=="number"?n:void 0}catch{return}}async function gt(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(fb)});if(!n.ok)throw new Error(`/__stop ${n.status}`);let{closed:r=0,stuck:s=0}=await n.json(),i=Date.now()+fb;for(;ir(t.pid)&&Date.now()<i;)await yb(100);return ir(t.pid)?(await or(t.pid),"killed"):(await gn(t.pid),{closed:r,stuck:s})}catch{return await or(t.pid),"killed"}}function yn(t,e){let n=oe(e);return t.filter(r=>!ye(r)&&r.pid!==process.pid&&oe(r.file)===n)}async function ta(t,e){let n=yn(await G(),t);for(let r of n)await gt(r,e!==void 0&&r.port===e?"keep":"close");return n}function jO(t,e,n){(process.platform==="win32"?ub("cmd",["/c","start","","/b",t,...e],{cwd:n,stdio:"ignore",windowsHide:!0}):ub(t,e,{cwd:n,detached:!0,stdio:"ignore"})).unref()}function cr(){return _e.join(_e.dirname(LO(import.meta.url)),"index.js")}function bb(t,e={}){return{command:process.execPath,args:[cr(),...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:[cr(),`agent:${t}`,"--no-open"]}}async function vb(t,e,n,r){let s=await t();if(s)return s;jO(e.command,e.args,n);let i=Date.now()+2e4;for(;Date.now()<i;){await yb(150);let o=await t();if(o)return o}throw new Error(`Launched ${r} but it did not register within 20s.`)}async function bn(t,e={}){let n=e.cwd??process.cwd(),r=_e.resolve(n,t),s=await sr({kind:"bulb",file:r},n),[i]=await ta(r,s),o={...e,mode:e.mode??i?.mode};return vb(async()=>yn(await G(),r)[0],bb(t,o),n,_e.basename(t))}async function Ns(t,e=process.cwd()){return vb(()=>ea(e,t),wb(t),e,`the ${t} mirror`)}var db,MO,fb,BO,yb,je=v(()=>{"use strict";Be();mn();Xo();db=1e6;MO=/^── run (\d+) ── /;fb=6e3,BO=500;yb=t=>new Promise(e=>setTimeout(e,t))});function ur(t){return{...Fp(t),server:t.files.get("server.ts")??""}}function na(t){return!!t.server&&!t.code}var Ls=v(()=>{"use strict";ee();ee()});function ra(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 dd(t){return Qn(ra(t)??"bulb")||"bulb"}var fd=v(()=>{"use strict";ee()});import{readdirSync as FO,readFileSync as UO,statSync as qO}from"fs";import{join as Sb,basename as JO}from"path";function xb(t,e,n){if(e>8)return n;let r;try{r=FO(t,{withFileTypes:!0})}catch{return n}for(let s of r)if(s.isDirectory()){if(s.name.startsWith(".")||s.name==="node_modules")continue;xb(Sb(t,s.name),e+1,n)}else s.isFile()&&s.name.endsWith(".bulb.md")&&n.push(Sb(t,s.name));return n}function WO(t,e){let n,r=!1;try{let s=UO(t,"utf8");n=ra(s.slice(0,1024));let i=ze(s);r=!!i&&na(ur(i))}catch{}return{mtime:e,name:n??JO(t).replace(/\.bulb\.md$/,""),serverOnly:r}}function sa(t){let e=new Map,n=xb(t,0,[]).map(r=>{let s=0;try{s=qO(r).mtimeMs}catch{}let i=s?kb.get(r):void 0,o=i?.mtime===s?i:WO(r,s);return s&&e.set(r,o),{path:r,...o}});return kb=e,n}var kb,Eb=v(()=>{"use strict";ee();Ls();fd();kb=new Map});function dr(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 ia=v(()=>{"use strict"});import{readFile as KO}from"fs/promises";async function pd(t){try{let e=ze(await KO(t,"utf-8"));return e?dr(ur(e)):void 0}catch{return}}var Ab=v(()=>{"use strict";Ls();ia()});function hd(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==="/"&&qO.has(s)){let a=r+1,l=!1;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==="/"&&HO.has(s)){let a=r+1,l=!1;for(;a<t.length&&t[a]!==`
334
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=vb(t,r);n(r,a),r=a,s="`"}else/\s/.test(i)||(s=i),r++}return e.join("")}function vb(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=vb(t,n);continue}if(s==="$"&&t[n+1]==="{"){r++,n+=2;continue}if(s==="}"&&r>0){r--,n++;continue}n++}return t.length}var qO,Sb=S(()=>{qO=new Set(["","(",",","=",":","[","!","&","|","?",";","{"])});function KO(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 kb(t){let e=[];for(let s of WO)for(let i of t.matchAll(s)){let o=KO(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 xb(t){return kb(pd(t)).map(e=>e.root)}function Ms(t,e){if(!t)return[];let{target:n,dependencies:r}=e,s=(e.lineOffset??1)-1,i=[],o=t.split(`
337
- `),a=pd(t).split(`
338
- `);for(let l=0;l<o.length;l++){let c=a[l],u=l+1+s;for(let d of JO)d.targets.includes(n)&&d.pattern.test(c)&&i.push({type:d.type,severity:"error",message:YO(d.type,u),lineNumber:u,lineContent:o[l]})}return n==="client"&&r&&i.push(...HO(a,o,r,s)),i}function HO(t,e,n,r){let s=new Set(Object.keys(n));return kb(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:zO(i,a),lineNumber:a,lineContent:e[o]}})}function zO(t,e){return`Import "${t}" is not declared in config.json dependencies! Found on line ${e}.
335
+ `;)t[a]==="\\"&&a++,a++;r=a+1,s=i}else if(i==="`"){let a=Tb(t,r);n(r,a),r=a,s="`"}else/\s/.test(i)||(s=i),r++}return e.join("")}function Tb(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=Tb(t,n);continue}if(s==="$"&&t[n+1]==="{"){r++,n+=2;continue}if(s==="}"&&r>0){r--,n++;continue}n++}return t.length}var HO,Cb=v(()=>{HO=new Set(["","(",",","=",":","[","!","&","|","?",";","{"])});function VO(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 Ob(t){let e=[];for(let s of YO)for(let i of t.matchAll(s)){let o=VO(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 Pb(t){return Ob(hd(t)).map(e=>e.root)}function Ms(t,e){if(!t)return[];let{target:n,dependencies:r}=e,s=(e.lineOffset??1)-1,i=[],o=t.split(`
337
+ `),a=hd(t).split(`
338
+ `);for(let l=0;l<o.length;l++){let c=a[l],u=l+1+s;for(let d of zO)d.targets.includes(n)&&d.pattern.test(c)&&i.push({type:d.type,severity:"error",message:QO(d.type,u),lineNumber:u,lineContent:o[l]})}return n==="client"&&r&&i.push(...GO(a,o,r,s)),i}function GO(t,e,n,r){let s=new Set(Object.keys(n));return Ob(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:XO(i,a),lineNumber:a,lineContent:e[o]}})}function XO(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 YO(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 QO(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 wn,vn,JO,WO,oa=S(()=>{Sb();wn=["client"],vn=["client","server"],JO=[{type:"DYNAMIC_IMPORT",pattern:/\bimport\s*\(\s*['"`]/,targets:wn},{type:"COMMONJS_REQUIRE",pattern:/\brequire\s*\(\s*['"`]/,targets:vn},{type:"JS_EXTENSION_IMPORT",pattern:/from\s+['"][^'"]*\/[^'"]*\.js['"]/,targets:wn},{type:"URL_IMPORT",pattern:/from\s+['"]https?:\/\//,targets:wn},{type:"VERSION_SPECIFIER_IMPORT",pattern:/from\s+['"][^'"]*@[\d^~]/,targets:wn},{type:"REDUNDANT_TB_DECLARATION",pattern:/declare\s+(const|var|let)\s+tb\b/,targets:vn},{type:"CONST_ENUM",pattern:/\bconst\s+enum\b/,targets:vn},{type:"NAMESPACE_DECLARATION",pattern:/\bnamespace\s+\w+/,targets:vn},{type:"COMMONJS_EXPORT_EQUALS",pattern:/\bexport\s*=/,targets:vn},{type:"COMMONJS_IMPORT_EQUALS",pattern:/\bimport\s+\w+\s*=/,targets:vn},{type:"MODULE_DECLARATION",pattern:/\bmodule\s+\w+\s*\{/,targets:vn},{type:"CSS_FILE_IMPORT",pattern:/(?:from|import)\s+['"][^'"]*\.css['"]/,targets:wn},{type:"NAVIGATION",pattern:/window\.(location\.(reload|assign|replace)\s*\(|open\s*\()/,targets:wn},{type:"NAVIGATION",pattern:/window\.location(\.href)?\s*=[^=]/,targets:wn}],WO=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g]});function hd(t){let e=ze(t);if(!e)return t;let n=e.files.get("code.tsx");if(!n)return t;let r=xb(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,u]of e.files){let d=Ip(c);d&&(l[d]=u)}return l.config=JSON.stringify(i,null,2),Up(l)}var Eb=S(()=>{"use strict";Z();oa()});import{spawn as Ab}from"child_process";import{basename as VO}from"path";function GO(){return process.env.TYPEBULB_EDITOR||"code"}function QO(t,e,n){return n==null?[e]:XO.test(VO(t))?["-g",`${e}:${n}`]:[`+${n}`,e]}function ZO(t,e){let n=GO();return{command:n,args:QO(n,t,e)}}function md(t,e){let{command:n,args:r}=ZO(t,e),s=process.platform==="win32"?Ab("cmd.exe",["/d","/s","/c",n,...r],{detached:!0,stdio:"ignore",windowsHide:!0}):Ab(n,r,{detached:!0,stdio:"ignore"});s.on("error",i=>console.error("[typebulb] editor launch failed:",i?.message??i)),s.unref()}var XO,Tb=S(()=>{"use strict";XO=/^(code|code-insiders|codium|vscodium|cursor|windsurf)(\.cmd|\.exe)?$/i});import{readFileSync as eP,writeFileSync as tP,mkdirSync as nP,statSync as rP}from"fs";import{join as sP}from"path";function gd(){return sP(Ge(),"trust.json")}function yd(){try{let t=gd(),e=rP(t).mtimeMs;if(Ds?.mtime!==e){let n=JSON.parse(eP(t,"utf8"));Ds={mtime:e,set:new Set(Array.isArray(n)?n:[])}}return Ds.set}catch{return Ds=void 0,new Set}}function iP(t){try{nP(Ge(),{recursive:!0}),tP(gd(),JSON.stringify([...t])),Ds=void 0}catch(e){throw new Error(`can't write ${gd()} \u2014 trust not remembered (unwritable home; sandboxed shell?): ${e.message}`)}}function Sn(t){return yd().has(oe(t))}function pr(t,e){let n=new Set(yd()),r=oe(t);(e?n.has(r):!n.has(r))||(e?n.add(r):n.delete(r),iP(n))}function bd(){return[...yd()]}var Ds,Bs=S(()=>{"use strict";Be()});function mr(t){return(t.includes("://")?t:`http://${t}`).replace(/\/+$/,"")}function wd(){return Fs}async function yt(){let[t,e]=await Promise.all([Ob(),fP()]);return dP([...pP(e),...t],process.env.TB_AI_PROVIDER,process.env.TB_AI_MODEL)}function dP(t,e,n){return!e||!n?t:t.map(r=>r.provider===e&&r.name===n?{...r,default:!0}:r)}async function Cb(){let t;try{t=await fetch(oP,{signal:AbortSignal.timeout(lP)})}catch(e){Fs=`catalog fetch failed: ${e?.message??e}`;return}if(!t.ok){Fs=`catalog fetch failed: HTTP ${t.status}`;return}try{return await t.json()}catch(e){Fs=`catalog returned an unreadable body: ${e?.message??e}`;return}}async function fP(){if(js&&Date.now()-js.fetchedAt<=aP)return js.models;let t=await Cb()??await Cb();return t?(js={models:t,fetchedAt:Date.now()},Fs=void 0,t):js?.models??[]}async function Ob(){if(aa&&Date.now()-aa.fetchedAt<=cP)return aa.models;let t=mr(process.env.OLLAMA_HOST??"http://localhost:11434"),e=[];try{let n=await fetch(new URL("/api/tags",t).toString(),{signal:AbortSignal.timeout(uP)});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 aa={models:e,fetchedAt:Date.now()},e}function pP(t){let e=new Set(Object.entries(hr).filter(([,n])=>!!process.env[n]).map(([n])=>n));return t.filter(n=>e.has(n.provider))}function vd(){return Object.values(hr).some(t=>!!process.env[t])}async function la(){return vd()||process.env.TB_AI_BASE_URL||(await Ob()).length>0?"own":"none"}function Pb(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 hr,oP,aP,lP,cP,uP,js,aa,Fs,kn=S(()=>{"use strict";hr={anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY",gemini:"GOOGLE_API_KEY",openrouter:"OPENROUTER_API_KEY"};oP="https://api.typebulb.com/api/models",aP=1440*60*1e3,lP=5e3,cP=60*1e3,uP=1500});var _b,Rb,ot,xn=S(()=>{_b=t=>t!=null&&t>=0&&t<=4?t:void 0,Rb=(t,e)=>{let n={...t};for(let r of["input","output","reasoning","cacheRead"])e[r]!==void 0&&(n[r]=e[r]);return n},ot=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 Re,Qe,gr=S(()=>{Re=class extends Error{constructor(e,n="unknown",r=!1){super(e),this.code=n,this.retryable=r}},Qe=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 wn,vn,zO,YO,oa=v(()=>{Cb();wn=["client"],vn=["client","server"],zO=[{type:"DYNAMIC_IMPORT",pattern:/\bimport\s*\(\s*['"`]/,targets:wn},{type:"COMMONJS_REQUIRE",pattern:/\brequire\s*\(\s*['"`]/,targets:vn},{type:"JS_EXTENSION_IMPORT",pattern:/from\s+['"][^'"]*\/[^'"]*\.js['"]/,targets:wn},{type:"URL_IMPORT",pattern:/from\s+['"]https?:\/\//,targets:wn},{type:"VERSION_SPECIFIER_IMPORT",pattern:/from\s+['"][^'"]*@[\d^~]/,targets:wn},{type:"REDUNDANT_TB_DECLARATION",pattern:/declare\s+(const|var|let)\s+tb\b/,targets:vn},{type:"CONST_ENUM",pattern:/\bconst\s+enum\b/,targets:vn},{type:"NAMESPACE_DECLARATION",pattern:/\bnamespace\s+\w+/,targets:vn},{type:"COMMONJS_EXPORT_EQUALS",pattern:/\bexport\s*=/,targets:vn},{type:"COMMONJS_IMPORT_EQUALS",pattern:/\bimport\s+\w+\s*=/,targets:vn},{type:"MODULE_DECLARATION",pattern:/\bmodule\s+\w+\s*\{/,targets:vn},{type:"CSS_FILE_IMPORT",pattern:/(?:from|import)\s+['"][^'"]*\.css['"]/,targets:wn},{type:"NAVIGATION",pattern:/window\.(location\.(reload|assign|replace)\s*\(|open\s*\()/,targets:wn},{type:"NAVIGATION",pattern:/window\.location(\.href)?\s*=[^=]/,targets:wn}],YO=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g]});function md(t){let e=ze(t);if(!e)return t;let n=e.files.get("code.tsx");if(!n)return t;let r=Pb(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,u]of e.files){let d=Np(c);d&&(l[d]=u)}return l.config=JSON.stringify(i,null,2),Jp(l)}var _b=v(()=>{"use strict";ee();oa()});import{spawn as Rb}from"child_process";import{basename as ZO}from"path";function eP(){return process.env.TYPEBULB_EDITOR||"code"}function nP(t,e,n){return n==null?[e]:tP.test(ZO(t))?["-g",`${e}:${n}`]:[`+${n}`,e]}function rP(t,e){let n=eP();return{command:n,args:nP(n,t,e)}}function gd(t,e){let{command:n,args:r}=rP(t,e),s=process.platform==="win32"?Rb("cmd.exe",["/d","/s","/c",n,...r],{detached:!0,stdio:"ignore",windowsHide:!0}):Rb(n,r,{detached:!0,stdio:"ignore"});s.on("error",i=>console.error("[typebulb] editor launch failed:",i?.message??i)),s.unref()}var tP,Ib=v(()=>{"use strict";tP=/^(code|code-insiders|codium|vscodium|cursor|windsurf)(\.cmd|\.exe)?$/i});import{readFileSync as sP,writeFileSync as iP,mkdirSync as oP,statSync as aP}from"fs";import{join as lP}from"path";function yd(){return lP(Ge(),"trust.json")}function bd(){try{let t=yd(),e=aP(t).mtimeMs;if(Ds?.mtime!==e){let n=JSON.parse(sP(t,"utf8"));Ds={mtime:e,set:new Set(Array.isArray(n)?n:[])}}return Ds.set}catch{return Ds=void 0,new Set}}function cP(t){try{oP(Ge(),{recursive:!0}),iP(yd(),JSON.stringify([...t])),Ds=void 0}catch(e){throw new Error(`can't write ${yd()} \u2014 trust not remembered (unwritable home; sandboxed shell?): ${e.message}`)}}function Sn(t){return bd().has(oe(t))}function fr(t,e){let n=new Set(bd()),r=oe(t);(e?n.has(r):!n.has(r))||(e?n.add(r):n.delete(r),cP(n))}function wd(){return[...bd()]}var Ds,Bs=v(()=>{"use strict";Be()});function hr(t){return(t.includes("://")?t:`http://${t}`).replace(/\/+$/,"")}function vd(){return Fs}async function yt(){let[t,e]=await Promise.all([Nb(),gP()]);return mP([...yP(e),...t],process.env.TB_AI_PROVIDER,process.env.TB_AI_MODEL)}function mP(t,e,n){return!e||!n?t:t.map(r=>r.provider===e&&r.name===n?{...r,default:!0}:r)}async function $b(){let t;try{t=await fetch(uP,{signal:AbortSignal.timeout(fP)})}catch(e){Fs=`catalog fetch failed: ${e?.message??e}`;return}if(!t.ok){Fs=`catalog fetch failed: HTTP ${t.status}`;return}try{return await t.json()}catch(e){Fs=`catalog returned an unreadable body: ${e?.message??e}`;return}}async function gP(){if(js&&Date.now()-js.fetchedAt<=dP)return js.models;let t=await $b()??await $b();return t?(js={models:t,fetchedAt:Date.now()},Fs=void 0,t):js?.models??[]}async function Nb(){if(aa&&Date.now()-aa.fetchedAt<=pP)return aa.models;let t=hr(process.env.OLLAMA_HOST??"http://localhost:11434"),e=[];try{let n=await fetch(new URL("/api/tags",t).toString(),{signal:AbortSignal.timeout(hP)});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 aa={models:e,fetchedAt:Date.now()},e}function yP(t){let e=new Set(Object.entries(pr).filter(([,n])=>!!process.env[n]).map(([n])=>n));return t.filter(n=>e.has(n.provider))}function Sd(){return Object.values(pr).some(t=>!!process.env[t])}async function la(){return Sd()||process.env.TB_AI_BASE_URL||(await Nb()).length>0?"own":"none"}function Lb(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 pr,uP,dP,fP,pP,hP,js,aa,Fs,kn=v(()=>{"use strict";pr={anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY",gemini:"GOOGLE_API_KEY",openrouter:"OPENROUTER_API_KEY"};uP="https://api.typebulb.com/api/models",dP=1440*60*1e3,fP=5e3,pP=60*1e3,hP=1500});var Mb,Db,ot,xn=v(()=>{Mb=t=>t!=null&&t>=0&&t<=4?t:void 0,Db=(t,e)=>{let n={...t};for(let r of["input","output","reasoning","cacheRead"])e[r]!==void 0&&(n[r]=e[r]);return n},ot=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 Re,Qe,mr=v(()=>{Re=class extends Error{constructor(e,n="unknown",r=!1){super(e),this.code=n,this.retryable=r}},Qe=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 Re(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 Re(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 ca,Sd=S(()=>{xn();gr();ca=class extends Qe{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(`
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 Re(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 Re(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 ca,kd=v(()=>{xn();mr();ca=class extends Qe{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
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 Re(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 ot({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 yr,ua=S(()=>{xn();gr();yr=class extends Qe{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 ot({input:e.prompt_tokens,output:e.completion_tokens,reasoning:e.completion_tokens_details?.reasoning_tokens,cacheRead:e.prompt_tokens_details?.cached_tokens})}}});var kd,da,xd=S(()=>{ua();kd={"HTTP-Referer":"https://typebulb.com","X-OpenRouter-Title":"Typebulb"},da=class extends yr{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",...kd}}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 fa,Ed=S(()=>{xn();gr();fa=class extends Qe{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 gr,ua=v(()=>{xn();mr();gr=class extends Qe{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 ot({input:e.prompt_tokens,output:e.completion_tokens,reasoning:e.completion_tokens_details?.reasoning_tokens,cacheRead:e.prompt_tokens_details?.cached_tokens})}}});var xd,da,Ed=v(()=>{ua();xd={"HTTP-Referer":"https://typebulb.com","X-OpenRouter-Title":"Typebulb"},da=class extends gr{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",...xd}}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 fa,Ad=v(()=>{xn();mr();fa=class extends Qe{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(`
514
514
 
515
- `);return{text:n,reasoning:r||void 0,usage:ot(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 pa,Ad=S(()=>{xn();gr();pa=class extends Qe{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,`
515
+ `);return{text:n,reasoning:r||void 0,usage:ot(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 pa,Td=v(()=>{xn();mr();pa=class extends Qe{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
516
  `),l={contents:o.map(u=>({role:u.role==="assistant"?"model":"user",parts:[{text:u.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 u=this.geminiVersion(n),d=u!==void 0&&u>=3?{thinkingLevel:this.thinkingLevelFor(u,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 ot({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 Re(`Prompt blocked: ${n}`)}}}});var ha,Td=S(()=>{ua();ha=class extends yr{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 En(t){let e=hP.get(t);if(!e)throw new Error(`Unsupported protocol: ${t}`);return e}function mP(t,e){return t.replace(/\/+$/,"")+(e.startsWith("/")?e:`/${e}`)}async function Cd(t,e){let n=En(t.protocol),r=n.getPath(t.model,e.stream),s=mP(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 gP(t){return/prompt is too long|context[_ ](length|window)|maximum context|token count exceeds|too many tokens/i.test(t)}async function br(t,e){let n=En(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||gP(s))&&(o="context_exceeded"),{code:o,message:s,retryable:i===429||i>=500}}var Ib,hP,Od=S(()=>{Sd();xd();Ed();Ad();Td();Ib=new ha,hP=new Map([["openai",new ca],["openrouter",new da],["anthropic",new fa],["gemini",new pa],["ollama",Ib],["openai-compat",Ib]])});function $b(t){let e=t.indexOf(`\r
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 ot({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 Re(`Prompt blocked: ${n}`)}}}});var ha,Cd=v(()=>{ua();ha=class extends gr{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 En(t){let e=bP.get(t);if(!e)throw new Error(`Unsupported protocol: ${t}`);return e}function wP(t,e){return t.replace(/\/+$/,"")+(e.startsWith("/")?e:`/${e}`)}async function Od(t,e){let n=En(t.protocol),r=n.getPath(t.model,e.stream),s=wP(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 vP(t){return/prompt is too long|context[_ ](length|window)|maximum context|token count exceeds|too many tokens/i.test(t)}async function yr(t,e){let n=En(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||vP(s))&&(o="context_exceeded"),{code:o,message:s,retryable:i===429||i>=500}}var Bb,bP,Pd=v(()=>{kd();Ed();Ad();Td();Cd();Bb=new ha,bP=new Map([["openai",new ca],["openrouter",new da],["anthropic",new fa],["gemini",new pa],["ollama",Bb],["openai-compat",Bb]])});function jb(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 Pd(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*Nb(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=Pd(s);d!==void 0&&d!=="done"&&(yield d)}return}n?.(),s+=r.decode(l,{stream:!0});let{pos:c,len:u}=$b(s);for(;c!==-1;){let d=s.slice(0,c);s=s.slice(c+u);let f=Pd(d);if(f==="done")return;f!==void 0&&(yield f),{pos:c,len:u}=$b(s)}}}finally{i&&e?.removeEventListener("abort",i);try{await t.cancel()}catch{}}}async function _d(t,e){return(await wr(t,e)).text}async function wr(t,e){if(!t.body)throw new Error("Response body is missing");let n="",r;for await(let s of An(t,e))s.kind==="text"?n+=s.text:s.kind==="usage"&&(r=s.usage);return{text:n,usage:r}}async function*An(t,e){let n=e??(t.headers.get("X-Provider-Protocol")||"openai"),r=En(n);if(!t.body)return;let s=t.body.getReader(),i;for await(let a of Nb(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=Rb(i,l.usage))}let o=ot(i);o&&(yield{kind:"usage",usage:o})}var Lb=S(()=>{xn();Od()});import{strToU8 as yP,strFromU8 as bP,deflateSync as wP,inflateSync as vP}from"fflate";function Id(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 _d(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*Fb(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=_d(s);d!==void 0&&d!=="done"&&(yield d)}return}n?.(),s+=r.decode(l,{stream:!0});let{pos:c,len:u}=jb(s);for(;c!==-1;){let d=s.slice(0,c);s=s.slice(c+u);let f=_d(d);if(f==="done")return;f!==void 0&&(yield f),{pos:c,len:u}=jb(s)}}}finally{i&&e?.removeEventListener("abort",i);try{await t.cancel()}catch{}}}async function Rd(t,e){return(await br(t,e)).text}async function br(t,e){if(!t.body)throw new Error("Response body is missing");let n="",r;for await(let s of An(t,e))s.kind==="text"?n+=s.text:s.kind==="usage"&&(r=s.usage);return{text:n,usage:r}}async function*An(t,e){let n=e??(t.headers.get("X-Provider-Protocol")||"openai"),r=En(n);if(!t.body)return;let s=t.body.getReader(),i;for await(let a of Fb(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=Db(i,l.usage))}let o=ot(i);o&&(yield{kind:"usage",usage:o})}var Ub=v(()=>{xn();Pd()});import{strToU8 as SP,strFromU8 as kP,deflateSync as xP,inflateSync as EP}from"fflate";function $d(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 Us(t){try{return JSON.parse(t)}catch{return}}function Mb(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 kP(t){let e=Mb(t,n=>n.replace(/,(\s*[}\]])/g,"$1"));return e!==t?e:void 0}function xP(t){let e=Mb(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 EP(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 AP(t){let e,n=0;for(;n<t.length;){let r=t[n];if(r==="{"||r==="["){let s=EP(t,n);if(s!==-1){let i=t.slice(n,s+1),o=Us(i);o!==void 0&&(e={parsed:o,json:i}),n=s+1;continue}}n++}return e}function $d(t){let e=[],n=t.trim();n.startsWith("```")&&(n=n.replace(/^```(?:json)?\s*\n?/,"").replace(/\n?```\s*$/,""),e.push("markdown fences"));let r=Us(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=Us(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=Us(n),r!==void 0))return{parsed:r,json:n,fixesApplied:e}}for(let[o,a]of SP){let l=a(n);if(l!==void 0){let c=Us(l);if(c!==void 0)return{parsed:c,json:l,fixesApplied:[...e,o]}}}let i=AP(t);return i!==void 0?{...i,fixesApplied:[...e,"extracted last JSON value"]}:{parsed:void 0,json:n,fixesApplied:e}}function Nd(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=wP(yP(n),{level:9}),s=CP(r),i=`${Db}:${s}`;return i.length>TP?"":"#"+Rd+i}catch{return""}}function Ld(t){try{let e=t.startsWith("#")?t.slice(1):t;if(!e.startsWith(Rd))return;let n=e.slice(Rd.length),r=n.indexOf(":");if(r===-1||n.slice(0,r)!==Db)return;let s=OP(n.slice(r+1)),i=JSON.parse(bP(vP(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 CP(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 OP(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 SP,Rd,Db,TP,Bb=S(()=>{SP=[["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",kP],["arithmetic constants",xP]];Rd="tb=",Db="1",TP=6e4});var qt=S(()=>{xn();gr();Od();Lb();Bb();ua();Ed();Ad();Sd();xd();Td()});import{readFileSync as jb,existsSync as PP}from"fs";import*as at from"path";function Fb(t){return[...t?[`.env.${t}.local`,`.env.${t}`]:[],".env.local",".env"]}function be(t,e=process.cwd()){let n={},r=[];for(let s of Fb(t)){let i;try{i=jb(at.resolve(e,s),"utf-8")}catch{continue}r.push(s);for(let[o,a]of Ub(i))process.env[o]===void 0&&(process.env[o]=a,n[o]=s)}return{mode:t,sources:n,loaded:r}}function*Ub(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 ma(t,e=process.cwd()){for(let n of Fb()){let r;try{r=jb(at.resolve(e,n),"utf-8")}catch{continue}for(let[s,i]of Ub(r))if(s===t)return i}return process.env[t]}function _P(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 qb(){return`.env loads from ${process.cwd()} (the directory you ran from, not the bulb's)`}function Jt(t,e,n){let{sources:r,mode:s,loaded:i}=t,o=process.cwd(),a=at.dirname(e),l=`(mode: ${s??"none"})`,c=n?_P(n):[],u=c.filter(p=>r[p]).map(p=>`${p} \u2190 ${r[p]}`);u.length?console.log(`env: ${u.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=at.resolve(a)!==at.resolve(o);if(d)for(let p of[".env.local",".env"])PP(at.join(a,p))&&console.log(`env: ${at.join(a,p)} present but not loaded (cwd is ${o})`);let f=c.filter(p=>process.env[p]===void 0);if(f.length){let p=d?` \u2014 try running from ${a}`:"";console.log(`env: server.ts reads ${f.join(", ")} but ${f.length>1?"they are":"it's"} unset${p}`)}}var Ze=S(()=>{"use strict"});function bt(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=En(n)}catch{return`Unknown provider '${n}'.`}if(n==="ollama")return{apiKey:"",baseUrl:`${mr(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=hr[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 ${qb()}.`}function Wt(t,e){let n=[...e.system?[{role:"system",content:e.system}]:[],...e.messages.map(r=>({role:r.role,content:r.content}))];return Cd(t,{messages:n,stream:!0,effort:_b(e.effort),webSearch:e.webSearch,signal:e.signal})}var ga=S(()=>{"use strict";qt();qt();Ze();kn()});import{readFileSync as Vj,existsSync as RP}from"fs";import*as vr from"path";import{fileURLToPath as IP}from"url";function $P(){let t=vr.dirname(IP(import.meta.url));for(;!RP(vr.join(t,"package.json"));){let e=vr.dirname(t);if(e===t)break;t=e}return t}function qs(){return vr.join($P(),"SKILL.md")}var Md=S(()=>{"use strict"});import{transform as NP}from"sucrase";function Dd(t,e={}){let n=e.serverOnly?["typescript"]:["typescript","jsx"];try{let{code:r}=NP(t,{transforms:n,jsxRuntime:"automatic",jsxImportSource:e.jsxImportSource||"react",production:!0});return{code:r}}catch(r){return{code:"",error:String(r)}}}var Jb=S(()=>{});function LP(t){return t.map(e=>`${e.type} (line ${e.lineNumber}): ${e.message.split(`
540
+ `)}function Us(t){try{return JSON.parse(t)}catch{return}}function qb(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 TP(t){let e=qb(t,n=>n.replace(/,(\s*[}\]])/g,"$1"));return e!==t?e:void 0}function CP(t){let e=qb(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 OP(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 PP(t){let e,n=0;for(;n<t.length;){let r=t[n];if(r==="{"||r==="["){let s=OP(t,n);if(s!==-1){let i=t.slice(n,s+1),o=Us(i);o!==void 0&&(e={parsed:o,json:i}),n=s+1;continue}}n++}return e}function Nd(t){let e=[],n=t.trim();n.startsWith("```")&&(n=n.replace(/^```(?:json)?\s*\n?/,"").replace(/\n?```\s*$/,""),e.push("markdown fences"));let r=Us(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=Us(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=Us(n),r!==void 0))return{parsed:r,json:n,fixesApplied:e}}for(let[o,a]of AP){let l=a(n);if(l!==void 0){let c=Us(l);if(c!==void 0)return{parsed:c,json:l,fixesApplied:[...e,o]}}}let i=PP(t);return i!==void 0?{...i,fixesApplied:[...e,"extracted last JSON value"]}:{parsed:void 0,json:n,fixesApplied:e}}function Ld(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=xP(SP(n),{level:9}),s=RP(r),i=`${Jb}:${s}`;return i.length>_P?"":"#"+Id+i}catch{return""}}function Md(t){try{let e=t.startsWith("#")?t.slice(1):t;if(!e.startsWith(Id))return;let n=e.slice(Id.length),r=n.indexOf(":");if(r===-1||n.slice(0,r)!==Jb)return;let s=IP(n.slice(r+1)),i=JSON.parse(kP(EP(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 RP(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 IP(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 AP,Id,Jb,_P,Wb=v(()=>{AP=[["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",TP],["arithmetic constants",CP]];Id="tb=",Jb="1",_P=6e4});var qt=v(()=>{xn();mr();Pd();Ub();Wb();ua();Ad();Td();kd();Ed();Cd()});import{readFileSync as Kb,existsSync as $P}from"fs";import*as at from"path";function Hb(t){return[...t?[`.env.${t}.local`,`.env.${t}`]:[],".env.local",".env"]}function be(t,e=process.cwd()){let n={},r=[];for(let s of Hb(t)){let i;try{i=Kb(at.resolve(e,s),"utf-8")}catch{continue}r.push(s);for(let[o,a]of zb(i))process.env[o]===void 0&&(process.env[o]=a,n[o]=s)}return{mode:t,sources:n,loaded:r}}function*zb(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 ma(t,e=process.cwd()){for(let n of Hb()){let r;try{r=Kb(at.resolve(e,n),"utf-8")}catch{continue}for(let[s,i]of zb(r))if(s===t)return i}return process.env[t]}function NP(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 Yb(){return`.env loads from ${process.cwd()} (the directory you ran from, not the bulb's)`}function Jt(t,e,n){let{sources:r,mode:s,loaded:i}=t,o=process.cwd(),a=at.dirname(e),l=`(mode: ${s??"none"})`,c=n?NP(n):[],u=c.filter(p=>r[p]).map(p=>`${p} \u2190 ${r[p]}`);u.length?console.log(`env: ${u.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=at.resolve(a)!==at.resolve(o);if(d)for(let p of[".env.local",".env"])$P(at.join(a,p))&&console.log(`env: ${at.join(a,p)} present but not loaded (cwd is ${o})`);let f=c.filter(p=>process.env[p]===void 0);if(f.length){let p=d?` \u2014 try running from ${a}`:"";console.log(`env: server.ts reads ${f.join(", ")} but ${f.length>1?"they are":"it's"} unset${p}`)}}var Ze=v(()=>{"use strict"});function bt(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=En(n)}catch{return`Unknown provider '${n}'.`}if(n==="ollama")return{apiKey:"",baseUrl:`${hr(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=pr[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 ${Yb()}.`}function Wt(t,e){let n=[...e.system?[{role:"system",content:e.system}]:[],...e.messages.map(r=>({role:r.role,content:r.content}))];return Od(t,{messages:n,stream:!0,effort:Mb(e.effort),webSearch:e.webSearch,signal:e.signal})}var ga=v(()=>{"use strict";qt();qt();Ze();kn()});import{readFileSync as rF,existsSync as LP}from"fs";import*as wr from"path";import{fileURLToPath as MP}from"url";function DP(){let t=wr.dirname(MP(import.meta.url));for(;!LP(wr.join(t,"package.json"));){let e=wr.dirname(t);if(e===t)break;t=e}return t}function qs(){return wr.join(DP(),"SKILL.md")}var Dd=v(()=>{"use strict"});import{transform as BP}from"sucrase";function Bd(t,e={}){let n=e.serverOnly?["typescript"]:["typescript","jsx"];try{let{code:r}=BP(t,{transforms:n,jsxRuntime:"automatic",jsxImportSource:e.jsxImportSource||"react",production:!0});return{code:r}}catch(r){return{code:"",error:String(r)}}}var Vb=v(()=>{});function jP(t){return t.map(e=>`${e.type} (line ${e.lineNumber}): ${e.message.split(`
542
542
  `)[0]}`).join(`
543
- `)}function Wb(t,e){let n=Ms(t,{target:"client",dependencies:e}).filter(r=>r.type==="UNDECLARED_IMPORT");if(n.length)throw new Error(`Lint failed:
544
- ${LP(n)}`)}var Kb=S(()=>{"use strict";oa()});var Kt,Js,Bd,Ws=S(()=>{Kt="https://esm.sh",Js="https://cdn.jsdelivr.net/npm/",Bd="https://data.jsdelivr.com/v1/package/npm/"});function Hb(t){let e=(t||"").replace(/^\/+/,"").replace(/\/+$/,"");return e?e.split("/"):[]}var j,Sr,zb,Ks=S(()=>{Ws();j=class t{constructor(e,n,r){let s=typeof e=="string"?t.parse(e):e;this.name=s.name,this.version=Sr(n??s.version),this.subpath=Sr(r??s.subpath)}static parse(e){let n=Hb(e||"");if(!n.length)return new t({name:""});if(n[0].startsWith("@")){let s=n[0],[i,o]=zb(n[1]??""),a=Sr(n.slice(2).join("/"));return new t({name:`${s}/${i}`,version:o,subpath:a})}else{let[s,i]=zb(n[0]),o=Sr(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(Kt).host,s=new URL(Js).host;if(n.host===r){let i=Hb(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:Sr(e),subpath:this.subpath})}static isBare(e){return!e||e.startsWith(".")||e.startsWith("/")?!1:!/^[a-z][a-z0-9+.-]*:/i.test(e)}},Sr=t=>t&&t.length?t:void 0,zb=t=>{let e=t.indexOf("@");return e<0?[t,void 0]:[t.slice(0,e),Sr(t.slice(e+1))]}});async function Te(t){try{return await t()}catch{return}}var ya=S(()=>{});function Tn(t){let e=t||"";return e.startsWith("./")?e.slice(2):e.replace(/^\/+/,"")}function jd(t){return t.startsWith("./")?t:`./${t}`}var Hs,Fd=S(()=>{Ks();ya();Ws();Hs=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 j(e):e;return`${Js}${n.name}${n.version?`@${n.version}`:""}/`}file(e,n){return new URL(Tn(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(",")),`${Kt}/${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),`${Kt}/${e}`]);return this.pinCache.set(e,{value:s,ts:n}),s}async tryResolveFromUrls(e){for(let n of e){let r=await Te(()=>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 Te(()=>this.http.getJson(`${Bd}${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=j.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:u,peerDependencies:d,peerDependenciesMeta:f}=r;return{name:e,version:n,dependencies:u,peerDependencies:d,peerDependenciesMeta:f}}let s=this.packageJson(new j(`${e}@${n}`)),i=await Te(()=>this.http.getJson(s));if(!i)return;let o=u=>u&&Object.keys(u).length?u: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 Yb,zs,Ud,MP,Ys,ba=S(()=>{Yb=t=>t.startsWith("@types/"),zs=t=>Object.keys(t?.peerDependencies||{}).filter(e=>!Yb(e)),Ud=t=>Object.keys(t?.dependencies||{}).filter(e=>!Yb(e)),MP=t=>zs(t).filter(e=>!t?.peerDependenciesMeta?.[e]?.optional),Ys=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 MP(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=>zs(i.meta))),r=new Map;for(let i of e)for(let o of Ud(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:zs(i.meta).length>0,isSharedDep:s.has(i.name)}]))}}});var Vs,qd=S(()=>{Ks();ya();Vs=class{constructor(e,n,r){this.cache=e,this.cdn=n,this.semver=r}async learnExactVersion(e){let n=await Te(()=>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 Te(()=>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 Te(()=>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 j(e),s=r.root(),i=n[s],o=i?await Te(()=>this.resolveExactForRoot(s,i)):void 0;return{effectivePackage:o?r.withVersion(o).format():e,root:s,range:i,pinned:o}}}});import{init as DP,parse as BP}from"es-module-lexer";var kr,Jd=S(()=>{Ks();Ws();ba();kr=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))j.isBare(s[1])&&n.add(s[1])}return Array.from(n)}async extractImports(e){let n=new Set,r=s=>{j.isBare(s)&&n.add(s)};try{await DP;let[s]=BP(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(j.rootOf(d))),i=[...new Set(s.map(j.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)),u=this.buildEntries([...s,...c.map(d=>d.name)],a,l);return{importMap:{imports:Object.fromEntries(u)},prefetchUrls:u.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(j.rootOf(p));return new j(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!==j.rootOf(p)).map(j.rootOf)),l=[],c=new Set,u=new Set(e.filter(p=>p===j.rootOf(p))),d=new Set;for(let p of e){let h=j.rootOf(p),m=s.get(h),{isPeerRoot:g,hasPeers:v,isSharedDep:A}=r.get(h),C=a.has(h),x=p!==h,I=!(g||A)&&(C||!v),L=this.singletonDepsOf(m,o),T=x&&u.has(h);T&&d.add(h);let F=T?[...L,h]:L.length?L:void 0;l.push([p,this.cdn.buildEsmUrl(i(p),{bundle:I,external:F})]),c.add(p)}let f=new Set([...o,...d]);for(let p of f)s.has(p)&&(c.has(p)||l.push([p,this.cdn.buildEsmUrl(i(p),{})]),l.push([`${p}/`,`${Kt}/${i(p)}/`]));return l}singletonDepsOf(e,n){return[...new Set([...zs(e.meta),...Ud(e.meta)])].filter(r=>n.has(r))}};kr.importPatterns=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g]});import{gt as Vb,satisfies as jP,maxSatisfying as Gb,major as FP,valid as UP,validRange as qP}from"semver";var wa,Cn,Wd=S(()=>{wa=class{cmp(e,n){return e===n?0:Vb(e,n)?1:Vb(n,e)?-1:0}satisfies(e,n){return!e||!e.trim()?!0:!!jP(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=Gb(e,r,{includePrerelease:!1});if(a)return a}return Gb(e,r,{includePrerelease:!0})??void 0}majorOf(e){return FP(e)}isExactVersion(e){return UP(e)!==null}isRange(e){return qP(e)!==null}},Cn=new wa});function JP(t){return Math.min(9e5*Math.pow(2,Math.max(0,t-1)),864e5)}var On,Xb=S(()=>{ya();On=class{constructor(e){this.store=e}async isNegative(e){let n=await Te(()=>this.store.get(e));return!!n&&n.until>Date.now()}async recordNegative(e){let r=((await Te(()=>this.store.get(e)))?.attempts||0)+1;await Te(()=>this.store.set(e,{until:Date.now()+JP(r),attempts:r}))}async clearNegative(e){await Te(()=>this.store.delete(e))}}});function Qb(t,e){let n=new Hs(t,e),r=new Ys(n),s=new Vs(t,n,Cn);return{packageService:new kr(s,n,r),versionResolver:s,cdnClient:n,peerResolver:r}}var wt=S(()=>{Fd();ba();qd();Jd();Wd();Ks();Wd();Ws();Fd();ba();qd();Jd();Xb()});import*as Kd from"fs/promises";import*as Zb from"crypto";function et(t){return Zb.createHash("sha1").update(t).digest("hex")}async function vt(t){try{return JSON.parse(await Kd.readFile(t,"utf8"))}catch{return}}async function va(t){try{return await Kd.readFile(t,"utf8")}catch{return}}var xr=S(()=>{"use strict"});import*as zt from"fs/promises";import*as St from"path";import*as tw from"os";function te(){return Hd||(Hd=KP().catch(()=>ht())),Hd}function ka(t,e){return St.join(WP,et(t),e)}async function KP(){await zt.mkdir(Ht,{recursive:!0});let t=St.join(Ht,"version.json");if((await vt(t))?.version===ew)return;let n=await zt.readdir(Ht).catch(()=>[]);await Promise.all(n.map(r=>zt.rm(St.join(Ht,r),{recursive:!0,force:!0}))),await zt.writeFile(t,JSON.stringify({version:ew})+`
545
- `,"utf8")}var ew,Ht,Gs,Xs,Sa,WP,Hd,Er=S(()=>{"use strict";xr();Be();ew=1,Ht=St.join(tw.homedir(),".typebulb","cache"),Gs=St.join(Ht,"packages"),Xs=St.join(Ht,"proxy"),Sa=St.join(Ht,"dts"),WP=St.join(Ht,"emit")});import*as Yt from"fs/promises";import*as nw from"path";async function Fe(t,e){let n=`${t}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;try{await Yt.mkdir(nw.dirname(t),{recursive:!0}),await Yt.writeFile(n,e,"utf8")}catch{ht();return}await Yt.rename(n,t).catch(async()=>{await Yt.rm(n,{force:!0}).catch(()=>{})})}var Qs=S(()=>{"use strict";Be()});var Ar,zd=S(()=>{"use strict";Qs();xr();Ar=class{constructor(e){this.filePath=e}mem;loadPromise;load(){return this.mem?Promise.resolve(this.mem):(this.loadPromise||(this.loadPromise=vt(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 iw from"fs/promises";import*as tt from"path";function sw(t,e){return tt.join(HP,xa(t),encodeURIComponent(e)+".json")}function xa(t){return t.replace(/\//g,"__")}var Yd,rw,HP,zP,Ea,ow=S(()=>{"use strict";wt();Er();Qs();zd();xr();Yd=tt.join(Gs,"indexes"),rw=tt.join(Gs,"pinned"),HP=tt.join(Gs,"meta"),zP=tt.join(Gs,"negative.json"),Ea=class{pinnedMem=new Map;indexMem=new Map;metaMem=new Map;negativeCache=new On(new Ar(zP));async getPinnedExact(e,n){let r=`${e}@${n}`;if(this.pinnedMem.has(r))return this.pinnedMem.get(r);await te();let s=await va(tt.join(rw,et(r)+".txt"));return this.pinnedMem.set(r,s),s}async setPinnedExact(e,n,r){let s=`${e}@${n}`;this.pinnedMem.set(s,r),await te(),await Fe(tt.join(rw,et(s)+".txt"),r)}async getIndex(e){if(this.indexMem.has(e))return this.indexMem.get(e);await te();let n=await vt(tt.join(Yd,xa(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 te(),await Fe(tt.join(Yd,xa(e)+".json"),JSON.stringify(s))}async invalidateVersionsCache(e){this.indexMem.delete(e),await iw.rm(tt.join(Yd,xa(e)+".json"),{force:!0}).catch(()=>{})}async isNegative(e){return await te(),this.negativeCache.isNegative(e)}async recordNegative(e){await te(),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 te();let s=await vt(sw(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 te(),await Fe(sw(e,n),JSON.stringify(o))}}});var aw,lw=S(()=>{"use strict";aw={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 YP,Aa,cw,uw,n2,Vd=S(()=>{"use strict";wt();ow();lw();YP=new Ea,{packageService:Aa,versionResolver:cw,cdnClient:uw,peerResolver:n2}=Qb(YP,aw)});function Ta(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function dw(){return` <script>
546
- ${oy}
543
+ `)}function Gb(t,e){let n=Ms(t,{target:"client",dependencies:e}).filter(r=>r.type==="UNDECLARED_IMPORT");if(n.length)throw new Error(`Lint failed:
544
+ ${jP(n)}`)}var Xb=v(()=>{"use strict";oa()});var Kt,Js,jd,Ws=v(()=>{Kt="https://esm.sh",Js="https://cdn.jsdelivr.net/npm/",jd="https://data.jsdelivr.com/v1/package/npm/"});function Qb(t){let e=(t||"").replace(/^\/+/,"").replace(/\/+$/,"");return e?e.split("/"):[]}var F,vr,Zb,Ks=v(()=>{Ws();F=class t{constructor(e,n,r){let s=typeof e=="string"?t.parse(e):e;this.name=s.name,this.version=vr(n??s.version),this.subpath=vr(r??s.subpath)}static parse(e){let n=Qb(e||"");if(!n.length)return new t({name:""});if(n[0].startsWith("@")){let s=n[0],[i,o]=Zb(n[1]??""),a=vr(n.slice(2).join("/"));return new t({name:`${s}/${i}`,version:o,subpath:a})}else{let[s,i]=Zb(n[0]),o=vr(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(Kt).host,s=new URL(Js).host;if(n.host===r){let i=Qb(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:vr(e),subpath:this.subpath})}static isBare(e){return!e||e.startsWith(".")||e.startsWith("/")?!1:!/^[a-z][a-z0-9+.-]*:/i.test(e)}},vr=t=>t&&t.length?t:void 0,Zb=t=>{let e=t.indexOf("@");return e<0?[t,void 0]:[t.slice(0,e),vr(t.slice(e+1))]}});async function Te(t){try{return await t()}catch{return}}var ya=v(()=>{});function Tn(t){let e=t||"";return e.startsWith("./")?e.slice(2):e.replace(/^\/+/,"")}function Fd(t){return t.startsWith("./")?t:`./${t}`}var Hs,Ud=v(()=>{Ks();ya();Ws();Hs=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`${Js}${n.name}${n.version?`@${n.version}`:""}/`}file(e,n){return new URL(Tn(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(",")),`${Kt}/${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),`${Kt}/${e}`]);return this.pinCache.set(e,{value:s,ts:n}),s}async tryResolveFromUrls(e){for(let n of e){let r=await Te(()=>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 Te(()=>this.http.getJson(`${jd}${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:u,peerDependencies:d,peerDependenciesMeta:f}=r;return{name:e,version:n,dependencies:u,peerDependencies:d,peerDependenciesMeta:f}}let s=this.packageJson(new F(`${e}@${n}`)),i=await Te(()=>this.http.getJson(s));if(!i)return;let o=u=>u&&Object.keys(u).length?u: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 ew,zs,qd,FP,Ys,ba=v(()=>{ew=t=>t.startsWith("@types/"),zs=t=>Object.keys(t?.peerDependencies||{}).filter(e=>!ew(e)),qd=t=>Object.keys(t?.dependencies||{}).filter(e=>!ew(e)),FP=t=>zs(t).filter(e=>!t?.peerDependenciesMeta?.[e]?.optional),Ys=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 FP(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=>zs(i.meta))),r=new Map;for(let i of e)for(let o of qd(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:zs(i.meta).length>0,isSharedDep:s.has(i.name)}]))}}});var Vs,Jd=v(()=>{Ks();ya();Vs=class{constructor(e,n,r){this.cache=e,this.cdn=n,this.semver=r}async learnExactVersion(e){let n=await Te(()=>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 Te(()=>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 Te(()=>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 Te(()=>this.resolveExactForRoot(s,i)):void 0;return{effectivePackage:o?r.withVersion(o).format():e,root:s,range:i,pinned:o}}}});import{init as UP,parse as qP}from"es-module-lexer";var Sr,Wd=v(()=>{Ks();Ws();ba();Sr=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 UP;let[s]=qP(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)),u=this.buildEntries([...s,...c.map(d=>d.name)],a,l);return{importMap:{imports:Object.fromEntries(u)},prefetchUrls:u.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 m=s.get(F.rootOf(p));return new F(p).withVersion(m.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,u=new Set(e.filter(p=>p===F.rootOf(p))),d=new Set;for(let p of e){let m=F.rootOf(p),h=s.get(m),{isPeerRoot:y,hasPeers:k,isSharedDep:T}=r.get(m),P=a.has(m),E=p!==m,_=!(y||T)&&(P||!k),I=this.singletonDepsOf(h,o),A=E&&u.has(m);A&&d.add(m);let M=A?[...I,m]:I.length?I:void 0;l.push([p,this.cdn.buildEsmUrl(i(p),{bundle:_,external:M})]),c.add(p)}let f=new Set([...o,...d]);for(let p of f)s.has(p)&&(c.has(p)||l.push([p,this.cdn.buildEsmUrl(i(p),{})]),l.push([`${p}/`,`${Kt}/${i(p)}/`]));return l}singletonDepsOf(e,n){return[...new Set([...zs(e.meta),...qd(e.meta)])].filter(r=>n.has(r))}};Sr.importPatterns=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g]});import{gt as tw,satisfies as JP,maxSatisfying as nw,major as WP,valid as KP,validRange as HP}from"semver";var wa,Cn,Kd=v(()=>{wa=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:!!JP(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=nw(e,r,{includePrerelease:!1});if(a)return a}return nw(e,r,{includePrerelease:!0})??void 0}majorOf(e){return WP(e)}isExactVersion(e){return KP(e)!==null}isRange(e){return HP(e)!==null}},Cn=new wa});function zP(t){return Math.min(9e5*Math.pow(2,Math.max(0,t-1)),864e5)}var On,rw=v(()=>{ya();On=class{constructor(e){this.store=e}async isNegative(e){let n=await Te(()=>this.store.get(e));return!!n&&n.until>Date.now()}async recordNegative(e){let r=((await Te(()=>this.store.get(e)))?.attempts||0)+1;await Te(()=>this.store.set(e,{until:Date.now()+zP(r),attempts:r}))}async clearNegative(e){await Te(()=>this.store.delete(e))}}});function sw(t,e){let n=new Hs(t,e),r=new Ys(n),s=new Vs(t,n,Cn);return{packageService:new Sr(s,n,r),versionResolver:s,cdnClient:n,peerResolver:r}}var wt=v(()=>{Ud();ba();Jd();Wd();Kd();Ks();Kd();Ws();Ud();ba();Jd();Wd();rw()});import*as Hd from"fs/promises";import*as iw from"crypto";function et(t){return iw.createHash("sha1").update(t).digest("hex")}async function vt(t){try{return JSON.parse(await Hd.readFile(t,"utf8"))}catch{return}}async function va(t){try{return await Hd.readFile(t,"utf8")}catch{return}}var kr=v(()=>{"use strict"});import*as zt from"fs/promises";import*as St from"path";import*as aw from"os";function te(){return zd||(zd=VP().catch(()=>ht())),zd}function ka(t,e){return St.join(YP,et(t),e)}async function VP(){await zt.mkdir(Ht,{recursive:!0});let t=St.join(Ht,"version.json");if((await vt(t))?.version===ow)return;let n=await zt.readdir(Ht).catch(()=>[]);await Promise.all(n.map(r=>zt.rm(St.join(Ht,r),{recursive:!0,force:!0}))),await zt.writeFile(t,JSON.stringify({version:ow})+`
545
+ `,"utf8")}var ow,Ht,Gs,Xs,Sa,YP,zd,xr=v(()=>{"use strict";kr();Be();ow=1,Ht=St.join(aw.homedir(),".typebulb","cache"),Gs=St.join(Ht,"packages"),Xs=St.join(Ht,"proxy"),Sa=St.join(Ht,"dts"),YP=St.join(Ht,"emit")});import*as Yt from"fs/promises";import*as lw from"path";async function Fe(t,e){let n=`${t}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;try{await Yt.mkdir(lw.dirname(t),{recursive:!0}),await Yt.writeFile(n,e,"utf8")}catch{ht();return}await Yt.rename(n,t).catch(async()=>{await Yt.rm(n,{force:!0}).catch(()=>{})})}var Qs=v(()=>{"use strict";Be()});var Er,Yd=v(()=>{"use strict";Qs();kr();Er=class{constructor(e){this.filePath=e}mem;loadPromise;load(){return this.mem?Promise.resolve(this.mem):(this.loadPromise||(this.loadPromise=vt(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 dw from"fs/promises";import*as tt from"path";function uw(t,e){return tt.join(GP,xa(t),encodeURIComponent(e)+".json")}function xa(t){return t.replace(/\//g,"__")}var Vd,cw,GP,XP,Ea,fw=v(()=>{"use strict";wt();xr();Qs();Yd();kr();Vd=tt.join(Gs,"indexes"),cw=tt.join(Gs,"pinned"),GP=tt.join(Gs,"meta"),XP=tt.join(Gs,"negative.json"),Ea=class{pinnedMem=new Map;indexMem=new Map;metaMem=new Map;negativeCache=new On(new Er(XP));async getPinnedExact(e,n){let r=`${e}@${n}`;if(this.pinnedMem.has(r))return this.pinnedMem.get(r);await te();let s=await va(tt.join(cw,et(r)+".txt"));return this.pinnedMem.set(r,s),s}async setPinnedExact(e,n,r){let s=`${e}@${n}`;this.pinnedMem.set(s,r),await te(),await Fe(tt.join(cw,et(s)+".txt"),r)}async getIndex(e){if(this.indexMem.has(e))return this.indexMem.get(e);await te();let n=await vt(tt.join(Vd,xa(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 te(),await Fe(tt.join(Vd,xa(e)+".json"),JSON.stringify(s))}async invalidateVersionsCache(e){this.indexMem.delete(e),await dw.rm(tt.join(Vd,xa(e)+".json"),{force:!0}).catch(()=>{})}async isNegative(e){return await te(),this.negativeCache.isNegative(e)}async recordNegative(e){await te(),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 te();let s=await vt(uw(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 te(),await Fe(uw(e,n),JSON.stringify(o))}}});var pw,hw=v(()=>{"use strict";pw={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 QP,Aa,mw,gw,u2,Gd=v(()=>{"use strict";wt();fw();hw();QP=new Ea,{packageService:Aa,versionResolver:mw,cdnClient:gw,peerResolver:u2}=sw(QP,pw)});function Ta(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function yw(){return` <script>
546
+ ${ly}
547
547
  (function () {
548
548
  try {
549
549
  var key = function () { return 'tb-scroll:' + location.pathname + location.search; };
@@ -601,7 +601,7 @@ ${oy}
601
601
  });
602
602
  } catch (e) {}
603
603
  })();
604
- </script>`}var kt,fw,Gd,VP,GP,Oa,Tr=S(()=>{"use strict";Z();Z();kt=t=>t.replace(/<\/script/gi,"<\\/script");fw=30*6e4,Gd=1e3,VP=6e4,GP=3e4,Oa=(t="'/__reload'")=>`
604
+ </script>`}var kt,bw,Xd,ZP,e_,Oa,Ar=v(()=>{"use strict";ee();ee();kt=t=>t.replace(/<\/script/gi,"<\\/script");bw=30*6e4,Xd=1e3,ZP=6e4,e_=3e4,Oa=(t="'/__reload'")=>`
605
605
  let es = null;
606
606
  let bootId = null;
607
607
  let firstErrorAt = 0;
@@ -616,9 +616,9 @@ ${oy}
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 <= ${VP}) return;
619
+ if (Date.now() - firstErrorAt <= ${ZP}) return;
620
620
  es.close();
621
- backoff = Math.min(${GP}, backoff ? backoff * 2 : ${Gd} * 2);
621
+ backoff = Math.min(${e_}, backoff ? backoff * 2 : ${Xd} * 2);
622
622
  setTimeout(tbConnect, backoff);
623
623
  };
624
624
  };
@@ -634,7 +634,7 @@ ${oy}
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 pw,hw=S(()=>{"use strict";Tr();Z();pw=`
637
+ tbConnect();`});var ww,vw=v(()=>{"use strict";Ar();ee();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 @@ ${oy}
1078
1078
  },
1079
1079
 
1080
1080
  // Environment ('inline' when running as a bulb-in-a-bulb)
1081
- mode: isFramed ? '${er.inline}' : '${er.local}',
1081
+ mode: isFramed ? '${Zn.inline}' : '${Zn.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
@@ -1594,27 +1594,27 @@ ${Oa("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:u,source:d,bulbKey:f,compileError:p}=t,h=s.trim()||'<div id="app"></div>',m=c?"":`
1598
- `+Mu,g={imports:t_(a.imports)};return`<!DOCTYPE html>
1597
+ `});function Sw(t){let{name:e,code:n,css:r,html:s,data:i,insight:o,importMap:a,theme:l,inline:c,dir:u,source:d,bulbKey:f,compileError:p}=t,m=s.trim()||'<div id="app"></div>',h=c?"":`
1598
+ `+Mu,y={imports:i_(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
1603
  <title>${Ta(e)} - typebulb</title>
1604
1604
  ${Ca(e,l)}
1605
- ${c?"":dw()}
1605
+ ${c?"":yw()}
1606
1606
  <script type="importmap">
1607
- ${JSON.stringify(g,null,2)}
1607
+ ${JSON.stringify(y,null,2)}
1608
1608
  </script>
1609
1609
  <style>
1610
- ${As}${m}
1610
+ ${As}${h}
1611
1611
  </style>
1612
1612
  <style>
1613
1613
  ${r}
1614
1614
  </style>
1615
1615
  </head>
1616
1616
  <body>
1617
- ${h}
1617
+ ${m}
1618
1618
 
1619
1619
  ${i.length>0?`<script>window.__TB_DATA__ = ${kt(JSON.stringify(i))};</script>`:""}
1620
1620
  ${o?`<script>window.__TB_INSIGHT__ = ${kt(JSON.stringify(o))};</script>`:""}
@@ -1623,20 +1623,20 @@ ${f?`<script>window.__TB_BULB__ = ${kt(JSON.stringify(f))};</script>`:""}
1623
1623
  ${p?`<script>window.__TB_COMPILE_ERROR__ = ${kt(JSON.stringify(p))};</script>`:""}
1624
1624
 
1625
1625
  <script>
1626
- ${ly}
1627
- ${pw}
1626
+ ${uy}
1627
+ ${ww}
1628
1628
  </script>
1629
1629
 
1630
- ${e_}
1630
+ ${s_}
1631
1631
 
1632
- ${QP(n,d)}
1632
+ ${n_(n,d)}
1633
1633
  </body>
1634
- </html>`}function QP(t,e){let n=["",...XP],r=e?Array(Math.max(0,e.codeLine-n.length-1)).fill(""):[],s=[...n,...r,kt(t)].join(`
1635
- `);return`<script type="module">${s}${ZP(e,s)}
1636
- </script>`}function ZP(t,e){if(!t)return"";let n=e.split(`
1634
+ </html>`}function n_(t,e){let n=["",...t_],r=e?Array(Math.max(0,e.codeLine-n.length-1)).fill(""):[],s=[...n,...r,kt(t)].join(`
1635
+ `);return`<script type="module">${s}${r_(e,s)}
1636
+ </script>`}function r_(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 t_(t){let e={};for(let[n,r]of Object.entries(t))e[n]=r.startsWith("https://")?"/proxy/"+r:r;return e}var XP,e_,gw=S(()=>{"use strict";Z();hw();Tr();XP=["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) */"];e_=`<script>
1639
+ //# sourceMappingURL=data:application/json;charset=utf-8,${encodeURIComponent(JSON.stringify(r))}`}function i_(t){let e={};for(let[n,r]of Object.entries(t))e[n]=r.startsWith("https://")?"/proxy/"+r:r;return e}var t_,s_,kw=v(()=>{"use strict";ee();vw();Ar();t_=["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) */"];s_=`<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 @@ ${QP(n,d)}
1735
1735
  }
1736
1736
  });
1737
1737
  })();
1738
- </script>`});import*as _a from"fs/promises";import*as Pa from"path";import{existsSync as yw,readFileSync as n_}from"fs";import{execFile as r_}from"child_process";import{promisify as s_}from"util";import{builtinModules as i_}from"node:module";import{satisfies as o_}from"semver";async function Ra(t,e,n,r){let i=t.map(c=>u_(c,n)).filter(c=>!d_(c,e));if(i.length===0)return;let o=i.filter(c=>!c_.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 _a.mkdir(e,{recursive:!0});let a=Pa.join(e,"package.json");yw(a)||await _a.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 a_("npm",["install",...l,...i],{cwd:e,shell:!0})}function u_(t,e){if(!e||j.parse(t).version)return t;let n=e[t];return n?`${t}@${n}`:t}function d_(t,e){let{name:n,version:r}=j.parse(t),s=Pa.join(e,"node_modules",n);if(!yw(s))return!1;if(!r)return!0;try{let i=JSON.parse(n_(Pa.join(s,"package.json"),"utf-8")).version;return o_(i,r)}catch{return!1}}function Ia(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=j.rootOf(s);l_.has(i)||e.add(i)}return[...e]}var a_,l_,c_,Xd=S(()=>{"use strict";wt();a_=s_(r_),l_=new Set(i_),c_=/^(@[a-z0-9._-]+\/)?[a-z0-9._-]+(@[a-zA-Z0-9.^~*x-]+)?$/i});import*as Ue from"fs/promises";import*as Ie from"path";function Cr(t,e){let n=Ie.resolve(e,t),r=Ie.normalize(e),s=Ie.normalize(n);if(s!==r&&!s.startsWith(r+Ie.sep))throw new Error("Path traversal detected - access denied");return n}async function Zs(t,e){return Ue.readFile(Cr(t,e))}async function $a(t,e,n){let r=Cr(t,n);await Ue.mkdir(Ie.dirname(r),{recursive:!0}),await Ue.writeFile(r,typeof e=="string"?e:Buffer.from(e))}async function Na(t,e){let n=Cr(t,e),r=await Ue.readdir(n,{withFileTypes:!0});return Promise.all(r.map(async s=>{let i=await Ue.stat(Ie.join(n,s.name)).then(o=>o.mtimeMs).catch(()=>0);return{name:s.name,dir:s.isDirectory(),mtime:i}}))}async function La(t,e){let n=Cr(t,e);if(Ie.normalize(n)===Ie.normalize(e))throw new Error("Cannot remove the bulb's folder itself: remove its contents instead");await Ue.rm(n,{recursive:!0})}var Qd=S(()=>{"use strict"});async function bw(t){let e=bt(t.provider,t.model);if(typeof e=="string")throw new Error(e);let n=await Wt(e,t);if(!n.ok){let r=await br(n,e.protocol);throw new Error(r.message)}return{response:n,protocol:e.protocol}}async function f_(t){let{response:e,protocol:n}=await bw(t);return wr(e,n)}async function*p_(t){let{response:e,protocol:n}=await bw(t);yield*An(e,n)}function ww(t){let e=Object.assign(f_,{stream:p_}),n={read:async r=>{let s=await Zs(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 Zs(r,t)),write:async(r,s)=>(await $a(r,s,t),!0),list:async(r=".")=>Na(r,t),remove:async r=>(await La(r,t),!0)};globalThis.tb=Object.freeze({log:(...r)=>{console.log(...r)},ai:e,fs:n,dir:t,models:()=>yt(),aiAccess:la,mode:er.local})}var vw=S(()=>{"use strict";qt();Z();ga();kn();Qd()});import*as Vt from"fs/promises";import*as fe from"path";import{pathToFileURL as h_}from"url";async function Sw(t){let n=(await Vt.readdir(t)).find(r=>r.endsWith(".bulb.md"));return n?fe.join(t,n):void 0}function Or(t){let e=fe.resolve(t);return fe.join(fe.dirname(e),fe.basename(e).replace(/\.bulb\.md$/,""))}function Pr(t){let[e,n,r,s]=t.split(fe.sep).slice(-4);if(!(e!=="typebulbs"||n!=="u"||!r||!s?.endsWith(".bulb.md")))return{userSlug:r,slug:s.slice(0,-8)}}async function nt(t){let e=await Vt.readFile(t,"utf-8"),n=Un(e),r=dr(n);return{bulb:r,config:Kr(r.config),warnings:Dp(e),starts:n.starts}}function Zd(t){let e=fe.basename(t).replace(/\.bulb\.md$/i,"");return fe.join(fe.dirname(t),".typebulb",`${e}.server.mjs`)}async function ei(t,e,n,r){let s=Dd(t,{serverOnly:!0});if(s.error)throw new Error(`Server compilation error: ${s.error}`);let i=s.code;n&&(i=await Rp(i,n));let o=fe.join(fe.dirname(e),".typebulb");await Vt.mkdir(o,{recursive:!0});let a=Ia(i);a.length>0&&await Ra(a,o,r);let l=Zd(e);return await Vt.writeFile(l,i,"utf-8"),ww(Or(e)),await import(`${h_(l).href}?t=${Date.now()}`)}async function ef(t,e,n,r){let{bulb:s,config:i,starts:o}=await nt(t),a=Po(s.data),l,c=h=>{l??=h instanceof Error?h.message:String(h)};try{Wb(s.code,i.dependencies??{})}catch(h){c(h)}let u=Dd(s.code,{jsxImportSource:i.ts?.jsxImportSource});u.error&&c(u.error);let d={imports:{}};if(!l)try{({importMap:d}=await Aa.buildImportMap(u.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 f=mw({name:s.name,code:l?"":u.code,css:s.css,html:s.html,data:a,insight:s.insight,importMap:d,dir:Or(t),watch:e,source:{file:fe.basename(t),codeLine:o.get("code.tsx")??1},bulbKey:Rs(t),compileError:l}),p;return s.server&&n&&(p=await ei(s.server,t,r,i.dependencies)),{html:f,bulb:s,serverExports:p,buildError:l}}var Pn,xt=S(()=>{"use strict";Ls();Jb();Kb();Vd();gw();Xd();Ti();Be();vw();Pn=t=>fe.join(Or(t),"assets")});import*as $e from"fs/promises";import*as qe from"path";import{createHash as m_}from"crypto";async function nf(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 _r(t){try{return JSON.parse(t).error||t}catch{return t}}async function sf(t,e){try{let n=await fetch(ti(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}): ${_r(await n.text())}`}}catch(n){return{error:n instanceof Error?n.message:String(n)}}}function of(t,e){be(e);let n=process.env.TYPEBULB_ORIGIN||g_;try{return Ba(t,process.cwd(),n)}catch(r){console.error(r instanceof Error?r.message:String(r)),process.exit(1)}}function Ba(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,Ma(l,c))}}let r=qe.resolve(e,t),s=Pr(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 y_(t,e){let n=await sf(t,e);if("error"in n||!n.entries.length)return{kind:"none"};let r=n.entries,s=Pn(t.dest),i=[],o=[],a=0;for(let l of r){let c=await $e.readFile(qe.join(s,...l.path.split("/"))).catch(()=>{});c===void 0?i.push(l.path):rf(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 b_(t,e,n){let r=Pn(t.dest),s=[],i=0;return await nf(e.toGet,4,async o=>{try{let a=await fetch(`${ti(t)}/${Da(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 $e.mkdir(qe.dirname(l),{recursive:!0}),await $e.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 ja(t,e={}){let n=await fetch(tf(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 $e.readFile(t.dest,"utf-8")}catch{}let o=i!==void 0&&w_(i,s);if(i!==void 0&&!o&&!e.force){let{mtime:c}=await $e.stat(t.dest);return{kind:"conflict",dest:t.dest,localMtime:c,remoteLastModified:n.headers.get("last-modified")??void 0}}let a=await y_(t,e);if(a.kind==="conflict")return{kind:"asset-conflict",dest:t.dest,paths:a.paths};if(!o){await $e.mkdir(qe.dirname(t.dest),{recursive:!0}),await $e.writeFile(t.dest,s);let c=new Date(n.headers.get("last-modified")??"");isNaN(c.getTime())||await $e.utimes(t.dest,new Date,c)}let l=a.kind==="plan"?await b_(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 w_(t,e){let n=i=>i.replace(/\r\n/g,`
1742
- `),r=ze(n(t)),s=ze(n(e));return!r||!s?n(t)===n(e):r.frontmatter.name===s.frontmatter.name&&He.every(i=>(r.files.get(de[i].path)||"")===(s.files.get(de[i].path)||""))}async function xw(t,e){t||(console.error("Usage: typebulb pull <bulb url | typebulbs/u/<user>/<slug>.bulb.md>"),process.exit(1));let n=of(t,e.mode),r=`${n.origin}/u/${n.userSlug}/${n.slug}`,s;try{s=await ja(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)"}`),kw(s.assets);return;case"up-to-date":console.log(`up to date: ${i}`),kw(s.assets);return;case"conflict":console.error(`Refusing to overwrite ${i} \u2014 it differs from ${r}
1738
+ </script>`});import*as _a from"fs/promises";import*as Pa from"path";import{existsSync as xw,readFileSync as o_}from"fs";import{execFile as a_}from"child_process";import{promisify as l_}from"util";import{builtinModules as c_}from"node:module";import{satisfies as u_}from"semver";async function Ra(t,e,n,r){let i=t.map(c=>h_(c,n)).filter(c=>!m_(c,e));if(i.length===0)return;let o=i.filter(c=>!p_.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 _a.mkdir(e,{recursive:!0});let a=Pa.join(e,"package.json");xw(a)||await _a.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 h_(t,e){if(!e||F.parse(t).version)return t;let n=e[t];return n?`${t}@${n}`:t}function m_(t,e){let{name:n,version:r}=F.parse(t),s=Pa.join(e,"node_modules",n);if(!xw(s))return!1;if(!r)return!0;try{let i=JSON.parse(o_(Pa.join(s,"package.json"),"utf-8")).version;return u_(i,r)}catch{return!1}}function Ia(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);f_.has(i)||e.add(i)}return[...e]}var d_,f_,p_,Qd=v(()=>{"use strict";wt();d_=l_(a_),f_=new Set(c_),p_=/^(@[a-z0-9._-]+\/)?[a-z0-9._-]+(@[a-zA-Z0-9.^~*x-]+)?$/i});import*as Ue from"fs/promises";import*as Ie from"path";function Tr(t,e){let n=Ie.resolve(e,t),r=Ie.normalize(e),s=Ie.normalize(n);if(s!==r&&!s.startsWith(r+Ie.sep))throw new Error("Path traversal detected - access denied");return n}async function Zs(t,e){return Ue.readFile(Tr(t,e))}async function $a(t,e,n){let r=Tr(t,n);await Ue.mkdir(Ie.dirname(r),{recursive:!0}),await Ue.writeFile(r,typeof e=="string"?e:Buffer.from(e))}async function Na(t,e){let n=Tr(t,e),r=await Ue.readdir(n,{withFileTypes:!0});return Promise.all(r.map(async s=>{let i=await Ue.stat(Ie.join(n,s.name)).then(o=>o.mtimeMs).catch(()=>0);return{name:s.name,dir:s.isDirectory(),mtime:i}}))}async function La(t,e){let n=Tr(t,e);if(Ie.normalize(n)===Ie.normalize(e))throw new Error("Cannot remove the bulb's folder itself: remove its contents instead");await Ue.rm(n,{recursive:!0})}var Zd=v(()=>{"use strict"});async function Ew(t){let e=bt(t.provider,t.model);if(typeof e=="string")throw new Error(e);let n=await Wt(e,t);if(!n.ok){let r=await yr(n,e.protocol);throw new Error(r.message)}return{response:n,protocol:e.protocol}}async function g_(t){let{response:e,protocol:n}=await Ew(t);return br(e,n)}async function*y_(t){let{response:e,protocol:n}=await Ew(t);yield*An(e,n)}function Aw(t){let e=Object.assign(g_,{stream:y_}),n={read:async r=>{let s=await Zs(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 Zs(r,t)),write:async(r,s)=>(await $a(r,s,t),!0),list:async(r=".")=>Na(r,t),remove:async r=>(await La(r,t),!0)};globalThis.tb=Object.freeze({log:(...r)=>{console.log(...r)},ai:e,fs:n,dir:t,models:()=>yt(),aiAccess:la,mode:Zn.local})}var Tw=v(()=>{"use strict";qt();ee();ga();kn();Zd()});import*as Vt from"fs/promises";import*as fe from"path";import{pathToFileURL as b_}from"url";async function Cw(t){let n=(await Vt.readdir(t)).find(r=>r.endsWith(".bulb.md"));return n?fe.join(t,n):void 0}function Cr(t){let e=fe.resolve(t);return fe.join(fe.dirname(e),fe.basename(e).replace(/\.bulb\.md$/,""))}function Or(t){let[e,n,r,s]=t.split(fe.sep).slice(-4);if(!(e!=="typebulbs"||n!=="u"||!r||!s?.endsWith(".bulb.md")))return{userSlug:r,slug:s.slice(0,-8)}}async function nt(t){let e=await Vt.readFile(t,"utf-8"),n=Fn(e),r=ur(n);return{bulb:r,config:Kr(r.config),warnings:jp(e),starts:n.starts}}function ef(t){let e=fe.basename(t).replace(/\.bulb\.md$/i,"");return fe.join(fe.dirname(t),".typebulb",`${e}.server.mjs`)}async function ei(t,e,n,r){let s=Bd(t,{serverOnly:!0});if(s.error)throw new Error(`Server compilation error: ${s.error}`);let i=s.code;n&&(i=await $p(i,n));let o=fe.join(fe.dirname(e),".typebulb");await Vt.mkdir(o,{recursive:!0});let a=Ia(i);a.length>0&&await Ra(a,o,r);let l=ef(e);return await Vt.writeFile(l,i,"utf-8"),Aw(Cr(e)),await import(`${b_(l).href}?t=${Date.now()}`)}async function tf(t,e,n,r){let{bulb:s,config:i,starts:o}=await nt(t),a=Po(s.data),l,c=m=>{l??=m instanceof Error?m.message:String(m)};try{Gb(s.code,i.dependencies??{})}catch(m){c(m)}let u=Bd(s.code,{jsxImportSource:i.ts?.jsxImportSource});u.error&&c(u.error);let d={imports:{}};if(!l)try{({importMap:d}=await Aa.buildImportMap(u.code,i.dependencies??{},r?new Set([r.name]):void 0))}catch(m){c(`Dependency resolution failed: ${m instanceof Error?m.message:String(m)}`)}l&&console.error("Build error:",l),r&&(d.imports[r.name]=r.entryUrl);let f=Sw({name:s.name,code:l?"":u.code,css:s.css,html:s.html,data:a,insight:s.insight,importMap:d,dir:Cr(t),watch:e,source:{file:fe.basename(t),codeLine:o.get("code.tsx")??1},bulbKey:Rs(t),compileError:l}),p;return s.server&&n&&(p=await ei(s.server,t,r,i.dependencies)),{html:f,bulb:s,serverExports:p,buildError:l}}var Pn,xt=v(()=>{"use strict";Ls();Vb();Xb();Gd();kw();Qd();Ti();Be();Tw();Pn=t=>fe.join(Cr(t),"assets")});import*as $e from"fs/promises";import*as qe from"path";import{createHash as w_}from"crypto";async function rf(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 Pr(t){try{return JSON.parse(t).error||t}catch{return t}}async function of(t,e){try{let n=await fetch(ti(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}): ${Pr(await n.text())}`}}catch(n){return{error:n instanceof Error?n.message:String(n)}}}function af(t,e){be(e);let n=process.env.TYPEBULB_ORIGIN||v_;try{return Ba(t,process.cwd(),n)}catch(r){console.error(r instanceof Error?r.message:String(r)),process.exit(1)}}function Ba(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,Ma(l,c))}}let r=qe.resolve(e,t),s=Or(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 S_(t,e){let n=await of(t,e);if("error"in n||!n.entries.length)return{kind:"none"};let r=n.entries,s=Pn(t.dest),i=[],o=[],a=0;for(let l of r){let c=await $e.readFile(qe.join(s,...l.path.split("/"))).catch(()=>{});c===void 0?i.push(l.path):sf(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 k_(t,e,n){let r=Pn(t.dest),s=[],i=0;return await rf(e.toGet,4,async o=>{try{let a=await fetch(`${ti(t)}/${Da(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 $e.mkdir(qe.dirname(l),{recursive:!0}),await $e.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 ja(t,e={}){let n=await fetch(nf(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 $e.readFile(t.dest,"utf-8")}catch{}let o=i!==void 0&&x_(i,s);if(i!==void 0&&!o&&!e.force){let{mtime:c}=await $e.stat(t.dest);return{kind:"conflict",dest:t.dest,localMtime:c,remoteLastModified:n.headers.get("last-modified")??void 0}}let a=await S_(t,e);if(a.kind==="conflict")return{kind:"asset-conflict",dest:t.dest,paths:a.paths};if(!o){await $e.mkdir(qe.dirname(t.dest),{recursive:!0}),await $e.writeFile(t.dest,s);let c=new Date(n.headers.get("last-modified")??"");isNaN(c.getTime())||await $e.utimes(t.dest,new Date,c)}let l=a.kind==="plan"?await k_(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 x_(t,e){let n=i=>i.replace(/\r\n/g,`
1742
+ `),r=ze(n(t)),s=ze(n(e));return!r||!s?n(t)===n(e):r.frontmatter.name===s.frontmatter.name&&He.every(i=>(r.files.get(de[i].path)||"")===(s.files.get(de[i].path)||""))}async function Pw(t,e){t||(console.error("Usage: typebulb pull <bulb url | typebulbs/u/<user>/<slug>.bulb.md>"),process.exit(1));let n=af(t,e.mode),r=`${n.origin}/u/${n.userSlug}/${n.slug}`,s;try{s=await ja(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)"}`),Ow(s.assets);return;case"up-to-date":console.log(`up to date: ${i}`),Ow(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 kw(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 g_,Ma,tf,Da,ti,rf,Fa=S(()=>{"use strict";Ze();Z();xt();g_="https://typebulb.com",Ma=(t,e)=>qe.join("typebulbs","u",t,`${e}.bulb.md`),tf=t=>`${t.origin}/u/${encodeURIComponent(t.userSlug)}/${encodeURIComponent(t.slug)}.md`,Da=t=>t.split("/").map(encodeURIComponent).join("/"),ti=t=>`${t.origin}/u/${encodeURIComponent(t.userSlug)}/${encodeURIComponent(t.slug)}/assets`;rf=t=>m_("md5").update(t).digest("hex")});import*as lt from"fs/promises";import*as ni from"path";async function Ew(t,e=""){let n=await lt.readdir(t,{withFileTypes:!0}).catch(()=>[]),r=[];for(let s of n)s.isDirectory()?r.push(...await Ew(ni.join(t,s.name),`${e}${s.name}/`)):s.isFile()&&r.push(e+s.name);return r}async function v_(t,e){let n=e.timeoutMs??3e4,r=ti(t),s={Authorization:`Bearer ${e.token}`},i=Pn(t.dest);if(!await lt.stat(i).then(h=>h.isDirectory()).catch(()=>!1))return{kind:"skipped"};let o=await Ew(i),a=await sf(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])),u=new Set(o),d=l.map(h=>h.path).filter(h=>!u.has(h)),f=0,p=0;try{await nf(o,4,async h=>{let m=await lt.readFile(ni.join(i,...h.split("/")));if(c.get(h)===rf(m)){p++;return}let g=await fetch(`${r}/${Da(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}): ${_r(await g.text())}`);f++})}catch(h){return{kind:"sync-error",message:h instanceof Error?h.message:String(h)}}return{kind:"synced",uploaded:f,unchanged:p,toDelete:d,base:_i(t.userSlug,t.slug)}}async function S_(t,e,n){let r=n.timeoutMs??3e4,s=ti(t),i=[];for(let o of e)try{let a=await fetch(`${s}/${Da(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}): ${_r(await a.text())}`};i.push(o)}catch(a){return{deleted:i,error:a instanceof Error?a.message:String(a)}}return{deleted:i}}async function Ua(t,e){let n=await lt.readFile(t.dest,"utf-8"),{mtime:r}=await lt.stat(t.dest),s=await v_(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(tf(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:_r(l),assets:i};if(!a.ok)return{kind:"http-error",status:a.status,message:_r(l),assets:i};let c=JSON.parse(l);if(await lt.utimes(t.dest,new Date,new Date(c.updatedAt)),i&&s.kind==="synced"&&s.toDelete.length){let u=await S_(t,s.toDelete,{token:e.token,timeoutMs:e.timeoutMs});i.deleted=u.deleted,u.error&&(i.pruneError=u.error)}return{kind:"pushed",created:c.created,serverStripped:c.serverStripped,updatedAt:c.updatedAt,assets:i}}async function Aw(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=of(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=ni.relative(process.cwd(),n.dest)||n.dest,o;try{o=await Ua(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 Ow(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 v_,Ma,nf,Da,ti,sf,Fa=v(()=>{"use strict";Ze();ee();xt();v_="https://typebulb.com",Ma=(t,e)=>qe.join("typebulbs","u",t,`${e}.bulb.md`),nf=t=>`${t.origin}/u/${encodeURIComponent(t.userSlug)}/${encodeURIComponent(t.slug)}.md`,Da=t=>t.split("/").map(encodeURIComponent).join("/"),ti=t=>`${t.origin}/u/${encodeURIComponent(t.userSlug)}/${encodeURIComponent(t.slug)}/assets`;sf=t=>w_("md5").update(t).digest("hex")});import*as lt from"fs/promises";import*as ni from"path";async function _w(t,e=""){let n=await lt.readdir(t,{withFileTypes:!0}).catch(()=>[]),r=[];for(let s of n)s.isDirectory()?r.push(...await _w(ni.join(t,s.name),`${e}${s.name}/`)):s.isFile()&&r.push(e+s.name);return r}async function E_(t,e){let n=e.timeoutMs??3e4,r=ti(t),s={Authorization:`Bearer ${e.token}`},i=Pn(t.dest);if(!await lt.stat(i).then(m=>m.isDirectory()).catch(()=>!1))return{kind:"skipped"};let o=await _w(i),a=await of(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(m=>[m.path,m.md5])),u=new Set(o),d=l.map(m=>m.path).filter(m=>!u.has(m)),f=0,p=0;try{await rf(o,4,async m=>{let h=await lt.readFile(ni.join(i,...m.split("/")));if(c.get(m)===sf(h)){p++;return}let y=await fetch(`${r}/${Da(m)}`,{method:"PUT",body:new Uint8Array(h),headers:s,signal:AbortSignal.timeout(n)});if(!y.ok)throw new Error(`upload of '${m}' refused (${y.status}): ${Pr(await y.text())}`);f++})}catch(m){return{kind:"sync-error",message:m instanceof Error?m.message:String(m)}}return{kind:"synced",uploaded:f,unchanged:p,toDelete:d,base:_i(t.userSlug,t.slug)}}async function A_(t,e,n){let r=n.timeoutMs??3e4,s=ti(t),i=[];for(let o of e)try{let a=await fetch(`${s}/${Da(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}): ${Pr(await a.text())}`};i.push(o)}catch(a){return{deleted:i,error:a instanceof Error?a.message:String(a)}}return{deleted:i}}async function Ua(t,e){let n=await lt.readFile(t.dest,"utf-8"),{mtime:r}=await lt.stat(t.dest),s=await E_(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(nf(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:Pr(l),assets:i};if(!a.ok)return{kind:"http-error",status:a.status,message:Pr(l),assets:i};let c=JSON.parse(l);if(await lt.utimes(t.dest,new Date,new Date(c.updatedAt)),i&&s.kind==="synced"&&s.toDelete.length){let u=await A_(t,s.toDelete,{token:e.token,timeoutMs:e.timeoutMs});i.deleted=u.deleted,u.error&&(i.pruneError=u.error)}return{kind:"pushed",created:c.created,serverStripped:c.serverStripped,updatedAt:c.updatedAt,assets:i}}async function Rw(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=af(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=ni.relative(process.cwd(),n.dest)||n.dest,o;try{o=await Ua(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}
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 af=S(()=>{"use strict";Z();Fa();xt()});var Rr=S(()=>{"use strict";je();bb();mn();wb();dd();Eb();Tb();Bs();kn();kn();ga();Md();je();Fa();af();Ze();Be()});import{existsSync as k_,mkdirSync as x_,readFileSync as E_,rmSync as A_,writeFileSync as T_}from"fs";import{homedir as C_}from"os";import*as Ir from"path";function R_(){return __.replace('"__TB_SKILL_PATH__"',JSON.stringify(qs())).replace('"__TB_BIN_PATH__"',JSON.stringify(ur()))}function Tw(){try{if(!k_(lf()))return}catch{return}try{let t=O_(),e=R_(),n;try{n=E_(t,"utf8")}catch{}n!==e&&(x_(Ir.dirname(t),{recursive:!0}),T_(t,e))}catch{}for(let t of P_())try{A_(t,{force:!0})}catch{}}var lf,O_,P_,__,Cw=S(()=>{"use strict";Rr();lf=()=>Ir.join(C_(),".pi","agent"),O_=()=>Ir.join(lf(),"extensions","typebulb.ts"),P_=()=>["typebulb-wait.ts","matchu-patchu.ts"].map(t=>Ir.join(lf(),"extensions",t)),__=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 lf=v(()=>{"use strict";ee();Fa();xt()});var _r=v(()=>{"use strict";je();Eb();mn();Ab();fd();_b();Ib();Bs();kn();kn();ga();Dd();je();Fa();lf();Ze();Be()});import{existsSync as T_,mkdirSync as C_,readFileSync as O_,rmSync as P_,writeFileSync as __}from"fs";import{homedir as R_}from"os";import*as Rr from"path";function L_(){return N_.replace('"__TB_SKILL_PATH__"',JSON.stringify(qs())).replace('"__TB_BIN_PATH__"',JSON.stringify(cr()))}function Iw(){try{if(!T_(cf()))return}catch{return}try{let t=I_(),e=L_(),n;try{n=O_(t,"utf8")}catch{}n!==e&&(C_(Rr.dirname(t),{recursive:!0}),__(t,e))}catch{}for(let t of $_())try{P_(t,{force:!0})}catch{}}var cf,I_,$_,N_,$w=v(()=>{"use strict";_r();cf=()=>Rr.join(R_(),".pi","agent"),I_=()=>Rr.join(cf(),"extensions","typebulb.ts"),$_=()=>["typebulb-wait.ts","matchu-patchu.ts"].map(t=>Rr.join(cf(),"extensions",t)),N_=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,Gt=S(()=>{"use strict";X=process.cwd()});import{spawn as Ow}from"child_process";import{StringDecoder as I_}from"string_decoder";function B_(t,e){let n=new I_("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 $_,Pw,_w,cf,Rw,N_,L_,M_,Iw,D_,qa,Ja,$w,Nw=S(()=>{"use strict";Gt();$_=3e4,Pw=18e4,_w="starting pi\u2026",cf=5e3,Rw=2e3,N_=2e3,L_=12e4,M_=8e3,Iw=15e3,D_=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{}});Ja=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)=>Ow(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()+Pw,this.#r={text:_w,kind:"info"},qa.add(i),i.stdout&&B_(i.stdout,o=>this.#I(o)),i.stderr&&i.stderr.on("data",o=>{this.#v=(this.#v+o.toString()).slice(-N_)}),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===_w&&(this.#r=null),this.#i&&(this.#i.until=Date.now()+Iw),!this.#o&&Date.now()<this.#e&&(this.#e=Date.now()+cf),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(!D_.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+cf),{ok:!0};let a;try{a=await this.#h(i)}catch(l){return{ok:!1,error:V(l)}}return a.success&&o(Date.now()+cf),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,$w(Rw)])}try{e.stdin?.end()}catch{}if(await Promise.race([this.#x,$w(Rw)]),e.exitCode===null&&!e.killed)if(process.platform==="win32"&&e.pid)try{Ow("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)+`
2019
+ `});function V(t){return t?.message??String(t)}var X,Gt=v(()=>{"use strict";X=process.cwd()});import{spawn as Nw}from"child_process";import{StringDecoder as M_}from"string_decoder";function q_(t,e){let n=new M_("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 D_,Lw,Mw,uf,Dw,B_,j_,F_,Bw,U_,qa,Ja,jw,Fw=v(()=>{"use strict";Gt();D_=3e4,Lw=18e4,Mw="starting pi\u2026",uf=5e3,Dw=2e3,B_=2e3,j_=12e4,F_=8e3,Bw=15e3,U_=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{}});Ja=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)=>Nw(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()+Lw,this.#r={text:Mw,kind:"info"},qa.add(i),i.stdout&&q_(i.stdout,o=>this.#I(o)),i.stderr&&i.stderr.on("data",o=>{this.#v=(this.#v+o.toString()).slice(-B_)}),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===Mw&&(this.#r=null),this.#i&&(this.#i.until=Date.now()+Bw),!this.#o&&Date.now()<this.#e&&(this.#e=Date.now()+uf),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(!U_.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+uf),{ok:!0};let a;try{a=await this.#h(i)}catch(l){return{ok:!1,error:V(l)}}return a.success&&o(Date.now()+uf),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,jw(Dw)])}try{e.stdin?.end()}catch{}if(await Promise.race([this.#x,jw(Dw)]),e.exitCode===null&&!e.killed)if(process.platform==="win32"&&e.pid)try{Nw("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
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"?M_:Iw)})}#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?Pw:$_,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??L_),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()}},$w=t=>new Promise(e=>{setTimeout(e,t).unref?.()})});import{existsSync as Lw,readFileSync as j_,realpathSync as F_}from"fs";import{join as _n,dirname as jw,resolve as U_}from"path";import{homedir as Mw}from"os";function J_(t,e){let n=_n(t,".pi");if(q_.some(s=>Lw(_n(n,s))))return!0;let r=_n(e,".agents","skills");for(let s=t;;){let i=_n(s,".agents","skills");if(i!==r&&Lw(i))return!0;let o=jw(s);if(o===s)return!1;s=o}}function W_(t,e){for(let n=e;;){if(t[n]===!0||t[n]===!1)return!0;let r=jw(n);if(r===n)return!1;n=r}}function Fw(t,e){try{let n=e?.agentDir??_n(Mw(),".pi","agent"),r=Dw(e?.home??process.env.HOME??Mw()),s=Dw(U_(t));if(!J_(s,r))return null;let i=Bw(_n(n,"settings.json")).defaultProjectTrust;return i==="always"||i==="never"||W_(Bw(_n(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 q_,Dw,Bw,Uw=S(()=>{"use strict";q_=["settings.json","extensions","skills","prompts","themes","SYSTEM.md","APPEND_SYSTEM.md"],Dw=t=>{try{return F_(t)}catch{return t}},Bw=t=>{try{return JSON.parse(j_(t,"utf8"))}catch{return{}}}});import{statSync as K_,openSync as H_,readSync as z_,closeSync as Y_,existsSync as Jw}from"fs";import{join as Wa}from"path";import{homedir as uf}from"os";import{execFile as V_}from"child_process";async function X_(t){let e=Wa(uf(),".pi","agent","bin",process.platform==="win32"?"fd.exe":"fd");for(let n of["fd","fdfind",...Jw(e)?[e]:[]]){let r=await new Promise(s=>{V_(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 Q_(t){return`--${t.replace(/^[/\\]/,"").replace(/[/\\:]/g,"-")}--`}function qw(t){return t.type==="message"?Z_(t.message?.role):t.type==="custom_message"?t.display!==!1:!1}var G_,Z_,$r,df=S(()=>{"use strict";Cs();Mo();Do();Cw();Nw();Uw();G_=Wa(uf(),".pi","agent","sessions");Z_=t=>t==="user"||t==="assistant"||t==="toolResult"||t==="bashExecution";$r=class extends Ft{displayName="Pi Mirror";detectsSelf(){return process.env.PI_CODING_AGENT==="true"}detectsInstalled(){return Jw(Wa(uf(),".pi","agent"))}ensureHarnessSupport(){Tw()}createDriver(e,n){let r=new Ja(e,n),s=Fw(e);return s&&r.notice(s,"warning"),r}walkFiles(e){return X_(e)}sessionsDir(e){return Wa(G_,Q_(e))}listSessionFiles(e){return Lo(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 qw(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:De(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(f=>f.type==="text").map(f=>f.text??"").join(""),a=i.filter(f=>f.type==="thinking").map(f=>f.thinking??"").join(`
2026
- `),l=i.filter(f=>f.type==="toolCall").map(f=>({id:f.id??"",name:f.name??"",input:f.arguments??{}}));if(o||a||l.length){let f=Date.parse(e.timestamp??""),p=!isNaN(f)&&f>=n;r.push({type:"assistant",text:o,thinking:a,tools:l,live:p})}let c=s.usage,u=c?(c.input??0)+(c.output??0)+(c.cacheRead??0)+(c.cacheWrite??0):0,d=c&&u>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)qw(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=H_(e,"r")}catch{return""}try{let s=65536;try{s=K_(e).size}catch{}let i=(d,f)=>{let p=Buffer.alloc(f),h=z_(n,p,0,f,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 f="";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&&(f=h.name)}catch{}return f},c="";for(let d of o.split(`
2028
- `))if(!(c||!d.includes('"type"')))try{let f=JSON.parse(d);f?.type==="message"&&f.message?.role==="user"&&(c=this.contentText(f.message.content).replace(/\s+/g," ").trim())}catch{}let u=l(a)||l(o)||c;return u?u.slice(0,200):""}finally{Y_(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"?Pe(e):Array.isArray(e)?e.map(n=>typeof n?.text=="string"?Pe(n.text):n?.type==="image"&&n.data?$o(n.data,n.mimeType):"").filter(Boolean).join(`
2029
- `):""}}});var Ka,Ww=S(()=>{"use strict";Ka=class{#t=new Map;accept(e,n){return this.#t.get(e)===n?!1:(this.#t.set(e,n),!0)}}});import{execFile as eR}from"child_process";import{promisify as tR}from"util";import{readFile as nR}from"fs/promises";import{resolve as Kw,sep as rR}from"path";async function we(t,e){let{stdout:n}=await sR("git",t,{cwd:e,maxBuffer:67108864});return n}async function Rn(){if(Ha)return Ha;try{Ha=(await we(["rev-parse","--show-toplevel"],X)).trim()}catch{}return Ha}function iR(t,e){let n=e===" "?t:e;return n==="?"?"U":n}async function pf(){let t=await Rn();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:iR(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 hf(t){let e=await Rn();if(!e)return{ok:!1,error:"not a git repository"};try{if((await we(["status","--porcelain","-z","--",t],e)).startsWith("??")){let s=Kw(e,t);if(!s.startsWith(Kw(e)+rR))return{ok:!1,error:"outside repository"};let i=await nR(s);return i.includes(0)?ff("Binary file (not shown)",!1):ff(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 ff(r,!1)}catch(n){return{ok:!1,error:V(n)}}}var sR,Hw,Ha,ff,Nr=S(()=>{"use strict";Gt();sR=tR(eR),Hw=2e6;ff=(t,e)=>({ok:!0,text:t.slice(0,Hw),untracked:e,truncated:t.length>Hw})});function ri(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=S(()=>{"use strict"});function zw(){return oR.map(([t,e])=>bt(t,e)).filter(t=>typeof t!="string")}function Yw(){return zw().length>0}async function za(t,e,n=0){let r=AbortSignal.timeout(e);for(let s of zw()){try{let i=await Wt(s,{messages:[{role:"user",content:t}],effort:n,webSearch:!1,signal:r});if(i.ok){let o=(await _d(i,s.protocol)).trim();if(o)return o}}catch{}if(r.aborted)return}}var oR,gf=S(()=>{"use strict";qt();Rr();oR=[["openrouter","openai/gpt-6-luna"],["openai","gpt-6-luna"]]});var Ya,Va,Et,Lr=S(()=>{"use strict";Ya=".typebulb/paste",Va={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",bmp:"image/bmp"},Et=t=>t.label||t.kind||"agent"});import{existsSync as aR,mkdirSync as lR,writeFileSync as cR,readFileSync as uR}from"fs";import{join as Ga}from"path";function Vw(){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 pR(t){return t.trim().toLowerCase().replace(/\.[a-z0-9]{1,4}$/,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)}async function hR(t){let e=await za(`Reply with ONLY a short kebab-case filename (2-5 words, lowercase, no extension) describing this text:
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"?F_:Bw)})}#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?Lw:D_,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??j_),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()}},jw=t=>new Promise(e=>{setTimeout(e,t).unref?.()})});import{existsSync as Uw,readFileSync as J_,realpathSync as W_}from"fs";import{join as _n,dirname as Kw,resolve as K_}from"path";import{homedir as qw}from"os";function z_(t,e){let n=_n(t,".pi");if(H_.some(s=>Uw(_n(n,s))))return!0;let r=_n(e,".agents","skills");for(let s=t;;){let i=_n(s,".agents","skills");if(i!==r&&Uw(i))return!0;let o=Kw(s);if(o===s)return!1;s=o}}function Y_(t,e){for(let n=e;;){if(t[n]===!0||t[n]===!1)return!0;let r=Kw(n);if(r===n)return!1;n=r}}function Hw(t,e){try{let n=e?.agentDir??_n(qw(),".pi","agent"),r=Jw(e?.home??process.env.HOME??qw()),s=Jw(K_(t));if(!z_(s,r))return null;let i=Ww(_n(n,"settings.json")).defaultProjectTrust;return i==="always"||i==="never"||Y_(Ww(_n(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 H_,Jw,Ww,zw=v(()=>{"use strict";H_=["settings.json","extensions","skills","prompts","themes","SYSTEM.md","APPEND_SYSTEM.md"],Jw=t=>{try{return W_(t)}catch{return t}},Ww=t=>{try{return JSON.parse(J_(t,"utf8"))}catch{return{}}}});import{statSync as V_,openSync as G_,readSync as X_,closeSync as Q_,existsSync as Vw}from"fs";import{join as Wa}from"path";import{homedir as df}from"os";import{execFile as Z_}from"child_process";async function tR(t){let e=Wa(df(),".pi","agent","bin",process.platform==="win32"?"fd.exe":"fd");for(let n of["fd","fdfind",...Vw(e)?[e]:[]]){let r=await new Promise(s=>{Z_(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 nR(t){return`--${t.replace(/^[/\\]/,"").replace(/[/\\:]/g,"-")}--`}function Yw(t){return t.type==="message"?rR(t.message?.role):t.type==="custom_message"?t.display!==!1:!1}var eR,rR,Ir,ff=v(()=>{"use strict";Cs();Mo();Do();$w();Fw();zw();eR=Wa(df(),".pi","agent","sessions");rR=t=>t==="user"||t==="assistant"||t==="toolResult"||t==="bashExecution";Ir=class extends Ft{displayName="Pi Mirror";detectsSelf(){return process.env.PI_CODING_AGENT==="true"}detectsInstalled(){return Vw(Wa(df(),".pi","agent"))}ensureHarnessSupport(){Iw()}createDriver(e,n){let r=new Ja(e,n),s=Hw(e);return s&&r.notice(s,"warning"),r}walkFiles(e){return tR(e)}sessionsDir(e){return Wa(eR,nR(e))}listSessionFiles(e){return Lo(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 Yw(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:De(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(f=>f.type==="text").map(f=>f.text??"").join(""),a=i.filter(f=>f.type==="thinking").map(f=>f.thinking??"").join(`
2026
+ `),l=i.filter(f=>f.type==="toolCall").map(f=>({id:f.id??"",name:f.name??"",input:f.arguments??{}}));if(o||a||l.length){let f=Date.parse(e.timestamp??""),p=!isNaN(f)&&f>=n;r.push({type:"assistant",text:o,thinking:a,tools:l,live:p})}let c=s.usage,u=c?(c.input??0)+(c.output??0)+(c.cacheRead??0)+(c.cacheWrite??0):0,d=c&&u>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)Yw(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=G_(e,"r")}catch{return""}try{let s=65536;try{s=V_(e).size}catch{}let i=(d,f)=>{let p=Buffer.alloc(f),m=X_(n,p,0,f,d);return p.subarray(0,m).toString("utf8")},o=i(0,Math.min(65536,s)),a=s>65536?i(s-65536,65536):"",l=d=>{let f="";for(let p of d.split(`
2027
+ `))if(p.includes('"session_info"'))try{let m=JSON.parse(p);m?.type==="session_info"&&typeof m.name=="string"&&m.name&&(f=m.name)}catch{}return f},c="";for(let d of o.split(`
2028
+ `))if(!(c||!d.includes('"type"')))try{let f=JSON.parse(d);f?.type==="message"&&f.message?.role==="user"&&(c=this.contentText(f.message.content).replace(/\s+/g," ").trim())}catch{}let u=l(a)||l(o)||c;return u?u.slice(0,200):""}finally{Q_(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"?Pe(e):Array.isArray(e)?e.map(n=>typeof n?.text=="string"?Pe(n.text):n?.type==="image"&&n.data?$o(n.data,n.mimeType):"").filter(Boolean).join(`
2029
+ `):""}}});var Ka,Gw=v(()=>{"use strict";Ka=class{#t=new Map;accept(e,n){return this.#t.get(e)===n?!1:(this.#t.set(e,n),!0)}}});import{execFile as sR}from"child_process";import{promisify as iR}from"util";import{readFile as oR}from"fs/promises";import{resolve as Xw,sep as aR}from"path";async function we(t,e){let{stdout:n}=await lR("git",t,{cwd:e,maxBuffer:67108864});return n}async function Rn(){if(Ha)return Ha;try{Ha=(await we(["rev-parse","--show-toplevel"],X)).trim()}catch{}return Ha}function cR(t,e){let n=e===" "?t:e;return n==="?"?"U":n}async function hf(){let t=await Rn();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:cR(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 mf(t){let e=await Rn();if(!e)return{ok:!1,error:"not a git repository"};try{if((await we(["status","--porcelain","-z","--",t],e)).startsWith("??")){let s=Xw(e,t);if(!s.startsWith(Xw(e)+aR))return{ok:!1,error:"outside repository"};let i=await oR(s);return i.includes(0)?pf("Binary file (not shown)",!1):pf(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 pf(r,!1)}catch(n){return{ok:!1,error:V(n)}}}var lR,Qw,Ha,pf,$r=v(()=>{"use strict";Gt();lR=iR(sR),Qw=2e6;pf=(t,e)=>({ok:!0,text:t.slice(0,Qw),untracked:e,truncated:t.length>Qw})});function ri(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 gf=v(()=>{"use strict"});function Zw(){return uR.map(([t,e])=>bt(t,e)).filter(t=>typeof t!="string")}function ev(){return Zw().length>0}async function za(t,e,n=0){let r=AbortSignal.timeout(e);for(let s of Zw()){try{let i=await Wt(s,{messages:[{role:"user",content:t}],effort:n,webSearch:!1,signal:r});if(i.ok){let o=(await Rd(i,s.protocol)).trim();if(o)return o}}catch{}if(r.aborted)return}}var uR,yf=v(()=>{"use strict";qt();_r();uR=[["openrouter","openai/gpt-6-luna"],["openai","gpt-6-luna"]]});var Ya,Va,Et,Nr=v(()=>{"use strict";Ya=".typebulb/paste",Va={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",bmp:"image/bmp"},Et=t=>t.label||t.kind||"agent"});import{existsSync as dR,mkdirSync as fR,writeFileSync as pR,readFileSync as hR}from"fs";import{join as Ga}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 yR(t){return t.trim().toLowerCase().replace(/\.[a-z0-9]{1,4}$/,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)}async function bR(t){let e=await za(`Reply with ONLY a short kebab-case filename (2-5 words, lowercase, no extension) describing this text:
2030
2030
 
2031
- ${t.slice(0,fR)}`,dR);return e&&pR(e)||void 0}async function Gw(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=Ga(t,Ya);try{lR(n,{recursive:!0})}catch(a){return{ok:!1,error:V(a)}}let r,s,i;if(e.kind==="image"){if(r=`img-${Vw()}`,s=Object.keys(Va).find(a=>Va[a]===e.mime)??"png",i=Buffer.from(e.data,"base64"),!i.length)return{ok:!1,error:"empty image data"}}else r=await hR(e.data)??`paste-${Vw()}`,s="md",i=e.data;let o=`${r}.${s}`;for(let a=2;aR(Ga(n,o));a++)o=`${r}-${a}.${s}`;try{cR(Ga(n,o),i)}catch(a){return{ok:!1,error:V(a)}}return{ok:!0,path:`${Ya}/${o}`}}function Xw(t,e){if(!/^[\w-]+(\.[\w-]+)*$/.test(e))return{ok:!1,error:"bad name"};let n=e.slice(e.lastIndexOf(".")+1).toLowerCase(),r=Va[n];if(!r)return{ok:!1,error:"not an image"};try{return{ok:!0,mime:r,base64:uR(Ga(t,Ya,e)).toString("base64")}}catch{return{ok:!1,error:"not found"}}}var dR,fR,Qw=S(()=>{"use strict";gf();Gt();Lr();dR=4e3,fR=4e3});async function tv(t,e=""){let n=t.trim();if(!n)return{ok:!1,error:"nothing to summarize"};if(!Yw())return yR;let r=e.trim()?ev+`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
- `+gR(e.trim())+`
2031
+ ${t.slice(0,gR)}`,mR);return e&&yR(e)||void 0}async function nv(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=Ga(t,Ya);try{fR(n,{recursive:!0})}catch(a){return{ok:!1,error:V(a)}}let r,s,i;if(e.kind==="image"){if(r=`img-${tv()}`,s=Object.keys(Va).find(a=>Va[a]===e.mime)??"png",i=Buffer.from(e.data,"base64"),!i.length)return{ok:!1,error:"empty image data"}}else r=await bR(e.data)??`paste-${tv()}`,s="md",i=e.data;let o=`${r}.${s}`;for(let a=2;dR(Ga(n,o));a++)o=`${r}-${a}.${s}`;try{pR(Ga(n,o),i)}catch(a){return{ok:!1,error:V(a)}}return{ok:!0,path:`${Ya}/${o}`}}function rv(t,e){if(!/^[\w-]+(\.[\w-]+)*$/.test(e))return{ok:!1,error:"bad name"};let n=e.slice(e.lastIndexOf(".")+1).toLowerCase(),r=Va[n];if(!r)return{ok:!1,error:"not an image"};try{return{ok:!0,mime:r,base64:hR(Ga(t,Ya,e)).toString("base64")}}catch{return{ok:!1,error:"not found"}}}var mR,gR,sv=v(()=>{"use strict";yf();Gt();Nr();mR=4e3,gR=4e3});async function av(t,e=""){let n=t.trim();if(!n)return{ok:!1,error:"nothing to summarize"};if(!ev())return SR;let r=e.trim()?ov+`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
+ `+vR(e.trim())+`
2033
2033
 
2034
2034
  REPLY TO SUMMARIZE:
2035
- `+n.slice(0,Zw):ev+n.slice(0,Zw),s=await za(r,mR,1);return s?{ok:!0,text:s}:bR}var mR,Zw,ev,gR,yR,bR,nv=S(()=>{"use strict";gf();mR=2e4,Zw=24e3,ev=`Summarize this assistant reply for someone who wants its substance without the prose.
2035
+ `+n.slice(0,iv):ov+n.slice(0,iv),s=await za(r,wR,1);return s?{ok:!0,text:s}:kR}var wR,iv,ov,vR,SR,kR,lv=v(()=>{"use strict";yf();wR=2e4,iv=24e3,ov=`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,33 +2047,33 @@ Reply with the summary alone.
2047
2047
 
2048
2048
  ---
2049
2049
 
2050
- `,gR=(t,e=4e3)=>{if(t.length<=e)return t;let n=Math.floor(e/2)-20;return t.slice(0,n)+`
2050
+ `,vR=(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)},yR={ok:!1,error:"Summary needs OPENROUTER_API_KEY or OPENAI_API_KEY in this project\u2019s .env.",setup:!0},bR={ok:!1,error:"the model call failed or timed out"}});import{readFileSync as wR,statSync as vR}from"fs";function Xa(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 Qa(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 rv(t,e,n){let r=t.forRead(),s;try{s=wR(e,"utf8")}catch{return[]}let{entries:i,add:o}=Qa(r),a=o(s.split(`
2055
- `),n),l=[],c=new Set;for(let f=a;f&&!c.has(f);){let p=i.get(f);if(!p)break;c.add(f),l.push(p),f=r.parentOf(p)}let u=[],d=Date.now();for(let f of l.reverse())if(!r.isSidechain(f,n))try{u.push(...Xa(r,f,n,d).events)}catch{}return u}function Za(t,e,n,r){let s=t.sessionAlive(e,n);if(s!==void 0)return s;if(!r)return!1;try{return Date.now()-vR(r).mtimeMs<1e4}catch{return!1}}function si(t,e){return t.stopped?"stopped":t.running&&e?"running":"done"}var yf=S(()=>{"use strict"});function SR(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 sv(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 ii,bf=S(()=>{"use strict";ii=(t,e)=>SR(t,{key:e,desc:!0})});function uv(t){let e=[],n=new Map,r=new Map,s=[],i=[],o=[],a,l=!1,c=0;for(let u of t){if(u.type==="cleared"){e=[],n=new Map,r=new Map,s=[],i=[],o=[],a=void 0,l=!1;continue}let d="at"in u?u.at:void 0;if(d!==void 0&&(c=Math.max(c,d)),u.type==="user")a===void 0&&!u.agent?a=d:d!==void 0&&s.push(d),l=!1;else if(u.type==="assistant"){d!==void 0&&i.push(d);for(let f of u.tools){let p={id:f.id,name:f.name,input:f.input,at:d,isError:!1};e.push(p),n.set(f.id,p)}}else if(u.type==="tool_result"){let f=n.get(u.id);if(!f)continue;Object.assign(f,{result:u.content,isError:u.isError,exit:u.exit,background:u.background,refused:u.refused,doneAt:d}),u.output&&(f.output=u.output),u.task&&r.set(u.task,f),d!==void 0&&i.push(d)}else if(u.type==="task_done"){let f=u.id?n.get(u.id):u.task?r.get(u.task):void 0;if(!f?.background||f.endAt!==void 0)continue;Object.assign(f,{endAt:d??c,outcome:u.outcome,output:u.output??f.output}),u.exit!==void 0&&(f.exit=u.exit),l&&d!==void 0&&(s.push(d),l=!1)}else u.type==="turn_end"&&(!l&&d!==void 0&&o.push(d),l=!0)}return{calls:e,turnEnds:o,lastAt:c,...xR(e,s,i,a,c)}}function xR(t,e,n,r,s){let i=r??t[0]?.at??s,o=[];for(let u of e){let d=-1/0;for(let p of n)p<=u&&p>d&&(d=p);let f=t.some(p=>p.at!==void 0&&p.at<u&&(p.doneAt??1/0)>u);d>-1/0&&!f&&u-d>=kR&&o.push([d,u])}let a=o.reduce((u,[d,f])=>u+Math.max(0,Math.min(s,f)-d),0),l=0,c=-1/0;for(let u of t.filter(d=>d.at!==void 0).sort((d,f)=>d.at-f.at)){let d=u.doneAt??s;d>c&&(l+=d-Math.max(u.at,c),c=d)}return{span:Math.max(0,s-i-a),idle:a,toolMs:l}}function ER(t,e){if(t.refused)return;let n=t.result===void 0||!!t.background&&t.endAt===void 0,r=t.background?t.endAt:t.doneAt,s=!n&&(t.exit!==void 0?t.exit!==0:t.background?t.outcome==="failed":t.isError),i=t.background?t.output?e?.(t.output)??"":"":t.result??"";return{id:t.id,at:t.at,open:n,failed:s,exit:t.exit,outcome:t.background?t.outcome:void 0,ms:t.at!==void 0&&r!==void 0?r-t.at:void 0,...AR(i)}}function AR(t){let e=Ts(t).split(`
2056
- `).map(n=>n.trim()).filter(n=>/[\p{L}\p{N}]/u.test(n));return/^exit(?: code)?:? \d+$/i.test(e[0]??"")&&e.shift(),{first:In(e[0]??"",120),last:e.length>1?In(e.at(-1),120):""}}function tl(t){let e=[],n=0;for(let r of kf(t).matchAll(/&&|\|\||[;|\n]/g))e.push({text:t.slice(n,r.index),at:n}),n=r.index+r[0].length;return e.push({text:t.slice(n),at:n}),e.filter(r=>r.text.trim())}function wf(t){if(/>|\btee\b/.test(kf(t).replace(/\d?>&\d|\d?>\s*(\/dev\/null|\$null|NUL)\b/gi,"")))return!1;let e=t.trim().match(/"[^"]*"|'[^']*'|\S+/g)??[];for(;e.length&&(IR.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"?RR.has(r.find(s=>!s.startsWith("-"))??""):n==="git"?_R.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)):PR.has(n)||/^get-/.test(n)}function $R(t){let e=[...t.matchAll(/\$\(|`/g)].map(n=>t.slice(n.index+n[0].length));return tl(t).every(n=>wf(n.text))&&e.every(n=>wf(tl(n)[0]?.text??""))}function vf(t){t=t.replace(NR,(s,i,o,a)=>`<<${i}${o}${i}${a} \u2026 ${o}`);let e=tl(t),n=e.findIndex(s=>!wf(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 LR(t,e){let n=new Map,r=0;for(let a of t.calls){let l=Sf(a),c=l&&ER(a,e);if(!c)continue;let u=cv(l).trim();if($R(u)){r++;continue}let d=tl(u).at(-1)?.text.trim().split(/\s+/)[0]?.toLowerCase()??"";c.exit===1&&OR.has(d)&&(c.failed=!1),n.set(u,[...n.get(u)??[],c])}let s=[...n].map(([a,l])=>{let c=0;for(let f of l.filter(p=>!p.open).reverse()){if(!f.failed)break;c++}let u=kf(a),d=[TR.test(u)?"stops a process":"",CR.test(u)?"git write":""].filter(Boolean);return{cmd:In(vf(a),100),runs:l.length,failed:l.filter(f=>f.failed).length,streak:c,long:l.some(f=>(f.ms??0)>lv),ms:l.reduce((f,p)=>f+(p.ms??0),0),tags:d,latest:l.at(-1)}}).sort((a,l)=>(l.latest.at??0)-(a.latest.at??0)),o=[...n].flatMap(([a,l])=>l.filter(c=>!c.open).map(c=>({cmd:In(vf(a),100),run:c}))).sort((a,l)=>(l.run.at??0)-(a.run.at??0))[0];return{runs:s.reduce((a,l)=>a+l.runs,0),failed:s.reduce((a,l)=>a+l.failed,0),reads:r,groups:s,last:o}}function dv(t,e){let n=new Map,r=[],s=[],i=o=>{let a=o.trim().replace(/^["']|["']$/g,"").replace(/\\/g,"/").replace(/^\/([a-zA-Z])\//,"$1:/"),l=fy(a,e).replace(/^\.\//,"");return!l||/^([a-zA-Z]:)?\//.test(l)?void 0:l};for(let o of t.calls){if(o.isError||o.result===void 0)continue;let a=o.doneAt??o.at??0,l=(g,v={},A=!1)=>{let C=i(g);if(!C)return;let x=n.get(C)??{path:C};x.deleted=v.deleted,v.from&&(x.from=v.from),n.set(C,x),r.push({path:C,at:a,whole:A})},c=(g,v)=>{let A=i(g),C=A?n.get(A):void 0;A&&(n.delete(A),r.push({path:A,at:a})),l(v,{from:C?.from??A})},u=o.input??{},d=!1;for(let[g,v]of Object.entries(u)){if(g==="command"||g==="cmd"||typeof v!="string"||!/^(---|\+\+\+) /m.test(v))continue;let A;for(let C of v.split(`
2057
- `)){let x=/^(---|\+\+\+) (?:[ab]\/)?(.+?)\s*$/.exec(C);if(x?.[1]==="---"){A=x[2];continue}if(x?.[1]==="+++"){d=!0,x[2]==="/dev/null"?A&&A!=="/dev/null"&&l(A,{deleted:!0}):l(x[2]);continue}let R=/^\*\*\* Move to: (.+?)\s*$/.exec(C);R&&A&&c(A,R[1])}}let f=ee(u.file_path)??ee(u.filePath)??ee(u.path),p=DR.some(g=>g in u);!d&&f&&p&&l(f,{},typeof u.content=="string");let h=ee(u.file_path)??ee(u.filePath);if(h&&!p&&!d){let g=i(h);g&&s.push({path:g,at:a})}let m=Sf(o);if(m)for(let g of BR(m))g.to?c(g.from,g.to):l(g.from,{deleted:!0})}return{edited:[...n.values()],writes:r,reads:s}}function BR(t){let e=[];for(let n of t.split(/&&|\|\||[;|\n]/)){let r=n.trim().match(/"[^"]*"|'[^']*'|\S+/g)??[],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("-")).map(l=>l.replace(/^["']|["']$/g,""));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(/\/+$/,"")}/${py(l)}`:a})}return e}function fv(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(f=>f.id!==a.id);if(!c)return;let u=t.find(f=>f.id===a.id);[...u.reads,...u.writes].some(f=>f.path===s&&f.at>c.at&&f.at<a.at)||r.set(`${s}
2054
+ `+t.slice(t.length-n)},SR={ok:!1,error:"Summary needs OPENROUTER_API_KEY or OPENAI_API_KEY in this project\u2019s .env.",setup:!0},kR={ok:!1,error:"the model call failed or timed out"}});import{readFileSync as xR,statSync as ER}from"fs";function Xa(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 Qa(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 cv(t,e,n){let r=t.forRead(),s;try{s=xR(e,"utf8")}catch{return[]}let{entries:i,add:o}=Qa(r),a=o(s.split(`
2055
+ `),n),l=[],c=new Set;for(let f=a;f&&!c.has(f);){let p=i.get(f);if(!p)break;c.add(f),l.push(p),f=r.parentOf(p)}let u=[],d=Date.now();for(let f of l.reverse())if(!r.isSidechain(f,n))try{u.push(...Xa(r,f,n,d).events)}catch{}return u}function Za(t,e,n,r){let s=t.sessionAlive(e,n);if(s!==void 0)return s;if(!r)return!1;try{return Date.now()-ER(r).mtimeMs<1e4}catch{return!1}}function si(t,e){return t.stopped?"stopped":t.running&&e?"running":"done"}var bf=v(()=>{"use strict"});function AR(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 uv(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 ii,wf=v(()=>{"use strict";ii=(t,e)=>AR(t,{key:e,desc:!0})});function mv(t){let e=[],n=new Map,r=new Map,s=[],i=[],o=[],a,l=!1,c=0;for(let u of t){if(u.type==="cleared"){e=[],n=new Map,r=new Map,s=[],i=[],o=[],a=void 0,l=!1;continue}let d="at"in u?u.at:void 0;if(d!==void 0&&(c=Math.max(c,d)),u.type==="user")a===void 0&&!u.agent?a=d:d!==void 0&&s.push(d),l=!1;else if(u.type==="assistant"){d!==void 0&&i.push(d);for(let f of u.tools){let p={id:f.id,name:f.name,input:f.input,at:d,isError:!1};e.push(p),n.set(f.id,p)}}else if(u.type==="tool_result"){let f=n.get(u.id);if(!f)continue;Object.assign(f,{result:u.content,isError:u.isError,exit:u.exit,background:u.background,refused:u.refused,doneAt:d}),u.output&&(f.output=u.output),u.task&&r.set(u.task,f),d!==void 0&&i.push(d)}else if(u.type==="task_done"){let f=u.id?n.get(u.id):u.task?r.get(u.task):void 0;if(!f?.background||f.endAt!==void 0)continue;Object.assign(f,{endAt:d??c,outcome:u.outcome,output:u.output??f.output}),u.exit!==void 0&&(f.exit=u.exit),l&&d!==void 0&&(s.push(d),l=!1)}else u.type==="turn_end"&&(!l&&d!==void 0&&o.push(d),l=!0)}return{calls:e,turnEnds:o,lastAt:c,...CR(e,s,i,a,c)}}function CR(t,e,n,r,s){let i=r??t[0]?.at??s,o=[];for(let u of e){let d=-1/0;for(let p of n)p<=u&&p>d&&(d=p);let f=t.some(p=>p.at!==void 0&&p.at<u&&(p.doneAt??1/0)>u);d>-1/0&&!f&&u-d>=TR&&o.push([d,u])}let a=o.reduce((u,[d,f])=>u+Math.max(0,Math.min(s,f)-d),0),l=0,c=-1/0;for(let u of t.filter(d=>d.at!==void 0).sort((d,f)=>d.at-f.at)){let d=u.doneAt??s;d>c&&(l+=d-Math.max(u.at,c),c=d)}return{span:Math.max(0,s-i-a),idle:a,toolMs:l}}function Sf(t,e){if(t.refused)return;let n=t.result===void 0||!!t.background&&t.endAt===void 0,r=t.background?t.endAt:t.doneAt,s=!n&&(t.exit!==void 0?t.exit!==0:t.background?t.outcome==="failed":t.isError),i=t.background?t.output?e?.(t.output)??"":"":t.result??"";return{id:t.id,at:t.at,open:n,failed:s,exit:t.exit,outcome:t.background?t.outcome:void 0,ms:t.at!==void 0&&r!==void 0?r-t.at:void 0,...OR(i)}}function OR(t){let e=Ts(t).split(`
2056
+ `).map(n=>n.trim()).filter(n=>/[\p{L}\p{N}]/u.test(n));return/^exit(?: code)?:? \d+$/i.test(e[0]??"")&&e.shift(),{first:Mr(e[0]??"",120),last:e.length>1?Mr(e.at(-1),120):""}}function tl(t){let e=[],n=0;for(let r of Ef(t).matchAll(/&&|\|\||[;|\n]/g))e.push({text:t.slice(n,r.index),at:n}),n=r.index+r[0].length;return e.push({text:t.slice(n),at:n}),e.filter(r=>r.text.trim())}function kf(t){if(/>|\btee\b/.test(Ef(t).replace(/\d?>&\d|\d?>\s*(\/dev\/null|\$null|NUL)\b/gi,"")))return!1;let e=t.trim().match(/"[^"]*"|'[^']*'|\S+/g)??[];for(;e.length&&(LR.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"?NR.has(r.find(s=>!s.startsWith("-"))??""):n==="git"?$R.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)):IR.has(n)||/^get-/.test(n)}function MR(t){let e=[...t.matchAll(/\$\(|`/g)].map(n=>t.slice(n.index+n[0].length));return tl(t).every(n=>kf(n.text))&&e.every(n=>kf(tl(n)[0]?.text??""))}function gv(t){t=t.replace(DR,(s,i,o,a)=>`<<${i}${o}${i}${a} \u2026 ${o}`);let e=tl(t),n=e.findIndex(s=>!kf(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 BR(t,e){let n=new Map,r=0;for(let i of t.calls){let o=xf(i),a=o&&Sf(i,e);if(!a)continue;let l=hv(o).trim();if(MR(l)){r++;continue}let c=tl(l).at(-1)?.text.trim().split(/\s+/)[0]?.toLowerCase()??"";a.exit===1&&RR.has(c)&&(a.failed=!1),n.set(l,[...n.get(l)??[],a])}let s=[...n].map(([i,o])=>{let a=0;for(let u of o.filter(d=>!d.open).reverse()){if(!u.failed)break;a++}let l=Ef(i),c=[PR.test(l)?"stops a process":"",_R.test(l)?"git write":""].filter(Boolean);return{cmd:Mr(gv(i),100),runs:o.length,open:o.filter(u=>u.open).length,failed:o.filter(u=>u.failed).length,streak:a,long:o.some(u=>(u.ms??0)>pv),ms:o.reduce((u,d)=>u+(d.ms??0),0),tags:c,latest:o.at(-1)}}).sort((i,o)=>(o.latest.at??0)-(i.latest.at??0));return{runs:s.reduce((i,o)=>i+o.runs,0),failed:s.reduce((i,o)=>i+o.failed,0),lookups:r,groups:s}}function yv(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 u=hy(o(c),e).replace(/^\.\//,"");return!u||/^([a-zA-Z]:)?\//.test(u)?void 0:u},l=c=>a(c)??(o(c)||void 0);for(let c of t.calls){if(c.isError||c.result===void 0)continue;let u=c.doneAt??c.at??0,d=(O,_={},I=!1)=>{let A=a(O);if(!A)return;let M=n.get(A)??{path:A};M.deleted=_.deleted,_.from&&(M.from=_.from),n.set(A,M),r.push({path:A,at:u,whole:I})},f=(O,_)=>{let I=a(O),A=I?n.get(I):void 0;I&&(n.delete(I),r.push({path:I,at:u})),d(_,{from:A?.from??I})},p=c.input??{},m=!1;for(let[O,_]of Object.entries(p)){if(O==="command"||O==="cmd"||typeof _!="string"||!/^(---|\+\+\+) /m.test(_))continue;let I;for(let A of _.split(`
2057
+ `)){let M=/^(---|\+\+\+) (?:[ab]\/)?(.+?)\s*$/.exec(A);if(M?.[1]==="---"){I=M[2];continue}if(M?.[1]==="+++"){m=!0,M[2]==="/dev/null"?I&&I!=="/dev/null"&&d(I,{deleted:!0}):d(M[2]);continue}let K=/^\*\*\* Move to: (.+?)\s*$/.exec(A);K&&I&&f(I,K[1])}}let h=Z(p.file_path)??Z(p.filePath)??Z(p.path),y=UR.some(O=>O in p);!m&&h&&y&&d(h,{},typeof p.content=="string");let k=Z(p.file_path)??Z(p.filePath);if(k&&!y&&!m){let O=l(k);O&&s.push({path:O,at:u})}let T=O=>Object.entries(p).filter(([_,I])=>typeof I=="string"&&(_===O||_.startsWith(`${O} (`))).map(([,_])=>_);if(c.name==="read")for(let O of T("path")){let _=l(O);_&&s.push({path:_,at:u})}let P=Z(p.workdir);for(let O of[...T("command"),...T("cmd")])for(let _ of Ry(O)){let I=l(P&&!/^([a-zA-Z]:)?[\\/]/.test(_)?`${P}/${_}`:_);I&&i.push({path:I,at:u})}let E=xf(c);if(E)for(let O of qR(E))O.to?f(O.from,O.to):d(O.from,{deleted:!0})}return{edited:[...n.values()],writes:r,reads:s,shellReads:i}}function qR(t){let e=[];for(let n of t.split(/&&|\|\||[;|\n]/)){let r=n.trim().match(/"[^"]*"|'[^']*'|\S+/g)??[],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("-")).map(l=>l.replace(/^["']|["']$/g,""));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(/\/+$/,"")}/${my(l)}`:a})}return e}function bv(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(f=>f.id!==a.id);if(!c)return;let u=t.find(f=>f.id===a.id);[...u.reads,...u.writes].some(f=>f.path===s&&f.at>c.at&&f.at<a.at)||r.set(`${s}
2058
2058
  ${a.id}
2059
- ${c.id}`,{path:s,by:a.id,over:c.id,at:a.at,overAt:c.at})})}return{writers:n,blind:[...r.values()]}}function pv(t,e,n,r,s,i,o,a=xf){let l=u=>`"${s.get(u)??u}"`,c=e.calls.filter(u=>!u.refused&&(u.result===void 0||u.background&&u.endAt===void 0)).map(u=>({id:u.id,label:ov(u),short:In(ee(u.input?.description)??"",80)||ov(u),at:u.at,background:!!u.background,interrupted:!i||t.liveSince!==void 0&&(u.at??0)<t.liveSince}));return{id:t.id,name:Et(t),state:t.state==="stopped"?"stopped":t.failing?"failing":t.state==="running"?"running":"finished",asOf:e.lastAt,activeMs:e.span,idleMs:e.idle,toolMs:e.toolMs,open:c,commands:jR(LR(e,o),c),files:n.map(u=>{let d=a.since(u.path);return{...u,committed:!a.ignored(u.path)&&!a.uncommitted(u.path),ignored:a.ignored(u.path),also:(r.writers.get(u.path)??[]).filter(f=>f.id!==t.id&&f.at>d).map(f=>({name:s.get(f.id)??f.id,at:f.at})),blind:r.blind.filter(f=>f.path===u.path&&(f.by===t.id||f.over===t.id)&&f.overAt>d).map(f=>f.by===t.id?`\u26A0 written at ${Mr(f.at)} over ${l(f.over)}'s ${Mr(f.overAt)} write without reading it`:`\u26A0 ${l(f.by)} wrote over this agent's ${Mr(f.overAt)} write at ${Mr(f.at)} without reading it`)}})}}function jR(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 UR(t,e){let n=$n(t).filter(s=>s.background);return`${t.state==="finished"&&n.length?`finished, background call running ${ie(e-(n[0].at??e))}${n.length>1?` (+${n.length-1} more)`:""}`:t.state} \xB7 ${ie(Ef(t,e))} active${t.idleMs?`, ${ie(t.idleMs)} idle`:""}`}function JR(t,e){return t.open.length?t.open.length===1?[`Now: ${av(t.open[0],e)}`]:["Now:",...t.open.map(n=>` ${av(n,e)}`)]:[`Now: ${qR(t,e)}`]}function WR(t,e){let n=t.latest;return`latest: ${n.interrupted?"interrupted":n.open?`running ${ie(e-(n.at??e))}`:n.outcome&&n.outcome!=="completed"&&n.outcome!=="failed"&&n.exit===void 0?n.outcome:`exit ${n.exit??(n.failed?"error":0)}${n.ms!==void 0?` after ${ie(n.ms)}`:""}`}${t.streak>=2?`, failed ${t.streak} in a row`:""}`}function mv(t,e){let n=[`Sub-agent "${t.name}" (${t.id}): ${UR(t,e)}${t.asOf?` \xB7 as of ${Mr(t.asOf)}`:""}`,""];n.push(...JR(t,e));let r=t.commands;r.last&&n.push(`Last run: ${XR(r)}`),n.push(`Commands: ${MR(r)}`);for(let a of r.groups.filter(el).slice(0,iv)){let l=GR(a);n.push(` ${a.cmd} \xD7${a.runs}${a.failed?`, ${a.failed} failed`:""}${l?` \xB7 ${l}`:""}`,` ${WR(a,e)}`);let c=[a.latest.first,a.latest.last].filter(Boolean).map(u=>`"${u}"`).join(" \u2026 ");c&&n.push(` ${c}`)}let s=Math.min(iv,r.groups.filter(el).length),i=r.groups.filter(el).length-s;i&&n.push(` +${i} more like these`);let o=VR(r);o.runs&&n.push(` +${o.runs} other ${o.runs===1?"run":"runs"} passed (${ie(o.ms)} in all)`),n.push(`Files: ${KR(t)}`);for(let a of t.files){let l=a.also.length?` also ${YR(a)}`:"";n.push(` ${QR(a)}${a.ignored?" (ignored)":a.committed?" (committed)":""}${l}`,...a.blind.map(c=>` ${c}`))}return t.activeMs&&n.push(`Time: ${zR(t,e)}`),n.join(`
2060
- `)}function HR(t,e){let n=t.toolMs+($n(t).some(r=>!r.background)?hv(t,e):0);return{tools:n,model:Math.max(0,Ef(t,e)-n)}}function gv(t,e,n,r){let s=e.filter(oi).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 ${ie(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(d=>`"${d.name}"${d.running?" (running)":""}`).join(", ")}${u.blind.length?" \u26A0":""}`)}o.push("","Agents:");let a=e.filter(u=>oi(u)||u.state==="failing"||n.some(d=>d.writers.some(f=>f.id===u.id))),l=new Set(a.map(u=>u.id));for(let u of a){let d=$n(u)[0],f=u.state==="finished"?$n(u).filter(A=>A.background):[],p=f.length?`finished, background call running ${ie(r-(f[0].at??r))}${f.length>1?` (+${f.length-1} more)`:""}`:u.state.padEnd(8),h=f.length?f[0].short:d?`waiting ${ie(r-(d.at??r))} on ${d.short}`:"",m=FR(u),g=[h,m>=2?`failed ${m} in a row`:"",n.some(A=>A.blind.includes(u.id))?"\u26A0":""].filter(Boolean),v=u.parentId&&l.has(u.parentId)?" ".repeat(Math.max(0,u.depth-1)):"";o.push(` ${v}${u.id} ${p} ${`${ie(Ef(u,r))} active`.padStart(10)} ${u.name}${g.length?` \xB7 ${g.join(" \xB7 ")}`:""}`)}let c=e.length-a.length;return c&&o.push(` ${a.length?"+":""}${c} ${e.some(u=>!l.has(u.id)&&u.state==="stopped")?"finished or stopped":"finished"}, 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(`
2061
- `)}function yv(t,e){let n=new Map,r=o=>`"${t.find(a=>a.id===o)?.name??o}"`,s=Math.max(0,...t.map(o=>o.asOf));t.length&&!t.some(oi)&&e-s>=ZR&&n.set("idle",`No agent running for ${ie(e-s)} (${t.length} agents).`);for(let o of t){if(o.state==="finished")for(let a of $n(o).filter(l=>l.background&&e-(l.at??e)>=eI))n.set(`background:${a.id}`,`${r(o.id)}: finished, background call running ${ie(e-(a.at??e))}: ${a.short}`);for(let a of o.commands.groups.filter(l=>l.streak>=2))n.set(`streak:${o.id}:${a.cmd}`,`${r(o.id)}: failed ${a.streak} in a row: ${a.cmd}`)}let i=t.flatMap(o=>$n(o).filter(a=>!a.background&&e-(a.at??e)>=tI).map(a=>({a:o,ms:e-(a.at??e)})));return new Set(i.map(o=>o.a.id)).size>=2&&n.set("waiting",`${new Set(i.map(o=>o.a.id)).size} agents waiting on calls at once: ${i.map(o=>`${r(o.a.id)} ${ie(o.ms)}`).join(", ")}`),n}var kR,iv,lv,In,cv,Sf,Mr,ov,TR,CR,OR,PR,_R,RR,IR,kf,NR,MR,DR,xf,$n,oi,FR,hv,Ef,av,qR,KR,zR,YR,el,VR,GR,XR,QR,ZR,eI,tI,nl=S(()=>{"use strict";Lr();Io();kR=6e4,iv=8,lv=3*6e4,In=(t,e)=>(t=Ts(t).replace(/\s+/g," ").trim(),t.length>e?t.slice(0,e)+"\u2026":t),cv=t=>t.replace(/^(\s*(cd\s+\S+|export\s+PATH=\S+)\s*(;|&&)\s*)+/,""),Sf=t=>ee(t.input?.command)??ee(t.input?.cmd),Mr=t=>new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),ov=t=>{let e=Sf(t);if(e)return In(vf(cv(e).trim()),100);let n=In(hy(t.input),80);return n?`${Bu(t.name)}: ${n}`:Bu(t.name)};TR=/(^|[\s;|&(])(kill|pkill|killall|taskkill|stop-process)\b/i,CR=/\bgit\s+(-C\s+\S+\s+)?(commit|stash|checkout|reset|push|clean|restore|rebase|merge|cherry-pick|revert)\b/,OR=new Set(["grep","egrep","fgrep","rg","findstr","select-string"]),PR=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"]),_R=new Set(["log","status","diff","show","blame","rev-parse","ls-files","grep","branch","remote"]),RR=new Set(["status","logs","get","models","slug","predict"]),IR=new Set(["if","then","else","elif","fi","do","done","while","until","!","{","}","(",")"]),kf=t=>t.replace(/'[^']*'|"(?:\\.|[^"\\])*"/g,e=>"_".repeat(e.length));NR=/<<-?\s*(['"]?)(\w+)\1([^\n]*)\n[\s\S]*?\n\s*\2\b/g;MR=t=>[t.runs?`${t.runs} run, ${t.failed} failed`:"none",t.reads?`${t.reads} ${t.reads===1?"read":"reads"}`:""].filter(Boolean).join(", "),DR=["content","diff","new_string","new_source","edits"];xf={uncommitted:()=>!0,ignored:()=>!1,since:()=>0};$n=t=>t.open.filter(e=>!e.interrupted),oi=t=>t.state==="running"||$n(t).length>0,FR=t=>Math.max(0,...t.commands.groups.map(e=>e.streak)),hv=(t,e)=>t.state==="running"?Math.max(0,e-t.asOf):0,Ef=(t,e)=>t.activeMs+hv(t,e);av=(t,e)=>t.interrupted?`${t.label}: interrupted, its process has ended`:`${t.label}, ${ie(e-(t.at??e))}${t.background?" (background)":""}`,qR=(t,e)=>`nothing open, last entry ${ie(e-t.asOf)} ago`;KR=t=>{let e=t.files.filter(n=>!n.committed&&!n.ignored).length;return t.files.length?`${t.files.length} (${e} uncommitted)`:"none"};zR=(t,e)=>{let n=HR(t,e);return`${ie(n.tools)} in tools, ${ie(n.model)} in the model`},YR=t=>t.also.map(e=>`"${e.name}" ${Mr(e.at)}`).join(", "),el=t=>t.failed>0||t.latest.open||t.long||t.runs>=3||t.tags.length>0,VR=t=>{let e=t.groups.filter(n=>!el(n));return{runs:e.reduce((n,r)=>n+r.runs,0),ms:e.reduce((n,r)=>n+r.ms,0)}},GR=t=>[...t.tags,t.long?`over ${ie(lv)}`:""].filter(Boolean).join(", "),XR=t=>{let e=t.last;if(!e)return"";let n=e.run.outcome&&e.run.outcome!=="completed"&&e.run.outcome!=="failed"&&e.run.exit===void 0?e.run.outcome:`exit ${e.run.exit??(e.run.failed?"error":0)}`;return`${e.cmd} \xB7 ${n}${e.run.ms!==void 0?` after ${ie(e.run.ms)}`:""}`},QR=t=>t.deleted?`${t.path} (deleted)`:t.from?`${t.path} (moved from ${t.from})`:t.path;ZR=5*6e4,eI=10*6e4,tI=2*6e4});import{openSync as nI,readSync as rI,closeSync as sI,fstatSync as iI,statSync as oI}from"fs";function*Af(t,e){if(!t.listChildren)return;let n=t.callerSessionId?.(e),r=ii(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 vv(t,e,s.sessionId,s.file,i))}}function vv(t,e,n,r,s){let i=Za(t,n,e,r);return{sessionId:n,live:i,children:s.map(o=>({...o,state:si(o,i)}))}}function Sv(t,e){return t.callerSessionId?.(e)??Af(t,e).next().value?.sessionId}function kv(t,e,n){let r=t.listSessionFiles(e).find(s=>s.sessionId===n)?.file;return vv(t,e,n,r,t.listChildren?.(e,n)??[])}function xv(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)||Et(s).toLowerCase().includes(n))}function wv(t,e){let n={size:-1,mtimeMs:-1};try{n=oI(e)}catch{}let r=bv.get(e);if(r&&r.size===n.size&&r.mtime===n.mtimeMs)return r.d;let s=uv(rv(t,e,"child"));return bv.set(e,{size:n.size,mtime:n.mtimeMs,d:s}),s}function aI(t){let e;try{e=nI(t,"r")}catch{return}try{let n=iI(e).size,r=(s,i)=>{let o=Buffer.alloc(i);return o.subarray(0,rI(e,o,0,i,s)).toString("utf8")};return n<=2*rl?r(0,n):`${r(0,rl)}
2062
- ${r(n-rl,rl)}`}catch{return}finally{sI(e)}}async function Nn(t,e,n){let r=sv([...n.children].sort((c,u)=>(c.started??c.mtime)-(u.started??u.mtime))),s=r.map(c=>dv(wv(t,c.file),e)),i=fv(r.map((c,u)=>({id:c.id,writes:s[u].writes,reads:s[u].reads}))),o=await cI(e,Math.min(1/0,...[...i.writers.values()].flat().map(c=>c.at)),[...i.writers.keys()]),a=new Map(r.map(c=>[c.id,Et(c)])),l=r.map((c,u)=>({...pv(c,wv(t,c.file),s[u].edited,i,a,n.live,aI,o),depth:c.depth,parentId:c.parentId}));return{reports:l,files:lI(l,i,o)}}function lI(t,e,n){let r=new Set(t.filter(oi).map(o=>o.id)),s=new Map(t.map(o=>[o.id,o.name]));return[...e.writers].filter(([o])=>n.uncommitted(o)).map(([o,a])=>{let l=n.since(o),c=a.filter(d=>d.at>l);if(c.length<2&&!c.some(d=>r.has(d.id)))return;let u=e.blind.filter(d=>d.path===o&&d.overAt>l).flatMap(d=>[d.by,d.over]);return{path:o,writers:c.map(d=>({id:d.id,name:s.get(d.id)??d.id,running:r.has(d.id)})),blind:[...new Set(u)]}}).filter(o=>!!o).sort((o,a)=>o.path.localeCompare(a.path))}async function cI(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 f=l[d];if(f.length<4)continue;(f[0]==="R"||f[0]==="C")&&d++;let p=i(f.slice(3));p&&a.add(p)}let c=new Map;if(Number.isFinite(e)){let d=0;for(let f of(await we(["log",`--since=${new Date(e).toISOString()}`,"--format=@%ct","--name-only","--","."],t)).split(`
2059
+ ${c.id}`,{path:s,by:a.id,over:c.id,at:a.at,overAt:c.at})})}return{writers:n,blind:[...r.values()]}}function wv(t,e,n,r,s,i,o,a=Af){let l=p=>`"${s.get(p)??p}"`,c=e.calls.filter(p=>!p.refused&&(p.result===void 0||p.background&&p.endAt===void 0)).map(p=>({id:p.id,label:vf(p),short:Mr(Z(p.input?.description)??"",80)||vf(p),at:p.at,background:!!p.background,interrupted:!i||t.liveSince!==void 0&&(p.at??0)<t.liveSince,said:tI(Sf(p,o))})),u=new Map;for(let p of[...n.reads,...n.shellReads].sort((m,h)=>m.at-h.at)){let m=u.get(p.path)??{path:p.path,times:0,at:0};u.delete(p.path),u.set(p.path,{...m,times:m.times+1,at:Math.max(m.at,p.at)})}let d=t.state==="running"&&!c.length?e.calls.filter(p=>!p.refused).at(-1):void 0,f=d&&Sf(d);return{id:t.id,name:Et(t),state:t.state==="stopped"?"stopped":t.failing?"failing":t.state==="running"?"running":"finished",asOf:e.lastAt,activeMs:e.span,idleMs:e.idle,toolMs:e.toolMs,open:c,commands:JR(BR(e,o),c),files:n.edited.map(p=>{let m=a.since(p.path);return{...p,committed:!a.ignored(p.path)&&!a.uncommitted(p.path),ignored:a.ignored(p.path),also:(r.writers.get(p.path)??[]).filter(h=>h.id!==t.id&&h.at>m).map(h=>({name:s.get(h.id)??h.id,at:h.at})),blind:r.blind.filter(h=>h.path===p.path&&(h.by===t.id||h.over===t.id)&&h.overAt>m).map(h=>h.by===t.id?`\u26A0 written at ${Lr(h.at)} over ${l(h.over)}'s ${Lr(h.overAt)} write without reading it`:`\u26A0 ${l(h.by)} wrote over this agent's ${Lr(h.overAt)} write at ${Lr(h.at)} without reading it`)}}),read:[...u.values()].sort((p,m)=>p.at-m.at),latest:d&&f?{id:d.id,label:vf(d),run:f}:void 0}}function JR(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 KR(t,e){let n=In(t).filter(s=>s.background);return`${t.state==="finished"&&n.length?`finished, background call running ${ie(e-(n[0].at??e))}${n.length>1?` (+${n.length-1} more)`:""}`:t.state} \xB7 ${ie(Tf(t,e))} active${t.idleMs?`, ${ie(t.idleMs)} idle`:""}`}function zR(t,e){if(!t.open.length)return[`Now: ${HR(t,e)}`,...t.latest?[`Latest: ${t.latest.label} \xB7 ${nI(t.latest.run)}${t.latest.run.ms!==void 0?` after ${ie(t.latest.run.ms)}`:""}`]:[]];let n=(r,s)=>r.said?[`${s}"${r.said}"`]:[];return t.open.length===1?[`Now: ${fv(t.open[0],e)}`,...n(t.open[0]," ")]:["Now:",...t.open.flatMap(r=>[` ${fv(r,e)}`,...n(r," ")])]}function YR(t,e){let n=t.latest;return`latest: ${n.interrupted?"interrupted":n.open?`running ${ie(e-(n.at??e))}`:n.outcome&&n.outcome!=="completed"&&n.outcome!=="failed"&&n.exit===void 0?n.outcome:`exit ${n.exit??(n.failed?"error":0)}${n.ms!==void 0?` after ${ie(n.ms)}`:""}`}${t.streak>=2?`, failed ${t.streak} in a row`:""}`}function Sv(t,e){let n=[`Sub-agent "${t.name}" (${t.id}): ${KR(t,e)}${t.asOf?` \xB7 as of ${Lr(t.asOf)}`:""}`,""];n.push(...zR(t,e));let r=t.commands;n.push(`Commands: ${jR(r)}`);for(let a of r.groups.filter(el).slice(0,dv)){let l=eI(a);n.push(` ${a.cmd} \xD7${a.runs}${a.failed?`, ${a.failed} failed`:""}${l?` \xB7 ${l}`:""}`,` ${YR(a,e)}`);let c=[a.latest.first,a.latest.last].filter(Boolean).map(u=>`"${u}"`).join(" \u2026 ");c&&n.push(` ${c}`)}let s=Math.min(dv,r.groups.filter(el).length),i=r.groups.filter(el).length-s;i&&n.push(` +${i} more like these`),kv(r).runs&&n.push(` ${ZR(r)}`),n.push(`Files written: ${VR(t)}`);for(let a of t.files){let l=a.also.length?` also ${QR(a)}`:"";n.push(` ${rI(a)}${a.ignored?" (ignored)":a.committed?" (committed)":""}${l}`,...a.blind.map(c=>` ${c}`))}return t.activeMs&&n.push(`Time: ${XR(t,e)}`),n.push(`Files read: ${t.read.length||"none"}`,...t.read.map(a=>` ${sI(a)}`)),n.join(`
2060
+ `)}function GR(t,e){let n=t.toolMs+(In(t).some(r=>!r.background)?vv(t,e):0);return{tools:n,model:Math.max(0,Tf(t,e)-n)}}function xv(t,e,n,r){let s=e.filter(oi).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 ${ie(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(d=>`"${d.name}"${d.running?" (running)":""}`).join(", ")}${u.blind.length?" \u26A0":""}`)}o.push("","Agents:");let a=e.filter(u=>oi(u)||u.state==="failing"||n.some(d=>d.writers.some(f=>f.id===u.id))),l=new Set(a.map(u=>u.id));for(let u of a){let d=In(u)[0],f=u.state==="finished"?In(u).filter(T=>T.background):[],p=f.length?`finished, background call running ${ie(r-(f[0].at??r))}${f.length>1?` (+${f.length-1} more)`:""}`:u.state.padEnd(8),m=f.length?f[0].short:d?`waiting ${ie(r-(d.at??r))} on ${d.short}`:"",h=WR(u),y=[m,h>=2?`failed ${h} in a row`:"",n.some(T=>T.blind.includes(u.id))?"\u26A0":""].filter(Boolean),k=u.parentId&&l.has(u.parentId)?" ".repeat(Math.max(0,u.depth-1)):"";o.push(` ${k}${u.id} ${p} ${`${ie(Tf(u,r))} active`.padStart(10)} ${u.name}${y.length?` \xB7 ${y.join(" \xB7 ")}`:""}`)}let c=e.length-a.length;return c&&o.push(` ${a.length?"+":""}${c} ${e.some(u=>!l.has(u.id)&&u.state==="stopped")?"finished or stopped":"finished"}, 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(`
2061
+ `)}function Ev(t,e){let n=new Map,r=o=>`"${t.find(a=>a.id===o)?.name??o}"`,s=Math.max(0,...t.map(o=>o.asOf));t.length&&!t.some(oi)&&e-s>=iI&&n.set("idle",`No agent running for ${ie(e-s)} (${t.length} agents).`);for(let o of t){if(o.state==="finished")for(let a of In(o).filter(l=>l.background&&e-(l.at??e)>=oI))n.set(`background:${a.id}`,`${r(o.id)}: finished, background call running ${ie(e-(a.at??e))}: ${a.short}`);for(let a of o.commands.groups.filter(l=>l.streak>=2))n.set(`streak:${o.id}:${a.cmd}`,`${r(o.id)}: failed ${a.streak} in a row: ${a.cmd}`)}let i=t.flatMap(o=>In(o).filter(a=>!a.background&&e-(a.at??e)>=aI).map(a=>({a:o,ms:e-(a.at??e)})));return new Set(i.map(o=>o.a.id)).size>=2&&n.set("waiting",`${new Set(i.map(o=>o.a.id)).size} agents waiting on calls at once: ${i.map(o=>`${r(o.a.id)} ${ie(o.ms)}`).join(", ")}`),n}var TR,dv,pv,Mr,hv,xf,Lr,vf,PR,_R,RR,IR,$R,NR,LR,Ef,DR,jR,FR,UR,Af,In,oi,WR,vv,Tf,fv,HR,VR,XR,QR,el,kv,ZR,eI,tI,nI,rI,sI,iI,oI,aI,nl=v(()=>{"use strict";Nr();Io();Wu();TR=6e4,dv=8,pv=3*6e4,Mr=(t,e)=>(t=Ts(t).replace(/\s+/g," ").trim(),t.length>e?t.slice(0,e)+"\u2026":t),hv=t=>t.replace(/^(\s*(cd\s+\S+|export\s+PATH=\S+)\s*(;|&&)\s*)+/,""),xf=t=>Z(t.input?.command)??Z(t.input?.cmd),Lr=t=>new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),vf=t=>{let e=xf(t);if(e)return Mr(gv(hv(e).trim()),100);let n=Mr(gy(t.input),80);return n?`${Bu(t.name)}: ${n}`:Bu(t.name)};PR=/(^|[\s;|&(])(kill|pkill|killall|taskkill|stop-process)\b/i,_R=/\bgit\s+(-C\s+\S+\s+)?(commit|stash|checkout|reset|push|clean|restore|rebase|merge|cherry-pick|revert)\b/,RR=new Set(["grep","egrep","fgrep","rg","findstr","select-string"]),IR=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"]),$R=new Set(["log","status","diff","show","blame","rev-parse","ls-files","grep","branch","remote"]),NR=new Set(["status","logs","get","models","slug","predict"]),LR=new Set(["if","then","else","elif","fi","do","done","while","until","!","{","}","(",")"]),Ef=t=>t.replace(/'[^']*'|"(?:\\.|[^"\\])*"/g,e=>"_".repeat(e.length));DR=/<<-?\s*(['"]?)(\w+)\1([^\n]*)\n[\s\S]*?\n\s*\2\b/g;jR=t=>[t.runs?`${t.runs} run, ${t.failed} failed`:"",FR(t)].filter(Boolean).join(", ")||"none",FR=t=>t.lookups?`${t.lookups} ${t.lookups===1?"lookup":"lookups"}`:"",UR=["content","diff","new_string","new_source","edits"];Af={uncommitted:()=>!0,ignored:()=>!1,since:()=>0};In=t=>t.open.filter(e=>!e.interrupted),oi=t=>t.state==="running"||In(t).length>0,WR=t=>Math.max(0,...t.commands.groups.map(e=>e.streak)),vv=(t,e)=>t.state==="running"?Math.max(0,e-t.asOf):0,Tf=(t,e)=>t.activeMs+vv(t,e);fv=(t,e)=>t.interrupted?`${t.label}: interrupted, its process has ended`:`${t.label}, ${ie(e-(t.at??e))}${t.background?" (background)":""}`,HR=(t,e)=>`nothing open, last entry ${ie(e-t.asOf)} ago`;VR=t=>{let e=t.files.filter(n=>!n.committed&&!n.ignored).length;return t.files.length?`${t.files.length} (${e} uncommitted)`:"none"};XR=(t,e)=>{let n=GR(t,e);return`${ie(n.tools)} in tools, ${ie(n.model)} in the model`},QR=t=>t.also.map(e=>`"${e.name}" ${Lr(e.at)}`).join(", "),el=t=>t.failed>0||t.long||t.runs>=3||t.tags.length>0,kv=t=>{let e=t.groups.filter(n=>!el(n));return{runs:e.reduce((n,r)=>n+r.runs-r.open,0),ms:e.reduce((n,r)=>n+r.ms,0)}},ZR=(t,e=!0)=>{let n=kv(t);return`${n.runs}${e?" other":""} ${n.runs===1?"run":"runs"} passed, ${ie(n.ms)} in all`},eI=t=>[...t.tags,t.long?`over ${ie(pv)}`:""].filter(Boolean).join(", "),tI=t=>t?t.last||t.first:"",nI=t=>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",rI=t=>t.deleted?`${t.path} (deleted)`:t.from?`${t.path} (moved from ${t.from})`:t.path,sI=t=>t.times>1?`${t.path} \xD7${t.times}`:t.path;iI=5*6e4,oI=10*6e4,aI=2*6e4});import{openSync as lI,readSync as cI,closeSync as uI,fstatSync as dI,statSync as fI}from"fs";function*Cf(t,e){if(!t.listChildren)return;let n=t.callerSessionId?.(e),r=ii(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 Cv(t,e,s.sessionId,s.file,i))}}function Cv(t,e,n,r,s){let i=Za(t,n,e,r);return{sessionId:n,live:i,children:s.map(o=>({...o,state:si(o,i)}))}}function Ov(t,e){return t.callerSessionId?.(e)??Cf(t,e).next().value?.sessionId}function Pv(t,e,n){let r=t.listSessionFiles(e).find(s=>s.sessionId===n)?.file;return Cv(t,e,n,r,t.listChildren?.(e,n)??[])}function _v(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)||Et(s).toLowerCase().includes(n))}function Tv(t,e){let n={size:-1,mtimeMs:-1};try{n=fI(e)}catch{}let r=Av.get(e);if(r&&r.size===n.size&&r.mtime===n.mtimeMs)return r.d;let s=mv(cv(t,e,"child"));return Av.set(e,{size:n.size,mtime:n.mtimeMs,d:s}),s}function pI(t){let e;try{e=lI(t,"r")}catch{return}try{let n=dI(e).size,r=(s,i)=>{let o=Buffer.alloc(i);return o.subarray(0,cI(e,o,0,i,s)).toString("utf8")};return n<=2*rl?r(0,n):`${r(0,rl)}
2062
+ ${r(n-rl,rl)}`}catch{return}finally{uI(e)}}async function $n(t,e,n){let r=uv([...n.children].sort((c,u)=>(c.started??c.mtime)-(u.started??u.mtime))),s=r.map(c=>yv(Tv(t,c.file),e)),i=bv(r.map((c,u)=>({id:c.id,writes:s[u].writes,reads:s[u].reads}))),o=await mI(e,Math.min(1/0,...[...i.writers.values()].flat().map(c=>c.at)),[...i.writers.keys()]),a=new Map(r.map(c=>[c.id,Et(c)])),l=r.map((c,u)=>({...wv(c,Tv(t,c.file),s[u],i,a,n.live,pI,o),depth:c.depth,parentId:c.parentId}));return{reports:l,files:hI(l,i,o)}}function hI(t,e,n){let r=new Set(t.filter(oi).map(o=>o.id)),s=new Map(t.map(o=>[o.id,o.name]));return[...e.writers].filter(([o])=>n.uncommitted(o)).map(([o,a])=>{let l=n.since(o),c=a.filter(d=>d.at>l);if(c.length<2&&!c.some(d=>r.has(d.id)))return;let u=e.blind.filter(d=>d.path===o&&d.overAt>l).flatMap(d=>[d.by,d.over]);return{path:o,writers:c.map(d=>({id:d.id,name:s.get(d.id)??d.id,running:r.has(d.id)})),blind:[...new Set(u)]}}).filter(o=>!!o).sort((o,a)=>o.path.localeCompare(a.path))}async function mI(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 f=l[d];if(f.length<4)continue;(f[0]==="R"||f[0]==="C")&&d++;let p=i(f.slice(3));p&&a.add(p)}let c=new Map;if(Number.isFinite(e)){let d=0;for(let f of(await we(["log",`--since=${new Date(e).toISOString()}`,"--format=@%ct","--name-only","--","."],t)).split(`
2063
2063
  `)){if(f.startsWith("@")){d=Number(f.slice(1))*1e3;continue}let p=f.trim()&&i(f.trim());p&&!c.has(p)&&c.set(p,d)}}let u=new Set(n.length?(await we(["check-ignore","--",...n],t).catch(()=>"")).split(`
2064
- `).map(d=>r(d.trim())).filter(Boolean):[]);return{uncommitted:d=>a.has(r(d)),ignored:d=>u.has(r(d)),since:d=>c.get(r(d))??0}}catch{return xf}}var bv,rl,sl=S(()=>{"use strict";Nr();yf();Lr();bf();nl();bv=new Map;rl=4096});import{existsSync as Ev,openSync as uI,readSync as dI,closeSync as fI,statSync as ai,readdirSync as Av,watchFile as pI,unwatchFile as Tv,mkdirSync as hI,writeFileSync as mI,readFileSync as Tf,unlinkSync as gI,rmSync as yI}from"fs";import{stat as bI}from"fs/promises";import{dirname as wI,join as Ln,resolve as Cv}from"path";function xI(t){if(!Number.isInteger(t))return!0;try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}function Dr(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:Qa(t),thread:"main"},n;function r(y,k){let w={offset:k,text:""},O;try{O=ai(y).size}catch{return w}if(O<=k)return w;let N;try{N=uI(y,"r")}catch{return w}try{let D=O-k,B=Buffer.alloc(D),z=0;for(;z<D;){let Q=dI(N,B,z,D-z,k+z);if(!Q)break;z+=Q}return{offset:k+z,text:B.subarray(0,z).toString("utf8")}}finally{fI(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 k={d:t.createDriver(e.cwd,y),file:y,id:`new:${++o}`,startedAt:Date.now()};return s.add(k),e.file||(i=k),k}function c(){let y=[...s].filter(w=>w.file);if(!y.length)return[];let k=new Map(t.listSessionFiles(e.cwd).map(w=>[w.file,w.sessionId]));return y.map(w=>{let O=k.get(w.file);return{rec:w,sessionId:O??w.id,pending:O===void 0}})}let u=()=>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(k){console.error("[composer] dispose:",V(k))}}function f(){let y=a(),k=new Set(u().map(w=>w.rec));for(let w of[...s])w!==y&&(k.has(w)||w.d.streaming||w.d.queue||w.d.error||d(w))}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(k=>k.file===i.file);y&&H(y)}i&&!e.file&&i.prompt!==void 0&&e.sessionId!==i.id&&(F(void 0,i.id),e.everAttached=!0)}let h=y=>Ln(y,SI),m=(y,k)=>Ln(h(y),`${k}.lock`);function g(y,k){try{let w=m(y,k);if(Date.now()-ai(w).mtimeMs>=Ov)return!1;try{let O=parseInt(Tf(w,"utf8").trim(),10);if(O===process.pid||!xI(O))return!1}catch{}return!0}catch{return!1}}function v(y,k){if(k)try{hI(h(y),{recursive:!0}),mI(m(y,k),String(process.pid))}catch(w){console.error("[lock] claim failed:",V(w))}}function A(y){try{yI(Ln(y,".claude-bulb"),{recursive:!0,force:!0})}catch{}}function C(y){let k=h(y);if(!Ev(k))return;let w;try{w=Av(k)}catch{return}let O=Date.now();for(let N of w){if(!N.endsWith(".lock"))continue;let D=Ln(k,N);try{let B=ai(D);O-B.mtimeMs>kI&&gI(D)}catch{}}}function x(y){try{return ai(y),!1}catch(k){return k.code==="ENOENT"}}function R(){let y=e;if(y.file&&!x(y.file)){v(y.cwd,y.sessionId);return}let k=I(y);k&&H(k)}function I(y){if(!y.everAttached)return L(y.cwd)??T(y.cwd,()=>!0)}function L(y){let k=h(y);if(!Ev(k))return;let w;try{w=Av(k)}catch{return}let O;for(let D of w)if(D.endsWith(".lock"))try{let B=ai(Ln(k,D));if(Date.now()-B.mtimeMs>=Ov||parseInt(Tf(Ln(k,D),"utf8").trim(),10)!==process.pid)continue;(!O||B.mtimeMs>O.mtime)&&(O={sessionId:D.slice(0,-5),mtime:B.mtimeMs})}catch{}if(!O)return;let N=t.listSessionFiles(y).find(D=>D.sessionId===O.sessionId);if(!(!N||x(N.file)))return N}function T(y,k){return t.listSessionFiles(y).sort((w,O)=>O.mtime-w.mtime).find(w=>!g(y,w.sessionId)&&k(w))}function F(y,k){let w=e;if(w.file)try{Tv(w.file)}catch{}w.file=y,w.sessionId=k,w.partial="",w.offset=0,w.latest={in:0,out:0,cached:0,cacheCreate:0},w.latestModel=null,w.index=Qa(t),w.chainLastId=void 0,w.buffer.push({type:"cleared"}),w.buffer.push({type:"session",sessionId:k})}function H(y){let k=e;i=void 0,xi(),n=y.file,F(y.file,y.sessionId),k.everAttached=!0,v(k.cwd,y.sessionId),ne(y.file)}function ne(y){if(re(),!!y){try{Tv(y)}catch{}pI(y,{interval:200},()=>re())}}function U(){xi(),n=void 0,F(void 0,"")}function re(){let y=e;if(!y.file)return;let k=r(y.file,y.offset);if(!k.text)return;y.offset=k.offset,y.partial+=k.text;let w=y.partial.lastIndexOf(`
2065
- `);if(w<0)return;let O=y.index.add(y.partial.slice(0,w).split(`
2066
- `),y.thread);if(y.partial=y.partial.slice(w+1),!O)return;let N=[],{entries:D}=y.index,B=D.get(O),z=!1;for(;B;){if(N.push(B),t.idOf(B)===y.chainLastId){z=!0;break}let Q=t.parentOf(B);B=Q?D.get(Q):void 0}if(z)for(let Q=N.length-2;Q>=0;Q--)pe(N[Q]);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 Q=new Set(N.map(ue=>t.idOf(ue))),dt=ge(D);for(let ue=N.length-1;ue>=0;ue--)pe(N[ue]),Le(t.idOf(N[ue]),dt,Q)}y.chainLastId=O}function ge(y){let k=new Map;for(let w of y.values()){let O=t.parentOf(w);if(!O)continue;let N=k.get(O);N?N.push(w):k.set(O,[w])}return k}function Le(y,k,w){if(!y)return;let O=k.get(y);if(!O)return;let N=O.filter(Q=>!t.isSidechain(Q,e.thread));if(N.length<2)return;let D=N.filter(Q=>!w.has(t.idOf(Q)));if(!D.length)return;let B=[],z=0;for(let Q of D){let dt=ut(Q,k);B.push(...dt.events),z+=dt.count}z>0&&e.buffer.push({type:"fork",atId:y,count:z,events:B})}function ut(y,k){let w=[],O=[y];for(;O.length;){let B=O.pop();if(t.isSidechain(B,e.thread))continue;w.push(B);let z=k.get(t.idOf(B)??"");if(z)for(let Q of z)O.push(Q)}w.sort((B,z)=>(Date.parse(t.timestampOf(B)??"")||0)-(Date.parse(t.timestampOf(z)??"")||0));let N=[];for(let B of w)t.isRecoveryNoise(B)||N.push(...Xa(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 pe(y){if(!t.isSidechain(y,e.thread))try{let{events:k,usage:w,model:O,cost:N}=Xa(t,y,e.thread,e.sessionStartMs);for(let D of k)e.buffer.push(D);k.some(D=>D.type==="assistant")&&a()?.d.clearCompletedDraft(),k.some(D=>D.type==="user")&&a()?.d.clearEcho(),O&&(e.latestModel=O),w&&(e.latest=w),(w||N)&&e.buffer.push({type:"usage",...e.latest,cost:N})}catch(k){console.error("[mirror] skipped malformed entry:",V(k))}}async function Ce(){return{cwd:e.cwd,pid:process.pid,composer:!!t.createDriver,children:!!t.listChildren,elsewhere:await Ot()}}async function Ot(){if(t.listSessionFiles(e.cwd).length)return;let y=await Rn();if(!y)return;let k=Cv(y).toLowerCase();for(let w=Cv(e.cwd);w.toLowerCase()!==k;){let O=wI(w);if(O===w)return;w=O;let N=t.listSessionFiles(w).length;if(N)return{dir:w,count:N}}}Ot().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 b=new Ka;async function E(y,k){e.thread!=="child"&&b.accept(y,k)&&console.log(k)}function P(){return Za(t,e.sessionId,e.cwd,e.file)}function $(){return t.chainWorking([...e.index.entries.values()])&&P()}function M(){!t.createDriver||a()||e.latestModel||$()||l(e.file)}async function W(y){let k=e;R(),p(),M(),f();let w=a();for(let B of s)B!==w&&B.d.dialog;let O=c().filter(B=>B.rec.d.streaming).map(B=>B.sessionId),N=$(),D=t.createDriver?{streaming:!!w?.d.streaming,foreign:!w&&N,draft:w?.d.draft??null,echo:w?.d.echo??null,status:w?.d.status??null,dialog:w?.d.dialog??null,queue:w?.d.queue??null,stats:w?.d.stats??null,model:w?.d.model??null,error:w?.d.error}:void 0;return{events:k.buffer.slice(y),cursor:k.buffer.length,working:!!w?.d.streaming||N,latestModel:k.latestModel,child:k.child?.id??null,composer:D,busy:O}}async function q(){R(),p();let y=a();if(y?.d.error&&!y.d.streaming&&(await d(y),y=void 0),!y){if($())return{ok:!1,error:"the agent is mid-turn in a terminal \u2014 watch only"};y=l(e.file)}let k=y;return{ok:!0,d:k.d,markSent:w=>{k.prompt===void 0&&(k.prompt=w)}}}async function Ke(y,k){if(!t.createDriver)return{ok:!1,error:"not supported"};let w=String(y??"").trim();if(!w)return{ok:!1,error:"empty message"};let O=await q();if(!O.ok)return O;let N=await O.d.send(w,k);return N.ok&&O.markSent(w),N}async function Y(y,k){let w=a();return w?w.d.respondUi(String(y??""),k??{}):{ok:!1,error:"no dialog pending"}}async function ce(y,k){if(!t.createDriver)return{ok:!1,error:"not supported"};if(!y||typeof y.type!="string")return{ok:!1,error:"bad command"};if(k?.spawn){let O=await q();return O.ok?O.d.rpc(y):O}let w=a();return!w||w.d.error?{ok:!1,error:"not running"}:w.d.rpc(y)}async function Oe(){let y=a();if(y)try{await y.d.stop()}catch(k){console.error("[composer] stop:",V(k))}return{ok:!0}}async function Jr(){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),f(),{ok:!0})):{ok:!1,error:"not supported"}}async function sn(){if(!t.createDriver)return[];let y=await we(["ls-files","--cached","--others","--exclude-standard"],e.cwd).catch(()=>null),k=y!==null?y.split(`
2067
- `).filter(Boolean):await t.walkFiles?.(e.cwd)??[];return(await Promise.all(k.map(async O=>{try{return{f:O,m:(await bI(Ln(e.cwd,O))).mtimeMs}}catch{return{f:O,m:0}}}))).sort((O,N)=>N.m-O.m).map(O=>O.f)}function Pt(){for(let y of[...s])d(y)}async function Ml(y){return t.createDriver?Gw(e.cwd,y):{ok:!1,error:"not supported"}}async function Dl(y){return Xw(e.cwd,String(y??""))}async function Ik(y,k){return tv(String(y??""),String(k??""))}async function $k(y){let k=t.listChildren?.(e.cwd,e.sessionId)??[],w=P(),{reports:O}=await Nn(t,e.cwd,{sessionId:e.sessionId,live:w,children:k.map(D=>({...D,state:si(D,w)}))}),N=O.find(D=>D.id===y);return N?{ok:!0,report:N}:{ok:!1,error:"child not found"}}async function Nk(){let y=t.sessionsWorking?.(e.cwd),k=t.listSessionFiles(e.cwd).map(({sessionId:O,file:N,mtime:D})=>({sessionId:O,mtime:D,preview:t.readPreview(N),working:y?.has(O)})),w=u().map(O=>({sessionId:O.sessionId,mtime:O.rec.startedAt,preview:O.rec.prompt??"",pending:!0}));return ii([...k,...w],O=>O.mtime)}let kp=new Map;function xp(y,k){let w=kp.get(y);if(w&&w.mtime===k)return w.turns;let O=[],N="";try{N=Tf(y,"utf8")}catch{return[]}for(let D of N.split(`
2068
- `)){if(!D.trim())continue;let B=t.parseEntry(D);if(!B)continue;let z=t.searchText(B);z&&O.push({text:z,lower:z.toLowerCase()})}return kp.set(y,{mtime:k,turns:O}),O}async function Lk(y){let k=y.toLowerCase(),w=[],O=0,N=t.sessionsWorking?.(e.cwd);for(let{sessionId:D,file:B,mtime:z}of t.listSessionFiles(e.cwd).sort((Q,dt)=>dt.mtime-Q.mtime)){let Q=ri(xp(B,z),k),dt=(t.listChildren?.(e.cwd,D)??[]).map(ue=>({c:ue,hit:ri(xp(ue.file,ue.mtime),k)})).filter(ue=>ue.hit.hitCount);if(!(!Q.hitCount&&!dt.length)){for(let{c:ue,hit:Fk}of ii(dt,Uk=>Uk.c.mtime))w.push({sessionId:D,mtime:ue.mtime,preview:Et(ue),...Fk,child:{id:ue.id,kind:ue.kind,depth:ue.depth}});if(w.push({sessionId:D,mtime:z,preview:t.readPreview(B),working:N?.has(D),...Q}),++O>=EI)break}}return w}async function Mk(y){let k=e,w=t.listSessionFiles(k.cwd).find(O=>O.sessionId===y);if(!w){let O=u().find(N=>N.sessionId===y)?.rec;return O?((i!==O||k.sessionId!==O.id)&&(i=O,xi(),n=void 0,F(void 0,O.id),k.everAttached=!0,f()),{ok:!0}):{ok:!1,error:"session not found"}}return w.file===k.file?{ok:!0}:(H(w),p(),f(),{ok:!0})}async function Dk(){if(!t.listChildren||!e.sessionId)return[];let y=P();return t.listChildren(e.cwd,e.sessionId).map(k=>({...k,state:si(k,y)}))}async function Bk(y){let k=e;if(!t.listChildren)return{ok:!1,error:"this harness has no child transcripts"};let w=t.listChildren(k.cwd,k.sessionId).find(O=>O.id===y);return w?(k.thread="child",k.child=w,F(w.file,k.sessionId),ne(w.file),{ok:!0}):{ok:!1,error:"child not found"}}async function jk(){let y=n;return!xi()||!y?{ok:!0}:(F(y,e.sessionId),ne(y),{ok:!0})}function xi(){let y=e;return y.thread==="main"?!1:(y.thread="main",y.child=void 0,!0)}return A(e.cwd),C(e.cwd),R(),{info:Ce,poll:W,logInlineStatus:E,listSessions:Nk,searchSessions:Lk,attach:Mk,listChildren:Dk,openChild:Bk,closeChild:jk,composerSend:Ke,composerStop:Oe,composerNew:Jr,composerFiles:sn,composerUiRespond:Y,composerRpc:ce,composerPaste:Ml,composerPasteRead:Dl,summarizeTurn:Ik,childStatus:$k,shutdownComposer:Pt}}var vI,SI,Ov,kI,EI,il=S(()=>{"use strict";Gt();Ww();Nr();mf();Qw();nv();yf();sl();bf();Lr();vI=".typebulb",SI=`${vI}/locks`,Ov=5e3,kI=6e4;EI=50});import{existsSync as _f,mkdirSync as AI,readFileSync as Pv,writeFileSync as TI}from"fs";import{join as Mn,isAbsolute as CI}from"path";async function If(t,e){let n=CI(t)?t:Mn(X,t);return _f(n)?(md(n,e),{ok:!0}):{ok:!1,error:"file not found"}}async function $f(t){let e=X,n=hd(t),r=Mn(e,"typebulbs");AI(r,{recursive:!0});let s=ud(n),i=`${s}.bulb.md`;for(let c=2;_f(Mn(r,i))&&Pv(Mn(r,i),"utf8")!==n;c++)i=`${s}-${c}.bulb.md`;let o=Mn(r,i);_f(o)||TI(o,n);let a=Mn("typebulbs",i),l=await bn(a,{cwd:e,open:!1});return{ok:!0,file:a,pid:l.pid,url:l.url}}async function Nf(){return G(X)}async function Lf(t){let e=(await G()).find(n=>n.pid===t);return e?{ok:!0,outcome:await gt(e)}:(await ar(t),{ok:!0})}async function Mf(){let t=await hn(X);return sa(X).filter(e=>!e.serverOnly).map(e=>({...e,trusted:Sn(e.path),lastRunAt:t(e.path)}))}async function Df(t){let e=t.toLowerCase(),n=[];for(let r of sa(X).filter(s=>!s.serverOnly).sort((s,i)=>i.mtime-s.mtime)){let s="";try{s=Pv(r.path,"utf8")}catch{continue}let i=[];for(let l of s.split(`
2069
- `)){let c=l.replace(/\s+/g," ").trim();c&&i.push({text:c,lower:c.toLowerCase()})}let{hitCount:o,snippet:a}=ri(i,e);o&&n.push({path:r.path,hitCount:o,snippet:a})}return n}async function Bf(t,e){let n=X;e!=null&&pr(t,e);let r=await bn(t,{cwd:n,open:!1,trust:e});return{ok:!0,file:r.file,pid:r.pid,url:r.url,trust:!!r.trust}}async function jf(t){return{cap:await fd(t)}}async function Ff(t,e){return pr(t,e),{ok:!0}}async function Uf(t,e){return Xe(t,e)}async function qf(){return li&&Date.now()-li.fetchedAt<=PI?li.samples:(Cf??=_I().finally(()=>{Cf=null}),Cf)}async function _I(){try{let t=await fetch(`${OI}/api/scripts/u/samples?stubs`,{signal:AbortSignal.timeout(Rv)});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:Hl(i.config)}));return li={samples:s,fetchedAt:Date.now()},s}catch{return li?.samples??[]}}async function Jf(t){return Rf.test(t)?$v(_v,"samples",t,!0):{ok:!1,error:"bad slug"}}async function Kf(){let t=Wf();if(!t)return{bulbs:[]};let e=`${ol()}
2070
- ${t}`;return Xt?.key===e&&Date.now()-Xt.fetchedAt<=RI?{user:Xt.user,bulbs:Xt.bulbs}:(Of??=II(e,t).finally(()=>{Of=null}),Of)}async function Pf(t,e,n){let r=await fetch(`${t}${e}`,{headers:n,signal:AbortSignal.timeout(Rv)});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 II(t,e){let n={Authorization:`Bearer ${e}`};try{let r=ol(),s;try{s=await Pf(r,"/api/me",n)}catch{let a=new URL(r);r=`${a.protocol}//api.${a.host}`,s=await Pf(r,"/api/me",n)}let o=(await Pf(r,"/api/scripts/list",n)).filter(a=>a.userSlug===s.slug&&!a.isTemplate).map(a=>({slug:a.slug,name:a.name,description:Hl(a.config)}));return Xt={key:t,user:s.slug,bulbs:o,fetchedAt:Date.now()},{user:s.slug,bulbs:o}}catch{return Xt?.key===t?{user:Xt.user,bulbs:Xt.bulbs}:{bulbs:[]}}}async function Hf(t,e,n=!1){return!Rf.test(e)||!Rf.test(t)?{ok:!1,error:"bad slug"}:$v(ol(),t,e,n)}async function $v(t,e,n,r){let s=Ma(e,n);try{let i=await ja({origin:t,userSlug:e,slug:n,dest:Mn(X,s)},{force:r,token:Wf(),timeoutMs:Iv});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 zf(t,e=!1){let n=Wf();if(!n)return{ok:!1,error:"no TYPEBULB_TOKEN in .env"};try{let r=Ba(t,X,ol()),s=await Ua(r,{token:n,force:e,timeoutMs:Iv});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 OI,_v,PI,Rv,Iv,li,Cf,Rf,RI,Xt,Of,ol,Wf,al=S(()=>{"use strict";Rr();Gt();mf();Z();OI="https://api.typebulb.com",_v="https://typebulb.com",PI=3600*1e3,Rv=5e3,Iv=15e3,li=null,Cf=null;Rf=/^[a-z0-9][a-z0-9-]*$/,RI=300*1e3,Xt=null,Of=null,ol=()=>ma("TYPEBULB_ORIGIN",X)||_v,Wf=()=>ma("TYPEBULB_TOKEN",X)});import{readFileSync as Gf,writeFileSync as Lv,mkdirSync as $I,appendFileSync as Mv,rmSync as Nv}from"fs";import{join as ul,dirname as NI}from"path";import{createServer as LI}from"http";function Qt(t){try{return JSON.parse(Gf(t,"utf8"))}catch{return null}}function cl(t,e){$I(NI(t),{recursive:!0}),Lv(t,JSON.stringify(e,null,2)+`
2071
- `)}function Bv(t,e,n){let r=ul(t,".gitignore"),s="";try{s=Gf(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(`
2064
+ `).map(d=>r(d.trim())).filter(Boolean):[]);return{uncommitted:d=>a.has(r(d)),ignored:d=>u.has(r(d)),since:d=>c.get(r(d))??0}}catch{return Af}}var Av,rl,sl=v(()=>{"use strict";$r();bf();Nr();wf();nl();Av=new Map;rl=4096});import{existsSync as Rv,openSync as gI,readSync as yI,closeSync as bI,statSync as ai,readdirSync as Iv,watchFile as wI,unwatchFile as $v,mkdirSync as vI,writeFileSync as SI,readFileSync as Of,unlinkSync as kI,rmSync as xI}from"fs";import{stat as EI}from"fs/promises";import{dirname as AI,join as Nn,resolve as Nv}from"path";function PI(t){if(!Number.isInteger(t))return!0;try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}function Dr(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:Qa(t),thread:"main"},n;function r(g,S){let w={offset:S,text:""},C;try{C=ai(g).size}catch{return w}if(C<=S)return w;let L;try{L=gI(g,"r")}catch{return w}try{let B=C-S,j=Buffer.alloc(B),z=0;for(;z<B;){let Q=yI(L,j,z,B-z,S+z);if(!Q)break;z+=Q}return{offset:S+z,text:j.subarray(0,z).toString("utf8")}}finally{bI(L)}}let s=new Set,i,o=0;function a(){if(e.file){for(let g of s)if(g.file===e.file)return g;return}return i}function l(g){let S={d:t.createDriver(e.cwd,g),file:g,id:`new:${++o}`,startedAt:Date.now()};return s.add(S),e.file||(i=S),S}function c(){let g=[...s].filter(w=>w.file);if(!g.length)return[];let S=new Map(t.listSessionFiles(e.cwd).map(w=>[w.file,w.sessionId]));return g.map(w=>{let C=S.get(w.file);return{rec:w,sessionId:C??w.id,pending:C===void 0}})}let u=()=>c().filter(g=>g.pending&&g.rec.prompt!==void 0);async function d(g){s.delete(g),i===g&&(i=void 0);try{await g.d.dispose()}catch(S){console.error("[composer] dispose:",V(S))}}function f(){let g=a(),S=new Set(u().map(w=>w.rec));for(let w of[...s])w!==g&&(S.has(w)||w.d.streaming||w.d.queue||w.d.error||d(w))}function p(){for(let g of s)g.d.sessionFile&&g.file!==g.d.sessionFile&&(g.file=g.d.sessionFile);if(i&&!e.file&&i.file){let g=t.listSessionFiles(e.cwd).find(S=>S.file===i.file);g&&K(g)}i&&!e.file&&i.prompt!==void 0&&e.sessionId!==i.id&&(M(void 0,i.id),e.everAttached=!0)}let m=g=>Nn(g,CI),h=(g,S)=>Nn(m(g),`${S}.lock`);function y(g,S){try{let w=h(g,S);if(Date.now()-ai(w).mtimeMs>=Lv)return!1;try{let C=parseInt(Of(w,"utf8").trim(),10);if(C===process.pid||!PI(C))return!1}catch{}return!0}catch{return!1}}function k(g,S){if(S)try{vI(m(g),{recursive:!0}),SI(h(g,S),String(process.pid))}catch(w){console.error("[lock] claim failed:",V(w))}}function T(g){try{xI(Nn(g,".claude-bulb"),{recursive:!0,force:!0})}catch{}}function P(g){let S=m(g);if(!Rv(S))return;let w;try{w=Iv(S)}catch{return}let C=Date.now();for(let L of w){if(!L.endsWith(".lock"))continue;let B=Nn(S,L);try{let j=ai(B);C-j.mtimeMs>OI&&kI(B)}catch{}}}function E(g){try{return ai(g),!1}catch(S){return S.code==="ENOENT"}}function O(){let g=e;if(g.file&&!E(g.file)){k(g.cwd,g.sessionId);return}let S=_(g);S&&K(S)}function _(g){if(!g.everAttached)return I(g.cwd)??A(g.cwd,()=>!0)}function I(g){let S=m(g);if(!Rv(S))return;let w;try{w=Iv(S)}catch{return}let C;for(let B of w)if(B.endsWith(".lock"))try{let j=ai(Nn(S,B));if(Date.now()-j.mtimeMs>=Lv||parseInt(Of(Nn(S,B),"utf8").trim(),10)!==process.pid)continue;(!C||j.mtimeMs>C.mtime)&&(C={sessionId:B.slice(0,-5),mtime:j.mtimeMs})}catch{}if(!C)return;let L=t.listSessionFiles(g).find(B=>B.sessionId===C.sessionId);if(!(!L||E(L.file)))return L}function A(g,S){return t.listSessionFiles(g).sort((w,C)=>C.mtime-w.mtime).find(w=>!y(g,w.sessionId)&&S(w))}function M(g,S){let w=e;if(w.file)try{$v(w.file)}catch{}w.file=g,w.sessionId=S,w.partial="",w.offset=0,w.latest={in:0,out:0,cached:0,cacheCreate:0},w.latestModel=null,w.index=Qa(t),w.chainLastId=void 0,w.buffer.push({type:"cleared"}),w.buffer.push({type:"session",sessionId:S})}function K(g){let S=e;i=void 0,xi(),n=g.file,M(g.file,g.sessionId),S.everAttached=!0,k(S.cwd,g.sessionId),ne(g.file)}function ne(g){if(re(),!!g){try{$v(g)}catch{}wI(g,{interval:200},()=>re())}}function U(){xi(),n=void 0,M(void 0,"")}function re(){let g=e;if(!g.file)return;let S=r(g.file,g.offset);if(!S.text)return;g.offset=S.offset,g.partial+=S.text;let w=g.partial.lastIndexOf(`
2065
+ `);if(w<0)return;let C=g.index.add(g.partial.slice(0,w).split(`
2066
+ `),g.thread);if(g.partial=g.partial.slice(w+1),!C)return;let L=[],{entries:B}=g.index,j=B.get(C),z=!1;for(;j;){if(L.push(j),t.idOf(j)===g.chainLastId){z=!0;break}let Q=t.parentOf(j);j=Q?B.get(Q):void 0}if(z)for(let Q=L.length-2;Q>=0;Q--)pe(L[Q]);else{g.chainLastId!==void 0&&(g.buffer.push({type:"cleared"}),g.buffer.push({type:"session",sessionId:g.sessionId}),g.latest={in:0,out:0,cached:0,cacheCreate:0});let Q=new Set(L.map(ue=>t.idOf(ue))),dt=ge(B);for(let ue=L.length-1;ue>=0;ue--)pe(L[ue]),Le(t.idOf(L[ue]),dt,Q)}g.chainLastId=C}function ge(g){let S=new Map;for(let w of g.values()){let C=t.parentOf(w);if(!C)continue;let L=S.get(C);L?L.push(w):S.set(C,[w])}return S}function Le(g,S,w){if(!g)return;let C=S.get(g);if(!C)return;let L=C.filter(Q=>!t.isSidechain(Q,e.thread));if(L.length<2)return;let B=L.filter(Q=>!w.has(t.idOf(Q)));if(!B.length)return;let j=[],z=0;for(let Q of B){let dt=ut(Q,S);j.push(...dt.events),z+=dt.count}z>0&&e.buffer.push({type:"fork",atId:g,count:z,events:j})}function ut(g,S){let w=[],C=[g];for(;C.length;){let j=C.pop();if(t.isSidechain(j,e.thread))continue;w.push(j);let z=S.get(t.idOf(j)??"");if(z)for(let Q of z)C.push(Q)}w.sort((j,z)=>(Date.parse(t.timestampOf(j)??"")||0)-(Date.parse(t.timestampOf(z)??"")||0));let L=[];for(let j of w)t.isRecoveryNoise(j)||L.push(...Xa(t,j,e.thread,e.sessionStartMs).events);return{count:L.reduce((j,z)=>j+(z.type==="user"||z.type==="assistant"?1:0),0),events:L}}function pe(g){if(!t.isSidechain(g,e.thread))try{let{events:S,usage:w,model:C,cost:L}=Xa(t,g,e.thread,e.sessionStartMs);for(let B of S)e.buffer.push(B);S.some(B=>B.type==="assistant")&&a()?.d.clearCompletedDraft(),S.some(B=>B.type==="user")&&a()?.d.clearEcho(),C&&(e.latestModel=C),w&&(e.latest=w),(w||L)&&e.buffer.push({type:"usage",...e.latest,cost:L})}catch(S){console.error("[mirror] skipped malformed entry:",V(S))}}async function Ce(){return{cwd:e.cwd,pid:process.pid,composer:!!t.createDriver,children:!!t.listChildren,elsewhere:await Ot()}}async function Ot(){if(t.listSessionFiles(e.cwd).length)return;let g=await Rn();if(!g)return;let S=Nv(g).toLowerCase();for(let w=Nv(e.cwd);w.toLowerCase()!==S;){let C=AI(w);if(C===w)return;w=C;let L=t.listSessionFiles(w).length;if(L)return{dir:w,count:L}}}Ot().then(g=>{g&&console.log(`No sessions for ${e.cwd} \u2014 ${g.count} exist for ${g.dir}. Launched from a subfolder? Relaunch from the project root.`)}).catch(()=>{});let b=new Ka;async function x(g,S){e.thread!=="child"&&b.accept(g,S)&&console.log(S)}function R(){return Za(t,e.sessionId,e.cwd,e.file)}function N(){return t.chainWorking([...e.index.entries.values()])&&R()}function D(){!t.createDriver||a()||e.latestModel||N()||l(e.file)}async function W(g){let S=e;O(),p(),D(),f();let w=a();for(let j of s)j!==w&&j.d.dialog;let C=c().filter(j=>j.rec.d.streaming).map(j=>j.sessionId),L=N(),B=t.createDriver?{streaming:!!w?.d.streaming,foreign:!w&&L,draft:w?.d.draft??null,echo:w?.d.echo??null,status:w?.d.status??null,dialog:w?.d.dialog??null,queue:w?.d.queue??null,stats:w?.d.stats??null,model:w?.d.model??null,error:w?.d.error}:void 0;return{events:S.buffer.slice(g),cursor:S.buffer.length,working:!!w?.d.streaming||L,latestModel:S.latestModel,child:S.child?.id??null,composer:B,busy:C}}async function q(){O(),p();let g=a();if(g?.d.error&&!g.d.streaming&&(await d(g),g=void 0),!g){if(N())return{ok:!1,error:"the agent is mid-turn in a terminal \u2014 watch only"};g=l(e.file)}let S=g;return{ok:!0,d:S.d,markSent:w=>{S.prompt===void 0&&(S.prompt=w)}}}async function Ke(g,S){if(!t.createDriver)return{ok:!1,error:"not supported"};let w=String(g??"").trim();if(!w)return{ok:!1,error:"empty message"};let C=await q();if(!C.ok)return C;let L=await C.d.send(w,S);return L.ok&&C.markSent(w),L}async function Y(g,S){let w=a();return w?w.d.respondUi(String(g??""),S??{}):{ok:!1,error:"no dialog pending"}}async function ce(g,S){if(!t.createDriver)return{ok:!1,error:"not supported"};if(!g||typeof g.type!="string")return{ok:!1,error:"bad command"};if(S?.spawn){let C=await q();return C.ok?C.d.rpc(g):C}let w=a();return!w||w.d.error?{ok:!1,error:"not running"}:w.d.rpc(g)}async function Oe(){let g=a();if(g)try{await g.d.stop()}catch(S){console.error("[composer] stop:",V(S))}return{ok:!0}}async function Jr(){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),f(),{ok:!0})):{ok:!1,error:"not supported"}}async function sn(){if(!t.createDriver)return[];let g=await we(["ls-files","--cached","--others","--exclude-standard"],e.cwd).catch(()=>null),S=g!==null?g.split(`
2067
+ `).filter(Boolean):await t.walkFiles?.(e.cwd)??[];return(await Promise.all(S.map(async C=>{try{return{f:C,m:(await EI(Nn(e.cwd,C))).mtimeMs}}catch{return{f:C,m:0}}}))).sort((C,L)=>L.m-C.m).map(C=>C.f)}function Pt(){for(let g of[...s])d(g)}async function Ml(g){return t.createDriver?nv(e.cwd,g):{ok:!1,error:"not supported"}}async function Dl(g){return rv(e.cwd,String(g??""))}async function jk(g,S){return av(String(g??""),String(S??""))}async function Fk(g){let S=t.listChildren?.(e.cwd,e.sessionId)??[],w=R(),{reports:C}=await $n(t,e.cwd,{sessionId:e.sessionId,live:w,children:S.map(B=>({...B,state:si(B,w)}))}),L=C.find(B=>B.id===g);return L?{ok:!0,report:L}:{ok:!1,error:"child not found"}}async function Uk(){let g=t.sessionsWorking?.(e.cwd),S=t.listSessionFiles(e.cwd).map(({sessionId:C,file:L,mtime:B})=>({sessionId:C,mtime:B,preview:t.readPreview(L),working:g?.has(C)})),w=u().map(C=>({sessionId:C.sessionId,mtime:C.rec.startedAt,preview:C.rec.prompt??"",pending:!0}));return ii([...S,...w],C=>C.mtime)}let Ep=new Map;function Ap(g,S){let w=Ep.get(g);if(w&&w.mtime===S)return w.turns;let C=[],L="";try{L=Of(g,"utf8")}catch{return[]}for(let B of L.split(`
2068
+ `)){if(!B.trim())continue;let j=t.parseEntry(B);if(!j)continue;let z=t.searchText(j);z&&C.push({text:z,lower:z.toLowerCase()})}return Ep.set(g,{mtime:S,turns:C}),C}async function qk(g){let S=g.toLowerCase(),w=[],C=0,L=t.sessionsWorking?.(e.cwd);for(let{sessionId:B,file:j,mtime:z}of t.listSessionFiles(e.cwd).sort((Q,dt)=>dt.mtime-Q.mtime)){let Q=ri(Ap(j,z),S),dt=(t.listChildren?.(e.cwd,B)??[]).map(ue=>({c:ue,hit:ri(Ap(ue.file,ue.mtime),S)})).filter(ue=>ue.hit.hitCount);if(!(!Q.hitCount&&!dt.length)){for(let{c:ue,hit:zk}of ii(dt,Yk=>Yk.c.mtime))w.push({sessionId:B,mtime:ue.mtime,preview:Et(ue),...zk,child:{id:ue.id,kind:ue.kind,depth:ue.depth}});if(w.push({sessionId:B,mtime:z,preview:t.readPreview(j),working:L?.has(B),...Q}),++C>=_I)break}}return w}async function Jk(g){let S=e,w=t.listSessionFiles(S.cwd).find(C=>C.sessionId===g);if(!w){let C=u().find(L=>L.sessionId===g)?.rec;return C?((i!==C||S.sessionId!==C.id)&&(i=C,xi(),n=void 0,M(void 0,C.id),S.everAttached=!0,f()),{ok:!0}):{ok:!1,error:"session not found"}}return w.file===S.file?{ok:!0}:(K(w),p(),f(),{ok:!0})}async function Wk(){if(!t.listChildren||!e.sessionId)return[];let g=R();return t.listChildren(e.cwd,e.sessionId).map(S=>({...S,state:si(S,g)}))}async function Kk(g){let S=e;if(!t.listChildren)return{ok:!1,error:"this harness has no child transcripts"};let w=t.listChildren(S.cwd,S.sessionId).find(C=>C.id===g);return w?(S.thread="child",S.child=w,M(w.file,S.sessionId),ne(w.file),{ok:!0}):{ok:!1,error:"child not found"}}async function Hk(){let g=n;return!xi()||!g?{ok:!0}:(M(g,e.sessionId),ne(g),{ok:!0})}function xi(){let g=e;return g.thread==="main"?!1:(g.thread="main",g.child=void 0,!0)}return T(e.cwd),P(e.cwd),O(),{info:Ce,poll:W,logInlineStatus:x,listSessions:Uk,searchSessions:qk,attach:Jk,listChildren:Wk,openChild:Kk,closeChild:Hk,composerSend:Ke,composerStop:Oe,composerNew:Jr,composerFiles:sn,composerUiRespond:Y,composerRpc:ce,composerPaste:Ml,composerPasteRead:Dl,summarizeTurn:jk,childStatus:Fk,shutdownComposer:Pt}}var TI,CI,Lv,OI,_I,il=v(()=>{"use strict";Gt();Gw();$r();gf();sv();lv();bf();sl();wf();Nr();TI=".typebulb",CI=`${TI}/locks`,Lv=5e3,OI=6e4;_I=50});import{existsSync as If,mkdirSync as RI,readFileSync as Mv,writeFileSync as II}from"fs";import{join as Ln,isAbsolute as $I}from"path";async function Nf(t,e){let n=$I(t)?t:Ln(X,t);return If(n)?(gd(n,e),{ok:!0}):{ok:!1,error:"file not found"}}async function Lf(t){let e=X,n=md(t),r=Ln(e,"typebulbs");RI(r,{recursive:!0});let s=dd(n),i=`${s}.bulb.md`;for(let c=2;If(Ln(r,i))&&Mv(Ln(r,i),"utf8")!==n;c++)i=`${s}-${c}.bulb.md`;let o=Ln(r,i);If(o)||II(o,n);let a=Ln("typebulbs",i),l=await bn(a,{cwd:e,open:!1});return{ok:!0,file:a,pid:l.pid,url:l.url}}async function Mf(){return G(X)}async function Df(t){let e=(await G()).find(n=>n.pid===t);return e?{ok:!0,outcome:await gt(e)}:(await or(t),{ok:!0})}async function Bf(){let t=await hn(X);return sa(X).filter(e=>!e.serverOnly).map(e=>({...e,trusted:Sn(e.path),lastRunAt:t(e.path)}))}async function jf(t){let e=t.toLowerCase(),n=[];for(let r of sa(X).filter(s=>!s.serverOnly).sort((s,i)=>i.mtime-s.mtime)){let s="";try{s=Mv(r.path,"utf8")}catch{continue}let i=[];for(let l of s.split(`
2069
+ `)){let c=l.replace(/\s+/g," ").trim();c&&i.push({text:c,lower:c.toLowerCase()})}let{hitCount:o,snippet:a}=ri(i,e);o&&n.push({path:r.path,hitCount:o,snippet:a})}return n}async function Ff(t,e){let n=X;e!=null&&fr(t,e);let r=await bn(t,{cwd:n,open:!1,trust:e});return{ok:!0,file:r.file,pid:r.pid,url:r.url,trust:!!r.trust}}async function Uf(t){return{cap:await pd(t)}}async function qf(t,e){return fr(t,e),{ok:!0}}async function Jf(t,e){return Xe(t,e)}async function Wf(){return li&&Date.now()-li.fetchedAt<=LI?li.samples:(Pf??=MI().finally(()=>{Pf=null}),Pf)}async function MI(){try{let t=await fetch(`${NI}/api/scripts/u/samples?stubs`,{signal:AbortSignal.timeout(Bv)});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:Hl(i.config)}));return li={samples:s,fetchedAt:Date.now()},s}catch{return li?.samples??[]}}async function Kf(t){return $f.test(t)?Fv(Dv,"samples",t,!0):{ok:!1,error:"bad slug"}}async function zf(){let t=Hf();if(!t)return{bulbs:[]};let e=`${ol()}
2070
+ ${t}`;return Xt?.key===e&&Date.now()-Xt.fetchedAt<=DI?{user:Xt.user,bulbs:Xt.bulbs}:(_f??=BI(e,t).finally(()=>{_f=null}),_f)}async function Rf(t,e,n){let r=await fetch(`${t}${e}`,{headers:n,signal:AbortSignal.timeout(Bv)});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 BI(t,e){let n={Authorization:`Bearer ${e}`};try{let r=ol(),s;try{s=await Rf(r,"/api/me",n)}catch{let a=new URL(r);r=`${a.protocol}//api.${a.host}`,s=await Rf(r,"/api/me",n)}let o=(await Rf(r,"/api/scripts/list",n)).filter(a=>a.userSlug===s.slug&&!a.isTemplate).map(a=>({slug:a.slug,name:a.name,description:Hl(a.config)}));return Xt={key:t,user:s.slug,bulbs:o,fetchedAt:Date.now()},{user:s.slug,bulbs:o}}catch{return Xt?.key===t?{user:Xt.user,bulbs:Xt.bulbs}:{bulbs:[]}}}async function Yf(t,e,n=!1){return!$f.test(e)||!$f.test(t)?{ok:!1,error:"bad slug"}:Fv(ol(),t,e,n)}async function Fv(t,e,n,r){let s=Ma(e,n);try{let i=await ja({origin:t,userSlug:e,slug:n,dest:Ln(X,s)},{force:r,token:Hf(),timeoutMs:jv});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 Vf(t,e=!1){let n=Hf();if(!n)return{ok:!1,error:"no TYPEBULB_TOKEN in .env"};try{let r=Ba(t,X,ol()),s=await Ua(r,{token:n,force:e,timeoutMs:jv});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 NI,Dv,LI,Bv,jv,li,Pf,$f,DI,Xt,_f,ol,Hf,al=v(()=>{"use strict";_r();Gt();gf();ee();NI="https://api.typebulb.com",Dv="https://typebulb.com",LI=3600*1e3,Bv=5e3,jv=15e3,li=null,Pf=null;$f=/^[a-z0-9][a-z0-9-]*$/,DI=300*1e3,Xt=null,_f=null,ol=()=>ma("TYPEBULB_ORIGIN",X)||Dv,Hf=()=>ma("TYPEBULB_TOKEN",X)});import{readFileSync as Qf,writeFileSync as qv,mkdirSync as jI,appendFileSync as Jv,rmSync as Uv}from"fs";import{join as ul,dirname as FI}from"path";import{createServer as UI}from"http";function Qt(t){try{return JSON.parse(Qf(t,"utf8"))}catch{return null}}function cl(t,e){jI(FI(t),{recursive:!0}),qv(t,JSON.stringify(e,null,2)+`
2071
+ `)}function Kv(t,e,n){let r=ul(t,".gitignore"),s="";try{s=Qf(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(`
2072
2072
  `)?`
2073
- `:"";try{Mv(r,a+n+`
2073
+ `:"";try{Jv(r,a+n+`
2074
2074
  `+o.join(`
2075
2075
  `)+`
2076
- `)}catch(l){console.error("[switcher] .gitignore update failed",V(l))}}function FI(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?di="live":s>jI&&(di="uncached")}function Fv(t,e){let n={"content-type":"application/json",authorization:`Bearer ${e}`,"anthropic-version":t.headers["anthropic-version"]||"2023-06-01",...kd},r=t.headers["anthropic-beta"];return typeof r=="string"&&(n["anthropic-beta"]=r),n}function UI(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 Uv(t){let e;try{e=JSON.parse(t)}catch{return t}ui=typeof e?.model=="string"?e.model:null,ct&&(e.model=ct),Bn&&(e.provider=jv(Bn));let n=/haiku/i.test(ui||"");return fi!=null&&!n&&(e.reasoning={effort:Yf[fi]}),delete e.thinking,e.output_config&&delete e.output_config.effort,UI(e),JSON.stringify(e)}function qI(){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}
2076
+ `)}catch(l){console.error("[switcher] .gitignore update failed",V(l))}}function HI(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?di="live":s>KI&&(di="uncached")}function zv(t,e){let n={"content-type":"application/json",authorization:`Bearer ${e}`,"anthropic-version":t.headers["anthropic-version"]||"2023-06-01",...xd},r=t.headers["anthropic-beta"];return typeof r=="string"&&(n["anthropic-beta"]=r),n}function zI(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 Yv(t){let e;try{e=JSON.parse(t)}catch{return t}ui=typeof e?.model=="string"?e.model:null,ct&&(e.model=ct),Dn&&(e.provider=Hv(Dn));let n=/haiku/i.test(ui||"");return fi!=null&&!n&&(e.reasoning={effort:Gf[fi]}),delete e.thinking,e.output_config&&delete e.output_config.effort,zI(e),JSON.stringify(e)}function YI(){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}
2077
2077
  data: ${JSON.stringify(a)}
2078
2078
 
2079
2079
  `}case"content_block_delta":case"content_block_stop":{let l=n.get(a.index);return l==null?null:(a.index=l,`event: ${a.type}
@@ -2081,11 +2081,11 @@ data: ${JSON.stringify(a)}
2081
2081
 
2082
2082
  `)}default:return i}};return i=>{t+=i;let o="",a;for(;(a=t.indexOf(`
2083
2083
 
2084
- `))!==-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 JI(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 ci(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 WI(t,e,n){if(!ct){ci(e,400,"invalid_request_error",BI);return}let r=process.env.OPENROUTER_API_KEY;if(!r){ci(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(Xf,{method:"POST",headers:Fv(t,r),body:Uv(n),signal:s.signal})}catch(d){ci(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,u=a?qI():null;try{for(;;){let{done:d,value:f}=await l.read();if(d)break;if(f)if(u){let p=c.decode(f,{stream:!0});FI(p);let h=u(p);h&&e.write(h)}else e.write(Buffer.from(f))}}catch{}finally{e.writableEnded||e.end()}}async function KI(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(!ct||!r)return s();try{let i=await fetch(`${Xf}/count_tokens`,{method:"POST",headers:Fv(t,r),body:Uv(n)});if(!i.ok)return s();let o=await i.text();e.writeHead(200,{"content-type":"application/json"}),e.end(o)}catch{s()}}function HI(t,e){let n=t.url||"/";if(t.method==="HEAD"){e.writeHead(200),e.end();return}if(t.method!=="POST"){ci(e,404,"not_found_error",n);return}JI(t).then(r=>{if(n.includes("count_tokens"))return KI(t,e,r);if(n.includes("/v1/messages"))return WI(t,e,r);ci(e,404,"not_found_error",n)})}function zI(){return Br&&Dn?Promise.resolve(Dn):new Promise((t,e)=>{let n=LI(HI);n.on("error",e),n.listen(0,"127.0.0.1",()=>{Br=n,Dn=n.address().port,console.log(`[switcher] wire proxy listening on ${ll(Dn)}`),t(Dn)})})}function YI(){try{Br?.close()}catch{}Br=null,Dn=null}function VI(t,e){let n=dl(t),r=Qt(n),s=r||{};if((!s.env||typeof s.env!="object")&&(s.env={}),s.env.ANTHROPIC_BASE_URL===ll(e)&&s.env.ANTHROPIC_AUTH_TOKEN)return;let i=fl(t);if(!Qt(i)){let a={};for(let l of Dv)a[l]=l in s.env?s.env[l]:null;cl(i,{managedBy:"agent-switcher",fileExisted:r!==null,snapshot:a,active:null})}s.env.ANTHROPIC_BASE_URL=ll(e),s.env.ANTHROPIC_AUTH_TOKEN=DI,cl(n,s),Bv(t,[".claude/settings.local.json",".claude/.cc-switcher.json"],"# agent switcher (local Claude Code model override)")}function GI(t,e,n){let r=fl(t),s=Qt(r)||{managedBy:"agent-switcher",fileExisted:!1,snapshot:{}};s.active={model:e,provider:n},cl(r,s)}function qv(t){let e=dl(t),n=fl(t),r=Qt(n),s=Qt(e);if(s?.env){let i=r?.snapshot||{};for(let o of Dv){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{Nv(e,{force:!0})}catch{}else cl(e,s)}try{Nv(n,{force:!0})}catch{}}async function XI(){let t=!!process.env.OPENROUTER_API_KEY,e=[];try{e=(await yt()).filter(r=>r.provider==="openrouter"&&!Qf(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:wd()??void 0;return{hasKey:t,models:e,error:n}}async function QI(){if(Br&&ct)return{active:!0,managed:!0,model:ct,port:Dn,provider:Bn,routedModel:ui,caching:di,reasoning:fi,externalBaseUrl:null};let t=Qt(dl(X))?.env||{};return{active:!1,managed:!1,model:null,port:null,provider:null,routedModel:null,caching:"unknown",reasoning:fi,externalBaseUrl:t.ANTHROPIC_BASE_URL||null}}async function Jv(t,e){let n=await zI();return ct=t,Bn=e,VI(X,n),n}async function ZI({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(Qf(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 Jv(t,Zf[t]??null),ui=null,di="unknown",GI(X,t,Bn)}catch(e){return{ok:!1,error:`failed to start the wire proxy: ${V(e)}`}}return{ok:!0}}async function e$({level:t}){return t!=null&&(!Number.isInteger(t)||t<0||t>=Yf.length)?{ok:!1,error:`reasoning level must be 0\u2013${Yf.length-1} or null`}:(fi=t,{ok:!0,level:t})}async function t$(){return qv(X),ct=null,Bn=null,ui=null,di="unknown",{ok:!0}}async function n$({key:t}){let e=(t||"").trim();if(!e)return{ok:!1,error:"empty key"};let n=X,r=ul(n,".env"),s="";try{s=Gf(r,"utf8")}catch{}try{if(/^\s*OPENROUTER_API_KEY\s*=/m.test(s))Lv(r,s.replace(/^\s*OPENROUTER_API_KEY\s*=.*$/m,`OPENROUTER_API_KEY=${e}`));else{let i=s&&!s.endsWith(`
2084
+ `))!==-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 VI(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 ci(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 GI(t,e,n){if(!ct){ci(e,400,"invalid_request_error",WI);return}let r=process.env.OPENROUTER_API_KEY;if(!r){ci(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(Zf,{method:"POST",headers:zv(t,r),body:Yv(n),signal:s.signal})}catch(d){ci(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,u=a?YI():null;try{for(;;){let{done:d,value:f}=await l.read();if(d)break;if(f)if(u){let p=c.decode(f,{stream:!0});HI(p);let m=u(p);m&&e.write(m)}else e.write(Buffer.from(f))}}catch{}finally{e.writableEnded||e.end()}}async function XI(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(!ct||!r)return s();try{let i=await fetch(`${Zf}/count_tokens`,{method:"POST",headers:zv(t,r),body:Yv(n)});if(!i.ok)return s();let o=await i.text();e.writeHead(200,{"content-type":"application/json"}),e.end(o)}catch{s()}}function QI(t,e){let n=t.url||"/";if(t.method==="HEAD"){e.writeHead(200),e.end();return}if(t.method!=="POST"){ci(e,404,"not_found_error",n);return}VI(t).then(r=>{if(n.includes("count_tokens"))return XI(t,e,r);if(n.includes("/v1/messages"))return GI(t,e,r);ci(e,404,"not_found_error",n)})}function ZI(){return Br&&Mn?Promise.resolve(Mn):new Promise((t,e)=>{let n=UI(QI);n.on("error",e),n.listen(0,"127.0.0.1",()=>{Br=n,Mn=n.address().port,console.log(`[switcher] wire proxy listening on ${ll(Mn)}`),t(Mn)})})}function e$(){try{Br?.close()}catch{}Br=null,Mn=null}function t$(t,e){let n=dl(t),r=Qt(n),s=r||{};if((!s.env||typeof s.env!="object")&&(s.env={}),s.env.ANTHROPIC_BASE_URL===ll(e)&&s.env.ANTHROPIC_AUTH_TOKEN)return;let i=fl(t);if(!Qt(i)){let a={};for(let l of Wv)a[l]=l in s.env?s.env[l]:null;cl(i,{managedBy:"agent-switcher",fileExisted:r!==null,snapshot:a,active:null})}s.env.ANTHROPIC_BASE_URL=ll(e),s.env.ANTHROPIC_AUTH_TOKEN=JI,cl(n,s),Kv(t,[".claude/settings.local.json",".claude/.cc-switcher.json"],"# agent switcher (local Claude Code model override)")}function n$(t,e,n){let r=fl(t),s=Qt(r)||{managedBy:"agent-switcher",fileExisted:!1,snapshot:{}};s.active={model:e,provider:n},cl(r,s)}function Vv(t){let e=dl(t),n=fl(t),r=Qt(n),s=Qt(e);if(s?.env){let i=r?.snapshot||{};for(let o of Wv){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{Uv(e,{force:!0})}catch{}else cl(e,s)}try{Uv(n,{force:!0})}catch{}}async function r$(){let t=!!process.env.OPENROUTER_API_KEY,e=[];try{e=(await yt()).filter(r=>r.provider==="openrouter"&&!ep(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:vd()??void 0;return{hasKey:t,models:e,error:n}}async function s$(){if(Br&&ct)return{active:!0,managed:!0,model:ct,port:Mn,provider:Dn,routedModel:ui,caching:di,reasoning:fi,externalBaseUrl:null};let t=Qt(dl(X))?.env||{};return{active:!1,managed:!1,model:null,port:null,provider:null,routedModel:null,caching:"unknown",reasoning:fi,externalBaseUrl:t.ANTHROPIC_BASE_URL||null}}async function Gv(t,e){let n=await ZI();return ct=t,Dn=e,t$(X,n),n}async function i$({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(ep(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 Gv(t,tp[t]??null),ui=null,di="unknown",n$(X,t,Dn)}catch(e){return{ok:!1,error:`failed to start the wire proxy: ${V(e)}`}}return{ok:!0}}async function o$({level:t}){return t!=null&&(!Number.isInteger(t)||t<0||t>=Gf.length)?{ok:!1,error:`reasoning level must be 0\u2013${Gf.length-1} or null`}:(fi=t,{ok:!0,level:t})}async function a$(){return Vv(X),ct=null,Dn=null,ui=null,di="unknown",{ok:!0}}async function l$({key:t}){let e=(t||"").trim();if(!e)return{ok:!1,error:"empty key"};let n=X,r=ul(n,".env"),s="";try{s=Qf(r,"utf8")}catch{}try{if(/^\s*OPENROUTER_API_KEY\s*=/m.test(s))qv(r,s.replace(/^\s*OPENROUTER_API_KEY\s*=.*$/m,`OPENROUTER_API_KEY=${e}`));else{let i=s&&!s.endsWith(`
2085
2085
  `)?`
2086
- `:"";Mv(r,i+`OPENROUTER_API_KEY=${e}
2087
- `)}}catch(i){return{ok:!1,error:V(i)}}return process.env.OPENROUTER_API_KEY=e,Bv(n,[".env"],"# secrets"),{ok:!0}}function r$(){if(!(!Br&&!ct)){try{qv(X)}catch{}YI()}}function s$(t,e){return Wv.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 i$(t){if(Wv.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 o$(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=Vf(e?.cache_read_input_tokens)||Vf(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 a$({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(Qf(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 u=JSON.stringify(a?{...i,provider:jv(a)}:i),d=await fetch(Xf,{method:"POST",signal:l.signal,headers:s,body:u}),f=await d.json().catch(()=>({}));return{r:d,j:f}}finally{clearTimeout(c)}};try{let{r:a,j:l}=await o();if(!a.ok){let v=l?.error?.message||l?.message||JSON.stringify(l).slice(0,300);return{ok:!0,callable:!1,status:a.status,ms:Date.now()-n,error:s$(a.status,v),restriction:i$(v)}}let c=typeof l?.provider=="string"?l.provider:void 0,u=l?.content?.find?.(v=>v.type==="text")?.text??l?.content?.[0]?.text??"ok",d=Vf(l?.usage?.cache_creation_input_tokens),{r:f,j:p}=await o(c),{works:h,read:m,note:g}=o$(f.ok,p?.usage,c);return h===!0&&c&&(Zf[t]=c,ct===t&&(Bn=c)),{ok:!0,callable:!0,status:a.status,ms:Date.now()-n,provider:c,sample:String(u).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 MI,Xf,DI,BI,Dv,jI,Yf,dl,fl,ll,Qf,Br,Dn,ct,Bn,ui,di,fi,Zf,Vf,jv,Wv,Kv=S(()=>{"use strict";Rr();Gt();qt();MI="https://openrouter.ai/api",Xf=`${MI}/v1/messages`,DI="typebulb-proxy-managed",BI="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.",Dv=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"],jI=5e3,Yf=["low","medium","high"],dl=t=>ul(t,".claude","settings.local.json"),fl=t=>ul(t,".claude",".cc-switcher.json"),ll=t=>`http://127.0.0.1:${t}`;Qf=t=>/^anthropic\//i.test(t)||/claude/i.test(t),Br=null,Dn=null,ct=null,Bn=null,ui=null,di="unknown",fi=1,Zf={},Vf=t=>typeof t=="number"?t:0,jv=t=>({order:[t],allow_fallbacks:!1});Wv=/data policy|no endpoints|no allowed providers|privacy|requires.*(training|logging|data)/i;(async function(){try{let e=Qt(fl(X)),n=e?.active?.model;if(!n)return;let s=(Qt(dl(X))?.env||{}).ANTHROPIC_BASE_URL||"";if(!/127\.0\.0\.1|localhost/.test(s))return;let i=await Jv(n,e.active.provider??Zf[n]??null);console.log(`[switcher] re-adopted override after restart: ${n} via ${ll(i)}`)}catch(e){console.error("[switcher] boot reconcile failed",V(e))}})()});var zv={};Ai(zv,{agentMessage:()=>Fo,attach:()=>h$,blockToMarkdown:()=>jo,breakout:()=>$f,capText:()=>Pe,childStatus:()=>v$,cleanUserText:()=>Ut,clearSwitchModel:()=>t$,closeChild:()=>y$,composerPasteRead:()=>b$,displayName:()=>l$,downloadSample:()=>Jf,firstLineDigest:()=>De,git:()=>we,gitChangedFiles:()=>pf,gitDiff:()=>hf,info:()=>c$,isHiddenTurn:()=>Ps,launchBulb:()=>Bf,listBreakouts:()=>Nf,listBulbFiles:()=>Mf,listChildren:()=>m$,listMyBulbs:()=>Kf,listSamples:()=>qf,listSessions:()=>f$,listSwitchModels:()=>XI,logInlineStatus:()=>d$,openChild:()=>g$,openFile:()=>If,poll:()=>u$,predictTrustOf:()=>jf,probeModel:()=>a$,pullRemoteBulb:()=>Hf,pushLocalBulb:()=>zf,readBulbLog:()=>Uf,repoRoot:()=>Rn,saveOpenRouterKey:()=>n$,searchBulbs:()=>Df,searchSessions:()=>p$,setBulbTrust:()=>Ff,setReasoning:()=>e$,setSwitchModel:()=>ZI,shutdownSwitcher:()=>r$,stopBreakout:()=>Lf,summarizeTurn:()=>w$,switchState:()=>QI,toolResultDigest:()=>qu});var Hv,l$,c$,u$,d$,f$,p$,h$,m$,g$,y$,b$,w$,v$,Yv=S(()=>{"use strict";il();Uo();al();Nr();Kv();Uo();Cs();Hv=new nr,l$=Hv.displayName,{info:c$,poll:u$,logInlineStatus:d$,listSessions:f$,searchSessions:p$,attach:h$,listChildren:m$,openChild:g$,closeChild:y$,composerPasteRead:b$,summarizeTurn:w$,childStatus:v$}=Dr(Hv)});var Gv={};Ai(Gv,{attach:()=>C$,breakout:()=>$f,childStatus:()=>$$,closeChild:()=>_$,composerPasteRead:()=>R$,displayName:()=>S$,downloadSample:()=>Jf,git:()=>we,gitChangedFiles:()=>pf,gitDiff:()=>hf,info:()=>k$,launchBulb:()=>Bf,listBreakouts:()=>Nf,listBulbFiles:()=>Mf,listChildren:()=>O$,listMyBulbs:()=>Kf,listSamples:()=>qf,listSessions:()=>A$,logInlineStatus:()=>E$,openChild:()=>P$,openFile:()=>If,poll:()=>x$,predictTrustOf:()=>jf,pullRemoteBulb:()=>Hf,pushLocalBulb:()=>zf,readBulbLog:()=>Uf,repoRoot:()=>Rn,searchBulbs:()=>Df,searchSessions:()=>T$,setBulbTrust:()=>Ff,stopBreakout:()=>Lf,summarizeTurn:()=>I$});var Vv,S$,k$,x$,E$,A$,T$,C$,O$,P$,_$,R$,I$,$$,Xv=S(()=>{"use strict";il();Vu();al();Nr();Vv=new sr,S$=Vv.displayName,{info:k$,poll:x$,logInlineStatus:E$,listSessions:A$,searchSessions:T$,attach:C$,listChildren:O$,openChild:P$,closeChild:_$,composerPasteRead:R$,summarizeTurn:I$,childStatus:$$}=Dr(Vv)});import{readFileSync as N$,writeFileSync as L$,mkdirSync as M$}from"fs";import{homedir as D$}from"os";import*as pl from"path";async function eS(){try{let t=await fetch(new URL("/api/tags",Zv()).toString(),{signal:AbortSignal.timeout(B$)});return t.ok?((await t.json()).models??[]).map(n=>n.name).filter(n=>!!n):[]}catch{return[]}}function tS(t){let e;try{e=N$(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 j$(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 nS(){let{json:t,unreadable:e}=tS(Qv());return e?{installed:[],configured:null}:{installed:await eS(),configured:j$(t)}}async function rS(){let t=await eS();return t.length?F$(Qv(),t,Zv()):{ok:!1,error:"Ollama is not running (or has no models installed)"}}function F$(t,e,n){let{json:r,unreadable:s}=tS(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{M$(pl.dirname(t),{recursive:!0}),L$(t,JSON.stringify(i,null,2)+`
2088
- `)}catch(o){return{ok:!1,error:`could not write ${t}: ${V(o)}`}}return{ok:!0,count:e.length}}var B$,Qv,Zv,sS=S(()=>{"use strict";Gt();Rr();B$=1500,Qv=()=>pl.join(D$(),".pi","agent","models.json"),Zv=()=>mr(process.env.OLLAMA_HOST??"http://localhost:11434")});var oS={};Ai(oS,{attach:()=>z$,breakout:()=>$f,closeChild:()=>G$,composerFiles:()=>eN,composerNew:()=>Z$,composerPaste:()=>rN,composerPasteRead:()=>sN,composerRpc:()=>nN,composerSend:()=>X$,composerStop:()=>Q$,composerUiRespond:()=>tN,displayName:()=>U$,downloadSample:()=>Jf,git:()=>we,gitChangedFiles:()=>pf,gitDiff:()=>hf,info:()=>q$,launchBulb:()=>Bf,listBreakouts:()=>Nf,listBulbFiles:()=>Mf,listChildren:()=>Y$,listMyBulbs:()=>Kf,listSamples:()=>qf,listSessions:()=>K$,logInlineStatus:()=>W$,ollamaOffer:()=>nS,ollamaSync:()=>rS,openChild:()=>V$,openFile:()=>If,poll:()=>J$,predictTrustOf:()=>jf,pullRemoteBulb:()=>Hf,pushLocalBulb:()=>zf,readBulbLog:()=>Uf,repoRoot:()=>Rn,searchBulbs:()=>Df,searchSessions:()=>H$,setBulbTrust:()=>Ff,shutdownComposer:()=>oN,stopBreakout:()=>Lf,summarizeTurn:()=>iN});var iS,U$,q$,J$,W$,K$,H$,z$,Y$,V$,G$,X$,Q$,Z$,eN,tN,nN,rN,sN,iN,oN,aS=S(()=>{"use strict";il();df();al();Nr();sS();iS=new $r,U$=iS.displayName,{info:q$,poll:J$,logInlineStatus:W$,listSessions:K$,searchSessions:H$,attach:z$,listChildren:Y$,openChild:V$,closeChild:G$,composerSend:X$,composerStop:Q$,composerNew:Z$,composerFiles:eN,composerUiRespond:tN,composerRpc:nN,composerPaste:rN,composerPasteRead:sN,summarizeTurn:iN,shutdownComposer:oN}=Dr(iS)});import*as Rk from"fs/promises";import*as Ct from"path";Ti();Z();function Du(t){if(!He.includes(t))throw new Error(`Unknown block kind '${t}' (one of: ${He.join(", ")})`);return t}function uy(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=Du(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}Uo();Vu();df();var hl={claude:{adapter:()=>new nr,server:()=>Promise.resolve().then(()=>(Yv(),zv))},codex:{adapter:()=>new sr,server:()=>Promise.resolve().then(()=>(Xv(),Gv))},pi:{adapter:()=>new $r,server:()=>Promise.resolve().then(()=>(aS(),oS))}};function lS(t){return t in hl}function jr(){return Object.keys(hl)}function Zt(){return Object.fromEntries(Object.entries(hl).map(([t,e])=>[t,e.adapter]))}function cS(t){return hl[t].server()}var pi=Zt();function uS(){for(let t of Object.values(pi))try{t().ensureHarnessSupport()}catch{}}function Ne(){for(let t of Object.keys(pi))try{if(pi[t]().detectsSelf())return t}catch{}}function dS(t){let e=jr(),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 np=5e3;function tp(t){try{return t()}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exit(1)}}function fS(t){let n={subcommand:"run",file:"",watch:!0,open:process.env.TERM_PROGRAM==="vscode"||Ne()!==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==="--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=np;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=tp(()=>Pp(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=tp(()=>Du(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=tp(()=>uy(i.slice(1)))),n}function pS(){console.log(`
2086
+ `:"";Jv(r,i+`OPENROUTER_API_KEY=${e}
2087
+ `)}}catch(i){return{ok:!1,error:V(i)}}return process.env.OPENROUTER_API_KEY=e,Kv(n,[".env"],"# secrets"),{ok:!0}}function c$(){if(!(!Br&&!ct)){try{Vv(X)}catch{}e$()}}function u$(t,e){return Xv.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 d$(t){if(Xv.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 f$(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=Xf(e?.cache_read_input_tokens)||Xf(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 p$({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(ep(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 u=JSON.stringify(a?{...i,provider:Hv(a)}:i),d=await fetch(Zf,{method:"POST",signal:l.signal,headers:s,body:u}),f=await d.json().catch(()=>({}));return{r:d,j:f}}finally{clearTimeout(c)}};try{let{r:a,j:l}=await o();if(!a.ok){let k=l?.error?.message||l?.message||JSON.stringify(l).slice(0,300);return{ok:!0,callable:!1,status:a.status,ms:Date.now()-n,error:u$(a.status,k),restriction:d$(k)}}let c=typeof l?.provider=="string"?l.provider:void 0,u=l?.content?.find?.(k=>k.type==="text")?.text??l?.content?.[0]?.text??"ok",d=Xf(l?.usage?.cache_creation_input_tokens),{r:f,j:p}=await o(c),{works:m,read:h,note:y}=f$(f.ok,p?.usage,c);return m===!0&&c&&(tp[t]=c,ct===t&&(Dn=c)),{ok:!0,callable:!0,status:a.status,ms:Date.now()-n,provider:c,sample:String(u).trim().slice(0,60),cache:{works:m,created:d,read:h,note:y}}}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 qI,Zf,JI,WI,Wv,KI,Gf,dl,fl,ll,ep,Br,Mn,ct,Dn,ui,di,fi,tp,Xf,Hv,Xv,Qv=v(()=>{"use strict";_r();Gt();qt();qI="https://openrouter.ai/api",Zf=`${qI}/v1/messages`,JI="typebulb-proxy-managed",WI="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.",Wv=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"],KI=5e3,Gf=["low","medium","high"],dl=t=>ul(t,".claude","settings.local.json"),fl=t=>ul(t,".claude",".cc-switcher.json"),ll=t=>`http://127.0.0.1:${t}`;ep=t=>/^anthropic\//i.test(t)||/claude/i.test(t),Br=null,Mn=null,ct=null,Dn=null,ui=null,di="unknown",fi=1,tp={},Xf=t=>typeof t=="number"?t:0,Hv=t=>({order:[t],allow_fallbacks:!1});Xv=/data policy|no endpoints|no allowed providers|privacy|requires.*(training|logging|data)/i;(async function(){try{let e=Qt(fl(X)),n=e?.active?.model;if(!n)return;let s=(Qt(dl(X))?.env||{}).ANTHROPIC_BASE_URL||"";if(!/127\.0\.0\.1|localhost/.test(s))return;let i=await Gv(n,e.active.provider??tp[n]??null);console.log(`[switcher] re-adopted override after restart: ${n} via ${ll(i)}`)}catch(e){console.error("[switcher] boot reconcile failed",V(e))}})()});var eS={};Ai(eS,{agentMessage:()=>Fo,attach:()=>v$,blockToMarkdown:()=>jo,breakout:()=>Lf,capText:()=>Pe,childStatus:()=>T$,cleanUserText:()=>Ut,clearSwitchModel:()=>a$,closeChild:()=>x$,composerPasteRead:()=>E$,displayName:()=>h$,downloadSample:()=>Kf,firstLineDigest:()=>De,git:()=>we,gitChangedFiles:()=>hf,gitDiff:()=>mf,info:()=>m$,isHiddenTurn:()=>Ps,launchBulb:()=>Ff,listBreakouts:()=>Mf,listBulbFiles:()=>Bf,listChildren:()=>S$,listMyBulbs:()=>zf,listSamples:()=>Wf,listSessions:()=>b$,listSwitchModels:()=>r$,logInlineStatus:()=>y$,openChild:()=>k$,openFile:()=>Nf,poll:()=>g$,predictTrustOf:()=>Uf,probeModel:()=>p$,pullRemoteBulb:()=>Yf,pushLocalBulb:()=>Vf,readBulbLog:()=>Jf,repoRoot:()=>Rn,saveOpenRouterKey:()=>l$,searchBulbs:()=>jf,searchSessions:()=>w$,setBulbTrust:()=>qf,setReasoning:()=>o$,setSwitchModel:()=>i$,shutdownSwitcher:()=>c$,stopBreakout:()=>Df,summarizeTurn:()=>A$,switchState:()=>s$,toolResultDigest:()=>qu});var Zv,h$,m$,g$,y$,b$,w$,v$,S$,k$,x$,E$,A$,T$,tS=v(()=>{"use strict";il();Uo();al();$r();Qv();Uo();Cs();Zv=new tr,h$=Zv.displayName,{info:m$,poll:g$,logInlineStatus:y$,listSessions:b$,searchSessions:w$,attach:v$,listChildren:S$,openChild:k$,closeChild:x$,composerPasteRead:E$,summarizeTurn:A$,childStatus:T$}=Dr(Zv)});var rS={};Ai(rS,{attach:()=>$$,breakout:()=>Lf,childStatus:()=>j$,closeChild:()=>M$,composerPasteRead:()=>D$,displayName:()=>C$,downloadSample:()=>Kf,git:()=>we,gitChangedFiles:()=>hf,gitDiff:()=>mf,info:()=>O$,launchBulb:()=>Ff,listBreakouts:()=>Mf,listBulbFiles:()=>Bf,listChildren:()=>N$,listMyBulbs:()=>zf,listSamples:()=>Wf,listSessions:()=>R$,logInlineStatus:()=>_$,openChild:()=>L$,openFile:()=>Nf,poll:()=>P$,predictTrustOf:()=>Uf,pullRemoteBulb:()=>Yf,pushLocalBulb:()=>Vf,readBulbLog:()=>Jf,repoRoot:()=>Rn,searchBulbs:()=>jf,searchSessions:()=>I$,setBulbTrust:()=>qf,stopBreakout:()=>Df,summarizeTurn:()=>B$});var nS,C$,O$,P$,_$,R$,I$,$$,N$,L$,M$,D$,B$,j$,sS=v(()=>{"use strict";il();Gu();al();$r();nS=new rr,C$=nS.displayName,{info:O$,poll:P$,logInlineStatus:_$,listSessions:R$,searchSessions:I$,attach:$$,listChildren:N$,openChild:L$,closeChild:M$,composerPasteRead:D$,summarizeTurn:B$,childStatus:j$}=Dr(nS)});import{readFileSync as F$,writeFileSync as U$,mkdirSync as q$}from"fs";import{homedir as J$}from"os";import*as pl from"path";async function aS(){try{let t=await fetch(new URL("/api/tags",oS()).toString(),{signal:AbortSignal.timeout(W$)});return t.ok?((await t.json()).models??[]).map(n=>n.name).filter(n=>!!n):[]}catch{return[]}}function lS(t){let e;try{e=F$(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&&!np(r)}}}catch{}return{json:void 0,unreadable:!0}}function np(t){let e=t?.providers;return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function K$(t){let e=np(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 cS(){let{json:t,unreadable:e}=lS(iS());return e?{installed:[],configured:null}:{installed:await aS(),configured:K$(t)}}async function uS(){let t=await aS();return t.length?H$(iS(),t,oS()):{ok:!1,error:"Ollama is not running (or has no models installed)"}}function H$(t,e,n){let{json:r,unreadable:s}=lS(t);if(s)return{ok:!1,error:`could not parse ${t} \u2014 edit the ollama provider there yourself`};let i={...r??{},providers:{...np(r)??{},ollama:{baseUrl:`${n}/v1`,api:"openai-completions",apiKey:"ollama",models:e.map(o=>({id:o}))}}};try{q$(pl.dirname(t),{recursive:!0}),U$(t,JSON.stringify(i,null,2)+`
2088
+ `)}catch(o){return{ok:!1,error:`could not write ${t}: ${V(o)}`}}return{ok:!0,count:e.length}}var W$,iS,oS,dS=v(()=>{"use strict";Gt();_r();W$=1500,iS=()=>pl.join(J$(),".pi","agent","models.json"),oS=()=>hr(process.env.OLLAMA_HOST??"http://localhost:11434")});var pS={};Ai(pS,{attach:()=>Z$,breakout:()=>Lf,closeChild:()=>n1,composerFiles:()=>o1,composerNew:()=>i1,composerPaste:()=>c1,composerPasteRead:()=>u1,composerRpc:()=>l1,composerSend:()=>r1,composerStop:()=>s1,composerUiRespond:()=>a1,displayName:()=>z$,downloadSample:()=>Kf,git:()=>we,gitChangedFiles:()=>hf,gitDiff:()=>mf,info:()=>Y$,launchBulb:()=>Ff,listBreakouts:()=>Mf,listBulbFiles:()=>Bf,listChildren:()=>e1,listMyBulbs:()=>zf,listSamples:()=>Wf,listSessions:()=>X$,logInlineStatus:()=>G$,ollamaOffer:()=>cS,ollamaSync:()=>uS,openChild:()=>t1,openFile:()=>Nf,poll:()=>V$,predictTrustOf:()=>Uf,pullRemoteBulb:()=>Yf,pushLocalBulb:()=>Vf,readBulbLog:()=>Jf,repoRoot:()=>Rn,searchBulbs:()=>jf,searchSessions:()=>Q$,setBulbTrust:()=>qf,shutdownComposer:()=>f1,stopBreakout:()=>Df,summarizeTurn:()=>d1});var fS,z$,Y$,V$,G$,X$,Q$,Z$,e1,t1,n1,r1,s1,i1,o1,a1,l1,c1,u1,d1,f1,hS=v(()=>{"use strict";il();ff();al();$r();dS();fS=new Ir,z$=fS.displayName,{info:Y$,poll:V$,logInlineStatus:G$,listSessions:X$,searchSessions:Q$,attach:Z$,listChildren:e1,openChild:t1,closeChild:n1,composerSend:r1,composerStop:s1,composerNew:i1,composerFiles:o1,composerUiRespond:a1,composerRpc:l1,composerPaste:c1,composerPasteRead:u1,summarizeTurn:d1,shutdownComposer:f1}=Dr(fS)});import*as Bk from"fs/promises";import*as Ct from"path";Ti();ee();function Du(t){if(!He.includes(t))throw new Error(`Unknown block kind '${t}' (one of: ${He.join(", ")})`);return t}function fy(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=Du(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}Uo();Gu();ff();var hl={claude:{adapter:()=>new tr,server:()=>Promise.resolve().then(()=>(tS(),eS))},codex:{adapter:()=>new rr,server:()=>Promise.resolve().then(()=>(sS(),rS))},pi:{adapter:()=>new Ir,server:()=>Promise.resolve().then(()=>(hS(),pS))}};function mS(t){return t in hl}function jr(){return Object.keys(hl)}function Zt(){return Object.fromEntries(Object.entries(hl).map(([t,e])=>[t,e.adapter]))}function gS(t){return hl[t].server()}var pi=Zt();function yS(){for(let t of Object.values(pi))try{t().ensureHarnessSupport()}catch{}}function Ne(){for(let t of Object.keys(pi))try{if(pi[t]().detectsSelf())return t}catch{}}function bS(t){let e=jr(),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 sp=5e3;function rp(t){try{return t()}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exit(1)}}function wS(t){let n={subcommand:"run",file:"",watch:!0,open:process.env.TERM_PROGRAM==="vscode"||Ne()!==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==="--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=sp;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=rp(()=>Rp(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=rp(()=>Du(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=rp(()=>fy(i.slice(1)))),n}function vS(){console.log(`
2089
2089
  typebulb - Local bulb runner for Typebulb
2090
2090
 
2091
2091
  Usage:
@@ -2273,7 +2273,7 @@ Examples:
2273
2273
  typebulb my-editor.bulb.md
2274
2274
  typebulb --no-watch my-editor.bulb.md
2275
2275
  typebulb .
2276
- `)}xt();Ls();Ti();Bs();xt();import*as We from"path";import{spawn as NN,execSync as LN}from"child_process";import{createRequire as MN}from"module";import{existsSync as DN}from"fs";import*as Se from"fs/promises";import*as ve from"path";var rp=[{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"}],sp=[{name:"dom"},{name:"dom.iterable"},{name:"dom.asynciterable"}];function ip(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)}Z();var aN=`
2276
+ `)}xt();Ls();Ti();Bs();xt();import*as We from"path";import{spawn as F1,execSync as U1}from"child_process";import{createRequire as q1}from"module";import{existsSync as J1}from"fs";import*as Se from"fs/promises";import*as ve from"path";var ip=[{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 ap(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)}ee();var p1=`
2277
2277
  /**
2278
2278
  * Get raw data chunk from the Data tab.
2279
2279
  * @param index - Chunk index (0-based). Separate chunks with 2 blank lines.
@@ -2284,7 +2284,7 @@ Examples:
2284
2284
  * @param index - Chunk index (0-based)
2285
2285
  * @throws If chunk is not valid JSON/JSON-ish
2286
2286
  */
2287
- json<T = unknown>(index: number): T;`,lN=`
2287
+ json<T = unknown>(index: number): T;`,h1=`
2288
2288
  /**
2289
2289
  * Get the insight data produced by the inference layer.
2290
2290
  *
@@ -2293,7 +2293,7 @@ Examples:
2293
2293
  *
2294
2294
  * @returns The parsed insight JSON, or undefined if no insight is available
2295
2295
  */
2296
- insight<T = unknown>(): T | undefined;`,cN=`
2296
+ insight<T = unknown>(): T | undefined;`,m1=`
2297
2297
  /**
2298
2298
  * Replace the data this run is working on.
2299
2299
  *
@@ -2316,7 +2316,7 @@ Examples:
2316
2316
  *
2317
2317
  * @param value - Any JSON-serializable value
2318
2318
  */
2319
- setInsight(value: unknown): Promise<void>;`,hS=`options: {
2319
+ setInsight(value: unknown): Promise<void>;`,SS=`options: {
2320
2320
  messages: Array<{ role: "user" | "assistant"; content: string }>;
2321
2321
  system?: string;
2322
2322
  /** 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. */
@@ -2327,7 +2327,7 @@ Examples:
2327
2327
  webSearch?: boolean;
2328
2328
  /** Abort the request. On abort the promise rejects / the stream ends. */
2329
2329
  signal?: AbortSignal;
2330
- }`,mS=`
2330
+ }`,kS=`
2331
2331
  /** Provider-reported token counts for one call \u2014 real usage from the API, never an estimate.
2332
2332
  * \`output\` is total billed output (reasoning included); \`reasoning\` is the itemized subset where
2333
2333
  * the provider splits it (OpenAI, Gemini, OpenRouter \u2014 Anthropic doesn't); \`cacheRead\` is the
@@ -2339,10 +2339,10 @@ type AiChunk =
2339
2339
  | { kind: "text"; text: string }
2340
2340
  | { kind: "reasoning"; text: string }
2341
2341
  | { kind: "usage"; usage: AiUsage };
2342
- `,gS=`
2342
+ `,xS=`
2343
2343
  /** What backs \`tb.ai\`: the user's own keys, the quota-limited courtesy model, or nothing. */
2344
2344
  type AiAccess = "own" | "courtesy" | "none";
2345
- `,yS=`
2345
+ `,ES=`
2346
2346
  /**
2347
2347
  * General-purpose AI call. \`tb.ai(opts)\` resolves with the full text; \`tb.ai.stream(opts)\`
2348
2348
  * returns an async iterable of {@link AiChunk} deltas you consume with \`for await\`.
@@ -2352,7 +2352,7 @@ type AiAccess = "own" | "courtesy" | "none";
2352
2352
  * @throws On rate limit, network error, or provider error
2353
2353
  */
2354
2354
  ai: {
2355
- (${hS}): Promise<{ text: string; usage?: AiUsage }>;
2355
+ (${SS}): Promise<{ text: string; usage?: AiUsage }>;
2356
2356
  /**
2357
2357
  * Streaming counterpart of \`tb.ai()\`. Yields \`{ kind: "text" | "reasoning", text }\` deltas
2358
2358
  * as they arrive, then one final \`{ kind: "usage", usage }\` chunk with the call's token
@@ -2369,8 +2369,8 @@ type AiAccess = "own" | "courtesy" | "none";
2369
2369
  * if (c.kind === "text") answer += c.text;
2370
2370
  * }
2371
2371
  */
2372
- stream(${hS}): AsyncIterable<AiChunk>;
2373
- };`,bS=`
2372
+ stream(${SS}): AsyncIterable<AiChunk>;
2373
+ };`,AS=`
2374
2374
  /**
2375
2375
  * Returns AI models available to the current user.
2376
2376
  * Models are filtered by the user's configured API keys.
@@ -2400,7 +2400,7 @@ type AiAccess = "own" | "courtesy" | "none";
2400
2400
  * \`tb.mode\` or the length of \`tb.models()\` \u2014 which hosts offer a courtesy
2401
2401
  * model is the host's business and changes without your bulb changing.
2402
2402
  */
2403
- aiAccess(): Promise<AiAccess>;`,uN="\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;",wS=`
2403
+ aiAccess(): Promise<AiAccess>;`,g1="\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;",TS=`
2404
2404
  /**
2405
2405
  * The mode this bulb is running in.
2406
2406
  *
@@ -2410,7 +2410,7 @@ type AiAccess = "own" | "courtesy" | "none";
2410
2410
  * - \`'inline'\` \u2014 Running inline in an agent's transcript, rendered by the mirror
2411
2411
  * (sandboxed, client-only: AI, filesystem, and server RPC are unavailable)
2412
2412
  */
2413
- mode: ${ry};`,vS=`
2413
+ mode: ${iy};`,CS=`
2414
2414
  /**
2415
2415
  * Local filesystem access (CLI only).
2416
2416
  *
@@ -2431,7 +2431,7 @@ type AiAccess = "own" | "courtesy" | "none";
2431
2431
  list(path?: string): Promise<Array<{ name: string; dir: boolean; mtime: number }>>;
2432
2432
  /** 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. */
2433
2433
  remove(path: string): Promise<boolean>;
2434
- };`,SS=`
2434
+ };`,OS=`
2435
2435
  /**
2436
2436
  * The bulb's folder \u2014 absolute path to \`<bulb-dir>/<filename-stem>/\`
2437
2437
  *
@@ -2439,7 +2439,7 @@ type AiAccess = "own" | "courtesy" | "none";
2439
2439
  * \`tb.fs\` already resolves relative paths against it, so bulb code writing
2440
2440
  * its own files never needs it. CLI only \u2014 throws in ide/published/inline mode.
2441
2441
  */
2442
- readonly dir: string;`,dN=`
2442
+ readonly dir: string;`,y1=`
2443
2443
  /**
2444
2444
  * Async value inspector for tensor-like objects.
2445
2445
  *
@@ -2492,49 +2492,49 @@ type AiAccess = "own" | "courtesy" | "none";
2492
2492
  *
2493
2493
  * @returns The full canonical URL
2494
2494
  */
2495
- url(): Promise<string>;`,fN="\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;",pN="\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;",hN="\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>>;",op=`${mS}${gS}
2495
+ url(): Promise<string>;`,b1="\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;",w1="\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;",v1="\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>>;",lp=`${kS}${xS}
2496
2496
  /**
2497
2497
  * Typebulb utilities namespace.
2498
2498
  * Type \`tb.\` to discover available helpers.
2499
2499
  */
2500
- declare const tb: {${aN}${dN}${lN}${cN}${pN}${hN}${fN}${yS}${vS}${SS}${bS}${uN}${wS}
2500
+ declare const tb: {${p1}${y1}${h1}${m1}${w1}${v1}${b1}${ES}${CS}${OS}${AS}${g1}${TS}
2501
2501
  };
2502
- `,mN=`
2502
+ `,S1=`
2503
2503
  /**
2504
2504
  * Print to the CLI's stdout \u2014 the same channel as \`console.log\` here (the server's console IS
2505
2505
  * the bulb's log). One log verb across blocks: page-side \`tb.log\` reaches this same stdout.
2506
2506
  */
2507
- log(...args: any[]): void;`,ap=`${mS}${gS}
2507
+ log(...args: any[]): void;`,cp=`${kS}${xS}
2508
2508
  /**
2509
2509
  * Typebulb utilities namespace (server-side).
2510
2510
  * Type \`tb.\` to discover available helpers.
2511
2511
  */
2512
- declare const tb: {${mN}${yS}${vS}${SS}${bS}${wS}
2512
+ declare const tb: {${S1}${ES}${CS}${OS}${AS}${TS}
2513
2513
  };
2514
- `;wt();import wN from"p-limit";wt();import{resolve as xS}from"resolve.exports";var At={maxRelativeTypeRefs:500,maxBareDeps:8,maxBareDepth:3,prefetchConcurrency:4,negativeTtlMs:1e4},hi=["index.d.ts","index.d.mts"],lp=/\.d\.(ts|mts|cts)$/i;function ml(t){return/\.d\.(ts|mts|cts)(?:[?#].*)?$/i.test(t)||/[?&]dts(?:[&#]|$)/i.test(t)}function kS(t){return[`${t}.d.ts`,`${t}.d.mts`]}function en(t){if(!t||t==="./"||t==="/")return[...hi];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 Fr(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(gN(a.status)&&s<e)continue;return a}catch{if(s<e)continue;return}finally{clearTimeout(o)}}}function gN(t){return t===408||t===429||t>=500&&t<600}var gl=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)||ml(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 j({name:e,version:n})),s=await Fr(r);if(!s?.ok)return;let i;try{i=await s.json()}catch{return}if(i)return{pkg:i,baseDir:this.cdnClient.baseDir(new j({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=Tn(e.path);if(!o||o==="/"||o===".")return this.tryUntilSuccess([...hi],n);if(!lp.test(o)){let a=await this.tryUntilSuccess(en(o),n);if(a)return a}return n(o)}let s=en(e.path),i=r?.subpath?[...s,...hi]:[...hi,...s];return this.tryUntilSuccess(i,n)}toResolutionResult(e){return{kind:lp.test(e)?"types":"probe",path:e}}resolveExportsPath(e,n){let r=n||".",s=e;try{let i=this.extractPathFromResult(xS(s,r,{conditions:["types"]}));if(i)return i}catch{}try{return this.extractPathFromResult(xS(s,r,{browser:!0,conditions:["import","default","module","browser","node"]}))}catch{return}}async resolve(e){try{let n=j.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 j(i).format(),a=new j({...i,subpath:n.subpath}).format(),l=d=>this.fetchCandidateFrom(s,n.name,d);if(n.subpath){let d=jd(n.subpath),f=this.resolveExportsPath(r,d);if(f){let h=await this.resolveFromSelected(this.toResolutionResult(f),l,{subpath:!0});if(h)return{...h,resolvedPkg:a}}let p=await this.tryUntilSuccess(en(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 u=this.resolveExportsPath(r,".");if(u){let d=await this.resolveFromSelected(this.toResolutionResult(u),l);if(d)return{...d,resolvedPkg:o}}return}catch{return}}async fetchCandidateFrom(e,n,r){let s=Tn(r),i=new URL(s,e).toString(),o=await this.tryUrls([i]);return o?{dts:o.dts,url:o.url,resolvedPkg:n}:void 0}};wt();import{gunzipSync as yN}from"fflate";var yl=class{async fetchAndExtract(e,n){let r=this.getTarballUrl(e,n),s=await Fr(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=yN(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(),u=o.slice(124,136),d=s.decode(u).trim().replace(/\0/g,""),f=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+f);n.set(this.normalizeTarPath(c),s.decode(h))}i+=Math.ceil(f/512)*512}}catch{}return n}};var bl=class{constructor(e,n,r=new yl){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=Cn.majorOf(r),o=e.filter(a=>Cn.majorOf(a)===i);if(o.length)return o.sort((a,l)=>Cn.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=en(e);return n!==e&&r.push(`${e}.d.ts`,`${e}/index.d.ts`),r}async fetchFromVersionedRoot(e,n){let r=new j(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 j(n).format():n.name}}}async resolve(e){let n=j.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 wl=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(`
2514
+ `;wt();import A1 from"p-limit";wt();import{resolve as _S}from"resolve.exports";var At={maxRelativeTypeRefs:500,maxBareDeps:8,maxBareDepth:3,prefetchConcurrency:4,negativeTtlMs:1e4},hi=["index.d.ts","index.d.mts"],up=/\.d\.(ts|mts|cts)$/i;function ml(t){return/\.d\.(ts|mts|cts)(?:[?#].*)?$/i.test(t)||/[?&]dts(?:[&#]|$)/i.test(t)}function PS(t){return[`${t}.d.ts`,`${t}.d.mts`]}function en(t){if(!t||t==="./"||t==="/")return[...hi];let e=t.replace(/\.(mjs|cjs|js|mts|cts|ts)$/i,""),n=PS(e),r=e.endsWith("/")?e:`${e}/`;return n.push(...PS(`${r}index`)),n}async function Fr(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(k1(a.status)&&s<e)continue;return a}catch{if(s<e)continue;return}finally{clearTimeout(o)}}}function k1(t){return t===408||t===429||t>=500&&t<600}var gl=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)||ml(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 Fr(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=Tn(e.path);if(!o||o==="/"||o===".")return this.tryUntilSuccess([...hi],n);if(!up.test(o)){let a=await this.tryUntilSuccess(en(o),n);if(a)return a}return n(o)}let s=en(e.path),i=r?.subpath?[...s,...hi]:[...hi,...s];return this.tryUntilSuccess(i,n)}toResolutionResult(e){return{kind:up.test(e)?"types":"probe",path:e}}resolveExportsPath(e,n){let r=n||".",s=e;try{let i=this.extractPathFromResult(_S(s,r,{conditions:["types"]}));if(i)return i}catch{}try{return this.extractPathFromResult(_S(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=Fd(n.subpath),f=this.resolveExportsPath(r,d);if(f){let m=await this.resolveFromSelected(this.toResolutionResult(f),l,{subpath:!0});if(m)return{...m,resolvedPkg:a}}let p=await this.tryUntilSuccess(en(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 u=this.resolveExportsPath(r,".");if(u){let d=await this.resolveFromSelected(this.toResolutionResult(u),l);if(d)return{...d,resolvedPkg:o}}return}catch{return}}async fetchCandidateFrom(e,n,r){let s=Tn(r),i=new URL(s,e).toString(),o=await this.tryUrls([i]);return o?{dts:o.dts,url:o.url,resolvedPkg:n}:void 0}};wt();import{gunzipSync as x1}from"fflate";var yl=class{async fetchAndExtract(e,n){let r=this.getTarballUrl(e,n),s=await Fr(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=x1(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(),u=o.slice(124,136),d=s.decode(u).trim().replace(/\0/g,""),f=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 m=r.slice(i,i+f);n.set(this.normalizeTarPath(c),s.decode(m))}i+=Math.ceil(f/512)*512}}catch{}return n}};var bl=class{constructor(e,n,r=new yl){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=Cn.majorOf(r),o=e.filter(a=>Cn.majorOf(a)===i);if(o.length)return o.sort((a,l)=>Cn.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=en(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 wl=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(`
2515
2515
  `).filter(s=>{let i=s.trimStart();return!(i.startsWith("*")||i.startsWith("//")||i.startsWith("/*"))}).join(`
2516
- `),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://"))}};wt();var ES="file:///node_modules",vl=class{constructor(){this.epoch=0}bumpEpoch(){this.epoch+=1}epochDir(){return`__tsepoch_${this.epoch}`}pathForMain(e){return`${ES}/${this.epochDir()}/${e}/index.d.ts`}pathFor(e,n){let r=Tn(n);return`${ES}/${this.epochDir()}/${e}/${r}`}};import{LRUCache as bN}from"lru-cache";function AS(t){let e=new bN({ttl:At.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 Fr(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(),u=l.url||s;return await t.clearNegative(s),await t.setCachedFile(u,c),{dts:c,url:u}})();return n.set(s,a),await a.finally(()=>n.delete(s))}catch{return}}}var mi=class{constructor(e){this.inFlight=new Map,this.scanner=new wl,this.cache=e.cache,this.cdnClient=e.cdnClient,this.versionResolver=e.versionResolver,this.packageService=e.packageService,this.fetchDts=AS(e.cache),this.typescriptProvider=new gl(this.fetchDts,e.cdnClient),this.definitelyTypedProvider=new bl(e.cdnClient,e.cache),this.virtualFs=new vl}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 j(r).subpath===new j(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>At.maxRelativeTypeRefs)))try{let a=new URL(n),l=new URL("./",a);o??(o=this.extractPackageRootUrl(a));let c=this.scanner.collectRelativeTypeRefs(e).slice(0,At.maxRelativeTypeRefs);for(let u of c)await this.tryRelativeRef(u,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=ml(l)?[l]:en(l);for(let u of c){let f=new URL(u,a).toString();if(o.has(f))return;let p=await this.fetchDts(f);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 j(e).name!==new j(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,At.maxBareDeps).filter(c=>this.isDifferentPackage(c,n));if(!o.length)return;let a=new Set([n]),l=wN(At.prefetchConcurrency);await Promise.all(o.map(c=>l(()=>this.prefetchBareDepsRecursive(c,r,s,At.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 u=this.scanner.collectBareModuleRefs(a.dts).slice(0,At.maxBareDeps).filter(d=>!i.has(d));for(let d of u)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 j(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 j(a||r),c=l.version?`${l.name}@${l.version}`:l.name,{mainPath:u,packageRootUrl:d}=this.computeEntryPath(o,c),f=[{path:u,content:i}],p=[];o&&await this.expandRelativeRefs(i,o,c,f,void 0,d);let h=f.map(A=>A.content).join(`
2517
- `);await this.prefetchBareDeps(h,c,f,p,s);let m=l.format(),g=e===m?[e]:[e,m],v=g.some(A=>this.ambientlyDeclares(i,A));return v?this.markFileAmbient(f,u):p.push(...g.map(A=>({module:A,path:u}))),{pkg:e,mainPath:u,files:f,shims:p,ambient:v}}};Vd();wt();Er();Qs();zd();xr();import*as Ur from"path";var vN=Ur.join(Sa,"pkg"),SN=Ur.join(Sa,"files"),kN=Ur.join(Sa,"negative.json"),kl=class{pkgMem=new Map;fileMem=new Map;negativeCache=new On(new Ar(kN));async getCachedDts(e){if(this.pkgMem.has(e))return this.pkgMem.get(e);await te();let n=await vt(TS(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 Sl(async()=>{await te(),await Fe(TS(e),JSON.stringify(s))})}async getCachedFile(e){if(this.fileMem.has(e))return this.fileMem.get(e);await te();let n=await va(CS(e));return this.fileMem.set(e,n),n}async setCachedFile(e,n){this.fileMem.set(e,n),await Sl(async()=>{await te(),await Fe(CS(e),n)})}isNegative(e){return this.negativeCache.isNegative(e)}async recordNegative(e){await Sl(async()=>{await te(),await this.negativeCache.recordNegative(e)})}clearNegative(e){return Sl(()=>this.negativeCache.clearNegative(e))}};async function Sl(t){try{await t()}catch{}}function TS(t){return Ur.join(vN,et(t)+".json")}function CS(t){return Ur.join(SN,et(t)+".txt")}Er();var cp;function xN(){return cp||(cp=new mi({cache:new kl,cdnClient:uw,packageService:Aa,versionResolver:cw})),cp}var OS="file:///node_modules/";async function PS(t){let e=ka(t.emitKey,"typecheck");await te(),await Se.rm(e,{recursive:!0,force:!0}),await Se.mkdir(e,{recursive:!0});let n=CN(t.jsxImportSource,t.dependencies),r=await xN().resolve(t.code,t.dependencies,n),s=t.local?.name,i=s?r.filter(u=>u.pkg!==s):r,o=new Set;for(let u of i)for(let d of u.files){let f=xl(d.path);if(!f||o.has(f))continue;o.add(f);let p=ve.join(e,"node_modules",f);await Se.mkdir(ve.dirname(p),{recursive:!0}),await Se.writeFile(p,d.content,"utf8")}let a={};for(let u of i)for(let d of u.shims){let f=xl(d.path);f&&(a[d.module]=[`./node_modules/${f}`])}for(let u of i){if(u.ambient)continue;let d=xl(u.mainPath);d&&(a[u.pkg]=[`./node_modules/${d}`])}let l=new Set;for(let u of i)for(let d of u.files){if(!d.ambient)continue;let f=xl(d.path);f&&l.add(`node_modules/${f}`)}if(t.local){delete a[t.local.name];let u=await ON(t.local,e);u?a[t.local.name]=[`./node_modules/${t.local.name}/${u}`]:console.warn(` local: '${t.local.name}' ships no type defs; check cannot type against it.`)}let c=EN(t.jsxImportSource,a,[...l]);return await Se.writeFile(ve.join(e,"tsconfig.json"),JSON.stringify(c,null,2)+`
2518
- `,"utf8"),await Se.writeFile(ve.join(e,"code.tsx"),t.code,"utf8"),await Se.writeFile(ve.join(e,"tb.d.ts"),op,"utf8"),{dir:e}}var up={target:"es2023",module:"esnext",moduleResolution:"bundler",strict:!0,noEmit:!0,skipLibCheck:!0,esModuleInterop:!0,allowSyntheticDefaultImports:!0,forceConsistentCasingInFileNames:!0};function EN(t,e,n=[]){return{compilerOptions:{...up,lib:AN([...rp,...sp]),jsx:"react-jsx",jsxImportSource:t??"react",paths:e},include:["code.tsx","tb.d.ts",...n]}}function AN(t){return ip(t).map(e=>TN(e.name))}function TN(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 CN(t,e){let n=t??("react"in e?"react":void 0);return n?[`${n}/jsx-runtime`,`${n}/jsx-dev-runtime`]:[]}function xl(t){if(!t.startsWith(OS))return;let e=t.slice(OS.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 PN(n)){let i=ve.join(r,ve.relative(n,s));await Se.mkdir(ve.dirname(i),{recursive:!0}),await Se.copyFile(s,i)}return ve.basename(t.typesAbs)}async function PN(t){let e=[];async function n(r){let s=await Se.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 Tt from"path";import{existsSync as _N}from"fs";Er();Xd();var RN="^22";async function _S(t){let e=ka(t.emitKey,"typecheck-server");await te(),await Je.rm(e,{recursive:!0,force:!0}),await Je.mkdir(e,{recursive:!0});let n=Tt.join(t.bulbDir,".typebulb"),r=Ia(t.server).filter(o=>o!==t.local?.name);await Ra([`@types/node@${RN}`,...r],n,t.dependencies,{ignoreScripts:!0});let s=Tt.join(n,"node_modules"),i=Tt.join(e,"node_modules");return await $N(s,i),await Je.writeFile(Tt.join(e,"server.ts"),t.server,"utf8"),await Je.writeFile(Tt.join(e,"tb.d.ts"),ap,"utf8"),await Je.writeFile(Tt.join(e,"tsconfig.json"),JSON.stringify(IN(t.local),null,2)+`
2519
- `,"utf8"),{dir:e}}function IN(t){let e={...up,lib:["ES2023"],types:["node"]};if(t?.typesAbs){let n=i=>i.replace(/\\/g,"/"),r=n(Tt.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 $N(t,e){if(!_N(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)}oa();Z();async function IS(t,e){let{bulb:n,config:r,warnings:s,starts:i}=await nt(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 u=Pr(We.resolve(t)),d=u?Zn(n.name):"";u&&d&&d!==u.slug&&(console.log(`naming filename '${u.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=RS(Ms(n.code,{target:"client",dependencies:r.dependencies??{},lineOffset:a("code.tsx")}),"client")||l),n.server&&(l=RS(Ms(n.server,{target:"server",lineOffset:a("server.ts")}),"server")||l);let f=UN([process.cwd(),We.dirname(t)]);if(!f){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 PS({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 _S({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:v,exitCode:A}=await jN(f,g);for(let C of v.split(/\r?\n/))C.trim()&&console.log(`${m} ${BN(C,o,a)}`);A!==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 RS(t,e){for(let n of t)for(let r of n.message.split(`
2520
- `))console.log(`${e} ${r}`);return t.length>0}function BN(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 jN(t,e){return new Promise(n=>{let r=NN(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 FN=MN(import.meta.url);function UN(t){let e=r=>{try{let s=FN.resolve("typescript/package.json",{paths:r}),i=We.join(We.dirname(s),"lib","tsc.js");return DN(i)?i:void 0}catch{return}},n=e(t);if(n)return n;try{let r=LN("npm root -g",{encoding:"utf8"}).trim();return e([r])}catch{return}}xt();ia();Bs();async function $S(t,e){let{bulb:n}=await nt(t),r=fr(n);if(Sn(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.)")}Bs();import*as gi from"path";async function NS(t,e){if(!t){e||(console.error("Usage: typebulb untrust <file.bulb.md>"),process.exit(1));let r=bd();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=gi.resolve(t);n.endsWith(".bulb.md")||(console.error("File must have .bulb.md extension"),process.exit(1));try{pr(n,e)}catch(r){console.error(r.message),process.exit(1)}console.log(e?`Trusted ${gi.basename(n)} \u2014 runs with fs / AI / server.ts (no --trust needed).`:`Untrusted ${gi.basename(n)} \u2014 runs Restricted.`),console.log(` ${n}`)}je();import*as DS from"readline";Md();function dp(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 qN=5e3,El=()=>Math.round(performance.now()),LS=t=>t>=1e3?`${(t/1e3).toFixed(1)}s`:`${t}ms`;async function BS(t){let e=dS(process.cwd()),n=El();if("ambiguous"in e){let r=await JN(t,e.ambiguous);return r?MS(t,r,{boot:n,from:El()}):WN(t,e.ambiguous)}return MS(t,e.name,{boot:n,from:El()})}async function MS(t,e,n){let r,s;try{r=await Ns(e)}catch(p){s=p instanceof Error?p.message:String(p)}let i=El()-n.from,{lit:o,litLink:a,brand:l}=dp(process.stdout.isTTY===!0),c=[" Read the authoring skill before writing a bulb:",` \u2022 ${o(qs())}`],u=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>qN?[` slow launch: boot ${LS(n.boot)} \xB7 mirror ${LS(i)}`]:[],f=[` ${l(`typebulb v${t}`)}`,...d,...u,""];process.stdout.write(f.join(`
2516
+ `),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://"))}};wt();var RS="file:///node_modules",vl=class{constructor(){this.epoch=0}bumpEpoch(){this.epoch+=1}epochDir(){return`__tsepoch_${this.epoch}`}pathForMain(e){return`${RS}/${this.epochDir()}/${e}/index.d.ts`}pathFor(e,n){let r=Tn(n);return`${RS}/${this.epochDir()}/${e}/${r}`}};import{LRUCache as E1}from"lru-cache";function IS(t){let e=new E1({ttl:At.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 Fr(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(),u=l.url||s;return await t.clearNegative(s),await t.setCachedFile(u,c),{dts:c,url:u}})();return n.set(s,a),await a.finally(()=>n.delete(s))}catch{return}}}var mi=class{constructor(e){this.inFlight=new Map,this.scanner=new wl,this.cache=e.cache,this.cdnClient=e.cdnClient,this.versionResolver=e.versionResolver,this.packageService=e.packageService,this.fetchDts=IS(e.cache),this.typescriptProvider=new gl(this.fetchDts,e.cdnClient),this.definitelyTypedProvider=new bl(e.cdnClient,e.cache),this.virtualFs=new vl}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>At.maxRelativeTypeRefs)))try{let a=new URL(n),l=new URL("./",a);o??(o=this.extractPackageRootUrl(a));let c=this.scanner.collectRelativeTypeRefs(e).slice(0,At.maxRelativeTypeRefs);for(let u of c)await this.tryRelativeRef(u,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=ml(l)?[l]:en(l);for(let u of c){let f=new URL(u,a).toString();if(o.has(f))return;let p=await this.fetchDts(f);if(p?.dts){let m=this.toVirtualPath(r,new URL(p.url),s);this.pushFileIfNew(i,m,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,At.maxBareDeps).filter(c=>this.isDifferentPackage(c,n));if(!o.length)return;let a=new Set([n]),l=A1(At.prefetchConcurrency);await Promise.all(o.map(c=>l(()=>this.prefetchBareDepsRecursive(c,r,s,At.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 u=this.scanner.collectBareModuleRefs(a.dts).slice(0,At.maxBareDeps).filter(d=>!i.has(d));for(let d of u)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:u,packageRootUrl:d}=this.computeEntryPath(o,c),f=[{path:u,content:i}],p=[];o&&await this.expandRelativeRefs(i,o,c,f,void 0,d);let m=f.map(T=>T.content).join(`
2517
+ `);await this.prefetchBareDeps(m,c,f,p,s);let h=l.format(),y=e===h?[e]:[e,h],k=y.some(T=>this.ambientlyDeclares(i,T));return k?this.markFileAmbient(f,u):p.push(...y.map(T=>({module:T,path:u}))),{pkg:e,mainPath:u,files:f,shims:p,ambient:k}}};Gd();wt();xr();Qs();Yd();kr();import*as Ur from"path";var T1=Ur.join(Sa,"pkg"),C1=Ur.join(Sa,"files"),O1=Ur.join(Sa,"negative.json"),kl=class{pkgMem=new Map;fileMem=new Map;negativeCache=new On(new Er(O1));async getCachedDts(e){if(this.pkgMem.has(e))return this.pkgMem.get(e);await te();let n=await vt($S(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 Sl(async()=>{await te(),await Fe($S(e),JSON.stringify(s))})}async getCachedFile(e){if(this.fileMem.has(e))return this.fileMem.get(e);await te();let n=await va(NS(e));return this.fileMem.set(e,n),n}async setCachedFile(e,n){this.fileMem.set(e,n),await Sl(async()=>{await te(),await Fe(NS(e),n)})}isNegative(e){return this.negativeCache.isNegative(e)}async recordNegative(e){await Sl(async()=>{await te(),await this.negativeCache.recordNegative(e)})}clearNegative(e){return Sl(()=>this.negativeCache.clearNegative(e))}};async function Sl(t){try{await t()}catch{}}function $S(t){return Ur.join(T1,et(t)+".json")}function NS(t){return Ur.join(C1,et(t)+".txt")}xr();var dp;function P1(){return dp||(dp=new mi({cache:new kl,cdnClient:gw,packageService:Aa,versionResolver:mw})),dp}var LS="file:///node_modules/";async function MS(t){let e=ka(t.emitKey,"typecheck");await te(),await Se.rm(e,{recursive:!0,force:!0}),await Se.mkdir(e,{recursive:!0});let n=$1(t.jsxImportSource,t.dependencies),r=await P1().resolve(t.code,t.dependencies,n),s=t.local?.name,i=s?r.filter(u=>u.pkg!==s):r,o=new Set;for(let u of i)for(let d of u.files){let f=xl(d.path);if(!f||o.has(f))continue;o.add(f);let p=ve.join(e,"node_modules",f);await Se.mkdir(ve.dirname(p),{recursive:!0}),await Se.writeFile(p,d.content,"utf8")}let a={};for(let u of i)for(let d of u.shims){let f=xl(d.path);f&&(a[d.module]=[`./node_modules/${f}`])}for(let u of i){if(u.ambient)continue;let d=xl(u.mainPath);d&&(a[u.pkg]=[`./node_modules/${d}`])}let l=new Set;for(let u of i)for(let d of u.files){if(!d.ambient)continue;let f=xl(d.path);f&&l.add(`node_modules/${f}`)}if(t.local){delete a[t.local.name];let u=await N1(t.local,e);u?a[t.local.name]=[`./node_modules/${t.local.name}/${u}`]:console.warn(` local: '${t.local.name}' ships no type defs; check cannot type against it.`)}let c=_1(t.jsxImportSource,a,[...l]);return await Se.writeFile(ve.join(e,"tsconfig.json"),JSON.stringify(c,null,2)+`
2518
+ `,"utf8"),await Se.writeFile(ve.join(e,"code.tsx"),t.code,"utf8"),await Se.writeFile(ve.join(e,"tb.d.ts"),lp,"utf8"),{dir:e}}var fp={target:"es2023",module:"esnext",moduleResolution:"bundler",strict:!0,noEmit:!0,skipLibCheck:!0,esModuleInterop:!0,allowSyntheticDefaultImports:!0,forceConsistentCasingInFileNames:!0};function _1(t,e,n=[]){return{compilerOptions:{...fp,lib:R1([...ip,...op]),jsx:"react-jsx",jsxImportSource:t??"react",paths:e},include:["code.tsx","tb.d.ts",...n]}}function R1(t){return ap(t).map(e=>I1(e.name))}function I1(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 $1(t,e){let n=t??("react"in e?"react":void 0);return n?[`${n}/jsx-runtime`,`${n}/jsx-dev-runtime`]:[]}function xl(t){if(!t.startsWith(LS))return;let e=t.slice(LS.length),n=e.indexOf("/");if(!(n<0))return e.slice(n+1)}async function N1(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 L1(n)){let i=ve.join(r,ve.relative(n,s));await Se.mkdir(ve.dirname(i),{recursive:!0}),await Se.copyFile(s,i)}return ve.basename(t.typesAbs)}async function L1(t){let e=[];async function n(r){let s=await Se.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 Tt from"path";import{existsSync as M1}from"fs";xr();Qd();var D1="^22";async function DS(t){let e=ka(t.emitKey,"typecheck-server");await te(),await Je.rm(e,{recursive:!0,force:!0}),await Je.mkdir(e,{recursive:!0});let n=Tt.join(t.bulbDir,".typebulb"),r=Ia(t.server).filter(o=>o!==t.local?.name);await Ra([`@types/node@${D1}`,...r],n,t.dependencies,{ignoreScripts:!0});let s=Tt.join(n,"node_modules"),i=Tt.join(e,"node_modules");return await j1(s,i),await Je.writeFile(Tt.join(e,"server.ts"),t.server,"utf8"),await Je.writeFile(Tt.join(e,"tb.d.ts"),cp,"utf8"),await Je.writeFile(Tt.join(e,"tsconfig.json"),JSON.stringify(B1(t.local),null,2)+`
2519
+ `,"utf8"),{dir:e}}function B1(t){let e={...fp,lib:["ES2023"],types:["node"]};if(t?.typesAbs){let n=i=>i.replace(/\\/g,"/"),r=n(Tt.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 j1(t,e){if(!M1(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)}oa();ee();async function jS(t,e){let{bulb:n,config:r,warnings:s,starts:i}=await nt(t),o=We.basename(t),a=h=>i.get(h)??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 h of s)console.log(`structure ${h}`);s.length&&(l=!0);let u=Or(We.resolve(t)),d=u?Qn(n.name):"";u&&d&&d!==u.slug&&(console.log(`naming filename '${u.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=BS(Ms(n.code,{target:"client",dependencies:r.dependencies??{},lineOffset:a("code.tsx")}),"client")||l),n.server&&(l=BS(Ms(n.server,{target:"server",lineOffset:a("server.ts")}),"server")||l);let f=z1([process.cwd(),We.dirname(t)]);if(!f){let h=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 ${h}`),process.exit(2)}let p=[];if(n.code){let{dir:h}=await MS({code:n.code,dependencies:r.dependencies??{},jsxImportSource:r.ts?.jsxImportSource,emitKey:t,local:e});p.push({role:"client",dir:h})}if(n.server){let{dir:h}=await DS({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:h})}for(let{role:h,dir:y}of p){let{stdout:k,exitCode:T}=await K1(f,y);for(let P of k.split(/\r?\n/))P.trim()&&console.log(`${h} ${W1(P,o,a)}`);T!==0&&(l=!0)}l&&process.exit(1);let m=[n.code&&"code.tsx",n.server&&"server.ts"].filter(Boolean).join(", ");console.error(c?`\u2713 type-checks (${m}) \u2014 see the naming warning above`:`\u2713 no issues (${m})`)}function BS(t,e){for(let n of t)for(let r of n.message.split(`
2520
+ `))console.log(`${e} ${r}`);return t.length>0}function W1(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 K1(t,e){return new Promise(n=>{let r=F1(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 H1=q1(import.meta.url);function z1(t){let e=r=>{try{let s=H1.resolve("typescript/package.json",{paths:r}),i=We.join(We.dirname(s),"lib","tsc.js");return J1(i)?i:void 0}catch{return}},n=e(t);if(n)return n;try{let r=U1("npm root -g",{encoding:"utf8"}).trim();return e([r])}catch{return}}xt();ia();Bs();async function FS(t,e){let{bulb:n}=await nt(t),r=dr(n);if(Sn(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.)")}Bs();import*as gi from"path";async function US(t,e){if(!t){e||(console.error("Usage: typebulb untrust <file.bulb.md>"),process.exit(1));let r=wd();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=gi.resolve(t);n.endsWith(".bulb.md")||(console.error("File must have .bulb.md extension"),process.exit(1));try{fr(n,e)}catch(r){console.error(r.message),process.exit(1)}console.log(e?`Trusted ${gi.basename(n)} \u2014 runs with fs / AI / server.ts (no --trust needed).`:`Untrusted ${gi.basename(n)} \u2014 runs Restricted.`),console.log(` ${n}`)}je();import*as WS from"readline";Dd();function pp(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 Y1=5e3,El=()=>Math.round(performance.now()),qS=t=>t>=1e3?`${(t/1e3).toFixed(1)}s`:`${t}ms`;async function KS(t){let e=bS(process.cwd()),n=El();if("ambiguous"in e){let r=await V1(t,e.ambiguous);return r?JS(t,r,{boot:n,from:El()}):G1(t,e.ambiguous)}return JS(t,e.name,{boot:n,from:El()})}async function JS(t,e,n){let r,s;try{r=await Ns(e)}catch(p){s=p instanceof Error?p.message:String(p)}let i=El()-n.from,{lit:o,litLink:a,brand:l}=pp(process.stdout.isTTY===!0),c=[" Read the authoring skill before writing a bulb:",` \u2022 ${o(qs())}`],u=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>Y1?[` slow launch: boot ${qS(n.boot)} \xB7 mirror ${qS(i)}`]:[],f=[` ${l(`typebulb v${t}`)}`,...d,...u,""];process.stdout.write(f.join(`
2521
2521
  `)+`
2522
- `)}async function JN(t,e){if(!process.stdin.isTTY||!process.stdout.isTTY)return;let{lit:n,brand:r}=dp(!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(`
2522
+ `)}async function V1(t,e){if(!process.stdin.isTTY||!process.stdout.isTTY)return;let{lit:n,brand:r}=pp(!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(`
2523
2523
  `)+`
2524
- `);let i=DS.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 WN(t,e){let{lit:n,brand:r}=dp(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(`
2524
+ `);let i=WS.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 G1(t,e){let{lit:n,brand:r}=pp(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(`
2525
2525
  `)+`
2526
- `)}Ze();kn();async function jS(t){be(t);let e=await yt();if(e.length>0){console.log(Pb(e,process.env.TB_AI_PROVIDER,process.env.TB_AI_MODEL));return}if(!vd()){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(hr))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.")}Z();function FS(t){t?.trim()||(console.error("Usage: typebulb slug <bulb name>"),process.exit(1));let e=Zn(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)}Be();import*as JS from"path";import{valid as qS,lt as HN}from"semver";je();var rt={connected:"[page] connected",disconnected:"[page] disconnected",closed:t=>`[page] closed: ${t}`},fp=3e3,US=1e4,KN=2500,Al=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?.()},fp).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,KN);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()}};Xo();function zN(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=>cr(o,n));return r&&i.find(o=>o.agent===r)||i[0]}return t.find(i=>oe(i.file)===oe(e))}var tn=t=>t.agent??JS.basename(t.file);function WS(t){return t===Ae?!1:t&&qS(t)&&qS(Ae)?HN(t,Ae):!0}function YN(t){return t===Ae?"":t?WS(t)?` STALE runtime v${t} (this CLI is v${Ae} \u2014 relaunch to update)`:` runtime v${t} (newer than this CLI's v${Ae})`:" STALE runtime (predates the version stamp \u2014 relaunch to update)"}function VN(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 KS(t,e,n){t.forEach((r,s)=>e(` ${r.url} pid ${r.pid} ${r.trust?"trusted":"restricted"}${n?VN(r,n[s]):""}${YN(r.version)} ${r.file}`))}async function hp(t,e){if(!t.length){console.log("No running bulb servers.");return}let n=await Promise.all(t.map(cd));console.log("Running bulb servers:"),KS(t,r=>console.log(r),n),console.log(`
2527
- `+e)}function Tl(t,e,n,r,s){let i=zN(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>\`):`),KS(t,o=>console.error(o))):console.error("No bulb servers are running."),process.exit(1)}async function HS(t,e){if(!t){e.clear&&(console.error("Specify which server to clear: typebulb logs --clear <file|pid>"),process.exit(1)),await hp(await G(process.cwd()),"Run `typebulb logs <file|pid>` to print one server's console.");return}let n=Tl(await G(),t,"logs",process.cwd(),Ne());if(e.clear){nd(n.pid),console.log(`Cleared log for ${tn(n)} (pid ${n.pid}).`);return}let r=Xe(n.pid),s=r.text;if(e.run!==void 0?(s=sd(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(`
2526
+ `)}Ze();kn();async function HS(t){be(t);let e=await yt();if(e.length>0){console.log(Lb(e,process.env.TB_AI_PROVIDER,process.env.TB_AI_MODEL));return}if(!Sd()){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(pr))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.")}ee();function zS(t){t?.trim()||(console.error("Usage: typebulb slug <bulb name>"),process.exit(1));let e=Qn(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)}Be();import*as GS from"path";import{valid as VS,lt as Q1}from"semver";je();var rt={connected:"[page] connected",disconnected:"[page] disconnected",closed:t=>`[page] closed: ${t}`},hp=3e3,YS=1e4,X1=2500,Al=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?.()},hp).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,X1);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()}};Xo();function Z1(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=>lr(o,n));return r&&i.find(o=>o.agent===r)||i[0]}return t.find(i=>oe(i.file)===oe(e))}var tn=t=>t.agent??GS.basename(t.file);function XS(t){return t===Ae?!1:t&&VS(t)&&VS(Ae)?Q1(t,Ae):!0}function eN(t){return t===Ae?"":t?XS(t)?` STALE runtime v${t} (this CLI is v${Ae} \u2014 relaunch to update)`:` runtime v${t} (newer than this CLI's v${Ae})`:" STALE runtime (predates the version stamp \u2014 relaunch to update)"}function tN(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 QS(t,e,n){t.forEach((r,s)=>e(` ${r.url} pid ${r.pid} ${r.trust?"trusted":"restricted"}${n?tN(r,n[s]):""}${eN(r.version)} ${r.file}`))}async function gp(t,e){if(!t.length){console.log("No running bulb servers.");return}let n=await Promise.all(t.map(ud));console.log("Running bulb servers:"),QS(t,r=>console.log(r),n),console.log(`
2527
+ `+e)}function Tl(t,e,n,r,s){let i=Z1(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>\`):`),QS(t,o=>console.error(o))):console.error("No bulb servers are running."),process.exit(1)}async function ZS(t,e){if(!t){e.clear&&(console.error("Specify which server to clear: typebulb logs --clear <file|pid>"),process.exit(1)),await gp(await G(process.cwd()),"Run `typebulb logs <file|pid>` to print one server's console.");return}let n=Tl(await G(),t,"logs",process.cwd(),Ne());if(e.clear){rd(n.pid),console.log(`Cleared log for ${tn(n)} (pid ${n.pid}).`);return}let r=Xe(n.pid),s=r.text;if(e.run!==void 0?(s=id(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(`
2528
2528
  `);i.length&&i[i.length-1]===""&&i.pop(),s=i.slice(-e.lines).join(`
2529
2529
  `)}if(process.stdout.write(s),s&&!s.endsWith(`
2530
2530
  `)&&process.stdout.write(`
2531
- `),e.follow&&e.run===void 0){let i=r.offset,o=setInterval(()=>{let l=Xe(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 GN=t=>new Promise(e=>setTimeout(e,t));async function zS(t,e){if(!t){hp(await G(process.cwd()),"Run `typebulb wait <file|pid>` to block until one logs a new line.");return}let n=Tl(await G(),t,"wait",process.cwd(),Ne()),r=e.wake?await XN():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=Xe(n.pid).offset,u=i?void 0:Zo(n.pid,l)??(l?Zo(n.pid):void 0),d=i?c:u!==void 0&&u<=c?u:l?0:c,f=Date.now()+a*1e3,p=ye(n)?1e4:1e3,h=2e3,m=!ye(n)&&!i,g,v="",A=[],C="",x=0,R=!1;for(;;){let I=d>=c,L=Xe(n.pid,d);if(d=L.offset,L.text){v+=L.text;let T=v.split(`
2532
- `);v=T.pop()??"";let F=!1;for(let H of T)H.trim()&&(m&&I&&H.startsWith(rt.disconnected)&&(F=!0),!(e.match&&!H.includes(e.match))&&(console.log(H),A.push(H),!i&&(g??=Date.now()+p,ye(n)&&(H.includes("] compile error")||H.includes("] runtime error"))&&(g=Math.min(g,Date.now()+h)))));if(F&&!g){C=`the last page of ${tn(n)} closed while waiting \u2014 a bulb runs in its page, so nothing can log ${e.match?`'${e.match}'`:"anything"} now`,console.error(C),x=3;break}}if(g&&Date.now()>=g)break;if(!o&&!g&&Date.now()>=f){C=`timeout: no ${e.match?`line matching '${e.match}'`:"new output"} from ${tn(n)} within ${a}s`,console.error(C),x=2;break}if(!or(n.pid)){g||(C=`server ${tn(n)} (pid ${n.pid}) exited while waiting`,console.error(C),x=3,R=!0);break}await GN(400)}if(r){console.error(`detected ${new Date().toISOString()}`);try{await r.adapter.wake(r.sessionId,"typebulb_wait",A.length?A.join(`
2533
- `):C)}catch(I){console.error(`Not delivered: ${I instanceof Error?I.message:I}`),process.exit(4)}console.error(`accepted ${new Date().toISOString()}`)}R&&process.exit(3),i||Is(n.pid,d,l),process.exit(x)}async function XN(){let t=Ne(),e=t?Zt()[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 YS(t,e){if(e==="killed")return` \u2014 forced (${WS(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 VS(t){if(!t){await hp(await G(process.cwd()),"Run `typebulb stop <file|pid>` to stop one.");return}let e=Tl(await G(),t,"stop",process.cwd(),Ne()),n=await gt(e);console.log(`Stopped ${tn(e)} (pid ${e.pid}, ${e.url}).${YS(e,n)}`)}async function GS(t){let e=await pp(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=>gt(s)));console.log(`Stopped ${e.length} ${n}${e.length===1?"":"s"}:`),e.forEach((s,i)=>console.log(` ${s.url} pid ${s.pid} ${tn(s)}${YS(s,r[i])}`))}async function pp(t){let e=process.cwd(),n=t==="agent"?Ne():void 0;return t==="global"?await G():t==="bulbs"?await G(e):(await G()).filter(r=>cr(r,e)&&(!n||r.agent===n))}async function XS(t,e){let n=process.cwd(),r=t?[Tl(await G(),t,"restart",n,Ne())]:e?await pp(e):[...await G(n),...await pp("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${Ae}:`);for(let s of r){let i=s.version?`v${s.version}`:"unknown version";try{let o=ye(s)?(await gt(s,"keep"),await Ns(s.agent,s.cwd??n)):await bn(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} ${tn(s)} ${i} \u2192 v${Ae}`)}catch(o){console.log(` ${s.url} ${tn(s)} failed: ${o instanceof Error?o.message:o}`),process.exitCode=1}}}je();Be();mn();import*as Cl from"path";import*as QS from"http";import{mkdir as QN,writeFile as ZN}from"fs/promises";async function qr(){let t=[];for await(let e of process.stdin)t.push(e);return Buffer.concat(t).toString("utf-8")}function yi(t){return(t.charCodeAt(0)===65279?t.slice(1):t).replace(/\r\n/g,`
2534
- `).trimEnd()}function e1(t,e){return new Promise((n,r)=>{let s=new URL(t),i=QS.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 t1=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 ZS(t,e,n=0){e==="-"&&(e=yi(await qr()));let r=e!==void 0&&e.startsWith("tb:");r&&n<=0&&(n=np);let s=e!==void 0&&/^tb:(click|set)( |$)/.test(e),i=Cl.resolve(t),o=yn(await G(),i)[0];if(!o){let h=(await hn(process.cwd()))(i);console.error(h?`No running server for '${t}' \u2014 it last ran ${t1(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 e1(`${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 u=l.clients??0,d=`${u} page${u===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)),u===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 "${rt.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 f=l.results??[],p=l.errors??[];for(let h of p)console.error(`handler error: ${h}`);if(p.length&&process.exit(1),f.length>1&&(console.error(`${f.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)),f.length===1){if(e!==void 0&&/^tb:png( |$)/.test(e)){let m={};try{m=JSON.parse(f[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=zy(i);await QN(Cl.dirname(g),{recursive:!0}),await ZN(g,Buffer.from(m.png,"base64"));let v=[m.via?`inside "${m.via}"`:"",m.backdrop?`backdrop ${m.backdrop}`:""].filter(Boolean);console.error(`canvas ${m.width}\xD7${m.height} \u2192 PNG${v.length?` (${v.join("; ")})`:""}`),console.log(g);return}let h;try{h=JSON.parse(f[0])}catch{h=void 0}console.log(typeof h=="string"?h:f[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)`))}Fa();af();Z();import*as ek from"fs/promises";async function tk(t,e){let n=await ek.readFile(t,"utf-8"),r=Un(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(`
2531
+ `),e.follow&&e.run===void 0){let i=r.offset,o=setInterval(()=>{let l=Xe(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 nN=t=>new Promise(e=>setTimeout(e,t));async function ek(t,e){if(!t){gp(await G(process.cwd()),"Run `typebulb wait <file|pid>` to block until one logs a new line.");return}let n=Tl(await G(),t,"wait",process.cwd(),Ne()),r=e.wake?await rN():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=Xe(n.pid).offset,u=i?void 0:Zo(n.pid,l)??(l?Zo(n.pid):void 0),d=i?c:u!==void 0&&u<=c?u:l?0:c,f=Date.now()+a*1e3,p=ye(n)?1e4:1e3,m=2e3,h=!ye(n)&&!i,y,k="",T=[],P="",E=0,O=!1;for(;;){let _=d>=c,I=Xe(n.pid,d);if(d=I.offset,I.text){k+=I.text;let A=k.split(`
2532
+ `);k=A.pop()??"";let M=!1;for(let K of A)K.trim()&&(h&&_&&K.startsWith(rt.disconnected)&&(M=!0),!(e.match&&!K.includes(e.match))&&(console.log(K),T.push(K),!i&&(y??=Date.now()+p,ye(n)&&(K.includes("] compile error")||K.includes("] runtime error"))&&(y=Math.min(y,Date.now()+m)))));if(M&&!y){P=`the last page of ${tn(n)} closed while waiting \u2014 a bulb runs in its page, so nothing can log ${e.match?`'${e.match}'`:"anything"} now`,console.error(P),E=3;break}}if(y&&Date.now()>=y)break;if(!o&&!y&&Date.now()>=f){P=`timeout: no ${e.match?`line matching '${e.match}'`:"new output"} from ${tn(n)} within ${a}s`,console.error(P),E=2;break}if(!ir(n.pid)){y||(P=`server ${tn(n)} (pid ${n.pid}) exited while waiting`,console.error(P),E=3,O=!0);break}await nN(400)}if(r){console.error(`detected ${new Date().toISOString()}`);try{await r.adapter.wake(r.sessionId,"typebulb_wait",T.length?T.join(`
2533
+ `):P)}catch(_){console.error(`Not delivered: ${_ instanceof Error?_.message:_}`),process.exit(4)}console.error(`accepted ${new Date().toISOString()}`)}O&&process.exit(3),i||Is(n.pid,d,l),process.exit(E)}async function rN(){let t=Ne(),e=t?Zt()[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 tk(t,e){if(e==="killed")return` \u2014 forced (${XS(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 nk(t){if(!t){await gp(await G(process.cwd()),"Run `typebulb stop <file|pid>` to stop one.");return}let e=Tl(await G(),t,"stop",process.cwd(),Ne()),n=await gt(e);console.log(`Stopped ${tn(e)} (pid ${e.pid}, ${e.url}).${tk(e,n)}`)}async function rk(t){let e=await mp(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=>gt(s)));console.log(`Stopped ${e.length} ${n}${e.length===1?"":"s"}:`),e.forEach((s,i)=>console.log(` ${s.url} pid ${s.pid} ${tn(s)}${tk(s,r[i])}`))}async function mp(t){let e=process.cwd(),n=t==="agent"?Ne():void 0;return t==="global"?await G():t==="bulbs"?await G(e):(await G()).filter(r=>lr(r,e)&&(!n||r.agent===n))}async function sk(t,e){let n=process.cwd(),r=t?[Tl(await G(),t,"restart",n,Ne())]:e?await mp(e):[...await G(n),...await mp("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${Ae}:`);for(let s of r){let i=s.version?`v${s.version}`:"unknown version";try{let o=ye(s)?(await gt(s,"keep"),await Ns(s.agent,s.cwd??n)):await bn(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} ${tn(s)} ${i} \u2192 v${Ae}`)}catch(o){console.log(` ${s.url} ${tn(s)} failed: ${o instanceof Error?o.message:o}`),process.exitCode=1}}}je();Be();mn();import*as Cl from"path";import*as ik from"http";import{mkdir as sN,writeFile as iN}from"fs/promises";async function qr(){let t=[];for await(let e of process.stdin)t.push(e);return Buffer.concat(t).toString("utf-8")}function yi(t){return(t.charCodeAt(0)===65279?t.slice(1):t).replace(/\r\n/g,`
2534
+ `).trimEnd()}function oN(t,e){return new Promise((n,r)=>{let s=new URL(t),i=ik.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 aN=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 ok(t,e,n=0){e==="-"&&(e=yi(await qr()));let r=e!==void 0&&e.startsWith("tb:");r&&n<=0&&(n=sp);let s=e!==void 0&&/^tb:(click|set)( |$)/.test(e),i=Cl.resolve(t),o=yn(await G(),i)[0];if(!o){let m=(await hn(process.cwd()))(i);console.error(m?`No running server for '${t}' \u2014 it last ran ${aN(m)}. 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 m=>{let h=[m>0?`reply=${m}`:"",s?"solo=1":"","open=1"].filter(Boolean).join("&"),y=await oN(`${o.url}/__send${h?`?${h}`:""}`,e??"");(y.status<200||y.status>=300)&&(console.error(`send failed: HTTP ${y.status} from ${o.url}/__send`),process.exit(1));try{return JSON.parse(y.text)}catch{return{}}},l={},c=Date.now();try{l=await a(n)}catch(m){console.error(`send failed: ${m instanceof Error?m.message:String(m)}`),process.exit(1)}let u=l.clients??0,d=`${u} page${u===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)),u===0){let m=l.droppedMsAgo,h=l.opening==="none"?" and no agent mirror page is open to open one through":"",y=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?`:m!==void 0?` \u2014 a page disconnected ${Math.round(m/1e3)}s ago and hasn't reconnected${h}; reload it, or open ${o.url}`:` \u2014 no page has ever connected${h}; share ${o.url} and arm: typebulb wait ${t} --match "${rt.connected}"`;console.error(`No page connected after ${((Date.now()-c)/1e3).toFixed(1)}s, so nothing was delivered${y}`),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 f=l.results??[],p=l.errors??[];for(let m of p)console.error(`handler error: ${m}`);if(p.length&&process.exit(1),f.length>1&&(console.error(`${f.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)),f.length===1){if(e!==void 0&&/^tb:png( |$)/.test(e)){let h={};try{h=JSON.parse(f[0])}catch{}typeof h.png!="string"&&(console.error("tb:png replied with an unexpected shape \u2014 an older runtime? (`typebulb logs` lists server versions)"),process.exit(1));let y=Zy(i);await sN(Cl.dirname(y),{recursive:!0}),await iN(y,Buffer.from(h.png,"base64"));let k=[h.via?`inside "${h.via}"`:"",h.backdrop?`backdrop ${h.backdrop}`:""].filter(Boolean);console.error(`canvas ${h.width}\xD7${h.height} \u2192 PNG${k.length?` (${k.join("; ")})`:""}`),console.log(y);return}let m;try{m=JSON.parse(f[0])}catch{m=void 0}console.log(typeof m=="string"?m:f[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)`))}Fa();lf();ee();import*as ak from"fs/promises";async function lk(t,e){let n=await ak.readFile(t,"utf-8"),r=Fn(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(`
2535
2535
  `)?i:i+`
2536
- `)}Z();import*as bi from"fs/promises";async function sk(t,e){let n=await bi.readFile(t,"utf-8"),r=[];for(let{kind:i,source:o}of e){let a;try{a=o==="-"?await qr():await bi.readFile(o,"utf-8")}catch(l){rk(`Cannot read ${i}'s source: ${l instanceof Error?l.message:String(l)}`)}r.push({kind:i,content:yi(a),label:o==="-"?"stdin":o})}let s;try{s=n1(n,r)}catch(i){rk(`${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 bi.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 n1(t,e){let n=Un(t),r=t,s=[],i=[];for(let{kind:o,content:a,label:l}of e){let c=de[o].path,u=n.files.get(c);if(!a){if(u===void 0){i.push(o);continue}r=nk(Jp(r,o),r,c),s.push({kind:o,action:"removed",chars:0,label:l});continue}if(u!==void 0&&yi(u)===a){i.push(o);continue}r=nk(Wr(r,o,a),r,c),s.push({kind:o,action:u===void 0?"created":"replaced",chars:a.length,label:l})}return{text:r,written:s,upToDate:i}}function nk(t,e,n){if(t===e)throw new Error(`the **${n}** block's fence is unterminated; refusing to rewrite inside it`);return t}function rk(t){console.error(t),process.exit(1)}Ze();sl();nl();Lr();async function ik(t,e){be(e);let n=process.cwd(),r=Zt(),s=Ne(),i=(s?[s]:Object.keys(r)).map(a=>r[a]()).filter(a=>a.listChildren);if(!i.length){console.error(`Sub-agent status isn't supported for ${s} sessions.`),process.exitCode=1;return}let o=!1;for(let a of i)for(let l of Af(a,n)){if(o=!0,!t){let{reports:u,files:d}=await Nn(a,n,l);console.log(gv(l.sessionId,u,d,Date.now()));return}let c=xv(l,t);if(c.length){if(c.length>1){console.error(`Several agents match "${t}"; name one by its id:`);for(let u of c)console.error(` ${r1(u)}`);process.exitCode=1;return}console.log(mv((await Nn(a,n,l)).reports.find(u=>u.id===c[0].id),Date.now()));return}}if(!o){console.log("No sub-agents in this project's sessions.");return}console.error(`No agent matches "${t}". Run \`typebulb status\` to list them.`),process.exitCode=1}var r1=t=>`${t.id} ${(t.failing&&t.state!=="stopped"?"failing":t.state).padEnd(7)} ${Et(t)}`;Ze();import{mkdirSync as s1,readFileSync as gp,writeFileSync as ak,rmSync as i1}from"fs";import{join as Pl}from"path";Be();sl();nl();var o1=1e4,a1=720*6e4,ok="typebulb_babysit";async function lk(t){be(t);let e=process.cwd(),n=Zt(),r=Ne(),s=(r?[r]:Object.keys(n)).map(p=>n[p]()).filter(p=>p.listChildren),i=s.map(p=>({adapter:p,sessionId:p.wake?p.callerSessionId?.(e):Sv(p,e)})).find(p=>p.sessionId);if(!i?.sessionId)return mp(s.length?s.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 ${r} sessions.`);let{adapter:o,sessionId:a}=i;if(o.wake){let p=await o.wakeRoute(a);if(p.error)return mp(`Can't babysit: ${p.error}.`)}let l=Pl(Ge(),"babysit"),c=Pl(l,`${a}.json`);if(!l1(Pl(l,`${a}.lock`)))return mp("A babysit is already watching this session.");let u=[];try{u=JSON.parse(gp(c,"utf8"))}catch{}let d=p=>{try{ak(c,JSON.stringify(p))}catch{}};console.error(`Babysitting the sub-agents of session ${a}: this exits with a line when one needs attention.`);let f=Date.now()+a1;for(;Date.now()<f;){o.sessionEnded?.(a,e)&&Ol(3,"The session this babysits has ended.");let{reports:p}=await Nn(o,e,kv(o,e,a)),h=yv(p,Date.now()),m=[...h].filter(([g])=>!u.includes(g));if(!m.length)u=[...h.keys()],d(u);else{let g=m.map(([,v])=>v).join(`
2537
- `);if(o.wake){console.error(`detected ${new Date().toISOString()}`);try{await o.wake(a,ok,g)}catch(v){d([...h.keys()].filter(A=>!m.some(([C])=>C===A))),console.log(g),Ol(4,`Not delivered: ${v instanceof Error?v.message:v}`)}console.error(`accepted ${new Date().toISOString()}`)}d([...h.keys()]),console.log(g),Ol(0)}await new Promise(g=>setTimeout(g,o1))}o.wake&&await o.wake(a,ok,"typebulb babysit stopped after 12 hours with nothing to report; run it again to keep watching.").catch(()=>{}),Ol(2,"Nothing needed attention; gave up.")}function mp(t){console.error(t),process.exitCode=1}function Ol(t,e){e&&console.error(e),process.exit(t)}function l1(t){try{let e=Number(gp(t,"utf8"));if(e&&e!==process.pid)return process.kill(e,0),!1}catch{}try{s1(Pl(t,".."),{recursive:!0}),ak(t,String(process.pid)),process.on("exit",()=>{try{Number(gp(t,"utf8"))===process.pid&&i1(t)}catch{}})}catch{}return!0}Ze();xt();Z();ia();import*as rn from"fs/promises";import*as jn from"path";import{EventEmitter as _1}from"events";qt();Z();import{Hono as h1}from"hono";import{serve as m1}from"@hono/node-server";import{streamSSE as g1}from"hono/streaming";import*as wp from"fs/promises";import y1 from"open";Er();Qs();xr();import*as yp from"fs/promises";import*as wi from"path";var _l=class{async get(e){let n=et(e),r=wi.join(Xs,n+".bin"),s=wi.join(Xs,n+".json");try{let[i,o]=await Promise.all([yp.readFile(r),yp.readFile(s,"utf8")]),a=JSON.parse(o);return{body:i,contentType:a.contentType,cacheControl:a.cacheControl}}catch{return}}async set(e,n){await te();let r=et(e),s=wi.join(Xs,r+".bin"),i=wi.join(Xs,r+".json"),o={url:e,contentType:n.contentType,cacheControl:n.cacheControl};await Promise.all([Fe(s,n.body),Fe(i,JSON.stringify(o))])}};var ck=`
2536
+ `)}ee();import*as bi from"fs/promises";async function dk(t,e){let n=await bi.readFile(t,"utf-8"),r=[];for(let{kind:i,source:o}of e){let a;try{a=o==="-"?await qr():await bi.readFile(o,"utf-8")}catch(l){uk(`Cannot read ${i}'s source: ${l instanceof Error?l.message:String(l)}`)}r.push({kind:i,content:yi(a),label:o==="-"?"stdin":o})}let s;try{s=lN(n,r)}catch(i){uk(`${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 bi.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 lN(t,e){let n=Fn(t),r=t,s=[],i=[];for(let{kind:o,content:a,label:l}of e){let c=de[o].path,u=n.files.get(c);if(!a){if(u===void 0){i.push(o);continue}r=ck(Kp(r,o),r,c),s.push({kind:o,action:"removed",chars:0,label:l});continue}if(u!==void 0&&yi(u)===a){i.push(o);continue}r=ck(Wr(r,o,a),r,c),s.push({kind:o,action:u===void 0?"created":"replaced",chars:a.length,label:l})}return{text:r,written:s,upToDate:i}}function ck(t,e,n){if(t===e)throw new Error(`the **${n}** block's fence is unterminated; refusing to rewrite inside it`);return t}function uk(t){console.error(t),process.exit(1)}Ze();sl();nl();Nr();async function fk(t,e){be(e);let n=process.cwd(),r=Zt(),s=Ne(),i=(s?[s]:Object.keys(r)).map(a=>r[a]()).filter(a=>a.listChildren);if(!i.length){console.error(`Sub-agent status isn't supported for ${s} sessions.`),process.exitCode=1;return}let o=!1;for(let a of i)for(let l of Cf(a,n)){if(o=!0,!t){let{reports:u,files:d}=await $n(a,n,l);console.log(xv(l.sessionId,u,d,Date.now()));return}let c=_v(l,t);if(c.length){if(c.length>1){console.error(`Several agents match "${t}"; name one by its id:`);for(let u of c)console.error(` ${cN(u)}`);process.exitCode=1;return}console.log(Sv((await $n(a,n,l)).reports.find(u=>u.id===c[0].id),Date.now()));return}}if(!o){console.log("No sub-agents in this project's sessions.");return}console.error(`No agent matches "${t}". Run \`typebulb status\` to list them.`),process.exitCode=1}var cN=t=>`${t.id} ${(t.failing&&t.state!=="stopped"?"failing":t.state).padEnd(7)} ${Et(t)}`;Ze();import{mkdirSync as uN,readFileSync as bp,writeFileSync as hk,rmSync as dN}from"fs";import{join as Pl}from"path";Be();sl();nl();var fN=1e4,pN=720*6e4,pk="typebulb_babysit";async function mk(t){be(t);let e=process.cwd(),n=Zt(),r=Ne(),s=(r?[r]:Object.keys(n)).map(p=>n[p]()).filter(p=>p.listChildren),i=s.map(p=>({adapter:p,sessionId:p.wake?p.callerSessionId?.(e):Ov(p,e)})).find(p=>p.sessionId);if(!i?.sessionId)return yp(s.length?s.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 ${r} sessions.`);let{adapter:o,sessionId:a}=i;if(o.wake){let p=await o.wakeRoute(a);if(p.error)return yp(`Can't babysit: ${p.error}.`)}let l=Pl(Ge(),"babysit"),c=Pl(l,`${a}.json`);if(!hN(Pl(l,`${a}.lock`)))return yp("A babysit is already watching this session.");let u=[];try{u=JSON.parse(bp(c,"utf8"))}catch{}let d=p=>{try{hk(c,JSON.stringify(p))}catch{}};console.error(`Babysitting the sub-agents of session ${a}: this exits with a line when one needs attention.`);let f=Date.now()+pN;for(;Date.now()<f;){o.sessionEnded?.(a,e)&&Ol(3,"The session this babysits has ended.");let{reports:p}=await $n(o,e,Pv(o,e,a)),m=Ev(p,Date.now()),h=[...m].filter(([y])=>!u.includes(y));if(!h.length)u=[...m.keys()],d(u);else{let y=h.map(([,k])=>k).join(`
2537
+ `);if(o.wake){console.error(`detected ${new Date().toISOString()}`);try{await o.wake(a,pk,y)}catch(k){d([...m.keys()].filter(T=>!h.some(([P])=>P===T))),console.log(y),Ol(4,`Not delivered: ${k instanceof Error?k.message:k}`)}console.error(`accepted ${new Date().toISOString()}`)}d([...m.keys()]),console.log(y),Ol(0)}await new Promise(y=>setTimeout(y,fN))}o.wake&&await o.wake(a,pk,"typebulb babysit stopped after 12 hours with nothing to report; run it again to keep watching.").catch(()=>{}),Ol(2,"Nothing needed attention; gave up.")}function yp(t){console.error(t),process.exitCode=1}function Ol(t,e){e&&console.error(e),process.exit(t)}function hN(t){try{let e=Number(bp(t,"utf8"));if(e&&e!==process.pid)return process.kill(e,0),!1}catch{}try{uN(Pl(t,".."),{recursive:!0}),hk(t,String(process.pid)),process.on("exit",()=>{try{Number(bp(t,"utf8"))===process.pid&&dN(t)}catch{}})}catch{}return!0}Ze();xt();ee();ia();import*as rn from"fs/promises";import*as Bn from"path";import{EventEmitter as MN}from"events";qt();ee();import{Hono as vN}from"hono";import{serve as SN}from"@hono/node-server";import{streamSSE as kN}from"hono/streaming";import*as Sp from"fs/promises";import xN from"open";xr();Qs();kr();import*as wp from"fs/promises";import*as wi from"path";var _l=class{async get(e){let n=et(e),r=wi.join(Xs,n+".bin"),s=wi.join(Xs,n+".json");try{let[i,o]=await Promise.all([wp.readFile(r),wp.readFile(s,"utf8")]),a=JSON.parse(o);return{body:i,contentType:a.contentType,cacheControl:a.cacheControl}}catch{return}}async set(e,n){await te();let r=et(e),s=wi.join(Xs,r+".bin"),i=wi.join(Xs,r+".json"),o={url:e,contentType:n.contentType,cacheControl:n.cacheControl};await Promise.all([Fe(s,n.body),Fe(i,JSON.stringify(o))])}};var gk=`
2538
2538
  const CSS = '\\n' +
2539
2539
  /* The agent mirror's token set, verbatim (agents/core/client/styles.css) \u2014 one system across CLI
2540
2540
  chrome: app chrome sits on --panel, content wells paint --veil, grays ride one neutral tint.
@@ -2917,22 +2917,22 @@ export function runInference(ctx) {
2917
2917
  showConfirm();
2918
2918
  document.body.appendChild(host);
2919
2919
  }
2920
- `;Tr();je();kn();ga();qt();import{stream as c1}from"hono/streaming";var u1="X-TB-Stream";function vi(t){return t instanceof Re?{message:t.message,code:t.code,retryable:t.retryable}:{message:t instanceof Error?t.message:"Unknown error",code:"unknown",retryable:!1}}function Rl(t,e){return t.header("Content-Type","application/x-ndjson; charset=utf-8"),t.header("Cache-Control","no-cache"),t.header(u1,"1"),c1(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:vi(s)}))}finally{try{await r.return?.()}catch{}}})}var Il={log:(...t)=>console.log(...t)};function $l(t,e){let n=t?.[e]??(Object.hasOwn(Il,e)?Il[e]:void 0);return typeof n=="function"?n:void 0}function Nl(t){return t.constructor?.name==="AsyncGeneratorFunction"}Qd();var d1=/^\/(v\d+\/|stable\/|node\/|gh\/|@[^/]+\/[^@/]+@|[^@/]+@)/,f1=/[?&]target=/,p1=/^\/(?:@[^/]+\/)?[^/@]+\/[^/]+/;function uk(t,e=""){return d1.test(t)?!0:p1.test(t)&&f1.test(e)}var b1="127.0.0.1",w1=new Set(["localhost","127.0.0.1","::1"]),mk=(t,e)=>!!t&&typeof t=="object"&&e in t,dk=t=>{let e={};return Array.isArray(t.data)&&(e.data=t.data),mk(t,"insight")&&(e.insight=t.insight),e},fk=8*1024*1024,v1=0;function S1(t){if(t)try{return new URL(t.includes("://")?t:`http://${t}`).hostname}catch{return}}function gk(t){let e=S1(t);return!!e&&w1.has(e)}function k1(t){try{let e=new URL(t);return(e.protocol==="http:"||e.protocol==="https:")&&gk(e.host)}catch{return!1}}function x1(t){return!!t&&/\bCode\/\d/.test(t)&&/\bElectron\//.test(t)}function E1(t,e){if(!e)return!1;try{return new URL(t).host===e}catch{return!1}}function Si(t){return t instanceof Error?t.message:"Unknown error"}var pk=t=>t.how==="editor"||t.how==="unreached"?t.via:void 0,A1=2e3;async function yk(t){let{getHtml:e,basePath:n,fsBase:r,port:s,reloadEmitter:i,sendChannel:o,getServerExports:a,getBulbBlocks:l,saveInferenceResult:c,localOverride:u,trusted:d=!1,trustHint:f,staticAssets:p,bulbAssets:h,sourceFile:m,bulbKey:g,onStop:v}=t,A=`${process.pid}-${++v1}-${Date.now()}`,C=r??n,x=new h1;x.use("*",async(b,E)=>{if(!gk(b.req.header("host")))return b.text("Forbidden: untrusted Host",403);await E()}),x.use("*",async(b,E)=>{await E(),b.res.headers.set("Cross-Origin-Opener-Policy","same-origin"),b.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"]],I=async(b,E)=>{if(!d){let P=new URL(b.req.url).pathname,$=R.find(([W])=>W.endsWith("/*")?P.startsWith(W.slice(0,-2)):P===W)?.[1]??"server-side code (server.ts)";od(process.pid,$);let M=f?`
2921
- ${f}`:"";return b.text(`Forbidden: this capability requires --trust.${M}`,403)}await E()},L=async(b,E)=>{let P=b.req.header("sec-fetch-site");if(P){if(P!=="same-origin")return b.text(`Forbidden: ${P} request`,403)}else{let $=b.req.header("origin");if($&&!E1($,b.req.header("host")))return b.text("Forbidden: cross-origin request",403)}await E()};for(let[b]of R)x.use(b,I),x.use(b,L);x.use("/__log",L),x.post("/__log",async b=>{try{let{args:E}=await b.req.json();console.log(...E||[])}catch{}return b.json({ok:!0})});let T=new Al,F=new Set,H=new Set,ne=Date.now();T.onArrival(({page:b,firstAttach:E,count:P})=>{o&&P===1&&console.log(rt.connected),E&&P>1&&b.close("yielded").catch(()=>{})}),o&&T.onSettledEmpty(()=>console.log(rt.disconnected));let U,re=0,ge=async b=>{let E=Math.max(b.fresh?0:ne,T.lastDropAt);if(await T.whenArrives(fp-(Date.now()-E)))return{how:"attached"};if(Date.now()-re<A1)return{how:"none"};let P=`http://localhost:${s}#tb-relay`,$=await ld(P,n),M;return $?.where==="editor"?M={how:"editor",via:$.via}:(b.external==="force"||b.external==="follow"&&$?.where==="external")&&(await y1(P),M={how:"external"}),M?await T.whenArrives(US)?M:{how:"unreached",via:pk(M)}:(re=Date.now(),{how:"none"})},Le=b=>T.count>0?Promise.resolve({how:"attached"}):U??=ge(b).finally(()=>{U=void 0});if(o){let b=0,E=new Map;x.use("/__send",L),x.post("/__send",async P=>{let $="";try{$=await P.req.text()}catch{}let M=Number(P.req.query("reply"))||0,W=T.count===0&&P.req.query("open")!==void 0?await Le({external:"follow",fresh:!1}):void 0,q=T.count,Ke=q===0&&T.lastDropAt?Date.now()-T.lastDropAt:void 0,Y={clients:q,droppedMsAgo:Ke,...W?{opening:W.how,via:pk(W)}:{}};if(P.req.query("solo")!==void 0&&q!==1)return P.json({...Y,refused:q>1});if(q===0)return P.json(Y);let ce=sn=>{for(let Pt of T)Pt.send(sn).catch(()=>{})};if(M<=0)return ce({payload:$}),P.json(Y);let Oe=++b,Jr=await new Promise(sn=>{let Pt={expected:q,received:0,results:[],errors:[],finish:Dl=>{clearTimeout(Ml),E.delete(Oe),sn({results:Pt.results,errors:Pt.errors,timedOut:Dl})}},Ml=setTimeout(()=>Pt.finish(!0),M);E.set(Oe,Pt),ce({id:Oe,payload:$})});return P.json({...Y,...Jr})}),x.use("/__send-reply",L),x.post("/__send-reply",async P=>{try{let{id:$,results:M,errors:W}=await P.req.json(),q=E.get($);q&&(q.results.push(...M??[]),q.errors.push(...W??[]),++q.received>=q.expected&&q.finish(!1))}catch{}return P.json({ok:!0})})}x.get("/",b=>b.html(e())),x.post("/__fs/read",async b=>{try{let{path:E}=await b.req.json(),P=await Zs(E,C);return new Response(new Uint8Array(P),{headers:{"Content-Type":"application/octet-stream"}})}catch(E){let P=Si(E);return b.json({error:P},400)}}),x.post("/__fs/write",async b=>{try{let E=b.req.query("path");return E?(await $a(E,new Uint8Array(await b.req.arrayBuffer()),C),b.json({success:!0})):b.json({error:"Missing path"},400)}catch(E){let P=Si(E);return b.json({error:P},400)}}),x.post("/__fs/list",async b=>{try{let{path:E}=await b.req.json();return b.json(await Na(E??".",C))}catch(E){return b.json({error:Si(E)},400)}}),x.post("/__fs/remove",async b=>{try{let{path:E}=await b.req.json();return await La(E,C),b.json({success:!0})}catch(E){return b.json({error:Si(E)},400)}}),x.post("/__api/:name",async b=>{try{let E=b.req.param("name"),P=$l(a?.(),E);if(!P)return b.json({error:`API function '${E}' not found`},404);let{args:$}=await b.req.json();if(Nl(P))return Rl(b,P(...$||[]));let M=await P(...$||[]);return b.json({result:M})}catch(E){let P=Si(E);return b.json({error:P},500)}}),x.post("/__ai",async b=>{try{let{messages:E,system:P,effort:$,provider:M,model:W,webSearch:q,stream:Ke}=await b.req.json();if(!E||!Array.isArray(E)||E.length===0)return b.json({message:"messages array is required",code:"unknown",retryable:!1},400);let Y=bt(M,W);if(typeof Y=="string")return b.json({message:Y,code:"unknown",retryable:!1},400);let ce=await Wt(Y,{messages:E,system:P,effort:$,webSearch:q,signal:b.req.raw.signal});if(!ce.ok){let sn=await br(ce,Y.protocol);return b.json(sn,ce.status)}if(Ke)return Rl(b,An(ce,Y.protocol));let{text:Oe,usage:Jr}=await wr(ce,Y.protocol);return Oe||console.warn("[tb.ai] Empty response from provider"),b.json({text:Oe,usage:Jr})}catch(E){return b.json(vi(E),500)}}),x.post("/__infer",async b=>{try{let{data:E}=await b.req.json().catch(()=>({})),P=l?.();if(!P?.infer.trim())return b.json({message:"This bulb has no infer.md block.",code:"unknown",retryable:!1},400);let $=bt();if(typeof $=="string")return b.json({message:$,code:"unknown",retryable:!1},400);let M=Array.isArray(E)?E.map(String):[],W=Id(P,M),q=await Wt($,{messages:[{role:"user",content:W}],signal:b.req.raw.signal});if(!q.ok){let Y=await br(q,$.protocol);return b.json(Y,q.status)}let Ke=(async function*(){let Y="";for await(let Oe of An(q,$.protocol))Oe.kind!=="text"||!Oe.text||(Y+=Oe.text,yield{kind:"delta",text:Oe.text});let ce=$d(Y);if(ce.parsed===void 0)throw console.warn(`[tb.infer] output not valid JSON after sanitize; raw output (last 4000 chars):
2922
- `+Y.slice(-4e3)),new Re("LLM output is not valid JSON","parse_error",!0);ce.fixesApplied.length&&console.warn("[tb.infer] sanitized output, fixes applied:",ce.fixesApplied.join(", ")),yield{kind:"complete",insight:ce.parsed,data:M,fixesApplied:ce.fixesApplied}})();return Rl(b,Ke)}catch(E){return b.json(vi(E),500)}}),x.post("/__infer-save",async b=>{try{if(!c)return b.json({message:"Save is not available for this server.",code:"unknown",retryable:!1},400);let E=dk(await b.req.json().catch(()=>({})));return Object.keys(E).length?(await c(E.data,mk(E,"insight")?JSON.stringify(E.insight,null,2):void 0),b.json({ok:!0})):b.json({message:"Nothing to save \u2014 this page holds no runtime state.",code:"unknown",retryable:!1},400)}catch(E){return b.json(vi(E),500)}}),x.get("/__infer-info",b=>{let E=l?.(),P=Kr(E?.config??"").inference,$=Po(E?.data??""),M=!!E?.infer.trim(),W=bt();return typeof W=="string"?b.json({error:W,inference:P,data:$,hasInfer:M}):b.json({provider:W.protocol,model:W.model,inference:P,data:$,hasInfer:M})}),x.use("/__tb-decode",L),x.post("/__tb-decode",async b=>{let{hash:E}=await b.req.json().catch(()=>({})),P=typeof E=="string"?Ld(E):void 0;return b.json(P??{error:"invalid fragment"})}),x.use("/__tb-encode",L),x.post("/__tb-encode",async b=>{let E=Number(b.req.header("content-length"));if(Number.isFinite(E)&&E>fk)return b.json({hash:""});let P=await b.req.text().catch(()=>"");if(P.length>fk)return b.json({hash:""});let $;try{$=JSON.parse(P)}catch{return b.json({hash:""})}return b.json({hash:Nd(dk($))})}),x.get("/__infer-ui.js",b=>b.body(ck,200,{"Content-Type":"text/javascript; charset=utf-8"})),x.get("/__models",async b=>{try{let E=await yt();return b.json(E)}catch{return b.json([],200)}}),x.get("/__ai-access",async b=>{try{return b.json(await la())}catch{return b.json("none",200)}}),m&&x.get("/__source/*",async b=>{let E=await wp.readFile(m,"utf-8").catch(()=>{});return E===void 0?b.text("Not Found",404):new Response(E,{headers:{"Content-Type":"text/plain; charset=utf-8"}})});let ut=["esm.sh","unpkg.com","cdn.jsdelivr.net","cdnjs.cloudflare.com"],pe=new _l;x.get("/proxy/*",async b=>{let E=new URL(b.req.url),$=(E.pathname+E.search).slice(7),M=$.lastIndexOf("https://");return M===-1?b.text("Invalid proxy URL",400):Ce(b,$.slice(M))}),u&&hk(x,`/local/${u.name}/`,u.serveDir),p&&hk(x,p.mount,p.dir),h&&x.get("/assets/*",async b=>{let{pathname:E}=new URL(b.req.url),P=E.slice(8),$;try{$=decodeURIComponent(P)}catch{return b.text("Not Found",404)}let M=zp($);if(M)return b.text(`${M} is not an asset type: a bulb's code and markup live in the bulb; assets are media and data`,403);try{let q=await bk($,h.dir,{"Cache-Control":"no-cache"});if(q)return q}catch{return b.text("Not Found",404)}let W=h.remoteBase;return W?b.redirect(W+P,302):b.text("Not Found",404)});async function Ce(b,E){let P;try{P=new URL(E)}catch{return b.text("Invalid URL",400)}if(P.protocol!=="https:")return b.text("HTTPS only",400);if(!ut.includes(P.hostname))return b.text("Host not allowed",403);let $=await pe.get(E);if($)return new Response($.body,{status:200,headers:bp($.contentType,$.cacheControl)});try{let M=await fetch(E,{headers:{Accept:b.req.header("Accept")||"*/*"},redirect:"follow"});if(!M.ok)return b.text(`Upstream ${M.status}`,M.status);let W=M.headers.get("Content-Type")||void 0,q=M.headers.get("Cache-Control")||void 0;if(M.body){let[Ke,Y]=M.body.tee();return(async()=>{try{let ce=await new Response(Y).arrayBuffer();await pe.set(E,{body:Buffer.from(ce),contentType:W,cacheControl:q})}catch{}})(),new Response(Ke,{status:M.status,headers:bp(W,q)})}return new Response(null,{status:M.status,headers:bp(W,q)})}catch(M){return b.text(`Proxy fetch failed: ${M instanceof Error?M.message:M}`,502)}}(i||o)&&(x.get("/__reload",b=>g1(b,async E=>{let P=b.req.query("bulb")||void 0;if(g&&P&&P!==g){F.has(P)||(F.add(P),console.log(rt.closed("foreign"))),await E.writeSSE({event:"close",data:"foreign"});return}let $=()=>{E.writeSSE({event:"reload",data:""})};i?.on("reload",$);let M=()=>i?.removeListener("reload",$),W=b.req.query("relay")||void 0,q={inEditor:x1(b.req.header("user-agent")),doc:W,open:Y=>E.writeSSE({event:"open-url",data:Y}),send:Y=>E.writeSSE({event:"message",data:JSON.stringify(Y)}),close:Y=>(M(),T.closing(q),console.log(rt.closed(Y)),E.writeSSE({event:"close",data:Y}))},Ke=!!W&&!H.has(W);for(W&&H.add(W),T.add(q,Ke),E.onAbort(()=>{M(),T.dropped(q)}),await E.writeSSE({event:"hello",data:A,retry:Gd});!E.aborted;)await E.sleep(3e4)})),x.use("/__open",L),x.post("/__open",async b=>{let E="";try{E=String((await b.req.json()).url??"")}catch{}if(!k1(E))return b.json({error:"a local http URL is required"},400);let P=[...T].find($=>$.inEditor);return await P?.open(E),b.json({opened:!!P,pages:T.count})})),x.use("/__stop",L),x.post("/__stop",async b=>{if(b.req.header("sec-fetch-site")||b.req.header("origin"))return b.text("Forbidden: browser request",403);let E="close";try{let $=await b.req.json();($?.pages==="keep"||$?.pages==="close")&&(E=$.pages)}catch{}let P=E==="close"?await T.closeAll("stopped"):{told:0,gone:0};return v&&setTimeout(()=>{v({pages:E})},50),b.json({closed:P.gone,stuck:P.told-P.gone,exiting:!!v})}),x.get("/__pages",b=>b.json({pages:T.count})),x.notFound(async b=>{if(b.req.method!=="GET")return b.text("Not Found",404);let E=new URL(b.req.url);return uk(E.pathname,E.search)?Ce(b,"https://esm.sh"+E.pathname+E.search):b.text("Not Found",404)});let Ot=m1({fetch:x.fetch,port:s,hostname:b1});return Ot.listening||await new Promise((b,E)=>{let P=$=>E($);Ot.once("error",P),Ot.once("listening",()=>{Ot.removeListener("error",P),b()})}),{port:s,close:()=>Ot.close(),requestPage:Le,closePages:b=>T.closeAll(b),pageCount:()=>T.count}}function bp(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 hk(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 bk(decodeURIComponent(s.slice(e.length)),n)??r.text("Not Found",404)}catch{return r.text("Not Found",404)}})}async function bk(t,e,n={}){let r=Cr(t,e),s=await wp.readFile(r).catch(()=>{});if(s)return new Response(s,{headers:{"Content-Type":Hp(r),...n}})}je();mn();async function Ll(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),u=[],d,f=!1,p=async m=>{if(!f){f=!0,console.log(`
2923
- Shutting down...`),(m?.pages??(ye(c)?"keep":"close"))==="close"&&await d?.closePages("stopped"),d?.close();for(let g of u)try{await g()}catch{}a(),await gn(process.pid),process.exit(0)}},h=await yk({...r(e),onStop:p}).catch(async m=>{if(m?.code!=="EADDRINUSE")throw m;return Xu(e)});return d=h,await id(c),console.log(`
2924
- ${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:v}){if(m==="none")return;let A={fresh:g,external:v?"never":m==="window"?"force":"follow"},C=await h.requestPage(A);C.how==="attached"?console.log(` Reusing the open browser tab.
2925
- `):C.how==="editor"?console.log(` Opened in VS Code via ${C.via}.
2926
- `):C.how==="external"?console.log(` Opened in your browser.
2927
- `):console.log(` ${C.how==="unreached"?`Opened ${C.via?`in VS Code via ${C.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."}
2920
+ `;Ar();je();kn();ga();qt();import{stream as mN}from"hono/streaming";var gN="X-TB-Stream";function vi(t){return t instanceof Re?{message:t.message,code:t.code,retryable:t.retryable}:{message:t instanceof Error?t.message:"Unknown error",code:"unknown",retryable:!1}}function Rl(t,e){return t.header("Content-Type","application/x-ndjson; charset=utf-8"),t.header("Cache-Control","no-cache"),t.header(gN,"1"),mN(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:vi(s)}))}finally{try{await r.return?.()}catch{}}})}var Il={log:(...t)=>console.log(...t)};function $l(t,e){let n=t?.[e]??(Object.hasOwn(Il,e)?Il[e]:void 0);return typeof n=="function"?n:void 0}function Nl(t){return t.constructor?.name==="AsyncGeneratorFunction"}Zd();var yN=/^\/(v\d+\/|stable\/|node\/|gh\/|@[^/]+\/[^@/]+@|[^@/]+@)/,bN=/[?&]target=/,wN=/^\/(?:@[^/]+\/)?[^/@]+\/[^/]+/;function yk(t,e=""){return yN.test(t)?!0:wN.test(t)&&bN.test(e)}var EN="127.0.0.1",AN=new Set(["localhost","127.0.0.1","::1"]),kk=(t,e)=>!!t&&typeof t=="object"&&e in t,bk=t=>{let e={};return Array.isArray(t.data)&&(e.data=t.data),kk(t,"insight")&&(e.insight=t.insight),e},wk=8*1024*1024,TN=0;function CN(t){if(t)try{return new URL(t.includes("://")?t:`http://${t}`).hostname}catch{return}}function xk(t){let e=CN(t);return!!e&&AN.has(e)}function ON(t){try{let e=new URL(t);return(e.protocol==="http:"||e.protocol==="https:")&&xk(e.host)}catch{return!1}}function PN(t){return!!t&&/\bCode\/\d/.test(t)&&/\bElectron\//.test(t)}function _N(t,e){if(!e)return!1;try{return new URL(t).host===e}catch{return!1}}function Si(t){return t instanceof Error?t.message:"Unknown error"}var vk=t=>t.how==="editor"||t.how==="unreached"?t.via:void 0,RN=2e3;async function Ek(t){let{getHtml:e,basePath:n,fsBase:r,port:s,reloadEmitter:i,sendChannel:o,getServerExports:a,getBulbBlocks:l,saveInferenceResult:c,localOverride:u,trusted:d=!1,trustHint:f,staticAssets:p,bulbAssets:m,sourceFile:h,bulbKey:y,onStop:k}=t,T=`${process.pid}-${++TN}-${Date.now()}`,P=r??n,E=new vN;E.use("*",async(b,x)=>{if(!xk(b.req.header("host")))return b.text("Forbidden: untrusted Host",403);await x()}),E.use("*",async(b,x)=>{await x(),b.res.headers.set("Cross-Origin-Opener-Policy","same-origin"),b.res.headers.set("Cross-Origin-Embedder-Policy","credentialless")});let O=[["/__fs/*","the filesystem"],["/__api/*","server-side code (server.ts)"],["/__ai","AI (your API keys)"],["/__infer","AI (your API keys)"],["/__infer-save","the filesystem"]],_=async(b,x)=>{if(!d){let R=new URL(b.req.url).pathname,N=O.find(([W])=>W.endsWith("/*")?R.startsWith(W.slice(0,-2)):R===W)?.[1]??"server-side code (server.ts)";ad(process.pid,N);let D=f?`
2921
+ ${f}`:"";return b.text(`Forbidden: this capability requires --trust.${D}`,403)}await x()},I=async(b,x)=>{let R=b.req.header("sec-fetch-site");if(R){if(R!=="same-origin")return b.text(`Forbidden: ${R} request`,403)}else{let N=b.req.header("origin");if(N&&!_N(N,b.req.header("host")))return b.text("Forbidden: cross-origin request",403)}await x()};for(let[b]of O)E.use(b,_),E.use(b,I);E.use("/__log",I),E.post("/__log",async b=>{try{let{args:x}=await b.req.json();console.log(...x||[])}catch{}return b.json({ok:!0})});let A=new Al,M=new Set,K=new Set,ne=Date.now();A.onArrival(({page:b,firstAttach:x,count:R})=>{o&&R===1&&console.log(rt.connected),x&&R>1&&b.close("yielded").catch(()=>{})}),o&&A.onSettledEmpty(()=>console.log(rt.disconnected));let U,re=0,ge=async b=>{let x=Math.max(b.fresh?0:ne,A.lastDropAt);if(await A.whenArrives(hp-(Date.now()-x)))return{how:"attached"};if(Date.now()-re<RN)return{how:"none"};let R=`http://localhost:${s}#tb-relay`,N=await cd(R,n),D;return N?.where==="editor"?D={how:"editor",via:N.via}:(b.external==="force"||b.external==="follow"&&N?.where==="external")&&(await xN(R),D={how:"external"}),D?await A.whenArrives(YS)?D:{how:"unreached",via:vk(D)}:(re=Date.now(),{how:"none"})},Le=b=>A.count>0?Promise.resolve({how:"attached"}):U??=ge(b).finally(()=>{U=void 0});if(o){let b=0,x=new Map;E.use("/__send",I),E.post("/__send",async R=>{let N="";try{N=await R.req.text()}catch{}let D=Number(R.req.query("reply"))||0,W=A.count===0&&R.req.query("open")!==void 0?await Le({external:"follow",fresh:!1}):void 0,q=A.count,Ke=q===0&&A.lastDropAt?Date.now()-A.lastDropAt:void 0,Y={clients:q,droppedMsAgo:Ke,...W?{opening:W.how,via:vk(W)}:{}};if(R.req.query("solo")!==void 0&&q!==1)return R.json({...Y,refused:q>1});if(q===0)return R.json(Y);let ce=sn=>{for(let Pt of A)Pt.send(sn).catch(()=>{})};if(D<=0)return ce({payload:N}),R.json(Y);let Oe=++b,Jr=await new Promise(sn=>{let Pt={expected:q,received:0,results:[],errors:[],finish:Dl=>{clearTimeout(Ml),x.delete(Oe),sn({results:Pt.results,errors:Pt.errors,timedOut:Dl})}},Ml=setTimeout(()=>Pt.finish(!0),D);x.set(Oe,Pt),ce({id:Oe,payload:N})});return R.json({...Y,...Jr})}),E.use("/__send-reply",I),E.post("/__send-reply",async R=>{try{let{id:N,results:D,errors:W}=await R.req.json(),q=x.get(N);q&&(q.results.push(...D??[]),q.errors.push(...W??[]),++q.received>=q.expected&&q.finish(!1))}catch{}return R.json({ok:!0})})}E.get("/",b=>b.html(e())),E.post("/__fs/read",async b=>{try{let{path:x}=await b.req.json(),R=await Zs(x,P);return new Response(new Uint8Array(R),{headers:{"Content-Type":"application/octet-stream"}})}catch(x){let R=Si(x);return b.json({error:R},400)}}),E.post("/__fs/write",async b=>{try{let x=b.req.query("path");return x?(await $a(x,new Uint8Array(await b.req.arrayBuffer()),P),b.json({success:!0})):b.json({error:"Missing path"},400)}catch(x){let R=Si(x);return b.json({error:R},400)}}),E.post("/__fs/list",async b=>{try{let{path:x}=await b.req.json();return b.json(await Na(x??".",P))}catch(x){return b.json({error:Si(x)},400)}}),E.post("/__fs/remove",async b=>{try{let{path:x}=await b.req.json();return await La(x,P),b.json({success:!0})}catch(x){return b.json({error:Si(x)},400)}}),E.post("/__api/:name",async b=>{try{let x=b.req.param("name"),R=$l(a?.(),x);if(!R)return b.json({error:`API function '${x}' not found`},404);let{args:N}=await b.req.json();if(Nl(R))return Rl(b,R(...N||[]));let D=await R(...N||[]);return b.json({result:D})}catch(x){let R=Si(x);return b.json({error:R},500)}}),E.post("/__ai",async b=>{try{let{messages:x,system:R,effort:N,provider:D,model:W,webSearch:q,stream:Ke}=await b.req.json();if(!x||!Array.isArray(x)||x.length===0)return b.json({message:"messages array is required",code:"unknown",retryable:!1},400);let Y=bt(D,W);if(typeof Y=="string")return b.json({message:Y,code:"unknown",retryable:!1},400);let ce=await Wt(Y,{messages:x,system:R,effort:N,webSearch:q,signal:b.req.raw.signal});if(!ce.ok){let sn=await yr(ce,Y.protocol);return b.json(sn,ce.status)}if(Ke)return Rl(b,An(ce,Y.protocol));let{text:Oe,usage:Jr}=await br(ce,Y.protocol);return Oe||console.warn("[tb.ai] Empty response from provider"),b.json({text:Oe,usage:Jr})}catch(x){return b.json(vi(x),500)}}),E.post("/__infer",async b=>{try{let{data:x}=await b.req.json().catch(()=>({})),R=l?.();if(!R?.infer.trim())return b.json({message:"This bulb has no infer.md block.",code:"unknown",retryable:!1},400);let N=bt();if(typeof N=="string")return b.json({message:N,code:"unknown",retryable:!1},400);let D=Array.isArray(x)?x.map(String):[],W=$d(R,D),q=await Wt(N,{messages:[{role:"user",content:W}],signal:b.req.raw.signal});if(!q.ok){let Y=await yr(q,N.protocol);return b.json(Y,q.status)}let Ke=(async function*(){let Y="";for await(let Oe of An(q,N.protocol))Oe.kind!=="text"||!Oe.text||(Y+=Oe.text,yield{kind:"delta",text:Oe.text});let ce=Nd(Y);if(ce.parsed===void 0)throw console.warn(`[tb.infer] output not valid JSON after sanitize; raw output (last 4000 chars):
2922
+ `+Y.slice(-4e3)),new Re("LLM output is not valid JSON","parse_error",!0);ce.fixesApplied.length&&console.warn("[tb.infer] sanitized output, fixes applied:",ce.fixesApplied.join(", ")),yield{kind:"complete",insight:ce.parsed,data:D,fixesApplied:ce.fixesApplied}})();return Rl(b,Ke)}catch(x){return b.json(vi(x),500)}}),E.post("/__infer-save",async b=>{try{if(!c)return b.json({message:"Save is not available for this server.",code:"unknown",retryable:!1},400);let x=bk(await b.req.json().catch(()=>({})));return Object.keys(x).length?(await c(x.data,kk(x,"insight")?JSON.stringify(x.insight,null,2):void 0),b.json({ok:!0})):b.json({message:"Nothing to save \u2014 this page holds no runtime state.",code:"unknown",retryable:!1},400)}catch(x){return b.json(vi(x),500)}}),E.get("/__infer-info",b=>{let x=l?.(),R=Kr(x?.config??"").inference,N=Po(x?.data??""),D=!!x?.infer.trim(),W=bt();return typeof W=="string"?b.json({error:W,inference:R,data:N,hasInfer:D}):b.json({provider:W.protocol,model:W.model,inference:R,data:N,hasInfer:D})}),E.use("/__tb-decode",I),E.post("/__tb-decode",async b=>{let{hash:x}=await b.req.json().catch(()=>({})),R=typeof x=="string"?Md(x):void 0;return b.json(R??{error:"invalid fragment"})}),E.use("/__tb-encode",I),E.post("/__tb-encode",async b=>{let x=Number(b.req.header("content-length"));if(Number.isFinite(x)&&x>wk)return b.json({hash:""});let R=await b.req.text().catch(()=>"");if(R.length>wk)return b.json({hash:""});let N;try{N=JSON.parse(R)}catch{return b.json({hash:""})}return b.json({hash:Ld(bk(N))})}),E.get("/__infer-ui.js",b=>b.body(gk,200,{"Content-Type":"text/javascript; charset=utf-8"})),E.get("/__models",async b=>{try{let x=await yt();return b.json(x)}catch{return b.json([],200)}}),E.get("/__ai-access",async b=>{try{return b.json(await la())}catch{return b.json("none",200)}}),h&&E.get("/__source/*",async b=>{let x=await Sp.readFile(h,"utf-8").catch(()=>{});return x===void 0?b.text("Not Found",404):new Response(x,{headers:{"Content-Type":"text/plain; charset=utf-8"}})});let ut=["esm.sh","unpkg.com","cdn.jsdelivr.net","cdnjs.cloudflare.com"],pe=new _l;E.get("/proxy/*",async b=>{let x=new URL(b.req.url),N=(x.pathname+x.search).slice(7),D=N.lastIndexOf("https://");return D===-1?b.text("Invalid proxy URL",400):Ce(b,N.slice(D))}),u&&Sk(E,`/local/${u.name}/`,u.serveDir),p&&Sk(E,p.mount,p.dir),m&&E.get("/assets/*",async b=>{let{pathname:x}=new URL(b.req.url),R=x.slice(8),N;try{N=decodeURIComponent(R)}catch{return b.text("Not Found",404)}let D=Vp(N);if(D)return b.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 q=await Ak(N,m.dir,{"Cache-Control":"no-cache"});if(q)return q}catch{return b.text("Not Found",404)}let W=m.remoteBase;return W?b.redirect(W+R,302):b.text("Not Found",404)});async function Ce(b,x){let R;try{R=new URL(x)}catch{return b.text("Invalid URL",400)}if(R.protocol!=="https:")return b.text("HTTPS only",400);if(!ut.includes(R.hostname))return b.text("Host not allowed",403);let N=await pe.get(x);if(N)return new Response(N.body,{status:200,headers:vp(N.contentType,N.cacheControl)});try{let D=await fetch(x,{headers:{Accept:b.req.header("Accept")||"*/*"},redirect:"follow"});if(!D.ok)return b.text(`Upstream ${D.status}`,D.status);let W=D.headers.get("Content-Type")||void 0,q=D.headers.get("Cache-Control")||void 0;if(D.body){let[Ke,Y]=D.body.tee();return(async()=>{try{let ce=await new Response(Y).arrayBuffer();await pe.set(x,{body:Buffer.from(ce),contentType:W,cacheControl:q})}catch{}})(),new Response(Ke,{status:D.status,headers:vp(W,q)})}return new Response(null,{status:D.status,headers:vp(W,q)})}catch(D){return b.text(`Proxy fetch failed: ${D instanceof Error?D.message:D}`,502)}}(i||o)&&(E.get("/__reload",b=>kN(b,async x=>{let R=b.req.query("bulb")||void 0;if(y&&R&&R!==y){M.has(R)||(M.add(R),console.log(rt.closed("foreign"))),await x.writeSSE({event:"close",data:"foreign"});return}let N=()=>{x.writeSSE({event:"reload",data:""})};i?.on("reload",N);let D=()=>i?.removeListener("reload",N),W=b.req.query("relay")||void 0,q={inEditor:PN(b.req.header("user-agent")),doc:W,open:Y=>x.writeSSE({event:"open-url",data:Y}),send:Y=>x.writeSSE({event:"message",data:JSON.stringify(Y)}),close:Y=>(D(),A.closing(q),console.log(rt.closed(Y)),x.writeSSE({event:"close",data:Y}))},Ke=!!W&&!K.has(W);for(W&&K.add(W),A.add(q,Ke),x.onAbort(()=>{D(),A.dropped(q)}),await x.writeSSE({event:"hello",data:T,retry:Xd});!x.aborted;)await x.sleep(3e4)})),E.use("/__open",I),E.post("/__open",async b=>{let x="";try{x=String((await b.req.json()).url??"")}catch{}if(!ON(x))return b.json({error:"a local http URL is required"},400);let R=[...A].find(N=>N.inEditor);return await R?.open(x),b.json({opened:!!R,pages:A.count})})),E.use("/__stop",I),E.post("/__stop",async b=>{if(b.req.header("sec-fetch-site")||b.req.header("origin"))return b.text("Forbidden: browser request",403);let x="close";try{let N=await b.req.json();(N?.pages==="keep"||N?.pages==="close")&&(x=N.pages)}catch{}let R=x==="close"?await A.closeAll("stopped"):{told:0,gone:0};return k&&setTimeout(()=>{k({pages:x})},50),b.json({closed:R.gone,stuck:R.told-R.gone,exiting:!!k})}),E.get("/__pages",b=>b.json({pages:A.count})),E.notFound(async b=>{if(b.req.method!=="GET")return b.text("Not Found",404);let x=new URL(b.req.url);return yk(x.pathname,x.search)?Ce(b,"https://esm.sh"+x.pathname+x.search):b.text("Not Found",404)});let Ot=SN({fetch:E.fetch,port:s,hostname:EN});return Ot.listening||await new Promise((b,x)=>{let R=N=>x(N);Ot.once("error",R),Ot.once("listening",()=>{Ot.removeListener("error",R),b()})}),{port:s,close:()=>Ot.close(),requestPage:Le,closePages:b=>A.closeAll(b),pageCount:()=>A.count}}function vp(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 Sk(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 Ak(decodeURIComponent(s.slice(e.length)),n)??r.text("Not Found",404)}catch{return r.text("Not Found",404)}})}async function Ak(t,e,n={}){let r=Tr(t,e),s=await Sp.readFile(r).catch(()=>{});if(s)return new Response(s,{headers:{"Content-Type":Yp(r),...n}})}je();mn();async function Ll(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),u=[],d,f=!1,p=async h=>{if(!f){f=!0,console.log(`
2923
+ Shutting down...`),(h?.pages??(ye(c)?"keep":"close"))==="close"&&await d?.closePages("stopped"),d?.close();for(let y of u)try{await y()}catch{}a(),await gn(process.pid),process.exit(0)}},m=await Ek({...r(e),onStop:p}).catch(async h=>{if(h?.code!=="EADDRINUSE")throw h;return Qu(e)});return d=m,await od(c),console.log(`
2924
+ ${i}`),console.log(` ${l}`),n&&console.log(` ${n}`),process.on("SIGINT",()=>{p()}),process.on("SIGTERM",()=>{p()}),{port:e,url:l,pageCount:()=>m.pageCount(),async handOver({mode:h,fresh:y,replacedLive:k}){if(h==="none")return;let T={fresh:y,external:k?"never":h==="window"?"force":"follow"},P=await m.requestPage(T);P.how==="attached"?console.log(` Reusing the open browser tab.
2925
+ `):P.how==="editor"?console.log(` Opened in VS Code via ${P.via}.
2926
+ `):P.how==="external"?console.log(` Opened in your browser.
2927
+ `):console.log(` ${P.how==="unreached"?`Opened ${P.via?`in VS Code via ${P.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."}
2928
2928
  Share ${l}, and wake on the arrival:
2929
2929
  typebulb wait ${o} --match "${rt.connected}"
2930
- `)},onCleanup(m){u.push(m)}}}mn();import T1 from"chokidar";import wk from"node:fs";import C1 from"node:path";var O1={persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}};function nn(t){let{target:e,onChange:n,events:r="change",debounceMs:s=150}=t,i,o=T1.watch(e,O1);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 P1=t=>process.platform==="win32"||process.platform==="darwin"?t.toLowerCase()==="assets":t==="assets";function vk(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&&P1(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=C1.join(t,"assets");return wk.existsSync(i)?nn({target:i,onChange:e,events:"all",debounceMs:n}):()=>{}}}je();Be();Tr();async function Sk(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=$s(process.pid),o=e.watch?new _1:void 0,a=be(e.mode),l=(await hn(process.cwd()))(t),c=await ir({kind:"bulb",file:t},process.cwd()),u=await ta(t,c);u.length&&console.log(`Replacing the running server for this bulb (pid ${u.map(ge=>ge.pid).join(", ")})`);let d=u.length>0||Date.now()-l<fw,{port:f,note:p}=await Go({target:{kind:"bulb",file:t},cwd:process.cwd()});c!==void 0&&f!==c&&d&&(console.error(`
2931
- 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(rd(++h));m(),console.log(`Loading ${jn.basename(t)}...`);let{html:g,bulb:v,serverExports:A}=await ef(t,e.watch,e.trust,r);Jt(a,t,v.server);let C=Pn(t),x=Pr(jn.resolve(t)),R=e.trust?void 0:fr(v),{port:I,onCleanup:L,handOver:T,pageCount:F}=await Ll({port:f,portNote:p,displayName:v.name,stopLog:i,makeServerOptions:ge=>({getHtml:()=>g,basePath:s,fsBase:Or(t),port:ge,reloadEmitter:o,sendChannel:!0,getServerExports:()=>A,getBulbBlocks:()=>({infer:v.infer,insight:v.insight,code:v.code,config:v.config,data:v.data}),saveInferenceResult:async(Le,ut)=>{let pe=await rn.readFile(t,"utf-8");Le!==void 0&&(pe=Wr(pe,"data",Le.join(Hg))),ut!==void 0&&(pe=Wr(pe,"insight",ut)),await rn.writeFile(t,pe)},localOverride:r?{name:r.name,serveDir:r.serveDir}:void 0,bulbAssets:{dir:C,remoteBase:x&&_i(x.userSlug,x.slug)},sourceFile:t,bulbKey:Rs(t),trusted:e.trust,trustHint:n}),makeEntry:(ge,Le)=>({pid:process.pid,port:ge,url:Le,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:jn.relative(process.cwd(),t)||jn.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:
2930
+ `)},onCleanup(h){u.push(h)}}}mn();import IN from"chokidar";import Tk from"node:fs";import $N from"node:path";var NN={persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}};function nn(t){let{target:e,onChange:n,events:r="change",debounceMs:s=150}=t,i,o=IN.watch(e,NN);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 LN=t=>process.platform==="win32"||process.platform==="darwin"?t.toLowerCase()==="assets":t==="assets";function Ck(t,e,n=150){let r,s=()=>{r&&clearTimeout(r),r=setTimeout(e,n)};try{let i=Tk.watch(t,{recursive:!0},(o,a)=>{a&&LN(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=$N.join(t,"assets");return Tk.existsSync(i)?nn({target:i,onChange:e,events:"all",debounceMs:n}):()=>{}}}je();Be();Ar();async function Ok(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=$s(process.pid),o=e.watch?new MN:void 0,a=be(e.mode),l=(await hn(process.cwd()))(t),c=await sr({kind:"bulb",file:t},process.cwd()),u=await ta(t,c);u.length&&console.log(`Replacing the running server for this bulb (pid ${u.map(ge=>ge.pid).join(", ")})`);let d=u.length>0||Date.now()-l<bw,{port:f,note:p}=await Go({target:{kind:"bulb",file:t},cwd:process.cwd()});c!==void 0&&f!==c&&d&&(console.error(`
2931
+ 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 m=0,h=()=>console.log(sd(++m));h(),console.log(`Loading ${Bn.basename(t)}...`);let{html:y,bulb:k,serverExports:T}=await tf(t,e.watch,e.trust,r);Jt(a,t,k.server);let P=Pn(t),E=Or(Bn.resolve(t)),O=e.trust?void 0:dr(k),{port:_,onCleanup:I,handOver:A,pageCount:M}=await Ll({port:f,portNote:p,displayName:k.name,stopLog:i,makeServerOptions:ge=>({getHtml:()=>y,basePath:s,fsBase:Cr(t),port:ge,reloadEmitter:o,sendChannel:!0,getServerExports:()=>T,getBulbBlocks:()=>({infer:k.infer,insight:k.insight,code:k.code,config:k.config,data:k.data}),saveInferenceResult:async(Le,ut)=>{let pe=await rn.readFile(t,"utf-8");Le!==void 0&&(pe=Wr(pe,"data",Le.join(Yg))),ut!==void 0&&(pe=Wr(pe,"insight",ut)),await rn.writeFile(t,pe)},localOverride:r?{name:r.name,serveDir:r.serveDir}:void 0,bulbAssets:{dir:P,remoteBase:E&&_i(E.userSlug,E.slug)},sourceFile:t,bulbKey:Rs(t),trusted:e.trust,trustHint:n}),makeEntry:(ge,Le)=>({pid:process.pid,port:ge,url:Le,file:t,cwd:process.cwd(),startedAt:Date.now(),trust:e.trust,mode:e.mode,predicted:O,watch:e.watch?void 0:!1,replace:e.local?`${e.local.name}=${e.local.dir}`:void 0}),waitTarget:Bn.relative(process.cwd(),t)||Bn.basename(t)});e.trust?console.log(" trust: granted (filesystem, AI, server.ts enabled)"):console.log(O?` trust: restricted \u2014 this bulb appears to use ${O}; re-run with --trust to enable it:
2932
2932
  ${n}
2933
2933
  `:` trust: restricted \u2014 re-run with --trust to enable filesystem / AI / server.ts
2934
2934
  `),e.watch&&console.log(` Watching for changes...
2935
- `);let H,ne,U=()=>{F()===0&&console.log(" No page attached \u2014 nothing reloaded; this change is not live."),o?.emit("reload")},re=ge=>{console.log(ge),m(),U()};if(e.watch&&o){let ge=0,Le=Promise.resolve();if(H=nn({target:t,onChange:()=>{let pe=++ge;Le=Le.then(async()=>{if(pe===ge)try{console.log("Recompiling...");let Ce=await ef(t,!0,e.trust,r);g=Ce.html,A=Ce.serverExports,v=Ce.bulb,Ce.buildError||m(),U()}catch(Ce){console.error("Recompile failed:",Ce)}})}}),r){let{name:pe,serveDir:Ce}=r;ne=nn({target:Ce,events:"all",onChange:()=>re(`Local package '${pe}' changed.`)})}let ut=Or(t);await rn.stat(ut).then(pe=>pe.isDirectory()).catch(()=>!1)&&L(vk(ut,()=>re("Assets changed.")))}H&&L(H),ne&&L(ne),L(()=>rn.rm(Zd(t),{force:!0})),await T({mode:e.open,fresh:!d,replacedLive:u.some(ge=>ge.port===I)})}Ze();import{readFileSync as Sp,copyFileSync as I1,existsSync as $1}from"fs";import*as me from"path";import{fileURLToPath as N1}from"url";import{EventEmitter as L1}from"events";import M1 from"open";mn();je();Tr();var vp=t=>`/agents/${t}/client.js`,R1=`
2935
+ `);let K,ne,U=()=>{M()===0&&console.log(" No page attached \u2014 nothing reloaded; this change is not live."),o?.emit("reload")},re=ge=>{console.log(ge),h(),U()};if(e.watch&&o){let ge=0,Le=Promise.resolve();if(K=nn({target:t,onChange:()=>{let pe=++ge;Le=Le.then(async()=>{if(pe===ge)try{console.log("Recompiling...");let Ce=await tf(t,!0,e.trust,r);y=Ce.html,T=Ce.serverExports,k=Ce.bulb,Ce.buildError||h(),U()}catch(Ce){console.error("Recompile failed:",Ce)}})}}),r){let{name:pe,serveDir:Ce}=r;ne=nn({target:Ce,events:"all",onChange:()=>re(`Local package '${pe}' changed.`)})}let ut=Cr(t);await rn.stat(ut).then(pe=>pe.isDirectory()).catch(()=>!1)&&I(Ck(ut,()=>re("Assets changed.")))}K&&I(K),ne&&I(ne),I(()=>rn.rm(ef(t),{force:!0})),await A({mode:e.open,fresh:!d,replacedLive:u.some(ge=>ge.port===_)})}Ze();import{readFileSync as xp,copyFileSync as BN,existsSync as jN}from"fs";import*as me from"path";import{fileURLToPath as FN}from"url";import{EventEmitter as UN}from"events";import qN from"open";mn();je();Ar();var kp=t=>`/agents/${t}/client.js`,DN=`
2936
2936
  (() => {
2937
2937
  const api = async (name, ...args) => {
2938
2938
  const resp = await fetch('/__api/' + name, {
@@ -2964,7 +2964,7 @@ Port ${c} is this bulb's, and a page of it may be waiting there, but something e
2964
2964
  ${Oa()}
2965
2965
  }
2966
2966
  })();
2967
- `;function kk(t){let{name:e,agent:n,styles:r,katex:s,mountHtml:i,watch:o,theme:a}=t,l=vp(n);return`<!DOCTYPE html>
2967
+ `;function Pk(t){let{name:e,agent:n,styles:r,katex:s,mountHtml:i,watch:o,theme:a}=t,l=kp(n);return`<!DOCTYPE html>
2968
2968
  <html>
2969
2969
  <head>
2970
2970
  <meta charset="utf-8">
@@ -2987,18 +2987,18 @@ ${i}
2987
2987
  ${o?"<script>window.__TYPEBULB_WATCH__ = true;</script>":""}
2988
2988
 
2989
2989
  <script>
2990
- ${R1}
2990
+ ${DN}
2991
2991
  </script>
2992
2992
 
2993
2993
  <script type="module" src="${l}"></script>
2994
2994
  </body>
2995
- </html>`}async function xk(t){let e=process.cwd(),n=t.agentTarget;lS(n)||(console.error(`Unknown agent '${n}'. Known: ${jr().join(", ")}.`),process.exit(1));let r=await ea(e,n);if(r){console.log(`Mirror '${n}' is already running for this project:
2996
- ${r.url}`),t.open==="window"&&await M1(r.url);return}let s=$s(process.pid),i=t.watch?new L1:void 0,o=be(t.mode),a=await cS(n),l=a.displayName||`${n} mirror`;Jt(o,me.join(e,"mirror"));let c=me.dirname(N1(import.meta.url)),u=me.join(c,"agents",n),d=me.join(c,"..","cli","agents"),f=me.join(u,"styles.css"),p=me.join(u,"katex.min.css"),h=me.join(u,"index.html"),m=()=>kk({name:l,agent:n,styles:Sp(f,"utf8"),katex:Sp(p,"utf8"),mountHtml:Sp(h,"utf8"),watch:t.watch}),{port:g,note:v}=await Go({explicit:t.port,target:{kind:"mirror",agent:n},cwd:e}),{port:A,url:C,onCleanup:x,handOver:R,pageCount:I}=await Ll({port:g,portNote:v,displayName:l,stopLog:s,waitTarget:"agent",makeServerOptions:U=>({getHtml:m,basePath:e,port:U,reloadEmitter:i,getServerExports:()=>a,trusted:!0,staticAssets:{mount:`${me.posix.dirname(vp(n))}/`,dir:u}}),makeEntry:(U,re)=>({pid:process.pid,port:U,url:re,file:`agent:${n}`,cwd:e,startedAt:Date.now(),trust:!0,agent:n})}),L=me.join(d,n,"client"),T=me.join(d,"core","client"),F=$1(L);t.watch&&F&&console.log(` Watching for changes...
2997
- `);async function H(){await(await import("esbuild")).build({entryPoints:[me.join(L,"index.ts")],bundle:!0,platform:"browser",format:"esm",outfile:me.join(u,"client.js")});for(let re of["styles.css","index.html","typebulb.png","typebulb-inv.png"])I1(me.join(T,re),me.join(u,re))}let ne;if(t.watch&&F&&i){let U=!1;ne=nn({target:d,events:"all",onChange:async()=>{if(!U){U=!0;try{await H(),console.log(I()?`Mirror rebuilt. Reloading.
2995
+ </html>`}async function _k(t){let e=process.cwd(),n=t.agentTarget;mS(n)||(console.error(`Unknown agent '${n}'. Known: ${jr().join(", ")}.`),process.exit(1));let r=await ea(e,n);if(r){console.log(`Mirror '${n}' is already running for this project:
2996
+ ${r.url}`),t.open==="window"&&await qN(r.url);return}let s=$s(process.pid),i=t.watch?new UN:void 0,o=be(t.mode),a=await gS(n),l=a.displayName||`${n} mirror`;Jt(o,me.join(e,"mirror"));let c=me.dirname(FN(import.meta.url)),u=me.join(c,"agents",n),d=me.join(c,"..","cli","agents"),f=me.join(u,"styles.css"),p=me.join(u,"katex.min.css"),m=me.join(u,"index.html"),h=()=>Pk({name:l,agent:n,styles:xp(f,"utf8"),katex:xp(p,"utf8"),mountHtml:xp(m,"utf8"),watch:t.watch}),{port:y,note:k}=await Go({explicit:t.port,target:{kind:"mirror",agent:n},cwd:e}),{port:T,url:P,onCleanup:E,handOver:O,pageCount:_}=await Ll({port:y,portNote:k,displayName:l,stopLog:s,waitTarget:"agent",makeServerOptions:U=>({getHtml:h,basePath:e,port:U,reloadEmitter:i,getServerExports:()=>a,trusted:!0,staticAssets:{mount:`${me.posix.dirname(kp(n))}/`,dir:u}}),makeEntry:(U,re)=>({pid:process.pid,port:U,url:re,file:`agent:${n}`,cwd:e,startedAt:Date.now(),trust:!0,agent:n})}),I=me.join(d,n,"client"),A=me.join(d,"core","client"),M=jN(I);t.watch&&M&&console.log(` Watching for changes...
2997
+ `);async function K(){await(await import("esbuild")).build({entryPoints:[me.join(I,"index.ts")],bundle:!0,platform:"browser",format:"esm",outfile:me.join(u,"client.js")});for(let re of["styles.css","index.html","typebulb.png","typebulb-inv.png"])BN(me.join(A,re),me.join(u,re))}let ne;if(t.watch&&M&&i){let U=!1;ne=nn({target:d,events:"all",onChange:async()=>{if(!U){U=!0;try{await K(),console.log(_()?`Mirror rebuilt. Reloading.
2998
2998
  `:`Mirror rebuilt. No tab open on it \u2014 nobody is reading this.
2999
- `),i.emit("reload")}catch(re){console.error("Mirror rebuild failed:",re instanceof Error?re.message:re)}finally{U=!1}}}})}await R({mode:t.open,fresh:!1,replacedLive:!1}),x(()=>a.shutdownSwitcher?.()),x(()=>a.shutdownComposer?.()),ne&&x(ne)}Ze();xt();import*as Ek from"path";async function Ak(t,e,n,r){let s=be(n),i=!1,o=async()=>{let{bulb:a,config:l}=await nt(t);i||(Jt(s,t,a.server),i=!0),await ei(a.server,t,r,l.dependencies)};if(console.log(`Running ${Ek.basename(t)}...`),await o(),e){console.log(`Watching for changes...
3000
- `);let a=0,l=Promise.resolve();nn({target:t,onChange:()=>{let c=++a;l=l.then(async()=>{if(c===a)try{console.log("Re-running..."),await o()}catch(u){console.error("Error:",u)}})}})}}Ze();xt();import{Console as D1}from"node:console";je();async function Ok(t,e,n,r){q1();try{let f=yn(await G(),t)[0];f&&(Is(f.pid,Xe(f.pid).offset),console.error(`note: 'call' boots a fresh server.ts instance; the running server (${f.url}) is not contacted \u2014 state shared with it must live on disk.`))}catch{}let s=be(n),{bulb:i,config:o}=await nt(t);i.server||ki("This bulb has no **server.ts** block; nothing to call."),Jt(s,t,i.server);let a;try{a=await ei(i.server,t,r,o.dependencies)}catch(f){ki(f instanceof Error?f.message:String(f))}let l=$l(a,e.fn);if(!l){let f=[...Object.keys(a).filter(p=>typeof a[p]=="function"),...Object.keys(Il)];ki(`Function '${e.fn}' not found. Available: ${f.length?f.join(", "):"(none)"}.`)}let c=await B1(e);if(Nl(l)){try{for await(let f of l(...c))await Ck(JSON.stringify(f,Pk)+`
3001
- `)}catch(f){ki(f instanceof Error?f.stack??f.message:String(f))}return Tk(0)}let u;try{u=await l(...c)}catch(f){ki(f instanceof Error?f.stack??f.message:String(f))}let d=U1(u);d!==void 0&&await Ck(d+`
3002
- `),Tk(0)}function Tk(t){process.exitCode=t,setTimeout(()=>process.exit(t),2e3).unref?.()}async function B1(t){if(t.hasArgsFlag){let e=t.argsJson??"";return e==="-"&&(e=await qr()),F1(e)}return j1(t.positional)}function j1(t){return t.map(e=>{try{return JSON.parse(e)}catch{return e}})}function F1(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 U1(t){if(t!==void 0)return JSON.stringify(t,Pk,2)}function Pk(t,e){return typeof e=="bigint"?e.toString():e}function ki(t){process.stderr.write(t+`
3003
- `),process.exit(1)}function q1(){let t=new D1(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 Ck(t){return new Promise((e,n)=>{process.stdout.write(t,r=>r?n(r):e())})}Xo();for(let t of[process.stdout,process.stderr])t.on("error",e=>{if(e?.code!=="EPIPE")throw e});function _k(t,e){t||(console.error(`This bulb runs server-side Node code (server.ts), which --trust must authorize:
3004
- ${e}`),process.exit(1))}async function J1(){let t=fS(process.argv.slice(2));if(t.version&&(console.log(`typebulb ${Ae}`),process.exit(0)),t.help&&(pS(),process.exit(0)),uS(),t.subcommand==="logs"){await HS(t.file||void 0,{follow:t.follow,clear:t.clear,run:t.run,lines:t.lines});return}if(t.subcommand==="wait"){await zS(t.file||void 0,{match:t.match,timeoutSec:t.timeoutSec,wake:t.wake});return}if(t.subcommand==="stop"){t.stopScope?await GS(t.stopScope):await VS(t.file||void 0);return}if(t.subcommand==="restart"){await XS(t.file||void 0,t.stopScope);return}if(t.subcommand==="babysit"){await lk(t.mode);return}if(t.subcommand==="send"){await ZS(t.file,t.sendMessage,t.sendWaitMs??0);return}if(t.subcommand==="models"){await jS(t.mode);return}if(t.subcommand==="slug"){FS(t.slugName);return}if(t.subcommand==="status"){await ik(t.statusQuery,t.mode);return}if(t.subcommand==="pull"){await xw(t.file||void 0,{force:t.force,mode:t.mode});return}if(t.subcommand==="push"){await Aw(t.file||void 0,{force:t.force,mode:t.mode});return}if(t.subcommand==="agent"){await(t.agentTarget?xk(t):BS(Ae));return}if(t.subcommand==="trust"||t.subcommand==="untrust"){await NS(t.file||void 0,t.subcommand==="trust");return}let e;if(!t.file||t.file==="."){let l=await Sw(process.cwd());l||(console.error("No .bulb.md file found in current directory"),process.exit(1)),e=l}else e=Ct.resolve(t.file);if(await Rk.access(e).then(()=>!0,()=>!1)||(jr().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}`+(Ct.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 tk(e,t.blockKind);return}if(t.subcommand==="put"){await sk(e,t.blockPairs);return}let r=t.file&&t.file!=="."?t.file:Ct.relative(process.cwd(),e)||Ct.basename(e),s=`npx typebulb --trust ${r.includes(" ")?`"${r}"`:r}`;if(t.subcommand==="predict"){await $S(e,s);return}let i=!t.noTrust&&Sn(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 nt(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 _p(t.local)}catch(l){console.error(l instanceof Error?l.message:String(l)),process.exit(1)}console.error(`replace: ${a.name} \u2192 ${Ct.relative(process.cwd(),a.dir)||"."}`)}if(t.subcommand==="check"){await IS(e,a);return}if(t.subcommand==="call"){_k(t.trust,s),await Ok(e,{fn:t.fn,positional:t.callArgs,argsJson:t.argsJson,hasArgsFlag:t.hasArgsFlag},t.mode,a);return}if(o&&o.bulb.server&&(na(o.bulb)||t.server)){_k(t.trust,s),await Ak(e,t.watch,t.mode,a);return}await Sk(e,t,s,a)}J1().catch(t=>{console.error("Error:",t.message),process.exit(1)});
2999
+ `),i.emit("reload")}catch(re){console.error("Mirror rebuild failed:",re instanceof Error?re.message:re)}finally{U=!1}}}})}await O({mode:t.open,fresh:!1,replacedLive:!1}),E(()=>a.shutdownSwitcher?.()),E(()=>a.shutdownComposer?.()),ne&&E(ne)}Ze();xt();import*as Rk from"path";async function Ik(t,e,n,r){let s=be(n),i=!1,o=async()=>{let{bulb:a,config:l}=await nt(t);i||(Jt(s,t,a.server),i=!0),await ei(a.server,t,r,l.dependencies)};if(console.log(`Running ${Rk.basename(t)}...`),await o(),e){console.log(`Watching for changes...
3000
+ `);let a=0,l=Promise.resolve();nn({target:t,onChange:()=>{let c=++a;l=l.then(async()=>{if(c===a)try{console.log("Re-running..."),await o()}catch(u){console.error("Error:",u)}})}})}}Ze();xt();import{Console as JN}from"node:console";je();async function Lk(t,e,n,r){YN();try{let f=yn(await G(),t)[0];f&&(Is(f.pid,Xe(f.pid).offset),console.error(`note: 'call' boots a fresh server.ts instance; the running server (${f.url}) is not contacted \u2014 state shared with it must live on disk.`))}catch{}let s=be(n),{bulb:i,config:o}=await nt(t);i.server||ki("This bulb has no **server.ts** block; nothing to call."),Jt(s,t,i.server);let a;try{a=await ei(i.server,t,r,o.dependencies)}catch(f){ki(f instanceof Error?f.message:String(f))}let l=$l(a,e.fn);if(!l){let f=[...Object.keys(a).filter(p=>typeof a[p]=="function"),...Object.keys(Il)];ki(`Function '${e.fn}' not found. Available: ${f.length?f.join(", "):"(none)"}.`)}let c=await WN(e);if(Nl(l)){try{for await(let f of l(...c))await Nk(JSON.stringify(f,Mk)+`
3001
+ `)}catch(f){ki(f instanceof Error?f.stack??f.message:String(f))}return $k(0)}let u;try{u=await l(...c)}catch(f){ki(f instanceof Error?f.stack??f.message:String(f))}let d=zN(u);d!==void 0&&await Nk(d+`
3002
+ `),$k(0)}function $k(t){process.exitCode=t,setTimeout(()=>process.exit(t),2e3).unref?.()}async function WN(t){if(t.hasArgsFlag){let e=t.argsJson??"";return e==="-"&&(e=await qr()),HN(e)}return KN(t.positional)}function KN(t){return t.map(e=>{try{return JSON.parse(e)}catch{return e}})}function HN(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 zN(t){if(t!==void 0)return JSON.stringify(t,Mk,2)}function Mk(t,e){return typeof e=="bigint"?e.toString():e}function ki(t){process.stderr.write(t+`
3003
+ `),process.exit(1)}function YN(){let t=new JN(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 Nk(t){return new Promise((e,n)=>{process.stdout.write(t,r=>r?n(r):e())})}Xo();for(let t of[process.stdout,process.stderr])t.on("error",e=>{if(e?.code!=="EPIPE")throw e});function Dk(t,e){t||(console.error(`This bulb runs server-side Node code (server.ts), which --trust must authorize:
3004
+ ${e}`),process.exit(1))}async function VN(){let t=wS(process.argv.slice(2));if(t.version&&(console.log(`typebulb ${Ae}`),process.exit(0)),t.help&&(vS(),process.exit(0)),yS(),t.subcommand==="logs"){await ZS(t.file||void 0,{follow:t.follow,clear:t.clear,run:t.run,lines:t.lines});return}if(t.subcommand==="wait"){await ek(t.file||void 0,{match:t.match,timeoutSec:t.timeoutSec,wake:t.wake});return}if(t.subcommand==="stop"){t.stopScope?await rk(t.stopScope):await nk(t.file||void 0);return}if(t.subcommand==="restart"){await sk(t.file||void 0,t.stopScope);return}if(t.subcommand==="babysit"){await mk(t.mode);return}if(t.subcommand==="send"){await ok(t.file,t.sendMessage,t.sendWaitMs??0);return}if(t.subcommand==="models"){await HS(t.mode);return}if(t.subcommand==="slug"){zS(t.slugName);return}if(t.subcommand==="status"){await fk(t.statusQuery,t.mode);return}if(t.subcommand==="pull"){await Pw(t.file||void 0,{force:t.force,mode:t.mode});return}if(t.subcommand==="push"){await Rw(t.file||void 0,{force:t.force,mode:t.mode});return}if(t.subcommand==="agent"){await(t.agentTarget?_k(t):KS(Ae));return}if(t.subcommand==="trust"||t.subcommand==="untrust"){await US(t.file||void 0,t.subcommand==="trust");return}let e;if(!t.file||t.file==="."){let l=await Cw(process.cwd());l||(console.error("No .bulb.md file found in current directory"),process.exit(1)),e=l}else e=Ct.resolve(t.file);if(await Bk.access(e).then(()=>!0,()=>!1)||(jr().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}`+(Ct.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 lk(e,t.blockKind);return}if(t.subcommand==="put"){await dk(e,t.blockPairs);return}let r=t.file&&t.file!=="."?t.file:Ct.relative(process.cwd(),e)||Ct.basename(e),s=`npx typebulb --trust ${r.includes(" ")?`"${r}"`:r}`;if(t.subcommand==="predict"){await FS(e,s);return}let i=!t.noTrust&&Sn(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 nt(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 Ip(t.local)}catch(l){console.error(l instanceof Error?l.message:String(l)),process.exit(1)}console.error(`replace: ${a.name} \u2192 ${Ct.relative(process.cwd(),a.dir)||"."}`)}if(t.subcommand==="check"){await jS(e,a);return}if(t.subcommand==="call"){Dk(t.trust,s),await Lk(e,{fn:t.fn,positional:t.callArgs,argsJson:t.argsJson,hasArgsFlag:t.hasArgsFlag},t.mode,a);return}if(o&&o.bulb.server&&(na(o.bulb)||t.server)){Dk(t.trust,s),await Ik(e,t.watch,t.mode,a);return}await Ok(e,t,s,a)}VN().catch(t=>{console.error("Error:",t.message),process.exit(1)});