typebulb 0.62.3 → 0.62.4
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 +1 -1
- package/SKILL.md +3 -3
- package/dist/agents/claude/client.js +1 -1
- package/dist/agents/codex/client.js +37 -37
- package/dist/agents/pi/client.js +1 -1
- package/dist/index.js +235 -235
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
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(u,m),c=n}else n++}return{bulb:{frontmatter:i,files:o,warnings:l,bodyEndLine:c,starts:a}}}catch(e){return{reason:`unexpected parse error: ${e instanceof Error?e.message:String(e)}`}}}function
|
|
3
|
+
var ux=Object.create;var zl=Object.defineProperty;var dx=Object.getOwnPropertyDescriptor;var fx=Object.getOwnPropertyNames;var px=Object.getPrototypeOf,hx=Object.prototype.hasOwnProperty;var _i=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var S=(t,e)=>()=>(t&&(e=t(t=0)),e);var I=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Ri=(t,e)=>{for(var n in e)zl(t,n,{get:e[n],enumerable:!0})},mx=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of fx(e))!hx.call(t,s)&&s!==n&&zl(t,s,{get:()=>e[s],enumerable:!(r=dx(e,s))||r.enumerable});return t};var gx=(t,e,n)=>(n=t!=null?ux(px(t)):{},mx(e||!t||!t.__esModule?zl(n,"default",{value:t,enumerable:!0}):n,t));import*as Mp from"fs/promises";import{existsSync as Un,readFileSync as yx}from"fs";import*as le from"path";import{pathToFileURL as bx}from"url";import{resolve as Vl}from"resolve.exports";import{init as Dp,parse as Bp}from"es-module-lexer";function jp(t,e){let n=le.join(t,"package.json");try{return JSON.parse(yx(n,"utf8"))}catch{throw new Error(`--replace package '${e}' has no readable package.json at ${n}`)}}function Fp(t){let e=t.indexOf("=");if(e===-1)throw new Error(`--replace must be <name>=<path> (got '${t}')`);let n=t.slice(0,e).trim(),r=t.slice(e+1).trim();if(!n)throw new Error(`--replace missing package name (got '${t}')`);if(!r)throw new Error(`--replace missing path for '${n}'`);if(n.startsWith("@"))throw new Error(`--replace does not support scoped names yet; '${n}' is scoped`);return{name:n,dir:le.resolve(r)}}async function Up(t){let{name:e,dir:n}=t;if(!Un(n))throw new Error(`--replace path for '${e}' does not exist: ${n}`);let r=jp(n,e),s=wx(r,e),i=le.resolve(n,s);if(!Un(i))throw new Error(`--replace package '${e}' entry not found on disk: ${i} \u2014 did you build it (e.g. \`pnpm run build\`)?`);let o=le.dirname(i),a=`/local/${e}/${le.basename(i)}`,l=vx(r,n);return await Sx(e,i,o),{name:e,dir:n,entryAbs:i,serveDir:o,entryUrl:a,typesAbs:l}}function wx(t,e){if(t.exports!==void 0){let r;try{r=Vl(t,".",{browser:!0,conditions:Yl})}catch(i){throw new Error(`--replace package '${e}' "exports" does not resolve a browser entry (conditions: ${Yl.join(", ")}): ${i instanceof Error?i.message:i}`)}let s=Gl(r);if(!s)throw new Error(`--replace package '${e}' "exports" did not resolve "." to a single file (conditions: ${Yl.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 vx(t,e){if(t.exports!==void 0)try{let r=Vl(t,".",{conditions:["types"]}),s=Gl(r);if(s){let i=le.resolve(e,s);if(Un(i))return i}}catch{}let n=t.types??t.typings;if(n){let r=le.resolve(e,n);if(Un(r))return r}}function Gl(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.find(e=>typeof e=="string")}async function Sx(t,e,n){await Dp;let r=le.normalize(n),s=new Set,i=[e];for(;i.length;){let o=i.shift();if(s.has(o))continue;s.add(o);let a;try{a=await Mp.readFile(o,"utf8")}catch{continue}let l,c;try{[l,,,c]=Bp(a,o)}catch{continue}if(o===e&&!c)throw new Error(`override package '${t}' entry is not an ES module (no import/export syntax); CommonJS or non-module entries aren't supported (esm.sh would have to transform it).`);for(let f of l){if(f.d===-2)continue;let d=f.n;if(d&&!d.startsWith("node:")){if(d.startsWith("./")||d.startsWith("../")||d.startsWith("/")){let u=kx(o,d,r);u&&!s.has(u)&&i.push(u);continue}throw new Error(`override package must ship self-contained (bundle its dependencies); ${t} externalizes '${d}'`)}}}}function kx(t,e,n){let r=e.replace(/[?#].*$/,""),s=le.resolve(le.dirname(t),r),i=[s,s+".js",s+".mjs",le.join(s,"index.js"),le.join(s,"index.mjs")];for(let o of i)if(le.normalize(o).startsWith(n)&&Un(o))return o}function xx(t,e,n){let r=jp(t,e),s;if(r.exports!==void 0)try{s=Gl(Vl(r,n,{conditions:Lp}))}catch(o){throw new Error(`--replace package '${e}' "exports" does not resolve a node entry for '${n}' (conditions: ${Lp.join(", ")}): ${o instanceof Error?o.message:o}`)}else n==="."&&(s=r.main??r.module);if(!s)throw new Error(`--replace package '${e}' has no node export for '${n}'.`);let i=le.resolve(t,s);if(!Un(i))throw new Error(`--replace package '${e}' built file not found: ${i} \u2014 did you build it (e.g. \`pnpm run build\`)?`);return bx(i).href}async function qp(t,e){await Dp;let n;try{[n]=Bp(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=xx(e.dir,e.name,a);r+=t.slice(s,i.s)+l,s=i.e}return r+t.slice(s)}var Yl,Lp,Ii=S(()=>{"use strict";Yl=["browser","import","default"],Lp=["node","import","default"]});function Jp(t){return He.find(e=>pe[e].path===t)}function Kp(t){return!!t?.startsWith("typebulb")}var pe,He,Wp,$i=S(()=>{pe={code:{path:"code.tsx",language:"typescript"},css:{path:"styles.css",language:"css"},html:{path:"index.html",language:"html"},config:{path:"config.json",language:"json"},notes:{path:"notes.md",language:"markdown"},data:{path:"data.txt",language:"text"},infer:{path:"infer.md",language:"markdown"},insight:{path:"insight.json",language:"json"}},He=["code","css","html","data","infer","insight","config","notes"];Wp="typebulb/v1"});function Xl(t){return/[:\n"']/.test(t)||t.startsWith(" ")||t.endsWith(" ")?`"${t.replace(/"/g,'\\"')}"`:t}function Ql(t){return t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1).replace(/\\"/g,'"'):t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}var Ni=S(()=>{});function qn(t){let e=zp(t);if("reason"in e)throw new Error(`Invalid .bulb.md file format: ${e.reason}`);return e.bulb}function ze(t){let e=zp(t);return"bulb"in e?e.bulb:void 0}function zp(t){try{let e=t.split(`
|
|
4
|
+
`),n=0;if(e[n]?.trim()!=="---")return{reason:Ax(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(!Kp(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(Hp);if(d){let u=d[1].trim();for(n++;n<e.length&&e[n]?.trim()==="";)n++;let p=e[n]?.match(Li);if(!p){l.push(`**${u}** has no code fence \u2014 block skipped`);continue}let h=p[1];n++;let m=n+1,g=[],v=Zl(h);for(;n<e.length&&!e[n]?.match(v);)g.push(e[n]),n++;let E=n<e.length;n++,l.push(...Tx(u,g,E)),o.set(u,g.join(`
|
|
5
|
+
`)),a.set(u,m),c=n}else n++}return{bulb:{frontmatter:i,files:o,warnings:l,bodyEndLine:c,starts:a}}}catch(e){return{reason:`unexpected parse error: ${e instanceof Error?e.message:String(e)}`}}}function Ax(t,e){let n=Px(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 Tx(t,e,n){let r=[];for(let s=0;s<e.length;s++){let i=e[s]?.trim().match(Hp);i&&Ex.has(i[1].trim())&&Cx(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 Cx(t,e){let n=e+1;for(;n<t.length&&t[n]?.trim()==="";)n++;return!!t[n]?.match(Li)}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=Ql(i);break}}return e}function Yp(t){return ze(t)?.warnings??[]}function Px(t){let e=t.split(`
|
|
6
6
|
`),n=[],r=0;for(;r<e.length;){if(e[r]?.trim()!=="---"){r++;continue}let s=ze(e.slice(r).join(`
|
|
7
7
|
`));if(s&&s.files.size>0){let i=r+s.bodyEndLine;n.push({start:r,end:i,source:e.slice(r,i).join(`
|
|
8
|
-
`)}),r=i}else r++}return n}function Vp(t){let e=Object.fromEntries(He.map(n=>[n,t.files.get(pe[n].path)||""]));return{name:t.frontmatter.name,...e}}var Hp,
|
|
8
|
+
`)}),r=i}else r++}return n}function Vp(t){let e=Object.fromEntries(He.map(n=>[n,t.files.get(pe[n].path)||""]));return{name:t.frontmatter.name,...e}}var Hp,Li,Ex,Zl,ec=S(()=>{$i();Ni();Hp=/^\*\*(.+)\*\*$/,Li=/^(`{3,})(\w*)\s*$/,Ex=new Set(He.map(t=>pe[t].path)),Zl=t=>new RegExp(`^${t}\\s*$`)});function Gp(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 Xp(t,e){let{path:n}=pe[t],r=n.split(".").pop(),s=Gp(e);return`**${n}**
|
|
9
9
|
|
|
10
10
|
${s}${r}
|
|
11
11
|
${e}
|
|
12
|
-
${s}`}function Qp(t){let e=He.filter(n=>t[n]).map(n=>Xp(n,t[n]));return["---",`format: ${Wp}`,`name: ${
|
|
13
|
-
`)}function Zp(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(
|
|
12
|
+
${s}`}function Qp(t){let e=He.filter(n=>t[n]).map(n=>Xp(n,t[n]));return["---",`format: ${Wp}`,`name: ${Xl(t.name)}`,"---","",...e].join(`
|
|
13
|
+
`)}function Zp(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(Li);if(!s)continue;let i=Zl(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 Kr(t,e,n){let r=t.split(`
|
|
14
14
|
`),s=Zp(r,pe[e].path);if(s==="unterminated")return t;if(!s)return`${t.replace(/\s*$/,"")}
|
|
15
15
|
|
|
16
16
|
${Xp(e,n)}
|
|
@@ -19,42 +19,42 @@ ${Xp(e,n)}
|
|
|
19
19
|
`)}function eh(t,e){let n=t.split(`
|
|
20
20
|
`),r=Zp(n,pe[e].path);if(!r||r==="unterminated")return t;let s=r.close+1;for(;s<n.length&&n[s]?.trim()==="";)s++;return[...n.slice(0,r.header),...n.slice(s)].join(`
|
|
21
21
|
`).replace(/\s*$/,"")+`
|
|
22
|
-
`}var th=S(()=>{
|
|
23
|
-
>/]`,i);if(r&&console.log("[xml-utils] start:",o),o===-1)return;let a=t.slice(o+e.length),l=zr(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=zr(a,"[ /]"+e+">",p))!==-1;){let g=a.substring(p,l+1);if(h+=
|
|
24
|
-
>]`),m+=
|
|
25
|
-
`)}};Gr.defaultYaml={explicit:!1,version:"1.2"};Gr.defaultTags={"!!":"tag:yaml.org,2002:"};kh.Directives=Gr});var
|
|
26
|
-
`)?
|
|
22
|
+
`}var th=S(()=>{$i();ec();Ni()});function Hr(t){if(!t.trim())return{};try{return JSON.parse(t)}catch{return{}}}function rh(t){switch(nh(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 sh(t){let e=nh(t);return e!==void 0&&Rx.has(e)?e:void 0}function $x(t){return t.replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\*\*([^*]+)\*\*/g,"$1").replace(/\*([^*]+)\*/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/^#{1,6}\s+/gm,"")}function tc(t){let e=Hr(t??"").description?.trim();if(!e)return Ix;let n=$x(e);return(n.length>200?n.slice(0,197)+"...":n).replace(/\n/g," ")}var _x,Mi,nh,Rx,Ix,ih=S(()=>{_x="https://assets.typebulb.com",Mi=(t,e)=>`${_x}/u/${encodeURIComponent(t)}/${encodeURIComponent(e)}/`,nh=t=>/\.[^./\\]+$/.exec(t)?.[0]?.toLowerCase();Rx=new Set([".html",".htm",".xhtml",".js",".mjs",".cjs",".ts",".tsx",".css"]);Ix="A Typebulb bulb."});var oh=S(()=>{});function nc(t,e,n){let s=new RegExp(e).exec(t.slice(n));return s?n+s.index:-1}var ah=S(()=>{});function zr(t,e,n){let s=new RegExp(e).exec(t.slice(n));return s?n+s.index+s[0].length-1:-1}var lh=S(()=>{});function Di(t,e){let n=new RegExp(e,"g"),r=t.match(n);return r?r.length:0}var ch=S(()=>{});function Yr(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=nc(t,`<${e}[
|
|
23
|
+
>/]`,i);if(r&&console.log("[xml-utils] start:",o),o===-1)return;let a=t.slice(o+e.length),l=zr(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=zr(a,"[ /]"+e+">",p))!==-1;){let g=a.substring(p,l+1);if(h+=Di(g,"<"+e+`[
|
|
24
|
+
>]`),m+=Di(g,"</"+e+">"),m>=h)break;p=l}}else l=zr(a,"[ /]"+e+">",0);let f=o+e.length+l+1;if(r&&console.log("[xml-utils] end:",f),f===-1)return;let d=t.slice(o,f),u;return c?u=null:u=d.slice(d.indexOf(">")+1,d.lastIndexOf("<")),{inner:u,outer:d,start:o,end:f}}var rc=S(()=>{ah();lh();ch()});var sc=S(()=>{rc()});var ic=S(()=>{sc()});var uh=S(()=>{ic()});var dh=S(()=>{});var fh=S(()=>{oh();rc();sc();uh();ic();dh()});var W=I(ge=>{"use strict";var oc=Symbol.for("yaml.alias"),ph=Symbol.for("yaml.document"),Bi=Symbol.for("yaml.map"),hh=Symbol.for("yaml.pair"),ac=Symbol.for("yaml.scalar"),ji=Symbol.for("yaml.seq"),ft=Symbol.for("yaml.node.type"),Mx=t=>!!t&&typeof t=="object"&&t[ft]===oc,Dx=t=>!!t&&typeof t=="object"&&t[ft]===ph,Bx=t=>!!t&&typeof t=="object"&&t[ft]===Bi,jx=t=>!!t&&typeof t=="object"&&t[ft]===hh,mh=t=>!!t&&typeof t=="object"&&t[ft]===ac,Fx=t=>!!t&&typeof t=="object"&&t[ft]===ji;function gh(t){if(t&&typeof t=="object")switch(t[ft]){case Bi:case ji:return!0}return!1}function Ux(t){if(t&&typeof t=="object")switch(t[ft]){case oc:case Bi:case ac:case ji:return!0}return!1}var qx=t=>(mh(t)||gh(t))&&!!t.anchor;ge.ALIAS=oc;ge.DOC=ph;ge.MAP=Bi;ge.NODE_TYPE=ft;ge.PAIR=hh;ge.SCALAR=ac;ge.SEQ=ji;ge.hasAnchor=qx;ge.isAlias=Mx;ge.isCollection=gh;ge.isDocument=Dx;ge.isMap=Bx;ge.isNode=Ux;ge.isPair=jx;ge.isScalar=mh;ge.isSeq=Fx});var Vr=I(lc=>{"use strict";var ce=W(),Ae=Symbol("break visit"),yh=Symbol("skip children"),it=Symbol("remove node");function Fi(t,e){let n=bh(e);ce.isDocument(t)?Jn(null,t.contents,n,Object.freeze([t]))===it&&(t.contents=null):Jn(null,t,n,Object.freeze([]))}Fi.BREAK=Ae;Fi.SKIP=yh;Fi.REMOVE=it;function Jn(t,e,n,r){let s=wh(t,e,n,r);if(ce.isNode(s)||ce.isPair(s))return vh(t,r,s),Jn(t,s,n,r);if(typeof s!="symbol"){if(ce.isCollection(e)){r=Object.freeze(r.concat(e));for(let i=0;i<e.items.length;++i){let o=Jn(i,e.items[i],n,r);if(typeof o=="number")i=o-1;else{if(o===Ae)return Ae;o===it&&(e.items.splice(i,1),i-=1)}}}else if(ce.isPair(e)){r=Object.freeze(r.concat(e));let i=Jn("key",e.key,n,r);if(i===Ae)return Ae;i===it&&(e.key=null);let o=Jn("value",e.value,n,r);if(o===Ae)return Ae;o===it&&(e.value=null)}}return s}async function Ui(t,e){let n=bh(e);ce.isDocument(t)?await Wn(null,t.contents,n,Object.freeze([t]))===it&&(t.contents=null):await Wn(null,t,n,Object.freeze([]))}Ui.BREAK=Ae;Ui.SKIP=yh;Ui.REMOVE=it;async function Wn(t,e,n,r){let s=await wh(t,e,n,r);if(ce.isNode(s)||ce.isPair(s))return vh(t,r,s),Wn(t,s,n,r);if(typeof s!="symbol"){if(ce.isCollection(e)){r=Object.freeze(r.concat(e));for(let i=0;i<e.items.length;++i){let o=await Wn(i,e.items[i],n,r);if(typeof o=="number")i=o-1;else{if(o===Ae)return Ae;o===it&&(e.items.splice(i,1),i-=1)}}}else if(ce.isPair(e)){r=Object.freeze(r.concat(e));let i=await Wn("key",e.key,n,r);if(i===Ae)return Ae;i===it&&(e.key=null);let o=await Wn("value",e.value,n,r);if(o===Ae)return Ae;o===it&&(e.value=null)}}return s}function bh(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 wh(t,e,n,r){if(typeof n=="function")return n(t,e,r);if(ce.isMap(e))return n.Map?.(t,e,r);if(ce.isSeq(e))return n.Seq?.(t,e,r);if(ce.isPair(e))return n.Pair?.(t,e,r);if(ce.isScalar(e))return n.Scalar?.(t,e,r);if(ce.isAlias(e))return n.Alias?.(t,e,r)}function vh(t,e,n){let r=e[e.length-1];if(ce.isCollection(r))r.items[t]=n;else if(ce.isPair(r))t==="key"?r.key=n:r.value=n;else if(ce.isDocument(r))r.contents=n;else{let s=ce.isAlias(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${s} parent`)}}lc.visit=Fi;lc.visitAsync=Ui});var cc=I(kh=>{"use strict";var Sh=W(),Jx=Vr(),Wx={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Kx=t=>t.replace(/[!,[\]{}]/g,e=>Wx[e]),Gr=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+Kx(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&&Sh.isNode(e.contents)){let i={};Jx.visit(e.contents,(o,a)=>{Sh.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
|
+
`)}};Gr.defaultYaml={explicit:!1,version:"1.2"};Gr.defaultTags={"!!":"tag:yaml.org,2002:"};kh.Directives=Gr});var qi=I(Xr=>{"use strict";var xh=W(),Hx=Vr();function zx(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 Eh(t){let e=new Set;return Hx.visit(t,{Value(n,r){r.anchor&&e.add(r.anchor)}}),e}function Ah(t,e){for(let n=1;;++n){let r=`${t}${n}`;if(!e.has(r))return r}}function Yx(t,e){let n=[],r=new Map,s=null;return{onAnchor:i=>{n.push(i),s??(s=Eh(t));let o=Ah(e,s);return s.add(o),o},setAnchors:()=>{for(let i of n){let o=r.get(i);if(typeof o=="object"&&o.anchor&&(xh.isScalar(o.node)||xh.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}}Xr.anchorIsValid=zx;Xr.anchorNames=Eh;Xr.createNodeAnchors=Yx;Xr.findNewAnchor=Ah});var uc=I(Th=>{"use strict";function Qr(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=Qr(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=Qr(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=Qr(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=Qr(t,r,s,i);o===void 0?delete r[s]:o!==i&&(r[s]=o)}return t.call(e,n,r)}Th.applyReviver=Qr});var Rt=I(Oh=>{"use strict";var Vx=W();function Ch(t,e,n){if(Array.isArray(t))return t.map((r,s)=>Ch(r,String(s),n));if(t&&typeof t.toJSON=="function"){if(!n||!Vx.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}Oh.toJS=Ch});var Ji=I(_h=>{"use strict";var Gx=uc(),Ph=W(),Xx=Rt(),dc=class{constructor(e){Object.defineProperty(this,Ph.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(!Ph.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=Xx.toJS(this,"",o);if(typeof s=="function")for(let{count:l,res:c}of o.anchors.values())s(c,l);return typeof i=="function"?Gx.applyReviver(i,{"":a},"",a):a}};_h.NodeBase=dc});var Zr=I(Rh=>{"use strict";var Qx=qi(),Zx=Vr(),Kn=W(),e0=Ji(),t0=Rt(),fc=class extends e0.NodeBase{constructor(e){super(Kn.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=[],Zx.visit(e,{Node:(i,o)=>{(Kn.isAlias(o)||Kn.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||(t0.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=Wi(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(Qx.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 Wi(t,e,n){if(Kn.isAlias(e)){let r=e.resolve(t),s=n&&r&&n.get(r);return s?s.count*s.aliasCount:0}else if(Kn.isCollection(e)){let r=0;for(let s of e.items){let i=Wi(t,s,n);i>r&&(r=i)}return r}else if(Kn.isPair(e)){let r=Wi(t,e.key,n),s=Wi(t,e.value,n);return Math.max(r,s)}return 1}Rh.Alias=fc});var re=I(pc=>{"use strict";var n0=W(),r0=Ji(),s0=Rt(),i0=t=>!t||typeof t!="function"&&typeof t!="object",It=class extends r0.NodeBase{constructor(e){super(n0.SCALAR),this.value=e}toJSON(e,n){return n?.keep?this.value:s0.toJS(this.value,e,n)}toString(){return String(this.value)}};It.BLOCK_FOLDED="BLOCK_FOLDED";It.BLOCK_LITERAL="BLOCK_LITERAL";It.PLAIN="PLAIN";It.QUOTE_DOUBLE="QUOTE_DOUBLE";It.QUOTE_SINGLE="QUOTE_SINGLE";pc.Scalar=It;pc.isScalarValue=i0});var es=I($h=>{"use strict";var o0=Zr(),an=W(),Ih=re(),a0="tag:yaml.org,2002:";function l0(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 c0(t,e,n){if(an.isDocument(t)&&(t=t.contents),an.isNode(t))return t;if(an.isPair(t)){let d=n.schema[an.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 o0.Alias(l.anchor);l={anchor:null,node:null},a.set(t,l)}e?.startsWith("!!")&&(e=a0+e.slice(2));let c=l0(t,e,o.tags);if(!c){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let d=new Ih.Scalar(t);return l&&(l.node=d),d}c=t instanceof Map?o[an.MAP]:Symbol.iterator in Object(t)?o[an.SEQ]:o[an.MAP]}i&&(i(c),delete n.onTagObj);let f=c?.createNode?c.createNode(n.schema,t,n):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(n.schema,t,n):new Ih.Scalar(t);return e?f.tag=e:c.default||(f.tag=c.tag),l&&(l.node=f),f}$h.createNode=c0});var Hi=I(Ki=>{"use strict";var u0=es(),ot=W(),d0=Ji();function hc(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 u0.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 Nh=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,mc=class extends d0.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=>ot.isNode(r)||ot.isPair(r)?r.clone(e):r),this.range&&(n.range=this.range.slice()),n}addIn(e,n){if(Nh(e))this.add(n);else{let[r,...s]=e,i=this.get(r,!0);if(ot.isCollection(i))i.addIn(s,n);else if(i===void 0&&this.schema)this.set(r,hc(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(ot.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&&ot.isScalar(i)?i.value:i:ot.isCollection(i)?i.getIn(s,n):void 0}hasAllNullValues(e){return this.items.every(n=>{if(!ot.isPair(n))return!1;let r=n.value;return r==null||e&&ot.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 ot.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(ot.isCollection(i))i.setIn(s,n);else if(i===void 0&&this.schema)this.set(r,hc(this.schema,s,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${s}`)}}};Ki.Collection=mc;Ki.collectionFromPath=hc;Ki.isEmptyPath=Nh});var ts=I(zi=>{"use strict";var f0=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function gc(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var p0=(t,e,n)=>t.endsWith(`
|
|
26
|
+
`)?gc(n,e):n.includes(`
|
|
27
27
|
`)?`
|
|
28
|
-
`+
|
|
29
|
-
`)n===
|
|
28
|
+
`+gc(n,e):(t.endsWith(" ")?"":" ")+n;zi.indentComment=gc;zi.lineComment=p0;zi.stringifyComment=f0});var Mh=I(ns=>{"use strict";var h0="flow",yc="block",Yi="quoted";function m0(t,e,n="flow",{indentAtStart:r,lineWidth:s=80,minContentWidth:i=20,onFold:o,onOverflow:a}={}){if(!s||s<0)return t;s<i&&(i=0);let l=Math.max(1+i,1+s-e.length);if(t.length<=l)return t;let c=[],f={},d=s-e.length;typeof r=="number"&&(r>s-Math.max(2,i)?c.push(0):d=s-r);let u,p,h=!1,m=-1,g=-1,v=-1;n===yc&&(m=Lh(t,m,e.length),m!==-1&&(d=m+l));for(let P;P=t[m+=1];){if(n===Yi&&P==="\\"){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(P===`
|
|
29
|
+
`)n===yc&&(m=Lh(t,m,e.length)),d=m+e.length+l,u=void 0;else{if(P===" "&&p&&p!==" "&&p!==`
|
|
30
30
|
`&&p!==" "){let A=t[m+1];A&&A!==" "&&A!==`
|
|
31
|
-
`&&A!==" "&&(u=m)}if(m>=d)if(u)c.push(u),d=u+l,u=void 0;else if(n===
|
|
32
|
-
${e}${t.slice(0,$)}`:(n===
|
|
31
|
+
`&&A!==" "&&(u=m)}if(m>=d)if(u)c.push(u),d=u+l,u=void 0;else if(n===Yi){for(;p===" "||p===" ";)p=P,P=t[m+=1],h=!0;let A=m>v+1?m-2:g-1;if(f[A])return t;c.push(A),f[A]=!0,d=A+l,u=void 0}else h=!0}p=P}if(h&&a&&a(),c.length===0)return t;o&&o();let E=t.slice(0,c[0]);for(let P=0;P<c.length;++P){let A=c[P],$=c[P+1]||t.length;A===0?E=`
|
|
32
|
+
${e}${t.slice(0,$)}`:(n===Yi&&f[A]&&(E+=`${t[A]}\\`),E+=`
|
|
33
33
|
${e}${t.slice(A+1,$)}`)}return E}function Lh(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}ns.FOLD_BLOCK=
|
|
35
|
-
`){if(i-o>r)return!0;if(o=i+1,s-o<=r)return!1}return!0}function rs(t,e){let n=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=e,s=e.options.doubleQuotedMinMultiLineLength,i=e.indent||(
|
|
34
|
+
`);r=e,s=e+1,i=t[s]}return r}ns.FOLD_BLOCK=yc;ns.FOLD_FLOW=h0;ns.FOLD_QUOTED=Yi;ns.foldFlowLines=m0});var ss=I(Dh=>{"use strict";var Ye=re(),$t=Mh(),Gi=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),Xi=t=>/^(%|---|\.\.\.)/m.test(t);function g0(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 rs(t,e){let n=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=e,s=e.options.doubleQuotedMinMultiLineLength,i=e.indent||(Xi(t)?" ":""),o="",a=0;for(let l=0,c=n[l];c;c=n[++l])if(c===" "&&n[l+1]==="\\"&&n[l+2]==="n"&&(o+=n.slice(a,l)+"\\ ",l+=1,a=l,c="\\"),c==="\\")switch(n[l+1]){case"u":{o+=n.slice(a,l);let f=n.substr(l+2,4);switch(f){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:f.substr(0,2)==="00"?o+="\\x"+f.substr(2):o+=n.substr(l,6)}l+=5,a=l+1}break;case"n":if(r||n[l+2]==='"'||n.length<s)l+=1;else{for(o+=n.slice(a,l)+`
|
|
36
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 rs(t,e);let n=e.indent||(
|
|
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:$t.foldFlowLines(o,i,$t.FOLD_QUOTED,Gi(e,!1))}function bc(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
|
|
39
|
+
`)||/[ \t]\n|\n[ \t]/.test(t))return rs(t,e);let n=e.indent||(Xi(t)?" ":""),r="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
40
|
+
${n}`)+"'";return e.implicitKey?r:$t.foldFlowLines(r,n,$t.FOLD_FLOW,Gi(e,!1))}function Hn(t,e){let{singleQuote:n}=e.options,r;if(n===!1)r=rs;else{let s=t.includes('"'),i=t.includes("'");s&&!i?r=bc:i&&!s?r=rs:r=n?bc:rs}return r(t,e)}var wc;try{wc=new RegExp(`(^|(?<!
|
|
41
41
|
))
|
|
42
42
|
+(?!
|
|
43
|
-
|$)`,"g")}catch{
|
|
43
|
+
|$)`,"g")}catch{wc=/\n+(?!\n|$)/g}function Vi({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 Hn(n,r);let c=r.indent||(r.forceBlockIndent||Xi(n)?" ":""),f=o==="literal"?!0:o==="folded"||e===Ye.Scalar.BLOCK_FOLDED?!1:e===Ye.Scalar.BLOCK_LITERAL?!0:!g0(n,l,c.length);if(!n)return f?`|
|
|
44
44
|
`:`>
|
|
45
45
|
`;let d,u;for(u=n.length;u>0;--u){let $=n[u-1];if($!==`
|
|
46
46
|
`&&$!==" "&&$!==" ")break}let p=n.substring(u),h=p.indexOf(`
|
|
47
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(
|
|
48
|
+
`&&(p=p.slice(0,-1)),p=p.replace(wc,`$&${c}`));let m=!1,g,v=-1;for(g=0;g<n.length;++g){let $=n[g];if($===" ")m=!0;else if($===`
|
|
49
49
|
`)v=g;else break}let E=n.substring(0,v<g?v+1:g);E&&(n=n.substring(E.length),E=E.replace(/\n+/g,`$&${c}`));let A=(m?c?"2":"1":"")+d;if(t&&(A+=" "+a(t.replace(/ ?[\r\n]+/g," ")),s&&s()),!f){let $=n.replace(/\n+/g,`
|
|
50
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),O=!1,_=
|
|
50
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),O=!1,_=Gi(r,!0);o!=="folded"&&e!==Ye.Scalar.BLOCK_FOLDED&&(_.onOverflow=()=>{O=!0});let k=$t.foldFlowLines(`${E}${$}${p}`,c,$t.FOLD_BLOCK,_);if(!O)return`>${A}
|
|
51
51
|
${c}${k}`}return n=n.replace(/\n+/g,`$&${c}`),`|${A}
|
|
52
|
-
${c}${E}${n}${p}`}function
|
|
52
|
+
${c}${E}${n}${p}`}function y0(t,e,n,r){let{type:s,value:i}=t,{actualString:o,implicitKey:a,indent:l,indentStep:c,inFlow:f}=e;if(a&&i.includes(`
|
|
53
53
|
`)||f&&/[[\]{},]/.test(i))return Hn(i,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(i))return a||f||!i.includes(`
|
|
54
|
-
`)?Hn(i,e):
|
|
55
|
-
`))return
|
|
56
|
-
${l}`);if(o){let u=m=>m.default&&m.tag!=="tag:yaml.org,2002:str"&&m.test?.test(d),{compat:p,tags:h}=e.doc.schema;if(h.some(u)||p?.some(u))return Hn(i,e)}return a?d
|
|
57
|
-
${e.indent}${a}`:a}
|
|
54
|
+
`)?Hn(i,e):Vi(t,e,n,r);if(!a&&!f&&s!==Ye.Scalar.PLAIN&&i.includes(`
|
|
55
|
+
`))return Vi(t,e,n,r);if(Xi(i)){if(l==="")return e.forceBlockIndent=!0,Vi(t,e,n,r);if(a&&l===c)return Hn(i,e)}let d=i.replace(/\n+/g,`$&
|
|
56
|
+
${l}`);if(o){let u=m=>m.default&&m.tag!=="tag:yaml.org,2002:str"&&m.test?.test(d),{compat:p,tags:h}=e.doc.schema;if(h.some(u)||p?.some(u))return Hn(i,e)}return a?d:$t.foldFlowLines(d,l,$t.FOLD_FLOW,Gi(e,!1))}function b0(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=f=>{switch(f){case Ye.Scalar.BLOCK_FOLDED:case Ye.Scalar.BLOCK_LITERAL:return s||i?Hn(o.value,e):Vi(o,e,n,r);case Ye.Scalar.QUOTE_DOUBLE:return rs(o.value,e);case Ye.Scalar.QUOTE_SINGLE:return bc(o.value,e);case Ye.Scalar.PLAIN:return y0(o,e,n,r);default:return null}},c=l(a);if(c===null){let{defaultKeyType:f,defaultStringType:d}=e.options,u=s&&f||d;if(c=l(u),c===null)throw new Error(`Unsupported default string type ${u}`)}return c}Dh.stringifyString=b0});var is=I(vc=>{"use strict";var w0=qi(),Nt=W(),v0=ts(),S0=ss();function k0(t,e){let n=Object.assign({blockQuote:!0,commentString:v0.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 x0(t,e){if(e.tag){let s=t.filter(i=>i.tag===e.tag);if(s.length>0)return s.find(i=>i.format===e.format)??s[0]}let n,r;if(Nt.isScalar(e)){r=e.value;let s=t.filter(i=>i.identify?.(r));if(s.length>1){let i=s.filter(o=>o.test);i.length>0&&(s=i)}n=s.find(i=>i.format===e.format)??s.find(i=>!i.format)}else r=e,n=t.find(s=>s.nodeClass&&r instanceof s.nodeClass);if(!n){let s=r?.constructor?.name??(r===null?"null":typeof r);throw new Error(`Tag not resolved for ${s} value`)}return n}function E0(t,e,{anchors:n,doc:r}){if(!r.directives)return"";let s=[],i=(Nt.isScalar(t)||Nt.isCollection(t))&&t.anchor;i&&w0.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 A0(t,e,n,r){if(Nt.isPair(t))return t.toString(e,n,r);if(Nt.isAlias(t)){if(e.doc.directives)return t.toString(e);if(e.resolvedAliases?.has(t))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(t):e.resolvedAliases=new Set([t]),t=t.resolve(e.doc)}let s,i=Nt.isNode(t)?t:e.doc.createNode(t,{onTagObj:l=>s=l});s??(s=x0(e.doc.schema.tags,i));let o=E0(i,s,e);o.length>0&&(e.indentAtStart=(e.indentAtStart??0)+o.length+1);let a=typeof s.stringify=="function"?s.stringify(i,e,n,r):Nt.isScalar(i)?S0.stringifyString(i,e,n,r):i.toString(e,n,r);return o?Nt.isScalar(i)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
|
|
57
|
+
${e.indent}${a}`:a}vc.createStringifyContext=k0;vc.stringify=A0});var Uh=I(Fh=>{"use strict";var pt=W(),Bh=re(),jh=is(),os=ts();function T0({key:t,value:e},n,r,s){let{allNullValues:i,doc:o,indent:a,indentStep:l,options:{commentString:c,indentSeq:f,simpleKeys:d}}=n,u=pt.isNode(t)&&t.comment||null;if(d){if(u)throw new Error("With simple keys, key nodes cannot have comments");if(pt.isCollection(t)||!pt.isNode(t)&&typeof t=="object"){let _="With simple keys, collection cannot be used as a key value";throw new Error(_)}}let p=!d&&(!t||u&&e==null&&!n.inFlow||pt.isCollection(t)||(pt.isScalar(t)?t.type===Bh.Scalar.BLOCK_FOLDED||t.type===Bh.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=jh.stringify(t,n,()=>h=!0,()=>m=!0);if(!p&&!n.inFlow&&g.length>1024){if(d)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");p=!0}if(n.inFlow){if(i||e==null)return h&&r&&r(),g===""?"?":p?`? ${g}`:g}else if(i&&!d||e==null&&p)return g=`? ${g}`,u&&!h?g+=os.lineComment(g,n.indent,c(u)):m&&s&&s(),g;h&&(u=null),p?(u&&(g+=os.lineComment(g,n.indent,c(u))),g=`? ${g}
|
|
58
58
|
${a}:`):(g=`${g}:`,u&&(g+=os.lineComment(g,n.indent,c(u))));let v,E,P;pt.isNode(e)?(v=!!e.spaceBefore,E=e.commentBefore,P=e.comment):(v=!1,E=null,P=null,e&&typeof e=="object"&&(e=o.createNode(e))),n.implicitKey=!1,!p&&!u&&pt.isScalar(e)&&(n.indentAtStart=g.length+1),m=!1,!f&&l.length>=2&&!n.inFlow&&!p&&pt.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(n.indent=n.indent.substring(2));let A=!1,$=jh.stringify(e,n,()=>A=!0,()=>m=!0),O=" ";if(u||v||E){if(O=v?`
|
|
59
59
|
`:"",E){let _=c(E);O+=`
|
|
60
60
|
${os.indentComment(_,n.indent)}`}$===""&&!n.inFlow?O===`
|
|
@@ -64,34 +64,34 @@ ${os.indentComment(_,n.indent)}`}$===""&&!n.inFlow?O===`
|
|
|
64
64
|
${n.indent}`}else if(!p&&pt.isCollection(e)){let _=$[0],k=$.indexOf(`
|
|
65
65
|
`),N=k!==-1,B=n.inFlow??e.flow??e.items.length===0;if(N||!B){let Z=!1;if(N&&(_==="&"||_==="!")){let q=$.indexOf(" ");_==="&"&&q!==-1&&q<k&&$[q+1]==="!"&&(q=$.indexOf(" ",q+1)),(q===-1||k<q)&&(Z=!0)}Z||(O=`
|
|
66
66
|
${n.indent}`)}}else($===""||$[0]===`
|
|
67
|
-
`)&&(O="");return g+=O+$,n.inFlow?A&&r&&r():P&&!A?g+=os.lineComment(g,n.indent,c(P)):m&&s&&s(),g}Fh.stringifyPair=
|
|
67
|
+
`)&&(O="");return g+=O+$,n.inFlow?A&&r&&r():P&&!A?g+=os.lineComment(g,n.indent,c(P)):m&&s&&s(),g}Fh.stringifyPair=T0});var kc=I(Sc=>{"use strict";var qh=_i("process");function C0(t,...e){t==="debug"&&console.log(...e)}function O0(t,e){(t==="debug"||t==="warn")&&(typeof qh.emitWarning=="function"?qh.emitWarning(e):console.warn(e))}Sc.debug=C0;Sc.warn=O0});var to=I(eo=>{"use strict";var as=W(),Jh=re(),Qi="<<",Zi={identify:t=>t===Qi||typeof t=="symbol"&&t.description===Qi,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Jh.Scalar(Symbol(Qi)),{addToJSMap:Wh}),stringify:()=>Qi},P0=(t,e)=>(Zi.identify(e)||as.isScalar(e)&&(!e.type||e.type===Jh.Scalar.PLAIN)&&Zi.identify(e.value))&&t?.doc.schema.tags.some(n=>n.tag===Zi.tag&&n.default);function Wh(t,e,n){if(n=t&&as.isAlias(n)?n.resolve(t.doc):n,as.isSeq(n))for(let r of n.items)xc(t,e,r);else if(Array.isArray(n))for(let r of n)xc(t,e,r);else xc(t,e,n)}function xc(t,e,n){let r=t&&as.isAlias(n)?n.resolve(t.doc):n;if(!as.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}eo.addMergeToJSMap=Wh;eo.isMergeKey=P0;eo.merge=Zi});var Ac=I(zh=>{"use strict";var _0=kc(),Kh=to(),R0=is(),Hh=W(),Ec=Rt();function I0(t,e,{key:n,value:r}){if(Hh.isNode(n)&&n.addToJSMap)n.addToJSMap(t,e,r);else if(Kh.isMergeKey(t,n))Kh.addMergeToJSMap(t,e,r);else{let s=Ec.toJS(n,"",t);if(e instanceof Map)e.set(s,Ec.toJS(r,s,t));else if(e instanceof Set)e.add(s);else{let i=$0(n,s,t),o=Ec.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 $0(t,e,n){if(e===null)return"";if(typeof e!="object")return String(e);if(Hh.isNode(t)&&n?.doc){let r=R0.createStringifyContext(n.doc,{});r.anchors=new Set;for(let i of n.anchors.keys())r.anchors.add(i.anchor);r.inFlow=!0,r.inStringifyKey=!0;let s=t.toString(r);if(!n.mapKeyWarned){let i=JSON.stringify(s);i.length>40&&(i=i.substring(0,36)+'..."'),_0.warn(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${i}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return s}return JSON.stringify(e)}zh.addPairToJSMap=I0});var Lt=I(Tc=>{"use strict";var Yh=es(),N0=Uh(),L0=Ac(),no=W();function M0(t,e,n){let r=Yh.createNode(t,void 0,n),s=Yh.createNode(e,void 0,n);return new ro(r,s)}var ro=class t{constructor(e,n=null){Object.defineProperty(this,no.NODE_TYPE,{value:no.PAIR}),this.key=e,this.value=n}clone(e){let{key:n,value:r}=this;return no.isNode(n)&&(n=n.clone(e)),no.isNode(r)&&(r=r.clone(e)),new t(n,r)}toJSON(e,n){let r=n?.mapAsMap?new Map:{};return L0.addPairToJSMap(n,r,this)}toString(e,n,r){return e?.doc?N0.stringifyPair(this,e,n,r):JSON.stringify(this)}};Tc.Pair=ro;Tc.createPair=M0});var Cc=I(Gh=>{"use strict";var ln=W(),Vh=is(),so=ts();function D0(t,e,n){return(e.inFlow??t.flow?j0:B0)(t,e,n)}function B0({comment:t,items:e},n,{blockItemPrefix:r,flowChars:s,itemIndent:i,onChompKeep:o,onComment:a}){let{indent:l,options:{commentString:c}}=n,f=Object.assign({},n,{indent:i,type:null}),d=!1,u=[];for(let h=0;h<e.length;++h){let m=e[h],g=null;if(ln.isNode(m))!d&&m.spaceBefore&&u.push(""),io(n,u,m.commentBefore,d),m.comment&&(g=m.comment);else if(ln.isPair(m)){let E=ln.isNode(m.key)?m.key:null;E&&(!d&&E.spaceBefore&&u.push(""),io(n,u,E.commentBefore,d))}d=!1;let v=Vh.stringify(m,f,()=>g=null,()=>d=!0);g&&(v+=so.lineComment(v,i,c(g))),d&&g&&(d=!1),u.push(r+v)}let p;if(u.length===0)p=s.start+s.end;else{p=u[0];for(let h=1;h<u.length;++h){let m=u[h];p+=m?`
|
|
68
68
|
${l}${m}`:`
|
|
69
69
|
`}}return t?(p+=`
|
|
70
|
-
`+
|
|
70
|
+
`+so.indentComment(c(t),l),a&&a()):d&&o&&o(),p}function j0({items:t},e,{flowChars:n,itemIndent:r}){let{indent:s,indentStep:i,flowCollectionPadding:o,options:{commentString:a}}=e;r+=i;let l=Object.assign({},e,{indent:r,inFlow:!0,type:null}),c=!1,f=0,d=[];for(let h=0;h<t.length;++h){let m=t[h],g=null;if(ln.isNode(m))m.spaceBefore&&d.push(""),io(e,d,m.commentBefore,!1),m.comment&&(g=m.comment);else if(ln.isPair(m)){let E=ln.isNode(m.key)?m.key:null;E&&(E.spaceBefore&&d.push(""),io(e,d,E.commentBefore,!1),E.comment&&(c=!0));let P=ln.isNode(m.value)?m.value:null;P?(P.comment&&(g=P.comment),P.commentBefore&&(c=!0)):m.value==null&&E?.comment&&(g=E.comment)}g&&(c=!0);let v=Vh.stringify(m,l,()=>g=null);h<t.length-1&&(v+=","),g&&(v+=so.lineComment(v,r,a(g))),!c&&(d.length>f||v.includes(`
|
|
71
71
|
`))&&(c=!0),d.push(v),f=d.length}let{start:u,end:p}=n;if(d.length===0)return u+p;if(!c){let h=d.reduce((m,g)=>m+g.length+2,2);c=e.options.lineWidth>0&&h>e.options.lineWidth}if(c){let h=u;for(let m of d)h+=m?`
|
|
72
72
|
${i}${s}${m}`:`
|
|
73
73
|
`;return`${h}
|
|
74
|
-
${s}${p}`}else return`${u}${o}${d.join(" ")}${o}${p}`}function
|
|
75
|
-
`:" ")}return
|
|
74
|
+
${s}${p}`}else return`${u}${o}${d.join(" ")}${o}${p}`}function io({indent:t,options:{commentString:e}},n,r,s){if(r&&s&&(r=r.replace(/^\n+/,"")),r){let i=so.indentComment(e(r),t);n.push(i.trimStart())}}Gh.stringifyCollection=D0});var Dt=I(Pc=>{"use strict";var F0=Cc(),U0=Ac(),q0=Hi(),Mt=W(),oo=Lt(),J0=re();function ls(t,e){let n=Mt.isScalar(e)?e.value:e;for(let r of t)if(Mt.isPair(r)&&(r.key===e||r.key===n||Mt.isScalar(r.key)&&r.key.value===n))return r}var Oc=class extends q0.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Mt.MAP,e),this.items=[]}static from(e,n,r){let{keepUndefined:s,replacer:i}=r,o=new this(e),a=(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(oo.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;Mt.isPair(e)?r=e:!e||typeof e!="object"||!("key"in e)?r=new oo.Pair(e,e?.value):r=new oo.Pair(e.key,e.value);let s=ls(this.items,r.key),i=this.schema?.sortMapEntries;if(s){if(!n)throw new Error(`Key ${r.key} already set`);Mt.isScalar(s.value)&&J0.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=ls(this.items,e);return n?this.items.splice(this.items.indexOf(n),1).length>0:!1}get(e,n){let s=ls(this.items,e)?.value;return(!n&&Mt.isScalar(s)?s.value:s)??void 0}has(e){return!!ls(this.items,e)}set(e,n){this.add(new oo.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)U0.addPairToJSMap(n,s,i);return s}toString(e,n,r){if(!e)return JSON.stringify(this);for(let s of this.items)if(!Mt.isPair(s))throw new Error(`Map items must all be pairs; found ${JSON.stringify(s)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),F0.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:n})}};Pc.YAMLMap=Oc;Pc.findPair=ls});var zn=I(Qh=>{"use strict";var W0=W(),Xh=Dt(),K0={collection:"map",default:!0,nodeClass:Xh.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(t,e){return W0.isMap(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,n)=>Xh.YAMLMap.from(t,e,n)};Qh.map=K0});var Bt=I(Zh=>{"use strict";var H0=es(),z0=Cc(),Y0=Hi(),lo=W(),V0=re(),G0=Rt(),_c=class extends Y0.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(lo.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let n=ao(e);return typeof n!="number"?!1:this.items.splice(n,1).length>0}get(e,n){let r=ao(e);if(typeof r!="number")return;let s=this.items[r];return!n&&lo.isScalar(s)?s.value:s}has(e){let n=ao(e);return typeof n=="number"&&n<this.items.length}set(e,n){let r=ao(e);if(typeof r!="number")throw new Error(`Expected a valid index, not ${e}.`);let s=this.items[r];lo.isScalar(s)&&V0.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(G0.toJS(i,String(s++),n));return r}toString(e,n,r){return e?z0.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(H0.createNode(a,void 0,r))}}return i}};function ao(t){let e=lo.isScalar(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}Zh.YAMLSeq=_c});var Yn=I(tm=>{"use strict";var X0=W(),em=Bt(),Q0={collection:"seq",default:!0,nodeClass:em.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(t,e){return X0.isSeq(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,n)=>em.YAMLSeq.from(t,e,n)};tm.seq=Q0});var cs=I(nm=>{"use strict";var Z0=ss(),eE={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),Z0.stringifyString(t,e,n,r)}};nm.string=eE});var co=I(im=>{"use strict";var rm=re(),sm={identify:t=>t==null,createNode:()=>new rm.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new rm.Scalar(null),stringify:({source:t},e)=>typeof t=="string"&&sm.test.test(t)?t:e.options.nullStr};im.nullTag=sm});var Rc=I(am=>{"use strict";var tE=re(),om={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new tE.Scalar(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},n){if(t&&om.test.test(t)){let r=t[0]==="t"||t[0]==="T";if(e===r)return t}return e?n.options.trueStr:n.options.falseStr}};am.boolTag=om});var Vn=I(lm=>{"use strict";function nE({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}lm.stringifyNumber=nE});var $c=I(uo=>{"use strict";var rE=re(),Ic=Vn(),sE={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:Ic.stringifyNumber},iE={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():Ic.stringifyNumber(t)}},oE={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 rE.Scalar(parseFloat(t)),n=t.indexOf(".");return n!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-n-1),e},stringify:Ic.stringifyNumber};uo.float=oE;uo.floatExp=iE;uo.floatNaN=sE});var Lc=I(po=>{"use strict";var cm=Vn(),fo=t=>typeof t=="bigint"||Number.isInteger(t),Nc=(t,e,n,{intAsBigInt:r})=>r?BigInt(t):parseInt(t.substring(e),n);function um(t,e,n){let{value:r}=t;return fo(r)&&r>=0?n+r.toString(e):cm.stringifyNumber(t)}var aE={identify:t=>fo(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,n)=>Nc(t,2,8,n),stringify:t=>um(t,8,"0o")},lE={identify:fo,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,n)=>Nc(t,0,10,n),stringify:cm.stringifyNumber},cE={identify:t=>fo(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,n)=>Nc(t,2,16,n),stringify:t=>um(t,16,"0x")};po.int=lE;po.intHex=cE;po.intOct=aE});var fm=I(dm=>{"use strict";var uE=zn(),dE=co(),fE=Yn(),pE=cs(),hE=Rc(),Mc=$c(),Dc=Lc(),mE=[uE.map,fE.seq,pE.string,dE.nullTag,hE.boolTag,Dc.intOct,Dc.int,Dc.intHex,Mc.floatNaN,Mc.floatExp,Mc.float];dm.schema=mE});var mm=I(hm=>{"use strict";var gE=re(),yE=zn(),bE=Yn();function pm(t){return typeof t=="bigint"||Number.isInteger(t)}var ho=({value:t})=>JSON.stringify(t),wE=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:ho},{identify:t=>t==null,createNode:()=>new gE.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:ho},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:ho},{identify:pm,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})=>pm(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:ho}],vE={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},SE=[yE.map,bE.seq].concat(wE,vE);hm.schema=SE});var jc=I(gm=>{"use strict";var us=_i("buffer"),Bc=re(),kE=ss(),xE={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof us.Buffer=="function")return us.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 us.Buffer=="function")a=o instanceof us.Buffer?o.toString("base64"):us.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=Bc.Scalar.BLOCK_LITERAL),e!==Bc.Scalar.QUOTE_DOUBLE){let l=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),c=Math.ceil(a.length/l),f=new Array(c);for(let d=0,u=0;d<c;++d,u+=l)f[d]=a.substr(u,l);a=f.join(e===Bc.Scalar.BLOCK_LITERAL?`
|
|
75
|
+
`:" ")}return kE.stringifyString({comment:t,type:e,value:a},r,s,i)}};gm.binary=xE});var yo=I(go=>{"use strict";var mo=W(),Fc=Lt(),EE=re(),AE=Bt();function ym(t,e){if(mo.isSeq(t))for(let n=0;n<t.items.length;++n){let r=t.items[n];if(!mo.isPair(r)){if(mo.isMap(r)){r.items.length>1&&e("Each pair must have its own sequence indicator");let s=r.items[0]||new Fc.Pair(new EE.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]=fo.isPair(r)?r:new jc.Pair(r)}}else e("Expected a sequence for this tag");return t}function bm(t,e,n){let{replacer:r}=n,s=new EE.YAMLSeq(t);s.tag="tag:yaml.org,2002:pairs";let i=0;if(e&&Symbol.iterator in Object(e))for(let o of e){typeof r=="function"&&(o=r.call(e,String(i++),o));let a,l;if(Array.isArray(o))if(o.length===2)a=o[0],l=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let c=Object.keys(o);if(c.length===1)a=c[0],l=o[a];else throw new TypeError(`Expected tuple with one key, not ${c.length} keys`)}else a=o;s.items.push(jc.createPair(a,l,n))}return s}var AE={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:ym,createNode:bm};po.createPairs=bm;po.pairs=AE;po.resolvePairs=ym});var qc=I(Uc=>{"use strict";var wm=W(),Fc=_t(),ds=Mt(),TE=Dt(),vm=ho(),ln=class t extends TE.YAMLSeq{constructor(){super(),this.add=ds.YAMLMap.prototype.add.bind(this),this.delete=ds.YAMLMap.prototype.delete.bind(this),this.get=ds.YAMLMap.prototype.get.bind(this),this.has=ds.YAMLMap.prototype.has.bind(this),this.set=ds.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(wm.isPair(s)?(i=Fc.toJS(s.key,"",n),o=Fc.toJS(s.value,i,n)):i=Fc.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=vm.createPairs(e,n,r),i=new this;return i.items=s.items,i}};ln.tag="tag:yaml.org,2002:omap";var CE={collection:"seq",identify:t=>t instanceof Map,nodeClass:ln,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let n=vm.resolvePairs(t,e),r=[];for(let{key:s}of n.items)wm.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)};Uc.YAMLOMap=ln;Uc.omap=CE});var Am=I(Jc=>{"use strict";var Sm=re();function km({value:t,source:e},n){return e&&(t?xm:Em).test.test(e)?e:t?n.options.trueStr:n.options.falseStr}var xm={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 Sm.Scalar(!0),stringify:km},Em={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 Sm.Scalar(!1),stringify:km};Jc.falseTag=Em;Jc.trueTag=xm});var Tm=I(mo=>{"use strict";var OE=re(),Wc=Vn(),PE={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:Wc.stringifyNumber},_E={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():Wc.stringifyNumber(t)}},RE={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(t){let e=new OE.Scalar(parseFloat(t.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:Wc.stringifyNumber};mo.float=RE;mo.floatExp=_E;mo.floatNaN=PE});var Om=I(ps=>{"use strict";var Cm=Vn(),fs=t=>typeof t=="bigint"||Number.isInteger(t);function go(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 Kc(t,e,n){let{value:r}=t;if(fs(r)){let s=r.toString(e);return r<0?"-"+n+s.substr(1):n+s}return Cm.stringifyNumber(t)}var IE={identify:fs,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,n)=>go(t,2,2,n),stringify:t=>Kc(t,2,"0b")},$E={identify:fs,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,n)=>go(t,1,8,n),stringify:t=>Kc(t,8,"0")},NE={identify:fs,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,n)=>go(t,0,10,n),stringify:Cm.stringifyNumber},LE={identify:fs,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,n)=>go(t,2,16,n),stringify:t=>Kc(t,16,"0x")};ps.int=NE;ps.intBin=IE;ps.intHex=LE;ps.intOct=$E});var zc=I(Hc=>{"use strict";var wo=W(),yo=Nt(),bo=Mt(),cn=class t extends bo.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let n;wo.isPair(e)?n=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?n=new yo.Pair(e.key,null):n=new yo.Pair(e,null),bo.findPair(this.items,n.key)||this.items.push(n)}get(e,n){let r=bo.findPair(this.items,e);return!n&&wo.isPair(r)?wo.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=bo.findPair(this.items,e);r&&!n?this.items.splice(this.items.indexOf(r),1):!r&&n&&this.items.push(new yo.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(yo.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(wo.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}};Hc.YAMLSet=cn;Hc.set=ME});var Vc=I(vo=>{"use strict";var DE=Vn();function Yc(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 Pm(t){let{value:e}=t,n=o=>o;if(typeof e=="bigint")n=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return DE.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 BE={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})=>Yc(t,n),stringify:Pm},jE={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:t=>Yc(t,!1),stringify:Pm},_m={identify:t=>t instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(t){let e=t.match(_m.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,n,r,s,i,o,a]=e.map(Number),l=e[7]?Number((e[7]+"00").substr(1,3)):0,c=Date.UTC(n,r-1,s,i||0,o||0,a||0,l),f=e[8];if(f&&f!=="Z"){let d=Yc(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$/,"")??""};vo.floatTime=jE;vo.intTime=BE;vo.timestamp=_m});var $m=I(Im=>{"use strict";var FE=zn(),UE=oo(),qE=Yn(),JE=cs(),WE=Bc(),Rm=Am(),Gc=Tm(),So=Om(),KE=Qi(),HE=qc(),zE=ho(),YE=zc(),Xc=Vc(),VE=[FE.map,qE.seq,JE.string,UE.nullTag,Rm.trueTag,Rm.falseTag,So.intBin,So.intOct,So.int,So.intHex,Gc.floatNaN,Gc.floatExp,Gc.float,WE.binary,KE.merge,HE.omap,zE.pairs,YE.set,Xc.intTime,Xc.floatTime,Xc.timestamp];Im.schema=VE});var Jm=I(eu=>{"use strict";var Dm=zn(),GE=oo(),Bm=Yn(),XE=cs(),QE=_c(),Qc=Ic(),Zc=Nc(),ZE=fm(),eA=mm(),jm=Bc(),hs=Qi(),Fm=qc(),Um=ho(),Nm=$m(),qm=zc(),ko=Vc(),Lm=new Map([["core",ZE.schema],["failsafe",[Dm.map,Bm.seq,XE.string]],["json",eA.schema],["yaml11",Nm.schema],["yaml-1.1",Nm.schema]]),Mm={binary:jm.binary,bool:QE.boolTag,float:Qc.float,floatExp:Qc.floatExp,floatNaN:Qc.floatNaN,floatTime:ko.floatTime,int:Zc.int,intHex:Zc.intHex,intOct:Zc.intOct,intTime:ko.intTime,map:Dm.map,merge:hs.merge,null:GE.nullTag,omap:Fm.omap,pairs:Um.pairs,seq:Bm.seq,set:qm.set,timestamp:ko.timestamp},tA={"tag:yaml.org,2002:binary":jm.binary,"tag:yaml.org,2002:merge":hs.merge,"tag:yaml.org,2002:omap":Fm.omap,"tag:yaml.org,2002:pairs":Um.pairs,"tag:yaml.org,2002:set":qm.set,"tag:yaml.org,2002:timestamp":ko.timestamp};function nA(t,e,n){let r=Lm.get(e);if(r&&!t)return n&&!r.includes(hs.merge)?r.concat(hs.merge):r.slice();let s=r;if(!s)if(Array.isArray(t))s=[];else{let i=Array.from(Lm.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(hs.merge)),s.reduce((i,o)=>{let a=typeof o=="string"?Mm[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(Mm).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},[])}eu.coreKnownTags=tA;eu.getTags=nA});var ru=I(Wm=>{"use strict";var tu=W(),rA=zn(),sA=Yn(),iA=cs(),xo=Jm(),oA=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,nu=class t{constructor({compat:e,customTags:n,merge:r,resolveKnownTags:s,schema:i,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(e)?xo.getTags(e,"compat"):e?xo.getTags(null,e):null,this.name=typeof i=="string"&&i||"core",this.knownTags=s?xo.coreKnownTags:{},this.tags=xo.getTags(n,this.name,r),this.toStringOptions=a??null,Object.defineProperty(this,tu.MAP,{value:rA.map}),Object.defineProperty(this,tu.SCALAR,{value:iA.string}),Object.defineProperty(this,tu.SEQ,{value:sA.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?oA:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};Wm.Schema=nu});var Hm=I(Km=>{"use strict";var aA=W(),su=is(),ms=ts();function lA(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=su.createStringifyContext(t,e),{commentString:i}=s.options;if(t.commentBefore){n.length!==1&&n.unshift("");let l=i(t.commentBefore);n.unshift(ms.indentComment(l,""))}let o=!1,a=null;if(t.contents){if(aA.isNode(t.contents)){if(t.contents.spaceBefore&&r&&n.push(""),t.contents.commentBefore){let f=i(t.contents.commentBefore);n.push(ms.indentComment(f,""))}s.forceBlockIndent=!!t.comment,a=t.contents.comment}let l=a?void 0:()=>o=!0,c=su.stringify(t.contents,s,()=>a=null,l);a&&(c+=ms.lineComment(c,"",i(a))),(c[0]==="|"||c[0]===">")&&n[n.length-1]==="---"?n[n.length-1]=`--- ${c}`:n.push(c)}else n.push(su.stringify(t.contents,s));if(t.directives?.docEnd)if(t.comment){let l=i(t.comment);l.includes(`
|
|
77
|
+
${i.comment}`:r.comment}r=s}t.items[n]=mo.isPair(r)?r:new Fc.Pair(r)}}else e("Expected a sequence for this tag");return t}function bm(t,e,n){let{replacer:r}=n,s=new AE.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(Fc.createPair(a,l,n))}return s}var TE={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:ym,createNode:bm};go.createPairs=bm;go.pairs=TE;go.resolvePairs=ym});var Jc=I(qc=>{"use strict";var wm=W(),Uc=Rt(),ds=Dt(),CE=Bt(),vm=yo(),cn=class t extends CE.YAMLSeq{constructor(){super(),this.add=ds.YAMLMap.prototype.add.bind(this),this.delete=ds.YAMLMap.prototype.delete.bind(this),this.get=ds.YAMLMap.prototype.get.bind(this),this.has=ds.YAMLMap.prototype.has.bind(this),this.set=ds.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(wm.isPair(s)?(i=Uc.toJS(s.key,"",n),o=Uc.toJS(s.value,i,n)):i=Uc.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=vm.createPairs(e,n,r),i=new this;return i.items=s.items,i}};cn.tag="tag:yaml.org,2002:omap";var OE={collection:"seq",identify:t=>t instanceof Map,nodeClass:cn,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let n=vm.resolvePairs(t,e),r=[];for(let{key:s}of n.items)wm.isScalar(s)&&(r.includes(s.value)?e(`Ordered maps must not include duplicate keys: ${s.value}`):r.push(s.value));return Object.assign(new cn,n)},createNode:(t,e,n)=>cn.from(t,e,n)};qc.YAMLOMap=cn;qc.omap=OE});var Am=I(Wc=>{"use strict";var Sm=re();function km({value:t,source:e},n){return e&&(t?xm:Em).test.test(e)?e:t?n.options.trueStr:n.options.falseStr}var xm={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 Sm.Scalar(!0),stringify:km},Em={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 Sm.Scalar(!1),stringify:km};Wc.falseTag=Em;Wc.trueTag=xm});var Tm=I(bo=>{"use strict";var PE=re(),Kc=Vn(),_E={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Kc.stringifyNumber},RE={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():Kc.stringifyNumber(t)}},IE={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 PE.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:Kc.stringifyNumber};bo.float=IE;bo.floatExp=RE;bo.floatNaN=_E});var Om=I(ps=>{"use strict";var Cm=Vn(),fs=t=>typeof t=="bigint"||Number.isInteger(t);function wo(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 Hc(t,e,n){let{value:r}=t;if(fs(r)){let s=r.toString(e);return r<0?"-"+n+s.substr(1):n+s}return Cm.stringifyNumber(t)}var $E={identify:fs,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,n)=>wo(t,2,2,n),stringify:t=>Hc(t,2,"0b")},NE={identify:fs,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,n)=>wo(t,1,8,n),stringify:t=>Hc(t,8,"0")},LE={identify:fs,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,n)=>wo(t,0,10,n),stringify:Cm.stringifyNumber},ME={identify:fs,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,n)=>wo(t,2,16,n),stringify:t=>Hc(t,16,"0x")};ps.int=LE;ps.intBin=$E;ps.intHex=ME;ps.intOct=NE});var Yc=I(zc=>{"use strict";var ko=W(),vo=Lt(),So=Dt(),un=class t extends So.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let n;ko.isPair(e)?n=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?n=new vo.Pair(e.key,null):n=new vo.Pair(e,null),So.findPair(this.items,n.key)||this.items.push(n)}get(e,n){let r=So.findPair(this.items,e);return!n&&ko.isPair(r)?ko.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=So.findPair(this.items,e);r&&!n?this.items.splice(this.items.indexOf(r),1):!r&&n&&this.items.push(new vo.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(vo.createPair(o,null,r));return i}};un.tag="tag:yaml.org,2002:set";var DE={collection:"map",identify:t=>t instanceof Set,nodeClass:un,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,n)=>un.from(t,e,n),resolve(t,e){if(ko.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new un,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};zc.YAMLSet=un;zc.set=DE});var Gc=I(xo=>{"use strict";var BE=Vn();function Vc(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 Pm(t){let{value:e}=t,n=o=>o;if(typeof e=="bigint")n=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return BE.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 jE={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})=>Vc(t,n),stringify:Pm},FE={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=>Vc(t,!1),stringify:Pm},_m={identify:t=>t instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(t){let e=t.match(_m.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,n,r,s,i,o,a]=e.map(Number),l=e[7]?Number((e[7]+"00").substr(1,3)):0,c=Date.UTC(n,r-1,s,i||0,o||0,a||0,l),f=e[8];if(f&&f!=="Z"){let d=Vc(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$/,"")??""};xo.floatTime=FE;xo.intTime=jE;xo.timestamp=_m});var $m=I(Im=>{"use strict";var UE=zn(),qE=co(),JE=Yn(),WE=cs(),KE=jc(),Rm=Am(),Xc=Tm(),Eo=Om(),HE=to(),zE=Jc(),YE=yo(),VE=Yc(),Qc=Gc(),GE=[UE.map,JE.seq,WE.string,qE.nullTag,Rm.trueTag,Rm.falseTag,Eo.intBin,Eo.intOct,Eo.int,Eo.intHex,Xc.floatNaN,Xc.floatExp,Xc.float,KE.binary,HE.merge,zE.omap,YE.pairs,VE.set,Qc.intTime,Qc.floatTime,Qc.timestamp];Im.schema=GE});var Jm=I(tu=>{"use strict";var Dm=zn(),XE=co(),Bm=Yn(),QE=cs(),ZE=Rc(),Zc=$c(),eu=Lc(),eA=fm(),tA=mm(),jm=jc(),hs=to(),Fm=Jc(),Um=yo(),Nm=$m(),qm=Yc(),Ao=Gc(),Lm=new Map([["core",eA.schema],["failsafe",[Dm.map,Bm.seq,QE.string]],["json",tA.schema],["yaml11",Nm.schema],["yaml-1.1",Nm.schema]]),Mm={binary:jm.binary,bool:ZE.boolTag,float:Zc.float,floatExp:Zc.floatExp,floatNaN:Zc.floatNaN,floatTime:Ao.floatTime,int:eu.int,intHex:eu.intHex,intOct:eu.intOct,intTime:Ao.intTime,map:Dm.map,merge:hs.merge,null:XE.nullTag,omap:Fm.omap,pairs:Um.pairs,seq:Bm.seq,set:qm.set,timestamp:Ao.timestamp},nA={"tag:yaml.org,2002:binary":jm.binary,"tag:yaml.org,2002:merge":hs.merge,"tag:yaml.org,2002:omap":Fm.omap,"tag:yaml.org,2002:pairs":Um.pairs,"tag:yaml.org,2002:set":qm.set,"tag:yaml.org,2002:timestamp":Ao.timestamp};function rA(t,e,n){let r=Lm.get(e);if(r&&!t)return n&&!r.includes(hs.merge)?r.concat(hs.merge):r.slice();let s=r;if(!s)if(Array.isArray(t))s=[];else{let i=Array.from(Lm.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(hs.merge)),s.reduce((i,o)=>{let a=typeof o=="string"?Mm[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(Mm).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},[])}tu.coreKnownTags=nA;tu.getTags=rA});var su=I(Wm=>{"use strict";var nu=W(),sA=zn(),iA=Yn(),oA=cs(),To=Jm(),aA=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,ru=class t{constructor({compat:e,customTags:n,merge:r,resolveKnownTags:s,schema:i,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(e)?To.getTags(e,"compat"):e?To.getTags(null,e):null,this.name=typeof i=="string"&&i||"core",this.knownTags=s?To.coreKnownTags:{},this.tags=To.getTags(n,this.name,r),this.toStringOptions=a??null,Object.defineProperty(this,nu.MAP,{value:sA.map}),Object.defineProperty(this,nu.SCALAR,{value:oA.string}),Object.defineProperty(this,nu.SEQ,{value:iA.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?aA:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};Wm.Schema=ru});var Hm=I(Km=>{"use strict";var lA=W(),iu=is(),ms=ts();function cA(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=iu.createStringifyContext(t,e),{commentString:i}=s.options;if(t.commentBefore){n.length!==1&&n.unshift("");let l=i(t.commentBefore);n.unshift(ms.indentComment(l,""))}let o=!1,a=null;if(t.contents){if(lA.isNode(t.contents)){if(t.contents.spaceBefore&&r&&n.push(""),t.contents.commentBefore){let f=i(t.contents.commentBefore);n.push(ms.indentComment(f,""))}s.forceBlockIndent=!!t.comment,a=t.contents.comment}let l=a?void 0:()=>o=!0,c=iu.stringify(t.contents,s,()=>a=null,l);a&&(c+=ms.lineComment(c,"",i(a))),(c[0]==="|"||c[0]===">")&&n[n.length-1]==="---"?n[n.length-1]=`--- ${c}`:n.push(c)}else n.push(iu.stringify(t.contents,s));if(t.directives?.docEnd)if(t.comment){let l=i(t.comment);l.includes(`
|
|
78
78
|
`)?(n.push("..."),n.push(ms.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(ms.indentComment(i(l),"")))}return n.join(`
|
|
79
79
|
`)+`
|
|
80
|
-
`}Km.stringifyDocument=
|
|
80
|
+
`}Km.stringifyDocument=cA});var gs=I(zm=>{"use strict";var uA=Zr(),Gn=Hi(),De=W(),dA=Lt(),fA=Rt(),pA=su(),hA=Hm(),ou=qi(),mA=uc(),gA=es(),au=cc(),lu=class t{constructor(e,n,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,De.NODE_TYPE,{value:De.DOC});let s=null;typeof n=="function"||Array.isArray(n)?s=n:r===void 0&&n&&(r=n,n=void 0);let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},r);this.options=i;let{version:o}=i;r?._directives?(this.directives=r._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new au.Directives({version:o}),this.setSchema(o,r),this.contents=e===void 0?null:this.createNode(e,s,r)}clone(){let e=Object.create(t.prototype,{[De.NODE_TYPE]:{value:De.DOC}});return e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives&&(e.directives=this.directives.clone()),e.schema=this.schema.clone(),e.contents=De.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){Xn(this.contents)&&this.contents.add(e)}addIn(e,n){Xn(this.contents)&&this.contents.addIn(e,n)}createAlias(e,n){if(!e.anchor){let r=ou.anchorNames(this);e.anchor=!n||r.has(n)?ou.findNewAnchor(n||"a",r):n}return new uA.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=E=>typeof E=="number"||E instanceof String||E 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:f}=r??{},{onAnchor:d,setAnchors:u,sourceObjects:p}=ou.createNodeAnchors(this,o||"a"),h={aliasDuplicateObjects:i??!0,keepUndefined:l??!1,onAnchor:d,onTagObj:c,replacer:s,schema:this.schema,sourceObjects:p},m=gA.createNode(e,f,h);return a&&De.isCollection(m)&&(m.flow=!0),u(),m}createPair(e,n,r={}){let s=this.createNode(e,null,r),i=this.createNode(n,null,r);return new dA.Pair(s,i)}delete(e){return Xn(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Gn.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):Xn(this.contents)?this.contents.deleteIn(e):!1}get(e,n){return De.isCollection(this.contents)?this.contents.get(e,n):void 0}getIn(e,n){return Gn.isEmptyPath(e)?!n&&De.isScalar(this.contents)?this.contents.value:this.contents:De.isCollection(this.contents)?this.contents.getIn(e,n):void 0}has(e){return De.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return Gn.isEmptyPath(e)?this.contents!==void 0:De.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,n){this.contents==null?this.contents=Gn.collectionFromPath(this.schema,[e],n):Xn(this.contents)&&this.contents.set(e,n)}setIn(e,n){Gn.isEmptyPath(e)?this.contents=n:this.contents==null?this.contents=Gn.collectionFromPath(this.schema,Array.from(e),n):Xn(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 au.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 au.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 pA.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=fA.toJS(this.contents,n??"",a);if(typeof i=="function")for(let{count:c,res:f}of a.anchors.values())i(f,c);return typeof o=="function"?mA.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 hA.stringifyDocument(this,e)}};function Xn(t){if(De.isCollection(t))return!0;throw new Error("Expected a YAML collection as document contents")}zm.Document=lu});var ws=I(bs=>{"use strict";var ys=class extends Error{constructor(e,n,r,s){super(),this.name=e,this.code=r,this.message=s,this.pos=n}},cu=class extends ys{constructor(e,n,r){super("YAMLParseError",e,n,r)}},uu=class extends ys{constructor(e,n,r){super("YAMLWarning",e,n,r)}},yA=(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
|
-
`}};bs.YAMLError=ys;bs.YAMLParseError=
|
|
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
|
-
`+m.comment:a.comment=m.comment);continue}(m.newlineAfterProp||
|
|
88
|
-
`+P.comment:E.comment=P.comment);let A=new Zm.Pair(E);n.options.keepSourceTokens&&(A.srcToken=f),a.items.push(A)}}return c&&c<l&&s(c,"IMPOSSIBLE","Map comment with trailing content"),a.range=[r.offset,l,c??l],a}rg.resolveBlockMap=
|
|
89
|
-
`+O.comment:c.comment=O.comment),d=O.end;continue}!o&&n.options.strict&&
|
|
90
|
-
`+_:k.comment=_,O.comment=O.comment.substring(_.length+1)}}if(!o&&!A&&!O.found){let _=$?t(n,$,O,s):e(n,O.end,A,null,O,s);c.items.push(_),d=_.range[2],
|
|
91
|
-
`+N.comment:k.comment=N.comment);let Z=new
|
|
92
|
-
`+g.comment:c.comment=g.comment),c.range=[r.offset,m,g.offset]}else c.range=[r.offset,m,m];return c}ug.resolveFlowCollection=
|
|
85
|
+
`}};bs.YAMLError=ys;bs.YAMLParseError=cu;bs.YAMLWarning=uu;bs.prettifyError=yA});var vs=I(Ym=>{"use strict";function bA(t,{flow:e,indicator:n,next:r,offset:s,onError:i,parentIndent:o,startOnNewline:a}){let l=!1,c=a,f=a,d="",u="",p=!1,h=!1,m=null,g=null,v=null,E=null,P=null,A=null,$=null;for(let k of t)switch(h&&(k.type!=="space"&&k.type!=="newline"&&k.type!=="comma"&&i(k.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),h=!1),m&&(c&&k.type!=="comment"&&k.type!=="newline"&&i(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),m=null),k.type){case"space":!e&&(n!=="doc-start"||r?.type!=="flow-collection")&&k.source.includes(" ")&&(m=k),f=!0;break;case"comment":{f||i(k,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let N=k.source.substring(1)||" ";d?d+=u+N:d=N,u="",c=!1;break}case"newline":c?d?d+=k.source:(!A||n!=="seq-item-ind")&&(l=!0):u+=k.source,c=!0,p=!0,(g||v)&&(E=k),f=!0;break;case"anchor":g&&i(k,"MULTIPLE_ANCHORS","A node can have at most one anchor"),k.source.endsWith(":")&&i(k.offset+k.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),g=k,$??($=k.offset),c=!1,f=!1,h=!0;break;case"tag":{v&&i(k,"MULTIPLE_TAGS","A node can have at most one tag"),v=k,$??($=k.offset),c=!1,f=!1,h=!0;break}case n:(g||v)&&i(k,"BAD_PROP_ORDER",`Anchors and tags must be after the ${k.source} indicator`),A&&i(k,"UNEXPECTED_TOKEN",`Unexpected ${k.source} in ${e??"collection"}`),A=k,c=n==="seq-item-ind"||n==="explicit-key-ind",f=!1;break;case"comma":if(e){P&&i(k,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),P=k,c=!1,f=!1;break}default:i(k,"UNEXPECTED_TOKEN",`Unexpected ${k.type} token`),c=!1,f=!1}let O=t[t.length-1],_=O?O.offset+O.source.length:s;return h&&r&&r.type!=="space"&&r.type!=="newline"&&r.type!=="comma"&&(r.type!=="scalar"||r.source!=="")&&i(r.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m&&(c&&m.indent<=o||r?.type==="block-map"||r?.type==="block-seq")&&i(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:P,found:A,spaceBefore:l,comment:d,hasNewline:p,anchor:g,tag:v,newlineAfterProp:E,end:_,start:$??_}}Ym.resolveProps=bA});var Co=I(Vm=>{"use strict";function du(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(du(e.key)||du(e.value))return!0}return!1;default:return!0}}Vm.containsNewline=du});var fu=I(Gm=>{"use strict";var wA=Co();function vA(t,e,n){if(e?.type==="flow-collection"){let r=e.end[0];r.indent===t&&(r.source==="]"||r.source==="}")&&wA.containsNewline(e)&&n(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}Gm.flowIndentCheck=vA});var pu=I(Qm=>{"use strict";var Xm=W();function SA(t,e,n){let{uniqueKeys:r}=t.options;if(r===!1)return!1;let s=typeof r=="function"?r:(i,o)=>i===o||Xm.isScalar(i)&&Xm.isScalar(o)&&i.value===o.value;return e.some(i=>s(i.key,n))}Qm.mapIncludes=SA});var sg=I(rg=>{"use strict";var Zm=Lt(),kA=Dt(),eg=vs(),xA=Co(),tg=fu(),EA=pu(),ng="All mapping items must start at the same column";function AA({composeNode:t,composeEmptyNode:e},n,r,s,i){let o=i?.nodeClass??kA.YAMLMap,a=new o(n.schema);n.atRoot&&(n.atRoot=!1);let l=r.offset,c=null;for(let f of r.items){let{start:d,key:u,sep:p,value:h}=f,m=eg.resolveProps(d,{indicator:"explicit-key-ind",next:u??p?.[0],offset:l,onError:s,parentIndent:r.indent,startOnNewline:!0}),g=!m.found;if(g){if(u&&(u.type==="block-seq"?s(l,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in u&&u.indent!==r.indent&&s(l,"BAD_INDENT",ng)),!m.anchor&&!m.tag&&!p){c=m.end,m.comment&&(a.comment?a.comment+=`
|
|
87
|
+
`+m.comment:a.comment=m.comment);continue}(m.newlineAfterProp||xA.containsNewline(u))&&s(u??d[d.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else m.found?.indent!==r.indent&&s(l,"BAD_INDENT",ng);n.atKey=!0;let v=m.end,E=u?t(n,u,m,s):e(n,v,d,null,m,s);n.schema.compat&&tg.flowIndentCheck(r.indent,u,s),n.atKey=!1,EA.mapIncludes(n,a.items,E)&&s(v,"DUPLICATE_KEY","Map keys must be unique");let P=eg.resolveProps(p??[],{indicator:"map-value-ind",next:h,offset:E.range[2],onError:s,parentIndent:r.indent,startOnNewline:!u||u.type==="block-scalar"});if(l=P.end,P.found){g&&(h?.type==="block-map"&&!P.hasNewline&&s(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),n.options.strict&&m.start<P.found.offset-1024&&s(E.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let A=h?t(n,h,P,s):e(n,l,p,null,P,s);n.schema.compat&&tg.flowIndentCheck(r.indent,h,s),l=A.range[2];let $=new Zm.Pair(E,A);n.options.keepSourceTokens&&($.srcToken=f),a.items.push($)}else{g&&s(E.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),P.comment&&(E.comment?E.comment+=`
|
|
88
|
+
`+P.comment:E.comment=P.comment);let A=new Zm.Pair(E);n.options.keepSourceTokens&&(A.srcToken=f),a.items.push(A)}}return c&&c<l&&s(c,"IMPOSSIBLE","Map comment with trailing content"),a.range=[r.offset,l,c??l],a}rg.resolveBlockMap=AA});var og=I(ig=>{"use strict";var TA=Bt(),CA=vs(),OA=fu();function PA({composeNode:t,composeEmptyNode:e},n,r,s,i){let o=i?.nodeClass??TA.YAMLSeq,a=new o(n.schema);n.atRoot&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let l=r.offset,c=null;for(let{start:f,value:d}of r.items){let u=CA.resolveProps(f,{indicator:"seq-item-ind",next:d,offset:l,onError:s,parentIndent:r.indent,startOnNewline:!0});if(!u.found)if(u.anchor||u.tag||d)d?.type==="block-seq"?s(u.end,"BAD_INDENT","All sequence items must start at the same column"):s(l,"MISSING_CHAR","Sequence item without - indicator");else{c=u.end,u.comment&&(a.comment=u.comment);continue}let p=d?t(n,d,u,s):e(n,u.end,f,null,u,s);n.schema.compat&&OA.flowIndentCheck(r.indent,d,s),l=p.range[2],a.items.push(p)}return a.range=[r.offset,l,c??l],a}ig.resolveBlockSeq=PA});var Qn=I(ag=>{"use strict";function _A(t,e,n,r){let s="";if(t){let i=!1,o="";for(let a of t){let{source:l,type:c}=a;switch(c){case"space":i=!0;break;case"comment":{n&&!i&&r(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let f=l.substring(1)||" ";s?s+=o+f:s=f,o="";break}case"newline":s&&(o+=l),i=!0;break;default:r(a,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}e+=l.length}}return{comment:s,offset:e}}ag.resolveEnd=_A});var dg=I(ug=>{"use strict";var RA=W(),IA=Lt(),lg=Dt(),$A=Bt(),NA=Qn(),cg=vs(),LA=Co(),MA=pu(),hu="Block collections are not allowed within flow collections",mu=t=>t&&(t.type==="block-map"||t.type==="block-seq");function DA({composeNode:t,composeEmptyNode:e},n,r,s,i){let o=r.start.source==="{",a=o?"flow map":"flow sequence",l=i?.nodeClass??(o?lg.YAMLMap:$A.YAMLSeq),c=new l(n.schema);c.flow=!0;let f=n.atRoot;f&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let d=r.offset+r.start.source.length;for(let g=0;g<r.items.length;++g){let v=r.items[g],{start:E,key:P,sep:A,value:$}=v,O=cg.resolveProps(E,{flow:a,indicator:"explicit-key-ind",next:P??A?.[0],offset:d,onError:s,parentIndent:r.indent,startOnNewline:!1});if(!O.found){if(!O.anchor&&!O.tag&&!A&&!$){g===0&&O.comma?s(O.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):g<r.items.length-1&&s(O.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),O.comment&&(c.comment?c.comment+=`
|
|
89
|
+
`+O.comment:c.comment=O.comment),d=O.end;continue}!o&&n.options.strict&&LA.containsNewline(P)&&s(P,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(g===0)O.comma&&s(O.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(O.comma||s(O.start,"MISSING_CHAR",`Missing , between ${a} items`),O.comment){let _="";e:for(let k of E)switch(k.type){case"comma":case"space":break;case"comment":_=k.source.substring(1);break e;default:break e}if(_){let k=c.items[c.items.length-1];RA.isPair(k)&&(k=k.value??k.key),k.comment?k.comment+=`
|
|
90
|
+
`+_:k.comment=_,O.comment=O.comment.substring(_.length+1)}}if(!o&&!A&&!O.found){let _=$?t(n,$,O,s):e(n,O.end,A,null,O,s);c.items.push(_),d=_.range[2],mu($)&&s(_.range,"BLOCK_IN_FLOW",hu)}else{n.atKey=!0;let _=O.end,k=P?t(n,P,O,s):e(n,_,E,null,O,s);mu(P)&&s(k.range,"BLOCK_IN_FLOW",hu),n.atKey=!1;let N=cg.resolveProps(A??[],{flow:a,indicator:"map-value-ind",next:$,offset:k.range[2],onError:s,parentIndent:r.indent,startOnNewline:!1});if(N.found){if(!o&&!O.found&&n.options.strict){if(A)for(let q of A){if(q===N.found)break;if(q.type==="newline"){s(q,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}O.start<N.found.offset-1024&&s(N.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else $&&("source"in $&&$.source?.[0]===":"?s($,"MISSING_CHAR",`Missing space after : in ${a}`):s(N.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let B=$?t(n,$,N,s):N.found?e(n,N.end,A,null,N,s):null;B?mu($)&&s(B.range,"BLOCK_IN_FLOW",hu):N.comment&&(k.comment?k.comment+=`
|
|
91
|
+
`+N.comment:k.comment=N.comment);let Z=new IA.Pair(k,B);if(n.options.keepSourceTokens&&(Z.srcToken=v),o){let q=c;MA.mapIncludes(n,q.items,k)&&s(_,"DUPLICATE_KEY","Map keys must be unique"),q.items.push(Z)}else{let q=new lg.YAMLMap(n.schema);q.flow=!0,q.items.push(Z);let ie=(B??k).range;q.range=[k.range[0],ie[1],ie[2]],c.items.push(q)}d=B?B.range[2]:N.end}}let u=o?"}":"]",[p,...h]=r.end,m=d;if(p?.source===u)m=p.offset+p.source.length;else{let g=a[0].toUpperCase()+a.substring(1),v=f?`${g} must end with a ${u}`:`${g} in block collection must be sufficiently indented and end with a ${u}`;s(d,f?"MISSING_CHAR":"BAD_INDENT",v),p&&p.source.length!==1&&h.unshift(p)}if(h.length>0){let g=NA.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}ug.resolveFlowCollection=DA});var pg=I(fg=>{"use strict";var BA=W(),jA=re(),FA=Dt(),UA=Bt(),qA=sg(),JA=og(),WA=dg();function gu(t,e,n,r,s,i){let o=n.type==="block-map"?qA.resolveBlockMap(t,e,n,r,i):n.type==="block-seq"?JA.resolveBlockSeq(t,e,n,r,i):WA.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 KA(t,e,n,r,s){let i=r.tag,o=i?e.directives.tagName(i.source,u=>s(i,"TAG_RESOLVE_FAILED",u)):null;if(n.type==="block-seq"){let{anchor:u,newlineAfterProp:p}=r,h=u&&i?u.offset>i.offset?u:i:u??i;h&&(!p||p.offset<h.offset)&&s(h,"MISSING_CHAR","Missing newline after block sequence props")}let a=n.type==="block-map"?"map":n.type==="block-seq"?"seq":n.start.source==="{"?"map":"seq";if(!i||!o||o==="!"||o===FA.YAMLMap.tagName&&a==="map"||o===UA.YAMLSeq.tagName&&a==="seq")return gu(t,e,n,s,o);let l=e.schema.tags.find(u=>u.tag===o&&u.collection===a);if(!l){let u=e.schema.knownTags[o];if(u?.collection===a)e.schema.tags.push(Object.assign({},u,{default:!1})),l=u;else return u?s(i,"BAD_COLLECTION_TYPE",`${u.tag} used for ${a} collection, but expects ${u.collection??"scalar"}`,!0):s(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),gu(t,e,n,s,o)}let c=gu(t,e,n,s,o,l),f=l.resolve?.(c,u=>s(i,"TAG_RESOLVE_FAILED",u),e.options)??c,d=BA.isNode(f)?f:new jA.Scalar(f);return d.range=c.range,d.tag=o,l?.format&&(d.format=l.format),d}fg.composeCollection=KA});var bu=I(hg=>{"use strict";var yu=re();function HA(t,e,n){let r=e.offset,s=zA(e,t.options.strict,n);if(!s)return{value:"",type:null,comment:"",range:[r,r,r]};let i=s.mode===">"?yu.Scalar.BLOCK_FOLDED:yu.Scalar.BLOCK_LITERAL,o=e.source?YA(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
93
|
`.repeat(Math.max(1,o.length-1)):"",g=r+s.length;return e.source&&(g+=e.source.length),{value:m,type:i,comment:s.comment,range:[r,g,g]}}let l=e.indent+s.indent,c=e.offset+s.length,f=0;for(let m=0;m<a;++m){let[g,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),f=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="",u="",p=!1;for(let m=0;m<f;++m)d+=o[m][0].slice(l)+`
|
|
94
|
-
`;for(let m=f;m<a;++m){let[g,v]=o[m];c+=g.length+v.length+1;let E=v[v.length-1]==="\r";if(E&&(v=v.slice(0,-1)),v&&g.length<l){let A=`Block scalar lines must not be less indented than their ${s.indent?"explicit indentation indicator":"first line"}`;n(c-v.length-(E?2:1),"BAD_INDENT",A),g=""}i===
|
|
94
|
+
`;for(let m=f;m<a;++m){let[g,v]=o[m];c+=g.length+v.length+1;let E=v[v.length-1]==="\r";if(E&&(v=v.slice(0,-1)),v&&g.length<l){let A=`Block scalar lines must not be less indented than their ${s.indent?"explicit indentation indicator":"first line"}`;n(c-v.length-(E?2:1),"BAD_INDENT",A),g=""}i===yu.Scalar.BLOCK_LITERAL?(d+=u+g.slice(l)+v,u=`
|
|
95
95
|
`):g.length>l||v[0]===" "?(u===" "?u=`
|
|
96
96
|
`:!p&&u===`
|
|
97
97
|
`&&(u=`
|
|
@@ -104,73 +104,73 @@ ${c}
|
|
|
104
104
|
`+o[m][0].slice(l);d[d.length-1]!==`
|
|
105
105
|
`&&(d+=`
|
|
106
106
|
`);break;default:d+=`
|
|
107
|
-
`}let h=r+s.length+e.source.length;return{value:d,type:i,comment:s.comment,range:[r,h,h]}}function
|
|
107
|
+
`}let h=r+s.length+e.source.length;return{value:d,type:i,comment:s.comment,range:[r,h,h]}}function zA({offset:t,props:e},n,r){if(e[0].type!=="block-scalar-header")return r(e[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:s}=e[0],i=s[0],o=0,a="",l=-1;for(let u=1;u<s.length;++u){let p=s[u];if(!a&&(p==="-"||p==="+"))a=p;else{let h=Number(p);!o&&h?o=h:l===-1&&(l=t+u)}}l!==-1&&r(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${s}`);let c=!1,f="",d=s.length;for(let u=1;u<e.length;++u){let p=e[u];switch(p.type){case"space":c=!0;case"newline":d+=p.source.length;break;case"comment":n&&!c&&r(p,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),d+=p.source.length,f=p.source.substring(1);break;case"error":r(p,"UNEXPECTED_TOKEN",p.message),d+=p.source.length;break;default:{let h=`Unexpected token in block scalar header: ${p.type}`;r(p,"UNEXPECTED_TOKEN",h);let m=p.source;m&&typeof m=="string"&&(d+=m.length)}}}return{mode:i,indent:o,chomp:a,comment:f,length:d}}function YA(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}hg.resolveBlockScalar=HA});var vu=I(gg=>{"use strict";var wu=re(),VA=Qn();function GA(t,e,n){let{offset:r,type:s,source:i,end:o}=t,a,l,c=(u,p,h)=>n(r+u,p,h);switch(s){case"scalar":a=wu.Scalar.PLAIN,l=XA(i,c);break;case"single-quoted-scalar":a=wu.Scalar.QUOTE_SINGLE,l=QA(i,c);break;case"double-quoted-scalar":a=wu.Scalar.QUOTE_DOUBLE,l=ZA(i,c);break;default:return n(t,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${s}`),{value:"",type:null,comment:"",range:[r,r+i.length,r+i.length]}}let f=r+i.length,d=VA.resolveEnd(o,f,e,n);return{value:l,type:a,comment:d.comment,range:[r,f,d.offset]}}function XA(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}`),mg(t)}function QA(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),mg(t.slice(1,-1)).replace(/''/g,"'")}function mg(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 ZA(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}=eT(t,r);n+=i,r=o}else if(s==="\\"){let i=t[++r],o=tT[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+=nT(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 eT(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 tT={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 nT(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)}gg.resolveFlowScalar=GA});var wg=I(bg=>{"use strict";var dn=W(),yg=re(),rT=bu(),sT=vu();function iT(t,e,n,r){let{value:s,type:i,comment:o,range:a}=e.type==="block-scalar"?rT.resolveBlockScalar(t,e,r):sT.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[dn.SCALAR]:l?c=oT(t.schema,s,l,n,r):e.type==="scalar"?c=aT(t,s,e,r):c=t.schema[dn.SCALAR];let f;try{let d=c.resolve(s,u=>r(n??e,"TAG_RESOLVE_FAILED",u),t.options);f=dn.isScalar(d)?d:new yg.Scalar(d)}catch(d){let u=d instanceof Error?d.message:String(d);r(n??e,"TAG_RESOLVE_FAILED",u),f=new yg.Scalar(s)}return f.range=a,f.source=s,i&&(f.type=i),l&&(f.tag=l),c.format&&(f.format=c.format),o&&(f.comment=o),f}function oT(t,e,n,r,s){if(n==="!")return t[dn.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[dn.SCALAR])}function aT({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[dn.SCALAR];if(n.compat){let a=n.compat.find(l=>l.default&&l.test?.test(r))??n[dn.SCALAR];if(o.tag!==a.tag){let l=e.tagString(o.tag),c=e.tagString(a.tag),f=`Value may be parsed as either ${l} or ${c}`;i(s,"TAG_RESOLVE_FAILED",f,!0)}}return o}bg.composeScalar=iT});var Sg=I(vg=>{"use strict";function lT(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}vg.emptyScalarPosition=lT});var Eg=I(ku=>{"use strict";var cT=Zr(),uT=W(),dT=pg(),kg=wg(),fT=Qn(),pT=Sg(),hT={composeNode:xg,composeEmptyNode:Su};function xg(t,e,n,r){let s=t.atKey,{spaceBefore:i,comment:o,anchor:a,tag:l}=n,c,f=!0;switch(e.type){case"alias":c=mT(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=kg.composeScalar(t,e,l,r),a&&(c.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":c=dT.composeCollection(hT,t,e,n,r),a&&(c.anchor=a.source.substring(1));break;default:{let d=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;r(e,"UNEXPECTED_TOKEN",d),c=Su(t,e.offset,void 0,null,n,r),f=!1}}return a&&c.anchor===""&&r(a,"BAD_ALIAS","Anchor cannot be an empty string"),s&&t.options.stringKeys&&(!uT.isScalar(c)||typeof c.value!="string"||c.tag&&c.tag!=="tag:yaml.org,2002:str")&&r(l??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),i&&(c.spaceBefore=!0),o&&(e.type==="scalar"&&e.source===""?c.comment=o:c.commentBefore=o),t.options.keepSourceTokens&&f&&(c.srcToken=e),c}function Su(t,e,n,r,{spaceBefore:s,comment:i,anchor:o,tag:a,end:l},c){let f={type:"scalar",offset:pT.emptyScalarPosition(e,n,r),indent:-1,source:""},d=kg.composeScalar(t,f,a,c);return o&&(d.anchor=o.source.substring(1),d.anchor===""&&c(o,"BAD_ALIAS","Anchor cannot be an empty string")),s&&(d.spaceBefore=!0),i&&(d.comment=i,d.range[2]=l),d}function mT({options:t},{offset:e,source:n,end:r},s){let i=new cT.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=fT.resolveEnd(r,o,t.strict,s);return i.range=[e,o,a.offset],a.comment&&(i.comment=a.comment),i}ku.composeEmptyNode=Su;ku.composeNode=xg});var Cg=I(Tg=>{"use strict";var gT=gs(),Ag=Eg(),yT=Qn(),bT=vs();function wT(t,e,{offset:n,start:r,value:s,end:i},o){let a=Object.assign({_directives:e},t),l=new gT.Document(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},f=bT.resolveProps(r,{indicator:"doc-start",next:s??i?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});f.found&&(l.directives.docStart=!0,s&&(s.type==="block-map"||s.type==="block-seq")&&!f.hasNewline&&o(f.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),l.contents=s?Ag.composeNode(c,s,f,o):Ag.composeEmptyNode(c,f.end,r,null,f,o);let d=l.contents.range[2],u=yT.resolveEnd(i,d,!1,o);return u.comment&&(l.comment=u.comment),l.range=[n,d,u.offset],l}Tg.composeDoc=wT});var Eu=I(_g=>{"use strict";var vT=_i("process"),ST=cc(),kT=gs(),Ss=ws(),Og=W(),xT=Cg(),ET=Qn();function ks(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 Pg(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
|
|
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 xu=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(n,r,s,i)=>{let o=ks(n);i?this.warnings.push(new Ss.YAMLWarning(o,r,s)):this.errors.push(new Ss.YAMLParseError(o,r,s))},this.directives=new ST.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,n){let{comment:r,afterEmptyLine:s}=Pg(this.prelude);if(r){let i=e.contents;if(n)e.comment=e.comment?`${e.comment}
|
|
126
126
|
${r}`:r;else if(s||e.directives.docStart||!i)e.commentBefore=r;else if(Og.isCollection(i)&&!i.flow&&i.items.length>0){let o=i.items[0];Og.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:Pg(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(
|
|
129
|
-
${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.push(new Ss.YAMLParseError(ks(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
|
|
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:Pg(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(vT.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(n,r,s)=>{let i=ks(e);i[0]+=n,this.onError(i,"BAD_DIRECTIVE",r,s)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let n=xT.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 Ss.YAMLParseError(ks(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 Ss.YAMLParseError(ks(e),"UNEXPECTED_TOKEN",r));break}this.doc.directives.docEnd=!0;let n=ET.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 Ss.YAMLParseError(ks(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 kT.Document(void 0,r);this.atDirectives&&this.onError(n,"MISSING_CHAR","Missing directives-end indicator line"),s.range=[0,n,n],this.decorate(s,!1),yield s}}};_g.Composer=xu});var $g=I(Oo=>{"use strict";var AT=bu(),TT=vu(),CT=ws(),Rg=ss();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 CT.YAMLParseError([a,a+1],i,o)};switch(t.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return TT.resolveFlowScalar(t,e,r);case"block-scalar":return AT.resolveBlockScalar({options:{strict:e}},t,r)}}return null}function PT(t,e){let{implicitKey:n=!1,indent:r,inFlow:s=!1,offset:i=-1,type:o="PLAIN"}=e,a=Rg.stringifyString({type:o,value:t},{implicitKey:n,indent:r>0?" ".repeat(r):"",inFlow:s,options:{blockQuote:!0,lineWidth:-1}}),l=e.end??[{type:"newline",offset:-1,indent:r,source:`
|
|
130
130
|
`}];switch(a[0]){case"|":case">":{let c=a.indexOf(`
|
|
131
131
|
`),f=a.substring(0,c),d=a.substring(c+1)+`
|
|
132
132
|
`,u=[{type:"block-scalar-header",offset:i,indent:r,source:f}];return Ig(u,l)||u.push({type:"newline",offset:-1,indent:r,source:`
|
|
133
|
-
`}),{type:"block-scalar",offset:i,indent:r,props:u,source:d}}case'"':return{type:"double-quoted-scalar",offset:i,indent:r,source:a,end:l};case"'":return{type:"single-quoted-scalar",offset:i,indent:r,source:a,end:l};default:return{type:"scalar",offset:i,indent:r,source:a,end:l}}}function
|
|
133
|
+
`}),{type:"block-scalar",offset:i,indent:r,props:u,source:d}}case'"':return{type:"double-quoted-scalar",offset:i,indent:r,source:a,end:l};case"'":return{type:"single-quoted-scalar",offset:i,indent:r,source:a,end:l};default:return{type:"scalar",offset:i,indent:r,source:a,end:l}}}function _T(t,e,n={}){let{afterKey:r=!1,implicitKey:s=!1,inFlow:i=!1,type:o}=n,a="indent"in t?t.indent:null;if(r&&typeof a=="number"&&(a+=2),!o)switch(t.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let c=t.props[0];if(c.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o=c.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let l=Rg.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">":RT(t,l);break;case'"':Au(t,l,"double-quoted-scalar");break;case"'":Au(t,l,"single-quoted-scalar");break;default:Au(t,l,"scalar")}}function RT(t,e){let n=e.indexOf(`
|
|
134
134
|
`),r=e.substring(0,n),s=e.substring(n+1)+`
|
|
135
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}];Ig(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 Ig(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
|
|
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})}}}
|
|
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 Ig(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 Au(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})}}}Oo.createScalarToken=PT;Oo.resolveAsScalar=OT;Oo.setScalarValue=_T});var Lg=I(Ng=>{"use strict";var IT=t=>"type"in t?_o(t):Po(t);function _o(t){switch(t.type){case"block-scalar":{let e="";for(let n of t.props)e+=_o(n);return e+t.source}case"block-map":case"block-seq":{let e="";for(let n of t.items)e+=Po(n);return e}case"flow-collection":{let e=t.start.source;for(let n of t.items)e+=Po(n);for(let n of t.end)e+=n.source;return e}case"document":{let e=Po(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 Po({start:t,key:e,sep:n,value:r}){let s="";for(let i of t)s+=i.source;if(e&&(s+=_o(e)),n)for(let i of n)s+=i.source;return r&&(s+=_o(r)),s}Ng.stringify=IT});var jg=I(Bg=>{"use strict";var Tu=Symbol("break visit"),$T=Symbol("skip children"),Mg=Symbol("remove item");function fn(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),Dg(Object.freeze([]),t,e)}fn.BREAK=Tu;fn.SKIP=$T;fn.REMOVE=Mg;fn.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};fn.parentCollection=(t,e)=>{let n=fn.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 Dg(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=Dg(Object.freeze(t.concat([[s,o]])),i.items[o],n);if(typeof a=="number")o=a-1;else{if(a===Tu)return Tu;a===Mg&&(i.items.splice(o,1),o-=1)}}typeof r=="function"&&s==="key"&&(r=r(e,t))}}return typeof r=="function"?r(e,t):r}Bg.visit=fn});var Ro=I(Te=>{"use strict";var Cu=$g(),NT=Lg(),LT=jg(),Ou="\uFEFF",Pu="",_u="",Ru="",MT=t=>!!t&&"items"in t,DT=t=>!!t&&(t.type==="scalar"||t.type==="single-quoted-scalar"||t.type==="double-quoted-scalar"||t.type==="block-scalar");function BT(t){switch(t){case Ou:return"<BOM>";case Pu:return"<DOC>";case _u:return"<FLOW_END>";case Ru:return"<SCALAR>";default:return JSON.stringify(t)}}function jT(t){switch(t){case Ou:return"byte-order-mark";case Pu:return"doc-mode";case _u:return"flow-error-end";case Ru: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}Te.createScalarToken=
|
|
140
|
-
`:case"\r":case" ":return!0;default:return!1}}var Fg=new Set("0123456789ABCDEFabcdef"),
|
|
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}Te.createScalarToken=Cu.createScalarToken;Te.resolveAsScalar=Cu.resolveAsScalar;Te.setScalarValue=Cu.setScalarValue;Te.stringify=NT.stringify;Te.visit=LT.visit;Te.BOM=Ou;Te.DOCUMENT=Pu;Te.FLOW_END=_u;Te.SCALAR=Ru;Te.isCollection=MT;Te.isScalar=DT;Te.prettyToken=BT;Te.tokenType=jT});var Nu=I(Ug=>{"use strict";var xs=Ro();function Ve(t){switch(t){case void 0:case" ":case`
|
|
140
|
+
`:case"\r":case" ":return!0;default:return!1}}var Fg=new Set("0123456789ABCDEFabcdef"),FT=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Io=new Set(",[]{}"),UT=new Set(` ,[]{}
|
|
141
|
+
\r `),Iu=t=>!t||UT.has(t),$u=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
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]===xs.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 xs.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(
|
|
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]===xs.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 xs.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(Iu),"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 xs.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(Iu),"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
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 xs.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&&
|
|
153
|
+
`&&i>=this.pos&&i+1+n>a)e=i;else break}while(!0);return yield xs.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&&Io.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&&Io.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&&Io.has(s))break;n=r}return!s&&!this.atEnd?this.setNext("plain-scalar"):(yield xs.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(Iu))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let e=this.flowLevel>0,n=this.charAt(1);if(Ve(n)||e&&Io.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(FT.has(n))n=this.buffer[++e];else if(n==="%"&&Fg.has(this.buffer[e+1])&&Fg.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)}};Ug.Lexer
|
|
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)}};Ug.Lexer=$u});var Mu=I(qg=>{"use strict";var Lu=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}}}};qg.LineCounter=Lu});var Bu=I(zg=>{"use strict";var qT=_i("process"),Jg=Ro(),JT=Nu();function jt(t,e){for(let n=0;n<t.length;++n)if(t[n].type===e)return!0;return!1}function Wg(t){for(let e=0;e<t.length;++e)switch(t[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function Hg(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 $o(t){switch(t.type){case"document":return t.start;case"block-map":{let e=t.items[t.items.length-1];return e.sep??e.start}case"block-seq":return t.items[t.items.length-1].start;default:return[]}}function Zn(t){if(t.length===0)return[];let e=t.length;e:for(;--e>=0;)switch(t[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;t[++e]?.type==="space";);return t.splice(e,t.length)}function Kg(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!jt(e.start,"explicit-key-ind")&&!jt(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,Hg(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 Du=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 JT.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,qT.env.LOG_TOKENS&&console.log("|",Jg.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let n=Jg.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"&&Kg(n),r.type){case"document":r.value=n;break;case"block-scalar":r.props.push(n);break;case"block-map":{let s=r.items[r.items.length-1];if(s.value){r.items.push({start:[],key:n,sep:[]}),this.onKeyLine=!0;return}else if(s.sep)s.value=n;else{Object.assign(s,{key:n,sep:[]}),this.onKeyLine=!s.explicitKey;return}break}case"block-seq":{let s=r.items[r.items.length-1];s.value?r.items.push({start:[],value:n}):s.value=n;break}case"flow-collection":{let s=r.items[r.items.length-1];!s||s.value?r.items.push({start:[],key:n,sep:[]}):s.sep?s.value=n:Object.assign(s,{key:n,sep:[]});return}default:yield*this.pop(),yield*this.pop(n)}if((r.type==="document"||r.type==="block-map"||r.type==="block-seq")&&(n.type==="block-map"||n.type==="block-seq")){let s=n.items[n.items.length-1];s&&!s.sep&&!s.value&&s.start.length>0&&Wg(s.start)===-1&&(n.indent===0||s.start.every(i=>i.type!=="comment"||i.indent<n.indent))&&(r.type==="document"?r.end=s.start:r.items.push({start:s.start}),n.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let e={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{Wg(e.start)!==-1?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){let n=$o(this.peek(2)),r=Zn(n),s;e.end?(s=e.end,s.push(this.sourceToken),delete e.end):s=[this.sourceToken];let i={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:s}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let n=this.source.indexOf(`
|
|
159
159
|
`)+1;for(;n!==0;)this.onNewLine(this.offset+n),n=this.source.indexOf(`
|
|
160
|
-
`,n)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let n=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,n.value){let r="end"in n.value?n.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)e.items.push({start:[this.sourceToken]});else if(n.sep)n.sep.push(this.sourceToken);else{if(this.atIndentedComment(n.start,e.indent)){let s=e.items[e.items.length-2]?.value?.end;if(Array.isArray(s)){Array.prototype.push.apply(s,n.start),s.push(this.sourceToken),e.items.pop();return}}n.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let r=!this.onKeyLine&&this.indent===e.indent,s=r&&(n.sep||n.explicitKey)&&this.type!=="seq-item-ind",i=[];if(s&&n.sep&&!n.value){let o=[];for(let a=0;a<n.sep.length;++a){let l=n.sep[a];switch(l.type){case"newline":o.push(a);break;case"space":break;case"comment":l.indent>e.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(i=n.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":s||n.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"explicit-key-ind":!n.sep&&!n.explicitKey?(n.start.push(this.sourceToken),n.explicitKey=!0):s||n.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(n.explicitKey)if(n.sep)if(n.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(
|
|
160
|
+
`,n)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let n=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,n.value){let r="end"in n.value?n.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)e.items.push({start:[this.sourceToken]});else if(n.sep)n.sep.push(this.sourceToken);else{if(this.atIndentedComment(n.start,e.indent)){let s=e.items[e.items.length-2]?.value?.end;if(Array.isArray(s)){Array.prototype.push.apply(s,n.start),s.push(this.sourceToken),e.items.pop();return}}n.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let r=!this.onKeyLine&&this.indent===e.indent,s=r&&(n.sep||n.explicitKey)&&this.type!=="seq-item-ind",i=[];if(s&&n.sep&&!n.value){let o=[];for(let a=0;a<n.sep.length;++a){let l=n.sep[a];switch(l.type){case"newline":o.push(a);break;case"space":break;case"comment":l.indent>e.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(i=n.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":s||n.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"explicit-key-ind":!n.sep&&!n.explicitKey?(n.start.push(this.sourceToken),n.explicitKey=!0):s||n.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(n.explicitKey)if(n.sep)if(n.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(jt(n.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(Hg(n.key)&&!jt(n.sep,"newline")){let o=Zn(n.start),a=n.key,l=n.sep;l.push(this.sourceToken),delete n.key,delete n.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:a,sep:l}]})}else i.length>0?n.sep=n.sep.concat(i,this.sourceToken):n.sep.push(this.sourceToken);else if(jt(n.start,"newline"))Object.assign(n,{key:null,sep:[this.sourceToken]});else{let o=Zn(n.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else n.sep?n.value||s?e.items.push({start:i,key:null,sep:[this.sourceToken]}):jt(n.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):n.sep.push(this.sourceToken):Object.assign(n,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let o=this.flowScalar(this.type);s||n.value?(e.items.push({start:i,key:o,sep:[]}),this.onKeyLine=!0):n.sep?this.stack.push(o):(Object.assign(n,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{let o=this.startBlockValue(e);if(o){if(o.type==="block-seq"){if(!n.explicitKey&&n.sep&&!jt(n.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else r&&e.items.push({start:i});this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let n=e.items[e.items.length-1];switch(this.type){case"newline":if(n.value){let r="end"in n.value?n.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(n.start,e.indent)){let s=e.items[e.items.length-2]?.value?.end;if(Array.isArray(s)){Array.prototype.push.apply(s,n.start),s.push(this.sourceToken),e.items.pop();return}}n.start.push(this.sourceToken)}return;case"anchor":case"tag":if(n.value||this.indent<=e.indent)break;n.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;n.value||jt(n.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return}if(this.indent>e.indent){let r=this.startBlockValue(e);if(r){this.stack.push(r);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let n=e.items[e.items.length-1];if(this.type==="flow-error-end"){let r;do yield*this.pop(),r=this.peek(1);while(r?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!n||n.sep?e.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return;case"map-value-ind":!n||n.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):n.sep?n.sep.push(this.sourceToken):Object.assign(n,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!n||n.value?e.items.push({start:[this.sourceToken]}):n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let s=this.flowScalar(this.type);!n||n.value?e.items.push({start:[],key:s,sep:[]}):n.sep?this.stack.push(s):Object.assign(n,{key:s,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let r=this.startBlockValue(e);r?this.stack.push(r):(yield*this.pop(),yield*this.step())}else{let r=this.peek(2);if(r.type==="block-map"&&(this.type==="map-value-ind"&&r.indent===e.indent||this.type==="newline"&&!r.items[r.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&r.type!=="flow-collection"){let s=$o(r),i=Zn(s);Kg(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
|
|
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=$o(e),r=Zn(n);return r.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let n=$o(e),r=Zn(n);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,n){return this.type!=="comment"||this.indent<=n?!1:e.every(r=>r.type==="newline"||r.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};zg.Parser=Du});var Qg=I(As=>{"use strict";var Yg=Eu(),WT=gs(),Es=ws(),KT=kc(),HT=W(),zT=Mu(),Vg=Bu();function Gg(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new zT.LineCounter||null,prettyErrors:e}}function YT(t,e={}){let{lineCounter:n,prettyErrors:r}=Gg(e),s=new Vg.Parser(n?.addNewLine),i=new Yg.Composer(e),o=Array.from(i.compose(s.parse(t)));if(r&&n)for(let a of o)a.errors.forEach(Es.prettifyError(t,n)),a.warnings.forEach(Es.prettifyError(t,n));return o.length>0?o:Object.assign([],{empty:!0},i.streamInfo())}function Xg(t,e={}){let{lineCounter:n,prettyErrors:r}=Gg(e),s=new Vg.Parser(n?.addNewLine),i=new Yg.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 Es.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&n&&(o.errors.forEach(Es.prettifyError(t,n)),o.warnings.forEach(Es.prettifyError(t,n))),o}function VT(t,e,n){let r;typeof e=="function"?r=e:n===void 0&&e&&typeof e=="object"&&(n=e);let s=Xg(t,n);if(!s)return null;if(s.warnings.forEach(i=>KT.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 GT(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 HT.isDocument(t)&&!r?t.toString(n):new WT.Document(t,r,n).toString(n)}As.parse=VT;As.parseAllDocuments=YT;As.parseDocument=Xg;As.stringify=GT});var ey=I(H=>{"use strict";var XT=Eu(),QT=gs(),ZT=su(),ju=ws(),eC=Zr(),Ft=W(),tC=Lt(),nC=re(),rC=Dt(),sC=Bt(),iC=Ro(),oC=Nu(),aC=Mu(),lC=Bu(),No=Qg(),Zg=Vr();H.Composer=XT.Composer;H.Document=QT.Document;H.Schema=ZT.Schema;H.YAMLError=ju.YAMLError;H.YAMLParseError=ju.YAMLParseError;H.YAMLWarning=ju.YAMLWarning;H.Alias=eC.Alias;H.isAlias=Ft.isAlias;H.isCollection=Ft.isCollection;H.isDocument=Ft.isDocument;H.isMap=Ft.isMap;H.isNode=Ft.isNode;H.isPair=Ft.isPair;H.isScalar=Ft.isScalar;H.isSeq=Ft.isSeq;H.Pair=tC.Pair;H.Scalar=nC.Scalar;H.YAMLMap=rC.YAMLMap;H.YAMLSeq=sC.YAMLSeq;H.CST=iC;H.Lexer=oC.Lexer;H.LineCounter=aC.LineCounter;H.Parser=lC.Parser;H.parse=No.parse;H.parseAllDocuments=No.parseAllDocuments;H.parseDocument=No.parseDocument;H.stringify=No.stringify;H.visit=Zg.visit;H.visitAsync=Zg.visitAsync});function uC(t){try{return JSON.parse(t.trim()),!0}catch{return!1}}function dC(t){let e=t.trim();if(!e.startsWith("<"))return!1;let n=e.match(cC);return n?Yr(e,n[1])!==null:!1}function fC(t){let e=t.trim();if(!e.match(/^(---|#|\w+:|-)/)||"[{<".includes(e[0]))return!1;try{let n=ty.parse(e);return n!==null&&typeof n=="object"}catch{return!1}}function ny(t){return uC(t)||dC(t)||fC(t)}var ty,cC,Fu=S(()=>{fh();ty=gx(ey(),1),cC=/<([a-zA-Z_][\w.-]*)/});function pC(t){if(!t?.trim())return[];let e=t.replace(/\r\n/g,`
|
|
163
163
|
`),n=e.trim();if(ny(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 Lo(t){return pC(t).map(e=>e.text)}var ry,sy=S(()=>{Fu();ry=`
|
|
167
167
|
|
|
168
168
|
|
|
169
|
-
`});function $o(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var iy=S(()=>{});var pC,hC,Fu,oy=S(()=>{pC=[["\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","-"]],hC=new Map(pC),Fu=hC});var ay,No,Uu,ly=S(()=>{ay=[["\xE6","ae"],["\xC6","Ae"],["\xF8","oe"],["\xD8","Oe"],["\xE5","aa"],["\xC5","Aa"]],No={sv:[["\xE4","a"],["\xC4","A"],["\xF6","o"],["\xD6","O"],["\xE5","a"],["\xC5","A"]],da:ay,nb:ay,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(No))No[t]=new Map(No[t]);Uu=No});function qu(t,e){if(typeof t!="string")throw new TypeError(`Expected a string, got \`${typeof t}\``);e={customReplacements:[],...e};let n=gC(e.locale),r=Fu,s=e.customReplacements.length>0||e.customReplacements.size>0;if(n||s){if(r=new Map(Fu),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=mC(t,r),t=t.normalize("NFD").replaceAll(/\p{Diacritic}/gu,"").normalize(),t=t.replaceAll(/\p{Dash_Punctuation}/gu,"-"),t}var mC,gC,cy=S(()=>{oy();ly();mC=(t,e)=>{for(let[n,r]of e)t=t.replaceAll(n,r);return t},gC=t=>{if(!t)return;let e=t.toLowerCase().replace(/^no(-|$)/,"nb$1");return Uu[e]||Uu[e.split("-")[0]]||void 0}});var yC,uy,dy=S(()=>{yC=[["&"," and "],["\u{1F984}"," unicorn "],["\u2665"," love "]],uy=yC});function Ju(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([...uy,...e.customReplacements]);t=qu(t,{customReplacements:i,locale:e.locale})}else if(e.customReplacements.length>0)for(let[i,o]of e.customReplacements)t=t.replaceAll(i,o);e.decamelize&&(t=bC(t));let s=vC(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=wC(t,e.separator)),n&&(t=`_${t}`),r&&(t=`${t}-`),t}var bC,wC,vC,fy=S(()=>{iy();cy();dy();bC=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"),wC=(t,e)=>{let n=$o(e);return t.replaceAll(new RegExp(`(?:${n}){2,}`,"g"),e).replaceAll(new RegExp(`^(?:${n})|(?:${n})$`,"g"),"")},vC=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 er(t){return Ju(t)}var py=S(()=>{fy()});var tr,hy,my=S(()=>{tr={local:"local",ide:"ide",published:"published",inline:"inline"},hy=Object.values(tr).map(t=>`'${t}'`).join(" | ")});var Ts,Wu,gy=S(()=>{Ts=` *, *::before, *::after { box-sizing: border-box; }
|
|
169
|
+
`});function Mo(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var iy=S(()=>{});var hC,mC,Uu,oy=S(()=>{hC=[["\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","-"]],mC=new Map(hC),Uu=mC});var ay,Do,qu,ly=S(()=>{ay=[["\xE6","ae"],["\xC6","Ae"],["\xF8","oe"],["\xD8","Oe"],["\xE5","aa"],["\xC5","Aa"]],Do={sv:[["\xE4","a"],["\xC4","A"],["\xF6","o"],["\xD6","O"],["\xE5","a"],["\xC5","A"]],da:ay,nb:ay,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(Do))Do[t]=new Map(Do[t]);qu=Do});function Ju(t,e){if(typeof t!="string")throw new TypeError(`Expected a string, got \`${typeof t}\``);e={customReplacements:[],...e};let n=yC(e.locale),r=Uu,s=e.customReplacements.length>0||e.customReplacements.size>0;if(n||s){if(r=new Map(Uu),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=gC(t,r),t=t.normalize("NFD").replaceAll(/\p{Diacritic}/gu,"").normalize(),t=t.replaceAll(/\p{Dash_Punctuation}/gu,"-"),t}var gC,yC,cy=S(()=>{oy();ly();gC=(t,e)=>{for(let[n,r]of e)t=t.replaceAll(n,r);return t},yC=t=>{if(!t)return;let e=t.toLowerCase().replace(/^no(-|$)/,"nb$1");return qu[e]||qu[e.split("-")[0]]||void 0}});var bC,uy,dy=S(()=>{bC=[["&"," and "],["\u{1F984}"," unicorn "],["\u2665"," love "]],uy=bC});function Wu(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([...uy,...e.customReplacements]);t=Ju(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=wC(t));let s=SC(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=vC(t,e.separator)),n&&(t=`_${t}`),r&&(t=`${t}-`),t}var wC,vC,SC,fy=S(()=>{iy();cy();dy();wC=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"),vC=(t,e)=>{let n=Mo(e);return t.replaceAll(new RegExp(`(?:${n}){2,}`,"g"),e).replaceAll(new RegExp(`^(?:${n})|(?:${n})$`,"g"),"")},SC=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+=Mo(r)}let n=t.transliterate?"g":"gu";return new RegExp(`[^${e}]+`,n)}});function er(t){return Wu(t)}var py=S(()=>{fy()});var tr,hy,my=S(()=>{tr={local:"local",ide:"ide",published:"published",inline:"inline"},hy=Object.values(tr).map(t=>`'${t}'`).join(" | ")});var Ts,Ku,gy=S(()=>{Ts=` *, *::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; }`,Ku=" html, body { height: 100%; }"});var yy,by=S(()=>{yy=`(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 };
|
|
@@ -292,51 +292,51 @@ ${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.pus
|
|
|
292
292
|
return publish();
|
|
293
293
|
}
|
|
294
294
|
};
|
|
295
|
-
})();`});var te=S(()=>{
|
|
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+ky(s):r}var
|
|
298
|
-
`);o.partial&&a.shift();let l=[];for(let u of a)if(u.trim())try{l.push(JSON.parse(u))}catch{}if(o.partial&&!l.some(u=>u.type==="user"||u.type==="assistant"))continue;let c,f;for(let u=l.length-1;u>=0&&!f;u--){let p=l[u];p?.type==="assistant"&&(c??=p,!p.isApiErrorMessage&&p.message?.usage&&(f=p))}let d=f?.message?.usage;if(s={tokens:d?(d.input_tokens??0)+(d.output_tokens??0)+(d.cache_read_input_tokens??0)+(d.cache_creation_input_tokens??0):r?.tokens,model:f?.message?.model??r?.model,effort:f?.effort??r?.effort,running:My(l),failing:!!c?.isApiErrorMessage,stopped:
|
|
299
|
-
`))if(e.includes('"modelId"'))try{let n=JSON.parse(e).attachment?.identity?.modelId;if(n)return n}catch{}}function My(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(
|
|
300
|
-
`):t==null?"":Re(JSON.stringify(t))}function Dy(t){let e=t.trim();return!!e&&
|
|
295
|
+
})();`});var te=S(()=>{$i();ec();th();ih();Fu();sy();py();my();gy();by();vy();Ni()});function ue(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 xy(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 Ey(t){return t.replace(/[/\\]+$/,"").split(/[/\\]/).pop()??""}function Ay(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 zu(t){let e=/^mcp__(.+?)__(.+)$/.exec(t);return e?`${e[1][0].toUpperCase()}${e[1].slice(1)} [${e[2]}]`:t}var ee,Cs,ky,Os=S(()=>{"use strict";ee=t=>typeof t=="string"?t:void 0,Cs=t=>t.replace(/\u001b\[[0-9;]*m/g,""),ky=t=>` (+${t} line${t===1?"":"s"})`});function Re(t){return t.length>Yu?t.slice(0,Yu)+`
|
|
296
|
+
\u2026[${t.length-Yu} more characters truncated]`:t}function Be(t){let e=Cs(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+ky(s):r}var Yu,Ce,Bo,Ps=S(()=>{"use strict";Os();Yu=5e4,Ce=(t,e,n=e+"s")=>`${t} ${t===1?e:n}`;Bo=(t,e)=>``});import{closeSync as Ty,existsSync as kC,fstatSync as xC,openSync as Cy,readdirSync as EC,readSync as Oy,statSync as AC}from"fs";import{join as TC}from"path";function nr(t,e){let n;try{n=Cy(t,"r")}catch{return}try{let r=Buffer.alloc(e),s=Oy(n,r,0,e,0);return{text:r.subarray(0,s).toString("utf8"),bytes:s}}finally{Ty(n)}}function jo(t,e){let n;try{n=Cy(t,"r")}catch{return}try{let r=xC(n).size,s=Math.min(e,r),i=Buffer.alloc(s),o=Oy(n,i,0,s,r-s);return{text:i.subarray(0,o).toString("utf8"),partial:r>s}}finally{Ty(n)}}function Fo(t){if(!kC(t))return[];let e;try{e=EC(t)}catch{return[]}let n=[];for(let r of e){if(!r.endsWith(".jsonl"))continue;let s=TC(t,r);try{let i=AC(s);i.isFile()&&n.push({sessionId:r.slice(0,-6),file:s,mtime:i.mtimeMs})}catch{}}return n}var Uo=S(()=>{"use strict"});var Ut,qo=S(()=>{"use strict";Ut=class{ensureHarnessSupport(){}forRead(){return this}linker(){return{link(){}}}}});import{openSync as CC,readSync as OC,closeSync as PC,statSync as $y,readdirSync as Ny,readFileSync as Ly,existsSync as _C}from"fs";import{join as pn}from"path";import{homedir as RC}from"os";function IC(t){return t.replace(/[^a-zA-Z0-9]/g,"-")}function NC(t,e,n){let r=pn(Vu(t,e),n,$C),s;try{s=Ny(r)}catch{return[]}let i=rO(t,n),o=[];for(let a of s){if(!a.endsWith(".jsonl"))continue;let l=pn(r,a),c;try{c=$y(l)}catch{continue}let f=a.slice(0,-6),d={};try{d=JSON.parse(Ly(pn(r,`${f}.meta.json`),"utf8"))}catch{}let u=DC(l,c.size,c.mtimeMs);o.push({id:f.startsWith("agent-")?f.slice(6):f,file:l,mtime:c.mtimeMs,started:c.birthtimeMs||void 0,tokens:u.tokens,failing:u.failing,running:!!u.running&&(i===void 0||c.mtimeMs>=i),liveSince:i,label:d.description??"",kind:d.agentType===LC?void 0:d.agentType,model:u.model?.replace(/^claude-/,"").replace(/-\d{8}$/,"")??d.model,effort:u.effort,spawnId:d.toolUseId,parentId:d.parentAgentId,depth:d.spawnDepth??1,stopped:!!d.stoppedByUser||!!u.stopped})}return o}function DC(t,e,n){let r=Py.get(t);if(r&&r.size===e&&r.mtime===n)return r;let s={};for(let i of MC){let o=jo(t,i);if(!o)break;let a=o.text.split(`
|
|
298
|
+
`);o.partial&&a.shift();let l=[];for(let u of a)if(u.trim())try{l.push(JSON.parse(u))}catch{}if(o.partial&&!l.some(u=>u.type==="user"||u.type==="assistant"))continue;let c,f;for(let u=l.length-1;u>=0&&!f;u--){let p=l[u];p?.type==="assistant"&&(c??=p,!p.isApiErrorMessage&&p.message?.usage&&(f=p))}let d=f?.message?.usage;if(s={tokens:d?(d.input_tokens??0)+(d.output_tokens??0)+(d.cache_read_input_tokens??0)+(d.cache_creation_input_tokens??0):r?.tokens,model:f?.message?.model??r?.model,effort:f?.effort??r?.effort,running:My(l),failing:!!c?.isApiErrorMessage,stopped:jC(l)},!(s.tokens===void 0&&o.partial))break}return s.model??=BC(t),Py.set(t,{size:e,mtime:n,...s}),s}function BC(t){for(let e of(nr(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 My(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(FC(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(!Xu(e)&&o.trim()&&qt(o)==="")return!1}catch{}return!0}let r=(Array.isArray(e.message?.content)?e.message.content:[]).filter(i=>i.type==="tool_use").map(i=>i.id);if(r.length===0)return!e.message?.stop_reason||e.message.stop_reason==="tool_use";let s=new Set;for(let i of t){let o=i.message?.content;if(Array.isArray(o))for(let a of o)a.type==="tool_result"&&a.tool_use_id&&s.add(a.tool_use_id)}return r.some(i=>i&&!s.has(i))}function jC(t){let e;for(let s of t)(s.type==="user"||s.type==="assistant")&&(e=s);let n=e?.type==="user"&&!Xu(e)?e.message?.content:void 0,r=typeof n=="string"?n:Array.isArray(n)?n.filter(s=>s?.type==="text").map(s=>s.text??"").join(""):"";return/^\[Request interrupted by user\b/.test(r.trim())}function FC(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 Wo(t){let e=t?.type==="image"?t.source:void 0;return e?.type==="base64"&&e.data?Bo(e.data,e.media_type):""}function _s(t){return typeof t=="string"?Re(t):Array.isArray(t)?t.map(e=>{if(typeof e=="string")return Re(e);let n=e;return typeof n?.text=="string"?Re(n.text):n?.content!=null?_s(n.content):Wo(n)}).join(`
|
|
300
|
+
`):t==null?"":Re(JSON.stringify(t))}function Dy(t){let e=t.trim();return!!e&&UC.some(n=>n.exec(e)?.index===0)}function qC(t){return!t.trim()||Dy(t)}function WC(t){return t.replace(JC,"")}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 qt(t){let e=WC(t).trim();return e?KC(e)??(Dy(e)?"":e):""}function Ko(t){let e=HC.exec(t.trim());if(e)return{from:e[1],body:YC(e[2].replace(zC,""))}}function YC(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 Ce(n.numLines??0,"line");if(n.mode==="count")return`${Ce(n.numMatches??0,"match","matches")} (${Ce(n.numFiles??0,"file")})`;if(n.mode==="files_with_matches")return Ce(n.numFiles??0,"file");if(Array.isArray(n.structuredPatch)){let r=0,s=0;for(let i of n.structuredPatch)for(let o of i?.lines??[])typeof o=="string"&&(o.startsWith("+")?r++:o.startsWith("-")&&s++);return`+${r} \u2212${s}`}return typeof n.stdout=="string"||typeof n.stderr=="string"?n.backgroundTaskId?"running in background":n.interrupted?"interrupted":Be(n.stdout||n.stderr||"")||"no output":typeof n.code=="number"&&typeof n.codeText=="string"?`${n.code} ${n.codeText}`:typeof n.searchCount=="number"?Ce(n.searchCount,"search","searches"):Array.isArray(n.matches)&&typeof n.total_deferred_tools=="number"?Ce(n.matches.length,"tool"):Array.isArray(n.newTodos)?Ce(n.newTodos.length,"todo"):typeof n.numFiles=="number"?Ce(n.numFiles,"file"):Be(e)}function Rs(t){return!!t.isMeta}function
|
|
303
|
+
`):t}function Jo(t){let e=Ko(t);return e?{type:"user",text:e.body,agent:{from:e.from}}:{type:"user",text:t}}function VC(t){let e=t.message?.content;return typeof e=="string"&&!!Ko(e)}function GC(t){let e=t.message?.content;return typeof e=="string"&&e.startsWith(_y)?e.slice(_y.length).trim():void 0}function Gu(t){return t?.type==="text"&&typeof t.text=="string"?qt(t.text):""}function QC(t){let e=t.message?.content,n=t.type==="attachment"&&t.attachment?.type==="queued_command"?_s(t.attachment.prompt):t.type==="user"&&t.isMeta&&!(Array.isArray(e)&&e.some(s=>s?.type==="tool_result"))?_s(e):"";if(!n.includes("<task-notification>"))return[];let r=[];for(let[,s]of n.matchAll(XC)){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 Be(t);if(!t||typeof t!="object")return Be(e);let n=t;if(n.type==="text"&&typeof n.file?.numLines=="number")return Ce(n.file.numLines,"line");if(n.type==="image"){let r=Ry(n.file?.originalSize);return r?`image (${r})`:"image"}if(n.type==="pdf"){let r=Ry(n.file?.originalSize);return r?`PDF (${r})`:"PDF"}if(n.type==="parts"&&typeof n.file?.count=="number")return Ce(n.file.count,"page");if(n.type==="file_unchanged")return"unchanged since last read";if(n.type==="create"&&typeof n.content=="string")return`created, ${Ce(n.content.split(`
|
|
304
|
+
`).length,"line")}`;if(n.mode==="content")return Ce(n.numLines??0,"line");if(n.mode==="count")return`${Ce(n.numMatches??0,"match","matches")} (${Ce(n.numFiles??0,"file")})`;if(n.mode==="files_with_matches")return Ce(n.numFiles??0,"file");if(Array.isArray(n.structuredPatch)){let r=0,s=0;for(let i of n.structuredPatch)for(let o of i?.lines??[])typeof o=="string"&&(o.startsWith("+")?r++:o.startsWith("-")&&s++);return`+${r} \u2212${s}`}return typeof n.stdout=="string"||typeof n.stderr=="string"?n.backgroundTaskId?"running in background":n.interrupted?"interrupted":Be(n.stdout||n.stderr||"")||"no output":typeof n.code=="number"&&typeof n.codeText=="string"?`${n.code} ${n.codeText}`:typeof n.searchCount=="number"?Ce(n.searchCount,"search","searches"):Array.isArray(n.matches)&&typeof n.total_deferred_tools=="number"?Ce(n.matches.length,"tool"):Array.isArray(n.newTodos)?Ce(n.newTodos.length,"todo"):typeof n.numFiles=="number"?Ce(n.numFiles,"file"):Be(e)}function Rs(t){return!!t.isMeta}function nO(t){let e;try{e=CC(t,"r")}catch{return""}try{let r=65536;try{r=$y(t).size}catch{}let s=(c,f)=>{if(f<=0)return"";let d=Buffer.alloc(f),u=OC(e,d,0,f,c);return d.subarray(0,u).toString("utf8")},i=(c,f,d)=>{let u="";for(let p of c.split(`
|
|
305
305
|
`)){if(!p.includes(`"${f}"`))continue;let h;try{h=JSON.parse(p)}catch{continue}let m=h?.[d];h?.type===f&&typeof m=="string"&&m&&(u=m)}return u},o=s(0,Math.min(65536,r)),a=r>65536?s(r-65536,65536):"",l=i(a,"custom-title","customTitle")||i(o,"custom-title","customTitle")||i(a,"ai-title","aiTitle")||i(o,"ai-title","aiTitle");if(l)return l.replace(/\s+/g," ").trim().slice(0,200);for(let c of o.split(`
|
|
306
|
-
`)){if(!c.trim())continue;let f;try{f=JSON.parse(c)}catch{continue}if(!f||Rs(f)||f.type!=="user")continue;let d=f.message?.content,u="";typeof d=="string"?u=
|
|
307
|
-
`;
|
|
308
|
-
`),d=l.filter(h=>h.type==="tool_use").map(h=>({id:h.id??"",name:h.name??"",input:h.input??{}}));if(c||f||d.length){let h=Date.parse(n.timestamp??""),m=!isNaN(h)&&h>=r;o.push({type:"assistant",text:c,thinking:f,tools:d,live:m,error:n.isApiErrorMessage||void 0})}(n.message?.stop_reason==="end_turn"||d.some(h=>h.name==="SubagentHandback"))&&o.push({type:"turn_end"});for(let h of d)if(
|
|
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
|
|
306
|
+
`)){if(!c.trim())continue;let f;try{f=JSON.parse(c)}catch{continue}if(!f||Rs(f)||f.type!=="user")continue;let d=f.message?.content,u="";typeof d=="string"?u=qt(d):Array.isArray(d)&&(u=d.map(Gu).filter(Boolean).join(" "));let p=u.replace(/\s+/g," ").trim();if(p)return(p.replace(/^Continuing from a prior session\. Here is the summary of our work so far:\s*/i,"").trim()||p).slice(0,200)}return""}finally{PC(e)}}function Ho(t){let e=pn(t,"sessions"),n;try{n=Ny(e)}catch{return[]}let r=[];for(let s of n)if(s.endsWith(".json"))try{let i=JSON.parse(Ly(pn(e,s),"utf8"));if(!i?.sessionId)continue;process.kill(i.pid,0),r.push(i)}catch{}return r}function Iy(t,e){return Ho(t).some(n=>n.sessionId===e)}function rO(t,e){let n=Ho(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 sO(t){return new Set(Ho(t).filter(e=>e.status==="busy").map(e=>e.sessionId))}var Xu,Vu,$C,LC,MC,Py,UC,JC,HC,zC,_y,XC,ZC,eO,tO,Ry,rr,zo=S(()=>{"use strict";Ps();Uo();qo();Os();Xu=t=>t.type==="user"&&Array.isArray(t.message?.content)&&t.message.content.some(e=>e?.type==="tool_result");Vu=(t,e)=>pn(t,"projects",IC(e)),$C="subagents";LC="general-purpose",MC=[256*1024,4*1024*1024,64*1024*1024],Py=new Map;UC=[/\[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];JC=/<ide_[a-z_]+>[\s\S]*?<\/ide_[a-z_]+>/gi;HC=/^(?:[^\n<][^\n]*\n)?<agent-message from="([^"]+)">\n([\s\S]*?)(?:\n?<\/agent-message>[\s\S]*)?$/,zC=/^\[[^\]\n]+\][\s\S]*?The report follows:\n/;_y=`The coordinator sent a message while you were working:
|
|
307
|
+
`;XC=/<task-notification>([\s\S]*?)<\/task-notification>/g;ZC=/^(Command running in background with ID|Command did not complete within its \d+s timeout and was moved to the background|Async agent launched)/,eO=/\bID: ([A-Za-z0-9]+)/,tO=new Set(["TaskStop","KillShell"]),Ry=t=>typeof t!="number"?"":t<1024?`${t}B`:t<1048576?`${Math.round(t/1024)}KB`:`${(t/1048576).toFixed(1)}MB`;rr=class extends Ut{constructor(n=pn(RC(),".claude")){super();this.root=n}displayName="Claude Mirror";detectsSelf(){return process.env.CLAUDECODE==="1"}detectsInstalled(){return _C(this.root)}sessionsDir(n){return Vu(this.root,n)}listSessionFiles(n){return Fo(Vu(this.root,n))}listChildren(n,r){return NC(this.root,n,r)}callerSessionId(){return process.env.CLAUDE_CODE_SESSION_ID||void 0}sessionCwd(n){return Ho(this.root).find(r=>r.sessionId===n)?.cwd}parseEntry(n){try{return JSON.parse(n)}catch{return null}}idOf(n){return n.uuid}parentOf(n){return n.parentUuid}linker(){let n=new Map,r=new Map;return{link(s){if(!s.uuid||n.has(s.uuid))return;let i=s.parentUuid===void 0?void 0:n.get(s.parentUuid),o=s.type==="assistant"?s.message?.id:Xu(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=GC(n);if(s)return{events:[Jo(s)]};let i=QC(n);if(i.length)return{events:i};if(Rs(n)&&!VC(n))return{events:[]};let o=[];if(n.type==="user"){let a=n.message?.content;if(typeof a=="string"){let l=qt(a);l&&o.push(Jo(l))}else if(Array.isArray(a))for(let l of a)if(l?.type==="tool_result"){let c=_s(l.content),f=l.is_error?/^Exit code (\d+)/.exec(c)?.[1]:void 0,d=n.toolUseResult,u=ZC.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:f===void 0?void 0:Number(f),background:u||void 0,task:u?eO.exec(c)?.[1]??ee(d?.backgroundTaskId):void 0,output:u?/Output is being written to: (\S.*?)\.?\s*$/m.exec(c)?.[1]:void 0,refused:!!l.is_error&&f===void 0||void 0})}else{let c=Gu(l)||Wo(l);c&&o.push(Jo(c))}return{events:o}}if(n.type==="attachment"&&n.attachment?.type==="queued_command"){let a=qt(_s(n.attachment.prompt));return a&&o.push(Jo(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=>!qC(h)).join(""),f=l.filter(h=>h.type==="thinking").map(h=>h.thinking??"").join(`
|
|
308
|
+
`),d=l.filter(h=>h.type==="tool_use").map(h=>({id:h.id??"",name:h.name??"",input:h.input??{}}));if(c||f||d.length){let h=Date.parse(n.timestamp??""),m=!isNaN(h)&&h>=r;o.push({type:"assistant",text:c,thinking:f,tools:d,live:m,error:n.isApiErrorMessage||void 0})}(n.message?.stop_reason==="end_turn"||d.some(h=>h.name==="SubagentHandback"))&&o.push({type:"turn_end"});for(let h of d)if(tO.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 u=n.message?.usage??n.usage,p=u&&{in:u.input_tokens??0,out:u.output_tokens??0,cached:u.cache_read_input_tokens??0,cacheCreate:u.cache_creation_input_tokens??0};return{events:o,usage:p,model:n.message?.model}}return{events:o}}chainWorking(n){return My(n)}sessionAlive(n){return Iy(this.root,n)}sessionEnded(n){return!Iy(this.root,n)}sessionsWorking(n){return sO(this.root)}readPreview(n){return nO(n)}searchText(n){if(!n||Rs(n)||n.type!=="user"&&n.type!=="assistant")return"";let r=n.message?.content,s="";if(typeof r=="string")s=qt(r);else if(Array.isArray(r)){let i=r;s=n.type==="user"?i.map(Gu).filter(Boolean).join(" "):i.filter(o=>o.type==="text"&&typeof o.text=="string").map(o=>o.text).join(" ")}return s.replace(/\s+/g," ").trim()}}});function ht(t,e=!0){let n=[],r=0;for(let s of Is(t).matchAll(e?/&&|\|\||[;|\n]/g:/&&|\|\||[;\n]/g))n.push({text:t.slice(r,s.index),at:r}),r=s.index+s[0].length;return n.push({text:t.slice(r),at:r}),n.filter(s=>s.text.trim())}function Yo(t){let e=[],n;for(;n=iO.exec(t);)n[1]&&e.push(n[1]),t=t.slice(n[0].length);return{dirs:e,rest:t}}function Zu(t){if(/>|\btee\b/.test(Is(t).replace(/\d?>&\d|\d?>\s*(\/dev\/null|\$null|NUL)\b/gi,"")))return!1;let e=$s(t);for(;e.length&&(cO.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"?lO.has(r.find(s=>!s.startsWith("-"))??""):n==="git"?aO.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)):oO.has(n)||/^get-/.test(n)}function By(t){let e=[...t.matchAll(/\$\(|`/g)].map(n=>t.slice(n.index+n[0].length));return ht(t).every(n=>Zu(n.text))&&e.every(n=>Zu(ht(n)[0]?.text??""))}function Fy(t){if(/\bset\s+-\w*o\s+pipefail\b/.test(Is(t)))return!1;let e=ht(ht(t,!1).at(-1)?.text??"");return e.length>1&&dO.has($s(e.at(-1).text)[0]?.toLowerCase()??"")}function ed(t){t=t.replace(fO,(s,i,o,a)=>`<<${i}${o}${i}${a} \u2026 ${o}`);let e=ht(t),n=e.findIndex(s=>!Zu(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 Uy(t){let e=[];for(let n of ht(t)){let r=$s(n.text),s=r.indexOf("git"),i=r[s+1];if(s<0||i!=="rm"&&i!=="mv"||r.includes("--cached"))continue;let o=r.slice(s+2).filter(l=>!l.startsWith("-"));if(i==="rm"){for(let l of o)e.push({from:l});continue}let a=o.pop();if(a)for(let l of o)e.push({from:l,to:o.length>1?`${a.replace(/\/+$/,"")}/${Ey(l)}`:a})}return e}function qy(t){let e=Wy(t),n=e.map(Ky);return e.length&&n.every(r=>r!==void 0)?n:void 0}function Jy(t){let e=new Map,n=[];for(let r of Wy(t)){let s=/^\$([\w:]+)\s*=\s*(['"])([^'"]*)\2$/.exec(r);if(s){e.set(s[1].toLowerCase(),s[3]);continue}let i=Ky(r.replace(/^\$[\w:]+\s*=\s*/,"")),o=i&&/^\$([\w:]+)$/.exec(i),a=o?e.get(o[1].toLowerCase()):i;a&&!/[*?$]/.test(a)&&n.push(a)}return n}function Ky(t){let[e,...n]=ht(t).map(i=>i.text.trim());if(!e||!n.every(i=>gO.test(i)))return;let r=$s(e);if(!pO.test(r[0]??""))return;let s=[];for(let i=1;i<r.length;i++){let o=r[i];if(hO.test(o)){i+1<r.length&&s.push(r[++i]);continue}if(mO.test(o)){i++;continue}o.startsWith("-")||/^\d+(,\d+)?p?$/.test(o)||s.push(o)}return s.length===1?s[0]:void 0}var Is,$s,iO,oO,aO,lO,cO,uO,jy,dO,fO,pO,hO,mO,gO,Wy,td=S(()=>{"use strict";Os();Is=t=>t.replace(/'[^']*'|"(?:\\.|[^"\\])*"/g,e=>"_".repeat(e.length));$s=t=>(t.trim().match(/"[^"]*"|'[^']*'|\S+/g)??[]).map(e=>/^(['"])(.*)\1$/.exec(e)?.[2]??e),iO=/^\s*(?:(?:cd|set-location)\s+(?:-(?:literal)?path\s+)?("[^"]*"|'[^']*'|[^\s;&]+)|export\s+PATH=\S+)\s*(?:;|&&)\s*/i;oO=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"]),aO=new Set(["log","status","diff","show","blame","rev-parse","ls-files","grep","branch","remote"]),lO=new Set(["status","logs","get","models","slug","predict"]),cO=new Set(["if","then","else","elif","fi","do","done","while","until","!","{","}","(",")"]);uO=new Set(["grep","egrep","fgrep","rg","findstr","select-string"]),jy=t=>uO.has($s(ht(t).at(-1)?.text??"")[0]?.toLowerCase()??""),dO=new Set(["tail","head","grep","egrep","fgrep","rg","sed","awk","sort","uniq","wc","cut","tr","tee","cat","less","findstr"]);fO=/<<-?\s*(['"]?)(\w+)\1([^\n]*)\n[\s\S]*?\n\s*\2\b/g;pO=/^(Get-Content|gc|cat|type|nl|bat|sed|head|tail)$/i,hO=/^-(Path|LiteralPath)$/i,mO=/^-(Encoding|TotalCount|Head|Tail|ReadCount|Delimiter)$/i,gO=/^(sed -n|head|tail|Select-Object|select)(\s|$)/i;Wy=t=>ht(t,!1).map(e=>e.text.trim())});import{spawn as yO,execFile as bO}from"child_process";import{promisify as wO}from"util";import{randomBytes as zy}from"crypto";async function SO(){let t;try{t=(await vO("codex",["app-server","daemon","version"],{shell:!0,timeout:Yy})).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 Hy(t){let e=Buffer.from(t),n=zy(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 Vy(){let t=await SO(),e=new nd(yO(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 rd(){let t=await Vy();try{return(await t.call("thread/loaded/list",{})).data??[]}finally{t.close()}}async function Gy(t,e,n){let r=await Vy();try{await r.call("turn/start",{threadId:t,input:[],toolOutput:{name:e,output:n},turnTrigger:"typebulb"})}finally{r.close()}}var vO,Yy,nd,Xy=S(()=>{"use strict";vO=wO(bO),Yy=15e3;nd=class{constructor(e){this.proc=e;let n,r;this.#u=new Promise((s,i)=>{n=s,r=i}),e.stderr.on("data",s=>{this.#n+=s}),e.stdout.on("data",s=>this.#c(s,n,r)),e.on("error",s=>{r(new Error(`could not reach the Codex app server socket: ${s.message}`));for(let i of this.#t.values())i({error:{message:"connection closed"}})}),e.stdin.on("error",()=>{}),e.on("exit",()=>{let s=this.#n.trim().split(`
|
|
310
310
|
`).filter(i=>i.trim()).join(" ").slice(0,300);r(new Error(`could not reach the Codex app server socket${s?`: ${s}`:""}`));for(let i of this.#t.values())i({error:{message:"connection closed"}})}),e.stdin.write(`GET / HTTP/1.1\r
|
|
311
311
|
Host: localhost\r
|
|
312
312
|
Upgrade: websocket\r
|
|
313
313
|
Connection: Upgrade\r
|
|
314
|
-
Sec-WebSocket-Key: ${
|
|
314
|
+
Sec-WebSocket-Key: ${zy(16).toString("base64")}\r
|
|
315
315
|
Sec-WebSocket-Version: 13\r
|
|
316
316
|
\r
|
|
317
317
|
`)}#t=new Map;#o=1;#e=Buffer.alloc(0);#s=!1;#u;#n="";#c(e,n,r){if(this.#e=Buffer.concat([this.#e,e]),!this.#s){let s=this.#e.indexOf(`\r
|
|
318
318
|
\r
|
|
319
319
|
`);if(s<0)return;let i=this.#e.subarray(0,s).toString().split(`\r
|
|
320
|
-
`)[0]??"";if(!/^HTTP\/1\.[01] 101\b/.test(i)){r(new Error(`the Codex app server refused the connection: ${i}`)),this.proc.kill();return}this.#s=!0,this.#e=this.#e.subarray(s+4),n()}for(;;){if(this.#e.length<2)return;let s=this.#e[1]&127,i=2;if(s===126){if(this.#e.length<4)return;s=this.#e.readUInt16BE(2),i=4}else if(s===127){if(this.#e.length<10)return;s=Number(this.#e.readBigUInt64BE(2)),i=10}if(this.#e.length<i+s)return;let o=this.#e[0]&15,a=this.#e.subarray(i,i+s).toString();if(this.#e=this.#e.subarray(i+s),o===1)try{let l=JSON.parse(a);l.id!==void 0&&!l.method&&this.#t.has(l.id)&&(this.#t.get(l.id)(l),this.#t.delete(l.id))}catch{}}}async call(e,n){await this.#u;let r=this.#o++,s=await new Promise((i,o)=>{let a=setTimeout(()=>{this.#t.delete(r),o(new Error(`no reply to ${e}`))},
|
|
321
|
-
`):""}function
|
|
322
|
-
`))r.startsWith("+")&&!r.startsWith("+++")?e++:r.startsWith("-")&&!r.startsWith("---")&&n++;return`+${e} \u2212${n}`}function
|
|
323
|
-
`)}}function
|
|
324
|
-
`);i.partial&&o.shift();let a;for(let l=o.length-1;l>=0;l--){if(!o[l].trim())continue;let c;try{c=JSON.parse(o[l])}catch{continue}if(a===void 0){let f=Date.parse(c.timestamp??"");Number.isNaN(f)||(a=f)}if(e===void 0&&c.type==="event_msg"){let f=c.payload?.type;f==="task_started"?e=!0:(f==="task_complete"||f==="turn_aborted")&&(e=!1)}if(n===void 0&&c.type==="event_msg"&&c.payload?.type==="token_count"&&c.payload.info?.last_token_usage){let f=
|
|
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=
|
|
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
|
|
327
|
-
`,t:" ",r:"\r",b:"\b",f:"\f",v:"\v",0:"\0"};
|
|
328
|
-
`).length:0;
|
|
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"?sr(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"?"":sr(n.payload.content,r==="user").replace(/\s+/g," ").trim()}},
|
|
330
|
-
`),r=[];if(n.forEach((o,a)=>{let l=
|
|
331
|
-
`)}function
|
|
320
|
+
`)[0]??"";if(!/^HTTP\/1\.[01] 101\b/.test(i)){r(new Error(`the Codex app server refused the connection: ${i}`)),this.proc.kill();return}this.#s=!0,this.#e=this.#e.subarray(s+4),n()}for(;;){if(this.#e.length<2)return;let s=this.#e[1]&127,i=2;if(s===126){if(this.#e.length<4)return;s=this.#e.readUInt16BE(2),i=4}else if(s===127){if(this.#e.length<10)return;s=Number(this.#e.readBigUInt64BE(2)),i=10}if(this.#e.length<i+s)return;let o=this.#e[0]&15,a=this.#e.subarray(i,i+s).toString();if(this.#e=this.#e.subarray(i+s),o===1)try{let l=JSON.parse(a);l.id!==void 0&&!l.method&&this.#t.has(l.id)&&(this.#t.get(l.id)(l),this.#t.delete(l.id))}catch{}}}async call(e,n){await this.#u;let r=this.#o++,s=await new Promise((i,o)=>{let a=setTimeout(()=>{this.#t.delete(r),o(new Error(`no reply to ${e}`))},Yy);this.#t.set(r,l=>{clearTimeout(a),i(l)}),this.proc.stdin.write(Hy(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(Hy(JSON.stringify({jsonrpc:"2.0",method:e})))}close(){this.proc.kill()}}});import{statSync as Vo,readdirSync as kO,existsSync as xO}from"fs";import{basename as Qy,join as sd,resolve as EO}from"path";import{homedir as Zy}from"os";function TO(t){let e=t.trimStart();return AO.some(n=>e.startsWith(n))}function sr(t,e){return Array.isArray(t)?t.map(n=>typeof n?.text=="string"?e&&TO(n.text)?"":Re(n.text):n?.type==="input_image"&&typeof n.image_url=="string"&&n.image_url.startsWith("data:")?``:"").filter(Boolean).join(`
|
|
321
|
+
`):""}function CO(t){return typeof t=="string"?Re(t):sr(t,!1)}function OO(t,e){let n=e??"",r=IO(n);if(!r.length)return{name:t,input:{script:n}};let s=r.map(i=>id(i.fn)&&Ns(i.arg)?qy(String(i.arg.cmd??i.arg.command??"")):void 0);if(s.every(i=>i!==void 0))return{name:"read",input:eb(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}=tb(o);return{name:i,input:new Set(a).size===1?{path:a[0],patch:l}:{patch:l},pending:{kind:"patch",digest:RO(l)}}}return Ns(o)?id(i)?{name:t,input:_O(o)}:{name:i,input:o}:typeof o=="string"?{name:i,input:{arg:o}}:{name:t,input:{script:n}}}return{name:t,input:eb(r.map(({fn:i,arg:o})=>i==="apply_patch"&&typeof o=="string"?["patch",tb(o).diff]:id(i)&&Ns(o)?["command",o.cmd??o.command]:[i,o]))}}function _O(t){let e=Object.fromEntries(Object.entries(t).filter(([r])=>r!=="cmd"&&r!=="command"&&!PO.has(r))),n=t.command??t.cmd;return n===void 0?e:{command:n,...e}}function eb(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 RO(t){let e=0,n=0;for(let r of t.split(`
|
|
322
|
+
`))r.startsWith("+")&&!r.startsWith("+++")?e++:r.startsWith("-")&&!r.startsWith("---")&&n++;return`+${e} \u2212${n}`}function 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=ab(t,s);if(i<0)break;e.push({fn:r[1],arg:ob(t.slice(s+1,i).trim(),t)}),n.lastIndex=i+1}return e}function ob(t,e){let n=t[0];if(n==='"'||n==="'"||n==="`")return Xo(t,0)===t.length-1?lb(t.slice(1,-1)):t;if(n==="{"){for(let r of[t,NO(t)])try{let s=JSON.parse(r);if(Ns(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==="`"?Xo(e,s):i==="{"?ab(e,s):-1;if(o>s)return ob(e.slice(s,o+1),"")}}return t}function ab(t,e){let n=0;for(let r=e;r<t.length;r++){let s=t[r];if(s==='"'||s==="'"||s==="`"){if(r=Xo(t,r),r<0)return-1}else if(s==="("||s==="["||s==="{")n++;else if((s===")"||s==="]"||s==="}")&&--n===0)return r}return-1}function Xo(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 lb(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)):$O[i]??i)}function NO(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=Xo(t,i);if(l<0)return t;r+=JSON.stringify(lb(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 tb(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:Be(t)};let r=n[3].replace(/^\n+/,"").replace(/^Script error:\n/,""),s=n[1]==="failed",i=MO(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:Ce(DO(r),"line")}:e?.kind==="patch"&&!s?{content:e.digest,isError:s,digest:e.digest}:{content:r,isError:s,digest:Be(r),exit:o}}function MO(t){if(t.startsWith("{"))try{let e=JSON.parse(t);if(Ns(e)&&typeof e.output=="string")return{output:e.output,exit_code:typeof e.exit_code=="number"?e.exit_code:void 0}}catch{}}function BO(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 FO(t){let e,n,r;for(let s of jO){let i=jo(t,s);if(i===void 0)return{};let o=i.text.split(`
|
|
324
|
+
`);i.partial&&o.shift();let a;for(let l=o.length-1;l>=0;l--){if(!o[l].trim())continue;let c;try{c=JSON.parse(o[l])}catch{continue}if(a===void 0){let f=Date.parse(c.timestamp??"");Number.isNaN(f)||(a=f)}if(e===void 0&&c.type==="event_msg"){let f=c.payload?.type;f==="task_started"?e=!0:(f==="task_complete"||f==="turn_aborted")&&(e=!1)}if(n===void 0&&c.type==="event_msg"&&c.payload?.type==="token_count"&&c.payload.info?.last_token_usage){let f=cb(c.payload.info.last_token_usage);n=f.in+f.out+f.cached+f.cacheCreate}if(r===void 0&&c.type==="turn_context"&&(r={model:c.payload?.model,effort:c.payload?.effort}),a!==void 0&&e!==void 0&&n!==void 0&&r!==void 0)break}if(a!==void 0)return{ms:a,running:e??!0,tokens:n,turn:r};if(!i.partial)break}return{running:e??!0,tokens:n,turn:r}}function cb(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 rb(t){let n=nr(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=UO(i,o),l=ib(n.text,r),c=a&&!l&&n.bytes>=65536?nr(t,sb):void 0,f=l??(c&&ib(c.text,r)),d=!!a&&!f&&(c??n).bytes<(c?sb:65536);return{cwd:i.cwd,subagent:!!o,id:i.id,spawn:a,turn:f,modelPending:d}}catch{return{cwd:"",subagent:!1}}}function UO(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 ib(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 AO,Ns,id,PO,$O,DO,Go,nb,od,ir,jO,sb,ad=S(()=>{"use strict";Ps();qo();Uo();td();Xy();AO=["<permissions instructions>","<apps_instructions>","<plugins_instructions>","<skills_instructions>","<recommended_plugins>","<environment_context>","<node_repl_review_evidence>","# AGENTS.md instructions for "];Ns=t=>!!t&&typeof t=="object"&&!Array.isArray(t),id=t=>t==="shell_command"||t==="exec_command",PO=new Set(["max_output_tokens","yield_time_ms","timeout_ms"]);$O={n:`
|
|
327
|
+
`,t:" ",r:"\r",b:"\b",f:"\f",v:"\v",0:"\0"};DO=t=>t?t.replace(/\r?\n$/,"").split(`
|
|
328
|
+
`).length:0;Go=t=>{let e=EO(t);return process.platform==="win32"?e.toLowerCase():e},nb=12e4,od=t=>t.slice(-36),ir=class t extends Ut{constructor(n=sd(Zy(),".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 rd()).includes(od(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 rd()).includes(od(n)))throw new Error("the Codex session is not loaded by its app server now");await Gy(od(n),r,s)}detectsInstalled(){return xO(sd(Zy(),".codex"))}sessionsDir(n){return this.root}listSessionFiles(n){let r=Go(n),s=[];for(let i of this.#f()){let o=0,a=0;try{let f=Vo(i);if(!f.isFile())continue;o=f.size,a=f.mtimeMs}catch{continue}let l=this.#n.get(i);if(l===void 0){if(l=rb(i),l===void 0)continue;this.#n.set(i,l)}if(l.subagent||Go(l.cwd)!==r)continue;let c=Qy(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=Go(n),i=new Map,o;for(let c of this.#f()){let f=0,d=0,u;try{let v=Vo(c);if(!v.isFile())continue;f=v.size,d=v.mtimeMs,u=v.birthtimeMs||void 0}catch{continue}let p=this.#n.get(c);if(p===void 0||p.modelPending){if(p=rb(c),p===void 0)continue;this.#n.set(c,p)}if(Qy(c,".jsonl")===r&&(o=p.id),!p.spawn||Go(p.cwd)!==s)continue;let{running:h,tokens:m,turn:g}=this.#i(c,f,d);i.set(p.spawn.id,{file:c,mtime:this.#r(c,f,d),started:u,running:h,tokens:m,spawn:p.spawn,turn:g??p.turn})}if(!o)return[];let a=(c,f=new Set)=>{if(c.parent===o)return!0;if(f.has(c.id))return!1;f.add(c.id);let d=i.get(c.parent);return d?a(d.spawn,f):!1},l=[];for(let{file:c,mtime:f,started:d,running:u,tokens:p,spawn:h,turn:m}of i.values())a(h)&&l.push({id:h.id,file:c,mtime:f,started:d,tokens:p,label:h.path.split("/").filter(Boolean).pop()??h.path,kind:h.role||void 0,model:m?.model,effort:m?.effort,parentId:i.has(h.parent)?h.parent:void 0,depth:h.depth,stopped:!1,running:u});return l}sessionsWorking(n){let r=new Set,s=Date.now();for(let{sessionId:i,file:o,mtime:a}of this.listSessionFiles(n)){if(s-a>=nb)continue;let l;try{let c=Vo(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=FO(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 kO(s).map(i=>sd(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=sr(i.content,!0).trim();a&&s.push({type:"user",text:a})}else if(i.role==="assistant"){let a=sr(i.content,!1);a&&s.push({type:"assistant",text:a,thinking:"",tools:[],live:o()})}return{events:s}}if(i.type==="reasoning"){let a=sr(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"?OO(i.name??"",i.input):{name:i.name??"",input:BO(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(CO(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:cb(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=Vo(r);s=this.#r(r,i.size,i.mtimeMs)}catch{return}return Date.now()-s<nb}readPreview(n){for(let r of(nr(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"?sr(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"?"":sr(n.payload.content,r==="user").replace(/\s+/g," ").trim()}},jO=[64*1024,1024*1024];sb=512*1024});import{realpathSync as qO}from"fs";import{createHash as JO}from"crypto";import{join as Qo,resolve as WO}from"path";import{homedir as KO}from"os";function Ge(){let t=process.env.TYPEBULB_SERVERS_DIR;return t?Qo(t,".."):Qo(KO(),".typebulb")}function mt(){ub||(ub=!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 gt(){return process.env.TYPEBULB_SERVERS_DIR||Qo(Ge(),"servers")}function db(t){let e=se(t),n=e.slice(e.lastIndexOf("/")+1).replace(/\.bulb\.md$/,"");return Qo(Ge(),"canvas",`${n}-${Ls(t)}.png`)}function Ls(t){return JO("sha1").update(se(t)).digest("hex").slice(0,8)}function se(t){let e=WO(t),n=e;try{n=qO.native(e)}catch{}return(process.platform==="win32"?n.toLowerCase():n).replace(/\\/g,"/")}function fb(t,e){let n=se(t),r=se(e);return n.startsWith(r.endsWith("/")?r:r+"/")?!n.includes("/node_modules/"):!1}var ub,je=S(()=>{"use strict";ub=!1});import*as mb from"net";import{mkdir as HO,readFile as zO,writeFile as gb}from"fs/promises";import{existsSync as YO}from"fs";import{join as yb}from"path";function vb(){return yb(Ge(),"blocks")}function ld(t){return yb(vb(),`${t}.json`)}function ea(t){return new Promise(e=>{let n=mb.createServer();n.once("error",()=>e(!1)),n.listen(t,"127.0.0.1",()=>n.close(()=>e(!0)))})}async function QO(t){for(let e=t;e<65535;e++)if(await ea(e))return e;throw new Error(`No free port found above ${t}`)}async function cd(t){let{listBulbServers:e}=await Promise.resolve().then(()=>(Ie(),Sb)),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 ta(t){try{let e=JSON.parse(await zO(ld(t),"utf8"));return e&&typeof e.cwd=="string"?{cwd:e.cwd,slots:e.slots??{},mirrors:e.mirrors??{}}:void 0}catch{return}}async function na(t,e){try{return await gb(ld(t),JSON.stringify(e,null,2)),!0}catch{return mt(),!1}}async function ZO(t){let e=se(t);try{await HO(vb(),{recursive:!0})}catch{return}let n=[];for(let o=0;o<wb;o++)n.push(bb+o*hn);let r=await Promise.all(n.map(async o=>({base:o,block:await ta(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 gb(ld(o),JSON.stringify(s,null,2),{flag:"wx"}),o}catch(l){if((await ta(o))?.cwd===e)return o;l.code!=="EEXIST"&&mt();continue}if(!YO(a.cwd))return await na(o,s)?o:void 0}let i=r.filter(o=>!!o.block).sort((o,a)=>pb(o.block)-pb(a.block))[0];if(i)return await na(i.base,s)?i.base:void 0}function pb(t){return Object.values(t.slots).reduce((e,n)=>Math.max(e,n.usedAt??0),0)}async function eP(t,e){let n=await ta(t)??{cwd:"",slots:{},mirrors:{}};if(e.kind==="mirror"){let i=n.mirrors[e.agent];if(i!==void 0)return i;let o=hb(n),a=o.has(0)?GO:0;for(;a>Zo&&o.has(a);)a--;return n.mirrors[e.agent]=a,await na(t,n),a}let r=se(e.file),s=n.slots[r]?.offset;if(s===void 0){let i=hb(n);for(s=Zo;s<hn&&i.has(s);)s++;if(s>=hn){let o=Object.entries(n.slots).sort((a,l)=>(a[1].usedAt??0)-(l[1].usedAt??0))[0];s=o?o[1].offset:Zo,o&&delete n.slots[o[0]]}}return n.slots[r]={offset:s,usedAt:Date.now()},await na(t,n),s}function hb(t){return new Set([...Object.values(t.mirrors),...Object.values(t.slots).map(e=>e.offset)])}async function or(t,e){let n=await ZO(e);return n===void 0?void 0:n+await eP(n,t)}async function mn(t){let e=se(t);for(let n=0;n<wb;n++){let r=await ta(bb+n*hn);if(r?.cwd===e)return s=>r.slots[se(s)]?.usedAt??0}return()=>0}async function ra(t){if(t.explicit!==void 0)return await ea(t.explicit)||await cd(t.explicit),t.target.kind==="bulb"&&await or(t.target,t.cwd),{port:t.explicit};let e=await or(t.target,t.cwd);if(e!==void 0){let r=e-e%hn,s=Date.now()+XO;do{if(await ea(e))return{port:e};await new Promise(i=>setTimeout(i,150))}while(Date.now()<s);for(let i=Zo;i<hn;i++){let o=r+i;if(o!==e&&await ea(o))return{port:o,note:`(slot ${e} was busy)`}}}return{port:await QO(VO),note:e===void 0?"(no port block available)":"(this project's block was full)"}}var bb,hn,wb,VO,Zo,GO,XO,gn=S(()=>{"use strict";je();bb=20100,hn=100,wb=19,VO=23e3,Zo=1,GO=hn-1,XO=3e3});var Oe,sa=S(()=>{"use strict";Oe="0.62.4"});var Sb={};Ri(Sb,{agentViewerCommand:()=>Rb,bulbServerCommand:()=>_b,clearServerLog:()=>hd,findProjectViewer:()=>aa,isAlive:()=>Jt,isMirror:()=>be,isProjectBulb:()=>wd,isProjectMirror:()=>cr,launchAgentViewer:()=>Bs,launchBulbServer:()=>wn,listBulbServers:()=>G,probePageCount:()=>Sd,readServerLog:()=>Xe,readWaitCursor:()=>oa,recordDenial:()=>bd,registerServer:()=>yd,relayOpen:()=>vd,runMarker:()=>md,serverLogPath:()=>lr,serversForBulb:()=>bn,sliceRunLog:()=>gd,startServerLog:()=>Ds,stopBulbServer:()=>ar,stopServer:()=>yt,stopServersForBulb:()=>la,typebulbBinPath:()=>ur,unregisterServer:()=>yn,writeWaitCursor:()=>Ms});import{spawn as kb}from"child_process";import{readdir as tP,readFile as Ab,writeFile as Tb,unlink as ud,mkdir as nP}from"fs/promises";import{mkdirSync as Cb,writeFileSync as ia,appendFileSync as rP,readFileSync as dd}from"fs";import*as $e from"path";import{fileURLToPath as sP}from"url";function fd(t){return $e.join(gt(),`${t}.json`)}function lr(t){return $e.join(gt(),`${t}.log`)}function pd(t){return $e.join(gt(),`${t}.wait.json`)}function Ob(t){try{let e=JSON.parse(dd(pd(t),"utf8"));return e.cursors&&typeof e.cursors=="object"?e.cursors:{}}catch{return{}}}function oa(t,e=""){let n=Ob(t)[e];return typeof n=="number"&&Number.isFinite(n)&&n>=0?n:void 0}function Ms(t,e,n=""){try{Cb(gt(),{recursive:!0});let r=Ob(t);r[n]=e,ia(pd(t),JSON.stringify({cursors:r}))}catch{}}function Ds(t){let e=lr(t);try{Cb(gt(),{recursive:!0}),ia(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(rP(e,l),s+=l.length,s>2*xb){let c=dd(e),f=c.subarray(Math.max(0,c.length-xb));ia(e,f),s=f.length}}catch{i=!0}};return process.stdout.write=((a,...l)=>(o(a),n(a,...l))),process.stderr.write=((a,...l)=>(o(a),r(a,...l))),()=>{process.stdout.write=n,process.stderr.write=r}}function hd(t){try{ia(lr(t),"")}catch{}}function Xe(t,e=0){try{let n=dd(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 md(t){return`\u2500\u2500 run ${t} \u2500\u2500 ${new Date().toTimeString().slice(0,8)}`}function oP(t){let e=iP.exec(t);return e?Number(e[1]):void 0}function gd(t,e){let n=t.split(`
|
|
330
|
+
`),r=[];if(n.forEach((o,a)=>{let l=oP(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 Jt(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}async function yd(t){try{await nP(gt(),{recursive:!0}),await Tb(fd(t.pid),JSON.stringify({version:Oe,...t}))}catch{mt()}}async function bd(t,e){let n=fd(t);try{let r=JSON.parse(await Ab(n,"utf8"));if(r.denied===e)return;r.denied=e,await Tb(n,JSON.stringify(r))}catch{}}async function yn(t){await ud(fd(t)).catch(()=>{}),await ud(lr(t)).catch(()=>{}),await ud(pd(t)).catch(()=>{})}function be(t){return t.agent!=null}function cr(t,e){return be(t)&&t.cwd!=null&&se(t.cwd)===se(e)}function wd(t,e){return!be(t)&&fb(t.file,e)}async function G(t){let e;try{e=await tP(gt())}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(gt(),s),"utf8"))}catch{await yn(i);return}o&&typeof o.pid=="number"&&Jt(o.pid)?n.push(o):await yn(i)})),(t?n.filter(s=>wd(s,t)):n).sort((s,i)=>s.startedAt-i.startedAt)}async function aa(t,e){return(await G()).find(n=>cr(n,t)&&(e?n.agent===e:!0))}async function vd(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=>wd(a,e)),o=0;for(let a of[...s,...i])try{let l=await fetch(`${a.url}/__open`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:t}),signal:AbortSignal.timeout(2e3)});if(!l.ok)continue;let{opened:c,pages:f}=await l.json();if(c)return{where:"editor",via:a.agent?"the agent mirror":`${$e.basename(a.file)}'s page`};be(a)&&(o+=f??0)}catch{}return o>0?{where:"external"}:void 0}async function ar(t){try{process.kill(t,"SIGTERM")}catch{}await yn(t)}async function Sd(t){try{let e=await fetch(`${t.url}/__pages`,{signal:AbortSignal.timeout(aP)});if(!e.ok)return;let{pages:n}=await e.json();return typeof n=="number"?n:void 0}catch{return}}async function yt(t,e=be(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(Eb)});if(!n.ok)throw new Error(`/__stop ${n.status}`);let{closed:r=0,stuck:s=0}=await n.json(),i=Date.now()+Eb;for(;Jt(t.pid)&&Date.now()<i;)await Pb(100);return Jt(t.pid)?(await ar(t.pid),"killed"):(await yn(t.pid),{closed:r,stuck:s})}catch{return await ar(t.pid),"killed"}}function bn(t,e){let n=se(e);return t.filter(r=>!be(r)&&r.pid!==process.pid&&se(r.file)===n)}async function la(t,e){let n=bn(await G(),t);for(let r of n)await yt(r,e!==void 0&&r.port===e?"keep":"close");return n}function lP(t,e,n){(process.platform==="win32"?kb("cmd",["/c","start","","/b",t,...e],{cwd:n,stdio:"ignore",windowsHide:!0}):kb(t,e,{cwd:n,detached:!0,stdio:"ignore"})).unref()}function ur(){return $e.join($e.dirname(sP(import.meta.url)),"index.js")}function _b(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 Rb(t){return{command:process.execPath,args:[ur(),`agent:${t}`,"--no-open"]}}async function Ib(t,e,n,r){let s=await t();if(s)return s;lP(e.command,e.args,n);let i=Date.now()+2e4;for(;Date.now()<i;){await Pb(150);let o=await t();if(o)return o}throw new Error(`Launched ${r} but it did not register within 20s.`)}async function wn(t,e={}){let n=e.cwd??process.cwd(),r=$e.resolve(n,t),s=await or({kind:"bulb",file:r},n),[i]=await la(r,s),o={...e,mode:e.mode??i?.mode};return Ib(async()=>bn(await G(),r)[0],_b(t,o),n,$e.basename(t))}async function Bs(t,e=process.cwd()){return Ib(()=>aa(e,t),Rb(t),e,`the ${t} mirror`)}var xb,iP,Eb,aP,Pb,Ie=S(()=>{"use strict";je();gn();sa();xb=1e6;iP=/^── run (\d+) ── /;Eb=6e3,aP=500;Pb=t=>new Promise(e=>setTimeout(e,t))});function dr(t){return{...Vp(t),server:t.files.get("server.ts")??""}}function ca(t){return!!t.server&&!t.code}var js=S(()=>{"use strict";te();te()});function ua(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 kd(t){return er(ua(t)??"bulb")||"bulb"}var xd=S(()=>{"use strict";te()});import{readdirSync as cP,readFileSync as uP,statSync as dP}from"fs";import{join as $b,basename as fP}from"path";function Lb(t,e,n){if(e>8)return n;let r;try{r=cP(t,{withFileTypes:!0})}catch{return n}for(let s of r)if(s.isDirectory()){if(s.name.startsWith(".")||s.name==="node_modules")continue;Lb($b(t,s.name),e+1,n)}else s.isFile()&&s.name.endsWith(".bulb.md")&&n.push($b(t,s.name));return n}function pP(t,e){let n,r=!1;try{let s=uP(t,"utf8");n=ua(s.slice(0,1024));let i=ze(s);r=!!i&&ca(dr(i))}catch{}return{mtime:e,name:n??fP(t).replace(/\.bulb\.md$/,""),serverOnly:r}}function da(t){let e=new Map,n=Lb(t,0,[]).map(r=>{let s=0;try{s=dP(r).mtimeMs}catch{}let i=s?Nb.get(r):void 0,o=i?.mtime===s?i:pP(r,s);return s&&e.set(r,o),{path:r,...o}});return Nb=e,n}var Nb,Mb=S(()=>{"use strict";te();js();xd();Nb=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 fa=S(()=>{"use strict"});import{readFile as hP}from"fs/promises";async function Ed(t){try{let e=ze(await hP(t,"utf-8"));return e?fr(dr(e)):void 0}catch{return}}var Db=S(()=>{"use strict";js();fa()});function Ad(t){let e=t.split(""),n=(i,o)=>{for(let a=i;a<o&&a<e.length;a++)e[a]!==`
|
|
332
332
|
`&&(e[a]=" ")},r=0,s="";for(;r<t.length;){let i=t[r],o=t[r+1];if(i==="/"&&o==="/"){let a=r;for(;a<t.length&&t[a]!==`
|
|
333
|
-
`;)a++;n(r,a),r=a}else if(i==="/"&&o==="*"){let a=r+2;for(;a<t.length&&!(t[a]==="*"&&t[a+1]==="/");)a++;n(r,Math.min(a+2,t.length)),r=a+2}else if(i==="/"&&
|
|
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==="/"&&mP.has(s)){let a=r+1,l=!1;for(;a<t.length&&t[a]!==`
|
|
334
334
|
`;){let c=t[a];if(c==="\\")a++;else if(c==="[")l=!0;else if(c==="]")l=!1;else if(c==="/"&&!l)break;a++}r=a+1,s="/"}else if(i==='"'||i==="'"){let a=r+1;for(;a<t.length&&t[a]!==i&&t[a]!==`
|
|
335
|
-
`;)t[a]==="\\"&&a++,a++;r=a+1,s=i}else if(i==="`"){let a=
|
|
336
|
-
`).length-1}));return r}function
|
|
335
|
+
`;)t[a]==="\\"&&a++,a++;r=a+1,s=i}else if(i==="`"){let a=Bb(t,r);n(r,a),r=a,s="`"}else/\s/.test(i)||(s=i),r++}return e.join("")}function Bb(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=Bb(t,n);continue}if(s==="$"&&t[n+1]==="{"){r++,n+=2;continue}if(s==="}"&&r>0){r--,n++;continue}n++}return t.length}var mP,jb=S(()=>{mP=new Set(["","(",",","=",":","[","!","&","|","?",";","{"])});function bP(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 Fb(t){let e=[];for(let s of yP)for(let i of t.matchAll(s)){let o=bP(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 Ub(t){return Fb(Ad(t)).map(e=>e.root)}function Fs(t,e){if(!t)return[];let{target:n,dependencies:r}=e,s=(e.lineOffset??1)-1,i=[],o=t.split(`
|
|
337
337
|
`),a=Ad(t).split(`
|
|
338
|
-
`);for(let l=0;l<o.length;l++){let c=a[l],f=l+1+s;for(let d of
|
|
339
|
-
`)).filter(({root:i})=>!s.has(i)).map(({root:i,lineIndex:o})=>{let a=o+1+r;return{type:"UNDECLARED_IMPORT",severity:"error",message:
|
|
338
|
+
`);for(let l=0;l<o.length;l++){let c=a[l],f=l+1+s;for(let d of gP)d.targets.includes(n)&&d.pattern.test(c)&&i.push({type:d.type,severity:"error",message:SP(d.type,f),lineNumber:f,lineContent:o[l]})}return n==="client"&&r&&i.push(...wP(a,o,r,s)),i}function wP(t,e,n,r){let s=new Set(Object.keys(n));return Fb(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:vP(i,a),lineNumber:a,lineContent:e[o]}})}function vP(t,e){return`Import "${t}" is not declared in config.json dependencies! Found on line ${e}.
|
|
340
340
|
|
|
341
341
|
**CRITICAL**: Every bare import in code.tsx must be declared in the **config.json** "dependencies" block. A bulb that imports a package it doesn't declare is incomplete \u2014 it won't type-check, its versions aren't pinned, and it can't be reliably re-run or ported to typebulb.com.
|
|
342
342
|
|
|
@@ -350,7 +350,7 @@ Sec-WebSocket-Version: 13\r
|
|
|
350
350
|
}
|
|
351
351
|
\`\`\`
|
|
352
352
|
|
|
353
|
-
**Fix:** Add a **config.json** block (or extend the existing one) with a "dependencies" entry for "${t}" \u2014 and for every other bare import in code.tsx. Pin a real version where you can (e.g. "react": "^19.2.7").`}function
|
|
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 SP(t,e){return t==="URL_IMPORT"?`Direct URL imports are not supported! Found on line ${e}.
|
|
354
354
|
|
|
355
355
|
**CRITICAL**: Import packages by name only. Do NOT use CDN URLs:
|
|
356
356
|
|
|
@@ -504,22 +504,22 @@ import { something } from 'module-name'
|
|
|
504
504
|
const something = require('module-name') // NOT SUPPORTED!
|
|
505
505
|
\`\`\`
|
|
506
506
|
|
|
507
|
-
**Fix:** Replace all \`require()\` calls with ES6 \`import\` statements at the top of the file.`}var vn,Sn,
|
|
508
|
-
`)}var hr
|
|
507
|
+
**Fix:** Replace all \`require()\` calls with ES6 \`import\` statements at the top of the file.`}var vn,Sn,gP,yP,pa=S(()=>{jb();vn=["client"],Sn=["client","server"],gP=[{type:"DYNAMIC_IMPORT",pattern:/\bimport\s*\(\s*['"`]/,targets:vn},{type:"COMMONJS_REQUIRE",pattern:/\brequire\s*\(\s*['"`]/,targets:Sn},{type:"JS_EXTENSION_IMPORT",pattern:/from\s+['"][^'"]*\/[^'"]*\.js['"]/,targets:vn},{type:"URL_IMPORT",pattern:/from\s+['"]https?:\/\//,targets:vn},{type:"VERSION_SPECIFIER_IMPORT",pattern:/from\s+['"][^'"]*@[\d^~]/,targets:vn},{type:"REDUNDANT_TB_DECLARATION",pattern:/declare\s+(const|var|let)\s+tb\b/,targets:Sn},{type:"CONST_ENUM",pattern:/\bconst\s+enum\b/,targets:Sn},{type:"NAMESPACE_DECLARATION",pattern:/\bnamespace\s+\w+/,targets:Sn},{type:"COMMONJS_EXPORT_EQUALS",pattern:/\bexport\s*=/,targets:Sn},{type:"COMMONJS_IMPORT_EQUALS",pattern:/\bimport\s+\w+\s*=/,targets:Sn},{type:"MODULE_DECLARATION",pattern:/\bmodule\s+\w+\s*\{/,targets:Sn},{type:"CSS_FILE_IMPORT",pattern:/(?:from|import)\s+['"][^'"]*\.css['"]/,targets:vn},{type:"NAVIGATION",pattern:/window\.(location\.(reload|assign|replace)\s*\(|open\s*\()/,targets:vn},{type:"NAVIGATION",pattern:/window\.location(\.href)?\s*=[^=]/,targets:vn}],yP=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g]});function Td(t){let e=ze(t);if(!e)return t;let n=e.files.get("code.tsx");if(!n)return t;let r=Ub(n);if(!r.length)return t;let s=e.files.get("config.json"),i={};if(s)try{let c=JSON.parse(s);c&&typeof c=="object"&&(i=c)}catch{}let o=i.dependencies&&typeof i.dependencies=="object"?{...i.dependencies}:{},a=r.filter(c=>!(c in o));if(!a.length)return t;for(let c of a)o[c]="latest";i.dependencies=o;let l={name:e.frontmatter.name};for(let[c,f]of e.files){let d=Jp(c);d&&(l[d]=f)}return l.config=JSON.stringify(i,null,2),Qp(l)}var qb=S(()=>{"use strict";te();pa()});import{spawn as Jb}from"child_process";import{basename as kP}from"path";function xP(){return process.env.TYPEBULB_EDITOR||"code"}function AP(t,e,n){return n==null?[e]:EP.test(kP(t))?["-g",`${e}:${n}`]:[`+${n}`,e]}function TP(t,e){let n=xP();return{command:n,args:AP(n,t,e)}}function Cd(t,e){let{command:n,args:r}=TP(t,e),s=process.platform==="win32"?Jb("cmd.exe",["/d","/s","/c",n,...r],{detached:!0,stdio:"ignore",windowsHide:!0}):Jb(n,r,{detached:!0,stdio:"ignore"});s.on("error",i=>console.error("[typebulb] editor launch failed:",i?.message??i)),s.unref()}var EP,Wb=S(()=>{"use strict";EP=/^(code|code-insiders|codium|vscodium|cursor|windsurf)(\.cmd|\.exe)?$/i});import{readFileSync as CP,writeFileSync as OP,mkdirSync as PP,statSync as _P}from"fs";import{join as RP}from"path";function Od(){return RP(Ge(),"trust.json")}function Pd(){try{let t=Od(),e=_P(t).mtimeMs;if(Us?.mtime!==e){let n=JSON.parse(CP(t,"utf8"));Us={mtime:e,set:new Set(Array.isArray(n)?n:[])}}return Us.set}catch{return Us=void 0,new Set}}function IP(t){try{PP(Ge(),{recursive:!0}),OP(Od(),JSON.stringify([...t])),Us=void 0}catch(e){throw new Error(`can't write ${Od()} \u2014 trust not remembered (unwritable home; sandboxed shell?): ${e.message}`)}}function kn(t){return Pd().has(se(t))}function pr(t,e){let n=new Set(Pd()),r=se(t);(e?n.has(r):!n.has(r))||(e?n.add(r):n.delete(r),IP(n))}function _d(){return[...Pd()]}var Us,qs=S(()=>{"use strict";je()});function mr(t){return(t.includes("://")?t:`http://${t}`).replace(/\/+$/,"")}function Rd(){return Ws}async function bt(){let[t,e]=await Promise.all([Hb(),jP()]);return BP([...FP(e),...t],process.env.TB_AI_PROVIDER,process.env.TB_AI_MODEL)}function BP(t,e,n){return!e||!n?t:t.map(r=>r.provider===e&&r.name===n?{...r,default:!0}:r)}async function Kb(){let t;try{t=await fetch($P,{signal:AbortSignal.timeout(LP)})}catch(e){Ws=`catalog fetch failed: ${e?.message??e}`;return}if(!t.ok){Ws=`catalog fetch failed: HTTP ${t.status}`;return}try{return await t.json()}catch(e){Ws=`catalog returned an unreadable body: ${e?.message??e}`;return}}async function jP(){if(Js&&Date.now()-Js.fetchedAt<=NP)return Js.models;let t=await Kb()??await Kb();return t?(Js={models:t,fetchedAt:Date.now()},Ws=void 0,t):Js?.models??[]}async function Hb(){if(ha&&Date.now()-ha.fetchedAt<=MP)return ha.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(DP)});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 ha={models:e,fetchedAt:Date.now()},e}function FP(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 Id(){return Object.values(hr).some(t=>!!process.env[t])}async function ma(){return Id()||process.env.TB_AI_BASE_URL||(await Hb()).length>0?"own":"none"}function zb(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,$P,NP,LP,MP,DP,Js,ha,Ws,xn=S(()=>{"use strict";hr={anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY",gemini:"GOOGLE_API_KEY",openrouter:"OPENROUTER_API_KEY"};$P="https://api.typebulb.com/api/models",NP=1440*60*1e3,LP=5e3,MP=60*1e3,DP=1500});var Yb,Vb,at,En=S(()=>{Yb=t=>t!=null&&t>=0&&t<=4?t:void 0,Vb=(t,e)=>{let n={...t};for(let r of["input","output","reasoning","cacheRead"])e[r]!==void 0&&(n[r]=e[r]);return n},at=t=>t===void 0||t.input===void 0&&t.output===void 0?void 0:{input:t.input??0,output:t.output??0,reasoning:t.reasoning,cacheRead:t.cacheRead}});var Ne,Qe,gr=S(()=>{Ne=class extends Error{constructor(e,n="unknown",r=!1){super(e),this.code=n,this.retryable=r}},Qe=class{getPath(e,n){return this.path}parseError(e,n){return this.parseJsonError(e,n)}parseStreamChunk(e){return this.checkAndThrowError(e),this.parseProviderStreamChunk(e)}extractSystemMessages(e,n=`
|
|
509
509
|
|
|
510
|
-
`){let r=e.filter(s=>s.role==="system").map(s=>s.content);return{system:r.length?r.join(n):void 0,conversationMessages:e.filter(s=>s.role!=="system")}}parseJsonError(e,n){if(!e)return{message:`HTTP ${n}`};try{let r=JSON.parse(e);return r.error&&typeof r.error=="object"?{message:r.error.message||`HTTP ${n}`,type:r.error.type}:r.message?{message:r.message}:{message:e}}catch{return{message:e}}}checkAndThrowError(e){if(typeof e!="object"||e===null)return;let n=e;if(n.type==="error"&&"message"in n){let r=n.code||"unknown";throw new Ne(n.message,r,!!n.retryable)}if(n.error){let r=n.error,s=typeof r=="object"&&r!==null?String(r.type??r.code??""):"",i=/rate_limit|too_many_requests/i.test(s),o=/overloaded|server_error|unavailable/i.test(s),a=/context_length/i.test(s);throw new Ne(this.extractErrorMessage(n.error),i?"rate_limit":a?"context_exceeded":"unknown",i||o)}}extractErrorMessage(e){if(typeof e=="string")try{let n=JSON.parse(e);return n.error?.message||n.message||e}catch{return e}return typeof e=="object"&&e!==null?e.message||JSON.stringify(e):`${this.providerName} returned an error`}}});var
|
|
510
|
+
`){let r=e.filter(s=>s.role==="system").map(s=>s.content);return{system:r.length?r.join(n):void 0,conversationMessages:e.filter(s=>s.role!=="system")}}parseJsonError(e,n){if(!e)return{message:`HTTP ${n}`};try{let r=JSON.parse(e);return r.error&&typeof r.error=="object"?{message:r.error.message||`HTTP ${n}`,type:r.error.type}:r.message?{message:r.message}:{message:e}}catch{return{message:e}}}checkAndThrowError(e){if(typeof e!="object"||e===null)return;let n=e;if(n.type==="error"&&"message"in n){let r=n.code||"unknown";throw new Ne(n.message,r,!!n.retryable)}if(n.error){let r=n.error,s=typeof r=="object"&&r!==null?String(r.type??r.code??""):"",i=/rate_limit|too_many_requests/i.test(s),o=/overloaded|server_error|unavailable/i.test(s),a=/context_length/i.test(s);throw new Ne(this.extractErrorMessage(n.error),i?"rate_limit":a?"context_exceeded":"unknown",i||o)}}extractErrorMessage(e){if(typeof e=="string")try{let n=JSON.parse(e);return n.error?.message||n.message||e}catch{return e}return typeof e=="object"&&e!==null?e.message||JSON.stringify(e):`${this.providerName} returned an error`}}});var ga,$d=S(()=>{En();gr();ga=class extends Qe{constructor(){super(...arguments),this.providerName="OpenAI",this.defaultBaseUrl="https://api.openai.com",this.path="/v1/responses",this.effortMap={0:"none",1:"low",2:"medium",3:"high",4:"xhigh"}}buildHeaders(e){return{Authorization:`Bearer ${e}`,"Content-Type":"application/json",Accept:"application/json"}}buildPayload(e,n,r,s){let i=this.convertMessagesToInput(e),o={model:n,input:i,stream:s};if(r?.webSearch===!0&&(o.tools=[{type:"web_search"}]),r?.effort!==void 0){let a=this.effortMap[r.effort];o.reasoning=a==="none"?{effort:a}:{effort:a,summary:"auto"}}return r?.maxOutputTokens!==void 0&&(o.max_output_tokens=r.maxOutputTokens),o}parseNonStreamingResponse(e){if(!this.isResponsesApiResponse(e))return{text:""};let n=e.output_text||"",r;if(e.output&&Array.isArray(e.output))for(let s of e.output)s.type==="reasoning"&&s.summary&&(r=s.summary.map(i=>i.text).join(`
|
|
511
511
|
`)),!n&&s.type==="message"&&s.content&&(n=s.content.filter(i=>i.type==="output_text").map(i=>i.text).join(""));return{text:n,reasoning:r,usage:this.mapUsage(e.usage)}}parseProviderStreamChunk(e){if(this.isResponsesApiEvent(e))switch(e.type){case"response.failed":{let r=e.response?.error,s=r?.message||"Response failed",i=r?.code==="insufficient_quota"||r?.code==="rate_limit_exceeded";throw new Ne(s,i?"rate_limit":"unknown",i)}case"response.output_text.delta":return{text:e.delta};case"response.reasoning_summary_text.delta":return{reasoning:e.delta};case"response.completed":{let n=this.mapUsage(e.response?.usage);return n?{usage:n}:void 0}default:return}}mapUsage(e){if(e)return at({input:e.input_tokens,output:e.output_tokens,reasoning:e.output_tokens_details?.reasoning_tokens,cacheRead:e.input_tokens_details?.cached_tokens})}convertMessagesToInput(e){return e.map(n=>n.role==="system"?`System: ${n.content}`:n.role==="user"?`User: ${n.content}`:n.role==="assistant"?`Assistant: ${n.content}`:n.content).join(`
|
|
512
512
|
|
|
513
|
-
`)}isResponsesApiEvent(e){return typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string"}isResponsesApiResponse(e){return typeof e=="object"&&e!==null&&e.object==="response"}}});var yr,
|
|
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,ya=S(()=>{En();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 at({input:e.prompt_tokens,output:e.completion_tokens,reasoning:e.completion_tokens_details?.reasoning_tokens,cacheRead:e.prompt_tokens_details?.cached_tokens})}}});var Nd,ba,Ld=S(()=>{ya();Nd={"HTTP-Referer":"https://typebulb.com","X-OpenRouter-Title":"Typebulb"},ba=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",...Nd}}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 wa,Md=S(()=>{En();gr();wa=class extends Qe{constructor(){super(...arguments),this.providerName="Anthropic",this.defaultBaseUrl="https://api.anthropic.com",this.path="/v1/messages"}buildHeaders(e){return{"x-api-key":e,"anthropic-version":"2023-06-01","Content-Type":"application/json",Accept:"application/json"}}buildPayload(e,n,r,s){let{system:i,conversationMessages:o}=this.extractSystemMessages(e),a={model:n,max_tokens:Math.min(this.getMaxTokens(n),r?.maxOutputTokens??1/0),messages:this.withTailMessagesCached(o),stream:s};r?.webSearch===!0&&(a.tools=[{type:"web_search_20250305",name:"web_search"}]),i&&(a.system=[{type:"text",text:i,cache_control:{type:"ephemeral"}}]);let l=r?.effort;if(l!==void 0){if(this.isModernModel(n))if(l===0)this.alwaysThinks(n)||(a.thinking={type:"disabled"}),a.output_config={effort:"low"};else{let c={1:"low",2:"medium",3:"high",4:"max"};a.thinking={type:"adaptive",display:"summarized"},a.output_config={effort:c[l]}}else if(l!==0){let c={1:2048,2:4096,3:8192,4:16384};a.thinking={type:"enabled",budget_tokens:c[l]}}}return a}parseNonStreamingResponse(e){if(!this.isAnthropicResponse(e))return{text:""};let n=e.content.filter(s=>s.type==="text").map(s=>s.text).join(""),r=e.content.filter(s=>s.type==="thinking").map(s=>s.thinking).join(`
|
|
514
514
|
|
|
515
|
-
`);return{text:n,reasoning:r||void 0,usage:at(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
|
|
515
|
+
`);return{text:n,reasoning:r||void 0,usage:at(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 va,Dd=S(()=>{En();gr();va=class extends Qe{constructor(){super(...arguments),this.providerName="Gemini",this.defaultBaseUrl="https://generativelanguage.googleapis.com",this.path="/v1beta/models",this.budgetMap={0:0,1:1024,2:8192,3:-1,4:-1}}getPath(e,n){return`/v1beta/models/${e}:${n?"streamGenerateContent":"generateContent"}${n?"?alt=sse":""}`}buildHeaders(e){return{"Content-Type":"application/json","x-goog-api-key":e}}buildPayload(e,n,r,s){let{system:i,conversationMessages:o}=this.extractSystemMessages(e,`
|
|
516
516
|
`),l={contents:o.map(f=>({role:f.role==="assistant"?"model":"user",parts:[{text:f.content}]}))};r?.webSearch===!0&&(l.tools=[{google_search:{}}]),i&&(l.systemInstruction={role:"system",parts:[{text:i}]});let c=r?.effort;if(c!==void 0){let f=this.geminiVersion(n),d=f!==void 0&&f>=3?{thinkingLevel:this.thinkingLevelFor(f,c)}:{thinkingBudget:this.budgetMap[c]};l.generationConfig={thinkingConfig:c===0?d:{includeThoughts:!0,...d}}}return r?.maxOutputTokens!==void 0&&(l.generationConfig={...l.generationConfig,maxOutputTokens:r.maxOutputTokens}),l}parseError(e,n){if(!e)return{message:`HTTP ${n}`};try{let r=JSON.parse(e),s=Array.isArray(r)?r[0]?.error:r?.error;return s&&typeof s=="object"?{message:(s.message||`HTTP ${n}`).split(`
|
|
517
|
-
`)[0],type:s.status,code:s.code?.toString()}:r.message?{message:r.message}:{message:e}}catch{return{message:e}}}parseNonStreamingResponse(e){if(this.checkAndThrowError(e),this.checkGeminiError(e),!this.isGeminiResponse(e))return{text:"",status:"failed",error:"Invalid response format"};let n=this.extractParts(e).text||"",r=e.candidates?.[0]?.finishReason,s="complete";return r==="MAX_TOKENS"?s="interrupted":(r==="SAFETY"||r==="RECITATION")&&(s="failed"),{text:n,status:s,usage:this.mapUsage(e.usageMetadata)}}parseProviderStreamChunk(e){if(this.checkGeminiError(e),!this.isGeminiResponse(e))return;let n=this.extractParts(e),r=this.mapUsage(e.usageMetadata);return r&&(n.usage=r),n.text||n.reasoning||n.usage?n:void 0}mapUsage(e){if(!e)return;let n=e.candidatesTokenCount!==void 0||e.thoughtsTokenCount!==void 0;return at({input:e.promptTokenCount,output:n?(e.candidatesTokenCount??0)+(e.thoughtsTokenCount??0):void 0,reasoning:e.thoughtsTokenCount,cacheRead:e.cachedContentTokenCount})}geminiVersion(e){let n=e.match(/^gemini-(\d+(?:\.\d+)?)/);return n?Number(n[1]):void 0}thinkingLevelFor(e,n){let r=["minimal","low","medium","high","high"][n];return r==="minimal"&&e<3.5?"low":r}isGeminiResponse(e){return typeof e=="object"&&e!==null&&"candidates"in e&&Array.isArray(e.candidates)}extractParts(e){let n=e.candidates?.[0]?.content?.parts;if(!n)return{};let r="",s="";for(let i of n)i.text&&(i.thought?s+=i.text:r+=i.text);return{text:r||void 0,reasoning:s||void 0}}checkGeminiError(e){if(this.isGeminiResponse(e)&&e.promptFeedback?.blockReason){let n=e.promptFeedback.blockReason;throw new Ne(`Prompt blocked: ${n}`)}}}});var
|
|
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 at({input:e.promptTokenCount,output:n?(e.candidatesTokenCount??0)+(e.thoughtsTokenCount??0):void 0,reasoning:e.thoughtsTokenCount,cacheRead:e.cachedContentTokenCount})}geminiVersion(e){let n=e.match(/^gemini-(\d+(?:\.\d+)?)/);return n?Number(n[1]):void 0}thinkingLevelFor(e,n){let r=["minimal","low","medium","high","high"][n];return r==="minimal"&&e<3.5?"low":r}isGeminiResponse(e){return typeof e=="object"&&e!==null&&"candidates"in e&&Array.isArray(e.candidates)}extractParts(e){let n=e.candidates?.[0]?.content?.parts;if(!n)return{};let r="",s="";for(let i of n)i.text&&(i.thought?s+=i.text:r+=i.text);return{text:r||void 0,reasoning:s||void 0}}checkGeminiError(e){if(this.isGeminiResponse(e)&&e.promptFeedback?.blockReason){let n=e.promptFeedback.blockReason;throw new Ne(`Prompt blocked: ${n}`)}}}});var Sa,Bd=S(()=>{ya();Sa=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 An(t){let e=UP.get(t);if(!e)throw new Error(`Unsupported protocol: ${t}`);return e}function qP(t,e){return t.replace(/\/+$/,"")+(e.startsWith("/")?e:`/${e}`)}async function jd(t,e){let n=An(t.protocol),r=n.getPath(t.model,e.stream),s=qP(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 JP(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=An(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||JP(s))&&(o="context_exceeded"),{code:o,message:s,retryable:i===429||i>=500}}var Gb,UP,Fd=S(()=>{$d();Ld();Md();Dd();Bd();Gb=new Sa,UP=new Map([["openai",new ga],["openrouter",new ba],["anthropic",new wa],["gemini",new va],["ollama",Gb],["openai-compat",Gb]])});function Xb(t){let e=t.indexOf(`\r
|
|
518
518
|
\r
|
|
519
519
|
`),n=t.indexOf(`
|
|
520
520
|
|
|
521
521
|
`);return e!==-1&&(n===-1||e<n)?{pos:e,len:4}:n!==-1?{pos:n,len:2}:{pos:-1,len:0}}function Ud(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*
|
|
522
|
+
`).trim();if(r){if(r==="[DONE]")return"done";try{return JSON.parse(r)}catch{return}}}async function*Qb(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=Ud(s);d!==void 0&&d!=="done"&&(yield d)}return}n?.(),s+=r.decode(l,{stream:!0});let{pos:c,len:f}=Xb(s);for(;c!==-1;){let d=s.slice(0,c);s=s.slice(c+f);let u=Ud(d);if(u==="done")return;u!==void 0&&(yield u),{pos:c,len:f}=Xb(s)}}}finally{i&&e?.removeEventListener("abort",i);try{await t.cancel()}catch{}}}async function qd(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 Tn(t,e))s.kind==="text"?n+=s.text:s.kind==="usage"&&(r=s.usage);return{text:n,usage:r}}async function*Tn(t,e){let n=e??(t.headers.get("X-Provider-Protocol")||"openai"),r=An(n);if(!t.body)return;let s=t.body.getReader(),i;for await(let a of Qb(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=Vb(i,l.usage))}let o=at(i);o&&(yield{kind:"usage",usage:o})}var Zb=S(()=>{En();Fd()});import{strToU8 as WP,strFromU8 as KP,deflateSync as HP,inflateSync as zP}from"fflate";function Wd(t,e){let n=[];if(n.push(`You are a data processor. Follow the instructions to analyze the provided data. Output valid JSON that the code can consume.
|
|
523
523
|
|
|
524
524
|
---
|
|
525
525
|
Instructions:
|
|
@@ -537,12 +537,12 @@ ${r}
|
|
|
537
537
|
</data>`)}return n.push(`
|
|
538
538
|
Output only valid JSON. No explanation, no markdown fences, just the JSON object. Every number must be a JSON literal \u2014 never an expression like 2 * pi; write the computed decimal instead.`),n.join(`
|
|
539
539
|
|
|
540
|
-
`)}function
|
|
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
|
|
540
|
+
`)}function Ks(t){try{return JSON.parse(t)}catch{return}}function ew(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 VP(t){let e=ew(t,n=>n.replace(/,(\s*[}\]])/g,"$1"));return e!==t?e:void 0}function GP(t){let e=ew(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 XP(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 QP(t){let e,n=0;for(;n<t.length;){let r=t[n];if(r==="{"||r==="["){let s=XP(t,n);if(s!==-1){let i=t.slice(n,s+1),o=Ks(i);o!==void 0&&(e={parsed:o,json:i}),n=s+1;continue}}n++}return e}function Kd(t){let e=[],n=t.trim();n.startsWith("```")&&(n=n.replace(/^```(?:json)?\s*\n?/,"").replace(/\n?```\s*$/,""),e.push("markdown fences"));let r=Ks(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=Ks(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=Ks(n),r!==void 0))return{parsed:r,json:n,fixesApplied:e}}for(let[o,a]of YP){let l=a(n);if(l!==void 0){let c=Ks(l);if(c!==void 0)return{parsed:c,json:l,fixesApplied:[...e,o]}}}let i=QP(t);return i!==void 0?{...i,fixesApplied:[...e,"extracted last JSON value"]}:{parsed:void 0,json:n,fixesApplied:e}}function Hd(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=HP(WP(n),{level:9}),s=e_(r),i=`${tw}:${s}`;return i.length>ZP?"":"#"+Jd+i}catch{return""}}function zd(t){try{let e=t.startsWith("#")?t.slice(1):t;if(!e.startsWith(Jd))return;let n=e.slice(Jd.length),r=n.indexOf(":");if(r===-1||n.slice(0,r)!==tw)return;let s=t_(n.slice(r+1)),i=JSON.parse(KP(zP(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 e_(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 t_(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 YP,Jd,tw,ZP,nw=S(()=>{YP=[["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",VP],["arithmetic constants",GP]];Jd="tb=",tw="1",ZP=6e4});var Wt=S(()=>{En();gr();Fd();Zb();nw();ya();Md();Dd();$d();Ld();Bd()});import{readFileSync as rw,existsSync as n_}from"fs";import*as lt from"path";function sw(t){return[...t?[`.env.${t}.local`,`.env.${t}`]:[],".env.local",".env"]}function we(t,e=process.cwd()){let n={},r=[];for(let s of sw(t)){let i;try{i=rw(lt.resolve(e,s),"utf-8")}catch{continue}r.push(s);for(let[o,a]of iw(i))process.env[o]===void 0&&(process.env[o]=a,n[o]=s)}return{mode:t,sources:n,loaded:r}}function*iw(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 ka(t,e=process.cwd()){for(let n of sw()){let r;try{r=rw(lt.resolve(e,n),"utf-8")}catch{continue}for(let[s,i]of iw(r))if(s===t)return i}return process.env[t]}function r_(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 ow(){return`.env loads from ${process.cwd()} (the directory you ran from, not the bulb's)`}function Kt(t,e,n){let{sources:r,mode:s,loaded:i}=t,o=process.cwd(),a=lt.dirname(e),l=`(mode: ${s??"none"})`,c=n?r_(n):[],f=c.filter(p=>r[p]).map(p=>`${p} \u2190 ${r[p]}`);f.length?console.log(`env: ${f.join(", ")} ${l}`):i.length&&console.log(`env: loaded ${i.join(", ")} ${l}`),s&&!i.some(p=>p===`.env.${s}`||p===`.env.${s}.local`)&&console.log(`env: mode=${s} \u2014 no .env.${s} found; using .env`);let d=lt.resolve(a)!==lt.resolve(o);if(d)for(let p of[".env.local",".env"])n_(lt.join(a,p))&&console.log(`env: ${lt.join(a,p)} present but not loaded (cwd is ${o})`);let u=c.filter(p=>process.env[p]===void 0);if(u.length){let p=d?` \u2014 try running from ${a}`:"";console.log(`env: server.ts reads ${u.join(", ")} but ${u.length>1?"they are":"it's"} unset${p}`)}}var Ze=S(()=>{"use strict"});function wt(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=An(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 ${ow()}.`}function Ht(t,e){let n=[...e.system?[{role:"system",content:e.system}]:[],...e.messages.map(r=>({role:r.role,content:r.content}))];return jd(t,{messages:n,stream:!0,effort:Yb(e.effort),webSearch:e.webSearch,signal:e.signal})}var xa=S(()=>{"use strict";Wt();Wt();Ze();xn()});import{readFileSync as TF,existsSync as s_}from"fs";import*as vr from"path";import{fileURLToPath as i_}from"url";function o_(){let t=vr.dirname(i_(import.meta.url));for(;!s_(vr.join(t,"package.json"));){let e=vr.dirname(t);if(e===t)break;t=e}return t}function Hs(){return vr.join(o_(),"SKILL.md")}var Yd=S(()=>{"use strict"});import{transform as a_}from"sucrase";function Vd(t,e={}){let n=e.serverOnly?["typescript"]:["typescript","jsx"];try{let{code:r}=a_(t,{transforms:n,jsxRuntime:"automatic",jsxImportSource:e.jsxImportSource||"react",production:!0});return{code:r}}catch(r){return{code:"",error:String(r)}}}var aw=S(()=>{});function l_(t){return t.map(e=>`${e.type} (line ${e.lineNumber}): ${e.message.split(`
|
|
542
542
|
`)[0]}`).join(`
|
|
543
|
-
`)}function
|
|
544
|
-
${o_(n)}`)}var lw=S(()=>{"use strict";da()});var Ht,Ks,Gd,Hs=S(()=>{Ht="https://esm.sh",Ks="https://cdn.jsdelivr.net/npm/",Gd="https://data.jsdelivr.com/v1/package/npm/"});function cw(t){let e=(t||"").replace(/^\/+/,"").replace(/\/+$/,"");return e?e.split("/"):[]}var F,Sr,uw,zs=S(()=>{Hs();F=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=cw(e||"");if(!n.length)return new t({name:""});if(n[0].startsWith("@")){let s=n[0],[i,o]=uw(n[1]??""),a=Sr(n.slice(2).join("/"));return new t({name:`${s}/${i}`,version:o,subpath:a})}else{let[s,i]=uw(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(Ht).host,s=new URL(Ks).host;if(n.host===r){let i=cw(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,uw=t=>{let e=t.indexOf("@");return e<0?[t,void 0]:[t.slice(0,e),Sr(t.slice(e+1))]}});async function Pe(t){try{return await t()}catch{return}}var ka=S(()=>{});function Cn(t){let e=t||"";return e.startsWith("./")?e.slice(2):e.replace(/^\/+/,"")}function Xd(t){return t.startsWith("./")?t:`./${t}`}var Ys,Qd=S(()=>{zs();ka();Hs();Ys=class{constructor(e,n){this.cache=e,this.http=n,this.pinMs=1e4,this.versionsIndexMs=1440*60*1e3,this.metaTtlMs=10080*60*1e3,this.pinCache=new Map}baseDir(e){let n=typeof e=="string"?new F(e):e;return`${Ks}${n.name}${n.version?`@${n.version}`:""}/`}file(e,n){return new URL(Cn(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(",")),`${Ht}/${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),`${Ht}/${e}`]);return this.pinCache.set(e,{value:s,ts:n}),s}async tryResolveFromUrls(e){for(let n of e){let r=await Pe(()=>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 Pe(()=>this.http.getJson(`${Gd}${encodeURIComponent(e)}`));if(!r?.versions?.length){await this.cache.recordNegative(e);return}await this.cache.clearNegative(e);let s=r.tags&&Object.keys(r.tags).length?r.tags:void 0;return await this.cache.setIndex(e,r.versions,s),{versions:r.versions,distTags:s}}parseVersionFromUrl(e){let n=F.fromUrl(e)?.version;return n&&/\d+\.\d+\.\d+/.test(n)?n:void 0}async fetchPackageMeta(e,n){let r=await this.cache.getMeta(e,n);if(r&&Date.now()-r.updatedAt<this.metaTtlMs){let{dependencies:f,peerDependencies:d,peerDependenciesMeta:u}=r;return{name:e,version:n,dependencies:f,peerDependencies:d,peerDependenciesMeta:u}}let s=this.packageJson(new F(`${e}@${n}`)),i=await Pe(()=>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 dw,Vs,Zd,a_,Gs,xa=S(()=>{dw=t=>t.startsWith("@types/"),Vs=t=>Object.keys(t?.peerDependencies||{}).filter(e=>!dw(e)),Zd=t=>Object.keys(t?.dependencies||{}).filter(e=>!dw(e)),a_=t=>Vs(t).filter(e=>!t?.peerDependenciesMeta?.[e]?.optional),Gs=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 a_(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=>Vs(i.meta))),r=new Map;for(let i of e)for(let o of Zd(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:Vs(i.meta).length>0,isSharedDep:s.has(i.name)}]))}}});var Xs,ef=S(()=>{zs();ka();Xs=class{constructor(e,n,r){this.cache=e,this.cdn=n,this.semver=r}async learnExactVersion(e){let n=await Pe(()=>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 Pe(()=>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 Pe(()=>this.cdn.fetchVersionsIndex(e));if(l?.versions?.length){let c=await i(this.semver.selectBestVersion(l.versions,{range:n,distTags:l.distTags}));if(c)return c}}}return i(await this.cdn.resolveExactVersion(`${e}@${n}`))}async effectivePackage(e,n){let r=new F(e),s=r.root(),i=n[s],o=i?await Pe(()=>this.resolveExactForRoot(s,i)):void 0;return{effectivePackage:o?r.withVersion(o).format():e,root:s,range:i,pinned:o}}}});import{init as l_,parse as c_}from"es-module-lexer";var kr,tf=S(()=>{zs();Hs();xa();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))F.isBare(s[1])&&n.add(s[1])}return Array.from(n)}async extractImports(e){let n=new Set,r=s=>{F.isBare(s)&&n.add(s)};try{await l_;let[s]=c_(e);s.forEach(i=>r(e.slice(i.s,i.e).trim()))}catch{return this.extractImportsSync(e)}return Array.from(n)}async buildImportMap(e,n,r){let s=(await this.extractImports(e)).filter(d=>!r?.has(F.rootOf(d))),i=[...new Set(s.map(F.rootOf))],o=await Promise.all(i.map(async d=>({name:d,version:await this.resolveVersion(d,n)}))),{allRoots:a,flags:l,autoAddedPeers:c}=await this.peer.resolve(o,d=>this.resolveVersion(d,n)),f=this.buildEntries([...s,...c.map(d=>d.name)],a,l);return{importMap:{imports:Object.fromEntries(f)},prefetchUrls:f.map(([,d])=>d)}}async resolveVersion(e,n){let r=n[e],s=await this.version.resolveExactForRoot(e,r);if(!s)throw new Error(`Cannot resolve ${r?`${e}@${r}`:e}: no matching version is published (the package or version may not exist, or the registry was unreachable).`);return s}buildEntries(e,n,r){let s=new Map(n.map(p=>[p.name,p])),i=p=>{let h=s.get(F.rootOf(p));return new F(p).withVersion(h.version).format()},o=new Set([...r.entries()].filter(([,p])=>p.isPeerRoot||p.isSharedDep).map(([p])=>p)),a=new Set(e.filter(p=>p!==F.rootOf(p)).map(F.rootOf)),l=[],c=new Set,f=new Set(e.filter(p=>p===F.rootOf(p))),d=new Set;for(let p of e){let h=F.rootOf(p),m=s.get(h),{isPeerRoot:g,hasPeers:v,isSharedDep:E}=r.get(h),P=a.has(h),A=p!==h,O=!(g||E)&&(P||!v),_=this.singletonDepsOf(m,o),k=A&&f.has(h);k&&d.add(h);let N=k?[..._,h]:_.length?_:void 0;l.push([p,this.cdn.buildEsmUrl(i(p),{bundle:O,external:N})]),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}/`,`${Ht}/${i(p)}/`]));return l}singletonDepsOf(e,n){return[...new Set([...Vs(e.meta),...Zd(e.meta)])].filter(r=>n.has(r))}};kr.importPatterns=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g]});import{gt as fw,satisfies as u_,maxSatisfying as pw,major as d_,valid as f_,validRange as p_}from"semver";var Ea,On,nf=S(()=>{Ea=class{cmp(e,n){return e===n?0:fw(e,n)?1:fw(n,e)?-1:0}satisfies(e,n){return!e||!e.trim()?!0:!!u_(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=pw(e,r,{includePrerelease:!1});if(a)return a}return pw(e,r,{includePrerelease:!0})??void 0}majorOf(e){return d_(e)}isExactVersion(e){return f_(e)!==null}isRange(e){return p_(e)!==null}},On=new Ea});function h_(t){return Math.min(9e5*Math.pow(2,Math.max(0,t-1)),864e5)}var Pn,hw=S(()=>{ka();Pn=class{constructor(e){this.store=e}async isNegative(e){let n=await Pe(()=>this.store.get(e));return!!n&&n.until>Date.now()}async recordNegative(e){let r=((await Pe(()=>this.store.get(e)))?.attempts||0)+1;await Pe(()=>this.store.set(e,{until:Date.now()+h_(r),attempts:r}))}async clearNegative(e){await Pe(()=>this.store.delete(e))}}});function mw(t,e){let n=new Ys(t,e),r=new Gs(n),s=new Xs(t,n,On);return{packageService:new kr(s,n,r),versionResolver:s,cdnClient:n,peerResolver:r}}var wt=S(()=>{Qd();xa();ef();tf();nf();zs();nf();Hs();Qd();xa();ef();tf();hw()});import*as rf from"fs/promises";import*as gw from"crypto";function et(t){return gw.createHash("sha1").update(t).digest("hex")}async function vt(t){try{return JSON.parse(await rf.readFile(t,"utf8"))}catch{return}}async function Aa(t){try{return await rf.readFile(t,"utf8")}catch{return}}var xr=S(()=>{"use strict"});import*as Yt from"fs/promises";import*as St from"path";import*as bw from"os";function ne(){return sf||(sf=g_().catch(()=>ht())),sf}function Ca(t,e){return St.join(m_,et(t),e)}async function g_(){await Yt.mkdir(zt,{recursive:!0});let t=St.join(zt,"version.json");if((await vt(t))?.version===yw)return;let n=await Yt.readdir(zt).catch(()=>[]);await Promise.all(n.map(r=>Yt.rm(St.join(zt,r),{recursive:!0,force:!0}))),await Yt.writeFile(t,JSON.stringify({version:yw})+`
|
|
545
|
-
`,"utf8")}var
|
|
543
|
+
`)}function lw(t,e){let n=Fs(t,{target:"client",dependencies:e}).filter(r=>r.type==="UNDECLARED_IMPORT");if(n.length)throw new Error(`Lint failed:
|
|
544
|
+
${l_(n)}`)}var cw=S(()=>{"use strict";pa()});var zt,zs,Gd,Ys=S(()=>{zt="https://esm.sh",zs="https://cdn.jsdelivr.net/npm/",Gd="https://data.jsdelivr.com/v1/package/npm/"});function uw(t){let e=(t||"").replace(/^\/+/,"").replace(/\/+$/,"");return e?e.split("/"):[]}var F,Sr,dw,Vs=S(()=>{Ys();F=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=uw(e||"");if(!n.length)return new t({name:""});if(n[0].startsWith("@")){let s=n[0],[i,o]=dw(n[1]??""),a=Sr(n.slice(2).join("/"));return new t({name:`${s}/${i}`,version:o,subpath:a})}else{let[s,i]=dw(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(zt).host,s=new URL(zs).host;if(n.host===r){let i=uw(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,dw=t=>{let e=t.indexOf("@");return e<0?[t,void 0]:[t.slice(0,e),Sr(t.slice(e+1))]}});async function Pe(t){try{return await t()}catch{return}}var Ea=S(()=>{});function Cn(t){let e=t||"";return e.startsWith("./")?e.slice(2):e.replace(/^\/+/,"")}function Xd(t){return t.startsWith("./")?t:`./${t}`}var Gs,Qd=S(()=>{Vs();Ea();Ys();Gs=class{constructor(e,n){this.cache=e,this.http=n,this.pinMs=1e4,this.versionsIndexMs=1440*60*1e3,this.metaTtlMs=10080*60*1e3,this.pinCache=new Map}baseDir(e){let n=typeof e=="string"?new F(e):e;return`${zs}${n.name}${n.version?`@${n.version}`:""}/`}file(e,n){return new URL(Cn(n),this.baseDir(e)).toString()}packageJson(e){return this.file(e,"package.json")}buildEsmUrl(e,n={}){let{target:r="es2022",bundle:s=!1,external:i}=n,o=new URLSearchParams({target:r});return s&&o.append("bundle",""),i?.length&&o.append("external",i.join(",")),`${zt}/${e}?${o.toString()}`}async resolveExactVersion(e){let n=Date.now(),r=this.pinCache.get(e);if(r&&n-r.ts<this.pinMs)return r.value;let s=await this.tryResolveFromUrls([this.buildEsmUrl(e),`${zt}/${e}`]);return this.pinCache.set(e,{value:s,ts:n}),s}async tryResolveFromUrls(e){for(let n of e){let r=await Pe(()=>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 Pe(()=>this.http.getJson(`${Gd}${encodeURIComponent(e)}`));if(!r?.versions?.length){await this.cache.recordNegative(e);return}await this.cache.clearNegative(e);let s=r.tags&&Object.keys(r.tags).length?r.tags:void 0;return await this.cache.setIndex(e,r.versions,s),{versions:r.versions,distTags:s}}parseVersionFromUrl(e){let n=F.fromUrl(e)?.version;return n&&/\d+\.\d+\.\d+/.test(n)?n:void 0}async fetchPackageMeta(e,n){let r=await this.cache.getMeta(e,n);if(r&&Date.now()-r.updatedAt<this.metaTtlMs){let{dependencies:f,peerDependencies:d,peerDependenciesMeta:u}=r;return{name:e,version:n,dependencies:f,peerDependencies:d,peerDependenciesMeta:u}}let s=this.packageJson(new F(`${e}@${n}`)),i=await Pe(()=>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 fw,Xs,Zd,c_,Qs,Aa=S(()=>{fw=t=>t.startsWith("@types/"),Xs=t=>Object.keys(t?.peerDependencies||{}).filter(e=>!fw(e)),Zd=t=>Object.keys(t?.dependencies||{}).filter(e=>!fw(e)),c_=t=>Xs(t).filter(e=>!t?.peerDependenciesMeta?.[e]?.optional),Qs=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 c_(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=>Xs(i.meta))),r=new Map;for(let i of e)for(let o of Zd(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:Xs(i.meta).length>0,isSharedDep:s.has(i.name)}]))}}});var Zs,ef=S(()=>{Vs();Ea();Zs=class{constructor(e,n,r){this.cache=e,this.cdn=n,this.semver=r}async learnExactVersion(e){let n=await Pe(()=>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 Pe(()=>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 Pe(()=>this.cdn.fetchVersionsIndex(e));if(l?.versions?.length){let c=await i(this.semver.selectBestVersion(l.versions,{range:n,distTags:l.distTags}));if(c)return c}}}return i(await this.cdn.resolveExactVersion(`${e}@${n}`))}async effectivePackage(e,n){let r=new F(e),s=r.root(),i=n[s],o=i?await Pe(()=>this.resolveExactForRoot(s,i)):void 0;return{effectivePackage:o?r.withVersion(o).format():e,root:s,range:i,pinned:o}}}});import{init as u_,parse as d_}from"es-module-lexer";var kr,tf=S(()=>{Vs();Ys();Aa();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))F.isBare(s[1])&&n.add(s[1])}return Array.from(n)}async extractImports(e){let n=new Set,r=s=>{F.isBare(s)&&n.add(s)};try{await u_;let[s]=d_(e);s.forEach(i=>r(e.slice(i.s,i.e).trim()))}catch{return this.extractImportsSync(e)}return Array.from(n)}async buildImportMap(e,n,r){let s=(await this.extractImports(e)).filter(d=>!r?.has(F.rootOf(d))),i=[...new Set(s.map(F.rootOf))],o=await Promise.all(i.map(async d=>({name:d,version:await this.resolveVersion(d,n)}))),{allRoots:a,flags:l,autoAddedPeers:c}=await this.peer.resolve(o,d=>this.resolveVersion(d,n)),f=this.buildEntries([...s,...c.map(d=>d.name)],a,l);return{importMap:{imports:Object.fromEntries(f)},prefetchUrls:f.map(([,d])=>d)}}async resolveVersion(e,n){let r=n[e],s=await this.version.resolveExactForRoot(e,r);if(!s)throw new Error(`Cannot resolve ${r?`${e}@${r}`:e}: no matching version is published (the package or version may not exist, or the registry was unreachable).`);return s}buildEntries(e,n,r){let s=new Map(n.map(p=>[p.name,p])),i=p=>{let h=s.get(F.rootOf(p));return new F(p).withVersion(h.version).format()},o=new Set([...r.entries()].filter(([,p])=>p.isPeerRoot||p.isSharedDep).map(([p])=>p)),a=new Set(e.filter(p=>p!==F.rootOf(p)).map(F.rootOf)),l=[],c=new Set,f=new Set(e.filter(p=>p===F.rootOf(p))),d=new Set;for(let p of e){let h=F.rootOf(p),m=s.get(h),{isPeerRoot:g,hasPeers:v,isSharedDep:E}=r.get(h),P=a.has(h),A=p!==h,O=!(g||E)&&(P||!v),_=this.singletonDepsOf(m,o),k=A&&f.has(h);k&&d.add(h);let N=k?[..._,h]:_.length?_:void 0;l.push([p,this.cdn.buildEsmUrl(i(p),{bundle:O,external:N})]),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}/`,`${zt}/${i(p)}/`]));return l}singletonDepsOf(e,n){return[...new Set([...Xs(e.meta),...Zd(e.meta)])].filter(r=>n.has(r))}};kr.importPatterns=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g]});import{gt as pw,satisfies as f_,maxSatisfying as hw,major as p_,valid as h_,validRange as m_}from"semver";var Ta,On,nf=S(()=>{Ta=class{cmp(e,n){return e===n?0:pw(e,n)?1:pw(n,e)?-1:0}satisfies(e,n){return!e||!e.trim()?!0:!!f_(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=hw(e,r,{includePrerelease:!1});if(a)return a}return hw(e,r,{includePrerelease:!0})??void 0}majorOf(e){return p_(e)}isExactVersion(e){return h_(e)!==null}isRange(e){return m_(e)!==null}},On=new Ta});function g_(t){return Math.min(9e5*Math.pow(2,Math.max(0,t-1)),864e5)}var Pn,mw=S(()=>{Ea();Pn=class{constructor(e){this.store=e}async isNegative(e){let n=await Pe(()=>this.store.get(e));return!!n&&n.until>Date.now()}async recordNegative(e){let r=((await Pe(()=>this.store.get(e)))?.attempts||0)+1;await Pe(()=>this.store.set(e,{until:Date.now()+g_(r),attempts:r}))}async clearNegative(e){await Pe(()=>this.store.delete(e))}}});function gw(t,e){let n=new Gs(t,e),r=new Qs(n),s=new Zs(t,n,On);return{packageService:new kr(s,n,r),versionResolver:s,cdnClient:n,peerResolver:r}}var vt=S(()=>{Qd();Aa();ef();tf();nf();Vs();nf();Ys();Qd();Aa();ef();tf();mw()});import*as rf from"fs/promises";import*as yw from"crypto";function et(t){return yw.createHash("sha1").update(t).digest("hex")}async function St(t){try{return JSON.parse(await rf.readFile(t,"utf8"))}catch{return}}async function Ca(t){try{return await rf.readFile(t,"utf8")}catch{return}}var xr=S(()=>{"use strict"});import*as Vt from"fs/promises";import*as kt from"path";import*as ww from"os";function ne(){return sf||(sf=b_().catch(()=>mt())),sf}function Pa(t,e){return kt.join(y_,et(t),e)}async function b_(){await Vt.mkdir(Yt,{recursive:!0});let t=kt.join(Yt,"version.json");if((await St(t))?.version===bw)return;let n=await Vt.readdir(Yt).catch(()=>[]);await Promise.all(n.map(r=>Vt.rm(kt.join(Yt,r),{recursive:!0,force:!0}))),await Vt.writeFile(t,JSON.stringify({version:bw})+`
|
|
545
|
+
`,"utf8")}var bw,Yt,ei,ti,Oa,y_,sf,Er=S(()=>{"use strict";xr();je();bw=1,Yt=kt.join(ww.homedir(),".typebulb","cache"),ei=kt.join(Yt,"packages"),ti=kt.join(Yt,"proxy"),Oa=kt.join(Yt,"dts"),y_=kt.join(Yt,"emit")});import*as Gt from"fs/promises";import*as vw from"path";async function Fe(t,e){let n=`${t}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;try{await Gt.mkdir(vw.dirname(t),{recursive:!0}),await Gt.writeFile(n,e,"utf8")}catch{mt();return}await Gt.rename(n,t).catch(async()=>{await Gt.rm(n,{force:!0}).catch(()=>{})})}var ni=S(()=>{"use strict";je()});var Ar,of=S(()=>{"use strict";ni();xr();Ar=class{constructor(e){this.filePath=e}mem;loadPromise;load(){return this.mem?Promise.resolve(this.mem):(this.loadPromise||(this.loadPromise=St(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 xw from"fs/promises";import*as tt from"path";function kw(t,e){return tt.join(w_,_a(t),encodeURIComponent(e)+".json")}function _a(t){return t.replace(/\//g,"__")}var af,Sw,w_,v_,Ra,Ew=S(()=>{"use strict";vt();Er();ni();of();xr();af=tt.join(ei,"indexes"),Sw=tt.join(ei,"pinned"),w_=tt.join(ei,"meta"),v_=tt.join(ei,"negative.json"),Ra=class{pinnedMem=new Map;indexMem=new Map;metaMem=new Map;negativeCache=new Pn(new Ar(v_));async getPinnedExact(e,n){let r=`${e}@${n}`;if(this.pinnedMem.has(r))return this.pinnedMem.get(r);await ne();let s=await Ca(tt.join(Sw,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 ne(),await Fe(tt.join(Sw,et(s)+".txt"),r)}async getIndex(e){if(this.indexMem.has(e))return this.indexMem.get(e);await ne();let n=await St(tt.join(af,_a(e)+".json"));return this.indexMem.set(e,n),n}async setIndex(e,n,r){let s={versions:n,distTags:r,updatedAt:Date.now()};this.indexMem.set(e,s),await ne(),await Fe(tt.join(af,_a(e)+".json"),JSON.stringify(s))}async invalidateVersionsCache(e){this.indexMem.delete(e),await xw.rm(tt.join(af,_a(e)+".json"),{force:!0}).catch(()=>{})}async isNegative(e){return await ne(),this.negativeCache.isNegative(e)}async recordNegative(e){await ne(),await this.negativeCache.recordNegative(e)}async clearNegative(e){await this.negativeCache.clearNegative(e)}async getMeta(e,n){let r=`${e}@${n}`;if(this.metaMem.has(r))return this.metaMem.get(r);await ne();let s=await St(kw(e,n));return this.metaMem.set(r,s),s}async setMeta(e,n,r,s,i){let o={dependencies:r,peerDependencies:s,peerDependenciesMeta:i,updatedAt:Date.now()};this.metaMem.set(`${e}@${n}`,o),await ne(),await Fe(kw(e,n),JSON.stringify(o))}}});var Aw,Tw=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 S_,Ia,Cw,Ow,$2,lf=S(()=>{"use strict";vt();Ew();Tw();S_=new Ra,{packageService:Ia,versionResolver:Cw,cdnClient:Ow,peerResolver:$2}=gw(S_,Aw)});function $a(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Pw(){return` <script>
|
|
546
546
|
${yy}
|
|
547
547
|
(function () {
|
|
548
548
|
try {
|
|
@@ -556,14 +556,14 @@ ${yy}
|
|
|
556
556
|
});
|
|
557
557
|
} catch (e) {}
|
|
558
558
|
})();
|
|
559
|
-
</script>`}function
|
|
559
|
+
</script>`}function Na(t,e){return` <script>
|
|
560
560
|
(function() {
|
|
561
561
|
try {
|
|
562
|
-
var KEY = ${
|
|
562
|
+
var KEY = ${xt(JSON.stringify("tb-theme:"+t))};
|
|
563
563
|
var doc = document.documentElement;
|
|
564
564
|
var mq = window.matchMedia('(prefers-color-scheme: dark)');
|
|
565
565
|
var os = function() { return mq.matches ? 'dark' : 'light'; };
|
|
566
|
-
var FORCED = ${
|
|
566
|
+
var FORCED = ${xt(JSON.stringify(e??null))};
|
|
567
567
|
var stored = function() {
|
|
568
568
|
try { var v = localStorage.getItem(KEY); return (v === 'dark' || v === 'light') ? v : undefined; }
|
|
569
569
|
catch (e) { return undefined; }
|
|
@@ -601,7 +601,7 @@ ${yy}
|
|
|
601
601
|
});
|
|
602
602
|
} catch (e) {}
|
|
603
603
|
})();
|
|
604
|
-
</script>`}var
|
|
604
|
+
</script>`}var xt,_w,cf,k_,x_,La,Tr=S(()=>{"use strict";te();te();xt=t=>t.replace(/<\/script/gi,"<\\/script");_w=30*6e4,cf=1e3,k_=6e4,x_=3e4,La=(t="'/__reload'")=>`
|
|
605
605
|
let es = null;
|
|
606
606
|
let bootId = null;
|
|
607
607
|
let firstErrorAt = 0;
|
|
@@ -616,9 +616,9 @@ ${yy}
|
|
|
616
616
|
es.onerror = () => {
|
|
617
617
|
if (!firstErrorAt) firstErrorAt = Date.now();
|
|
618
618
|
// Inside the replace window, EventSource's own retry is faster than anything we'd schedule.
|
|
619
|
-
if (Date.now() - firstErrorAt <= ${
|
|
619
|
+
if (Date.now() - firstErrorAt <= ${k_}) return;
|
|
620
620
|
es.close();
|
|
621
|
-
backoff = Math.min(${
|
|
621
|
+
backoff = Math.min(${x_}, backoff ? backoff * 2 : ${cf} * 2);
|
|
622
622
|
setTimeout(tbConnect, backoff);
|
|
623
623
|
};
|
|
624
624
|
};
|
|
@@ -634,7 +634,7 @@ ${yy}
|
|
|
634
634
|
// A relay open (TB-VSCode-Browser.md): the CLI asks a page of ours inside VS Code to open a URL,
|
|
635
635
|
// since its integrated browser honors a gesture-less window.open and keeps the new tab in-editor.
|
|
636
636
|
tbOn('open-url', (e) => { window.open(e.data, '_blank', 'noopener'); });
|
|
637
|
-
tbConnect();`});var
|
|
637
|
+
tbConnect();`});var Rw,Iw=S(()=>{"use strict";Tr();te();Rw=`
|
|
638
638
|
(() => {
|
|
639
639
|
// Inline (bulb-in-a-bulb): runs inside a sandboxed iframe with no parent
|
|
640
640
|
// bridge, so privileged tb.* (AI, fs, server RPC) can't reach a host and would
|
|
@@ -1507,7 +1507,7 @@ ${yy}
|
|
|
1507
1507
|
if (relayed) history.replaceState(null, '', location.pathname + location.search);
|
|
1508
1508
|
const tbStreamUrl = '/__reload?bulb=' + encodeURIComponent(window.__TB_BULB__ || '')
|
|
1509
1509
|
+ (relayed ? '&relay=' + Math.random().toString(36).slice(2) : '');
|
|
1510
|
-
${
|
|
1510
|
+
${La("tbStreamUrl")}
|
|
1511
1511
|
// Told to go, the page goes: it closes the tab, and where the browser refuses a script the close
|
|
1512
1512
|
// (a tab that wasn't script-opened and has history) it replaces itself with a note naming the
|
|
1513
1513
|
// reason. The note is a blob document, never a served route \u2014 a note that needs the server
|
|
@@ -1594,15 +1594,15 @@ ${$a("tbStreamUrl")}
|
|
|
1594
1594
|
});
|
|
1595
1595
|
}
|
|
1596
1596
|
})();
|
|
1597
|
-
`});function
|
|
1598
|
-
`+
|
|
1597
|
+
`});function $w(t){let{name:e,code:n,css:r,html:s,data:i,insight:o,importMap:a,theme:l,inline:c,dir:f,source:d,bulbKey:u,compileError:p}=t,h=s.trim()||'<div id="app"></div>',m=c?"":`
|
|
1598
|
+
`+Ku,g={imports:O_(a.imports)};return`<!DOCTYPE html>
|
|
1599
1599
|
<html>
|
|
1600
1600
|
<head>
|
|
1601
1601
|
<meta charset="utf-8">
|
|
1602
1602
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
1603
|
-
<title>${
|
|
1604
|
-
${
|
|
1605
|
-
${c?"":
|
|
1603
|
+
<title>${$a(e)} - typebulb</title>
|
|
1604
|
+
${Na(e,l)}
|
|
1605
|
+
${c?"":Pw()}
|
|
1606
1606
|
<script type="importmap">
|
|
1607
1607
|
${JSON.stringify(g,null,2)}
|
|
1608
1608
|
</script>
|
|
@@ -1616,27 +1616,27 @@ ${r}
|
|
|
1616
1616
|
<body>
|
|
1617
1617
|
${h}
|
|
1618
1618
|
|
|
1619
|
-
${i.length>0?`<script>window.__TB_DATA__ = ${
|
|
1620
|
-
${o?`<script>window.__TB_INSIGHT__ = ${
|
|
1621
|
-
${f?`<script>window.__TB_DIR__ = ${
|
|
1622
|
-
${u?`<script>window.__TB_BULB__ = ${
|
|
1623
|
-
${p?`<script>window.__TB_COMPILE_ERROR__ = ${
|
|
1619
|
+
${i.length>0?`<script>window.__TB_DATA__ = ${xt(JSON.stringify(i))};</script>`:""}
|
|
1620
|
+
${o?`<script>window.__TB_INSIGHT__ = ${xt(JSON.stringify(o))};</script>`:""}
|
|
1621
|
+
${f?`<script>window.__TB_DIR__ = ${xt(JSON.stringify(f))};</script>`:""}
|
|
1622
|
+
${u?`<script>window.__TB_BULB__ = ${xt(JSON.stringify(u))};</script>`:""}
|
|
1623
|
+
${p?`<script>window.__TB_COMPILE_ERROR__ = ${xt(JSON.stringify(p))};</script>`:""}
|
|
1624
1624
|
|
|
1625
1625
|
<script>
|
|
1626
1626
|
${wy}
|
|
1627
|
-
${
|
|
1627
|
+
${Rw}
|
|
1628
1628
|
</script>
|
|
1629
1629
|
|
|
1630
|
-
${
|
|
1630
|
+
${C_}
|
|
1631
1631
|
|
|
1632
|
-
${
|
|
1632
|
+
${A_(n,d)}
|
|
1633
1633
|
</body>
|
|
1634
|
-
</html>`}function
|
|
1635
|
-
`);return`<script type="module">${s}${
|
|
1636
|
-
</script>`}function
|
|
1634
|
+
</html>`}function A_(t,e){let n=["",...E_],r=e?Array(Math.max(0,e.codeLine-n.length-1)).fill(""):[],s=[...n,...r,xt(t)].join(`
|
|
1635
|
+
`);return`<script type="module">${s}${T_(e,s)}
|
|
1636
|
+
</script>`}function T_(t,e){if(!t)return"";let n=e.split(`
|
|
1637
1637
|
`).length,r={version:3,file:t.file,sources:[`/__source/${t.file}`],names:[],mappings:["AAAA",...Array(Math.max(0,n-1)).fill("AACA")].join(";")};return`
|
|
1638
1638
|
//# sourceURL=${t.file.replace(/\s/g,"%20")}
|
|
1639
|
-
//# sourceMappingURL=data:application/json;charset=utf-8,${encodeURIComponent(JSON.stringify(r))}`}function
|
|
1639
|
+
//# sourceMappingURL=data:application/json;charset=utf-8,${encodeURIComponent(JSON.stringify(r))}`}function O_(t){let e={};for(let[n,r]of Object.entries(t))e[n]=r.startsWith("https://")?"/proxy/"+r:r;return e}var E_,C_,Nw=S(()=>{"use strict";te();Iw();Tr();E_=["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) */"];C_=`<script>
|
|
1640
1640
|
(function () {
|
|
1641
1641
|
var framed = window.parent !== window;
|
|
1642
1642
|
var post = function (m) { try { parent.postMessage(m, '*'); } catch (e) {} }; /* framed only */
|
|
@@ -1735,20 +1735,20 @@ ${x_(n,d)}
|
|
|
1735
1735
|
}
|
|
1736
1736
|
});
|
|
1737
1737
|
})();
|
|
1738
|
-
</script>`});import*as
|
|
1739
|
-
Use a plain name with an exact / caret / tilde range (e.g. three@^0.160.0).`);await
|
|
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,
|
|
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
|
|
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(pe[i].path)||"")===(s.files.get(pe[i].path)||""))}async function
|
|
1738
|
+
</script>`});import*as Da from"fs/promises";import*as Ma from"path";import{existsSync as Lw,readFileSync as P_}from"fs";import{execFile as __}from"child_process";import{promisify as R_}from"util";import{builtinModules as I_}from"node:module";import{satisfies as $_}from"semver";async function Ba(t,e,n,r){let i=t.map(c=>D_(c,n)).filter(c=>!B_(c,e));if(i.length===0)return;let o=i.filter(c=>!M_.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 Da.mkdir(e,{recursive:!0});let a=Ma.join(e,"package.json");Lw(a)||await Da.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 N_("npm",["install",...l,...i],{cwd:e,shell:!0})}function D_(t,e){if(!e||F.parse(t).version)return t;let n=e[t];return n?`${t}@${n}`:t}function B_(t,e){let{name:n,version:r}=F.parse(t),s=Ma.join(e,"node_modules",n);if(!Lw(s))return!1;if(!r)return!0;try{let i=JSON.parse(P_(Ma.join(s,"package.json"),"utf-8")).version;return $_(i,r)}catch{return!1}}function ja(t){let e=new Set,n=/\bimport\s+(?:[\s\S]*?\s+from\s+)?['"]([^./][^'"]*)['"]/g,r;for(;r=n.exec(t);){let s=r[1];if(s.includes(":"))continue;let i=F.rootOf(s);L_.has(i)||e.add(i)}return[...e]}var N_,L_,M_,uf=S(()=>{"use strict";vt();N_=R_(__),L_=new Set(I_),M_=/^(@[a-z0-9._-]+\/)?[a-z0-9._-]+(@[a-zA-Z0-9.^~*x-]+)?$/i});import*as Ue from"fs/promises";import*as Le from"path";function Cr(t,e){let n=Le.resolve(e,t),r=Le.normalize(e),s=Le.normalize(n);if(s!==r&&!s.startsWith(r+Le.sep))throw new Error("Path traversal detected - access denied");return n}async function ri(t,e){return Ue.readFile(Cr(t,e))}async function Fa(t,e,n){let r=Cr(t,n);await Ue.mkdir(Le.dirname(r),{recursive:!0}),await Ue.writeFile(r,typeof e=="string"?e:Buffer.from(e))}async function Ua(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(Le.join(n,s.name)).then(o=>o.mtimeMs).catch(()=>0);return{name:s.name,dir:s.isDirectory(),mtime:i}}))}async function qa(t,e){let n=Cr(t,e);if(Le.normalize(n)===Le.normalize(e))throw new Error("Cannot remove the bulb's folder itself: remove its contents instead");await Ue.rm(n,{recursive:!0})}var df=S(()=>{"use strict"});async function Mw(t){let e=wt(t.provider,t.model);if(typeof e=="string")throw new Error(e);let n=await Ht(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 j_(t){let{response:e,protocol:n}=await Mw(t);return wr(e,n)}async function*F_(t){let{response:e,protocol:n}=await Mw(t);yield*Tn(e,n)}function Dw(t){let e=Object.assign(j_,{stream:F_}),n={read:async r=>{let s=await ri(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 ri(r,t)),write:async(r,s)=>(await Fa(r,s,t),!0),list:async(r=".")=>Ua(r,t),remove:async r=>(await qa(r,t),!0)};globalThis.tb=Object.freeze({log:(...r)=>{console.log(...r)},ai:e,fs:n,dir:t,models:()=>bt(),aiAccess:ma,mode:tr.local})}var Bw=S(()=>{"use strict";Wt();te();xa();xn();df()});import*as Xt from"fs/promises";import*as he from"path";import{pathToFileURL as U_}from"url";async function jw(t){let n=(await Xt.readdir(t)).find(r=>r.endsWith(".bulb.md"));return n?he.join(t,n):void 0}function Or(t){let e=he.resolve(t);return he.join(he.dirname(e),he.basename(e).replace(/\.bulb\.md$/,""))}function Pr(t){let[e,n,r,s]=t.split(he.sep).slice(-4);if(!(e!=="typebulbs"||n!=="u"||!r||!s?.endsWith(".bulb.md")))return{userSlug:r,slug:s.slice(0,-8)}}async function nt(t){let e=await Xt.readFile(t,"utf-8"),n=qn(e),r=dr(n);return{bulb:r,config:Hr(r.config),warnings:Yp(e),starts:n.starts}}function ff(t){let e=he.basename(t).replace(/\.bulb\.md$/i,"");return he.join(he.dirname(t),".typebulb",`${e}.server.mjs`)}async function si(t,e,n,r){let s=Vd(t,{serverOnly:!0});if(s.error)throw new Error(`Server compilation error: ${s.error}`);let i=s.code;n&&(i=await qp(i,n));let o=he.join(he.dirname(e),".typebulb");await Xt.mkdir(o,{recursive:!0});let a=ja(i);a.length>0&&await Ba(a,o,r);let l=ff(e);return await Xt.writeFile(l,i,"utf-8"),Dw(Or(e)),await import(`${U_(l).href}?t=${Date.now()}`)}async function pf(t,e,n,r){let{bulb:s,config:i,starts:o}=await nt(t),a=Lo(s.data),l,c=h=>{l??=h instanceof Error?h.message:String(h)};try{lw(s.code,i.dependencies??{})}catch(h){c(h)}let f=Vd(s.code,{jsxImportSource:i.ts?.jsxImportSource});f.error&&c(f.error);let d={imports:{}};if(!l)try{({importMap:d}=await Ia.buildImportMap(f.code,i.dependencies??{},r?new Set([r.name]):void 0))}catch(h){c(`Dependency resolution failed: ${h instanceof Error?h.message:String(h)}`)}l&&console.error("Build error:",l),r&&(d.imports[r.name]=r.entryUrl);let u=$w({name:s.name,code:l?"":f.code,css:s.css,html:s.html,data:a,insight:s.insight,importMap:d,dir:Or(t),watch:e,source:{file:he.basename(t),codeLine:o.get("code.tsx")??1},bulbKey:Ls(t),compileError:l}),p;return s.server&&n&&(p=await si(s.server,t,r,i.dependencies)),{html:u,bulb:s,serverExports:p,buildError:l}}var _n,Et=S(()=>{"use strict";js();aw();cw();lf();Nw();uf();Ii();je();Bw();_n=t=>he.join(Or(t),"assets")});import*as Me from"fs/promises";import*as qe from"path";import{createHash as q_}from"crypto";async function mf(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 yf(t,e){try{let n=await fetch(ii(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 bf(t,e){we(e);let n=process.env.TYPEBULB_ORIGIN||J_;try{return Ka(t,process.cwd(),n)}catch(r){console.error(r instanceof Error?r.message:String(r)),process.exit(1)}}function Ka(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,Ja(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 W_(t,e){let n=await yf(t,e);if("error"in n||!n.entries.length)return{kind:"none"};let r=n.entries,s=_n(t.dest),i=[],o=[],a=0;for(let l of r){let c=await Me.readFile(qe.join(s,...l.path.split("/"))).catch(()=>{});c===void 0?i.push(l.path):gf(c)===l.md5?a++:e.force?i.push(l.path):o.push(l.path)}return o.length?{kind:"conflict",paths:o}:{kind:"plan",toGet:i,unchanged:a}}async function K_(t,e,n){let r=_n(t.dest),s=[],i=0;return await mf(e.toGet,4,async o=>{try{let a=await fetch(`${ii(t)}/${Wa(o)}`,{headers:n.token?{Authorization:`Bearer ${n.token}`}:{},signal:AbortSignal.timeout(n.timeoutMs??3e4)});if(!a.ok){s.push(`${o}: HTTP ${a.status}`);return}let l=qe.join(r,...o.split("/"));await Me.mkdir(qe.dirname(l),{recursive:!0}),await Me.writeFile(l,new Uint8Array(await a.arrayBuffer())),i++}catch(a){s.push(`${o}: ${a instanceof Error?a.message:String(a)}`)}}),{downloaded:i,unchanged:e.unchanged,errors:s}}async function Ha(t,e={}){let n=await fetch(hf(t),{headers:e.token?{Authorization:`Bearer ${e.token}`}:{},signal:e.timeoutMs?AbortSignal.timeout(e.timeoutMs):void 0});if(!n.ok)return{kind:"http-error",status:n.status};let r=n.headers.get("content-type");if(!r?.includes("text/markdown"))return{kind:"not-markdown",contentType:r??void 0};let s=await n.text(),i;try{i=await Me.readFile(t.dest,"utf-8")}catch{}let o=i!==void 0&&H_(i,s);if(i!==void 0&&!o&&!e.force){let{mtime:c}=await Me.stat(t.dest);return{kind:"conflict",dest:t.dest,localMtime:c,remoteLastModified:n.headers.get("last-modified")??void 0}}let a=await W_(t,e);if(a.kind==="conflict")return{kind:"asset-conflict",dest:t.dest,paths:a.paths};if(!o){await Me.mkdir(qe.dirname(t.dest),{recursive:!0}),await Me.writeFile(t.dest,s);let c=new Date(n.headers.get("last-modified")??"");isNaN(c.getTime())||await Me.utimes(t.dest,new Date,c)}let l=a.kind==="plan"?await K_(t,a,e):void 0;return o?{kind:"up-to-date",dest:t.dest,assets:l}:{kind:"written",dest:t.dest,created:i===void 0,assets:l}}function H_(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(pe[i].path)||"")===(s.files.get(pe[i].path)||""))}async function Uw(t,e){t||(console.error("Usage: typebulb pull <bulb url | typebulbs/u/<user>/<slug>.bulb.md>"),process.exit(1));let n=bf(t,e.mode),r=`${n.origin}/u/${n.userSlug}/${n.slug}`,s;try{s=await Ha(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)"}`),Fw(s.assets);return;case"up-to-date":console.log(`up to date: ${i}`),Fw(s.assets);return;case"conflict":console.error(`Refusing to overwrite ${i} \u2014 it differs from ${r}
|
|
1743
1743
|
local file modified ${s.localMtime.toISOString()}
|
|
1744
1744
|
remote last saved ${s.remoteLastModified??"unknown"}
|
|
1745
1745
|
Re-run with --force to overwrite the local file.`),process.exitCode=1;return;case"asset-conflict":console.error(`Refusing to overwrite local assets that differ from the hosted copies:
|
|
1746
1746
|
`+s.paths.map(o=>` assets/${o}`).join(`
|
|
1747
1747
|
`)+`
|
|
1748
|
-
Re-run with --force to overwrite them.`),process.exitCode=1;return;case"http-error":s.status===404?console.error(`Bulb not found: ${r}`):s.status===401||s.status===403?console.error(`This bulb is private (${s.status}) \u2014 pulling it needs a TYPEBULB_TOKEN for its owner.`):console.error(`Pull failed: ${n.origin} responded ${s.status}`),process.exitCode=1;return;case"not-markdown":console.error(`${r}.md did not return bulb markdown (got ${s.contentType??"no content-type"}) \u2014 is ${n.origin} a typebulb host?`),process.exitCode=1}}function
|
|
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 Fw(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 J_,Ja,hf,Wa,ii,gf,za=S(()=>{"use strict";Ze();te();Et();J_="https://typebulb.com",Ja=(t,e)=>qe.join("typebulbs","u",t,`${e}.bulb.md`),hf=t=>`${t.origin}/u/${encodeURIComponent(t.userSlug)}/${encodeURIComponent(t.slug)}.md`,Wa=t=>t.split("/").map(encodeURIComponent).join("/"),ii=t=>`${t.origin}/u/${encodeURIComponent(t.userSlug)}/${encodeURIComponent(t.slug)}/assets`;gf=t=>q_("md5").update(t).digest("hex")});import*as ct from"fs/promises";import*as oi from"path";async function qw(t,e=""){let n=await ct.readdir(t,{withFileTypes:!0}).catch(()=>[]),r=[];for(let s of n)s.isDirectory()?r.push(...await qw(oi.join(t,s.name),`${e}${s.name}/`)):s.isFile()&&r.push(e+s.name);return r}async function z_(t,e){let n=e.timeoutMs??3e4,r=ii(t),s={Authorization:`Bearer ${e.token}`},i=_n(t.dest);if(!await ct.stat(i).then(h=>h.isDirectory()).catch(()=>!1))return{kind:"skipped"};let o=await qw(i),a=await yf(t,{token:e.token,timeoutMs:n});if("error"in a)return{kind:"sync-error",message:a.error};let l=a.entries;if(!o.length&&!l.length)return{kind:"skipped"};let c=new Map(l.map(h=>[h.path,h.md5])),f=new Set(o),d=l.map(h=>h.path).filter(h=>!f.has(h)),u=0,p=0;try{await mf(o,4,async h=>{let m=await ct.readFile(oi.join(i,...h.split("/")));if(c.get(h)===gf(m)){p++;return}let g=await fetch(`${r}/${Wa(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())}`);u++})}catch(h){return{kind:"sync-error",message:h instanceof Error?h.message:String(h)}}return{kind:"synced",uploaded:u,unchanged:p,toDelete:d,base:Mi(t.userSlug,t.slug)}}async function Y_(t,e,n){let r=n.timeoutMs??3e4,s=ii(t),i=[];for(let o of e)try{let a=await fetch(`${s}/${Wa(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 Ya(t,e){let n=await ct.readFile(t.dest,"utf-8"),{mtime:r}=await ct.stat(t.dest),s=await z_(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(hf(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 ct.utimes(t.dest,new Date,new Date(c.updatedAt)),i&&s.kind==="synced"&&s.toDelete.length){let f=await Y_(t,s.toDelete,{token:e.token,timeoutMs:e.timeoutMs});i.deleted=f.deleted,f.error&&(i.pruneError=f.error)}return{kind:"pushed",created:c.created,serverStripped:c.serverStripped,updatedAt:c.updatedAt,assets:i}}async function Jw(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=bf(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=oi.relative(process.cwd(),n.dest)||n.dest,o;try{o=await Ya(n,{token:r,force:e.force})}catch(a){let l=a instanceof Error?a.message:String(a);console.error(a?.code==="ENOENT"?`File not found: ${i}`:`Could not push to ${n.origin}: ${l}`),process.exitCode=1;return}switch(o.kind!=="asset-error"&&o.assets&&console.log(`assets: ${o.assets.uploaded} uploaded, ${o.assets.unchanged} unchanged \u2192 ${o.assets.base}`),o.kind){case"asset-error":console.error(`assets sync failed: ${o.message}
|
|
1749
1749
|
push refused: the bulb text was not pushed.`),process.exitCode=1;return;case"pushed":{console.log(`pushed ${i} \u2192 ${s}/full`),o.created&&(console.log(" created a new bulb, unlisted \u2014 nothing existed at this URL before"),console.log(" if you renamed this file, its previous bulb is still live at the old URL")),o.serverStripped&&console.log("note: the server.ts block was stripped on the server copy (CLI-only); your local file is untouched.");for(let a of o.assets?.deleted??[])console.log(` deleted ${a} (no longer in assets/)`);o.assets?.pruneError&&console.log(`note: asset cleanup incomplete \u2014 ${o.assets.pruneError}; the next push will retry.`);return}case"conflict":console.error(`${o.message}
|
|
1750
1750
|
pull to see the remote: typebulb pull ${i}
|
|
1751
|
-
or overwrite it: typebulb push ${i} --force`),process.exitCode=1;return;case"http-error":o.status===401?console.error("The server rejected TYPEBULB_TOKEN (401) \u2014 it may be revoked; mint a new one on the settings page."):console.error(`Push failed: ${n.origin} responded ${o.status}${o.message?` \u2014 ${o.message}`:""}`),process.exitCode=1}}var wf=S(()=>{"use strict";te();
|
|
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 wf=S(()=>{"use strict";te();za();Et()});var Rr=S(()=>{"use strict";Ie();Mb();gn();Db();xd();qb();Wb();qs();xn();xn();xa();Yd();Ie();za();wf();Ze();je()});import{existsSync as V_,mkdirSync as G_,readFileSync as X_,rmSync as Q_,writeFileSync as Z_}from"fs";import{homedir as eR}from"os";import*as Ir from"path";function sR(){return rR.replace('"__TB_SKILL_PATH__"',JSON.stringify(Hs())).replace('"__TB_BIN_PATH__"',JSON.stringify(ur()))}function Ww(){try{if(!V_(vf()))return}catch{return}try{let t=tR(),e=sR(),n;try{n=X_(t,"utf8")}catch{}n!==e&&(G_(Ir.dirname(t),{recursive:!0}),Z_(t,e))}catch{}for(let t of nR())try{Q_(t,{force:!0})}catch{}}var vf,tR,nR,rR,Kw=S(()=>{"use strict";Rr();vf=()=>Ir.join(eR(),".pi","agent"),tR=()=>Ir.join(vf(),"extensions","typebulb.ts"),nR=()=>["typebulb-wait.ts","matchu-patchu.ts"].map(t=>Ir.join(vf(),"extensions",t)),rR=String.raw`// Generated by typebulb — do not edit; overwritten on each run.
|
|
1752
1752
|
import { spawn } from "node:child_process";
|
|
1753
1753
|
import { existsSync } from "node:fs";
|
|
1754
1754
|
|
|
@@ -2016,23 +2016,23 @@ export default function (pi) {
|
|
|
2016
2016
|
try { pi.on("session_shutdown", () => { stopping = true; if (watcher) { try { watcher.kill(); } catch (e) {} watcher = null; } for (const c of pending) { try { c.kill(); } catch (e) {} } pending.clear(); }); } catch (e) {}
|
|
2017
2017
|
} catch (e) { logErr("load", e && e.message); }
|
|
2018
2018
|
}
|
|
2019
|
-
`});function V(t){return t?.message??String(t)}var X,
|
|
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
|
|
2021
|
-
`)}catch{}await Promise.race([this.#x,
|
|
2019
|
+
`});function V(t){return t?.message??String(t)}var X,Qt=S(()=>{"use strict";X=process.cwd()});import{spawn as Hw}from"child_process";import{StringDecoder as iR}from"string_decoder";function dR(t,e){let n=new iR("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 oR,zw,Yw,Sf,Vw,aR,lR,cR,Gw,uR,Va,Ga,Xw,Qw=S(()=>{"use strict";Qt();oR=3e4,zw=18e4,Yw="starting pi\u2026",Sf=5e3,Vw=2e3,aR=2e3,lR=12e4,cR=8e3,Gw=15e3,uR=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"]),Va=new Set;process.on("exit",()=>{for(let t of Va)try{t.kill()}catch{}});Ga=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)=>Hw(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()+zw,this.#r={text:Yw,kind:"info"},Va.add(i),i.stdout&&dR(i.stdout,o=>this.#I(o)),i.stderr&&i.stderr.on("data",o=>{this.#v=(this.#v+o.toString()).slice(-aR)}),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"),Va.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===Yw&&(this.#r=null),this.#i&&(this.#i.until=Date.now()+Gw),!this.#o&&Date.now()<this.#e&&(this.#e=Date.now()+Sf),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(!uR.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+Sf),{ok:!0};let a;try{a=await this.#h(i)}catch(l){return{ok:!1,error:V(l)}}return a.success&&o(Date.now()+Sf),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,Xw(Vw)])}try{e.stdin?.end()}catch{}if(await Promise.race([this.#x,Xw(Vw)]),e.exitCode===null&&!e.killed)if(process.platform==="win32"&&e.pid)try{Hw("taskkill",["/pid",String(e.pid),"/T","/F"],{stdio:"ignore"})}catch{}else try{e.kill("SIGKILL")}catch{}Va.delete(e),this.#l=[],this.#P("pi was shut down")}}#E(e){try{this.#t?.stdin?.write(JSON.stringify(e)+`
|
|
2022
2022
|
`)}catch{}}#C(){let e=this.#a[this.#a.length-1];this.#c={text:this.#a.filter(n=>n?.kind==="text").map(n=>n.text).join(""),thinking:this.#a.filter(n=>n?.kind==="thinking").map(n=>n.text).join(`
|
|
2023
|
-
`),tool:e?.kind==="tool"?e.name:void 0}}#A(e){let n=Array.isArray(e?.content)?e.content:[];this.#a=n.map(r=>({kind:r.type==="thinking"?"thinking":r.type==="toolCall"?"tool":"text",text:(r.type==="thinking"?r.thinking:r.text)??"",name:r.name})),this.#C()}#y(e,n){let r=e.length>200?e.slice(0,200)+"\u2026":e;r&&(this.#i={text:r,kind:n,until:Date.now()+(n==="info"?
|
|
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??
|
|
2025
|
-
`).filter(Boolean).map(s=>s.replace(/\\/g,"/"))}return null}function
|
|
2026
|
-
`),l=i.filter(u=>u.type==="toolCall").map(u=>({id:u.id??"",name:u.name??"",input:u.arguments??{}}));if(o||a||l.length){let u=Date.parse(e.timestamp??""),p=!isNaN(u)&&u>=n;r.push({type:"assistant",text:o,thinking:a,tools:l,live:p})}let c=s.usage,f=c?(c.input??0)+(c.output??0)+(c.cacheRead??0)+(c.cacheWrite??0):0,d=c&&f>0&&s.stopReason!=="aborted"&&s.stopReason!=="error"?{in:c.input??0,out:c.output??0,cached:c.cacheRead??0,cacheCreate:c.cacheWrite??0}:void 0;return{events:r,usage:d,model:s.model,cost:c?.cost?.total}}return{events:r}}chainWorking(e){let n;for(let a of e)
|
|
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"?cR:Gw)})}#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?zw:oR,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??lR),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()}},Xw=t=>new Promise(e=>{setTimeout(e,t).unref?.()})});import{existsSync as Zw,readFileSync as fR,realpathSync as pR}from"fs";import{join as Rn,dirname as rv,resolve as hR}from"path";import{homedir as ev}from"os";function gR(t,e){let n=Rn(t,".pi");if(mR.some(s=>Zw(Rn(n,s))))return!0;let r=Rn(e,".agents","skills");for(let s=t;;){let i=Rn(s,".agents","skills");if(i!==r&&Zw(i))return!0;let o=rv(s);if(o===s)return!1;s=o}}function yR(t,e){for(let n=e;;){if(t[n]===!0||t[n]===!1)return!0;let r=rv(n);if(r===n)return!1;n=r}}function sv(t,e){try{let n=e?.agentDir??Rn(ev(),".pi","agent"),r=tv(e?.home??process.env.HOME??ev()),s=tv(hR(t));if(!gR(s,r))return null;let i=nv(Rn(n,"settings.json")).defaultProjectTrust;return i==="always"||i==="never"||yR(nv(Rn(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 mR,tv,nv,iv=S(()=>{"use strict";mR=["settings.json","extensions","skills","prompts","themes","SYSTEM.md","APPEND_SYSTEM.md"],tv=t=>{try{return pR(t)}catch{return t}},nv=t=>{try{return JSON.parse(fR(t,"utf8"))}catch{return{}}}});import{statSync as bR,openSync as wR,readSync as vR,closeSync as SR,existsSync as av}from"fs";import{join as Xa}from"path";import{homedir as kf}from"os";import{execFile as kR}from"child_process";async function ER(t){let e=Xa(kf(),".pi","agent","bin",process.platform==="win32"?"fd.exe":"fd");for(let n of["fd","fdfind",...av(e)?[e]:[]]){let r=await new Promise(s=>{kR(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 AR(t){return`--${t.replace(/^[/\\]/,"").replace(/[/\\:]/g,"-")}--`}function ov(t){return t.type==="message"?TR(t.message?.role):t.type==="custom_message"?t.display!==!1:!1}var xR,TR,$r,xf=S(()=>{"use strict";Ps();Uo();qo();Kw();Qw();iv();xR=Xa(kf(),".pi","agent","sessions");TR=t=>t==="user"||t==="assistant"||t==="toolResult"||t==="bashExecution";$r=class extends Ut{displayName="Pi Mirror";detectsSelf(){return process.env.PI_CODING_AGENT==="true"}detectsInstalled(){return av(Xa(kf(),".pi","agent"))}ensureHarnessSupport(){Ww()}createDriver(e,n){let r=new Ga(e,n),s=sv(e);return s&&r.notice(s,"warning"),r}walkFiles(e){return ER(e)}sessionsDir(e){return Xa(xR,AR(e))}listSessionFiles(e){return Fo(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 ov(e)}isRecoveryNoise(e){return!1}apply(e,n){let r=[];if(e.type==="custom_message"){if(e.display===!1)return{events:r};let i=this.contentText(e.content).trim();return i&&r.push({type:"user",text:i}),{events:r}}if(e.type!=="message"||!e.message)return{events:r};let s=e.message;if(s.role==="user"){let i=this.contentText(s.content).trim();return i&&r.push({type:"user",text:i}),{events:r}}if(s.role==="toolResult"){let i=this.contentText(s.content);return r.push({type:"tool_result",id:s.toolCallId??"",content:i,isError:!!s.isError,digest:Be(i)}),{events:r}}if(s.role==="bashExecution")return s.command&&!s.excludeFromContext&&r.push({type:"user",text:`$ ${s.command}`}),{events:r};if(s.role==="assistant"){let i=Array.isArray(s.content)?s.content:[],o=i.filter(u=>u.type==="text").map(u=>u.text??"").join(""),a=i.filter(u=>u.type==="thinking").map(u=>u.thinking??"").join(`
|
|
2026
|
+
`),l=i.filter(u=>u.type==="toolCall").map(u=>({id:u.id??"",name:u.name??"",input:u.arguments??{}}));if(o||a||l.length){let u=Date.parse(e.timestamp??""),p=!isNaN(u)&&u>=n;r.push({type:"assistant",text:o,thinking:a,tools:l,live:p})}let c=s.usage,f=c?(c.input??0)+(c.output??0)+(c.cacheRead??0)+(c.cacheWrite??0):0,d=c&&f>0&&s.stopReason!=="aborted"&&s.stopReason!=="error"?{in:c.input??0,out:c.output??0,cached:c.cacheRead??0,cacheCreate:c.cacheWrite??0}:void 0;return{events:r,usage:d,model:s.model,cost:c?.cost?.total}}return{events:r}}chainWorking(e){let n;for(let a of e)ov(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=wR(e,"r")}catch{return""}try{let s=65536;try{s=bR(e).size}catch{}let i=(d,u)=>{let p=Buffer.alloc(u),h=vR(n,p,0,u,d);return p.subarray(0,h).toString("utf8")},o=i(0,Math.min(65536,s)),a=s>65536?i(s-65536,65536):"",l=d=>{let u="";for(let p of d.split(`
|
|
2027
2027
|
`))if(p.includes('"session_info"'))try{let h=JSON.parse(p);h?.type==="session_info"&&typeof h.name=="string"&&h.name&&(u=h.name)}catch{}return u},c="";for(let d of o.split(`
|
|
2028
|
-
`))if(!(c||!d.includes('"type"')))try{let u=JSON.parse(d);u?.type==="message"&&u.message?.role==="user"&&(c=this.contentText(u.message.content).replace(/\s+/g," ").trim())}catch{}let f=l(a)||l(o)||c;return f?f.slice(0,200):""}finally{
|
|
2029
|
-
`):""}}});var
|
|
2028
|
+
`))if(!(c||!d.includes('"type"')))try{let u=JSON.parse(d);u?.type==="message"&&u.message?.role==="user"&&(c=this.contentText(u.message.content).replace(/\s+/g," ").trim())}catch{}let f=l(a)||l(o)||c;return f?f.slice(0,200):""}finally{SR(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"?Re(e):Array.isArray(e)?e.map(n=>typeof n?.text=="string"?Re(n.text):n?.type==="image"&&n.data?Bo(n.data,n.mimeType):"").filter(Boolean).join(`
|
|
2029
|
+
`):""}}});var Qa,lv=S(()=>{"use strict";Qa=class{#t=new Map;accept(e,n){return this.#t.get(e)===n?!1:(this.#t.set(e,n),!0)}}});import{execFile as CR}from"child_process";import{promisify as OR}from"util";import{readFile as PR}from"fs/promises";import{resolve as cv,sep as _R}from"path";async function ve(t,e){let{stdout:n}=await RR("git",t,{cwd:e,maxBuffer:67108864});return n}async function In(){if(Za)return Za;try{Za=(await ve(["rev-parse","--show-toplevel"],X)).trim()}catch{}return Za}function IR(t,e){let n=e===" "?t:e;return n==="?"?"U":n}async function Af(){let t=await In();if(!t)return{repo:!1,root:"",files:[]};try{let e=await ve(["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 ve(["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 Tf(t){let e=await In();if(!e)return{ok:!1,error:"not a git repository"};try{if((await ve(["status","--porcelain","-z","--",t],e)).startsWith("??")){let s=cv(e,t);if(!s.startsWith(cv(e)+_R))return{ok:!1,error:"outside repository"};let i=await PR(s);return i.includes(0)?Ef("Binary file (not shown)",!1):Ef(i.toString("utf8"),!0)}let r;try{r=await ve(["diff","--no-color","--unified=999999","HEAD","--",t],e)}catch{r=await ve(["diff","--no-color","--unified=999999","--",t],e)}return Ef(r,!1)}catch(n){return{ok:!1,error:V(n)}}}var RR,uv,Za,Ef,Nr=S(()=>{"use strict";Qt();RR=OR(CR),uv=2e6;Ef=(t,e)=>({ok:!0,text:t.slice(0,uv),untracked:e,truncated:t.length>uv})});function ai(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 Cf=S(()=>{"use strict"});function dv(){return $R.map(([t,e])=>wt(t,e)).filter(t=>typeof t!="string")}function fv(){return dv().length>0}async function el(t,e,n=0){let r=AbortSignal.timeout(e);for(let s of dv()){try{let i=await Ht(s,{messages:[{role:"user",content:t}],effort:n,webSearch:!1,signal:r});if(i.ok){let o=(await qd(i,s.protocol)).trim();if(o)return o}}catch{}if(r.aborted)return}}var $R,Of=S(()=>{"use strict";Wt();Rr();$R=[["openrouter","openai/gpt-6-luna"],["openai","gpt-6-luna"]]});var tl,nl,At,rl,Lr=S(()=>{"use strict";tl=".typebulb/paste",nl={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",bmp:"image/bmp"},At=t=>t.label||t.kind||"agent",rl=t=>t.failing&&t.state!=="stopped"?"failing":t.state});import{existsSync as NR,mkdirSync as LR,writeFileSync as MR,readFileSync as DR}from"fs";import{join as sl}from"path";function pv(){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 FR(t){return t.trim().toLowerCase().replace(/\.[a-z0-9]{1,4}$/,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)}async function UR(t){let e=await el(`Reply with ONLY a short kebab-case filename (2-5 words, lowercase, no extension) describing this text:
|
|
2030
2030
|
|
|
2031
|
-
${t.slice(0,
|
|
2032
|
-
`+
|
|
2031
|
+
${t.slice(0,jR)}`,BR);return e&&FR(e)||void 0}async function hv(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=sl(t,tl);try{LR(n,{recursive:!0})}catch(a){return{ok:!1,error:V(a)}}let r,s,i;if(e.kind==="image"){if(r=`img-${pv()}`,s=Object.keys(nl).find(a=>nl[a]===e.mime)??"png",i=Buffer.from(e.data,"base64"),!i.length)return{ok:!1,error:"empty image data"}}else r=await UR(e.data)??`paste-${pv()}`,s="md",i=e.data;let o=`${r}.${s}`;for(let a=2;NR(sl(n,o));a++)o=`${r}-${a}.${s}`;try{MR(sl(n,o),i)}catch(a){return{ok:!1,error:V(a)}}return{ok:!0,path:`${tl}/${o}`}}function mv(t,e){if(!/^[\w-]+(\.[\w-]+)*$/.test(e))return{ok:!1,error:"bad name"};let n=e.slice(e.lastIndexOf(".")+1).toLowerCase(),r=nl[n];if(!r)return{ok:!1,error:"not an image"};try{return{ok:!0,mime:r,base64:DR(sl(t,tl,e)).toString("base64")}}catch{return{ok:!1,error:"not found"}}}var BR,jR,gv=S(()=>{"use strict";Of();Qt();Lr();BR=4e3,jR=4e3});async function wv(t,e=""){let n=t.trim();if(!n)return{ok:!1,error:"nothing to summarize"};if(!fv())return WR;let r=e.trim()?bv+`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
|
+
`+JR(e.trim())+`
|
|
2033
2033
|
|
|
2034
2034
|
REPLY TO SUMMARIZE:
|
|
2035
|
-
`+n.slice(0,
|
|
2035
|
+
`+n.slice(0,yv):bv+n.slice(0,yv),s=await el(r,qR,1);return s?{ok:!0,text:s}:KR}var qR,yv,bv,JR,WR,KR,vv=S(()=>{"use strict";Of();qR=2e4,yv=24e3,bv=`Summarize this assistant reply for someone who wants its substance without the prose.
|
|
2036
2036
|
|
|
2037
2037
|
- Markdown. Start with the direct answer, recommendation, result, or status. If it is qualified, put the qualification in that same opening sentence; do not make the reader infer it from later bullets.
|
|
2038
2038
|
- Preserve material limits and conditions that change the answer: exceptions, tradeoffs, prerequisites, uncertainty, incomplete validation, and clauses such as but, only when, unless, or if. Cut only filler hedges (for example, "I think" or "arguably") that change nothing.
|
|
@@ -2047,34 +2047,34 @@ Reply with the summary alone.
|
|
|
2047
2047
|
|
|
2048
2048
|
---
|
|
2049
2049
|
|
|
2050
|
-
`,
|
|
2050
|
+
`,JR=(t,e=4e3)=>{if(t.length<=e)return t;let n=Math.floor(e/2)-20;return t.slice(0,n)+`
|
|
2051
2051
|
|
|
2052
2052
|
[snipped for brevity]
|
|
2053
2053
|
|
|
2054
|
-
`+t.slice(t.length-n)},
|
|
2055
|
-
`),n),l=[],c=new Set;for(let u=a;u&&!c.has(u);){let p=i.get(u);if(!p)break;c.add(u),l.push(p),u=r.parentOf(p)}let f=[],d=Date.now();for(let u of l.reverse())if(!r.isSidechain(u,n))try{f.push(...
|
|
2056
|
-
`).find(h=>h.trim());p&&a.push({text:$n(p,200),calls:e.length});for(let h of d.tools){let m={id:h.id,name:h.name,input:h.input,at:u,isError:!1};e.push(m),n.set(h.id,m)}}else if(d.type==="tool_result"){let p=n.get(d.id);if(!p)continue;Object.assign(p,{result:d.content,isError:d.isError,exit:d.exit,background:d.background,refused:d.refused,doneAt:u}),d.output&&(p.output=d.output),d.task&&r.set(d.task,p),u!==void 0&&i.push(u)}else if(d.type==="task_done"){let p=d.id?n.get(d.id):d.task?r.get(d.task):void 0;if(!p?.background||p.endAt!==void 0)continue;Object.assign(p,{endAt:u??f,outcome:d.outcome,output:d.output??p.output}),d.exit!==void 0&&(p.exit=d.exit),c&&u!==void 0&&(s.push(u),c=!1)}else d.type==="turn_end"&&(!c&&u!==void 0&&o.push(u),c=!0)}return{calls:e,turnEnds:o,narration:a,lastAt:f,...
|
|
2057
|
-
`).map(n=>n.trim()).filter(n=>/[\p{L}\p{N}]/u.test(n));return/^exit(?: code)?:? \d+$/i.test(e[0]??"")&&e.shift(),{first:$n(e[0]??"",120),last:e.length>1?$n(e.at(-1),120):""}}function
|
|
2058
|
-
`)){let B=/^(---|\+\+\+) (?:[ab]\/)?(.+?)\s*$/.exec(N);if(B?.[1]==="---"){k=B[2];continue}if(B?.[1]==="+++"){h=!0,B[2]==="/dev/null"?k&&k!=="/dev/null"&&d(k,{deleted:!0}):d(B[2]);continue}let Z=/^\*\*\* Move to: (.+?)\s*$/.exec(N);Z&&k&&u(k,Z[1])}}let m=ee(p.file_path)??ee(p.filePath)??ee(p.path),g=
|
|
2054
|
+
`+t.slice(t.length-n)},WR={ok:!1,error:"Summary needs OPENROUTER_API_KEY or OPENAI_API_KEY in this project\u2019s .env.",setup:!0},KR={ok:!1,error:"the model call failed or timed out"}});import{readFileSync as HR,statSync as zR}from"fs";function il(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 ol(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 Sv(t,e,n){let r=t.forRead(),s;try{s=HR(e,"utf8")}catch{return[]}let{entries:i,add:o}=ol(r),a=o(s.split(`
|
|
2055
|
+
`),n),l=[],c=new Set;for(let u=a;u&&!c.has(u);){let p=i.get(u);if(!p)break;c.add(u),l.push(p),u=r.parentOf(p)}let f=[],d=Date.now();for(let u of l.reverse())if(!r.isSidechain(u,n))try{f.push(...il(r,u,n,d).events)}catch{}return f}function al(t,e,n,r){let s=t.sessionAlive(e,n);if(s!==void 0)return s;if(!r)return!1;try{return Date.now()-zR(r).mtimeMs<1e4}catch{return!1}}function li(t,e){return t.stopped?"stopped":t.running&&e?"running":"done"}var Pf=S(()=>{"use strict"});function YR(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 kv(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 ci,_f=S(()=>{"use strict";ci=(t,e)=>YR(t,{key:e,desc:!0})});function Ov(t){let e=[],n=new Map,r=new Map,s=[],i=[],o=[],a=[],l,c=!1,f=0;for(let d of t){if(d.type==="cleared"){e=[],n=new Map,r=new Map,s=[],i=[],o=[],a=[],l=void 0,c=!1;continue}let u="at"in d?d.at:void 0;if(u!==void 0&&(f=Math.max(f,u)),d.type==="user")l===void 0&&!d.agent?l=u:u!==void 0&&s.push(u),c=!1;else if(d.type==="assistant"){u!==void 0&&i.push(u);let p=d.error?void 0:d.text.split(`
|
|
2056
|
+
`).find(h=>h.trim());p&&a.push({text:$n(p,200),calls:e.length});for(let h of d.tools){let m={id:h.id,name:h.name,input:h.input,at:u,isError:!1};e.push(m),n.set(h.id,m)}}else if(d.type==="tool_result"){let p=n.get(d.id);if(!p)continue;Object.assign(p,{result:d.content,isError:d.isError,exit:d.exit,background:d.background,refused:d.refused,doneAt:u}),d.output&&(p.output=d.output),d.task&&r.set(d.task,p),u!==void 0&&i.push(u)}else if(d.type==="task_done"){let p=d.id?n.get(d.id):d.task?r.get(d.task):void 0;if(!p?.background||p.endAt!==void 0)continue;Object.assign(p,{endAt:u??f,outcome:d.outcome,output:d.output??p.output}),d.exit!==void 0&&(p.exit=d.exit),c&&u!==void 0&&(s.push(u),c=!1)}else d.type==="turn_end"&&(!c&&u!==void 0&&o.push(u),c=!0)}return{calls:e,turnEnds:o,narration:a,lastAt:f,...GR(e,s,i,l,f)}}function GR(t,e,n,r,s){let i=r??t[0]?.at??s,o=[];for(let f of e){let d=-1/0;for(let p of n)p<=f&&p>d&&(d=p);let u=t.some(p=>p.at!==void 0&&p.at<f&&(p.doneAt??1/0)>f);d>-1/0&&!u&&f-d>=VR&&o.push([d,f])}let a=o.reduce((f,[d,u])=>f+Math.max(0,Math.min(s,u)-d),0),l=0,c=-1/0;for(let f of t.filter(d=>d.at!==void 0).sort((d,u)=>d.at-u.at)){let d=f.doneAt??s;d>c&&(l+=d-Math.max(f.at,c),c=d)}return{span:Math.max(0,s-i-a),idle:a,toolMs:l}}function $f(t,e){if(If(t))return;let n=Pv(t),r=t.background?t.endAt:t.doneAt,s=di(t),i=!n&&(t.exit!==void 0?t.exit!==0&&!(t.exit===1&&s&&jy(Yo(s).rest)):t.background?t.outcome==="failed":t.isError),o=t.background?t.output?e?.(t.output)??"":"":t.result??"";return{id:t.id,at:t.at,open:n,failed:i,hidden:!n&&!i&&!!s&&Fy(s)||void 0,exit:t.exit,outcome:t.background?t.outcome:void 0,ms:t.at!==void 0&&r!==void 0?r-t.at:void 0,...XR(o)}}function XR(t){let e=Cs(t).split(`
|
|
2057
|
+
`).map(n=>n.trim()).filter(n=>/[\p{L}\p{N}]/u.test(n));return/^exit(?: code)?:? \d+$/i.test(e[0]??"")&&e.shift(),{first:$n(e[0]??"",120),last:e.length>1?$n(e.at(-1),120):""}}function eI(t,e){let n=new Map,r=0;for(let i of t.calls){let o=di(i),a=o&&$f(i,e);if(!a)continue;let l=Cv(o).trim();if(By(l)){r++;continue}n.set(l,[...n.get(l)??[],a])}let s=[...n].map(([i,o])=>{let a=0;for(let f of o.filter(d=>!d.open&&!d.hidden).reverse()){if(!f.failed)break;a++}let l=Is(i),c=[QR.test(l)?"stops a process":"",ZR.test(l)?"git write":""].filter(Boolean);return{cmd:$n(ed(i),100),runs:o.length,open:o.filter(f=>f.open).length,failed:o.filter(f=>f.failed).length,hidden:o.filter(f=>f.hidden).length,streak:a,long:o.some(f=>(f.ms??0)>Tv),ms:o.reduce((f,d)=>f+(d.ms??0),0),tags:c,latest:o.at(-1)}}).sort((i,o)=>(o.latest.at??0)-(i.latest.at??0));return{runs:s.reduce((i,o)=>i+o.runs,0),failed:s.reduce((i,o)=>i+o.failed,0),lookups:r,groups:s}}function iI(t){let e=t.filter(Boolean),n=e.slice(Math.max(0,e.map(sI).lastIndexOf(!0)));if(n.some(s=>s.includes("$")||/^~|^-$/.test(s)))return;let r=[];for(let s of n.join("/").split("/"))s===".."&&r.length&&!/^(\.\.|[a-zA-Z]:)?$/.test(r.at(-1))?r.pop():s!=="."&&(s||!r.length)&&r.push(s);return r.join("/")}function _v(t,e){let n=new Map,r=[],s=[],i=[],o=c=>c.trim().replace(/^["']|["']$/g,"").replace(/\\/g,"/").replace(/^\/([a-zA-Z])\//,"$1:/"),a=c=>{let f=xy(o(c),e).replace(/^\.\//,"");return!f||/^([a-zA-Z]:)?\//.test(f)?void 0:f},l=c=>a(c)??(o(c)||void 0);for(let c of t.calls){if(c.isError||c.result===void 0)continue;let f=c.doneAt??c.at??0,d=(O,_={},k=!1)=>{let N=a(O);if(!N)return;let B=n.get(N)??{path:N};B.deleted=_.deleted,_.from&&(B.from=_.from),n.set(N,B),r.push({path:N,at:f,whole:k})},u=(O,_)=>{let k=a(O),N=k?n.get(k):void 0;k&&(n.delete(k),r.push({path:k,at:f})),d(_,{from:N?.from??k})},p=c.input??{},h=!1;for(let[O,_]of Object.entries(p)){if(O==="command"||O==="cmd"||typeof _!="string"||!/^(---|\+\+\+) /m.test(_))continue;let k;for(let N of _.split(`
|
|
2058
|
+
`)){let B=/^(---|\+\+\+) (?:[ab]\/)?(.+?)\s*$/.exec(N);if(B?.[1]==="---"){k=B[2];continue}if(B?.[1]==="+++"){h=!0,B[2]==="/dev/null"?k&&k!=="/dev/null"&&d(k,{deleted:!0}):d(B[2]);continue}let Z=/^\*\*\* Move to: (.+?)\s*$/.exec(N);Z&&k&&u(k,Z[1])}}let m=ee(p.file_path)??ee(p.filePath)??ee(p.path),g=rI.some(O=>O in p);!h&&m&&g&&d(m,{},typeof p.content=="string");let v=ee(p.file_path)??ee(p.filePath);if(v&&!g&&!h){let O=l(v);O&&s.push({path:O,at:f})}let E=O=>Object.entries(p).filter(([_,k])=>typeof k=="string"&&(_===O||_.startsWith(`${O} (`))).map(([,_])=>_);if(c.name==="read")for(let O of E("path")){let _=l(O);_&&s.push({path:_,at:f})}let P=ee(p.workdir),A=O=>{let{dirs:_,rest:k}=Yo(O);return{rest:k,at:N=>iI([e,P??"",..._,N].map(o))}};for(let O of[...E("command"),...E("cmd")]){let _=A(O);for(let k of Jy(_.rest)){let N=_.at(k),B=N&&l(N);B&&i.push({path:B,at:f})}}let $=di(c);if($){let O=A($);for(let _ of Uy(O.rest)){let k=O.at(_.from),N=_.to&&O.at(_.to);k&&N?u(k,N):k&&!_.to&&d(k,{deleted:!0})}}}return{edited:[...n.values()],writes:r,reads:s,shellReads:i}}function Rv(t){let e=new Map;for(let s of t)for(let i of s.writes)e.set(i.path,[...e.get(i.path)??[],{id:s.id,at:i.at,whole:i.whole}]);let n=new Map,r=new Map;for(let[s,i]of e){i.sort((a,l)=>a.at-l.at);let o=new Map;for(let a of i)o.set(a.id,a.at);n.set(s,[...o].map(([a,l])=>({id:a,at:l})).sort((a,l)=>a.at-l.at)),i.forEach((a,l)=>{if(!a.whole)return;let c=i.slice(0,l).reverse().find(u=>u.id!==a.id);if(!c)return;let f=t.find(u=>u.id===a.id);[...f.reads,...f.writes].some(u=>u.path===s&&u.at>c.at&&u.at<a.at)||r.set(`${s}
|
|
2059
2059
|
${a.id}
|
|
2060
|
-
${c.id}`,{path:s,by:a.id,over:c.id,at:a.at,overAt:c.at})})}return{writers:n,blind:[...r.values()]}}function
|
|
2061
|
-
`)}function
|
|
2062
|
-
`)}function
|
|
2063
|
-
${r(n-
|
|
2060
|
+
${c.id}`,{path:s,by:a.id,over:c.id,at:a.at,overAt:c.at})})}return{writers:n,blind:[...r.values()]}}function Iv(t,e,n,r,s,i,o,a=Nf){let l=g=>`"${s.get(g)??g}"`,c=e.calls.filter(g=>!If(g)&&Pv(g)).map(g=>({id:g.id,label:Rf(g),short:$n(ee(g.input?.description)??"",80)||Rf(g),at:g.at,background:!!g.background,interrupted:!i||t.liveSince!==void 0&&(g.at??0)<t.liveSince,said:SI($f(g,o))})),f=new Map;for(let g of[...n.reads,...n.shellReads].sort((v,E)=>v.at-E.at)){let v=f.get(g.path)??{path:g.path,times:0,at:0};f.delete(g.path),f.set(g.path,{...v,times:v.times+1,at:Math.max(v.at,g.at)})}let d=t.state==="running"&&!c.length?e.calls.filter(g=>!If(g)).at(-1):void 0,u=d&&$f(d),p=rl(t),h=p==="done"?"finished":p,m=h==="finished"&&e.narration.at(-1)?.calls===e.calls.length;return{id:t.id,name:At(t),state:h,asOf:e.lastAt,activeMs:e.span,idleMs:e.idle,toolMs:e.toolMs,open:c,commands:oI(eI(e,o),c),files:n.edited.map(g=>{let v=a.since(g.path);return{...g,committed:!a.ignored(g.path)&&!a.uncommitted(g.path),ignored:a.ignored(g.path),also:(r.writers.get(g.path)??[]).filter(E=>E.id!==t.id&&E.at>v).map(E=>({name:s.get(E.id)??E.id,at:E.at})),blind:r.blind.filter(E=>E.path===g.path&&(E.by===t.id||E.over===t.id)&&E.overAt>v).map(E=>E.by===t.id?`\u26A0 written at ${Mr(E.at)} over ${l(E.over)}'s ${Mr(E.overAt)} write without reading it`:`\u26A0 ${l(E.by)} wrote over this agent's ${Mr(E.overAt)} write at ${Mr(E.at)} without reading it`)}}),read:[...f.values()].sort((g,v)=>g.at-v.at),narration:(m?e.narration.slice(0,-1):e.narration).map(g=>g.text),latest:d&&u?{id:d.id,label:Rf(d),run:u}:void 0}}function oI(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 Nv(t,e){let n=t.state==="finished"?Nn(t).filter(r=>r.background):[];return n.length?`finished, background call running ${ue(e-(n[0].at??e))}${n.length>1?` (+${n.length-1} more)`:""}`:t.state}function dI(t,e){if(!t.open.length)return[`Now: ${uI(t,e)}`,...t.latest?[`Latest: ${t.latest.label} \xB7 ${Bv(t.latest.run)}${t.latest.run.ms!==void 0?` after ${ue(t.latest.run.ms)}`:""}`]:[]];let n=(r,s)=>r.said?[`${s}"${r.said}"`]:[];return t.open.length===1?[`Now: ${Av(t.open[0],e)}`,...n(t.open[0]," ")]:["Now:",...t.open.flatMap(r=>[` ${Av(r,e)}`,...n(r," ")])]}function fI(t,e){let n=t.latest;return`latest: ${n.interrupted?"interrupted":n.open?`running ${ue(e-(n.at??e))}`:`${Bv(n)}${n.ms!==void 0?` after ${ue(n.ms)}`:""}`}${t.streak>=2?`, failed ${t.streak} in a row`:""}`}function Lv(t,e){let n=[`Sub-agent "${t.name}" (${t.id}): ${cI(t,e)}${t.asOf?` \xB7 as of ${Mr(t.asOf)}`:""}`,""];n.push(...dI(t,e));let r=t.commands;n.push(`Commands: ${tI(r)}`);let{shown:s,more:i}=yI(r);for(let l of s){let c=vI(l);n.push(` ${l.cmd} \xD7${l.runs}${l.failed?`, ${l.failed} failed`:""}${c?` \xB7 ${c}`:""}`,` ${fI(l,e)}`);let f=[l.latest.first,l.latest.last].filter(Boolean).map(d=>`"${d}"`).join(" \u2026 ");f&&n.push(` ${f}`)}i&&n.push(` ${bI(i)}`),Dv(r).runs&&n.push(` ${wI(r)}`),t.activeMs&&n.push(`Time: ${mI(t,e)}`),t.narration.length&&n.push("Narration:",...t.narration.map(l=>` ${l}`)),n.push(`Files written: ${pI(t)}`);for(let l of t.files){let c=l.also.length?` also ${gI(l)}`:"";n.push(` ${kI(l)}${l.ignored?" (ignored)":l.committed?" (committed)":""}${c}`,...l.blind.map(f=>` ${f}`))}let{shown:o,earlier:a}=EI(t);return n.push(`Files read: ${t.read.length||"none"}`,...a?[` +${a} earlier`]:[],...o.map(l=>` ${xI(l)}`)),n.join(`
|
|
2061
|
+
`)}function hI(t,e){let n=t.toolMs+(Nn(t).some(r=>!r.background)?$v(t,e):0);return{tools:n,model:Math.max(0,Lf(t,e)-n)}}function jv(t,e,n,r){let s=e.filter(ui).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 ${ue(r-i)} (${e.length} agents).`];if(n.length){o.push("","Files to check before git add:");for(let u of n)o.push(` ${u.path} ${u.writers.map(p=>`"${p.name}"${p.running?" (running)":p.stopped?" (stopped)":""}`).join(", ")}${u.blind.length?" \u26A0":""}`)}o.push("","Agents:");let a=e.filter(u=>ui(u)||u.state==="failing"||n.some(p=>p.writers.some(h=>h.id===u.id))),l=new Set(a.map(u=>u.id));for(let u of a){let p=Nn(u)[0],h=u.state==="finished"?Nn(u).filter(A=>A.background):[],m=Nv(u,r).padEnd(8),g=h.length?h[0].short:p?`waiting ${ue(r-(p.at??r))} on ${p.short}`:"",v=aI(u),E=[g,v>=2?`failed ${v} in a row`:"",n.some(A=>A.blind.includes(u.id))?"\u26A0":""].filter(Boolean),P=u.parentId&&l.has(u.parentId)?" ".repeat(Math.max(0,u.depth-1)):"";o.push(` ${P}${u.id} ${m} ${`${ue(Lf(u,r))} active`.padStart(10)} ${u.name}${E.length?` \xB7 ${E.join(" \xB7 ")}`:""}`)}let c=e.filter(u=>!l.has(u.id)),f=c.filter(u=>u.state==="stopped").length,d=[c.length-f?`${c.length-f} finished`:"",f?`${f} stopped`:""].filter(Boolean).join(", ");return c.length&&o.push(` ${a.length?"+":""}${d}, nothing to check`),o.push("","Run `typebulb status <id>` for one agent's report, or `typebulb babysit` in the background to be woken when an agent needs attention."),o.join(`
|
|
2062
|
+
`)}function Fv(t,e,n=!1){let r=new Map,s=a=>`"${t.find(l=>l.id===a)?.name??a}"`,i=Math.max(0,...t.map(a=>a.asOf));t.length&&!n&&!t.some(ui)&&e-i>=AI&&r.set("idle",`No agent running for ${ue(e-i)} (${t.length} agents).`);for(let a of t){if(a.state==="finished")for(let l of Nn(a).filter(c=>c.background&&e-(c.at??e)>=TI))r.set(`background:${l.id}`,`${s(a.id)}: finished, background call running ${ue(e-(l.at??e))}: ${l.short}`);for(let l of a.commands.groups.filter(c=>c.streak>=2))r.set(`streak:${a.id}:${l.cmd}`,`${s(a.id)}: failed ${l.streak} in a row: ${l.cmd}`)}let o=t.flatMap(a=>Nn(a).filter(l=>!l.background&&e-(l.at??e)>=CI).map(l=>({a,ms:e-(l.at??e)})));return new Set(o.map(a=>a.a.id)).size>=2&&r.set("waiting",`${new Set(o.map(a=>a.a.id)).size} agents waiting on calls at once: ${o.map(a=>`${s(a.a.id)} ${ue(a.ms)}`).join(", ")}`),r}var VR,xv,Ev,Tv,$n,Cv,di,Mr,Rf,Pv,If,QR,ZR,tI,nI,rI,sI,Nf,Nn,ui,aI,$v,Lf,lI,cI,Av,uI,pI,mI,gI,Mv,yI,bI,Dv,wI,vI,SI,Bv,kI,xI,EI,AI,TI,CI,ll=S(()=>{"use strict";Lr();Os();td();VR=6e4,xv=8,Ev=30,Tv=3*6e4,$n=(t,e)=>(t=Cs(t).replace(/\s+/g," ").trim(),t.length>e?t.slice(0,e)+"\u2026":t),Cv=t=>Yo(t).rest,di=t=>ee(t.input?.command)??ee(t.input?.cmd),Mr=t=>new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),Rf=t=>{let e=di(t);if(e)return $n(ed(Cv(e).trim()),100);let n=$n(Ay(t.input),80);return n?`${zu(t.name)}: ${n}`:zu(t.name)};Pv=t=>t.result===void 0||!!t.background&&t.endAt===void 0,If=t=>!!t.refused&&di(t)!==void 0;QR=/(^|[\s;|&(])(kill|pkill|killall|taskkill|stop-process)\b/i,ZR=/\bgit\s+(-C\s+\S+\s+)?(commit|stash|checkout|reset|push|clean|restore|rebase|merge|cherry-pick|revert)(?![\w-])/;tI=t=>[t.runs?`${t.runs} run, ${t.failed} failed`:"",nI(t)].filter(Boolean).join(", ")||"none",nI=t=>t.lookups?`${t.lookups} ${t.lookups===1?"lookup":"lookups"}`:"",rI=["content","diff","new_string","new_source","edits"],sI=t=>/^([a-zA-Z]:)?\//.test(t);Nf={uncommitted:()=>!0,ignored:()=>!1,since:()=>0};Nn=t=>t.open.filter(e=>!e.interrupted),ui=t=>t.state==="running"||Nn(t).length>0,aI=t=>Math.max(0,...t.commands.groups.map(e=>e.streak)),$v=(t,e)=>t.state==="running"?Math.max(0,e-t.asOf):0,Lf=(t,e)=>t.activeMs+$v(t,e);lI=(t,e)=>({state:Nv(t,e),active:`${ue(Lf(t,e))} active`,idle:t.idleMs?`${ue(t.idleMs)} idle`:""}),cI=(t,e)=>{let n=lI(t,e);return[n.state,n.active,n.idle].filter(Boolean).join(" \xB7 ")},Av=(t,e)=>t.interrupted?`${t.label}: interrupted, its process has ended`:`${t.label}, ${ue(e-(t.at??e))}${t.background?" (background)":""}`,uI=(t,e)=>`nothing open, last entry ${ue(e-t.asOf)} ago`;pI=t=>{let e=t.files.filter(n=>!n.committed&&!n.ignored).length;return t.files.length?`${t.files.length} (${e} uncommitted)`:"none"};mI=(t,e)=>{let n=hI(t,e);return`${ue(n.tools)} in tools, ${ue(n.model)} in the model`},gI=t=>t.also.map(e=>`"${e.name}" ${Mr(e.at)}`).join(", "),Mv=t=>t.failed>0||t.long||t.runs>=3||t.tags.length>0,yI=t=>{let e=t.groups.filter(Mv);return{shown:e.slice(0,xv),more:Math.max(0,e.length-xv)}},bI=t=>`+${t} more like these`,Dv=t=>{let e=t.groups.filter(n=>!Mv(n));return{runs:e.reduce((n,r)=>n+r.runs-r.open,0),hidden:e.reduce((n,r)=>n+r.hidden,0),ms:e.reduce((n,r)=>n+r.ms,0)}},wI=(t,e=!0)=>{let n=Dv(t),r=n.runs-n.hidden,s=e?" other":"",i=l=>l===1?"run":"runs",o=`with ${n.hidden===1?"its":"their"} exit hidden by a pipe`;return`${r?`${r}${s} ${i(r)} passed${n.hidden?`, ${n.hidden} ${o}`:""}`:`${n.hidden}${s} ${i(n.hidden)} ${o}`}, ${ue(n.ms)} in all`},vI=t=>[...t.tags,t.long?`over ${ue(Tv)}`:""].filter(Boolean).join(", "),SI=t=>t?t.last||t.first:"",Bv=t=>t.hidden?"exit hidden":t.outcome&&t.outcome!=="completed"&&t.outcome!=="failed"&&t.exit===void 0?t.outcome:t.exit!==void 0?`exit ${t.exit}`:t.failed?"error":"ok",kI=t=>t.deleted?`${t.path} (deleted)`:t.from?`${t.path} (moved from ${t.from})`:t.path,xI=t=>t.times>1?`${t.path} \xD7${t.times}`:t.path,EI=t=>({shown:t.read.slice(-Ev),earlier:Math.max(0,t.read.length-Ev)});AI=5*6e4,TI=10*6e4,CI=2*6e4});import{openSync as OI,readSync as PI,closeSync as _I,fstatSync as RI,statSync as II}from"fs";function*dl(t,e){if(!t.listChildren)return;let n=t.callerSessionId?.(e),r=ci(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 Uv(t,e,s.sessionId,s.file,i))}}function Uv(t,e,n,r,s){let i=al(t,n,e,r);return{sessionId:n,live:i,children:s.map(o=>({...o,state:li(o,i)}))}}function fi(t,e){let n=t.callerSessionId?.(e);return{sessionId:n,cwd:n&&t.sessionCwd?.(n)||e}}function qv(t,e){let n=fi(t,e);return n.sessionId?n:{sessionId:dl(t,e).next().value?.sessionId,cwd:e}}function fl(t,e,n){let r=t.listSessionFiles(e).find(s=>s.sessionId===n)?.file;return Uv(t,e,n,r,t.listChildren?.(e,n)??[])}function Jv(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)||At(s).toLowerCase().includes(n))}function $I(t,e,n){let r={size:-1,mtimeMs:-1};try{r=II(e)}catch{}let s=ul.get(e);if(s&&s.size===r.size&&s.mtime===r.mtimeMs&&s.cwd===n)return s;let i=Ov(Sv(t,e,"child")),o={size:r.size,mtime:r.mtimeMs,cwd:n,d:i,touches:_v(i,n)};return ul.set(e,o),o}function NI(t){let e;try{e=OI(t,"r")}catch{return}try{let n=RI(e).size,r=(s,i)=>{let o=Buffer.alloc(i);return o.subarray(0,PI(e,o,0,i,s)).toString("utf8")};return n<=2*cl?r(0,n):`${r(0,cl)}
|
|
2063
|
+
${r(n-cl,cl)}`}catch{return}finally{_I(e)}}async function Ln(t,e,n,r){let s=kv([...n.children].sort((d,u)=>(d.started??d.mtime)-(u.started??u.mtime))),i=s.map(d=>$I(t,d.file,e)),o=new Set(s.map(d=>d.file));for(let d of ul.keys())o.has(d)||ul.delete(d);let a=Rv(s.map((d,u)=>({id:d.id,writes:i[u].touches.writes,reads:i[u].touches.reads}))),l=await MI(e,Math.min(1/0,...[...a.writers.values()].flat().map(d=>d.at)),[...a.writers.keys()]),c=new Map(s.map(d=>[d.id,At(d)])),f=s.flatMap((d,u)=>r&&d.id!==r?[]:[{...Iv(d,i[u].d,i[u].touches,a,c,n.live,NI,l),depth:d.depth,parentId:d.parentId}]);return{reports:f,files:r?[]:LI(f,a,l)}}function LI(t,e,n){let r=new Set(t.filter(ui).map(a=>a.id)),s=new Set(t.filter(a=>a.state==="stopped").map(a=>a.id)),i=new Map(t.map(a=>[a.id,a.name]));return[...e.writers].filter(([a])=>n.uncommitted(a)).map(([a,l])=>{let c=n.since(a),f=l.filter(u=>u.at>c);if(f.length<2&&!f.some(u=>r.has(u.id)||s.has(u.id)))return;let d=e.blind.filter(u=>u.path===a&&u.overAt>c).flatMap(u=>[u.by,u.over]);return{path:a,writers:f.map(u=>({id:u.id,name:i.get(u.id)??u.id,running:r.has(u.id),stopped:s.has(u.id)})),blind:[...new Set(d)]}}).filter(a=>!!a).sort((a,l)=>a.path.localeCompare(l.path))}async function MI(t,e,n){let r=s=>process.platform==="win32"?s.toLowerCase():s;try{let s=(await ve(["rev-parse","--show-prefix"],t)).trim(),i=d=>d.startsWith(s)?r(d.slice(s.length)):void 0,o=await ve(["status","--porcelain","-z","--untracked-files=all"],t),a=new Set,l=o.split("\0");for(let d=0;d<l.length;d++){let u=l[d];if(u.length<4)continue;(u[0]==="R"||u[0]==="C")&&d++;let p=i(u.slice(3));p&&a.add(p)}let c=new Map;if(Number.isFinite(e)){let d=0;for(let u of(await ve(["log",`--since=${new Date(e).toISOString()}`,"--format=@%ct","--name-only","--","."],t)).split(`
|
|
2064
2064
|
`)){if(u.startsWith("@")){d=Number(u.slice(1))*1e3;continue}let p=u.trim()&&i(u.trim());p&&!c.has(p)&&c.set(p,d)}}let f=new Set(n.length?(await ve(["check-ignore","--",...n],t).catch(()=>"")).split(`
|
|
2065
|
-
`).map(d=>r(d.trim())).filter(Boolean):[]);return{uncommitted:d=>a.has(r(d)),ignored:d=>f.has(r(d)),since:d=>c.get(r(d))??0}}catch{return Nf}}var cl,
|
|
2065
|
+
`).map(d=>r(d.trim())).filter(Boolean):[]);return{uncommitted:d=>a.has(r(d)),ignored:d=>f.has(r(d)),since:d=>c.get(r(d))??0}}catch{return Nf}}var ul,cl,pl=S(()=>{"use strict";Nr();Pf();Lr();_f();ll();ul=new Map;cl=4096});import{existsSync as Wv,openSync as DI,readSync as BI,closeSync as jI,statSync as pi,readdirSync as Kv,watchFile as FI,unwatchFile as Hv,mkdirSync as UI,writeFileSync as qI,readFileSync as Mf,unlinkSync as JI,rmSync as WI}from"fs";import{stat as KI}from"fs/promises";import{dirname as HI,join as Mn,resolve as zv}from"path";function GI(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:ol(t),thread:"main"},n;function r(y,x){let w={offset:x,text:""},C;try{C=pi(y).size}catch{return w}if(C<=x)return w;let M;try{M=DI(y,"r")}catch{return w}try{let U=C-x,j=Buffer.alloc(U),z=0;for(;z<U;){let Q=BI(M,j,z,U-z,x+z);if(!Q)break;z+=Q}return{offset:x+z,text:j.subarray(0,z).toString("utf8")}}finally{jI(M)}}let s=new Set,i,o=0;function a(){if(e.file){for(let y of s)if(y.file===e.file)return y;return}return i}function l(y){let x={d:t.createDriver(e.cwd,y),file:y,id:`new:${++o}`,startedAt:Date.now()};return s.add(x),e.file||(i=x),x}function c(){let y=[...s].filter(w=>w.file);if(!y.length)return[];let x=new Map(t.listSessionFiles(e.cwd).map(w=>[w.file,w.sessionId]));return y.map(w=>{let C=x.get(w.file);return{rec:w,sessionId:C??w.id,pending:C===void 0}})}let f=()=>c().filter(y=>y.pending&&y.rec.prompt!==void 0);async function d(y){s.delete(y),i===y&&(i=void 0);try{await y.d.dispose()}catch(x){console.error("[composer] dispose:",V(x))}}function u(){let y=a(),x=new Set(f().map(w=>w.rec));for(let w of[...s])w!==y&&(x.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(x=>x.file===i.file);y&&B(y)}i&&!e.file&&i.prompt!==void 0&&e.sessionId!==i.id&&(N(void 0,i.id),e.everAttached=!0)}let h=y=>Mn(y,YI),m=(y,x)=>Mn(h(y),`${x}.lock`);function g(y,x){try{let w=m(y,x);if(Date.now()-pi(w).mtimeMs>=Yv)return!1;try{let C=parseInt(Mf(w,"utf8").trim(),10);if(C===process.pid||!GI(C))return!1}catch{}return!0}catch{return!1}}function v(y,x){if(x)try{UI(h(y),{recursive:!0}),qI(m(y,x),String(process.pid))}catch(w){console.error("[lock] claim failed:",V(w))}}function E(y){try{WI(Mn(y,".claude-bulb"),{recursive:!0,force:!0})}catch{}}function P(y){let x=h(y);if(!Wv(x))return;let w;try{w=Kv(x)}catch{return}let C=Date.now();for(let M of w){if(!M.endsWith(".lock"))continue;let U=Mn(x,M);try{let j=pi(U);C-j.mtimeMs>VI&&JI(U)}catch{}}}function A(y){try{return pi(y),!1}catch(x){return x.code==="ENOENT"}}function $(){let y=e;if(y.file&&!A(y.file)){v(y.cwd,y.sessionId);return}let x=O(y);x&&B(x)}function O(y){if(!y.everAttached)return _(y.cwd)??k(y.cwd,()=>!0)}function _(y){let x=h(y);if(!Wv(x))return;let w;try{w=Kv(x)}catch{return}let C;for(let U of w)if(U.endsWith(".lock"))try{let j=pi(Mn(x,U));if(Date.now()-j.mtimeMs>=Yv||parseInt(Mf(Mn(x,U),"utf8").trim(),10)!==process.pid)continue;(!C||j.mtimeMs>C.mtime)&&(C={sessionId:U.slice(0,-5),mtime:j.mtimeMs})}catch{}if(!C)return;let M=t.listSessionFiles(y).find(U=>U.sessionId===C.sessionId);if(!(!M||A(M.file)))return M}function k(y,x){return t.listSessionFiles(y).sort((w,C)=>C.mtime-w.mtime).find(w=>!g(y,w.sessionId)&&x(w))}function N(y,x){let w=e;if(w.file)try{Hv(w.file)}catch{}w.file=y,w.sessionId=x,w.partial="",w.offset=0,w.latest={in:0,out:0,cached:0,cacheCreate:0},w.latestModel=null,w.index=ol(t),w.chainLastId=void 0,w.buffer.push({type:"cleared"}),w.buffer.push({type:"session",sessionId:x})}function B(y){let x=e;i=void 0,Pi(),n=y.file,N(y.file,y.sessionId),x.everAttached=!0,v(x.cwd,y.sessionId),Z(y.file)}function Z(y){if(ie(),!!y){try{Hv(y)}catch{}FI(y,{interval:200},()=>ie())}}function q(){Pi(),n=void 0,N(void 0,"")}function ie(){let y=e;if(!y.file)return;let x=r(y.file,y.offset);if(!x.text)return;y.offset=x.offset,y.partial+=x.text;let w=y.partial.lastIndexOf(`
|
|
2066
2066
|
`);if(w<0)return;let C=y.index.add(y.partial.slice(0,w).split(`
|
|
2067
|
-
`),y.thread);if(y.partial=y.partial.slice(w+1),!C)return;let M=[],{entries:U}=y.index,j=U.get(C),z=!1;for(;j;){if(M.push(j),t.idOf(j)===y.chainLastId){z=!0;break}let Q=t.parentOf(j);j=Q?U.get(Q):void 0}if(z)for(let Q=M.length-2;Q>=0;Q--)ae(M[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(M.map(fe=>t.idOf(fe))),dt=oe(U);for(let fe=M.length-1;fe>=0;fe--)ae(M[fe]),ye(t.idOf(M[fe]),dt,Q)}y.chainLastId=C}function oe(y){let x=new Map;for(let w of y.values()){let C=t.parentOf(w);if(!C)continue;let M=x.get(C);M?M.push(w):x.set(C,[w])}return x}function ye(y,x,w){if(!y)return;let C=x.get(y);if(!C)return;let M=C.filter(Q=>!t.isSidechain(Q,e.thread));if(M.length<2)return;let U=M.filter(Q=>!w.has(t.idOf(Q)));if(!U.length)return;let j=[],z=0;for(let Q of U){let dt=ke(Q,x);j.push(...dt.events),z+=dt.count}z>0&&e.buffer.push({type:"fork",atId:y,count:z,events:j})}function ke(y,x){let w=[],C=[y];for(;C.length;){let j=C.pop();if(t.isSidechain(j,e.thread))continue;w.push(j);let z=x.get(t.idOf(j)??"");if(z)for(let Q of z)C.push(Q)}w.sort((j,z)=>(Date.parse(t.timestampOf(j)??"")||0)-(Date.parse(t.timestampOf(z)??"")||0));let M=[];for(let j of w)t.isRecoveryNoise(j)||M.push(...
|
|
2068
|
-
`).filter(Boolean):await t.walkFiles?.(e.cwd)??[];return(await Promise.all(x.map(async C=>{try{return{f:C,m:(await
|
|
2069
|
-
`)){if(!U.trim())continue;let j=t.parseEntry(U);if(!j)continue;let z=t.searchText(j);z&&C.push({text:z,lower:z.toLowerCase()})}return $p.set(y,{mtime:x,turns:C}),C}async function
|
|
2070
|
-
`)){let c=l.replace(/\s+/g," ").trim();c&&i.push({text:c,lower:c.toLowerCase()})}let{hitCount:o,snippet:a}=
|
|
2071
|
-
${t}`;return
|
|
2072
|
-
`)}function
|
|
2067
|
+
`),y.thread);if(y.partial=y.partial.slice(w+1),!C)return;let M=[],{entries:U}=y.index,j=U.get(C),z=!1;for(;j;){if(M.push(j),t.idOf(j)===y.chainLastId){z=!0;break}let Q=t.parentOf(j);j=Q?U.get(Q):void 0}if(z)for(let Q=M.length-2;Q>=0;Q--)ae(M[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(M.map(fe=>t.idOf(fe))),dt=oe(U);for(let fe=M.length-1;fe>=0;fe--)ae(M[fe]),ye(t.idOf(M[fe]),dt,Q)}y.chainLastId=C}function oe(y){let x=new Map;for(let w of y.values()){let C=t.parentOf(w);if(!C)continue;let M=x.get(C);M?M.push(w):x.set(C,[w])}return x}function ye(y,x,w){if(!y)return;let C=x.get(y);if(!C)return;let M=C.filter(Q=>!t.isSidechain(Q,e.thread));if(M.length<2)return;let U=M.filter(Q=>!w.has(t.idOf(Q)));if(!U.length)return;let j=[],z=0;for(let Q of U){let dt=ke(Q,x);j.push(...dt.events),z+=dt.count}z>0&&e.buffer.push({type:"fork",atId:y,count:z,events:j})}function ke(y,x){let w=[],C=[y];for(;C.length;){let j=C.pop();if(t.isSidechain(j,e.thread))continue;w.push(j);let z=x.get(t.idOf(j)??"");if(z)for(let Q of z)C.push(Q)}w.sort((j,z)=>(Date.parse(t.timestampOf(j)??"")||0)-(Date.parse(t.timestampOf(z)??"")||0));let M=[];for(let j of w)t.isRecoveryNoise(j)||M.push(...il(t,j,e.thread,e.sessionStartMs).events);return{count:M.reduce((j,z)=>j+(z.type==="user"||z.type==="assistant"?1:0),0),events:M}}function ae(y){if(!t.isSidechain(y,e.thread))try{let{events:x,usage:w,model:C,cost:M}=il(t,y,e.thread,e.sessionStartMs);for(let U of x)e.buffer.push(U);x.some(U=>U.type==="assistant")&&a()?.d.clearCompletedDraft(),x.some(U=>U.type==="user")&&a()?.d.clearEcho(),C&&(e.latestModel=C),w&&(e.latest=w),(w||M)&&e.buffer.push({type:"usage",...e.latest,cost:M})}catch(x){console.error("[mirror] skipped malformed entry:",V(x))}}async function xe(){return{cwd:e.cwd,pid:process.pid,composer:!!t.createDriver,children:!!t.listChildren,elsewhere:await Pt()}}async function Pt(){if(t.listSessionFiles(e.cwd).length)return;let y=await In();if(!y)return;let x=zv(y).toLowerCase();for(let w=zv(e.cwd);w.toLowerCase()!==x;){let C=HI(w);if(C===w)return;w=C;let M=t.listSessionFiles(w).length;if(M)return{dir:w,count:M}}}Pt().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 Qa;async function T(y,x){e.thread!=="child"&&b.accept(y,x)&&console.log(x)}function R(){return al(t,e.sessionId,e.cwd,e.file)}function L(){return t.chainWorking([...e.index.entries.values()])&&R()}function D(){!t.createDriver||a()||e.latestModel||L()||l(e.file)}async function K(y){let x=e;$(),p(),D(),u();let w=a();for(let j of s)j!==w&&j.d.dialog;let C=c().filter(j=>j.rec.d.streaming).map(j=>j.sessionId),M=L(),U=t.createDriver?{streaming:!!w?.d.streaming,foreign:!w&&M,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:x.buffer.slice(y),cursor:x.buffer.length,working:!!w?.d.streaming||M,latestModel:x.latestModel,child:x.child?.id??null,composer:U,busy:C}}async function J(){$(),p();let y=a();if(y?.d.error&&!y.d.streaming&&(await d(y),y=void 0),!y){if(L())return{ok:!1,error:"the agent is mid-turn in a terminal \u2014 watch only"};y=l(e.file)}let x=y;return{ok:!0,d:x.d,markSent:w=>{x.prompt===void 0&&(x.prompt=w)}}}async function Ke(y,x){if(!t.createDriver)return{ok:!1,error:"not supported"};let w=String(y??"").trim();if(!w)return{ok:!1,error:"empty message"};let C=await J();if(!C.ok)return C;let M=await C.d.send(w,x);return M.ok&&C.markSent(w),M}async function Y(y,x){let w=a();return w?w.d.respondUi(String(y??""),x??{}):{ok:!1,error:"no dialog pending"}}async function de(y,x){if(!t.createDriver)return{ok:!1,error:"not supported"};if(!y||typeof y.type!="string")return{ok:!1,error:"bad command"};if(x?.spawn){let C=await J();return C.ok?C.d.rpc(y):C}let w=a();return!w||w.d.error?{ok:!1,error:"not running"}:w.d.rpc(y)}async function _e(){let y=a();if(y)try{await y.d.stop()}catch(x){console.error("[composer] stop:",V(x))}return{ok:!0}}async function Wr(){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,q(),l(void 0),u(),{ok:!0})):{ok:!1,error:"not supported"}}async function on(){if(!t.createDriver)return[];let y=await ve(["ls-files","--cached","--others","--exclude-standard"],e.cwd).catch(()=>null),x=y!==null?y.split(`
|
|
2068
|
+
`).filter(Boolean):await t.walkFiles?.(e.cwd)??[];return(await Promise.all(x.map(async C=>{try{return{f:C,m:(await KI(Mn(e.cwd,C))).mtimeMs}}catch{return{f:C,m:0}}}))).sort((C,M)=>M.m-C.m).map(C=>C.f)}function _t(){for(let y of[...s])d(y)}async function Kl(y){return t.createDriver?hv(e.cwd,y):{ok:!1,error:"not supported"}}async function Hl(y){return mv(e.cwd,String(y??""))}async function ex(y,x){return wv(String(y??""),String(x??""))}async function tx(y){let x=t.listChildren?.(e.cwd,e.sessionId)??[],w=R(),{reports:[C]}=await Ln(t,e.cwd,{sessionId:e.sessionId,live:w,children:x.map(M=>({...M,state:li(M,w)}))},y);return C?{ok:!0,report:C}:{ok:!1,error:"child not found"}}async function nx(){let y=t.sessionsWorking?.(e.cwd),x=t.listSessionFiles(e.cwd).map(({sessionId:C,file:M,mtime:U})=>({sessionId:C,mtime:U,preview:t.readPreview(M),working:y?.has(C)})),w=f().map(C=>({sessionId:C.sessionId,mtime:C.rec.startedAt,preview:C.rec.prompt??"",pending:!0}));return ci([...x,...w],C=>C.mtime)}let $p=new Map;function Np(y,x){let w=$p.get(y);if(w&&w.mtime===x)return w.turns;let C=[],M="";try{M=Mf(y,"utf8")}catch{return[]}for(let U of M.split(`
|
|
2069
|
+
`)){if(!U.trim())continue;let j=t.parseEntry(U);if(!j)continue;let z=t.searchText(j);z&&C.push({text:z,lower:z.toLowerCase()})}return $p.set(y,{mtime:x,turns:C}),C}async function rx(y){let x=y.toLowerCase(),w=[],C=0,M=t.sessionsWorking?.(e.cwd);for(let{sessionId:U,file:j,mtime:z}of t.listSessionFiles(e.cwd).sort((Q,dt)=>dt.mtime-Q.mtime)){let Q=ai(Np(j,z),x),dt=(t.listChildren?.(e.cwd,U)??[]).map(fe=>({c:fe,hit:ai(Np(fe.file,fe.mtime),x)})).filter(fe=>fe.hit.hitCount);if(!(!Q.hitCount&&!dt.length)){for(let{c:fe,hit:lx}of ci(dt,cx=>cx.c.mtime))w.push({sessionId:U,mtime:fe.mtime,preview:At(fe),...lx,child:{id:fe.id,kind:fe.kind,depth:fe.depth}});if(w.push({sessionId:U,mtime:z,preview:t.readPreview(j),working:M?.has(U),...Q}),++C>=XI)break}}return w}async function sx(y){let x=e,w=t.listSessionFiles(x.cwd).find(C=>C.sessionId===y);if(!w){let C=f().find(M=>M.sessionId===y)?.rec;return C?((i!==C||x.sessionId!==C.id)&&(i=C,Pi(),n=void 0,N(void 0,C.id),x.everAttached=!0,u()),{ok:!0}):{ok:!1,error:"session not found"}}return w.file===x.file?{ok:!0}:(B(w),p(),u(),{ok:!0})}async function ix(){if(!t.listChildren||!e.sessionId)return[];let y=R();return t.listChildren(e.cwd,e.sessionId).map(x=>({...x,state:li(x,y)}))}async function ox(y){let x=e;if(!t.listChildren)return{ok:!1,error:"this harness has no child transcripts"};let w=t.listChildren(x.cwd,x.sessionId).find(C=>C.id===y);return w?(x.thread="child",x.child=w,N(w.file,x.sessionId),Z(w.file),{ok:!0}):{ok:!1,error:"child not found"}}async function ax(){let y=n;return!Pi()||!y?{ok:!0}:(N(y,e.sessionId),Z(y),{ok:!0})}function Pi(){let y=e;return y.thread==="main"?!1:(y.thread="main",y.child=void 0,!0)}return E(e.cwd),P(e.cwd),$(),{info:xe,poll:K,logInlineStatus:T,listSessions:nx,searchSessions:rx,attach:sx,listChildren:ix,openChild:ox,closeChild:ax,composerSend:Ke,composerStop:_e,composerNew:Wr,composerFiles:on,composerUiRespond:Y,composerRpc:de,composerPaste:Kl,composerPasteRead:Hl,summarizeTurn:ex,childStatus:tx,shutdownComposer:_t}}var zI,YI,Yv,VI,XI,hl=S(()=>{"use strict";Qt();lv();Nr();Cf();gv();vv();Pf();pl();_f();Lr();zI=".typebulb",YI=`${zI}/locks`,Yv=5e3,VI=6e4;XI=50});import{existsSync as Ff,mkdirSync as QI,readFileSync as Vv,writeFileSync as ZI}from"fs";import{join as Dn,isAbsolute as e$}from"path";async function qf(t,e){let n=e$(t)?t:Dn(X,t);return Ff(n)?(Cd(n,e),{ok:!0}):{ok:!1,error:"file not found"}}async function Jf(t){let e=X,n=Td(t),r=Dn(e,"typebulbs");QI(r,{recursive:!0});let s=kd(n),i=`${s}.bulb.md`;for(let c=2;Ff(Dn(r,i))&&Vv(Dn(r,i),"utf8")!==n;c++)i=`${s}-${c}.bulb.md`;let o=Dn(r,i);Ff(o)||ZI(o,n);let a=Dn("typebulbs",i),l=await wn(a,{cwd:e,open:!1});return{ok:!0,file:a,pid:l.pid,url:l.url}}async function Wf(){return G(X)}async function Kf(t){let e=(await G()).find(n=>n.pid===t);return e?{ok:!0,outcome:await yt(e)}:(await ar(t),{ok:!0})}async function Hf(){let t=await mn(X);return da(X).filter(e=>!e.serverOnly).map(e=>({...e,trusted:kn(e.path),lastRunAt:t(e.path)}))}async function zf(t){let e=t.toLowerCase(),n=[];for(let r of da(X).filter(s=>!s.serverOnly).sort((s,i)=>i.mtime-s.mtime)){let s="";try{s=Vv(r.path,"utf8")}catch{continue}let i=[];for(let l of s.split(`
|
|
2070
|
+
`)){let c=l.replace(/\s+/g," ").trim();c&&i.push({text:c,lower:c.toLowerCase()})}let{hitCount:o,snippet:a}=ai(i,e);o&&n.push({path:r.path,hitCount:o,snippet:a})}return n}async function Yf(t,e){let n=X;e!=null&&pr(t,e);let r=await wn(t,{cwd:n,open:!1,trust:e});return{ok:!0,file:r.file,pid:r.pid,url:r.url,trust:!!r.trust}}async function Vf(t){return{cap:await Ed(t)}}async function Gf(t,e){return pr(t,e),{ok:!0}}async function Xf(t,e){return Xe(t,e)}async function Qf(){return hi&&Date.now()-hi.fetchedAt<=n$?hi.samples:(Df??=r$().finally(()=>{Df=null}),Df)}async function r$(){try{let t=await fetch(`${t$}/api/scripts/u/samples?stubs`,{signal:AbortSignal.timeout(Xv)});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:tc(i.config)}));return hi={samples:s,fetchedAt:Date.now()},s}catch{return hi?.samples??[]}}async function Zf(t){return Uf.test(t)?Zv(Gv,"samples",t,!0):{ok:!1,error:"bad slug"}}async function tp(){let t=ep();if(!t)return{bulbs:[]};let e=`${ml()}
|
|
2071
|
+
${t}`;return Zt?.key===e&&Date.now()-Zt.fetchedAt<=s$?{user:Zt.user,bulbs:Zt.bulbs}:(Bf??=i$(e,t).finally(()=>{Bf=null}),Bf)}async function jf(t,e,n){let r=await fetch(`${t}${e}`,{headers:n,signal:AbortSignal.timeout(Xv)});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 i$(t,e){let n={Authorization:`Bearer ${e}`};try{let r=ml(),s;try{s=await jf(r,"/api/me",n)}catch{let a=new URL(r);r=`${a.protocol}//api.${a.host}`,s=await jf(r,"/api/me",n)}let o=(await jf(r,"/api/scripts/list",n)).filter(a=>a.userSlug===s.slug&&!a.isTemplate).map(a=>({slug:a.slug,name:a.name,description:tc(a.config)}));return Zt={key:t,user:s.slug,bulbs:o,fetchedAt:Date.now()},{user:s.slug,bulbs:o}}catch{return Zt?.key===t?{user:Zt.user,bulbs:Zt.bulbs}:{bulbs:[]}}}async function np(t,e,n=!1){return!Uf.test(e)||!Uf.test(t)?{ok:!1,error:"bad slug"}:Zv(ml(),t,e,n)}async function Zv(t,e,n,r){let s=Ja(e,n);try{let i=await Ha({origin:t,userSlug:e,slug:n,dest:Dn(X,s)},{force:r,token:ep(),timeoutMs:Qv});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 rp(t,e=!1){let n=ep();if(!n)return{ok:!1,error:"no TYPEBULB_TOKEN in .env"};try{let r=Ka(t,X,ml()),s=await Ya(r,{token:n,force:e,timeoutMs:Qv});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 t$,Gv,n$,Xv,Qv,hi,Df,Uf,s$,Zt,Bf,ml,ep,gl=S(()=>{"use strict";Rr();Qt();Cf();te();t$="https://api.typebulb.com",Gv="https://typebulb.com",n$=3600*1e3,Xv=5e3,Qv=15e3,hi=null,Df=null;Uf=/^[a-z0-9][a-z0-9-]*$/,s$=300*1e3,Zt=null,Bf=null,ml=()=>ka("TYPEBULB_ORIGIN",X)||Gv,ep=()=>ka("TYPEBULB_TOKEN",X)});import{readFileSync as op,writeFileSync as tS,mkdirSync as o$,appendFileSync as nS,rmSync as eS}from"fs";import{join as wl,dirname as a$}from"path";import{createServer as l$}from"http";function en(t){try{return JSON.parse(op(t,"utf8"))}catch{return null}}function bl(t,e){o$(a$(t),{recursive:!0}),tS(t,JSON.stringify(e,null,2)+`
|
|
2072
|
+
`)}function sS(t,e,n){let r=wl(t,".gitignore"),s="";try{s=op(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(`
|
|
2073
2073
|
`)?`
|
|
2074
|
-
`:"";try{
|
|
2074
|
+
`:"";try{nS(r,a+n+`
|
|
2075
2075
|
`+o.join(`
|
|
2076
2076
|
`)+`
|
|
2077
|
-
`)}catch(l){console.error("[switcher] .gitignore update failed",V(l))}}function
|
|
2077
|
+
`)}catch(l){console.error("[switcher] .gitignore update failed",V(l))}}function p$(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?yi="live":s>f$&&(yi="uncached")}function oS(t,e){let n={"content-type":"application/json",authorization:`Bearer ${e}`,"anthropic-version":t.headers["anthropic-version"]||"2023-06-01",...Nd},r=t.headers["anthropic-beta"];return typeof r=="string"&&(n["anthropic-beta"]=r),n}function h$(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 aS(t){let e;try{e=JSON.parse(t)}catch{return t}gi=typeof e?.model=="string"?e.model:null,ut&&(e.model=ut),jn&&(e.provider=iS(jn));let n=/haiku/i.test(gi||"");return bi!=null&&!n&&(e.reasoning={effort:sp[bi]}),delete e.thinking,e.output_config&&delete e.output_config.effort,h$(e),JSON.stringify(e)}function m$(){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}
|
|
2078
2078
|
data: ${JSON.stringify(a)}
|
|
2079
2079
|
|
|
2080
2080
|
`}case"content_block_delta":case"content_block_stop":{let l=n.get(a.index);return l==null?null:(a.index=l,`event: ${a.type}
|
|
@@ -2082,11 +2082,11 @@ data: ${JSON.stringify(a)}
|
|
|
2082
2082
|
|
|
2083
2083
|
`)}default:return i}};return i=>{t+=i;let o="",a;for(;(a=t.indexOf(`
|
|
2084
2084
|
|
|
2085
|
-
`))!==-1;){let l=t.slice(0,a);if(t=t.slice(a+2),!l.trim())continue;let c=s(l);c!==null&&(o+=c)}return o}}function
|
|
2085
|
+
`))!==-1;){let l=t.slice(0,a);if(t=t.slice(a+2),!l.trim())continue;let c=s(l);c!==null&&(o+=c)}return o}}function g$(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 mi(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 y$(t,e,n){if(!ut){mi(e,400,"invalid_request_error",d$);return}let r=process.env.OPENROUTER_API_KEY;if(!r){mi(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(ap,{method:"POST",headers:oS(t,r),body:aS(n),signal:s.signal})}catch(d){mi(e,502,"api_error",`proxy upstream failed: ${V(d)}`);return}let o=i.headers.get("content-type")||"application/json";if(e.writeHead(i.status,{"content-type":o}),!i.body){e.end();return}let a=o.includes("event-stream"),l=i.body.getReader(),c=new TextDecoder,f=a?m$():null;try{for(;;){let{done:d,value:u}=await l.read();if(d)break;if(u)if(f){let p=c.decode(u,{stream:!0});p$(p);let h=f(p);h&&e.write(h)}else e.write(Buffer.from(u))}}catch{}finally{e.writableEnded||e.end()}}async function b$(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(!ut||!r)return s();try{let i=await fetch(`${ap}/count_tokens`,{method:"POST",headers:oS(t,r),body:aS(n)});if(!i.ok)return s();let o=await i.text();e.writeHead(200,{"content-type":"application/json"}),e.end(o)}catch{s()}}function w$(t,e){let n=t.url||"/";if(t.method==="HEAD"){e.writeHead(200),e.end();return}if(t.method!=="POST"){mi(e,404,"not_found_error",n);return}g$(t).then(r=>{if(n.includes("count_tokens"))return b$(t,e,r);if(n.includes("/v1/messages"))return y$(t,e,r);mi(e,404,"not_found_error",n)})}function v$(){return Br&&Bn?Promise.resolve(Bn):new Promise((t,e)=>{let n=l$(w$);n.on("error",e),n.listen(0,"127.0.0.1",()=>{Br=n,Bn=n.address().port,console.log(`[switcher] wire proxy listening on ${yl(Bn)}`),t(Bn)})})}function S$(){try{Br?.close()}catch{}Br=null,Bn=null}function k$(t,e){let n=vl(t),r=en(n),s=r||{};if((!s.env||typeof s.env!="object")&&(s.env={}),s.env.ANTHROPIC_BASE_URL===yl(e)&&s.env.ANTHROPIC_AUTH_TOKEN)return;let i=Sl(t);if(!en(i)){let a={};for(let l of rS)a[l]=l in s.env?s.env[l]:null;bl(i,{managedBy:"agent-switcher",fileExisted:r!==null,snapshot:a,active:null})}s.env.ANTHROPIC_BASE_URL=yl(e),s.env.ANTHROPIC_AUTH_TOKEN=u$,bl(n,s),sS(t,[".claude/settings.local.json",".claude/.cc-switcher.json"],"# agent switcher (local Claude Code model override)")}function x$(t,e,n){let r=Sl(t),s=en(r)||{managedBy:"agent-switcher",fileExisted:!1,snapshot:{}};s.active={model:e,provider:n},bl(r,s)}function lS(t){let e=vl(t),n=Sl(t),r=en(n),s=en(e);if(s?.env){let i=r?.snapshot||{};for(let o of rS){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{eS(e,{force:!0})}catch{}else bl(e,s)}try{eS(n,{force:!0})}catch{}}async function E$(){let t=!!process.env.OPENROUTER_API_KEY,e=[];try{e=(await bt()).filter(r=>r.provider==="openrouter"&&!lp(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:Rd()??void 0;return{hasKey:t,models:e,error:n}}async function A$(){if(Br&&ut)return{active:!0,managed:!0,model:ut,port:Bn,provider:jn,routedModel:gi,caching:yi,reasoning:bi,externalBaseUrl:null};let t=en(vl(X))?.env||{};return{active:!1,managed:!1,model:null,port:null,provider:null,routedModel:null,caching:"unknown",reasoning:bi,externalBaseUrl:t.ANTHROPIC_BASE_URL||null}}async function cS(t,e){let n=await v$();return ut=t,jn=e,k$(X,n),n}async function T$({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(lp(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 cS(t,cp[t]??null),gi=null,yi="unknown",x$(X,t,jn)}catch(e){return{ok:!1,error:`failed to start the wire proxy: ${V(e)}`}}return{ok:!0}}async function C$({level:t}){return t!=null&&(!Number.isInteger(t)||t<0||t>=sp.length)?{ok:!1,error:`reasoning level must be 0\u2013${sp.length-1} or null`}:(bi=t,{ok:!0,level:t})}async function O$(){return lS(X),ut=null,jn=null,gi=null,yi="unknown",{ok:!0}}async function P$({key:t}){let e=(t||"").trim();if(!e)return{ok:!1,error:"empty key"};let n=X,r=wl(n,".env"),s="";try{s=op(r,"utf8")}catch{}try{if(/^\s*OPENROUTER_API_KEY\s*=/m.test(s))tS(r,s.replace(/^\s*OPENROUTER_API_KEY\s*=.*$/m,`OPENROUTER_API_KEY=${e}`));else{let i=s&&!s.endsWith(`
|
|
2086
2086
|
`)?`
|
|
2087
|
-
`:"";
|
|
2088
|
-
`)}}catch(i){return{ok:!1,error:V(i)}}return process.env.OPENROUTER_API_KEY=e,
|
|
2089
|
-
`)}catch(o){return{ok:!1,error:`could not write ${t}: ${V(o)}`}}return{ok:!0,count:e.length}}var
|
|
2087
|
+
`:"";nS(r,i+`OPENROUTER_API_KEY=${e}
|
|
2088
|
+
`)}}catch(i){return{ok:!1,error:V(i)}}return process.env.OPENROUTER_API_KEY=e,sS(n,[".env"],"# secrets"),{ok:!0}}function _$(){if(!(!Br&&!ut)){try{lS(X)}catch{}S$()}}function R$(t,e){return uS.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(uS.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 $$(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=ip(e?.cache_read_input_tokens)||ip(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 N$({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(lp(t))return{ok:!1,error:"Anthropic model \u2014 not offered or probed via OpenRouter"};let n=Date.now(),r=Array(350).fill("Caching probe filler sentence; its only purpose is to exceed the prompt-cache minimum token threshold.").join(" "),s={"content-type":"application/json",authorization:`Bearer ${e}`,"anthropic-version":"2023-06-01"},i={model:t,max_tokens:64,system:[{type:"text",text:r,cache_control:{type:"ephemeral"}}],messages:[{role:"user",content:"Reply with exactly: ok"}]},o=async a=>{let l=new AbortController,c=setTimeout(()=>l.abort(),2e4);try{let f=JSON.stringify(a?{...i,provider:iS(a)}:i),d=await fetch(ap,{method:"POST",signal:l.signal,headers:s,body:f}),u=await d.json().catch(()=>({}));return{r:d,j:u}}finally{clearTimeout(c)}};try{let{r:a,j:l}=await o();if(!a.ok){let 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:R$(a.status,v),restriction:I$(v)}}let c=typeof l?.provider=="string"?l.provider:void 0,f=l?.content?.find?.(v=>v.type==="text")?.text??l?.content?.[0]?.text??"ok",d=ip(l?.usage?.cache_creation_input_tokens),{r:u,j:p}=await o(c),{works:h,read:m,note:g}=$$(u.ok,p?.usage,c);return h===!0&&c&&(cp[t]=c,ut===t&&(jn=c)),{ok:!0,callable:!0,status:a.status,ms:Date.now()-n,provider:c,sample:String(f).trim().slice(0,60),cache:{works:h,created:d,read:m,note:g}}}catch(a){let l=V(a);return{ok:!0,callable:!1,ms:Date.now()-n,error:/abort/i.test(l)?"timed out (20s)":l}}}var c$,ap,u$,d$,rS,f$,sp,vl,Sl,yl,lp,Br,Bn,ut,jn,gi,yi,bi,cp,ip,iS,uS,dS=S(()=>{"use strict";Rr();Qt();Wt();c$="https://openrouter.ai/api",ap=`${c$}/v1/messages`,u$="typebulb-proxy-managed",d$="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.",rS=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"],f$=5e3,sp=["low","medium","high"],vl=t=>wl(t,".claude","settings.local.json"),Sl=t=>wl(t,".claude",".cc-switcher.json"),yl=t=>`http://127.0.0.1:${t}`;lp=t=>/^anthropic\//i.test(t)||/claude/i.test(t),Br=null,Bn=null,ut=null,jn=null,gi=null,yi="unknown",bi=1,cp={},ip=t=>typeof t=="number"?t:0,iS=t=>({order:[t],allow_fallbacks:!1});uS=/data policy|no endpoints|no allowed providers|privacy|requires.*(training|logging|data)/i;(async function(){try{let e=en(Sl(X)),n=e?.active?.model;if(!n)return;let s=(en(vl(X))?.env||{}).ANTHROPIC_BASE_URL||"";if(!/127\.0\.0\.1|localhost/.test(s))return;let i=await cS(n,e.active.provider??cp[n]??null);console.log(`[switcher] re-adopted override after restart: ${n} via ${yl(i)}`)}catch(e){console.error("[switcher] boot reconcile failed",V(e))}})()});var pS={};Ri(pS,{agentMessage:()=>Ko,attach:()=>U$,blockToMarkdown:()=>Wo,breakout:()=>Jf,capText:()=>Re,childStatus:()=>z$,cleanUserText:()=>qt,clearSwitchModel:()=>O$,closeChild:()=>W$,composerPasteRead:()=>K$,displayName:()=>L$,downloadSample:()=>Zf,firstLineDigest:()=>Be,git:()=>ve,gitChangedFiles:()=>Af,gitDiff:()=>Tf,info:()=>M$,isHiddenTurn:()=>Rs,launchBulb:()=>Yf,listBreakouts:()=>Wf,listBulbFiles:()=>Hf,listChildren:()=>q$,listMyBulbs:()=>tp,listSamples:()=>Qf,listSessions:()=>j$,listSwitchModels:()=>E$,logInlineStatus:()=>B$,openChild:()=>J$,openFile:()=>qf,poll:()=>D$,predictTrustOf:()=>Vf,probeModel:()=>N$,pullRemoteBulb:()=>np,pushLocalBulb:()=>rp,readBulbLog:()=>Xf,repoRoot:()=>In,saveOpenRouterKey:()=>P$,searchBulbs:()=>zf,searchSessions:()=>F$,setBulbTrust:()=>Gf,setReasoning:()=>C$,setSwitchModel:()=>T$,shutdownSwitcher:()=>_$,stopBreakout:()=>Kf,summarizeTurn:()=>H$,switchState:()=>A$,toolResultDigest:()=>Qu});var fS,L$,M$,D$,B$,j$,F$,U$,q$,J$,W$,K$,H$,z$,hS=S(()=>{"use strict";hl();zo();gl();Nr();dS();zo();Ps();fS=new rr,L$=fS.displayName,{info:M$,poll:D$,logInlineStatus:B$,listSessions:j$,searchSessions:F$,attach:U$,listChildren:q$,openChild:J$,closeChild:W$,composerPasteRead:K$,summarizeTurn:H$,childStatus:z$}=Dr(fS)});var gS={};Ri(gS,{attach:()=>e1,breakout:()=>Jf,childStatus:()=>o1,closeChild:()=>r1,composerPasteRead:()=>s1,displayName:()=>Y$,downloadSample:()=>Zf,git:()=>ve,gitChangedFiles:()=>Af,gitDiff:()=>Tf,info:()=>V$,launchBulb:()=>Yf,listBreakouts:()=>Wf,listBulbFiles:()=>Hf,listChildren:()=>t1,listMyBulbs:()=>tp,listSamples:()=>Qf,listSessions:()=>Q$,logInlineStatus:()=>X$,openChild:()=>n1,openFile:()=>qf,poll:()=>G$,predictTrustOf:()=>Vf,pullRemoteBulb:()=>np,pushLocalBulb:()=>rp,readBulbLog:()=>Xf,repoRoot:()=>In,searchBulbs:()=>zf,searchSessions:()=>Z$,setBulbTrust:()=>Gf,stopBreakout:()=>Kf,summarizeTurn:()=>i1});var mS,Y$,V$,G$,X$,Q$,Z$,e1,t1,n1,r1,s1,i1,o1,yS=S(()=>{"use strict";hl();ad();gl();Nr();mS=new ir,Y$=mS.displayName,{info:V$,poll:G$,logInlineStatus:X$,listSessions:Q$,searchSessions:Z$,attach:e1,listChildren:t1,openChild:n1,closeChild:r1,composerPasteRead:s1,summarizeTurn:i1,childStatus:o1}=Dr(mS)});import{readFileSync as a1,writeFileSync as l1,mkdirSync as c1}from"fs";import{homedir as u1}from"os";import*as kl from"path";async function vS(){try{let t=await fetch(new URL("/api/tags",wS()).toString(),{signal:AbortSignal.timeout(d1)});return t.ok?((await t.json()).models??[]).map(n=>n.name).filter(n=>!!n):[]}catch{return[]}}function SS(t){let e;try{e=a1(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&&!up(r)}}}catch{}return{json:void 0,unreadable:!0}}function up(t){let e=t?.providers;return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function f1(t){let e=up(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 kS(){let{json:t,unreadable:e}=SS(bS());return e?{installed:[],configured:null}:{installed:await vS(),configured:f1(t)}}async function xS(){let t=await vS();return t.length?p1(bS(),t,wS()):{ok:!1,error:"Ollama is not running (or has no models installed)"}}function p1(t,e,n){let{json:r,unreadable:s}=SS(t);if(s)return{ok:!1,error:`could not parse ${t} \u2014 edit the ollama provider there yourself`};let i={...r??{},providers:{...up(r)??{},ollama:{baseUrl:`${n}/v1`,api:"openai-completions",apiKey:"ollama",models:e.map(o=>({id:o}))}}};try{c1(kl.dirname(t),{recursive:!0}),l1(t,JSON.stringify(i,null,2)+`
|
|
2089
|
+
`)}catch(o){return{ok:!1,error:`could not write ${t}: ${V(o)}`}}return{ok:!0,count:e.length}}var d1,bS,wS,ES=S(()=>{"use strict";Qt();Rr();d1=1500,bS=()=>kl.join(u1(),".pi","agent","models.json"),wS=()=>mr(process.env.OLLAMA_HOST??"http://localhost:11434")});var TS={};Ri(TS,{attach:()=>v1,breakout:()=>Jf,closeChild:()=>x1,composerFiles:()=>C1,composerNew:()=>T1,composerPaste:()=>_1,composerPasteRead:()=>R1,composerRpc:()=>P1,composerSend:()=>E1,composerStop:()=>A1,composerUiRespond:()=>O1,displayName:()=>h1,downloadSample:()=>Zf,git:()=>ve,gitChangedFiles:()=>Af,gitDiff:()=>Tf,info:()=>m1,launchBulb:()=>Yf,listBreakouts:()=>Wf,listBulbFiles:()=>Hf,listChildren:()=>S1,listMyBulbs:()=>tp,listSamples:()=>Qf,listSessions:()=>b1,logInlineStatus:()=>y1,ollamaOffer:()=>kS,ollamaSync:()=>xS,openChild:()=>k1,openFile:()=>qf,poll:()=>g1,predictTrustOf:()=>Vf,pullRemoteBulb:()=>np,pushLocalBulb:()=>rp,readBulbLog:()=>Xf,repoRoot:()=>In,searchBulbs:()=>zf,searchSessions:()=>w1,setBulbTrust:()=>Gf,shutdownComposer:()=>$1,stopBreakout:()=>Kf,summarizeTurn:()=>I1});var AS,h1,m1,g1,y1,b1,w1,v1,S1,k1,x1,E1,A1,T1,C1,O1,P1,_1,R1,I1,$1,CS=S(()=>{"use strict";hl();xf();gl();Nr();ES();AS=new $r,h1=AS.displayName,{info:m1,poll:g1,logInlineStatus:y1,listSessions:b1,searchSessions:w1,attach:v1,listChildren:S1,openChild:k1,closeChild:x1,composerSend:E1,composerStop:A1,composerNew:T1,composerFiles:C1,composerUiRespond:O1,composerRpc:P1,composerPaste:_1,composerPasteRead:R1,summarizeTurn:I1,shutdownComposer:$1}=Dr(AS)});import*as Zk from"fs/promises";import*as Ot from"path";Ii();te();function Hu(t){if(!He.includes(t))throw new Error(`Unknown block kind '${t}' (one of: ${He.join(", ")})`);return t}function Sy(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=Hu(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}zo();ad();xf();var xl={claude:{adapter:()=>new rr,server:()=>Promise.resolve().then(()=>(hS(),pS))},codex:{adapter:()=>new ir,server:()=>Promise.resolve().then(()=>(yS(),gS))},pi:{adapter:()=>new $r,server:()=>Promise.resolve().then(()=>(CS(),TS))}};function OS(t){return t in xl}function jr(){return Object.keys(xl)}function Fr(){return Object.fromEntries(Object.entries(xl).map(([t,e])=>[t,e.adapter]))}function PS(t){return xl[t].server()}var wi=Fr();function _S(){for(let t of Object.values(wi))try{t().ensureHarnessSupport()}catch{}}function rt(){for(let t of Object.keys(wi))try{if(wi[t]().detectsSelf())return t}catch{}}function RS(t){let e=jr(),n=new Map(e.filter(i=>wi[i]).map(i=>[i,wi[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 fp=5e3;function dp(t){try{return t()}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exit(1)}}function IS(t){let n={subcommand:"run",file:"",watch:!0,open:process.env.TERM_PROGRAM==="vscode"||rt()!==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=fp;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=dp(()=>Fp(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=dp(()=>Hu(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=dp(()=>Sy(i.slice(1)))),n}function $S(){console.log(`
|
|
2090
2090
|
typebulb - Local bulb runner for Typebulb
|
|
2091
2091
|
|
|
2092
2092
|
Usage:
|
|
@@ -2274,7 +2274,7 @@ Examples:
|
|
|
2274
2274
|
typebulb my-editor.bulb.md
|
|
2275
2275
|
typebulb --no-watch my-editor.bulb.md
|
|
2276
2276
|
typebulb .
|
|
2277
|
-
`)}
|
|
2277
|
+
`)}Et();js();Ii();qs();Et();import*as We from"path";import{spawn as aN,execSync as lN}from"child_process";import{createRequire as cN}from"module";import{existsSync as uN}from"fs";import*as Ee from"fs/promises";import*as Se from"path";var pp=[{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"}],hp=[{name:"dom"},{name:"dom.iterable"},{name:"dom.asynciterable"}];function mp(t,e){if(!e)return t.filter(s=>!s.since);let n={"5.0":0,"5.5":1},r=n[e];return t.filter(s=>!s.since||n[s.since]<=r)}te();var N1=`
|
|
2278
2278
|
/**
|
|
2279
2279
|
* Get raw data chunk from the Data tab.
|
|
2280
2280
|
* @param index - Chunk index (0-based). Separate chunks with 2 blank lines.
|
|
@@ -2285,7 +2285,7 @@ Examples:
|
|
|
2285
2285
|
* @param index - Chunk index (0-based)
|
|
2286
2286
|
* @throws If chunk is not valid JSON/JSON-ish
|
|
2287
2287
|
*/
|
|
2288
|
-
json<T = unknown>(index: number): T
|
|
2288
|
+
json<T = unknown>(index: number): T;`,L1=`
|
|
2289
2289
|
/**
|
|
2290
2290
|
* Get the insight data produced by the inference layer.
|
|
2291
2291
|
*
|
|
@@ -2294,7 +2294,7 @@ Examples:
|
|
|
2294
2294
|
*
|
|
2295
2295
|
* @returns The parsed insight JSON, or undefined if no insight is available
|
|
2296
2296
|
*/
|
|
2297
|
-
insight<T = unknown>(): T | undefined;`,
|
|
2297
|
+
insight<T = unknown>(): T | undefined;`,M1=`
|
|
2298
2298
|
/**
|
|
2299
2299
|
* Replace the data this run is working on.
|
|
2300
2300
|
*
|
|
@@ -2317,7 +2317,7 @@ Examples:
|
|
|
2317
2317
|
*
|
|
2318
2318
|
* @param value - Any JSON-serializable value
|
|
2319
2319
|
*/
|
|
2320
|
-
setInsight(value: unknown): Promise<void
|
|
2320
|
+
setInsight(value: unknown): Promise<void>;`,NS=`options: {
|
|
2321
2321
|
messages: Array<{ role: "user" | "assistant"; content: string }>;
|
|
2322
2322
|
system?: string;
|
|
2323
2323
|
/** 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. */
|
|
@@ -2328,7 +2328,7 @@ Examples:
|
|
|
2328
2328
|
webSearch?: boolean;
|
|
2329
2329
|
/** Abort the request. On abort the promise rejects / the stream ends. */
|
|
2330
2330
|
signal?: AbortSignal;
|
|
2331
|
-
}`,
|
|
2331
|
+
}`,LS=`
|
|
2332
2332
|
/** Provider-reported token counts for one call \u2014 real usage from the API, never an estimate.
|
|
2333
2333
|
* \`output\` is total billed output (reasoning included); \`reasoning\` is the itemized subset where
|
|
2334
2334
|
* the provider splits it (OpenAI, Gemini, OpenRouter \u2014 Anthropic doesn't); \`cacheRead\` is the
|
|
@@ -2340,10 +2340,10 @@ type AiChunk =
|
|
|
2340
2340
|
| { kind: "text"; text: string }
|
|
2341
2341
|
| { kind: "reasoning"; text: string }
|
|
2342
2342
|
| { kind: "usage"; usage: AiUsage };
|
|
2343
|
-
`,
|
|
2343
|
+
`,MS=`
|
|
2344
2344
|
/** What backs \`tb.ai\`: the user's own keys, the quota-limited courtesy model, or nothing. */
|
|
2345
2345
|
type AiAccess = "own" | "courtesy" | "none";
|
|
2346
|
-
`,
|
|
2346
|
+
`,DS=`
|
|
2347
2347
|
/**
|
|
2348
2348
|
* General-purpose AI call. \`tb.ai(opts)\` resolves with the full text; \`tb.ai.stream(opts)\`
|
|
2349
2349
|
* returns an async iterable of {@link AiChunk} deltas you consume with \`for await\`.
|
|
@@ -2353,7 +2353,7 @@ type AiAccess = "own" | "courtesy" | "none";
|
|
|
2353
2353
|
* @throws On rate limit, network error, or provider error
|
|
2354
2354
|
*/
|
|
2355
2355
|
ai: {
|
|
2356
|
-
(${
|
|
2356
|
+
(${NS}): Promise<{ text: string; usage?: AiUsage }>;
|
|
2357
2357
|
/**
|
|
2358
2358
|
* Streaming counterpart of \`tb.ai()\`. Yields \`{ kind: "text" | "reasoning", text }\` deltas
|
|
2359
2359
|
* as they arrive, then one final \`{ kind: "usage", usage }\` chunk with the call's token
|
|
@@ -2370,8 +2370,8 @@ type AiAccess = "own" | "courtesy" | "none";
|
|
|
2370
2370
|
* if (c.kind === "text") answer += c.text;
|
|
2371
2371
|
* }
|
|
2372
2372
|
*/
|
|
2373
|
-
stream(${
|
|
2374
|
-
};`,
|
|
2373
|
+
stream(${NS}): AsyncIterable<AiChunk>;
|
|
2374
|
+
};`,BS=`
|
|
2375
2375
|
/**
|
|
2376
2376
|
* Returns AI models available to the current user.
|
|
2377
2377
|
* Models are filtered by the user's configured API keys.
|
|
@@ -2401,7 +2401,7 @@ type AiAccess = "own" | "courtesy" | "none";
|
|
|
2401
2401
|
* \`tb.mode\` or the length of \`tb.models()\` \u2014 which hosts offer a courtesy
|
|
2402
2402
|
* model is the host's business and changes without your bulb changing.
|
|
2403
2403
|
*/
|
|
2404
|
-
aiAccess(): Promise<AiAccess>;`,
|
|
2404
|
+
aiAccess(): Promise<AiAccess>;`,D1="\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;",jS=`
|
|
2405
2405
|
/**
|
|
2406
2406
|
* The mode this bulb is running in.
|
|
2407
2407
|
*
|
|
@@ -2411,7 +2411,7 @@ type AiAccess = "own" | "courtesy" | "none";
|
|
|
2411
2411
|
* - \`'inline'\` \u2014 Running inline in an agent's transcript, rendered by the mirror
|
|
2412
2412
|
* (sandboxed, client-only: AI, filesystem, and server RPC are unavailable)
|
|
2413
2413
|
*/
|
|
2414
|
-
mode: ${hy};`,
|
|
2414
|
+
mode: ${hy};`,FS=`
|
|
2415
2415
|
/**
|
|
2416
2416
|
* Local filesystem access (CLI only).
|
|
2417
2417
|
*
|
|
@@ -2432,7 +2432,7 @@ type AiAccess = "own" | "courtesy" | "none";
|
|
|
2432
2432
|
list(path?: string): Promise<Array<{ name: string; dir: boolean; mtime: number }>>;
|
|
2433
2433
|
/** 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. */
|
|
2434
2434
|
remove(path: string): Promise<boolean>;
|
|
2435
|
-
};`,
|
|
2435
|
+
};`,US=`
|
|
2436
2436
|
/**
|
|
2437
2437
|
* The bulb's folder \u2014 absolute path to \`<bulb-dir>/<filename-stem>/\`
|
|
2438
2438
|
*
|
|
@@ -2440,7 +2440,7 @@ type AiAccess = "own" | "courtesy" | "none";
|
|
|
2440
2440
|
* \`tb.fs\` already resolves relative paths against it, so bulb code writing
|
|
2441
2441
|
* its own files never needs it. CLI only \u2014 throws in ide/published/inline mode.
|
|
2442
2442
|
*/
|
|
2443
|
-
readonly dir: string;`,
|
|
2443
|
+
readonly dir: string;`,B1=`
|
|
2444
2444
|
/**
|
|
2445
2445
|
* Async value inspector for tensor-like objects.
|
|
2446
2446
|
*
|
|
@@ -2493,49 +2493,49 @@ type AiAccess = "own" | "courtesy" | "none";
|
|
|
2493
2493
|
*
|
|
2494
2494
|
* @returns The full canonical URL
|
|
2495
2495
|
*/
|
|
2496
|
-
url(): Promise<string>;`,
|
|
2496
|
+
url(): Promise<string>;`,j1="\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;",F1="\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;",U1="\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>>;",gp=`${LS}${MS}
|
|
2497
2497
|
/**
|
|
2498
2498
|
* Typebulb utilities namespace.
|
|
2499
2499
|
* Type \`tb.\` to discover available helpers.
|
|
2500
2500
|
*/
|
|
2501
|
-
declare const tb: {${
|
|
2501
|
+
declare const tb: {${N1}${B1}${L1}${M1}${F1}${U1}${j1}${DS}${FS}${US}${BS}${D1}${jS}
|
|
2502
2502
|
};
|
|
2503
|
-
`,
|
|
2503
|
+
`,q1=`
|
|
2504
2504
|
/**
|
|
2505
2505
|
* Print to the CLI's stdout \u2014 the same channel as \`console.log\` here (the server's console IS
|
|
2506
2506
|
* the bulb's log). One log verb across blocks: page-side \`tb.log\` reaches this same stdout.
|
|
2507
2507
|
*/
|
|
2508
|
-
log(...args: any[]): void;`,yp=`${
|
|
2508
|
+
log(...args: any[]): void;`,yp=`${LS}${MS}
|
|
2509
2509
|
/**
|
|
2510
2510
|
* Typebulb utilities namespace (server-side).
|
|
2511
2511
|
* Type \`tb.\` to discover available helpers.
|
|
2512
2512
|
*/
|
|
2513
|
-
declare const tb: {${
|
|
2513
|
+
declare const tb: {${q1}${DS}${FS}${US}${BS}${jS}
|
|
2514
2514
|
};
|
|
2515
|
-
`;
|
|
2515
|
+
`;vt();import H1 from"p-limit";vt();import{resolve as JS}from"resolve.exports";var Tt={maxRelativeTypeRefs:500,maxBareDeps:8,maxBareDepth:3,prefetchConcurrency:4,negativeTtlMs:1e4},vi=["index.d.ts","index.d.mts"],bp=/\.d\.(ts|mts|cts)$/i;function El(t){return/\.d\.(ts|mts|cts)(?:[?#].*)?$/i.test(t)||/[?&]dts(?:[&#]|$)/i.test(t)}function qS(t){return[`${t}.d.ts`,`${t}.d.mts`]}function tn(t){if(!t||t==="./"||t==="/")return[...vi];let e=t.replace(/\.(mjs|cjs|js|mts|cts|ts)$/i,""),n=qS(e),r=e.endsWith("/")?e:`${e}/`;return n.push(...qS(`${r}index`)),n}async function Ur(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(J1(a.status)&&s<e)continue;return a}catch{if(s<e)continue;return}finally{clearTimeout(o)}}}function J1(t){return t===408||t===429||t>=500&&t<600}var Al=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)||El(r.url)))return r}}looksLikeDts(e){return/^\s*export\s*\{\s*\}\s*;?\s*$/m.test(e)?!0:/declare\s+(module|namespace|class|interface|function|const|var|let)/.test(e)||/interface\s+\w+/.test(e)||/type\s+\w+\s*=/.test(e)}async loadPackageAtVersionedRoot(e,n){let r=this.cdnClient.packageJson(new F({name:e,version:n})),s=await Ur(r);if(!s?.ok)return;let i;try{i=await s.json()}catch{return}if(i)return{pkg:i,baseDir:this.cdnClient.baseDir(new F({name:e,version:n??i.version})),version:n}}extractPathFromResult(e){if(typeof e=="string")return e;if(Array.isArray(e))return e.find(n=>typeof n=="string")}async tryUntilSuccess(e,n){for(let r of e){let s=await n(r);if(s)return s}}async resolveFromSelected(e,n,r){if(e.kind==="types"){let o=Cn(e.path);if(!o||o==="/"||o===".")return this.tryUntilSuccess([...vi],n);if(!bp.test(o)){let a=await this.tryUntilSuccess(tn(o),n);if(a)return a}return n(o)}let s=tn(e.path),i=r?.subpath?[...s,...vi]:[...vi,...s];return this.tryUntilSuccess(i,n)}toResolutionResult(e){return{kind:bp.test(e)?"types":"probe",path:e}}resolveExportsPath(e,n){let r=n||".",s=e;try{let i=this.extractPathFromResult(JS(s,r,{conditions:["types"]}));if(i)return i}catch{}try{return this.extractPathFromResult(JS(s,r,{browser:!0,conditions:["import","default","module","browser","node"]}))}catch{return}}async resolve(e){try{let n=F.parse(e),{pkg:r,baseDir:s}=await this.loadPackageAtVersionedRoot(n.name,n.version)||{};if(!r||!s)return;let i={name:n.name,version:n.version},o=new F(i).format(),a=new F({...i,subpath:n.subpath}).format(),l=d=>this.fetchCandidateFrom(s,n.name,d);if(n.subpath){let d=Xd(n.subpath),u=this.resolveExportsPath(r,d);if(u){let h=await this.resolveFromSelected(this.toResolutionResult(u),l,{subpath:!0});if(h)return{...h,resolvedPkg:a}}let p=await this.tryUntilSuccess(tn(d),l);if(p)return{...p,resolvedPkg:a}}let c=r.types??r.typings;if(c){let d=await this.resolveFromSelected({kind:"types",path:c},l);if(d)return{...d,resolvedPkg:o}}let f=this.resolveExportsPath(r,".");if(f){let d=await this.resolveFromSelected(this.toResolutionResult(f),l);if(d)return{...d,resolvedPkg:o}}return}catch{return}}async fetchCandidateFrom(e,n,r){let s=Cn(r),i=new URL(s,e).toString(),o=await this.tryUrls([i]);return o?{dts:o.dts,url:o.url,resolvedPkg:n}:void 0}};vt();import{gunzipSync as W1}from"fflate";var Tl=class{async fetchAndExtract(e,n){let r=this.getTarballUrl(e,n),s=await Ur(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=W1(e),s=new TextDecoder("utf-8"),i=0;for(;i<r.length-512;){let o=r.slice(i,i+512);if(o[0]===0)break;let a=o.slice(0,100),l=a.indexOf(0),c=s.decode(a.slice(0,l>0?l:100)).trim(),f=o.slice(124,136),d=s.decode(f).trim().replace(/\0/g,""),u=parseInt(d,8)||0,p=String.fromCharCode(o[156]);if(i+=512,(p==="0"||p==="\0")&&(c.endsWith(".d.ts")||c.endsWith(".d.mts"))){let h=r.slice(i,i+u);n.set(this.normalizeTarPath(c),s.decode(h))}i+=Math.ceil(u/512)*512}}catch{}return n}};var Cl=class{constructor(e,n,r=new Tl){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=On.majorOf(r),o=e.filter(a=>On.majorOf(a)===i);if(o.length)return o.sort((a,l)=>On.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=tn(e);return n!==e&&r.push(`${e}.d.ts`,`${e}/index.d.ts`),r}async fetchFromVersionedRoot(e,n){let r=new F(e),s=r.version;if(!s)return;let i;try{i=await this.tarballFetcher.fetchAndExtract(r.name,s)}catch{return}if(!i||i.size===0)return;for(let[a,l]of i.entries()){let c=this.cdnClient.file(e,a);try{await this.cache.setCachedFile(c,l)}catch{}}let o=n.subpath?this.subpathCandidates(n.subpath):["index.d.ts"];for(let a of o){let l=i.get(a);if(l)return{dts:l,url:this.cdnClient.file(e,a),resolvedPkg:n.subpath?new F(n).format():n.name}}}async resolve(e){let n=F.parse(e);if(n.name)for(let r of this.typesNameCandidates(n.name)){let s=`@types/${r}`,i;try{i=await this.cdnClient.fetchVersionsIndex(s)}catch{continue}if(!i?.versions?.length)continue;let o=this.selectTypesVersion(i.versions,i.distTags,n.version),a=await this.fetchFromVersionedRoot(`${s}@${o}`,n);if(a)return a}}};var Ol=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(`
|
|
2516
2516
|
`).filter(s=>{let i=s.trimStart();return!(i.startsWith("*")||i.startsWith("//")||i.startsWith("/*"))}).join(`
|
|
2517
|
-
`),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://"))}};
|
|
2518
|
-
`);await this.prefetchBareDeps(h,c,u,p,s);let m=l.format(),g=e===m?[e]:[e,m],v=g.some(E=>this.ambientlyDeclares(i,E));return v?this.markFileAmbient(u,f):p.push(...g.map(E=>({module:E,path:f}))),{pkg:e,mainPath:f,files:u,shims:p,ambient:v}}};lf();
|
|
2519
|
-
`,"utf8"),await Ee.writeFile(Se.join(e,"code.tsx"),t.code,"utf8"),await Ee.writeFile(Se.join(e,"tb.d.ts"),gp,"utf8"),{dir:e}}var vp={target:"es2023",module:"esnext",moduleResolution:"bundler",strict:!0,noEmit:!0,skipLibCheck:!0,esModuleInterop:!0,allowSyntheticDefaultImports:!0,forceConsistentCasingInFileNames:!0};function
|
|
2520
|
-
`,"utf8"),{dir:e}}function
|
|
2521
|
-
`))console.log(`${e} ${r}`);return t.length>0}function
|
|
2517
|
+
`),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://"))}};vt();var WS="file:///node_modules",Pl=class{constructor(){this.epoch=0}bumpEpoch(){this.epoch+=1}epochDir(){return`__tsepoch_${this.epoch}`}pathForMain(e){return`${WS}/${this.epochDir()}/${e}/index.d.ts`}pathFor(e,n){let r=Cn(n);return`${WS}/${this.epochDir()}/${e}/${r}`}};import{LRUCache as K1}from"lru-cache";function KS(t){let e=new K1({ttl:Tt.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 Ur(s,{init:{cache:"no-store"}});if(!l?.ok){l?.status===404&&(e.set(s,!0),await t.recordNegative(s));return}let c=await l.text(),f=l.url||s;return await t.clearNegative(s),await t.setCachedFile(f,c),{dts:c,url:f}})();return n.set(s,a),await a.finally(()=>n.delete(s))}catch{return}}}var Si=class{constructor(e){this.inFlight=new Map,this.scanner=new Ol,this.cache=e.cache,this.cdnClient=e.cdnClient,this.versionResolver=e.versionResolver,this.packageService=e.packageService,this.fetchDts=KS(e.cache),this.typescriptProvider=new Al(this.fetchDts,e.cdnClient),this.definitelyTypedProvider=new Cl(e.cdnClient,e.cache),this.virtualFs=new Pl}withInFlight(e,n){let r=this.inFlight.get(e);if(r)return r;let s=n().finally(()=>this.inFlight.delete(e));return this.inFlight.set(e,s),s}invalidate(){this.virtualFs.bumpEpoch(),this.inFlight.clear()}pushFileIfNew(e,n,r){e.some(s=>s.path===n)||e.push({path:n,content:r})}createStubDef(e){let n=this.virtualFs.pathForMain(e);return{pkg:e,mainPath:n,files:[{path:n,content:"export const _shim: any; export default _shim;"}],shims:[{module:e,path:n}]}}async fetchViaProviders(e){for(let n of[this.typescriptProvider,this.definitelyTypedProvider])try{let r=await n.resolve(e);if(r?.dts)return r}catch{}}async fetchRootDts(e,n){let{effectivePackage:r,root:s,pinned:i}=await this.versionResolver.effectivePackage(e,n),o=await this.cache.getCachedDts(r);if(o?.content){let l=o.url??this.cdnClient.file(i?`${s}@${i}`:s,"index.d.ts");return{dts:o.content,url:l,resolvedPkg:r}}let a;try{a=await this.fetchViaProviders(r)}catch{return}if(!(!a?.dts||!a.url)&&new F(r).subpath===new F(a.resolvedPkg||r).subpath){try{await this.cache.setCachedDts(r,a.dts,a.url)}catch{}return a}}extractPackageRootUrl(e){let n=e.pathname.match(/^(.+@[^/]+\/)/);return n?new URL(n[1],e.origin):new URL("./",e)}toVirtualPath(e,n,r){let s=n.pathname.startsWith(e.pathname)?n.pathname.slice(e.pathname.length):`__deps__/${encodeURIComponent(n.toString()).replace(/%/g,"_")}.d.ts`;return this.virtualFs.pathFor(r,s)}computeEntryPath(e,n){if(!e)return{mainPath:this.virtualFs.pathForMain(n),packageRootUrl:void 0};let r=new URL(e),s=this.extractPackageRootUrl(r);return{mainPath:this.toVirtualPath(s,r,n),packageRootUrl:s}}async expandRelativeRefs(e,n,r,s,i=new Set,o){if(!i.has(n)&&(i.add(n),!(i.size>Tt.maxRelativeTypeRefs)))try{let a=new URL(n),l=new URL("./",a);o??(o=this.extractPackageRootUrl(a));let c=this.scanner.collectRelativeTypeRefs(e).slice(0,Tt.maxRelativeTypeRefs);for(let f of c)await this.tryRelativeRef(f,l,o,r,s,i)}catch{}}async tryRelativeRef(e,n,r,s,i,o){try{let a=new URL(e,n),l=a.pathname+a.search,c=El(l)?[l]:tn(l);for(let f of c){let u=new URL(f,a).toString();if(o.has(u))return;let p=await this.fetchDts(u);if(p?.dts){let h=this.toVirtualPath(r,new URL(p.url),s);this.pushFileIfNew(i,h,p.dts),await this.expandRelativeRefs(p.dts,p.url,s,i,o,r);return}}}catch{}}isDifferentPackage(e,n){return e===n?!1:new F(e).name!==new F(n).name}ambientlyDeclares(e,n){if(/^(?:import|export)\b/m.test(e))return!1;for(let r of e.matchAll(/declare\s+module\s+['"]([^'"]+)['"]/g)){let s=r[1];if(s===n||s.endsWith("/*")&&n.startsWith(s.slice(0,-1)))return!0}return!1}markFileAmbient(e,n){let r=e.find(s=>s.path===n);r&&(r.ambient=!0)}async prefetchBareDeps(e,n,r,s,i){try{let o=this.scanner.collectBareModuleRefs(e).slice(0,Tt.maxBareDeps).filter(c=>this.isDifferentPackage(c,n));if(!o.length)return;let a=new Set([n]),l=H1(Tt.prefetchConcurrency);await Promise.all(o.map(c=>l(()=>this.prefetchBareDepsRecursive(c,r,s,Tt.maxBareDepth,a,i).catch(()=>{}))))}catch{}}async prefetchBareDepsRecursive(e,n,r,s,i,o){if(s<=0||i.has(e))return;i.add(e);let a=await this.fetchRootDts(e,o);if(!a?.dts)return;let l=a.resolvedPkg||e,c=this.virtualFs.pathForMain(l);this.pushFileIfNew(n,c,a.dts),this.ambientlyDeclares(a.dts,e)?this.markFileAmbient(n,c):r.push({module:e,path:c}),a.url&&await this.expandRelativeRefs(a.dts,a.url,l,n);let f=this.scanner.collectBareModuleRefs(a.dts).slice(0,Tt.maxBareDeps).filter(d=>!i.has(d));for(let d of f)await this.prefetchBareDepsRecursive(d,n,r,s-1,i,o)}async resolve(e,n,r){let s=await this.packageService.extractImports(e),i=r?[...s,...r]:s;return(await Promise.all(i.map(a=>this.resolveOne(a,n)))).filter(a=>!!a)}async resolveOne(e,n){let{effectivePackage:r}=await this.versionResolver.effectivePackage(e,n);return this.withInFlight(r,async()=>{let s=new F(e),i=await this.fetchRootDts(e,n)??(s.subpath?await this.fetchRootDts(s.name,n):void 0);return i?this.buildDefFromContent(e,i,i.resolvedPkg||e,n):this.createStubDef(e)})}async buildDefFromContent(e,n,r,s){let{dts:i,url:o,resolvedPkg:a}=n,l=new F(a||r),c=l.version?`${l.name}@${l.version}`:l.name,{mainPath:f,packageRootUrl:d}=this.computeEntryPath(o,c),u=[{path:f,content:i}],p=[];o&&await this.expandRelativeRefs(i,o,c,u,void 0,d);let h=u.map(E=>E.content).join(`
|
|
2518
|
+
`);await this.prefetchBareDeps(h,c,u,p,s);let m=l.format(),g=e===m?[e]:[e,m],v=g.some(E=>this.ambientlyDeclares(i,E));return v?this.markFileAmbient(u,f):p.push(...g.map(E=>({module:E,path:f}))),{pkg:e,mainPath:f,files:u,shims:p,ambient:v}}};lf();vt();Er();ni();of();xr();import*as qr from"path";var z1=qr.join(Oa,"pkg"),Y1=qr.join(Oa,"files"),V1=qr.join(Oa,"negative.json"),Rl=class{pkgMem=new Map;fileMem=new Map;negativeCache=new Pn(new Ar(V1));async getCachedDts(e){if(this.pkgMem.has(e))return this.pkgMem.get(e);await ne();let n=await St(HS(e));return this.pkgMem.set(e,n),n}async setCachedDts(e,n,r){let s={content:n,url:r};this.pkgMem.set(e,s),await _l(async()=>{await ne(),await Fe(HS(e),JSON.stringify(s))})}async getCachedFile(e){if(this.fileMem.has(e))return this.fileMem.get(e);await ne();let n=await Ca(zS(e));return this.fileMem.set(e,n),n}async setCachedFile(e,n){this.fileMem.set(e,n),await _l(async()=>{await ne(),await Fe(zS(e),n)})}isNegative(e){return this.negativeCache.isNegative(e)}async recordNegative(e){await _l(async()=>{await ne(),await this.negativeCache.recordNegative(e)})}clearNegative(e){return _l(()=>this.negativeCache.clearNegative(e))}};async function _l(t){try{await t()}catch{}}function HS(t){return qr.join(z1,et(t)+".json")}function zS(t){return qr.join(Y1,et(t)+".txt")}Er();var wp;function G1(){return wp||(wp=new Si({cache:new Rl,cdnClient:Ow,packageService:Ia,versionResolver:Cw})),wp}var YS="file:///node_modules/";async function VS(t){let e=Pa(t.emitKey,"typecheck");await ne(),await Ee.rm(e,{recursive:!0,force:!0}),await Ee.mkdir(e,{recursive:!0});let n=eN(t.jsxImportSource,t.dependencies),r=await G1().resolve(t.code,t.dependencies,n),s=t.local?.name,i=s?r.filter(f=>f.pkg!==s):r,o=new Set;for(let f of i)for(let d of f.files){let u=Il(d.path);if(!u||o.has(u))continue;o.add(u);let p=Se.join(e,"node_modules",u);await Ee.mkdir(Se.dirname(p),{recursive:!0}),await Ee.writeFile(p,d.content,"utf8")}let a={};for(let f of i)for(let d of f.shims){let u=Il(d.path);u&&(a[d.module]=[`./node_modules/${u}`])}for(let f of i){if(f.ambient)continue;let d=Il(f.mainPath);d&&(a[f.pkg]=[`./node_modules/${d}`])}let l=new Set;for(let f of i)for(let d of f.files){if(!d.ambient)continue;let u=Il(d.path);u&&l.add(`node_modules/${u}`)}if(t.local){delete a[t.local.name];let f=await tN(t.local,e);f?a[t.local.name]=[`./node_modules/${t.local.name}/${f}`]:console.warn(` local: '${t.local.name}' ships no type defs; check cannot type against it.`)}let c=X1(t.jsxImportSource,a,[...l]);return await Ee.writeFile(Se.join(e,"tsconfig.json"),JSON.stringify(c,null,2)+`
|
|
2519
|
+
`,"utf8"),await Ee.writeFile(Se.join(e,"code.tsx"),t.code,"utf8"),await Ee.writeFile(Se.join(e,"tb.d.ts"),gp,"utf8"),{dir:e}}var vp={target:"es2023",module:"esnext",moduleResolution:"bundler",strict:!0,noEmit:!0,skipLibCheck:!0,esModuleInterop:!0,allowSyntheticDefaultImports:!0,forceConsistentCasingInFileNames:!0};function X1(t,e,n=[]){return{compilerOptions:{...vp,lib:Q1([...pp,...hp]),jsx:"react-jsx",jsxImportSource:t??"react",paths:e},include:["code.tsx","tb.d.ts",...n]}}function Q1(t){return mp(t).map(e=>Z1(e.name))}function Z1(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 eN(t,e){let n=t??("react"in e?"react":void 0);return n?[`${n}/jsx-runtime`,`${n}/jsx-dev-runtime`]:[]}function Il(t){if(!t.startsWith(YS))return;let e=t.slice(YS.length),n=e.indexOf("/");if(!(n<0))return e.slice(n+1)}async function tN(t,e){if(!t.typesAbs)return;let n=Se.dirname(t.typesAbs),r=Se.join(e,"node_modules",t.name);for(let s of await nN(n)){let i=Se.join(r,Se.relative(n,s));await Ee.mkdir(Se.dirname(i),{recursive:!0}),await Ee.copyFile(s,i)}return Se.basename(t.typesAbs)}async function nN(t){let e=[];async function n(r){let s=await Ee.readdir(r,{withFileTypes:!0});for(let i of s){let o=Se.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 Ct from"path";import{existsSync as rN}from"fs";Er();uf();var sN="^22";async function GS(t){let e=Pa(t.emitKey,"typecheck-server");await ne(),await Je.rm(e,{recursive:!0,force:!0}),await Je.mkdir(e,{recursive:!0});let n=Ct.join(t.bulbDir,".typebulb"),r=ja(t.server).filter(o=>o!==t.local?.name);await Ba([`@types/node@${sN}`,...r],n,t.dependencies,{ignoreScripts:!0});let s=Ct.join(n,"node_modules"),i=Ct.join(e,"node_modules");return await oN(s,i),await Je.writeFile(Ct.join(e,"server.ts"),t.server,"utf8"),await Je.writeFile(Ct.join(e,"tb.d.ts"),yp,"utf8"),await Je.writeFile(Ct.join(e,"tsconfig.json"),JSON.stringify(iN(t.local),null,2)+`
|
|
2520
|
+
`,"utf8"),{dir:e}}function iN(t){let e={...vp,lib:["ES2023"],types:["node"]};if(t?.typesAbs){let n=i=>i.replace(/\\/g,"/"),r=n(Ct.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 oN(t,e){if(!rN(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)}pa();te();async function QS(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 f=Pr(We.resolve(t)),d=f?er(n.name):"";f&&d&&d!==f.slug&&(console.log(`naming filename '${f.slug}.bulb.md' doesn't match the title '${n.name}' \u2014 its slug derives to '${d}'. Rename the file to '${d}.bulb.md', or change name: to suit the filename.`),c=!0),n.code&&(l=XS(Fs(n.code,{target:"client",dependencies:r.dependencies??{},lineOffset:a("code.tsx")}),"client")||l),n.server&&(l=XS(Fs(n.server,{target:"server",lineOffset:a("server.ts")}),"server")||l);let u=hN([process.cwd(),We.dirname(t)]);if(!u){let m=We.relative(process.cwd(),t)||t;console.error("check: TypeScript not found \u2014 install it once, then re-run:"),console.error(" npm i -g typescript"),console.error(` typebulb check ${m}`),process.exit(2)}let p=[];if(n.code){let{dir:m}=await VS({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 GS({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:E}=await fN(u,g);for(let P of v.split(/\r?\n/))P.trim()&&console.log(`${m} ${dN(P,o,a)}`);E!==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 XS(t,e){for(let n of t)for(let r of n.message.split(`
|
|
2521
|
+
`))console.log(`${e} ${r}`);return t.length>0}function dN(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 fN(t,e){return new Promise(n=>{let r=aN(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 pN=cN(import.meta.url);function hN(t){let e=r=>{try{let s=pN.resolve("typescript/package.json",{paths:r}),i=We.join(We.dirname(s),"lib","tsc.js");return uN(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}}Et();fa();qs();async function ZS(t,e){let{bulb:n}=await nt(t),r=fr(n);if(kn(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.)")}qs();import*as ki from"path";async function ek(t,e){if(!t){e||(console.error("Usage: typebulb untrust <file.bulb.md>"),process.exit(1));let r=_d();if(!r.length){console.log("No bulbs are remembered as trusted.");return}console.log("Trusted bulbs (run with fs/AI/server.ts without --trust):");for(let s of r)console.log(` ${s}`);return}let n=ki.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 ${ki.basename(n)} \u2014 runs with fs / AI / server.ts (no --trust needed).`:`Untrusted ${ki.basename(n)} \u2014 runs Restricted.`),console.log(` ${n}`)}Ie();import*as rk from"readline";Yd();function Sp(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 mN=5e3,$l=()=>Math.round(performance.now()),tk=t=>t>=1e3?`${(t/1e3).toFixed(1)}s`:`${t}ms`;async function sk(t){let e=RS(process.cwd()),n=$l();if("ambiguous"in e){let r=await gN(t,e.ambiguous);return r?nk(t,r,{boot:n,from:$l()}):yN(t,e.ambiguous)}return nk(t,e.name,{boot:n,from:$l()})}async function nk(t,e,n){let r,s;try{r=await Bs(e)}catch(p){s=p instanceof Error?p.message:String(p)}let i=$l()-n.from,{lit:o,litLink:a,brand:l}=Sp(process.stdout.isTTY===!0),c=[" Read the authoring skill before writing a bulb:",` \u2022 ${o(Hs())}`],f=r?[` Agent mirror (${e}) is live\u{1F4A1}`,` ${o("\u25CF")} ${a(r.url)}`," Inline bulbs render live here."," Agents:",` Reusable app/tool \u2192 write a ${o(".bulb.md")}`," Show something inline \u2192 emit an inline bulb"," emit it with no .bulb.md draft first",...e==="codex"?[" verify it this turn \u2014 foreground-wait, bounded:",` \u2022 ${o('typebulb wait agent --match "[inline <name>" --timeout 120')}`," via exec_command; while it still runs,"," poll it with write_stdin until it exits"]:[e==="pi"?" arm a wait for its render verdict \u2014 run it plainly:":" background a wait for its render verdict:",` \u2022 ${o('typebulb wait agent --match "[inline <name>"')}`],...c," End this reply with the mirror link above"," \u2022 easy to miss the link mid-message"]:[` The mirror did not start (${s})`,` \u25CF Start it manually: ${o(`npx typebulb agent:${e}`)}`," Agents:",...c],d=n.boot+i>mN?[` slow launch: boot ${tk(n.boot)} \xB7 mirror ${tk(i)}`]:[],u=[` ${l(`typebulb v${t}`)}`,...d,...f,""];process.stdout.write(u.join(`
|
|
2522
2522
|
`)+`
|
|
2523
|
-
`)}async function
|
|
2523
|
+
`)}async function gN(t,e){if(!process.stdin.isTTY||!process.stdout.isTTY)return;let{lit:n,brand:r}=Sp(!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(`
|
|
2524
2524
|
`)+`
|
|
2525
|
-
`);let i=
|
|
2525
|
+
`);let i=rk.createInterface({input:process.stdin,output:process.stdout});try{let o=(await new Promise(l=>i.question(" Open which? [1]: ",l))).trim();if(o==="")return e[0];let a=Number(o);return Number.isInteger(a)&&a>=1&&a<=e.length?e[a-1]:e.find(l=>l===o.toLowerCase())}finally{i.close()}}function yN(t,e){let{lit:n,brand:r}=Sp(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(`
|
|
2526
2526
|
`)+`
|
|
2527
|
-
`)}Ze();xn();async function
|
|
2528
|
-
`+e)}function
|
|
2527
|
+
`)}Ze();xn();async function ik(t){we(t);let e=await bt();if(e.length>0){console.log(zb(e,process.env.TB_AI_PROVIDER,process.env.TB_AI_MODEL));return}if(!Id()){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.")}te();function ok(t){t?.trim()||(console.error("Usage: typebulb slug <bulb name>"),process.exit(1));let e=er(t);e||(console.error(`'${t}' has no slug \u2014 a bulb name needs at least one letter or digit.`),process.exit(1)),console.log(e)}je();import*as ck from"path";import{valid as lk,lt as wN}from"semver";Ie();var st={connected:"[page] connected",disconnected:"[page] disconnected",closed:t=>`[page] closed: ${t}`},kp=3e3,ak=1e4,bN=2500,Nl=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?.()},kp).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,bN);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()}};sa();function vN(t,e,n,r){if(/^\d+$/.test(e))return t.find(i=>i.pid===parseInt(e,10));let s=e==="agent"?t.filter(be):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=>se(i.file)===se(e))}var nn=t=>t.agent??ck.basename(t.file);function uk(t){return t===Oe?!1:t&&lk(t)&&lk(Oe)?wN(t,Oe):!0}function SN(t){return t===Oe?"":t?uk(t)?` STALE runtime v${t} (this CLI is v${Oe} \u2014 relaunch to update)`:` runtime v${t} (newer than this CLI's v${Oe})`:" STALE runtime (predates the version stamp \u2014 relaunch to update)"}function kN(t,e){return e===void 0?" pages ?":e>0?` ${e} page${e===1?"":"s"}`:be(t)?" NO PAGE (no tab open on it)":" NO PAGE (nothing of it is running)"}function dk(t,e,n){t.forEach((r,s)=>e(` ${r.url} pid ${r.pid} ${r.trust?"trusted":"restricted"}${n?kN(r,n[s]):""}${SN(r.version)} ${r.file}`))}async function Ep(t,e){if(!t.length){console.log("No running bulb servers.");return}let n=await Promise.all(t.map(Sd));console.log("Running bulb servers:"),dk(t,r=>console.log(r),n),console.log(`
|
|
2528
|
+
`+e)}function Ll(t,e,n,r,s){let i=vN(t,e,r,s);if(i)return i;console.error(`No running server for '${e}'.`),t.length?(console.error(`Running servers (try \`typebulb ${n} <file|pid>\`):`),dk(t,o=>console.error(o))):console.error("No bulb servers are running."),process.exit(1)}async function fk(t,e){if(!t){e.clear&&(console.error("Specify which server to clear: typebulb logs --clear <file|pid>"),process.exit(1)),await Ep(await G(process.cwd()),"Run `typebulb logs <file|pid>` to print one server's console.");return}let n=Ll(await G(),t,"logs",process.cwd(),rt());if(e.clear){hd(n.pid),console.log(`Cleared log for ${nn(n)} (pid ${n.pid}).`);return}let r=Xe(n.pid),s=r.text;if(e.run!==void 0?(s=gd(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(`
|
|
2529
2529
|
`);i.length&&i[i.length-1]===""&&i.pop(),s=i.slice(-e.lines).join(`
|
|
2530
2530
|
`)}if(process.stdout.write(s),s&&!s.endsWith(`
|
|
2531
2531
|
`)&&process.stdout.write(`
|
|
2532
|
-
`),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
|
|
2533
|
-
`);v=k.pop()??"";let N=!1;for(let B of k)B.trim()&&(m&&O&&B.startsWith(st.disconnected)&&(N=!0),!(e.match&&!B.includes(e.match))&&(console.log(B),E.push(B),!i&&(g??=Date.now()+p,be(n)&&(B.includes("] compile error")||B.includes("] runtime error"))&&(g=Math.min(g,Date.now()+h)))));if(N&&!g){P=`the last page of ${
|
|
2534
|
-
`):P)}catch(O){console.error(`Not delivered: ${O instanceof Error?O.message:O}`),process.exit(4)}console.error(`accepted ${new Date().toISOString()}`)}$&&process.exit(3),i||
|
|
2535
|
-
`).trimEnd()}function
|
|
2532
|
+
`),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 xN=t=>new Promise(e=>setTimeout(e,t));async function pk(t,e){if(!t){Ep(await G(process.cwd()),"Run `typebulb wait <file|pid>` to block until one logs a new line.");return}let n=Ll(await G(),t,"wait",process.cwd(),rt()),r=e.wake?await EN():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,f=i?void 0:oa(n.pid,l)??(l?oa(n.pid):void 0),d=i?c:f!==void 0&&f<=c?f:l?0:c,u=Date.now()+a*1e3,p=be(n)?1e4:1e3,h=2e3,m=!be(n)&&!i,g,v="",E=[],P="",A=0,$=!1;for(;;){let O=d>=c,_=Xe(n.pid,d);if(d=_.offset,_.text){v+=_.text;let k=v.split(`
|
|
2533
|
+
`);v=k.pop()??"";let N=!1;for(let B of k)B.trim()&&(m&&O&&B.startsWith(st.disconnected)&&(N=!0),!(e.match&&!B.includes(e.match))&&(console.log(B),E.push(B),!i&&(g??=Date.now()+p,be(n)&&(B.includes("] compile error")||B.includes("] runtime error"))&&(g=Math.min(g,Date.now()+h)))));if(N&&!g){P=`the last page of ${nn(n)} closed while waiting \u2014 a bulb runs in its page, so nothing can log ${e.match?`'${e.match}'`:"anything"} now`,console.error(P),A=3;break}}if(g&&Date.now()>=g)break;if(!o&&!g&&Date.now()>=u){P=`timeout: no ${e.match?`line matching '${e.match}'`:"new output"} from ${nn(n)} within ${a}s`,console.error(P),A=2;break}if(!Jt(n.pid)){g||(P=`server ${nn(n)} (pid ${n.pid}) exited while waiting`,console.error(P),A=3,$=!0);break}await xN(400)}if(r){console.error(`detected ${new Date().toISOString()}`);try{await r.adapter.wake(r.sessionId,"typebulb_wait",E.length?E.join(`
|
|
2534
|
+
`):P)}catch(O){console.error(`Not delivered: ${O instanceof Error?O.message:O}`),process.exit(4)}console.error(`accepted ${new Date().toISOString()}`)}$&&process.exit(3),i||Ms(n.pid,d,l),process.exit(A)}async function EN(){let t=rt(),e=t?Fr()[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 hk(t,e){if(e==="killed")return` \u2014 forced (${uk(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 mk(t){if(!t){await Ep(await G(process.cwd()),"Run `typebulb stop <file|pid>` to stop one.");return}let e=Ll(await G(),t,"stop",process.cwd(),rt()),n=await yt(e);console.log(`Stopped ${nn(e)} (pid ${e.pid}, ${e.url}).${hk(e,n)}`)}async function gk(t){let e=await xp(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=>yt(s)));console.log(`Stopped ${e.length} ${n}${e.length===1?"":"s"}:`),e.forEach((s,i)=>console.log(` ${s.url} pid ${s.pid} ${nn(s)}${hk(s,r[i])}`))}async function xp(t){let e=process.cwd(),n=t==="agent"?rt():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 yk(t,e){let n=process.cwd(),r=t?[Ll(await G(),t,"restart",n,rt())]:e?await xp(e):[...await G(n),...await xp("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${Oe}:`);for(let s of r){let i=s.version?`v${s.version}`:"unknown version";try{let o=be(s)?(await yt(s,"keep"),await Bs(s.agent,s.cwd??n)):await wn(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} ${nn(s)} ${i} \u2192 v${Oe}`)}catch(o){console.log(` ${s.url} ${nn(s)} failed: ${o instanceof Error?o.message:o}`),process.exitCode=1}}}Ie();je();gn();import*as Ml from"path";import*as bk from"http";import{mkdir as AN,writeFile as TN}from"fs/promises";async function Jr(){let t=[];for await(let e of process.stdin)t.push(e);return Buffer.concat(t).toString("utf-8")}function xi(t){return(t.charCodeAt(0)===65279?t.slice(1):t).replace(/\r\n/g,`
|
|
2535
|
+
`).trimEnd()}function CN(t,e){return new Promise((n,r)=>{let s=new URL(t),i=bk.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 ON=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 wk(t,e,n=0){e==="-"&&(e=xi(await Jr()));let r=e!==void 0&&e.startsWith("tb:");r&&n<=0&&(n=fp);let s=e!==void 0&&/^tb:(click|set)( |$)/.test(e),i=Ml.resolve(t),o=bn(await G(),i)[0];if(!o){let h=(await mn(process.cwd()))(i);console.error(h?`No running server for '${t}' \u2014 it last ran ${ON(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 CN(`${o.url}/__send${m?`?${m}`:""}`,e??"");(g.status<200||g.status>=300)&&(console.error(`send failed: HTTP ${g.status} from ${o.url}/__send`),process.exit(1));try{return JSON.parse(g.text)}catch{return{}}},l={},c=Date.now();try{l=await a(n)}catch(h){console.error(`send failed: ${h instanceof Error?h.message:String(h)}`),process.exit(1)}let f=l.clients??0,d=`${f} page${f===1?"":"s"}`;if(l.refused&&(console.error(`Actuation needs exactly one connected page; ${d} are open on ${o.url} \u2014 the reset is \`typebulb stop ${t}\` then relaunch.`),process.exit(1)),f===0){let h=l.droppedMsAgo,m=l.opening==="none"?" and no agent mirror page is open to open one through":"",g=l.opening==="unreached"?` \u2014 the page was opened ${l.via?`in VS Code via ${l.via}`:"in your browser"} and never attached; is the browser it opened in still there?`:h!==void 0?` \u2014 a page disconnected ${Math.round(h/1e3)}s ago and hasn't reconnected${m}; reload it, or open ${o.url}`:` \u2014 no page has ever connected${m}; share ${o.url} and arm: typebulb wait ${t} --match "${st.connected}"`;console.error(`No page connected after ${((Date.now()-c)/1e3).toFixed(1)}s, so nothing was delivered${g}`),process.exit(1)}l.opening==="editor"?console.error(`Opened in VS Code via ${l.via}.`):l.opening==="external"&&console.error("Opened in your browser, where the agent mirror is."),console.error(`Sent to ${d}.`);let u=l.results??[],p=l.errors??[];for(let h of p)console.error(`handler error: ${h}`);if(p.length&&process.exit(1),u.length>1&&(console.error(`${u.length} replies from ${d} \u2014 one reply owns stdout: at most one tb.onMessage handler, in one page, may return a value.`),process.exit(1)),u.length===1){if(e!==void 0&&/^tb:png( |$)/.test(e)){let m={};try{m=JSON.parse(u[0])}catch{}typeof m.png!="string"&&(console.error("tb:png replied with an unexpected shape \u2014 an older runtime? (`typebulb logs` lists server versions)"),process.exit(1));let g=db(i);await AN(Ml.dirname(g),{recursive:!0}),await TN(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(u[0])}catch{h=void 0}console.log(typeof h=="string"?h:u[0])}else l.timedOut&&(r&&(console.error(`No reply to '${e}' within ${n/1e3}s \u2014 reload the page and retry.`),process.exit(1)),console.error(`(no reply within ${n/1e3}s \u2014 slow work needs a larger --wait=ms; a reply that NEVER comes is a done-promise that missed an exit, or a blocked main thread: tb:snapshot runs no page code, so its silence too means blocked)`))}za();wf();te();import*as vk from"fs/promises";async function Sk(t,e){let n=await vk.readFile(t,"utf-8"),r=qn(n),s=pe[e].path,i=r.files.get(s);i||(console.error(i===void 0?`No **${s}** block in ${t}`:`The **${s}** block in ${t} is empty`),process.exit(2)),process.stdout.write(i.endsWith(`
|
|
2536
2536
|
`)?i:i+`
|
|
2537
|
-
`)}te();import*as
|
|
2538
|
-
`);if(s.wake){console.error(`detected ${new Date().toISOString()}`);try{await s.wake(i,
|
|
2537
|
+
`)}te();import*as Ei from"fs/promises";async function Ek(t,e){let n=await Ei.readFile(t,"utf-8"),r=[];for(let{kind:i,source:o}of e){let a;try{a=o==="-"?await Jr():await Ei.readFile(o,"utf-8")}catch(l){xk(`Cannot read ${i}'s source: ${l instanceof Error?l.message:String(l)}`)}r.push({kind:i,content:xi(a),label:o==="-"?"stdin":o})}let s;try{s=PN(n,r)}catch(i){xk(`${t}: ${i instanceof Error?i.message:String(i)}`)}for(let i of s.upToDate)console.log(`${pe[i].path}: already up to date`);if(s.written.length){await Ei.writeFile(t,s.text);for(let i of s.written)console.log(i.action==="removed"?`${pe[i.kind].path}: removed (${i.label} is empty)`:`${pe[i.kind].path}: ${i.action} from ${i.label} (${i.chars.toLocaleString()} chars)`)}}function PN(t,e){let n=qn(t),r=t,s=[],i=[];for(let{kind:o,content:a,label:l}of e){let c=pe[o].path,f=n.files.get(c);if(!a){if(f===void 0){i.push(o);continue}r=kk(eh(r,o),r,c),s.push({kind:o,action:"removed",chars:0,label:l});continue}if(f!==void 0&&xi(f)===a){i.push(o);continue}r=kk(Kr(r,o,a),r,c),s.push({kind:o,action:f===void 0?"created":"replaced",chars:a.length,label:l})}return{text:r,written:s,upToDate:i}}function kk(t,e,n){if(t===e)throw new Error(`the **${n}** block's fence is unterminated; refusing to rewrite inside it`);return t}function xk(t){console.error(t),process.exit(1)}Ze();pl();ll();Lr();function Ap(){let t=Fr(),e=rt();return{caller:e,adapters:(e?[e]:Object.keys(t)).map(n=>t[n]()).filter(n=>n.listChildren)}}async function Tk(t,e){we(e);let{caller:n,adapters:r}=Ap();if(!r.length){console.error(`Sub-agent status isn't supported for ${n} sessions.`),process.exitCode=1;return}let s;for(let i of r){let{sessionId:o,cwd:a}=fi(i,process.cwd());if(!t){let l=o?fl(i,a,o):dl(i,a).next().value;if(!l?.children.length){if(o){console.log("No sub-agents in this session yet.");return}continue}let{reports:c,files:f}=await Ln(i,a,l);console.log(jv(l.sessionId,c,f,Date.now()));return}for(let l of dl(i,a)){s??=l;let c=Jv(l,t);if(c.length){if(c.length>1){console.error(`Several agents match "${t}"; name one by its id:`);for(let f of c)console.error(` ${Ak(f)}`);process.exitCode=1;return}console.log(Lv((await Ln(i,a,l,c[0].id)).reports[0],Date.now()));return}}}if(!s){console.log("No sub-agents in this project's sessions.");return}console.error(`No agent matches "${t}". The agents of session ${s.sessionId}:`);for(let i of s.children)console.error(` ${Ak(i)}`);process.exitCode=1}var Ak=t=>`${t.id} ${rl(t).padEnd(7)} ${At(t)}`;Ze();je();Ie();pl();ll();import{mkdirSync as _N,readFileSync as Cp,writeFileSync as Pk,rmSync as Ck}from"fs";import{join as Bl}from"path";var RN=1e4,IN=720*6e4,Ok="typebulb_babysit";async function _k(t){we(t);let{caller:e,adapters:n}=Ap(),r=n.map(u=>({adapter:u,...(u.wake?fi:qv)(u,process.cwd())})).find(u=>u.sessionId);if(!r?.sessionId)return Tp(n.length?n.some(u=>u.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 ${e} sessions.`);let{adapter:s,sessionId:i,cwd:o}=r;if(s.wake){let u=await s.wakeRoute(i);if(u.error)return Tp(`Can't babysit: ${u.error}.`)}let a=Bl(Ge(),"babysit"),l=Bl(a,`${i}.json`);if(!$N(Bl(a,`${i}.lock`)))return Tp("A babysit is already watching this session.");let c=[];try{c=JSON.parse(Cp(l,"utf8"))}catch{}let f=u=>{try{Pk(l,JSON.stringify(u))}catch{}};console.error(`Babysitting the sub-agents of session ${i}: this exits with a line when one needs attention.`);let d=Date.now()+IN;for(;Date.now()<d;){s.sessionEnded?.(i,o)&&Dl(3,"The session this babysits has ended.");let{reports:u}=await Ln(s,o,fl(s,o,i)),p=Fv(u,Date.now(),!!s.sessionsWorking?.(o)?.has(i)),h=[...p].filter(([m])=>!c.includes(m));if(!h.length)c=[...p.keys()],f(c);else{let m=h.map(([,g])=>g).join(`
|
|
2538
|
+
`);if(s.wake){console.error(`detected ${new Date().toISOString()}`);try{await s.wake(i,Ok,m)}catch(g){f([...p.keys()].filter(v=>!h.some(([E])=>E===v))),console.log(m),Dl(4,`Not delivered: ${g instanceof Error?g.message:g}`)}console.error(`accepted ${new Date().toISOString()}`)}f([...p.keys()]),console.log(m),Dl(0)}await new Promise(m=>setTimeout(m,RN))}s.wake&&await s.wake(i,Ok,"typebulb babysit stopped after 12 hours with nothing to report; run it again to keep watching.").catch(()=>{}),Dl(2,"Nothing needed attention; gave up.")}function Tp(t){console.error(t),process.exitCode=1}function Dl(t,e){e&&console.error(e),process.exit(t)}function $N(t){try{_N(Bl(t,".."),{recursive:!0})}catch{}for(let e=0;e<2;e++)try{return Pk(t,String(process.pid),{flag:"wx"}),process.on("exit",()=>{try{Number(Cp(t,"utf8"))===process.pid&&Ck(t)}catch{}}),!0}catch(n){if(n.code!=="EEXIST")return!0;let r=0;try{r=Number(Cp(t,"utf8"))}catch{}if(r&&r!==process.pid&&Jt(r))return!1;try{Ck(t)}catch{}}return!1}Ze();Et();te();fa();import*as sn from"fs/promises";import*as Fn from"path";import{EventEmitter as tL}from"events";Wt();te();import{Hono as jN}from"hono";import{serve as FN}from"@hono/node-server";import{streamSSE as UN}from"hono/streaming";import*as _p from"fs/promises";import qN from"open";Er();ni();xr();import*as Op from"fs/promises";import*as Ai from"path";var jl=class{async get(e){let n=et(e),r=Ai.join(ti,n+".bin"),s=Ai.join(ti,n+".json");try{let[i,o]=await Promise.all([Op.readFile(r),Op.readFile(s,"utf8")]),a=JSON.parse(o);return{body:i,contentType:a.contentType,cacheControl:a.cacheControl}}catch{return}}async set(e,n){await ne();let r=et(e),s=Ai.join(ti,r+".bin"),i=Ai.join(ti,r+".json"),o={url:e,contentType:n.contentType,cacheControl:n.cacheControl};await Promise.all([Fe(s,n.body),Fe(i,JSON.stringify(o))])}};var Rk=`
|
|
2539
2539
|
const CSS = '\\n' +
|
|
2540
2540
|
/* The agent mirror's token set, verbatim (agents/core/client/styles.css) \u2014 one system across CLI
|
|
2541
2541
|
chrome: app chrome sits on --panel, content wells paint --veil, grays ride one neutral tint.
|
|
@@ -2918,22 +2918,22 @@ export function runInference(ctx) {
|
|
|
2918
2918
|
showConfirm();
|
|
2919
2919
|
document.body.appendChild(host);
|
|
2920
2920
|
}
|
|
2921
|
-
`;Tr();Ie();xn();
|
|
2922
|
-
${u}`:"";return b.text(`Forbidden: this capability requires --trust.${D}`,403)}await T()},_=async(b,T)=>{let R=b.req.header("sec-fetch-site");if(R){if(R!=="same-origin")return b.text(`Forbidden: ${R} request`,403)}else{let L=b.req.header("origin");if(L&&!
|
|
2923
|
-
`+Y.slice(-4e3)),new Ne("LLM output is not valid JSON","parse_error",!0);de.fixesApplied.length&&console.warn("[tb.infer] sanitized output, fixes applied:",de.fixesApplied.join(", ")),yield{kind:"complete",insight:de.parsed,data:D,fixesApplied:de.fixesApplied}})();return
|
|
2924
|
-
Shutting down...`),(m?.pages??(be(c)?"keep":"close"))==="close"&&await d?.closePages("stopped"),d?.close();for(let g of f)try{await g()}catch{}a(),await yn(process.pid),process.exit(0)}},h=await
|
|
2921
|
+
`;Tr();Ie();xn();xa();Wt();import{stream as NN}from"hono/streaming";var LN="X-TB-Stream";function Ti(t){return t instanceof Ne?{message:t.message,code:t.code,retryable:t.retryable}:{message:t instanceof Error?t.message:"Unknown error",code:"unknown",retryable:!1}}function Fl(t,e){return t.header("Content-Type","application/x-ndjson; charset=utf-8"),t.header("Cache-Control","no-cache"),t.header(LN,"1"),NN(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:Ti(s)}))}finally{try{await r.return?.()}catch{}}})}var Ul={log:(...t)=>console.log(...t)};function ql(t,e){let n=t?.[e]??(Object.hasOwn(Ul,e)?Ul[e]:void 0);return typeof n=="function"?n:void 0}function Jl(t){return t.constructor?.name==="AsyncGeneratorFunction"}df();var MN=/^\/(v\d+\/|stable\/|node\/|gh\/|@[^/]+\/[^@/]+@|[^@/]+@)/,DN=/[?&]target=/,BN=/^\/(?:@[^/]+\/)?[^/@]+\/[^/]+/;function Ik(t,e=""){return MN.test(t)?!0:BN.test(t)&&DN.test(e)}var JN="127.0.0.1",WN=new Set(["localhost","127.0.0.1","::1"]),Dk=(t,e)=>!!t&&typeof t=="object"&&e in t,$k=t=>{let e={};return Array.isArray(t.data)&&(e.data=t.data),Dk(t,"insight")&&(e.insight=t.insight),e},Nk=8*1024*1024,KN=0;function HN(t){if(t)try{return new URL(t.includes("://")?t:`http://${t}`).hostname}catch{return}}function Bk(t){let e=HN(t);return!!e&&WN.has(e)}function zN(t){try{let e=new URL(t);return(e.protocol==="http:"||e.protocol==="https:")&&Bk(e.host)}catch{return!1}}function YN(t){return!!t&&/\bCode\/\d/.test(t)&&/\bElectron\//.test(t)}function VN(t,e){if(!e)return!1;try{return new URL(t).host===e}catch{return!1}}function Ci(t){return t instanceof Error?t.message:"Unknown error"}var Lk=t=>t.how==="editor"||t.how==="unreached"?t.via:void 0,GN=2e3;async function jk(t){let{getHtml:e,basePath:n,fsBase:r,port:s,reloadEmitter:i,sendChannel:o,getServerExports:a,getBulbBlocks:l,saveInferenceResult:c,localOverride:f,trusted:d=!1,trustHint:u,staticAssets:p,bulbAssets:h,sourceFile:m,bulbKey:g,onStop:v}=t,E=`${process.pid}-${++KN}-${Date.now()}`,P=r??n,A=new jN;A.use("*",async(b,T)=>{if(!Bk(b.req.header("host")))return b.text("Forbidden: untrusted Host",403);await T()}),A.use("*",async(b,T)=>{await T(),b.res.headers.set("Cross-Origin-Opener-Policy","same-origin"),b.res.headers.set("Cross-Origin-Embedder-Policy","credentialless")});let $=[["/__fs/*","the filesystem"],["/__api/*","server-side code (server.ts)"],["/__ai","AI (your API keys)"],["/__infer","AI (your API keys)"],["/__infer-save","the filesystem"]],O=async(b,T)=>{if(!d){let R=new URL(b.req.url).pathname,L=$.find(([K])=>K.endsWith("/*")?R.startsWith(K.slice(0,-2)):R===K)?.[1]??"server-side code (server.ts)";bd(process.pid,L);let D=u?`
|
|
2922
|
+
${u}`:"";return b.text(`Forbidden: this capability requires --trust.${D}`,403)}await T()},_=async(b,T)=>{let R=b.req.header("sec-fetch-site");if(R){if(R!=="same-origin")return b.text(`Forbidden: ${R} request`,403)}else{let L=b.req.header("origin");if(L&&!VN(L,b.req.header("host")))return b.text("Forbidden: cross-origin request",403)}await T()};for(let[b]of $)A.use(b,O),A.use(b,_);A.use("/__log",_),A.post("/__log",async b=>{try{let{args:T}=await b.req.json();console.log(...T||[])}catch{}return b.json({ok:!0})});let k=new Nl,N=new Set,B=new Set,Z=Date.now();k.onArrival(({page:b,firstAttach:T,count:R})=>{o&&R===1&&console.log(st.connected),T&&R>1&&b.close("yielded").catch(()=>{})}),o&&k.onSettledEmpty(()=>console.log(st.disconnected));let q,ie=0,oe=async b=>{let T=Math.max(b.fresh?0:Z,k.lastDropAt);if(await k.whenArrives(kp-(Date.now()-T)))return{how:"attached"};if(Date.now()-ie<GN)return{how:"none"};let R=`http://localhost:${s}#tb-relay`,L=await vd(R,n),D;return L?.where==="editor"?D={how:"editor",via:L.via}:(b.external==="force"||b.external==="follow"&&L?.where==="external")&&(await qN(R),D={how:"external"}),D?await k.whenArrives(ak)?D:{how:"unreached",via:Lk(D)}:(ie=Date.now(),{how:"none"})},ye=b=>k.count>0?Promise.resolve({how:"attached"}):q??=oe(b).finally(()=>{q=void 0});if(o){let b=0,T=new Map;A.use("/__send",_),A.post("/__send",async R=>{let L="";try{L=await R.req.text()}catch{}let D=Number(R.req.query("reply"))||0,K=k.count===0&&R.req.query("open")!==void 0?await ye({external:"follow",fresh:!1}):void 0,J=k.count,Ke=J===0&&k.lastDropAt?Date.now()-k.lastDropAt:void 0,Y={clients:J,droppedMsAgo:Ke,...K?{opening:K.how,via:Lk(K)}:{}};if(R.req.query("solo")!==void 0&&J!==1)return R.json({...Y,refused:J>1});if(J===0)return R.json(Y);let de=on=>{for(let _t of k)_t.send(on).catch(()=>{})};if(D<=0)return de({payload:L}),R.json(Y);let _e=++b,Wr=await new Promise(on=>{let _t={expected:J,received:0,results:[],errors:[],finish:Hl=>{clearTimeout(Kl),T.delete(_e),on({results:_t.results,errors:_t.errors,timedOut:Hl})}},Kl=setTimeout(()=>_t.finish(!0),D);T.set(_e,_t),de({id:_e,payload:L})});return R.json({...Y,...Wr})}),A.use("/__send-reply",_),A.post("/__send-reply",async R=>{try{let{id:L,results:D,errors:K}=await R.req.json(),J=T.get(L);J&&(J.results.push(...D??[]),J.errors.push(...K??[]),++J.received>=J.expected&&J.finish(!1))}catch{}return R.json({ok:!0})})}A.get("/",b=>b.html(e())),A.post("/__fs/read",async b=>{try{let{path:T}=await b.req.json(),R=await ri(T,P);return new Response(new Uint8Array(R),{headers:{"Content-Type":"application/octet-stream"}})}catch(T){let R=Ci(T);return b.json({error:R},400)}}),A.post("/__fs/write",async b=>{try{let T=b.req.query("path");return T?(await Fa(T,new Uint8Array(await b.req.arrayBuffer()),P),b.json({success:!0})):b.json({error:"Missing path"},400)}catch(T){let R=Ci(T);return b.json({error:R},400)}}),A.post("/__fs/list",async b=>{try{let{path:T}=await b.req.json();return b.json(await Ua(T??".",P))}catch(T){return b.json({error:Ci(T)},400)}}),A.post("/__fs/remove",async b=>{try{let{path:T}=await b.req.json();return await qa(T,P),b.json({success:!0})}catch(T){return b.json({error:Ci(T)},400)}}),A.post("/__api/:name",async b=>{try{let T=b.req.param("name"),R=ql(a?.(),T);if(!R)return b.json({error:`API function '${T}' not found`},404);let{args:L}=await b.req.json();if(Jl(R))return Fl(b,R(...L||[]));let D=await R(...L||[]);return b.json({result:D})}catch(T){let R=Ci(T);return b.json({error:R},500)}}),A.post("/__ai",async b=>{try{let{messages:T,system:R,effort:L,provider:D,model:K,webSearch:J,stream:Ke}=await b.req.json();if(!T||!Array.isArray(T)||T.length===0)return b.json({message:"messages array is required",code:"unknown",retryable:!1},400);let Y=wt(D,K);if(typeof Y=="string")return b.json({message:Y,code:"unknown",retryable:!1},400);let de=await Ht(Y,{messages:T,system:R,effort:L,webSearch:J,signal:b.req.raw.signal});if(!de.ok){let on=await br(de,Y.protocol);return b.json(on,de.status)}if(Ke)return Fl(b,Tn(de,Y.protocol));let{text:_e,usage:Wr}=await wr(de,Y.protocol);return _e||console.warn("[tb.ai] Empty response from provider"),b.json({text:_e,usage:Wr})}catch(T){return b.json(Ti(T),500)}}),A.post("/__infer",async b=>{try{let{data:T}=await b.req.json().catch(()=>({})),R=l?.();if(!R?.infer.trim())return b.json({message:"This bulb has no infer.md block.",code:"unknown",retryable:!1},400);let L=wt();if(typeof L=="string")return b.json({message:L,code:"unknown",retryable:!1},400);let D=Array.isArray(T)?T.map(String):[],K=Wd(R,D),J=await Ht(L,{messages:[{role:"user",content:K}],signal:b.req.raw.signal});if(!J.ok){let Y=await br(J,L.protocol);return b.json(Y,J.status)}let Ke=(async function*(){let Y="";for await(let _e of Tn(J,L.protocol))_e.kind!=="text"||!_e.text||(Y+=_e.text,yield{kind:"delta",text:_e.text});let de=Kd(Y);if(de.parsed===void 0)throw console.warn(`[tb.infer] output not valid JSON after sanitize; raw output (last 4000 chars):
|
|
2923
|
+
`+Y.slice(-4e3)),new Ne("LLM output is not valid JSON","parse_error",!0);de.fixesApplied.length&&console.warn("[tb.infer] sanitized output, fixes applied:",de.fixesApplied.join(", ")),yield{kind:"complete",insight:de.parsed,data:D,fixesApplied:de.fixesApplied}})();return Fl(b,Ke)}catch(T){return b.json(Ti(T),500)}}),A.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 T=$k(await b.req.json().catch(()=>({})));return Object.keys(T).length?(await c(T.data,Dk(T,"insight")?JSON.stringify(T.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(T){return b.json(Ti(T),500)}}),A.get("/__infer-info",b=>{let T=l?.(),R=Hr(T?.config??"").inference,L=Lo(T?.data??""),D=!!T?.infer.trim(),K=wt();return typeof K=="string"?b.json({error:K,inference:R,data:L,hasInfer:D}):b.json({provider:K.protocol,model:K.model,inference:R,data:L,hasInfer:D})}),A.use("/__tb-decode",_),A.post("/__tb-decode",async b=>{let{hash:T}=await b.req.json().catch(()=>({})),R=typeof T=="string"?zd(T):void 0;return b.json(R??{error:"invalid fragment"})}),A.use("/__tb-encode",_),A.post("/__tb-encode",async b=>{let T=Number(b.req.header("content-length"));if(Number.isFinite(T)&&T>Nk)return b.json({hash:""});let R=await b.req.text().catch(()=>"");if(R.length>Nk)return b.json({hash:""});let L;try{L=JSON.parse(R)}catch{return b.json({hash:""})}return b.json({hash:Hd($k(L))})}),A.get("/__infer-ui.js",b=>b.body(Rk,200,{"Content-Type":"text/javascript; charset=utf-8"})),A.get("/__models",async b=>{try{let T=await bt();return b.json(T)}catch{return b.json([],200)}}),A.get("/__ai-access",async b=>{try{return b.json(await ma())}catch{return b.json("none",200)}}),m&&A.get("/__source/*",async b=>{let T=await _p.readFile(m,"utf-8").catch(()=>{});return T===void 0?b.text("Not Found",404):new Response(T,{headers:{"Content-Type":"text/plain; charset=utf-8"}})});let ke=["esm.sh","unpkg.com","cdn.jsdelivr.net","cdnjs.cloudflare.com"],ae=new jl;A.get("/proxy/*",async b=>{let T=new URL(b.req.url),L=(T.pathname+T.search).slice(7),D=L.lastIndexOf("https://");return D===-1?b.text("Invalid proxy URL",400):xe(b,L.slice(D))}),f&&Mk(A,`/local/${f.name}/`,f.serveDir),p&&Mk(A,p.mount,p.dir),h&&A.get("/assets/*",async b=>{let{pathname:T}=new URL(b.req.url),R=T.slice(8),L;try{L=decodeURIComponent(R)}catch{return b.text("Not Found",404)}let D=sh(L);if(D)return b.text(`${D} is not an asset type: a bulb's code and markup live in the bulb; assets are media and data`,403);try{let J=await Fk(L,h.dir,{"Cache-Control":"no-cache"});if(J)return J}catch{return b.text("Not Found",404)}let K=h.remoteBase;return K?b.redirect(K+R,302):b.text("Not Found",404)});async function xe(b,T){let R;try{R=new URL(T)}catch{return b.text("Invalid URL",400)}if(R.protocol!=="https:")return b.text("HTTPS only",400);if(!ke.includes(R.hostname))return b.text("Host not allowed",403);let L=await ae.get(T);if(L)return new Response(L.body,{status:200,headers:Pp(L.contentType,L.cacheControl)});try{let D=await fetch(T,{headers:{Accept:b.req.header("Accept")||"*/*"},redirect:"follow"});if(!D.ok)return b.text(`Upstream ${D.status}`,D.status);let K=D.headers.get("Content-Type")||void 0,J=D.headers.get("Cache-Control")||void 0;if(D.body){let[Ke,Y]=D.body.tee();return(async()=>{try{let de=await new Response(Y).arrayBuffer();await ae.set(T,{body:Buffer.from(de),contentType:K,cacheControl:J})}catch{}})(),new Response(Ke,{status:D.status,headers:Pp(K,J)})}return new Response(null,{status:D.status,headers:Pp(K,J)})}catch(D){return b.text(`Proxy fetch failed: ${D instanceof Error?D.message:D}`,502)}}(i||o)&&(A.get("/__reload",b=>UN(b,async T=>{let R=b.req.query("bulb")||void 0;if(g&&R&&R!==g){N.has(R)||(N.add(R),console.log(st.closed("foreign"))),await T.writeSSE({event:"close",data:"foreign"});return}let L=()=>{T.writeSSE({event:"reload",data:""})};i?.on("reload",L);let D=()=>i?.removeListener("reload",L),K=b.req.query("relay")||void 0,J={inEditor:YN(b.req.header("user-agent")),doc:K,open:Y=>T.writeSSE({event:"open-url",data:Y}),send:Y=>T.writeSSE({event:"message",data:JSON.stringify(Y)}),close:Y=>(D(),k.closing(J),console.log(st.closed(Y)),T.writeSSE({event:"close",data:Y}))},Ke=!!K&&!B.has(K);for(K&&B.add(K),k.add(J,Ke),T.onAbort(()=>{D(),k.dropped(J)}),await T.writeSSE({event:"hello",data:E,retry:cf});!T.aborted;)await T.sleep(3e4)})),A.use("/__open",_),A.post("/__open",async b=>{let T="";try{T=String((await b.req.json()).url??"")}catch{}if(!zN(T))return b.json({error:"a local http URL is required"},400);let R=[...k].find(L=>L.inEditor);return await R?.open(T),b.json({opened:!!R,pages:k.count})})),A.use("/__stop",_),A.post("/__stop",async b=>{if(b.req.header("sec-fetch-site")||b.req.header("origin"))return b.text("Forbidden: browser request",403);let T="close";try{let L=await b.req.json();(L?.pages==="keep"||L?.pages==="close")&&(T=L.pages)}catch{}let R=T==="close"?await k.closeAll("stopped"):{told:0,gone:0};return v&&setTimeout(()=>{v({pages:T})},50),b.json({closed:R.gone,stuck:R.told-R.gone,exiting:!!v})}),A.get("/__pages",b=>b.json({pages:k.count})),A.notFound(async b=>{if(b.req.method!=="GET")return b.text("Not Found",404);let T=new URL(b.req.url);return Ik(T.pathname,T.search)?xe(b,"https://esm.sh"+T.pathname+T.search):b.text("Not Found",404)});let Pt=FN({fetch:A.fetch,port:s,hostname:JN});return Pt.listening||await new Promise((b,T)=>{let R=L=>T(L);Pt.once("error",R),Pt.once("listening",()=>{Pt.removeListener("error",R),b()})}),{port:s,close:()=>Pt.close(),requestPage:ye,closePages:b=>k.closeAll(b),pageCount:()=>k.count}}function Pp(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 Mk(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 Fk(decodeURIComponent(s.slice(e.length)),n)??r.text("Not Found",404)}catch{return r.text("Not Found",404)}})}async function Fk(t,e,n={}){let r=Cr(t,e),s=await _p.readFile(r).catch(()=>{});if(s)return new Response(s,{headers:{"Content-Type":rh(r),...n}})}Ie();gn();async function Wl(t){let{port:e,portNote:n,makeServerOptions:r,makeEntry:s,displayName:i,waitTarget:o,stopLog:a}=t,l=`http://localhost:${e}`,c=s(e,l),f=[],d,u=!1,p=async m=>{if(!u){u=!0,console.log(`
|
|
2924
|
+
Shutting down...`),(m?.pages??(be(c)?"keep":"close"))==="close"&&await d?.closePages("stopped"),d?.close();for(let g of f)try{await g()}catch{}a(),await yn(process.pid),process.exit(0)}},h=await jk({...r(e),onStop:p}).catch(async m=>{if(m?.code!=="EADDRINUSE")throw m;return cd(e)});return d=h,await yd(c),console.log(`
|
|
2925
2925
|
${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 E={fresh:g,external:v?"never":m==="window"?"force":"follow"},P=await h.requestPage(E);P.how==="attached"?console.log(` Reusing the open browser tab.
|
|
2926
2926
|
`):P.how==="editor"?console.log(` Opened in VS Code via ${P.via}.
|
|
2927
2927
|
`):P.how==="external"?console.log(` Opened in your browser.
|
|
2928
2928
|
`):console.log(` ${P.how==="unreached"?`Opened ${P.via?`in VS Code via ${P.via}`:"in your browser"}, but no page attached \u2014 is the browser it opened in still there?`:be(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."}
|
|
2929
2929
|
Share ${l}, and wake on the arrival:
|
|
2930
2930
|
typebulb wait ${o} --match "${st.connected}"
|
|
2931
|
-
`)},onCleanup(m){f.push(m)}}}gn();import
|
|
2932
|
-
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(md(++h));m(),console.log(`Loading ${Fn.basename(t)}...`);let{html:g,bulb:v,serverExports:E}=await pf(t,e.watch,e.trust,r);
|
|
2931
|
+
`)},onCleanup(m){f.push(m)}}}gn();import XN from"chokidar";import Uk from"node:fs";import QN from"node:path";var ZN={persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}};function rn(t){let{target:e,onChange:n,events:r="change",debounceMs:s=150}=t,i,o=XN.watch(e,ZN);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 eL=t=>process.platform==="win32"||process.platform==="darwin"?t.toLowerCase()==="assets":t==="assets";function qk(t,e,n=150){let r,s=()=>{r&&clearTimeout(r),r=setTimeout(e,n)};try{let i=Uk.watch(t,{recursive:!0},(o,a)=>{a&&eL(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=QN.join(t,"assets");return Uk.existsSync(i)?rn({target:i,onChange:e,events:"all",debounceMs:n}):()=>{}}}Ie();je();Tr();async function Jk(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=Ds(process.pid),o=e.watch?new tL:void 0,a=we(e.mode),l=(await mn(process.cwd()))(t),c=await or({kind:"bulb",file:t},process.cwd()),f=await la(t,c);f.length&&console.log(`Replacing the running server for this bulb (pid ${f.map(oe=>oe.pid).join(", ")})`);let d=f.length>0||Date.now()-l<_w,{port:u,note:p}=await ra({target:{kind:"bulb",file:t},cwd:process.cwd()});c!==void 0&&u!==c&&d&&(console.error(`
|
|
2932
|
+
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(md(++h));m(),console.log(`Loading ${Fn.basename(t)}...`);let{html:g,bulb:v,serverExports:E}=await pf(t,e.watch,e.trust,r);Kt(a,t,v.server);let P=_n(t),A=Pr(Fn.resolve(t)),$=e.trust?void 0:fr(v),{port:O,onCleanup:_,handOver:k,pageCount:N}=await Wl({port:u,portNote:p,displayName:v.name,stopLog:i,makeServerOptions:oe=>({getHtml:()=>g,basePath:s,fsBase:Or(t),port:oe,reloadEmitter:o,sendChannel:!0,getServerExports:()=>E,getBulbBlocks:()=>({infer:v.infer,insight:v.insight,code:v.code,config:v.config,data:v.data}),saveInferenceResult:async(ye,ke)=>{let ae=await sn.readFile(t,"utf-8");ye!==void 0&&(ae=Kr(ae,"data",ye.join(ry))),ke!==void 0&&(ae=Kr(ae,"insight",ke)),await sn.writeFile(t,ae)},localOverride:r?{name:r.name,serveDir:r.serveDir}:void 0,bulbAssets:{dir:P,remoteBase:A&&Mi(A.userSlug,A.slug)},sourceFile:t,bulbKey:Ls(t),trusted:e.trust,trustHint:n}),makeEntry:(oe,ye)=>({pid:process.pid,port:oe,url:ye,file:t,cwd:process.cwd(),startedAt:Date.now(),trust:e.trust,mode:e.mode,predicted:$,watch:e.watch?void 0:!1,replace:e.local?`${e.local.name}=${e.local.dir}`:void 0}),waitTarget:Fn.relative(process.cwd(),t)||Fn.basename(t)});e.trust?console.log(" trust: granted (filesystem, AI, server.ts enabled)"):console.log($?` trust: restricted \u2014 this bulb appears to use ${$}; re-run with --trust to enable it:
|
|
2933
2933
|
${n}
|
|
2934
2934
|
`:` trust: restricted \u2014 re-run with --trust to enable filesystem / AI / server.ts
|
|
2935
2935
|
`),e.watch&&console.log(` Watching for changes...
|
|
2936
|
-
`);let B,Z,q=()=>{N()===0&&console.log(" No page attached \u2014 nothing reloaded; this change is not live."),o?.emit("reload")},ie=oe=>{console.log(oe),m(),q()};if(e.watch&&o){let oe=0,ye=Promise.resolve();if(B=
|
|
2936
|
+
`);let B,Z,q=()=>{N()===0&&console.log(" No page attached \u2014 nothing reloaded; this change is not live."),o?.emit("reload")},ie=oe=>{console.log(oe),m(),q()};if(e.watch&&o){let oe=0,ye=Promise.resolve();if(B=rn({target:t,onChange:()=>{let ae=++oe;ye=ye.then(async()=>{if(ae===oe)try{console.log("Recompiling...");let xe=await pf(t,!0,e.trust,r);g=xe.html,E=xe.serverExports,v=xe.bulb,xe.buildError||m(),q()}catch(xe){console.error("Recompile failed:",xe)}})}}),r){let{name:ae,serveDir:xe}=r;Z=rn({target:xe,events:"all",onChange:()=>ie(`Local package '${ae}' changed.`)})}let ke=Or(t);await sn.stat(ke).then(ae=>ae.isDirectory()).catch(()=>!1)&&_(qk(ke,()=>ie("Assets changed.")))}B&&_(B),Z&&_(Z),_(()=>sn.rm(ff(t),{force:!0})),await k({mode:e.open,fresh:!d,replacedLive:f.some(oe=>oe.port===O)})}Ze();import{readFileSync as Ip,copyFileSync as rL,existsSync as sL,writeFileSync as iL,renameSync as oL,rmSync as aL}from"fs";import*as me from"path";import{fileURLToPath as lL}from"url";import{EventEmitter as cL}from"events";import uL from"open";gn();Ie();Tr();var Rp=t=>`/agents/${t}/client.js`,nL=`
|
|
2937
2937
|
(() => {
|
|
2938
2938
|
const api = async (name, ...args) => {
|
|
2939
2939
|
const resp = await fetch('/__api/' + name, {
|
|
@@ -2962,16 +2962,16 @@ Port ${c} is this bulb's, and a page of it may be waiting there, but something e
|
|
|
2962
2962
|
})
|
|
2963
2963
|
});
|
|
2964
2964
|
if (window.__TYPEBULB_WATCH__) {
|
|
2965
|
-
${
|
|
2965
|
+
${La()}
|
|
2966
2966
|
}
|
|
2967
2967
|
})();
|
|
2968
|
-
`;function
|
|
2968
|
+
`;function Wk(t){let{name:e,agent:n,styles:r,katex:s,mountHtml:i,watch:o,theme:a}=t,l=Rp(n);return`<!DOCTYPE html>
|
|
2969
2969
|
<html>
|
|
2970
2970
|
<head>
|
|
2971
2971
|
<meta charset="utf-8">
|
|
2972
2972
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
2973
|
-
<title>${
|
|
2974
|
-
${
|
|
2973
|
+
<title>${$a(e)} - typebulb</title>
|
|
2974
|
+
${Na(e,a)}
|
|
2975
2975
|
<style>
|
|
2976
2976
|
${Ts}
|
|
2977
2977
|
</style>
|
|
@@ -2988,18 +2988,18 @@ ${i}
|
|
|
2988
2988
|
${o?"<script>window.__TYPEBULB_WATCH__ = true;</script>":""}
|
|
2989
2989
|
|
|
2990
2990
|
<script>
|
|
2991
|
-
${
|
|
2991
|
+
${nL}
|
|
2992
2992
|
</script>
|
|
2993
2993
|
|
|
2994
2994
|
<script type="module" src="${l}"></script>
|
|
2995
2995
|
</body>
|
|
2996
|
-
</html>`}async function
|
|
2997
|
-
${r.url}`),t.open==="window"&&await
|
|
2998
|
-
`);async function B(){let q=await import("esbuild"),{outputFiles:ie}=await q.build({entryPoints:[me.join(_,"index.ts")],bundle:!0,platform:"browser",format:"esm",outfile:me.join(f,"client.js"),write:!1}),oe=me.join(f,"client.js"),ye=`${oe}.${process.pid}.tmp`;
|
|
2996
|
+
</html>`}async function Kk(t){let e=process.cwd(),n=t.agentTarget;OS(n)||(console.error(`Unknown agent '${n}'. Known: ${jr().join(", ")}.`),process.exit(1));let r=await aa(e,n);if(r){console.log(`Mirror '${n}' is already running for this project:
|
|
2997
|
+
${r.url}`),t.open==="window"&&await uL(r.url);return}let s=Ds(process.pid),i=t.watch?new cL:void 0,o=we(t.mode),a=await PS(n),l=a.displayName||`${n} mirror`;Kt(o,me.join(e,"mirror"));let c=me.dirname(lL(import.meta.url)),f=me.join(c,"agents",n),d=me.join(c,"..","cli","agents"),u=me.join(f,"styles.css"),p=me.join(f,"katex.min.css"),h=me.join(f,"index.html"),m=()=>Wk({name:l,agent:n,styles:Ip(u,"utf8"),katex:Ip(p,"utf8"),mountHtml:Ip(h,"utf8"),watch:t.watch}),{port:g,note:v}=await ra({explicit:t.port,target:{kind:"mirror",agent:n},cwd:e}),{port:E,url:P,onCleanup:A,handOver:$,pageCount:O}=await Wl({port:g,portNote:v,displayName:l,stopLog:s,waitTarget:"agent",makeServerOptions:q=>({getHtml:m,basePath:e,port:q,reloadEmitter:i,getServerExports:()=>a,trusted:!0,staticAssets:{mount:`${me.posix.dirname(Rp(n))}/`,dir:f}}),makeEntry:(q,ie)=>({pid:process.pid,port:q,url:ie,file:`agent:${n}`,cwd:e,startedAt:Date.now(),trust:!0,agent:n})}),_=me.join(d,n,"client"),k=me.join(d,"core","client"),N=sL(_);t.watch&&N&&console.log(` Watching for changes...
|
|
2998
|
+
`);async function B(){let q=await import("esbuild"),{outputFiles:ie}=await q.build({entryPoints:[me.join(_,"index.ts")],bundle:!0,platform:"browser",format:"esm",outfile:me.join(f,"client.js"),write:!1}),oe=me.join(f,"client.js"),ye=`${oe}.${process.pid}.tmp`;iL(ye,ie[0].contents);for(let ke=1;;ke++)try{oL(ye,oe);break}catch(ae){if(ke===10)throw aL(ye,{force:!0}),ae;await new Promise(xe=>setTimeout(xe,50))}for(let ke of["styles.css","index.html","typebulb.png","typebulb-inv.png"])rL(me.join(k,ke),me.join(f,ke))}let Z;if(t.watch&&N&&i){let q=!1;Z=rn({target:d,events:"all",onChange:async()=>{if(!q){q=!0;try{await B(),console.log(O()?`Mirror rebuilt. Reloading.
|
|
2999
2999
|
`:`Mirror rebuilt. No tab open on it \u2014 nobody is reading this.
|
|
3000
|
-
`),i.emit("reload")}catch(ie){console.error("Mirror rebuild failed:",ie instanceof Error?ie.message:ie)}finally{q=!1}}}})}await $({mode:t.open,fresh:!1,replacedLive:!1}),A(()=>a.shutdownSwitcher?.()),A(()=>a.shutdownComposer?.()),Z&&A(Z)}Ze();
|
|
3001
|
-
`);let a=0,l=Promise.resolve();
|
|
3002
|
-
`)}catch(u){
|
|
3003
|
-
`),
|
|
3004
|
-
`),process.exit(1)}function
|
|
3005
|
-
${e}`),process.exit(1))}async function
|
|
3000
|
+
`),i.emit("reload")}catch(ie){console.error("Mirror rebuild failed:",ie instanceof Error?ie.message:ie)}finally{q=!1}}}})}await $({mode:t.open,fresh:!1,replacedLive:!1}),A(()=>a.shutdownSwitcher?.()),A(()=>a.shutdownComposer?.()),Z&&A(Z)}Ze();Et();import*as Hk from"path";async function zk(t,e,n,r){let s=we(n),i=!1,o=async()=>{let{bulb:a,config:l}=await nt(t);i||(Kt(s,t,a.server),i=!0),await si(a.server,t,r,l.dependencies)};if(console.log(`Running ${Hk.basename(t)}...`),await o(),e){console.log(`Watching for changes...
|
|
3001
|
+
`);let a=0,l=Promise.resolve();rn({target:t,onChange:()=>{let c=++a;l=l.then(async()=>{if(c===a)try{console.log("Re-running..."),await o()}catch(f){console.error("Error:",f)}})}})}}Ze();Et();import{Console as dL}from"node:console";Ie();async function Gk(t,e,n,r){gL();try{let u=bn(await G(),t)[0];u&&(Ms(u.pid,Xe(u.pid).offset),console.error(`note: 'call' boots a fresh server.ts instance; the running server (${u.url}) is not contacted \u2014 state shared with it must live on disk.`))}catch{}let s=we(n),{bulb:i,config:o}=await nt(t);i.server||Oi("This bulb has no **server.ts** block; nothing to call."),Kt(s,t,i.server);let a;try{a=await si(i.server,t,r,o.dependencies)}catch(u){Oi(u instanceof Error?u.message:String(u))}let l=ql(a,e.fn);if(!l){let u=[...Object.keys(a).filter(p=>typeof a[p]=="function"),...Object.keys(Ul)];Oi(`Function '${e.fn}' not found. Available: ${u.length?u.join(", "):"(none)"}.`)}let c=await fL(e);if(Jl(l)){try{for await(let u of l(...c))await Vk(JSON.stringify(u,Xk)+`
|
|
3002
|
+
`)}catch(u){Oi(u instanceof Error?u.stack??u.message:String(u))}return Yk(0)}let f;try{f=await l(...c)}catch(u){Oi(u instanceof Error?u.stack??u.message:String(u))}let d=mL(f);d!==void 0&&await Vk(d+`
|
|
3003
|
+
`),Yk(0)}function Yk(t){process.exitCode=t,setTimeout(()=>process.exit(t),2e3).unref?.()}async function fL(t){if(t.hasArgsFlag){let e=t.argsJson??"";return e==="-"&&(e=await Jr()),hL(e)}return pL(t.positional)}function pL(t){return t.map(e=>{try{return JSON.parse(e)}catch{return e}})}function hL(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 mL(t){if(t!==void 0)return JSON.stringify(t,Xk,2)}function Xk(t,e){return typeof e=="bigint"?e.toString():e}function Oi(t){process.stderr.write(t+`
|
|
3004
|
+
`),process.exit(1)}function gL(){let t=new dL(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 Vk(t){return new Promise((e,n)=>{process.stdout.write(t,r=>r?n(r):e())})}sa();for(let t of[process.stdout,process.stderr])t.on("error",e=>{if(e?.code!=="EPIPE")throw e});function Qk(t,e){t||(console.error(`This bulb runs server-side Node code (server.ts), which --trust must authorize:
|
|
3005
|
+
${e}`),process.exit(1))}async function yL(){let t=IS(process.argv.slice(2));if(t.version&&(console.log(`typebulb ${Oe}`),process.exit(0)),t.help&&($S(),process.exit(0)),_S(),t.subcommand==="logs"){await fk(t.file||void 0,{follow:t.follow,clear:t.clear,run:t.run,lines:t.lines});return}if(t.subcommand==="wait"){await pk(t.file||void 0,{match:t.match,timeoutSec:t.timeoutSec,wake:t.wake});return}if(t.subcommand==="stop"){t.stopScope?await gk(t.stopScope):await mk(t.file||void 0);return}if(t.subcommand==="restart"){await yk(t.file||void 0,t.stopScope);return}if(t.subcommand==="babysit"){await _k(t.mode);return}if(t.subcommand==="send"){await wk(t.file,t.sendMessage,t.sendWaitMs??0);return}if(t.subcommand==="models"){await ik(t.mode);return}if(t.subcommand==="slug"){ok(t.slugName);return}if(t.subcommand==="status"){await Tk(t.statusQuery,t.mode);return}if(t.subcommand==="pull"){await Uw(t.file||void 0,{force:t.force,mode:t.mode});return}if(t.subcommand==="push"){await Jw(t.file||void 0,{force:t.force,mode:t.mode});return}if(t.subcommand==="agent"){await(t.agentTarget?Kk(t):sk(Oe));return}if(t.subcommand==="trust"||t.subcommand==="untrust"){await ek(t.file||void 0,t.subcommand==="trust");return}let e;if(!t.file||t.file==="."){let l=await jw(process.cwd());l||(console.error("No .bulb.md file found in current directory"),process.exit(1)),e=l}else e=Ot.resolve(t.file);if(await Zk.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}`+(Ot.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 Sk(e,t.blockKind);return}if(t.subcommand==="put"){await Ek(e,t.blockPairs);return}let r=t.file&&t.file!=="."?t.file:Ot.relative(process.cwd(),e)||Ot.basename(e),s=`npx typebulb --trust ${r.includes(" ")?`"${r}"`:r}`;if(t.subcommand==="predict"){await ZS(e,s);return}let i=!t.noTrust&&kn(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 Up(t.local)}catch(l){console.error(l instanceof Error?l.message:String(l)),process.exit(1)}console.error(`replace: ${a.name} \u2192 ${Ot.relative(process.cwd(),a.dir)||"."}`)}if(t.subcommand==="check"){await QS(e,a);return}if(t.subcommand==="call"){Qk(t.trust,s),await Gk(e,{fn:t.fn,positional:t.callArgs,argsJson:t.argsJson,hasArgsFlag:t.hasArgsFlag},t.mode,a);return}if(o&&o.bulb.server&&(ca(o.bulb)||t.server)){Qk(t.trust,s),await zk(e,t.watch,t.mode,a);return}await Jk(e,t,s,a)}yL().catch(t=>{console.error("Error:",t.message),process.exit(1)});
|