typebulb 0.61.13 → 0.62.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/SKILL.md +8 -6
- package/dist/agents/claude/client.js +248 -258
- package/dist/agents/claude/styles.css +47 -62
- package/dist/agents/codex/client.js +303 -313
- package/dist/agents/codex/styles.css +47 -62
- package/dist/agents/pi/client.js +264 -274
- package/dist/agents/pi/styles.css +47 -62
- package/dist/index.js +318 -337
- package/dist/servers.js +1 -1
- 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 qk=Object.create;var Bl=Object.defineProperty;var Jk=Object.getOwnPropertyDescriptor;var Wk=Object.getOwnPropertyNames;var Kk=Object.getPrototypeOf,Hk=Object.prototype.hasOwnProperty;var Ei=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var S=(t,e)=>()=>(t&&(e=t(t=0)),e);var _=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Ai=(t,e)=>{for(var n in e)Bl(t,n,{get:e[n],enumerable:!0})},zk=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Wk(e))!Hk.call(t,s)&&s!==n&&Bl(t,s,{get:()=>e[s],enumerable:!(r=Jk(e,s))||r.enumerable});return t};var Yk=(t,e,n)=>(n=t!=null?qk(Kk(t)):{},zk(e||!t||!t.__esModule?Bl(n,"default",{value:t,enumerable:!0}):n,t));import*as Ap from"fs/promises";import{existsSync as Fn,readFileSync as Vk}from"fs";import*as ae from"path";import{pathToFileURL as Gk}from"url";import{resolve as Fl}from"resolve.exports";import{init as Tp,parse as Cp}from"es-module-lexer";function Op(t,e){let n=ae.join(t,"package.json");try{return JSON.parse(Vk(n,"utf8"))}catch{throw new Error(`--replace package '${e}' has no readable package.json at ${n}`)}}function Pp(t){let e=t.indexOf("=");if(e===-1)throw new Error(`--replace must be <name>=<path> (got '${t}')`);let n=t.slice(0,e).trim(),r=t.slice(e+1).trim();if(!n)throw new Error(`--replace missing package name (got '${t}')`);if(!r)throw new Error(`--replace missing path for '${n}'`);if(n.startsWith("@"))throw new Error(`--replace does not support scoped names yet; '${n}' is scoped`);return{name:n,dir:ae.resolve(r)}}async function _p(t){let{name:e,dir:n}=t;if(!Fn(n))throw new Error(`--replace path for '${e}' does not exist: ${n}`);let r=Op(n,e),s=Xk(r,e),i=ae.resolve(n,s);if(!Fn(i))throw new Error(`--replace package '${e}' entry not found on disk: ${i} \u2014 did you build it (e.g. \`pnpm run build\`)?`);let o=ae.dirname(i),a=`/local/${e}/${ae.basename(i)}`,l=Qk(r,n);return await Zk(e,i,o),{name:e,dir:n,entryAbs:i,serveDir:o,entryUrl:a,typesAbs:l}}function Xk(t,e){if(t.exports!==void 0){let r;try{r=Fl(t,".",{browser:!0,conditions:jl})}catch(i){throw new Error(`--replace package '${e}' "exports" does not resolve a browser entry (conditions: ${jl.join(", ")}): ${i instanceof Error?i.message:i}`)}let s=Ul(r);if(!s)throw new Error(`--replace package '${e}' "exports" did not resolve "." to a single file (conditions: ${jl.join(", ")}); too complex to override.`);return s}let n=t.module??t.main;if(!n)throw new Error(`--replace package '${e}' has no "exports", "module", or "main" entry to resolve.`);return n}function Qk(t,e){if(t.exports!==void 0)try{let r=Fl(t,".",{conditions:["types"]}),s=Ul(r);if(s){let i=ae.resolve(e,s);if(Fn(i))return i}}catch{}let n=t.types??t.typings;if(n){let r=ae.resolve(e,n);if(Fn(r))return r}}function Ul(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.find(e=>typeof e=="string")}async function Zk(t,e,n){await Tp;let r=ae.normalize(n),s=new Set,i=[e];for(;i.length;){let o=i.shift();if(s.has(o))continue;s.add(o);let a;try{a=await Ap.readFile(o,"utf8")}catch{continue}let l,c;try{[l,,,c]=Cp(a,o)}catch{continue}if(o===e&&!c)throw new Error(`override package '${t}' entry is not an ES module (no import/export syntax); CommonJS or non-module entries aren't supported (esm.sh would have to transform it).`);for(let u of l){if(u.d===-2)continue;let d=u.n;if(d&&!d.startsWith("node:")){if(d.startsWith("./")||d.startsWith("../")||d.startsWith("/")){let f=ex(o,d,r);f&&!s.has(f)&&i.push(f);continue}throw new Error(`override package must ship self-contained (bundle its dependencies); ${t} externalizes '${d}'`)}}}}function ex(t,e,n){let r=e.replace(/[?#].*$/,""),s=ae.resolve(ae.dirname(t),r),i=[s,s+".js",s+".mjs",ae.join(s,"index.js"),ae.join(s,"index.mjs")];for(let o of i)if(ae.normalize(o).startsWith(n)&&Fn(o))return o}function tx(t,e,n){let r=Op(t,e),s;if(r.exports!==void 0)try{s=Ul(Fl(r,n,{conditions:Ep}))}catch(o){throw new Error(`--replace package '${e}' "exports" does not resolve a node entry for '${n}' (conditions: ${Ep.join(", ")}): ${o instanceof Error?o.message:o}`)}else n==="."&&(s=r.main??r.module);if(!s)throw new Error(`--replace package '${e}' has no node export for '${n}'.`);let i=ae.resolve(t,s);if(!Fn(i))throw new Error(`--replace package '${e}' built file not found: ${i} \u2014 did you build it (e.g. \`pnpm run build\`)?`);return Gk(i).href}async function Rp(t,e){await Tp;let n;try{[n]=Cp(t)}catch{return t}let r="",s=0;for(let i of n){if(i.d!==-1)continue;let o=i.n;if(!o||o!==e.name&&!o.startsWith(e.name+"/"))continue;let a=o===e.name?".":"."+o.slice(e.name.length),l=tx(e.dir,e.name,a);r+=t.slice(s,i.s)+l,s=i.e}return r+t.slice(s)}var jl,Ep,Ti=S(()=>{"use strict";jl=["browser","import","default"],Ep=["node","import","default"]});function Ip(t){return He.find(e=>de[e].path===t)}function Np(t){return!!t?.startsWith("typebulb")}var de,He,$p,Ci=S(()=>{de={code:{path:"code.tsx",language:"typescript"},css:{path:"styles.css",language:"css"},html:{path:"index.html",language:"html"},config:{path:"config.json",language:"json"},notes:{path:"notes.md",language:"markdown"},data:{path:"data.txt",language:"text"},infer:{path:"infer.md",language:"markdown"},insight:{path:"insight.json",language:"json"}},He=["code","css","html","data","infer","insight","config","notes"];$p="typebulb/v1"});function ql(t){return/[:\n"']/.test(t)||t.startsWith(" ")||t.endsWith(" ")?`"${t.replace(/"/g,'\\"')}"`:t}function Jl(t){return t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1).replace(/\\"/g,'"'):t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}var Oi=S(()=>{});function Un(t){let e=Mp(t);if("reason"in e)throw new Error(`Invalid .bulb.md file format: ${e.reason}`);return e.bulb}function ze(t){let e=Mp(t);return"bulb"in e?e.bulb:void 0}function Mp(t){try{let e=t.split(`
|
|
4
|
+
`),n=0;if(e[n]?.trim()!=="---")return{reason:rx(t,e)};n++;let r=[];for(;n<e.length&&e[n]?.trim()!=="---";)r.push(e[n]),n++;if(e[n]?.trim()!=="---")return{reason:"the frontmatter opened on line 1 but never closed (no second '---')"};n++;let s=ox(r);if(!Np(s.format))return{reason:s.format?`frontmatter 'format: ${s.format}' is not a typebulb format (expected 'format: typebulb/v1')`:"frontmatter has no 'format:' (expected 'format: typebulb/v1')"};if(!s.name)return{reason:"frontmatter has no 'name:'"};let i=s,o=new Map,a=new Map,l=[],c=n;for(;n<e.length;){let d=e[n]?.trim()?.match(Lp);if(d){let f=d[1].trim();for(n++;n<e.length&&e[n]?.trim()==="";)n++;let p=e[n]?.match(Pi);if(!p){l.push(`**${f}** has no code fence \u2014 block skipped`);continue}let h=p[1];n++;let m=n+1,g=[],v=Wl(h);for(;n<e.length&&!e[n]?.match(v);)g.push(e[n]),n++;let A=n<e.length;n++,l.push(...sx(f,g,A)),o.set(f,g.join(`
|
|
5
|
+
`)),a.set(f,m),c=n}else n++}return{bulb:{frontmatter:i,files:o,warnings:l,bodyEndLine:c,starts:a}}}catch(e){return{reason:`unexpected parse error: ${e instanceof Error?e.message:String(e)}`}}}function rx(t,e){let n=ax(t)[0];if(n&&n.start>0)return`expected '---' on line 1; the frontmatter starts on line ${n.start+1} instead. Is there content above it?`;let r=e.find(s=>s.trim())?.trim()??"";return r?`expected '---' on line 1, found '${r.length>40?`${r.slice(0,40)}\u2026`:r}'`:"expected '---' on line 1, found an empty file"}function sx(t,e,n){let r=[];for(let s=0;s<e.length;s++){let i=e[s]?.trim().match(Lp);i&&nx.has(i[1].trim())&&ix(e,s)&&r.push(i[1].trim())}return r.length?r.map(s=>`**${t}** block has an unterminated code fence \u2014 it swallowed the **${s}** block.`):n?[]:[`**${t}** block has an unterminated code fence (it runs to the end of the file).`]}function ix(t,e){let n=e+1;for(;n<t.length&&t[n]?.trim()==="";)n++;return!!t[n]?.match(Pi)}function ox(t){let e={};for(let n of t){let r=n.indexOf(":");if(r===-1)continue;let s=n.slice(0,r).trim(),i=n.slice(r+1).trim();switch(s){case"format":e.format=i;break;case"name":e.name=Jl(i);break}}return e}function Dp(t){return ze(t)?.warnings??[]}function ax(t){let e=t.split(`
|
|
6
|
+
`),n=[],r=0;for(;r<e.length;){if(e[r]?.trim()!=="---"){r++;continue}let s=ze(e.slice(r).join(`
|
|
7
7
|
`));if(s&&s.files.size>0){let i=r+s.bodyEndLine;n.push({start:r,end:i,source:e.slice(r,i).join(`
|
|
8
|
-
`)}),r=i}else r++}return n}function
|
|
8
|
+
`)}),r=i}else r++}return n}function Bp(t){let e=Object.fromEntries(He.map(n=>[n,t.files.get(de[n].path)||""]));return{name:t.frontmatter.name,...e}}var Lp,Pi,nx,Wl,Kl=S(()=>{Ci();Oi();Lp=/^\*\*(.+)\*\*$/,Pi=/^(`{3,})(\w*)\s*$/,nx=new Set(He.map(t=>de[t].path)),Wl=t=>new RegExp(`^${t}\\s*$`)});function jp(t){let e=t.match(/^`{3,}/gm),n=e?Math.max(...e.map(r=>r.length)):0;return"`".repeat(Math.max(3,n+1))}function Fp(t,e){let{path:n}=de[t],r=n.split(".").pop(),s=jp(e);return`**${n}**
|
|
9
9
|
|
|
10
10
|
${s}${r}
|
|
11
11
|
${e}
|
|
12
|
-
${s}`}function
|
|
13
|
-
`)}function
|
|
14
|
-
`),s=
|
|
12
|
+
${s}`}function Up(t){let e=He.filter(n=>t[n]).map(n=>Fp(n,t[n]));return["---",`format: ${$p}`,`name: ${ql(t.name)}`,"---","",...e].join(`
|
|
13
|
+
`)}function qp(t,e){for(let n=0;n<t.length;n++){if(t[n]?.trim()!==`**${e}**`)continue;let r=n+1;for(;r<t.length&&t[r]?.trim()==="";)r++;let s=t[r]?.match(Pi);if(!s)continue;let i=Wl(s[1]),o=r+1;for(;o<t.length&&!t[o]?.match(i);)o++;return o>=t.length?"unterminated":{header:n,open:r,close:o,fence:s[1],lang:s[2]}}}function Wr(t,e,n){let r=t.split(`
|
|
14
|
+
`),s=qp(r,de[e].path);if(s==="unterminated")return t;if(!s)return`${t.replace(/\s*$/,"")}
|
|
15
15
|
|
|
16
|
-
${
|
|
17
|
-
`;let i=
|
|
16
|
+
${Fp(e,n)}
|
|
17
|
+
`;let i=jp(n),o=i.length>s.fence.length?i:s.fence;return[...r.slice(0,s.open),o+s.lang,...n.split(`
|
|
18
18
|
`),o,...r.slice(s.close+1)].join(`
|
|
19
|
-
`)}function
|
|
20
|
-
`),r=
|
|
19
|
+
`)}function Jp(t,e){let n=t.split(`
|
|
20
|
+
`),r=qp(n,de[e].path);if(!r||r==="unterminated")return t;let s=r.close+1;for(;s<n.length&&n[s]?.trim()==="";)s++;return[...n.slice(0,r.header),...n.slice(s)].join(`
|
|
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 Wp=S(()=>{Ci();Kl();Oi()});function Kr(t){if(!t.trim())return{};try{return JSON.parse(t)}catch{return{}}}function Hp(t){switch(Kp(t)){case".js":case".mjs":return"text/javascript";case".wasm":return"application/wasm";case".json":case".map":return"application/json";case".svg":return"image/svg+xml";case".png":return"image/png";case".jpg":case".jpeg":return"image/jpeg";case".gif":return"image/gif";case".webp":return"image/webp";case".avif":return"image/avif";case".ico":return"image/x-icon";case".mp3":return"audio/mpeg";case".wav":return"audio/wav";case".ogg":return"audio/ogg";case".m4a":return"audio/mp4";case".mp4":return"video/mp4";case".webm":return"video/webm";case".woff2":return"font/woff2";case".ttf":return"font/ttf";case".css":return"text/css";case".txt":return"text/plain; charset=utf-8";default:return"application/octet-stream"}}function zp(t){let e=Kp(t);return e!==void 0&&cx.has(e)?e:void 0}function dx(t){return t.replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\*\*([^*]+)\*\*/g,"$1").replace(/\*([^*]+)\*/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/^#{1,6}\s+/gm,"")}function Hl(t){let e=Kr(t??"").description?.trim();if(!e)return ux;let n=dx(e);return(n.length>200?n.slice(0,197)+"...":n).replace(/\n/g," ")}var lx,_i,Kp,cx,ux,Yp=S(()=>{lx="https://assets.typebulb.com",_i=(t,e)=>`${lx}/u/${encodeURIComponent(t)}/${encodeURIComponent(e)}/`,Kp=t=>/\.[^./\\]+$/.exec(t)?.[0]?.toLowerCase();cx=new Set([".html",".htm",".xhtml",".js",".mjs",".cjs",".ts",".tsx",".css"]);ux="A Typebulb bulb."});var Vp=S(()=>{});function zl(t,e,n){let s=new RegExp(e).exec(t.slice(n));return s?n+s.index:-1}var Gp=S(()=>{});function Hr(t,e,n){let s=new RegExp(e).exec(t.slice(n));return s?n+s.index+s[0].length-1:-1}var Xp=S(()=>{});function Ri(t,e){let n=new RegExp(e,"g"),r=t.match(n);return r?r.length:0}var Qp=S(()=>{});function zr(t,e,n){let r=n&&n.debug||!1,s=!(n&&typeof n.nested===!1),i=n&&n.startIndex||0;r&&console.log("[xml-utils] starting findTagByName with",e," and ",n);let o=zl(t,`<${e}[
|
|
23
|
+
>/]`,i);if(r&&console.log("[xml-utils] start:",o),o===-1)return;let a=t.slice(o+e.length),l=Hr(a,"^[^<]*[ /]>",0),c=l!==-1&&a[l-1]==="/";if(r&&console.log("[xml-utils] selfClosing:",c),c===!1)if(s){let p=0,h=1,m=0;for(;(l=Hr(a,"[ /]"+e+">",p))!==-1;){let g=a.substring(p,l+1);if(h+=Ri(g,"<"+e+`[
|
|
24
|
+
>]`),m+=Ri(g,"</"+e+">"),m>=h)break;p=l}}else l=Hr(a,"[ /]"+e+">",0);let u=o+e.length+l+1;if(r&&console.log("[xml-utils] end:",u),u===-1)return;let d=t.slice(o,u),f;return c?f=null:f=d.slice(d.indexOf(">")+1,d.lastIndexOf("<")),{inner:f,outer:d,start:o,end:u}}var Yl=S(()=>{Gp();Xp();Qp()});var Vl=S(()=>{Yl()});var Gl=S(()=>{Vl()});var Zp=S(()=>{Gl()});var eh=S(()=>{});var th=S(()=>{Vp();Yl();Vl();Zp();Gl();eh()});var J=_(he=>{"use strict";var Xl=Symbol.for("yaml.alias"),nh=Symbol.for("yaml.document"),Ii=Symbol.for("yaml.map"),rh=Symbol.for("yaml.pair"),Ql=Symbol.for("yaml.scalar"),$i=Symbol.for("yaml.seq"),ft=Symbol.for("yaml.node.type"),hx=t=>!!t&&typeof t=="object"&&t[ft]===Xl,mx=t=>!!t&&typeof t=="object"&&t[ft]===nh,gx=t=>!!t&&typeof t=="object"&&t[ft]===Ii,yx=t=>!!t&&typeof t=="object"&&t[ft]===rh,sh=t=>!!t&&typeof t=="object"&&t[ft]===Ql,bx=t=>!!t&&typeof t=="object"&&t[ft]===$i;function ih(t){if(t&&typeof t=="object")switch(t[ft]){case Ii:case $i:return!0}return!1}function wx(t){if(t&&typeof t=="object")switch(t[ft]){case Xl:case Ii:case Ql:case $i:return!0}return!1}var vx=t=>(sh(t)||ih(t))&&!!t.anchor;he.ALIAS=Xl;he.DOC=nh;he.MAP=Ii;he.NODE_TYPE=ft;he.PAIR=rh;he.SCALAR=Ql;he.SEQ=$i;he.hasAnchor=vx;he.isAlias=hx;he.isCollection=ih;he.isDocument=mx;he.isMap=gx;he.isNode=wx;he.isPair=yx;he.isScalar=sh;he.isSeq=bx});var Yr=_(Zl=>{"use strict";var le=J(),ke=Symbol("break visit"),oh=Symbol("skip children"),st=Symbol("remove node");function Ni(t,e){let n=ah(e);le.isDocument(t)?qn(null,t.contents,n,Object.freeze([t]))===st&&(t.contents=null):qn(null,t,n,Object.freeze([]))}Ni.BREAK=ke;Ni.SKIP=oh;Ni.REMOVE=st;function qn(t,e,n,r){let s=lh(t,e,n,r);if(le.isNode(s)||le.isPair(s))return ch(t,r,s),qn(t,s,n,r);if(typeof s!="symbol"){if(le.isCollection(e)){r=Object.freeze(r.concat(e));for(let i=0;i<e.items.length;++i){let o=qn(i,e.items[i],n,r);if(typeof o=="number")i=o-1;else{if(o===ke)return ke;o===st&&(e.items.splice(i,1),i-=1)}}}else if(le.isPair(e)){r=Object.freeze(r.concat(e));let i=qn("key",e.key,n,r);if(i===ke)return ke;i===st&&(e.key=null);let o=qn("value",e.value,n,r);if(o===ke)return ke;o===st&&(e.value=null)}}return s}async function Li(t,e){let n=ah(e);le.isDocument(t)?await Jn(null,t.contents,n,Object.freeze([t]))===st&&(t.contents=null):await Jn(null,t,n,Object.freeze([]))}Li.BREAK=ke;Li.SKIP=oh;Li.REMOVE=st;async function Jn(t,e,n,r){let s=await lh(t,e,n,r);if(le.isNode(s)||le.isPair(s))return ch(t,r,s),Jn(t,s,n,r);if(typeof s!="symbol"){if(le.isCollection(e)){r=Object.freeze(r.concat(e));for(let i=0;i<e.items.length;++i){let o=await Jn(i,e.items[i],n,r);if(typeof o=="number")i=o-1;else{if(o===ke)return ke;o===st&&(e.items.splice(i,1),i-=1)}}}else if(le.isPair(e)){r=Object.freeze(r.concat(e));let i=await Jn("key",e.key,n,r);if(i===ke)return ke;i===st&&(e.key=null);let o=await Jn("value",e.value,n,r);if(o===ke)return ke;o===st&&(e.value=null)}}return s}function ah(t){return typeof t=="object"&&(t.Collection||t.Node||t.Value)?Object.assign({Alias:t.Node,Map:t.Node,Scalar:t.Node,Seq:t.Node},t.Value&&{Map:t.Value,Scalar:t.Value,Seq:t.Value},t.Collection&&{Map:t.Collection,Seq:t.Collection},t):t}function lh(t,e,n,r){if(typeof n=="function")return n(t,e,r);if(le.isMap(e))return n.Map?.(t,e,r);if(le.isSeq(e))return n.Seq?.(t,e,r);if(le.isPair(e))return n.Pair?.(t,e,r);if(le.isScalar(e))return n.Scalar?.(t,e,r);if(le.isAlias(e))return n.Alias?.(t,e,r)}function ch(t,e,n){let r=e[e.length-1];if(le.isCollection(r))r.items[t]=n;else if(le.isPair(r))t==="key"?r.key=n:r.value=n;else if(le.isDocument(r))r.contents=n;else{let s=le.isAlias(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${s} parent`)}}Zl.visit=Ni;Zl.visitAsync=Li});var ec=_(dh=>{"use strict";var uh=J(),Sx=Yr(),kx={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},xx=t=>t.replace(/[!,[\]{}]/g,e=>kx[e]),Vr=class t{constructor(e,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},t.defaultYaml,e),this.tags=Object.assign({},t.defaultTags,n)}clone(){let e=new t(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new t(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:t.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},t.defaultTags);break}return e}add(e,n){this.atNextDocument&&(this.yaml={explicit:t.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},t.defaultTags),this.atNextDocument=!1);let r=e.trim().split(/[ \t]+/),s=r.shift();switch(s){case"%TAG":{if(r.length!==2&&(n(0,"%TAG directive should contain exactly two parts"),r.length<2))return!1;let[i,o]=r;return this.tags[i]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,r.length!==1)return n(0,"%YAML directive should contain exactly one part"),!1;let[i]=r;if(i==="1.1"||i==="1.2")return this.yaml.version=i,!0;{let o=/^\d+\.\d+$/.test(i);return n(6,`Unsupported YAML version ${i}`,o),!1}}default:return n(0,`Unknown directive ${s}`,!0),!1}}tagName(e,n){if(e==="!")return"!";if(e[0]!=="!")return n(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let o=e.slice(2,-1);return o==="!"||o==="!!"?(n(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&n("Verbatim tags must end with a >"),o)}let[,r,s]=e.match(/^(.*!)([^!]*)$/s);s||n(`The ${e} tag has no suffix`);let i=this.tags[r];if(i)try{return i+decodeURIComponent(s)}catch(o){return n(String(o)),null}return r==="!"?e:(n(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[n,r]of Object.entries(this.tags))if(e.startsWith(r))return n+xx(e.substring(r.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let n=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags),s;if(e&&r.length>0&&uh.isNode(e.contents)){let i={};Sx.visit(e.contents,(o,a)=>{uh.isNode(a)&&a.tag&&(i[a.tag]=!0)}),s=Object.keys(i)}else s=[];for(let[i,o]of r)i==="!!"&&o==="tag:yaml.org,2002:"||(!e||s.some(a=>a.startsWith(o)))&&n.push(`%TAG ${i} ${o}`);return n.join(`
|
|
25
|
+
`)}};Vr.defaultYaml={explicit:!1,version:"1.2"};Vr.defaultTags={"!!":"tag:yaml.org,2002:"};dh.Directives=Vr});var Mi=_(Gr=>{"use strict";var fh=J(),Ex=Yr();function Ax(t){if(/[\x00-\x19\s,[\]{}]/.test(t)){let n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(t)}`;throw new Error(n)}return!0}function ph(t){let e=new Set;return Ex.visit(t,{Value(n,r){r.anchor&&e.add(r.anchor)}}),e}function hh(t,e){for(let n=1;;++n){let r=`${t}${n}`;if(!e.has(r))return r}}function Tx(t,e){let n=[],r=new Map,s=null;return{onAnchor:i=>{n.push(i),s??(s=ph(t));let o=hh(e,s);return s.add(o),o},setAnchors:()=>{for(let i of n){let o=r.get(i);if(typeof o=="object"&&o.anchor&&(fh.isScalar(o.node)||fh.isCollection(o.node)))o.node.anchor=o.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=i,a}}},sourceObjects:r}}Gr.anchorIsValid=Ax;Gr.anchorNames=ph;Gr.createNodeAnchors=Tx;Gr.findNewAnchor=hh});var tc=_(mh=>{"use strict";function Xr(t,e,n,r){if(r&&typeof r=="object")if(Array.isArray(r))for(let s=0,i=r.length;s<i;++s){let o=r[s],a=Xr(t,r,String(s),o);a===void 0?delete r[s]:a!==o&&(r[s]=a)}else if(r instanceof Map)for(let s of Array.from(r.keys())){let i=r.get(s),o=Xr(t,r,s,i);o===void 0?r.delete(s):o!==i&&r.set(s,o)}else if(r instanceof Set)for(let s of Array.from(r)){let i=Xr(t,r,s,s);i===void 0?r.delete(s):i!==s&&(r.delete(s),r.add(i))}else for(let[s,i]of Object.entries(r)){let o=Xr(t,r,s,i);o===void 0?delete r[s]:o!==i&&(r[s]=o)}return t.call(e,n,r)}mh.applyReviver=Xr});var _t=_(yh=>{"use strict";var Cx=J();function gh(t,e,n){if(Array.isArray(t))return t.map((r,s)=>gh(r,String(s),n));if(t&&typeof t.toJSON=="function"){if(!n||!Cx.hasAnchor(t))return t.toJSON(e,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(t,r),n.onCreate=i=>{r.res=i,delete n.onCreate};let s=t.toJSON(e,n);return n.onCreate&&n.onCreate(s),s}return typeof t=="bigint"&&!n?.keep?Number(t):t}yh.toJS=gh});var Di=_(wh=>{"use strict";var Ox=tc(),bh=J(),Px=_t(),nc=class{constructor(e){Object.defineProperty(this,bh.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:n,maxAliasCount:r,onAnchor:s,reviver:i}={}){if(!bh.isDocument(e))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:e,keep:!0,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},a=Px.toJS(this,"",o);if(typeof s=="function")for(let{count:l,res:c}of o.anchors.values())s(c,l);return typeof i=="function"?Ox.applyReviver(i,{"":a},"",a):a}};wh.NodeBase=nc});var Qr=_(vh=>{"use strict";var _x=Mi(),Rx=Yr(),Wn=J(),Ix=Di(),$x=_t(),rc=class extends Ix.NodeBase{constructor(e){super(Wn.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,n){let r;n?.aliasResolveCache?r=n.aliasResolveCache:(r=[],Rx.visit(e,{Node:(i,o)=>{(Wn.isAlias(o)||Wn.hasAnchor(o))&&r.push(o)}}),n&&(n.aliasResolveCache=r));let s;for(let i of r){if(i===this)break;i.anchor===this.source&&(s=i)}return s}toJSON(e,n){if(!n)return{source:this.source};let{anchors:r,doc:s,maxAliasCount:i}=n,o=this.resolve(s,n);if(!o){let l=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(l)}let a=r.get(o);if(a||($x.toJS(o,null,n),a=r.get(o)),a?.res===void 0){let l="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(l)}if(i>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=Bi(s,o,r)),a.count*a.aliasCount>i)){let l="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(l)}return a.res}toString(e,n,r){let s=`*${this.source}`;if(e){if(_x.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let i=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(i)}if(e.implicitKey)return`${s} `}return s}};function Bi(t,e,n){if(Wn.isAlias(e)){let r=e.resolve(t),s=n&&r&&n.get(r);return s?s.count*s.aliasCount:0}else if(Wn.isCollection(e)){let r=0;for(let s of e.items){let i=Bi(t,s,n);i>r&&(r=i)}return r}else if(Wn.isPair(e)){let r=Bi(t,e.key,n),s=Bi(t,e.value,n);return Math.max(r,s)}return 1}vh.Alias=rc});var se=_(sc=>{"use strict";var Nx=J(),Lx=Di(),Mx=_t(),Dx=t=>!t||typeof t!="function"&&typeof t!="object",Rt=class extends Lx.NodeBase{constructor(e){super(Nx.SCALAR),this.value=e}toJSON(e,n){return n?.keep?this.value:Mx.toJS(this.value,e,n)}toString(){return String(this.value)}};Rt.BLOCK_FOLDED="BLOCK_FOLDED";Rt.BLOCK_LITERAL="BLOCK_LITERAL";Rt.PLAIN="PLAIN";Rt.QUOTE_DOUBLE="QUOTE_DOUBLE";Rt.QUOTE_SINGLE="QUOTE_SINGLE";sc.Scalar=Rt;sc.isScalarValue=Dx});var Zr=_(kh=>{"use strict";var Bx=Qr(),on=J(),Sh=se(),jx="tag:yaml.org,2002:";function Fx(t,e,n){if(e){let r=n.filter(i=>i.tag===e),s=r.find(i=>!i.format)??r[0];if(!s)throw new Error(`Tag ${e} not found`);return s}return n.find(r=>r.identify?.(t)&&!r.format)}function Ux(t,e,n){if(on.isDocument(t)&&(t=t.contents),on.isNode(t))return t;if(on.isPair(t)){let d=n.schema[on.MAP].createNode?.(n.schema,null,n);return d.items.push(t),d}(t instanceof String||t instanceof Number||t instanceof Boolean||typeof BigInt<"u"&&t instanceof BigInt)&&(t=t.valueOf());let{aliasDuplicateObjects:r,onAnchor:s,onTagObj:i,schema:o,sourceObjects:a}=n,l;if(r&&t&&typeof t=="object"){if(l=a.get(t),l)return l.anchor??(l.anchor=s(t)),new Bx.Alias(l.anchor);l={anchor:null,node:null},a.set(t,l)}e?.startsWith("!!")&&(e=jx+e.slice(2));let c=Fx(t,e,o.tags);if(!c){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let d=new Sh.Scalar(t);return l&&(l.node=d),d}c=t instanceof Map?o[on.MAP]:Symbol.iterator in Object(t)?o[on.SEQ]:o[on.MAP]}i&&(i(c),delete n.onTagObj);let u=c?.createNode?c.createNode(n.schema,t,n):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(n.schema,t,n):new Sh.Scalar(t);return e?u.tag=e:c.default||(u.tag=c.tag),l&&(l.node=u),u}kh.createNode=Ux});var Fi=_(ji=>{"use strict";var qx=Zr(),it=J(),Jx=Di();function ic(t,e,n){let r=n;for(let s=e.length-1;s>=0;--s){let i=e[s];if(typeof i=="number"&&Number.isInteger(i)&&i>=0){let o=[];o[i]=r,r=o}else r=new Map([[i,r]])}return qx.createNode(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:t,sourceObjects:new Map})}var xh=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,oc=class extends Jx.NodeBase{constructor(e,n){super(e),Object.defineProperty(this,"schema",{value:n,configurable:!0,enumerable:!1,writable:!0})}clone(e){let n=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(n.schema=e),n.items=n.items.map(r=>it.isNode(r)||it.isPair(r)?r.clone(e):r),this.range&&(n.range=this.range.slice()),n}addIn(e,n){if(xh(e))this.add(n);else{let[r,...s]=e,i=this.get(r,!0);if(it.isCollection(i))i.addIn(s,n);else if(i===void 0&&this.schema)this.set(r,ic(this.schema,s,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${s}`)}}deleteIn(e){let[n,...r]=e;if(r.length===0)return this.delete(n);let s=this.get(n,!0);if(it.isCollection(s))return s.deleteIn(r);throw new Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}getIn(e,n){let[r,...s]=e,i=this.get(r,!0);return s.length===0?!n&&it.isScalar(i)?i.value:i:it.isCollection(i)?i.getIn(s,n):void 0}hasAllNullValues(e){return this.items.every(n=>{if(!it.isPair(n))return!1;let r=n.value;return r==null||e&&it.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[n,...r]=e;if(r.length===0)return this.has(n);let s=this.get(n,!0);return it.isCollection(s)?s.hasIn(r):!1}setIn(e,n){let[r,...s]=e;if(s.length===0)this.set(r,n);else{let i=this.get(r,!0);if(it.isCollection(i))i.setIn(s,n);else if(i===void 0&&this.schema)this.set(r,ic(this.schema,s,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${s}`)}}};ji.Collection=oc;ji.collectionFromPath=ic;ji.isEmptyPath=xh});var es=_(Ui=>{"use strict";var Wx=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function ac(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var Kx=(t,e,n)=>t.endsWith(`
|
|
26
|
+
`)?ac(n,e):n.includes(`
|
|
27
27
|
`)?`
|
|
28
|
-
`+
|
|
29
|
-
`)n===
|
|
30
|
-
`&&p!==" "){let
|
|
31
|
-
`&&
|
|
32
|
-
${e}${t.slice(0,R)}`:(n===
|
|
33
|
-
${e}${t.slice(
|
|
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
|
+
`+ac(n,e):(t.endsWith(" ")?"":" ")+n;Ui.indentComment=ac;Ui.lineComment=Kx;Ui.stringifyComment=Wx});var Ah=_(ts=>{"use strict";var Hx="flow",lc="block",qi="quoted";function zx(t,e,n="flow",{indentAtStart:r,lineWidth:s=80,minContentWidth:i=20,onFold:o,onOverflow:a}={}){if(!s||s<0)return t;s<i&&(i=0);let l=Math.max(1+i,1+s-e.length);if(t.length<=l)return t;let c=[],u={},d=s-e.length;typeof r=="number"&&(r>s-Math.max(2,i)?c.push(0):d=s-r);let f,p,h=!1,m=-1,g=-1,v=-1;n===lc&&(m=Eh(t,m,e.length),m!==-1&&(d=m+l));for(let C;C=t[m+=1];){if(n===qi&&C==="\\"){switch(g=m,t[m+1]){case"x":m+=3;break;case"u":m+=5;break;case"U":m+=9;break;default:m+=1}v=m}if(C===`
|
|
29
|
+
`)n===lc&&(m=Eh(t,m,e.length)),d=m+e.length+l,f=void 0;else{if(C===" "&&p&&p!==" "&&p!==`
|
|
30
|
+
`&&p!==" "){let x=t[m+1];x&&x!==" "&&x!==`
|
|
31
|
+
`&&x!==" "&&(f=m)}if(m>=d)if(f)c.push(f),d=f+l,f=void 0;else if(n===qi){for(;p===" "||p===" ";)p=C,C=t[m+=1],h=!0;let x=m>v+1?m-2:g-1;if(u[x])return t;c.push(x),u[x]=!0,d=x+l,f=void 0}else h=!0}p=C}if(h&&a&&a(),c.length===0)return t;o&&o();let A=t.slice(0,c[0]);for(let C=0;C<c.length;++C){let x=c[C],R=c[C+1]||t.length;x===0?A=`
|
|
32
|
+
${e}${t.slice(0,R)}`:(n===qi&&u[x]&&(A+=`${t[x]}\\`),A+=`
|
|
33
|
+
${e}${t.slice(x+1,R)}`)}return A}function Eh(t,e,n){let r=e,s=e+1,i=t[s];for(;i===" "||i===" ";)if(e<s+n)i=t[++e];else{do i=t[++e];while(i&&i!==`
|
|
34
|
+
`);r=e,s=e+1,i=t[s]}return r}ts.FOLD_BLOCK=lc;ts.FOLD_FLOW=Hx;ts.FOLD_QUOTED=qi;ts.foldFlowLines=zx});var rs=_(Th=>{"use strict";var Ye=se(),It=Ah(),Wi=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),Ki=t=>/^(%|---|\.\.\.)/m.test(t);function Yx(t,e,n){if(!e||e<0)return!1;let r=e-n,s=t.length;if(s<=r)return!1;for(let i=0,o=0;i<s;++i)if(t[i]===`
|
|
35
|
+
`){if(i-o>r)return!0;if(o=i+1,s-o<=r)return!1}return!0}function ns(t,e){let n=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=e,s=e.options.doubleQuotedMinMultiLineLength,i=e.indent||(Ki(t)?" ":""),o="",a=0;for(let l=0,c=n[l];c;c=n[++l])if(c===" "&&n[l+1]==="\\"&&n[l+2]==="n"&&(o+=n.slice(a,l)+"\\ ",l+=1,a=l,c="\\"),c==="\\")switch(n[l+1]){case"u":{o+=n.slice(a,l);let u=n.substr(l+2,4);switch(u){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:u.substr(0,2)==="00"?o+="\\x"+u.substr(2):o+=n.substr(l,6)}l+=5,a=l+1}break;case"n":if(r||n[l+2]==='"'||n.length<s)l+=1;else{for(o+=n.slice(a,l)+`
|
|
36
36
|
|
|
37
37
|
`;n[l+2]==="\\"&&n[l+3]==="n"&&n[l+4]!=='"';)o+=`
|
|
38
|
-
`,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:It.foldFlowLines(o,i,It.FOLD_QUOTED,Wi(e,!1))}function cc(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
|
|
39
|
+
`)||/[ \t]\n|\n[ \t]/.test(t))return ns(t,e);let n=e.indent||(Ki(t)?" ":""),r="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
40
|
+
${n}`)+"'";return e.implicitKey?r:It.foldFlowLines(r,n,It.FOLD_FLOW,Wi(e,!1))}function Kn(t,e){let{singleQuote:n}=e.options,r;if(n===!1)r=ns;else{let s=t.includes('"'),i=t.includes("'");s&&!i?r=cc:i&&!s?r=ns:r=n?cc:ns}return r(t,e)}var uc;try{uc=new RegExp(`(^|(?<!
|
|
41
41
|
))
|
|
42
42
|
+(?!
|
|
43
|
-
|$)`,"g")}catch{
|
|
43
|
+
|$)`,"g")}catch{uc=/\n+(?!\n|$)/g}function Ji({comment:t,type:e,value:n},r,s,i){let{blockQuote:o,commentString:a,lineWidth:l}=r.options;if(!o||/\n[\t ]+$/.test(n))return Kn(n,r);let c=r.indent||(r.forceBlockIndent||Ki(n)?" ":""),u=o==="literal"?!0:o==="folded"||e===Ye.Scalar.BLOCK_FOLDED?!1:e===Ye.Scalar.BLOCK_LITERAL?!0:!Yx(n,l,c.length);if(!n)return u?`|
|
|
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=
|
|
51
|
-
${c}${
|
|
52
|
-
${c}${
|
|
53
|
-
`)||
|
|
54
|
-
`)?
|
|
55
|
-
`))return
|
|
56
|
-
${l}`);if(o){let
|
|
57
|
-
${e.indent}${a}`:a}
|
|
58
|
-
${a}:`):(g=`${g}:`,
|
|
59
|
-
`:"",
|
|
60
|
-
${
|
|
45
|
+
`;let d,f;for(f=n.length;f>0;--f){let R=n[f-1];if(R!==`
|
|
46
|
+
`&&R!==" "&&R!==" ")break}let p=n.substring(f),h=p.indexOf(`
|
|
47
|
+
`);h===-1?d="-":n===p||h!==p.length-1?(d="+",i&&i()):d="",p&&(n=n.slice(0,-p.length),p[p.length-1]===`
|
|
48
|
+
`&&(p=p.slice(0,-1)),p=p.replace(uc,`$&${c}`));let m=!1,g,v=-1;for(g=0;g<n.length;++g){let R=n[g];if(R===" ")m=!0;else if(R===`
|
|
49
|
+
`)v=g;else break}let A=n.substring(0,v<g?v+1:g);A&&(n=n.substring(A.length),A=A.replace(/\n+/g,`$&${c}`));let x=(m?c?"2":"1":"")+d;if(t&&(x+=" "+a(t.replace(/ ?[\r\n]+/g," ")),s&&s()),!u){let R=n.replace(/\n+/g,`
|
|
50
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),I=!1,L=Wi(r,!0);o!=="folded"&&e!==Ye.Scalar.BLOCK_FOLDED&&(L.onOverflow=()=>{I=!0});let T=It.foldFlowLines(`${A}${R}${p}`,c,It.FOLD_BLOCK,L);if(!I)return`>${x}
|
|
51
|
+
${c}${T}`}return n=n.replace(/\n+/g,`$&${c}`),`|${x}
|
|
52
|
+
${c}${A}${n}${p}`}function Vx(t,e,n,r){let{type:s,value:i}=t,{actualString:o,implicitKey:a,indent:l,indentStep:c,inFlow:u}=e;if(a&&i.includes(`
|
|
53
|
+
`)||u&&/[[\]{},]/.test(i))return Kn(i,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(i))return a||u||!i.includes(`
|
|
54
|
+
`)?Kn(i,e):Ji(t,e,n,r);if(!a&&!u&&s!==Ye.Scalar.PLAIN&&i.includes(`
|
|
55
|
+
`))return Ji(t,e,n,r);if(Ki(i)){if(l==="")return e.forceBlockIndent=!0,Ji(t,e,n,r);if(a&&l===c)return Kn(i,e)}let d=i.replace(/\n+/g,`$&
|
|
56
|
+
${l}`);if(o){let f=m=>m.default&&m.tag!=="tag:yaml.org,2002:str"&&m.test?.test(d),{compat:p,tags:h}=e.doc.schema;if(h.some(f)||p?.some(f))return Kn(i,e)}return a?d:It.foldFlowLines(d,l,It.FOLD_FLOW,Wi(e,!1))}function Gx(t,e,n,r){let{implicitKey:s,inFlow:i}=e,o=typeof t.value=="string"?t:Object.assign({},t,{value:String(t.value)}),{type:a}=t;a!==Ye.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(a=Ye.Scalar.QUOTE_DOUBLE);let l=u=>{switch(u){case Ye.Scalar.BLOCK_FOLDED:case Ye.Scalar.BLOCK_LITERAL:return s||i?Kn(o.value,e):Ji(o,e,n,r);case Ye.Scalar.QUOTE_DOUBLE:return ns(o.value,e);case Ye.Scalar.QUOTE_SINGLE:return cc(o.value,e);case Ye.Scalar.PLAIN:return Vx(o,e,n,r);default:return null}},c=l(a);if(c===null){let{defaultKeyType:u,defaultStringType:d}=e.options,f=s&&u||d;if(c=l(f),c===null)throw new Error(`Unsupported default string type ${f}`)}return c}Th.stringifyString=Gx});var ss=_(dc=>{"use strict";var Xx=Mi(),$t=J(),Qx=es(),Zx=rs();function e0(t,e){let n=Object.assign({blockQuote:!0,commentString:Qx.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trueStr:"true",verifyAliasOrder:!0},t.schema.toStringOptions,e),r;switch(n.collectionStyle){case"block":r=!1;break;case"flow":r=!0;break;default:r=null}return{anchors:new Set,doc:t,flowCollectionPadding:n.flowCollectionPadding?" ":"",indent:"",indentStep:typeof n.indent=="number"?" ".repeat(n.indent):" ",inFlow:r,options:n}}function t0(t,e){if(e.tag){let s=t.filter(i=>i.tag===e.tag);if(s.length>0)return s.find(i=>i.format===e.format)??s[0]}let n,r;if($t.isScalar(e)){r=e.value;let s=t.filter(i=>i.identify?.(r));if(s.length>1){let i=s.filter(o=>o.test);i.length>0&&(s=i)}n=s.find(i=>i.format===e.format)??s.find(i=>!i.format)}else r=e,n=t.find(s=>s.nodeClass&&r instanceof s.nodeClass);if(!n){let s=r?.constructor?.name??(r===null?"null":typeof r);throw new Error(`Tag not resolved for ${s} value`)}return n}function n0(t,e,{anchors:n,doc:r}){if(!r.directives)return"";let s=[],i=($t.isScalar(t)||$t.isCollection(t))&&t.anchor;i&&Xx.anchorIsValid(i)&&(n.add(i),s.push(`&${i}`));let o=t.tag??(e.default?null:e.tag);return o&&s.push(r.directives.tagString(o)),s.join(" ")}function r0(t,e,n,r){if($t.isPair(t))return t.toString(e,n,r);if($t.isAlias(t)){if(e.doc.directives)return t.toString(e);if(e.resolvedAliases?.has(t))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(t):e.resolvedAliases=new Set([t]),t=t.resolve(e.doc)}let s,i=$t.isNode(t)?t:e.doc.createNode(t,{onTagObj:l=>s=l});s??(s=t0(e.doc.schema.tags,i));let o=n0(i,s,e);o.length>0&&(e.indentAtStart=(e.indentAtStart??0)+o.length+1);let a=typeof s.stringify=="function"?s.stringify(i,e,n,r):$t.isScalar(i)?Zx.stringifyString(i,e,n,r):i.toString(e,n,r);return o?$t.isScalar(i)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
|
|
57
|
+
${e.indent}${a}`:a}dc.createStringifyContext=e0;dc.stringify=r0});var _h=_(Ph=>{"use strict";var pt=J(),Ch=se(),Oh=ss(),is=es();function s0({key:t,value:e},n,r,s){let{allNullValues:i,doc:o,indent:a,indentStep:l,options:{commentString:c,indentSeq:u,simpleKeys:d}}=n,f=pt.isNode(t)&&t.comment||null;if(d){if(f)throw new Error("With simple keys, key nodes cannot have comments");if(pt.isCollection(t)||!pt.isNode(t)&&typeof t=="object"){let L="With simple keys, collection cannot be used as a key value";throw new Error(L)}}let p=!d&&(!t||f&&e==null&&!n.inFlow||pt.isCollection(t)||(pt.isScalar(t)?t.type===Ch.Scalar.BLOCK_FOLDED||t.type===Ch.Scalar.BLOCK_LITERAL:typeof t=="object"));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(d||!i),indent:a+l});let h=!1,m=!1,g=Oh.stringify(t,n,()=>h=!0,()=>m=!0);if(!p&&!n.inFlow&&g.length>1024){if(d)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");p=!0}if(n.inFlow){if(i||e==null)return h&&r&&r(),g===""?"?":p?`? ${g}`:g}else if(i&&!d||e==null&&p)return g=`? ${g}`,f&&!h?g+=is.lineComment(g,n.indent,c(f)):m&&s&&s(),g;h&&(f=null),p?(f&&(g+=is.lineComment(g,n.indent,c(f))),g=`? ${g}
|
|
58
|
+
${a}:`):(g=`${g}:`,f&&(g+=is.lineComment(g,n.indent,c(f))));let v,A,C;pt.isNode(e)?(v=!!e.spaceBefore,A=e.commentBefore,C=e.comment):(v=!1,A=null,C=null,e&&typeof e=="object"&&(e=o.createNode(e))),n.implicitKey=!1,!p&&!f&&pt.isScalar(e)&&(n.indentAtStart=g.length+1),m=!1,!u&&l.length>=2&&!n.inFlow&&!p&&pt.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(n.indent=n.indent.substring(2));let x=!1,R=Oh.stringify(e,n,()=>x=!0,()=>m=!0),I=" ";if(f||v||A){if(I=v?`
|
|
59
|
+
`:"",A){let L=c(A);I+=`
|
|
60
|
+
${is.indentComment(L,n.indent)}`}R===""&&!n.inFlow?I===`
|
|
61
61
|
`&&C&&(I=`
|
|
62
62
|
|
|
63
63
|
`):I+=`
|
|
64
|
-
${n.indent}`}else if(!p&&
|
|
65
|
-
`),F=
|
|
64
|
+
${n.indent}`}else if(!p&&pt.isCollection(e)){let L=R[0],T=R.indexOf(`
|
|
65
|
+
`),F=T!==-1,H=n.inFlow??e.flow??e.items.length===0;if(F||!H){let ne=!1;if(F&&(L==="&"||L==="!")){let U=R.indexOf(" ");L==="&"&&U!==-1&&U<T&&R[U+1]==="!"&&(U=R.indexOf(" ",U+1)),(U===-1||T<U)&&(ne=!0)}ne||(I=`
|
|
66
66
|
${n.indent}`)}}else(R===""||R[0]===`
|
|
67
|
-
`)&&(I="");return g+=I+R,n.inFlow?
|
|
68
|
-
${l}${
|
|
67
|
+
`)&&(I="");return g+=I+R,n.inFlow?x&&r&&r():C&&!x?g+=is.lineComment(g,n.indent,c(C)):m&&s&&s(),g}Ph.stringifyPair=s0});var pc=_(fc=>{"use strict";var Rh=Ei("process");function i0(t,...e){t==="debug"&&console.log(...e)}function o0(t,e){(t==="debug"||t==="warn")&&(typeof Rh.emitWarning=="function"?Rh.emitWarning(e):console.warn(e))}fc.debug=i0;fc.warn=o0});var Vi=_(Yi=>{"use strict";var os=J(),Ih=se(),Hi="<<",zi={identify:t=>t===Hi||typeof t=="symbol"&&t.description===Hi,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Ih.Scalar(Symbol(Hi)),{addToJSMap:$h}),stringify:()=>Hi},a0=(t,e)=>(zi.identify(e)||os.isScalar(e)&&(!e.type||e.type===Ih.Scalar.PLAIN)&&zi.identify(e.value))&&t?.doc.schema.tags.some(n=>n.tag===zi.tag&&n.default);function $h(t,e,n){if(n=t&&os.isAlias(n)?n.resolve(t.doc):n,os.isSeq(n))for(let r of n.items)hc(t,e,r);else if(Array.isArray(n))for(let r of n)hc(t,e,r);else hc(t,e,n)}function hc(t,e,n){let r=t&&os.isAlias(n)?n.resolve(t.doc):n;if(!os.isMap(r))throw new Error("Merge sources must be maps or map aliases");let s=r.toJSON(null,t,Map);for(let[i,o]of s)e instanceof Map?e.has(i)||e.set(i,o):e instanceof Set?e.add(i):Object.prototype.hasOwnProperty.call(e,i)||Object.defineProperty(e,i,{value:o,writable:!0,enumerable:!0,configurable:!0});return e}Yi.addMergeToJSMap=$h;Yi.isMergeKey=a0;Yi.merge=zi});var gc=_(Mh=>{"use strict";var l0=pc(),Nh=Vi(),c0=ss(),Lh=J(),mc=_t();function u0(t,e,{key:n,value:r}){if(Lh.isNode(n)&&n.addToJSMap)n.addToJSMap(t,e,r);else if(Nh.isMergeKey(t,n))Nh.addMergeToJSMap(t,e,r);else{let s=mc.toJS(n,"",t);if(e instanceof Map)e.set(s,mc.toJS(r,s,t));else if(e instanceof Set)e.add(s);else{let i=d0(n,s,t),o=mc.toJS(r,i,t);i in e?Object.defineProperty(e,i,{value:o,writable:!0,enumerable:!0,configurable:!0}):e[i]=o}}return e}function d0(t,e,n){if(e===null)return"";if(typeof e!="object")return String(e);if(Lh.isNode(t)&&n?.doc){let r=c0.createStringifyContext(n.doc,{});r.anchors=new Set;for(let i of n.anchors.keys())r.anchors.add(i.anchor);r.inFlow=!0,r.inStringifyKey=!0;let s=t.toString(r);if(!n.mapKeyWarned){let i=JSON.stringify(s);i.length>40&&(i=i.substring(0,36)+'..."'),l0.warn(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${i}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return s}return JSON.stringify(e)}Mh.addPairToJSMap=u0});var Nt=_(yc=>{"use strict";var Dh=Zr(),f0=_h(),p0=gc(),Gi=J();function h0(t,e,n){let r=Dh.createNode(t,void 0,n),s=Dh.createNode(e,void 0,n);return new Xi(r,s)}var Xi=class t{constructor(e,n=null){Object.defineProperty(this,Gi.NODE_TYPE,{value:Gi.PAIR}),this.key=e,this.value=n}clone(e){let{key:n,value:r}=this;return Gi.isNode(n)&&(n=n.clone(e)),Gi.isNode(r)&&(r=r.clone(e)),new t(n,r)}toJSON(e,n){let r=n?.mapAsMap?new Map:{};return p0.addPairToJSMap(n,r,this)}toString(e,n,r){return e?.doc?f0.stringifyPair(this,e,n,r):JSON.stringify(this)}};yc.Pair=Xi;yc.createPair=h0});var bc=_(jh=>{"use strict";var an=J(),Bh=ss(),Qi=es();function m0(t,e,n){return(e.inFlow??t.flow?y0:g0)(t,e,n)}function g0({comment:t,items:e},n,{blockItemPrefix:r,flowChars:s,itemIndent:i,onChompKeep:o,onComment:a}){let{indent:l,options:{commentString:c}}=n,u=Object.assign({},n,{indent:i,type:null}),d=!1,f=[];for(let h=0;h<e.length;++h){let m=e[h],g=null;if(an.isNode(m))!d&&m.spaceBefore&&f.push(""),Zi(n,f,m.commentBefore,d),m.comment&&(g=m.comment);else if(an.isPair(m)){let A=an.isNode(m.key)?m.key:null;A&&(!d&&A.spaceBefore&&f.push(""),Zi(n,f,A.commentBefore,d))}d=!1;let v=Bh.stringify(m,u,()=>g=null,()=>d=!0);g&&(v+=Qi.lineComment(v,i,c(g))),d&&g&&(d=!1),f.push(r+v)}let p;if(f.length===0)p=s.start+s.end;else{p=f[0];for(let h=1;h<f.length;++h){let m=f[h];p+=m?`
|
|
68
|
+
${l}${m}`:`
|
|
69
69
|
`}}return t?(p+=`
|
|
70
|
-
`+
|
|
71
|
-
`))&&(c=!0),d.push(
|
|
72
|
-
${i}${s}${
|
|
73
|
-
`;return`${
|
|
74
|
-
${s}${p}`}else return`${
|
|
75
|
-
`:" ")}return
|
|
70
|
+
`+Qi.indentComment(c(t),l),a&&a()):d&&o&&o(),p}function y0({items:t},e,{flowChars:n,itemIndent:r}){let{indent:s,indentStep:i,flowCollectionPadding:o,options:{commentString:a}}=e;r+=i;let l=Object.assign({},e,{indent:r,inFlow:!0,type:null}),c=!1,u=0,d=[];for(let h=0;h<t.length;++h){let m=t[h],g=null;if(an.isNode(m))m.spaceBefore&&d.push(""),Zi(e,d,m.commentBefore,!1),m.comment&&(g=m.comment);else if(an.isPair(m)){let A=an.isNode(m.key)?m.key:null;A&&(A.spaceBefore&&d.push(""),Zi(e,d,A.commentBefore,!1),A.comment&&(c=!0));let C=an.isNode(m.value)?m.value:null;C?(C.comment&&(g=C.comment),C.commentBefore&&(c=!0)):m.value==null&&A?.comment&&(g=A.comment)}g&&(c=!0);let v=Bh.stringify(m,l,()=>g=null);h<t.length-1&&(v+=","),g&&(v+=Qi.lineComment(v,r,a(g))),!c&&(d.length>u||v.includes(`
|
|
71
|
+
`))&&(c=!0),d.push(v),u=d.length}let{start:f,end:p}=n;if(d.length===0)return f+p;if(!c){let h=d.reduce((m,g)=>m+g.length+2,2);c=e.options.lineWidth>0&&h>e.options.lineWidth}if(c){let h=f;for(let m of d)h+=m?`
|
|
72
|
+
${i}${s}${m}`:`
|
|
73
|
+
`;return`${h}
|
|
74
|
+
${s}${p}`}else return`${f}${o}${d.join(" ")}${o}${p}`}function Zi({indent:t,options:{commentString:e}},n,r,s){if(r&&s&&(r=r.replace(/^\n+/,"")),r){let i=Qi.indentComment(e(r),t);n.push(i.trimStart())}}jh.stringifyCollection=m0});var Mt=_(vc=>{"use strict";var b0=bc(),w0=gc(),v0=Fi(),Lt=J(),eo=Nt(),S0=se();function as(t,e){let n=Lt.isScalar(e)?e.value:e;for(let r of t)if(Lt.isPair(r)&&(r.key===e||r.key===n||Lt.isScalar(r.key)&&r.key.value===n))return r}var wc=class extends v0.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Lt.MAP,e),this.items=[]}static from(e,n,r){let{keepUndefined:s,replacer:i}=r,o=new this(e),a=(l,c)=>{if(typeof i=="function")c=i.call(n,l,c);else if(Array.isArray(i)&&!i.includes(l))return;(c!==void 0||s)&&o.items.push(eo.createPair(l,c,r))};if(n instanceof Map)for(let[l,c]of n)a(l,c);else if(n&&typeof n=="object")for(let l of Object.keys(n))a(l,n[l]);return typeof e.sortMapEntries=="function"&&o.items.sort(e.sortMapEntries),o}add(e,n){let r;Lt.isPair(e)?r=e:!e||typeof e!="object"||!("key"in e)?r=new eo.Pair(e,e?.value):r=new eo.Pair(e.key,e.value);let s=as(this.items,r.key),i=this.schema?.sortMapEntries;if(s){if(!n)throw new Error(`Key ${r.key} already set`);Lt.isScalar(s.value)&&S0.isScalarValue(r.value)?s.value.value=r.value:s.value=r.value}else if(i){let o=this.items.findIndex(a=>i(r,a)<0);o===-1?this.items.push(r):this.items.splice(o,0,r)}else this.items.push(r)}delete(e){let n=as(this.items,e);return n?this.items.splice(this.items.indexOf(n),1).length>0:!1}get(e,n){let s=as(this.items,e)?.value;return(!n&&Lt.isScalar(s)?s.value:s)??void 0}has(e){return!!as(this.items,e)}set(e,n){this.add(new eo.Pair(e,n),!0)}toJSON(e,n,r){let s=r?new r:n?.mapAsMap?new Map:{};n?.onCreate&&n.onCreate(s);for(let i of this.items)w0.addPairToJSMap(n,s,i);return s}toString(e,n,r){if(!e)return JSON.stringify(this);for(let s of this.items)if(!Lt.isPair(s))throw new Error(`Map items must all be pairs; found ${JSON.stringify(s)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),b0.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:n})}};vc.YAMLMap=wc;vc.findPair=as});var Hn=_(Uh=>{"use strict";var k0=J(),Fh=Mt(),x0={collection:"map",default:!0,nodeClass:Fh.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(t,e){return k0.isMap(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,n)=>Fh.YAMLMap.from(t,e,n)};Uh.map=x0});var Dt=_(qh=>{"use strict";var E0=Zr(),A0=bc(),T0=Fi(),no=J(),C0=se(),O0=_t(),Sc=class extends T0.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(no.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let n=to(e);return typeof n!="number"?!1:this.items.splice(n,1).length>0}get(e,n){let r=to(e);if(typeof r!="number")return;let s=this.items[r];return!n&&no.isScalar(s)?s.value:s}has(e){let n=to(e);return typeof n=="number"&&n<this.items.length}set(e,n){let r=to(e);if(typeof r!="number")throw new Error(`Expected a valid index, not ${e}.`);let s=this.items[r];no.isScalar(s)&&C0.isScalarValue(n)?s.value=n:this.items[r]=n}toJSON(e,n){let r=[];n?.onCreate&&n.onCreate(r);let s=0;for(let i of this.items)r.push(O0.toJS(i,String(s++),n));return r}toString(e,n,r){return e?A0.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:r,onComment:n}):JSON.stringify(this)}static from(e,n,r){let{replacer:s}=r,i=new this(e);if(n&&Symbol.iterator in Object(n)){let o=0;for(let a of n){if(typeof s=="function"){let l=n instanceof Set?a:String(o++);a=s.call(n,l,a)}i.items.push(E0.createNode(a,void 0,r))}}return i}};function to(t){let e=no.isScalar(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}qh.YAMLSeq=Sc});var zn=_(Wh=>{"use strict";var P0=J(),Jh=Dt(),_0={collection:"seq",default:!0,nodeClass:Jh.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(t,e){return P0.isSeq(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,n)=>Jh.YAMLSeq.from(t,e,n)};Wh.seq=_0});var ls=_(Kh=>{"use strict";var R0=rs(),I0={identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify(t,e,n,r){return e=Object.assign({actualString:!0},e),R0.stringifyString(t,e,n,r)}};Kh.string=I0});var ro=_(Yh=>{"use strict";var Hh=se(),zh={identify:t=>t==null,createNode:()=>new Hh.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Hh.Scalar(null),stringify:({source:t},e)=>typeof t=="string"&&zh.test.test(t)?t:e.options.nullStr};Yh.nullTag=zh});var kc=_(Gh=>{"use strict";var $0=se(),Vh={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new $0.Scalar(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},n){if(t&&Vh.test.test(t)){let r=t[0]==="t"||t[0]==="T";if(e===r)return t}return e?n.options.trueStr:n.options.falseStr}};Gh.boolTag=Vh});var Yn=_(Xh=>{"use strict";function N0({format:t,minFractionDigits:e,tag:n,value:r}){if(typeof r=="bigint")return String(r);let s=typeof r=="number"?r:Number(r);if(!isFinite(s))return isNaN(s)?".nan":s<0?"-.inf":".inf";let i=Object.is(r,-0)?"-0":JSON.stringify(r);if(!t&&e&&(!n||n==="tag:yaml.org,2002:float")&&/^\d/.test(i)){let o=i.indexOf(".");o<0&&(o=i.length,i+=".");let a=e-(i.length-o-1);for(;a-- >0;)i+="0"}return i}Xh.stringifyNumber=N0});var Ec=_(so=>{"use strict";var L0=se(),xc=Yn(),M0={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:xc.stringifyNumber},D0={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():xc.stringifyNumber(t)}},B0={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(t){let e=new L0.Scalar(parseFloat(t)),n=t.indexOf(".");return n!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-n-1),e},stringify:xc.stringifyNumber};so.float=B0;so.floatExp=D0;so.floatNaN=M0});var Tc=_(oo=>{"use strict";var Qh=Yn(),io=t=>typeof t=="bigint"||Number.isInteger(t),Ac=(t,e,n,{intAsBigInt:r})=>r?BigInt(t):parseInt(t.substring(e),n);function Zh(t,e,n){let{value:r}=t;return io(r)&&r>=0?n+r.toString(e):Qh.stringifyNumber(t)}var j0={identify:t=>io(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,n)=>Ac(t,2,8,n),stringify:t=>Zh(t,8,"0o")},F0={identify:io,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,n)=>Ac(t,0,10,n),stringify:Qh.stringifyNumber},U0={identify:t=>io(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,n)=>Ac(t,2,16,n),stringify:t=>Zh(t,16,"0x")};oo.int=F0;oo.intHex=U0;oo.intOct=j0});var tm=_(em=>{"use strict";var q0=Hn(),J0=ro(),W0=zn(),K0=ls(),H0=kc(),Cc=Ec(),Oc=Tc(),z0=[q0.map,W0.seq,K0.string,J0.nullTag,H0.boolTag,Oc.intOct,Oc.int,Oc.intHex,Cc.floatNaN,Cc.floatExp,Cc.float];em.schema=z0});var sm=_(rm=>{"use strict";var Y0=se(),V0=Hn(),G0=zn();function nm(t){return typeof t=="bigint"||Number.isInteger(t)}var ao=({value:t})=>JSON.stringify(t),X0=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:ao},{identify:t=>t==null,createNode:()=>new Y0.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:ao},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:ao},{identify:nm,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(t,e,{intAsBigInt:n})=>n?BigInt(t):parseInt(t,10),stringify:({value:t})=>nm(t)?t.toString():JSON.stringify(t)},{identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:t=>parseFloat(t),stringify:ao}],Q0={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},Z0=[V0.map,G0.seq].concat(X0,Q0);rm.schema=Z0});var _c=_(im=>{"use strict";var cs=Ei("buffer"),Pc=se(),eE=rs(),tE={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof cs.Buffer=="function")return cs.Buffer.from(t,"base64");if(typeof atob=="function"){let n=atob(t.replace(/[\n\r]/g,"")),r=new Uint8Array(n.length);for(let s=0;s<n.length;++s)r[s]=n.charCodeAt(s);return r}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),t},stringify({comment:t,type:e,value:n},r,s,i){if(!n)return"";let o=n,a;if(typeof cs.Buffer=="function")a=o instanceof cs.Buffer?o.toString("base64"):cs.Buffer.from(o.buffer).toString("base64");else if(typeof btoa=="function"){let l="";for(let c=0;c<o.length;++c)l+=String.fromCharCode(o[c]);a=btoa(l)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e??(e=Pc.Scalar.BLOCK_LITERAL),e!==Pc.Scalar.QUOTE_DOUBLE){let l=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),c=Math.ceil(a.length/l),u=new Array(c);for(let d=0,f=0;d<c;++d,f+=l)u[d]=a.substr(f,l);a=u.join(e===Pc.Scalar.BLOCK_LITERAL?`
|
|
75
|
+
`:" ")}return eE.stringifyString({comment:t,type:e,value:a},r,s,i)}};im.binary=tE});var uo=_(co=>{"use strict";var lo=J(),Rc=Nt(),nE=se(),rE=Dt();function om(t,e){if(lo.isSeq(t))for(let n=0;n<t.items.length;++n){let r=t.items[n];if(!lo.isPair(r)){if(lo.isMap(r)){r.items.length>1&&e("Each pair must have its own sequence indicator");let s=r.items[0]||new Rc.Pair(new nE.Scalar(null));if(r.commentBefore&&(s.key.commentBefore=s.key.commentBefore?`${r.commentBefore}
|
|
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]=lo.isPair(r)?r:new Rc.Pair(r)}}else e("Expected a sequence for this tag");return t}function am(t,e,n){let{replacer:r}=n,s=new rE.YAMLSeq(t);s.tag="tag:yaml.org,2002:pairs";let i=0;if(e&&Symbol.iterator in Object(e))for(let o of e){typeof r=="function"&&(o=r.call(e,String(i++),o));let a,l;if(Array.isArray(o))if(o.length===2)a=o[0],l=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let c=Object.keys(o);if(c.length===1)a=c[0],l=o[a];else throw new TypeError(`Expected tuple with one key, not ${c.length} keys`)}else a=o;s.items.push(Rc.createPair(a,l,n))}return s}var sE={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:om,createNode:am};co.createPairs=am;co.pairs=sE;co.resolvePairs=om});var Nc=_($c=>{"use strict";var lm=J(),Ic=_t(),us=Mt(),iE=Dt(),cm=uo(),ln=class t extends iE.YAMLSeq{constructor(){super(),this.add=us.YAMLMap.prototype.add.bind(this),this.delete=us.YAMLMap.prototype.delete.bind(this),this.get=us.YAMLMap.prototype.get.bind(this),this.has=us.YAMLMap.prototype.has.bind(this),this.set=us.YAMLMap.prototype.set.bind(this),this.tag=t.tag}toJSON(e,n){if(!n)return super.toJSON(e);let r=new Map;n?.onCreate&&n.onCreate(r);for(let s of this.items){let i,o;if(lm.isPair(s)?(i=Ic.toJS(s.key,"",n),o=Ic.toJS(s.value,i,n)):i=Ic.toJS(s,"",n),r.has(i))throw new Error("Ordered maps must not include duplicate keys");r.set(i,o)}return r}static from(e,n,r){let s=cm.createPairs(e,n,r),i=new this;return i.items=s.items,i}};ln.tag="tag:yaml.org,2002:omap";var oE={collection:"seq",identify:t=>t instanceof Map,nodeClass:ln,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let n=cm.resolvePairs(t,e),r=[];for(let{key:s}of n.items)lm.isScalar(s)&&(r.includes(s.value)?e(`Ordered maps must not include duplicate keys: ${s.value}`):r.push(s.value));return Object.assign(new ln,n)},createNode:(t,e,n)=>ln.from(t,e,n)};$c.YAMLOMap=ln;$c.omap=oE});var hm=_(Lc=>{"use strict";var um=se();function dm({value:t,source:e},n){return e&&(t?fm:pm).test.test(e)?e:t?n.options.trueStr:n.options.falseStr}var fm={identify:t=>t===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new um.Scalar(!0),stringify:dm},pm={identify:t=>t===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new um.Scalar(!1),stringify:dm};Lc.falseTag=pm;Lc.trueTag=fm});var mm=_(fo=>{"use strict";var aE=se(),Mc=Yn(),lE={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Mc.stringifyNumber},cE={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t.replace(/_/g,"")),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():Mc.stringifyNumber(t)}},uE={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(t){let e=new aE.Scalar(parseFloat(t.replace(/_/g,""))),n=t.indexOf(".");if(n!==-1){let r=t.substring(n+1).replace(/_/g,"");r[r.length-1]==="0"&&(e.minFractionDigits=r.length)}return e},stringify:Mc.stringifyNumber};fo.float=uE;fo.floatExp=cE;fo.floatNaN=lE});var ym=_(fs=>{"use strict";var gm=Yn(),ds=t=>typeof t=="bigint"||Number.isInteger(t);function po(t,e,n,{intAsBigInt:r}){let s=t[0];if((s==="-"||s==="+")&&(e+=1),t=t.substring(e).replace(/_/g,""),r){switch(n){case 2:t=`0b${t}`;break;case 8:t=`0o${t}`;break;case 16:t=`0x${t}`;break}let o=BigInt(t);return s==="-"?BigInt(-1)*o:o}let i=parseInt(t,n);return s==="-"?-1*i:i}function Dc(t,e,n){let{value:r}=t;if(ds(r)){let s=r.toString(e);return r<0?"-"+n+s.substr(1):n+s}return gm.stringifyNumber(t)}var dE={identify:ds,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,n)=>po(t,2,2,n),stringify:t=>Dc(t,2,"0b")},fE={identify:ds,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,n)=>po(t,1,8,n),stringify:t=>Dc(t,8,"0")},pE={identify:ds,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,n)=>po(t,0,10,n),stringify:gm.stringifyNumber},hE={identify:ds,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,n)=>po(t,2,16,n),stringify:t=>Dc(t,16,"0x")};fs.int=pE;fs.intBin=dE;fs.intHex=hE;fs.intOct=fE});var jc=_(Bc=>{"use strict";var go=J(),ho=Nt(),mo=Mt(),cn=class t extends mo.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let n;go.isPair(e)?n=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?n=new ho.Pair(e.key,null):n=new ho.Pair(e,null),mo.findPair(this.items,n.key)||this.items.push(n)}get(e,n){let r=mo.findPair(this.items,e);return!n&&go.isPair(r)?go.isScalar(r.key)?r.key.value:r.key:r}set(e,n){if(typeof n!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof n}`);let r=mo.findPair(this.items,e);r&&!n?this.items.splice(this.items.indexOf(r),1):!r&&n&&this.items.push(new ho.Pair(e))}toJSON(e,n){return super.toJSON(e,n,Set)}toString(e,n,r){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),n,r);throw new Error("Set items must all have null values")}static from(e,n,r){let{replacer:s}=r,i=new this(e);if(n&&Symbol.iterator in Object(n))for(let o of n)typeof s=="function"&&(o=s.call(n,o,o)),i.items.push(ho.createPair(o,null,r));return i}};cn.tag="tag:yaml.org,2002:set";var mE={collection:"map",identify:t=>t instanceof Set,nodeClass:cn,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,n)=>cn.from(t,e,n),resolve(t,e){if(go.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new cn,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};Bc.YAMLSet=cn;Bc.set=mE});var Uc=_(yo=>{"use strict";var gE=Yn();function Fc(t,e){let n=t[0],r=n==="-"||n==="+"?t.substring(1):t,s=o=>e?BigInt(o):Number(o),i=r.replace(/_/g,"").split(":").reduce((o,a)=>o*s(60)+s(a),s(0));return n==="-"?s(-1)*i:i}function bm(t){let{value:e}=t,n=o=>o;if(typeof e=="bigint")n=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return gE.stringifyNumber(t);let r="";e<0&&(r="-",e*=n(-1));let s=n(60),i=[e%s];return e<60?i.unshift(0):(e=(e-i[0])/s,i.unshift(e%s),e>=60&&(e=(e-i[0])/s,i.unshift(e))),r+i.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var yE={identify:t=>typeof t=="bigint"||Number.isInteger(t),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(t,e,{intAsBigInt:n})=>Fc(t,n),stringify:bm},bE={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:t=>Fc(t,!1),stringify:bm},wm={identify:t=>t instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(t){let e=t.match(wm.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,n,r,s,i,o,a]=e.map(Number),l=e[7]?Number((e[7]+"00").substr(1,3)):0,c=Date.UTC(n,r-1,s,i||0,o||0,a||0,l),u=e[8];if(u&&u!=="Z"){let d=Fc(u,!1);Math.abs(d)<30&&(d*=60),c-=6e4*d}return new Date(c)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};yo.floatTime=bE;yo.intTime=yE;yo.timestamp=wm});var km=_(Sm=>{"use strict";var wE=Hn(),vE=ro(),SE=zn(),kE=ls(),xE=_c(),vm=hm(),qc=mm(),bo=ym(),EE=Vi(),AE=Nc(),TE=uo(),CE=jc(),Jc=Uc(),OE=[wE.map,SE.seq,kE.string,vE.nullTag,vm.trueTag,vm.falseTag,bo.intBin,bo.intOct,bo.int,bo.intHex,qc.floatNaN,qc.floatExp,qc.float,xE.binary,EE.merge,AE.omap,TE.pairs,CE.set,Jc.intTime,Jc.floatTime,Jc.timestamp];Sm.schema=OE});var Im=_(Hc=>{"use strict";var Tm=Hn(),PE=ro(),Cm=zn(),_E=ls(),RE=kc(),Wc=Ec(),Kc=Tc(),IE=tm(),$E=sm(),Om=_c(),ps=Vi(),Pm=Nc(),_m=uo(),xm=km(),Rm=jc(),wo=Uc(),Em=new Map([["core",IE.schema],["failsafe",[Tm.map,Cm.seq,_E.string]],["json",$E.schema],["yaml11",xm.schema],["yaml-1.1",xm.schema]]),Am={binary:Om.binary,bool:RE.boolTag,float:Wc.float,floatExp:Wc.floatExp,floatNaN:Wc.floatNaN,floatTime:wo.floatTime,int:Kc.int,intHex:Kc.intHex,intOct:Kc.intOct,intTime:wo.intTime,map:Tm.map,merge:ps.merge,null:PE.nullTag,omap:Pm.omap,pairs:_m.pairs,seq:Cm.seq,set:Rm.set,timestamp:wo.timestamp},NE={"tag:yaml.org,2002:binary":Om.binary,"tag:yaml.org,2002:merge":ps.merge,"tag:yaml.org,2002:omap":Pm.omap,"tag:yaml.org,2002:pairs":_m.pairs,"tag:yaml.org,2002:set":Rm.set,"tag:yaml.org,2002:timestamp":wo.timestamp};function LE(t,e,n){let r=Em.get(e);if(r&&!t)return n&&!r.includes(ps.merge)?r.concat(ps.merge):r.slice();let s=r;if(!s)if(Array.isArray(t))s=[];else{let i=Array.from(Em.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${i} or define customTags array`)}if(Array.isArray(t))for(let i of t)s=s.concat(i);else typeof t=="function"&&(s=t(s.slice()));return n&&(s=s.concat(ps.merge)),s.reduce((i,o)=>{let a=typeof o=="string"?Am[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(Am).map(u=>JSON.stringify(u)).join(", ");throw new Error(`Unknown custom tag ${l}; use one of ${c}`)}return i.includes(a)||i.push(a),i},[])}Hc.coreKnownTags=NE;Hc.getTags=LE});var Vc=_($m=>{"use strict";var zc=J(),ME=Hn(),DE=zn(),BE=ls(),vo=Im(),jE=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,Yc=class t{constructor({compat:e,customTags:n,merge:r,resolveKnownTags:s,schema:i,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(e)?vo.getTags(e,"compat"):e?vo.getTags(null,e):null,this.name=typeof i=="string"&&i||"core",this.knownTags=s?vo.coreKnownTags:{},this.tags=vo.getTags(n,this.name,r),this.toStringOptions=a??null,Object.defineProperty(this,zc.MAP,{value:ME.map}),Object.defineProperty(this,zc.SCALAR,{value:BE.string}),Object.defineProperty(this,zc.SEQ,{value:DE.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?jE:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};$m.Schema=Yc});var Lm=_(Nm=>{"use strict";var FE=J(),Gc=ss(),hs=es();function UE(t,e){let n=[],r=e.directives===!0;if(e.directives!==!1&&t.directives){let l=t.directives.toString(t);l?(n.push(l),r=!0):t.directives.docStart&&(r=!0)}r&&n.push("---");let s=Gc.createStringifyContext(t,e),{commentString:i}=s.options;if(t.commentBefore){n.length!==1&&n.unshift("");let l=i(t.commentBefore);n.unshift(hs.indentComment(l,""))}let o=!1,a=null;if(t.contents){if(FE.isNode(t.contents)){if(t.contents.spaceBefore&&r&&n.push(""),t.contents.commentBefore){let u=i(t.contents.commentBefore);n.push(hs.indentComment(u,""))}s.forceBlockIndent=!!t.comment,a=t.contents.comment}let l=a?void 0:()=>o=!0,c=Gc.stringify(t.contents,s,()=>a=null,l);a&&(c+=hs.lineComment(c,"",i(a))),(c[0]==="|"||c[0]===">")&&n[n.length-1]==="---"?n[n.length-1]=`--- ${c}`:n.push(c)}else n.push(Gc.stringify(t.contents,s));if(t.directives?.docEnd)if(t.comment){let l=i(t.comment);l.includes(`
|
|
78
|
+
`)?(n.push("..."),n.push(hs.indentComment(l,""))):n.push(`... ${l}`)}else n.push("...");else{let l=t.comment;l&&o&&(l=l.replace(/^\n+/,"")),l&&((!o||a)&&n[n.length-1]!==""&&n.push(""),n.push(hs.indentComment(i(l),"")))}return n.join(`
|
|
79
79
|
`)+`
|
|
80
|
-
`}
|
|
80
|
+
`}Nm.stringifyDocument=UE});var ms=_(Mm=>{"use strict";var qE=Qr(),Vn=Fi(),Me=J(),JE=Nt(),WE=_t(),KE=Vc(),HE=Lm(),Xc=Mi(),zE=tc(),YE=Zr(),Qc=ec(),Zc=class t{constructor(e,n,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Me.NODE_TYPE,{value:Me.DOC});let s=null;typeof n=="function"||Array.isArray(n)?s=n:r===void 0&&n&&(r=n,n=void 0);let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},r);this.options=i;let{version:o}=i;r?._directives?(this.directives=r._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new Qc.Directives({version:o}),this.setSchema(o,r),this.contents=e===void 0?null:this.createNode(e,s,r)}clone(){let e=Object.create(t.prototype,{[Me.NODE_TYPE]:{value:Me.DOC}});return e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives&&(e.directives=this.directives.clone()),e.schema=this.schema.clone(),e.contents=Me.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){Gn(this.contents)&&this.contents.add(e)}addIn(e,n){Gn(this.contents)&&this.contents.addIn(e,n)}createAlias(e,n){if(!e.anchor){let r=Xc.anchorNames(this);e.anchor=!n||r.has(n)?Xc.findNewAnchor(n||"a",r):n}return new qE.Alias(e.anchor)}createNode(e,n,r){let s;if(typeof n=="function")e=n.call({"":e},"",e),s=n;else if(Array.isArray(n)){let g=A=>typeof A=="number"||A instanceof String||A instanceof Number,v=n.filter(g).map(String);v.length>0&&(n=n.concat(v)),s=n}else r===void 0&&n&&(r=n,n=void 0);let{aliasDuplicateObjects:i,anchorPrefix:o,flow:a,keepUndefined:l,onTagObj:c,tag:u}=r??{},{onAnchor:d,setAnchors:f,sourceObjects:p}=Xc.createNodeAnchors(this,o||"a"),h={aliasDuplicateObjects:i??!0,keepUndefined:l??!1,onAnchor:d,onTagObj:c,replacer:s,schema:this.schema,sourceObjects:p},m=YE.createNode(e,u,h);return a&&Me.isCollection(m)&&(m.flow=!0),f(),m}createPair(e,n,r={}){let s=this.createNode(e,null,r),i=this.createNode(n,null,r);return new JE.Pair(s,i)}delete(e){return Gn(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Vn.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):Gn(this.contents)?this.contents.deleteIn(e):!1}get(e,n){return Me.isCollection(this.contents)?this.contents.get(e,n):void 0}getIn(e,n){return Vn.isEmptyPath(e)?!n&&Me.isScalar(this.contents)?this.contents.value:this.contents:Me.isCollection(this.contents)?this.contents.getIn(e,n):void 0}has(e){return Me.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return Vn.isEmptyPath(e)?this.contents!==void 0:Me.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,n){this.contents==null?this.contents=Vn.collectionFromPath(this.schema,[e],n):Gn(this.contents)&&this.contents.set(e,n)}setIn(e,n){Vn.isEmptyPath(e)?this.contents=n:this.contents==null?this.contents=Vn.collectionFromPath(this.schema,Array.from(e),n):Gn(this.contents)&&this.contents.setIn(e,n)}setSchema(e,n={}){typeof e=="number"&&(e=String(e));let r;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new Qc.Directives({version:"1.1"}),r={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new Qc.Directives({version:e}),r={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,r=null;break;default:{let s=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${s}`)}}if(n.schema instanceof Object)this.schema=n.schema;else if(r)this.schema=new KE.Schema(Object.assign(r,n));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:n,mapAsMap:r,maxAliasCount:s,onAnchor:i,reviver:o}={}){let a={anchors:new Map,doc:this,keep:!e,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof s=="number"?s:100},l=WE.toJS(this.contents,n??"",a);if(typeof i=="function")for(let{count:c,res:u}of a.anchors.values())i(u,c);return typeof o=="function"?zE.applyReviver(o,{"":l},"",l):l}toJSON(e,n){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:n})}toString(e={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let n=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${n}`)}return HE.stringifyDocument(this,e)}};function Gn(t){if(Me.isCollection(t))return!0;throw new Error("Expected a YAML collection as document contents")}Mm.Document=Zc});var bs=_(ys=>{"use strict";var gs=class extends Error{constructor(e,n,r,s){super(),this.name=e,this.code=r,this.message=s,this.pos=n}},eu=class extends gs{constructor(e,n,r){super("YAMLParseError",e,n,r)}},tu=class extends gs{constructor(e,n,r){super("YAMLWarning",e,n,r)}},VE=(t,e)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(a=>e.linePos(a));let{line:r,col:s}=n.linePos[0];n.message+=` at line ${r}, column ${s}`;let i=s-1,o=t.substring(e.lineStarts[r-1],e.lineStarts[r]).replace(/[\n\r]+$/,"");if(i>=60&&o.length>80){let a=Math.min(i-39,o.length-79);o="\u2026"+o.substring(a),i-=a-1}if(o.length>80&&(o=o.substring(0,79)+"\u2026"),r>1&&/^ *$/.test(o.substring(0,i))){let a=t.substring(e.lineStarts[r-2],e.lineStarts[r-1]);a.length>80&&(a=a.substring(0,79)+`\u2026
|
|
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
|
-
`+C.comment:
|
|
89
|
-
`+I.comment:c.comment=I.comment),d=I.end;continue}!o&&n.options.strict&&
|
|
90
|
-
`+L:
|
|
91
|
-
`+F.comment:
|
|
92
|
-
`+g.comment:c.comment=g.comment),c.range=[r.offset,
|
|
93
|
-
`.repeat(Math.max(1,o.length-1)):"",g=r+s.length;return e.source&&(g+=e.source.length),{value:
|
|
94
|
-
`;for(let
|
|
95
|
-
`):g.length>l||
|
|
96
|
-
`:!p&&
|
|
97
|
-
`&&(
|
|
98
|
-
|
|
99
|
-
`),d+=
|
|
100
|
-
`,p=!0):
|
|
85
|
+
`}};ys.YAMLError=gs;ys.YAMLParseError=eu;ys.YAMLWarning=tu;ys.prettifyError=VE});var ws=_(Dm=>{"use strict";function GE(t,{flow:e,indicator:n,next:r,offset:s,onError:i,parentIndent:o,startOnNewline:a}){let l=!1,c=a,u=a,d="",f="",p=!1,h=!1,m=null,g=null,v=null,A=null,C=null,x=null,R=null;for(let T of t)switch(h&&(T.type!=="space"&&T.type!=="newline"&&T.type!=="comma"&&i(T.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),h=!1),m&&(c&&T.type!=="comment"&&T.type!=="newline"&&i(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),m=null),T.type){case"space":!e&&(n!=="doc-start"||r?.type!=="flow-collection")&&T.source.includes(" ")&&(m=T),u=!0;break;case"comment":{u||i(T,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let F=T.source.substring(1)||" ";d?d+=f+F:d=F,f="",c=!1;break}case"newline":c?d?d+=T.source:(!x||n!=="seq-item-ind")&&(l=!0):f+=T.source,c=!0,p=!0,(g||v)&&(A=T),u=!0;break;case"anchor":g&&i(T,"MULTIPLE_ANCHORS","A node can have at most one anchor"),T.source.endsWith(":")&&i(T.offset+T.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),g=T,R??(R=T.offset),c=!1,u=!1,h=!0;break;case"tag":{v&&i(T,"MULTIPLE_TAGS","A node can have at most one tag"),v=T,R??(R=T.offset),c=!1,u=!1,h=!0;break}case n:(g||v)&&i(T,"BAD_PROP_ORDER",`Anchors and tags must be after the ${T.source} indicator`),x&&i(T,"UNEXPECTED_TOKEN",`Unexpected ${T.source} in ${e??"collection"}`),x=T,c=n==="seq-item-ind"||n==="explicit-key-ind",u=!1;break;case"comma":if(e){C&&i(T,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),C=T,c=!1,u=!1;break}default:i(T,"UNEXPECTED_TOKEN",`Unexpected ${T.type} token`),c=!1,u=!1}let I=t[t.length-1],L=I?I.offset+I.source.length:s;return h&&r&&r.type!=="space"&&r.type!=="newline"&&r.type!=="comma"&&(r.type!=="scalar"||r.source!=="")&&i(r.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m&&(c&&m.indent<=o||r?.type==="block-map"||r?.type==="block-seq")&&i(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:C,found:x,spaceBefore:l,comment:d,hasNewline:p,anchor:g,tag:v,newlineAfterProp:A,end:L,start:R??L}}Dm.resolveProps=GE});var So=_(Bm=>{"use strict";function nu(t){if(!t)return null;switch(t.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(t.source.includes(`
|
|
86
|
+
`))return!0;if(t.end){for(let e of t.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of t.items){for(let n of e.start)if(n.type==="newline")return!0;if(e.sep){for(let n of e.sep)if(n.type==="newline")return!0}if(nu(e.key)||nu(e.value))return!0}return!1;default:return!0}}Bm.containsNewline=nu});var ru=_(jm=>{"use strict";var XE=So();function QE(t,e,n){if(e?.type==="flow-collection"){let r=e.end[0];r.indent===t&&(r.source==="]"||r.source==="}")&&XE.containsNewline(e)&&n(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}jm.flowIndentCheck=QE});var su=_(Um=>{"use strict";var Fm=J();function ZE(t,e,n){let{uniqueKeys:r}=t.options;if(r===!1)return!1;let s=typeof r=="function"?r:(i,o)=>i===o||Fm.isScalar(i)&&Fm.isScalar(o)&&i.value===o.value;return e.some(i=>s(i.key,n))}Um.mapIncludes=ZE});var zm=_(Hm=>{"use strict";var qm=Nt(),eA=Mt(),Jm=ws(),tA=So(),Wm=ru(),nA=su(),Km="All mapping items must start at the same column";function rA({composeNode:t,composeEmptyNode:e},n,r,s,i){let o=i?.nodeClass??eA.YAMLMap,a=new o(n.schema);n.atRoot&&(n.atRoot=!1);let l=r.offset,c=null;for(let u of r.items){let{start:d,key:f,sep:p,value:h}=u,m=Jm.resolveProps(d,{indicator:"explicit-key-ind",next:f??p?.[0],offset:l,onError:s,parentIndent:r.indent,startOnNewline:!0}),g=!m.found;if(g){if(f&&(f.type==="block-seq"?s(l,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in f&&f.indent!==r.indent&&s(l,"BAD_INDENT",Km)),!m.anchor&&!m.tag&&!p){c=m.end,m.comment&&(a.comment?a.comment+=`
|
|
87
|
+
`+m.comment:a.comment=m.comment);continue}(m.newlineAfterProp||tA.containsNewline(f))&&s(f??d[d.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else m.found?.indent!==r.indent&&s(l,"BAD_INDENT",Km);n.atKey=!0;let v=m.end,A=f?t(n,f,m,s):e(n,v,d,null,m,s);n.schema.compat&&Wm.flowIndentCheck(r.indent,f,s),n.atKey=!1,nA.mapIncludes(n,a.items,A)&&s(v,"DUPLICATE_KEY","Map keys must be unique");let C=Jm.resolveProps(p??[],{indicator:"map-value-ind",next:h,offset:A.range[2],onError:s,parentIndent:r.indent,startOnNewline:!f||f.type==="block-scalar"});if(l=C.end,C.found){g&&(h?.type==="block-map"&&!C.hasNewline&&s(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),n.options.strict&&m.start<C.found.offset-1024&&s(A.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let x=h?t(n,h,C,s):e(n,l,p,null,C,s);n.schema.compat&&Wm.flowIndentCheck(r.indent,h,s),l=x.range[2];let R=new qm.Pair(A,x);n.options.keepSourceTokens&&(R.srcToken=u),a.items.push(R)}else{g&&s(A.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),C.comment&&(A.comment?A.comment+=`
|
|
88
|
+
`+C.comment:A.comment=C.comment);let x=new qm.Pair(A);n.options.keepSourceTokens&&(x.srcToken=u),a.items.push(x)}}return c&&c<l&&s(c,"IMPOSSIBLE","Map comment with trailing content"),a.range=[r.offset,l,c??l],a}Hm.resolveBlockMap=rA});var Vm=_(Ym=>{"use strict";var sA=Dt(),iA=ws(),oA=ru();function aA({composeNode:t,composeEmptyNode:e},n,r,s,i){let o=i?.nodeClass??sA.YAMLSeq,a=new o(n.schema);n.atRoot&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let l=r.offset,c=null;for(let{start:u,value:d}of r.items){let f=iA.resolveProps(u,{indicator:"seq-item-ind",next:d,offset:l,onError:s,parentIndent:r.indent,startOnNewline:!0});if(!f.found)if(f.anchor||f.tag||d)d?.type==="block-seq"?s(f.end,"BAD_INDENT","All sequence items must start at the same column"):s(l,"MISSING_CHAR","Sequence item without - indicator");else{c=f.end,f.comment&&(a.comment=f.comment);continue}let p=d?t(n,d,f,s):e(n,f.end,u,null,f,s);n.schema.compat&&oA.flowIndentCheck(r.indent,d,s),l=p.range[2],a.items.push(p)}return a.range=[r.offset,l,c??l],a}Ym.resolveBlockSeq=aA});var Xn=_(Gm=>{"use strict";function lA(t,e,n,r){let s="";if(t){let i=!1,o="";for(let a of t){let{source:l,type:c}=a;switch(c){case"space":i=!0;break;case"comment":{n&&!i&&r(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let u=l.substring(1)||" ";s?s+=o+u:s=u,o="";break}case"newline":s&&(o+=l),i=!0;break;default:r(a,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}e+=l.length}}return{comment:s,offset:e}}Gm.resolveEnd=lA});var eg=_(Zm=>{"use strict";var cA=J(),uA=Nt(),Xm=Mt(),dA=Dt(),fA=Xn(),Qm=ws(),pA=So(),hA=su(),iu="Block collections are not allowed within flow collections",ou=t=>t&&(t.type==="block-map"||t.type==="block-seq");function mA({composeNode:t,composeEmptyNode:e},n,r,s,i){let o=r.start.source==="{",a=o?"flow map":"flow sequence",l=i?.nodeClass??(o?Xm.YAMLMap:dA.YAMLSeq),c=new l(n.schema);c.flow=!0;let u=n.atRoot;u&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let d=r.offset+r.start.source.length;for(let g=0;g<r.items.length;++g){let v=r.items[g],{start:A,key:C,sep:x,value:R}=v,I=Qm.resolveProps(A,{flow:a,indicator:"explicit-key-ind",next:C??x?.[0],offset:d,onError:s,parentIndent:r.indent,startOnNewline:!1});if(!I.found){if(!I.anchor&&!I.tag&&!x&&!R){g===0&&I.comma?s(I.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):g<r.items.length-1&&s(I.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),I.comment&&(c.comment?c.comment+=`
|
|
89
|
+
`+I.comment:c.comment=I.comment),d=I.end;continue}!o&&n.options.strict&&pA.containsNewline(C)&&s(C,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(g===0)I.comma&&s(I.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(I.comma||s(I.start,"MISSING_CHAR",`Missing , between ${a} items`),I.comment){let L="";e:for(let T of A)switch(T.type){case"comma":case"space":break;case"comment":L=T.source.substring(1);break e;default:break e}if(L){let T=c.items[c.items.length-1];cA.isPair(T)&&(T=T.value??T.key),T.comment?T.comment+=`
|
|
90
|
+
`+L:T.comment=L,I.comment=I.comment.substring(L.length+1)}}if(!o&&!x&&!I.found){let L=R?t(n,R,I,s):e(n,I.end,x,null,I,s);c.items.push(L),d=L.range[2],ou(R)&&s(L.range,"BLOCK_IN_FLOW",iu)}else{n.atKey=!0;let L=I.end,T=C?t(n,C,I,s):e(n,L,A,null,I,s);ou(C)&&s(T.range,"BLOCK_IN_FLOW",iu),n.atKey=!1;let F=Qm.resolveProps(x??[],{flow:a,indicator:"map-value-ind",next:R,offset:T.range[2],onError:s,parentIndent:r.indent,startOnNewline:!1});if(F.found){if(!o&&!I.found&&n.options.strict){if(x)for(let U of x){if(U===F.found)break;if(U.type==="newline"){s(U,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}I.start<F.found.offset-1024&&s(F.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else R&&("source"in R&&R.source?.[0]===":"?s(R,"MISSING_CHAR",`Missing space after : in ${a}`):s(F.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let H=R?t(n,R,F,s):F.found?e(n,F.end,x,null,F,s):null;H?ou(R)&&s(H.range,"BLOCK_IN_FLOW",iu):F.comment&&(T.comment?T.comment+=`
|
|
91
|
+
`+F.comment:T.comment=F.comment);let ne=new uA.Pair(T,H);if(n.options.keepSourceTokens&&(ne.srcToken=v),o){let U=c;hA.mapIncludes(n,U.items,T)&&s(L,"DUPLICATE_KEY","Map keys must be unique"),U.items.push(ne)}else{let U=new Xm.YAMLMap(n.schema);U.flow=!0,U.items.push(ne);let re=(H??T).range;U.range=[T.range[0],re[1],re[2]],c.items.push(U)}d=H?H.range[2]:F.end}}let f=o?"}":"]",[p,...h]=r.end,m=d;if(p?.source===f)m=p.offset+p.source.length;else{let g=a[0].toUpperCase()+a.substring(1),v=u?`${g} must end with a ${f}`:`${g} in block collection must be sufficiently indented and end with a ${f}`;s(d,u?"MISSING_CHAR":"BAD_INDENT",v),p&&p.source.length!==1&&h.unshift(p)}if(h.length>0){let g=fA.resolveEnd(h,m,n.options.strict,s);g.comment&&(c.comment?c.comment+=`
|
|
92
|
+
`+g.comment:c.comment=g.comment),c.range=[r.offset,m,g.offset]}else c.range=[r.offset,m,m];return c}Zm.resolveFlowCollection=mA});var ng=_(tg=>{"use strict";var gA=J(),yA=se(),bA=Mt(),wA=Dt(),vA=zm(),SA=Vm(),kA=eg();function au(t,e,n,r,s,i){let o=n.type==="block-map"?vA.resolveBlockMap(t,e,n,r,i):n.type==="block-seq"?SA.resolveBlockSeq(t,e,n,r,i):kA.resolveFlowCollection(t,e,n,r,i),a=o.constructor;return s==="!"||s===a.tagName?(o.tag=a.tagName,o):(s&&(o.tag=s),o)}function xA(t,e,n,r,s){let i=r.tag,o=i?e.directives.tagName(i.source,f=>s(i,"TAG_RESOLVE_FAILED",f)):null;if(n.type==="block-seq"){let{anchor:f,newlineAfterProp:p}=r,h=f&&i?f.offset>i.offset?f:i:f??i;h&&(!p||p.offset<h.offset)&&s(h,"MISSING_CHAR","Missing newline after block sequence props")}let a=n.type==="block-map"?"map":n.type==="block-seq"?"seq":n.start.source==="{"?"map":"seq";if(!i||!o||o==="!"||o===bA.YAMLMap.tagName&&a==="map"||o===wA.YAMLSeq.tagName&&a==="seq")return au(t,e,n,s,o);let l=e.schema.tags.find(f=>f.tag===o&&f.collection===a);if(!l){let f=e.schema.knownTags[o];if(f?.collection===a)e.schema.tags.push(Object.assign({},f,{default:!1})),l=f;else return f?s(i,"BAD_COLLECTION_TYPE",`${f.tag} used for ${a} collection, but expects ${f.collection??"scalar"}`,!0):s(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),au(t,e,n,s,o)}let c=au(t,e,n,s,o,l),u=l.resolve?.(c,f=>s(i,"TAG_RESOLVE_FAILED",f),e.options)??c,d=gA.isNode(u)?u:new yA.Scalar(u);return d.range=c.range,d.tag=o,l?.format&&(d.format=l.format),d}tg.composeCollection=xA});var cu=_(rg=>{"use strict";var lu=se();function EA(t,e,n){let r=e.offset,s=AA(e,t.options.strict,n);if(!s)return{value:"",type:null,comment:"",range:[r,r,r]};let i=s.mode===">"?lu.Scalar.BLOCK_FOLDED:lu.Scalar.BLOCK_LITERAL,o=e.source?TA(e.source):[],a=o.length;for(let m=o.length-1;m>=0;--m){let g=o[m][1];if(g===""||g==="\r")a=m;else break}if(a===0){let m=s.chomp==="+"&&o.length>0?`
|
|
93
|
+
`.repeat(Math.max(1,o.length-1)):"",g=r+s.length;return e.source&&(g+=e.source.length),{value:m,type:i,comment:s.comment,range:[r,g,g]}}let l=e.indent+s.indent,c=e.offset+s.length,u=0;for(let m=0;m<a;++m){let[g,v]=o[m];if(v===""||v==="\r")s.indent===0&&g.length>l&&(l=g.length);else{g.length<l&&n(c+g.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),s.indent===0&&(l=g.length),u=m,l===0&&!t.atRoot&&n(c,"BAD_INDENT","Block scalar values in collections must be indented");break}c+=g.length+v.length+1}for(let m=o.length-1;m>=a;--m)o[m][0].length>l&&(a=m+1);let d="",f="",p=!1;for(let m=0;m<u;++m)d+=o[m][0].slice(l)+`
|
|
94
|
+
`;for(let m=u;m<a;++m){let[g,v]=o[m];c+=g.length+v.length+1;let A=v[v.length-1]==="\r";if(A&&(v=v.slice(0,-1)),v&&g.length<l){let x=`Block scalar lines must not be less indented than their ${s.indent?"explicit indentation indicator":"first line"}`;n(c-v.length-(A?2:1),"BAD_INDENT",x),g=""}i===lu.Scalar.BLOCK_LITERAL?(d+=f+g.slice(l)+v,f=`
|
|
95
|
+
`):g.length>l||v[0]===" "?(f===" "?f=`
|
|
96
|
+
`:!p&&f===`
|
|
97
|
+
`&&(f=`
|
|
98
|
+
|
|
99
|
+
`),d+=f+g.slice(l)+v,f=`
|
|
100
|
+
`,p=!0):v===""?f===`
|
|
101
101
|
`?d+=`
|
|
102
|
-
`:
|
|
103
|
-
`:(d+=
|
|
104
|
-
`+o[
|
|
102
|
+
`:f=`
|
|
103
|
+
`:(d+=f+v,f=" ",p=!1)}switch(s.chomp){case"-":break;case"+":for(let m=a;m<o.length;++m)d+=`
|
|
104
|
+
`+o[m][0].slice(l);d[d.length-1]!==`
|
|
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 AA({offset:t,props:e},n,r){if(e[0].type!=="block-scalar-header")return r(e[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:s}=e[0],i=s[0],o=0,a="",l=-1;for(let f=1;f<s.length;++f){let p=s[f];if(!a&&(p==="-"||p==="+"))a=p;else{let h=Number(p);!o&&h?o=h:l===-1&&(l=t+f)}}l!==-1&&r(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${s}`);let c=!1,u="",d=s.length;for(let f=1;f<e.length;++f){let p=e[f];switch(p.type){case"space":c=!0;case"newline":d+=p.source.length;break;case"comment":n&&!c&&r(p,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),d+=p.source.length,u=p.source.substring(1);break;case"error":r(p,"UNEXPECTED_TOKEN",p.message),d+=p.source.length;break;default:{let h=`Unexpected token in block scalar header: ${p.type}`;r(p,"UNEXPECTED_TOKEN",h);let m=p.source;m&&typeof m=="string"&&(d+=m.length)}}}return{mode:i,indent:o,chomp:a,comment:u,length:d}}function TA(t){let e=t.split(/\n( *)/),n=e[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:["",n]];for(let o=1;o<e.length;o+=2)i.push([e[o],e[o+1]]);return i}rg.resolveBlockScalar=EA});var du=_(ig=>{"use strict";var uu=se(),CA=Xn();function OA(t,e,n){let{offset:r,type:s,source:i,end:o}=t,a,l,c=(f,p,h)=>n(r+f,p,h);switch(s){case"scalar":a=uu.Scalar.PLAIN,l=PA(i,c);break;case"single-quoted-scalar":a=uu.Scalar.QUOTE_SINGLE,l=_A(i,c);break;case"double-quoted-scalar":a=uu.Scalar.QUOTE_DOUBLE,l=RA(i,c);break;default:return n(t,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${s}`),{value:"",type:null,comment:"",range:[r,r+i.length,r+i.length]}}let u=r+i.length,d=CA.resolveEnd(o,u,e,n);return{value:l,type:a,comment:d.comment,range:[r,u,d.offset]}}function PA(t,e){let n="";switch(t[0]){case" ":n="a tab character";break;case",":n="flow indicator character ,";break;case"%":n="directive indicator character %";break;case"|":case">":{n=`block scalar indicator ${t[0]}`;break}case"@":case"`":{n=`reserved character ${t[0]}`;break}}return n&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${n}`),sg(t)}function _A(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),sg(t.slice(1,-1)).replace(/''/g,"'")}function sg(t){let e,n;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
|
|
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 RA(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}=IA(t,r);n+=i,r=o}else if(s==="\\"){let i=t[++r],o=$A[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+=NA(t,r+1,a,e),r+=a}else{let a=t.substr(r-1,2);e(r-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),n+=a}}else if(s===" "||s===" "){let i=r,o=t[r+1];for(;o===" "||o===" ";)o=t[++r+1];o!==`
|
|
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 IA(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 $A={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
|
|
122
|
+
`,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function NA(t,e,n,r){let s=t.substr(e,n),o=s.length===n&&/^[0-9a-fA-F]+$/.test(s)?parseInt(s,16):NaN;if(isNaN(o)){let a=t.substr(e-2,n+2);return r(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}return String.fromCodePoint(o)}ig.resolveFlowScalar=OA});var lg=_(ag=>{"use strict";var un=J(),og=se(),LA=cu(),MA=du();function DA(t,e,n,r){let{value:s,type:i,comment:o,range:a}=e.type==="block-scalar"?LA.resolveBlockScalar(t,e,r):MA.resolveFlowScalar(e,t.options.strict,r),l=n?t.directives.tagName(n.source,d=>r(n,"TAG_RESOLVE_FAILED",d)):null,c;t.options.stringKeys&&t.atKey?c=t.schema[un.SCALAR]:l?c=BA(t.schema,s,l,n,r):e.type==="scalar"?c=jA(t,s,e,r):c=t.schema[un.SCALAR];let u;try{let d=c.resolve(s,f=>r(n??e,"TAG_RESOLVE_FAILED",f),t.options);u=un.isScalar(d)?d:new og.Scalar(d)}catch(d){let f=d instanceof Error?d.message:String(d);r(n??e,"TAG_RESOLVE_FAILED",f),u=new og.Scalar(s)}return u.range=a,u.source=s,i&&(u.type=i),l&&(u.tag=l),c.format&&(u.format=c.format),o&&(u.comment=o),u}function BA(t,e,n,r,s){if(n==="!")return t[un.SCALAR];let i=[];for(let a of t.tags)if(!a.collection&&a.tag===n)if(a.default&&a.test)i.push(a);else return a;for(let a of i)if(a.test?.test(e))return a;let o=t.knownTags[n];return o&&!o.collection?(t.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(s(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${n}`,n!=="tag:yaml.org,2002:str"),t[un.SCALAR])}function jA({atKey:t,directives:e,schema:n},r,s,i){let o=n.tags.find(a=>(a.default===!0||t&&a.default==="key")&&a.test?.test(r))||n[un.SCALAR];if(n.compat){let a=n.compat.find(l=>l.default&&l.test?.test(r))??n[un.SCALAR];if(o.tag!==a.tag){let l=e.tagString(o.tag),c=e.tagString(a.tag),u=`Value may be parsed as either ${l} or ${c}`;i(s,"TAG_RESOLVE_FAILED",u,!0)}}return o}ag.composeScalar=DA});var ug=_(cg=>{"use strict";function FA(t,e,n){if(e){n??(n=e.length);for(let r=n-1;r>=0;--r){let s=e[r];switch(s.type){case"space":case"comment":case"newline":t-=s.source.length;continue}for(s=e[++r];s?.type==="space";)t+=s.source.length,s=e[++r];break}}return t}cg.emptyScalarPosition=FA});var pg=_(pu=>{"use strict";var UA=Qr(),qA=J(),JA=ng(),dg=lg(),WA=Xn(),KA=ug(),HA={composeNode:fg,composeEmptyNode:fu};function fg(t,e,n,r){let s=t.atKey,{spaceBefore:i,comment:o,anchor:a,tag:l}=n,c,u=!0;switch(e.type){case"alias":c=zA(t,e,r),(a||l)&&r(e,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":c=dg.composeScalar(t,e,l,r),a&&(c.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":c=JA.composeCollection(HA,t,e,n,r),a&&(c.anchor=a.source.substring(1));break;default:{let d=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;r(e,"UNEXPECTED_TOKEN",d),c=fu(t,e.offset,void 0,null,n,r),u=!1}}return a&&c.anchor===""&&r(a,"BAD_ALIAS","Anchor cannot be an empty string"),s&&t.options.stringKeys&&(!qA.isScalar(c)||typeof c.value!="string"||c.tag&&c.tag!=="tag:yaml.org,2002:str")&&r(l??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),i&&(c.spaceBefore=!0),o&&(e.type==="scalar"&&e.source===""?c.comment=o:c.commentBefore=o),t.options.keepSourceTokens&&u&&(c.srcToken=e),c}function fu(t,e,n,r,{spaceBefore:s,comment:i,anchor:o,tag:a,end:l},c){let u={type:"scalar",offset:KA.emptyScalarPosition(e,n,r),indent:-1,source:""},d=dg.composeScalar(t,u,a,c);return o&&(d.anchor=o.source.substring(1),d.anchor===""&&c(o,"BAD_ALIAS","Anchor cannot be an empty string")),s&&(d.spaceBefore=!0),i&&(d.comment=i,d.range[2]=l),d}function zA({options:t},{offset:e,source:n,end:r},s){let i=new UA.Alias(n.substring(1));i.source===""&&s(e,"BAD_ALIAS","Alias cannot be an empty string"),i.source.endsWith(":")&&s(e+n.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=e+n.length,a=WA.resolveEnd(r,o,t.strict,s);return i.range=[e,o,a.offset],a.comment&&(i.comment=a.comment),i}pu.composeEmptyNode=fu;pu.composeNode=fg});var gg=_(mg=>{"use strict";var YA=ms(),hg=pg(),VA=Xn(),GA=ws();function XA(t,e,{offset:n,start:r,value:s,end:i},o){let a=Object.assign({_directives:e},t),l=new YA.Document(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},u=GA.resolveProps(r,{indicator:"doc-start",next:s??i?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});u.found&&(l.directives.docStart=!0,s&&(s.type==="block-map"||s.type==="block-seq")&&!u.hasNewline&&o(u.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),l.contents=s?hg.composeNode(c,s,u,o):hg.composeEmptyNode(c,u.end,r,null,u,o);let d=l.contents.range[2],f=VA.resolveEnd(i,d,!1,o);return f.comment&&(l.comment=f.comment),l.range=[n,d,f.offset],l}mg.composeDoc=XA});var mu=_(wg=>{"use strict";var QA=Ei("process"),ZA=ec(),eT=ms(),vs=bs(),yg=J(),tT=gg(),nT=Xn();function Ss(t){if(typeof t=="number")return[t,t+1];if(Array.isArray(t))return t.length===2?t:[t[0],t[1]];let{offset:e,source:n}=t;return[e,e+(typeof n=="string"?n.length:1)]}function bg(t){let e="",n=!1,r=!1;for(let s=0;s<t.length;++s){let i=t[s];switch(i[0]){case"#":e+=(e===""?"":r?`
|
|
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 hu=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(n,r,s,i)=>{let o=Ss(n);i?this.warnings.push(new vs.YAMLWarning(o,r,s)):this.errors.push(new vs.YAMLParseError(o,r,s))},this.directives=new ZA.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,n){let{comment:r,afterEmptyLine:s}=bg(this.prelude);if(r){let i=e.contents;if(n)e.comment=e.comment?`${e.comment}
|
|
126
|
+
${r}`:r;else if(s||e.directives.docStart||!i)e.commentBefore=r;else if(yg.isCollection(i)&&!i.flow&&i.items.length>0){let o=i.items[0];yg.isPair(o)&&(o=o.key);let a=o.commentBefore;o.commentBefore=a?`${r}
|
|
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:bg(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,n=!1,r=-1){for(let s of e)yield*this.next(s);yield*this.end(n,r)}*next(e){switch(QA.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(n,r,s)=>{let i=Ss(e);i[0]+=n,this.onError(i,"BAD_DIRECTIVE",r,s)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let n=tT.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!n.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(n,!1),this.doc&&(yield this.doc),this.doc=n,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let n=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,r=new vs.YAMLParseError(Ss(e),"UNEXPECTED_TOKEN",n);this.atDirectives||!this.doc?this.errors.push(r):this.doc.errors.push(r);break}case"doc-end":{if(!this.doc){let r="Unexpected doc-end without preceding document";this.errors.push(new vs.YAMLParseError(Ss(e),"UNEXPECTED_TOKEN",r));break}this.doc.directives.docEnd=!0;let n=nT.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),n.comment){let r=this.doc.comment;this.doc.comment=r?`${r}
|
|
129
|
+
${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.push(new vs.YAMLParseError(Ss(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,n=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let r=Object.assign({_directives:this.directives},this.options),s=new eT.Document(void 0,r);this.atDirectives&&this.onError(n,"MISSING_CHAR","Missing directives-end indicator line"),s.range=[0,n,n],this.decorate(s,!1),yield s}}};wg.Composer=hu});var kg=_(ko=>{"use strict";var rT=cu(),sT=du(),iT=bs(),vg=rs();function oT(t,e=!0,n){if(t){let r=(s,i,o)=>{let a=typeof s=="number"?s:Array.isArray(s)?s[0]:s.offset;if(n)n(a,i,o);else throw new iT.YAMLParseError([a,a+1],i,o)};switch(t.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return sT.resolveFlowScalar(t,e,r);case"block-scalar":return rT.resolveBlockScalar({options:{strict:e}},t,r)}}return null}function aT(t,e){let{implicitKey:n=!1,indent:r,inFlow:s=!1,offset:i=-1,type:o="PLAIN"}=e,a=vg.stringifyString({type:o,value:t},{implicitKey:n,indent:r>0?" ".repeat(r):"",inFlow:s,options:{blockQuote:!0,lineWidth:-1}}),l=e.end??[{type:"newline",offset:-1,indent:r,source:`
|
|
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 Sg(f,l)||f.push({type:"newline",offset:-1,indent:r,source:`
|
|
133
|
+
`}),{type:"block-scalar",offset:i,indent:r,props:f,source:d}}case'"':return{type:"double-quoted-scalar",offset:i,indent:r,source:a,end:l};case"'":return{type:"single-quoted-scalar",offset:i,indent:r,source:a,end:l};default:return{type:"scalar",offset:i,indent:r,source:a,end:l}}}function lT(t,e,n={}){let{afterKey:r=!1,implicitKey:s=!1,inFlow:i=!1,type:o}=n,a="indent"in t?t.indent:null;if(r&&typeof a=="number"&&(a+=2),!o)switch(t.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let c=t.props[0];if(c.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o=c.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let l=vg.stringifyString({type:o,value:e},{implicitKey:s||a===null,indent:a!==null&&a>0?" ".repeat(a):"",inFlow:i,options:{blockQuote:!0,lineWidth:-1}});switch(l[0]){case"|":case">":cT(t,l);break;case'"':gu(t,l,"double-quoted-scalar");break;case"'":gu(t,l,"single-quoted-scalar");break;default:gu(t,l,"scalar")}}function cT(t,e){let n=e.indexOf(`
|
|
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})}}}
|
|
135
|
+
`;if(t.type==="block-scalar"){let i=t.props[0];if(i.type!=="block-scalar-header")throw new Error("Invalid block scalar header");i.source=r,t.source=s}else{let{offset:i}=t,o="indent"in t?t.indent:-1,a=[{type:"block-scalar-header",offset:i,indent:o,source:r}];Sg(a,"end"in t?t.end:void 0)||a.push({type:"newline",offset:-1,indent:o,source:`
|
|
136
|
+
`});for(let l of Object.keys(t))l!=="type"&&l!=="offset"&&delete t[l];Object.assign(t,{type:"block-scalar",indent:o,props:a,source:s})}}function Sg(t,e){if(e)for(let n of e)switch(n.type){case"space":case"comment":t.push(n);break;case"newline":return t.push(n),!0}return!1}function gu(t,e,n){switch(t.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":t.type=n,t.source=e;break;case"block-scalar":{let r=t.props.slice(1),s=e.length;t.props[0].type==="block-scalar-header"&&(s-=t.props[0].source.length);for(let i of r)i.offset+=s;delete t.props,Object.assign(t,{type:n,source:e,end:r});break}case"block-map":case"block-seq":{let s={type:"newline",offset:t.offset+e.length,indent:t.indent,source:`
|
|
137
|
+
`};delete t.items,Object.assign(t,{type:n,source:e,end:[s]});break}default:{let r="indent"in t?t.indent:-1,s="end"in t&&Array.isArray(t.end)?t.end.filter(i=>i.type==="space"||i.type==="comment"||i.type==="newline"):[];for(let i of Object.keys(t))i!=="type"&&i!=="offset"&&delete t[i];Object.assign(t,{type:n,indent:r,source:e,end:s})}}}ko.createScalarToken=aT;ko.resolveAsScalar=oT;ko.setScalarValue=lT});var Eg=_(xg=>{"use strict";var uT=t=>"type"in t?Eo(t):xo(t);function Eo(t){switch(t.type){case"block-scalar":{let e="";for(let n of t.props)e+=Eo(n);return e+t.source}case"block-map":case"block-seq":{let e="";for(let n of t.items)e+=xo(n);return e}case"flow-collection":{let e=t.start.source;for(let n of t.items)e+=xo(n);for(let n of t.end)e+=n.source;return e}case"document":{let e=xo(t);if(t.end)for(let n of t.end)e+=n.source;return e}default:{let e=t.source;if("end"in t&&t.end)for(let n of t.end)e+=n.source;return e}}}function xo({start:t,key:e,sep:n,value:r}){let s="";for(let i of t)s+=i.source;if(e&&(s+=Eo(e)),n)for(let i of n)s+=i.source;return r&&(s+=Eo(r)),s}xg.stringify=uT});var Og=_(Cg=>{"use strict";var yu=Symbol("break visit"),dT=Symbol("skip children"),Ag=Symbol("remove item");function dn(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),Tg(Object.freeze([]),t,e)}dn.BREAK=yu;dn.SKIP=dT;dn.REMOVE=Ag;dn.itemAtPath=(t,e)=>{let n=t;for(let[r,s]of e){let i=n?.[r];if(i&&"items"in i)n=i.items[s];else return}return n};dn.parentCollection=(t,e)=>{let n=dn.itemAtPath(t,e.slice(0,-1)),r=e[e.length-1][0],s=n?.[r];if(s&&"items"in s)return s;throw new Error("Parent collection not found")};function Tg(t,e,n){let r=n(e,t);if(typeof r=="symbol")return r;for(let s of["key","value"]){let i=e[s];if(i&&"items"in i){for(let o=0;o<i.items.length;++o){let a=Tg(Object.freeze(t.concat([[s,o]])),i.items[o],n);if(typeof a=="number")o=a-1;else{if(a===yu)return yu;a===Ag&&(i.items.splice(o,1),o-=1)}}typeof r=="function"&&s==="key"&&(r=r(e,t))}}return typeof r=="function"?r(e,t):r}Cg.visit=dn});var Ao=_(xe=>{"use strict";var bu=kg(),fT=Eg(),pT=Og(),wu="\uFEFF",vu="",Su="",ku="",hT=t=>!!t&&"items"in t,mT=t=>!!t&&(t.type==="scalar"||t.type==="single-quoted-scalar"||t.type==="double-quoted-scalar"||t.type==="block-scalar");function gT(t){switch(t){case wu:return"<BOM>";case vu:return"<DOC>";case Su:return"<FLOW_END>";case ku:return"<SCALAR>";default:return JSON.stringify(t)}}function yT(t){switch(t){case wu:return"byte-order-mark";case vu:return"doc-mode";case Su:return"flow-error-end";case ku:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
|
|
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}xe.createScalarToken=bu.createScalarToken;xe.resolveAsScalar=bu.resolveAsScalar;xe.setScalarValue=bu.setScalarValue;xe.stringify=fT.stringify;xe.visit=pT.visit;xe.BOM=wu;xe.DOCUMENT=vu;xe.FLOW_END=Su;xe.SCALAR=ku;xe.isCollection=hT;xe.isScalar=mT;xe.prettyToken=gT;xe.tokenType=yT});var Au=_(_g=>{"use strict";var ks=Ao();function Ve(t){switch(t){case void 0:case" ":case`
|
|
140
|
+
`:case"\r":case" ":return!0;default:return!1}}var Pg=new Set("0123456789ABCDEFabcdef"),bT=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),To=new Set(",[]{}"),wT=new Set(` ,[]{}
|
|
141
|
+
\r `),xu=t=>!t||wT.has(t),Eu=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,n=!1){if(e){if(typeof e!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!n;let r=this.next??"stream";for(;r&&(n||this.hasChars(1));)r=yield*this.parseNext(r)}atLineEnd(){let e=this.pos,n=this.buffer[e];for(;n===" "||n===" ";)n=this.buffer[++e];return!n||n==="#"||n===`
|
|
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==="...")&&Ve(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]===ks.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 ks.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==="...")&&Ve(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&&!Ve(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===":")&&Ve(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(xu),"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("..."))&&Ve(s[3]))&&!(r===this.indentNext-1&&this.flowLevel===1&&(s[0]==="]"||s[0]==="}")))return this.flowLevel=0,yield ks.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(xu),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||Ve(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=>Ve(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 ks.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,n=this.pos-1,r=this.pos-1,s;for(;s=this.buffer[++r];)if(s===":"){let i=this.buffer[r+1];if(Ve(i)||e&&To.has(i))break;n=r}else if(Ve(s)){let i=this.buffer[r+1];if(s==="\r"&&(i===`
|
|
154
154
|
`?(r+=1,s=`
|
|
155
|
-
`,i=this.buffer[r+1]):n=r),i==="#"||e&&
|
|
156
|
-
`){let o=this.continueScalar(r+1);if(o===-1)break;r=Math.max(r,o-2)}}else{if(e&&
|
|
155
|
+
`,i=this.buffer[r+1]):n=r),i==="#"||e&&To.has(i))break;if(s===`
|
|
156
|
+
`){let o=this.continueScalar(r+1);if(o===-1)break;r=Math.max(r,o-2)}}else{if(e&&To.has(s))break;n=r}return!s&&!this.atEnd?this.setNext("plain-scalar"):(yield ks.SCALAR,yield*this.pushToIndex(n+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,n){let r=this.buffer.slice(this.pos,e);return r?(yield r,this.pos+=r.length,r.length):(n&&(yield""),0)}*pushIndicators(){switch(this.charAt(0)){case"!":return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"&":return(yield*this.pushUntil(xu))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let e=this.flowLevel>0,n=this.charAt(1);if(Ve(n)||e&&To.has(n))return e?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,(yield*this.pushCount(1))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators())}}return 0}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,n=this.buffer[e];for(;!Ve(n)&&n!==">";)n=this.buffer[++e];return yield*this.pushToIndex(n===">"?e+1:e,!1)}else{let e=this.pos+1,n=this.buffer[e];for(;n;)if(bT.has(n))n=this.buffer[++e];else if(n==="%"&&Pg.has(this.buffer[e+1])&&Pg.has(this.buffer[e+2]))n=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
|
|
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)}};_g.Lexer=Eu});var Cu=_(Rg=>{"use strict";var Tu=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let n=0,r=this.lineStarts.length;for(;n<r;){let i=n+r>>1;this.lineStarts[i]<e?n=i+1:r=i}if(this.lineStarts[n]===e)return{line:n+1,col:1};if(n===0)return{line:0,col:e};let s=this.lineStarts[n-1];return{line:n,col:e-s+1}}}};Rg.LineCounter=Tu});var Pu=_(Mg=>{"use strict";var vT=Ei("process"),Ig=Ao(),ST=Au();function Bt(t,e){for(let n=0;n<t.length;++n)if(t[n].type===e)return!0;return!1}function $g(t){for(let e=0;e<t.length;++e)switch(t[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function Lg(t){switch(t?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function Co(t){switch(t.type){case"document":return t.start;case"block-map":{let e=t.items[t.items.length-1];return e.sep??e.start}case"block-seq":return t.items[t.items.length-1].start;default:return[]}}function Qn(t){if(t.length===0)return[];let e=t.length;e:for(;--e>=0;)switch(t[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;t[++e]?.type==="space";);return t.splice(e,t.length)}function Ng(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!Bt(e.start,"explicit-key-ind")&&!Bt(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,Lg(e.value)?e.value.end?Array.prototype.push.apply(e.value.end,e.sep):e.value.end=e.sep:Array.prototype.push.apply(e.start,e.sep),delete e.sep)}var Ou=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new ST.Lexer,this.onNewLine=e}*parse(e,n=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let r of this.lexer.lex(e,n))yield*this.next(r);n||(yield*this.end())}*next(e){if(this.source=e,vT.env.LOG_TOKENS&&console.log("|",Ig.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let n=Ig.tokenType(e);if(n)if(n==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=n,yield*this.step(),n){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&e[0]===" "&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{let r=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:r,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type==="doc-end"&&e?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let n=e??this.stack.pop();if(!n)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield n;else{let r=this.peek(1);switch(n.type==="block-scalar"?n.indent="indent"in r?r.indent:0:n.type==="flow-collection"&&r.type==="document"&&(n.indent=0),n.type==="flow-collection"&&Ng(n),r.type){case"document":r.value=n;break;case"block-scalar":r.props.push(n);break;case"block-map":{let s=r.items[r.items.length-1];if(s.value){r.items.push({start:[],key:n,sep:[]}),this.onKeyLine=!0;return}else if(s.sep)s.value=n;else{Object.assign(s,{key:n,sep:[]}),this.onKeyLine=!s.explicitKey;return}break}case"block-seq":{let s=r.items[r.items.length-1];s.value?r.items.push({start:[],value:n}):s.value=n;break}case"flow-collection":{let s=r.items[r.items.length-1];!s||s.value?r.items.push({start:[],key:n,sep:[]}):s.sep?s.value=n:Object.assign(s,{key:n,sep:[]});return}default:yield*this.pop(),yield*this.pop(n)}if((r.type==="document"||r.type==="block-map"||r.type==="block-seq")&&(n.type==="block-map"||n.type==="block-seq")){let s=n.items[n.items.length-1];s&&!s.sep&&!s.value&&s.start.length>0&&$g(s.start)===-1&&(n.indent===0||s.start.every(i=>i.type!=="comment"||i.indent<n.indent))&&(r.type==="document"?r.end=s.start:r.items.push({start:s.start}),n.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let e={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{$g(e.start)!==-1?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){let n=Co(this.peek(2)),r=Qn(n),s;e.end?(s=e.end,s.push(this.sourceToken),delete e.end):s=[this.sourceToken];let i={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:s}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let n=this.source.indexOf(`
|
|
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(Bt(n.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(Lg(n.key)&&!Bt(n.sep,"newline")){let o=Qn(n.start),a=n.key,l=n.sep;l.push(this.sourceToken),delete n.key,delete n.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:a,sep:l}]})}else i.length>0?n.sep=n.sep.concat(i,this.sourceToken):n.sep.push(this.sourceToken);else if(Bt(n.start,"newline"))Object.assign(n,{key:null,sep:[this.sourceToken]});else{let o=Qn(n.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else n.sep?n.value||s?e.items.push({start:i,key:null,sep:[this.sourceToken]}):Bt(n.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):n.sep.push(this.sourceToken):Object.assign(n,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let o=this.flowScalar(this.type);s||n.value?(e.items.push({start:i,key:o,sep:[]}),this.onKeyLine=!0):n.sep?this.stack.push(o):(Object.assign(n,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{let o=this.startBlockValue(e);if(o){if(o.type==="block-seq"){if(!n.explicitKey&&n.sep&&!Bt(n.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else r&&e.items.push({start:i});this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let n=e.items[e.items.length-1];switch(this.type){case"newline":if(n.value){let r="end"in n.value?n.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(n.start,e.indent)){let s=e.items[e.items.length-2]?.value?.end;if(Array.isArray(s)){Array.prototype.push.apply(s,n.start),s.push(this.sourceToken),e.items.pop();return}}n.start.push(this.sourceToken)}return;case"anchor":case"tag":if(n.value||this.indent<=e.indent)break;n.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;n.value||Bt(n.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return}if(this.indent>e.indent){let r=this.startBlockValue(e);if(r){this.stack.push(r);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let n=e.items[e.items.length-1];if(this.type==="flow-error-end"){let r;do yield*this.pop(),r=this.peek(1);while(r?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!n||n.sep?e.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return;case"map-value-ind":!n||n.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):n.sep?n.sep.push(this.sourceToken):Object.assign(n,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!n||n.value?e.items.push({start:[this.sourceToken]}):n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let s=this.flowScalar(this.type);!n||n.value?e.items.push({start:[],key:s,sep:[]}):n.sep?this.stack.push(s):Object.assign(n,{key:s,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let r=this.startBlockValue(e);r?this.stack.push(r):(yield*this.pop(),yield*this.step())}else{let r=this.peek(2);if(r.type==="block-map"&&(this.type==="map-value-ind"&&r.indent===e.indent||this.type==="newline"&&!r.items[r.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&r.type!=="flow-collection"){let s=Co(r),i=Qn(s);Ng(e);let o=e.end.splice(1,e.end.length);o.push(this.sourceToken);let a={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:i,key:e,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let n=this.source.indexOf(`
|
|
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=
|
|
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=Co(e),r=Qn(n);return r.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let n=Co(e),r=Qn(n);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,n){return this.type!=="comment"||this.indent<=n?!1:e.every(r=>r.type==="newline"||r.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};Mg.Parser=Ou});var Ug=_(Es=>{"use strict";var Dg=mu(),kT=ms(),xs=bs(),xT=pc(),ET=J(),AT=Cu(),Bg=Pu();function jg(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new AT.LineCounter||null,prettyErrors:e}}function TT(t,e={}){let{lineCounter:n,prettyErrors:r}=jg(e),s=new Bg.Parser(n?.addNewLine),i=new Dg.Composer(e),o=Array.from(i.compose(s.parse(t)));if(r&&n)for(let a of o)a.errors.forEach(xs.prettifyError(t,n)),a.warnings.forEach(xs.prettifyError(t,n));return o.length>0?o:Object.assign([],{empty:!0},i.streamInfo())}function Fg(t,e={}){let{lineCounter:n,prettyErrors:r}=jg(e),s=new Bg.Parser(n?.addNewLine),i=new Dg.Composer(e),o=null;for(let a of i.compose(s.parse(t),!0,t.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new xs.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&n&&(o.errors.forEach(xs.prettifyError(t,n)),o.warnings.forEach(xs.prettifyError(t,n))),o}function CT(t,e,n){let r;typeof e=="function"?r=e:n===void 0&&e&&typeof e=="object"&&(n=e);let s=Fg(t,n);if(!s)return null;if(s.warnings.forEach(i=>xT.warn(s.options.logLevel,i)),s.errors.length>0){if(s.options.logLevel!=="silent")throw s.errors[0];s.errors=[]}return s.toJS(Object.assign({reviver:r},n))}function OT(t,e,n){let r=null;if(typeof e=="function"||Array.isArray(e)?r=e:n===void 0&&e&&(n=e),typeof n=="string"&&(n=n.length),typeof n=="number"){let s=Math.round(n);n=s<1?void 0:s>8?{indent:8}:{indent:s}}if(t===void 0){let{keepUndefined:s}=n??e??{};if(!s)return}return ET.isDocument(t)&&!r?t.toString(n):new kT.Document(t,r,n).toString(n)}Es.parse=CT;Es.parseAllDocuments=TT;Es.parseDocument=Fg;Es.stringify=OT});var Jg=_(K=>{"use strict";var PT=mu(),_T=ms(),RT=Vc(),_u=bs(),IT=Qr(),jt=J(),$T=Nt(),NT=se(),LT=Mt(),MT=Dt(),DT=Ao(),BT=Au(),jT=Cu(),FT=Pu(),Oo=Ug(),qg=Yr();K.Composer=PT.Composer;K.Document=_T.Document;K.Schema=RT.Schema;K.YAMLError=_u.YAMLError;K.YAMLParseError=_u.YAMLParseError;K.YAMLWarning=_u.YAMLWarning;K.Alias=IT.Alias;K.isAlias=jt.isAlias;K.isCollection=jt.isCollection;K.isDocument=jt.isDocument;K.isMap=jt.isMap;K.isNode=jt.isNode;K.isPair=jt.isPair;K.isScalar=jt.isScalar;K.isSeq=jt.isSeq;K.Pair=$T.Pair;K.Scalar=NT.Scalar;K.YAMLMap=LT.YAMLMap;K.YAMLSeq=MT.YAMLSeq;K.CST=DT;K.Lexer=BT.Lexer;K.LineCounter=jT.LineCounter;K.Parser=FT.Parser;K.parse=Oo.parse;K.parseAllDocuments=Oo.parseAllDocuments;K.parseDocument=Oo.parseDocument;K.stringify=Oo.stringify;K.visit=qg.visit;K.visitAsync=qg.visitAsync});function qT(t){try{return JSON.parse(t.trim()),!0}catch{return!1}}function JT(t){let e=t.trim();if(!e.startsWith("<"))return!1;let n=e.match(UT);return n?zr(e,n[1])!==null:!1}function WT(t){let e=t.trim();if(!e.match(/^(---|#|\w+:|-)/)||"[{<".includes(e[0]))return!1;try{let n=Wg.parse(e);return n!==null&&typeof n=="object"}catch{return!1}}function Kg(t){return qT(t)||JT(t)||WT(t)}var Wg,UT,Ru=S(()=>{th();Wg=Yk(Jg(),1),UT=/<([a-zA-Z_][\w.-]*)/});function KT(t){if(!t?.trim())return[];let e=t.replace(/\r\n/g,`
|
|
163
|
+
`),n=e.trim();if(Kg(n))return[{text:n,startLine:1,endLine:e.split(`
|
|
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
|
|
166
|
+
`).trim();c&&s.push({text:c,startLine:i+1,endLine:o+1})}};for(let c=0;c<r.length;c++)r[c].trim()?(a>=2&&o>=i&&(l(),i=c),a=0,o=c):a++;return l(),s}function Po(t){return KT(t).map(e=>e.text)}var Hg,zg=S(()=>{Ru();Hg=`
|
|
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 _o(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var Yg=S(()=>{});var HT,zT,Iu,Vg=S(()=>{HT=[["\xDF","ss"],["\u1E9E","Ss"],["\xE4","ae"],["\xC4","Ae"],["\xF6","oe"],["\xD6","Oe"],["\xFC","ue"],["\xDC","Ue"],["\xC0","A"],["\xC1","A"],["\xC2","A"],["\xC3","A"],["\xC4","Ae"],["\xC5","A"],["\xC6","AE"],["\xC7","C"],["\xC8","E"],["\xC9","E"],["\xCA","E"],["\xCB","E"],["\u018F","A"],["\xCC","I"],["\xCD","I"],["\xCE","I"],["\xCF","I"],["\xD0","D"],["\xD1","N"],["\xD2","O"],["\xD3","O"],["\xD4","O"],["\xD5","O"],["\xD6","Oe"],["\u014C","O"],["\u0150","O"],["\xD8","O"],["\u0152","OE"],["\xD9","U"],["\xDA","U"],["\xDB","U"],["\xDC","Ue"],["\u0170","U"],["\xDD","Y"],["\xDE","TH"],["\xDF","ss"],["\xE0","a"],["\xE1","a"],["\xE2","a"],["\xE3","a"],["\xE4","ae"],["\xE5","a"],["\xE6","ae"],["\xE7","c"],["\xE8","e"],["\xE9","e"],["\xEA","e"],["\xEB","e"],["\u0259","a"],["\xEC","i"],["\xED","i"],["\xEE","i"],["\xEF","i"],["\xF0","d"],["\xF1","n"],["\xF2","o"],["\xF3","o"],["\xF4","o"],["\xF5","o"],["\xF6","oe"],["\u014D","o"],["\u0151","o"],["\xF8","o"],["\u0153","oe"],["\xF9","u"],["\xFA","u"],["\xFB","u"],["\xFC","ue"],["\u0171","u"],["\xFD","y"],["\xFE","th"],["\xFF","y"],["\xE0","a"],["\xC0","A"],["\xE1","a"],["\xC1","A"],["\xE2","a"],["\xC2","A"],["\xE3","a"],["\xC3","A"],["\xE8","e"],["\xC8","E"],["\xE9","e"],["\xC9","E"],["\xEA","e"],["\xCA","E"],["\xEC","i"],["\xCC","I"],["\xED","i"],["\xCD","I"],["\xF2","o"],["\xD2","O"],["\xF3","o"],["\xD3","O"],["\xF4","o"],["\xD4","O"],["\xF5","o"],["\xD5","O"],["\xF9","u"],["\xD9","U"],["\xFA","u"],["\xDA","U"],["\xFD","y"],["\xDD","Y"],["\u0103","a"],["\u0102","A"],["\u0110","D"],["\u0111","d"],["\u0129","i"],["\u0128","I"],["\u0169","u"],["\u0168","U"],["\u01A1","o"],["\u01A0","O"],["\u01B0","u"],["\u01AF","U"],["\u1EA1","a"],["\u1EA0","A"],["\u1EA3","a"],["\u1EA2","A"],["\u1EA5","a"],["\u1EA4","A"],["\u1EA7","a"],["\u1EA6","A"],["\u1EA9","a"],["\u1EA8","A"],["\u1EAB","a"],["\u1EAA","A"],["\u1EAD","a"],["\u1EAC","A"],["\u1EAF","a"],["\u1EAE","A"],["\u1EB1","a"],["\u1EB0","A"],["\u1EB3","a"],["\u1EB2","A"],["\u1EB5","a"],["\u1EB4","A"],["\u1EB7","a"],["\u1EB6","A"],["\u1EB9","e"],["\u1EB8","E"],["\u1EBB","e"],["\u1EBA","E"],["\u1EBD","e"],["\u1EBC","E"],["\u1EBF","e"],["\u1EBE","E"],["\u1EC1","e"],["\u1EC0","E"],["\u1EC3","e"],["\u1EC2","E"],["\u1EC5","e"],["\u1EC4","E"],["\u1EC7","e"],["\u1EC6","E"],["\u1EC9","i"],["\u1EC8","I"],["\u1ECB","i"],["\u1ECA","I"],["\u1ECD","o"],["\u1ECC","O"],["\u1ECF","o"],["\u1ECE","O"],["\u1ED1","o"],["\u1ED0","O"],["\u1ED3","o"],["\u1ED2","O"],["\u1ED5","o"],["\u1ED4","O"],["\u1ED7","o"],["\u1ED6","O"],["\u1ED9","o"],["\u1ED8","O"],["\u1EDB","o"],["\u1EDA","O"],["\u1EDD","o"],["\u1EDC","O"],["\u1EDF","o"],["\u1EDE","O"],["\u1EE1","o"],["\u1EE0","O"],["\u1EE3","o"],["\u1EE2","O"],["\u1EE5","u"],["\u1EE4","U"],["\u1EE7","u"],["\u1EE6","U"],["\u1EE9","u"],["\u1EE8","U"],["\u1EEB","u"],["\u1EEA","U"],["\u1EED","u"],["\u1EEC","U"],["\u1EEF","u"],["\u1EEE","U"],["\u1EF1","u"],["\u1EF0","U"],["\u1EF3","y"],["\u1EF2","Y"],["\u1EF5","y"],["\u1EF4","Y"],["\u1EF7","y"],["\u1EF6","Y"],["\u1EF9","y"],["\u1EF8","Y"],["\u0621","e"],["\u0622","a"],["\u0623","a"],["\u0624","w"],["\u0625","a"],["\u0626","y"],["\u0627","a"],["\u0628","b"],["\u0629","t"],["\u062A","t"],["\u062B","th"],["\u062C","j"],["\u062D","h"],["\u062E","kh"],["\u062F","d"],["\u0630","dh"],["\u0631","r"],["\u0632","z"],["\u0633","s"],["\u0634","sh"],["\u0635","s"],["\u0636","d"],["\u0637","t"],["\u0638","z"],["\u0639","e"],["\u063A","gh"],["\u0640","_"],["\u0641","f"],["\u0642","q"],["\u0643","k"],["\u0644","l"],["\u0645","m"],["\u0646","n"],["\u0647","h"],["\u0648","w"],["\u0649","a"],["\u064A","y"],["\u064E\u200E","a"],["\u064F","u"],["\u0650\u200E","i"],["\u0660","0"],["\u0661","1"],["\u0662","2"],["\u0663","3"],["\u0664","4"],["\u0665","5"],["\u0666","6"],["\u0667","7"],["\u0668","8"],["\u0669","9"],["\u0686","ch"],["\u06A9","k"],["\u06AF","g"],["\u067E","p"],["\u0698","zh"],["\u06CC","y"],["\u06F0","0"],["\u06F1","1"],["\u06F2","2"],["\u06F3","3"],["\u06F4","4"],["\u06F5","5"],["\u06F6","6"],["\u06F7","7"],["\u06F8","8"],["\u06F9","9"],["\u067C","p"],["\u0681","z"],["\u0685","c"],["\u0689","d"],["\uFEAB","d"],["\uFEAD","r"],["\u0693","r"],["\uFEAF","z"],["\u0696","g"],["\u069A","x"],["\u06AB","g"],["\u06BC","n"],["\u06C0","e"],["\u06D0","e"],["\u06CD","ai"],["\u0679","t"],["\u0688","d"],["\u0691","r"],["\u06BA","n"],["\u06C1","h"],["\u06BE","h"],["\u06D2","e"],["\u0410","A"],["\u0430","a"],["\u0411","B"],["\u0431","b"],["\u0412","V"],["\u0432","v"],["\u0413","G"],["\u0433","g"],["\u0414","D"],["\u0434","d"],["\u044A\u0435","ye"],["\u042A\u0435","Ye"],["\u044A\u0415","yE"],["\u042A\u0415","YE"],["\u0415","E"],["\u0435","e"],["\u0401","Yo"],["\u0451","yo"],["\u0416","Zh"],["\u0436","zh"],["\u0417","Z"],["\u0437","z"],["\u0418","I"],["\u0438","i"],["\u044B\u0439","iy"],["\u042B\u0439","Iy"],["\u042B\u0419","IY"],["\u044B\u0419","iY"],["\u0419","Y"],["\u0439","y"],["\u041A","K"],["\u043A","k"],["\u041B","L"],["\u043B","l"],["\u041C","M"],["\u043C","m"],["\u041D","N"],["\u043D","n"],["\u041E","O"],["\u043E","o"],["\u041F","P"],["\u043F","p"],["\u0420","R"],["\u0440","r"],["\u0421","S"],["\u0441","s"],["\u0422","T"],["\u0442","t"],["\u0423","U"],["\u0443","u"],["\u0424","F"],["\u0444","f"],["\u0425","Kh"],["\u0445","kh"],["\u0426","Ts"],["\u0446","ts"],["\u0427","Ch"],["\u0447","ch"],["\u0428","Sh"],["\u0448","sh"],["\u0429","Sch"],["\u0449","sch"],["\u042A",""],["\u044A",""],["\u042B","Y"],["\u044B","y"],["\u042C",""],["\u044C",""],["\u042D","E"],["\u044D","e"],["\u042E","Yu"],["\u044E","yu"],["\u042F","Ya"],["\u044F","ya"],["\u0103","a"],["\u0102","A"],["\u0219","s"],["\u0218","S"],["\u021B","t"],["\u021A","T"],["\u0163","t"],["\u0162","T"],["\u015F","s"],["\u015E","S"],["\xE7","c"],["\xC7","C"],["\u011F","g"],["\u011E","G"],["\u0131","i"],["\u0130","I"],["\u0561","a"],["\u0531","A"],["\u0562","b"],["\u0532","B"],["\u0563","g"],["\u0533","G"],["\u0564","d"],["\u0534","D"],["\u0565","ye"],["\u0535","Ye"],["\u0566","z"],["\u0536","Z"],["\u0567","e"],["\u0537","E"],["\u0568","y"],["\u0538","Y"],["\u0569","t"],["\u0539","T"],["\u056A","zh"],["\u053A","Zh"],["\u056B","i"],["\u053B","I"],["\u056C","l"],["\u053C","L"],["\u056D","kh"],["\u053D","Kh"],["\u056E","ts"],["\u053E","Ts"],["\u056F","k"],["\u053F","K"],["\u0570","h"],["\u0540","H"],["\u0571","dz"],["\u0541","Dz"],["\u0572","gh"],["\u0542","Gh"],["\u0573","tch"],["\u0543","Tch"],["\u0574","m"],["\u0544","M"],["\u0575","y"],["\u0545","Y"],["\u0576","n"],["\u0546","N"],["\u0577","sh"],["\u0547","Sh"],["\u0578\u0582","u"],["\u0548\u0552","U"],["\u0548\u0582","U"],["\u0578","vo"],["\u0548","Vo"],["\u0579","ch"],["\u0549","Ch"],["\u057A","p"],["\u054A","P"],["\u057B","j"],["\u054B","J"],["\u057C","r"],["\u054C","R"],["\u057D","s"],["\u054D","S"],["\u057E","v"],["\u054E","V"],["\u057F","t"],["\u054F","T"],["\u0580","r"],["\u0550","R"],["\u0581","c"],["\u0551","C"],["\u0583","p"],["\u0553","P"],["\u0584","q"],["\u0554","Q"],["\u0585","o"],["\u0555","O"],["\u0586","f"],["\u0556","F"],["\u0587","yev"],["\u10D0","a"],["\u10D1","b"],["\u10D2","g"],["\u10D3","d"],["\u10D4","e"],["\u10D5","v"],["\u10D6","z"],["\u10D7","t"],["\u10D8","i"],["\u10D9","k"],["\u10DA","l"],["\u10DB","m"],["\u10DC","n"],["\u10DD","o"],["\u10DE","p"],["\u10DF","zh"],["\u10E0","r"],["\u10E1","s"],["\u10E2","t"],["\u10E3","u"],["\u10E4","ph"],["\u10E5","q"],["\u10E6","gh"],["\u10E7","k"],["\u10E8","sh"],["\u10E9","ch"],["\u10EA","ts"],["\u10EB","dz"],["\u10EC","ts"],["\u10ED","tch"],["\u10EE","kh"],["\u10EF","j"],["\u10F0","h"],["\u010D","c"],["\u010F","d"],["\u011B","e"],["\u0148","n"],["\u0159","r"],["\u0161","s"],["\u0165","t"],["\u016F","u"],["\u017E","z"],["\u010C","C"],["\u010E","D"],["\u011A","E"],["\u0147","N"],["\u0158","R"],["\u0160","S"],["\u0164","T"],["\u016E","U"],["\u017D","Z"],["\u0780","h"],["\u0781","sh"],["\u0782","n"],["\u0783","r"],["\u0784","b"],["\u0785","lh"],["\u0786","k"],["\u0787","a"],["\u0788","v"],["\u0789","m"],["\u078A","f"],["\u078B","dh"],["\u078C","th"],["\u078D","l"],["\u078E","g"],["\u078F","gn"],["\u0790","s"],["\u0791","d"],["\u0792","z"],["\u0793","t"],["\u0794","y"],["\u0795","p"],["\u0796","j"],["\u0797","ch"],["\u0798","tt"],["\u0799","hh"],["\u079A","kh"],["\u079B","th"],["\u079C","z"],["\u079D","sh"],["\u079E","s"],["\u079F","d"],["\u07A0","t"],["\u07A1","z"],["\u07A2","a"],["\u07A3","gh"],["\u07A4","q"],["\u07A5","w"],["\u07A6","a"],["\u07A7","aa"],["\u07A8","i"],["\u07A9","ee"],["\u07AA","u"],["\u07AB","oo"],["\u07AC","e"],["\u07AD","ey"],["\u07AE","o"],["\u07AF","oa"],["\u07B0",""],["\u03B1","a"],["\u03B2","v"],["\u03B3","g"],["\u03B4","d"],["\u03B5","e"],["\u03B6","z"],["\u03B7","i"],["\u03B8","th"],["\u03B9","i"],["\u03BA","k"],["\u03BB","l"],["\u03BC","m"],["\u03BD","n"],["\u03BE","ks"],["\u03BF","o"],["\u03C0","p"],["\u03C1","r"],["\u03C3","s"],["\u03C4","t"],["\u03C5","y"],["\u03C6","f"],["\u03C7","x"],["\u03C8","ps"],["\u03C9","o"],["\u03AC","a"],["\u03AD","e"],["\u03AF","i"],["\u03CC","o"],["\u03CD","y"],["\u03AE","i"],["\u03CE","o"],["\u03C2","s"],["\u03CA","i"],["\u03B0","y"],["\u03CB","y"],["\u0390","i"],["\u0391","A"],["\u0392","B"],["\u0393","G"],["\u0394","D"],["\u0395","E"],["\u0396","Z"],["\u0397","I"],["\u0398","TH"],["\u0399","I"],["\u039A","K"],["\u039B","L"],["\u039C","M"],["\u039D","N"],["\u039E","KS"],["\u039F","O"],["\u03A0","P"],["\u03A1","R"],["\u03A3","S"],["\u03A4","T"],["\u03A5","Y"],["\u03A6","F"],["\u03A7","X"],["\u03A8","PS"],["\u03A9","O"],["\u0386","A"],["\u0388","E"],["\u038A","I"],["\u038C","O"],["\u038E","Y"],["\u0389","I"],["\u038F","O"],["\u03AA","I"],["\u03AB","Y"],["\u0101","a"],["\u0113","e"],["\u0123","g"],["\u012B","i"],["\u0137","k"],["\u013C","l"],["\u0146","n"],["\u016B","u"],["\u0100","A"],["\u0112","E"],["\u0122","G"],["\u012A","I"],["\u0136","K"],["\u013B","L"],["\u0145","N"],["\u016A","U"],["\u010D","c"],["\u0161","s"],["\u017E","z"],["\u010C","C"],["\u0160","S"],["\u017D","Z"],["\u0105","a"],["\u010D","c"],["\u0119","e"],["\u0117","e"],["\u012F","i"],["\u0161","s"],["\u0173","u"],["\u016B","u"],["\u017E","z"],["\u0104","A"],["\u010C","C"],["\u0118","E"],["\u0116","E"],["\u012E","I"],["\u0160","S"],["\u0172","U"],["\u016A","U"],["\u040C","Kj"],["\u045C","kj"],["\u0409","Lj"],["\u0459","lj"],["\u040A","Nj"],["\u045A","nj"],["\u0422\u0441","Ts"],["\u0442\u0441","ts"],["\u0105","a"],["\u0107","c"],["\u0119","e"],["\u0142","l"],["\u0144","n"],["\u015B","s"],["\u017A","z"],["\u017C","z"],["\u0104","A"],["\u0106","C"],["\u0118","E"],["\u0141","L"],["\u0143","N"],["\u015A","S"],["\u0179","Z"],["\u017B","Z"],["\u0404","Ye"],["\u0406","I"],["\u0407","Yi"],["\u0490","G"],["\u0454","ye"],["\u0456","i"],["\u0457","yi"],["\u0491","g"],["\u0132","IJ"],["\u0133","ij"],["\xA2","c"],["\xA5","Y"],["\u07FF","b"],["\u09F3","t"],["\u0AF1","Bo"],["\u0E3F","B"],["\u20A0","CE"],["\u20A1","C"],["\u20A2","Cr"],["\u20A3","F"],["\u20A5","m"],["\u20A6","N"],["\u20A7","Pt"],["\u20A8","Rs"],["\u20A9","W"],["\u20AB","s"],["\u20AC","E"],["\u20AD","K"],["\u20AE","T"],["\u20AF","Dp"],["\u20B0","S"],["\u20B1","P"],["\u20B2","G"],["\u20B3","A"],["\u20B4","S"],["\u20B5","C"],["\u20B6","tt"],["\u20B7","S"],["\u20B8","T"],["\u20B9","R"],["\u20BA","L"],["\u20BD","P"],["\u20BF","B"],["\uFE69","$"],["\uFFE0","c"],["\uFFE5","Y"],["\uFFE6","W"],["\u{1D400}","A"],["\u{1D401}","B"],["\u{1D402}","C"],["\u{1D403}","D"],["\u{1D404}","E"],["\u{1D405}","F"],["\u{1D406}","G"],["\u{1D407}","H"],["\u{1D408}","I"],["\u{1D409}","J"],["\u{1D40A}","K"],["\u{1D40B}","L"],["\u{1D40C}","M"],["\u{1D40D}","N"],["\u{1D40E}","O"],["\u{1D40F}","P"],["\u{1D410}","Q"],["\u{1D411}","R"],["\u{1D412}","S"],["\u{1D413}","T"],["\u{1D414}","U"],["\u{1D415}","V"],["\u{1D416}","W"],["\u{1D417}","X"],["\u{1D418}","Y"],["\u{1D419}","Z"],["\u{1D41A}","a"],["\u{1D41B}","b"],["\u{1D41C}","c"],["\u{1D41D}","d"],["\u{1D41E}","e"],["\u{1D41F}","f"],["\u{1D420}","g"],["\u{1D421}","h"],["\u{1D422}","i"],["\u{1D423}","j"],["\u{1D424}","k"],["\u{1D425}","l"],["\u{1D426}","m"],["\u{1D427}","n"],["\u{1D428}","o"],["\u{1D429}","p"],["\u{1D42A}","q"],["\u{1D42B}","r"],["\u{1D42C}","s"],["\u{1D42D}","t"],["\u{1D42E}","u"],["\u{1D42F}","v"],["\u{1D430}","w"],["\u{1D431}","x"],["\u{1D432}","y"],["\u{1D433}","z"],["\u{1D434}","A"],["\u{1D435}","B"],["\u{1D436}","C"],["\u{1D437}","D"],["\u{1D438}","E"],["\u{1D439}","F"],["\u{1D43A}","G"],["\u{1D43B}","H"],["\u{1D43C}","I"],["\u{1D43D}","J"],["\u{1D43E}","K"],["\u{1D43F}","L"],["\u{1D440}","M"],["\u{1D441}","N"],["\u{1D442}","O"],["\u{1D443}","P"],["\u{1D444}","Q"],["\u{1D445}","R"],["\u{1D446}","S"],["\u{1D447}","T"],["\u{1D448}","U"],["\u{1D449}","V"],["\u{1D44A}","W"],["\u{1D44B}","X"],["\u{1D44C}","Y"],["\u{1D44D}","Z"],["\u{1D44E}","a"],["\u{1D44F}","b"],["\u{1D450}","c"],["\u{1D451}","d"],["\u{1D452}","e"],["\u{1D453}","f"],["\u{1D454}","g"],["\u{1D456}","i"],["\u{1D457}","j"],["\u{1D458}","k"],["\u{1D459}","l"],["\u{1D45A}","m"],["\u{1D45B}","n"],["\u{1D45C}","o"],["\u{1D45D}","p"],["\u{1D45E}","q"],["\u{1D45F}","r"],["\u{1D460}","s"],["\u{1D461}","t"],["\u{1D462}","u"],["\u{1D463}","v"],["\u{1D464}","w"],["\u{1D465}","x"],["\u{1D466}","y"],["\u{1D467}","z"],["\u{1D468}","A"],["\u{1D469}","B"],["\u{1D46A}","C"],["\u{1D46B}","D"],["\u{1D46C}","E"],["\u{1D46D}","F"],["\u{1D46E}","G"],["\u{1D46F}","H"],["\u{1D470}","I"],["\u{1D471}","J"],["\u{1D472}","K"],["\u{1D473}","L"],["\u{1D474}","M"],["\u{1D475}","N"],["\u{1D476}","O"],["\u{1D477}","P"],["\u{1D478}","Q"],["\u{1D479}","R"],["\u{1D47A}","S"],["\u{1D47B}","T"],["\u{1D47C}","U"],["\u{1D47D}","V"],["\u{1D47E}","W"],["\u{1D47F}","X"],["\u{1D480}","Y"],["\u{1D481}","Z"],["\u{1D482}","a"],["\u{1D483}","b"],["\u{1D484}","c"],["\u{1D485}","d"],["\u{1D486}","e"],["\u{1D487}","f"],["\u{1D488}","g"],["\u{1D489}","h"],["\u{1D48A}","i"],["\u{1D48B}","j"],["\u{1D48C}","k"],["\u{1D48D}","l"],["\u{1D48E}","m"],["\u{1D48F}","n"],["\u{1D490}","o"],["\u{1D491}","p"],["\u{1D492}","q"],["\u{1D493}","r"],["\u{1D494}","s"],["\u{1D495}","t"],["\u{1D496}","u"],["\u{1D497}","v"],["\u{1D498}","w"],["\u{1D499}","x"],["\u{1D49A}","y"],["\u{1D49B}","z"],["\u{1D49C}","A"],["\u{1D49E}","C"],["\u{1D49F}","D"],["\u{1D4A2}","g"],["\u{1D4A5}","J"],["\u{1D4A6}","K"],["\u{1D4A9}","N"],["\u{1D4AA}","O"],["\u{1D4AB}","P"],["\u{1D4AC}","Q"],["\u{1D4AE}","S"],["\u{1D4AF}","T"],["\u{1D4B0}","U"],["\u{1D4B1}","V"],["\u{1D4B2}","W"],["\u{1D4B3}","X"],["\u{1D4B4}","Y"],["\u{1D4B5}","Z"],["\u{1D4B6}","a"],["\u{1D4B7}","b"],["\u{1D4B8}","c"],["\u{1D4B9}","d"],["\u{1D4BB}","f"],["\u{1D4BD}","h"],["\u{1D4BE}","i"],["\u{1D4BF}","j"],["\u{1D4C0}","k"],["\u{1D4C1}","l"],["\u{1D4C2}","m"],["\u{1D4C3}","n"],["\u{1D4C5}","p"],["\u{1D4C6}","q"],["\u{1D4C7}","r"],["\u{1D4C8}","s"],["\u{1D4C9}","t"],["\u{1D4CA}","u"],["\u{1D4CB}","v"],["\u{1D4CC}","w"],["\u{1D4CD}","x"],["\u{1D4CE}","y"],["\u{1D4CF}","z"],["\u{1D4D0}","A"],["\u{1D4D1}","B"],["\u{1D4D2}","C"],["\u{1D4D3}","D"],["\u{1D4D4}","E"],["\u{1D4D5}","F"],["\u{1D4D6}","G"],["\u{1D4D7}","H"],["\u{1D4D8}","I"],["\u{1D4D9}","J"],["\u{1D4DA}","K"],["\u{1D4DB}","L"],["\u{1D4DC}","M"],["\u{1D4DD}","N"],["\u{1D4DE}","O"],["\u{1D4DF}","P"],["\u{1D4E0}","Q"],["\u{1D4E1}","R"],["\u{1D4E2}","S"],["\u{1D4E3}","T"],["\u{1D4E4}","U"],["\u{1D4E5}","V"],["\u{1D4E6}","W"],["\u{1D4E7}","X"],["\u{1D4E8}","Y"],["\u{1D4E9}","Z"],["\u{1D4EA}","a"],["\u{1D4EB}","b"],["\u{1D4EC}","c"],["\u{1D4ED}","d"],["\u{1D4EE}","e"],["\u{1D4EF}","f"],["\u{1D4F0}","g"],["\u{1D4F1}","h"],["\u{1D4F2}","i"],["\u{1D4F3}","j"],["\u{1D4F4}","k"],["\u{1D4F5}","l"],["\u{1D4F6}","m"],["\u{1D4F7}","n"],["\u{1D4F8}","o"],["\u{1D4F9}","p"],["\u{1D4FA}","q"],["\u{1D4FB}","r"],["\u{1D4FC}","s"],["\u{1D4FD}","t"],["\u{1D4FE}","u"],["\u{1D4FF}","v"],["\u{1D500}","w"],["\u{1D501}","x"],["\u{1D502}","y"],["\u{1D503}","z"],["\u{1D504}","A"],["\u{1D505}","B"],["\u{1D507}","D"],["\u{1D508}","E"],["\u{1D509}","F"],["\u{1D50A}","G"],["\u{1D50D}","J"],["\u{1D50E}","K"],["\u{1D50F}","L"],["\u{1D510}","M"],["\u{1D511}","N"],["\u{1D512}","O"],["\u{1D513}","P"],["\u{1D514}","Q"],["\u{1D516}","S"],["\u{1D517}","T"],["\u{1D518}","U"],["\u{1D519}","V"],["\u{1D51A}","W"],["\u{1D51B}","X"],["\u{1D51C}","Y"],["\u{1D51E}","a"],["\u{1D51F}","b"],["\u{1D520}","c"],["\u{1D521}","d"],["\u{1D522}","e"],["\u{1D523}","f"],["\u{1D524}","g"],["\u{1D525}","h"],["\u{1D526}","i"],["\u{1D527}","j"],["\u{1D528}","k"],["\u{1D529}","l"],["\u{1D52A}","m"],["\u{1D52B}","n"],["\u{1D52C}","o"],["\u{1D52D}","p"],["\u{1D52E}","q"],["\u{1D52F}","r"],["\u{1D530}","s"],["\u{1D531}","t"],["\u{1D532}","u"],["\u{1D533}","v"],["\u{1D534}","w"],["\u{1D535}","x"],["\u{1D536}","y"],["\u{1D537}","z"],["\u{1D538}","A"],["\u{1D539}","B"],["\u{1D53B}","D"],["\u{1D53C}","E"],["\u{1D53D}","F"],["\u{1D53E}","G"],["\u{1D540}","I"],["\u{1D541}","J"],["\u{1D542}","K"],["\u{1D543}","L"],["\u{1D544}","M"],["\u{1D546}","O"],["\u{1D54A}","S"],["\u{1D54B}","T"],["\u{1D54C}","U"],["\u{1D54D}","V"],["\u{1D54E}","W"],["\u{1D54F}","X"],["\u{1D550}","Y"],["\u{1D552}","a"],["\u{1D553}","b"],["\u{1D554}","c"],["\u{1D555}","d"],["\u{1D556}","e"],["\u{1D557}","f"],["\u{1D558}","g"],["\u{1D559}","h"],["\u{1D55A}","i"],["\u{1D55B}","j"],["\u{1D55C}","k"],["\u{1D55D}","l"],["\u{1D55E}","m"],["\u{1D55F}","n"],["\u{1D560}","o"],["\u{1D561}","p"],["\u{1D562}","q"],["\u{1D563}","r"],["\u{1D564}","s"],["\u{1D565}","t"],["\u{1D566}","u"],["\u{1D567}","v"],["\u{1D568}","w"],["\u{1D569}","x"],["\u{1D56A}","y"],["\u{1D56B}","z"],["\u{1D56C}","A"],["\u{1D56D}","B"],["\u{1D56E}","C"],["\u{1D56F}","D"],["\u{1D570}","E"],["\u{1D571}","F"],["\u{1D572}","G"],["\u{1D573}","H"],["\u{1D574}","I"],["\u{1D575}","J"],["\u{1D576}","K"],["\u{1D577}","L"],["\u{1D578}","M"],["\u{1D579}","N"],["\u{1D57A}","O"],["\u{1D57B}","P"],["\u{1D57C}","Q"],["\u{1D57D}","R"],["\u{1D57E}","S"],["\u{1D57F}","T"],["\u{1D580}","U"],["\u{1D581}","V"],["\u{1D582}","W"],["\u{1D583}","X"],["\u{1D584}","Y"],["\u{1D585}","Z"],["\u{1D586}","a"],["\u{1D587}","b"],["\u{1D588}","c"],["\u{1D589}","d"],["\u{1D58A}","e"],["\u{1D58B}","f"],["\u{1D58C}","g"],["\u{1D58D}","h"],["\u{1D58E}","i"],["\u{1D58F}","j"],["\u{1D590}","k"],["\u{1D591}","l"],["\u{1D592}","m"],["\u{1D593}","n"],["\u{1D594}","o"],["\u{1D595}","p"],["\u{1D596}","q"],["\u{1D597}","r"],["\u{1D598}","s"],["\u{1D599}","t"],["\u{1D59A}","u"],["\u{1D59B}","v"],["\u{1D59C}","w"],["\u{1D59D}","x"],["\u{1D59E}","y"],["\u{1D59F}","z"],["\u{1D5A0}","A"],["\u{1D5A1}","B"],["\u{1D5A2}","C"],["\u{1D5A3}","D"],["\u{1D5A4}","E"],["\u{1D5A5}","F"],["\u{1D5A6}","G"],["\u{1D5A7}","H"],["\u{1D5A8}","I"],["\u{1D5A9}","J"],["\u{1D5AA}","K"],["\u{1D5AB}","L"],["\u{1D5AC}","M"],["\u{1D5AD}","N"],["\u{1D5AE}","O"],["\u{1D5AF}","P"],["\u{1D5B0}","Q"],["\u{1D5B1}","R"],["\u{1D5B2}","S"],["\u{1D5B3}","T"],["\u{1D5B4}","U"],["\u{1D5B5}","V"],["\u{1D5B6}","W"],["\u{1D5B7}","X"],["\u{1D5B8}","Y"],["\u{1D5B9}","Z"],["\u{1D5BA}","a"],["\u{1D5BB}","b"],["\u{1D5BC}","c"],["\u{1D5BD}","d"],["\u{1D5BE}","e"],["\u{1D5BF}","f"],["\u{1D5C0}","g"],["\u{1D5C1}","h"],["\u{1D5C2}","i"],["\u{1D5C3}","j"],["\u{1D5C4}","k"],["\u{1D5C5}","l"],["\u{1D5C6}","m"],["\u{1D5C7}","n"],["\u{1D5C8}","o"],["\u{1D5C9}","p"],["\u{1D5CA}","q"],["\u{1D5CB}","r"],["\u{1D5CC}","s"],["\u{1D5CD}","t"],["\u{1D5CE}","u"],["\u{1D5CF}","v"],["\u{1D5D0}","w"],["\u{1D5D1}","x"],["\u{1D5D2}","y"],["\u{1D5D3}","z"],["\u{1D5D4}","A"],["\u{1D5D5}","B"],["\u{1D5D6}","C"],["\u{1D5D7}","D"],["\u{1D5D8}","E"],["\u{1D5D9}","F"],["\u{1D5DA}","G"],["\u{1D5DB}","H"],["\u{1D5DC}","I"],["\u{1D5DD}","J"],["\u{1D5DE}","K"],["\u{1D5DF}","L"],["\u{1D5E0}","M"],["\u{1D5E1}","N"],["\u{1D5E2}","O"],["\u{1D5E3}","P"],["\u{1D5E4}","Q"],["\u{1D5E5}","R"],["\u{1D5E6}","S"],["\u{1D5E7}","T"],["\u{1D5E8}","U"],["\u{1D5E9}","V"],["\u{1D5EA}","W"],["\u{1D5EB}","X"],["\u{1D5EC}","Y"],["\u{1D5ED}","Z"],["\u{1D5EE}","a"],["\u{1D5EF}","b"],["\u{1D5F0}","c"],["\u{1D5F1}","d"],["\u{1D5F2}","e"],["\u{1D5F3}","f"],["\u{1D5F4}","g"],["\u{1D5F5}","h"],["\u{1D5F6}","i"],["\u{1D5F7}","j"],["\u{1D5F8}","k"],["\u{1D5F9}","l"],["\u{1D5FA}","m"],["\u{1D5FB}","n"],["\u{1D5FC}","o"],["\u{1D5FD}","p"],["\u{1D5FE}","q"],["\u{1D5FF}","r"],["\u{1D600}","s"],["\u{1D601}","t"],["\u{1D602}","u"],["\u{1D603}","v"],["\u{1D604}","w"],["\u{1D605}","x"],["\u{1D606}","y"],["\u{1D607}","z"],["\u{1D608}","A"],["\u{1D609}","B"],["\u{1D60A}","C"],["\u{1D60B}","D"],["\u{1D60C}","E"],["\u{1D60D}","F"],["\u{1D60E}","G"],["\u{1D60F}","H"],["\u{1D610}","I"],["\u{1D611}","J"],["\u{1D612}","K"],["\u{1D613}","L"],["\u{1D614}","M"],["\u{1D615}","N"],["\u{1D616}","O"],["\u{1D617}","P"],["\u{1D618}","Q"],["\u{1D619}","R"],["\u{1D61A}","S"],["\u{1D61B}","T"],["\u{1D61C}","U"],["\u{1D61D}","V"],["\u{1D61E}","W"],["\u{1D61F}","X"],["\u{1D620}","Y"],["\u{1D621}","Z"],["\u{1D622}","a"],["\u{1D623}","b"],["\u{1D624}","c"],["\u{1D625}","d"],["\u{1D626}","e"],["\u{1D627}","f"],["\u{1D628}","g"],["\u{1D629}","h"],["\u{1D62A}","i"],["\u{1D62B}","j"],["\u{1D62C}","k"],["\u{1D62D}","l"],["\u{1D62E}","m"],["\u{1D62F}","n"],["\u{1D630}","o"],["\u{1D631}","p"],["\u{1D632}","q"],["\u{1D633}","r"],["\u{1D634}","s"],["\u{1D635}","t"],["\u{1D636}","u"],["\u{1D637}","v"],["\u{1D638}","w"],["\u{1D639}","x"],["\u{1D63A}","y"],["\u{1D63B}","z"],["\u{1D63C}","A"],["\u{1D63D}","B"],["\u{1D63E}","C"],["\u{1D63F}","D"],["\u{1D640}","E"],["\u{1D641}","F"],["\u{1D642}","G"],["\u{1D643}","H"],["\u{1D644}","I"],["\u{1D645}","J"],["\u{1D646}","K"],["\u{1D647}","L"],["\u{1D648}","M"],["\u{1D649}","N"],["\u{1D64A}","O"],["\u{1D64B}","P"],["\u{1D64C}","Q"],["\u{1D64D}","R"],["\u{1D64E}","S"],["\u{1D64F}","T"],["\u{1D650}","U"],["\u{1D651}","V"],["\u{1D652}","W"],["\u{1D653}","X"],["\u{1D654}","Y"],["\u{1D655}","Z"],["\u{1D656}","a"],["\u{1D657}","b"],["\u{1D658}","c"],["\u{1D659}","d"],["\u{1D65A}","e"],["\u{1D65B}","f"],["\u{1D65C}","g"],["\u{1D65D}","h"],["\u{1D65E}","i"],["\u{1D65F}","j"],["\u{1D660}","k"],["\u{1D661}","l"],["\u{1D662}","m"],["\u{1D663}","n"],["\u{1D664}","o"],["\u{1D665}","p"],["\u{1D666}","q"],["\u{1D667}","r"],["\u{1D668}","s"],["\u{1D669}","t"],["\u{1D66A}","u"],["\u{1D66B}","v"],["\u{1D66C}","w"],["\u{1D66D}","x"],["\u{1D66E}","y"],["\u{1D66F}","z"],["\u{1D670}","A"],["\u{1D671}","B"],["\u{1D672}","C"],["\u{1D673}","D"],["\u{1D674}","E"],["\u{1D675}","F"],["\u{1D676}","G"],["\u{1D677}","H"],["\u{1D678}","I"],["\u{1D679}","J"],["\u{1D67A}","K"],["\u{1D67B}","L"],["\u{1D67C}","M"],["\u{1D67D}","N"],["\u{1D67E}","O"],["\u{1D67F}","P"],["\u{1D680}","Q"],["\u{1D681}","R"],["\u{1D682}","S"],["\u{1D683}","T"],["\u{1D684}","U"],["\u{1D685}","V"],["\u{1D686}","W"],["\u{1D687}","X"],["\u{1D688}","Y"],["\u{1D689}","Z"],["\u{1D68A}","a"],["\u{1D68B}","b"],["\u{1D68C}","c"],["\u{1D68D}","d"],["\u{1D68E}","e"],["\u{1D68F}","f"],["\u{1D690}","g"],["\u{1D691}","h"],["\u{1D692}","i"],["\u{1D693}","j"],["\u{1D694}","k"],["\u{1D695}","l"],["\u{1D696}","m"],["\u{1D697}","n"],["\u{1D698}","o"],["\u{1D699}","p"],["\u{1D69A}","q"],["\u{1D69B}","r"],["\u{1D69C}","s"],["\u{1D69D}","t"],["\u{1D69E}","u"],["\u{1D69F}","v"],["\u{1D6A0}","w"],["\u{1D6A1}","x"],["\u{1D6A2}","y"],["\u{1D6A3}","z"],["\u{1D6A4}","l"],["\u{1D6A5}","j"],["\u{1D6E2}","A"],["\u{1D6E3}","B"],["\u{1D6E4}","G"],["\u{1D6E5}","D"],["\u{1D6E6}","E"],["\u{1D6E7}","Z"],["\u{1D6E8}","I"],["\u{1D6E9}","TH"],["\u{1D6EA}","I"],["\u{1D6EB}","K"],["\u{1D6EC}","L"],["\u{1D6ED}","M"],["\u{1D6EE}","N"],["\u{1D6EF}","KS"],["\u{1D6F0}","O"],["\u{1D6F1}","P"],["\u{1D6F2}","R"],["\u{1D6F3}","TH"],["\u{1D6F4}","S"],["\u{1D6F5}","T"],["\u{1D6F6}","Y"],["\u{1D6F7}","F"],["\u{1D6F8}","x"],["\u{1D6F9}","PS"],["\u{1D6FA}","O"],["\u{1D6FB}","D"],["\u{1D6FC}","a"],["\u{1D6FD}","b"],["\u{1D6FE}","g"],["\u{1D6FF}","d"],["\u{1D700}","e"],["\u{1D701}","z"],["\u{1D702}","i"],["\u{1D703}","th"],["\u{1D704}","i"],["\u{1D705}","k"],["\u{1D706}","l"],["\u{1D707}","m"],["\u{1D708}","n"],["\u{1D709}","ks"],["\u{1D70A}","o"],["\u{1D70B}","p"],["\u{1D70C}","r"],["\u{1D70D}","s"],["\u{1D70E}","s"],["\u{1D70F}","t"],["\u{1D710}","y"],["\u{1D711}","f"],["\u{1D712}","x"],["\u{1D713}","ps"],["\u{1D714}","o"],["\u{1D715}","d"],["\u{1D716}","E"],["\u{1D717}","TH"],["\u{1D718}","K"],["\u{1D719}","f"],["\u{1D71A}","r"],["\u{1D71B}","p"],["\u{1D71C}","A"],["\u{1D71D}","V"],["\u{1D71E}","G"],["\u{1D71F}","D"],["\u{1D720}","E"],["\u{1D721}","Z"],["\u{1D722}","I"],["\u{1D723}","TH"],["\u{1D724}","I"],["\u{1D725}","K"],["\u{1D726}","L"],["\u{1D727}","M"],["\u{1D728}","N"],["\u{1D729}","KS"],["\u{1D72A}","O"],["\u{1D72B}","P"],["\u{1D72C}","S"],["\u{1D72D}","TH"],["\u{1D72E}","S"],["\u{1D72F}","T"],["\u{1D730}","Y"],["\u{1D731}","F"],["\u{1D732}","X"],["\u{1D733}","PS"],["\u{1D734}","O"],["\u{1D735}","D"],["\u{1D736}","a"],["\u{1D737}","v"],["\u{1D738}","g"],["\u{1D739}","d"],["\u{1D73A}","e"],["\u{1D73B}","z"],["\u{1D73C}","i"],["\u{1D73D}","th"],["\u{1D73E}","i"],["\u{1D73F}","k"],["\u{1D740}","l"],["\u{1D741}","m"],["\u{1D742}","n"],["\u{1D743}","ks"],["\u{1D744}","o"],["\u{1D745}","p"],["\u{1D746}","r"],["\u{1D747}","s"],["\u{1D748}","s"],["\u{1D749}","t"],["\u{1D74A}","y"],["\u{1D74B}","f"],["\u{1D74C}","x"],["\u{1D74D}","ps"],["\u{1D74E}","o"],["\u{1D74F}","a"],["\u{1D750}","e"],["\u{1D751}","i"],["\u{1D752}","k"],["\u{1D753}","f"],["\u{1D754}","r"],["\u{1D755}","p"],["\u{1D756}","A"],["\u{1D757}","B"],["\u{1D758}","G"],["\u{1D759}","D"],["\u{1D75A}","E"],["\u{1D75B}","Z"],["\u{1D75C}","I"],["\u{1D75D}","TH"],["\u{1D75E}","I"],["\u{1D75F}","K"],["\u{1D760}","L"],["\u{1D761}","M"],["\u{1D762}","N"],["\u{1D763}","KS"],["\u{1D764}","O"],["\u{1D765}","P"],["\u{1D766}","R"],["\u{1D767}","TH"],["\u{1D768}","S"],["\u{1D769}","T"],["\u{1D76A}","Y"],["\u{1D76B}","F"],["\u{1D76C}","X"],["\u{1D76D}","PS"],["\u{1D76E}","O"],["\u{1D76F}","D"],["\u{1D770}","a"],["\u{1D771}","v"],["\u{1D772}","g"],["\u{1D773}","d"],["\u{1D774}","e"],["\u{1D775}","z"],["\u{1D776}","i"],["\u{1D777}","th"],["\u{1D778}","i"],["\u{1D779}","k"],["\u{1D77A}","l"],["\u{1D77B}","m"],["\u{1D77C}","n"],["\u{1D77D}","ks"],["\u{1D77E}","o"],["\u{1D77F}","p"],["\u{1D780}","r"],["\u{1D781}","s"],["\u{1D782}","s"],["\u{1D783}","t"],["\u{1D784}","y"],["\u{1D785}","f"],["\u{1D786}","x"],["\u{1D787}","ps"],["\u{1D788}","o"],["\u{1D789}","a"],["\u{1D78A}","e"],["\u{1D78B}","i"],["\u{1D78C}","k"],["\u{1D78D}","f"],["\u{1D78E}","r"],["\u{1D78F}","p"],["\u{1D790}","A"],["\u{1D791}","V"],["\u{1D792}","G"],["\u{1D793}","D"],["\u{1D794}","E"],["\u{1D795}","Z"],["\u{1D796}","I"],["\u{1D797}","TH"],["\u{1D798}","I"],["\u{1D799}","K"],["\u{1D79A}","L"],["\u{1D79B}","M"],["\u{1D79C}","N"],["\u{1D79D}","KS"],["\u{1D79E}","O"],["\u{1D79F}","P"],["\u{1D7A0}","S"],["\u{1D7A1}","TH"],["\u{1D7A2}","S"],["\u{1D7A3}","T"],["\u{1D7A4}","Y"],["\u{1D7A5}","F"],["\u{1D7A6}","X"],["\u{1D7A7}","PS"],["\u{1D7A8}","O"],["\u{1D7A9}","D"],["\u{1D7AA}","av"],["\u{1D7AB}","g"],["\u{1D7AC}","d"],["\u{1D7AD}","e"],["\u{1D7AE}","z"],["\u{1D7AF}","i"],["\u{1D7B0}","i"],["\u{1D7B1}","th"],["\u{1D7B2}","i"],["\u{1D7B3}","k"],["\u{1D7B4}","l"],["\u{1D7B5}","m"],["\u{1D7B6}","n"],["\u{1D7B7}","ks"],["\u{1D7B8}","o"],["\u{1D7B9}","p"],["\u{1D7BA}","r"],["\u{1D7BB}","s"],["\u{1D7BC}","s"],["\u{1D7BD}","t"],["\u{1D7BE}","y"],["\u{1D7BF}","f"],["\u{1D7C0}","x"],["\u{1D7C1}","ps"],["\u{1D7C2}","o"],["\u{1D7C3}","a"],["\u{1D7C4}","e"],["\u{1D7C5}","i"],["\u{1D7C6}","k"],["\u{1D7C7}","f"],["\u{1D7C8}","r"],["\u{1D7C9}","p"],["\u{1D7CA}","F"],["\u{1D7CB}","f"],["\u249C","(a)"],["\u249D","(b)"],["\u249E","(c)"],["\u249F","(d)"],["\u24A0","(e)"],["\u24A1","(f)"],["\u24A2","(g)"],["\u24A3","(h)"],["\u24A4","(i)"],["\u24A5","(j)"],["\u24A6","(k)"],["\u24A7","(l)"],["\u24A8","(m)"],["\u24A9","(n)"],["\u24AA","(o)"],["\u24AB","(p)"],["\u24AC","(q)"],["\u24AD","(r)"],["\u24AE","(s)"],["\u24AF","(t)"],["\u24B0","(u)"],["\u24B1","(v)"],["\u24B2","(w)"],["\u24B3","(x)"],["\u24B4","(y)"],["\u24B5","(z)"],["\u24B6","(A)"],["\u24B7","(B)"],["\u24B8","(C)"],["\u24B9","(D)"],["\u24BA","(E)"],["\u24BB","(F)"],["\u24BC","(G)"],["\u24BD","(H)"],["\u24BE","(I)"],["\u24BF","(J)"],["\u24C0","(K)"],["\u24C1","(L)"],["\u24C3","(N)"],["\u24C4","(O)"],["\u24C5","(P)"],["\u24C6","(Q)"],["\u24C7","(R)"],["\u24C8","(S)"],["\u24C9","(T)"],["\u24CA","(U)"],["\u24CB","(V)"],["\u24CC","(W)"],["\u24CD","(X)"],["\u24CE","(Y)"],["\u24CF","(Z)"],["\u24D0","(a)"],["\u24D1","(b)"],["\u24D2","(c)"],["\u24D3","(d)"],["\u24D4","(e)"],["\u24D5","(f)"],["\u24D6","(g)"],["\u24D7","(h)"],["\u24D8","(i)"],["\u24D9","(j)"],["\u24DA","(k)"],["\u24DB","(l)"],["\u24DC","(m)"],["\u24DD","(n)"],["\u24DE","(o)"],["\u24DF","(p)"],["\u24E0","(q)"],["\u24E1","(r)"],["\u24E2","(s)"],["\u24E3","(t)"],["\u24E4","(u)"],["\u24E5","(v)"],["\u24E6","(w)"],["\u24E7","(x)"],["\u24E8","(y)"],["\u24E9","(z)"],["\u010A","C"],["\u010B","c"],["\u0120","G"],["\u0121","g"],["\u0126","H"],["\u0127","h"],["\u017B","Z"],["\u017C","z"],["\u{1D7CE}","0"],["\u{1D7CF}","1"],["\u{1D7D0}","2"],["\u{1D7D1}","3"],["\u{1D7D2}","4"],["\u{1D7D3}","5"],["\u{1D7D4}","6"],["\u{1D7D5}","7"],["\u{1D7D6}","8"],["\u{1D7D7}","9"],["\u{1D7D8}","0"],["\u{1D7D9}","1"],["\u{1D7DA}","2"],["\u{1D7DB}","3"],["\u{1D7DC}","4"],["\u{1D7DD}","5"],["\u{1D7DE}","6"],["\u{1D7DF}","7"],["\u{1D7E0}","8"],["\u{1D7E1}","9"],["\u{1D7E2}","0"],["\u{1D7E3}","1"],["\u{1D7E4}","2"],["\u{1D7E5}","3"],["\u{1D7E6}","4"],["\u{1D7E7}","5"],["\u{1D7E8}","6"],["\u{1D7E9}","7"],["\u{1D7EA}","8"],["\u{1D7EB}","9"],["\u{1D7EC}","0"],["\u{1D7ED}","1"],["\u{1D7EE}","2"],["\u{1D7EF}","3"],["\u{1D7F0}","4"],["\u{1D7F1}","5"],["\u{1D7F2}","6"],["\u{1D7F3}","7"],["\u{1D7F4}","8"],["\u{1D7F5}","9"],["\u{1D7F6}","0"],["\u{1D7F7}","1"],["\u{1D7F8}","2"],["\u{1D7F9}","3"],["\u{1D7FA}","4"],["\u{1D7FB}","5"],["\u{1D7FC}","6"],["\u{1D7FD}","7"],["\u{1D7FE}","8"],["\u{1D7FF}","9"],["\u2460","1"],["\u2461","2"],["\u2462","3"],["\u2463","4"],["\u2464","5"],["\u2465","6"],["\u2466","7"],["\u2467","8"],["\u2468","9"],["\u2469","10"],["\u246A","11"],["\u246B","12"],["\u246C","13"],["\u246D","14"],["\u246E","15"],["\u246F","16"],["\u2470","17"],["\u2471","18"],["\u2472","19"],["\u2473","20"],["\u2474","1"],["\u2475","2"],["\u2476","3"],["\u2477","4"],["\u2478","5"],["\u2479","6"],["\u247A","7"],["\u247B","8"],["\u247C","9"],["\u247D","10"],["\u247E","11"],["\u247F","12"],["\u2480","13"],["\u2481","14"],["\u2482","15"],["\u2483","16"],["\u2484","17"],["\u2485","18"],["\u2486","19"],["\u2487","20"],["\u2488","1."],["\u2489","2."],["\u248A","3."],["\u248B","4."],["\u248C","5."],["\u248D","6."],["\u248E","7."],["\u248F","8."],["\u2490","9."],["\u2491","10."],["\u2492","11."],["\u2493","12."],["\u2494","13."],["\u2495","14."],["\u2496","15."],["\u2497","16."],["\u2498","17."],["\u2499","18."],["\u249A","19."],["\u249B","20."],["\u24EA","0"],["\u24EB","11"],["\u24EC","12"],["\u24ED","13"],["\u24EE","14"],["\u24EF","15"],["\u24F0","16"],["\u24F1","17"],["\u24F2","18"],["\u24F3","19"],["\u24F4","20"],["\u24F5","1"],["\u24F6","2"],["\u24F7","3"],["\u24F8","4"],["\u24F9","5"],["\u24FA","6"],["\u24FB","7"],["\u24FC","8"],["\u24FD","9"],["\u24FE","10"],["\u24FF","0"],["\u{1F670}","&"],["\u{1F671}","&"],["\u{1F672}","&"],["\u{1F673}","&"],["\u{1F674}","&"],["\u{1F675}","&"],["\u{1F676}",'"'],["\u{1F677}",'"'],["\u{1F678}",'"'],["\u203D","?!"],["\u{1F679}","?!"],["\u{1F67A}","?!"],["\u{1F67B}","?!"],["\u{1F67C}","/"],["\u{1F67D}","\\"],["\u{1F707}","AR"],["\u{1F708}","V"],["\u{1F709}","V"],["\u{1F706}","VR"],["\u{1F705}","VF"],["\u{1F729}","2"],["\u{1F72A}","5"],["\u{1F761}","f"],["\u{1F762}","W"],["\u{1F763}","U"],["\u{1F767}","V"],["\u{1F768}","T"],["\u{1F76A}","V"],["\u{1F76B}","MB"],["\u{1F76C}","VB"],["\u{1F772}","3B"],["\u{1F773}","3B"],["\u{1F4AF}","100"],["\u{1F519}","BACK"],["\u{1F51A}","END"],["\u{1F51B}","ON!"],["\u{1F51C}","SOON"],["\u{1F51D}","TOP"],["\u{1F51E}","18"],["\u{1F524}","abc"],["\u{1F520}","ABCD"],["\u{1F521}","abcd"],["\u{1F522}","1234"],["\u{1F523}","T&@%"],["#\uFE0F\u20E3","#"],["*\uFE0F\u20E3","*"],["0\uFE0F\u20E3","0"],["1\uFE0F\u20E3","1"],["2\uFE0F\u20E3","2"],["3\uFE0F\u20E3","3"],["4\uFE0F\u20E3","4"],["5\uFE0F\u20E3","5"],["6\uFE0F\u20E3","6"],["7\uFE0F\u20E3","7"],["8\uFE0F\u20E3","8"],["9\uFE0F\u20E3","9"],["\u{1F51F}","10"],["\u{1F170}\uFE0F","A"],["\u{1F171}\uFE0F","B"],["\u{1F18E}","AB"],["\u{1F191}","CL"],["\u{1F17E}\uFE0F","O"],["\u{1F17F}","P"],["\u{1F198}","SOS"],["\u{1F172}","C"],["\u{1F173}","D"],["\u{1F174}","E"],["\u{1F175}","F"],["\u{1F176}","G"],["\u{1F177}","H"],["\u{1F178}","I"],["\u{1F179}","J"],["\u{1F17A}","K"],["\u{1F17B}","L"],["\u{1F17C}","M"],["\u{1F17D}","N"],["\u{1F180}","Q"],["\u{1F181}","R"],["\u{1F182}","S"],["\u{1F183}","T"],["\u{1F184}","U"],["\u{1F185}","V"],["\u{1F186}","W"],["\u{1F187}","X"],["\u{1F188}","Y"],["\u{1F189}","Z"],["\u2212","-"],["\u2053","-"]],zT=new Map(HT),Iu=zT});var Gg,Ro,$u,Xg=S(()=>{Gg=[["\xE6","ae"],["\xC6","Ae"],["\xF8","oe"],["\xD8","Oe"],["\xE5","aa"],["\xC5","Aa"]],Ro={sv:[["\xE4","a"],["\xC4","A"],["\xF6","o"],["\xD6","O"],["\xE5","a"],["\xC5","A"]],da:Gg,nb:Gg,de:[["\xE4","ae"],["\xC4","Ae"],["\xF6","oe"],["\xD6","Oe"],["\xFC","ue"],["\xDC","Ue"],["\xDF","ss"],["\u1E9E","Ss"]],tr:[["\xE2","a"],["\xC2","A"],["\xF6","o"],["\xD6","O"],["\xFC","u"],["\xDC","U"]],hu:[["\u0171","u"],["\u0170","U"],["\xF6","o"],["\xD6","O"],["\xFC","u"],["\xDC","U"],["\xE1","a"],["\xC1","A"],["\xE9","e"],["\xC9","E"],["\xED","i"],["\xCD","I"],["\xF3","o"],["\xD3","O"],["\xFA","u"],["\xDA","U"]],sr:[["\u0452","dj"],["\u0402","Dj"],["\u045F","dz"],["\u040F","Dz"],["\u0459","lj"],["\u0409","Lj"],["\u045A","nj"],["\u040A","Nj"],["\u045B","c"],["\u040B","C"],["\u0447","ch"],["\u0427","Ch"],["\u0448","sh"],["\u0428","Sh"],["\u0436","zh"],["\u0416","Zh"]]};for(let t of Object.keys(Ro))Ro[t]=new Map(Ro[t]);$u=Ro});function Nu(t,e){if(typeof t!="string")throw new TypeError(`Expected a string, got \`${typeof t}\``);e={customReplacements:[],...e};let n=VT(e.locale),r=Iu,s=e.customReplacements.length>0||e.customReplacements.size>0;if(n||s){if(r=new Map(Iu),n)for(let[i,o]of n)r.set(i,o);for(let[i,o]of e.customReplacements)r.set(i,o)}return t=t.normalize(),t=YT(t,r),t=t.normalize("NFD").replaceAll(/\p{Diacritic}/gu,"").normalize(),t=t.replaceAll(/\p{Dash_Punctuation}/gu,"-"),t}var YT,VT,Qg=S(()=>{Vg();Xg();YT=(t,e)=>{for(let[n,r]of e)t=t.replaceAll(n,r);return t},VT=t=>{if(!t)return;let e=t.toLowerCase().replace(/^no(-|$)/,"nb$1");return $u[e]||$u[e.split("-")[0]]||void 0}});var GT,Zg,ey=S(()=>{GT=[["&"," and "],["\u{1F984}"," unicorn "],["\u2665"," love "]],Zg=GT});function Lu(t,e){if(typeof t!="string")throw new TypeError(`Expected a string, got \`${typeof t}\``);e={separator:"-",lowercase:!0,decamelize:!0,customReplacements:[],preserveLeadingUnderscore:!1,preserveTrailingDash:!1,preserveCharacters:[],transliterate:!0,...e};let n=e.preserveLeadingUnderscore&&t.startsWith("_"),r=e.preserveTrailingDash&&t.endsWith("-");if(e.transliterate){let i=new Map([...Zg,...e.customReplacements]);t=Nu(t,{customReplacements:i,locale:e.locale})}else if(e.customReplacements.length>0)for(let[i,o]of e.customReplacements)t=t.replaceAll(i,o);e.decamelize&&(t=XT(t));let s=ZT(e);return e.lowercase&&(t=e.locale?t.toLocaleLowerCase(e.locale):t.toLowerCase()),t=t.replaceAll(/([a-zA-Z\d]+)['\u2019]([ts])(\s|$)/g,"$1$2$3"),t=t.replace(s,e.separator),t=t.replaceAll("\\",""),e.separator&&(t=QT(t,e.separator)),n&&(t=`_${t}`),r&&(t=`${t}-`),t}var XT,QT,ZT,ty=S(()=>{Yg();Qg();ey();XT=t=>t.replaceAll(/([A-Z]{2,})(\d+)/g,"$1 $2").replaceAll(/([a-z\d]+)([A-Z]{2,})/g,"$1 $2").replaceAll(/([a-z\d])([A-Z])/g,"$1 $2").replaceAll(/([A-Z]+)([A-Z][a-rt-z\d]+)/g,"$1 $2"),QT=(t,e)=>{let n=_o(e);return t.replaceAll(new RegExp(`(?:${n}){2,}`,"g"),e).replaceAll(new RegExp(`^(?:${n})|(?:${n})$`,"g"),"")},ZT=t=>{let e=String.raw`a-z\d`;if(e+=t.lowercase?"":"A-Z",t.transliterate===!1&&(e+=String.raw`\p{L}\p{N}`),t.preserveCharacters.length>0)for(let r of t.preserveCharacters){if(r===t.separator)throw new Error(`The separator character \`${t.separator}\` cannot be included in preserved characters: ${t.preserveCharacters}`);e+=_o(r)}let n=t.transliterate?"g":"gu";return new RegExp(`[^${e}]+`,n)}});function Zn(t){return Lu(t)}var ny=S(()=>{ty()});var er,ry,sy=S(()=>{er={local:"local",ide:"ide",published:"published",inline:"inline"},ry=Object.values(er).map(t=>`'${t}'`).join(" | ")});var As,Mu,iy=S(()=>{As=` *, *::before, *::after { box-sizing: border-box; }
|
|
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; }`,Mu=" html, body { height: 100%; }"});var oy,ay=S(()=>{oy=`(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 ly,cy=S(()=>{ly=`(function () {
|
|
242
242
|
var W = window;
|
|
243
243
|
var rtData, rtInsight, rtHasInsight = false;
|
|
244
244
|
var applyData, applyInsight, send;
|
|
@@ -292,40 +292,51 @@ ${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.pus
|
|
|
292
292
|
return publish();
|
|
293
293
|
}
|
|
294
294
|
};
|
|
295
|
-
})();`});var
|
|
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 Z=S(()=>{Ci();Kl();Wp();Yp();Ru();zg();ny();sy();iy();ay();cy();Oi()});function ie(t){let e=Math.max(0,Math.round(t/1e3));if(e<60)return`${e}s`;let n=Math.floor(e/60);return n<60?`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}function fy(t,e){if(!e)return t;let n=t.replace(/\\/g,"/"),r=e.replace(/\\/g,"/").replace(/\/+$/,"");return n.toLowerCase().startsWith(r.toLowerCase()+"/")?n.slice(r.length+1):t}function py(t){return t.replace(/[/\\]+$/,"").split(/[/\\]/).pop()??""}function hy(t){return!t||typeof t!="object"?"":ee(t.command)??ee(t.file_path)??ee(t.filePath)??ee(t.path)??ee(t.pattern)??ee(t.query)??ee(t.url)??ee(t.skill)??ee(t.description)??""}function Bu(t){let e=/^mcp__(.+?)__(.+)$/.exec(t);return e?`${e[1][0].toUpperCase()}${e[1].slice(1)} [${e[2]}]`:t}var ee,Ts,dy,Io=S(()=>{"use strict";ee=t=>typeof t=="string"?t:void 0,Ts=t=>t.replace(/\u001b\[[0-9;]*m/g,""),dy=t=>` (+${t} line${t===1?"":"s"})`});function Pe(t){return t.length>ju?t.slice(0,ju)+`
|
|
296
|
+
\u2026[${t.length-ju} more characters truncated]`:t}function De(t){let e=Ts(t).split(`
|
|
297
|
+
`).map(i=>i.trim()).filter(Boolean),n=e[0];if(!n)return"";let r=n.length>300?n.slice(0,300).trimEnd()+"\u2026":n,s=e.length-1;return s>0?r+dy(s):r}var ju,Ee,$o,Cs=S(()=>{"use strict";Io();ju=5e4,Ee=(t,e,n=e+"s")=>`${t} ${t===1?e:n}`;$o=(t,e)=>``});import{closeSync as my,existsSync as eC,fstatSync as tC,openSync as gy,readdirSync as nC,readSync as yy,statSync as rC}from"fs";import{join as sC}from"path";function tr(t,e){let n;try{n=gy(t,"r")}catch{return}try{let r=Buffer.alloc(e),s=yy(n,r,0,e,0);return{text:r.subarray(0,s).toString("utf8"),bytes:s}}finally{my(n)}}function No(t,e){let n;try{n=gy(t,"r")}catch{return}try{let r=tC(n).size,s=Math.min(e,r),i=Buffer.alloc(s),o=yy(n,i,0,s,r-s);return{text:i.subarray(0,o).toString("utf8"),partial:r>s}}finally{my(n)}}function Lo(t){if(!eC(t))return[];let e;try{e=nC(t)}catch{return[]}let n=[];for(let r of e){if(!r.endsWith(".jsonl"))continue;let s=sC(t,r);try{let i=rC(s);i.isFile()&&n.push({sessionId:r.slice(0,-6),file:s,mtime:i.mtimeMs})}catch{}}return n}var Mo=S(()=>{"use strict"});var Ft,Do=S(()=>{"use strict";Ft=class{ensureHarnessSupport(){}forRead(){return this}linker(){return{link(){}}}}});import{openSync as iC,readSync as oC,closeSync as aC,statSync as ky,readdirSync as xy,readFileSync as Ey,existsSync as lC}from"fs";import{join as fn}from"path";import{homedir as cC}from"os";function uC(t){return t.replace(/[^a-zA-Z0-9]/g,"-")}function fC(t,e,n){let r=fn(Fu(t,e),n,dC),s;try{s=xy(r)}catch{return[]}let i=NC(t,n),o=[];for(let a of s){if(!a.endsWith(".jsonl"))continue;let l=fn(r,a),c;try{c=ky(l)}catch{continue}let u=a.slice(0,-6),d={};try{d=JSON.parse(Ey(fn(r,`${u}.meta.json`),"utf8"))}catch{}let f=mC(l,c.size,c.mtimeMs);o.push({id:u.startsWith("agent-")?u.slice(6):u,file:l,mtime:c.mtimeMs,started:c.birthtimeMs||void 0,tokens:f.tokens,failing:f.failing,running:!!f.running&&(i===void 0||c.mtimeMs>=i),liveSince:i,label:d.description??"",kind:d.agentType===pC?void 0:d.agentType,model:f.model?.replace(/^claude-/,"").replace(/-\d{8}$/,"")??d.model,effort:f.effort,spawnId:d.toolUseId,parentId:d.parentAgentId,depth:d.spawnDepth??1,stopped:!!d.stoppedByUser})}return o}function mC(t,e,n){let r=by.get(t);if(r&&r.size===e&&r.mtime===n)return r;let s={};for(let i of hC){let o=No(t,i);if(!o)break;let a=o.text.split(`
|
|
298
|
+
`);o.partial&&a.shift();let l=[];for(let f of a)if(f.trim())try{l.push(JSON.parse(f))}catch{}if(o.partial&&!l.some(f=>f.type==="user"||f.type==="assistant"))continue;let c,u;for(let f=l.length-1;f>=0&&!u;f--){let p=l[f];p?.type==="assistant"&&(c??=p,!p.isApiErrorMessage&&p.message?.usage&&(u=p))}let d=u?.message?.usage;if(s={tokens:d?(d.input_tokens??0)+(d.output_tokens??0)+(d.cache_read_input_tokens??0)+(d.cache_creation_input_tokens??0):r?.tokens,model:u?.message?.model??r?.model,effort:u?.effort??r?.effort,running:Ty(l),failing:!!c?.isApiErrorMessage},!(s.tokens===void 0&&o.partial))break}return s.model??=gC(t),by.set(t,{size:e,mtime:n,...s}),s}function gC(t){for(let e of(tr(t,256*1024)?.text??"").split(`
|
|
299
|
+
`))if(e.includes('"modelId"'))try{let n=JSON.parse(e).attachment?.identity?.modelId;if(n)return n}catch{}}function Ty(t){let e;for(let i of t)(i.type==="user"||i.type==="assistant")&&(e=i);if(!e)return!1;if(e.type==="user"){try{if(yC(e,t))return!1;let i=e.message?.content,o=typeof i=="string"?i:Array.isArray(i)?i.filter(a=>a&&a.type==="text").map(a=>a.text??"").join(""):"";if(!Ay(e)&&o.trim()&&Ut(o)==="")return!1}catch{}return!0}let r=(Array.isArray(e.message?.content)?e.message.content:[]).filter(i=>i.type==="tool_use").map(i=>i.id);if(r.length===0)return!e.message?.stop_reason||e.message.stop_reason==="tool_use";let s=new Set;for(let i of t){let o=i.message?.content;if(Array.isArray(o))for(let a of o)a.type==="tool_result"&&a.tool_use_id&&s.add(a.tool_use_id)}return r.some(i=>i&&!s.has(i))}function yC(t,e){let n=t.message?.content,r=Array.isArray(n)?n.filter(i=>i?.type==="tool_result").map(i=>i.tool_use_id):[];if(r.length===0)return!1;let s=new Set;for(let i of e){let o=i.type==="assistant"?i.message?.content:void 0;if(Array.isArray(o))for(let a of o)a?.type==="tool_use"&&a.name==="SubagentHandback"&&s.add(a.id)}return r.every(i=>s.has(i))}function jo(t){let e=t?.type==="image"?t.source:void 0;return e?.type==="base64"&&e.data?$o(e.data,e.media_type):""}function Os(t){return typeof t=="string"?Pe(t):Array.isArray(t)?t.map(e=>{if(typeof e=="string")return Pe(e);let n=e;return typeof n?.text=="string"?Pe(n.text):n?.content!=null?Os(n.content):jo(n)}).join(`
|
|
300
|
+
`):t==null?"":Pe(JSON.stringify(t))}function bC(t){let e=t.trim();return!!e&&Cy.some(n=>n.test(e))}function wC(t){let e=t.trim();return e?Cy.some(n=>{let r=n.exec(e);return!!r&&r.index===0}):!0}function SC(t){return t.replace(vC,"")}function kC(t){let e=/^<command-name>([\s\S]*?)<\/command-name>/.exec(t)?.[1]?.trim();if(!e)return;let n=/<command-args>([\s\S]*?)<\/command-args>/.exec(t)?.[1]?.trim();return n?`${e} ${n}`:e}function Ut(t){let e=SC(t).trim();return e?kC(e)??(bC(e)?"":e):""}function Fo(t){let e=xC.exec(t.trim());if(e)return{from:e[1],body:AC(e[2].replace(EC,""))}}function AC(t){let e=t.split(`
|
|
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
|
|
304
|
-
`).length,"line")}`;if(n.mode==="content")return
|
|
305
|
-
`)){if(!p.includes(`"${
|
|
306
|
-
`)){if(!c.trim())continue;let
|
|
307
|
-
`;
|
|
308
|
-
`),
|
|
309
|
-
`)
|
|
310
|
-
`)
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
`)
|
|
318
|
-
|
|
319
|
-
`),r=[];if(
|
|
320
|
-
`)}function
|
|
303
|
+
`):t}function Bo(t){let e=Fo(t);return e?{type:"user",text:e.body,agent:{from:e.from}}:{type:"user",text:t}}function TC(t){let e=t.message?.content;return typeof e=="string"&&!!Fo(e)}function CC(t){let e=t.message?.content;return typeof e=="string"&&e.startsWith(wy)?e.slice(wy.length).trim():void 0}function Uu(t){return t?.type==="text"&&typeof t.text=="string"?Ut(t.text):""}function PC(t){let e=t.message?.content,n=t.type==="attachment"&&t.attachment?.type==="queued_command"?Os(t.attachment.prompt):t.type==="user"&&t.isMeta&&!(Array.isArray(e)&&e.some(s=>s?.type==="tool_result"))?Os(e):"";if(!n.includes("<task-notification>"))return[];let r=[];for(let[,s]of n.matchAll(OC)){let i=/<tool-use-id>([^<]+)<\/tool-use-id>/.exec(s)?.[1],o=/<status>([^<]+)<\/status>/.exec(s)?.[1];if(!i||!o||o==="running")continue;let a=/\bexit(?: code)? (\d+)/.exec(/<summary>([\s\S]*?)<\/summary>/.exec(s)?.[1]??"")?.[1],l=/<output-file>([^<]+)<\/output-file>/.exec(s)?.[1];r.push({type:"task_done",id:i,outcome:o,exit:a===void 0?void 0:Number(a),output:l})}return r}function qu(t,e){if(typeof t=="string")return De(t);if(!t||typeof t!="object")return De(e);let n=t;if(n.type==="text"&&typeof n.file?.numLines=="number")return Ee(n.file.numLines,"line");if(n.type==="image"){let r=vy(n.file?.originalSize);return r?`image (${r})`:"image"}if(n.type==="pdf"){let r=vy(n.file?.originalSize);return r?`PDF (${r})`:"PDF"}if(n.type==="parts"&&typeof n.file?.count=="number")return Ee(n.file.count,"page");if(n.type==="file_unchanged")return"unchanged since last read";if(n.type==="create"&&typeof n.content=="string")return`created, ${Ee(n.content.split(`
|
|
304
|
+
`).length,"line")}`;if(n.mode==="content")return Ee(n.numLines??0,"line");if(n.mode==="count")return`${Ee(n.numMatches??0,"match","matches")} (${Ee(n.numFiles??0,"file")})`;if(n.mode==="files_with_matches")return Ee(n.numFiles??0,"file");if(Array.isArray(n.structuredPatch)){let r=0,s=0;for(let i of n.structuredPatch)for(let o of i?.lines??[])typeof o=="string"&&(o.startsWith("+")?r++:o.startsWith("-")&&s++);return`+${r} \u2212${s}`}return typeof n.stdout=="string"||typeof n.stderr=="string"?n.backgroundTaskId?"running in background":n.interrupted?"interrupted":De(n.stdout||n.stderr||"")||"no output":typeof n.code=="number"&&typeof n.codeText=="string"?`${n.code} ${n.codeText}`:typeof n.searchCount=="number"?Ee(n.searchCount,"search","searches"):Array.isArray(n.matches)&&typeof n.total_deferred_tools=="number"?Ee(n.matches.length,"tool"):Array.isArray(n.newTodos)?Ee(n.newTodos.length,"todo"):typeof n.numFiles=="number"?Ee(n.numFiles,"file"):De(e)}function Ps(t){return!!t.isMeta}function $C(t){let e;try{e=iC(t,"r")}catch{return""}try{let r=65536;try{r=ky(t).size}catch{}let s=(c,u)=>{if(u<=0)return"";let d=Buffer.alloc(u),f=oC(e,d,0,u,c);return d.subarray(0,f).toString("utf8")},i=(c,u,d)=>{let f="";for(let p of c.split(`
|
|
305
|
+
`)){if(!p.includes(`"${u}"`))continue;let h;try{h=JSON.parse(p)}catch{continue}let m=h?.[d];h?.type===u&&typeof m=="string"&&m&&(f=m)}return f},o=s(0,Math.min(65536,r)),a=r>65536?s(r-65536,65536):"",l=i(a,"custom-title","customTitle")||i(o,"custom-title","customTitle")||i(a,"ai-title","aiTitle")||i(o,"ai-title","aiTitle");if(l)return l.replace(/\s+/g," ").trim().slice(0,200);for(let c of o.split(`
|
|
306
|
+
`)){if(!c.trim())continue;let u;try{u=JSON.parse(c)}catch{continue}if(!u||Ps(u)||u.type!=="user")continue;let d=u.message?.content,f="";typeof d=="string"?f=Ut(d):Array.isArray(d)&&(f=d.map(Uu).filter(Boolean).join(" "));let p=f.replace(/\s+/g," ").trim();if(p)return(p.replace(/^Continuing from a prior session\. Here is the summary of our work so far:\s*/i,"").trim()||p).slice(0,200)}return""}finally{aC(e)}}function Ju(t){let e=fn(t,"sessions"),n;try{n=xy(e)}catch{return[]}let r=[];for(let s of n)if(s.endsWith(".json"))try{let i=JSON.parse(Ey(fn(e,s),"utf8"));if(!i?.sessionId)continue;process.kill(i.pid,0),r.push(i)}catch{}return r}function Sy(t,e){return Ju(t).some(n=>n.sessionId===e)}function NC(t,e){let n=Ju(t).filter(r=>r.sessionId===e).map(r=>r.startedAt);return n.length&&n.every(r=>typeof r=="number")?Math.min(...n):void 0}function LC(t){return new Set(Ju(t).filter(e=>e.status==="busy").map(e=>e.sessionId))}var Ay,Fu,dC,pC,hC,by,Cy,vC,xC,EC,wy,OC,_C,RC,IC,vy,nr,Uo=S(()=>{"use strict";Cs();Mo();Do();Io();Ay=t=>t.type==="user"&&Array.isArray(t.message?.content)&&t.message.content.some(e=>e?.type==="tool_result");Fu=(t,e)=>fn(t,"projects",uC(e)),dC="subagents";pC="general-purpose",hC=[256*1024,4*1024*1024,64*1024*1024],by=new Map;Cy=[/\[Request interrupted by user\b/i,/\[Tool use was interrupted\]/i,/Claude Code returned an error/i,/\[ede_diagnostic\]/i,/^No response requested\.?$/i,/^<task-notification\b/i,/^<system-reminder\b/i,/^<local-command-stdout\b/i,/^<local-command-stderr\b/i];vC=/<ide_[a-z_]+>[\s\S]*?<\/ide_[a-z_]+>/gi;xC=/^(?:[^\n<][^\n]*\n)?<agent-message from="([^"]+)">\n([\s\S]*?)(?:\n?<\/agent-message>[\s\S]*)?$/,EC=/^\[[^\]\n]+\][\s\S]*?The report follows:\n/;wy=`The coordinator sent a message while you were working:
|
|
307
|
+
`;OC=/<task-notification>([\s\S]*?)<\/task-notification>/g;_C=/^(Command running in background with ID|Command did not complete within its \d+s timeout and was moved to the background|Async agent launched)/,RC=/\bID: ([A-Za-z0-9]+)/,IC=new Set(["TaskStop","KillShell"]),vy=t=>typeof t!="number"?"":t<1024?`${t}B`:t<1048576?`${Math.round(t/1024)}KB`:`${(t/1048576).toFixed(1)}MB`;nr=class extends Ft{constructor(n=fn(cC(),".claude")){super();this.root=n}displayName="Claude Mirror";detectsSelf(){return process.env.CLAUDECODE==="1"}detectsInstalled(){return lC(this.root)}sessionsDir(n){return Fu(this.root,n)}listSessionFiles(n){return Lo(Fu(this.root,n))}listChildren(n,r){return fC(this.root,n,r)}callerSessionId(){return process.env.CLAUDE_CODE_SESSION_ID||void 0}parseEntry(n){try{return JSON.parse(n)}catch{return null}}idOf(n){return n.uuid}parentOf(n){return n.parentUuid}linker(){let n=new Map,r=new Map;return{link(s){if(!s.uuid||n.has(s.uuid))return;let i=s.parentUuid===void 0?void 0:n.get(s.parentUuid),o=s.type==="assistant"?s.message?.id:Ay(s)?i:void 0;o&&(i===o&&(s.parentUuid=r.get(o)),n.set(s.uuid,o),r.set(o,s.uuid))}}}timestampOf(n){return n.timestamp}isSidechain(n,r){return!!n.isSidechain!=(r==="child")}isLeafType(n){return n.type==="user"||n.type==="assistant"}isRecoveryNoise(n){return!!n.isApiErrorMessage}apply(n,r){let s=CC(n);if(s)return{events:[Bo(s)]};let i=PC(n);if(i.length)return{events:i};if(Ps(n)&&!TC(n))return{events:[]};let o=[];if(n.type==="user"){let a=n.message?.content;if(typeof a=="string"){let l=Ut(a);l&&o.push(Bo(l))}else if(Array.isArray(a))for(let l of a)if(l?.type==="tool_result"){let c=Os(l.content),u=l.is_error?/^Exit code (\d+)/.exec(c)?.[1]:void 0,d=n.toolUseResult,f=_C.test(c)||!!d&&typeof d=="object"&&!!d.backgroundTaskId;o.push({type:"tool_result",id:l.tool_use_id??"",content:c,isError:!!l.is_error,digest:qu(n.toolUseResult,c),exit:u===void 0?void 0:Number(u),background:f||void 0,task:f?RC.exec(c)?.[1]??ee(d?.backgroundTaskId):void 0,output:f?/Output is being written to: (\S.*?)\.?\s*$/m.exec(c)?.[1]:void 0,refused:!!l.is_error&&u===void 0||void 0})}else{let c=Uu(l)||jo(l);c&&o.push(Bo(c))}return{events:o}}if(n.type==="attachment"&&n.attachment?.type==="queued_command"){let a=Ut(Os(n.attachment.prompt));return a&&o.push(Bo(a)),{events:o}}if(n.type==="assistant"){let a=n.message?.content,l=Array.isArray(a)?a:[],c=l.filter(h=>h.type==="text").map(h=>h.text??"").filter(h=>!wC(h)).join(""),u=l.filter(h=>h.type==="thinking").map(h=>h.thinking??"").join(`
|
|
308
|
+
`),d=l.filter(h=>h.type==="tool_use").map(h=>({id:h.id??"",name:h.name??"",input:h.input??{}}));if(c||u||d.length){let h=Date.parse(n.timestamp??""),m=!isNaN(h)&&h>=r;o.push({type:"assistant",text:c,thinking:u,tools:d,live:m,error:n.isApiErrorMessage||void 0})}(n.message?.stop_reason==="end_turn"||d.some(h=>h.name==="SubagentHandback"))&&o.push({type:"turn_end"});for(let h of d)if(IC.has(h.name)){let m=ee(h.input.task_id)??ee(h.input.shell_id);m&&o.push({type:"task_done",task:m,outcome:"stopped"})}let f=n.message?.usage??n.usage,p=f&&{in:f.input_tokens??0,out:f.output_tokens??0,cached:f.cache_read_input_tokens??0,cacheCreate:f.cache_creation_input_tokens??0};return{events:o,usage:p,model:n.message?.model}}return{events:o}}chainWorking(n){return Ty(n)}sessionAlive(n){return Sy(this.root,n)}sessionEnded(n){return!Sy(this.root,n)}sessionsWorking(n){return LC(this.root)}readPreview(n){return $C(n)}searchText(n){if(!n||Ps(n)||n.type!=="user"&&n.type!=="assistant")return"";let r=n.message?.content,s="";if(typeof r=="string")s=Ut(r);else if(Array.isArray(r)){let i=r;s=n.type==="user"?i.map(Uu).filter(Boolean).join(" "):i.filter(o=>o.type==="text"&&typeof o.text=="string").map(o=>o.text).join(" ")}return s.replace(/\s+/g," ").trim()}}});import{spawn as MC,execFile as DC}from"child_process";import{promisify as BC}from"util";import{randomBytes as Py}from"crypto";async function FC(){let t;try{t=(await jC("codex",["app-server","daemon","version"],{shell:!0,timeout:_y})).stdout}catch(n){let r=n,s=(r.stderr||r.message||"").trim().split(`
|
|
309
|
+
`).at(-1);throw new Error(r.code==="ENOENT"?"the codex CLI is not on PATH":`the codex CLI could not report its app server (${s})`)}let e;try{e=JSON.parse(t)}catch{throw new Error(`the codex CLI's daemon report was not JSON: ${t.trim().slice(0,120)}`)}if(e.status!=="running")throw new Error(`no shared Codex app server is running (daemon status: ${e.status??"unknown"})`);if(!e.managedCodexPath||!e.socketPath)throw new Error("the codex CLI named no daemon binary or socket");return{exe:e.managedCodexPath,socket:e.socketPath}}function Oy(t){let e=Buffer.from(t),n=Py(4),r=e.length,s=r<126?Buffer.from([129,128|r]):r<65536?Buffer.from([129,254,r>>8,r&255]):Buffer.concat([Buffer.from([129,255]),(()=>{let i=Buffer.alloc(8);return i.writeBigUInt64BE(BigInt(r)),i})()]);return Buffer.concat([s,n,Buffer.from(e.map((i,o)=>i^n[o%4]))])}async function Ry(){let t=await FC(),e=new Wu(MC(t.exe,["app-server","proxy","--sock",t.socket],{stdio:["pipe","pipe","pipe"]}));return await e.call("initialize",{clientInfo:{name:"typebulb",version:"1"}}),e.notify("initialized"),e}async function Ku(){let t=await Ry();try{return(await t.call("thread/loaded/list",{})).data??[]}finally{t.close()}}async function Iy(t,e,n){let r=await Ry();try{await r.call("turn/start",{threadId:t,input:[],toolOutput:{name:e,output:n},turnTrigger:"typebulb"})}finally{r.close()}}var jC,_y,Wu,$y=S(()=>{"use strict";jC=BC(DC),_y=15e3;Wu=class{constructor(e){this.proc=e;let n,r;this.#u=new Promise((s,i)=>{n=s,r=i}),e.stderr.on("data",s=>{this.#n+=s}),e.stdout.on("data",s=>this.#c(s,n)),e.on("exit",()=>{let s=this.#n.trim().split(`
|
|
310
|
+
`).filter(i=>i.trim()).join(" ").slice(0,300);r(new Error(`could not reach the Codex app server socket${s?`: ${s}`:""}`));for(let i of this.#t.values())i({error:{message:"connection closed"}})}),e.stdin.write(`GET / HTTP/1.1\r
|
|
311
|
+
Host: localhost\r
|
|
312
|
+
Upgrade: websocket\r
|
|
313
|
+
Connection: Upgrade\r
|
|
314
|
+
Sec-WebSocket-Key: ${Py(16).toString("base64")}\r
|
|
315
|
+
Sec-WebSocket-Version: 13\r
|
|
316
|
+
\r
|
|
317
|
+
`)}#t=new Map;#o=1;#e=Buffer.alloc(0);#s=!1;#u;#n="";#c(e,n){if(this.#e=Buffer.concat([this.#e,e]),!this.#s){let r=this.#e.indexOf(`\r
|
|
318
|
+
\r
|
|
319
|
+
`);if(r<0)return;this.#s=!0,this.#e=this.#e.subarray(r+4),n()}for(;;){if(this.#e.length<2)return;let r=this.#e[1]&127,s=2;if(r===126){if(this.#e.length<4)return;r=this.#e.readUInt16BE(2),s=4}else if(r===127){if(this.#e.length<10)return;r=Number(this.#e.readBigUInt64BE(2)),s=10}if(this.#e.length<s+r)return;let i=this.#e[0]&15,o=this.#e.subarray(s,s+r).toString();if(this.#e=this.#e.subarray(s+r),i===1)try{let a=JSON.parse(o);a.id!==void 0&&!a.method&&this.#t.has(a.id)&&(this.#t.get(a.id)(a),this.#t.delete(a.id))}catch{}}}async call(e,n){await this.#u;let r=this.#o++,s=await new Promise((i,o)=>{this.#t.set(r,i),setTimeout(()=>o(new Error(`no reply to ${e}`)),_y),this.proc.stdin.write(Oy(JSON.stringify({jsonrpc:"2.0",id:r,method:e,params:n})))});if(s.error)throw new Error(s.error.message??`${e} failed`);return s.result}notify(e){this.proc.stdin.write(Oy(JSON.stringify({jsonrpc:"2.0",method:e})))}close(){this.proc.kill()}}});import{statSync as qo,readdirSync as UC,existsSync as qC}from"fs";import{basename as Ny,join as Hu,resolve as JC}from"path";import{homedir as Ly}from"os";function KC(t){let e=t.trimStart();return WC.some(n=>e.startsWith(n))}function rr(t,e){return Array.isArray(t)?t.map(n=>typeof n?.text=="string"?e&&KC(n.text)?"":Pe(n.text):n?.type==="input_image"&&typeof n.image_url=="string"&&n.image_url.startsWith("data:")?``:"").filter(Boolean).join(`
|
|
320
|
+
`):""}function HC(t){return typeof t=="string"?Pe(t):rr(t,!1)}function zC(t,e){let n=e??"",r=iO(n);if(!r.length)return{name:t,input:{script:n}};let s=r.map(i=>zu(i.fn)&&_s(i.arg)?tO(String(i.arg.cmd??i.arg.command??"")):void 0);if(s.every(i=>i!==void 0))return{name:"read",input:My(s.flat().map(i=>["path",i])),pending:{kind:"read"}};if(r.length===1){let{fn:i,arg:o}=r[0];if(i==="apply_patch"&&typeof o=="string"){let{files:a,diff:l}=Dy(o);return{name:i,input:new Set(a).size===1?{path:a[0],patch:l}:{patch:l},pending:{kind:"patch",digest:GC(l)}}}return _s(o)?zu(i)?{name:t,input:VC(o)}:{name:i,input:o}:typeof o=="string"?{name:i,input:{arg:o}}:{name:t,input:{script:n}}}return{name:t,input:My(r.map(({fn:i,arg:o})=>i==="apply_patch"&&typeof o=="string"?["patch",Dy(o).diff]:zu(i)&&_s(o)?["command",o.cmd??o.command]:[i,o]))}}function VC(t){let e=Object.fromEntries(Object.entries(t).filter(([r])=>r!=="cmd"&&r!=="command"&&!YC.has(r))),n=t.command??t.cmd;return n===void 0?e:{command:n,...e}}function My(t){let e={};for(let[n,r]of t){let s=n;for(let i=2;s in e;i++)s=`${n} (${i})`;e[s]=r}return e}function GC(t){let e=0,n=0;for(let r of t.split(`
|
|
321
|
+
`))r.startsWith("+")&&!r.startsWith("+++")?e++:r.startsWith("-")&&!r.startsWith("---")&&n++;return`+${e} \u2212${n}`}function tO(t){let e=rO(t),n=e.map(nO);return e.length&&n.every(r=>r!==void 0)?n:void 0}function nO(t){let[e,...n]=t.split("|");if(!n.every(i=>eO.test(i.trim())))return;let r=sO(e);if(!XC.test(r[0]??""))return;let s=[];for(let i=1;i<r.length;i++){let o=r[i];if(QC.test(o)){i+1<r.length&&s.push(r[++i]);continue}if(ZC.test(o)){i++;continue}o.startsWith("-")||/^\d+(,\d+)?p?$/.test(o)||s.push(o)}return s.length===1?s[0]:void 0}function rO(t){let e=[],n=0;for(let r=0;r<t.length;r++){let s=t[r];if(s==='"'||s==="'"){let o=t.indexOf(s,r+1);if(o<0)break;r=o;continue}let i=t.slice(r,r+2);(s===";"||s===`
|
|
322
|
+
`||i==="&&"||i==="||")&&(e.push(t.slice(n,r)),(i==="&&"||i==="||")&&r++,n=r+1)}return e.push(t.slice(n)),e.map(r=>r.trim()).filter(Boolean)}function sO(t){return(t.match(/'[^']*'|"[^"]*"|\S+/g)??[]).map(e=>/^(['"])(.*)\1$/.exec(e)?.[2]??e)}function iO(t){let e=[],n=/tools\.([A-Za-z_$][\w$]*)\s*\(/g;for(let r=n.exec(t);r;r=n.exec(t)){let s=r.index+r[0].length-1,i=Jy(t,s);if(i<0)break;e.push({fn:r[1],arg:qy(t.slice(s+1,i).trim(),t)}),n.lastIndex=i+1}return e}function qy(t,e){let n=t[0];if(n==='"'||n==="'"||n==="`")return Wo(t,0)===t.length-1?Wy(t.slice(1,-1)):t;if(n==="{"){for(let r of[t,aO(t)])try{let s=JSON.parse(r);if(_s(s))return s}catch{}return t}if(/^[A-Za-z_$][\w$]*$/.test(t)){let r=new RegExp(`\\b(?:const|let|var)\\s+${t.replace(/\$/g,"\\$")}\\s*=\\s*`).exec(e);if(r){let s=r.index+r[0].length,i=e[s],o=i==='"'||i==="'"||i==="`"?Wo(e,s):i==="{"?Jy(e,s):-1;if(o>s)return qy(e.slice(s,o+1),"")}}return t}function Jy(t,e){let n=0;for(let r=e;r<t.length;r++){let s=t[r];if(s==='"'||s==="'"||s==="`"){if(r=Wo(t,r),r<0)return-1}else if(s==="("||s==="["||s==="{")n++;else if((s===")"||s==="]"||s==="}")&&--n===0)return r}return-1}function Wo(t,e){let n=t[e];for(let r=e+1;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===n)return r;return-1}function Wy(t){return t.replace(/\\(?:u\{([0-9a-fA-F]+)\}|u([0-9a-fA-F]{4})|x([0-9a-fA-F]{2})|([\s\S]))/g,(e,n,r,s,i)=>n||r||s?String.fromCodePoint(parseInt(n||r||s,16)):oO[i]??i)}function aO(t){let e=/[A-Za-z_$][\w$]*(?=\s*:)/y,n=/,(?=\s*[}\]])/y,r="",s="";for(let i=0;i<t.length;i++){let o=t[i];if(o==='"'||o==="'"||o==="`"){let l=Wo(t,i);if(l<0)return t;r+=JSON.stringify(Wy(t.slice(i+1,l))),i=l,s=o;continue}e.lastIndex=i;let a=s==="{"||s===","?e.exec(t):null;if(a){r+=`"${a[0]}"`,i+=a[0].length-1,s='"';continue}n.lastIndex=i,!n.test(t)&&(r+=o,/\s/.test(o)||(s=o))}return r}function Dy(t){let e=[],n=[],r=!1;for(let s of t.split(/\r?\n/)){let i=/^\*\*\* (Update|Add|Delete) File: (.+)$/.exec(s);if(i){let o=i[2].trim();e.push(o),n.push(`--- ${i[1]==="Add"?"/dev/null":`a/${o}`}`,`+++ ${i[1]==="Delete"?"/dev/null":`b/${o}`}`),r=!0;continue}if(!/^\*\*\* (Begin|End) Patch$/.test(s)){if(s.startsWith("*** Move to:")){n.push(s);continue}r&&!s.startsWith("@@")&&n.push("@@"),r=!1,n.push(s)}}return r&&n.push("@@"),{files:e,diff:n.join(`
|
|
323
|
+
`)}}function lO(t,e){let n=/^Script (completed|failed|running with cell ID (\d+))\nWall time [^\n]*\nOutput:\n([\s\S]*)$/.exec(t);if(!n)return{content:t,isError:!1,digest:De(t)};let r=n[3].replace(/^\n+/,"").replace(/^Script error:\n/,""),s=n[1]==="failed",i=cO(r),o=i?.exit_code;return i&&(r=i.output,i.exit_code&&(s=!0)),n[2]?{content:r,isError:s,digest:`running (cell ${n[2]})`}:e?.kind==="read"&&!s?{content:r,isError:s,digest:Ee(uO(r),"line")}:e?.kind==="patch"&&!s?{content:e.digest,isError:s,digest:e.digest}:{content:r,isError:s,digest:De(r),exit:o}}function cO(t){if(t.startsWith("{"))try{let e=JSON.parse(t);if(_s(e)&&typeof e.output=="string")return{output:e.output,exit_code:typeof e.exit_code=="number"?e.exit_code:void 0}}catch{}}function dO(t){if(typeof t=="string"&&t)try{let e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e))return e}catch{}return{arguments:t??""}}function pO(t){let e,n,r;for(let s of fO){let i=No(t,s);if(i===void 0)return{};let o=i.text.split(`
|
|
324
|
+
`);i.partial&&o.shift();let a;for(let l=o.length-1;l>=0;l--){if(!o[l].trim())continue;let c;try{c=JSON.parse(o[l])}catch{continue}if(a===void 0){let u=Date.parse(c.timestamp??"");Number.isNaN(u)||(a=u)}if(e===void 0&&c.type==="event_msg"){let u=c.payload?.type;u==="task_started"?e=!0:(u==="task_complete"||u==="turn_aborted")&&(e=!1)}if(n===void 0&&c.type==="event_msg"&&c.payload?.type==="token_count"&&c.payload.info?.last_token_usage){let u=Ky(c.payload.info.last_token_usage);n=u.in+u.out+u.cached+u.cacheCreate}if(r===void 0&&c.type==="turn_context"&&(r={model:c.payload?.model,effort:c.payload?.effort}),a!==void 0&&e!==void 0&&n!==void 0&&r!==void 0)break}if(a!==void 0)return{ms:a,running:e??!0,tokens:n,turn:r};if(!i.partial)break}return{running:e??!0,tokens:n,turn:r}}function Ky(t){return{in:Math.max(0,(t.input_tokens??0)-(t.cached_input_tokens??0)),out:t.output_tokens??0,cached:t.cached_input_tokens??0,cacheCreate:t.cache_write_input_tokens??0}}function jy(t){let n=tr(t,65536);if(n===void 0)return;let r=n.text.indexOf(`
|
|
325
|
+
`);if(r<0)return n.bytes>=65536?{cwd:"",subagent:!1}:void 0;try{let s=JSON.parse(n.text.slice(0,r)),i=s?.type==="session_meta"?s.payload:void 0;if(typeof i?.cwd!="string")return{cwd:"",subagent:!1};let o=typeof i.source=="object"?i.source?.subagent:void 0,a=hO(i,o),l=Uy(n.text,r),c=a&&!l&&n.bytes>=65536?tr(t,Fy):void 0,u=l??(c&&Uy(c.text,r)),d=!!a&&!u&&(c??n).bytes<(c?Fy:65536);return{cwd:i.cwd,subagent:!!o,id:i.id,spawn:a,turn:u,modelPending:d}}catch{return{cwd:"",subagent:!1}}}function hO(t,e){let n=e?.thread_spawn;if(!n)return;let r=n.parent_thread_id??t.parent_thread_id;if(!(!t.id||!r))return{id:t.id,parent:r,path:n.agent_path??"",role:n.agent_role??void 0,depth:n.depth??1}}function Uy(t,e){for(let n of t.slice(e+1).split(`
|
|
326
|
+
`))if(n.trim())try{let r=JSON.parse(n);if(r.type==="turn_context"&&typeof r.payload?.model=="string")return{model:r.payload.model,effort:r.payload.effort}}catch{}}var WC,_s,zu,YC,XC,QC,ZC,eO,oO,uO,Jo,By,Yu,sr,fO,Fy,Vu=S(()=>{"use strict";Cs();Do();Mo();$y();WC=["<permissions instructions>","<apps_instructions>","<plugins_instructions>","<skills_instructions>","<recommended_plugins>","<environment_context>","<node_repl_review_evidence>","# AGENTS.md instructions for "];_s=t=>!!t&&typeof t=="object"&&!Array.isArray(t),zu=t=>t==="shell_command"||t==="exec_command",YC=new Set(["max_output_tokens","yield_time_ms","timeout_ms"]);XC=/^(Get-Content|gc|cat|type|nl|bat|sed|head|tail)$/i,QC=/^-(Path|LiteralPath)$/i,ZC=/^-(Encoding|TotalCount|Head|Tail|ReadCount|Delimiter)$/i,eO=/^(sed -n|head|tail|Select-Object|select)(\s|$)/i;oO={n:`
|
|
327
|
+
`,t:" ",r:"\r",b:"\b",f:"\f",v:"\v",0:"\0"};uO=t=>t?t.replace(/\r?\n$/,"").split(`
|
|
328
|
+
`).length:0;Jo=t=>{let e=JC(t);return process.platform==="win32"?e.toLowerCase():e},By=12e4,Yu=t=>t.slice(-36),sr=class t extends Ft{constructor(n=Hu(Ly(),".codex","sessions")){super();this.root=n}displayName="Codex Mirror";#t=0;#o;#e=!1;#s;#u=0;#n=new Map;#c=new Map;#a=new Map;#d=new Map;detectsSelf(){return!!process.env.CODEX_THREAD_ID}forRead(){return new t(this.root)}callerSessionId(n){let r=process.env.CODEX_THREAD_ID;return r?this.listSessionFiles(n).find(s=>s.sessionId.endsWith(r))?.sessionId:void 0}async wakeRoute(n){try{return(await Ku()).includes(Yu(n))?{hosted:!0}:{hosted:!1,error:"this Codex session is not hosted by the shared app server, so nothing can wake it"}}catch(r){return{error:r instanceof Error?r.message:String(r)}}}async wake(n,r,s){if(!(await Ku()).includes(Yu(n)))throw new Error("the Codex session is not loaded by its app server now");await Iy(Yu(n),r,s)}detectsInstalled(){return qC(Hu(Ly(),".codex"))}sessionsDir(n){return this.root}listSessionFiles(n){let r=Jo(n),s=[];for(let i of this.#f()){let o=0,a=0;try{let u=qo(i);if(!u.isFile())continue;o=u.size,a=u.mtimeMs}catch{continue}let l=this.#n.get(i);if(l===void 0){if(l=jy(i),l===void 0)continue;this.#n.set(i,l)}if(l.subagent||Jo(l.cwd)!==r)continue;let c=Ny(i,".jsonl");this.#a.set(c,i),s.push({sessionId:c,file:i,mtime:this.#r(i,o,a)})}return s}listChildren(n,r){let s=Jo(n),i=new Map,o;for(let c of this.#f()){let u=0,d=0,f;try{let v=qo(c);if(!v.isFile())continue;u=v.size,d=v.mtimeMs,f=v.birthtimeMs||void 0}catch{continue}let p=this.#n.get(c);if(p===void 0||p.modelPending){if(p=jy(c),p===void 0)continue;this.#n.set(c,p)}if(Ny(c,".jsonl")===r&&(o=p.id),!p.spawn||Jo(p.cwd)!==s)continue;let{running:h,tokens:m,turn:g}=this.#i(c,u,d);i.set(p.spawn.id,{file:c,mtime:this.#r(c,u,d),started:f,running:h,tokens:m,spawn:p.spawn,turn:g??p.turn})}if(!o)return[];let a=(c,u=new Set)=>{if(c.parent===o)return!0;if(u.has(c.id))return!1;u.add(c.id);let d=i.get(c.parent);return d?a(d.spawn,u):!1},l=[];for(let{file:c,mtime:u,started:d,running:f,tokens:p,spawn:h,turn:m}of i.values())a(h)&&l.push({id:h.id,file:c,mtime:u,started:d,tokens:p,label:h.path.split("/").filter(Boolean).pop()??h.path,kind:h.role||void 0,model:m?.model,effort:m?.effort,parentId:i.has(h.parent)?h.parent:void 0,depth:h.depth,stopped:!1,running:f});return l}sessionsWorking(n){let r=new Set,s=Date.now();for(let{sessionId:i,file:o,mtime:a}of this.listSessionFiles(n)){if(s-a>=By)continue;let l;try{let c=qo(o);l=this.#i(o,c.size,c.mtimeMs)}catch{continue}l.running&&r.add(i)}return r}#r(n,r,s){return Math.max(s,this.#i(n,r,s).ms??0)}#i(n,r,s){let i=this.#c.get(n);if(i&&i.size===r&&i.mtime===s)return i;let o=pO(n),a={size:r,mtime:s,...o,turn:o.turn??i?.turn};return this.#c.set(n,a),a}#f(){let n=[],r=s=>{try{return UC(s).map(i=>Hu(s,i))}catch{return[]}};for(let s of r(this.root))for(let i of r(s))for(let o of r(i))for(let a of r(o))a.endsWith(".jsonl")&&n.push(a);return n}parseEntry(n){let r;try{r=JSON.parse(n)}catch{return null}return!r||typeof r.type!="string"?null:r}idOf(n){return n.ord===void 0&&(this.#l(n),n.ord=String(this.#t++),n.parent=this.#o,this.#o=n.ord),n.ord}#l(n){let r=n.payload;if(n.type==="session_meta"){if(++this.#u===1){let s=typeof r?.source=="object"?r.source?.subagent?.thread_spawn:void 0;this.#s=s?.agent_path,this.#e=!!s}}else this.#u=0,this.#e&&r?.type==="agent_message"&&r.recipient===this.#s&&(this.#e=!1);n.inherited=this.#e}parentOf(n){return n.parent}timestampOf(n){return n.timestamp}isSidechain(n,r){return r==="child"&&!!n.inherited}isLeafType(n){return!0}isRecoveryNoise(n){return!1}apply(n,r){let s=[],i=n.payload;if(!i)return{events:s};let o=()=>{let a=Date.parse(n.timestamp??"");return!isNaN(a)&&a>=r};if(n.type==="response_item"){if(i.type==="message"){if(i.role==="user"){let a=rr(i.content,!0).trim();a&&s.push({type:"user",text:a})}else if(i.role==="assistant"){let a=rr(i.content,!1);a&&s.push({type:"assistant",text:a,thinking:"",tools:[],live:o()})}return{events:s}}if(i.type==="reasoning"){let a=rr(i.summary,!1);return a&&s.push({type:"assistant",text:"",thinking:a,tools:[],live:o()}),{events:s}}if(i.type==="custom_tool_call"||i.type==="function_call"){let a=i.call_id??"",{pending:l,...c}=i.type==="custom_tool_call"?zC(i.name??"",i.input):{name:i.name??"",input:dO(i.arguments)};return l&&this.#d.set(a,l),s.push({type:"assistant",text:"",thinking:"",tools:[{id:a,...c}],live:o()}),{events:s}}if(i.type==="custom_tool_call_output"||i.type==="function_call_output"){let a=i.call_id??"",l=this.#d.get(a);return this.#d.delete(a),s.push({type:"tool_result",id:a,...lO(HC(i.output),l)}),{events:s}}return{events:s}}if(n.type==="event_msg"){if(i.type==="token_count"){let a=i.info?.last_token_usage;return a?{events:s,usage:Ky(a)}:{events:s}}return i.type==="task_complete"&&s.push({type:"turn_end"}),{events:s}}return n.type==="turn_context"?{events:s,model:i.model}:{events:s}}chainWorking(n){let r=!1;for(let s of n){if(s.type!=="event_msg")continue;let i=s.payload?.type;i==="task_started"?r=!0:(i==="task_complete"||i==="turn_aborted")&&(r=!1)}return r}sessionAlive(n){let r=this.#a.get(n);if(!r)return;let s;try{let i=qo(r);s=this.#r(r,i.size,i.mtimeMs)}catch{return}return Date.now()-s<By}readPreview(n){for(let r of(tr(n,256*1024)?.text??"").split(`
|
|
329
|
+
`))if(!(!r.includes('"user_message"')&&!r.includes('"UserMessage"')))try{let s=JSON.parse(r);if(s?.type!=="event_msg")continue;let i=s.payload,a=((i?.type==="user_message"?i.message:i?.type==="item_completed"&&i.item?.type==="UserMessage"?rr(i.item.content,!0):void 0)??"").replace(/\s+/g," ").trim();if(a)return a.slice(0,200)}catch{}return""}searchText(n){if(n?.type!=="response_item"||n.payload?.type!=="message")return"";let r=n.payload.role;return r!=="user"&&r!=="assistant"?"":rr(n.payload.content,r==="user").replace(/\s+/g," ").trim()}},fO=[64*1024,1024*1024];Fy=512*1024});import{realpathSync as mO}from"fs";import{createHash as gO}from"crypto";import{join as Ko,resolve as yO}from"path";import{homedir as bO}from"os";function Ge(){let t=process.env.TYPEBULB_SERVERS_DIR;return t?Ko(t,".."):Ko(bO(),".typebulb")}function ht(){Hy||(Hy=!0,console.error(`${Ge()} not writable \u2014 continuing stateless: ports won't stick, caches stay cold, and typebulb logs/wait/send/stop may not see this run`))}function mt(){return process.env.TYPEBULB_SERVERS_DIR||Ko(Ge(),"servers")}function zy(t){let e=oe(t),n=e.slice(e.lastIndexOf("/")+1).replace(/\.bulb\.md$/,"");return Ko(Ge(),"canvas",`${n}-${Rs(t)}.png`)}function Rs(t){return gO("sha1").update(oe(t)).digest("hex").slice(0,8)}function oe(t){let e=yO(t),n=e;try{n=mO.native(e)}catch{}return(process.platform==="win32"?n.toLowerCase():n).replace(/\\/g,"/")}function Yy(t,e){let n=oe(t),r=oe(e);return n.startsWith(r.endsWith("/")?r:r+"/")?!n.includes("/node_modules/"):!1}var Hy,Be=S(()=>{"use strict";Hy=!1});import*as Xy from"net";import{mkdir as wO,readFile as vO,writeFile as Qy}from"fs/promises";import{existsSync as SO}from"fs";import{join as Zy}from"path";function nb(){return Zy(Ge(),"blocks")}function Gu(t){return Zy(nb(),`${t}.json`)}function zo(t){return new Promise(e=>{let n=Xy.createServer();n.once("error",()=>e(!1)),n.listen(t,"127.0.0.1",()=>n.close(()=>e(!0)))})}async function AO(t){for(let e=t;e<65535;e++)if(await zo(e))return e;throw new Error(`No free port found above ${t}`)}async function Xu(t){let{listBulbServers:e}=await Promise.resolve().then(()=>(je(),rb)),n=(await e()).find(s=>s.port===t),r=n?` (pid ${n.pid}, ${n.agent?`agent:${n.agent}`:n.file})`:"";console.error(`port ${t} in use${r}`),process.exit(1)}async function Yo(t){try{let e=JSON.parse(await vO(Gu(t),"utf8"));return e&&typeof e.cwd=="string"?{cwd:e.cwd,slots:e.slots??{},mirrors:e.mirrors??{}}:void 0}catch{return}}async function Vo(t,e){try{return await Qy(Gu(t),JSON.stringify(e,null,2)),!0}catch{return ht(),!1}}async function TO(t){let e=oe(t);try{await wO(nb(),{recursive:!0})}catch{return}let n=[];for(let o=0;o<tb;o++)n.push(eb+o*pn);let r=await Promise.all(n.map(async o=>({base:o,block:await Yo(o)})));for(let{base:o,block:a}of r)if(a?.cwd===e)return o;let s={cwd:e,slots:{},mirrors:{}};for(let{base:o,block:a}of r){if(!a)try{return await Qy(Gu(o),JSON.stringify(s,null,2),{flag:"wx"}),o}catch(l){if((await Yo(o))?.cwd===e)return o;l.code!=="EEXIST"&&ht();continue}if(!SO(a.cwd))return await Vo(o,s)?o:void 0}let i=r.filter(o=>!!o.block).sort((o,a)=>Vy(o.block)-Vy(a.block))[0];if(i)return await Vo(i.base,s)?i.base:void 0}function Vy(t){return Object.values(t.slots).reduce((e,n)=>Math.max(e,n.usedAt??0),0)}async function CO(t,e){let n=await Yo(t)??{cwd:"",slots:{},mirrors:{}};if(e.kind==="mirror"){let i=n.mirrors[e.agent];if(i!==void 0)return i;let o=Gy(n),a=o.has(0)?xO:0;for(;a>Ho&&o.has(a);)a--;return n.mirrors[e.agent]=a,await Vo(t,n),a}let r=oe(e.file),s=n.slots[r]?.offset;if(s===void 0){let i=Gy(n);for(s=Ho;s<pn&&i.has(s);)s++;if(s>=pn){let o=Object.entries(n.slots).sort((a,l)=>(a[1].usedAt??0)-(l[1].usedAt??0))[0];s=o?o[1].offset:Ho,o&&delete n.slots[o[0]]}}return n.slots[r]={offset:s,usedAt:Date.now()},await Vo(t,n),s}function Gy(t){return new Set([...Object.values(t.mirrors),...Object.values(t.slots).map(e=>e.offset)])}async function ir(t,e){let n=await TO(e);return n===void 0?void 0:n+await CO(n,t)}async function hn(t){let e=oe(t);for(let n=0;n<tb;n++){let r=await Yo(eb+n*pn);if(r?.cwd===e)return s=>r.slots[oe(s)]?.usedAt??0}return()=>0}async function Go(t){if(t.explicit!==void 0)return await zo(t.explicit)||await Xu(t.explicit),t.target.kind==="bulb"&&await ir(t.target,t.cwd),{port:t.explicit};let e=await ir(t.target,t.cwd);if(e!==void 0){let r=e-e%pn,s=Date.now()+EO;do{if(await zo(e))return{port:e};await new Promise(i=>setTimeout(i,150))}while(Date.now()<s);for(let i=Ho;i<pn;i++){let o=r+i;if(o!==e&&await zo(o))return{port:o,note:`(slot ${e} was busy)`}}}return{port:await AO(kO),note:e===void 0?"(no port block available)":"(this project's block was full)"}}var eb,pn,tb,kO,Ho,xO,EO,mn=S(()=>{"use strict";Be();eb=20100,pn=100,tb=19,kO=23e3,Ho=1,xO=pn-1,EO=3e3});var Ae,Xo=S(()=>{"use strict";Ae="0.62.1"});var rb={};Ai(rb,{agentViewerCommand:()=>pb,bulbServerCommand:()=>fb,clearServerLog:()=>nd,findProjectViewer:()=>ea,isAlive:()=>or,isMirror:()=>ye,isProjectBulb:()=>ad,isProjectMirror:()=>cr,launchAgentViewer:()=>Ns,launchBulbServer:()=>bn,listBulbServers:()=>G,probePageCount:()=>cd,readServerLog:()=>Xe,readWaitCursor:()=>Zo,recordDenial:()=>od,registerServer:()=>id,relayOpen:()=>ld,runMarker:()=>rd,serverLogPath:()=>lr,serversForBulb:()=>yn,sliceRunLog:()=>sd,startServerLog:()=>$s,stopBulbServer:()=>ar,stopServer:()=>gt,stopServersForBulb:()=>ta,typebulbBinPath:()=>ur,unregisterServer:()=>gn,writeWaitCursor:()=>Is});import{spawn as sb}from"child_process";import{readdir as OO,readFile as ab,writeFile as lb,unlink as Qu,mkdir as PO}from"fs/promises";import{mkdirSync as cb,writeFileSync as Qo,appendFileSync as _O,readFileSync as Zu}from"fs";import*as _e from"path";import{fileURLToPath as RO}from"url";function ed(t){return _e.join(mt(),`${t}.json`)}function lr(t){return _e.join(mt(),`${t}.log`)}function td(t){return _e.join(mt(),`${t}.wait.json`)}function ub(t){try{let e=JSON.parse(Zu(td(t),"utf8"));return e.cursors&&typeof e.cursors=="object"?e.cursors:{}}catch{return{}}}function Zo(t,e=""){let n=ub(t)[e];return typeof n=="number"&&Number.isFinite(n)&&n>=0?n:void 0}function Is(t,e,n=""){try{cb(mt(),{recursive:!0});let r=ub(t);r[n]=e,Qo(td(t),JSON.stringify({cursors:r}))}catch{}}function $s(t){let e=lr(t);try{cb(mt(),{recursive:!0}),Qo(e,"")}catch{return()=>{}}let n=process.stdout.write.bind(process.stdout),r=process.stderr.write.bind(process.stderr),s=0,i=!1,o=a=>{if(!i)try{let l=typeof a=="string"?Buffer.from(a,"utf8"):Buffer.from(a);if(_O(e,l),s+=l.length,s>2*ib){let c=Zu(e),u=c.subarray(Math.max(0,c.length-ib));Qo(e,u),s=u.length}}catch{i=!0}};return process.stdout.write=((a,...l)=>(o(a),n(a,...l))),process.stderr.write=((a,...l)=>(o(a),r(a,...l))),()=>{process.stdout.write=n,process.stderr.write=r}}function nd(t){try{Qo(lr(t),"")}catch{}}function Xe(t,e=0){try{let n=Zu(lr(t)),r=e>=0&&e<=n.length?e:0;return{text:n.subarray(r).toString("utf8"),offset:n.length}}catch{return{text:"",offset:0}}}function rd(t){return`\u2500\u2500 run ${t} \u2500\u2500 ${new Date().toTimeString().slice(0,8)}`}function $O(t){let e=IO.exec(t);return e?Number(e[1]):void 0}function sd(t,e){let n=t.split(`
|
|
330
|
+
`),r=[];if(n.forEach((o,a)=>{let l=$O(o);l!==void 0&&r.push({id:l,idx:a})}),!r.length)return e==="latest"?t:"";let s=e==="latest"?r[r.length-1]:r.find(o=>o.id===e);if(!s)return"";let i=r.find(o=>o.idx>s.idx);return n.slice(s.idx,i?i.idx:n.length).join(`
|
|
331
|
+
`)}function or(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}async function id(t){try{await PO(mt(),{recursive:!0}),await lb(ed(t.pid),JSON.stringify({version:Ae,...t}))}catch{ht()}}async function od(t,e){let n=ed(t);try{let r=JSON.parse(await ab(n,"utf8"));if(r.denied===e)return;r.denied=e,await lb(n,JSON.stringify(r))}catch{}}async function gn(t){await Qu(ed(t)).catch(()=>{}),await Qu(lr(t)).catch(()=>{}),await Qu(td(t)).catch(()=>{})}function ye(t){return t.agent!=null}function cr(t,e){return ye(t)&&t.cwd!=null&&oe(t.cwd)===oe(e)}function ad(t,e){return!ye(t)&&Yy(t.file,e)}async function G(t){let e;try{e=await OO(mt())}catch{return[]}let n=[];return await Promise.all(e.map(async s=>{if(!/^\d+\.json$/.test(s))return;let i=parseInt(s,10),o;try{o=JSON.parse(await ab(_e.join(mt(),s),"utf8"))}catch{await gn(i);return}o&&typeof o.pid=="number"&&or(o.pid)?n.push(o):await gn(i)})),(t?n.filter(s=>ad(s,t)):n).sort((s,i)=>s.startedAt-i.startedAt)}async function ea(t,e){return(await G()).find(n=>cr(n,t)&&(e?n.agent===e:!0))}async function ld(t,e){let n=new URL(t).port,r=(await G()).filter(a=>String(a.port)!==n),s=r.filter(a=>cr(a,e)),i=r.filter(a=>ad(a,e)),o=0;for(let a of[...s,...i])try{let l=await fetch(`${a.url}/__open`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:t}),signal:AbortSignal.timeout(2e3)});if(!l.ok)continue;let{opened:c,pages:u}=await l.json();if(c)return{where:"editor",via:a.agent?"the agent mirror":`${_e.basename(a.file)}'s page`};ye(a)&&(o+=u??0)}catch{}return o>0?{where:"external"}:void 0}async function ar(t){try{process.kill(t,"SIGTERM")}catch{}await gn(t)}async function cd(t){try{let e=await fetch(`${t.url}/__pages`,{signal:AbortSignal.timeout(NO)});if(!e.ok)return;let{pages:n}=await e.json();return typeof n=="number"?n:void 0}catch{return}}async function gt(t,e=ye(t)?"keep":"close"){try{let n=await fetch(`${t.url}/__stop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pages:e}),signal:AbortSignal.timeout(ob)});if(!n.ok)throw new Error(`/__stop ${n.status}`);let{closed:r=0,stuck:s=0}=await n.json(),i=Date.now()+ob;for(;or(t.pid)&&Date.now()<i;)await db(100);return or(t.pid)?(await ar(t.pid),"killed"):(await gn(t.pid),{closed:r,stuck:s})}catch{return await ar(t.pid),"killed"}}function yn(t,e){let n=oe(e);return t.filter(r=>!ye(r)&&r.pid!==process.pid&&oe(r.file)===n)}async function ta(t,e){let n=yn(await G(),t);for(let r of n)await gt(r,e!==void 0&&r.port===e?"keep":"close");return n}function LO(t,e,n){(process.platform==="win32"?sb("cmd",["/c","start","","/b",t,...e],{cwd:n,stdio:"ignore",windowsHide:!0}):sb(t,e,{cwd:n,detached:!0,stdio:"ignore"})).unref()}function ur(){return _e.join(_e.dirname(RO(import.meta.url)),"index.js")}function fb(t,e={}){return{command:process.execPath,args:[ur(),...e.trust?["--trust"]:[],...e.noTrust?["--no-trust"]:[],...e.mode?["--mode",e.mode]:[],...e.watch===!1?["--no-watch"]:[],...e.replace?["--replace",e.replace]:[],t,...e.open===!1?["--no-open"]:[]]}}function pb(t){return{command:process.execPath,args:[ur(),`agent:${t}`,"--no-open"]}}async function hb(t,e,n,r){let s=await t();if(s)return s;LO(e.command,e.args,n);let i=Date.now()+2e4;for(;Date.now()<i;){await db(150);let o=await t();if(o)return o}throw new Error(`Launched ${r} but it did not register within 20s.`)}async function bn(t,e={}){let n=e.cwd??process.cwd(),r=_e.resolve(n,t),s=await ir({kind:"bulb",file:r},n),[i]=await ta(r,s),o={...e,mode:e.mode??i?.mode};return hb(async()=>yn(await G(),r)[0],fb(t,o),n,_e.basename(t))}async function Ns(t,e=process.cwd()){return hb(()=>ea(e,t),pb(t),e,`the ${t} mirror`)}var ib,IO,ob,NO,db,je=S(()=>{"use strict";Be();mn();Xo();ib=1e6;IO=/^── run (\d+) ── /;ob=6e3,NO=500;db=t=>new Promise(e=>setTimeout(e,t))});function dr(t){return{...Bp(t),server:t.files.get("server.ts")??""}}function na(t){return!!t.server&&!t.code}var Ls=S(()=>{"use strict";Z();Z()});function ra(t){let e=/^---[^\n]*\n([\s\S]*?)\n---/.exec(t),n=e?/^\s*name:\s*(.+?)\s*$/m.exec(e[1]):null;return n?n[1].replace(/^["']|["']$/g,""):void 0}function ud(t){return Zn(ra(t)??"bulb")||"bulb"}var dd=S(()=>{"use strict";Z()});import{readdirSync as MO,readFileSync as DO,statSync as BO}from"fs";import{join as mb,basename as jO}from"path";function yb(t,e,n){if(e>8)return n;let r;try{r=MO(t,{withFileTypes:!0})}catch{return n}for(let s of r)if(s.isDirectory()){if(s.name.startsWith(".")||s.name==="node_modules")continue;yb(mb(t,s.name),e+1,n)}else s.isFile()&&s.name.endsWith(".bulb.md")&&n.push(mb(t,s.name));return n}function FO(t,e){let n,r=!1;try{let s=DO(t,"utf8");n=ra(s.slice(0,1024));let i=ze(s);r=!!i&&na(dr(i))}catch{}return{mtime:e,name:n??jO(t).replace(/\.bulb\.md$/,""),serverOnly:r}}function sa(t){let e=new Map,n=yb(t,0,[]).map(r=>{let s=0;try{s=BO(r).mtimeMs}catch{}let i=s?gb.get(r):void 0,o=i?.mtime===s?i:FO(r,s);return s&&e.set(r,o),{path:r,...o}});return gb=e,n}var gb,bb=S(()=>{"use strict";Z();Ls();dd();gb=new Map});function fr(t){if(t.server.trim())return"server-side code (server.ts)";let e=t.code;if(/\btb\s*\.\s*fs\b/.test(e)||e.includes("/__fs"))return"the filesystem";if(/\btb\s*\.\s*ai\b/.test(e)||e.includes("/__ai")||t.infer.trim()||/\btb\s*\.\s*infer\b/.test(e))return"AI (your API keys)";if(/\btb\s*\.\s*server\s*\.\s*\w/.test(e)||e.includes("/__api"))return"server-side code (server.ts)"}var ia=S(()=>{"use strict"});import{readFile as UO}from"fs/promises";async function fd(t){try{let e=ze(await UO(t,"utf-8"));return e?fr(dr(e)):void 0}catch{return}}var wb=S(()=>{"use strict";Ls();ia()});function pd(t){let e=t.split(""),n=(i,o)=>{for(let a=i;a<o&&a<e.length;a++)e[a]!==`
|
|
321
332
|
`&&(e[a]=" ")},r=0,s="";for(;r<t.length;){let i=t[r],o=t[r+1];if(i==="/"&&o==="/"){let a=r;for(;a<t.length&&t[a]!==`
|
|
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==="/"&&
|
|
333
|
+
`;)a++;n(r,a),r=a}else if(i==="/"&&o==="*"){let a=r+2;for(;a<t.length&&!(t[a]==="*"&&t[a+1]==="/");)a++;n(r,Math.min(a+2,t.length)),r=a+2}else if(i==="/"&&qO.has(s)){let a=r+1,l=!1;for(;a<t.length&&t[a]!==`
|
|
323
334
|
`;){let c=t[a];if(c==="\\")a++;else if(c==="[")l=!0;else if(c==="]")l=!1;else if(c==="/"&&!l)break;a++}r=a+1,s="/"}else if(i==='"'||i==="'"){let a=r+1;for(;a<t.length&&t[a]!==i&&t[a]!==`
|
|
324
|
-
`;)t[a]==="\\"&&a++,a++;r=a+1,s=i}else if(i==="`"){let a=
|
|
325
|
-
`).length-1}));return r}function
|
|
326
|
-
`),a=
|
|
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:
|
|
335
|
+
`;)t[a]==="\\"&&a++,a++;r=a+1,s=i}else if(i==="`"){let a=vb(t,r);n(r,a),r=a,s="`"}else/\s/.test(i)||(s=i),r++}return e.join("")}function vb(t,e){let n=e+1,r=0;for(;n<t.length;){let s=t[n];if(s==="\\"){n+=2;continue}if(s==="`"){if(r===0)return n+1;n=vb(t,n);continue}if(s==="$"&&t[n+1]==="{"){r++,n+=2;continue}if(s==="}"&&r>0){r--,n++;continue}n++}return t.length}var qO,Sb=S(()=>{qO=new Set(["","(",",","=",":","[","!","&","|","?",";","{"])});function KO(t){if(/^[./]/.test(t)||/^[a-z][a-z0-9+.-]*:/i.test(t))return;let e=t.split("/");return t.startsWith("@")?e.slice(0,2).join("/"):e[0]}function kb(t){let e=[];for(let s of WO)for(let i of t.matchAll(s)){let o=KO(i[1]);o&&e.push({root:o,index:i.index??0})}e.sort((s,i)=>s.index-i.index);let n=new Set,r=[];for(let{root:s,index:i}of e)n.has(s)||(n.add(s),r.push({root:s,lineIndex:t.slice(0,i).split(`
|
|
336
|
+
`).length-1}));return r}function xb(t){return kb(pd(t)).map(e=>e.root)}function Ms(t,e){if(!t)return[];let{target:n,dependencies:r}=e,s=(e.lineOffset??1)-1,i=[],o=t.split(`
|
|
337
|
+
`),a=pd(t).split(`
|
|
338
|
+
`);for(let l=0;l<o.length;l++){let c=a[l],u=l+1+s;for(let d of JO)d.targets.includes(n)&&d.pattern.test(c)&&i.push({type:d.type,severity:"error",message:YO(d.type,u),lineNumber:u,lineContent:o[l]})}return n==="client"&&r&&i.push(...HO(a,o,r,s)),i}function HO(t,e,n,r){let s=new Set(Object.keys(n));return kb(t.join(`
|
|
339
|
+
`)).filter(({root:i})=>!s.has(i)).map(({root:i,lineIndex:o})=>{let a=o+1+r;return{type:"UNDECLARED_IMPORT",severity:"error",message:zO(i,a),lineNumber:a,lineContent:e[o]}})}function zO(t,e){return`Import "${t}" is not declared in config.json dependencies! Found on line ${e}.
|
|
329
340
|
|
|
330
341
|
**CRITICAL**: Every bare import in code.tsx must be declared in the **config.json** "dependencies" block. A bulb that imports a package it doesn't declare is incomplete \u2014 it won't type-check, its versions aren't pinned, and it can't be reliably re-run or ported to typebulb.com.
|
|
331
342
|
|
|
@@ -339,7 +350,7 @@ ${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.pus
|
|
|
339
350
|
}
|
|
340
351
|
\`\`\`
|
|
341
352
|
|
|
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
|
|
353
|
+
**Fix:** Add a **config.json** block (or extend the existing one) with a "dependencies" entry for "${t}" \u2014 and for every other bare import in code.tsx. Pin a real version where you can (e.g. "react": "^19.2.7").`}function YO(t,e){return t==="URL_IMPORT"?`Direct URL imports are not supported! Found on line ${e}.
|
|
343
354
|
|
|
344
355
|
**CRITICAL**: Import packages by name only. Do NOT use CDN URLs:
|
|
345
356
|
|
|
@@ -493,22 +504,22 @@ import { something } from 'module-name'
|
|
|
493
504
|
const something = require('module-name') // NOT SUPPORTED!
|
|
494
505
|
\`\`\`
|
|
495
506
|
|
|
496
|
-
**Fix:** Replace all \`require()\` calls with ES6 \`import\` statements at the top of the file.`}var
|
|
497
|
-
`)}var
|
|
507
|
+
**Fix:** Replace all \`require()\` calls with ES6 \`import\` statements at the top of the file.`}var wn,vn,JO,WO,oa=S(()=>{Sb();wn=["client"],vn=["client","server"],JO=[{type:"DYNAMIC_IMPORT",pattern:/\bimport\s*\(\s*['"`]/,targets:wn},{type:"COMMONJS_REQUIRE",pattern:/\brequire\s*\(\s*['"`]/,targets:vn},{type:"JS_EXTENSION_IMPORT",pattern:/from\s+['"][^'"]*\/[^'"]*\.js['"]/,targets:wn},{type:"URL_IMPORT",pattern:/from\s+['"]https?:\/\//,targets:wn},{type:"VERSION_SPECIFIER_IMPORT",pattern:/from\s+['"][^'"]*@[\d^~]/,targets:wn},{type:"REDUNDANT_TB_DECLARATION",pattern:/declare\s+(const|var|let)\s+tb\b/,targets:vn},{type:"CONST_ENUM",pattern:/\bconst\s+enum\b/,targets:vn},{type:"NAMESPACE_DECLARATION",pattern:/\bnamespace\s+\w+/,targets:vn},{type:"COMMONJS_EXPORT_EQUALS",pattern:/\bexport\s*=/,targets:vn},{type:"COMMONJS_IMPORT_EQUALS",pattern:/\bimport\s+\w+\s*=/,targets:vn},{type:"MODULE_DECLARATION",pattern:/\bmodule\s+\w+\s*\{/,targets:vn},{type:"CSS_FILE_IMPORT",pattern:/(?:from|import)\s+['"][^'"]*\.css['"]/,targets:wn},{type:"NAVIGATION",pattern:/window\.(location\.(reload|assign|replace)\s*\(|open\s*\()/,targets:wn},{type:"NAVIGATION",pattern:/window\.location(\.href)?\s*=[^=]/,targets:wn}],WO=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g]});function hd(t){let e=ze(t);if(!e)return t;let n=e.files.get("code.tsx");if(!n)return t;let r=xb(n);if(!r.length)return t;let s=e.files.get("config.json"),i={};if(s)try{let c=JSON.parse(s);c&&typeof c=="object"&&(i=c)}catch{}let o=i.dependencies&&typeof i.dependencies=="object"?{...i.dependencies}:{},a=r.filter(c=>!(c in o));if(!a.length)return t;for(let c of a)o[c]="latest";i.dependencies=o;let l={name:e.frontmatter.name};for(let[c,u]of e.files){let d=Ip(c);d&&(l[d]=u)}return l.config=JSON.stringify(i,null,2),Up(l)}var Eb=S(()=>{"use strict";Z();oa()});import{spawn as Ab}from"child_process";import{basename as VO}from"path";function GO(){return process.env.TYPEBULB_EDITOR||"code"}function QO(t,e,n){return n==null?[e]:XO.test(VO(t))?["-g",`${e}:${n}`]:[`+${n}`,e]}function ZO(t,e){let n=GO();return{command:n,args:QO(n,t,e)}}function md(t,e){let{command:n,args:r}=ZO(t,e),s=process.platform==="win32"?Ab("cmd.exe",["/d","/s","/c",n,...r],{detached:!0,stdio:"ignore",windowsHide:!0}):Ab(n,r,{detached:!0,stdio:"ignore"});s.on("error",i=>console.error("[typebulb] editor launch failed:",i?.message??i)),s.unref()}var XO,Tb=S(()=>{"use strict";XO=/^(code|code-insiders|codium|vscodium|cursor|windsurf)(\.cmd|\.exe)?$/i});import{readFileSync as eP,writeFileSync as tP,mkdirSync as nP,statSync as rP}from"fs";import{join as sP}from"path";function gd(){return sP(Ge(),"trust.json")}function yd(){try{let t=gd(),e=rP(t).mtimeMs;if(Ds?.mtime!==e){let n=JSON.parse(eP(t,"utf8"));Ds={mtime:e,set:new Set(Array.isArray(n)?n:[])}}return Ds.set}catch{return Ds=void 0,new Set}}function iP(t){try{nP(Ge(),{recursive:!0}),tP(gd(),JSON.stringify([...t])),Ds=void 0}catch(e){throw new Error(`can't write ${gd()} \u2014 trust not remembered (unwritable home; sandboxed shell?): ${e.message}`)}}function Sn(t){return yd().has(oe(t))}function pr(t,e){let n=new Set(yd()),r=oe(t);(e?n.has(r):!n.has(r))||(e?n.add(r):n.delete(r),iP(n))}function bd(){return[...yd()]}var Ds,Bs=S(()=>{"use strict";Be()});function mr(t){return(t.includes("://")?t:`http://${t}`).replace(/\/+$/,"")}function wd(){return Fs}async function yt(){let[t,e]=await Promise.all([Ob(),fP()]);return dP([...pP(e),...t],process.env.TB_AI_PROVIDER,process.env.TB_AI_MODEL)}function dP(t,e,n){return!e||!n?t:t.map(r=>r.provider===e&&r.name===n?{...r,default:!0}:r)}async function Cb(){let t;try{t=await fetch(oP,{signal:AbortSignal.timeout(lP)})}catch(e){Fs=`catalog fetch failed: ${e?.message??e}`;return}if(!t.ok){Fs=`catalog fetch failed: HTTP ${t.status}`;return}try{return await t.json()}catch(e){Fs=`catalog returned an unreadable body: ${e?.message??e}`;return}}async function fP(){if(js&&Date.now()-js.fetchedAt<=aP)return js.models;let t=await Cb()??await Cb();return t?(js={models:t,fetchedAt:Date.now()},Fs=void 0,t):js?.models??[]}async function Ob(){if(aa&&Date.now()-aa.fetchedAt<=cP)return aa.models;let t=mr(process.env.OLLAMA_HOST??"http://localhost:11434"),e=[];try{let n=await fetch(new URL("/api/tags",t).toString(),{signal:AbortSignal.timeout(uP)});n.ok&&(e=((await n.json()).models??[]).map(s=>s.name).filter(s=>!!s).map(s=>({provider:"ollama",name:s,friendlyName:s,providerName:"Ollama"})))}catch{}return aa={models:e,fetchedAt:Date.now()},e}function pP(t){let e=new Set(Object.entries(hr).filter(([,n])=>!!process.env[n]).map(([n])=>n));return t.filter(n=>e.has(n.provider))}function vd(){return Object.values(hr).some(t=>!!process.env[t])}async function la(){return vd()||process.env.TB_AI_BASE_URL||(await Ob()).length>0?"own":"none"}function Pb(t,e,n){let r=Math.max(...t.map(o=>o.name.length)),s=Math.max(...t.map(o=>o.friendlyName.length)),i=["Models available to tb.ai (filtered by your .env keys):",""];for(let o of t)i.push(` ${o.name.padEnd(r)} ${o.friendlyName.padEnd(s)} (${o.provider})`);return i.push("","Pass an id as the `model` in tb.ai({ provider, model })."),e&&n&&i.push(`Default (from .env): ${e} / ${n}`),i.join(`
|
|
508
|
+
`)}var hr,oP,aP,lP,cP,uP,js,aa,Fs,kn=S(()=>{"use strict";hr={anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY",gemini:"GOOGLE_API_KEY",openrouter:"OPENROUTER_API_KEY"};oP="https://api.typebulb.com/api/models",aP=1440*60*1e3,lP=5e3,cP=60*1e3,uP=1500});var _b,Rb,ot,xn=S(()=>{_b=t=>t!=null&&t>=0&&t<=4?t:void 0,Rb=(t,e)=>{let n={...t};for(let r of["input","output","reasoning","cacheRead"])e[r]!==void 0&&(n[r]=e[r]);return n},ot=t=>t===void 0||t.input===void 0&&t.output===void 0?void 0:{input:t.input??0,output:t.output??0,reasoning:t.reasoning,cacheRead:t.cacheRead}});var Re,Qe,gr=S(()=>{Re=class extends Error{constructor(e,n="unknown",r=!1){super(e),this.code=n,this.retryable=r}},Qe=class{getPath(e,n){return this.path}parseError(e,n){return this.parseJsonError(e,n)}parseStreamChunk(e){return this.checkAndThrowError(e),this.parseProviderStreamChunk(e)}extractSystemMessages(e,n=`
|
|
498
509
|
|
|
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
|
|
510
|
+
`){let r=e.filter(s=>s.role==="system").map(s=>s.content);return{system:r.length?r.join(n):void 0,conversationMessages:e.filter(s=>s.role!=="system")}}parseJsonError(e,n){if(!e)return{message:`HTTP ${n}`};try{let r=JSON.parse(e);return r.error&&typeof r.error=="object"?{message:r.error.message||`HTTP ${n}`,type:r.error.type}:r.message?{message:r.message}:{message:e}}catch{return{message:e}}}checkAndThrowError(e){if(typeof e!="object"||e===null)return;let n=e;if(n.type==="error"&&"message"in n){let r=n.code||"unknown";throw new Re(n.message,r,!!n.retryable)}if(n.error){let r=n.error,s=typeof r=="object"&&r!==null?String(r.type??r.code??""):"",i=/rate_limit|too_many_requests/i.test(s),o=/overloaded|server_error|unavailable/i.test(s),a=/context_length/i.test(s);throw new Re(this.extractErrorMessage(n.error),i?"rate_limit":a?"context_exceeded":"unknown",i||o)}}extractErrorMessage(e){if(typeof e=="string")try{let n=JSON.parse(e);return n.error?.message||n.message||e}catch{return e}return typeof e=="object"&&e!==null?e.message||JSON.stringify(e):`${this.providerName} returned an error`}}});var ca,Sd=S(()=>{xn();gr();ca=class extends Qe{constructor(){super(...arguments),this.providerName="OpenAI",this.defaultBaseUrl="https://api.openai.com",this.path="/v1/responses",this.effortMap={0:"none",1:"low",2:"medium",3:"high",4:"xhigh"}}buildHeaders(e){return{Authorization:`Bearer ${e}`,"Content-Type":"application/json",Accept:"application/json"}}buildPayload(e,n,r,s){let i=this.convertMessagesToInput(e),o={model:n,input:i,stream:s};if(r?.webSearch===!0&&(o.tools=[{type:"web_search"}]),r?.effort!==void 0){let a=this.effortMap[r.effort];o.reasoning=a==="none"?{effort:a}:{effort:a,summary:"auto"}}return r?.maxOutputTokens!==void 0&&(o.max_output_tokens=r.maxOutputTokens),o}parseNonStreamingResponse(e){if(!this.isResponsesApiResponse(e))return{text:""};let n=e.output_text||"",r;if(e.output&&Array.isArray(e.output))for(let s of e.output)s.type==="reasoning"&&s.summary&&(r=s.summary.map(i=>i.text).join(`
|
|
511
|
+
`)),!n&&s.type==="message"&&s.content&&(n=s.content.filter(i=>i.type==="output_text").map(i=>i.text).join(""));return{text:n,reasoning:r,usage:this.mapUsage(e.usage)}}parseProviderStreamChunk(e){if(this.isResponsesApiEvent(e))switch(e.type){case"response.failed":{let r=e.response?.error,s=r?.message||"Response failed",i=r?.code==="insufficient_quota"||r?.code==="rate_limit_exceeded";throw new Re(s,i?"rate_limit":"unknown",i)}case"response.output_text.delta":return{text:e.delta};case"response.reasoning_summary_text.delta":return{reasoning:e.delta};case"response.completed":{let n=this.mapUsage(e.response?.usage);return n?{usage:n}:void 0}default:return}}mapUsage(e){if(e)return ot({input:e.input_tokens,output:e.output_tokens,reasoning:e.output_tokens_details?.reasoning_tokens,cacheRead:e.input_tokens_details?.cached_tokens})}convertMessagesToInput(e){return e.map(n=>n.role==="system"?`System: ${n.content}`:n.role==="user"?`User: ${n.content}`:n.role==="assistant"?`Assistant: ${n.content}`:n.content).join(`
|
|
501
512
|
|
|
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
|
|
513
|
+
`)}isResponsesApiEvent(e){return typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string"}isResponsesApiResponse(e){return typeof e=="object"&&e!==null&&e.object==="response"}}});var yr,ua=S(()=>{xn();gr();yr=class extends Qe{parseNonStreamingResponse(e){if(!this.hasChoices(e))return{text:""};let n=e,r=n.choices[0],s=r?.message,i=s?.content??r?.text??"",o=s?.reasoning??s?.reasoning_content??n.reasoning;return{text:i,reasoning:o,usage:this.mapUsage(n.usage)}}parseProviderStreamChunk(e){if(!this.hasChoices(e))return;let n=e,r=this.mapUsage(n.usage),s=n.choices[0]?.delta||n.choices[0]?.message,i=s?.content||void 0,o=s?.reasoning||s?.reasoning_content||void 0;if(!(!i&&!o&&!r))return{text:i,reasoning:o,usage:r}}hasChoices(e){return typeof e=="object"&&e!==null&&"choices"in e&&Array.isArray(e.choices)}mapUsage(e){if(e)return ot({input:e.prompt_tokens,output:e.completion_tokens,reasoning:e.completion_tokens_details?.reasoning_tokens,cacheRead:e.prompt_tokens_details?.cached_tokens})}}});var kd,da,xd=S(()=>{ua();kd={"HTTP-Referer":"https://typebulb.com","X-OpenRouter-Title":"Typebulb"},da=class extends yr{constructor(){super(...arguments),this.providerName="OpenRouter",this.defaultBaseUrl="https://openrouter.ai",this.path="/api/v1/chat/completions",this.effortMap={0:"none",1:"low",2:"medium",3:"high",4:"xhigh"}}buildHeaders(e){return{Authorization:`Bearer ${e}`,"x-api-key":e,"Content-Type":"application/json",Accept:"application/json",...kd}}buildPayload(e,n,r,s){let i={model:n,messages:e,stream:s};s&&(i.stream_options={include_usage:!0}),r?.webSearch===!0&&(i.plugins=[{id:"web"}]);let o=r?.effort;return o!==void 0&&(i.reasoning={effort:this.effortMap[o]}),r?.maxOutputTokens!==void 0&&(i.max_tokens=r.maxOutputTokens),i}}});var fa,Ed=S(()=>{xn();gr();fa=class extends Qe{constructor(){super(...arguments),this.providerName="Anthropic",this.defaultBaseUrl="https://api.anthropic.com",this.path="/v1/messages"}buildHeaders(e){return{"x-api-key":e,"anthropic-version":"2023-06-01","Content-Type":"application/json",Accept:"application/json"}}buildPayload(e,n,r,s){let{system:i,conversationMessages:o}=this.extractSystemMessages(e),a={model:n,max_tokens:Math.min(this.getMaxTokens(n),r?.maxOutputTokens??1/0),messages:this.withTailMessagesCached(o),stream:s};r?.webSearch===!0&&(a.tools=[{type:"web_search_20250305",name:"web_search"}]),i&&(a.system=[{type:"text",text:i,cache_control:{type:"ephemeral"}}]);let l=r?.effort;if(l!==void 0){if(this.isModernModel(n))if(l===0)this.alwaysThinks(n)||(a.thinking={type:"disabled"}),a.output_config={effort:"low"};else{let c={1:"low",2:"medium",3:"high",4:"max"};a.thinking={type:"adaptive",display:"summarized"},a.output_config={effort:c[l]}}else if(l!==0){let c={1:2048,2:4096,3:8192,4:16384};a.thinking={type:"enabled",budget_tokens:c[l]}}}return a}parseNonStreamingResponse(e){if(!this.isAnthropicResponse(e))return{text:""};let n=e.content.filter(s=>s.type==="text").map(s=>s.text).join(""),r=e.content.filter(s=>s.type==="thinking").map(s=>s.thinking).join(`
|
|
503
514
|
|
|
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
|
|
515
|
+
`);return{text:n,reasoning:r||void 0,usage:ot(this.mapUsage(e.usage))}}parseProviderStreamChunk(e){if(this.isAnthropicEvent(e))switch(e.type){case"content_block_delta":return e.delta.type==="text_delta"?{text:e.delta.text||""}:e.delta.type==="thinking_delta"?{reasoning:e.delta.thinking||""}:void 0;case"message_start":{let n=this.mapUsage(e.message?.usage);return n?{usage:n}:void 0}case"message_delta":{let n=this.mapUsage(e.usage);return n?{usage:n}:void 0}default:return}}mapUsage(e){if(typeof e!="object"||e===null)return;let n=e,r=c=>typeof c=="number"?c:void 0,s=r(n.input_tokens),i=r(n.cache_read_input_tokens),o=r(n.cache_creation_input_tokens),a=r(n.output_tokens),l=s!==void 0||i!==void 0||o!==void 0?(s??0)+(i??0)+(o??0):void 0;if(!(l===void 0&&a===void 0))return{input:l,output:a,cacheRead:i}}withTailMessagesCached(e){let n=Math.max(0,e.length-2);return e.map((r,s)=>s>=n?{role:r.role,content:[{type:"text",text:r.content,cache_control:{type:"ephemeral"}}]}:r)}isAnthropicResponse(e){return typeof e=="object"&&e!==null&&e.type==="message"&&Array.isArray(e.content)}isAnthropicEvent(e){return typeof e=="object"&&e!==null&&"type"in e}isModernModel(e){let n=e.match(/^claude-[a-z]+-(\d+)(?:-(\d+))?/i);if(!n)return!1;let r=+n[1],s=n[2]?+n[2]:0;return r>4||r===4&&s>=6}alwaysThinks(e){return/^claude-(fable|mythos)\b/i.test(e)}getMaxTokens(e){return this.isModernModel(e)?64e3:32e3}}});var pa,Ad=S(()=>{xn();gr();pa=class extends Qe{constructor(){super(...arguments),this.providerName="Gemini",this.defaultBaseUrl="https://generativelanguage.googleapis.com",this.path="/v1beta/models",this.budgetMap={0:0,1:1024,2:8192,3:-1,4:-1}}getPath(e,n){return`/v1beta/models/${e}:${n?"streamGenerateContent":"generateContent"}${n?"?alt=sse":""}`}buildHeaders(e){return{"Content-Type":"application/json","x-goog-api-key":e}}buildPayload(e,n,r,s){let{system:i,conversationMessages:o}=this.extractSystemMessages(e,`
|
|
516
|
+
`),l={contents:o.map(u=>({role:u.role==="assistant"?"model":"user",parts:[{text:u.content}]}))};r?.webSearch===!0&&(l.tools=[{google_search:{}}]),i&&(l.systemInstruction={role:"system",parts:[{text:i}]});let c=r?.effort;if(c!==void 0){let u=this.geminiVersion(n),d=u!==void 0&&u>=3?{thinkingLevel:this.thinkingLevelFor(u,c)}:{thinkingBudget:this.budgetMap[c]};l.generationConfig={thinkingConfig:c===0?d:{includeThoughts:!0,...d}}}return r?.maxOutputTokens!==void 0&&(l.generationConfig={...l.generationConfig,maxOutputTokens:r.maxOutputTokens}),l}parseError(e,n){if(!e)return{message:`HTTP ${n}`};try{let r=JSON.parse(e),s=Array.isArray(r)?r[0]?.error:r?.error;return s&&typeof s=="object"?{message:(s.message||`HTTP ${n}`).split(`
|
|
517
|
+
`)[0],type:s.status,code:s.code?.toString()}:r.message?{message:r.message}:{message:e}}catch{return{message:e}}}parseNonStreamingResponse(e){if(this.checkAndThrowError(e),this.checkGeminiError(e),!this.isGeminiResponse(e))return{text:"",status:"failed",error:"Invalid response format"};let n=this.extractParts(e).text||"",r=e.candidates?.[0]?.finishReason,s="complete";return r==="MAX_TOKENS"?s="interrupted":(r==="SAFETY"||r==="RECITATION")&&(s="failed"),{text:n,status:s,usage:this.mapUsage(e.usageMetadata)}}parseProviderStreamChunk(e){if(this.checkGeminiError(e),!this.isGeminiResponse(e))return;let n=this.extractParts(e),r=this.mapUsage(e.usageMetadata);return r&&(n.usage=r),n.text||n.reasoning||n.usage?n:void 0}mapUsage(e){if(!e)return;let n=e.candidatesTokenCount!==void 0||e.thoughtsTokenCount!==void 0;return ot({input:e.promptTokenCount,output:n?(e.candidatesTokenCount??0)+(e.thoughtsTokenCount??0):void 0,reasoning:e.thoughtsTokenCount,cacheRead:e.cachedContentTokenCount})}geminiVersion(e){let n=e.match(/^gemini-(\d+(?:\.\d+)?)/);return n?Number(n[1]):void 0}thinkingLevelFor(e,n){let r=["minimal","low","medium","high","high"][n];return r==="minimal"&&e<3.5?"low":r}isGeminiResponse(e){return typeof e=="object"&&e!==null&&"candidates"in e&&Array.isArray(e.candidates)}extractParts(e){let n=e.candidates?.[0]?.content?.parts;if(!n)return{};let r="",s="";for(let i of n)i.text&&(i.thought?s+=i.text:r+=i.text);return{text:r||void 0,reasoning:s||void 0}}checkGeminiError(e){if(this.isGeminiResponse(e)&&e.promptFeedback?.blockReason){let n=e.promptFeedback.blockReason;throw new Re(`Prompt blocked: ${n}`)}}}});var ha,Td=S(()=>{ua();ha=class extends yr{constructor(){super(...arguments),this.providerName="Ollama",this.defaultBaseUrl="http://localhost:11434",this.path="/chat/completions"}buildHeaders(e){let n={"Content-Type":"application/json",Accept:"application/json"};return e&&(n.Authorization=`Bearer ${e}`),n}buildPayload(e,n,r,s){return s?{model:n,messages:e,stream:s,stream_options:{include_usage:!0}}:{model:n,messages:e,stream:s}}}});function En(t){let e=hP.get(t);if(!e)throw new Error(`Unsupported protocol: ${t}`);return e}function mP(t,e){return t.replace(/\/+$/,"")+(e.startsWith("/")?e:`/${e}`)}async function Cd(t,e){let n=En(t.protocol),r=n.getPath(t.model,e.stream),s=mP(t.baseUrl,r),i=n.buildHeaders(t.apiKey),o=n.buildPayload(e.messages,t.model,{effort:e.effort,webSearch:e.webSearch,maxOutputTokens:e.maxOutputTokens},e.stream);return fetch(s,{method:"POST",headers:i,body:JSON.stringify(o),signal:e.signal})}function gP(t){return/prompt is too long|context[_ ](length|window)|maximum context|token count exceeds|too many tokens/i.test(t)}async function br(t,e){let n=En(e),r=await t.text().catch(()=>""),{message:s}=n.parseError(r,t.status),i=t.status,o="unknown";return i===429?o="rate_limit":(i===413||gP(s))&&(o="context_exceeded"),{code:o,message:s,retryable:i===429||i>=500}}var Ib,hP,Od=S(()=>{Sd();xd();Ed();Ad();Td();Ib=new ha,hP=new Map([["openai",new ca],["openrouter",new da],["anthropic",new fa],["gemini",new pa],["ollama",Ib],["openai-compat",Ib]])});function $b(t){let e=t.indexOf(`\r
|
|
507
518
|
\r
|
|
508
519
|
`),n=t.indexOf(`
|
|
509
520
|
|
|
510
|
-
`);return e!==-1&&(n===-1||e<n)?{pos:e,len:4}:n!==-1?{pos:n,len:2}:{pos:-1,len:0}}function
|
|
511
|
-
`).trim();if(r){if(r==="[DONE]")return"done";try{return JSON.parse(r)}catch{return}}}async function*
|
|
521
|
+
`);return e!==-1&&(n===-1||e<n)?{pos:e,len:4}:n!==-1?{pos:n,len:2}:{pos:-1,len:0}}function Pd(t){let n=t.split(/\r?\n/).filter(s=>s.startsWith("data:"));if(!n.length)return;let r=n.map(s=>s.replace(/^data:\s?/,"")).join(`
|
|
522
|
+
`).trim();if(r){if(r==="[DONE]")return"done";try{return JSON.parse(r)}catch{return}}}async function*Nb(t,e,n){let r=new TextDecoder,s="",i,o=e?new Promise((a,l)=>{e.aborted&&l(new Error("Aborted")),i=()=>l(new Error("Aborted")),e.addEventListener("abort",i,{once:!0})}):void 0;o?.catch(()=>{});try{for(;;){let{done:a,value:l}=o?await Promise.race([t.read(),o]):await t.read();if(a){if(s.trim()){let d=Pd(s);d!==void 0&&d!=="done"&&(yield d)}return}n?.(),s+=r.decode(l,{stream:!0});let{pos:c,len:u}=$b(s);for(;c!==-1;){let d=s.slice(0,c);s=s.slice(c+u);let f=Pd(d);if(f==="done")return;f!==void 0&&(yield f),{pos:c,len:u}=$b(s)}}}finally{i&&e?.removeEventListener("abort",i);try{await t.cancel()}catch{}}}async function _d(t,e){return(await wr(t,e)).text}async function wr(t,e){if(!t.body)throw new Error("Response body is missing");let n="",r;for await(let s of An(t,e))s.kind==="text"?n+=s.text:s.kind==="usage"&&(r=s.usage);return{text:n,usage:r}}async function*An(t,e){let n=e??(t.headers.get("X-Provider-Protocol")||"openai"),r=En(n);if(!t.body)return;let s=t.body.getReader(),i;for await(let a of Nb(s)){let l=r.parseStreamChunk(a);l?.reasoning&&(yield{kind:"reasoning",text:l.reasoning}),l?.text&&(yield{kind:"text",text:l.text}),l?.usage&&(i=Rb(i,l.usage))}let o=ot(i);o&&(yield{kind:"usage",usage:o})}var Lb=S(()=>{xn();Od()});import{strToU8 as yP,strFromU8 as bP,deflateSync as wP,inflateSync as vP}from"fflate";function Id(t,e){let n=[];if(n.push(`You are a data processor. Follow the instructions to analyze the provided data. Output valid JSON that the code can consume.
|
|
512
523
|
|
|
513
524
|
---
|
|
514
525
|
Instructions:
|
|
@@ -526,13 +537,13 @@ ${r}
|
|
|
526
537
|
</data>`)}return n.push(`
|
|
527
538
|
Output only valid JSON. No explanation, no markdown fences, just the JSON object. Every number must be a JSON literal \u2014 never an expression like 2 * pi; write the computed decimal instead.`),n.join(`
|
|
528
539
|
|
|
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
|
|
540
|
+
`)}function Us(t){try{return JSON.parse(t)}catch{return}}function Mb(t,e){let n="",r=0,s=!1,i=!1;for(let o=0;o<t.length;o++){let a=t[o];if(i){i=!1;continue}if(a==="\\"){i=!0;continue}a==='"'&&(s?(n+=t.slice(r,o+1),r=o+1):(n+=e(t.slice(r,o))+'"',r=o+1),s=!s)}return n+=s?t.slice(r):e(t.slice(r)),n}function kP(t){let e=Mb(t,n=>n.replace(/,(\s*[}\]])/g,"$1"));return e!==t?e:void 0}function xP(t){let e=Mb(t,n=>n.replace(/\bpi\b/g,"3.141592653589793").replace(/\be\b/g,"2.718281828459045").replace(/-?\d[\d.\s+\-*/()]*\d|\(-?\d[\d.\s+\-*/()]*\d\)/g,r=>{if(!/[+\-*/]/.test(r.replace(/^-/,""))||r.length>64||!/^[\d\s.+\-*/()]+$/.test(r))return r;try{let s=Function(`"use strict"; return (${r})`)();return typeof s=="number"&&Number.isFinite(s)?String(s):r}catch{return r}}));return e!==t?e:void 0}function EP(t,e){let n=0,r=!1,s=!1;for(let i=e;i<t.length;i++){let o=t[i];if(s){s=!1;continue}if(o==="\\"){s=!0;continue}if(o==='"'){r=!r;continue}if(!r){if(o==="{"||o==="[")n++;else if((o==="}"||o==="]")&&(n--,n===0))return i}}return-1}function AP(t){let e,n=0;for(;n<t.length;){let r=t[n];if(r==="{"||r==="["){let s=EP(t,n);if(s!==-1){let i=t.slice(n,s+1),o=Us(i);o!==void 0&&(e={parsed:o,json:i}),n=s+1;continue}}n++}return e}function $d(t){let e=[],n=t.trim();n.startsWith("```")&&(n=n.replace(/^```(?:json)?\s*\n?/,"").replace(/\n?```\s*$/,""),e.push("markdown fences"));let r=Us(n);if(r!==void 0)return{parsed:r,json:n,fixesApplied:e};let s=n.match(/```(?:json)?\s*\n([\s\S]*?)\n?```\s*$/);if(s&&(n=s[1].trim(),e.push("preamble before fenced JSON"),r=Us(n),r!==void 0))return{parsed:r,json:n,fixesApplied:e};if(!n.startsWith("{")&&!n.startsWith("[")){let o=n.indexOf("{"),a=n.indexOf("["),l=o>=0&&a>=0?Math.min(o,a):o>=0?o:a;if(l>0&&(n=n.slice(l),e.push("preamble text"),r=Us(n),r!==void 0))return{parsed:r,json:n,fixesApplied:e}}for(let[o,a]of SP){let l=a(n);if(l!==void 0){let c=Us(l);if(c!==void 0)return{parsed:c,json:l,fixesApplied:[...e,o]}}}let i=AP(t);return i!==void 0?{...i,fixesApplied:[...e,"extracted last JSON value"]}:{parsed:void 0,json:n,fixesApplied:e}}function Nd(t){try{let e={};if(t.insight!==void 0&&(e.i=t.insight),t.data!==void 0&&(e.d=t.data),e.i===void 0&&e.d===void 0)return"";let n=JSON.stringify(e),r=wP(yP(n),{level:9}),s=CP(r),i=`${Db}:${s}`;return i.length>TP?"":"#"+Rd+i}catch{return""}}function Ld(t){try{let e=t.startsWith("#")?t.slice(1):t;if(!e.startsWith(Rd))return;let n=e.slice(Rd.length),r=n.indexOf(":");if(r===-1||n.slice(0,r)!==Db)return;let s=OP(n.slice(r+1)),i=JSON.parse(bP(vP(s)));if(!i||typeof i!="object")return;let o=i.i!==void 0,a=Array.isArray(i.d);if(!o&&!a)return;let l={};return o&&(l.insight=i.i,l.insightJson=JSON.stringify(i.i,null,2)),a&&(l.data=i.d),l}catch{return}}function CP(t){let e="";for(let n=0;n<t.length;n+=32768)e+=String.fromCharCode(...t.subarray(n,n+32768));return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function OP(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");for(;e.length%4;)e+="=";let n=atob(e),r=new Uint8Array(n.length);for(let s=0;s<n.length;s++)r[s]=n.charCodeAt(s);return r}var SP,Rd,Db,TP,Bb=S(()=>{SP=[["orphan quote",t=>{let e=t.replace(/^[ \t]*"[ \t]*\r?\n/gm,"");return e!==t?e:void 0}],["trailing }",t=>t.endsWith("}}")?t.slice(0,-1):void 0],["trailing ]",t=>t.endsWith("]]")?t.slice(0,-1):void 0],["trailing },",t=>t.endsWith("},")?t.slice(0,-1):void 0],["trailing ],",t=>t.endsWith("],")?t.slice(0,-1):void 0],["trailing commas",kP],["arithmetic constants",xP]];Rd="tb=",Db="1",TP=6e4});var qt=S(()=>{xn();gr();Od();Lb();Bb();ua();Ed();Ad();Sd();xd();Td()});import{readFileSync as jb,existsSync as PP}from"fs";import*as at from"path";function Fb(t){return[...t?[`.env.${t}.local`,`.env.${t}`]:[],".env.local",".env"]}function be(t,e=process.cwd()){let n={},r=[];for(let s of Fb(t)){let i;try{i=jb(at.resolve(e,s),"utf-8")}catch{continue}r.push(s);for(let[o,a]of Ub(i))process.env[o]===void 0&&(process.env[o]=a,n[o]=s)}return{mode:t,sources:n,loaded:r}}function*Ub(t){for(let e of t.split(`
|
|
541
|
+
`)){let n=e.trim();if(!n||n.startsWith("#"))continue;let r=n.indexOf("=");if(r===-1)continue;let s=n.slice(0,r).trim(),i=n.slice(r+1).trim();(i.startsWith('"')&&i.endsWith('"')||i.startsWith("'")&&i.endsWith("'"))&&(i=i.slice(1,-1)),yield[s,i]}}function ma(t,e=process.cwd()){for(let n of Fb()){let r;try{r=jb(at.resolve(e,n),"utf-8")}catch{continue}for(let[s,i]of Ub(r))if(s===t)return i}return process.env[t]}function _P(t){let e=new Set,n=/process\.env\.([A-Za-z_$][\w$]*)|process\.env\[\s*['"]([^'"]+)['"]\s*\]/g;for(let r;r=n.exec(t);)e.add(r[1]??r[2]);return[...e]}function qb(){return`.env loads from ${process.cwd()} (the directory you ran from, not the bulb's)`}function Jt(t,e,n){let{sources:r,mode:s,loaded:i}=t,o=process.cwd(),a=at.dirname(e),l=`(mode: ${s??"none"})`,c=n?_P(n):[],u=c.filter(p=>r[p]).map(p=>`${p} \u2190 ${r[p]}`);u.length?console.log(`env: ${u.join(", ")} ${l}`):i.length&&console.log(`env: loaded ${i.join(", ")} ${l}`),s&&!i.some(p=>p===`.env.${s}`||p===`.env.${s}.local`)&&console.log(`env: mode=${s} \u2014 no .env.${s} found; using .env`);let d=at.resolve(a)!==at.resolve(o);if(d)for(let p of[".env.local",".env"])PP(at.join(a,p))&&console.log(`env: ${at.join(a,p)} present but not loaded (cwd is ${o})`);let f=c.filter(p=>process.env[p]===void 0);if(f.length){let p=d?` \u2014 try running from ${a}`:"";console.log(`env: server.ts reads ${f.join(", ")} but ${f.length>1?"they are":"it's"} unset${p}`)}}var Ze=S(()=>{"use strict"});function bt(t,e){let n=t??process.env.TB_AI_PROVIDER,r=e??process.env.TB_AI_MODEL;if(!n)return"No provider specified. Set TB_AI_PROVIDER in your .env file or pass provider in the tb.ai() call.";if(!r)return"No model specified. Set TB_AI_MODEL in your .env file or pass model in the tb.ai() call.";let s;try{s=En(n)}catch{return`Unknown provider '${n}'.`}if(n==="ollama")return{apiKey:"",baseUrl:`${mr(process.env.OLLAMA_HOST??s.defaultBaseUrl)}/v1`,protocol:n,model:r,isFreeModel:!1};if(n==="openai-compat"){let a=process.env.TB_AI_BASE_URL;return a?{apiKey:process.env.TB_AI_API_KEY??"",baseUrl:a,protocol:n,model:r,isFreeModel:!1}:"No base URL for openai-compat. Set TB_AI_BASE_URL (the OpenAI-style base ending in /v1, e.g. http://localhost:1234/v1) in your .env file."}let i=hr[n];if(!i)return`Unknown provider '${n}'.`;let o=process.env[i];return o?{apiKey:o,baseUrl:s.defaultBaseUrl,protocol:n,model:r,isFreeModel:!1}:`No API key for '${n}'. Set ${i} \u2014 ${qb()}.`}function Wt(t,e){let n=[...e.system?[{role:"system",content:e.system}]:[],...e.messages.map(r=>({role:r.role,content:r.content}))];return Cd(t,{messages:n,stream:!0,effort:_b(e.effort),webSearch:e.webSearch,signal:e.signal})}var ga=S(()=>{"use strict";qt();qt();Ze();kn()});import{readFileSync as Vj,existsSync as RP}from"fs";import*as vr from"path";import{fileURLToPath as IP}from"url";function $P(){let t=vr.dirname(IP(import.meta.url));for(;!RP(vr.join(t,"package.json"));){let e=vr.dirname(t);if(e===t)break;t=e}return t}function qs(){return vr.join($P(),"SKILL.md")}var Md=S(()=>{"use strict"});import{transform as NP}from"sucrase";function Dd(t,e={}){let n=e.serverOnly?["typescript"]:["typescript","jsx"];try{let{code:r}=NP(t,{transforms:n,jsxRuntime:"automatic",jsxImportSource:e.jsxImportSource||"react",production:!0});return{code:r}}catch(r){return{code:"",error:String(r)}}}var Jb=S(()=>{});function LP(t){return t.map(e=>`${e.type} (line ${e.lineNumber}): ${e.message.split(`
|
|
531
542
|
`)[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
|
-
${
|
|
543
|
+
`)}function Wb(t,e){let n=Ms(t,{target:"client",dependencies:e}).filter(r=>r.type==="UNDECLARED_IMPORT");if(n.length)throw new Error(`Lint failed:
|
|
544
|
+
${LP(n)}`)}var Kb=S(()=>{"use strict";oa()});var Kt,Js,Bd,Ws=S(()=>{Kt="https://esm.sh",Js="https://cdn.jsdelivr.net/npm/",Bd="https://data.jsdelivr.com/v1/package/npm/"});function Hb(t){let e=(t||"").replace(/^\/+/,"").replace(/\/+$/,"");return e?e.split("/"):[]}var j,Sr,zb,Ks=S(()=>{Ws();j=class t{constructor(e,n,r){let s=typeof e=="string"?t.parse(e):e;this.name=s.name,this.version=Sr(n??s.version),this.subpath=Sr(r??s.subpath)}static parse(e){let n=Hb(e||"");if(!n.length)return new t({name:""});if(n[0].startsWith("@")){let s=n[0],[i,o]=zb(n[1]??""),a=Sr(n.slice(2).join("/"));return new t({name:`${s}/${i}`,version:o,subpath:a})}else{let[s,i]=zb(n[0]),o=Sr(n.slice(1).join("/"));return new t({name:s,version:i,subpath:o})}}static fromUrl(e){try{let n=new URL(e),r=new URL(Kt).host,s=new URL(Js).host;if(n.host===r){let i=Hb(n.pathname.replace(/^\/v\d+\//,"/"));if(!i.length)return;let o=i[0].startsWith("@")?`${i[0]}/${i[1]??""}`:i[0];return t.parse(o)}if(n.host===s){let i=n.pathname.split("/npm/")[1];if(!i)return;let o=i.split("/")[0]||"";return t.parse(o)}return}catch{return}}format(){let e=this.version?`${this.name}@${this.version}`:this.name;return this.subpath?`${e}/${this.subpath}`:e}root(){return this.name}static rootOf(e){return t.parse(e).name}withVersion(e){return new t({name:this.name,version:Sr(e),subpath:this.subpath})}static isBare(e){return!e||e.startsWith(".")||e.startsWith("/")?!1:!/^[a-z][a-z0-9+.-]*:/i.test(e)}},Sr=t=>t&&t.length?t:void 0,zb=t=>{let e=t.indexOf("@");return e<0?[t,void 0]:[t.slice(0,e),Sr(t.slice(e+1))]}});async function Te(t){try{return await t()}catch{return}}var ya=S(()=>{});function Tn(t){let e=t||"";return e.startsWith("./")?e.slice(2):e.replace(/^\/+/,"")}function jd(t){return t.startsWith("./")?t:`./${t}`}var Hs,Fd=S(()=>{Ks();ya();Ws();Hs=class{constructor(e,n){this.cache=e,this.http=n,this.pinMs=1e4,this.versionsIndexMs=1440*60*1e3,this.metaTtlMs=10080*60*1e3,this.pinCache=new Map}baseDir(e){let n=typeof e=="string"?new j(e):e;return`${Js}${n.name}${n.version?`@${n.version}`:""}/`}file(e,n){return new URL(Tn(n),this.baseDir(e)).toString()}packageJson(e){return this.file(e,"package.json")}buildEsmUrl(e,n={}){let{target:r="es2022",bundle:s=!1,external:i}=n,o=new URLSearchParams({target:r});return s&&o.append("bundle",""),i?.length&&o.append("external",i.join(",")),`${Kt}/${e}?${o.toString()}`}async resolveExactVersion(e){let n=Date.now(),r=this.pinCache.get(e);if(r&&n-r.ts<this.pinMs)return r.value;let s=await this.tryResolveFromUrls([this.buildEsmUrl(e),`${Kt}/${e}`]);return this.pinCache.set(e,{value:s,ts:n}),s}async tryResolveFromUrls(e){for(let n of e){let r=await Te(()=>this.http.head(n)),s=this.parseVersionFromUrl(r?.url||n);if(s)return s}}async fetchVersionsIndex(e){if(await this.cache.isNegative(e))return;let n=await this.cache.getIndex(e);if(n&&Date.now()-n.updatedAt<this.versionsIndexMs)return{versions:n.versions,distTags:n.distTags};let r=await Te(()=>this.http.getJson(`${Bd}${encodeURIComponent(e)}`));if(!r?.versions?.length){await this.cache.recordNegative(e);return}await this.cache.clearNegative(e);let s=r.tags&&Object.keys(r.tags).length?r.tags:void 0;return await this.cache.setIndex(e,r.versions,s),{versions:r.versions,distTags:s}}parseVersionFromUrl(e){let n=j.fromUrl(e)?.version;return n&&/\d+\.\d+\.\d+/.test(n)?n:void 0}async fetchPackageMeta(e,n){let r=await this.cache.getMeta(e,n);if(r&&Date.now()-r.updatedAt<this.metaTtlMs){let{dependencies:u,peerDependencies:d,peerDependenciesMeta:f}=r;return{name:e,version:n,dependencies:u,peerDependencies:d,peerDependenciesMeta:f}}let s=this.packageJson(new j(`${e}@${n}`)),i=await Te(()=>this.http.getJson(s));if(!i)return;let o=u=>u&&Object.keys(u).length?u:void 0,a=o(i.dependencies),l=o(i.peerDependencies),c=o(i.peerDependenciesMeta);return await this.cache.setMeta(e,n,a,l,c),{name:e,version:n,dependencies:a,peerDependencies:l,peerDependenciesMeta:c}}}});var Yb,zs,Ud,MP,Ys,ba=S(()=>{Yb=t=>t.startsWith("@types/"),zs=t=>Object.keys(t?.peerDependencies||{}).filter(e=>!Yb(e)),Ud=t=>Object.keys(t?.dependencies||{}).filter(e=>!Yb(e)),MP=t=>zs(t).filter(e=>!t?.peerDependenciesMeta?.[e]?.optional),Ys=class{constructor(e){this.cdn=e}async resolve(e,n){let r=await this.fetchMeta(e),{allRoots:s,autoAddedPeers:i}=await this.expandWithPeers(r,n),o=this.computeFlags(s);return{allRoots:s,flags:o,autoAddedPeers:i}}async fetchMeta(e){return Promise.all(e.map(async({name:n,version:r})=>({name:n,version:r,meta:await this.cdn.fetchPackageMeta(n,r)})))}async expandWithPeers(e,n){let r=new Map(e.map(i=>[i.name,i])),s=[];for(let i of e)for(let o of MP(i.meta))!r.has(o)&&!s.some(a=>a.name===o)&&s.push({name:o,requiredBy:i.name});for(let{name:i,requiredBy:o}of s)try{let a=await n(i),l=await this.cdn.fetchPackageMeta(i,a);r.set(i,{name:i,version:a,meta:l})}catch(a){console.warn(`[typebulb] Failed to resolve peer "${i}" for "${o}":`,a)}return{allRoots:[...r.values()],autoAddedPeers:s.filter(i=>r.has(i.name))}}computeFlags(e){let n=new Set(e.flatMap(i=>zs(i.meta))),r=new Map;for(let i of e)for(let o of Ud(i.meta))r.set(o,(r.get(o)||0)+1);let s=new Set([...r.entries()].filter(([,i])=>i>=2).map(([i])=>i));return new Map(e.map(i=>[i.name,{isPeerRoot:n.has(i.name),hasPeers:zs(i.meta).length>0,isSharedDep:s.has(i.name)}]))}}});var Vs,qd=S(()=>{Ks();ya();Vs=class{constructor(e,n,r){this.cache=e,this.cdn=n,this.semver=r}async learnExactVersion(e){let n=await Te(()=>this.cdn.fetchVersionsIndex(e));if(n?.versions?.length){let r=this.semver.selectBestVersion(n.versions,{distTags:n.distTags});if(r)return r}return this.cdn.resolveExactVersion(e)}async resolveExactForRoot(e,n){if(!n)return this.learnExactVersion(e);let r=a=>!this.semver.isRange(n)||this.semver.satisfies(n,a),s=await this.cache.getPinnedExact(e,n);if(s){if(this.semver.isExactVersion(s)&&r(s))return s;console.debug("[typebulb] cached version for",e,"is not exact or not in",n,"(",s,"); re-resolving from registry")}let i=async a=>{if(a&&this.semver.isExactVersion(a)&&r(a))return await this.cache.setPinnedExact(e,n,a),a},o=await Te(()=>this.cdn.fetchVersionsIndex(e));if(o?.versions?.length){let a=this.semver.selectBestVersion(o.versions,{range:n,distTags:o.distTags});if(a){let l=await i(a);if(l)return l}else{console.debug("[typebulb] refreshing version cache for",e,"(",n,"not in cached set \u2014 likely a new release)"),await this.cache.invalidateVersionsCache(e);let l=await Te(()=>this.cdn.fetchVersionsIndex(e));if(l?.versions?.length){let c=await i(this.semver.selectBestVersion(l.versions,{range:n,distTags:l.distTags}));if(c)return c}}}return i(await this.cdn.resolveExactVersion(`${e}@${n}`))}async effectivePackage(e,n){let r=new j(e),s=r.root(),i=n[s],o=i?await Te(()=>this.resolveExactForRoot(s,i)):void 0;return{effectivePackage:o?r.withVersion(o).format():e,root:s,range:i,pinned:o}}}});import{init as DP,parse as BP}from"es-module-lexer";var kr,Jd=S(()=>{Ks();Ws();ba();kr=class t{constructor(e,n,r){this.version=e,this.cdn=n,this.peer=r}extractImportsSync(e){let n=new Set;for(let r of t.importPatterns){r.lastIndex=0;for(let s of e.matchAll(r))j.isBare(s[1])&&n.add(s[1])}return Array.from(n)}async extractImports(e){let n=new Set,r=s=>{j.isBare(s)&&n.add(s)};try{await DP;let[s]=BP(e);s.forEach(i=>r(e.slice(i.s,i.e).trim()))}catch{return this.extractImportsSync(e)}return Array.from(n)}async buildImportMap(e,n,r){let s=(await this.extractImports(e)).filter(d=>!r?.has(j.rootOf(d))),i=[...new Set(s.map(j.rootOf))],o=await Promise.all(i.map(async d=>({name:d,version:await this.resolveVersion(d,n)}))),{allRoots:a,flags:l,autoAddedPeers:c}=await this.peer.resolve(o,d=>this.resolveVersion(d,n)),u=this.buildEntries([...s,...c.map(d=>d.name)],a,l);return{importMap:{imports:Object.fromEntries(u)},prefetchUrls:u.map(([,d])=>d)}}async resolveVersion(e,n){let r=n[e],s=await this.version.resolveExactForRoot(e,r);if(!s)throw new Error(`Cannot resolve ${r?`${e}@${r}`:e}: no matching version is published (the package or version may not exist, or the registry was unreachable).`);return s}buildEntries(e,n,r){let s=new Map(n.map(p=>[p.name,p])),i=p=>{let h=s.get(j.rootOf(p));return new j(p).withVersion(h.version).format()},o=new Set([...r.entries()].filter(([,p])=>p.isPeerRoot||p.isSharedDep).map(([p])=>p)),a=new Set(e.filter(p=>p!==j.rootOf(p)).map(j.rootOf)),l=[],c=new Set,u=new Set(e.filter(p=>p===j.rootOf(p))),d=new Set;for(let p of e){let h=j.rootOf(p),m=s.get(h),{isPeerRoot:g,hasPeers:v,isSharedDep:A}=r.get(h),C=a.has(h),x=p!==h,I=!(g||A)&&(C||!v),L=this.singletonDepsOf(m,o),T=x&&u.has(h);T&&d.add(h);let F=T?[...L,h]:L.length?L:void 0;l.push([p,this.cdn.buildEsmUrl(i(p),{bundle:I,external:F})]),c.add(p)}let f=new Set([...o,...d]);for(let p of f)s.has(p)&&(c.has(p)||l.push([p,this.cdn.buildEsmUrl(i(p),{})]),l.push([`${p}/`,`${Kt}/${i(p)}/`]));return l}singletonDepsOf(e,n){return[...new Set([...zs(e.meta),...Ud(e.meta)])].filter(r=>n.has(r))}};kr.importPatterns=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g]});import{gt as Vb,satisfies as jP,maxSatisfying as Gb,major as FP,valid as UP,validRange as qP}from"semver";var wa,Cn,Wd=S(()=>{wa=class{cmp(e,n){return e===n?0:Vb(e,n)?1:Vb(n,e)?-1:0}satisfies(e,n){return!e||!e.trim()?!0:!!jP(n,e,{includePrerelease:!0})}selectBestVersion(e,n){if(!e?.length)return;let r=n?.range?.trim()||"*",s=n?.preferStable??!0,i=n?.distTags?.latest;if(i&&e.includes(i)&&this.satisfies(r,i))return i;if(s){let a=Gb(e,r,{includePrerelease:!1});if(a)return a}return Gb(e,r,{includePrerelease:!0})??void 0}majorOf(e){return FP(e)}isExactVersion(e){return UP(e)!==null}isRange(e){return qP(e)!==null}},Cn=new wa});function JP(t){return Math.min(9e5*Math.pow(2,Math.max(0,t-1)),864e5)}var On,Xb=S(()=>{ya();On=class{constructor(e){this.store=e}async isNegative(e){let n=await Te(()=>this.store.get(e));return!!n&&n.until>Date.now()}async recordNegative(e){let r=((await Te(()=>this.store.get(e)))?.attempts||0)+1;await Te(()=>this.store.set(e,{until:Date.now()+JP(r),attempts:r}))}async clearNegative(e){await Te(()=>this.store.delete(e))}}});function Qb(t,e){let n=new Hs(t,e),r=new Ys(n),s=new Vs(t,n,Cn);return{packageService:new kr(s,n,r),versionResolver:s,cdnClient:n,peerResolver:r}}var wt=S(()=>{Fd();ba();qd();Jd();Wd();Ks();Wd();Ws();Fd();ba();qd();Jd();Xb()});import*as Kd from"fs/promises";import*as Zb from"crypto";function et(t){return Zb.createHash("sha1").update(t).digest("hex")}async function vt(t){try{return JSON.parse(await Kd.readFile(t,"utf8"))}catch{return}}async function va(t){try{return await Kd.readFile(t,"utf8")}catch{return}}var xr=S(()=>{"use strict"});import*as zt from"fs/promises";import*as St from"path";import*as tw from"os";function te(){return Hd||(Hd=KP().catch(()=>ht())),Hd}function ka(t,e){return St.join(WP,et(t),e)}async function KP(){await zt.mkdir(Ht,{recursive:!0});let t=St.join(Ht,"version.json");if((await vt(t))?.version===ew)return;let n=await zt.readdir(Ht).catch(()=>[]);await Promise.all(n.map(r=>zt.rm(St.join(Ht,r),{recursive:!0,force:!0}))),await zt.writeFile(t,JSON.stringify({version:ew})+`
|
|
545
|
+
`,"utf8")}var ew,Ht,Gs,Xs,Sa,WP,Hd,Er=S(()=>{"use strict";xr();Be();ew=1,Ht=St.join(tw.homedir(),".typebulb","cache"),Gs=St.join(Ht,"packages"),Xs=St.join(Ht,"proxy"),Sa=St.join(Ht,"dts"),WP=St.join(Ht,"emit")});import*as Yt from"fs/promises";import*as nw from"path";async function Fe(t,e){let n=`${t}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;try{await Yt.mkdir(nw.dirname(t),{recursive:!0}),await Yt.writeFile(n,e,"utf8")}catch{ht();return}await Yt.rename(n,t).catch(async()=>{await Yt.rm(n,{force:!0}).catch(()=>{})})}var Qs=S(()=>{"use strict";Be()});var Ar,zd=S(()=>{"use strict";Qs();xr();Ar=class{constructor(e){this.filePath=e}mem;loadPromise;load(){return this.mem?Promise.resolve(this.mem):(this.loadPromise||(this.loadPromise=vt(this.filePath).then(e=>(this.mem=new Map(Object.entries(e??{})),this.mem))),this.loadPromise)}async get(e){return(await this.load()).get(e)}async set(e,n){let r=await this.load();r.set(e,n),await this.persist(r)}async delete(e){let n=await this.load();n.delete(e)&&await this.persist(n)}async persist(e){await Fe(this.filePath,JSON.stringify(Object.fromEntries(e)))}}});import*as iw from"fs/promises";import*as tt from"path";function sw(t,e){return tt.join(HP,xa(t),encodeURIComponent(e)+".json")}function xa(t){return t.replace(/\//g,"__")}var Yd,rw,HP,zP,Ea,ow=S(()=>{"use strict";wt();Er();Qs();zd();xr();Yd=tt.join(Gs,"indexes"),rw=tt.join(Gs,"pinned"),HP=tt.join(Gs,"meta"),zP=tt.join(Gs,"negative.json"),Ea=class{pinnedMem=new Map;indexMem=new Map;metaMem=new Map;negativeCache=new On(new Ar(zP));async getPinnedExact(e,n){let r=`${e}@${n}`;if(this.pinnedMem.has(r))return this.pinnedMem.get(r);await te();let s=await va(tt.join(rw,et(r)+".txt"));return this.pinnedMem.set(r,s),s}async setPinnedExact(e,n,r){let s=`${e}@${n}`;this.pinnedMem.set(s,r),await te(),await Fe(tt.join(rw,et(s)+".txt"),r)}async getIndex(e){if(this.indexMem.has(e))return this.indexMem.get(e);await te();let n=await vt(tt.join(Yd,xa(e)+".json"));return this.indexMem.set(e,n),n}async setIndex(e,n,r){let s={versions:n,distTags:r,updatedAt:Date.now()};this.indexMem.set(e,s),await te(),await Fe(tt.join(Yd,xa(e)+".json"),JSON.stringify(s))}async invalidateVersionsCache(e){this.indexMem.delete(e),await iw.rm(tt.join(Yd,xa(e)+".json"),{force:!0}).catch(()=>{})}async isNegative(e){return await te(),this.negativeCache.isNegative(e)}async recordNegative(e){await te(),await this.negativeCache.recordNegative(e)}async clearNegative(e){await this.negativeCache.clearNegative(e)}async getMeta(e,n){let r=`${e}@${n}`;if(this.metaMem.has(r))return this.metaMem.get(r);await te();let s=await vt(sw(e,n));return this.metaMem.set(r,s),s}async setMeta(e,n,r,s,i){let o={dependencies:r,peerDependencies:s,peerDependenciesMeta:i,updatedAt:Date.now()};this.metaMem.set(`${e}@${n}`,o),await te(),await Fe(sw(e,n),JSON.stringify(o))}}});var aw,lw=S(()=>{"use strict";aw={async getJson(t){try{let e=await fetch(t,{redirect:"follow"});return e.ok?await e.json():void 0}catch{return}},async head(t){try{let e=await fetch(t,{method:"HEAD",redirect:"follow"});return{ok:e.ok,url:e.url}}catch{return}}}});var YP,Aa,cw,uw,n2,Vd=S(()=>{"use strict";wt();ow();lw();YP=new Ea,{packageService:Aa,versionResolver:cw,cdnClient:uw,peerResolver:n2}=Qb(YP,aw)});function Ta(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function dw(){return` <script>
|
|
546
|
+
${oy}
|
|
536
547
|
(function () {
|
|
537
548
|
try {
|
|
538
549
|
var key = function () { return 'tb-scroll:' + location.pathname + location.search; };
|
|
@@ -545,14 +556,14 @@ ${Vg}
|
|
|
545
556
|
});
|
|
546
557
|
} catch (e) {}
|
|
547
558
|
})();
|
|
548
|
-
</script>`}function
|
|
559
|
+
</script>`}function Ca(t,e){return` <script>
|
|
549
560
|
(function() {
|
|
550
561
|
try {
|
|
551
|
-
var KEY = ${
|
|
562
|
+
var KEY = ${kt(JSON.stringify("tb-theme:"+t))};
|
|
552
563
|
var doc = document.documentElement;
|
|
553
564
|
var mq = window.matchMedia('(prefers-color-scheme: dark)');
|
|
554
565
|
var os = function() { return mq.matches ? 'dark' : 'light'; };
|
|
555
|
-
var FORCED = ${
|
|
566
|
+
var FORCED = ${kt(JSON.stringify(e??null))};
|
|
556
567
|
var stored = function() {
|
|
557
568
|
try { var v = localStorage.getItem(KEY); return (v === 'dark' || v === 'light') ? v : undefined; }
|
|
558
569
|
catch (e) { return undefined; }
|
|
@@ -590,7 +601,7 @@ ${Vg}
|
|
|
590
601
|
});
|
|
591
602
|
} catch (e) {}
|
|
592
603
|
})();
|
|
593
|
-
</script>`}var
|
|
604
|
+
</script>`}var kt,fw,Gd,VP,GP,Oa,Tr=S(()=>{"use strict";Z();Z();kt=t=>t.replace(/<\/script/gi,"<\\/script");fw=30*6e4,Gd=1e3,VP=6e4,GP=3e4,Oa=(t="'/__reload'")=>`
|
|
594
605
|
let es = null;
|
|
595
606
|
let bootId = null;
|
|
596
607
|
let firstErrorAt = 0;
|
|
@@ -605,9 +616,9 @@ ${Vg}
|
|
|
605
616
|
es.onerror = () => {
|
|
606
617
|
if (!firstErrorAt) firstErrorAt = Date.now();
|
|
607
618
|
// Inside the replace window, EventSource's own retry is faster than anything we'd schedule.
|
|
608
|
-
if (Date.now() - firstErrorAt <= ${
|
|
619
|
+
if (Date.now() - firstErrorAt <= ${VP}) return;
|
|
609
620
|
es.close();
|
|
610
|
-
backoff = Math.min(${
|
|
621
|
+
backoff = Math.min(${GP}, backoff ? backoff * 2 : ${Gd} * 2);
|
|
611
622
|
setTimeout(tbConnect, backoff);
|
|
612
623
|
};
|
|
613
624
|
};
|
|
@@ -623,7 +634,7 @@ ${Vg}
|
|
|
623
634
|
// A relay open (TB-VSCode-Browser.md): the CLI asks a page of ours inside VS Code to open a URL,
|
|
624
635
|
// since its integrated browser honors a gesture-less window.open and keeps the new tab in-editor.
|
|
625
636
|
tbOn('open-url', (e) => { window.open(e.data, '_blank', 'noopener'); });
|
|
626
|
-
tbConnect();`});var
|
|
637
|
+
tbConnect();`});var pw,hw=S(()=>{"use strict";Tr();Z();pw=`
|
|
627
638
|
(() => {
|
|
628
639
|
// Inline (bulb-in-a-bulb): runs inside a sandboxed iframe with no parent
|
|
629
640
|
// bridge, so privileged tb.* (AI, fs, server RPC) can't reach a host and would
|
|
@@ -1067,7 +1078,7 @@ ${Vg}
|
|
|
1067
1078
|
},
|
|
1068
1079
|
|
|
1069
1080
|
// Environment ('inline' when running as a bulb-in-a-bulb)
|
|
1070
|
-
mode: isFramed ? '${
|
|
1081
|
+
mode: isFramed ? '${er.inline}' : '${er.local}',
|
|
1071
1082
|
|
|
1072
1083
|
// Theme accessor - delegates to the head-script engine (window.__tbTheme).
|
|
1073
1084
|
// Get: override slot ('dark'|'light'|undefined). Set applies + persists
|
|
@@ -1496,7 +1507,7 @@ ${Vg}
|
|
|
1496
1507
|
if (relayed) history.replaceState(null, '', location.pathname + location.search);
|
|
1497
1508
|
const tbStreamUrl = '/__reload?bulb=' + encodeURIComponent(window.__TB_BULB__ || '')
|
|
1498
1509
|
+ (relayed ? '&relay=' + Math.random().toString(36).slice(2) : '');
|
|
1499
|
-
${
|
|
1510
|
+
${Oa("tbStreamUrl")}
|
|
1500
1511
|
// Told to go, the page goes: it closes the tab, and where the browser refuses a script the close
|
|
1501
1512
|
// (a tab that wasn't script-opened and has history) it replaces itself with a note naming the
|
|
1502
1513
|
// reason. The note is a blob document, never a served route \u2014 a note that needs the server
|
|
@@ -1583,49 +1594,49 @@ ${Ea("tbStreamUrl")}
|
|
|
1583
1594
|
});
|
|
1584
1595
|
}
|
|
1585
1596
|
})();
|
|
1586
|
-
`});function
|
|
1587
|
-
`+
|
|
1597
|
+
`});function mw(t){let{name:e,code:n,css:r,html:s,data:i,insight:o,importMap:a,theme:l,inline:c,dir:u,source:d,bulbKey:f,compileError:p}=t,h=s.trim()||'<div id="app"></div>',m=c?"":`
|
|
1598
|
+
`+Mu,g={imports:t_(a.imports)};return`<!DOCTYPE html>
|
|
1588
1599
|
<html>
|
|
1589
1600
|
<head>
|
|
1590
1601
|
<meta charset="utf-8">
|
|
1591
1602
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
1592
|
-
<title>${
|
|
1593
|
-
${
|
|
1594
|
-
${c?"":
|
|
1603
|
+
<title>${Ta(e)} - typebulb</title>
|
|
1604
|
+
${Ca(e,l)}
|
|
1605
|
+
${c?"":dw()}
|
|
1595
1606
|
<script type="importmap">
|
|
1596
1607
|
${JSON.stringify(g,null,2)}
|
|
1597
1608
|
</script>
|
|
1598
1609
|
<style>
|
|
1599
|
-
${
|
|
1610
|
+
${As}${m}
|
|
1600
1611
|
</style>
|
|
1601
1612
|
<style>
|
|
1602
1613
|
${r}
|
|
1603
1614
|
</style>
|
|
1604
1615
|
</head>
|
|
1605
1616
|
<body>
|
|
1606
|
-
${
|
|
1617
|
+
${h}
|
|
1607
1618
|
|
|
1608
|
-
${i.length>0?`<script>window.__TB_DATA__ = ${
|
|
1609
|
-
${o?`<script>window.__TB_INSIGHT__ = ${
|
|
1610
|
-
${
|
|
1611
|
-
${
|
|
1612
|
-
${p?`<script>window.__TB_COMPILE_ERROR__ = ${
|
|
1619
|
+
${i.length>0?`<script>window.__TB_DATA__ = ${kt(JSON.stringify(i))};</script>`:""}
|
|
1620
|
+
${o?`<script>window.__TB_INSIGHT__ = ${kt(JSON.stringify(o))};</script>`:""}
|
|
1621
|
+
${u?`<script>window.__TB_DIR__ = ${kt(JSON.stringify(u))};</script>`:""}
|
|
1622
|
+
${f?`<script>window.__TB_BULB__ = ${kt(JSON.stringify(f))};</script>`:""}
|
|
1623
|
+
${p?`<script>window.__TB_COMPILE_ERROR__ = ${kt(JSON.stringify(p))};</script>`:""}
|
|
1613
1624
|
|
|
1614
1625
|
<script>
|
|
1615
|
-
${
|
|
1616
|
-
${
|
|
1626
|
+
${ly}
|
|
1627
|
+
${pw}
|
|
1617
1628
|
</script>
|
|
1618
1629
|
|
|
1619
|
-
${
|
|
1630
|
+
${e_}
|
|
1620
1631
|
|
|
1621
|
-
${
|
|
1632
|
+
${QP(n,d)}
|
|
1622
1633
|
</body>
|
|
1623
|
-
</html>`}function
|
|
1624
|
-
`);return`<script type="module">${s}${
|
|
1625
|
-
</script>`}function
|
|
1634
|
+
</html>`}function QP(t,e){let n=["",...XP],r=e?Array(Math.max(0,e.codeLine-n.length-1)).fill(""):[],s=[...n,...r,kt(t)].join(`
|
|
1635
|
+
`);return`<script type="module">${s}${ZP(e,s)}
|
|
1636
|
+
</script>`}function ZP(t,e){if(!t)return"";let n=e.split(`
|
|
1626
1637
|
`).length,r={version:3,file:t.file,sources:[`/__source/${t.file}`],names:[],mappings:["AAAA",...Array(Math.max(0,n-1)).fill("AACA")].join(";")};return`
|
|
1627
1638
|
//# sourceURL=${t.file.replace(/\s/g,"%20")}
|
|
1628
|
-
//# sourceMappingURL=data:application/json;charset=utf-8,${encodeURIComponent(JSON.stringify(r))}`}function
|
|
1639
|
+
//# sourceMappingURL=data:application/json;charset=utf-8,${encodeURIComponent(JSON.stringify(r))}`}function t_(t){let e={};for(let[n,r]of Object.entries(t))e[n]=r.startsWith("https://")?"/proxy/"+r:r;return e}var XP,e_,gw=S(()=>{"use strict";Z();hw();Tr();XP=["globalThis.__tbEntryRan = true; /* import graph resolved \u2014 the load-failure backstop's signal (imports hoist above this line) */","await globalThis.__tbBoot; /* #tb= fragment restore, set by the shim when present (TB-Inference.md) */"];e_=`<script>
|
|
1629
1640
|
(function () {
|
|
1630
1641
|
var framed = window.parent !== window;
|
|
1631
1642
|
var post = function (m) { try { parent.postMessage(m, '*'); } catch (e) {} }; /* framed only */
|
|
@@ -1724,20 +1735,20 @@ ${yC(n,d)}
|
|
|
1724
1735
|
}
|
|
1725
1736
|
});
|
|
1726
1737
|
})();
|
|
1727
|
-
</script>`});import*as
|
|
1728
|
-
Use a plain name with an exact / caret / tilde range (e.g. three@^0.160.0).`);await
|
|
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=
|
|
1738
|
+
</script>`});import*as _a from"fs/promises";import*as Pa from"path";import{existsSync as yw,readFileSync as n_}from"fs";import{execFile as r_}from"child_process";import{promisify as s_}from"util";import{builtinModules as i_}from"node:module";import{satisfies as o_}from"semver";async function Ra(t,e,n,r){let i=t.map(c=>u_(c,n)).filter(c=>!d_(c,e));if(i.length===0)return;let o=i.filter(c=>!c_.test(c));if(o.length)throw new Error(`Refusing to install npm spec(s) with unsupported characters: ${o.join(", ")}
|
|
1739
|
+
Use a plain name with an exact / caret / tilde range (e.g. three@^0.160.0).`);await _a.mkdir(e,{recursive:!0});let a=Pa.join(e,"package.json");yw(a)||await _a.writeFile(a,JSON.stringify({name:"typebulb-server",private:!0})),console.log(` Installing: ${i.join(", ")}`);let l=["--no-audit","--no-fund",...r?.ignoreScripts?["--ignore-scripts"]:[]];await a_("npm",["install",...l,...i],{cwd:e,shell:!0})}function u_(t,e){if(!e||j.parse(t).version)return t;let n=e[t];return n?`${t}@${n}`:t}function d_(t,e){let{name:n,version:r}=j.parse(t),s=Pa.join(e,"node_modules",n);if(!yw(s))return!1;if(!r)return!0;try{let i=JSON.parse(n_(Pa.join(s,"package.json"),"utf-8")).version;return o_(i,r)}catch{return!1}}function Ia(t){let e=new Set,n=/\bimport\s+(?:[\s\S]*?\s+from\s+)?['"]([^./][^'"]*)['"]/g,r;for(;r=n.exec(t);){let s=r[1];if(s.includes(":"))continue;let i=j.rootOf(s);l_.has(i)||e.add(i)}return[...e]}var a_,l_,c_,Xd=S(()=>{"use strict";wt();a_=s_(r_),l_=new Set(i_),c_=/^(@[a-z0-9._-]+\/)?[a-z0-9._-]+(@[a-zA-Z0-9.^~*x-]+)?$/i});import*as Ue from"fs/promises";import*as Ie from"path";function Cr(t,e){let n=Ie.resolve(e,t),r=Ie.normalize(e),s=Ie.normalize(n);if(s!==r&&!s.startsWith(r+Ie.sep))throw new Error("Path traversal detected - access denied");return n}async function Zs(t,e){return Ue.readFile(Cr(t,e))}async function $a(t,e,n){let r=Cr(t,n);await Ue.mkdir(Ie.dirname(r),{recursive:!0}),await Ue.writeFile(r,typeof e=="string"?e:Buffer.from(e))}async function Na(t,e){let n=Cr(t,e),r=await Ue.readdir(n,{withFileTypes:!0});return Promise.all(r.map(async s=>{let i=await Ue.stat(Ie.join(n,s.name)).then(o=>o.mtimeMs).catch(()=>0);return{name:s.name,dir:s.isDirectory(),mtime:i}}))}async function La(t,e){let n=Cr(t,e);if(Ie.normalize(n)===Ie.normalize(e))throw new Error("Cannot remove the bulb's folder itself: remove its contents instead");await Ue.rm(n,{recursive:!0})}var Qd=S(()=>{"use strict"});async function bw(t){let e=bt(t.provider,t.model);if(typeof e=="string")throw new Error(e);let n=await Wt(e,t);if(!n.ok){let r=await br(n,e.protocol);throw new Error(r.message)}return{response:n,protocol:e.protocol}}async function f_(t){let{response:e,protocol:n}=await bw(t);return wr(e,n)}async function*p_(t){let{response:e,protocol:n}=await bw(t);yield*An(e,n)}function ww(t){let e=Object.assign(f_,{stream:p_}),n={read:async r=>{let s=await Zs(r,t);try{return new TextDecoder("utf-8",{fatal:!0}).decode(s)}catch{throw new Error(`File is not valid UTF-8 text: ${r} \u2014 use tb.fs.readBytes() for binary files.`)}},readBytes:async r=>new Uint8Array(await Zs(r,t)),write:async(r,s)=>(await $a(r,s,t),!0),list:async(r=".")=>Na(r,t),remove:async r=>(await La(r,t),!0)};globalThis.tb=Object.freeze({log:(...r)=>{console.log(...r)},ai:e,fs:n,dir:t,models:()=>yt(),aiAccess:la,mode:er.local})}var vw=S(()=>{"use strict";qt();Z();ga();kn();Qd()});import*as Vt from"fs/promises";import*as fe from"path";import{pathToFileURL as h_}from"url";async function Sw(t){let n=(await Vt.readdir(t)).find(r=>r.endsWith(".bulb.md"));return n?fe.join(t,n):void 0}function Or(t){let e=fe.resolve(t);return fe.join(fe.dirname(e),fe.basename(e).replace(/\.bulb\.md$/,""))}function Pr(t){let[e,n,r,s]=t.split(fe.sep).slice(-4);if(!(e!=="typebulbs"||n!=="u"||!r||!s?.endsWith(".bulb.md")))return{userSlug:r,slug:s.slice(0,-8)}}async function nt(t){let e=await Vt.readFile(t,"utf-8"),n=Un(e),r=dr(n);return{bulb:r,config:Kr(r.config),warnings:Dp(e),starts:n.starts}}function Zd(t){let e=fe.basename(t).replace(/\.bulb\.md$/i,"");return fe.join(fe.dirname(t),".typebulb",`${e}.server.mjs`)}async function ei(t,e,n,r){let s=Dd(t,{serverOnly:!0});if(s.error)throw new Error(`Server compilation error: ${s.error}`);let i=s.code;n&&(i=await Rp(i,n));let o=fe.join(fe.dirname(e),".typebulb");await Vt.mkdir(o,{recursive:!0});let a=Ia(i);a.length>0&&await Ra(a,o,r);let l=Zd(e);return await Vt.writeFile(l,i,"utf-8"),ww(Or(e)),await import(`${h_(l).href}?t=${Date.now()}`)}async function ef(t,e,n,r){let{bulb:s,config:i,starts:o}=await nt(t),a=Po(s.data),l,c=h=>{l??=h instanceof Error?h.message:String(h)};try{Wb(s.code,i.dependencies??{})}catch(h){c(h)}let u=Dd(s.code,{jsxImportSource:i.ts?.jsxImportSource});u.error&&c(u.error);let d={imports:{}};if(!l)try{({importMap:d}=await Aa.buildImportMap(u.code,i.dependencies??{},r?new Set([r.name]):void 0))}catch(h){c(`Dependency resolution failed: ${h instanceof Error?h.message:String(h)}`)}l&&console.error("Build error:",l),r&&(d.imports[r.name]=r.entryUrl);let f=mw({name:s.name,code:l?"":u.code,css:s.css,html:s.html,data:a,insight:s.insight,importMap:d,dir:Or(t),watch:e,source:{file:fe.basename(t),codeLine:o.get("code.tsx")??1},bulbKey:Rs(t),compileError:l}),p;return s.server&&n&&(p=await ei(s.server,t,r,i.dependencies)),{html:f,bulb:s,serverExports:p,buildError:l}}var Pn,xt=S(()=>{"use strict";Ls();Jb();Kb();Vd();gw();Xd();Ti();Be();vw();Pn=t=>fe.join(Or(t),"assets")});import*as $e from"fs/promises";import*as qe from"path";import{createHash as m_}from"crypto";async function nf(t,e,n){let r=[...t],s=async()=>{for(let i=r.shift();i!==void 0;i=r.shift())await n(i)};await Promise.all(Array.from({length:Math.min(e,t.length)},s))}function _r(t){try{return JSON.parse(t).error||t}catch{return t}}async function sf(t,e){try{let n=await fetch(ti(t),{headers:e.token?{Authorization:`Bearer ${e.token}`}:{},signal:e.timeoutMs?AbortSignal.timeout(e.timeoutMs):void 0});return n.ok?n.headers.get("content-type")?.includes("json")?{entries:await n.json()}:{error:"manifest response is not JSON \u2014 wrong origin?"}:{error:`manifest request failed (${n.status}): ${_r(await n.text())}`}}catch(n){return{error:n instanceof Error?n.message:String(n)}}}function of(t,e){be(e);let n=process.env.TYPEBULB_ORIGIN||g_;try{return Ba(t,process.cwd(),n)}catch(r){console.error(r instanceof Error?r.message:String(r)),process.exit(1)}}function Ba(t,e,n){if(/^https?:\/\//i.test(t)){let i=new URL(t),o=i.pathname.split("/").filter(Boolean).map(decodeURIComponent),a=o[0]==="api"&&o[1]==="scripts"?o.slice(2):o;if(a[0]!=="u"||!a[1]||!a[2])throw new Error(`Not a bulb URL: ${t}
|
|
1740
|
+
Expected <origin>/u/<user>/<slug>`);let l=a[1],c=a[2].replace(/(\.bulb)?\.md$/,"");return{origin:i.origin,userSlug:l,slug:c,dest:qe.join(e,Ma(l,c))}}let r=qe.resolve(e,t),s=Pr(r);if(!s)throw new Error(`Not a conventional bulb path: ${t}
|
|
1741
|
+
A pull target must be a bulb URL, or a local file at typebulbs/u/<user>/<slug>.bulb.md \u2014 the path is its remote identity.`);return{origin:n,...s,dest:r}}async function y_(t,e){let n=await sf(t,e);if("error"in n||!n.entries.length)return{kind:"none"};let r=n.entries,s=Pn(t.dest),i=[],o=[],a=0;for(let l of r){let c=await $e.readFile(qe.join(s,...l.path.split("/"))).catch(()=>{});c===void 0?i.push(l.path):rf(c)===l.md5?a++:e.force?i.push(l.path):o.push(l.path)}return o.length?{kind:"conflict",paths:o}:{kind:"plan",toGet:i,unchanged:a}}async function b_(t,e,n){let r=Pn(t.dest),s=[],i=0;return await nf(e.toGet,4,async o=>{try{let a=await fetch(`${ti(t)}/${Da(o)}`,{headers:n.token?{Authorization:`Bearer ${n.token}`}:{},signal:AbortSignal.timeout(n.timeoutMs??3e4)});if(!a.ok){s.push(`${o}: HTTP ${a.status}`);return}let l=qe.join(r,...o.split("/"));await $e.mkdir(qe.dirname(l),{recursive:!0}),await $e.writeFile(l,new Uint8Array(await a.arrayBuffer())),i++}catch(a){s.push(`${o}: ${a instanceof Error?a.message:String(a)}`)}}),{downloaded:i,unchanged:e.unchanged,errors:s}}async function ja(t,e={}){let n=await fetch(tf(t),{headers:e.token?{Authorization:`Bearer ${e.token}`}:{},signal:e.timeoutMs?AbortSignal.timeout(e.timeoutMs):void 0});if(!n.ok)return{kind:"http-error",status:n.status};let r=n.headers.get("content-type");if(!r?.includes("text/markdown"))return{kind:"not-markdown",contentType:r??void 0};let s=await n.text(),i;try{i=await $e.readFile(t.dest,"utf-8")}catch{}let o=i!==void 0&&w_(i,s);if(i!==void 0&&!o&&!e.force){let{mtime:c}=await $e.stat(t.dest);return{kind:"conflict",dest:t.dest,localMtime:c,remoteLastModified:n.headers.get("last-modified")??void 0}}let a=await y_(t,e);if(a.kind==="conflict")return{kind:"asset-conflict",dest:t.dest,paths:a.paths};if(!o){await $e.mkdir(qe.dirname(t.dest),{recursive:!0}),await $e.writeFile(t.dest,s);let c=new Date(n.headers.get("last-modified")??"");isNaN(c.getTime())||await $e.utimes(t.dest,new Date,c)}let l=a.kind==="plan"?await b_(t,a,e):void 0;return o?{kind:"up-to-date",dest:t.dest,assets:l}:{kind:"written",dest:t.dest,created:i===void 0,assets:l}}function w_(t,e){let n=i=>i.replace(/\r\n/g,`
|
|
1742
|
+
`),r=ze(n(t)),s=ze(n(e));return!r||!s?n(t)===n(e):r.frontmatter.name===s.frontmatter.name&&He.every(i=>(r.files.get(de[i].path)||"")===(s.files.get(de[i].path)||""))}async function xw(t,e){t||(console.error("Usage: typebulb pull <bulb url | typebulbs/u/<user>/<slug>.bulb.md>"),process.exit(1));let n=of(t,e.mode),r=`${n.origin}/u/${n.userSlug}/${n.slug}`,s;try{s=await ja(n,{force:e.force,token:process.env.TYPEBULB_TOKEN})}catch(o){console.error(`Could not reach ${n.origin}: ${o instanceof Error?o.message:String(o)}`),process.exitCode=1;return}let i=qe.relative(process.cwd(),n.dest)||n.dest;switch(s.kind){case"written":console.log(`pulled ${r} \u2192 ${i}${s.created?"":" (overwritten)"}`),kw(s.assets);return;case"up-to-date":console.log(`up to date: ${i}`),kw(s.assets);return;case"conflict":console.error(`Refusing to overwrite ${i} \u2014 it differs from ${r}
|
|
1732
1743
|
local file modified ${s.localMtime.toISOString()}
|
|
1733
1744
|
remote last saved ${s.remoteLastModified??"unknown"}
|
|
1734
1745
|
Re-run with --force to overwrite the local file.`),process.exitCode=1;return;case"asset-conflict":console.error(`Refusing to overwrite local assets that differ from the hosted copies:
|
|
1735
1746
|
`+s.paths.map(o=>` assets/${o}`).join(`
|
|
1736
1747
|
`)+`
|
|
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
|
|
1748
|
+
Re-run with --force to overwrite them.`),process.exitCode=1;return;case"http-error":s.status===404?console.error(`Bulb not found: ${r}`):s.status===401||s.status===403?console.error(`This bulb is private (${s.status}) \u2014 pulling it needs a TYPEBULB_TOKEN for its owner.`):console.error(`Pull failed: ${n.origin} responded ${s.status}`),process.exitCode=1;return;case"not-markdown":console.error(`${r}.md did not return bulb markdown (got ${s.contentType??"no content-type"}) \u2014 is ${n.origin} a typebulb host?`),process.exitCode=1}}function kw(t){if(!(!t||!t.downloaded&&!t.errors.length)){console.log(`assets: ${t.downloaded} downloaded${t.unchanged?`, ${t.unchanged} unchanged`:""}`);for(let e of t.errors)console.error(` asset failed \u2014 ${e} (a re-pull retries just the missing ones)`);t.errors.length&&(process.exitCode=1)}}var g_,Ma,tf,Da,ti,rf,Fa=S(()=>{"use strict";Ze();Z();xt();g_="https://typebulb.com",Ma=(t,e)=>qe.join("typebulbs","u",t,`${e}.bulb.md`),tf=t=>`${t.origin}/u/${encodeURIComponent(t.userSlug)}/${encodeURIComponent(t.slug)}.md`,Da=t=>t.split("/").map(encodeURIComponent).join("/"),ti=t=>`${t.origin}/u/${encodeURIComponent(t.userSlug)}/${encodeURIComponent(t.slug)}/assets`;rf=t=>m_("md5").update(t).digest("hex")});import*as lt from"fs/promises";import*as ni from"path";async function Ew(t,e=""){let n=await lt.readdir(t,{withFileTypes:!0}).catch(()=>[]),r=[];for(let s of n)s.isDirectory()?r.push(...await Ew(ni.join(t,s.name),`${e}${s.name}/`)):s.isFile()&&r.push(e+s.name);return r}async function v_(t,e){let n=e.timeoutMs??3e4,r=ti(t),s={Authorization:`Bearer ${e.token}`},i=Pn(t.dest);if(!await lt.stat(i).then(h=>h.isDirectory()).catch(()=>!1))return{kind:"skipped"};let o=await Ew(i),a=await sf(t,{token:e.token,timeoutMs:n});if("error"in a)return{kind:"sync-error",message:a.error};let l=a.entries;if(!o.length&&!l.length)return{kind:"skipped"};let c=new Map(l.map(h=>[h.path,h.md5])),u=new Set(o),d=l.map(h=>h.path).filter(h=>!u.has(h)),f=0,p=0;try{await nf(o,4,async h=>{let m=await lt.readFile(ni.join(i,...h.split("/")));if(c.get(h)===rf(m)){p++;return}let g=await fetch(`${r}/${Da(h)}`,{method:"PUT",body:new Uint8Array(m),headers:s,signal:AbortSignal.timeout(n)});if(!g.ok)throw new Error(`upload of '${h}' refused (${g.status}): ${_r(await g.text())}`);f++})}catch(h){return{kind:"sync-error",message:h instanceof Error?h.message:String(h)}}return{kind:"synced",uploaded:f,unchanged:p,toDelete:d,base:_i(t.userSlug,t.slug)}}async function S_(t,e,n){let r=n.timeoutMs??3e4,s=ti(t),i=[];for(let o of e)try{let a=await fetch(`${s}/${Da(o)}`,{method:"DELETE",headers:{Authorization:`Bearer ${n.token}`},signal:AbortSignal.timeout(r)});if(!a.ok)return{deleted:i,error:`delete of '${o}' refused (${a.status}): ${_r(await a.text())}`};i.push(o)}catch(a){return{deleted:i,error:a instanceof Error?a.message:String(a)}}return{deleted:i}}async function Ua(t,e){let n=await lt.readFile(t.dest,"utf-8"),{mtime:r}=await lt.stat(t.dest),s=await v_(t,{token:e.token,timeoutMs:e.timeoutMs});if(s.kind==="sync-error")return{kind:"asset-error",message:s.message};let i=s.kind==="synced"?{uploaded:s.uploaded,unchanged:s.unchanged,deleted:[],base:s.base}:void 0,o={Authorization:`Bearer ${e.token}`,"Content-Type":"text/markdown; charset=utf-8"};e.force||(o["If-Unmodified-Since"]=r.toUTCString());let a=await fetch(tf(t),{method:"PUT",body:n,headers:o,signal:e.timeoutMs?AbortSignal.timeout(e.timeoutMs):void 0}),l=await a.text();if(a.status===409)return{kind:"conflict",message:_r(l),assets:i};if(!a.ok)return{kind:"http-error",status:a.status,message:_r(l),assets:i};let c=JSON.parse(l);if(await lt.utimes(t.dest,new Date,new Date(c.updatedAt)),i&&s.kind==="synced"&&s.toDelete.length){let u=await S_(t,s.toDelete,{token:e.token,timeoutMs:e.timeoutMs});i.deleted=u.deleted,u.error&&(i.pruneError=u.error)}return{kind:"pushed",created:c.created,serverStripped:c.serverStripped,updatedAt:c.updatedAt,assets:i}}async function Aw(t,e){t||(console.error("Usage: typebulb push <typebulbs/u/<user>/<slug>.bulb.md>"),process.exit(1)),/^https?:\/\//i.test(t)&&(console.error("push takes a local .bulb.md file, not a URL (the path is its remote identity)"),process.exit(1));let n=of(t,e.mode),r=process.env.TYPEBULB_TOKEN;r||(console.error("push needs TYPEBULB_TOKEN in your .env \u2014 create one on your typebulb.com settings page."),process.exit(1));let s=`${n.origin}/u/${n.userSlug}/${n.slug}`,i=ni.relative(process.cwd(),n.dest)||n.dest,o;try{o=await Ua(n,{token:r,force:e.force})}catch(a){let l=a instanceof Error?a.message:String(a);console.error(a?.code==="ENOENT"?`File not found: ${i}`:`Could not push to ${n.origin}: ${l}`),process.exitCode=1;return}switch(o.kind!=="asset-error"&&o.assets&&console.log(`assets: ${o.assets.uploaded} uploaded, ${o.assets.unchanged} unchanged \u2192 ${o.assets.base}`),o.kind){case"asset-error":console.error(`assets sync failed: ${o.message}
|
|
1738
1749
|
push refused: the bulb text was not pushed.`),process.exitCode=1;return;case"pushed":{console.log(`pushed ${i} \u2192 ${s}/full`),o.created&&(console.log(" created a new bulb, unlisted \u2014 nothing existed at this URL before"),console.log(" if you renamed this file, its previous bulb is still live at the old URL")),o.serverStripped&&console.log("note: the server.ts block was stripped on the server copy (CLI-only); your local file is untouched.");for(let a of o.assets?.deleted??[])console.log(` deleted ${a} (no longer in assets/)`);o.assets?.pruneError&&console.log(`note: asset cleanup incomplete \u2014 ${o.assets.pruneError}; the next push will retry.`);return}case"conflict":console.error(`${o.message}
|
|
1739
1750
|
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
|
|
1751
|
+
or overwrite it: typebulb push ${i} --force`),process.exitCode=1;return;case"http-error":o.status===401?console.error("The server rejected TYPEBULB_TOKEN (401) \u2014 it may be revoked; mint a new one on the settings page."):console.error(`Push failed: ${n.origin} responded ${o.status}${o.message?` \u2014 ${o.message}`:""}`),process.exitCode=1}}var af=S(()=>{"use strict";Z();Fa();xt()});var Rr=S(()=>{"use strict";je();bb();mn();wb();dd();Eb();Tb();Bs();kn();kn();ga();Md();je();Fa();af();Ze();Be()});import{existsSync as k_,mkdirSync as x_,readFileSync as E_,rmSync as A_,writeFileSync as T_}from"fs";import{homedir as C_}from"os";import*as Ir from"path";function R_(){return __.replace('"__TB_SKILL_PATH__"',JSON.stringify(qs())).replace('"__TB_BIN_PATH__"',JSON.stringify(ur()))}function Tw(){try{if(!k_(lf()))return}catch{return}try{let t=O_(),e=R_(),n;try{n=E_(t,"utf8")}catch{}n!==e&&(x_(Ir.dirname(t),{recursive:!0}),T_(t,e))}catch{}for(let t of P_())try{A_(t,{force:!0})}catch{}}var lf,O_,P_,__,Cw=S(()=>{"use strict";Rr();lf=()=>Ir.join(C_(),".pi","agent"),O_=()=>Ir.join(lf(),"extensions","typebulb.ts"),P_=()=>["typebulb-wait.ts","matchu-patchu.ts"].map(t=>Ir.join(lf(),"extensions",t)),__=String.raw`// Generated by typebulb — do not edit; overwritten on each run.
|
|
1741
1752
|
import { spawn } from "node:child_process";
|
|
1742
1753
|
import { existsSync } from "node:fs";
|
|
1743
1754
|
|
|
@@ -2005,23 +2016,23 @@ export default function (pi) {
|
|
|
2005
2016
|
try { pi.on("session_shutdown", () => { stopping = true; if (watcher) { try { watcher.kill(); } catch (e) {} watcher = null; } for (const c of pending) { try { c.kill(); } catch (e) {} } pending.clear(); }); } catch (e) {}
|
|
2006
2017
|
} catch (e) { logErr("load", e && e.message); }
|
|
2007
2018
|
}
|
|
2008
|
-
`});function
|
|
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
|
|
2011
|
-
`)}catch{}}#
|
|
2012
|
-
`),tool:e?.kind==="tool"?e.name:void 0}}#A(e){let n=Array.isArray(e?.content)?e.content:[];this.#
|
|
2013
|
-
`)}catch(l){clearTimeout(a),this.#
|
|
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
|
|
2019
|
-
|
|
2020
|
-
${t.slice(0,
|
|
2021
|
-
|
|
2019
|
+
`});function V(t){return t?.message??String(t)}var X,Gt=S(()=>{"use strict";X=process.cwd()});import{spawn as Ow}from"child_process";import{StringDecoder as I_}from"string_decoder";function B_(t,e){let n=new I_("utf8"),r="";t.on("data",s=>{r+=typeof s=="string"?s:n.write(s);let i;for(;(i=r.indexOf(`
|
|
2020
|
+
`))>=0;){let o=r.slice(0,i);r=r.slice(i+1),o.endsWith("\r")&&(o=o.slice(0,-1)),o&&e(o)}})}var $_,Pw,_w,cf,Rw,N_,L_,M_,Iw,D_,qa,Ja,$w,Nw=S(()=>{"use strict";Gt();$_=3e4,Pw=18e4,_w="starting pi\u2026",cf=5e3,Rw=2e3,N_=2e3,L_=12e4,M_=8e3,Iw=15e3,D_=new Set(["get_state","get_commands","get_available_models","set_model","set_thinking_level","cycle_thinking_level","get_session_stats","compact","set_auto_compaction","get_fork_messages","fork","clone","set_session_name","export_html","bash","abort_bash"]),qa=new Set;process.on("exit",()=>{for(let t of qa)try{t.kill()}catch{}});Ja=class{#t;#o=!1;#e=0;#s=!1;#u=0;#n=!1;#c=null;#a=[];#d=null;#r=null;#i=null;#f=new Map;#l=[];#b=null;#k=null;#w=null;#m;#g;#v="";#_=1;#p=new Map;#x;#S;constructor(e,n,r=(s,i)=>Ow(s,{cwd:i,shell:!0,stdio:["pipe","pipe","pipe"],env:{...process.env,TYPEBULB_MIRROR:"1"}})){if(this.#x=new Promise(o=>{this.#S=o}),n?.includes('"')){this.#g="session path contains a quote \u2014 cannot drive it",this.#S();return}let s=n?`pi --mode rpc --session "${n}"`:"pi --mode rpc",i;try{i=r(s,e)}catch(o){this.#g=`could not start pi: ${V(o)}`,this.#S();return}this.#t=i,this.#m=n,this.#s=!0,this.#u=Date.now()+Pw,this.#r={text:_w,kind:"info"},qa.add(i),i.stdout&&B_(i.stdout,o=>this.#I(o)),i.stderr&&i.stderr.on("data",o=>{this.#v=(this.#v+o.toString()).slice(-N_)}),i.on("error",o=>this.#O(`could not start pi: ${o.message}`)),i.on("exit",o=>{this.#t===i&&this.#O(o?`pi exited (code ${o})${this.#v.trim()?`: ${this.#v.trim()}`:""}`:"pi exited"),qa.delete(i),this.#S()}),this.#h({type:"get_state"}).then(o=>{let a=o.data?.sessionFile;typeof a=="string"&&a&&(this.#m=a);let l=o.data?.model;l&&typeof l.id=="string"&&l.id&&(this.#w=l.id)}).catch(()=>{}).finally(()=>this.#R())}#R(){this.#s&&(this.#s=!1,this.#r?.text===_w&&(this.#r=null),this.#i&&(this.#i.until=Date.now()+Iw),!this.#o&&Date.now()<this.#e&&(this.#e=Date.now()+cf),this.#T())}get streaming(){return this.#o||Date.now()<this.#e}get draft(){return this.#c}get echo(){return this.#d}get queue(){return this.#b}get stats(){return this.#k}get model(){return this.#w}get sessionFile(){return this.#m}get error(){return this.#g}get status(){if(this.#r)return this.#r;if(this.#i){if(Date.now()<this.#i.until)return{text:this.#i.text,kind:this.#i.kind};this.#i=null}return this.#f.size?{text:[...this.#f.values()].join(" \xB7 "),kind:"info"}:null}get dialog(){let e=Date.now();for(;this.#l.length;){let n=this.#l[0];if(e<n.until)return n.req;this.#l.shift(),n.ownTimeout||this.#E({type:"extension_ui_response",id:n.req.id,cancelled:!0})}return null}notice(e,n){this.#y(e,n)}respondUi(e,n){let r=this.#l.findIndex(o=>o.req.id===e);if(r<0)return{ok:!1,error:"dialog expired or already answered"};let[s]=this.#l.splice(r,1),i={type:"extension_ui_response",id:e};return n.cancelled?i.cancelled=!0:s.req.method==="confirm"?i.confirmed=!!n.confirmed:i.value=n.value??"",this.#E(i),{ok:!0}}async rpc(e){if(!D_.has(e.type))return{ok:!1,error:`command not allowed: ${e.type}`};try{let n=await this.#h(e);if(n.success&&e.type==="set_model"){let r=n.data?.id;typeof r=="string"&&r&&(this.#w=r)}if(n.success&&(e.type==="fork"||e.type==="clone")){try{let s=(await this.#h({type:"get_state"})).data?.sessionFile;typeof s=="string"&&s&&(this.#m=s)}catch{}return{ok:!0,data:{...n.data??{},sessionFile:this.#m}}}return n.success?{ok:!0,data:n.data}:{ok:!1,error:n.error??`pi rejected ${e.type}`}}catch(n){return{ok:!1,error:V(n)}}}async send(e,n){let r=this.streaming,s=e.trimStart().startsWith("/"),i=r?s?{type:"prompt",message:e,streamingBehavior:n?.followUp?"followUp":"steer"}:{type:n?.followUp?"follow_up":"steer",message:e}:{type:"prompt",message:e},o=l=>{r||(this.#e=l,s||(this.#d=e))};if(this.#s)return this.#h(i).catch(()=>{}),o(this.#u+cf),{ok:!0};let a;try{a=await this.#h(i)}catch(l){return{ok:!1,error:V(l)}}return a.success&&o(Date.now()+cf),a.success?{ok:!0}:{ok:!1,error:a.error??"pi rejected the message"}}async stop(){if(this.#t){if(this.#s){this.#E({type:"abort"}),this.#e=0;return}try{await this.#h({type:"abort"})}catch{}}}clearCompletedDraft(){this.#n||(this.#c=null)}clearEcho(){this.#d=null}async dispose(){let e=this.#t;if(e){if(this.#t=void 0,this.#s=!1,this.#o){try{e.stdin?.write(JSON.stringify({type:"abort"})+`
|
|
2021
|
+
`)}catch{}await Promise.race([this.#x,$w(Rw)])}try{e.stdin?.end()}catch{}if(await Promise.race([this.#x,$w(Rw)]),e.exitCode===null&&!e.killed)if(process.platform==="win32"&&e.pid)try{Ow("taskkill",["/pid",String(e.pid),"/T","/F"],{stdio:"ignore"})}catch{}else try{e.kill("SIGKILL")}catch{}qa.delete(e),this.#l=[],this.#P("pi was shut down")}}#E(e){try{this.#t?.stdin?.write(JSON.stringify(e)+`
|
|
2022
|
+
`)}catch{}}#C(){let e=this.#a[this.#a.length-1];this.#c={text:this.#a.filter(n=>n?.kind==="text").map(n=>n.text).join(""),thinking:this.#a.filter(n=>n?.kind==="thinking").map(n=>n.text).join(`
|
|
2023
|
+
`),tool:e?.kind==="tool"?e.name:void 0}}#A(e){let n=Array.isArray(e?.content)?e.content:[];this.#a=n.map(r=>({kind:r.type==="thinking"?"thinking":r.type==="toolCall"?"tool":"text",text:(r.type==="thinking"?r.thinking:r.text)??"",name:r.name})),this.#C()}#y(e,n){let r=e.length>200?e.slice(0,200)+"\u2026":e;r&&(this.#i={text:r,kind:n,until:Date.now()+(n==="info"?M_:Iw)})}#T(){this.#h({type:"get_session_stats"}).then(e=>{if(!e.success||!e.data)return;let n=e.data;this.#k={cost:typeof n.cost=="number"?n.cost:0,contextTokens:typeof n.contextUsage?.tokens=="number"?n.contextUsage.tokens:null,contextPercent:typeof n.contextUsage?.percent=="number"?n.contextUsage.percent:null}}).catch(()=>{})}#h(e){let n=this.#t;if(!n?.stdin?.writable)return Promise.reject(new Error(this.#g??"pi is not running"));let r=this.#s?Pw:$_,s=`tb-${this.#_++}`;return new Promise((i,o)=>{let a=setTimeout(()=>{this.#p.delete(s),o(new Error(`pi did not respond (${Math.round(r/1e3)}s)`))},r);a.unref?.(),this.#p.set(s,{resolve:i,timer:a});try{n.stdin.write(JSON.stringify({id:s,...e})+`
|
|
2024
|
+
`)}catch(l){clearTimeout(a),this.#p.delete(s),o(new Error(V(l)))}})}#I(e){let n;try{n=JSON.parse(e)}catch{return}switch(n.type){case"response":{let r=n,s=r.id?this.#p.get(r.id):void 0;s&&(this.#p.delete(r.id),clearTimeout(s.timer),s.resolve(r));return}case"agent_start":this.#o=!0,this.#e=0;return;case"agent_end":this.#o=!1,this.#e=0,this.#n=!1,this.#r=null,this.#b=null,this.#T();return;case"message_start":{let r=n.message;if(r?.role!=="assistant")return;this.#n=!0,this.#A(r);return}case"message_update":{if(!this.#n)return;if(n.message){this.#A(n.message);return}let r=n.assistantMessageEvent;if(!r||typeof r.contentIndex!="number")return;let s=r.type.startsWith("thinking")?"thinking":r.type.startsWith("toolcall")?"tool":"text",i=this.#a[r.contentIndex]??={kind:s,text:""};i.kind=s,typeof r.delta=="string"&&s!=="tool"&&(i.text+=r.delta),typeof r.content=="string"&&(i.text=r.content),r.toolCall?.name&&(i.name=r.toolCall.name),this.#C();return}case"message_end":if(!this.#n)return;n.message&&this.#A(n.message),this.#n=!1;return;case"auto_retry_start":this.#r={text:`retrying after a transient error (attempt ${Number(n.attempt)||1}/${Number(n.maxAttempts)||"?"})\u2026`,kind:"warning"};return;case"auto_retry_end":this.#r=null,n.success===!1&&this.#y(`retries exhausted: ${String(n.finalError??"unknown error")}`,"error");return;case"compaction_start":this.#r={text:"compacting context\u2026",kind:"info"};return;case"compaction_end":{this.#r=null;let r=n.result;typeof n.errorMessage=="string"&&n.errorMessage?this.#y(`compaction failed: ${n.errorMessage}`,"error"):r?.tokensBefore&&this.#y(`compacted: ~${Math.round(r.tokensBefore/1e3)}k \u2192 ~${Math.round((r.estimatedTokensAfter??0)/1e3)}k tokens`,"info"),this.#T();return}case"queue_update":{let r=Array.isArray(n.steering)?n.steering.map(String):[],s=Array.isArray(n.followUp)?n.followUp.map(String):[];this.#b=r.length||s.length?{steering:r,followUp:s}:null;return}case"extension_ui_request":{let r=String(n.method??"");if(r==="select"||r==="confirm"||r==="input"||r==="editor"){let s=typeof n.timeout=="number"&&n.timeout>0?n.timeout:void 0;this.#l.push({req:{id:String(n.id??""),method:r,title:typeof n.title=="string"?n.title:void 0,message:typeof n.message=="string"?n.message:void 0,options:Array.isArray(n.options)?n.options.map(String):void 0,placeholder:typeof n.placeholder=="string"?n.placeholder:void 0,prefill:typeof n.prefill=="string"?n.prefill:void 0},until:Date.now()+(s??L_),ownTimeout:s!==void 0})}else if(r==="notify"){let s=n.notifyType==="warning"?"warning":n.notifyType==="error"?"error":"info";this.#y(String(n.message??""),s),console.log(`[composer] pi extension: ${String(n.message??"")}`)}else if(r==="setStatus"){let s=String(n.statusKey??"");typeof n.statusText=="string"&&n.statusText?this.#f.set(s,n.statusText):this.#f.delete(s)}return}default:return}}#O(e){this.#g=e,this.#s=!1,this.#o=!1,this.#e=0,this.#n=!1,this.#c=null,this.#a=[],this.#d=null,this.#r=null,this.#i=null,this.#f.clear(),this.#l=[],this.#b=null,this.#k=null,this.#w=null,this.#t=void 0,this.#P(e)}#P(e){for(let[,n]of this.#p)clearTimeout(n.timer),n.resolve({type:"response",success:!1,error:e});this.#p.clear()}},$w=t=>new Promise(e=>{setTimeout(e,t).unref?.()})});import{existsSync as Lw,readFileSync as j_,realpathSync as F_}from"fs";import{join as _n,dirname as jw,resolve as U_}from"path";import{homedir as Mw}from"os";function J_(t,e){let n=_n(t,".pi");if(q_.some(s=>Lw(_n(n,s))))return!0;let r=_n(e,".agents","skills");for(let s=t;;){let i=_n(s,".agents","skills");if(i!==r&&Lw(i))return!0;let o=jw(s);if(o===s)return!1;s=o}}function W_(t,e){for(let n=e;;){if(t[n]===!0||t[n]===!1)return!0;let r=jw(n);if(r===n)return!1;n=r}}function Fw(t,e){try{let n=e?.agentDir??_n(Mw(),".pi","agent"),r=Dw(e?.home??process.env.HOME??Mw()),s=Dw(U_(t));if(!J_(s,r))return null;let i=Bw(_n(n,"settings.json")).defaultProjectTrust;return i==="always"||i==="never"||W_(Bw(_n(n,"trust.json")),s)?null:"pi has no trust decision for this project \u2014 running untrusted; run `pi` once in a terminal to grant it"}catch{return null}}var q_,Dw,Bw,Uw=S(()=>{"use strict";q_=["settings.json","extensions","skills","prompts","themes","SYSTEM.md","APPEND_SYSTEM.md"],Dw=t=>{try{return F_(t)}catch{return t}},Bw=t=>{try{return JSON.parse(j_(t,"utf8"))}catch{return{}}}});import{statSync as K_,openSync as H_,readSync as z_,closeSync as Y_,existsSync as Jw}from"fs";import{join as Wa}from"path";import{homedir as uf}from"os";import{execFile as V_}from"child_process";async function X_(t){let e=Wa(uf(),".pi","agent","bin",process.platform==="win32"?"fd.exe":"fd");for(let n of["fd","fdfind",...Jw(e)?[e]:[]]){let r=await new Promise(s=>{V_(n,["--base-directory",t,"--type","f","--follow","--hidden","--exclude",".git"],{maxBuffer:67108864},(i,o)=>s(i?null:o))});if(r!==null)return r.split(`
|
|
2025
|
+
`).filter(Boolean).map(s=>s.replace(/\\/g,"/"))}return null}function Q_(t){return`--${t.replace(/^[/\\]/,"").replace(/[/\\:]/g,"-")}--`}function qw(t){return t.type==="message"?Z_(t.message?.role):t.type==="custom_message"?t.display!==!1:!1}var G_,Z_,$r,df=S(()=>{"use strict";Cs();Mo();Do();Cw();Nw();Uw();G_=Wa(uf(),".pi","agent","sessions");Z_=t=>t==="user"||t==="assistant"||t==="toolResult"||t==="bashExecution";$r=class extends Ft{displayName="Pi Mirror";detectsSelf(){return process.env.PI_CODING_AGENT==="true"}detectsInstalled(){return Jw(Wa(uf(),".pi","agent"))}ensureHarnessSupport(){Tw()}createDriver(e,n){let r=new Ja(e,n),s=Fw(e);return s&&r.notice(s,"warning"),r}walkFiles(e){return X_(e)}sessionsDir(e){return Wa(G_,Q_(e))}listSessionFiles(e){return Lo(this.sessionsDir(e))}parseEntry(e){let n;try{n=JSON.parse(e)}catch{return null}return!n||n.type==="session"||!n.id?null:n}idOf(e){return e.id}parentOf(e){return e.parentId??void 0}timestampOf(e){return e.timestamp}isSidechain(e){return!1}isLeafType(e){return qw(e)}isRecoveryNoise(e){return!1}apply(e,n){let r=[];if(e.type==="custom_message"){if(e.display===!1)return{events:r};let i=this.contentText(e.content).trim();return i&&r.push({type:"user",text:i}),{events:r}}if(e.type!=="message"||!e.message)return{events:r};let s=e.message;if(s.role==="user"){let i=this.contentText(s.content).trim();return i&&r.push({type:"user",text:i}),{events:r}}if(s.role==="toolResult"){let i=this.contentText(s.content);return r.push({type:"tool_result",id:s.toolCallId??"",content:i,isError:!!s.isError,digest:De(i)}),{events:r}}if(s.role==="bashExecution")return s.command&&!s.excludeFromContext&&r.push({type:"user",text:`$ ${s.command}`}),{events:r};if(s.role==="assistant"){let i=Array.isArray(s.content)?s.content:[],o=i.filter(f=>f.type==="text").map(f=>f.text??"").join(""),a=i.filter(f=>f.type==="thinking").map(f=>f.thinking??"").join(`
|
|
2026
|
+
`),l=i.filter(f=>f.type==="toolCall").map(f=>({id:f.id??"",name:f.name??"",input:f.arguments??{}}));if(o||a||l.length){let f=Date.parse(e.timestamp??""),p=!isNaN(f)&&f>=n;r.push({type:"assistant",text:o,thinking:a,tools:l,live:p})}let c=s.usage,u=c?(c.input??0)+(c.output??0)+(c.cacheRead??0)+(c.cacheWrite??0):0,d=c&&u>0&&s.stopReason!=="aborted"&&s.stopReason!=="error"?{in:c.input??0,out:c.output??0,cached:c.cacheRead??0,cacheCreate:c.cacheWrite??0}:void 0;return{events:r,usage:d,model:s.model,cost:c?.cost?.total}}return{events:r}}chainWorking(e){let n;for(let a of e)qw(a)&&(n=a);if(!n||n.type==="custom_message")return!1;let r=n.message.role;if(r==="user"||r==="toolResult"||r==="bashExecution")return!0;if(r!=="assistant")return!1;let i=(Array.isArray(n.message.content)?n.message.content:[]).filter(a=>a.type==="toolCall").map(a=>a.id);if(!i.length)return!1;let o=new Set;for(let a of e)a.type==="message"&&a.message?.role==="toolResult"&&a.message.toolCallId&&o.add(a.message.toolCallId);return i.some(a=>a&&!o.has(a))}sessionAlive(){}readPreview(e){let n;try{n=H_(e,"r")}catch{return""}try{let s=65536;try{s=K_(e).size}catch{}let i=(d,f)=>{let p=Buffer.alloc(f),h=z_(n,p,0,f,d);return p.subarray(0,h).toString("utf8")},o=i(0,Math.min(65536,s)),a=s>65536?i(s-65536,65536):"",l=d=>{let f="";for(let p of d.split(`
|
|
2027
|
+
`))if(p.includes('"session_info"'))try{let h=JSON.parse(p);h?.type==="session_info"&&typeof h.name=="string"&&h.name&&(f=h.name)}catch{}return f},c="";for(let d of o.split(`
|
|
2028
|
+
`))if(!(c||!d.includes('"type"')))try{let f=JSON.parse(d);f?.type==="message"&&f.message?.role==="user"&&(c=this.contentText(f.message.content).replace(/\s+/g," ").trim())}catch{}let u=l(a)||l(o)||c;return u?u.slice(0,200):""}finally{Y_(n)}}searchText(e){if(e?.type!=="message")return"";let n=e.message?.role;if(n!=="user"&&n!=="assistant")return"";let r=e.message?.content,s="";return typeof r=="string"?s=r:Array.isArray(r)&&(s=r.filter(i=>i.type==="text"&&typeof i.text=="string").map(i=>i.text).join(" ")),s.replace(/\s+/g," ").trim()}contentText(e){return typeof e=="string"?Pe(e):Array.isArray(e)?e.map(n=>typeof n?.text=="string"?Pe(n.text):n?.type==="image"&&n.data?$o(n.data,n.mimeType):"").filter(Boolean).join(`
|
|
2029
|
+
`):""}}});var Ka,Ww=S(()=>{"use strict";Ka=class{#t=new Map;accept(e,n){return this.#t.get(e)===n?!1:(this.#t.set(e,n),!0)}}});import{execFile as eR}from"child_process";import{promisify as tR}from"util";import{readFile as nR}from"fs/promises";import{resolve as Kw,sep as rR}from"path";async function we(t,e){let{stdout:n}=await sR("git",t,{cwd:e,maxBuffer:67108864});return n}async function Rn(){if(Ha)return Ha;try{Ha=(await we(["rev-parse","--show-toplevel"],X)).trim()}catch{}return Ha}function iR(t,e){let n=e===" "?t:e;return n==="?"?"U":n}async function pf(){let t=await Rn();if(!t)return{repo:!1,root:"",files:[]};try{let e=await we(["status","--porcelain","-z"],t),n=[],r=e.split("\0");for(let s=0;s<r.length;s++){let i=r[s];i.length<4||((i[0]==="R"||i[0]==="C")&&s++,n.push({path:i.slice(3),status:iR(i[0],i[1])}))}try{let s=await we(["diff","--numstat","-z","HEAD"],t),i=new Map,o=s.split("\0");for(let a=0;a<o.length;a++){let l=/^(\d+|-)\t(\d+|-)\t(.*)$/.exec(o[a]);if(!l)continue;let c=l[3]||o[a+=2];c&&i.set(c,{add:+l[1]||0,del:+l[2]||0,binary:l[1]==="-"})}for(let a of n){let l=i.get(a.path);l&&(l.binary?a.binary=!0:(a.add=l.add,a.del=l.del))}}catch{}return n.sort((s,i)=>s.path.localeCompare(i.path)),{repo:!0,root:t,files:n}}catch(e){return{repo:!1,root:"",files:[],error:V(e)}}}async function hf(t){let e=await Rn();if(!e)return{ok:!1,error:"not a git repository"};try{if((await we(["status","--porcelain","-z","--",t],e)).startsWith("??")){let s=Kw(e,t);if(!s.startsWith(Kw(e)+rR))return{ok:!1,error:"outside repository"};let i=await nR(s);return i.includes(0)?ff("Binary file (not shown)",!1):ff(i.toString("utf8"),!0)}let r;try{r=await we(["diff","--no-color","--unified=999999","HEAD","--",t],e)}catch{r=await we(["diff","--no-color","--unified=999999","--",t],e)}return ff(r,!1)}catch(n){return{ok:!1,error:V(n)}}}var sR,Hw,Ha,ff,Nr=S(()=>{"use strict";Gt();sR=tR(eR),Hw=2e6;ff=(t,e)=>({ok:!0,text:t.slice(0,Hw),untracked:e,truncated:t.length>Hw})});function ri(t,e){let n=0,r="";for(let s of t){let i=s.lower.indexOf(e);if(!(i<0)&&(n++,!r)){let o=Math.max(0,i-110),a=Math.min(s.text.length,i+e.length+110);r=(o>0?"\u2026":"")+s.text.slice(o,a)+(a<s.text.length?"\u2026":"")}}return{hitCount:n,snippet:r}}var mf=S(()=>{"use strict"});function zw(){return oR.map(([t,e])=>bt(t,e)).filter(t=>typeof t!="string")}function Yw(){return zw().length>0}async function za(t,e,n=0){let r=AbortSignal.timeout(e);for(let s of zw()){try{let i=await Wt(s,{messages:[{role:"user",content:t}],effort:n,webSearch:!1,signal:r});if(i.ok){let o=(await _d(i,s.protocol)).trim();if(o)return o}}catch{}if(r.aborted)return}}var oR,gf=S(()=>{"use strict";qt();Rr();oR=[["openrouter","openai/gpt-6-luna"],["openai","gpt-6-luna"]]});var Ya,Va,Et,Lr=S(()=>{"use strict";Ya=".typebulb/paste",Va={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",bmp:"image/bmp"},Et=t=>t.label||t.kind||"agent"});import{existsSync as aR,mkdirSync as lR,writeFileSync as cR,readFileSync as uR}from"fs";import{join as Ga}from"path";function Vw(){let t=new Date,e=n=>String(n).padStart(2,"0");return`${t.getFullYear()}${e(t.getMonth()+1)}${e(t.getDate())}-${e(t.getHours())}${e(t.getMinutes())}${e(t.getSeconds())}`}function pR(t){return t.trim().toLowerCase().replace(/\.[a-z0-9]{1,4}$/,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)}async function hR(t){let e=await za(`Reply with ONLY a short kebab-case filename (2-5 words, lowercase, no extension) describing this text:
|
|
2030
|
+
|
|
2031
|
+
${t.slice(0,fR)}`,dR);return e&&pR(e)||void 0}async function Gw(t,e){if(!e||e.kind!=="image"&&e.kind!=="text")return{ok:!1,error:"bad paste kind"};if(typeof e.data!="string"||!e.data)return{ok:!1,error:"empty paste"};let n=Ga(t,Ya);try{lR(n,{recursive:!0})}catch(a){return{ok:!1,error:V(a)}}let r,s,i;if(e.kind==="image"){if(r=`img-${Vw()}`,s=Object.keys(Va).find(a=>Va[a]===e.mime)??"png",i=Buffer.from(e.data,"base64"),!i.length)return{ok:!1,error:"empty image data"}}else r=await hR(e.data)??`paste-${Vw()}`,s="md",i=e.data;let o=`${r}.${s}`;for(let a=2;aR(Ga(n,o));a++)o=`${r}-${a}.${s}`;try{cR(Ga(n,o),i)}catch(a){return{ok:!1,error:V(a)}}return{ok:!0,path:`${Ya}/${o}`}}function Xw(t,e){if(!/^[\w-]+(\.[\w-]+)*$/.test(e))return{ok:!1,error:"bad name"};let n=e.slice(e.lastIndexOf(".")+1).toLowerCase(),r=Va[n];if(!r)return{ok:!1,error:"not an image"};try{return{ok:!0,mime:r,base64:uR(Ga(t,Ya,e)).toString("base64")}}catch{return{ok:!1,error:"not found"}}}var dR,fR,Qw=S(()=>{"use strict";gf();Gt();Lr();dR=4e3,fR=4e3});async function tv(t,e=""){let n=t.trim();if(!n)return{ok:!1,error:"nothing to summarize"};if(!Yw())return yR;let r=e.trim()?ev+`CONTEXT \u2014 the user message this reply answers. It is context only: never summarize it, and never report it as the reply's content.
|
|
2032
|
+
`+gR(e.trim())+`
|
|
2022
2033
|
|
|
2023
2034
|
REPLY TO SUMMARIZE:
|
|
2024
|
-
`+n.slice(0,
|
|
2035
|
+
`+n.slice(0,Zw):ev+n.slice(0,Zw),s=await za(r,mR,1);return s?{ok:!0,text:s}:bR}var mR,Zw,ev,gR,yR,bR,nv=S(()=>{"use strict";gf();mR=2e4,Zw=24e3,ev=`Summarize this assistant reply for someone who wants its substance without the prose.
|
|
2025
2036
|
|
|
2026
2037
|
- Markdown. Start with the direct answer, recommendation, result, or status. If it is qualified, put the qualification in that same opening sentence; do not make the reader infer it from later bullets.
|
|
2027
2038
|
- Preserve material limits and conditions that change the answer: exceptions, tradeoffs, prerequisites, uncertainty, incomplete validation, and clauses such as but, only when, unless, or if. Cut only filler hedges (for example, "I think" or "arguably") that change nothing.
|
|
@@ -2036,74 +2047,33 @@ Reply with the summary alone.
|
|
|
2036
2047
|
|
|
2037
2048
|
---
|
|
2038
2049
|
|
|
2039
|
-
|
|
2050
|
+
`,gR=(t,e=4e3)=>{if(t.length<=e)return t;let n=Math.floor(e/2)-20;return t.slice(0,n)+`
|
|
2040
2051
|
|
|
2041
2052
|
[snipped for brevity]
|
|
2042
2053
|
|
|
2043
|
-
`+t.slice(t.length-n)},
|
|
2044
|
-
{"
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
`)}
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
{"
|
|
2059
|
-
"
|
|
2060
|
-
|
|
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(`
|
|
2054
|
+
`+t.slice(t.length-n)},yR={ok:!1,error:"Summary needs OPENROUTER_API_KEY or OPENAI_API_KEY in this project\u2019s .env.",setup:!0},bR={ok:!1,error:"the model call failed or timed out"}});import{readFileSync as wR,statSync as vR}from"fs";function Xa(t,e,n,r){let s=t.apply(e,r),i=Date.parse(t.timestampOf(e)??""),o=s.events.map(a=>{let l=n==="child"&&a.type==="user"?{...a,authored:!0}:a;return!isNaN(i)&&(l.type==="user"||l.type==="assistant"||l.type==="tool_result"||l.type==="task_done"||l.type==="turn_end")&&(l.at=i),l});return{...s,events:o}}function Qa(t){let e=new Map,n=t.linker();return{entries:e,add(r,s){let i;for(let o of r){if(!o.trim())continue;let a=t.parseEntry(o);if(!a)continue;n.link(a);let l=t.idOf(a);l&&(e.set(l,a),!t.isSidechain(a,s)&&t.isLeafType(a)&&(i=l))}return i}}}function rv(t,e,n){let r=t.forRead(),s;try{s=wR(e,"utf8")}catch{return[]}let{entries:i,add:o}=Qa(r),a=o(s.split(`
|
|
2055
|
+
`),n),l=[],c=new Set;for(let f=a;f&&!c.has(f);){let p=i.get(f);if(!p)break;c.add(f),l.push(p),f=r.parentOf(p)}let u=[],d=Date.now();for(let f of l.reverse())if(!r.isSidechain(f,n))try{u.push(...Xa(r,f,n,d).events)}catch{}return u}function Za(t,e,n,r){let s=t.sessionAlive(e,n);if(s!==void 0)return s;if(!r)return!1;try{return Date.now()-vR(r).mtimeMs<1e4}catch{return!1}}function si(t,e){return t.stopped?"stopped":t.running&&e?"running":"done"}var yf=S(()=>{"use strict"});function SR(t,...e){return t.slice().sort((n,r)=>{for(let{key:s,desc:i}of e){let o=s(n),a=s(r);if(o!==a)return o==null?i?-1:1:a==null||o<a?i?1:-1:i?-1:1}return 0})}function sv(t){let e=new Set(t.map(o=>o.id)),n=new Map;for(let o of t){let a=o.parentId&&e.has(o.parentId)?o.parentId:"",l=n.get(a);l?l.push(o):n.set(a,[o])}let r=[],s=new Set,i=o=>{for(let a of n.get(o)??[])s.has(a.id)||(s.add(a.id),r.push(a),i(a.id))};i("");for(let o of t)s.has(o.id)||r.push(o);return r}var ii,bf=S(()=>{"use strict";ii=(t,e)=>SR(t,{key:e,desc:!0})});function uv(t){let e=[],n=new Map,r=new Map,s=[],i=[],o=[],a,l=!1,c=0;for(let u of t){if(u.type==="cleared"){e=[],n=new Map,r=new Map,s=[],i=[],o=[],a=void 0,l=!1;continue}let d="at"in u?u.at:void 0;if(d!==void 0&&(c=Math.max(c,d)),u.type==="user")a===void 0&&!u.agent?a=d:d!==void 0&&s.push(d),l=!1;else if(u.type==="assistant"){d!==void 0&&i.push(d);for(let f of u.tools){let p={id:f.id,name:f.name,input:f.input,at:d,isError:!1};e.push(p),n.set(f.id,p)}}else if(u.type==="tool_result"){let f=n.get(u.id);if(!f)continue;Object.assign(f,{result:u.content,isError:u.isError,exit:u.exit,background:u.background,refused:u.refused,doneAt:d}),u.output&&(f.output=u.output),u.task&&r.set(u.task,f),d!==void 0&&i.push(d)}else if(u.type==="task_done"){let f=u.id?n.get(u.id):u.task?r.get(u.task):void 0;if(!f?.background||f.endAt!==void 0)continue;Object.assign(f,{endAt:d??c,outcome:u.outcome,output:u.output??f.output}),u.exit!==void 0&&(f.exit=u.exit),l&&d!==void 0&&(s.push(d),l=!1)}else u.type==="turn_end"&&(!l&&d!==void 0&&o.push(d),l=!0)}return{calls:e,turnEnds:o,lastAt:c,...xR(e,s,i,a,c)}}function xR(t,e,n,r,s){let i=r??t[0]?.at??s,o=[];for(let u of e){let d=-1/0;for(let p of n)p<=u&&p>d&&(d=p);let f=t.some(p=>p.at!==void 0&&p.at<u&&(p.doneAt??1/0)>u);d>-1/0&&!f&&u-d>=kR&&o.push([d,u])}let a=o.reduce((u,[d,f])=>u+Math.max(0,Math.min(s,f)-d),0),l=0,c=-1/0;for(let u of t.filter(d=>d.at!==void 0).sort((d,f)=>d.at-f.at)){let d=u.doneAt??s;d>c&&(l+=d-Math.max(u.at,c),c=d)}return{span:Math.max(0,s-i-a),idle:a,toolMs:l}}function ER(t,e){if(t.refused)return;let n=t.result===void 0||!!t.background&&t.endAt===void 0,r=t.background?t.endAt:t.doneAt,s=!n&&(t.exit!==void 0?t.exit!==0:t.background?t.outcome==="failed":t.isError),i=t.background?t.output?e?.(t.output)??"":"":t.result??"";return{id:t.id,at:t.at,open:n,failed:s,exit:t.exit,outcome:t.background?t.outcome:void 0,ms:t.at!==void 0&&r!==void 0?r-t.at:void 0,...AR(i)}}function AR(t){let e=Ts(t).split(`
|
|
2056
|
+
`).map(n=>n.trim()).filter(n=>/[\p{L}\p{N}]/u.test(n));return/^exit(?: code)?:? \d+$/i.test(e[0]??"")&&e.shift(),{first:In(e[0]??"",120),last:e.length>1?In(e.at(-1),120):""}}function tl(t){let e=[],n=0;for(let r of kf(t).matchAll(/&&|\|\||[;|\n]/g))e.push({text:t.slice(n,r.index),at:n}),n=r.index+r[0].length;return e.push({text:t.slice(n),at:n}),e.filter(r=>r.text.trim())}function wf(t){if(/>|\btee\b/.test(kf(t).replace(/\d?>&\d|\d?>\s*(\/dev\/null|\$null|NUL)\b/gi,"")))return!1;let e=t.trim().match(/"[^"]*"|'[^']*'|\S+/g)??[];for(;e.length&&(IR.has(e[0])||/^\w+=/.test(e[0]));)e=/^\w+=\$\(/.test(e[0])?[]:e.slice(1);if(!e.length)return!0;let[n,...r]=[e[0].replace(/^["'(]+/,"").toLowerCase(),...e.slice(1)];return n==="npx"&&(r=r.filter(s=>!s.startsWith("-")),n=(r.shift()??"").replace(/@.*$/,"").toLowerCase()),n==="for"?!0:n==="typebulb"?RR.has(r.find(s=>!s.startsWith("-"))??""):n==="git"?_R.has(r.find((s,i)=>!s.startsWith("-")&&!/^-[Cc]$/.test(r[i-1]??""))??""):n==="sed"?!r.some(s=>/^-[a-z]*i|^--in-place/.test(s)):n==="find"?!r.some(s=>/^-(delete|exec|execdir|ok)$/.test(s)):PR.has(n)||/^get-/.test(n)}function $R(t){let e=[...t.matchAll(/\$\(|`/g)].map(n=>t.slice(n.index+n[0].length));return tl(t).every(n=>wf(n.text))&&e.every(n=>wf(tl(n)[0]?.text??""))}function vf(t){t=t.replace(NR,(s,i,o,a)=>`<<${i}${o}${i}${a} \u2026 ${o}`);let e=tl(t),n=e.findIndex(s=>!wf(s.text));if(/^\s*(do|then|else|elif)\b/.test(e[n]?.text??""))for(;n>0&&!/^\s*(while|until|for|if)\b/.test(e[n].text);)n--;let r=e[n]?.at??0;return r?`\u2026${t.slice(r).trim()}`:t}function LR(t,e){let n=new Map,r=0;for(let a of t.calls){let l=Sf(a),c=l&&ER(a,e);if(!c)continue;let u=cv(l).trim();if($R(u)){r++;continue}let d=tl(u).at(-1)?.text.trim().split(/\s+/)[0]?.toLowerCase()??"";c.exit===1&&OR.has(d)&&(c.failed=!1),n.set(u,[...n.get(u)??[],c])}let s=[...n].map(([a,l])=>{let c=0;for(let f of l.filter(p=>!p.open).reverse()){if(!f.failed)break;c++}let u=kf(a),d=[TR.test(u)?"stops a process":"",CR.test(u)?"git write":""].filter(Boolean);return{cmd:In(vf(a),100),runs:l.length,failed:l.filter(f=>f.failed).length,streak:c,long:l.some(f=>(f.ms??0)>lv),ms:l.reduce((f,p)=>f+(p.ms??0),0),tags:d,latest:l.at(-1)}}).sort((a,l)=>(l.latest.at??0)-(a.latest.at??0)),o=[...n].flatMap(([a,l])=>l.filter(c=>!c.open).map(c=>({cmd:In(vf(a),100),run:c}))).sort((a,l)=>(l.run.at??0)-(a.run.at??0))[0];return{runs:s.reduce((a,l)=>a+l.runs,0),failed:s.reduce((a,l)=>a+l.failed,0),reads:r,groups:s,last:o}}function dv(t,e){let n=new Map,r=[],s=[],i=o=>{let a=o.trim().replace(/^["']|["']$/g,"").replace(/\\/g,"/").replace(/^\/([a-zA-Z])\//,"$1:/"),l=fy(a,e).replace(/^\.\//,"");return!l||/^([a-zA-Z]:)?\//.test(l)?void 0:l};for(let o of t.calls){if(o.isError||o.result===void 0)continue;let a=o.doneAt??o.at??0,l=(g,v={},A=!1)=>{let C=i(g);if(!C)return;let x=n.get(C)??{path:C};x.deleted=v.deleted,v.from&&(x.from=v.from),n.set(C,x),r.push({path:C,at:a,whole:A})},c=(g,v)=>{let A=i(g),C=A?n.get(A):void 0;A&&(n.delete(A),r.push({path:A,at:a})),l(v,{from:C?.from??A})},u=o.input??{},d=!1;for(let[g,v]of Object.entries(u)){if(g==="command"||g==="cmd"||typeof v!="string"||!/^(---|\+\+\+) /m.test(v))continue;let A;for(let C of v.split(`
|
|
2057
|
+
`)){let x=/^(---|\+\+\+) (?:[ab]\/)?(.+?)\s*$/.exec(C);if(x?.[1]==="---"){A=x[2];continue}if(x?.[1]==="+++"){d=!0,x[2]==="/dev/null"?A&&A!=="/dev/null"&&l(A,{deleted:!0}):l(x[2]);continue}let R=/^\*\*\* Move to: (.+?)\s*$/.exec(C);R&&A&&c(A,R[1])}}let f=ee(u.file_path)??ee(u.filePath)??ee(u.path),p=DR.some(g=>g in u);!d&&f&&p&&l(f,{},typeof u.content=="string");let h=ee(u.file_path)??ee(u.filePath);if(h&&!p&&!d){let g=i(h);g&&s.push({path:g,at:a})}let m=Sf(o);if(m)for(let g of BR(m))g.to?c(g.from,g.to):l(g.from,{deleted:!0})}return{edited:[...n.values()],writes:r,reads:s}}function BR(t){let e=[];for(let n of t.split(/&&|\|\||[;|\n]/)){let r=n.trim().match(/"[^"]*"|'[^']*'|\S+/g)??[],s=r.indexOf("git"),i=r[s+1];if(s<0||i!=="rm"&&i!=="mv"||r.includes("--cached"))continue;let o=r.slice(s+2).filter(l=>!l.startsWith("-")).map(l=>l.replace(/^["']|["']$/g,""));if(i==="rm"){for(let l of o)e.push({from:l});continue}let a=o.pop();if(a)for(let l of o)e.push({from:l,to:o.length>1?`${a.replace(/\/+$/,"")}/${py(l)}`:a})}return e}function fv(t){let e=new Map;for(let s of t)for(let i of s.writes)e.set(i.path,[...e.get(i.path)??[],{id:s.id,at:i.at,whole:i.whole}]);let n=new Map,r=new Map;for(let[s,i]of e){i.sort((a,l)=>a.at-l.at);let o=new Map;for(let a of i)o.set(a.id,a.at);n.set(s,[...o].map(([a,l])=>({id:a,at:l})).sort((a,l)=>a.at-l.at)),i.forEach((a,l)=>{if(!a.whole)return;let c=i.slice(0,l).reverse().find(f=>f.id!==a.id);if(!c)return;let u=t.find(f=>f.id===a.id);[...u.reads,...u.writes].some(f=>f.path===s&&f.at>c.at&&f.at<a.at)||r.set(`${s}
|
|
2058
|
+
${a.id}
|
|
2059
|
+
${c.id}`,{path:s,by:a.id,over:c.id,at:a.at,overAt:c.at})})}return{writers:n,blind:[...r.values()]}}function pv(t,e,n,r,s,i,o,a=xf){let l=u=>`"${s.get(u)??u}"`,c=e.calls.filter(u=>!u.refused&&(u.result===void 0||u.background&&u.endAt===void 0)).map(u=>({id:u.id,label:ov(u),short:In(ee(u.input?.description)??"",80)||ov(u),at:u.at,background:!!u.background,interrupted:!i||t.liveSince!==void 0&&(u.at??0)<t.liveSince}));return{id:t.id,name:Et(t),state:t.state==="stopped"?"stopped":t.failing?"failing":t.state==="running"?"running":"finished",asOf:e.lastAt,activeMs:e.span,idleMs:e.idle,toolMs:e.toolMs,open:c,commands:jR(LR(e,o),c),files:n.map(u=>{let d=a.since(u.path);return{...u,committed:!a.ignored(u.path)&&!a.uncommitted(u.path),ignored:a.ignored(u.path),also:(r.writers.get(u.path)??[]).filter(f=>f.id!==t.id&&f.at>d).map(f=>({name:s.get(f.id)??f.id,at:f.at})),blind:r.blind.filter(f=>f.path===u.path&&(f.by===t.id||f.over===t.id)&&f.overAt>d).map(f=>f.by===t.id?`\u26A0 written at ${Mr(f.at)} over ${l(f.over)}'s ${Mr(f.overAt)} write without reading it`:`\u26A0 ${l(f.by)} wrote over this agent's ${Mr(f.overAt)} write at ${Mr(f.at)} without reading it`)}})}}function jR(t,e){let n=new Set(e.filter(r=>r.interrupted).map(r=>r.id));return{...t,groups:t.groups.map(r=>n.has(r.latest.id)?{...r,latest:{...r.latest,interrupted:!0}}:r)}}function UR(t,e){let n=$n(t).filter(s=>s.background);return`${t.state==="finished"&&n.length?`finished, background call running ${ie(e-(n[0].at??e))}${n.length>1?` (+${n.length-1} more)`:""}`:t.state} \xB7 ${ie(Ef(t,e))} active${t.idleMs?`, ${ie(t.idleMs)} idle`:""}`}function JR(t,e){return t.open.length?t.open.length===1?[`Now: ${av(t.open[0],e)}`]:["Now:",...t.open.map(n=>` ${av(n,e)}`)]:[`Now: ${qR(t,e)}`]}function WR(t,e){let n=t.latest;return`latest: ${n.interrupted?"interrupted":n.open?`running ${ie(e-(n.at??e))}`:n.outcome&&n.outcome!=="completed"&&n.outcome!=="failed"&&n.exit===void 0?n.outcome:`exit ${n.exit??(n.failed?"error":0)}${n.ms!==void 0?` after ${ie(n.ms)}`:""}`}${t.streak>=2?`, failed ${t.streak} in a row`:""}`}function mv(t,e){let n=[`Sub-agent "${t.name}" (${t.id}): ${UR(t,e)}${t.asOf?` \xB7 as of ${Mr(t.asOf)}`:""}`,""];n.push(...JR(t,e));let r=t.commands;r.last&&n.push(`Last run: ${XR(r)}`),n.push(`Commands: ${MR(r)}`);for(let a of r.groups.filter(el).slice(0,iv)){let l=GR(a);n.push(` ${a.cmd} \xD7${a.runs}${a.failed?`, ${a.failed} failed`:""}${l?` \xB7 ${l}`:""}`,` ${WR(a,e)}`);let c=[a.latest.first,a.latest.last].filter(Boolean).map(u=>`"${u}"`).join(" \u2026 ");c&&n.push(` ${c}`)}let s=Math.min(iv,r.groups.filter(el).length),i=r.groups.filter(el).length-s;i&&n.push(` +${i} more like these`);let o=VR(r);o.runs&&n.push(` +${o.runs} other ${o.runs===1?"run":"runs"} passed (${ie(o.ms)} in all)`),n.push(`Files: ${KR(t)}`);for(let a of t.files){let l=a.also.length?` also ${YR(a)}`:"";n.push(` ${QR(a)}${a.ignored?" (ignored)":a.committed?" (committed)":""}${l}`,...a.blind.map(c=>` ${c}`))}return t.activeMs&&n.push(`Time: ${zR(t,e)}`),n.join(`
|
|
2060
|
+
`)}function HR(t,e){let n=t.toolMs+($n(t).some(r=>!r.background)?hv(t,e):0);return{tools:n,model:Math.max(0,Ef(t,e)-n)}}function gv(t,e,n,r){let s=e.filter(oi).length,i=Math.max(0,...e.map(u=>u.asOf)),o=[s?`Session ${t}: ${s} of ${e.length} agents running.`:`Session ${t}: No agent running for ${ie(r-i)} (${e.length} agents).`];if(n.length){o.push("","Files to check before git add:");for(let u of n)o.push(` ${u.path} ${u.writers.map(d=>`"${d.name}"${d.running?" (running)":""}`).join(", ")}${u.blind.length?" \u26A0":""}`)}o.push("","Agents:");let a=e.filter(u=>oi(u)||u.state==="failing"||n.some(d=>d.writers.some(f=>f.id===u.id))),l=new Set(a.map(u=>u.id));for(let u of a){let d=$n(u)[0],f=u.state==="finished"?$n(u).filter(A=>A.background):[],p=f.length?`finished, background call running ${ie(r-(f[0].at??r))}${f.length>1?` (+${f.length-1} more)`:""}`:u.state.padEnd(8),h=f.length?f[0].short:d?`waiting ${ie(r-(d.at??r))} on ${d.short}`:"",m=FR(u),g=[h,m>=2?`failed ${m} in a row`:"",n.some(A=>A.blind.includes(u.id))?"\u26A0":""].filter(Boolean),v=u.parentId&&l.has(u.parentId)?" ".repeat(Math.max(0,u.depth-1)):"";o.push(` ${v}${u.id} ${p} ${`${ie(Ef(u,r))} active`.padStart(10)} ${u.name}${g.length?` \xB7 ${g.join(" \xB7 ")}`:""}`)}let c=e.length-a.length;return c&&o.push(` ${a.length?"+":""}${c} ${e.some(u=>!l.has(u.id)&&u.state==="stopped")?"finished or stopped":"finished"}, nothing to check`),o.push("","Run `typebulb status <id>` for one agent's report, or `typebulb babysit` in the background to be woken when an agent needs attention."),o.join(`
|
|
2061
|
+
`)}function yv(t,e){let n=new Map,r=o=>`"${t.find(a=>a.id===o)?.name??o}"`,s=Math.max(0,...t.map(o=>o.asOf));t.length&&!t.some(oi)&&e-s>=ZR&&n.set("idle",`No agent running for ${ie(e-s)} (${t.length} agents).`);for(let o of t){if(o.state==="finished")for(let a of $n(o).filter(l=>l.background&&e-(l.at??e)>=eI))n.set(`background:${a.id}`,`${r(o.id)}: finished, background call running ${ie(e-(a.at??e))}: ${a.short}`);for(let a of o.commands.groups.filter(l=>l.streak>=2))n.set(`streak:${o.id}:${a.cmd}`,`${r(o.id)}: failed ${a.streak} in a row: ${a.cmd}`)}let i=t.flatMap(o=>$n(o).filter(a=>!a.background&&e-(a.at??e)>=tI).map(a=>({a:o,ms:e-(a.at??e)})));return new Set(i.map(o=>o.a.id)).size>=2&&n.set("waiting",`${new Set(i.map(o=>o.a.id)).size} agents waiting on calls at once: ${i.map(o=>`${r(o.a.id)} ${ie(o.ms)}`).join(", ")}`),n}var kR,iv,lv,In,cv,Sf,Mr,ov,TR,CR,OR,PR,_R,RR,IR,kf,NR,MR,DR,xf,$n,oi,FR,hv,Ef,av,qR,KR,zR,YR,el,VR,GR,XR,QR,ZR,eI,tI,nl=S(()=>{"use strict";Lr();Io();kR=6e4,iv=8,lv=3*6e4,In=(t,e)=>(t=Ts(t).replace(/\s+/g," ").trim(),t.length>e?t.slice(0,e)+"\u2026":t),cv=t=>t.replace(/^(\s*(cd\s+\S+|export\s+PATH=\S+)\s*(;|&&)\s*)+/,""),Sf=t=>ee(t.input?.command)??ee(t.input?.cmd),Mr=t=>new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),ov=t=>{let e=Sf(t);if(e)return In(vf(cv(e).trim()),100);let n=In(hy(t.input),80);return n?`${Bu(t.name)}: ${n}`:Bu(t.name)};TR=/(^|[\s;|&(])(kill|pkill|killall|taskkill|stop-process)\b/i,CR=/\bgit\s+(-C\s+\S+\s+)?(commit|stash|checkout|reset|push|clean|restore|rebase|merge|cherry-pick|revert)\b/,OR=new Set(["grep","egrep","fgrep","rg","findstr","select-string"]),PR=new Set(["grep","egrep","fgrep","rg","cat","head","tail","less","ls","wc","find","date","echo","printf","pwd","which","sort","uniq","cut","tr","awk","jq","stat","file","diff","basename","dirname","realpath","cd","pushd","popd","export","set","true","test","[","seq","ps","tasklist","time","select-string","test-path","measure-object","select-object","where-object","sort-object","format-table","format-list","write-output","write-host"]),_R=new Set(["log","status","diff","show","blame","rev-parse","ls-files","grep","branch","remote"]),RR=new Set(["status","logs","get","models","slug","predict"]),IR=new Set(["if","then","else","elif","fi","do","done","while","until","!","{","}","(",")"]),kf=t=>t.replace(/'[^']*'|"(?:\\.|[^"\\])*"/g,e=>"_".repeat(e.length));NR=/<<-?\s*(['"]?)(\w+)\1([^\n]*)\n[\s\S]*?\n\s*\2\b/g;MR=t=>[t.runs?`${t.runs} run, ${t.failed} failed`:"none",t.reads?`${t.reads} ${t.reads===1?"read":"reads"}`:""].filter(Boolean).join(", "),DR=["content","diff","new_string","new_source","edits"];xf={uncommitted:()=>!0,ignored:()=>!1,since:()=>0};$n=t=>t.open.filter(e=>!e.interrupted),oi=t=>t.state==="running"||$n(t).length>0,FR=t=>Math.max(0,...t.commands.groups.map(e=>e.streak)),hv=(t,e)=>t.state==="running"?Math.max(0,e-t.asOf):0,Ef=(t,e)=>t.activeMs+hv(t,e);av=(t,e)=>t.interrupted?`${t.label}: interrupted, its process has ended`:`${t.label}, ${ie(e-(t.at??e))}${t.background?" (background)":""}`,qR=(t,e)=>`nothing open, last entry ${ie(e-t.asOf)} ago`;KR=t=>{let e=t.files.filter(n=>!n.committed&&!n.ignored).length;return t.files.length?`${t.files.length} (${e} uncommitted)`:"none"};zR=(t,e)=>{let n=HR(t,e);return`${ie(n.tools)} in tools, ${ie(n.model)} in the model`},YR=t=>t.also.map(e=>`"${e.name}" ${Mr(e.at)}`).join(", "),el=t=>t.failed>0||t.latest.open||t.long||t.runs>=3||t.tags.length>0,VR=t=>{let e=t.groups.filter(n=>!el(n));return{runs:e.reduce((n,r)=>n+r.runs,0),ms:e.reduce((n,r)=>n+r.ms,0)}},GR=t=>[...t.tags,t.long?`over ${ie(lv)}`:""].filter(Boolean).join(", "),XR=t=>{let e=t.last;if(!e)return"";let n=e.run.outcome&&e.run.outcome!=="completed"&&e.run.outcome!=="failed"&&e.run.exit===void 0?e.run.outcome:`exit ${e.run.exit??(e.run.failed?"error":0)}`;return`${e.cmd} \xB7 ${n}${e.run.ms!==void 0?` after ${ie(e.run.ms)}`:""}`},QR=t=>t.deleted?`${t.path} (deleted)`:t.from?`${t.path} (moved from ${t.from})`:t.path;ZR=5*6e4,eI=10*6e4,tI=2*6e4});import{openSync as nI,readSync as rI,closeSync as sI,fstatSync as iI,statSync as oI}from"fs";function*Af(t,e){if(!t.listChildren)return;let n=t.callerSessionId?.(e),r=ii(t.listSessionFiles(e),s=>s.mtime).sort((s,i)=>+(i.sessionId===n)-+(s.sessionId===n));for(let s of r){let i=t.listChildren(e,s.sessionId);i.length&&(yield vv(t,e,s.sessionId,s.file,i))}}function vv(t,e,n,r,s){let i=Za(t,n,e,r);return{sessionId:n,live:i,children:s.map(o=>({...o,state:si(o,i)}))}}function Sv(t,e){return t.callerSessionId?.(e)??Af(t,e).next().value?.sessionId}function kv(t,e,n){let r=t.listSessionFiles(e).find(s=>s.sessionId===n)?.file;return vv(t,e,n,r,t.listChildren?.(e,n)??[])}function xv(t,e){let n=e.trim().toLowerCase(),r=t.children.filter(s=>s.id.toLowerCase()===n);return r.length?r:t.children.filter(s=>s.id.toLowerCase().startsWith(n)||Et(s).toLowerCase().includes(n))}function wv(t,e){let n={size:-1,mtimeMs:-1};try{n=oI(e)}catch{}let r=bv.get(e);if(r&&r.size===n.size&&r.mtime===n.mtimeMs)return r.d;let s=uv(rv(t,e,"child"));return bv.set(e,{size:n.size,mtime:n.mtimeMs,d:s}),s}function aI(t){let e;try{e=nI(t,"r")}catch{return}try{let n=iI(e).size,r=(s,i)=>{let o=Buffer.alloc(i);return o.subarray(0,rI(e,o,0,i,s)).toString("utf8")};return n<=2*rl?r(0,n):`${r(0,rl)}
|
|
2062
|
+
${r(n-rl,rl)}`}catch{return}finally{sI(e)}}async function Nn(t,e,n){let r=sv([...n.children].sort((c,u)=>(c.started??c.mtime)-(u.started??u.mtime))),s=r.map(c=>dv(wv(t,c.file),e)),i=fv(r.map((c,u)=>({id:c.id,writes:s[u].writes,reads:s[u].reads}))),o=await cI(e,Math.min(1/0,...[...i.writers.values()].flat().map(c=>c.at)),[...i.writers.keys()]),a=new Map(r.map(c=>[c.id,Et(c)])),l=r.map((c,u)=>({...pv(c,wv(t,c.file),s[u].edited,i,a,n.live,aI,o),depth:c.depth,parentId:c.parentId}));return{reports:l,files:lI(l,i,o)}}function lI(t,e,n){let r=new Set(t.filter(oi).map(o=>o.id)),s=new Map(t.map(o=>[o.id,o.name]));return[...e.writers].filter(([o])=>n.uncommitted(o)).map(([o,a])=>{let l=n.since(o),c=a.filter(d=>d.at>l);if(c.length<2&&!c.some(d=>r.has(d.id)))return;let u=e.blind.filter(d=>d.path===o&&d.overAt>l).flatMap(d=>[d.by,d.over]);return{path:o,writers:c.map(d=>({id:d.id,name:s.get(d.id)??d.id,running:r.has(d.id)})),blind:[...new Set(u)]}}).filter(o=>!!o).sort((o,a)=>o.path.localeCompare(a.path))}async function cI(t,e,n){let r=s=>process.platform==="win32"?s.toLowerCase():s;try{let s=(await we(["rev-parse","--show-prefix"],t)).trim(),i=d=>d.startsWith(s)?r(d.slice(s.length)):void 0,o=await we(["status","--porcelain","-z","--untracked-files=all"],t),a=new Set,l=o.split("\0");for(let d=0;d<l.length;d++){let f=l[d];if(f.length<4)continue;(f[0]==="R"||f[0]==="C")&&d++;let p=i(f.slice(3));p&&a.add(p)}let c=new Map;if(Number.isFinite(e)){let d=0;for(let f of(await we(["log",`--since=${new Date(e).toISOString()}`,"--format=@%ct","--name-only","--","."],t)).split(`
|
|
2063
|
+
`)){if(f.startsWith("@")){d=Number(f.slice(1))*1e3;continue}let p=f.trim()&&i(f.trim());p&&!c.has(p)&&c.set(p,d)}}let u=new Set(n.length?(await we(["check-ignore","--",...n],t).catch(()=>"")).split(`
|
|
2064
|
+
`).map(d=>r(d.trim())).filter(Boolean):[]);return{uncommitted:d=>a.has(r(d)),ignored:d=>u.has(r(d)),since:d=>c.get(r(d))??0}}catch{return xf}}var bv,rl,sl=S(()=>{"use strict";Nr();yf();Lr();bf();nl();bv=new Map;rl=4096});import{existsSync as Ev,openSync as uI,readSync as dI,closeSync as fI,statSync as ai,readdirSync as Av,watchFile as pI,unwatchFile as Tv,mkdirSync as hI,writeFileSync as mI,readFileSync as Tf,unlinkSync as gI,rmSync as yI}from"fs";import{stat as bI}from"fs/promises";import{dirname as wI,join as Ln,resolve as Cv}from"path";function xI(t){if(!Number.isInteger(t))return!0;try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}function Dr(t){let e={cwd:X,sessionId:"",sessionStartMs:Date.now(),buffer:[],partial:"",offset:0,latest:{in:0,out:0,cached:0,cacheCreate:0},latestModel:null,everAttached:!1,index:Qa(t),thread:"main"},n;function r(y,k){let w={offset:k,text:""},O;try{O=ai(y).size}catch{return w}if(O<=k)return w;let N;try{N=uI(y,"r")}catch{return w}try{let D=O-k,B=Buffer.alloc(D),z=0;for(;z<D;){let Q=dI(N,B,z,D-z,k+z);if(!Q)break;z+=Q}return{offset:k+z,text:B.subarray(0,z).toString("utf8")}}finally{fI(N)}}let s=new Set,i,o=0;function a(){if(e.file){for(let y of s)if(y.file===e.file)return y;return}return i}function l(y){let k={d:t.createDriver(e.cwd,y),file:y,id:`new:${++o}`,startedAt:Date.now()};return s.add(k),e.file||(i=k),k}function c(){let y=[...s].filter(w=>w.file);if(!y.length)return[];let k=new Map(t.listSessionFiles(e.cwd).map(w=>[w.file,w.sessionId]));return y.map(w=>{let O=k.get(w.file);return{rec:w,sessionId:O??w.id,pending:O===void 0}})}let u=()=>c().filter(y=>y.pending&&y.rec.prompt!==void 0);async function d(y){s.delete(y),i===y&&(i=void 0);try{await y.d.dispose()}catch(k){console.error("[composer] dispose:",V(k))}}function f(){let y=a(),k=new Set(u().map(w=>w.rec));for(let w of[...s])w!==y&&(k.has(w)||w.d.streaming||w.d.queue||w.d.error||d(w))}function p(){for(let y of s)y.d.sessionFile&&y.file!==y.d.sessionFile&&(y.file=y.d.sessionFile);if(i&&!e.file&&i.file){let y=t.listSessionFiles(e.cwd).find(k=>k.file===i.file);y&&H(y)}i&&!e.file&&i.prompt!==void 0&&e.sessionId!==i.id&&(F(void 0,i.id),e.everAttached=!0)}let h=y=>Ln(y,SI),m=(y,k)=>Ln(h(y),`${k}.lock`);function g(y,k){try{let w=m(y,k);if(Date.now()-ai(w).mtimeMs>=Ov)return!1;try{let O=parseInt(Tf(w,"utf8").trim(),10);if(O===process.pid||!xI(O))return!1}catch{}return!0}catch{return!1}}function v(y,k){if(k)try{hI(h(y),{recursive:!0}),mI(m(y,k),String(process.pid))}catch(w){console.error("[lock] claim failed:",V(w))}}function A(y){try{yI(Ln(y,".claude-bulb"),{recursive:!0,force:!0})}catch{}}function C(y){let k=h(y);if(!Ev(k))return;let w;try{w=Av(k)}catch{return}let O=Date.now();for(let N of w){if(!N.endsWith(".lock"))continue;let D=Ln(k,N);try{let B=ai(D);O-B.mtimeMs>kI&&gI(D)}catch{}}}function x(y){try{return ai(y),!1}catch(k){return k.code==="ENOENT"}}function R(){let y=e;if(y.file&&!x(y.file)){v(y.cwd,y.sessionId);return}let k=I(y);k&&H(k)}function I(y){if(!y.everAttached)return L(y.cwd)??T(y.cwd,()=>!0)}function L(y){let k=h(y);if(!Ev(k))return;let w;try{w=Av(k)}catch{return}let O;for(let D of w)if(D.endsWith(".lock"))try{let B=ai(Ln(k,D));if(Date.now()-B.mtimeMs>=Ov||parseInt(Tf(Ln(k,D),"utf8").trim(),10)!==process.pid)continue;(!O||B.mtimeMs>O.mtime)&&(O={sessionId:D.slice(0,-5),mtime:B.mtimeMs})}catch{}if(!O)return;let N=t.listSessionFiles(y).find(D=>D.sessionId===O.sessionId);if(!(!N||x(N.file)))return N}function T(y,k){return t.listSessionFiles(y).sort((w,O)=>O.mtime-w.mtime).find(w=>!g(y,w.sessionId)&&k(w))}function F(y,k){let w=e;if(w.file)try{Tv(w.file)}catch{}w.file=y,w.sessionId=k,w.partial="",w.offset=0,w.latest={in:0,out:0,cached:0,cacheCreate:0},w.latestModel=null,w.index=Qa(t),w.chainLastId=void 0,w.buffer.push({type:"cleared"}),w.buffer.push({type:"session",sessionId:k})}function H(y){let k=e;i=void 0,xi(),n=y.file,F(y.file,y.sessionId),k.everAttached=!0,v(k.cwd,y.sessionId),ne(y.file)}function ne(y){if(re(),!!y){try{Tv(y)}catch{}pI(y,{interval:200},()=>re())}}function U(){xi(),n=void 0,F(void 0,"")}function re(){let y=e;if(!y.file)return;let k=r(y.file,y.offset);if(!k.text)return;y.offset=k.offset,y.partial+=k.text;let w=y.partial.lastIndexOf(`
|
|
2065
|
+
`);if(w<0)return;let O=y.index.add(y.partial.slice(0,w).split(`
|
|
2066
|
+
`),y.thread);if(y.partial=y.partial.slice(w+1),!O)return;let N=[],{entries:D}=y.index,B=D.get(O),z=!1;for(;B;){if(N.push(B),t.idOf(B)===y.chainLastId){z=!0;break}let Q=t.parentOf(B);B=Q?D.get(Q):void 0}if(z)for(let Q=N.length-2;Q>=0;Q--)pe(N[Q]);else{y.chainLastId!==void 0&&(y.buffer.push({type:"cleared"}),y.buffer.push({type:"session",sessionId:y.sessionId}),y.latest={in:0,out:0,cached:0,cacheCreate:0});let Q=new Set(N.map(ue=>t.idOf(ue))),dt=ge(D);for(let ue=N.length-1;ue>=0;ue--)pe(N[ue]),Le(t.idOf(N[ue]),dt,Q)}y.chainLastId=O}function ge(y){let k=new Map;for(let w of y.values()){let O=t.parentOf(w);if(!O)continue;let N=k.get(O);N?N.push(w):k.set(O,[w])}return k}function Le(y,k,w){if(!y)return;let O=k.get(y);if(!O)return;let N=O.filter(Q=>!t.isSidechain(Q,e.thread));if(N.length<2)return;let D=N.filter(Q=>!w.has(t.idOf(Q)));if(!D.length)return;let B=[],z=0;for(let Q of D){let dt=ut(Q,k);B.push(...dt.events),z+=dt.count}z>0&&e.buffer.push({type:"fork",atId:y,count:z,events:B})}function ut(y,k){let w=[],O=[y];for(;O.length;){let B=O.pop();if(t.isSidechain(B,e.thread))continue;w.push(B);let z=k.get(t.idOf(B)??"");if(z)for(let Q of z)O.push(Q)}w.sort((B,z)=>(Date.parse(t.timestampOf(B)??"")||0)-(Date.parse(t.timestampOf(z)??"")||0));let N=[];for(let B of w)t.isRecoveryNoise(B)||N.push(...Xa(t,B,e.thread,e.sessionStartMs).events);return{count:N.reduce((B,z)=>B+(z.type==="user"||z.type==="assistant"?1:0),0),events:N}}function pe(y){if(!t.isSidechain(y,e.thread))try{let{events:k,usage:w,model:O,cost:N}=Xa(t,y,e.thread,e.sessionStartMs);for(let D of k)e.buffer.push(D);k.some(D=>D.type==="assistant")&&a()?.d.clearCompletedDraft(),k.some(D=>D.type==="user")&&a()?.d.clearEcho(),O&&(e.latestModel=O),w&&(e.latest=w),(w||N)&&e.buffer.push({type:"usage",...e.latest,cost:N})}catch(k){console.error("[mirror] skipped malformed entry:",V(k))}}async function Ce(){return{cwd:e.cwd,pid:process.pid,composer:!!t.createDriver,children:!!t.listChildren,elsewhere:await Ot()}}async function Ot(){if(t.listSessionFiles(e.cwd).length)return;let y=await Rn();if(!y)return;let k=Cv(y).toLowerCase();for(let w=Cv(e.cwd);w.toLowerCase()!==k;){let O=wI(w);if(O===w)return;w=O;let N=t.listSessionFiles(w).length;if(N)return{dir:w,count:N}}}Ot().then(y=>{y&&console.log(`No sessions for ${e.cwd} \u2014 ${y.count} exist for ${y.dir}. Launched from a subfolder? Relaunch from the project root.`)}).catch(()=>{});let b=new Ka;async function E(y,k){e.thread!=="child"&&b.accept(y,k)&&console.log(k)}function P(){return Za(t,e.sessionId,e.cwd,e.file)}function $(){return t.chainWorking([...e.index.entries.values()])&&P()}function M(){!t.createDriver||a()||e.latestModel||$()||l(e.file)}async function W(y){let k=e;R(),p(),M(),f();let w=a();for(let B of s)B!==w&&B.d.dialog;let O=c().filter(B=>B.rec.d.streaming).map(B=>B.sessionId),N=$(),D=t.createDriver?{streaming:!!w?.d.streaming,foreign:!w&&N,draft:w?.d.draft??null,echo:w?.d.echo??null,status:w?.d.status??null,dialog:w?.d.dialog??null,queue:w?.d.queue??null,stats:w?.d.stats??null,model:w?.d.model??null,error:w?.d.error}:void 0;return{events:k.buffer.slice(y),cursor:k.buffer.length,working:!!w?.d.streaming||N,latestModel:k.latestModel,child:k.child?.id??null,composer:D,busy:O}}async function q(){R(),p();let y=a();if(y?.d.error&&!y.d.streaming&&(await d(y),y=void 0),!y){if($())return{ok:!1,error:"the agent is mid-turn in a terminal \u2014 watch only"};y=l(e.file)}let k=y;return{ok:!0,d:k.d,markSent:w=>{k.prompt===void 0&&(k.prompt=w)}}}async function Ke(y,k){if(!t.createDriver)return{ok:!1,error:"not supported"};let w=String(y??"").trim();if(!w)return{ok:!1,error:"empty message"};let O=await q();if(!O.ok)return O;let N=await O.d.send(w,k);return N.ok&&O.markSent(w),N}async function Y(y,k){let w=a();return w?w.d.respondUi(String(y??""),k??{}):{ok:!1,error:"no dialog pending"}}async function ce(y,k){if(!t.createDriver)return{ok:!1,error:"not supported"};if(!y||typeof y.type!="string")return{ok:!1,error:"bad command"};if(k?.spawn){let O=await q();return O.ok?O.d.rpc(y):O}let w=a();return!w||w.d.error?{ok:!1,error:"not running"}:w.d.rpc(y)}async function Oe(){let y=a();if(y)try{await y.d.stop()}catch(k){console.error("[composer] stop:",V(k))}return{ok:!0}}async function Jr(){return t.createDriver?(p(),!e.file&&i&&i.prompt===void 0&&!i.d.streaming&&!i.d.error?{ok:!0}:(i?.d.error&&await d(i),i=void 0,U(),l(void 0),f(),{ok:!0})):{ok:!1,error:"not supported"}}async function sn(){if(!t.createDriver)return[];let y=await we(["ls-files","--cached","--others","--exclude-standard"],e.cwd).catch(()=>null),k=y!==null?y.split(`
|
|
2067
|
+
`).filter(Boolean):await t.walkFiles?.(e.cwd)??[];return(await Promise.all(k.map(async O=>{try{return{f:O,m:(await bI(Ln(e.cwd,O))).mtimeMs}}catch{return{f:O,m:0}}}))).sort((O,N)=>N.m-O.m).map(O=>O.f)}function Pt(){for(let y of[...s])d(y)}async function Ml(y){return t.createDriver?Gw(e.cwd,y):{ok:!1,error:"not supported"}}async function Dl(y){return Xw(e.cwd,String(y??""))}async function Ik(y,k){return tv(String(y??""),String(k??""))}async function $k(y){let k=t.listChildren?.(e.cwd,e.sessionId)??[],w=P(),{reports:O}=await Nn(t,e.cwd,{sessionId:e.sessionId,live:w,children:k.map(D=>({...D,state:si(D,w)}))}),N=O.find(D=>D.id===y);return N?{ok:!0,report:N}:{ok:!1,error:"child not found"}}async function Nk(){let y=t.sessionsWorking?.(e.cwd),k=t.listSessionFiles(e.cwd).map(({sessionId:O,file:N,mtime:D})=>({sessionId:O,mtime:D,preview:t.readPreview(N),working:y?.has(O)})),w=u().map(O=>({sessionId:O.sessionId,mtime:O.rec.startedAt,preview:O.rec.prompt??"",pending:!0}));return ii([...k,...w],O=>O.mtime)}let kp=new Map;function xp(y,k){let w=kp.get(y);if(w&&w.mtime===k)return w.turns;let O=[],N="";try{N=Tf(y,"utf8")}catch{return[]}for(let D of N.split(`
|
|
2068
|
+
`)){if(!D.trim())continue;let B=t.parseEntry(D);if(!B)continue;let z=t.searchText(B);z&&O.push({text:z,lower:z.toLowerCase()})}return kp.set(y,{mtime:k,turns:O}),O}async function Lk(y){let k=y.toLowerCase(),w=[],O=0,N=t.sessionsWorking?.(e.cwd);for(let{sessionId:D,file:B,mtime:z}of t.listSessionFiles(e.cwd).sort((Q,dt)=>dt.mtime-Q.mtime)){let Q=ri(xp(B,z),k),dt=(t.listChildren?.(e.cwd,D)??[]).map(ue=>({c:ue,hit:ri(xp(ue.file,ue.mtime),k)})).filter(ue=>ue.hit.hitCount);if(!(!Q.hitCount&&!dt.length)){for(let{c:ue,hit:Fk}of ii(dt,Uk=>Uk.c.mtime))w.push({sessionId:D,mtime:ue.mtime,preview:Et(ue),...Fk,child:{id:ue.id,kind:ue.kind,depth:ue.depth}});if(w.push({sessionId:D,mtime:z,preview:t.readPreview(B),working:N?.has(D),...Q}),++O>=EI)break}}return w}async function Mk(y){let k=e,w=t.listSessionFiles(k.cwd).find(O=>O.sessionId===y);if(!w){let O=u().find(N=>N.sessionId===y)?.rec;return O?((i!==O||k.sessionId!==O.id)&&(i=O,xi(),n=void 0,F(void 0,O.id),k.everAttached=!0,f()),{ok:!0}):{ok:!1,error:"session not found"}}return w.file===k.file?{ok:!0}:(H(w),p(),f(),{ok:!0})}async function Dk(){if(!t.listChildren||!e.sessionId)return[];let y=P();return t.listChildren(e.cwd,e.sessionId).map(k=>({...k,state:si(k,y)}))}async function Bk(y){let k=e;if(!t.listChildren)return{ok:!1,error:"this harness has no child transcripts"};let w=t.listChildren(k.cwd,k.sessionId).find(O=>O.id===y);return w?(k.thread="child",k.child=w,F(w.file,k.sessionId),ne(w.file),{ok:!0}):{ok:!1,error:"child not found"}}async function jk(){let y=n;return!xi()||!y?{ok:!0}:(F(y,e.sessionId),ne(y),{ok:!0})}function xi(){let y=e;return y.thread==="main"?!1:(y.thread="main",y.child=void 0,!0)}return A(e.cwd),C(e.cwd),R(),{info:Ce,poll:W,logInlineStatus:E,listSessions:Nk,searchSessions:Lk,attach:Mk,listChildren:Dk,openChild:Bk,closeChild:jk,composerSend:Ke,composerStop:Oe,composerNew:Jr,composerFiles:sn,composerUiRespond:Y,composerRpc:ce,composerPaste:Ml,composerPasteRead:Dl,summarizeTurn:Ik,childStatus:$k,shutdownComposer:Pt}}var vI,SI,Ov,kI,EI,il=S(()=>{"use strict";Gt();Ww();Nr();mf();Qw();nv();yf();sl();bf();Lr();vI=".typebulb",SI=`${vI}/locks`,Ov=5e3,kI=6e4;EI=50});import{existsSync as _f,mkdirSync as AI,readFileSync as Pv,writeFileSync as TI}from"fs";import{join as Mn,isAbsolute as CI}from"path";async function If(t,e){let n=CI(t)?t:Mn(X,t);return _f(n)?(md(n,e),{ok:!0}):{ok:!1,error:"file not found"}}async function $f(t){let e=X,n=hd(t),r=Mn(e,"typebulbs");AI(r,{recursive:!0});let s=ud(n),i=`${s}.bulb.md`;for(let c=2;_f(Mn(r,i))&&Pv(Mn(r,i),"utf8")!==n;c++)i=`${s}-${c}.bulb.md`;let o=Mn(r,i);_f(o)||TI(o,n);let a=Mn("typebulbs",i),l=await bn(a,{cwd:e,open:!1});return{ok:!0,file:a,pid:l.pid,url:l.url}}async function Nf(){return G(X)}async function Lf(t){let e=(await G()).find(n=>n.pid===t);return e?{ok:!0,outcome:await gt(e)}:(await ar(t),{ok:!0})}async function Mf(){let t=await hn(X);return sa(X).filter(e=>!e.serverOnly).map(e=>({...e,trusted:Sn(e.path),lastRunAt:t(e.path)}))}async function Df(t){let e=t.toLowerCase(),n=[];for(let r of sa(X).filter(s=>!s.serverOnly).sort((s,i)=>i.mtime-s.mtime)){let s="";try{s=Pv(r.path,"utf8")}catch{continue}let i=[];for(let l of s.split(`
|
|
2069
|
+
`)){let c=l.replace(/\s+/g," ").trim();c&&i.push({text:c,lower:c.toLowerCase()})}let{hitCount:o,snippet:a}=ri(i,e);o&&n.push({path:r.path,hitCount:o,snippet:a})}return n}async function Bf(t,e){let n=X;e!=null&&pr(t,e);let r=await bn(t,{cwd:n,open:!1,trust:e});return{ok:!0,file:r.file,pid:r.pid,url:r.url,trust:!!r.trust}}async function jf(t){return{cap:await fd(t)}}async function Ff(t,e){return pr(t,e),{ok:!0}}async function Uf(t,e){return Xe(t,e)}async function qf(){return li&&Date.now()-li.fetchedAt<=PI?li.samples:(Cf??=_I().finally(()=>{Cf=null}),Cf)}async function _I(){try{let t=await fetch(`${OI}/api/scripts/u/samples?stubs`,{signal:AbortSignal.timeout(Rv)});if(!t.ok)throw new Error(`HTTP ${t.status}`);let e=await t.json(),n=i=>i.order??Number.MAX_SAFE_INTEGER,r=i=>Date.parse(i.createdAt??"")||0,s=e.filter(i=>i.slug!=="welcome").sort((i,o)=>n(i)-n(o)||r(o)-r(i)).map(i=>({slug:i.slug,name:i.name,description:Hl(i.config)}));return li={samples:s,fetchedAt:Date.now()},s}catch{return li?.samples??[]}}async function Jf(t){return Rf.test(t)?$v(_v,"samples",t,!0):{ok:!1,error:"bad slug"}}async function Kf(){let t=Wf();if(!t)return{bulbs:[]};let e=`${ol()}
|
|
2070
|
+
${t}`;return Xt?.key===e&&Date.now()-Xt.fetchedAt<=RI?{user:Xt.user,bulbs:Xt.bulbs}:(Of??=II(e,t).finally(()=>{Of=null}),Of)}async function Pf(t,e,n){let r=await fetch(`${t}${e}`,{headers:n,signal:AbortSignal.timeout(Rv)});if(!r.ok)throw new Error(`HTTP ${r.status}`);if(!r.headers.get("content-type")?.includes("json"))throw new Error("not json");return r.json()}async function II(t,e){let n={Authorization:`Bearer ${e}`};try{let r=ol(),s;try{s=await Pf(r,"/api/me",n)}catch{let a=new URL(r);r=`${a.protocol}//api.${a.host}`,s=await Pf(r,"/api/me",n)}let o=(await Pf(r,"/api/scripts/list",n)).filter(a=>a.userSlug===s.slug&&!a.isTemplate).map(a=>({slug:a.slug,name:a.name,description:Hl(a.config)}));return Xt={key:t,user:s.slug,bulbs:o,fetchedAt:Date.now()},{user:s.slug,bulbs:o}}catch{return Xt?.key===t?{user:Xt.user,bulbs:Xt.bulbs}:{bulbs:[]}}}async function Hf(t,e,n=!1){return!Rf.test(e)||!Rf.test(t)?{ok:!1,error:"bad slug"}:$v(ol(),t,e,n)}async function $v(t,e,n,r){let s=Ma(e,n);try{let i=await ja({origin:t,userSlug:e,slug:n,dest:Mn(X,s)},{force:r,token:Wf(),timeoutMs:Iv});return i.kind==="conflict"?{ok:!1,conflict:!0,error:"local file differs from the site copy"}:i.kind==="asset-conflict"?{ok:!1,conflict:!0,error:`local assets differ from the site copies (${i.paths.join(", ")})`}:i.kind==="http-error"?{ok:!1,error:`HTTP ${i.status}`}:i.kind==="not-markdown"?{ok:!1,error:`not a bulb (${i.contentType??"no content-type"})`}:{ok:!0,file:s,upToDate:i.kind==="up-to-date"}}catch(i){return{ok:!1,error:i?.message??String(i)}}}async function zf(t,e=!1){let n=Wf();if(!n)return{ok:!1,error:"no TYPEBULB_TOKEN in .env"};try{let r=Ba(t,X,ol()),s=await Ua(r,{token:n,force:e,timeoutMs:Iv});return s.kind==="conflict"?{ok:!1,conflict:!0,error:s.message}:s.kind==="asset-error"?{ok:!1,error:`assets sync failed: ${s.message}`}:s.kind==="http-error"?{ok:!1,error:`HTTP ${s.status}: ${s.message}`}:{ok:!0,created:s.created,serverStripped:s.serverStripped}}catch(r){return{ok:!1,error:r?.message??String(r)}}}var OI,_v,PI,Rv,Iv,li,Cf,Rf,RI,Xt,Of,ol,Wf,al=S(()=>{"use strict";Rr();Gt();mf();Z();OI="https://api.typebulb.com",_v="https://typebulb.com",PI=3600*1e3,Rv=5e3,Iv=15e3,li=null,Cf=null;Rf=/^[a-z0-9][a-z0-9-]*$/,RI=300*1e3,Xt=null,Of=null,ol=()=>ma("TYPEBULB_ORIGIN",X)||_v,Wf=()=>ma("TYPEBULB_TOKEN",X)});import{readFileSync as Gf,writeFileSync as Lv,mkdirSync as $I,appendFileSync as Mv,rmSync as Nv}from"fs";import{join as ul,dirname as NI}from"path";import{createServer as LI}from"http";function Qt(t){try{return JSON.parse(Gf(t,"utf8"))}catch{return null}}function cl(t,e){$I(NI(t),{recursive:!0}),Lv(t,JSON.stringify(e,null,2)+`
|
|
2071
|
+
`)}function Bv(t,e,n){let r=ul(t,".gitignore"),s="";try{s=Gf(r,"utf8")}catch{}let i=new Set(s.split(/\r?\n/).map(l=>l.trim())),o=e.filter(l=>!i.has(l));if(!o.length)return;let a=s&&!s.endsWith(`
|
|
2102
2072
|
`)?`
|
|
2103
|
-
`:"";try{
|
|
2073
|
+
`:"";try{Mv(r,a+n+`
|
|
2104
2074
|
`+o.join(`
|
|
2105
2075
|
`)+`
|
|
2106
|
-
`)}catch(l){console.error("[switcher] .gitignore update failed",
|
|
2076
|
+
`)}catch(l){console.error("[switcher] .gitignore update failed",V(l))}}function FI(t){let e=i=>{let o=i.exec(t);return o?Number(o[1]):0},n=e(/"cache_read_input_tokens":\s*(\d+)/),r=e(/"cache_creation_input_tokens":\s*(\d+)/),s=e(/"input_tokens":\s*(\d+)/);n>0||r>0?di="live":s>jI&&(di="uncached")}function Fv(t,e){let n={"content-type":"application/json",authorization:`Bearer ${e}`,"anthropic-version":t.headers["anthropic-version"]||"2023-06-01",...kd},r=t.headers["anthropic-beta"];return typeof r=="string"&&(n["anthropic-beta"]=r),n}function UI(t){if(Array.isArray(t?.messages))for(let e of t.messages){if(!Array.isArray(e?.content))continue;let n=e.content.filter(r=>r?.type!=="thinking"&&r?.type!=="redacted_thinking");n.length&&n.length!==e.content.length&&(e.content=n)}}function Uv(t){let e;try{e=JSON.parse(t)}catch{return t}ui=typeof e?.model=="string"?e.model:null,ct&&(e.model=ct),Bn&&(e.provider=jv(Bn));let n=/haiku/i.test(ui||"");return fi!=null&&!n&&(e.reasoning={effort:Yf[fi]}),delete e.thinking,e.output_config&&delete e.output_config.effort,UI(e),JSON.stringify(e)}function qI(){let t="",e=0,n=new Map,r=new Set(["thinking","redacted_thinking"]),s=i=>{let o=/^data: (.*)$/m.exec(i);if(!o)return i;let a;try{a=JSON.parse(o[1])}catch{return i}switch(a.type){case"message_start":return n.clear(),e=0,i;case"content_block_start":{if(r.has(a.content_block?.type))return n.set(a.index,null),null;let l=e++;return n.set(a.index,l),a.index=l,`event: ${a.type}
|
|
2107
2077
|
data: ${JSON.stringify(a)}
|
|
2108
2078
|
|
|
2109
2079
|
`}case"content_block_delta":case"content_block_stop":{let l=n.get(a.index);return l==null?null:(a.index=l,`event: ${a.type}
|
|
@@ -2111,11 +2081,11 @@ data: ${JSON.stringify(a)}
|
|
|
2111
2081
|
|
|
2112
2082
|
`)}default:return i}};return i=>{t+=i;let o="",a;for(;(a=t.indexOf(`
|
|
2113
2083
|
|
|
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
|
|
2084
|
+
`))!==-1;){let l=t.slice(0,a);if(t=t.slice(a+2),!l.trim())continue;let c=s(l);c!==null&&(o+=c)}return o}}function JI(t){return new Promise(e=>{let n=[];t.on("data",r=>n.push(r)),t.on("end",()=>e(Buffer.concat(n).toString("utf8"))),t.on("error",()=>e(Buffer.concat(n).toString("utf8")))})}function ci(t,e,n,r){t.writableEnded||(t.writeHead(e,{"content-type":"application/json"}),t.end(JSON.stringify({type:"error",error:{type:n,message:r}})))}async function WI(t,e,n){if(!ct){ci(e,400,"invalid_request_error",BI);return}let r=process.env.OPENROUTER_API_KEY;if(!r){ci(e,401,"authentication_error","OPENROUTER_API_KEY not set in the typebulb proxy");return}let s=new AbortController;e.on("close",()=>{e.writableEnded||s.abort()});let i;try{i=await fetch(Xf,{method:"POST",headers:Fv(t,r),body:Uv(n),signal:s.signal})}catch(d){ci(e,502,"api_error",`proxy upstream failed: ${V(d)}`);return}let o=i.headers.get("content-type")||"application/json";if(e.writeHead(i.status,{"content-type":o}),!i.body){e.end();return}let a=o.includes("event-stream"),l=i.body.getReader(),c=new TextDecoder,u=a?qI():null;try{for(;;){let{done:d,value:f}=await l.read();if(d)break;if(f)if(u){let p=c.decode(f,{stream:!0});FI(p);let h=u(p);h&&e.write(h)}else e.write(Buffer.from(f))}}catch{}finally{e.writableEnded||e.end()}}async function KI(t,e,n){let r=process.env.OPENROUTER_API_KEY,s=()=>{e.writeHead(200,{"content-type":"application/json"}),e.end(JSON.stringify({input_tokens:Math.max(1,Math.ceil(n.length/4))}))};if(!ct||!r)return s();try{let i=await fetch(`${Xf}/count_tokens`,{method:"POST",headers:Fv(t,r),body:Uv(n)});if(!i.ok)return s();let o=await i.text();e.writeHead(200,{"content-type":"application/json"}),e.end(o)}catch{s()}}function HI(t,e){let n=t.url||"/";if(t.method==="HEAD"){e.writeHead(200),e.end();return}if(t.method!=="POST"){ci(e,404,"not_found_error",n);return}JI(t).then(r=>{if(n.includes("count_tokens"))return KI(t,e,r);if(n.includes("/v1/messages"))return WI(t,e,r);ci(e,404,"not_found_error",n)})}function zI(){return Br&&Dn?Promise.resolve(Dn):new Promise((t,e)=>{let n=LI(HI);n.on("error",e),n.listen(0,"127.0.0.1",()=>{Br=n,Dn=n.address().port,console.log(`[switcher] wire proxy listening on ${ll(Dn)}`),t(Dn)})})}function YI(){try{Br?.close()}catch{}Br=null,Dn=null}function VI(t,e){let n=dl(t),r=Qt(n),s=r||{};if((!s.env||typeof s.env!="object")&&(s.env={}),s.env.ANTHROPIC_BASE_URL===ll(e)&&s.env.ANTHROPIC_AUTH_TOKEN)return;let i=fl(t);if(!Qt(i)){let a={};for(let l of Dv)a[l]=l in s.env?s.env[l]:null;cl(i,{managedBy:"agent-switcher",fileExisted:r!==null,snapshot:a,active:null})}s.env.ANTHROPIC_BASE_URL=ll(e),s.env.ANTHROPIC_AUTH_TOKEN=DI,cl(n,s),Bv(t,[".claude/settings.local.json",".claude/.cc-switcher.json"],"# agent switcher (local Claude Code model override)")}function GI(t,e,n){let r=fl(t),s=Qt(r)||{managedBy:"agent-switcher",fileExisted:!1,snapshot:{}};s.active={model:e,provider:n},cl(r,s)}function qv(t){let e=dl(t),n=fl(t),r=Qt(n),s=Qt(e);if(s?.env){let i=r?.snapshot||{};for(let o of Dv){let a=i[o];a==null?delete s.env[o]:s.env[o]=a}if(Object.keys(s.env).length===0&&delete s.env,r?.fileExisted===!1&&Object.keys(s).length===0)try{Nv(e,{force:!0})}catch{}else cl(e,s)}try{Nv(n,{force:!0})}catch{}}async function XI(){let t=!!process.env.OPENROUTER_API_KEY,e=[];try{e=(await yt()).filter(r=>r.provider==="openrouter"&&!Qf(r.name)).map(r=>({id:r.name,label:r.friendlyName||r.name}))}catch(r){console.error("[switcher] model list failed",V(r))}let n=e.length?void 0:wd()??void 0;return{hasKey:t,models:e,error:n}}async function QI(){if(Br&&ct)return{active:!0,managed:!0,model:ct,port:Dn,provider:Bn,routedModel:ui,caching:di,reasoning:fi,externalBaseUrl:null};let t=Qt(dl(X))?.env||{};return{active:!1,managed:!1,model:null,port:null,provider:null,routedModel:null,caching:"unknown",reasoning:fi,externalBaseUrl:t.ANTHROPIC_BASE_URL||null}}async function Jv(t,e){let n=await zI();return ct=t,Bn=e,VI(X,n),n}async function ZI({model:t}){if(!process.env.OPENROUTER_API_KEY)return{ok:!1,error:"OPENROUTER_API_KEY not set \u2014 add a key first"};if(!t)return{ok:!1,error:"no model given"};if(Qf(t))return{ok:!1,error:"Refusing to route an Anthropic model through OpenRouter \u2014 that bills full API rate with no caching. Use it on your Anthropic subscription instead."};try{await Jv(t,Zf[t]??null),ui=null,di="unknown",GI(X,t,Bn)}catch(e){return{ok:!1,error:`failed to start the wire proxy: ${V(e)}`}}return{ok:!0}}async function e$({level:t}){return t!=null&&(!Number.isInteger(t)||t<0||t>=Yf.length)?{ok:!1,error:`reasoning level must be 0\u2013${Yf.length-1} or null`}:(fi=t,{ok:!0,level:t})}async function t$(){return qv(X),ct=null,Bn=null,ui=null,di="unknown",{ok:!0}}async function n$({key:t}){let e=(t||"").trim();if(!e)return{ok:!1,error:"empty key"};let n=X,r=ul(n,".env"),s="";try{s=Gf(r,"utf8")}catch{}try{if(/^\s*OPENROUTER_API_KEY\s*=/m.test(s))Lv(r,s.replace(/^\s*OPENROUTER_API_KEY\s*=.*$/m,`OPENROUTER_API_KEY=${e}`));else{let i=s&&!s.endsWith(`
|
|
2115
2085
|
`)?`
|
|
2116
|
-
`:"";
|
|
2117
|
-
`)}}catch(i){return{ok:!1,error:
|
|
2118
|
-
`)}catch(o){return{ok:!1,error:`could not write ${t}: ${
|
|
2086
|
+
`:"";Mv(r,i+`OPENROUTER_API_KEY=${e}
|
|
2087
|
+
`)}}catch(i){return{ok:!1,error:V(i)}}return process.env.OPENROUTER_API_KEY=e,Bv(n,[".env"],"# secrets"),{ok:!0}}function r$(){if(!(!Br&&!ct)){try{qv(X)}catch{}YI()}}function s$(t,e){return Wv.test(e)?"blocked by your OpenRouter data policy":t===401||t===403||/unauthor|invalid api key|no auth|forbidden/i.test(e)?"auth rejected \u2014 check your OpenRouter key":t===404||/not a valid model|no such model|unknown model|model not found/i.test(e)?"model not found on this route":t===429||/rate limit/i.test(e)?"rate limited":t===402||/insufficient|credit|quota|balance/i.test(e)?"out of credits / quota":e.slice(0,160)}function i$(t){if(Wv.test(t))return"This model's only provider(s) require prompt logging/training, which your OpenRouter account disallows by default. Allow it (or that provider) at openrouter.ai/settings/privacy, then probe again."}function o$(t,e,n){if(!t)return{works:null,read:0,note:n?`couldn't re-test on ${n} \u2014 caching unconfirmed`:"caching unconfirmed"};let r=Vf(e?.cache_read_input_tokens)||Vf(e?.prompt_tokens_details?.cached_tokens),s=e?.cache_read_input_tokens!==void 0||e?.cache_creation_input_tokens!==void 0||e?.prompt_tokens_details!==void 0;return r>0?{works:!0,read:r,note:`${r} tokens read from cache on the 2nd call`}:s?{works:!1,read:r,note:"no cache reads after a warm call \u2014 every turn re-bills the full context"}:{works:null,read:r,note:"route doesn't report cache usage \u2014 caching almost certainly not honored"}}async function a$({model:t}){let e=process.env.OPENROUTER_API_KEY;if(!e)return{ok:!1,error:"OPENROUTER_API_KEY not set \u2014 add a key first"};if(!t)return{ok:!1,error:"no model given"};if(Qf(t))return{ok:!1,error:"Anthropic model \u2014 not offered or probed via OpenRouter"};let n=Date.now(),r=Array(350).fill("Caching probe filler sentence; its only purpose is to exceed the prompt-cache minimum token threshold.").join(" "),s={"content-type":"application/json",authorization:`Bearer ${e}`,"anthropic-version":"2023-06-01"},i={model:t,max_tokens:64,system:[{type:"text",text:r,cache_control:{type:"ephemeral"}}],messages:[{role:"user",content:"Reply with exactly: ok"}]},o=async a=>{let l=new AbortController,c=setTimeout(()=>l.abort(),2e4);try{let u=JSON.stringify(a?{...i,provider:jv(a)}:i),d=await fetch(Xf,{method:"POST",signal:l.signal,headers:s,body:u}),f=await d.json().catch(()=>({}));return{r:d,j:f}}finally{clearTimeout(c)}};try{let{r:a,j:l}=await o();if(!a.ok){let v=l?.error?.message||l?.message||JSON.stringify(l).slice(0,300);return{ok:!0,callable:!1,status:a.status,ms:Date.now()-n,error:s$(a.status,v),restriction:i$(v)}}let c=typeof l?.provider=="string"?l.provider:void 0,u=l?.content?.find?.(v=>v.type==="text")?.text??l?.content?.[0]?.text??"ok",d=Vf(l?.usage?.cache_creation_input_tokens),{r:f,j:p}=await o(c),{works:h,read:m,note:g}=o$(f.ok,p?.usage,c);return h===!0&&c&&(Zf[t]=c,ct===t&&(Bn=c)),{ok:!0,callable:!0,status:a.status,ms:Date.now()-n,provider:c,sample:String(u).trim().slice(0,60),cache:{works:h,created:d,read:m,note:g}}}catch(a){let l=V(a);return{ok:!0,callable:!1,ms:Date.now()-n,error:/abort/i.test(l)?"timed out (20s)":l}}}var MI,Xf,DI,BI,Dv,jI,Yf,dl,fl,ll,Qf,Br,Dn,ct,Bn,ui,di,fi,Zf,Vf,jv,Wv,Kv=S(()=>{"use strict";Rr();Gt();qt();MI="https://openrouter.ai/api",Xf=`${MI}/v1/messages`,DI="typebulb-proxy-managed",BI="The typebulb model override was reverted to Anthropic, but this Claude Code session still points at the now-idle proxy. Reload the window (VS Code/Cursor: \u201CDeveloper: Reload Window\u201D) or relaunch `claude` in a terminal to return to your Anthropic subscription.",Dv=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"],jI=5e3,Yf=["low","medium","high"],dl=t=>ul(t,".claude","settings.local.json"),fl=t=>ul(t,".claude",".cc-switcher.json"),ll=t=>`http://127.0.0.1:${t}`;Qf=t=>/^anthropic\//i.test(t)||/claude/i.test(t),Br=null,Dn=null,ct=null,Bn=null,ui=null,di="unknown",fi=1,Zf={},Vf=t=>typeof t=="number"?t:0,jv=t=>({order:[t],allow_fallbacks:!1});Wv=/data policy|no endpoints|no allowed providers|privacy|requires.*(training|logging|data)/i;(async function(){try{let e=Qt(fl(X)),n=e?.active?.model;if(!n)return;let s=(Qt(dl(X))?.env||{}).ANTHROPIC_BASE_URL||"";if(!/127\.0\.0\.1|localhost/.test(s))return;let i=await Jv(n,e.active.provider??Zf[n]??null);console.log(`[switcher] re-adopted override after restart: ${n} via ${ll(i)}`)}catch(e){console.error("[switcher] boot reconcile failed",V(e))}})()});var zv={};Ai(zv,{agentMessage:()=>Fo,attach:()=>h$,blockToMarkdown:()=>jo,breakout:()=>$f,capText:()=>Pe,childStatus:()=>v$,cleanUserText:()=>Ut,clearSwitchModel:()=>t$,closeChild:()=>y$,composerPasteRead:()=>b$,displayName:()=>l$,downloadSample:()=>Jf,firstLineDigest:()=>De,git:()=>we,gitChangedFiles:()=>pf,gitDiff:()=>hf,info:()=>c$,isHiddenTurn:()=>Ps,launchBulb:()=>Bf,listBreakouts:()=>Nf,listBulbFiles:()=>Mf,listChildren:()=>m$,listMyBulbs:()=>Kf,listSamples:()=>qf,listSessions:()=>f$,listSwitchModels:()=>XI,logInlineStatus:()=>d$,openChild:()=>g$,openFile:()=>If,poll:()=>u$,predictTrustOf:()=>jf,probeModel:()=>a$,pullRemoteBulb:()=>Hf,pushLocalBulb:()=>zf,readBulbLog:()=>Uf,repoRoot:()=>Rn,saveOpenRouterKey:()=>n$,searchBulbs:()=>Df,searchSessions:()=>p$,setBulbTrust:()=>Ff,setReasoning:()=>e$,setSwitchModel:()=>ZI,shutdownSwitcher:()=>r$,stopBreakout:()=>Lf,summarizeTurn:()=>w$,switchState:()=>QI,toolResultDigest:()=>qu});var Hv,l$,c$,u$,d$,f$,p$,h$,m$,g$,y$,b$,w$,v$,Yv=S(()=>{"use strict";il();Uo();al();Nr();Kv();Uo();Cs();Hv=new nr,l$=Hv.displayName,{info:c$,poll:u$,logInlineStatus:d$,listSessions:f$,searchSessions:p$,attach:h$,listChildren:m$,openChild:g$,closeChild:y$,composerPasteRead:b$,summarizeTurn:w$,childStatus:v$}=Dr(Hv)});var Gv={};Ai(Gv,{attach:()=>C$,breakout:()=>$f,childStatus:()=>$$,closeChild:()=>_$,composerPasteRead:()=>R$,displayName:()=>S$,downloadSample:()=>Jf,git:()=>we,gitChangedFiles:()=>pf,gitDiff:()=>hf,info:()=>k$,launchBulb:()=>Bf,listBreakouts:()=>Nf,listBulbFiles:()=>Mf,listChildren:()=>O$,listMyBulbs:()=>Kf,listSamples:()=>qf,listSessions:()=>A$,logInlineStatus:()=>E$,openChild:()=>P$,openFile:()=>If,poll:()=>x$,predictTrustOf:()=>jf,pullRemoteBulb:()=>Hf,pushLocalBulb:()=>zf,readBulbLog:()=>Uf,repoRoot:()=>Rn,searchBulbs:()=>Df,searchSessions:()=>T$,setBulbTrust:()=>Ff,stopBreakout:()=>Lf,summarizeTurn:()=>I$});var Vv,S$,k$,x$,E$,A$,T$,C$,O$,P$,_$,R$,I$,$$,Xv=S(()=>{"use strict";il();Vu();al();Nr();Vv=new sr,S$=Vv.displayName,{info:k$,poll:x$,logInlineStatus:E$,listSessions:A$,searchSessions:T$,attach:C$,listChildren:O$,openChild:P$,closeChild:_$,composerPasteRead:R$,summarizeTurn:I$,childStatus:$$}=Dr(Vv)});import{readFileSync as N$,writeFileSync as L$,mkdirSync as M$}from"fs";import{homedir as D$}from"os";import*as pl from"path";async function eS(){try{let t=await fetch(new URL("/api/tags",Zv()).toString(),{signal:AbortSignal.timeout(B$)});return t.ok?((await t.json()).models??[]).map(n=>n.name).filter(n=>!!n):[]}catch{return[]}}function tS(t){let e;try{e=N$(t,"utf-8")}catch{return{json:void 0,unreadable:!1}}try{let n=JSON.parse(e);if(n&&typeof n=="object"&&!Array.isArray(n)){let r=n;return{json:r,unreadable:"providers"in r&&!ep(r)}}}catch{}return{json:void 0,unreadable:!0}}function ep(t){let e=t?.providers;return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function j$(t){let e=ep(t);if(!e||!("ollama"in e))return null;let n=e.ollama?.models;return Array.isArray(n)?n.map(r=>r?.id).filter(r=>typeof r=="string"):[]}async function nS(){let{json:t,unreadable:e}=tS(Qv());return e?{installed:[],configured:null}:{installed:await eS(),configured:j$(t)}}async function rS(){let t=await eS();return t.length?F$(Qv(),t,Zv()):{ok:!1,error:"Ollama is not running (or has no models installed)"}}function F$(t,e,n){let{json:r,unreadable:s}=tS(t);if(s)return{ok:!1,error:`could not parse ${t} \u2014 edit the ollama provider there yourself`};let i={...r??{},providers:{...ep(r)??{},ollama:{baseUrl:`${n}/v1`,api:"openai-completions",apiKey:"ollama",models:e.map(o=>({id:o}))}}};try{M$(pl.dirname(t),{recursive:!0}),L$(t,JSON.stringify(i,null,2)+`
|
|
2088
|
+
`)}catch(o){return{ok:!1,error:`could not write ${t}: ${V(o)}`}}return{ok:!0,count:e.length}}var B$,Qv,Zv,sS=S(()=>{"use strict";Gt();Rr();B$=1500,Qv=()=>pl.join(D$(),".pi","agent","models.json"),Zv=()=>mr(process.env.OLLAMA_HOST??"http://localhost:11434")});var oS={};Ai(oS,{attach:()=>z$,breakout:()=>$f,closeChild:()=>G$,composerFiles:()=>eN,composerNew:()=>Z$,composerPaste:()=>rN,composerPasteRead:()=>sN,composerRpc:()=>nN,composerSend:()=>X$,composerStop:()=>Q$,composerUiRespond:()=>tN,displayName:()=>U$,downloadSample:()=>Jf,git:()=>we,gitChangedFiles:()=>pf,gitDiff:()=>hf,info:()=>q$,launchBulb:()=>Bf,listBreakouts:()=>Nf,listBulbFiles:()=>Mf,listChildren:()=>Y$,listMyBulbs:()=>Kf,listSamples:()=>qf,listSessions:()=>K$,logInlineStatus:()=>W$,ollamaOffer:()=>nS,ollamaSync:()=>rS,openChild:()=>V$,openFile:()=>If,poll:()=>J$,predictTrustOf:()=>jf,pullRemoteBulb:()=>Hf,pushLocalBulb:()=>zf,readBulbLog:()=>Uf,repoRoot:()=>Rn,searchBulbs:()=>Df,searchSessions:()=>H$,setBulbTrust:()=>Ff,shutdownComposer:()=>oN,stopBreakout:()=>Lf,summarizeTurn:()=>iN});var iS,U$,q$,J$,W$,K$,H$,z$,Y$,V$,G$,X$,Q$,Z$,eN,tN,nN,rN,sN,iN,oN,aS=S(()=>{"use strict";il();df();al();Nr();sS();iS=new $r,U$=iS.displayName,{info:q$,poll:J$,logInlineStatus:W$,listSessions:K$,searchSessions:H$,attach:z$,listChildren:Y$,openChild:V$,closeChild:G$,composerSend:X$,composerStop:Q$,composerNew:Z$,composerFiles:eN,composerUiRespond:tN,composerRpc:nN,composerPaste:rN,composerPasteRead:sN,summarizeTurn:iN,shutdownComposer:oN}=Dr(iS)});import*as Rk from"fs/promises";import*as Ct from"path";Ti();Z();function Du(t){if(!He.includes(t))throw new Error(`Unknown block kind '${t}' (one of: ${He.join(", ")})`);return t}function uy(t){let e=[];for(let n of t){let r=n.indexOf("=");if(r<=0||r===n.length-1)throw new Error(`Expected <kind>=<source>, got '${n}' (e.g. data=results.json, or data=- for stdin)`);let s=Du(n.slice(0,r));if(e.some(i=>i.kind===s))throw new Error(`Duplicate block kind '${s}' \u2014 each block can be written once per invocation`);e.push({kind:s,source:n.slice(r+1)})}if(e.filter(n=>n.source==="-").length>1)throw new Error("Only one <kind>=- can read stdin");return e}Uo();Vu();df();var hl={claude:{adapter:()=>new nr,server:()=>Promise.resolve().then(()=>(Yv(),zv))},codex:{adapter:()=>new sr,server:()=>Promise.resolve().then(()=>(Xv(),Gv))},pi:{adapter:()=>new $r,server:()=>Promise.resolve().then(()=>(aS(),oS))}};function lS(t){return t in hl}function jr(){return Object.keys(hl)}function Zt(){return Object.fromEntries(Object.entries(hl).map(([t,e])=>[t,e.adapter]))}function cS(t){return hl[t].server()}var pi=Zt();function uS(){for(let t of Object.values(pi))try{t().ensureHarnessSupport()}catch{}}function Ne(){for(let t of Object.keys(pi))try{if(pi[t]().detectsSelf())return t}catch{}}function dS(t){let e=jr(),n=new Map(e.filter(i=>pi[i]).map(i=>[i,pi[i]()]));for(let[i,o]of n)if(o.detectsSelf())return{name:i};let r=[...n].filter(([,i])=>i.detectsInstalled()).map(([i])=>i);if(r.length===0)return{name:e[0]};if(r.length===1)return{name:r[0]};let s=i=>n.get(i).listSessionFiles(t).length>0;return{ambiguous:[...r].sort((i,o)=>Number(s(o))-Number(s(i)))}}var np=5e3;function tp(t){try{return t()}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exit(1)}}function fS(t){let n={subcommand:"run",file:"",watch:!0,open:process.env.TERM_PROGRAM==="vscode"||Ne()!==void 0?"link":"window",server:!1,trust:!1,noTrust:!1,force:!1,follow:!1,clear:!1,help:!1,version:!1,callArgs:[],hasArgsFlag:!1},r=["call","check","predict","logs","wait","stop","restart","trust","untrust","models","slug","send","pull","push","get","put","status","babysit"],s=t[0];if(s==="agent"||s?.startsWith("agent:")){n.subcommand="agent";let o=s.indexOf(":");if(o!==-1){let a=s.slice(o+1);a&&(n.agentTarget=a)}t=t.slice(1)}else s&&r.includes(s)&&(n.subcommand=s,t=t.slice(1));let i=[];for(let o=0;o<t.length;o++){let a=t[o];if(a==="--help"||a==="-h")n.help=!0;else if(a==="--version"||a==="-V")n.version=!0;else if(a==="--no-watch")n.watch=!1;else if(a==="--open")n.open="window";else if(a==="--no-open")n.open="none";else if(a==="--server")n.server=!0;else if(a==="--trust")n.trust=!0;else if(a==="--no-trust")n.noTrust=!0;else if(a==="--force")n.force=!0;else if(a==="--mode"){let l=t[++o];(!l||l.startsWith("-"))&&(console.error("Missing value for --mode (e.g. --mode staging)"),process.exit(1)),n.mode=l}else if(a==="--follow"||a==="-f")n.follow=!0;else if(a==="--clear")n.clear=!0;else if(a==="--run"){let l=t[++o];if(l==="latest")n.run="latest";else{let c=parseInt(l,10);(isNaN(c)||c<1)&&(console.error(`Invalid --run value: ${l} (a run number, or 'latest')`),process.exit(1)),n.run=c}}else if(a==="--bulbs")n.stopScope="bulbs";else if(a==="--agent")n.stopScope="agent";else if(a==="--global")n.stopScope="global";else if(a==="--wake")n.wake=!0;else if(a==="--match"){let l=t[++o];l===void 0&&(console.error("Missing value for --match (a literal substring new log lines must contain)"),process.exit(1)),n.match=l}else if(a==="--timeout"){let l=parseInt(t[++o],10);(isNaN(l)||l<=0)&&(console.error(`Invalid --timeout value: ${t[o]} (seconds)`),process.exit(1)),n.timeoutSec=l}else if(a==="--wait"||a.startsWith("--wait="))if(a.startsWith("--wait=")){let l=parseInt(a.slice(7),10);(isNaN(l)||l<=0)&&(console.error(`Invalid --wait value: ${a.slice(7)} (milliseconds)`),process.exit(1)),n.sendWaitMs=l}else n.sendWaitMs=np;else if(a==="--lines"||a==="-n"){let l=parseInt(t[++o],10);(isNaN(l)||l<0)&&(console.error(`Invalid --lines value: ${t[o]}`),process.exit(1)),n.lines=l}else if(a==="--port"||a==="-p"){let l=t[++o],c=parseInt(l,10);isNaN(c)&&(console.error(`Invalid port: ${l}`),process.exit(1)),n.port=c}else if(a==="--replace"||a.startsWith("--replace=")){let l=a.startsWith("--replace=")?a.slice(10):t[++o]??"",c=tp(()=>Pp(l));n.local&&(console.error(`--replace can only be used once (got '${n.local.name}' and '${c.name}')`),process.exit(1)),n.local=c}else if(a==="--args"||a.startsWith("--args=")){n.hasArgsFlag=!0;let l=a.startsWith("--args=")?a.slice(7):t[++o];l===void 0&&(console.error("Missing value for --args (a JSON array, or - to read it from stdin)"),process.exit(1)),n.argsJson=l}else if(!a.startsWith("-")||a==="-"&&n.subcommand==="send")["call","send","get","put","slug","status"].includes(n.subcommand)?i.push(a):n.file=a;else{let l=n.subcommand==="call"?" (for a negative or dash-leading argument, use --args '<json-array>')":"";console.error(`Unknown option: ${a}${l}`),process.exit(1)}}return n.subcommand==="call"&&(i.length<2&&(console.error("Usage: typebulb call <file> <fn> [arg\u2026]"),process.exit(1)),n.file=i[0],n.fn=i[1],n.callArgs=i.slice(2)),n.subcommand==="send"&&(i.length<1&&(console.error("Usage: typebulb send <file> [message]"),process.exit(1)),n.file=i[0],n.sendMessage=i[1]),n.subcommand==="slug"&&(i.length||(console.error("Usage: typebulb slug <bulb name>"),process.exit(1)),n.slugName=i.join(" ")),n.subcommand==="status"&&i.length&&(n.statusQuery=i.join(" ")),n.subcommand==="get"&&(i.length!==2&&(console.error("Usage: typebulb get <file> <kind>"),process.exit(1)),n.file=i[0],n.blockKind=tp(()=>Du(i[1]))),n.subcommand==="put"&&(i.length<2&&(console.error("Usage: typebulb put <file> <kind>=<source> [<kind>=<source> \u2026]"),process.exit(1)),n.file=i[0],n.blockPairs=tp(()=>uy(i.slice(1)))),n}function pS(){console.log(`
|
|
2119
2089
|
typebulb - Local bulb runner for Typebulb
|
|
2120
2090
|
|
|
2121
2091
|
Usage:
|
|
@@ -2197,15 +2167,25 @@ Usage:
|
|
|
2197
2167
|
Batch flags: --bulbs (this project's bulbs, the
|
|
2198
2168
|
mirror survives), --agent (this project's mirror),
|
|
2199
2169
|
--global (every bulb + mirror, all projects).
|
|
2170
|
+
typebulb restart [file|pid|agent]
|
|
2171
|
+
Relaunch running servers on this typebulb's
|
|
2172
|
+
version, each with its own flags and port, so an
|
|
2173
|
+
open tab reattaches (no arg: this project's bulbs
|
|
2174
|
+
and mirror). Batch flags as for stop.
|
|
2200
2175
|
typebulb trust [file] Remember a bulb as Trusted, so a later run grants
|
|
2201
2176
|
fs/AI/server.ts without --trust (no arg: list the
|
|
2202
2177
|
remembered-trusted bulbs).
|
|
2203
2178
|
typebulb untrust <file> Forget a bulb's trust (back to Restricted).
|
|
2204
|
-
typebulb status [agent] A sub-agent's Status:
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2179
|
+
typebulb status [agent] A sub-agent's Status: what it waits on, commands
|
|
2180
|
+
failing repeatedly, uncommitted files. Name it by
|
|
2181
|
+
id or a piece of its description; no arg: the
|
|
2182
|
+
session's overview. Claude Code, Codex.
|
|
2183
|
+
typebulb babysit Watch your sub-agents and stay silent until one
|
|
2184
|
+
needs you (an idle stall, a background call left
|
|
2185
|
+
running, a failure streak, several agents waiting
|
|
2186
|
+
at once), then print it and exit.
|
|
2187
|
+
Run it in the background; the exit is your
|
|
2188
|
+
wake-up. Run it again after handling it.
|
|
2209
2189
|
|
|
2210
2190
|
Options:
|
|
2211
2191
|
-f, --follow Stream new log output until interrupted (logs)
|
|
@@ -2293,7 +2273,7 @@ Examples:
|
|
|
2293
2273
|
typebulb my-editor.bulb.md
|
|
2294
2274
|
typebulb --no-watch my-editor.bulb.md
|
|
2295
2275
|
typebulb .
|
|
2296
|
-
`)}
|
|
2276
|
+
`)}xt();Ls();Ti();Bs();xt();import*as We from"path";import{spawn as NN,execSync as LN}from"child_process";import{createRequire as MN}from"module";import{existsSync as DN}from"fs";import*as Se from"fs/promises";import*as ve from"path";var rp=[{name:"es5"},{name:"es2015.core"},{name:"es2015.collection"},{name:"es2015.promise"},{name:"es2015.iterable"},{name:"es2015.symbol"},{name:"es2015.symbol.wellknown"},{name:"es2015.generator"},{name:"es2015.proxy"},{name:"es2015.reflect"},{name:"es2016.array.include"},{name:"es2016.intl"},{name:"es2017.object"},{name:"es2017.string"},{name:"es2017.sharedmemory"},{name:"es2017.typedarrays"},{name:"es2017.date"},{name:"es2017.intl"},{name:"es2018.asynciterable"},{name:"es2018.asyncgenerator"},{name:"es2018.promise"},{name:"es2018.regexp"},{name:"es2018.intl"},{name:"es2019.array"},{name:"es2019.object"},{name:"es2019.string"},{name:"es2019.symbol"},{name:"es2019.intl"},{name:"es2020.bigint"},{name:"es2020.promise"},{name:"es2020.string"},{name:"es2020.sharedmemory"},{name:"es2020.date"},{name:"es2020.number"},{name:"es2020.symbol.wellknown"},{name:"es2020.intl"},{name:"es2021.promise"},{name:"es2021.string"},{name:"es2021.weakref"},{name:"es2021.intl"},{name:"es2022.array"},{name:"es2022.object"},{name:"es2022.error"},{name:"es2022.string"},{name:"es2022.regexp"},{name:"es2022.intl"},{name:"es2023.array"},{name:"es2023.collection"},{name:"es2023.intl",since:"5.5"},{name:"es2024.arraybuffer",since:"5.5"},{name:"es2024.collection",since:"5.5"},{name:"es2024.object",since:"5.5"},{name:"es2024.promise",since:"5.5"},{name:"es2024.regexp",since:"5.5"},{name:"es2024.sharedmemory",since:"5.5"},{name:"es2024.string",since:"5.5"},{name:"esnext.array",since:"5.5"},{name:"esnext.collection"},{name:"esnext.decorators"},{name:"esnext.disposable"},{name:"esnext.error",since:"5.5"},{name:"esnext.float16",since:"5.5"},{name:"esnext.iterator",since:"5.5"},{name:"esnext.object"},{name:"esnext.promise"},{name:"esnext.sharedmemory",since:"5.5"},{name:"esnext.intl"}],sp=[{name:"dom"},{name:"dom.iterable"},{name:"dom.asynciterable"}];function ip(t,e){if(!e)return t.filter(s=>!s.since);let n={"5.0":0,"5.5":1},r=n[e];return t.filter(s=>!s.since||n[s.since]<=r)}Z();var aN=`
|
|
2297
2277
|
/**
|
|
2298
2278
|
* Get raw data chunk from the Data tab.
|
|
2299
2279
|
* @param index - Chunk index (0-based). Separate chunks with 2 blank lines.
|
|
@@ -2304,7 +2284,7 @@ Examples:
|
|
|
2304
2284
|
* @param index - Chunk index (0-based)
|
|
2305
2285
|
* @throws If chunk is not valid JSON/JSON-ish
|
|
2306
2286
|
*/
|
|
2307
|
-
json<T = unknown>(index: number): T;`,
|
|
2287
|
+
json<T = unknown>(index: number): T;`,lN=`
|
|
2308
2288
|
/**
|
|
2309
2289
|
* Get the insight data produced by the inference layer.
|
|
2310
2290
|
*
|
|
@@ -2313,7 +2293,7 @@ Examples:
|
|
|
2313
2293
|
*
|
|
2314
2294
|
* @returns The parsed insight JSON, or undefined if no insight is available
|
|
2315
2295
|
*/
|
|
2316
|
-
insight<T = unknown>(): T | undefined;`,
|
|
2296
|
+
insight<T = unknown>(): T | undefined;`,cN=`
|
|
2317
2297
|
/**
|
|
2318
2298
|
* Replace the data this run is working on.
|
|
2319
2299
|
*
|
|
@@ -2336,7 +2316,7 @@ Examples:
|
|
|
2336
2316
|
*
|
|
2337
2317
|
* @param value - Any JSON-serializable value
|
|
2338
2318
|
*/
|
|
2339
|
-
setInsight(value: unknown): Promise<void>;`,
|
|
2319
|
+
setInsight(value: unknown): Promise<void>;`,hS=`options: {
|
|
2340
2320
|
messages: Array<{ role: "user" | "assistant"; content: string }>;
|
|
2341
2321
|
system?: string;
|
|
2342
2322
|
/** Reasoning effort: 0=minimal, 1=low, 2=med, 3=high, 4=xhigh. Mapped to each provider's native mechanism (OpenAI/OpenRouter reasoning effort, Gemini thinking level, Anthropic adaptive thinking). 0 reaches the vendor's explicit off switch, and floors to a little thinking only on always-thinking models. 4 reaches the rung above high where the vendor has one (OpenAI/OpenRouter xhigh, Anthropic max) and clamps to high where it doesn't (Gemini) \u2014 never an error. Pin 1 (low) for most work; pick 0 deliberately, when you want the raw model or latency is the constraint. Omitting is NOT off \u2014 it buys the model's own default (medium on GPT-5.6), which reasons and bills invisibly. Ignored on the courtesy model, which runs at the level Typebulb sets. */
|
|
@@ -2347,7 +2327,7 @@ Examples:
|
|
|
2347
2327
|
webSearch?: boolean;
|
|
2348
2328
|
/** Abort the request. On abort the promise rejects / the stream ends. */
|
|
2349
2329
|
signal?: AbortSignal;
|
|
2350
|
-
}`,
|
|
2330
|
+
}`,mS=`
|
|
2351
2331
|
/** Provider-reported token counts for one call \u2014 real usage from the API, never an estimate.
|
|
2352
2332
|
* \`output\` is total billed output (reasoning included); \`reasoning\` is the itemized subset where
|
|
2353
2333
|
* the provider splits it (OpenAI, Gemini, OpenRouter \u2014 Anthropic doesn't); \`cacheRead\` is the
|
|
@@ -2359,10 +2339,10 @@ type AiChunk =
|
|
|
2359
2339
|
| { kind: "text"; text: string }
|
|
2360
2340
|
| { kind: "reasoning"; text: string }
|
|
2361
2341
|
| { kind: "usage"; usage: AiUsage };
|
|
2362
|
-
`,
|
|
2342
|
+
`,gS=`
|
|
2363
2343
|
/** What backs \`tb.ai\`: the user's own keys, the quota-limited courtesy model, or nothing. */
|
|
2364
2344
|
type AiAccess = "own" | "courtesy" | "none";
|
|
2365
|
-
`,
|
|
2345
|
+
`,yS=`
|
|
2366
2346
|
/**
|
|
2367
2347
|
* General-purpose AI call. \`tb.ai(opts)\` resolves with the full text; \`tb.ai.stream(opts)\`
|
|
2368
2348
|
* returns an async iterable of {@link AiChunk} deltas you consume with \`for await\`.
|
|
@@ -2372,7 +2352,7 @@ type AiAccess = "own" | "courtesy" | "none";
|
|
|
2372
2352
|
* @throws On rate limit, network error, or provider error
|
|
2373
2353
|
*/
|
|
2374
2354
|
ai: {
|
|
2375
|
-
(${
|
|
2355
|
+
(${hS}): Promise<{ text: string; usage?: AiUsage }>;
|
|
2376
2356
|
/**
|
|
2377
2357
|
* Streaming counterpart of \`tb.ai()\`. Yields \`{ kind: "text" | "reasoning", text }\` deltas
|
|
2378
2358
|
* as they arrive, then one final \`{ kind: "usage", usage }\` chunk with the call's token
|
|
@@ -2389,8 +2369,8 @@ type AiAccess = "own" | "courtesy" | "none";
|
|
|
2389
2369
|
* if (c.kind === "text") answer += c.text;
|
|
2390
2370
|
* }
|
|
2391
2371
|
*/
|
|
2392
|
-
stream(${
|
|
2393
|
-
};`,
|
|
2372
|
+
stream(${hS}): AsyncIterable<AiChunk>;
|
|
2373
|
+
};`,bS=`
|
|
2394
2374
|
/**
|
|
2395
2375
|
* Returns AI models available to the current user.
|
|
2396
2376
|
* Models are filtered by the user's configured API keys.
|
|
@@ -2420,7 +2400,7 @@ type AiAccess = "own" | "courtesy" | "none";
|
|
|
2420
2400
|
* \`tb.mode\` or the length of \`tb.models()\` \u2014 which hosts offer a courtesy
|
|
2421
2401
|
* model is the host's business and changes without your bulb changing.
|
|
2422
2402
|
*/
|
|
2423
|
-
aiAccess(): Promise<AiAccess>;`,
|
|
2403
|
+
aiAccess(): Promise<AiAccess>;`,uN="\n /**\n * The bulb's theme override (`<html data-theme>`).\n *\n * - Get: the current override \u2014 `'dark'` | `'light'`, or `undefined` when\n * following the OS preference.\n * - Set `'dark'`/`'light'` to force and persist it (per-bulb); set\n * `undefined` to clear the override and follow the OS again.\n *\n * Drives `<html data-theme>`, so render off `html[data-theme=\"\u2026\"]` selectors\n * (or observe the attribute) rather than reading `tb.theme`.\n */\n theme: 'light' | 'dark' | undefined;",wS=`
|
|
2424
2404
|
/**
|
|
2425
2405
|
* The mode this bulb is running in.
|
|
2426
2406
|
*
|
|
@@ -2430,7 +2410,7 @@ type AiAccess = "own" | "courtesy" | "none";
|
|
|
2430
2410
|
* - \`'inline'\` \u2014 Running inline in an agent's transcript, rendered by the mirror
|
|
2431
2411
|
* (sandboxed, client-only: AI, filesystem, and server RPC are unavailable)
|
|
2432
2412
|
*/
|
|
2433
|
-
mode: ${
|
|
2413
|
+
mode: ${ry};`,vS=`
|
|
2434
2414
|
/**
|
|
2435
2415
|
* Local filesystem access (CLI only).
|
|
2436
2416
|
*
|
|
@@ -2451,7 +2431,7 @@ type AiAccess = "own" | "courtesy" | "none";
|
|
|
2451
2431
|
list(path?: string): Promise<Array<{ name: string; dir: boolean; mtime: number }>>;
|
|
2452
2432
|
/** Remove a file, or a folder and everything in it. Throws if the path does not exist; the bulb's folder itself cannot be removed. */
|
|
2453
2433
|
remove(path: string): Promise<boolean>;
|
|
2454
|
-
};`,
|
|
2434
|
+
};`,SS=`
|
|
2455
2435
|
/**
|
|
2456
2436
|
* The bulb's folder \u2014 absolute path to \`<bulb-dir>/<filename-stem>/\`
|
|
2457
2437
|
*
|
|
@@ -2459,7 +2439,7 @@ type AiAccess = "own" | "courtesy" | "none";
|
|
|
2459
2439
|
* \`tb.fs\` already resolves relative paths against it, so bulb code writing
|
|
2460
2440
|
* its own files never needs it. CLI only \u2014 throws in ide/published/inline mode.
|
|
2461
2441
|
*/
|
|
2462
|
-
readonly dir: string;`,
|
|
2442
|
+
readonly dir: string;`,dN=`
|
|
2463
2443
|
/**
|
|
2464
2444
|
* Async value inspector for tensor-like objects.
|
|
2465
2445
|
*
|
|
@@ -2512,48 +2492,49 @@ type AiAccess = "own" | "courtesy" | "none";
|
|
|
2512
2492
|
*
|
|
2513
2493
|
* @returns The full canonical URL
|
|
2514
2494
|
*/
|
|
2515
|
-
url(): Promise<string>;`,
|
|
2495
|
+
url(): Promise<string>;`,fN="\n /**\n * Subscribe to a value pushed from the terminal via `typebulb send <file> [message]`.\n *\n * The dual of `tb.log` (data out): a value sent *in* from the CLI, no `--trust` required.\n * Use it to start expensive work on demand instead of on load \u2014 e.g. `tb.onMessage(() => start())`\n * \u2014 so hot reloads don't re-trigger it while you edit, and an agent kicks off one run when ready.\n *\n * The message is the JSON-parsed value of what `send` was given (or the raw string if it isn't\n * JSON; `undefined` for a bare `typebulb send <file>`). A non-`undefined` return value (awaited)\n * becomes the reply `send --wait` prints on stdout \u2014 JSON-serializable, at most one handler\n * replying \u2014 the structured read-back for self-tests. Returns an unsubscribe function. Inert in\n * an inline bulb (no sender) \u2014 the handler is registered but never fires.\n *\n * @param handler - Called with each pushed message; may return a JSON-serializable reply.\n * @returns An unsubscribe function.\n */\n onMessage(handler: (message: any) => unknown): () => void;",pN="\n /**\n * Print to the CLI's stdout \u2014 the bulb's log channel, read back with `typebulb logs <file>`.\n *\n * Ungated: needs no `server.ts` block and no `--trust`, so a Restricted client-only bulb can\n * instrument itself. Args cross to the CLI as JSON; where no CLI serves the page (web, inline,\n * or a transport failure) it falls back to the browser console. Works in `server.ts` too (same\n * as `console.log` there).\n */\n log(...args: any[]): void;",hN="\n /**\n * Server-side function proxy.\n *\n * In the CLI, calls exported functions from the `**server.ts**` section.\n *\n * A normal export is awaited for its result (`await tb.server.fn()`). An `async function*`\n * export streams: `for await (const chunk of tb.server.gen())`. The call object supports both;\n * break the `for await` to cancel and tear down the server generator.\n */\n server: Record<string, (...args: any[]) => Promise<any> & AsyncIterable<any>>;",op=`${mS}${gS}
|
|
2516
2496
|
/**
|
|
2517
2497
|
* Typebulb utilities namespace.
|
|
2518
2498
|
* Type \`tb.\` to discover available helpers.
|
|
2519
2499
|
*/
|
|
2520
|
-
declare const tb: {${
|
|
2500
|
+
declare const tb: {${aN}${dN}${lN}${cN}${pN}${hN}${fN}${yS}${vS}${SS}${bS}${uN}${wS}
|
|
2521
2501
|
};
|
|
2522
|
-
`,
|
|
2502
|
+
`,mN=`
|
|
2523
2503
|
/**
|
|
2524
2504
|
* Print to the CLI's stdout \u2014 the same channel as \`console.log\` here (the server's console IS
|
|
2525
2505
|
* the bulb's log). One log verb across blocks: page-side \`tb.log\` reaches this same stdout.
|
|
2526
2506
|
*/
|
|
2527
|
-
log(...args: any[]): void;`,
|
|
2507
|
+
log(...args: any[]): void;`,ap=`${mS}${gS}
|
|
2528
2508
|
/**
|
|
2529
2509
|
* Typebulb utilities namespace (server-side).
|
|
2530
2510
|
* Type \`tb.\` to discover available helpers.
|
|
2531
2511
|
*/
|
|
2532
|
-
declare const tb: {${
|
|
2512
|
+
declare const tb: {${mN}${yS}${vS}${SS}${bS}${wS}
|
|
2533
2513
|
};
|
|
2534
|
-
`;
|
|
2514
|
+
`;wt();import wN from"p-limit";wt();import{resolve as xS}from"resolve.exports";var At={maxRelativeTypeRefs:500,maxBareDeps:8,maxBareDepth:3,prefetchConcurrency:4,negativeTtlMs:1e4},hi=["index.d.ts","index.d.mts"],lp=/\.d\.(ts|mts|cts)$/i;function ml(t){return/\.d\.(ts|mts|cts)(?:[?#].*)?$/i.test(t)||/[?&]dts(?:[&#]|$)/i.test(t)}function kS(t){return[`${t}.d.ts`,`${t}.d.mts`]}function en(t){if(!t||t==="./"||t==="/")return[...hi];let e=t.replace(/\.(mjs|cjs|js|mts|cts|ts)$/i,""),n=kS(e),r=e.endsWith("/")?e:`${e}/`;return n.push(...kS(`${r}index`)),n}async function Fr(t,{retries:e=2,timeoutMs:n=15e3,init:r}={}){for(let s=0;s<=e;s++){let i=new AbortController,o=setTimeout(()=>i.abort(),n);try{let a=await fetch(t,{...r,signal:i.signal});if(gN(a.status)&&s<e)continue;return a}catch{if(s<e)continue;return}finally{clearTimeout(o)}}}function gN(t){return t===408||t===429||t>=500&&t<600}var gl=class{constructor(e,n){this.fetchDts=e,this.cdnClient=n}async tryUrls(e){for(let n of e){let r=await this.fetchDts(n);if(r&&(this.looksLikeDts(r.dts)||ml(r.url)))return r}}looksLikeDts(e){return/^\s*export\s*\{\s*\}\s*;?\s*$/m.test(e)?!0:/declare\s+(module|namespace|class|interface|function|const|var|let)/.test(e)||/interface\s+\w+/.test(e)||/type\s+\w+\s*=/.test(e)}async loadPackageAtVersionedRoot(e,n){let r=this.cdnClient.packageJson(new j({name:e,version:n})),s=await Fr(r);if(!s?.ok)return;let i;try{i=await s.json()}catch{return}if(i)return{pkg:i,baseDir:this.cdnClient.baseDir(new j({name:e,version:n??i.version})),version:n}}extractPathFromResult(e){if(typeof e=="string")return e;if(Array.isArray(e))return e.find(n=>typeof n=="string")}async tryUntilSuccess(e,n){for(let r of e){let s=await n(r);if(s)return s}}async resolveFromSelected(e,n,r){if(e.kind==="types"){let o=Tn(e.path);if(!o||o==="/"||o===".")return this.tryUntilSuccess([...hi],n);if(!lp.test(o)){let a=await this.tryUntilSuccess(en(o),n);if(a)return a}return n(o)}let s=en(e.path),i=r?.subpath?[...s,...hi]:[...hi,...s];return this.tryUntilSuccess(i,n)}toResolutionResult(e){return{kind:lp.test(e)?"types":"probe",path:e}}resolveExportsPath(e,n){let r=n||".",s=e;try{let i=this.extractPathFromResult(xS(s,r,{conditions:["types"]}));if(i)return i}catch{}try{return this.extractPathFromResult(xS(s,r,{browser:!0,conditions:["import","default","module","browser","node"]}))}catch{return}}async resolve(e){try{let n=j.parse(e),{pkg:r,baseDir:s}=await this.loadPackageAtVersionedRoot(n.name,n.version)||{};if(!r||!s)return;let i={name:n.name,version:n.version},o=new j(i).format(),a=new j({...i,subpath:n.subpath}).format(),l=d=>this.fetchCandidateFrom(s,n.name,d);if(n.subpath){let d=jd(n.subpath),f=this.resolveExportsPath(r,d);if(f){let h=await this.resolveFromSelected(this.toResolutionResult(f),l,{subpath:!0});if(h)return{...h,resolvedPkg:a}}let p=await this.tryUntilSuccess(en(d),l);if(p)return{...p,resolvedPkg:a}}let c=r.types??r.typings;if(c){let d=await this.resolveFromSelected({kind:"types",path:c},l);if(d)return{...d,resolvedPkg:o}}let u=this.resolveExportsPath(r,".");if(u){let d=await this.resolveFromSelected(this.toResolutionResult(u),l);if(d)return{...d,resolvedPkg:o}}return}catch{return}}async fetchCandidateFrom(e,n,r){let s=Tn(r),i=new URL(s,e).toString(),o=await this.tryUrls([i]);return o?{dts:o.dts,url:o.url,resolvedPkg:n}:void 0}};wt();import{gunzipSync as yN}from"fflate";var yl=class{async fetchAndExtract(e,n){let r=this.getTarballUrl(e,n),s=await Fr(r,{timeoutMs:3e4});if(!s?.ok)return new Map;let i=new Uint8Array(await s.arrayBuffer());return this.extractDtsFiles(i)}getTarballUrl(e,n){return`https://registry.npmjs.org/${e.replace("/","%2F")}/-/${e.split("/").pop()}-${n}.tgz`}normalizeTarPath(e){let n=e.replace(/^package\//,""),r=n.indexOf("/");return r>0?n.substring(r+1):n}extractDtsFiles(e){let n=new Map;try{let r=yN(e),s=new TextDecoder("utf-8"),i=0;for(;i<r.length-512;){let o=r.slice(i,i+512);if(o[0]===0)break;let a=o.slice(0,100),l=a.indexOf(0),c=s.decode(a.slice(0,l>0?l:100)).trim(),u=o.slice(124,136),d=s.decode(u).trim().replace(/\0/g,""),f=parseInt(d,8)||0,p=String.fromCharCode(o[156]);if(i+=512,(p==="0"||p==="\0")&&(c.endsWith(".d.ts")||c.endsWith(".d.mts"))){let h=r.slice(i,i+f);n.set(this.normalizeTarPath(c),s.decode(h))}i+=Math.ceil(f/512)*512}}catch{}return n}};var bl=class{constructor(e,n,r=new yl){this.cdnClient=e,this.cache=n,this.tarballFetcher=r}typesNameCandidates(e){let n=e.startsWith("@")?e.slice(1).replace("/","__"):e;return n.includes(".")?[n,n.split(".").join("-"),n.split(".").join("")]:[n]}selectTypesVersion(e,n,r){try{if(r){let i=Cn.majorOf(r),o=e.filter(a=>Cn.majorOf(a)===i);if(o.length)return o.sort((a,l)=>Cn.cmp(l,a))[0]}let s=n?.latest;return s&&e.includes(s)?s:e[0]}catch{return e[0]}}subpathCandidates(e){let n=e.replace(/\.(mjs|cjs|js|mts|cts|ts)$/i,""),r=en(e);return n!==e&&r.push(`${e}.d.ts`,`${e}/index.d.ts`),r}async fetchFromVersionedRoot(e,n){let r=new j(e),s=r.version;if(!s)return;let i;try{i=await this.tarballFetcher.fetchAndExtract(r.name,s)}catch{return}if(!i||i.size===0)return;for(let[a,l]of i.entries()){let c=this.cdnClient.file(e,a);try{await this.cache.setCachedFile(c,l)}catch{}}let o=n.subpath?this.subpathCandidates(n.subpath):["index.d.ts"];for(let a of o){let l=i.get(a);if(l)return{dts:l,url:this.cdnClient.file(e,a),resolvedPkg:n.subpath?new j(n).format():n.name}}}async resolve(e){let n=j.parse(e);if(n.name)for(let r of this.typesNameCandidates(n.name)){let s=`@types/${r}`,i;try{i=await this.cdnClient.fetchVersionsIndex(s)}catch{continue}if(!i?.versions?.length)continue;let o=this.selectTypesVersion(i.versions,i.distTags,n.version),a=await this.fetchFromVersionedRoot(`${s}@${o}`,n);if(a)return a}}};var wl=class{collectRelativeTypeRefs(e){return this.collectRefs(e).filter(n=>n.startsWith("./")||n.startsWith("../"))}collectBareModuleRefs(e){return this.collectRefs(e).filter(n=>this.isBare(n))}collectRefs(e){let n=e.split(`
|
|
2535
2515
|
`).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://"))}};
|
|
2537
|
-
`);await this.prefetchBareDeps(
|
|
2538
|
-
`,"utf8"),await
|
|
2539
|
-
`,"utf8"),{dir:e}}function
|
|
2540
|
-
`))console.log(`${e} ${r}`);return t.length>0}function
|
|
2516
|
+
`),r=new Set;for(let s of n.matchAll(/(import|export)\s+[^'"\n]*from\s*['"]([^'"\n]+)['"]/g))r.add(s[2]);for(let s of n.matchAll(/export\s*\*\s*from\s*['"]([^'"\n]+)['"]/g))r.add(s[1]);return Array.from(r)}isBare(e){return!(e.startsWith("./")||e.startsWith("../")||e.startsWith("file:")||e.startsWith("http://")||e.startsWith("https://"))}};wt();var ES="file:///node_modules",vl=class{constructor(){this.epoch=0}bumpEpoch(){this.epoch+=1}epochDir(){return`__tsepoch_${this.epoch}`}pathForMain(e){return`${ES}/${this.epochDir()}/${e}/index.d.ts`}pathFor(e,n){let r=Tn(n);return`${ES}/${this.epochDir()}/${e}/${r}`}};import{LRUCache as bN}from"lru-cache";function AS(t){let e=new bN({ttl:At.negativeTtlMs,max:500}),n=new Map;return async function(s){try{if(await t.isNegative(s)||e.has(s))return;let i=await t.getCachedFile(s);if(i)return{dts:i,url:s};let o=n.get(s);if(o)return o;let a=(async()=>{let l=await Fr(s,{init:{cache:"no-store"}});if(!l?.ok){l?.status===404&&(e.set(s,!0),await t.recordNegative(s));return}let c=await l.text(),u=l.url||s;return await t.clearNegative(s),await t.setCachedFile(u,c),{dts:c,url:u}})();return n.set(s,a),await a.finally(()=>n.delete(s))}catch{return}}}var mi=class{constructor(e){this.inFlight=new Map,this.scanner=new wl,this.cache=e.cache,this.cdnClient=e.cdnClient,this.versionResolver=e.versionResolver,this.packageService=e.packageService,this.fetchDts=AS(e.cache),this.typescriptProvider=new gl(this.fetchDts,e.cdnClient),this.definitelyTypedProvider=new bl(e.cdnClient,e.cache),this.virtualFs=new vl}withInFlight(e,n){let r=this.inFlight.get(e);if(r)return r;let s=n().finally(()=>this.inFlight.delete(e));return this.inFlight.set(e,s),s}invalidate(){this.virtualFs.bumpEpoch(),this.inFlight.clear()}pushFileIfNew(e,n,r){e.some(s=>s.path===n)||e.push({path:n,content:r})}createStubDef(e){let n=this.virtualFs.pathForMain(e);return{pkg:e,mainPath:n,files:[{path:n,content:"export const _shim: any; export default _shim;"}],shims:[{module:e,path:n}]}}async fetchViaProviders(e){for(let n of[this.typescriptProvider,this.definitelyTypedProvider])try{let r=await n.resolve(e);if(r?.dts)return r}catch{}}async fetchRootDts(e,n){let{effectivePackage:r,root:s,pinned:i}=await this.versionResolver.effectivePackage(e,n),o=await this.cache.getCachedDts(r);if(o?.content){let l=o.url??this.cdnClient.file(i?`${s}@${i}`:s,"index.d.ts");return{dts:o.content,url:l,resolvedPkg:r}}let a;try{a=await this.fetchViaProviders(r)}catch{return}if(!(!a?.dts||!a.url)&&new j(r).subpath===new j(a.resolvedPkg||r).subpath){try{await this.cache.setCachedDts(r,a.dts,a.url)}catch{}return a}}extractPackageRootUrl(e){let n=e.pathname.match(/^(.+@[^/]+\/)/);return n?new URL(n[1],e.origin):new URL("./",e)}toVirtualPath(e,n,r){let s=n.pathname.startsWith(e.pathname)?n.pathname.slice(e.pathname.length):`__deps__/${encodeURIComponent(n.toString()).replace(/%/g,"_")}.d.ts`;return this.virtualFs.pathFor(r,s)}computeEntryPath(e,n){if(!e)return{mainPath:this.virtualFs.pathForMain(n),packageRootUrl:void 0};let r=new URL(e),s=this.extractPackageRootUrl(r);return{mainPath:this.toVirtualPath(s,r,n),packageRootUrl:s}}async expandRelativeRefs(e,n,r,s,i=new Set,o){if(!i.has(n)&&(i.add(n),!(i.size>At.maxRelativeTypeRefs)))try{let a=new URL(n),l=new URL("./",a);o??(o=this.extractPackageRootUrl(a));let c=this.scanner.collectRelativeTypeRefs(e).slice(0,At.maxRelativeTypeRefs);for(let u of c)await this.tryRelativeRef(u,l,o,r,s,i)}catch{}}async tryRelativeRef(e,n,r,s,i,o){try{let a=new URL(e,n),l=a.pathname+a.search,c=ml(l)?[l]:en(l);for(let u of c){let f=new URL(u,a).toString();if(o.has(f))return;let p=await this.fetchDts(f);if(p?.dts){let h=this.toVirtualPath(r,new URL(p.url),s);this.pushFileIfNew(i,h,p.dts),await this.expandRelativeRefs(p.dts,p.url,s,i,o,r);return}}}catch{}}isDifferentPackage(e,n){return e===n?!1:new j(e).name!==new j(n).name}ambientlyDeclares(e,n){if(/^(?:import|export)\b/m.test(e))return!1;for(let r of e.matchAll(/declare\s+module\s+['"]([^'"]+)['"]/g)){let s=r[1];if(s===n||s.endsWith("/*")&&n.startsWith(s.slice(0,-1)))return!0}return!1}markFileAmbient(e,n){let r=e.find(s=>s.path===n);r&&(r.ambient=!0)}async prefetchBareDeps(e,n,r,s,i){try{let o=this.scanner.collectBareModuleRefs(e).slice(0,At.maxBareDeps).filter(c=>this.isDifferentPackage(c,n));if(!o.length)return;let a=new Set([n]),l=wN(At.prefetchConcurrency);await Promise.all(o.map(c=>l(()=>this.prefetchBareDepsRecursive(c,r,s,At.maxBareDepth,a,i).catch(()=>{}))))}catch{}}async prefetchBareDepsRecursive(e,n,r,s,i,o){if(s<=0||i.has(e))return;i.add(e);let a=await this.fetchRootDts(e,o);if(!a?.dts)return;let l=a.resolvedPkg||e,c=this.virtualFs.pathForMain(l);this.pushFileIfNew(n,c,a.dts),this.ambientlyDeclares(a.dts,e)?this.markFileAmbient(n,c):r.push({module:e,path:c}),a.url&&await this.expandRelativeRefs(a.dts,a.url,l,n);let u=this.scanner.collectBareModuleRefs(a.dts).slice(0,At.maxBareDeps).filter(d=>!i.has(d));for(let d of u)await this.prefetchBareDepsRecursive(d,n,r,s-1,i,o)}async resolve(e,n,r){let s=await this.packageService.extractImports(e),i=r?[...s,...r]:s;return(await Promise.all(i.map(a=>this.resolveOne(a,n)))).filter(a=>!!a)}async resolveOne(e,n){let{effectivePackage:r}=await this.versionResolver.effectivePackage(e,n);return this.withInFlight(r,async()=>{let s=new j(e),i=await this.fetchRootDts(e,n)??(s.subpath?await this.fetchRootDts(s.name,n):void 0);return i?this.buildDefFromContent(e,i,i.resolvedPkg||e,n):this.createStubDef(e)})}async buildDefFromContent(e,n,r,s){let{dts:i,url:o,resolvedPkg:a}=n,l=new j(a||r),c=l.version?`${l.name}@${l.version}`:l.name,{mainPath:u,packageRootUrl:d}=this.computeEntryPath(o,c),f=[{path:u,content:i}],p=[];o&&await this.expandRelativeRefs(i,o,c,f,void 0,d);let h=f.map(A=>A.content).join(`
|
|
2517
|
+
`);await this.prefetchBareDeps(h,c,f,p,s);let m=l.format(),g=e===m?[e]:[e,m],v=g.some(A=>this.ambientlyDeclares(i,A));return v?this.markFileAmbient(f,u):p.push(...g.map(A=>({module:A,path:u}))),{pkg:e,mainPath:u,files:f,shims:p,ambient:v}}};Vd();wt();Er();Qs();zd();xr();import*as Ur from"path";var vN=Ur.join(Sa,"pkg"),SN=Ur.join(Sa,"files"),kN=Ur.join(Sa,"negative.json"),kl=class{pkgMem=new Map;fileMem=new Map;negativeCache=new On(new Ar(kN));async getCachedDts(e){if(this.pkgMem.has(e))return this.pkgMem.get(e);await te();let n=await vt(TS(e));return this.pkgMem.set(e,n),n}async setCachedDts(e,n,r){let s={content:n,url:r};this.pkgMem.set(e,s),await Sl(async()=>{await te(),await Fe(TS(e),JSON.stringify(s))})}async getCachedFile(e){if(this.fileMem.has(e))return this.fileMem.get(e);await te();let n=await va(CS(e));return this.fileMem.set(e,n),n}async setCachedFile(e,n){this.fileMem.set(e,n),await Sl(async()=>{await te(),await Fe(CS(e),n)})}isNegative(e){return this.negativeCache.isNegative(e)}async recordNegative(e){await Sl(async()=>{await te(),await this.negativeCache.recordNegative(e)})}clearNegative(e){return Sl(()=>this.negativeCache.clearNegative(e))}};async function Sl(t){try{await t()}catch{}}function TS(t){return Ur.join(vN,et(t)+".json")}function CS(t){return Ur.join(SN,et(t)+".txt")}Er();var cp;function xN(){return cp||(cp=new mi({cache:new kl,cdnClient:uw,packageService:Aa,versionResolver:cw})),cp}var OS="file:///node_modules/";async function PS(t){let e=ka(t.emitKey,"typecheck");await te(),await Se.rm(e,{recursive:!0,force:!0}),await Se.mkdir(e,{recursive:!0});let n=CN(t.jsxImportSource,t.dependencies),r=await xN().resolve(t.code,t.dependencies,n),s=t.local?.name,i=s?r.filter(u=>u.pkg!==s):r,o=new Set;for(let u of i)for(let d of u.files){let f=xl(d.path);if(!f||o.has(f))continue;o.add(f);let p=ve.join(e,"node_modules",f);await Se.mkdir(ve.dirname(p),{recursive:!0}),await Se.writeFile(p,d.content,"utf8")}let a={};for(let u of i)for(let d of u.shims){let f=xl(d.path);f&&(a[d.module]=[`./node_modules/${f}`])}for(let u of i){if(u.ambient)continue;let d=xl(u.mainPath);d&&(a[u.pkg]=[`./node_modules/${d}`])}let l=new Set;for(let u of i)for(let d of u.files){if(!d.ambient)continue;let f=xl(d.path);f&&l.add(`node_modules/${f}`)}if(t.local){delete a[t.local.name];let u=await ON(t.local,e);u?a[t.local.name]=[`./node_modules/${t.local.name}/${u}`]:console.warn(` local: '${t.local.name}' ships no type defs; check cannot type against it.`)}let c=EN(t.jsxImportSource,a,[...l]);return await Se.writeFile(ve.join(e,"tsconfig.json"),JSON.stringify(c,null,2)+`
|
|
2518
|
+
`,"utf8"),await Se.writeFile(ve.join(e,"code.tsx"),t.code,"utf8"),await Se.writeFile(ve.join(e,"tb.d.ts"),op,"utf8"),{dir:e}}var up={target:"es2023",module:"esnext",moduleResolution:"bundler",strict:!0,noEmit:!0,skipLibCheck:!0,esModuleInterop:!0,allowSyntheticDefaultImports:!0,forceConsistentCasingInFileNames:!0};function EN(t,e,n=[]){return{compilerOptions:{...up,lib:AN([...rp,...sp]),jsx:"react-jsx",jsxImportSource:t??"react",paths:e},include:["code.tsx","tb.d.ts",...n]}}function AN(t){return ip(t).map(e=>TN(e.name))}function TN(t){return t.split(".").map(e=>/^es\d+$/i.test(e)?e.toUpperCase():e==="dom"?"DOM":e==="esnext"?"ESNext":e.charAt(0).toUpperCase()+e.slice(1)).join(".")}function CN(t,e){let n=t??("react"in e?"react":void 0);return n?[`${n}/jsx-runtime`,`${n}/jsx-dev-runtime`]:[]}function xl(t){if(!t.startsWith(OS))return;let e=t.slice(OS.length),n=e.indexOf("/");if(!(n<0))return e.slice(n+1)}async function ON(t,e){if(!t.typesAbs)return;let n=ve.dirname(t.typesAbs),r=ve.join(e,"node_modules",t.name);for(let s of await PN(n)){let i=ve.join(r,ve.relative(n,s));await Se.mkdir(ve.dirname(i),{recursive:!0}),await Se.copyFile(s,i)}return ve.basename(t.typesAbs)}async function PN(t){let e=[];async function n(r){let s=await Se.readdir(r,{withFileTypes:!0});for(let i of s){let o=ve.join(r,i.name);i.isDirectory()?await n(o):/\.d\.ts(\.map)?$/.test(i.name)&&e.push(o)}}return await n(t),e}import*as Je from"fs/promises";import*as Tt from"path";import{existsSync as _N}from"fs";Er();Xd();var RN="^22";async function _S(t){let e=ka(t.emitKey,"typecheck-server");await te(),await Je.rm(e,{recursive:!0,force:!0}),await Je.mkdir(e,{recursive:!0});let n=Tt.join(t.bulbDir,".typebulb"),r=Ia(t.server).filter(o=>o!==t.local?.name);await Ra([`@types/node@${RN}`,...r],n,t.dependencies,{ignoreScripts:!0});let s=Tt.join(n,"node_modules"),i=Tt.join(e,"node_modules");return await $N(s,i),await Je.writeFile(Tt.join(e,"server.ts"),t.server,"utf8"),await Je.writeFile(Tt.join(e,"tb.d.ts"),ap,"utf8"),await Je.writeFile(Tt.join(e,"tsconfig.json"),JSON.stringify(IN(t.local),null,2)+`
|
|
2519
|
+
`,"utf8"),{dir:e}}function IN(t){let e={...up,lib:["ES2023"],types:["node"]};if(t?.typesAbs){let n=i=>i.replace(/\\/g,"/"),r=n(Tt.dirname(t.typesAbs)),s=n(t.typesAbs).replace(/\.d\.ts$/,"");e.paths={[t.name]:[s],[`${t.name}/*`]:[`${r}/*`]}}return{compilerOptions:e,include:["server.ts","tb.d.ts"]}}async function $N(t,e){if(!_N(t)){await Je.mkdir(e,{recursive:!0});return}await Je.rm(e,{recursive:!0,force:!0});let n=process.platform==="win32"?"junction":"dir";await Je.symlink(t,e,n)}oa();Z();async function IS(t,e){let{bulb:n,config:r,warnings:s,starts:i}=await nt(t),o=We.basename(t),a=m=>i.get(m)??1;!n.code&&!n.server&&(console.error("Bulb has neither **code.tsx** nor **server.ts**; nothing to check."),process.exit(1));let l=!1,c=!1;for(let m of s)console.log(`structure ${m}`);s.length&&(l=!0);let u=Pr(We.resolve(t)),d=u?Zn(n.name):"";u&&d&&d!==u.slug&&(console.log(`naming filename '${u.slug}.bulb.md' doesn't match the title '${n.name}' \u2014 its slug derives to '${d}'. Rename the file to '${d}.bulb.md', or change name: to suit the filename.`),c=!0),n.code&&(l=RS(Ms(n.code,{target:"client",dependencies:r.dependencies??{},lineOffset:a("code.tsx")}),"client")||l),n.server&&(l=RS(Ms(n.server,{target:"server",lineOffset:a("server.ts")}),"server")||l);let f=UN([process.cwd(),We.dirname(t)]);if(!f){let m=We.relative(process.cwd(),t)||t;console.error("check: TypeScript not found \u2014 install it once, then re-run:"),console.error(" npm i -g typescript"),console.error(` typebulb check ${m}`),process.exit(2)}let p=[];if(n.code){let{dir:m}=await PS({code:n.code,dependencies:r.dependencies??{},jsxImportSource:r.ts?.jsxImportSource,emitKey:t,local:e});p.push({role:"client",dir:m})}if(n.server){let{dir:m}=await _S({server:n.server,bulbDir:We.dirname(t),emitKey:t,local:e?{name:e.name,typesAbs:e.typesAbs}:void 0,dependencies:r.dependencies});p.push({role:"server",dir:m})}for(let{role:m,dir:g}of p){let{stdout:v,exitCode:A}=await jN(f,g);for(let C of v.split(/\r?\n/))C.trim()&&console.log(`${m} ${BN(C,o,a)}`);A!==0&&(l=!0)}l&&process.exit(1);let h=[n.code&&"code.tsx",n.server&&"server.ts"].filter(Boolean).join(", ");console.error(c?`\u2713 type-checks (${h}) \u2014 see the naming warning above`:`\u2713 no issues (${h})`)}function RS(t,e){for(let n of t)for(let r of n.message.split(`
|
|
2520
|
+
`))console.log(`${e} ${r}`);return t.length>0}function BN(t,e,n){return t.replace(/\b(code\.tsx|server\.ts)\((\d+),(\d+)\)/g,(r,s,i,o)=>`${e}(${Number(i)+n(s)-1},${o})`)}function jN(t,e){return new Promise(n=>{let r=NN(process.execPath,[t,"--noEmit"],{cwd:e}),s="";r.stdout?.on("data",i=>{s+=i.toString()}),r.stderr?.on("data",i=>{s+=i.toString()}),r.on("close",i=>n({stdout:s,exitCode:i??1}))})}var FN=MN(import.meta.url);function UN(t){let e=r=>{try{let s=FN.resolve("typescript/package.json",{paths:r}),i=We.join(We.dirname(s),"lib","tsc.js");return DN(i)?i:void 0}catch{return}},n=e(t);if(n)return n;try{let r=LN("npm root -g",{encoding:"utf8"}).trim();return e([r])}catch{return}}xt();ia();Bs();async function $S(t,e){let{bulb:n}=await nt(t),r=fr(n);if(Sn(t)){console.log("remembered-trusted \u2014 runs with filesystem / AI / server.ts automatically (`typebulb untrust` to revoke)."),r&&console.log(` (it uses ${r})`);return}r?(console.log(`This bulb appears to use ${r}; it runs Restricted unless you grant trust:`),console.log(` ${e}`)):console.log("No privileged capability detected \u2014 runs Restricted by default. (A clean scan is a hint, not a guarantee.)")}Bs();import*as gi from"path";async function NS(t,e){if(!t){e||(console.error("Usage: typebulb untrust <file.bulb.md>"),process.exit(1));let r=bd();if(!r.length){console.log("No bulbs are remembered as trusted.");return}console.log("Trusted bulbs (run with fs/AI/server.ts without --trust):");for(let s of r)console.log(` ${s}`);return}let n=gi.resolve(t);n.endsWith(".bulb.md")||(console.error("File must have .bulb.md extension"),process.exit(1));try{pr(n,e)}catch(r){console.error(r.message),process.exit(1)}console.log(e?`Trusted ${gi.basename(n)} \u2014 runs with fs / AI / server.ts (no --trust needed).`:`Untrusted ${gi.basename(n)} \u2014 runs Restricted.`),console.log(` ${n}`)}je();import*as DS from"readline";Md();function dp(t){let e=n=>r=>t?`\x1B[${n}m${r}\x1B[0m`:r;return{lit:e("38;5;70"),litLink:e("4;38;5;70"),brand:e("38;5;135")}}var qN=5e3,El=()=>Math.round(performance.now()),LS=t=>t>=1e3?`${(t/1e3).toFixed(1)}s`:`${t}ms`;async function BS(t){let e=dS(process.cwd()),n=El();if("ambiguous"in e){let r=await JN(t,e.ambiguous);return r?MS(t,r,{boot:n,from:El()}):WN(t,e.ambiguous)}return MS(t,e.name,{boot:n,from:El()})}async function MS(t,e,n){let r,s;try{r=await Ns(e)}catch(p){s=p instanceof Error?p.message:String(p)}let i=El()-n.from,{lit:o,litLink:a,brand:l}=dp(process.stdout.isTTY===!0),c=[" Read the authoring skill before writing a bulb:",` \u2022 ${o(qs())}`],u=r?[` Agent mirror (${e}) is live\u{1F4A1}`,` ${o("\u25CF")} ${a(r.url)}`," Inline bulbs render live here."," Agents:",` Reusable app/tool \u2192 write a ${o(".bulb.md")}`," Show something inline \u2192 emit an inline bulb"," emit it with no .bulb.md draft first",...e==="codex"?[" verify it this turn \u2014 foreground-wait, bounded:",` \u2022 ${o('typebulb wait agent --match "[inline <name>" --timeout 120')}`," via exec_command; while it still runs,"," poll it with write_stdin until it exits"]:[e==="pi"?" arm a wait for its render verdict \u2014 run it plainly:":" background a wait for its render verdict:",` \u2022 ${o('typebulb wait agent --match "[inline <name>"')}`],...c," End this reply with the mirror link above"," \u2022 easy to miss the link mid-message"]:[` The mirror did not start (${s})`,` \u25CF Start it manually: ${o(`npx typebulb agent:${e}`)}`," Agents:",...c],d=n.boot+i>qN?[` slow launch: boot ${LS(n.boot)} \xB7 mirror ${LS(i)}`]:[],f=[` ${l(`typebulb v${t}`)}`,...d,...u,""];process.stdout.write(f.join(`
|
|
2541
2521
|
`)+`
|
|
2542
|
-
`)}async function
|
|
2522
|
+
`)}async function JN(t,e){if(!process.stdin.isTTY||!process.stdout.isTTY)return;let{lit:n,brand:r}=dp(!0),s=[` ${r(`typebulb v${t}`)}`," More than one agent harness is available here.",...e.map((o,a)=>` ${n(String(a+1))}) ${o}`),""];process.stdout.write(s.join(`
|
|
2543
2523
|
`)+`
|
|
2544
|
-
`);let i=
|
|
2524
|
+
`);let i=DS.createInterface({input:process.stdin,output:process.stdout});try{let o=(await new Promise(l=>i.question(" Open which? [1]: ",l))).trim();if(o==="")return e[0];let a=Number(o);return Number.isInteger(a)&&a>=1&&a<=e.length?e[a-1]:e.find(l=>l===o.toLowerCase())}finally{i.close()}}function WN(t,e){let{lit:n,brand:r}=dp(process.stdout.isTTY===!0),s=[` ${r(`typebulb v${t}`)}`," More than one agent harness is available here."," Open the mirror for the one you want:",...e.map(i=>` \u2022 ${n(`npx typebulb agent:${i}`)}`),""];process.stdout.write(s.join(`
|
|
2545
2525
|
`)+`
|
|
2546
|
-
`)}
|
|
2547
|
-
`+e)}function
|
|
2526
|
+
`)}Ze();kn();async function jS(t){be(t);let e=await yt();if(e.length>0){console.log(Pb(e,process.env.TB_AI_PROVIDER,process.env.TB_AI_MODEL));return}if(!vd()){console.log("No AI provider keys found in this directory's .env, and no local Ollama server detected."),console.log("Set one of these to use a cloud model with tb.ai:");for(let[n,r]of Object.entries(hr))console.log(` ${r.padEnd(20)} (${n})`);console.log("\u2026or start Ollama (http://localhost:11434, or set OLLAMA_HOST) for local models. Then re-run `typebulb models`.");return}console.log("Couldn't fetch the model catalog (offline?). tb.ai still works with any valid provider/model id for your keys.")}Z();function FS(t){t?.trim()||(console.error("Usage: typebulb slug <bulb name>"),process.exit(1));let e=Zn(t);e||(console.error(`'${t}' has no slug \u2014 a bulb name needs at least one letter or digit.`),process.exit(1)),console.log(e)}Be();import*as JS from"path";import{valid as qS,lt as HN}from"semver";je();var rt={connected:"[page] connected",disconnected:"[page] disconnected",closed:t=>`[page] closed: ${t}`},fp=3e3,US=1e4,KN=2500,Al=class{attached=new Set;leaving=new Set;arrivalWaiters=new Set;goneWaiters=new Set;arrivalSubs=[];settledEmpty;dropAt=0;get count(){return this.attached.size}get lastDropAt(){return this.dropAt}[Symbol.iterator](){return this.attached[Symbol.iterator]()}add(e,n){this.attached.add(e);for(let s of[...this.arrivalWaiters])s(!0);let r={page:e,firstAttach:n,count:this.attached.size};for(let s of this.arrivalSubs)s(r)}closing(e){this.attached.delete(e)&&this.leaving.add(e)}dropped(e){if(this.leaving.delete(e)){this.drainIfGone();return}if(!this.attached.delete(e))return;let n=this.dropAt=Date.now();setTimeout(()=>{this.attached.size===0&&this.dropAt===n&&this.settledEmpty?.()},fp).unref()}async closeAll(e){let n=[...this.attached];if(!n.length)return{told:0,gone:0};await Promise.all(n.map(s=>s.close(e).catch(()=>{}))),await this.whenGone(n,KN);let r=n.filter(s=>!this.leaving.has(s)).length;for(let s of n)this.leaving.delete(s);return{told:n.length,gone:r}}whenArrives(e){return this.attached.size>0?Promise.resolve(!0):e>0?new Promise(n=>{let r=i=>{clearTimeout(s),this.arrivalWaiters.delete(r),n(i)},s=setTimeout(()=>r(!1),e);s.unref(),this.arrivalWaiters.add(r)}):Promise.resolve(!1)}onArrival(e){this.arrivalSubs.push(e)}onSettledEmpty(e){this.settledEmpty=e}whenGone(e,n){return e.some(r=>this.leaving.has(r))?new Promise(r=>{let s=()=>{e.some(o=>this.leaving.has(o))||(clearTimeout(i),this.goneWaiters.delete(s),r())},i=setTimeout(()=>{this.goneWaiters.delete(s),r()},n);i.unref(),this.goneWaiters.add(s)}):Promise.resolve()}drainIfGone(){for(let e of[...this.goneWaiters])e()}};Xo();function zN(t,e,n,r){if(/^\d+$/.test(e))return t.find(i=>i.pid===parseInt(e,10));let s=e==="agent"?t.filter(ye):t.filter(i=>i.agent===e);if(s.length){if(!n)return s[0];let i=s.filter(o=>cr(o,n));return r&&i.find(o=>o.agent===r)||i[0]}return t.find(i=>oe(i.file)===oe(e))}var tn=t=>t.agent??JS.basename(t.file);function WS(t){return t===Ae?!1:t&&qS(t)&&qS(Ae)?HN(t,Ae):!0}function YN(t){return t===Ae?"":t?WS(t)?` STALE runtime v${t} (this CLI is v${Ae} \u2014 relaunch to update)`:` runtime v${t} (newer than this CLI's v${Ae})`:" STALE runtime (predates the version stamp \u2014 relaunch to update)"}function VN(t,e){return e===void 0?" pages ?":e>0?` ${e} page${e===1?"":"s"}`:ye(t)?" NO PAGE (no tab open on it)":" NO PAGE (nothing of it is running)"}function KS(t,e,n){t.forEach((r,s)=>e(` ${r.url} pid ${r.pid} ${r.trust?"trusted":"restricted"}${n?VN(r,n[s]):""}${YN(r.version)} ${r.file}`))}async function hp(t,e){if(!t.length){console.log("No running bulb servers.");return}let n=await Promise.all(t.map(cd));console.log("Running bulb servers:"),KS(t,r=>console.log(r),n),console.log(`
|
|
2527
|
+
`+e)}function Tl(t,e,n,r,s){let i=zN(t,e,r,s);if(i)return i;console.error(`No running server for '${e}'.`),t.length?(console.error(`Running servers (try \`typebulb ${n} <file|pid>\`):`),KS(t,o=>console.error(o))):console.error("No bulb servers are running."),process.exit(1)}async function HS(t,e){if(!t){e.clear&&(console.error("Specify which server to clear: typebulb logs --clear <file|pid>"),process.exit(1)),await hp(await G(process.cwd()),"Run `typebulb logs <file|pid>` to print one server's console.");return}let n=Tl(await G(),t,"logs",process.cwd(),Ne());if(e.clear){nd(n.pid),console.log(`Cleared log for ${tn(n)} (pid ${n.pid}).`);return}let r=Xe(n.pid),s=r.text;if(e.run!==void 0?(s=sd(s,e.run),s||console.error(e.run==="latest"?"No output in the latest run yet (the server has logged nothing since its last reload).":`No output for run ${e.run} (it hasn't started, or was trimmed from the log).`)):!s&&!e.follow&&console.error("Log is empty \u2014 this server has logged nothing yet."),e.lines&&e.lines>0){let i=s.split(`
|
|
2548
2528
|
`);i.length&&i[i.length-1]===""&&i.pop(),s=i.slice(-e.lines).join(`
|
|
2549
2529
|
`)}if(process.stdout.write(s),s&&!s.endsWith(`
|
|
2550
2530
|
`)&&process.stdout.write(`
|
|
2551
|
-
`),e.follow&&e.run===void 0){let i=r.offset,o=setInterval(()=>{let l=
|
|
2552
|
-
`);
|
|
2553
|
-
`)
|
|
2531
|
+
`),e.follow&&e.run===void 0){let i=r.offset,o=setInterval(()=>{let l=Xe(n.pid,i);i=l.offset,l.text&&process.stdout.write(l.text)},500),a=()=>{clearInterval(o),process.exit(0)};process.on("SIGINT",a),process.on("SIGTERM",a),await new Promise(()=>{})}}var GN=t=>new Promise(e=>setTimeout(e,t));async function zS(t,e){if(!t){hp(await G(process.cwd()),"Run `typebulb wait <file|pid>` to block until one logs a new line.");return}let n=Tl(await G(),t,"wait",process.cwd(),Ne()),r=e.wake?await XN():void 0,s=process.env.TYPEBULB_WAIT_SHIM==="1",i=process.env.TYPEBULB_WAIT_FOLLOW==="1",o=s||i,a=e.timeoutSec??1800,l=e.match??"",c=Xe(n.pid).offset,u=i?void 0:Zo(n.pid,l)??(l?Zo(n.pid):void 0),d=i?c:u!==void 0&&u<=c?u:l?0:c,f=Date.now()+a*1e3,p=ye(n)?1e4:1e3,h=2e3,m=!ye(n)&&!i,g,v="",A=[],C="",x=0,R=!1;for(;;){let I=d>=c,L=Xe(n.pid,d);if(d=L.offset,L.text){v+=L.text;let T=v.split(`
|
|
2532
|
+
`);v=T.pop()??"";let F=!1;for(let H of T)H.trim()&&(m&&I&&H.startsWith(rt.disconnected)&&(F=!0),!(e.match&&!H.includes(e.match))&&(console.log(H),A.push(H),!i&&(g??=Date.now()+p,ye(n)&&(H.includes("] compile error")||H.includes("] runtime error"))&&(g=Math.min(g,Date.now()+h)))));if(F&&!g){C=`the last page of ${tn(n)} closed while waiting \u2014 a bulb runs in its page, so nothing can log ${e.match?`'${e.match}'`:"anything"} now`,console.error(C),x=3;break}}if(g&&Date.now()>=g)break;if(!o&&!g&&Date.now()>=f){C=`timeout: no ${e.match?`line matching '${e.match}'`:"new output"} from ${tn(n)} within ${a}s`,console.error(C),x=2;break}if(!or(n.pid)){g||(C=`server ${tn(n)} (pid ${n.pid}) exited while waiting`,console.error(C),x=3,R=!0);break}await GN(400)}if(r){console.error(`detected ${new Date().toISOString()}`);try{await r.adapter.wake(r.sessionId,"typebulb_wait",A.length?A.join(`
|
|
2533
|
+
`):C)}catch(I){console.error(`Not delivered: ${I instanceof Error?I.message:I}`),process.exit(4)}console.error(`accepted ${new Date().toISOString()}`)}R&&process.exit(3),i||Is(n.pid,d,l),process.exit(x)}async function XN(){let t=Ne(),e=t?Zt()[t]?.():void 0,n=e?.wake?e.callerSessionId?.(process.cwd()):void 0;(!e||!n)&&(console.error(e?.wake?"Can't --wake: your own session couldn't be identified in this project, and a wake goes to no other.":`--wake needs a harness that wakes through its host (here: ${t??"none detected"}); on Claude Code, a background wait already wakes you.`),process.exit(1));let r=await e.wakeRoute(n);return r.error&&(console.error(`Can't --wake: ${r.error}.`),process.exit(1)),{adapter:e,sessionId:n}}function YS(t,e){if(e==="killed")return` \u2014 forced (${WS(t.version)?`its runtime ${t.version?`v${t.version} `:""}predates the stop route`:"it did not answer"}); a page it opened may still be open`;let n=[];return e.closed&&n.push(`closed ${e.closed} page${e.closed===1?"":"s"}`),e.stuck&&n.push(`${e.stuck} did not close`),n.length?` \u2014 ${n.join(", ")}`:""}async function VS(t){if(!t){await hp(await G(process.cwd()),"Run `typebulb stop <file|pid>` to stop one.");return}let e=Tl(await G(),t,"stop",process.cwd(),Ne()),n=await gt(e);console.log(`Stopped ${tn(e)} (pid ${e.pid}, ${e.url}).${YS(e,n)}`)}async function GS(t){let e=await pp(t),n=t==="global"?"server":t==="agent"?"mirror":"bulb";if(!e.length){console.log(t==="global"?"No running bulb servers.":`No running ${n}s for this project.`);return}let r=await Promise.all(e.map(s=>gt(s)));console.log(`Stopped ${e.length} ${n}${e.length===1?"":"s"}:`),e.forEach((s,i)=>console.log(` ${s.url} pid ${s.pid} ${tn(s)}${YS(s,r[i])}`))}async function pp(t){let e=process.cwd(),n=t==="agent"?Ne():void 0;return t==="global"?await G():t==="bulbs"?await G(e):(await G()).filter(r=>cr(r,e)&&(!n||r.agent===n))}async function XS(t,e){let n=process.cwd(),r=t?[Tl(await G(),t,"restart",n,Ne())]:e?await pp(e):[...await G(n),...await pp("agent")];if(!r.length){console.log(e==="global"?"No running bulb servers.":"No running bulbs or mirrors for this project.");return}console.log(`Restarting on v${Ae}:`);for(let s of r){let i=s.version?`v${s.version}`:"unknown version";try{let o=ye(s)?(await gt(s,"keep"),await Ns(s.agent,s.cwd??n)):await bn(s.file,{cwd:s.cwd??n,open:!1,trust:s.trust,noTrust:!s.trust,mode:s.mode,watch:s.watch,replace:s.replace});console.log(` ${o.url} ${tn(s)} ${i} \u2192 v${Ae}`)}catch(o){console.log(` ${s.url} ${tn(s)} failed: ${o instanceof Error?o.message:o}`),process.exitCode=1}}}je();Be();mn();import*as Cl from"path";import*as QS from"http";import{mkdir as QN,writeFile as ZN}from"fs/promises";async function qr(){let t=[];for await(let e of process.stdin)t.push(e);return Buffer.concat(t).toString("utf-8")}function yi(t){return(t.charCodeAt(0)===65279?t.slice(1):t).replace(/\r\n/g,`
|
|
2534
|
+
`).trimEnd()}function e1(t,e){return new Promise((n,r)=>{let s=new URL(t),i=QS.request({hostname:s.hostname,port:s.port,path:s.pathname+s.search,method:"POST",headers:{"Content-Type":"text/plain","Content-Length":Buffer.byteLength(e)}},o=>{let a="";o.setEncoding("utf8"),o.on("data",l=>{a+=l}),o.on("end",()=>n({status:o.statusCode??0,text:a}))});i.setTimeout(0),i.on("error",r),i.end(e)})}var t1=t=>{let e=Math.round((Date.now()-t)/6e4);return e<1?"moments ago":e<60?`${e}m ago`:`${Math.round(e/60)}h ago`};async function ZS(t,e,n=0){e==="-"&&(e=yi(await qr()));let r=e!==void 0&&e.startsWith("tb:");r&&n<=0&&(n=np);let s=e!==void 0&&/^tb:(click|set)( |$)/.test(e),i=Cl.resolve(t),o=yn(await G(),i)[0];if(!o){let h=(await hn(process.cwd()))(i);console.error(h?`No running server for '${t}' \u2014 it last ran ${t1(h)}. Relaunching reuses the same URL (a stale tab is one reload from live): npx typebulb ${t}`:`No running server for '${t}'. Start it first: npx typebulb ${t}`),process.exit(1)}let a=async h=>{let m=[h>0?`reply=${h}`:"",s?"solo=1":"","open=1"].filter(Boolean).join("&"),g=await e1(`${o.url}/__send${m?`?${m}`:""}`,e??"");(g.status<200||g.status>=300)&&(console.error(`send failed: HTTP ${g.status} from ${o.url}/__send`),process.exit(1));try{return JSON.parse(g.text)}catch{return{}}},l={},c=Date.now();try{l=await a(n)}catch(h){console.error(`send failed: ${h instanceof Error?h.message:String(h)}`),process.exit(1)}let u=l.clients??0,d=`${u} page${u===1?"":"s"}`;if(l.refused&&(console.error(`Actuation needs exactly one connected page; ${d} are open on ${o.url} \u2014 the reset is \`typebulb stop ${t}\` then relaunch.`),process.exit(1)),u===0){let h=l.droppedMsAgo,m=l.opening==="none"?" and no agent mirror page is open to open one through":"",g=l.opening==="unreached"?` \u2014 the page was opened ${l.via?`in VS Code via ${l.via}`:"in your browser"} and never attached; is the browser it opened in still there?`:h!==void 0?` \u2014 a page disconnected ${Math.round(h/1e3)}s ago and hasn't reconnected${m}; reload it, or open ${o.url}`:` \u2014 no page has ever connected${m}; share ${o.url} and arm: typebulb wait ${t} --match "${rt.connected}"`;console.error(`No page connected after ${((Date.now()-c)/1e3).toFixed(1)}s, so nothing was delivered${g}`),process.exit(1)}l.opening==="editor"?console.error(`Opened in VS Code via ${l.via}.`):l.opening==="external"&&console.error("Opened in your browser, where the agent mirror is."),console.error(`Sent to ${d}.`);let f=l.results??[],p=l.errors??[];for(let h of p)console.error(`handler error: ${h}`);if(p.length&&process.exit(1),f.length>1&&(console.error(`${f.length} replies from ${d} \u2014 one reply owns stdout: at most one tb.onMessage handler, in one page, may return a value.`),process.exit(1)),f.length===1){if(e!==void 0&&/^tb:png( |$)/.test(e)){let m={};try{m=JSON.parse(f[0])}catch{}typeof m.png!="string"&&(console.error("tb:png replied with an unexpected shape \u2014 an older runtime? (`typebulb logs` lists server versions)"),process.exit(1));let g=zy(i);await QN(Cl.dirname(g),{recursive:!0}),await ZN(g,Buffer.from(m.png,"base64"));let v=[m.via?`inside "${m.via}"`:"",m.backdrop?`backdrop ${m.backdrop}`:""].filter(Boolean);console.error(`canvas ${m.width}\xD7${m.height} \u2192 PNG${v.length?` (${v.join("; ")})`:""}`),console.log(g);return}let h;try{h=JSON.parse(f[0])}catch{h=void 0}console.log(typeof h=="string"?h:f[0])}else l.timedOut&&(r&&(console.error(`No reply to '${e}' within ${n/1e3}s \u2014 reload the page and retry.`),process.exit(1)),console.error(`(no reply within ${n/1e3}s \u2014 slow work needs a larger --wait=ms; a reply that NEVER comes is a done-promise that missed an exit, or a blocked main thread: tb:snapshot runs no page code, so its silence too means blocked)`))}Fa();af();Z();import*as ek from"fs/promises";async function tk(t,e){let n=await ek.readFile(t,"utf-8"),r=Un(n),s=de[e].path,i=r.files.get(s);i||(console.error(i===void 0?`No **${s}** block in ${t}`:`The **${s}** block in ${t} is empty`),process.exit(2)),process.stdout.write(i.endsWith(`
|
|
2554
2535
|
`)?i:i+`
|
|
2555
|
-
`)}
|
|
2556
|
-
|
|
2536
|
+
`)}Z();import*as bi from"fs/promises";async function sk(t,e){let n=await bi.readFile(t,"utf-8"),r=[];for(let{kind:i,source:o}of e){let a;try{a=o==="-"?await qr():await bi.readFile(o,"utf-8")}catch(l){rk(`Cannot read ${i}'s source: ${l instanceof Error?l.message:String(l)}`)}r.push({kind:i,content:yi(a),label:o==="-"?"stdin":o})}let s;try{s=n1(n,r)}catch(i){rk(`${t}: ${i instanceof Error?i.message:String(i)}`)}for(let i of s.upToDate)console.log(`${de[i].path}: already up to date`);if(s.written.length){await bi.writeFile(t,s.text);for(let i of s.written)console.log(i.action==="removed"?`${de[i.kind].path}: removed (${i.label} is empty)`:`${de[i.kind].path}: ${i.action} from ${i.label} (${i.chars.toLocaleString()} chars)`)}}function n1(t,e){let n=Un(t),r=t,s=[],i=[];for(let{kind:o,content:a,label:l}of e){let c=de[o].path,u=n.files.get(c);if(!a){if(u===void 0){i.push(o);continue}r=nk(Jp(r,o),r,c),s.push({kind:o,action:"removed",chars:0,label:l});continue}if(u!==void 0&&yi(u)===a){i.push(o);continue}r=nk(Wr(r,o,a),r,c),s.push({kind:o,action:u===void 0?"created":"replaced",chars:a.length,label:l})}return{text:r,written:s,upToDate:i}}function nk(t,e,n){if(t===e)throw new Error(`the **${n}** block's fence is unterminated; refusing to rewrite inside it`);return t}function rk(t){console.error(t),process.exit(1)}Ze();sl();nl();Lr();async function ik(t,e){be(e);let n=process.cwd(),r=Zt(),s=Ne(),i=(s?[s]:Object.keys(r)).map(a=>r[a]()).filter(a=>a.listChildren);if(!i.length){console.error(`Sub-agent status isn't supported for ${s} sessions.`),process.exitCode=1;return}let o=!1;for(let a of i)for(let l of Af(a,n)){if(o=!0,!t){let{reports:u,files:d}=await Nn(a,n,l);console.log(gv(l.sessionId,u,d,Date.now()));return}let c=xv(l,t);if(c.length){if(c.length>1){console.error(`Several agents match "${t}"; name one by its id:`);for(let u of c)console.error(` ${r1(u)}`);process.exitCode=1;return}console.log(mv((await Nn(a,n,l)).reports.find(u=>u.id===c[0].id),Date.now()));return}}if(!o){console.log("No sub-agents in this project's sessions.");return}console.error(`No agent matches "${t}". Run \`typebulb status\` to list them.`),process.exitCode=1}var r1=t=>`${t.id} ${(t.failing&&t.state!=="stopped"?"failing":t.state).padEnd(7)} ${Et(t)}`;Ze();import{mkdirSync as s1,readFileSync as gp,writeFileSync as ak,rmSync as i1}from"fs";import{join as Pl}from"path";Be();sl();nl();var o1=1e4,a1=720*6e4,ok="typebulb_babysit";async function lk(t){be(t);let e=process.cwd(),n=Zt(),r=Ne(),s=(r?[r]:Object.keys(n)).map(p=>n[p]()).filter(p=>p.listChildren),i=s.map(p=>({adapter:p,sessionId:p.wake?p.callerSessionId?.(e):Sv(p,e)})).find(p=>p.sessionId);if(!i?.sessionId)return mp(s.length?s.some(p=>p.wake)?"Can't babysit: your own session couldn't be identified in this project, and a wake goes to no other.":"No session to babysit in this project.":`Babysitting sub-agents isn't supported for ${r} sessions.`);let{adapter:o,sessionId:a}=i;if(o.wake){let p=await o.wakeRoute(a);if(p.error)return mp(`Can't babysit: ${p.error}.`)}let l=Pl(Ge(),"babysit"),c=Pl(l,`${a}.json`);if(!l1(Pl(l,`${a}.lock`)))return mp("A babysit is already watching this session.");let u=[];try{u=JSON.parse(gp(c,"utf8"))}catch{}let d=p=>{try{ak(c,JSON.stringify(p))}catch{}};console.error(`Babysitting the sub-agents of session ${a}: this exits with a line when one needs attention.`);let f=Date.now()+a1;for(;Date.now()<f;){o.sessionEnded?.(a,e)&&Ol(3,"The session this babysits has ended.");let{reports:p}=await Nn(o,e,kv(o,e,a)),h=yv(p,Date.now()),m=[...h].filter(([g])=>!u.includes(g));if(!m.length)u=[...h.keys()],d(u);else{let g=m.map(([,v])=>v).join(`
|
|
2537
|
+
`);if(o.wake){console.error(`detected ${new Date().toISOString()}`);try{await o.wake(a,ok,g)}catch(v){d([...h.keys()].filter(A=>!m.some(([C])=>C===A))),console.log(g),Ol(4,`Not delivered: ${v instanceof Error?v.message:v}`)}console.error(`accepted ${new Date().toISOString()}`)}d([...h.keys()]),console.log(g),Ol(0)}await new Promise(g=>setTimeout(g,o1))}o.wake&&await o.wake(a,ok,"typebulb babysit stopped after 12 hours with nothing to report; run it again to keep watching.").catch(()=>{}),Ol(2,"Nothing needed attention; gave up.")}function mp(t){console.error(t),process.exitCode=1}function Ol(t,e){e&&console.error(e),process.exit(t)}function l1(t){try{let e=Number(gp(t,"utf8"));if(e&&e!==process.pid)return process.kill(e,0),!1}catch{}try{s1(Pl(t,".."),{recursive:!0}),ak(t,String(process.pid)),process.on("exit",()=>{try{Number(gp(t,"utf8"))===process.pid&&i1(t)}catch{}})}catch{}return!0}Ze();xt();Z();ia();import*as rn from"fs/promises";import*as jn from"path";import{EventEmitter as _1}from"events";qt();Z();import{Hono as h1}from"hono";import{serve as m1}from"@hono/node-server";import{streamSSE as g1}from"hono/streaming";import*as wp from"fs/promises";import y1 from"open";Er();Qs();xr();import*as yp from"fs/promises";import*as wi from"path";var _l=class{async get(e){let n=et(e),r=wi.join(Xs,n+".bin"),s=wi.join(Xs,n+".json");try{let[i,o]=await Promise.all([yp.readFile(r),yp.readFile(s,"utf8")]),a=JSON.parse(o);return{body:i,contentType:a.contentType,cacheControl:a.cacheControl}}catch{return}}async set(e,n){await te();let r=et(e),s=wi.join(Xs,r+".bin"),i=wi.join(Xs,r+".json"),o={url:e,contentType:n.contentType,cacheControl:n.cacheControl};await Promise.all([Fe(s,n.body),Fe(i,JSON.stringify(o))])}};var ck=`
|
|
2557
2538
|
const CSS = '\\n' +
|
|
2558
2539
|
/* The agent mirror's token set, verbatim (agents/core/client/styles.css) \u2014 one system across CLI
|
|
2559
2540
|
chrome: app chrome sits on --panel, content wells paint --veil, grays ride one neutral tint.
|
|
@@ -2936,22 +2917,22 @@ export function runInference(ctx) {
|
|
|
2936
2917
|
showConfirm();
|
|
2937
2918
|
document.body.appendChild(host);
|
|
2938
2919
|
}
|
|
2939
|
-
`;
|
|
2940
|
-
${
|
|
2941
|
-
`+
|
|
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:()=>
|
|
2920
|
+
`;Tr();je();kn();ga();qt();import{stream as c1}from"hono/streaming";var u1="X-TB-Stream";function vi(t){return t instanceof Re?{message:t.message,code:t.code,retryable:t.retryable}:{message:t instanceof Error?t.message:"Unknown error",code:"unknown",retryable:!1}}function Rl(t,e){return t.header("Content-Type","application/x-ndjson; charset=utf-8"),t.header("Cache-Control","no-cache"),t.header(u1,"1"),c1(t,async n=>{let r=e[Symbol.asyncIterator]();n.onAbort(()=>{r.return?.()});try{for(;;){let{done:s,value:i}=await r.next();if(s)break;await n.writeln(JSON.stringify({type:"chunk",value:i}))}}catch(s){await n.writeln(JSON.stringify({type:"error",error:vi(s)}))}finally{try{await r.return?.()}catch{}}})}var Il={log:(...t)=>console.log(...t)};function $l(t,e){let n=t?.[e]??(Object.hasOwn(Il,e)?Il[e]:void 0);return typeof n=="function"?n:void 0}function Nl(t){return t.constructor?.name==="AsyncGeneratorFunction"}Qd();var d1=/^\/(v\d+\/|stable\/|node\/|gh\/|@[^/]+\/[^@/]+@|[^@/]+@)/,f1=/[?&]target=/,p1=/^\/(?:@[^/]+\/)?[^/@]+\/[^/]+/;function uk(t,e=""){return d1.test(t)?!0:p1.test(t)&&f1.test(e)}var b1="127.0.0.1",w1=new Set(["localhost","127.0.0.1","::1"]),mk=(t,e)=>!!t&&typeof t=="object"&&e in t,dk=t=>{let e={};return Array.isArray(t.data)&&(e.data=t.data),mk(t,"insight")&&(e.insight=t.insight),e},fk=8*1024*1024,v1=0;function S1(t){if(t)try{return new URL(t.includes("://")?t:`http://${t}`).hostname}catch{return}}function gk(t){let e=S1(t);return!!e&&w1.has(e)}function k1(t){try{let e=new URL(t);return(e.protocol==="http:"||e.protocol==="https:")&&gk(e.host)}catch{return!1}}function x1(t){return!!t&&/\bCode\/\d/.test(t)&&/\bElectron\//.test(t)}function E1(t,e){if(!e)return!1;try{return new URL(t).host===e}catch{return!1}}function Si(t){return t instanceof Error?t.message:"Unknown error"}var pk=t=>t.how==="editor"||t.how==="unreached"?t.via:void 0,A1=2e3;async function yk(t){let{getHtml:e,basePath:n,fsBase:r,port:s,reloadEmitter:i,sendChannel:o,getServerExports:a,getBulbBlocks:l,saveInferenceResult:c,localOverride:u,trusted:d=!1,trustHint:f,staticAssets:p,bulbAssets:h,sourceFile:m,bulbKey:g,onStop:v}=t,A=`${process.pid}-${++v1}-${Date.now()}`,C=r??n,x=new h1;x.use("*",async(b,E)=>{if(!gk(b.req.header("host")))return b.text("Forbidden: untrusted Host",403);await E()}),x.use("*",async(b,E)=>{await E(),b.res.headers.set("Cross-Origin-Opener-Policy","same-origin"),b.res.headers.set("Cross-Origin-Embedder-Policy","credentialless")});let R=[["/__fs/*","the filesystem"],["/__api/*","server-side code (server.ts)"],["/__ai","AI (your API keys)"],["/__infer","AI (your API keys)"],["/__infer-save","the filesystem"]],I=async(b,E)=>{if(!d){let P=new URL(b.req.url).pathname,$=R.find(([W])=>W.endsWith("/*")?P.startsWith(W.slice(0,-2)):P===W)?.[1]??"server-side code (server.ts)";od(process.pid,$);let M=f?`
|
|
2921
|
+
${f}`:"";return b.text(`Forbidden: this capability requires --trust.${M}`,403)}await E()},L=async(b,E)=>{let P=b.req.header("sec-fetch-site");if(P){if(P!=="same-origin")return b.text(`Forbidden: ${P} request`,403)}else{let $=b.req.header("origin");if($&&!E1($,b.req.header("host")))return b.text("Forbidden: cross-origin request",403)}await E()};for(let[b]of R)x.use(b,I),x.use(b,L);x.use("/__log",L),x.post("/__log",async b=>{try{let{args:E}=await b.req.json();console.log(...E||[])}catch{}return b.json({ok:!0})});let T=new Al,F=new Set,H=new Set,ne=Date.now();T.onArrival(({page:b,firstAttach:E,count:P})=>{o&&P===1&&console.log(rt.connected),E&&P>1&&b.close("yielded").catch(()=>{})}),o&&T.onSettledEmpty(()=>console.log(rt.disconnected));let U,re=0,ge=async b=>{let E=Math.max(b.fresh?0:ne,T.lastDropAt);if(await T.whenArrives(fp-(Date.now()-E)))return{how:"attached"};if(Date.now()-re<A1)return{how:"none"};let P=`http://localhost:${s}#tb-relay`,$=await ld(P,n),M;return $?.where==="editor"?M={how:"editor",via:$.via}:(b.external==="force"||b.external==="follow"&&$?.where==="external")&&(await y1(P),M={how:"external"}),M?await T.whenArrives(US)?M:{how:"unreached",via:pk(M)}:(re=Date.now(),{how:"none"})},Le=b=>T.count>0?Promise.resolve({how:"attached"}):U??=ge(b).finally(()=>{U=void 0});if(o){let b=0,E=new Map;x.use("/__send",L),x.post("/__send",async P=>{let $="";try{$=await P.req.text()}catch{}let M=Number(P.req.query("reply"))||0,W=T.count===0&&P.req.query("open")!==void 0?await Le({external:"follow",fresh:!1}):void 0,q=T.count,Ke=q===0&&T.lastDropAt?Date.now()-T.lastDropAt:void 0,Y={clients:q,droppedMsAgo:Ke,...W?{opening:W.how,via:pk(W)}:{}};if(P.req.query("solo")!==void 0&&q!==1)return P.json({...Y,refused:q>1});if(q===0)return P.json(Y);let ce=sn=>{for(let Pt of T)Pt.send(sn).catch(()=>{})};if(M<=0)return ce({payload:$}),P.json(Y);let Oe=++b,Jr=await new Promise(sn=>{let Pt={expected:q,received:0,results:[],errors:[],finish:Dl=>{clearTimeout(Ml),E.delete(Oe),sn({results:Pt.results,errors:Pt.errors,timedOut:Dl})}},Ml=setTimeout(()=>Pt.finish(!0),M);E.set(Oe,Pt),ce({id:Oe,payload:$})});return P.json({...Y,...Jr})}),x.use("/__send-reply",L),x.post("/__send-reply",async P=>{try{let{id:$,results:M,errors:W}=await P.req.json(),q=E.get($);q&&(q.results.push(...M??[]),q.errors.push(...W??[]),++q.received>=q.expected&&q.finish(!1))}catch{}return P.json({ok:!0})})}x.get("/",b=>b.html(e())),x.post("/__fs/read",async b=>{try{let{path:E}=await b.req.json(),P=await Zs(E,C);return new Response(new Uint8Array(P),{headers:{"Content-Type":"application/octet-stream"}})}catch(E){let P=Si(E);return b.json({error:P},400)}}),x.post("/__fs/write",async b=>{try{let E=b.req.query("path");return E?(await $a(E,new Uint8Array(await b.req.arrayBuffer()),C),b.json({success:!0})):b.json({error:"Missing path"},400)}catch(E){let P=Si(E);return b.json({error:P},400)}}),x.post("/__fs/list",async b=>{try{let{path:E}=await b.req.json();return b.json(await Na(E??".",C))}catch(E){return b.json({error:Si(E)},400)}}),x.post("/__fs/remove",async b=>{try{let{path:E}=await b.req.json();return await La(E,C),b.json({success:!0})}catch(E){return b.json({error:Si(E)},400)}}),x.post("/__api/:name",async b=>{try{let E=b.req.param("name"),P=$l(a?.(),E);if(!P)return b.json({error:`API function '${E}' not found`},404);let{args:$}=await b.req.json();if(Nl(P))return Rl(b,P(...$||[]));let M=await P(...$||[]);return b.json({result:M})}catch(E){let P=Si(E);return b.json({error:P},500)}}),x.post("/__ai",async b=>{try{let{messages:E,system:P,effort:$,provider:M,model:W,webSearch:q,stream:Ke}=await b.req.json();if(!E||!Array.isArray(E)||E.length===0)return b.json({message:"messages array is required",code:"unknown",retryable:!1},400);let Y=bt(M,W);if(typeof Y=="string")return b.json({message:Y,code:"unknown",retryable:!1},400);let ce=await Wt(Y,{messages:E,system:P,effort:$,webSearch:q,signal:b.req.raw.signal});if(!ce.ok){let sn=await br(ce,Y.protocol);return b.json(sn,ce.status)}if(Ke)return Rl(b,An(ce,Y.protocol));let{text:Oe,usage:Jr}=await wr(ce,Y.protocol);return Oe||console.warn("[tb.ai] Empty response from provider"),b.json({text:Oe,usage:Jr})}catch(E){return b.json(vi(E),500)}}),x.post("/__infer",async b=>{try{let{data:E}=await b.req.json().catch(()=>({})),P=l?.();if(!P?.infer.trim())return b.json({message:"This bulb has no infer.md block.",code:"unknown",retryable:!1},400);let $=bt();if(typeof $=="string")return b.json({message:$,code:"unknown",retryable:!1},400);let M=Array.isArray(E)?E.map(String):[],W=Id(P,M),q=await Wt($,{messages:[{role:"user",content:W}],signal:b.req.raw.signal});if(!q.ok){let Y=await br(q,$.protocol);return b.json(Y,q.status)}let Ke=(async function*(){let Y="";for await(let Oe of An(q,$.protocol))Oe.kind!=="text"||!Oe.text||(Y+=Oe.text,yield{kind:"delta",text:Oe.text});let ce=$d(Y);if(ce.parsed===void 0)throw console.warn(`[tb.infer] output not valid JSON after sanitize; raw output (last 4000 chars):
|
|
2922
|
+
`+Y.slice(-4e3)),new Re("LLM output is not valid JSON","parse_error",!0);ce.fixesApplied.length&&console.warn("[tb.infer] sanitized output, fixes applied:",ce.fixesApplied.join(", ")),yield{kind:"complete",insight:ce.parsed,data:M,fixesApplied:ce.fixesApplied}})();return Rl(b,Ke)}catch(E){return b.json(vi(E),500)}}),x.post("/__infer-save",async b=>{try{if(!c)return b.json({message:"Save is not available for this server.",code:"unknown",retryable:!1},400);let E=dk(await b.req.json().catch(()=>({})));return Object.keys(E).length?(await c(E.data,mk(E,"insight")?JSON.stringify(E.insight,null,2):void 0),b.json({ok:!0})):b.json({message:"Nothing to save \u2014 this page holds no runtime state.",code:"unknown",retryable:!1},400)}catch(E){return b.json(vi(E),500)}}),x.get("/__infer-info",b=>{let E=l?.(),P=Kr(E?.config??"").inference,$=Po(E?.data??""),M=!!E?.infer.trim(),W=bt();return typeof W=="string"?b.json({error:W,inference:P,data:$,hasInfer:M}):b.json({provider:W.protocol,model:W.model,inference:P,data:$,hasInfer:M})}),x.use("/__tb-decode",L),x.post("/__tb-decode",async b=>{let{hash:E}=await b.req.json().catch(()=>({})),P=typeof E=="string"?Ld(E):void 0;return b.json(P??{error:"invalid fragment"})}),x.use("/__tb-encode",L),x.post("/__tb-encode",async b=>{let E=Number(b.req.header("content-length"));if(Number.isFinite(E)&&E>fk)return b.json({hash:""});let P=await b.req.text().catch(()=>"");if(P.length>fk)return b.json({hash:""});let $;try{$=JSON.parse(P)}catch{return b.json({hash:""})}return b.json({hash:Nd(dk($))})}),x.get("/__infer-ui.js",b=>b.body(ck,200,{"Content-Type":"text/javascript; charset=utf-8"})),x.get("/__models",async b=>{try{let E=await yt();return b.json(E)}catch{return b.json([],200)}}),x.get("/__ai-access",async b=>{try{return b.json(await la())}catch{return b.json("none",200)}}),m&&x.get("/__source/*",async b=>{let E=await wp.readFile(m,"utf-8").catch(()=>{});return E===void 0?b.text("Not Found",404):new Response(E,{headers:{"Content-Type":"text/plain; charset=utf-8"}})});let ut=["esm.sh","unpkg.com","cdn.jsdelivr.net","cdnjs.cloudflare.com"],pe=new _l;x.get("/proxy/*",async b=>{let E=new URL(b.req.url),$=(E.pathname+E.search).slice(7),M=$.lastIndexOf("https://");return M===-1?b.text("Invalid proxy URL",400):Ce(b,$.slice(M))}),u&&hk(x,`/local/${u.name}/`,u.serveDir),p&&hk(x,p.mount,p.dir),h&&x.get("/assets/*",async b=>{let{pathname:E}=new URL(b.req.url),P=E.slice(8),$;try{$=decodeURIComponent(P)}catch{return b.text("Not Found",404)}let M=zp($);if(M)return b.text(`${M} is not an asset type: a bulb's code and markup live in the bulb; assets are media and data`,403);try{let q=await bk($,h.dir,{"Cache-Control":"no-cache"});if(q)return q}catch{return b.text("Not Found",404)}let W=h.remoteBase;return W?b.redirect(W+P,302):b.text("Not Found",404)});async function Ce(b,E){let P;try{P=new URL(E)}catch{return b.text("Invalid URL",400)}if(P.protocol!=="https:")return b.text("HTTPS only",400);if(!ut.includes(P.hostname))return b.text("Host not allowed",403);let $=await pe.get(E);if($)return new Response($.body,{status:200,headers:bp($.contentType,$.cacheControl)});try{let M=await fetch(E,{headers:{Accept:b.req.header("Accept")||"*/*"},redirect:"follow"});if(!M.ok)return b.text(`Upstream ${M.status}`,M.status);let W=M.headers.get("Content-Type")||void 0,q=M.headers.get("Cache-Control")||void 0;if(M.body){let[Ke,Y]=M.body.tee();return(async()=>{try{let ce=await new Response(Y).arrayBuffer();await pe.set(E,{body:Buffer.from(ce),contentType:W,cacheControl:q})}catch{}})(),new Response(Ke,{status:M.status,headers:bp(W,q)})}return new Response(null,{status:M.status,headers:bp(W,q)})}catch(M){return b.text(`Proxy fetch failed: ${M instanceof Error?M.message:M}`,502)}}(i||o)&&(x.get("/__reload",b=>g1(b,async E=>{let P=b.req.query("bulb")||void 0;if(g&&P&&P!==g){F.has(P)||(F.add(P),console.log(rt.closed("foreign"))),await E.writeSSE({event:"close",data:"foreign"});return}let $=()=>{E.writeSSE({event:"reload",data:""})};i?.on("reload",$);let M=()=>i?.removeListener("reload",$),W=b.req.query("relay")||void 0,q={inEditor:x1(b.req.header("user-agent")),doc:W,open:Y=>E.writeSSE({event:"open-url",data:Y}),send:Y=>E.writeSSE({event:"message",data:JSON.stringify(Y)}),close:Y=>(M(),T.closing(q),console.log(rt.closed(Y)),E.writeSSE({event:"close",data:Y}))},Ke=!!W&&!H.has(W);for(W&&H.add(W),T.add(q,Ke),E.onAbort(()=>{M(),T.dropped(q)}),await E.writeSSE({event:"hello",data:A,retry:Gd});!E.aborted;)await E.sleep(3e4)})),x.use("/__open",L),x.post("/__open",async b=>{let E="";try{E=String((await b.req.json()).url??"")}catch{}if(!k1(E))return b.json({error:"a local http URL is required"},400);let P=[...T].find($=>$.inEditor);return await P?.open(E),b.json({opened:!!P,pages:T.count})})),x.use("/__stop",L),x.post("/__stop",async b=>{if(b.req.header("sec-fetch-site")||b.req.header("origin"))return b.text("Forbidden: browser request",403);let E="close";try{let $=await b.req.json();($?.pages==="keep"||$?.pages==="close")&&(E=$.pages)}catch{}let P=E==="close"?await T.closeAll("stopped"):{told:0,gone:0};return v&&setTimeout(()=>{v({pages:E})},50),b.json({closed:P.gone,stuck:P.told-P.gone,exiting:!!v})}),x.get("/__pages",b=>b.json({pages:T.count})),x.notFound(async b=>{if(b.req.method!=="GET")return b.text("Not Found",404);let E=new URL(b.req.url);return uk(E.pathname,E.search)?Ce(b,"https://esm.sh"+E.pathname+E.search):b.text("Not Found",404)});let Ot=m1({fetch:x.fetch,port:s,hostname:b1});return Ot.listening||await new Promise((b,E)=>{let P=$=>E($);Ot.once("error",P),Ot.once("listening",()=>{Ot.removeListener("error",P),b()})}),{port:s,close:()=>Ot.close(),requestPage:Le,closePages:b=>T.closeAll(b),pageCount:()=>T.count}}function bp(t,e){let n=new Headers;return t&&n.set("Content-Type",t),e&&n.set("Cache-Control",e),n.set("Access-Control-Allow-Origin","*"),n.set("Cross-Origin-Resource-Policy","cross-origin"),n}function hk(t,e,n){t.get(`${e}*`,async r=>{let{pathname:s}=new URL(r.req.url);if(!s.startsWith(e))return r.text("Not Found",404);try{return await bk(decodeURIComponent(s.slice(e.length)),n)??r.text("Not Found",404)}catch{return r.text("Not Found",404)}})}async function bk(t,e,n={}){let r=Cr(t,e),s=await wp.readFile(r).catch(()=>{});if(s)return new Response(s,{headers:{"Content-Type":Hp(r),...n}})}je();mn();async function Ll(t){let{port:e,portNote:n,makeServerOptions:r,makeEntry:s,displayName:i,waitTarget:o,stopLog:a}=t,l=`http://localhost:${e}`,c=s(e,l),u=[],d,f=!1,p=async m=>{if(!f){f=!0,console.log(`
|
|
2923
|
+
Shutting down...`),(m?.pages??(ye(c)?"keep":"close"))==="close"&&await d?.closePages("stopped"),d?.close();for(let g of u)try{await g()}catch{}a(),await gn(process.pid),process.exit(0)}},h=await yk({...r(e),onStop:p}).catch(async m=>{if(m?.code!=="EADDRINUSE")throw m;return Xu(e)});return d=h,await id(c),console.log(`
|
|
2924
|
+
${i}`),console.log(` ${l}`),n&&console.log(` ${n}`),process.on("SIGINT",()=>{p()}),process.on("SIGTERM",()=>{p()}),{port:e,url:l,pageCount:()=>h.pageCount(),async handOver({mode:m,fresh:g,replacedLive:v}){if(m==="none")return;let A={fresh:g,external:v?"never":m==="window"?"force":"follow"},C=await h.requestPage(A);C.how==="attached"?console.log(` Reusing the open browser tab.
|
|
2944
2925
|
`):C.how==="editor"?console.log(` Opened in VS Code via ${C.via}.
|
|
2945
2926
|
`):C.how==="external"?console.log(` Opened in your browser.
|
|
2946
2927
|
`):console.log(` ${C.how==="unreached"?`Opened ${C.via?`in VS Code via ${C.via}`:"in your browser"}, but no page attached \u2014 is the browser it opened in still there?`:ye(c)?"No page opened \u2014 nothing is reading this mirror until someone opens it.":"No page opened \u2014 no agent mirror page to open one through, and a bulb runs in its page."}
|
|
2947
2928
|
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
|
|
2929
|
+
typebulb wait ${o} --match "${rt.connected}"
|
|
2930
|
+
`)},onCleanup(m){u.push(m)}}}mn();import T1 from"chokidar";import wk from"node:fs";import C1 from"node:path";var O1={persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}};function nn(t){let{target:e,onChange:n,events:r="change",debounceMs:s=150}=t,i,o=T1.watch(e,O1);o.on("error",l=>console.warn(`watch: ${l instanceof Error?l.message:l} \u2014 continuing`));let a=()=>{i&&clearTimeout(i),i=setTimeout(n,s)};return r==="all"?o.on("all",a):o.on("change",a),()=>{i&&clearTimeout(i),o.close()}}var P1=t=>process.platform==="win32"||process.platform==="darwin"?t.toLowerCase()==="assets":t==="assets";function vk(t,e,n=150){let r,s=()=>{r&&clearTimeout(r),r=setTimeout(e,n)};try{let i=wk.watch(t,{recursive:!0},(o,a)=>{a&&P1(a.split(/[\\/]/)[0])&&s()});return i.on("error",o=>console.warn(`watch: ${o instanceof Error?o.message:o} \u2014 continuing`)),()=>{r&&clearTimeout(r),i.close()}}catch{let i=C1.join(t,"assets");return wk.existsSync(i)?nn({target:i,onChange:e,events:"all",debounceMs:n}):()=>{}}}je();Be();Tr();async function Sk(t,e,n,r){e.port!==void 0&&(console.error("--port isn't supported when running a bulb: a bulb keeps its assigned project port across runs, and moving it strands the open tab."),console.error("It applies to `typebulb agent`. Run the bulb with no --port; `typebulb logs` prints the URL it kept."),process.exit(1));let s=process.cwd(),i=$s(process.pid),o=e.watch?new _1:void 0,a=be(e.mode),l=(await hn(process.cwd()))(t),c=await ir({kind:"bulb",file:t},process.cwd()),u=await ta(t,c);u.length&&console.log(`Replacing the running server for this bulb (pid ${u.map(ge=>ge.pid).join(", ")})`);let d=u.length>0||Date.now()-l<fw,{port:f,note:p}=await Go({target:{kind:"bulb",file:t},cwd:process.cwd()});c!==void 0&&f!==c&&d&&(console.error(`
|
|
2931
|
+
Port ${c} is this bulb's, and a page of it may be waiting there, but something else took it.`),console.error("Free that port and relaunch; starting elsewhere would leave that page running with no way to reach it."),process.exit(1));let h=0,m=()=>console.log(rd(++h));m(),console.log(`Loading ${jn.basename(t)}...`);let{html:g,bulb:v,serverExports:A}=await ef(t,e.watch,e.trust,r);Jt(a,t,v.server);let C=Pn(t),x=Pr(jn.resolve(t)),R=e.trust?void 0:fr(v),{port:I,onCleanup:L,handOver:T,pageCount:F}=await Ll({port:f,portNote:p,displayName:v.name,stopLog:i,makeServerOptions:ge=>({getHtml:()=>g,basePath:s,fsBase:Or(t),port:ge,reloadEmitter:o,sendChannel:!0,getServerExports:()=>A,getBulbBlocks:()=>({infer:v.infer,insight:v.insight,code:v.code,config:v.config,data:v.data}),saveInferenceResult:async(Le,ut)=>{let pe=await rn.readFile(t,"utf-8");Le!==void 0&&(pe=Wr(pe,"data",Le.join(Hg))),ut!==void 0&&(pe=Wr(pe,"insight",ut)),await rn.writeFile(t,pe)},localOverride:r?{name:r.name,serveDir:r.serveDir}:void 0,bulbAssets:{dir:C,remoteBase:x&&_i(x.userSlug,x.slug)},sourceFile:t,bulbKey:Rs(t),trusted:e.trust,trustHint:n}),makeEntry:(ge,Le)=>({pid:process.pid,port:ge,url:Le,file:t,cwd:process.cwd(),startedAt:Date.now(),trust:e.trust,mode:e.mode,predicted:R,watch:e.watch?void 0:!1,replace:e.local?`${e.local.name}=${e.local.dir}`:void 0}),waitTarget:jn.relative(process.cwd(),t)||jn.basename(t)});e.trust?console.log(" trust: granted (filesystem, AI, server.ts enabled)"):console.log(R?` trust: restricted \u2014 this bulb appears to use ${R}; re-run with --trust to enable it:
|
|
2951
2932
|
${n}
|
|
2952
2933
|
`:` trust: restricted \u2014 re-run with --trust to enable filesystem / AI / server.ts
|
|
2953
2934
|
`),e.watch&&console.log(` Watching for changes...
|
|
2954
|
-
`);let
|
|
2935
|
+
`);let H,ne,U=()=>{F()===0&&console.log(" No page attached \u2014 nothing reloaded; this change is not live."),o?.emit("reload")},re=ge=>{console.log(ge),m(),U()};if(e.watch&&o){let ge=0,Le=Promise.resolve();if(H=nn({target:t,onChange:()=>{let pe=++ge;Le=Le.then(async()=>{if(pe===ge)try{console.log("Recompiling...");let Ce=await ef(t,!0,e.trust,r);g=Ce.html,A=Ce.serverExports,v=Ce.bulb,Ce.buildError||m(),U()}catch(Ce){console.error("Recompile failed:",Ce)}})}}),r){let{name:pe,serveDir:Ce}=r;ne=nn({target:Ce,events:"all",onChange:()=>re(`Local package '${pe}' changed.`)})}let ut=Or(t);await rn.stat(ut).then(pe=>pe.isDirectory()).catch(()=>!1)&&L(vk(ut,()=>re("Assets changed.")))}H&&L(H),ne&&L(ne),L(()=>rn.rm(Zd(t),{force:!0})),await T({mode:e.open,fresh:!d,replacedLive:u.some(ge=>ge.port===I)})}Ze();import{readFileSync as Sp,copyFileSync as I1,existsSync as $1}from"fs";import*as me from"path";import{fileURLToPath as N1}from"url";import{EventEmitter as L1}from"events";import M1 from"open";mn();je();Tr();var vp=t=>`/agents/${t}/client.js`,R1=`
|
|
2955
2936
|
(() => {
|
|
2956
2937
|
const api = async (name, ...args) => {
|
|
2957
2938
|
const resp = await fetch('/__api/' + name, {
|
|
@@ -2980,18 +2961,18 @@ Port ${c} is this bulb's, and a page of it may be waiting there, but something e
|
|
|
2980
2961
|
})
|
|
2981
2962
|
});
|
|
2982
2963
|
if (window.__TYPEBULB_WATCH__) {
|
|
2983
|
-
${
|
|
2964
|
+
${Oa()}
|
|
2984
2965
|
}
|
|
2985
2966
|
})();
|
|
2986
|
-
`;function
|
|
2967
|
+
`;function kk(t){let{name:e,agent:n,styles:r,katex:s,mountHtml:i,watch:o,theme:a}=t,l=vp(n);return`<!DOCTYPE html>
|
|
2987
2968
|
<html>
|
|
2988
2969
|
<head>
|
|
2989
2970
|
<meta charset="utf-8">
|
|
2990
2971
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
2991
|
-
<title>${
|
|
2992
|
-
${
|
|
2972
|
+
<title>${Ta(e)} - typebulb</title>
|
|
2973
|
+
${Ca(e,a)}
|
|
2993
2974
|
<style>
|
|
2994
|
-
${
|
|
2975
|
+
${As}
|
|
2995
2976
|
</style>
|
|
2996
2977
|
<style>
|
|
2997
2978
|
${r}
|
|
@@ -3011,13 +2992,13 @@ ${R1}
|
|
|
3011
2992
|
|
|
3012
2993
|
<script type="module" src="${l}"></script>
|
|
3013
2994
|
</body>
|
|
3014
|
-
</html>`}async function
|
|
3015
|
-
${r.url}`),t.open==="window"&&await M1(r.url);return}let s
|
|
3016
|
-
`);async function
|
|
2995
|
+
</html>`}async function xk(t){let e=process.cwd(),n=t.agentTarget;lS(n)||(console.error(`Unknown agent '${n}'. Known: ${jr().join(", ")}.`),process.exit(1));let r=await ea(e,n);if(r){console.log(`Mirror '${n}' is already running for this project:
|
|
2996
|
+
${r.url}`),t.open==="window"&&await M1(r.url);return}let s=$s(process.pid),i=t.watch?new L1:void 0,o=be(t.mode),a=await cS(n),l=a.displayName||`${n} mirror`;Jt(o,me.join(e,"mirror"));let c=me.dirname(N1(import.meta.url)),u=me.join(c,"agents",n),d=me.join(c,"..","cli","agents"),f=me.join(u,"styles.css"),p=me.join(u,"katex.min.css"),h=me.join(u,"index.html"),m=()=>kk({name:l,agent:n,styles:Sp(f,"utf8"),katex:Sp(p,"utf8"),mountHtml:Sp(h,"utf8"),watch:t.watch}),{port:g,note:v}=await Go({explicit:t.port,target:{kind:"mirror",agent:n},cwd:e}),{port:A,url:C,onCleanup:x,handOver:R,pageCount:I}=await Ll({port:g,portNote:v,displayName:l,stopLog:s,waitTarget:"agent",makeServerOptions:U=>({getHtml:m,basePath:e,port:U,reloadEmitter:i,getServerExports:()=>a,trusted:!0,staticAssets:{mount:`${me.posix.dirname(vp(n))}/`,dir:u}}),makeEntry:(U,re)=>({pid:process.pid,port:U,url:re,file:`agent:${n}`,cwd:e,startedAt:Date.now(),trust:!0,agent:n})}),L=me.join(d,n,"client"),T=me.join(d,"core","client"),F=$1(L);t.watch&&F&&console.log(` Watching for changes...
|
|
2997
|
+
`);async function H(){await(await import("esbuild")).build({entryPoints:[me.join(L,"index.ts")],bundle:!0,platform:"browser",format:"esm",outfile:me.join(u,"client.js")});for(let re of["styles.css","index.html","typebulb.png","typebulb-inv.png"])I1(me.join(T,re),me.join(u,re))}let ne;if(t.watch&&F&&i){let U=!1;ne=nn({target:d,events:"all",onChange:async()=>{if(!U){U=!0;try{await H(),console.log(I()?`Mirror rebuilt. Reloading.
|
|
3017
2998
|
`:`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 q1(){let t=new D1(process.stderr,process.stderr);console.log=t.log.bind(t),console.info=t.info.bind(t),console.debug=t.debug.bind(t),console.dir=t.dir.bind(t)}function
|
|
3023
|
-
${e}`),process.exit(1))}async function J1(){let t=
|
|
2999
|
+
`),i.emit("reload")}catch(re){console.error("Mirror rebuild failed:",re instanceof Error?re.message:re)}finally{U=!1}}}})}await R({mode:t.open,fresh:!1,replacedLive:!1}),x(()=>a.shutdownSwitcher?.()),x(()=>a.shutdownComposer?.()),ne&&x(ne)}Ze();xt();import*as Ek from"path";async function Ak(t,e,n,r){let s=be(n),i=!1,o=async()=>{let{bulb:a,config:l}=await nt(t);i||(Jt(s,t,a.server),i=!0),await ei(a.server,t,r,l.dependencies)};if(console.log(`Running ${Ek.basename(t)}...`),await o(),e){console.log(`Watching for changes...
|
|
3000
|
+
`);let a=0,l=Promise.resolve();nn({target:t,onChange:()=>{let c=++a;l=l.then(async()=>{if(c===a)try{console.log("Re-running..."),await o()}catch(u){console.error("Error:",u)}})}})}}Ze();xt();import{Console as D1}from"node:console";je();async function Ok(t,e,n,r){q1();try{let f=yn(await G(),t)[0];f&&(Is(f.pid,Xe(f.pid).offset),console.error(`note: 'call' boots a fresh server.ts instance; the running server (${f.url}) is not contacted \u2014 state shared with it must live on disk.`))}catch{}let s=be(n),{bulb:i,config:o}=await nt(t);i.server||ki("This bulb has no **server.ts** block; nothing to call."),Jt(s,t,i.server);let a;try{a=await ei(i.server,t,r,o.dependencies)}catch(f){ki(f instanceof Error?f.message:String(f))}let l=$l(a,e.fn);if(!l){let f=[...Object.keys(a).filter(p=>typeof a[p]=="function"),...Object.keys(Il)];ki(`Function '${e.fn}' not found. Available: ${f.length?f.join(", "):"(none)"}.`)}let c=await B1(e);if(Nl(l)){try{for await(let f of l(...c))await Ck(JSON.stringify(f,Pk)+`
|
|
3001
|
+
`)}catch(f){ki(f instanceof Error?f.stack??f.message:String(f))}return Tk(0)}let u;try{u=await l(...c)}catch(f){ki(f instanceof Error?f.stack??f.message:String(f))}let d=U1(u);d!==void 0&&await Ck(d+`
|
|
3002
|
+
`),Tk(0)}function Tk(t){process.exitCode=t,setTimeout(()=>process.exit(t),2e3).unref?.()}async function B1(t){if(t.hasArgsFlag){let e=t.argsJson??"";return e==="-"&&(e=await qr()),F1(e)}return j1(t.positional)}function j1(t){return t.map(e=>{try{return JSON.parse(e)}catch{return e}})}function F1(t){let e;try{e=JSON.parse(t)}catch(n){throw new Error(`--args must be a JSON array: ${n instanceof Error?n.message:String(n)}`)}if(!Array.isArray(e))throw new Error(`--args must be a JSON array, got ${e===null?"null":typeof e}`);return e}function U1(t){if(t!==void 0)return JSON.stringify(t,Pk,2)}function Pk(t,e){return typeof e=="bigint"?e.toString():e}function ki(t){process.stderr.write(t+`
|
|
3003
|
+
`),process.exit(1)}function q1(){let t=new D1(process.stderr,process.stderr);console.log=t.log.bind(t),console.info=t.info.bind(t),console.debug=t.debug.bind(t),console.dir=t.dir.bind(t)}function Ck(t){return new Promise((e,n)=>{process.stdout.write(t,r=>r?n(r):e())})}Xo();for(let t of[process.stdout,process.stderr])t.on("error",e=>{if(e?.code!=="EPIPE")throw e});function _k(t,e){t||(console.error(`This bulb runs server-side Node code (server.ts), which --trust must authorize:
|
|
3004
|
+
${e}`),process.exit(1))}async function J1(){let t=fS(process.argv.slice(2));if(t.version&&(console.log(`typebulb ${Ae}`),process.exit(0)),t.help&&(pS(),process.exit(0)),uS(),t.subcommand==="logs"){await HS(t.file||void 0,{follow:t.follow,clear:t.clear,run:t.run,lines:t.lines});return}if(t.subcommand==="wait"){await zS(t.file||void 0,{match:t.match,timeoutSec:t.timeoutSec,wake:t.wake});return}if(t.subcommand==="stop"){t.stopScope?await GS(t.stopScope):await VS(t.file||void 0);return}if(t.subcommand==="restart"){await XS(t.file||void 0,t.stopScope);return}if(t.subcommand==="babysit"){await lk(t.mode);return}if(t.subcommand==="send"){await ZS(t.file,t.sendMessage,t.sendWaitMs??0);return}if(t.subcommand==="models"){await jS(t.mode);return}if(t.subcommand==="slug"){FS(t.slugName);return}if(t.subcommand==="status"){await ik(t.statusQuery,t.mode);return}if(t.subcommand==="pull"){await xw(t.file||void 0,{force:t.force,mode:t.mode});return}if(t.subcommand==="push"){await Aw(t.file||void 0,{force:t.force,mode:t.mode});return}if(t.subcommand==="agent"){await(t.agentTarget?xk(t):BS(Ae));return}if(t.subcommand==="trust"||t.subcommand==="untrust"){await NS(t.file||void 0,t.subcommand==="trust");return}let e;if(!t.file||t.file==="."){let l=await Sw(process.cwd());l||(console.error("No .bulb.md file found in current directory"),process.exit(1)),e=l}else e=Ct.resolve(t.file);if(await Rk.access(e).then(()=>!0,()=>!1)||(jr().includes(t.file)&&(console.error(`To open the ${t.file} agent mirror, run: npx typebulb agent:${t.file}`),process.exit(1)),console.error(`File not found: ${e}`+(Ct.isAbsolute(t.file)?"":` (resolved from cwd ${process.cwd()})`)),process.exit(1)),e.endsWith(".bulb.md")||(console.error("File must have .bulb.md extension"),process.exit(1)),t.subcommand==="get"){await tk(e,t.blockKind);return}if(t.subcommand==="put"){await sk(e,t.blockPairs);return}let r=t.file&&t.file!=="."?t.file:Ct.relative(process.cwd(),e)||Ct.basename(e),s=`npx typebulb --trust ${r.includes(" ")?`"${r}"`:r}`;if(t.subcommand==="predict"){await $S(e,s);return}let i=!t.noTrust&&Sn(e);i&&!t.trust&&console.error("trust: granted from memory (run `typebulb untrust` to revoke)"),t.trust=t.noTrust?!1:t.trust||i;let o;try{o=await nt(e)}catch{}let a;if(t.local){o&&!(t.local.name in(o.config.dependencies??{}))&&(console.error(`--replace: '${t.local.name}' is not a dependency in this bulb's config.json; nothing to replace.`),process.exit(1)),o&&t.subcommand!=="call"&&(!o.bulb.code||t.server)&&console.warn("warning: --replace has no effect in server mode (the override is client-only).");try{a=await _p(t.local)}catch(l){console.error(l instanceof Error?l.message:String(l)),process.exit(1)}console.error(`replace: ${a.name} \u2192 ${Ct.relative(process.cwd(),a.dir)||"."}`)}if(t.subcommand==="check"){await IS(e,a);return}if(t.subcommand==="call"){_k(t.trust,s),await Ok(e,{fn:t.fn,positional:t.callArgs,argsJson:t.argsJson,hasArgsFlag:t.hasArgsFlag},t.mode,a);return}if(o&&o.bulb.server&&(na(o.bulb)||t.server)){_k(t.trust,s),await Ak(e,t.watch,t.mode,a);return}await Sk(e,t,s,a)}J1().catch(t=>{console.error("Error:",t.message),process.exit(1)});
|