typebulb 0.61.13 → 0.62.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/SKILL.md +4 -4
- package/dist/agents/claude/client.js +246 -256
- package/dist/agents/claude/styles.css +50 -61
- package/dist/agents/codex/client.js +290 -300
- package/dist/agents/codex/styles.css +50 -61
- package/dist/agents/pi/client.js +260 -270
- package/dist/agents/pi/styles.css +50 -61
- package/dist/index.js +275 -319
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,176 +1,176 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __cr } from 'module'; const require = __cr(import.meta.url);
|
|
3
|
-
var
|
|
4
|
-
`),n=0;if(e[n]?.trim()!=="---")return{reason:
|
|
5
|
-
`)),a.set(
|
|
6
|
-
`),n=[],r=0;for(;r<e.length;){if(e[r]?.trim()!=="---"){r++;continue}let s=
|
|
3
|
+
var pk=Object.create;var _l=Object.defineProperty;var hk=Object.getOwnPropertyDescriptor;var mk=Object.getOwnPropertyNames;var gk=Object.getPrototypeOf,yk=Object.prototype.hasOwnProperty;var vi=(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),Si=(t,e)=>{for(var n in e)_l(t,n,{get:e[n],enumerable:!0})},bk=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of mk(e))!yk.call(t,s)&&s!==n&&_l(t,s,{get:()=>e[s],enumerable:!(r=hk(e,s))||r.enumerable});return t};var wk=(t,e,n)=>(n=t!=null?pk(gk(t)):{},bk(e||!t||!t.__esModule?_l(n,"default",{value:t,enumerable:!0}):n,t));import*as dp from"fs/promises";import{existsSync as Ln,readFileSync as vk}from"fs";import*as oe from"path";import{pathToFileURL as Sk}from"url";import{resolve as Il}from"resolve.exports";import{init as fp,parse as pp}from"es-module-lexer";function hp(t,e){let n=oe.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 mp(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:oe.resolve(r)}}async function gp(t){let{name:e,dir:n}=t;if(!Ln(n))throw new Error(`--replace path for '${e}' does not exist: ${n}`);let r=hp(n,e),s=kk(r,e),i=oe.resolve(n,s);if(!Ln(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=oe.dirname(i),a=`/local/${e}/${oe.basename(i)}`,l=xk(r,n);return await Ek(e,i,o),{name:e,dir:n,entryAbs:i,serveDir:o,entryUrl:a,typesAbs:l}}function kk(t,e){if(t.exports!==void 0){let r;try{r=Il(t,".",{browser:!0,conditions:Rl})}catch(i){throw new Error(`--replace package '${e}' "exports" does not resolve a browser entry (conditions: ${Rl.join(", ")}): ${i instanceof Error?i.message:i}`)}let s=Nl(r);if(!s)throw new Error(`--replace package '${e}' "exports" did not resolve "." to a single file (conditions: ${Rl.join(", ")}); too complex to override.`);return s}let n=t.module??t.main;if(!n)throw new Error(`--replace package '${e}' has no "exports", "module", or "main" entry to resolve.`);return n}function xk(t,e){if(t.exports!==void 0)try{let r=Il(t,".",{conditions:["types"]}),s=Nl(r);if(s){let i=oe.resolve(e,s);if(Ln(i))return i}}catch{}let n=t.types??t.typings;if(n){let r=oe.resolve(e,n);if(Ln(r))return r}}function Nl(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.find(e=>typeof e=="string")}async function Ek(t,e,n){await fp;let r=oe.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 dp.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=Ak(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 Ak(t,e,n){let r=e.replace(/[?#].*$/,""),s=oe.resolve(oe.dirname(t),r),i=[s,s+".js",s+".mjs",oe.join(s,"index.js"),oe.join(s,"index.mjs")];for(let o of i)if(oe.normalize(o).startsWith(n)&&Ln(o))return o}function Tk(t,e,n){let r=hp(t,e),s;if(r.exports!==void 0)try{s=Nl(Il(r,n,{conditions:up}))}catch(o){throw new Error(`--replace package '${e}' "exports" does not resolve a node entry for '${n}' (conditions: ${up.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=oe.resolve(t,s);if(!Ln(i))throw new Error(`--replace package '${e}' built file not found: ${i} \u2014 did you build it (e.g. \`pnpm run build\`)?`);return Sk(i).href}async function yp(t,e){await fp;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=Tk(e.dir,e.name,a);r+=t.slice(s,i.s)+l,s=i.e}return r+t.slice(s)}var Rl,up,ki=v(()=>{"use strict";Rl=["browser","import","default"],up=["node","import","default"]});function bp(t){return We.find(e=>ue[e].path===t)}function vp(t){return!!t?.startsWith("typebulb")}var ue,We,wp,xi=v(()=>{ue={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"}},We=["code","css","html","data","infer","insight","config","notes"];wp="typebulb/v1"});function $l(t){return/[:\n"']/.test(t)||t.startsWith(" ")||t.endsWith(" ")?`"${t.replace(/"/g,'\\"')}"`:t}function Ll(t){return t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1).replace(/\\"/g,'"'):t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}var Ei=v(()=>{});function Mn(t){let e=kp(t);if("reason"in e)throw new Error(`Invalid .bulb.md file format: ${e.reason}`);return e.bulb}function Ke(t){let e=kp(t);return"bulb"in e?e.bulb:void 0}function kp(t){try{let e=t.split(`
|
|
4
|
+
`),n=0;if(e[n]?.trim()!=="---")return{reason:Pk(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=Rk(r);if(!vp(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(Sp);if(d){let f=d[1].trim();for(n++;n<e.length&&e[n]?.trim()==="";)n++;let p=e[n]?.match(Ai);if(!p){l.push(`**${f}** has no code fence \u2014 block skipped`);continue}let h=p[1];n++;let m=n+1,y=[],k=Ml(h);for(;n<e.length&&!e[n]?.match(k);)y.push(e[n]),n++;let A=n<e.length;n++,l.push(...Ck(f,y,A)),o.set(f,y.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 Pk(t,e){let n=Ik(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 Ck(t,e,n){let r=[];for(let s=0;s<e.length;s++){let i=e[s]?.trim().match(Sp);i&&Ok.has(i[1].trim())&&_k(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 _k(t,e){let n=e+1;for(;n<t.length&&t[n]?.trim()==="";)n++;return!!t[n]?.match(Ai)}function Rk(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=Ll(i);break}}return e}function xp(t){return Ke(t)?.warnings??[]}function Ik(t){let e=t.split(`
|
|
6
|
+
`),n=[],r=0;for(;r<e.length;){if(e[r]?.trim()!=="---"){r++;continue}let s=Ke(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
|
|
8
|
+
`)}),r=i}else r++}return n}function Ep(t){let e=Object.fromEntries(We.map(n=>[n,t.files.get(ue[n].path)||""]));return{name:t.frontmatter.name,...e}}var Sp,Ai,Ok,Ml,Dl=v(()=>{xi();Ei();Sp=/^\*\*(.+)\*\*$/,Ai=/^(`{3,})(\w*)\s*$/,Ok=new Set(We.map(t=>ue[t].path)),Ml=t=>new RegExp(`^${t}\\s*$`)});function Ap(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 Tp(t,e){let{path:n}=ue[t],r=n.split(".").pop(),s=Ap(e);return`**${n}**
|
|
9
9
|
|
|
10
10
|
${s}${r}
|
|
11
11
|
${e}
|
|
12
|
-
${s}`}function
|
|
13
|
-
`)}function
|
|
14
|
-
`),s=
|
|
12
|
+
${s}`}function Op(t){let e=We.filter(n=>t[n]).map(n=>Tp(n,t[n]));return["---",`format: ${wp}`,`name: ${$l(t.name)}`,"---","",...e].join(`
|
|
13
|
+
`)}function Pp(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(Ai);if(!s)continue;let i=Ml(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 Fr(t,e,n){let r=t.split(`
|
|
14
|
+
`),s=Pp(r,ue[e].path);if(s==="unterminated")return t;if(!s)return`${t.replace(/\s*$/,"")}
|
|
15
15
|
|
|
16
|
-
${
|
|
17
|
-
`;let i=
|
|
16
|
+
${Tp(e,n)}
|
|
17
|
+
`;let i=Ap(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
|
|
20
|
-
`),r=
|
|
19
|
+
`)}function Cp(t,e){let n=t.split(`
|
|
20
|
+
`),r=Pp(n,ue[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
|
|
23
|
-
>/]`,i);if(r&&console.log("[xml-utils] start:",o),o===-1)return;let a=t.slice(o+e.length),l=
|
|
24
|
-
>]`),
|
|
25
|
-
`)}};
|
|
26
|
-
`)?
|
|
22
|
+
`}var _p=v(()=>{xi();Dl();Ei()});function Ur(t){if(!t.trim())return{};try{return JSON.parse(t)}catch{return{}}}function Ip(t){switch(Rp(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 Np(t){let e=Rp(t);return e!==void 0&&$k.has(e)?e:void 0}function Mk(t){return t.replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\*\*([^*]+)\*\*/g,"$1").replace(/\*([^*]+)\*/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/^#{1,6}\s+/gm,"")}function Bl(t){let e=Ur(t??"").description?.trim();if(!e)return Lk;let n=Mk(e);return(n.length>200?n.slice(0,197)+"...":n).replace(/\n/g," ")}var Nk,Ti,Rp,$k,Lk,$p=v(()=>{Nk="https://assets.typebulb.com",Ti=(t,e)=>`${Nk}/u/${encodeURIComponent(t)}/${encodeURIComponent(e)}/`,Rp=t=>/\.[^./\\]+$/.exec(t)?.[0]?.toLowerCase();$k=new Set([".html",".htm",".xhtml",".js",".mjs",".cjs",".ts",".tsx",".css"]);Lk="A Typebulb bulb."});var Lp=v(()=>{});function jl(t,e,n){let s=new RegExp(e).exec(t.slice(n));return s?n+s.index:-1}var Mp=v(()=>{});function qr(t,e,n){let s=new RegExp(e).exec(t.slice(n));return s?n+s.index+s[0].length-1:-1}var Dp=v(()=>{});function Oi(t,e){let n=new RegExp(e,"g"),r=t.match(n);return r?r.length:0}var Bp=v(()=>{});function Jr(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=jl(t,`<${e}[
|
|
23
|
+
>/]`,i);if(r&&console.log("[xml-utils] start:",o),o===-1)return;let a=t.slice(o+e.length),l=qr(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=qr(a,"[ /]"+e+">",p))!==-1;){let y=a.substring(p,l+1);if(h+=Oi(y,"<"+e+`[
|
|
24
|
+
>]`),m+=Oi(y,"</"+e+">"),m>=h)break;p=l}}else l=qr(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 Fl=v(()=>{Mp();Dp();Bp()});var Ul=v(()=>{Fl()});var ql=v(()=>{Ul()});var jp=v(()=>{ql()});var Fp=v(()=>{});var Up=v(()=>{Lp();Fl();Ul();jp();ql();Fp()});var J=_(pe=>{"use strict";var Jl=Symbol.for("yaml.alias"),qp=Symbol.for("yaml.document"),Pi=Symbol.for("yaml.map"),Jp=Symbol.for("yaml.pair"),Wl=Symbol.for("yaml.scalar"),Ci=Symbol.for("yaml.seq"),ut=Symbol.for("yaml.node.type"),jk=t=>!!t&&typeof t=="object"&&t[ut]===Jl,Fk=t=>!!t&&typeof t=="object"&&t[ut]===qp,Uk=t=>!!t&&typeof t=="object"&&t[ut]===Pi,qk=t=>!!t&&typeof t=="object"&&t[ut]===Jp,Wp=t=>!!t&&typeof t=="object"&&t[ut]===Wl,Jk=t=>!!t&&typeof t=="object"&&t[ut]===Ci;function Kp(t){if(t&&typeof t=="object")switch(t[ut]){case Pi:case Ci:return!0}return!1}function Wk(t){if(t&&typeof t=="object")switch(t[ut]){case Jl:case Pi:case Wl:case Ci:return!0}return!1}var Kk=t=>(Wp(t)||Kp(t))&&!!t.anchor;pe.ALIAS=Jl;pe.DOC=qp;pe.MAP=Pi;pe.NODE_TYPE=ut;pe.PAIR=Jp;pe.SCALAR=Wl;pe.SEQ=Ci;pe.hasAnchor=Kk;pe.isAlias=jk;pe.isCollection=Kp;pe.isDocument=Fk;pe.isMap=Uk;pe.isNode=Wk;pe.isPair=qk;pe.isScalar=Wp;pe.isSeq=Jk});var Wr=_(Kl=>{"use strict";var ae=J(),ve=Symbol("break visit"),Hp=Symbol("skip children"),tt=Symbol("remove node");function _i(t,e){let n=zp(e);ae.isDocument(t)?Dn(null,t.contents,n,Object.freeze([t]))===tt&&(t.contents=null):Dn(null,t,n,Object.freeze([]))}_i.BREAK=ve;_i.SKIP=Hp;_i.REMOVE=tt;function Dn(t,e,n,r){let s=Yp(t,e,n,r);if(ae.isNode(s)||ae.isPair(s))return Vp(t,r,s),Dn(t,s,n,r);if(typeof s!="symbol"){if(ae.isCollection(e)){r=Object.freeze(r.concat(e));for(let i=0;i<e.items.length;++i){let o=Dn(i,e.items[i],n,r);if(typeof o=="number")i=o-1;else{if(o===ve)return ve;o===tt&&(e.items.splice(i,1),i-=1)}}}else if(ae.isPair(e)){r=Object.freeze(r.concat(e));let i=Dn("key",e.key,n,r);if(i===ve)return ve;i===tt&&(e.key=null);let o=Dn("value",e.value,n,r);if(o===ve)return ve;o===tt&&(e.value=null)}}return s}async function Ri(t,e){let n=zp(e);ae.isDocument(t)?await Bn(null,t.contents,n,Object.freeze([t]))===tt&&(t.contents=null):await Bn(null,t,n,Object.freeze([]))}Ri.BREAK=ve;Ri.SKIP=Hp;Ri.REMOVE=tt;async function Bn(t,e,n,r){let s=await Yp(t,e,n,r);if(ae.isNode(s)||ae.isPair(s))return Vp(t,r,s),Bn(t,s,n,r);if(typeof s!="symbol"){if(ae.isCollection(e)){r=Object.freeze(r.concat(e));for(let i=0;i<e.items.length;++i){let o=await Bn(i,e.items[i],n,r);if(typeof o=="number")i=o-1;else{if(o===ve)return ve;o===tt&&(e.items.splice(i,1),i-=1)}}}else if(ae.isPair(e)){r=Object.freeze(r.concat(e));let i=await Bn("key",e.key,n,r);if(i===ve)return ve;i===tt&&(e.key=null);let o=await Bn("value",e.value,n,r);if(o===ve)return ve;o===tt&&(e.value=null)}}return s}function zp(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 Yp(t,e,n,r){if(typeof n=="function")return n(t,e,r);if(ae.isMap(e))return n.Map?.(t,e,r);if(ae.isSeq(e))return n.Seq?.(t,e,r);if(ae.isPair(e))return n.Pair?.(t,e,r);if(ae.isScalar(e))return n.Scalar?.(t,e,r);if(ae.isAlias(e))return n.Alias?.(t,e,r)}function Vp(t,e,n){let r=e[e.length-1];if(ae.isCollection(r))r.items[t]=n;else if(ae.isPair(r))t==="key"?r.key=n:r.value=n;else if(ae.isDocument(r))r.contents=n;else{let s=ae.isAlias(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${s} parent`)}}Kl.visit=_i;Kl.visitAsync=Ri});var Hl=_(Xp=>{"use strict";var Gp=J(),Hk=Wr(),zk={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Yk=t=>t.replace(/[!,[\]{}]/g,e=>zk[e]),Kr=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+Yk(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&&Gp.isNode(e.contents)){let i={};Hk.visit(e.contents,(o,a)=>{Gp.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
|
+
`)}};Kr.defaultYaml={explicit:!1,version:"1.2"};Kr.defaultTags={"!!":"tag:yaml.org,2002:"};Xp.Directives=Kr});var Ii=_(Hr=>{"use strict";var Qp=J(),Vk=Wr();function Gk(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 Zp(t){let e=new Set;return Vk.visit(t,{Value(n,r){r.anchor&&e.add(r.anchor)}}),e}function eh(t,e){for(let n=1;;++n){let r=`${t}${n}`;if(!e.has(r))return r}}function Xk(t,e){let n=[],r=new Map,s=null;return{onAnchor:i=>{n.push(i),s??(s=Zp(t));let o=eh(e,s);return s.add(o),o},setAnchors:()=>{for(let i of n){let o=r.get(i);if(typeof o=="object"&&o.anchor&&(Qp.isScalar(o.node)||Qp.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}}Hr.anchorIsValid=Gk;Hr.anchorNames=Zp;Hr.createNodeAnchors=Xk;Hr.findNewAnchor=eh});var zl=_(th=>{"use strict";function zr(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=zr(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=zr(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=zr(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=zr(t,r,s,i);o===void 0?delete r[s]:o!==i&&(r[s]=o)}return t.call(e,n,r)}th.applyReviver=zr});var Ct=_(rh=>{"use strict";var Qk=J();function nh(t,e,n){if(Array.isArray(t))return t.map((r,s)=>nh(r,String(s),n));if(t&&typeof t.toJSON=="function"){if(!n||!Qk.hasAnchor(t))return t.toJSON(e,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(t,r),n.onCreate=i=>{r.res=i,delete n.onCreate};let s=t.toJSON(e,n);return n.onCreate&&n.onCreate(s),s}return typeof t=="bigint"&&!n?.keep?Number(t):t}rh.toJS=nh});var Ni=_(ih=>{"use strict";var Zk=zl(),sh=J(),ex=Ct(),Yl=class{constructor(e){Object.defineProperty(this,sh.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(!sh.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=ex.toJS(this,"",o);if(typeof s=="function")for(let{count:l,res:c}of o.anchors.values())s(c,l);return typeof i=="function"?Zk.applyReviver(i,{"":a},"",a):a}};ih.NodeBase=Yl});var Yr=_(oh=>{"use strict";var tx=Ii(),nx=Wr(),jn=J(),rx=Ni(),sx=Ct(),Vl=class extends rx.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=[],nx.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||(sx.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=$i(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(tx.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 $i(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=$i(t,s,n);i>r&&(r=i)}return r}else if(jn.isPair(e)){let r=$i(t,e.key,n),s=$i(t,e.value,n);return Math.max(r,s)}return 1}oh.Alias=Vl});var se=_(Gl=>{"use strict";var ix=J(),ox=Ni(),ax=Ct(),lx=t=>!t||typeof t!="function"&&typeof t!="object",_t=class extends ox.NodeBase{constructor(e){super(ix.SCALAR),this.value=e}toJSON(e,n){return n?.keep?this.value:ax.toJS(this.value,e,n)}toString(){return String(this.value)}};_t.BLOCK_FOLDED="BLOCK_FOLDED";_t.BLOCK_LITERAL="BLOCK_LITERAL";_t.PLAIN="PLAIN";_t.QUOTE_DOUBLE="QUOTE_DOUBLE";_t.QUOTE_SINGLE="QUOTE_SINGLE";Gl.Scalar=_t;Gl.isScalarValue=lx});var Vr=_(lh=>{"use strict";var cx=Yr(),rn=J(),ah=se(),ux="tag:yaml.org,2002:";function dx(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 fx(t,e,n){if(rn.isDocument(t)&&(t=t.contents),rn.isNode(t))return t;if(rn.isPair(t)){let d=n.schema[rn.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 cx.Alias(l.anchor);l={anchor:null,node:null},a.set(t,l)}e?.startsWith("!!")&&(e=ux+e.slice(2));let c=dx(t,e,o.tags);if(!c){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let d=new ah.Scalar(t);return l&&(l.node=d),d}c=t instanceof Map?o[rn.MAP]:Symbol.iterator in Object(t)?o[rn.SEQ]:o[rn.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 ah.Scalar(t);return e?u.tag=e:c.default||(u.tag=c.tag),l&&(l.node=u),u}lh.createNode=fx});var Mi=_(Li=>{"use strict";var px=Vr(),nt=J(),hx=Ni();function Xl(t,e,n){let r=n;for(let s=e.length-1;s>=0;--s){let i=e[s];if(typeof i=="number"&&Number.isInteger(i)&&i>=0){let o=[];o[i]=r,r=o}else r=new Map([[i,r]])}return px.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 ch=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,Ql=class extends hx.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=>nt.isNode(r)||nt.isPair(r)?r.clone(e):r),this.range&&(n.range=this.range.slice()),n}addIn(e,n){if(ch(e))this.add(n);else{let[r,...s]=e,i=this.get(r,!0);if(nt.isCollection(i))i.addIn(s,n);else if(i===void 0&&this.schema)this.set(r,Xl(this.schema,s,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${s}`)}}deleteIn(e){let[n,...r]=e;if(r.length===0)return this.delete(n);let s=this.get(n,!0);if(nt.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&&nt.isScalar(i)?i.value:i:nt.isCollection(i)?i.getIn(s,n):void 0}hasAllNullValues(e){return this.items.every(n=>{if(!nt.isPair(n))return!1;let r=n.value;return r==null||e&&nt.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 nt.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(nt.isCollection(i))i.setIn(s,n);else if(i===void 0&&this.schema)this.set(r,Xl(this.schema,s,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${s}`)}}};Li.Collection=Ql;Li.collectionFromPath=Xl;Li.isEmptyPath=ch});var Gr=_(Di=>{"use strict";var mx=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function Zl(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var gx=(t,e,n)=>t.endsWith(`
|
|
26
|
+
`)?Zl(n,e):n.includes(`
|
|
27
27
|
`)?`
|
|
28
|
-
`+
|
|
29
|
-
`)n===
|
|
30
|
-
`&&p!==" "){let E=t[
|
|
31
|
-
`&&E!==" "&&(
|
|
32
|
-
${e}${t.slice(0,R)}`:(n===Bi&&
|
|
33
|
-
${e}${t.slice(E+1,R)}`)}return
|
|
34
|
-
`);r=e,s=e+1,i=t[s]}return r}
|
|
35
|
-
`){if(i-o>r)return!0;if(o=i+1,s-o<=r)return!1}return!0}function
|
|
28
|
+
`+Zl(n,e):(t.endsWith(" ")?"":" ")+n;Di.indentComment=Zl;Di.lineComment=gx;Di.stringifyComment=mx});var dh=_(Xr=>{"use strict";var yx="flow",ec="block",Bi="quoted";function bx(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,y=-1,k=-1;n===ec&&(m=uh(t,m,e.length),m!==-1&&(d=m+l));for(let P;P=t[m+=1];){if(n===Bi&&P==="\\"){switch(y=m,t[m+1]){case"x":m+=3;break;case"u":m+=5;break;case"U":m+=9;break;default:m+=1}k=m}if(P===`
|
|
29
|
+
`)n===ec&&(m=uh(t,m,e.length)),d=m+e.length+l,f=void 0;else{if(P===" "&&p&&p!==" "&&p!==`
|
|
30
|
+
`&&p!==" "){let E=t[m+1];E&&E!==" "&&E!==`
|
|
31
|
+
`&&E!==" "&&(f=m)}if(m>=d)if(f)c.push(f),d=f+l,f=void 0;else if(n===Bi){for(;p===" "||p===" ";)p=P,P=t[m+=1],h=!0;let E=m>k+1?m-2:y-1;if(u[E])return t;c.push(E),u[E]=!0,d=E+l,f=void 0}else h=!0}p=P}if(h&&a&&a(),c.length===0)return t;o&&o();let A=t.slice(0,c[0]);for(let P=0;P<c.length;++P){let E=c[P],R=c[P+1]||t.length;E===0?A=`
|
|
32
|
+
${e}${t.slice(0,R)}`:(n===Bi&&u[E]&&(A+=`${t[E]}\\`),A+=`
|
|
33
|
+
${e}${t.slice(E+1,R)}`)}return A}function uh(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}Xr.FOLD_BLOCK=ec;Xr.FOLD_FLOW=yx;Xr.FOLD_QUOTED=Bi;Xr.foldFlowLines=bx});var Zr=_(fh=>{"use strict";var He=se(),Rt=dh(),Fi=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),Ui=t=>/^(%|---|\.\.\.)/m.test(t);function wx(t,e,n){if(!e||e<0)return!1;let r=e-n,s=t.length;if(s<=r)return!1;for(let i=0,o=0;i<s;++i)if(t[i]===`
|
|
35
|
+
`){if(i-o>r)return!0;if(o=i+1,s-o<=r)return!1}return!0}function Qr(t,e){let n=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=e,s=e.options.doubleQuotedMinMultiLineLength,i=e.indent||(Ui(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
|
-
`,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:
|
|
39
|
-
`)||/[ \t]\n|\n[ \t]/.test(t))return
|
|
40
|
-
${n}`)+"'";return e.implicitKey?r:
|
|
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:Rt.foldFlowLines(o,i,Rt.FOLD_QUOTED,Fi(e,!1))}function tc(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
|
|
39
|
+
`)||/[ \t]\n|\n[ \t]/.test(t))return Qr(t,e);let n=e.indent||(Ui(t)?" ":""),r="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
40
|
+
${n}`)+"'";return e.implicitKey?r:Rt.foldFlowLines(r,n,Rt.FOLD_FLOW,Fi(e,!1))}function Fn(t,e){let{singleQuote:n}=e.options,r;if(n===!1)r=Qr;else{let s=t.includes('"'),i=t.includes("'");s&&!i?r=tc:i&&!s?r=Qr:r=n?tc:Qr}return r(t,e)}var nc;try{nc=new RegExp(`(^|(?<!
|
|
41
41
|
))
|
|
42
42
|
+(?!
|
|
43
|
-
|$)`,"g")}catch{
|
|
43
|
+
|$)`,"g")}catch{nc=/\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 Fn(n,r);let c=r.indent||(r.forceBlockIndent||Ui(n)?" ":""),u=o==="literal"?!0:o==="folded"||e===He.Scalar.BLOCK_FOLDED?!1:e===He.Scalar.BLOCK_LITERAL?!0:!wx(n,l,c.length);if(!n)return u?`|
|
|
44
44
|
`:`>
|
|
45
|
-
`;let d,
|
|
46
|
-
`&&R!==" "&&R!==" ")break}let p=n.substring(
|
|
47
|
-
`);
|
|
48
|
-
`&&(p=p.slice(0,-1)),p=p.replace(
|
|
49
|
-
`)
|
|
50
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),I=!1,L=Fi(r,!0);o!=="folded"&&e!==
|
|
51
|
-
${c}${
|
|
52
|
-
${c}${
|
|
53
|
-
`)||
|
|
54
|
-
`)?Fn(i,e):ji(t,e,n,r);if(!a&&!
|
|
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(nc,`$&${c}`));let m=!1,y,k=-1;for(y=0;y<n.length;++y){let R=n[y];if(R===" ")m=!0;else if(R===`
|
|
49
|
+
`)k=y;else break}let A=n.substring(0,k<y?k+1:y);A&&(n=n.substring(A.length),A=A.replace(/\n+/g,`$&${c}`));let E=(m?c?"2":"1":"")+d;if(t&&(E+=" "+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=Fi(r,!0);o!=="folded"&&e!==He.Scalar.BLOCK_FOLDED&&(L.onOverflow=()=>{I=!0});let T=Rt.foldFlowLines(`${A}${R}${p}`,c,Rt.FOLD_BLOCK,L);if(!I)return`>${E}
|
|
51
|
+
${c}${T}`}return n=n.replace(/\n+/g,`$&${c}`),`|${E}
|
|
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 Fn(i,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(i))return a||u||!i.includes(`
|
|
54
|
+
`)?Fn(i,e):ji(t,e,n,r);if(!a&&!u&&s!==He.Scalar.PLAIN&&i.includes(`
|
|
55
55
|
`))return ji(t,e,n,r);if(Ui(i)){if(l==="")return e.forceBlockIndent=!0,ji(t,e,n,r);if(a&&l===c)return Fn(i,e)}let d=i.replace(/\n+/g,`$&
|
|
56
|
-
${l}`);if(o){let
|
|
57
|
-
${e.indent}${a}`:a}
|
|
58
|
-
${a}:`):(
|
|
59
|
-
`:"",
|
|
60
|
-
${
|
|
61
|
-
`&&
|
|
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 Fn(i,e)}return a?d:Rt.foldFlowLines(d,l,Rt.FOLD_FLOW,Fi(e,!1))}function Sx(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!==He.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(a=He.Scalar.QUOTE_DOUBLE);let l=u=>{switch(u){case He.Scalar.BLOCK_FOLDED:case He.Scalar.BLOCK_LITERAL:return s||i?Fn(o.value,e):ji(o,e,n,r);case He.Scalar.QUOTE_DOUBLE:return Qr(o.value,e);case He.Scalar.QUOTE_SINGLE:return tc(o.value,e);case He.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}fh.stringifyString=Sx});var es=_(rc=>{"use strict";var kx=Ii(),It=J(),xx=Gr(),Ex=Zr();function Ax(t,e){let n=Object.assign({blockQuote:!0,commentString:xx.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 Tx(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(It.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 Ox(t,e,{anchors:n,doc:r}){if(!r.directives)return"";let s=[],i=(It.isScalar(t)||It.isCollection(t))&&t.anchor;i&&kx.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 Px(t,e,n,r){if(It.isPair(t))return t.toString(e,n,r);if(It.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=It.isNode(t)?t:e.doc.createNode(t,{onTagObj:l=>s=l});s??(s=Tx(e.doc.schema.tags,i));let o=Ox(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):It.isScalar(i)?Ex.stringifyString(i,e,n,r):i.toString(e,n,r);return o?It.isScalar(i)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
|
|
57
|
+
${e.indent}${a}`:a}rc.createStringifyContext=Ax;rc.stringify=Px});var gh=_(mh=>{"use strict";var dt=J(),ph=se(),hh=es(),ts=Gr();function Cx({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=dt.isNode(t)&&t.comment||null;if(d){if(f)throw new Error("With simple keys, key nodes cannot have comments");if(dt.isCollection(t)||!dt.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||dt.isCollection(t)||(dt.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 h=!1,m=!1,y=hh.stringify(t,n,()=>h=!0,()=>m=!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 h&&r&&r(),y===""?"?":p?`? ${y}`:y}else if(i&&!d||e==null&&p)return y=`? ${y}`,f&&!h?y+=ts.lineComment(y,n.indent,c(f)):m&&s&&s(),y;h&&(f=null),p?(f&&(y+=ts.lineComment(y,n.indent,c(f))),y=`? ${y}
|
|
58
|
+
${a}:`):(y=`${y}:`,f&&(y+=ts.lineComment(y,n.indent,c(f))));let k,A,P;dt.isNode(e)?(k=!!e.spaceBefore,A=e.commentBefore,P=e.comment):(k=!1,A=null,P=null,e&&typeof e=="object"&&(e=o.createNode(e))),n.implicitKey=!1,!p&&!f&&dt.isScalar(e)&&(n.indentAtStart=y.length+1),m=!1,!u&&l.length>=2&&!n.inFlow&&!p&&dt.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(n.indent=n.indent.substring(2));let E=!1,R=hh.stringify(e,n,()=>E=!0,()=>m=!0),I=" ";if(f||k||A){if(I=k?`
|
|
59
|
+
`:"",A){let L=c(A);I+=`
|
|
60
|
+
${ts.indentComment(L,n.indent)}`}R===""&&!n.inFlow?I===`
|
|
61
|
+
`&&P&&(I=`
|
|
62
62
|
|
|
63
63
|
`):I+=`
|
|
64
|
-
${n.indent}`}else if(!p&&
|
|
65
|
-
`),F=
|
|
64
|
+
${n.indent}`}else if(!p&&dt.isCollection(e)){let L=R[0],T=R.indexOf(`
|
|
65
|
+
`),F=T!==-1,ee=n.inFlow??e.flow??e.items.length===0;if(F||!ee){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
66
|
${n.indent}`)}}else(R===""||R[0]===`
|
|
67
|
-
`)&&(I="");return
|
|
68
|
-
${l}${
|
|
67
|
+
`)&&(I="");return y+=I+R,n.inFlow?E&&r&&r():P&&!E?y+=ts.lineComment(y,n.indent,c(P)):m&&s&&s(),y}mh.stringifyPair=Cx});var ic=_(sc=>{"use strict";var yh=vi("process");function _x(t,...e){t==="debug"&&console.log(...e)}function Rx(t,e){(t==="debug"||t==="warn")&&(typeof yh.emitWarning=="function"?yh.emitWarning(e):console.warn(e))}sc.debug=_x;sc.warn=Rx});var Ki=_(Wi=>{"use strict";var ns=J(),bh=se(),qi="<<",Ji={identify:t=>t===qi||typeof t=="symbol"&&t.description===qi,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new bh.Scalar(Symbol(qi)),{addToJSMap:wh}),stringify:()=>qi},Ix=(t,e)=>(Ji.identify(e)||ns.isScalar(e)&&(!e.type||e.type===bh.Scalar.PLAIN)&&Ji.identify(e.value))&&t?.doc.schema.tags.some(n=>n.tag===Ji.tag&&n.default);function wh(t,e,n){if(n=t&&ns.isAlias(n)?n.resolve(t.doc):n,ns.isSeq(n))for(let r of n.items)oc(t,e,r);else if(Array.isArray(n))for(let r of n)oc(t,e,r);else oc(t,e,n)}function oc(t,e,n){let r=t&&ns.isAlias(n)?n.resolve(t.doc):n;if(!ns.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}Wi.addMergeToJSMap=wh;Wi.isMergeKey=Ix;Wi.merge=Ji});var lc=_(kh=>{"use strict";var Nx=ic(),vh=Ki(),$x=es(),Sh=J(),ac=Ct();function Lx(t,e,{key:n,value:r}){if(Sh.isNode(n)&&n.addToJSMap)n.addToJSMap(t,e,r);else if(vh.isMergeKey(t,n))vh.addMergeToJSMap(t,e,r);else{let s=ac.toJS(n,"",t);if(e instanceof Map)e.set(s,ac.toJS(r,s,t));else if(e instanceof Set)e.add(s);else{let i=Mx(n,s,t),o=ac.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 Mx(t,e,n){if(e===null)return"";if(typeof e!="object")return String(e);if(Sh.isNode(t)&&n?.doc){let r=$x.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)+'..."'),Nx.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)}kh.addPairToJSMap=Lx});var Nt=_(cc=>{"use strict";var xh=Vr(),Dx=gh(),Bx=lc(),Hi=J();function jx(t,e,n){let r=xh.createNode(t,void 0,n),s=xh.createNode(e,void 0,n);return new zi(r,s)}var zi=class t{constructor(e,n=null){Object.defineProperty(this,Hi.NODE_TYPE,{value:Hi.PAIR}),this.key=e,this.value=n}clone(e){let{key:n,value:r}=this;return Hi.isNode(n)&&(n=n.clone(e)),Hi.isNode(r)&&(r=r.clone(e)),new t(n,r)}toJSON(e,n){let r=n?.mapAsMap?new Map:{};return Bx.addPairToJSMap(n,r,this)}toString(e,n,r){return e?.doc?Dx.stringifyPair(this,e,n,r):JSON.stringify(this)}};cc.Pair=zi;cc.createPair=jx});var uc=_(Ah=>{"use strict";var sn=J(),Eh=es(),Yi=Gr();function Fx(t,e,n){return(e.inFlow??t.flow?qx:Ux)(t,e,n)}function Ux({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],y=null;if(sn.isNode(m))!d&&m.spaceBefore&&f.push(""),Vi(n,f,m.commentBefore,d),m.comment&&(y=m.comment);else if(sn.isPair(m)){let A=sn.isNode(m.key)?m.key:null;A&&(!d&&A.spaceBefore&&f.push(""),Vi(n,f,A.commentBefore,d))}d=!1;let k=Eh.stringify(m,u,()=>y=null,()=>d=!0);y&&(k+=Yi.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 h=1;h<f.length;++h){let m=f[h];p+=m?`
|
|
68
|
+
${l}${m}`:`
|
|
69
69
|
`}}return t?(p+=`
|
|
70
|
-
`+Yi.indentComment(c(t),l),a&&a()):d&&o&&o(),p}function
|
|
71
|
-
`))&&(c=!0),d.push(
|
|
72
|
-
${i}${s}${
|
|
73
|
-
`;return`${
|
|
74
|
-
${s}${p}`}else return`${
|
|
75
|
-
`:" ")}return
|
|
70
|
+
`+Yi.indentComment(c(t),l),a&&a()):d&&o&&o(),p}function qx({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],y=null;if(sn.isNode(m))m.spaceBefore&&d.push(""),Vi(e,d,m.commentBefore,!1),m.comment&&(y=m.comment);else if(sn.isPair(m)){let A=sn.isNode(m.key)?m.key:null;A&&(A.spaceBefore&&d.push(""),Vi(e,d,A.commentBefore,!1),A.comment&&(c=!0));let P=sn.isNode(m.value)?m.value:null;P?(P.comment&&(y=P.comment),P.commentBefore&&(c=!0)):m.value==null&&A?.comment&&(y=A.comment)}y&&(c=!0);let k=Eh.stringify(m,l,()=>y=null);h<t.length-1&&(k+=","),y&&(k+=Yi.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 h=d.reduce((m,y)=>m+y.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 Vi({indent:t,options:{commentString:e}},n,r,s){if(r&&s&&(r=r.replace(/^\n+/,"")),r){let i=Yi.indentComment(e(r),t);n.push(i.trimStart())}}Ah.stringifyCollection=Fx});var Lt=_(fc=>{"use strict";var Jx=uc(),Wx=lc(),Kx=Mi(),$t=J(),Gi=Nt(),Hx=se();function rs(t,e){let n=$t.isScalar(e)?e.value:e;for(let r of t)if($t.isPair(r)&&(r.key===e||r.key===n||$t.isScalar(r.key)&&r.key.value===n))return r}var dc=class extends Kx.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super($t.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(Gi.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;$t.isPair(e)?r=e:!e||typeof e!="object"||!("key"in e)?r=new Gi.Pair(e,e?.value):r=new Gi.Pair(e.key,e.value);let s=rs(this.items,r.key),i=this.schema?.sortMapEntries;if(s){if(!n)throw new Error(`Key ${r.key} already set`);$t.isScalar(s.value)&&Hx.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=rs(this.items,e);return n?this.items.splice(this.items.indexOf(n),1).length>0:!1}get(e,n){let s=rs(this.items,e)?.value;return(!n&&$t.isScalar(s)?s.value:s)??void 0}has(e){return!!rs(this.items,e)}set(e,n){this.add(new Gi.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)Wx.addPairToJSMap(n,s,i);return s}toString(e,n,r){if(!e)return JSON.stringify(this);for(let s of this.items)if(!$t.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})),Jx.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:n})}};fc.YAMLMap=dc;fc.findPair=rs});var Un=_(Oh=>{"use strict";var zx=J(),Th=Lt(),Yx={collection:"map",default:!0,nodeClass:Th.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(t,e){return zx.isMap(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,n)=>Th.YAMLMap.from(t,e,n)};Oh.map=Yx});var Mt=_(Ph=>{"use strict";var Vx=Vr(),Gx=uc(),Xx=Mi(),Qi=J(),Qx=se(),Zx=Ct(),pc=class extends Xx.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(Qi.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let n=Xi(e);return typeof n!="number"?!1:this.items.splice(n,1).length>0}get(e,n){let r=Xi(e);if(typeof r!="number")return;let s=this.items[r];return!n&&Qi.isScalar(s)?s.value:s}has(e){let n=Xi(e);return typeof n=="number"&&n<this.items.length}set(e,n){let r=Xi(e);if(typeof r!="number")throw new Error(`Expected a valid index, not ${e}.`);let s=this.items[r];Qi.isScalar(s)&&Qx.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(Zx.toJS(i,String(s++),n));return r}toString(e,n,r){return e?Gx.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(Vx.createNode(a,void 0,r))}}return i}};function Xi(t){let e=Qi.isScalar(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}Ph.YAMLSeq=pc});var qn=_(_h=>{"use strict";var e0=J(),Ch=Mt(),t0={collection:"seq",default:!0,nodeClass:Ch.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(t,e){return e0.isSeq(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,n)=>Ch.YAMLSeq.from(t,e,n)};_h.seq=t0});var ss=_(Rh=>{"use strict";var n0=Zr(),r0={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),n0.stringifyString(t,e,n,r)}};Rh.string=r0});var Zi=_($h=>{"use strict";var Ih=se(),Nh={identify:t=>t==null,createNode:()=>new Ih.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Ih.Scalar(null),stringify:({source:t},e)=>typeof t=="string"&&Nh.test.test(t)?t:e.options.nullStr};$h.nullTag=Nh});var hc=_(Mh=>{"use strict";var s0=se(),Lh={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new s0.Scalar(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},n){if(t&&Lh.test.test(t)){let r=t[0]==="t"||t[0]==="T";if(e===r)return t}return e?n.options.trueStr:n.options.falseStr}};Mh.boolTag=Lh});var Jn=_(Dh=>{"use strict";function i0({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}Dh.stringifyNumber=i0});var gc=_(eo=>{"use strict";var o0=se(),mc=Jn(),a0={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},l0={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():mc.stringifyNumber(t)}},c0={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 o0.Scalar(parseFloat(t)),n=t.indexOf(".");return n!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-n-1),e},stringify:mc.stringifyNumber};eo.float=c0;eo.floatExp=l0;eo.floatNaN=a0});var bc=_(no=>{"use strict";var Bh=Jn(),to=t=>typeof t=="bigint"||Number.isInteger(t),yc=(t,e,n,{intAsBigInt:r})=>r?BigInt(t):parseInt(t.substring(e),n);function jh(t,e,n){let{value:r}=t;return to(r)&&r>=0?n+r.toString(e):Bh.stringifyNumber(t)}var u0={identify:t=>to(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,n)=>yc(t,2,8,n),stringify:t=>jh(t,8,"0o")},d0={identify:to,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,n)=>yc(t,0,10,n),stringify:Bh.stringifyNumber},f0={identify:t=>to(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,n)=>yc(t,2,16,n),stringify:t=>jh(t,16,"0x")};no.int=d0;no.intHex=f0;no.intOct=u0});var Uh=_(Fh=>{"use strict";var p0=Un(),h0=Zi(),m0=qn(),g0=ss(),y0=hc(),wc=gc(),vc=bc(),b0=[p0.map,m0.seq,g0.string,h0.nullTag,y0.boolTag,vc.intOct,vc.int,vc.intHex,wc.floatNaN,wc.floatExp,wc.float];Fh.schema=b0});var Wh=_(Jh=>{"use strict";var w0=se(),v0=Un(),S0=qn();function qh(t){return typeof t=="bigint"||Number.isInteger(t)}var ro=({value:t})=>JSON.stringify(t),k0=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:ro},{identify:t=>t==null,createNode:()=>new w0.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:ro},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:ro},{identify:qh,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})=>qh(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:ro}],x0={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},E0=[v0.map,S0.seq].concat(k0,x0);Jh.schema=E0});var kc=_(Kh=>{"use strict";var is=vi("buffer"),Sc=se(),A0=Zr(),T0={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof is.Buffer=="function")return is.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 is.Buffer=="function")a=o instanceof is.Buffer?o.toString("base64"):is.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=Sc.Scalar.BLOCK_LITERAL),e!==Sc.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===Sc.Scalar.BLOCK_LITERAL?`
|
|
75
|
+
`:" ")}return A0.stringifyString({comment:t,type:e,value:a},r,s,i)}};Kh.binary=T0});var oo=_(io=>{"use strict";var so=J(),xc=Nt(),O0=se(),P0=Mt();function Hh(t,e){if(so.isSeq(t))for(let n=0;n<t.items.length;++n){let r=t.items[n];if(!so.isPair(r)){if(so.isMap(r)){r.items.length>1&&e("Each pair must have its own sequence indicator");let s=r.items[0]||new xc.Pair(new O0.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]=so.isPair(r)?r:new vc.Pair(r)}}else e("Expected a sequence for this tag");return t}function Gh(t,e,n){let{replacer:r}=n,s=new R0.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(vc.createPair(a,l,n))}return s}var I0={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Vh,createNode:Gh};io.createPairs=Gh;io.pairs=I0;io.resolvePairs=Vh});var xc=_(kc=>{"use strict";var Xh=J(),Sc=Pt(),rs=$t(),N0=Lt(),Qh=oo(),sn=class t extends N0.YAMLSeq{constructor(){super(),this.add=rs.YAMLMap.prototype.add.bind(this),this.delete=rs.YAMLMap.prototype.delete.bind(this),this.get=rs.YAMLMap.prototype.get.bind(this),this.has=rs.YAMLMap.prototype.has.bind(this),this.set=rs.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(Xh.isPair(s)?(i=Sc.toJS(s.key,"",n),o=Sc.toJS(s.value,i,n)):i=Sc.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=Qh.createPairs(e,n,r),i=new this;return i.items=s.items,i}};sn.tag="tag:yaml.org,2002:omap";var $0={collection:"seq",identify:t=>t instanceof Map,nodeClass:sn,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let n=Qh.resolvePairs(t,e),r=[];for(let{key:s}of n.items)Xh.isScalar(s)&&(r.includes(s.value)?e(`Ordered maps must not include duplicate keys: ${s.value}`):r.push(s.value));return Object.assign(new sn,n)},createNode:(t,e,n)=>sn.from(t,e,n)};kc.YAMLOMap=sn;kc.omap=$0});var rm=_(Ec=>{"use strict";var Zh=re();function em({value:t,source:e},n){return e&&(t?tm:nm).test.test(e)?e:t?n.options.trueStr:n.options.falseStr}var tm={identify:t=>t===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Zh.Scalar(!0),stringify:em},nm={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 Zh.Scalar(!1),stringify:em};Ec.falseTag=nm;Ec.trueTag=tm});var sm=_(ao=>{"use strict";var L0=re(),Ac=Jn(),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:Ac.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.replace(/_/g,"")),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():Ac.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.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:Ac.stringifyNumber};ao.float=B0;ao.floatExp=D0;ao.floatNaN=M0});var om=_(is=>{"use strict";var im=Jn(),ss=t=>typeof t=="bigint"||Number.isInteger(t);function lo(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 Tc(t,e,n){let{value:r}=t;if(ss(r)){let s=r.toString(e);return r<0?"-"+n+s.substr(1):n+s}return im.stringifyNumber(t)}var j0={identify:ss,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,n)=>lo(t,2,2,n),stringify:t=>Tc(t,2,"0b")},F0={identify:ss,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,n)=>lo(t,1,8,n),stringify:t=>Tc(t,8,"0")},U0={identify:ss,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,n)=>lo(t,0,10,n),stringify:im.stringifyNumber},q0={identify:ss,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,n)=>lo(t,2,16,n),stringify:t=>Tc(t,16,"0x")};is.int=U0;is.intBin=j0;is.intHex=q0;is.intOct=F0});var Pc=_(Oc=>{"use strict";var fo=J(),co=It(),uo=$t(),on=class t extends uo.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let n;fo.isPair(e)?n=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?n=new co.Pair(e.key,null):n=new co.Pair(e,null),uo.findPair(this.items,n.key)||this.items.push(n)}get(e,n){let r=uo.findPair(this.items,e);return!n&&fo.isPair(r)?fo.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=uo.findPair(this.items,e);r&&!n?this.items.splice(this.items.indexOf(r),1):!r&&n&&this.items.push(new co.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(co.createPair(o,null,r));return i}};on.tag="tag:yaml.org,2002:set";var J0={collection:"map",identify:t=>t instanceof Set,nodeClass:on,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,n)=>on.from(t,e,n),resolve(t,e){if(fo.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new on,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};Oc.YAMLSet=on;Oc.set=J0});var _c=_(po=>{"use strict";var W0=Jn();function Cc(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 am(t){let{value:e}=t,n=o=>o;if(typeof e=="bigint")n=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return W0.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 K0={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})=>Cc(t,n),stringify:am},H0={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=>Cc(t,!1),stringify:am},lm={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(lm.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,n,r,s,i,o,a]=e.map(Number),l=e[7]?Number((e[7]+"00").substr(1,3)):0,c=Date.UTC(n,r-1,s,i||0,o||0,a||0,l),f=e[8];if(f&&f!=="Z"){let d=Cc(f,!1);Math.abs(d)<30&&(d*=60),c-=6e4*d}return new Date(c)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};po.floatTime=H0;po.intTime=K0;po.timestamp=lm});var dm=_(um=>{"use strict";var z0=Un(),Y0=Zi(),V0=qn(),G0=ts(),X0=wc(),cm=rm(),Rc=sm(),ho=om(),Q0=Ki(),Z0=xc(),eE=oo(),tE=Pc(),Ic=_c(),nE=[z0.map,V0.seq,G0.string,Y0.nullTag,cm.trueTag,cm.falseTag,ho.intBin,ho.intOct,ho.int,ho.intHex,Rc.floatNaN,Rc.floatExp,Rc.float,X0.binary,Q0.merge,Z0.omap,eE.pairs,tE.set,Ic.intTime,Ic.floatTime,Ic.timestamp];um.schema=nE});var Sm=_(Lc=>{"use strict";var mm=Un(),rE=Zi(),gm=qn(),sE=ts(),iE=dc(),Nc=pc(),$c=mc(),oE=Wh(),aE=zh(),ym=wc(),os=Ki(),bm=xc(),wm=oo(),fm=dm(),vm=Pc(),mo=_c(),pm=new Map([["core",oE.schema],["failsafe",[mm.map,gm.seq,sE.string]],["json",aE.schema],["yaml11",fm.schema],["yaml-1.1",fm.schema]]),hm={binary:ym.binary,bool:iE.boolTag,float:Nc.float,floatExp:Nc.floatExp,floatNaN:Nc.floatNaN,floatTime:mo.floatTime,int:$c.int,intHex:$c.intHex,intOct:$c.intOct,intTime:mo.intTime,map:mm.map,merge:os.merge,null:rE.nullTag,omap:bm.omap,pairs:wm.pairs,seq:gm.seq,set:vm.set,timestamp:mo.timestamp},lE={"tag:yaml.org,2002:binary":ym.binary,"tag:yaml.org,2002:merge":os.merge,"tag:yaml.org,2002:omap":bm.omap,"tag:yaml.org,2002:pairs":wm.pairs,"tag:yaml.org,2002:set":vm.set,"tag:yaml.org,2002:timestamp":mo.timestamp};function cE(t,e,n){let r=pm.get(e);if(r&&!t)return n&&!r.includes(os.merge)?r.concat(os.merge):r.slice();let s=r;if(!s)if(Array.isArray(t))s=[];else{let i=Array.from(pm.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(os.merge)),s.reduce((i,o)=>{let a=typeof o=="string"?hm[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(hm).map(f=>JSON.stringify(f)).join(", ");throw new Error(`Unknown custom tag ${l}; use one of ${c}`)}return i.includes(a)||i.push(a),i},[])}Lc.coreKnownTags=lE;Lc.getTags=cE});var Bc=_(km=>{"use strict";var Mc=J(),uE=Un(),dE=qn(),fE=ts(),go=Sm(),pE=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,Dc=class t{constructor({compat:e,customTags:n,merge:r,resolveKnownTags:s,schema:i,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(e)?go.getTags(e,"compat"):e?go.getTags(null,e):null,this.name=typeof i=="string"&&i||"core",this.knownTags=s?go.coreKnownTags:{},this.tags=go.getTags(n,this.name,r),this.toStringOptions=a??null,Object.defineProperty(this,Mc.MAP,{value:uE.map}),Object.defineProperty(this,Mc.SCALAR,{value:fE.string}),Object.defineProperty(this,Mc.SEQ,{value:dE.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?pE:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};km.Schema=Dc});var Em=_(xm=>{"use strict";var hE=J(),jc=Xr(),as=zr();function mE(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=jc.createStringifyContext(t,e),{commentString:i}=s.options;if(t.commentBefore){n.length!==1&&n.unshift("");let l=i(t.commentBefore);n.unshift(as.indentComment(l,""))}let o=!1,a=null;if(t.contents){if(hE.isNode(t.contents)){if(t.contents.spaceBefore&&r&&n.push(""),t.contents.commentBefore){let f=i(t.contents.commentBefore);n.push(as.indentComment(f,""))}s.forceBlockIndent=!!t.comment,a=t.contents.comment}let l=a?void 0:()=>o=!0,c=jc.stringify(t.contents,s,()=>a=null,l);a&&(c+=as.lineComment(c,"",i(a))),(c[0]==="|"||c[0]===">")&&n[n.length-1]==="---"?n[n.length-1]=`--- ${c}`:n.push(c)}else n.push(jc.stringify(t.contents,s));if(t.directives?.docEnd)if(t.comment){let l=i(t.comment);l.includes(`
|
|
78
|
-
`)?(n.push("..."),n.push(
|
|
77
|
+
${i.comment}`:r.comment}r=s}t.items[n]=so.isPair(r)?r:new xc.Pair(r)}}else e("Expected a sequence for this tag");return t}function zh(t,e,n){let{replacer:r}=n,s=new P0.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(xc.createPair(a,l,n))}return s}var C0={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Hh,createNode:zh};io.createPairs=zh;io.pairs=C0;io.resolvePairs=Hh});var Tc=_(Ac=>{"use strict";var Yh=J(),Ec=Ct(),os=Lt(),_0=Mt(),Vh=oo(),on=class t extends _0.YAMLSeq{constructor(){super(),this.add=os.YAMLMap.prototype.add.bind(this),this.delete=os.YAMLMap.prototype.delete.bind(this),this.get=os.YAMLMap.prototype.get.bind(this),this.has=os.YAMLMap.prototype.has.bind(this),this.set=os.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(Yh.isPair(s)?(i=Ec.toJS(s.key,"",n),o=Ec.toJS(s.value,i,n)):i=Ec.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=Vh.createPairs(e,n,r),i=new this;return i.items=s.items,i}};on.tag="tag:yaml.org,2002:omap";var R0={collection:"seq",identify:t=>t instanceof Map,nodeClass:on,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let n=Vh.resolvePairs(t,e),r=[];for(let{key:s}of n.items)Yh.isScalar(s)&&(r.includes(s.value)?e(`Ordered maps must not include duplicate keys: ${s.value}`):r.push(s.value));return Object.assign(new on,n)},createNode:(t,e,n)=>on.from(t,e,n)};Ac.YAMLOMap=on;Ac.omap=R0});var em=_(Oc=>{"use strict";var Gh=se();function Xh({value:t,source:e},n){return e&&(t?Qh:Zh).test.test(e)?e:t?n.options.trueStr:n.options.falseStr}var Qh={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 Gh.Scalar(!0),stringify:Xh},Zh={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 Gh.Scalar(!1),stringify:Xh};Oc.falseTag=Zh;Oc.trueTag=Qh});var tm=_(ao=>{"use strict";var I0=se(),Pc=Jn(),N0={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:Pc.stringifyNumber},$0={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():Pc.stringifyNumber(t)}},L0={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 I0.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:Pc.stringifyNumber};ao.float=L0;ao.floatExp=$0;ao.floatNaN=N0});var rm=_(ls=>{"use strict";var nm=Jn(),as=t=>typeof t=="bigint"||Number.isInteger(t);function lo(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 Cc(t,e,n){let{value:r}=t;if(as(r)){let s=r.toString(e);return r<0?"-"+n+s.substr(1):n+s}return nm.stringifyNumber(t)}var M0={identify:as,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,n)=>lo(t,2,2,n),stringify:t=>Cc(t,2,"0b")},D0={identify:as,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,n)=>lo(t,1,8,n),stringify:t=>Cc(t,8,"0")},B0={identify:as,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,n)=>lo(t,0,10,n),stringify:nm.stringifyNumber},j0={identify:as,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,n)=>lo(t,2,16,n),stringify:t=>Cc(t,16,"0x")};ls.int=B0;ls.intBin=M0;ls.intHex=j0;ls.intOct=D0});var Rc=_(_c=>{"use strict";var fo=J(),co=Nt(),uo=Lt(),an=class t extends uo.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let n;fo.isPair(e)?n=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?n=new co.Pair(e.key,null):n=new co.Pair(e,null),uo.findPair(this.items,n.key)||this.items.push(n)}get(e,n){let r=uo.findPair(this.items,e);return!n&&fo.isPair(r)?fo.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=uo.findPair(this.items,e);r&&!n?this.items.splice(this.items.indexOf(r),1):!r&&n&&this.items.push(new co.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(co.createPair(o,null,r));return i}};an.tag="tag:yaml.org,2002:set";var F0={collection:"map",identify:t=>t instanceof Set,nodeClass:an,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,n)=>an.from(t,e,n),resolve(t,e){if(fo.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new an,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};_c.YAMLSet=an;_c.set=F0});var Nc=_(po=>{"use strict";var U0=Jn();function Ic(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 sm(t){let{value:e}=t,n=o=>o;if(typeof e=="bigint")n=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return U0.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 q0={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})=>Ic(t,n),stringify:sm},J0={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=>Ic(t,!1),stringify:sm},im={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(im.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=Ic(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$/,"")??""};po.floatTime=J0;po.intTime=q0;po.timestamp=im});var lm=_(am=>{"use strict";var W0=Un(),K0=Zi(),H0=qn(),z0=ss(),Y0=kc(),om=em(),$c=tm(),ho=rm(),V0=Ki(),G0=Tc(),X0=oo(),Q0=Rc(),Lc=Nc(),Z0=[W0.map,H0.seq,z0.string,K0.nullTag,om.trueTag,om.falseTag,ho.intBin,ho.intOct,ho.int,ho.intHex,$c.floatNaN,$c.floatExp,$c.float,Y0.binary,V0.merge,G0.omap,X0.pairs,Q0.set,Lc.intTime,Lc.floatTime,Lc.timestamp];am.schema=Z0});var bm=_(Bc=>{"use strict";var fm=Un(),eE=Zi(),pm=qn(),tE=ss(),nE=hc(),Mc=gc(),Dc=bc(),rE=Uh(),sE=Wh(),hm=kc(),cs=Ki(),mm=Tc(),gm=oo(),cm=lm(),ym=Rc(),mo=Nc(),um=new Map([["core",rE.schema],["failsafe",[fm.map,pm.seq,tE.string]],["json",sE.schema],["yaml11",cm.schema],["yaml-1.1",cm.schema]]),dm={binary:hm.binary,bool:nE.boolTag,float:Mc.float,floatExp:Mc.floatExp,floatNaN:Mc.floatNaN,floatTime:mo.floatTime,int:Dc.int,intHex:Dc.intHex,intOct:Dc.intOct,intTime:mo.intTime,map:fm.map,merge:cs.merge,null:eE.nullTag,omap:mm.omap,pairs:gm.pairs,seq:pm.seq,set:ym.set,timestamp:mo.timestamp},iE={"tag:yaml.org,2002:binary":hm.binary,"tag:yaml.org,2002:merge":cs.merge,"tag:yaml.org,2002:omap":mm.omap,"tag:yaml.org,2002:pairs":gm.pairs,"tag:yaml.org,2002:set":ym.set,"tag:yaml.org,2002:timestamp":mo.timestamp};function oE(t,e,n){let r=um.get(e);if(r&&!t)return n&&!r.includes(cs.merge)?r.concat(cs.merge):r.slice();let s=r;if(!s)if(Array.isArray(t))s=[];else{let i=Array.from(um.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(cs.merge)),s.reduce((i,o)=>{let a=typeof o=="string"?dm[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(dm).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},[])}Bc.coreKnownTags=iE;Bc.getTags=oE});var Uc=_(wm=>{"use strict";var jc=J(),aE=Un(),lE=qn(),cE=ss(),go=bm(),uE=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,Fc=class t{constructor({compat:e,customTags:n,merge:r,resolveKnownTags:s,schema:i,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(e)?go.getTags(e,"compat"):e?go.getTags(null,e):null,this.name=typeof i=="string"&&i||"core",this.knownTags=s?go.coreKnownTags:{},this.tags=go.getTags(n,this.name,r),this.toStringOptions=a??null,Object.defineProperty(this,jc.MAP,{value:aE.map}),Object.defineProperty(this,jc.SCALAR,{value:cE.string}),Object.defineProperty(this,jc.SEQ,{value:lE.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?uE:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};wm.Schema=Fc});var Sm=_(vm=>{"use strict";var dE=J(),qc=es(),us=Gr();function fE(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=qc.createStringifyContext(t,e),{commentString:i}=s.options;if(t.commentBefore){n.length!==1&&n.unshift("");let l=i(t.commentBefore);n.unshift(us.indentComment(l,""))}let o=!1,a=null;if(t.contents){if(dE.isNode(t.contents)){if(t.contents.spaceBefore&&r&&n.push(""),t.contents.commentBefore){let u=i(t.contents.commentBefore);n.push(us.indentComment(u,""))}s.forceBlockIndent=!!t.comment,a=t.contents.comment}let l=a?void 0:()=>o=!0,c=qc.stringify(t.contents,s,()=>a=null,l);a&&(c+=us.lineComment(c,"",i(a))),(c[0]==="|"||c[0]===">")&&n[n.length-1]==="---"?n[n.length-1]=`--- ${c}`:n.push(c)}else n.push(qc.stringify(t.contents,s));if(t.directives?.docEnd)if(t.comment){let l=i(t.comment);l.includes(`
|
|
78
|
+
`)?(n.push("..."),n.push(us.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(us.indentComment(i(l),"")))}return n.join(`
|
|
79
79
|
`)+`
|
|
80
|
-
`}
|
|
80
|
+
`}vm.stringifyDocument=fE});var ds=_(km=>{"use strict";var pE=Yr(),Wn=Mi(),$e=J(),hE=Nt(),mE=Ct(),gE=Uc(),yE=Sm(),Jc=Ii(),bE=zl(),wE=Vr(),Wc=Hl(),Kc=class t{constructor(e,n,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,$e.NODE_TYPE,{value:$e.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 Wc.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,{[$e.NODE_TYPE]:{value:$e.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=$e.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){Kn(this.contents)&&this.contents.add(e)}addIn(e,n){Kn(this.contents)&&this.contents.addIn(e,n)}createAlias(e,n){if(!e.anchor){let r=Jc.anchorNames(this);e.anchor=!n||r.has(n)?Jc.findNewAnchor(n||"a",r):n}return new pE.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=A=>typeof A=="number"||A instanceof String||A 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}=Jc.createNodeAnchors(this,o||"a"),h={aliasDuplicateObjects:i??!0,keepUndefined:l??!1,onAnchor:d,onTagObj:c,replacer:s,schema:this.schema,sourceObjects:p},m=wE.createNode(e,u,h);return a&&$e.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 hE.Pair(s,i)}delete(e){return Kn(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Wn.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):Kn(this.contents)?this.contents.deleteIn(e):!1}get(e,n){return $e.isCollection(this.contents)?this.contents.get(e,n):void 0}getIn(e,n){return Wn.isEmptyPath(e)?!n&&$e.isScalar(this.contents)?this.contents.value:this.contents:$e.isCollection(this.contents)?this.contents.getIn(e,n):void 0}has(e){return $e.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return Wn.isEmptyPath(e)?this.contents!==void 0:$e.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,n){this.contents==null?this.contents=Wn.collectionFromPath(this.schema,[e],n):Kn(this.contents)&&this.contents.set(e,n)}setIn(e,n){Wn.isEmptyPath(e)?this.contents=n:this.contents==null?this.contents=Wn.collectionFromPath(this.schema,Array.from(e),n):Kn(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 Wc.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 Wc.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 gE.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=mE.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"?bE.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 yE.stringifyDocument(this,e)}};function Kn(t){if($e.isCollection(t))return!0;throw new Error("Expected a YAML collection as document contents")}km.Document=Kc});var hs=_(ps=>{"use strict";var fs=class extends Error{constructor(e,n,r,s){super(),this.name=e,this.code=r,this.message=s,this.pos=n}},Hc=class extends fs{constructor(e,n,r){super("YAMLParseError",e,n,r)}},zc=class extends fs{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
|
|
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
|
-
`}};
|
|
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(
|
|
87
|
-
`+
|
|
88
|
-
`+
|
|
89
|
-
`+I.comment:c.comment=I.comment),d=I.end;continue}!o&&n.options.strict&&
|
|
90
|
-
`+L:
|
|
91
|
-
`+F.comment:
|
|
92
|
-
`+
|
|
93
|
-
`.repeat(Math.max(1,o.length-1)):"",
|
|
94
|
-
`;for(let
|
|
95
|
-
`):
|
|
96
|
-
`:!p&&
|
|
97
|
-
`&&(
|
|
98
|
-
|
|
99
|
-
`),d+=
|
|
100
|
-
`,p=!0):
|
|
85
|
+
`}};ps.YAMLError=fs;ps.YAMLParseError=Hc;ps.YAMLWarning=zc;ps.prettifyError=vE});var ms=_(xm=>{"use strict";function SE(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,y=null,k=null,A=null,P=null,E=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:(!E||n!=="seq-item-ind")&&(l=!0):f+=T.source,c=!0,p=!0,(y||k)&&(A=T),u=!0;break;case"anchor":y&&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),y=T,R??(R=T.offset),c=!1,u=!1,h=!0;break;case"tag":{k&&i(T,"MULTIPLE_TAGS","A node can have at most one tag"),k=T,R??(R=T.offset),c=!1,u=!1,h=!0;break}case n:(y||k)&&i(T,"BAD_PROP_ORDER",`Anchors and tags must be after the ${T.source} indicator`),E&&i(T,"UNEXPECTED_TOKEN",`Unexpected ${T.source} in ${e??"collection"}`),E=T,c=n==="seq-item-ind"||n==="explicit-key-ind",u=!1;break;case"comma":if(e){P&&i(T,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),P=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:P,found:E,spaceBefore:l,comment:d,hasNewline:p,anchor:y,tag:k,newlineAfterProp:A,end:L,start:R??L}}xm.resolveProps=SE});var yo=_(Em=>{"use strict";function Yc(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(Yc(e.key)||Yc(e.value))return!0}return!1;default:return!0}}Em.containsNewline=Yc});var Vc=_(Am=>{"use strict";var kE=yo();function xE(t,e,n){if(e?.type==="flow-collection"){let r=e.end[0];r.indent===t&&(r.source==="]"||r.source==="}")&&kE.containsNewline(e)&&n(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}Am.flowIndentCheck=xE});var Gc=_(Om=>{"use strict";var Tm=J();function EE(t,e,n){let{uniqueKeys:r}=t.options;if(r===!1)return!1;let s=typeof r=="function"?r:(i,o)=>i===o||Tm.isScalar(i)&&Tm.isScalar(o)&&i.value===o.value;return e.some(i=>s(i.key,n))}Om.mapIncludes=EE});var Nm=_(Im=>{"use strict";var Pm=Nt(),AE=Lt(),Cm=ms(),TE=yo(),_m=Vc(),OE=Gc(),Rm="All mapping items must start at the same column";function PE({composeNode:t,composeEmptyNode:e},n,r,s,i){let o=i?.nodeClass??AE.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=Cm.resolveProps(d,{indicator:"explicit-key-ind",next:f??p?.[0],offset:l,onError:s,parentIndent:r.indent,startOnNewline:!0}),y=!m.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",Rm)),!m.anchor&&!m.tag&&!p){c=m.end,m.comment&&(a.comment?a.comment+=`
|
|
87
|
+
`+m.comment:a.comment=m.comment);continue}(m.newlineAfterProp||TE.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",Rm);n.atKey=!0;let k=m.end,A=f?t(n,f,m,s):e(n,k,d,null,m,s);n.schema.compat&&_m.flowIndentCheck(r.indent,f,s),n.atKey=!1,OE.mapIncludes(n,a.items,A)&&s(k,"DUPLICATE_KEY","Map keys must be unique");let P=Cm.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=P.end,P.found){y&&(h?.type==="block-map"&&!P.hasNewline&&s(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),n.options.strict&&m.start<P.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 E=h?t(n,h,P,s):e(n,l,p,null,P,s);n.schema.compat&&_m.flowIndentCheck(r.indent,h,s),l=E.range[2];let R=new Pm.Pair(A,E);n.options.keepSourceTokens&&(R.srcToken=u),a.items.push(R)}else{y&&s(A.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),P.comment&&(A.comment?A.comment+=`
|
|
88
|
+
`+P.comment:A.comment=P.comment);let E=new Pm.Pair(A);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}Im.resolveBlockMap=PE});var Lm=_($m=>{"use strict";var CE=Mt(),_E=ms(),RE=Vc();function IE({composeNode:t,composeEmptyNode:e},n,r,s,i){let o=i?.nodeClass??CE.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=_E.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&&RE.flowIndentCheck(r.indent,d,s),l=p.range[2],a.items.push(p)}return a.range=[r.offset,l,c??l],a}$m.resolveBlockSeq=IE});var Hn=_(Mm=>{"use strict";function NE(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}}Mm.resolveEnd=NE});var Fm=_(jm=>{"use strict";var $E=J(),LE=Nt(),Dm=Lt(),ME=Mt(),DE=Hn(),Bm=ms(),BE=yo(),jE=Gc(),Xc="Block collections are not allowed within flow collections",Qc=t=>t&&(t.type==="block-map"||t.type==="block-seq");function FE({composeNode:t,composeEmptyNode:e},n,r,s,i){let o=r.start.source==="{",a=o?"flow map":"flow sequence",l=i?.nodeClass??(o?Dm.YAMLMap:ME.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:A,key:P,sep:E,value:R}=k,I=Bm.resolveProps(A,{flow:a,indicator:"explicit-key-ind",next:P??E?.[0],offset:d,onError:s,parentIndent:r.indent,startOnNewline:!1});if(!I.found){if(!I.anchor&&!I.tag&&!E&&!R){y===0&&I.comma?s(I.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):y<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&&BE.containsNewline(P)&&s(P,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(y===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];$E.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&&!E&&!I.found){let L=R?t(n,R,I,s):e(n,I.end,E,null,I,s);c.items.push(L),d=L.range[2],Qc(R)&&s(L.range,"BLOCK_IN_FLOW",Xc)}else{n.atKey=!0;let L=I.end,T=P?t(n,P,I,s):e(n,L,A,null,I,s);Qc(P)&&s(T.range,"BLOCK_IN_FLOW",Xc),n.atKey=!1;let F=Bm.resolveProps(E??[],{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(E)for(let U of E){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 ee=R?t(n,R,F,s):F.found?e(n,F.end,E,null,F,s):null;ee?Qc(R)&&s(ee.range,"BLOCK_IN_FLOW",Xc):F.comment&&(T.comment?T.comment+=`
|
|
91
|
+
`+F.comment:T.comment=F.comment);let ne=new LE.Pair(T,ee);if(n.options.keepSourceTokens&&(ne.srcToken=k),o){let U=c;jE.mapIncludes(n,U.items,T)&&s(L,"DUPLICATE_KEY","Map keys must be unique"),U.items.push(ne)}else{let U=new Dm.YAMLMap(n.schema);U.flow=!0,U.items.push(ne);let re=(ee??T).range;U.range=[T.range[0],re[1],re[2]],c.items.push(U)}d=ee?ee.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 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&&h.unshift(p)}if(h.length>0){let y=DE.resolveEnd(h,m,n.options.strict,s);y.comment&&(c.comment?c.comment+=`
|
|
92
|
+
`+y.comment:c.comment=y.comment),c.range=[r.offset,m,y.offset]}else c.range=[r.offset,m,m];return c}jm.resolveFlowCollection=FE});var qm=_(Um=>{"use strict";var UE=J(),qE=se(),JE=Lt(),WE=Mt(),KE=Nm(),HE=Lm(),zE=Fm();function Zc(t,e,n,r,s,i){let o=n.type==="block-map"?KE.resolveBlockMap(t,e,n,r,i):n.type==="block-seq"?HE.resolveBlockSeq(t,e,n,r,i):zE.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 YE(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===JE.YAMLMap.tagName&&a==="map"||o===WE.YAMLSeq.tagName&&a==="seq")return Zc(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),Zc(t,e,n,s,o)}let c=Zc(t,e,n,s,o,l),u=l.resolve?.(c,f=>s(i,"TAG_RESOLVE_FAILED",f),e.options)??c,d=UE.isNode(u)?u:new qE.Scalar(u);return d.range=c.range,d.tag=o,l?.format&&(d.format=l.format),d}Um.composeCollection=YE});var tu=_(Jm=>{"use strict";var eu=se();function VE(t,e,n){let r=e.offset,s=GE(e,t.options.strict,n);if(!s)return{value:"",type:null,comment:"",range:[r,r,r]};let i=s.mode===">"?eu.Scalar.BLOCK_FOLDED:eu.Scalar.BLOCK_LITERAL,o=e.source?XE(e.source):[],a=o.length;for(let m=o.length-1;m>=0;--m){let y=o[m][1];if(y===""||y==="\r")a=m;else break}if(a===0){let m=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:m,type:i,comment:s.comment,range:[r,y,y]}}let l=e.indent+s.indent,c=e.offset+s.length,u=0;for(let m=0;m<a;++m){let[y,k]=o[m];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=m,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 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[y,k]=o[m];c+=y.length+k.length+1;let A=k[k.length-1]==="\r";if(A&&(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-(A?2:1),"BAD_INDENT",E),y=""}i===eu.Scalar.BLOCK_LITERAL?(d+=f+y.slice(l)+k,f=`
|
|
95
|
+
`):y.length>l||k[0]===" "?(f===" "?f=`
|
|
96
|
+
`:!p&&f===`
|
|
97
|
+
`&&(f=`
|
|
98
|
+
|
|
99
|
+
`),d+=f+y.slice(l)+k,f=`
|
|
100
|
+
`,p=!0):k===""?f===`
|
|
101
101
|
`?d+=`
|
|
102
|
-
`:
|
|
103
|
-
`:(d+=
|
|
104
|
-
`+o[
|
|
102
|
+
`:f=`
|
|
103
|
+
`:(d+=f+k,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]!==`
|
|
105
105
|
`&&(d+=`
|
|
106
106
|
`);break;default:d+=`
|
|
107
|
-
`}let
|
|
107
|
+
`}let h=r+s.length+e.source.length;return{value:d,type:i,comment:s.comment,range:[r,h,h]}}function GE({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 XE(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}Jm.resolveBlockScalar=VE});var ru=_(Km=>{"use strict";var nu=se(),QE=Hn();function ZE(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=nu.Scalar.PLAIN,l=eA(i,c);break;case"single-quoted-scalar":a=nu.Scalar.QUOTE_SINGLE,l=tA(i,c);break;case"double-quoted-scalar":a=nu.Scalar.QUOTE_DOUBLE,l=nA(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=QE.resolveEnd(o,u,e,n);return{value:l,type:a,comment:d.comment,range:[r,u,d.offset]}}function eA(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}`),Wm(t)}function tA(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),Wm(t.slice(1,-1)).replace(/''/g,"'")}function Wm(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
|
|
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 nA(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}=
|
|
113
|
+
`){let{fold:i,offset:o}=rA(t,r);n+=i,r=o}else if(s==="\\"){let i=t[++r],o=sA[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+=
|
|
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+=iA(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
|
|
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 rA(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
|
|
122
|
-
`,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function
|
|
121
|
+
`),e+=1,r=t[e+1];return n||(n=" "),{fold:n,offset:e}}var sA={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 iA(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)}Km.resolveFlowScalar=ZE});var Ym=_(zm=>{"use strict";var ln=J(),Hm=se(),oA=tu(),aA=ru();function lA(t,e,n,r){let{value:s,type:i,comment:o,range:a}=e.type==="block-scalar"?oA.resolveBlockScalar(t,e,r):aA.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[ln.SCALAR]:l?c=cA(t.schema,s,l,n,r):e.type==="scalar"?c=uA(t,s,e,r):c=t.schema[ln.SCALAR];let u;try{let d=c.resolve(s,f=>r(n??e,"TAG_RESOLVE_FAILED",f),t.options);u=ln.isScalar(d)?d:new Hm.Scalar(d)}catch(d){let f=d instanceof Error?d.message:String(d);r(n??e,"TAG_RESOLVE_FAILED",f),u=new Hm.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 cA(t,e,n,r,s){if(n==="!")return t[ln.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[ln.SCALAR])}function uA({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[ln.SCALAR];if(n.compat){let a=n.compat.find(l=>l.default&&l.test?.test(r))??n[ln.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}zm.composeScalar=lA});var Gm=_(Vm=>{"use strict";function dA(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}Vm.emptyScalarPosition=dA});var Zm=_(iu=>{"use strict";var fA=Yr(),pA=J(),hA=qm(),Xm=Ym(),mA=Hn(),gA=Gm(),yA={composeNode:Qm,composeEmptyNode:su};function Qm(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=bA(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=Xm.composeScalar(t,e,l,r),a&&(c.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":c=hA.composeCollection(yA,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=su(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&&(!pA.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 su(t,e,n,r,{spaceBefore:s,comment:i,anchor:o,tag:a,end:l},c){let u={type:"scalar",offset:gA.emptyScalarPosition(e,n,r),indent:-1,source:""},d=Xm.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 bA({options:t},{offset:e,source:n,end:r},s){let i=new fA.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=mA.resolveEnd(r,o,t.strict,s);return i.range=[e,o,a.offset],a.comment&&(i.comment=a.comment),i}iu.composeEmptyNode=su;iu.composeNode=Qm});var ng=_(tg=>{"use strict";var wA=ds(),eg=Zm(),vA=Hn(),SA=ms();function kA(t,e,{offset:n,start:r,value:s,end:i},o){let a=Object.assign({_directives:e},t),l=new wA.Document(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},u=SA.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?eg.composeNode(c,s,u,o):eg.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}tg.composeDoc=kA});var au=_(ig=>{"use strict";var xA=vi("process"),EA=Hl(),AA=ds(),gs=hs(),rg=J(),TA=ng(),OA=Hn();function ys(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 sg(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
|
|
126
|
-
${r}`:r;else if(s||e.directives.docStart||!i)e.commentBefore=r;else if(
|
|
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 ou=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(n,r,s,i)=>{let o=ys(n);i?this.warnings.push(new gs.YAMLWarning(o,r,s)):this.errors.push(new gs.YAMLParseError(o,r,s))},this.directives=new EA.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,n){let{comment:r,afterEmptyLine:s}=sg(this.prelude);if(r){let i=e.contents;if(n)e.comment=e.comment?`${e.comment}
|
|
126
|
+
${r}`:r;else if(s||e.directives.docStart||!i)e.commentBefore=r;else if(rg.isCollection(i)&&!i.flow&&i.items.length>0){let o=i.items[0];rg.isPair(o)&&(o=o.key);let a=o.commentBefore;o.commentBefore=a?`${r}
|
|
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:
|
|
129
|
-
${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.push(new
|
|
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:sg(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(xA.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(n,r,s)=>{let i=ys(e);i[0]+=n,this.onError(i,"BAD_DIRECTIVE",r,s)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let n=TA.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 gs.YAMLParseError(ys(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 gs.YAMLParseError(ys(e),"UNEXPECTED_TOKEN",r));break}this.doc.directives.docEnd=!0;let n=OA.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 gs.YAMLParseError(ys(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 AA.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}}};ig.Composer=ou});var lg=_(bo=>{"use strict";var PA=tu(),CA=ru(),_A=hs(),og=Zr();function RA(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 _A.YAMLParseError([a,a+1],i,o)};switch(t.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return CA.resolveFlowScalar(t,e,r);case"block-scalar":return PA.resolveBlockScalar({options:{strict:e}},t,r)}}return null}function IA(t,e){let{implicitKey:n=!1,indent:r,inFlow:s=!1,offset:i=-1,type:o="PLAIN"}=e,a=og.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
|
-
`),
|
|
132
|
-
`,
|
|
133
|
-
`}),{type:"block-scalar",offset:i,indent:r,props:
|
|
131
|
+
`),u=a.substring(0,c),d=a.substring(c+1)+`
|
|
132
|
+
`,f=[{type:"block-scalar-header",offset:i,indent:r,source:u}];return ag(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 NA(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=og.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">":$A(t,l);break;case'"':lu(t,l,"double-quoted-scalar");break;case"'":lu(t,l,"single-quoted-scalar");break;default:lu(t,l,"scalar")}}function $A(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}];
|
|
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
|
|
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})}}}bo.createScalarToken=
|
|
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}];ag(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 ag(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 lu(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})}}}bo.createScalarToken=IA;bo.resolveAsScalar=RA;bo.setScalarValue=NA});var ug=_(cg=>{"use strict";var LA=t=>"type"in t?vo(t):wo(t);function vo(t){switch(t.type){case"block-scalar":{let e="";for(let n of t.props)e+=vo(n);return e+t.source}case"block-map":case"block-seq":{let e="";for(let n of t.items)e+=wo(n);return e}case"flow-collection":{let e=t.start.source;for(let n of t.items)e+=wo(n);for(let n of t.end)e+=n.source;return e}case"document":{let e=wo(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 wo({start:t,key:e,sep:n,value:r}){let s="";for(let i of t)s+=i.source;if(e&&(s+=vo(e)),n)for(let i of n)s+=i.source;return r&&(s+=vo(r)),s}cg.stringify=LA});var hg=_(pg=>{"use strict";var cu=Symbol("break visit"),MA=Symbol("skip children"),dg=Symbol("remove item");function cn(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),fg(Object.freeze([]),t,e)}cn.BREAK=cu;cn.SKIP=MA;cn.REMOVE=dg;cn.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};cn.parentCollection=(t,e)=>{let n=cn.itemAtPath(t,e.slice(0,-1)),r=e[e.length-1][0],s=n?.[r];if(s&&"items"in s)return s;throw new Error("Parent collection not found")};function fg(t,e,n){let r=n(e,t);if(typeof r=="symbol")return r;for(let s of["key","value"]){let i=e[s];if(i&&"items"in i){for(let o=0;o<i.items.length;++o){let a=fg(Object.freeze(t.concat([[s,o]])),i.items[o],n);if(typeof a=="number")o=a-1;else{if(a===cu)return cu;a===dg&&(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=cn});var So=_(Se=>{"use strict";var uu=lg(),DA=ug(),BA=hg(),du="\uFEFF",fu="",pu="",hu="",jA=t=>!!t&&"items"in t,FA=t=>!!t&&(t.type==="scalar"||t.type==="single-quoted-scalar"||t.type==="double-quoted-scalar"||t.type==="block-scalar");function UA(t){switch(t){case du:return"<BOM>";case fu:return"<DOC>";case pu:return"<FLOW_END>";case hu:return"<SCALAR>";default:return JSON.stringify(t)}}function qA(t){switch(t){case du:return"byte-order-mark";case fu:return"doc-mode";case pu:return"flow-error-end";case hu: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}
|
|
140
|
-
`:case"\r":case" ":return!0;default:return!1}}var
|
|
141
|
-
\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}Se.createScalarToken=uu.createScalarToken;Se.resolveAsScalar=uu.resolveAsScalar;Se.setScalarValue=uu.setScalarValue;Se.stringify=DA.stringify;Se.visit=BA.visit;Se.BOM=du;Se.DOCUMENT=fu;Se.FLOW_END=pu;Se.SCALAR=hu;Se.isCollection=jA;Se.isScalar=FA;Se.prettyToken=UA;Se.tokenType=qA});var yu=_(gg=>{"use strict";var bs=So();function ze(t){switch(t){case void 0:case" ":case`
|
|
140
|
+
`:case"\r":case" ":return!0;default:return!1}}var mg=new Set("0123456789ABCDEFabcdef"),JA=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),ko=new Set(",[]{}"),WA=new Set(` ,[]{}
|
|
141
|
+
\r `),mu=t=>!t||WA.has(t),gu=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,n=!1){if(e){if(typeof e!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!n;let r=this.next??"stream";for(;r&&(n||this.hasChars(1));)r=yield*this.parseNext(r)}atLineEnd(){let e=this.pos,n=this.buffer[e];for(;n===" "||n===" ";)n=this.buffer[++e];return!n||n==="#"||n===`
|
|
142
142
|
`?!0:n==="\r"?this.buffer[e+1]===`
|
|
143
143
|
`:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let n=this.buffer[e];if(this.indentNext>0){let r=0;for(;n===" ";)n=this.buffer[++r+e];if(n==="\r"){let s=this.buffer[r+e+1];if(s===`
|
|
144
144
|
`||!s&&!this.atEnd)return e+r+1}return n===`
|
|
145
|
-
`||r>=this.indentNext||!n&&!this.atEnd?e+r:-1}if(n==="-"||n==="."){let r=this.buffer.substr(e,3);if((r==="---"||r==="...")&&
|
|
146
|
-
`,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===
|
|
145
|
+
`||r>=this.indentNext||!n&&!this.atEnd?e+r:-1}if(n==="-"||n==="."){let r=this.buffer.substr(e,3);if((r==="---"||r==="...")&&ze(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!="number"||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
|
|
146
|
+
`,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===bs.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let n=e.length,r=e.indexOf("#");for(;r!==-1;){let i=e[r-1];if(i===" "||i===" "){n=r-1;break}else r=e.indexOf("#",r+1)}for(;;){let i=e[n-1];if(i===" "||i===" ")n-=1;else break}let s=(yield*this.pushCount(n))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-s),this.pushNewline(),"stream"}if(this.atLineEnd()){let n=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-n),yield*this.pushNewline(),"stream"}return yield bs.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let n=this.peek(3);if((n==="---"||n==="...")&&ze(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,n==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!ze(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,n]=this.peek(2);if(!n&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&ze(n)){let r=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=r,yield*this.parseBlockStart()}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let n=yield*this.pushIndicators();switch(e[n]){case"#":yield*this.pushCount(e.length-n);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(mu),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return n+=yield*this.parseBlockScalarHeader(),n+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-n),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,n,r=-1;do e=yield*this.pushNewline(),e>0?(n=yield*this.pushSpaces(!1),this.indentValue=r=n):n=0,n+=yield*this.pushSpaces(!0);while(e+n>0);let s=this.getLine();if(s===null)return this.setNext("flow");if((r!==-1&&r<this.indentNext&&s[0]!=="#"||r===0&&(s.startsWith("---")||s.startsWith("..."))&&ze(s[3]))&&!(r===this.indentNext-1&&this.flowLevel===1&&(s[0]==="]"||s[0]==="}")))return this.flowLevel=0,yield bs.FLOW_END,yield*this.parseLineStart();let i=0;for(;s[i]===",";)i+=yield*this.pushCount(1),i+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(i+=yield*this.pushIndicators(),s[i]){case void 0:return"flow";case"#":return yield*this.pushCount(s.length-i),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(mu),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||ze(o)||o===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),n=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;n!==-1&&this.buffer[n+1]==="'";)n=this.buffer.indexOf("'",n+2);else for(;n!==-1;){let i=0;for(;this.buffer[n-1-i]==="\\";)i+=1;if(i%2===0)break;n=this.buffer.indexOf('"',n+1)}let r=this.buffer.substring(0,n),s=r.indexOf(`
|
|
147
147
|
`,this.pos);if(s!==-1){for(;s!==-1;){let i=this.continueScalar(s+1);if(i===-1)break;s=r.indexOf(`
|
|
148
|
-
`,i)}s!==-1&&(n=s-(r[s-1]==="\r"?2:1))}if(n===-1){if(!this.atEnd)return this.setNext("quoted-scalar");n=this.buffer.length}return yield*this.pushToIndex(n+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let n=this.buffer[++e];if(n==="+")this.blockScalarKeep=!0;else if(n>"0"&&n<="9")this.blockScalarIndent=Number(n)-1;else if(n!=="-")break}return yield*this.pushUntil(n=>
|
|
148
|
+
`,i)}s!==-1&&(n=s-(r[s-1]==="\r"?2:1))}if(n===-1){if(!this.atEnd)return this.setNext("quoted-scalar");n=this.buffer.length}return yield*this.pushToIndex(n+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let n=this.buffer[++e];if(n==="+")this.blockScalarKeep=!0;else if(n>"0"&&n<="9")this.blockScalarIndent=Number(n)-1;else if(n!=="-")break}return yield*this.pushUntil(n=>ze(n)||n==="#")}*parseBlockScalar(){let e=this.pos-1,n=0,r;e:for(let i=this.pos;r=this.buffer[i];++i)switch(r){case" ":n+=1;break;case`
|
|
149
149
|
`:e=i,n=0;break;case"\r":{let o=this.buffer[i+1];if(!o&&!this.atEnd)return this.setNext("block-scalar");if(o===`
|
|
150
150
|
`)break}default:break e}if(!r&&!this.atEnd)return this.setNext("block-scalar");if(n>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=n:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let i=this.continueScalar(e+1);if(i===-1)break;e=this.buffer.indexOf(`
|
|
151
151
|
`,i)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let s=e+1;for(r=this.buffer[s];r===" ";)r=this.buffer[++s];if(r===" "){for(;r===" "||r===" "||r==="\r"||r===`
|
|
152
152
|
`;)r=this.buffer[++s];e=s-1}else if(!this.blockScalarKeep)do{let i=e-1,o=this.buffer[i];o==="\r"&&(o=this.buffer[--i]);let a=i;for(;o===" ";)o=this.buffer[--i];if(o===`
|
|
153
|
-
`&&i>=this.pos&&i+1+n>a)e=i;else break}while(!0);return yield
|
|
153
|
+
`&&i>=this.pos&&i+1+n>a)e=i;else break}while(!0);return yield bs.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(ze(i)||e&&ko.has(i))break;n=r}else if(ze(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&&ko.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&&ko.has(s))break;n=r}return!s&&!this.atEnd?this.setNext("plain-scalar"):(yield
|
|
156
|
+
`){let o=this.continueScalar(r+1);if(o===-1)break;r=Math.max(r,o-2)}}else{if(e&&ko.has(s))break;n=r}return!s&&!this.atEnd?this.setNext("plain-scalar"):(yield bs.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(mu))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let e=this.flowLevel>0,n=this.charAt(1);if(ze(n)||e&&ko.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(;!ze(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(JA.has(n))n=this.buffer[++e];else if(n==="%"&&mg.has(this.buffer[e+1])&&mg.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)}};
|
|
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)}};gg.Lexer=gu});var wu=_(yg=>{"use strict";var bu=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let n=0,r=this.lineStarts.length;for(;n<r;){let i=n+r>>1;this.lineStarts[i]<e?n=i+1:r=i}if(this.lineStarts[n]===e)return{line:n+1,col:1};if(n===0)return{line:0,col:e};let s=this.lineStarts[n-1];return{line:n,col:e-s+1}}}};yg.LineCounter=bu});var Su=_(kg=>{"use strict";var KA=vi("process"),bg=So(),HA=yu();function Dt(t,e){for(let n=0;n<t.length;++n)if(t[n].type===e)return!0;return!1}function wg(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 Sg(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 xo(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 zn(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 vg(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!Dt(e.start,"explicit-key-ind")&&!Dt(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,Sg(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 vu=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 HA.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,KA.env.LOG_TOKENS&&console.log("|",bg.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let n=bg.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"&&vg(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&&wg(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":{wg(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=xo(this.peek(2)),r=zn(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(
|
|
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(Dt(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(Sg(n.key)&&!Dt(n.sep,"newline")){let o=zn(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(Dt(n.start,"newline"))Object.assign(n,{key:null,sep:[this.sourceToken]});else{let o=zn(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]}):Dt(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&&!Dt(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||Dt(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=xo(r),i=zn(s);vg(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=xo(e),r=zn(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=xo(e),r=zn(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())}}};
|
|
163
|
-
`),n=e.trim();if(
|
|
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=xo(e),r=zn(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=xo(e),r=zn(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())}}};kg.Parser=vu});var Og=_(vs=>{"use strict";var xg=au(),zA=ds(),ws=hs(),YA=ic(),VA=J(),GA=wu(),Eg=Su();function Ag(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new GA.LineCounter||null,prettyErrors:e}}function XA(t,e={}){let{lineCounter:n,prettyErrors:r}=Ag(e),s=new Eg.Parser(n?.addNewLine),i=new xg.Composer(e),o=Array.from(i.compose(s.parse(t)));if(r&&n)for(let a of o)a.errors.forEach(ws.prettifyError(t,n)),a.warnings.forEach(ws.prettifyError(t,n));return o.length>0?o:Object.assign([],{empty:!0},i.streamInfo())}function Tg(t,e={}){let{lineCounter:n,prettyErrors:r}=Ag(e),s=new Eg.Parser(n?.addNewLine),i=new xg.Composer(e),o=null;for(let a of i.compose(s.parse(t),!0,t.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new ws.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&n&&(o.errors.forEach(ws.prettifyError(t,n)),o.warnings.forEach(ws.prettifyError(t,n))),o}function QA(t,e,n){let r;typeof e=="function"?r=e:n===void 0&&e&&typeof e=="object"&&(n=e);let s=Tg(t,n);if(!s)return null;if(s.warnings.forEach(i=>YA.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 ZA(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 VA.isDocument(t)&&!r?t.toString(n):new zA.Document(t,r,n).toString(n)}vs.parse=QA;vs.parseAllDocuments=XA;vs.parseDocument=Tg;vs.stringify=ZA});var Cg=_(K=>{"use strict";var eT=au(),tT=ds(),nT=Uc(),ku=hs(),rT=Yr(),Bt=J(),sT=Nt(),iT=se(),oT=Lt(),aT=Mt(),lT=So(),cT=yu(),uT=wu(),dT=Su(),Eo=Og(),Pg=Wr();K.Composer=eT.Composer;K.Document=tT.Document;K.Schema=nT.Schema;K.YAMLError=ku.YAMLError;K.YAMLParseError=ku.YAMLParseError;K.YAMLWarning=ku.YAMLWarning;K.Alias=rT.Alias;K.isAlias=Bt.isAlias;K.isCollection=Bt.isCollection;K.isDocument=Bt.isDocument;K.isMap=Bt.isMap;K.isNode=Bt.isNode;K.isPair=Bt.isPair;K.isScalar=Bt.isScalar;K.isSeq=Bt.isSeq;K.Pair=sT.Pair;K.Scalar=iT.Scalar;K.YAMLMap=oT.YAMLMap;K.YAMLSeq=aT.YAMLSeq;K.CST=lT;K.Lexer=cT.Lexer;K.LineCounter=uT.LineCounter;K.Parser=dT.Parser;K.parse=Eo.parse;K.parseAllDocuments=Eo.parseAllDocuments;K.parseDocument=Eo.parseDocument;K.stringify=Eo.stringify;K.visit=Pg.visit;K.visitAsync=Pg.visitAsync});function pT(t){try{return JSON.parse(t.trim()),!0}catch{return!1}}function hT(t){let e=t.trim();if(!e.startsWith("<"))return!1;let n=e.match(fT);return n?Jr(e,n[1])!==null:!1}function mT(t){let e=t.trim();if(!e.match(/^(---|#|\w+:|-)/)||"[{<".includes(e[0]))return!1;try{let n=_g.parse(e);return n!==null&&typeof n=="object"}catch{return!1}}function Rg(t){return pT(t)||hT(t)||mT(t)}var _g,fT,xu=v(()=>{Up();_g=wk(Cg(),1),fT=/<([a-zA-Z_][\w.-]*)/});function gT(t){if(!t?.trim())return[];let e=t.replace(/\r\n/g,`
|
|
163
|
+
`),n=e.trim();if(Rg(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 Ao(t){return
|
|
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 Ao(t){return gT(t).map(e=>e.text)}var Ig,Ng=v(()=>{xu();Ig=`
|
|
167
167
|
|
|
168
168
|
|
|
169
|
-
`});function To(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var Dg=S(()=>{});var vT,ST,Su,Bg=S(()=>{vT=[["\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","-"]],ST=new Map(vT),Su=ST});var jg,Oo,ku,Fg=S(()=>{jg=[["\xE6","ae"],["\xC6","Ae"],["\xF8","oe"],["\xD8","Oe"],["\xE5","aa"],["\xC5","Aa"]],Oo={sv:[["\xE4","a"],["\xC4","A"],["\xF6","o"],["\xD6","O"],["\xE5","a"],["\xC5","A"]],da:jg,nb:jg,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(Oo))Oo[t]=new Map(Oo[t]);ku=Oo});function xu(t,e){if(typeof t!="string")throw new TypeError(`Expected a string, got \`${typeof t}\``);e={customReplacements:[],...e};let n=xT(e.locale),r=Su,s=e.customReplacements.length>0||e.customReplacements.size>0;if(n||s){if(r=new Map(Su),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=kT(t,r),t=t.normalize("NFD").replaceAll(/\p{Diacritic}/gu,"").normalize(),t=t.replaceAll(/\p{Dash_Punctuation}/gu,"-"),t}var kT,xT,Ug=S(()=>{Bg();Fg();kT=(t,e)=>{for(let[n,r]of e)t=t.replaceAll(n,r);return t},xT=t=>{if(!t)return;let e=t.toLowerCase().replace(/^no(-|$)/,"nb$1");return ku[e]||ku[e.split("-")[0]]||void 0}});var ET,qg,Jg=S(()=>{ET=[["&"," and "],["\u{1F984}"," unicorn "],["\u2665"," love "]],qg=ET});function Eu(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([...qg,...e.customReplacements]);t=xu(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=AT(t));let s=OT(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=TT(t,e.separator)),n&&(t=`_${t}`),r&&(t=`${t}-`),t}var AT,TT,OT,Wg=S(()=>{Dg();Ug();Jg();AT=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"),TT=(t,e)=>{let n=To(e);return t.replaceAll(new RegExp(`(?:${n}){2,}`,"g"),e).replaceAll(new RegExp(`^(?:${n})|(?:${n})$`,"g"),"")},OT=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+=To(r)}let n=t.transliterate?"g":"gu";return new RegExp(`[^${e}]+`,n)}});function Yn(t){return Eu(t)}var Kg=S(()=>{Wg()});var Vn,Hg,zg=S(()=>{Vn={local:"local",ide:"ide",published:"published",inline:"inline"},Hg=Object.values(Vn).map(t=>`'${t}'`).join(" | ")});var bs,Au,Yg=S(()=>{bs=` *, *::before, *::after { box-sizing: border-box; }
|
|
169
|
+
`});function To(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var $g=v(()=>{});var yT,bT,Eu,Lg=v(()=>{yT=[["\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","-"]],bT=new Map(yT),Eu=bT});var Mg,Oo,Au,Dg=v(()=>{Mg=[["\xE6","ae"],["\xC6","Ae"],["\xF8","oe"],["\xD8","Oe"],["\xE5","aa"],["\xC5","Aa"]],Oo={sv:[["\xE4","a"],["\xC4","A"],["\xF6","o"],["\xD6","O"],["\xE5","a"],["\xC5","A"]],da:Mg,nb:Mg,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(Oo))Oo[t]=new Map(Oo[t]);Au=Oo});function Tu(t,e){if(typeof t!="string")throw new TypeError(`Expected a string, got \`${typeof t}\``);e={customReplacements:[],...e};let n=vT(e.locale),r=Eu,s=e.customReplacements.length>0||e.customReplacements.size>0;if(n||s){if(r=new Map(Eu),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=wT(t,r),t=t.normalize("NFD").replaceAll(/\p{Diacritic}/gu,"").normalize(),t=t.replaceAll(/\p{Dash_Punctuation}/gu,"-"),t}var wT,vT,Bg=v(()=>{Lg();Dg();wT=(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 Au[e]||Au[e.split("-")[0]]||void 0}});var ST,jg,Fg=v(()=>{ST=[["&"," and "],["\u{1F984}"," unicorn "],["\u2665"," love "]],jg=ST});function Ou(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([...jg,...e.customReplacements]);t=Tu(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=kT(t));let s=ET(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=xT(t,e.separator)),n&&(t=`_${t}`),r&&(t=`${t}-`),t}var kT,xT,ET,Ug=v(()=>{$g();Bg();Fg();kT=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"),xT=(t,e)=>{let n=To(e);return t.replaceAll(new RegExp(`(?:${n}){2,}`,"g"),e).replaceAll(new RegExp(`^(?:${n})|(?:${n})$`,"g"),"")},ET=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+=To(r)}let n=t.transliterate?"g":"gu";return new RegExp(`[^${e}]+`,n)}});function Yn(t){return Ou(t)}var qg=v(()=>{Ug()});var Vn,Jg,Wg=v(()=>{Vn={local:"local",ide:"ide",published:"published",inline:"inline"},Jg=Object.values(Vn).map(t=>`'${t}'`).join(" | ")});var Ss,Pu,Kg=v(()=>{Ss=` *, *::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; }`,
|
|
173
|
+
html[data-theme="light"] { color-scheme: light; }`,Pu=" html, body { height: 100%; }"});var Hg,zg=v(()=>{Hg=`(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
|
|
241
|
+
})();`});var Yg,Vg=v(()=>{Yg=`(function () {
|
|
242
242
|
var W = window;
|
|
243
243
|
var rtData, rtInsight, rtHasInsight = false;
|
|
244
244
|
var applyData, applyInsight, send;
|
|
@@ -292,40 +292,40 @@ ${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 Q=
|
|
296
|
-
\u2026[${t.length-
|
|
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+
|
|
298
|
-
`);o.partial&&a.shift();let l=[];for(let
|
|
299
|
-
`))if(e.includes('"modelId"'))try{let n=JSON.parse(e).attachment?.identity?.modelId;if(n)return n}catch{}}function
|
|
300
|
-
`):t==null?"":
|
|
295
|
+
})();`});var Q=v(()=>{xi();Dl();_p();$p();xu();Ng();qg();Wg();Kg();zg();Vg();Ei()});function ke(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 Qg(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 Zg(t){return t.replace(/[/\\]+$/,"").split(/[/\\]/).pop()??""}function ey(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 _u(t){let e=/^mcp__(.+?)__(.+)$/.exec(t);return e?`${e[1][0].toUpperCase()}${e[1].slice(1)} [${e[2]}]`:t}var Z,ks,Xg,Po=v(()=>{"use strict";Z=t=>typeof t=="string"?t:void 0,ks=t=>t.replace(/\u001b\[[0-9;]*m/g,""),Xg=t=>` (+${t} line${t===1?"":"s"})`});function Pe(t){return t.length>Ru?t.slice(0,Ru)+`
|
|
296
|
+
\u2026[${t.length-Ru} more characters truncated]`:t}function Le(t){let e=ks(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+Xg(s):r}var Ru,xe,Co,xs=v(()=>{"use strict";Po();Ru=5e4,xe=(t,e,n=e+"s")=>`${t} ${t===1?e:n}`;Co=(t,e)=>``});import{closeSync as ty,existsSync as AT,fstatSync as TT,openSync as ny,readdirSync as OT,readSync as ry,statSync as PT}from"fs";import{join as CT}from"path";function Gn(t,e){let n;try{n=ny(t,"r")}catch{return}try{let r=Buffer.alloc(e),s=ry(n,r,0,e,0);return{text:r.subarray(0,s).toString("utf8"),bytes:s}}finally{ty(n)}}function _o(t,e){let n;try{n=ny(t,"r")}catch{return}try{let r=TT(n).size,s=Math.min(e,r),i=Buffer.alloc(s),o=ry(n,i,0,s,r-s);return{text:i.subarray(0,o).toString("utf8"),partial:r>s}}finally{ty(n)}}function Ro(t){if(!AT(t))return[];let e;try{e=OT(t)}catch{return[]}let n=[];for(let r of e){if(!r.endsWith(".jsonl"))continue;let s=CT(t,r);try{let i=PT(s);i.isFile()&&n.push({sessionId:r.slice(0,-6),file:s,mtime:i.mtimeMs})}catch{}}return n}var Io=v(()=>{"use strict"});var jt,No=v(()=>{"use strict";jt=class{ensureHarnessSupport(){}forRead(){return this}linker(){return{link(){}}}}});import{openSync as _T,readSync as RT,closeSync as IT,statSync as ay,readdirSync as ly,readFileSync as cy,existsSync as NT}from"fs";import{join as un}from"path";import{homedir as $T}from"os";function LT(t){return t.replace(/[^a-zA-Z0-9]/g,"-")}function DT(t,e,n){let r=un(Iu(t,e),n,MT),s;try{s=ly(r)}catch{return[]}let i=oO(t,n),o=[];for(let a of s){if(!a.endsWith(".jsonl"))continue;let l=un(r,a),c;try{c=ay(l)}catch{continue}let u=a.slice(0,-6),d={};try{d=JSON.parse(cy(un(r,`${u}.meta.json`),"utf8"))}catch{}let f=FT(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===BT?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 FT(t,e,n){let r=sy.get(t);if(r&&r.size===e&&r.mtime===n)return r;let s={};for(let i of jT){let o=_o(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:dy(l),failing:!!c?.isApiErrorMessage},!(s.tokens===void 0&&o.partial))break}return s.model??=UT(t),sy.set(t,{size:e,mtime:n,...s}),s}function UT(t){for(let e of(Gn(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 dy(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(qT(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(!uy(e)&&o.trim()&&Ft(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 qT(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 Lo(t){let e=t?.type==="image"?t.source:void 0;return e?.type==="base64"&&e.data?Co(e.data,e.media_type):""}function Es(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?Es(n.content):Lo(n)}).join(`
|
|
300
|
+
`):t==null?"":Pe(JSON.stringify(t))}function JT(t){let e=t.trim();return!!e&&fy.some(n=>n.test(e))}function WT(t){let e=t.trim();return e?fy.some(n=>{let r=n.exec(e);return!!r&&r.index===0}):!0}function HT(t){return t.replace(KT,"")}function zT(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 Ft(t){let e=HT(t).trim();return e?zT(e)??(JT(e)?"":e):""}function Mo(t){let e=YT.exec(t.trim());if(e)return{from:e[1],body:GT(e[2].replace(VT,""))}}function GT(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 $o(t){let e=Mo(t);return e?{type:"user",text:e.body,agent:{from:e.from}}:{type:"user",text:t}}function
|
|
304
|
-
`).length,"line")}`;if(n.mode==="content")return
|
|
305
|
-
`)){if(!p.includes(`"${
|
|
306
|
-
`)){if(!c.trim())continue;let
|
|
307
|
-
`;
|
|
308
|
-
`),
|
|
309
|
-
`):""}function
|
|
310
|
-
`))r.startsWith("+")&&!r.startsWith("+++")?e++:r.startsWith("-")&&!r.startsWith("---")&&n++;return`+${e} \u2212${n}`}function
|
|
311
|
-
`||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
|
|
312
|
-
`)}}function
|
|
313
|
-
`);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
|
|
314
|
-
`);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=
|
|
315
|
-
`))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
|
|
316
|
-
`,t:" ",r:"\r",b:"\b",f:"\f",v:"\v",0:"\0"};
|
|
317
|
-
`).length:0;jo=t=>{let e=
|
|
318
|
-
`))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"?Qn(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"?"":Qn(n.payload.content,r==="user").replace(/\s+/g," ").trim()}},
|
|
319
|
-
`),r=[];if(n.forEach((o,a)=>{let l=
|
|
320
|
-
`)}function tr(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}async function Yu(t){try{await
|
|
303
|
+
`):t}function $o(t){let e=Mo(t);return e?{type:"user",text:e.body,agent:{from:e.from}}:{type:"user",text:t}}function XT(t){let e=t.message?.content;return typeof e=="string"&&!!Mo(e)}function QT(t){let e=t.message?.content;return typeof e=="string"&&e.startsWith(iy)?e.slice(iy.length).trim():void 0}function Nu(t){return t?.type==="text"&&typeof t.text=="string"?Ft(t.text):""}function eO(t){let e=t.type==="attachment"&&t.attachment?.type==="queued_command"?Es(t.attachment.prompt):t.type==="user"?Es(t.message?.content):"";if(!e.includes("<task-notification>"))return[];let n=[];for(let[,r]of e.matchAll(ZT)){let s=/<tool-use-id>([^<]+)<\/tool-use-id>/.exec(r)?.[1],i=/<status>([^<]+)<\/status>/.exec(r)?.[1];if(!s||!i||i==="running")continue;let o=/\bexit(?: code)? (\d+)/.exec(/<summary>([\s\S]*?)<\/summary>/.exec(r)?.[1]??"")?.[1],a=/<output-file>([^<]+)<\/output-file>/.exec(r)?.[1];n.push({type:"task_done",id:s,outcome:i,exit:o===void 0?void 0:Number(o),output:a})}return n}function $u(t,e){if(typeof t=="string")return Le(t);if(!t||typeof t!="object")return Le(e);let n=t;if(n.type==="text"&&typeof n.file?.numLines=="number")return xe(n.file.numLines,"line");if(n.type==="image"){let r=oy(n.file?.originalSize);return r?`image (${r})`:"image"}if(n.type==="pdf"){let r=oy(n.file?.originalSize);return r?`PDF (${r})`:"PDF"}if(n.type==="parts"&&typeof n.file?.count=="number")return xe(n.file.count,"page");if(n.type==="file_unchanged")return"unchanged since last read";if(n.type==="create"&&typeof n.content=="string")return`created, ${xe(n.content.split(`
|
|
304
|
+
`).length,"line")}`;if(n.mode==="content")return xe(n.numLines??0,"line");if(n.mode==="count")return`${xe(n.numMatches??0,"match","matches")} (${xe(n.numFiles??0,"file")})`;if(n.mode==="files_with_matches")return xe(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":Le(n.stdout||n.stderr||"")||"no output":typeof n.code=="number"&&typeof n.codeText=="string"?`${n.code} ${n.codeText}`:typeof n.searchCount=="number"?xe(n.searchCount,"search","searches"):Array.isArray(n.matches)&&typeof n.total_deferred_tools=="number"?xe(n.matches.length,"tool"):Array.isArray(n.newTodos)?xe(n.newTodos.length,"todo"):typeof n.numFiles=="number"?xe(n.numFiles,"file"):Le(e)}function As(t){return!!t.isMeta}function sO(t){let e;try{e=_T(t,"r")}catch{return""}try{let r=65536;try{r=ay(t).size}catch{}let s=(c,u)=>{if(u<=0)return"";let d=Buffer.alloc(u),f=RT(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||As(u)||u.type!=="user")continue;let d=u.message?.content,f="";typeof d=="string"?f=Ft(d):Array.isArray(d)&&(f=d.map(Nu).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{IT(e)}}function Lu(t){let e=un(t,"sessions"),n;try{n=ly(e)}catch{return[]}let r=[];for(let s of n)if(s.endsWith(".json"))try{let i=JSON.parse(cy(un(e,s),"utf8"));if(!i?.sessionId)continue;process.kill(i.pid,0),r.push(i)}catch{}return r}function iO(t,e){return Lu(t).some(n=>n.sessionId===e)}function oO(t,e){let n=Lu(t).filter(r=>r.sessionId===e).map(r=>r.startedAt);return n.length&&n.every(r=>typeof r=="number")?Math.min(...n):void 0}function aO(t){return new Set(Lu(t).filter(e=>e.status==="busy").map(e=>e.sessionId))}var uy,Iu,MT,BT,jT,sy,fy,KT,YT,VT,iy,ZT,tO,nO,rO,oy,Xn,Do=v(()=>{"use strict";xs();Io();No();Po();uy=t=>t.type==="user"&&Array.isArray(t.message?.content)&&t.message.content.some(e=>e?.type==="tool_result");Iu=(t,e)=>un(t,"projects",LT(e)),MT="subagents";BT="general-purpose",jT=[256*1024,4*1024*1024,64*1024*1024],sy=new Map;fy=[/\[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];KT=/<ide_[a-z_]+>[\s\S]*?<\/ide_[a-z_]+>/gi;YT=/^(?:[^\n<][^\n]*\n)?<agent-message from="([^"]+)">\n([\s\S]*?)(?:\n?<\/agent-message>[\s\S]*)?$/,VT=/^\[[^\]\n]+\][\s\S]*?The report follows:\n/;iy=`The coordinator sent a message while you were working:
|
|
307
|
+
`;ZT=/<task-notification>([\s\S]*?)<\/task-notification>/g;tO=/^(Command running in background with ID|Command did not complete within its \d+s timeout and was moved to the background|Async agent launched)/,nO=/\bID: ([A-Za-z0-9]+)/,rO=new Set(["TaskStop","KillShell"]),oy=t=>typeof t!="number"?"":t<1024?`${t}B`:t<1048576?`${Math.round(t/1024)}KB`:`${(t/1048576).toFixed(1)}MB`;Xn=class extends jt{constructor(n=un($T(),".claude")){super();this.root=n}displayName="Claude Mirror";detectsSelf(){return process.env.CLAUDECODE==="1"}detectsInstalled(){return NT(this.root)}sessionsDir(n){return Iu(this.root,n)}listSessionFiles(n){return Ro(Iu(this.root,n))}listChildren(n,r){return DT(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:uy(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=QT(n);if(s)return{events:[$o(s)]};let i=eO(n);if(i.length)return{events:i};if(As(n)&&!XT(n))return{events:[]};let o=[];if(n.type==="user"){let a=n.message?.content;if(typeof a=="string"){let l=Ft(a);l&&o.push($o(l))}else if(Array.isArray(a))for(let l of a)if(l?.type==="tool_result"){let c=Es(l.content),u=l.is_error?/^Exit code (\d+)/.exec(c)?.[1]:void 0,d=n.toolUseResult,f=tO.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:$u(n.toolUseResult,c),exit:u===void 0?void 0:Number(u),background:f||void 0,task:f?nO.exec(c)?.[1]??Z(d?.backgroundTaskId):void 0,refused:!!l.is_error&&u===void 0||void 0})}else{let c=Nu(l)||Lo(l);c&&o.push($o(c))}return{events:o}}if(n.type==="attachment"&&n.attachment?.type==="queued_command"){let a=Ft(Es(n.attachment.prompt));return a&&o.push($o(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=>!WT(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(rO.has(h.name)){let m=Z(h.input.task_id)??Z(h.input.shell_id);m&&o.push({type:"task_done",task:m,outcome:"stopped"})}let 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 dy(n)}sessionAlive(n){return iO(this.root,n)}sessionsWorking(n){return aO(this.root)}readPreview(n){return sO(n)}searchText(n){if(!n||As(n)||n.type!=="user"&&n.type!=="assistant")return"";let r=n.message?.content,s="";if(typeof r=="string")s=Ft(r);else if(Array.isArray(r)){let i=r;s=n.type==="user"?i.map(Nu).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{statSync as Bo,readdirSync as lO,existsSync as cO}from"fs";import{basename as py,join as Mu,resolve as uO}from"path";import{homedir as hy}from"os";function fO(t){let e=t.trimStart();return dO.some(n=>e.startsWith(n))}function Qn(t,e){return Array.isArray(t)?t.map(n=>typeof n?.text=="string"?e&&fO(n.text)?"":Pe(n.text):n?.type==="input_image"&&typeof n.image_url=="string"&&n.image_url.startsWith("data:")?``:"").filter(Boolean).join(`
|
|
309
|
+
`):""}function pO(t){return typeof t=="string"?Pe(t):Qn(t,!1)}function hO(t,e){let n=e??"",r=TO(n);if(!r.length)return{name:t,input:{script:n}};let s=r.map(i=>Du(i.fn)&&Ts(i.arg)?kO(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}=gy(o);return{name:i,input:new Set(a).size===1?{path:a[0],patch:l}:{patch:l},pending:{kind:"patch",digest:yO(l)}}}return Ts(o)?Du(i)?{name:t,input:gO(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",gy(o).diff]:Du(i)&&Ts(o)?["command",o.cmd??o.command]:[i,o]))}}function gO(t){let e=Object.fromEntries(Object.entries(t).filter(([r])=>r!=="cmd"&&r!=="command"&&!mO.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 yO(t){let e=0,n=0;for(let r of t.split(`
|
|
310
|
+
`))r.startsWith("+")&&!r.startsWith("+++")?e++:r.startsWith("-")&&!r.startsWith("---")&&n++;return`+${e} \u2212${n}`}function kO(t){let e=EO(t),n=e.map(xO);return e.length&&n.every(r=>r!==void 0)?n:void 0}function xO(t){let[e,...n]=t.split("|");if(!n.every(i=>SO.test(i.trim())))return;let r=AO(e);if(!bO.test(r[0]??""))return;let s=[];for(let i=1;i<r.length;i++){let o=r[i];if(wO.test(o)){i+1<r.length&&s.push(r[++i]);continue}if(vO.test(o)){i++;continue}o.startsWith("-")||/^\d+(,\d+)?p?$/.test(o)||s.push(o)}return s.length===1?s[0]:void 0}function EO(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===`
|
|
311
|
+
`||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 AO(t){return(t.match(/'[^']*'|"[^"]*"|\S+/g)??[]).map(e=>/^(['"])(.*)\1$/.exec(e)?.[2]??e)}function TO(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=ky(t,s);if(i<0)break;e.push({fn:r[1],arg:Sy(t.slice(s+1,i).trim(),t)}),n.lastIndex=i+1}return e}function Sy(t,e){let n=t[0];if(n==='"'||n==="'"||n==="`")return Fo(t,0)===t.length-1?xy(t.slice(1,-1)):t;if(n==="{"){for(let r of[t,PO(t)])try{let s=JSON.parse(r);if(Ts(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==="`"?Fo(e,s):i==="{"?ky(e,s):-1;if(o>s)return Sy(e.slice(s,o+1),"")}}return t}function ky(t,e){let n=0;for(let r=e;r<t.length;r++){let s=t[r];if(s==='"'||s==="'"||s==="`"){if(r=Fo(t,r),r<0)return-1}else if(s==="("||s==="["||s==="{")n++;else if((s===")"||s==="]"||s==="}")&&--n===0)return r}return-1}function Fo(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 xy(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 PO(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=Fo(t,i);if(l<0)return t;r+=JSON.stringify(xy(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 gy(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(`
|
|
312
|
+
`)}}function CO(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:Le(t)};let r=n[3].replace(/^\n+/,"").replace(/^Script error:\n/,""),s=n[1]==="failed",i=_O(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:xe(RO(r),"line")}:e?.kind==="patch"&&!s?{content:e.digest,isError:s,digest:e.digest}:{content:r,isError:s,digest:Le(r),exit:o}}function _O(t){if(t.startsWith("{"))try{let e=JSON.parse(t);if(Ts(e)&&typeof e.output=="string")return{output:e.output,exit_code:typeof e.exit_code=="number"?e.exit_code:void 0}}catch{}}function IO(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 $O(t){let e,n,r;for(let s of NO){let i=_o(t,s);if(i===void 0)return{};let o=i.text.split(`
|
|
313
|
+
`);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=Ey(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 Ey(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 by(t){let n=Gn(t,65536);if(n===void 0)return;let r=n.text.indexOf(`
|
|
314
|
+
`);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=LO(i,o),l=vy(n.text,r),c=a&&!l&&n.bytes>=65536?Gn(t,wy):void 0,u=l??(c&&vy(c.text,r)),d=!!a&&!u&&(c??n).bytes<(c?wy:65536);return{cwd:i.cwd,subagent:!!o,id:i.id,spawn:a,turn:u,modelPending:d}}catch{return{cwd:"",subagent:!1}}}function LO(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 vy(t,e){for(let n of t.slice(e+1).split(`
|
|
315
|
+
`))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 dO,Ts,Du,mO,bO,wO,vO,SO,OO,RO,jo,yy,Zn,NO,wy,Bu=v(()=>{"use strict";xs();No();Io();dO=["<permissions instructions>","<apps_instructions>","<plugins_instructions>","<skills_instructions>","<recommended_plugins>","<environment_context>","<node_repl_review_evidence>","# AGENTS.md instructions for "];Ts=t=>!!t&&typeof t=="object"&&!Array.isArray(t),Du=t=>t==="shell_command"||t==="exec_command",mO=new Set(["max_output_tokens","yield_time_ms","timeout_ms"]);bO=/^(Get-Content|gc|cat|type|nl|bat|sed|head|tail)$/i,wO=/^-(Path|LiteralPath)$/i,vO=/^-(Encoding|TotalCount|Head|Tail|ReadCount|Delimiter)$/i,SO=/^(sed -n|head|tail|Select-Object|select)(\s|$)/i;OO={n:`
|
|
316
|
+
`,t:" ",r:"\r",b:"\b",f:"\f",v:"\v",0:"\0"};RO=t=>t?t.replace(/\r?\n$/,"").split(`
|
|
317
|
+
`).length:0;jo=t=>{let e=uO(t);return process.platform==="win32"?e.toLowerCase():e},yy=12e4,Zn=class t extends jt{constructor(n=Mu(hy(),".codex","sessions")){super();this.root=n}displayName="Codex Mirror";#t=0;#l;#n=!1;#i;#h=0;#s=new Map;#d=new Map;#o=new Map;#c=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}detectsInstalled(){return cO(Mu(hy(),".codex"))}sessionsDir(n){return this.root}listSessionFiles(n){let r=jo(n),s=[];for(let i of this.#u()){let o=0,a=0;try{let u=Bo(i);if(!u.isFile())continue;o=u.size,a=u.mtimeMs}catch{continue}let l=this.#s.get(i);if(l===void 0){if(l=by(i),l===void 0)continue;this.#s.set(i,l)}if(l.subagent||jo(l.cwd)!==r)continue;let c=py(i,".jsonl");this.#o.set(c,i),s.push({sessionId:c,file:i,mtime:this.#e(i,o,a)})}return s}listChildren(n,r){let s=jo(n),i=new Map,o;for(let c of this.#u()){let u=0,d=0,f;try{let k=Bo(c);if(!k.isFile())continue;u=k.size,d=k.mtimeMs,f=k.birthtimeMs||void 0}catch{continue}let p=this.#s.get(c);if(p===void 0||p.modelPending){if(p=by(c),p===void 0)continue;this.#s.set(c,p)}if(py(c,".jsonl")===r&&(o=p.id),!p.spawn||jo(p.cwd)!==s)continue;let{running:h,tokens:m,turn:y}=this.#r(c,u,d);i.set(p.spawn.id,{file:c,mtime:this.#e(c,u,d),started:f,running:h,tokens:m,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: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>=yy)continue;let l;try{let c=Bo(o);l=this.#r(o,c.size,c.mtimeMs)}catch{continue}l.running&&r.add(i)}return r}#e(n,r,s){return Math.max(s,this.#r(n,r,s).ms??0)}#r(n,r,s){let i=this.#d.get(n);if(i&&i.size===r&&i.mtime===s)return i;let o=$O(n),a={size:r,mtime:s,...o,turn:o.turn??i?.turn};return this.#d.set(n,a),a}#u(){let n=[],r=s=>{try{return lO(s).map(i=>Mu(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.#a(n),n.ord=String(this.#t++),n.parent=this.#l,this.#l=n.ord),n.ord}#a(n){let r=n.payload;if(n.type==="session_meta"){if(++this.#h===1){let s=typeof r?.source=="object"?r.source?.subagent?.thread_spawn:void 0;this.#i=s?.agent_path,this.#n=!!s}}else this.#h=0,this.#n&&r?.type==="agent_message"&&r.recipient===this.#i&&(this.#n=!1);n.inherited=this.#n}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=Qn(i.content,!0).trim();a&&s.push({type:"user",text:a})}else if(i.role==="assistant"){let a=Qn(i.content,!1);a&&s.push({type:"assistant",text:a,thinking:"",tools:[],live:o()})}return{events:s}}if(i.type==="reasoning"){let a=Qn(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"?hO(i.name??"",i.input):{name:i.name??"",input:IO(i.arguments)};return l&&this.#c.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.#c.get(a);return this.#c.delete(a),s.push({type:"tool_result",id:a,...CO(pO(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:Ey(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.#o.get(n);if(!r)return;let s;try{let i=Bo(r);s=this.#e(r,i.size,i.mtimeMs)}catch{return}return Date.now()-s<yy}readPreview(n){for(let r of(Gn(n,256*1024)?.text??"").split(`
|
|
318
|
+
`))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"?Qn(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"?"":Qn(n.payload.content,r==="user").replace(/\s+/g," ").trim()}},NO=[64*1024,1024*1024];wy=512*1024});import{realpathSync as MO}from"fs";import{createHash as DO}from"crypto";import{join as Uo,resolve as BO}from"path";import{homedir as jO}from"os";function ft(){let t=process.env.TYPEBULB_SERVERS_DIR;return t?Uo(t,".."):Uo(jO(),".typebulb")}function pt(){Ay||(Ay=!0,console.error(`${ft()} not writable \u2014 continuing stateless: ports won't stick, caches stay cold, and typebulb logs/wait/send/stop may not see this run`))}function ht(){return process.env.TYPEBULB_SERVERS_DIR||Uo(ft(),"servers")}function Ty(t){let e=ie(t),n=e.slice(e.lastIndexOf("/")+1).replace(/\.bulb\.md$/,"");return Uo(ft(),"canvas",`${n}-${Os(t)}.png`)}function Os(t){return DO("sha1").update(ie(t)).digest("hex").slice(0,8)}function ie(t){let e=BO(t),n=e;try{n=MO.native(e)}catch{}return(process.platform==="win32"?n.toLowerCase():n).replace(/\\/g,"/")}function Oy(t,e){let n=ie(t),r=ie(e);return n.startsWith(r.endsWith("/")?r:r+"/")?!n.includes("/node_modules/"):!1}var Ay,Ye=v(()=>{"use strict";Ay=!1});import*as _y from"net";import{mkdir as FO,readFile as UO,writeFile as Ry}from"fs/promises";import{existsSync as qO}from"fs";import{join as Iy}from"path";function Ly(){return Iy(ft(),"blocks")}function ju(t){return Iy(Ly(),`${t}.json`)}function Jo(t){return new Promise(e=>{let n=_y.createServer();n.once("error",()=>e(!1)),n.listen(t,"127.0.0.1",()=>n.close(()=>e(!0)))})}async function HO(t){for(let e=t;e<65535;e++)if(await Jo(e))return e;throw new Error(`No free port found above ${t}`)}async function Fu(t){let{listBulbServers:e}=await Promise.resolve().then(()=>(Me(),My)),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 Wo(t){try{let e=JSON.parse(await UO(ju(t),"utf8"));return e&&typeof e.cwd=="string"?{cwd:e.cwd,slots:e.slots??{},mirrors:e.mirrors??{}}:void 0}catch{return}}async function Ko(t,e){try{return await Ry(ju(t),JSON.stringify(e,null,2)),!0}catch{return pt(),!1}}async function zO(t){let e=ie(t);try{await FO(Ly(),{recursive:!0})}catch{return}let n=[];for(let o=0;o<$y;o++)n.push(Ny+o*dn);let r=await Promise.all(n.map(async o=>({base:o,block:await Wo(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 Ry(ju(o),JSON.stringify(s,null,2),{flag:"wx"}),o}catch(l){if((await Wo(o))?.cwd===e)return o;l.code!=="EEXIST"&&pt();continue}if(!qO(a.cwd))return await Ko(o,s)?o:void 0}let i=r.filter(o=>!!o.block).sort((o,a)=>Py(o.block)-Py(a.block))[0];if(i)return await Ko(i.base,s)?i.base:void 0}function Py(t){return Object.values(t.slots).reduce((e,n)=>Math.max(e,n.usedAt??0),0)}async function YO(t,e){let n=await Wo(t)??{cwd:"",slots:{},mirrors:{}};if(e.kind==="mirror"){let i=n.mirrors[e.agent];if(i!==void 0)return i;let o=Cy(n),a=o.has(0)?WO:0;for(;a>qo&&o.has(a);)a--;return n.mirrors[e.agent]=a,await Ko(t,n),a}let r=ie(e.file),s=n.slots[r]?.offset;if(s===void 0){let i=Cy(n);for(s=qo;s<dn&&i.has(s);)s++;if(s>=dn){let o=Object.entries(n.slots).sort((a,l)=>(a[1].usedAt??0)-(l[1].usedAt??0))[0];s=o?o[1].offset:qo,o&&delete n.slots[o[0]]}}return n.slots[r]={offset:s,usedAt:Date.now()},await Ko(t,n),s}function Cy(t){return new Set([...Object.values(t.mirrors),...Object.values(t.slots).map(e=>e.offset)])}async function er(t,e){let n=await zO(e);return n===void 0?void 0:n+await YO(n,t)}async function fn(t){let e=ie(t);for(let n=0;n<$y;n++){let r=await Wo(Ny+n*dn);if(r?.cwd===e)return s=>r.slots[ie(s)]?.usedAt??0}return()=>0}async function Ho(t){if(t.explicit!==void 0)return await Jo(t.explicit)||await Fu(t.explicit),t.target.kind==="bulb"&&await er(t.target,t.cwd),{port:t.explicit};let e=await er(t.target,t.cwd);if(e!==void 0){let r=e-e%dn,s=Date.now()+KO;do{if(await Jo(e))return{port:e};await new Promise(i=>setTimeout(i,150))}while(Date.now()<s);for(let i=qo;i<dn;i++){let o=r+i;if(o!==e&&await Jo(o))return{port:o,note:`(slot ${e} was busy)`}}}return{port:await HO(JO),note:e===void 0?"(no port block available)":"(this project's block was full)"}}var Ny,dn,$y,JO,qo,WO,KO,pn=v(()=>{"use strict";Ye();Ny=20100,dn=100,$y=19,JO=23e3,qo=1,WO=dn-1,KO=3e3});var De,zo=v(()=>{"use strict";De="0.62.0"});var My={};Si(My,{agentViewerCommand:()=>Hy,bulbServerCommand:()=>Ky,clearServerLog:()=>Ku,findProjectViewer:()=>Go,isAlive:()=>tr,isMirror:()=>ye,isProjectBulb:()=>Gu,isProjectMirror:()=>sr,launchAgentViewer:()=>Zu,launchBulbServer:()=>_s,listBulbServers:()=>X,probePageCount:()=>Qu,readServerLog:()=>Ve,readWaitCursor:()=>Vo,recordDenial:()=>Vu,registerServer:()=>Yu,relayOpen:()=>Xu,runMarker:()=>Hu,serverLogPath:()=>rr,serversForBulb:()=>mn,sliceRunLog:()=>zu,startServerLog:()=>Cs,stopBulbServer:()=>nr,stopServer:()=>Ut,stopServersForBulb:()=>Xo,typebulbBinPath:()=>ir,unregisterServer:()=>hn,writeWaitCursor:()=>Ps});import{spawn as Dy}from"child_process";import{readdir as VO,readFile as Fy,writeFile as Uy,unlink as Uu,mkdir as GO}from"fs/promises";import{mkdirSync as qy,writeFileSync as Yo,appendFileSync as XO,readFileSync as qu}from"fs";import*as Ce from"path";import{fileURLToPath as QO}from"url";function Ju(t){return Ce.join(ht(),`${t}.json`)}function rr(t){return Ce.join(ht(),`${t}.log`)}function Wu(t){return Ce.join(ht(),`${t}.wait.json`)}function Jy(t){try{let e=JSON.parse(qu(Wu(t),"utf8"));return e.cursors&&typeof e.cursors=="object"?e.cursors:{}}catch{return{}}}function Vo(t,e=""){let n=Jy(t)[e];return typeof n=="number"&&Number.isFinite(n)&&n>=0?n:void 0}function Ps(t,e,n=""){try{qy(ht(),{recursive:!0});let r=Jy(t);r[n]=e,Yo(Wu(t),JSON.stringify({cursors:r}))}catch{}}function Cs(t){let e=rr(t);try{qy(ht(),{recursive:!0}),Yo(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(XO(e,l),s+=l.length,s>2*By){let c=qu(e),u=c.subarray(Math.max(0,c.length-By));Yo(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 Ku(t){try{Yo(rr(t),"")}catch{}}function Ve(t,e=0){try{let n=qu(rr(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 Hu(t){return`\u2500\u2500 run ${t} \u2500\u2500 ${new Date().toTimeString().slice(0,8)}`}function eP(t){let e=ZO.exec(t);return e?Number(e[1]):void 0}function zu(t,e){let n=t.split(`
|
|
319
|
+
`),r=[];if(n.forEach((o,a)=>{let l=eP(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(`
|
|
320
|
+
`)}function tr(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}async function Yu(t){try{await GO(ht(),{recursive:!0}),await Uy(Ju(t.pid),JSON.stringify({version:De,...t}))}catch{pt()}}async function Vu(t,e){let n=Ju(t);try{let r=JSON.parse(await Fy(n,"utf8"));if(r.denied===e)return;r.denied=e,await Uy(n,JSON.stringify(r))}catch{}}async function hn(t){await Uu(Ju(t)).catch(()=>{}),await Uu(rr(t)).catch(()=>{}),await Uu(Wu(t)).catch(()=>{})}function ye(t){return t.agent!=null}function sr(t,e){return ye(t)&&t.cwd!=null&&ie(t.cwd)===ie(e)}function Gu(t,e){return!ye(t)&&Oy(t.file,e)}async function X(t){let e;try{e=await VO(ht())}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 Fy(Ce.join(ht(),s),"utf8"))}catch{await hn(i);return}o&&typeof o.pid=="number"&&tr(o.pid)?n.push(o):await hn(i)})),(t?n.filter(s=>Gu(s,t)):n).sort((s,i)=>s.startedAt-i.startedAt)}async function Go(t,e){return(await X()).find(n=>sr(n,t)&&(e?n.agent===e:!0))}async function Xu(t,e){let n=new URL(t).port,r=(await X()).filter(a=>String(a.port)!==n),s=r.filter(a=>sr(a,e)),i=r.filter(a=>Gu(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":`${Ce.basename(a.file)}'s page`};ye(a)&&(o+=u??0)}catch{}return o>0?{where:"external"}:void 0}async function nr(t){try{process.kill(t,"SIGTERM")}catch{}await hn(t)}async function Qu(t){try{let e=await fetch(`${t.url}/__pages`,{signal:AbortSignal.timeout(tP)});if(!e.ok)return;let{pages:n}=await e.json();return typeof n=="number"?n:void 0}catch{return}}async function Ut(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(jy)});if(!n.ok)throw new Error(`/__stop ${n.status}`);let{closed:r=0,stuck:s=0}=await n.json(),i=Date.now()+jy;for(;tr(t.pid)&&Date.now()<i;)await Wy(100);return tr(t.pid)?(await nr(t.pid),"killed"):(await hn(t.pid),{closed:r,stuck:s})}catch{return await nr(t.pid),"killed"}}function mn(t,e){let n=ie(e);return t.filter(r=>!ye(r)&&r.pid!==process.pid&&ie(r.file)===n)}async function Xo(t,e){let n=mn(await X(),t);for(let r of n)await Ut(r,e!==void 0&&r.port===e?"keep":"close");return n}function nP(t,e,n){(process.platform==="win32"?Dy("cmd",["/c","start","","/b",t,...e],{cwd:n,stdio:"ignore",windowsHide:!0}):Dy(t,e,{cwd:n,detached:!0,stdio:"ignore"})).unref()}function ir(){return Ce.join(Ce.dirname(QO(import.meta.url)),"index.js")}function Ky(t,e={}){return{command:process.execPath,args:[ir(),...e.trust?["--trust"]:[],...e.mode?["--mode",e.mode]:[],t,...e.open===!1?["--no-open"]:[]]}}function Hy(t){return{command:process.execPath,args:[ir(),`agent:${t}`,"--no-open"]}}async function zy(t,e,n,r){let s=await t();if(s)return s;nP(e.command,e.args,n);let i=Date.now()+2e4;for(;Date.now()<i;){await Wy(150);let o=await t();if(o)return o}throw new Error(`Launched ${r} but it did not register within 20s.`)}async function _s(t,e={}){let n=e.cwd??process.cwd(),r=Ce.resolve(n,t),s=await er({kind:"bulb",file:r},n),[i]=await Xo(r,s),o={...e,mode:e.mode??i?.mode};return zy(async()=>mn(await X(),r)[0],Ky(t,o),n,Ce.basename(t))}async function Zu(t,e=process.cwd()){return zy(()=>Go(e,t),Hy(t),e,`the ${t} mirror`)}var By,ZO,jy,tP,Wy,Me=v(()=>{"use strict";Ye();pn();zo();By=1e6;ZO=/^── run (\d+) ── /;jy=6e3,tP=500;Wy=t=>new Promise(e=>setTimeout(e,t))});function or(t){return{...Ep(t),server:t.files.get("server.ts")??""}}function Qo(t){return!!t.server&&!t.code}var Rs=v(()=>{"use strict";Q();Q()});function Zo(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 ed(t){return Yn(Zo(t)??"bulb")||"bulb"}var td=v(()=>{"use strict";Q()});import{readdirSync as rP,readFileSync as sP,statSync as iP}from"fs";import{join as Yy,basename as oP}from"path";function Gy(t,e,n){if(e>8)return n;let r;try{r=rP(t,{withFileTypes:!0})}catch{return n}for(let s of r)if(s.isDirectory()){if(s.name.startsWith(".")||s.name==="node_modules")continue;Gy(Yy(t,s.name),e+1,n)}else s.isFile()&&s.name.endsWith(".bulb.md")&&n.push(Yy(t,s.name));return n}function aP(t,e){let n,r=!1;try{let s=sP(t,"utf8");n=Zo(s.slice(0,1024));let i=Ke(s);r=!!i&&Qo(or(i))}catch{}return{mtime:e,name:n??oP(t).replace(/\.bulb\.md$/,""),serverOnly:r}}function ea(t){let e=new Map,n=Gy(t,0,[]).map(r=>{let s=0;try{s=iP(r).mtimeMs}catch{}let i=s?Vy.get(r):void 0,o=i?.mtime===s?i:aP(r,s);return s&&e.set(r,o),{path:r,...o}});return Vy=e,n}var Vy,Xy=v(()=>{"use strict";Q();Rs();td();Vy=new Map});function ar(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 ta=v(()=>{"use strict"});import{readFile as lP}from"fs/promises";async function nd(t){try{let e=Ke(await lP(t,"utf-8"));return e?ar(or(e)):void 0}catch{return}}var Qy=v(()=>{"use strict";Rs();ta()});function rd(t){let e=t.split(""),n=(i,o)=>{for(let a=i;a<o&&a<e.length;a++)e[a]!==`
|
|
321
321
|
`&&(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]!==`
|
|
322
|
-
`;)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==="/"&&
|
|
322
|
+
`;)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==="/"&&cP.has(s)){let a=r+1,l=!1;for(;a<t.length&&t[a]!==`
|
|
323
323
|
`;){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]!==`
|
|
324
|
-
`;)t[a]==="\\"&&a++,a++;r=a+1,s=i}else if(i==="`"){let a=
|
|
325
|
-
`).length-1}));return r}function
|
|
324
|
+
`;)t[a]==="\\"&&a++,a++;r=a+1,s=i}else if(i==="`"){let a=Zy(t,r);n(r,a),r=a,s="`"}else/\s/.test(i)||(s=i),r++}return e.join("")}function Zy(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=Zy(t,n);continue}if(s==="$"&&t[n+1]==="{"){r++,n+=2;continue}if(s==="}"&&r>0){r--,n++;continue}n++}return t.length}var cP,eb=v(()=>{cP=new Set(["","(",",","=",":","[","!","&","|","?",";","{"])});function fP(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 tb(t){let e=[];for(let s of dP)for(let i of t.matchAll(s)){let o=fP(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(`
|
|
325
|
+
`).length-1}));return r}function nb(t){return tb(rd(t)).map(e=>e.root)}function Is(t,e){if(!t)return[];let{target:n,dependencies:r}=e,s=(e.lineOffset??1)-1,i=[],o=t.split(`
|
|
326
326
|
`),a=rd(t).split(`
|
|
327
|
-
`);for(let l=0;l<o.length;l++){let c=a[l],
|
|
328
|
-
`)).filter(({root:i})=>!s.has(i)).map(({root:i,lineIndex:o})=>{let a=o+1+r;return{type:"UNDECLARED_IMPORT",severity:"error",message:
|
|
327
|
+
`);for(let l=0;l<o.length;l++){let c=a[l],u=l+1+s;for(let d of uP)d.targets.includes(n)&&d.pattern.test(c)&&i.push({type:d.type,severity:"error",message:mP(d.type,u),lineNumber:u,lineContent:o[l]})}return n==="client"&&r&&i.push(...pP(a,o,r,s)),i}function pP(t,e,n,r){let s=new Set(Object.keys(n));return tb(t.join(`
|
|
328
|
+
`)).filter(({root:i})=>!s.has(i)).map(({root:i,lineIndex:o})=>{let a=o+1+r;return{type:"UNDECLARED_IMPORT",severity:"error",message:hP(i,a),lineNumber:a,lineContent:e[o]}})}function hP(t,e){return`Import "${t}" is not declared in config.json dependencies! Found on line ${e}.
|
|
329
329
|
|
|
330
330
|
**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.
|
|
331
331
|
|
|
@@ -339,7 +339,7 @@ ${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.pus
|
|
|
339
339
|
}
|
|
340
340
|
\`\`\`
|
|
341
341
|
|
|
342
|
-
**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
|
|
342
|
+
**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 mP(t,e){return t==="URL_IMPORT"?`Direct URL imports are not supported! Found on line ${e}.
|
|
343
343
|
|
|
344
344
|
**CRITICAL**: Import packages by name only. Do NOT use CDN URLs:
|
|
345
345
|
|
|
@@ -493,22 +493,22 @@ import { something } from 'module-name'
|
|
|
493
493
|
const something = require('module-name') // NOT SUPPORTED!
|
|
494
494
|
\`\`\`
|
|
495
495
|
|
|
496
|
-
**Fix:** Replace all \`require()\` calls with ES6 \`import\` statements at the top of the file.`}var
|
|
497
|
-
`)}var cr,
|
|
496
|
+
**Fix:** Replace all \`require()\` calls with ES6 \`import\` statements at the top of the file.`}var gn,yn,uP,dP,na=v(()=>{eb();gn=["client"],yn=["client","server"],uP=[{type:"DYNAMIC_IMPORT",pattern:/\bimport\s*\(\s*['"`]/,targets:gn},{type:"COMMONJS_REQUIRE",pattern:/\brequire\s*\(\s*['"`]/,targets:yn},{type:"JS_EXTENSION_IMPORT",pattern:/from\s+['"][^'"]*\/[^'"]*\.js['"]/,targets:gn},{type:"URL_IMPORT",pattern:/from\s+['"]https?:\/\//,targets:gn},{type:"VERSION_SPECIFIER_IMPORT",pattern:/from\s+['"][^'"]*@[\d^~]/,targets:gn},{type:"REDUNDANT_TB_DECLARATION",pattern:/declare\s+(const|var|let)\s+tb\b/,targets:yn},{type:"CONST_ENUM",pattern:/\bconst\s+enum\b/,targets:yn},{type:"NAMESPACE_DECLARATION",pattern:/\bnamespace\s+\w+/,targets:yn},{type:"COMMONJS_EXPORT_EQUALS",pattern:/\bexport\s*=/,targets:yn},{type:"COMMONJS_IMPORT_EQUALS",pattern:/\bimport\s+\w+\s*=/,targets:yn},{type:"MODULE_DECLARATION",pattern:/\bmodule\s+\w+\s*\{/,targets:yn},{type:"CSS_FILE_IMPORT",pattern:/(?:from|import)\s+['"][^'"]*\.css['"]/,targets:gn},{type:"NAVIGATION",pattern:/window\.(location\.(reload|assign|replace)\s*\(|open\s*\()/,targets:gn},{type:"NAVIGATION",pattern:/window\.location(\.href)?\s*=[^=]/,targets:gn}],dP=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g]});function sd(t){let e=Ke(t);if(!e)return t;let n=e.files.get("code.tsx");if(!n)return t;let r=nb(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=bp(c);d&&(l[d]=u)}return l.config=JSON.stringify(i,null,2),Op(l)}var rb=v(()=>{"use strict";Q();na()});import{spawn as sb}from"child_process";import{basename as gP}from"path";function yP(){return process.env.TYPEBULB_EDITOR||"code"}function wP(t,e,n){return n==null?[e]:bP.test(gP(t))?["-g",`${e}:${n}`]:[`+${n}`,e]}function vP(t,e){let n=yP();return{command:n,args:wP(n,t,e)}}function id(t,e){let{command:n,args:r}=vP(t,e),s=process.platform==="win32"?sb("cmd.exe",["/d","/s","/c",n,...r],{detached:!0,stdio:"ignore",windowsHide:!0}):sb(n,r,{detached:!0,stdio:"ignore"});s.on("error",i=>console.error("[typebulb] editor launch failed:",i?.message??i)),s.unref()}var bP,ib=v(()=>{"use strict";bP=/^(code|code-insiders|codium|vscodium|cursor|windsurf)(\.cmd|\.exe)?$/i});import{readFileSync as SP,writeFileSync as kP,mkdirSync as xP,statSync as EP}from"fs";import{join as AP}from"path";function od(){return AP(ft(),"trust.json")}function ad(){try{let t=od(),e=EP(t).mtimeMs;if(Ns?.mtime!==e){let n=JSON.parse(SP(t,"utf8"));Ns={mtime:e,set:new Set(Array.isArray(n)?n:[])}}return Ns.set}catch{return Ns=void 0,new Set}}function TP(t){try{xP(ft(),{recursive:!0}),kP(od(),JSON.stringify([...t])),Ns=void 0}catch(e){throw new Error(`can't write ${od()} \u2014 trust not remembered (unwritable home; sandboxed shell?): ${e.message}`)}}function bn(t){return ad().has(ie(t))}function lr(t,e){let n=new Set(ad()),r=ie(t);(e?n.has(r):!n.has(r))||(e?n.add(r):n.delete(r),TP(n))}function ld(){return[...ad()]}var Ns,$s=v(()=>{"use strict";Ye()});function ur(t){return(t.includes("://")?t:`http://${t}`).replace(/\/+$/,"")}function cd(){return Ms}async function mt(){let[t,e]=await Promise.all([ab(),NP()]);return IP([...$P(e),...t],process.env.TB_AI_PROVIDER,process.env.TB_AI_MODEL)}function IP(t,e,n){return!e||!n?t:t.map(r=>r.provider===e&&r.name===n?{...r,default:!0}:r)}async function ob(){let t;try{t=await fetch(OP,{signal:AbortSignal.timeout(CP)})}catch(e){Ms=`catalog fetch failed: ${e?.message??e}`;return}if(!t.ok){Ms=`catalog fetch failed: HTTP ${t.status}`;return}try{return await t.json()}catch(e){Ms=`catalog returned an unreadable body: ${e?.message??e}`;return}}async function NP(){if(Ls&&Date.now()-Ls.fetchedAt<=PP)return Ls.models;let t=await ob()??await ob();return t?(Ls={models:t,fetchedAt:Date.now()},Ms=void 0,t):Ls?.models??[]}async function ab(){if(ra&&Date.now()-ra.fetchedAt<=_P)return ra.models;let t=ur(process.env.OLLAMA_HOST??"http://localhost:11434"),e=[];try{let n=await fetch(new URL("/api/tags",t).toString(),{signal:AbortSignal.timeout(RP)});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 ra={models:e,fetchedAt:Date.now()},e}function $P(t){let e=new Set(Object.entries(cr).filter(([,n])=>!!process.env[n]).map(([n])=>n));return t.filter(n=>e.has(n.provider))}function ud(){return Object.values(cr).some(t=>!!process.env[t])}async function sa(){return ud()||process.env.TB_AI_BASE_URL||(await ab()).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(`
|
|
497
|
+
`)}var cr,OP,PP,CP,_P,RP,Ls,ra,Ms,wn=v(()=>{"use strict";cr={anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY",gemini:"GOOGLE_API_KEY",openrouter:"OPENROUTER_API_KEY"};OP="https://api.typebulb.com/api/models",PP=1440*60*1e3,CP=5e3,_P=60*1e3,RP=1500});var cb,ub,rt,vn=v(()=>{cb=t=>t!=null&&t>=0&&t<=4?t:void 0,ub=(t,e)=>{let n={...t};for(let r of["input","output","reasoning","cacheRead"])e[r]!==void 0&&(n[r]=e[r]);return n},rt=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 _e,Ge,dr=v(()=>{_e=class extends Error{constructor(e,n="unknown",r=!1){super(e),this.code=n,this.retryable=r}},Ge=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=`
|
|
498
498
|
|
|
499
|
-
`){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
|
|
500
|
-
`)),!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
|
|
499
|
+
`){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 _e(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 _e(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 ia,dd=v(()=>{vn();dr();ia=class extends Ge{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(`
|
|
500
|
+
`)),!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 _e(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 rt({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(`
|
|
501
501
|
|
|
502
|
-
`)}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 fr,oa=
|
|
502
|
+
`)}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 fr,oa=v(()=>{vn();dr();fr=class extends Ge{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 rt({input:e.prompt_tokens,output:e.completion_tokens,reasoning:e.completion_tokens_details?.reasoning_tokens,cacheRead:e.prompt_tokens_details?.cached_tokens})}}});var fd,aa,pd=v(()=>{oa();fd={"HTTP-Referer":"https://typebulb.com","X-OpenRouter-Title":"Typebulb"},aa=class extends fr{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",...fd}}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 la,hd=v(()=>{vn();dr();la=class extends Ge{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(`
|
|
503
503
|
|
|
504
|
-
`);return{text:n,reasoning:r||void 0,usage:
|
|
505
|
-
`),l={contents:o.map(
|
|
506
|
-
`)[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
|
|
504
|
+
`);return{text:n,reasoning:r||void 0,usage:rt(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 ca,md=v(()=>{vn();dr();ca=class extends Ge{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,`
|
|
505
|
+
`),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(`
|
|
506
|
+
`)[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 rt({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 _e(`Prompt blocked: ${n}`)}}}});var ua,gd=v(()=>{oa();ua=class extends fr{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 Sn(t){let e=LP.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 yd(t,e){let n=Sn(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 DP(t){return/prompt is too long|context[_ ](length|window)|maximum context|token count exceeds|too many tokens/i.test(t)}async function pr(t,e){let n=Sn(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||DP(s))&&(o="context_exceeded"),{code:o,message:s,retryable:i===429||i>=500}}var db,LP,bd=v(()=>{dd();pd();hd();md();gd();db=new ua,LP=new Map([["openai",new ia],["openrouter",new aa],["anthropic",new la],["gemini",new ca],["ollama",db],["openai-compat",db]])});function fb(t){let e=t.indexOf(`\r
|
|
507
507
|
\r
|
|
508
508
|
`),n=t.indexOf(`
|
|
509
509
|
|
|
510
510
|
`);return e!==-1&&(n===-1||e<n)?{pos:e,len:4}:n!==-1?{pos:n,len:2}:{pos:-1,len:0}}function wd(t){let n=t.split(/\r?\n/).filter(s=>s.startsWith("data:"));if(!n.length)return;let r=n.map(s=>s.replace(/^data:\s?/,"")).join(`
|
|
511
|
-
`).trim();if(r){if(r==="[DONE]")return"done";try{return JSON.parse(r)}catch{return}}}async function*
|
|
511
|
+
`).trim();if(r){if(r==="[DONE]")return"done";try{return JSON.parse(r)}catch{return}}}async function*pb(t,e,n){let r=new TextDecoder,s="",i,o=e?new Promise((a,l)=>{e.aborted&&l(new Error("Aborted")),i=()=>l(new Error("Aborted")),e.addEventListener("abort",i,{once:!0})}):void 0;o?.catch(()=>{});try{for(;;){let{done:a,value:l}=o?await Promise.race([t.read(),o]):await t.read();if(a){if(s.trim()){let d=wd(s);d!==void 0&&d!=="done"&&(yield d)}return}n?.(),s+=r.decode(l,{stream:!0});let{pos:c,len:u}=fb(s);for(;c!==-1;){let d=s.slice(0,c);s=s.slice(c+u);let f=wd(d);if(f==="done")return;f!==void 0&&(yield f),{pos:c,len:u}=fb(s)}}}finally{i&&e?.removeEventListener("abort",i);try{await t.cancel()}catch{}}}async function vd(t,e){return(await hr(t,e)).text}async function hr(t,e){if(!t.body)throw new Error("Response body is missing");let n="",r;for await(let s of kn(t,e))s.kind==="text"?n+=s.text:s.kind==="usage"&&(r=s.usage);return{text:n,usage:r}}async function*kn(t,e){let n=e??(t.headers.get("X-Provider-Protocol")||"openai"),r=Sn(n);if(!t.body)return;let s=t.body.getReader(),i;for await(let a of pb(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=ub(i,l.usage))}let o=rt(i);o&&(yield{kind:"usage",usage:o})}var hb=v(()=>{vn();bd()});import{strToU8 as BP,strFromU8 as jP,deflateSync as FP,inflateSync as UP}from"fflate";function kd(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.
|
|
512
512
|
|
|
513
513
|
---
|
|
514
514
|
Instructions:
|
|
@@ -526,13 +526,13 @@ ${r}
|
|
|
526
526
|
</data>`)}return n.push(`
|
|
527
527
|
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(`
|
|
528
528
|
|
|
529
|
-
`)}function
|
|
530
|
-
`)){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 da(t,e=process.cwd()){for(let n of
|
|
529
|
+
`)}function Ds(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 JP(t){let e=mb(t,n=>n.replace(/,(\s*[}\]])/g,"$1"));return e!==t?e:void 0}function WP(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 KP(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 HP(t){let e,n=0;for(;n<t.length;){let r=t[n];if(r==="{"||r==="["){let s=KP(t,n);if(s!==-1){let i=t.slice(n,s+1),o=Ds(i);o!==void 0&&(e={parsed:o,json:i}),n=s+1;continue}}n++}return e}function xd(t){let e=[],n=t.trim();n.startsWith("```")&&(n=n.replace(/^```(?:json)?\s*\n?/,"").replace(/\n?```\s*$/,""),e.push("markdown fences"));let r=Ds(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=Ds(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=Ds(n),r!==void 0))return{parsed:r,json:n,fixesApplied:e}}for(let[o,a]of qP){let l=a(n);if(l!==void 0){let c=Ds(l);if(c!==void 0)return{parsed:c,json:l,fixesApplied:[...e,o]}}}let i=HP(t);return i!==void 0?{...i,fixesApplied:[...e,"extracted last JSON value"]}:{parsed:void 0,json:n,fixesApplied:e}}function Ed(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=FP(BP(n),{level:9}),s=YP(r),i=`${gb}:${s}`;return i.length>zP?"":"#"+Sd+i}catch{return""}}function Ad(t){try{let e=t.startsWith("#")?t.slice(1):t;if(!e.startsWith(Sd))return;let n=e.slice(Sd.length),r=n.indexOf(":");if(r===-1||n.slice(0,r)!==gb)return;let s=VP(n.slice(r+1)),i=JSON.parse(jP(UP(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 YP(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 VP(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 qP,Sd,gb,zP,yb=v(()=>{qP=[["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",JP],["arithmetic constants",WP]];Sd="tb=",gb="1",zP=6e4});var qt=v(()=>{vn();dr();bd();hb();yb();oa();hd();md();dd();pd();gd()});import{readFileSync as bb,existsSync as GP}from"fs";import*as st from"path";function wb(t){return[...t?[`.env.${t}.local`,`.env.${t}`]:[],".env.local",".env"]}function Ee(t,e=process.cwd()){let n={},r=[];for(let s of wb(t)){let i;try{i=bb(st.resolve(e,s),"utf-8")}catch{continue}r.push(s);for(let[o,a]of vb(i))process.env[o]===void 0&&(process.env[o]=a,n[o]=s)}return{mode:t,sources:n,loaded:r}}function*vb(t){for(let e of t.split(`
|
|
530
|
+
`)){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 da(t,e=process.cwd()){for(let n of wb()){let r;try{r=bb(st.resolve(e,n),"utf-8")}catch{continue}for(let[s,i]of vb(r))if(s===t)return i}return process.env[t]}function XP(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 Sb(){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=st.dirname(e),l=`(mode: ${s??"none"})`,c=n?XP(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=st.resolve(a)!==st.resolve(o);if(d)for(let p of[".env.local",".env"])GP(st.join(a,p))&&console.log(`env: ${st.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 it=v(()=>{"use strict"});function gt(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=Sn(n)}catch{return`Unknown provider '${n}'.`}if(n==="ollama")return{apiKey:"",baseUrl:`${ur(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=cr[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 ${Sb()}.`}function Wt(t,e){let n=[...e.system?[{role:"system",content:e.system}]:[],...e.messages.map(r=>({role:r.role,content:r.content}))];return yd(t,{messages:n,stream:!0,effort:cb(e.effort),webSearch:e.webSearch,signal:e.signal})}var fa=v(()=>{"use strict";qt();qt();it();wn()});import{readFileSync as qB,existsSync as QP}from"fs";import*as mr from"path";import{fileURLToPath as ZP}from"url";function eC(){let t=mr.dirname(ZP(import.meta.url));for(;!QP(mr.join(t,"package.json"));){let e=mr.dirname(t);if(e===t)break;t=e}return t}function Bs(){return mr.join(eC(),"SKILL.md")}var Td=v(()=>{"use strict"});import{transform as tC}from"sucrase";function Od(t,e={}){let n=e.serverOnly?["typescript"]:["typescript","jsx"];try{let{code:r}=tC(t,{transforms:n,jsxRuntime:"automatic",jsxImportSource:e.jsxImportSource||"react",production:!0});return{code:r}}catch(r){return{code:"",error:String(r)}}}var kb=v(()=>{});function nC(t){return t.map(e=>`${e.type} (line ${e.lineNumber}): ${e.message.split(`
|
|
531
531
|
`)[0]}`).join(`
|
|
532
|
-
`)}function
|
|
533
|
-
${eC(n)}`)}var Tb=S(()=>{"use strict";na()});var Wt,Ls,Pd,Ms=S(()=>{Wt="https://esm.sh",Ls="https://cdn.jsdelivr.net/npm/",Pd="https://data.jsdelivr.com/v1/package/npm/"});function Ob(t){let e=(t||"").replace(/^\/+/,"").replace(/\/+$/,"");return e?e.split("/"):[]}var B,gr,Pb,Ds=S(()=>{Ms();B=class t{constructor(e,n,r){let s=typeof e=="string"?t.parse(e):e;this.name=s.name,this.version=gr(n??s.version),this.subpath=gr(r??s.subpath)}static parse(e){let n=Ob(e||"");if(!n.length)return new t({name:""});if(n[0].startsWith("@")){let s=n[0],[i,o]=Pb(n[1]??""),a=gr(n.slice(2).join("/"));return new t({name:`${s}/${i}`,version:o,subpath:a})}else{let[s,i]=Pb(n[0]),o=gr(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(Wt).host,s=new URL(Ls).host;if(n.host===r){let i=Ob(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:gr(e),subpath:this.subpath})}static isBare(e){return!e||e.startsWith(".")||e.startsWith("/")?!1:!/^[a-z][a-z0-9+.-]*:/i.test(e)}},gr=t=>t&&t.length?t:void 0,Pb=t=>{let e=t.indexOf("@");return e<0?[t,void 0]:[t.slice(0,e),gr(t.slice(e+1))]}});async function Ee(t){try{return await t()}catch{return}}var pa=S(()=>{});function kn(t){let e=t||"";return e.startsWith("./")?e.slice(2):e.replace(/^\/+/,"")}function Cd(t){return t.startsWith("./")?t:`./${t}`}var Bs,_d=S(()=>{Ds();pa();Ms();Bs=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 B(e):e;return`${Ls}${n.name}${n.version?`@${n.version}`:""}/`}file(e,n){return new URL(kn(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(",")),`${Wt}/${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),`${Wt}/${e}`]);return this.pinCache.set(e,{value:s,ts:n}),s}async tryResolveFromUrls(e){for(let n of e){let r=await Ee(()=>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 Ee(()=>this.http.getJson(`${Pd}${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=B.fromUrl(e)?.version;return n&&/\d+\.\d+\.\d+/.test(n)?n:void 0}async fetchPackageMeta(e,n){let r=await this.cache.getMeta(e,n);if(r&&Date.now()-r.updatedAt<this.metaTtlMs){let{dependencies:f,peerDependencies:d,peerDependenciesMeta:u}=r;return{name:e,version:n,dependencies:f,peerDependencies:d,peerDependenciesMeta:u}}let s=this.packageJson(new B(`${e}@${n}`)),i=await Ee(()=>this.http.getJson(s));if(!i)return;let o=f=>f&&Object.keys(f).length?f:void 0,a=o(i.dependencies),l=o(i.peerDependencies),c=o(i.peerDependenciesMeta);return await this.cache.setMeta(e,n,a,l,c),{name:e,version:n,dependencies:a,peerDependencies:l,peerDependenciesMeta:c}}}});var Cb,js,Rd,tC,Fs,ha=S(()=>{Cb=t=>t.startsWith("@types/"),js=t=>Object.keys(t?.peerDependencies||{}).filter(e=>!Cb(e)),Rd=t=>Object.keys(t?.dependencies||{}).filter(e=>!Cb(e)),tC=t=>js(t).filter(e=>!t?.peerDependenciesMeta?.[e]?.optional),Fs=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 tC(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=>js(i.meta))),r=new Map;for(let i of e)for(let o of Rd(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:js(i.meta).length>0,isSharedDep:s.has(i.name)}]))}}});var Us,Id=S(()=>{Ds();pa();Us=class{constructor(e,n,r){this.cache=e,this.cdn=n,this.semver=r}async learnExactVersion(e){let n=await Ee(()=>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 Ee(()=>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 Ee(()=>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 B(e),s=r.root(),i=n[s],o=i?await Ee(()=>this.resolveExactForRoot(s,i)):void 0;return{effectivePackage:o?r.withVersion(o).format():e,root:s,range:i,pinned:o}}}});import{init as nC,parse as rC}from"es-module-lexer";var yr,Nd=S(()=>{Ds();Ms();ha();yr=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))B.isBare(s[1])&&n.add(s[1])}return Array.from(n)}async extractImports(e){let n=new Set,r=s=>{B.isBare(s)&&n.add(s)};try{await nC;let[s]=rC(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(B.rootOf(d))),i=[...new Set(s.map(B.rootOf))],o=await Promise.all(i.map(async d=>({name:d,version:await this.resolveVersion(d,n)}))),{allRoots:a,flags:l,autoAddedPeers:c}=await this.peer.resolve(o,d=>this.resolveVersion(d,n)),f=this.buildEntries([...s,...c.map(d=>d.name)],a,l);return{importMap:{imports:Object.fromEntries(f)},prefetchUrls:f.map(([,d])=>d)}}async resolveVersion(e,n){let r=n[e],s=await this.version.resolveExactForRoot(e,r);if(!s)throw new Error(`Cannot resolve ${r?`${e}@${r}`:e}: no matching version is published (the package or version may not exist, or the registry was unreachable).`);return s}buildEntries(e,n,r){let s=new Map(n.map(p=>[p.name,p])),i=p=>{let m=s.get(B.rootOf(p));return new B(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!==B.rootOf(p)).map(B.rootOf)),l=[],c=new Set,f=new Set(e.filter(p=>p===B.rootOf(p))),d=new Set;for(let p of e){let m=B.rootOf(p),h=s.get(m),{isPeerRoot:g,hasPeers:x,isSharedDep:O}=r.get(m),C=a.has(m),E=p!==m,I=!(g||O)&&(C||!x),L=this.singletonDepsOf(h,o),A=E&&f.has(m);A&&d.add(m);let F=A?[...L,m]:L.length?L:void 0;l.push([p,this.cdn.buildEsmUrl(i(p),{bundle:I,external:F})]),c.add(p)}let u=new Set([...o,...d]);for(let p of u)s.has(p)&&(c.has(p)||l.push([p,this.cdn.buildEsmUrl(i(p),{})]),l.push([`${p}/`,`${Wt}/${i(p)}/`]));return l}singletonDepsOf(e,n){return[...new Set([...js(e.meta),...Rd(e.meta)])].filter(r=>n.has(r))}};yr.importPatterns=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g]});import{gt as _b,satisfies as sC,maxSatisfying as Rb,major as iC,valid as oC,validRange as aC}from"semver";var ma,xn,$d=S(()=>{ma=class{cmp(e,n){return e===n?0:_b(e,n)?1:_b(n,e)?-1:0}satisfies(e,n){return!e||!e.trim()?!0:!!sC(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=Rb(e,r,{includePrerelease:!1});if(a)return a}return Rb(e,r,{includePrerelease:!0})??void 0}majorOf(e){return iC(e)}isExactVersion(e){return oC(e)!==null}isRange(e){return aC(e)!==null}},xn=new ma});function lC(t){return Math.min(9e5*Math.pow(2,Math.max(0,t-1)),864e5)}var En,Ib=S(()=>{pa();En=class{constructor(e){this.store=e}async isNegative(e){let n=await Ee(()=>this.store.get(e));return!!n&&n.until>Date.now()}async recordNegative(e){let r=((await Ee(()=>this.store.get(e)))?.attempts||0)+1;await Ee(()=>this.store.set(e,{until:Date.now()+lC(r),attempts:r}))}async clearNegative(e){await Ee(()=>this.store.delete(e))}}});function Nb(t,e){let n=new Bs(t,e),r=new Fs(n),s=new Us(t,n,xn);return{packageService:new yr(s,n,r),versionResolver:s,cdnClient:n,peerResolver:r}}var yt=S(()=>{_d();ha();Id();Nd();$d();Ds();$d();Ms();_d();ha();Id();Nd();Ib()});import*as Ld from"fs/promises";import*as $b from"crypto";function Xe(t){return $b.createHash("sha1").update(t).digest("hex")}async function bt(t){try{return JSON.parse(await Ld.readFile(t,"utf8"))}catch{return}}async function ga(t){try{return await Ld.readFile(t,"utf8")}catch{return}}var br=S(()=>{"use strict"});import*as Ht from"fs/promises";import*as wt from"path";import*as Mb from"os";function ee(){return Md||(Md=uC().catch(()=>pt())),Md}function ba(t,e){return wt.join(cC,Xe(t),e)}async function uC(){await Ht.mkdir(Kt,{recursive:!0});let t=wt.join(Kt,"version.json");if((await bt(t))?.version===Lb)return;let n=await Ht.readdir(Kt).catch(()=>[]);await Promise.all(n.map(r=>Ht.rm(wt.join(Kt,r),{recursive:!0,force:!0}))),await Ht.writeFile(t,JSON.stringify({version:Lb})+`
|
|
534
|
-
`,"utf8")}var
|
|
535
|
-
${
|
|
532
|
+
`)}function xb(t,e){let n=Is(t,{target:"client",dependencies:e}).filter(r=>r.type==="UNDECLARED_IMPORT");if(n.length)throw new Error(`Lint failed:
|
|
533
|
+
${nC(n)}`)}var Eb=v(()=>{"use strict";na()});var Kt,js,Pd,Fs=v(()=>{Kt="https://esm.sh",js="https://cdn.jsdelivr.net/npm/",Pd="https://data.jsdelivr.com/v1/package/npm/"});function Ab(t){let e=(t||"").replace(/^\/+/,"").replace(/\/+$/,"");return e?e.split("/"):[]}var j,gr,Tb,Us=v(()=>{Fs();j=class t{constructor(e,n,r){let s=typeof e=="string"?t.parse(e):e;this.name=s.name,this.version=gr(n??s.version),this.subpath=gr(r??s.subpath)}static parse(e){let n=Ab(e||"");if(!n.length)return new t({name:""});if(n[0].startsWith("@")){let s=n[0],[i,o]=Tb(n[1]??""),a=gr(n.slice(2).join("/"));return new t({name:`${s}/${i}`,version:o,subpath:a})}else{let[s,i]=Tb(n[0]),o=gr(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=Ab(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:gr(e),subpath:this.subpath})}static isBare(e){return!e||e.startsWith(".")||e.startsWith("/")?!1:!/^[a-z][a-z0-9+.-]*:/i.test(e)}},gr=t=>t&&t.length?t:void 0,Tb=t=>{let e=t.indexOf("@");return e<0?[t,void 0]:[t.slice(0,e),gr(t.slice(e+1))]}});async function Ae(t){try{return await t()}catch{return}}var pa=v(()=>{});function xn(t){let e=t||"";return e.startsWith("./")?e.slice(2):e.replace(/^\/+/,"")}function Cd(t){return t.startsWith("./")?t:`./${t}`}var qs,_d=v(()=>{Us();pa();Fs();qs=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(xn(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 Ae(()=>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 Ae(()=>this.http.getJson(`${Pd}${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 Ae(()=>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 Ob,Js,Rd,rC,Ws,ha=v(()=>{Ob=t=>t.startsWith("@types/"),Js=t=>Object.keys(t?.peerDependencies||{}).filter(e=>!Ob(e)),Rd=t=>Object.keys(t?.dependencies||{}).filter(e=>!Ob(e)),rC=t=>Js(t).filter(e=>!t?.peerDependenciesMeta?.[e]?.optional),Ws=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 rC(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=>Js(i.meta))),r=new Map;for(let i of e)for(let o of Rd(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:Js(i.meta).length>0,isSharedDep:s.has(i.name)}]))}}});var Ks,Id=v(()=>{Us();pa();Ks=class{constructor(e,n,r){this.cache=e,this.cdn=n,this.semver=r}async learnExactVersion(e){let n=await Ae(()=>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 Ae(()=>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 Ae(()=>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 Ae(()=>this.resolveExactForRoot(s,i)):void 0;return{effectivePackage:o?r.withVersion(o).format():e,root:s,range:i,pinned:o}}}});import{init as sC,parse as iC}from"es-module-lexer";var yr,Nd=v(()=>{Us();Fs();ha();yr=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 sC;let[s]=iC(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:y,hasPeers:k,isSharedDep:A}=r.get(h),P=a.has(h),E=p!==h,I=!(y||A)&&(P||!k),L=this.singletonDepsOf(m,o),T=E&&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([...Js(e.meta),...Rd(e.meta)])].filter(r=>n.has(r))}};yr.importPatterns=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g]});import{gt as Pb,satisfies as oC,maxSatisfying as Cb,major as aC,valid as lC,validRange as cC}from"semver";var ma,En,$d=v(()=>{ma=class{cmp(e,n){return e===n?0:Pb(e,n)?1:Pb(n,e)?-1:0}satisfies(e,n){return!e||!e.trim()?!0:!!oC(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=Cb(e,r,{includePrerelease:!1});if(a)return a}return Cb(e,r,{includePrerelease:!0})??void 0}majorOf(e){return aC(e)}isExactVersion(e){return lC(e)!==null}isRange(e){return cC(e)!==null}},En=new ma});function uC(t){return Math.min(9e5*Math.pow(2,Math.max(0,t-1)),864e5)}var An,_b=v(()=>{pa();An=class{constructor(e){this.store=e}async isNegative(e){let n=await Ae(()=>this.store.get(e));return!!n&&n.until>Date.now()}async recordNegative(e){let r=((await Ae(()=>this.store.get(e)))?.attempts||0)+1;await Ae(()=>this.store.set(e,{until:Date.now()+uC(r),attempts:r}))}async clearNegative(e){await Ae(()=>this.store.delete(e))}}});function Rb(t,e){let n=new qs(t,e),r=new Ws(n),s=new Ks(t,n,En);return{packageService:new yr(s,n,r),versionResolver:s,cdnClient:n,peerResolver:r}}var yt=v(()=>{_d();ha();Id();Nd();$d();Us();$d();Fs();_d();ha();Id();Nd();_b()});import*as Ld from"fs/promises";import*as Ib from"crypto";function Xe(t){return Ib.createHash("sha1").update(t).digest("hex")}async function bt(t){try{return JSON.parse(await Ld.readFile(t,"utf8"))}catch{return}}async function ga(t){try{return await Ld.readFile(t,"utf8")}catch{return}}var br=v(()=>{"use strict"});import*as zt from"fs/promises";import*as wt from"path";import*as $b from"os";function te(){return Md||(Md=fC().catch(()=>pt())),Md}function ba(t,e){return wt.join(dC,Xe(t),e)}async function fC(){await zt.mkdir(Ht,{recursive:!0});let t=wt.join(Ht,"version.json");if((await bt(t))?.version===Nb)return;let n=await zt.readdir(Ht).catch(()=>[]);await Promise.all(n.map(r=>zt.rm(wt.join(Ht,r),{recursive:!0,force:!0}))),await zt.writeFile(t,JSON.stringify({version:Nb})+`
|
|
534
|
+
`,"utf8")}var Nb,Ht,Hs,zs,ya,dC,Md,wr=v(()=>{"use strict";br();Ye();Nb=1,Ht=wt.join($b.homedir(),".typebulb","cache"),Hs=wt.join(Ht,"packages"),zs=wt.join(Ht,"proxy"),ya=wt.join(Ht,"dts"),dC=wt.join(Ht,"emit")});import*as Yt from"fs/promises";import*as Lb from"path";async function Be(t,e){let n=`${t}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;try{await Yt.mkdir(Lb.dirname(t),{recursive:!0}),await Yt.writeFile(n,e,"utf8")}catch{pt();return}await Yt.rename(n,t).catch(async()=>{await Yt.rm(n,{force:!0}).catch(()=>{})})}var Ys=v(()=>{"use strict";Ye()});var vr,Dd=v(()=>{"use strict";Ys();br();vr=class{constructor(e){this.filePath=e}mem;loadPromise;load(){return this.mem?Promise.resolve(this.mem):(this.loadPromise||(this.loadPromise=bt(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 Be(this.filePath,JSON.stringify(Object.fromEntries(e)))}}});import*as Bb from"fs/promises";import*as Qe from"path";function Db(t,e){return Qe.join(pC,wa(t),encodeURIComponent(e)+".json")}function wa(t){return t.replace(/\//g,"__")}var Bd,Mb,pC,hC,va,jb=v(()=>{"use strict";yt();wr();Ys();Dd();br();Bd=Qe.join(Hs,"indexes"),Mb=Qe.join(Hs,"pinned"),pC=Qe.join(Hs,"meta"),hC=Qe.join(Hs,"negative.json"),va=class{pinnedMem=new Map;indexMem=new Map;metaMem=new Map;negativeCache=new An(new vr(hC));async getPinnedExact(e,n){let r=`${e}@${n}`;if(this.pinnedMem.has(r))return this.pinnedMem.get(r);await te();let s=await ga(Qe.join(Mb,Xe(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 Be(Qe.join(Mb,Xe(s)+".txt"),r)}async getIndex(e){if(this.indexMem.has(e))return this.indexMem.get(e);await te();let n=await bt(Qe.join(Bd,wa(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 Be(Qe.join(Bd,wa(e)+".json"),JSON.stringify(s))}async invalidateVersionsCache(e){this.indexMem.delete(e),await Bb.rm(Qe.join(Bd,wa(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 bt(Db(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 Be(Db(e,n),JSON.stringify(o))}}});var Fb,Ub=v(()=>{"use strict";Fb={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 mC,Sa,qb,Jb,Vj,jd=v(()=>{"use strict";yt();jb();Ub();mC=new va,{packageService:Sa,versionResolver:qb,cdnClient:Jb,peerResolver:Vj}=Rb(mC,Fb)});function ka(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Wb(){return` <script>
|
|
535
|
+
${Hg}
|
|
536
536
|
(function () {
|
|
537
537
|
try {
|
|
538
538
|
var key = function () { return 'tb-scroll:' + location.pathname + location.search; };
|
|
@@ -590,7 +590,7 @@ ${Vg}
|
|
|
590
590
|
});
|
|
591
591
|
} catch (e) {}
|
|
592
592
|
})();
|
|
593
|
-
</script>`}var vt,
|
|
593
|
+
</script>`}var vt,Kb,Fd,gC,yC,Ea,Sr=v(()=>{"use strict";Q();Q();vt=t=>t.replace(/<\/script/gi,"<\\/script");Kb=30*6e4,Fd=1e3,gC=6e4,yC=3e4,Ea=(t="'/__reload'")=>`
|
|
594
594
|
let es = null;
|
|
595
595
|
let bootId = null;
|
|
596
596
|
let firstErrorAt = 0;
|
|
@@ -605,9 +605,9 @@ ${Vg}
|
|
|
605
605
|
es.onerror = () => {
|
|
606
606
|
if (!firstErrorAt) firstErrorAt = Date.now();
|
|
607
607
|
// Inside the replace window, EventSource's own retry is faster than anything we'd schedule.
|
|
608
|
-
if (Date.now() - firstErrorAt <= ${
|
|
608
|
+
if (Date.now() - firstErrorAt <= ${gC}) return;
|
|
609
609
|
es.close();
|
|
610
|
-
backoff = Math.min(${
|
|
610
|
+
backoff = Math.min(${yC}, backoff ? backoff * 2 : ${Fd} * 2);
|
|
611
611
|
setTimeout(tbConnect, backoff);
|
|
612
612
|
};
|
|
613
613
|
};
|
|
@@ -623,7 +623,7 @@ ${Vg}
|
|
|
623
623
|
// A relay open (TB-VSCode-Browser.md): the CLI asks a page of ours inside VS Code to open a URL,
|
|
624
624
|
// since its integrated browser honors a gesture-less window.open and keeps the new tab in-editor.
|
|
625
625
|
tbOn('open-url', (e) => { window.open(e.data, '_blank', 'noopener'); });
|
|
626
|
-
tbConnect();`});var
|
|
626
|
+
tbConnect();`});var Hb,zb=v(()=>{"use strict";Sr();Q();Hb=`
|
|
627
627
|
(() => {
|
|
628
628
|
// Inline (bulb-in-a-bulb): runs inside a sandboxed iframe with no parent
|
|
629
629
|
// bridge, so privileged tb.* (AI, fs, server RPC) can't reach a host and would
|
|
@@ -1583,49 +1583,49 @@ ${Ea("tbStreamUrl")}
|
|
|
1583
1583
|
});
|
|
1584
1584
|
}
|
|
1585
1585
|
})();
|
|
1586
|
-
`});function
|
|
1587
|
-
`+
|
|
1586
|
+
`});function Yb(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?"":`
|
|
1587
|
+
`+Pu,y={imports:kC(a.imports)};return`<!DOCTYPE html>
|
|
1588
1588
|
<html>
|
|
1589
1589
|
<head>
|
|
1590
1590
|
<meta charset="utf-8">
|
|
1591
1591
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
1592
1592
|
<title>${ka(e)} - typebulb</title>
|
|
1593
1593
|
${xa(e,l)}
|
|
1594
|
-
${c?"":
|
|
1594
|
+
${c?"":Wb()}
|
|
1595
1595
|
<script type="importmap">
|
|
1596
|
-
${JSON.stringify(
|
|
1596
|
+
${JSON.stringify(y,null,2)}
|
|
1597
1597
|
</script>
|
|
1598
1598
|
<style>
|
|
1599
|
-
${
|
|
1599
|
+
${Ss}${m}
|
|
1600
1600
|
</style>
|
|
1601
1601
|
<style>
|
|
1602
1602
|
${r}
|
|
1603
1603
|
</style>
|
|
1604
1604
|
</head>
|
|
1605
1605
|
<body>
|
|
1606
|
-
${
|
|
1606
|
+
${h}
|
|
1607
1607
|
|
|
1608
1608
|
${i.length>0?`<script>window.__TB_DATA__ = ${vt(JSON.stringify(i))};</script>`:""}
|
|
1609
1609
|
${o?`<script>window.__TB_INSIGHT__ = ${vt(JSON.stringify(o))};</script>`:""}
|
|
1610
|
-
${
|
|
1611
|
-
${
|
|
1610
|
+
${u?`<script>window.__TB_DIR__ = ${vt(JSON.stringify(u))};</script>`:""}
|
|
1611
|
+
${f?`<script>window.__TB_BULB__ = ${vt(JSON.stringify(f))};</script>`:""}
|
|
1612
1612
|
${p?`<script>window.__TB_COMPILE_ERROR__ = ${vt(JSON.stringify(p))};</script>`:""}
|
|
1613
1613
|
|
|
1614
1614
|
<script>
|
|
1615
|
-
${
|
|
1616
|
-
${
|
|
1615
|
+
${Yg}
|
|
1616
|
+
${Hb}
|
|
1617
1617
|
</script>
|
|
1618
1618
|
|
|
1619
|
-
${
|
|
1619
|
+
${SC}
|
|
1620
1620
|
|
|
1621
|
-
${
|
|
1621
|
+
${wC(n,d)}
|
|
1622
1622
|
</body>
|
|
1623
|
-
</html>`}function
|
|
1624
|
-
`);return`<script type="module">${s}${
|
|
1625
|
-
</script>`}function
|
|
1623
|
+
</html>`}function wC(t,e){let n=["",...bC],r=e?Array(Math.max(0,e.codeLine-n.length-1)).fill(""):[],s=[...n,...r,vt(t)].join(`
|
|
1624
|
+
`);return`<script type="module">${s}${vC(e,s)}
|
|
1625
|
+
</script>`}function vC(t,e){if(!t)return"";let n=e.split(`
|
|
1626
1626
|
`).length,r={version:3,file:t.file,sources:[`/__source/${t.file}`],names:[],mappings:["AAAA",...Array(Math.max(0,n-1)).fill("AACA")].join(";")};return`
|
|
1627
1627
|
//# sourceURL=${t.file.replace(/\s/g,"%20")}
|
|
1628
|
-
//# sourceMappingURL=data:application/json;charset=utf-8,${encodeURIComponent(JSON.stringify(r))}`}function
|
|
1628
|
+
//# sourceMappingURL=data:application/json;charset=utf-8,${encodeURIComponent(JSON.stringify(r))}`}function kC(t){let e={};for(let[n,r]of Object.entries(t))e[n]=r.startsWith("https://")?"/proxy/"+r:r;return e}var bC,SC,Vb=v(()=>{"use strict";Q();zb();Sr();bC=["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) */"];SC=`<script>
|
|
1629
1629
|
(function () {
|
|
1630
1630
|
var framed = window.parent !== window;
|
|
1631
1631
|
var post = function (m) { try { parent.postMessage(m, '*'); } catch (e) {} }; /* framed only */
|
|
@@ -1724,20 +1724,20 @@ ${yC(n,d)}
|
|
|
1724
1724
|
}
|
|
1725
1725
|
});
|
|
1726
1726
|
})();
|
|
1727
|
-
</script>`});import*as Ta from"fs/promises";import*as Aa from"path";import{existsSync as
|
|
1728
|
-
Use a plain name with an exact / caret / tilde range (e.g. three@^0.160.0).`);await Ta.mkdir(e,{recursive:!0});let a=Aa.join(e,"package.json");
|
|
1729
|
-
Expected <origin>/u/<user>/<slug>`);let l=a[1],c=a[2].replace(/(\.bulb)?\.md$/,"");return{origin:i.origin,userSlug:l,slug:c,dest:
|
|
1730
|
-
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
|
|
1731
|
-
`),r=
|
|
1727
|
+
</script>`});import*as Ta from"fs/promises";import*as Aa from"path";import{existsSync as Gb,readFileSync as xC}from"fs";import{execFile as EC}from"child_process";import{promisify as AC}from"util";import{builtinModules as TC}from"node:module";import{satisfies as OC}from"semver";async function Oa(t,e,n,r){let i=t.map(c=>RC(c,n)).filter(c=>!IC(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(", ")}
|
|
1728
|
+
Use a plain name with an exact / caret / tilde range (e.g. three@^0.160.0).`);await Ta.mkdir(e,{recursive:!0});let a=Aa.join(e,"package.json");Gb(a)||await Ta.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 PC("npm",["install",...l,...i],{cwd:e,shell:!0})}function RC(t,e){if(!e||j.parse(t).version)return t;let n=e[t];return n?`${t}@${n}`:t}function IC(t,e){let{name:n,version:r}=j.parse(t),s=Aa.join(e,"node_modules",n);if(!Gb(s))return!1;if(!r)return!0;try{let i=JSON.parse(xC(Aa.join(s,"package.json"),"utf-8")).version;return OC(i,r)}catch{return!1}}function Pa(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);CC.has(i)||e.add(i)}return[...e]}var PC,CC,_C,Ud=v(()=>{"use strict";yt();PC=AC(EC),CC=new Set(TC),_C=/^(@[a-z0-9._-]+\/)?[a-z0-9._-]+(@[a-zA-Z0-9.^~*x-]+)?$/i});import*as je from"fs/promises";import*as Re from"path";function kr(t,e){let n=Re.resolve(e,t),r=Re.normalize(e),s=Re.normalize(n);if(s!==r&&!s.startsWith(r+Re.sep))throw new Error("Path traversal detected - access denied");return n}async function Vs(t,e){return je.readFile(kr(t,e))}async function Ca(t,e,n){let r=kr(t,n);await je.mkdir(Re.dirname(r),{recursive:!0}),await je.writeFile(r,typeof e=="string"?e:Buffer.from(e))}async function _a(t,e){let n=kr(t,e),r=await je.readdir(n,{withFileTypes:!0});return Promise.all(r.map(async s=>{let i=await je.stat(Re.join(n,s.name)).then(o=>o.mtimeMs).catch(()=>0);return{name:s.name,dir:s.isDirectory(),mtime:i}}))}async function Ra(t,e){let n=kr(t,e);if(Re.normalize(n)===Re.normalize(e))throw new Error("Cannot remove the bulb's folder itself: remove its contents instead");await je.rm(n,{recursive:!0})}var qd=v(()=>{"use strict"});async function Xb(t){let e=gt(t.provider,t.model);if(typeof e=="string")throw new Error(e);let n=await Wt(e,t);if(!n.ok){let r=await pr(n,e.protocol);throw new Error(r.message)}return{response:n,protocol:e.protocol}}async function NC(t){let{response:e,protocol:n}=await Xb(t);return hr(e,n)}async function*$C(t){let{response:e,protocol:n}=await Xb(t);yield*kn(e,n)}function Qb(t){let e=Object.assign(NC,{stream:$C}),n={read:async r=>{let s=await Vs(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 Vs(r,t)),write:async(r,s)=>(await Ca(r,s,t),!0),list:async(r=".")=>_a(r,t),remove:async r=>(await Ra(r,t),!0)};globalThis.tb=Object.freeze({log:(...r)=>{console.log(...r)},ai:e,fs:n,dir:t,models:()=>mt(),aiAccess:sa,mode:Vn.local})}var Zb=v(()=>{"use strict";qt();Q();fa();wn();qd()});import*as Vt from"fs/promises";import*as de from"path";import{pathToFileURL as LC}from"url";async function ew(t){let n=(await Vt.readdir(t)).find(r=>r.endsWith(".bulb.md"));return n?de.join(t,n):void 0}function xr(t){let e=de.resolve(t);return de.join(de.dirname(e),de.basename(e).replace(/\.bulb\.md$/,""))}function Er(t){let[e,n,r,s]=t.split(de.sep).slice(-4);if(!(e!=="typebulbs"||n!=="u"||!r||!s?.endsWith(".bulb.md")))return{userSlug:r,slug:s.slice(0,-8)}}async function Ze(t){let e=await Vt.readFile(t,"utf-8"),n=Mn(e),r=or(n);return{bulb:r,config:Ur(r.config),warnings:xp(e),starts:n.starts}}function Jd(t){let e=de.basename(t).replace(/\.bulb\.md$/i,"");return de.join(de.dirname(t),".typebulb",`${e}.server.mjs`)}async function Gs(t,e,n,r){let s=Od(t,{serverOnly:!0});if(s.error)throw new Error(`Server compilation error: ${s.error}`);let i=s.code;n&&(i=await yp(i,n));let o=de.join(de.dirname(e),".typebulb");await Vt.mkdir(o,{recursive:!0});let a=Pa(i);a.length>0&&await Oa(a,o,r);let l=Jd(e);return await Vt.writeFile(l,i,"utf-8"),Qb(xr(e)),await import(`${LC(l).href}?t=${Date.now()}`)}async function Wd(t,e,n,r){let{bulb:s,config:i,starts:o}=await Ze(t),a=Ao(s.data),l,c=h=>{l??=h instanceof Error?h.message:String(h)};try{xb(s.code,i.dependencies??{})}catch(h){c(h)}let u=Od(s.code,{jsxImportSource:i.ts?.jsxImportSource});u.error&&c(u.error);let d={imports:{}};if(!l)try{({importMap:d}=await Sa.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=Yb({name:s.name,code:l?"":u.code,css:s.css,html:s.html,data:a,insight:s.insight,importMap:d,dir:xr(t),watch:e,source:{file:de.basename(t),codeLine:o.get("code.tsx")??1},bulbKey:Os(t),compileError:l}),p;return s.server&&n&&(p=await Gs(s.server,t,r,i.dependencies)),{html:f,bulb:s,serverExports:p,buildError:l}}var Tn,St=v(()=>{"use strict";Rs();kb();Eb();jd();Vb();Ud();ki();Ye();Zb();Tn=t=>de.join(xr(t),"assets")});import*as Ie from"fs/promises";import*as Fe from"path";import{createHash as MC}from"crypto";async function Hd(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 Ar(t){try{return JSON.parse(t).error||t}catch{return t}}async function Yd(t,e){try{let n=await fetch(Xs(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}): ${Ar(await n.text())}`}}catch(n){return{error:n instanceof Error?n.message:String(n)}}}function Vd(t,e){Ee(e);let n=process.env.TYPEBULB_ORIGIN||DC;try{return $a(t,process.cwd(),n)}catch(r){console.error(r instanceof Error?r.message:String(r)),process.exit(1)}}function $a(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}
|
|
1729
|
+
Expected <origin>/u/<user>/<slug>`);let l=a[1],c=a[2].replace(/(\.bulb)?\.md$/,"");return{origin:i.origin,userSlug:l,slug:c,dest:Fe.join(e,Ia(l,c))}}let r=Fe.resolve(e,t),s=Er(r);if(!s)throw new Error(`Not a conventional bulb path: ${t}
|
|
1730
|
+
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 BC(t,e){let n=await Yd(t,e);if("error"in n||!n.entries.length)return{kind:"none"};let r=n.entries,s=Tn(t.dest),i=[],o=[],a=0;for(let l of r){let c=await Ie.readFile(Fe.join(s,...l.path.split("/"))).catch(()=>{});c===void 0?i.push(l.path):zd(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 jC(t,e,n){let r=Tn(t.dest),s=[],i=0;return await Hd(e.toGet,4,async o=>{try{let a=await fetch(`${Xs(t)}/${Na(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=Fe.join(r,...o.split("/"));await Ie.mkdir(Fe.dirname(l),{recursive:!0}),await Ie.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 La(t,e={}){let n=await fetch(Kd(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 Ie.readFile(t.dest,"utf-8")}catch{}let o=i!==void 0&&FC(i,s);if(i!==void 0&&!o&&!e.force){let{mtime:c}=await Ie.stat(t.dest);return{kind:"conflict",dest:t.dest,localMtime:c,remoteLastModified:n.headers.get("last-modified")??void 0}}let a=await BC(t,e);if(a.kind==="conflict")return{kind:"asset-conflict",dest:t.dest,paths:a.paths};if(!o){await Ie.mkdir(Fe.dirname(t.dest),{recursive:!0}),await Ie.writeFile(t.dest,s);let c=new Date(n.headers.get("last-modified")??"");isNaN(c.getTime())||await Ie.utimes(t.dest,new Date,c)}let l=a.kind==="plan"?await jC(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 FC(t,e){let n=i=>i.replace(/\r\n/g,`
|
|
1731
|
+
`),r=Ke(n(t)),s=Ke(n(e));return!r||!s?n(t)===n(e):r.frontmatter.name===s.frontmatter.name&&We.every(i=>(r.files.get(ue[i].path)||"")===(s.files.get(ue[i].path)||""))}async function nw(t,e){t||(console.error("Usage: typebulb pull <bulb url | typebulbs/u/<user>/<slug>.bulb.md>"),process.exit(1));let n=Vd(t,e.mode),r=`${n.origin}/u/${n.userSlug}/${n.slug}`,s;try{s=await La(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=Fe.relative(process.cwd(),n.dest)||n.dest;switch(s.kind){case"written":console.log(`pulled ${r} \u2192 ${i}${s.created?"":" (overwritten)"}`),tw(s.assets);return;case"up-to-date":console.log(`up to date: ${i}`),tw(s.assets);return;case"conflict":console.error(`Refusing to overwrite ${i} \u2014 it differs from ${r}
|
|
1732
1732
|
local file modified ${s.localMtime.toISOString()}
|
|
1733
1733
|
remote last saved ${s.remoteLastModified??"unknown"}
|
|
1734
1734
|
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:
|
|
1735
1735
|
`+s.paths.map(o=>` assets/${o}`).join(`
|
|
1736
1736
|
`)+`
|
|
1737
|
-
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
|
|
1737
|
+
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 tw(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 DC,Ia,Kd,Na,Xs,zd,Ma=v(()=>{"use strict";it();Q();St();DC="https://typebulb.com",Ia=(t,e)=>Fe.join("typebulbs","u",t,`${e}.bulb.md`),Kd=t=>`${t.origin}/u/${encodeURIComponent(t.userSlug)}/${encodeURIComponent(t.slug)}.md`,Na=t=>t.split("/").map(encodeURIComponent).join("/"),Xs=t=>`${t.origin}/u/${encodeURIComponent(t.userSlug)}/${encodeURIComponent(t.slug)}/assets`;zd=t=>MC("md5").update(t).digest("hex")});import*as ot from"fs/promises";import*as Qs from"path";async function rw(t,e=""){let n=await ot.readdir(t,{withFileTypes:!0}).catch(()=>[]),r=[];for(let s of n)s.isDirectory()?r.push(...await rw(Qs.join(t,s.name),`${e}${s.name}/`)):s.isFile()&&r.push(e+s.name);return r}async function UC(t,e){let n=e.timeoutMs??3e4,r=Xs(t),s={Authorization:`Bearer ${e.token}`},i=Tn(t.dest);if(!await ot.stat(i).then(h=>h.isDirectory()).catch(()=>!1))return{kind:"skipped"};let o=await rw(i),a=await Yd(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 Hd(o,4,async h=>{let m=await ot.readFile(Qs.join(i,...h.split("/")));if(c.get(h)===zd(m)){p++;return}let y=await fetch(`${r}/${Na(h)}`,{method:"PUT",body:new Uint8Array(m),headers:s,signal:AbortSignal.timeout(n)});if(!y.ok)throw new Error(`upload of '${h}' refused (${y.status}): ${Ar(await y.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:Ti(t.userSlug,t.slug)}}async function qC(t,e,n){let r=n.timeoutMs??3e4,s=Xs(t),i=[];for(let o of e)try{let a=await fetch(`${s}/${Na(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}): ${Ar(await a.text())}`};i.push(o)}catch(a){return{deleted:i,error:a instanceof Error?a.message:String(a)}}return{deleted:i}}async function Da(t,e){let n=await ot.readFile(t.dest,"utf-8"),{mtime:r}=await ot.stat(t.dest),s=await UC(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(Kd(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:Ar(l),assets:i};if(!a.ok)return{kind:"http-error",status:a.status,message:Ar(l),assets:i};let c=JSON.parse(l);if(await ot.utimes(t.dest,new Date,new Date(c.updatedAt)),i&&s.kind==="synced"&&s.toDelete.length){let u=await qC(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 sw(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=Vd(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=Qs.relative(process.cwd(),n.dest)||n.dest,o;try{o=await Da(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}
|
|
1738
1738
|
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}
|
|
1739
1739
|
pull to see the remote: typebulb pull ${i}
|
|
1740
|
-
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 Gd=
|
|
1740
|
+
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 Gd=v(()=>{"use strict";Q();Ma();St()});var Tr=v(()=>{"use strict";Me();Xy();pn();Qy();td();rb();ib();$s();wn();wn();fa();Td();Me();Ma();Gd();it();Ye()});import{existsSync as JC,mkdirSync as WC,readFileSync as KC,rmSync as HC,writeFileSync as zC}from"fs";import{homedir as YC}from"os";import*as Or from"path";function QC(){return XC.replace('"__TB_SKILL_PATH__"',JSON.stringify(Bs())).replace('"__TB_BIN_PATH__"',JSON.stringify(ir()))}function iw(){try{if(!JC(Xd()))return}catch{return}try{let t=VC(),e=QC(),n;try{n=KC(t,"utf8")}catch{}n!==e&&(WC(Or.dirname(t),{recursive:!0}),zC(t,e))}catch{}for(let t of GC())try{HC(t,{force:!0})}catch{}}var Xd,VC,GC,XC,ow=v(()=>{"use strict";Tr();Xd=()=>Or.join(YC(),".pi","agent"),VC=()=>Or.join(Xd(),"extensions","typebulb.ts"),GC=()=>["typebulb-wait.ts","matchu-patchu.ts"].map(t=>Or.join(Xd(),"extensions",t)),XC=String.raw`// Generated by typebulb — do not edit; overwritten on each run.
|
|
1741
1741
|
import { spawn } from "node:child_process";
|
|
1742
1742
|
import { existsSync } from "node:fs";
|
|
1743
1743
|
|
|
@@ -2005,23 +2005,23 @@ export default function (pi) {
|
|
|
2005
2005
|
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) {}
|
|
2006
2006
|
} catch (e) { logErr("load", e && e.message); }
|
|
2007
2007
|
}
|
|
2008
|
-
`});function Y(t){return t?.message??String(t)}var V,
|
|
2009
|
-
`))>=0;){let o=r.slice(0,i);r=r.slice(i+1),o.endsWith("\r")&&(o=o.slice(0,-1)),o&&e(o)}})}var
|
|
2010
|
-
`)}catch{}await Promise.race([this.#x,
|
|
2008
|
+
`});function Y(t){return t?.message??String(t)}var V,Gt=v(()=>{"use strict";V=process.cwd()});import{spawn as aw}from"child_process";import{StringDecoder as ZC}from"string_decoder";function i_(t,e){let n=new ZC("utf8"),r="";t.on("data",s=>{r+=typeof s=="string"?s:n.write(s);let i;for(;(i=r.indexOf(`
|
|
2009
|
+
`))>=0;){let o=r.slice(0,i);r=r.slice(i+1),o.endsWith("\r")&&(o=o.slice(0,-1)),o&&e(o)}})}var e_,lw,cw,Qd,uw,t_,n_,r_,dw,s_,Ba,ja,fw,pw=v(()=>{"use strict";Gt();e_=3e4,lw=18e4,cw="starting pi\u2026",Qd=5e3,uw=2e3,t_=2e3,n_=12e4,r_=8e3,dw=15e3,s_=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"]),Ba=new Set;process.on("exit",()=>{for(let t of Ba)try{t.kill()}catch{}});ja=class{#t;#l=!1;#n=0;#i=!1;#h=0;#s=!1;#d=null;#o=[];#c=null;#e=null;#r=null;#u=new Map;#a=[];#b=null;#k=null;#w=null;#m;#g;#v="";#_=1;#f=new Map;#x;#S;constructor(e,n,r=(s,i)=>aw(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: ${Y(o)}`,this.#S();return}this.#t=i,this.#m=n,this.#i=!0,this.#h=Date.now()+lw,this.#e={text:cw,kind:"info"},Ba.add(i),i.stdout&&i_(i.stdout,o=>this.#I(o)),i.stderr&&i.stderr.on("data",o=>{this.#v=(this.#v+o.toString()).slice(-t_)}),i.on("error",o=>this.#P(`could not start pi: ${o.message}`)),i.on("exit",o=>{this.#t===i&&this.#P(o?`pi exited (code ${o})${this.#v.trim()?`: ${this.#v.trim()}`:""}`:"pi exited"),Ba.delete(i),this.#S()}),this.#p({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.#i&&(this.#i=!1,this.#e?.text===cw&&(this.#e=null),this.#r&&(this.#r.until=Date.now()+dw),!this.#l&&Date.now()<this.#n&&(this.#n=Date.now()+Qd),this.#T())}get streaming(){return this.#l||Date.now()<this.#n}get draft(){return this.#d}get echo(){return this.#c}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.#e)return this.#e;if(this.#r){if(Date.now()<this.#r.until)return{text:this.#r.text,kind:this.#r.kind};this.#r=null}return this.#u.size?{text:[...this.#u.values()].join(" \xB7 "),kind:"info"}:null}get dialog(){let e=Date.now();for(;this.#a.length;){let n=this.#a[0];if(e<n.until)return n.req;this.#a.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.#a.findIndex(o=>o.req.id===e);if(r<0)return{ok:!1,error:"dialog expired or already answered"};let[s]=this.#a.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(!s_.has(e.type))return{ok:!1,error:`command not allowed: ${e.type}`};try{let n=await this.#p(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.#p({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:Y(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.#n=l,s||(this.#c=e))};if(this.#i)return this.#p(i).catch(()=>{}),o(this.#h+Qd),{ok:!0};let a;try{a=await this.#p(i)}catch(l){return{ok:!1,error:Y(l)}}return a.success&&o(Date.now()+Qd),a.success?{ok:!0}:{ok:!1,error:a.error??"pi rejected the message"}}async stop(){if(this.#t){if(this.#i){this.#E({type:"abort"}),this.#n=0;return}try{await this.#p({type:"abort"})}catch{}}}clearCompletedDraft(){this.#s||(this.#d=null)}clearEcho(){this.#c=null}async dispose(){let e=this.#t;if(e){if(this.#t=void 0,this.#i=!1,this.#l){try{e.stdin?.write(JSON.stringify({type:"abort"})+`
|
|
2010
|
+
`)}catch{}await Promise.race([this.#x,fw(uw)])}try{e.stdin?.end()}catch{}if(await Promise.race([this.#x,fw(uw)]),e.exitCode===null&&!e.killed)if(process.platform==="win32"&&e.pid)try{aw("taskkill",["/pid",String(e.pid),"/T","/F"],{stdio:"ignore"})}catch{}else try{e.kill("SIGKILL")}catch{}Ba.delete(e),this.#a=[],this.#C("pi was shut down")}}#E(e){try{this.#t?.stdin?.write(JSON.stringify(e)+`
|
|
2011
2011
|
`)}catch{}}#O(){let e=this.#o[this.#o.length-1];this.#d={text:this.#o.filter(n=>n?.kind==="text").map(n=>n.text).join(""),thinking:this.#o.filter(n=>n?.kind==="thinking").map(n=>n.text).join(`
|
|
2012
|
-
`),tool:e?.kind==="tool"?e.name:void 0}}#A(e){let n=Array.isArray(e?.content)?e.content:[];this.#o=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.#O()}#y(e,n){let r=e.length>200?e.slice(0,200)+"\u2026":e;r&&(this.#r={text:r,kind:n,until:Date.now()+(n==="info"?
|
|
2013
|
-
`)}catch(l){clearTimeout(a),this.#f.delete(s),o(new Error(Y(l)))}})}#I(e){let n;try{n=JSON.parse(e)}catch{return}switch(n.type){case"response":{let r=n,s=r.id?this.#f.get(r.id):void 0;s&&(this.#f.delete(r.id),clearTimeout(s.timer),s.resolve(r));return}case"agent_start":this.#l=!0,this.#n=0;return;case"agent_end":this.#l=!1,this.#n=0,this.#s=!1,this.#e=null,this.#b=null,this.#T();return;case"message_start":{let r=n.message;if(r?.role!=="assistant")return;this.#s=!0,this.#A(r);return}case"message_update":{if(!this.#s)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.#o[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.#O();return}case"message_end":if(!this.#s)return;n.message&&this.#A(n.message),this.#s=!1;return;case"auto_retry_start":this.#e={text:`retrying after a transient error (attempt ${Number(n.attempt)||1}/${Number(n.maxAttempts)||"?"})\u2026`,kind:"warning"};return;case"auto_retry_end":this.#e=null,n.success===!1&&this.#y(`retries exhausted: ${String(n.finalError??"unknown error")}`,"error");return;case"compaction_start":this.#e={text:"compacting context\u2026",kind:"info"};return;case"compaction_end":{this.#e=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.#a.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??
|
|
2014
|
-
`).filter(Boolean).map(s=>s.replace(/\\/g,"/"))}return null}function
|
|
2015
|
-
`),l=i.filter(
|
|
2016
|
-
`))if(p.includes('"session_info"'))try{let
|
|
2017
|
-
`))if(!(c||!d.includes('"type"')))try{let
|
|
2018
|
-
`):""}}});var Ua,
|
|
2012
|
+
`),tool:e?.kind==="tool"?e.name:void 0}}#A(e){let n=Array.isArray(e?.content)?e.content:[];this.#o=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.#O()}#y(e,n){let r=e.length>200?e.slice(0,200)+"\u2026":e;r&&(this.#r={text:r,kind:n,until:Date.now()+(n==="info"?r_:dw)})}#T(){this.#p({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(()=>{})}#p(e){let n=this.#t;if(!n?.stdin?.writable)return Promise.reject(new Error(this.#g??"pi is not running"));let r=this.#i?lw:e_,s=`tb-${this.#_++}`;return new Promise((i,o)=>{let a=setTimeout(()=>{this.#f.delete(s),o(new Error(`pi did not respond (${Math.round(r/1e3)}s)`))},r);a.unref?.(),this.#f.set(s,{resolve:i,timer:a});try{n.stdin.write(JSON.stringify({id:s,...e})+`
|
|
2013
|
+
`)}catch(l){clearTimeout(a),this.#f.delete(s),o(new Error(Y(l)))}})}#I(e){let n;try{n=JSON.parse(e)}catch{return}switch(n.type){case"response":{let r=n,s=r.id?this.#f.get(r.id):void 0;s&&(this.#f.delete(r.id),clearTimeout(s.timer),s.resolve(r));return}case"agent_start":this.#l=!0,this.#n=0;return;case"agent_end":this.#l=!1,this.#n=0,this.#s=!1,this.#e=null,this.#b=null,this.#T();return;case"message_start":{let r=n.message;if(r?.role!=="assistant")return;this.#s=!0,this.#A(r);return}case"message_update":{if(!this.#s)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.#o[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.#O();return}case"message_end":if(!this.#s)return;n.message&&this.#A(n.message),this.#s=!1;return;case"auto_retry_start":this.#e={text:`retrying after a transient error (attempt ${Number(n.attempt)||1}/${Number(n.maxAttempts)||"?"})\u2026`,kind:"warning"};return;case"auto_retry_end":this.#e=null,n.success===!1&&this.#y(`retries exhausted: ${String(n.finalError??"unknown error")}`,"error");return;case"compaction_start":this.#e={text:"compacting context\u2026",kind:"info"};return;case"compaction_end":{this.#e=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.#a.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??n_),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.#u.set(s,n.statusText):this.#u.delete(s)}return}default:return}}#P(e){this.#g=e,this.#i=!1,this.#l=!1,this.#n=0,this.#s=!1,this.#d=null,this.#o=[],this.#c=null,this.#e=null,this.#r=null,this.#u.clear(),this.#a=[],this.#b=null,this.#k=null,this.#w=null,this.#t=void 0,this.#C(e)}#C(e){for(let[,n]of this.#f)clearTimeout(n.timer),n.resolve({type:"response",success:!1,error:e});this.#f.clear()}},fw=t=>new Promise(e=>{setTimeout(e,t).unref?.()})});import{existsSync as hw,readFileSync as o_,realpathSync as a_}from"fs";import{join as On,dirname as bw,resolve as l_}from"path";import{homedir as mw}from"os";function u_(t,e){let n=On(t,".pi");if(c_.some(s=>hw(On(n,s))))return!0;let r=On(e,".agents","skills");for(let s=t;;){let i=On(s,".agents","skills");if(i!==r&&hw(i))return!0;let o=bw(s);if(o===s)return!1;s=o}}function d_(t,e){for(let n=e;;){if(t[n]===!0||t[n]===!1)return!0;let r=bw(n);if(r===n)return!1;n=r}}function ww(t,e){try{let n=e?.agentDir??On(mw(),".pi","agent"),r=gw(e?.home??process.env.HOME??mw()),s=gw(l_(t));if(!u_(s,r))return null;let i=yw(On(n,"settings.json")).defaultProjectTrust;return i==="always"||i==="never"||d_(yw(On(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 c_,gw,yw,vw=v(()=>{"use strict";c_=["settings.json","extensions","skills","prompts","themes","SYSTEM.md","APPEND_SYSTEM.md"],gw=t=>{try{return a_(t)}catch{return t}},yw=t=>{try{return JSON.parse(o_(t,"utf8"))}catch{return{}}}});import{statSync as f_,openSync as p_,readSync as h_,closeSync as m_,existsSync as kw}from"fs";import{join as Fa}from"path";import{homedir as Zd}from"os";import{execFile as g_}from"child_process";async function b_(t){let e=Fa(Zd(),".pi","agent","bin",process.platform==="win32"?"fd.exe":"fd");for(let n of["fd","fdfind",...kw(e)?[e]:[]]){let r=await new Promise(s=>{g_(n,["--base-directory",t,"--type","f","--follow","--hidden","--exclude",".git"],{maxBuffer:67108864},(i,o)=>s(i?null:o))});if(r!==null)return r.split(`
|
|
2014
|
+
`).filter(Boolean).map(s=>s.replace(/\\/g,"/"))}return null}function w_(t){return`--${t.replace(/^[/\\]/,"").replace(/[/\\:]/g,"-")}--`}function Sw(t){return t.type==="message"?v_(t.message?.role):t.type==="custom_message"?t.display!==!1:!1}var y_,v_,Pr,ef=v(()=>{"use strict";xs();Io();No();ow();pw();vw();y_=Fa(Zd(),".pi","agent","sessions");v_=t=>t==="user"||t==="assistant"||t==="toolResult"||t==="bashExecution";Pr=class extends jt{displayName="Pi Mirror";detectsSelf(){return process.env.PI_CODING_AGENT==="true"}detectsInstalled(){return kw(Fa(Zd(),".pi","agent"))}ensureHarnessSupport(){iw()}createDriver(e,n){let r=new ja(e,n),s=ww(e);return s&&r.notice(s,"warning"),r}walkFiles(e){return b_(e)}sessionsDir(e){return Fa(y_,w_(e))}listSessionFiles(e){return Ro(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 Sw(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:Le(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(`
|
|
2015
|
+
`),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)Sw(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=p_(e,"r")}catch{return""}try{let s=65536;try{s=f_(e).size}catch{}let i=(d,f)=>{let p=Buffer.alloc(f),h=h_(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(`
|
|
2016
|
+
`))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(`
|
|
2017
|
+
`))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{m_(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?Co(n.data,n.mimeType):"").filter(Boolean).join(`
|
|
2018
|
+
`):""}}});var Ua,xw=v(()=>{"use strict";Ua=class{#t=new Map;accept(e,n){return this.#t.get(e)===n?!1:(this.#t.set(e,n),!0)}}});import{execFile as S_}from"child_process";import{promisify as k_}from"util";import{readFile as x_}from"fs/promises";import{resolve as Ew,sep as E_}from"path";async function be(t,e){let{stdout:n}=await A_("git",t,{cwd:e,maxBuffer:67108864});return n}async function Pn(){if(qa)return qa;try{qa=(await be(["rev-parse","--show-toplevel"],V)).trim()}catch{}return qa}function T_(t,e){let n=e===" "?t:e;return n==="?"?"U":n}async function nf(){let t=await Pn();if(!t)return{repo:!1,root:"",files:[]};try{let e=await be(["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:T_(i[0],i[1])}))}try{let s=await be(["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:Y(e)}}}async function rf(t){let e=await Pn();if(!e)return{ok:!1,error:"not a git repository"};try{if((await be(["status","--porcelain","-z","--",t],e)).startsWith("??")){let s=Ew(e,t);if(!s.startsWith(Ew(e)+E_))return{ok:!1,error:"outside repository"};let i=await x_(s);return i.includes(0)?tf("Binary file (not shown)",!1):tf(i.toString("utf8"),!0)}let r;try{r=await be(["diff","--no-color","--unified=999999","HEAD","--",t],e)}catch{r=await be(["diff","--no-color","--unified=999999","--",t],e)}return tf(r,!1)}catch(n){return{ok:!1,error:Y(n)}}}var A_,Aw,qa,tf,Cr=v(()=>{"use strict";Gt();A_=k_(S_),Aw=2e6;tf=(t,e)=>({ok:!0,text:t.slice(0,Aw),untracked:e,truncated:t.length>Aw})});function Zs(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 sf=v(()=>{"use strict"});function Tw(){return O_.map(([t,e])=>gt(t,e)).filter(t=>typeof t!="string")}function Ow(){return Tw().length>0}async function Ja(t,e,n=0){let r=AbortSignal.timeout(e);for(let s of Tw()){try{let i=await Wt(s,{messages:[{role:"user",content:t}],effort:n,webSearch:!1,signal:r});if(i.ok){let o=(await vd(i,s.protocol)).trim();if(o)return o}}catch{}if(r.aborted)return}}var O_,of=v(()=>{"use strict";qt();Tr();O_=[["openrouter","openai/gpt-6-luna"],["openai","gpt-6-luna"]]});var Wa,Ka,kt,_r=v(()=>{"use strict";Wa=".typebulb/paste",Ka={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",bmp:"image/bmp"},kt=t=>t.label||t.kind||"agent"});import{existsSync as P_,mkdirSync as C_,writeFileSync as __,readFileSync as R_}from"fs";import{join as Ha}from"path";function Pw(){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 $_(t){return t.trim().toLowerCase().replace(/\.[a-z0-9]{1,4}$/,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)}async function L_(t){let e=await Ja(`Reply with ONLY a short kebab-case filename (2-5 words, lowercase, no extension) describing this text:
|
|
2019
2019
|
|
|
2020
|
-
${t.slice(0,
|
|
2021
|
-
|
|
2020
|
+
${t.slice(0,N_)}`,I_);return e&&$_(e)||void 0}async function Cw(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=Ha(t,Wa);try{C_(n,{recursive:!0})}catch(a){return{ok:!1,error:Y(a)}}let r,s,i;if(e.kind==="image"){if(r=`img-${Pw()}`,s=Object.keys(Ka).find(a=>Ka[a]===e.mime)??"png",i=Buffer.from(e.data,"base64"),!i.length)return{ok:!1,error:"empty image data"}}else r=await L_(e.data)??`paste-${Pw()}`,s="md",i=e.data;let o=`${r}.${s}`;for(let a=2;P_(Ha(n,o));a++)o=`${r}-${a}.${s}`;try{__(Ha(n,o),i)}catch(a){return{ok:!1,error:Y(a)}}return{ok:!0,path:`${Wa}/${o}`}}function _w(t,e){if(!/^[\w-]+(\.[\w-]+)*$/.test(e))return{ok:!1,error:"bad name"};let n=e.slice(e.lastIndexOf(".")+1).toLowerCase(),r=Ka[n];if(!r)return{ok:!1,error:"not an image"};try{return{ok:!0,mime:r,base64:R_(Ha(t,Wa,e)).toString("base64")}}catch{return{ok:!1,error:"not found"}}}var I_,N_,Rw=v(()=>{"use strict";of();Gt();_r();I_=4e3,N_=4e3});async function $w(t,e=""){let n=t.trim();if(!n)return{ok:!1,error:"nothing to summarize"};if(!Ow())return B_;let r=e.trim()?Nw+`CONTEXT \u2014 the user message this reply answers. It is context only: never summarize it, and never report it as the reply's content.
|
|
2021
|
+
`+D_(e.trim())+`
|
|
2022
2022
|
|
|
2023
2023
|
REPLY TO SUMMARIZE:
|
|
2024
|
-
`+n.slice(0,
|
|
2024
|
+
`+n.slice(0,Iw):Nw+n.slice(0,Iw),s=await Ja(r,M_,1);return s?{ok:!0,text:s}:j_}var M_,Iw,Nw,D_,B_,j_,Lw=v(()=>{"use strict";of();M_=2e4,Iw=24e3,Nw=`Summarize this assistant reply for someone who wants its substance without the prose.
|
|
2025
2025
|
|
|
2026
2026
|
- 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.
|
|
2027
2027
|
- 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.
|
|
@@ -2036,74 +2036,31 @@ Reply with the summary alone.
|
|
|
2036
2036
|
|
|
2037
2037
|
---
|
|
2038
2038
|
|
|
2039
|
-
|
|
2039
|
+
`,D_=(t,e=4e3)=>{if(t.length<=e)return t;let n=Math.floor(e/2)-20;return t.slice(0,n)+`
|
|
2040
2040
|
|
|
2041
2041
|
[snipped for brevity]
|
|
2042
2042
|
|
|
2043
|
-
`+t.slice(t.length-n)},
|
|
2044
|
-
{"
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
`)}
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
{"
|
|
2059
|
-
"rows": [{"id": 1, "status": "not_started | in_progress | done | blocked", "did": "...", "note": "...", "steps": [[a, b]], "evidence": [[a, b]]}],
|
|
2060
|
-
"offBrief": [{"what": "short phrase", "note": "...", "steps": [[a, b]]}]}
|
|
2061
|
-
|
|
2062
|
-
Rules:
|
|
2063
|
-
- "now": one line, the sub-agent's current finding or working hypothesis at the end of the log: what it has established or suspects, with the decisive specific (the cause, the file, the number). Not what it is looking at. If it has finished, its outcome.
|
|
2064
|
-
- "decision": one line when it is stuck, about to decide something the brief did not cover, or has left a question open for the delegator or owner to settle. Its own reports and messages are where it raises these ("an owner decision", "your call", "needs a ruling"): carry any such open question here, even when a row mentions it too. Otherwise "".
|
|
2065
|
-
- One row per subtask, same ids. "steps" lists EVERY bracketed step range that worked on it: reading, attempts, failures and fixes, not only the result. Together the rows and offBrief should cover the whole log; ranges never overlap.
|
|
2066
|
-
- "evidence" lists the few steps that show where it stands: the result for done, the latest work for in_progress.
|
|
2067
|
-
- "done" only when the log shows the result. If the only evidence is the agent's own report, write "reported" in "did".
|
|
2068
|
-
- A step's result is one line of its output, and its last line where the log gives one; "(+N lines)" is how much more there was. Never read a count or a total off a line that does not state it.
|
|
2069
|
-
- "did" says what was achieved so far: outcome and state, not tool mechanics. For a done row, one short clause. For an in_progress row, what has been found or confirmed so far, never only what was examined ("Confirmed the per-stroke check drops stretches 3 and 6-10", not "Investigated the dropped stretches"); when nothing is established yet, the hypothesis being tested. A file name only when it is the deliverable. A not_started row has "did": "".
|
|
2070
|
-
- Make the work the subject of every sentence ("Counted 14 references", "The build passes"); never refer to the agent itself, as "the agent", "it", or otherwise.
|
|
2071
|
-
- Unfinished is not off track: a subtask not started yet is normal while earlier ones run.
|
|
2072
|
-
- "note" only for something that would change what the delegator does: repeated failures, a problem found outside the task, a risk to the deliverable, unexpected time spent. Use the FACTS, which are counted. Most rows have no note, and a whole table rarely has more than two. Never a note: remaining work, a failure fixed at once, an instruction followed as directed, a remark on style, or anything "did" or "decision" already says.
|
|
2073
|
-
- "offBrief": work the brief did not ask for, done by the sub-agent itself. Something it only saw is not its work: a file changed by someone else, shown in a status or a diff. Empty array if none.
|
|
2074
|
-
|
|
2075
|
-
FACTS (counted from the log):
|
|
2076
|
-
${t.facts||"none"}
|
|
2077
|
-
|
|
2078
|
-
LOG (steps numbered in brackets):
|
|
2079
|
-
${t.log}`,lf=2e5,D_=t=>t.length<=lf?t:t.slice(0,lf/3)+`
|
|
2080
|
-
[\u2026 earlier steps omitted \u2026]
|
|
2081
|
-
`+t.slice(-lf*2/3)});import{readFileSync as B_,statSync as j_}from"fs";function Ha(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.at=i),l});return{...s,events:o}}function za(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 Bw(t,e,n){let r=t.forRead(),s;try{s=B_(e,"utf8")}catch{return[]}let{entries:i,add:o}=za(r),a=o(s.split(`
|
|
2082
|
-
`),n),l=[],c=new Set;for(let u=a;u&&!c.has(u);){let p=i.get(u);if(!p)break;c.add(u),l.push(p),u=r.parentOf(p)}let f=[],d=Date.now();for(let u of l.reverse())if(!r.isSidechain(u,n))try{f.push(...Ha(r,u,n,d).events)}catch{}return f}function Ya(t,e,n,r){let s=t.sessionAlive(e,n);if(s!==void 0)return s;if(!r)return!1;try{return Date.now()-j_(r).mtimeMs<1e4}catch{return!1}}function ei(t,e){return t.stopped?"stopped":t.running&&e?"running":"done"}var df=S(()=>{"use strict"});function F_(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})}var ti,ff=S(()=>{"use strict";ti=(t,e)=>F_(t,{key:e,desc:!0})});function Q_(t,e){let n=t.digest??"",r=ty.exec(n)?.[0]??"",s=Pr(n.slice(0,n.length-r.length),e)+r,i=r&&pf(t)?Pr(H_(t.result??""),e):"";return i?`${s}, last: ${i}`:s}function Uw(t){let e=[];for(let n of t)if(n.type==="cleared")e.length=0;else if(n.type==="user"){let r=e.at(-1);r?.role==="user"&&!n.agent&&!r.agent?r.text+=`
|
|
2083
|
-
|
|
2084
|
-
`+n.text:e.push({role:"user",text:n.text,tools:[],agent:n.agent,at:n.at})}else if(n.type==="assistant")e.push({role:"assistant",text:n.text,tools:n.tools.map(r=>({...r,isError:!1,at:n.at})),at:n.at});else if(n.type==="tool_result"){let r=e.flatMap(s=>s.tools).find(s=>s.id===n.id);r&&(r.result=n.content,r.isError=n.isError,r.digest=n.digest,r.doneAt=n.at)}return e}function qw(t){let e="",n=[],r=[],s=[],i=[],o=0;for(let d of t)if(o=Math.max(o,d.at??0,...d.tools.map(u=>u.doneAt??u.at??0)),d.role!=="fork"){if(d.role==="user"){if(d.agent){i.push({after:r.length,line:"REPORT FROM ITS OWN SUB-AGENT: "+ni(d.text,1500)});continue}if(!e){e=d.text;continue}n.push(d.text),i.push({after:r.length,line:`FOLLOW-UP FROM PARENT: ${ni(d.text,1500)}`});continue}d.text&&i.push({after:r.length,line:"AGENT SAYS: "+ni(d.text,1500)});for(let u of d.tools){r.push({n:r.length+1,tool:u,wall:0,parts:[]});let p=u.input?.message;typeof p=="string"&&p.length>200&&i.push({after:r.length,line:`AGENT SENDS (${Cu(u.name)}): ${ni(p,8e3)}`})}}let a=eR(t,r,o),l=i.at(-1);if(l&&/^AGENT SAYS/.test(l.line)){let d=[...t].reverse().find(u=>u.role==="assistant"&&u.text);d&&(l.line="AGENT SAYS: "+ni(d.text,8e3))}let c=new Map;for(let d of i)c.set(d.after,[...c.get(d.after)??[],d.line]);s.push(...c.get(0)??[]);let f=r.length-U_;for(let d=0;d<r.length;){let u=r[d];if(u.n<=f&&jw.has(u.tool.name)&&!u.tool.isError){let g=d;for(;g<r.length&&r[g].n<=f&&jw.has(r[g].tool.name)&&!r[g].tool.isError&&(g===d||!c.has(r[g-1].n));)g++;if(g-d>=3){let x=[...new Set(r.slice(d,g).map(O=>Ou(Pu(O.tool.input))))];s.push(`[${u.n}-${r[g-1].n}] explored ${g-d} files/searches: ${Pr(x.join(", "),160)}`),s.push(...c.get(r[g-1].n)??[]),d=g;continue}}let p=u.n>f,m=u.tool,h=m.result===void 0?"(running)":m.isError?"ERROR: "+Pr(K_(m.result),160):Q_(m,p?120:60)||"ok";s.push(`[${u.n}] ${Va(m,p?160:80)} \u2192 ${h}`),s.push(...c.get(u.n)??[]),d++}return{brief:e,followups:n,steps:r,log:s.join(`
|
|
2085
|
-
`),facts:nR(r),...a,tests:Z_(r),lastAt:o}}function Z_(t){for(let e=t.length-1;e>=0;e--){let n=t[e].tool,r=pf(n);if(!r||!W_.test(r)||n.result===void 0)continue;let s=(ws(n.result).split(`
|
|
2086
|
-
`).filter(o=>/\b\d+\s+(passed|failed)\b/i.test(o)).at(-1)??"").trim().replace(/^tests?:?\s+/i,""),i=n.isError||/\b[1-9]\d*\s+failed\b/i.test(s)?"red":/\bpassed\b/i.test(s)?"green":"unknown";return{n:t[e].n,state:i,line:Pr(s,90),ms:Fw(n)}}}function eR(t,e,n){let r=t.flatMap(u=>u.tools),s=[],i=[],o;for(let u of t)if(u.role!=="fork"){if(u.role==="user"){o===void 0&&!u.agent?o=u.at:u.at&&i.push(u.at);continue}u.at&&s.push(u.at);for(let p of u.tools)p.at&&s.push(p.at),p.doneAt&&s.push(p.doneAt)}let a=o??e[0]?.tool.at??n,l=[];for(let u of i){let p=-1/0;for(let h of s)h<=u&&h>p&&(p=h);let m=r.some(h=>h.at!==void 0&&h.at<u&&(h.doneAt??1/0)>u);p>-1/0&&!m&&u-p>=J_&&l.push([p,u])}let c=u=>l.reduce((p,[m,h])=>p+Math.max(0,Math.min(u,h)-m),0),f=u=>Math.max(0,u-a-c(u)),d=[];e.forEach((u,p)=>{let m=e[p-1]?.tool,h=p===0?a:m?.doneAt??m?.at??a;d.push(Math.min(n,Math.max(d[p-1]??a,h)))}),e.forEach((u,p)=>{let m=d[p],h=d[p+1]??n,g=m,x=!0;for(let[O,C]of l){if(C<=m||O>=h)continue;let E=x&&p>0?e[p-1]:u;O>g&&E.parts.push({from:f(g),to:f(O)}),g=Math.max(g,C),x=!1}h>g&&u.parts.push({from:f(g),to:f(h)})});for(let u of e)u.wall=u.parts.reduce((p,m)=>p+m.to-m.from,0);return{span:f(n),idle:c(n),wakes:i.filter(u=>u>a&&u<n).map(f),toolMs:tR(e,n)}}function tR(t,e){let n=t.map(i=>i.tool).filter(i=>i.at!==void 0).sort((i,o)=>i.at-o.at),r=0,s=-1/0;for(let i of n){let o=i.doneAt??e;o>s&&(r+=o-Math.max(i.at,s),s=o)}return r}function nR(t){let e=[],n=t.filter(o=>o.tool.isError);n.length&&e.push(`${n.length} of ${t.length} steps failed.`);let r=new Map;for(let o of n){let a=Va(o.tool,60);r.set(a,[...r.get(a)??[],o.n])}for(let[o,a]of r)a.length>1&&e.push(`${o} failed ${a.length} times (steps ${a.join(", ")}).`);let s=t.slice(-20).filter(o=>o.tool.isError).length;s>=4&&e.push(`${s} of the last 20 steps failed.`);for(let o of t)if(o.wall>=q_){let a=Fw(o.tool),l=a!==void 0&&a<o.wall/2?`: the call ran ${Se(a)}, the rest was the model before it`:"";e.push(`Step ${o.n} (${Va(o.tool,60)}) took ${Se(o.wall)}${l}.`)}let i=t.reduce((o,a)=>o+a.wall,0);return i&&e.push(`${Se(i)} in all over ${t.length} steps.`),e.join(`
|
|
2087
|
-
`)}function Jw(t,e,n){let r=[t.brief,...t.followups].map(i=>e.get(i));if(r.some(i=>!i))return;let s={subtasks:r.flatMap(i=>i.subtasks),log:t.log,facts:t.facts,finished:n};return{key:rR(JSON.stringify(s)),payload:s,steps:t.steps.length,followups:t.followups.length}}function rR(t){let e=3735928559,n=1103547991;for(let r=0;r<t.length;r++){let s=t.charCodeAt(r);e=Math.imul(e^s,2654435761),n=Math.imul(n^s,1597334677)}return e=Math.imul(e^e>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(e^e>>>13,3266489909),(4294967296*(2097151&n)+(e>>>0)).toString(36)}function hf(t,e,n,r){let s=[],i=0;[t.brief,...t.followups].forEach((o,a)=>{let l=e.get(o);a>0&&s.push({kind:"group",request:l?.request??"",idx:a});for(let c of l?.subtasks??[]){i++;let f=t.brief+`
|
|
2088
|
-
`+c,d=n?.rows.find(p=>p.id===i);d?.status==="done"&&!r.has(f)&&r.set(f,d),d=r.get(f)??d;let u=d?.steps??[];s.push({kind:"row",num:i,title:c,status:d?.status??"",did:d?.did??"",note:d?.note??"",steps:u,cite:d?.evidence?.length?d.evidence:u,ms:0,spans:[]})}});for(let o of n?.offBrief??[])s.push({kind:"row",title:o.what,status:"off",did:"",note:o.note,steps:o.steps,cite:o.steps,ms:0,spans:[]});return sR(s,t),s}function sR(t,e){let n=t.filter(o=>o.kind==="row"),r=e.steps.map(o=>n.find(a=>V_(o.n,a.steps))),s=r.find(Boolean);if(!s)return;let i=s;for(let o=0;o<r.length;o++)r[o]=i=r[o]??i;e.steps.forEach((o,a)=>{let l=r[a];l.ms+=o.wall;for(let c of o.parts){let f=l.spans.at(-1);f&&Math.abs(f.to-c.from)<1e3?f.to=Math.max(f.to,c.to):l.spans.push({...c})}})}function Ww(t,e,n,r){let s=t.tests,i=e&&e.followups===t.followups.length,o=t.followups.length?n.get(t.followups.at(-1))?.request:void 0;return[["Now",i?e.data.now:o?`Working on the latest follow-up: ${o}`:r?"\u2026":""],["Tests",s?`${s.state}${s.line?`, ${s.line}`:""}${s.ms!==void 0?`, took ${Se(s.ms)}`:""} (step ${s.n})`:"",s?`tests-${s.state}`:void 0],["Time",t.span&&t.steps.length?`${Se(t.toolMs)} in tools, ${Se(Math.max(0,t.span-t.toolMs))} in the model${t.idle?`, ${Se(t.idle)} stopped`:""}`:""],["Needs a decision",i?e.data.decision:"","warn"]].filter(([,l])=>l)}function Kw(t,e){let n=new Map,r=o=>{let a=o.trim().replace(/^["']|["']$/g,"").replace(/\\/g,"/").replace(/^\/([a-zA-Z])\//,"$1:/"),l=ny(a,e).replace(/^\.\//,"");return!l||/^([a-zA-Z]:)?\//.test(l)?void 0:l},s=(o,a={})=>{let l=r(o);if(!l)return;let c=n.get(l)??{path:l};c.deleted=a.deleted,a.from&&(c.from=a.from),n.set(l,c)},i=(o,a)=>{let l=r(o),c=l?n.get(l):void 0;l&&n.delete(l),s(a,{from:c?.from??l})};for(let{tool:o}of t.steps){if(o.isError)continue;let a=o.input??{},l=!1;for(let[d,u]of Object.entries(a)){if(d==="command"||d==="cmd"||typeof u!="string"||!/^(---|\+\+\+) /m.test(u))continue;let p;for(let m of u.split(`
|
|
2089
|
-
`)){let h=/^(---|\+\+\+) (?:[ab]\/)?(.+?)\s*$/.exec(m);if(h?.[1]==="---"){p=h[2];continue}if(h?.[1]==="+++"){l=!0,h[2]==="/dev/null"?p&&p!=="/dev/null"&&s(p,{deleted:!0}):s(h[2]);continue}let g=/^\*\*\* Move to: (.+?)\s*$/.exec(m);g&&p&&i(p,g[1])}}let c=ge(a.file_path)??ge(a.filePath)??ge(a.path);!l&&c&&iR.some(d=>d in a)&&s(c);let f=pf(o);if(f)for(let d of oR(f))d.to?i(d.from,d.to):s(d.from,{deleted:!0})}return[...n.values()]}function oR(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(/\/+$/,"")}/${Ou(l)}`:a})}return e}function Hw(t){let{d:e}=t,n=t.working?`running, step ${e.steps.length}${lR(e,t.now)}`:`finished after ${e.steps.length} steps`,r=[`Sub-agent "${t.name}": ${n}, ${Se(e.span)} active${e.lastAt?`, as of ${G_(e.lastAt)}`:""}.`];r.push("",`Request: ${e.brief?t.plans.get(e.brief)?.request??"(not summarized yet)":X_}`);for(let s of t.lines){if(s.kind==="group"){r.push("",`Follow-up: ${s.request||"(not summarized yet)"}`);continue}let i=s.ms?` (${Se(s.ms)})`:"";r.push(`- ${s.title}: ${Y_(s.status||"pending")}.${s.did?` ${s.did}`:""}${i}`),s.note&&r.push(` Note: ${s.note}`)}t.edited.length&&r.push("","Edited:",...t.edited.map(aR)),t.facts.length&&r.push("");for(let[s,i]of t.facts)r.push(`${s}: ${i}`);return r.join(`
|
|
2090
|
-
`)}function lR(t,e){let n=[...t.steps].reverse().find(r=>r.tool.result===void 0&&r.tool.at);return n?`, waiting ${Se(e-n.tool.at)} on ${Va(n.tool,60)}`:t.lastAt?`, last activity ${Se(e-t.lastAt)} ago`:""}function zw(t){let e=t??{},n=r=>Array.isArray(r)?r.filter(Array.isArray).map(s=>[Number(s[0]),s[1]===void 0?void 0:Number(s[1])]).filter(s=>s[0]>0):[];return{now:String(e.now??""),decision:String(e.decision??""),rows:(Array.isArray(e.rows)?e.rows:[]).map(r=>({id:Number(r.id),status:String(r.status??""),did:String(r.did??""),note:String(r.note??""),steps:n(r.steps),evidence:n(r.evidence)})),offBrief:(Array.isArray(e.offBrief)?e.offBrief:[]).map(r=>({what:String(r.what??""),note:String(r.note??""),steps:n(r.steps)}))}}function Yw(t){let e=t;return{request:String(e?.request??""),subtasks:Array.isArray(e?.subtasks)?e.subtasks.map(n=>String(n).replace(/[.\s]+$/,"")):[]}}var U_,q_,J_,jw,W_,Pr,ni,K_,H_,z_,Va,pf,Fw,Y_,V_,G_,X_,iR,aR,Vw=S(()=>{"use strict";Po();U_=30,q_=3*6e4,J_=6e4,jw=new Set(["Read","Grep","Glob"]),W_=/\b(vitest|jest|pytest|mocha|playwright test|go test|cargo test|dotnet test|(?:npm|pnpm|yarn|bun)(?: run)? test)\b/,Pr=(t,e)=>(t=ws(t).replace(/\s+/g," ").trim(),t.length>e?t.slice(0,e)+"\u2026":t),ni=(t,e)=>t.length<=e?t:t.slice(0,e/2)+`
|
|
2091
|
-
[\u2026]
|
|
2092
|
-
`+t.slice(-e/2),K_=t=>t.split(`
|
|
2093
|
-
`).find(e=>e.trim())??"",H_=t=>t.split(`
|
|
2094
|
-
`).reverse().find(e=>e.trim())??"",z_=t=>t.replace(/^(\s*(cd\s+\S+|export\s+PATH=\S+)\s*(;|&&)\s*)+/,""),Va=(t,e)=>`${Cu(t.name)}: ${Pr(z_(Pu(t.input)),e)}`,pf=t=>ge(t.input?.command)??ge(t.input?.cmd),Fw=t=>t.at!==void 0&&t.doneAt!==void 0?t.doneAt-t.at:void 0,Y_=t=>t==="off"?"off brief":t.replace("_"," "),V_=(t,e)=>e.some(([n,r])=>t>=n&&t<=(r??n)),G_=t=>new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),X_="No readable brief on record, so no subtasks to judge.";iR=["content","diff","new_string","new_source","edits"];aR=t=>t.deleted?`${t.path} (deleted)`:t.from?`${t.path} (moved from ${t.from})`:t.path});import{readFileSync as cR,writeFileSync as uR,mkdirSync as dR}from"fs";import{join as Gw}from"path";import{createHash as fR}from"crypto";function Xw(t,e){if(!t.listChildren)return[];let n=t.callerSessionId?.(e),r=ti(t.listSessionFiles(e),i=>i.mtime).sort((i,o)=>+(o.sessionId===n)-+(i.sessionId===n)),s=[];for(let i of r){let o=t.listChildren(e,i.sessionId);if(!o.length)continue;let a=Ya(t,i.sessionId,e,i.file);s.push({sessionId:i.sessionId,children:o.map(l=>({...l,state:ei(l,a)}))})}return s}function Qw(t,e){let n=e.trim().toLowerCase();for(let r of t){let s=r.children.filter(o=>o.id.toLowerCase()===n);if(s.length)return s;let i=r.children.filter(o=>o.id.toLowerCase().startsWith(n)||Cn(o).toLowerCase().includes(n));if(i.length)return i}return[]}async function mf(t,e){let n=qw(Uw(Bw(t,e.file,"child"))),r=Gw(ze(),"cache","child-status",`${pR(e.file)}.json`),s={plans:{},frozen:{}};try{s={...s,...JSON.parse(cR(r,"utf8"))}}catch{}let i=new Map(Object.entries(s.plans)),o=new Map(Object.entries(s.frozen)),a,l=!1,c=m=>{a??=m.error,l||=!!m.setup},f=[n.brief,...n.followups].filter(m=>m&&!i.has(m));for(let[m,h]of await Promise.all(f.map(async g=>[g,await Zs("plan",g)])))h.ok?i.set(m,Yw(h.data)):c(h);let d=s.status,u=n.brief?Jw(n,i,e.state!=="running"):void 0,p=!!u&&d?.key!==u.key;if(u&&p){let m=await Zs("status",u.payload);m.ok?d={key:u.key,data:zw(m.data),steps:u.steps,followups:u.followups,at:Date.now()}:c(m)}hf(n,i,d?.data,o);try{dR(Gw(r,".."),{recursive:!0}),uR(r,JSON.stringify({plans:Object.fromEntries(i),frozen:Object.fromEntries(o),status:d}))}catch{}return{d:n,plans:i,frozen:o,judged:d,error:a,setup:l,cached:!f.length&&!p}}async function Zw(t,e,n){let{d:r,plans:s,frozen:i,judged:o,error:a}=await mf(t,n);return{text:Hw({d:r,lines:hf(r,s,o?.data,i),facts:Ww(r,o,s,!1),edited:Kw(r,e),plans:s,name:Cn(n),working:n.state==="running",now:Date.now()}),error:a}}var pR,gf=S(()=>{"use strict";Tn();uf();df();Qs();ff();Vw();pR=t=>fR("sha1").update(t).digest("hex")});import{existsSync as ev,openSync as hR,readSync as mR,closeSync as gR,statSync as ri,readdirSync as tv,watchFile as yR,unwatchFile as nv,mkdirSync as bR,writeFileSync as wR,readFileSync as yf,unlinkSync as vR,rmSync as SR}from"fs";import{stat as kR}from"fs/promises";import{dirname as xR,join as _n,resolve as rv}from"path";function OR(t){if(!Number.isInteger(t))return!0;try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}function Cr(t){let e={cwd:V,sessionId:"",sessionStartMs:Date.now(),buffer:[],partial:"",offset:0,latest:{in:0,out:0,cached:0,cacheCreate:0},latestModel:null,everAttached:!1,index:za(t),thread:"main"},n;function r(y,v){let w={offset:v,text:""},T;try{T=ri(y).size}catch{return w}if(T<=v)return w;let $;try{$=hR(y,"r")}catch{return w}try{let j=T-v,D=Buffer.alloc(j),H=0;for(;H<j;){let G=mR($,D,H,j-H,v+H);if(!G)break;H+=G}return{offset:v+H,text:D.subarray(0,H).toString("utf8")}}finally{gR($)}}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 v={d:t.createDriver(e.cwd,y),file:y,id:`new:${++o}`,startedAt:Date.now()};return s.add(v),e.file||(i=v),v}function c(){let y=[...s].filter(w=>w.file);if(!y.length)return[];let v=new Map(t.listSessionFiles(e.cwd).map(w=>[w.file,w.sessionId]));return y.map(w=>{let T=v.get(w.file);return{rec:w,sessionId:T??w.id,pending:T===void 0}})}let f=()=>c().filter(y=>y.pending&&y.rec.prompt!==void 0);async function d(y){s.delete(y),i===y&&(i=void 0);try{await y.d.dispose()}catch(v){console.error("[composer] dispose:",Y(v))}}function u(){let y=a(),v=new Set(f().map(w=>w.rec));for(let w of[...s])w!==y&&(v.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(v=>v.file===i.file);y&&Z(y)}i&&!e.file&&i.prompt!==void 0&&e.sessionId!==i.id&&(F(void 0,i.id),e.everAttached=!0)}let m=y=>_n(y,AR),h=(y,v)=>_n(m(y),`${v}.lock`);function g(y,v){try{let w=h(y,v);if(Date.now()-ri(w).mtimeMs>=sv)return!1;try{let T=parseInt(yf(w,"utf8").trim(),10);if(T===process.pid||!OR(T))return!1}catch{}return!0}catch{return!1}}function x(y,v){if(v)try{bR(m(y),{recursive:!0}),wR(h(y,v),String(process.pid))}catch(w){console.error("[lock] claim failed:",Y(w))}}function O(y){try{SR(_n(y,".claude-bulb"),{recursive:!0,force:!0})}catch{}}function C(y){let v=m(y);if(!ev(v))return;let w;try{w=tv(v)}catch{return}let T=Date.now();for(let $ of w){if(!$.endsWith(".lock"))continue;let j=_n(v,$);try{let D=ri(j);T-D.mtimeMs>TR&&vR(j)}catch{}}}function E(y){try{return ri(y),!1}catch(v){return v.code==="ENOENT"}}function R(){let y=e;if(y.file&&!E(y.file)){x(y.cwd,y.sessionId);return}let v=I(y);v&&Z(v)}function I(y){if(!y.everAttached)return L(y.cwd)??A(y.cwd,()=>!0)}function L(y){let v=m(y);if(!ev(v))return;let w;try{w=tv(v)}catch{return}let T;for(let j of w)if(j.endsWith(".lock"))try{let D=ri(_n(v,j));if(Date.now()-D.mtimeMs>=sv||parseInt(yf(_n(v,j),"utf8").trim(),10)!==process.pid)continue;(!T||D.mtimeMs>T.mtime)&&(T={sessionId:j.slice(0,-5),mtime:D.mtimeMs})}catch{}if(!T)return;let $=t.listSessionFiles(y).find(j=>j.sessionId===T.sessionId);if(!(!$||E($.file)))return $}function A(y,v){return t.listSessionFiles(y).sort((w,T)=>T.mtime-w.mtime).find(w=>!g(y,w.sessionId)&&v(w))}function F(y,v){let w=e;if(w.file)try{nv(w.file)}catch{}w.file=y,w.sessionId=v,w.partial="",w.offset=0,w.latest={in:0,out:0,cached:0,cacheCreate:0},w.latestModel=null,w.index=za(t),w.chainLastId=void 0,w.buffer.push({type:"cleared"}),w.buffer.push({type:"session",sessionId:v})}function Z(y){let v=e;i=void 0,wi(),n=y.file,F(y.file,y.sessionId),v.everAttached=!0,x(v.cwd,y.sessionId),te(y.file)}function te(y){if(ne(),!!y){try{nv(y)}catch{}yR(y,{interval:200},()=>ne())}}function U(){wi(),n=void 0,F(void 0,"")}function ne(){let y=e;if(!y.file)return;let v=r(y.file,y.offset);if(!v.text)return;y.offset=v.offset,y.partial+=v.text;let w=y.partial.lastIndexOf(`
|
|
2095
|
-
`);if(w<0)return;let T=y.index.add(y.partial.slice(0,w).split(`
|
|
2096
|
-
`),y.thread);if(y.partial=y.partial.slice(w+1),!T)return;let $=[],{entries:j}=y.index,D=j.get(T),H=!1;for(;D;){if($.push(D),t.idOf(D)===y.chainLastId){H=!0;break}let G=t.parentOf(D);D=G?j.get(G):void 0}if(H)for(let G=$.length-2;G>=0;G--)de($[G]);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 G=new Set($.map(le=>t.idOf(le))),ut=he(j);for(let le=$.length-1;le>=0;le--)de($[le]),Ie(t.idOf($[le]),ut,G)}y.chainLastId=T}function he(y){let v=new Map;for(let w of y.values()){let T=t.parentOf(w);if(!T)continue;let $=v.get(T);$?$.push(w):v.set(T,[w])}return v}function Ie(y,v,w){if(!y)return;let T=v.get(y);if(!T)return;let $=T.filter(G=>!t.isSidechain(G,e.thread));if($.length<2)return;let j=$.filter(G=>!w.has(t.idOf(G)));if(!j.length)return;let D=[],H=0;for(let G of j){let ut=ct(G,v);D.push(...ut.events),H+=ut.count}H>0&&e.buffer.push({type:"fork",atId:y,count:H,events:D})}function ct(y,v){let w=[],T=[y];for(;T.length;){let D=T.pop();if(t.isSidechain(D,e.thread))continue;w.push(D);let H=v.get(t.idOf(D)??"");if(H)for(let G of H)T.push(G)}w.sort((D,H)=>(Date.parse(t.timestampOf(D)??"")||0)-(Date.parse(t.timestampOf(H)??"")||0));let $=[];for(let D of w)t.isRecoveryNoise(D)||$.push(...Ha(t,D,e.thread,e.sessionStartMs).events);return{count:$.reduce((D,H)=>D+(H.type==="user"||H.type==="assistant"?1:0),0),events:$}}function de(y){if(!t.isSidechain(y,e.thread))try{let{events:v,usage:w,model:T,cost:$}=Ha(t,y,e.thread,e.sessionStartMs);for(let j of v)e.buffer.push(j);v.some(j=>j.type==="assistant")&&a()?.d.clearCompletedDraft(),v.some(j=>j.type==="user")&&a()?.d.clearEcho(),T&&(e.latestModel=T),w&&(e.latest=w),(w||$)&&e.buffer.push({type:"usage",...e.latest,cost:$})}catch(v){console.error("[mirror] skipped malformed entry:",Y(v))}}async function Ae(){return{cwd:e.cwd,pid:process.pid,composer:!!t.createDriver,children:!!t.listChildren,childStatus:!!t.listChildren&&t.childBriefs,elsewhere:await Tt()}}async function Tt(){if(t.listSessionFiles(e.cwd).length)return;let y=await Pn();if(!y)return;let v=rv(y).toLowerCase();for(let w=rv(e.cwd);w.toLowerCase()!==v;){let T=xR(w);if(T===w)return;w=T;let $=t.listSessionFiles(w).length;if($)return{dir:w,count:$}}}Tt().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 Ua;async function k(y,v){e.thread!=="child"&&b.accept(y,v)&&console.log(v)}function P(){return Ya(t,e.sessionId,e.cwd,e.file)}function N(){return t.chainWorking([...e.index.entries.values()])&&P()}function M(){!t.createDriver||a()||e.latestModel||N()||l(e.file)}async function W(y){let v=e;R(),p(),M(),u();let w=a();for(let D of s)D!==w&&D.d.dialog;let T=c().filter(D=>D.rec.d.streaming).map(D=>D.sessionId),$=N(),j=t.createDriver?{streaming:!!w?.d.streaming,foreign:!w&&$,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:v.buffer.slice(y),cursor:v.buffer.length,working:!!w?.d.streaming||$,latestModel:v.latestModel,child:v.child?.id??null,composer:j,busy:T}}async function q(){R(),p();let y=a();if(y?.d.error&&!y.d.streaming&&(await d(y),y=void 0),!y){if(N())return{ok:!1,error:"the agent is mid-turn in a terminal \u2014 watch only"};y=l(e.file)}let v=y;return{ok:!0,d:v.d,markSent:w=>{v.prompt===void 0&&(v.prompt=w)}}}async function qe(y,v){if(!t.createDriver)return{ok:!1,error:"not supported"};let w=String(y??"").trim();if(!w)return{ok:!1,error:"empty message"};let T=await q();if(!T.ok)return T;let $=await T.d.send(w,v);return $.ok&&T.markSent(w),$}async function z(y,v){let w=a();return w?w.d.respondUi(String(y??""),v??{}):{ok:!1,error:"no dialog pending"}}async function ae(y,v){if(!t.createDriver)return{ok:!1,error:"not supported"};if(!y||typeof y.type!="string")return{ok:!1,error:"bad command"};if(v?.spawn){let T=await q();return T.ok?T.d.rpc(y):T}let w=a();return!w||w.d.error?{ok:!1,error:"not running"}:w.d.rpc(y)}async function Te(){let y=a();if(y)try{await y.d.stop()}catch(v){console.error("[composer] stop:",Y(v))}return{ok:!0}}async function Mr(){return t.createDriver?(p(),!e.file&&i&&i.prompt===void 0&&!i.d.streaming&&!i.d.error?{ok:!0}:(i?.d.error&&await d(i),i=void 0,U(),l(void 0),u(),{ok:!0})):{ok:!1,error:"not supported"}}async function tn(){if(!t.createDriver)return[];let y=await et(["ls-files","--cached","--others","--exclude-standard"],e.cwd).catch(()=>null),v=y!==null?y.split(`
|
|
2097
|
-
`).filter(Boolean):await t.walkFiles?.(e.cwd)??[];return(await Promise.all(v.map(async T=>{try{return{f:T,m:(await kR(_n(e.cwd,T))).mtimeMs}}catch{return{f:T,m:0}}}))).sort((T,$)=>$.m-T.m).map(T=>T.f)}function Ot(){for(let y of[...s])d(y)}async function Al(y){return t.createDriver?_w(e.cwd,y):{ok:!1,error:"not supported"}}async function Tl(y){return Rw(e.cwd,String(y??""))}async function ik(y,v){return Dw(String(y??""),String(v??""))}async function ok(y,v){return Zs(y==="status"?"status":"plan",v)}async function ak(y){let v=t.listChildren?.(e.cwd,e.sessionId).find(T=>T.id===y);if(!v)return{ok:!1,error:"child not found"};let w=await mf(t,{...v,state:ei(v,P())});return{ok:!0,plans:Object.fromEntries(w.plans),frozen:Object.fromEntries(w.frozen),judged:w.judged,error:w.error,setup:w.setup,cached:w.cached}}async function lk(){let y=t.sessionsWorking?.(e.cwd),v=t.listSessionFiles(e.cwd).map(({sessionId:T,file:$,mtime:j})=>({sessionId:T,mtime:j,preview:t.readPreview($),working:y?.has(T)})),w=f().map(T=>({sessionId:T.sessionId,mtime:T.rec.startedAt,preview:T.rec.prompt??"",pending:!0}));return ti([...v,...w],T=>T.mtime)}let dp=new Map;function fp(y,v){let w=dp.get(y);if(w&&w.mtime===v)return w.turns;let T=[],$="";try{$=yf(y,"utf8")}catch{return[]}for(let j of $.split(`
|
|
2098
|
-
`)){if(!j.trim())continue;let D=t.parseEntry(j);if(!D)continue;let H=t.searchText(D);H&&T.push({text:H,lower:H.toLowerCase()})}return dp.set(y,{mtime:v,turns:T}),T}async function ck(y){let v=y.toLowerCase(),w=[],T=0,$=t.sessionsWorking?.(e.cwd);for(let{sessionId:j,file:D,mtime:H}of t.listSessionFiles(e.cwd).sort((G,ut)=>ut.mtime-G.mtime)){let G=Gs(fp(D,H),v),ut=(t.listChildren?.(e.cwd,j)??[]).map(le=>({c:le,hit:Gs(fp(le.file,le.mtime),v)})).filter(le=>le.hit.hitCount);if(!(!G.hitCount&&!ut.length)){for(let{c:le,hit:hk}of ti(ut,mk=>mk.c.mtime))w.push({sessionId:j,mtime:le.mtime,preview:Cn(le),...hk,child:{id:le.id,kind:le.kind,depth:le.depth}});if(w.push({sessionId:j,mtime:H,preview:t.readPreview(D),working:$?.has(j),...G}),++T>=PR)break}}return w}async function uk(y){let v=e,w=t.listSessionFiles(v.cwd).find(T=>T.sessionId===y);if(!w){let T=f().find($=>$.sessionId===y)?.rec;return T?((i!==T||v.sessionId!==T.id)&&(i=T,wi(),n=void 0,F(void 0,T.id),v.everAttached=!0,u()),{ok:!0}):{ok:!1,error:"session not found"}}return w.file===v.file?{ok:!0}:(Z(w),p(),u(),{ok:!0})}async function dk(){if(!t.listChildren||!e.sessionId)return[];let y=P();return t.listChildren(e.cwd,e.sessionId).map(v=>({...v,state:ei(v,y)}))}async function fk(y){let v=e;if(!t.listChildren)return{ok:!1,error:"this harness has no child transcripts"};let w=t.listChildren(v.cwd,v.sessionId).find(T=>T.id===y);return w?(v.thread="child",v.child=w,F(w.file,v.sessionId),te(w.file),{ok:!0}):{ok:!1,error:"child not found"}}async function pk(){let y=n;return!wi()||!y?{ok:!0}:(F(y,e.sessionId),te(y),{ok:!0})}function wi(){let y=e;return y.thread==="main"?!1:(y.thread="main",y.child=void 0,!0)}return O(e.cwd),C(e.cwd),R(),{info:Ae,poll:W,logInlineStatus:k,listSessions:lk,searchSessions:ck,attach:uk,listChildren:dk,openChild:fk,closeChild:pk,composerSend:qe,composerStop:Te,composerNew:Mr,composerFiles:tn,composerUiRespond:z,composerRpc:ae,composerPaste:Al,composerPasteRead:Tl,summarizeTurn:ik,childStatus:ok,judgeChildStatus:ak,shutdownComposer:Ot}}var ER,AR,sv,TR,PR,Ga=S(()=>{"use strict";Vt();Aw();Vs();sf();Iw();uf();df();gf();ff();Qs();ER=".typebulb",AR=`${ER}/locks`,sv=5e3,TR=6e4;PR=50});import{existsSync as Sf,mkdirSync as CR,readFileSync as iv,writeFileSync as _R}from"fs";import{join as Rn,isAbsolute as RR}from"path";async function xf(t,e){let n=RR(t)?t:Rn(V,t);return Sf(n)?(id(n,e),{ok:!0}):{ok:!1,error:"file not found"}}async function Ef(t){let e=V,n=sd(t),r=Rn(e,"typebulbs");CR(r,{recursive:!0});let s=ed(n),i=`${s}.bulb.md`;for(let c=2;Sf(Rn(r,i))&&iv(Rn(r,i),"utf8")!==n;c++)i=`${s}-${c}.bulb.md`;let o=Rn(r,i);Sf(o)||_R(o,n);let a=Rn("typebulbs",i),l=await Ts(a,{cwd:e,open:!1});return{ok:!0,file:a,pid:l.pid,url:l.url}}async function Af(){return X(V)}async function Tf(t){let e=(await X()).find(n=>n.pid===t);return e?{ok:!0,outcome:await Ft(e)}:(await nr(t),{ok:!0})}async function Of(){let t=await dn(V);return ea(V).filter(e=>!e.serverOnly).map(e=>({...e,trusted:yn(e.path),lastRunAt:t(e.path)}))}async function Pf(t){let e=t.toLowerCase(),n=[];for(let r of ea(V).filter(s=>!s.serverOnly).sort((s,i)=>i.mtime-s.mtime)){let s="";try{s=iv(r.path,"utf8")}catch{continue}let i=[];for(let l of s.split(`
|
|
2099
|
-
`)){let c=l.replace(/\s+/g," ").trim();c&&i.push({text:c,lower:c.toLowerCase()})}let{hitCount:o,snippet:a}=Gs(i,e);o&&n.push({path:r.path,hitCount:o,snippet:a})}return n}async function Cf(t,e){let n=V;e!=null&&lr(t,e);let r=await Ts(t,{cwd:n,open:!1,trust:e});return{ok:!0,file:r.file,pid:r.pid,url:r.url,trust:!!r.trust}}async function _f(t){return{cap:await nd(t)}}async function Rf(t,e){return lr(t,e),{ok:!0}}async function If(t,e){return Ve(t,e)}async function Nf(){return si&&Date.now()-si.fetchedAt<=NR?si.samples:(bf??=$R().finally(()=>{bf=null}),bf)}async function $R(){try{let t=await fetch(`${IR}/api/scripts/u/samples?stubs`,{signal:AbortSignal.timeout(av)});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:Ll(i.config)}));return si={samples:s,fetchedAt:Date.now()},s}catch{return si?.samples??[]}}async function $f(t){return kf.test(t)?cv(ov,"samples",t,!0):{ok:!1,error:"bad slug"}}async function Mf(){let t=Lf();if(!t)return{bulbs:[]};let e=`${Xa()}
|
|
2100
|
-
${t}`;return Gt?.key===e&&Date.now()-Gt.fetchedAt<=LR?{user:Gt.user,bulbs:Gt.bulbs}:(wf??=MR(e,t).finally(()=>{wf=null}),wf)}async function vf(t,e,n){let r=await fetch(`${t}${e}`,{headers:n,signal:AbortSignal.timeout(av)});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 MR(t,e){let n={Authorization:`Bearer ${e}`};try{let r=Xa(),s;try{s=await vf(r,"/api/me",n)}catch{let a=new URL(r);r=`${a.protocol}//api.${a.host}`,s=await vf(r,"/api/me",n)}let o=(await vf(r,"/api/scripts/list",n)).filter(a=>a.userSlug===s.slug&&!a.isTemplate).map(a=>({slug:a.slug,name:a.name,description:Ll(a.config)}));return Gt={key:t,user:s.slug,bulbs:o,fetchedAt:Date.now()},{user:s.slug,bulbs:o}}catch{return Gt?.key===t?{user:Gt.user,bulbs:Gt.bulbs}:{bulbs:[]}}}async function Df(t,e,n=!1){return!kf.test(e)||!kf.test(t)?{ok:!1,error:"bad slug"}:cv(Xa(),t,e,n)}async function cv(t,e,n,r){let s=Ia(e,n);try{let i=await La({origin:t,userSlug:e,slug:n,dest:Rn(V,s)},{force:r,token:Lf(),timeoutMs:lv});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 Bf(t,e=!1){let n=Lf();if(!n)return{ok:!1,error:"no TYPEBULB_TOKEN in .env"};try{let r=$a(t,V,Xa()),s=await Da(r,{token:n,force:e,timeoutMs:lv});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 IR,ov,NR,av,lv,si,bf,kf,LR,Gt,wf,Xa,Lf,Qa=S(()=>{"use strict";Tn();Vt();sf();Q();IR="https://api.typebulb.com",ov="https://typebulb.com",NR=3600*1e3,av=5e3,lv=15e3,si=null,bf=null;kf=/^[a-z0-9][a-z0-9-]*$/,LR=300*1e3,Gt=null,wf=null,Xa=()=>da("TYPEBULB_ORIGIN",V)||ov,Lf=()=>da("TYPEBULB_TOKEN",V)});import{readFileSync as Uf,writeFileSync as dv,mkdirSync as DR,appendFileSync as fv,rmSync as uv}from"fs";import{join as tl,dirname as BR}from"path";import{createServer as jR}from"http";function Xt(t){try{return JSON.parse(Uf(t,"utf8"))}catch{return null}}function el(t,e){DR(BR(t),{recursive:!0}),dv(t,JSON.stringify(e,null,2)+`
|
|
2101
|
-
`)}function hv(t,e,n){let r=tl(t,".gitignore"),s="";try{s=Uf(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(`
|
|
2043
|
+
`+t.slice(t.length-n)},B_={ok:!1,error:"Summary needs OPENROUTER_API_KEY or OPENAI_API_KEY in this project\u2019s .env.",setup:!0},j_={ok:!1,error:"the model call failed or timed out"}});import{readFileSync as F_,statSync as U_}from"fs";function za(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 Ya(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 Mw(t,e,n){let r=t.forRead(),s;try{s=F_(e,"utf8")}catch{return[]}let{entries:i,add:o}=Ya(r),a=o(s.split(`
|
|
2044
|
+
`),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(...za(r,f,n,d).events)}catch{}return u}function Va(t,e,n,r){let s=t.sessionAlive(e,n);if(s!==void 0)return s;if(!r)return!1;try{return Date.now()-U_(r).mtimeMs<1e4}catch{return!1}}function ei(t,e){return t.stopped?"stopped":t.running&&e?"running":"done"}var af=v(()=>{"use strict"});function q_(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 Dw(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 ti,lf=v(()=>{"use strict";ti=(t,e)=>q_(t,{key:e,desc:!0})});function Uw(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.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}),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,...W_(e,s,i,a,c)}}function W_(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>=J_&&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 K_(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&&!n?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,...H_(i)}}function H_(t){let e=ks(t).split(`
|
|
2045
|
+
`).map(n=>n.trim()).filter(Boolean);return/^exit(?: code)?:? \d+$/i.test(e[0]??"")&&e.shift(),{first:Rr(e[0]??"",120),last:e.length>1?Rr(e.at(-1),120):""}}function z_(t,e){let n=new Map;for(let s of t.calls){let i=uf(s),o=i&&K_(s,e);if(!o)continue;let a=Fw(i).trim();n.set(a,[...n.get(a)??[],o])}let r=[...n].map(([s,i])=>{let o=0;for(let a of i.filter(l=>!l.open).reverse()){if(!a.failed)break;o++}return{cmd:Rr(s,100),runs:i.length,failed:i.filter(a=>a.failed).length,streak:o,latest:i.at(-1)}}).sort((s,i)=>(i.latest.at??0)-(s.latest.at??0));return{runs:r.reduce((s,i)=>s+i.runs,0),failed:r.reduce((s,i)=>s+i.failed,0),groups:r}}function qw(t,e){let n=new Map,r=[],s=[],i=o=>{let a=o.trim().replace(/^["']|["']$/g,"").replace(/\\/g,"/").replace(/^\/([a-zA-Z])\//,"$1:/"),l=Qg(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=(y,k={})=>{let A=i(y);if(!A)return;let P=n.get(A)??{path:A};P.deleted=k.deleted,k.from&&(P.from=k.from),n.set(A,P),r.push({path:A,at:a})},c=(y,k)=>{let A=i(y),P=A?n.get(A):void 0;A&&(n.delete(A),r.push({path:A,at:a})),l(k,{from:P?.from??A})},u=o.input??{},d=!1;for(let[y,k]of Object.entries(u)){if(y==="command"||y==="cmd"||typeof k!="string"||!/^(---|\+\+\+) /m.test(k))continue;let A;for(let P of k.split(`
|
|
2046
|
+
`)){let E=/^(---|\+\+\+) (?:[ab]\/)?(.+?)\s*$/.exec(P);if(E?.[1]==="---"){A=E[2];continue}if(E?.[1]==="+++"){d=!0,E[2]==="/dev/null"?A&&A!=="/dev/null"&&l(A,{deleted:!0}):l(E[2]);continue}let R=/^\*\*\* Move to: (.+?)\s*$/.exec(P);R&&A&&c(A,R[1])}}let f=Z(u.file_path)??Z(u.filePath)??Z(u.path),p=Y_.some(y=>y in u);!d&&f&&p&&l(f);let h=Z(u.file_path)??Z(u.filePath);if(h&&!p&&!d){let y=i(h);y&&s.push({path:y,at:a})}let m=uf(o);if(m)for(let y of V_(m))y.to?c(y.from,y.to):l(y.from,{deleted:!0})}return{edited:[...n.values()],writes:r,reads:s}}function V_(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(/\/+$/,"")}/${Zg(l)}`:a})}return e}function Jw(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}]);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)=>{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}
|
|
2047
|
+
${a.id}
|
|
2048
|
+
${c.id}`,{path:s,by:a.id,over:c.id,at:a.at,overAt:c.at})})}return{writers:n,blind:[...r.values()]}}function Ww(t,e,n,r,s,i,o){let a=c=>`"${s.get(c)??c}"`,l=e.calls.filter(c=>!c.refused&&(c.result===void 0||c.background&&c.endAt===void 0)).map(c=>({id:c.id,label:Bw(c),short:Rr(Z(c.input?.description)??"",80)||Bw(c),at:c.at,background:!!c.background,interrupted:!i||t.liveSince!==void 0&&(c.at??0)<t.liveSince}));return{id:t.id,name:kt(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:l,commands:z_(e,o),files:n.map(c=>({...c,also:(r.writers.get(c.path)??[]).filter(u=>u.id!==t.id).map(u=>({name:s.get(u.id)??u.id,at:u.at})),blind:r.blind.filter(u=>u.path===c.path&&(u.by===t.id||u.over===t.id)).map(u=>u.by===t.id?`\u26A0 written at ${Cn(u.at)} over ${a(u.over)}'s ${Cn(u.overAt)} write without reading it`:`\u26A0 ${a(u.by)} wrote over this agent's ${Cn(u.overAt)} write at ${Cn(u.at)} without reading it`)})),handbacks:e.turnEnds}}function X_(t,e){let n=Xa(t).filter(s=>s.background);return`${t.state==="finished"&&n.length?`finished, background call running ${ke(e-(n[0].at??e))}${n.length>1?` (+${n.length-1} more)`:""}`:t.state} \xB7 ${ke(df(t,e))} active${t.idleMs?`, ${ke(t.idleMs)} idle`:""}`}function Z_(t,e){return t.open.length?t.open.length===1?[`Now: ${jw(t.open[0],e)}`]:["Now:",...t.open.map(n=>` ${jw(n,e)}`)]:[`Now: ${Q_(t,e)}`]}function eR(t,e){let n=t.latest;return`latest: ${n.open?`running ${ke(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 ${ke(n.ms)}`:""}`}${t.streak>=2?`, failed ${t.streak} in a row`:""}`}function Hw(t,e){let n=[`Sub-agent "${t.name}" (${t.id}): ${X_(t,e)}${t.asOf?` \xB7 as of ${Cn(t.asOf)}`:""}`,""];n.push(...Z_(t,e));let r=t.commands;n.push(`Commands: ${r.runs?`${r.runs} run, ${r.failed} failed`:"none"}`);for(let s of r.groups.slice(0,cf)){n.push(` ${s.cmd} \xD7${s.runs}${s.failed?`, ${s.failed} failed`:""}`,` ${eR(s,e)}`);let i=[s.latest.first,s.latest.last].filter(Boolean).map(o=>`"${o}"`).join(" \u2026 ");i&&n.push(` ${i}`)}r.groups.length>cf&&n.push(` +${r.groups.length-cf} older commands`),n.push(`Files: ${t.files.length?"":"none"}`.trimEnd());for(let s of t.files){let i=s.also.length?` also ${sR(s)}`:"";n.push(` ${iR(s)}${i}`,...s.blind.map(o=>` ${o}`))}return n.push(`Hand-backs: ${tR(t)}`),t.activeMs&&n.push(`Time: ${rR(t,e)}`),n.join(`
|
|
2049
|
+
`)}function nR(t,e){let n=t.toolMs+(Xa(t).some(r=>!r.background)?Kw(t,e):0);return{tools:n,model:Math.max(0,df(t,e)-n)}}function zw(t,e,n,r){let s=e.filter(Ga).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 ${ke(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=>Ga(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=Xa(u)[0],f=d?u.state==="finished"&&d.background?`background call running ${ke(r-(d.at??r))}: ${d.short}`:`waiting ${ke(r-(d.at??r))} on ${d.short}`:"",p=G_(u),h=[f,p>=2?`failed ${p} in a row`:"",n.some(y=>y.blind.includes(u.id))?"\u26A0":""].filter(Boolean),m=u.parentId&&l.has(u.parentId)?" ".repeat(Math.max(0,u.depth-1)):"";o.push(` ${m}${u.id} ${u.state.padEnd(8)} ${`${ke(df(u,r))} active`.padStart(10)} ${u.name}${h.length?` \xB7 ${h.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."),o.join(`
|
|
2050
|
+
`)}var J_,cf,Rr,Fw,uf,Cn,Bw,Y_,Xa,Ga,G_,Kw,df,jw,Q_,tR,rR,sR,iR,ff=v(()=>{"use strict";_r();Po();J_=6e4,cf=5,Rr=(t,e)=>(t=ks(t).replace(/\s+/g," ").trim(),t.length>e?t.slice(0,e)+"\u2026":t),Fw=t=>t.replace(/^(\s*(cd\s+\S+|export\s+PATH=\S+)\s*(;|&&)\s*)+/,""),uf=t=>Z(t.input?.command)??Z(t.input?.cmd),Cn=t=>new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),Bw=t=>{let e=uf(t);if(e)return Rr(Fw(e),100);let n=Rr(ey(t.input),80);return n?`${_u(t.name)}: ${n}`:_u(t.name)};Y_=["content","diff","new_string","new_source","edits"];Xa=t=>t.open.filter(e=>!e.interrupted),Ga=t=>t.state==="running"||Xa(t).length>0,G_=t=>Math.max(0,...t.commands.groups.map(e=>e.streak)),Kw=(t,e)=>t.state==="running"?Math.max(0,e-t.asOf):0,df=(t,e)=>t.activeMs+Kw(t,e);jw=(t,e)=>t.interrupted?`${t.label}: interrupted, its process has ended`:`${t.label}, ${ke(e-(t.at??e))}${t.background?" (background)":""}`,Q_=(t,e)=>`nothing open, last entry ${ke(e-t.asOf)} ago`;tR=t=>t.handbacks.length?t.handbacks.map(Cn).join(", "):"not yet";rR=(t,e)=>{let n=nR(t,e);return`${ke(n.tools)} in tools, ${ke(n.model)} in the model`},sR=t=>t.also.map(e=>`"${e.name}" ${Cn(e.at)}`).join(", "),iR=t=>t.deleted?`${t.path} (deleted)`:t.from?`${t.path} (moved from ${t.from})`:t.path});import{openSync as oR,readSync as aR,closeSync as lR,fstatSync as cR,statSync as uR}from"fs";function*Gw(t,e){if(!t.listChildren)return;let n=t.callerSessionId?.(e),r=ti(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);if(!i.length)continue;let o=Va(t,s.sessionId,e,s.file);yield{sessionId:s.sessionId,live:o,children:i.map(a=>({...a,state:ei(a,o)}))}}}function Xw(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)||kt(s).toLowerCase().includes(n))}function Vw(t,e){let n={size:-1,mtimeMs:-1};try{n=uR(e)}catch{}let r=Yw.get(e);if(r&&r.size===n.size&&r.mtime===n.mtimeMs)return r.d;let s=Uw(Mw(t,e,"child"));return Yw.set(e,{size:n.size,mtime:n.mtimeMs,d:s}),s}function dR(t){let e;try{e=oR(t,"r")}catch{return}try{let n=cR(e).size,r=(s,i)=>{let o=Buffer.alloc(i);return o.subarray(0,aR(e,o,0,i,s)).toString("utf8")};return n<=2*Qa?r(0,n):`${r(0,Qa)}
|
|
2051
|
+
${r(n-Qa,Qa)}`}catch{return}finally{lR(e)}}function ni(t,e,n){let r=Dw([...n.children].sort((l,c)=>(l.started??l.mtime)-(c.started??c.mtime))),s=r.map(l=>qw(Vw(t,l.file),e)),i=Jw(r.map((l,c)=>({id:l.id,writes:s[c].writes,reads:s[c].reads}))),o=new Map(r.map(l=>[l.id,kt(l)]));return{reports:r.map((l,c)=>({...Ww(l,Vw(t,l.file),s[c].edited,i,o,n.live,dR),depth:l.depth,parentId:l.parentId})),shared:i}}async function Qw(t,e,n){let r=await pR(t),s=c=>process.platform==="win32"?c.toLowerCase():c,i=new Set(e.filter(Ga).map(c=>c.id)),o=new Map(e.map(c=>[c.id,c.name])),a=[...n.writers].filter(([c])=>!r||r.has(s(c)));return(await Promise.all(a.map(async([c,u])=>{let d=r?await fR(t,c):0,f=u.filter(h=>h.at>d);if(f.length<2&&!f.some(h=>i.has(h.id)))return;let p=n.blind.filter(h=>h.path===c&&h.overAt>d).flatMap(h=>[h.by,h.over]);return{path:c,writers:f.map(h=>({id:h.id,name:o.get(h.id)??h.id,running:i.has(h.id)})),blind:[...new Set(p)]}}))).filter(c=>!!c).sort((c,u)=>c.path.localeCompare(u.path))}async function fR(t,e){try{return Number((await be(["log","-1","--format=%ct","--",e],t)).trim())*1e3||0}catch{return 0}}async function pR(t){try{let e=(await be(["rev-parse","--show-prefix"],t)).trim(),n=await be(["status","--porcelain","-z","--untracked-files=all"],t),r=o=>process.platform==="win32"?o.toLowerCase():o,s=new Set,i=n.split("\0");for(let o=0;o<i.length;o++){let a=i[o];if(a.length<4)continue;(a[0]==="R"||a[0]==="C")&&o++;let l=a.slice(3);l.startsWith(e)&&s.add(r(l.slice(e.length)))}return s}catch{return null}}var Yw,Qa,pf=v(()=>{"use strict";Cr();af();_r();lf();ff();Yw=new Map;Qa=4096});import{existsSync as Zw,openSync as hR,readSync as mR,closeSync as gR,statSync as ri,readdirSync as ev,watchFile as yR,unwatchFile as tv,mkdirSync as bR,writeFileSync as wR,readFileSync as hf,unlinkSync as vR,rmSync as SR}from"fs";import{stat as kR}from"fs/promises";import{dirname as xR,join as _n,resolve as nv}from"path";function OR(t){if(!Number.isInteger(t))return!0;try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}function Ir(t){let e={cwd:V,sessionId:"",sessionStartMs:Date.now(),buffer:[],partial:"",offset:0,latest:{in:0,out:0,cached:0,cacheCreate:0},latestModel:null,everAttached:!1,index:Ya(t),thread:"main"},n;function r(g,S){let w={offset:S,text:""},O;try{O=ri(g).size}catch{return w}if(O<=S)return w;let $;try{$=hR(g,"r")}catch{return w}try{let D=O-S,B=Buffer.alloc(D),H=0;for(;H<D;){let G=mR($,B,H,D-H,S+H);if(!G)break;H+=G}return{offset:S+H,text:B.subarray(0,H).toString("utf8")}}finally{gR($)}}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 O=S.get(w.file);return{rec:w,sessionId:O??w.id,pending:O===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:",Y(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&&ee(g)}i&&!e.file&&i.prompt!==void 0&&e.sessionId!==i.id&&(F(void 0,i.id),e.everAttached=!0)}let h=g=>_n(g,AR),m=(g,S)=>_n(h(g),`${S}.lock`);function y(g,S){try{let w=m(g,S);if(Date.now()-ri(w).mtimeMs>=rv)return!1;try{let O=parseInt(hf(w,"utf8").trim(),10);if(O===process.pid||!OR(O))return!1}catch{}return!0}catch{return!1}}function k(g,S){if(S)try{bR(h(g),{recursive:!0}),wR(m(g,S),String(process.pid))}catch(w){console.error("[lock] claim failed:",Y(w))}}function A(g){try{SR(_n(g,".claude-bulb"),{recursive:!0,force:!0})}catch{}}function P(g){let S=h(g);if(!Zw(S))return;let w;try{w=ev(S)}catch{return}let O=Date.now();for(let $ of w){if(!$.endsWith(".lock"))continue;let D=_n(S,$);try{let B=ri(D);O-B.mtimeMs>TR&&vR(D)}catch{}}}function E(g){try{return ri(g),!1}catch(S){return S.code==="ENOENT"}}function R(){let g=e;if(g.file&&!E(g.file)){k(g.cwd,g.sessionId);return}let S=I(g);S&&ee(S)}function I(g){if(!g.everAttached)return L(g.cwd)??T(g.cwd,()=>!0)}function L(g){let S=h(g);if(!Zw(S))return;let w;try{w=ev(S)}catch{return}let O;for(let D of w)if(D.endsWith(".lock"))try{let B=ri(_n(S,D));if(Date.now()-B.mtimeMs>=rv||parseInt(hf(_n(S,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 $=t.listSessionFiles(g).find(D=>D.sessionId===O.sessionId);if(!(!$||E($.file)))return $}function T(g,S){return t.listSessionFiles(g).sort((w,O)=>O.mtime-w.mtime).find(w=>!y(g,w.sessionId)&&S(w))}function F(g,S){let w=e;if(w.file)try{tv(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=Ya(t),w.chainLastId=void 0,w.buffer.push({type:"cleared"}),w.buffer.push({type:"session",sessionId:S})}function ee(g){let S=e;i=void 0,wi(),n=g.file,F(g.file,g.sessionId),S.everAttached=!0,k(S.cwd,g.sessionId),ne(g.file)}function ne(g){if(re(),!!g){try{tv(g)}catch{}yR(g,{interval:200},()=>re())}}function U(){wi(),n=void 0,F(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(`
|
|
2052
|
+
`);if(w<0)return;let O=g.index.add(g.partial.slice(0,w).split(`
|
|
2053
|
+
`),g.thread);if(g.partial=g.partial.slice(w+1),!O)return;let $=[],{entries:D}=g.index,B=D.get(O),H=!1;for(;B;){if($.push(B),t.idOf(B)===g.chainLastId){H=!0;break}let G=t.parentOf(B);B=G?D.get(G):void 0}if(H)for(let G=$.length-2;G>=0;G--)fe($[G]);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 G=new Set($.map(ce=>t.idOf(ce))),ct=me(D);for(let ce=$.length-1;ce>=0;ce--)fe($[ce]),Ne(t.idOf($[ce]),ct,G)}g.chainLastId=O}function me(g){let S=new Map;for(let w of g.values()){let O=t.parentOf(w);if(!O)continue;let $=S.get(O);$?$.push(w):S.set(O,[w])}return S}function Ne(g,S,w){if(!g)return;let O=S.get(g);if(!O)return;let $=O.filter(G=>!t.isSidechain(G,e.thread));if($.length<2)return;let D=$.filter(G=>!w.has(t.idOf(G)));if(!D.length)return;let B=[],H=0;for(let G of D){let ct=lt(G,S);B.push(...ct.events),H+=ct.count}H>0&&e.buffer.push({type:"fork",atId:g,count:H,events:B})}function lt(g,S){let w=[],O=[g];for(;O.length;){let B=O.pop();if(t.isSidechain(B,e.thread))continue;w.push(B);let H=S.get(t.idOf(B)??"");if(H)for(let G of H)O.push(G)}w.sort((B,H)=>(Date.parse(t.timestampOf(B)??"")||0)-(Date.parse(t.timestampOf(H)??"")||0));let $=[];for(let B of w)t.isRecoveryNoise(B)||$.push(...za(t,B,e.thread,e.sessionStartMs).events);return{count:$.reduce((B,H)=>B+(H.type==="user"||H.type==="assistant"?1:0),0),events:$}}function fe(g){if(!t.isSidechain(g,e.thread))try{let{events:S,usage:w,model:O,cost:$}=za(t,g,e.thread,e.sessionStartMs);for(let D of S)e.buffer.push(D);S.some(D=>D.type==="assistant")&&a()?.d.clearCompletedDraft(),S.some(D=>D.type==="user")&&a()?.d.clearEcho(),O&&(e.latestModel=O),w&&(e.latest=w),(w||$)&&e.buffer.push({type:"usage",...e.latest,cost:$})}catch(S){console.error("[mirror] skipped malformed entry:",Y(S))}}async function Te(){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 Pn();if(!g)return;let S=nv(g).toLowerCase();for(let w=nv(e.cwd);w.toLowerCase()!==S;){let O=xR(w);if(O===w)return;w=O;let $=t.listSessionFiles(w).length;if($)return{dir:w,count:$}}}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 Ua;async function x(g,S){e.thread!=="child"&&b.accept(g,S)&&console.log(S)}function C(){return Va(t,e.sessionId,e.cwd,e.file)}function N(){return t.chainWorking([...e.index.entries.values()])&&C()}function M(){!t.createDriver||a()||e.latestModel||N()||l(e.file)}async function W(g){let S=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&&$,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||$,latestModel:S.latestModel,child:S.child?.id??null,composer:D,busy:O}}async function q(){R(),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 Je(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 O=await q();if(!O.ok)return O;let $=await O.d.send(w,S);return $.ok&&O.markSent(w),$}async function z(g,S){let w=a();return w?w.d.respondUi(String(g??""),S??{}):{ok:!1,error:"no dialog pending"}}async function le(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 O=await q();return O.ok?O.d.rpc(g):O}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:",Y(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 nn(){if(!t.createDriver)return[];let g=await be(["ls-files","--cached","--others","--exclude-standard"],e.cwd).catch(()=>null),S=g!==null?g.split(`
|
|
2054
|
+
`).filter(Boolean):await t.walkFiles?.(e.cwd)??[];return(await Promise.all(S.map(async O=>{try{return{f:O,m:(await kR(_n(e.cwd,O))).mtimeMs}}catch{return{f:O,m:0}}}))).sort((O,$)=>$.m-O.m).map(O=>O.f)}function Pt(){for(let g of[...s])d(g)}async function Pl(g){return t.createDriver?Cw(e.cwd,g):{ok:!1,error:"not supported"}}async function Cl(g){return _w(e.cwd,String(g??""))}async function rk(g,S){return $w(String(g??""),String(S??""))}async function sk(g){let S=t.listChildren?.(e.cwd,e.sessionId)??[],w=C(),{reports:O}=ni(t,e.cwd,{sessionId:e.sessionId,live:w,children:S.map(D=>({...D,state:ei(D,w)}))}),$=O.find(D=>D.id===g);return $?{ok:!0,report:$}:{ok:!1,error:"child not found"}}async function ik(){let g=t.sessionsWorking?.(e.cwd),S=t.listSessionFiles(e.cwd).map(({sessionId:O,file:$,mtime:D})=>({sessionId:O,mtime:D,preview:t.readPreview($),working:g?.has(O)})),w=u().map(O=>({sessionId:O.sessionId,mtime:O.rec.startedAt,preview:O.rec.prompt??"",pending:!0}));return ti([...S,...w],O=>O.mtime)}let lp=new Map;function cp(g,S){let w=lp.get(g);if(w&&w.mtime===S)return w.turns;let O=[],$="";try{$=hf(g,"utf8")}catch{return[]}for(let D of $.split(`
|
|
2055
|
+
`)){if(!D.trim())continue;let B=t.parseEntry(D);if(!B)continue;let H=t.searchText(B);H&&O.push({text:H,lower:H.toLowerCase()})}return lp.set(g,{mtime:S,turns:O}),O}async function ok(g){let S=g.toLowerCase(),w=[],O=0,$=t.sessionsWorking?.(e.cwd);for(let{sessionId:D,file:B,mtime:H}of t.listSessionFiles(e.cwd).sort((G,ct)=>ct.mtime-G.mtime)){let G=Zs(cp(B,H),S),ct=(t.listChildren?.(e.cwd,D)??[]).map(ce=>({c:ce,hit:Zs(cp(ce.file,ce.mtime),S)})).filter(ce=>ce.hit.hitCount);if(!(!G.hitCount&&!ct.length)){for(let{c:ce,hit:dk}of ti(ct,fk=>fk.c.mtime))w.push({sessionId:D,mtime:ce.mtime,preview:kt(ce),...dk,child:{id:ce.id,kind:ce.kind,depth:ce.depth}});if(w.push({sessionId:D,mtime:H,preview:t.readPreview(B),working:$?.has(D),...G}),++O>=PR)break}}return w}async function ak(g){let S=e,w=t.listSessionFiles(S.cwd).find(O=>O.sessionId===g);if(!w){let O=u().find($=>$.sessionId===g)?.rec;return O?((i!==O||S.sessionId!==O.id)&&(i=O,wi(),n=void 0,F(void 0,O.id),S.everAttached=!0,f()),{ok:!0}):{ok:!1,error:"session not found"}}return w.file===S.file?{ok:!0}:(ee(w),p(),f(),{ok:!0})}async function lk(){if(!t.listChildren||!e.sessionId)return[];let g=C();return t.listChildren(e.cwd,e.sessionId).map(S=>({...S,state:ei(S,g)}))}async function ck(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(O=>O.id===g);return w?(S.thread="child",S.child=w,F(w.file,S.sessionId),ne(w.file),{ok:!0}):{ok:!1,error:"child not found"}}async function uk(){let g=n;return!wi()||!g?{ok:!0}:(F(g,e.sessionId),ne(g),{ok:!0})}function wi(){let g=e;return g.thread==="main"?!1:(g.thread="main",g.child=void 0,!0)}return A(e.cwd),P(e.cwd),R(),{info:Te,poll:W,logInlineStatus:x,listSessions:ik,searchSessions:ok,attach:ak,listChildren:lk,openChild:ck,closeChild:uk,composerSend:Je,composerStop:Oe,composerNew:jr,composerFiles:nn,composerUiRespond:z,composerRpc:le,composerPaste:Pl,composerPasteRead:Cl,summarizeTurn:rk,childStatus:sk,shutdownComposer:Pt}}var ER,AR,rv,TR,PR,Za=v(()=>{"use strict";Gt();xw();Cr();sf();Rw();Lw();af();pf();lf();_r();ER=".typebulb",AR=`${ER}/locks`,rv=5e3,TR=6e4;PR=50});import{existsSync as bf,mkdirSync as CR,readFileSync as sv,writeFileSync as _R}from"fs";import{join as Rn,isAbsolute as RR}from"path";async function vf(t,e){let n=RR(t)?t:Rn(V,t);return bf(n)?(id(n,e),{ok:!0}):{ok:!1,error:"file not found"}}async function Sf(t){let e=V,n=sd(t),r=Rn(e,"typebulbs");CR(r,{recursive:!0});let s=ed(n),i=`${s}.bulb.md`;for(let c=2;bf(Rn(r,i))&&sv(Rn(r,i),"utf8")!==n;c++)i=`${s}-${c}.bulb.md`;let o=Rn(r,i);bf(o)||_R(o,n);let a=Rn("typebulbs",i),l=await _s(a,{cwd:e,open:!1});return{ok:!0,file:a,pid:l.pid,url:l.url}}async function kf(){return X(V)}async function xf(t){let e=(await X()).find(n=>n.pid===t);return e?{ok:!0,outcome:await Ut(e)}:(await nr(t),{ok:!0})}async function Ef(){let t=await fn(V);return ea(V).filter(e=>!e.serverOnly).map(e=>({...e,trusted:bn(e.path),lastRunAt:t(e.path)}))}async function Af(t){let e=t.toLowerCase(),n=[];for(let r of ea(V).filter(s=>!s.serverOnly).sort((s,i)=>i.mtime-s.mtime)){let s="";try{s=sv(r.path,"utf8")}catch{continue}let i=[];for(let l of s.split(`
|
|
2056
|
+
`)){let c=l.replace(/\s+/g," ").trim();c&&i.push({text:c,lower:c.toLowerCase()})}let{hitCount:o,snippet:a}=Zs(i,e);o&&n.push({path:r.path,hitCount:o,snippet:a})}return n}async function Tf(t,e){let n=V;e!=null&&lr(t,e);let r=await _s(t,{cwd:n,open:!1,trust:e});return{ok:!0,file:r.file,pid:r.pid,url:r.url,trust:!!r.trust}}async function Of(t){return{cap:await nd(t)}}async function Pf(t,e){return lr(t,e),{ok:!0}}async function Cf(t,e){return Ve(t,e)}async function _f(){return si&&Date.now()-si.fetchedAt<=NR?si.samples:(mf??=$R().finally(()=>{mf=null}),mf)}async function $R(){try{let t=await fetch(`${IR}/api/scripts/u/samples?stubs`,{signal:AbortSignal.timeout(ov)});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:Bl(i.config)}));return si={samples:s,fetchedAt:Date.now()},s}catch{return si?.samples??[]}}async function Rf(t){return wf.test(t)?lv(iv,"samples",t,!0):{ok:!1,error:"bad slug"}}async function Nf(){let t=If();if(!t)return{bulbs:[]};let e=`${el()}
|
|
2057
|
+
${t}`;return Xt?.key===e&&Date.now()-Xt.fetchedAt<=LR?{user:Xt.user,bulbs:Xt.bulbs}:(gf??=MR(e,t).finally(()=>{gf=null}),gf)}async function yf(t,e,n){let r=await fetch(`${t}${e}`,{headers:n,signal:AbortSignal.timeout(ov)});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 MR(t,e){let n={Authorization:`Bearer ${e}`};try{let r=el(),s;try{s=await yf(r,"/api/me",n)}catch{let a=new URL(r);r=`${a.protocol}//api.${a.host}`,s=await yf(r,"/api/me",n)}let o=(await yf(r,"/api/scripts/list",n)).filter(a=>a.userSlug===s.slug&&!a.isTemplate).map(a=>({slug:a.slug,name:a.name,description:Bl(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 $f(t,e,n=!1){return!wf.test(e)||!wf.test(t)?{ok:!1,error:"bad slug"}:lv(el(),t,e,n)}async function lv(t,e,n,r){let s=Ia(e,n);try{let i=await La({origin:t,userSlug:e,slug:n,dest:Rn(V,s)},{force:r,token:If(),timeoutMs:av});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 Lf(t,e=!1){let n=If();if(!n)return{ok:!1,error:"no TYPEBULB_TOKEN in .env"};try{let r=$a(t,V,el()),s=await Da(r,{token:n,force:e,timeoutMs:av});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 IR,iv,NR,ov,av,si,mf,wf,LR,Xt,gf,el,If,tl=v(()=>{"use strict";Tr();Gt();sf();Q();IR="https://api.typebulb.com",iv="https://typebulb.com",NR=3600*1e3,ov=5e3,av=15e3,si=null,mf=null;wf=/^[a-z0-9][a-z0-9-]*$/,LR=300*1e3,Xt=null,gf=null,el=()=>da("TYPEBULB_ORIGIN",V)||iv,If=()=>da("TYPEBULB_TOKEN",V)});import{readFileSync as Bf,writeFileSync as uv,mkdirSync as DR,appendFileSync as dv,rmSync as cv}from"fs";import{join as sl,dirname as BR}from"path";import{createServer as jR}from"http";function Qt(t){try{return JSON.parse(Bf(t,"utf8"))}catch{return null}}function rl(t,e){DR(BR(t),{recursive:!0}),uv(t,JSON.stringify(e,null,2)+`
|
|
2058
|
+
`)}function pv(t,e,n){let r=sl(t,".gitignore"),s="";try{s=Bf(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(`
|
|
2102
2059
|
`)?`
|
|
2103
|
-
`:"";try{
|
|
2060
|
+
`:"";try{dv(r,a+n+`
|
|
2104
2061
|
`+o.join(`
|
|
2105
2062
|
`)+`
|
|
2106
|
-
`)}catch(l){console.error("[switcher] .gitignore update failed",Y(l))}}function WR(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?ai="live":s>JR&&(ai="uncached")}function
|
|
2063
|
+
`)}catch(l){console.error("[switcher] .gitignore update failed",Y(l))}}function WR(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?ai="live":s>JR&&(ai="uncached")}function mv(t,e){let n={"content-type":"application/json",authorization:`Bearer ${e}`,"anthropic-version":t.headers["anthropic-version"]||"2023-06-01",...fd},r=t.headers["anthropic-beta"];return typeof r=="string"&&(n["anthropic-beta"]=r),n}function KR(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 gv(t){let e;try{e=JSON.parse(t)}catch{return t}oi=typeof e?.model=="string"?e.model:null,at&&(e.model=at),Nn&&(e.provider=hv(Nn));let n=/haiku/i.test(oi||"");return li!=null&&!n&&(e.reasoning={effort:Mf[li]}),delete e.thinking,e.output_config&&delete e.output_config.effort,KR(e),JSON.stringify(e)}function HR(){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}
|
|
2107
2064
|
data: ${JSON.stringify(a)}
|
|
2108
2065
|
|
|
2109
2066
|
`}case"content_block_delta":case"content_block_stop":{let l=n.get(a.index);return l==null?null:(a.index=l,`event: ${a.type}
|
|
@@ -2111,11 +2068,11 @@ data: ${JSON.stringify(a)}
|
|
|
2111
2068
|
|
|
2112
2069
|
`)}default:return i}};return i=>{t+=i;let o="",a;for(;(a=t.indexOf(`
|
|
2113
2070
|
|
|
2114
|
-
`))!==-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 zR(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 ii(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 YR(t,e,n){if(!
|
|
2071
|
+
`))!==-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 zR(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 ii(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 YR(t,e,n){if(!at){ii(e,400,"invalid_request_error",qR);return}let r=process.env.OPENROUTER_API_KEY;if(!r){ii(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(jf,{method:"POST",headers:mv(t,r),body:gv(n),signal:s.signal})}catch(d){ii(e,502,"api_error",`proxy upstream failed: ${Y(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?HR():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});WR(p);let h=u(p);h&&e.write(h)}else e.write(Buffer.from(f))}}catch{}finally{e.writableEnded||e.end()}}async function VR(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(!at||!r)return s();try{let i=await fetch(`${jf}/count_tokens`,{method:"POST",headers:mv(t,r),body:gv(n)});if(!i.ok)return s();let o=await i.text();e.writeHead(200,{"content-type":"application/json"}),e.end(o)}catch{s()}}function GR(t,e){let n=t.url||"/";if(t.method==="HEAD"){e.writeHead(200),e.end();return}if(t.method!=="POST"){ii(e,404,"not_found_error",n);return}zR(t).then(r=>{if(n.includes("count_tokens"))return VR(t,e,r);if(n.includes("/v1/messages"))return YR(t,e,r);ii(e,404,"not_found_error",n)})}function XR(){return Nr&&In?Promise.resolve(In):new Promise((t,e)=>{let n=jR(GR);n.on("error",e),n.listen(0,"127.0.0.1",()=>{Nr=n,In=n.address().port,console.log(`[switcher] wire proxy listening on ${nl(In)}`),t(In)})})}function QR(){try{Nr?.close()}catch{}Nr=null,In=null}function ZR(t,e){let n=il(t),r=Qt(n),s=r||{};if((!s.env||typeof s.env!="object")&&(s.env={}),s.env.ANTHROPIC_BASE_URL===nl(e)&&s.env.ANTHROPIC_AUTH_TOKEN)return;let i=ol(t);if(!Qt(i)){let a={};for(let l of fv)a[l]=l in s.env?s.env[l]:null;rl(i,{managedBy:"agent-switcher",fileExisted:r!==null,snapshot:a,active:null})}s.env.ANTHROPIC_BASE_URL=nl(e),s.env.ANTHROPIC_AUTH_TOKEN=UR,rl(n,s),pv(t,[".claude/settings.local.json",".claude/.cc-switcher.json"],"# agent switcher (local Claude Code model override)")}function eI(t,e,n){let r=ol(t),s=Qt(r)||{managedBy:"agent-switcher",fileExisted:!1,snapshot:{}};s.active={model:e,provider:n},rl(r,s)}function yv(t){let e=il(t),n=ol(t),r=Qt(n),s=Qt(e);if(s?.env){let i=r?.snapshot||{};for(let o of fv){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{cv(e,{force:!0})}catch{}else rl(e,s)}try{cv(n,{force:!0})}catch{}}async function tI(){let t=!!process.env.OPENROUTER_API_KEY,e=[];try{e=(await mt()).filter(r=>r.provider==="openrouter"&&!Ff(r.name)).map(r=>({id:r.name,label:r.friendlyName||r.name}))}catch(r){console.error("[switcher] model list failed",Y(r))}let n=e.length?void 0:cd()??void 0;return{hasKey:t,models:e,error:n}}async function nI(){if(Nr&&at)return{active:!0,managed:!0,model:at,port:In,provider:Nn,routedModel:oi,caching:ai,reasoning:li,externalBaseUrl:null};let t=Qt(il(V))?.env||{};return{active:!1,managed:!1,model:null,port:null,provider:null,routedModel:null,caching:"unknown",reasoning:li,externalBaseUrl:t.ANTHROPIC_BASE_URL||null}}async function bv(t,e){let n=await XR();return at=t,Nn=e,ZR(V,n),n}async function rI({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(Ff(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 bv(t,Uf[t]??null),oi=null,ai="unknown",eI(V,t,Nn)}catch(e){return{ok:!1,error:`failed to start the wire proxy: ${Y(e)}`}}return{ok:!0}}async function sI({level:t}){return t!=null&&(!Number.isInteger(t)||t<0||t>=Mf.length)?{ok:!1,error:`reasoning level must be 0\u2013${Mf.length-1} or null`}:(li=t,{ok:!0,level:t})}async function iI(){return yv(V),at=null,Nn=null,oi=null,ai="unknown",{ok:!0}}async function oI({key:t}){let e=(t||"").trim();if(!e)return{ok:!1,error:"empty key"};let n=V,r=sl(n,".env"),s="";try{s=Bf(r,"utf8")}catch{}try{if(/^\s*OPENROUTER_API_KEY\s*=/m.test(s))uv(r,s.replace(/^\s*OPENROUTER_API_KEY\s*=.*$/m,`OPENROUTER_API_KEY=${e}`));else{let i=s&&!s.endsWith(`
|
|
2115
2072
|
`)?`
|
|
2116
|
-
`:"";
|
|
2117
|
-
`)}}catch(i){return{ok:!1,error:Y(i)}}return process.env.OPENROUTER_API_KEY=e,
|
|
2118
|
-
`)}catch(o){return{ok:!1,error:`could not write ${t}: ${Y(o)}`}}return{ok:!0,count:e.length}}var
|
|
2073
|
+
`:"";dv(r,i+`OPENROUTER_API_KEY=${e}
|
|
2074
|
+
`)}}catch(i){return{ok:!1,error:Y(i)}}return process.env.OPENROUTER_API_KEY=e,pv(n,[".env"],"# secrets"),{ok:!0}}function aI(){if(!(!Nr&&!at)){try{yv(V)}catch{}QR()}}function lI(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 cI(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 uI(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=Df(e?.cache_read_input_tokens)||Df(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 dI({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(Ff(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(jf,{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:lI(a.status,k),restriction:cI(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=Df(l?.usage?.cache_creation_input_tokens),{r:f,j:p}=await o(c),{works:h,read:m,note:y}=uI(f.ok,p?.usage,c);return h===!0&&c&&(Uf[t]=c,at===t&&(Nn=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:y}}}catch(a){let l=Y(a);return{ok:!0,callable:!1,ms:Date.now()-n,error:/abort/i.test(l)?"timed out (20s)":l}}}var FR,jf,UR,qR,fv,JR,Mf,il,ol,nl,Ff,Nr,In,at,Nn,oi,ai,li,Uf,Df,hv,wv,vv=v(()=>{"use strict";Tr();Gt();qt();FR="https://openrouter.ai/api",jf=`${FR}/v1/messages`,UR="typebulb-proxy-managed",qR="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.",fv=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"],JR=5e3,Mf=["low","medium","high"],il=t=>sl(t,".claude","settings.local.json"),ol=t=>sl(t,".claude",".cc-switcher.json"),nl=t=>`http://127.0.0.1:${t}`;Ff=t=>/^anthropic\//i.test(t)||/claude/i.test(t),Nr=null,In=null,at=null,Nn=null,oi=null,ai="unknown",li=1,Uf={},Df=t=>typeof t=="number"?t:0,hv=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(ol(V)),n=e?.active?.model;if(!n)return;let s=(Qt(il(V))?.env||{}).ANTHROPIC_BASE_URL||"";if(!/127\.0\.0\.1|localhost/.test(s))return;let i=await bv(n,e.active.provider??Uf[n]??null);console.log(`[switcher] re-adopted override after restart: ${n} via ${nl(i)}`)}catch(e){console.error("[switcher] boot reconcile failed",Y(e))}})()});var kv={};Si(kv,{agentMessage:()=>Mo,attach:()=>bI,blockToMarkdown:()=>Lo,breakout:()=>Sf,capText:()=>Pe,childStatus:()=>EI,cleanUserText:()=>Ft,clearSwitchModel:()=>iI,closeChild:()=>SI,composerPasteRead:()=>kI,displayName:()=>fI,downloadSample:()=>Rf,firstLineDigest:()=>Le,git:()=>be,gitChangedFiles:()=>nf,gitDiff:()=>rf,info:()=>pI,isHiddenTurn:()=>As,launchBulb:()=>Tf,listBreakouts:()=>kf,listBulbFiles:()=>Ef,listChildren:()=>wI,listMyBulbs:()=>Nf,listSamples:()=>_f,listSessions:()=>gI,listSwitchModels:()=>tI,logInlineStatus:()=>mI,openChild:()=>vI,openFile:()=>vf,poll:()=>hI,predictTrustOf:()=>Of,probeModel:()=>dI,pullRemoteBulb:()=>$f,pushLocalBulb:()=>Lf,readBulbLog:()=>Cf,repoRoot:()=>Pn,saveOpenRouterKey:()=>oI,searchBulbs:()=>Af,searchSessions:()=>yI,setBulbTrust:()=>Pf,setReasoning:()=>sI,setSwitchModel:()=>rI,shutdownSwitcher:()=>aI,stopBreakout:()=>xf,summarizeTurn:()=>xI,switchState:()=>nI,toolResultDigest:()=>$u});var Sv,fI,pI,hI,mI,gI,yI,bI,wI,vI,SI,kI,xI,EI,xv=v(()=>{"use strict";Za();Do();tl();Cr();vv();Do();xs();Sv=new Xn,fI=Sv.displayName,{info:pI,poll:hI,logInlineStatus:mI,listSessions:gI,searchSessions:yI,attach:bI,listChildren:wI,openChild:vI,closeChild:SI,composerPasteRead:kI,summarizeTurn:xI,childStatus:EI}=Ir(Sv)});var Av={};Si(Av,{attach:()=>RI,breakout:()=>Sf,childStatus:()=>DI,closeChild:()=>$I,composerPasteRead:()=>LI,displayName:()=>AI,downloadSample:()=>Rf,git:()=>be,gitChangedFiles:()=>nf,gitDiff:()=>rf,info:()=>TI,launchBulb:()=>Tf,listBreakouts:()=>kf,listBulbFiles:()=>Ef,listChildren:()=>II,listMyBulbs:()=>Nf,listSamples:()=>_f,listSessions:()=>CI,logInlineStatus:()=>PI,openChild:()=>NI,openFile:()=>vf,poll:()=>OI,predictTrustOf:()=>Of,pullRemoteBulb:()=>$f,pushLocalBulb:()=>Lf,readBulbLog:()=>Cf,repoRoot:()=>Pn,searchBulbs:()=>Af,searchSessions:()=>_I,setBulbTrust:()=>Pf,stopBreakout:()=>xf,summarizeTurn:()=>MI});var Ev,AI,TI,OI,PI,CI,_I,RI,II,NI,$I,LI,MI,DI,Tv=v(()=>{"use strict";Za();Bu();tl();Cr();Ev=new Zn,AI=Ev.displayName,{info:TI,poll:OI,logInlineStatus:PI,listSessions:CI,searchSessions:_I,attach:RI,listChildren:II,openChild:NI,closeChild:$I,composerPasteRead:LI,summarizeTurn:MI,childStatus:DI}=Ir(Ev)});import{readFileSync as BI,writeFileSync as jI,mkdirSync as FI}from"fs";import{homedir as UI}from"os";import*as al from"path";async function Cv(){try{let t=await fetch(new URL("/api/tags",Pv()).toString(),{signal:AbortSignal.timeout(qI)});return t.ok?((await t.json()).models??[]).map(n=>n.name).filter(n=>!!n):[]}catch{return[]}}function _v(t){let e;try{e=BI(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&&!qf(r)}}}catch{}return{json:void 0,unreadable:!0}}function qf(t){let e=t?.providers;return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function JI(t){let e=qf(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 Rv(){let{json:t,unreadable:e}=_v(Ov());return e?{installed:[],configured:null}:{installed:await Cv(),configured:JI(t)}}async function Iv(){let t=await Cv();return t.length?WI(Ov(),t,Pv()):{ok:!1,error:"Ollama is not running (or has no models installed)"}}function WI(t,e,n){let{json:r,unreadable:s}=_v(t);if(s)return{ok:!1,error:`could not parse ${t} \u2014 edit the ollama provider there yourself`};let i={...r??{},providers:{...qf(r)??{},ollama:{baseUrl:`${n}/v1`,api:"openai-completions",apiKey:"ollama",models:e.map(o=>({id:o}))}}};try{FI(al.dirname(t),{recursive:!0}),jI(t,JSON.stringify(i,null,2)+`
|
|
2075
|
+
`)}catch(o){return{ok:!1,error:`could not write ${t}: ${Y(o)}`}}return{ok:!0,count:e.length}}var qI,Ov,Pv,Nv=v(()=>{"use strict";Gt();Tr();qI=1500,Ov=()=>al.join(UI(),".pi","agent","models.json"),Pv=()=>ur(process.env.OLLAMA_HOST??"http://localhost:11434")});var Lv={};Si(Lv,{attach:()=>XI,breakout:()=>Sf,closeChild:()=>eN,composerFiles:()=>sN,composerNew:()=>rN,composerPaste:()=>aN,composerPasteRead:()=>lN,composerRpc:()=>oN,composerSend:()=>tN,composerStop:()=>nN,composerUiRespond:()=>iN,displayName:()=>KI,downloadSample:()=>Rf,git:()=>be,gitChangedFiles:()=>nf,gitDiff:()=>rf,info:()=>HI,launchBulb:()=>Tf,listBreakouts:()=>kf,listBulbFiles:()=>Ef,listChildren:()=>QI,listMyBulbs:()=>Nf,listSamples:()=>_f,listSessions:()=>VI,logInlineStatus:()=>YI,ollamaOffer:()=>Rv,ollamaSync:()=>Iv,openChild:()=>ZI,openFile:()=>vf,poll:()=>zI,predictTrustOf:()=>Of,pullRemoteBulb:()=>$f,pushLocalBulb:()=>Lf,readBulbLog:()=>Cf,repoRoot:()=>Pn,searchBulbs:()=>Af,searchSessions:()=>GI,setBulbTrust:()=>Pf,shutdownComposer:()=>uN,stopBreakout:()=>xf,summarizeTurn:()=>cN});var $v,KI,HI,zI,YI,VI,GI,XI,QI,ZI,eN,tN,nN,rN,sN,iN,oN,aN,lN,cN,uN,Mv=v(()=>{"use strict";Za();ef();tl();Cr();Nv();$v=new Pr,KI=$v.displayName,{info:HI,poll:zI,logInlineStatus:YI,listSessions:VI,searchSessions:GI,attach:XI,listChildren:QI,openChild:ZI,closeChild:eN,composerSend:tN,composerStop:nN,composerNew:rN,composerFiles:sN,composerUiRespond:iN,composerRpc:oN,composerPaste:aN,composerPasteRead:lN,summarizeTurn:cN,shutdownComposer:uN}=Ir($v)});import*as nk from"fs/promises";import*as Tt from"path";ki();Q();function Cu(t){if(!We.includes(t))throw new Error(`Unknown block kind '${t}' (one of: ${We.join(", ")})`);return t}function Gg(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=Cu(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}Do();Bu();ef();var ll={claude:{adapter:()=>new Xn,server:()=>Promise.resolve().then(()=>(xv(),kv))},codex:{adapter:()=>new Zn,server:()=>Promise.resolve().then(()=>(Tv(),Av))},pi:{adapter:()=>new Pr,server:()=>Promise.resolve().then(()=>(Mv(),Lv))}};function Dv(t){return t in ll}function $r(){return Object.keys(ll)}function cl(){return Object.fromEntries(Object.entries(ll).map(([t,e])=>[t,e.adapter]))}function Bv(t){return ll[t].server()}var ci=cl();function jv(){for(let t of Object.values(ci))try{t().ensureHarnessSupport()}catch{}}function xt(){for(let t of Object.keys(ci))try{if(ci[t]().detectsSelf())return t}catch{}}function Fv(t){let e=$r(),n=new Map(e.filter(i=>ci[i]).map(i=>[i,ci[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 Wf=5e3;function Jf(t){try{return t()}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exit(1)}}function Uv(t){let n={subcommand:"run",file:"",watch:!0,open:process.env.TERM_PROGRAM==="vscode"||xt()!==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","trust","untrust","models","slug","send","pull","push","get","put","status"],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==="--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=Wf;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=Jf(()=>mp(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=Jf(()=>Cu(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=Jf(()=>Gg(i.slice(1)))),n}function qv(){console.log(`
|
|
2119
2076
|
typebulb - Local bulb runner for Typebulb
|
|
2120
2077
|
|
|
2121
2078
|
Usage:
|
|
@@ -2293,7 +2250,7 @@ Examples:
|
|
|
2293
2250
|
typebulb my-editor.bulb.md
|
|
2294
2251
|
typebulb --no-watch my-editor.bulb.md
|
|
2295
2252
|
typebulb .
|
|
2296
|
-
`)}St();
|
|
2253
|
+
`)}St();Rs();ki();$s();St();import*as qe from"path";import{spawn as BN,execSync as jN}from"child_process";import{createRequire as FN}from"module";import{existsSync as UN}from"fs";import*as we from"fs/promises";import*as ge from"path";var Kf=[{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"}],Hf=[{name:"dom"},{name:"dom.iterable"},{name:"dom.asynciterable"}];function zf(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)}Q();var dN=`
|
|
2297
2254
|
/**
|
|
2298
2255
|
* Get raw data chunk from the Data tab.
|
|
2299
2256
|
* @param index - Chunk index (0-based). Separate chunks with 2 blank lines.
|
|
@@ -2304,7 +2261,7 @@ Examples:
|
|
|
2304
2261
|
* @param index - Chunk index (0-based)
|
|
2305
2262
|
* @throws If chunk is not valid JSON/JSON-ish
|
|
2306
2263
|
*/
|
|
2307
|
-
json<T = unknown>(index: number): T;`,
|
|
2264
|
+
json<T = unknown>(index: number): T;`,fN=`
|
|
2308
2265
|
/**
|
|
2309
2266
|
* Get the insight data produced by the inference layer.
|
|
2310
2267
|
*
|
|
@@ -2313,7 +2270,7 @@ Examples:
|
|
|
2313
2270
|
*
|
|
2314
2271
|
* @returns The parsed insight JSON, or undefined if no insight is available
|
|
2315
2272
|
*/
|
|
2316
|
-
insight<T = unknown>(): T | undefined;`,
|
|
2273
|
+
insight<T = unknown>(): T | undefined;`,pN=`
|
|
2317
2274
|
/**
|
|
2318
2275
|
* Replace the data this run is working on.
|
|
2319
2276
|
*
|
|
@@ -2336,7 +2293,7 @@ Examples:
|
|
|
2336
2293
|
*
|
|
2337
2294
|
* @param value - Any JSON-serializable value
|
|
2338
2295
|
*/
|
|
2339
|
-
setInsight(value: unknown): Promise<void>;`,
|
|
2296
|
+
setInsight(value: unknown): Promise<void>;`,Jv=`options: {
|
|
2340
2297
|
messages: Array<{ role: "user" | "assistant"; content: string }>;
|
|
2341
2298
|
system?: string;
|
|
2342
2299
|
/** 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. */
|
|
@@ -2347,7 +2304,7 @@ Examples:
|
|
|
2347
2304
|
webSearch?: boolean;
|
|
2348
2305
|
/** Abort the request. On abort the promise rejects / the stream ends. */
|
|
2349
2306
|
signal?: AbortSignal;
|
|
2350
|
-
}`,
|
|
2307
|
+
}`,Wv=`
|
|
2351
2308
|
/** Provider-reported token counts for one call \u2014 real usage from the API, never an estimate.
|
|
2352
2309
|
* \`output\` is total billed output (reasoning included); \`reasoning\` is the itemized subset where
|
|
2353
2310
|
* the provider splits it (OpenAI, Gemini, OpenRouter \u2014 Anthropic doesn't); \`cacheRead\` is the
|
|
@@ -2359,10 +2316,10 @@ type AiChunk =
|
|
|
2359
2316
|
| { kind: "text"; text: string }
|
|
2360
2317
|
| { kind: "reasoning"; text: string }
|
|
2361
2318
|
| { kind: "usage"; usage: AiUsage };
|
|
2362
|
-
`,
|
|
2319
|
+
`,Kv=`
|
|
2363
2320
|
/** What backs \`tb.ai\`: the user's own keys, the quota-limited courtesy model, or nothing. */
|
|
2364
2321
|
type AiAccess = "own" | "courtesy" | "none";
|
|
2365
|
-
`,
|
|
2322
|
+
`,Hv=`
|
|
2366
2323
|
/**
|
|
2367
2324
|
* General-purpose AI call. \`tb.ai(opts)\` resolves with the full text; \`tb.ai.stream(opts)\`
|
|
2368
2325
|
* returns an async iterable of {@link AiChunk} deltas you consume with \`for await\`.
|
|
@@ -2372,7 +2329,7 @@ type AiAccess = "own" | "courtesy" | "none";
|
|
|
2372
2329
|
* @throws On rate limit, network error, or provider error
|
|
2373
2330
|
*/
|
|
2374
2331
|
ai: {
|
|
2375
|
-
(${
|
|
2332
|
+
(${Jv}): Promise<{ text: string; usage?: AiUsage }>;
|
|
2376
2333
|
/**
|
|
2377
2334
|
* Streaming counterpart of \`tb.ai()\`. Yields \`{ kind: "text" | "reasoning", text }\` deltas
|
|
2378
2335
|
* as they arrive, then one final \`{ kind: "usage", usage }\` chunk with the call's token
|
|
@@ -2389,8 +2346,8 @@ type AiAccess = "own" | "courtesy" | "none";
|
|
|
2389
2346
|
* if (c.kind === "text") answer += c.text;
|
|
2390
2347
|
* }
|
|
2391
2348
|
*/
|
|
2392
|
-
stream(${
|
|
2393
|
-
};`,
|
|
2349
|
+
stream(${Jv}): AsyncIterable<AiChunk>;
|
|
2350
|
+
};`,zv=`
|
|
2394
2351
|
/**
|
|
2395
2352
|
* Returns AI models available to the current user.
|
|
2396
2353
|
* Models are filtered by the user's configured API keys.
|
|
@@ -2420,7 +2377,7 @@ type AiAccess = "own" | "courtesy" | "none";
|
|
|
2420
2377
|
* \`tb.mode\` or the length of \`tb.models()\` \u2014 which hosts offer a courtesy
|
|
2421
2378
|
* model is the host's business and changes without your bulb changing.
|
|
2422
2379
|
*/
|
|
2423
|
-
aiAccess(): Promise<AiAccess>;`,
|
|
2380
|
+
aiAccess(): Promise<AiAccess>;`,hN="\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;",Yv=`
|
|
2424
2381
|
/**
|
|
2425
2382
|
* The mode this bulb is running in.
|
|
2426
2383
|
*
|
|
@@ -2430,7 +2387,7 @@ type AiAccess = "own" | "courtesy" | "none";
|
|
|
2430
2387
|
* - \`'inline'\` \u2014 Running inline in an agent's transcript, rendered by the mirror
|
|
2431
2388
|
* (sandboxed, client-only: AI, filesystem, and server RPC are unavailable)
|
|
2432
2389
|
*/
|
|
2433
|
-
mode: ${
|
|
2390
|
+
mode: ${Jg};`,Vv=`
|
|
2434
2391
|
/**
|
|
2435
2392
|
* Local filesystem access (CLI only).
|
|
2436
2393
|
*
|
|
@@ -2451,7 +2408,7 @@ type AiAccess = "own" | "courtesy" | "none";
|
|
|
2451
2408
|
list(path?: string): Promise<Array<{ name: string; dir: boolean; mtime: number }>>;
|
|
2452
2409
|
/** 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. */
|
|
2453
2410
|
remove(path: string): Promise<boolean>;
|
|
2454
|
-
};`,
|
|
2411
|
+
};`,Gv=`
|
|
2455
2412
|
/**
|
|
2456
2413
|
* The bulb's folder \u2014 absolute path to \`<bulb-dir>/<filename-stem>/\`
|
|
2457
2414
|
*
|
|
@@ -2459,7 +2416,7 @@ type AiAccess = "own" | "courtesy" | "none";
|
|
|
2459
2416
|
* \`tb.fs\` already resolves relative paths against it, so bulb code writing
|
|
2460
2417
|
* its own files never needs it. CLI only \u2014 throws in ide/published/inline mode.
|
|
2461
2418
|
*/
|
|
2462
|
-
readonly dir: string;`,
|
|
2419
|
+
readonly dir: string;`,mN=`
|
|
2463
2420
|
/**
|
|
2464
2421
|
* Async value inspector for tensor-like objects.
|
|
2465
2422
|
*
|
|
@@ -2512,48 +2469,47 @@ type AiAccess = "own" | "courtesy" | "none";
|
|
|
2512
2469
|
*
|
|
2513
2470
|
* @returns The full canonical URL
|
|
2514
2471
|
*/
|
|
2515
|
-
url(): Promise<string>;`,
|
|
2472
|
+
url(): Promise<string>;`,gN="\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;",yN="\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;",bN="\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>>;",Yf=`${Wv}${Kv}
|
|
2516
2473
|
/**
|
|
2517
2474
|
* Typebulb utilities namespace.
|
|
2518
2475
|
* Type \`tb.\` to discover available helpers.
|
|
2519
2476
|
*/
|
|
2520
|
-
declare const tb: {${
|
|
2477
|
+
declare const tb: {${dN}${mN}${fN}${pN}${yN}${bN}${gN}${Hv}${Vv}${Gv}${zv}${hN}${Yv}
|
|
2521
2478
|
};
|
|
2522
|
-
`,
|
|
2479
|
+
`,wN=`
|
|
2523
2480
|
/**
|
|
2524
2481
|
* Print to the CLI's stdout \u2014 the same channel as \`console.log\` here (the server's console IS
|
|
2525
2482
|
* the bulb's log). One log verb across blocks: page-side \`tb.log\` reaches this same stdout.
|
|
2526
2483
|
*/
|
|
2527
|
-
log(...args: any[]): void;`,
|
|
2484
|
+
log(...args: any[]): void;`,Vf=`${Wv}${Kv}
|
|
2528
2485
|
/**
|
|
2529
2486
|
* Typebulb utilities namespace (server-side).
|
|
2530
2487
|
* Type \`tb.\` to discover available helpers.
|
|
2531
2488
|
*/
|
|
2532
|
-
declare const tb: {${
|
|
2489
|
+
declare const tb: {${wN}${Hv}${Vv}${Gv}${zv}${Yv}
|
|
2533
2490
|
};
|
|
2534
|
-
`;yt();import
|
|
2491
|
+
`;yt();import xN from"p-limit";yt();import{resolve as Qv}from"resolve.exports";var Et={maxRelativeTypeRefs:500,maxBareDeps:8,maxBareDepth:3,prefetchConcurrency:4,negativeTtlMs:1e4},ui=["index.d.ts","index.d.mts"],Gf=/\.d\.(ts|mts|cts)$/i;function ul(t){return/\.d\.(ts|mts|cts)(?:[?#].*)?$/i.test(t)||/[?&]dts(?:[&#]|$)/i.test(t)}function Xv(t){return[`${t}.d.ts`,`${t}.d.mts`]}function Zt(t){if(!t||t==="./"||t==="/")return[...ui];let e=t.replace(/\.(mjs|cjs|js|mts|cts|ts)$/i,""),n=Xv(e),r=e.endsWith("/")?e:`${e}/`;return n.push(...Xv(`${r}index`)),n}async function Lr(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(vN(a.status)&&s<e)continue;return a}catch{if(s<e)continue;return}finally{clearTimeout(o)}}}function vN(t){return t===408||t===429||t>=500&&t<600}var dl=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)||ul(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 Lr(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=xn(e.path);if(!o||o==="/"||o===".")return this.tryUntilSuccess([...ui],n);if(!Gf.test(o)){let a=await this.tryUntilSuccess(Zt(o),n);if(a)return a}return n(o)}let s=Zt(e.path),i=r?.subpath?[...s,...ui]:[...ui,...s];return this.tryUntilSuccess(i,n)}toResolutionResult(e){return{kind:Gf.test(e)?"types":"probe",path:e}}resolveExportsPath(e,n){let r=n||".",s=e;try{let i=this.extractPathFromResult(Qv(s,r,{conditions:["types"]}));if(i)return i}catch{}try{return this.extractPathFromResult(Qv(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=Cd(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(Zt(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=xn(r),i=new URL(s,e).toString(),o=await this.tryUrls([i]);return o?{dts:o.dts,url:o.url,resolvedPkg:n}:void 0}};yt();import{gunzipSync as SN}from"fflate";var fl=class{async fetchAndExtract(e,n){let r=this.getTarballUrl(e,n),s=await Lr(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=SN(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 pl=class{constructor(e,n,r=new fl){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=En.majorOf(r),o=e.filter(a=>En.majorOf(a)===i);if(o.length)return o.sort((a,l)=>En.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=Zt(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 hl=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(`
|
|
2535
2492
|
`).filter(s=>{let i=s.trimStart();return!(i.startsWith("*")||i.startsWith("//")||i.startsWith("/*"))}).join(`
|
|
2536
|
-
`),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://"))}};yt();var
|
|
2537
|
-
`);await this.prefetchBareDeps(
|
|
2538
|
-
`,"utf8"),await
|
|
2539
|
-
`,"utf8"),{dir:e}}function
|
|
2540
|
-
`))console.log(`${e} ${r}`);return t.length>0}function
|
|
2493
|
+
`),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://"))}};yt();var Zv="file:///node_modules",ml=class{constructor(){this.epoch=0}bumpEpoch(){this.epoch+=1}epochDir(){return`__tsepoch_${this.epoch}`}pathForMain(e){return`${Zv}/${this.epochDir()}/${e}/index.d.ts`}pathFor(e,n){let r=xn(n);return`${Zv}/${this.epochDir()}/${e}/${r}`}};import{LRUCache as kN}from"lru-cache";function eS(t){let e=new kN({ttl:Et.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 Lr(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 di=class{constructor(e){this.inFlight=new Map,this.scanner=new hl,this.cache=e.cache,this.cdnClient=e.cdnClient,this.versionResolver=e.versionResolver,this.packageService=e.packageService,this.fetchDts=eS(e.cache),this.typescriptProvider=new dl(this.fetchDts,e.cdnClient),this.definitelyTypedProvider=new pl(e.cdnClient,e.cache),this.virtualFs=new ml}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>Et.maxRelativeTypeRefs)))try{let a=new URL(n),l=new URL("./",a);o??(o=this.extractPackageRootUrl(a));let c=this.scanner.collectRelativeTypeRefs(e).slice(0,Et.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=ul(l)?[l]:Zt(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,Et.maxBareDeps).filter(c=>this.isDifferentPackage(c,n));if(!o.length)return;let a=new Set([n]),l=xN(Et.prefetchConcurrency);await Promise.all(o.map(c=>l(()=>this.prefetchBareDepsRecursive(c,r,s,Et.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,Et.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(`
|
|
2494
|
+
`);await this.prefetchBareDeps(h,c,f,p,s);let m=l.format(),y=e===m?[e]:[e,m],k=y.some(A=>this.ambientlyDeclares(i,A));return k?this.markFileAmbient(f,u):p.push(...y.map(A=>({module:A,path:u}))),{pkg:e,mainPath:u,files:f,shims:p,ambient:k}}};jd();yt();wr();Ys();Dd();br();import*as Mr from"path";var EN=Mr.join(ya,"pkg"),AN=Mr.join(ya,"files"),TN=Mr.join(ya,"negative.json"),yl=class{pkgMem=new Map;fileMem=new Map;negativeCache=new An(new vr(TN));async getCachedDts(e){if(this.pkgMem.has(e))return this.pkgMem.get(e);await te();let n=await bt(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 gl(async()=>{await te(),await Be(tS(e),JSON.stringify(s))})}async getCachedFile(e){if(this.fileMem.has(e))return this.fileMem.get(e);await te();let n=await ga(nS(e));return this.fileMem.set(e,n),n}async setCachedFile(e,n){this.fileMem.set(e,n),await gl(async()=>{await te(),await Be(nS(e),n)})}isNegative(e){return this.negativeCache.isNegative(e)}async recordNegative(e){await gl(async()=>{await te(),await this.negativeCache.recordNegative(e)})}clearNegative(e){return gl(()=>this.negativeCache.clearNegative(e))}};async function gl(t){try{await t()}catch{}}function tS(t){return Mr.join(EN,Xe(t)+".json")}function nS(t){return Mr.join(AN,Xe(t)+".txt")}wr();var Xf;function ON(){return Xf||(Xf=new di({cache:new yl,cdnClient:Jb,packageService:Sa,versionResolver:qb})),Xf}var rS="file:///node_modules/";async function sS(t){let e=ba(t.emitKey,"typecheck");await te(),await we.rm(e,{recursive:!0,force:!0}),await we.mkdir(e,{recursive:!0});let n=RN(t.jsxImportSource,t.dependencies),r=await ON().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=bl(d.path);if(!f||o.has(f))continue;o.add(f);let p=ge.join(e,"node_modules",f);await we.mkdir(ge.dirname(p),{recursive:!0}),await we.writeFile(p,d.content,"utf8")}let a={};for(let u of i)for(let d of u.shims){let f=bl(d.path);f&&(a[d.module]=[`./node_modules/${f}`])}for(let u of i){if(u.ambient)continue;let d=bl(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=bl(d.path);f&&l.add(`node_modules/${f}`)}if(t.local){delete a[t.local.name];let u=await IN(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=PN(t.jsxImportSource,a,[...l]);return await we.writeFile(ge.join(e,"tsconfig.json"),JSON.stringify(c,null,2)+`
|
|
2495
|
+
`,"utf8"),await we.writeFile(ge.join(e,"code.tsx"),t.code,"utf8"),await we.writeFile(ge.join(e,"tb.d.ts"),Yf,"utf8"),{dir:e}}var Qf={target:"es2023",module:"esnext",moduleResolution:"bundler",strict:!0,noEmit:!0,skipLibCheck:!0,esModuleInterop:!0,allowSyntheticDefaultImports:!0,forceConsistentCasingInFileNames:!0};function PN(t,e,n=[]){return{compilerOptions:{...Qf,lib:CN([...Kf,...Hf]),jsx:"react-jsx",jsxImportSource:t??"react",paths:e},include:["code.tsx","tb.d.ts",...n]}}function CN(t){return zf(t).map(e=>_N(e.name))}function _N(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 RN(t,e){let n=t??("react"in e?"react":void 0);return n?[`${n}/jsx-runtime`,`${n}/jsx-dev-runtime`]:[]}function bl(t){if(!t.startsWith(rS))return;let e=t.slice(rS.length),n=e.indexOf("/");if(!(n<0))return e.slice(n+1)}async function IN(t,e){if(!t.typesAbs)return;let n=ge.dirname(t.typesAbs),r=ge.join(e,"node_modules",t.name);for(let s of await NN(n)){let i=ge.join(r,ge.relative(n,s));await we.mkdir(ge.dirname(i),{recursive:!0}),await we.copyFile(s,i)}return ge.basename(t.typesAbs)}async function NN(t){let e=[];async function n(r){let s=await we.readdir(r,{withFileTypes:!0});for(let i of s){let o=ge.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 Ue from"fs/promises";import*as At from"path";import{existsSync as $N}from"fs";wr();Ud();var LN="^22";async function iS(t){let e=ba(t.emitKey,"typecheck-server");await te(),await Ue.rm(e,{recursive:!0,force:!0}),await Ue.mkdir(e,{recursive:!0});let n=At.join(t.bulbDir,".typebulb"),r=Pa(t.server).filter(o=>o!==t.local?.name);await Oa([`@types/node@${LN}`,...r],n,t.dependencies,{ignoreScripts:!0});let s=At.join(n,"node_modules"),i=At.join(e,"node_modules");return await DN(s,i),await Ue.writeFile(At.join(e,"server.ts"),t.server,"utf8"),await Ue.writeFile(At.join(e,"tb.d.ts"),Vf,"utf8"),await Ue.writeFile(At.join(e,"tsconfig.json"),JSON.stringify(MN(t.local),null,2)+`
|
|
2496
|
+
`,"utf8"),{dir:e}}function MN(t){let e={...Qf,lib:["ES2023"],types:["node"]};if(t?.typesAbs){let n=i=>i.replace(/\\/g,"/"),r=n(At.dirname(t.typesAbs)),s=n(t.typesAbs).replace(/\.d\.ts$/,"");e.paths={[t.name]:[s],[`${t.name}/*`]:[`${r}/*`]}}return{compilerOptions:e,include:["server.ts","tb.d.ts"]}}async function DN(t,e){if(!$N(t)){await Ue.mkdir(e,{recursive:!0});return}await Ue.rm(e,{recursive:!0,force:!0});let n=process.platform==="win32"?"junction":"dir";await Ue.symlink(t,e,n)}na();Q();async function aS(t,e){let{bulb:n,config:r,warnings:s,starts:i}=await Ze(t),o=qe.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=Er(qe.resolve(t)),d=u?Yn(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=oS(Is(n.code,{target:"client",dependencies:r.dependencies??{},lineOffset:a("code.tsx")}),"client")||l),n.server&&(l=oS(Is(n.server,{target:"server",lineOffset:a("server.ts")}),"server")||l);let f=KN([process.cwd(),qe.dirname(t)]);if(!f){let m=qe.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 sS({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 iS({server:n.server,bulbDir:qe.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:y}of p){let{stdout:k,exitCode:A}=await JN(f,y);for(let P of k.split(/\r?\n/))P.trim()&&console.log(`${m} ${qN(P,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 oS(t,e){for(let n of t)for(let r of n.message.split(`
|
|
2497
|
+
`))console.log(`${e} ${r}`);return t.length>0}function qN(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=BN(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 WN=FN(import.meta.url);function KN(t){let e=r=>{try{let s=WN.resolve("typescript/package.json",{paths:r}),i=qe.join(qe.dirname(s),"lib","tsc.js");return UN(i)?i:void 0}catch{return}},n=e(t);if(n)return n;try{let r=jN("npm root -g",{encoding:"utf8"}).trim();return e([r])}catch{return}}St();ta();$s();async function lS(t,e){let{bulb:n}=await Ze(t),r=ar(n);if(bn(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.)")}$s();import*as fi from"path";async function cS(t,e){if(!t){e||(console.error("Usage: typebulb untrust <file.bulb.md>"),process.exit(1));let r=ld();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=fi.resolve(t);n.endsWith(".bulb.md")||(console.error("File must have .bulb.md extension"),process.exit(1));try{lr(n,e)}catch(r){console.error(r.message),process.exit(1)}console.log(e?`Trusted ${fi.basename(n)} \u2014 runs with fs / AI / server.ts (no --trust needed).`:`Untrusted ${fi.basename(n)} \u2014 runs Restricted.`),console.log(` ${n}`)}Me();import*as fS from"readline";Td();function Zf(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 HN=5e3,wl=()=>Math.round(performance.now()),uS=t=>t>=1e3?`${(t/1e3).toFixed(1)}s`:`${t}ms`;async function pS(t){let e=Fv(process.cwd()),n=wl();if("ambiguous"in e){let r=await zN(t,e.ambiguous);return r?dS(t,r,{boot:n,from:wl()}):YN(t,e.ambiguous)}return dS(t,e.name,{boot:n,from:wl()})}async function dS(t,e,n){let r,s;try{r=await Zu(e)}catch(p){s=p instanceof Error?p.message:String(p)}let i=wl()-n.from,{lit:o,litLink:a,brand:l}=Zf(process.stdout.isTTY===!0),c=[" Read the authoring skill before writing a bulb:",` \u2022 ${o(Bs())}`],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')}`," raise the shell tool's timeout_ms to 130000"," (its 10s default kills even a clean ok)"]:[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>HN?[` slow launch: boot ${uS(n.boot)} \xB7 mirror ${uS(i)}`]:[],f=[` ${l(`typebulb v${t}`)}`,...d,...u,""];process.stdout.write(f.join(`
|
|
2541
2498
|
`)+`
|
|
2542
|
-
`)}async function
|
|
2499
|
+
`)}async function zN(t,e){if(!process.stdin.isTTY||!process.stdout.isTTY)return;let{lit:n,brand:r}=Zf(!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(`
|
|
2543
2500
|
`)+`
|
|
2544
|
-
`);let i=
|
|
2501
|
+
`);let i=fS.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 YN(t,e){let{lit:n,brand:r}=Zf(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(`
|
|
2545
2502
|
`)+`
|
|
2546
|
-
`)}
|
|
2547
|
-
`+e)}function
|
|
2503
|
+
`)}it();wn();async function hS(t){Ee(t);let e=await mt();if(e.length>0){console.log(lb(e,process.env.TB_AI_PROVIDER,process.env.TB_AI_MODEL));return}if(!ud()){console.log("No AI provider keys found in this directory's .env, and no local Ollama server detected."),console.log("Set one of these to use a cloud model with tb.ai:");for(let[n,r]of Object.entries(cr))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.")}Q();function mS(t){t?.trim()||(console.error("Usage: typebulb slug <bulb name>"),process.exit(1));let e=Yn(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)}Ye();import*as bS from"path";import{valid as yS,lt as GN}from"semver";Me();var et={connected:"[page] connected",disconnected:"[page] disconnected",closed:t=>`[page] closed: ${t}`},ep=3e3,gS=1e4,VN=2500,vl=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?.()},ep).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,VN);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()}};zo();function XN(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=>sr(o,n));return r&&i.find(o=>o.agent===r)||i[0]}return t.find(i=>ie(i.file)===ie(e))}var Dr=t=>t.agent??bS.basename(t.file);function wS(t){return t===De?!1:t&&yS(t)&&yS(De)?GN(t,De):!0}function QN(t){return t===De?"":t?wS(t)?` STALE runtime v${t} (this CLI is v${De} \u2014 relaunch to update)`:` runtime v${t} (newer than this CLI's v${De})`:" STALE runtime (predates the version stamp \u2014 relaunch to update)"}function ZN(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 vS(t,e,n){t.forEach((r,s)=>e(` ${r.url} pid ${r.pid} ${r.trust?"trusted":"restricted"}${n?ZN(r,n[s]):""}${QN(r.version)} ${r.file}`))}async function tp(t,e){if(!t.length){console.log("No running bulb servers.");return}let n=await Promise.all(t.map(Qu));console.log("Running bulb servers:"),vS(t,r=>console.log(r),n),console.log(`
|
|
2504
|
+
`+e)}function np(t,e,n,r,s){let i=XN(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>\`):`),vS(t,o=>console.error(o))):console.error("No bulb servers are running."),process.exit(1)}async function SS(t,e){if(!t){e.clear&&(console.error("Specify which server to clear: typebulb logs --clear <file|pid>"),process.exit(1)),await tp(await X(process.cwd()),"Run `typebulb logs <file|pid>` to print one server's console.");return}let n=np(await X(),t,"logs",process.cwd(),xt());if(e.clear){Ku(n.pid),console.log(`Cleared log for ${Dr(n)} (pid ${n.pid}).`);return}let r=Ve(n.pid),s=r.text;if(e.run!==void 0?(s=zu(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(`
|
|
2548
2505
|
`);i.length&&i[i.length-1]===""&&i.pop(),s=i.slice(-e.lines).join(`
|
|
2549
2506
|
`)}if(process.stdout.write(s),s&&!s.endsWith(`
|
|
2550
2507
|
`)&&process.stdout.write(`
|
|
2551
|
-
`),e.follow&&e.run===void 0){let i=r.offset,o=setInterval(()=>{let l=Ve(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
|
|
2552
|
-
`);
|
|
2553
|
-
`).trimEnd()}function
|
|
2508
|
+
`),e.follow&&e.run===void 0){let i=r.offset,o=setInterval(()=>{let l=Ve(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 e1=t=>new Promise(e=>setTimeout(e,t));async function kS(t,e){if(!t){tp(await X(process.cwd()),"Run `typebulb wait <file|pid>` to block until one logs a new line.");return}let n=np(await X(),t,"wait",process.cwd(),xt()),r=process.env.TYPEBULB_WAIT_SHIM==="1",s=process.env.TYPEBULB_WAIT_FOLLOW==="1",i=r||s,o=e.timeoutSec??1800,a=e.match??"",l=Ve(n.pid).offset,c=s?void 0:Vo(n.pid,a)??(a?Vo(n.pid):void 0),u=s?l:c!==void 0&&c<=l?c:a?0:l,d=Date.now()+o*1e3,f=ye(n)?1e4:1e3,p=2e3,h=!ye(n)&&!s,m,y="",k=0;for(;;){let A=u>=l,P=Ve(n.pid,u);if(u=P.offset,P.text){y+=P.text;let E=y.split(`
|
|
2509
|
+
`);y=E.pop()??"";let R=!1;for(let I of E)I.trim()&&(h&&A&&I.startsWith(et.disconnected)&&(R=!0),!(e.match&&!I.includes(e.match))&&(console.log(I),!s&&(m??=Date.now()+f,ye(n)&&(I.includes("] compile error")||I.includes("] runtime error"))&&(m=Math.min(m,Date.now()+p)))));if(R&&!m){console.error(`the last page of ${Dr(n)} closed while waiting \u2014 a bulb runs in its page, so nothing can log ${e.match?`'${e.match}'`:"anything"} now`),k=3;break}}if(m&&Date.now()>=m)break;if(!i&&!m&&Date.now()>=d){console.error(`timeout: no ${e.match?`line matching '${e.match}'`:"new output"} from ${Dr(n)} within ${o}s`),k=2;break}if(!tr(n.pid)){m||(console.error(`server ${Dr(n)} (pid ${n.pid}) exited while waiting`),process.exit(3));break}await e1(400)}s||Ps(n.pid,u,a),process.exit(k)}function xS(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 ES(t){if(!t){await tp(await X(process.cwd()),"Run `typebulb stop <file|pid>` to stop one.");return}let e=np(await X(),t,"stop",process.cwd(),xt()),n=await Ut(e);console.log(`Stopped ${Dr(e)} (pid ${e.pid}, ${e.url}).${xS(e,n)}`)}async function AS(t){let e=process.cwd(),n=t==="agent"?xt():void 0,r=t==="global"?await X():t==="bulbs"?await X(e):(await X()).filter(o=>sr(o,e)&&(!n||o.agent===n)),s=t==="global"?"server":t==="agent"?"mirror":"bulb";if(!r.length){console.log(t==="global"?"No running bulb servers.":`No running ${s}s for this project.`);return}let i=await Promise.all(r.map(o=>Ut(o)));console.log(`Stopped ${r.length} ${s}${r.length===1?"":"s"}:`),r.forEach((o,a)=>console.log(` ${o.url} pid ${o.pid} ${Dr(o)}${xS(o,i[a])}`))}Me();Ye();pn();import*as Sl from"path";import*as TS from"http";import{mkdir as t1,writeFile as n1}from"fs/promises";async function Br(){let t=[];for await(let e of process.stdin)t.push(e);return Buffer.concat(t).toString("utf-8")}function pi(t){return(t.charCodeAt(0)===65279?t.slice(1):t).replace(/\r\n/g,`
|
|
2510
|
+
`).trimEnd()}function r1(t,e){return new Promise((n,r)=>{let s=new URL(t),i=TS.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 s1=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 OS(t,e,n=0){e==="-"&&(e=pi(await Br()));let r=e!==void 0&&e.startsWith("tb:");r&&n<=0&&(n=Wf);let s=e!==void 0&&/^tb:(click|set)( |$)/.test(e),i=Sl.resolve(t),o=mn(await X(),i)[0];if(!o){let h=(await fn(process.cwd()))(i);console.error(h?`No running server for '${t}' \u2014 it last ran ${s1(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("&"),y=await r1(`${o.url}/__send${m?`?${m}`:""}`,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(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":"",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?`: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 "${et.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 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 y=Ty(i);await t1(Sl.dirname(y),{recursive:!0}),await n1(y,Buffer.from(m.png,"base64"));let k=[m.via?`inside "${m.via}"`:"",m.backdrop?`backdrop ${m.backdrop}`:""].filter(Boolean);console.error(`canvas ${m.width}\xD7${m.height} \u2192 PNG${k.length?` (${k.join("; ")})`:""}`),console.log(y);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)`))}Ma();Gd();Q();import*as PS from"fs/promises";async function CS(t,e){let n=await PS.readFile(t,"utf-8"),r=Mn(n),s=ue[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(`
|
|
2554
2511
|
`)?i:i+`
|
|
2555
|
-
`)}Q();import*as hi from"fs/promises";async function
|
|
2556
|
-
(partly unjudged: ${d})`);return}console.error(`No agent matches "${t}". Run \`typebulb status\` to list them.`),process.exitCode=1}function l1(t){let e=[...t.children].sort((n,r)=>n.mtime-r.mtime);console.log(`Sub-agents of session ${t.sessionId}:`);for(let n of e)console.log(` ${" ".repeat(Math.max(0,n.depth-1))}${LS(n)}`);console.log("\nRun `typebulb status <id>` for one agent's report.")}var LS=t=>{let e=t.started?Se((t.state==="running"?Date.now():t.mtime)-t.started):"",n=t.failing&&t.state!=="stopped"?"failing":t.state;return`${t.id} ${n.padEnd(7)} ${e.padStart(6)} ${Cn(t)}`};ot();St();Q();ta();import*as en from"fs/promises";import*as $n from"path";import{EventEmitter as _1}from"events";Ut();Q();import{Hono as h1}from"hono";import{serve as m1}from"@hono/node-server";import{streamSSE as g1}from"hono/streaming";import*as lp from"fs/promises";import y1 from"open";wr();Ws();br();import*as op from"fs/promises";import*as mi from"path";var wl=class{async get(e){let n=Xe(e),r=mi.join(Js,n+".bin"),s=mi.join(Js,n+".json");try{let[i,o]=await Promise.all([op.readFile(r),op.readFile(s,"utf8")]),a=JSON.parse(o);return{body:i,contentType:a.contentType,cacheControl:a.cacheControl}}catch{return}}async set(e,n){await ee();let r=Xe(e),s=mi.join(Js,r+".bin"),i=mi.join(Js,r+".json"),o={url:e,contentType:n.contentType,cacheControl:n.cacheControl};await Promise.all([De(s,n.body),De(i,JSON.stringify(o))])}};var MS=`
|
|
2512
|
+
`)}Q();import*as hi from"fs/promises";async function IS(t,e){let n=await hi.readFile(t,"utf-8"),r=[];for(let{kind:i,source:o}of e){let a;try{a=o==="-"?await Br():await hi.readFile(o,"utf-8")}catch(l){RS(`Cannot read ${i}'s source: ${l instanceof Error?l.message:String(l)}`)}r.push({kind:i,content:pi(a),label:o==="-"?"stdin":o})}let s;try{s=i1(n,r)}catch(i){RS(`${t}: ${i instanceof Error?i.message:String(i)}`)}for(let i of s.upToDate)console.log(`${ue[i].path}: already up to date`);if(s.written.length){await hi.writeFile(t,s.text);for(let i of s.written)console.log(i.action==="removed"?`${ue[i.kind].path}: removed (${i.label} is empty)`:`${ue[i.kind].path}: ${i.action} from ${i.label} (${i.chars.toLocaleString()} chars)`)}}function i1(t,e){let n=Mn(t),r=t,s=[],i=[];for(let{kind:o,content:a,label:l}of e){let c=ue[o].path,u=n.files.get(c);if(!a){if(u===void 0){i.push(o);continue}r=_S(Cp(r,o),r,c),s.push({kind:o,action:"removed",chars:0,label:l});continue}if(u!==void 0&&pi(u)===a){i.push(o);continue}r=_S(Fr(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 _S(t,e,n){if(t===e)throw new Error(`the **${n}** block's fence is unterminated; refusing to rewrite inside it`);return t}function RS(t){console.error(t),process.exit(1)}it();pf();ff();_r();async function NS(t,e){Ee(e);let n=process.cwd(),r=cl(),s=xt(),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 Gw(a,n)){if(o=!0,!t){let{reports:u,shared:d}=ni(a,n,l);console.log(zw(l.sessionId,u,await Qw(n,u,d),Date.now()));return}let c=Xw(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(` ${o1(u)}`);process.exitCode=1;return}console.log(Hw(ni(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 o1=t=>`${t.id} ${(t.failing&&t.state!=="stopped"?"failing":t.state).padEnd(7)} ${kt(t)}`;it();St();Q();ta();import*as tn from"fs/promises";import*as $n from"path";import{EventEmitter as P1}from"events";qt();Q();import{Hono as f1}from"hono";import{serve as p1}from"@hono/node-server";import{streamSSE as h1}from"hono/streaming";import*as ip from"fs/promises";import m1 from"open";wr();Ys();br();import*as rp from"fs/promises";import*as mi from"path";var kl=class{async get(e){let n=Xe(e),r=mi.join(zs,n+".bin"),s=mi.join(zs,n+".json");try{let[i,o]=await Promise.all([rp.readFile(r),rp.readFile(s,"utf8")]),a=JSON.parse(o);return{body:i,contentType:a.contentType,cacheControl:a.cacheControl}}catch{return}}async set(e,n){await te();let r=Xe(e),s=mi.join(zs,r+".bin"),i=mi.join(zs,r+".json"),o={url:e,contentType:n.contentType,cacheControl:n.cacheControl};await Promise.all([Be(s,n.body),Be(i,JSON.stringify(o))])}};var $S=`
|
|
2557
2513
|
const CSS = '\\n' +
|
|
2558
2514
|
/* The agent mirror's token set, verbatim (agents/core/client/styles.css) \u2014 one system across CLI
|
|
2559
2515
|
chrome: app chrome sits on --panel, content wells paint --veil, grays ride one neutral tint.
|
|
@@ -2936,22 +2892,22 @@ export function runInference(ctx) {
|
|
|
2936
2892
|
showConfirm();
|
|
2937
2893
|
document.body.appendChild(host);
|
|
2938
2894
|
}
|
|
2939
|
-
`;Sr();
|
|
2940
|
-
${
|
|
2941
|
-
`+z.slice(-4e3)),new
|
|
2942
|
-
Shutting down...`),(
|
|
2943
|
-
${i}`),console.log(` ${l}`),n&&console.log(` ${n}`),process.on("SIGINT",()=>{p()}),process.on("SIGTERM",()=>{p()}),{port:e,url:l,pageCount:()=>
|
|
2944
|
-
`):
|
|
2945
|
-
`):
|
|
2946
|
-
`):console.log(` ${
|
|
2895
|
+
`;Sr();Me();wn();fa();qt();import{stream as a1}from"hono/streaming";var l1="X-TB-Stream";function gi(t){return t instanceof _e?{message:t.message,code:t.code,retryable:t.retryable}:{message:t instanceof Error?t.message:"Unknown error",code:"unknown",retryable:!1}}function xl(t,e){return t.header("Content-Type","application/x-ndjson; charset=utf-8"),t.header("Cache-Control","no-cache"),t.header(l1,"1"),a1(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:gi(s)}))}finally{try{await r.return?.()}catch{}}})}var El={log:(...t)=>console.log(...t)};function Al(t,e){let n=t?.[e]??(Object.hasOwn(El,e)?El[e]:void 0);return typeof n=="function"?n:void 0}function Tl(t){return t.constructor?.name==="AsyncGeneratorFunction"}qd();var c1=/^\/(v\d+\/|stable\/|node\/|gh\/|@[^/]+\/[^@/]+@|[^@/]+@)/,u1=/[?&]target=/,d1=/^\/(?:@[^/]+\/)?[^/@]+\/[^/]+/;function LS(t,e=""){return c1.test(t)?!0:d1.test(t)&&u1.test(e)}var g1="127.0.0.1",y1=new Set(["localhost","127.0.0.1","::1"]),FS=(t,e)=>!!t&&typeof t=="object"&&e in t,MS=t=>{let e={};return Array.isArray(t.data)&&(e.data=t.data),FS(t,"insight")&&(e.insight=t.insight),e},DS=8*1024*1024,b1=0;function w1(t){if(t)try{return new URL(t.includes("://")?t:`http://${t}`).hostname}catch{return}}function US(t){let e=w1(t);return!!e&&y1.has(e)}function v1(t){try{let e=new URL(t);return(e.protocol==="http:"||e.protocol==="https:")&&US(e.host)}catch{return!1}}function S1(t){return!!t&&/\bCode\/\d/.test(t)&&/\bElectron\//.test(t)}function k1(t,e){if(!e)return!1;try{return new URL(t).host===e}catch{return!1}}function yi(t){return t instanceof Error?t.message:"Unknown error"}var BS=t=>t.how==="editor"||t.how==="unreached"?t.via:void 0,x1=2e3;async function qS(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:y,onStop:k}=t,A=`${process.pid}-${++b1}-${Date.now()}`,P=r??n,E=new f1;E.use("*",async(b,x)=>{if(!US(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 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,x)=>{if(!d){let C=new URL(b.req.url).pathname,N=R.find(([W])=>W.endsWith("/*")?C.startsWith(W.slice(0,-2)):C===W)?.[1]??"server-side code (server.ts)";Vu(process.pid,N);let M=f?`
|
|
2896
|
+
${f}`:"";return b.text(`Forbidden: this capability requires --trust.${M}`,403)}await x()},L=async(b,x)=>{let C=b.req.header("sec-fetch-site");if(C){if(C!=="same-origin")return b.text(`Forbidden: ${C} request`,403)}else{let N=b.req.header("origin");if(N&&!k1(N,b.req.header("host")))return b.text("Forbidden: cross-origin request",403)}await x()};for(let[b]of R)E.use(b,I),E.use(b,L);E.use("/__log",L),E.post("/__log",async b=>{try{let{args:x}=await b.req.json();console.log(...x||[])}catch{}return b.json({ok:!0})});let T=new vl,F=new Set,ee=new Set,ne=Date.now();T.onArrival(({page:b,firstAttach:x,count:C})=>{o&&C===1&&console.log(et.connected),x&&C>1&&b.close("yielded").catch(()=>{})}),o&&T.onSettledEmpty(()=>console.log(et.disconnected));let U,re=0,me=async b=>{let x=Math.max(b.fresh?0:ne,T.lastDropAt);if(await T.whenArrives(ep-(Date.now()-x)))return{how:"attached"};if(Date.now()-re<x1)return{how:"none"};let C=`http://localhost:${s}#tb-relay`,N=await Xu(C,n),M;return N?.where==="editor"?M={how:"editor",via:N.via}:(b.external==="force"||b.external==="follow"&&N?.where==="external")&&(await m1(C),M={how:"external"}),M?await T.whenArrives(gS)?M:{how:"unreached",via:BS(M)}:(re=Date.now(),{how:"none"})},Ne=b=>T.count>0?Promise.resolve({how:"attached"}):U??=me(b).finally(()=>{U=void 0});if(o){let b=0,x=new Map;E.use("/__send",L),E.post("/__send",async C=>{let N="";try{N=await C.req.text()}catch{}let M=Number(C.req.query("reply"))||0,W=T.count===0&&C.req.query("open")!==void 0?await Ne({external:"follow",fresh:!1}):void 0,q=T.count,Je=q===0&&T.lastDropAt?Date.now()-T.lastDropAt:void 0,z={clients:q,droppedMsAgo:Je,...W?{opening:W.how,via:BS(W)}:{}};if(C.req.query("solo")!==void 0&&q!==1)return C.json({...z,refused:q>1});if(q===0)return C.json(z);let le=nn=>{for(let Pt of T)Pt.send(nn).catch(()=>{})};if(M<=0)return le({payload:N}),C.json(z);let Oe=++b,jr=await new Promise(nn=>{let Pt={expected:q,received:0,results:[],errors:[],finish:Cl=>{clearTimeout(Pl),x.delete(Oe),nn({results:Pt.results,errors:Pt.errors,timedOut:Cl})}},Pl=setTimeout(()=>Pt.finish(!0),M);x.set(Oe,Pt),le({id:Oe,payload:N})});return C.json({...z,...jr})}),E.use("/__send-reply",L),E.post("/__send-reply",async C=>{try{let{id:N,results:M,errors:W}=await C.req.json(),q=x.get(N);q&&(q.results.push(...M??[]),q.errors.push(...W??[]),++q.received>=q.expected&&q.finish(!1))}catch{}return C.json({ok:!0})})}E.get("/",b=>b.html(e())),E.post("/__fs/read",async b=>{try{let{path:x}=await b.req.json(),C=await Vs(x,P);return new Response(new Uint8Array(C),{headers:{"Content-Type":"application/octet-stream"}})}catch(x){let C=yi(x);return b.json({error:C},400)}}),E.post("/__fs/write",async b=>{try{let x=b.req.query("path");return x?(await Ca(x,new Uint8Array(await b.req.arrayBuffer()),P),b.json({success:!0})):b.json({error:"Missing path"},400)}catch(x){let C=yi(x);return b.json({error:C},400)}}),E.post("/__fs/list",async b=>{try{let{path:x}=await b.req.json();return b.json(await _a(x??".",P))}catch(x){return b.json({error:yi(x)},400)}}),E.post("/__fs/remove",async b=>{try{let{path:x}=await b.req.json();return await Ra(x,P),b.json({success:!0})}catch(x){return b.json({error:yi(x)},400)}}),E.post("/__api/:name",async b=>{try{let x=b.req.param("name"),C=Al(a?.(),x);if(!C)return b.json({error:`API function '${x}' not found`},404);let{args:N}=await b.req.json();if(Tl(C))return xl(b,C(...N||[]));let M=await C(...N||[]);return b.json({result:M})}catch(x){let C=yi(x);return b.json({error:C},500)}}),E.post("/__ai",async b=>{try{let{messages:x,system:C,effort:N,provider:M,model:W,webSearch:q,stream:Je}=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 z=gt(M,W);if(typeof z=="string")return b.json({message:z,code:"unknown",retryable:!1},400);let le=await Wt(z,{messages:x,system:C,effort:N,webSearch:q,signal:b.req.raw.signal});if(!le.ok){let nn=await pr(le,z.protocol);return b.json(nn,le.status)}if(Je)return xl(b,kn(le,z.protocol));let{text:Oe,usage:jr}=await hr(le,z.protocol);return Oe||console.warn("[tb.ai] Empty response from provider"),b.json({text:Oe,usage:jr})}catch(x){return b.json(gi(x),500)}}),E.post("/__infer",async b=>{try{let{data:x}=await b.req.json().catch(()=>({})),C=l?.();if(!C?.infer.trim())return b.json({message:"This bulb has no infer.md block.",code:"unknown",retryable:!1},400);let N=gt();if(typeof N=="string")return b.json({message:N,code:"unknown",retryable:!1},400);let M=Array.isArray(x)?x.map(String):[],W=kd(C,M),q=await Wt(N,{messages:[{role:"user",content:W}],signal:b.req.raw.signal});if(!q.ok){let z=await pr(q,N.protocol);return b.json(z,q.status)}let Je=(async function*(){let z="";for await(let Oe of kn(q,N.protocol))Oe.kind!=="text"||!Oe.text||(z+=Oe.text,yield{kind:"delta",text:Oe.text});let le=xd(z);if(le.parsed===void 0)throw console.warn(`[tb.infer] output not valid JSON after sanitize; raw output (last 4000 chars):
|
|
2897
|
+
`+z.slice(-4e3)),new _e("LLM output is not valid JSON","parse_error",!0);le.fixesApplied.length&&console.warn("[tb.infer] sanitized output, fixes applied:",le.fixesApplied.join(", ")),yield{kind:"complete",insight:le.parsed,data:M,fixesApplied:le.fixesApplied}})();return xl(b,Je)}catch(x){return b.json(gi(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=MS(await b.req.json().catch(()=>({})));return Object.keys(x).length?(await c(x.data,FS(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(gi(x),500)}}),E.get("/__infer-info",b=>{let x=l?.(),C=Ur(x?.config??"").inference,N=Ao(x?.data??""),M=!!x?.infer.trim(),W=gt();return typeof W=="string"?b.json({error:W,inference:C,data:N,hasInfer:M}):b.json({provider:W.protocol,model:W.model,inference:C,data:N,hasInfer:M})}),E.use("/__tb-decode",L),E.post("/__tb-decode",async b=>{let{hash:x}=await b.req.json().catch(()=>({})),C=typeof x=="string"?Ad(x):void 0;return b.json(C??{error:"invalid fragment"})}),E.use("/__tb-encode",L),E.post("/__tb-encode",async b=>{let x=Number(b.req.header("content-length"));if(Number.isFinite(x)&&x>DS)return b.json({hash:""});let C=await b.req.text().catch(()=>"");if(C.length>DS)return b.json({hash:""});let N;try{N=JSON.parse(C)}catch{return b.json({hash:""})}return b.json({hash:Ed(MS(N))})}),E.get("/__infer-ui.js",b=>b.body($S,200,{"Content-Type":"text/javascript; charset=utf-8"})),E.get("/__models",async b=>{try{let x=await mt();return b.json(x)}catch{return b.json([],200)}}),E.get("/__ai-access",async b=>{try{return b.json(await sa())}catch{return b.json("none",200)}}),m&&E.get("/__source/*",async b=>{let x=await ip.readFile(m,"utf-8").catch(()=>{});return x===void 0?b.text("Not Found",404):new Response(x,{headers:{"Content-Type":"text/plain; charset=utf-8"}})});let lt=["esm.sh","unpkg.com","cdn.jsdelivr.net","cdnjs.cloudflare.com"],fe=new kl;E.get("/proxy/*",async b=>{let x=new URL(b.req.url),N=(x.pathname+x.search).slice(7),M=N.lastIndexOf("https://");return M===-1?b.text("Invalid proxy URL",400):Te(b,N.slice(M))}),u&&jS(E,`/local/${u.name}/`,u.serveDir),p&&jS(E,p.mount,p.dir),h&&E.get("/assets/*",async b=>{let{pathname:x}=new URL(b.req.url),C=x.slice(8),N;try{N=decodeURIComponent(C)}catch{return b.text("Not Found",404)}let M=Np(N);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 JS(N,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+C,302):b.text("Not Found",404)});async function Te(b,x){let C;try{C=new URL(x)}catch{return b.text("Invalid URL",400)}if(C.protocol!=="https:")return b.text("HTTPS only",400);if(!lt.includes(C.hostname))return b.text("Host not allowed",403);let N=await fe.get(x);if(N)return new Response(N.body,{status:200,headers:sp(N.contentType,N.cacheControl)});try{let M=await fetch(x,{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[Je,z]=M.body.tee();return(async()=>{try{let le=await new Response(z).arrayBuffer();await fe.set(x,{body:Buffer.from(le),contentType:W,cacheControl:q})}catch{}})(),new Response(Je,{status:M.status,headers:sp(W,q)})}return new Response(null,{status:M.status,headers:sp(W,q)})}catch(M){return b.text(`Proxy fetch failed: ${M instanceof Error?M.message:M}`,502)}}(i||o)&&(E.get("/__reload",b=>h1(b,async x=>{let C=b.req.query("bulb")||void 0;if(y&&C&&C!==y){F.has(C)||(F.add(C),console.log(et.closed("foreign"))),await x.writeSSE({event:"close",data:"foreign"});return}let N=()=>{x.writeSSE({event:"reload",data:""})};i?.on("reload",N);let M=()=>i?.removeListener("reload",N),W=b.req.query("relay")||void 0,q={inEditor:S1(b.req.header("user-agent")),doc:W,open:z=>x.writeSSE({event:"open-url",data:z}),send:z=>x.writeSSE({event:"message",data:JSON.stringify(z)}),close:z=>(M(),T.closing(q),console.log(et.closed(z)),x.writeSSE({event:"close",data:z}))},Je=!!W&&!ee.has(W);for(W&&ee.add(W),T.add(q,Je),x.onAbort(()=>{M(),T.dropped(q)}),await x.writeSSE({event:"hello",data:A,retry:Fd});!x.aborted;)await x.sleep(3e4)})),E.use("/__open",L),E.post("/__open",async b=>{let x="";try{x=String((await b.req.json()).url??"")}catch{}if(!v1(x))return b.json({error:"a local http URL is required"},400);let C=[...T].find(N=>N.inEditor);return await C?.open(x),b.json({opened:!!C,pages:T.count})})),E.use("/__stop",L),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 C=x==="close"?await T.closeAll("stopped"):{told:0,gone:0};return k&&setTimeout(()=>{k({pages:x})},50),b.json({closed:C.gone,stuck:C.told-C.gone,exiting:!!k})}),E.get("/__pages",b=>b.json({pages:T.count})),E.notFound(async b=>{if(b.req.method!=="GET")return b.text("Not Found",404);let x=new URL(b.req.url);return LS(x.pathname,x.search)?Te(b,"https://esm.sh"+x.pathname+x.search):b.text("Not Found",404)});let Ot=p1({fetch:E.fetch,port:s,hostname:g1});return Ot.listening||await new Promise((b,x)=>{let C=N=>x(N);Ot.once("error",C),Ot.once("listening",()=>{Ot.removeListener("error",C),b()})}),{port:s,close:()=>Ot.close(),requestPage:Ne,closePages:b=>T.closeAll(b),pageCount:()=>T.count}}function sp(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 jS(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 JS(decodeURIComponent(s.slice(e.length)),n)??r.text("Not Found",404)}catch{return r.text("Not Found",404)}})}async function JS(t,e,n={}){let r=kr(t,e),s=await ip.readFile(r).catch(()=>{});if(s)return new Response(s,{headers:{"Content-Type":Ip(r),...n}})}Me();pn();async function Ol(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(`
|
|
2898
|
+
Shutting down...`),(m?.pages??(ye(c)?"keep":"close"))==="close"&&await d?.closePages("stopped"),d?.close();for(let y of u)try{await y()}catch{}a(),await hn(process.pid),process.exit(0)}},h=await qS({...r(e),onStop:p}).catch(async m=>{if(m?.code!=="EADDRINUSE")throw m;return Fu(e)});return d=h,await Yu(c),console.log(`
|
|
2899
|
+
${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:y,replacedLive:k}){if(m==="none")return;let A={fresh:y,external:k?"never":m==="window"?"force":"follow"},P=await h.requestPage(A);P.how==="attached"?console.log(` Reusing the open browser tab.
|
|
2900
|
+
`):P.how==="editor"?console.log(` Opened in VS Code via ${P.via}.
|
|
2901
|
+
`):P.how==="external"?console.log(` Opened in your browser.
|
|
2902
|
+
`):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."}
|
|
2947
2903
|
Share ${l}, and wake on the arrival:
|
|
2948
|
-
typebulb wait ${o} --match "${
|
|
2949
|
-
`)},onCleanup(
|
|
2950
|
-
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
|
|
2904
|
+
typebulb wait ${o} --match "${et.connected}"
|
|
2905
|
+
`)},onCleanup(m){u.push(m)}}}pn();import E1 from"chokidar";import WS from"node:fs";import A1 from"node:path";var T1={persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}};function en(t){let{target:e,onChange:n,events:r="change",debounceMs:s=150}=t,i,o=E1.watch(e,T1);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 O1=t=>process.platform==="win32"||process.platform==="darwin"?t.toLowerCase()==="assets":t==="assets";function KS(t,e,n=150){let r,s=()=>{r&&clearTimeout(r),r=setTimeout(e,n)};try{let i=WS.watch(t,{recursive:!0},(o,a)=>{a&&O1(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=A1.join(t,"assets");return WS.existsSync(i)?en({target:i,onChange:e,events:"all",debounceMs:n}):()=>{}}}Me();Ye();Sr();async function HS(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=Cs(process.pid),o=e.watch?new P1:void 0,a=Ee(e.mode),l=(await fn(process.cwd()))(t),c=await er({kind:"bulb",file:t},process.cwd()),u=await Xo(t,c);u.length&&console.log(`Replacing the running server for this bulb (pid ${u.map(me=>me.pid).join(", ")})`);let d=u.length>0||Date.now()-l<Kb,{port:f,note:p}=await Ho({target:{kind:"bulb",file:t},cwd:process.cwd()});c!==void 0&&f!==c&&d&&(console.error(`
|
|
2906
|
+
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(Hu(++h));m(),console.log(`Loading ${$n.basename(t)}...`);let{html:y,bulb:k,serverExports:A}=await Wd(t,e.watch,e.trust,r);Jt(a,t,k.server);let P=Tn(t),E=Er($n.resolve(t)),R=e.trust?void 0:ar(k),{port:I,onCleanup:L,handOver:T,pageCount:F}=await Ol({port:f,portNote:p,displayName:k.name,stopLog:i,makeServerOptions:me=>({getHtml:()=>y,basePath:s,fsBase:xr(t),port:me,reloadEmitter:o,sendChannel:!0,getServerExports:()=>A,getBulbBlocks:()=>({infer:k.infer,insight:k.insight,code:k.code,config:k.config,data:k.data}),saveInferenceResult:async(Ne,lt)=>{let fe=await tn.readFile(t,"utf-8");Ne!==void 0&&(fe=Fr(fe,"data",Ne.join(Ig))),lt!==void 0&&(fe=Fr(fe,"insight",lt)),await tn.writeFile(t,fe)},localOverride:r?{name:r.name,serveDir:r.serveDir}:void 0,bulbAssets:{dir:P,remoteBase:E&&Ti(E.userSlug,E.slug)},sourceFile:t,bulbKey:Os(t),trusted:e.trust,trustHint:n}),makeEntry:(me,Ne)=>({pid:process.pid,port:me,url:Ne,file:t,cwd:process.cwd(),startedAt:Date.now(),trust:e.trust,mode:e.mode,predicted:R}),waitTarget:$n.relative(process.cwd(),t)||$n.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:
|
|
2951
2907
|
${n}
|
|
2952
2908
|
`:` trust: restricted \u2014 re-run with --trust to enable filesystem / AI / server.ts
|
|
2953
2909
|
`),e.watch&&console.log(` Watching for changes...
|
|
2954
|
-
`);let
|
|
2910
|
+
`);let ee,ne,U=()=>{F()===0&&console.log(" No page attached \u2014 nothing reloaded; this change is not live."),o?.emit("reload")},re=me=>{console.log(me),m(),U()};if(e.watch&&o){let me=0,Ne=Promise.resolve();if(ee=en({target:t,onChange:()=>{let fe=++me;Ne=Ne.then(async()=>{if(fe===me)try{console.log("Recompiling...");let Te=await Wd(t,!0,e.trust,r);y=Te.html,A=Te.serverExports,k=Te.bulb,Te.buildError||m(),U()}catch(Te){console.error("Recompile failed:",Te)}})}}),r){let{name:fe,serveDir:Te}=r;ne=en({target:Te,events:"all",onChange:()=>re(`Local package '${fe}' changed.`)})}let lt=xr(t);await tn.stat(lt).then(fe=>fe.isDirectory()).catch(()=>!1)&&L(KS(lt,()=>re("Assets changed.")))}ee&&L(ee),ne&&L(ne),L(()=>tn.rm(Jd(t),{force:!0})),await T({mode:e.open,fresh:!d,replacedLive:u.some(me=>me.port===I)})}it();import{readFileSync as ap,copyFileSync as _1,existsSync as R1}from"fs";import*as he from"path";import{fileURLToPath as I1}from"url";import{EventEmitter as N1}from"events";import $1 from"open";pn();Me();Sr();var op=t=>`/agents/${t}/client.js`,C1=`
|
|
2955
2911
|
(() => {
|
|
2956
2912
|
const api = async (name, ...args) => {
|
|
2957
2913
|
const resp = await fetch('/__api/' + name, {
|
|
@@ -2983,7 +2939,7 @@ Port ${c} is this bulb's, and a page of it may be waiting there, but something e
|
|
|
2983
2939
|
${Ea()}
|
|
2984
2940
|
}
|
|
2985
2941
|
})();
|
|
2986
|
-
`;function
|
|
2942
|
+
`;function zS(t){let{name:e,agent:n,styles:r,katex:s,mountHtml:i,watch:o,theme:a}=t,l=op(n);return`<!DOCTYPE html>
|
|
2987
2943
|
<html>
|
|
2988
2944
|
<head>
|
|
2989
2945
|
<meta charset="utf-8">
|
|
@@ -2991,7 +2947,7 @@ ${Ea()}
|
|
|
2991
2947
|
<title>${ka(e)} - typebulb</title>
|
|
2992
2948
|
${xa(e,a)}
|
|
2993
2949
|
<style>
|
|
2994
|
-
${
|
|
2950
|
+
${Ss}
|
|
2995
2951
|
</style>
|
|
2996
2952
|
<style>
|
|
2997
2953
|
${r}
|
|
@@ -3006,18 +2962,18 @@ ${i}
|
|
|
3006
2962
|
${o?"<script>window.__TYPEBULB_WATCH__ = true;</script>":""}
|
|
3007
2963
|
|
|
3008
2964
|
<script>
|
|
3009
|
-
${
|
|
2965
|
+
${C1}
|
|
3010
2966
|
</script>
|
|
3011
2967
|
|
|
3012
2968
|
<script type="module" src="${l}"></script>
|
|
3013
2969
|
</body>
|
|
3014
|
-
</html>`}async function
|
|
3015
|
-
${r.url}`),t.open==="window"&&await
|
|
3016
|
-
`);async function
|
|
2970
|
+
</html>`}async function YS(t){let e=process.cwd(),n=t.agentTarget;Dv(n)||(console.error(`Unknown agent '${n}'. Known: ${$r().join(", ")}.`),process.exit(1));let r=await Go(e,n);if(r){console.log(`Mirror '${n}' is already running for this project:
|
|
2971
|
+
${r.url}`),t.open==="window"&&await $1(r.url);return}let s=Cs(process.pid),i=t.watch?new N1:void 0,o=Ee(t.mode),a=await Bv(n),l=a.displayName||`${n} mirror`;Jt(o,he.join(e,"mirror"));let c=he.dirname(I1(import.meta.url)),u=he.join(c,"agents",n),d=he.join(c,"..","cli","agents"),f=he.join(u,"styles.css"),p=he.join(u,"katex.min.css"),h=he.join(u,"index.html"),m=()=>zS({name:l,agent:n,styles:ap(f,"utf8"),katex:ap(p,"utf8"),mountHtml:ap(h,"utf8"),watch:t.watch}),{port:y,note:k}=await Ho({explicit:t.port,target:{kind:"mirror",agent:n},cwd:e}),{port:A,url:P,onCleanup:E,handOver:R,pageCount:I}=await Ol({port:y,portNote:k,displayName:l,stopLog:s,waitTarget:"agent",makeServerOptions:U=>({getHtml:m,basePath:e,port:U,reloadEmitter:i,getServerExports:()=>a,trusted:!0,staticAssets:{mount:`${he.posix.dirname(op(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=he.join(d,n,"client"),T=he.join(d,"core","client"),F=R1(L);t.watch&&F&&console.log(` Watching for changes...
|
|
2972
|
+
`);async function ee(){await(await import("esbuild")).build({entryPoints:[he.join(L,"index.ts")],bundle:!0,platform:"browser",format:"esm",outfile:he.join(u,"client.js")});for(let re of["styles.css","index.html","typebulb.png","typebulb-inv.png"])_1(he.join(T,re),he.join(u,re))}let ne;if(t.watch&&F&&i){let U=!1;ne=en({target:d,events:"all",onChange:async()=>{if(!U){U=!0;try{await ee(),console.log(I()?`Mirror rebuilt. Reloading.
|
|
3017
2973
|
`:`Mirror rebuilt. No tab open on it \u2014 nobody is reading this.
|
|
3018
|
-
`),i.emit("reload")}catch(
|
|
3019
|
-
`);let a=0,l=Promise.resolve();
|
|
3020
|
-
`)}catch(
|
|
3021
|
-
`),
|
|
3022
|
-
`),process.exit(1)}function
|
|
3023
|
-
${e}`),process.exit(1))}async function
|
|
2974
|
+
`),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}),E(()=>a.shutdownSwitcher?.()),E(()=>a.shutdownComposer?.()),ne&&E(ne)}it();St();import*as VS from"path";async function GS(t,e,n,r){let s=Ee(n),i=!1,o=async()=>{let{bulb:a,config:l}=await Ze(t);i||(Jt(s,t,a.server),i=!0),await Gs(a.server,t,r,l.dependencies)};if(console.log(`Running ${VS.basename(t)}...`),await o(),e){console.log(`Watching for changes...
|
|
2975
|
+
`);let a=0,l=Promise.resolve();en({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)}})}})}}it();St();import{Console as L1}from"node:console";Me();async function ZS(t,e,n,r){F1();try{let f=mn(await X(),t)[0];f&&(Ps(f.pid,Ve(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=Ee(n),{bulb:i,config:o}=await Ze(t);i.server||bi("This bulb has no **server.ts** block; nothing to call."),Jt(s,t,i.server);let a;try{a=await Gs(i.server,t,r,o.dependencies)}catch(f){bi(f instanceof Error?f.message:String(f))}let l=Al(a,e.fn);if(!l){let f=[...Object.keys(a).filter(p=>typeof a[p]=="function"),...Object.keys(El)];bi(`Function '${e.fn}' not found. Available: ${f.length?f.join(", "):"(none)"}.`)}let c=await M1(e);if(Tl(l)){try{for await(let f of l(...c))await QS(JSON.stringify(f,ek)+`
|
|
2976
|
+
`)}catch(f){bi(f instanceof Error?f.stack??f.message:String(f))}return XS(0)}let u;try{u=await l(...c)}catch(f){bi(f instanceof Error?f.stack??f.message:String(f))}let d=j1(u);d!==void 0&&await QS(d+`
|
|
2977
|
+
`),XS(0)}function XS(t){process.exitCode=t,setTimeout(()=>process.exit(t),2e3).unref?.()}async function M1(t){if(t.hasArgsFlag){let e=t.argsJson??"";return e==="-"&&(e=await Br()),B1(e)}return D1(t.positional)}function D1(t){return t.map(e=>{try{return JSON.parse(e)}catch{return e}})}function B1(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 j1(t){if(t!==void 0)return JSON.stringify(t,ek,2)}function ek(t,e){return typeof e=="bigint"?e.toString():e}function bi(t){process.stderr.write(t+`
|
|
2978
|
+
`),process.exit(1)}function F1(){let t=new L1(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 QS(t){return new Promise((e,n)=>{process.stdout.write(t,r=>r?n(r):e())})}zo();for(let t of[process.stdout,process.stderr])t.on("error",e=>{if(e?.code!=="EPIPE")throw e});function tk(t,e){t||(console.error(`This bulb runs server-side Node code (server.ts), which --trust must authorize:
|
|
2979
|
+
${e}`),process.exit(1))}async function U1(){let t=Uv(process.argv.slice(2));if(t.version&&(console.log(`typebulb ${De}`),process.exit(0)),t.help&&(qv(),process.exit(0)),jv(),t.subcommand==="logs"){await SS(t.file||void 0,{follow:t.follow,clear:t.clear,run:t.run,lines:t.lines});return}if(t.subcommand==="wait"){await kS(t.file||void 0,{match:t.match,timeoutSec:t.timeoutSec});return}if(t.subcommand==="stop"){t.stopScope?await AS(t.stopScope):await ES(t.file||void 0);return}if(t.subcommand==="send"){await OS(t.file,t.sendMessage,t.sendWaitMs??0);return}if(t.subcommand==="models"){await hS(t.mode);return}if(t.subcommand==="slug"){mS(t.slugName);return}if(t.subcommand==="status"){await NS(t.statusQuery,t.mode);return}if(t.subcommand==="pull"){await nw(t.file||void 0,{force:t.force,mode:t.mode});return}if(t.subcommand==="push"){await sw(t.file||void 0,{force:t.force,mode:t.mode});return}if(t.subcommand==="agent"){await(t.agentTarget?YS(t):pS(De));return}if(t.subcommand==="trust"||t.subcommand==="untrust"){await cS(t.file||void 0,t.subcommand==="trust");return}let e;if(!t.file||t.file==="."){let l=await ew(process.cwd());l||(console.error("No .bulb.md file found in current directory"),process.exit(1)),e=l}else e=Tt.resolve(t.file);if(await nk.access(e).then(()=>!0,()=>!1)||($r().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}`+(Tt.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 CS(e,t.blockKind);return}if(t.subcommand==="put"){await IS(e,t.blockPairs);return}let r=t.file&&t.file!=="."?t.file:Tt.relative(process.cwd(),e)||Tt.basename(e),s=`npx typebulb --trust ${r.includes(" ")?`"${r}"`:r}`;if(t.subcommand==="predict"){await lS(e,s);return}let i=!t.noTrust&&bn(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 Ze(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 gp(t.local)}catch(l){console.error(l instanceof Error?l.message:String(l)),process.exit(1)}console.error(`replace: ${a.name} \u2192 ${Tt.relative(process.cwd(),a.dir)||"."}`)}if(t.subcommand==="check"){await aS(e,a);return}if(t.subcommand==="call"){tk(t.trust,s),await ZS(e,{fn:t.fn,positional:t.callArgs,argsJson:t.argsJson,hasArgsFlag:t.hasArgsFlag},t.mode,a);return}if(o&&o.bulb.server&&(Qo(o.bulb)||t.server)){tk(t.trust,s),await GS(e,t.watch,t.mode,a);return}await HS(e,t,s,a)}U1().catch(t=>{console.error("Error:",t.message),process.exit(1)});
|